- Timestamp:
- Jun 21, 2022, 1:39:24 PM (3 years ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
- Children:
- b62d1d6
- Parents:
- 1df492a (diff), 1dbbef6 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src
- Files:
-
- 1 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Pass.impl.hpp
r1df492a reb5962a 182 182 183 183 // get the stmts/decls that will need to be spliced in 184 auto stmts_before = __pass::stmtsToAddBefore( core, 0 );185 auto stmts_after = __pass::stmtsToAddAfter ( core, 0 );186 auto decls_before = __pass::declsToAddBefore( core, 0 );187 auto decls_after = __pass::declsToAddAfter ( core, 0 );184 auto stmts_before = __pass::stmtsToAddBefore( core, 0 ); 185 auto stmts_after = __pass::stmtsToAddAfter ( core, 0 ); 186 auto decls_before = __pass::declsToAddBefore( core, 0 ); 187 auto decls_after = __pass::declsToAddAfter ( core, 0 ); 188 188 189 189 // These may be modified by subnode but most be restored once we exit this statemnet. … … 287 287 288 288 // get the stmts/decls that will need to be spliced in 289 auto stmts_before = __pass::stmtsToAddBefore( core, 0 );290 auto stmts_after = __pass::stmtsToAddAfter ( core, 0 );291 auto decls_before = __pass::declsToAddBefore( core, 0 );292 auto decls_after = __pass::declsToAddAfter ( core, 0 );289 auto stmts_before = __pass::stmtsToAddBefore( core, 0 ); 290 auto stmts_after = __pass::stmtsToAddAfter ( core, 0 ); 291 auto decls_before = __pass::declsToAddBefore( core, 0 ); 292 auto decls_after = __pass::declsToAddAfter ( core, 0 ); 293 293 294 294 // These may be modified by subnode but most be restored once we exit this statemnet. … … 317 317 assert(( empty( stmts_before ) && empty( stmts_after )) 318 318 || ( empty( decls_before ) && empty( decls_after )) ); 319 320 321 319 322 320 // Take all the statements which should have gone after, N/A for first iteration … … 2116 2114 if ( __visit_children() ) { 2117 2115 bool mutated = false; 2118 std::unordered_map< ast::TypeInstType::TypeEnvKey, ast::ptr< ast::Type > >new_map;2119 for ( const auto & p : node->type Env) {2116 ast::TypeSubstitution::TypeMap new_map; 2117 for ( const auto & p : node->typeMap ) { 2120 2118 guard_symtab guard { *this }; 2121 2119 auto new_node = p.second->accept( *this ); … … 2125 2123 if (mutated) { 2126 2124 auto new_node = __pass::mutate<core_t>( node ); 2127 new_node->type Env.swap( new_map );2125 new_node->typeMap.swap( new_map ); 2128 2126 node = new_node; 2129 2127 } -
src/AST/TypeSubstitution.cpp
r1df492a reb5962a 38 38 39 39 void TypeSubstitution::initialize( const TypeSubstitution &src, TypeSubstitution &dest ) { 40 dest.type Env.clear();40 dest.typeMap.clear(); 41 41 dest.add( src ); 42 42 } 43 43 44 44 void TypeSubstitution::add( const TypeSubstitution &other ) { 45 for ( Type EnvType::const_iterator i = other.typeEnv.begin(); i != other.typeEnv.end(); ++i ) {46 type Env[ i->first ] = i->second;45 for ( TypeMap::const_iterator i = other.typeMap.begin(); i != other.typeMap.end(); ++i ) { 46 typeMap[ i->first ] = i->second; 47 47 } // for 48 48 } 49 49 50 50 void TypeSubstitution::add( const TypeInstType * formalType, const Type *actualType ) { 51 type Env[ *formalType ] = actualType;51 typeMap[ *formalType ] = actualType; 52 52 } 53 53 54 54 void TypeSubstitution::add( const TypeInstType::TypeEnvKey & key, const Type * actualType) { 55 type Env[ key ] = actualType;55 typeMap[ key ] = actualType; 56 56 } 57 57 58 58 void TypeSubstitution::remove( const TypeInstType * formalType ) { 59 TypeEnvType::iterator i = typeEnv.find( *formalType ); 60 if ( i != typeEnv.end() ) { 61 typeEnv.erase( *formalType ); 62 } // if 63 } 64 65 const Type *TypeSubstitution::lookup( const TypeInstType * formalType ) const { 66 TypeEnvType::const_iterator i = typeEnv.find( *formalType ); 59 TypeMap::iterator i = typeMap.find( *formalType ); 60 if ( i != typeMap.end() ) { 61 typeMap.erase( *formalType ); 62 } // if 63 } 64 65 const Type *TypeSubstitution::lookup( 66 const TypeInstType::TypeEnvKey & formalType ) const { 67 TypeMap::const_iterator i = typeMap.find( formalType ); 67 68 68 69 // break on not in substitution set 69 if ( i == type Env.end() ) return 0;70 if ( i == typeMap.end() ) return 0; 70 71 71 72 // attempt to transitively follow TypeInstType links. 72 73 while ( const TypeInstType *actualType = i->second.as<TypeInstType>()) { 73 74 // break cycles in the transitive follow 74 if ( *formalType == *actualType ) break;75 if ( formalType == *actualType ) break; 75 76 76 77 // Look for the type this maps to, returning previous mapping if none-such 77 i = type Env.find( *actualType );78 if ( i == type Env.end() ) return actualType;78 i = typeMap.find( *actualType ); 79 if ( i == typeMap.end() ) return actualType; 79 80 } 80 81 … … 83 84 } 84 85 86 const Type *TypeSubstitution::lookup( const TypeInstType * formalType ) const { 87 return lookup( ast::TypeInstType::TypeEnvKey( *formalType ) ); 88 } 89 85 90 bool TypeSubstitution::empty() const { 86 return type Env.empty();91 return typeMap.empty(); 87 92 } 88 93 … … 119 124 sub.core.subCount = 0; 120 125 sub.core.freeOnly = true; 121 for ( Type EnvType::iterator i = typeEnv.begin(); i != typeEnv.end(); ++i ) {126 for ( TypeMap::iterator i = typeMap.begin(); i != typeMap.end(); ++i ) { 122 127 i->second = i->second->accept( sub ); 123 128 } … … 129 134 if ( bound != boundVars.end() ) return inst; 130 135 131 Type EnvType::const_iterator i = sub.typeEnv.find( *inst );132 if ( i == sub.type Env.end() ) {136 TypeMap::const_iterator i = sub.typeMap.find( *inst ); 137 if ( i == sub.typeMap.end() ) { 133 138 return inst; 134 139 } else { -
src/AST/TypeSubstitution.hpp
r1df492a reb5962a 75 75 void add( const TypeSubstitution &other ); 76 76 void remove( const TypeInstType * formalType ); 77 const Type *lookup( const TypeInstType::TypeEnvKey & formalType ) const; 77 78 const Type *lookup( const TypeInstType * formalType ) const; 78 79 bool empty() const; … … 104 105 friend class Pass; 105 106 106 typedef std::unordered_map< TypeInstType::TypeEnvKey, ptr<Type> > Type EnvType;107 Type EnvType typeEnv;107 typedef std::unordered_map< TypeInstType::TypeEnvKey, ptr<Type> > TypeMap; 108 TypeMap typeMap; 108 109 109 110 public: 110 // has to come after declaration of type Env111 auto begin() -> decltype( type Env.begin() ) { return typeEnv.begin(); }112 auto end() -> decltype( type Env. end() ) { return typeEnv. end(); }113 auto begin() const -> decltype( type Env.begin() ) { return typeEnv.begin(); }114 auto end() const -> decltype( type Env. end() ) { return typeEnv. end(); }111 // has to come after declaration of typeMap 112 auto begin() -> decltype( typeMap.begin() ) { return typeMap.begin(); } 113 auto end() -> decltype( typeMap. end() ) { return typeMap. end(); } 114 auto begin() const -> decltype( typeMap.begin() ) { return typeMap.begin(); } 115 auto end() const -> decltype( typeMap. end() ) { return typeMap. end(); } 115 116 116 117 }; … … 144 145 if ( const TypeExpr *actual = actualIt->template as<TypeExpr>() ) { 145 146 if ( formal->name != "" ) { 146 type Env[ formal ] = actual->type;147 typeMap[ formal ] = actual->type; 147 148 } // if 148 149 } else { -
src/Concurrency/Waitfor.cc
r1df492a reb5962a 56 56 | | 57 57 | | 58 58 | | 59 59 | | 60 60 | | -
src/Concurrency/Waitfor.h
r1df492a reb5962a 19 19 20 20 class Declaration; 21 namespace ast { 22 class TranslationUnit; 23 } 21 24 22 25 namespace Concurrency { 23 26 void generateWaitFor( std::list< Declaration * > & translationUnit ); 27 28 void generateWaitFor( ast::TranslationUnit & translationUnit ); 24 29 }; 25 30 -
src/Concurrency/module.mk
r1df492a reb5962a 19 19 Concurrency/Keywords.cc \ 20 20 Concurrency/Keywords.h \ 21 Concurrency/WaitforNew.cpp \ 21 22 Concurrency/Waitfor.cc \ 22 23 Concurrency/Waitfor.h -
src/GenPoly/Specialize.cc
r1df492a reb5962a 247 247 structureArg( (*actualBegin)->get_type(), argBegin, argEnd, back_inserter( appExpr->get_args() ) ); 248 248 } 249 assertf( argBegin == argEnd, "Did not structure all arguments." ); 249 250 250 251 appExpr->env = TypeSubstitution::newFromExpr( appExpr, env ); -
src/InitTweak/FixGlobalInit.cc
r1df492a reb5962a 162 162 } // if 163 163 if ( Statement * ctor = ctorInit->ctor ) { 164 addDataSect onAttribute( objDecl );164 addDataSectionAttribute( objDecl ); 165 165 initStatements.push_back( ctor ); 166 166 objDecl->init = nullptr; -
src/InitTweak/FixInit.cc
r1df492a reb5962a 806 806 // The attribute works, and is meant to apply, both for leaving the static local alone, 807 807 // and for hoisting it out as a static global. 808 addDataSect onAttribute( objDecl );808 addDataSectionAttribute( objDecl ); 809 809 810 810 // originally wanted to take advantage of gcc nested functions, but -
src/InitTweak/InitTweak.cc
r1df492a reb5962a 587 587 588 588 bool isConstructable( const ast::Type * type ) { 589 return ! dynamic_cast< const ast::VarArgsType * >( type ) && ! dynamic_cast< const ast::ReferenceType * >( type ) 589 return ! dynamic_cast< const ast::VarArgsType * >( type ) && ! dynamic_cast< const ast::ReferenceType * >( type ) 590 590 && ! dynamic_cast< const ast::FunctionType * >( type ) && ! Tuples::isTtype( type ); 591 591 } … … 1025 1025 if (!assign) { 1026 1026 auto td = new ast::TypeDecl({}, "T", {}, nullptr, ast::TypeDecl::Dtype, true); 1027 assign = new ast::FunctionDecl({}, "?=?", {}, 1027 assign = new ast::FunctionDecl({}, "?=?", {}, 1028 1028 { new ast::ObjectDecl({}, "_dst", new ast::ReferenceType(new ast::TypeInstType("T", td))), 1029 1029 new ast::ObjectDecl({}, "_src", new ast::TypeInstType("T", td))}, … … 1095 1095 1096 1096 // address of a variable or member expression is constexpr 1097 if ( ! dynamic_cast< const ast::NameExpr * >( arg ) 1098 && ! dynamic_cast< const ast::VariableExpr * >( arg ) 1099 && ! dynamic_cast< const ast::MemberExpr * >( arg ) 1097 if ( ! dynamic_cast< const ast::NameExpr * >( arg ) 1098 && ! dynamic_cast< const ast::VariableExpr * >( arg ) 1099 && ! dynamic_cast< const ast::MemberExpr * >( arg ) 1100 1100 && ! dynamic_cast< const ast::UntypedMemberExpr * >( arg ) ) result = false; 1101 1101 } … … 1241 1241 } 1242 1242 1243 void addDataSectonAttribute( ObjectDecl * objDecl ) { 1243 #if defined( __x86_64 ) || defined( __i386 ) // assembler comment to prevent assembler warning message 1244 #define ASM_COMMENT "#" 1245 #else // defined( __ARM_ARCH ) 1246 #define ASM_COMMENT "//" 1247 #endif 1248 static const char * const data_section = ".data" ASM_COMMENT; 1249 static const char * const tlsd_section = ".tdata" ASM_COMMENT; 1250 void addDataSectionAttribute( ObjectDecl * objDecl ) { 1251 const bool is_tls = objDecl->get_storageClasses().is_threadlocal; 1252 const char * section = is_tls ? tlsd_section : data_section; 1244 1253 objDecl->attributes.push_back(new Attribute("section", { 1245 new ConstantExpr( Constant::from_string(".data" 1246 #if defined( __x86_64 ) || defined( __i386 ) // assembler comment to prevent assembler warning message 1247 "#" 1248 #else // defined( __ARM_ARCH ) 1249 "//" 1250 #endif 1251 ))})); 1254 new ConstantExpr( Constant::from_string( section ) ) 1255 })); 1252 1256 } 1253 1257 1254 1258 void addDataSectionAttribute( ast::ObjectDecl * objDecl ) { 1259 const bool is_tls = objDecl->storage.is_threadlocal; 1260 const char * section = is_tls ? tlsd_section : data_section; 1255 1261 objDecl->attributes.push_back(new ast::Attribute("section", { 1256 ast::ConstantExpr::from_string(objDecl->location, ".data" 1257 #if defined( __x86_64 ) || defined( __i386 ) // assembler comment to prevent assembler warning message 1258 "#" 1259 #else // defined( __ARM_ARCH ) 1260 "//" 1261 #endif 1262 )})); 1262 ast::ConstantExpr::from_string(objDecl->location, section) 1263 })); 1263 1264 } 1264 1265 -
src/InitTweak/InitTweak.h
r1df492a reb5962a 127 127 /// .section .data#,"a" 128 128 /// to avoid assembler warning "ignoring changed section attributes for .data" 129 void addDataSect onAttribute( ObjectDecl * objDecl );129 void addDataSectionAttribute( ObjectDecl * objDecl ); 130 130 131 131 void addDataSectionAttribute( ast::ObjectDecl * objDecl ); -
src/main.cc
r1df492a reb5962a 10 10 // Created On : Fri May 15 23:12:02 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Apr 29 9:52:00 202213 // Update Count : 67 312 // Last Modified On : Tue Jun 7 13:29:00 2022 13 // Update Count : 674 14 14 // 15 15 … … 447 447 PASS( "Expand Unique Expr", Tuples::expandUniqueExpr( transUnit ) ); // xxx - is this the right place for this? want to expand ASAP so tha, sequent passes don't need to worry about double-visiting a unique expr - needs to go after InitTweak::fix so that copy constructed return declarations are reused 448 448 449 PASS( "Translate Tries" , ControlStruct::translateTries( transUnit ) ); 449 PASS( "Translate Tries", ControlStruct::translateTries( transUnit ) ); 450 PASS( "Gen Waitfor", Concurrency::generateWaitFor( transUnit ) ); 450 451 451 452 translationUnit = convert( move( transUnit ) ); … … 517 518 518 519 PASS( "Expand Unique Expr", Tuples::expandUniqueExpr( translationUnit ) ); // xxx - is this the right place for this? want to expand ASAP so tha, sequent passes don't need to worry about double-visiting a unique expr - needs to go after InitTweak::fix so that copy constructed return declarations are reused 519 520 PASS( " Translate Tries" , ControlStruct::translateTries( translationUnit ) );520 PASS( "Translate Tries", ControlStruct::translateTries( translationUnit ) ); 521 PASS( "Gen Waitfor", Concurrency::generateWaitFor( translationUnit ) ); 521 522 } 522 523 PASS( "Gen Waitfor" , Concurrency::generateWaitFor( translationUnit ) );524 523 525 524 PASS( "Convert Specializations", GenPoly::convertSpecializations( translationUnit ) ); // needs to happen before tuple types are expanded
Note:
See TracChangeset
for help on using the changeset viewer.