| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 ForceMemIntrinOpt("fmem-intrin-opt", | 92 ForceMemIntrinOpt("fmem-intrin-opt", |
| 93 cl::desc("Force optimization of memory intrinsics.")); | 93 cl::desc("Force optimization of memory intrinsics.")); |
| 94 | 94 |
| 95 cl::opt<bool> | 95 cl::opt<bool> |
| 96 FunctionSections("ffunction-sections", | 96 FunctionSections("ffunction-sections", |
| 97 cl::desc("Emit functions into separate sections")); | 97 cl::desc("Emit functions into separate sections")); |
| 98 | 98 |
| 99 cl::opt<bool> MockBoundsCheck("mock-bounds-check", | 99 cl::opt<bool> MockBoundsCheck("mock-bounds-check", |
| 100 cl::desc("Mock bounds checking on loads/stores")); | 100 cl::desc("Mock bounds checking on loads/stores")); |
| 101 | 101 |
| 102 // Number of translation threads (in addition to the parser thread and | 102 // Number of translation threads (in addition to the parser thread and the |
| 103 // the emitter thread). The special case of 0 means purely | 103 // emitter thread). The special case of 0 means purely sequential, i.e. parser, |
| 104 // sequential, i.e. parser, translator, and emitter all within the | 104 // translator, and emitter all within the same single thread. (This may need a |
| 105 // same single thread. (This may need a slight rework if we expand to | 105 // slight rework if we expand to multiple parser or emitter threads.) |
| 106 // multiple parser or emitter threads.) | |
| 107 cl::opt<uint32_t> NumThreads( | 106 cl::opt<uint32_t> NumThreads( |
| 108 "threads", | 107 "threads", |
| 109 cl::desc("Number of translation threads (0 for purely sequential)"), | 108 cl::desc("Number of translation threads (0 for purely sequential)"), |
| 110 // TODO(stichnot): Settle on a good default. Consider | 109 // TODO(stichnot): Settle on a good default. Consider something related to |
| 111 // something related to std::thread::hardware_concurrency(). | 110 // std::thread::hardware_concurrency(). |
| 112 cl::init(2)); | 111 cl::init(2)); |
| 113 | 112 |
| 114 cl::opt<Ice::OptLevel> OLevel(cl::desc("Optimization level"), | 113 cl::opt<Ice::OptLevel> OLevel(cl::desc("Optimization level"), |
| 115 cl::init(Ice::Opt_m1), cl::value_desc("level"), | 114 cl::init(Ice::Opt_m1), cl::value_desc("level"), |
| 116 cl::values(clEnumValN(Ice::Opt_m1, "Om1", "-1"), | 115 cl::values(clEnumValN(Ice::Opt_m1, "Om1", "-1"), |
| 117 clEnumValN(Ice::Opt_m1, "O-1", "-1"), | 116 clEnumValN(Ice::Opt_m1, "O-1", "-1"), |
| 118 clEnumValN(Ice::Opt_0, "O0", "0"), | 117 clEnumValN(Ice::Opt_0, "O0", "0"), |
| 119 clEnumValN(Ice::Opt_1, "O1", "1"), | 118 clEnumValN(Ice::Opt_1, "O1", "1"), |
| 120 clEnumValN(Ice::Opt_2, "O2", "2"), | 119 clEnumValN(Ice::Opt_2, "O2", "2"), |
| 121 clEnumValEnd)); | 120 clEnumValEnd)); |
| 122 | 121 |
| 123 cl::opt<bool> | 122 cl::opt<bool> |
| 124 EnablePhiEdgeSplit("phi-edge-split", | 123 EnablePhiEdgeSplit("phi-edge-split", |
| 125 cl::desc("Enable edge splitting for Phi lowering"), | 124 cl::desc("Enable edge splitting for Phi lowering"), |
| 126 cl::init(true)); | 125 cl::init(true)); |
| 127 | 126 |
| 128 // TODO(stichnot): See if we can easily use LLVM's -rng-seed option | 127 // TODO(stichnot): See if we can easily use LLVM's -rng-seed option and |
| 129 // and implementation. I expect the implementation is different and | 128 // implementation. I expect the implementation is different and therefore the |
| 130 // therefore the tests would need to be changed. | 129 // tests would need to be changed. |
| 131 cl::opt<unsigned long long> | 130 cl::opt<unsigned long long> |
| 132 RandomSeed("sz-seed", cl::desc("Seed the random number generator"), | 131 RandomSeed("sz-seed", cl::desc("Seed the random number generator"), |
| 133 cl::init(1)); | 132 cl::init(1)); |
| 134 | 133 |
| 135 cl::opt<bool> ShouldDoNopInsertion("nop-insertion", | 134 cl::opt<bool> ShouldDoNopInsertion("nop-insertion", |
| 136 cl::desc("Randomly insert NOPs"), | 135 cl::desc("Randomly insert NOPs"), |
| 137 cl::init(false)); | 136 cl::init(false)); |
| 138 | 137 |
| 139 cl::opt<bool> | 138 cl::opt<bool> |
| 140 RandomizeRegisterAllocation("randomize-regalloc", | 139 RandomizeRegisterAllocation("randomize-regalloc", |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 clEnumValN(Ice::IceV_Most, "most", | 247 clEnumValN(Ice::IceV_Most, "most", |
| 249 "Use all verbose options except 'regalloc'"), | 248 "Use all verbose options except 'regalloc'"), |
| 250 clEnumValN(Ice::IceV_None, "none", "No verbosity"), clEnumValEnd)); | 249 clEnumValN(Ice::IceV_None, "none", "No verbosity"), clEnumValEnd)); |
| 251 | 250 |
| 252 // Options not captured in Ice::ClFlags and propagated. | 251 // Options not captured in Ice::ClFlags and propagated. |
| 253 | 252 |
| 254 cl::opt<bool> AlwaysExitSuccess( | 253 cl::opt<bool> AlwaysExitSuccess( |
| 255 "exit-success", cl::desc("Exit with success status, even if errors found"), | 254 "exit-success", cl::desc("Exit with success status, even if errors found"), |
| 256 cl::init(false)); | 255 cl::init(false)); |
| 257 | 256 |
| 258 // Note: While this flag isn't used in the minimal build, we keep this | 257 // Note: While this flag isn't used in the minimal build, we keep this flag so |
| 259 // flag so that tests can set this command-line flag without concern | 258 // that tests can set this command-line flag without concern to the type of |
| 260 // to the type of build. We double check that this flag at runtime | 259 // build. We double check that this flag at runtime to make sure the |
| 261 // to make sure the consistency is maintained. | 260 // consistency is maintained. |
| 262 cl::opt<bool> | 261 cl::opt<bool> |
| 263 BuildOnRead("build-on-read", | 262 BuildOnRead("build-on-read", |
| 264 cl::desc("Build ICE instructions when reading bitcode"), | 263 cl::desc("Build ICE instructions when reading bitcode"), |
| 265 cl::init(true)); | 264 cl::init(true)); |
| 266 | 265 |
| 267 cl::opt<llvm::NaClFileFormat> InputFileFormat( | 266 cl::opt<llvm::NaClFileFormat> InputFileFormat( |
| 268 "bitcode-format", cl::desc("Define format of input file:"), | 267 "bitcode-format", cl::desc("Define format of input file:"), |
| 269 cl::values(clEnumValN(llvm::LLVMFormat, "llvm", "LLVM file (default)"), | 268 cl::values(clEnumValN(llvm::LLVMFormat, "llvm", "LLVM file (default)"), |
| 270 clEnumValN(llvm::PNaClFormat, "pnacl", "PNaCl bitcode file"), | 269 clEnumValN(llvm::PNaClFormat, "pnacl", "PNaCl bitcode file"), |
| 271 clEnumValEnd), | 270 clEnumValEnd), |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 // size_t and 64-bit fields. | 405 // size_t and 64-bit fields. |
| 407 OutFlags.NumTranslationThreads = 0; | 406 OutFlags.NumTranslationThreads = 0; |
| 408 OutFlags.RandomSeed = 0; | 407 OutFlags.RandomSeed = 0; |
| 409 } | 408 } |
| 410 | 409 |
| 411 void ClFlags::getParsedClFlags(ClFlags &OutFlags) { | 410 void ClFlags::getParsedClFlags(ClFlags &OutFlags) { |
| 412 if (::DisableIRGeneration) | 411 if (::DisableIRGeneration) |
| 413 ::DisableTranslation = true; | 412 ::DisableTranslation = true; |
| 414 | 413 |
| 415 Ice::VerboseMask VMask = Ice::IceV_None; | 414 Ice::VerboseMask VMask = Ice::IceV_None; |
| 416 // Don't generate verbose messages if routines | 415 // Don't generate verbose messages if routines to dump messages are not |
| 417 // to dump messages are not available. | 416 // available. |
| 418 if (BuildDefs::dump()) { | 417 if (BuildDefs::dump()) { |
| 419 for (unsigned i = 0; i != VerboseList.size(); ++i) | 418 for (unsigned i = 0; i != VerboseList.size(); ++i) |
| 420 VMask |= VerboseList[i]; | 419 VMask |= VerboseList[i]; |
| 421 } | 420 } |
| 422 | 421 |
| 423 OutFlags.setAllowErrorRecovery(::AllowErrorRecovery); | 422 OutFlags.setAllowErrorRecovery(::AllowErrorRecovery); |
| 424 OutFlags.setAllowIacaMarks(::AllowIacaMarks); | 423 OutFlags.setAllowIacaMarks(::AllowIacaMarks); |
| 425 OutFlags.setAllowUninitializedGlobals(::AllowUninitializedGlobals); | 424 OutFlags.setAllowUninitializedGlobals(::AllowUninitializedGlobals); |
| 426 OutFlags.setDataSections(::DataSections); | 425 OutFlags.setDataSections(::DataSections); |
| 427 OutFlags.setDecorateAsm(::DecorateAsm); | 426 OutFlags.setDecorateAsm(::DecorateAsm); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 OutFlagsExtra.setGenerateBuildAtts(GenerateBuildAtts); | 473 OutFlagsExtra.setGenerateBuildAtts(GenerateBuildAtts); |
| 475 OutFlagsExtra.setLLVMVerboseErrors(LLVMVerboseErrors); | 474 OutFlagsExtra.setLLVMVerboseErrors(LLVMVerboseErrors); |
| 476 OutFlagsExtra.setAppName(AppName); | 475 OutFlagsExtra.setAppName(AppName); |
| 477 OutFlagsExtra.setInputFileFormat(InputFileFormat); | 476 OutFlagsExtra.setInputFileFormat(InputFileFormat); |
| 478 OutFlagsExtra.setIRFilename(IRFilename); | 477 OutFlagsExtra.setIRFilename(IRFilename); |
| 479 OutFlagsExtra.setLogFilename(LogFilename); | 478 OutFlagsExtra.setLogFilename(LogFilename); |
| 480 OutFlagsExtra.setOutputFilename(OutputFilename); | 479 OutFlagsExtra.setOutputFilename(OutputFilename); |
| 481 } | 480 } |
| 482 | 481 |
| 483 } // end of namespace Ice | 482 } // end of namespace Ice |
| OLD | NEW |