| OLD | NEW |
| 1 //===- subzero/src/IceClFlags.cpp - Command line flags and parsing --------===// | 1 //===- subzero/src/IceClFlags.cpp - Command line flags and parsing --------===// |
| 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 /// \file | 10 /// \file |
| 11 /// This file defines commandline flags parsing. | 11 /// This file defines commandline flags parsing. This currently relies on |
| 12 /// This currently relies on llvm::cl to parse. In the future, the minimal | 12 /// llvm::cl to parse. In the future, the minimal build can have a simpler |
| 13 /// build can have a simpler parser. | 13 /// parser. |
| 14 /// | 14 /// |
| 15 //===----------------------------------------------------------------------===// | 15 //===----------------------------------------------------------------------===// |
| 16 | 16 |
| 17 #include "IceClFlags.h" | 17 #include "IceClFlags.h" |
| 18 | 18 |
| 19 #include "IceClFlagsExtra.h" | 19 #include "IceClFlagsExtra.h" |
| 20 | 20 |
| 21 #pragma clang diagnostic push | 21 #pragma clang diagnostic push |
| 22 #pragma clang diagnostic ignored "-Wunused-parameter" | 22 #pragma clang diagnostic ignored "-Wunused-parameter" |
| 23 #include "llvm/Support/CommandLine.h" | 23 #include "llvm/Support/CommandLine.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 cl::init(false)); | 83 cl::init(false)); |
| 84 | 84 |
| 85 cl::opt<bool> | 85 cl::opt<bool> |
| 86 ForceMemIntrinOpt("fmem-intrin-opt", | 86 ForceMemIntrinOpt("fmem-intrin-opt", |
| 87 cl::desc("Force optimization of memory intrinsics.")); | 87 cl::desc("Force optimization of memory intrinsics.")); |
| 88 | 88 |
| 89 cl::opt<bool> | 89 cl::opt<bool> |
| 90 FunctionSections("ffunction-sections", | 90 FunctionSections("ffunction-sections", |
| 91 cl::desc("Emit functions into separate sections")); | 91 cl::desc("Emit functions into separate sections")); |
| 92 | 92 |
| 93 // Number of translation threads (in addition to the parser thread and | 93 // Number of translation threads (in addition to the parser thread and the |
| 94 // the emitter thread). The special case of 0 means purely | 94 // emitter thread). The special case of 0 means purely sequential, i.e. parser, |
| 95 // sequential, i.e. parser, translator, and emitter all within the | 95 // translator, and emitter all within the same single thread. (This may need a |
| 96 // same single thread. (This may need a slight rework if we expand to | 96 // slight rework if we expand to multiple parser or emitter threads.) |
| 97 // multiple parser or emitter threads.) | |
| 98 cl::opt<uint32_t> NumThreads( | 97 cl::opt<uint32_t> NumThreads( |
| 99 "threads", | 98 "threads", |
| 100 cl::desc("Number of translation threads (0 for purely sequential)"), | 99 cl::desc("Number of translation threads (0 for purely sequential)"), |
| 101 // TODO(stichnot): Settle on a good default. Consider | 100 // TODO(stichnot): Settle on a good default. Consider something related to |
| 102 // something related to std::thread::hardware_concurrency(). | 101 // std::thread::hardware_concurrency(). |
| 103 cl::init(2)); | 102 cl::init(2)); |
| 104 | 103 |
| 105 cl::opt<Ice::OptLevel> OLevel(cl::desc("Optimization level"), | 104 cl::opt<Ice::OptLevel> OLevel(cl::desc("Optimization level"), |
| 106 cl::init(Ice::Opt_m1), cl::value_desc("level"), | 105 cl::init(Ice::Opt_m1), cl::value_desc("level"), |
| 107 cl::values(clEnumValN(Ice::Opt_m1, "Om1", "-1"), | 106 cl::values(clEnumValN(Ice::Opt_m1, "Om1", "-1"), |
| 108 clEnumValN(Ice::Opt_m1, "O-1", "-1"), | 107 clEnumValN(Ice::Opt_m1, "O-1", "-1"), |
| 109 clEnumValN(Ice::Opt_0, "O0", "0"), | 108 clEnumValN(Ice::Opt_0, "O0", "0"), |
| 110 clEnumValN(Ice::Opt_1, "O1", "1"), | 109 clEnumValN(Ice::Opt_1, "O1", "1"), |
| 111 clEnumValN(Ice::Opt_2, "O2", "2"), | 110 clEnumValN(Ice::Opt_2, "O2", "2"), |
| 112 clEnumValEnd)); | 111 clEnumValEnd)); |
| 113 | 112 |
| 114 cl::opt<bool> | 113 cl::opt<bool> |
| 115 EnablePhiEdgeSplit("phi-edge-split", | 114 EnablePhiEdgeSplit("phi-edge-split", |
| 116 cl::desc("Enable edge splitting for Phi lowering"), | 115 cl::desc("Enable edge splitting for Phi lowering"), |
| 117 cl::init(true)); | 116 cl::init(true)); |
| 118 | 117 |
| 119 // TODO(stichnot): See if we can easily use LLVM's -rng-seed option | 118 // TODO(stichnot): See if we can easily use LLVM's -rng-seed option and |
| 120 // and implementation. I expect the implementation is different and | 119 // implementation. I expect the implementation is different and therefore the |
| 121 // therefore the tests would need to be changed. | 120 // tests would need to be changed. |
| 122 cl::opt<unsigned long long> | 121 cl::opt<unsigned long long> |
| 123 RandomSeed("sz-seed", cl::desc("Seed the random number generator"), | 122 RandomSeed("sz-seed", cl::desc("Seed the random number generator"), |
| 124 cl::init(1)); | 123 cl::init(1)); |
| 125 | 124 |
| 126 cl::opt<bool> ShouldDoNopInsertion("nop-insertion", | 125 cl::opt<bool> ShouldDoNopInsertion("nop-insertion", |
| 127 cl::desc("Randomly insert NOPs"), | 126 cl::desc("Randomly insert NOPs"), |
| 128 cl::init(false)); | 127 cl::init(false)); |
| 129 | 128 |
| 130 cl::opt<bool> | 129 cl::opt<bool> |
| 131 RandomizeRegisterAllocation("randomize-regalloc", | 130 RandomizeRegisterAllocation("randomize-regalloc", |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 clEnumValN(Ice::IceV_Most, "most", | 238 clEnumValN(Ice::IceV_Most, "most", |
| 240 "Use all verbose options except 'regalloc'"), | 239 "Use all verbose options except 'regalloc'"), |
| 241 clEnumValN(Ice::IceV_None, "none", "No verbosity"), clEnumValEnd)); | 240 clEnumValN(Ice::IceV_None, "none", "No verbosity"), clEnumValEnd)); |
| 242 | 241 |
| 243 // Options not captured in Ice::ClFlags and propagated. | 242 // Options not captured in Ice::ClFlags and propagated. |
| 244 | 243 |
| 245 cl::opt<bool> AlwaysExitSuccess( | 244 cl::opt<bool> AlwaysExitSuccess( |
| 246 "exit-success", cl::desc("Exit with success status, even if errors found"), | 245 "exit-success", cl::desc("Exit with success status, even if errors found"), |
| 247 cl::init(false)); | 246 cl::init(false)); |
| 248 | 247 |
| 249 // Note: While this flag isn't used in the minimal build, we keep this | 248 // Note: While this flag isn't used in the minimal build, we keep this flag so |
| 250 // flag so that tests can set this command-line flag without concern | 249 // that tests can set this command-line flag without concern to the type of |
| 251 // to the type of build. We double check that this flag at runtime | 250 // build. We double check that this flag at runtime to make sure the |
| 252 // to make sure the consistency is maintained. | 251 // consistency is maintained. |
| 253 cl::opt<bool> | 252 cl::opt<bool> |
| 254 BuildOnRead("build-on-read", | 253 BuildOnRead("build-on-read", |
| 255 cl::desc("Build ICE instructions when reading bitcode"), | 254 cl::desc("Build ICE instructions when reading bitcode"), |
| 256 cl::init(true)); | 255 cl::init(true)); |
| 257 | 256 |
| 258 cl::opt<llvm::NaClFileFormat> InputFileFormat( | 257 cl::opt<llvm::NaClFileFormat> InputFileFormat( |
| 259 "bitcode-format", cl::desc("Define format of input file:"), | 258 "bitcode-format", cl::desc("Define format of input file:"), |
| 260 cl::values(clEnumValN(llvm::LLVMFormat, "llvm", "LLVM file (default)"), | 259 cl::values(clEnumValN(llvm::LLVMFormat, "llvm", "LLVM file (default)"), |
| 261 clEnumValN(llvm::PNaClFormat, "pnacl", "PNaCl bitcode file"), | 260 clEnumValN(llvm::PNaClFormat, "pnacl", "PNaCl bitcode file"), |
| 262 clEnumValEnd), | 261 clEnumValEnd), |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 // size_t and 64-bit fields. | 395 // size_t and 64-bit fields. |
| 397 OutFlags.NumTranslationThreads = 0; | 396 OutFlags.NumTranslationThreads = 0; |
| 398 OutFlags.RandomSeed = 0; | 397 OutFlags.RandomSeed = 0; |
| 399 } | 398 } |
| 400 | 399 |
| 401 void ClFlags::getParsedClFlags(ClFlags &OutFlags) { | 400 void ClFlags::getParsedClFlags(ClFlags &OutFlags) { |
| 402 if (::DisableIRGeneration) | 401 if (::DisableIRGeneration) |
| 403 ::DisableTranslation = true; | 402 ::DisableTranslation = true; |
| 404 | 403 |
| 405 Ice::VerboseMask VMask = Ice::IceV_None; | 404 Ice::VerboseMask VMask = Ice::IceV_None; |
| 406 // Don't generate verbose messages if routines | 405 // Don't generate verbose messages if routines to dump messages are not |
| 407 // to dump messages are not available. | 406 // available. |
| 408 if (BuildDefs::dump()) { | 407 if (BuildDefs::dump()) { |
| 409 for (unsigned i = 0; i != VerboseList.size(); ++i) | 408 for (unsigned i = 0; i != VerboseList.size(); ++i) |
| 410 VMask |= VerboseList[i]; | 409 VMask |= VerboseList[i]; |
| 411 } | 410 } |
| 412 | 411 |
| 413 OutFlags.setAllowErrorRecovery(::AllowErrorRecovery); | 412 OutFlags.setAllowErrorRecovery(::AllowErrorRecovery); |
| 414 OutFlags.setAllowIacaMarks(::AllowIacaMarks); | 413 OutFlags.setAllowIacaMarks(::AllowIacaMarks); |
| 415 OutFlags.setAllowUninitializedGlobals(::AllowUninitializedGlobals); | 414 OutFlags.setAllowUninitializedGlobals(::AllowUninitializedGlobals); |
| 416 OutFlags.setDataSections(::DataSections); | 415 OutFlags.setDataSections(::DataSections); |
| 417 OutFlags.setDecorateAsm(::DecorateAsm); | 416 OutFlags.setDecorateAsm(::DecorateAsm); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 OutFlagsExtra.setGenerateBuildAtts(GenerateBuildAtts); | 462 OutFlagsExtra.setGenerateBuildAtts(GenerateBuildAtts); |
| 464 OutFlagsExtra.setLLVMVerboseErrors(LLVMVerboseErrors); | 463 OutFlagsExtra.setLLVMVerboseErrors(LLVMVerboseErrors); |
| 465 OutFlagsExtra.setAppName(AppName); | 464 OutFlagsExtra.setAppName(AppName); |
| 466 OutFlagsExtra.setInputFileFormat(InputFileFormat); | 465 OutFlagsExtra.setInputFileFormat(InputFileFormat); |
| 467 OutFlagsExtra.setIRFilename(IRFilename); | 466 OutFlagsExtra.setIRFilename(IRFilename); |
| 468 OutFlagsExtra.setLogFilename(LogFilename); | 467 OutFlagsExtra.setLogFilename(LogFilename); |
| 469 OutFlagsExtra.setOutputFilename(OutputFilename); | 468 OutFlagsExtra.setOutputFilename(OutputFilename); |
| 470 } | 469 } |
| 471 | 470 |
| 472 } // end of namespace Ice | 471 } // end of namespace Ice |
| OLD | NEW |