Chromium Code Reviews| 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 cl::desc("Define default global prefix for naming " | 141 cl::desc("Define default global prefix for naming " |
| 142 "unnamed globals"), | 142 "unnamed globals"), |
| 143 cl::init("Global")); | 143 cl::init("Global")); |
| 144 | 144 |
| 145 static cl::opt<std::string> | 145 static cl::opt<std::string> |
| 146 DefaultFunctionPrefix("default-function-prefix", | 146 DefaultFunctionPrefix("default-function-prefix", |
| 147 cl::desc("Define default function prefix for naming " | 147 cl::desc("Define default function prefix for naming " |
| 148 "unnamed functions"), | 148 "unnamed functions"), |
| 149 cl::init("Function")); | 149 cl::init("Function")); |
| 150 | 150 |
| 151 // Note: While this flag isn't used in the minimal build, we keep this | |
| 152 // flag so that tests can set this command-line flag without concern | |
| 153 // to the type of build. We double check that this flag at runtime | |
| 154 // to make sure the consistency is maintained. | |
| 151 static cl::opt<bool> | 155 static cl::opt<bool> |
| 152 BuildOnRead("build-on-read", | 156 BuildOnRead("build-on-read", |
| 153 cl::desc("Build ICE instructions when reading bitcode"), | 157 cl::desc("Build ICE instructions when reading bitcode"), |
| 154 cl::init(false)); | 158 cl::init(true)); |
| 155 | 159 |
| 156 static cl::opt<bool> | 160 static cl::opt<bool> |
| 157 UseIntegratedAssembler("integrated-as", | 161 UseIntegratedAssembler("integrated-as", |
| 158 cl::desc("Use integrated assembler (default yes)"), | 162 cl::desc("Use integrated assembler (default yes)"), |
| 159 cl::init(true)); | 163 cl::init(true)); |
| 160 | 164 |
| 161 static cl::alias UseIas("ias", cl::desc("Alias for -integrated-as"), | 165 static cl::alias UseIas("ias", cl::desc("Alias for -integrated-as"), |
| 162 cl::NotHidden, cl::aliasopt(UseIntegratedAssembler)); | 166 cl::NotHidden, cl::aliasopt(UseIntegratedAssembler)); |
| 163 | 167 |
| 164 static cl::opt<bool> AlwaysExitSuccess( | 168 static cl::opt<bool> AlwaysExitSuccess( |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 260 Flags.TimingFocusOn = TimingFocusOn; | 264 Flags.TimingFocusOn = TimingFocusOn; |
| 261 Flags.VerboseFocusOn = VerboseFocusOn; | 265 Flags.VerboseFocusOn = VerboseFocusOn; |
| 262 Flags.TranslateOnly = TranslateOnly; | 266 Flags.TranslateOnly = TranslateOnly; |
| 263 | 267 |
| 264 Ice::GlobalContext Ctx(Ls, Os, VMask, TargetArch, OptLevel, TestPrefix, | 268 Ice::GlobalContext Ctx(Ls, Os, VMask, TargetArch, OptLevel, TestPrefix, |
| 265 Flags); | 269 Flags); |
| 266 | 270 |
| 267 Ice::TimerMarker T(Ice::TimerStack::TT_szmain, &Ctx); | 271 Ice::TimerMarker T(Ice::TimerStack::TT_szmain, &Ctx); |
| 268 | 272 |
| 269 int ErrorStatus = 0; | 273 int ErrorStatus = 0; |
| 274 #if ALLOW_LLVM_IR == 1 | |
| 270 if (BuildOnRead) { | 275 if (BuildOnRead) { |
|
Jim Stichnoth
2014/10/28 20:45:35
Could this #if construct be more like this?
if (B
Karl
2014/10/28 21:43:51
Done.
| |
| 276 #else | |
| 277 if (!BuildOnRead) { | |
| 278 *Ls << "Error: Build doesn't allow LLVM IR, " | |
| 279 << "--build-on-read=0 not allowed\n"; | |
| 280 return GetReturnValue(1); | |
| 281 } | |
| 282 #endif | |
| 271 Ice::PNaClTranslator Translator(&Ctx, Flags); | 283 Ice::PNaClTranslator Translator(&Ctx, Flags); |
| 272 Translator.translate(IRFilename); | 284 Translator.translate(IRFilename); |
| 273 ErrorStatus = Translator.getErrorStatus(); | 285 ErrorStatus = Translator.getErrorStatus(); |
| 286 #if ALLOW_LLVM_IR == 1 | |
| 274 } else { | 287 } else { |
| 275 // Parse the input LLVM IR file into a module. | 288 // Parse the input LLVM IR file into a module. |
| 276 SMDiagnostic Err; | 289 SMDiagnostic Err; |
| 277 Ice::TimerMarker T1(Ice::TimerStack::TT_parse, &Ctx); | 290 Ice::TimerMarker T1(Ice::TimerStack::TT_parse, &Ctx); |
| 278 Module *Mod = | 291 Module *Mod = |
| 279 NaClParseIRFile(IRFilename, InputFileFormat, Err, getGlobalContext()); | 292 NaClParseIRFile(IRFilename, InputFileFormat, Err, getGlobalContext()); |
| 280 | 293 |
| 281 if (!Mod) { | 294 if (!Mod) { |
| 282 Err.print(argv[0], errs()); | 295 Err.print(argv[0], errs()); |
| 283 return GetReturnValue(1); | 296 return GetReturnValue(1); |
| 284 } | 297 } |
| 285 | 298 |
| 286 Ice::Converter Converter(Mod, &Ctx, Flags); | 299 Ice::Converter Converter(Mod, &Ctx, Flags); |
| 287 Converter.convertToIce(); | 300 Converter.convertToIce(); |
| 288 ErrorStatus = Converter.getErrorStatus(); | 301 ErrorStatus = Converter.getErrorStatus(); |
| 289 } | 302 } |
| 303 #endif | |
| 290 if (TimeEachFunction) { | 304 if (TimeEachFunction) { |
| 291 const bool DumpCumulative = false; | 305 const bool DumpCumulative = false; |
| 292 Ctx.dumpTimers(Ice::GlobalContext::TSK_Funcs, DumpCumulative); | 306 Ctx.dumpTimers(Ice::GlobalContext::TSK_Funcs, DumpCumulative); |
| 293 } | 307 } |
| 294 if (SubzeroTimingEnabled) | 308 if (SubzeroTimingEnabled) |
| 295 Ctx.dumpTimers(); | 309 Ctx.dumpTimers(); |
| 296 const bool FinalStats = true; | 310 const bool FinalStats = true; |
| 297 Ctx.dumpStats("_FINAL_", FinalStats); | 311 Ctx.dumpStats("_FINAL_", FinalStats); |
| 298 return GetReturnValue(ErrorStatus); | 312 return GetReturnValue(ErrorStatus); |
| 299 } | 313 } |
| OLD | NEW |