|
| 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 | + |
| 4 | +// Check that an instruction that uses mixed upper/lower case in its mnemonic |
| 5 | +// is printed as-is, and is parsed in its "canonicalized" lowercase form. |
| 6 | + |
| 7 | +include "llvm/Target/Target.td" |
| 8 | + |
| 9 | +def ArchInstrInfo : InstrInfo { } |
| 10 | + |
| 11 | +def Arch : Target { |
| 12 | + let InstructionSet = ArchInstrInfo; |
| 13 | +} |
| 14 | + |
| 15 | +def Reg : Register<"reg">; |
| 16 | +def RegClass : RegisterClass<"foo", [i32], 0, (add Reg)>; |
| 17 | + |
| 18 | +// Define instructions that demonstrate case-insensitivity. |
| 19 | +// In case-sensitive ASCII order, "BInst" < "aInst". |
| 20 | +// In case-insensitive order, "aInst" < "BInst". |
| 21 | +// If the matcher really treats the mnemonics in a case-insensitive way, |
| 22 | +// then we should see "aInst" appearing before "BInst", despite the |
| 23 | +// fact that "BInst" would appear before "aInst" in ASCIIbetical order. |
| 24 | +def AlphabeticallySecondInst : Instruction { |
| 25 | + let Size = 2; |
| 26 | + let OutOperandList = (outs); |
| 27 | + let InOperandList = (ins); |
| 28 | + let AsmString = "BInst"; |
| 29 | +} |
| 30 | + |
| 31 | +def AlphabeticallyFirstInst : Instruction { |
| 32 | + let Size = 2; |
| 33 | + let OutOperandList = (outs); |
| 34 | + let InOperandList = (ins); |
| 35 | + let AsmString = "aInst"; |
| 36 | +} |
| 37 | + |
| 38 | +// Check that the matcher lower()s the mnemonics it matches. |
| 39 | +// MATCHER: static const char *const MnemonicTable = |
| 40 | +// MATCHER-NEXT: "\005ainst\005binst"; |
| 41 | + |
| 42 | +// Check that aInst appears before BInst in the match table. |
| 43 | +// This shows that the mnemonics are sorted in a case-insensitive way, |
| 44 | +// since otherwise "B" would be less than "a" by ASCII order. |
| 45 | +// MATCHER: static const MatchEntry MatchTable0[] = { |
| 46 | +// MATCHER-NEXT: /* aInst */, ::AlphabeticallyFirstInst |
| 47 | +// MATCHER-NEXT: /* BInst */, ::AlphabeticallySecondInst |
| 48 | +// MATCHER-NEXT: }; |
| 49 | + |
| 50 | +// Check that the writer preserves the case of the mnemonics. |
| 51 | +// WRITER: static const char AsmStrs[] = { |
| 52 | +// WRITER: "BInst\0" |
| 53 | +// WRITER-NEXT: "aInst\0" |
| 54 | +// WRITER-NEXT: }; |
| 55 | + |
0 commit comments