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 // This file defines commandline flags parsing. | 10 // This file defines commandline flags parsing. |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 cl::opt<bool> | 99 cl::opt<bool> |
100 EnablePhiEdgeSplit("phi-edge-split", | 100 EnablePhiEdgeSplit("phi-edge-split", |
101 cl::desc("Enable edge splitting for Phi lowering"), | 101 cl::desc("Enable edge splitting for Phi lowering"), |
102 cl::init(true)); | 102 cl::init(true)); |
103 | 103 |
104 // TODO(stichnot): See if we can easily use LLVM's -rng-seed option | 104 // TODO(stichnot): See if we can easily use LLVM's -rng-seed option |
105 // and implementation. I expect the implementation is different and | 105 // and implementation. I expect the implementation is different and |
106 // therefore the tests would need to be changed. | 106 // therefore the tests would need to be changed. |
107 cl::opt<unsigned long long> | 107 cl::opt<unsigned long long> |
108 RandomSeed("sz-seed", cl::desc("Seed the random number generator"), | 108 RandomSeed("sz-seed", cl::desc("Seed the random number generator"), |
109 cl::init(time(0))); | 109 cl::init(1)); |
110 | 110 |
111 cl::opt<bool> ShouldDoNopInsertion("nop-insertion", | 111 cl::opt<bool> ShouldDoNopInsertion("nop-insertion", |
112 cl::desc("Randomly insert NOPs"), | 112 cl::desc("Randomly insert NOPs"), |
113 cl::init(false)); | 113 cl::init(false)); |
114 | 114 |
115 cl::opt<bool> | 115 cl::opt<bool> |
116 RandomizeRegisterAllocation("randomize-regalloc", | 116 RandomizeRegisterAllocation("randomize-regalloc", |
117 cl::desc("Randomize register allocation"), | 117 cl::desc("Randomize register allocation"), |
118 cl::init(false)); | 118 cl::init(false)); |
119 | 119 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 cl::opt<bool> LLVMVerboseErrors( | 251 cl::opt<bool> LLVMVerboseErrors( |
252 "verbose-llvm-parse-errors", | 252 "verbose-llvm-parse-errors", |
253 cl::desc("Print out more descriptive PNaCl bitcode parse errors when " | 253 cl::desc("Print out more descriptive PNaCl bitcode parse errors when " |
254 "building LLVM IR first"), | 254 "building LLVM IR first"), |
255 cl::init(false)); | 255 cl::init(false)); |
256 cl::opt<std::string> OutputFilename("o", cl::desc("Override output filename"), | 256 cl::opt<std::string> OutputFilename("o", cl::desc("Override output filename"), |
257 cl::init("-"), cl::value_desc("filename")); | 257 cl::init("-"), cl::value_desc("filename")); |
258 | 258 |
259 Ice::IceString AppName; | 259 Ice::IceString AppName; |
260 | 260 |
| 261 // Define the command line options for immediates pooling and randomization |
| 262 cl::opt<Ice::RandomizeAndPoolImmediatesEnum> RandomizeAndPoolImmediatesOption( |
| 263 "randomize-pool-immediates", |
| 264 cl::desc("Randomize or pooling the representation of immediates"), |
| 265 cl::init(Ice::RPI_None), |
| 266 cl::values(clEnumValN(Ice::RPI_None, "none", |
| 267 "Do not randomize or pooling immediates (default)"), |
| 268 clEnumValN(Ice::RPI_Randomize, "randomize", |
| 269 "Turn on immediate constants blinding"), |
| 270 clEnumValN(Ice::RPI_Pool, "pool", |
| 271 "Turn on immediate constants pooling"), |
| 272 clEnumValEnd)); |
| 273 // Command line option for x86 immediate integer randomization/pooling |
| 274 // threshold. Immediates whose representation are between: |
| 275 // -RandomizeAndPoolImmediatesThreshold/2 and |
| 276 // +RandomizeAndPoolImmediatesThreshold/2 will be randomized or pooled. |
| 277 cl::opt<uint32_t> RandomizeAndPoolImmediatesThreshold( |
| 278 "randomize-pool-threshold", |
| 279 cl::desc("The threshold for immediates randomization and pooling"), |
| 280 cl::init(0xffff)); |
| 281 |
261 } // end of anonymous namespace | 282 } // end of anonymous namespace |
262 | 283 |
263 namespace Ice { | 284 namespace Ice { |
264 | 285 |
265 void ClFlags::parseFlags(int argc, char **argv) { | 286 void ClFlags::parseFlags(int argc, char **argv) { |
266 cl::ParseCommandLineOptions(argc, argv); | 287 cl::ParseCommandLineOptions(argc, argv); |
267 AppName = IceString(argv[0]); | 288 AppName = IceString(argv[0]); |
268 } | 289 } |
269 | 290 |
270 void ClFlags::resetClFlags(ClFlags &OutFlags) { | 291 void ClFlags::resetClFlags(ClFlags &OutFlags) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 OutFlags.setTestPrefix(::TestPrefix); | 364 OutFlags.setTestPrefix(::TestPrefix); |
344 OutFlags.setTimeEachFunction(::TimeEachFunction); | 365 OutFlags.setTimeEachFunction(::TimeEachFunction); |
345 OutFlags.setTimingFocusOn(::TimingFocusOn); | 366 OutFlags.setTimingFocusOn(::TimingFocusOn); |
346 OutFlags.setTranslateOnly(::TranslateOnly); | 367 OutFlags.setTranslateOnly(::TranslateOnly); |
347 OutFlags.setUseSandboxing(::UseSandboxing); | 368 OutFlags.setUseSandboxing(::UseSandboxing); |
348 OutFlags.setVerboseFocusOn(::VerboseFocusOn); | 369 OutFlags.setVerboseFocusOn(::VerboseFocusOn); |
349 OutFlags.setOutFileType(::OutFileType); | 370 OutFlags.setOutFileType(::OutFileType); |
350 OutFlags.setMaxNopsPerInstruction(::MaxNopsPerInstruction); | 371 OutFlags.setMaxNopsPerInstruction(::MaxNopsPerInstruction); |
351 OutFlags.setNopProbabilityAsPercentage(::NopProbabilityAsPercentage); | 372 OutFlags.setNopProbabilityAsPercentage(::NopProbabilityAsPercentage); |
352 OutFlags.setVerbose(VMask); | 373 OutFlags.setVerbose(VMask); |
| 374 |
| 375 // set for immediates randomization or pooling option |
| 376 OutFlags.setRandomizeAndPoolImmediatesOption( |
| 377 ::RandomizeAndPoolImmediatesOption); |
| 378 OutFlags.setRandomizeAndPoolImmediatesThreshold( |
| 379 ::RandomizeAndPoolImmediatesThreshold); |
353 } | 380 } |
354 | 381 |
355 void ClFlags::getParsedClFlagsExtra(ClFlagsExtra &OutFlagsExtra) { | 382 void ClFlags::getParsedClFlagsExtra(ClFlagsExtra &OutFlagsExtra) { |
356 OutFlagsExtra.setAlwaysExitSuccess(AlwaysExitSuccess); | 383 OutFlagsExtra.setAlwaysExitSuccess(AlwaysExitSuccess); |
357 OutFlagsExtra.setBuildOnRead(BuildOnRead); | 384 OutFlagsExtra.setBuildOnRead(BuildOnRead); |
358 OutFlagsExtra.setGenerateBuildAtts(GenerateBuildAtts); | 385 OutFlagsExtra.setGenerateBuildAtts(GenerateBuildAtts); |
359 OutFlagsExtra.setLLVMVerboseErrors(LLVMVerboseErrors); | 386 OutFlagsExtra.setLLVMVerboseErrors(LLVMVerboseErrors); |
360 OutFlagsExtra.setAppName(AppName); | 387 OutFlagsExtra.setAppName(AppName); |
361 OutFlagsExtra.setInputFileFormat(InputFileFormat); | 388 OutFlagsExtra.setInputFileFormat(InputFileFormat); |
362 OutFlagsExtra.setIRFilename(IRFilename); | 389 OutFlagsExtra.setIRFilename(IRFilename); |
363 OutFlagsExtra.setLogFilename(LogFilename); | 390 OutFlagsExtra.setLogFilename(LogFilename); |
364 OutFlagsExtra.setOutputFilename(OutputFilename); | 391 OutFlagsExtra.setOutputFilename(OutputFilename); |
365 } | 392 } |
366 | 393 |
367 } // end of namespace Ice | 394 } // end of namespace Ice |
OLD | NEW |