Home | History | Annotate | Download | only in TableGen
      1 // RUN: llvm-tblgen --gen-fast-isel -I %p/../../include %s 2>&1 | FileCheck %s
      2 
      3 include "llvm/Target/Target.td"
      4 
      5 //===- Define the necessary boilerplate for our test target. --------------===//
      6 
      7 def MyTargetISA : InstrInfo;
      8 def MyTarget : Target { let InstructionSet = MyTargetISA; }
      9 
     10 def R0 : Register<"r0"> { let Namespace = "MyTarget"; }
     11 def R1 : Register<"r0"> { let Namespace = "MyTarget"; }
     12 def GPR32M : RegisterClass<"MyTarget", [i32], 32, (add R0)>;
     13 def GPR32MOp : RegisterOperand<GPR32M>;
     14 
     15 def GPR32 : RegisterClass<"MyTarget", [i32], 32, (add R0, R1)>;
     16 def GPR32Op : RegisterOperand<GPR32>;
     17 
     18 class I<dag OOps, dag IOps, list<dag> Pat> : Instruction {
     19   let Namespace = "MyTarget";
     20   let OutOperandList = OOps;
     21   let InOperandList = IOps;
     22   let Pattern = Pat;
     23 }
     24 
     25 def HasA : Predicate<"Subtarget->hasA()">;
     26 
     27 let Predicates = [HasA] in {
     28 
     29   def ADD : I<(outs GPR32Op:$rd), (ins GPR32Op:$rs, GPR32Op:$rt),
     30               [(set GPR32Op:$rd, (add GPR32Op:$rs, GPR32Op:$rt))]>;
     31 
     32   let FastISelShouldIgnore = 1 in
     33     def ADD_M : I<(outs GPR32MOp:$rd), (ins GPR32MOp:$rs, GPR32MOp:$rt),
     34                   [(set GPR32MOp:$rd, (add GPR32MOp:$rs, GPR32MOp:$rt))]>;
     35 }
     36 
     37 // CHECK-NOT: error: Duplicate predicate in FastISel table!
     38