Home | History | Annotate | Download | only in PowerPC
      1 //===- PowerPCInstrFormats.td - PowerPC Instruction Formats --*- tablegen -*-=//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 //===----------------------------------------------------------------------===//
     11 //
     12 // PowerPC instruction formats
     13 
     14 class I<bits<6> opcode, dag OOL, dag IOL, string asmstr, InstrItinClass itin>
     15         : Instruction {
     16   field bits<32> Inst;
     17 
     18   bit PPC64 = 0;  // Default value, override with isPPC64
     19 
     20   let Namespace = "PPC";
     21   let Inst{0-5} = opcode;
     22   let OutOperandList = OOL;
     23   let InOperandList = IOL;
     24   let AsmString = asmstr;
     25   let Itinerary = itin;
     26 
     27   bits<1> PPC970_First = 0;
     28   bits<1> PPC970_Single = 0;
     29   bits<1> PPC970_Cracked = 0;
     30   bits<3> PPC970_Unit = 0;
     31 
     32   /// These fields correspond to the fields in PPCInstrInfo.h.  Any changes to
     33   /// these must be reflected there!  See comments there for what these are.
     34   let TSFlags{0}   = PPC970_First;
     35   let TSFlags{1}   = PPC970_Single;
     36   let TSFlags{2}   = PPC970_Cracked;
     37   let TSFlags{5-3} = PPC970_Unit;
     38 
     39   // Fields used for relation models.
     40   string BaseName = "";
     41 
     42   // For cases where multiple instruction definitions really represent the
     43   // same underlying instruction but with one definition for 64-bit arguments
     44   // and one for 32-bit arguments, this bit breaks the degeneracy between
     45   // the two forms and allows TableGen to generate mapping tables.
     46   bit Interpretation64Bit = 0;
     47 }
     48 
     49 class PPC970_DGroup_First   { bits<1> PPC970_First = 1;  }
     50 class PPC970_DGroup_Single  { bits<1> PPC970_Single = 1; }
     51 class PPC970_DGroup_Cracked { bits<1> PPC970_Cracked = 1; }
     52 class PPC970_MicroCode;
     53 
     54 class PPC970_Unit_Pseudo   { bits<3> PPC970_Unit = 0;   }
     55 class PPC970_Unit_FXU      { bits<3> PPC970_Unit = 1;   }
     56 class PPC970_Unit_LSU      { bits<3> PPC970_Unit = 2;   }
     57 class PPC970_Unit_FPU      { bits<3> PPC970_Unit = 3;   }
     58 class PPC970_Unit_CRU      { bits<3> PPC970_Unit = 4;   }
     59 class PPC970_Unit_VALU     { bits<3> PPC970_Unit = 5;   }
     60 class PPC970_Unit_VPERM    { bits<3> PPC970_Unit = 6;   }
     61 class PPC970_Unit_BRU      { bits<3> PPC970_Unit = 7;   }
     62 
     63 // Two joined instructions; used to emit two adjacent instructions as one.
     64 // The itinerary from the first instruction is used for scheduling and
     65 // classification.
     66 class I2<bits<6> opcode1, bits<6> opcode2, dag OOL, dag IOL, string asmstr,
     67          InstrItinClass itin>
     68         : Instruction {
     69   field bits<64> Inst;
     70 
     71   bit PPC64 = 0;  // Default value, override with isPPC64
     72 
     73   let Namespace = "PPC";
     74   let Inst{0-5} = opcode1;
     75   let Inst{32-37} = opcode2;
     76   let OutOperandList = OOL;
     77   let InOperandList = IOL;
     78   let AsmString = asmstr;
     79   let Itinerary = itin;
     80 
     81   bits<1> PPC970_First = 0;
     82   bits<1> PPC970_Single = 0;
     83   bits<1> PPC970_Cracked = 0;
     84   bits<3> PPC970_Unit = 0;
     85 
     86   /// These fields correspond to the fields in PPCInstrInfo.h.  Any changes to
     87   /// these must be reflected there!  See comments there for what these are.
     88   let TSFlags{0}   = PPC970_First;
     89   let TSFlags{1}   = PPC970_Single;
     90   let TSFlags{2}   = PPC970_Cracked;
     91   let TSFlags{5-3} = PPC970_Unit;
     92 
     93   // Fields used for relation models.
     94   string BaseName = "";
     95   bit Interpretation64Bit = 0;
     96 }
     97 
     98 // 1.7.1 I-Form
     99 class IForm<bits<6> opcode, bit aa, bit lk, dag OOL, dag IOL, string asmstr,
    100             InstrItinClass itin, list<dag> pattern>
    101          : I<opcode, OOL, IOL, asmstr, itin> {
    102   let Pattern = pattern;
    103   bits<24> LI;
    104 
    105   let Inst{6-29}  = LI;
    106   let Inst{30}    = aa;
    107   let Inst{31}    = lk;
    108 }
    109 
    110 // 1.7.2 B-Form
    111 class BForm<bits<6> opcode, bit aa, bit lk, dag OOL, dag IOL, string asmstr>
    112   : I<opcode, OOL, IOL, asmstr, BrB> {
    113   bits<7> BIBO;  // 2 bits of BI and 5 bits of BO.
    114   bits<3>  CR;
    115   bits<14> BD;
    116 
    117   bits<5> BI;
    118   let BI{0-1} = BIBO{5-6};
    119   let BI{2-4} = CR{0-2};
    120 
    121   let Inst{6-10}  = BIBO{4-0};
    122   let Inst{11-15} = BI;
    123   let Inst{16-29} = BD;
    124   let Inst{30}    = aa;
    125   let Inst{31}    = lk;
    126 }
    127 
    128 class BForm_1<bits<6> opcode, bits<5> bo, bit aa, bit lk, dag OOL, dag IOL,
    129              string asmstr>
    130   : BForm<opcode, aa, lk, OOL, IOL, asmstr> {
    131   let BIBO{4-0} = bo;
    132   let BIBO{6-5} = 0;
    133   let CR = 0;
    134 }
    135 
    136 class BForm_2<bits<6> opcode, bits<5> bo, bits<5> bi, bit aa, bit lk,
    137               dag OOL, dag IOL, string asmstr>
    138   : I<opcode, OOL, IOL, asmstr, BrB> {
    139   bits<14> BD;
    140 
    141   let Inst{6-10}  = bo;
    142   let Inst{11-15} = bi;
    143   let Inst{16-29} = BD;
    144   let Inst{30}    = aa;
    145   let Inst{31}    = lk;
    146 }
    147 
    148 class BForm_3<bits<6> opcode, bit aa, bit lk,
    149               dag OOL, dag IOL, string asmstr>
    150   : I<opcode, OOL, IOL, asmstr, BrB> {
    151   bits<5> BO;
    152   bits<5> BI;
    153   bits<14> BD;
    154 
    155   let Inst{6-10}  = BO;
    156   let Inst{11-15} = BI;
    157   let Inst{16-29} = BD;
    158   let Inst{30}    = aa;
    159   let Inst{31}    = lk;
    160 }
    161 
    162 // 1.7.3 SC-Form
    163 class SCForm<bits<6> opcode, bits<1> xo,
    164                      dag OOL, dag IOL, string asmstr, InstrItinClass itin,
    165                      list<dag> pattern>
    166   : I<opcode, OOL, IOL, asmstr, itin> {
    167   bits<7>  LEV;
    168 
    169   let Pattern = pattern;
    170 
    171   let Inst{20-26} = LEV;
    172   let Inst{30}    = xo;
    173 }
    174 
    175 // 1.7.4 D-Form
    176 class DForm_base<bits<6> opcode, dag OOL, dag IOL, string asmstr,
    177                  InstrItinClass itin, list<dag> pattern> 
    178   : I<opcode, OOL, IOL, asmstr, itin> {
    179   bits<5>  A;
    180   bits<5>  B;
    181   bits<16> C;
    182 
    183   let Pattern = pattern;
    184   
    185   let Inst{6-10}  = A;
    186   let Inst{11-15} = B;
    187   let Inst{16-31} = C;
    188 }
    189 
    190 class DForm_1<bits<6> opcode, dag OOL, dag IOL, string asmstr,
    191               InstrItinClass itin, list<dag> pattern>
    192   : I<opcode, OOL, IOL, asmstr, itin> {
    193   bits<5>  A;
    194   bits<21> Addr;
    195 
    196   let Pattern = pattern;
    197   
    198   let Inst{6-10}  = A;
    199   let Inst{11-15} = Addr{20-16}; // Base Reg
    200   let Inst{16-31} = Addr{15-0};  // Displacement
    201 }
    202 
    203 class DForm_1a<bits<6> opcode, dag OOL, dag IOL, string asmstr,
    204                InstrItinClass itin, list<dag> pattern>
    205   : I<opcode, OOL, IOL, asmstr, itin> {
    206   bits<5>  A;
    207   bits<16> C;
    208   bits<5>  B;
    209 
    210   let Pattern = pattern;
    211   
    212   let Inst{6-10}  = A;
    213   let Inst{11-15} = B;
    214   let Inst{16-31} = C;
    215 }
    216 
    217 
    218 class DForm_2<bits<6> opcode, dag OOL, dag IOL, string asmstr,
    219               InstrItinClass itin, list<dag> pattern>
    220   : DForm_base<opcode, OOL, IOL, asmstr, itin, pattern> {
    221 
    222   // Even though ADDICo does not really have an RC bit, provide
    223   // the declaration of one here so that isDOT has something to set.
    224   bit RC = 0;
    225 }
    226 
    227 class DForm_2_r0<bits<6> opcode, dag OOL, dag IOL, string asmstr,
    228                  InstrItinClass itin, list<dag> pattern>
    229   : I<opcode, OOL, IOL, asmstr, itin> {
    230   bits<5>  A;
    231   bits<16> B;
    232   
    233   let Pattern = pattern;
    234   
    235   let Inst{6-10}  = A;
    236   let Inst{11-15} = 0;
    237   let Inst{16-31} = B;
    238 }
    239 
    240 class DForm_4<bits<6> opcode, dag OOL, dag IOL, string asmstr,
    241               InstrItinClass itin, list<dag> pattern>
    242   : I<opcode, OOL, IOL, asmstr, itin> {
    243   bits<5>  B;
    244   bits<5>  A;
    245   bits<16> C;
    246   
    247   let Pattern = pattern;
    248   
    249   let Inst{6-10}  = A;
    250   let Inst{11-15} = B;
    251   let Inst{16-31} = C;
    252 }
    253               
    254 class DForm_4_zero<bits<6> opcode, dag OOL, dag IOL, string asmstr,
    255                    InstrItinClass itin, list<dag> pattern>
    256   : DForm_1<opcode, OOL, IOL, asmstr, itin, pattern> {
    257   let A = 0;
    258   let Addr = 0;
    259 }
    260 
    261 class IForm_and_DForm_1<bits<6> opcode1, bit aa, bit lk, bits<6> opcode2,
    262             dag OOL, dag IOL, string asmstr,
    263             InstrItinClass itin, list<dag> pattern>
    264          : I2<opcode1, opcode2, OOL, IOL, asmstr, itin> {
    265   bits<5>  A;
    266   bits<21> Addr;
    267 
    268   let Pattern = pattern;
    269   bits<24> LI;
    270 
    271   let Inst{6-29}  = LI;
    272   let Inst{30}    = aa;
    273   let Inst{31}    = lk;
    274 
    275   let Inst{38-42}  = A;
    276   let Inst{43-47} = Addr{20-16}; // Base Reg
    277   let Inst{48-63} = Addr{15-0};  // Displacement
    278 }
    279 
    280 // This is used to emit BL8+NOP.
    281 class IForm_and_DForm_4_zero<bits<6> opcode1, bit aa, bit lk, bits<6> opcode2,
    282             dag OOL, dag IOL, string asmstr,
    283             InstrItinClass itin, list<dag> pattern>
    284          :  IForm_and_DForm_1<opcode1, aa, lk, opcode2,
    285                               OOL, IOL, asmstr, itin, pattern> {
    286   let A = 0;
    287   let Addr = 0;
    288 }
    289 
    290 class DForm_5<bits<6> opcode, dag OOL, dag IOL, string asmstr,
    291               InstrItinClass itin>
    292   : I<opcode, OOL, IOL, asmstr, itin> {
    293   bits<3>  BF;
    294   bits<1>  L;
    295   bits<5>  RA;
    296   bits<16> I;
    297 
    298   let Inst{6-8}   = BF;
    299   let Inst{9}     = 0;
    300   let Inst{10}    = L;
    301   let Inst{11-15} = RA;
    302   let Inst{16-31} = I;
    303 }
    304 
    305 class DForm_5_ext<bits<6> opcode, dag OOL, dag IOL, string asmstr,
    306                   InstrItinClass itin>
    307   : DForm_5<opcode, OOL, IOL, asmstr, itin> {
    308   let L = PPC64;
    309 }
    310 
    311 class DForm_6<bits<6> opcode, dag OOL, dag IOL, string asmstr,
    312               InstrItinClass itin> 
    313   : DForm_5<opcode, OOL, IOL, asmstr, itin>;
    314 
    315 class DForm_6_ext<bits<6> opcode, dag OOL, dag IOL, string asmstr,
    316                   InstrItinClass itin>
    317   : DForm_6<opcode, OOL, IOL, asmstr, itin> {
    318   let L = PPC64;
    319 }
    320 
    321 
    322 // 1.7.5 DS-Form
    323 class DSForm_1<bits<6> opcode, bits<2> xo, dag OOL, dag IOL, string asmstr,
    324                InstrItinClass itin, list<dag> pattern>
    325          : I<opcode, OOL, IOL, asmstr, itin> {
    326   bits<5>  RST;
    327   bits<19> DS_RA;
    328 
    329   let Pattern = pattern;
    330   
    331   let Inst{6-10}  = RST;
    332   let Inst{11-15} = DS_RA{18-14};  // Register #
    333   let Inst{16-29} = DS_RA{13-0};   // Displacement.
    334   let Inst{30-31} = xo;
    335 }
    336 
    337 class DSForm_1a<bits<6> opcode, bits<2> xo, dag OOL, dag IOL, string asmstr,
    338                 InstrItinClass itin, list<dag> pattern>
    339          : I<opcode, OOL, IOL, asmstr, itin> {
    340    bits<5>  RST;
    341    bits<14> DS;
    342    bits<5>  RA;
    343  
    344    let Pattern = pattern;
    345    
    346    let Inst{6-10}  = RST;
    347    let Inst{11-15} = RA;
    348    let Inst{16-29} = DS;
    349    let Inst{30-31} = xo;
    350 }
    351 
    352 // 1.7.6 X-Form
    353 class XForm_base_r3xo<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr, 
    354                       InstrItinClass itin, list<dag> pattern>
    355   : I<opcode, OOL, IOL, asmstr, itin> {
    356   bits<5> RST;
    357   bits<5> A;
    358   bits<5> B;
    359 
    360   let Pattern = pattern;
    361 
    362   bit RC = 0;    // set by isDOT
    363 
    364   let Inst{6-10}  = RST;
    365   let Inst{11-15} = A;
    366   let Inst{16-20} = B;
    367   let Inst{21-30} = xo;
    368   let Inst{31}    = RC;
    369 }
    370 
    371 // This is the same as XForm_base_r3xo, but the first two operands are swapped
    372 // when code is emitted.
    373 class XForm_base_r3xo_swapped
    374         <bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
    375         InstrItinClass itin> 
    376   : I<opcode, OOL, IOL, asmstr, itin> {
    377   bits<5> A;
    378   bits<5> RST;
    379   bits<5> B;
    380 
    381   bit RC = 0;    // set by isDOT
    382 
    383   let Inst{6-10}  = RST;
    384   let Inst{11-15} = A;
    385   let Inst{16-20} = B;
    386   let Inst{21-30} = xo;
    387   let Inst{31}    = RC;
    388 }
    389 
    390 
    391 class XForm_1<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
    392               InstrItinClass itin, list<dag> pattern> 
    393   : XForm_base_r3xo<opcode, xo, OOL, IOL, asmstr, itin, pattern>;
    394 
    395 class XForm_1a<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
    396               InstrItinClass itin, list<dag> pattern>
    397   : XForm_base_r3xo<opcode, xo, OOL, IOL, asmstr, itin, pattern> {
    398   let RST = 0;
    399 }
    400 
    401 class XForm_6<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
    402               InstrItinClass itin, list<dag> pattern> 
    403   : XForm_base_r3xo_swapped<opcode, xo, OOL, IOL, asmstr, itin> {
    404   let Pattern = pattern;
    405 }
    406 
    407 class XForm_8<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
    408               InstrItinClass itin, list<dag> pattern> 
    409   : XForm_base_r3xo<opcode, xo, OOL, IOL, asmstr, itin, pattern>;
    410 
    411 class XForm_10<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
    412                InstrItinClass itin, list<dag> pattern> 
    413   : XForm_base_r3xo_swapped<opcode, xo, OOL, IOL, asmstr, itin> {
    414     let Pattern = pattern;
    415 }
    416 
    417 class XForm_11<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
    418                InstrItinClass itin, list<dag> pattern> 
    419   : XForm_base_r3xo_swapped<opcode, xo, OOL, IOL, asmstr, itin> {
    420   let B = 0;
    421   let Pattern = pattern;
    422 }
    423 
    424 class XForm_16<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
    425                InstrItinClass itin>
    426          : I<opcode, OOL, IOL, asmstr, itin> {
    427   bits<3> BF;
    428   bits<1> L; 
    429   bits<5> RA;
    430   bits<5> RB;
    431   
    432   let Inst{6-8}   = BF;
    433   let Inst{9}     = 0;
    434   let Inst{10}    = L;
    435   let Inst{11-15} = RA;
    436   let Inst{16-20} = RB;
    437   let Inst{21-30} = xo;
    438   let Inst{31}    = 0;
    439 }
    440 
    441 class XForm_16_ext<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
    442                    InstrItinClass itin>
    443   : XForm_16<opcode, xo, OOL, IOL, asmstr, itin> {
    444   let L = PPC64;
    445 }
    446 
    447 class XForm_17<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
    448                InstrItinClass itin>
    449          : I<opcode, OOL, IOL, asmstr, itin> {
    450   bits<3> BF;
    451   bits<5> FRA;
    452   bits<5> FRB;
    453   
    454   let Inst{6-8}   = BF;
    455   let Inst{9-10}  = 0;
    456   let Inst{11-15} = FRA;
    457   let Inst{16-20} = FRB;
    458   let Inst{21-30} = xo;
    459   let Inst{31}    = 0;
    460 }
    461 
    462 class XForm_24<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
    463                InstrItinClass itin, list<dag> pattern> 
    464   : I<opcode, OOL, IOL, asmstr, itin> {
    465   let Pattern = pattern;
    466   let Inst{6-10}  = 31;
    467   let Inst{11-15} = 0;
    468   let Inst{16-20} = 0;
    469   let Inst{21-30} = xo;
    470   let Inst{31}    = 0;
    471 }
    472 
    473 class XForm_24_sync<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
    474                string asmstr, InstrItinClass itin, list<dag> pattern> 
    475   : I<opcode, OOL, IOL, asmstr, itin> {
    476   bits<2> L;
    477 
    478   let Pattern = pattern;
    479   let Inst{6-8}   = 0;
    480   let Inst{9-10}  = L;
    481   let Inst{11-15} = 0;
    482   let Inst{16-20} = 0;
    483   let Inst{21-30} = xo;
    484   let Inst{31}    = 0;
    485 }
    486 
    487 class XForm_24_eieio<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
    488                string asmstr, InstrItinClass itin, list<dag> pattern> 
    489   : XForm_24_sync<opcode, xo, OOL, IOL, asmstr, itin, pattern> {
    490   let L = 0;
    491 }
    492 
    493 class XForm_25<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
    494                InstrItinClass itin, list<dag> pattern> 
    495   : XForm_base_r3xo<opcode, xo, OOL, IOL, asmstr, itin, pattern> {
    496 }
    497 
    498 class XForm_26<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
    499                InstrItinClass itin, list<dag> pattern>
    500   : XForm_base_r3xo<opcode, xo, OOL, IOL, asmstr, itin, pattern> {
    501   let A = 0;
    502 }
    503 
    504 class XForm_28<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
    505                InstrItinClass itin, list<dag> pattern> 
    506   : XForm_base_r3xo<opcode, xo, OOL, IOL, asmstr, itin, pattern> {
    507 }
    508 
    509 // This is used for MFFS, MTFSB0, MTFSB1.  42 is arbitrary; this series of
    510 // numbers presumably relates to some document, but I haven't found it.
    511 class XForm_42<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
    512               InstrItinClass itin, list<dag> pattern>
    513   : XForm_base_r3xo<opcode, xo, OOL, IOL, asmstr, itin, pattern> {
    514   let Pattern = pattern;
    515 
    516   bit RC = 0;    // set by isDOT
    517 
    518   let Inst{6-10}  = RST;
    519   let Inst{11-20} = 0;
    520   let Inst{21-30} = xo;
    521   let Inst{31}    = RC;
    522 }
    523 class XForm_43<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
    524               InstrItinClass itin, list<dag> pattern>
    525   : XForm_base_r3xo<opcode, xo, OOL, IOL, asmstr, itin, pattern> {
    526   let Pattern = pattern;
    527   bits<5> FM;
    528 
    529   bit RC = 0;    // set by isDOT
    530 
    531   let Inst{6-10}  = FM;
    532   let Inst{11-20} = 0;
    533   let Inst{21-30} = xo;
    534   let Inst{31}    = RC;
    535 }
    536 
    537 // DCB_Form - Form X instruction, used for dcb* instructions.
    538 class DCB_Form<bits<10> xo, bits<5> immfield, dag OOL, dag IOL, string asmstr, 
    539                       InstrItinClass itin, list<dag> pattern>
    540   : I<31, OOL, IOL, asmstr, itin> {
    541   bits<5> A;
    542   bits<5> B;
    543 
    544   let Pattern = pattern;
    545 
    546   let Inst{6-10}  = immfield;
    547   let Inst{11-15} = A;
    548   let Inst{16-20} = B;
    549   let Inst{21-30} = xo;
    550   let Inst{31}    = 0;
    551 }
    552 
    553 
    554 // DSS_Form - Form X instruction, used for altivec dss* instructions.
    555 class DSS_Form<bits<10> xo, dag OOL, dag IOL, string asmstr, 
    556                       InstrItinClass itin, list<dag> pattern>
    557   : I<31, OOL, IOL, asmstr, itin> {
    558   bits<1> T;
    559   bits<2> STRM;
    560   bits<5> A;
    561   bits<5> B;
    562 
    563   let Pattern = pattern;
    564 
    565   let Inst{6}     = T;
    566   let Inst{7-8}   = 0;
    567   let Inst{9-10}  = STRM;
    568   let Inst{11-15} = A;
    569   let Inst{16-20} = B;
    570   let Inst{21-30} = xo;
    571   let Inst{31}    = 0;
    572 }
    573 
    574 // 1.7.7 XL-Form
    575 class XLForm_1<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
    576                InstrItinClass itin, list<dag> pattern>
    577     : I<opcode, OOL, IOL, asmstr, itin> {
    578   bits<5> CRD;
    579   bits<5> CRA;
    580   bits<5> CRB;
    581   
    582   let Pattern = pattern;
    583   
    584   let Inst{6-10}  = CRD;
    585   let Inst{11-15} = CRA;
    586   let Inst{16-20} = CRB;
    587   let Inst{21-30} = xo;
    588   let Inst{31}    = 0;
    589 }
    590 
    591 class XLForm_1_ext<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
    592                InstrItinClass itin, list<dag> pattern>
    593     : I<opcode, OOL, IOL, asmstr, itin> {
    594   bits<5> CRD;
    595   
    596   let Pattern = pattern;
    597   
    598   let Inst{6-10}  = CRD;
    599   let Inst{11-15} = CRD;
    600   let Inst{16-20} = CRD;
    601   let Inst{21-30} = xo;
    602   let Inst{31}    = 0;
    603 }
    604 
    605 class XLForm_2<bits<6> opcode, bits<10> xo, bit lk, dag OOL, dag IOL, string asmstr, 
    606                InstrItinClass itin, list<dag> pattern>
    607     : I<opcode, OOL, IOL, asmstr, itin> {
    608   bits<5> BO;
    609   bits<5> BI;
    610   bits<2> BH;
    611   
    612   let Pattern = pattern;
    613   
    614   let Inst{6-10}  = BO;
    615   let Inst{11-15} = BI;
    616   let Inst{16-18} = 0;
    617   let Inst{19-20} = BH;
    618   let Inst{21-30} = xo;
    619   let Inst{31}    = lk;
    620 }
    621 
    622 class XLForm_2_br<bits<6> opcode, bits<10> xo, bit lk,
    623                   dag OOL, dag IOL, string asmstr, InstrItinClass itin, list<dag> pattern>
    624   : XLForm_2<opcode, xo, lk, OOL, IOL, asmstr, itin, pattern> {
    625   bits<7> BIBO;  // 2 bits of BI and 5 bits of BO.
    626   bits<3>  CR;
    627   
    628   let BO = BIBO{4-0};
    629   let BI{0-1} = BIBO{5-6};
    630   let BI{2-4} = CR{0-2};
    631   let BH = 0;
    632 }
    633 
    634 
    635 class XLForm_2_ext<bits<6> opcode, bits<10> xo, bits<5> bo,  bits<5> bi, bit lk,
    636                   dag OOL, dag IOL, string asmstr, InstrItinClass itin, list<dag> pattern>
    637   : XLForm_2<opcode, xo, lk, OOL, IOL, asmstr, itin, pattern> {
    638   let BO = bo;
    639   let BI = bi;
    640   let BH = 0;
    641 }
    642 
    643 class XLForm_3<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
    644                InstrItinClass itin>
    645          : I<opcode, OOL, IOL, asmstr, itin> {
    646   bits<3> BF;
    647   bits<3> BFA;
    648   
    649   let Inst{6-8}   = BF;
    650   let Inst{9-10}  = 0;
    651   let Inst{11-13} = BFA;
    652   let Inst{14-15} = 0;
    653   let Inst{16-20} = 0;
    654   let Inst{21-30} = xo;
    655   let Inst{31}    = 0;
    656 }
    657 
    658 // 1.7.8 XFX-Form
    659 class XFXForm_1<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
    660                 InstrItinClass itin>
    661          : I<opcode, OOL, IOL, asmstr, itin> {
    662   bits<5>  RT;
    663   bits<10> SPR;
    664 
    665   let Inst{6-10}  = RT;
    666   let Inst{11}    = SPR{4};
    667   let Inst{12}    = SPR{3};
    668   let Inst{13}    = SPR{2};
    669   let Inst{14}    = SPR{1};
    670   let Inst{15}    = SPR{0};
    671   let Inst{16}    = SPR{9};
    672   let Inst{17}    = SPR{8};
    673   let Inst{18}    = SPR{7};
    674   let Inst{19}    = SPR{6};
    675   let Inst{20}    = SPR{5};
    676   let Inst{21-30} = xo;
    677   let Inst{31}    = 0;
    678 }
    679 
    680 class XFXForm_1_ext<bits<6> opcode, bits<10> xo, bits<10> spr, 
    681                    dag OOL, dag IOL, string asmstr, InstrItinClass itin> 
    682   : XFXForm_1<opcode, xo, OOL, IOL, asmstr, itin> {
    683   let SPR = spr;
    684 }
    685 
    686 class XFXForm_3<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
    687                 InstrItinClass itin>
    688          : I<opcode, OOL, IOL, asmstr, itin> {
    689   bits<5>  RT;
    690    
    691   let Inst{6-10}  = RT;
    692   let Inst{11-20} = 0;
    693   let Inst{21-30} = xo;
    694   let Inst{31}    = 0;
    695 }
    696 
    697 class XFXForm_5<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
    698                 InstrItinClass itin> 
    699   : I<opcode, OOL, IOL, asmstr, itin> {
    700   bits<8>  FXM;
    701   bits<5>  rS;
    702    
    703   let Inst{6-10}  = rS;
    704   let Inst{11}    = 0;
    705   let Inst{12-19} = FXM;
    706   let Inst{20}    = 0;
    707   let Inst{21-30} = xo;
    708   let Inst{31}    = 0;
    709 }
    710 
    711 class XFXForm_5a<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
    712                  InstrItinClass itin> 
    713   : I<opcode, OOL, IOL, asmstr, itin> {
    714   bits<5>  ST;
    715   bits<8>  FXM;
    716    
    717   let Inst{6-10}  = ST;
    718   let Inst{11}    = 1;
    719   let Inst{12-19} = FXM;
    720   let Inst{20}    = 0;
    721   let Inst{21-30} = xo;
    722   let Inst{31}    = 0;
    723 }
    724 
    725 class XFXForm_7<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
    726                 InstrItinClass itin>
    727   : XFXForm_1<opcode, xo, OOL, IOL, asmstr, itin>;
    728 
    729 class XFXForm_7_ext<bits<6> opcode, bits<10> xo, bits<10> spr, 
    730                     dag OOL, dag IOL, string asmstr, InstrItinClass itin> 
    731   : XFXForm_7<opcode, xo, OOL, IOL, asmstr, itin> {
    732   let SPR = spr;
    733 }
    734 
    735 // XFL-Form - MTFSF
    736 // This is probably 1.7.9, but I don't have the reference that uses this
    737 // numbering scheme...
    738 class XFLForm<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr, 
    739               InstrItinClass itin, list<dag>pattern>
    740   : I<opcode, OOL, IOL, asmstr, itin> {
    741   bits<8> FM;
    742   bits<5> rT;
    743 
    744   bit RC = 0;    // set by isDOT
    745   let Pattern = pattern;
    746 
    747   let Inst{6} = 0;
    748   let Inst{7-14}  = FM;
    749   let Inst{15} = 0;
    750   let Inst{16-20} = rT;
    751   let Inst{21-30} = xo;
    752   let Inst{31}    = RC;
    753 }
    754 
    755 // 1.7.10 XS-Form - SRADI.
    756 class XSForm_1<bits<6> opcode, bits<9> xo, dag OOL, dag IOL, string asmstr,
    757                InstrItinClass itin, list<dag> pattern>
    758          : I<opcode, OOL, IOL, asmstr, itin> {
    759   bits<5> A;
    760   bits<5> RS;
    761   bits<6> SH;
    762 
    763   bit RC = 0;    // set by isDOT
    764   let Pattern = pattern;
    765 
    766   let Inst{6-10}  = RS;
    767   let Inst{11-15} = A;
    768   let Inst{16-20} = SH{4,3,2,1,0};
    769   let Inst{21-29} = xo;
    770   let Inst{30}    = SH{5};
    771   let Inst{31}    = RC;
    772 }
    773 
    774 // 1.7.11 XO-Form
    775 class XOForm_1<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL, string asmstr,
    776                InstrItinClass itin, list<dag> pattern>
    777          : I<opcode, OOL, IOL, asmstr, itin> {
    778   bits<5> RT;
    779   bits<5> RA;
    780   bits<5> RB;
    781 
    782   let Pattern = pattern;
    783 
    784   bit RC = 0;    // set by isDOT
    785 
    786   let Inst{6-10}  = RT;
    787   let Inst{11-15} = RA;
    788   let Inst{16-20} = RB;
    789   let Inst{21}    = oe;
    790   let Inst{22-30} = xo;
    791   let Inst{31}    = RC;  
    792 }
    793 
    794 class XOForm_3<bits<6> opcode, bits<9> xo, bit oe, 
    795                dag OOL, dag IOL, string asmstr, InstrItinClass itin, list<dag> pattern>
    796   : XOForm_1<opcode, xo, oe, OOL, IOL, asmstr, itin, pattern> {
    797   let RB = 0;
    798 }
    799 
    800 // 1.7.12 A-Form
    801 class AForm_1<bits<6> opcode, bits<5> xo, dag OOL, dag IOL, string asmstr, 
    802               InstrItinClass itin, list<dag> pattern>
    803          : I<opcode, OOL, IOL, asmstr, itin> {
    804   bits<5> FRT;
    805   bits<5> FRA;
    806   bits<5> FRC;
    807   bits<5> FRB;
    808 
    809   let Pattern = pattern;
    810 
    811   bit RC = 0;    // set by isDOT
    812 
    813   let Inst{6-10}  = FRT;
    814   let Inst{11-15} = FRA;
    815   let Inst{16-20} = FRB;
    816   let Inst{21-25} = FRC;
    817   let Inst{26-30} = xo;
    818   let Inst{31}    = RC;
    819 }
    820 
    821 class AForm_2<bits<6> opcode, bits<5> xo, dag OOL, dag IOL, string asmstr,
    822               InstrItinClass itin, list<dag> pattern>
    823   : AForm_1<opcode, xo, OOL, IOL, asmstr, itin, pattern> {
    824   let FRC = 0;
    825 }
    826 
    827 class AForm_3<bits<6> opcode, bits<5> xo, dag OOL, dag IOL, string asmstr,
    828               InstrItinClass itin, list<dag> pattern> 
    829   : AForm_1<opcode, xo, OOL, IOL, asmstr, itin, pattern> {
    830   let FRB = 0;
    831 }
    832 
    833 class AForm_4<bits<6> opcode, bits<5> xo, dag OOL, dag IOL, string asmstr, 
    834               InstrItinClass itin, list<dag> pattern>
    835          : I<opcode, OOL, IOL, asmstr, itin> {
    836   bits<5> RT;
    837   bits<5> RA;
    838   bits<5> RB;
    839   bits<5> COND;
    840 
    841   let Pattern = pattern;
    842 
    843   let Inst{6-10}  = RT;
    844   let Inst{11-15} = RA;
    845   let Inst{16-20} = RB;
    846   let Inst{21-25} = COND;
    847   let Inst{26-30} = xo;
    848   let Inst{31}    = 0;
    849 }
    850 
    851 // 1.7.13 M-Form
    852 class MForm_1<bits<6> opcode, dag OOL, dag IOL, string asmstr,
    853               InstrItinClass itin, list<dag> pattern>
    854     : I<opcode, OOL, IOL, asmstr, itin> {
    855   bits<5> RA;
    856   bits<5> RS;
    857   bits<5> RB;
    858   bits<5> MB;
    859   bits<5> ME;
    860 
    861   let Pattern = pattern;
    862 
    863   bit RC = 0;    // set by isDOT
    864 
    865   let Inst{6-10}  = RS;
    866   let Inst{11-15} = RA;
    867   let Inst{16-20} = RB;
    868   let Inst{21-25} = MB;
    869   let Inst{26-30} = ME;
    870   let Inst{31}    = RC;
    871 }
    872 
    873 class MForm_2<bits<6> opcode, dag OOL, dag IOL, string asmstr,
    874               InstrItinClass itin, list<dag> pattern>
    875   : MForm_1<opcode, OOL, IOL, asmstr, itin, pattern> {
    876 }
    877 
    878 // 1.7.14 MD-Form
    879 class MDForm_1<bits<6> opcode, bits<3> xo, dag OOL, dag IOL, string asmstr,
    880                InstrItinClass itin, list<dag> pattern>
    881     : I<opcode, OOL, IOL, asmstr, itin> {
    882   bits<5> RA;
    883   bits<5> RS;
    884   bits<6> SH;
    885   bits<6> MBE;
    886 
    887   let Pattern = pattern;
    888 
    889   bit RC = 0;    // set by isDOT
    890 
    891   let Inst{6-10}  = RS;
    892   let Inst{11-15} = RA;
    893   let Inst{16-20} = SH{4,3,2,1,0};
    894   let Inst{21-26} = MBE{4,3,2,1,0,5};
    895   let Inst{27-29} = xo;
    896   let Inst{30}    = SH{5};
    897   let Inst{31}    = RC;
    898 }
    899 
    900 class MDSForm_1<bits<6> opcode, bits<4> xo, dag OOL, dag IOL, string asmstr,
    901                 InstrItinClass itin, list<dag> pattern>
    902     : I<opcode, OOL, IOL, asmstr, itin> {
    903   bits<5> RA;
    904   bits<5> RS;
    905   bits<5> RB;
    906   bits<6> MBE;
    907 
    908   let Pattern = pattern;
    909 
    910   bit RC = 0;    // set by isDOT
    911 
    912   let Inst{6-10}  = RS;
    913   let Inst{11-15} = RA;
    914   let Inst{16-20} = RB;
    915   let Inst{21-26} = MBE{4,3,2,1,0,5};
    916   let Inst{27-30} = xo;
    917   let Inst{31}    = RC;
    918 }
    919 
    920 
    921 // E-1 VA-Form
    922 
    923 // VAForm_1 - DACB ordering.
    924 class VAForm_1<bits<6> xo, dag OOL, dag IOL, string asmstr,
    925                InstrItinClass itin, list<dag> pattern>
    926     : I<4, OOL, IOL, asmstr, itin> {
    927   bits<5> VD;
    928   bits<5> VA;
    929   bits<5> VC;
    930   bits<5> VB;
    931 
    932   let Pattern = pattern;
    933   
    934   let Inst{6-10}  = VD;
    935   let Inst{11-15} = VA;
    936   let Inst{16-20} = VB;
    937   let Inst{21-25} = VC;
    938   let Inst{26-31} = xo;
    939 }
    940 
    941 // VAForm_1a - DABC ordering.
    942 class VAForm_1a<bits<6> xo, dag OOL, dag IOL, string asmstr,
    943                 InstrItinClass itin, list<dag> pattern>
    944     : I<4, OOL, IOL, asmstr, itin> {
    945   bits<5> VD;
    946   bits<5> VA;
    947   bits<5> VB;
    948   bits<5> VC;
    949 
    950   let Pattern = pattern;
    951   
    952   let Inst{6-10}  = VD;
    953   let Inst{11-15} = VA;
    954   let Inst{16-20} = VB;
    955   let Inst{21-25} = VC;
    956   let Inst{26-31} = xo;
    957 }
    958 
    959 class VAForm_2<bits<6> xo, dag OOL, dag IOL, string asmstr,
    960                InstrItinClass itin, list<dag> pattern>
    961     : I<4, OOL, IOL, asmstr, itin> {
    962   bits<5> VD;
    963   bits<5> VA;
    964   bits<5> VB;
    965   bits<4> SH;
    966 
    967   let Pattern = pattern;
    968   
    969   let Inst{6-10}  = VD;
    970   let Inst{11-15} = VA;
    971   let Inst{16-20} = VB;
    972   let Inst{21}    = 0;
    973   let Inst{22-25} = SH;
    974   let Inst{26-31} = xo;
    975 }
    976 
    977 // E-2 VX-Form
    978 class VXForm_1<bits<11> xo, dag OOL, dag IOL, string asmstr,
    979                InstrItinClass itin, list<dag> pattern>
    980     : I<4, OOL, IOL, asmstr, itin> {
    981   bits<5> VD;
    982   bits<5> VA;
    983   bits<5> VB;
    984   
    985   let Pattern = pattern;
    986   
    987   let Inst{6-10}  = VD;
    988   let Inst{11-15} = VA;
    989   let Inst{16-20} = VB;
    990   let Inst{21-31} = xo;
    991 }
    992 
    993 class VXForm_setzero<bits<11> xo, dag OOL, dag IOL, string asmstr,
    994                InstrItinClass itin, list<dag> pattern>
    995     : VXForm_1<xo, OOL, IOL, asmstr, itin, pattern> {
    996   let VA = VD;
    997   let VB = VD;
    998 }
    999 
   1000 
   1001 class VXForm_2<bits<11> xo, dag OOL, dag IOL, string asmstr,
   1002                InstrItinClass itin, list<dag> pattern>
   1003     : I<4, OOL, IOL, asmstr, itin> {
   1004   bits<5> VD;
   1005   bits<5> VB;
   1006   
   1007   let Pattern = pattern;
   1008   
   1009   let Inst{6-10}  = VD;
   1010   let Inst{11-15} = 0;
   1011   let Inst{16-20} = VB;
   1012   let Inst{21-31} = xo;
   1013 }
   1014 
   1015 class VXForm_3<bits<11> xo, dag OOL, dag IOL, string asmstr,
   1016                InstrItinClass itin, list<dag> pattern>
   1017     : I<4, OOL, IOL, asmstr, itin> {
   1018   bits<5> VD;
   1019   bits<5> IMM;
   1020   
   1021   let Pattern = pattern;
   1022   
   1023   let Inst{6-10}  = VD;
   1024   let Inst{11-15} = IMM;
   1025   let Inst{16-20} = 0;
   1026   let Inst{21-31} = xo;
   1027 }
   1028 
   1029 /// VXForm_4 - VX instructions with "VD,0,0" register fields, like mfvscr.
   1030 class VXForm_4<bits<11> xo, dag OOL, dag IOL, string asmstr,
   1031                InstrItinClass itin, list<dag> pattern>
   1032     : I<4, OOL, IOL, asmstr, itin> {
   1033   bits<5> VD;
   1034   
   1035   let Pattern = pattern;
   1036   
   1037   let Inst{6-10}  = VD;
   1038   let Inst{11-15} = 0;
   1039   let Inst{16-20} = 0;
   1040   let Inst{21-31} = xo;
   1041 }
   1042 
   1043 /// VXForm_5 - VX instructions with "0,0,VB" register fields, like mtvscr.
   1044 class VXForm_5<bits<11> xo, dag OOL, dag IOL, string asmstr,
   1045                InstrItinClass itin, list<dag> pattern>
   1046     : I<4, OOL, IOL, asmstr, itin> {
   1047   bits<5> VB;
   1048   
   1049   let Pattern = pattern;
   1050   
   1051   let Inst{6-10}  = 0;
   1052   let Inst{11-15} = 0;
   1053   let Inst{16-20} = VB;
   1054   let Inst{21-31} = xo;
   1055 }
   1056 
   1057 // E-4 VXR-Form
   1058 class VXRForm_1<bits<10> xo, dag OOL, dag IOL, string asmstr,
   1059                InstrItinClass itin, list<dag> pattern>
   1060     : I<4, OOL, IOL, asmstr, itin> {
   1061   bits<5> VD;
   1062   bits<5> VA;
   1063   bits<5> VB;
   1064   bit RC = 0;
   1065   
   1066   let Pattern = pattern;
   1067   
   1068   let Inst{6-10}  = VD;
   1069   let Inst{11-15} = VA;
   1070   let Inst{16-20} = VB;
   1071   let Inst{21}    = RC;
   1072   let Inst{22-31} = xo;
   1073 }
   1074 
   1075 //===----------------------------------------------------------------------===//
   1076 class Pseudo<dag OOL, dag IOL, string asmstr, list<dag> pattern>
   1077     : I<0, OOL, IOL, asmstr, NoItinerary> {
   1078   let isCodeGenOnly = 1;
   1079   let PPC64 = 0;
   1080   let Pattern = pattern;
   1081   let Inst{31-0} = 0;
   1082 }
   1083