1 //===- PPCInstr64Bit.td - The PowerPC 64-bit Support -------*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
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.
13 //===----------------------------------------------------------------------===//
15 //===----------------------------------------------------------------------===//
18 def s16imm64 : Operand<i64> {
19 let PrintMethod = "printS16ImmOperand";
21 def u16imm64 : Operand<i64> {
22 let PrintMethod = "printU16ImmOperand";
24 def symbolHi64 : Operand<i64> {
25 let PrintMethod = "printSymbolHi";
27 def symbolLo64 : Operand<i64> {
28 let PrintMethod = "printSymbolLo";
31 //===----------------------------------------------------------------------===//
32 // 64-bit transformation functions.
35 def SHL64 : SDNodeXForm<imm, [{
36 // Transformation function: 63 - imm
37 return getI32Imm(63 - N->getZExtValue());
40 def SRL64 : SDNodeXForm<imm, [{
41 // Transformation function: 64 - imm
42 return N->getZExtValue() ? getI32Imm(64 - N->getZExtValue()) : getI32Imm(0);
45 def HI32_48 : SDNodeXForm<imm, [{
46 // Transformation function: shift the immediate value down into the low bits.
47 return getI32Imm((unsigned short)(N->getZExtValue() >> 32));
50 def HI48_64 : SDNodeXForm<imm, [{
51 // Transformation function: shift the immediate value down into the low bits.
52 return getI32Imm((unsigned short)(N->getZExtValue() >> 48));
56 //===----------------------------------------------------------------------===//
61 def MovePCtoLR8 : Pseudo<(outs), (ins piclabel:$label), "bl $label", []>,
65 let isCall = 1, PPC970_Unit = 7,
66 // All calls clobber the PPC64 non-callee saved registers.
67 Defs = [X0,X2,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12,
68 F0,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,
69 V0,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11,V12,V13,V14,V15,V16,V17,V18,V19,
71 CR0,CR1,CR5,CR6,CR7] in {
72 // Convenient aliases for call instructions
74 def BL8_Darwin : IForm<18, 0, 1,
75 (outs), (ins calltarget:$func, variable_ops),
76 "bl $func", BrB, []>; // See Pat patterns below.
77 def BLA8_Darwin : IForm<18, 1, 1,
78 (outs), (ins aaddr:$func, variable_ops),
79 "bla $func", BrB, [(PPCcall_Darwin (i64 imm:$func))]>;
81 let Uses = [CTR8, RM] in {
82 def BCTRL8_Darwin : XLForm_2_ext<19, 528, 20, 0, 1,
83 (outs), (ins variable_ops),
85 [(PPCbctrl_Darwin)]>, Requires<[In64BitMode]>;
89 // ELF 64 ABI Calls = Darwin ABI Calls
90 // Used to define BL8_ELF and BLA8_ELF
91 let isCall = 1, PPC970_Unit = 7,
92 // All calls clobber the PPC64 non-callee saved registers.
93 Defs = [X0,X2,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12,
94 F0,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,
95 V0,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11,V12,V13,V14,V15,V16,V17,V18,V19,
97 CR0,CR1,CR5,CR6,CR7] in {
98 // Convenient aliases for call instructions
100 def BL8_ELF : IForm<18, 0, 1,
101 (outs), (ins calltarget:$func, variable_ops),
102 "bl $func", BrB, []>; // See Pat patterns below.
103 def BLA8_ELF : IForm<18, 1, 1,
104 (outs), (ins aaddr:$func, variable_ops),
105 "bla $func", BrB, [(PPCcall_SVR4 (i64 imm:$func))]>;
107 let Uses = [CTR8, RM] in {
108 def BCTRL8_ELF : XLForm_2_ext<19, 528, 20, 0, 1,
109 (outs), (ins variable_ops),
111 [(PPCbctrl_SVR4)]>, Requires<[In64BitMode]>;
117 def : Pat<(PPCcall_Darwin (i64 tglobaladdr:$dst)),
118 (BL8_Darwin tglobaladdr:$dst)>;
119 def : Pat<(PPCcall_Darwin (i64 texternalsym:$dst)),
120 (BL8_Darwin texternalsym:$dst)>;
122 def : Pat<(PPCcall_SVR4 (i64 tglobaladdr:$dst)),
123 (BL8_ELF tglobaladdr:$dst)>;
124 def : Pat<(PPCcall_SVR4 (i64 texternalsym:$dst)),
125 (BL8_ELF texternalsym:$dst)>;
130 let usesCustomDAGSchedInserter = 1 in {
131 let Uses = [CR0] in {
132 def ATOMIC_LOAD_ADD_I64 : Pseudo<
133 (outs G8RC:$dst), (ins memrr:$ptr, G8RC:$incr),
134 "${:comment} ATOMIC_LOAD_ADD_I64 PSEUDO!",
135 [(set G8RC:$dst, (atomic_load_add_64 xoaddr:$ptr, G8RC:$incr))]>;
136 def ATOMIC_LOAD_SUB_I64 : Pseudo<
137 (outs G8RC:$dst), (ins memrr:$ptr, G8RC:$incr),
138 "${:comment} ATOMIC_LOAD_SUB_I64 PSEUDO!",
139 [(set G8RC:$dst, (atomic_load_sub_64 xoaddr:$ptr, G8RC:$incr))]>;
140 def ATOMIC_LOAD_OR_I64 : Pseudo<
141 (outs G8RC:$dst), (ins memrr:$ptr, G8RC:$incr),
142 "${:comment} ATOMIC_LOAD_OR_I64 PSEUDO!",
143 [(set G8RC:$dst, (atomic_load_or_64 xoaddr:$ptr, G8RC:$incr))]>;
144 def ATOMIC_LOAD_XOR_I64 : Pseudo<
145 (outs G8RC:$dst), (ins memrr:$ptr, G8RC:$incr),
146 "${:comment} ATOMIC_LOAD_XOR_I64 PSEUDO!",
147 [(set G8RC:$dst, (atomic_load_xor_64 xoaddr:$ptr, G8RC:$incr))]>;
148 def ATOMIC_LOAD_AND_I64 : Pseudo<
149 (outs G8RC:$dst), (ins memrr:$ptr, G8RC:$incr),
150 "${:comment} ATOMIC_LOAD_AND_I64 PSEUDO!",
151 [(set G8RC:$dst, (atomic_load_and_64 xoaddr:$ptr, G8RC:$incr))]>;
152 def ATOMIC_LOAD_NAND_I64 : Pseudo<
153 (outs G8RC:$dst), (ins memrr:$ptr, G8RC:$incr),
154 "${:comment} ATOMIC_LOAD_NAND_I64 PSEUDO!",
155 [(set G8RC:$dst, (atomic_load_nand_64 xoaddr:$ptr, G8RC:$incr))]>;
157 def ATOMIC_CMP_SWAP_I64 : Pseudo<
158 (outs G8RC:$dst), (ins memrr:$ptr, G8RC:$old, G8RC:$new),
159 "${:comment} ATOMIC_CMP_SWAP_I64 PSEUDO!",
161 (atomic_cmp_swap_64 xoaddr:$ptr, G8RC:$old, G8RC:$new))]>;
163 def ATOMIC_SWAP_I64 : Pseudo<
164 (outs G8RC:$dst), (ins memrr:$ptr, G8RC:$new),
165 "${:comment} ATOMIC_SWAP_I64 PSEUDO!",
166 [(set G8RC:$dst, (atomic_swap_64 xoaddr:$ptr, G8RC:$new))]>;
170 // Instructions to support atomic operations
171 def LDARX : XForm_1<31, 84, (outs G8RC:$rD), (ins memrr:$ptr),
172 "ldarx $rD, $ptr", LdStLDARX,
173 [(set G8RC:$rD, (PPClarx xoaddr:$ptr))]>;
176 def STDCX : XForm_1<31, 214, (outs), (ins G8RC:$rS, memrr:$dst),
177 "stdcx. $rS, $dst", LdStSTDCX,
178 [(PPCstcx G8RC:$rS, xoaddr:$dst)]>,
181 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
182 def TCRETURNdi8 :Pseudo< (outs),
183 (ins calltarget:$dst, i32imm:$offset, variable_ops),
184 "#TC_RETURNd8 $dst $offset",
187 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
188 def TCRETURNai8 :Pseudo<(outs), (ins aaddr:$func, i32imm:$offset, variable_ops),
189 "#TC_RETURNa8 $func $offset",
190 [(PPCtc_return (i64 imm:$func), imm:$offset)]>;
192 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
193 def TCRETURNri8 : Pseudo<(outs), (ins CTRRC8:$dst, i32imm:$offset, variable_ops),
194 "#TC_RETURNr8 $dst $offset",
198 let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, isBranch = 1,
199 isIndirectBranch = 1, isCall = 1, isReturn = 1, Uses = [CTR, RM] in
200 def TAILBCTR8 : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", BrB, []>,
201 Requires<[In64BitMode]>;
205 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
206 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
207 def TAILB8 : IForm<18, 0, 0, (outs), (ins calltarget:$dst),
212 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
213 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
214 def TAILBA8 : IForm<18, 0, 0, (outs), (ins aaddr:$dst),
218 def : Pat<(PPCtc_return (i64 tglobaladdr:$dst), imm:$imm),
219 (TCRETURNdi8 tglobaladdr:$dst, imm:$imm)>;
221 def : Pat<(PPCtc_return (i64 texternalsym:$dst), imm:$imm),
222 (TCRETURNdi8 texternalsym:$dst, imm:$imm)>;
224 def : Pat<(PPCtc_return CTRRC8:$dst, imm:$imm),
225 (TCRETURNri8 CTRRC8:$dst, imm:$imm)>;
228 //===----------------------------------------------------------------------===//
229 // 64-bit SPR manipulation instrs.
231 let Uses = [CTR8] in {
232 def MFCTR8 : XFXForm_1_ext<31, 339, 9, (outs G8RC:$rT), (ins),
233 "mfctr $rT", SprMFSPR>,
234 PPC970_DGroup_First, PPC970_Unit_FXU;
236 let Pattern = [(PPCmtctr G8RC:$rS)], Defs = [CTR8] in {
237 def MTCTR8 : XFXForm_7_ext<31, 467, 9, (outs), (ins G8RC:$rS),
238 "mtctr $rS", SprMTSPR>,
239 PPC970_DGroup_First, PPC970_Unit_FXU;
242 let Defs = [X1], Uses = [X1] in
243 def DYNALLOC8 : Pseudo<(outs G8RC:$result), (ins G8RC:$negsize, memri:$fpsi),
244 "${:comment} DYNALLOC8 $result, $negsize, $fpsi",
246 (PPCdynalloc G8RC:$negsize, iaddr:$fpsi))]>;
248 let Defs = [LR8] in {
249 def MTLR8 : XFXForm_7_ext<31, 467, 8, (outs), (ins G8RC:$rS),
250 "mtlr $rS", SprMTSPR>,
251 PPC970_DGroup_First, PPC970_Unit_FXU;
253 let Uses = [LR8] in {
254 def MFLR8 : XFXForm_1_ext<31, 339, 8, (outs G8RC:$rT), (ins),
255 "mflr $rT", SprMFSPR>,
256 PPC970_DGroup_First, PPC970_Unit_FXU;
259 //===----------------------------------------------------------------------===//
260 // Fixed point instructions.
263 let PPC970_Unit = 1 in { // FXU Operations.
265 // Copies, extends, truncates.
266 def OR4To8 : XForm_6<31, 444, (outs G8RC:$rA), (ins GPRC:$rS, GPRC:$rB),
267 "or $rA, $rS, $rB", IntGeneral,
269 def OR8To4 : XForm_6<31, 444, (outs GPRC:$rA), (ins G8RC:$rS, G8RC:$rB),
270 "or $rA, $rS, $rB", IntGeneral,
273 def LI8 : DForm_2_r0<14, (outs G8RC:$rD), (ins symbolLo64:$imm),
274 "li $rD, $imm", IntGeneral,
275 [(set G8RC:$rD, immSExt16:$imm)]>;
276 def LIS8 : DForm_2_r0<15, (outs G8RC:$rD), (ins symbolHi64:$imm),
277 "lis $rD, $imm", IntGeneral,
278 [(set G8RC:$rD, imm16ShiftedSExt:$imm)]>;
281 def NAND8: XForm_6<31, 476, (outs G8RC:$rA), (ins G8RC:$rS, G8RC:$rB),
282 "nand $rA, $rS, $rB", IntGeneral,
283 [(set G8RC:$rA, (not (and G8RC:$rS, G8RC:$rB)))]>;
284 def AND8 : XForm_6<31, 28, (outs G8RC:$rA), (ins G8RC:$rS, G8RC:$rB),
285 "and $rA, $rS, $rB", IntGeneral,
286 [(set G8RC:$rA, (and G8RC:$rS, G8RC:$rB))]>;
287 def ANDC8: XForm_6<31, 60, (outs G8RC:$rA), (ins G8RC:$rS, G8RC:$rB),
288 "andc $rA, $rS, $rB", IntGeneral,
289 [(set G8RC:$rA, (and G8RC:$rS, (not G8RC:$rB)))]>;
290 def OR8 : XForm_6<31, 444, (outs G8RC:$rA), (ins G8RC:$rS, G8RC:$rB),
291 "or $rA, $rS, $rB", IntGeneral,
292 [(set G8RC:$rA, (or G8RC:$rS, G8RC:$rB))]>;
293 def NOR8 : XForm_6<31, 124, (outs G8RC:$rA), (ins G8RC:$rS, G8RC:$rB),
294 "nor $rA, $rS, $rB", IntGeneral,
295 [(set G8RC:$rA, (not (or G8RC:$rS, G8RC:$rB)))]>;
296 def ORC8 : XForm_6<31, 412, (outs G8RC:$rA), (ins G8RC:$rS, G8RC:$rB),
297 "orc $rA, $rS, $rB", IntGeneral,
298 [(set G8RC:$rA, (or G8RC:$rS, (not G8RC:$rB)))]>;
299 def EQV8 : XForm_6<31, 284, (outs G8RC:$rA), (ins G8RC:$rS, G8RC:$rB),
300 "eqv $rA, $rS, $rB", IntGeneral,
301 [(set G8RC:$rA, (not (xor G8RC:$rS, G8RC:$rB)))]>;
302 def XOR8 : XForm_6<31, 316, (outs G8RC:$rA), (ins G8RC:$rS, G8RC:$rB),
303 "xor $rA, $rS, $rB", IntGeneral,
304 [(set G8RC:$rA, (xor G8RC:$rS, G8RC:$rB))]>;
306 // Logical ops with immediate.
307 def ANDIo8 : DForm_4<28, (outs G8RC:$dst), (ins G8RC:$src1, u16imm:$src2),
308 "andi. $dst, $src1, $src2", IntGeneral,
309 [(set G8RC:$dst, (and G8RC:$src1, immZExt16:$src2))]>,
311 def ANDISo8 : DForm_4<29, (outs G8RC:$dst), (ins G8RC:$src1, u16imm:$src2),
312 "andis. $dst, $src1, $src2", IntGeneral,
313 [(set G8RC:$dst, (and G8RC:$src1,imm16ShiftedZExt:$src2))]>,
315 def ORI8 : DForm_4<24, (outs G8RC:$dst), (ins G8RC:$src1, u16imm:$src2),
316 "ori $dst, $src1, $src2", IntGeneral,
317 [(set G8RC:$dst, (or G8RC:$src1, immZExt16:$src2))]>;
318 def ORIS8 : DForm_4<25, (outs G8RC:$dst), (ins G8RC:$src1, u16imm:$src2),
319 "oris $dst, $src1, $src2", IntGeneral,
320 [(set G8RC:$dst, (or G8RC:$src1, imm16ShiftedZExt:$src2))]>;
321 def XORI8 : DForm_4<26, (outs G8RC:$dst), (ins G8RC:$src1, u16imm:$src2),
322 "xori $dst, $src1, $src2", IntGeneral,
323 [(set G8RC:$dst, (xor G8RC:$src1, immZExt16:$src2))]>;
324 def XORIS8 : DForm_4<27, (outs G8RC:$dst), (ins G8RC:$src1, u16imm:$src2),
325 "xoris $dst, $src1, $src2", IntGeneral,
326 [(set G8RC:$dst, (xor G8RC:$src1, imm16ShiftedZExt:$src2))]>;
328 def ADD8 : XOForm_1<31, 266, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
329 "add $rT, $rA, $rB", IntGeneral,
330 [(set G8RC:$rT, (add G8RC:$rA, G8RC:$rB))]>;
332 def ADDC8 : XOForm_1<31, 10, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
333 "addc $rT, $rA, $rB", IntGeneral,
334 [(set G8RC:$rT, (addc G8RC:$rA, G8RC:$rB))]>,
335 PPC970_DGroup_Cracked;
336 def ADDE8 : XOForm_1<31, 138, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
337 "adde $rT, $rA, $rB", IntGeneral,
338 [(set G8RC:$rT, (adde G8RC:$rA, G8RC:$rB))]>;
340 def ADDI8 : DForm_2<14, (outs G8RC:$rD), (ins G8RC:$rA, s16imm64:$imm),
341 "addi $rD, $rA, $imm", IntGeneral,
342 [(set G8RC:$rD, (add G8RC:$rA, immSExt16:$imm))]>;
343 def ADDIS8 : DForm_2<15, (outs G8RC:$rD), (ins G8RC:$rA, symbolHi64:$imm),
344 "addis $rD, $rA, $imm", IntGeneral,
345 [(set G8RC:$rD, (add G8RC:$rA, imm16ShiftedSExt:$imm))]>;
347 def SUBFIC8: DForm_2< 8, (outs G8RC:$rD), (ins G8RC:$rA, s16imm64:$imm),
348 "subfic $rD, $rA, $imm", IntGeneral,
349 [(set G8RC:$rD, (subc immSExt16:$imm, G8RC:$rA))]>;
350 def SUBF8 : XOForm_1<31, 40, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
351 "subf $rT, $rA, $rB", IntGeneral,
352 [(set G8RC:$rT, (sub G8RC:$rB, G8RC:$rA))]>;
353 def SUBFC8 : XOForm_1<31, 8, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
354 "subfc $rT, $rA, $rB", IntGeneral,
355 [(set G8RC:$rT, (subc G8RC:$rB, G8RC:$rA))]>,
356 PPC970_DGroup_Cracked;
358 def SUBFE8 : XOForm_1<31, 136, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
359 "subfe $rT, $rA, $rB", IntGeneral,
360 [(set G8RC:$rT, (sube G8RC:$rB, G8RC:$rA))]>;
361 def ADDME8 : XOForm_3<31, 234, 0, (outs G8RC:$rT), (ins G8RC:$rA),
362 "addme $rT, $rA", IntGeneral,
363 [(set G8RC:$rT, (adde G8RC:$rA, immAllOnes))]>;
364 def ADDZE8 : XOForm_3<31, 202, 0, (outs G8RC:$rT), (ins G8RC:$rA),
365 "addze $rT, $rA", IntGeneral,
366 [(set G8RC:$rT, (adde G8RC:$rA, 0))]>;
367 def NEG8 : XOForm_3<31, 104, 0, (outs G8RC:$rT), (ins G8RC:$rA),
368 "neg $rT, $rA", IntGeneral,
369 [(set G8RC:$rT, (ineg G8RC:$rA))]>;
370 def SUBFME8 : XOForm_3<31, 232, 0, (outs G8RC:$rT), (ins G8RC:$rA),
371 "subfme $rT, $rA", IntGeneral,
372 [(set G8RC:$rT, (sube immAllOnes, G8RC:$rA))]>;
373 def SUBFZE8 : XOForm_3<31, 200, 0, (outs G8RC:$rT), (ins G8RC:$rA),
374 "subfze $rT, $rA", IntGeneral,
375 [(set G8RC:$rT, (sube 0, G8RC:$rA))]>;
379 def MULHD : XOForm_1<31, 73, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
380 "mulhd $rT, $rA, $rB", IntMulHW,
381 [(set G8RC:$rT, (mulhs G8RC:$rA, G8RC:$rB))]>;
382 def MULHDU : XOForm_1<31, 9, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
383 "mulhdu $rT, $rA, $rB", IntMulHWU,
384 [(set G8RC:$rT, (mulhu G8RC:$rA, G8RC:$rB))]>;
386 def CMPD : XForm_16_ext<31, 0, (outs CRRC:$crD), (ins G8RC:$rA, G8RC:$rB),
387 "cmpd $crD, $rA, $rB", IntCompare>, isPPC64;
388 def CMPLD : XForm_16_ext<31, 32, (outs CRRC:$crD), (ins G8RC:$rA, G8RC:$rB),
389 "cmpld $crD, $rA, $rB", IntCompare>, isPPC64;
390 def CMPDI : DForm_5_ext<11, (outs CRRC:$crD), (ins G8RC:$rA, s16imm:$imm),
391 "cmpdi $crD, $rA, $imm", IntCompare>, isPPC64;
392 def CMPLDI : DForm_6_ext<10, (outs CRRC:$dst), (ins G8RC:$src1, u16imm:$src2),
393 "cmpldi $dst, $src1, $src2", IntCompare>, isPPC64;
395 def SLD : XForm_6<31, 27, (outs G8RC:$rA), (ins G8RC:$rS, GPRC:$rB),
396 "sld $rA, $rS, $rB", IntRotateD,
397 [(set G8RC:$rA, (PPCshl G8RC:$rS, GPRC:$rB))]>, isPPC64;
398 def SRD : XForm_6<31, 539, (outs G8RC:$rA), (ins G8RC:$rS, GPRC:$rB),
399 "srd $rA, $rS, $rB", IntRotateD,
400 [(set G8RC:$rA, (PPCsrl G8RC:$rS, GPRC:$rB))]>, isPPC64;
401 def SRAD : XForm_6<31, 794, (outs G8RC:$rA), (ins G8RC:$rS, GPRC:$rB),
402 "srad $rA, $rS, $rB", IntRotateD,
403 [(set G8RC:$rA, (PPCsra G8RC:$rS, GPRC:$rB))]>, isPPC64;
405 def EXTSB8 : XForm_11<31, 954, (outs G8RC:$rA), (ins G8RC:$rS),
406 "extsb $rA, $rS", IntGeneral,
407 [(set G8RC:$rA, (sext_inreg G8RC:$rS, i8))]>;
408 def EXTSH8 : XForm_11<31, 922, (outs G8RC:$rA), (ins G8RC:$rS),
409 "extsh $rA, $rS", IntGeneral,
410 [(set G8RC:$rA, (sext_inreg G8RC:$rS, i16))]>;
412 def EXTSW : XForm_11<31, 986, (outs G8RC:$rA), (ins G8RC:$rS),
413 "extsw $rA, $rS", IntGeneral,
414 [(set G8RC:$rA, (sext_inreg G8RC:$rS, i32))]>, isPPC64;
415 /// EXTSW_32 - Just like EXTSW, but works on '32-bit' registers.
416 def EXTSW_32 : XForm_11<31, 986, (outs GPRC:$rA), (ins GPRC:$rS),
417 "extsw $rA, $rS", IntGeneral,
418 [(set GPRC:$rA, (PPCextsw_32 GPRC:$rS))]>, isPPC64;
419 def EXTSW_32_64 : XForm_11<31, 986, (outs G8RC:$rA), (ins GPRC:$rS),
420 "extsw $rA, $rS", IntGeneral,
421 [(set G8RC:$rA, (sext GPRC:$rS))]>, isPPC64;
423 def SRADI : XSForm_1<31, 413, (outs G8RC:$rA), (ins G8RC:$rS, u6imm:$SH),
424 "sradi $rA, $rS, $SH", IntRotateD,
425 [(set G8RC:$rA, (sra G8RC:$rS, (i32 imm:$SH)))]>, isPPC64;
426 def CNTLZD : XForm_11<31, 58, (outs G8RC:$rA), (ins G8RC:$rS),
427 "cntlzd $rA, $rS", IntGeneral,
428 [(set G8RC:$rA, (ctlz G8RC:$rS))]>;
430 def DIVD : XOForm_1<31, 489, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
431 "divd $rT, $rA, $rB", IntDivD,
432 [(set G8RC:$rT, (sdiv G8RC:$rA, G8RC:$rB))]>, isPPC64,
433 PPC970_DGroup_First, PPC970_DGroup_Cracked;
434 def DIVDU : XOForm_1<31, 457, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
435 "divdu $rT, $rA, $rB", IntDivD,
436 [(set G8RC:$rT, (udiv G8RC:$rA, G8RC:$rB))]>, isPPC64,
437 PPC970_DGroup_First, PPC970_DGroup_Cracked;
438 def MULLD : XOForm_1<31, 233, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
439 "mulld $rT, $rA, $rB", IntMulHD,
440 [(set G8RC:$rT, (mul G8RC:$rA, G8RC:$rB))]>, isPPC64;
443 let isCommutable = 1 in {
444 def RLDIMI : MDForm_1<30, 3,
445 (outs G8RC:$rA), (ins G8RC:$rSi, G8RC:$rS, u6imm:$SH, u6imm:$MB),
446 "rldimi $rA, $rS, $SH, $MB", IntRotateD,
447 []>, isPPC64, RegConstraint<"$rSi = $rA">,
451 // Rotate instructions.
452 def RLDCL : MDForm_1<30, 0,
453 (outs G8RC:$rA), (ins G8RC:$rS, GPRC:$rB, u6imm:$MB),
454 "rldcl $rA, $rS, $rB, $MB", IntRotateD,
456 def RLDICL : MDForm_1<30, 0,
457 (outs G8RC:$rA), (ins G8RC:$rS, u6imm:$SH, u6imm:$MB),
458 "rldicl $rA, $rS, $SH, $MB", IntRotateD,
460 def RLDICR : MDForm_1<30, 1,
461 (outs G8RC:$rA), (ins G8RC:$rS, u6imm:$SH, u6imm:$ME),
462 "rldicr $rA, $rS, $SH, $ME", IntRotateD,
464 } // End FXU Operations.
467 //===----------------------------------------------------------------------===//
468 // Load/Store instructions.
472 // Sign extending loads.
473 let canFoldAsLoad = 1, PPC970_Unit = 2 in {
474 def LHA8: DForm_1<42, (outs G8RC:$rD), (ins memri:$src),
475 "lha $rD, $src", LdStLHA,
476 [(set G8RC:$rD, (sextloadi16 iaddr:$src))]>,
477 PPC970_DGroup_Cracked;
478 def LWA : DSForm_1<58, 2, (outs G8RC:$rD), (ins memrix:$src),
479 "lwa $rD, $src", LdStLWA,
480 [(set G8RC:$rD, (sextloadi32 ixaddr:$src))]>, isPPC64,
481 PPC970_DGroup_Cracked;
482 def LHAX8: XForm_1<31, 343, (outs G8RC:$rD), (ins memrr:$src),
483 "lhax $rD, $src", LdStLHA,
484 [(set G8RC:$rD, (sextloadi16 xaddr:$src))]>,
485 PPC970_DGroup_Cracked;
486 def LWAX : XForm_1<31, 341, (outs G8RC:$rD), (ins memrr:$src),
487 "lwax $rD, $src", LdStLHA,
488 [(set G8RC:$rD, (sextloadi32 xaddr:$src))]>, isPPC64,
489 PPC970_DGroup_Cracked;
493 def LHAU8 : DForm_1<43, (outs G8RC:$rD, ptr_rc:$ea_result), (ins symbolLo:$disp,
495 "lhau $rD, $disp($rA)", LdStGeneral,
496 []>, RegConstraint<"$rA = $ea_result">,
497 NoEncode<"$ea_result">;
502 // Zero extending loads.
503 let canFoldAsLoad = 1, PPC970_Unit = 2 in {
504 def LBZ8 : DForm_1<34, (outs G8RC:$rD), (ins memri:$src),
505 "lbz $rD, $src", LdStGeneral,
506 [(set G8RC:$rD, (zextloadi8 iaddr:$src))]>;
507 def LHZ8 : DForm_1<40, (outs G8RC:$rD), (ins memri:$src),
508 "lhz $rD, $src", LdStGeneral,
509 [(set G8RC:$rD, (zextloadi16 iaddr:$src))]>;
510 def LWZ8 : DForm_1<32, (outs G8RC:$rD), (ins memri:$src),
511 "lwz $rD, $src", LdStGeneral,
512 [(set G8RC:$rD, (zextloadi32 iaddr:$src))]>, isPPC64;
514 def LBZX8 : XForm_1<31, 87, (outs G8RC:$rD), (ins memrr:$src),
515 "lbzx $rD, $src", LdStGeneral,
516 [(set G8RC:$rD, (zextloadi8 xaddr:$src))]>;
517 def LHZX8 : XForm_1<31, 279, (outs G8RC:$rD), (ins memrr:$src),
518 "lhzx $rD, $src", LdStGeneral,
519 [(set G8RC:$rD, (zextloadi16 xaddr:$src))]>;
520 def LWZX8 : XForm_1<31, 23, (outs G8RC:$rD), (ins memrr:$src),
521 "lwzx $rD, $src", LdStGeneral,
522 [(set G8RC:$rD, (zextloadi32 xaddr:$src))]>;
527 def LBZU8 : DForm_1<35, (outs G8RC:$rD, ptr_rc:$ea_result), (ins memri:$addr),
528 "lbzu $rD, $addr", LdStGeneral,
529 []>, RegConstraint<"$addr.reg = $ea_result">,
530 NoEncode<"$ea_result">;
531 def LHZU8 : DForm_1<41, (outs G8RC:$rD, ptr_rc:$ea_result), (ins memri:$addr),
532 "lhzu $rD, $addr", LdStGeneral,
533 []>, RegConstraint<"$addr.reg = $ea_result">,
534 NoEncode<"$ea_result">;
535 def LWZU8 : DForm_1<33, (outs G8RC:$rD, ptr_rc:$ea_result), (ins memri:$addr),
536 "lwzu $rD, $addr", LdStGeneral,
537 []>, RegConstraint<"$addr.reg = $ea_result">,
538 NoEncode<"$ea_result">;
543 // Full 8-byte loads.
544 let canFoldAsLoad = 1, PPC970_Unit = 2 in {
545 def LD : DSForm_1<58, 0, (outs G8RC:$rD), (ins memrix:$src),
546 "ld $rD, $src", LdStLD,
547 [(set G8RC:$rD, (load ixaddr:$src))]>, isPPC64;
548 def LDtoc: DSForm_1<58, 0, (outs G8RC:$rD), (ins tocentry:$disp, G8RC:$reg),
549 "ld $rD, $disp($reg)", LdStLD,
551 (PPCtoc_entry tglobaladdr:$disp, G8RC:$reg))]>, isPPC64;
552 def LDX : XForm_1<31, 21, (outs G8RC:$rD), (ins memrr:$src),
553 "ldx $rD, $src", LdStLD,
554 [(set G8RC:$rD, (load xaddr:$src))]>, isPPC64;
557 def LDU : DSForm_1<58, 1, (outs G8RC:$rD, ptr_rc:$ea_result), (ins memrix:$addr),
558 "ldu $rD, $addr", LdStLD,
559 []>, RegConstraint<"$addr.reg = $ea_result">, isPPC64,
560 NoEncode<"$ea_result">;
564 let PPC970_Unit = 2 in {
565 // Truncating stores.
566 def STB8 : DForm_1<38, (outs), (ins G8RC:$rS, memri:$src),
567 "stb $rS, $src", LdStGeneral,
568 [(truncstorei8 G8RC:$rS, iaddr:$src)]>;
569 def STH8 : DForm_1<44, (outs), (ins G8RC:$rS, memri:$src),
570 "sth $rS, $src", LdStGeneral,
571 [(truncstorei16 G8RC:$rS, iaddr:$src)]>;
572 def STW8 : DForm_1<36, (outs), (ins G8RC:$rS, memri:$src),
573 "stw $rS, $src", LdStGeneral,
574 [(truncstorei32 G8RC:$rS, iaddr:$src)]>;
575 def STBX8 : XForm_8<31, 215, (outs), (ins G8RC:$rS, memrr:$dst),
576 "stbx $rS, $dst", LdStGeneral,
577 [(truncstorei8 G8RC:$rS, xaddr:$dst)]>,
578 PPC970_DGroup_Cracked;
579 def STHX8 : XForm_8<31, 407, (outs), (ins G8RC:$rS, memrr:$dst),
580 "sthx $rS, $dst", LdStGeneral,
581 [(truncstorei16 G8RC:$rS, xaddr:$dst)]>,
582 PPC970_DGroup_Cracked;
583 def STWX8 : XForm_8<31, 151, (outs), (ins G8RC:$rS, memrr:$dst),
584 "stwx $rS, $dst", LdStGeneral,
585 [(truncstorei32 G8RC:$rS, xaddr:$dst)]>,
586 PPC970_DGroup_Cracked;
587 // Normal 8-byte stores.
588 def STD : DSForm_1<62, 0, (outs), (ins G8RC:$rS, memrix:$dst),
589 "std $rS, $dst", LdStSTD,
590 [(store G8RC:$rS, ixaddr:$dst)]>, isPPC64;
591 def STDX : XForm_8<31, 149, (outs), (ins G8RC:$rS, memrr:$dst),
592 "stdx $rS, $dst", LdStSTD,
593 [(store G8RC:$rS, xaddr:$dst)]>, isPPC64,
594 PPC970_DGroup_Cracked;
597 let PPC970_Unit = 2 in {
599 def STBU8 : DForm_1<38, (outs ptr_rc:$ea_res), (ins G8RC:$rS,
600 symbolLo:$ptroff, ptr_rc:$ptrreg),
601 "stbu $rS, $ptroff($ptrreg)", LdStGeneral,
602 [(set ptr_rc:$ea_res,
603 (pre_truncsti8 G8RC:$rS, ptr_rc:$ptrreg,
604 iaddroff:$ptroff))]>,
605 RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">;
606 def STHU8 : DForm_1<45, (outs ptr_rc:$ea_res), (ins G8RC:$rS,
607 symbolLo:$ptroff, ptr_rc:$ptrreg),
608 "sthu $rS, $ptroff($ptrreg)", LdStGeneral,
609 [(set ptr_rc:$ea_res,
610 (pre_truncsti16 G8RC:$rS, ptr_rc:$ptrreg,
611 iaddroff:$ptroff))]>,
612 RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">;
613 def STWU8 : DForm_1<37, (outs ptr_rc:$ea_res), (ins G8RC:$rS,
614 symbolLo:$ptroff, ptr_rc:$ptrreg),
615 "stwu $rS, $ptroff($ptrreg)", LdStGeneral,
616 [(set ptr_rc:$ea_res, (pre_store G8RC:$rS, ptr_rc:$ptrreg,
617 iaddroff:$ptroff))]>,
618 RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">;
621 def STDU : DSForm_1<62, 1, (outs ptr_rc:$ea_res), (ins G8RC:$rS,
622 s16immX4:$ptroff, ptr_rc:$ptrreg),
623 "stdu $rS, $ptroff($ptrreg)", LdStSTD,
624 [(set ptr_rc:$ea_res, (pre_store G8RC:$rS, ptr_rc:$ptrreg,
625 iaddroff:$ptroff))]>,
626 RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">,
630 def STDUX : XForm_8<31, 181, (outs), (ins G8RC:$rS, memrr:$dst),
631 "stdux $rS, $dst", LdStSTD,
634 // STD_32/STDX_32 - Just like STD/STDX, but uses a '32-bit' input register.
635 def STD_32 : DSForm_1<62, 0, (outs), (ins GPRC:$rT, memrix:$dst),
636 "std $rT, $dst", LdStSTD,
637 [(PPCstd_32 GPRC:$rT, ixaddr:$dst)]>, isPPC64;
638 def STDX_32 : XForm_8<31, 149, (outs), (ins GPRC:$rT, memrr:$dst),
639 "stdx $rT, $dst", LdStSTD,
640 [(PPCstd_32 GPRC:$rT, xaddr:$dst)]>, isPPC64,
641 PPC970_DGroup_Cracked;
646 //===----------------------------------------------------------------------===//
647 // Floating point instructions.
651 let PPC970_Unit = 3, Uses = [RM] in { // FPU Operations.
652 def FCFID : XForm_26<63, 846, (outs F8RC:$frD), (ins F8RC:$frB),
653 "fcfid $frD, $frB", FPGeneral,
654 [(set F8RC:$frD, (PPCfcfid F8RC:$frB))]>, isPPC64;
655 def FCTIDZ : XForm_26<63, 815, (outs F8RC:$frD), (ins F8RC:$frB),
656 "fctidz $frD, $frB", FPGeneral,
657 [(set F8RC:$frD, (PPCfctidz F8RC:$frB))]>, isPPC64;
661 //===----------------------------------------------------------------------===//
662 // Instruction Patterns
665 // Extensions and truncates to/from 32-bit regs.
666 def : Pat<(i64 (zext GPRC:$in)),
667 (RLDICL (OR4To8 GPRC:$in, GPRC:$in), 0, 32)>;
668 def : Pat<(i64 (anyext GPRC:$in)),
669 (OR4To8 GPRC:$in, GPRC:$in)>;
670 def : Pat<(i32 (trunc G8RC:$in)),
671 (OR8To4 G8RC:$in, G8RC:$in)>;
673 // Extending loads with i64 targets.
674 def : Pat<(zextloadi1 iaddr:$src),
676 def : Pat<(zextloadi1 xaddr:$src),
678 def : Pat<(extloadi1 iaddr:$src),
680 def : Pat<(extloadi1 xaddr:$src),
682 def : Pat<(extloadi8 iaddr:$src),
684 def : Pat<(extloadi8 xaddr:$src),
686 def : Pat<(extloadi16 iaddr:$src),
688 def : Pat<(extloadi16 xaddr:$src),
690 def : Pat<(extloadi32 iaddr:$src),
692 def : Pat<(extloadi32 xaddr:$src),
695 // Standard shifts. These are represented separately from the real shifts above
696 // so that we can distinguish between shifts that allow 6-bit and 7-bit shift
698 def : Pat<(sra G8RC:$rS, GPRC:$rB),
699 (SRAD G8RC:$rS, GPRC:$rB)>;
700 def : Pat<(srl G8RC:$rS, GPRC:$rB),
701 (SRD G8RC:$rS, GPRC:$rB)>;
702 def : Pat<(shl G8RC:$rS, GPRC:$rB),
703 (SLD G8RC:$rS, GPRC:$rB)>;
706 def : Pat<(shl G8RC:$in, (i32 imm:$imm)),
707 (RLDICR G8RC:$in, imm:$imm, (SHL64 imm:$imm))>;
708 def : Pat<(srl G8RC:$in, (i32 imm:$imm)),
709 (RLDICL G8RC:$in, (SRL64 imm:$imm), imm:$imm)>;
712 def : Pat<(rotl G8RC:$in, GPRC:$sh),
713 (RLDCL G8RC:$in, GPRC:$sh, 0)>;
714 def : Pat<(rotl G8RC:$in, (i32 imm:$imm)),
715 (RLDICL G8RC:$in, imm:$imm, 0)>;
717 // Hi and Lo for Darwin Global Addresses.
718 def : Pat<(PPChi tglobaladdr:$in, 0), (LIS8 tglobaladdr:$in)>;
719 def : Pat<(PPClo tglobaladdr:$in, 0), (LI8 tglobaladdr:$in)>;
720 def : Pat<(PPChi tconstpool:$in , 0), (LIS8 tconstpool:$in)>;
721 def : Pat<(PPClo tconstpool:$in , 0), (LI8 tconstpool:$in)>;
722 def : Pat<(PPChi tjumptable:$in , 0), (LIS8 tjumptable:$in)>;
723 def : Pat<(PPClo tjumptable:$in , 0), (LI8 tjumptable:$in)>;
724 def : Pat<(add G8RC:$in, (PPChi tglobaladdr:$g, 0)),
725 (ADDIS8 G8RC:$in, tglobaladdr:$g)>;
726 def : Pat<(add G8RC:$in, (PPChi tconstpool:$g, 0)),
727 (ADDIS8 G8RC:$in, tconstpool:$g)>;
728 def : Pat<(add G8RC:$in, (PPChi tjumptable:$g, 0)),
729 (ADDIS8 G8RC:$in, tjumptable:$g)>;