brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.8 KiB · cb224ac Raw
76 lines · plain
1// RUN: llvm-tblgen -gen-asm-matcher -I %p/../../include %s | FileCheck %s --check-prefix=MATCHER2// RUN: llvm-tblgen -gen-asm-writer -I %p/../../include %s | FileCheck %s --check-prefix=WRITER3// RUN: llvm-tblgen -gen-asm-matcher -I %p/../../include %s | FileCheck %s --check-prefix=ALIAS4 5// Check that an instruction that uses mixed upper/lower case in its mnemonic6// is printed as-is, and is parsed in its "canonicalized" lowercase form.7 8include "llvm/Target/Target.td"9 10def ArchInstrInfo : InstrInfo { }11 12def Arch : Target {13  let InstructionSet = ArchInstrInfo;14}15 16def Reg : Register<"reg">;17def 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 the24// fact that "BInst" would appear before "aInst" in ASCIIbetical order.25def AlphabeticallySecondInst : Instruction {26  let Size = 2;27  let OutOperandList = (outs);28  let InOperandList = (ins);29  let AsmString = "BInst";30}31 32def AlphabeticallyFirstInst : Instruction {33  let Size = 2;34  let OutOperandList = (outs);35  let InOperandList = (ins);36  let AsmString = "aInst";37}38 39def :MnemonicAlias<"Insta", "aInst">;40def :MnemonicAlias<"InstB", "BInst">;41 42// Check that the matcher lower()s the mnemonics it matches.43// MATCHER: static const char 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 */, ::AlphabeticallyFirstInst51// MATCHER-NEXT:     /* BInst */, ::AlphabeticallySecondInst52// MATCHER-NEXT: };53 54// Check that the writer preserves the case of the mnemonics.55// WRITER:      static const char AsmStrs[] = {56// WRITER:        "BInst\000"57// WRITER-NEXT:   "aInst\000"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