1 // RUN: llvm-tblgen -gen-asm-matcher -I %p/../../include %s | FileCheck %s --check-prefix=MATCHER
2 // RUN: llvm-tblgen -gen-asm-writer -I %p/../../include %s | FileCheck %s --check-prefix=WRITER
3 // RUN: llvm-tblgen -gen-asm-matcher -I %p/../../include %s | FileCheck %s --check-prefix=ALIAS
5 // Check that an instruction that uses mixed upper/lower case in its mnemonic
6 // is printed as-is, and is parsed in its "canonicalized" lowercase form.
8 include "llvm/Target/Target.td"
10 def ArchInstrInfo : InstrInfo { }
13 let InstructionSet = ArchInstrInfo;
16 def Reg : Register<"reg">;
17 def RegClass : RegisterClass<"foo", [i32], 0, (add Reg)>;
19 // Define instructions that demonstrate case-insensitivity.
20 // In case-sensitive ASCII order, "BInst" < "aInst".
21 // In case-insensitive order, "aInst" < "BInst".
22 // If the matcher really treats the mnemonics in a case-insensitive way,
23 // then we should see "aInst" appearing before "BInst", despite the
24 // fact that "BInst" would appear before "aInst" in ASCIIbetical order.
25 def AlphabeticallySecondInst : Instruction {
27 let OutOperandList = (outs);
28 let InOperandList = (ins);
29 let AsmString = "BInst";
32 def AlphabeticallyFirstInst : Instruction {
34 let OutOperandList = (outs);
35 let InOperandList = (ins);
36 let AsmString = "aInst";
39 def :MnemonicAlias<"Insta", "aInst">;
40 def :MnemonicAlias<"InstB", "BInst">;
42 // Check that the matcher lower()s the mnemonics it matches.
43 // MATCHER: static const char MnemonicTable[] =
44 // MATCHER-NEXT: "\005ainst\005binst";
46 // Check that aInst appears before BInst in the match table.
47 // This shows that the mnemonics are sorted in a case-insensitive way,
48 // since otherwise "B" would be less than "a" by ASCII order.
49 // MATCHER: static const MatchEntry MatchTable0[] = {
50 // MATCHER-NEXT: /* aInst */, ::AlphabeticallyFirstInst
51 // MATCHER-NEXT: /* BInst */, ::AlphabeticallySecondInst
54 // Check that the writer preserves the case of the mnemonics.
55 // WRITER: static const char AsmStrs[] = {
57 // WRITER-NEXT: "aInst\0"
60 // ALIAS: static void applyMnemonicAliases(StringRef &Mnemonic, const FeatureBitset &Features, unsigned VariantID) {
61 // ALIAS-NEXT switch (VariantID) {
63 // ALIAS-NEXT switch (Mnemonic.size()) {
64 // ALIAS-NEXT default: break;
65 // ALIAS-NEXT case 5: // 2 strings to match.
66 // ALIAS-NEXT if (memcmp(Mnemonic.data()+0, "inst", 4) != 0)
68 // ALIAS-NEXT switch (Mnemonic[4]) {
69 // ALIAS-NEXT default: break;
70 // ALIAS-NEXT case 'a': // 1 string to match.
71 // ALIAS-NEXT Mnemonic = "ainst"; // "insta"
73 // ALIAS-NEXT case 'b': // 1 string to match.
74 // ALIAS-NEXT Mnemonic = "binst"; // "instb"