| 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 |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 TranslateOnly("translate-only", | 216 TranslateOnly("translate-only", |
| 217 cl::desc("Translate only the given function"), cl::init("")); | 217 cl::desc("Translate only the given function"), cl::init("")); |
| 218 | 218 |
| 219 cl::opt<bool> UseSandboxing("sandbox", cl::desc("Use sandboxing")); | 219 cl::opt<bool> UseSandboxing("sandbox", cl::desc("Use sandboxing")); |
| 220 | 220 |
| 221 cl::opt<std::string> VerboseFocusOn( | 221 cl::opt<std::string> VerboseFocusOn( |
| 222 "verbose-focus", | 222 "verbose-focus", |
| 223 cl::desc("Override with -verbose=none except for the specified function"), | 223 cl::desc("Override with -verbose=none except for the specified function"), |
| 224 cl::init("")); | 224 cl::init("")); |
| 225 | 225 |
| 226 cl::opt<Ice::FileType> OutFileType( | 226 // Allow integrated assembler to use standalone assembler for instructions not |
| 227 "filetype", cl::desc("Output file type"), cl::init(Ice::FT_Iasm), | 227 // yet implemented in the integrated assembler. |
| 228 cl::values(clEnumValN(Ice::FT_Elf, "obj", "Native ELF object ('.o') file"), | 228 cl::opt<bool> |
| 229 clEnumValN(Ice::FT_Asm, "asm", "Assembly ('.s') file"), | 229 AllowHybridAssembly("hybrid-asm", |
| 230 clEnumValN(Ice::FT_Iasm, "iasm", | 230 cl::desc("Use hybrid of 'asm' and 'iasm' assemblers"), |
| 231 cl::init(false)); |
| 232 |
| 233 // Extends enum FileType to incorporate a hybrid integrated assembler. |
| 234 enum ClFileType { |
| 235 CFT_Elf = Ice::FT_Elf, |
| 236 CFT_Asm = Ice::FT_Asm, |
| 237 CFT_Iasm = Ice::FT_Iasm, |
| 238 CFT_Hasm = 1000 // Intentionally big to not conflict with FT constants. |
| 239 }; |
| 240 |
| 241 cl::opt<ClFileType> OutFileType( |
| 242 "filetype", cl::desc("Output file type"), cl::init(CFT_Iasm), |
| 243 cl::values(clEnumValN(CFT_Elf, "obj", "Native ELF object ('.o') file"), |
| 244 clEnumValN(CFT_Asm, "asm", "Assembly ('.s') file"), |
| 245 clEnumValN(CFT_Iasm, "iasm", |
| 231 "Low-level integrated assembly ('.s') file"), | 246 "Low-level integrated assembly ('.s') file"), |
| 247 clEnumValN(CFT_Hasm, "hasm", |
| 248 "shortcut for '-filetype=iasm -hybrid-asm'"), |
| 232 clEnumValEnd)); | 249 clEnumValEnd)); |
| 233 | 250 |
| 234 cl::opt<int> MaxNopsPerInstruction( | 251 cl::opt<int> MaxNopsPerInstruction( |
| 235 "max-nops-per-instruction", | 252 "max-nops-per-instruction", |
| 236 cl::desc("Max number of nops to insert per instruction"), cl::init(1)); | 253 cl::desc("Max number of nops to insert per instruction"), cl::init(1)); |
| 237 | 254 |
| 238 cl::opt<int> NopProbabilityAsPercentage( | 255 cl::opt<int> NopProbabilityAsPercentage( |
| 239 "nop-insertion-percentage", | 256 "nop-insertion-percentage", |
| 240 cl::desc("Nop insertion probability as percentage"), cl::init(10)); | 257 cl::desc("Nop insertion probability as percentage"), cl::init(10)); |
| 241 | 258 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 | 386 |
| 370 void ClFlags::parseFlags(int argc, char **argv) { | 387 void ClFlags::parseFlags(int argc, char **argv) { |
| 371 cl::ParseCommandLineOptions(argc, argv); | 388 cl::ParseCommandLineOptions(argc, argv); |
| 372 AppName = IceString(argv[0]); | 389 AppName = IceString(argv[0]); |
| 373 } | 390 } |
| 374 | 391 |
| 375 void ClFlags::resetClFlags(ClFlags &OutFlags) { | 392 void ClFlags::resetClFlags(ClFlags &OutFlags) { |
| 376 // bool fields | 393 // bool fields |
| 377 OutFlags.AllowErrorRecovery = false; | 394 OutFlags.AllowErrorRecovery = false; |
| 378 OutFlags.AllowExternDefinedSymbols = false; | 395 OutFlags.AllowExternDefinedSymbols = false; |
| 396 OutFlags.AllowHybridAssembly = false; |
| 379 OutFlags.AllowIacaMarks = false; | 397 OutFlags.AllowIacaMarks = false; |
| 380 OutFlags.AllowUninitializedGlobals = false; | 398 OutFlags.AllowUninitializedGlobals = false; |
| 381 OutFlags.DataSections = false; | 399 OutFlags.DataSections = false; |
| 382 OutFlags.DecorateAsm = false; | 400 OutFlags.DecorateAsm = false; |
| 383 OutFlags.DisableInternal = false; | 401 OutFlags.DisableInternal = false; |
| 384 OutFlags.DisableIRGeneration = false; | 402 OutFlags.DisableIRGeneration = false; |
| 385 OutFlags.DisableTranslation = false; | 403 OutFlags.DisableTranslation = false; |
| 386 OutFlags.DumpStats = false; | 404 OutFlags.DumpStats = false; |
| 387 OutFlags.EnableBlockProfile = false; | 405 OutFlags.EnableBlockProfile = false; |
| 388 OutFlags.ForceMemIntrinOpt = false; | 406 OutFlags.ForceMemIntrinOpt = false; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 // Don't generate verbose messages if routines to dump messages are not | 450 // Don't generate verbose messages if routines to dump messages are not |
| 433 // available. | 451 // available. |
| 434 if (BuildDefs::dump()) { | 452 if (BuildDefs::dump()) { |
| 435 for (unsigned i = 0; i != VerboseList.size(); ++i) | 453 for (unsigned i = 0; i != VerboseList.size(); ++i) |
| 436 VMask |= VerboseList[i]; | 454 VMask |= VerboseList[i]; |
| 437 } | 455 } |
| 438 | 456 |
| 439 OutFlags.setAllowErrorRecovery(::AllowErrorRecovery); | 457 OutFlags.setAllowErrorRecovery(::AllowErrorRecovery); |
| 440 OutFlags.setAllowExternDefinedSymbols(::AllowExternDefinedSymbols || | 458 OutFlags.setAllowExternDefinedSymbols(::AllowExternDefinedSymbols || |
| 441 ::DisableInternal); | 459 ::DisableInternal); |
| 460 OutFlags.setAllowHybridAssembly(::AllowHybridAssembly || |
| 461 ::OutFileType == CFT_Hasm); |
| 442 OutFlags.setAllowIacaMarks(::AllowIacaMarks); | 462 OutFlags.setAllowIacaMarks(::AllowIacaMarks); |
| 443 OutFlags.setAllowUninitializedGlobals(::AllowUninitializedGlobals); | 463 OutFlags.setAllowUninitializedGlobals(::AllowUninitializedGlobals); |
| 444 OutFlags.setDataSections(::DataSections); | 464 OutFlags.setDataSections(::DataSections); |
| 445 OutFlags.setDecorateAsm(::DecorateAsm); | 465 OutFlags.setDecorateAsm(::DecorateAsm); |
| 446 OutFlags.setDefaultFunctionPrefix(::DefaultFunctionPrefix); | 466 OutFlags.setDefaultFunctionPrefix(::DefaultFunctionPrefix); |
| 447 OutFlags.setDefaultGlobalPrefix(::DefaultGlobalPrefix); | 467 OutFlags.setDefaultGlobalPrefix(::DefaultGlobalPrefix); |
| 448 OutFlags.setDisableInternal(::DisableInternal); | 468 OutFlags.setDisableInternal(::DisableInternal); |
| 449 OutFlags.setDisableIRGeneration(::DisableIRGeneration); | 469 OutFlags.setDisableIRGeneration(::DisableIRGeneration); |
| 450 OutFlags.setDisableTranslation(::DisableTranslation); | 470 OutFlags.setDisableTranslation(::DisableTranslation); |
| 451 OutFlags.setDumpStats(::DumpStats); | 471 OutFlags.setDumpStats(::DumpStats); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 473 OutFlags.setSubzeroTimingEnabled(::SubzeroTimingEnabled); | 493 OutFlags.setSubzeroTimingEnabled(::SubzeroTimingEnabled); |
| 474 OutFlags.setTargetArch(::TargetArch); | 494 OutFlags.setTargetArch(::TargetArch); |
| 475 OutFlags.setTargetInstructionSet(::TargetInstructionSet); | 495 OutFlags.setTargetInstructionSet(::TargetInstructionSet); |
| 476 OutFlags.setTestPrefix(::TestPrefix); | 496 OutFlags.setTestPrefix(::TestPrefix); |
| 477 OutFlags.setTestStackExtra(::TestStackExtra); | 497 OutFlags.setTestStackExtra(::TestStackExtra); |
| 478 OutFlags.setTimeEachFunction(::TimeEachFunction); | 498 OutFlags.setTimeEachFunction(::TimeEachFunction); |
| 479 OutFlags.setTimingFocusOn(::TimingFocusOn); | 499 OutFlags.setTimingFocusOn(::TimingFocusOn); |
| 480 OutFlags.setTranslateOnly(::TranslateOnly); | 500 OutFlags.setTranslateOnly(::TranslateOnly); |
| 481 OutFlags.setUseSandboxing(::UseSandboxing); | 501 OutFlags.setUseSandboxing(::UseSandboxing); |
| 482 OutFlags.setVerboseFocusOn(::VerboseFocusOn); | 502 OutFlags.setVerboseFocusOn(::VerboseFocusOn); |
| 483 OutFlags.setOutFileType(::OutFileType); | 503 OutFlags.setOutFileType( |
| 504 ::OutFileType == CFT_Hasm |
| 505 ? FT_Iasm |
| 506 : static_cast<Ice::FileType>(static_cast<int>(::OutFileType))); |
| 484 OutFlags.setMaxNopsPerInstruction(::MaxNopsPerInstruction); | 507 OutFlags.setMaxNopsPerInstruction(::MaxNopsPerInstruction); |
| 485 OutFlags.setNopProbabilityAsPercentage(::NopProbabilityAsPercentage); | 508 OutFlags.setNopProbabilityAsPercentage(::NopProbabilityAsPercentage); |
| 486 OutFlags.setVerbose(VMask); | 509 OutFlags.setVerbose(VMask); |
| 487 } | 510 } |
| 488 | 511 |
| 489 void ClFlags::getParsedClFlagsExtra(ClFlagsExtra &OutFlagsExtra) { | 512 void ClFlags::getParsedClFlagsExtra(ClFlagsExtra &OutFlagsExtra) { |
| 490 OutFlagsExtra.setAlwaysExitSuccess(AlwaysExitSuccess); | 513 OutFlagsExtra.setAlwaysExitSuccess(AlwaysExitSuccess); |
| 491 OutFlagsExtra.setBitcodeAsText(BitcodeAsText); | 514 OutFlagsExtra.setBitcodeAsText(BitcodeAsText); |
| 492 OutFlagsExtra.setBuildOnRead(BuildOnRead); | 515 OutFlagsExtra.setBuildOnRead(BuildOnRead); |
| 493 OutFlagsExtra.setGenerateBuildAtts(GenerateBuildAtts); | 516 OutFlagsExtra.setGenerateBuildAtts(GenerateBuildAtts); |
| 494 OutFlagsExtra.setLLVMVerboseErrors(LLVMVerboseErrors); | 517 OutFlagsExtra.setLLVMVerboseErrors(LLVMVerboseErrors); |
| 495 OutFlagsExtra.setAppName(AppName); | 518 OutFlagsExtra.setAppName(AppName); |
| 496 OutFlagsExtra.setInputFileFormat(InputFileFormat); | 519 OutFlagsExtra.setInputFileFormat(InputFileFormat); |
| 497 OutFlagsExtra.setIRFilename(IRFilename); | 520 OutFlagsExtra.setIRFilename(IRFilename); |
| 498 OutFlagsExtra.setLogFilename(LogFilename); | 521 OutFlagsExtra.setLogFilename(LogFilename); |
| 499 OutFlagsExtra.setOutputFilename(OutputFilename); | 522 OutFlagsExtra.setOutputFilename(OutputFilename); |
| 500 } | 523 } |
| 501 | 524 |
| 502 } // end of namespace Ice | 525 } // end of namespace Ice |
| OLD | NEW |