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)
40 def FOO32 : MyVarInst<MemOp32> {
42 (descend (operand "$dst", 3), 0b01001, (operand "$src.reg", 3)),
43 (slice "$src.offset", 31, 16),
44 (slice "$src.offset", 15, 0)
48 // CHECK: MCD::OPC_ExtractField, 3, 5, // Inst{7-3} ...
49 // CHECK-NEXT: MCD::OPC_FilterValue, 8, 4, 0, 0, // Skip to: 12
50 // CHECK-NEXT: MCD::OPC_Decode, [[#OPCODE:]], 1, 0, // Opcode: FOO16
51 // CHECK-NEXT: MCD::OPC_FilterValue, 9, 4, 0, 0, // Skip to: 21
52 // CHECK-NEXT: MCD::OPC_Decode, [[#OPCODE+1]], 1, 1, // Opcode: FOO32
53 // CHECK-NEXT: MCD::OPC_Fail,
55 // Instruction length table
61 // CHECK-NEXT: tmp = fieldFromInstruction(insn, 8, 3);
62 // CHECK-NEXT: if (DecodeRegClassRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
63 // CHECK-NEXT: tmp = fieldFromInstruction(insn, 0, 3);
64 // CHECK-NEXT: if (DecodeRegClassRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
65 // CHECK-NEXT: tmp = fieldFromInstruction(insn, 11, 16);
66 // CHECK-NEXT: MI.addOperand(MCOperand::createImm(tmp));
67 // CHECK-NEXT: return S;
68 // CHECK-NEXT: case 1:
69 // CHECK-NEXT: tmp = fieldFromInstruction(insn, 8, 3);
70 // CHECK-NEXT: if (DecodeRegClassRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
71 // CHECK-NEXT: tmp = fieldFromInstruction(insn, 0, 3);
72 // CHECK-NEXT: if (DecodeRegClassRegisterClass(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }
73 // CHECK-NEXT: tmp = 0x0;
74 // CHECK-NEXT: insertBits(tmp, fieldFromInstruction(insn, 11, 16), 16, 16);
75 // CHECK-NEXT: insertBits(tmp, fieldFromInstruction(insn, 27, 16), 0, 16);
76 // CHECK-NEXT: MI.addOperand(MCOperand::createImm(tmp));
77 // CHECK-NEXT: return S;
79 // CHECK-LABEL: case MCD::OPC_ExtractField: {
80 // CHECK: makeUp(insn, Start + Len);
82 // CHECK-LABEL: case MCD::OPC_CheckField: {
83 // CHECK: makeUp(insn, Start + Len);
85 // CHECK-LABEL: case MCD::OPC_Decode: {
86 // CHECK: Len = InstrLenTable[Opc];
87 // CHECK-NEXT: makeUp(insn, Len);