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";
26 let EncoderMethod = "getHA16Encoding";
28 def symbolLo64 : Operand<i64> {
29 let PrintMethod = "printSymbolLo";
30 let EncoderMethod = "getLO16Encoding";
33 //===----------------------------------------------------------------------===//
34 // 64-bit transformation functions.
37 def SHL64 : SDNodeXForm<imm, [{
38 // Transformation function: 63 - imm
39 return getI32Imm(63 - N->getZExtValue());
42 def SRL64 : SDNodeXForm<imm, [{
43 // Transformation function: 64 - imm
44 return N->getZExtValue() ? getI32Imm(64 - N->getZExtValue()) : getI32Imm(0);
47 def HI32_48 : SDNodeXForm<imm, [{
48 // Transformation function: shift the immediate value down into the low bits.
49 return getI32Imm((unsigned short)(N->getZExtValue() >> 32));
52 def HI48_64 : SDNodeXForm<imm, [{
53 // Transformation function: shift the immediate value down into the low bits.
54 return getI32Imm((unsigned short)(N->getZExtValue() >> 48));
58 //===----------------------------------------------------------------------===//
63 def MovePCtoLR8 : Pseudo<(outs), (ins), "", []>,
67 let isCall = 1, PPC970_Unit = 7,
68 // All calls clobber the PPC64 non-callee saved registers.
69 Defs = [X0,X2,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12,
70 F0,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,
71 V0,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11,V12,V13,V14,V15,V16,V17,V18,V19,
73 CR0,CR1,CR5,CR6,CR7,CARRY] in {
74 // Convenient aliases for call instructions
76 def BL8_Darwin : IForm<18, 0, 1,
77 (outs), (ins calltarget:$func, variable_ops),
78 "bl $func", BrB, []>; // See Pat patterns below.
79 def BLA8_Darwin : IForm<18, 1, 1,
80 (outs), (ins aaddr:$func, variable_ops),
81 "bla $func", BrB, [(PPCcall_Darwin (i64 imm:$func))]>;
83 let Uses = [CTR8, RM] in {
84 def BCTRL8_Darwin : XLForm_2_ext<19, 528, 20, 0, 1,
85 (outs), (ins variable_ops),
87 [(PPCbctrl_Darwin)]>, Requires<[In64BitMode]>;
91 // ELF 64 ABI Calls = Darwin ABI Calls
92 // Used to define BL8_ELF and BLA8_ELF
93 let isCall = 1, PPC970_Unit = 7,
94 // All calls clobber the PPC64 non-callee saved registers.
95 Defs = [X0,X2,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12,
96 F0,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,
97 V0,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11,V12,V13,V14,V15,V16,V17,V18,V19,
99 CR0,CR1,CR5,CR6,CR7,CARRY] in {
100 // Convenient aliases for call instructions
102 def BL8_ELF : IForm<18, 0, 1,
103 (outs), (ins calltarget:$func, variable_ops),
104 "bl $func", BrB, []>; // See Pat patterns below.
105 def BLA8_ELF : IForm<18, 1, 1,
106 (outs), (ins aaddr:$func, variable_ops),
107 "bla $func", BrB, [(PPCcall_SVR4 (i64 imm:$func))]>;
109 let Uses = [X11, CTR8, RM] in {
110 def BCTRL8_ELF : XLForm_2_ext<19, 528, 20, 0, 1,
111 (outs), (ins variable_ops),
113 [(PPCbctrl_SVR4)]>, Requires<[In64BitMode]>;
119 def : Pat<(PPCcall_Darwin (i64 tglobaladdr:$dst)),
120 (BL8_Darwin tglobaladdr:$dst)>;
121 def : Pat<(PPCcall_Darwin (i64 texternalsym:$dst)),
122 (BL8_Darwin texternalsym:$dst)>;
124 def : Pat<(PPCcall_SVR4 (i64 tglobaladdr:$dst)),
125 (BL8_ELF tglobaladdr:$dst)>;
126 def : Pat<(PPCcall_SVR4 (i64 texternalsym:$dst)),
127 (BL8_ELF texternalsym:$dst)>;
132 let usesCustomInserter = 1 in {
133 let Defs = [CR0] in {
134 def ATOMIC_LOAD_ADD_I64 : Pseudo<
135 (outs G8RC:$dst), (ins memrr:$ptr, G8RC:$incr), "",
136 [(set G8RC:$dst, (atomic_load_add_64 xoaddr:$ptr, G8RC:$incr))]>;
137 def ATOMIC_LOAD_SUB_I64 : Pseudo<
138 (outs G8RC:$dst), (ins memrr:$ptr, G8RC:$incr), "",
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 [(set G8RC:$dst, (atomic_load_or_64 xoaddr:$ptr, G8RC:$incr))]>;
143 def ATOMIC_LOAD_XOR_I64 : Pseudo<
144 (outs G8RC:$dst), (ins memrr:$ptr, G8RC:$incr), "",
145 [(set G8RC:$dst, (atomic_load_xor_64 xoaddr:$ptr, G8RC:$incr))]>;
146 def ATOMIC_LOAD_AND_I64 : Pseudo<
147 (outs G8RC:$dst), (ins memrr:$ptr, G8RC:$incr), "",
148 [(set G8RC:$dst, (atomic_load_and_64 xoaddr:$ptr, G8RC:$incr))]>;
149 def ATOMIC_LOAD_NAND_I64 : Pseudo<
150 (outs G8RC:$dst), (ins memrr:$ptr, G8RC:$incr), "",
151 [(set G8RC:$dst, (atomic_load_nand_64 xoaddr:$ptr, G8RC:$incr))]>;
153 def ATOMIC_CMP_SWAP_I64 : Pseudo<
154 (outs G8RC:$dst), (ins memrr:$ptr, G8RC:$old, G8RC:$new), "",
156 (atomic_cmp_swap_64 xoaddr:$ptr, G8RC:$old, G8RC:$new))]>;
158 def ATOMIC_SWAP_I64 : Pseudo<
159 (outs G8RC:$dst), (ins memrr:$ptr, G8RC:$new), "",
160 [(set G8RC:$dst, (atomic_swap_64 xoaddr:$ptr, G8RC:$new))]>;
164 // Instructions to support atomic operations
165 def LDARX : XForm_1<31, 84, (outs G8RC:$rD), (ins memrr:$ptr),
166 "ldarx $rD, $ptr", LdStLDARX,
167 [(set G8RC:$rD, (PPClarx xoaddr:$ptr))]>;
170 def STDCX : XForm_1<31, 214, (outs), (ins G8RC:$rS, memrr:$dst),
171 "stdcx. $rS, $dst", LdStSTDCX,
172 [(PPCstcx G8RC:$rS, xoaddr:$dst)]>,
175 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
176 def TCRETURNdi8 :Pseudo< (outs),
177 (ins calltarget:$dst, i32imm:$offset, variable_ops),
178 "#TC_RETURNd8 $dst $offset",
181 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
182 def TCRETURNai8 :Pseudo<(outs), (ins aaddr:$func, i32imm:$offset, variable_ops),
183 "#TC_RETURNa8 $func $offset",
184 [(PPCtc_return (i64 imm:$func), imm:$offset)]>;
186 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
187 def TCRETURNri8 : Pseudo<(outs), (ins CTRRC8:$dst, i32imm:$offset, variable_ops),
188 "#TC_RETURNr8 $dst $offset",
192 let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, isBranch = 1,
193 isIndirectBranch = 1, isCall = 1, Uses = [CTR8, RM] in {
194 let isReturn = 1 in {
195 def TAILBCTR8 : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", BrB, []>,
196 Requires<[In64BitMode]>;
199 def BCTR8 : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", BrB, []>,
200 Requires<[In64BitMode]>;
204 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
205 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
206 def TAILB8 : IForm<18, 0, 0, (outs), (ins calltarget:$dst),
211 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
212 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
213 def TAILBA8 : IForm<18, 0, 0, (outs), (ins aaddr:$dst),
217 def : Pat<(PPCtc_return (i64 tglobaladdr:$dst), imm:$imm),
218 (TCRETURNdi8 tglobaladdr:$dst, imm:$imm)>;
220 def : Pat<(PPCtc_return (i64 texternalsym:$dst), imm:$imm),
221 (TCRETURNdi8 texternalsym:$dst, imm:$imm)>;
223 def : Pat<(PPCtc_return CTRRC8:$dst, imm:$imm),
224 (TCRETURNri8 CTRRC8:$dst, imm:$imm)>;
226 // 64-but CR instructions
227 def MTCRF8 : XFXForm_5<31, 144, (outs crbitm:$FXM), (ins G8RC:$rS),
228 "mtcrf $FXM, $rS", BrMCRX>,
229 PPC970_MicroCode, PPC970_Unit_CRU;
231 def MFCR8pseud: XFXForm_3<31, 19, (outs G8RC:$rT), (ins crbitm:$FXM),
233 PPC970_MicroCode, PPC970_Unit_CRU;
235 def MFCR8 : XFXForm_3<31, 19, (outs G8RC:$rT), (ins),
236 "mfcr $rT", SprMFCR>,
237 PPC970_MicroCode, PPC970_Unit_CRU;
239 //===----------------------------------------------------------------------===//
240 // 64-bit SPR manipulation instrs.
242 let Uses = [CTR8] in {
243 def MFCTR8 : XFXForm_1_ext<31, 339, 9, (outs G8RC:$rT), (ins),
244 "mfctr $rT", SprMFSPR>,
245 PPC970_DGroup_First, PPC970_Unit_FXU;
247 let Pattern = [(PPCmtctr G8RC:$rS)], Defs = [CTR8] in {
248 def MTCTR8 : XFXForm_7_ext<31, 467, 9, (outs), (ins G8RC:$rS),
249 "mtctr $rS", SprMTSPR>,
250 PPC970_DGroup_First, PPC970_Unit_FXU;
253 let Defs = [X1], Uses = [X1] in
254 def DYNALLOC8 : Pseudo<(outs G8RC:$result), (ins G8RC:$negsize, memri:$fpsi),"",
256 (PPCdynalloc G8RC:$negsize, iaddr:$fpsi))]>;
258 let Defs = [LR8] in {
259 def MTLR8 : XFXForm_7_ext<31, 467, 8, (outs), (ins G8RC:$rS),
260 "mtlr $rS", SprMTSPR>,
261 PPC970_DGroup_First, PPC970_Unit_FXU;
263 let Uses = [LR8] in {
264 def MFLR8 : XFXForm_1_ext<31, 339, 8, (outs G8RC:$rT), (ins),
265 "mflr $rT", SprMFSPR>,
266 PPC970_DGroup_First, PPC970_Unit_FXU;
269 //===----------------------------------------------------------------------===//
270 // Fixed point instructions.
273 let PPC970_Unit = 1 in { // FXU Operations.
275 // Copies, extends, truncates.
276 def OR4To8 : XForm_6<31, 444, (outs G8RC:$rA), (ins GPRC:$rS, GPRC:$rB),
277 "or $rA, $rS, $rB", IntGeneral,
279 def OR8To4 : XForm_6<31, 444, (outs GPRC:$rA), (ins G8RC:$rS, G8RC:$rB),
280 "or $rA, $rS, $rB", IntGeneral,
283 def LI8 : DForm_2_r0<14, (outs G8RC:$rD), (ins symbolLo64:$imm),
284 "li $rD, $imm", IntGeneral,
285 [(set G8RC:$rD, immSExt16:$imm)]>;
286 def LIS8 : DForm_2_r0<15, (outs G8RC:$rD), (ins symbolHi64:$imm),
287 "lis $rD, $imm", IntGeneral,
288 [(set G8RC:$rD, imm16ShiftedSExt:$imm)]>;
291 def NAND8: XForm_6<31, 476, (outs G8RC:$rA), (ins G8RC:$rS, G8RC:$rB),
292 "nand $rA, $rS, $rB", IntGeneral,
293 [(set G8RC:$rA, (not (and G8RC:$rS, G8RC:$rB)))]>;
294 def AND8 : XForm_6<31, 28, (outs G8RC:$rA), (ins G8RC:$rS, G8RC:$rB),
295 "and $rA, $rS, $rB", IntGeneral,
296 [(set G8RC:$rA, (and G8RC:$rS, G8RC:$rB))]>;
297 def ANDC8: XForm_6<31, 60, (outs G8RC:$rA), (ins G8RC:$rS, G8RC:$rB),
298 "andc $rA, $rS, $rB", IntGeneral,
299 [(set G8RC:$rA, (and G8RC:$rS, (not G8RC:$rB)))]>;
300 def OR8 : XForm_6<31, 444, (outs G8RC:$rA), (ins G8RC:$rS, G8RC:$rB),
301 "or $rA, $rS, $rB", IntGeneral,
302 [(set G8RC:$rA, (or G8RC:$rS, G8RC:$rB))]>;
303 def NOR8 : XForm_6<31, 124, (outs G8RC:$rA), (ins G8RC:$rS, G8RC:$rB),
304 "nor $rA, $rS, $rB", IntGeneral,
305 [(set G8RC:$rA, (not (or G8RC:$rS, G8RC:$rB)))]>;
306 def ORC8 : XForm_6<31, 412, (outs G8RC:$rA), (ins G8RC:$rS, G8RC:$rB),
307 "orc $rA, $rS, $rB", IntGeneral,
308 [(set G8RC:$rA, (or G8RC:$rS, (not G8RC:$rB)))]>;
309 def EQV8 : XForm_6<31, 284, (outs G8RC:$rA), (ins G8RC:$rS, G8RC:$rB),
310 "eqv $rA, $rS, $rB", IntGeneral,
311 [(set G8RC:$rA, (not (xor G8RC:$rS, G8RC:$rB)))]>;
312 def XOR8 : XForm_6<31, 316, (outs G8RC:$rA), (ins G8RC:$rS, G8RC:$rB),
313 "xor $rA, $rS, $rB", IntGeneral,
314 [(set G8RC:$rA, (xor G8RC:$rS, G8RC:$rB))]>;
316 // Logical ops with immediate.
317 def ANDIo8 : DForm_4<28, (outs G8RC:$dst), (ins G8RC:$src1, u16imm:$src2),
318 "andi. $dst, $src1, $src2", IntGeneral,
319 [(set G8RC:$dst, (and G8RC:$src1, immZExt16:$src2))]>,
321 def ANDISo8 : DForm_4<29, (outs G8RC:$dst), (ins G8RC:$src1, u16imm:$src2),
322 "andis. $dst, $src1, $src2", IntGeneral,
323 [(set G8RC:$dst, (and G8RC:$src1,imm16ShiftedZExt:$src2))]>,
325 def ORI8 : DForm_4<24, (outs G8RC:$dst), (ins G8RC:$src1, u16imm:$src2),
326 "ori $dst, $src1, $src2", IntGeneral,
327 [(set G8RC:$dst, (or G8RC:$src1, immZExt16:$src2))]>;
328 def ORIS8 : DForm_4<25, (outs G8RC:$dst), (ins G8RC:$src1, u16imm:$src2),
329 "oris $dst, $src1, $src2", IntGeneral,
330 [(set G8RC:$dst, (or G8RC:$src1, imm16ShiftedZExt:$src2))]>;
331 def XORI8 : DForm_4<26, (outs G8RC:$dst), (ins G8RC:$src1, u16imm:$src2),
332 "xori $dst, $src1, $src2", IntGeneral,
333 [(set G8RC:$dst, (xor G8RC:$src1, immZExt16:$src2))]>;
334 def XORIS8 : DForm_4<27, (outs G8RC:$dst), (ins G8RC:$src1, u16imm:$src2),
335 "xoris $dst, $src1, $src2", IntGeneral,
336 [(set G8RC:$dst, (xor G8RC:$src1, imm16ShiftedZExt:$src2))]>;
338 def ADD8 : XOForm_1<31, 266, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
339 "add $rT, $rA, $rB", IntGeneral,
340 [(set G8RC:$rT, (add G8RC:$rA, G8RC:$rB))]>;
342 let Defs = [CARRY] in {
343 def ADDC8 : XOForm_1<31, 10, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
344 "addc $rT, $rA, $rB", IntGeneral,
345 [(set G8RC:$rT, (addc G8RC:$rA, G8RC:$rB))]>,
346 PPC970_DGroup_Cracked;
347 def ADDIC8 : DForm_2<12, (outs G8RC:$rD), (ins G8RC:$rA, s16imm64:$imm),
348 "addic $rD, $rA, $imm", IntGeneral,
349 [(set G8RC:$rD, (addc G8RC:$rA, immSExt16:$imm))]>;
351 def ADDI8 : DForm_2<14, (outs G8RC:$rD), (ins G8RC:$rA, s16imm64:$imm),
352 "addi $rD, $rA, $imm", IntGeneral,
353 [(set G8RC:$rD, (add G8RC:$rA, immSExt16:$imm))]>;
354 def ADDIS8 : DForm_2<15, (outs G8RC:$rD), (ins G8RC:$rA, symbolHi64:$imm),
355 "addis $rD, $rA, $imm", IntGeneral,
356 [(set G8RC:$rD, (add G8RC:$rA, imm16ShiftedSExt:$imm))]>;
358 let Defs = [CARRY] in {
359 def SUBFIC8: DForm_2< 8, (outs G8RC:$rD), (ins G8RC:$rA, s16imm64:$imm),
360 "subfic $rD, $rA, $imm", IntGeneral,
361 [(set G8RC:$rD, (subc immSExt16:$imm, G8RC:$rA))]>;
362 def SUBFC8 : XOForm_1<31, 8, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
363 "subfc $rT, $rA, $rB", IntGeneral,
364 [(set G8RC:$rT, (subc G8RC:$rB, G8RC:$rA))]>,
365 PPC970_DGroup_Cracked;
367 def SUBF8 : XOForm_1<31, 40, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
368 "subf $rT, $rA, $rB", IntGeneral,
369 [(set G8RC:$rT, (sub G8RC:$rB, G8RC:$rA))]>;
370 def NEG8 : XOForm_3<31, 104, 0, (outs G8RC:$rT), (ins G8RC:$rA),
371 "neg $rT, $rA", IntGeneral,
372 [(set G8RC:$rT, (ineg G8RC:$rA))]>;
373 let Uses = [CARRY], Defs = [CARRY] in {
374 def ADDE8 : XOForm_1<31, 138, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
375 "adde $rT, $rA, $rB", IntGeneral,
376 [(set G8RC:$rT, (adde G8RC:$rA, G8RC:$rB))]>;
377 def ADDME8 : XOForm_3<31, 234, 0, (outs G8RC:$rT), (ins G8RC:$rA),
378 "addme $rT, $rA", IntGeneral,
379 [(set G8RC:$rT, (adde G8RC:$rA, -1))]>;
380 def ADDZE8 : XOForm_3<31, 202, 0, (outs G8RC:$rT), (ins G8RC:$rA),
381 "addze $rT, $rA", IntGeneral,
382 [(set G8RC:$rT, (adde G8RC:$rA, 0))]>;
383 def SUBFE8 : XOForm_1<31, 136, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
384 "subfe $rT, $rA, $rB", IntGeneral,
385 [(set G8RC:$rT, (sube G8RC:$rB, G8RC:$rA))]>;
386 def SUBFME8 : XOForm_3<31, 232, 0, (outs G8RC:$rT), (ins G8RC:$rA),
387 "subfme $rT, $rA", IntGeneral,
388 [(set G8RC:$rT, (sube -1, G8RC:$rA))]>;
389 def SUBFZE8 : XOForm_3<31, 200, 0, (outs G8RC:$rT), (ins G8RC:$rA),
390 "subfze $rT, $rA", IntGeneral,
391 [(set G8RC:$rT, (sube 0, G8RC:$rA))]>;
395 def MULHD : XOForm_1<31, 73, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
396 "mulhd $rT, $rA, $rB", IntMulHW,
397 [(set G8RC:$rT, (mulhs G8RC:$rA, G8RC:$rB))]>;
398 def MULHDU : XOForm_1<31, 9, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
399 "mulhdu $rT, $rA, $rB", IntMulHWU,
400 [(set G8RC:$rT, (mulhu G8RC:$rA, G8RC:$rB))]>;
402 def CMPD : XForm_16_ext<31, 0, (outs CRRC:$crD), (ins G8RC:$rA, G8RC:$rB),
403 "cmpd $crD, $rA, $rB", IntCompare>, isPPC64;
404 def CMPLD : XForm_16_ext<31, 32, (outs CRRC:$crD), (ins G8RC:$rA, G8RC:$rB),
405 "cmpld $crD, $rA, $rB", IntCompare>, isPPC64;
406 def CMPDI : DForm_5_ext<11, (outs CRRC:$crD), (ins G8RC:$rA, s16imm:$imm),
407 "cmpdi $crD, $rA, $imm", IntCompare>, isPPC64;
408 def CMPLDI : DForm_6_ext<10, (outs CRRC:$dst), (ins G8RC:$src1, u16imm:$src2),
409 "cmpldi $dst, $src1, $src2", IntCompare>, isPPC64;
411 def SLD : XForm_6<31, 27, (outs G8RC:$rA), (ins G8RC:$rS, GPRC:$rB),
412 "sld $rA, $rS, $rB", IntRotateD,
413 [(set G8RC:$rA, (PPCshl G8RC:$rS, GPRC:$rB))]>, isPPC64;
414 def SRD : XForm_6<31, 539, (outs G8RC:$rA), (ins G8RC:$rS, GPRC:$rB),
415 "srd $rA, $rS, $rB", IntRotateD,
416 [(set G8RC:$rA, (PPCsrl G8RC:$rS, GPRC:$rB))]>, isPPC64;
417 let Defs = [CARRY] in {
418 def SRAD : XForm_6<31, 794, (outs G8RC:$rA), (ins G8RC:$rS, GPRC:$rB),
419 "srad $rA, $rS, $rB", IntRotateD,
420 [(set G8RC:$rA, (PPCsra G8RC:$rS, GPRC:$rB))]>, isPPC64;
423 def EXTSB8 : XForm_11<31, 954, (outs G8RC:$rA), (ins G8RC:$rS),
424 "extsb $rA, $rS", IntGeneral,
425 [(set G8RC:$rA, (sext_inreg G8RC:$rS, i8))]>;
426 def EXTSH8 : XForm_11<31, 922, (outs G8RC:$rA), (ins G8RC:$rS),
427 "extsh $rA, $rS", IntGeneral,
428 [(set G8RC:$rA, (sext_inreg G8RC:$rS, i16))]>;
430 def EXTSW : XForm_11<31, 986, (outs G8RC:$rA), (ins G8RC:$rS),
431 "extsw $rA, $rS", IntGeneral,
432 [(set G8RC:$rA, (sext_inreg G8RC:$rS, i32))]>, isPPC64;
433 /// EXTSW_32 - Just like EXTSW, but works on '32-bit' registers.
434 def EXTSW_32 : XForm_11<31, 986, (outs GPRC:$rA), (ins GPRC:$rS),
435 "extsw $rA, $rS", IntGeneral,
436 [(set GPRC:$rA, (PPCextsw_32 GPRC:$rS))]>, isPPC64;
437 def EXTSW_32_64 : XForm_11<31, 986, (outs G8RC:$rA), (ins GPRC:$rS),
438 "extsw $rA, $rS", IntGeneral,
439 [(set G8RC:$rA, (sext GPRC:$rS))]>, isPPC64;
441 let Defs = [CARRY] in {
442 def SRADI : XSForm_1<31, 413, (outs G8RC:$rA), (ins G8RC:$rS, u6imm:$SH),
443 "sradi $rA, $rS, $SH", IntRotateD,
444 [(set G8RC:$rA, (sra G8RC:$rS, (i32 imm:$SH)))]>, isPPC64;
446 def CNTLZD : XForm_11<31, 58, (outs G8RC:$rA), (ins G8RC:$rS),
447 "cntlzd $rA, $rS", IntGeneral,
448 [(set G8RC:$rA, (ctlz G8RC:$rS))]>;
450 def DIVD : XOForm_1<31, 489, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
451 "divd $rT, $rA, $rB", IntDivD,
452 [(set G8RC:$rT, (sdiv G8RC:$rA, G8RC:$rB))]>, isPPC64,
453 PPC970_DGroup_First, PPC970_DGroup_Cracked;
454 def DIVDU : XOForm_1<31, 457, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
455 "divdu $rT, $rA, $rB", IntDivD,
456 [(set G8RC:$rT, (udiv G8RC:$rA, G8RC:$rB))]>, isPPC64,
457 PPC970_DGroup_First, PPC970_DGroup_Cracked;
458 def MULLD : XOForm_1<31, 233, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
459 "mulld $rT, $rA, $rB", IntMulHD,
460 [(set G8RC:$rT, (mul G8RC:$rA, G8RC:$rB))]>, isPPC64;
463 let isCommutable = 1 in {
464 def RLDIMI : MDForm_1<30, 3,
465 (outs G8RC:$rA), (ins G8RC:$rSi, G8RC:$rS, u6imm:$SH, u6imm:$MB),
466 "rldimi $rA, $rS, $SH, $MB", IntRotateD,
467 []>, isPPC64, RegConstraint<"$rSi = $rA">,
471 // Rotate instructions.
472 def RLDCL : MDForm_1<30, 0,
473 (outs G8RC:$rA), (ins G8RC:$rS, GPRC:$rB, u6imm:$MB),
474 "rldcl $rA, $rS, $rB, $MB", IntRotateD,
476 def RLDICL : MDForm_1<30, 0,
477 (outs G8RC:$rA), (ins G8RC:$rS, u6imm:$SH, u6imm:$MB),
478 "rldicl $rA, $rS, $SH, $MB", IntRotateD,
480 def RLDICR : MDForm_1<30, 1,
481 (outs G8RC:$rA), (ins G8RC:$rS, u6imm:$SH, u6imm:$ME),
482 "rldicr $rA, $rS, $SH, $ME", IntRotateD,
485 def RLWINM8 : MForm_2<21,
486 (outs G8RC:$rA), (ins G8RC:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
487 "rlwinm $rA, $rS, $SH, $MB, $ME", IntGeneral,
490 } // End FXU Operations.
493 //===----------------------------------------------------------------------===//
494 // Load/Store instructions.
498 // Sign extending loads.
499 let canFoldAsLoad = 1, PPC970_Unit = 2 in {
500 def LHA8: DForm_1<42, (outs G8RC:$rD), (ins memri:$src),
501 "lha $rD, $src", LdStLHA,
502 [(set G8RC:$rD, (sextloadi16 iaddr:$src))]>,
503 PPC970_DGroup_Cracked;
504 def LWA : DSForm_1<58, 2, (outs G8RC:$rD), (ins memrix:$src),
505 "lwa $rD, $src", LdStLWA,
506 [(set G8RC:$rD, (sextloadi32 ixaddr:$src))]>, isPPC64,
507 PPC970_DGroup_Cracked;
508 def LHAX8: XForm_1<31, 343, (outs G8RC:$rD), (ins memrr:$src),
509 "lhax $rD, $src", LdStLHA,
510 [(set G8RC:$rD, (sextloadi16 xaddr:$src))]>,
511 PPC970_DGroup_Cracked;
512 def LWAX : XForm_1<31, 341, (outs G8RC:$rD), (ins memrr:$src),
513 "lwax $rD, $src", LdStLHA,
514 [(set G8RC:$rD, (sextloadi32 xaddr:$src))]>, isPPC64,
515 PPC970_DGroup_Cracked;
519 def LHAU8 : DForm_1a<43, (outs G8RC:$rD, ptr_rc:$ea_result), (ins symbolLo:$disp,
521 "lhau $rD, $disp($rA)", LdStGeneral,
522 []>, RegConstraint<"$rA = $ea_result">,
523 NoEncode<"$ea_result">;
528 // Zero extending loads.
529 let canFoldAsLoad = 1, PPC970_Unit = 2 in {
530 def LBZ8 : DForm_1<34, (outs G8RC:$rD), (ins memri:$src),
531 "lbz $rD, $src", LdStGeneral,
532 [(set G8RC:$rD, (zextloadi8 iaddr:$src))]>;
533 def LHZ8 : DForm_1<40, (outs G8RC:$rD), (ins memri:$src),
534 "lhz $rD, $src", LdStGeneral,
535 [(set G8RC:$rD, (zextloadi16 iaddr:$src))]>;
536 def LWZ8 : DForm_1<32, (outs G8RC:$rD), (ins memri:$src),
537 "lwz $rD, $src", LdStGeneral,
538 [(set G8RC:$rD, (zextloadi32 iaddr:$src))]>, isPPC64;
540 def LBZX8 : XForm_1<31, 87, (outs G8RC:$rD), (ins memrr:$src),
541 "lbzx $rD, $src", LdStGeneral,
542 [(set G8RC:$rD, (zextloadi8 xaddr:$src))]>;
543 def LHZX8 : XForm_1<31, 279, (outs G8RC:$rD), (ins memrr:$src),
544 "lhzx $rD, $src", LdStGeneral,
545 [(set G8RC:$rD, (zextloadi16 xaddr:$src))]>;
546 def LWZX8 : XForm_1<31, 23, (outs G8RC:$rD), (ins memrr:$src),
547 "lwzx $rD, $src", LdStGeneral,
548 [(set G8RC:$rD, (zextloadi32 xaddr:$src))]>;
553 def LBZU8 : DForm_1<35, (outs G8RC:$rD, ptr_rc:$ea_result), (ins memri:$addr),
554 "lbzu $rD, $addr", LdStGeneral,
555 []>, RegConstraint<"$addr.reg = $ea_result">,
556 NoEncode<"$ea_result">;
557 def LHZU8 : DForm_1<41, (outs G8RC:$rD, ptr_rc:$ea_result), (ins memri:$addr),
558 "lhzu $rD, $addr", LdStGeneral,
559 []>, RegConstraint<"$addr.reg = $ea_result">,
560 NoEncode<"$ea_result">;
561 def LWZU8 : DForm_1<33, (outs G8RC:$rD, ptr_rc:$ea_result), (ins memri:$addr),
562 "lwzu $rD, $addr", LdStGeneral,
563 []>, RegConstraint<"$addr.reg = $ea_result">,
564 NoEncode<"$ea_result">;
569 // Full 8-byte loads.
570 let canFoldAsLoad = 1, PPC970_Unit = 2 in {
571 def LD : DSForm_1<58, 0, (outs G8RC:$rD), (ins memrix:$src),
572 "ld $rD, $src", LdStLD,
573 [(set G8RC:$rD, (load ixaddr:$src))]>, isPPC64;
574 def LDtoc: Pseudo<(outs G8RC:$rD), (ins tocentry:$disp, G8RC:$reg),
577 (PPCtoc_entry tglobaladdr:$disp, G8RC:$reg))]>, isPPC64;
579 let hasSideEffects = 1 in {
580 let RST = 2, DS_RA = 0 in // FIXME: Should be a pseudo.
581 def LDinto_toc: DSForm_1<58, 0, (outs), (ins G8RC:$reg),
582 "ld 2, 8($reg)", LdStLD,
583 [(PPCload_toc G8RC:$reg)]>, isPPC64;
585 let RST = 2, DS_RA = 0 in // FIXME: Should be a pseudo.
586 def LDtoc_restore : DSForm_1<58, 0, (outs), (ins),
587 "ld 2, 40(1)", LdStLD,
588 [(PPCtoc_restore)]>, isPPC64;
590 def LDX : XForm_1<31, 21, (outs G8RC:$rD), (ins memrr:$src),
591 "ldx $rD, $src", LdStLD,
592 [(set G8RC:$rD, (load xaddr:$src))]>, isPPC64;
595 def LDU : DSForm_1<58, 1, (outs G8RC:$rD, ptr_rc:$ea_result), (ins memrix:$addr),
596 "ldu $rD, $addr", LdStLD,
597 []>, RegConstraint<"$addr.reg = $ea_result">, isPPC64,
598 NoEncode<"$ea_result">;
602 def : Pat<(PPCload ixaddr:$src),
604 def : Pat<(PPCload xaddr:$src),
607 let PPC970_Unit = 2 in {
608 // Truncating stores.
609 def STB8 : DForm_1<38, (outs), (ins G8RC:$rS, memri:$src),
610 "stb $rS, $src", LdStGeneral,
611 [(truncstorei8 G8RC:$rS, iaddr:$src)]>;
612 def STH8 : DForm_1<44, (outs), (ins G8RC:$rS, memri:$src),
613 "sth $rS, $src", LdStGeneral,
614 [(truncstorei16 G8RC:$rS, iaddr:$src)]>;
615 def STW8 : DForm_1<36, (outs), (ins G8RC:$rS, memri:$src),
616 "stw $rS, $src", LdStGeneral,
617 [(truncstorei32 G8RC:$rS, iaddr:$src)]>;
618 def STBX8 : XForm_8<31, 215, (outs), (ins G8RC:$rS, memrr:$dst),
619 "stbx $rS, $dst", LdStGeneral,
620 [(truncstorei8 G8RC:$rS, xaddr:$dst)]>,
621 PPC970_DGroup_Cracked;
622 def STHX8 : XForm_8<31, 407, (outs), (ins G8RC:$rS, memrr:$dst),
623 "sthx $rS, $dst", LdStGeneral,
624 [(truncstorei16 G8RC:$rS, xaddr:$dst)]>,
625 PPC970_DGroup_Cracked;
626 def STWX8 : XForm_8<31, 151, (outs), (ins G8RC:$rS, memrr:$dst),
627 "stwx $rS, $dst", LdStGeneral,
628 [(truncstorei32 G8RC:$rS, xaddr:$dst)]>,
629 PPC970_DGroup_Cracked;
630 // Normal 8-byte stores.
631 def STD : DSForm_1<62, 0, (outs), (ins G8RC:$rS, memrix:$dst),
632 "std $rS, $dst", LdStSTD,
633 [(store G8RC:$rS, ixaddr:$dst)]>, isPPC64;
634 def STDX : XForm_8<31, 149, (outs), (ins G8RC:$rS, memrr:$dst),
635 "stdx $rS, $dst", LdStSTD,
636 [(store G8RC:$rS, xaddr:$dst)]>, isPPC64,
637 PPC970_DGroup_Cracked;
640 let PPC970_Unit = 2 in {
642 def STBU8 : DForm_1a<38, (outs ptr_rc:$ea_res), (ins G8RC:$rS,
643 symbolLo:$ptroff, ptr_rc:$ptrreg),
644 "stbu $rS, $ptroff($ptrreg)", LdStGeneral,
645 [(set ptr_rc:$ea_res,
646 (pre_truncsti8 G8RC:$rS, ptr_rc:$ptrreg,
647 iaddroff:$ptroff))]>,
648 RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">;
649 def STHU8 : DForm_1a<45, (outs ptr_rc:$ea_res), (ins G8RC:$rS,
650 symbolLo:$ptroff, ptr_rc:$ptrreg),
651 "sthu $rS, $ptroff($ptrreg)", LdStGeneral,
652 [(set ptr_rc:$ea_res,
653 (pre_truncsti16 G8RC:$rS, ptr_rc:$ptrreg,
654 iaddroff:$ptroff))]>,
655 RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">;
657 def STDU : DSForm_1a<62, 1, (outs ptr_rc:$ea_res), (ins G8RC:$rS,
658 s16immX4:$ptroff, ptr_rc:$ptrreg),
659 "stdu $rS, $ptroff($ptrreg)", LdStSTD,
660 [(set ptr_rc:$ea_res, (pre_store G8RC:$rS, ptr_rc:$ptrreg,
661 iaddroff:$ptroff))]>,
662 RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">,
666 def STDUX : XForm_8<31, 181, (outs), (ins G8RC:$rS, memrr:$dst),
667 "stdux $rS, $dst", LdStSTD,
670 // STD_32/STDX_32 - Just like STD/STDX, but uses a '32-bit' input register.
671 def STD_32 : DSForm_1<62, 0, (outs), (ins GPRC:$rT, memrix:$dst),
672 "std $rT, $dst", LdStSTD,
673 [(PPCstd_32 GPRC:$rT, ixaddr:$dst)]>, isPPC64;
674 def STDX_32 : XForm_8<31, 149, (outs), (ins GPRC:$rT, memrr:$dst),
675 "stdx $rT, $dst", LdStSTD,
676 [(PPCstd_32 GPRC:$rT, xaddr:$dst)]>, isPPC64,
677 PPC970_DGroup_Cracked;
682 //===----------------------------------------------------------------------===//
683 // Floating point instructions.
687 let PPC970_Unit = 3, Uses = [RM] in { // FPU Operations.
688 def FCFID : XForm_26<63, 846, (outs F8RC:$frD), (ins F8RC:$frB),
689 "fcfid $frD, $frB", FPGeneral,
690 [(set F8RC:$frD, (PPCfcfid F8RC:$frB))]>, isPPC64;
691 def FCTIDZ : XForm_26<63, 815, (outs F8RC:$frD), (ins F8RC:$frB),
692 "fctidz $frD, $frB", FPGeneral,
693 [(set F8RC:$frD, (PPCfctidz F8RC:$frB))]>, isPPC64;
697 //===----------------------------------------------------------------------===//
698 // Instruction Patterns
701 // Extensions and truncates to/from 32-bit regs.
702 def : Pat<(i64 (zext GPRC:$in)),
703 (RLDICL (OR4To8 GPRC:$in, GPRC:$in), 0, 32)>;
704 def : Pat<(i64 (anyext GPRC:$in)),
705 (OR4To8 GPRC:$in, GPRC:$in)>;
706 def : Pat<(i32 (trunc G8RC:$in)),
707 (OR8To4 G8RC:$in, G8RC:$in)>;
709 // Extending loads with i64 targets.
710 def : Pat<(zextloadi1 iaddr:$src),
712 def : Pat<(zextloadi1 xaddr:$src),
714 def : Pat<(extloadi1 iaddr:$src),
716 def : Pat<(extloadi1 xaddr:$src),
718 def : Pat<(extloadi8 iaddr:$src),
720 def : Pat<(extloadi8 xaddr:$src),
722 def : Pat<(extloadi16 iaddr:$src),
724 def : Pat<(extloadi16 xaddr:$src),
726 def : Pat<(extloadi32 iaddr:$src),
728 def : Pat<(extloadi32 xaddr:$src),
731 // Standard shifts. These are represented separately from the real shifts above
732 // so that we can distinguish between shifts that allow 6-bit and 7-bit shift
734 def : Pat<(sra G8RC:$rS, GPRC:$rB),
735 (SRAD G8RC:$rS, GPRC:$rB)>;
736 def : Pat<(srl G8RC:$rS, GPRC:$rB),
737 (SRD G8RC:$rS, GPRC:$rB)>;
738 def : Pat<(shl G8RC:$rS, GPRC:$rB),
739 (SLD G8RC:$rS, GPRC:$rB)>;
742 def : Pat<(shl G8RC:$in, (i32 imm:$imm)),
743 (RLDICR G8RC:$in, imm:$imm, (SHL64 imm:$imm))>;
744 def : Pat<(srl G8RC:$in, (i32 imm:$imm)),
745 (RLDICL G8RC:$in, (SRL64 imm:$imm), imm:$imm)>;
748 def : Pat<(rotl G8RC:$in, GPRC:$sh),
749 (RLDCL G8RC:$in, GPRC:$sh, 0)>;
750 def : Pat<(rotl G8RC:$in, (i32 imm:$imm)),
751 (RLDICL G8RC:$in, imm:$imm, 0)>;
753 // Hi and Lo for Darwin Global Addresses.
754 def : Pat<(PPChi tglobaladdr:$in, 0), (LIS8 tglobaladdr:$in)>;
755 def : Pat<(PPClo tglobaladdr:$in, 0), (LI8 tglobaladdr:$in)>;
756 def : Pat<(PPChi tconstpool:$in , 0), (LIS8 tconstpool:$in)>;
757 def : Pat<(PPClo tconstpool:$in , 0), (LI8 tconstpool:$in)>;
758 def : Pat<(PPChi tjumptable:$in , 0), (LIS8 tjumptable:$in)>;
759 def : Pat<(PPClo tjumptable:$in , 0), (LI8 tjumptable:$in)>;
760 def : Pat<(PPChi tblockaddress:$in, 0), (LIS8 tblockaddress:$in)>;
761 def : Pat<(PPClo tblockaddress:$in, 0), (LI8 tblockaddress:$in)>;
762 def : Pat<(add G8RC:$in, (PPChi tglobaladdr:$g, 0)),
763 (ADDIS8 G8RC:$in, tglobaladdr:$g)>;
764 def : Pat<(add G8RC:$in, (PPChi tconstpool:$g, 0)),
765 (ADDIS8 G8RC:$in, tconstpool:$g)>;
766 def : Pat<(add G8RC:$in, (PPChi tjumptable:$g, 0)),
767 (ADDIS8 G8RC:$in, tjumptable:$g)>;
768 def : Pat<(add G8RC:$in, (PPChi tblockaddress:$g, 0)),
769 (ADDIS8 G8RC:$in, tblockaddress:$g)>;