150
|
1 // RUN: llvm-tblgen -gen-disassembler -I %p/../../include %s | FileCheck %s
|
|
2
|
|
3 include "llvm/Target/Target.td"
|
|
4
|
|
5 def archInstrInfo : InstrInfo { }
|
|
6
|
|
7 def arch : Target {
|
|
8 let InstructionSet = archInstrInfo;
|
|
9 }
|
|
10
|
|
11 def Myi32 : Operand<i32> {
|
|
12 let DecoderMethod = "DecodeMyi32";
|
|
13 }
|
|
14
|
|
15
|
|
16 let OutOperandList = (outs), Size = 2 in {
|
|
17
|
|
18 def foo : Instruction {
|
|
19 let InOperandList = (ins i32imm:$factor);
|
|
20 field bits<16> Inst;
|
|
21 bits<32> factor;
|
207
|
22 let Inst{7...0} = 0xAA;
|
|
23 let Inst{14...8} = factor{6...0}; // no offset
|
150
|
24 let AsmString = "foo $factor";
|
|
25 field bits<16> SoftFail = 0;
|
|
26 }
|
|
27
|
|
28 def bar : Instruction {
|
|
29 let InOperandList = (ins i32imm:$factor);
|
|
30 field bits<16> Inst;
|
|
31 bits<32> factor;
|
207
|
32 let Inst{7...0} = 0xBB;
|
|
33 let Inst{15...8} = factor{10...3}; // offset by 3
|
150
|
34 let AsmString = "bar $factor";
|
|
35 field bits<16> SoftFail = 0;
|
|
36 }
|
|
37
|
|
38 def biz : Instruction {
|
|
39 let InOperandList = (ins i32imm:$factor);
|
|
40 field bits<16> Inst;
|
|
41 bits<32> factor;
|
207
|
42 let Inst{7...0} = 0xCC;
|
|
43 let Inst{11...8,15...12} = factor{10...3}; // offset by 3, multipart
|
150
|
44 let AsmString = "biz $factor";
|
|
45 field bits<16> SoftFail = 0;
|
|
46 }
|
|
47
|
|
48 def baz : Instruction {
|
|
49 let InOperandList = (ins Myi32:$factor);
|
|
50 field bits<16> Inst;
|
|
51 bits<32> factor;
|
207
|
52 let Inst{7...0} = 0xDD;
|
|
53 let Inst{15...8} = factor{11...4}; // offset by 4 + custom decode
|
150
|
54 let AsmString = "baz $factor";
|
|
55 field bits<16> SoftFail = 0;
|
|
56 }
|
|
57
|
|
58 }
|
|
59
|
|
60 // CHECK: tmp = fieldFromInstruction(insn, 8, 7);
|
|
61 // CHECK: tmp = fieldFromInstruction(insn, 8, 8) << 3;
|
207
|
62 // CHECK: insertBits(tmp, fieldFromInstruction(insn, 8, 4), 7, 4);
|
|
63 // CHECK: insertBits(tmp, fieldFromInstruction(insn, 12, 4), 3, 4);
|
150
|
64 // CHECK: tmp = fieldFromInstruction(insn, 8, 8) << 4;
|