[llvm] r355429 - [Subtarget] Create a separate SubtargetSubtargetKV struct for ProcDesc to remove fields from the stack tables that aren't needed for CPUs
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 5 10:54:34 PST 2019
Author: ctopper
Date: Tue Mar 5 10:54:34 2019
New Revision: 355429
URL: http://llvm.org/viewvc/llvm-project?rev=355429&view=rev
Log:
[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
Modified:
llvm/trunk/include/llvm/CodeGen/TargetSubtargetInfo.h
llvm/trunk/include/llvm/MC/MCSubtargetInfo.h
llvm/trunk/lib/CodeGen/TargetSubtargetInfo.cpp
llvm/trunk/lib/MC/MCSubtargetInfo.cpp
llvm/trunk/utils/TableGen/SubtargetEmitter.cpp
Modified: llvm/trunk/include/llvm/CodeGen/TargetSubtargetInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/TargetSubtargetInfo.h?rev=355429&r1=355428&r2=355429&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/TargetSubtargetInfo.h (original)
+++ llvm/trunk/include/llvm/CodeGen/TargetSubtargetInfo.h Tue Mar 5 10:54:34 2019
@@ -42,6 +42,7 @@ class RegisterBankInfo;
class SDep;
class SelectionDAGTargetInfo;
struct SubtargetFeatureKV;
+struct SubtargetSubTypeKV;
struct SubtargetInfoKV;
class SUnit;
class TargetFrameLowering;
@@ -62,7 +63,7 @@ class TargetSubtargetInfo : public MCSub
protected: // Can only create subclasses...
TargetSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS,
ArrayRef<SubtargetFeatureKV> PF,
- ArrayRef<SubtargetFeatureKV> PD,
+ ArrayRef<SubtargetSubTypeKV> PD,
const SubtargetInfoKV *ProcSched,
const MCWriteProcResEntry *WPR,
const MCWriteLatencyEntry *WL,
Modified: llvm/trunk/include/llvm/MC/MCSubtargetInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCSubtargetInfo.h?rev=355429&r1=355428&r2=355429&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCSubtargetInfo.h (original)
+++ llvm/trunk/include/llvm/MC/MCSubtargetInfo.h Tue Mar 5 10:54:34 2019
@@ -50,6 +50,24 @@ struct SubtargetFeatureKV {
//===----------------------------------------------------------------------===//
+/// Used to provide key value pairs for feature and CPU bit flags.
+struct SubtargetSubTypeKV {
+ const char *Key; ///< K-V key string
+ FeatureBitArray Implies; ///< K-V bit mask
+
+ /// Compare routine for std::lower_bound
+ bool operator<(StringRef S) const {
+ return StringRef(Key) < S;
+ }
+
+ /// Compare routine for std::is_sorted.
+ bool operator<(const SubtargetSubTypeKV &Other) const {
+ return StringRef(Key) < StringRef(Other.Key);
+ }
+};
+
+//===----------------------------------------------------------------------===//
+
/// Used to provide key value pairs for CPU and arbitrary pointers.
struct SubtargetInfoKV {
const char *Key; ///< K-V key string
@@ -74,7 +92,7 @@ class MCSubtargetInfo {
Triple TargetTriple;
std::string CPU; // CPU being targeted.
ArrayRef<SubtargetFeatureKV> ProcFeatures; // Processor feature list
- ArrayRef<SubtargetFeatureKV> ProcDesc; // Processor descriptions
+ ArrayRef<SubtargetSubTypeKV> ProcDesc; // Processor descriptions
// Scheduler machine model
const SubtargetInfoKV *ProcSchedModels;
@@ -92,7 +110,7 @@ public:
MCSubtargetInfo(const MCSubtargetInfo &) = default;
MCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS,
ArrayRef<SubtargetFeatureKV> PF,
- ArrayRef<SubtargetFeatureKV> PD,
+ ArrayRef<SubtargetSubTypeKV> PD,
const SubtargetInfoKV *ProcSched,
const MCWriteProcResEntry *WPR, const MCWriteLatencyEntry *WL,
const MCReadAdvanceEntry *RA, const InstrStage *IS,
Modified: llvm/trunk/lib/CodeGen/TargetSubtargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetSubtargetInfo.cpp?rev=355429&r1=355428&r2=355429&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/TargetSubtargetInfo.cpp (original)
+++ llvm/trunk/lib/CodeGen/TargetSubtargetInfo.cpp Tue Mar 5 10:54:34 2019
@@ -16,7 +16,7 @@ using namespace llvm;
TargetSubtargetInfo::TargetSubtargetInfo(
const Triple &TT, StringRef CPU, StringRef FS,
- ArrayRef<SubtargetFeatureKV> PF, ArrayRef<SubtargetFeatureKV> PD,
+ ArrayRef<SubtargetFeatureKV> PF, ArrayRef<SubtargetSubTypeKV> PD,
const SubtargetInfoKV *ProcSched, const MCWriteProcResEntry *WPR,
const MCWriteLatencyEntry *WL, const MCReadAdvanceEntry *RA,
const InstrStage *IS, const unsigned *OC, const unsigned *FP)
Modified: llvm/trunk/lib/MC/MCSubtargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCSubtargetInfo.cpp?rev=355429&r1=355428&r2=355429&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCSubtargetInfo.cpp (original)
+++ llvm/trunk/lib/MC/MCSubtargetInfo.cpp Tue Mar 5 10:54:34 2019
@@ -21,8 +21,8 @@
using namespace llvm;
/// Find KV in array using binary search.
-static const SubtargetFeatureKV *Find(StringRef S,
- ArrayRef<SubtargetFeatureKV> A) {
+template <typename T>
+static const T *Find(StringRef S, ArrayRef<T> A) {
// Binary search the array
auto F = std::lower_bound(A.begin(), A.end(), S);
// If not found then return NULL
@@ -84,7 +84,8 @@ static void ApplyFeatureFlag(FeatureBits
}
/// Return the length of the longest entry in the table.
-static size_t getLongestEntryLength(ArrayRef<SubtargetFeatureKV> Table) {
+template <typename T>
+static size_t getLongestEntryLength(ArrayRef<T> Table) {
size_t MaxLen = 0;
for (auto &I : Table)
MaxLen = std::max(MaxLen, std::strlen(I.Key));
@@ -92,7 +93,7 @@ static size_t getLongestEntryLength(Arra
}
/// Display help for feature choices.
-static void Help(ArrayRef<SubtargetFeatureKV> CPUTable,
+static void Help(ArrayRef<SubtargetSubTypeKV> CPUTable,
ArrayRef<SubtargetFeatureKV> FeatTable) {
// Determine the length of the longest CPU and Feature entries.
unsigned MaxCPULen = getLongestEntryLength(CPUTable);
@@ -101,7 +102,8 @@ static void Help(ArrayRef<SubtargetFeatu
// Print the CPU table.
errs() << "Available CPUs for this target:\n\n";
for (auto &CPU : CPUTable)
- errs() << format(" %-*s - %s.\n", MaxCPULen, CPU.Key, CPU.Desc);
+ errs() << format(" %-*s - Select the %s processor.\n", MaxCPULen, CPU.Key,
+ CPU.Key);
errs() << '\n';
// Print the Feature table.
@@ -115,7 +117,7 @@ static void Help(ArrayRef<SubtargetFeatu
}
static FeatureBitset getFeatures(StringRef CPU, StringRef FS,
- ArrayRef<SubtargetFeatureKV> ProcDesc,
+ ArrayRef<SubtargetSubTypeKV> ProcDesc,
ArrayRef<SubtargetFeatureKV> ProcFeatures) {
SubtargetFeatures Features(FS);
@@ -135,7 +137,7 @@ static FeatureBitset getFeatures(StringR
// Find CPU entry if CPU name is specified.
else if (!CPU.empty()) {
- const SubtargetFeatureKV *CPUEntry = Find(CPU, ProcDesc);
+ const SubtargetSubTypeKV *CPUEntry = Find(CPU, ProcDesc);
// If there is a match
if (CPUEntry) {
@@ -173,7 +175,7 @@ void MCSubtargetInfo::setDefaultFeatures
MCSubtargetInfo::MCSubtargetInfo(
const Triple &TT, StringRef C, StringRef FS,
- ArrayRef<SubtargetFeatureKV> PF, ArrayRef<SubtargetFeatureKV> PD,
+ ArrayRef<SubtargetFeatureKV> PF, ArrayRef<SubtargetSubTypeKV> PD,
const SubtargetInfoKV *ProcSched, const MCWriteProcResEntry *WPR,
const MCWriteLatencyEntry *WL, const MCReadAdvanceEntry *RA,
const InstrStage *IS, const unsigned *OC, const unsigned *FP)
Modified: llvm/trunk/utils/TableGen/SubtargetEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/SubtargetEmitter.cpp?rev=355429&r1=355428&r2=355429&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/SubtargetEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/SubtargetEmitter.cpp Tue Mar 5 10:54:34 2019
@@ -257,7 +257,7 @@ SubtargetEmitter::CPUKeyValues(raw_ostre
// Begin processor table
OS << "// Sorted (by key) array of values for CPU subtype.\n"
- << "extern const llvm::SubtargetFeatureKV " << Target
+ << "extern const llvm::SubtargetSubTypeKV " << Target
<< "SubTypeKV[] = {\n";
// For each processor
@@ -266,10 +266,8 @@ SubtargetEmitter::CPUKeyValues(raw_ostre
RecVec FeatureList = Processor->getValueAsListOfDefs("Features");
// Emit as { "cpu", "description", 0, { f1 , f2 , ... fn } },
- // The 0 is for the feature id which isn't used for CPUs.
OS << " { "
- << "\"" << Name << "\", "
- << "\"Select the " << Name << " processor\", 0, ";
+ << "\"" << Name << "\", ";
printFeatureMask(OS, FeatureList, FeatureMap);
@@ -1760,7 +1758,7 @@ void SubtargetEmitter::emitGenMCSubtarge
<< "GenMCSubtargetInfo : public MCSubtargetInfo {\n";
OS << " " << Target << "GenMCSubtargetInfo(const Triple &TT, \n"
<< " StringRef CPU, StringRef FS, ArrayRef<SubtargetFeatureKV> PF,\n"
- << " ArrayRef<SubtargetFeatureKV> PD,\n"
+ << " ArrayRef<SubtargetSubTypeKV> PD,\n"
<< " const SubtargetInfoKV *ProcSched,\n"
<< " const MCWriteProcResEntry *WPR,\n"
<< " const MCWriteLatencyEntry *WL,\n"
@@ -1917,7 +1915,7 @@ void SubtargetEmitter::run(raw_ostream &
OS << "#include \"llvm/CodeGen/TargetSchedule.h\"\n\n";
OS << "namespace llvm {\n";
OS << "extern const llvm::SubtargetFeatureKV " << Target << "FeatureKV[];\n";
- OS << "extern const llvm::SubtargetFeatureKV " << Target << "SubTypeKV[];\n";
+ OS << "extern const llvm::SubtargetSubTypeKV " << Target << "SubTypeKV[];\n";
OS << "extern const llvm::SubtargetInfoKV " << Target << "ProcSchedKV[];\n";
OS << "extern const llvm::MCWriteProcResEntry "
<< Target << "WriteProcResTable[];\n";
More information about the llvm-commits
mailing list