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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 if (UseELFWriter) { | 367 if (UseELFWriter) { |
368 Ice::TimerMarker T1(Ice::TimerStack::TT_emit, &Ctx); | 368 Ice::TimerMarker T1(Ice::TimerStack::TT_emit, &Ctx); |
369 Ctx.getObjectWriter()->writeInitialELFHeader(); | 369 Ctx.getObjectWriter()->writeInitialELFHeader(); |
370 } | 370 } |
371 | 371 |
372 Ctx.startWorkerThreads(); | 372 Ctx.startWorkerThreads(); |
373 | 373 |
374 std::unique_ptr<Ice::Translator> Translator; | 374 std::unique_ptr<Ice::Translator> Translator; |
375 if (BuildOnRead) { | 375 if (BuildOnRead) { |
376 std::unique_ptr<Ice::PNaClTranslator> PTranslator( | 376 std::unique_ptr<Ice::PNaClTranslator> PTranslator( |
377 new Ice::PNaClTranslator(&Ctx, Flags)); | 377 new Ice::PNaClTranslator(&Ctx)); |
378 PTranslator->translate(IRFilename); | 378 PTranslator->translate(IRFilename); |
379 Translator.reset(PTranslator.release()); | 379 Translator.reset(PTranslator.release()); |
380 } else if (ALLOW_LLVM_IR) { | 380 } else if (ALLOW_LLVM_IR) { |
381 // Parse the input LLVM IR file into a module. | 381 // Parse the input LLVM IR file into a module. |
382 SMDiagnostic Err; | 382 SMDiagnostic Err; |
383 Ice::TimerMarker T1(Ice::TimerStack::TT_parse, &Ctx); | 383 Ice::TimerMarker T1(Ice::TimerStack::TT_parse, &Ctx); |
384 raw_ostream *Verbose = LLVMVerboseErrors ? &errs() : nullptr; | 384 raw_ostream *Verbose = LLVMVerboseErrors ? &errs() : nullptr; |
385 Module *Mod = NaClParseIRFile(IRFilename, InputFileFormat, Err, Verbose, | 385 Module *Mod = NaClParseIRFile(IRFilename, InputFileFormat, Err, Verbose, |
386 getGlobalContext()); | 386 getGlobalContext()); |
387 | 387 |
388 if (!Mod) { | 388 if (!Mod) { |
389 Err.print(argv[0], errs()); | 389 Err.print(argv[0], errs()); |
390 return GetReturnValue(Ice::EC_Bitcode); | 390 return GetReturnValue(Ice::EC_Bitcode); |
391 } | 391 } |
392 | 392 |
393 std::unique_ptr<Ice::Converter> Converter( | 393 std::unique_ptr<Ice::Converter> Converter(new Ice::Converter(Mod, &Ctx)); |
394 new Ice::Converter(Mod, &Ctx, Flags)); | |
395 Converter->convertToIce(); | 394 Converter->convertToIce(); |
396 Translator.reset(Converter.release()); | 395 Translator.reset(Converter.release()); |
397 } else { | 396 } else { |
398 *Ls << "Error: Build doesn't allow LLVM IR, " | 397 *Ls << "Error: Build doesn't allow LLVM IR, " |
399 << "--build-on-read=0 not allowed\n"; | 398 << "--build-on-read=0 not allowed\n"; |
400 return GetReturnValue(Ice::EC_Args); | 399 return GetReturnValue(Ice::EC_Args); |
401 } | 400 } |
402 | 401 |
403 Ctx.waitForWorkerThreads(); | 402 Ctx.waitForWorkerThreads(); |
404 Translator->transferErrorCode(); | 403 Translator->transferErrorCode(); |
405 Translator->emitConstants(); | 404 Translator->emitConstants(); |
406 | 405 |
407 if (UseELFWriter) { | 406 if (UseELFWriter) { |
408 Ice::TimerMarker T1(Ice::TimerStack::TT_emit, &Ctx); | 407 Ice::TimerMarker T1(Ice::TimerStack::TT_emit, &Ctx); |
409 Ctx.getObjectWriter()->setUndefinedSyms(Ctx.getConstantExternSyms()); | 408 Ctx.getObjectWriter()->setUndefinedSyms(Ctx.getConstantExternSyms()); |
410 Ctx.getObjectWriter()->writeNonUserSections(); | 409 Ctx.getObjectWriter()->writeNonUserSections(); |
411 } | 410 } |
412 if (SubzeroTimingEnabled) | 411 if (SubzeroTimingEnabled) |
413 Ctx.dumpTimers(); | 412 Ctx.dumpTimers(); |
414 if (TimeEachFunction) { | 413 if (TimeEachFunction) { |
415 const bool DumpCumulative = false; | 414 const bool DumpCumulative = false; |
416 Ctx.dumpTimers(Ice::GlobalContext::TSK_Funcs, DumpCumulative); | 415 Ctx.dumpTimers(Ice::GlobalContext::TSK_Funcs, DumpCumulative); |
417 } | 416 } |
418 const bool FinalStats = true; | 417 const bool FinalStats = true; |
419 Ctx.dumpStats("_FINAL_", FinalStats); | 418 Ctx.dumpStats("_FINAL_", FinalStats); |
420 return GetReturnValue(Ctx.getErrorStatus()->value()); | 419 return GetReturnValue(Ctx.getErrorStatus()->value()); |
421 } | 420 } |
OLD | NEW |