Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/IceClFlags.cpp

Issue 1571433004: Implements include/exclude register lists for translation. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: fix nits. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 /// Max number of nops to insert per instruction. 280 /// Max number of nops to insert per instruction.
281 cl::opt<int> MaxNopsPerInstruction( 281 cl::opt<int> MaxNopsPerInstruction(
282 "max-nops-per-instruction", 282 "max-nops-per-instruction",
283 cl::desc("Max number of nops to insert per instruction"), cl::init(1)); 283 cl::desc("Max number of nops to insert per instruction"), cl::init(1));
284 284
285 /// Nop insertion probability as percentage. 285 /// Nop insertion probability as percentage.
286 cl::opt<int> NopProbabilityAsPercentage( 286 cl::opt<int> NopProbabilityAsPercentage(
287 "nop-insertion-percentage", 287 "nop-insertion-percentage",
288 cl::desc("Nop insertion probability as percentage"), cl::init(10)); 288 cl::desc("Nop insertion probability as percentage"), cl::init(10));
289 289
290 /// Restricts registers in corresponding register classes to specified list.
291 cl::list<std::string> UseRestrictedRegisters(
292 "use-registers",
Jim Stichnoth 2016/01/10 16:51:25 Can you add the cl::CommaSeparated option here, wh
Karl 2016/01/12 23:44:04 Done.
293 cl::desc(
294 "Only use specified registers for corresponding register classes"));
295
296 /// List of excluded registers.
297 cl::list<std::string>
298 ExcludedRegisters("exclude-registers",
Jim Stichnoth 2016/01/10 16:51:25 I would give these two option names a common prefi
Karl 2016/01/12 23:44:04 Switched to '-reg-use' and '-reg-exclude'.
299 cl::desc("Don't use specified registers"));
300
290 /// Verbose options (can be comma-separated). 301 /// Verbose options (can be comma-separated).
291 cl::list<Ice::VerboseItem> VerboseList( 302 cl::list<Ice::VerboseItem> VerboseList(
292 "verbose", cl::CommaSeparated, 303 "verbose", cl::CommaSeparated,
293 cl::desc("Verbose options (can be comma-separated):"), 304 cl::desc("Verbose options (can be comma-separated):"),
294 cl::values( 305 cl::values(
295 clEnumValN(Ice::IceV_Instructions, "inst", "Print basic instructions"), 306 clEnumValN(Ice::IceV_Instructions, "inst", "Print basic instructions"),
296 clEnumValN(Ice::IceV_Deleted, "del", "Include deleted instructions"), 307 clEnumValN(Ice::IceV_Deleted, "del", "Include deleted instructions"),
297 clEnumValN(Ice::IceV_InstNumbers, "instnum", 308 clEnumValN(Ice::IceV_InstNumbers, "instnum",
298 "Print instruction numbers"), 309 "Print instruction numbers"),
299 clEnumValN(Ice::IceV_Preds, "pred", "Show predecessors"), 310 clEnumValN(Ice::IceV_Preds, "pred", "Show predecessors"),
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 ReorderPooledConstants("reorder-pooled-constants", 425 ReorderPooledConstants("reorder-pooled-constants",
415 cl::desc("Randomize constant pool entry ordering"), 426 cl::desc("Randomize constant pool entry ordering"),
416 cl::init(false)); 427 cl::init(false));
417 428
418 /// Command line option for accepting textual bitcode. 429 /// Command line option for accepting textual bitcode.
419 cl::opt<bool> BitcodeAsText( 430 cl::opt<bool> BitcodeAsText(
420 "bitcode-as-text", 431 "bitcode-as-text",
421 cl::desc( 432 cl::desc(
422 "Accept textual form of PNaCl bitcode records (i.e. not .ll assembly)"), 433 "Accept textual form of PNaCl bitcode records (i.e. not .ll assembly)"),
423 cl::init(false)); 434 cl::init(false));
435
436 void splitOnChars(const std::string &Text, const char *Chars,
437 std::vector<std::string> &Tokens) {
438 size_t Start = 0;
439 bool KeepSplitting = true;
440 while (KeepSplitting) {
441 size_t End = Text.find_first_of(Chars, Start);
442 if (End == std::string::npos) {
443 KeepSplitting = false;
444 End = Text.size();
445 }
446 std::string RegName = Text.substr(Start, End - Start);
447 Tokens.push_back(RegName);
448 Start = End + 1;
449 }
450 }
451
452 void extractCommaSeparated(cl::list<std::string> &NameList,
453 std::vector<std::string> &Names) {
454 Names.clear();
455 for (const std::string &Name : NameList) {
456 splitOnChars(Name, ",", Names);
457 }
458 }
459
424 } // end of anonymous namespace 460 } // end of anonymous namespace
425 461
426 namespace Ice { 462 namespace Ice {
427 463
428 void ClFlags::parseFlags(int argc, char **argv) { 464 void ClFlags::parseFlags(int argc, char **argv) {
429 cl::ParseCommandLineOptions(argc, argv); 465 cl::ParseCommandLineOptions(argc, argv);
430 AppName = IceString(argv[0]); 466 AppName = IceString(argv[0]);
431 } 467 }
432 468
433 void ClFlags::resetClFlags(ClFlags &OutFlags) { 469 void ClFlags::resetClFlags(ClFlags &OutFlags) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 // IceString fields. 510 // IceString fields.
475 OutFlags.DefaultFunctionPrefix = ""; 511 OutFlags.DefaultFunctionPrefix = "";
476 OutFlags.DefaultGlobalPrefix = ""; 512 OutFlags.DefaultGlobalPrefix = "";
477 OutFlags.TestPrefix = ""; 513 OutFlags.TestPrefix = "";
478 OutFlags.TimingFocusOn = ""; 514 OutFlags.TimingFocusOn = "";
479 OutFlags.TranslateOnly = ""; 515 OutFlags.TranslateOnly = "";
480 OutFlags.VerboseFocusOn = ""; 516 OutFlags.VerboseFocusOn = "";
481 // size_t and 64-bit fields. 517 // size_t and 64-bit fields.
482 OutFlags.NumTranslationThreads = 0; 518 OutFlags.NumTranslationThreads = 0;
483 OutFlags.RandomSeed = 0; 519 OutFlags.RandomSeed = 0;
520 // Sets.
521 OutFlags.clearExcludedRegisters();
522 OutFlags.clearUseRestrictedRegisters();
484 } 523 }
485 524
486 void ClFlags::getParsedClFlags(ClFlags &OutFlags) { 525 void ClFlags::getParsedClFlags(ClFlags &OutFlags) {
487 Ice::VerboseMask VMask = Ice::IceV_None; 526 Ice::VerboseMask VMask = Ice::IceV_None;
488 // Don't generate verbose messages if routines to dump messages are not 527 // Don't generate verbose messages if routines to dump messages are not
489 // available. 528 // available.
490 if (BuildDefs::dump()) { 529 if (BuildDefs::dump()) {
491 for (unsigned i = 0; i != VerboseList.size(); ++i) 530 for (unsigned i = 0; i != VerboseList.size(); ++i)
492 VMask |= VerboseList[i]; 531 VMask |= VerboseList[i];
493 } 532 }
494 533
495 OutFlags.setAllowErrorRecovery(::AllowErrorRecovery); 534 OutFlags.setAllowErrorRecovery(::AllowErrorRecovery);
496 OutFlags.setAllowExternDefinedSymbols(::AllowExternDefinedSymbols || 535 OutFlags.setAllowExternDefinedSymbols(::AllowExternDefinedSymbols ||
497 ::DisableInternal); 536 ::DisableInternal);
498 OutFlags.setAllowIacaMarks(::AllowIacaMarks); 537 OutFlags.setAllowIacaMarks(::AllowIacaMarks);
499 OutFlags.setAllowUninitializedGlobals(::AllowUninitializedGlobals); 538 OutFlags.setAllowUninitializedGlobals(::AllowUninitializedGlobals);
500 OutFlags.setDataSections(::DataSections); 539 OutFlags.setDataSections(::DataSections);
501 OutFlags.setDecorateAsm(::DecorateAsm); 540 OutFlags.setDecorateAsm(::DecorateAsm);
502 OutFlags.setDefaultFunctionPrefix(::DefaultFunctionPrefix); 541 OutFlags.setDefaultFunctionPrefix(::DefaultFunctionPrefix);
503 OutFlags.setDefaultGlobalPrefix(::DefaultGlobalPrefix); 542 OutFlags.setDefaultGlobalPrefix(::DefaultGlobalPrefix);
504 OutFlags.setDisableHybridAssembly(::DisableHybridAssembly || 543 OutFlags.setDisableHybridAssembly(::DisableHybridAssembly ||
505 (::OutFileType != Ice::FT_Iasm)); 544 (::OutFileType != Ice::FT_Iasm));
506 OutFlags.setDisableInternal(::DisableInternal); 545 OutFlags.setDisableInternal(::DisableInternal);
507 OutFlags.setDisableTranslation(::DisableTranslation); 546 OutFlags.setDisableTranslation(::DisableTranslation);
508 OutFlags.setDumpStats(::DumpStats); 547 OutFlags.setDumpStats(::DumpStats);
509 OutFlags.setEnableBlockProfile(::EnableBlockProfile); 548 OutFlags.setEnableBlockProfile(::EnableBlockProfile);
549 std::vector<std::string> RegNames;
550 extractCommaSeparated(::ExcludedRegisters, RegNames);
551 for (const auto &Name : RegNames)
552 OutFlags.insertExcludedRegister(Name);
510 OutFlags.setForceMemIntrinOpt(::ForceMemIntrinOpt); 553 OutFlags.setForceMemIntrinOpt(::ForceMemIntrinOpt);
511 OutFlags.setFunctionSections(::FunctionSections); 554 OutFlags.setFunctionSections(::FunctionSections);
512 OutFlags.setNumTranslationThreads(::NumThreads); 555 OutFlags.setNumTranslationThreads(::NumThreads);
513 OutFlags.setOptLevel(::OLevel); 556 OutFlags.setOptLevel(::OLevel);
514 OutFlags.setMockBoundsCheck(::MockBoundsCheck); 557 OutFlags.setMockBoundsCheck(::MockBoundsCheck);
515 OutFlags.setPhiEdgeSplit(::EnablePhiEdgeSplit); 558 OutFlags.setPhiEdgeSplit(::EnablePhiEdgeSplit);
516 OutFlags.setRandomSeed(::RandomSeed); 559 OutFlags.setRandomSeed(::RandomSeed);
517 OutFlags.setRandomizeAndPoolImmediatesOption( 560 OutFlags.setRandomizeAndPoolImmediatesOption(
518 ::RandomizeAndPoolImmediatesOption); 561 ::RandomizeAndPoolImmediatesOption);
519 OutFlags.setRandomizeAndPoolImmediatesThreshold( 562 OutFlags.setRandomizeAndPoolImmediatesThreshold(
520 ::RandomizeAndPoolImmediatesThreshold); 563 ::RandomizeAndPoolImmediatesThreshold);
521 OutFlags.setReorderFunctionsWindowSize(::ReorderFunctionsWindowSize); 564 OutFlags.setReorderFunctionsWindowSize(::ReorderFunctionsWindowSize);
522 OutFlags.setShouldReorderBasicBlocks(::ReorderBasicBlocks); 565 OutFlags.setShouldReorderBasicBlocks(::ReorderBasicBlocks);
523 OutFlags.setShouldDoNopInsertion(::ShouldDoNopInsertion); 566 OutFlags.setShouldDoNopInsertion(::ShouldDoNopInsertion);
524 OutFlags.setShouldRandomizeRegAlloc(::RandomizeRegisterAllocation); 567 OutFlags.setShouldRandomizeRegAlloc(::RandomizeRegisterAllocation);
525 OutFlags.setShouldRepeatRegAlloc(::RepeatRegAlloc); 568 OutFlags.setShouldRepeatRegAlloc(::RepeatRegAlloc);
526 OutFlags.setShouldReorderFunctions(::ReorderFunctions); 569 OutFlags.setShouldReorderFunctions(::ReorderFunctions);
527 OutFlags.setShouldReorderGlobalVariables(::ReorderGlobalVariables); 570 OutFlags.setShouldReorderGlobalVariables(::ReorderGlobalVariables);
528 OutFlags.setShouldReorderPooledConstants(::ReorderPooledConstants); 571 OutFlags.setShouldReorderPooledConstants(::ReorderPooledConstants);
529 OutFlags.setSkipUnimplemented(::SkipUnimplemented); 572 OutFlags.setSkipUnimplemented(::SkipUnimplemented);
530 OutFlags.setSubzeroTimingEnabled(::SubzeroTimingEnabled); 573 OutFlags.setSubzeroTimingEnabled(::SubzeroTimingEnabled);
531 OutFlags.setTargetArch(::TargetArch); 574 OutFlags.setTargetArch(::TargetArch);
532 OutFlags.setTargetInstructionSet(::TargetInstructionSet); 575 OutFlags.setTargetInstructionSet(::TargetInstructionSet);
533 OutFlags.setTestPrefix(::TestPrefix); 576 OutFlags.setTestPrefix(::TestPrefix);
534 OutFlags.setTestStackExtra(::TestStackExtra); 577 OutFlags.setTestStackExtra(::TestStackExtra);
535 OutFlags.setTimeEachFunction(::TimeEachFunction); 578 OutFlags.setTimeEachFunction(::TimeEachFunction);
536 OutFlags.setTimingFocusOn(::TimingFocusOn); 579 OutFlags.setTimingFocusOn(::TimingFocusOn);
537 OutFlags.setTranslateOnly(::TranslateOnly); 580 OutFlags.setTranslateOnly(::TranslateOnly);
538 OutFlags.setUseNonsfi(::UseNonsfi); 581 OutFlags.setUseNonsfi(::UseNonsfi);
582 extractCommaSeparated(::UseRestrictedRegisters, RegNames);
583 for (const auto &Name : RegNames)
584 OutFlags.insertUseRestrictedRegister(Name);
539 OutFlags.setUseSandboxing(::UseSandboxing); 585 OutFlags.setUseSandboxing(::UseSandboxing);
540 OutFlags.setVerboseFocusOn(::VerboseFocusOn); 586 OutFlags.setVerboseFocusOn(::VerboseFocusOn);
541 OutFlags.setOutFileType(::OutFileType); 587 OutFlags.setOutFileType(::OutFileType);
542 OutFlags.setMaxNopsPerInstruction(::MaxNopsPerInstruction); 588 OutFlags.setMaxNopsPerInstruction(::MaxNopsPerInstruction);
543 OutFlags.setNopProbabilityAsPercentage(::NopProbabilityAsPercentage); 589 OutFlags.setNopProbabilityAsPercentage(::NopProbabilityAsPercentage);
544 OutFlags.setVerbose(VMask); 590 OutFlags.setVerbose(VMask);
545 } 591 }
546 592
547 void ClFlags::getParsedClFlagsExtra(ClFlagsExtra &OutFlagsExtra) { 593 void ClFlags::getParsedClFlagsExtra(ClFlagsExtra &OutFlagsExtra) {
548 OutFlagsExtra.setAlwaysExitSuccess(AlwaysExitSuccess); 594 OutFlagsExtra.setAlwaysExitSuccess(AlwaysExitSuccess);
549 OutFlagsExtra.setBitcodeAsText(BitcodeAsText); 595 OutFlagsExtra.setBitcodeAsText(BitcodeAsText);
550 OutFlagsExtra.setBuildOnRead(BuildOnRead); 596 OutFlagsExtra.setBuildOnRead(BuildOnRead);
551 OutFlagsExtra.setGenerateBuildAtts(GenerateBuildAtts); 597 OutFlagsExtra.setGenerateBuildAtts(GenerateBuildAtts);
552 OutFlagsExtra.setLLVMVerboseErrors(LLVMVerboseErrors); 598 OutFlagsExtra.setLLVMVerboseErrors(LLVMVerboseErrors);
553 OutFlagsExtra.setAppName(AppName); 599 OutFlagsExtra.setAppName(AppName);
554 OutFlagsExtra.setInputFileFormat(InputFileFormat); 600 OutFlagsExtra.setInputFileFormat(InputFileFormat);
555 OutFlagsExtra.setIRFilename(IRFilename); 601 OutFlagsExtra.setIRFilename(IRFilename);
556 OutFlagsExtra.setLogFilename(LogFilename); 602 OutFlagsExtra.setLogFilename(LogFilename);
557 OutFlagsExtra.setOutputFilename(OutputFilename); 603 OutFlagsExtra.setOutputFilename(OutputFilename);
558 } 604 }
559 605
560 } // end of namespace Ice 606 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698