Changeset 53bb8f1 for src/main.cc
- Timestamp:
- Mar 12, 2019, 3:00:54 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 30e32b2, a2545593
- Parents:
- 9d9a451 (diff), 91d6584 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main.cc
r9d9a451 r53bb8f1 10 10 // Created On : Fri May 15 23:12:02 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jun 6 15:51:47 201813 // Update Count : 49812 // Last Modified On : Sat Feb 16 09:14:04 2019 13 // Update Count : 500 14 14 // 15 15 … … 37 37 #include "CodeTools/TrackLoc.h" // for fillLocations 38 38 #include "Common/CompilerError.h" // for CompilerError 39 #include "Common/ Heap.h"39 #include "Common/Stats.h" 40 40 #include "Common/PassVisitor.h" 41 41 #include "Common/SemanticError.h" // for SemanticError … … 65 65 using namespace std; 66 66 67 #define PASS(name, pass) \ 67 68 void 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) \ 68 79 if ( errorp ) { cerr << name << endl; } \ 69 HeapStats::newPass(name); \ 70 pass; 80 NewPass(name); \ 81 Stats::Time::StartBlock(name); \ 82 pass; \ 83 Stats::Time::StopBlock(); 71 84 72 85 LinkageSpec::Spec linkage = LinkageSpec::Cforall; … … 142 155 backtrace( 6 ); // skip first 6 stack frames 143 156 signal( SIGABRT, SIG_DFL); // reset default signal handler 144 157 raise( SIGABRT ); // reraise SIGABRT 145 158 } // sigAbortHandler 146 159 … … 148 161 int main( int argc, char * argv[] ) { 149 162 FILE * input; // use FILE rather than istream because yyin is FILE 150 ostream * output = & cout;151 const char * filename = nullptr;163 ostream * output = & cout; 164 const char * filename = nullptr; 152 165 list< Declaration * > translationUnit; 153 166 … … 181 194 } // if 182 195 196 Stats::Time::StartGlobal(); 197 NewPass("Parse"); 198 Stats::Time::StartBlock("Parse"); 199 183 200 // read in the builtins, extras, and the prelude 184 201 if ( ! nopreludep ) { // include gcc builtins … … 231 248 // works okay for now. 232 249 CodeTools::fillLocations( translationUnit ); 250 Stats::Time::StopBlock(); 233 251 234 252 // 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 ) ); 236 254 if ( symtabp ) { 237 255 deleteAll( translationUnit ); … … 250 268 } // if 251 269 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 ) ); 256 274 if ( libcfap ) { 257 275 // generate the bodies of cfa library functions … … 277 295 } 278 296 279 PASS( " resolve", ResolvExpr::resolve( translationUnit ) );297 PASS( "Resolve", ResolvExpr::resolve( translationUnit ) ); 280 298 if ( exprp ) { 281 299 dump( translationUnit ); … … 284 302 285 303 // fix ObjectDecl - replaces ConstructorInit nodes 286 PASS( " fixInit", InitTweak::fix( translationUnit, buildingLibrary() ) );304 PASS( "Fix Init", InitTweak::fix( translationUnit, buildingLibrary() ) ); 287 305 if ( ctorinitp ) { 288 306 dump ( translationUnit ); … … 290 308 } // if 291 309 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 reused293 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 expanded299 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? 301 319 302 320 if ( tuplep ) { … … 305 323 } 306 324 307 PASS( " virtual expandCasts", Virtual::expandCasts( translationUnit ) ); // Must come after translateEHM308 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 ) ); 310 328 if ( genericsp ) { 311 329 dump( translationUnit ); 312 330 return 0; 313 331 } 314 PASS( " convertLvalue", GenPoly::convertLvalue( translationUnit ) );332 PASS( "Convert L-Value", GenPoly::convertLvalue( translationUnit ) ); 315 333 316 334 … … 319 337 return 0; 320 338 } // if 321 PASS( " box", GenPoly::box( translationUnit ) );339 PASS( "Box", GenPoly::box( translationUnit ) ); 322 340 323 341 if ( bcodegenp ) { … … 331 349 332 350 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 ) ); 334 352 335 353 CodeGen::FixMain::fix( *output, (PreludeDirector + "/bootloader.c").c_str() ); … … 371 389 } 372 390 } catch(const std::exception& e) { 373 std::cerr << "Un aught Exception \"" << e.what() << "\"\n";391 std::cerr << "Uncaught Exception \"" << e.what() << "\"\n"; 374 392 } 375 393 return 1; … … 377 395 378 396 deleteAll( translationUnit ); 379 if(!libcfap && !treep) HeapStats::printStats(); 397 Stats::print(); 398 380 399 return 0; 381 400 } // main 382 401 383 402 void parse_cmdline( int argc, char * argv[], const char *& filename ) { 384 enum { Ast, Bbox, Bresolver, CtorInitFix, DeclStats, Expr, ExprAlt, Grammar, LibCFA, Linemarks, Nolinemarks, Nopreamble, Parse, PreludeDir, Prototypes, Resolver, ResolvProto, S ymbol, Tree, TupleExpansion, Validate,};403 enum { Ast, Bbox, Bresolver, CtorInitFix, DeclStats, Expr, ExprAlt, Grammar, LibCFA, Linemarks, Nolinemarks, Nopreamble, Parse, PreludeDir, Prototypes, Resolver, ResolvProto, Stats, Symbol, Tree, TupleExpansion, Validate}; 385 404 386 405 static struct option long_opts[] = { … … 402 421 { "resolver", no_argument, 0, Resolver }, 403 422 { "resolv-proto", no_argument, 0, ResolvProto }, 423 { "stats", required_argument, 0, Stats }, 404 424 { "symbol", no_argument, 0, Symbol }, 405 425 { "tree", no_argument, 0, Tree }, … … 416 436 while ( (c = getopt_long( argc, argv, "abBcCdefgGlLmnNpqrRstTvwW:yzZD:F:", long_opts, &long_index )) != -1 ) { 417 437 switch ( c ) { 418 419 438 case Ast: 439 case 'a': // dump AST 420 440 astp = true; 421 441 break; 422 423 442 case Bresolver: 443 case 'b': // print before resolver steps 424 444 bresolvep = true; 425 445 break; 426 446 case 'B': // print before box steps 427 447 bboxp = true; 428 448 break; 429 430 449 case CtorInitFix: 450 case 'c': // print after constructors and destructors are replaced 431 451 ctorinitp = true; 432 452 break; 433 453 case 'C': // print before code generation 434 454 bcodegenp = true; 435 455 break; 436 437 438 439 break; 440 441 456 case DeclStats: 457 case 'd': 458 declstatsp = true; 459 break; 460 case Expr: 461 case 'e': // dump AST after expression analysis 442 462 exprp = true; 443 463 break; 444 445 464 case ExprAlt: 465 case 'f': // print alternatives for expressions 446 466 expraltp = true; 447 467 break; 448 449 468 case Grammar: 469 case 'g': // bison debugging info (grammar rules) 450 470 yydebug = true; 451 471 break; 452 472 case 'G': // dump AST after instantiate generics 453 473 genericsp = true; 454 474 break; 455 456 475 case LibCFA: 476 case 'l': // generate libcfa.c 457 477 libcfap = true; 458 478 break; 459 460 479 case Linemarks: 480 case 'L': // print lines marks 461 481 linemarks = true; 462 482 break; 463 464 483 case Nopreamble: 484 case 'n': // do not read preamble 465 485 nopreludep = true; 466 486 break; 467 468 487 case Nolinemarks: 488 case 'N': // suppress line marks 469 489 linemarks = false; 470 490 break; 471 472 491 case Prototypes: 492 case 'p': // generate prototypes for preamble functions 473 493 noprotop = true; 474 494 break; 475 476 477 break; 478 479 480 break; 481 482 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 483 503 parsep = true; 484 504 break; 485 486 505 case Resolver: 506 case 'r': // print resolver steps 487 507 resolvep = true; 488 508 break; 489 509 case 'R': // dump resolv-proto instance 490 510 resolvprotop = true; 491 511 break; 492 case Symbol: 493 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 494 517 symtabp = true; 495 518 break; 496 497 519 case Tree: 520 case 't': // build in tree 498 521 treep = true; 499 522 break; 500 501 523 case TupleExpansion: 524 case 'T': // print after tuple expansion 502 525 tuplep = true; 503 526 break; 504 527 case 'v': // dump AST after decl validation pass 505 528 validp = true; 506 529 break; 507 530 case 'w': 508 531 Wsuppress = true; 509 532 break; 510 533 case 'W': 511 534 if ( strcmp( optarg, "all" ) == 0 ) { 512 535 SemanticWarning_EnableAll(); … … 525 548 } // if 526 549 break; 527 550 case 'y': // dump AST on error 528 551 errorp = true; 529 552 break; 530 553 case 'z': // dump as codegen rather than AST 531 554 codegenp = true; 532 555 break; … … 534 557 prettycodegenp = true; 535 558 break; 536 537 break; 538 559 case 'D': // ignore -Dxxx 560 break; 561 case 'F': // source file-name without suffix 539 562 filename = optarg; 540 563 break; 541 564 case '?': 542 565 if ( optopt ) { // short option ? 543 566 assertf( false, "Unknown option: -%c\n", (char)optopt ); … … 548 571 __attribute__((fallthrough)); 549 572 #endif 550 573 default: 551 574 abort(); 552 575 } // switch
Note:
See TracChangeset
for help on using the changeset viewer.