1 // RUN: llvm-tblgen -gen-disassembler -I %p/../../include %s | \
2 // RUN: FileCheck %s --check-prefix=DECODER
3 // RUN: llvm-tblgen -gen-disassembler --suppress-per-hwmode-duplicates=O2 -I \
4 // RUN: %p/../../include %s | FileCheck %s --check-prefix=DECODER-SUPPRESS
6 // Test duplicate table suppression for per-HwMode decoders.
8 include "llvm/Target/Target.td"
10 def archInstrInfo : InstrInfo { }
13 let InstructionSet = archInstrInfo;
16 def Myi32 : Operand<i32> {
17 let DecoderMethod = "DecodeMyi32";
20 def HasA : Predicate<"Subtarget->hasA()">;
21 def HasB : Predicate<"Subtarget->hasB()">;
23 def ModeA : HwMode<"+a", [HasA]>;
24 def ModeB : HwMode<"+b", [HasB]>;
27 def fooTypeEncA : InstructionEncoding {
29 field bits<32> SoftFail = 0;
32 let Inst{7...0} = factor;
33 let Inst{3...2} = 0b11;
34 let Inst{1...0} = 0b00;
37 def fooTypeEncB : InstructionEncoding {
39 field bits<32> SoftFail = 0;
42 let Inst{15...8} = factor;
43 let Inst{1...0} = 0b11;
46 let OutOperandList = (outs) in {
47 def foo : Instruction {
48 let InOperandList = (ins i32imm:$factor);
49 let EncodingInfos = EncodingByHwMode<
50 [ModeA, ModeB], [fooTypeEncA, fooTypeEncB]
52 let AsmString = "foo $factor";
55 // Encoding not overridden, same namespace:
56 // In the default case, this instruction is duplicated into both ModeA and
57 // ModeB decoder tables.
58 // In the suppressed case, this instruction appears in a single decoder table.
59 def bar: Instruction {
60 let InOperandList = (ins i32imm:$factor);
65 let Inst{31...24} = factor;
66 let Inst{1...0} = 0b10;
67 let AsmString = "bar $factor";
70 def baz : Instruction {
71 let InOperandList = (ins i32imm:$factor);
73 let EncodingInfos = EncodingByHwMode<
74 [ModeB], [fooTypeEncA]
76 let AsmString = "foo $factor";
79 // Encoding not overridden, different namespace:
80 // In the default case, this instruction is duplicated into two Alt decoder
81 // tables (ModeA and ModeB).
82 // In the suppressed case, this instruction appears in a single decoder table.
83 def unrelated: Instruction {
84 let DecoderNamespace = "Alt";
85 let InOperandList = (ins i32imm:$factor);
90 let Inst{31...24} = factor;
91 let Inst{1...0} = 0b10;
92 let AsmString = "unrelated $factor";
96 // DECODER-LABEL: DecoderTableAlt_ModeA32[] =
97 // DECODER-DAG: Opcode: unrelated
98 // DECODER-LABEL: DecoderTableAlt_ModeB32[] =
99 // DECODER-DAG: Opcode: unrelated
100 // DECODER-LABEL: DecoderTable_ModeA32[] =
101 // DECODER-DAG: Opcode: fooTypeEncA:foo
102 // DECODER-DAG: Opcode: bar
103 // DECODER-LABEL: DecoderTable_ModeB32[] =
104 // DECODER-DAG: Opcode: fooTypeEncB:foo
105 // DECODER-DAG: Opcode: fooTypeEncA:baz
106 // DECODER-DAG: Opcode: bar
108 // DECODER-SUPPRESS-LABEL: DecoderTable32[] =
109 // DECODER-SUPPRESS-DAG: Opcode: bar
110 // DECODER-SUPPRESS-LABEL: DecoderTableAlt32[] =
111 // DECODER-SUPPRESS-DAG: Opcode: unrelated
112 // DECODER-SUPPRESS-LABEL: DecoderTable_ModeA32[] =
113 // DECODER-SUPPRESS-DAG: Opcode: fooTypeEncA:foo
114 // DECODER-SUPPRESS-NOT: Opcode: bar
115 // DECODER-SUPPRESS-LABEL: DecoderTable_ModeB32[] =
116 // DECODER-SUPPRESS-DAG: Opcode: fooTypeEncB:foo
117 // DECODER-SUPPRESS-DAG: Opcode: fooTypeEncA:baz
118 // DECODER-SUPPRESS-NOT: Opcode: bar