Merge ISD::TRUNCSTORE to ISD::STORE. Switch to using StoreSDNode.
[oota-llvm.git] / lib / Target / PowerPC / PPCInstr64Bit.td
1 //===- PPCInstr64Bit.td - The PowerPC 64-bit Support -------*- tablegen -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by Chris Lattner 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 PowerPC 64-bit instructions.  These patterns are used
11 // both when in ppc64 mode and when in "use 64-bit extensions in 32-bit" mode.
12 //
13 //===----------------------------------------------------------------------===//
14
15 //===----------------------------------------------------------------------===//
16 // 64-bit operands.
17 //
18 def s16imm64 : Operand<i64> {
19   let PrintMethod = "printS16ImmOperand";
20 }
21 def u16imm64 : Operand<i64> {
22   let PrintMethod = "printU16ImmOperand";
23 }
24 def symbolHi64 : Operand<i64> {
25   let PrintMethod = "printSymbolHi";
26 }
27 def symbolLo64 : Operand<i64> {
28   let PrintMethod = "printSymbolLo";
29 }
30
31 //===----------------------------------------------------------------------===//
32 // 64-bit transformation functions.
33 //
34
35 def SHL64 : SDNodeXForm<imm, [{
36   // Transformation function: 63 - imm
37   return getI32Imm(63 - N->getValue());
38 }]>;
39
40 def SRL64 : SDNodeXForm<imm, [{
41   // Transformation function: 64 - imm
42   return N->getValue() ? getI32Imm(64 - N->getValue()) : getI32Imm(0);
43 }]>;
44
45 def HI32_48 : SDNodeXForm<imm, [{
46   // Transformation function: shift the immediate value down into the low bits.
47   return getI32Imm((unsigned short)(N->getValue() >> 32));
48 }]>;
49
50 def HI48_64 : SDNodeXForm<imm, [{
51   // Transformation function: shift the immediate value down into the low bits.
52   return getI32Imm((unsigned short)(N->getValue() >> 48));
53 }]>;
54
55
56 //===----------------------------------------------------------------------===//
57 // Pseudo instructions.
58 //
59
60 def IMPLICIT_DEF_G8RC : Pseudo<(ops G8RC:$rD), "; IMPLICIT_DEF_G8RC $rD",
61                               [(set G8RC:$rD, (undef))]>;
62
63 let Pattern = [(PPCmtctr G8RC:$rS)] in {
64 def MTCTR8 : XFXForm_7_ext<31, 467, 9, (ops G8RC:$rS), "mtctr $rS", SprMTSPR>,
65             PPC970_DGroup_First, PPC970_Unit_FXU;
66 }
67
68 //===----------------------------------------------------------------------===//
69 // Fixed point instructions.
70 //
71
72 let PPC970_Unit = 1 in {  // FXU Operations.
73
74 // Copies, extends, truncates.
75 def OR4To8  : XForm_6<31, 444, (ops G8RC:$rA, GPRC:$rS, GPRC:$rB),
76                    "or $rA, $rS, $rB", IntGeneral,
77                    []>;
78 def OR8To4  : XForm_6<31, 444, (ops GPRC:$rA, G8RC:$rS, G8RC:$rB),
79                    "or $rA, $rS, $rB", IntGeneral,
80                    []>;
81
82 def LI8  : DForm_2_r0<14, (ops G8RC:$rD, symbolLo64:$imm),
83                       "li $rD, $imm", IntGeneral,
84                       [(set G8RC:$rD, immSExt16:$imm)]>;
85 def LIS8 : DForm_2_r0<15, (ops G8RC:$rD, symbolHi64:$imm),
86                       "lis $rD, $imm", IntGeneral,
87                       [(set G8RC:$rD, imm16ShiftedSExt:$imm)]>;
88
89 // Logical ops.
90 def NAND8: XForm_6<31, 476, (ops G8RC:$rA, G8RC:$rS, G8RC:$rB),
91                    "nand $rA, $rS, $rB", IntGeneral,
92                    [(set G8RC:$rA, (not (and G8RC:$rS, G8RC:$rB)))]>;
93 def AND8 : XForm_6<31,  28, (ops G8RC:$rA, G8RC:$rS, G8RC:$rB),
94                    "and $rA, $rS, $rB", IntGeneral,
95                    [(set G8RC:$rA, (and G8RC:$rS, G8RC:$rB))]>;
96 def ANDC8: XForm_6<31,  60, (ops G8RC:$rA, G8RC:$rS, G8RC:$rB),
97                    "andc $rA, $rS, $rB", IntGeneral,
98                    [(set G8RC:$rA, (and G8RC:$rS, (not G8RC:$rB)))]>;
99 def OR8  : XForm_6<31, 444, (ops G8RC:$rA, G8RC:$rS, G8RC:$rB),
100                    "or $rA, $rS, $rB", IntGeneral,
101                    [(set G8RC:$rA, (or G8RC:$rS, G8RC:$rB))]>;
102 def NOR8 : XForm_6<31, 124, (ops G8RC:$rA, G8RC:$rS, G8RC:$rB),
103                    "nor $rA, $rS, $rB", IntGeneral,
104                    [(set G8RC:$rA, (not (or G8RC:$rS, G8RC:$rB)))]>;
105 def ORC8 : XForm_6<31, 412, (ops G8RC:$rA, G8RC:$rS, G8RC:$rB),
106                    "orc $rA, $rS, $rB", IntGeneral,
107                    [(set G8RC:$rA, (or G8RC:$rS, (not G8RC:$rB)))]>;
108 def EQV8 : XForm_6<31, 284, (ops G8RC:$rA, G8RC:$rS, G8RC:$rB),
109                    "eqv $rA, $rS, $rB", IntGeneral,
110                    [(set G8RC:$rA, (not (xor G8RC:$rS, G8RC:$rB)))]>;
111 def XOR8 : XForm_6<31, 316, (ops G8RC:$rA, G8RC:$rS, G8RC:$rB),
112                    "xor $rA, $rS, $rB", IntGeneral,
113                    [(set G8RC:$rA, (xor G8RC:$rS, G8RC:$rB))]>;
114
115 // Logical ops with immediate.
116 def ANDIo8  : DForm_4<28, (ops G8RC:$dst, G8RC:$src1, u16imm:$src2),
117                       "andi. $dst, $src1, $src2", IntGeneral,
118                       [(set G8RC:$dst, (and G8RC:$src1, immZExt16:$src2))]>,
119                       isDOT;
120 def ANDISo8 : DForm_4<29, (ops G8RC:$dst, G8RC:$src1, u16imm:$src2),
121                      "andis. $dst, $src1, $src2", IntGeneral,
122                     [(set G8RC:$dst, (and G8RC:$src1,imm16ShiftedZExt:$src2))]>,
123                      isDOT;
124 def ORI8    : DForm_4<24, (ops G8RC:$dst, G8RC:$src1, u16imm:$src2),
125                       "ori $dst, $src1, $src2", IntGeneral,
126                       [(set G8RC:$dst, (or G8RC:$src1, immZExt16:$src2))]>;
127 def ORIS8   : DForm_4<25, (ops G8RC:$dst, G8RC:$src1, u16imm:$src2),
128                       "oris $dst, $src1, $src2", IntGeneral,
129                     [(set G8RC:$dst, (or G8RC:$src1, imm16ShiftedZExt:$src2))]>;
130 def XORI8   : DForm_4<26, (ops G8RC:$dst, G8RC:$src1, u16imm:$src2),
131                       "xori $dst, $src1, $src2", IntGeneral,
132                       [(set G8RC:$dst, (xor G8RC:$src1, immZExt16:$src2))]>;
133 def XORIS8  : DForm_4<27, (ops G8RC:$dst, G8RC:$src1, u16imm:$src2),
134                       "xoris $dst, $src1, $src2", IntGeneral,
135                    [(set G8RC:$dst, (xor G8RC:$src1, imm16ShiftedZExt:$src2))]>;
136
137 def ADD8  : XOForm_1<31, 266, 0, (ops G8RC:$rT, G8RC:$rA, G8RC:$rB),
138                      "add $rT, $rA, $rB", IntGeneral,
139                      [(set G8RC:$rT, (add G8RC:$rA, G8RC:$rB))]>;
140 def ADDI8  : DForm_2<14, (ops G8RC:$rD, G8RC:$rA, s16imm64:$imm),
141                      "addi $rD, $rA, $imm", IntGeneral,
142                      [(set G8RC:$rD, (add G8RC:$rA, immSExt16:$imm))]>;
143 def ADDIS8 : DForm_2<15, (ops G8RC:$rD, G8RC:$rA, symbolHi64:$imm),
144                      "addis $rD, $rA, $imm", IntGeneral,
145                      [(set G8RC:$rD, (add G8RC:$rA, imm16ShiftedSExt:$imm))]>;
146
147 def SUBFIC8: DForm_2< 8, (ops G8RC:$rD, G8RC:$rA, s16imm64:$imm),
148                      "subfic $rD, $rA, $imm", IntGeneral,
149                      [(set G8RC:$rD, (subc immSExt16:$imm, G8RC:$rA))]>;
150 def SUBF8 : XOForm_1<31, 40, 0, (ops G8RC:$rT, G8RC:$rA, G8RC:$rB),
151                      "subf $rT, $rA, $rB", IntGeneral,
152                      [(set G8RC:$rT, (sub G8RC:$rB, G8RC:$rA))]>;
153
154
155 def MULHD : XOForm_1<31, 73, 0, (ops G8RC:$rT, G8RC:$rA, G8RC:$rB),
156                      "mulhd $rT, $rA, $rB", IntMulHW,
157                      [(set G8RC:$rT, (mulhs G8RC:$rA, G8RC:$rB))]>;
158 def MULHDU : XOForm_1<31, 9, 0, (ops G8RC:$rT, G8RC:$rA, G8RC:$rB),
159                      "mulhdu $rT, $rA, $rB", IntMulHWU,
160                      [(set G8RC:$rT, (mulhu G8RC:$rA, G8RC:$rB))]>;
161
162 def CMPD   : XForm_16_ext<31, 0, (ops CRRC:$crD, G8RC:$rA, G8RC:$rB),
163                           "cmpd $crD, $rA, $rB", IntCompare>, isPPC64;
164 def CMPLD  : XForm_16_ext<31, 32, (ops CRRC:$crD, G8RC:$rA, G8RC:$rB),
165                           "cmpld $crD, $rA, $rB", IntCompare>, isPPC64;
166 def CMPDI  : DForm_5_ext<11, (ops CRRC:$crD, G8RC:$rA, s16imm:$imm),
167                          "cmpdi $crD, $rA, $imm", IntCompare>, isPPC64;
168 def CMPLDI : DForm_6_ext<10, (ops CRRC:$dst, G8RC:$src1, u16imm:$src2),
169                          "cmpldi $dst, $src1, $src2", IntCompare>, isPPC64;
170
171 def SLD  : XForm_6<31,  27, (ops G8RC:$rA, G8RC:$rS, GPRC:$rB),
172                    "sld $rA, $rS, $rB", IntRotateD,
173                    [(set G8RC:$rA, (shl G8RC:$rS, GPRC:$rB))]>, isPPC64;
174 def SRD  : XForm_6<31, 539, (ops G8RC:$rA, G8RC:$rS, GPRC:$rB),
175                    "srd $rA, $rS, $rB", IntRotateD,
176                    [(set G8RC:$rA, (srl G8RC:$rS, GPRC:$rB))]>, isPPC64;
177 def SRAD : XForm_6<31, 794, (ops G8RC:$rA, G8RC:$rS, GPRC:$rB),
178                    "srad $rA, $rS, $rB", IntRotateD,
179                    [(set G8RC:$rA, (sra G8RC:$rS, GPRC:$rB))]>, isPPC64;
180 def EXTSW  : XForm_11<31, 986, (ops G8RC:$rA, G8RC:$rS),
181                       "extsw $rA, $rS", IntGeneral,
182                       [(set G8RC:$rA, (sext_inreg G8RC:$rS, i32))]>, isPPC64;
183 /// EXTSW_32 - Just like EXTSW, but works on '32-bit' registers.
184 def EXTSW_32 : XForm_11<31, 986, (ops GPRC:$rA, GPRC:$rS),
185                       "extsw $rA, $rS", IntGeneral,
186                       [(set GPRC:$rA, (PPCextsw_32 GPRC:$rS))]>, isPPC64;
187 def EXTSW_32_64 : XForm_11<31, 986, (ops G8RC:$rA, GPRC:$rS),
188                       "extsw $rA, $rS", IntGeneral,
189                       [(set G8RC:$rA, (sext GPRC:$rS))]>, isPPC64;
190
191 def SRADI  : XSForm_1<31, 413, (ops G8RC:$rA, G8RC:$rS, u6imm:$SH),
192                       "sradi $rA, $rS, $SH", IntRotateD,
193                       [(set G8RC:$rA, (sra G8RC:$rS, (i32 imm:$SH)))]>, isPPC64;
194                       
195 def DIVD  : XOForm_1<31, 489, 0, (ops G8RC:$rT, G8RC:$rA, G8RC:$rB),
196                      "divd $rT, $rA, $rB", IntDivD,
197                      [(set G8RC:$rT, (sdiv G8RC:$rA, G8RC:$rB))]>, isPPC64,
198                      PPC970_DGroup_First, PPC970_DGroup_Cracked;
199 def DIVDU : XOForm_1<31, 457, 0, (ops G8RC:$rT, G8RC:$rA, G8RC:$rB),
200                      "divdu $rT, $rA, $rB", IntDivD,
201                      [(set G8RC:$rT, (udiv G8RC:$rA, G8RC:$rB))]>, isPPC64,
202                      PPC970_DGroup_First, PPC970_DGroup_Cracked;
203 def MULLD : XOForm_1<31, 233, 0, (ops G8RC:$rT, G8RC:$rA, G8RC:$rB),
204                      "mulld $rT, $rA, $rB", IntMulHD,
205                      [(set G8RC:$rT, (mul G8RC:$rA, G8RC:$rB))]>, isPPC64;
206
207
208 let isTwoAddress = 1, isCommutable = 1 in {
209 def RLDIMI : MDForm_1<30, 3,
210                       (ops G8RC:$rA, G8RC:$rSi, G8RC:$rS, u6imm:$SH, u6imm:$MB),
211                       "rldimi $rA, $rS, $SH, $MB", IntRotateD,
212                       []>, isPPC64;
213 }
214
215 // Rotate instructions.
216 def RLDICL : MDForm_1<30, 0,
217                       (ops G8RC:$rA, G8RC:$rS, u6imm:$SH, u6imm:$MB),
218                       "rldicl $rA, $rS, $SH, $MB", IntRotateD,
219                       []>, isPPC64;
220 def RLDICR : MDForm_1<30, 1,
221                       (ops G8RC:$rA, G8RC:$rS, u6imm:$SH, u6imm:$ME),
222                       "rldicr $rA, $rS, $SH, $ME", IntRotateD,
223                       []>, isPPC64;
224 }  // End FXU Operations.
225
226
227 //===----------------------------------------------------------------------===//
228 // Load/Store instructions.
229 //
230
231
232 let isLoad = 1, PPC970_Unit = 2 in {
233 // Sign extending loads.
234 def LHA8: DForm_1<42, (ops G8RC:$rD, memri:$src),
235                   "lha $rD, $src", LdStLHA,
236                   [(set G8RC:$rD, (sextloadi16 iaddr:$src))]>,
237                   PPC970_DGroup_Cracked;
238 def LWA  : DSForm_1<58, 2, (ops G8RC:$rD, memrix:$src),
239                     "lwa $rD, $src", LdStLWA,
240                     [(set G8RC:$rD, (sextloadi32 ixaddr:$src))]>, isPPC64,
241                     PPC970_DGroup_Cracked;
242 def LHAX8: XForm_1<31, 343, (ops G8RC:$rD, memrr:$src),
243                    "lhax $rD, $src", LdStLHA,
244                    [(set G8RC:$rD, (sextloadi16 xaddr:$src))]>,
245                    PPC970_DGroup_Cracked;
246 def LWAX : XForm_1<31, 341, (ops G8RC:$rD, memrr:$src),
247                    "lwax $rD, $src", LdStLHA,
248                    [(set G8RC:$rD, (sextloadi32 xaddr:$src))]>, isPPC64,
249                    PPC970_DGroup_Cracked;
250
251 // Zero extending loads.
252 def LBZ8 : DForm_1<34, (ops G8RC:$rD, memri:$src),
253                   "lbz $rD, $src", LdStGeneral,
254                   [(set G8RC:$rD, (zextloadi8 iaddr:$src))]>;
255 def LHZ8 : DForm_1<40, (ops G8RC:$rD, memri:$src),
256                   "lhz $rD, $src", LdStGeneral,
257                   [(set G8RC:$rD, (zextloadi16 iaddr:$src))]>;
258 def LWZ8 : DForm_1<32, (ops G8RC:$rD, memri:$src),
259                   "lwz $rD, $src", LdStGeneral,
260                   [(set G8RC:$rD, (zextloadi32 iaddr:$src))]>, isPPC64;
261
262 def LBZX8 : XForm_1<31,  87, (ops G8RC:$rD, memrr:$src),
263                    "lbzx $rD, $src", LdStGeneral,
264                    [(set G8RC:$rD, (zextloadi8 xaddr:$src))]>;
265 def LHZX8 : XForm_1<31, 279, (ops G8RC:$rD, memrr:$src),
266                    "lhzx $rD, $src", LdStGeneral,
267                    [(set G8RC:$rD, (zextloadi16 xaddr:$src))]>;
268 def LWZX8 : XForm_1<31,  23, (ops G8RC:$rD, memrr:$src),
269                    "lwzx $rD, $src", LdStGeneral,
270                    [(set G8RC:$rD, (zextloadi32 xaddr:$src))]>;
271
272
273 // Full 8-byte loads.
274 def LD   : DSForm_2<58, 0, (ops G8RC:$rD, memrix:$src),
275                     "ld $rD, $src", LdStLD,
276                     [(set G8RC:$rD, (load ixaddr:$src))]>, isPPC64;
277 def LDX  : XForm_1<31,  21, (ops G8RC:$rD, memrr:$src),
278                    "ldx $rD, $src", LdStLD,
279                    [(set G8RC:$rD, (load xaddr:$src))]>, isPPC64;
280 }
281
282 let isStore = 1, noResults = 1, PPC970_Unit = 2 in {
283 // Normal stores.
284 def STD  : DSForm_2<62, 0, (ops G8RC:$rS, memrix:$dst),
285                     "std $rS, $dst", LdStSTD,
286                     [(store G8RC:$rS, ixaddr:$dst)]>, isPPC64;
287 def STDX  : XForm_8<31, 149, (ops G8RC:$rS, memrr:$dst),
288                    "stdx $rS, $dst", LdStSTD,
289                    [(store G8RC:$rS, xaddr:$dst)]>, isPPC64,
290                    PPC970_DGroup_Cracked;
291 def STDUX : XForm_8<31, 181, (ops G8RC:$rS, memrr:$dst),
292                    "stdux $rS, $dst", LdStSTD,
293                    []>, isPPC64;
294                    
295 // STD_32/STDX_32 - Just like STD/STDX, but uses a '32-bit' input register.
296 def STD_32  : DSForm_2<62, 0, (ops GPRC:$rT, memrix:$dst),
297                        "std $rT, $dst", LdStSTD,
298                        [(PPCstd_32  GPRC:$rT, ixaddr:$dst)]>, isPPC64;
299 def STDX_32  : XForm_8<31, 149, (ops GPRC:$rT, memrr:$dst),
300                        "stdx $rT, $dst", LdStSTD,
301                        [(PPCstd_32  GPRC:$rT, xaddr:$dst)]>, isPPC64,
302                        PPC970_DGroup_Cracked;
303
304 // Truncating stores.                       
305 def STB8 : DForm_3<38, (ops G8RC:$rS, memri:$src),
306                    "stb $rS, $src", LdStGeneral,
307                    [(truncstorei8 G8RC:$rS, iaddr:$src)]>;
308 def STH8 : DForm_3<44, (ops G8RC:$rS, memri:$src),
309                    "sth $rS, $src", LdStGeneral,
310                    [(truncstorei16 G8RC:$rS, iaddr:$src)]>;
311 def STW8 : DForm_3<36, (ops G8RC:$rS, memri:$src),
312                    "stw $rS, $src", LdStGeneral,
313                    [(truncstorei32 G8RC:$rS, iaddr:$src)]>;
314 def STBX8 : XForm_8<31, 215, (ops G8RC:$rS, memrr:$dst),
315                    "stbx $rS, $dst", LdStGeneral,
316                    [(truncstorei8 G8RC:$rS, xaddr:$dst)]>, 
317                    PPC970_DGroup_Cracked;
318 def STHX8 : XForm_8<31, 407, (ops G8RC:$rS, memrr:$dst),
319                    "sthx $rS, $dst", LdStGeneral,
320                    [(truncstorei16 G8RC:$rS, xaddr:$dst)]>, 
321                    PPC970_DGroup_Cracked;
322 def STWX8 : XForm_8<31, 151, (ops G8RC:$rS, memrr:$dst),
323                    "stwx $rS, $dst", LdStGeneral,
324                    [(truncstorei32 G8RC:$rS, xaddr:$dst)]>,
325                    PPC970_DGroup_Cracked;
326 }
327
328
329
330 //===----------------------------------------------------------------------===//
331 // Floating point instructions.
332 //
333
334
335 let PPC970_Unit = 3 in {  // FPU Operations.
336 def FCFID  : XForm_26<63, 846, (ops F8RC:$frD, F8RC:$frB),
337                       "fcfid $frD, $frB", FPGeneral,
338                       [(set F8RC:$frD, (PPCfcfid F8RC:$frB))]>, isPPC64;
339 def FCTIDZ : XForm_26<63, 815, (ops F8RC:$frD, F8RC:$frB),
340                       "fctidz $frD, $frB", FPGeneral,
341                       [(set F8RC:$frD, (PPCfctidz F8RC:$frB))]>, isPPC64;
342 }
343
344
345 //===----------------------------------------------------------------------===//
346 // Instruction Patterns
347 //
348
349 // Immediate support.
350 // Handled above:
351 //   sext(0x0000_0000_0000_FFFF,  i8) -> li imm
352 //   sext(0x0000_0000_FFFF_0000, i16) -> lis imm>>16
353
354 // sext(0x0000_0000_FFFF_FFFF,  i16)  -> lis + ori
355 def sext_0x0000_0000_FFFF_FFFF_i16 : PatLeaf<(imm), [{
356   return N->getValue() == (uint64_t)(int32_t)N->getValue();
357 }]>;
358 def : Pat<(i64 sext_0x0000_0000_FFFF_FFFF_i16:$imm),
359           (ORI8 (LIS8 (HI16 imm:$imm)), (LO16 imm:$imm))>;
360
361 // zext(0x0000_0000_FFFF_7FFF, i16) -> oris (li lo16(imm)), imm>>16
362 def zext_0x0000_0000_FFFF_7FFF_i16 : PatLeaf<(imm), [{
363   return (N->getValue() & 0xFFFFFFFF00008000ULL) == 0;
364 }]>;
365 def : Pat<(i64 zext_0x0000_0000_FFFF_7FFF_i16:$imm),
366           (ORIS8 (LI8 (LO16 imm:$imm)), (HI16 imm:$imm))>;
367
368 // zext(0x0000_0000_FFFF_FFFF, i16) -> oris (ori (li 0), lo16(imm)), imm>>16
369 def zext_0x0000_0000_FFFF_FFFF_i16 : PatLeaf<(imm), [{
370   return (N->getValue() & 0xFFFFFFFF00000000ULL) == 0;
371 }]>;
372 def : Pat<(i64 zext_0x0000_0000_FFFF_FFFF_i16:$imm),
373           (ORIS8 (ORI8 (LI8 0), (LO16 imm:$imm)), (HI16 imm:$imm))>;
374
375 // FIXME: Handle smart forms where the top 32-bits are set.  Right now, stuff
376 // like 0xABCD0123BCDE0000 hits the case below, which produces ORI R, R, 0's! 
377
378 // Fully general (and most expensive: 6 instructions!) immediate pattern.
379 def : Pat<(i64 imm:$imm),
380           (ORI8 
381              (ORIS8 
382                 (RLDICR
383                    (ORI8
384                       (LIS8 (HI48_64 imm:$imm)),
385                       (HI32_48 imm:$imm)),
386                    32, 31),
387                 (HI16 imm:$imm)),
388              (LO16 imm:$imm))>;
389
390
391 // Extensions and truncates to/from 32-bit regs.
392 def : Pat<(i64 (zext GPRC:$in)),
393           (RLDICL (OR4To8 GPRC:$in, GPRC:$in), 0, 32)>;
394 def : Pat<(i64 (anyext GPRC:$in)),
395           (OR4To8 GPRC:$in, GPRC:$in)>;
396 def : Pat<(i32 (trunc G8RC:$in)),
397           (OR8To4 G8RC:$in, G8RC:$in)>;
398
399 // Extending loads with i64 targets.
400 def : Pat<(zextloadi1 iaddr:$src),
401           (LBZ8 iaddr:$src)>;
402 def : Pat<(zextloadi1 xaddr:$src),
403           (LBZX8 xaddr:$src)>;
404 def : Pat<(extloadi1 iaddr:$src),
405           (LBZ8 iaddr:$src)>;
406 def : Pat<(extloadi1 xaddr:$src),
407           (LBZX8 xaddr:$src)>;
408 def : Pat<(extloadi8 iaddr:$src),
409           (LBZ8 iaddr:$src)>;
410 def : Pat<(extloadi8 xaddr:$src),
411           (LBZX8 xaddr:$src)>;
412 def : Pat<(extloadi16 iaddr:$src),
413           (LHZ8 iaddr:$src)>;
414 def : Pat<(extloadi16 xaddr:$src),
415           (LHZX8 xaddr:$src)>;
416 def : Pat<(extloadi32 iaddr:$src),
417           (LWZ8 iaddr:$src)>;
418 def : Pat<(extloadi32 xaddr:$src),
419           (LWZX8 xaddr:$src)>;
420
421 // SHL/SRL
422 def : Pat<(shl G8RC:$in, (i32 imm:$imm)),
423           (RLDICR G8RC:$in, imm:$imm, (SHL64 imm:$imm))>;
424 def : Pat<(srl G8RC:$in, (i32 imm:$imm)),
425           (RLDICL G8RC:$in, (SRL64 imm:$imm), imm:$imm)>;
426
427 // Hi and Lo for Darwin Global Addresses.
428 def : Pat<(PPChi tglobaladdr:$in, 0), (LIS8 tglobaladdr:$in)>;
429 def : Pat<(PPClo tglobaladdr:$in, 0), (LI8  tglobaladdr:$in)>;
430 def : Pat<(PPChi tconstpool:$in , 0), (LIS8 tconstpool:$in)>;
431 def : Pat<(PPClo tconstpool:$in , 0), (LI8  tconstpool:$in)>;
432 def : Pat<(PPChi tjumptable:$in , 0), (LIS8 tjumptable:$in)>;
433 def : Pat<(PPClo tjumptable:$in , 0), (LI8  tjumptable:$in)>;
434 def : Pat<(add G8RC:$in, (PPChi tglobaladdr:$g, 0)),
435           (ADDIS8 G8RC:$in, tglobaladdr:$g)>;
436 def : Pat<(add G8RC:$in, (PPChi tconstpool:$g, 0)),
437           (ADDIS8 G8RC:$in, tconstpool:$g)>;
438 def : Pat<(add G8RC:$in, (PPChi tjumptable:$g, 0)),
439           (ADDIS8 G8RC:$in, tjumptable:$g)>;