Home | History | Annotate | Download | only in TableGen
      1 // RUN: llvm-tblgen -gen-instr-info -I %p/../../include %s | FileCheck %s
      2 
      3 // CHECK: ABCForm_A
      4 // CHECK-NOT: ABCForm_A
      5 
      6 //
      7 // include Target.td for InstrMapping class and define minimally required objects
      8 //
      9 
     10 include "llvm/Target/Target.td"
     11 
     12 class DFVReg<string n> : Register<n> {
     13   let Namespace = "DFV";
     14 }
     15 
     16 def R0 : DFVReg<"r0">;
     17 def DFVRegClass : RegisterClass<"DFV",[i32],0,(add R0)>;
     18 def DFVInstrInfo : InstrInfo;
     19 
     20 def DFVTest : Target {
     21   let InstructionSet = DFVInstrInfo;
     22 }
     23 
     24 //
     25 // Define a number of a InstrMappings with repeated ValueCol fields
     26 //
     27 
     28 class ABCRel;
     29 
     30 def getAFormFromBForm : InstrMapping {
     31   let FilterClass = "ABCRel";
     32   let RowFields = ["BaseName"];
     33   let ColFields = ["ABCForm"];
     34   let KeyCol = ["B"];
     35   let ValueCols = [["A"]];
     36 }
     37 
     38 def getAFormFromCForm : InstrMapping {
     39   let FilterClass = "ABCRel";
     40   let RowFields = ["BaseName"];
     41   let ColFields = ["ABCForm"];
     42   let KeyCol = ["C"];
     43   let ValueCols = [["A"]];
     44 }
     45 
     46 def getAFormFromDForm : InstrMapping {
     47   let FilterClass = "ABCRel";
     48   let RowFields = ["BaseName"];
     49   let ColFields = ["ABCForm"];
     50   let KeyCol = ["D"];
     51   let ValueCols = [["A"]];
     52 }
     53 
     54 def getAFormFromEForm : InstrMapping {
     55   let FilterClass = "ABCRel";
     56   let RowFields = ["BaseName"];
     57   let ColFields = ["ABCForm"];
     58   let KeyCol = ["E"];
     59   let ValueCols = [["A"]];
     60 }
     61 
     62 class I : Instruction {
     63   let Namespace = "DFV";
     64   let OutOperandList = (outs);
     65   let InOperandList = (ins);
     66 
     67   string BaseName = "";
     68   string ABCForm = "";
     69 }
     70 
     71 class isAForm { string ABCForm = "A"; }
     72 class isBForm { string ABCForm = "B"; }
     73 class isCForm { string ABCForm = "C"; }
     74 class isDForm { string ABCForm = "D"; }
     75 class isEForm { string ABCForm = "E"; }
     76 
     77 let BaseName = "0" in {
     78   def A0 : I, ABCRel, isAForm;
     79   def B0 : I, ABCRel, isBForm;
     80   def C0 : I, ABCRel, isCForm;
     81   def D0 : I, ABCRel, isDForm;
     82   def E0 : I, ABCRel, isEForm;
     83 }
     84 
     85