Changeset 6e1e2d0 for src/main.cc


Ignore:
Timestamp:
May 1, 2023, 4:19:09 PM (15 months ago)
Author:
caparsons <caparson@…>
Branches:
ADT, ast-experimental, master
Children:
c083c3d
Parents:
a50fdfb (diff), 985b624 (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:

resolved merge conflicts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main.cc

    ra50fdfb r6e1e2d0  
    99// Author           : Peter Buhr and Rob Schluntz
    1010// Created On       : Fri May 15 23:12:02 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Thr Feb 16 10:08:00 2023
    13 // Update Count     : 680
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Mon Apr 10 21:12:17 2023
     13// Update Count     : 682
    1414//
    1515
     
    3232
    3333#include "AST/Convert.hpp"
     34#include "AST/Util.hpp"                     // for checkInvariants
    3435#include "CompilationState.h"
    3536#include "../config.h"                      // for CFA_LIBDIR
     
    102103}
    103104
    104 #define PASS( name, pass )                  \
     105// Helpers for checkInvariant:
     106void checkInvariants( std::list< Declaration * > & ) {}
     107using ast::checkInvariants;
     108
     109#define PASS( name, pass, unit, ... )       \
    105110        if ( errorp ) { cerr << name << endl; } \
    106111        NewPass(name);                          \
    107112        Stats::Time::StartBlock(name);          \
    108         pass;                                   \
    109         Stats::Time::StopBlock();
     113        pass(unit,##__VA_ARGS__);               \
     114        Stats::Time::StopBlock();               \
     115        if ( invariant ) {                      \
     116                checkInvariants(unit);              \
     117        }
     118
     119#define DUMP( cond, unit )                  \
     120        if ( cond ) {                           \
     121                dump(unit);                         \
     122                return EXIT_SUCCESS;                \
     123        }
    110124
    111125static bool waiting_for_gdb = false;                                    // flag to set cfa-cpp to wait for gdb on start
     
    298312                transUnit = buildUnit();
    299313
    300                 if ( astp ) {
    301                         dump( std::move( transUnit ) );
    302                         return EXIT_SUCCESS;
    303                 } // if
     314                DUMP( astp, std::move( transUnit ) );
    304315
    305316                Stats::Time::StopBlock();
     
    310321                }
    311322
    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 ) );
     323                PASS( "Hoist Type Decls", Validate::hoistTypeDecls, transUnit );
     324
     325                PASS( "Translate Exception Declarations", ControlStruct::translateExcept, transUnit );
     326                DUMP( exdeclp, std::move( transUnit ) );
     327                PASS( "Verify Ctor, Dtor & Assign", Validate::verifyCtorDtorAssign, transUnit );
     328                PASS( "Replace Typedefs", Validate::replaceTypedef, transUnit );
     329                PASS( "Fix Return Types", Validate::fixReturnTypes, transUnit );
     330                PASS( "Enum and Pointer Decay", Validate::decayEnumsAndPointers, transUnit );
     331
     332                PASS( "Link Reference To Types", Validate::linkReferenceToTypes, transUnit );
     333
     334                PASS( "Fix Qualified Types", Validate::fixQualifiedTypes, transUnit );
     335                PASS( "Hoist Struct", Validate::hoistStruct, transUnit );
     336                PASS( "Eliminate Typedef", Validate::eliminateTypedef, transUnit );
     337                PASS( "Validate Generic Parameters", Validate::fillGenericParameters, transUnit );
     338                PASS( "Translate Dimensions", Validate::translateDimensionParameters, transUnit );
     339                PASS( "Check Function Returns", Validate::checkReturnStatements, transUnit );
     340                PASS( "Fix Return Statements", InitTweak::fixReturnStatements, transUnit );
     341                PASS( "Implement Concurrent Keywords", Concurrency::implementKeywords, transUnit );
     342                PASS( "Forall Pointer Decay", Validate::decayForallPointers, transUnit );
     343        PASS( "Implement Waituntil", Concurrency::generateWaitUntil, transUnit  );
     344                PASS( "Hoist Control Declarations", ControlStruct::hoistControlDecls, transUnit );
     345
     346                PASS( "Generate Autogen Routines", Validate::autogenerateRoutines, transUnit );
     347
     348                PASS( "Implement Actors", Concurrency::implementActors, transUnit );
     349                PASS( "Implement Virtual Destructors", Virtual::implementVirtDtors, transUnit );
     350                PASS( "Implement Mutex", Concurrency::implementMutex, transUnit );
     351                PASS( "Implement Thread Start", Concurrency::implementThreadStarter, transUnit );
     352                PASS( "Compound Literal", Validate::handleCompoundLiterals, transUnit );
     353                PASS( "Set Length From Initializer", Validate::setLengthFromInitializer, transUnit );
     354                PASS( "Find Global Decls", Validate::findGlobalDecls, transUnit );
     355                PASS( "Fix Label Address", Validate::fixLabelAddresses, transUnit );
    353356
    354357                if ( symtabp ) {
     
    361364                } // if
    362365
    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 ) );
     366                DUMP( validp, std::move( transUnit ) );
     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 );
    373373
    374374                if ( libcfap ) {
     
    382382                } // if
    383383
    384                 if ( bresolvep ) {
    385                         dump( std::move( transUnit ) );
    386                         return EXIT_SUCCESS;
    387                 } // if
     384                DUMP( bresolvep, std::move( transUnit ) );
    388385
    389386                if ( resolvprotop ) {
     
    392389                } // if
    393390
    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()));
     391                PASS( "Resolve", ResolvExpr::resolve, transUnit );
     392                DUMP( exprp, std::move( transUnit ) );
     393
     394                PASS( "Fix Init", InitTweak::fix, transUnit, buildingLibrary() );
    403395
    404396                // fix ObjectDecl - replaces ConstructorInit nodes
    405                 if ( ctorinitp ) {
    406                         dump( std::move( transUnit ) );
    407                         return EXIT_SUCCESS;
    408                 } // if
     397                DUMP( ctorinitp, std::move( transUnit ) );
    409398
    410399                // Currently not working due to unresolved issues with UniqueExpr
    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 ) );
     400                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
     401
     402                PASS( "Translate Tries", ControlStruct::translateTries, transUnit );
     403                PASS( "Gen Waitfor", Concurrency::generateWaitFor, transUnit );
    415404
    416405                // Needs to happen before tuple types are expanded.
    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
     406                PASS( "Convert Specializations",  GenPoly::convertSpecializations, transUnit );
     407
     408                PASS( "Expand Tuples", Tuples::expandTuples, transUnit );
     409                DUMP( tuplep, std::move( transUnit ) );
    425410
    426411                // Must come after Translate Tries.
    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 ) );
     412                PASS( "Virtual Expand Casts", Virtual::expandCasts, transUnit );
     413
     414                PASS( "Instantiate Generics", GenPoly::instantiateGeneric, transUnit );
     415                DUMP( genericsp, std::move( transUnit ) );
     416
     417                PASS( "Convert L-Value", GenPoly::convertLvalue, transUnit );
    436418
    437419                translationUnit = convert( std::move( transUnit ) );
    438420
    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 ) );
     421                DUMP( bboxp, translationUnit );
     422                PASS( "Box", GenPoly::box, translationUnit );
     423
     424                PASS( "Link-Once", CodeGen::translateLinkOnce, translationUnit );
    446425
    447426                // Code has been lowered to C, now we can start generation.
    448427
    449                 if ( bcodegenp ) {
    450                         dump( translationUnit );
    451                         return EXIT_SUCCESS;
    452                 } // if
     428                DUMP( bcodegenp, translationUnit );
    453429
    454430                if ( optind < argc ) {                                                  // any commands after the flags and input file ? => output file name
     
    457433
    458434                CodeTools::fillLocations( translationUnit );
    459                 PASS( "Code Gen", CodeGen::generate( translationUnit, *output, ! genproto, prettycodegenp, true, linemarks ) );
     435                PASS( "Code Gen", CodeGen::generate, translationUnit, *output, ! genproto, prettycodegenp, true, linemarks );
    460436
    461437                CodeGen::FixMain::fix( translationUnit, *output,
     
    505481
    506482
    507 static const char optstring[] = ":c:ghlLmNnpdP:S:twW:D:";
     483static const char optstring[] = ":c:ghilLmNnpdP:S:twW:D:";
    508484
    509485enum { PreludeDir = 128 };
     
    512488        { "gdb", no_argument, nullptr, 'g' },
    513489        { "help", no_argument, nullptr, 'h' },
     490        { "invariant", no_argument, nullptr, 'i' },
    514491        { "libcfa", no_argument, nullptr, 'l' },
    515492        { "linemarks", no_argument, nullptr, 'L' },
    516         { "no-main", no_argument, 0, 'm' },
     493        { "no-main", no_argument, nullptr, 'm' },
    517494        { "no-linemarks", no_argument, nullptr, 'N' },
    518495        { "no-prelude", no_argument, nullptr, 'n' },
     
    533510        "wait for gdb to attach",                                                       // -g
    534511        "print translator help message",                                        // -h
     512        "invariant checking during AST passes",                         // -i
    535513        "generate libcfa.c",                                                            // -l
    536514        "generate line marks",                                                          // -L
     
    626604                        usage( argv );                                                          // no return
    627605                        break;
     606                  case 'i':                                                                             // invariant checking
     607                        invariant = true;
     608                        break;
    628609                  case 'l':                                                                             // generate libcfa.c
    629610                        libcfap = true;
Note: See TracChangeset for help on using the changeset viewer.