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>";
22 let OperandType = "OPERAND_IMMEDIATE";
24 def u16imm64 : Operand<i64> {
25 let PrintMethod = "printU16ImmOperand";
26 let EncoderMethod = "getImm16Encoding";
27 let ParserMatchClass = PPCU16ImmAsmOperand;
28 let DecoderMethod = "decodeUImmOperand<16>";
29 let OperandType = "OPERAND_IMMEDIATE";
31 def s17imm64 : Operand<i64> {
32 // This operand type is used for addis/lis to allow the assembler parser
33 // to accept immediates in the range -65536..65535 for compatibility with
34 // the GNU assembler. The operand is treated as 16-bit otherwise.
35 let PrintMethod = "printS16ImmOperand";
36 let EncoderMethod = "getImm16Encoding";
37 let ParserMatchClass = PPCS17ImmAsmOperand;
38 let DecoderMethod = "decodeSImmOperand<16>";
39 let OperandType = "OPERAND_IMMEDIATE";
41 def tocentry : Operand<iPTR> {
42 let MIOperandInfo = (ops i64imm:$imm);
44 def tlsreg : Operand<i64> {
45 let EncoderMethod = "getTLSRegEncoding";
46 let ParserMatchClass = PPCTLSRegOperand;
48 def tlsgd : Operand<i64> {}
49 def tlscall : Operand<i64> {
50 let PrintMethod = "printTLSCall";
51 let MIOperandInfo = (ops calltarget:$func, tlsgd:$sym);
52 let EncoderMethod = "getTLSCallEncoding";
55 //===----------------------------------------------------------------------===//
56 // 64-bit transformation functions.
59 def SHL64 : SDNodeXForm<imm, [{
60 // Transformation function: 63 - imm
61 return getI32Imm(63 - N->getZExtValue(), SDLoc(N));
64 def SRL64 : SDNodeXForm<imm, [{
65 // Transformation function: 64 - imm
66 return N->getZExtValue() ? getI32Imm(64 - N->getZExtValue(), SDLoc(N))
67 : getI32Imm(0, SDLoc(N));
71 //===----------------------------------------------------------------------===//
75 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
76 let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7 in {
77 let isReturn = 1, isPredicable = 1, Uses = [LR8, RM] in
78 def BLR8 : XLForm_2_ext<19, 16, 20, 0, 0, (outs), (ins), "blr", IIC_BrB,
79 [(retflag)]>, Requires<[In64BitMode]>;
80 let isBranch = 1, isIndirectBranch = 1, Uses = [CTR8] in {
81 let isPredicable = 1 in
82 def BCTR8 : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
84 Requires<[In64BitMode]>;
85 def BCCCTR8 : XLForm_2_br<19, 528, 0, (outs), (ins pred:$cond),
86 "b${cond:cc}ctr${cond:pm} ${cond:reg}", IIC_BrB,
88 Requires<[In64BitMode]>;
90 def BCCTR8 : XLForm_2_br2<19, 528, 12, 0, (outs), (ins crbitrc:$bi),
91 "bcctr 12, $bi, 0", IIC_BrB, []>,
92 Requires<[In64BitMode]>;
93 def BCCTR8n : XLForm_2_br2<19, 528, 4, 0, (outs), (ins crbitrc:$bi),
94 "bcctr 4, $bi, 0", IIC_BrB, []>,
95 Requires<[In64BitMode]>;
100 def MovePCtoLR8 : PPCEmitTimePseudo<(outs), (ins), "#MovePCtoLR8", []>,
103 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7 in {
104 let Defs = [CTR8], Uses = [CTR8] in {
105 def BDZ8 : BForm_1<16, 18, 0, 0, (outs), (ins condbrtarget:$dst),
107 def BDNZ8 : BForm_1<16, 16, 0, 0, (outs), (ins condbrtarget:$dst),
111 let isReturn = 1, Defs = [CTR8], Uses = [CTR8, LR8, RM] in {
112 def BDZLR8 : XLForm_2_ext<19, 16, 18, 0, 0, (outs), (ins),
113 "bdzlr", IIC_BrB, []>;
114 def BDNZLR8 : XLForm_2_ext<19, 16, 16, 0, 0, (outs), (ins),
115 "bdnzlr", IIC_BrB, []>;
121 let isCall = 1, PPC970_Unit = 7, Defs = [LR8] in {
122 // Convenient aliases for call instructions
124 def BL8 : IForm<18, 0, 1, (outs), (ins calltarget:$func),
125 "bl $func", IIC_BrB, []>; // See Pat patterns below.
127 def BL8_TLS : IForm<18, 0, 1, (outs), (ins tlscall:$func),
128 "bl $func", IIC_BrB, []>;
130 def BLA8 : IForm<18, 1, 1, (outs), (ins abscalltarget:$func),
131 "bla $func", IIC_BrB, [(PPCcall (i64 imm:$func))]>;
133 let Uses = [RM], isCodeGenOnly = 1 in {
134 def BL8_NOP : IForm_and_DForm_4_zero<18, 0, 1, 24,
135 (outs), (ins calltarget:$func),
136 "bl $func\n\tnop", IIC_BrB, []>;
138 def BL8_NOP_TLS : IForm_and_DForm_4_zero<18, 0, 1, 24,
139 (outs), (ins tlscall:$func),
140 "bl $func\n\tnop", IIC_BrB, []>;
142 def BLA8_NOP : IForm_and_DForm_4_zero<18, 1, 1, 24,
143 (outs), (ins abscalltarget:$func),
144 "bla $func\n\tnop", IIC_BrB,
145 [(PPCcall_nop (i64 imm:$func))]>;
146 let Predicates = [PCRelativeMemops] in {
147 // BL8_NOTOC means that the caller does not use the TOC pointer and if
148 // it does use R2 then it is just a caller saved register. Therefore it is
149 // safe to emit only the bl and not the nop for this instruction. The
150 // linker will not try to restore R2 after the call.
151 def BL8_NOTOC : IForm<18, 0, 1, (outs),
152 (ins calltarget:$func),
153 "bl $func", IIC_BrB, []>;
154 def BL8_NOTOC_TLS : IForm<18, 0, 1, (outs),
156 "bl $func", IIC_BrB, []>;
159 let Uses = [CTR8, RM] in {
160 let isPredicable = 1 in
161 def BCTRL8 : XLForm_2_ext<19, 528, 20, 0, 1, (outs), (ins),
162 "bctrl", IIC_BrB, [(PPCbctrl)]>,
163 Requires<[In64BitMode]>;
165 let isCodeGenOnly = 1 in {
166 def BCCCTRL8 : XLForm_2_br<19, 528, 1, (outs), (ins pred:$cond),
167 "b${cond:cc}ctrl${cond:pm} ${cond:reg}", IIC_BrB,
169 Requires<[In64BitMode]>;
171 def BCCTRL8 : XLForm_2_br2<19, 528, 12, 1, (outs), (ins crbitrc:$bi),
172 "bcctrl 12, $bi, 0", IIC_BrB, []>,
173 Requires<[In64BitMode]>;
174 def BCCTRL8n : XLForm_2_br2<19, 528, 4, 1, (outs), (ins crbitrc:$bi),
175 "bcctrl 4, $bi, 0", IIC_BrB, []>,
176 Requires<[In64BitMode]>;
181 let isCall = 1, PPC970_Unit = 7, isCodeGenOnly = 1,
182 Defs = [LR8, X2], Uses = [CTR8, RM], RST = 2 in {
183 def BCTRL8_LDinto_toc :
184 XLForm_2_ext_and_DSForm_1<19, 528, 20, 0, 1, 58, 0, (outs),
186 "bctrl\n\tld 2, $src", IIC_BrB,
187 [(PPCbctrl_load_toc iaddrX4:$src)]>,
188 Requires<[In64BitMode]>;
191 } // Interpretation64Bit
193 // FIXME: Duplicating this for the asm parser should be unnecessary, but the
194 // previous definition must be marked as CodeGen only to prevent decoding
196 let Interpretation64Bit = 1, isAsmParserOnly = 1 in
197 let isCall = 1, PPC970_Unit = 7, Defs = [LR8], Uses = [RM] in
198 def BL8_TLS_ : IForm<18, 0, 1, (outs), (ins tlscall:$func),
199 "bl $func", IIC_BrB, []>;
202 def : Pat<(PPCcall (i64 tglobaladdr:$dst)),
203 (BL8 tglobaladdr:$dst)>;
204 def : Pat<(PPCcall_nop (i64 tglobaladdr:$dst)),
205 (BL8_NOP tglobaladdr:$dst)>;
207 def : Pat<(PPCcall (i64 texternalsym:$dst)),
208 (BL8 texternalsym:$dst)>;
209 def : Pat<(PPCcall_nop (i64 texternalsym:$dst)),
210 (BL8_NOP texternalsym:$dst)>;
212 def : Pat<(PPCcall_notoc (i64 tglobaladdr:$dst)),
213 (BL8_NOTOC tglobaladdr:$dst)>;
214 def : Pat<(PPCcall_notoc (i64 texternalsym:$dst)),
215 (BL8_NOTOC texternalsym:$dst)>;
218 def : Pat<(PPCcall (i64 mcsym:$dst)),
220 def : Pat<(PPCcall_nop (i64 mcsym:$dst)),
221 (BL8_NOP mcsym:$dst)>;
224 // FIXME: some of these might be used with constant operands. This will result
225 // in constant materialization instructions that may be redundant. We currently
226 // clean this up in PPCMIPeephole with calls to
227 // PPCInstrInfo::convertToImmediateForm() but we should probably not emit them
228 // in the first place.
229 let Defs = [CR0] in {
230 def ATOMIC_LOAD_ADD_I64 : PPCCustomInserterPseudo<
231 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_ADD_I64",
232 [(set i64:$dst, (atomic_load_add_64 ForceXForm:$ptr, i64:$incr))]>;
233 def ATOMIC_LOAD_SUB_I64 : PPCCustomInserterPseudo<
234 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_SUB_I64",
235 [(set i64:$dst, (atomic_load_sub_64 ForceXForm:$ptr, i64:$incr))]>;
236 def ATOMIC_LOAD_OR_I64 : PPCCustomInserterPseudo<
237 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_OR_I64",
238 [(set i64:$dst, (atomic_load_or_64 ForceXForm:$ptr, i64:$incr))]>;
239 def ATOMIC_LOAD_XOR_I64 : PPCCustomInserterPseudo<
240 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_XOR_I64",
241 [(set i64:$dst, (atomic_load_xor_64 ForceXForm:$ptr, i64:$incr))]>;
242 def ATOMIC_LOAD_AND_I64 : PPCCustomInserterPseudo<
243 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_AND_i64",
244 [(set i64:$dst, (atomic_load_and_64 ForceXForm:$ptr, i64:$incr))]>;
245 def ATOMIC_LOAD_NAND_I64 : PPCCustomInserterPseudo<
246 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_NAND_I64",
247 [(set i64:$dst, (atomic_load_nand_64 ForceXForm:$ptr, i64:$incr))]>;
248 def ATOMIC_LOAD_MIN_I64 : PPCCustomInserterPseudo<
249 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_MIN_I64",
250 [(set i64:$dst, (atomic_load_min_64 ForceXForm:$ptr, i64:$incr))]>;
251 def ATOMIC_LOAD_MAX_I64 : PPCCustomInserterPseudo<
252 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_MAX_I64",
253 [(set i64:$dst, (atomic_load_max_64 ForceXForm:$ptr, i64:$incr))]>;
254 def ATOMIC_LOAD_UMIN_I64 : PPCCustomInserterPseudo<
255 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_UMIN_I64",
256 [(set i64:$dst, (atomic_load_umin_64 ForceXForm:$ptr, i64:$incr))]>;
257 def ATOMIC_LOAD_UMAX_I64 : PPCCustomInserterPseudo<
258 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_UMAX_I64",
259 [(set i64:$dst, (atomic_load_umax_64 ForceXForm:$ptr, i64:$incr))]>;
261 def ATOMIC_CMP_SWAP_I64 : PPCCustomInserterPseudo<
262 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$old, g8rc:$new), "#ATOMIC_CMP_SWAP_I64",
263 [(set i64:$dst, (atomic_cmp_swap_64 ForceXForm:$ptr, i64:$old, i64:$new))]>;
265 def ATOMIC_SWAP_I64 : PPCCustomInserterPseudo<
266 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$new), "#ATOMIC_SWAP_I64",
267 [(set i64:$dst, (atomic_swap_64 ForceXForm:$ptr, i64:$new))]>;
270 // Instructions to support atomic operations
271 let mayLoad = 1, hasSideEffects = 0 in {
272 def LDARX : XForm_1_memOp<31, 84, (outs g8rc:$rD), (ins memrr:$ptr),
273 "ldarx $rD, $ptr", IIC_LdStLDARX, []>;
274 // TODO: Add scheduling info.
275 let hasNoSchedulingInfo = 1 in
276 def LQARX : XForm_1_memOp<31, 276, (outs g8prc:$RTp), (ins memrr:$ptr),
277 "lqarx $RTp, $ptr", IIC_LdStLQARX, []>, isPPC64;
279 // Instruction to support lock versions of atomics
280 // (EH=1 - see Power ISA 2.07 Book II 4.4.2)
281 def LDARXL : XForm_1<31, 84, (outs g8rc:$rD), (ins memrr:$ptr),
282 "ldarx $rD, $ptr, 1", IIC_LdStLDARX, []>, isRecordForm;
283 // TODO: Add scheduling info.
284 let hasNoSchedulingInfo = 1 in
285 // FIXME: We have to seek a way to remove isRecordForm since
286 // LQARXL is not really altering CR0.
287 def LQARXL : XForm_1<31, 276, (outs g8prc:$RTp), (ins memrr:$ptr),
288 "lqarx $RTp, $ptr, 1", IIC_LdStLQARX, []>,
289 isPPC64, isRecordForm;
291 let hasExtraDefRegAllocReq = 1 in
292 def LDAT : X_RD5_RS5_IM5<31, 614, (outs g8rc:$rD), (ins g8rc:$rA, u5imm:$FC),
293 "ldat $rD, $rA, $FC", IIC_LdStLoad>, isPPC64,
294 Requires<[IsISA3_0]>;
297 let Defs = [CR0], mayStore = 1, mayLoad = 0, hasSideEffects = 0 in {
298 def STDCX : XForm_1_memOp<31, 214, (outs), (ins g8rc:$rS, memrr:$dst),
299 "stdcx. $rS, $dst", IIC_LdStSTDCX, []>, isRecordForm;
300 // TODO: Add scheduling info.
301 let hasNoSchedulingInfo = 1 in
302 def STQCX : XForm_1_memOp<31, 182, (outs), (ins g8prc:$RSp, memrr:$dst),
303 "stqcx. $RSp, $dst", IIC_LdStSTQCX, []>,
304 isPPC64, isRecordForm;
307 def SPLIT_QUADWORD : PPCCustomInserterPseudo<(outs g8rc:$lo, g8rc:$hi),
309 "#SPLIT_QUADWORD", []>;
310 class AtomicRMW128<string asmstr>
311 : PPCPostRAExpPseudo<(outs g8prc:$RTp, g8prc:$scratch),
312 (ins memrr:$ptr, g8rc:$incr_lo, g8rc:$incr_hi),
314 // We have to keep values in MI's uses during LL/SC looping as they are,
315 // so set both $RTp and $scratch earlyclobber.
316 let mayStore = 1, mayLoad = 1,
318 Constraints = "@earlyclobber $scratch,@earlyclobber $RTp" in {
319 // Atomic pseudo instructions expanded post-ra.
320 def ATOMIC_SWAP_I128 : AtomicRMW128<"#ATOMIC_SWAP_I128">;
321 def ATOMIC_LOAD_ADD_I128 : AtomicRMW128<"#ATOMIC_LOAD_ADD_I128">;
322 def ATOMIC_LOAD_SUB_I128 : AtomicRMW128<"#ATOMIC_LOAD_SUB_I128">;
323 def ATOMIC_LOAD_AND_I128 : AtomicRMW128<"#ATOMIC_LOAD_AND_I128">;
324 def ATOMIC_LOAD_XOR_I128 : AtomicRMW128<"#ATOMIC_LOAD_XOR_I128">;
325 def ATOMIC_LOAD_OR_I128 : AtomicRMW128<"#ATOMIC_LOAD_OR_I128">;
326 def ATOMIC_LOAD_NAND_I128 : AtomicRMW128<"#ATOMIC_LOAD_NAND_I128">;
328 def ATOMIC_CMP_SWAP_I128 : PPCPostRAExpPseudo<
329 (outs g8prc:$RTp, g8prc:$scratch),
330 (ins memrr:$ptr, g8rc:$cmp_lo, g8rc:$cmp_hi,
331 g8rc:$new_lo, g8rc:$new_hi),
332 "#ATOMIC_CMP_SWAP_I128", []>;
335 def : Pat<(int_ppc_atomicrmw_add_i128 ForceXForm:$ptr,
338 (SPLIT_QUADWORD (ATOMIC_LOAD_ADD_I128 memrr:$ptr,
341 def : Pat<(int_ppc_atomicrmw_sub_i128 ForceXForm:$ptr,
344 (SPLIT_QUADWORD (ATOMIC_LOAD_SUB_I128 memrr:$ptr,
347 def : Pat<(int_ppc_atomicrmw_xor_i128 ForceXForm:$ptr,
350 (SPLIT_QUADWORD (ATOMIC_LOAD_XOR_I128 memrr:$ptr,
353 def : Pat<(int_ppc_atomicrmw_and_i128 ForceXForm:$ptr,
356 (SPLIT_QUADWORD (ATOMIC_LOAD_AND_I128 memrr:$ptr,
359 def : Pat<(int_ppc_atomicrmw_nand_i128 ForceXForm:$ptr,
362 (SPLIT_QUADWORD (ATOMIC_LOAD_NAND_I128 memrr:$ptr,
365 def : Pat<(int_ppc_atomicrmw_or_i128 ForceXForm:$ptr,
368 (SPLIT_QUADWORD (ATOMIC_LOAD_OR_I128 memrr:$ptr,
371 def : Pat<(int_ppc_atomicrmw_xchg_i128 ForceXForm:$ptr,
374 (SPLIT_QUADWORD (ATOMIC_SWAP_I128 memrr:$ptr,
377 def : Pat<(int_ppc_cmpxchg_i128 ForceXForm:$ptr,
382 (SPLIT_QUADWORD (ATOMIC_CMP_SWAP_I128
389 let mayStore = 1, mayLoad = 0, hasSideEffects = 0 in
390 def STDAT : X_RD5_RS5_IM5<31, 742, (outs), (ins g8rc:$rS, g8rc:$rA, u5imm:$FC),
391 "stdat $rS, $rA, $FC", IIC_LdStStore>, isPPC64,
392 Requires<[IsISA3_0]>;
394 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
395 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
396 def TCRETURNdi8 :PPCEmitTimePseudo< (outs),
397 (ins calltarget:$dst, i32imm:$offset),
398 "#TC_RETURNd8 $dst $offset",
401 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
402 def TCRETURNai8 :PPCEmitTimePseudo<(outs), (ins abscalltarget:$func, i32imm:$offset),
403 "#TC_RETURNa8 $func $offset",
404 [(PPCtc_return (i64 imm:$func), imm:$offset)]>;
406 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
407 def TCRETURNri8 : PPCEmitTimePseudo<(outs), (ins CTRRC8:$dst, i32imm:$offset),
408 "#TC_RETURNr8 $dst $offset",
411 let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, isBranch = 1,
412 isIndirectBranch = 1, isCall = 1, isReturn = 1, Uses = [CTR8, RM] in
413 def TAILBCTR8 : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
415 Requires<[In64BitMode]>;
417 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
418 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
419 def TAILB8 : IForm<18, 0, 0, (outs), (ins calltarget:$dst),
423 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
424 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
425 def TAILBA8 : IForm<18, 0, 0, (outs), (ins abscalltarget:$dst),
428 } // Interpretation64Bit
430 def : Pat<(PPCtc_return (i64 tglobaladdr:$dst), imm:$imm),
431 (TCRETURNdi8 tglobaladdr:$dst, imm:$imm)>;
433 def : Pat<(PPCtc_return (i64 texternalsym:$dst), imm:$imm),
434 (TCRETURNdi8 texternalsym:$dst, imm:$imm)>;
436 def : Pat<(PPCtc_return CTRRC8:$dst, imm:$imm),
437 (TCRETURNri8 CTRRC8:$dst, imm:$imm)>;
440 // 64-bit CR instructions
441 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
442 let hasSideEffects = 0 in {
443 // mtocrf's input needs to be prepared by shifting by an amount dependent
444 // on the cr register selected. Thus, post-ra anti-dep breaking must not
445 // later change that register assignment.
446 let hasExtraDefRegAllocReq = 1 in {
447 def MTOCRF8: XFXForm_5a<31, 144, (outs crbitm:$FXM), (ins g8rc:$ST),
448 "mtocrf $FXM, $ST", IIC_BrMCRX>,
449 PPC970_DGroup_First, PPC970_Unit_CRU;
451 // Similarly to mtocrf, the mask for mtcrf must be prepared in a way that
452 // is dependent on the cr fields being set.
453 def MTCRF8 : XFXForm_5<31, 144, (outs), (ins i32imm:$FXM, g8rc:$rS),
454 "mtcrf $FXM, $rS", IIC_BrMCRX>,
455 PPC970_MicroCode, PPC970_Unit_CRU;
456 } // hasExtraDefRegAllocReq = 1
458 // mfocrf's input needs to be prepared by shifting by an amount dependent
459 // on the cr register selected. Thus, post-ra anti-dep breaking must not
460 // later change that register assignment.
461 let hasExtraSrcRegAllocReq = 1 in {
462 def MFOCRF8: XFXForm_5a<31, 19, (outs g8rc:$rT), (ins crbitm:$FXM),
463 "mfocrf $rT, $FXM", IIC_SprMFCRF>,
464 PPC970_DGroup_First, PPC970_Unit_CRU;
466 // Similarly to mfocrf, the mask for mfcrf must be prepared in a way that
467 // is dependent on the cr fields being copied.
468 def MFCR8 : XFXForm_3<31, 19, (outs g8rc:$rT), (ins),
469 "mfcr $rT", IIC_SprMFCR>,
470 PPC970_MicroCode, PPC970_Unit_CRU;
471 } // hasExtraSrcRegAllocReq = 1
472 } // hasSideEffects = 0
474 // While longjmp is a control-flow barrier (fallthrough isn't allowed), setjmp
476 let hasSideEffects = 1 in {
478 def EH_SjLj_SetJmp64 : PPCCustomInserterPseudo<(outs gprc:$dst), (ins memr:$buf),
480 [(set i32:$dst, (PPCeh_sjlj_setjmp addr:$buf))]>,
481 Requires<[In64BitMode]>;
484 let hasSideEffects = 1, isBarrier = 1 in {
485 let isTerminator = 1 in
486 def EH_SjLj_LongJmp64 : PPCCustomInserterPseudo<(outs), (ins memr:$buf),
487 "#EH_SJLJ_LONGJMP64",
488 [(PPCeh_sjlj_longjmp addr:$buf)]>,
489 Requires<[In64BitMode]>;
492 def MFSPR8 : XFXForm_1<31, 339, (outs g8rc:$RT), (ins i32imm:$SPR),
493 "mfspr $RT, $SPR", IIC_SprMFSPR>;
494 def MTSPR8 : XFXForm_1<31, 467, (outs), (ins i32imm:$SPR, g8rc:$RT),
495 "mtspr $SPR, $RT", IIC_SprMTSPR>;
498 //===----------------------------------------------------------------------===//
499 // 64-bit SPR manipulation instrs.
501 let Uses = [CTR8] in {
502 def MFCTR8 : XFXForm_1_ext<31, 339, 9, (outs g8rc:$rT), (ins),
503 "mfctr $rT", IIC_SprMFSPR>,
504 PPC970_DGroup_First, PPC970_Unit_FXU;
506 let Pattern = [(PPCmtctr i64:$rS)], Defs = [CTR8] in {
507 def MTCTR8 : XFXForm_7_ext<31, 467, 9, (outs), (ins g8rc:$rS),
508 "mtctr $rS", IIC_SprMTSPR>,
509 PPC970_DGroup_First, PPC970_Unit_FXU;
511 let hasSideEffects = 1, Defs = [CTR8] in {
512 let Pattern = [(int_set_loop_iterations i64:$rS)] in
513 def MTCTR8loop : XFXForm_7_ext<31, 467, 9, (outs), (ins g8rc:$rS),
514 "mtctr $rS", IIC_SprMTSPR>,
515 PPC970_DGroup_First, PPC970_Unit_FXU;
518 let Pattern = [(set i64:$rT, readcyclecounter)] in
519 def MFTB8 : XFXForm_1_ext<31, 339, 268, (outs g8rc:$rT), (ins),
520 "mfspr $rT, 268", IIC_SprMFTB>,
521 PPC970_DGroup_First, PPC970_Unit_FXU;
522 // Note that encoding mftb using mfspr is now the preferred form,
523 // and has been since at least ISA v2.03. The mftb instruction has
524 // now been phased out. Using mfspr, however, is known not to work on
527 let Defs = [X1], Uses = [X1] in
528 def DYNALLOC8 : PPCEmitTimePseudo<(outs g8rc:$result), (ins g8rc:$negsize, memri:$fpsi),"#DYNALLOC8",
530 (PPCdynalloc i64:$negsize, iaddr:$fpsi))]>;
531 def DYNAREAOFFSET8 : PPCEmitTimePseudo<(outs i64imm:$result), (ins memri:$fpsi), "#DYNAREAOFFSET8",
532 [(set i64:$result, (PPCdynareaoffset iaddr:$fpsi))]>;
533 // Probed alloca to support stack clash protection.
534 let Defs = [X1], Uses = [X1], hasNoSchedulingInfo = 1 in {
535 def PROBED_ALLOCA_64 : PPCCustomInserterPseudo<(outs g8rc:$result),
536 (ins g8rc:$negsize, memri:$fpsi), "#PROBED_ALLOCA_64",
538 (PPCprobedalloca i64:$negsize, iaddr:$fpsi))]>;
539 def PREPARE_PROBED_ALLOCA_64 : PPCEmitTimePseudo<(outs
540 g8rc:$fp, g8rc:$actual_negsize),
541 (ins g8rc:$negsize, memri:$fpsi), "#PREPARE_PROBED_ALLOCA_64", []>;
542 def PREPARE_PROBED_ALLOCA_NEGSIZE_SAME_REG_64 : PPCEmitTimePseudo<(outs
543 g8rc:$fp, g8rc:$actual_negsize),
544 (ins g8rc:$negsize, memri:$fpsi),
545 "#PREPARE_PROBED_ALLOCA_NEGSIZE_SAME_REG_64", []>,
546 RegConstraint<"$actual_negsize = $negsize">;
547 def PROBED_STACKALLOC_64 : PPCEmitTimePseudo<(outs g8rc:$scratch, g8rc:$temp),
548 (ins i64imm:$stacksize),
549 "#PROBED_STACKALLOC_64", []>;
552 let hasSideEffects = 0 in {
553 let Defs = [LR8] in {
554 def MTLR8 : XFXForm_7_ext<31, 467, 8, (outs), (ins g8rc:$rS),
555 "mtlr $rS", IIC_SprMTSPR>,
556 PPC970_DGroup_First, PPC970_Unit_FXU;
558 let Uses = [LR8] in {
559 def MFLR8 : XFXForm_1_ext<31, 339, 8, (outs g8rc:$rT), (ins),
560 "mflr $rT", IIC_SprMFSPR>,
561 PPC970_DGroup_First, PPC970_Unit_FXU;
563 } // Interpretation64Bit
566 //===----------------------------------------------------------------------===//
567 // Fixed point instructions.
570 let PPC970_Unit = 1 in { // FXU Operations.
571 let Interpretation64Bit = 1 in {
572 let hasSideEffects = 0 in {
573 let isCodeGenOnly = 1 in {
575 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in {
576 def LI8 : DForm_2_r0<14, (outs g8rc:$rD), (ins s16imm64:$imm),
577 "li $rD, $imm", IIC_IntSimple,
578 [(set i64:$rD, imm64SExt16:$imm)]>;
579 def LIS8 : DForm_2_r0<15, (outs g8rc:$rD), (ins s17imm64:$imm),
580 "lis $rD, $imm", IIC_IntSimple,
581 [(set i64:$rD, imm16ShiftedSExt:$imm)]>;
585 let isCommutable = 1 in {
586 defm NAND8: XForm_6r<31, 476, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
587 "nand", "$rA, $rS, $rB", IIC_IntSimple,
588 [(set i64:$rA, (not (and i64:$rS, i64:$rB)))]>;
589 defm AND8 : XForm_6r<31, 28, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
590 "and", "$rA, $rS, $rB", IIC_IntSimple,
591 [(set i64:$rA, (and i64:$rS, i64:$rB))]>;
593 defm ANDC8: XForm_6r<31, 60, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
594 "andc", "$rA, $rS, $rB", IIC_IntSimple,
595 [(set i64:$rA, (and i64:$rS, (not i64:$rB)))]>;
596 let isCommutable = 1 in {
597 defm OR8 : XForm_6r<31, 444, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
598 "or", "$rA, $rS, $rB", IIC_IntSimple,
599 [(set i64:$rA, (or i64:$rS, i64:$rB))]>;
600 defm NOR8 : XForm_6r<31, 124, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
601 "nor", "$rA, $rS, $rB", IIC_IntSimple,
602 [(set i64:$rA, (not (or i64:$rS, i64:$rB)))]>;
604 defm ORC8 : XForm_6r<31, 412, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
605 "orc", "$rA, $rS, $rB", IIC_IntSimple,
606 [(set i64:$rA, (or i64:$rS, (not i64:$rB)))]>;
607 let isCommutable = 1 in {
608 defm EQV8 : XForm_6r<31, 284, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
609 "eqv", "$rA, $rS, $rB", IIC_IntSimple,
610 [(set i64:$rA, (not (xor i64:$rS, i64:$rB)))]>;
611 defm XOR8 : XForm_6r<31, 316, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
612 "xor", "$rA, $rS, $rB", IIC_IntSimple,
613 [(set i64:$rA, (xor i64:$rS, i64:$rB))]>;
614 } // let isCommutable = 1
616 // Logical ops with immediate.
617 let Defs = [CR0] in {
618 def ANDI8_rec : DForm_4<28, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
619 "andi. $dst, $src1, $src2", IIC_IntGeneral,
620 [(set i64:$dst, (and i64:$src1, immZExt16:$src2))]>,
622 def ANDIS8_rec : DForm_4<29, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
623 "andis. $dst, $src1, $src2", IIC_IntGeneral,
624 [(set i64:$dst, (and i64:$src1, imm16ShiftedZExt:$src2))]>,
627 def ORI8 : DForm_4<24, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
628 "ori $dst, $src1, $src2", IIC_IntSimple,
629 [(set i64:$dst, (or i64:$src1, immZExt16:$src2))]>;
630 def ORIS8 : DForm_4<25, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
631 "oris $dst, $src1, $src2", IIC_IntSimple,
632 [(set i64:$dst, (or i64:$src1, imm16ShiftedZExt:$src2))]>;
633 def XORI8 : DForm_4<26, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
634 "xori $dst, $src1, $src2", IIC_IntSimple,
635 [(set i64:$dst, (xor i64:$src1, immZExt16:$src2))]>;
636 def XORIS8 : DForm_4<27, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
637 "xoris $dst, $src1, $src2", IIC_IntSimple,
638 [(set i64:$dst, (xor i64:$src1, imm16ShiftedZExt:$src2))]>;
640 let isCommutable = 1 in
641 defm ADD8 : XOForm_1rx<31, 266, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
642 "add", "$rT, $rA, $rB", IIC_IntSimple,
643 [(set i64:$rT, (add i64:$rA, i64:$rB))]>;
644 // ADD8 has a special form: reg = ADD8(reg, sym@tls) for use by the
645 // initial-exec thread-local storage model. We need to forbid r0 here -
646 // while it works for add just fine, the linker can relax this to local-exec
647 // addi, which won't work for r0.
648 def ADD8TLS : XOForm_1<31, 266, 0, (outs g8rc:$rT), (ins g8rc_nox0:$rA, tlsreg:$rB),
649 "add $rT, $rA, $rB", IIC_IntSimple,
650 [(set i64:$rT, (add i64:$rA, tglobaltlsaddr:$rB))]>;
652 def LBZXTLS : XForm_1<31, 87, (outs g8rc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
653 "lbzx $rD, $rA, $rB", IIC_LdStLoad, []>;
654 def LHZXTLS : XForm_1<31, 279, (outs g8rc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
655 "lhzx $rD, $rA, $rB", IIC_LdStLoad, []>;
656 def LWZXTLS : XForm_1<31, 23, (outs g8rc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
657 "lwzx $rD, $rA, $rB", IIC_LdStLoad, []>;
658 def LDXTLS : XForm_1<31, 21, (outs g8rc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
659 "ldx $rD, $rA, $rB", IIC_LdStLD, []>, isPPC64;
660 def LBZXTLS_32 : XForm_1<31, 87, (outs gprc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
661 "lbzx $rD, $rA, $rB", IIC_LdStLoad, []>;
662 def LHZXTLS_32 : XForm_1<31, 279, (outs gprc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
663 "lhzx $rD, $rA, $rB", IIC_LdStLoad, []>;
664 def LWZXTLS_32 : XForm_1<31, 23, (outs gprc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
665 "lwzx $rD, $rA, $rB", IIC_LdStLoad, []>;
669 let mayStore = 1 in {
670 def STBXTLS : XForm_8<31, 215, (outs), (ins g8rc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
671 "stbx $rS, $rA, $rB", IIC_LdStStore, []>,
672 PPC970_DGroup_Cracked;
673 def STHXTLS : XForm_8<31, 407, (outs), (ins g8rc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
674 "sthx $rS, $rA, $rB", IIC_LdStStore, []>,
675 PPC970_DGroup_Cracked;
676 def STWXTLS : XForm_8<31, 151, (outs), (ins g8rc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
677 "stwx $rS, $rA, $rB", IIC_LdStStore, []>,
678 PPC970_DGroup_Cracked;
679 def STDXTLS : XForm_8<31, 149, (outs), (ins g8rc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
680 "stdx $rS, $rA, $rB", IIC_LdStSTD, []>, isPPC64,
681 PPC970_DGroup_Cracked;
682 def STBXTLS_32 : XForm_8<31, 215, (outs), (ins gprc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
683 "stbx $rS, $rA, $rB", IIC_LdStStore, []>,
684 PPC970_DGroup_Cracked;
685 def STHXTLS_32 : XForm_8<31, 407, (outs), (ins gprc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
686 "sthx $rS, $rA, $rB", IIC_LdStStore, []>,
687 PPC970_DGroup_Cracked;
688 def STWXTLS_32 : XForm_8<31, 151, (outs), (ins gprc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
689 "stwx $rS, $rA, $rB", IIC_LdStStore, []>,
690 PPC970_DGroup_Cracked;
694 let isCommutable = 1 in
695 defm ADDC8 : XOForm_1rc<31, 10, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
696 "addc", "$rT, $rA, $rB", IIC_IntGeneral,
697 [(set i64:$rT, (addc i64:$rA, i64:$rB))]>,
698 PPC970_DGroup_Cracked;
700 let Defs = [CARRY] in
701 def ADDIC8 : DForm_2<12, (outs g8rc:$rD), (ins g8rc:$rA, s16imm64:$imm),
702 "addic $rD, $rA, $imm", IIC_IntGeneral,
703 [(set i64:$rD, (addc i64:$rA, imm64SExt16:$imm))]>;
704 def ADDI8 : DForm_2<14, (outs g8rc:$rD), (ins g8rc_nox0:$rA, s16imm64:$imm),
705 "addi $rD, $rA, $imm", IIC_IntSimple,
706 [(set i64:$rD, (add i64:$rA, imm64SExt16:$imm))]>;
707 def ADDIS8 : DForm_2<15, (outs g8rc:$rD), (ins g8rc_nox0:$rA, s17imm64:$imm),
708 "addis $rD, $rA, $imm", IIC_IntSimple,
709 [(set i64:$rD, (add i64:$rA, imm16ShiftedSExt:$imm))]>;
711 let Defs = [CARRY] in {
712 def SUBFIC8: DForm_2< 8, (outs g8rc:$rD), (ins g8rc:$rA, s16imm64:$imm),
713 "subfic $rD, $rA, $imm", IIC_IntGeneral,
714 [(set i64:$rD, (subc imm64SExt16:$imm, i64:$rA))]>;
716 defm SUBFC8 : XOForm_1rc<31, 8, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
717 "subfc", "$rT, $rA, $rB", IIC_IntGeneral,
718 [(set i64:$rT, (subc i64:$rB, i64:$rA))]>,
719 PPC970_DGroup_Cracked;
720 defm SUBF8 : XOForm_1rx<31, 40, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
721 "subf", "$rT, $rA, $rB", IIC_IntGeneral,
722 [(set i64:$rT, (sub i64:$rB, i64:$rA))]>;
723 defm NEG8 : XOForm_3r<31, 104, 0, (outs g8rc:$rT), (ins g8rc:$rA),
724 "neg", "$rT, $rA", IIC_IntSimple,
725 [(set i64:$rT, (ineg i64:$rA))]>;
726 let Uses = [CARRY] in {
727 let isCommutable = 1 in
728 defm ADDE8 : XOForm_1rc<31, 138, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
729 "adde", "$rT, $rA, $rB", IIC_IntGeneral,
730 [(set i64:$rT, (adde i64:$rA, i64:$rB))]>;
731 defm ADDME8 : XOForm_3rc<31, 234, 0, (outs g8rc:$rT), (ins g8rc:$rA),
732 "addme", "$rT, $rA", IIC_IntGeneral,
733 [(set i64:$rT, (adde i64:$rA, -1))]>;
734 defm ADDZE8 : XOForm_3rc<31, 202, 0, (outs g8rc:$rT), (ins g8rc:$rA),
735 "addze", "$rT, $rA", IIC_IntGeneral,
736 [(set i64:$rT, (adde i64:$rA, 0))]>;
737 defm SUBFE8 : XOForm_1rc<31, 136, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
738 "subfe", "$rT, $rA, $rB", IIC_IntGeneral,
739 [(set i64:$rT, (sube i64:$rB, i64:$rA))]>;
740 defm SUBFME8 : XOForm_3rc<31, 232, 0, (outs g8rc:$rT), (ins g8rc:$rA),
741 "subfme", "$rT, $rA", IIC_IntGeneral,
742 [(set i64:$rT, (sube -1, i64:$rA))]>;
743 defm SUBFZE8 : XOForm_3rc<31, 200, 0, (outs g8rc:$rT), (ins g8rc:$rA),
744 "subfze", "$rT, $rA", IIC_IntGeneral,
745 [(set i64:$rT, (sube 0, i64:$rA))]>;
749 // FIXME: Duplicating this for the asm parser should be unnecessary, but the
750 // previous definition must be marked as CodeGen only to prevent decoding
752 let isAsmParserOnly = 1 in {
753 def ADD8TLS_ : XOForm_1<31, 266, 0, (outs g8rc:$rT), (ins g8rc:$rA, tlsreg:$rB),
754 "add $rT, $rA, $rB", IIC_IntSimple, []>;
757 def LBZXTLS_ : XForm_1<31, 87, (outs g8rc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
758 "lbzx $rD, $rA, $rB", IIC_LdStLoad, []>;
759 def LHZXTLS_ : XForm_1<31, 279, (outs g8rc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
760 "lhzx $rD, $rA, $rB", IIC_LdStLoad, []>;
761 def LWZXTLS_ : XForm_1<31, 23, (outs g8rc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
762 "lwzx $rD, $rA, $rB", IIC_LdStLoad, []>;
763 def LDXTLS_ : XForm_1<31, 21, (outs g8rc:$rD), (ins ptr_rc_nor0:$rA, tlsreg:$rB),
764 "ldx $rD, $rA, $rB", IIC_LdStLD, []>, isPPC64;
767 let mayStore = 1 in {
768 def STBXTLS_ : XForm_8<31, 215, (outs), (ins g8rc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
769 "stbx $rS, $rA, $rB", IIC_LdStStore, []>,
770 PPC970_DGroup_Cracked;
771 def STHXTLS_ : XForm_8<31, 407, (outs), (ins g8rc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
772 "sthx $rS, $rA, $rB", IIC_LdStStore, []>,
773 PPC970_DGroup_Cracked;
774 def STWXTLS_ : XForm_8<31, 151, (outs), (ins g8rc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
775 "stwx $rS, $rA, $rB", IIC_LdStStore, []>,
776 PPC970_DGroup_Cracked;
777 def STDXTLS_ : XForm_8<31, 149, (outs), (ins g8rc:$rS, ptr_rc_nor0:$rA, tlsreg:$rB),
778 "stdx $rS, $rA, $rB", IIC_LdStSTD, []>, isPPC64,
779 PPC970_DGroup_Cracked;
783 let isCommutable = 1 in {
784 defm MULHD : XOForm_1r<31, 73, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
785 "mulhd", "$rT, $rA, $rB", IIC_IntMulHW,
786 [(set i64:$rT, (mulhs i64:$rA, i64:$rB))]>;
787 defm MULHDU : XOForm_1r<31, 9, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
788 "mulhdu", "$rT, $rA, $rB", IIC_IntMulHWU,
789 [(set i64:$rT, (mulhu i64:$rA, i64:$rB))]>;
792 } // Interpretation64Bit
794 let isCompare = 1, hasSideEffects = 0 in {
795 def CMPD : XForm_16_ext<31, 0, (outs crrc:$crD), (ins g8rc:$rA, g8rc:$rB),
796 "cmpd $crD, $rA, $rB", IIC_IntCompare>, isPPC64;
797 def CMPLD : XForm_16_ext<31, 32, (outs crrc:$crD), (ins g8rc:$rA, g8rc:$rB),
798 "cmpld $crD, $rA, $rB", IIC_IntCompare>, isPPC64;
799 def CMPDI : DForm_5_ext<11, (outs crrc:$crD), (ins g8rc:$rA, s16imm64:$imm),
800 "cmpdi $crD, $rA, $imm", IIC_IntCompare>, isPPC64;
801 def CMPLDI : DForm_6_ext<10, (outs crrc:$dst), (ins g8rc:$src1, u16imm64:$src2),
802 "cmpldi $dst, $src1, $src2",
803 IIC_IntCompare>, isPPC64;
804 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
805 def CMPRB8 : X_BF3_L1_RS5_RS5<31, 192, (outs crrc:$BF),
806 (ins u1imm:$L, g8rc:$rA, g8rc:$rB),
807 "cmprb $BF, $L, $rA, $rB", IIC_IntCompare, []>,
808 Requires<[IsISA3_0]>;
809 def CMPEQB : X_BF3_RS5_RS5<31, 224, (outs crrc:$BF),
810 (ins g8rc:$rA, g8rc:$rB), "cmpeqb $BF, $rA, $rB",
811 IIC_IntCompare, []>, Requires<[IsISA3_0]>;
814 let hasSideEffects = 0 in {
815 defm SLD : XForm_6r<31, 27, (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB),
816 "sld", "$rA, $rS, $rB", IIC_IntRotateD,
817 [(set i64:$rA, (PPCshl i64:$rS, i32:$rB))]>, isPPC64;
818 defm SRD : XForm_6r<31, 539, (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB),
819 "srd", "$rA, $rS, $rB", IIC_IntRotateD,
820 [(set i64:$rA, (PPCsrl i64:$rS, i32:$rB))]>, isPPC64;
821 defm SRAD : XForm_6rc<31, 794, (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB),
822 "srad", "$rA, $rS, $rB", IIC_IntRotateD,
823 [(set i64:$rA, (PPCsra i64:$rS, i32:$rB))]>, isPPC64;
825 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
826 defm CNTLZW8 : XForm_11r<31, 26, (outs g8rc:$rA), (ins g8rc:$rS),
827 "cntlzw", "$rA, $rS", IIC_IntGeneral, []>;
828 defm CNTTZW8 : XForm_11r<31, 538, (outs g8rc:$rA), (ins g8rc:$rS),
829 "cnttzw", "$rA, $rS", IIC_IntGeneral, []>,
830 Requires<[IsISA3_0]>;
832 defm EXTSB8 : XForm_11r<31, 954, (outs g8rc:$rA), (ins g8rc:$rS),
833 "extsb", "$rA, $rS", IIC_IntSimple,
834 [(set i64:$rA, (sext_inreg i64:$rS, i8))]>;
835 defm EXTSH8 : XForm_11r<31, 922, (outs g8rc:$rA), (ins g8rc:$rS),
836 "extsh", "$rA, $rS", IIC_IntSimple,
837 [(set i64:$rA, (sext_inreg i64:$rS, i16))]>;
839 defm SLW8 : XForm_6r<31, 24, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
840 "slw", "$rA, $rS, $rB", IIC_IntGeneral, []>;
841 defm SRW8 : XForm_6r<31, 536, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
842 "srw", "$rA, $rS, $rB", IIC_IntGeneral, []>;
843 } // Interpretation64Bit
846 let isCodeGenOnly = 1 in {
847 def EXTSB8_32_64 : XForm_11<31, 954, (outs g8rc:$rA), (ins gprc:$rS),
848 "extsb $rA, $rS", IIC_IntSimple, []>, isPPC64;
849 def EXTSH8_32_64 : XForm_11<31, 922, (outs g8rc:$rA), (ins gprc:$rS),
850 "extsh $rA, $rS", IIC_IntSimple, []>, isPPC64;
851 } // isCodeGenOnly for fast-isel
853 defm EXTSW : XForm_11r<31, 986, (outs g8rc:$rA), (ins g8rc:$rS),
854 "extsw", "$rA, $rS", IIC_IntSimple,
855 [(set i64:$rA, (sext_inreg i64:$rS, i32))]>, isPPC64;
856 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
857 defm EXTSW_32_64 : XForm_11r<31, 986, (outs g8rc:$rA), (ins gprc:$rS),
858 "extsw", "$rA, $rS", IIC_IntSimple,
859 [(set i64:$rA, (sext i32:$rS))]>, isPPC64;
860 let isCodeGenOnly = 1 in
861 def EXTSW_32 : XForm_11<31, 986, (outs gprc:$rA), (ins gprc:$rS),
862 "extsw $rA, $rS", IIC_IntSimple,
865 defm SRADI : XSForm_1rc<31, 413, (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH),
866 "sradi", "$rA, $rS, $SH", IIC_IntRotateDI,
867 [(set i64:$rA, (sra i64:$rS, (i32 imm:$SH)))]>, isPPC64;
869 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
870 defm EXTSWSLI_32_64 : XSForm_1r<31, 445, (outs g8rc:$rA),
871 (ins gprc:$rS, u6imm:$SH),
872 "extswsli", "$rA, $rS, $SH", IIC_IntRotateDI,
874 (PPCextswsli i32:$rS, (i32 imm:$SH)))]>,
875 isPPC64, Requires<[IsISA3_0]>;
877 defm EXTSWSLI : XSForm_1rc<31, 445, (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH),
878 "extswsli", "$rA, $rS, $SH", IIC_IntRotateDI,
879 []>, isPPC64, Requires<[IsISA3_0]>;
882 let isCodeGenOnly = 1, Defs = [CARRY] in
883 def SRADI_32 : XSForm_1<31, 413, (outs gprc:$rA), (ins gprc:$rS, u6imm:$SH),
884 "sradi $rA, $rS, $SH", IIC_IntRotateDI, []>, isPPC64;
886 defm CNTLZD : XForm_11r<31, 58, (outs g8rc:$rA), (ins g8rc:$rS),
887 "cntlzd", "$rA, $rS", IIC_IntGeneral,
888 [(set i64:$rA, (ctlz i64:$rS))]>;
889 defm CNTTZD : XForm_11r<31, 570, (outs g8rc:$rA), (ins g8rc:$rS),
890 "cnttzd", "$rA, $rS", IIC_IntGeneral,
891 [(set i64:$rA, (cttz i64:$rS))]>, Requires<[IsISA3_0]>;
892 def POPCNTD : XForm_11<31, 506, (outs g8rc:$rA), (ins g8rc:$rS),
893 "popcntd $rA, $rS", IIC_IntGeneral,
894 [(set i64:$rA, (ctpop i64:$rS))]>;
895 def BPERMD : XForm_6<31, 252, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
896 "bpermd $rA, $rS, $rB", IIC_IntGeneral,
897 [(set i64:$rA, (int_ppc_bpermd g8rc:$rS, g8rc:$rB))]>,
898 isPPC64, Requires<[HasBPERMD]>;
900 let isCodeGenOnly = 1, isCommutable = 1 in
901 def CMPB8 : XForm_6<31, 508, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
902 "cmpb $rA, $rS, $rB", IIC_IntGeneral,
903 [(set i64:$rA, (PPCcmpb i64:$rS, i64:$rB))]>;
905 // popcntw also does a population count on the high 32 bits (storing the
906 // results in the high 32-bits of the output). We'll ignore that here (which is
907 // safe because we never separately use the high part of the 64-bit registers).
908 def POPCNTW : XForm_11<31, 378, (outs gprc:$rA), (ins gprc:$rS),
909 "popcntw $rA, $rS", IIC_IntGeneral,
910 [(set i32:$rA, (ctpop i32:$rS))]>;
912 let isCodeGenOnly = 1 in
913 def POPCNTB8 : XForm_11<31, 122, (outs g8rc:$rA), (ins g8rc:$rS),
914 "popcntb $rA, $rS", IIC_IntGeneral,
915 [(set i64:$rA, (int_ppc_popcntb i64:$rS))]>;
917 defm DIVD : XOForm_1rcr<31, 489, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
918 "divd", "$rT, $rA, $rB", IIC_IntDivD,
919 [(set i64:$rT, (sdiv i64:$rA, i64:$rB))]>, isPPC64;
920 defm DIVDU : XOForm_1rcr<31, 457, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
921 "divdu", "$rT, $rA, $rB", IIC_IntDivD,
922 [(set i64:$rT, (udiv i64:$rA, i64:$rB))]>, isPPC64;
923 defm DIVDE : XOForm_1rcr<31, 425, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
924 "divde", "$rT, $rA, $rB", IIC_IntDivD,
925 [(set i64:$rT, (int_ppc_divde g8rc:$rA, g8rc:$rB))]>,
926 isPPC64, Requires<[HasExtDiv]>;
928 let Predicates = [IsISA3_0] in {
929 def MADDHD : VAForm_1a<48, (outs g8rc :$RT), (ins g8rc:$RA, g8rc:$RB, g8rc:$RC),
930 "maddhd $RT, $RA, $RB, $RC", IIC_IntMulHD, []>, isPPC64;
931 def MADDHDU : VAForm_1a<49,
932 (outs g8rc :$RT), (ins g8rc:$RA, g8rc:$RB, g8rc:$RC),
933 "maddhdu $RT, $RA, $RB, $RC", IIC_IntMulHD, []>, isPPC64;
934 def MADDLD : VAForm_1a<51, (outs gprc :$RT), (ins gprc:$RA, gprc:$RB, gprc:$RC),
935 "maddld $RT, $RA, $RB, $RC", IIC_IntMulHD,
936 [(set i32:$RT, (add_without_simm16 (mul_without_simm16 i32:$RA, i32:$RB), i32:$RC))]>,
938 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
939 def MADDLD8 : VAForm_1a<51,
940 (outs g8rc :$RT), (ins g8rc:$RA, g8rc:$RB, g8rc:$RC),
941 "maddld $RT, $RA, $RB, $RC", IIC_IntMulHD,
942 [(set i64:$RT, (add_without_simm16 (mul_without_simm16 i64:$RA, i64:$RB), i64:$RC))]>,
944 def SETB8 : XForm_44<31, 128, (outs g8rc:$RT), (ins crrc:$BFA),
945 "setb $RT, $BFA", IIC_IntGeneral>, isPPC64;
947 def DARN : XForm_45<31, 755, (outs g8rc:$RT), (ins u2imm:$L),
948 "darn $RT, $L", IIC_LdStLD>, isPPC64;
949 def ADDPCIS : DXForm<19, 2, (outs g8rc:$RT), (ins i32imm:$D),
950 "addpcis $RT, $D", IIC_BrB, []>, isPPC64;
951 def MODSD : XForm_8<31, 777, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
952 "modsd $rT, $rA, $rB", IIC_IntDivW,
953 [(set i64:$rT, (srem i64:$rA, i64:$rB))]>;
954 def MODUD : XForm_8<31, 265, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
955 "modud $rT, $rA, $rB", IIC_IntDivW,
956 [(set i64:$rT, (urem i64:$rA, i64:$rB))]>;
959 defm DIVDEU : XOForm_1rcr<31, 393, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
960 "divdeu", "$rT, $rA, $rB", IIC_IntDivD,
961 [(set i64:$rT, (int_ppc_divdeu g8rc:$rA, g8rc:$rB))]>,
962 isPPC64, Requires<[HasExtDiv]>;
963 let isCommutable = 1 in
964 defm MULLD : XOForm_1rx<31, 233, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
965 "mulld", "$rT, $rA, $rB", IIC_IntMulHD,
966 [(set i64:$rT, (mul i64:$rA, i64:$rB))]>, isPPC64;
967 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
968 def MULLI8 : DForm_2<7, (outs g8rc:$rD), (ins g8rc:$rA, s16imm64:$imm),
969 "mulli $rD, $rA, $imm", IIC_IntMulLI,
970 [(set i64:$rD, (mul i64:$rA, imm64SExt16:$imm))]>;
973 let hasSideEffects = 0 in {
974 defm RLDIMI : MDForm_1r<30, 3, (outs g8rc:$rA),
975 (ins g8rc:$rSi, g8rc:$rS, u6imm:$SH, u6imm:$MBE),
976 "rldimi", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
977 []>, isPPC64, RegConstraint<"$rSi = $rA">,
980 // Rotate instructions.
981 defm RLDCL : MDSForm_1r<30, 8,
982 (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB, u6imm:$MBE),
983 "rldcl", "$rA, $rS, $rB, $MBE", IIC_IntRotateD,
985 defm RLDCR : MDSForm_1r<30, 9,
986 (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB, u6imm:$MBE),
987 "rldcr", "$rA, $rS, $rB, $MBE", IIC_IntRotateD,
989 defm RLDICL : MDForm_1r<30, 0,
990 (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH, u6imm:$MBE),
991 "rldicl", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
994 let isCodeGenOnly = 1 in
995 def RLDICL_32_64 : MDForm_1<30, 0,
997 (ins gprc:$rS, u6imm:$SH, u6imm:$MBE),
998 "rldicl $rA, $rS, $SH, $MBE", IIC_IntRotateDI,
1001 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
1002 defm RLDICL_32 : MDForm_1r<30, 0,
1004 (ins gprc:$rS, u6imm:$SH, u6imm:$MBE),
1005 "rldicl", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
1007 defm RLDICR : MDForm_1r<30, 1,
1008 (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH, u6imm:$MBE),
1009 "rldicr", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
1011 let isCodeGenOnly = 1 in
1012 def RLDICR_32 : MDForm_1<30, 1,
1013 (outs gprc:$rA), (ins gprc:$rS, u6imm:$SH, u6imm:$MBE),
1014 "rldicr $rA, $rS, $SH, $MBE", IIC_IntRotateDI,
1016 defm RLDIC : MDForm_1r<30, 2,
1017 (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH, u6imm:$MBE),
1018 "rldic", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
1021 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
1022 defm RLWINM8 : MForm_2r<21, (outs g8rc:$rA),
1023 (ins g8rc:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
1024 "rlwinm", "$rA, $rS, $SH, $MB, $ME", IIC_IntGeneral,
1027 defm RLWNM8 : MForm_2r<23, (outs g8rc:$rA),
1028 (ins g8rc:$rS, g8rc:$rB, u5imm:$MB, u5imm:$ME),
1029 "rlwnm", "$rA, $rS, $rB, $MB, $ME", IIC_IntGeneral,
1032 // RLWIMI can be commuted if the rotate amount is zero.
1033 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
1034 defm RLWIMI8 : MForm_2r<20, (outs g8rc:$rA),
1035 (ins g8rc:$rSi, g8rc:$rS, u5imm:$SH, u5imm:$MB,
1036 u5imm:$ME), "rlwimi", "$rA, $rS, $SH, $MB, $ME",
1037 IIC_IntRotate, []>, PPC970_DGroup_Cracked,
1038 RegConstraint<"$rSi = $rA">, NoEncode<"$rSi">;
1041 def ISEL8 : AForm_4<31, 15,
1042 (outs g8rc:$rT), (ins g8rc_nox0:$rA, g8rc:$rB, crbitrc:$cond),
1043 "isel $rT, $rA, $rB, $cond", IIC_IntISEL,
1045 } // Interpretation64Bit
1046 } // hasSideEffects = 0
1047 } // End FXU Operations.
1049 def : InstAlias<"li $rD, $imm", (ADDI8 g8rc:$rD, ZERO8, s16imm64:$imm)>;
1050 def : InstAlias<"lis $rD, $imm", (ADDIS8 g8rc:$rD, ZERO8, s17imm64:$imm)>;
1052 def : InstAlias<"mr $rA, $rB", (OR8 g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
1053 def : InstAlias<"mr. $rA, $rB", (OR8_rec g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
1055 def : InstAlias<"not $rA, $rB", (NOR8 g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
1056 def : InstAlias<"not. $rA, $rB", (NOR8_rec g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
1058 def : InstAlias<"mtcr $rA", (MTCRF8 255, g8rc:$rA)>;
1060 def : InstAlias<"sub $rA, $rB, $rC", (SUBF8 g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
1061 def : InstAlias<"sub. $rA, $rB, $rC", (SUBF8_rec g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
1062 def : InstAlias<"subc $rA, $rB, $rC", (SUBFC8 g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
1063 def : InstAlias<"subc. $rA, $rB, $rC", (SUBFC8_rec g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
1065 def : InstAlias<"rotlwi $rA, $rS, $n", (RLWINM8 g8rc:$rA, g8rc:$rS, u5imm:$n, 0, 31)>;
1066 def : InstAlias<"rotlwi. $rA, $rS, $n", (RLWINM8_rec g8rc:$rA, g8rc:$rS, u5imm:$n, 0, 31)>;
1067 def : InstAlias<"rotlw $rA, $rS, $rB", (RLWNM8 g8rc:$rA, g8rc:$rS, g8rc:$rB, 0, 31)>;
1068 def : InstAlias<"rotlw. $rA, $rS, $rB", (RLWNM8_rec g8rc:$rA, g8rc:$rS, g8rc:$rB, 0, 31)>;
1069 def : InstAlias<"clrlwi $rA, $rS, $n", (RLWINM8 g8rc:$rA, g8rc:$rS, 0, u5imm:$n, 31)>;
1070 def : InstAlias<"clrlwi. $rA, $rS, $n", (RLWINM8_rec g8rc:$rA, g8rc:$rS, 0, u5imm:$n, 31)>;
1072 def : InstAlias<"isellt $rT, $rA, $rB",
1073 (ISEL8 g8rc:$rT, g8rc_nox0:$rA, g8rc:$rB, CR0LT)>;
1074 def : InstAlias<"iselgt $rT, $rA, $rB",
1075 (ISEL8 g8rc:$rT, g8rc_nox0:$rA, g8rc:$rB, CR0GT)>;
1076 def : InstAlias<"iseleq $rT, $rA, $rB",
1077 (ISEL8 g8rc:$rT, g8rc_nox0:$rA, g8rc:$rB, CR0EQ)>;
1079 def : InstAlias<"nop", (ORI8 X0, X0, 0)>;
1080 def : InstAlias<"xnop", (XORI8 X0, X0, 0)>;
1082 def : InstAlias<"cntlzw $rA, $rS", (CNTLZW8 g8rc:$rA, g8rc:$rS)>;
1083 def : InstAlias<"cntlzw. $rA, $rS", (CNTLZW8_rec g8rc:$rA, g8rc:$rS)>;
1085 def : InstAlias<"mtxer $Rx", (MTSPR8 1, g8rc:$Rx)>;
1086 def : InstAlias<"mfxer $Rx", (MFSPR8 g8rc:$Rx, 1)>;
1088 //Disable this alias on AIX for now because as does not support them.
1089 let Predicates = [ModernAs] in {
1091 def : InstAlias<"mtudscr $Rx", (MTSPR8 3, g8rc:$Rx)>;
1092 def : InstAlias<"mfudscr $Rx", (MFSPR8 g8rc:$Rx, 3)>;
1094 def : InstAlias<"mfrtcu $Rx", (MFSPR8 g8rc:$Rx, 4)>;
1095 def : InstAlias<"mfrtcl $Rx", (MFSPR8 g8rc:$Rx, 5)>;
1097 def : InstAlias<"mtlr $Rx", (MTSPR8 8, g8rc:$Rx)>;
1098 def : InstAlias<"mflr $Rx", (MFSPR8 g8rc:$Rx, 8)>;
1100 def : InstAlias<"mtctr $Rx", (MTSPR8 9, g8rc:$Rx)>;
1101 def : InstAlias<"mfctr $Rx", (MFSPR8 g8rc:$Rx, 9)>;
1103 def : InstAlias<"mtuamr $Rx", (MTSPR8 13, g8rc:$Rx)>;
1104 def : InstAlias<"mfuamr $Rx", (MFSPR8 g8rc:$Rx, 13)>;
1106 def : InstAlias<"mtdscr $Rx", (MTSPR8 17, g8rc:$Rx)>;
1107 def : InstAlias<"mfdscr $Rx", (MFSPR8 g8rc:$Rx, 17)>;
1109 def : InstAlias<"mtdsisr $Rx", (MTSPR8 18, g8rc:$Rx)>;
1110 def : InstAlias<"mfdsisr $Rx", (MFSPR8 g8rc:$Rx, 18)>;
1112 def : InstAlias<"mtdar $Rx", (MTSPR8 19, g8rc:$Rx)>;
1113 def : InstAlias<"mfdar $Rx", (MFSPR8 g8rc:$Rx, 19)>;
1115 def : InstAlias<"mtdec $Rx", (MTSPR8 22, g8rc:$Rx)>;
1116 def : InstAlias<"mfdec $Rx", (MFSPR8 g8rc:$Rx, 22)>;
1118 def : InstAlias<"mtsdr1 $Rx", (MTSPR8 25, g8rc:$Rx)>;
1119 def : InstAlias<"mfsdr1 $Rx", (MFSPR8 g8rc:$Rx, 25)>;
1121 def : InstAlias<"mtsrr0 $Rx", (MTSPR8 26, g8rc:$Rx)>;
1122 def : InstAlias<"mfsrr0 $Rx", (MFSPR8 g8rc:$Rx, 26)>;
1124 def : InstAlias<"mtsrr1 $Rx", (MTSPR8 27, g8rc:$Rx)>;
1125 def : InstAlias<"mfsrr1 $Rx", (MFSPR8 g8rc:$Rx, 27)>;
1127 def : InstAlias<"mtcfar $Rx", (MTSPR8 28, g8rc:$Rx)>;
1128 def : InstAlias<"mfcfar $Rx", (MFSPR8 g8rc:$Rx, 28)>;
1130 def : InstAlias<"mtamr $Rx", (MTSPR8 29, g8rc:$Rx)>;
1131 def : InstAlias<"mfamr $Rx", (MFSPR8 g8rc:$Rx, 29)>;
1133 foreach SPRG = 0-3 in {
1134 def : InstAlias<"mfsprg $RT, "#SPRG, (MFSPR8 g8rc:$RT, !add(SPRG, 272))>;
1135 def : InstAlias<"mfsprg"#SPRG#" $RT", (MFSPR8 g8rc:$RT, !add(SPRG, 272))>;
1136 def : InstAlias<"mtsprg "#SPRG#", $RT", (MTSPR8 !add(SPRG, 272), g8rc:$RT)>;
1137 def : InstAlias<"mtsprg"#SPRG#" $RT", (MTSPR8 !add(SPRG, 272), g8rc:$RT)>;
1140 def : InstAlias<"mfasr $RT", (MFSPR8 g8rc:$RT, 280)>;
1141 def : InstAlias<"mtasr $RT", (MTSPR8 280, g8rc:$RT)>;
1143 def : InstAlias<"mttbl $Rx", (MTSPR8 284, g8rc:$Rx)>;
1144 def : InstAlias<"mttbu $Rx", (MTSPR8 285, g8rc:$Rx)>;
1146 def : InstAlias<"mfpvr $RT", (MFSPR8 g8rc:$RT, 287)>;
1148 def : InstAlias<"mfspefscr $Rx", (MFSPR8 g8rc:$Rx, 512)>;
1149 def : InstAlias<"mtspefscr $Rx", (MTSPR8 512, g8rc:$Rx)>;
1153 //===----------------------------------------------------------------------===//
1154 // Load/Store instructions.
1158 // Sign extending loads.
1159 let PPC970_Unit = 2 in {
1160 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
1161 def LHA8: DForm_1<42, (outs g8rc:$rD), (ins memri:$src),
1162 "lha $rD, $src", IIC_LdStLHA,
1163 [(set i64:$rD, (sextloadi16 DForm:$src))]>,
1164 PPC970_DGroup_Cracked;
1165 def LWA : DSForm_1<58, 2, (outs g8rc:$rD), (ins memrix:$src),
1166 "lwa $rD, $src", IIC_LdStLWA,
1168 (sextloadi32 DSForm:$src))]>, isPPC64,
1169 PPC970_DGroup_Cracked;
1170 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
1171 def LHAX8: XForm_1_memOp<31, 343, (outs g8rc:$rD), (ins memrr:$src),
1172 "lhax $rD, $src", IIC_LdStLHA,
1173 [(set i64:$rD, (sextloadi16 XForm:$src))]>,
1174 PPC970_DGroup_Cracked;
1175 def LWAX : XForm_1_memOp<31, 341, (outs g8rc:$rD), (ins memrr:$src),
1176 "lwax $rD, $src", IIC_LdStLHA,
1177 [(set i64:$rD, (sextloadi32 XForm:$src))]>, isPPC64,
1178 PPC970_DGroup_Cracked;
1180 let isCodeGenOnly = 1, mayLoad = 1, hasSideEffects = 0 in {
1181 def LWA_32 : DSForm_1<58, 2, (outs gprc:$rD), (ins memrix:$src),
1182 "lwa $rD, $src", IIC_LdStLWA, []>, isPPC64,
1183 PPC970_DGroup_Cracked;
1184 def LWAX_32 : XForm_1_memOp<31, 341, (outs gprc:$rD), (ins memrr:$src),
1185 "lwax $rD, $src", IIC_LdStLHA, []>, isPPC64,
1186 PPC970_DGroup_Cracked;
1187 } // end fast-isel isCodeGenOnly
1190 let mayLoad = 1, hasSideEffects = 0 in {
1191 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
1192 def LHAU8 : DForm_1<43, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
1194 "lhau $rD, $addr", IIC_LdStLHAU,
1195 []>, RegConstraint<"$addr.reg = $ea_result">,
1196 NoEncode<"$ea_result">;
1199 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
1200 def LHAUX8 : XForm_1_memOp<31, 375, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
1202 "lhaux $rD, $addr", IIC_LdStLHAUX,
1203 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1204 NoEncode<"$ea_result">;
1205 def LWAUX : XForm_1_memOp<31, 373, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
1207 "lwaux $rD, $addr", IIC_LdStLHAUX,
1208 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1209 NoEncode<"$ea_result">, isPPC64;
1213 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
1214 // Zero extending loads.
1215 let PPC970_Unit = 2 in {
1216 def LBZ8 : DForm_1<34, (outs g8rc:$rD), (ins memri:$src),
1217 "lbz $rD, $src", IIC_LdStLoad,
1218 [(set i64:$rD, (zextloadi8 DForm:$src))]>;
1219 def LHZ8 : DForm_1<40, (outs g8rc:$rD), (ins memri:$src),
1220 "lhz $rD, $src", IIC_LdStLoad,
1221 [(set i64:$rD, (zextloadi16 DForm:$src))]>;
1222 def LWZ8 : DForm_1<32, (outs g8rc:$rD), (ins memri:$src),
1223 "lwz $rD, $src", IIC_LdStLoad,
1224 [(set i64:$rD, (zextloadi32 DForm:$src))]>, isPPC64;
1226 def LBZX8 : XForm_1_memOp<31, 87, (outs g8rc:$rD), (ins memrr:$src),
1227 "lbzx $rD, $src", IIC_LdStLoad,
1228 [(set i64:$rD, (zextloadi8 XForm:$src))]>;
1229 def LHZX8 : XForm_1_memOp<31, 279, (outs g8rc:$rD), (ins memrr:$src),
1230 "lhzx $rD, $src", IIC_LdStLoad,
1231 [(set i64:$rD, (zextloadi16 XForm:$src))]>;
1232 def LWZX8 : XForm_1_memOp<31, 23, (outs g8rc:$rD), (ins memrr:$src),
1233 "lwzx $rD, $src", IIC_LdStLoad,
1234 [(set i64:$rD, (zextloadi32 XForm:$src))]>;
1238 let mayLoad = 1, hasSideEffects = 0 in {
1239 def LBZU8 : DForm_1<35, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
1241 "lbzu $rD, $addr", IIC_LdStLoadUpd,
1242 []>, RegConstraint<"$addr.reg = $ea_result">,
1243 NoEncode<"$ea_result">;
1244 def LHZU8 : DForm_1<41, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
1246 "lhzu $rD, $addr", IIC_LdStLoadUpd,
1247 []>, RegConstraint<"$addr.reg = $ea_result">,
1248 NoEncode<"$ea_result">;
1249 def LWZU8 : DForm_1<33, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
1251 "lwzu $rD, $addr", IIC_LdStLoadUpd,
1252 []>, RegConstraint<"$addr.reg = $ea_result">,
1253 NoEncode<"$ea_result">;
1255 def LBZUX8 : XForm_1_memOp<31, 119, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
1257 "lbzux $rD, $addr", IIC_LdStLoadUpdX,
1258 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1259 NoEncode<"$ea_result">;
1260 def LHZUX8 : XForm_1_memOp<31, 311, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
1262 "lhzux $rD, $addr", IIC_LdStLoadUpdX,
1263 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1264 NoEncode<"$ea_result">;
1265 def LWZUX8 : XForm_1_memOp<31, 55, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
1267 "lwzux $rD, $addr", IIC_LdStLoadUpdX,
1268 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1269 NoEncode<"$ea_result">;
1272 } // Interpretation64Bit
1275 // Full 8-byte loads.
1276 let PPC970_Unit = 2 in {
1277 def LD : DSForm_1<58, 0, (outs g8rc:$rD), (ins memrix:$src),
1278 "ld $rD, $src", IIC_LdStLD,
1279 [(set i64:$rD, (load DSForm:$src))]>, isPPC64;
1280 // The following four definitions are selected for small code model only.
1281 // Otherwise, we need to create two instructions to form a 32-bit offset,
1282 // so we have a custom matcher for TOC_ENTRY in PPCDAGToDAGIsel::Select().
1283 def LDtoc: PPCEmitTimePseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
1286 (PPCtoc_entry tglobaladdr:$disp, i64:$reg))]>, isPPC64;
1287 def LDtocJTI: PPCEmitTimePseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
1290 (PPCtoc_entry tjumptable:$disp, i64:$reg))]>, isPPC64;
1291 def LDtocCPT: PPCEmitTimePseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
1294 (PPCtoc_entry tconstpool:$disp, i64:$reg))]>, isPPC64;
1295 def LDtocBA: PPCEmitTimePseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
1298 (PPCtoc_entry tblockaddress:$disp, i64:$reg))]>, isPPC64;
1300 def LDX : XForm_1_memOp<31, 21, (outs g8rc:$rD), (ins memrr:$src),
1301 "ldx $rD, $src", IIC_LdStLD,
1302 [(set i64:$rD, (load XForm:$src))]>, isPPC64;
1303 def LDBRX : XForm_1_memOp<31, 532, (outs g8rc:$rD), (ins memrr:$src),
1304 "ldbrx $rD, $src", IIC_LdStLoad,
1305 [(set i64:$rD, (PPClbrx ForceXForm:$src, i64))]>, isPPC64;
1307 let mayLoad = 1, hasSideEffects = 0, isCodeGenOnly = 1 in {
1308 def LHBRX8 : XForm_1_memOp<31, 790, (outs g8rc:$rD), (ins memrr:$src),
1309 "lhbrx $rD, $src", IIC_LdStLoad, []>;
1310 def LWBRX8 : XForm_1_memOp<31, 534, (outs g8rc:$rD), (ins memrr:$src),
1311 "lwbrx $rD, $src", IIC_LdStLoad, []>;
1314 let mayLoad = 1, hasSideEffects = 0 in {
1315 def LDU : DSForm_1<58, 1, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
1317 "ldu $rD, $addr", IIC_LdStLDU,
1318 []>, RegConstraint<"$addr.reg = $ea_result">, isPPC64,
1319 NoEncode<"$ea_result">;
1321 def LDUX : XForm_1_memOp<31, 53, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
1323 "ldux $rD, $addr", IIC_LdStLDUX,
1324 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1325 NoEncode<"$ea_result">, isPPC64;
1327 def LDMX : XForm_1<31, 309, (outs g8rc:$rD), (ins memrr:$src),
1328 "ldmx $rD, $src", IIC_LdStLD, []>, isPPC64,
1329 Requires<[IsISA3_0]>;
1332 let mayLoad = 1, hasNoSchedulingInfo = 1 in {
1333 // Full 16-byte load.
1334 // Early clobber $RTp to avoid assigned to the same register as RA.
1335 // TODO: Add scheduling info.
1336 def LQ : DQForm_RTp5_RA17_MEM<56, 0,
1338 (ins memrix16:$src),
1339 "lq $RTp, $src", IIC_LdStLQ,
1341 RegConstraint<"@earlyclobber $RTp">,
1343 def RESTORE_QUADWORD : PPCEmitTimePseudo<(outs g8prc:$RTp), (ins memrix:$src),
1344 "#RESTORE_QUADWORD", []>;
1349 // Support for medium and large code model.
1350 let hasSideEffects = 0 in {
1351 let isReMaterializable = 1 in {
1352 def ADDIStocHA8: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, tocentry:$disp),
1353 "#ADDIStocHA8", []>, isPPC64;
1354 def ADDItocL: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, tocentry:$disp),
1355 "#ADDItocL", []>, isPPC64;
1358 def LDtocL: PPCEmitTimePseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc_nox0:$reg),
1359 "#LDtocL", []>, isPPC64;
1362 // Support for thread-local storage.
1363 def ADDISgotTprelHA: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
1366 (PPCaddisGotTprelHA i64:$reg,
1367 tglobaltlsaddr:$disp))]>,
1369 def LDgotTprelL: PPCEmitTimePseudo<(outs g8rc_nox0:$rD), (ins s16imm64:$disp, g8rc_nox0:$reg),
1372 (PPCldGotTprelL tglobaltlsaddr:$disp, i64:$reg))]>,
1375 let Defs = [CR7], Itinerary = IIC_LdStSync in
1376 def CFENCE8 : PPCPostRAExpPseudo<(outs), (ins g8rc:$cr), "#CFENCE8", []>;
1378 def : Pat<(PPCaddTls i64:$in, tglobaltlsaddr:$g),
1379 (ADD8TLS $in, tglobaltlsaddr:$g)>;
1380 def ADDIStlsgdHA: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
1383 (PPCaddisTlsgdHA i64:$reg, tglobaltlsaddr:$disp))]>,
1385 def ADDItlsgdL : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
1388 (PPCaddiTlsgdL i64:$reg, tglobaltlsaddr:$disp))]>,
1391 class GETtlsADDRPseudo <string asmstr> : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc:$reg, tlsgd:$sym),
1394 (PPCgetTlsAddr i64:$reg, tglobaltlsaddr:$sym))]>,
1396 class GETtlsldADDRPseudo <string asmstr> : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc:$reg, tlsgd:$sym),
1399 (PPCgetTlsldAddr i64:$reg, tglobaltlsaddr:$sym))]>,
1402 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1 in {
1403 // LR8 is a true define, while the rest of the Defs are clobbers. X3 is
1404 // explicitly defined when this op is created, so not mentioned here.
1405 // This is lowered to BL8_NOP_TLS by the assembly printer, so the size must be
1406 // correct because the branch select pass is relying on it.
1407 let Defs = [X0,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7], Size = 8 in
1408 def GETtlsADDR : GETtlsADDRPseudo <"#GETtlsADDR">;
1409 let Defs = [X0,X2,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7], Size = 8 in
1410 def GETtlsADDRPCREL : GETtlsADDRPseudo <"#GETtlsADDRPCREL">;
1412 // LR8 is a true define, while the rest of the Defs are clobbers. X3 is
1413 // explicitly defined when this op is created, so not mentioned here.
1414 let Defs = [X0,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7] in
1415 def GETtlsldADDR : GETtlsldADDRPseudo <"#GETtlsldADDR">;
1416 let Defs = [X0,X2,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7] in
1417 def GETtlsldADDRPCREL : GETtlsldADDRPseudo <"#GETtlsldADDRPCREL">;
1419 // On AIX, the call to __tls_get_addr needs two inputs in X3/X4 for the
1420 // offset and region handle respectively. The call is not followed by a nop
1421 // so we don't need to mark it with a size of 8 bytes. Finally, the assembly
1422 // manual mentions this exact set of registers as the clobbered set, others
1423 // are guaranteed not to be clobbered.
1424 let Defs = [X0,X4,X5,X11,LR8,CR0] in
1425 def GETtlsADDR64AIX :
1426 PPCEmitTimePseudo<(outs g8rc:$rD),(ins g8rc:$offset, g8rc:$handle),
1429 (PPCgetTlsAddr i64:$offset, i64:$handle))]>, isPPC64;
1432 // Combined op for ADDItlsgdL and GETtlsADDR, late expanded. X3 and LR8
1433 // are true defines while the rest of the Defs are clobbers.
1434 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
1435 Defs = [X0,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7]
1437 def ADDItlsgdLADDR : PPCEmitTimePseudo<(outs g8rc:$rD),
1438 (ins g8rc_nox0:$reg, s16imm64:$disp, tlsgd:$sym),
1441 (PPCaddiTlsgdLAddr i64:$reg,
1442 tglobaltlsaddr:$disp,
1443 tglobaltlsaddr:$sym))]>,
1445 def ADDIStlsldHA: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
1448 (PPCaddisTlsldHA i64:$reg, tglobaltlsaddr:$disp))]>,
1450 def ADDItlsldL : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
1453 (PPCaddiTlsldL i64:$reg, tglobaltlsaddr:$disp))]>,
1455 // This pseudo is expanded to two copies to put the variable offset in R4 and
1456 // the region handle in R3 and GETtlsADDR64AIX.
1458 PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc:$offset, g8rc:$handle),
1461 (PPCTlsgdAIX i64:$offset, i64:$handle))]>;
1462 // Combined op for ADDItlsldL and GETtlsADDR, late expanded. X3 and LR8
1463 // are true defines, while the rest of the Defs are clobbers.
1464 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
1465 Defs = [X0,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7]
1467 def ADDItlsldLADDR : PPCEmitTimePseudo<(outs g8rc:$rD),
1468 (ins g8rc_nox0:$reg, s16imm64:$disp, tlsgd:$sym),
1471 (PPCaddiTlsldLAddr i64:$reg,
1472 tglobaltlsaddr:$disp,
1473 tglobaltlsaddr:$sym))]>,
1475 def ADDISdtprelHA: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
1478 (PPCaddisDtprelHA i64:$reg,
1479 tglobaltlsaddr:$disp))]>,
1481 def ADDIdtprelL : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
1484 (PPCaddiDtprelL i64:$reg, tglobaltlsaddr:$disp))]>,
1486 def PADDIdtprel : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
1489 (PPCpaddiDtprel i64:$reg, tglobaltlsaddr:$disp))]>,
1492 let PPC970_Unit = 2 in {
1493 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
1494 // Truncating stores.
1495 def STB8 : DForm_1<38, (outs), (ins g8rc:$rS, memri:$src),
1496 "stb $rS, $src", IIC_LdStStore,
1497 [(truncstorei8 i64:$rS, DForm:$src)]>;
1498 def STH8 : DForm_1<44, (outs), (ins g8rc:$rS, memri:$src),
1499 "sth $rS, $src", IIC_LdStStore,
1500 [(truncstorei16 i64:$rS, DForm:$src)]>;
1501 def STW8 : DForm_1<36, (outs), (ins g8rc:$rS, memri:$src),
1502 "stw $rS, $src", IIC_LdStStore,
1503 [(truncstorei32 i64:$rS, DForm:$src)]>;
1504 def STBX8 : XForm_8_memOp<31, 215, (outs), (ins g8rc:$rS, memrr:$dst),
1505 "stbx $rS, $dst", IIC_LdStStore,
1506 [(truncstorei8 i64:$rS, XForm:$dst)]>,
1507 PPC970_DGroup_Cracked;
1508 def STHX8 : XForm_8_memOp<31, 407, (outs), (ins g8rc:$rS, memrr:$dst),
1509 "sthx $rS, $dst", IIC_LdStStore,
1510 [(truncstorei16 i64:$rS, XForm:$dst)]>,
1511 PPC970_DGroup_Cracked;
1512 def STWX8 : XForm_8_memOp<31, 151, (outs), (ins g8rc:$rS, memrr:$dst),
1513 "stwx $rS, $dst", IIC_LdStStore,
1514 [(truncstorei32 i64:$rS, XForm:$dst)]>,
1515 PPC970_DGroup_Cracked;
1516 } // Interpretation64Bit
1518 // Normal 8-byte stores.
1519 def STD : DSForm_1<62, 0, (outs), (ins g8rc:$rS, memrix:$dst),
1520 "std $rS, $dst", IIC_LdStSTD,
1521 [(store i64:$rS, DSForm:$dst)]>, isPPC64;
1522 def STDX : XForm_8_memOp<31, 149, (outs), (ins g8rc:$rS, memrr:$dst),
1523 "stdx $rS, $dst", IIC_LdStSTD,
1524 [(store i64:$rS, XForm:$dst)]>, isPPC64,
1525 PPC970_DGroup_Cracked;
1526 def STDBRX: XForm_8_memOp<31, 660, (outs), (ins g8rc:$rS, memrr:$dst),
1527 "stdbrx $rS, $dst", IIC_LdStStore,
1528 [(PPCstbrx i64:$rS, ForceXForm:$dst, i64)]>, isPPC64,
1529 PPC970_DGroup_Cracked;
1531 let mayStore = 1, hasNoSchedulingInfo = 1 in {
1532 // Normal 16-byte stores.
1533 // TODO: Add scheduling info.
1534 def STQ : DSForm_1<62, 2, (outs), (ins g8prc:$RSp, memrix:$dst),
1535 "stq $RSp, $dst", IIC_LdStSTQ,
1537 def SPILL_QUADWORD : PPCEmitTimePseudo<(outs), (ins g8prc:$RSp, memrix:$dst),
1538 "#SPILL_QUADWORD", []>;
1543 // Stores with Update (pre-inc).
1544 let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in {
1545 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
1546 def STBU8 : DForm_1<39, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memri:$dst),
1547 "stbu $rS, $dst", IIC_LdStSTU, []>,
1548 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
1549 def STHU8 : DForm_1<45, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memri:$dst),
1550 "sthu $rS, $dst", IIC_LdStSTU, []>,
1551 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
1552 def STWU8 : DForm_1<37, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memri:$dst),
1553 "stwu $rS, $dst", IIC_LdStSTU, []>,
1554 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
1556 def STBUX8: XForm_8_memOp<31, 247, (outs ptr_rc_nor0:$ea_res),
1557 (ins g8rc:$rS, memrr:$dst),
1558 "stbux $rS, $dst", IIC_LdStSTUX, []>,
1559 RegConstraint<"$dst.ptrreg = $ea_res">,
1560 NoEncode<"$ea_res">,
1561 PPC970_DGroup_Cracked;
1562 def STHUX8: XForm_8_memOp<31, 439, (outs ptr_rc_nor0:$ea_res),
1563 (ins g8rc:$rS, memrr:$dst),
1564 "sthux $rS, $dst", IIC_LdStSTUX, []>,
1565 RegConstraint<"$dst.ptrreg = $ea_res">,
1566 NoEncode<"$ea_res">,
1567 PPC970_DGroup_Cracked;
1568 def STWUX8: XForm_8_memOp<31, 183, (outs ptr_rc_nor0:$ea_res),
1569 (ins g8rc:$rS, memrr:$dst),
1570 "stwux $rS, $dst", IIC_LdStSTUX, []>,
1571 RegConstraint<"$dst.ptrreg = $ea_res">,
1572 NoEncode<"$ea_res">,
1573 PPC970_DGroup_Cracked;
1574 } // Interpretation64Bit
1576 def STDU : DSForm_1<62, 1, (outs ptr_rc_nor0:$ea_res),
1577 (ins g8rc:$rS, memrix:$dst),
1578 "stdu $rS, $dst", IIC_LdStSTU, []>,
1579 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">,
1582 def STDUX : XForm_8_memOp<31, 181, (outs ptr_rc_nor0:$ea_res),
1583 (ins g8rc:$rS, memrr:$dst),
1584 "stdux $rS, $dst", IIC_LdStSTUX, []>,
1585 RegConstraint<"$dst.ptrreg = $ea_res">,
1586 NoEncode<"$ea_res">,
1587 PPC970_DGroup_Cracked, isPPC64;
1590 // Patterns to match the pre-inc stores. We can't put the patterns on
1591 // the instruction definitions directly as ISel wants the address base
1592 // and offset to be separate operands, not a single complex operand.
1593 def : Pat<(pre_truncsti8 i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1594 (STBU8 $rS, iaddroff:$ptroff, $ptrreg)>;
1595 def : Pat<(pre_truncsti16 i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1596 (STHU8 $rS, iaddroff:$ptroff, $ptrreg)>;
1597 def : Pat<(pre_truncsti32 i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1598 (STWU8 $rS, iaddroff:$ptroff, $ptrreg)>;
1599 def : Pat<(DSFormPreStore i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1600 (STDU $rS, iaddroff:$ptroff, $ptrreg)>;
1602 def : Pat<(pre_truncsti8 i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1603 (STBUX8 $rS, $ptrreg, $ptroff)>;
1604 def : Pat<(pre_truncsti16 i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1605 (STHUX8 $rS, $ptrreg, $ptroff)>;
1606 def : Pat<(pre_truncsti32 i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1607 (STWUX8 $rS, $ptrreg, $ptroff)>;
1608 def : Pat<(pre_store i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1609 (STDUX $rS, $ptrreg, $ptroff)>;
1612 //===----------------------------------------------------------------------===//
1613 // Floating point instructions.
1617 let PPC970_Unit = 3, hasSideEffects = 0, mayRaiseFPException = 1,
1618 Uses = [RM] in { // FPU Operations.
1619 defm FCFID : XForm_26r<63, 846, (outs f8rc:$frD), (ins f8rc:$frB),
1620 "fcfid", "$frD, $frB", IIC_FPGeneral,
1621 [(set f64:$frD, (PPCany_fcfid f64:$frB))]>, isPPC64;
1622 defm FCTID : XForm_26r<63, 814, (outs f8rc:$frD), (ins f8rc:$frB),
1623 "fctid", "$frD, $frB", IIC_FPGeneral,
1625 defm FCTIDU : XForm_26r<63, 942, (outs f8rc:$frD), (ins f8rc:$frB),
1626 "fctidu", "$frD, $frB", IIC_FPGeneral,
1628 defm FCTIDZ : XForm_26r<63, 815, (outs f8rc:$frD), (ins f8rc:$frB),
1629 "fctidz", "$frD, $frB", IIC_FPGeneral,
1630 [(set f64:$frD, (PPCany_fctidz f64:$frB))]>, isPPC64;
1632 defm FCFIDU : XForm_26r<63, 974, (outs f8rc:$frD), (ins f8rc:$frB),
1633 "fcfidu", "$frD, $frB", IIC_FPGeneral,
1634 [(set f64:$frD, (PPCany_fcfidu f64:$frB))]>, isPPC64;
1635 defm FCFIDS : XForm_26r<59, 846, (outs f4rc:$frD), (ins f8rc:$frB),
1636 "fcfids", "$frD, $frB", IIC_FPGeneral,
1637 [(set f32:$frD, (PPCany_fcfids f64:$frB))]>, isPPC64;
1638 defm FCFIDUS : XForm_26r<59, 974, (outs f4rc:$frD), (ins f8rc:$frB),
1639 "fcfidus", "$frD, $frB", IIC_FPGeneral,
1640 [(set f32:$frD, (PPCany_fcfidus f64:$frB))]>, isPPC64;
1641 defm FCTIDUZ : XForm_26r<63, 943, (outs f8rc:$frD), (ins f8rc:$frB),
1642 "fctiduz", "$frD, $frB", IIC_FPGeneral,
1643 [(set f64:$frD, (PPCany_fctiduz f64:$frB))]>, isPPC64;
1644 defm FCTIWUZ : XForm_26r<63, 143, (outs f8rc:$frD), (ins f8rc:$frB),
1645 "fctiwuz", "$frD, $frB", IIC_FPGeneral,
1646 [(set f64:$frD, (PPCany_fctiwuz f64:$frB))]>, isPPC64;
1649 // These instructions store a hash computed from the value of the link register
1650 // and the value of the stack pointer.
1651 let mayStore = 1 in {
1652 def HASHST : XForm_XD6_RA5_RB5<31, 722, (outs),
1653 (ins g8rc:$RB, memrihash:$D_RA_XD),
1654 "hashst $RB, $D_RA_XD", IIC_IntGeneral, []>;
1655 def HASHSTP : XForm_XD6_RA5_RB5<31, 658, (outs),
1656 (ins g8rc:$RB, memrihash:$D_RA_XD),
1657 "hashstp $RB, $D_RA_XD", IIC_IntGeneral, []>;
1660 // These instructions check a hash computed from the value of the link register
1661 // and the value of the stack pointer. The hasSideEffects flag is needed as the
1662 // instruction may TRAP if the hash does not match the hash stored at the
1663 // specified address.
1664 let mayLoad = 1, hasSideEffects = 1 in {
1665 def HASHCHK : XForm_XD6_RA5_RB5<31, 754, (outs),
1666 (ins g8rc:$RB, memrihash:$D_RA_XD),
1667 "hashchk $RB, $D_RA_XD", IIC_IntGeneral, []>;
1668 def HASHCHKP : XForm_XD6_RA5_RB5<31, 690, (outs),
1669 (ins g8rc:$RB, memrihash:$D_RA_XD),
1670 "hashchkp $RB, $D_RA_XD", IIC_IntGeneral, []>;
1673 let Interpretation64Bit = 1, isCodeGenOnly = 1, hasSideEffects = 1 in
1674 def ADDEX8 : Z23Form_RTAB5_CY2<31, 170, (outs g8rc:$rT),
1675 (ins g8rc:$rA, g8rc:$rB, u2imm:$CY),
1676 "addex $rT, $rA, $rB, $CY", IIC_IntGeneral,
1677 [(set i64:$rT, (int_ppc_addex i64:$rA, i64:$rB,
1680 //===----------------------------------------------------------------------===//
1681 // Instruction Patterns
1684 // Extensions and truncates to/from 32-bit regs.
1685 def : Pat<(i64 (zext i32:$in)),
1686 (RLDICL (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $in, sub_32),
1688 def : Pat<(i64 (anyext i32:$in)),
1689 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $in, sub_32)>;
1690 def : Pat<(i32 (trunc i64:$in)),
1691 (EXTRACT_SUBREG $in, sub_32)>;
1693 // Implement the 'not' operation with the NOR instruction.
1694 // (we could use the default xori pattern, but nor has lower latency on some
1695 // cores (such as the A2)).
1696 def i64not : OutPatFrag<(ops node:$in),
1698 def : Pat<(not i64:$in),
1701 // Extending loads with i64 targets.
1702 def : Pat<(zextloadi1 DForm:$src),
1704 def : Pat<(zextloadi1 XForm:$src),
1705 (LBZX8 XForm:$src)>;
1706 def : Pat<(extloadi1 DForm:$src),
1708 def : Pat<(extloadi1 XForm:$src),
1709 (LBZX8 XForm:$src)>;
1710 def : Pat<(extloadi8 DForm:$src),
1712 def : Pat<(extloadi8 XForm:$src),
1713 (LBZX8 XForm:$src)>;
1714 def : Pat<(extloadi16 DForm:$src),
1716 def : Pat<(extloadi16 XForm:$src),
1717 (LHZX8 XForm:$src)>;
1718 def : Pat<(extloadi32 DForm:$src),
1720 def : Pat<(extloadi32 XForm:$src),
1721 (LWZX8 XForm:$src)>;
1723 // Standard shifts. These are represented separately from the real shifts above
1724 // so that we can distinguish between shifts that allow 6-bit and 7-bit shift
1726 def : Pat<(sra i64:$rS, i32:$rB),
1728 def : Pat<(srl i64:$rS, i32:$rB),
1730 def : Pat<(shl i64:$rS, i32:$rB),
1734 def : Pat<(sub imm64SExt16:$imm, i64:$in),
1735 (SUBFIC8 $in, imm:$imm)>;
1738 def : Pat<(shl i64:$in, (i32 imm:$imm)),
1739 (RLDICR $in, imm:$imm, (SHL64 imm:$imm))>;
1740 def : Pat<(srl i64:$in, (i32 imm:$imm)),
1741 (RLDICL $in, (SRL64 imm:$imm), imm:$imm)>;
1744 def : Pat<(rotl i64:$in, i32:$sh),
1745 (RLDCL $in, $sh, 0)>;
1746 def : Pat<(rotl i64:$in, (i32 imm:$imm)),
1747 (RLDICL $in, imm:$imm, 0)>;
1749 // Hi and Lo for Darwin Global Addresses.
1750 def : Pat<(PPChi tglobaladdr:$in, 0), (LIS8 tglobaladdr:$in)>;
1751 def : Pat<(PPClo tglobaladdr:$in, 0), (LI8 tglobaladdr:$in)>;
1752 def : Pat<(PPChi tconstpool:$in , 0), (LIS8 tconstpool:$in)>;
1753 def : Pat<(PPClo tconstpool:$in , 0), (LI8 tconstpool:$in)>;
1754 def : Pat<(PPChi tjumptable:$in , 0), (LIS8 tjumptable:$in)>;
1755 def : Pat<(PPClo tjumptable:$in , 0), (LI8 tjumptable:$in)>;
1756 def : Pat<(PPChi tblockaddress:$in, 0), (LIS8 tblockaddress:$in)>;
1757 def : Pat<(PPClo tblockaddress:$in, 0), (LI8 tblockaddress:$in)>;
1758 def : Pat<(PPChi tglobaltlsaddr:$g, i64:$in),
1759 (ADDIS8 $in, tglobaltlsaddr:$g)>;
1760 def : Pat<(PPClo tglobaltlsaddr:$g, i64:$in),
1761 (ADDI8 $in, tglobaltlsaddr:$g)>;
1762 def : Pat<(add i64:$in, (PPChi tglobaladdr:$g, 0)),
1763 (ADDIS8 $in, tglobaladdr:$g)>;
1764 def : Pat<(add i64:$in, (PPChi tconstpool:$g, 0)),
1765 (ADDIS8 $in, tconstpool:$g)>;
1766 def : Pat<(add i64:$in, (PPChi tjumptable:$g, 0)),
1767 (ADDIS8 $in, tjumptable:$g)>;
1768 def : Pat<(add i64:$in, (PPChi tblockaddress:$g, 0)),
1769 (ADDIS8 $in, tblockaddress:$g)>;
1771 // AIX 64-bit small code model TLS access.
1772 def : Pat<(i64 (PPCtoc_entry tglobaltlsaddr:$disp, i64:$reg)),
1773 (i64 (LDtoc tglobaltlsaddr:$disp, i64:$reg))>;
1775 // 64-bits atomic loads and stores
1776 def : Pat<(atomic_load_64 DSForm:$src), (LD memrix:$src)>;
1777 def : Pat<(atomic_load_64 XForm:$src), (LDX memrr:$src)>;
1779 def : Pat<(atomic_store_64 DSForm:$ptr, i64:$val), (STD g8rc:$val, memrix:$ptr)>;
1780 def : Pat<(atomic_store_64 XForm:$ptr, i64:$val), (STDX g8rc:$val, memrr:$ptr)>;
1782 let Predicates = [IsISA3_0, In64BitMode] in {
1783 def : Pat<(i64 (int_ppc_cmpeqb g8rc:$a, g8rc:$b)),
1784 (i64 (SETB8 (CMPEQB $a, $b)))>;
1785 def : Pat<(i64 (int_ppc_setb g8rc:$a, g8rc:$b)),
1786 (i64 (SETB8 (CMPD $a, $b)))>;
1787 def : Pat<(i64 (int_ppc_maddhd g8rc:$a, g8rc:$b, g8rc:$c)),
1788 (i64 (MADDHD $a, $b, $c))>;
1789 def : Pat<(i64 (int_ppc_maddhdu g8rc:$a, g8rc:$b, g8rc:$c)),
1790 (i64 (MADDHDU $a, $b, $c))>;
1791 def : Pat<(i64 (int_ppc_maddld g8rc:$a, g8rc:$b, g8rc:$c)),
1792 (i64 (MADDLD8 $a, $b, $c))>;
1795 let Predicates = [In64BitMode] in {
1796 def : Pat<(i64 (int_ppc_mulhd g8rc:$a, g8rc:$b)),
1797 (i64 (MULHD $a, $b))>;
1798 def : Pat<(i64 (int_ppc_mulhdu g8rc:$a, g8rc:$b)),
1799 (i64 (MULHDU $a, $b))>;
1800 def : Pat<(int_ppc_load8r ForceXForm:$ptr),
1801 (LDBRX ForceXForm:$ptr)>;
1802 def : Pat<(int_ppc_store8r g8rc:$a, ForceXForm:$ptr),
1803 (STDBRX g8rc:$a, ForceXForm:$ptr)>;
1806 def : Pat<(i64 (int_ppc_cmpb g8rc:$a, g8rc:$b)),
1807 (i64 (CMPB8 $a, $b))>;
1809 let Predicates = [IsISA3_0] in {
1810 // DARN (deliver random number)
1811 // L=0 for 32-bit, L=1 for conditioned random, L=2 for raw random
1812 def : Pat<(int_ppc_darn32), (EXTRACT_SUBREG (DARN 0), sub_32)>;
1813 def : Pat<(int_ppc_darn), (DARN 1)>;
1814 def : Pat<(int_ppc_darnraw), (DARN 2)>;
1816 class X_RA5_RB5<bits<6> opcode, bits<10> xo, string opc, RegisterOperand ty,
1817 InstrItinClass itin, list<dag> pattern>
1818 : X_L1_RS5_RS5<opcode, xo, (outs), (ins ty:$rA, ty:$rB, u1imm:$L),
1819 !strconcat(opc, " $rA, $rB"), itin, pattern>{
1823 class X_L1_RA5_RB5<bits<6> opcode, bits<10> xo, string opc, RegisterOperand ty,
1824 InstrItinClass itin, list<dag> pattern>
1825 : X_L1_RS5_RS5<opcode, xo, (outs), (ins ty:$rA, ty:$rB, u1imm:$L),
1826 !strconcat(opc, " $rA, $rB, $L"), itin, pattern>;
1828 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
1829 def CP_COPY8 : X_RA5_RB5<31, 774, "copy" , g8rc, IIC_LdStCOPY, []>;
1830 def CP_PASTE8_rec : X_L1_RA5_RB5<31, 902, "paste.", g8rc, IIC_LdStPASTE, []>,isRecordForm;
1833 // SLB Invalidate Entry Global
1834 def SLBIEG : XForm_26<31, 466, (outs), (ins gprc:$RS, gprc:$RB),
1835 "slbieg $RS, $RB", IIC_SprSLBIEG, []>;
1837 def SLBSYNC : XForm_0<31, 338, (outs), (ins), "slbsync", IIC_SprSLBSYNC, []>;
1841 def : Pat<(int_ppc_stdcx ForceXForm:$dst, g8rc:$A),
1842 (STDCX g8rc:$A, ForceXForm:$dst)>;
1843 def : Pat<(int_ppc_tdw g8rc:$A, g8rc:$B, i32:$IMM),
1847 def : Pat<(int_ppc_trapd g8rc:$A),
1849 def : Pat<(i64 (int_ppc_mfspr timm:$SPR)),
1851 def : Pat<(int_ppc_mtspr timm:$SPR, g8rc:$RT),
1852 (MTSPR8 $SPR, $RT)>;