1 // RUN: llvm-tblgen -gen-disassembler -I %p/../../include %s | FileCheck %s
3 include "llvm/Target/Target.td"
5 def ArchInstrInfo : InstrInfo { }
8 let InstructionSet = ArchInstrInfo;
11 def Reg : Register<"reg">;
13 def RegClass : RegisterClass<"foo", [i64], 0, (add Reg)>;
15 def GR64 : RegisterOperand<RegClass>;
17 class MyMemOperand<dag sub_ops> : Operand<iPTR> {
18 let MIOperandInfo = sub_ops;
23 def MemOp16: MyMemOperand<(ops GR64:$reg, i16imm:$offset)>;
25 def MemOp32: MyMemOperand<(ops GR64:$reg, i32imm:$offset)>;
27 class MyVarInst<MyMemOperand memory_op> : Instruction {
30 let OutOperandList = (outs GR64:$dst);
31 let InOperandList = (ins memory_op:$src);
34 def FOO16 : MyVarInst<MemOp16> {
36 (descend (operand "$dst", 3), 0b01000, (operand "$src.reg", 3)),
37 (slice "$src.offset", 15, 0, (decoder "myCustomDecoder"))
40 def FOO32 : MyVarInst<MemOp32> {
42 (descend (operand "$dst", 3), 0b01001,
43 (operand "$src.reg", 3, (decoder "myCustomDecoder"))),
44 (slice "$src.offset", 31, 16),
45 (slice "$src.offset", 15, 0)
49 // CHECK: MCD::OPC_ExtractField, 3, 5, // Inst{7-3} ...
50 // CHECK-NEXT: MCD::OPC_FilterValue, 8, 4, 0, 0, // Skip to: 12
51 // CHECK-NEXT: MCD::OPC_Decode, {{[0-9]+}}, {{[0-9]+}}, 0, // Opcode: FOO16
52 // CHECK-NEXT: MCD::OPC_FilterValue, 9, 4, 0, 0, // Skip to: 21
53 // CHECK-NEXT: MCD::OPC_Decode, {{[0-9]+}}, {{[0-9]+}}, 1, // Opcode: FOO32
54 // CHECK-NEXT: MCD::OPC_Fail,
56 // Instruction length table
62 // CHECK-NEXT: tmp = fieldFromInstruction(insn, 8, 3);
63 // CHECK-NEXT: if (!Check(S, DecodeRegClassRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
64 // CHECK-NEXT: tmp = fieldFromInstruction(insn, 0, 3);
65 // CHECK-NEXT: if (!Check(S, DecodeRegClassRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
66 // CHECK-NEXT: tmp = fieldFromInstruction(insn, 11, 16);
67 // CHECK-NEXT: if (!Check(S, myCustomDecoder(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
68 // CHECK-NEXT: return S;
69 // CHECK-NEXT: case 1:
70 // CHECK-NEXT: tmp = fieldFromInstruction(insn, 8, 3);
71 // CHECK-NEXT: if (!Check(S, DecodeRegClassRegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
72 // CHECK-NEXT: tmp = fieldFromInstruction(insn, 0, 3);
73 // CHECK-NEXT: if (!Check(S, myCustomDecoder(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; }
74 // CHECK-NEXT: tmp = 0x0;
75 // CHECK-NEXT: insertBits(tmp, fieldFromInstruction(insn, 11, 16), 16, 16);
76 // CHECK-NEXT: insertBits(tmp, fieldFromInstruction(insn, 27, 16), 0, 16);
77 // CHECK-NEXT: MI.addOperand(MCOperand::createImm(tmp));
78 // CHECK-NEXT: return S;
80 // CHECK-LABEL: case MCD::OPC_ExtractField: {
81 // CHECK: makeUp(insn, Start + Len);
83 // CHECK-LABEL: case MCD::OPC_CheckField: {
84 // CHECK: makeUp(insn, Start + Len);
86 // CHECK-LABEL: case MCD::OPC_Decode: {
87 // CHECK: Len = InstrLenTable[Opc];
88 // CHECK-NEXT: makeUp(insn, Len);