Changeset 8a1d95af for src/Concurrency/Keywords.cc
- Timestamp:
- Aug 14, 2021, 8:48:49 AM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, pthread-emulation, qualifiedEnum
- Children:
- f79ee0d
- Parents:
- c99a0d1 (diff), 6d63c14 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Concurrency/Keywords.cc
rc99a0d1 r8a1d95af 302 302 void postvisit( FunctionDecl * decl ); 303 303 void postvisit( StructDecl * decl ); 304 Statement * postmutate( MutexStmt * stmt ); 304 305 305 306 std::list<DeclarationWithType*> findMutexArgs( FunctionDecl*, bool & first ); … … 307 308 void addDtorStatements( FunctionDecl* func, CompoundStmt *, const std::list<DeclarationWithType * > &); 308 309 void addStatements( FunctionDecl* func, CompoundStmt *, const std::list<DeclarationWithType * > &); 310 void addStatements( CompoundStmt * body, const std::list<Expression * > & args ); 309 311 void addThreadDtorStatements( FunctionDecl* func, CompoundStmt * body, const std::list<DeclarationWithType * > & args ); 310 312 … … 312 314 PassVisitor< MutexKeyword > impl; 313 315 acceptAll( translationUnit, impl ); 316 mutateAll( translationUnit, impl ); 314 317 } 315 318 … … 935 938 thread_guard_decl = decl; 936 939 } 940 } 941 942 Statement * MutexKeyword::postmutate( MutexStmt * stmt ) { 943 std::list<Statement *> stmtsForCtor; 944 stmtsForCtor.push_back(stmt->stmt); 945 CompoundStmt * body = new CompoundStmt( stmtsForCtor ); 946 addStatements( body, stmt->mutexObjs); 947 return body; 937 948 } 938 949 … … 1058 1069 )) 1059 1070 ); 1071 } 1072 1073 void MutexKeyword::addStatements( CompoundStmt * body, const std::list<Expression * > & args ) { 1074 ObjectDecl * monitors = new ObjectDecl( 1075 "__monitors", 1076 noStorageClasses, 1077 LinkageSpec::Cforall, 1078 nullptr, 1079 new ArrayType( 1080 noQualifiers, 1081 new PointerType( 1082 noQualifiers, 1083 new StructInstType( 1084 noQualifiers, 1085 monitor_decl 1086 ) 1087 ), 1088 new ConstantExpr( Constant::from_ulong( args.size() ) ), 1089 false, 1090 false 1091 ), 1092 new ListInit( 1093 map_range < std::list<Initializer*> > ( args, [](Expression * var ){ 1094 return new SingleInit( new UntypedExpr( 1095 new NameExpr( "get_monitor" ), 1096 { var } 1097 ) ); 1098 }) 1099 ) 1100 ); 1101 1102 // in reverse order : 1103 // monitor_guard_t __guard = { __monitors, # }; 1104 body->push_front( 1105 new DeclStmt( new ObjectDecl( 1106 "__guard", 1107 noStorageClasses, 1108 LinkageSpec::Cforall, 1109 nullptr, 1110 new StructInstType( 1111 noQualifiers, 1112 guard_decl 1113 ), 1114 new ListInit( 1115 { 1116 new SingleInit( new VariableExpr( monitors ) ), 1117 new SingleInit( new ConstantExpr( Constant::from_ulong( args.size() ) ) ) 1118 }, 1119 noDesignators, 1120 true 1121 ) 1122 )) 1123 ); 1124 1125 //monitor$ * __monitors[] = { get_monitor(a), get_monitor(b) }; 1126 body->push_front( new DeclStmt( monitors) ); 1060 1127 } 1061 1128
Note: See TracChangeset
for help on using the changeset viewer.