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 5 6// Test duplicate table suppression for per-HwMode decoders. 7 8include "llvm/Target/Target.td" 9 10def archInstrInfo : InstrInfo { } 11 12def arch : Target { 13 let InstructionSet = archInstrInfo; 14} 15 16def Myi32 : Operand<i32> { 17 let DecoderMethod = "DecodeMyi32"; 18} 19 20def HasA : Predicate<"Subtarget->hasA()">; 21def HasB : Predicate<"Subtarget->hasB()">; 22 23def ModeA : HwMode<"+a", [HasA]>; 24def ModeB : HwMode<"+b", [HasB]>; 25 26 27def fooTypeEncA : InstructionEncoding { 28 let Size = 4; 29 field bits<32> SoftFail = 0; 30 bits<32> Inst; 31 bits<8> factor; 32 let Inst{7...0} = factor; 33 let Inst{3...2} = 0b11; 34 let Inst{1...0} = 0b00; 35} 36 37def fooTypeEncB : InstructionEncoding { 38 let Size = 4; 39 field bits<32> SoftFail = 0; 40 bits<32> Inst; 41 bits<8> factor; 42 let Inst{15...8} = factor; 43 let Inst{1...0} = 0b11; 44} 45 46let OutOperandList = (outs) in { 47 def foo : Instruction { 48 let InOperandList = (ins i32imm:$factor); 49 let EncodingInfos = EncodingByHwMode< 50 [ModeA, ModeB], [fooTypeEncA, fooTypeEncB] 51 >; 52 let AsmString = "foo $factor"; 53 } 54 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); 61 let Size = 4; 62 bits<32> Inst; 63 bits<32> SoftFail; 64 bits<8> factor; 65 let Inst{31...24} = factor; 66 let Inst{1...0} = 0b10; 67 let AsmString = "bar $factor"; 68 } 69 70 def baz : Instruction { 71 let InOperandList = (ins i32imm:$factor); 72 bits<32> Inst; 73 let EncodingInfos = EncodingByHwMode< 74 [ModeB], [fooTypeEncA] 75 >; 76 let AsmString = "foo $factor"; 77 } 78 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); 86 let Size = 4; 87 bits<32> Inst; 88 bits<32> SoftFail; 89 bits<8> factor; 90 let Inst{31...24} = factor; 91 let Inst{1...0} = 0b10; 92 let AsmString = "unrelated $factor"; 93 } 94} 95 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 107 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 119