Changes in src/main.cc [52f9804:c86b08d]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main.cc
r52f9804 rc86b08d 9 9 // Author : Peter Buhr and Rob Schluntz 10 10 // Created On : Fri May 15 23:12:02 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Mon Apr 10 21:12:17202313 // Update Count : 68 211 // Last Modified By : Andrew Beach 12 // Last Modified On : Thr Feb 16 10:08:00 2023 13 // Update Count : 680 14 14 // 15 15 … … 32 32 33 33 #include "AST/Convert.hpp" 34 #include "AST/Util.hpp" // for checkInvariants35 34 #include "CompilationState.h" 36 35 #include "../config.h" // for CFA_LIBDIR … … 48 47 #include "Concurrency/Keywords.h" // for implementMutex, implement... 49 48 #include "Concurrency/Waitfor.h" // for generateWaitfor 49 #include "Concurrency/Waituntil.hpp" // for generateWaitUntil 50 50 #include "ControlStruct/ExceptDecl.h" // for translateExcept 51 51 #include "ControlStruct/ExceptTranslate.h" // for translateThrows, translat... … … 102 102 } 103 103 104 // Helpers for checkInvariant: 105 void checkInvariants( std::list< Declaration * > & ) {} 106 using ast::checkInvariants; 107 108 #define PASS( name, pass, unit, ... ) \ 104 #define PASS( name, pass ) \ 109 105 if ( errorp ) { cerr << name << endl; } \ 110 106 NewPass(name); \ 111 107 Stats::Time::StartBlock(name); \ 112 pass(unit,##__VA_ARGS__); \ 113 Stats::Time::StopBlock(); \ 114 if ( invariant ) { \ 115 checkInvariants(unit); \ 116 } 117 118 #define DUMP( cond, unit ) \ 119 if ( cond ) { \ 120 dump(unit); \ 121 return EXIT_SUCCESS; \ 122 } 108 pass; \ 109 Stats::Time::StopBlock(); 123 110 124 111 static bool waiting_for_gdb = false; // flag to set cfa-cpp to wait for gdb on start … … 311 298 transUnit = buildUnit(); 312 299 313 DUMP( astp, std::move( transUnit ) ); 300 if ( astp ) { 301 dump( std::move( transUnit ) ); 302 return EXIT_SUCCESS; 303 } // if 314 304 315 305 Stats::Time::StopBlock(); … … 320 310 } 321 311 322 PASS( "Hoist Type Decls", Validate::hoistTypeDecls, transUnit ); 323 324 PASS( "Translate Exception Declarations", ControlStruct::translateExcept, transUnit ); 325 DUMP( exdeclp, std::move( transUnit ) ); 326 PASS( "Verify Ctor, Dtor & Assign", Validate::verifyCtorDtorAssign, transUnit ); 327 PASS( "Replace Typedefs", Validate::replaceTypedef, transUnit ); 328 PASS( "Fix Return Types", Validate::fixReturnTypes, transUnit ); 329 PASS( "Enum and Pointer Decay", Validate::decayEnumsAndPointers, transUnit ); 330 331 PASS( "Link Reference To Types", Validate::linkReferenceToTypes, transUnit ); 332 333 PASS( "Fix Qualified Types", Validate::fixQualifiedTypes, transUnit ); 334 PASS( "Hoist Struct", Validate::hoistStruct, transUnit ); 335 PASS( "Eliminate Typedef", Validate::eliminateTypedef, transUnit ); 336 PASS( "Validate Generic Parameters", Validate::fillGenericParameters, transUnit ); 337 PASS( "Translate Dimensions", Validate::translateDimensionParameters, transUnit ); 338 PASS( "Check Function Returns", Validate::checkReturnStatements, transUnit ); 339 PASS( "Fix Return Statements", InitTweak::fixReturnStatements, transUnit ); 340 PASS( "Implement Concurrent Keywords", Concurrency::implementKeywords, transUnit ); 341 PASS( "Forall Pointer Decay", Validate::decayForallPointers, transUnit ); 342 PASS( "Hoist Control Declarations", ControlStruct::hoistControlDecls, transUnit ); 343 344 PASS( "Generate Autogen Routines", Validate::autogenerateRoutines, transUnit ); 345 346 PASS( "Implement Actors", Concurrency::implementActors, transUnit ); 347 PASS( "Implement Virtual Destructors", Virtual::implementVirtDtors, transUnit ); 348 PASS( "Implement Mutex", Concurrency::implementMutex, transUnit ); 349 PASS( "Implement Thread Start", Concurrency::implementThreadStarter, transUnit ); 350 PASS( "Compound Literal", Validate::handleCompoundLiterals, transUnit ); 351 PASS( "Set Length From Initializer", Validate::setLengthFromInitializer, transUnit ); 352 PASS( "Find Global Decls", Validate::findGlobalDecls, transUnit ); 353 PASS( "Fix Label Address", Validate::fixLabelAddresses, transUnit ); 312 PASS( "Hoist Type Decls", Validate::hoistTypeDecls( transUnit ) ); 313 // Hoist Type Decls pulls some declarations out of contexts where 314 // locations are not tracked. Perhaps they should be, but for now 315 // the full fill solves it. 316 forceFillCodeLocations( transUnit ); 317 318 PASS( "Translate Exception Declarations", ControlStruct::translateExcept( transUnit ) ); 319 if ( exdeclp ) { 320 dump( std::move( transUnit ) ); 321 return EXIT_SUCCESS; 322 } 323 324 PASS( "Verify Ctor, Dtor & Assign", Validate::verifyCtorDtorAssign( transUnit ) ); 325 PASS( "Replace Typedefs", Validate::replaceTypedef( transUnit ) ); 326 PASS( "Fix Return Types", Validate::fixReturnTypes( transUnit ) ); 327 PASS( "Enum and Pointer Decay", Validate::decayEnumsAndPointers( transUnit ) ); 328 329 PASS( "Link Reference To Types", Validate::linkReferenceToTypes( transUnit ) ); 330 331 PASS( "Fix Qualified Types", Validate::fixQualifiedTypes( transUnit ) ); 332 PASS( "Hoist Struct", Validate::hoistStruct( transUnit ) ); 333 PASS( "Eliminate Typedef", Validate::eliminateTypedef( transUnit ) ); 334 PASS( "Validate Generic Parameters", Validate::fillGenericParameters( transUnit ) ); 335 PASS( "Translate Dimensions", Validate::translateDimensionParameters( transUnit ) ); 336 PASS( "Check Function Returns", Validate::checkReturnStatements( transUnit ) ); 337 PASS( "Fix Return Statements", InitTweak::fixReturnStatements( transUnit ) ); 338 PASS( "Implement Concurrent Keywords", Concurrency::implementKeywords( transUnit ) ); 339 PASS( "Forall Pointer Decay", Validate::decayForallPointers( transUnit ) ); 340 PASS( "Implement Waituntil", Concurrency::generateWaitUntil( transUnit ) ); 341 PASS( "Hoist Control Declarations", ControlStruct::hoistControlDecls( transUnit ) ); 342 343 PASS( "Generate Autogen Routines", Validate::autogenerateRoutines( transUnit ) ); 344 345 PASS( "Implement Actors", Concurrency::implementActors( transUnit ) ); 346 PASS( "Implement Virtual Destructors", Virtual::implementVirtDtors(transUnit) ); 347 PASS( "Implement Mutex", Concurrency::implementMutex( transUnit ) ); 348 PASS( "Implement Thread Start", Concurrency::implementThreadStarter( transUnit ) ); 349 PASS( "Compound Literal", Validate::handleCompoundLiterals( transUnit ) ); 350 PASS( "Set Length From Initializer", Validate::setLengthFromInitializer( transUnit ) ); 351 PASS( "Find Global Decls", Validate::findGlobalDecls( transUnit ) ); 352 PASS( "Fix Label Address", Validate::fixLabelAddresses( transUnit ) ); 354 353 355 354 if ( symtabp ) { … … 362 361 } // if 363 362 364 DUMP( validp, std::move( transUnit ) ); 365 366 PASS( "Translate Throws", ControlStruct::translateThrows, transUnit ); 367 PASS( "Fix Labels", ControlStruct::fixLabels, transUnit ); 368 PASS( "Fix Names", CodeGen::fixNames, transUnit ); 369 PASS( "Gen Init", InitTweak::genInit, transUnit ); 370 PASS( "Expand Member Tuples" , Tuples::expandMemberTuples, transUnit ); 363 if ( validp ) { 364 dump( std::move( transUnit ) ); 365 return EXIT_SUCCESS; 366 } // if 367 368 PASS( "Translate Throws", ControlStruct::translateThrows( transUnit ) ); 369 PASS( "Fix Labels", ControlStruct::fixLabels( transUnit ) ); 370 PASS( "Fix Names", CodeGen::fixNames( transUnit ) ); 371 PASS( "Gen Init", InitTweak::genInit( transUnit ) ); 372 PASS( "Expand Member Tuples" , Tuples::expandMemberTuples( transUnit ) ); 371 373 372 374 if ( libcfap ) { … … 380 382 } // if 381 383 382 DUMP( bresolvep, std::move( transUnit ) ); 384 if ( bresolvep ) { 385 dump( std::move( transUnit ) ); 386 return EXIT_SUCCESS; 387 } // if 383 388 384 389 if ( resolvprotop ) { … … 387 392 } // if 388 393 389 PASS( "Resolve", ResolvExpr::resolve, transUnit ); 390 DUMP( exprp, std::move( transUnit ) ); 391 392 PASS( "Fix Init", InitTweak::fix, transUnit, buildingLibrary() ); 394 PASS( "Resolve", ResolvExpr::resolve( transUnit ) ); 395 if ( exprp ) { 396 dump( std::move( transUnit ) ); 397 return EXIT_SUCCESS; 398 } // if 399 400 forceFillCodeLocations( transUnit ); 401 402 PASS( "Fix Init", InitTweak::fix(transUnit, buildingLibrary())); 393 403 394 404 // fix ObjectDecl - replaces ConstructorInit nodes 395 DUMP( ctorinitp, std::move( transUnit ) ); 405 if ( ctorinitp ) { 406 dump( std::move( transUnit ) ); 407 return EXIT_SUCCESS; 408 } // if 396 409 397 410 // Currently not working due to unresolved issues with UniqueExpr 398 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 reused399 400 PASS( "Translate Tries", ControlStruct::translateTries , transUnit);401 PASS( "Gen Waitfor", Concurrency::generateWaitFor , transUnit);411 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 412 413 PASS( "Translate Tries", ControlStruct::translateTries( transUnit ) ); 414 PASS( "Gen Waitfor", Concurrency::generateWaitFor( transUnit ) ); 402 415 403 416 // Needs to happen before tuple types are expanded. 404 PASS( "Convert Specializations", GenPoly::convertSpecializations, transUnit ); 405 406 PASS( "Expand Tuples", Tuples::expandTuples, transUnit ); 407 DUMP( tuplep, std::move( transUnit ) ); 417 PASS( "Convert Specializations", GenPoly::convertSpecializations( transUnit ) ); 418 419 PASS( "Expand Tuples", Tuples::expandTuples( transUnit ) ); 420 421 if ( tuplep ) { 422 dump( std::move( transUnit ) ); 423 return EXIT_SUCCESS; 424 } // if 408 425 409 426 // Must come after Translate Tries. 410 PASS( "Virtual Expand Casts", Virtual::expandCasts, transUnit ); 411 412 PASS( "Instantiate Generics", GenPoly::instantiateGeneric, transUnit ); 413 DUMP( genericsp, std::move( transUnit ) ); 414 415 PASS( "Convert L-Value", GenPoly::convertLvalue, transUnit ); 427 PASS( "Virtual Expand Casts", Virtual::expandCasts( transUnit ) ); 428 429 PASS( "Instantiate Generics", GenPoly::instantiateGeneric( transUnit ) ); 430 if ( genericsp ) { 431 dump( std::move( transUnit ) ); 432 return EXIT_SUCCESS; 433 } // if 434 435 PASS( "Convert L-Value", GenPoly::convertLvalue( transUnit ) ); 416 436 417 437 translationUnit = convert( std::move( transUnit ) ); 418 438 419 DUMP( bboxp, translationUnit ); 420 PASS( "Box", GenPoly::box, translationUnit ); 421 422 PASS( "Link-Once", CodeGen::translateLinkOnce, translationUnit ); 439 if ( bboxp ) { 440 dump( translationUnit ); 441 return EXIT_SUCCESS; 442 } // if 443 PASS( "Box", GenPoly::box( translationUnit ) ); 444 445 PASS( "Link-Once", CodeGen::translateLinkOnce( translationUnit ) ); 423 446 424 447 // Code has been lowered to C, now we can start generation. 425 448 426 DUMP( bcodegenp, translationUnit ); 449 if ( bcodegenp ) { 450 dump( translationUnit ); 451 return EXIT_SUCCESS; 452 } // if 427 453 428 454 if ( optind < argc ) { // any commands after the flags and input file ? => output file name … … 431 457 432 458 CodeTools::fillLocations( translationUnit ); 433 PASS( "Code Gen", CodeGen::generate , translationUnit, *output, ! genproto, prettycodegenp, true, linemarks);459 PASS( "Code Gen", CodeGen::generate( translationUnit, *output, ! genproto, prettycodegenp, true, linemarks ) ); 434 460 435 461 CodeGen::FixMain::fix( translationUnit, *output, … … 479 505 480 506 481 static const char optstring[] = ":c:gh ilLmNnpdP:S:twW:D:";507 static const char optstring[] = ":c:ghlLmNnpdP:S:twW:D:"; 482 508 483 509 enum { PreludeDir = 128 }; … … 486 512 { "gdb", no_argument, nullptr, 'g' }, 487 513 { "help", no_argument, nullptr, 'h' }, 488 { "invariant", no_argument, nullptr, 'i' },489 514 { "libcfa", no_argument, nullptr, 'l' }, 490 515 { "linemarks", no_argument, nullptr, 'L' }, 491 { "no-main", no_argument, nullptr, 'm' },516 { "no-main", no_argument, 0, 'm' }, 492 517 { "no-linemarks", no_argument, nullptr, 'N' }, 493 518 { "no-prelude", no_argument, nullptr, 'n' }, … … 508 533 "wait for gdb to attach", // -g 509 534 "print translator help message", // -h 510 "invariant checking during AST passes", // -i511 535 "generate libcfa.c", // -l 512 536 "generate line marks", // -L … … 602 626 usage( argv ); // no return 603 627 break; 604 case 'i': // invariant checking605 invariant = true;606 break;607 628 case 'l': // generate libcfa.c 608 629 libcfap = true;
Note:
See TracChangeset
for help on using the changeset viewer.