1 //===-- PPCInstr64Bit.td - The PowerPC 64-bit Support ------*- tablegen -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file describes the PowerPC 64-bit instructions. These patterns are used
10 // both when in ppc64 mode and when in "use 64-bit extensions in 32-bit" mode.
12 //===----------------------------------------------------------------------===//
14 //===----------------------------------------------------------------------===//
17 def s16imm64 : Operand<i64> {
18 let PrintMethod = "printS16ImmOperand";
19 let EncoderMethod = "getImm16Encoding";
20 let ParserMatchClass = PPCS16ImmAsmOperand;
21 let DecoderMethod = "decodeSImmOperand<16>";
23 def u16imm64 : Operand<i64> {
24 let PrintMethod = "printU16ImmOperand";
25 let EncoderMethod = "getImm16Encoding";
26 let ParserMatchClass = PPCU16ImmAsmOperand;
27 let DecoderMethod = "decodeUImmOperand<16>";
29 def s17imm64 : Operand<i64> {
30 // This operand type is used for addis/lis to allow the assembler parser
31 // to accept immediates in the range -65536..65535 for compatibility with
32 // the GNU assembler. The operand is treated as 16-bit otherwise.
33 let PrintMethod = "printS16ImmOperand";
34 let EncoderMethod = "getImm16Encoding";
35 let ParserMatchClass = PPCS17ImmAsmOperand;
36 let DecoderMethod = "decodeSImmOperand<16>";
38 def tocentry : Operand<iPTR> {
39 let MIOperandInfo = (ops i64imm:$imm);
41 def tlsreg : Operand<i64> {
42 let EncoderMethod = "getTLSRegEncoding";
43 let ParserMatchClass = PPCTLSRegOperand;
45 def tlsgd : Operand<i64> {}
46 def tlscall : Operand<i64> {
47 let PrintMethod = "printTLSCall";
48 let MIOperandInfo = (ops calltarget:$func, tlsgd:$sym);
49 let EncoderMethod = "getTLSCallEncoding";
52 //===----------------------------------------------------------------------===//
53 // 64-bit transformation functions.
56 def SHL64 : SDNodeXForm<imm, [{
57 // Transformation function: 63 - imm
58 return getI32Imm(63 - N->getZExtValue(), SDLoc(N));
61 def SRL64 : SDNodeXForm<imm, [{
62 // Transformation function: 64 - imm
63 return N->getZExtValue() ? getI32Imm(64 - N->getZExtValue(), SDLoc(N))
64 : getI32Imm(0, SDLoc(N));
68 //===----------------------------------------------------------------------===//
72 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
73 let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7 in {
74 let isReturn = 1, Uses = [LR8, RM] in
75 def BLR8 : XLForm_2_ext<19, 16, 20, 0, 0, (outs), (ins), "blr", IIC_BrB,
76 [(retflag)]>, Requires<[In64BitMode]>;
77 let isBranch = 1, isIndirectBranch = 1, Uses = [CTR8] in {
78 def BCTR8 : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
80 Requires<[In64BitMode]>;
81 def BCCCTR8 : XLForm_2_br<19, 528, 0, (outs), (ins pred:$cond),
82 "b${cond:cc}ctr${cond:pm} ${cond:reg}", IIC_BrB,
84 Requires<[In64BitMode]>;
86 def BCCTR8 : XLForm_2_br2<19, 528, 12, 0, (outs), (ins crbitrc:$bi),
87 "bcctr 12, $bi, 0", IIC_BrB, []>,
88 Requires<[In64BitMode]>;
89 def BCCTR8n : XLForm_2_br2<19, 528, 4, 0, (outs), (ins crbitrc:$bi),
90 "bcctr 4, $bi, 0", IIC_BrB, []>,
91 Requires<[In64BitMode]>;
96 def MovePCtoLR8 : PPCEmitTimePseudo<(outs), (ins), "#MovePCtoLR8", []>,
99 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7 in {
100 let Defs = [CTR8], Uses = [CTR8] in {
101 def BDZ8 : BForm_1<16, 18, 0, 0, (outs), (ins condbrtarget:$dst),
103 def BDNZ8 : BForm_1<16, 16, 0, 0, (outs), (ins condbrtarget:$dst),
107 let isReturn = 1, Defs = [CTR8], Uses = [CTR8, LR8, RM] in {
108 def BDZLR8 : XLForm_2_ext<19, 16, 18, 0, 0, (outs), (ins),
109 "bdzlr", IIC_BrB, []>;
110 def BDNZLR8 : XLForm_2_ext<19, 16, 16, 0, 0, (outs), (ins),
111 "bdnzlr", IIC_BrB, []>;
117 let isCall = 1, PPC970_Unit = 7, Defs = [LR8] in {
118 // Convenient aliases for call instructions
120 def BL8 : IForm<18, 0, 1, (outs), (ins calltarget:$func),
121 "bl $func", IIC_BrB, []>; // See Pat patterns below.
123 def BL8_TLS : IForm<18, 0, 1, (outs), (ins tlscall:$func),
124 "bl $func", IIC_BrB, []>;
126 def BLA8 : IForm<18, 1, 1, (outs), (ins abscalltarget:$func),
127 "bla $func", IIC_BrB, [(PPCcall (i64 imm:$func))]>;
129 let Uses = [RM], isCodeGenOnly = 1 in {
130 def BL8_NOP : IForm_and_DForm_4_zero<18, 0, 1, 24,
131 (outs), (ins calltarget:$func),
132 "bl $func\n\tnop", IIC_BrB, []>;
134 def BL8_NOP_TLS : IForm_and_DForm_4_zero<18, 0, 1, 24,
135 (outs), (ins tlscall:$func),
136 "bl $func\n\tnop", IIC_BrB, []>;
138 def BLA8_NOP : IForm_and_DForm_4_zero<18, 1, 1, 24,
139 (outs), (ins abscalltarget:$func),
140 "bla $func\n\tnop", IIC_BrB,
141 [(PPCcall_nop (i64 imm:$func))]>;
143 let Uses = [CTR8, RM] in {
144 def BCTRL8 : XLForm_2_ext<19, 528, 20, 0, 1, (outs), (ins),
145 "bctrl", IIC_BrB, [(PPCbctrl)]>,
146 Requires<[In64BitMode]>;
148 let isCodeGenOnly = 1 in {
149 def BCCCTRL8 : XLForm_2_br<19, 528, 1, (outs), (ins pred:$cond),
150 "b${cond:cc}ctrl${cond:pm} ${cond:reg}", IIC_BrB,
152 Requires<[In64BitMode]>;
154 def BCCTRL8 : XLForm_2_br2<19, 528, 12, 1, (outs), (ins crbitrc:$bi),
155 "bcctrl 12, $bi, 0", IIC_BrB, []>,
156 Requires<[In64BitMode]>;
157 def BCCTRL8n : XLForm_2_br2<19, 528, 4, 1, (outs), (ins crbitrc:$bi),
158 "bcctrl 4, $bi, 0", IIC_BrB, []>,
159 Requires<[In64BitMode]>;
164 let isCall = 1, PPC970_Unit = 7, isCodeGenOnly = 1,
165 Defs = [LR8, X2], Uses = [CTR8, RM], RST = 2 in {
166 def BCTRL8_LDinto_toc :
167 XLForm_2_ext_and_DSForm_1<19, 528, 20, 0, 1, 58, 0, (outs),
169 "bctrl\n\tld 2, $src", IIC_BrB,
170 [(PPCbctrl_load_toc ixaddr:$src)]>,
171 Requires<[In64BitMode]>;
174 } // Interpretation64Bit
176 // FIXME: Duplicating this for the asm parser should be unnecessary, but the
177 // previous definition must be marked as CodeGen only to prevent decoding
179 let Interpretation64Bit = 1, isAsmParserOnly = 1 in
180 let isCall = 1, PPC970_Unit = 7, Defs = [LR8], Uses = [RM] in
181 def BL8_TLS_ : IForm<18, 0, 1, (outs), (ins tlscall:$func),
182 "bl $func", IIC_BrB, []>;
185 def : Pat<(PPCcall (i64 tglobaladdr:$dst)),
186 (BL8 tglobaladdr:$dst)>;
187 def : Pat<(PPCcall_nop (i64 tglobaladdr:$dst)),
188 (BL8_NOP tglobaladdr:$dst)>;
190 def : Pat<(PPCcall (i64 texternalsym:$dst)),
191 (BL8 texternalsym:$dst)>;
192 def : Pat<(PPCcall_nop (i64 texternalsym:$dst)),
193 (BL8_NOP texternalsym:$dst)>;
196 // FIXME: some of these might be used with constant operands. This will result
197 // in constant materialization instructions that may be redundant. We currently
198 // clean this up in PPCMIPeephole with calls to
199 // PPCInstrInfo::convertToImmediateForm() but we should probably not emit them
200 // in the first place.
201 let Defs = [CR0] in {
202 def ATOMIC_LOAD_ADD_I64 : PPCCustomInserterPseudo<
203 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_ADD_I64",
204 [(set i64:$dst, (atomic_load_add_64 xoaddr:$ptr, i64:$incr))]>;
205 def ATOMIC_LOAD_SUB_I64 : PPCCustomInserterPseudo<
206 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_SUB_I64",
207 [(set i64:$dst, (atomic_load_sub_64 xoaddr:$ptr, i64:$incr))]>;
208 def ATOMIC_LOAD_OR_I64 : PPCCustomInserterPseudo<
209 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_OR_I64",
210 [(set i64:$dst, (atomic_load_or_64 xoaddr:$ptr, i64:$incr))]>;
211 def ATOMIC_LOAD_XOR_I64 : PPCCustomInserterPseudo<
212 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_XOR_I64",
213 [(set i64:$dst, (atomic_load_xor_64 xoaddr:$ptr, i64:$incr))]>;
214 def ATOMIC_LOAD_AND_I64 : PPCCustomInserterPseudo<
215 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_AND_i64",
216 [(set i64:$dst, (atomic_load_and_64 xoaddr:$ptr, i64:$incr))]>;
217 def ATOMIC_LOAD_NAND_I64 : PPCCustomInserterPseudo<
218 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_NAND_I64",
219 [(set i64:$dst, (atomic_load_nand_64 xoaddr:$ptr, i64:$incr))]>;
220 def ATOMIC_LOAD_MIN_I64 : PPCCustomInserterPseudo<
221 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_MIN_I64",
222 [(set i64:$dst, (atomic_load_min_64 xoaddr:$ptr, i64:$incr))]>;
223 def ATOMIC_LOAD_MAX_I64 : PPCCustomInserterPseudo<
224 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_MAX_I64",
225 [(set i64:$dst, (atomic_load_max_64 xoaddr:$ptr, i64:$incr))]>;
226 def ATOMIC_LOAD_UMIN_I64 : PPCCustomInserterPseudo<
227 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_UMIN_I64",
228 [(set i64:$dst, (atomic_load_umin_64 xoaddr:$ptr, i64:$incr))]>;
229 def ATOMIC_LOAD_UMAX_I64 : PPCCustomInserterPseudo<
230 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_UMAX_I64",
231 [(set i64:$dst, (atomic_load_umax_64 xoaddr:$ptr, i64:$incr))]>;
233 def ATOMIC_CMP_SWAP_I64 : PPCCustomInserterPseudo<
234 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$old, g8rc:$new), "#ATOMIC_CMP_SWAP_I64",
235 [(set i64:$dst, (atomic_cmp_swap_64 xoaddr:$ptr, i64:$old, i64:$new))]>;
237 def ATOMIC_SWAP_I64 : PPCCustomInserterPseudo<
238 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$new), "#ATOMIC_SWAP_I64",
239 [(set i64:$dst, (atomic_swap_64 xoaddr:$ptr, i64:$new))]>;
242 // Instructions to support atomic operations
243 let mayLoad = 1, hasSideEffects = 0 in {
244 def LDARX : XForm_1_memOp<31, 84, (outs g8rc:$rD), (ins memrr:$ptr),
245 "ldarx $rD, $ptr", IIC_LdStLDARX, []>;
247 // Instruction to support lock versions of atomics
248 // (EH=1 - see Power ISA 2.07 Book II 4.4.2)
249 def LDARXL : XForm_1<31, 84, (outs g8rc:$rD), (ins memrr:$ptr),
250 "ldarx $rD, $ptr, 1", IIC_LdStLDARX, []>, isDOT;
252 let hasExtraDefRegAllocReq = 1 in
253 def LDAT : X_RD5_RS5_IM5<31, 614, (outs g8rc:$rD), (ins g8rc:$rA, u5imm:$FC),
254 "ldat $rD, $rA, $FC", IIC_LdStLoad>, isPPC64,
255 Requires<[IsISA3_0]>;
258 let Defs = [CR0], mayStore = 1, mayLoad = 0, hasSideEffects = 0 in
259 def STDCX : XForm_1_memOp<31, 214, (outs), (ins g8rc:$rS, memrr:$dst),
260 "stdcx. $rS, $dst", IIC_LdStSTDCX, []>, isDOT;
262 let mayStore = 1, mayLoad = 0, hasSideEffects = 0 in
263 def STDAT : X_RD5_RS5_IM5<31, 742, (outs), (ins g8rc:$rS, g8rc:$rA, u5imm:$FC),
264 "stdat $rS, $rA, $FC", IIC_LdStStore>, isPPC64,
265 Requires<[IsISA3_0]>;
267 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
268 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
269 def TCRETURNdi8 :PPCEmitTimePseudo< (outs),
270 (ins calltarget:$dst, i32imm:$offset),
271 "#TC_RETURNd8 $dst $offset",
274 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
275 def TCRETURNai8 :PPCEmitTimePseudo<(outs), (ins abscalltarget:$func, i32imm:$offset),
276 "#TC_RETURNa8 $func $offset",
277 [(PPCtc_return (i64 imm:$func), imm:$offset)]>;
279 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
280 def TCRETURNri8 : PPCEmitTimePseudo<(outs), (ins CTRRC8:$dst, i32imm:$offset),
281 "#TC_RETURNr8 $dst $offset",
284 let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, isBranch = 1,
285 isIndirectBranch = 1, isCall = 1, isReturn = 1, Uses = [CTR8, RM] in
286 def TAILBCTR8 : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
288 Requires<[In64BitMode]>;
290 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
291 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
292 def TAILB8 : IForm<18, 0, 0, (outs), (ins calltarget:$dst),
296 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
297 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
298 def TAILBA8 : IForm<18, 0, 0, (outs), (ins abscalltarget:$dst),
301 } // Interpretation64Bit
303 def : Pat<(PPCtc_return (i64 tglobaladdr:$dst), imm:$imm),
304 (TCRETURNdi8 tglobaladdr:$dst, imm:$imm)>;
306 def : Pat<(PPCtc_return (i64 texternalsym:$dst), imm:$imm),
307 (TCRETURNdi8 texternalsym:$dst, imm:$imm)>;
309 def : Pat<(PPCtc_return CTRRC8:$dst, imm:$imm),
310 (TCRETURNri8 CTRRC8:$dst, imm:$imm)>;
313 // 64-bit CR instructions
314 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
315 let hasSideEffects = 0 in {
316 // mtocrf's input needs to be prepared by shifting by an amount dependent
317 // on the cr register selected. Thus, post-ra anti-dep breaking must not
318 // later change that register assignment.
319 let hasExtraDefRegAllocReq = 1 in {
320 def MTOCRF8: XFXForm_5a<31, 144, (outs crbitm:$FXM), (ins g8rc:$ST),
321 "mtocrf $FXM, $ST", IIC_BrMCRX>,
322 PPC970_DGroup_First, PPC970_Unit_CRU;
324 // Similarly to mtocrf, the mask for mtcrf must be prepared in a way that
325 // is dependent on the cr fields being set.
326 def MTCRF8 : XFXForm_5<31, 144, (outs), (ins i32imm:$FXM, g8rc:$rS),
327 "mtcrf $FXM, $rS", IIC_BrMCRX>,
328 PPC970_MicroCode, PPC970_Unit_CRU;
329 } // hasExtraDefRegAllocReq = 1
331 // mfocrf's input needs to be prepared by shifting by an amount dependent
332 // on the cr register selected. Thus, post-ra anti-dep breaking must not
333 // later change that register assignment.
334 let hasExtraSrcRegAllocReq = 1 in {
335 def MFOCRF8: XFXForm_5a<31, 19, (outs g8rc:$rT), (ins crbitm:$FXM),
336 "mfocrf $rT, $FXM", IIC_SprMFCRF>,
337 PPC970_DGroup_First, PPC970_Unit_CRU;
339 // Similarly to mfocrf, the mask for mfcrf must be prepared in a way that
340 // is dependent on the cr fields being copied.
341 def MFCR8 : XFXForm_3<31, 19, (outs g8rc:$rT), (ins),
342 "mfcr $rT", IIC_SprMFCR>,
343 PPC970_MicroCode, PPC970_Unit_CRU;
344 } // hasExtraSrcRegAllocReq = 1
345 } // hasSideEffects = 0
347 // While longjmp is a control-flow barrier (fallthrough isn't allowed), setjmp
349 let hasSideEffects = 1 in {
351 def EH_SjLj_SetJmp64 : PPCCustomInserterPseudo<(outs gprc:$dst), (ins memr:$buf),
353 [(set i32:$dst, (PPCeh_sjlj_setjmp addr:$buf))]>,
354 Requires<[In64BitMode]>;
357 let hasSideEffects = 1, isBarrier = 1 in {
358 let isTerminator = 1 in
359 def EH_SjLj_LongJmp64 : PPCCustomInserterPseudo<(outs), (ins memr:$buf),
360 "#EH_SJLJ_LONGJMP64",
361 [(PPCeh_sjlj_longjmp addr:$buf)]>,
362 Requires<[In64BitMode]>;
365 def MFSPR8 : XFXForm_1<31, 339, (outs g8rc:$RT), (ins i32imm:$SPR),
366 "mfspr $RT, $SPR", IIC_SprMFSPR>;
367 def MTSPR8 : XFXForm_1<31, 467, (outs), (ins i32imm:$SPR, g8rc:$RT),
368 "mtspr $SPR, $RT", IIC_SprMTSPR>;
371 //===----------------------------------------------------------------------===//
372 // 64-bit SPR manipulation instrs.
374 let Uses = [CTR8] in {
375 def MFCTR8 : XFXForm_1_ext<31, 339, 9, (outs g8rc:$rT), (ins),
376 "mfctr $rT", IIC_SprMFSPR>,
377 PPC970_DGroup_First, PPC970_Unit_FXU;
379 let Pattern = [(PPCmtctr i64:$rS)], Defs = [CTR8] in {
380 def MTCTR8 : XFXForm_7_ext<31, 467, 9, (outs), (ins g8rc:$rS),
381 "mtctr $rS", IIC_SprMTSPR>,
382 PPC970_DGroup_First, PPC970_Unit_FXU;
384 let hasSideEffects = 1, Defs = [CTR8] in {
385 let Pattern = [(int_ppc_mtctr i64:$rS)] in
386 def MTCTR8loop : XFXForm_7_ext<31, 467, 9, (outs), (ins g8rc:$rS),
387 "mtctr $rS", IIC_SprMTSPR>,
388 PPC970_DGroup_First, PPC970_Unit_FXU;
391 let Pattern = [(set i64:$rT, readcyclecounter)] in
392 def MFTB8 : XFXForm_1_ext<31, 339, 268, (outs g8rc:$rT), (ins),
393 "mfspr $rT, 268", IIC_SprMFTB>,
394 PPC970_DGroup_First, PPC970_Unit_FXU;
395 // Note that encoding mftb using mfspr is now the preferred form,
396 // and has been since at least ISA v2.03. The mftb instruction has
397 // now been phased out. Using mfspr, however, is known not to work on
400 let Defs = [X1], Uses = [X1] in
401 def DYNALLOC8 : PPCEmitTimePseudo<(outs g8rc:$result), (ins g8rc:$negsize, memri:$fpsi),"#DYNALLOC8",
403 (PPCdynalloc i64:$negsize, iaddr:$fpsi))]>;
404 def DYNAREAOFFSET8 : PPCEmitTimePseudo<(outs i64imm:$result), (ins memri:$fpsi), "#DYNAREAOFFSET8",
405 [(set i64:$result, (PPCdynareaoffset iaddr:$fpsi))]>;
407 let Defs = [LR8] in {
408 def MTLR8 : XFXForm_7_ext<31, 467, 8, (outs), (ins g8rc:$rS),
409 "mtlr $rS", IIC_SprMTSPR>,
410 PPC970_DGroup_First, PPC970_Unit_FXU;
412 let Uses = [LR8] in {
413 def MFLR8 : XFXForm_1_ext<31, 339, 8, (outs g8rc:$rT), (ins),
414 "mflr $rT", IIC_SprMFSPR>,
415 PPC970_DGroup_First, PPC970_Unit_FXU;
417 } // Interpretation64Bit
419 //===----------------------------------------------------------------------===//
420 // Fixed point instructions.
423 let PPC970_Unit = 1 in { // FXU Operations.
424 let Interpretation64Bit = 1 in {
425 let hasSideEffects = 0 in {
426 let isCodeGenOnly = 1 in {
428 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in {
429 def LI8 : DForm_2_r0<14, (outs g8rc:$rD), (ins s16imm64:$imm),
430 "li $rD, $imm", IIC_IntSimple,
431 [(set i64:$rD, imm64SExt16:$imm)]>;
432 def LIS8 : DForm_2_r0<15, (outs g8rc:$rD), (ins s17imm64:$imm),
433 "lis $rD, $imm", IIC_IntSimple,
434 [(set i64:$rD, imm16ShiftedSExt:$imm)]>;
438 let isCommutable = 1 in {
439 defm NAND8: XForm_6r<31, 476, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
440 "nand", "$rA, $rS, $rB", IIC_IntSimple,
441 [(set i64:$rA, (not (and i64:$rS, i64:$rB)))]>;
442 defm AND8 : XForm_6r<31, 28, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
443 "and", "$rA, $rS, $rB", IIC_IntSimple,
444 [(set i64:$rA, (and i64:$rS, i64:$rB))]>;
446 defm ANDC8: XForm_6r<31, 60, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
447 "andc", "$rA, $rS, $rB", IIC_IntSimple,
448 [(set i64:$rA, (and i64:$rS, (not i64:$rB)))]>;
449 let isCommutable = 1 in {
450 defm OR8 : XForm_6r<31, 444, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
451 "or", "$rA, $rS, $rB", IIC_IntSimple,
452 [(set i64:$rA, (or i64:$rS, i64:$rB))]>;
453 defm NOR8 : XForm_6r<31, 124, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
454 "nor", "$rA, $rS, $rB", IIC_IntSimple,
455 [(set i64:$rA, (not (or i64:$rS, i64:$rB)))]>;
457 defm ORC8 : XForm_6r<31, 412, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
458 "orc", "$rA, $rS, $rB", IIC_IntSimple,
459 [(set i64:$rA, (or i64:$rS, (not i64:$rB)))]>;
460 let isCommutable = 1 in {
461 defm EQV8 : XForm_6r<31, 284, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
462 "eqv", "$rA, $rS, $rB", IIC_IntSimple,
463 [(set i64:$rA, (not (xor i64:$rS, i64:$rB)))]>;
464 defm XOR8 : XForm_6r<31, 316, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
465 "xor", "$rA, $rS, $rB", IIC_IntSimple,
466 [(set i64:$rA, (xor i64:$rS, i64:$rB))]>;
467 } // let isCommutable = 1
469 // Logical ops with immediate.
470 let Defs = [CR0] in {
471 def ANDIo8 : DForm_4<28, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
472 "andi. $dst, $src1, $src2", IIC_IntGeneral,
473 [(set i64:$dst, (and i64:$src1, immZExt16:$src2))]>,
475 def ANDISo8 : DForm_4<29, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
476 "andis. $dst, $src1, $src2", IIC_IntGeneral,
477 [(set i64:$dst, (and i64:$src1, imm16ShiftedZExt:$src2))]>,
480 def ORI8 : DForm_4<24, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
481 "ori $dst, $src1, $src2", IIC_IntSimple,
482 [(set i64:$dst, (or i64:$src1, immZExt16:$src2))]>;
483 def ORIS8 : DForm_4<25, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
484 "oris $dst, $src1, $src2", IIC_IntSimple,
485 [(set i64:$dst, (or i64:$src1, imm16ShiftedZExt:$src2))]>;
486 def XORI8 : DForm_4<26, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
487 "xori $dst, $src1, $src2", IIC_IntSimple,
488 [(set i64:$dst, (xor i64:$src1, immZExt16:$src2))]>;
489 def XORIS8 : DForm_4<27, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
490 "xoris $dst, $src1, $src2", IIC_IntSimple,
491 [(set i64:$dst, (xor i64:$src1, imm16ShiftedZExt:$src2))]>;
493 let isCommutable = 1 in
494 defm ADD8 : XOForm_1r<31, 266, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
495 "add", "$rT, $rA, $rB", IIC_IntSimple,
496 [(set i64:$rT, (add i64:$rA, i64:$rB))]>;
497 // ADD8 has a special form: reg = ADD8(reg, sym@tls) for use by the
498 // initial-exec thread-local storage model. We need to forbid r0 here -
499 // while it works for add just fine, the linker can relax this to local-exec
500 // addi, which won't work for r0.
501 def ADD8TLS : XOForm_1<31, 266, 0, (outs g8rc:$rT), (ins g8rc_nox0:$rA, tlsreg:$rB),
502 "add $rT, $rA, $rB", IIC_IntSimple,
503 [(set i64:$rT, (add i64:$rA, tglobaltlsaddr:$rB))]>;
505 def LBZXTLS : XForm_1<31, 87, (outs g8rc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
506 "lbzx $rD, $rA, $rB", IIC_LdStLoad, []>;
507 def LHZXTLS : XForm_1<31, 279, (outs g8rc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
508 "lhzx $rD, $rA, $rB", IIC_LdStLoad, []>;
509 def LWZXTLS : XForm_1<31, 23, (outs g8rc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
510 "lwzx $rD, $rA, $rB", IIC_LdStLoad, []>;
511 def LDXTLS : XForm_1<31, 21, (outs g8rc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
512 "ldx $rD, $rA, $rB", IIC_LdStLD, []>, isPPC64;
513 def LBZXTLS_32 : XForm_1<31, 87, (outs gprc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
514 "lbzx $rD, $rA, $rB", IIC_LdStLoad, []>;
515 def LHZXTLS_32 : XForm_1<31, 279, (outs gprc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
516 "lhzx $rD, $rA, $rB", IIC_LdStLoad, []>;
517 def LWZXTLS_32 : XForm_1<31, 23, (outs gprc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
518 "lwzx $rD, $rA, $rB", IIC_LdStLoad, []>;
522 let mayStore = 1 in {
523 def STBXTLS : XForm_8<31, 215, (outs), (ins g8rc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
524 "stbx $rS, $rA, $rB", IIC_LdStStore, []>,
525 PPC970_DGroup_Cracked;
526 def STHXTLS : XForm_8<31, 407, (outs), (ins g8rc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
527 "sthx $rS, $rA, $rB", IIC_LdStStore, []>,
528 PPC970_DGroup_Cracked;
529 def STWXTLS : XForm_8<31, 151, (outs), (ins g8rc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
530 "stwx $rS, $rA, $rB", IIC_LdStStore, []>,
531 PPC970_DGroup_Cracked;
532 def STDXTLS : XForm_8<31, 149, (outs), (ins g8rc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
533 "stdx $rS, $rA, $rB", IIC_LdStSTD, []>, isPPC64,
534 PPC970_DGroup_Cracked;
535 def STBXTLS_32 : XForm_8<31, 215, (outs), (ins gprc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
536 "stbx $rS, $rA, $rB", IIC_LdStStore, []>,
537 PPC970_DGroup_Cracked;
538 def STHXTLS_32 : XForm_8<31, 407, (outs), (ins gprc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
539 "sthx $rS, $rA, $rB", IIC_LdStStore, []>,
540 PPC970_DGroup_Cracked;
541 def STWXTLS_32 : XForm_8<31, 151, (outs), (ins gprc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
542 "stwx $rS, $rA, $rB", IIC_LdStStore, []>,
543 PPC970_DGroup_Cracked;
547 let isCommutable = 1 in
548 defm ADDC8 : XOForm_1rc<31, 10, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
549 "addc", "$rT, $rA, $rB", IIC_IntGeneral,
550 [(set i64:$rT, (addc i64:$rA, i64:$rB))]>,
551 PPC970_DGroup_Cracked;
553 let Defs = [CARRY] in
554 def ADDIC8 : DForm_2<12, (outs g8rc:$rD), (ins g8rc:$rA, s16imm64:$imm),
555 "addic $rD, $rA, $imm", IIC_IntGeneral,
556 [(set i64:$rD, (addc i64:$rA, imm64SExt16:$imm))]>;
557 def ADDI8 : DForm_2<14, (outs g8rc:$rD), (ins g8rc_nox0:$rA, s16imm64:$imm),
558 "addi $rD, $rA, $imm", IIC_IntSimple,
559 [(set i64:$rD, (add i64:$rA, imm64SExt16:$imm))]>;
560 def ADDIS8 : DForm_2<15, (outs g8rc:$rD), (ins g8rc_nox0:$rA, s17imm64:$imm),
561 "addis $rD, $rA, $imm", IIC_IntSimple,
562 [(set i64:$rD, (add i64:$rA, imm16ShiftedSExt:$imm))]>;
564 let Defs = [CARRY] in {
565 def SUBFIC8: DForm_2< 8, (outs g8rc:$rD), (ins g8rc:$rA, s16imm64:$imm),
566 "subfic $rD, $rA, $imm", IIC_IntGeneral,
567 [(set i64:$rD, (subc imm64SExt16:$imm, i64:$rA))]>;
569 defm SUBFC8 : XOForm_1rc<31, 8, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
570 "subfc", "$rT, $rA, $rB", IIC_IntGeneral,
571 [(set i64:$rT, (subc i64:$rB, i64:$rA))]>,
572 PPC970_DGroup_Cracked;
573 defm SUBF8 : XOForm_1r<31, 40, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
574 "subf", "$rT, $rA, $rB", IIC_IntGeneral,
575 [(set i64:$rT, (sub i64:$rB, i64:$rA))]>;
576 defm NEG8 : XOForm_3r<31, 104, 0, (outs g8rc:$rT), (ins g8rc:$rA),
577 "neg", "$rT, $rA", IIC_IntSimple,
578 [(set i64:$rT, (ineg i64:$rA))]>;
579 let Uses = [CARRY] in {
580 let isCommutable = 1 in
581 defm ADDE8 : XOForm_1rc<31, 138, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
582 "adde", "$rT, $rA, $rB", IIC_IntGeneral,
583 [(set i64:$rT, (adde i64:$rA, i64:$rB))]>;
584 defm ADDME8 : XOForm_3rc<31, 234, 0, (outs g8rc:$rT), (ins g8rc:$rA),
585 "addme", "$rT, $rA", IIC_IntGeneral,
586 [(set i64:$rT, (adde i64:$rA, -1))]>;
587 defm ADDZE8 : XOForm_3rc<31, 202, 0, (outs g8rc:$rT), (ins g8rc:$rA),
588 "addze", "$rT, $rA", IIC_IntGeneral,
589 [(set i64:$rT, (adde i64:$rA, 0))]>;
590 defm SUBFE8 : XOForm_1rc<31, 136, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
591 "subfe", "$rT, $rA, $rB", IIC_IntGeneral,
592 [(set i64:$rT, (sube i64:$rB, i64:$rA))]>;
593 defm SUBFME8 : XOForm_3rc<31, 232, 0, (outs g8rc:$rT), (ins g8rc:$rA),
594 "subfme", "$rT, $rA", IIC_IntGeneral,
595 [(set i64:$rT, (sube -1, i64:$rA))]>;
596 defm SUBFZE8 : XOForm_3rc<31, 200, 0, (outs g8rc:$rT), (ins g8rc:$rA),
597 "subfze", "$rT, $rA", IIC_IntGeneral,
598 [(set i64:$rT, (sube 0, i64:$rA))]>;
602 // FIXME: Duplicating this for the asm parser should be unnecessary, but the
603 // previous definition must be marked as CodeGen only to prevent decoding
605 let isAsmParserOnly = 1 in {
606 def ADD8TLS_ : XOForm_1<31, 266, 0, (outs g8rc:$rT), (ins g8rc:$rA, tlsreg:$rB),
607 "add $rT, $rA, $rB", IIC_IntSimple, []>;
610 def LBZXTLS_ : XForm_1<31, 87, (outs g8rc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
611 "lbzx $rD, $rA, $rB", IIC_LdStLoad, []>;
612 def LHZXTLS_ : XForm_1<31, 279, (outs g8rc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
613 "lhzx $rD, $rA, $rB", IIC_LdStLoad, []>;
614 def LWZXTLS_ : XForm_1<31, 23, (outs g8rc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
615 "lwzx $rD, $rA, $rB", IIC_LdStLoad, []>;
616 def LDXTLS_ : XForm_1<31, 21, (outs g8rc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
617 "ldx $rD, $rA, $rB", IIC_LdStLD, []>, isPPC64;
620 let mayStore = 1 in {
621 def STBXTLS_ : XForm_8<31, 215, (outs), (ins g8rc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
622 "stbx $rS, $rA, $rB", IIC_LdStStore, []>,
623 PPC970_DGroup_Cracked;
624 def STHXTLS_ : XForm_8<31, 407, (outs), (ins g8rc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
625 "sthx $rS, $rA, $rB", IIC_LdStStore, []>,
626 PPC970_DGroup_Cracked;
627 def STWXTLS_ : XForm_8<31, 151, (outs), (ins g8rc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
628 "stwx $rS, $rA, $rB", IIC_LdStStore, []>,
629 PPC970_DGroup_Cracked;
630 def STDXTLS_ : XForm_8<31, 149, (outs), (ins g8rc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
631 "stdx $rS, $rA, $rB", IIC_LdStSTD, []>, isPPC64,
632 PPC970_DGroup_Cracked;
636 let isCommutable = 1 in {
637 defm MULHD : XOForm_1r<31, 73, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
638 "mulhd", "$rT, $rA, $rB", IIC_IntMulHW,
639 [(set i64:$rT, (mulhs i64:$rA, i64:$rB))]>;
640 defm MULHDU : XOForm_1r<31, 9, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
641 "mulhdu", "$rT, $rA, $rB", IIC_IntMulHWU,
642 [(set i64:$rT, (mulhu i64:$rA, i64:$rB))]>;
645 } // Interpretation64Bit
647 let isCompare = 1, hasSideEffects = 0 in {
648 def CMPD : XForm_16_ext<31, 0, (outs crrc:$crD), (ins g8rc:$rA, g8rc:$rB),
649 "cmpd $crD, $rA, $rB", IIC_IntCompare>, isPPC64;
650 def CMPLD : XForm_16_ext<31, 32, (outs crrc:$crD), (ins g8rc:$rA, g8rc:$rB),
651 "cmpld $crD, $rA, $rB", IIC_IntCompare>, isPPC64;
652 def CMPDI : DForm_5_ext<11, (outs crrc:$crD), (ins g8rc:$rA, s16imm64:$imm),
653 "cmpdi $crD, $rA, $imm", IIC_IntCompare>, isPPC64;
654 def CMPLDI : DForm_6_ext<10, (outs crrc:$dst), (ins g8rc:$src1, u16imm64:$src2),
655 "cmpldi $dst, $src1, $src2",
656 IIC_IntCompare>, isPPC64;
657 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
658 def CMPRB8 : X_BF3_L1_RS5_RS5<31, 192, (outs crbitrc:$BF),
659 (ins u1imm:$L, g8rc:$rA, g8rc:$rB),
660 "cmprb $BF, $L, $rA, $rB", IIC_IntCompare, []>,
661 Requires<[IsISA3_0]>;
662 def CMPEQB : X_BF3_RS5_RS5<31, 224, (outs crbitrc:$BF),
663 (ins g8rc:$rA, g8rc:$rB), "cmpeqb $BF, $rA, $rB",
664 IIC_IntCompare, []>, Requires<[IsISA3_0]>;
667 let hasSideEffects = 0 in {
668 defm SLD : XForm_6r<31, 27, (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB),
669 "sld", "$rA, $rS, $rB", IIC_IntRotateD,
670 [(set i64:$rA, (PPCshl i64:$rS, i32:$rB))]>, isPPC64;
671 defm SRD : XForm_6r<31, 539, (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB),
672 "srd", "$rA, $rS, $rB", IIC_IntRotateD,
673 [(set i64:$rA, (PPCsrl i64:$rS, i32:$rB))]>, isPPC64;
674 defm SRAD : XForm_6rc<31, 794, (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB),
675 "srad", "$rA, $rS, $rB", IIC_IntRotateD,
676 [(set i64:$rA, (PPCsra i64:$rS, i32:$rB))]>, isPPC64;
678 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
679 defm CNTLZW8 : XForm_11r<31, 26, (outs g8rc:$rA), (ins g8rc:$rS),
680 "cntlzw", "$rA, $rS", IIC_IntGeneral, []>;
681 defm CNTTZW8 : XForm_11r<31, 538, (outs g8rc:$rA), (ins g8rc:$rS),
682 "cnttzw", "$rA, $rS", IIC_IntGeneral, []>,
683 Requires<[IsISA3_0]>;
685 defm EXTSB8 : XForm_11r<31, 954, (outs g8rc:$rA), (ins g8rc:$rS),
686 "extsb", "$rA, $rS", IIC_IntSimple,
687 [(set i64:$rA, (sext_inreg i64:$rS, i8))]>;
688 defm EXTSH8 : XForm_11r<31, 922, (outs g8rc:$rA), (ins g8rc:$rS),
689 "extsh", "$rA, $rS", IIC_IntSimple,
690 [(set i64:$rA, (sext_inreg i64:$rS, i16))]>;
692 defm SLW8 : XForm_6r<31, 24, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
693 "slw", "$rA, $rS, $rB", IIC_IntGeneral, []>;
694 defm SRW8 : XForm_6r<31, 536, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
695 "srw", "$rA, $rS, $rB", IIC_IntGeneral, []>;
696 } // Interpretation64Bit
699 let isCodeGenOnly = 1 in {
700 def EXTSB8_32_64 : XForm_11<31, 954, (outs g8rc:$rA), (ins gprc:$rS),
701 "extsb $rA, $rS", IIC_IntSimple, []>, isPPC64;
702 def EXTSH8_32_64 : XForm_11<31, 922, (outs g8rc:$rA), (ins gprc:$rS),
703 "extsh $rA, $rS", IIC_IntSimple, []>, isPPC64;
704 } // isCodeGenOnly for fast-isel
706 defm EXTSW : XForm_11r<31, 986, (outs g8rc:$rA), (ins g8rc:$rS),
707 "extsw", "$rA, $rS", IIC_IntSimple,
708 [(set i64:$rA, (sext_inreg i64:$rS, i32))]>, isPPC64;
709 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
710 defm EXTSW_32_64 : XForm_11r<31, 986, (outs g8rc:$rA), (ins gprc:$rS),
711 "extsw", "$rA, $rS", IIC_IntSimple,
712 [(set i64:$rA, (sext i32:$rS))]>, isPPC64;
713 let isCodeGenOnly = 1 in
714 def EXTSW_32 : XForm_11<31, 986, (outs gprc:$rA), (ins gprc:$rS),
715 "extsw $rA, $rS", IIC_IntSimple,
718 defm SRADI : XSForm_1rc<31, 413, (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH),
719 "sradi", "$rA, $rS, $SH", IIC_IntRotateDI,
720 [(set i64:$rA, (sra i64:$rS, (i32 imm:$SH)))]>, isPPC64;
722 defm EXTSWSLI : XSForm_1r<31, 445, (outs g8rc:$rA), (ins gprc:$rS, u6imm:$SH),
723 "extswsli", "$rA, $rS, $SH", IIC_IntRotateDI,
724 [(set i64:$rA, (PPCextswsli i32:$rS, (i32 imm:$SH)))]>,
725 isPPC64, Requires<[IsISA3_0]>;
728 let isCodeGenOnly = 1, Defs = [CARRY] in
729 def SRADI_32 : XSForm_1<31, 413, (outs gprc:$rA), (ins gprc:$rS, u6imm:$SH),
730 "sradi $rA, $rS, $SH", IIC_IntRotateDI, []>, isPPC64;
732 defm CNTLZD : XForm_11r<31, 58, (outs g8rc:$rA), (ins g8rc:$rS),
733 "cntlzd", "$rA, $rS", IIC_IntGeneral,
734 [(set i64:$rA, (ctlz i64:$rS))]>;
735 defm CNTTZD : XForm_11r<31, 570, (outs g8rc:$rA), (ins g8rc:$rS),
736 "cnttzd", "$rA, $rS", IIC_IntGeneral,
737 [(set i64:$rA, (cttz i64:$rS))]>, Requires<[IsISA3_0]>;
738 def POPCNTD : XForm_11<31, 506, (outs g8rc:$rA), (ins g8rc:$rS),
739 "popcntd $rA, $rS", IIC_IntGeneral,
740 [(set i64:$rA, (ctpop i64:$rS))]>;
741 def BPERMD : XForm_6<31, 252, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
742 "bpermd $rA, $rS, $rB", IIC_IntGeneral,
743 [(set i64:$rA, (int_ppc_bpermd g8rc:$rS, g8rc:$rB))]>,
744 isPPC64, Requires<[HasBPERMD]>;
746 let isCodeGenOnly = 1, isCommutable = 1 in
747 def CMPB8 : XForm_6<31, 508, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
748 "cmpb $rA, $rS, $rB", IIC_IntGeneral,
749 [(set i64:$rA, (PPCcmpb i64:$rS, i64:$rB))]>;
751 // popcntw also does a population count on the high 32 bits (storing the
752 // results in the high 32-bits of the output). We'll ignore that here (which is
753 // safe because we never separately use the high part of the 64-bit registers).
754 def POPCNTW : XForm_11<31, 378, (outs gprc:$rA), (ins gprc:$rS),
755 "popcntw $rA, $rS", IIC_IntGeneral,
756 [(set i32:$rA, (ctpop i32:$rS))]>;
758 def POPCNTB : XForm_11<31, 122, (outs gprc:$rA), (ins gprc:$rS),
759 "popcntb $rA, $rS", IIC_IntGeneral, []>;
761 defm DIVD : XOForm_1rcr<31, 489, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
762 "divd", "$rT, $rA, $rB", IIC_IntDivD,
763 [(set i64:$rT, (sdiv i64:$rA, i64:$rB))]>, isPPC64;
764 defm DIVDU : XOForm_1rcr<31, 457, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
765 "divdu", "$rT, $rA, $rB", IIC_IntDivD,
766 [(set i64:$rT, (udiv i64:$rA, i64:$rB))]>, isPPC64;
767 def DIVDE : XOForm_1<31, 425, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
768 "divde $rT, $rA, $rB", IIC_IntDivD,
769 [(set i64:$rT, (int_ppc_divde g8rc:$rA, g8rc:$rB))]>,
770 isPPC64, Requires<[HasExtDiv]>;
772 let Predicates = [IsISA3_0] in {
773 def MADDHD : VAForm_1a<48, (outs g8rc :$RT), (ins g8rc:$RA, g8rc:$RB, g8rc:$RC),
774 "maddhd $RT, $RA, $RB, $RC", IIC_IntMulHD, []>, isPPC64;
775 def MADDHDU : VAForm_1a<49, (outs g8rc :$RT), (ins g8rc:$RA, g8rc:$RB, g8rc:$RC),
776 "maddhdu $RT, $RA, $RB, $RC", IIC_IntMulHD, []>, isPPC64;
777 def MADDLD : VAForm_1a<51, (outs g8rc :$RT), (ins g8rc:$RA, g8rc:$RB, g8rc:$RC),
778 "maddld $RT, $RA, $RB, $RC", IIC_IntMulHD, []>, isPPC64;
779 def SETB : XForm_44<31, 128, (outs gprc:$RT), (ins crrc:$BFA),
780 "setb $RT, $BFA", IIC_IntGeneral>, isPPC64;
781 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
782 def SETB8 : XForm_44<31, 128, (outs g8rc:$RT), (ins crrc:$BFA),
783 "setb $RT, $BFA", IIC_IntGeneral>, isPPC64;
785 def DARN : XForm_45<31, 755, (outs g8rc:$RT), (ins i32imm:$L),
786 "darn $RT, $L", IIC_LdStLD>, isPPC64;
787 def ADDPCIS : DXForm<19, 2, (outs g8rc:$RT), (ins i32imm:$D),
788 "addpcis $RT, $D", IIC_BrB, []>, isPPC64;
789 def MODSD : XForm_8<31, 777, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
790 "modsd $rT, $rA, $rB", IIC_IntDivW,
791 [(set i64:$rT, (srem i64:$rA, i64:$rB))]>;
792 def MODUD : XForm_8<31, 265, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
793 "modud $rT, $rA, $rB", IIC_IntDivW,
794 [(set i64:$rT, (urem i64:$rA, i64:$rB))]>;
798 def DIVDEo : XOForm_1<31, 425, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
799 "divde. $rT, $rA, $rB", IIC_IntDivD,
800 []>, isDOT, PPC970_DGroup_Cracked, PPC970_DGroup_First,
801 isPPC64, Requires<[HasExtDiv]>;
802 def DIVDEU : XOForm_1<31, 393, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
803 "divdeu $rT, $rA, $rB", IIC_IntDivD,
804 [(set i64:$rT, (int_ppc_divdeu g8rc:$rA, g8rc:$rB))]>,
805 isPPC64, Requires<[HasExtDiv]>;
807 def DIVDEUo : XOForm_1<31, 393, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
808 "divdeu. $rT, $rA, $rB", IIC_IntDivD,
809 []>, isDOT, PPC970_DGroup_Cracked, PPC970_DGroup_First,
810 isPPC64, Requires<[HasExtDiv]>;
811 let isCommutable = 1 in
812 defm MULLD : XOForm_1r<31, 233, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
813 "mulld", "$rT, $rA, $rB", IIC_IntMulHD,
814 [(set i64:$rT, (mul i64:$rA, i64:$rB))]>, isPPC64;
815 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
816 def MULLI8 : DForm_2<7, (outs g8rc:$rD), (ins g8rc:$rA, s16imm64:$imm),
817 "mulli $rD, $rA, $imm", IIC_IntMulLI,
818 [(set i64:$rD, (mul i64:$rA, imm64SExt16:$imm))]>;
821 let hasSideEffects = 0 in {
822 defm RLDIMI : MDForm_1r<30, 3, (outs g8rc:$rA),
823 (ins g8rc:$rSi, g8rc:$rS, u6imm:$SH, u6imm:$MBE),
824 "rldimi", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
825 []>, isPPC64, RegConstraint<"$rSi = $rA">,
828 // Rotate instructions.
829 defm RLDCL : MDSForm_1r<30, 8,
830 (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB, u6imm:$MBE),
831 "rldcl", "$rA, $rS, $rB, $MBE", IIC_IntRotateD,
833 defm RLDCR : MDSForm_1r<30, 9,
834 (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB, u6imm:$MBE),
835 "rldcr", "$rA, $rS, $rB, $MBE", IIC_IntRotateD,
837 defm RLDICL : MDForm_1r<30, 0,
838 (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH, u6imm:$MBE),
839 "rldicl", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
842 let isCodeGenOnly = 1 in
843 def RLDICL_32_64 : MDForm_1<30, 0,
845 (ins gprc:$rS, u6imm:$SH, u6imm:$MBE),
846 "rldicl $rA, $rS, $SH, $MBE", IIC_IntRotateDI,
849 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
850 defm RLDICL_32 : MDForm_1r<30, 0,
852 (ins gprc:$rS, u6imm:$SH, u6imm:$MBE),
853 "rldicl", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
855 defm RLDICR : MDForm_1r<30, 1,
856 (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH, u6imm:$MBE),
857 "rldicr", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
859 let isCodeGenOnly = 1 in
860 def RLDICR_32 : MDForm_1<30, 1,
861 (outs gprc:$rA), (ins gprc:$rS, u6imm:$SH, u6imm:$MBE),
862 "rldicr $rA, $rS, $SH, $MBE", IIC_IntRotateDI,
864 defm RLDIC : MDForm_1r<30, 2,
865 (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH, u6imm:$MBE),
866 "rldic", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
869 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
870 defm RLWINM8 : MForm_2r<21, (outs g8rc:$rA),
871 (ins g8rc:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
872 "rlwinm", "$rA, $rS, $SH, $MB, $ME", IIC_IntGeneral,
875 defm RLWNM8 : MForm_2r<23, (outs g8rc:$rA),
876 (ins g8rc:$rS, g8rc:$rB, u5imm:$MB, u5imm:$ME),
877 "rlwnm", "$rA, $rS, $rB, $MB, $ME", IIC_IntGeneral,
880 // RLWIMI can be commuted if the rotate amount is zero.
881 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
882 defm RLWIMI8 : MForm_2r<20, (outs g8rc:$rA),
883 (ins g8rc:$rSi, g8rc:$rS, u5imm:$SH, u5imm:$MB,
884 u5imm:$ME), "rlwimi", "$rA, $rS, $SH, $MB, $ME",
885 IIC_IntRotate, []>, PPC970_DGroup_Cracked,
886 RegConstraint<"$rSi = $rA">, NoEncode<"$rSi">;
889 def ISEL8 : AForm_4<31, 15,
890 (outs g8rc:$rT), (ins g8rc_nox0:$rA, g8rc:$rB, crbitrc:$cond),
891 "isel $rT, $rA, $rB, $cond", IIC_IntISEL,
893 } // Interpretation64Bit
894 } // hasSideEffects = 0
895 } // End FXU Operations.
898 //===----------------------------------------------------------------------===//
899 // Load/Store instructions.
903 // Sign extending loads.
904 let PPC970_Unit = 2 in {
905 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
906 def LHA8: DForm_1<42, (outs g8rc:$rD), (ins memri:$src),
907 "lha $rD, $src", IIC_LdStLHA,
908 [(set i64:$rD, (sextloadi16 iaddr:$src))]>,
909 PPC970_DGroup_Cracked;
910 def LWA : DSForm_1<58, 2, (outs g8rc:$rD), (ins memrix:$src),
911 "lwa $rD, $src", IIC_LdStLWA,
913 (aligned4sextloadi32 ixaddr:$src))]>, isPPC64,
914 PPC970_DGroup_Cracked;
915 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
916 def LHAX8: XForm_1_memOp<31, 343, (outs g8rc:$rD), (ins memrr:$src),
917 "lhax $rD, $src", IIC_LdStLHA,
918 [(set i64:$rD, (sextloadi16 xaddr:$src))]>,
919 PPC970_DGroup_Cracked;
920 def LWAX : XForm_1_memOp<31, 341, (outs g8rc:$rD), (ins memrr:$src),
921 "lwax $rD, $src", IIC_LdStLHA,
922 [(set i64:$rD, (sextloadi32 xaddr:$src))]>, isPPC64,
923 PPC970_DGroup_Cracked;
925 let isCodeGenOnly = 1, mayLoad = 1 in {
926 def LWA_32 : DSForm_1<58, 2, (outs gprc:$rD), (ins memrix:$src),
927 "lwa $rD, $src", IIC_LdStLWA, []>, isPPC64,
928 PPC970_DGroup_Cracked;
929 def LWAX_32 : XForm_1_memOp<31, 341, (outs gprc:$rD), (ins memrr:$src),
930 "lwax $rD, $src", IIC_LdStLHA, []>, isPPC64,
931 PPC970_DGroup_Cracked;
932 } // end fast-isel isCodeGenOnly
935 let mayLoad = 1, hasSideEffects = 0 in {
936 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
937 def LHAU8 : DForm_1<43, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
939 "lhau $rD, $addr", IIC_LdStLHAU,
940 []>, RegConstraint<"$addr.reg = $ea_result">,
941 NoEncode<"$ea_result">;
944 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
945 def LHAUX8 : XForm_1_memOp<31, 375, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
947 "lhaux $rD, $addr", IIC_LdStLHAUX,
948 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
949 NoEncode<"$ea_result">;
950 def LWAUX : XForm_1_memOp<31, 373, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
952 "lwaux $rD, $addr", IIC_LdStLHAUX,
953 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
954 NoEncode<"$ea_result">, isPPC64;
958 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
959 // Zero extending loads.
960 let PPC970_Unit = 2 in {
961 def LBZ8 : DForm_1<34, (outs g8rc:$rD), (ins memri:$src),
962 "lbz $rD, $src", IIC_LdStLoad,
963 [(set i64:$rD, (zextloadi8 iaddr:$src))]>;
964 def LHZ8 : DForm_1<40, (outs g8rc:$rD), (ins memri:$src),
965 "lhz $rD, $src", IIC_LdStLoad,
966 [(set i64:$rD, (zextloadi16 iaddr:$src))]>;
967 def LWZ8 : DForm_1<32, (outs g8rc:$rD), (ins memri:$src),
968 "lwz $rD, $src", IIC_LdStLoad,
969 [(set i64:$rD, (zextloadi32 iaddr:$src))]>, isPPC64;
971 def LBZX8 : XForm_1_memOp<31, 87, (outs g8rc:$rD), (ins memrr:$src),
972 "lbzx $rD, $src", IIC_LdStLoad,
973 [(set i64:$rD, (zextloadi8 xaddr:$src))]>;
974 def LHZX8 : XForm_1_memOp<31, 279, (outs g8rc:$rD), (ins memrr:$src),
975 "lhzx $rD, $src", IIC_LdStLoad,
976 [(set i64:$rD, (zextloadi16 xaddr:$src))]>;
977 def LWZX8 : XForm_1_memOp<31, 23, (outs g8rc:$rD), (ins memrr:$src),
978 "lwzx $rD, $src", IIC_LdStLoad,
979 [(set i64:$rD, (zextloadi32 xaddr:$src))]>;
983 let mayLoad = 1, hasSideEffects = 0 in {
984 def LBZU8 : DForm_1<35, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
986 "lbzu $rD, $addr", IIC_LdStLoadUpd,
987 []>, RegConstraint<"$addr.reg = $ea_result">,
988 NoEncode<"$ea_result">;
989 def LHZU8 : DForm_1<41, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
991 "lhzu $rD, $addr", IIC_LdStLoadUpd,
992 []>, RegConstraint<"$addr.reg = $ea_result">,
993 NoEncode<"$ea_result">;
994 def LWZU8 : DForm_1<33, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
996 "lwzu $rD, $addr", IIC_LdStLoadUpd,
997 []>, RegConstraint<"$addr.reg = $ea_result">,
998 NoEncode<"$ea_result">;
1000 def LBZUX8 : XForm_1_memOp<31, 119, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
1002 "lbzux $rD, $addr", IIC_LdStLoadUpdX,
1003 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1004 NoEncode<"$ea_result">;
1005 def LHZUX8 : XForm_1_memOp<31, 311, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
1007 "lhzux $rD, $addr", IIC_LdStLoadUpdX,
1008 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1009 NoEncode<"$ea_result">;
1010 def LWZUX8 : XForm_1_memOp<31, 55, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
1012 "lwzux $rD, $addr", IIC_LdStLoadUpdX,
1013 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1014 NoEncode<"$ea_result">;
1017 } // Interpretation64Bit
1020 // Full 8-byte loads.
1021 let PPC970_Unit = 2 in {
1022 def LD : DSForm_1<58, 0, (outs g8rc:$rD), (ins memrix:$src),
1023 "ld $rD, $src", IIC_LdStLD,
1024 [(set i64:$rD, (aligned4load ixaddr:$src))]>, isPPC64;
1025 // The following four definitions are selected for small code model only.
1026 // Otherwise, we need to create two instructions to form a 32-bit offset,
1027 // so we have a custom matcher for TOC_ENTRY in PPCDAGToDAGIsel::Select().
1028 def LDtoc: PPCEmitTimePseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
1031 (PPCtoc_entry tglobaladdr:$disp, i64:$reg))]>, isPPC64;
1032 def LDtocJTI: PPCEmitTimePseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
1035 (PPCtoc_entry tjumptable:$disp, i64:$reg))]>, isPPC64;
1036 def LDtocCPT: PPCEmitTimePseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
1039 (PPCtoc_entry tconstpool:$disp, i64:$reg))]>, isPPC64;
1040 def LDtocBA: PPCEmitTimePseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
1043 (PPCtoc_entry tblockaddress:$disp, i64:$reg))]>, isPPC64;
1045 def LDX : XForm_1_memOp<31, 21, (outs g8rc:$rD), (ins memrr:$src),
1046 "ldx $rD, $src", IIC_LdStLD,
1047 [(set i64:$rD, (load xaddr:$src))]>, isPPC64;
1048 def LDBRX : XForm_1_memOp<31, 532, (outs g8rc:$rD), (ins memrr:$src),
1049 "ldbrx $rD, $src", IIC_LdStLoad,
1050 [(set i64:$rD, (PPClbrx xoaddr:$src, i64))]>, isPPC64;
1052 let mayLoad = 1, hasSideEffects = 0, isCodeGenOnly = 1 in {
1053 def LHBRX8 : XForm_1_memOp<31, 790, (outs g8rc:$rD), (ins memrr:$src),
1054 "lhbrx $rD, $src", IIC_LdStLoad, []>;
1055 def LWBRX8 : XForm_1_memOp<31, 534, (outs g8rc:$rD), (ins memrr:$src),
1056 "lwbrx $rD, $src", IIC_LdStLoad, []>;
1059 let mayLoad = 1, hasSideEffects = 0 in {
1060 def LDU : DSForm_1<58, 1, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
1062 "ldu $rD, $addr", IIC_LdStLDU,
1063 []>, RegConstraint<"$addr.reg = $ea_result">, isPPC64,
1064 NoEncode<"$ea_result">;
1066 def LDUX : XForm_1_memOp<31, 53, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
1068 "ldux $rD, $addr", IIC_LdStLDUX,
1069 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1070 NoEncode<"$ea_result">, isPPC64;
1072 def LDMX : XForm_1<31, 309, (outs g8rc:$rD), (ins memrr:$src),
1073 "ldmx $rD, $src", IIC_LdStLD, []>, isPPC64,
1074 Requires<[IsISA3_0]>;
1078 // Support for medium and large code model.
1079 let hasSideEffects = 0 in {
1080 let isReMaterializable = 1 in {
1081 def ADDIStocHA: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, tocentry:$disp),
1082 "#ADDIStocHA", []>, isPPC64;
1083 def ADDItocL: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, tocentry:$disp),
1084 "#ADDItocL", []>, isPPC64;
1087 def LDtocL: PPCEmitTimePseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc_nox0:$reg),
1088 "#LDtocL", []>, isPPC64;
1091 // Support for thread-local storage.
1092 def ADDISgotTprelHA: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
1095 (PPCaddisGotTprelHA i64:$reg,
1096 tglobaltlsaddr:$disp))]>,
1098 def LDgotTprelL: PPCEmitTimePseudo<(outs g8rc:$rD), (ins s16imm64:$disp, g8rc_nox0:$reg),
1101 (PPCldGotTprelL tglobaltlsaddr:$disp, i64:$reg))]>,
1104 let Defs = [CR7], Itinerary = IIC_LdStSync in
1105 def CFENCE8 : PPCPostRAExpPseudo<(outs), (ins g8rc:$cr), "#CFENCE8", []>;
1107 def : Pat<(PPCaddTls i64:$in, tglobaltlsaddr:$g),
1108 (ADD8TLS $in, tglobaltlsaddr:$g)>;
1109 def ADDIStlsgdHA: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
1112 (PPCaddisTlsgdHA i64:$reg, tglobaltlsaddr:$disp))]>,
1114 def ADDItlsgdL : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
1117 (PPCaddiTlsgdL i64:$reg, tglobaltlsaddr:$disp))]>,
1119 // LR8 is a true define, while the rest of the Defs are clobbers. X3 is
1120 // explicitly defined when this op is created, so not mentioned here.
1121 // This is lowered to BL8_NOP_TLS by the assembly printer, so the size must be
1122 // correct because the branch select pass is relying on it.
1123 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1, Size = 8,
1124 Defs = [X0,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7] in
1125 def GETtlsADDR : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc:$reg, tlsgd:$sym),
1128 (PPCgetTlsAddr i64:$reg, tglobaltlsaddr:$sym))]>,
1130 // Combined op for ADDItlsgdL and GETtlsADDR, late expanded. X3 and LR8
1131 // are true defines while the rest of the Defs are clobbers.
1132 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
1133 Defs = [X0,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7]
1135 def ADDItlsgdLADDR : PPCEmitTimePseudo<(outs g8rc:$rD),
1136 (ins g8rc_nox0:$reg, s16imm64:$disp, tlsgd:$sym),
1139 (PPCaddiTlsgdLAddr i64:$reg,
1140 tglobaltlsaddr:$disp,
1141 tglobaltlsaddr:$sym))]>,
1143 def ADDIStlsldHA: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
1146 (PPCaddisTlsldHA i64:$reg, tglobaltlsaddr:$disp))]>,
1148 def ADDItlsldL : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
1151 (PPCaddiTlsldL i64:$reg, tglobaltlsaddr:$disp))]>,
1153 // LR8 is a true define, while the rest of the Defs are clobbers. X3 is
1154 // explicitly defined when this op is created, so not mentioned here.
1155 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
1156 Defs = [X0,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7] in
1157 def GETtlsldADDR : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc:$reg, tlsgd:$sym),
1160 (PPCgetTlsldAddr i64:$reg, tglobaltlsaddr:$sym))]>,
1162 // Combined op for ADDItlsldL and GETtlsADDR, late expanded. X3 and LR8
1163 // are true defines, while the rest of the Defs are clobbers.
1164 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
1165 Defs = [X0,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7]
1167 def ADDItlsldLADDR : PPCEmitTimePseudo<(outs g8rc:$rD),
1168 (ins g8rc_nox0:$reg, s16imm64:$disp, tlsgd:$sym),
1171 (PPCaddiTlsldLAddr i64:$reg,
1172 tglobaltlsaddr:$disp,
1173 tglobaltlsaddr:$sym))]>,
1175 def ADDISdtprelHA: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
1178 (PPCaddisDtprelHA i64:$reg,
1179 tglobaltlsaddr:$disp))]>,
1181 def ADDIdtprelL : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
1184 (PPCaddiDtprelL i64:$reg, tglobaltlsaddr:$disp))]>,
1187 let PPC970_Unit = 2 in {
1188 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
1189 // Truncating stores.
1190 def STB8 : DForm_1<38, (outs), (ins g8rc:$rS, memri:$src),
1191 "stb $rS, $src", IIC_LdStStore,
1192 [(truncstorei8 i64:$rS, iaddr:$src)]>;
1193 def STH8 : DForm_1<44, (outs), (ins g8rc:$rS, memri:$src),
1194 "sth $rS, $src", IIC_LdStStore,
1195 [(truncstorei16 i64:$rS, iaddr:$src)]>;
1196 def STW8 : DForm_1<36, (outs), (ins g8rc:$rS, memri:$src),
1197 "stw $rS, $src", IIC_LdStStore,
1198 [(truncstorei32 i64:$rS, iaddr:$src)]>;
1199 def STBX8 : XForm_8_memOp<31, 215, (outs), (ins g8rc:$rS, memrr:$dst),
1200 "stbx $rS, $dst", IIC_LdStStore,
1201 [(truncstorei8 i64:$rS, xaddr:$dst)]>,
1202 PPC970_DGroup_Cracked;
1203 def STHX8 : XForm_8_memOp<31, 407, (outs), (ins g8rc:$rS, memrr:$dst),
1204 "sthx $rS, $dst", IIC_LdStStore,
1205 [(truncstorei16 i64:$rS, xaddr:$dst)]>,
1206 PPC970_DGroup_Cracked;
1207 def STWX8 : XForm_8_memOp<31, 151, (outs), (ins g8rc:$rS, memrr:$dst),
1208 "stwx $rS, $dst", IIC_LdStStore,
1209 [(truncstorei32 i64:$rS, xaddr:$dst)]>,
1210 PPC970_DGroup_Cracked;
1211 } // Interpretation64Bit
1213 // Normal 8-byte stores.
1214 def STD : DSForm_1<62, 0, (outs), (ins g8rc:$rS, memrix:$dst),
1215 "std $rS, $dst", IIC_LdStSTD,
1216 [(aligned4store i64:$rS, ixaddr:$dst)]>, isPPC64;
1217 def STDX : XForm_8_memOp<31, 149, (outs), (ins g8rc:$rS, memrr:$dst),
1218 "stdx $rS, $dst", IIC_LdStSTD,
1219 [(store i64:$rS, xaddr:$dst)]>, isPPC64,
1220 PPC970_DGroup_Cracked;
1221 def STDBRX: XForm_8_memOp<31, 660, (outs), (ins g8rc:$rS, memrr:$dst),
1222 "stdbrx $rS, $dst", IIC_LdStStore,
1223 [(PPCstbrx i64:$rS, xoaddr:$dst, i64)]>, isPPC64,
1224 PPC970_DGroup_Cracked;
1227 // Stores with Update (pre-inc).
1228 let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in {
1229 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
1230 def STBU8 : DForm_1<39, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memri:$dst),
1231 "stbu $rS, $dst", IIC_LdStSTU, []>,
1232 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
1233 def STHU8 : DForm_1<45, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memri:$dst),
1234 "sthu $rS, $dst", IIC_LdStSTU, []>,
1235 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
1236 def STWU8 : DForm_1<37, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memri:$dst),
1237 "stwu $rS, $dst", IIC_LdStSTU, []>,
1238 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
1240 def STBUX8: XForm_8_memOp<31, 247, (outs ptr_rc_nor0:$ea_res),
1241 (ins g8rc:$rS, memrr:$dst),
1242 "stbux $rS, $dst", IIC_LdStSTUX, []>,
1243 RegConstraint<"$dst.ptrreg = $ea_res">,
1244 NoEncode<"$ea_res">,
1245 PPC970_DGroup_Cracked;
1246 def STHUX8: XForm_8_memOp<31, 439, (outs ptr_rc_nor0:$ea_res),
1247 (ins g8rc:$rS, memrr:$dst),
1248 "sthux $rS, $dst", IIC_LdStSTUX, []>,
1249 RegConstraint<"$dst.ptrreg = $ea_res">,
1250 NoEncode<"$ea_res">,
1251 PPC970_DGroup_Cracked;
1252 def STWUX8: XForm_8_memOp<31, 183, (outs ptr_rc_nor0:$ea_res),
1253 (ins g8rc:$rS, memrr:$dst),
1254 "stwux $rS, $dst", IIC_LdStSTUX, []>,
1255 RegConstraint<"$dst.ptrreg = $ea_res">,
1256 NoEncode<"$ea_res">,
1257 PPC970_DGroup_Cracked;
1258 } // Interpretation64Bit
1260 def STDU : DSForm_1<62, 1, (outs ptr_rc_nor0:$ea_res),
1261 (ins g8rc:$rS, memrix:$dst),
1262 "stdu $rS, $dst", IIC_LdStSTU, []>,
1263 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">,
1266 def STDUX : XForm_8_memOp<31, 181, (outs ptr_rc_nor0:$ea_res),
1267 (ins g8rc:$rS, memrr:$dst),
1268 "stdux $rS, $dst", IIC_LdStSTUX, []>,
1269 RegConstraint<"$dst.ptrreg = $ea_res">,
1270 NoEncode<"$ea_res">,
1271 PPC970_DGroup_Cracked, isPPC64;
1274 // Patterns to match the pre-inc stores. We can't put the patterns on
1275 // the instruction definitions directly as ISel wants the address base
1276 // and offset to be separate operands, not a single complex operand.
1277 def : Pat<(pre_truncsti8 i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1278 (STBU8 $rS, iaddroff:$ptroff, $ptrreg)>;
1279 def : Pat<(pre_truncsti16 i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1280 (STHU8 $rS, iaddroff:$ptroff, $ptrreg)>;
1281 def : Pat<(pre_truncsti32 i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1282 (STWU8 $rS, iaddroff:$ptroff, $ptrreg)>;
1283 def : Pat<(aligned4pre_store i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1284 (STDU $rS, iaddroff:$ptroff, $ptrreg)>;
1286 def : Pat<(pre_truncsti8 i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1287 (STBUX8 $rS, $ptrreg, $ptroff)>;
1288 def : Pat<(pre_truncsti16 i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1289 (STHUX8 $rS, $ptrreg, $ptroff)>;
1290 def : Pat<(pre_truncsti32 i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1291 (STWUX8 $rS, $ptrreg, $ptroff)>;
1292 def : Pat<(pre_store i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1293 (STDUX $rS, $ptrreg, $ptroff)>;
1296 //===----------------------------------------------------------------------===//
1297 // Floating point instructions.
1301 let PPC970_Unit = 3, hasSideEffects = 0,
1302 Uses = [RM] in { // FPU Operations.
1303 defm FCFID : XForm_26r<63, 846, (outs f8rc:$frD), (ins f8rc:$frB),
1304 "fcfid", "$frD, $frB", IIC_FPGeneral,
1305 [(set f64:$frD, (PPCfcfid f64:$frB))]>, isPPC64;
1306 defm FCTID : XForm_26r<63, 814, (outs f8rc:$frD), (ins f8rc:$frB),
1307 "fctid", "$frD, $frB", IIC_FPGeneral,
1309 defm FCTIDU : XForm_26r<63, 942, (outs f8rc:$frD), (ins f8rc:$frB),
1310 "fctidu", "$frD, $frB", IIC_FPGeneral,
1312 defm FCTIDZ : XForm_26r<63, 815, (outs f8rc:$frD), (ins f8rc:$frB),
1313 "fctidz", "$frD, $frB", IIC_FPGeneral,
1314 [(set f64:$frD, (PPCfctidz f64:$frB))]>, isPPC64;
1316 defm FCFIDU : XForm_26r<63, 974, (outs f8rc:$frD), (ins f8rc:$frB),
1317 "fcfidu", "$frD, $frB", IIC_FPGeneral,
1318 [(set f64:$frD, (PPCfcfidu f64:$frB))]>, isPPC64;
1319 defm FCFIDS : XForm_26r<59, 846, (outs f4rc:$frD), (ins f8rc:$frB),
1320 "fcfids", "$frD, $frB", IIC_FPGeneral,
1321 [(set f32:$frD, (PPCfcfids f64:$frB))]>, isPPC64;
1322 defm FCFIDUS : XForm_26r<59, 974, (outs f4rc:$frD), (ins f8rc:$frB),
1323 "fcfidus", "$frD, $frB", IIC_FPGeneral,
1324 [(set f32:$frD, (PPCfcfidus f64:$frB))]>, isPPC64;
1325 defm FCTIDUZ : XForm_26r<63, 943, (outs f8rc:$frD), (ins f8rc:$frB),
1326 "fctiduz", "$frD, $frB", IIC_FPGeneral,
1327 [(set f64:$frD, (PPCfctiduz f64:$frB))]>, isPPC64;
1328 defm FCTIWUZ : XForm_26r<63, 143, (outs f8rc:$frD), (ins f8rc:$frB),
1329 "fctiwuz", "$frD, $frB", IIC_FPGeneral,
1330 [(set f64:$frD, (PPCfctiwuz f64:$frB))]>, isPPC64;
1334 //===----------------------------------------------------------------------===//
1335 // Instruction Patterns
1338 // Extensions and truncates to/from 32-bit regs.
1339 def : Pat<(i64 (zext i32:$in)),
1340 (RLDICL (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $in, sub_32),
1342 def : Pat<(i64 (anyext i32:$in)),
1343 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $in, sub_32)>;
1344 def : Pat<(i32 (trunc i64:$in)),
1345 (EXTRACT_SUBREG $in, sub_32)>;
1347 // Implement the 'not' operation with the NOR instruction.
1348 // (we could use the default xori pattern, but nor has lower latency on some
1349 // cores (such as the A2)).
1350 def i64not : OutPatFrag<(ops node:$in),
1352 def : Pat<(not i64:$in),
1355 // Extending loads with i64 targets.
1356 def : Pat<(zextloadi1 iaddr:$src),
1358 def : Pat<(zextloadi1 xaddr:$src),
1359 (LBZX8 xaddr:$src)>;
1360 def : Pat<(extloadi1 iaddr:$src),
1362 def : Pat<(extloadi1 xaddr:$src),
1363 (LBZX8 xaddr:$src)>;
1364 def : Pat<(extloadi8 iaddr:$src),
1366 def : Pat<(extloadi8 xaddr:$src),
1367 (LBZX8 xaddr:$src)>;
1368 def : Pat<(extloadi16 iaddr:$src),
1370 def : Pat<(extloadi16 xaddr:$src),
1371 (LHZX8 xaddr:$src)>;
1372 def : Pat<(extloadi32 iaddr:$src),
1374 def : Pat<(extloadi32 xaddr:$src),
1375 (LWZX8 xaddr:$src)>;
1377 // Standard shifts. These are represented separately from the real shifts above
1378 // so that we can distinguish between shifts that allow 6-bit and 7-bit shift
1380 def : Pat<(sra i64:$rS, i32:$rB),
1382 def : Pat<(srl i64:$rS, i32:$rB),
1384 def : Pat<(shl i64:$rS, i32:$rB),
1388 def : Pat<(sub imm64SExt16:$imm, i64:$in),
1389 (SUBFIC8 $in, imm:$imm)>;
1392 def : Pat<(shl i64:$in, (i32 imm:$imm)),
1393 (RLDICR $in, imm:$imm, (SHL64 imm:$imm))>;
1394 def : Pat<(srl i64:$in, (i32 imm:$imm)),
1395 (RLDICL $in, (SRL64 imm:$imm), imm:$imm)>;
1398 def : Pat<(rotl i64:$in, i32:$sh),
1399 (RLDCL $in, $sh, 0)>;
1400 def : Pat<(rotl i64:$in, (i32 imm:$imm)),
1401 (RLDICL $in, imm:$imm, 0)>;
1403 // Hi and Lo for Darwin Global Addresses.
1404 def : Pat<(PPChi tglobaladdr:$in, 0), (LIS8 tglobaladdr:$in)>;
1405 def : Pat<(PPClo tglobaladdr:$in, 0), (LI8 tglobaladdr:$in)>;
1406 def : Pat<(PPChi tconstpool:$in , 0), (LIS8 tconstpool:$in)>;
1407 def : Pat<(PPClo tconstpool:$in , 0), (LI8 tconstpool:$in)>;
1408 def : Pat<(PPChi tjumptable:$in , 0), (LIS8 tjumptable:$in)>;
1409 def : Pat<(PPClo tjumptable:$in , 0), (LI8 tjumptable:$in)>;
1410 def : Pat<(PPChi tblockaddress:$in, 0), (LIS8 tblockaddress:$in)>;
1411 def : Pat<(PPClo tblockaddress:$in, 0), (LI8 tblockaddress:$in)>;
1412 def : Pat<(PPChi tglobaltlsaddr:$g, i64:$in),
1413 (ADDIS8 $in, tglobaltlsaddr:$g)>;
1414 def : Pat<(PPClo tglobaltlsaddr:$g, i64:$in),
1415 (ADDI8 $in, tglobaltlsaddr:$g)>;
1416 def : Pat<(add i64:$in, (PPChi tglobaladdr:$g, 0)),
1417 (ADDIS8 $in, tglobaladdr:$g)>;
1418 def : Pat<(add i64:$in, (PPChi tconstpool:$g, 0)),
1419 (ADDIS8 $in, tconstpool:$g)>;
1420 def : Pat<(add i64:$in, (PPChi tjumptable:$g, 0)),
1421 (ADDIS8 $in, tjumptable:$g)>;
1422 def : Pat<(add i64:$in, (PPChi tblockaddress:$g, 0)),
1423 (ADDIS8 $in, tblockaddress:$g)>;
1425 // Patterns to match r+r indexed loads and stores for
1426 // addresses without at least 4-byte alignment.
1427 def : Pat<(i64 (unaligned4sextloadi32 xoaddr:$src)),
1428 (LWAX xoaddr:$src)>;
1429 def : Pat<(i64 (unaligned4load xoaddr:$src)),
1431 def : Pat<(unaligned4store i64:$rS, xoaddr:$dst),
1432 (STDX $rS, xoaddr:$dst)>;
1434 // 64-bits atomic loads and stores
1435 def : Pat<(atomic_load_64 ixaddr:$src), (LD memrix:$src)>;
1436 def : Pat<(atomic_load_64 xaddr:$src), (LDX memrr:$src)>;
1438 def : Pat<(atomic_store_64 ixaddr:$ptr, i64:$val), (STD g8rc:$val, memrix:$ptr)>;
1439 def : Pat<(atomic_store_64 xaddr:$ptr, i64:$val), (STDX g8rc:$val, memrr:$ptr)>;
1441 let Predicates = [IsISA3_0] in {
1443 class X_L1_RA5_RB5<bits<6> opcode, bits<10> xo, string opc, RegisterOperand ty,
1444 InstrItinClass itin, list<dag> pattern>
1445 : X_L1_RS5_RS5<opcode, xo, (outs), (ins ty:$rA, ty:$rB, u1imm:$L),
1446 !strconcat(opc, " $rA, $rB, $L"), itin, pattern>;
1448 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
1449 def CP_COPY8 : X_L1_RA5_RB5<31, 774, "copy" , g8rc, IIC_LdStCOPY, []>;
1450 def CP_PASTE8 : X_L1_RA5_RB5<31, 902, "paste" , g8rc, IIC_LdStPASTE, []>;
1451 def CP_PASTE8o : X_L1_RA5_RB5<31, 902, "paste.", g8rc, IIC_LdStPASTE, []>,isDOT;
1454 // SLB Invalidate Entry Global
1455 def SLBIEG : XForm_26<31, 466, (outs), (ins gprc:$RS, gprc:$RB),
1456 "slbieg $RS, $RB", IIC_SprSLBIEG, []>;
1458 def SLBSYNC : XForm_0<31, 338, (outs), (ins), "slbsync", IIC_SprSLBSYNC, []>;