[PATCH] D96691: [TableGen] Allow mnemonics aliases with uppercase
Paul C. Anagnostopoulos via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 16 06:58:58 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6445d5ba8496: [TableGen] Allow mnemonics aliases with uppercase (authored by paperchalice, committed by Paul-C-Anagnostopoulos).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D96691/new/
https://reviews.llvm.org/D96691
Files:
llvm/test/TableGen/MixedCasedMnemonic.td
llvm/utils/TableGen/AsmMatcherEmitter.cpp
Index: llvm/utils/TableGen/AsmMatcherEmitter.cpp
===================================================================
--- llvm/utils/TableGen/AsmMatcherEmitter.cpp
+++ llvm/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";
}
Index: llvm/test/TableGen/MixedCasedMnemonic.td
===================================================================
--- llvm/test/TableGen/MixedCasedMnemonic.td
+++ llvm/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;
+
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96691.338098.patch
Type: text/x-patch
Size: 2969 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210416/f348e0e7/attachment.bin>
More information about the llvm-commits
mailing list