|
14 | 14 | #include "Common/CodeGenSchedule.h"
|
15 | 15 | #include "Common/CodeGenTarget.h"
|
16 | 16 | #include "Common/PredicateExpander.h"
|
| 17 | +#include "llvm/ADT/DenseMap.h" |
17 | 18 | #include "llvm/ADT/STLExtras.h"
|
18 | 19 | #include "llvm/ADT/SmallPtrSet.h"
|
19 | 20 | #include "llvm/ADT/StringExtras.h"
|
| 21 | +#include "llvm/ADT/StringMap.h" |
20 | 22 | #include "llvm/ADT/StringRef.h"
|
21 | 23 | #include "llvm/MC/MCInstrItineraries.h"
|
22 | 24 | #include "llvm/MC/MCSchedule.h"
|
|
31 | 33 | #include <cassert>
|
32 | 34 | #include <cstdint>
|
33 | 35 | #include <iterator>
|
34 |
| -#include <map> |
35 |
| -#include <set> |
36 | 36 | #include <string>
|
37 | 37 | #include <vector>
|
38 | 38 |
|
@@ -259,8 +259,8 @@ unsigned SubtargetEmitter::FeatureKeyValues(
|
259 | 259 |
|
260 | 260 | llvm::sort(FeatureList, LessRecordFieldName());
|
261 | 261 |
|
262 |
| - // Check that there are no duplicate keys |
263 |
| - std::set<StringRef> UniqueKeys; |
| 262 | + // Check that there are no duplicate features. |
| 263 | + DenseMap<StringRef, const Record *> UniqueFeatures; |
264 | 264 |
|
265 | 265 | // Begin feature table
|
266 | 266 | OS << "// Sorted (by key) array of values for CPU features.\n"
|
@@ -291,9 +291,12 @@ unsigned SubtargetEmitter::FeatureKeyValues(
|
291 | 291 | OS << " },\n";
|
292 | 292 | ++NumFeatures;
|
293 | 293 |
|
294 |
| - if (!UniqueKeys.insert(CommandLineName).second) |
295 |
| - PrintFatalError("Duplicate key in SubtargetFeatureKV: " + |
296 |
| - CommandLineName); |
| 294 | + auto [It, Inserted] = UniqueFeatures.insert({CommandLineName, Feature}); |
| 295 | + if (!Inserted) { |
| 296 | + PrintError(Feature, "Feature `" + CommandLineName + "` already defined."); |
| 297 | + const Record *Previous = It->second; |
| 298 | + PrintFatalNote(Previous, "Previous definition here."); |
| 299 | + } |
297 | 300 | }
|
298 | 301 |
|
299 | 302 | // End feature table
|
@@ -494,7 +497,7 @@ void SubtargetEmitter::EmitStageAndOperandCycleData(
|
494 | 497 | // operand cycles, and pipeline bypass tables. Then add the new Itinerary
|
495 | 498 | // object with computed offsets to the ProcItinLists result.
|
496 | 499 | unsigned StageCount = 1, OperandCycleCount = 1;
|
497 |
| - std::map<std::string, unsigned> ItinStageMap, ItinOperandMap; |
| 500 | + StringMap<unsigned> ItinStageMap, ItinOperandMap; |
498 | 501 | for (const CodeGenProcModel &ProcModel : SchedModels.procModels()) {
|
499 | 502 | // Add process itinerary to the list.
|
500 | 503 | std::vector<InstrItinerary> &ItinList = ProcItinLists.emplace_back();
|
|
0 commit comments