Fix JIT encoding of ppc mfocrf instruction; the operands were reversed
[oota-llvm.git] / lib / Target / PowerPC / PPCInstrInfo.td
1
2 //===- PowerPCInstrInfo.td - The PowerPC Instruction Set -----*- tablegen -*-=//
3 // 
4 //                     The LLVM Compiler Infrastructure
5 //
6 // This file was developed by the LLVM research group and is distributed under
7 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 // 
9 //===----------------------------------------------------------------------===//
10 //
11 // This file describes the subset of the 32-bit PowerPC instruction set, as used
12 // by the PowerPC instruction selector.
13 //
14 //===----------------------------------------------------------------------===//
15
16 include "PowerPCInstrFormats.td"
17
18 class isPPC64 { bit PPC64 = 1; }
19 class isVMX   { bit VMX = 1; }
20 class isDOT   {
21   list<Register> Defs = [CR0];
22   bit RC  = 1;
23 }
24
25 let isTerminator = 1 in {
26   let isReturn = 1 in
27     def BLR : XLForm_2_ext<19, 16, 20, 0, 0, (ops), "blr">;
28   def BCTR : XLForm_2_ext<19, 528, 20, 0, 0, (ops), "bctr">;
29 }
30
31 def u5imm   : Operand<i8> {
32   let PrintMethod = "printU5ImmOperand";
33 }
34 def u6imm   : Operand<i8> {
35   let PrintMethod = "printU6ImmOperand";
36 }
37 def s16imm  : Operand<i16> {
38   let PrintMethod = "printS16ImmOperand";
39 }
40 def u16imm  : Operand<i16> {
41   let PrintMethod = "printU16ImmOperand";
42 }
43 def target : Operand<i32> {
44   let PrintMethod = "printBranchOperand";
45 }
46 def piclabel: Operand<i32> {
47   let PrintMethod = "printPICLabel";
48 }
49 def symbolHi: Operand<i32> {
50   let PrintMethod = "printSymbolHi";
51 }
52 def symbolLo: Operand<i32> {
53   let PrintMethod = "printSymbolLo";
54 }
55 def crbit: Operand<i8> {
56   let PrintMethod = "printcrbit";
57 }
58 def crbitm: Operand<i8> {
59   let PrintMethod = "printcrbitm";
60 }
61
62 // Pseudo-instructions:
63 def PHI : Pseudo<(ops), "; PHI">;
64 let isLoad = 1 in {
65 def ADJCALLSTACKDOWN : Pseudo<(ops), "; ADJCALLSTACKDOWN">;
66 def ADJCALLSTACKUP : Pseudo<(ops), "; ADJCALLSTACKUP">;
67 }
68 def IMPLICIT_DEF : Pseudo<(ops), "; IMPLICIT_DEF">;
69
70 let Defs = [LR] in
71   def MovePCtoLR : Pseudo<(ops piclabel:$label), "bl $label">;
72
73 let isBranch = 1, isTerminator = 1 in {
74   def COND_BRANCH : Pseudo<(ops), "; COND_BRANCH">;
75   def B   : IForm<18, 0, 0, (ops target:$func), "b $func">;
76 //def BA  : IForm<18, 1, 0, (ops target:$func), "ba $func">;
77   def BL  : IForm<18, 0, 1, (ops target:$func), "bl $func">;
78 //def BLA : IForm<18, 1, 1, (ops target:$func), "bla $func">;
79
80   // FIXME: 4*CR# needs to be added to the BI field!
81   // This will only work for CR0 as it stands now
82   def BLT : BForm_ext<16, 0, 0, 12, 0, (ops CRRC:$crS, target:$block),
83                       "blt $block">;
84   def BLE : BForm_ext<16, 0, 0, 4,  1, (ops CRRC:$crS, target:$block),
85                       "ble $block">;
86   def BEQ : BForm_ext<16, 0, 0, 12, 2, (ops CRRC:$crS, target:$block),
87                       "beq $block">;
88   def BGE : BForm_ext<16, 0, 0, 4,  0, (ops CRRC:$crS, target:$block),
89                       "bge $block">;
90   def BGT : BForm_ext<16, 0, 0, 12, 1, (ops CRRC:$crS, target:$block),
91                       "bgt $block">;
92   def BNE : BForm_ext<16, 0, 0, 4,  2, (ops CRRC:$crS, target:$block),
93                       "bne $block">;
94 }
95
96 let isCall = 1, 
97   // All calls clobber the non-callee saved registers...
98   Defs = [R0,R2,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,
99           F0,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,
100           LR,XER,CTR,
101           CR0,CR1,CR5,CR6,CR7] in {
102   // Convenient aliases for call instructions
103   def CALLpcrel : IForm<18, 0, 1, (ops target:$func), "bl $func">;
104   def CALLindirect : XLForm_2_ext<19, 528, 20, 0, 1, (ops), "bctrl">;
105 }
106
107 // D-Form instructions.  Most instructions that perform an operation on a
108 // register and an immediate are of this type.
109 //
110 let isLoad = 1 in {
111 def LBZ : DForm_1<34, (ops GPRC:$rD, symbolLo:$disp, GPRC:$rA),
112                   "lbz $rD, $disp($rA)">;
113 def LHA : DForm_1<42, (ops GPRC:$rD, symbolLo:$disp, GPRC:$rA),
114                   "lha $rD, $disp($rA)">;
115 def LHZ : DForm_1<40, (ops GPRC:$rD, symbolLo:$disp, GPRC:$rA),
116                   "lhz $rD, $disp($rA)">;
117 def LMW : DForm_1<46, (ops GPRC:$rD, s16imm:$disp, GPRC:$rA),
118                   "lmw $rD, $disp($rA)">;
119 def LWZ : DForm_1<32, (ops GPRC:$rD, symbolLo:$disp, GPRC:$rA),
120                   "lwz $rD, $disp($rA)">;
121 def LWZU : DForm_1<35, (ops GPRC:$rD, s16imm:$disp, GPRC:$rA),
122                    "lwzu $rD, $disp($rA)">;
123 }
124 def ADDI   : DForm_2<14, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
125                      "addi $rD, $rA, $imm">;
126 def ADDIC  : DForm_2<12, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
127                      "addic $rD, $rA, $imm">;
128 def ADDICo : DForm_2<13, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
129                      "addic. $rD, $rA, $imm">;
130 def ADDIS  : DForm_2<15, (ops GPRC:$rD, GPRC:$rA, symbolHi:$imm),
131                      "addis $rD, $rA, $imm">;
132 def LA     : DForm_2<14, (ops GPRC:$rD, GPRC:$rA, symbolLo:$sym),
133                      "la $rD, $sym($rA)">;
134 def MULLI  : DForm_2< 7, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
135                      "mulli $rD, $rA, $imm">;
136 def SUBFIC : DForm_2< 8, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
137                      "subfic $rD, $rA, $imm">;
138 def LI  : DForm_2_r0<14, (ops GPRC:$rD, s16imm:$imm),
139                      "li $rD, $imm">;
140 def LIS : DForm_2_r0<15, (ops GPRC:$rD, symbolHi:$imm),
141                      "lis $rD, $imm">;
142 let isStore = 1 in {
143 def STMW : DForm_3<47, (ops GPRC:$rS, s16imm:$disp, GPRC:$rA),
144                    "stmw $rS, $disp($rA)">;
145 def STB  : DForm_3<38, (ops GPRC:$rS, symbolLo:$disp, GPRC:$rA),
146                    "stb $rS, $disp($rA)">;
147 def STH  : DForm_3<44, (ops GPRC:$rS, symbolLo:$disp, GPRC:$rA),
148                    "sth $rS, $disp($rA)">;
149 def STW  : DForm_3<36, (ops GPRC:$rS, symbolLo:$disp, GPRC:$rA),
150                    "stw $rS, $disp($rA)">;
151 def STWU : DForm_3<37, (ops GPRC:$rS, s16imm:$disp, GPRC:$rA),
152                    "stwu $rS, $disp($rA)">;
153 }
154 def ANDIo : DForm_4<28, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
155                     "andi. $dst, $src1, $src2">, isDOT;
156 def ANDISo : DForm_4<29, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
157                     "andis. $dst, $src1, $src2">, isDOT;
158 def ORI   : DForm_4<24, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
159                     "ori $dst, $src1, $src2">;
160 def ORIS  : DForm_4<25, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
161                     "oris $dst, $src1, $src2">;
162 def XORI  : DForm_4<26, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
163                     "xori $dst, $src1, $src2">;
164 def XORIS : DForm_4<27, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
165                     "xoris $dst, $src1, $src2">;
166 def NOP   : DForm_4_zero<24, (ops), "nop">;
167 def CMPI  : DForm_5<11, (ops CRRC:$crD, i1imm:$L, GPRC:$rA, s16imm:$imm),
168                     "cmpi $crD, $L, $rA, $imm">;
169 def CMPWI : DForm_5_ext<11, (ops CRRC:$crD, GPRC:$rA, s16imm:$imm),
170                         "cmpwi $crD, $rA, $imm">;
171 def CMPDI : DForm_5_ext<11, (ops CRRC:$crD, GPRC:$rA, s16imm:$imm),
172                         "cmpdi $crD, $rA, $imm">, isPPC64;
173 def CMPLI  : DForm_6<10, (ops CRRC:$dst, i1imm:$size, GPRC:$src1, u16imm:$src2),
174                      "cmpli $dst, $size, $src1, $src2">;
175 def CMPLWI : DForm_6_ext<10, (ops CRRC:$dst, GPRC:$src1, u16imm:$src2),
176                          "cmplwi $dst, $src1, $src2">;
177 def CMPLDI : DForm_6_ext<10, (ops CRRC:$dst, GPRC:$src1, u16imm:$src2),
178                          "cmpldi $dst, $src1, $src2">, isPPC64;
179 let isLoad = 1 in {
180 def LFS : DForm_8<48, (ops GPRC:$rD, symbolLo:$disp, GPRC:$rA),
181                   "lfs $rD, $disp($rA)">;
182 def LFD : DForm_8<50, (ops GPRC:$rD, symbolLo:$disp, GPRC:$rA),
183                   "lfd $rD, $disp($rA)">;
184 }
185 let isStore = 1 in {
186 def STFS : DForm_9<52, (ops GPRC:$rS, symbolLo:$disp, GPRC:$rA),
187                    "stfs $rS, $disp($rA)">;
188 def STFD : DForm_9<54, (ops GPRC:$rS, symbolLo:$disp, GPRC:$rA),
189                    "stfd $rS, $disp($rA)">;
190 }
191
192 // DS-Form instructions.  Load/Store instructions available in PPC-64
193 //
194 let isLoad = 1 in {
195 def LWA  : DSForm_1<58, 2, (ops GPRC:$rT, s16imm:$DS, GPRC:$rA),
196                     "lwa $rT, $DS($rA)">, isPPC64;
197 def LD   : DSForm_2<58, 0, (ops GPRC:$rT, s16imm:$DS, GPRC:$rA),
198                     "ld $rT, $DS($rA)">, isPPC64;
199 }
200 let isStore = 1 in {
201 def STD  : DSForm_2<62, 0, (ops GPRC:$rT, s16imm:$DS, GPRC:$rA),
202                     "std $rT, $DS($rA)">, isPPC64;
203 def STDU : DSForm_2<62, 1, (ops GPRC:$rT, s16imm:$DS, GPRC:$rA),
204                     "stdu $rT, $DS($rA)">, isPPC64;
205 }
206
207 // X-Form instructions.  Most instructions that perform an operation on a
208 // register and another register are of this type.
209 //
210 let isLoad = 1 in {
211 def LBZX : XForm_1<31,  87, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
212                    "lbzx $dst, $base, $index">;
213 def LHAX : XForm_1<31, 343, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
214                    "lhax $dst, $base, $index">;
215 def LHZX : XForm_1<31, 279, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
216                    "lhzx $dst, $base, $index">;
217 def LWAX : XForm_1<31, 341, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
218                    "lwax $dst, $base, $index">, isPPC64;
219 def LWZX : XForm_1<31,  23, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
220                    "lwzx $dst, $base, $index">;
221 def LDX  : XForm_1<31,  21, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
222                    "ldx $dst, $base, $index">, isPPC64;
223 }
224 def AND  : XForm_6<31,  28, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
225                    "and $rA, $rS, $rB">;
226 def ANDo : XForm_6<31,  28, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
227                    "and. $rA, $rS, $rB">, isDOT;
228 def ANDC : XForm_6<31,  60, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
229                    "andc $rA, $rS, $rB">;
230 def EQV  : XForm_6<31, 284, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
231                    "eqv $rA, $rS, $rB">;
232 def NAND : XForm_6<31, 476, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
233                    "nand $rA, $rS, $rB">;
234 def NOR  : XForm_6<31, 124, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
235                    "nor $rA, $rS, $rB">;
236 def OR   : XForm_6<31, 444, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
237                    "or $rA, $rS, $rB">;
238 def ORo  : XForm_6<31, 444, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
239                    "or. $rA, $rS, $rB">, isDOT;
240 def ORC  : XForm_6<31, 412, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
241                    "orc $rA, $rS, $rB">;
242 def SLD  : XForm_6<31,  27, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
243                    "sld $rA, $rS, $rB">, isPPC64;
244 def SLW  : XForm_6<31,  24, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
245                    "slw $rA, $rS, $rB">;
246 def SRD  : XForm_6<31, 539, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
247                    "srd $rA, $rS, $rB">, isPPC64;
248 def SRW  : XForm_6<31, 536, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
249                    "srw $rA, $rS, $rB">;
250 def SRAD : XForm_6<31, 794, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
251                    "srad $rA, $rS, $rB">, isPPC64;
252 def SRAW : XForm_6<31, 792, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
253                    "sraw $rA, $rS, $rB">;
254 def XOR  : XForm_6<31, 316, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
255                    "xor $rA, $rS, $rB">;
256 let isStore = 1 in {
257 def STBX  : XForm_8<31, 215, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
258                    "stbx $rS, $rA, $rB">;
259 def STHX  : XForm_8<31, 407, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
260                    "sthx $rS, $rA, $rB">;
261 def STWX  : XForm_8<31, 151, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
262                    "stwx $rS, $rA, $rB">;
263 def STWUX : XForm_8<31, 183, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
264                    "stwux $rS, $rA, $rB">;
265 def STDX  : XForm_8<31, 149, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
266                    "stdx $rS, $rA, $rB">, isPPC64;
267 def STDUX : XForm_8<31, 181, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
268                    "stdux $rS, $rA, $rB">, isPPC64;
269 }
270 def SRAWI : XForm_10<31, 824, (ops GPRC:$rA, GPRC:$rS, u5imm:$SH), 
271                      "srawi $rA, $rS, $SH">;
272 def CNTLZW : XForm_11<31,  26, (ops GPRC:$rA, GPRC:$rS),
273                       "cntlzw $rA, $rS">;
274 def EXTSB  : XForm_11<31, 954, (ops GPRC:$rA, GPRC:$rS),
275                       "extsb $rA, $rS">;
276 def EXTSH  : XForm_11<31, 922, (ops GPRC:$rA, GPRC:$rS),
277                       "extsh $rA, $rS">;
278 def EXTSW  : XForm_11<31, 986, (ops GPRC:$rA, GPRC:$rS),
279                       "extsw $rA, $rS">, isPPC64;
280 def CMP    : XForm_16<31, 0, (ops CRRC:$crD, i1imm:$long, GPRC:$rA, GPRC:$rB),
281                       "cmp $crD, $long, $rA, $rB">;
282 def CMPL   : XForm_16<31, 32, (ops CRRC:$crD, i1imm:$long, GPRC:$rA, GPRC:$rB),
283                       "cmpl $crD, $long, $rA, $rB">;
284 def CMPW   : XForm_16_ext<31, 0, (ops CRRC:$crD, GPRC:$rA, GPRC:$rB),
285                           "cmpw $crD, $rA, $rB">;
286 def CMPD   : XForm_16_ext<31, 0, (ops CRRC:$crD, GPRC:$rA, GPRC:$rB),
287                           "cmpd $crD, $rA, $rB">, isPPC64;
288 def CMPLW  : XForm_16_ext<31, 32, (ops CRRC:$crD, GPRC:$rA, GPRC:$rB),
289                           "cmplw $crD, $rA, $rB">;
290 def CMPLD  : XForm_16_ext<31, 32, (ops CRRC:$crD, GPRC:$rA, GPRC:$rB),
291                           "cmpld $crD, $rA, $rB">, isPPC64;
292 def FCMPO  : XForm_17<63, 32, (ops CRRC:$crD, FPRC:$fA, FPRC:$fB),
293                       "fcmpo $crD, $fA, $fB">;
294 def FCMPU  : XForm_17<63, 0, (ops CRRC:$crD, FPRC:$fA, FPRC:$fB),
295                       "fcmpu $crD, $fA, $fB">;
296 let isLoad = 1 in {
297 def LFSX   : XForm_25<31, 535, (ops FPRC:$dst, GPRC:$base, GPRC:$index),
298                       "lfsx $dst, $base, $index">;
299 def LFDX   : XForm_25<31, 599, (ops FPRC:$dst, GPRC:$base, GPRC:$index),
300                       "lfdx $dst, $base, $index">;
301 }
302 def FCFID  : XForm_26<63, 846, (ops FPRC:$frD, FPRC:$frB),
303                       "fcfid $frD, $frB">, isPPC64;
304 def FCTIDZ : XForm_26<63, 815, (ops FPRC:$frD, FPRC:$frB),
305                       "fctidz $frD, $frB">, isPPC64;
306 def FCTIWZ : XForm_26<63, 15, (ops FPRC:$frD, FPRC:$frB),
307                       "fctiwz $frD, $frB">;
308 def FABS   : XForm_26<63, 264, (ops FPRC:$frD, FPRC:$frB),
309                       "fabs $frD, $frB">;
310 def FMR    : XForm_26<63, 72, (ops FPRC:$frD, FPRC:$frB),
311                       "fmr $frD, $frB">;
312 def FNABS  : XForm_26<63, 136, (ops FPRC:$frD, FPRC:$frB),
313                       "fnabs $frD, $frB">;
314 def FNEG   : XForm_26<63, 40, (ops FPRC:$frD, FPRC:$frB),
315                       "fneg $frD, $frB">;
316 def FRSP   : XForm_26<63, 12, (ops FPRC:$frD, FPRC:$frB),
317                       "frsp $frD, $frB">;
318 def FSQRT  : XForm_26<63, 22, (ops FPRC:$frD, FPRC:$frB),
319                       "fsqrt $frD, $frB">;
320 def FSQRTS : XForm_26<59, 22, (ops FPRC:$frD, FPRC:$frB),
321                       "fsqrts $frD, $frB">;
322                       
323 let isStore = 1 in {
324 def STFSX : XForm_28<31, 663, (ops FPRC:$frS, GPRC:$rA, GPRC:$rB),
325                      "stfsx $frS, $rA, $rB">;
326 def STFDX : XForm_28<31, 727, (ops FPRC:$frS, GPRC:$rA, GPRC:$rB),
327                      "stfdx $frS, $rA, $rB">;
328 }
329
330 // XL-Form instructions.  condition register logical ops.
331 //
332 def CRAND  : XLForm_1<19, 257, (ops CRRC:$D, crbit:$Db,
333                       CRRC:$A, crbit:$Ab, CRRC:$B, crbit:$Bb),
334                       "crand $Db, $Ab, $Bb">;
335 def CRANDC : XLForm_1<19, 129, (ops CRRC:$D, crbit:$Db,
336                       CRRC:$A, crbit:$Ab, CRRC:$B, crbit:$Bb),
337                       "crandc $Db, $Ab, $Bb">;
338 def CREQV  : XLForm_1<19, 289, (ops CRRC:$D, crbit:$Db,
339                       CRRC:$A, crbit:$Ab, CRRC:$B, crbit:$Bb),
340                       "creqv $Db, $Ab, $Bb">;
341 def CRNAND : XLForm_1<19, 225, (ops CRRC:$D, crbit:$Db,
342                       CRRC:$A, crbit:$Ab, CRRC:$B, crbit:$Bb),
343                       "crnand $Db, $Ab, $Bb">;
344 def CRNOR  : XLForm_1<19, 33, (ops CRRC:$D, crbit:$Db,
345                       CRRC:$A, crbit:$Ab, CRRC:$B, crbit:$Bb),
346                       "crnor $Db, $Ab, $Bb">;
347 def CROR   : XLForm_1<19, 449, (ops CRRC:$D, crbit:$Db,
348                       CRRC:$A, crbit:$Ab, CRRC:$B, crbit:$Bb),
349                       "cror $Db, $Ab, $Bb">;
350 def CRORC  : XLForm_1<19, 417, (ops CRRC:$D, crbit:$Db,
351                       CRRC:$A, crbit:$Ab, CRRC:$B, crbit:$Bb),
352                       "crorc $Db, $Ab, $Bb">;
353 def CRXOR  : XLForm_1<19, 193, (ops CRRC:$D, crbit:$Db,
354                       CRRC:$A, crbit:$Ab, CRRC:$B, crbit:$Bb),
355                       "crxor $Db, $Ab, $Bb">;
356 def MCRF   : XLForm_3<19, 0, (ops CRRC:$BF, CRRC:$BFA),
357                       "mcrf $BF, $BFA">;
358
359 // XFX-Form instructions.  Instructions that deal with SPRs
360 //
361 // Note that although LR should be listed as `8' and CTR as `9' in the SPR
362 // field, the manual lists the groups of bits as [5-9] = 0, [0-4] = 8 or 9
363 // which means the SPR value needs to be multiplied by a factor of 32.
364 def MFCTR : XFXForm_1_ext<31, 339, 288, (ops GPRC:$rT), "mfctr $rT">;
365 def MFLR  : XFXForm_1_ext<31, 339, 256, (ops GPRC:$rT), "mflr $rT">;
366 def MFCR  : XFXForm_3<31, 19, (ops GPRC:$rT), "mfcr $rT">;
367 def MTCRF : XFXForm_5<31, 144, (ops CRRC:$FXM, GPRC:$rS),
368                       "mtcrf $FXM, $rS">;
369 def MFOCRF : XFXForm_5a<31, 19, (ops GPRC:$rT, crbitm:$FXM),
370                         "mfcr $rT, $FXM">;
371 def MTCTR : XFXForm_7_ext<31, 467, 288, (ops GPRC:$rS), "mtctr $rS">;
372 def MTLR  : XFXForm_7_ext<31, 467, 256, (ops GPRC:$rS), "mtlr $rS">;
373
374 // XS-Form instructions.  Just 'sradi'
375 //
376 def SRADI  : XSForm_1<31, 413, (ops GPRC:$rA, GPRC:$rS, u6imm:$SH),
377                       "sradi $rA, $rS, $SH">, isPPC64;
378
379 // XO-Form instructions.  Arithmetic instructions that can set overflow bit
380 //
381 def ADD   : XOForm_1<31, 266, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
382                      "add $rT, $rA, $rB">;
383 def ADDC  : XOForm_1<31, 10, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
384                      "addc $rT, $rA, $rB">;
385 def ADDE  : XOForm_1<31, 138, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
386                      "adde $rT, $rA, $rB">;
387 def DIVD  : XOForm_1<31, 489, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
388                      "divd $rT, $rA, $rB">, isPPC64;
389 def DIVDU : XOForm_1<31, 457, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
390                      "divdu $rT, $rA, $rB">, isPPC64;
391 def DIVW  : XOForm_1<31, 491, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
392                      "divw $rT, $rA, $rB">;
393 def DIVWU : XOForm_1<31, 459, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
394                      "divwu $rT, $rA, $rB">;
395 def MULHW : XOForm_1<31, 75, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
396                      "mulhw $rT, $rA, $rB">;
397 def MULHWU : XOForm_1<31, 11, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
398                      "mulhwu $rT, $rA, $rB">;
399 def MULLD : XOForm_1<31, 233, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
400                      "mulld $rT, $rA, $rB">, isPPC64;
401 def MULLW : XOForm_1<31, 235, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
402                      "mullw $rT, $rA, $rB">;
403 def SUBF  : XOForm_1<31, 40, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
404                      "subf $rT, $rA, $rB">;
405 def SUBFC : XOForm_1<31, 8, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
406                      "subfc $rT, $rA, $rB">;
407 def SUBFE : XOForm_1<31, 136, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
408                      "subfe $rT, $rA, $rB">;
409 def SUB  : XOForm_1r<31, 40, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
410                      "sub $rT, $rA, $rB">;
411 def ADDME  : XOForm_3<31, 234, 0, (ops GPRC:$rT, GPRC:$rA),
412                       "addme $rT, $rA">;
413 def ADDZE  : XOForm_3<31, 202, 0, (ops GPRC:$rT, GPRC:$rA),
414                       "addze $rT, $rA">;
415 def NEG    : XOForm_3<31, 104, 0, (ops GPRC:$rT, GPRC:$rA),
416                       "neg $rT, $rA">;
417 def SUBFZE : XOForm_3<31, 200, 0, (ops GPRC:$rT, GPRC:$rA),
418                       "subfze $rT, $rA">;
419
420 // A-Form instructions.  Most of the instructions executed in the FPU are of
421 // this type.
422 //
423 def FMADD : AForm_1<63, 29, 
424                     (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRC, FPRC:$FRB),
425                     "fmadd $FRT, $FRA, $FRC, $FRB">;
426 def FMADDS : AForm_1<59, 29,
427                     (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRC, FPRC:$FRB),
428                     "fmadds $FRT, $FRA, $FRC, $FRB">;
429 def FMSUB : AForm_1<63, 28,
430                     (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRC, FPRC:$FRB),
431                     "fmsub $FRT, $FRA, $FRC, $FRB">;
432 def FMSUBS : AForm_1<59, 28,
433                     (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRC, FPRC:$FRB),
434                     "fmsubs $FRT, $FRA, $FRC, $FRB">;
435 def FNMADD : AForm_1<63, 31,
436                     (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRC, FPRC:$FRB),
437                     "fnmadd $FRT, $FRA, $FRC, $FRB">;
438 def FNMADDS : AForm_1<59, 31,
439                     (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRC, FPRC:$FRB),
440                     "fnmadds $FRT, $FRA, $FRC, $FRB">;
441 def FNMSUB : AForm_1<63, 30,
442                     (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRC, FPRC:$FRB),
443                     "fnmsub $FRT, $FRA, $FRC, $FRB">;
444 def FNMSUBS : AForm_1<59, 30,
445                     (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRC, FPRC:$FRB),
446                     "fnmsubs $FRT, $FRA, $FRC, $FRB">;
447 def FSEL  : AForm_1<63, 23,
448                     (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRC, FPRC:$FRB),
449                     "fsel $FRT, $FRA, $FRC, $FRB">;
450 def FADD  : AForm_2<63, 21,
451                     (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
452                     "fadd $FRT, $FRA, $FRB">;
453 def FADDS : AForm_2<59, 21,
454                     (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
455                     "fadds $FRT, $FRA, $FRB">;
456 def FDIV  : AForm_2<63, 18,
457                     (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
458                     "fdiv $FRT, $FRA, $FRB">;
459 def FDIVS : AForm_2<59, 18,
460                     (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
461                     "fdivs $FRT, $FRA, $FRB">;
462 def FMUL  : AForm_3<63, 25,
463                     (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
464                     "fmul $FRT, $FRA, $FRB">;
465 def FMULS : AForm_3<59, 25,
466                     (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
467                     "fmuls $FRT, $FRA, $FRB">;
468 def FSUB  : AForm_2<63, 20,
469                     (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
470                     "fsub $FRT, $FRA, $FRB">;
471 def FSUBS : AForm_2<59, 20,
472                     (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
473                     "fsubs $FRT, $FRA, $FRB">;
474
475 // M-Form instructions.  rotate and mask instructions.
476 //
477 let isTwoAddress = 1 in {
478 def RLWIMI : MForm_2<20,
479                      (ops GPRC:$rA, GPRC:$rSi, GPRC:$rS, u5imm:$SH, u5imm:$MB, 
480                       u5imm:$ME), "rlwimi $rA, $rS, $SH, $MB, $ME">;
481 }
482 def RLWINM : MForm_2<21,
483                      (ops GPRC:$rA, GPRC:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
484                      "rlwinm $rA, $rS, $SH, $MB, $ME">;
485 def RLWINMo : MForm_2<21,
486                      (ops GPRC:$rA, GPRC:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
487                      "rlwinm. $rA, $rS, $SH, $MB, $ME">, isDOT;
488 def RLWNM  : MForm_2<23,
489                      (ops GPRC:$rA, GPRC:$rS, GPRC:$rB, u5imm:$MB, u5imm:$ME),
490                      "rlwnm $rA, $rS, $rB, $MB, $ME">;
491
492 // MD-Form instructions.  64 bit rotate instructions.
493 //
494 def RLDICL : MDForm_1<30, 0,
495                       (ops GPRC:$rA, GPRC:$rS, u6imm:$SH, u6imm:$MB),
496                       "rldicl $rA, $rS, $SH, $MB">, isPPC64;
497 def RLDICR : MDForm_1<30, 1,
498                       (ops GPRC:$rA, GPRC:$rS, u6imm:$SH, u6imm:$ME),
499                       "rldicr $rA, $rS, $SH, $ME">, isPPC64;
500
501 def PowerPCInstrInfo : InstrInfo {
502   let PHIInst  = PHI;
503
504   let TSFlagsFields = [ "VMX", "PPC64" ];
505   let TSFlagsShifts = [ 0, 1 ];
506
507   let isLittleEndianEncoding = 1;
508 }
509