Changeset 52f9804
- Timestamp:
- Apr 12, 2023, 6:32:46 PM (20 months ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 32d6fdc
- Parents:
- eb8d791
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main.cc
reb8d791 r52f9804 32 32 33 33 #include "AST/Convert.hpp" 34 #include "AST/Util.hpp" // for checkInvariants 34 35 #include "CompilationState.h" 35 36 #include "../config.h" // for CFA_LIBDIR … … 101 102 } 102 103 103 #define PASS( name, pass ) \ 104 // Helpers for checkInvariant: 105 void checkInvariants( std::list< Declaration * > & ) {} 106 using ast::checkInvariants; 107 108 #define PASS( name, pass, unit, ... ) \ 104 109 if ( errorp ) { cerr << name << endl; } \ 105 110 NewPass(name); \ 106 111 Stats::Time::StartBlock(name); \ 107 pass; \ 108 Stats::Time::StopBlock(); 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 } 109 123 110 124 static bool waiting_for_gdb = false; // flag to set cfa-cpp to wait for gdb on start … … 297 311 transUnit = buildUnit(); 298 312 299 if ( astp ) { 300 dump( std::move( transUnit ) ); 301 return EXIT_SUCCESS; 302 } // if 313 DUMP( astp, std::move( transUnit ) ); 303 314 304 315 Stats::Time::StopBlock(); … … 309 320 } 310 321 311 PASS( "Hoist Type Decls", Validate::hoistTypeDecls( transUnit ) ); 312 313 PASS( "Translate Exception Declarations", ControlStruct::translateExcept( transUnit ) ); 314 if ( exdeclp ) { 315 dump( std::move( transUnit ) ); 316 return EXIT_SUCCESS; 317 } 318 319 PASS( "Verify Ctor, Dtor & Assign", Validate::verifyCtorDtorAssign( transUnit ) ); 320 PASS( "Replace Typedefs", Validate::replaceTypedef( transUnit ) ); 321 PASS( "Fix Return Types", Validate::fixReturnTypes( transUnit ) ); 322 PASS( "Enum and Pointer Decay", Validate::decayEnumsAndPointers( transUnit ) ); 323 324 PASS( "Link Reference To Types", Validate::linkReferenceToTypes( transUnit ) ); 325 326 PASS( "Fix Qualified Types", Validate::fixQualifiedTypes( transUnit ) ); 327 PASS( "Hoist Struct", Validate::hoistStruct( transUnit ) ); 328 PASS( "Eliminate Typedef", Validate::eliminateTypedef( transUnit ) ); 329 PASS( "Validate Generic Parameters", Validate::fillGenericParameters( transUnit ) ); 330 PASS( "Translate Dimensions", Validate::translateDimensionParameters( transUnit ) ); 331 PASS( "Check Function Returns", Validate::checkReturnStatements( transUnit ) ); 332 PASS( "Fix Return Statements", InitTweak::fixReturnStatements( transUnit ) ); 333 PASS( "Implement Concurrent Keywords", Concurrency::implementKeywords( transUnit ) ); 334 PASS( "Forall Pointer Decay", Validate::decayForallPointers( transUnit ) ); 335 PASS( "Hoist Control Declarations", ControlStruct::hoistControlDecls( transUnit ) ); 336 337 PASS( "Generate Autogen Routines", Validate::autogenerateRoutines( transUnit ) ); 338 339 PASS( "Implement Actors", Concurrency::implementActors( transUnit ) ); 340 PASS( "Implement Virtual Destructors", Virtual::implementVirtDtors(transUnit) ); 341 PASS( "Implement Mutex", Concurrency::implementMutex( transUnit ) ); 342 PASS( "Implement Thread Start", Concurrency::implementThreadStarter( transUnit ) ); 343 PASS( "Compound Literal", Validate::handleCompoundLiterals( transUnit ) ); 344 PASS( "Set Length From Initializer", Validate::setLengthFromInitializer( transUnit ) ); 345 PASS( "Find Global Decls", Validate::findGlobalDecls( transUnit ) ); 346 PASS( "Fix Label Address", Validate::fixLabelAddresses( transUnit ) ); 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 ); 347 354 348 355 if ( symtabp ) { … … 355 362 } // if 356 363 357 if ( validp ) { 358 dump( std::move( transUnit ) ); 359 return EXIT_SUCCESS; 360 } // if 361 362 PASS( "Translate Throws", ControlStruct::translateThrows( transUnit ) ); 363 PASS( "Fix Labels", ControlStruct::fixLabels( transUnit ) ); 364 PASS( "Fix Names", CodeGen::fixNames( transUnit ) ); 365 PASS( "Gen Init", InitTweak::genInit( transUnit ) ); 366 PASS( "Expand Member Tuples" , Tuples::expandMemberTuples( transUnit ) ); 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 ); 367 371 368 372 if ( libcfap ) { … … 376 380 } // if 377 381 378 if ( bresolvep ) { 379 dump( std::move( transUnit ) ); 380 return EXIT_SUCCESS; 381 } // if 382 DUMP( bresolvep, std::move( transUnit ) ); 382 383 383 384 if ( resolvprotop ) { … … 386 387 } // if 387 388 388 PASS( "Resolve", ResolvExpr::resolve( transUnit ) ); 389 if ( exprp ) { 390 dump( std::move( transUnit ) ); 391 return EXIT_SUCCESS; 392 } // if 393 394 PASS( "Fix Init", InitTweak::fix(transUnit, buildingLibrary())); 389 PASS( "Resolve", ResolvExpr::resolve, transUnit ); 390 DUMP( exprp, std::move( transUnit ) ); 391 392 PASS( "Fix Init", InitTweak::fix, transUnit, buildingLibrary() ); 395 393 396 394 // fix ObjectDecl - replaces ConstructorInit nodes 397 if ( ctorinitp ) { 398 dump( std::move( transUnit ) ); 399 return EXIT_SUCCESS; 400 } // if 395 DUMP( ctorinitp, std::move( transUnit ) ); 401 396 402 397 // Currently not working due to unresolved issues with UniqueExpr 403 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 reused404 405 PASS( "Translate Tries", ControlStruct::translateTries ( transUnit ));406 PASS( "Gen Waitfor", Concurrency::generateWaitFor ( transUnit ));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 reused 399 400 PASS( "Translate Tries", ControlStruct::translateTries, transUnit ); 401 PASS( "Gen Waitfor", Concurrency::generateWaitFor, transUnit ); 407 402 408 403 // Needs to happen before tuple types are expanded. 409 PASS( "Convert Specializations", GenPoly::convertSpecializations( transUnit ) ); 410 411 PASS( "Expand Tuples", Tuples::expandTuples( transUnit ) ); 412 413 if ( tuplep ) { 414 dump( std::move( transUnit ) ); 415 return EXIT_SUCCESS; 416 } // if 404 PASS( "Convert Specializations", GenPoly::convertSpecializations, transUnit ); 405 406 PASS( "Expand Tuples", Tuples::expandTuples, transUnit ); 407 DUMP( tuplep, std::move( transUnit ) ); 417 408 418 409 // Must come after Translate Tries. 419 PASS( "Virtual Expand Casts", Virtual::expandCasts( transUnit ) ); 420 421 PASS( "Instantiate Generics", GenPoly::instantiateGeneric( transUnit ) ); 422 if ( genericsp ) { 423 dump( std::move( transUnit ) ); 424 return EXIT_SUCCESS; 425 } // if 426 427 PASS( "Convert L-Value", GenPoly::convertLvalue( transUnit ) ); 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 ); 428 416 429 417 translationUnit = convert( std::move( transUnit ) ); 430 418 431 if ( bboxp ) { 432 dump( translationUnit ); 433 return EXIT_SUCCESS; 434 } // if 435 PASS( "Box", GenPoly::box( translationUnit ) ); 436 437 PASS( "Link-Once", CodeGen::translateLinkOnce( translationUnit ) ); 419 DUMP( bboxp, translationUnit ); 420 PASS( "Box", GenPoly::box, translationUnit ); 421 422 PASS( "Link-Once", CodeGen::translateLinkOnce, translationUnit ); 438 423 439 424 // Code has been lowered to C, now we can start generation. 440 425 441 if ( bcodegenp ) { 442 dump( translationUnit ); 443 return EXIT_SUCCESS; 444 } // if 426 DUMP( bcodegenp, translationUnit ); 445 427 446 428 if ( optind < argc ) { // any commands after the flags and input file ? => output file name … … 449 431 450 432 CodeTools::fillLocations( translationUnit ); 451 PASS( "Code Gen", CodeGen::generate ( translationUnit, *output, ! genproto, prettycodegenp, true, linemarks ));433 PASS( "Code Gen", CodeGen::generate, translationUnit, *output, ! genproto, prettycodegenp, true, linemarks ); 452 434 453 435 CodeGen::FixMain::fix( translationUnit, *output,
Note: See TracChangeset
for help on using the changeset viewer.