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, hasSideEffects = 0 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 [(PPCretglue)]>, 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 $BIBO, $CR):$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, hasSideEffects = 0 in {
104 let Defs = [CTR8], Uses = [CTR8] in {
105 def BDZ8 : BForm_1<16, 18, 0, 0, (outs), (ins condbrtarget:$BD),
107 def BDNZ8 : BForm_1<16, 16, 0, 0, (outs), (ins condbrtarget:$BD),
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], hasSideEffects = 0 in {
122 // Convenient aliases for call instructions
124 def BL8 : IForm<18, 0, 1, (outs), (ins calltarget:$LI),
125 "bl $LI", IIC_BrB, []>; // See Pat patterns below.
127 def BL8_TLS : IForm<18, 0, 1, (outs), (ins tlscall:$LI),
128 "bl $LI", IIC_BrB, []>;
130 def BLA8 : IForm<18, 1, 1, (outs), (ins abscalltarget:$LI),
131 "bla $LI", IIC_BrB, [(PPCcall (i64 imm:$LI))]>;
133 let Uses = [RM], isCodeGenOnly = 1 in {
134 def BL8_NOP : IForm_and_DForm_4_zero<18, 0, 1, 24,
135 (outs), (ins calltarget:$LI),
136 "bl $LI\n\tnop", IIC_BrB, []>;
138 def BL8_NOP_TLS : IForm_and_DForm_4_zero<18, 0, 1, 24,
139 (outs), (ins tlscall:$LI),
140 "bl $LI\n\tnop", IIC_BrB, []>;
142 def BLA8_NOP : IForm_and_DForm_4_zero<18, 1, 1, 24,
143 (outs), (ins abscalltarget:$LI),
144 "bla $LI\n\tnop", IIC_BrB,
145 [(PPCcall_nop (i64 imm:$LI))]>;
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:$LI),
153 "bl $LI", IIC_BrB, []>;
154 def BL8_NOTOC_TLS : IForm<18, 0, 1, (outs),
156 "bl $LI", 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 $BIBO, $CR):$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, Defs = [LR8, RM], hasSideEffects = 0,
182 isCodeGenOnly = 1, Uses = [RM] in {
183 // Convenient aliases for call instructions
184 def BL8_RM : IForm<18, 0, 1, (outs), (ins calltarget:$LI),
185 "bl $LI", IIC_BrB, []>; // See Pat patterns below.
187 def BLA8_RM : IForm<18, 1, 1, (outs), (ins abscalltarget:$LI),
188 "bla $LI", IIC_BrB, [(PPCcall_rm (i64 imm:$LI))]>;
189 def BL8_NOP_RM : IForm_and_DForm_4_zero<18, 0, 1, 24,
190 (outs), (ins calltarget:$LI),
191 "bl $LI\n\tnop", IIC_BrB, []>;
193 def BLA8_NOP_RM : IForm_and_DForm_4_zero<18, 1, 1, 24,
194 (outs), (ins abscalltarget:$LI),
195 "bla $LI\n\tnop", IIC_BrB,
196 [(PPCcall_nop_rm (i64 imm:$LI))]>;
197 let Predicates = [PCRelativeMemops] in {
198 // BL8_NOTOC means that the caller does not use the TOC pointer and if
199 // it does use R2 then it is just a caller saved register. Therefore it is
200 // safe to emit only the bl and not the nop for this instruction. The
201 // linker will not try to restore R2 after the call.
202 def BL8_NOTOC_RM : IForm<18, 0, 1, (outs),
203 (ins calltarget:$LI),
204 "bl $LI", IIC_BrB, []>;
206 let Uses = [CTR8, RM] in {
207 let isPredicable = 1 in
208 def BCTRL8_RM : XLForm_2_ext<19, 528, 20, 0, 1, (outs), (ins),
209 "bctrl", IIC_BrB, [(PPCbctrl_rm)]>,
210 Requires<[In64BitMode]>;
214 let isCall = 1, PPC970_Unit = 7, isCodeGenOnly = 1,
215 Defs = [LR8, X2], Uses = [CTR8, RM], RST = 2 in {
216 def BCTRL8_LDinto_toc :
217 XLForm_2_ext_and_DSForm_1<19, 528, 20, 0, 1, 58, 0, (outs),
218 (ins (memrix $D, $RA):$src),
219 "bctrl\n\tld 2, $src", IIC_BrB,
220 [(PPCbctrl_load_toc iaddrX4:$src)]>,
221 Requires<[In64BitMode]>;
224 let isCall = 1, PPC970_Unit = 7, isCodeGenOnly = 1,
225 Defs = [LR8, X2, RM], Uses = [CTR8, RM], RST = 2 in {
226 def BCTRL8_LDinto_toc_RM :
227 XLForm_2_ext_and_DSForm_1<19, 528, 20, 0, 1, 58, 0, (outs),
228 (ins (memrix $D, $RA):$src),
229 "bctrl\n\tld 2, $src", IIC_BrB,
230 [(PPCbctrl_load_toc_rm iaddrX4:$src)]>,
231 Requires<[In64BitMode]>;
234 } // Interpretation64Bit
236 // FIXME: Duplicating this for the asm parser should be unnecessary, but the
237 // previous definition must be marked as CodeGen only to prevent decoding
239 let Interpretation64Bit = 1, isAsmParserOnly = 1, hasSideEffects = 0 in
240 let isCall = 1, PPC970_Unit = 7, Defs = [LR8], Uses = [RM] in
241 def BL8_TLS_ : IForm<18, 0, 1, (outs), (ins tlscall:$LI),
242 "bl $LI", IIC_BrB, []>;
245 def : Pat<(PPCcall (i64 tglobaladdr:$dst)),
246 (BL8 tglobaladdr:$dst)>;
247 def : Pat<(PPCcall_nop (i64 tglobaladdr:$dst)),
248 (BL8_NOP tglobaladdr:$dst)>;
250 def : Pat<(PPCcall (i64 texternalsym:$dst)),
251 (BL8 texternalsym:$dst)>;
252 def : Pat<(PPCcall_nop (i64 texternalsym:$dst)),
253 (BL8_NOP texternalsym:$dst)>;
255 def : Pat<(PPCcall_notoc (i64 tglobaladdr:$dst)),
256 (BL8_NOTOC tglobaladdr:$dst)>;
257 def : Pat<(PPCcall_notoc (i64 texternalsym:$dst)),
258 (BL8_NOTOC texternalsym:$dst)>;
260 def : Pat<(PPCcall_rm (i64 tglobaladdr:$dst)),
261 (BL8_RM tglobaladdr:$dst)>;
262 def : Pat<(PPCcall_nop_rm (i64 tglobaladdr:$dst)),
263 (BL8_NOP_RM tglobaladdr:$dst)>;
265 def : Pat<(PPCcall_rm (i64 texternalsym:$dst)),
266 (BL8_RM texternalsym:$dst)>;
267 def : Pat<(PPCcall_nop_rm (i64 texternalsym:$dst)),
268 (BL8_NOP_RM texternalsym:$dst)>;
270 def : Pat<(PPCcall_notoc_rm (i64 tglobaladdr:$dst)),
271 (BL8_NOTOC_RM tglobaladdr:$dst)>;
272 def : Pat<(PPCcall_notoc_rm (i64 texternalsym:$dst)),
273 (BL8_NOTOC_RM texternalsym:$dst)>;
276 def : Pat<(PPCcall (i64 mcsym:$dst)),
278 def : Pat<(PPCcall_nop (i64 mcsym:$dst)),
279 (BL8_NOP mcsym:$dst)>;
281 def : Pat<(PPCcall_rm (i64 mcsym:$dst)),
282 (BL8_RM mcsym:$dst)>;
283 def : Pat<(PPCcall_nop_rm (i64 mcsym:$dst)),
284 (BL8_NOP_RM mcsym:$dst)>;
287 // FIXME: some of these might be used with constant operands. This will result
288 // in constant materialization instructions that may be redundant. We currently
289 // clean this up in PPCMIPeephole with calls to
290 // PPCInstrInfo::convertToImmediateForm() but we should probably not emit them
291 // in the first place.
292 let Defs = [CR0] in {
293 def ATOMIC_LOAD_ADD_I64 : PPCCustomInserterPseudo<
294 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_ADD_I64",
295 [(set i64:$dst, (atomic_load_add_i64 ForceXForm:$ptr, i64:$incr))]>;
296 def ATOMIC_LOAD_SUB_I64 : PPCCustomInserterPseudo<
297 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_SUB_I64",
298 [(set i64:$dst, (atomic_load_sub_i64 ForceXForm:$ptr, i64:$incr))]>;
299 def ATOMIC_LOAD_OR_I64 : PPCCustomInserterPseudo<
300 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_OR_I64",
301 [(set i64:$dst, (atomic_load_or_i64 ForceXForm:$ptr, i64:$incr))]>;
302 def ATOMIC_LOAD_XOR_I64 : PPCCustomInserterPseudo<
303 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_XOR_I64",
304 [(set i64:$dst, (atomic_load_xor_i64 ForceXForm:$ptr, i64:$incr))]>;
305 def ATOMIC_LOAD_AND_I64 : PPCCustomInserterPseudo<
306 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_AND_i64",
307 [(set i64:$dst, (atomic_load_and_i64 ForceXForm:$ptr, i64:$incr))]>;
308 def ATOMIC_LOAD_NAND_I64 : PPCCustomInserterPseudo<
309 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_NAND_I64",
310 [(set i64:$dst, (atomic_load_nand_i64 ForceXForm:$ptr, i64:$incr))]>;
311 def ATOMIC_LOAD_MIN_I64 : PPCCustomInserterPseudo<
312 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_MIN_I64",
313 [(set i64:$dst, (atomic_load_min_i64 ForceXForm:$ptr, i64:$incr))]>;
314 def ATOMIC_LOAD_MAX_I64 : PPCCustomInserterPseudo<
315 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_MAX_I64",
316 [(set i64:$dst, (atomic_load_max_i64 ForceXForm:$ptr, i64:$incr))]>;
317 def ATOMIC_LOAD_UMIN_I64 : PPCCustomInserterPseudo<
318 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_UMIN_I64",
319 [(set i64:$dst, (atomic_load_umin_i64 ForceXForm:$ptr, i64:$incr))]>;
320 def ATOMIC_LOAD_UMAX_I64 : PPCCustomInserterPseudo<
321 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_UMAX_I64",
322 [(set i64:$dst, (atomic_load_umax_i64 ForceXForm:$ptr, i64:$incr))]>;
324 def ATOMIC_CMP_SWAP_I64 : PPCCustomInserterPseudo<
325 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$old, g8rc:$new), "#ATOMIC_CMP_SWAP_I64",
326 [(set i64:$dst, (atomic_cmp_swap_i64 ForceXForm:$ptr, i64:$old, i64:$new))]>;
328 def ATOMIC_SWAP_I64 : PPCCustomInserterPseudo<
329 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$new), "#ATOMIC_SWAP_I64",
330 [(set i64:$dst, (atomic_swap_i64 ForceXForm:$ptr, i64:$new))]>;
333 // Instructions to support atomic operations
334 let mayLoad = 1, hasSideEffects = 0 in {
335 def LDARX : XForm_1_memOp<31, 84, (outs g8rc:$RST), (ins (memrr $RA, $RB):$addr),
336 "ldarx $RST, $addr", IIC_LdStLDARX, []>;
337 // TODO: Add scheduling info.
338 let hasNoSchedulingInfo = 1 in
339 def LQARX : XForm_1_memOp<31, 276, (outs g8prc:$RST), (ins (memrr $RA, $RB):$addr),
340 "lqarx $RST, $addr", IIC_LdStLQARX, []>, isPPC64;
342 // Instruction to support lock versions of atomics
343 // (EH=1 - see Power ISA 2.07 Book II 4.4.2)
344 def LDARXL : XForm_1<31, 84, (outs g8rc:$RST), (ins (memrr $RA, $RB):$addr),
345 "ldarx $RST, $addr, 1", IIC_LdStLDARX, []>, isRecordForm;
346 // TODO: Add scheduling info.
347 let hasNoSchedulingInfo = 1 in
348 // FIXME: We have to seek a way to remove isRecordForm since
349 // LQARXL is not really altering CR0.
350 def LQARXL : XForm_1<31, 276, (outs g8prc:$RST), (ins (memrr $RA, $RB):$addr),
351 "lqarx $RST, $addr, 1", IIC_LdStLQARX, []>,
352 isPPC64, isRecordForm;
354 let hasExtraDefRegAllocReq = 1 in
355 def LDAT : X_RD5_RS5_IM5<31, 614, (outs g8rc:$RST), (ins g8rc:$RA, u5imm:$RB),
356 "ldat $RST, $RA, $RB", IIC_LdStLoad>, isPPC64,
357 Requires<[IsISA3_0]>;
360 let Defs = [CR0], mayStore = 1, mayLoad = 0, hasSideEffects = 0 in {
361 def STDCX : XForm_1_memOp<31, 214, (outs), (ins g8rc:$RST, (memrr $RA, $RB):$addr),
362 "stdcx. $RST, $addr", IIC_LdStSTDCX, []>, isRecordForm;
363 // TODO: Add scheduling info.
364 let hasNoSchedulingInfo = 1 in
365 def STQCX : XForm_1_memOp<31, 182, (outs), (ins g8prc:$RST, (memrr $RA, $RB):$addr),
366 "stqcx. $RST, $addr", IIC_LdStSTQCX, []>,
367 isPPC64, isRecordForm;
370 def SPLIT_QUADWORD : PPCCustomInserterPseudo<(outs g8rc:$lo, g8rc:$hi),
372 "#SPLIT_QUADWORD", []>;
373 class AtomicRMW128<string asmstr>
374 : PPCPostRAExpPseudo<(outs g8prc:$RTp, g8prc:$scratch),
375 (ins memrr:$ptr, g8rc:$incr_lo, g8rc:$incr_hi),
377 // We have to keep values in MI's uses during LL/SC looping as they are,
378 // so set both $RTp and $scratch earlyclobber.
379 let mayStore = 1, mayLoad = 1,
381 Constraints = "@earlyclobber $scratch,@earlyclobber $RTp" in {
382 // Atomic pseudo instructions expanded post-ra.
383 def ATOMIC_SWAP_I128 : AtomicRMW128<"#ATOMIC_SWAP_I128">;
384 def ATOMIC_LOAD_ADD_I128 : AtomicRMW128<"#ATOMIC_LOAD_ADD_I128">;
385 def ATOMIC_LOAD_SUB_I128 : AtomicRMW128<"#ATOMIC_LOAD_SUB_I128">;
386 def ATOMIC_LOAD_AND_I128 : AtomicRMW128<"#ATOMIC_LOAD_AND_I128">;
387 def ATOMIC_LOAD_XOR_I128 : AtomicRMW128<"#ATOMIC_LOAD_XOR_I128">;
388 def ATOMIC_LOAD_OR_I128 : AtomicRMW128<"#ATOMIC_LOAD_OR_I128">;
389 def ATOMIC_LOAD_NAND_I128 : AtomicRMW128<"#ATOMIC_LOAD_NAND_I128">;
391 def ATOMIC_CMP_SWAP_I128 : PPCPostRAExpPseudo<
392 (outs g8prc:$RTp, g8prc:$scratch),
393 (ins memrr:$ptr, g8rc:$cmp_lo, g8rc:$cmp_hi,
394 g8rc:$new_lo, g8rc:$new_hi),
395 "#ATOMIC_CMP_SWAP_I128", []>;
398 class PatAtomicRMWI128<SDPatternOperator OpNode, AtomicRMW128 Inst> :
399 Pat<(OpNode ForceXForm:$ptr,
402 (SPLIT_QUADWORD (Inst memrr:$ptr,
406 def : PatAtomicRMWI128<int_ppc_atomicrmw_add_i128, ATOMIC_LOAD_ADD_I128>;
407 def : PatAtomicRMWI128<int_ppc_atomicrmw_sub_i128, ATOMIC_LOAD_SUB_I128>;
408 def : PatAtomicRMWI128<int_ppc_atomicrmw_xor_i128, ATOMIC_LOAD_XOR_I128>;
409 def : PatAtomicRMWI128<int_ppc_atomicrmw_and_i128, ATOMIC_LOAD_AND_I128>;
410 def : PatAtomicRMWI128<int_ppc_atomicrmw_nand_i128, ATOMIC_LOAD_NAND_I128>;
411 def : PatAtomicRMWI128<int_ppc_atomicrmw_or_i128, ATOMIC_LOAD_OR_I128>;
412 def : PatAtomicRMWI128<int_ppc_atomicrmw_xchg_i128, ATOMIC_SWAP_I128>;
413 def : Pat<(int_ppc_cmpxchg_i128 ForceXForm:$ptr,
418 (SPLIT_QUADWORD (ATOMIC_CMP_SWAP_I128
425 let mayStore = 1, mayLoad = 0, hasSideEffects = 0 in
426 def STDAT : X_RD5_RS5_IM5<31, 742, (outs), (ins g8rc:$RST, g8rc:$RA, u5imm:$RB),
427 "stdat $RST, $RA, $RB", IIC_LdStStore>, isPPC64,
428 Requires<[IsISA3_0]>;
430 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
431 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
432 def TCRETURNdi8 :PPCEmitTimePseudo< (outs),
433 (ins calltarget:$dst, i32imm:$offset),
434 "#TC_RETURNd8 $dst $offset",
437 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
438 def TCRETURNai8 :PPCEmitTimePseudo<(outs), (ins abscalltarget:$func, i32imm:$offset),
439 "#TC_RETURNa8 $func $offset",
440 [(PPCtc_return (i64 imm:$func), imm:$offset)]>;
442 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
443 def TCRETURNri8 : PPCEmitTimePseudo<(outs), (ins CTRRC8:$dst, i32imm:$offset),
444 "#TC_RETURNr8 $dst $offset",
447 let hasSideEffects = 0 in {
448 let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, isBranch = 1,
449 isIndirectBranch = 1, isCall = 1, isReturn = 1, Uses = [CTR8, RM] in
450 def TAILBCTR8 : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
452 Requires<[In64BitMode]>;
454 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
455 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
456 def TAILB8 : IForm<18, 0, 0, (outs), (ins calltarget:$LI),
460 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
461 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
462 def TAILBA8 : IForm<18, 0, 0, (outs), (ins abscalltarget:$LI),
466 } // Interpretation64Bit
468 def : Pat<(PPCtc_return (i64 tglobaladdr:$dst), imm:$imm),
469 (TCRETURNdi8 tglobaladdr:$dst, imm:$imm)>;
471 def : Pat<(PPCtc_return (i64 texternalsym:$dst), imm:$imm),
472 (TCRETURNdi8 texternalsym:$dst, imm:$imm)>;
474 def : Pat<(PPCtc_return CTRRC8:$dst, imm:$imm),
475 (TCRETURNri8 CTRRC8:$dst, imm:$imm)>;
478 // 64-bit CR instructions
479 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
480 let hasSideEffects = 0 in {
481 // mtocrf's input needs to be prepared by shifting by an amount dependent
482 // on the cr register selected. Thus, post-ra anti-dep breaking must not
483 // later change that register assignment.
484 let hasExtraDefRegAllocReq = 1 in {
485 def MTOCRF8: XFXForm_5a<31, 144, (outs crbitm:$FXM), (ins g8rc:$RST),
486 "mtocrf $FXM, $RST", IIC_BrMCRX>,
487 PPC970_DGroup_First, PPC970_Unit_CRU;
489 // Similarly to mtocrf, the mask for mtcrf must be prepared in a way that
490 // is dependent on the cr fields being set.
491 def MTCRF8 : XFXForm_5<31, 144, (outs), (ins i32imm:$FXM, g8rc:$RST),
492 "mtcrf $FXM, $RST", IIC_BrMCRX>,
493 PPC970_MicroCode, PPC970_Unit_CRU;
494 } // hasExtraDefRegAllocReq = 1
496 // mfocrf's input needs to be prepared by shifting by an amount dependent
497 // on the cr register selected. Thus, post-ra anti-dep breaking must not
498 // later change that register assignment.
499 let hasExtraSrcRegAllocReq = 1 in {
500 def MFOCRF8: XFXForm_5a<31, 19, (outs g8rc:$RST), (ins crbitm:$FXM),
501 "mfocrf $RST, $FXM", IIC_SprMFCRF>,
502 PPC970_DGroup_First, PPC970_Unit_CRU;
504 // Similarly to mfocrf, the mask for mfcrf must be prepared in a way that
505 // is dependent on the cr fields being copied.
506 def MFCR8 : XFXForm_3<31, 19, (outs g8rc:$RT), (ins),
507 "mfcr $RT", IIC_SprMFCR>,
508 PPC970_MicroCode, PPC970_Unit_CRU;
509 } // hasExtraSrcRegAllocReq = 1
510 } // hasSideEffects = 0
512 // While longjmp is a control-flow barrier (fallthrough isn't allowed), setjmp
514 let hasSideEffects = 1 in {
516 def EH_SjLj_SetJmp64 : PPCCustomInserterPseudo<(outs gprc:$dst), (ins memr:$buf),
518 [(set i32:$dst, (PPCeh_sjlj_setjmp addr:$buf))]>,
519 Requires<[In64BitMode]>;
522 let hasSideEffects = 1, isBarrier = 1 in {
523 let isTerminator = 1 in
524 def EH_SjLj_LongJmp64 : PPCCustomInserterPseudo<(outs), (ins memr:$buf),
525 "#EH_SJLJ_LONGJMP64",
526 [(PPCeh_sjlj_longjmp addr:$buf)]>,
527 Requires<[In64BitMode]>;
530 def MFSPR8 : XFXForm_1<31, 339, (outs g8rc:$RST), (ins i32imm:$SPR),
531 "mfspr $RST, $SPR", IIC_SprMFSPR>;
532 def MTSPR8 : XFXForm_1<31, 467, (outs), (ins i32imm:$SPR, g8rc:$RST),
533 "mtspr $SPR, $RST", IIC_SprMTSPR>;
536 //===----------------------------------------------------------------------===//
537 // 64-bit SPR manipulation instrs.
539 let Uses = [CTR8] in {
540 def MFCTR8 : XFXForm_1_ext<31, 339, 9, (outs g8rc:$RST), (ins),
541 "mfctr $RST", IIC_SprMFSPR>,
542 PPC970_DGroup_First, PPC970_Unit_FXU;
544 let Pattern = [(PPCmtctr i64:$RST)], Defs = [CTR8] in {
545 def MTCTR8 : XFXForm_1_ext<31, 467, 9, (outs), (ins g8rc:$RST),
546 "mtctr $RST", IIC_SprMTSPR>,
547 PPC970_DGroup_First, PPC970_Unit_FXU;
549 // MTCTR[8|]loop must be inside a loop-preheader, duplicating
550 // the loop-preheader block will break this assumption.
551 let hasSideEffects = 1, isNotDuplicable = 1, Defs = [CTR8] in {
552 let Pattern = [(int_set_loop_iterations i64:$RST)] in
553 def MTCTR8loop : XFXForm_1_ext<31, 467, 9, (outs), (ins g8rc:$RST),
554 "mtctr $RST", IIC_SprMTSPR>,
555 PPC970_DGroup_First, PPC970_Unit_FXU;
558 let hasSideEffects = 1, hasNoSchedulingInfo = 1, isNotDuplicable = 1, Uses = [CTR8], Defs = [CTR8] in
559 def DecreaseCTR8loop : PPCEmitTimePseudo<(outs crbitrc:$rT), (ins i64imm:$stride),
560 "#DecreaseCTR8loop", [(set i1:$rT, (int_loop_decrement (i64 imm:$stride)))]>;
562 let Pattern = [(set i64:$RST, readcyclecounter)] in
563 def MFTB8 : XFXForm_1_ext<31, 339, 268, (outs g8rc:$RST), (ins),
564 "mfspr $RST, 268", IIC_SprMFTB>,
565 PPC970_DGroup_First, PPC970_Unit_FXU;
566 // Note that encoding mftb using mfspr is now the preferred form,
567 // and has been since at least ISA v2.03. The mftb instruction has
568 // now been phased out. Using mfspr, however, is known not to work on
571 let Defs = [X1], Uses = [X1] in
572 def DYNALLOC8 : PPCEmitTimePseudo<(outs g8rc:$result), (ins g8rc:$negsize, memri:$fpsi),"#DYNALLOC8",
574 (PPCdynalloc i64:$negsize, iaddr:$fpsi))]>;
575 def DYNAREAOFFSET8 : PPCEmitTimePseudo<(outs i64imm:$result), (ins memri:$fpsi), "#DYNAREAOFFSET8",
576 [(set i64:$result, (PPCdynareaoffset iaddr:$fpsi))]>;
577 // Probed alloca to support stack clash protection.
578 let Defs = [X1], Uses = [X1], hasNoSchedulingInfo = 1 in {
579 def PROBED_ALLOCA_64 : PPCCustomInserterPseudo<(outs g8rc:$result),
580 (ins g8rc:$negsize, memri:$fpsi), "#PROBED_ALLOCA_64",
582 (PPCprobedalloca i64:$negsize, iaddr:$fpsi))]>;
583 def PREPARE_PROBED_ALLOCA_64 : PPCEmitTimePseudo<(outs
584 g8rc:$fp, g8rc:$actual_negsize),
585 (ins g8rc:$negsize, memri:$fpsi), "#PREPARE_PROBED_ALLOCA_64", []>;
586 def PREPARE_PROBED_ALLOCA_NEGSIZE_SAME_REG_64 : PPCEmitTimePseudo<(outs
587 g8rc:$fp, g8rc:$actual_negsize),
588 (ins g8rc:$negsize, memri:$fpsi),
589 "#PREPARE_PROBED_ALLOCA_NEGSIZE_SAME_REG_64", []>,
590 RegConstraint<"$actual_negsize = $negsize">;
591 def PROBED_STACKALLOC_64 : PPCEmitTimePseudo<(outs g8rc:$scratch, g8rc:$temp),
592 (ins i64imm:$stacksize),
593 "#PROBED_STACKALLOC_64", []>;
596 let hasSideEffects = 0 in {
597 let Defs = [LR8] in {
598 def MTLR8 : XFXForm_1_ext<31, 467, 8, (outs), (ins g8rc:$RST),
599 "mtlr $RST", IIC_SprMTSPR>,
600 PPC970_DGroup_First, PPC970_Unit_FXU;
602 let Uses = [LR8] in {
603 def MFLR8 : XFXForm_1_ext<31, 339, 8, (outs g8rc:$RST), (ins),
604 "mflr $RST", IIC_SprMFSPR>,
605 PPC970_DGroup_First, PPC970_Unit_FXU;
607 } // Interpretation64Bit
610 //===----------------------------------------------------------------------===//
611 // Fixed point instructions.
614 let PPC970_Unit = 1 in { // FXU Operations.
615 let Interpretation64Bit = 1 in {
616 let hasSideEffects = 0 in {
617 let isCodeGenOnly = 1 in {
619 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in {
620 def LI8 : DForm_2_r0<14, (outs g8rc:$RST), (ins s16imm64:$D),
621 "li $RST, $D", IIC_IntSimple,
622 [(set i64:$RST, imm64SExt16:$D)]>, SExt32To64;
623 def LIS8 : DForm_2_r0<15, (outs g8rc:$RST), (ins s17imm64:$D),
624 "lis $RST, $D", IIC_IntSimple,
625 [(set i64:$RST, imm16ShiftedSExt:$D)]>, SExt32To64;
629 let isCommutable = 1 in {
630 defm NAND8: XForm_6r<31, 476, (outs g8rc:$RA), (ins g8rc:$RST, g8rc:$RB),
631 "nand", "$RA, $RST, $RB", IIC_IntSimple,
632 [(set i64:$RA, (not (and i64:$RST, i64:$RB)))]>;
633 defm AND8 : XForm_6r<31, 28, (outs g8rc:$RA), (ins g8rc:$RST, g8rc:$RB),
634 "and", "$RA, $RST, $RB", IIC_IntSimple,
635 [(set i64:$RA, (and i64:$RST, i64:$RB))]>;
637 defm ANDC8: XForm_6r<31, 60, (outs g8rc:$RA), (ins g8rc:$RST, g8rc:$RB),
638 "andc", "$RA, $RST, $RB", IIC_IntSimple,
639 [(set i64:$RA, (and i64:$RST, (not i64:$RB)))]>;
640 let isCommutable = 1 in {
641 defm OR8 : XForm_6r<31, 444, (outs g8rc:$RA), (ins g8rc:$RST, g8rc:$RB),
642 "or", "$RA, $RST, $RB", IIC_IntSimple,
643 [(set i64:$RA, (or i64:$RST, i64:$RB))]>;
644 defm NOR8 : XForm_6r<31, 124, (outs g8rc:$RA), (ins g8rc:$RST, g8rc:$RB),
645 "nor", "$RA, $RST, $RB", IIC_IntSimple,
646 [(set i64:$RA, (not (or i64:$RST, i64:$RB)))]>;
648 defm ORC8 : XForm_6r<31, 412, (outs g8rc:$RA), (ins g8rc:$RST, g8rc:$RB),
649 "orc", "$RA, $RST, $RB", IIC_IntSimple,
650 [(set i64:$RA, (or i64:$RST, (not i64:$RB)))]>;
651 let isCommutable = 1 in {
652 defm EQV8 : XForm_6r<31, 284, (outs g8rc:$RA), (ins g8rc:$RST, g8rc:$RB),
653 "eqv", "$RA, $RST, $RB", IIC_IntSimple,
654 [(set i64:$RA, (not (xor i64:$RST, i64:$RB)))]>;
655 defm XOR8 : XForm_6r<31, 316, (outs g8rc:$RA), (ins g8rc:$RST, g8rc:$RB),
656 "xor", "$RA, $RST, $RB", IIC_IntSimple,
657 [(set i64:$RA, (xor i64:$RST, i64:$RB))]>;
658 } // let isCommutable = 1
660 // Logical ops with immediate.
661 let Defs = [CR0] in {
662 def ANDI8_rec : DForm_4<28, (outs g8rc:$RA), (ins g8rc:$RST, u16imm64:$D),
663 "andi. $RA, $RST, $D", IIC_IntGeneral,
664 [(set i64:$RA, (and i64:$RST, immZExt16:$D))]>,
665 isRecordForm, SExt32To64, ZExt32To64;
666 def ANDIS8_rec : DForm_4<29, (outs g8rc:$RA), (ins g8rc:$RST, u16imm64:$D),
667 "andis. $RA, $RST, $D", IIC_IntGeneral,
668 [(set i64:$RA, (and i64:$RST, imm16ShiftedZExt:$D))]>,
669 isRecordForm, ZExt32To64;
671 def ORI8 : DForm_4<24, (outs g8rc:$RA), (ins g8rc:$RST, u16imm64:$D),
672 "ori $RA, $RST, $D", IIC_IntSimple,
673 [(set i64:$RA, (or i64:$RST, immZExt16:$D))]>;
674 def ORIS8 : DForm_4<25, (outs g8rc:$RA), (ins g8rc:$RST, u16imm64:$D),
675 "oris $RA, $RST, $D", IIC_IntSimple,
676 [(set i64:$RA, (or i64:$RST, imm16ShiftedZExt:$D))]>;
677 def XORI8 : DForm_4<26, (outs g8rc:$RA), (ins g8rc:$RST, u16imm64:$D),
678 "xori $RA, $RST, $D", IIC_IntSimple,
679 [(set i64:$RA, (xor i64:$RST, immZExt16:$D))]>;
680 def XORIS8 : DForm_4<27, (outs g8rc:$RA), (ins g8rc:$RST, u16imm64:$D),
681 "xoris $RA, $RST, $D", IIC_IntSimple,
682 [(set i64:$RA, (xor i64:$RST, imm16ShiftedZExt:$D))]>;
684 let isCommutable = 1 in
685 defm ADD8 : XOForm_1rx<31, 266, (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB),
686 "add", "$RT, $RA, $RB", IIC_IntSimple,
687 [(set i64:$RT, (add i64:$RA, i64:$RB))]>;
688 // ADD8 has a special form: reg = ADD8(reg, sym@tls) for use by the
689 // initial-exec thread-local storage model. We need to forbid r0 here -
690 // while it works for add just fine, the linker can relax this to local-exec
691 // addi, which won't work for r0.
692 def ADD8TLS : XOForm_1<31, 266, 0, (outs g8rc:$RT), (ins g8rc_nox0:$RA, tlsreg:$RB),
693 "add $RT, $RA, $RB", IIC_IntSimple,
694 [(set i64:$RT, (add i64:$RA, tglobaltlsaddr:$RB))]>;
696 def LBZXTLS : XForm_1<31, 87, (outs g8rc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
697 "lbzx $RST, $RA, $RB", IIC_LdStLoad, []>;
698 def LHZXTLS : XForm_1<31, 279, (outs g8rc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
699 "lhzx $RST, $RA, $RB", IIC_LdStLoad, []>;
700 def LHAXTLS : XForm_1<31, 343, (outs g8rc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
701 "lhax $RST, $RA, $RB", IIC_LdStLoad, []>;
702 def LWZXTLS : XForm_1<31, 23, (outs g8rc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
703 "lwzx $RST, $RA, $RB", IIC_LdStLoad, []>;
704 def LWAXTLS : XForm_1<31, 341, (outs g8rc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
705 "lwax $RST, $RA, $RB", IIC_LdStLoad, []>;
706 def LDXTLS : XForm_1<31, 21, (outs g8rc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
707 "ldx $RST, $RA, $RB", IIC_LdStLD, []>, isPPC64;
708 def LBZXTLS_32 : XForm_1<31, 87, (outs gprc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
709 "lbzx $RST, $RA, $RB", IIC_LdStLoad, []>;
710 def LHZXTLS_32 : XForm_1<31, 279, (outs gprc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
711 "lhzx $RST, $RA, $RB", IIC_LdStLoad, []>;
712 def LHAXTLS_32 : XForm_1<31, 343, (outs gprc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
713 "lhax $RST, $RA, $RB", IIC_LdStLoad, []>;
714 def LWZXTLS_32 : XForm_1<31, 23, (outs gprc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
715 "lwzx $RST, $RA, $RB", IIC_LdStLoad, []>;
716 def LWAXTLS_32 : XForm_1<31, 341, (outs gprc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
717 "lwax $RST, $RA, $RB", IIC_LdStLoad, []>;
720 let mayLoad = 1, Predicates = [HasFPU] in {
721 def LFSXTLS : XForm_25<31, 535, (outs f4rc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
722 "lfsx $RST, $RA, $RB", IIC_LdStLFD, []>;
723 def LFDXTLS : XForm_25<31, 599, (outs f8rc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
724 "lfdx $RST, $RA, $RB", IIC_LdStLFD, []>;
727 let mayStore = 1 in {
728 def STBXTLS : XForm_8<31, 215, (outs), (ins g8rc:$RST, ptr_rc_nor0:$RA, tlsreg:$RB),
729 "stbx $RST, $RA, $RB", IIC_LdStStore, []>,
730 PPC970_DGroup_Cracked;
731 def STHXTLS : XForm_8<31, 407, (outs), (ins g8rc:$RST, ptr_rc_nor0:$RA, tlsreg:$RB),
732 "sthx $RST, $RA, $RB", IIC_LdStStore, []>,
733 PPC970_DGroup_Cracked;
734 def STWXTLS : XForm_8<31, 151, (outs), (ins g8rc:$RST, ptr_rc_nor0:$RA, tlsreg:$RB),
735 "stwx $RST, $RA, $RB", IIC_LdStStore, []>,
736 PPC970_DGroup_Cracked;
737 def STDXTLS : XForm_8<31, 149, (outs), (ins g8rc:$RST, ptr_rc_nor0:$RA, tlsreg:$RB),
738 "stdx $RST, $RA, $RB", IIC_LdStSTD, []>, isPPC64,
739 PPC970_DGroup_Cracked;
740 def STBXTLS_32 : XForm_8<31, 215, (outs), (ins gprc:$RST, ptr_rc_nor0:$RA, tlsreg:$RB),
741 "stbx $RST, $RA, $RB", IIC_LdStStore, []>,
742 PPC970_DGroup_Cracked;
743 def STHXTLS_32 : XForm_8<31, 407, (outs), (ins gprc:$RST, ptr_rc_nor0:$RA, tlsreg:$RB),
744 "sthx $RST, $RA, $RB", IIC_LdStStore, []>,
745 PPC970_DGroup_Cracked;
746 def STWXTLS_32 : XForm_8<31, 151, (outs), (ins gprc:$RST, ptr_rc_nor0:$RA, tlsreg:$RB),
747 "stwx $RST, $RA, $RB", IIC_LdStStore, []>,
748 PPC970_DGroup_Cracked;
751 let mayStore = 1, Predicates = [HasFPU] in {
752 def STFSXTLS : XForm_8<31, 663, (outs), (ins f4rc:$RST, ptr_rc_nor0:$RA, tlsreg:$RB),
753 "stfsx $RST, $RA, $RB", IIC_LdStSTFD, []>,
754 PPC970_DGroup_Cracked;
755 def STFDXTLS : XForm_8<31, 727, (outs), (ins f8rc:$RST, ptr_rc_nor0:$RA, tlsreg:$RB),
756 "stfdx $RST, $RA, $RB", IIC_LdStSTFD, []>,
757 PPC970_DGroup_Cracked;
760 let isCommutable = 1 in
761 defm ADDC8 : XOForm_1rc<31, 10, 0, (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB),
762 "addc", "$RT, $RA, $RB", IIC_IntGeneral,
763 [(set i64:$RT, (addc i64:$RA, i64:$RB))]>,
764 PPC970_DGroup_Cracked;
766 let Defs = [CARRY] in
767 def ADDIC8 : DForm_2<12, (outs g8rc:$RST), (ins g8rc:$RA, s16imm64:$D),
768 "addic $RST, $RA, $D", IIC_IntGeneral,
769 [(set i64:$RST, (addc i64:$RA, imm64SExt16:$D))]>;
770 def ADDI8 : DForm_2<14, (outs g8rc:$RST), (ins g8rc_nox0:$RA, s16imm64:$D),
771 "addi $RST, $RA, $D", IIC_IntSimple,
772 [(set i64:$RST, (add i64:$RA, imm64SExt16:$D))]>;
773 def ADDIS8 : DForm_2<15, (outs g8rc:$RST), (ins g8rc_nox0:$RA, s17imm64:$D),
774 "addis $RST, $RA, $D", IIC_IntSimple,
775 [(set i64:$RST, (add i64:$RA, imm16ShiftedSExt:$D))]>;
777 def LA8 : DForm_2<14, (outs g8rc:$RST), (ins g8rc_nox0:$RA, s16imm64:$D),
778 "la $RST, $D($RA)", IIC_IntGeneral,
779 [(set i64:$RST, (add i64:$RA,
780 (PPClo tglobaladdr:$D, 0)))]>;
782 let Defs = [CARRY] in {
783 def SUBFIC8: DForm_2< 8, (outs g8rc:$RST), (ins g8rc:$RA, s16imm64:$D),
784 "subfic $RST, $RA, $D", IIC_IntGeneral,
785 [(set i64:$RST, (subc imm64SExt16:$D, i64:$RA))]>;
787 defm SUBFC8 : XOForm_1rc<31, 8, 0, (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB),
788 "subfc", "$RT, $RA, $RB", IIC_IntGeneral,
789 [(set i64:$RT, (subc i64:$RB, i64:$RA))]>,
790 PPC970_DGroup_Cracked;
791 defm SUBF8 : XOForm_1rx<31, 40, (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB),
792 "subf", "$RT, $RA, $RB", IIC_IntGeneral,
793 [(set i64:$RT, (sub i64:$RB, i64:$RA))]>;
794 defm NEG8 : XOForm_3r<31, 104, 0, (outs g8rc:$RT), (ins g8rc:$RA),
795 "neg", "$RT, $RA", IIC_IntSimple,
796 [(set i64:$RT, (ineg i64:$RA))]>;
797 let Uses = [CARRY] in {
798 let isCommutable = 1 in
799 defm ADDE8 : XOForm_1rc<31, 138, 0, (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB),
800 "adde", "$RT, $RA, $RB", IIC_IntGeneral,
801 [(set i64:$RT, (adde i64:$RA, i64:$RB))]>;
802 defm ADDME8 : XOForm_3rc<31, 234, 0, (outs g8rc:$RT), (ins g8rc:$RA),
803 "addme", "$RT, $RA", IIC_IntGeneral,
804 [(set i64:$RT, (adde i64:$RA, -1))]>;
805 defm ADDZE8 : XOForm_3rc<31, 202, 0, (outs g8rc:$RT), (ins g8rc:$RA),
806 "addze", "$RT, $RA", IIC_IntGeneral,
807 [(set i64:$RT, (adde i64:$RA, 0))]>;
808 defm SUBFE8 : XOForm_1rc<31, 136, 0, (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB),
809 "subfe", "$RT, $RA, $RB", IIC_IntGeneral,
810 [(set i64:$RT, (sube i64:$RB, i64:$RA))]>;
811 defm SUBFME8 : XOForm_3rc<31, 232, 0, (outs g8rc:$RT), (ins g8rc:$RA),
812 "subfme", "$RT, $RA", IIC_IntGeneral,
813 [(set i64:$RT, (sube -1, i64:$RA))]>;
814 defm SUBFZE8 : XOForm_3rc<31, 200, 0, (outs g8rc:$RT), (ins g8rc:$RA),
815 "subfze", "$RT, $RA", IIC_IntGeneral,
816 [(set i64:$RT, (sube 0, i64:$RA))]>;
820 // FIXME: Duplicating this for the asm parser should be unnecessary, but the
821 // previous definition must be marked as CodeGen only to prevent decoding
823 let isAsmParserOnly = 1 in {
824 def ADD8TLS_ : XOForm_1<31, 266, 0, (outs g8rc:$RT), (ins g8rc:$RA, tlsreg:$RB),
825 "add $RT, $RA, $RB", IIC_IntSimple, []>;
828 def LBZXTLS_ : XForm_1<31, 87, (outs g8rc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
829 "lbzx $RST, $RA, $RB", IIC_LdStLoad, []>;
830 def LHZXTLS_ : XForm_1<31, 279, (outs g8rc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
831 "lhzx $RST, $RA, $RB", IIC_LdStLoad, []>;
832 def LHAXTLS_ : XForm_1<31, 343, (outs g8rc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
833 "lhax $RST, $RA, $RB", IIC_LdStLoad, []>;
834 def LWZXTLS_ : XForm_1<31, 23, (outs g8rc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
835 "lwzx $RST, $RA, $RB", IIC_LdStLoad, []>;
836 def LWAXTLS_ : XForm_1<31, 341, (outs g8rc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
837 "lwax $RST, $RA, $RB", IIC_LdStLoad, []>;
838 def LDXTLS_ : XForm_1<31, 21, (outs g8rc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
839 "ldx $RST, $RA, $RB", IIC_LdStLD, []>, isPPC64;
842 let mayLoad = 1, Predicates = [HasFPU] in {
843 def LFSXTLS_ : XForm_25<31, 535, (outs f4rc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
844 "lfsx $RST, $RA, $RB", IIC_LdStLFD, []>;
845 def LFDXTLS_ : XForm_25<31, 599, (outs f8rc:$RST), (ins ptr_rc_nor0:$RA, tlsreg:$RB),
846 "lfdx $RST, $RA, $RB", IIC_LdStLFD, []>;
849 let mayStore = 1 in {
850 def STBXTLS_ : XForm_8<31, 215, (outs), (ins g8rc:$RST, ptr_rc_nor0:$RA, tlsreg:$RB),
851 "stbx $RST, $RA, $RB", IIC_LdStStore, []>,
852 PPC970_DGroup_Cracked;
853 def STHXTLS_ : XForm_8<31, 407, (outs), (ins g8rc:$RST, ptr_rc_nor0:$RA, tlsreg:$RB),
854 "sthx $RST, $RA, $RB", IIC_LdStStore, []>,
855 PPC970_DGroup_Cracked;
856 def STWXTLS_ : XForm_8<31, 151, (outs), (ins g8rc:$RST, ptr_rc_nor0:$RA, tlsreg:$RB),
857 "stwx $RST, $RA, $RB", IIC_LdStStore, []>,
858 PPC970_DGroup_Cracked;
859 def STDXTLS_ : XForm_8<31, 149, (outs), (ins g8rc:$RST, ptr_rc_nor0:$RA, tlsreg:$RB),
860 "stdx $RST, $RA, $RB", IIC_LdStSTD, []>, isPPC64,
861 PPC970_DGroup_Cracked;
864 let mayStore = 1, Predicates = [HasFPU] in {
865 def STFSXTLS_ : XForm_8<31, 663, (outs), (ins f4rc:$RST, ptr_rc_nor0:$RA, tlsreg:$RB),
866 "stfsx $RST, $RA, $RB", IIC_LdStSTFD, []>,
867 PPC970_DGroup_Cracked;
868 def STFDXTLS_ : XForm_8<31, 727, (outs), (ins f8rc:$RST, ptr_rc_nor0:$RA, tlsreg:$RB),
869 "stfdx $RST, $RA, $RB", IIC_LdStSTFD, []>,
870 PPC970_DGroup_Cracked;
874 let isCommutable = 1 in {
875 defm MULHD : XOForm_1r<31, 73, 0, (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB),
876 "mulhd", "$RT, $RA, $RB", IIC_IntMulHW,
877 [(set i64:$RT, (mulhs i64:$RA, i64:$RB))]>;
878 defm MULHDU : XOForm_1r<31, 9, 0, (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB),
879 "mulhdu", "$RT, $RA, $RB", IIC_IntMulHWU,
880 [(set i64:$RT, (mulhu i64:$RA, i64:$RB))]>;
883 } // Interpretation64Bit
885 let isCompare = 1, hasSideEffects = 0 in {
886 def CMPD : XForm_16_ext<31, 0, (outs crrc:$BF), (ins g8rc:$RA, g8rc:$RB),
887 "cmpd $BF, $RA, $RB", IIC_IntCompare>, isPPC64;
888 def CMPLD : XForm_16_ext<31, 32, (outs crrc:$BF), (ins g8rc:$RA, g8rc:$RB),
889 "cmpld $BF, $RA, $RB", IIC_IntCompare>, isPPC64;
890 def CMPDI : DForm_5_ext<11, (outs crrc:$BF), (ins g8rc:$RA, s16imm64:$D),
891 "cmpdi $BF, $RA, $D", IIC_IntCompare>, isPPC64;
892 def CMPLDI : DForm_6_ext<10, (outs crrc:$BF), (ins g8rc:$RA, u16imm64:$D),
893 "cmpldi $BF, $RA, $D",
894 IIC_IntCompare>, isPPC64;
895 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
896 def CMPRB8 : X_BF3_L1_RS5_RS5<31, 192, (outs crrc:$BF),
897 (ins u1imm:$L, g8rc:$RA, g8rc:$RB),
898 "cmprb $BF, $L, $RA, $RB", IIC_IntCompare, []>,
899 Requires<[IsISA3_0]>;
900 def CMPEQB : X_BF3_RS5_RS5<31, 224, (outs crrc:$BF),
901 (ins g8rc:$RA, g8rc:$RB), "cmpeqb $BF, $RA, $RB",
902 IIC_IntCompare, []>, Requires<[IsISA3_0]>;
905 let hasSideEffects = 0 in {
906 defm SLD : XForm_6r<31, 27, (outs g8rc:$RA), (ins g8rc:$RST, gprc:$RB),
907 "sld", "$RA, $RST, $RB", IIC_IntRotateD,
908 [(set i64:$RA, (PPCshl i64:$RST, i32:$RB))]>, isPPC64;
909 defm SRD : XForm_6r<31, 539, (outs g8rc:$RA), (ins g8rc:$RST, gprc:$RB),
910 "srd", "$RA, $RST, $RB", IIC_IntRotateD,
911 [(set i64:$RA, (PPCsrl i64:$RST, i32:$RB))]>, isPPC64;
912 defm SRAD : XForm_6rc<31, 794, (outs g8rc:$RA), (ins g8rc:$RST, gprc:$RB),
913 "srad", "$RA, $RST, $RB", IIC_IntRotateD,
914 [(set i64:$RA, (PPCsra i64:$RST, i32:$RB))]>, isPPC64;
916 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
917 defm CNTLZW8 : XForm_11r<31, 26, (outs g8rc:$RA), (ins g8rc:$RST),
918 "cntlzw", "$RA, $RST", IIC_IntGeneral, []>,
919 ZExt32To64, SExt32To64;
920 defm CNTTZW8 : XForm_11r<31, 538, (outs g8rc:$RA), (ins g8rc:$RST),
921 "cnttzw", "$RA, $RST", IIC_IntGeneral, []>,
922 Requires<[IsISA3_0]>, ZExt32To64, SExt32To64;
924 defm EXTSB8 : XForm_11r<31, 954, (outs g8rc:$RA), (ins g8rc:$RST),
925 "extsb", "$RA, $RST", IIC_IntSimple,
926 [(set i64:$RA, (sext_inreg i64:$RST, i8))]>, SExt32To64;
927 defm EXTSH8 : XForm_11r<31, 922, (outs g8rc:$RA), (ins g8rc:$RST),
928 "extsh", "$RA, $RST", IIC_IntSimple,
929 [(set i64:$RA, (sext_inreg i64:$RST, i16))]>, SExt32To64;
931 defm SLW8 : XForm_6r<31, 24, (outs g8rc:$RA), (ins g8rc:$RST, g8rc:$RB),
932 "slw", "$RA, $RST, $RB", IIC_IntGeneral, []>, ZExt32To64;
933 defm SRW8 : XForm_6r<31, 536, (outs g8rc:$RA), (ins g8rc:$RST, g8rc:$RB),
934 "srw", "$RA, $RST, $RB", IIC_IntGeneral, []>, ZExt32To64;
935 } // Interpretation64Bit
938 let isCodeGenOnly = 1 in {
939 def EXTSB8_32_64 : XForm_11<31, 954, (outs g8rc:$RA), (ins gprc:$RST),
940 "extsb $RA, $RST", IIC_IntSimple, []>, isPPC64,
942 def EXTSH8_32_64 : XForm_11<31, 922, (outs g8rc:$RA), (ins gprc:$RST),
943 "extsh $RA, $RST", IIC_IntSimple, []>, isPPC64,
945 } // isCodeGenOnly for fast-isel
947 defm EXTSW : XForm_11r<31, 986, (outs g8rc:$RA), (ins g8rc:$RST),
948 "extsw", "$RA, $RST", IIC_IntSimple,
949 [(set i64:$RA, (sext_inreg i64:$RST, i32))]>, isPPC64,
951 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
952 defm EXTSW_32_64 : XForm_11r<31, 986, (outs g8rc:$RA), (ins gprc:$RST),
953 "extsw", "$RA, $RST", IIC_IntSimple,
954 [(set i64:$RA, (sext i32:$RST))]>, isPPC64,
956 let isCodeGenOnly = 1 in
957 def EXTSW_32 : XForm_11<31, 986, (outs gprc:$RA), (ins gprc:$RST),
958 "extsw $RA, $RST", IIC_IntSimple,
961 defm SRADI : XSForm_1rc<31, 413, (outs g8rc:$RA), (ins g8rc:$RS, u6imm:$SH),
962 "sradi", "$RA, $RS, $SH", IIC_IntRotateDI,
963 [(set i64:$RA, (sra i64:$RS, (i32 imm:$SH)))]>, isPPC64;
965 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
966 defm EXTSWSLI_32_64 : XSForm_1r<31, 445, (outs g8rc:$RA),
967 (ins gprc:$RS, u6imm:$SH),
968 "extswsli", "$RA, $RS, $SH", IIC_IntRotateDI,
970 (PPCextswsli i32:$RS, (i32 imm:$SH)))]>,
971 isPPC64, Requires<[IsISA3_0]>;
973 defm EXTSWSLI : XSForm_1rc<31, 445, (outs g8rc:$RA), (ins g8rc:$RS, u6imm:$SH),
974 "extswsli", "$RA, $RS, $SH", IIC_IntRotateDI,
975 []>, isPPC64, Requires<[IsISA3_0]>;
978 let isCodeGenOnly = 1, Defs = [CARRY] in
979 def SRADI_32 : XSForm_1<31, 413, (outs gprc:$RA), (ins gprc:$RS, u6imm:$SH),
980 "sradi $RA, $RS, $SH", IIC_IntRotateDI, []>, isPPC64;
982 defm CNTLZD : XForm_11r<31, 58, (outs g8rc:$RA), (ins g8rc:$RST),
983 "cntlzd", "$RA, $RST", IIC_IntGeneral,
984 [(set i64:$RA, (ctlz i64:$RST))]>,
985 ZExt32To64, SExt32To64;
986 defm CNTTZD : XForm_11r<31, 570, (outs g8rc:$RA), (ins g8rc:$RST),
987 "cnttzd", "$RA, $RST", IIC_IntGeneral,
988 [(set i64:$RA, (cttz i64:$RST))]>, Requires<[IsISA3_0]>,
989 ZExt32To64, SExt32To64;
990 def POPCNTD : XForm_11<31, 506, (outs g8rc:$RA), (ins g8rc:$RST),
991 "popcntd $RA, $RST", IIC_IntGeneral,
992 [(set i64:$RA, (ctpop i64:$RST))]>,
993 ZExt32To64, SExt32To64;
994 def BPERMD : XForm_6<31, 252, (outs g8rc:$RA), (ins g8rc:$RST, g8rc:$RB),
995 "bpermd $RA, $RST, $RB", IIC_IntGeneral,
996 [(set i64:$RA, (int_ppc_bpermd g8rc:$RST, g8rc:$RB))]>,
997 isPPC64, Requires<[HasBPERMD]>;
999 let isCodeGenOnly = 1, isCommutable = 1 in
1000 def CMPB8 : XForm_6<31, 508, (outs g8rc:$RA), (ins g8rc:$RST, g8rc:$RB),
1001 "cmpb $RA, $RST, $RB", IIC_IntGeneral,
1002 [(set i64:$RA, (PPCcmpb i64:$RST, i64:$RB))]>;
1004 // popcntw also does a population count on the high 32 bits (storing the
1005 // results in the high 32-bits of the output). We'll ignore that here (which is
1006 // safe because we never separately use the high part of the 64-bit registers).
1007 def POPCNTW : XForm_11<31, 378, (outs gprc:$RA), (ins gprc:$RST),
1008 "popcntw $RA, $RST", IIC_IntGeneral,
1009 [(set i32:$RA, (ctpop i32:$RST))]>;
1011 let isCodeGenOnly = 1 in {
1012 def POPCNTB8 : XForm_11<31, 122, (outs g8rc:$RA), (ins g8rc:$RST),
1013 "popcntb $RA, $RST", IIC_IntGeneral,
1014 [(set i64:$RA, (int_ppc_popcntb i64:$RST))]>;
1016 def CDTBCD8 : XForm_11<31, 282, (outs g8rc:$RA), (ins g8rc:$RST),
1017 "cdtbcd $RA, $RST", IIC_IntGeneral, []>;
1018 def CBCDTD8 : XForm_11<31, 314, (outs g8rc:$RA), (ins g8rc:$RST),
1019 "cbcdtd $RA, $RST", IIC_IntGeneral, []>;
1021 def ADDG6S8 : XOForm_1<31, 74, 0, (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB),
1022 "addg6s $RT, $RA, $RB", IIC_IntGeneral, []>;
1025 defm DIVD : XOForm_1rcr<31, 489, 0, (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB),
1026 "divd", "$RT, $RA, $RB", IIC_IntDivD,
1027 [(set i64:$RT, (sdiv i64:$RA, i64:$RB))]>, isPPC64;
1028 defm DIVDU : XOForm_1rcr<31, 457, 0, (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB),
1029 "divdu", "$RT, $RA, $RB", IIC_IntDivD,
1030 [(set i64:$RT, (udiv i64:$RA, i64:$RB))]>, isPPC64;
1031 defm DIVDE : XOForm_1rcr<31, 425, 0, (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB),
1032 "divde", "$RT, $RA, $RB", IIC_IntDivD,
1033 [(set i64:$RT, (int_ppc_divde g8rc:$RA, g8rc:$RB))]>,
1034 isPPC64, Requires<[HasExtDiv]>;
1036 let Predicates = [IsISA3_0] in {
1037 def MADDHD : VAForm_1a<48, (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB, g8rc:$RC),
1038 "maddhd $RT, $RA, $RB, $RC", IIC_IntMulHD, []>, isPPC64;
1039 def MADDHDU : VAForm_1a<49,
1040 (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB, g8rc:$RC),
1041 "maddhdu $RT, $RA, $RB, $RC", IIC_IntMulHD, []>, isPPC64;
1042 def MADDLD : VAForm_1a<51, (outs gprc:$RT), (ins gprc:$RA, gprc:$RB, gprc:$RC),
1043 "maddld $RT, $RA, $RB, $RC", IIC_IntMulHD,
1044 [(set i32:$RT, (add_without_simm16 (mul_without_simm16 i32:$RA, i32:$RB), i32:$RC))]>,
1046 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
1047 def MADDLD8 : VAForm_1a<51,
1048 (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB, g8rc:$RC),
1049 "maddld $RT, $RA, $RB, $RC", IIC_IntMulHD,
1050 [(set i64:$RT, (add_without_simm16 (mul_without_simm16 i64:$RA, i64:$RB), i64:$RC))]>,
1052 def SETB8 : XForm_44<31, 128, (outs g8rc:$RT), (ins crrc:$BFA),
1053 "setb $RT, $BFA", IIC_IntGeneral>, isPPC64, SExt32To64;
1055 def ADDPCIS : DXForm<19, 2, (outs g8rc:$RT), (ins i32imm:$D),
1056 "addpcis $RT, $D", IIC_BrB, []>, isPPC64;
1057 def MODSD : XForm_8<31, 777, (outs g8rc:$RST), (ins g8rc:$RA, g8rc:$RB),
1058 "modsd $RST, $RA, $RB", IIC_IntDivW,
1059 [(set i64:$RST, (srem i64:$RA, i64:$RB))]>;
1060 def MODUD : XForm_8<31, 265, (outs g8rc:$RST), (ins g8rc:$RA, g8rc:$RB),
1061 "modud $RST, $RA, $RB", IIC_IntDivW,
1062 [(set i64:$RST, (urem i64:$RA, i64:$RB))]>;
1065 defm DIVDEU : XOForm_1rcr<31, 393, 0, (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB),
1066 "divdeu", "$RT, $RA, $RB", IIC_IntDivD,
1067 [(set i64:$RT, (int_ppc_divdeu g8rc:$RA, g8rc:$RB))]>,
1068 isPPC64, Requires<[HasExtDiv]>;
1069 let isCommutable = 1 in
1070 defm MULLD : XOForm_1rx<31, 233, (outs g8rc:$RT), (ins g8rc:$RA, g8rc:$RB),
1071 "mulld", "$RT, $RA, $RB", IIC_IntMulHD,
1072 [(set i64:$RT, (mul i64:$RA, i64:$RB))]>, isPPC64;
1073 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
1074 def MULLI8 : DForm_2<7, (outs g8rc:$RST), (ins g8rc:$RA, s16imm64:$D),
1075 "mulli $RST, $RA, $D", IIC_IntMulLI,
1076 [(set i64:$RST, (mul i64:$RA, imm64SExt16:$D))]>;
1079 let hasSideEffects = 1 in {
1080 def DARN : XForm_45<31, 755, (outs g8rc:$RT), (ins u2imm:$L),
1081 "darn $RT, $L", IIC_LdStLD>, isPPC64;
1084 let hasSideEffects = 0 in {
1085 defm RLDIMI : MDForm_1r<30, 3, (outs g8rc:$RA),
1086 (ins g8rc:$RAi, g8rc:$RS, u6imm:$SH, u6imm:$MBE),
1087 "rldimi", "$RA, $RS, $SH, $MBE", IIC_IntRotateDI,
1088 []>, isPPC64, RegConstraint<"$RAi = $RA">,
1091 // Rotate instructions.
1092 defm RLDCL : MDSForm_1r<30, 8,
1093 (outs g8rc:$RA), (ins g8rc:$RS, gprc:$RB, u6imm:$MBE),
1094 "rldcl", "$RA, $RS, $RB, $MBE", IIC_IntRotateD,
1096 defm RLDCR : MDSForm_1r<30, 9,
1097 (outs g8rc:$RA), (ins g8rc:$RS, gprc:$RB, u6imm:$MBE),
1098 "rldcr", "$RA, $RS, $RB, $MBE", IIC_IntRotateD,
1100 defm RLDICL : MDForm_1r<30, 0,
1101 (outs g8rc:$RA), (ins g8rc:$RS, u6imm:$SH, u6imm:$MBE),
1102 "rldicl", "$RA, $RS, $SH, $MBE", IIC_IntRotateDI,
1105 let isCodeGenOnly = 1 in
1106 def RLDICL_32_64 : MDForm_1<30, 0,
1108 (ins gprc:$RS, u6imm:$SH, u6imm:$MBE),
1109 "rldicl $RA, $RS, $SH, $MBE", IIC_IntRotateDI,
1112 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
1113 defm RLDICL_32 : MDForm_1r<30, 0,
1115 (ins gprc:$RS, u6imm:$SH, u6imm:$MBE),
1116 "rldicl", "$RA, $RS, $SH, $MBE", IIC_IntRotateDI,
1118 defm RLDICR : MDForm_1r<30, 1,
1119 (outs g8rc:$RA), (ins g8rc:$RS, u6imm:$SH, u6imm:$MBE),
1120 "rldicr", "$RA, $RS, $SH, $MBE", IIC_IntRotateDI,
1122 let isCodeGenOnly = 1 in
1123 def RLDICR_32 : MDForm_1<30, 1,
1124 (outs gprc:$RA), (ins gprc:$RS, u6imm:$SH, u6imm:$MBE),
1125 "rldicr $RA, $RS, $SH, $MBE", IIC_IntRotateDI,
1127 defm RLDIC : MDForm_1r<30, 2,
1128 (outs g8rc:$RA), (ins g8rc:$RS, u6imm:$SH, u6imm:$MBE),
1129 "rldic", "$RA, $RS, $SH, $MBE", IIC_IntRotateDI,
1132 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
1133 defm RLWINM8 : MForm_2r<21, (outs g8rc:$RA),
1134 (ins g8rc:$RS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
1135 "rlwinm", "$RA, $RS, $SH, $MB, $ME", IIC_IntGeneral,
1138 defm RLWNM8 : MForm_1r<23, (outs g8rc:$RA),
1139 (ins g8rc:$RS, g8rc:$RB, u5imm:$MB, u5imm:$ME),
1140 "rlwnm", "$RA, $RS, $RB, $MB, $ME", IIC_IntGeneral,
1143 // RLWIMI can be commuted if the rotate amount is zero.
1144 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
1145 defm RLWIMI8 : MForm_2r<20, (outs g8rc:$RA),
1146 (ins g8rc:$RAi, g8rc:$RS, u5imm:$SH, u5imm:$MB,
1147 u5imm:$ME), "rlwimi", "$RA, $RS, $SH, $MB, $ME",
1148 IIC_IntRotate, []>, PPC970_DGroup_Cracked,
1149 RegConstraint<"$RAi = $RA">, NoEncode<"$RAi">;
1152 def ISEL8 : AForm_4<31, 15,
1153 (outs g8rc:$RT), (ins g8rc_nox0:$RA, g8rc:$RB, crbitrc:$COND),
1154 "isel $RT, $RA, $RB, $COND", IIC_IntISEL,
1156 } // Interpretation64Bit
1157 } // hasSideEffects = 0
1158 } // End FXU Operations.
1160 def : InstAlias<"li $rD, $imm", (ADDI8 g8rc:$rD, ZERO8, s16imm64:$imm)>;
1161 def : InstAlias<"lis $rD, $imm", (ADDIS8 g8rc:$rD, ZERO8, s17imm64:$imm)>;
1163 def : InstAlias<"mr $rA, $rB", (OR8 g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
1164 def : InstAlias<"mr. $rA, $rB", (OR8_rec g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
1166 def : InstAlias<"not $rA, $rB", (NOR8 g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
1167 def : InstAlias<"not. $rA, $rB", (NOR8_rec g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
1169 def : InstAlias<"mtcr $rA", (MTCRF8 255, g8rc:$rA)>;
1171 def : InstAlias<"sub $rA, $rB, $rC", (SUBF8 g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
1172 def : InstAlias<"sub. $rA, $rB, $rC", (SUBF8_rec g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
1173 def : InstAlias<"subc $rA, $rB, $rC", (SUBFC8 g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
1174 def : InstAlias<"subc. $rA, $rB, $rC", (SUBFC8_rec g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
1176 def : InstAlias<"rotlwi $rA, $rS, $n", (RLWINM8 g8rc:$rA, g8rc:$rS, u5imm:$n, 0, 31)>;
1177 def : InstAlias<"rotlwi. $rA, $rS, $n", (RLWINM8_rec g8rc:$rA, g8rc:$rS, u5imm:$n, 0, 31)>;
1178 def : InstAlias<"rotlw $rA, $rS, $rB", (RLWNM8 g8rc:$rA, g8rc:$rS, g8rc:$rB, 0, 31)>;
1179 def : InstAlias<"rotlw. $rA, $rS, $rB", (RLWNM8_rec g8rc:$rA, g8rc:$rS, g8rc:$rB, 0, 31)>;
1180 def : InstAlias<"clrlwi $rA, $rS, $n", (RLWINM8 g8rc:$rA, g8rc:$rS, 0, u5imm:$n, 31)>;
1181 def : InstAlias<"clrlwi. $rA, $rS, $n", (RLWINM8_rec g8rc:$rA, g8rc:$rS, 0, u5imm:$n, 31)>;
1183 def : InstAlias<"isellt $rT, $rA, $rB",
1184 (ISEL8 g8rc:$rT, g8rc_nox0:$rA, g8rc:$rB, CR0LT)>;
1185 def : InstAlias<"iselgt $rT, $rA, $rB",
1186 (ISEL8 g8rc:$rT, g8rc_nox0:$rA, g8rc:$rB, CR0GT)>;
1187 def : InstAlias<"iseleq $rT, $rA, $rB",
1188 (ISEL8 g8rc:$rT, g8rc_nox0:$rA, g8rc:$rB, CR0EQ)>;
1190 def : InstAlias<"nop", (ORI8 X0, X0, 0)>;
1191 def : InstAlias<"xnop", (XORI8 X0, X0, 0)>;
1193 def : InstAlias<"cntlzw $rA, $rS", (CNTLZW8 g8rc:$rA, g8rc:$rS)>;
1194 def : InstAlias<"cntlzw. $rA, $rS", (CNTLZW8_rec g8rc:$rA, g8rc:$rS)>;
1196 def : InstAlias<"mtxer $Rx", (MTSPR8 1, g8rc:$Rx)>;
1197 def : InstAlias<"mfxer $Rx", (MFSPR8 g8rc:$Rx, 1)>;
1199 //Disable this alias on AIX for now because as does not support them.
1200 let Predicates = [ModernAs] in {
1202 def : InstAlias<"mtudscr $Rx", (MTSPR8 3, g8rc:$Rx)>;
1203 def : InstAlias<"mfudscr $Rx", (MFSPR8 g8rc:$Rx, 3)>;
1205 def : InstAlias<"mfrtcu $Rx", (MFSPR8 g8rc:$Rx, 4)>;
1206 def : InstAlias<"mfrtcl $Rx", (MFSPR8 g8rc:$Rx, 5)>;
1208 def : InstAlias<"mtlr $Rx", (MTSPR8 8, g8rc:$Rx)>;
1209 def : InstAlias<"mflr $Rx", (MFSPR8 g8rc:$Rx, 8)>;
1211 def : InstAlias<"mtctr $Rx", (MTSPR8 9, g8rc:$Rx)>;
1212 def : InstAlias<"mfctr $Rx", (MFSPR8 g8rc:$Rx, 9)>;
1214 def : InstAlias<"mtuamr $Rx", (MTSPR8 13, g8rc:$Rx)>;
1215 def : InstAlias<"mfuamr $Rx", (MFSPR8 g8rc:$Rx, 13)>;
1217 def : InstAlias<"mtdscr $Rx", (MTSPR8 17, g8rc:$Rx)>;
1218 def : InstAlias<"mfdscr $Rx", (MFSPR8 g8rc:$Rx, 17)>;
1220 def : InstAlias<"mtdsisr $Rx", (MTSPR8 18, g8rc:$Rx)>;
1221 def : InstAlias<"mfdsisr $Rx", (MFSPR8 g8rc:$Rx, 18)>;
1223 def : InstAlias<"mtdar $Rx", (MTSPR8 19, g8rc:$Rx)>;
1224 def : InstAlias<"mfdar $Rx", (MFSPR8 g8rc:$Rx, 19)>;
1226 def : InstAlias<"mtdec $Rx", (MTSPR8 22, g8rc:$Rx)>;
1227 def : InstAlias<"mfdec $Rx", (MFSPR8 g8rc:$Rx, 22)>;
1229 def : InstAlias<"mtsdr1 $Rx", (MTSPR8 25, g8rc:$Rx)>;
1230 def : InstAlias<"mfsdr1 $Rx", (MFSPR8 g8rc:$Rx, 25)>;
1232 def : InstAlias<"mtsrr0 $Rx", (MTSPR8 26, g8rc:$Rx)>;
1233 def : InstAlias<"mfsrr0 $Rx", (MFSPR8 g8rc:$Rx, 26)>;
1235 def : InstAlias<"mtsrr1 $Rx", (MTSPR8 27, g8rc:$Rx)>;
1236 def : InstAlias<"mfsrr1 $Rx", (MFSPR8 g8rc:$Rx, 27)>;
1238 def : InstAlias<"mtcfar $Rx", (MTSPR8 28, g8rc:$Rx)>;
1239 def : InstAlias<"mfcfar $Rx", (MFSPR8 g8rc:$Rx, 28)>;
1241 def : InstAlias<"mtamr $Rx", (MTSPR8 29, g8rc:$Rx)>;
1242 def : InstAlias<"mfamr $Rx", (MFSPR8 g8rc:$Rx, 29)>;
1244 foreach SPRG = 0-3 in {
1245 def : InstAlias<"mfsprg $RT, "#SPRG, (MFSPR8 g8rc:$RT, !add(SPRG, 272))>;
1246 def : InstAlias<"mfsprg"#SPRG#" $RT", (MFSPR8 g8rc:$RT, !add(SPRG, 272))>;
1247 def : InstAlias<"mtsprg "#SPRG#", $RT", (MTSPR8 !add(SPRG, 272), g8rc:$RT)>;
1248 def : InstAlias<"mtsprg"#SPRG#" $RT", (MTSPR8 !add(SPRG, 272), g8rc:$RT)>;
1251 def : InstAlias<"mfasr $RT", (MFSPR8 g8rc:$RT, 280)>;
1252 def : InstAlias<"mtasr $RT", (MTSPR8 280, g8rc:$RT)>;
1254 def : InstAlias<"mttbl $Rx", (MTSPR8 284, g8rc:$Rx)>;
1255 def : InstAlias<"mttbu $Rx", (MTSPR8 285, g8rc:$Rx)>;
1257 def : InstAlias<"mfpvr $RT", (MFSPR8 g8rc:$RT, 287)>;
1259 def : InstAlias<"mfspefscr $Rx", (MFSPR8 g8rc:$Rx, 512)>;
1260 def : InstAlias<"mtspefscr $Rx", (MTSPR8 512, g8rc:$Rx)>;
1264 //===----------------------------------------------------------------------===//
1265 // Load/Store instructions.
1269 // Sign extending loads.
1270 let PPC970_Unit = 2 in {
1271 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
1272 def LHA8: DForm_1<42, (outs g8rc:$RST), (ins (memri $D, $RA):$addr),
1273 "lha $RST, $addr", IIC_LdStLHA,
1274 [(set i64:$RST, (sextloadi16 DForm:$addr))]>,
1275 PPC970_DGroup_Cracked, SExt32To64;
1276 def LWA : DSForm_1<58, 2, (outs g8rc:$RST), (ins (memrix $D, $RA):$addr),
1277 "lwa $RST, $addr", IIC_LdStLWA,
1279 (sextloadi32 DSForm:$addr))]>, isPPC64,
1280 PPC970_DGroup_Cracked, SExt32To64;
1281 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
1282 def LHAX8: XForm_1_memOp<31, 343, (outs g8rc:$RST), (ins (memrr $RA, $RB):$addr),
1283 "lhax $RST, $addr", IIC_LdStLHA,
1284 [(set i64:$RST, (sextloadi16 XForm:$addr))]>,
1285 PPC970_DGroup_Cracked, SExt32To64;
1286 def LWAX : XForm_1_memOp<31, 341, (outs g8rc:$RST), (ins (memrr $RA, $RB):$addr),
1287 "lwax $RST, $addr", IIC_LdStLHA,
1288 [(set i64:$RST, (sextloadi32 XForm:$addr))]>, isPPC64,
1289 PPC970_DGroup_Cracked, SExt32To64;
1291 let isCodeGenOnly = 1, mayLoad = 1, hasSideEffects = 0 in {
1292 def LWA_32 : DSForm_1<58, 2, (outs gprc:$RST), (ins (memrix $D, $RA):$addr),
1293 "lwa $RST, $addr", IIC_LdStLWA, []>, isPPC64,
1294 PPC970_DGroup_Cracked, SExt32To64;
1295 def LWAX_32 : XForm_1_memOp<31, 341, (outs gprc:$RST), (ins (memrr $RA, $RB):$addr),
1296 "lwax $RST, $addr", IIC_LdStLHA, []>, isPPC64,
1297 PPC970_DGroup_Cracked, SExt32To64;
1298 } // end fast-isel isCodeGenOnly
1301 let mayLoad = 1, hasSideEffects = 0 in {
1302 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
1303 def LHAU8 : DForm_1<43, (outs g8rc:$RST, ptr_rc_nor0:$ea_result),
1304 (ins (memri $D, $RA):$addr),
1305 "lhau $RST, $addr", IIC_LdStLHAU,
1306 []>, RegConstraint<"$addr.reg = $ea_result">,
1307 NoEncode<"$ea_result">;
1310 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
1311 def LHAUX8 : XForm_1_memOp<31, 375, (outs g8rc:$RST, ptr_rc_nor0:$ea_result),
1312 (ins (memrr $RA, $RB):$addr),
1313 "lhaux $RST, $addr", IIC_LdStLHAUX,
1314 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1315 NoEncode<"$ea_result">;
1316 def LWAUX : XForm_1_memOp<31, 373, (outs g8rc:$RST, ptr_rc_nor0:$ea_result),
1317 (ins (memrr $RA, $RB):$addr),
1318 "lwaux $RST, $addr", IIC_LdStLHAUX,
1319 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1320 NoEncode<"$ea_result">, isPPC64;
1324 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
1325 // Zero extending loads.
1326 let PPC970_Unit = 2 in {
1327 def LBZ8 : DForm_1<34, (outs g8rc:$RST), (ins (memri $D, $RA):$addr),
1328 "lbz $RST, $addr", IIC_LdStLoad,
1329 [(set i64:$RST, (zextloadi8 DForm:$addr))]>, ZExt32To64,
1331 def LHZ8 : DForm_1<40, (outs g8rc:$RST), (ins (memri $D, $RA):$addr),
1332 "lhz $RST, $addr", IIC_LdStLoad,
1333 [(set i64:$RST, (zextloadi16 DForm:$addr))]>, ZExt32To64,
1335 def LWZ8 : DForm_1<32, (outs g8rc:$RST), (ins (memri $D, $RA):$addr),
1336 "lwz $RST, $addr", IIC_LdStLoad,
1337 [(set i64:$RST, (zextloadi32 DForm:$addr))]>, isPPC64,
1340 def LBZX8 : XForm_1_memOp<31, 87, (outs g8rc:$RST), (ins (memrr $RA, $RB):$addr),
1341 "lbzx $RST, $addr", IIC_LdStLoad,
1342 [(set i64:$RST, (zextloadi8 XForm:$addr))]>, ZExt32To64,
1344 def LHZX8 : XForm_1_memOp<31, 279, (outs g8rc:$RST), (ins (memrr $RA, $RB):$addr),
1345 "lhzx $RST, $addr", IIC_LdStLoad,
1346 [(set i64:$RST, (zextloadi16 XForm:$addr))]>,
1347 ZExt32To64, SExt32To64;
1348 def LWZX8 : XForm_1_memOp<31, 23, (outs g8rc:$RST), (ins (memrr $RA, $RB):$addr),
1349 "lwzx $RST, $addr", IIC_LdStLoad,
1350 [(set i64:$RST, (zextloadi32 XForm:$addr))]>,
1355 let mayLoad = 1, hasSideEffects = 0 in {
1356 def LBZU8 : DForm_1<35, (outs g8rc:$RST, ptr_rc_nor0:$ea_result),
1357 (ins (memri $D, $RA):$addr),
1358 "lbzu $RST, $addr", IIC_LdStLoadUpd,
1359 []>, RegConstraint<"$addr.reg = $ea_result">,
1360 NoEncode<"$ea_result">;
1361 def LHZU8 : DForm_1<41, (outs g8rc:$RST, ptr_rc_nor0:$ea_result),
1362 (ins (memri $D, $RA):$addr),
1363 "lhzu $RST, $addr", IIC_LdStLoadUpd,
1364 []>, RegConstraint<"$addr.reg = $ea_result">,
1365 NoEncode<"$ea_result">;
1366 def LWZU8 : DForm_1<33, (outs g8rc:$RST, ptr_rc_nor0:$ea_result),
1367 (ins (memri $D, $RA):$addr),
1368 "lwzu $RST, $addr", IIC_LdStLoadUpd,
1369 []>, RegConstraint<"$addr.reg = $ea_result">,
1370 NoEncode<"$ea_result">;
1372 def LBZUX8 : XForm_1_memOp<31, 119, (outs g8rc:$RST, ptr_rc_nor0:$ea_result),
1373 (ins (memrr $RA, $RB):$addr),
1374 "lbzux $RST, $addr", IIC_LdStLoadUpdX,
1375 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1376 NoEncode<"$ea_result">;
1377 def LHZUX8 : XForm_1_memOp<31, 311, (outs g8rc:$RST, ptr_rc_nor0:$ea_result),
1378 (ins (memrr $RA, $RB):$addr),
1379 "lhzux $RST, $addr", IIC_LdStLoadUpdX,
1380 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1381 NoEncode<"$ea_result">;
1382 def LWZUX8 : XForm_1_memOp<31, 55, (outs g8rc:$RST, ptr_rc_nor0:$ea_result),
1383 (ins (memrr $RA, $RB):$addr),
1384 "lwzux $RST, $addr", IIC_LdStLoadUpdX,
1385 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1386 NoEncode<"$ea_result">;
1389 } // Interpretation64Bit
1392 // Full 8-byte loads.
1393 let PPC970_Unit = 2 in {
1394 def LD : DSForm_1<58, 0, (outs g8rc:$RST), (ins (memrix $D, $RA):$addr),
1395 "ld $RST, $addr", IIC_LdStLD,
1396 [(set i64:$RST, (load DSForm:$addr))]>, isPPC64;
1397 // The following four definitions are selected for small code model only.
1398 // Otherwise, we need to create two instructions to form a 32-bit offset,
1399 // so we have a custom matcher for TOC_ENTRY in PPCDAGToDAGIsel::Select().
1400 def LDtoc: PPCEmitTimePseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
1403 (PPCtoc_entry tglobaladdr:$disp, i64:$reg))]>, isPPC64;
1404 def LDtocJTI: PPCEmitTimePseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
1407 (PPCtoc_entry tjumptable:$disp, i64:$reg))]>, isPPC64;
1408 def LDtocCPT: PPCEmitTimePseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
1411 (PPCtoc_entry tconstpool:$disp, i64:$reg))]>, isPPC64;
1412 def LDtocBA: PPCEmitTimePseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
1415 (PPCtoc_entry tblockaddress:$disp, i64:$reg))]>, isPPC64;
1417 def LDX : XForm_1_memOp<31, 21, (outs g8rc:$RST), (ins (memrr $RA, $RB):$addr),
1418 "ldx $RST, $addr", IIC_LdStLD,
1419 [(set i64:$RST, (load XForm:$addr))]>, isPPC64;
1421 let Predicates = [IsISA2_06] in {
1422 def LDBRX : XForm_1_memOp<31, 532, (outs g8rc:$RST), (ins (memrr $RA, $RB):$addr),
1423 "ldbrx $RST, $addr", IIC_LdStLoad,
1424 [(set i64:$RST, (PPClbrx ForceXForm:$addr, i64))]>, isPPC64;
1427 let mayLoad = 1, hasSideEffects = 0, isCodeGenOnly = 1 in {
1428 def LHBRX8 : XForm_1_memOp<31, 790, (outs g8rc:$RST), (ins (memrr $RA, $RB):$addr),
1429 "lhbrx $RST, $addr", IIC_LdStLoad, []>, ZExt32To64;
1430 def LWBRX8 : XForm_1_memOp<31, 534, (outs g8rc:$RST), (ins (memrr $RA, $RB):$addr),
1431 "lwbrx $RST, $addr", IIC_LdStLoad, []>, ZExt32To64;
1434 let mayLoad = 1, hasSideEffects = 0 in {
1435 def LDU : DSForm_1<58, 1, (outs g8rc:$RST, ptr_rc_nor0:$ea_result),
1436 (ins (memrix $D, $RA):$addr),
1437 "ldu $RST, $addr", IIC_LdStLDU,
1438 []>, RegConstraint<"$addr.reg = $ea_result">, isPPC64,
1439 NoEncode<"$ea_result">;
1441 def LDUX : XForm_1_memOp<31, 53, (outs g8rc:$RST, ptr_rc_nor0:$ea_result),
1442 (ins (memrr $RA, $RB):$addr),
1443 "ldux $RST, $addr", IIC_LdStLDUX,
1444 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1445 NoEncode<"$ea_result">, isPPC64;
1448 let mayLoad = 1, hasNoSchedulingInfo = 1 in {
1449 // Full 16-byte load.
1450 // Early clobber $RTp to avoid assigned to the same register as RA.
1451 // TODO: Add scheduling info.
1452 def LQ : DQForm_RTp5_RA17_MEM<56, 0,
1454 (ins (memrix16 $DQ, $RA):$addr),
1455 "lq $RTp, $addr", IIC_LdStLQ,
1457 RegConstraint<"@earlyclobber $RTp">,
1459 // We don't really have LQX in the ISA, make a pseudo one so that we can
1460 // handle x-form during isel. Make it pre-ra may expose
1461 // oppotunities to some opts(CSE, LICM and etc.) for the result of adding
1463 def LQX_PSEUDO : PPCCustomInserterPseudo<(outs g8prc:$RTp),
1464 (ins memrr:$src), "#LQX_PSEUDO", []>;
1466 def RESTORE_QUADWORD : PPCEmitTimePseudo<(outs g8prc:$RTp), (ins memrix:$src),
1467 "#RESTORE_QUADWORD", []>;
1472 def : Pat<(int_ppc_atomic_load_i128 iaddrX16:$src),
1473 (SPLIT_QUADWORD (LQ memrix16:$src))>;
1475 def : Pat<(int_ppc_atomic_load_i128 ForceXForm:$src),
1476 (SPLIT_QUADWORD (LQX_PSEUDO memrr:$src))>;
1478 // Support for medium and large code model.
1479 let hasSideEffects = 0 in {
1480 let isReMaterializable = 1 in {
1481 def ADDIStocHA8: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, tocentry:$disp),
1482 "#ADDIStocHA8", []>, isPPC64;
1483 def ADDItocL8: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, tocentry:$disp),
1484 "#ADDItocL8", []>, isPPC64;
1487 // Local Data Transform
1488 def ADDItoc8 : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, tocentry:$disp),
1492 def LDtocL: PPCEmitTimePseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc_nox0:$reg),
1493 "#LDtocL", []>, isPPC64;
1496 // Support for thread-local storage.
1497 def ADDISgotTprelHA: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
1500 (PPCaddisGotTprelHA i64:$reg,
1501 tglobaltlsaddr:$disp))]>,
1503 def LDgotTprelL: PPCEmitTimePseudo<(outs g8rc_nox0:$rD), (ins s16imm64:$disp, g8rc_nox0:$reg),
1506 (PPCldGotTprelL tglobaltlsaddr:$disp, i64:$reg))]>,
1509 let Defs = [CR7], Itinerary = IIC_LdStSync in
1510 def CFENCE8 : PPCPostRAExpPseudo<(outs), (ins g8rc:$cr), "#CFENCE8", []>;
1512 def : Pat<(PPCaddTls i64:$in, tglobaltlsaddr:$g),
1513 (ADD8TLS $in, tglobaltlsaddr:$g)>;
1514 def ADDIStlsgdHA: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
1517 (PPCaddisTlsgdHA i64:$reg, tglobaltlsaddr:$disp))]>,
1519 def ADDItlsgdL : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
1522 (PPCaddiTlsgdL i64:$reg, tglobaltlsaddr:$disp))]>,
1525 class GETtlsADDRPseudo <string asmstr> : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc:$reg, tlsgd:$sym),
1528 (PPCgetTlsAddr i64:$reg, tglobaltlsaddr:$sym))]>,
1530 class GETtlsldADDRPseudo <string asmstr> : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc:$reg, tlsgd:$sym),
1533 (PPCgetTlsldAddr i64:$reg, tglobaltlsaddr:$sym))]>,
1536 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1 in {
1537 // LR8 is a true define, while the rest of the Defs are clobbers. X3 is
1538 // explicitly defined when this op is created, so not mentioned here.
1539 // This is lowered to BL8_NOP_TLS by the assembly printer, so the size must be
1540 // correct because the branch select pass is relying on it.
1541 let Defs = [X0,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7], Size = 8 in
1542 def GETtlsADDR : GETtlsADDRPseudo <"#GETtlsADDR">;
1543 let Defs = [X0,X2,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7], Size = 8 in
1544 def GETtlsADDRPCREL : GETtlsADDRPseudo <"#GETtlsADDRPCREL">;
1546 // LR8 is a true define, while the rest of the Defs are clobbers. X3 is
1547 // explicitly defined when this op is created, so not mentioned here.
1548 let Defs = [X0,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7] in
1549 def GETtlsldADDR : GETtlsldADDRPseudo <"#GETtlsldADDR">;
1550 let Defs = [X0,X2,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7] in
1551 def GETtlsldADDRPCREL : GETtlsldADDRPseudo <"#GETtlsldADDRPCREL">;
1553 // On AIX, the call to __tls_get_addr needs two inputs in X3/X4 for the
1554 // offset and region handle respectively. The call is not followed by a nop
1555 // so we don't need to mark it with a size of 8 bytes. Finally, the assembly
1556 // manual mentions this exact set of registers as the clobbered set, others
1557 // are guaranteed not to be clobbered.
1558 let Defs = [X0,X4,X5,X11,LR8,CR0] in {
1559 def GETtlsADDR64AIX :
1560 PPCEmitTimePseudo<(outs g8rc:$rD),(ins g8rc:$offset, g8rc:$handle),
1563 (PPCgetTlsAddr i64:$offset, i64:$handle))]>, isPPC64;
1564 // On AIX, the call to .__tls_get_mod needs one input in X3 for the module handle.
1565 def GETtlsMOD64AIX :
1566 PPCEmitTimePseudo<(outs g8rc:$rD),(ins g8rc:$handle),
1569 (PPCgetTlsMod i64:$handle))]>, isPPC64;
1573 // Combined op for ADDItlsgdL and GETtlsADDR, late expanded. X3 and LR8
1574 // are true defines while the rest of the Defs are clobbers.
1575 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
1576 Defs = [X0,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7]
1578 def ADDItlsgdLADDR : PPCEmitTimePseudo<(outs g8rc:$rD),
1579 (ins g8rc_nox0:$reg, s16imm64:$disp, tlsgd:$sym),
1582 (PPCaddiTlsgdLAddr i64:$reg,
1583 tglobaltlsaddr:$disp,
1584 tglobaltlsaddr:$sym))]>,
1586 def ADDIStlsldHA: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
1589 (PPCaddisTlsldHA i64:$reg, tglobaltlsaddr:$disp))]>,
1591 def ADDItlsldL : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
1594 (PPCaddiTlsldL i64:$reg, tglobaltlsaddr:$disp))]>,
1596 // This pseudo is expanded to two copies to put the variable offset in R4 and
1597 // the region handle in R3 and GETtlsADDR64AIX.
1599 PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc:$offset, g8rc:$handle),
1602 (PPCTlsgdAIX i64:$offset, i64:$handle))]>;
1603 // This pseudo is expanded to the call to GETtlsMOD64AIX.
1604 def TLSLDAIX8 : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc:$handle),
1605 "#TLSLDAIX8", [(set i64:$rD, (PPCTlsldAIX i64:$handle))]>;
1606 // Combined op for ADDItlsldL and GETtlsADDR, late expanded. X3 and LR8
1607 // are true defines, while the rest of the Defs are clobbers.
1608 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
1609 Defs = [X0,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7]
1611 def ADDItlsldLADDR : PPCEmitTimePseudo<(outs g8rc:$rD),
1612 (ins g8rc_nox0:$reg, s16imm64:$disp, tlsgd:$sym),
1615 (PPCaddiTlsldLAddr i64:$reg,
1616 tglobaltlsaddr:$disp,
1617 tglobaltlsaddr:$sym))]>,
1619 def ADDISdtprelHA: PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
1622 (PPCaddisDtprelHA i64:$reg,
1623 tglobaltlsaddr:$disp))]>,
1625 def ADDIdtprelL : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
1628 (PPCaddiDtprelL i64:$reg, tglobaltlsaddr:$disp))]>,
1630 def PADDIdtprel : PPCEmitTimePseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
1633 (PPCpaddiDtprel i64:$reg, tglobaltlsaddr:$disp))]>,
1636 let PPC970_Unit = 2 in {
1637 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
1638 // Truncating stores.
1639 def STB8 : DForm_1<38, (outs), (ins g8rc:$RST, (memri $D, $RA):$addr),
1640 "stb $RST, $addr", IIC_LdStStore,
1641 [(truncstorei8 i64:$RST, DForm:$addr)]>;
1642 def STH8 : DForm_1<44, (outs), (ins g8rc:$RST, (memri $D, $RA):$addr),
1643 "sth $RST, $addr", IIC_LdStStore,
1644 [(truncstorei16 i64:$RST, DForm:$addr)]>;
1645 def STW8 : DForm_1<36, (outs), (ins g8rc:$RST, (memri $D, $RA):$addr),
1646 "stw $RST, $addr", IIC_LdStStore,
1647 [(truncstorei32 i64:$RST, DForm:$addr)]>;
1648 def STBX8 : XForm_8_memOp<31, 215, (outs), (ins g8rc:$RST, (memrr $RA, $RB):$addr),
1649 "stbx $RST, $addr", IIC_LdStStore,
1650 [(truncstorei8 i64:$RST, XForm:$addr)]>,
1651 PPC970_DGroup_Cracked;
1652 def STHX8 : XForm_8_memOp<31, 407, (outs), (ins g8rc:$RST, (memrr $RA, $RB):$addr),
1653 "sthx $RST, $addr", IIC_LdStStore,
1654 [(truncstorei16 i64:$RST, XForm:$addr)]>,
1655 PPC970_DGroup_Cracked;
1656 def STWX8 : XForm_8_memOp<31, 151, (outs), (ins g8rc:$RST, (memrr $RA, $RB):$addr),
1657 "stwx $RST, $addr", IIC_LdStStore,
1658 [(truncstorei32 i64:$RST, XForm:$addr)]>,
1659 PPC970_DGroup_Cracked;
1660 } // Interpretation64Bit
1662 // Normal 8-byte stores.
1663 def STD : DSForm_1<62, 0, (outs), (ins g8rc:$RST, (memrix $D, $RA):$addr),
1664 "std $RST, $addr", IIC_LdStSTD,
1665 [(store i64:$RST, DSForm:$addr)]>, isPPC64;
1666 def STDX : XForm_8_memOp<31, 149, (outs), (ins g8rc:$RST, (memrr $RA, $RB):$addr),
1667 "stdx $RST, $addr", IIC_LdStSTD,
1668 [(store i64:$RST, XForm:$addr)]>, isPPC64,
1669 PPC970_DGroup_Cracked;
1671 let Predicates = [IsISA2_06] in {
1672 def STDBRX: XForm_8_memOp<31, 660, (outs), (ins g8rc:$RST, (memrr $RA, $RB):$addr),
1673 "stdbrx $RST, $addr", IIC_LdStStore,
1674 [(PPCstbrx i64:$RST, ForceXForm:$addr, i64)]>, isPPC64,
1675 PPC970_DGroup_Cracked;
1678 let mayStore = 1, hasNoSchedulingInfo = 1 in {
1679 // Normal 16-byte stores.
1680 // TODO: Add scheduling info.
1681 def STQ : DSForm_1<62, 2, (outs), (ins g8prc:$RST, (memrix $D, $RA):$addr),
1682 "stq $RST, $addr", IIC_LdStSTQ,
1685 def STQX_PSEUDO : PPCCustomInserterPseudo<(outs),
1686 (ins g8prc:$RSp, memrr:$dst),
1687 "#STQX_PSEUDO", []>;
1689 def SPILL_QUADWORD : PPCEmitTimePseudo<(outs), (ins g8prc:$RSp, memrix:$dst),
1690 "#SPILL_QUADWORD", []>;
1695 def BUILD_QUADWORD : PPCPostRAExpPseudo<
1697 (ins g8rc:$lo, g8rc:$hi),
1698 "#BUILD_QUADWORD", []>;
1700 def : Pat<(int_ppc_atomic_store_i128 i64:$lo, i64:$hi, DSForm:$dst),
1701 (STQ (BUILD_QUADWORD g8rc:$lo, g8rc:$hi), memrix:$dst)>;
1703 def : Pat<(int_ppc_atomic_store_i128 i64:$lo, i64:$hi, ForceXForm:$dst),
1704 (STQX_PSEUDO (BUILD_QUADWORD g8rc:$lo, g8rc:$hi), memrr:$dst)>;
1706 // Stores with Update (pre-inc).
1707 let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in {
1708 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
1709 def STBU8 : DForm_1<39, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$RST, (memri $D, $RA):$addr),
1710 "stbu $RST, $addr", IIC_LdStSTU, []>,
1711 RegConstraint<"$addr.reg = $ea_res">, NoEncode<"$ea_res">;
1712 def STHU8 : DForm_1<45, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$RST, (memri $D, $RA):$addr),
1713 "sthu $RST, $addr", IIC_LdStSTU, []>,
1714 RegConstraint<"$addr.reg = $ea_res">, NoEncode<"$ea_res">;
1715 def STWU8 : DForm_1<37, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$RST, (memri $D, $RA):$addr),
1716 "stwu $RST, $addr", IIC_LdStSTU, []>,
1717 RegConstraint<"$addr.reg = $ea_res">, NoEncode<"$ea_res">;
1719 def STBUX8: XForm_8_memOp<31, 247, (outs ptr_rc_nor0:$ea_res),
1720 (ins g8rc:$RST, (memrr $RA, $RB):$addr),
1721 "stbux $RST, $addr", IIC_LdStSTUX, []>,
1722 RegConstraint<"$addr.ptrreg = $ea_res">,
1723 NoEncode<"$ea_res">,
1724 PPC970_DGroup_Cracked;
1725 def STHUX8: XForm_8_memOp<31, 439, (outs ptr_rc_nor0:$ea_res),
1726 (ins g8rc:$RST, (memrr $RA, $RB):$addr),
1727 "sthux $RST, $addr", IIC_LdStSTUX, []>,
1728 RegConstraint<"$addr.ptrreg = $ea_res">,
1729 NoEncode<"$ea_res">,
1730 PPC970_DGroup_Cracked;
1731 def STWUX8: XForm_8_memOp<31, 183, (outs ptr_rc_nor0:$ea_res),
1732 (ins g8rc:$RST, (memrr $RA, $RB):$addr),
1733 "stwux $RST, $addr", IIC_LdStSTUX, []>,
1734 RegConstraint<"$addr.ptrreg = $ea_res">,
1735 NoEncode<"$ea_res">,
1736 PPC970_DGroup_Cracked;
1737 } // Interpretation64Bit
1739 def STDU : DSForm_1<62, 1, (outs ptr_rc_nor0:$ea_res),
1740 (ins g8rc:$RST, (memrix $D, $RA):$addr),
1741 "stdu $RST, $addr", IIC_LdStSTU, []>,
1742 RegConstraint<"$addr.reg = $ea_res">, NoEncode<"$ea_res">,
1745 def STDUX : XForm_8_memOp<31, 181, (outs ptr_rc_nor0:$ea_res),
1746 (ins g8rc:$RST, (memrr $RA, $RB):$addr),
1747 "stdux $RST, $addr", IIC_LdStSTUX, []>,
1748 RegConstraint<"$addr.ptrreg = $ea_res">,
1749 NoEncode<"$ea_res">,
1750 PPC970_DGroup_Cracked, isPPC64;
1753 // Patterns to match the pre-inc stores. We can't put the patterns on
1754 // the instruction definitions directly as ISel wants the address base
1755 // and offset to be separate operands, not a single complex operand.
1756 def : Pat<(pre_truncsti8 i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1757 (STBU8 $rS, iaddroff:$ptroff, $ptrreg)>;
1758 def : Pat<(pre_truncsti16 i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1759 (STHU8 $rS, iaddroff:$ptroff, $ptrreg)>;
1760 def : Pat<(pre_truncsti32 i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1761 (STWU8 $rS, iaddroff:$ptroff, $ptrreg)>;
1762 def : Pat<(DSFormPreStore i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1763 (STDU $rS, iaddroff:$ptroff, $ptrreg)>;
1765 def : Pat<(pre_truncsti8 i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1766 (STBUX8 $rS, $ptrreg, $ptroff)>;
1767 def : Pat<(pre_truncsti16 i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1768 (STHUX8 $rS, $ptrreg, $ptroff)>;
1769 def : Pat<(pre_truncsti32 i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1770 (STWUX8 $rS, $ptrreg, $ptroff)>;
1771 def : Pat<(pre_store i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1772 (STDUX $rS, $ptrreg, $ptroff)>;
1775 //===----------------------------------------------------------------------===//
1776 // Floating point instructions.
1780 let PPC970_Unit = 3, hasSideEffects = 0, mayRaiseFPException = 1,
1781 Uses = [RM] in { // FPU Operations.
1782 defm FCFID : XForm_26r<63, 846, (outs f8rc:$RST), (ins f8rc:$RB),
1783 "fcfid", "$RST, $RB", IIC_FPGeneral,
1784 [(set f64:$RST, (PPCany_fcfid f64:$RB))]>, isPPC64;
1785 defm FCTID : XForm_26r<63, 814, (outs f8rc:$RST), (ins f8rc:$RB),
1786 "fctid", "$RST, $RB", IIC_FPGeneral,
1788 defm FCTIDU : XForm_26r<63, 942, (outs f8rc:$RST), (ins f8rc:$RB),
1789 "fctidu", "$RST, $RB", IIC_FPGeneral,
1791 defm FCTIDZ : XForm_26r<63, 815, (outs f8rc:$RST), (ins f8rc:$RB),
1792 "fctidz", "$RST, $RB", IIC_FPGeneral,
1793 [(set f64:$RST, (PPCany_fctidz f64:$RB))]>, isPPC64;
1795 defm FCFIDU : XForm_26r<63, 974, (outs f8rc:$RST), (ins f8rc:$RB),
1796 "fcfidu", "$RST, $RB", IIC_FPGeneral,
1797 [(set f64:$RST, (PPCany_fcfidu f64:$RB))]>, isPPC64;
1798 defm FCFIDS : XForm_26r<59, 846, (outs f4rc:$RST), (ins f8rc:$RB),
1799 "fcfids", "$RST, $RB", IIC_FPGeneral,
1800 [(set f32:$RST, (PPCany_fcfids f64:$RB))]>, isPPC64;
1801 defm FCFIDUS : XForm_26r<59, 974, (outs f4rc:$RST), (ins f8rc:$RB),
1802 "fcfidus", "$RST, $RB", IIC_FPGeneral,
1803 [(set f32:$RST, (PPCany_fcfidus f64:$RB))]>, isPPC64;
1804 defm FCTIDUZ : XForm_26r<63, 943, (outs f8rc:$RST), (ins f8rc:$RB),
1805 "fctiduz", "$RST, $RB", IIC_FPGeneral,
1806 [(set f64:$RST, (PPCany_fctiduz f64:$RB))]>, isPPC64;
1807 defm FCTIWUZ : XForm_26r<63, 143, (outs f8rc:$RST), (ins f8rc:$RB),
1808 "fctiwuz", "$RST, $RB", IIC_FPGeneral,
1809 [(set f64:$RST, (PPCany_fctiwuz f64:$RB))]>, isPPC64;
1812 // These instructions store a hash computed from the value of the link register
1813 // and the value of the stack pointer.
1814 let mayStore = 1, Interpretation64Bit = 1, isCodeGenOnly = 1 in {
1815 def HASHST8 : XForm_XD6_RA5_RB5<31, 722, (outs),
1816 (ins g8rc:$RB, (memrihash $D, $RA):$addr),
1817 "hashst $RB, $addr", IIC_IntGeneral, []>;
1818 def HASHSTP8 : XForm_XD6_RA5_RB5<31, 658, (outs),
1819 (ins g8rc:$RB, (memrihash $D, $RA):$addr),
1820 "hashstp $RB, $addr", IIC_IntGeneral, []>;
1823 // These instructions check a hash computed from the value of the link register
1824 // and the value of the stack pointer. The hasSideEffects flag is needed as the
1825 // instruction may TRAP if the hash does not match the hash stored at the
1826 // specified address.
1827 let mayLoad = 1, hasSideEffects = 1,
1828 Interpretation64Bit = 1, isCodeGenOnly = 1 in {
1829 def HASHCHK8 : XForm_XD6_RA5_RB5<31, 754, (outs),
1830 (ins g8rc:$RB, (memrihash $D, $RA):$addr),
1831 "hashchk $RB, $addr", IIC_IntGeneral, []>;
1832 def HASHCHKP8 : XForm_XD6_RA5_RB5<31, 690, (outs),
1833 (ins g8rc:$RB, (memrihash $D, $RA):$addr),
1834 "hashchkp $RB, $addr", IIC_IntGeneral, []>;
1837 let Interpretation64Bit = 1, isCodeGenOnly = 1, hasSideEffects = 1 in
1838 def ADDEX8 : Z23Form_RTAB5_CY2<31, 170, (outs g8rc:$RT),
1839 (ins g8rc:$RA, g8rc:$RB, u2imm:$CY),
1840 "addex $RT, $RA, $RB, $CY", IIC_IntGeneral,
1841 [(set i64:$RT, (int_ppc_addex i64:$RA, i64:$RB,
1844 //===----------------------------------------------------------------------===//
1845 // Instruction Patterns
1848 // Extensions and truncates to/from 32-bit regs.
1849 def : Pat<(i64 (zext i32:$in)),
1850 (RLDICL (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $in, sub_32),
1852 def : Pat<(i64 (anyext i32:$in)),
1853 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $in, sub_32)>;
1854 def : Pat<(i32 (trunc i64:$in)),
1855 (EXTRACT_SUBREG $in, sub_32)>;
1857 // Implement the 'not' operation with the NOR instruction.
1858 // (we could use the default xori pattern, but nor has lower latency on some
1859 // cores (such as the A2)).
1860 def i64not : OutPatFrag<(ops node:$in),
1862 def : Pat<(not i64:$in),
1865 // Extending loads with i64 targets.
1866 def : Pat<(zextloadi1 DForm:$src),
1868 def : Pat<(zextloadi1 XForm:$src),
1869 (LBZX8 XForm:$src)>;
1870 def : Pat<(extloadi1 DForm:$src),
1872 def : Pat<(extloadi1 XForm:$src),
1873 (LBZX8 XForm:$src)>;
1874 def : Pat<(extloadi8 DForm:$src),
1876 def : Pat<(extloadi8 XForm:$src),
1877 (LBZX8 XForm:$src)>;
1878 def : Pat<(extloadi16 DForm:$src),
1880 def : Pat<(extloadi16 XForm:$src),
1881 (LHZX8 XForm:$src)>;
1882 def : Pat<(extloadi32 DForm:$src),
1884 def : Pat<(extloadi32 XForm:$src),
1885 (LWZX8 XForm:$src)>;
1887 // Standard shifts. These are represented separately from the real shifts above
1888 // so that we can distinguish between shifts that allow 6-bit and 7-bit shift
1890 def : Pat<(sra i64:$rS, i32:$rB),
1892 def : Pat<(srl i64:$rS, i32:$rB),
1894 def : Pat<(shl i64:$rS, i32:$rB),
1898 def : Pat<(sub imm64SExt16:$imm, i64:$in),
1899 (SUBFIC8 $in, imm:$imm)>;
1902 def : Pat<(shl i64:$in, (i32 imm:$imm)),
1903 (RLDICR $in, imm:$imm, (SHL64 imm:$imm))>;
1904 def : Pat<(srl i64:$in, (i32 imm:$imm)),
1905 (RLDICL $in, (SRL64 imm:$imm), imm:$imm)>;
1908 def : Pat<(rotl i64:$in, i32:$sh),
1909 (RLDCL $in, $sh, 0)>;
1910 def : Pat<(rotl i64:$in, (i32 imm:$imm)),
1911 (RLDICL $in, imm:$imm, 0)>;
1913 // Hi and Lo for Darwin Global Addresses.
1914 def : Pat<(PPChi tglobaladdr:$in, 0), (LIS8 tglobaladdr:$in)>;
1915 def : Pat<(PPClo tglobaladdr:$in, 0), (LI8 tglobaladdr:$in)>;
1916 def : Pat<(PPChi tconstpool:$in , 0), (LIS8 tconstpool:$in)>;
1917 def : Pat<(PPClo tconstpool:$in , 0), (LI8 tconstpool:$in)>;
1918 def : Pat<(PPChi tjumptable:$in , 0), (LIS8 tjumptable:$in)>;
1919 def : Pat<(PPClo tjumptable:$in , 0), (LI8 tjumptable:$in)>;
1920 def : Pat<(PPChi tblockaddress:$in, 0), (LIS8 tblockaddress:$in)>;
1921 def : Pat<(PPClo tblockaddress:$in, 0), (LI8 tblockaddress:$in)>;
1922 def : Pat<(PPChi tglobaltlsaddr:$g, i64:$in),
1923 (ADDIS8 $in, tglobaltlsaddr:$g)>;
1924 def : Pat<(PPClo tglobaltlsaddr:$g, i64:$in),
1925 (ADDI8 $in, tglobaltlsaddr:$g)>;
1926 def : Pat<(add i64:$in, (PPChi tglobaladdr:$g, 0)),
1927 (ADDIS8 $in, tglobaladdr:$g)>;
1928 def : Pat<(add i64:$in, (PPChi tconstpool:$g, 0)),
1929 (ADDIS8 $in, tconstpool:$g)>;
1930 def : Pat<(add i64:$in, (PPChi tjumptable:$g, 0)),
1931 (ADDIS8 $in, tjumptable:$g)>;
1932 def : Pat<(add i64:$in, (PPChi tblockaddress:$g, 0)),
1933 (ADDIS8 $in, tblockaddress:$g)>;
1935 // AIX 64-bit small code model TLS access.
1936 // This is used for global dynamic accesses when loading the region handle and
1937 // variable offset, and also for local-exec accesses to load the offset of a
1938 // TLS variable from the TOC, prior to adding it to r13.
1939 def : Pat<(i64 (PPCtoc_entry tglobaltlsaddr:$disp, i64:$reg)),
1940 (i64 (LDtoc tglobaltlsaddr:$disp, i64:$reg))>;
1942 // The following pattern matches 64-bit local- and initial-exec TLS accesses on AIX.
1943 // PPCaddTls is used in local- and initial-exec accesses in order to:
1944 // - Get the address of a variable (adding the variable offset to the thread
1946 // - Create an opportunity to optimize the user of the loaded address.
1947 def : Pat<(PPCaddTls i64:$in, i64:$addr),
1948 (ADD8TLS $in, $addr)>;
1950 // 64-bits atomic loads and stores
1951 def : Pat<(atomic_load_64 DSForm:$src), (LD memrix:$src)>;
1952 def : Pat<(atomic_load_64 XForm:$src), (LDX memrr:$src)>;
1954 def : Pat<(atomic_store_64 i64:$val, DSForm:$ptr), (STD g8rc:$val, memrix:$ptr)>;
1955 def : Pat<(atomic_store_64 i64:$val, XForm:$ptr), (STDX g8rc:$val, memrr:$ptr)>;
1957 let Predicates = [IsISA3_0, In64BitMode] in {
1958 def : Pat<(i64 (int_ppc_cmpeqb g8rc:$a, g8rc:$b)),
1959 (i64 (SETB8 (CMPEQB $a, $b)))>;
1960 def : Pat<(i64 (int_ppc_setb g8rc:$a, g8rc:$b)),
1961 (i64 (SETB8 (CMPD $a, $b)))>;
1962 def : Pat<(i64 (int_ppc_maddhd g8rc:$a, g8rc:$b, g8rc:$c)),
1963 (i64 (MADDHD $a, $b, $c))>;
1964 def : Pat<(i64 (int_ppc_maddhdu g8rc:$a, g8rc:$b, g8rc:$c)),
1965 (i64 (MADDHDU $a, $b, $c))>;
1966 def : Pat<(i64 (int_ppc_maddld g8rc:$a, g8rc:$b, g8rc:$c)),
1967 (i64 (MADDLD8 $a, $b, $c))>;
1970 let Predicates = [In64BitMode] in {
1971 def : Pat<(i64 (int_ppc_mulhd g8rc:$a, g8rc:$b)),
1972 (i64 (MULHD $a, $b))>;
1973 def : Pat<(i64 (int_ppc_mulhdu g8rc:$a, g8rc:$b)),
1974 (i64 (MULHDU $a, $b))>;
1975 def : Pat<(int_ppc_load8r ForceXForm:$ptr),
1976 (LDBRX ForceXForm:$ptr)>;
1977 def : Pat<(int_ppc_store8r g8rc:$a, ForceXForm:$ptr),
1978 (STDBRX g8rc:$a, ForceXForm:$ptr)>;
1981 def : Pat<(i64 (int_ppc_cmpb g8rc:$a, g8rc:$b)),
1982 (i64 (CMPB8 $a, $b))>;
1984 let Predicates = [IsISA3_0] in {
1985 // DARN (deliver random number)
1986 // L=0 for 32-bit, L=1 for conditioned random, L=2 for raw random
1987 def : Pat<(int_ppc_darn32), (EXTRACT_SUBREG (DARN 0), sub_32)>;
1988 def : Pat<(int_ppc_darn), (DARN 1)>;
1989 def : Pat<(int_ppc_darnraw), (DARN 2)>;
1991 class X_RA5_RB5<bits<6> opcode, bits<10> xo, string opc, RegisterOperand ty,
1992 InstrItinClass itin, list<dag> pattern>
1993 : X_L1_RS5_RS5<opcode, xo, (outs), (ins ty:$RA, ty:$RB, u1imm:$L),
1994 !strconcat(opc, " $RA, $RB"), itin, pattern>{
1998 class X_L1_RA5_RB5<bits<6> opcode, bits<10> xo, string opc, RegisterOperand ty,
1999 InstrItinClass itin, list<dag> pattern>
2000 : X_L1_RS5_RS5<opcode, xo, (outs), (ins ty:$RA, ty:$RB, u1imm:$L),
2001 !strconcat(opc, " $RA, $RB, $L"), itin, pattern>;
2003 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
2004 def CP_COPY8 : X_RA5_RB5<31, 774, "copy" , g8rc, IIC_LdStCOPY, []>;
2005 def CP_PASTE8_rec : X_L1_RA5_RB5<31, 902, "paste.", g8rc, IIC_LdStPASTE, []>,isRecordForm;
2008 // SLB Invalidate Entry Global
2009 def SLBIEG : XForm_26<31, 466, (outs), (ins gprc:$RST, gprc:$RB),
2010 "slbieg $RST, $RB", IIC_SprSLBIEG, []>;
2012 def SLBSYNC : XForm_0<31, 338, (outs), (ins), "slbsync", IIC_SprSLBSYNC, []>;
2016 def : Pat<(int_ppc_stdcx ForceXForm:$dst, g8rc:$A),
2017 (RLWINM (STDCX g8rc:$A, ForceXForm:$dst), 31, 31, 31)>;
2018 def : Pat<(PPCStoreCond ForceXForm:$dst, g8rc:$A, 8),
2019 (RLWINM (STDCX g8rc:$A, ForceXForm:$dst), 31, 31, 31)>;
2021 def : Pat<(i64 (int_ppc_mfspr timm:$SPR)),
2023 def : Pat<(int_ppc_mtspr timm:$SPR, g8rc:$RT),
2024 (MTSPR8 $SPR, $RT)>;