119 lines · plain
1// RUN: llvm-tblgen -gen-disassembler -I %p/../../include %s | \2// RUN: FileCheck %s --check-prefix=DECODER3// RUN: llvm-tblgen -gen-disassembler --suppress-per-hwmode-duplicates=O2 -I \4// RUN: %p/../../include %s | FileCheck %s --check-prefix=DECODER-SUPPRESS5 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<[HasA]>;24def ModeB : HwMode<[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 and57 // 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 decoder81 // 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: DecoderTable_ModeA3297// DECODER-DAG: decode to fooTypeEncA:foo98// DECODER-DAG: decode to bar99// DECODER-LABEL: DecoderTable_ModeB32100// DECODER-DAG: decode to fooTypeEncB:foo101// DECODER-DAG: decode to fooTypeEncA:baz102// DECODER-DAG: decode to bar103// DECODER-LABEL: DecoderTableAlt_ModeA32104// DECODER-DAG: decode to unrelated105// DECODER-LABEL: DecoderTableAlt_ModeB32106// DECODER-DAG: decode to unrelated107 108// DECODER-SUPPRESS-LABEL: DecoderTable32109// DECODER-SUPPRESS-DAG: decode to bar110// DECODER-SUPPRESS-LABEL: DecoderTable_ModeA32111// DECODER-SUPPRESS-DAG: decode to fooTypeEncA:foo112// DECODER-SUPPRESS-NOT: decode to bar113// DECODER-SUPPRESS-LABEL: DecoderTable_ModeB32114// DECODER-SUPPRESS-DAG: decode to fooTypeEncB:foo115// DECODER-SUPPRESS-DAG: decode to fooTypeEncA:baz116// DECODER-SUPPRESS-NOT: decode to bar117// DECODER-SUPPRESS-LABEL: DecoderTableAlt32118// DECODER-SUPPRESS-DAG: decode to unrelated119