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_Macho : IForm<18, 0, 1,
75 (outs), (ins calltarget:$func, variable_ops),
76 "bl $func", BrB, []>; // See Pat patterns below.
77 def BLA8_Macho : IForm<18, 1, 1,
78 (outs), (ins aaddr:$func, variable_ops),
79 "bla $func", BrB, [(PPCcall_Macho (i64 imm:$func))]>;
81 let Uses = [CTR8, RM] in {
82 def BCTRL8_Macho : XLForm_2_ext<19, 528, 20, 0, 1,
83 (outs), (ins variable_ops),
85 [(PPCbctrl_Macho)]>, Requires<[In64BitMode]>;
89 // ELF 64 ABI Calls = Macho 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_ELF (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_ELF)]>, Requires<[In64BitMode]>;
117 def : Pat<(PPCcall_Macho (i64 tglobaladdr:$dst)),
118 (BL8_Macho tglobaladdr:$dst)>;
119 def : Pat<(PPCcall_Macho (i64 texternalsym:$dst)),
120 (BL8_Macho texternalsym:$dst)>;
122 def : Pat<(PPCcall_ELF (i64 tglobaladdr:$dst)),
123 (BL8_ELF tglobaladdr:$dst)>;
124 def : Pat<(PPCcall_ELF (i64 texternalsym:$dst)),
125 (BL8_ELF texternalsym:$dst)>;
128 let usesCustomDAGSchedInserter = 1 in {
129 let Uses = [CR0] in {
130 def ATOMIC_LOAD_ADD_I64 : Pseudo<
131 (outs G8RC:$dst), (ins memrr:$ptr, G8RC:$incr),
132 "${:comment} ATOMIC_LOAD_ADD_I64 PSEUDO!",
133 [(set G8RC:$dst, (atomic_load_add_64 xoaddr:$ptr, G8RC:$incr))]>;
134 def ATOMIC_LOAD_SUB_I64 : Pseudo<
135 (outs G8RC:$dst), (ins memrr:$ptr, G8RC:$incr),
136 "${:comment} ATOMIC_LOAD_SUB_I64 PSEUDO!",
137 [(set G8RC:$dst, (atomic_load_sub_64 xoaddr:$ptr, G8RC:$incr))]>;
138 def ATOMIC_LOAD_OR_I64 : Pseudo<
139 (outs G8RC:$dst), (ins memrr:$ptr, G8RC:$incr),
140 "${:comment} ATOMIC_LOAD_OR_I64 PSEUDO!",
141 [(set G8RC:$dst, (atomic_load_or_64 xoaddr:$ptr, G8RC:$incr))]>;
142 def ATOMIC_LOAD_XOR_I64 : Pseudo<
143 (outs G8RC:$dst), (ins memrr:$ptr, G8RC:$incr),
144 "${:comment} ATOMIC_LOAD_XOR_I64 PSEUDO!",
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 "${:comment} ATOMIC_LOAD_AND_I64 PSEUDO!",
149 [(set G8RC:$dst, (atomic_load_and_64 xoaddr:$ptr, G8RC:$incr))]>;
150 def ATOMIC_LOAD_NAND_I64 : Pseudo<
151 (outs G8RC:$dst), (ins memrr:$ptr, G8RC:$incr),
152 "${:comment} ATOMIC_LOAD_NAND_I64 PSEUDO!",
153 [(set G8RC:$dst, (atomic_load_nand_64 xoaddr:$ptr, G8RC:$incr))]>;
155 def ATOMIC_CMP_SWAP_I64 : Pseudo<
156 (outs G8RC:$dst), (ins memrr:$ptr, G8RC:$old, G8RC:$new),
157 "${:comment} ATOMIC_CMP_SWAP_I64 PSEUDO!",
159 (atomic_cmp_swap_64 xoaddr:$ptr, G8RC:$old, G8RC:$new))]>;
161 def ATOMIC_SWAP_I64 : Pseudo<
162 (outs G8RC:$dst), (ins memrr:$ptr, G8RC:$new),
163 "${:comment} ATOMIC_SWAP_I64 PSEUDO!",
164 [(set G8RC:$dst, (atomic_swap_64 xoaddr:$ptr, G8RC:$new))]>;
168 // Instructions to support atomic operations
169 def LDARX : XForm_1<31, 84, (outs G8RC:$rD), (ins memrr:$ptr),
170 "ldarx $rD, $ptr", LdStLDARX,
171 [(set G8RC:$rD, (PPClarx xoaddr:$ptr))]>;
174 def STDCX : XForm_1<31, 214, (outs), (ins G8RC:$rS, memrr:$dst),
175 "stdcx. $rS, $dst", LdStSTDCX,
176 [(PPCstcx G8RC:$rS, xoaddr:$dst)]>,
179 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
180 def TCRETURNdi8 :Pseudo< (outs),
181 (ins calltarget:$dst, i32imm:$offset, variable_ops),
182 "#TC_RETURNd8 $dst $offset",
185 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
186 def TCRETURNai8 :Pseudo<(outs), (ins aaddr:$func, i32imm:$offset, variable_ops),
187 "#TC_RETURNa8 $func $offset",
188 [(PPCtc_return (i64 imm:$func), imm:$offset)]>;
190 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
191 def TCRETURNri8 : Pseudo<(outs), (ins CTRRC8:$dst, i32imm:$offset, variable_ops),
192 "#TC_RETURNr8 $dst $offset",
196 let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, isBranch = 1,
197 isIndirectBranch = 1, isCall = 1, isReturn = 1, Uses = [CTR, RM] in
198 def TAILBCTR8 : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", BrB, []>,
199 Requires<[In64BitMode]>;
203 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
204 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
205 def TAILB8 : IForm<18, 0, 0, (outs), (ins calltarget:$dst),
210 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
211 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
212 def TAILBA8 : IForm<18, 0, 0, (outs), (ins aaddr:$dst),
216 def : Pat<(PPCtc_return (i64 tglobaladdr:$dst), imm:$imm),
217 (TCRETURNdi8 tglobaladdr:$dst, imm:$imm)>;
219 def : Pat<(PPCtc_return (i64 texternalsym:$dst), imm:$imm),
220 (TCRETURNdi8 texternalsym:$dst, imm:$imm)>;
222 def : Pat<(PPCtc_return CTRRC8:$dst, imm:$imm),
223 (TCRETURNri8 CTRRC8:$dst, imm:$imm)>;
226 //===----------------------------------------------------------------------===//
227 // 64-bit SPR manipulation instrs.
229 let Uses = [CTR8] in {
230 def MFCTR8 : XFXForm_1_ext<31, 339, 9, (outs G8RC:$rT), (ins),
231 "mfctr $rT", SprMFSPR>,
232 PPC970_DGroup_First, PPC970_Unit_FXU;
234 let Pattern = [(PPCmtctr G8RC:$rS)], Defs = [CTR8] in {
235 def MTCTR8 : XFXForm_7_ext<31, 467, 9, (outs), (ins G8RC:$rS),
236 "mtctr $rS", SprMTSPR>,
237 PPC970_DGroup_First, PPC970_Unit_FXU;
240 let Defs = [X1], Uses = [X1] in
241 def DYNALLOC8 : Pseudo<(outs G8RC:$result), (ins G8RC:$negsize, memri:$fpsi),
242 "${:comment} DYNALLOC8 $result, $negsize, $fpsi",
244 (PPCdynalloc G8RC:$negsize, iaddr:$fpsi))]>;
246 let Defs = [LR8] in {
247 def MTLR8 : XFXForm_7_ext<31, 467, 8, (outs), (ins G8RC:$rS),
248 "mtlr $rS", SprMTSPR>,
249 PPC970_DGroup_First, PPC970_Unit_FXU;
251 let Uses = [LR8] in {
252 def MFLR8 : XFXForm_1_ext<31, 339, 8, (outs G8RC:$rT), (ins),
253 "mflr $rT", SprMFSPR>,
254 PPC970_DGroup_First, PPC970_Unit_FXU;
257 //===----------------------------------------------------------------------===//
258 // Fixed point instructions.
261 let PPC970_Unit = 1 in { // FXU Operations.
263 // Copies, extends, truncates.
264 def OR4To8 : XForm_6<31, 444, (outs G8RC:$rA), (ins GPRC:$rS, GPRC:$rB),
265 "or $rA, $rS, $rB", IntGeneral,
267 def OR8To4 : XForm_6<31, 444, (outs GPRC:$rA), (ins G8RC:$rS, G8RC:$rB),
268 "or $rA, $rS, $rB", IntGeneral,
271 def LI8 : DForm_2_r0<14, (outs G8RC:$rD), (ins symbolLo64:$imm),
272 "li $rD, $imm", IntGeneral,
273 [(set G8RC:$rD, immSExt16:$imm)]>;
274 def LIS8 : DForm_2_r0<15, (outs G8RC:$rD), (ins symbolHi64:$imm),
275 "lis $rD, $imm", IntGeneral,
276 [(set G8RC:$rD, imm16ShiftedSExt:$imm)]>;
279 def NAND8: XForm_6<31, 476, (outs G8RC:$rA), (ins G8RC:$rS, G8RC:$rB),
280 "nand $rA, $rS, $rB", IntGeneral,
281 [(set G8RC:$rA, (not (and G8RC:$rS, G8RC:$rB)))]>;
282 def AND8 : XForm_6<31, 28, (outs G8RC:$rA), (ins G8RC:$rS, G8RC:$rB),
283 "and $rA, $rS, $rB", IntGeneral,
284 [(set G8RC:$rA, (and G8RC:$rS, G8RC:$rB))]>;
285 def ANDC8: XForm_6<31, 60, (outs G8RC:$rA), (ins G8RC:$rS, G8RC:$rB),
286 "andc $rA, $rS, $rB", IntGeneral,
287 [(set G8RC:$rA, (and G8RC:$rS, (not G8RC:$rB)))]>;
288 def OR8 : XForm_6<31, 444, (outs G8RC:$rA), (ins G8RC:$rS, G8RC:$rB),
289 "or $rA, $rS, $rB", IntGeneral,
290 [(set G8RC:$rA, (or G8RC:$rS, G8RC:$rB))]>;
291 def NOR8 : XForm_6<31, 124, (outs G8RC:$rA), (ins G8RC:$rS, G8RC:$rB),
292 "nor $rA, $rS, $rB", IntGeneral,
293 [(set G8RC:$rA, (not (or G8RC:$rS, G8RC:$rB)))]>;
294 def ORC8 : XForm_6<31, 412, (outs G8RC:$rA), (ins G8RC:$rS, G8RC:$rB),
295 "orc $rA, $rS, $rB", IntGeneral,
296 [(set G8RC:$rA, (or G8RC:$rS, (not G8RC:$rB)))]>;
297 def EQV8 : XForm_6<31, 284, (outs G8RC:$rA), (ins G8RC:$rS, G8RC:$rB),
298 "eqv $rA, $rS, $rB", IntGeneral,
299 [(set G8RC:$rA, (not (xor G8RC:$rS, G8RC:$rB)))]>;
300 def XOR8 : XForm_6<31, 316, (outs G8RC:$rA), (ins G8RC:$rS, G8RC:$rB),
301 "xor $rA, $rS, $rB", IntGeneral,
302 [(set G8RC:$rA, (xor G8RC:$rS, G8RC:$rB))]>;
304 // Logical ops with immediate.
305 def ANDIo8 : DForm_4<28, (outs G8RC:$dst), (ins G8RC:$src1, u16imm:$src2),
306 "andi. $dst, $src1, $src2", IntGeneral,
307 [(set G8RC:$dst, (and G8RC:$src1, immZExt16:$src2))]>,
309 def ANDISo8 : DForm_4<29, (outs G8RC:$dst), (ins G8RC:$src1, u16imm:$src2),
310 "andis. $dst, $src1, $src2", IntGeneral,
311 [(set G8RC:$dst, (and G8RC:$src1,imm16ShiftedZExt:$src2))]>,
313 def ORI8 : DForm_4<24, (outs G8RC:$dst), (ins G8RC:$src1, u16imm:$src2),
314 "ori $dst, $src1, $src2", IntGeneral,
315 [(set G8RC:$dst, (or G8RC:$src1, immZExt16:$src2))]>;
316 def ORIS8 : DForm_4<25, (outs G8RC:$dst), (ins G8RC:$src1, u16imm:$src2),
317 "oris $dst, $src1, $src2", IntGeneral,
318 [(set G8RC:$dst, (or G8RC:$src1, imm16ShiftedZExt:$src2))]>;
319 def XORI8 : DForm_4<26, (outs G8RC:$dst), (ins G8RC:$src1, u16imm:$src2),
320 "xori $dst, $src1, $src2", IntGeneral,
321 [(set G8RC:$dst, (xor G8RC:$src1, immZExt16:$src2))]>;
322 def XORIS8 : DForm_4<27, (outs G8RC:$dst), (ins G8RC:$src1, u16imm:$src2),
323 "xoris $dst, $src1, $src2", IntGeneral,
324 [(set G8RC:$dst, (xor G8RC:$src1, imm16ShiftedZExt:$src2))]>;
326 def ADD8 : XOForm_1<31, 266, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
327 "add $rT, $rA, $rB", IntGeneral,
328 [(set G8RC:$rT, (add G8RC:$rA, G8RC:$rB))]>;
330 def ADDC8 : XOForm_1<31, 10, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
331 "addc $rT, $rA, $rB", IntGeneral,
332 [(set G8RC:$rT, (addc G8RC:$rA, G8RC:$rB))]>,
333 PPC970_DGroup_Cracked;
334 def ADDE8 : XOForm_1<31, 138, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
335 "adde $rT, $rA, $rB", IntGeneral,
336 [(set G8RC:$rT, (adde G8RC:$rA, G8RC:$rB))]>;
338 def ADDI8 : DForm_2<14, (outs G8RC:$rD), (ins G8RC:$rA, s16imm64:$imm),
339 "addi $rD, $rA, $imm", IntGeneral,
340 [(set G8RC:$rD, (add G8RC:$rA, immSExt16:$imm))]>;
341 def ADDIS8 : DForm_2<15, (outs G8RC:$rD), (ins G8RC:$rA, symbolHi64:$imm),
342 "addis $rD, $rA, $imm", IntGeneral,
343 [(set G8RC:$rD, (add G8RC:$rA, imm16ShiftedSExt:$imm))]>;
345 def SUBFIC8: DForm_2< 8, (outs G8RC:$rD), (ins G8RC:$rA, s16imm64:$imm),
346 "subfic $rD, $rA, $imm", IntGeneral,
347 [(set G8RC:$rD, (subc immSExt16:$imm, G8RC:$rA))]>;
348 def SUBF8 : XOForm_1<31, 40, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
349 "subf $rT, $rA, $rB", IntGeneral,
350 [(set G8RC:$rT, (sub G8RC:$rB, G8RC:$rA))]>;
351 def SUBFC8 : XOForm_1<31, 8, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
352 "subfc $rT, $rA, $rB", IntGeneral,
353 [(set G8RC:$rT, (subc G8RC:$rB, G8RC:$rA))]>,
354 PPC970_DGroup_Cracked;
356 def SUBFE8 : XOForm_1<31, 136, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
357 "subfe $rT, $rA, $rB", IntGeneral,
358 [(set G8RC:$rT, (sube G8RC:$rB, G8RC:$rA))]>;
359 def ADDME8 : XOForm_3<31, 234, 0, (outs G8RC:$rT), (ins G8RC:$rA),
360 "addme $rT, $rA", IntGeneral,
361 [(set G8RC:$rT, (adde G8RC:$rA, immAllOnes))]>;
362 def ADDZE8 : XOForm_3<31, 202, 0, (outs G8RC:$rT), (ins G8RC:$rA),
363 "addze $rT, $rA", IntGeneral,
364 [(set G8RC:$rT, (adde G8RC:$rA, 0))]>;
365 def NEG8 : XOForm_3<31, 104, 0, (outs G8RC:$rT), (ins G8RC:$rA),
366 "neg $rT, $rA", IntGeneral,
367 [(set G8RC:$rT, (ineg G8RC:$rA))]>;
368 def SUBFME8 : XOForm_3<31, 232, 0, (outs G8RC:$rT), (ins G8RC:$rA),
369 "subfme $rT, $rA", IntGeneral,
370 [(set G8RC:$rT, (sube immAllOnes, G8RC:$rA))]>;
371 def SUBFZE8 : XOForm_3<31, 200, 0, (outs G8RC:$rT), (ins G8RC:$rA),
372 "subfze $rT, $rA", IntGeneral,
373 [(set G8RC:$rT, (sube 0, G8RC:$rA))]>;
377 def MULHD : XOForm_1<31, 73, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
378 "mulhd $rT, $rA, $rB", IntMulHW,
379 [(set G8RC:$rT, (mulhs G8RC:$rA, G8RC:$rB))]>;
380 def MULHDU : XOForm_1<31, 9, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
381 "mulhdu $rT, $rA, $rB", IntMulHWU,
382 [(set G8RC:$rT, (mulhu G8RC:$rA, G8RC:$rB))]>;
384 def CMPD : XForm_16_ext<31, 0, (outs CRRC:$crD), (ins G8RC:$rA, G8RC:$rB),
385 "cmpd $crD, $rA, $rB", IntCompare>, isPPC64;
386 def CMPLD : XForm_16_ext<31, 32, (outs CRRC:$crD), (ins G8RC:$rA, G8RC:$rB),
387 "cmpld $crD, $rA, $rB", IntCompare>, isPPC64;
388 def CMPDI : DForm_5_ext<11, (outs CRRC:$crD), (ins G8RC:$rA, s16imm:$imm),
389 "cmpdi $crD, $rA, $imm", IntCompare>, isPPC64;
390 def CMPLDI : DForm_6_ext<10, (outs CRRC:$dst), (ins G8RC:$src1, u16imm:$src2),
391 "cmpldi $dst, $src1, $src2", IntCompare>, isPPC64;
393 def SLD : XForm_6<31, 27, (outs G8RC:$rA), (ins G8RC:$rS, GPRC:$rB),
394 "sld $rA, $rS, $rB", IntRotateD,
395 [(set G8RC:$rA, (PPCshl G8RC:$rS, GPRC:$rB))]>, isPPC64;
396 def SRD : XForm_6<31, 539, (outs G8RC:$rA), (ins G8RC:$rS, GPRC:$rB),
397 "srd $rA, $rS, $rB", IntRotateD,
398 [(set G8RC:$rA, (PPCsrl G8RC:$rS, GPRC:$rB))]>, isPPC64;
399 def SRAD : XForm_6<31, 794, (outs G8RC:$rA), (ins G8RC:$rS, GPRC:$rB),
400 "srad $rA, $rS, $rB", IntRotateD,
401 [(set G8RC:$rA, (PPCsra G8RC:$rS, GPRC:$rB))]>, isPPC64;
403 def EXTSB8 : XForm_11<31, 954, (outs G8RC:$rA), (ins G8RC:$rS),
404 "extsb $rA, $rS", IntGeneral,
405 [(set G8RC:$rA, (sext_inreg G8RC:$rS, i8))]>;
406 def EXTSH8 : XForm_11<31, 922, (outs G8RC:$rA), (ins G8RC:$rS),
407 "extsh $rA, $rS", IntGeneral,
408 [(set G8RC:$rA, (sext_inreg G8RC:$rS, i16))]>;
410 def EXTSW : XForm_11<31, 986, (outs G8RC:$rA), (ins G8RC:$rS),
411 "extsw $rA, $rS", IntGeneral,
412 [(set G8RC:$rA, (sext_inreg G8RC:$rS, i32))]>, isPPC64;
413 /// EXTSW_32 - Just like EXTSW, but works on '32-bit' registers.
414 def EXTSW_32 : XForm_11<31, 986, (outs GPRC:$rA), (ins GPRC:$rS),
415 "extsw $rA, $rS", IntGeneral,
416 [(set GPRC:$rA, (PPCextsw_32 GPRC:$rS))]>, isPPC64;
417 def EXTSW_32_64 : XForm_11<31, 986, (outs G8RC:$rA), (ins GPRC:$rS),
418 "extsw $rA, $rS", IntGeneral,
419 [(set G8RC:$rA, (sext GPRC:$rS))]>, isPPC64;
421 def SRADI : XSForm_1<31, 413, (outs G8RC:$rA), (ins G8RC:$rS, u6imm:$SH),
422 "sradi $rA, $rS, $SH", IntRotateD,
423 [(set G8RC:$rA, (sra G8RC:$rS, (i32 imm:$SH)))]>, isPPC64;
424 def CNTLZD : XForm_11<31, 58, (outs G8RC:$rA), (ins G8RC:$rS),
425 "cntlzd $rA, $rS", IntGeneral,
426 [(set G8RC:$rA, (ctlz G8RC:$rS))]>;
428 def DIVD : XOForm_1<31, 489, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
429 "divd $rT, $rA, $rB", IntDivD,
430 [(set G8RC:$rT, (sdiv G8RC:$rA, G8RC:$rB))]>, isPPC64,
431 PPC970_DGroup_First, PPC970_DGroup_Cracked;
432 def DIVDU : XOForm_1<31, 457, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
433 "divdu $rT, $rA, $rB", IntDivD,
434 [(set G8RC:$rT, (udiv G8RC:$rA, G8RC:$rB))]>, isPPC64,
435 PPC970_DGroup_First, PPC970_DGroup_Cracked;
436 def MULLD : XOForm_1<31, 233, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
437 "mulld $rT, $rA, $rB", IntMulHD,
438 [(set G8RC:$rT, (mul G8RC:$rA, G8RC:$rB))]>, isPPC64;
441 let isCommutable = 1 in {
442 def RLDIMI : MDForm_1<30, 3,
443 (outs G8RC:$rA), (ins G8RC:$rSi, G8RC:$rS, u6imm:$SH, u6imm:$MB),
444 "rldimi $rA, $rS, $SH, $MB", IntRotateD,
445 []>, isPPC64, RegConstraint<"$rSi = $rA">,
449 // Rotate instructions.
450 def RLDCL : MDForm_1<30, 0,
451 (outs G8RC:$rA), (ins G8RC:$rS, GPRC:$rB, u6imm:$MB),
452 "rldcl $rA, $rS, $rB, $MB", IntRotateD,
454 def RLDICL : MDForm_1<30, 0,
455 (outs G8RC:$rA), (ins G8RC:$rS, u6imm:$SH, u6imm:$MB),
456 "rldicl $rA, $rS, $SH, $MB", IntRotateD,
458 def RLDICR : MDForm_1<30, 1,
459 (outs G8RC:$rA), (ins G8RC:$rS, u6imm:$SH, u6imm:$ME),
460 "rldicr $rA, $rS, $SH, $ME", IntRotateD,
462 } // End FXU Operations.
465 //===----------------------------------------------------------------------===//
466 // Load/Store instructions.
470 // Sign extending loads.
471 let canFoldAsLoad = 1, PPC970_Unit = 2 in {
472 def LHA8: DForm_1<42, (outs G8RC:$rD), (ins memri:$src),
473 "lha $rD, $src", LdStLHA,
474 [(set G8RC:$rD, (sextloadi16 iaddr:$src))]>,
475 PPC970_DGroup_Cracked;
476 def LWA : DSForm_1<58, 2, (outs G8RC:$rD), (ins memrix:$src),
477 "lwa $rD, $src", LdStLWA,
478 [(set G8RC:$rD, (sextloadi32 ixaddr:$src))]>, isPPC64,
479 PPC970_DGroup_Cracked;
480 def LHAX8: XForm_1<31, 343, (outs G8RC:$rD), (ins memrr:$src),
481 "lhax $rD, $src", LdStLHA,
482 [(set G8RC:$rD, (sextloadi16 xaddr:$src))]>,
483 PPC970_DGroup_Cracked;
484 def LWAX : XForm_1<31, 341, (outs G8RC:$rD), (ins memrr:$src),
485 "lwax $rD, $src", LdStLHA,
486 [(set G8RC:$rD, (sextloadi32 xaddr:$src))]>, isPPC64,
487 PPC970_DGroup_Cracked;
491 def LHAU8 : DForm_1<43, (outs G8RC:$rD, ptr_rc:$ea_result), (ins symbolLo:$disp,
493 "lhau $rD, $disp($rA)", LdStGeneral,
494 []>, RegConstraint<"$rA = $ea_result">,
495 NoEncode<"$ea_result">;
500 // Zero extending loads.
501 let canFoldAsLoad = 1, PPC970_Unit = 2 in {
502 def LBZ8 : DForm_1<34, (outs G8RC:$rD), (ins memri:$src),
503 "lbz $rD, $src", LdStGeneral,
504 [(set G8RC:$rD, (zextloadi8 iaddr:$src))]>;
505 def LHZ8 : DForm_1<40, (outs G8RC:$rD), (ins memri:$src),
506 "lhz $rD, $src", LdStGeneral,
507 [(set G8RC:$rD, (zextloadi16 iaddr:$src))]>;
508 def LWZ8 : DForm_1<32, (outs G8RC:$rD), (ins memri:$src),
509 "lwz $rD, $src", LdStGeneral,
510 [(set G8RC:$rD, (zextloadi32 iaddr:$src))]>, isPPC64;
512 def LBZX8 : XForm_1<31, 87, (outs G8RC:$rD), (ins memrr:$src),
513 "lbzx $rD, $src", LdStGeneral,
514 [(set G8RC:$rD, (zextloadi8 xaddr:$src))]>;
515 def LHZX8 : XForm_1<31, 279, (outs G8RC:$rD), (ins memrr:$src),
516 "lhzx $rD, $src", LdStGeneral,
517 [(set G8RC:$rD, (zextloadi16 xaddr:$src))]>;
518 def LWZX8 : XForm_1<31, 23, (outs G8RC:$rD), (ins memrr:$src),
519 "lwzx $rD, $src", LdStGeneral,
520 [(set G8RC:$rD, (zextloadi32 xaddr:$src))]>;
525 def LBZU8 : DForm_1<35, (outs G8RC:$rD, ptr_rc:$ea_result), (ins memri:$addr),
526 "lbzu $rD, $addr", LdStGeneral,
527 []>, RegConstraint<"$addr.reg = $ea_result">,
528 NoEncode<"$ea_result">;
529 def LHZU8 : DForm_1<41, (outs G8RC:$rD, ptr_rc:$ea_result), (ins memri:$addr),
530 "lhzu $rD, $addr", LdStGeneral,
531 []>, RegConstraint<"$addr.reg = $ea_result">,
532 NoEncode<"$ea_result">;
533 def LWZU8 : DForm_1<33, (outs G8RC:$rD, ptr_rc:$ea_result), (ins memri:$addr),
534 "lwzu $rD, $addr", LdStGeneral,
535 []>, RegConstraint<"$addr.reg = $ea_result">,
536 NoEncode<"$ea_result">;
541 // Full 8-byte loads.
542 let canFoldAsLoad = 1, PPC970_Unit = 2 in {
543 def LD : DSForm_1<58, 0, (outs G8RC:$rD), (ins memrix:$src),
544 "ld $rD, $src", LdStLD,
545 [(set G8RC:$rD, (load ixaddr:$src))]>, isPPC64;
546 def LDX : XForm_1<31, 21, (outs G8RC:$rD), (ins memrr:$src),
547 "ldx $rD, $src", LdStLD,
548 [(set G8RC:$rD, (load xaddr:$src))]>, isPPC64;
551 def LDU : DSForm_1<58, 1, (outs G8RC:$rD, ptr_rc:$ea_result), (ins memrix:$addr),
552 "ldu $rD, $addr", LdStLD,
553 []>, RegConstraint<"$addr.reg = $ea_result">, isPPC64,
554 NoEncode<"$ea_result">;
558 let PPC970_Unit = 2 in {
559 // Truncating stores.
560 def STB8 : DForm_1<38, (outs), (ins G8RC:$rS, memri:$src),
561 "stb $rS, $src", LdStGeneral,
562 [(truncstorei8 G8RC:$rS, iaddr:$src)]>;
563 def STH8 : DForm_1<44, (outs), (ins G8RC:$rS, memri:$src),
564 "sth $rS, $src", LdStGeneral,
565 [(truncstorei16 G8RC:$rS, iaddr:$src)]>;
566 def STW8 : DForm_1<36, (outs), (ins G8RC:$rS, memri:$src),
567 "stw $rS, $src", LdStGeneral,
568 [(truncstorei32 G8RC:$rS, iaddr:$src)]>;
569 def STBX8 : XForm_8<31, 215, (outs), (ins G8RC:$rS, memrr:$dst),
570 "stbx $rS, $dst", LdStGeneral,
571 [(truncstorei8 G8RC:$rS, xaddr:$dst)]>,
572 PPC970_DGroup_Cracked;
573 def STHX8 : XForm_8<31, 407, (outs), (ins G8RC:$rS, memrr:$dst),
574 "sthx $rS, $dst", LdStGeneral,
575 [(truncstorei16 G8RC:$rS, xaddr:$dst)]>,
576 PPC970_DGroup_Cracked;
577 def STWX8 : XForm_8<31, 151, (outs), (ins G8RC:$rS, memrr:$dst),
578 "stwx $rS, $dst", LdStGeneral,
579 [(truncstorei32 G8RC:$rS, xaddr:$dst)]>,
580 PPC970_DGroup_Cracked;
581 // Normal 8-byte stores.
582 def STD : DSForm_1<62, 0, (outs), (ins G8RC:$rS, memrix:$dst),
583 "std $rS, $dst", LdStSTD,
584 [(store G8RC:$rS, ixaddr:$dst)]>, isPPC64;
585 def STDX : XForm_8<31, 149, (outs), (ins G8RC:$rS, memrr:$dst),
586 "stdx $rS, $dst", LdStSTD,
587 [(store G8RC:$rS, xaddr:$dst)]>, isPPC64,
588 PPC970_DGroup_Cracked;
591 let PPC970_Unit = 2 in {
593 def STBU8 : DForm_1<38, (outs ptr_rc:$ea_res), (ins G8RC:$rS,
594 symbolLo:$ptroff, ptr_rc:$ptrreg),
595 "stbu $rS, $ptroff($ptrreg)", LdStGeneral,
596 [(set ptr_rc:$ea_res,
597 (pre_truncsti8 G8RC:$rS, ptr_rc:$ptrreg,
598 iaddroff:$ptroff))]>,
599 RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">;
600 def STHU8 : DForm_1<45, (outs ptr_rc:$ea_res), (ins G8RC:$rS,
601 symbolLo:$ptroff, ptr_rc:$ptrreg),
602 "sthu $rS, $ptroff($ptrreg)", LdStGeneral,
603 [(set ptr_rc:$ea_res,
604 (pre_truncsti16 G8RC:$rS, ptr_rc:$ptrreg,
605 iaddroff:$ptroff))]>,
606 RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">;
607 def STWU8 : DForm_1<37, (outs ptr_rc:$ea_res), (ins G8RC:$rS,
608 symbolLo:$ptroff, ptr_rc:$ptrreg),
609 "stwu $rS, $ptroff($ptrreg)", LdStGeneral,
610 [(set ptr_rc:$ea_res, (pre_store G8RC:$rS, ptr_rc:$ptrreg,
611 iaddroff:$ptroff))]>,
612 RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">;
615 def STDU : DSForm_1<62, 1, (outs ptr_rc:$ea_res), (ins G8RC:$rS,
616 s16immX4:$ptroff, ptr_rc:$ptrreg),
617 "stdu $rS, $ptroff($ptrreg)", LdStSTD,
618 [(set ptr_rc:$ea_res, (pre_store G8RC:$rS, ptr_rc:$ptrreg,
619 iaddroff:$ptroff))]>,
620 RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">,
624 def STDUX : XForm_8<31, 181, (outs), (ins G8RC:$rS, memrr:$dst),
625 "stdux $rS, $dst", LdStSTD,
628 // STD_32/STDX_32 - Just like STD/STDX, but uses a '32-bit' input register.
629 def STD_32 : DSForm_1<62, 0, (outs), (ins GPRC:$rT, memrix:$dst),
630 "std $rT, $dst", LdStSTD,
631 [(PPCstd_32 GPRC:$rT, ixaddr:$dst)]>, isPPC64;
632 def STDX_32 : XForm_8<31, 149, (outs), (ins GPRC:$rT, memrr:$dst),
633 "stdx $rT, $dst", LdStSTD,
634 [(PPCstd_32 GPRC:$rT, xaddr:$dst)]>, isPPC64,
635 PPC970_DGroup_Cracked;
640 //===----------------------------------------------------------------------===//
641 // Floating point instructions.
645 let PPC970_Unit = 3, Uses = [RM] in { // FPU Operations.
646 def FCFID : XForm_26<63, 846, (outs F8RC:$frD), (ins F8RC:$frB),
647 "fcfid $frD, $frB", FPGeneral,
648 [(set F8RC:$frD, (PPCfcfid F8RC:$frB))]>, isPPC64;
649 def FCTIDZ : XForm_26<63, 815, (outs F8RC:$frD), (ins F8RC:$frB),
650 "fctidz $frD, $frB", FPGeneral,
651 [(set F8RC:$frD, (PPCfctidz F8RC:$frB))]>, isPPC64;
655 //===----------------------------------------------------------------------===//
656 // Instruction Patterns
659 // Extensions and truncates to/from 32-bit regs.
660 def : Pat<(i64 (zext GPRC:$in)),
661 (RLDICL (OR4To8 GPRC:$in, GPRC:$in), 0, 32)>;
662 def : Pat<(i64 (anyext GPRC:$in)),
663 (OR4To8 GPRC:$in, GPRC:$in)>;
664 def : Pat<(i32 (trunc G8RC:$in)),
665 (OR8To4 G8RC:$in, G8RC:$in)>;
667 // Extending loads with i64 targets.
668 def : Pat<(zextloadi1 iaddr:$src),
670 def : Pat<(zextloadi1 xaddr:$src),
672 def : Pat<(extloadi1 iaddr:$src),
674 def : Pat<(extloadi1 xaddr:$src),
676 def : Pat<(extloadi8 iaddr:$src),
678 def : Pat<(extloadi8 xaddr:$src),
680 def : Pat<(extloadi16 iaddr:$src),
682 def : Pat<(extloadi16 xaddr:$src),
684 def : Pat<(extloadi32 iaddr:$src),
686 def : Pat<(extloadi32 xaddr:$src),
689 // Standard shifts. These are represented separately from the real shifts above
690 // so that we can distinguish between shifts that allow 6-bit and 7-bit shift
692 def : Pat<(sra G8RC:$rS, GPRC:$rB),
693 (SRAD G8RC:$rS, GPRC:$rB)>;
694 def : Pat<(srl G8RC:$rS, GPRC:$rB),
695 (SRD G8RC:$rS, GPRC:$rB)>;
696 def : Pat<(shl G8RC:$rS, GPRC:$rB),
697 (SLD G8RC:$rS, GPRC:$rB)>;
700 def : Pat<(shl G8RC:$in, (i32 imm:$imm)),
701 (RLDICR G8RC:$in, imm:$imm, (SHL64 imm:$imm))>;
702 def : Pat<(srl G8RC:$in, (i32 imm:$imm)),
703 (RLDICL G8RC:$in, (SRL64 imm:$imm), imm:$imm)>;
706 def : Pat<(rotl G8RC:$in, GPRC:$sh),
707 (RLDCL G8RC:$in, GPRC:$sh, 0)>;
708 def : Pat<(rotl G8RC:$in, (i32 imm:$imm)),
709 (RLDICL G8RC:$in, imm:$imm, 0)>;
711 // Hi and Lo for Darwin Global Addresses.
712 def : Pat<(PPChi tglobaladdr:$in, 0), (LIS8 tglobaladdr:$in)>;
713 def : Pat<(PPClo tglobaladdr:$in, 0), (LI8 tglobaladdr:$in)>;
714 def : Pat<(PPChi tconstpool:$in , 0), (LIS8 tconstpool:$in)>;
715 def : Pat<(PPClo tconstpool:$in , 0), (LI8 tconstpool:$in)>;
716 def : Pat<(PPChi tjumptable:$in , 0), (LIS8 tjumptable:$in)>;
717 def : Pat<(PPClo tjumptable:$in , 0), (LI8 tjumptable:$in)>;
718 def : Pat<(add G8RC:$in, (PPChi tglobaladdr:$g, 0)),
719 (ADDIS8 G8RC:$in, tglobaladdr:$g)>;
720 def : Pat<(add G8RC:$in, (PPChi tconstpool:$g, 0)),
721 (ADDIS8 G8RC:$in, tconstpool:$g)>;
722 def : Pat<(add G8RC:$in, (PPChi tjumptable:$g, 0)),
723 (ADDIS8 G8RC:$in, tjumptable:$g)>;