llvm.org GIT mirror llvm / 8bc601f
[Subtarget] Create a separate SubtargetSubtargetKV struct for ProcDesc to remove fields from the stack tables that aren't needed for CPUs The description for CPUs was just the CPU name wrapped with "Select the " and " processor". We can just do that directly in the help printer instead of making a separate version in the binary for each CPU. Also remove the Value field that isn't needed and was always 0. Differential Revision: https://reviews.llvm.org/D58938 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355429 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 7 months ago
5 changed file(s) with 37 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
4141 class SDep;
4242 class SelectionDAGTargetInfo;
4343 struct SubtargetFeatureKV;
44 struct SubtargetSubTypeKV;
4445 struct SubtargetInfoKV;
4546 class SUnit;
4647 class TargetFrameLowering;
6162 protected: // Can only create subclasses...
6263 TargetSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS,
6364 ArrayRef PF,
64 ArrayRefFeatureKV> PD,
65 ArrayRefSubTypeKV> PD,
6566 const SubtargetInfoKV *ProcSched,
6667 const MCWriteProcResEntry *WPR,
6768 const MCWriteLatencyEntry *WL,
4949
5050 //===----------------------------------------------------------------------===//
5151
52 /// Used to provide key value pairs for feature and CPU bit flags.
53 struct SubtargetSubTypeKV {
54 const char *Key; ///< K-V key string
55 FeatureBitArray Implies; ///< K-V bit mask
56
57 /// Compare routine for std::lower_bound
58 bool operator<(StringRef S) const {
59 return StringRef(Key) < S;
60 }
61
62 /// Compare routine for std::is_sorted.
63 bool operator<(const SubtargetSubTypeKV &Other) const {
64 return StringRef(Key) < StringRef(Other.Key);
65 }
66 };
67
68 //===----------------------------------------------------------------------===//
69
5270 /// Used to provide key value pairs for CPU and arbitrary pointers.
5371 struct SubtargetInfoKV {
5472 const char *Key; ///< K-V key string
7391 Triple TargetTriple;
7492 std::string CPU; // CPU being targeted.
7593 ArrayRef ProcFeatures; // Processor feature list
76 ArrayRefFeatureKV> ProcDesc; // Processor descriptions
94 ArrayRefSubTypeKV> ProcDesc; // Processor descriptions
7795
7896 // Scheduler machine model
7997 const SubtargetInfoKV *ProcSchedModels;
91109 MCSubtargetInfo(const MCSubtargetInfo &) = default;
92110 MCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS,
93111 ArrayRef PF,
94 ArrayRefFeatureKV> PD,
112 ArrayRefSubTypeKV> PD,
95113 const SubtargetInfoKV *ProcSched,
96114 const MCWriteProcResEntry *WPR, const MCWriteLatencyEntry *WL,
97115 const MCReadAdvanceEntry *RA, const InstrStage *IS,
1515
1616 TargetSubtargetInfo::TargetSubtargetInfo(
1717 const Triple &TT, StringRef CPU, StringRef FS,
18 ArrayRef PF, ArrayRefFeatureKV> PD,
18 ArrayRef PF, ArrayRefSubTypeKV> PD,
1919 const SubtargetInfoKV *ProcSched, const MCWriteProcResEntry *WPR,
2020 const MCWriteLatencyEntry *WL, const MCReadAdvanceEntry *RA,
2121 const InstrStage *IS, const unsigned *OC, const unsigned *FP)
2020 using namespace llvm;
2121
2222 /// Find KV in array using binary search.
23 static const SubtargetFeatureKV *Find(StringRef S,
24 ArrayRef A) {
23 template
24 static const T *Find(StringRef S, ArrayRef A) {
2525 // Binary search the array
2626 auto F = std::lower_bound(A.begin(), A.end(), S);
2727 // If not found then return NULL
8383 }
8484
8585 /// Return the length of the longest entry in the table.
86 static size_t getLongestEntryLength(ArrayRef Table) {
86 template
87 static size_t getLongestEntryLength(ArrayRef Table) {
8788 size_t MaxLen = 0;
8889 for (auto &I : Table)
8990 MaxLen = std::max(MaxLen, std::strlen(I.Key));
9192 }
9293
9394 /// Display help for feature choices.
94 static void Help(ArrayRefFeatureKV> CPUTable,
95 static void Help(ArrayRefSubTypeKV> CPUTable,
9596 ArrayRef FeatTable) {
9697 // Determine the length of the longest CPU and Feature entries.
9798 unsigned MaxCPULen = getLongestEntryLength(CPUTable);
100101 // Print the CPU table.
101102 errs() << "Available CPUs for this target:\n\n";
102103 for (auto &CPU : CPUTable)
103 errs() << format(" %-*s - %s.\n", MaxCPULen, CPU.Key, CPU.Desc);
104 errs() << format(" %-*s - Select the %s processor.\n", MaxCPULen, CPU.Key,
105 CPU.Key);
104106 errs() << '\n';
105107
106108 // Print the Feature table.
114116 }
115117
116118 static FeatureBitset getFeatures(StringRef CPU, StringRef FS,
117 ArrayRefFeatureKV> ProcDesc,
119 ArrayRefSubTypeKV> ProcDesc,
118120 ArrayRef ProcFeatures) {
119121 SubtargetFeatures Features(FS);
120122
134136
135137 // Find CPU entry if CPU name is specified.
136138 else if (!CPU.empty()) {
137 const SubtargetFeatureKV *CPUEntry = Find(CPU, ProcDesc);
139 const SubtargetSubTypeKV *CPUEntry = Find(CPU, ProcDesc);
138140
139141 // If there is a match
140142 if (CPUEntry) {
172174
173175 MCSubtargetInfo::MCSubtargetInfo(
174176 const Triple &TT, StringRef C, StringRef FS,
175 ArrayRef PF, ArrayRefFeatureKV> PD,
177 ArrayRef PF, ArrayRefSubTypeKV> PD,
176178 const SubtargetInfoKV *ProcSched, const MCWriteProcResEntry *WPR,
177179 const MCWriteLatencyEntry *WL, const MCReadAdvanceEntry *RA,
178180 const InstrStage *IS, const unsigned *OC, const unsigned *FP)
256256
257257 // Begin processor table
258258 OS << "// Sorted (by key) array of values for CPU subtype.\n"
259 << "extern const llvm::SubtargetFeatureKV " << Target
259 << "extern const llvm::SubtargetSubTypeKV " << Target
260260 << "SubTypeKV[] = {\n";
261261
262262 // For each processor
265265 RecVec FeatureList = Processor->getValueAsListOfDefs("Features");
266266
267267 // Emit as { "cpu", "description", 0, { f1 , f2 , ... fn } },
268 // The 0 is for the feature id which isn't used for CPUs.
269268 OS << " { "
270 << "\"" << Name << "\", "
271 << "\"Select the " << Name << " processor\", 0, ";
269 << "\"" << Name << "\", ";
272270
273271 printFeatureMask(OS, FeatureList, FeatureMap);
274272
17591757 << "GenMCSubtargetInfo : public MCSubtargetInfo {\n";
17601758 OS << " " << Target << "GenMCSubtargetInfo(const Triple &TT, \n"
17611759 << " StringRef CPU, StringRef FS, ArrayRef PF,\n"
1762 << " ArrayRefFeatureKV> PD,\n"
1760 << " ArrayRefSubTypeKV> PD,\n"
17631761 << " const SubtargetInfoKV *ProcSched,\n"
17641762 << " const MCWriteProcResEntry *WPR,\n"
17651763 << " const MCWriteLatencyEntry *WL,\n"
19161914 OS << "#include \"llvm/CodeGen/TargetSchedule.h\"\n\n";
19171915 OS << "namespace llvm {\n";
19181916 OS << "extern const llvm::SubtargetFeatureKV " << Target << "FeatureKV[];\n";
1919 OS << "extern const llvm::SubtargetFeatureKV " << Target << "SubTypeKV[];\n";
1917 OS << "extern const llvm::SubtargetSubTypeKV " << Target << "SubTypeKV[];\n";
19201918 OS << "extern const llvm::SubtargetInfoKV " << Target << "ProcSchedKV[];\n";
19211919 OS << "extern const llvm::MCWriteProcResEntry "
19221920 << Target << "WriteProcResTable[];\n";