forked from OSchip/llvm-project
[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 llvm-svn: 355429
This commit is contained in:
parent
16fc15ab15
commit
ca26808da9
|
@ -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 MCSubtargetInfo {
|
|||
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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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(FeatureBitset &Bits, StringRef Feature,
|
|||
}
|
||||
|
||||
/// 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(ArrayRef<SubtargetFeatureKV> Table) {
|
|||
}
|
||||
|
||||
/// 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<SubtargetFeatureKV> CPUTable,
|
|||
// 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<SubtargetFeatureKV> CPUTable,
|
|||
}
|
||||
|
||||
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(StringRef CPU, StringRef FS,
|
|||
|
||||
// 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(StringRef CPU, StringRef FS) {
|
|||
|
||||
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)
|
||||
|
|
|
@ -257,7 +257,7 @@ SubtargetEmitter::CPUKeyValues(raw_ostream &OS,
|
|||
|
||||
// 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_ostream &OS,
|
|||
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::emitGenMCSubtargetInfo(raw_ostream &OS) {
|
|||
<< "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) {
|
|||
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";
|
||||
|
|
Loading…
Reference in New Issue