Added InstrSchedClass to each of the PowerPC Instructions.
[oota-llvm.git] / lib / Target / PowerPC / PPCInstrInfo.td
1 //===- PPCInstrInfo.td - The PowerPC Instruction Set -------*- tablegen -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // This file describes the subset of the 32-bit PowerPC instruction set, as used
11 // by the PowerPC instruction selector.
12 //
13 //===----------------------------------------------------------------------===//
14
15 include "PPCInstrFormats.td"
16
17
18 //===----------------------------------------------------------------------===//
19 // PowerPC specific transformation functions and pattern fragments.
20 //
21
22 def SHL32 : SDNodeXForm<imm, [{
23   // Transformation function: 31 - imm
24   return getI32Imm(31 - N->getValue());
25 }]>;
26
27 def SHL64 : SDNodeXForm<imm, [{
28   // Transformation function: 63 - imm
29   return getI32Imm(63 - N->getValue());
30 }]>;
31
32 def SRL32 : SDNodeXForm<imm, [{
33   // Transformation function: 32 - imm
34   return N->getValue() ? getI32Imm(32 - N->getValue()) : getI32Imm(0);
35 }]>;
36
37 def SRL64 : SDNodeXForm<imm, [{
38   // Transformation function: 64 - imm
39   return N->getValue() ? getI32Imm(64 - N->getValue()) : getI32Imm(0);
40 }]>;
41
42 def LO16 : SDNodeXForm<imm, [{
43   // Transformation function: get the low 16 bits.
44   return getI32Imm((unsigned short)N->getValue());
45 }]>;
46
47 def HI16 : SDNodeXForm<imm, [{
48   // Transformation function: shift the immediate value down into the low bits.
49   return getI32Imm((unsigned)N->getValue() >> 16);
50 }]>;
51
52 def HA16 : SDNodeXForm<imm, [{
53   // Transformation function: shift the immediate value down into the low bits.
54   signed int Val = N->getValue();
55   return getI32Imm((Val - (signed short)Val) >> 16);
56 }]>;
57
58
59 def immSExt16  : PatLeaf<(imm), [{
60   // immSExt16 predicate - True if the immediate fits in a 16-bit sign extended
61   // field.  Used by instructions like 'addi'.
62   return (int)N->getValue() == (short)N->getValue();
63 }]>;
64 def immZExt16  : PatLeaf<(imm), [{
65   // immZExt16 predicate - True if the immediate fits in a 16-bit zero extended
66   // field.  Used by instructions like 'ori'.
67   return (unsigned)N->getValue() == (unsigned short)N->getValue();
68 }], LO16>;
69
70 def imm16Shifted : PatLeaf<(imm), [{
71   // imm16Shifted predicate - True if only bits in the top 16-bits of the
72   // immediate are set.  Used by instructions like 'addis'.
73   return ((unsigned)N->getValue() & 0xFFFF0000U) == (unsigned)N->getValue();
74 }], HI16>;
75
76 /*
77 // Example of a legalize expander: Only for PPC64.
78 def : Expander<(set i64:$dst, (fp_to_sint f64:$src)),
79                [(set f64:$tmp , (FCTIDZ f64:$src)),
80                 (set i32:$tmpFI, (CreateNewFrameIndex 8, 8)),
81                 (store f64:$tmp, i32:$tmpFI),
82                 (set i64:$dst, (load i32:$tmpFI))],
83                 Subtarget_PPC64>;
84 */
85
86 //===----------------------------------------------------------------------===//
87 // PowerPC Flag Definitions.
88
89 class isPPC64 { bit PPC64 = 1; }
90 class isVMX   { bit VMX = 1; }
91 class isDOT   {
92   list<Register> Defs = [CR0];
93   bit RC  = 1;
94 }
95
96
97
98 //===----------------------------------------------------------------------===//
99 // PowerPC Operand Definitions.
100
101 def u5imm   : Operand<i32> {
102   let PrintMethod = "printU5ImmOperand";
103 }
104 def u6imm   : Operand<i32> {
105   let PrintMethod = "printU6ImmOperand";
106 }
107 def s16imm  : Operand<i32> {
108   let PrintMethod = "printS16ImmOperand";
109 }
110 def u16imm  : Operand<i32> {
111   let PrintMethod = "printU16ImmOperand";
112 }
113 def s16immX4  : Operand<i32> {   // Multiply imm by 4 before printing.
114   let PrintMethod = "printS16X4ImmOperand";
115 }
116 def target : Operand<i32> {
117   let PrintMethod = "printBranchOperand";
118 }
119 def piclabel: Operand<i32> {
120   let PrintMethod = "printPICLabel";
121 }
122 def symbolHi: Operand<i32> {
123   let PrintMethod = "printSymbolHi";
124 }
125 def symbolLo: Operand<i32> {
126   let PrintMethod = "printSymbolLo";
127 }
128 def crbitm: Operand<i8> {
129   let PrintMethod = "printcrbitm";
130 }
131
132
133
134 //===----------------------------------------------------------------------===//
135 // PowerPC Instruction Definitions.
136
137 // Pseudo-instructions:
138 def PHI : Pseudo<(ops variable_ops), "; PHI">;
139
140 let isLoad = 1 in {
141 def ADJCALLSTACKDOWN : Pseudo<(ops u16imm:$amt), "; ADJCALLSTACKDOWN">;
142 def ADJCALLSTACKUP : Pseudo<(ops u16imm:$amt), "; ADJCALLSTACKUP">;
143 }
144 def IMPLICIT_DEF_GPR : Pseudo<(ops GPRC:$rD), "; $rD = IMPLICIT_DEF_GPRC">;
145 def IMPLICIT_DEF_F8  : Pseudo<(ops F8RC:$rD), "; %rD = IMPLICIT_DEF_F8">;
146 def IMPLICIT_DEF_F4  : Pseudo<(ops F4RC:$rD), "; %rD = IMPLICIT_DEF_F4">;
147
148 // SELECT_CC_* - Used to implement the SELECT_CC DAG operation.  Expanded by the
149 // scheduler into a branch sequence.
150 let usesCustomDAGSchedInserter = 1 in {  // Expanded by the scheduler.
151   def SELECT_CC_Int : Pseudo<(ops GPRC:$dst, CRRC:$cond, GPRC:$T, GPRC:$F,
152                               i32imm:$BROPC), "; SELECT_CC PSEUDO!">;
153   def SELECT_CC_F4  : Pseudo<(ops F4RC:$dst, CRRC:$cond, F4RC:$T, F4RC:$F,
154                               i32imm:$BROPC), "; SELECT_CC PSEUDO!">;
155   def SELECT_CC_F8  : Pseudo<(ops F8RC:$dst, CRRC:$cond, F8RC:$T, F8RC:$F,
156                               i32imm:$BROPC), "; SELECT_CC PSEUDO!">;
157 }
158
159
160 let isTerminator = 1 in {
161   let isReturn = 1 in
162     def BLR : XLForm_2_ext<19, 16, 20, 0, 0, (ops), "blr", BrB>;
163   def BCTR : XLForm_2_ext<19, 528, 20, 0, 0, (ops), "bctr", BrB>;
164 }
165
166 let Defs = [LR] in
167   def MovePCtoLR : Pseudo<(ops piclabel:$label), "bl $label">;
168
169 let isBranch = 1, isTerminator = 1 in {
170   def COND_BRANCH : Pseudo<(ops CRRC:$crS, u16imm:$opc,
171                                 target:$true, target:$false),
172                            "; COND_BRANCH">;
173   def B   : IForm<18, 0, 0, (ops target:$func), "b $func", BrB>;
174 //def BA  : IForm<18, 1, 0, (ops target:$func), "ba $func", BrB>;
175   def BL  : IForm<18, 0, 1, (ops target:$func), "bl $func", BrB>;
176 //def BLA : IForm<18, 1, 1, (ops target:$func), "bla $func", BrB>;
177
178   // FIXME: 4*CR# needs to be added to the BI field!
179   // This will only work for CR0 as it stands now
180   def BLT : BForm<16, 0, 0, 12, 0, (ops CRRC:$crS, target:$block),
181                   "blt $crS, $block", BrB>;
182   def BLE : BForm<16, 0, 0, 4,  1, (ops CRRC:$crS, target:$block),
183                   "ble $crS, $block", BrB>;
184   def BEQ : BForm<16, 0, 0, 12, 2, (ops CRRC:$crS, target:$block),
185                   "beq $crS, $block", BrB>;
186   def BGE : BForm<16, 0, 0, 4,  0, (ops CRRC:$crS, target:$block),
187                   "bge $crS, $block", BrB>;
188   def BGT : BForm<16, 0, 0, 12, 1, (ops CRRC:$crS, target:$block),
189                   "bgt $crS, $block", BrB>;
190   def BNE : BForm<16, 0, 0, 4,  2, (ops CRRC:$crS, target:$block),
191                   "bne $crS, $block", BrB>;
192 }
193
194 let isCall = 1, 
195   // All calls clobber the non-callee saved registers...
196   Defs = [R0,R2,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,
197           F0,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,
198           LR,CTR,
199           CR0,CR1,CR5,CR6,CR7] in {
200   // Convenient aliases for call instructions
201   def CALLpcrel : IForm<18, 0, 1, (ops target:$func, variable_ops),
202                         "bl $func", BrB>;
203   def CALLindirect : XLForm_2_ext<19, 528, 20, 0, 1,
204                                   (ops variable_ops), "bctrl", BrB>;
205 }
206
207 // D-Form instructions.  Most instructions that perform an operation on a
208 // register and an immediate are of this type.
209 //
210 let isLoad = 1 in {
211 def LBZ : DForm_1<34, (ops GPRC:$rD, symbolLo:$disp, GPRC:$rA),
212                   "lbz $rD, $disp($rA)", LdStGeneral>;
213 def LHA : DForm_1<42, (ops GPRC:$rD, symbolLo:$disp, GPRC:$rA),
214                   "lha $rD, $disp($rA)", LdStLHA>;
215 def LHZ : DForm_1<40, (ops GPRC:$rD, symbolLo:$disp, GPRC:$rA),
216                   "lhz $rD, $disp($rA)", LdStGeneral>;
217 def LMW : DForm_1<46, (ops GPRC:$rD, s16imm:$disp, GPRC:$rA),
218                   "lmw $rD, $disp($rA)", LdStLMW>;
219 def LWZ : DForm_1<32, (ops GPRC:$rD, symbolLo:$disp, GPRC:$rA),
220                   "lwz $rD, $disp($rA)", LdStGeneral>;
221 def LWZU : DForm_1<35, (ops GPRC:$rD, s16imm:$disp, GPRC:$rA),
222                    "lwzu $rD, $disp($rA)", LdStGeneral>;
223 }
224 def ADDI   : DForm_2<14, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
225                      "addi $rD, $rA, $imm", IntGeneral,
226                      [(set GPRC:$rD, (add GPRC:$rA, immSExt16:$imm))]>;
227 def ADDIC  : DForm_2<12, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
228                      "addic $rD, $rA, $imm", IntGeneral,
229                      []>;
230 def ADDICo : DForm_2<13, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
231                      "addic. $rD, $rA, $imm", IntGeneral,
232                      []>;
233 def ADDIS  : DForm_2<15, (ops GPRC:$rD, GPRC:$rA, symbolHi:$imm),
234                      "addis $rD, $rA, $imm", IntGeneral,
235                      [(set GPRC:$rD, (add GPRC:$rA, imm16Shifted:$imm))]>;
236 def LA     : DForm_2<14, (ops GPRC:$rD, GPRC:$rA, symbolLo:$sym),
237                      "la $rD, $sym($rA)", IntGeneral,
238                      []>;
239 def MULLI  : DForm_2< 7, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
240                      "mulli $rD, $rA, $imm", IntMulLI,
241                      [(set GPRC:$rD, (mul GPRC:$rA, immSExt16:$imm))]>;
242 def SUBFIC : DForm_2< 8, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
243                      "subfic $rD, $rA, $imm", IntGeneral,
244                      [(set GPRC:$rD, (sub immSExt16:$imm, GPRC:$rA))]>;
245 def LI  : DForm_2_r0<14, (ops GPRC:$rD, s16imm:$imm),
246                      "li $rD, $imm", IntGeneral,
247                      [(set GPRC:$rD, immSExt16:$imm)]>;
248 def LIS : DForm_2_r0<15, (ops GPRC:$rD, symbolHi:$imm),
249                      "lis $rD, $imm", IntGeneral,
250                      [(set GPRC:$rD, imm16Shifted:$imm)]>;
251 let isStore = 1 in {
252 def STMW : DForm_3<47, (ops GPRC:$rS, s16imm:$disp, GPRC:$rA),
253                    "stmw $rS, $disp($rA)", LdStLMW>;
254 def STB  : DForm_3<38, (ops GPRC:$rS, symbolLo:$disp, GPRC:$rA),
255                    "stb $rS, $disp($rA)", LdStGeneral>;
256 def STH  : DForm_3<44, (ops GPRC:$rS, symbolLo:$disp, GPRC:$rA),
257                    "sth $rS, $disp($rA)", LdStGeneral>;
258 def STW  : DForm_3<36, (ops GPRC:$rS, symbolLo:$disp, GPRC:$rA),
259                    "stw $rS, $disp($rA)", LdStGeneral>;
260 def STWU : DForm_3<37, (ops GPRC:$rS, s16imm:$disp, GPRC:$rA),
261                    "stwu $rS, $disp($rA)", LdStGeneral>;
262 }
263 def ANDIo : DForm_4<28, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
264                     "andi. $dst, $src1, $src2", IntGeneral,
265                     []>, isDOT;
266 def ANDISo : DForm_4<29, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
267                     "andis. $dst, $src1, $src2", IntGeneral,
268                     []>, isDOT;
269 def ORI   : DForm_4<24, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
270                     "ori $dst, $src1, $src2", IntGeneral,
271                     [(set GPRC:$dst, (or GPRC:$src1, immZExt16:$src2))]>;
272 def ORIS  : DForm_4<25, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
273                     "oris $dst, $src1, $src2", IntGeneral,
274                     [(set GPRC:$dst, (or GPRC:$src1, imm16Shifted:$src2))]>;
275 def XORI  : DForm_4<26, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
276                     "xori $dst, $src1, $src2", IntGeneral,
277                     [(set GPRC:$dst, (xor GPRC:$src1, immZExt16:$src2))]>;
278 def XORIS : DForm_4<27, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
279                     "xoris $dst, $src1, $src2", IntGeneral,
280                     [(set GPRC:$dst, (xor GPRC:$src1, imm16Shifted:$src2))]>;
281 def NOP   : DForm_4_zero<24, (ops), "nop", IntGeneral>;
282 def CMPI  : DForm_5<11, (ops CRRC:$crD, i1imm:$L, GPRC:$rA, s16imm:$imm),
283                     "cmpi $crD, $L, $rA, $imm", IntCompare>;
284 def CMPWI : DForm_5_ext<11, (ops CRRC:$crD, GPRC:$rA, s16imm:$imm),
285                         "cmpwi $crD, $rA, $imm", IntCompare>;
286 def CMPDI : DForm_5_ext<11, (ops CRRC:$crD, GPRC:$rA, s16imm:$imm),
287                         "cmpdi $crD, $rA, $imm", IntCompare>, isPPC64;
288 def CMPLI  : DForm_6<10, (ops CRRC:$dst, i1imm:$size, GPRC:$src1, u16imm:$src2),
289                      "cmpli $dst, $size, $src1, $src2", IntCompare>;
290 def CMPLWI : DForm_6_ext<10, (ops CRRC:$dst, GPRC:$src1, u16imm:$src2),
291                          "cmplwi $dst, $src1, $src2", IntCompare>;
292 def CMPLDI : DForm_6_ext<10, (ops CRRC:$dst, GPRC:$src1, u16imm:$src2),
293                          "cmpldi $dst, $src1, $src2", IntCompare>, isPPC64;
294 let isLoad = 1 in {
295 def LFS : DForm_8<48, (ops F4RC:$rD, symbolLo:$disp, GPRC:$rA),
296                   "lfs $rD, $disp($rA)", LdStLFDU>;
297 def LFD : DForm_8<50, (ops F8RC:$rD, symbolLo:$disp, GPRC:$rA),
298                   "lfd $rD, $disp($rA)", LdStLFD>;
299 }
300 let isStore = 1 in {
301 def STFS : DForm_9<52, (ops F4RC:$rS, symbolLo:$disp, GPRC:$rA),
302                    "stfs $rS, $disp($rA)", LdStUX>;
303 def STFD : DForm_9<54, (ops F8RC:$rS, symbolLo:$disp, GPRC:$rA),
304                    "stfd $rS, $disp($rA)", LdStUX>;
305 }
306
307 // DS-Form instructions.  Load/Store instructions available in PPC-64
308 //
309 let isLoad = 1 in {
310 def LWA  : DSForm_1<58, 2, (ops GPRC:$rT, s16immX4:$DS, GPRC:$rA),
311                     "lwa $rT, $DS($rA)", LdStLWA>, isPPC64;
312 def LD   : DSForm_2<58, 0, (ops GPRC:$rT, s16immX4:$DS, GPRC:$rA),
313                     "ld $rT, $DS($rA)", LdStLD>, isPPC64;
314 }
315 let isStore = 1 in {
316 def STD  : DSForm_2<62, 0, (ops GPRC:$rT, s16immX4:$DS, GPRC:$rA),
317                     "std $rT, $DS($rA)", LdStSTD>, isPPC64;
318 def STDU : DSForm_2<62, 1, (ops GPRC:$rT, s16immX4:$DS, GPRC:$rA),
319                     "stdu $rT, $DS($rA)", LdStSTD>, isPPC64;
320 }
321
322 // X-Form instructions.  Most instructions that perform an operation on a
323 // register and another register are of this type.
324 //
325 let isLoad = 1 in {
326 def LBZX : XForm_1<31,  87, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
327                    "lbzx $dst, $base, $index", LdStGeneral>;
328 def LHAX : XForm_1<31, 343, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
329                    "lhax $dst, $base, $index", LdStLHA>;
330 def LHZX : XForm_1<31, 279, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
331                    "lhzx $dst, $base, $index", LdStGeneral>;
332 def LWAX : XForm_1<31, 341, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
333                    "lwax $dst, $base, $index", LdStLHA>, isPPC64;
334 def LWZX : XForm_1<31,  23, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
335                    "lwzx $dst, $base, $index", LdStGeneral>;
336 def LDX  : XForm_1<31,  21, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
337                    "ldx $dst, $base, $index", LdStLD>, isPPC64;
338 }
339 def NAND : XForm_6<31, 476, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
340                    "nand $rA, $rS, $rB", IntGeneral,
341                    [(set GPRC:$rA, (not (and GPRC:$rS, GPRC:$rB)))]>;
342 def AND  : XForm_6<31,  28, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
343                    "and $rA, $rS, $rB", IntGeneral,
344                    [(set GPRC:$rA, (and GPRC:$rS, GPRC:$rB))]>;
345 def ANDo : XForm_6<31,  28, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
346                    "and. $rA, $rS, $rB", IntGeneral,
347                    []>, isDOT;
348 def ANDC : XForm_6<31,  60, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
349                    "andc $rA, $rS, $rB", IntGeneral,
350                    [(set GPRC:$rA, (and GPRC:$rS, (not GPRC:$rB)))]>;
351 def OR4  : XForm_6<31, 444, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
352                    "or $rA, $rS, $rB", IntGeneral,
353                    [(set GPRC:$rA, (or GPRC:$rS, GPRC:$rB))]>;
354 def OR8  : XForm_6<31, 444, (ops G8RC:$rA, G8RC:$rS, G8RC:$rB),
355                    "or $rA, $rS, $rB", IntGeneral,
356                    [(set G8RC:$rA, (or G8RC:$rS, G8RC:$rB))]>;
357 def OR4To8  : XForm_6<31, 444, (ops G8RC:$rA, GPRC:$rS, GPRC:$rB),
358                    "or $rA, $rS, $rB", IntGeneral,
359                    []>;
360 def OR8To4  : XForm_6<31, 444, (ops GPRC:$rA, G8RC:$rS, G8RC:$rB),
361                    "or $rA, $rS, $rB", IntGeneral,
362                    []>;
363 def NOR  : XForm_6<31, 124, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
364                    "nor $rA, $rS, $rB", IntGeneral,
365                    [(set GPRC:$rA, (not (or GPRC:$rS, GPRC:$rB)))]>;
366 def ORo  : XForm_6<31, 444, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
367                    "or. $rA, $rS, $rB", IntGeneral,
368                    []>, isDOT;
369 def ORC  : XForm_6<31, 412, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
370                    "orc $rA, $rS, $rB", IntGeneral,
371                    [(set GPRC:$rA, (or GPRC:$rS, (not GPRC:$rB)))]>;
372 def EQV  : XForm_6<31, 284, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
373                    "eqv $rA, $rS, $rB", IntGeneral,
374                    [(set GPRC:$rA, (not (xor GPRC:$rS, GPRC:$rB)))]>;
375 def XOR  : XForm_6<31, 316, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
376                    "xor $rA, $rS, $rB", IntGeneral,
377                    [(set GPRC:$rA, (xor GPRC:$rS, GPRC:$rB))]>;                   
378 def SLD  : XForm_6<31,  27, (ops G8RC:$rA, G8RC:$rS, G8RC:$rB),
379                    "sld $rA, $rS, $rB", IntRotateD,
380                    [(set G8RC:$rA, (shl G8RC:$rS, G8RC:$rB))]>, isPPC64;
381 def SLW  : XForm_6<31,  24, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
382                    "slw $rA, $rS, $rB", IntGeneral,
383                    [(set GPRC:$rA, (shl GPRC:$rS, GPRC:$rB))]>;
384 def SRD  : XForm_6<31, 539, (ops G8RC:$rA, G8RC:$rS, G8RC:$rB),
385                    "srd $rA, $rS, $rB", IntRotateD,
386                    [(set G8RC:$rA, (srl G8RC:$rS, G8RC:$rB))]>, isPPC64;
387 def SRW  : XForm_6<31, 536, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
388                    "srw $rA, $rS, $rB", IntGeneral,
389                    [(set GPRC:$rA, (srl GPRC:$rS, GPRC:$rB))]>;
390 def SRAD : XForm_6<31, 794, (ops G8RC:$rA, G8RC:$rS, G8RC:$rB),
391                    "srad $rA, $rS, $rB", IntRotateD,
392                    [(set G8RC:$rA, (sra G8RC:$rS, G8RC:$rB))]>, isPPC64;
393 def SRAW : XForm_6<31, 792, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
394                    "sraw $rA, $rS, $rB", IntShift,
395                    [(set GPRC:$rA, (sra GPRC:$rS, GPRC:$rB))]>;
396 let isStore = 1 in {
397 def STBX  : XForm_8<31, 215, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
398                    "stbx $rS, $rA, $rB", LdStGeneral>;
399 def STHX  : XForm_8<31, 407, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
400                    "sthx $rS, $rA, $rB", LdStGeneral>;
401 def STWX  : XForm_8<31, 151, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
402                    "stwx $rS, $rA, $rB", LdStGeneral>;
403 def STWUX : XForm_8<31, 183, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
404                    "stwux $rS, $rA, $rB", LdStGeneral>;
405 def STDX  : XForm_8<31, 149, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
406                    "stdx $rS, $rA, $rB", LdStSTD>, isPPC64;
407 def STDUX : XForm_8<31, 181, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
408                    "stdux $rS, $rA, $rB", LdStSTD>, isPPC64;
409 }
410 def SRAWI : XForm_10<31, 824, (ops GPRC:$rA, GPRC:$rS, u5imm:$SH), 
411                      "srawi $rA, $rS, $SH", IntShift,
412                      [(set GPRC:$rA, (sra GPRC:$rS, imm:$SH))]>;
413 def CNTLZW : XForm_11<31,  26, (ops GPRC:$rA, GPRC:$rS),
414                       "cntlzw $rA, $rS", IntGeneral,
415                       [(set GPRC:$rA, (ctlz GPRC:$rS))]>;
416 def EXTSB  : XForm_11<31, 954, (ops GPRC:$rA, GPRC:$rS),
417                       "extsb $rA, $rS", IntGeneral,
418                       [(set GPRC:$rA, (sext_inreg GPRC:$rS, i8))]>;
419 def EXTSH  : XForm_11<31, 922, (ops GPRC:$rA, GPRC:$rS),
420                       "extsh $rA, $rS", IntGeneral,
421                       [(set GPRC:$rA, (sext_inreg GPRC:$rS, i16))]>;
422 def EXTSW  : XForm_11<31, 986, (ops GPRC:$rA, GPRC:$rS),
423                       "extsw $rA, $rS", IntRotateD,
424                       []>, isPPC64;
425 def CMP    : XForm_16<31, 0, (ops CRRC:$crD, i1imm:$long, GPRC:$rA, GPRC:$rB),
426                       "cmp $crD, $long, $rA, $rB", IntCompare>;
427 def CMPL   : XForm_16<31, 32, (ops CRRC:$crD, i1imm:$long, GPRC:$rA, GPRC:$rB),
428                       "cmpl $crD, $long, $rA, $rB", IntCompare>;
429 def CMPW   : XForm_16_ext<31, 0, (ops CRRC:$crD, GPRC:$rA, GPRC:$rB),
430                           "cmpw $crD, $rA, $rB", IntCompare>;
431 def CMPD   : XForm_16_ext<31, 0, (ops CRRC:$crD, GPRC:$rA, GPRC:$rB),
432                           "cmpd $crD, $rA, $rB", IntCompare>, isPPC64;
433 def CMPLW  : XForm_16_ext<31, 32, (ops CRRC:$crD, GPRC:$rA, GPRC:$rB),
434                           "cmplw $crD, $rA, $rB", IntCompare>;
435 def CMPLD  : XForm_16_ext<31, 32, (ops CRRC:$crD, GPRC:$rA, GPRC:$rB),
436                           "cmpld $crD, $rA, $rB", IntCompare>, isPPC64;
437 //def FCMPO  : XForm_17<63, 32, (ops CRRC:$crD, FPRC:$fA, FPRC:$fB),
438 //                      "fcmpo $crD, $fA, $fB", FPCompare>;
439 def FCMPUS : XForm_17<63, 0, (ops CRRC:$crD, F4RC:$fA, F4RC:$fB),
440                       "fcmpu $crD, $fA, $fB", FPCompare>;
441 def FCMPUD : XForm_17<63, 0, (ops CRRC:$crD, F8RC:$fA, F8RC:$fB),
442                       "fcmpu $crD, $fA, $fB", FPCompare>;
443
444 let isLoad = 1 in {
445 def LFSX   : XForm_25<31, 535, (ops F4RC:$dst, GPRC:$base, GPRC:$index),
446                       "lfsx $dst, $base, $index", LdStLFDU>;
447 def LFDX   : XForm_25<31, 599, (ops F8RC:$dst, GPRC:$base, GPRC:$index),
448                       "lfdx $dst, $base, $index", LdStLFDU>;
449 }
450 def FCFID  : XForm_26<63, 846, (ops F8RC:$frD, F8RC:$frB),
451                       "fcfid $frD, $frB", FPGeneral,
452                       []>, isPPC64;
453 def FCTIDZ : XForm_26<63, 815, (ops F8RC:$frD, F8RC:$frB),
454                       "fctidz $frD, $frB", FPGeneral,
455                       []>, isPPC64;
456 def FCTIWZ : XForm_26<63, 15, (ops F8RC:$frD, F8RC:$frB),
457                       "fctiwz $frD, $frB", FPGeneral,
458                       []>;
459 def FRSP   : XForm_26<63, 12, (ops F4RC:$frD, F8RC:$frB),
460                       "frsp $frD, $frB", FPGeneral,
461                       [(set F4RC:$frD, (fround F8RC:$frB))]>;
462 def FSQRT  : XForm_26<63, 22, (ops F8RC:$frD, F8RC:$frB),
463                       "fsqrt $frD, $frB", FPSqrt,
464                       [(set F8RC:$frD, (fsqrt F8RC:$frB))]>;
465 def FSQRTS : XForm_26<59, 22, (ops F4RC:$frD, F4RC:$frB),
466                       "fsqrts $frD, $frB", FPSqrt,
467                       [(set F4RC:$frD, (fsqrt F4RC:$frB))]>;
468
469 /// FMR is split into 3 versions, one for 4/8 byte FP, and one for extending.
470 def FMRS   : XForm_26<63, 72, (ops F4RC:$frD, F4RC:$frB),
471                       "fmr $frD, $frB", FPGeneral,
472                       []>;  // (set F4RC:$frD, F4RC:$frB)
473 def FMRD   : XForm_26<63, 72, (ops F8RC:$frD, F8RC:$frB),
474                       "fmr $frD, $frB", FPGeneral,
475                       []>;  // (set F8RC:$frD, F8RC:$frB)
476 def FMRSD  : XForm_26<63, 72, (ops F8RC:$frD, F4RC:$frB),
477                       "fmr $frD, $frB", FPGeneral,
478                       [(set F8RC:$frD, (fextend F4RC:$frB))]>;
479
480 // These are artificially split into two different forms, for 4/8 byte FP.
481 def FABSS  : XForm_26<63, 264, (ops F4RC:$frD, F4RC:$frB),
482                       "fabs $frD, $frB", FPGeneral,
483                       [(set F4RC:$frD, (fabs F4RC:$frB))]>;
484 def FABSD  : XForm_26<63, 264, (ops F8RC:$frD, F8RC:$frB),
485                       "fabs $frD, $frB", FPGeneral,
486                       [(set F8RC:$frD, (fabs F8RC:$frB))]>;
487 def FNABSS : XForm_26<63, 136, (ops F4RC:$frD, F4RC:$frB),
488                       "fnabs $frD, $frB", FPGeneral,
489                       [(set F4RC:$frD, (fneg (fabs F4RC:$frB)))]>;
490 def FNABSD : XForm_26<63, 136, (ops F8RC:$frD, F8RC:$frB),
491                       "fnabs $frD, $frB", FPGeneral,
492                       [(set F8RC:$frD, (fneg (fabs F8RC:$frB)))]>;
493 def FNEGS  : XForm_26<63, 40, (ops F4RC:$frD, F4RC:$frB),
494                       "fneg $frD, $frB", FPGeneral,
495                       [(set F4RC:$frD, (fneg F4RC:$frB))]>;
496 def FNEGD  : XForm_26<63, 40, (ops F8RC:$frD, F8RC:$frB),
497                       "fneg $frD, $frB", FPGeneral,
498                       [(set F8RC:$frD, (fneg F8RC:$frB))]>;
499                       
500                       
501 let isStore = 1 in {
502 def STFSX : XForm_28<31, 663, (ops F4RC:$frS, GPRC:$rA, GPRC:$rB),
503                      "stfsx $frS, $rA, $rB", LdStUX>;
504 def STFDX : XForm_28<31, 727, (ops F8RC:$frS, GPRC:$rA, GPRC:$rB),
505                      "stfdx $frS, $rA, $rB", LdStUX>;
506 }
507
508 // XL-Form instructions.  condition register logical ops.
509 //
510 def MCRF   : XLForm_3<19, 0, (ops CRRC:$BF, CRRC:$BFA),
511                       "mcrf $BF, $BFA", BrMCR>;
512
513 // XFX-Form instructions.  Instructions that deal with SPRs
514 //
515 // Note that although LR should be listed as `8' and CTR as `9' in the SPR
516 // field, the manual lists the groups of bits as [5-9] = 0, [0-4] = 8 or 9
517 // which means the SPR value needs to be multiplied by a factor of 32.
518 def MFCTR : XFXForm_1_ext<31, 339, 288, (ops GPRC:$rT), "mfctr $rT", SprMFSPR>;
519 def MFLR  : XFXForm_1_ext<31, 339, 256, (ops GPRC:$rT), "mflr $rT", SprMFSPR>;
520 def MFCR  : XFXForm_3<31, 19, (ops GPRC:$rT), "mfcr $rT", SprMFCR>;
521 def MTCRF : XFXForm_5<31, 144, (ops crbitm:$FXM, GPRC:$rS),
522                       "mtcrf $FXM, $rS", BrMCRX>;
523 def MFOCRF : XFXForm_5a<31, 19, (ops GPRC:$rT, crbitm:$FXM),
524                         "mfcr $rT, $FXM", SprMFCR>;
525 def MTCTR : XFXForm_7_ext<31, 467, 288, (ops GPRC:$rS), "mtctr $rS", SprMTSPR>;
526 def MTLR  : XFXForm_7_ext<31, 467, 256, (ops GPRC:$rS), "mtlr $rS", SprMTSPR>;
527
528 // XS-Form instructions.  Just 'sradi'
529 //
530 def SRADI  : XSForm_1<31, 413, (ops GPRC:$rA, GPRC:$rS, u6imm:$SH),
531                       "sradi $rA, $rS, $SH", IntRotateD>, isPPC64;
532
533 // XO-Form instructions.  Arithmetic instructions that can set overflow bit
534 //
535 def ADD4  : XOForm_1<31, 266, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
536                      "add $rT, $rA, $rB", IntGeneral,
537                      [(set GPRC:$rT, (add GPRC:$rA, GPRC:$rB))]>;
538 def ADD8  : XOForm_1<31, 266, 0, (ops G8RC:$rT, G8RC:$rA, G8RC:$rB),
539                      "add $rT, $rA, $rB", IntGeneral,
540                      [(set G8RC:$rT, (add G8RC:$rA, G8RC:$rB))]>;
541 def ADDC  : XOForm_1<31, 10, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
542                      "addc $rT, $rA, $rB", IntGeneral,
543                      []>;
544 def ADDE  : XOForm_1<31, 138, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
545                      "adde $rT, $rA, $rB", IntGeneral,
546                      []>;
547 def DIVD  : XOForm_1<31, 489, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
548                      "divd $rT, $rA, $rB", IntDivD,
549                      []>, isPPC64;
550 def DIVDU : XOForm_1<31, 457, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
551                      "divdu $rT, $rA, $rB", IntDivD,
552                      []>, isPPC64;
553 def DIVW  : XOForm_1<31, 491, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
554                      "divw $rT, $rA, $rB", IntDivW,
555                      [(set GPRC:$rT, (sdiv GPRC:$rA, GPRC:$rB))]>;
556 def DIVWU : XOForm_1<31, 459, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
557                      "divwu $rT, $rA, $rB", IntDivW,
558                      [(set GPRC:$rT, (udiv GPRC:$rA, GPRC:$rB))]>;
559 def MULHW : XOForm_1<31, 75, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
560                      "mulhw $rT, $rA, $rB", IntMulHW,
561                      [(set GPRC:$rT, (mulhs GPRC:$rA, GPRC:$rB))]>;
562 def MULHWU : XOForm_1<31, 11, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
563                      "mulhwu $rT, $rA, $rB", IntMulHWU,
564                      [(set GPRC:$rT, (mulhu GPRC:$rA, GPRC:$rB))]>;
565 def MULLD : XOForm_1<31, 233, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
566                      "mulld $rT, $rA, $rB", IntMulHD,
567                      []>, isPPC64;
568 def MULLW : XOForm_1<31, 235, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
569                      "mullw $rT, $rA, $rB", IntMulHW,
570                      [(set GPRC:$rT, (mul GPRC:$rA, GPRC:$rB))]>;
571 def SUBF  : XOForm_1<31, 40, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
572                      "subf $rT, $rA, $rB", IntGeneral,
573                      [(set GPRC:$rT, (sub GPRC:$rB, GPRC:$rA))]>;
574 def SUBFC : XOForm_1<31, 8, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
575                      "subfc $rT, $rA, $rB", IntGeneral,
576                      []>;
577 def SUBFE : XOForm_1<31, 136, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
578                      "subfe $rT, $rA, $rB", IntGeneral,
579                      []>;
580 def ADDME  : XOForm_3<31, 234, 0, (ops GPRC:$rT, GPRC:$rA),
581                       "addme $rT, $rA", IntGeneral,
582                       []>;
583 def ADDZE  : XOForm_3<31, 202, 0, (ops GPRC:$rT, GPRC:$rA),
584                       "addze $rT, $rA", IntGeneral,
585                       []>;
586 def NEG    : XOForm_3<31, 104, 0, (ops GPRC:$rT, GPRC:$rA),
587                       "neg $rT, $rA", IntGeneral,
588                       [(set GPRC:$rT, (ineg GPRC:$rA))]>;
589 def SUBFZE : XOForm_3<31, 200, 0, (ops GPRC:$rT, GPRC:$rA),
590                       "subfze $rT, $rA", IntGeneral,
591                       []>;
592
593 // A-Form instructions.  Most of the instructions executed in the FPU are of
594 // this type.
595 //
596 def FMADD : AForm_1<63, 29, 
597                     (ops F8RC:$FRT, F8RC:$FRA, F8RC:$FRC, F8RC:$FRB),
598                     "fmadd $FRT, $FRA, $FRC, $FRB", FPFused,
599                     [(set F8RC:$FRT, (fadd (fmul F8RC:$FRA, F8RC:$FRC),
600                                            F8RC:$FRB))]>;
601 def FMADDS : AForm_1<59, 29,
602                     (ops F4RC:$FRT, F4RC:$FRA, F4RC:$FRC, F4RC:$FRB),
603                     "fmadds $FRT, $FRA, $FRC, $FRB", FPGeneral,
604                     [(set F4RC:$FRT, (fadd (fmul F4RC:$FRA, F4RC:$FRC),
605                                            F4RC:$FRB))]>;
606 def FMSUB : AForm_1<63, 28,
607                     (ops F8RC:$FRT, F8RC:$FRA, F8RC:$FRC, F8RC:$FRB),
608                     "fmsub $FRT, $FRA, $FRC, $FRB", FPFused,
609                     [(set F8RC:$FRT, (fsub (fmul F8RC:$FRA, F8RC:$FRC),
610                                            F8RC:$FRB))]>;
611 def FMSUBS : AForm_1<59, 28,
612                     (ops F4RC:$FRT, F4RC:$FRA, F4RC:$FRC, F4RC:$FRB),
613                     "fmsubs $FRT, $FRA, $FRC, $FRB", FPGeneral,
614                     [(set F4RC:$FRT, (fsub (fmul F4RC:$FRA, F4RC:$FRC),
615                                            F4RC:$FRB))]>;
616 def FNMADD : AForm_1<63, 31,
617                     (ops F8RC:$FRT, F8RC:$FRA, F8RC:$FRC, F8RC:$FRB),
618                     "fnmadd $FRT, $FRA, $FRC, $FRB", FPFused,
619                     [(set F8RC:$FRT, (fneg (fadd (fmul F8RC:$FRA, F8RC:$FRC),
620                                                  F8RC:$FRB)))]>;
621 def FNMADDS : AForm_1<59, 31,
622                     (ops F4RC:$FRT, F4RC:$FRA, F4RC:$FRC, F4RC:$FRB),
623                     "fnmadds $FRT, $FRA, $FRC, $FRB", FPGeneral,
624                     [(set F4RC:$FRT, (fneg (fadd (fmul F4RC:$FRA, F4RC:$FRC),
625                                                  F4RC:$FRB)))]>;
626 def FNMSUB : AForm_1<63, 30,
627                     (ops F8RC:$FRT, F8RC:$FRA, F8RC:$FRC, F8RC:$FRB),
628                     "fnmsub $FRT, $FRA, $FRC, $FRB", FPFused,
629                     [(set F8RC:$FRT, (fneg (fsub (fmul F8RC:$FRA, F8RC:$FRC),
630                                                  F8RC:$FRB)))]>;
631 def FNMSUBS : AForm_1<59, 30,
632                     (ops F4RC:$FRT, F4RC:$FRA, F4RC:$FRC, F4RC:$FRB),
633                     "fnmsubs $FRT, $FRA, $FRC, $FRB", FPGeneral,
634                     [(set F4RC:$FRT, (fneg (fsub (fmul F4RC:$FRA, F4RC:$FRC),
635                                                  F4RC:$FRB)))]>;
636 // FSEL is artificially split into 4 and 8-byte forms for the result.  To avoid
637 // having 4 of these, force the comparison to always be an 8-byte double (code
638 // should use an FMRSD if the input comparison value really wants to be a float)
639 // and 4/8 byte forms for the result and operand type..
640 def FSELD : AForm_1<63, 23,
641                     (ops F8RC:$FRT, F8RC:$FRA, F8RC:$FRC, F8RC:$FRB),
642                     "fsel $FRT, $FRA, $FRC, $FRB", FPGeneral,
643                     []>;
644 def FSELS : AForm_1<63, 23,
645                      (ops F4RC:$FRT, F8RC:$FRA, F4RC:$FRC, F4RC:$FRB),
646                      "fsel $FRT, $FRA, $FRC, $FRB", FPGeneral,
647                      []>;
648 def FADD  : AForm_2<63, 21,
649                     (ops F8RC:$FRT, F8RC:$FRA, F8RC:$FRB),
650                     "fadd $FRT, $FRA, $FRB", FPGeneral,
651                     [(set F8RC:$FRT, (fadd F8RC:$FRA, F8RC:$FRB))]>;
652 def FADDS : AForm_2<59, 21,
653                     (ops F4RC:$FRT, F4RC:$FRA, F4RC:$FRB),
654                     "fadds $FRT, $FRA, $FRB", FPGeneral,
655                     [(set F4RC:$FRT, (fadd F4RC:$FRA, F4RC:$FRB))]>;
656 def FDIV  : AForm_2<63, 18,
657                     (ops F8RC:$FRT, F8RC:$FRA, F8RC:$FRB),
658                     "fdiv $FRT, $FRA, $FRB", FPDivD,
659                     [(set F8RC:$FRT, (fdiv F8RC:$FRA, F8RC:$FRB))]>;
660 def FDIVS : AForm_2<59, 18,
661                     (ops F4RC:$FRT, F4RC:$FRA, F4RC:$FRB),
662                     "fdivs $FRT, $FRA, $FRB", FPDivS,
663                     [(set F4RC:$FRT, (fdiv F4RC:$FRA, F4RC:$FRB))]>;
664 def FMUL  : AForm_3<63, 25,
665                     (ops F8RC:$FRT, F8RC:$FRA, F8RC:$FRB),
666                     "fmul $FRT, $FRA, $FRB", FPFused,
667                     [(set F8RC:$FRT, (fmul F8RC:$FRA, F8RC:$FRB))]>;
668 def FMULS : AForm_3<59, 25,
669                     (ops F4RC:$FRT, F4RC:$FRA, F4RC:$FRB),
670                     "fmuls $FRT, $FRA, $FRB", FPGeneral,
671                     [(set F4RC:$FRT, (fmul F4RC:$FRA, F4RC:$FRB))]>;
672 def FSUB  : AForm_2<63, 20,
673                     (ops F8RC:$FRT, F8RC:$FRA, F8RC:$FRB),
674                     "fsub $FRT, $FRA, $FRB", FPGeneral,
675                     [(set F8RC:$FRT, (fsub F8RC:$FRA, F8RC:$FRB))]>;
676 def FSUBS : AForm_2<59, 20,
677                     (ops F4RC:$FRT, F4RC:$FRA, F4RC:$FRB),
678                     "fsubs $FRT, $FRA, $FRB", FPGeneral,
679                     [(set F4RC:$FRT, (fsub F4RC:$FRA, F4RC:$FRB))]>;
680
681 // M-Form instructions.  rotate and mask instructions.
682 //
683 let isTwoAddress = 1, isCommutable = 1 in {
684 // RLWIMI can be commuted if the rotate amount is zero.
685 def RLWIMI : MForm_2<20,
686                      (ops GPRC:$rA, GPRC:$rSi, GPRC:$rS, u5imm:$SH, u5imm:$MB, 
687                       u5imm:$ME), "rlwimi $rA, $rS, $SH, $MB, $ME", IntRotate,
688                       []>;
689 def RLDIMI : MDForm_1<30, 3,
690                       (ops G8RC:$rA, G8RC:$rSi, G8RC:$rS, u6imm:$SH, u6imm:$MB),
691                       "rldimi $rA, $rS, $SH, $MB", IntRotateD,
692                       []>, isPPC64;
693 }
694 def RLWINM : MForm_2<21,
695                      (ops GPRC:$rA, GPRC:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
696                      "rlwinm $rA, $rS, $SH, $MB, $ME", IntGeneral,
697                      []>;
698 def RLWINMo : MForm_2<21,
699                      (ops GPRC:$rA, GPRC:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
700                      "rlwinm. $rA, $rS, $SH, $MB, $ME", IntGeneral,
701                      []>, isDOT;
702 def RLWNM  : MForm_2<23,
703                      (ops GPRC:$rA, GPRC:$rS, GPRC:$rB, u5imm:$MB, u5imm:$ME),
704                      "rlwnm $rA, $rS, $rB, $MB, $ME", IntGeneral,
705                      []>;
706
707 // MD-Form instructions.  64 bit rotate instructions.
708 //
709 def RLDICL : MDForm_1<30, 0,
710                       (ops G8RC:$rA, G8RC:$rS, u6imm:$SH, u6imm:$MB),
711                       "rldicl $rA, $rS, $SH, $MB", IntRotateD,
712                       []>, isPPC64;
713 def RLDICR : MDForm_1<30, 1,
714                       (ops G8RC:$rA, G8RC:$rS, u6imm:$SH, u6imm:$ME),
715                       "rldicr $rA, $rS, $SH, $ME", IntRotateD,
716                       []>, isPPC64;
717
718 //===----------------------------------------------------------------------===//
719 // PowerPC Instruction Patterns
720 //
721
722 // Arbitrary immediate support.  Implement in terms of LIS/ORI.
723 def : Pat<(i32 imm:$imm),
724           (ORI (LIS (HI16 imm:$imm)), (LO16 imm:$imm))>;
725
726 // Implement the 'not' operation with the NOR instruction.
727 def NOT : Pat<(not GPRC:$in),
728               (NOR GPRC:$in, GPRC:$in)>;
729
730 // ADD an arbitrary immediate.
731 def : Pat<(add GPRC:$in, imm:$imm),
732           (ADDIS (ADDI GPRC:$in, (LO16 imm:$imm)), (HA16 imm:$imm))>;
733 // OR an arbitrary immediate.
734 def : Pat<(or GPRC:$in, imm:$imm),
735           (ORIS (ORI GPRC:$in, (LO16 imm:$imm)), (HI16 imm:$imm))>;
736 // XOR an arbitrary immediate.
737 def : Pat<(xor GPRC:$in, imm:$imm),
738           (XORIS (XORI GPRC:$in, (LO16 imm:$imm)), (HI16 imm:$imm))>;
739
740 def : Pat<(zext GPRC:$in),
741           (RLDICL (OR4To8 GPRC:$in, GPRC:$in), 0, 32)>;
742 def : Pat<(anyext GPRC:$in),
743           (OR4To8 GPRC:$in, GPRC:$in)>;
744 def : Pat<(trunc G8RC:$in),
745           (OR8To4 G8RC:$in, G8RC:$in)>;
746
747 // SHL
748 def : Pat<(shl GPRC:$in, imm:$imm),
749           (RLWINM GPRC:$in, imm:$imm, 0, (SHL32 imm:$imm))>;
750 def : Pat<(shl G8RC:$in, imm:$imm),
751           (RLDICR G8RC:$in, imm:$imm, (SHL64 imm:$imm))>;
752 // SRL
753 def : Pat<(srl GPRC:$in, imm:$imm),
754           (RLWINM GPRC:$in, (SRL32 imm:$imm), imm:$imm, 31)>;
755 def : Pat<(srl G8RC:$in, imm:$imm),
756           (RLDICL G8RC:$in, (SRL64 imm:$imm), imm:$imm)>;
757
758 // Same as above, but using a temporary. FIXME: implement temporaries :)
759 /*
760 def : Pattern<(xor GPRC:$in, imm:$imm),
761               [(set GPRC:$tmp, (XORI GPRC:$in, (LO16 imm:$imm))),
762                (XORIS GPRC:$tmp, (HI16 imm:$imm))]>;
763 */
764
765
766 //===----------------------------------------------------------------------===//
767 // PowerPCInstrInfo Definition
768 //
769 def PowerPCInstrInfo : InstrInfo {
770   let PHIInst  = PHI;
771
772   let TSFlagsFields = [ "VMX", "PPC64" ];
773   let TSFlagsShifts = [ 0, 1 ];
774
775   let isLittleEndianEncoding = 1;
776 }
777