Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main.cc

    rebcc940 r3c0d4cd  
    6565using namespace std;
    6666
    67 #define PASS(name, pass)                   \
     67
     68void NewPass(const char * const name) {
     69        Stats::Heap::newPass(name);
     70        using namespace Stats::Counters;
     71        static auto pass_visitor_group = build<CounterGroup>("Pass Visitor");
     72        auto pass = build<CounterGroup>(name, pass_visitor_group);
     73        pass_visitor_stats.depth = 0;
     74        pass_visitor_stats.avg = build<AverageCounter<double>>("Average Depth", pass);
     75        pass_visitor_stats.max = build<MaxCounter<double>>("Max Depth", pass);
     76}
     77
     78#define PASS(name, pass)                  \
    6879        if ( errorp ) { cerr << name << endl; } \
    69         Stats::Heap::newPass(name);               \
    70         pass;
     80        NewPass(name);                          \
     81        Stats::Time::StartBlock(name);          \
     82        pass;                                   \
     83        Stats::Time::StopBlock();
    7184
    7285LinkageSpec::Spec linkage = LinkageSpec::Cforall;
     
    142155        backtrace( 6 );                                                                         // skip first 6 stack frames
    143156        signal( SIGABRT, SIG_DFL);                                                      // reset default signal handler
    144     raise( SIGABRT );                                                                   // reraise SIGABRT
     157                raise( SIGABRT );                                                                       // reraise SIGABRT
    145158} // sigAbortHandler
    146159
     
    181194                } // if
    182195
     196                Stats::Time::StartGlobal();
     197                NewPass("Parse");
     198                Stats::Time::StartBlock("Parse");
     199
    183200                // read in the builtins, extras, and the prelude
    184201                if ( ! nopreludep ) {                                                   // include gcc builtins
     
    231248                // works okay for now.
    232249                CodeTools::fillLocations( translationUnit );
     250                Stats::Time::StopBlock();
    233251
    234252                // add the assignment statement after the initialization of a type parameter
    235                 PASS( "validate", SymTab::validate( translationUnit, symtabp ) );
     253                PASS( "Validate", SymTab::validate( translationUnit, symtabp ) );
    236254                if ( symtabp ) {
    237255                        deleteAll( translationUnit );
     
    250268                } // if
    251269
    252                 PASS( "fixLabels", ControlStruct::fixLabels( translationUnit ) );
    253                 PASS( "fixNames", CodeGen::fixNames( translationUnit ) );
    254                 PASS( "genInit", InitTweak::genInit( translationUnit ) );
    255                 PASS( "expandMemberTuples" , Tuples::expandMemberTuples( translationUnit ) );
     270                PASS( "Fix Labels", ControlStruct::fixLabels( translationUnit ) );
     271                PASS( "Fix Names", CodeGen::fixNames( translationUnit ) );
     272                PASS( "Gen Init", InitTweak::genInit( translationUnit ) );
     273                PASS( "Expand Member Tuples" , Tuples::expandMemberTuples( translationUnit ) );
    256274                if ( libcfap ) {
    257275                        // generate the bodies of cfa library functions
     
    277295                }
    278296
    279                 PASS( "resolve", ResolvExpr::resolve( translationUnit ) );
     297                PASS( "Resolve", ResolvExpr::resolve( translationUnit ) );
    280298                if ( exprp ) {
    281299                        dump( translationUnit );
     
    284302
    285303                // fix ObjectDecl - replaces ConstructorInit nodes
    286                 PASS( "fixInit", InitTweak::fix( translationUnit, buildingLibrary() ) );
     304                PASS( "Fix Init", InitTweak::fix( translationUnit, buildingLibrary() ) );
    287305                if ( ctorinitp ) {
    288306                        dump ( translationUnit );
     
    290308                } // if
    291309
    292                 PASS( "expandUniqueExpr", 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
    293 
    294                 PASS( "translateEHM" , ControlStruct::translateEHM( translationUnit ) );
    295 
    296                 PASS( "generateWaitfor" , Concurrency::generateWaitFor( translationUnit ) );
    297 
    298                 PASS( "convertSpecializations",  GenPoly::convertSpecializations( translationUnit ) ); // needs to happen before tuple types are expanded
    299 
    300                 PASS( "expandTuples", Tuples::expandTuples( translationUnit ) ); // xxx - is this the right place for this?
     310                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
     311
     312                PASS( "Translate EHM" , ControlStruct::translateEHM( translationUnit ) );
     313
     314                PASS( "Gen Waitfor" , Concurrency::generateWaitFor( translationUnit ) );
     315
     316                PASS( "Convert Specializations",  GenPoly::convertSpecializations( translationUnit ) ); // needs to happen before tuple types are expanded
     317
     318                PASS( "Expand Tuples", Tuples::expandTuples( translationUnit ) ); // xxx - is this the right place for this?
    301319
    302320                if ( tuplep ) {
     
    305323                }
    306324
    307                 PASS( "virtual expandCasts", Virtual::expandCasts( translationUnit ) ); // Must come after translateEHM
    308 
    309                 PASS( "instantiateGenerics", GenPoly::instantiateGeneric( translationUnit ) );
     325                PASS( "Virtual Expand Casts", Virtual::expandCasts( translationUnit ) ); // Must come after translateEHM
     326
     327                PASS( "Instantiate Generics", GenPoly::instantiateGeneric( translationUnit ) );
    310328                if ( genericsp ) {
    311329                        dump( translationUnit );
    312330                        return 0;
    313331                }
    314                 PASS( "convertLvalue", GenPoly::convertLvalue( translationUnit ) );
     332                PASS( "Convert L-Value", GenPoly::convertLvalue( translationUnit ) );
    315333
    316334
     
    319337                        return 0;
    320338                } // if
    321                 PASS( "box", GenPoly::box( translationUnit ) );
     339                PASS( "Box", GenPoly::box( translationUnit ) );
    322340
    323341                if ( bcodegenp ) {
     
    331349
    332350                CodeTools::fillLocations( translationUnit );
    333                 PASS( "codegen", CodeGen::generate( translationUnit, *output, ! noprotop, prettycodegenp, true, linemarks ) );
     351                PASS( "Code Gen", CodeGen::generate( translationUnit, *output, ! noprotop, prettycodegenp, true, linemarks ) );
    334352
    335353                CodeGen::FixMain::fix( *output, (PreludeDirector + "/bootloader.c").c_str() );
     
    377395
    378396        deleteAll( translationUnit );
    379         if(!libcfap && !treep) {
    380                 if(stats_counters) Stats::Counters::print();
    381                 if(stats_heap) Stats::Heap::print();
    382         }
     397        Stats::print();
    383398
    384399        return 0;
     
    421436        while ( (c = getopt_long( argc, argv, "abBcCdefgGlLmnNpqrRstTvwW:yzZD:F:", long_opts, &long_index )) != -1 ) {
    422437                switch ( c ) {
    423                   case Ast:
    424                   case 'a':                                                                             // dump AST
     438                        case Ast:
     439                        case 'a':                                                                               // dump AST
    425440                        astp = true;
    426441                        break;
    427                   case Bresolver:
    428                   case 'b':                                                                             // print before resolver steps
     442                        case Bresolver:
     443                        case 'b':                                                                               // print before resolver steps
    429444                        bresolvep = true;
    430445                        break;
    431                   case 'B':                                                                             // print before box steps
     446                        case 'B':                                                                               // print before box steps
    432447                        bboxp = true;
    433448                        break;
    434                   case CtorInitFix:
    435                   case 'c':                                                                             // print after constructors and destructors are replaced
     449                        case CtorInitFix:
     450                        case 'c':                                                                               // print after constructors and destructors are replaced
    436451                        ctorinitp = true;
    437452                        break;
    438                   case 'C':                                                                             // print before code generation
     453                        case 'C':                                                                               // print before code generation
    439454                        bcodegenp = true;
    440455                        break;
    441                   case DeclStats:
    442                   case 'd':
    443                     declstatsp = true;
    444                         break;
    445                   case Expr:
    446                   case 'e':                                                                             // dump AST after expression analysis
     456                        case DeclStats:
     457                        case 'd':
     458                                declstatsp = true;
     459                        break;
     460                        case Expr:
     461                        case 'e':                                                                               // dump AST after expression analysis
    447462                        exprp = true;
    448463                        break;
    449                   case ExprAlt:
    450                   case 'f':                                                                             // print alternatives for expressions
     464                        case ExprAlt:
     465                        case 'f':                                                                               // print alternatives for expressions
    451466                        expraltp = true;
    452467                        break;
    453                   case Grammar:
    454                   case 'g':                                                                             // bison debugging info (grammar rules)
     468                        case Grammar:
     469                        case 'g':                                                                               // bison debugging info (grammar rules)
    455470                        yydebug = true;
    456471                        break;
    457                   case 'G':                                                                             // dump AST after instantiate generics
     472                        case 'G':                                                                               // dump AST after instantiate generics
    458473                        genericsp = true;
    459474                        break;
    460                   case LibCFA:
    461                   case 'l':                                                                             // generate libcfa.c
     475                        case LibCFA:
     476                        case 'l':                                                                               // generate libcfa.c
    462477                        libcfap = true;
    463478                        break;
    464                   case Linemarks:
    465                   case 'L':                                                                             // print lines marks
     479                        case Linemarks:
     480                        case 'L':                                                                               // print lines marks
    466481                        linemarks = true;
    467482                        break;
    468                   case Nopreamble:
    469                   case 'n':                                                                             // do not read preamble
     483                        case Nopreamble:
     484                        case 'n':                                                                               // do not read preamble
    470485                        nopreludep = true;
    471486                        break;
    472                   case Nolinemarks:
    473                   case 'N':                                                                             // suppress line marks
     487                        case Nolinemarks:
     488                        case 'N':                                                                               // suppress line marks
    474489                        linemarks = false;
    475490                        break;
    476                   case Prototypes:
    477                   case 'p':                                                                             // generate prototypes for preamble functions
     491                        case Prototypes:
     492                        case 'p':                                                                               // generate prototypes for preamble functions
    478493                        noprotop = true;
    479494                        break;
    480                   case PreludeDir:
    481                         PreludeDirector = optarg;
    482                         break;
    483                   case 'm':                                                                             // don't replace the main
    484                         nomainp = true;
    485                         break;
    486                   case Parse:
    487                   case 'q':                                                                             // dump parse tree
     495                        case PreludeDir:
     496                                PreludeDirector = optarg;
     497                        break;
     498                        case 'm':                                                                               // don't replace the main
     499                                nomainp = true;
     500                        break;
     501                        case Parse:
     502                        case 'q':                                                                               // dump parse tree
    488503                        parsep = true;
    489504                        break;
    490                   case Resolver:
    491                   case 'r':                                                                             // print resolver steps
     505                        case Resolver:
     506                        case 'r':                                                                               // print resolver steps
    492507                        resolvep = true;
    493508                        break;
    494                   case 'R':                                                                             // dump resolv-proto instance
     509                        case 'R':                                                                               // dump resolv-proto instance
    495510                        resolvprotop = true;
    496511                        break;
    497                   case Stats:
    498                         {
    499                                 std::stringstream ss(optarg);
    500                                 while(ss.good()) {
    501                                         std::string substr;
    502                                         getline( ss, substr, ',' );
    503                                         if(substr == "counters") {
    504                                                 stats_counters = true;
    505                                         } else if(substr == "heap") {
    506                                                 stats_heap = true;
    507                                         } else if(substr == "none") {
    508                                                 stats_counters = false;
    509                                                 stats_heap = false;
    510                                         } else {
    511                                                 std::cerr << "Ignoring unknown statistic " << substr << std::endl;
    512                                         }
    513                                 }
    514 
    515                         }
    516                         break;
    517                   case Symbol:
    518                   case 's':                                                                             // print symbol table events
     512                        case Stats:
     513                                Stats::parse_params(optarg);
     514                        break;
     515                        case Symbol:
     516                        case 's':                                                                               // print symbol table events
    519517                        symtabp = true;
    520518                        break;
    521                   case Tree:
    522                   case 't':                                                                             // build in tree
     519                        case Tree:
     520                        case 't':                                                                               // build in tree
    523521                        treep = true;
    524522                        break;
    525                   case TupleExpansion:
    526                   case 'T':                                                                             // print after tuple expansion
     523                        case TupleExpansion:
     524                        case 'T':                                                                               // print after tuple expansion
    527525                        tuplep = true;
    528526                        break;
    529                   case 'v':                                                                             // dump AST after decl validation pass
     527                        case 'v':                                                                               // dump AST after decl validation pass
    530528                        validp = true;
    531529                        break;
    532                   case 'w':
     530                        case 'w':
    533531                        Wsuppress = true;
    534532                        break;
    535                   case 'W':
     533                        case 'W':
    536534                        if ( strcmp( optarg, "all" ) == 0 ) {
    537535                                SemanticWarning_EnableAll();
     
    550548                        } // if
    551549                        break;
    552                   case 'y':                                                                             // dump AST on error
     550                        case 'y':                                                                               // dump AST on error
    553551                        errorp = true;
    554552                        break;
    555                   case 'z':                                                                             // dump as codegen rather than AST
     553                        case 'z':                                                                               // dump as codegen rather than AST
    556554                        codegenp = true;
    557555                        break;
     
    559557                        prettycodegenp = true;
    560558                        break;
    561                   case 'D':                                                                             // ignore -Dxxx
    562                         break;
    563                   case 'F':                                                                             // source file-name without suffix
     559                        case 'D':                                                                               // ignore -Dxxx
     560                        break;
     561                        case 'F':                                                                               // source file-name without suffix
    564562                        filename = optarg;
    565563                        break;
    566                   case '?':
     564                        case '?':
    567565                        if ( optopt ) {                                                         // short option ?
    568566                                assertf( false, "Unknown option: -%c\n", (char)optopt );
     
    573571                                __attribute__((fallthrough));
    574572                        #endif
    575                   default:
     573                        default:
    576574                        abort();
    577575                } // switch
Note: See TracChangeset for help on using the changeset viewer.