Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 1 | //===- subzero/src/IceClFlags.cpp - Command line flags and parsing --------===// |
| 2 | // |
| 3 | // The Subzero Code Generator |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
Andrew Scull | 9612d32 | 2015-07-06 14:53:25 -0700 | [diff] [blame] | 9 | /// |
| 10 | /// \file |
| 11 | /// This file defines commandline flags parsing. |
| 12 | /// This currently relies on llvm::cl to parse. In the future, the minimal |
| 13 | /// build can have a simpler parser. |
| 14 | /// |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 15 | //===----------------------------------------------------------------------===// |
| 16 | |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 17 | #include "IceClFlags.h" |
John Porto | 67f8de9 | 2015-06-25 10:14:17 -0700 | [diff] [blame] | 18 | |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 19 | #include "IceClFlagsExtra.h" |
Jim Stichnoth | 98da966 | 2015-06-27 06:38:08 -0700 | [diff] [blame] | 20 | |
| 21 | #pragma clang diagnostic push |
| 22 | #pragma clang diagnostic ignored "-Wunused-parameter" |
John Porto | 67f8de9 | 2015-06-25 10:14:17 -0700 | [diff] [blame] | 23 | #include "llvm/Support/CommandLine.h" |
Jim Stichnoth | 98da966 | 2015-06-27 06:38:08 -0700 | [diff] [blame] | 24 | #pragma clang diagnostic pop |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 25 | |
| 26 | namespace cl = llvm::cl; |
| 27 | |
| 28 | // Options which are captured in Ice::ClFlags and propagated. |
| 29 | |
| 30 | namespace { |
| 31 | |
| 32 | cl::opt<bool> AllowErrorRecovery( |
| 33 | "allow-pnacl-reader-error-recovery", |
| 34 | cl::desc("Allow error recovery when reading PNaCl bitcode."), |
| 35 | cl::init(false)); |
| 36 | |
| 37 | // This is currently needed by crosstest.py. |
| 38 | cl::opt<bool> AllowUninitializedGlobals( |
| 39 | "allow-uninitialized-globals", |
| 40 | cl::desc("Allow global variables to be uninitialized")); |
| 41 | |
| 42 | cl::opt<bool> |
| 43 | DataSections("fdata-sections", |
| 44 | cl::desc("Emit (global) data into separate sections")); |
| 45 | |
| 46 | cl::opt<bool> DecorateAsm( |
| 47 | "asm-verbose", |
| 48 | cl::desc("Decorate textual asm output with register liveness info")); |
| 49 | |
| 50 | cl::opt<std::string> |
| 51 | DefaultFunctionPrefix("default-function-prefix", |
| 52 | cl::desc("Define default function prefix for naming " |
| 53 | "unnamed functions"), |
| 54 | cl::init("Function")); |
| 55 | |
| 56 | cl::opt<std::string> |
| 57 | DefaultGlobalPrefix("default-global-prefix", |
| 58 | cl::desc("Define default global prefix for naming " |
| 59 | "unnamed globals"), |
| 60 | cl::init("Global")); |
| 61 | cl::opt<bool> DisableInternal("externalize", |
| 62 | cl::desc("Externalize all symbols")); |
| 63 | // Note: Modifiable only if ALLOW_DISABLE_IR_GEN. |
| 64 | cl::opt<bool> DisableIRGeneration("no-ir-gen", |
| 65 | cl::desc("Disable generating Subzero IR.")); |
| 66 | cl::opt<bool> DisableTranslation("notranslate", |
| 67 | cl::desc("Disable Subzero translation")); |
| 68 | |
| 69 | cl::opt<bool> |
| 70 | DumpStats("szstats", |
| 71 | cl::desc("Print statistics after translating each function")); |
| 72 | |
John Porto | f8b4cc8 | 2015-06-09 18:06:19 -0700 | [diff] [blame] | 73 | cl::opt<bool> EnableBlockProfile( |
| 74 | "enable-block-profile", |
| 75 | cl::desc("If true, instrument basic blocks, and output profiling " |
| 76 | "information to stdout at the end of program execution."), |
| 77 | cl::init(false)); |
| 78 | |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 79 | cl::opt<bool> |
| 80 | FunctionSections("ffunction-sections", |
| 81 | cl::desc("Emit functions into separate sections")); |
| 82 | |
| 83 | // Number of translation threads (in addition to the parser thread and |
| 84 | // the emitter thread). The special case of 0 means purely |
| 85 | // sequential, i.e. parser, translator, and emitter all within the |
| 86 | // same single thread. (This may need a slight rework if we expand to |
| 87 | // multiple parser or emitter threads.) |
| 88 | cl::opt<uint32_t> NumThreads( |
| 89 | "threads", |
| 90 | cl::desc("Number of translation threads (0 for purely sequential)"), |
| 91 | // TODO(stichnot): Settle on a good default. Consider |
| 92 | // something related to std::thread::hardware_concurrency(). |
| 93 | cl::init(2)); |
| 94 | |
| 95 | cl::opt<Ice::OptLevel> OLevel(cl::desc("Optimization level"), |
| 96 | cl::init(Ice::Opt_m1), cl::value_desc("level"), |
| 97 | cl::values(clEnumValN(Ice::Opt_m1, "Om1", "-1"), |
| 98 | clEnumValN(Ice::Opt_m1, "O-1", "-1"), |
| 99 | clEnumValN(Ice::Opt_0, "O0", "0"), |
| 100 | clEnumValN(Ice::Opt_1, "O1", "1"), |
| 101 | clEnumValN(Ice::Opt_2, "O2", "2"), |
| 102 | clEnumValEnd)); |
| 103 | |
| 104 | cl::opt<bool> |
| 105 | EnablePhiEdgeSplit("phi-edge-split", |
| 106 | cl::desc("Enable edge splitting for Phi lowering"), |
| 107 | cl::init(true)); |
| 108 | |
| 109 | // TODO(stichnot): See if we can easily use LLVM's -rng-seed option |
| 110 | // and implementation. I expect the implementation is different and |
| 111 | // therefore the tests would need to be changed. |
| 112 | cl::opt<unsigned long long> |
| 113 | RandomSeed("sz-seed", cl::desc("Seed the random number generator"), |
Qining Lu | 253dc8a | 2015-06-22 10:10:23 -0700 | [diff] [blame] | 114 | cl::init(1)); |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 115 | |
| 116 | cl::opt<bool> ShouldDoNopInsertion("nop-insertion", |
| 117 | cl::desc("Randomly insert NOPs"), |
| 118 | cl::init(false)); |
| 119 | |
| 120 | cl::opt<bool> |
| 121 | RandomizeRegisterAllocation("randomize-regalloc", |
| 122 | cl::desc("Randomize register allocation"), |
| 123 | cl::init(false)); |
| 124 | |
Jan Voung | b2d5084 | 2015-05-12 09:53:50 -0700 | [diff] [blame] | 125 | cl::opt<bool> SkipUnimplemented( |
| 126 | "skip-unimplemented", |
| 127 | cl::desc("Skip through unimplemented lowering code instead of aborting."), |
| 128 | cl::init(false)); |
| 129 | |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 130 | cl::opt<bool> SubzeroTimingEnabled( |
| 131 | "timing", cl::desc("Enable breakdown timing of Subzero translation")); |
| 132 | |
| 133 | cl::opt<Ice::TargetArch> TargetArch( |
| 134 | "target", cl::desc("Target architecture:"), cl::init(Ice::Target_X8632), |
| 135 | cl::values( |
| 136 | clEnumValN(Ice::Target_X8632, "x8632", "x86-32"), |
| 137 | clEnumValN(Ice::Target_X8632, "x86-32", "x86-32 (same as x8632)"), |
| 138 | clEnumValN(Ice::Target_X8632, "x86_32", "x86-32 (same as x8632)"), |
| 139 | clEnumValN(Ice::Target_X8664, "x8664", "x86-64"), |
| 140 | clEnumValN(Ice::Target_X8664, "x86-64", "x86-64 (same as x8664)"), |
| 141 | clEnumValN(Ice::Target_X8664, "x86_64", "x86-64 (same as x8664)"), |
| 142 | clEnumValN(Ice::Target_ARM32, "arm", "arm32"), |
| 143 | clEnumValN(Ice::Target_ARM32, "arm32", "arm32 (same as arm)"), |
Jim Stichnoth | 6da4cef | 2015-06-11 13:26:33 -0700 | [diff] [blame] | 144 | clEnumValN(Ice::Target_ARM64, "arm64", "arm64"), |
| 145 | clEnumValN(Ice::Target_MIPS32, "mips", "mips32"), |
| 146 | clEnumValN(Ice::Target_MIPS32, "mips32", "mips32 (same as mips)"), |
| 147 | clEnumValEnd)); |
Jan Voung | 28068ad | 2015-07-31 12:58:46 -0700 | [diff] [blame] | 148 | |
| 149 | cl::opt<uint32_t> TestStackExtra( |
| 150 | "test-stack-extra", |
| 151 | cl::desc( |
| 152 | "Extra amount of stack to add to the frame in bytes (for testing)."), |
| 153 | cl::init(0)); |
| 154 | |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 155 | cl::opt<Ice::TargetInstructionSet> TargetInstructionSet( |
| 156 | "mattr", cl::desc("Target architecture attributes"), |
Jan Voung | d062f73 | 2015-06-15 17:17:31 -0700 | [diff] [blame] | 157 | cl::init(Ice::BaseInstructionSet), |
| 158 | cl::values(clEnumValN(Ice::BaseInstructionSet, "base", |
| 159 | "Target chooses baseline instruction set (default)"), |
| 160 | clEnumValN(Ice::X86InstructionSet_SSE2, "sse2", |
| 161 | "Enable X86 SSE2 instructions"), |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 162 | clEnumValN(Ice::X86InstructionSet_SSE4_1, "sse4.1", |
Jan Voung | d062f73 | 2015-06-15 17:17:31 -0700 | [diff] [blame] | 163 | "Enable X86 SSE 4.1 instructions"), |
| 164 | clEnumValN(Ice::ARM32InstructionSet_Neon, "neon", |
| 165 | "Enable ARM Neon instructions"), |
| 166 | clEnumValN(Ice::ARM32InstructionSet_HWDivArm, "hwdiv-arm", |
| 167 | "Enable ARM integer divide instructions in ARM mode"), |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 168 | clEnumValEnd)); |
| 169 | cl::opt<std::string> |
| 170 | TestPrefix("prefix", |
| 171 | cl::desc("Prepend a prefix to symbol names for testing"), |
| 172 | cl::init(""), cl::value_desc("prefix")); |
| 173 | |
| 174 | cl::opt<bool> TimeEachFunction( |
| 175 | "timing-funcs", cl::desc("Print total translation time for each function")); |
| 176 | |
| 177 | cl::opt<std::string> TimingFocusOn( |
| 178 | "timing-focus", |
| 179 | cl::desc("Break down timing for a specific function (use '*' for all)"), |
| 180 | cl::init("")); |
| 181 | |
| 182 | cl::opt<std::string> |
| 183 | TranslateOnly("translate-only", |
| 184 | cl::desc("Translate only the given function"), cl::init("")); |
| 185 | |
| 186 | cl::opt<bool> UseSandboxing("sandbox", cl::desc("Use sandboxing")); |
| 187 | |
| 188 | cl::opt<std::string> VerboseFocusOn( |
| 189 | "verbose-focus", |
| 190 | cl::desc("Temporarily enable full verbosity for a specific function"), |
| 191 | cl::init("")); |
| 192 | |
| 193 | cl::opt<Ice::FileType> OutFileType( |
| 194 | "filetype", cl::desc("Output file type"), cl::init(Ice::FT_Iasm), |
| 195 | cl::values(clEnumValN(Ice::FT_Elf, "obj", "Native ELF object ('.o') file"), |
| 196 | clEnumValN(Ice::FT_Asm, "asm", "Assembly ('.s') file"), |
| 197 | clEnumValN(Ice::FT_Iasm, "iasm", |
| 198 | "Low-level integrated assembly ('.s') file"), |
| 199 | clEnumValEnd)); |
| 200 | |
| 201 | cl::opt<int> MaxNopsPerInstruction( |
| 202 | "max-nops-per-instruction", |
| 203 | cl::desc("Max number of nops to insert per instruction"), cl::init(1)); |
| 204 | |
| 205 | cl::opt<int> NopProbabilityAsPercentage( |
| 206 | "nop-insertion-percentage", |
| 207 | cl::desc("Nop insertion probability as percentage"), cl::init(10)); |
| 208 | |
| 209 | cl::list<Ice::VerboseItem> VerboseList( |
| 210 | "verbose", cl::CommaSeparated, |
| 211 | cl::desc("Verbose options (can be comma-separated):"), |
| 212 | cl::values( |
| 213 | clEnumValN(Ice::IceV_Instructions, "inst", "Print basic instructions"), |
| 214 | clEnumValN(Ice::IceV_Deleted, "del", "Include deleted instructions"), |
| 215 | clEnumValN(Ice::IceV_InstNumbers, "instnum", |
| 216 | "Print instruction numbers"), |
| 217 | clEnumValN(Ice::IceV_Preds, "pred", "Show predecessors"), |
| 218 | clEnumValN(Ice::IceV_Succs, "succ", "Show successors"), |
| 219 | clEnumValN(Ice::IceV_Liveness, "live", "Liveness information"), |
| 220 | clEnumValN(Ice::IceV_RegOrigins, "orig", "Physical register origins"), |
| 221 | clEnumValN(Ice::IceV_LinearScan, "regalloc", "Linear scan details"), |
| 222 | clEnumValN(Ice::IceV_Frame, "frame", "Stack frame layout details"), |
| 223 | clEnumValN(Ice::IceV_AddrOpt, "addropt", "Address mode optimization"), |
| 224 | clEnumValN(Ice::IceV_Random, "random", "Randomization details"), |
Jim Stichnoth | a59ae6f | 2015-05-17 10:11:41 -0700 | [diff] [blame] | 225 | clEnumValN(Ice::IceV_Folding, "fold", "Instruction folding details"), |
Jim Stichnoth | e4f65d8 | 2015-06-17 22:16:02 -0700 | [diff] [blame] | 226 | clEnumValN(Ice::IceV_RMW, "rmw", "ReadModifyWrite optimization"), |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 227 | clEnumValN(Ice::IceV_All, "all", "Use all verbose options"), |
| 228 | clEnumValN(Ice::IceV_Most, "most", |
| 229 | "Use all verbose options except 'regalloc'"), |
| 230 | clEnumValN(Ice::IceV_None, "none", "No verbosity"), clEnumValEnd)); |
| 231 | |
| 232 | // Options not captured in Ice::ClFlags and propagated. |
| 233 | |
| 234 | cl::opt<bool> AlwaysExitSuccess( |
| 235 | "exit-success", cl::desc("Exit with success status, even if errors found"), |
| 236 | cl::init(false)); |
| 237 | |
| 238 | // Note: While this flag isn't used in the minimal build, we keep this |
| 239 | // flag so that tests can set this command-line flag without concern |
| 240 | // to the type of build. We double check that this flag at runtime |
| 241 | // to make sure the consistency is maintained. |
| 242 | cl::opt<bool> |
| 243 | BuildOnRead("build-on-read", |
| 244 | cl::desc("Build ICE instructions when reading bitcode"), |
| 245 | cl::init(true)); |
| 246 | |
| 247 | cl::opt<llvm::NaClFileFormat> InputFileFormat( |
| 248 | "bitcode-format", cl::desc("Define format of input file:"), |
| 249 | cl::values(clEnumValN(llvm::LLVMFormat, "llvm", "LLVM file (default)"), |
| 250 | clEnumValN(llvm::PNaClFormat, "pnacl", "PNaCl bitcode file"), |
| 251 | clEnumValEnd), |
| 252 | cl::init(llvm::LLVMFormat)); |
| 253 | |
| 254 | cl::opt<bool> GenerateBuildAtts( |
| 255 | "build-atts", cl::desc("Generate list of build attributes associated with " |
| 256 | "this executable."), |
| 257 | cl::init(false)); |
| 258 | |
| 259 | cl::opt<std::string> IRFilename(cl::Positional, cl::desc("<IR file>"), |
| 260 | cl::init("-")); |
| 261 | cl::opt<std::string> LogFilename("log", cl::desc("Set log filename"), |
| 262 | cl::init("-"), cl::value_desc("filename")); |
| 263 | cl::opt<bool> LLVMVerboseErrors( |
| 264 | "verbose-llvm-parse-errors", |
| 265 | cl::desc("Print out more descriptive PNaCl bitcode parse errors when " |
| 266 | "building LLVM IR first"), |
| 267 | cl::init(false)); |
| 268 | cl::opt<std::string> OutputFilename("o", cl::desc("Override output filename"), |
| 269 | cl::init("-"), cl::value_desc("filename")); |
| 270 | |
| 271 | Ice::IceString AppName; |
| 272 | |
Qining Lu | 253dc8a | 2015-06-22 10:10:23 -0700 | [diff] [blame] | 273 | // Define the command line options for immediates pooling and randomization |
| 274 | cl::opt<Ice::RandomizeAndPoolImmediatesEnum> RandomizeAndPoolImmediatesOption( |
| 275 | "randomize-pool-immediates", |
| 276 | cl::desc("Randomize or pooling the representation of immediates"), |
| 277 | cl::init(Ice::RPI_None), |
| 278 | cl::values(clEnumValN(Ice::RPI_None, "none", |
| 279 | "Do not randomize or pooling immediates (default)"), |
| 280 | clEnumValN(Ice::RPI_Randomize, "randomize", |
| 281 | "Turn on immediate constants blinding"), |
| 282 | clEnumValN(Ice::RPI_Pool, "pool", |
| 283 | "Turn on immediate constants pooling"), |
| 284 | clEnumValEnd)); |
| 285 | // Command line option for x86 immediate integer randomization/pooling |
| 286 | // threshold. Immediates whose representation are between: |
| 287 | // -RandomizeAndPoolImmediatesThreshold/2 and |
| 288 | // +RandomizeAndPoolImmediatesThreshold/2 will be randomized or pooled. |
| 289 | cl::opt<uint32_t> RandomizeAndPoolImmediatesThreshold( |
| 290 | "randomize-pool-threshold", |
| 291 | cl::desc("The threshold for immediates randomization and pooling"), |
| 292 | cl::init(0xffff)); |
| 293 | |
Qining Lu | 969f6a3 | 2015-07-31 09:58:34 -0700 | [diff] [blame] | 294 | // Command line option for turning on basic block shuffling. |
| 295 | cl::opt<bool> ReorderBasicBlocks( |
| 296 | "reorder-basic-blocks", |
| 297 | cl::desc("Shuffle the layout of basic blocks in each functions"), |
| 298 | cl::init(false)); |
| 299 | |
Qining Lu | 7cd5351 | 2015-06-26 09:36:00 -0700 | [diff] [blame] | 300 | // Command line option for turning on function layout reordering. |
| 301 | cl::opt<bool> ReorderFunctions( |
| 302 | "reorder-functions", |
| 303 | cl::desc("Reorder the layout of functions in TEXT section"), |
| 304 | cl::init(false)); |
| 305 | |
| 306 | // Command line option for the shuffling window size for function reordering. |
| 307 | // The default size is 8. |
| 308 | cl::opt<uint32_t> ReorderFunctionsWindowSize( |
| 309 | "reorder-functions-window-size", |
| 310 | cl::desc("The shuffling window size for function reordering. 1 or 0 means " |
| 311 | "no effective shuffling."), |
| 312 | cl::init(8)); |
| 313 | |
| 314 | // Command line option for turning on global variable layout reordering. |
| 315 | cl::opt<bool> ReorderGlobalVariables( |
| 316 | "reorder-global-variables", |
| 317 | cl::desc("Reorder the layout of global variables in NON TEXT section"), |
| 318 | cl::init(false)); |
| 319 | |
| 320 | // Command line option for turning on layout reordering in constant pools. |
| 321 | cl::opt<bool> ReorderPooledConstants( |
| 322 | "reorder-pooled-constants", |
| 323 | cl::desc("Reorder the layout of constants in constant pools"), |
| 324 | cl::init(false)); |
| 325 | |
Karl Schimpf | cb6e95a | 2015-07-23 09:10:03 -0700 | [diff] [blame] | 326 | // Command line option for accepting textual bitcode. |
| 327 | cl::opt<bool> BitcodeAsText( |
| 328 | "bitcode-as-text", |
| 329 | cl::desc( |
| 330 | "Accept textual form of PNaCl bitcode records (i.e. not .ll assembly)"), |
| 331 | cl::init(false)); |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 332 | } // end of anonymous namespace |
| 333 | |
| 334 | namespace Ice { |
| 335 | |
| 336 | void ClFlags::parseFlags(int argc, char **argv) { |
| 337 | cl::ParseCommandLineOptions(argc, argv); |
| 338 | AppName = IceString(argv[0]); |
| 339 | } |
| 340 | |
Karl Schimpf | d8b3289 | 2015-04-16 15:47:25 -0700 | [diff] [blame] | 341 | void ClFlags::resetClFlags(ClFlags &OutFlags) { |
| 342 | // bool fields |
| 343 | OutFlags.AllowErrorRecovery = false; |
| 344 | OutFlags.AllowUninitializedGlobals = false; |
| 345 | OutFlags.DataSections = false; |
| 346 | OutFlags.DecorateAsm = false; |
| 347 | OutFlags.DisableInternal = false; |
| 348 | OutFlags.DisableIRGeneration = false; |
| 349 | OutFlags.DisableTranslation = false; |
| 350 | OutFlags.DumpStats = false; |
John Porto | f8b4cc8 | 2015-06-09 18:06:19 -0700 | [diff] [blame] | 351 | OutFlags.EnableBlockProfile = false; |
Karl Schimpf | d8b3289 | 2015-04-16 15:47:25 -0700 | [diff] [blame] | 352 | OutFlags.FunctionSections = false; |
| 353 | OutFlags.GenerateUnitTestMessages = false; |
| 354 | OutFlags.PhiEdgeSplit = false; |
| 355 | OutFlags.RandomNopInsertion = false; |
| 356 | OutFlags.RandomRegAlloc = false; |
Qining Lu | 969f6a3 | 2015-07-31 09:58:34 -0700 | [diff] [blame] | 357 | OutFlags.ReorderBasicBlocks = false; |
Qining Lu | 7cd5351 | 2015-06-26 09:36:00 -0700 | [diff] [blame] | 358 | OutFlags.ReorderFunctions = false; |
| 359 | OutFlags.ReorderGlobalVariables = false; |
| 360 | OutFlags.ReorderPooledConstants = false; |
Jan Voung | b2d5084 | 2015-05-12 09:53:50 -0700 | [diff] [blame] | 361 | OutFlags.SkipUnimplemented = false; |
Karl Schimpf | d8b3289 | 2015-04-16 15:47:25 -0700 | [diff] [blame] | 362 | OutFlags.SubzeroTimingEnabled = false; |
| 363 | OutFlags.TimeEachFunction = false; |
| 364 | OutFlags.UseSandboxing = false; |
| 365 | // Enum and integer fields. |
| 366 | OutFlags.Opt = Opt_m1; |
| 367 | OutFlags.OutFileType = FT_Iasm; |
| 368 | OutFlags.RandomMaxNopsPerInstruction = 0; |
| 369 | OutFlags.RandomNopProbabilityAsPercentage = 0; |
Qining Lu | 7cd5351 | 2015-06-26 09:36:00 -0700 | [diff] [blame] | 370 | OutFlags.RandomizeAndPoolImmediatesOption = RPI_None; |
| 371 | OutFlags.RandomizeAndPoolImmediatesThreshold = 0xffff; |
| 372 | OutFlags.ReorderFunctionsWindowSize = 8; |
Karl Schimpf | d8b3289 | 2015-04-16 15:47:25 -0700 | [diff] [blame] | 373 | OutFlags.TArch = TargetArch_NUM; |
Jan Voung | 28068ad | 2015-07-31 12:58:46 -0700 | [diff] [blame] | 374 | OutFlags.TestStackExtra = 0; |
Karl Schimpf | d8b3289 | 2015-04-16 15:47:25 -0700 | [diff] [blame] | 375 | OutFlags.VMask = IceV_None; |
| 376 | // IceString fields. |
| 377 | OutFlags.DefaultFunctionPrefix = ""; |
| 378 | OutFlags.DefaultGlobalPrefix = ""; |
| 379 | OutFlags.TestPrefix = ""; |
| 380 | OutFlags.TimingFocusOn = ""; |
| 381 | OutFlags.TranslateOnly = ""; |
| 382 | OutFlags.VerboseFocusOn = ""; |
| 383 | // size_t and 64-bit fields. |
| 384 | OutFlags.NumTranslationThreads = 0; |
| 385 | OutFlags.RandomSeed = 0; |
| 386 | } |
| 387 | |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 388 | void ClFlags::getParsedClFlags(ClFlags &OutFlags) { |
| 389 | if (::DisableIRGeneration) |
| 390 | ::DisableTranslation = true; |
| 391 | |
| 392 | Ice::VerboseMask VMask = Ice::IceV_None; |
| 393 | // Don't generate verbose messages if routines |
| 394 | // to dump messages are not available. |
Jim Stichnoth | 20b71f5 | 2015-06-24 15:52:24 -0700 | [diff] [blame] | 395 | if (BuildDefs::dump()) { |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 396 | for (unsigned i = 0; i != VerboseList.size(); ++i) |
| 397 | VMask |= VerboseList[i]; |
| 398 | } |
| 399 | |
| 400 | OutFlags.setAllowErrorRecovery(::AllowErrorRecovery); |
| 401 | OutFlags.setAllowUninitializedGlobals(::AllowUninitializedGlobals); |
| 402 | OutFlags.setDataSections(::DataSections); |
| 403 | OutFlags.setDecorateAsm(::DecorateAsm); |
| 404 | OutFlags.setDefaultFunctionPrefix(::DefaultFunctionPrefix); |
| 405 | OutFlags.setDefaultGlobalPrefix(::DefaultGlobalPrefix); |
| 406 | OutFlags.setDisableInternal(::DisableInternal); |
| 407 | OutFlags.setDisableIRGeneration(::DisableIRGeneration); |
| 408 | OutFlags.setDisableTranslation(::DisableTranslation); |
| 409 | OutFlags.setDumpStats(::DumpStats); |
John Porto | f8b4cc8 | 2015-06-09 18:06:19 -0700 | [diff] [blame] | 410 | OutFlags.setEnableBlockProfile(::EnableBlockProfile); |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 411 | OutFlags.setFunctionSections(::FunctionSections); |
| 412 | OutFlags.setNumTranslationThreads(::NumThreads); |
| 413 | OutFlags.setOptLevel(::OLevel); |
Jim Stichnoth | a3f57b9 | 2015-07-30 12:46:04 -0700 | [diff] [blame] | 414 | OutFlags.setPhiEdgeSplit(::EnablePhiEdgeSplit); |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 415 | OutFlags.setRandomSeed(::RandomSeed); |
Qining Lu | 969f6a3 | 2015-07-31 09:58:34 -0700 | [diff] [blame] | 416 | OutFlags.setRandomizeAndPoolImmediatesOption( |
| 417 | ::RandomizeAndPoolImmediatesOption); |
| 418 | OutFlags.setRandomizeAndPoolImmediatesThreshold( |
| 419 | ::RandomizeAndPoolImmediatesThreshold); |
| 420 | OutFlags.setReorderFunctionsWindowSize(::ReorderFunctionsWindowSize); |
| 421 | OutFlags.setShouldReorderBasicBlocks(::ReorderBasicBlocks); |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 422 | OutFlags.setShouldDoNopInsertion(::ShouldDoNopInsertion); |
| 423 | OutFlags.setShouldRandomizeRegAlloc(::RandomizeRegisterAllocation); |
Qining Lu | 969f6a3 | 2015-07-31 09:58:34 -0700 | [diff] [blame] | 424 | OutFlags.setShouldReorderFunctions(::ReorderFunctions); |
| 425 | OutFlags.setShouldReorderGlobalVariables(::ReorderGlobalVariables); |
| 426 | OutFlags.setShouldReorderPooledConstants(::ReorderPooledConstants); |
Jan Voung | b2d5084 | 2015-05-12 09:53:50 -0700 | [diff] [blame] | 427 | OutFlags.setSkipUnimplemented(::SkipUnimplemented); |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 428 | OutFlags.setSubzeroTimingEnabled(::SubzeroTimingEnabled); |
| 429 | OutFlags.setTargetArch(::TargetArch); |
| 430 | OutFlags.setTargetInstructionSet(::TargetInstructionSet); |
| 431 | OutFlags.setTestPrefix(::TestPrefix); |
Jan Voung | 28068ad | 2015-07-31 12:58:46 -0700 | [diff] [blame] | 432 | OutFlags.setTestStackExtra(::TestStackExtra); |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 433 | OutFlags.setTimeEachFunction(::TimeEachFunction); |
| 434 | OutFlags.setTimingFocusOn(::TimingFocusOn); |
| 435 | OutFlags.setTranslateOnly(::TranslateOnly); |
| 436 | OutFlags.setUseSandboxing(::UseSandboxing); |
| 437 | OutFlags.setVerboseFocusOn(::VerboseFocusOn); |
| 438 | OutFlags.setOutFileType(::OutFileType); |
| 439 | OutFlags.setMaxNopsPerInstruction(::MaxNopsPerInstruction); |
| 440 | OutFlags.setNopProbabilityAsPercentage(::NopProbabilityAsPercentage); |
| 441 | OutFlags.setVerbose(VMask); |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 442 | } |
| 443 | |
| 444 | void ClFlags::getParsedClFlagsExtra(ClFlagsExtra &OutFlagsExtra) { |
| 445 | OutFlagsExtra.setAlwaysExitSuccess(AlwaysExitSuccess); |
Karl Schimpf | cb6e95a | 2015-07-23 09:10:03 -0700 | [diff] [blame] | 446 | OutFlagsExtra.setBitcodeAsText(BitcodeAsText); |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 447 | OutFlagsExtra.setBuildOnRead(BuildOnRead); |
| 448 | OutFlagsExtra.setGenerateBuildAtts(GenerateBuildAtts); |
| 449 | OutFlagsExtra.setLLVMVerboseErrors(LLVMVerboseErrors); |
| 450 | OutFlagsExtra.setAppName(AppName); |
| 451 | OutFlagsExtra.setInputFileFormat(InputFileFormat); |
| 452 | OutFlagsExtra.setIRFilename(IRFilename); |
| 453 | OutFlagsExtra.setLogFilename(LogFilename); |
| 454 | OutFlagsExtra.setOutputFilename(OutputFilename); |
| 455 | } |
| 456 | |
| 457 | } // end of namespace Ice |