Changes in src/main.cc [3c0d4cd:a2dbcff1]
- File:
-
- 1 edited
-
src/main.cc (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/main.cc
r3c0d4cd ra2dbcff1 10 10 // Created On : Fri May 15 23:12:02 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Feb 16 09:14:04 201913 // Update Count : 50012 // Last Modified On : Wed Jun 6 15:51:47 2018 13 // Update Count : 498 14 14 // 15 15 … … 37 37 #include "CodeTools/TrackLoc.h" // for fillLocations 38 38 #include "Common/CompilerError.h" // for CompilerError 39 #include "Common/ Stats.h"39 #include "Common/Heap.h" 40 40 #include "Common/PassVisitor.h" 41 41 #include "Common/SemanticError.h" // for SemanticError … … 65 65 using namespace std; 66 66 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) \ 67 #define PASS(name, pass) \ 79 68 if ( errorp ) { cerr << name << endl; } \ 80 NewPass(name); \ 81 Stats::Time::StartBlock(name); \ 82 pass; \ 83 Stats::Time::StopBlock(); 69 HeapStats::newPass(name); \ 70 pass; 84 71 85 72 LinkageSpec::Spec linkage = LinkageSpec::Cforall; … … 155 142 backtrace( 6 ); // skip first 6 stack frames 156 143 signal( SIGABRT, SIG_DFL); // reset default signal handler 157 raise( SIGABRT ); // reraise SIGABRT144 raise( SIGABRT ); // reraise SIGABRT 158 145 } // sigAbortHandler 159 146 … … 161 148 int main( int argc, char * argv[] ) { 162 149 FILE * input; // use FILE rather than istream because yyin is FILE 163 ostream * output = & cout;164 const char * filename = nullptr;150 ostream *output = & cout; 151 const char *filename = nullptr; 165 152 list< Declaration * > translationUnit; 166 153 … … 194 181 } // if 195 182 196 Stats::Time::StartGlobal();197 NewPass("Parse");198 Stats::Time::StartBlock("Parse");199 200 183 // read in the builtins, extras, and the prelude 201 184 if ( ! nopreludep ) { // include gcc builtins … … 248 231 // works okay for now. 249 232 CodeTools::fillLocations( translationUnit ); 250 Stats::Time::StopBlock();251 233 252 234 // add the assignment statement after the initialization of a type parameter 253 PASS( " Validate", SymTab::validate( translationUnit, symtabp ) );235 PASS( "validate", SymTab::validate( translationUnit, symtabp ) ); 254 236 if ( symtabp ) { 255 237 deleteAll( translationUnit ); … … 268 250 } // if 269 251 270 PASS( " FixLabels", ControlStruct::fixLabels( translationUnit ) );271 PASS( " FixNames", CodeGen::fixNames( translationUnit ) );272 PASS( " GenInit", InitTweak::genInit( translationUnit ) );273 PASS( " Expand MemberTuples" , Tuples::expandMemberTuples( translationUnit ) );252 PASS( "fixLabels", ControlStruct::fixLabels( translationUnit ) ); 253 PASS( "fixNames", CodeGen::fixNames( translationUnit ) ); 254 PASS( "genInit", InitTweak::genInit( translationUnit ) ); 255 PASS( "expandMemberTuples" , Tuples::expandMemberTuples( translationUnit ) ); 274 256 if ( libcfap ) { 275 257 // generate the bodies of cfa library functions … … 295 277 } 296 278 297 PASS( " Resolve", ResolvExpr::resolve( translationUnit ) );279 PASS( "resolve", ResolvExpr::resolve( translationUnit ) ); 298 280 if ( exprp ) { 299 281 dump( translationUnit ); … … 302 284 303 285 // fix ObjectDecl - replaces ConstructorInit nodes 304 PASS( " FixInit", InitTweak::fix( translationUnit, buildingLibrary() ) );286 PASS( "fixInit", InitTweak::fix( translationUnit, buildingLibrary() ) ); 305 287 if ( ctorinitp ) { 306 288 dump ( translationUnit ); … … 308 290 } // if 309 291 310 PASS( " Expand UniqueExpr", 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 reused311 312 PASS( " TranslateEHM" , ControlStruct::translateEHM( translationUnit ) );313 314 PASS( " GenWaitfor" , Concurrency::generateWaitFor( translationUnit ) );315 316 PASS( " ConvertSpecializations", GenPoly::convertSpecializations( translationUnit ) ); // needs to happen before tuple types are expanded317 318 PASS( " ExpandTuples", Tuples::expandTuples( translationUnit ) ); // xxx - is this the right place for this?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? 319 301 320 302 if ( tuplep ) { … … 323 305 } 324 306 325 PASS( " Virtual ExpandCasts", Virtual::expandCasts( translationUnit ) ); // Must come after translateEHM326 327 PASS( " InstantiateGenerics", GenPoly::instantiateGeneric( translationUnit ) );307 PASS( "virtual expandCasts", Virtual::expandCasts( translationUnit ) ); // Must come after translateEHM 308 309 PASS( "instantiateGenerics", GenPoly::instantiateGeneric( translationUnit ) ); 328 310 if ( genericsp ) { 329 311 dump( translationUnit ); 330 312 return 0; 331 313 } 332 PASS( " Convert L-Value", GenPoly::convertLvalue( translationUnit ) );314 PASS( "convertLvalue", GenPoly::convertLvalue( translationUnit ) ); 333 315 334 316 … … 337 319 return 0; 338 320 } // if 339 PASS( " Box", GenPoly::box( translationUnit ) );321 PASS( "box", GenPoly::box( translationUnit ) ); 340 322 341 323 if ( bcodegenp ) { … … 349 331 350 332 CodeTools::fillLocations( translationUnit ); 351 PASS( " Code Gen", CodeGen::generate( translationUnit, *output, ! noprotop, prettycodegenp, true, linemarks ) );333 PASS( "codegen", CodeGen::generate( translationUnit, *output, ! noprotop, prettycodegenp, true, linemarks ) ); 352 334 353 335 CodeGen::FixMain::fix( *output, (PreludeDirector + "/bootloader.c").c_str() ); … … 389 371 } 390 372 } catch(const std::exception& e) { 391 std::cerr << "Un caught Exception \"" << e.what() << "\"\n";373 std::cerr << "Unaught Exception \"" << e.what() << "\"\n"; 392 374 } 393 375 return 1; … … 395 377 396 378 deleteAll( translationUnit ); 397 Stats::print(); 398 379 if(!libcfap && !treep) HeapStats::printStats(); 399 380 return 0; 400 381 } // main 401 382 402 383 void parse_cmdline( int argc, char * argv[], const char *& filename ) { 403 enum { Ast, Bbox, Bresolver, CtorInitFix, DeclStats, Expr, ExprAlt, Grammar, LibCFA, Linemarks, Nolinemarks, Nopreamble, Parse, PreludeDir, Prototypes, Resolver, ResolvProto, S tats, Symbol, Tree, TupleExpansion, Validate};384 enum { Ast, Bbox, Bresolver, CtorInitFix, DeclStats, Expr, ExprAlt, Grammar, LibCFA, Linemarks, Nolinemarks, Nopreamble, Parse, PreludeDir, Prototypes, Resolver, ResolvProto, Symbol, Tree, TupleExpansion, Validate, }; 404 385 405 386 static struct option long_opts[] = { … … 421 402 { "resolver", no_argument, 0, Resolver }, 422 403 { "resolv-proto", no_argument, 0, ResolvProto }, 423 { "stats", required_argument, 0, Stats },424 404 { "symbol", no_argument, 0, Symbol }, 425 405 { "tree", no_argument, 0, Tree }, … … 436 416 while ( (c = getopt_long( argc, argv, "abBcCdefgGlLmnNpqrRstTvwW:yzZD:F:", long_opts, &long_index )) != -1 ) { 437 417 switch ( c ) { 438 case Ast:439 case 'a': // dump AST418 case Ast: 419 case 'a': // dump AST 440 420 astp = true; 441 421 break; 442 case Bresolver:443 case 'b': // print before resolver steps422 case Bresolver: 423 case 'b': // print before resolver steps 444 424 bresolvep = true; 445 425 break; 446 case 'B': // print before box steps426 case 'B': // print before box steps 447 427 bboxp = true; 448 428 break; 449 case CtorInitFix:450 case 'c': // print after constructors and destructors are replaced429 case CtorInitFix: 430 case 'c': // print after constructors and destructors are replaced 451 431 ctorinitp = true; 452 432 break; 453 case 'C': // print before code generation433 case 'C': // print before code generation 454 434 bcodegenp = true; 455 435 break; 456 case DeclStats:457 case 'd':458 declstatsp = true;459 break; 460 case Expr:461 case 'e': // dump AST after expression analysis436 case DeclStats: 437 case 'd': 438 declstatsp = true; 439 break; 440 case Expr: 441 case 'e': // dump AST after expression analysis 462 442 exprp = true; 463 443 break; 464 case ExprAlt:465 case 'f': // print alternatives for expressions444 case ExprAlt: 445 case 'f': // print alternatives for expressions 466 446 expraltp = true; 467 447 break; 468 case Grammar:469 case 'g': // bison debugging info (grammar rules)448 case Grammar: 449 case 'g': // bison debugging info (grammar rules) 470 450 yydebug = true; 471 451 break; 472 case 'G': // dump AST after instantiate generics452 case 'G': // dump AST after instantiate generics 473 453 genericsp = true; 474 454 break; 475 case LibCFA:476 case 'l': // generate libcfa.c455 case LibCFA: 456 case 'l': // generate libcfa.c 477 457 libcfap = true; 478 458 break; 479 case Linemarks:480 case 'L': // print lines marks459 case Linemarks: 460 case 'L': // print lines marks 481 461 linemarks = true; 482 462 break; 483 case Nopreamble:484 case 'n': // do not read preamble463 case Nopreamble: 464 case 'n': // do not read preamble 485 465 nopreludep = true; 486 466 break; 487 case Nolinemarks:488 case 'N': // suppress line marks467 case Nolinemarks: 468 case 'N': // suppress line marks 489 469 linemarks = false; 490 470 break; 491 case Prototypes:492 case 'p': // generate prototypes for preamble functions471 case Prototypes: 472 case 'p': // generate prototypes for preamble functions 493 473 noprotop = true; 494 474 break; 495 case PreludeDir:496 PreludeDirector = optarg;497 break; 498 case 'm': // don't replace the main499 nomainp = true;500 break; 501 case Parse:502 case 'q': // dump parse tree475 case PreludeDir: 476 PreludeDirector = optarg; 477 break; 478 case 'm': // don't replace the main 479 nomainp = true; 480 break; 481 case Parse: 482 case 'q': // dump parse tree 503 483 parsep = true; 504 484 break; 505 case Resolver:506 case 'r': // print resolver steps485 case Resolver: 486 case 'r': // print resolver steps 507 487 resolvep = true; 508 488 break; 509 case 'R': // dump resolv-proto instance489 case 'R': // dump resolv-proto instance 510 490 resolvprotop = true; 511 491 break; 512 case Stats: 513 Stats::parse_params(optarg); 514 break; 515 case Symbol: 516 case 's': // print symbol table events 492 case Symbol: 493 case 's': // print symbol table events 517 494 symtabp = true; 518 495 break; 519 case Tree:520 case 't': // build in tree496 case Tree: 497 case 't': // build in tree 521 498 treep = true; 522 499 break; 523 case TupleExpansion:524 case 'T': // print after tuple expansion500 case TupleExpansion: 501 case 'T': // print after tuple expansion 525 502 tuplep = true; 526 503 break; 527 case 'v': // dump AST after decl validation pass504 case 'v': // dump AST after decl validation pass 528 505 validp = true; 529 506 break; 530 case 'w':507 case 'w': 531 508 Wsuppress = true; 532 509 break; 533 case 'W':510 case 'W': 534 511 if ( strcmp( optarg, "all" ) == 0 ) { 535 512 SemanticWarning_EnableAll(); … … 548 525 } // if 549 526 break; 550 case 'y': // dump AST on error527 case 'y': // dump AST on error 551 528 errorp = true; 552 529 break; 553 case 'z': // dump as codegen rather than AST530 case 'z': // dump as codegen rather than AST 554 531 codegenp = true; 555 532 break; … … 557 534 prettycodegenp = true; 558 535 break; 559 case 'D': // ignore -Dxxx560 break; 561 case 'F': // source file-name without suffix536 case 'D': // ignore -Dxxx 537 break; 538 case 'F': // source file-name without suffix 562 539 filename = optarg; 563 540 break; 564 case '?':541 case '?': 565 542 if ( optopt ) { // short option ? 566 543 assertf( false, "Unknown option: -%c\n", (char)optopt ); … … 571 548 __attribute__((fallthrough)); 572 549 #endif 573 default:550 default: 574 551 abort(); 575 552 } // switch
Note:
See TracChangeset
for help on using the changeset viewer.