Changes in src/main.cc [09366b8:ce31925]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main.cc
r09366b8 rce31925 10 10 // Created On : Fri May 15 23:12:02 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Sep 15 13:58:00 202213 // Update Count : 67 812 // Last Modified On : Thu 11 12:18:00 2022 13 // Update Count : 677 14 14 // 15 15 … … 38 38 #include "CodeGen/Generate.h" // for generate 39 39 #include "CodeGen/LinkOnce.h" // for translateLinkOnce 40 #include "CodeTools/DeclStats.h" // for printDeclStats 41 #include "CodeTools/ResolvProtoDump.h" // for dumpAsResolvProto 40 42 #include "CodeTools/TrackLoc.h" // for fillLocations 41 43 #include "Common/CodeLocationTools.hpp" // for forceFillCodeLocations … … 43 45 #include "Common/DeclStats.hpp" // for printDeclStats 44 46 #include "Common/ResolvProtoDump.hpp" // for dumpAsResolverProto 45 #include "Common/Stats.h" // for Stats 47 #include "Common/Stats.h" 48 #include "Common/PassVisitor.h" 49 #include "Common/SemanticError.h" // for SemanticError 46 50 #include "Common/UnimplementedError.h" // for UnimplementedError 47 51 #include "Common/utility.h" // for deleteAll, filter, printAll … … 49 53 #include "Concurrency/Waitfor.h" // for generateWaitfor 50 54 #include "ControlStruct/ExceptDecl.h" // for translateExcept 51 #include "ControlStruct/ExceptTranslate.h" // for translate Throws, translat...55 #include "ControlStruct/ExceptTranslate.h" // for translateEHM 52 56 #include "ControlStruct/FixLabels.hpp" // for fixLabels 53 57 #include "ControlStruct/HoistControlDecls.hpp" // hoistControlDecls 58 #include "ControlStruct/Mutate.h" // for mutate 54 59 #include "GenPoly/Box.h" // for box 55 60 #include "GenPoly/InstantiateGeneric.h" // for instantiateGeneric … … 61 66 #include "Parser/ParseNode.h" // for DeclarationNode, buildList 62 67 #include "Parser/TypedefTable.h" // for TypedefTable 68 #include "ResolvExpr/AlternativePrinter.h" // for AlternativePrinter 63 69 #include "ResolvExpr/CandidatePrinter.hpp" // for printCandidates 64 70 #include "ResolvExpr/Resolver.h" // for resolve 71 #include "SymTab/Validate.h" // for validate 72 #include "SymTab/ValidateType.h" // for linkReferenceToTypes 65 73 #include "SynTree/LinkageSpec.h" // for Spec, Cforall, Intrinsic 66 74 #include "SynTree/Declaration.h" // for Declaration 75 #include "SynTree/Visitor.h" // for acceptAll 67 76 #include "Tuples/Tuples.h" // for expandMemberTuples, expan... 68 77 #include "Validate/Autogen.hpp" // for autogenerateRoutines … … 321 330 Stats::Time::StopBlock(); 322 331 323 if (Stats::Counters::enabled) { 324 ast::pass_visitor_stats.avg = Stats::Counters::build<Stats::Counters::AverageCounter<double>>("Average Depth - New"); 325 ast::pass_visitor_stats.max = Stats::Counters::build<Stats::Counters::MaxCounter<double>>("Max depth - New"); 332 if( useNewAST ) { 333 if (Stats::Counters::enabled) { 334 ast::pass_visitor_stats.avg = Stats::Counters::build<Stats::Counters::AverageCounter<double>>("Average Depth - New"); 335 ast::pass_visitor_stats.max = Stats::Counters::build<Stats::Counters::MaxCounter<double>>("Max depth - New"); 336 } 337 auto transUnit = convert( move( translationUnit ) ); 338 339 forceFillCodeLocations( transUnit ); 340 341 PASS( "Translate Exception Declarations", ControlStruct::translateExcept( transUnit ) ); 342 if ( exdeclp ) { 343 dump( move( transUnit ) ); 344 return EXIT_SUCCESS; 345 } 346 347 PASS( "Verify Ctor, Dtor & Assign", Validate::verifyCtorDtorAssign( transUnit ) ); 348 PASS( "Hoist Type Decls", Validate::hoistTypeDecls( transUnit ) ); 349 // Hoist Type Decls pulls some declarations out of contexts where 350 // locations are not tracked. Perhaps they should be, but for now 351 // the full fill solves it. 352 forceFillCodeLocations( transUnit ); 353 354 PASS( "Replace Typedefs", Validate::replaceTypedef( transUnit ) ); 355 PASS( "Fix Return Types", Validate::fixReturnTypes( transUnit ) ); 356 PASS( "Enum and Pointer Decay", Validate::decayEnumsAndPointers( transUnit ) ); 357 358 PASS( "Link Reference To Types", Validate::linkReferenceToTypes( transUnit ) ); 359 360 PASS( "Fix Qualified Types", Validate::fixQualifiedTypes( transUnit ) ); 361 PASS( "Hoist Struct", Validate::hoistStruct( transUnit ) ); 362 PASS( "Eliminate Typedef", Validate::eliminateTypedef( transUnit ) ); 363 PASS( "Validate Generic Parameters", Validate::fillGenericParameters( transUnit ) ); 364 PASS( "Translate Dimensions", Validate::translateDimensionParameters( transUnit ) ); 365 PASS( "Check Function Returns", Validate::checkReturnStatements( transUnit ) ); 366 PASS( "Fix Return Statements", InitTweak::fixReturnStatements( transUnit ) ); 367 PASS( "Implement Concurrent Keywords", Concurrency::implementKeywords( transUnit ) ); 368 PASS( "Forall Pointer Decay", Validate::decayForallPointers( transUnit ) ); 369 PASS( "Hoist Control Declarations", ControlStruct::hoistControlDecls( transUnit ) ); 370 371 PASS( "Generate Autogen Routines", Validate::autogenerateRoutines( transUnit ) ); 372 373 PASS( "Implement Mutex", Concurrency::implementMutex( transUnit ) ); 374 PASS( "Implement Thread Start", Concurrency::implementThreadStarter( transUnit ) ); 375 PASS( "Compound Literal", Validate::handleCompoundLiterals( transUnit ) ); 376 PASS( "Set Length From Initializer", Validate::setLengthFromInitializer( transUnit ) ); 377 PASS( "Find Global Decls", Validate::findGlobalDecls( transUnit ) ); 378 PASS( "Fix Label Address", Validate::fixLabelAddresses( transUnit ) ); 379 380 if ( symtabp ) { 381 return EXIT_SUCCESS; 382 } // if 383 384 if ( expraltp ) { 385 ResolvExpr::printCandidates( transUnit ); 386 return EXIT_SUCCESS; 387 } // if 388 389 if ( validp ) { 390 dump( move( transUnit ) ); 391 return EXIT_SUCCESS; 392 } // if 393 394 PASS( "Translate Throws", ControlStruct::translateThrows( transUnit ) ); 395 PASS( "Fix Labels", ControlStruct::fixLabels( transUnit ) ); 396 PASS( "Fix Names", CodeGen::fixNames( transUnit ) ); 397 PASS( "Gen Init", InitTweak::genInit( transUnit ) ); 398 PASS( "Expand Member Tuples" , Tuples::expandMemberTuples( transUnit ) ); 399 400 if ( libcfap ) { 401 // Generate the bodies of cfa library functions. 402 LibCfa::makeLibCfa( transUnit ); 403 } // if 404 405 if ( declstatsp ) { 406 printDeclStats( transUnit ); 407 return EXIT_SUCCESS; 408 } // if 409 410 if ( bresolvep ) { 411 dump( move( transUnit ) ); 412 return EXIT_SUCCESS; 413 } // if 414 415 if ( resolvprotop ) { 416 dumpAsResolverProto( transUnit ); 417 return EXIT_SUCCESS; 418 } // if 419 420 PASS( "Resolve", ResolvExpr::resolve( transUnit ) ); 421 if ( exprp ) { 422 dump( move( transUnit ) ); 423 return EXIT_SUCCESS; 424 } // if 425 426 forceFillCodeLocations( transUnit ); 427 428 PASS( "Fix Init", InitTweak::fix(transUnit, buildingLibrary())); 429 430 // fix ObjectDecl - replaces ConstructorInit nodes 431 if ( ctorinitp ) { 432 dump( move( transUnit ) ); 433 return EXIT_SUCCESS; 434 } // if 435 436 // Currently not working due to unresolved issues with UniqueExpr 437 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 438 439 PASS( "Translate Tries", ControlStruct::translateTries( transUnit ) ); 440 PASS( "Gen Waitfor", Concurrency::generateWaitFor( transUnit ) ); 441 442 // Needs to happen before tuple types are expanded. 443 PASS( "Convert Specializations", GenPoly::convertSpecializations( transUnit ) ); 444 445 PASS( "Expand Tuples", Tuples::expandTuples( transUnit ) ); 446 447 if ( tuplep ) { 448 dump( move( transUnit ) ); 449 return EXIT_SUCCESS; 450 } // if 451 452 // Must come after Translate Tries. 453 PASS( "Virtual Expand Casts", Virtual::expandCasts( transUnit ) ); 454 455 PASS( "Instantiate Generics", GenPoly::instantiateGeneric( transUnit ) ); 456 457 translationUnit = convert( move( transUnit ) ); 458 } else { 459 PASS( "Translate Exception Declarations", ControlStruct::translateExcept( translationUnit ) ); 460 if ( exdeclp ) { 461 dump( translationUnit ); 462 return EXIT_SUCCESS; 463 } // if 464 465 // add the assignment statement after the initialization of a type parameter 466 PASS( "Validate", SymTab::validate( translationUnit ) ); 467 468 if ( symtabp ) { 469 deleteAll( translationUnit ); 470 return EXIT_SUCCESS; 471 } // if 472 473 if ( expraltp ) { 474 PassVisitor<ResolvExpr::AlternativePrinter> printer( cout ); 475 acceptAll( translationUnit, printer ); 476 return EXIT_SUCCESS; 477 } // if 478 479 if ( validp ) { 480 dump( translationUnit ); 481 return EXIT_SUCCESS; 482 } // if 483 484 PASS( "Translate Throws", ControlStruct::translateThrows( translationUnit ) ); 485 PASS( "Fix Labels", ControlStruct::fixLabels( translationUnit ) ); 486 PASS( "Fix Names", CodeGen::fixNames( translationUnit ) ); 487 PASS( "Gen Init", InitTweak::genInit( translationUnit ) ); 488 PASS( "Expand Member Tuples" , Tuples::expandMemberTuples( translationUnit ) ); 489 490 if ( libcfap ) { 491 // Generate the bodies of cfa library functions. 492 LibCfa::makeLibCfa( translationUnit ); 493 } // if 494 495 if ( declstatsp ) { 496 CodeTools::printDeclStats( translationUnit ); 497 deleteAll( translationUnit ); 498 return EXIT_SUCCESS; 499 } // if 500 501 if ( bresolvep ) { 502 dump( translationUnit ); 503 return EXIT_SUCCESS; 504 } // if 505 506 CodeTools::fillLocations( translationUnit ); 507 508 if ( resolvprotop ) { 509 CodeTools::dumpAsResolvProto( translationUnit ); 510 return EXIT_SUCCESS; 511 } // if 512 513 PASS( "Resolve", ResolvExpr::resolve( translationUnit ) ); 514 if ( exprp ) { 515 dump( translationUnit ); 516 return EXIT_SUCCESS; 517 } 518 519 PASS( "Fix Init", InitTweak::fix( translationUnit, buildingLibrary() ) ); 520 521 // fix ObjectDecl - replaces ConstructorInit nodes 522 if ( ctorinitp ) { 523 dump ( translationUnit ); 524 return EXIT_SUCCESS; 525 } // if 526 527 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 528 PASS( "Translate Tries", ControlStruct::translateTries( translationUnit ) ); 529 PASS( "Gen Waitfor", Concurrency::generateWaitFor( translationUnit ) ); 530 PASS( "Convert Specializations", GenPoly::convertSpecializations( translationUnit ) ); // needs to happen before tuple types are expanded 531 PASS( "Expand Tuples", Tuples::expandTuples( translationUnit ) ); // xxx - is this the right place for this? 532 533 if ( tuplep ) { 534 dump( translationUnit ); 535 return EXIT_SUCCESS; 536 } // if 537 538 PASS( "Virtual Expand Casts", Virtual::expandCasts( translationUnit ) ); // Must come after translateEHM 539 540 PASS( "Instantiate Generics", GenPoly::instantiateGeneric( translationUnit ) ); 326 541 } 327 auto transUnit = convert( move( translationUnit ) );328 329 forceFillCodeLocations( transUnit );330 331 PASS( "Translate Exception Declarations", ControlStruct::translateExcept( transUnit ) );332 if ( exdeclp ) {333 dump( move( transUnit ) );334 return EXIT_SUCCESS;335 }336 337 PASS( "Verify Ctor, Dtor & Assign", Validate::verifyCtorDtorAssign( transUnit ) );338 PASS( "Hoist Type Decls", Validate::hoistTypeDecls( transUnit ) );339 // Hoist Type Decls pulls some declarations out of contexts where340 // locations are not tracked. Perhaps they should be, but for now341 // the full fill solves it.342 forceFillCodeLocations( transUnit );343 344 PASS( "Replace Typedefs", Validate::replaceTypedef( transUnit ) );345 PASS( "Fix Return Types", Validate::fixReturnTypes( transUnit ) );346 PASS( "Enum and Pointer Decay", Validate::decayEnumsAndPointers( transUnit ) );347 348 PASS( "Link Reference To Types", Validate::linkReferenceToTypes( transUnit ) );349 350 PASS( "Fix Qualified Types", Validate::fixQualifiedTypes( transUnit ) );351 PASS( "Hoist Struct", Validate::hoistStruct( transUnit ) );352 PASS( "Eliminate Typedef", Validate::eliminateTypedef( transUnit ) );353 PASS( "Validate Generic Parameters", Validate::fillGenericParameters( transUnit ) );354 PASS( "Translate Dimensions", Validate::translateDimensionParameters( transUnit ) );355 PASS( "Check Function Returns", Validate::checkReturnStatements( transUnit ) );356 PASS( "Fix Return Statements", InitTweak::fixReturnStatements( transUnit ) );357 PASS( "Implement Concurrent Keywords", Concurrency::implementKeywords( transUnit ) );358 PASS( "Forall Pointer Decay", Validate::decayForallPointers( transUnit ) );359 PASS( "Hoist Control Declarations", ControlStruct::hoistControlDecls( transUnit ) );360 361 PASS( "Generate Autogen Routines", Validate::autogenerateRoutines( transUnit ) );362 363 PASS( "Implement Mutex", Concurrency::implementMutex( transUnit ) );364 PASS( "Implement Thread Start", Concurrency::implementThreadStarter( transUnit ) );365 PASS( "Compound Literal", Validate::handleCompoundLiterals( transUnit ) );366 PASS( "Set Length From Initializer", Validate::setLengthFromInitializer( transUnit ) );367 PASS( "Find Global Decls", Validate::findGlobalDecls( transUnit ) );368 PASS( "Fix Label Address", Validate::fixLabelAddresses( transUnit ) );369 370 if ( symtabp ) {371 return EXIT_SUCCESS;372 } // if373 374 if ( expraltp ) {375 ResolvExpr::printCandidates( transUnit );376 return EXIT_SUCCESS;377 } // if378 379 if ( validp ) {380 dump( move( transUnit ) );381 return EXIT_SUCCESS;382 } // if383 384 PASS( "Translate Throws", ControlStruct::translateThrows( transUnit ) );385 PASS( "Fix Labels", ControlStruct::fixLabels( transUnit ) );386 PASS( "Fix Names", CodeGen::fixNames( transUnit ) );387 PASS( "Gen Init", InitTweak::genInit( transUnit ) );388 PASS( "Expand Member Tuples" , Tuples::expandMemberTuples( transUnit ) );389 390 if ( libcfap ) {391 // Generate the bodies of cfa library functions.392 LibCfa::makeLibCfa( transUnit );393 } // if394 395 if ( declstatsp ) {396 printDeclStats( transUnit );397 return EXIT_SUCCESS;398 } // if399 400 if ( bresolvep ) {401 dump( move( transUnit ) );402 return EXIT_SUCCESS;403 } // if404 405 if ( resolvprotop ) {406 dumpAsResolverProto( transUnit );407 return EXIT_SUCCESS;408 } // if409 410 PASS( "Resolve", ResolvExpr::resolve( transUnit ) );411 if ( exprp ) {412 dump( move( transUnit ) );413 return EXIT_SUCCESS;414 } // if415 416 forceFillCodeLocations( transUnit );417 418 PASS( "Fix Init", InitTweak::fix(transUnit, buildingLibrary()));419 420 // fix ObjectDecl - replaces ConstructorInit nodes421 if ( ctorinitp ) {422 dump( move( transUnit ) );423 return EXIT_SUCCESS;424 } // if425 426 // Currently not working due to unresolved issues with UniqueExpr427 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 reused428 429 PASS( "Translate Tries", ControlStruct::translateTries( transUnit ) );430 PASS( "Gen Waitfor", Concurrency::generateWaitFor( transUnit ) );431 432 // Needs to happen before tuple types are expanded.433 PASS( "Convert Specializations", GenPoly::convertSpecializations( transUnit ) );434 435 PASS( "Expand Tuples", Tuples::expandTuples( transUnit ) );436 437 if ( tuplep ) {438 dump( move( transUnit ) );439 return EXIT_SUCCESS;440 } // if441 442 // Must come after Translate Tries.443 PASS( "Virtual Expand Casts", Virtual::expandCasts( transUnit ) );444 445 PASS( "Instantiate Generics", GenPoly::instantiateGeneric( transUnit ) );446 447 translationUnit = convert( move( transUnit ) );448 542 449 543 if ( genericsp ) {
Note:
See TracChangeset
for help on using the changeset viewer.