diff --git a/test/TableGen/MixedCasedMnemonic.td b/test/TableGen/MixedCasedMnemonic.td --- a/test/TableGen/MixedCasedMnemonic.td +++ b/test/TableGen/MixedCasedMnemonic.td @@ -1,5 +1,6 @@ // RUN: llvm-tblgen -gen-asm-matcher -I %p/../../include %s | FileCheck %s --check-prefix=MATCHER // RUN: llvm-tblgen -gen-asm-writer -I %p/../../include %s | FileCheck %s --check-prefix=WRITER +// RUN: llvm-tblgen -gen-asm-matcher -I %p/../../include %s | FileCheck %s --check-prefix=ALIAS // Check that an instruction that uses mixed upper/lower case in its mnemonic // is printed as-is, and is parsed in its "canonicalized" lowercase form. @@ -35,6 +36,9 @@ let AsmString = "aInst"; } +def :MnemonicAlias<"Insta", "aInst">; +def :MnemonicAlias<"InstB", "BInst">; + // Check that the matcher lower()s the mnemonics it matches. // MATCHER: static const char *const MnemonicTable = // MATCHER-NEXT: "\005ainst\005binst"; @@ -53,3 +57,20 @@ // WRITER-NEXT: "aInst\0" // WRITER-NEXT: }; +// ALIAS: static void applyMnemonicAliases(StringRef &Mnemonic, const FeatureBitset &Features, unsigned VariantID) { +// ALIAS-NEXT switch (VariantID) { +// ALIAS-NEXT case 0: +// ALIAS-NEXT switch (Mnemonic.size()) { +// ALIAS-NEXT default: break; +// ALIAS-NEXT case 5: // 2 strings to match. +// ALIAS-NEXT if (memcmp(Mnemonic.data()+0, "inst", 4) != 0) +// ALIAS-NEXT break; +// ALIAS-NEXT switch (Mnemonic[4]) { +// ALIAS-NEXT default: break; +// ALIAS-NEXT case 'a': // 1 string to match. +// ALIAS-NEXT Mnemonic = "ainst"; // "insta" +// ALIAS-NEXT return; +// ALIAS-NEXT case 'b': // 1 string to match. +// ALIAS-NEXT Mnemonic = "binst"; // "instb" +// ALIAS-NEXT return; + diff --git a/utils/TableGen/AsmMatcherEmitter.cpp b/utils/TableGen/AsmMatcherEmitter.cpp --- a/utils/TableGen/AsmMatcherEmitter.cpp +++ b/utils/TableGen/AsmMatcherEmitter.cpp @@ -2726,7 +2726,7 @@ StringRef AsmVariantName = R->getValueAsString("AsmVariantName"); if (AsmVariantName != AsmParserVariantName) continue; - AliasesFromMnemonic[std::string(R->getValueAsString("FromMnemonic"))] + AliasesFromMnemonic[R->getValueAsString("FromMnemonic").lower()] .push_back(R); } if (AliasesFromMnemonic.empty()) @@ -2768,7 +2768,7 @@ MatchCode += "else "; MatchCode += "if (" + FeatureMask + ")\n"; MatchCode += " Mnemonic = \""; - MatchCode += R->getValueAsString("ToMnemonic"); + MatchCode += R->getValueAsString("ToMnemonic").lower(); MatchCode += "\";\n"; } @@ -2777,7 +2777,7 @@ if (!MatchCode.empty()) MatchCode += "else\n "; MatchCode += "Mnemonic = \""; - MatchCode += R->getValueAsString("ToMnemonic"); + MatchCode += R->getValueAsString("ToMnemonic").lower(); MatchCode += "\";\n"; }