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->getValue());
40 def SRL64 : SDNodeXForm<imm, [{
41 // Transformation function: 64 - imm
42 return N->getValue() ? getI32Imm(64 - N->getValue()) : 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->getValue() >> 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->getValue() >> 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
73 def BL8_Macho : IForm<18, 0, 1,
74 (outs), (ins calltarget:$func, variable_ops),
75 "bl $func", BrB, []>; // See Pat patterns below.
76 def BLA8_Macho : IForm<18, 1, 1,
77 (outs), (ins aaddr:$func, variable_ops),
78 "bla $func", BrB, [(PPCcall_Macho (i64 imm:$func))]>;
79 def BCTRL8_Macho : XLForm_2_ext<19, 528, 20, 0, 1,
80 (outs), (ins variable_ops),
82 [(PPCbctrl_Macho)]>, Requires<[In64BitMode]>;
85 // ELF 64 ABI Calls = Macho ABI Calls
86 // Used to define BL8_ELF and BLA8_ELF
87 let isCall = 1, PPC970_Unit = 7,
88 // All calls clobber the PPC64 non-callee saved registers.
89 Defs = [X0,X2,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12,
90 F0,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,
91 V0,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11,V12,V13,V14,V15,V16,V17,V18,V19,
93 CR0,CR1,CR5,CR6,CR7] in {
94 // Convenient aliases for call instructions
95 def BL8_ELF : IForm<18, 0, 1,
96 (outs), (ins calltarget:$func, variable_ops),
97 "bl $func", BrB, []>; // See Pat patterns below.
98 def BLA8_ELF : IForm<18, 1, 1,
99 (outs), (ins aaddr:$func, variable_ops),
100 "bla $func", BrB, [(PPCcall_ELF (i64 imm:$func))]>;
101 def BCTRL8_ELF : XLForm_2_ext<19, 528, 20, 0, 1,
102 (outs), (ins variable_ops),
104 [(PPCbctrl_ELF)]>, Requires<[In64BitMode]>;
109 def : Pat<(PPCcall_Macho (i64 tglobaladdr:$dst)),
110 (BL8_Macho tglobaladdr:$dst)>;
111 def : Pat<(PPCcall_Macho (i64 texternalsym:$dst)),
112 (BL8_Macho texternalsym:$dst)>;
114 def : Pat<(PPCcall_ELF (i64 tglobaladdr:$dst)),
115 (BL8_ELF tglobaladdr:$dst)>;
116 def : Pat<(PPCcall_ELF (i64 texternalsym:$dst)),
117 (BL8_ELF texternalsym:$dst)>;
119 // Atomic operations.
120 def LDARX : Pseudo<(outs G8RC:$rD), (ins memrr:$ptr, i32imm:$label),
121 "\nLa${label}_entry:\n\tldarx $rD, $ptr",
122 [(set G8RC:$rD, (PPClarx xoaddr:$ptr, imm:$label))]>;
124 let Defs = [CR0] in {
125 def STDCX : Pseudo<(outs), (ins G8RC:$rS, memrr:$dst, i32imm:$label),
126 "stdcx. $rS, $dst\n\tbne- La${label}_entry\nLa${label}_exit:",
127 [(PPCstcx G8RC:$rS, xoaddr:$dst, imm:$label)]>;
129 def CMP_UNRESd : Pseudo<(outs), (ins G8RC:$rA, G8RC:$rB, i32imm:$label),
130 "cmpd $rA, $rB\n\tbne- La${label}_exit",
131 [(PPCcmp_unres G8RC:$rA, G8RC:$rB, imm:$label)]>;
132 def CMP_UNRESdi : Pseudo<(outs), (ins G8RC:$rA, s16imm64:$imm, i32imm:$label),
133 "cmpdi $rA, $imm\n\tbne- La${label}_exit",
134 [(PPCcmp_unres G8RC:$rA, immSExt16:$imm, imm:$label)]>;
137 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
138 def TCRETURNdi8 :Pseudo< (outs),
139 (ins calltarget:$dst, i32imm:$offset, variable_ops),
140 "#TC_RETURNd8 $dst $offset",
143 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
144 def TCRETURNai8 :Pseudo<(outs), (ins aaddr:$func, i32imm:$offset, variable_ops),
145 "#TC_RETURNa8 $func $offset",
146 [(PPCtc_return (i64 imm:$func), imm:$offset)]>;
148 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
149 def TCRETURNri8 : Pseudo<(outs), (ins CTRRC8:$dst, i32imm:$offset, variable_ops),
150 "#TC_RETURNr8 $dst $offset",
154 let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, isBranch = 1,
155 isIndirectBranch = 1, isCall = 1, isReturn = 1 in
156 def TAILBCTR8 : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", BrB, []>,
157 Requires<[In64BitMode]>;
161 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
162 isBarrier = 1, isCall = 1, isReturn = 1 in
163 def TAILB8 : IForm<18, 0, 0, (outs), (ins calltarget:$dst),
168 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
169 isBarrier = 1, isCall = 1, isReturn = 1 in
170 def TAILBA8 : IForm<18, 0, 0, (outs), (ins aaddr:$dst),
174 def : Pat<(PPCtc_return (i64 tglobaladdr:$dst), imm:$imm),
175 (TCRETURNdi8 tglobaladdr:$dst, imm:$imm)>;
177 def : Pat<(PPCtc_return (i64 texternalsym:$dst), imm:$imm),
178 (TCRETURNdi8 texternalsym:$dst, imm:$imm)>;
180 def : Pat<(PPCtc_return CTRRC8:$dst, imm:$imm),
181 (TCRETURNri8 CTRRC8:$dst, imm:$imm)>;
184 //===----------------------------------------------------------------------===//
185 // 64-bit SPR manipulation instrs.
187 def MFCTR8 : XFXForm_1_ext<31, 339, 9, (outs G8RC:$rT), (ins),
188 "mfctr $rT", SprMFSPR>,
189 PPC970_DGroup_First, PPC970_Unit_FXU;
190 let Pattern = [(PPCmtctr G8RC:$rS)] in {
191 def MTCTR8 : XFXForm_7_ext<31, 467, 9, (outs), (ins G8RC:$rS),
192 "mtctr $rS", SprMTSPR>,
193 PPC970_DGroup_First, PPC970_Unit_FXU;
196 let Defs = [X1], Uses = [X1] in
197 def DYNALLOC8 : Pseudo<(outs G8RC:$result), (ins G8RC:$negsize, memri:$fpsi),
198 "${:comment} DYNALLOC8 $result, $negsize, $fpsi",
200 (PPCdynalloc G8RC:$negsize, iaddr:$fpsi))]>;
202 def MTLR8 : XFXForm_7_ext<31, 467, 8, (outs), (ins G8RC:$rS),
203 "mtlr $rS", SprMTSPR>,
204 PPC970_DGroup_First, PPC970_Unit_FXU;
205 def MFLR8 : XFXForm_1_ext<31, 339, 8, (outs G8RC:$rT), (ins),
206 "mflr $rT", SprMFSPR>,
207 PPC970_DGroup_First, PPC970_Unit_FXU;
210 //===----------------------------------------------------------------------===//
211 // Fixed point instructions.
214 let PPC970_Unit = 1 in { // FXU Operations.
216 // Copies, extends, truncates.
217 def OR4To8 : XForm_6<31, 444, (outs G8RC:$rA), (ins GPRC:$rS, GPRC:$rB),
218 "or $rA, $rS, $rB", IntGeneral,
220 def OR8To4 : XForm_6<31, 444, (outs GPRC:$rA), (ins G8RC:$rS, G8RC:$rB),
221 "or $rA, $rS, $rB", IntGeneral,
224 def LI8 : DForm_2_r0<14, (outs G8RC:$rD), (ins symbolLo64:$imm),
225 "li $rD, $imm", IntGeneral,
226 [(set G8RC:$rD, immSExt16:$imm)]>;
227 def LIS8 : DForm_2_r0<15, (outs G8RC:$rD), (ins symbolHi64:$imm),
228 "lis $rD, $imm", IntGeneral,
229 [(set G8RC:$rD, imm16ShiftedSExt:$imm)]>;
232 def NAND8: XForm_6<31, 476, (outs G8RC:$rA), (ins G8RC:$rS, G8RC:$rB),
233 "nand $rA, $rS, $rB", IntGeneral,
234 [(set G8RC:$rA, (not (and G8RC:$rS, G8RC:$rB)))]>;
235 def AND8 : XForm_6<31, 28, (outs G8RC:$rA), (ins G8RC:$rS, G8RC:$rB),
236 "and $rA, $rS, $rB", IntGeneral,
237 [(set G8RC:$rA, (and G8RC:$rS, G8RC:$rB))]>;
238 def ANDC8: XForm_6<31, 60, (outs G8RC:$rA), (ins G8RC:$rS, G8RC:$rB),
239 "andc $rA, $rS, $rB", IntGeneral,
240 [(set G8RC:$rA, (and G8RC:$rS, (not G8RC:$rB)))]>;
241 def OR8 : XForm_6<31, 444, (outs G8RC:$rA), (ins G8RC:$rS, G8RC:$rB),
242 "or $rA, $rS, $rB", IntGeneral,
243 [(set G8RC:$rA, (or G8RC:$rS, G8RC:$rB))]>;
244 def NOR8 : XForm_6<31, 124, (outs G8RC:$rA), (ins G8RC:$rS, G8RC:$rB),
245 "nor $rA, $rS, $rB", IntGeneral,
246 [(set G8RC:$rA, (not (or G8RC:$rS, G8RC:$rB)))]>;
247 def ORC8 : XForm_6<31, 412, (outs G8RC:$rA), (ins G8RC:$rS, G8RC:$rB),
248 "orc $rA, $rS, $rB", IntGeneral,
249 [(set G8RC:$rA, (or G8RC:$rS, (not G8RC:$rB)))]>;
250 def EQV8 : XForm_6<31, 284, (outs G8RC:$rA), (ins G8RC:$rS, G8RC:$rB),
251 "eqv $rA, $rS, $rB", IntGeneral,
252 [(set G8RC:$rA, (not (xor G8RC:$rS, G8RC:$rB)))]>;
253 def XOR8 : XForm_6<31, 316, (outs G8RC:$rA), (ins G8RC:$rS, G8RC:$rB),
254 "xor $rA, $rS, $rB", IntGeneral,
255 [(set G8RC:$rA, (xor G8RC:$rS, G8RC:$rB))]>;
257 // Logical ops with immediate.
258 def ANDIo8 : DForm_4<28, (outs G8RC:$dst), (ins G8RC:$src1, u16imm:$src2),
259 "andi. $dst, $src1, $src2", IntGeneral,
260 [(set G8RC:$dst, (and G8RC:$src1, immZExt16:$src2))]>,
262 def ANDISo8 : DForm_4<29, (outs G8RC:$dst), (ins G8RC:$src1, u16imm:$src2),
263 "andis. $dst, $src1, $src2", IntGeneral,
264 [(set G8RC:$dst, (and G8RC:$src1,imm16ShiftedZExt:$src2))]>,
266 def ORI8 : DForm_4<24, (outs G8RC:$dst), (ins G8RC:$src1, u16imm:$src2),
267 "ori $dst, $src1, $src2", IntGeneral,
268 [(set G8RC:$dst, (or G8RC:$src1, immZExt16:$src2))]>;
269 def ORIS8 : DForm_4<25, (outs G8RC:$dst), (ins G8RC:$src1, u16imm:$src2),
270 "oris $dst, $src1, $src2", IntGeneral,
271 [(set G8RC:$dst, (or G8RC:$src1, imm16ShiftedZExt:$src2))]>;
272 def XORI8 : DForm_4<26, (outs G8RC:$dst), (ins G8RC:$src1, u16imm:$src2),
273 "xori $dst, $src1, $src2", IntGeneral,
274 [(set G8RC:$dst, (xor G8RC:$src1, immZExt16:$src2))]>;
275 def XORIS8 : DForm_4<27, (outs G8RC:$dst), (ins G8RC:$src1, u16imm:$src2),
276 "xoris $dst, $src1, $src2", IntGeneral,
277 [(set G8RC:$dst, (xor G8RC:$src1, imm16ShiftedZExt:$src2))]>;
279 def ADD8 : XOForm_1<31, 266, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
280 "add $rT, $rA, $rB", IntGeneral,
281 [(set G8RC:$rT, (add G8RC:$rA, G8RC:$rB))]>;
283 def ADDC8 : XOForm_1<31, 10, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
284 "addc $rT, $rA, $rB", IntGeneral,
285 [(set G8RC:$rT, (addc G8RC:$rA, G8RC:$rB))]>,
286 PPC970_DGroup_Cracked;
287 def ADDE8 : XOForm_1<31, 138, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
288 "adde $rT, $rA, $rB", IntGeneral,
289 [(set G8RC:$rT, (adde G8RC:$rA, G8RC:$rB))]>;
291 def ADDI8 : DForm_2<14, (outs G8RC:$rD), (ins G8RC:$rA, s16imm64:$imm),
292 "addi $rD, $rA, $imm", IntGeneral,
293 [(set G8RC:$rD, (add G8RC:$rA, immSExt16:$imm))]>;
294 def ADDIS8 : DForm_2<15, (outs G8RC:$rD), (ins G8RC:$rA, symbolHi64:$imm),
295 "addis $rD, $rA, $imm", IntGeneral,
296 [(set G8RC:$rD, (add G8RC:$rA, imm16ShiftedSExt:$imm))]>;
298 def SUBFIC8: DForm_2< 8, (outs G8RC:$rD), (ins G8RC:$rA, s16imm64:$imm),
299 "subfic $rD, $rA, $imm", IntGeneral,
300 [(set G8RC:$rD, (subc immSExt16:$imm, G8RC:$rA))]>;
301 def SUBF8 : XOForm_1<31, 40, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
302 "subf $rT, $rA, $rB", IntGeneral,
303 [(set G8RC:$rT, (sub G8RC:$rB, G8RC:$rA))]>;
305 def SUBFC8 : XOForm_1<31, 8, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
306 "subfc $rT, $rA, $rB", IntGeneral,
307 [(set G8RC:$rT, (subc G8RC:$rB, G8RC:$rA))]>,
308 PPC970_DGroup_Cracked;
310 def SUBFE8 : XOForm_1<31, 136, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
311 "subfe $rT, $rA, $rB", IntGeneral,
312 [(set G8RC:$rT, (sube G8RC:$rB, G8RC:$rA))]>;
313 def ADDME8 : XOForm_3<31, 234, 0, (outs G8RC:$rT), (ins G8RC:$rA),
314 "addme $rT, $rA", IntGeneral,
315 [(set G8RC:$rT, (adde G8RC:$rA, immAllOnes))]>;
316 def ADDZE8 : XOForm_3<31, 202, 0, (outs G8RC:$rT), (ins G8RC:$rA),
317 "addze $rT, $rA", IntGeneral,
318 [(set G8RC:$rT, (adde G8RC:$rA, 0))]>;
319 def NEG8 : XOForm_3<31, 104, 0, (outs G8RC:$rT), (ins G8RC:$rA),
320 "neg $rT, $rA", IntGeneral,
321 [(set G8RC:$rT, (ineg G8RC:$rA))]>;
322 def SUBFME8 : XOForm_3<31, 232, 0, (outs G8RC:$rT), (ins G8RC:$rA),
323 "subfme $rT, $rA", IntGeneral,
324 [(set G8RC:$rT, (sube immAllOnes, G8RC:$rA))]>;
325 def SUBFZE8 : XOForm_3<31, 200, 0, (outs G8RC:$rT), (ins G8RC:$rA),
326 "subfze $rT, $rA", IntGeneral,
327 [(set G8RC:$rT, (sube 0, G8RC:$rA))]>;
331 def MULHD : XOForm_1<31, 73, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
332 "mulhd $rT, $rA, $rB", IntMulHW,
333 [(set G8RC:$rT, (mulhs G8RC:$rA, G8RC:$rB))]>;
334 def MULHDU : XOForm_1<31, 9, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
335 "mulhdu $rT, $rA, $rB", IntMulHWU,
336 [(set G8RC:$rT, (mulhu G8RC:$rA, G8RC:$rB))]>;
338 def CMPD : XForm_16_ext<31, 0, (outs CRRC:$crD), (ins G8RC:$rA, G8RC:$rB),
339 "cmpd $crD, $rA, $rB", IntCompare>, isPPC64;
340 def CMPLD : XForm_16_ext<31, 32, (outs CRRC:$crD), (ins G8RC:$rA, G8RC:$rB),
341 "cmpld $crD, $rA, $rB", IntCompare>, isPPC64;
342 def CMPDI : DForm_5_ext<11, (outs CRRC:$crD), (ins G8RC:$rA, s16imm:$imm),
343 "cmpdi $crD, $rA, $imm", IntCompare>, isPPC64;
344 def CMPLDI : DForm_6_ext<10, (outs CRRC:$dst), (ins G8RC:$src1, u16imm:$src2),
345 "cmpldi $dst, $src1, $src2", IntCompare>, isPPC64;
347 def SLD : XForm_6<31, 27, (outs G8RC:$rA), (ins G8RC:$rS, GPRC:$rB),
348 "sld $rA, $rS, $rB", IntRotateD,
349 [(set G8RC:$rA, (PPCshl G8RC:$rS, GPRC:$rB))]>, isPPC64;
350 def SRD : XForm_6<31, 539, (outs G8RC:$rA), (ins G8RC:$rS, GPRC:$rB),
351 "srd $rA, $rS, $rB", IntRotateD,
352 [(set G8RC:$rA, (PPCsrl G8RC:$rS, GPRC:$rB))]>, isPPC64;
353 def SRAD : XForm_6<31, 794, (outs G8RC:$rA), (ins G8RC:$rS, GPRC:$rB),
354 "srad $rA, $rS, $rB", IntRotateD,
355 [(set G8RC:$rA, (PPCsra G8RC:$rS, GPRC:$rB))]>, isPPC64;
357 def EXTSB8 : XForm_11<31, 954, (outs G8RC:$rA), (ins G8RC:$rS),
358 "extsb $rA, $rS", IntGeneral,
359 [(set G8RC:$rA, (sext_inreg G8RC:$rS, i8))]>;
360 def EXTSH8 : XForm_11<31, 922, (outs G8RC:$rA), (ins G8RC:$rS),
361 "extsh $rA, $rS", IntGeneral,
362 [(set G8RC:$rA, (sext_inreg G8RC:$rS, i16))]>;
364 def EXTSW : XForm_11<31, 986, (outs G8RC:$rA), (ins G8RC:$rS),
365 "extsw $rA, $rS", IntGeneral,
366 [(set G8RC:$rA, (sext_inreg G8RC:$rS, i32))]>, isPPC64;
367 /// EXTSW_32 - Just like EXTSW, but works on '32-bit' registers.
368 def EXTSW_32 : XForm_11<31, 986, (outs GPRC:$rA), (ins GPRC:$rS),
369 "extsw $rA, $rS", IntGeneral,
370 [(set GPRC:$rA, (PPCextsw_32 GPRC:$rS))]>, isPPC64;
371 def EXTSW_32_64 : XForm_11<31, 986, (outs G8RC:$rA), (ins GPRC:$rS),
372 "extsw $rA, $rS", IntGeneral,
373 [(set G8RC:$rA, (sext GPRC:$rS))]>, isPPC64;
375 def SRADI : XSForm_1<31, 413, (outs G8RC:$rA), (ins G8RC:$rS, u6imm:$SH),
376 "sradi $rA, $rS, $SH", IntRotateD,
377 [(set G8RC:$rA, (sra G8RC:$rS, (i32 imm:$SH)))]>, isPPC64;
378 def CNTLZD : XForm_11<31, 58, (outs G8RC:$rA), (ins G8RC:$rS),
379 "cntlzd $rA, $rS", IntGeneral,
380 [(set G8RC:$rA, (ctlz G8RC:$rS))]>;
382 def DIVD : XOForm_1<31, 489, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
383 "divd $rT, $rA, $rB", IntDivD,
384 [(set G8RC:$rT, (sdiv G8RC:$rA, G8RC:$rB))]>, isPPC64,
385 PPC970_DGroup_First, PPC970_DGroup_Cracked;
386 def DIVDU : XOForm_1<31, 457, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
387 "divdu $rT, $rA, $rB", IntDivD,
388 [(set G8RC:$rT, (udiv G8RC:$rA, G8RC:$rB))]>, isPPC64,
389 PPC970_DGroup_First, PPC970_DGroup_Cracked;
390 def MULLD : XOForm_1<31, 233, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
391 "mulld $rT, $rA, $rB", IntMulHD,
392 [(set G8RC:$rT, (mul G8RC:$rA, G8RC:$rB))]>, isPPC64;
395 let isCommutable = 1 in {
396 def RLDIMI : MDForm_1<30, 3,
397 (outs G8RC:$rA), (ins G8RC:$rSi, G8RC:$rS, u6imm:$SH, u6imm:$MB),
398 "rldimi $rA, $rS, $SH, $MB", IntRotateD,
399 []>, isPPC64, RegConstraint<"$rSi = $rA">,
403 // Rotate instructions.
404 def RLDCL : MDForm_1<30, 0,
405 (outs G8RC:$rA), (ins G8RC:$rS, GPRC:$rB, u6imm:$MB),
406 "rldcl $rA, $rS, $rB, $MB", IntRotateD,
408 def RLDICL : MDForm_1<30, 0,
409 (outs G8RC:$rA), (ins G8RC:$rS, u6imm:$SH, u6imm:$MB),
410 "rldicl $rA, $rS, $SH, $MB", IntRotateD,
412 def RLDICR : MDForm_1<30, 1,
413 (outs G8RC:$rA), (ins G8RC:$rS, u6imm:$SH, u6imm:$ME),
414 "rldicr $rA, $rS, $SH, $ME", IntRotateD,
416 } // End FXU Operations.
419 //===----------------------------------------------------------------------===//
420 // Load/Store instructions.
424 // Sign extending loads.
425 let isSimpleLoad = 1, PPC970_Unit = 2 in {
426 def LHA8: DForm_1<42, (outs G8RC:$rD), (ins memri:$src),
427 "lha $rD, $src", LdStLHA,
428 [(set G8RC:$rD, (sextloadi16 iaddr:$src))]>,
429 PPC970_DGroup_Cracked;
430 def LWA : DSForm_1<58, 2, (outs G8RC:$rD), (ins memrix:$src),
431 "lwa $rD, $src", LdStLWA,
432 [(set G8RC:$rD, (sextloadi32 ixaddr:$src))]>, isPPC64,
433 PPC970_DGroup_Cracked;
434 def LHAX8: XForm_1<31, 343, (outs G8RC:$rD), (ins memrr:$src),
435 "lhax $rD, $src", LdStLHA,
436 [(set G8RC:$rD, (sextloadi16 xaddr:$src))]>,
437 PPC970_DGroup_Cracked;
438 def LWAX : XForm_1<31, 341, (outs G8RC:$rD), (ins memrr:$src),
439 "lwax $rD, $src", LdStLHA,
440 [(set G8RC:$rD, (sextloadi32 xaddr:$src))]>, isPPC64,
441 PPC970_DGroup_Cracked;
444 def LHAU8 : DForm_1<43, (outs G8RC:$rD, ptr_rc:$ea_result), (ins symbolLo:$disp,
446 "lhau $rD, $disp($rA)", LdStGeneral,
447 []>, RegConstraint<"$rA = $ea_result">,
448 NoEncode<"$ea_result">;
453 // Zero extending loads.
454 let isSimpleLoad = 1, PPC970_Unit = 2 in {
455 def LBZ8 : DForm_1<34, (outs G8RC:$rD), (ins memri:$src),
456 "lbz $rD, $src", LdStGeneral,
457 [(set G8RC:$rD, (zextloadi8 iaddr:$src))]>;
458 def LHZ8 : DForm_1<40, (outs G8RC:$rD), (ins memri:$src),
459 "lhz $rD, $src", LdStGeneral,
460 [(set G8RC:$rD, (zextloadi16 iaddr:$src))]>;
461 def LWZ8 : DForm_1<32, (outs G8RC:$rD), (ins memri:$src),
462 "lwz $rD, $src", LdStGeneral,
463 [(set G8RC:$rD, (zextloadi32 iaddr:$src))]>, isPPC64;
465 def LBZX8 : XForm_1<31, 87, (outs G8RC:$rD), (ins memrr:$src),
466 "lbzx $rD, $src", LdStGeneral,
467 [(set G8RC:$rD, (zextloadi8 xaddr:$src))]>;
468 def LHZX8 : XForm_1<31, 279, (outs G8RC:$rD), (ins memrr:$src),
469 "lhzx $rD, $src", LdStGeneral,
470 [(set G8RC:$rD, (zextloadi16 xaddr:$src))]>;
471 def LWZX8 : XForm_1<31, 23, (outs G8RC:$rD), (ins memrr:$src),
472 "lwzx $rD, $src", LdStGeneral,
473 [(set G8RC:$rD, (zextloadi32 xaddr:$src))]>;
477 def LBZU8 : DForm_1<35, (outs G8RC:$rD, ptr_rc:$ea_result), (ins memri:$addr),
478 "lbzu $rD, $addr", LdStGeneral,
479 []>, RegConstraint<"$addr.reg = $ea_result">,
480 NoEncode<"$ea_result">;
481 def LHZU8 : DForm_1<41, (outs G8RC:$rD, ptr_rc:$ea_result), (ins memri:$addr),
482 "lhzu $rD, $addr", LdStGeneral,
483 []>, RegConstraint<"$addr.reg = $ea_result">,
484 NoEncode<"$ea_result">;
485 def LWZU8 : DForm_1<33, (outs G8RC:$rD, ptr_rc:$ea_result), (ins memri:$addr),
486 "lwzu $rD, $addr", LdStGeneral,
487 []>, RegConstraint<"$addr.reg = $ea_result">,
488 NoEncode<"$ea_result">;
492 // Full 8-byte loads.
493 let isSimpleLoad = 1, PPC970_Unit = 2 in {
494 def LD : DSForm_1<58, 0, (outs G8RC:$rD), (ins memrix:$src),
495 "ld $rD, $src", LdStLD,
496 [(set G8RC:$rD, (load ixaddr:$src))]>, isPPC64;
497 def LDX : XForm_1<31, 21, (outs G8RC:$rD), (ins memrr:$src),
498 "ldx $rD, $src", LdStLD,
499 [(set G8RC:$rD, (load xaddr:$src))]>, isPPC64;
501 def LDU : DSForm_1<58, 1, (outs G8RC:$rD, ptr_rc:$ea_result), (ins memrix:$addr),
502 "ldu $rD, $addr", LdStLD,
503 []>, RegConstraint<"$addr.reg = $ea_result">, isPPC64,
504 NoEncode<"$ea_result">;
508 let PPC970_Unit = 2 in {
509 // Truncating stores.
510 def STB8 : DForm_1<38, (outs), (ins G8RC:$rS, memri:$src),
511 "stb $rS, $src", LdStGeneral,
512 [(truncstorei8 G8RC:$rS, iaddr:$src)]>;
513 def STH8 : DForm_1<44, (outs), (ins G8RC:$rS, memri:$src),
514 "sth $rS, $src", LdStGeneral,
515 [(truncstorei16 G8RC:$rS, iaddr:$src)]>;
516 def STW8 : DForm_1<36, (outs), (ins G8RC:$rS, memri:$src),
517 "stw $rS, $src", LdStGeneral,
518 [(truncstorei32 G8RC:$rS, iaddr:$src)]>;
519 def STBX8 : XForm_8<31, 215, (outs), (ins G8RC:$rS, memrr:$dst),
520 "stbx $rS, $dst", LdStGeneral,
521 [(truncstorei8 G8RC:$rS, xaddr:$dst)]>,
522 PPC970_DGroup_Cracked;
523 def STHX8 : XForm_8<31, 407, (outs), (ins G8RC:$rS, memrr:$dst),
524 "sthx $rS, $dst", LdStGeneral,
525 [(truncstorei16 G8RC:$rS, xaddr:$dst)]>,
526 PPC970_DGroup_Cracked;
527 def STWX8 : XForm_8<31, 151, (outs), (ins G8RC:$rS, memrr:$dst),
528 "stwx $rS, $dst", LdStGeneral,
529 [(truncstorei32 G8RC:$rS, xaddr:$dst)]>,
530 PPC970_DGroup_Cracked;
531 // Normal 8-byte stores.
532 def STD : DSForm_1<62, 0, (outs), (ins G8RC:$rS, memrix:$dst),
533 "std $rS, $dst", LdStSTD,
534 [(store G8RC:$rS, ixaddr:$dst)]>, isPPC64;
535 def STDX : XForm_8<31, 149, (outs), (ins G8RC:$rS, memrr:$dst),
536 "stdx $rS, $dst", LdStSTD,
537 [(store G8RC:$rS, xaddr:$dst)]>, isPPC64,
538 PPC970_DGroup_Cracked;
541 let PPC970_Unit = 2 in {
543 def STBU8 : DForm_1<38, (outs ptr_rc:$ea_res), (ins G8RC:$rS,
544 symbolLo:$ptroff, ptr_rc:$ptrreg),
545 "stbu $rS, $ptroff($ptrreg)", LdStGeneral,
546 [(set ptr_rc:$ea_res,
547 (pre_truncsti8 G8RC:$rS, ptr_rc:$ptrreg,
548 iaddroff:$ptroff))]>,
549 RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">;
550 def STHU8 : DForm_1<45, (outs ptr_rc:$ea_res), (ins G8RC:$rS,
551 symbolLo:$ptroff, ptr_rc:$ptrreg),
552 "sthu $rS, $ptroff($ptrreg)", LdStGeneral,
553 [(set ptr_rc:$ea_res,
554 (pre_truncsti16 G8RC:$rS, ptr_rc:$ptrreg,
555 iaddroff:$ptroff))]>,
556 RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">;
557 def STWU8 : DForm_1<37, (outs ptr_rc:$ea_res), (ins G8RC:$rS,
558 symbolLo:$ptroff, ptr_rc:$ptrreg),
559 "stwu $rS, $ptroff($ptrreg)", LdStGeneral,
560 [(set ptr_rc:$ea_res, (pre_store G8RC:$rS, ptr_rc:$ptrreg,
561 iaddroff:$ptroff))]>,
562 RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">;
565 def STDU : DSForm_1<62, 1, (outs ptr_rc:$ea_res), (ins G8RC:$rS,
566 s16immX4:$ptroff, ptr_rc:$ptrreg),
567 "stdu $rS, $ptroff($ptrreg)", LdStSTD,
568 [(set ptr_rc:$ea_res, (pre_store G8RC:$rS, ptr_rc:$ptrreg,
569 iaddroff:$ptroff))]>,
570 RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">,
574 def STDUX : XForm_8<31, 181, (outs), (ins G8RC:$rS, memrr:$dst),
575 "stdux $rS, $dst", LdStSTD,
578 // STD_32/STDX_32 - Just like STD/STDX, but uses a '32-bit' input register.
579 def STD_32 : DSForm_1<62, 0, (outs), (ins GPRC:$rT, memrix:$dst),
580 "std $rT, $dst", LdStSTD,
581 [(PPCstd_32 GPRC:$rT, ixaddr:$dst)]>, isPPC64;
582 def STDX_32 : XForm_8<31, 149, (outs), (ins GPRC:$rT, memrr:$dst),
583 "stdx $rT, $dst", LdStSTD,
584 [(PPCstd_32 GPRC:$rT, xaddr:$dst)]>, isPPC64,
585 PPC970_DGroup_Cracked;
590 //===----------------------------------------------------------------------===//
591 // Floating point instructions.
595 let PPC970_Unit = 3 in { // FPU Operations.
596 def FCFID : XForm_26<63, 846, (outs F8RC:$frD), (ins F8RC:$frB),
597 "fcfid $frD, $frB", FPGeneral,
598 [(set F8RC:$frD, (PPCfcfid F8RC:$frB))]>, isPPC64;
599 def FCTIDZ : XForm_26<63, 815, (outs F8RC:$frD), (ins F8RC:$frB),
600 "fctidz $frD, $frB", FPGeneral,
601 [(set F8RC:$frD, (PPCfctidz F8RC:$frB))]>, isPPC64;
605 //===----------------------------------------------------------------------===//
606 // Instruction Patterns
609 // Extensions and truncates to/from 32-bit regs.
610 def : Pat<(i64 (zext GPRC:$in)),
611 (RLDICL (OR4To8 GPRC:$in, GPRC:$in), 0, 32)>;
612 def : Pat<(i64 (anyext GPRC:$in)),
613 (OR4To8 GPRC:$in, GPRC:$in)>;
614 def : Pat<(i32 (trunc G8RC:$in)),
615 (OR8To4 G8RC:$in, G8RC:$in)>;
617 // Extending loads with i64 targets.
618 def : Pat<(zextloadi1 iaddr:$src),
620 def : Pat<(zextloadi1 xaddr:$src),
622 def : Pat<(extloadi1 iaddr:$src),
624 def : Pat<(extloadi1 xaddr:$src),
626 def : Pat<(extloadi8 iaddr:$src),
628 def : Pat<(extloadi8 xaddr:$src),
630 def : Pat<(extloadi16 iaddr:$src),
632 def : Pat<(extloadi16 xaddr:$src),
634 def : Pat<(extloadi32 iaddr:$src),
636 def : Pat<(extloadi32 xaddr:$src),
639 // Standard shifts. These are represented separately from the real shifts above
640 // so that we can distinguish between shifts that allow 6-bit and 7-bit shift
642 def : Pat<(sra G8RC:$rS, GPRC:$rB),
643 (SRAD G8RC:$rS, GPRC:$rB)>;
644 def : Pat<(srl G8RC:$rS, GPRC:$rB),
645 (SRD G8RC:$rS, GPRC:$rB)>;
646 def : Pat<(shl G8RC:$rS, GPRC:$rB),
647 (SLD G8RC:$rS, GPRC:$rB)>;
650 def : Pat<(shl G8RC:$in, (i32 imm:$imm)),
651 (RLDICR G8RC:$in, imm:$imm, (SHL64 imm:$imm))>;
652 def : Pat<(srl G8RC:$in, (i32 imm:$imm)),
653 (RLDICL G8RC:$in, (SRL64 imm:$imm), imm:$imm)>;
656 def : Pat<(rotl G8RC:$in, GPRC:$sh),
657 (RLDCL G8RC:$in, GPRC:$sh, 0)>;
658 def : Pat<(rotl G8RC:$in, (i32 imm:$imm)),
659 (RLDICL G8RC:$in, imm:$imm, 0)>;
661 // Hi and Lo for Darwin Global Addresses.
662 def : Pat<(PPChi tglobaladdr:$in, 0), (LIS8 tglobaladdr:$in)>;
663 def : Pat<(PPClo tglobaladdr:$in, 0), (LI8 tglobaladdr:$in)>;
664 def : Pat<(PPChi tconstpool:$in , 0), (LIS8 tconstpool:$in)>;
665 def : Pat<(PPClo tconstpool:$in , 0), (LI8 tconstpool:$in)>;
666 def : Pat<(PPChi tjumptable:$in , 0), (LIS8 tjumptable:$in)>;
667 def : Pat<(PPClo tjumptable:$in , 0), (LI8 tjumptable:$in)>;
668 def : Pat<(add G8RC:$in, (PPChi tglobaladdr:$g, 0)),
669 (ADDIS8 G8RC:$in, tglobaladdr:$g)>;
670 def : Pat<(add G8RC:$in, (PPChi tconstpool:$g, 0)),
671 (ADDIS8 G8RC:$in, tconstpool:$g)>;
672 def : Pat<(add G8RC:$in, (PPChi tjumptable:$g, 0)),
673 (ADDIS8 G8RC:$in, tjumptable:$g)>;