comparison llvm/test/TableGen/MixedCasedMnemonic.td @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents
children c4bab56944e8
comparison
equal deleted inserted replaced
173:0572611fdcc8 207:2e18cbf3894f
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
4
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.
7
8 include "llvm/Target/Target.td"
9
10 def ArchInstrInfo : InstrInfo { }
11
12 def Arch : Target {
13 let InstructionSet = ArchInstrInfo;
14 }
15
16 def Reg : Register<"reg">;
17 def RegClass : RegisterClass<"foo", [i32], 0, (add Reg)>;
18
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 {
26 let Size = 2;
27 let OutOperandList = (outs);
28 let InOperandList = (ins);
29 let AsmString = "BInst";
30 }
31
32 def AlphabeticallyFirstInst : Instruction {
33 let Size = 2;
34 let OutOperandList = (outs);
35 let InOperandList = (ins);
36 let AsmString = "aInst";
37 }
38
39 def :MnemonicAlias<"Insta", "aInst">;
40 def :MnemonicAlias<"InstB", "BInst">;
41
42 // Check that the matcher lower()s the mnemonics it matches.
43 // MATCHER: static const char *const MnemonicTable =
44 // MATCHER-NEXT: "\005ainst\005binst";
45
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
52 // MATCHER-NEXT: };
53
54 // Check that the writer preserves the case of the mnemonics.
55 // WRITER: static const char AsmStrs[] = {
56 // WRITER: "BInst\0"
57 // WRITER-NEXT: "aInst\0"
58 // WRITER-NEXT: };
59
60 // ALIAS: static void applyMnemonicAliases(StringRef &Mnemonic, const FeatureBitset &Features, unsigned VariantID) {
61 // ALIAS-NEXT switch (VariantID) {
62 // ALIAS-NEXT case 0:
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)
67 // ALIAS-NEXT break;
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"
72 // ALIAS-NEXT return;
73 // ALIAS-NEXT case 'b': // 1 string to match.
74 // ALIAS-NEXT Mnemonic = "binst"; // "instb"
75 // ALIAS-NEXT return;
76