Changes in src/main.cc [b507dcd:09f34a84]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main.cc
rb507dcd r09f34a84 10 10 // Created On : Fri May 15 23:12:02 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Mon Jul 18 11:08:00 202213 // Update Count : 67 612 // Last Modified On : Thu Sep 15 13:58:00 2022 13 // Update Count : 678 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 printDeclStats41 #include "CodeTools/ResolvProtoDump.h" // for dumpAsResolvProto42 40 #include "CodeTools/TrackLoc.h" // for fillLocations 43 41 #include "Common/CodeLocationTools.hpp" // for forceFillCodeLocations … … 45 43 #include "Common/DeclStats.hpp" // for printDeclStats 46 44 #include "Common/ResolvProtoDump.hpp" // for dumpAsResolverProto 47 #include "Common/Stats.h" 48 #include "Common/PassVisitor.h" 49 #include "Common/SemanticError.h" // for SemanticError 45 #include "Common/Stats.h" // for Stats 50 46 #include "Common/UnimplementedError.h" // for UnimplementedError 51 47 #include "Common/utility.h" // for deleteAll, filter, printAll … … 53 49 #include "Concurrency/Waitfor.h" // for generateWaitfor 54 50 #include "ControlStruct/ExceptDecl.h" // for translateExcept 55 #include "ControlStruct/ExceptTranslate.h" // for translate EHM51 #include "ControlStruct/ExceptTranslate.h" // for translateThrows, translat... 56 52 #include "ControlStruct/FixLabels.hpp" // for fixLabels 57 53 #include "ControlStruct/HoistControlDecls.hpp" // hoistControlDecls 58 #include "ControlStruct/Mutate.h" // for mutate59 54 #include "GenPoly/Box.h" // for box 60 55 #include "GenPoly/InstantiateGeneric.h" // for instantiateGeneric … … 66 61 #include "Parser/ParseNode.h" // for DeclarationNode, buildList 67 62 #include "Parser/TypedefTable.h" // for TypedefTable 68 #include "ResolvExpr/AlternativePrinter.h" // for AlternativePrinter69 63 #include "ResolvExpr/CandidatePrinter.hpp" // for printCandidates 70 64 #include "ResolvExpr/Resolver.h" // for resolve 71 #include "SymTab/Validate.h" // for validate72 #include "SymTab/ValidateType.h" // for linkReferenceToTypes73 65 #include "SynTree/LinkageSpec.h" // for Spec, Cforall, Intrinsic 74 66 #include "SynTree/Declaration.h" // for Declaration 75 #include "SynTree/Visitor.h" // for acceptAll76 67 #include "Tuples/Tuples.h" // for expandMemberTuples, expan... 77 68 #include "Validate/Autogen.hpp" // for autogenerateRoutines … … 330 321 Stats::Time::StopBlock(); 331 322 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 translationUnit = convert( move( transUnit ) ); 448 } else { 449 PASS( "Translate Exception Declarations", ControlStruct::translateExcept( translationUnit ) ); 450 if ( exdeclp ) { 451 dump( translationUnit ); 452 return EXIT_SUCCESS; 453 } // if 454 455 // add the assignment statement after the initialization of a type parameter 456 PASS( "Validate", SymTab::validate( translationUnit ) ); 457 458 if ( symtabp ) { 459 deleteAll( translationUnit ); 460 return EXIT_SUCCESS; 461 } // if 462 463 if ( expraltp ) { 464 PassVisitor<ResolvExpr::AlternativePrinter> printer( cout ); 465 acceptAll( translationUnit, printer ); 466 return EXIT_SUCCESS; 467 } // if 468 469 if ( validp ) { 470 dump( translationUnit ); 471 return EXIT_SUCCESS; 472 } // if 473 474 PASS( "Translate Throws", ControlStruct::translateThrows( translationUnit ) ); 475 PASS( "Fix Labels", ControlStruct::fixLabels( translationUnit ) ); 476 PASS( "Fix Names", CodeGen::fixNames( translationUnit ) ); 477 PASS( "Gen Init", InitTweak::genInit( translationUnit ) ); 478 PASS( "Expand Member Tuples" , Tuples::expandMemberTuples( translationUnit ) ); 479 480 if ( libcfap ) { 481 // Generate the bodies of cfa library functions. 482 LibCfa::makeLibCfa( translationUnit ); 483 } // if 484 485 if ( declstatsp ) { 486 CodeTools::printDeclStats( translationUnit ); 487 deleteAll( translationUnit ); 488 return EXIT_SUCCESS; 489 } // if 490 491 if ( bresolvep ) { 492 dump( translationUnit ); 493 return EXIT_SUCCESS; 494 } // if 495 496 CodeTools::fillLocations( translationUnit ); 497 498 if ( resolvprotop ) { 499 CodeTools::dumpAsResolvProto( translationUnit ); 500 return EXIT_SUCCESS; 501 } // if 502 503 PASS( "Resolve", ResolvExpr::resolve( translationUnit ) ); 504 if ( exprp ) { 505 dump( translationUnit ); 506 return EXIT_SUCCESS; 507 } 508 509 PASS( "Fix Init", InitTweak::fix( translationUnit, buildingLibrary() ) ); 510 511 // fix ObjectDecl - replaces ConstructorInit nodes 512 if ( ctorinitp ) { 513 dump ( translationUnit ); 514 return EXIT_SUCCESS; 515 } // if 516 517 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 518 PASS( "Translate Tries", ControlStruct::translateTries( translationUnit ) ); 519 PASS( "Gen Waitfor", Concurrency::generateWaitFor( translationUnit ) ); 520 PASS( "Convert Specializations", GenPoly::convertSpecializations( translationUnit ) ); // needs to happen before tuple types are expanded 521 PASS( "Expand Tuples", Tuples::expandTuples( translationUnit ) ); // xxx - is this the right place for this? 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"); 522 326 } 327 auto transUnit = convert( std::move( translationUnit ) ); 328 329 forceFillCodeLocations( transUnit ); 330 331 PASS( "Translate Exception Declarations", ControlStruct::translateExcept( transUnit ) ); 332 if ( exdeclp ) { 333 dump( std::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 where 340 // locations are not tracked. Perhaps they should be, but for now 341 // 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 } // if 373 374 if ( expraltp ) { 375 ResolvExpr::printCandidates( transUnit ); 376 return EXIT_SUCCESS; 377 } // if 378 379 if ( validp ) { 380 dump( std::move( transUnit ) ); 381 return EXIT_SUCCESS; 382 } // if 383 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 } // if 394 395 if ( declstatsp ) { 396 printDeclStats( transUnit ); 397 return EXIT_SUCCESS; 398 } // if 399 400 if ( bresolvep ) { 401 dump( std::move( transUnit ) ); 402 return EXIT_SUCCESS; 403 } // if 404 405 if ( resolvprotop ) { 406 dumpAsResolverProto( transUnit ); 407 return EXIT_SUCCESS; 408 } // if 409 410 PASS( "Resolve", ResolvExpr::resolve( transUnit ) ); 411 if ( exprp ) { 412 dump( std::move( transUnit ) ); 413 return EXIT_SUCCESS; 414 } // if 415 416 forceFillCodeLocations( transUnit ); 417 418 PASS( "Fix Init", InitTweak::fix(transUnit, buildingLibrary())); 419 420 // fix ObjectDecl - replaces ConstructorInit nodes 421 if ( ctorinitp ) { 422 dump( std::move( transUnit ) ); 423 return EXIT_SUCCESS; 424 } // if 425 426 // Currently not working due to unresolved issues with UniqueExpr 427 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 428 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 ) ); 523 436 524 437 if ( tuplep ) { 525 dump( translationUnit ); 526 return EXIT_SUCCESS; 527 } // if 528 529 PASS( "Virtual Expand Casts", Virtual::expandCasts( translationUnit ) ); // Must come after translateEHM 530 531 PASS( "Instantiate Generics", GenPoly::instantiateGeneric( translationUnit ) ); 438 dump( std::move( transUnit ) ); 439 return EXIT_SUCCESS; 440 } // if 441 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( std::move( transUnit ) ); 448 532 449 if ( genericsp ) { 533 450 dump( translationUnit ); … … 612 529 613 530 614 static const char optstring[] = ":c:ghlLmNnpd OAP:S:twW:D:";531 static const char optstring[] = ":c:ghlLmNnpdP:S:twW:D:"; 615 532 616 533 enum { PreludeDir = 128 }; … … 626 543 { "prototypes", no_argument, nullptr, 'p' }, 627 544 { "deterministic-out", no_argument, nullptr, 'd' }, 628 { "old-ast", no_argument, nullptr, 'O'},629 { "new-ast", no_argument, nullptr, 'A'},630 545 { "print", required_argument, nullptr, 'P' }, 631 546 { "prelude-dir", required_argument, nullptr, PreludeDir }, … … 649 564 "do not generate prelude prototypes => prelude not printed", // -p 650 565 "only print deterministic output", // -d 651 "Use the old-ast", // -O652 "Use the new-ast", // -A653 566 "print", // -P 654 567 "<directory> prelude directory for debug/nodebug", // no flag … … 759 672 deterministic_output = true; 760 673 break; 761 case 'O': // don't print non-deterministic output762 useNewAST = false;763 break;764 case 'A': // don't print non-deterministic output765 useNewAST = true;766 break;767 674 case 'P': // print options 768 675 for ( int i = 0;; i += 1 ) { … … 881 788 882 789 static void dump( ast::TranslationUnit && transUnit, ostream & out ) { 883 std::list< Declaration * > translationUnit = convert( move( transUnit ) );790 std::list< Declaration * > translationUnit = convert( std::move( transUnit ) ); 884 791 dump( translationUnit, out ); 885 792 }
Note:
See TracChangeset
for help on using the changeset viewer.