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 ModeA : HwMode<"+a">;
17 def ModeB : HwMode<"+b">;
20 def fooTypeEncA : InstructionEncoding {
22 field bits<32> SoftFail = 0;
25 let Inst{7-0} = factor;
30 def fooTypeEncB : InstructionEncoding {
32 field bits<32> SoftFail = 0;
35 let Inst{15-8} = factor;
39 let OutOperandList = (outs) in {
40 def foo : Instruction {
41 let InOperandList = (ins i32imm:$factor);
42 let EncodingInfos = EncodingByHwMode<
43 [ModeA, ModeB], [fooTypeEncA,
46 let AsmString = "foo $factor";
49 def bar: Instruction {
50 let InOperandList = (ins i32imm:$factor);
55 let Inst{31-24} = factor;
57 let AsmString = "bar $factor";
61 // DECODER-LABEL: DecoderTable_ModeA32[] =
62 // DECODER-DAG: Opcode: fooTypeEncA:foo
63 // DECODER-DAG: Opcode: bar
64 // DECODER-LABEL: DecoderTable_ModeB32[] =
65 // Note that the comment says fooTypeEncA but this is actually fooTypeEncB; plumbing
66 // the correct comment text through the decoder is nontrivial.
67 // DECODER-DAG: Opcode: fooTypeEncA:foo
68 // DECODER-DAG: Opcode: bar
70 // ENCODER-LABEL: static const uint64_t InstBits_ModeA[] = {
71 // ENCODER: UINT64_C(2), // bar
72 // ENCODER: UINT64_C(12), // foo
74 // ENCODER-LABEL: static const uint64_t InstBits_ModeB[] = {
75 // ENCODER: UINT64_C(2), // bar
76 // ENCODER: UINT64_C(3), // foo
78 // ENCODER: case ::foo: {
79 // ENCODER: switch (HwMode) {
80 // ENCODER: default: llvm_unreachable("Unhandled HwMode");