xref: /aosp_15_r20/external/llvm/test/TableGen/trydecode-emission.td (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker// RUN: llvm-tblgen -gen-disassembler -I %p/../../include %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker// Check that if decoding of an instruction fails and the instruction does not
4*9880d681SAndroid Build Coastguard Worker// have a complete decoder method that can determine if the bitpattern is valid
5*9880d681SAndroid Build Coastguard Worker// or not then the decoder tries to find a more general instruction that
6*9880d681SAndroid Build Coastguard Worker// matches the bitpattern too.
7*9880d681SAndroid Build Coastguard Worker
8*9880d681SAndroid Build Coastguard Workerinclude "llvm/Target/Target.td"
9*9880d681SAndroid Build Coastguard Worker
10*9880d681SAndroid Build Coastguard Workerdef archInstrInfo : InstrInfo { }
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Workerdef arch : Target {
13*9880d681SAndroid Build Coastguard Worker  let InstructionSet = archInstrInfo;
14*9880d681SAndroid Build Coastguard Worker}
15*9880d681SAndroid Build Coastguard Worker
16*9880d681SAndroid Build Coastguard Workerclass TestInstruction : Instruction {
17*9880d681SAndroid Build Coastguard Worker  let Size = 1;
18*9880d681SAndroid Build Coastguard Worker  let OutOperandList = (outs);
19*9880d681SAndroid Build Coastguard Worker  let InOperandList = (ins);
20*9880d681SAndroid Build Coastguard Worker  field bits<8> Inst;
21*9880d681SAndroid Build Coastguard Worker  field bits<8> SoftFail = 0;
22*9880d681SAndroid Build Coastguard Worker}
23*9880d681SAndroid Build Coastguard Worker
24*9880d681SAndroid Build Coastguard Workerdef InstA : TestInstruction {
25*9880d681SAndroid Build Coastguard Worker  let Inst = {0,0,0,0,?,?,?,?};
26*9880d681SAndroid Build Coastguard Worker  let AsmString = "InstA";
27*9880d681SAndroid Build Coastguard Worker}
28*9880d681SAndroid Build Coastguard Worker
29*9880d681SAndroid Build Coastguard Workerdef InstB : TestInstruction {
30*9880d681SAndroid Build Coastguard Worker  let Inst = {0,0,0,0,0,0,?,?};
31*9880d681SAndroid Build Coastguard Worker  let AsmString = "InstB";
32*9880d681SAndroid Build Coastguard Worker  let DecoderMethod = "DecodeInstB";
33*9880d681SAndroid Build Coastguard Worker  let hasCompleteDecoder = 0;
34*9880d681SAndroid Build Coastguard Worker}
35*9880d681SAndroid Build Coastguard Worker
36*9880d681SAndroid Build Coastguard Worker// CHECK:      /* 0 */       MCD::OPC_ExtractField, 4, 4,  // Inst{7-4} ...
37*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT: /* 3 */       MCD::OPC_FilterValue, 0, 14, 0, // Skip to: 21
38*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT: /* 7 */       MCD::OPC_CheckField, 2, 2, 0, 5, 0, // Skip to: 18
39*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT: /* 13 */      MCD::OPC_TryDecode, {{[0-9]+}}, 0, 0, 0, // Opcode: InstB, skip to: 18
40*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT: /* 18 */      MCD::OPC_Decode, {{[0-9]+}}, 1, // Opcode: InstA
41*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT: /* 21 */      MCD::OPC_Fail,
42*9880d681SAndroid Build Coastguard Worker
43*9880d681SAndroid Build Coastguard Worker// CHECK: if (DecodeInstB(MI, insn, Address, Decoder) == MCDisassembler::Fail) { DecodeComplete = false; return MCDisassembler::Fail; }
44