Changes in / [4acc87f:d029162e]
- Location:
- src
- Files:
-
- 2 added
- 6 edited
-
CodeGen/CodeGenerator.cc (modified) (35 diffs)
-
InitTweak/FixGlobalInit.cc (added)
-
InitTweak/FixGlobalInit.h (added)
-
InitTweak/module.mk (modified) (1 diff)
-
Makefile.in (modified) (6 diffs)
-
SynTree/Declaration.h (modified) (4 diffs)
-
SynTree/FunctionDecl.cc (modified) (7 diffs)
-
main.cc (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r4acc87f rd029162e 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // CodeGenerator.cc -- 7 // CodeGenerator.cc -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Mar 2 17:32:16201611 // Last Modified By : Rob Schluntz 12 // Last Modified On : Fri May 06 11:39:01 2016 13 13 // Update Count : 243 14 14 // … … 84 84 output << genType( functionDecl->get_functionType(), mangleName( functionDecl ) ); 85 85 86 // generalize this 87 switch ( functionDecl->get_attribute() ) { 88 case FunctionDecl::Constructor: 89 output << " __attribute__ ((constructor))"; 90 break; 91 case FunctionDecl::Destructor: 92 output << " __attribute__ ((destructor))"; 93 break; 94 default: 95 break; 96 } 97 86 98 // how to get this to the Functype? 87 99 std::list< Declaration * > olds = functionDecl->get_oldDecls(); … … 99 111 handleStorageClass( objectDecl ); 100 112 output << genType( objectDecl->get_type(), mangleName( objectDecl ) ); 101 113 102 114 if ( objectDecl->get_init() ) { 103 115 output << " = "; … … 113 125 if ( aggDecl->get_name() != "" ) 114 126 output << aggDecl->get_name(); 115 127 116 128 std::list< Declaration * > &memb = aggDecl->get_members(); 117 129 … … 119 131 output << " {" << endl; 120 132 121 cur_indent += CodeGenerator::tabsize; 133 cur_indent += CodeGenerator::tabsize; 122 134 for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end(); i++) { 123 output << indent; 135 output << indent; 124 136 (*i)->accept( *this ); 125 137 output << ";" << endl; 126 138 } 127 139 128 cur_indent -= CodeGenerator::tabsize; 140 cur_indent -= CodeGenerator::tabsize; 129 141 130 142 output << indent << "}"; … … 141 153 handleAggregate( aggregateDecl ); 142 154 } 143 155 144 156 void CodeGenerator::visit( EnumDecl *aggDecl ) { 145 157 output << "enum "; … … 147 159 if ( aggDecl->get_name() != "" ) 148 160 output << aggDecl->get_name(); 149 161 150 162 std::list< Declaration* > &memb = aggDecl->get_members(); 151 163 … … 153 165 output << " {" << endl; 154 166 155 cur_indent += CodeGenerator::tabsize; 167 cur_indent += CodeGenerator::tabsize; 156 168 for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end(); i++) { 157 169 ObjectDecl *obj = dynamic_cast< ObjectDecl* >( *i ); 158 170 assert( obj ); 159 output << indent << mangleName( obj ); 171 output << indent << mangleName( obj ); 160 172 if ( obj->get_init() ) { 161 173 output << " = "; … … 165 177 } // for 166 178 167 cur_indent -= CodeGenerator::tabsize; 179 cur_indent -= CodeGenerator::tabsize; 168 180 169 181 output << indent << "}"; 170 182 } // if 171 183 } 172 184 173 185 void CodeGenerator::visit( TraitDecl *aggregateDecl ) {} 174 186 175 187 void CodeGenerator::visit( TypedefDecl *typeDecl ) { 176 188 output << "typedef "; 177 189 output << genType( typeDecl->get_base(), typeDecl->get_name() ); 178 190 } 179 191 180 192 void CodeGenerator::visit( TypeDecl *typeDecl ) { 181 193 // really, we should mutate this into something that isn't a TypeDecl but that requires large-scale changes, … … 217 229 } 218 230 219 void CodeGenerator::visit( Constant *constant ) { 231 void CodeGenerator::visit( Constant *constant ) { 220 232 output << constant->get_value() ; 221 233 } … … 234 246 assert( arg != applicationExpr->get_args().end() ); 235 247 if ( AddressExpr *addrExpr = dynamic_cast< AddressExpr * >( *arg ) ) { 236 248 237 249 *arg = addrExpr->get_arg(); 238 250 } else { … … 243 255 break; 244 256 } 245 257 246 258 default: 247 259 // do nothing 248 260 ; 249 261 } 250 262 251 263 switch ( opInfo.type ) { 252 264 case OT_INDEX: … … 257 269 output << "]"; 258 270 break; 259 271 260 272 case OT_CALL: 261 273 // there are no intrinsic definitions of the function call operator 262 274 assert( false ); 263 275 break; 264 276 265 277 case OT_PREFIX: 266 278 case OT_PREFIXASSIGN: … … 271 283 output << ")"; 272 284 break; 273 285 274 286 case OT_POSTFIX: 275 287 case OT_POSTFIXASSIGN: … … 288 300 output << ")"; 289 301 break; 290 302 291 303 case OT_CONSTANT: 292 304 case OT_LABELADDRESS: … … 307 319 } // if 308 320 } 309 321 310 322 void CodeGenerator::visit( UntypedExpr *untypedExpr ) { 311 323 if ( NameExpr *nameExpr = dynamic_cast< NameExpr* >( untypedExpr->get_function() ) ) { … … 321 333 output << "]"; 322 334 break; 323 335 324 336 case OT_CALL: 325 337 assert( false ); 326 338 break; 327 339 328 340 case OT_PREFIX: 329 341 case OT_PREFIXASSIGN: … … 335 347 output << ")"; 336 348 break; 337 349 338 350 case OT_POSTFIX: 339 351 case OT_POSTFIXASSIGN: … … 342 354 output << opInfo.symbol; 343 355 break; 344 356 345 357 case OT_INFIX: 346 358 case OT_INFIXASSIGN: … … 352 364 output << ")"; 353 365 break; 354 366 355 367 case OT_CONSTANT: 356 368 // there are no intrinsic definitions of 0 or 1 as functions … … 370 382 } // if 371 383 } 372 384 373 385 void CodeGenerator::visit( NameExpr *nameExpr ) { 374 386 OperatorInfo opInfo; … … 380 392 } // if 381 393 } 382 394 383 395 void CodeGenerator::visit( AddressExpr *addressExpr ) { 384 396 output << "(&"; … … 409 421 output << ")"; 410 422 } 411 423 412 424 void CodeGenerator::visit( UntypedMemberExpr *memberExpr ) { 413 425 assert( false ); 414 426 } 415 427 416 428 void CodeGenerator::visit( MemberExpr *memberExpr ) { 417 429 memberExpr->get_aggregate()->accept( *this ); 418 430 output << "." << mangleName( memberExpr->get_member() ); 419 431 } 420 432 421 433 void CodeGenerator::visit( VariableExpr *variableExpr ) { 422 434 OperatorInfo opInfo; … … 427 439 } // if 428 440 } 429 441 430 442 void CodeGenerator::visit( ConstantExpr *constantExpr ) { 431 443 assert( constantExpr->get_constant() ); 432 444 constantExpr->get_constant()->accept( *this ); 433 445 } 434 446 435 447 void CodeGenerator::visit( SizeofExpr *sizeofExpr ) { 436 448 output << "sizeof("; … … 469 481 assert( false && "OffsetPackExpr should not reach code generation" ); 470 482 } 471 483 472 484 void CodeGenerator::visit( LogicalExpr *logicalExpr ) { 473 485 output << "("; … … 481 493 output << ")"; 482 494 } 483 495 484 496 void CodeGenerator::visit( ConditionalExpr *conditionalExpr ) { 485 497 output << "("; … … 491 503 output << ")"; 492 504 } 493 505 494 506 void CodeGenerator::visit( CommaExpr *commaExpr ) { 495 507 output << "("; … … 499 511 output << ")"; 500 512 } 501 513 502 514 void CodeGenerator::visit( TupleExpr *tupleExpr ) {} 503 515 504 516 void CodeGenerator::visit( TypeExpr *typeExpr ) {} 505 517 … … 532 544 } 533 545 } 534 cur_indent -= CodeGenerator::tabsize; 546 cur_indent -= CodeGenerator::tabsize; 535 547 536 548 output << indent << "}"; … … 538 550 539 551 void CodeGenerator::visit( ExprStmt *exprStmt ) { 540 // I don't see why this check is necessary. 541 // If this starts to cause problems then put it back in, 552 // I don't see why this check is necessary. 553 // If this starts to cause problems then put it back in, 542 554 // with an explanation 543 555 assert( exprStmt ); … … 589 601 switchStmt->get_condition()->accept( *this ); 590 602 output << " ) "; 591 603 592 604 output << "{" << std::endl; 593 605 cur_indent += CodeGenerator::tabsize; … … 609 621 } // if 610 622 output << ":\n"; 611 623 612 624 std::list<Statement *> sts = caseStmt->get_statements(); 613 625 … … 626 638 if ( ! branchStmt->get_target().empty() ) 627 639 output << "goto " << branchStmt->get_target(); 628 else { 640 else { 629 641 if ( branchStmt->get_computedTarget() != 0 ) { 630 642 output << "goto *"; … … 677 689 678 690 void CodeGenerator::visit( ForStmt *forStmt ) { 679 // initialization is always hoisted, so don't 680 // bother doing anything with that 691 // initialization is always hoisted, so don't 692 // bother doing anything with that 681 693 output << "for (;"; 682 694 … … 702 714 void CodeGenerator::visit( DeclStmt *declStmt ) { 703 715 declStmt->get_decl()->accept( *this ); 704 716 705 717 if ( doSemicolon( declStmt->get_decl() ) ) { 706 718 output << ";"; -
src/InitTweak/module.mk
r4acc87f rd029162e 11 11 ## Created On : Mon Jun 1 17:49:17 2015 12 12 ## Last Modified By : Rob Schluntz 13 ## Last Modified On : Mon Jan 11 14:40:16201613 ## Last Modified On : Wed May 04 16:03:49 2016 14 14 ## Update Count : 2 15 15 ############################################################################### 16 16 17 SRC += InitTweak/RemoveInit.cc 17 SRC += InitTweak/RemoveInit.cc \ 18 InitTweak/FixGlobalInit.cc 18 19 -
src/Makefile.in
r4acc87f rd029162e 124 124 GenPoly/driver_cfa_cpp-DeclMutator.$(OBJEXT) \ 125 125 InitTweak/driver_cfa_cpp-RemoveInit.$(OBJEXT) \ 126 InitTweak/driver_cfa_cpp-FixGlobalInit.$(OBJEXT) \ 126 127 Parser/driver_cfa_cpp-parser.$(OBJEXT) \ 127 128 Parser/driver_cfa_cpp-lex.$(OBJEXT) \ … … 346 347 GenPoly/CopyParams.cc GenPoly/FindFunction.cc \ 347 348 GenPoly/DeclMutator.cc InitTweak/RemoveInit.cc \ 348 Parser/parser.yy Parser/lex.ll Parser/TypedefTable.cc \ 349 Parser/ParseNode.cc Parser/DeclarationNode.cc \ 350 Parser/ExpressionNode.cc Parser/StatementNode.cc \ 351 Parser/InitializerNode.cc Parser/TypeData.cc \ 352 Parser/LinkageSpec.cc Parser/parseutility.cc Parser/Parser.cc \ 349 InitTweak/FixGlobalInit.cc Parser/parser.yy Parser/lex.ll \ 350 Parser/TypedefTable.cc Parser/ParseNode.cc \ 351 Parser/DeclarationNode.cc Parser/ExpressionNode.cc \ 352 Parser/StatementNode.cc Parser/InitializerNode.cc \ 353 Parser/TypeData.cc Parser/LinkageSpec.cc \ 354 Parser/parseutility.cc Parser/Parser.cc \ 353 355 ResolvExpr/AlternativeFinder.cc ResolvExpr/Alternative.cc \ 354 356 ResolvExpr/Unify.cc ResolvExpr/PtrsAssignable.cc \ … … 562 564 @: > InitTweak/$(DEPDIR)/$(am__dirstamp) 563 565 InitTweak/driver_cfa_cpp-RemoveInit.$(OBJEXT): \ 566 InitTweak/$(am__dirstamp) InitTweak/$(DEPDIR)/$(am__dirstamp) 567 InitTweak/driver_cfa_cpp-FixGlobalInit.$(OBJEXT): \ 564 568 InitTweak/$(am__dirstamp) InitTweak/$(DEPDIR)/$(am__dirstamp) 565 569 Parser/parser.h: Parser/parser.cc … … 792 796 -rm -f GenPoly/driver_cfa_cpp-ScrubTyVars.$(OBJEXT) 793 797 -rm -f GenPoly/driver_cfa_cpp-Specialize.$(OBJEXT) 798 -rm -f InitTweak/driver_cfa_cpp-FixGlobalInit.$(OBJEXT) 794 799 -rm -f InitTweak/driver_cfa_cpp-RemoveInit.$(OBJEXT) 795 800 -rm -f Parser/driver_cfa_cpp-DeclarationNode.$(OBJEXT) … … 897 902 @AMDEP_TRUE@@am__include@ @am__quote@GenPoly/$(DEPDIR)/driver_cfa_cpp-ScrubTyVars.Po@am__quote@ 898 903 @AMDEP_TRUE@@am__include@ @am__quote@GenPoly/$(DEPDIR)/driver_cfa_cpp-Specialize.Po@am__quote@ 904 @AMDEP_TRUE@@am__include@ @am__quote@InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Po@am__quote@ 899 905 @AMDEP_TRUE@@am__include@ @am__quote@InitTweak/$(DEPDIR)/driver_cfa_cpp-RemoveInit.Po@am__quote@ 900 906 @AMDEP_TRUE@@am__include@ @am__quote@Parser/$(DEPDIR)/driver_cfa_cpp-DeclarationNode.Po@am__quote@ … … 1380 1386 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/driver_cfa_cpp-RemoveInit.obj `if test -f 'InitTweak/RemoveInit.cc'; then $(CYGPATH_W) 'InitTweak/RemoveInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/RemoveInit.cc'; fi` 1381 1387 1388 InitTweak/driver_cfa_cpp-FixGlobalInit.o: InitTweak/FixGlobalInit.cc 1389 @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT InitTweak/driver_cfa_cpp-FixGlobalInit.o -MD -MP -MF InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Tpo -c -o InitTweak/driver_cfa_cpp-FixGlobalInit.o `test -f 'InitTweak/FixGlobalInit.cc' || echo '$(srcdir)/'`InitTweak/FixGlobalInit.cc 1390 @am__fastdepCXX_TRUE@ $(am__mv) InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Tpo InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Po 1391 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='InitTweak/FixGlobalInit.cc' object='InitTweak/driver_cfa_cpp-FixGlobalInit.o' libtool=no @AMDEPBACKSLASH@ 1392 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1393 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/driver_cfa_cpp-FixGlobalInit.o `test -f 'InitTweak/FixGlobalInit.cc' || echo '$(srcdir)/'`InitTweak/FixGlobalInit.cc 1394 1395 InitTweak/driver_cfa_cpp-FixGlobalInit.obj: InitTweak/FixGlobalInit.cc 1396 @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT InitTweak/driver_cfa_cpp-FixGlobalInit.obj -MD -MP -MF InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Tpo -c -o InitTweak/driver_cfa_cpp-FixGlobalInit.obj `if test -f 'InitTweak/FixGlobalInit.cc'; then $(CYGPATH_W) 'InitTweak/FixGlobalInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/FixGlobalInit.cc'; fi` 1397 @am__fastdepCXX_TRUE@ $(am__mv) InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Tpo InitTweak/$(DEPDIR)/driver_cfa_cpp-FixGlobalInit.Po 1398 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='InitTweak/FixGlobalInit.cc' object='InitTweak/driver_cfa_cpp-FixGlobalInit.obj' libtool=no @AMDEPBACKSLASH@ 1399 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1400 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o InitTweak/driver_cfa_cpp-FixGlobalInit.obj `if test -f 'InitTweak/FixGlobalInit.cc'; then $(CYGPATH_W) 'InitTweak/FixGlobalInit.cc'; else $(CYGPATH_W) '$(srcdir)/InitTweak/FixGlobalInit.cc'; fi` 1401 1382 1402 Parser/driver_cfa_cpp-parser.o: Parser/parser.cc 1383 1403 @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT Parser/driver_cfa_cpp-parser.o -MD -MP -MF Parser/$(DEPDIR)/driver_cfa_cpp-parser.Tpo -c -o Parser/driver_cfa_cpp-parser.o `test -f 'Parser/parser.cc' || echo '$(srcdir)/'`Parser/parser.cc -
src/SynTree/Declaration.h
r4acc87f rd029162e 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Declaration.h -- 7 // Declaration.h -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Mar 2 17:28:11201611 // Last Modified By : Rob Schluntz 12 // Last Modified On : Fri May 06 11:16:45 2016 13 13 // Update Count : 33 14 14 // … … 106 106 typedef DeclarationWithType Parent; 107 107 public: 108 FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn ); 108 // temporary - merge this into general GCC attributes 109 enum Attribute { 110 NoAttribute, Constructor, Destructor, 111 }; 112 113 FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn, Attribute attribute = NoAttribute ); 109 114 FunctionDecl( const FunctionDecl &other ); 110 115 virtual ~FunctionDecl(); … … 119 124 std::list< std::string >& get_oldIdents() { return oldIdents; } 120 125 std::list< Declaration* >& get_oldDecls() { return oldDecls; } 126 Attribute get_attribute() const { return attribute; } 127 void set_attribute( Attribute newValue ) { attribute = newValue; } 121 128 122 129 virtual FunctionDecl *clone() const { return new FunctionDecl( *this ); } … … 130 137 std::list< std::string > oldIdents; 131 138 std::list< Declaration* > oldDecls; 139 Attribute attribute; 132 140 }; 133 141 -
src/SynTree/FunctionDecl.cc
r4acc87f rd029162e 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // FunctionDecl.cc -- 7 // FunctionDecl.cc -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Mon Jul 13 18:11:44 201511 // Last Modified By : Rob Schluntz 12 // Last Modified On : Fri May 06 11:35:09 2016 13 13 // Update Count : 19 14 14 // … … 21 21 #include "Common/utility.h" 22 22 23 FunctionDecl::FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn )24 : Parent( name, sc, linkage ), type( type ), statements( statements ) {23 FunctionDecl::FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn, Attribute attribute ) 24 : Parent( name, sc, linkage ), type( type ), statements( statements ), attribute( attribute ) { 25 25 set_isInline( isInline ); 26 26 set_isNoreturn( isNoreturn ); … … 32 32 33 33 FunctionDecl::FunctionDecl( const FunctionDecl &other ) 34 : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ) {34 : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ), attribute( other.attribute ) { 35 35 } 36 36 … … 52 52 using std::endl; 53 53 using std::string; 54 54 55 55 if ( get_name() != "" ) { 56 56 os << get_name() << ": "; … … 65 65 os << "_Noreturn "; 66 66 } // if 67 switch ( attribute ) { 68 case Constructor: 69 os << "Global Constructor "; 70 break; 71 case Destructor: 72 os << "Global Destructor "; 73 break; 74 default: 75 break; 76 } 67 77 if ( get_storageClass() != DeclarationNode::NoStorageClass ) { 68 78 os << DeclarationNode::storageName[ get_storageClass() ] << ' '; … … 94 104 using std::endl; 95 105 using std::string; 96 106 97 107 if ( get_name() != "" ) { 98 108 os << get_name() << ": "; … … 104 114 os << "_Noreturn "; 105 115 } // if 116 switch ( attribute ) { 117 case Constructor: 118 os << " Global Constructor "; 119 break; 120 case Destructor: 121 os << " Global Destructor "; 122 break; 123 default: 124 break; 125 } 106 126 if ( get_storageClass() != DeclarationNode::NoStorageClass ) { 107 127 os << DeclarationNode::storageName[ get_storageClass() ] << ' '; -
src/main.cc
r4acc87f rd029162e 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // main.cc -- 7 // main.cc -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Fri May 15 23:12:02 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed May 4 23:32:59 201611 // Last Modified By : Rob Schluntz 12 // Last Modified On : Fri May 06 14:04:49 2016 13 13 // Update Count : 203 14 14 // … … 41 41 #include "InitTweak/Mutate.h" 42 42 #include "InitTweak/RemoveInit.h" 43 #include "InitTweak/FixGlobalInit.h" 43 44 //#include "Explain/GenProlog.h" 44 45 //#include "Try/Visit.h" … … 98 99 int long_index; 99 100 std::list< Declaration * > translationUnit; 100 const char *filename = NULL; ;101 const char *filename = NULL; 101 102 102 103 opterr = 0; // prevent getopt from printing error messages 103 104 104 105 int c; 105 106 while ( (c = getopt_long( argc, argv, "abefglnpqrstvyzD:F:", long_opts, &long_index )) != -1 ) { … … 180 181 input = fopen( argv[ optind ], "r" ); 181 182 if ( ! input ) { 182 std::cout << "Error: can't open " << argv[ optind] << std::endl;183 std::cout << "Error: can't open " << argv[ optind ] << std::endl; 183 184 exit( 1 ); 184 185 } // if 186 // if running cfa-cpp directly, might forget to pass -F option (and really shouldn't have to) 187 if ( filename == NULL ) filename = argv[ optind ]; 185 188 optind += 1; 186 189 } else { … … 191 194 output = new ofstream( argv[ optind ] ); 192 195 } // if 193 196 194 197 Parser::get_parser().set_debug( grammarp ); 195 198 … … 212 215 exit( 1 ); 213 216 } // if 214 217 215 218 parse( prelude, LinkageSpec::Intrinsic ); 216 219 } // if 217 220 } // if 218 221 219 parse( input, libcfap ? LinkageSpec::Intrinsic : LinkageSpec::Cforall, grammarp ); 220 222 parse( input, libcfap ? LinkageSpec::Intrinsic : LinkageSpec::Cforall, grammarp ); 223 221 224 if ( parsep ) { 222 225 Parser::get_parser().get_parseTree()->printList( std::cout ); … … 253 256 OPTPRINT( "mutate" ) 254 257 ControlStruct::mutate( translationUnit ); 255 OPTPRINT( "fixNames" ) 258 OPTPRINT( "fixNames" ) 256 259 CodeGen::fixNames( translationUnit ); 260 OPTPRINT( "fixGlobalInit" ); 261 InitTweak::fixGlobalInit( translationUnit, filename ); 257 262 OPTPRINT( "tweak" ) 258 263 InitTweak::tweak( translationUnit ); … … 282 287 OPTPRINT( "box" ) 283 288 GenPoly::box( translationUnit ); 284 289 285 290 // print tree right before code generation 286 291 if ( codegenp ) { … … 338 343 std::list< Declaration * > decls; 339 344 if ( noprotop ) { 340 filter( translationUnit.begin(), translationUnit.end(), 345 filter( translationUnit.begin(), translationUnit.end(), 341 346 std::back_inserter( decls ), notPrelude ); 342 347 } else {
Note:
See TracChangeset
for help on using the changeset viewer.