[llvm] [utils][TableGen] Handle versions on clause/directive spellings (PR #143021)
Krzysztof Parzyszek via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 6 08:38:26 PDT 2025
================
@@ -381,14 +415,31 @@ static void generateGetName(ArrayRef<const Record *> Records, raw_ostream &OS,
std::string Qual = getQualifier(DirLang);
OS << "\n";
OS << "llvm::StringRef " << Qual << "get" << Lang << Enum << "Name(" << Qual
- << Enum << " Kind, unsigned) {\n";
+ << Enum << " Kind, unsigned Version) {\n";
OS << " switch (Kind) {\n";
for (const Record *R : Records) {
- OS << " case " << getIdentifierName(R, Prefix) << ":\n";
- // FIXME: This will need to recognize different spellings for different
- // versions.
- OS << " return \"" << BaseRecord(R).getSpellingForIdentifier()
- << "\";\n";
+ BaseRecord Rec(R);
+ std::string Ident = getIdentifierName(R, Prefix);
+ OS << " case " << Ident << ":";
+ auto Spellings(orderSpellings(Rec.getSpellings()));
+ assert(Spellings.size() != 0 && "No spellings for this item");
+ if (Spellings.size() == 1) {
+ OS << "\n";
+ OS << " return \"" << Spellings.front().Name << "\";\n";
+ } else {
+ OS << " {\n";
+ std::string SpellingsName = Ident + "_spellings";
+ OS << " static const llvm::directive::Spelling " << SpellingsName
----------------
kparzysz wrote:
Done.
https://github.com/llvm/llvm-project/pull/143021
More information about the llvm-commits
mailing list