Changes in directory llvm/lib/Target:
SubtargetFeature.cpp updated: 1.6 -> 1.7 --- Log message: If a user requests help, give them help on both features and processors --- Diffs of the changes: (+41 -25) SubtargetFeature.cpp | 66 +++++++++++++++++++++++++++++++-------------------- 1 files changed, 41 insertions(+), 25 deletions(-) Index: llvm/lib/Target/SubtargetFeature.cpp diff -u llvm/lib/Target/SubtargetFeature.cpp:1.6 llvm/lib/Target/SubtargetFeature.cpp:1.7 --- llvm/lib/Target/SubtargetFeature.cpp:1.6 Sun Oct 23 00:33:39 2005 +++ llvm/lib/Target/SubtargetFeature.cpp Sun Oct 23 17:23:13 2005 @@ -123,31 +123,42 @@ return F; } -/// Display help for feature choices. +/// getLongestEntryLength - Return the length of the longest entry in the table. /// -static void Help(bool isFeature, const SubtargetFeatureKV *Table, - size_t TableSize) { - // Determine the length of the longest key. +static size_t getLongestEntryLength(const SubtargetFeatureKV *Table, + size_t Size) { size_t MaxLen = 0; - for (size_t i = 0; i < TableSize; i++) + for (size_t i = 0; i < Size; i++) MaxLen = std::max(MaxLen, std::strlen(Table[i].Key)); - - std::cerr << "Available " << (isFeature ? "features" : "CPUs") - << " for this target:\n\n"; - - for (size_t i = 0; i < TableSize; i++) { - // Compute required padding - size_t Pad = MaxLen - std::strlen(Table[i].Key); - std::cerr << Table[i].Key << std::string(Pad, ' ') << " - " - << Table[i].Desc << ".\n"; - } + return MaxLen; +} +/// Display help for feature choices. +/// +static void Help(const SubtargetFeatureKV *CPUTable, size_t CPUTableSize, + const SubtargetFeatureKV *FeatTable, size_t FeatTableSize) { + // Determine the length of the longest CPU and Feature entries. + unsigned MaxCPULen = getLongestEntryLength(CPUTable, CPUTableSize); + unsigned MaxFeatLen = getLongestEntryLength(FeatTable, FeatTableSize); + + // Print the CPU table. + std::cerr << "Available CPUs for this target:\n\n"; + for (size_t i = 0; i != CPUTableSize; i++) + std::cerr << " " << CPUTable[i].Key + << std::string(MaxCPULen - std::strlen(CPUTable[i].Key), ' ') + << " - " << CPUTable[i].Desc << ".\n"; std::cerr << "\n"; - if (isFeature) { - std::cerr - << "Use +feature to enable a feature, or -feature to disable it.\n" - << "For example, llc -mcpu=mycpu -mattr=+feature1,-feature2\n"; - } + + // Print the Feature table. + std::cerr << "Available features for this target:\n\n"; + for (size_t i = 0; i != FeatTableSize; i++) + std::cerr << " " << FeatTable[i].Key + << std::string(MaxFeatLen - std::strlen(FeatTable[i].Key), ' ') + << " - " << FeatTable[i].Desc << ".\n"; + std::cerr << "\n"; + + std::cerr << "Use +feature to enable a feature, or -feature to disable it.\n" + << "For example, llc -mcpu=mycpu -mattr=+feature1,-feature2\n"; exit(1); } @@ -203,10 +214,13 @@ uint32_t Bits = 0; // Resulting bits // Split up features Split(Features, String); + // Check if default is needed - if (Features[0].empty()) Features[0] = DefaultCPU; - // Check for help - if (Features[0] == "help") Help(false, CPUTable, CPUTableSize); + if (Features[0].empty()) + Features[0] = DefaultCPU; + else if (Features[0] == "help") + Help(CPUTable, CPUTableSize, FeatureTable, FeatureTableSize); + // Find CPU entry const SubtargetFeatureKV *CPUEntry = Find(Features[0], CPUTable, CPUTableSize); @@ -222,10 +236,12 @@ } // Iterate through each feature 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(true, FeatureTable, FeatureTableSize); + if (Feature == "+help") + Help(CPUTable, CPUTableSize, FeatureTable, FeatureTableSize); + // Find feature in table. const SubtargetFeatureKV *FeatureEntry = Find(StripFlag(Feature), FeatureTable, FeatureTableSize); _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits