llvm.org GIT mirror llvm / 85ae034
Reverting r199886 (Prevent repetitive warnings for unrecognized processors and features) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200083 91177308-0d34-0410-b5e6-96231b3b80d8 Artyom Skrobov 6 years ago
4 changed file(s) with 27 addition(s) and 59 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);
109103 };
110104
111105 } // End namespace llvm
9595 #endif
9696
9797 // Find entry
98 const SubtargetInfoKV *Found = SubtargetFeatures::Find(CPU, ProcSchedModels,
99 NumProcs, "processor");
100 if (!Found)
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";
101104 return &MCSchedModel::DefaultSchedModel;
102
105 }
103106 assert(Found->Value && "Missing processor SchedModel value");
104107 return (const MCSchedModel *)Found->Value;
105108 }
1010 //
1111 //===----------------------------------------------------------------------===//
1212
13 #include "llvm/ADT/SmallSet.h"
1413 #include "llvm/MC/SubtargetFeature.h"
1514 #include "llvm/Support/Debug.h"
1615 #include "llvm/Support/Format.h"
17 #include "llvm/Support/SourceMgr.h"
1816 #include "llvm/Support/raw_ostream.h"
1917 #include
2018 #include
119117 }
120118 }
121119
122 // This needs to be shared between the instantiations of Find<>
123 typedef std::pair KeyWithType;
124 static SmallSet reportedAsUnrecognized;
125
126120 /// Find KV in array using binary search.
127 template
128 const T *SubtargetFeatures::Find(StringRef Key, const T *Array, size_t Length,
129 const char* KeyType) {
121 static const SubtargetFeatureKV *Find(StringRef S, const SubtargetFeatureKV *A,
122 size_t L) {
130123 // Determine the end of the array
131 const T *Hi = Array + Length;
124 const SubtargetFeatureKV *Hi = A + L;
132125 // Binary search the array
133 const T *F = std::lower_bound(Array, Hi, Key);
126 const SubtargetFeatureKV *F = std::lower_bound(A, Hi, S);
134127 // If not found then 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 }
128 if (F == Hi || StringRef(F->Key) != S) return NULL;
150129 // Return the found array item
151130 return F;
152131 }
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);
157132
158133 /// getLongestEntryLength - Return the length of the longest entry in the table.
159134 ///
252227 size_t FeatureTableSize) {
253228 // Find feature in table.
254229 const SubtargetFeatureKV *FeatureEntry =
255 Find(StripFlag(Feature), FeatureTable, FeatureTableSize, "feature");
230 Find(StripFlag(Feature), FeatureTable, FeatureTableSize);
256231 // If there is a match
257232 if (FeatureEntry) {
258233 if ((Bits & FeatureEntry->Value) == FeatureEntry->Value) {
266241 // For each feature that this implies, set it.
267242 SetImpliedBits(Bits, FeatureEntry, FeatureTable, FeatureTableSize);
268243 }
244 } else {
245 errs() << "'" << Feature
246 << "' is not a recognized feature for this target"
247 << " (ignoring feature)\n";
269248 }
270249
271250 return Bits;
300279
301280 // Find CPU entry if CPU name is specified.
302281 if (!CPU.empty()) {
303 const SubtargetFeatureKV *CPUEntry = Find(CPU, CPUTable, CPUTableSize,
304 "processor");
282 const SubtargetFeatureKV *CPUEntry = Find(CPU, CPUTable, CPUTableSize);
305283 // If there is a match
306284 if (CPUEntry) {
307285 // Set base feature bits
313291 if (CPUEntry->Value & FE.Value)
314292 SetImpliedBits(Bits, &FE, FeatureTable, FeatureTableSize);
315293 }
294 } else {
295 errs() << "'" << CPU
296 << "' is not a recognized processor for this target"
297 << " (ignoring processor)\n";
316298 }
317299 }
318300
326308
327309 // Find feature in table.
328310 const SubtargetFeatureKV *FeatureEntry =
329 Find(StripFlag(Feature), FeatureTable, FeatureTableSize, "feature");
311 Find(StripFlag(Feature), FeatureTable, FeatureTableSize);
330312 // If there is a match
331313 if (FeatureEntry) {
332314 // Enable/disable feature in bits
341323 // For each feature that implies this, clear it.
342324 ClearImpliedBits(Bits, FeatureEntry, FeatureTable, FeatureTableSize);
343325 }
326 } else {
327 errs() << "'" << Feature
328 << "' is not a recognized feature for this target"
329 << " (ignoring feature)\n";
344330 }
345331 }
346332
+0
-15
test/MC/ARM/unrecognized.ll less more
None ; 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