1 // RUN: llvm-tblgen -gen-emitter -I %p/../../include %s | FileCheck %s --check-prefix=ENCODER
2 // RUN: llvm-tblgen -gen-disassembler -I %p/../../include %s | FileCheck %s --check-prefix=DECODER
4 include "llvm/Target/Target.td"
6 def archInstrInfo : InstrInfo { }
9 let InstructionSet = archInstrInfo;
12 def Myi32 : Operand<i32> {
13 let DecoderMethod = "DecodeMyi32";
16 def HasA : Predicate<"Subtarget->hasA()">;
17 def HasB : Predicate<"Subtarget->hasB()">;
19 def ModeA : HwMode<"+a", [HasA]>;
20 def ModeB : HwMode<"+b", [HasB]>;
23 def fooTypeEncA : InstructionEncoding {
25 field bits<32> SoftFail = 0;
28 let Inst{7...0} = factor;
29 let Inst{3...2} = 0b11;
30 let Inst{1...0} = 0b00;
33 def fooTypeEncB : InstructionEncoding {
35 field bits<32> SoftFail = 0;
38 let Inst{15...8} = factor;
39 let Inst{1...0} = 0b11;
42 let OutOperandList = (outs) in {
43 def foo : Instruction {
44 let InOperandList = (ins i32imm:$factor);
45 let EncodingInfos = EncodingByHwMode<
46 [ModeA, ModeB], [fooTypeEncA,
49 let AsmString = "foo $factor";
52 def bar: Instruction {
53 let InOperandList = (ins i32imm:$factor);
58 let Inst{31...24} = factor;
59 let Inst{1...0} = 0b10;
60 let AsmString = "bar $factor";
63 def baz : Instruction {
64 let InOperandList = (ins i32imm:$factor);
66 let EncodingInfos = EncodingByHwMode<
67 [ModeB], [fooTypeEncA]
69 let AsmString = "foo $factor";
73 // DECODER-LABEL: DecoderTable_ModeA32[] =
74 // DECODER-DAG: Opcode: fooTypeEncA:foo
75 // DECODER-DAG: Opcode: bar
76 // DECODER-LABEL: DecoderTable_ModeB32[] =
77 // Note that the comment says fooTypeEncA but this is actually fooTypeEncB; plumbing
78 // the correct comment text through the decoder is nontrivial.
79 // DECODER-DAG: Opcode: fooTypeEncA:foo
80 // DECODER-DAG: Opcode: bar
82 // ENCODER-LABEL: static const uint64_t InstBits_ModeA[] = {
83 // ENCODER: UINT64_C(2), // bar
84 // ENCODER: UINT64_C(12), // foo
86 // ENCODER-LABEL: static const uint64_t InstBits_ModeB[] = {
87 // ENCODER: UINT64_C(2), // bar
88 // ENCODER: UINT64_C(3), // foo
90 // ENCODER: case ::foo: {
91 // ENCODER: switch (HwMode) {
92 // ENCODER: default: llvm_unreachable("Unhandled HwMode");