llvm.org GIT mirror llvm / 93681fa
Prevent repetitive warnings for unrecognized processors and features git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199886 91177308-0d34-0410-b5e6-96231b3b80d8 Artyom Skrobov 6 years ago
4 changed file(s) with 59 addition(s) and 27 deletion(s). Raw diff Collapse all Expand all
100100
101101 /// Adds the default features for the specified target triple.
102102 void getDefaultSubtargetFeatures(const Triple& Triple);
103
104 /// Find KV in array using binary search.
105 /// T should be either SubtargetFeatureKV or SubtargetInfoKV
106 template
107 static const T *Find(StringRef Key, const T *Array, size_t Length,
108 const char* KeyType);
103109 };
104110
105111 } // End namespace llvm
9595 #endif
9696
9797 // Find entry
98 const SubtargetInfoKV *Found =
99 std::lower_bound(ProcSchedModels, ProcSchedModels+NumProcs, CPU);
100 if (Found == ProcSchedModels+NumProcs || StringRef(Found->Key) != CPU) {
101 errs() << "'" << CPU
102 << "' is not a recognized processor for this target"
103 << " (ignoring processor)\n";
98 const SubtargetInfoKV *Found = SubtargetFeatures::Find(CPU, ProcSchedModels,
99 NumProcs, "processor");
100 if (!Found)
104101 return &MCSchedModel::DefaultSchedModel;
105 }
102
106103 assert(Found->Value && "Missing processor SchedModel value");
107104 return (const MCSchedModel *)Found->Value;
108105 }
1010 //
1111 //===----------------------------------------------------------------------===//
1212
13 #include "llvm/ADT/SmallSet.h"
1314 #include "llvm/MC/SubtargetFeature.h"
1415 #include "llvm/Support/Debug.h"
1516 #include "llvm/Support/Format.h"
17 #include "llvm/Support/SourceMgr.h"
1618 #include "llvm/Support/raw_ostream.h"
1719 #include
1820 #include
117119 }
118120 }
119121
122 // This needs to be shared between the instantiations of Find<>
123 typedef std::pair KeyWithType;
124 static SmallSet reportedAsUnrecognized;
125
120126 /// Find KV in array using binary search.
121 static const SubtargetFeatureKV *Find(StringRef S, const SubtargetFeatureKV *A,
122 size_t L) {
127 template
128 const T *SubtargetFeatures::Find(StringRef Key, const T *Array, size_t Length,
129 const char* KeyType) {
123130 // Determine the end of the array
124 const SubtargetFeatureKV *Hi = A + L;
131 const T *Hi = Array + Length;
125132 // Binary search the array
126 const SubtargetFeatureKV *F = std::lower_bound(A, Hi, S);
133 const T *F = std::lower_bound(Array, Hi, Key);
127134 // If not found then return NULL
128 if (F == Hi || StringRef(F->Key) != S) return NULL;
135 if (F == Hi || StringRef(F->Key) != Key) {
136 // If not yet reported, report now
137 KeyWithType current(KeyType, Key);
138 if(!reportedAsUnrecognized.count(current)) {
139 SmallString<1024> storage;
140 StringRef message = ("'" + Key +
141 "' is not a recognized " + KeyType +
142 " for this target (ignoring " + KeyType +
143 ")").toStringRef(storage);
144 SMDiagnostic(StringRef(), SourceMgr::DK_Warning, message)
145 .print(0, errs());
146 reportedAsUnrecognized.insert(current);
147 }
148 return NULL;
149 }
129150 // Return the found array item
130151 return F;
131152 }
153
154 // Instantiate with for use in MCSubtargetInfo
155 template const SubtargetInfoKV *SubtargetFeatures::Find
156 (StringRef Key, const SubtargetInfoKV *Array, size_t Length, const char* KeyType);
132157
133158 /// getLongestEntryLength - Return the length of the longest entry in the table.
134159 ///
227252 size_t FeatureTableSize) {
228253 // Find feature in table.
229254 const SubtargetFeatureKV *FeatureEntry =
230 Find(StripFlag(Feature), FeatureTable, FeatureTableSize);
255 Find(StripFlag(Feature), FeatureTable, FeatureTableSize, "feature");
231256 // If there is a match
232257 if (FeatureEntry) {
233258 if ((Bits & FeatureEntry->Value) == FeatureEntry->Value) {
241266 // For each feature that this implies, set it.
242267 SetImpliedBits(Bits, FeatureEntry, FeatureTable, FeatureTableSize);
243268 }
244 } else {
245 errs() << "'" << Feature
246 << "' is not a recognized feature for this target"
247 << " (ignoring feature)\n";
248269 }
249270
250271 return Bits;
279300
280301 // Find CPU entry if CPU name is specified.
281302 if (!CPU.empty()) {
282 const SubtargetFeatureKV *CPUEntry = Find(CPU, CPUTable, CPUTableSize);
303 const SubtargetFeatureKV *CPUEntry = Find(CPU, CPUTable, CPUTableSize,
304 "processor");
283305 // If there is a match
284306 if (CPUEntry) {
285307 // Set base feature bits
291313 if (CPUEntry->Value & FE.Value)
292314 SetImpliedBits(Bits, &FE, FeatureTable, FeatureTableSize);
293315 }
294 } else {
295 errs() << "'" << CPU
296 << "' is not a recognized processor for this target"
297 << " (ignoring processor)\n";
298316 }
299317 }
300318
308326
309327 // Find feature in table.
310328 const SubtargetFeatureKV *FeatureEntry =
311 Find(StripFlag(Feature), FeatureTable, FeatureTableSize);
329 Find(StripFlag(Feature), FeatureTable, FeatureTableSize, "feature");
312330 // If there is a match
313331 if (FeatureEntry) {
314332 // Enable/disable feature in bits
323341 // For each feature that implies this, clear it.
324342 ClearImpliedBits(Bits, FeatureEntry, FeatureTable, FeatureTableSize);
325343 }
326 } else {
327 errs() << "'" << Feature
328 << "' is not a recognized feature for this target"
329 << " (ignoring feature)\n";
330344 }
331345 }
332346
0 ; RUN: llc -mcpu=invalid -o /dev/null %s 2>&1 | FileCheck %s --check-prefix=CPU
1 ; CPU: 'invalid' is not a recognized processor for this target (ignoring processor)
2 ; CPU-NOT: 'invalid' is not a recognized processor for this target (ignoring processor)
3
4 ; RUN: llc -mattr=+foo,+bar -o /dev/null %s 2>&1 | FileCheck %s --check-prefix=FEATURE
5 ; FEATURE: 'foo' is not a recognized feature for this target (ignoring feature)
6 ; FEATURE-NEXT: 'bar' is not a recognized feature for this target (ignoring feature)
7 ; FEATURE-NOT: 'foo' is not a recognized feature for this target (ignoring feature)
8 ; FEATURE-NOT: 'bar' is not a recognized feature for this target (ignoring feature)
9
10 define void @foo() {
11 entry:
12 ret void
13 }
14