Index: src/IceClFlags.cpp |
diff --git a/src/IceClFlags.cpp b/src/IceClFlags.cpp |
index ed5a71df47ddf0ec3ed8886d5e20a5c4e330d256..aad30b6e4ae1483ecc1b72d77b84aec5e03aa734 100644 |
--- a/src/IceClFlags.cpp |
+++ b/src/IceClFlags.cpp |
@@ -287,6 +287,17 @@ cl::opt<int> NopProbabilityAsPercentage( |
"nop-insertion-percentage", |
cl::desc("Nop insertion probability as percentage"), cl::init(10)); |
+/// Restricts registers in corresponding register classes to specified list. |
+cl::list<std::string> UseRestrictedRegisters( |
+ "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.
|
+ cl::desc( |
+ "Only use specified registers for corresponding register classes")); |
+ |
+/// List of excluded registers. |
+cl::list<std::string> |
+ 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'.
|
+ cl::desc("Don't use specified registers")); |
+ |
/// Verbose options (can be comma-separated). |
cl::list<Ice::VerboseItem> VerboseList( |
"verbose", cl::CommaSeparated, |
@@ -421,6 +432,31 @@ cl::opt<bool> BitcodeAsText( |
cl::desc( |
"Accept textual form of PNaCl bitcode records (i.e. not .ll assembly)"), |
cl::init(false)); |
+ |
+void splitOnChars(const std::string &Text, const char *Chars, |
+ std::vector<std::string> &Tokens) { |
+ size_t Start = 0; |
+ bool KeepSplitting = true; |
+ while (KeepSplitting) { |
+ size_t End = Text.find_first_of(Chars, Start); |
+ if (End == std::string::npos) { |
+ KeepSplitting = false; |
+ End = Text.size(); |
+ } |
+ std::string RegName = Text.substr(Start, End - Start); |
+ Tokens.push_back(RegName); |
+ Start = End + 1; |
+ } |
+} |
+ |
+void extractCommaSeparated(cl::list<std::string> &NameList, |
+ std::vector<std::string> &Names) { |
+ Names.clear(); |
+ for (const std::string &Name : NameList) { |
+ splitOnChars(Name, ",", Names); |
+ } |
+} |
+ |
} // end of anonymous namespace |
namespace Ice { |
@@ -481,6 +517,9 @@ void ClFlags::resetClFlags(ClFlags &OutFlags) { |
// size_t and 64-bit fields. |
OutFlags.NumTranslationThreads = 0; |
OutFlags.RandomSeed = 0; |
+ // Sets. |
+ OutFlags.clearExcludedRegisters(); |
+ OutFlags.clearUseRestrictedRegisters(); |
} |
void ClFlags::getParsedClFlags(ClFlags &OutFlags) { |
@@ -507,6 +546,10 @@ void ClFlags::getParsedClFlags(ClFlags &OutFlags) { |
OutFlags.setDisableTranslation(::DisableTranslation); |
OutFlags.setDumpStats(::DumpStats); |
OutFlags.setEnableBlockProfile(::EnableBlockProfile); |
+ std::vector<std::string> RegNames; |
+ extractCommaSeparated(::ExcludedRegisters, RegNames); |
+ for (const auto &Name : RegNames) |
+ OutFlags.insertExcludedRegister(Name); |
OutFlags.setForceMemIntrinOpt(::ForceMemIntrinOpt); |
OutFlags.setFunctionSections(::FunctionSections); |
OutFlags.setNumTranslationThreads(::NumThreads); |
@@ -536,6 +579,9 @@ void ClFlags::getParsedClFlags(ClFlags &OutFlags) { |
OutFlags.setTimingFocusOn(::TimingFocusOn); |
OutFlags.setTranslateOnly(::TranslateOnly); |
OutFlags.setUseNonsfi(::UseNonsfi); |
+ extractCommaSeparated(::UseRestrictedRegisters, RegNames); |
+ for (const auto &Name : RegNames) |
+ OutFlags.insertUseRestrictedRegister(Name); |
OutFlags.setUseSandboxing(::UseSandboxing); |
OutFlags.setVerboseFocusOn(::VerboseFocusOn); |
OutFlags.setOutFileType(::OutFileType); |