brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.4 KiB · ef15b6b Raw
86 lines · plain
1// RUN: not llvm-tblgen -gen-disassembler -I %p/../../../include %s 2>&1 | FileCheck %s --implicit-check-not=error:2 3include "llvm/Target/Target.td"4 5def ArchInstrInfo : InstrInfo { }6 7def Arch : Target {8  let InstructionSet = ArchInstrInfo;9}10 11def Reg : Register<"reg">;12 13def Regs : RegisterClass<"foo", [i32], 0, (add Reg)>;14 15def complex_nodec1 : Operand<i32> {16  let MIOperandInfo = (ops Regs);17}18 19def complex_nodec2 : Operand<i32> {20  let MIOperandInfo = (ops Regs, Regs);21}22 23def complex_withdec1 : Operand<i32> {24  let MIOperandInfo = (ops Regs);25  let DecoderMethod = "DecodeComplex";26}27 28def complex_withdec2 : Operand<i32> {29  let MIOperandInfo = (ops Regs, Regs);30  let DecoderMethod = "DecodeComplex";31}32 33class ArchInstr : Instruction {34  let Size = 2;35  bits<16> Inst;36}37 38// This definition is broken in both directions:39// 1. Uses a complex operand without a decoder, and without named sub-ops.40// 2. Uses a complex operand with named sub-ops, but with a decoder as well.41 42// CHECK: error: DecoderEmitter: operand "r1c" has non-empty MIOperandInfo, but doesn't have a custom decoder!43// CHECK: note: Dumping record for previous error:44// CHECK: error: DecoderEmitter: operand "r2b" has non-empty MIOperandInfo, but doesn't have a custom decoder!45// CHECK: note: Dumping record for previous error:46// CHECK: error: DecoderEmitter: operand "r1" has type "complex_withdec2" with a custom DecoderMethod, but also named sub-operands.47// CHECK: error: DecoderEmitter: operand "r2" has type "complex_withdec1" with a custom DecoderMethod, but also named sub-operands.48def foo1 : ArchInstr {49  bits<2> r1a;50  bits<2> r1b;51  bits<2> r1c;52  bits<2> r2a;53  bits<2> r2b;54 55  let Inst{1-0} = r1a;56  let Inst{3-2} = r1b;57  let Inst{5-4} = r1c;58  let Inst{7-6} = r2a;59  let Inst{9-8} = r2b;60  let Inst{11-10} = 0b00;61 62  let OutOperandList = (outs complex_nodec2:$r1c, complex_nodec1:$r2b);63  let InOperandList = (ins (complex_withdec2 $r1a, $r1b):$r1,64                           (complex_withdec1 $r2a):$r2);65}66 67// This definition has no errors.68def foo2 : ArchInstr {69  bits<2> r2a;70  bits<2> r2b;71  bits<2> r2c;72  bits<2> r1a;73  bits<2> r1b;74 75  let Inst{1-0} = r2a;76  let Inst{3-2} = r2b;77  let Inst{5-4} = r2c;78  let Inst{7-6} = r1a;79  let Inst{9-8} = r1b;80  let Inst{11-10} = 0b01;81 82  let OutOperandList = (outs complex_withdec2:$r2c, complex_withdec1:$r1b);83  let InOperandList = (ins (complex_nodec2 $r2a, $r2b):$r2,84                           (complex_nodec1 $r1a):$r1);85}86