mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-21 23:17:16 +00:00
Add help support for -mcpu and -mattr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23222 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -99,6 +99,29 @@ SubtargetFeatures::Find(const std::string &S,
|
||||
return F;
|
||||
}
|
||||
|
||||
/// Display help for feature choices.
|
||||
void SubtargetFeatures::Help(const char *Heading,
|
||||
const SubtargetFeatureKV *Table, size_t TableSize) {
|
||||
// Determine the length of the longest key
|
||||
size_t MaxLen = 0;
|
||||
for (size_t i = 0; i < TableSize; i++)
|
||||
MaxLen = std::max(MaxLen, std::strlen(Table[i].Key));
|
||||
// Print heading
|
||||
std::cerr << "Help for " << Heading << " choices\n\n";
|
||||
// For each feature
|
||||
for (size_t i = 0; i < TableSize; i++) {
|
||||
// Compute required padding
|
||||
size_t Pad = MaxLen - std::strlen(Table[i].Key) + 1;
|
||||
// Print details
|
||||
std::cerr << Table[i].Key << std::string(Pad, ' ') << " - "
|
||||
<< Table[i].Desc << "\n";
|
||||
}
|
||||
// Wrap it up
|
||||
std::cerr << "\n\n";
|
||||
// Leave tool
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/// Parse feature string for quick usage.
|
||||
uint32_t SubtargetFeatures::Parse(const std::string &String,
|
||||
const std::string &DefaultCPU,
|
||||
@@ -124,6 +147,8 @@ uint32_t SubtargetFeatures::Parse(const std::string &String,
|
||||
Split(Features, String);
|
||||
// Check if default is needed
|
||||
if (Features[0].empty()) Features[0] = DefaultCPU;
|
||||
// Check for help
|
||||
if (Features[0] == "help") Help("CPU", CPUTable, CPUTableSize);
|
||||
// Find CPU entry
|
||||
const SubtargetFeatureKV *CPUEntry =
|
||||
Find(Features[0], CPUTable, CPUTableSize);
|
||||
@@ -141,6 +166,8 @@ uint32_t SubtargetFeatures::Parse(const std::string &String,
|
||||
for (size_t i = 1; i < Features.size(); i++) {
|
||||
// Get next feature
|
||||
const std::string &Feature = Features[i];
|
||||
// Check for help
|
||||
if (Feature == "+help") Help("feature", FeatureTable, FeatureTableSize);
|
||||
// Find feature in table.
|
||||
const SubtargetFeatureKV *FeatureEntry =
|
||||
Find(StripFlag(Feature), FeatureTable, FeatureTableSize);
|
||||
|
||||
Reference in New Issue
Block a user