93 lines · plain
1// RUN: llvm-tblgen -gen-emitter -I %p/../../include %s | FileCheck %s --check-prefix=ENCODER2// RUN: llvm-tblgen -gen-disassembler -I %p/../../include %s | FileCheck %s --check-prefix=DECODER3 4include "llvm/Target/Target.td"5 6def archInstrInfo : InstrInfo { }7 8def arch : Target {9 let InstructionSet = archInstrInfo;10}11 12def Myi32 : Operand<i32> {13 let DecoderMethod = "DecodeMyi32";14}15 16def HasA : Predicate<"Subtarget->hasA()">;17def HasB : Predicate<"Subtarget->hasB()">;18 19def ModeA : HwMode<[HasA]>;20def ModeB : HwMode<[HasB]>;21 22 23def fooTypeEncA : InstructionEncoding {24 let Size = 4;25 field bits<32> SoftFail = 0;26 bits<32> Inst;27 bits<8> factor;28 let Inst{7...0} = factor;29 let Inst{3...2} = 0b11;30 let Inst{1...0} = 0b00;31}32 33def fooTypeEncB : InstructionEncoding {34 let Size = 4;35 field bits<32> SoftFail = 0;36 bits<32> Inst;37 bits<8> factor;38 let Inst{15...8} = factor;39 let Inst{1...0} = 0b11;40}41 42let OutOperandList = (outs) in {43def foo : Instruction {44 let InOperandList = (ins i32imm:$factor);45 let EncodingInfos = EncodingByHwMode<46 [ModeA, ModeB], [fooTypeEncA,47 fooTypeEncB]48 >;49 let AsmString = "foo $factor";50}51 52def bar: Instruction {53 let InOperandList = (ins i32imm:$factor);54 let Size = 4;55 bits<32> Inst;56 bits<32> SoftFail;57 bits<8> factor;58 let Inst{31...24} = factor;59 let Inst{1...0} = 0b10;60 let AsmString = "bar $factor";61}62 63def baz : Instruction {64 let InOperandList = (ins i32imm:$factor);65 bits<32> Inst;66 let EncodingInfos = EncodingByHwMode<67 [ModeB], [fooTypeEncA]68 >;69 let AsmString = "foo $factor";70}71}72 73// DECODER-LABEL: DecoderTable_ModeA3274// DECODER-DAG: decode to fooTypeEncA:foo75// DECODER-DAG: decode to bar76// DECODER-LABEL: DecoderTable_ModeB3277// DECODER-DAG: decode to fooTypeEncA:baz78// DECODER-DAG: decode to bar79// DECODER-DAG: decode to fooTypeEncB:foo80 81// ENCODER-LABEL: static const uint64_t InstBits_ModeA[] = {82// ENCODER: UINT64_C(2), // bar83// ENCODER: UINT64_C(12), // foo84 85// ENCODER-LABEL: static const uint64_t InstBits_ModeB[] = {86// ENCODER: UINT64_C(2), // bar87// ENCODER: UINT64_C(3), // foo88 89// ENCODER: case ::foo: {90// ENCODER: switch (HwMode) {91// ENCODER: default: llvm_unreachable("Unhandled HwMode");92// ENCODER: case 1: {93