45 for (
unsigned i = 0; i < NumStrings; ++i)
46 RecipMap.insert(std::make_pair(
RecipOps[i], RecipParams()));
51 const char RefStepToken =
':';
52 Position = In.
find(RefStepToken);
59 if (RefStepString.
size() == 1) {
60 char RefStepChar = RefStepString[0];
61 if (RefStepChar >=
'0' && RefStepChar <=
'9') {
62 Value = RefStepChar -
'0';
69 bool TargetRecip::parseGlobalParams(
const std::string &Arg) {
79 RefStepString = ArgSub.
substr(RefPos + 1);
80 ArgSub = ArgSub.
substr(0, RefPos);
84 if (ArgSub ==
"all") {
87 }
else if (ArgSub ==
"none") {
90 }
else if (ArgSub ==
"default") {
100 for (
auto &KV : RecipMap)
101 KV.second.Enabled = Enable;
104 if (!RefStepString.
empty())
105 for (
auto &KV : RecipMap)
106 KV.second.RefinementSteps = RefSteps;
111 void TargetRecip::parseIndividualParams(
const std::vector<std::string> &Args) {
112 static const char DisabledPrefix =
'!';
113 unsigned NumArgs = Args.size();
115 for (
unsigned i = 0; i != NumArgs; ++i) {
118 bool IsDisabled = Val[0] == DisabledPrefix;
128 RefStepString = Val.
substr(RefPos + 1);
129 Val = Val.
substr(0, RefPos);
132 RecipIter Iter = RecipMap.find(Val);
133 if (Iter == RecipMap.end()) {
135 Iter = RecipMap.find(Val.
str() +
'f');
136 if (Iter == RecipMap.end()) {
137 Iter = RecipMap.find(Val.
str() +
'd');
138 assert(Iter == RecipMap.end() &&
"Float entry missing from map");
143 if (RecipMap[Val.
str() +
'd'].Enabled != Uninitialized) {
150 if (Iter->second.Enabled != Uninitialized)
154 Iter->second.Enabled = !IsDisabled;
155 if (!RefStepString.
empty())
156 Iter->second.RefinementSteps = RefSteps;
160 RecipMap[Val.
str() +
'd'].Enabled = !IsDisabled;
161 if (!RefStepString.
empty())
162 RecipMap[Val.
str() +
'd'].RefinementSteps = RefSteps;
169 unsigned NumArgs = Args.size();
172 if (NumArgs == 1 && parseGlobalParams(Args[0]))
175 parseIndividualParams(Args);
179 ConstRecipIter Iter = RecipMap.find(Key);
180 assert(Iter != RecipMap.end() &&
"Unknown name for reciprocal map");
181 assert(Iter->second.Enabled != Uninitialized &&
182 "Enablement setting was not initialized");
183 return Iter->second.Enabled;
187 ConstRecipIter Iter = RecipMap.find(Key);
188 assert(Iter != RecipMap.end() &&
"Unknown name for reciprocal map");
189 assert(Iter->second.RefinementSteps != Uninitialized &&
190 "Refinement step setting was not initialized");
191 return Iter->second.RefinementSteps;
198 for (
auto &KV : RecipMap) {
199 RecipParams &
RP = KV.second;
200 if (RP.Enabled == Uninitialized)
202 if (RP.RefinementSteps == Uninitialized)
203 RP.RefinementSteps = RefSteps;
206 RecipParams &
RP = RecipMap[Key];
207 if (RP.Enabled == Uninitialized)
209 if (RP.RefinementSteps == Uninitialized)
210 RP.RefinementSteps = RefSteps;
215 for (
const auto &KV : RecipMap) {
217 const RecipParams &
RP = KV.second;
218 const RecipParams &OtherRP = Other.RecipMap.find(Op)->second;
219 if (RP.RefinementSteps != OtherRP.RefinementSteps)
221 if (RP.Enabled != OtherRP.Enabled)
size_t size() const
size - Get the string size.
size_t find(char C, size_t From=0) const
Search for the first character C in the string.
StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
std::string str() const
str - Get the contents as an std::string.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const char *reason, bool gen_crash_diag=true)
Reports a serious error, calling any installed error handler.
bool operator==(const TargetRecip &Other) const
LLVM_CONSTEXPR size_t array_lengthof(T(&)[N])
Find the length of an array.
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
char back() const
back - Get the last character in the string.
bool isEnabled(const StringRef &Key) const
Return true if the reciprocal operation has been enabled by default or from the command-line.
static const char * RecipOps[]
LLVM Value Representation.
StringRef - Represent a constant reference to a string, i.e.
unsigned getRefinementSteps(const StringRef &Key) const
Return the number of iterations necessary to refine the the result of a machine instruction for the g...
static bool parseRefinementStep(const StringRef &In, size_t &Position, uint8_t &Value)
void setDefaults(const StringRef &Key, bool Enable, unsigned RefSteps)
Set whether a particular reciprocal operation is enabled and how many refinement steps are needed whe...
bool empty() const
empty - Check if the string is empty.