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 iaddrX4:$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 def : Pat<(PPCcall (i64 mcsym:$dst)),
198 def : Pat<(PPCcall_nop (i64 mcsym:$dst)),
199 (BL8_NOP mcsym:$dst)>;
202 // FIXME: some of these might be used with constant operands. This will result
203 // in constant materialization instructions that may be redundant. We currently
204 // clean this up in PPCMIPeephole with calls to
205 // PPCInstrInfo::convertToImmediateForm() but we should probably not emit them
206 // in the first place.
207 let Defs = [CR0] in {
208 def ATOMIC_LOAD_ADD_I64 : PPCCustomInserterPseudo<
209 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_ADD_I64",
210 [(set i64:$dst, (atomic_load_add_64 xoaddr:$ptr, i64:$incr))]>;
211 def ATOMIC_LOAD_SUB_I64 : PPCCustomInserterPseudo<
212 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_SUB_I64",
213 [(set i64:$dst, (atomic_load_sub_64 xoaddr:$ptr, i64:$incr))]>;
214 def ATOMIC_LOAD_OR_I64 : PPCCustomInserterPseudo<
215 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_OR_I64",
216 [(set i64:$dst, (atomic_load_or_64 xoaddr:$ptr, i64:$incr))]>;
217 def ATOMIC_LOAD_XOR_I64 : PPCCustomInserterPseudo<
218 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_XOR_I64",
219 [(set i64:$dst, (atomic_load_xor_64 xoaddr:$ptr, i64:$incr))]>;
220 def ATOMIC_LOAD_AND_I64 : PPCCustomInserterPseudo<
221 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_AND_i64",
222 [(set i64:$dst, (atomic_load_and_64 xoaddr:$ptr, i64:$incr))]>;
223 def ATOMIC_LOAD_NAND_I64 : PPCCustomInserterPseudo<
224 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_NAND_I64",
225 [(set i64:$dst, (atomic_load_nand_64 xoaddr:$ptr, i64:$incr))]>;
226 def ATOMIC_LOAD_MIN_I64 : PPCCustomInserterPseudo<
227 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_MIN_I64",
228 [(set i64:$dst, (atomic_load_min_64 xoaddr:$ptr, i64:$incr))]>;
229 def ATOMIC_LOAD_MAX_I64 : PPCCustomInserterPseudo<
230 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_MAX_I64",
231 [(set i64:$dst, (atomic_load_max_64 xoaddr:$ptr, i64:$incr))]>;
232 def ATOMIC_LOAD_UMIN_I64 : PPCCustomInserterPseudo<
233 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_UMIN_I64",
234 [(set i64:$dst, (atomic_load_umin_64 xoaddr:$ptr, i64:$incr))]>;
235 def ATOMIC_LOAD_UMAX_I64 : PPCCustomInserterPseudo<
236 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_UMAX_I64",
237 [(set i64:$dst, (atomic_load_umax_64 xoaddr:$ptr, i64:$incr))]>;
239 def ATOMIC_CMP_SWAP_I64 : PPCCustomInserterPseudo<
240 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$old, g8rc:$new), "#ATOMIC_CMP_SWAP_I64",
241 [(set i64:$dst, (atomic_cmp_swap_64 xoaddr:$ptr, i64:$old, i64:$new))]>;
243 def ATOMIC_SWAP_I64 : PPCCustomInserterPseudo<
244 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$new), "#ATOMIC_SWAP_I64",
245 [(set i64:$dst, (atomic_swap_64 xoaddr:$ptr, i64:$new))]>;
248 // Instructions to support atomic operations
249 let mayLoad = 1, hasSideEffects = 0 in {
250 def LDARX : XForm_1_memOp<31, 84, (outs g8rc:$rD), (ins memrr:$ptr),
251 "ldarx $rD, $ptr", IIC_LdStLDARX, []>;
253 // Instruction to support lock versions of atomics
254 // (EH=1 - see Power ISA 2.07 Book II 4.4.2)
255 def LDARXL : XForm_1<31, 84, (outs g8rc:$rD), (ins memrr:$ptr),
256 "ldarx $rD, $ptr, 1", IIC_LdStLDARX, []>, isDOT;
258 let hasExtraDefRegAllocReq = 1 in
259 def LDAT : X_RD5_RS5_IM5<31, 614, (outs g8rc:$rD), (ins g8rc:$rA, u5imm:$FC),
260 "ldat $rD, $rA, $FC", IIC_LdStLoad>, isPPC64,
261 Requires<[IsISA3_0]>;
264 let Defs = [CR0], mayStore = 1, mayLoad = 0, hasSideEffects = 0 in
265 def STDCX : XForm_1_memOp<31, 214, (outs), (ins g8rc:$rS, memrr:$dst),
266 "stdcx. $rS, $dst", IIC_LdStSTDCX, []>, isDOT;
268 let mayStore = 1, mayLoad = 0, hasSideEffects = 0 in
269 def STDAT : X_RD5_RS5_IM5<31, 742, (outs), (ins g8rc:$rS, g8rc:$rA, u5imm:$FC),
270 "stdat $rS, $rA, $FC", IIC_LdStStore>, isPPC64,
271 Requires<[IsISA3_0]>;
273 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
274 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
275 def TCRETURNdi8 :PPCEmitTimePseudo< (outs),
276 (ins calltarget:$dst, i32imm:$offset),
277 "#TC_RETURNd8 $dst $offset",
280 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
281 def TCRETURNai8 :PPCEmitTimePseudo<(outs), (ins abscalltarget:$func, i32imm:$offset),
282 "#TC_RETURNa8 $func $offset",
283 [(PPCtc_return (i64 imm:$func), imm:$offset)]>;
285 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
286 def TCRETURNri8 : PPCEmitTimePseudo<(outs), (ins CTRRC8:$dst, i32imm:$offset),
287 "#TC_RETURNr8 $dst $offset",
290 let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, isBranch = 1,
291 isIndirectBranch = 1, isCall = 1, isReturn = 1, Uses = [CTR8, RM] in
292 def TAILBCTR8 : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
294 Requires<[In64BitMode]>;
296 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
297 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
298 def TAILB8 : IForm<18, 0, 0, (outs), (ins calltarget:$dst),
302 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
303 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
304 def TAILBA8 : IForm<18, 0, 0, (outs), (ins abscalltarget:$dst),
307 } // Interpretation64Bit
309 def : Pat<(PPCtc_return (i64 tglobaladdr:$dst), imm:$imm),
310 (TCRETURNdi8 tglobaladdr:$dst, imm:$imm)>;
312 def : Pat<(PPCtc_return (i64 texternalsym:$dst), imm:$imm),
313 (TCRETURNdi8 texternalsym:$dst, imm:$imm)>;
315 def : Pat<(PPCtc_return CTRRC8:$dst, imm:$imm),
316 (TCRETURNri8 CTRRC8:$dst, imm:$imm)>;
319 // 64-bit CR instructions
320 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
321 let hasSideEffects = 0 in {
322 // mtocrf's input needs to be prepared by shifting by an amount dependent
323 // on the cr register selected. Thus, post-ra anti-dep breaking must not
324 // later change that register assignment.
325 let hasExtraDefRegAllocReq = 1 in {
326 def MTOCRF8: XFXForm_5a<31, 144, (outs crbitm:$FXM), (ins g8rc:$ST),
327 "mtocrf $FXM, $ST", IIC_BrMCRX>,
328 PPC970_DGroup_First, PPC970_Unit_CRU;
330 // Similarly to mtocrf, the mask for mtcrf must be prepared in a way that
331 // is dependent on the cr fields being set.
332 def MTCRF8 : XFXForm_5<31, 144, (outs), (ins i32imm:$FXM, g8rc:$rS),
333 "mtcrf $FXM, $rS", IIC_BrMCRX>,
334 PPC970_MicroCode, PPC970_Unit_CRU;
335 } // hasExtraDefRegAllocReq = 1
337 // mfocrf's input needs to be prepared by shifting by an amount dependent
338 // on the cr register selected. Thus, post-ra anti-dep breaking must not
339 // later change that register assignment.
340 let hasExtraSrcRegAllocReq = 1 in {
341 def MFOCRF8: XFXForm_5a<31, 19, (outs g8rc:$rT), (ins crbitm:$FXM),
342 "mfocrf $rT, $FXM", IIC_SprMFCRF>,
343 PPC970_DGroup_First, PPC970_Unit_CRU;
345 // Similarly to mfocrf, the mask for mfcrf must be prepared in a way that
346 // is dependent on the cr fields being copied.
347 def MFCR8 : XFXForm_3<31, 19, (outs g8rc:$rT), (ins),
348 "mfcr $rT", IIC_SprMFCR>,
349 PPC970_MicroCode, PPC970_Unit_CRU;
350 } // hasExtraSrcRegAllocReq = 1
351 } // hasSideEffects = 0
353 // While longjmp is a control-flow barrier (fallthrough isn't allowed), setjmp
355 let hasSideEffects = 1 in {
357 def EH_SjLj_SetJmp64 : PPCCustomInserterPseudo<(outs gprc:$dst), (ins memr:$buf),
359 [(set i32:$dst, (PPCeh_sjlj_setjmp addr:$buf))]>,
360 Requires<[In64BitMode]>;
363 let hasSideEffects = 1, isBarrier = 1 in {
364 let isTerminator = 1 in
365 def EH_SjLj_LongJmp64 : PPCCustomInserterPseudo<(outs), (ins memr:$buf),
366 "#EH_SJLJ_LONGJMP64",
367 [(PPCeh_sjlj_longjmp addr:$buf)]>,
368 Requires<[In64BitMode]>;
371 def MFSPR8 : XFXForm_1<31, 339, (outs g8rc:$RT), (ins i32imm:$SPR),
372 "mfspr $RT, $SPR", IIC_SprMFSPR>;
373 def MTSPR8 : XFXForm_1<31, 467, (outs), (ins i32imm:$SPR, g8rc:$RT),
374 "mtspr $SPR, $RT", IIC_SprMTSPR>;
377 //===----------------------------------------------------------------------===//
378 // 64-bit SPR manipulation instrs.
380 let Uses = [CTR8] in {
381 def MFCTR8 : XFXForm_1_ext<31, 339, 9, (outs g8rc:$rT), (ins),
382 "mfctr $rT", IIC_SprMFSPR>,
383 PPC970_DGroup_First, PPC970_Unit_FXU;
385 let Pattern = [(PPCmtctr i64:$rS)], Defs = [CTR8] in {
386 def MTCTR8 : XFXForm_7_ext<31, 467, 9, (outs), (ins g8rc:$rS),
387 "mtctr $rS", IIC_SprMTSPR>,
388 PPC970_DGroup_First, PPC970_Unit_FXU;
390 let hasSideEffects = 1, Defs = [CTR8] in {
391 let Pattern = [(int_set_loop_iterations i64:$rS)] in
392 def MTCTR8loop : XFXForm_7_ext<31, 467, 9, (outs), (ins g8rc:$rS),
393 "mtctr $rS", IIC_SprMTSPR>,
394 PPC970_DGroup_First, PPC970_Unit_FXU;
397 let Pattern = [(set i64:$rT, readcyclecounter)] in
398 def MFTB8 : XFXForm_1_ext<31, 339, 268, (outs g8rc:$rT), (ins),
399 "mfspr $rT, 268", IIC_SprMFTB>,
400 PPC970_DGroup_First, PPC970_Unit_FXU;
401 // Note that encoding mftb using mfspr is now the preferred form,
402 // and has been since at least ISA v2.03. The mftb instruction has
403 // now been phased out. Using mfspr, however, is known not to work on
406 let Defs = [X1], Uses = [X1] in
407 def DYNALLOC8 : PPCEmitTimePseudo<(outs g8rc:$result), (ins g8rc:$negsize, memri:$fpsi),"#DYNALLOC8",
409 (PPCdynalloc i64:$negsize, iaddr:$fpsi))]>;
410 def DYNAREAOFFSET8 : PPCEmitTimePseudo<(outs i64imm:$result), (ins memri:$fpsi), "#DYNAREAOFFSET8",
411 [(set i64:$result, (PPCdynareaoffset iaddr:$fpsi))]>;
413 let Defs = [LR8] in {
414 def MTLR8 : XFXForm_7_ext<31, 467, 8, (outs), (ins g8rc:$rS),
415 "mtlr $rS", IIC_SprMTSPR>,
416 PPC970_DGroup_First, PPC970_Unit_FXU;
418 let Uses = [LR8] in {
419 def MFLR8 : XFXForm_1_ext<31, 339, 8, (outs g8rc:$rT), (ins),
420 "mflr $rT", IIC_SprMFSPR>,
421 PPC970_DGroup_First, PPC970_Unit_FXU;
423 } // Interpretation64Bit
425 //===----------------------------------------------------------------------===//
426 // Fixed point instructions.
429 let PPC970_Unit = 1 in { // FXU Operations.
430 let Interpretation64Bit = 1 in {
431 let hasSideEffects = 0 in {
432 let isCodeGenOnly = 1 in {
434 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in {
435 def LI8 : DForm_2_r0<14, (outs g8rc:$rD), (ins s16imm64:$imm),
436 "li $rD, $imm", IIC_IntSimple,
437 [(set i64:$rD, imm64SExt16:$imm)]>;
438 def LIS8 : DForm_2_r0<15, (outs g8rc:$rD), (ins s17imm64:$imm),
439 "lis $rD, $imm", IIC_IntSimple,
440 [(set i64:$rD, imm16ShiftedSExt:$imm)]>;
444 let isCommutable = 1 in {
445 defm NAND8: XForm_6r<31, 476, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
446 "nand", "$rA, $rS, $rB", IIC_IntSimple,
447 [(set i64:$rA, (not (and i64:$rS, i64:$rB)))]>;
448 defm AND8 : XForm_6r<31, 28, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
449 "and", "$rA, $rS, $rB", IIC_IntSimple,
450 [(set i64:$rA, (and i64:$rS, i64:$rB))]>;
452 defm ANDC8: XForm_6r<31, 60, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
453 "andc", "$rA, $rS, $rB", IIC_IntSimple,
454 [(set i64:$rA, (and i64:$rS, (not i64:$rB)))]>;
455 let isCommutable = 1 in {
456 defm OR8 : XForm_6r<31, 444, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
457 "or", "$rA, $rS, $rB", IIC_IntSimple,
458 [(set i64:$rA, (or i64:$rS, i64:$rB))]>;
459 defm NOR8 : XForm_6r<31, 124, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
460 "nor", "$rA, $rS, $rB", IIC_IntSimple,
461 [(set i64:$rA, (not (or i64:$rS, i64:$rB)))]>;
463 defm ORC8 : XForm_6r<31, 412, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
464 "orc", "$rA, $rS, $rB", IIC_IntSimple,
465 [(set i64:$rA, (or i64:$rS, (not i64:$rB)))]>;
466 let isCommutable = 1 in {
467 defm EQV8 : XForm_6r<31, 284, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
468 "eqv", "$rA, $rS, $rB", IIC_IntSimple,
469 [(set i64:$rA, (not (xor i64:$rS, i64:$rB)))]>;
470 defm XOR8 : XForm_6r<31, 316, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
471 "xor", "$rA, $rS, $rB", IIC_IntSimple,
472 [(set i64:$rA, (xor i64:$rS, i64:$rB))]>;
473 } // let isCommutable = 1
475 // Logical ops with immediate.
476 let Defs = [CR0] in {
477 def ANDIo8 : DForm_4<28, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
478 "andi. $dst, $src1, $src2", IIC_IntGeneral,
479 [(set i64:$dst, (and i64:$src1, immZExt16:$src2))]>,
481 def ANDISo8 : DForm_4<29, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
482 "andis. $dst, $src1, $src2", IIC_IntGeneral,
483 [(set i64:$dst, (and i64:$src1, imm16ShiftedZExt:$src2))]>,
486 def ORI8 : DForm_4<24, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
487 "ori $dst, $src1, $src2", IIC_IntSimple,
488 [(set i64:$dst, (or i64:$src1, immZExt16:$src2))]>;
489 def ORIS8 : DForm_4<25, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
490 "oris $dst, $src1, $src2", IIC_IntSimple,
491 [(set i64:$dst, (or i64:$src1, imm16ShiftedZExt:$src2))]>;
492 def XORI8 : DForm_4<26, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
493 "xori $dst, $src1, $src2", IIC_IntSimple,
494 [(set i64:$dst, (xor i64:$src1, immZExt16:$src2))]>;
495 def XORIS8 : DForm_4<27, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
496 "xoris $dst, $src1, $src2", IIC_IntSimple,
497 [(set i64:$dst, (xor i64:$src1, imm16ShiftedZExt:$src2))]>;
499 let isCommutable = 1 in
500 defm ADD8 : XOForm_1r<31, 266, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
501 "add", "$rT, $rA, $rB", IIC_IntSimple,
502 [(set i64:$rT, (add i64:$rA, i64:$rB))]>;
503 // ADD8 has a special form: reg = ADD8(reg, sym@tls) for use by the
504 // initial-exec thread-local storage model. We need to forbid r0 here -
505 // while it works for add just fine, the linker can relax this to local-exec
506 // addi, which won't work for r0.
507 def ADD8TLS : XOForm_1<31, 266, 0, (outs g8rc:$rT), (ins g8rc_nox0:$rA, tlsreg:$rB),
508 "add $rT, $rA, $rB", IIC_IntSimple,
509 [(set i64:$rT, (add i64:$rA, tglobaltlsaddr:$rB))]>;
511 def LBZXTLS : XForm_1<31, 87, (outs g8rc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
512 "lbzx $rD, $rA, $rB", IIC_LdStLoad, []>;
513 def LHZXTLS : XForm_1<31, 279, (outs g8rc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
514 "lhzx $rD, $rA, $rB", IIC_LdStLoad, []>;
515 def LWZXTLS : XForm_1<31, 23, (outs g8rc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
516 "lwzx $rD, $rA, $rB", IIC_LdStLoad, []>;
517 def LDXTLS : XForm_1<31, 21, (outs g8rc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
518 "ldx $rD, $rA, $rB", IIC_LdStLD, []>, isPPC64;
519 def LBZXTLS_32 : XForm_1<31, 87, (outs gprc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
520 "lbzx $rD, $rA, $rB", IIC_LdStLoad, []>;
521 def LHZXTLS_32 : XForm_1<31, 279, (outs gprc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
522 "lhzx $rD, $rA, $rB", IIC_LdStLoad, []>;
523 def LWZXTLS_32 : XForm_1<31, 23, (outs gprc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
524 "lwzx $rD, $rA, $rB", IIC_LdStLoad, []>;
528 let mayStore = 1 in {
529 def STBXTLS : XForm_8<31, 215, (outs), (ins g8rc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
530 "stbx $rS, $rA, $rB", IIC_LdStStore, []>,
531 PPC970_DGroup_Cracked;
532 def STHXTLS : XForm_8<31, 407, (outs), (ins g8rc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
533 "sthx $rS, $rA, $rB", IIC_LdStStore, []>,
534 PPC970_DGroup_Cracked;
535 def STWXTLS : XForm_8<31, 151, (outs), (ins g8rc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
536 "stwx $rS, $rA, $rB", IIC_LdStStore, []>,
537 PPC970_DGroup_Cracked;
538 def STDXTLS : XForm_8<31, 149, (outs), (ins g8rc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
539 "stdx $rS, $rA, $rB", IIC_LdStSTD, []>, isPPC64,
540 PPC970_DGroup_Cracked;
541 def STBXTLS_32 : XForm_8<31, 215, (outs), (ins gprc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
542 "stbx $rS, $rA, $rB", IIC_LdStStore, []>,
543 PPC970_DGroup_Cracked;
544 def STHXTLS_32 : XForm_8<31, 407, (outs), (ins gprc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
545 "sthx $rS, $rA, $rB", IIC_LdStStore, []>,
546 PPC970_DGroup_Cracked;
547 def STWXTLS_32 : XForm_8<31, 151, (outs), (ins gprc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
548 "stwx $rS, $rA, $rB", IIC_LdStStore, []>,
549 PPC970_DGroup_Cracked;
553 let isCommutable = 1 in
554 defm ADDC8 : XOForm_1rc<31, 10, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
555 "addc", "$rT, $rA, $rB", IIC_IntGeneral,
556 [(set i64:$rT, (addc i64:$rA, i64:$rB))]>,
557 PPC970_DGroup_Cracked;
559 let Defs = [CARRY] in
560 def ADDIC8 : DForm_2<12, (outs g8rc:$rD), (ins g8rc:$rA, s16imm64:$imm),
561 "addic $rD, $rA, $imm", IIC_IntGeneral,
562 [(set i64:$rD, (addc i64:$rA, imm64SExt16:$imm))]>;
563 def ADDI8 : DForm_2<14, (outs g8rc:$rD), (ins g8rc_nox0:$rA, s16imm64:$imm),
564 "addi $rD, $rA, $imm", IIC_IntSimple,
565 [(set i64:$rD, (add i64:$rA, imm64SExt16:$imm))]>;
566 def ADDIS8 : DForm_2<15, (outs g8rc:$rD), (ins g8rc_nox0:$rA, s17imm64:$imm),
567 "addis $rD, $rA, $imm", IIC_IntSimple,
568 [(set i64:$rD, (add i64:$rA, imm16ShiftedSExt:$imm))]>;
570 let Defs = [CARRY] in {
571 def SUBFIC8: DForm_2< 8, (outs g8rc:$rD), (ins g8rc:$rA, s16imm64:$imm),
572 "subfic $rD, $rA, $imm", IIC_IntGeneral,
573 [(set i64:$rD, (subc imm64SExt16:$imm, i64:$rA))]>;
575 defm SUBFC8 : XOForm_1rc<31, 8, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
576 "subfc", "$rT, $rA, $rB", IIC_IntGeneral,
577 [(set i64:$rT, (subc i64:$rB, i64:$rA))]>,
578 PPC970_DGroup_Cracked;
579 defm SUBF8 : XOForm_1r<31, 40, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
580 "subf", "$rT, $rA, $rB", IIC_IntGeneral,
581 [(set i64:$rT, (sub i64:$rB, i64:$rA))]>;
582 defm NEG8 : XOForm_3r<31, 104, 0, (outs g8rc:$rT), (ins g8rc:$rA),
583 "neg", "$rT, $rA", IIC_IntSimple,
584 [(set i64:$rT, (ineg i64:$rA))]>;
585 let Uses = [CARRY] in {
586 let isCommutable = 1 in
587 defm ADDE8 : XOForm_1rc<31, 138, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
588 "adde", "$rT, $rA, $rB", IIC_IntGeneral,
589 [(set i64:$rT, (adde i64:$rA, i64:$rB))]>;
590 defm ADDME8 : XOForm_3rc<31, 234, 0, (outs g8rc:$rT), (ins g8rc:$rA),
591 "addme", "$rT, $rA", IIC_IntGeneral,
592 [(set i64:$rT, (adde i64:$rA, -1))]>;
593 defm ADDZE8 : XOForm_3rc<31, 202, 0, (outs g8rc:$rT), (ins g8rc:$rA),
594 "addze", "$rT, $rA", IIC_IntGeneral,
595 [(set i64:$rT, (adde i64:$rA, 0))]>;
596 defm SUBFE8 : XOForm_1rc<31, 136, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
597 "subfe", "$rT, $rA, $rB", IIC_IntGeneral,
598 [(set i64:$rT, (sube i64:$rB, i64:$rA))]>;
599 defm SUBFME8 : XOForm_3rc<31, 232, 0, (outs g8rc:$rT), (ins g8rc:$rA),
600 "subfme", "$rT, $rA", IIC_IntGeneral,
601 [(set i64:$rT, (sube -1, i64:$rA))]>;
602 defm SUBFZE8 : XOForm_3rc<31, 200, 0, (outs g8rc:$rT), (ins g8rc:$rA),
603 "subfze", "$rT, $rA", IIC_IntGeneral,
604 [(set i64:$rT, (sube 0, i64:$rA))]>;
608 // FIXME: Duplicating this for the asm parser should be unnecessary, but the
609 // previous definition must be marked as CodeGen only to prevent decoding
611 let isAsmParserOnly = 1 in {
612 def ADD8TLS_ : XOForm_1<31, 266, 0, (outs g8rc:$rT), (ins g8rc:$rA, tlsreg:$rB),
613 "add $rT, $rA, $rB", IIC_IntSimple, []>;
616 def LBZXTLS_ : XForm_1<31, 87, (outs g8rc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
617 "lbzx $rD, $rA, $rB", IIC_LdStLoad, []>;
618 def LHZXTLS_ : XForm_1<31, 279, (outs g8rc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
619 "lhzx $rD, $rA, $rB", IIC_LdStLoad, []>;
620 def LWZXTLS_ : XForm_1<31, 23, (outs g8rc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
621 "lwzx $rD, $rA, $rB", IIC_LdStLoad, []>;
622 def LDXTLS_ : XForm_1<31, 21, (outs g8rc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
623 "ldx $rD, $rA, $rB", IIC_LdStLD, []>, isPPC64;
626 let mayStore = 1 in {
627 def STBXTLS_ : XForm_8<31, 215, (outs), (ins g8rc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
628 "stbx $rS, $rA, $rB", IIC_LdStStore, []>,
629 PPC970_DGroup_Cracked;
630 def STHXTLS_ : XForm_8<31, 407, (outs), (ins g8rc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
631 "sthx $rS, $rA, $rB", IIC_LdStStore, []>,
632 PPC970_DGroup_Cracked;
633 def STWXTLS_ : XForm_8<31, 151, (outs), (ins g8rc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
634 "stwx $rS, $rA, $rB", IIC_LdStStore, []>,
635 PPC970_DGroup_Cracked;
636 def STDXTLS_ : XForm_8<31, 149, (outs), (ins g8rc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
637 "stdx $rS, $rA, $rB", IIC_LdStSTD, []>, isPPC64,
638 PPC970_DGroup_Cracked;
642 let isCommutable = 1 in {
643 defm MULHD : XOForm_1r<31, 73, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
644 "mulhd", "$rT, $rA, $rB", IIC_IntMulHW,
645 [(set i64:$rT, (mulhs i64:$rA, i64:$rB))]>;
646 defm MULHDU : XOForm_1r<31, 9, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
647 "mulhdu", "$rT, $rA, $rB", IIC_IntMulHWU,
648 [(set i64:$rT, (mulhu i64:$rA, i64:$rB))]>;
651 } // Interpretation64Bit
653 let isCompare = 1, hasSideEffects = 0 in {
654 def CMPD : XForm_16_ext<31, 0, (outs crrc:$crD), (ins g8rc:$rA, g8rc:$rB),
655 "cmpd $crD, $rA, $rB", IIC_IntCompare>, isPPC64;
656 def CMPLD : XForm_16_ext<31, 32, (outs crrc:$crD), (ins g8rc:$rA, g8rc:$rB),
657 "cmpld $crD, $rA, $rB", IIC_IntCompare>, isPPC64;
658 def CMPDI : DForm_5_ext<11, (outs crrc:$crD), (ins g8rc:$rA, s16imm64:$imm),
659 "cmpdi $crD, $rA, $imm", IIC_IntCompare>, isPPC64;
660 def CMPLDI : DForm_6_ext<10, (outs crrc:$dst), (ins g8rc:$src1, u16imm64:$src2),
661 "cmpldi $dst, $src1, $src2",
662 IIC_IntCompare>, isPPC64;
663 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
664 def CMPRB8 : X_BF3_L1_RS5_RS5<31, 192, (outs crbitrc:$BF),
665 (ins u1imm:$L, g8rc:$rA, g8rc:$rB),
666 "cmprb $BF, $L, $rA, $rB", IIC_IntCompare, []>,
667 Requires<[IsISA3_0]>;
668 def CMPEQB : X_BF3_RS5_RS5<31, 224, (outs crbitrc:$BF),
669 (ins g8rc:$rA, g8rc:$rB), "cmpeqb $BF, $rA, $rB",
670 IIC_IntCompare, []>, Requires<[IsISA3_0]>;
673 let hasSideEffects = 0 in {
674 defm SLD : XForm_6r<31, 27, (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB),
675 "sld", "$rA, $rS, $rB", IIC_IntRotateD,
676 [(set i64:$rA, (PPCshl i64:$rS, i32:$rB))]>, isPPC64;
677 defm SRD : XForm_6r<31, 539, (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB),
678 "srd", "$rA, $rS, $rB", IIC_IntRotateD,
679 [(set i64:$rA, (PPCsrl i64:$rS, i32:$rB))]>, isPPC64;
680 defm SRAD : XForm_6rc<31, 794, (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB),
681 "srad", "$rA, $rS, $rB", IIC_IntRotateD,
682 [(set i64:$rA, (PPCsra i64:$rS, i32:$rB))]>, isPPC64;
684 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
685 defm CNTLZW8 : XForm_11r<31, 26, (outs g8rc:$rA), (ins g8rc:$rS),
686 "cntlzw", "$rA, $rS", IIC_IntGeneral, []>;
687 defm CNTTZW8 : XForm_11r<31, 538, (outs g8rc:$rA), (ins g8rc:$rS),
688 "cnttzw", "$rA, $rS", IIC_IntGeneral, []>,
689 Requires<[IsISA3_0]>;
691 defm EXTSB8 : XForm_11r<31, 954, (outs g8rc:$rA), (ins g8rc:$rS),
692 "extsb", "$rA, $rS", IIC_IntSimple,
693 [(set i64:$rA, (sext_inreg i64:$rS, i8))]>;
694 defm EXTSH8 : XForm_11r<31, 922, (outs g8rc:$rA), (ins g8rc:$rS),
695 "extsh", "$rA, $rS", IIC_IntSimple,
696 [(set i64:$rA, (sext_inreg i64:$rS, i16))]>;
698 defm SLW8 : XForm_6r<31, 24, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
699 "slw", "$rA, $rS, $rB", IIC_IntGeneral, []>;
700 defm SRW8 : XForm_6r<31, 536, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
701 "srw", "$rA, $rS, $rB", IIC_IntGeneral, []>;
702 } // Interpretation64Bit
705 let isCodeGenOnly = 1 in {
706 def EXTSB8_32_64 : XForm_11<31, 954, (outs g8rc:$rA), (ins gprc:$rS),
707 "extsb $rA, $rS", IIC_IntSimple, []>, isPPC64;
708 def EXTSH8_32_64 : XForm_11<31, 922, (outs g8rc:$rA), (ins gprc:$rS),
709 "extsh $rA, $rS", IIC_IntSimple, []>, isPPC64;
710 } // isCodeGenOnly for fast-isel
712 defm EXTSW : XForm_11r<31, 986, (outs g8rc:$rA), (ins g8rc:$rS),
713 "extsw", "$rA, $rS", IIC_IntSimple,
714 [(set i64:$rA, (sext_inreg i64:$rS, i32))]>, isPPC64;
715 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
716 defm EXTSW_32_64 : XForm_11r<31, 986, (outs g8rc:$rA), (ins gprc:$rS),
717 "extsw", "$rA, $rS", IIC_IntSimple,
718 [(set i64:$rA, (sext i32:$rS))]>, isPPC64;
719 let isCodeGenOnly = 1 in
720 def EXTSW_32 : XForm_11<31, 986, (outs gprc:$rA), (ins gprc:$rS),
721 "extsw $rA, $rS", IIC_IntSimple,
724 defm SRADI : XSForm_1rc<31, 413, (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH),
725 "sradi", "$rA, $rS, $SH", IIC_IntRotateDI,
726 [(set i64:$rA, (sra i64:$rS, (i32 imm:$SH)))]>, isPPC64;
728 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
729 defm EXTSWSLI_32_64 : XSForm_1r<31, 445, (outs g8rc:$rA),
730 (ins gprc:$rS, u6imm:$SH),
731 "extswsli", "$rA, $rS, $SH", IIC_IntRotateDI,
733 (PPCextswsli i32:$rS, (i32 imm:$SH)))]>,
734 isPPC64, Requires<[IsISA3_0]>;
736 defm EXTSWSLI : XSForm_1rc<31, 445, (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH),
737 "extswsli", "$rA, $rS, $SH", IIC_IntRotateDI,
738 []>, isPPC64, Requires<[IsISA3_0]>;
741 let isCodeGenOnly = 1, Defs = [CARRY] in
742 def SRADI_32 : XSForm_1<31, 413, (outs gprc:$rA), (ins gprc:$rS, u6imm:$SH),
743 "sradi $rA, $rS, $SH", IIC_IntRotateDI, []>, isPPC64;
745 defm CNTLZD : XForm_11r<31, 58, (outs g8rc:$rA), (ins g8rc:$rS),
746 "cntlzd", "$rA, $rS", IIC_IntGeneral,
747 [(set i64:$rA, (ctlz i64:$rS))]>;
748 defm CNTTZD : XForm_11r<31, 570, (outs g8rc:$rA), (ins g8rc:$rS),
749 "cnttzd", "$rA, $rS", IIC_IntGeneral,
750 [(set i64:$rA, (cttz i64:$rS))]>, Requires<[IsISA3_0]>;
751 def POPCNTD : XForm_11<31, 506, (outs g8rc:$rA), (ins g8rc:$rS),
752 "popcntd $rA, $rS", IIC_IntGeneral,
753 [(set i64:$rA, (ctpop i64:$rS))]>;
754 def BPERMD : XForm_6<31, 252, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
755 "bpermd $rA, $rS, $rB", IIC_IntGeneral,
756 [(set i64:$rA, (int_ppc_bpermd g8rc:$rS, g8rc:$rB))]>,
757 isPPC64, Requires<[HasBPERMD]>;
759 let isCodeGenOnly = 1, isCommutable = 1 in
760 def CMPB8 : XForm_6<31, 508, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
761 "cmpb $rA, $rS, $rB", IIC_IntGeneral,
762 [(set i64:$rA, (PPCcmpb i64:$rS, i64:$rB))]>;
764 // popcntw also does a population count on the high 32 bits (storing the
765 // results in the high 32-bits of the output). We'll ignore that here (which is
766 // safe because we never separately use the high part of the 64-bit registers).
767 def POPCNTW : XForm_11<31, 378, (outs gprc:$rA), (ins gprc:$rS),
768 "popcntw $rA, $rS", IIC_IntGeneral,
769 [(set i32:$rA, (ctpop i32:$rS))]>;
771 def POPCNTB : XForm_11<31, 122, (outs gprc:$rA), (ins gprc:$rS),
772 "popcntb $rA, $rS", IIC_IntGeneral, []>;
774 defm DIVD : XOForm_1rcr<31, 489, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
775 "divd", "$rT, $rA, $rB", IIC_IntDivD,
776 [(set i64:$rT, (sdiv i64:$rA, i64:$rB))]>, isPPC64;
777 defm DIVDU : XOForm_1rcr<31, 457, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
778 "divdu", "$rT, $rA, $rB", IIC_IntDivD,
779 [(set i64:$rT, (udiv i64:$rA, i64:$rB))]>, isPPC64;
780 def DIVDE : XOForm_1<31, 425, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
781 "divde $rT, $rA, $rB", IIC_IntDivD,
782 [(set i64:$rT, (int_ppc_divde g8rc:$rA, g8rc:$rB))]>,
783 isPPC64, Requires<[HasExtDiv]>;
785 let Predicates = [IsISA3_0] in {
786 def MADDHD : VAForm_1a<48, (outs g8rc :$RT), (ins g8rc:$RA, g8rc:$RB, g8rc:$RC),
787 "maddhd $RT, $RA, $RB, $RC", IIC_IntMulHD, []>, isPPC64;
788 def MADDHDU : VAForm_1a<49,
789 (outs g8rc :$RT), (ins g8rc:$RA, g8rc:$RB, g8rc:$RC),
790 "maddhdu $RT, $RA, $RB, $RC", IIC_IntMulHD, []>, isPPC64;
791 def MADDLD : VAForm_1a<51, (outs gprc :$RT), (ins gprc:$RA, gprc:$RB, gprc:$RC),
792 "maddld $RT, $RA, $RB, $RC", IIC_IntMulHD,
793 [(set i32:$RT, (add_without_simm16 (mul_without_simm16 i32:$RA, i32:$RB), i32:$RC))]>,
795 def SETB : XForm_44<31, 128, (outs gprc:$RT), (ins crrc:$BFA),
796 "setb $RT, $BFA", IIC_IntGeneral>, isPPC64;
797 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
798 def MADDLD8 : VAForm_1a<51,
799 (outs g8rc :$RT), (ins g8rc:$RA, g8rc:$RB, g8rc:$RC),
800 "maddld $RT, $RA, $RB, $RC", IIC_IntMulHD,
801 [(set i64:$RT, (add_without_simm16 (mul_without_simm16 i64:$RA, i64:$RB), i64:$RC))]>,
803 def SETB8 : XForm_44<31, 128, (outs g8rc:$RT), (ins crrc:$BFA),
804 "setb $RT, $BFA", IIC_IntGeneral>, isPPC64;
806 def DARN : XForm_45<31, 755, (outs g8rc:$RT), (ins i32imm:$L),
807 "darn $RT, $L", IIC_LdStLD>, isPPC64;
808 def ADDPCIS : DXForm<19, 2, (outs g8rc:$RT), (ins i32imm:$D),
809 "addpcis $RT, $D", IIC_BrB, []>, isPPC64;
810 def MODSD : XForm_8<31, 777, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
811 "modsd $rT, $rA, $rB", IIC_IntDivW,
812 [(set i64:$rT, (srem i64:$rA, i64:$rB))]>;
813 def MODUD : XForm_8<31, 265, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
814 "modud $rT, $rA, $rB", IIC_IntDivW,
815 [(set i64:$rT, (urem i64:$rA, i64:$rB))]>;
819 def DIVDEo : XOForm_1<31, 425, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
820 "divde. $rT, $rA, $rB", IIC_IntDivD,
821 []>, isDOT, PPC970_DGroup_Cracked, PPC970_DGroup_First,
822 isPPC64, Requires<[HasExtDiv]>;
823 def DIVDEU : XOForm_1<31, 393, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
824 "divdeu $rT, $rA, $rB", IIC_IntDivD,
825 [(set i64:$rT, (int_ppc_divdeu g8rc:$rA, g8rc:$rB))]>,
826 isPPC64, Requires<[HasExtDiv]>;
828 def DIVDEUo : XOForm_1<31, 393, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
829 "divdeu. $rT, $rA, $rB", IIC_IntDivD,
830 []>, isDOT, PPC970_DGroup_Cracked, PPC970_DGroup_First,
831 isPPC64, Requires<[HasExtDiv]>;
832 let isCommutable = 1 in
833 defm MULLD : XOForm_1r<31, 233, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
834 "mulld", "$rT, $rA, $rB", IIC_IntMulHD,
835 [(set i64:$rT, (mul i64:$rA, i64:$rB))]>, isPPC64;
836 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
837 def MULLI8 : DForm_2<7, (outs g8rc:$rD), (ins g8rc:$rA, s16imm64:$imm),
838 "mulli $rD, $rA, $imm", IIC_IntMulLI,
839 [(set i64:$rD, (mul i64:$rA, imm64SExt16:$imm))]>;
842 let hasSideEffects = 0 in {
843 defm RLDIMI : MDForm_1r<30, 3, (outs g8rc:$rA),
844 (ins g8rc:$rSi, g8rc:$rS, u6imm:$SH, u6imm:$MBE),
845 "rldimi", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
846 []>, isPPC64, RegConstraint<"$rSi = $rA">,
849 // Rotate instructions.
850 defm RLDCL : MDSForm_1r<30, 8,
851 (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB, u6imm:$MBE),
852 "rldcl", "$rA, $rS, $rB, $MBE", IIC_IntRotateD,
854 defm RLDCR : MDSForm_1r<30, 9,
855 (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB, u6imm:$MBE),
856 "rldcr", "$rA, $rS, $rB, $MBE", IIC_IntRotateD,
858 defm RLDICL : MDForm_1r<30, 0,
859 (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH, u6imm:$MBE),
860 "rldicl", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
863 let isCodeGenOnly = 1 in
864 def RLDICL_32_64 : MDForm_1<30, 0,
866 (ins gprc:$rS, u6imm:$SH, u6imm:$MBE),
867 "rldicl $rA, $rS, $SH, $MBE", IIC_IntRotateDI,
870 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
871 defm RLDICL_32 : MDForm_1r<30, 0,
873 (ins gprc:$rS, u6imm:$SH, u6imm:$MBE),
874 "rldicl", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
876 defm RLDICR : MDForm_1r<30, 1,
877 (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH, u6imm:$MBE),
878 "rldicr", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
880 let isCodeGenOnly = 1 in
881 def RLDICR_32 : MDForm_1<30, 1,
882 (outs gprc:$rA), (ins gprc:$rS, u6imm:$SH, u6imm:$MBE),
883 "rldicr $rA, $rS, $SH, $MBE", IIC_IntRotateDI,
885 defm RLDIC : MDForm_1r<30, 2,
886 (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH, u6imm:$MBE),
887 "rldic", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
890 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
891 defm RLWINM8 : MForm_2r<21, (outs g8rc:$rA),
892 (ins g8rc:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
893 "rlwinm", "$rA, $rS, $SH, $MB, $ME", IIC_IntGeneral,
896 defm RLWNM8 : MForm_2r<23, (outs g8rc:$rA),
897 (ins g8rc:$rS, g8rc:$rB, u5imm:$MB, u5imm:$ME),
898 "rlwnm", "$rA, $rS, $rB, $MB, $ME", IIC_IntGeneral,
901 // RLWIMI can be commuted if the rotate amount is zero.
902 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
903 defm RLWIMI8 : MForm_2r<20, (outs g8rc:$rA),
904 (ins g8rc:$rSi, g8rc:$rS, u5imm:$SH, u5imm:$MB,
905 u5imm:$ME), "rlwimi", "$rA, $rS, $SH, $MB, $ME",
906 IIC_IntRotate, []>, PPC970_DGroup_Cracked,
907 RegConstraint<"$rSi = $rA">, NoEncode<"$rSi">;
910 def ISEL8 : AForm_4<31, 15,
911 (outs g8rc:$rT), (ins g8rc_nox0:$rA, g8rc:$rB, crbitrc:$cond),
912 "isel $rT, $rA, $rB, $cond", IIC_IntISEL,
914 } // Interpretation64Bit
915 } // hasSideEffects = 0
916 } // End FXU Operations.
919 //===----------------------------------------------------------------------===//
920 // Load/Store instructions.
924 // Sign extending loads.
925 let PPC970_Unit = 2 in {
926 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
927 def LHA8: DForm_1<42, (outs g8rc:$rD), (ins memri:$src),
928 "lha $rD, $src", IIC_LdStLHA,
929 [(set i64:$rD, (sextloadi16 iaddr:$src))]>,
930 PPC970_DGroup_Cracked;
931 def LWA : DSForm_1<58, 2, (outs g8rc:$rD), (ins memrix:$src),
932 "lwa $rD, $src", IIC_LdStLWA,
934 (aligned4sextloadi32 iaddrX4:$src))]>, isPPC64,
935 PPC970_DGroup_Cracked;
936 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
937 def LHAX8: XForm_1_memOp<31, 343, (outs g8rc:$rD), (ins memrr:$src),
938 "lhax $rD, $src", IIC_LdStLHA,
939 [(set i64:$rD, (sextloadi16 xaddr:$src))]>,
940 PPC970_DGroup_Cracked;
941 def LWAX : XForm_1_memOp<31, 341, (outs g8rc:$rD), (ins memrr:$src),
942 "lwax $rD, $src", IIC_LdStLHA,
943 [(set i64:$rD, (sextloadi32 xaddrX4:$src))]>, isPPC64,
944 PPC970_DGroup_Cracked;
946 let isCodeGenOnly = 1, mayLoad = 1 in {
947 def LWA_32 : DSForm_1<58, 2, (outs gprc:$rD), (ins memrix:$src),
948 "lwa $rD, $src", IIC_LdStLWA, []>, isPPC64,
949 PPC970_DGroup_Cracked;
950 def LWAX_32 : XForm_1_memOp<31, 341, (outs gprc:$rD), (ins memrr:$src),
951 "lwax $rD, $src", IIC_LdStLHA, []>, isPPC64,
952 PPC970_DGroup_Cracked;
953 } // end fast-isel isCodeGenOnly
956 let mayLoad = 1, hasSideEffects = 0 in {
957 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
958 def LHAU8 : DForm_1<43, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
960 "lhau $rD, $addr", IIC_LdStLHAU,
961 []>, RegConstraint<"$addr.reg = $ea_result">,
962 NoEncode<"$ea_result">;
965 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
966 def LHAUX8 : XForm_1_memOp<31, 375, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
968 "lhaux $rD, $addr", IIC_LdStLHAUX,
969 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
970 NoEncode<"$ea_result">;
971 def LWAUX : XForm_1_memOp<31, 373, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
973 "lwaux $rD, $addr", IIC_LdStLHAUX,
974 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
975 NoEncode<"$ea_result">, isPPC64;
979 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
980 // Zero extending loads.
981 let PPC970_Unit = 2 in {
982 def LBZ8 : DForm_1<34, (outs g8rc:$rD), (ins memri:$src),
983 "lbz $rD, $src", IIC_LdStLoad,
984 [(set i64:$rD, (zextloadi8 iaddr:$src))]>;
985 def LHZ8 : DForm_1<40, (outs g8rc:$rD), (ins memri:$src),
986 "lhz $rD, $src", IIC_LdStLoad,
987 [(set i64:$rD, (zextloadi16 iaddr:$src))]>;
988 def LWZ8 : DForm_1<32, (outs g8rc:$rD), (ins memri:$src),
989 "lwz $rD, $src", IIC_LdStLoad,
990 [(set i64:$rD, (zextloadi32 iaddr:$src))]>, isPPC64;
992 def LBZX8 : XForm_1_memOp<31, 87, (outs g8rc:$rD), (ins memrr:$src),
993 "lbzx $rD, $src", IIC_LdStLoad,
994 [(set i64:$rD, (zextloadi8 xaddr:$src))]>;
995 def LHZX8 : XForm_1_memOp<31, 279, (outs g8rc:$rD), (ins memrr:$src),
996 "lhzx $rD, $src", IIC_LdStLoad,
997 [(set i64:$rD, (zextloadi16 xaddr:$src))]>;
998 def LWZX8 : XForm_1_memOp<31, 23, (outs g8rc:$rD), (ins memrr:$src),
999 "lwzx $rD, $src", IIC_LdStLoad,
1000 [(set i64:$rD, (zextloadi32 xaddr:$src))]>;
1004 let mayLoad = 1, hasSideEffects = 0 in {
1005 def LBZU8 : DForm_1<35, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
1007 "lbzu $rD, $addr", IIC_LdStLoadUpd,
1008 []>, RegConstraint<"$addr.reg = $ea_result">,
1009 NoEncode<"$ea_result">;
1010 def LHZU8 : DForm_1<41, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
1012 "lhzu $rD, $addr", IIC_LdStLoadUpd,
1013 []>, RegConstraint<"$addr.reg = $ea_result">,
1014 NoEncode<"$ea_result">;
1015 def LWZU8 : DForm_1<33, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
1017 "lwzu $rD, $addr", IIC_LdStLoadUpd,
1018 []>, RegConstraint<"$addr.reg = $ea_result">,
1019 NoEncode<"$ea_result">;
1021 def LBZUX8 : XForm_1_memOp<31, 119, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
1023 "lbzux $rD, $addr", IIC_LdStLoadUpdX,
1024 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1025 NoEncode<"$ea_result">;
1026 def LHZUX8 : XForm_1_memOp<31, 311, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
1028 "lhzux $rD, $addr", IIC_LdStLoadUpdX,
1029 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1030 NoEncode<"$ea_result">;
1031 def LWZUX8 : XForm_1_memOp<31, 55, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
1033 "lwzux $rD, $addr", IIC_LdStLoadUpdX,
1034 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1035 NoEncode<"$ea_result">;
1038 } // Interpretation64Bit
1041 // Full 8-byte loads.
1042 let PPC970_Unit = 2 in {
1043 def LD : DSForm_1<58, 0, (outs g8rc:$rD), (ins memrix:$src),
1044 "ld $rD, $src", IIC_LdStLD,
1045 [(set i64:$rD, (aligned4load iaddrX4:$src))]>, isPPC64;
1046 // The following four definitions are selected for small code model only.
1047 // Otherwise, we need to create two instructions to form a 32-bit offset,
1048 // so we have a custom matcher for TOC_ENTRY in PPCDAGToDAGIsel::Select().
1049 def LDtoc: PPCEmitTimePseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
1052 (PPCtoc_entry tglobaladdr:$disp, i64:$reg))]>, isPPC64;
1053 def LDtocJTI: PPCEmitTimePseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
1056 (PPCtoc_entry tjumptable:$disp, i64:$reg))]>, isPPC64;
1057 def LDtocCPT: PPCEmitTimePseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
1060 (PPCtoc_entry tconstpool:$disp, i64:$reg))]>, isPPC64;
1061 def LDtocBA: PPCEmitTimePseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
1064 (PPCtoc_entry tblockaddress:$disp, i64:$reg))]>, isPPC64;
1066 def LDX : XForm_1_memOp<31, 21, (outs g8rc:$rD), (ins memrr:$src),
1067 "ldx $rD, $src", IIC_LdStLD,
1068 [(set i64:$rD, (load xaddrX4:$src))]>, isPPC64;
1069 def LDBRX : XForm_1_memOp<31, 532, (outs g8rc:$rD), (ins memrr:$src),
1070 "ldbrx $rD, $src", IIC_LdStLoad,
1071 [(set i64:$rD, (PPClbrx xoaddr:$src, i64))]>, isPPC64;
1073 let mayLoad = 1, hasSideEffects = 0, isCodeGenOnly = 1 in {
1074 def LHBRX8 : XForm_1_memOp<31, 790, (outs g8rc:$rD), (ins memrr:$src),
1075 "lhbrx $rD, $src", IIC_LdStLoad, []>;
1076 def LWBRX8 : XForm_1_memOp<31, 534, (outs g8rc:$rD), (ins memrr:$src),
1077 "lwbrx $rD, $src", IIC_LdStLoad, []>;
1080 let mayLoad = 1, hasSideEffects = 0 in {
1081 def LDU : DSForm_1<58, 1, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
1083 "ldu $rD, $addr", IIC_LdStLDU,
1084 []>, RegConstraint<"$addr.reg = $ea_result">, isPPC64,
1085 NoEncode<"$ea_result">;
1087 def LDUX : XForm_1_memOp<31, 53, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
1089 "ldux $rD, $addr", IIC_LdStLDUX,
1090 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1091 NoEncode<"$ea_result">, isPPC64;
1093 def LDMX : XForm_1<31, 309, (outs g8rc:$rD), (ins memrr:$src),
1094 "ldmx $rD, $src", IIC_LdStLD, []>, isPPC64,
1095 Requires<[IsISA3_0]>;
1099 // Support for medium and large code model.
1100 let hasSideEffects = 0 in {
1101 let isReMaterializable = 1 in {
1102 def ADDIStocHA8: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, tocentry:$disp),
1103 "#ADDIStocHA8", []>, isPPC64;
1104 def ADDItocL: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, tocentry:$disp),
1105 "#ADDItocL", []>, isPPC64;
1108 def LDtocL: PPCEmitTimePseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc_nox0:$reg),
1109 "#LDtocL", []>, isPPC64;
1112 // Support for thread-local storage.
1113 def ADDISgotTprelHA: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
1116 (PPCaddisGotTprelHA i64:$reg,
1117 tglobaltlsaddr:$disp))]>,
1119 def LDgotTprelL: PPCEmitTimePseudo<(outs g8rc:$rD), (ins s16imm64:$disp, g8rc_nox0:$reg),
1122 (PPCldGotTprelL tglobaltlsaddr:$disp, i64:$reg))]>,
1125 let Defs = [CR7], Itinerary = IIC_LdStSync in
1126 def CFENCE8 : PPCPostRAExpPseudo<(outs), (ins g8rc:$cr), "#CFENCE8", []>;
1128 def : Pat<(PPCaddTls i64:$in, tglobaltlsaddr:$g),
1129 (ADD8TLS $in, tglobaltlsaddr:$g)>;
1130 def ADDIStlsgdHA: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
1133 (PPCaddisTlsgdHA i64:$reg, tglobaltlsaddr:$disp))]>,
1135 def ADDItlsgdL : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
1138 (PPCaddiTlsgdL i64:$reg, tglobaltlsaddr:$disp))]>,
1140 // LR8 is a true define, while the rest of the Defs are clobbers. X3 is
1141 // explicitly defined when this op is created, so not mentioned here.
1142 // This is lowered to BL8_NOP_TLS by the assembly printer, so the size must be
1143 // correct because the branch select pass is relying on it.
1144 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1, Size = 8,
1145 Defs = [X0,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7] in
1146 def GETtlsADDR : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc:$reg, tlsgd:$sym),
1149 (PPCgetTlsAddr i64:$reg, tglobaltlsaddr:$sym))]>,
1151 // Combined op for ADDItlsgdL and GETtlsADDR, late expanded. X3 and LR8
1152 // are true defines while the rest of the Defs are clobbers.
1153 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
1154 Defs = [X0,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7]
1156 def ADDItlsgdLADDR : PPCEmitTimePseudo<(outs g8rc:$rD),
1157 (ins g8rc_nox0:$reg, s16imm64:$disp, tlsgd:$sym),
1160 (PPCaddiTlsgdLAddr i64:$reg,
1161 tglobaltlsaddr:$disp,
1162 tglobaltlsaddr:$sym))]>,
1164 def ADDIStlsldHA: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
1167 (PPCaddisTlsldHA i64:$reg, tglobaltlsaddr:$disp))]>,
1169 def ADDItlsldL : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
1172 (PPCaddiTlsldL i64:$reg, tglobaltlsaddr:$disp))]>,
1174 // LR8 is a true define, while the rest of the Defs are clobbers. X3 is
1175 // explicitly defined when this op is created, so not mentioned here.
1176 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
1177 Defs = [X0,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7] in
1178 def GETtlsldADDR : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc:$reg, tlsgd:$sym),
1181 (PPCgetTlsldAddr i64:$reg, tglobaltlsaddr:$sym))]>,
1183 // Combined op for ADDItlsldL and GETtlsADDR, late expanded. X3 and LR8
1184 // are true defines, while the rest of the Defs are clobbers.
1185 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
1186 Defs = [X0,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7]
1188 def ADDItlsldLADDR : PPCEmitTimePseudo<(outs g8rc:$rD),
1189 (ins g8rc_nox0:$reg, s16imm64:$disp, tlsgd:$sym),
1192 (PPCaddiTlsldLAddr i64:$reg,
1193 tglobaltlsaddr:$disp,
1194 tglobaltlsaddr:$sym))]>,
1196 def ADDISdtprelHA: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
1199 (PPCaddisDtprelHA i64:$reg,
1200 tglobaltlsaddr:$disp))]>,
1202 def ADDIdtprelL : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
1205 (PPCaddiDtprelL i64:$reg, tglobaltlsaddr:$disp))]>,
1208 let PPC970_Unit = 2 in {
1209 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
1210 // Truncating stores.
1211 def STB8 : DForm_1<38, (outs), (ins g8rc:$rS, memri:$src),
1212 "stb $rS, $src", IIC_LdStStore,
1213 [(truncstorei8 i64:$rS, iaddr:$src)]>;
1214 def STH8 : DForm_1<44, (outs), (ins g8rc:$rS, memri:$src),
1215 "sth $rS, $src", IIC_LdStStore,
1216 [(truncstorei16 i64:$rS, iaddr:$src)]>;
1217 def STW8 : DForm_1<36, (outs), (ins g8rc:$rS, memri:$src),
1218 "stw $rS, $src", IIC_LdStStore,
1219 [(truncstorei32 i64:$rS, iaddr:$src)]>;
1220 def STBX8 : XForm_8_memOp<31, 215, (outs), (ins g8rc:$rS, memrr:$dst),
1221 "stbx $rS, $dst", IIC_LdStStore,
1222 [(truncstorei8 i64:$rS, xaddr:$dst)]>,
1223 PPC970_DGroup_Cracked;
1224 def STHX8 : XForm_8_memOp<31, 407, (outs), (ins g8rc:$rS, memrr:$dst),
1225 "sthx $rS, $dst", IIC_LdStStore,
1226 [(truncstorei16 i64:$rS, xaddr:$dst)]>,
1227 PPC970_DGroup_Cracked;
1228 def STWX8 : XForm_8_memOp<31, 151, (outs), (ins g8rc:$rS, memrr:$dst),
1229 "stwx $rS, $dst", IIC_LdStStore,
1230 [(truncstorei32 i64:$rS, xaddr:$dst)]>,
1231 PPC970_DGroup_Cracked;
1232 } // Interpretation64Bit
1234 // Normal 8-byte stores.
1235 def STD : DSForm_1<62, 0, (outs), (ins g8rc:$rS, memrix:$dst),
1236 "std $rS, $dst", IIC_LdStSTD,
1237 [(aligned4store i64:$rS, iaddrX4:$dst)]>, isPPC64;
1238 def STDX : XForm_8_memOp<31, 149, (outs), (ins g8rc:$rS, memrr:$dst),
1239 "stdx $rS, $dst", IIC_LdStSTD,
1240 [(store i64:$rS, xaddrX4:$dst)]>, isPPC64,
1241 PPC970_DGroup_Cracked;
1242 def STDBRX: XForm_8_memOp<31, 660, (outs), (ins g8rc:$rS, memrr:$dst),
1243 "stdbrx $rS, $dst", IIC_LdStStore,
1244 [(PPCstbrx i64:$rS, xoaddr:$dst, i64)]>, isPPC64,
1245 PPC970_DGroup_Cracked;
1248 // Stores with Update (pre-inc).
1249 let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in {
1250 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
1251 def STBU8 : DForm_1<39, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memri:$dst),
1252 "stbu $rS, $dst", IIC_LdStSTU, []>,
1253 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
1254 def STHU8 : DForm_1<45, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memri:$dst),
1255 "sthu $rS, $dst", IIC_LdStSTU, []>,
1256 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
1257 def STWU8 : DForm_1<37, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memri:$dst),
1258 "stwu $rS, $dst", IIC_LdStSTU, []>,
1259 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
1261 def STBUX8: XForm_8_memOp<31, 247, (outs ptr_rc_nor0:$ea_res),
1262 (ins g8rc:$rS, memrr:$dst),
1263 "stbux $rS, $dst", IIC_LdStSTUX, []>,
1264 RegConstraint<"$dst.ptrreg = $ea_res">,
1265 NoEncode<"$ea_res">,
1266 PPC970_DGroup_Cracked;
1267 def STHUX8: XForm_8_memOp<31, 439, (outs ptr_rc_nor0:$ea_res),
1268 (ins g8rc:$rS, memrr:$dst),
1269 "sthux $rS, $dst", IIC_LdStSTUX, []>,
1270 RegConstraint<"$dst.ptrreg = $ea_res">,
1271 NoEncode<"$ea_res">,
1272 PPC970_DGroup_Cracked;
1273 def STWUX8: XForm_8_memOp<31, 183, (outs ptr_rc_nor0:$ea_res),
1274 (ins g8rc:$rS, memrr:$dst),
1275 "stwux $rS, $dst", IIC_LdStSTUX, []>,
1276 RegConstraint<"$dst.ptrreg = $ea_res">,
1277 NoEncode<"$ea_res">,
1278 PPC970_DGroup_Cracked;
1279 } // Interpretation64Bit
1281 def STDU : DSForm_1<62, 1, (outs ptr_rc_nor0:$ea_res),
1282 (ins g8rc:$rS, memrix:$dst),
1283 "stdu $rS, $dst", IIC_LdStSTU, []>,
1284 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">,
1287 def STDUX : XForm_8_memOp<31, 181, (outs ptr_rc_nor0:$ea_res),
1288 (ins g8rc:$rS, memrr:$dst),
1289 "stdux $rS, $dst", IIC_LdStSTUX, []>,
1290 RegConstraint<"$dst.ptrreg = $ea_res">,
1291 NoEncode<"$ea_res">,
1292 PPC970_DGroup_Cracked, isPPC64;
1295 // Patterns to match the pre-inc stores. We can't put the patterns on
1296 // the instruction definitions directly as ISel wants the address base
1297 // and offset to be separate operands, not a single complex operand.
1298 def : Pat<(pre_truncsti8 i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1299 (STBU8 $rS, iaddroff:$ptroff, $ptrreg)>;
1300 def : Pat<(pre_truncsti16 i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1301 (STHU8 $rS, iaddroff:$ptroff, $ptrreg)>;
1302 def : Pat<(pre_truncsti32 i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1303 (STWU8 $rS, iaddroff:$ptroff, $ptrreg)>;
1304 def : Pat<(aligned4pre_store i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1305 (STDU $rS, iaddroff:$ptroff, $ptrreg)>;
1307 def : Pat<(pre_truncsti8 i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1308 (STBUX8 $rS, $ptrreg, $ptroff)>;
1309 def : Pat<(pre_truncsti16 i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1310 (STHUX8 $rS, $ptrreg, $ptroff)>;
1311 def : Pat<(pre_truncsti32 i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1312 (STWUX8 $rS, $ptrreg, $ptroff)>;
1313 def : Pat<(pre_store i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1314 (STDUX $rS, $ptrreg, $ptroff)>;
1317 //===----------------------------------------------------------------------===//
1318 // Floating point instructions.
1322 let PPC970_Unit = 3, hasSideEffects = 0,
1323 Uses = [RM] in { // FPU Operations.
1324 defm FCFID : XForm_26r<63, 846, (outs f8rc:$frD), (ins f8rc:$frB),
1325 "fcfid", "$frD, $frB", IIC_FPGeneral,
1326 [(set f64:$frD, (PPCfcfid f64:$frB))]>, isPPC64;
1327 defm FCTID : XForm_26r<63, 814, (outs f8rc:$frD), (ins f8rc:$frB),
1328 "fctid", "$frD, $frB", IIC_FPGeneral,
1330 defm FCTIDU : XForm_26r<63, 942, (outs f8rc:$frD), (ins f8rc:$frB),
1331 "fctidu", "$frD, $frB", IIC_FPGeneral,
1333 defm FCTIDZ : XForm_26r<63, 815, (outs f8rc:$frD), (ins f8rc:$frB),
1334 "fctidz", "$frD, $frB", IIC_FPGeneral,
1335 [(set f64:$frD, (PPCfctidz f64:$frB))]>, isPPC64;
1337 defm FCFIDU : XForm_26r<63, 974, (outs f8rc:$frD), (ins f8rc:$frB),
1338 "fcfidu", "$frD, $frB", IIC_FPGeneral,
1339 [(set f64:$frD, (PPCfcfidu f64:$frB))]>, isPPC64;
1340 defm FCFIDS : XForm_26r<59, 846, (outs f4rc:$frD), (ins f8rc:$frB),
1341 "fcfids", "$frD, $frB", IIC_FPGeneral,
1342 [(set f32:$frD, (PPCfcfids f64:$frB))]>, isPPC64;
1343 defm FCFIDUS : XForm_26r<59, 974, (outs f4rc:$frD), (ins f8rc:$frB),
1344 "fcfidus", "$frD, $frB", IIC_FPGeneral,
1345 [(set f32:$frD, (PPCfcfidus f64:$frB))]>, isPPC64;
1346 defm FCTIDUZ : XForm_26r<63, 943, (outs f8rc:$frD), (ins f8rc:$frB),
1347 "fctiduz", "$frD, $frB", IIC_FPGeneral,
1348 [(set f64:$frD, (PPCfctiduz f64:$frB))]>, isPPC64;
1349 defm FCTIWUZ : XForm_26r<63, 143, (outs f8rc:$frD), (ins f8rc:$frB),
1350 "fctiwuz", "$frD, $frB", IIC_FPGeneral,
1351 [(set f64:$frD, (PPCfctiwuz f64:$frB))]>, isPPC64;
1355 //===----------------------------------------------------------------------===//
1356 // Instruction Patterns
1359 // Extensions and truncates to/from 32-bit regs.
1360 def : Pat<(i64 (zext i32:$in)),
1361 (RLDICL (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $in, sub_32),
1363 def : Pat<(i64 (anyext i32:$in)),
1364 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $in, sub_32)>;
1365 def : Pat<(i32 (trunc i64:$in)),
1366 (EXTRACT_SUBREG $in, sub_32)>;
1368 // Implement the 'not' operation with the NOR instruction.
1369 // (we could use the default xori pattern, but nor has lower latency on some
1370 // cores (such as the A2)).
1371 def i64not : OutPatFrag<(ops node:$in),
1373 def : Pat<(not i64:$in),
1376 // Extending loads with i64 targets.
1377 def : Pat<(zextloadi1 iaddr:$src),
1379 def : Pat<(zextloadi1 xaddr:$src),
1380 (LBZX8 xaddr:$src)>;
1381 def : Pat<(extloadi1 iaddr:$src),
1383 def : Pat<(extloadi1 xaddr:$src),
1384 (LBZX8 xaddr:$src)>;
1385 def : Pat<(extloadi8 iaddr:$src),
1387 def : Pat<(extloadi8 xaddr:$src),
1388 (LBZX8 xaddr:$src)>;
1389 def : Pat<(extloadi16 iaddr:$src),
1391 def : Pat<(extloadi16 xaddr:$src),
1392 (LHZX8 xaddr:$src)>;
1393 def : Pat<(extloadi32 iaddr:$src),
1395 def : Pat<(extloadi32 xaddr:$src),
1396 (LWZX8 xaddr:$src)>;
1398 // Standard shifts. These are represented separately from the real shifts above
1399 // so that we can distinguish between shifts that allow 6-bit and 7-bit shift
1401 def : Pat<(sra i64:$rS, i32:$rB),
1403 def : Pat<(srl i64:$rS, i32:$rB),
1405 def : Pat<(shl i64:$rS, i32:$rB),
1409 def : Pat<(sub imm64SExt16:$imm, i64:$in),
1410 (SUBFIC8 $in, imm:$imm)>;
1413 def : Pat<(shl i64:$in, (i32 imm:$imm)),
1414 (RLDICR $in, imm:$imm, (SHL64 imm:$imm))>;
1415 def : Pat<(srl i64:$in, (i32 imm:$imm)),
1416 (RLDICL $in, (SRL64 imm:$imm), imm:$imm)>;
1419 def : Pat<(rotl i64:$in, i32:$sh),
1420 (RLDCL $in, $sh, 0)>;
1421 def : Pat<(rotl i64:$in, (i32 imm:$imm)),
1422 (RLDICL $in, imm:$imm, 0)>;
1424 // Hi and Lo for Darwin Global Addresses.
1425 def : Pat<(PPChi tglobaladdr:$in, 0), (LIS8 tglobaladdr:$in)>;
1426 def : Pat<(PPClo tglobaladdr:$in, 0), (LI8 tglobaladdr:$in)>;
1427 def : Pat<(PPChi tconstpool:$in , 0), (LIS8 tconstpool:$in)>;
1428 def : Pat<(PPClo tconstpool:$in , 0), (LI8 tconstpool:$in)>;
1429 def : Pat<(PPChi tjumptable:$in , 0), (LIS8 tjumptable:$in)>;
1430 def : Pat<(PPClo tjumptable:$in , 0), (LI8 tjumptable:$in)>;
1431 def : Pat<(PPChi tblockaddress:$in, 0), (LIS8 tblockaddress:$in)>;
1432 def : Pat<(PPClo tblockaddress:$in, 0), (LI8 tblockaddress:$in)>;
1433 def : Pat<(PPChi tglobaltlsaddr:$g, i64:$in),
1434 (ADDIS8 $in, tglobaltlsaddr:$g)>;
1435 def : Pat<(PPClo tglobaltlsaddr:$g, i64:$in),
1436 (ADDI8 $in, tglobaltlsaddr:$g)>;
1437 def : Pat<(add i64:$in, (PPChi tglobaladdr:$g, 0)),
1438 (ADDIS8 $in, tglobaladdr:$g)>;
1439 def : Pat<(add i64:$in, (PPChi tconstpool:$g, 0)),
1440 (ADDIS8 $in, tconstpool:$g)>;
1441 def : Pat<(add i64:$in, (PPChi tjumptable:$g, 0)),
1442 (ADDIS8 $in, tjumptable:$g)>;
1443 def : Pat<(add i64:$in, (PPChi tblockaddress:$g, 0)),
1444 (ADDIS8 $in, tblockaddress:$g)>;
1446 // Patterns to match r+r indexed loads and stores for
1447 // addresses without at least 4-byte alignment.
1448 def : Pat<(i64 (unaligned4sextloadi32 xoaddr:$src)),
1449 (LWAX xoaddr:$src)>;
1450 def : Pat<(i64 (unaligned4load xoaddr:$src)),
1452 def : Pat<(unaligned4store i64:$rS, xoaddr:$dst),
1453 (STDX $rS, xoaddr:$dst)>;
1455 // 64-bits atomic loads and stores
1456 def : Pat<(atomic_load_64 iaddrX4:$src), (LD memrix:$src)>;
1457 def : Pat<(atomic_load_64 xaddrX4:$src), (LDX memrr:$src)>;
1459 def : Pat<(atomic_store_64 iaddrX4:$ptr, i64:$val), (STD g8rc:$val, memrix:$ptr)>;
1460 def : Pat<(atomic_store_64 xaddrX4:$ptr, i64:$val), (STDX g8rc:$val, memrr:$ptr)>;
1462 let Predicates = [IsISA3_0] in {
1464 class X_L1_RA5_RB5<bits<6> opcode, bits<10> xo, string opc, RegisterOperand ty,
1465 InstrItinClass itin, list<dag> pattern>
1466 : X_L1_RS5_RS5<opcode, xo, (outs), (ins ty:$rA, ty:$rB, u1imm:$L),
1467 !strconcat(opc, " $rA, $rB, $L"), itin, pattern>;
1469 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
1470 def CP_COPY8 : X_L1_RA5_RB5<31, 774, "copy" , g8rc, IIC_LdStCOPY, []>;
1471 def CP_PASTE8 : X_L1_RA5_RB5<31, 902, "paste" , g8rc, IIC_LdStPASTE, []>;
1472 def CP_PASTE8o : X_L1_RA5_RB5<31, 902, "paste.", g8rc, IIC_LdStPASTE, []>,isDOT;
1475 // SLB Invalidate Entry Global
1476 def SLBIEG : XForm_26<31, 466, (outs), (ins gprc:$RS, gprc:$RB),
1477 "slbieg $RS, $RB", IIC_SprSLBIEG, []>;
1479 def SLBSYNC : XForm_0<31, 338, (outs), (ins), "slbsync", IIC_SprSLBSYNC, []>;