| OLD | NEW |
| 1 //===- subzero/src/llvm2ice.cpp - Driver for testing ----------------------===// | 1 //===- subzero/src/llvm2ice.cpp - Driver for testing ----------------------===// |
| 2 // | 2 // |
| 3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 // | 9 // |
| 10 // This file defines a driver that uses LLVM capabilities to parse a | 10 // This file defines a driver that uses LLVM capabilities to parse a |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 if (UseELFWriter) { | 366 if (UseELFWriter) { |
| 367 Ice::TimerMarker T1(Ice::TimerStack::TT_emit, &Ctx); | 367 Ice::TimerMarker T1(Ice::TimerStack::TT_emit, &Ctx); |
| 368 Ctx.getObjectWriter()->writeInitialELFHeader(); | 368 Ctx.getObjectWriter()->writeInitialELFHeader(); |
| 369 } | 369 } |
| 370 | 370 |
| 371 Ctx.startWorkerThreads(); | 371 Ctx.startWorkerThreads(); |
| 372 | 372 |
| 373 std::unique_ptr<Ice::Translator> Translator; | 373 std::unique_ptr<Ice::Translator> Translator; |
| 374 if (BuildOnRead) { | 374 if (BuildOnRead) { |
| 375 std::unique_ptr<Ice::PNaClTranslator> PTranslator( | 375 std::unique_ptr<Ice::PNaClTranslator> PTranslator( |
| 376 new Ice::PNaClTranslator(&Ctx, Flags)); | 376 new Ice::PNaClTranslator(&Ctx)); |
| 377 PTranslator->translate(IRFilename); | 377 PTranslator->translate(IRFilename); |
| 378 Translator.reset(PTranslator.release()); | 378 Translator.reset(PTranslator.release()); |
| 379 } else if (ALLOW_LLVM_IR) { | 379 } else if (ALLOW_LLVM_IR) { |
| 380 // Parse the input LLVM IR file into a module. | 380 // Parse the input LLVM IR file into a module. |
| 381 SMDiagnostic Err; | 381 SMDiagnostic Err; |
| 382 Ice::TimerMarker T1(Ice::TimerStack::TT_parse, &Ctx); | 382 Ice::TimerMarker T1(Ice::TimerStack::TT_parse, &Ctx); |
| 383 raw_ostream *Verbose = LLVMVerboseErrors ? &errs() : nullptr; | 383 raw_ostream *Verbose = LLVMVerboseErrors ? &errs() : nullptr; |
| 384 Module *Mod = NaClParseIRFile(IRFilename, InputFileFormat, Err, Verbose, | 384 Module *Mod = NaClParseIRFile(IRFilename, InputFileFormat, Err, Verbose, |
| 385 getGlobalContext()); | 385 getGlobalContext()); |
| 386 | 386 |
| 387 if (!Mod) { | 387 if (!Mod) { |
| 388 Err.print(argv[0], errs()); | 388 Err.print(argv[0], errs()); |
| 389 return GetReturnValue(Ice::EC_Bitcode); | 389 return GetReturnValue(Ice::EC_Bitcode); |
| 390 } | 390 } |
| 391 | 391 |
| 392 std::unique_ptr<Ice::Converter> Converter( | 392 std::unique_ptr<Ice::Converter> Converter(new Ice::Converter(Mod, &Ctx)); |
| 393 new Ice::Converter(Mod, &Ctx, Flags)); | |
| 394 Converter->convertToIce(); | 393 Converter->convertToIce(); |
| 395 Translator.reset(Converter.release()); | 394 Translator.reset(Converter.release()); |
| 396 } else { | 395 } else { |
| 397 *Ls << "Error: Build doesn't allow LLVM IR, " | 396 *Ls << "Error: Build doesn't allow LLVM IR, " |
| 398 << "--build-on-read=0 not allowed\n"; | 397 << "--build-on-read=0 not allowed\n"; |
| 399 return GetReturnValue(Ice::EC_Args); | 398 return GetReturnValue(Ice::EC_Args); |
| 400 } | 399 } |
| 401 | 400 |
| 402 Ctx.waitForWorkerThreads(); | 401 Ctx.waitForWorkerThreads(); |
| 403 Translator->transferErrorCode(); | 402 Translator->transferErrorCode(); |
| 404 Translator->emitConstants(); | 403 Translator->emitConstants(); |
| 405 | 404 |
| 406 if (UseELFWriter) { | 405 if (UseELFWriter) { |
| 407 Ice::TimerMarker T1(Ice::TimerStack::TT_emit, &Ctx); | 406 Ice::TimerMarker T1(Ice::TimerStack::TT_emit, &Ctx); |
| 408 Ctx.getObjectWriter()->setUndefinedSyms(Ctx.getConstantExternSyms()); | 407 Ctx.getObjectWriter()->setUndefinedSyms(Ctx.getConstantExternSyms()); |
| 409 Ctx.getObjectWriter()->writeNonUserSections(); | 408 Ctx.getObjectWriter()->writeNonUserSections(); |
| 410 } | 409 } |
| 411 if (SubzeroTimingEnabled) | 410 if (SubzeroTimingEnabled) |
| 412 Ctx.dumpTimers(); | 411 Ctx.dumpTimers(); |
| 413 if (TimeEachFunction) { | 412 if (TimeEachFunction) { |
| 414 const bool DumpCumulative = false; | 413 const bool DumpCumulative = false; |
| 415 Ctx.dumpTimers(Ice::GlobalContext::TSK_Funcs, DumpCumulative); | 414 Ctx.dumpTimers(Ice::GlobalContext::TSK_Funcs, DumpCumulative); |
| 416 } | 415 } |
| 417 const bool FinalStats = true; | 416 const bool FinalStats = true; |
| 418 Ctx.dumpStats("_FINAL_", FinalStats); | 417 Ctx.dumpStats("_FINAL_", FinalStats); |
| 419 return GetReturnValue(Ctx.getErrorStatus()->value()); | 418 return GetReturnValue(Ctx.getErrorStatus()->value()); |
| 420 } | 419 } |
| OLD | NEW |