Changeset 23a08aa0 for src/main.cc


Ignore:
Timestamp:
Sep 19, 2022, 8:11:02 PM (3 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, ast-experimental, master, pthread-emulation
Children:
aa9f215
Parents:
ebf8ca5 (diff), ae1d151 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

fix merge conflict

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main.cc

    rebf8ca5 r23a08aa0  
    1010// Created On       : Fri May 15 23:12:02 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Thu 11 12:18:00 2022
    13 // Update Count     : 677
     12// Last Modified On : Thu Sep 15 13:58:00 2022
     13// Update Count     : 678
    1414//
    1515
     
    3838#include "CodeGen/Generate.h"               // for generate
    3939#include "CodeGen/LinkOnce.h"               // for translateLinkOnce
    40 #include "CodeTools/DeclStats.h"            // for printDeclStats
    41 #include "CodeTools/ResolvProtoDump.h"      // for dumpAsResolvProto
    4240#include "CodeTools/TrackLoc.h"             // for fillLocations
    4341#include "Common/CodeLocationTools.hpp"     // for forceFillCodeLocations
     
    4543#include "Common/DeclStats.hpp"             // for printDeclStats
    4644#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
    5046#include "Common/UnimplementedError.h"      // for UnimplementedError
    5147#include "Common/utility.h"                 // for deleteAll, filter, printAll
     
    5349#include "Concurrency/Waitfor.h"            // for generateWaitfor
    5450#include "ControlStruct/ExceptDecl.h"       // for translateExcept
    55 #include "ControlStruct/ExceptTranslate.h"  // for translateEHM
     51#include "ControlStruct/ExceptTranslate.h"  // for translateThrows, translat...
    5652#include "ControlStruct/FixLabels.hpp"      // for fixLabels
    5753#include "ControlStruct/HoistControlDecls.hpp" //  hoistControlDecls
    58 #include "ControlStruct/Mutate.h"           // for mutate
    5954#include "GenPoly/Box.h"                    // for box
    6055#include "GenPoly/InstantiateGeneric.h"     // for instantiateGeneric
     
    6661#include "Parser/ParseNode.h"               // for DeclarationNode, buildList
    6762#include "Parser/TypedefTable.h"            // for TypedefTable
    68 #include "ResolvExpr/AlternativePrinter.h"  // for AlternativePrinter
    6963#include "ResolvExpr/CandidatePrinter.hpp"  // for printCandidates
    7064#include "ResolvExpr/Resolver.h"            // for resolve
    71 #include "SymTab/Validate.h"                // for validate
    72 #include "SymTab/ValidateType.h"            // for linkReferenceToTypes
    7365#include "SynTree/LinkageSpec.h"            // for Spec, Cforall, Intrinsic
    7466#include "SynTree/Declaration.h"            // for Declaration
    75 #include "SynTree/Visitor.h"                // for acceptAll
    7667#include "Tuples/Tuples.h"                  // for expandMemberTuples, expan...
    7768#include "Validate/Autogen.hpp"             // for autogenerateRoutines
     
    330321                Stats::Time::StopBlock();
    331322
    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                         translationUnit = convert( move( transUnit ) );
    456                 } else {
    457                         PASS( "Translate Exception Declarations", ControlStruct::translateExcept( translationUnit ) );
    458                         if ( exdeclp ) {
    459                                 dump( translationUnit );
    460                                 return EXIT_SUCCESS;
    461                         } // if
    462 
    463                         // add the assignment statement after the initialization of a type parameter
    464                         PASS( "Validate", SymTab::validate( translationUnit ) );
    465 
    466                         if ( symtabp ) {
    467                                 deleteAll( translationUnit );
    468                                 return EXIT_SUCCESS;
    469                         } // if
    470 
    471                         if ( expraltp ) {
    472                                 PassVisitor<ResolvExpr::AlternativePrinter> printer( cout );
    473                                 acceptAll( translationUnit, printer );
    474                                 return EXIT_SUCCESS;
    475                         } // if
    476 
    477                         if ( validp ) {
    478                                 dump( translationUnit );
    479                                 return EXIT_SUCCESS;
    480                         } // if
    481 
    482                         PASS( "Translate Throws", ControlStruct::translateThrows( translationUnit ) );
    483                         PASS( "Fix Labels", ControlStruct::fixLabels( translationUnit ) );
    484                         PASS( "Fix Names", CodeGen::fixNames( translationUnit ) );
    485                         PASS( "Gen Init", InitTweak::genInit( translationUnit ) );
    486                         PASS( "Expand Member Tuples" , Tuples::expandMemberTuples( translationUnit ) );
    487 
    488                         if ( libcfap ) {
    489                                 // Generate the bodies of cfa library functions.
    490                                 LibCfa::makeLibCfa( translationUnit );
    491                         } // if
    492 
    493                         if ( declstatsp ) {
    494                                 CodeTools::printDeclStats( translationUnit );
    495                                 deleteAll( translationUnit );
    496                                 return EXIT_SUCCESS;
    497                         } // if
    498 
    499                         if ( bresolvep ) {
    500                                 dump( translationUnit );
    501                                 return EXIT_SUCCESS;
    502                         } // if
    503 
    504                         CodeTools::fillLocations( translationUnit );
    505 
    506                         if ( resolvprotop ) {
    507                                 CodeTools::dumpAsResolvProto( translationUnit );
    508                                 return EXIT_SUCCESS;
    509                         } // if
    510 
    511                         PASS( "Resolve", ResolvExpr::resolve( translationUnit ) );
    512                         if ( exprp ) {
    513                                 dump( translationUnit );
    514                                 return EXIT_SUCCESS;
    515                         }
    516 
    517                         PASS( "Fix Init", InitTweak::fix( translationUnit, buildingLibrary() ) );
    518 
    519                         // fix ObjectDecl - replaces ConstructorInit nodes
    520                         if ( ctorinitp ) {
    521                                 dump ( translationUnit );
    522                                 return EXIT_SUCCESS;
    523                         } // if
    524 
    525                         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
    526                         PASS( "Translate Tries", ControlStruct::translateTries( translationUnit ) );
    527                         PASS( "Gen Waitfor", Concurrency::generateWaitFor( translationUnit ) );
    528                         PASS( "Convert Specializations",  GenPoly::convertSpecializations( translationUnit ) ); // needs to happen before tuple types are expanded
    529                         PASS( "Expand Tuples", Tuples::expandTuples( translationUnit ) ); // xxx - is this the right place for this?
    530 
    531                         if ( tuplep ) {
    532                                 dump( translationUnit );
    533                                 return EXIT_SUCCESS;
    534                         } // if
    535 
    536                         PASS( "Virtual Expand Casts", Virtual::expandCasts( translationUnit ) ); // Must come after translateEHM
     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");
    537326                }
    538 
    539                 PASS( "Instantiate Generics", GenPoly::instantiateGeneric( translationUnit ) );
     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 ) );
     436
     437                if ( tuplep ) {
     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
    540449                if ( genericsp ) {
    541450                        dump( translationUnit );
     
    620529
    621530
    622 static const char optstring[] = ":c:ghlLmNnpdOAP:S:twW:D:";
     531static const char optstring[] = ":c:ghlLmNnpdP:S:twW:D:";
    623532
    624533enum { PreludeDir = 128 };
     
    634543        { "prototypes", no_argument, nullptr, 'p' },
    635544        { "deterministic-out", no_argument, nullptr, 'd' },
    636         { "old-ast", no_argument, nullptr, 'O'},
    637         { "new-ast", no_argument, nullptr, 'A'},
    638545        { "print", required_argument, nullptr, 'P' },
    639546        { "prelude-dir", required_argument, nullptr, PreludeDir },
     
    657564        "do not generate prelude prototypes => prelude not printed", // -p
    658565        "only print deterministic output",                  // -d
    659         "Use the old-ast",                                                                      // -O
    660         "Use the new-ast",                                                                      // -A
    661566        "print",                                                                                        // -P
    662567        "<directory> prelude directory for debug/nodebug",      // no flag
     
    767672                        deterministic_output = true;
    768673                        break;
    769                   case 'O':                                     // don't print non-deterministic output
    770                         useNewAST = false;
    771                         break;
    772                   case 'A':                                     // don't print non-deterministic output
    773                         useNewAST = true;
    774                         break;
    775674                  case 'P':                                                                             // print options
    776675                        for ( int i = 0;; i += 1 ) {
     
    889788
    890789static void dump( ast::TranslationUnit && transUnit, ostream & out ) {
    891         std::list< Declaration * > translationUnit = convert( move( transUnit ) );
     790        std::list< Declaration * > translationUnit = convert( std::move( transUnit ) );
    892791        dump( translationUnit, out );
    893792}
Note: See TracChangeset for help on using the changeset viewer.