1 //===-- PPCInstrInfo.td - The PowerPC Instruction Set ------*- 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 subset of the 32-bit PowerPC instruction set, as used
10 // by the PowerPC instruction selector.
12 //===----------------------------------------------------------------------===//
14 include "PPCInstrFormats.td"
16 //===----------------------------------------------------------------------===//
17 // PowerPC specific type constraints.
19 def SDT_PPCstfiwx : SDTypeProfile<0, 2, [ // stfiwx
20 SDTCisVT<0, f64>, SDTCisPtrTy<1>
22 def SDT_PPClfiwx : SDTypeProfile<1, 1, [ // lfiw[az]x
23 SDTCisVT<0, f64>, SDTCisPtrTy<1>
25 def SDT_PPCLxsizx : SDTypeProfile<1, 2, [
26 SDTCisVT<0, f64>, SDTCisPtrTy<1>, SDTCisPtrTy<2>
28 def SDT_PPCstxsix : SDTypeProfile<0, 3, [
29 SDTCisVT<0, f64>, SDTCisPtrTy<1>, SDTCisPtrTy<2>
31 def SDT_PPCcv_fp_to_int : SDTypeProfile<1, 1, [
32 SDTCisFP<0>, SDTCisFP<1>
34 def SDT_PPCstore_scal_int_from_vsr : SDTypeProfile<0, 3, [
35 SDTCisVT<0, f64>, SDTCisPtrTy<1>, SDTCisPtrTy<2>
37 def SDT_PPCVexts : SDTypeProfile<1, 2, [
38 SDTCisVT<0, f64>, SDTCisVT<1, f64>, SDTCisPtrTy<2>
40 def SDT_PPCSExtVElems : SDTypeProfile<1, 1, [
41 SDTCisVec<0>, SDTCisVec<1>
44 def SDT_PPCCallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32>,
46 def SDT_PPCCallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
48 def SDT_PPCvperm : SDTypeProfile<1, 3, [
49 SDTCisVT<3, v16i8>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>
52 def SDT_PPCVecSplat : SDTypeProfile<1, 2, [ SDTCisVec<0>,
53 SDTCisVec<1>, SDTCisInt<2>
56 def SDT_PPCVecShift : SDTypeProfile<1, 3, [ SDTCisVec<0>,
57 SDTCisVec<1>, SDTCisVec<2>, SDTCisPtrTy<3>
60 def SDT_PPCVecInsert : SDTypeProfile<1, 3, [ SDTCisVec<0>,
61 SDTCisVec<1>, SDTCisVec<2>, SDTCisInt<3>
64 def SDT_PPCVecReverse: SDTypeProfile<1, 1, [ SDTCisVec<0>,
68 def SDT_PPCxxpermdi: SDTypeProfile<1, 3, [ SDTCisVec<0>,
69 SDTCisVec<1>, SDTCisVec<2>, SDTCisInt<3>
72 def SDT_PPCvcmp : SDTypeProfile<1, 3, [
73 SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisVT<3, i32>
76 def SDT_PPCcondbr : SDTypeProfile<0, 3, [
77 SDTCisVT<0, i32>, SDTCisVT<2, OtherVT>
80 def SDT_PPClbrx : SDTypeProfile<1, 2, [
81 SDTCisInt<0>, SDTCisPtrTy<1>, SDTCisVT<2, OtherVT>
83 def SDT_PPCstbrx : SDTypeProfile<0, 3, [
84 SDTCisInt<0>, SDTCisPtrTy<1>, SDTCisVT<2, OtherVT>
87 def SDT_PPCTC_ret : SDTypeProfile<0, 2, [
88 SDTCisPtrTy<0>, SDTCisVT<1, i32>
91 def tocentry32 : Operand<iPTR> {
92 let MIOperandInfo = (ops i32imm:$imm);
95 def SDT_PPCqvfperm : SDTypeProfile<1, 3, [
96 SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisVec<3>
98 def SDT_PPCqvgpci : SDTypeProfile<1, 1, [
99 SDTCisVec<0>, SDTCisInt<1>
101 def SDT_PPCqvaligni : SDTypeProfile<1, 3, [
102 SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisInt<3>
104 def SDT_PPCqvesplati : SDTypeProfile<1, 2, [
105 SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisInt<2>
108 def SDT_PPCqbflt : SDTypeProfile<1, 1, [
109 SDTCisVec<0>, SDTCisVec<1>
112 def SDT_PPCqvlfsb : SDTypeProfile<1, 1, [
113 SDTCisVec<0>, SDTCisPtrTy<1>
116 def SDT_PPCextswsli : SDTypeProfile<1, 2, [ // extswsli
117 SDTCisInt<0>, SDTCisInt<1>, SDTCisOpSmallerThanOp<1, 0>, SDTCisInt<2>
120 //===----------------------------------------------------------------------===//
121 // PowerPC specific DAG Nodes.
124 def PPCfre : SDNode<"PPCISD::FRE", SDTFPUnaryOp, []>;
125 def PPCfrsqrte: SDNode<"PPCISD::FRSQRTE", SDTFPUnaryOp, []>;
127 def PPCfcfid : SDNode<"PPCISD::FCFID", SDTFPUnaryOp, []>;
128 def PPCfcfidu : SDNode<"PPCISD::FCFIDU", SDTFPUnaryOp, []>;
129 def PPCfcfids : SDNode<"PPCISD::FCFIDS", SDTFPRoundOp, []>;
130 def PPCfcfidus: SDNode<"PPCISD::FCFIDUS", SDTFPRoundOp, []>;
131 def PPCfctidz : SDNode<"PPCISD::FCTIDZ", SDTFPUnaryOp, []>;
132 def PPCfctiwz : SDNode<"PPCISD::FCTIWZ", SDTFPUnaryOp, []>;
133 def PPCfctiduz: SDNode<"PPCISD::FCTIDUZ",SDTFPUnaryOp, []>;
134 def PPCfctiwuz: SDNode<"PPCISD::FCTIWUZ",SDTFPUnaryOp, []>;
136 def PPCcv_fp_to_uint_in_vsr:
137 SDNode<"PPCISD::FP_TO_UINT_IN_VSR", SDT_PPCcv_fp_to_int, []>;
138 def PPCcv_fp_to_sint_in_vsr:
139 SDNode<"PPCISD::FP_TO_SINT_IN_VSR", SDT_PPCcv_fp_to_int, []>;
140 def PPCstore_scal_int_from_vsr:
141 SDNode<"PPCISD::ST_VSR_SCAL_INT", SDT_PPCstore_scal_int_from_vsr,
142 [SDNPHasChain, SDNPMayStore]>;
143 def PPCstfiwx : SDNode<"PPCISD::STFIWX", SDT_PPCstfiwx,
144 [SDNPHasChain, SDNPMayStore]>;
145 def PPClfiwax : SDNode<"PPCISD::LFIWAX", SDT_PPClfiwx,
146 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
147 def PPClfiwzx : SDNode<"PPCISD::LFIWZX", SDT_PPClfiwx,
148 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
149 def PPClxsizx : SDNode<"PPCISD::LXSIZX", SDT_PPCLxsizx,
150 [SDNPHasChain, SDNPMayLoad]>;
151 def PPCstxsix : SDNode<"PPCISD::STXSIX", SDT_PPCstxsix,
152 [SDNPHasChain, SDNPMayStore]>;
153 def PPCVexts : SDNode<"PPCISD::VEXTS", SDT_PPCVexts, []>;
154 def PPCSExtVElems : SDNode<"PPCISD::SExtVElems", SDT_PPCSExtVElems, []>;
156 // Extract FPSCR (not modeled at the DAG level).
157 def PPCmffs : SDNode<"PPCISD::MFFS",
158 SDTypeProfile<1, 0, [SDTCisVT<0, f64>]>, []>;
160 // Perform FADD in round-to-zero mode.
161 def PPCfaddrtz: SDNode<"PPCISD::FADDRTZ", SDTFPBinOp, []>;
164 def PPCfsel : SDNode<"PPCISD::FSEL",
165 // Type constraint for fsel.
166 SDTypeProfile<1, 3, [SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>,
167 SDTCisFP<0>, SDTCisVT<1, f64>]>, []>;
169 def PPChi : SDNode<"PPCISD::Hi", SDTIntBinOp, []>;
170 def PPClo : SDNode<"PPCISD::Lo", SDTIntBinOp, []>;
171 def PPCtoc_entry: SDNode<"PPCISD::TOC_ENTRY", SDTIntBinOp,
172 [SDNPMayLoad, SDNPMemOperand]>;
173 def PPCvmaddfp : SDNode<"PPCISD::VMADDFP", SDTFPTernaryOp, []>;
174 def PPCvnmsubfp : SDNode<"PPCISD::VNMSUBFP", SDTFPTernaryOp, []>;
176 def PPCppc32GOT : SDNode<"PPCISD::PPC32_GOT", SDTIntLeaf, []>;
178 def PPCaddisGotTprelHA : SDNode<"PPCISD::ADDIS_GOT_TPREL_HA", SDTIntBinOp>;
179 def PPCldGotTprelL : SDNode<"PPCISD::LD_GOT_TPREL_L", SDTIntBinOp,
181 def PPCaddTls : SDNode<"PPCISD::ADD_TLS", SDTIntBinOp, []>;
182 def PPCaddisTlsgdHA : SDNode<"PPCISD::ADDIS_TLSGD_HA", SDTIntBinOp>;
183 def PPCaddiTlsgdL : SDNode<"PPCISD::ADDI_TLSGD_L", SDTIntBinOp>;
184 def PPCgetTlsAddr : SDNode<"PPCISD::GET_TLS_ADDR", SDTIntBinOp>;
185 def PPCaddiTlsgdLAddr : SDNode<"PPCISD::ADDI_TLSGD_L_ADDR",
186 SDTypeProfile<1, 3, [
187 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
188 SDTCisSameAs<0, 3>, SDTCisInt<0> ]>>;
189 def PPCaddisTlsldHA : SDNode<"PPCISD::ADDIS_TLSLD_HA", SDTIntBinOp>;
190 def PPCaddiTlsldL : SDNode<"PPCISD::ADDI_TLSLD_L", SDTIntBinOp>;
191 def PPCgetTlsldAddr : SDNode<"PPCISD::GET_TLSLD_ADDR", SDTIntBinOp>;
192 def PPCaddiTlsldLAddr : SDNode<"PPCISD::ADDI_TLSLD_L_ADDR",
193 SDTypeProfile<1, 3, [
194 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
195 SDTCisSameAs<0, 3>, SDTCisInt<0> ]>>;
196 def PPCaddisDtprelHA : SDNode<"PPCISD::ADDIS_DTPREL_HA", SDTIntBinOp>;
197 def PPCaddiDtprelL : SDNode<"PPCISD::ADDI_DTPREL_L", SDTIntBinOp>;
199 def PPCvperm : SDNode<"PPCISD::VPERM", SDT_PPCvperm, []>;
200 def PPCxxsplt : SDNode<"PPCISD::XXSPLT", SDT_PPCVecSplat, []>;
201 def PPCvecinsert : SDNode<"PPCISD::VECINSERT", SDT_PPCVecInsert, []>;
202 def PPCxxreverse : SDNode<"PPCISD::XXREVERSE", SDT_PPCVecReverse, []>;
203 def PPCxxpermdi : SDNode<"PPCISD::XXPERMDI", SDT_PPCxxpermdi, []>;
204 def PPCvecshl : SDNode<"PPCISD::VECSHL", SDT_PPCVecShift, []>;
206 def PPCqvfperm : SDNode<"PPCISD::QVFPERM", SDT_PPCqvfperm, []>;
207 def PPCqvgpci : SDNode<"PPCISD::QVGPCI", SDT_PPCqvgpci, []>;
208 def PPCqvaligni : SDNode<"PPCISD::QVALIGNI", SDT_PPCqvaligni, []>;
209 def PPCqvesplati : SDNode<"PPCISD::QVESPLATI", SDT_PPCqvesplati, []>;
211 def PPCqbflt : SDNode<"PPCISD::QBFLT", SDT_PPCqbflt, []>;
213 def PPCqvlfsb : SDNode<"PPCISD::QVLFSb", SDT_PPCqvlfsb,
214 [SDNPHasChain, SDNPMayLoad]>;
216 def PPCcmpb : SDNode<"PPCISD::CMPB", SDTIntBinOp, []>;
218 // These nodes represent the 32-bit PPC shifts that operate on 6-bit shift
219 // amounts. These nodes are generated by the multi-precision shift code.
220 def PPCsrl : SDNode<"PPCISD::SRL" , SDTIntShiftOp>;
221 def PPCsra : SDNode<"PPCISD::SRA" , SDTIntShiftOp>;
222 def PPCshl : SDNode<"PPCISD::SHL" , SDTIntShiftOp>;
224 def PPCextswsli : SDNode<"PPCISD::EXTSWSLI" , SDT_PPCextswsli>;
226 // Move 2 i64 values into a VSX register
227 def PPCbuild_fp128: SDNode<"PPCISD::BUILD_FP128",
229 [SDTCisFP<0>, SDTCisSameSizeAs<1,2>,
233 def PPCbuild_spe64: SDNode<"PPCISD::BUILD_SPE64",
235 [SDTCisVT<0, f64>, SDTCisVT<1,i32>,
239 def PPCextract_spe : SDNode<"PPCISD::EXTRACT_SPE",
241 [SDTCisVT<0, i32>, SDTCisVT<1, f64>,
245 // These are target-independent nodes, but have target-specific formats.
246 def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_PPCCallSeqStart,
247 [SDNPHasChain, SDNPOutGlue]>;
248 def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_PPCCallSeqEnd,
249 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
251 def SDT_PPCCall : SDTypeProfile<0, -1, [SDTCisInt<0>]>;
252 def PPCcall : SDNode<"PPCISD::CALL", SDT_PPCCall,
253 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
255 def PPCcall_nop : SDNode<"PPCISD::CALL_NOP", SDT_PPCCall,
256 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
258 def PPCmtctr : SDNode<"PPCISD::MTCTR", SDT_PPCCall,
259 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
260 def PPCbctrl : SDNode<"PPCISD::BCTRL", SDTNone,
261 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
263 def PPCbctrl_load_toc : SDNode<"PPCISD::BCTRL_LOAD_TOC",
264 SDTypeProfile<0, 1, []>,
265 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
268 def retflag : SDNode<"PPCISD::RET_FLAG", SDTNone,
269 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
271 def PPCtc_return : SDNode<"PPCISD::TC_RETURN", SDT_PPCTC_ret,
272 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
274 def PPCeh_sjlj_setjmp : SDNode<"PPCISD::EH_SJLJ_SETJMP",
275 SDTypeProfile<1, 1, [SDTCisInt<0>,
277 [SDNPHasChain, SDNPSideEffect]>;
278 def PPCeh_sjlj_longjmp : SDNode<"PPCISD::EH_SJLJ_LONGJMP",
279 SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>,
280 [SDNPHasChain, SDNPSideEffect]>;
282 def SDT_PPCsc : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
283 def PPCsc : SDNode<"PPCISD::SC", SDT_PPCsc,
284 [SDNPHasChain, SDNPSideEffect]>;
286 def PPCclrbhrb : SDNode<"PPCISD::CLRBHRB", SDTNone,
287 [SDNPHasChain, SDNPSideEffect]>;
288 def PPCmfbhrbe : SDNode<"PPCISD::MFBHRBE", SDTIntBinOp, [SDNPHasChain]>;
289 def PPCrfebb : SDNode<"PPCISD::RFEBB", SDT_PPCsc,
290 [SDNPHasChain, SDNPSideEffect]>;
292 def PPCvcmp : SDNode<"PPCISD::VCMP" , SDT_PPCvcmp, []>;
293 def PPCvcmp_o : SDNode<"PPCISD::VCMPo", SDT_PPCvcmp, [SDNPOutGlue]>;
295 def PPCcondbranch : SDNode<"PPCISD::COND_BRANCH", SDT_PPCcondbr,
296 [SDNPHasChain, SDNPOptInGlue]>;
298 // PPC-specific atomic operations.
299 def PPCatomicCmpSwap_8 :
300 SDNode<"PPCISD::ATOMIC_CMP_SWAP_8", SDTAtomic3,
301 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
302 def PPCatomicCmpSwap_16 :
303 SDNode<"PPCISD::ATOMIC_CMP_SWAP_16", SDTAtomic3,
304 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
305 def PPClbrx : SDNode<"PPCISD::LBRX", SDT_PPClbrx,
306 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
307 def PPCstbrx : SDNode<"PPCISD::STBRX", SDT_PPCstbrx,
308 [SDNPHasChain, SDNPMayStore]>;
310 // Instructions to set/unset CR bit 6 for SVR4 vararg calls
311 def PPCcr6set : SDNode<"PPCISD::CR6SET", SDTNone,
312 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
313 def PPCcr6unset : SDNode<"PPCISD::CR6UNSET", SDTNone,
314 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
316 // Instructions to support dynamic alloca.
317 def SDTDynOp : SDTypeProfile<1, 2, []>;
318 def SDTDynAreaOp : SDTypeProfile<1, 1, []>;
319 def PPCdynalloc : SDNode<"PPCISD::DYNALLOC", SDTDynOp, [SDNPHasChain]>;
320 def PPCdynareaoffset : SDNode<"PPCISD::DYNAREAOFFSET", SDTDynAreaOp, [SDNPHasChain]>;
322 //===----------------------------------------------------------------------===//
323 // PowerPC specific transformation functions and pattern fragments.
326 def SHL32 : SDNodeXForm<imm, [{
327 // Transformation function: 31 - imm
328 return getI32Imm(31 - N->getZExtValue(), SDLoc(N));
331 def SRL32 : SDNodeXForm<imm, [{
332 // Transformation function: 32 - imm
333 return N->getZExtValue() ? getI32Imm(32 - N->getZExtValue(), SDLoc(N))
334 : getI32Imm(0, SDLoc(N));
337 def LO16 : SDNodeXForm<imm, [{
338 // Transformation function: get the low 16 bits.
339 return getI32Imm((unsigned short)N->getZExtValue(), SDLoc(N));
342 def HI16 : SDNodeXForm<imm, [{
343 // Transformation function: shift the immediate value down into the low bits.
344 return getI32Imm((unsigned)N->getZExtValue() >> 16, SDLoc(N));
347 def HA16 : SDNodeXForm<imm, [{
348 // Transformation function: shift the immediate value down into the low bits.
349 long Val = N->getZExtValue();
350 return getI32Imm((Val - (signed short)Val) >> 16, SDLoc(N));
352 def MB : SDNodeXForm<imm, [{
353 // Transformation function: get the start bit of a mask
355 (void)isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
356 return getI32Imm(mb, SDLoc(N));
359 def ME : SDNodeXForm<imm, [{
360 // Transformation function: get the end bit of a mask
362 (void)isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
363 return getI32Imm(me, SDLoc(N));
365 def maskimm32 : PatLeaf<(imm), [{
366 // maskImm predicate - True if immediate is a run of ones.
368 if (N->getValueType(0) == MVT::i32)
369 return isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
374 def imm32SExt16 : Operand<i32>, ImmLeaf<i32, [{
375 // imm32SExt16 predicate - True if the i32 immediate fits in a 16-bit
376 // sign extended field. Used by instructions like 'addi'.
377 return (int32_t)Imm == (short)Imm;
379 def imm64SExt16 : Operand<i64>, ImmLeaf<i64, [{
380 // imm64SExt16 predicate - True if the i64 immediate fits in a 16-bit
381 // sign extended field. Used by instructions like 'addi'.
382 return (int64_t)Imm == (short)Imm;
384 def immZExt16 : PatLeaf<(imm), [{
385 // immZExt16 predicate - True if the immediate fits in a 16-bit zero extended
386 // field. Used by instructions like 'ori'.
387 return (uint64_t)N->getZExtValue() == (unsigned short)N->getZExtValue();
389 def immNonAllOneAnyExt8 : ImmLeaf<i32, [{
390 return (isInt<8>(Imm) && (Imm != -1)) || (isUInt<8>(Imm) && (Imm != 0xFF));
392 def immSExt5NonZero : ImmLeaf<i32, [{ return Imm && isInt<5>(Imm); }]>;
394 // imm16Shifted* - These match immediates where the low 16-bits are zero. There
395 // are two forms: imm16ShiftedSExt and imm16ShiftedZExt. These two forms are
396 // identical in 32-bit mode, but in 64-bit mode, they return true if the
397 // immediate fits into a sign/zero extended 32-bit immediate (with the low bits
399 def imm16ShiftedZExt : PatLeaf<(imm), [{
400 // imm16ShiftedZExt predicate - True if only bits in the top 16-bits of the
401 // immediate are set. Used by instructions like 'xoris'.
402 return (N->getZExtValue() & ~uint64_t(0xFFFF0000)) == 0;
405 def imm16ShiftedSExt : PatLeaf<(imm), [{
406 // imm16ShiftedSExt predicate - True if only bits in the top 16-bits of the
407 // immediate are set. Used by instructions like 'addis'. Identical to
408 // imm16ShiftedZExt in 32-bit mode.
409 if (N->getZExtValue() & 0xFFFF) return false;
410 if (N->getValueType(0) == MVT::i32)
412 // For 64-bit, make sure it is sext right.
413 return N->getZExtValue() == (uint64_t)(int)N->getZExtValue();
416 def imm64ZExt32 : Operand<i64>, ImmLeaf<i64, [{
417 // imm64ZExt32 predicate - True if the i64 immediate fits in a 32-bit
418 // zero extended field.
419 return isUInt<32>(Imm);
422 // Some r+i load/store instructions (such as LD, STD, LDU, etc.) that require
423 // restricted memrix (4-aligned) constants are alignment sensitive. If these
424 // offsets are hidden behind TOC entries than the values of the lower-order
425 // bits cannot be checked directly. As a result, we need to also incorporate
426 // an alignment check into the relevant patterns.
428 def aligned4load : PatFrag<(ops node:$ptr), (load node:$ptr), [{
429 return cast<LoadSDNode>(N)->getAlignment() >= 4;
431 def aligned4store : PatFrag<(ops node:$val, node:$ptr),
432 (store node:$val, node:$ptr), [{
433 return cast<StoreSDNode>(N)->getAlignment() >= 4;
435 def aligned4sextloadi32 : PatFrag<(ops node:$ptr), (sextloadi32 node:$ptr), [{
436 return cast<LoadSDNode>(N)->getAlignment() >= 4;
438 def aligned4pre_store : PatFrag<
439 (ops node:$val, node:$base, node:$offset),
440 (pre_store node:$val, node:$base, node:$offset), [{
441 return cast<StoreSDNode>(N)->getAlignment() >= 4;
444 def unaligned4load : PatFrag<(ops node:$ptr), (load node:$ptr), [{
445 return cast<LoadSDNode>(N)->getAlignment() < 4;
447 def unaligned4store : PatFrag<(ops node:$val, node:$ptr),
448 (store node:$val, node:$ptr), [{
449 return cast<StoreSDNode>(N)->getAlignment() < 4;
451 def unaligned4sextloadi32 : PatFrag<(ops node:$ptr), (sextloadi32 node:$ptr), [{
452 return cast<LoadSDNode>(N)->getAlignment() < 4;
455 // This is a somewhat weaker condition than actually checking for 16-byte
456 // alignment. It is simply checking that the displacement can be represented
457 // as an immediate that is a multiple of 16 (i.e. the requirements for DQ-Form
459 def quadwOffsetLoad : PatFrag<(ops node:$ptr), (load node:$ptr), [{
460 return isOffsetMultipleOf(N, 16);
462 def quadwOffsetStore : PatFrag<(ops node:$val, node:$ptr),
463 (store node:$val, node:$ptr), [{
464 return isOffsetMultipleOf(N, 16);
466 def nonQuadwOffsetLoad : PatFrag<(ops node:$ptr), (load node:$ptr), [{
467 return !isOffsetMultipleOf(N, 16);
469 def nonQuadwOffsetStore : PatFrag<(ops node:$val, node:$ptr),
470 (store node:$val, node:$ptr), [{
471 return !isOffsetMultipleOf(N, 16);
474 // PatFrag for binary operation whose operands are both non-constant
475 class BinOpWithoutSImm16Operand<SDNode opcode> :
476 PatFrag<(ops node:$left, node:$right), (opcode node:$left, node:$right), [{
478 return !isIntS16Immediate(N->getOperand(0), Imm)
479 && !isIntS16Immediate(N->getOperand(1), Imm);
482 def add_without_simm16 : BinOpWithoutSImm16Operand<add>;
483 def mul_without_simm16 : BinOpWithoutSImm16Operand<mul>;
485 //===----------------------------------------------------------------------===//
486 // PowerPC Flag Definitions.
488 class isPPC64 { bit PPC64 = 1; }
489 class isDOT { bit RC = 1; }
491 class RegConstraint<string C> {
492 string Constraints = C;
494 class NoEncode<string E> {
495 string DisableEncoding = E;
499 //===----------------------------------------------------------------------===//
500 // PowerPC Operand Definitions.
502 // In the default PowerPC assembler syntax, registers are specified simply
503 // by number, so they cannot be distinguished from immediate values (without
504 // looking at the opcode). This means that the default operand matching logic
505 // for the asm parser does not work, and we need to specify custom matchers.
506 // Since those can only be specified with RegisterOperand classes and not
507 // directly on the RegisterClass, all instructions patterns used by the asm
508 // parser need to use a RegisterOperand (instead of a RegisterClass) for
509 // all their register operands.
510 // For this purpose, we define one RegisterOperand for each RegisterClass,
511 // using the same name as the class, just in lower case.
513 def PPCRegGPRCAsmOperand : AsmOperandClass {
514 let Name = "RegGPRC"; let PredicateMethod = "isRegNumber";
516 def gprc : RegisterOperand<GPRC> {
517 let ParserMatchClass = PPCRegGPRCAsmOperand;
519 def PPCRegG8RCAsmOperand : AsmOperandClass {
520 let Name = "RegG8RC"; let PredicateMethod = "isRegNumber";
522 def g8rc : RegisterOperand<G8RC> {
523 let ParserMatchClass = PPCRegG8RCAsmOperand;
525 def PPCRegGPRCNoR0AsmOperand : AsmOperandClass {
526 let Name = "RegGPRCNoR0"; let PredicateMethod = "isRegNumber";
528 def gprc_nor0 : RegisterOperand<GPRC_NOR0> {
529 let ParserMatchClass = PPCRegGPRCNoR0AsmOperand;
531 def PPCRegG8RCNoX0AsmOperand : AsmOperandClass {
532 let Name = "RegG8RCNoX0"; let PredicateMethod = "isRegNumber";
534 def g8rc_nox0 : RegisterOperand<G8RC_NOX0> {
535 let ParserMatchClass = PPCRegG8RCNoX0AsmOperand;
537 def PPCRegF8RCAsmOperand : AsmOperandClass {
538 let Name = "RegF8RC"; let PredicateMethod = "isRegNumber";
540 def f8rc : RegisterOperand<F8RC> {
541 let ParserMatchClass = PPCRegF8RCAsmOperand;
543 def PPCRegF4RCAsmOperand : AsmOperandClass {
544 let Name = "RegF4RC"; let PredicateMethod = "isRegNumber";
546 def f4rc : RegisterOperand<F4RC> {
547 let ParserMatchClass = PPCRegF4RCAsmOperand;
549 def PPCRegVRRCAsmOperand : AsmOperandClass {
550 let Name = "RegVRRC"; let PredicateMethod = "isRegNumber";
552 def vrrc : RegisterOperand<VRRC> {
553 let ParserMatchClass = PPCRegVRRCAsmOperand;
555 def PPCRegVFRCAsmOperand : AsmOperandClass {
556 let Name = "RegVFRC"; let PredicateMethod = "isRegNumber";
558 def vfrc : RegisterOperand<VFRC> {
559 let ParserMatchClass = PPCRegVFRCAsmOperand;
561 def PPCRegCRBITRCAsmOperand : AsmOperandClass {
562 let Name = "RegCRBITRC"; let PredicateMethod = "isCRBitNumber";
564 def crbitrc : RegisterOperand<CRBITRC> {
565 let ParserMatchClass = PPCRegCRBITRCAsmOperand;
567 def PPCRegCRRCAsmOperand : AsmOperandClass {
568 let Name = "RegCRRC"; let PredicateMethod = "isCCRegNumber";
570 def crrc : RegisterOperand<CRRC> {
571 let ParserMatchClass = PPCRegCRRCAsmOperand;
573 def PPCRegSPERCAsmOperand : AsmOperandClass {
574 let Name = "RegSPERC"; let PredicateMethod = "isRegNumber";
576 def sperc : RegisterOperand<SPERC> {
577 let ParserMatchClass = PPCRegSPERCAsmOperand;
579 def PPCRegSPE4RCAsmOperand : AsmOperandClass {
580 let Name = "RegSPE4RC"; let PredicateMethod = "isRegNumber";
582 def spe4rc : RegisterOperand<SPE4RC> {
583 let ParserMatchClass = PPCRegSPE4RCAsmOperand;
586 def PPCU1ImmAsmOperand : AsmOperandClass {
587 let Name = "U1Imm"; let PredicateMethod = "isU1Imm";
588 let RenderMethod = "addImmOperands";
590 def u1imm : Operand<i32> {
591 let PrintMethod = "printU1ImmOperand";
592 let ParserMatchClass = PPCU1ImmAsmOperand;
595 def PPCU2ImmAsmOperand : AsmOperandClass {
596 let Name = "U2Imm"; let PredicateMethod = "isU2Imm";
597 let RenderMethod = "addImmOperands";
599 def u2imm : Operand<i32> {
600 let PrintMethod = "printU2ImmOperand";
601 let ParserMatchClass = PPCU2ImmAsmOperand;
604 def PPCATBitsAsHintAsmOperand : AsmOperandClass {
605 let Name = "ATBitsAsHint"; let PredicateMethod = "isATBitsAsHint";
606 let RenderMethod = "addImmOperands"; // Irrelevant, predicate always fails.
608 def atimm : Operand<i32> {
609 let PrintMethod = "printATBitsAsHint";
610 let ParserMatchClass = PPCATBitsAsHintAsmOperand;
613 def PPCU3ImmAsmOperand : AsmOperandClass {
614 let Name = "U3Imm"; let PredicateMethod = "isU3Imm";
615 let RenderMethod = "addImmOperands";
617 def u3imm : Operand<i32> {
618 let PrintMethod = "printU3ImmOperand";
619 let ParserMatchClass = PPCU3ImmAsmOperand;
622 def PPCU4ImmAsmOperand : AsmOperandClass {
623 let Name = "U4Imm"; let PredicateMethod = "isU4Imm";
624 let RenderMethod = "addImmOperands";
626 def u4imm : Operand<i32> {
627 let PrintMethod = "printU4ImmOperand";
628 let ParserMatchClass = PPCU4ImmAsmOperand;
630 def PPCS5ImmAsmOperand : AsmOperandClass {
631 let Name = "S5Imm"; let PredicateMethod = "isS5Imm";
632 let RenderMethod = "addImmOperands";
634 def s5imm : Operand<i32> {
635 let PrintMethod = "printS5ImmOperand";
636 let ParserMatchClass = PPCS5ImmAsmOperand;
637 let DecoderMethod = "decodeSImmOperand<5>";
639 def PPCU5ImmAsmOperand : AsmOperandClass {
640 let Name = "U5Imm"; let PredicateMethod = "isU5Imm";
641 let RenderMethod = "addImmOperands";
643 def u5imm : Operand<i32> {
644 let PrintMethod = "printU5ImmOperand";
645 let ParserMatchClass = PPCU5ImmAsmOperand;
646 let DecoderMethod = "decodeUImmOperand<5>";
648 def PPCU6ImmAsmOperand : AsmOperandClass {
649 let Name = "U6Imm"; let PredicateMethod = "isU6Imm";
650 let RenderMethod = "addImmOperands";
652 def u6imm : Operand<i32> {
653 let PrintMethod = "printU6ImmOperand";
654 let ParserMatchClass = PPCU6ImmAsmOperand;
655 let DecoderMethod = "decodeUImmOperand<6>";
657 def PPCU7ImmAsmOperand : AsmOperandClass {
658 let Name = "U7Imm"; let PredicateMethod = "isU7Imm";
659 let RenderMethod = "addImmOperands";
661 def u7imm : Operand<i32> {
662 let PrintMethod = "printU7ImmOperand";
663 let ParserMatchClass = PPCU7ImmAsmOperand;
664 let DecoderMethod = "decodeUImmOperand<7>";
666 def PPCU8ImmAsmOperand : AsmOperandClass {
667 let Name = "U8Imm"; let PredicateMethod = "isU8Imm";
668 let RenderMethod = "addImmOperands";
670 def u8imm : Operand<i32> {
671 let PrintMethod = "printU8ImmOperand";
672 let ParserMatchClass = PPCU8ImmAsmOperand;
673 let DecoderMethod = "decodeUImmOperand<8>";
675 def PPCU10ImmAsmOperand : AsmOperandClass {
676 let Name = "U10Imm"; let PredicateMethod = "isU10Imm";
677 let RenderMethod = "addImmOperands";
679 def u10imm : Operand<i32> {
680 let PrintMethod = "printU10ImmOperand";
681 let ParserMatchClass = PPCU10ImmAsmOperand;
682 let DecoderMethod = "decodeUImmOperand<10>";
684 def PPCU12ImmAsmOperand : AsmOperandClass {
685 let Name = "U12Imm"; let PredicateMethod = "isU12Imm";
686 let RenderMethod = "addImmOperands";
688 def u12imm : Operand<i32> {
689 let PrintMethod = "printU12ImmOperand";
690 let ParserMatchClass = PPCU12ImmAsmOperand;
691 let DecoderMethod = "decodeUImmOperand<12>";
693 def PPCS16ImmAsmOperand : AsmOperandClass {
694 let Name = "S16Imm"; let PredicateMethod = "isS16Imm";
695 let RenderMethod = "addS16ImmOperands";
697 def s16imm : Operand<i32> {
698 let PrintMethod = "printS16ImmOperand";
699 let EncoderMethod = "getImm16Encoding";
700 let ParserMatchClass = PPCS16ImmAsmOperand;
701 let DecoderMethod = "decodeSImmOperand<16>";
703 def PPCU16ImmAsmOperand : AsmOperandClass {
704 let Name = "U16Imm"; let PredicateMethod = "isU16Imm";
705 let RenderMethod = "addU16ImmOperands";
707 def u16imm : Operand<i32> {
708 let PrintMethod = "printU16ImmOperand";
709 let EncoderMethod = "getImm16Encoding";
710 let ParserMatchClass = PPCU16ImmAsmOperand;
711 let DecoderMethod = "decodeUImmOperand<16>";
713 def PPCS17ImmAsmOperand : AsmOperandClass {
714 let Name = "S17Imm"; let PredicateMethod = "isS17Imm";
715 let RenderMethod = "addS16ImmOperands";
717 def s17imm : Operand<i32> {
718 // This operand type is used for addis/lis to allow the assembler parser
719 // to accept immediates in the range -65536..65535 for compatibility with
720 // the GNU assembler. The operand is treated as 16-bit otherwise.
721 let PrintMethod = "printS16ImmOperand";
722 let EncoderMethod = "getImm16Encoding";
723 let ParserMatchClass = PPCS17ImmAsmOperand;
724 let DecoderMethod = "decodeSImmOperand<16>";
727 def fpimm0 : PatLeaf<(fpimm), [{ return N->isExactlyValue(+0.0); }]>;
729 def PPCDirectBrAsmOperand : AsmOperandClass {
730 let Name = "DirectBr"; let PredicateMethod = "isDirectBr";
731 let RenderMethod = "addBranchTargetOperands";
733 def directbrtarget : Operand<OtherVT> {
734 let PrintMethod = "printBranchOperand";
735 let EncoderMethod = "getDirectBrEncoding";
736 let ParserMatchClass = PPCDirectBrAsmOperand;
738 def absdirectbrtarget : Operand<OtherVT> {
739 let PrintMethod = "printAbsBranchOperand";
740 let EncoderMethod = "getAbsDirectBrEncoding";
741 let ParserMatchClass = PPCDirectBrAsmOperand;
743 def PPCCondBrAsmOperand : AsmOperandClass {
744 let Name = "CondBr"; let PredicateMethod = "isCondBr";
745 let RenderMethod = "addBranchTargetOperands";
747 def condbrtarget : Operand<OtherVT> {
748 let PrintMethod = "printBranchOperand";
749 let EncoderMethod = "getCondBrEncoding";
750 let ParserMatchClass = PPCCondBrAsmOperand;
752 def abscondbrtarget : Operand<OtherVT> {
753 let PrintMethod = "printAbsBranchOperand";
754 let EncoderMethod = "getAbsCondBrEncoding";
755 let ParserMatchClass = PPCCondBrAsmOperand;
757 def calltarget : Operand<iPTR> {
758 let PrintMethod = "printBranchOperand";
759 let EncoderMethod = "getDirectBrEncoding";
760 let DecoderMethod = "DecodePCRel24BranchTarget";
761 let ParserMatchClass = PPCDirectBrAsmOperand;
762 let OperandType = "OPERAND_PCREL";
764 def abscalltarget : Operand<iPTR> {
765 let PrintMethod = "printAbsBranchOperand";
766 let EncoderMethod = "getAbsDirectBrEncoding";
767 let ParserMatchClass = PPCDirectBrAsmOperand;
769 def PPCCRBitMaskOperand : AsmOperandClass {
770 let Name = "CRBitMask"; let PredicateMethod = "isCRBitMask";
772 def crbitm: Operand<i8> {
773 let PrintMethod = "printcrbitm";
774 let EncoderMethod = "get_crbitm_encoding";
775 let DecoderMethod = "decodeCRBitMOperand";
776 let ParserMatchClass = PPCCRBitMaskOperand;
779 // A version of ptr_rc which excludes R0 (or X0 in 64-bit mode).
780 def PPCRegGxRCNoR0Operand : AsmOperandClass {
781 let Name = "RegGxRCNoR0"; let PredicateMethod = "isRegNumber";
783 def ptr_rc_nor0 : Operand<iPTR>, PointerLikeRegClass<1> {
784 let ParserMatchClass = PPCRegGxRCNoR0Operand;
786 // A version of ptr_rc usable with the asm parser.
787 def PPCRegGxRCOperand : AsmOperandClass {
788 let Name = "RegGxRC"; let PredicateMethod = "isRegNumber";
790 def ptr_rc_idx : Operand<iPTR>, PointerLikeRegClass<0> {
791 let ParserMatchClass = PPCRegGxRCOperand;
794 def PPCDispRIOperand : AsmOperandClass {
795 let Name = "DispRI"; let PredicateMethod = "isS16Imm";
796 let RenderMethod = "addS16ImmOperands";
798 def dispRI : Operand<iPTR> {
799 let ParserMatchClass = PPCDispRIOperand;
801 def PPCDispRIXOperand : AsmOperandClass {
802 let Name = "DispRIX"; let PredicateMethod = "isS16ImmX4";
803 let RenderMethod = "addImmOperands";
805 def dispRIX : Operand<iPTR> {
806 let ParserMatchClass = PPCDispRIXOperand;
808 def PPCDispRIX16Operand : AsmOperandClass {
809 let Name = "DispRIX16"; let PredicateMethod = "isS16ImmX16";
810 let RenderMethod = "addImmOperands";
812 def dispRIX16 : Operand<iPTR> {
813 let ParserMatchClass = PPCDispRIX16Operand;
815 def PPCDispSPE8Operand : AsmOperandClass {
816 let Name = "DispSPE8"; let PredicateMethod = "isU8ImmX8";
817 let RenderMethod = "addImmOperands";
819 def dispSPE8 : Operand<iPTR> {
820 let ParserMatchClass = PPCDispSPE8Operand;
822 def PPCDispSPE4Operand : AsmOperandClass {
823 let Name = "DispSPE4"; let PredicateMethod = "isU7ImmX4";
824 let RenderMethod = "addImmOperands";
826 def dispSPE4 : Operand<iPTR> {
827 let ParserMatchClass = PPCDispSPE4Operand;
829 def PPCDispSPE2Operand : AsmOperandClass {
830 let Name = "DispSPE2"; let PredicateMethod = "isU6ImmX2";
831 let RenderMethod = "addImmOperands";
833 def dispSPE2 : Operand<iPTR> {
834 let ParserMatchClass = PPCDispSPE2Operand;
837 def memri : Operand<iPTR> {
838 let PrintMethod = "printMemRegImm";
839 let MIOperandInfo = (ops dispRI:$imm, ptr_rc_nor0:$reg);
840 let EncoderMethod = "getMemRIEncoding";
841 let DecoderMethod = "decodeMemRIOperands";
843 def memrr : Operand<iPTR> {
844 let PrintMethod = "printMemRegReg";
845 let MIOperandInfo = (ops ptr_rc_nor0:$ptrreg, ptr_rc_idx:$offreg);
847 def memrix : Operand<iPTR> { // memri where the imm is 4-aligned.
848 let PrintMethod = "printMemRegImm";
849 let MIOperandInfo = (ops dispRIX:$imm, ptr_rc_nor0:$reg);
850 let EncoderMethod = "getMemRIXEncoding";
851 let DecoderMethod = "decodeMemRIXOperands";
853 def memrix16 : Operand<iPTR> { // memri, imm is 16-aligned, 12-bit, Inst{16:27}
854 let PrintMethod = "printMemRegImm";
855 let MIOperandInfo = (ops dispRIX16:$imm, ptr_rc_nor0:$reg);
856 let EncoderMethod = "getMemRIX16Encoding";
857 let DecoderMethod = "decodeMemRIX16Operands";
859 def spe8dis : Operand<iPTR> { // SPE displacement where the imm is 8-aligned.
860 let PrintMethod = "printMemRegImm";
861 let MIOperandInfo = (ops dispSPE8:$imm, ptr_rc_nor0:$reg);
862 let EncoderMethod = "getSPE8DisEncoding";
863 let DecoderMethod = "decodeSPE8Operands";
865 def spe4dis : Operand<iPTR> { // SPE displacement where the imm is 4-aligned.
866 let PrintMethod = "printMemRegImm";
867 let MIOperandInfo = (ops dispSPE4:$imm, ptr_rc_nor0:$reg);
868 let EncoderMethod = "getSPE4DisEncoding";
869 let DecoderMethod = "decodeSPE4Operands";
871 def spe2dis : Operand<iPTR> { // SPE displacement where the imm is 2-aligned.
872 let PrintMethod = "printMemRegImm";
873 let MIOperandInfo = (ops dispSPE2:$imm, ptr_rc_nor0:$reg);
874 let EncoderMethod = "getSPE2DisEncoding";
875 let DecoderMethod = "decodeSPE2Operands";
878 // A single-register address. This is used with the SjLj
879 // pseudo-instructions which tranlates to LD/LWZ. These instructions requires
880 // G8RC_NOX0 registers.
881 def memr : Operand<iPTR> {
882 let MIOperandInfo = (ops ptr_rc_nor0:$ptrreg);
884 def PPCTLSRegOperand : AsmOperandClass {
885 let Name = "TLSReg"; let PredicateMethod = "isTLSReg";
886 let RenderMethod = "addTLSRegOperands";
888 def tlsreg32 : Operand<i32> {
889 let EncoderMethod = "getTLSRegEncoding";
890 let ParserMatchClass = PPCTLSRegOperand;
892 def tlsgd32 : Operand<i32> {}
893 def tlscall32 : Operand<i32> {
894 let PrintMethod = "printTLSCall";
895 let MIOperandInfo = (ops calltarget:$func, tlsgd32:$sym);
896 let EncoderMethod = "getTLSCallEncoding";
899 // PowerPC Predicate operand.
900 def pred : Operand<OtherVT> {
901 let PrintMethod = "printPredicateOperand";
902 let MIOperandInfo = (ops i32imm:$bibo, crrc:$reg);
905 // Define PowerPC specific addressing mode.
908 def iaddr : ComplexPattern<iPTR, 2, "SelectAddrImm", [], []>; // "stb"
910 def iaddrX4 : ComplexPattern<iPTR, 2, "SelectAddrImmX4", [], []>; // "std"
912 def iaddrX16 : ComplexPattern<iPTR, 2, "SelectAddrImmX16", [], []>; // "stxv"
914 // Below forms are all x-form addressing mode, use three different ones so we
915 // can make a accurate check for x-form instructions in ISEL.
916 // x-form addressing mode whose associated diplacement form is D.
917 def xaddr : ComplexPattern<iPTR, 2, "SelectAddrIdx", [], []>; // "stbx"
918 // x-form addressing mode whose associated diplacement form is DS.
919 def xaddrX4 : ComplexPattern<iPTR, 2, "SelectAddrIdxX4", [], []>; // "stdx"
920 // x-form addressing mode whose associated diplacement form is DQ.
921 def xaddrX16 : ComplexPattern<iPTR, 2, "SelectAddrIdxX16", [], []>; // "stxvx"
923 def xoaddr : ComplexPattern<iPTR, 2, "SelectAddrIdxOnly",[], []>;
925 // The address in a single register. This is used with the SjLj
926 // pseudo-instructions.
927 def addr : ComplexPattern<iPTR, 1, "SelectAddr",[], []>;
929 /// This is just the offset part of iaddr, used for preinc.
930 def iaddroff : ComplexPattern<iPTR, 1, "SelectAddrImmOffs", [], []>;
932 //===----------------------------------------------------------------------===//
933 // PowerPC Instruction Predicate Definitions.
934 def In32BitMode : Predicate<"!PPCSubTarget->isPPC64()">;
935 def In64BitMode : Predicate<"PPCSubTarget->isPPC64()">;
936 def IsBookE : Predicate<"PPCSubTarget->isBookE()">;
937 def IsNotBookE : Predicate<"!PPCSubTarget->isBookE()">;
938 def HasOnlyMSYNC : Predicate<"PPCSubTarget->hasOnlyMSYNC()">;
939 def HasSYNC : Predicate<"!PPCSubTarget->hasOnlyMSYNC()">;
940 def IsPPC4xx : Predicate<"PPCSubTarget->isPPC4xx()">;
941 def IsPPC6xx : Predicate<"PPCSubTarget->isPPC6xx()">;
942 def IsE500 : Predicate<"PPCSubTarget->isE500()">;
943 def HasSPE : Predicate<"PPCSubTarget->hasSPE()">;
944 def HasICBT : Predicate<"PPCSubTarget->hasICBT()">;
945 def HasPartwordAtomics : Predicate<"PPCSubTarget->hasPartwordAtomics()">;
946 def NoNaNsFPMath : Predicate<"TM.Options.NoNaNsFPMath">;
947 def NaNsFPMath : Predicate<"!TM.Options.NoNaNsFPMath">;
948 def HasBPERMD : Predicate<"PPCSubTarget->hasBPERMD()">;
949 def HasExtDiv : Predicate<"PPCSubTarget->hasExtDiv()">;
950 def IsISA3_0 : Predicate<"PPCSubTarget->isISA3_0()">;
951 def HasFPU : Predicate<"PPCSubTarget->hasFPU()">;
953 //===----------------------------------------------------------------------===//
954 // PowerPC Multiclass Definitions.
956 multiclass XForm_6r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
957 string asmbase, string asmstr, InstrItinClass itin,
959 let BaseName = asmbase in {
960 def NAME : XForm_6<opcode, xo, OOL, IOL,
961 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
962 pattern>, RecFormRel;
964 def o : XForm_6<opcode, xo, OOL, IOL,
965 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
966 []>, isDOT, RecFormRel;
970 multiclass XForm_6rc<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
971 string asmbase, string asmstr, InstrItinClass itin,
973 let BaseName = asmbase in {
974 let Defs = [CARRY] in
975 def NAME : XForm_6<opcode, xo, OOL, IOL,
976 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
977 pattern>, RecFormRel;
978 let Defs = [CARRY, CR0] in
979 def o : XForm_6<opcode, xo, OOL, IOL,
980 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
981 []>, isDOT, RecFormRel;
985 multiclass XForm_10rc<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
986 string asmbase, string asmstr, InstrItinClass itin,
988 let BaseName = asmbase in {
989 let Defs = [CARRY] in
990 def NAME : XForm_10<opcode, xo, OOL, IOL,
991 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
992 pattern>, RecFormRel;
993 let Defs = [CARRY, CR0] in
994 def o : XForm_10<opcode, xo, OOL, IOL,
995 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
996 []>, isDOT, RecFormRel;
1000 multiclass XForm_11r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
1001 string asmbase, string asmstr, InstrItinClass itin,
1002 list<dag> pattern> {
1003 let BaseName = asmbase in {
1004 def NAME : XForm_11<opcode, xo, OOL, IOL,
1005 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1006 pattern>, RecFormRel;
1008 def o : XForm_11<opcode, xo, OOL, IOL,
1009 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1010 []>, isDOT, RecFormRel;
1014 multiclass XOForm_1r<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
1015 string asmbase, string asmstr, InstrItinClass itin,
1016 list<dag> pattern> {
1017 let BaseName = asmbase in {
1018 def NAME : XOForm_1<opcode, xo, oe, OOL, IOL,
1019 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1020 pattern>, RecFormRel;
1022 def o : XOForm_1<opcode, xo, oe, OOL, IOL,
1023 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1024 []>, isDOT, RecFormRel;
1028 // Multiclass for instructions for which the non record form is not cracked
1029 // and the record form is cracked (i.e. divw, mullw, etc.)
1030 multiclass XOForm_1rcr<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
1031 string asmbase, string asmstr, InstrItinClass itin,
1032 list<dag> pattern> {
1033 let BaseName = asmbase in {
1034 def NAME : XOForm_1<opcode, xo, oe, OOL, IOL,
1035 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1036 pattern>, RecFormRel;
1038 def o : XOForm_1<opcode, xo, oe, OOL, IOL,
1039 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1040 []>, isDOT, RecFormRel, PPC970_DGroup_First,
1041 PPC970_DGroup_Cracked;
1045 multiclass XOForm_1rc<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
1046 string asmbase, string asmstr, InstrItinClass itin,
1047 list<dag> pattern> {
1048 let BaseName = asmbase in {
1049 let Defs = [CARRY] in
1050 def NAME : XOForm_1<opcode, xo, oe, OOL, IOL,
1051 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1052 pattern>, RecFormRel;
1053 let Defs = [CARRY, CR0] in
1054 def o : XOForm_1<opcode, xo, oe, OOL, IOL,
1055 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1056 []>, isDOT, RecFormRel;
1060 multiclass XOForm_3r<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
1061 string asmbase, string asmstr, InstrItinClass itin,
1062 list<dag> pattern> {
1063 let BaseName = asmbase in {
1064 def NAME : XOForm_3<opcode, xo, oe, OOL, IOL,
1065 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1066 pattern>, RecFormRel;
1068 def o : XOForm_3<opcode, xo, oe, OOL, IOL,
1069 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1070 []>, isDOT, RecFormRel;
1074 multiclass XOForm_3rc<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
1075 string asmbase, string asmstr, InstrItinClass itin,
1076 list<dag> pattern> {
1077 let BaseName = asmbase in {
1078 let Defs = [CARRY] in
1079 def NAME : XOForm_3<opcode, xo, oe, OOL, IOL,
1080 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1081 pattern>, RecFormRel;
1082 let Defs = [CARRY, CR0] in
1083 def o : XOForm_3<opcode, xo, oe, OOL, IOL,
1084 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1085 []>, isDOT, RecFormRel;
1089 multiclass MForm_2r<bits<6> opcode, dag OOL, dag IOL,
1090 string asmbase, string asmstr, InstrItinClass itin,
1091 list<dag> pattern> {
1092 let BaseName = asmbase in {
1093 def NAME : MForm_2<opcode, OOL, IOL,
1094 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1095 pattern>, RecFormRel;
1097 def o : MForm_2<opcode, OOL, IOL,
1098 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1099 []>, isDOT, RecFormRel;
1103 multiclass MDForm_1r<bits<6> opcode, bits<3> xo, dag OOL, dag IOL,
1104 string asmbase, string asmstr, InstrItinClass itin,
1105 list<dag> pattern> {
1106 let BaseName = asmbase in {
1107 def NAME : MDForm_1<opcode, xo, OOL, IOL,
1108 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1109 pattern>, RecFormRel;
1111 def o : MDForm_1<opcode, xo, OOL, IOL,
1112 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1113 []>, isDOT, RecFormRel;
1117 multiclass MDSForm_1r<bits<6> opcode, bits<4> xo, dag OOL, dag IOL,
1118 string asmbase, string asmstr, InstrItinClass itin,
1119 list<dag> pattern> {
1120 let BaseName = asmbase in {
1121 def NAME : MDSForm_1<opcode, xo, OOL, IOL,
1122 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1123 pattern>, RecFormRel;
1125 def o : MDSForm_1<opcode, xo, OOL, IOL,
1126 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1127 []>, isDOT, RecFormRel;
1131 multiclass XSForm_1rc<bits<6> opcode, bits<9> xo, dag OOL, dag IOL,
1132 string asmbase, string asmstr, InstrItinClass itin,
1133 list<dag> pattern> {
1134 let BaseName = asmbase in {
1135 let Defs = [CARRY] in
1136 def NAME : XSForm_1<opcode, xo, OOL, IOL,
1137 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1138 pattern>, RecFormRel;
1139 let Defs = [CARRY, CR0] in
1140 def o : XSForm_1<opcode, xo, OOL, IOL,
1141 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1142 []>, isDOT, RecFormRel;
1146 multiclass XSForm_1r<bits<6> opcode, bits<9> xo, dag OOL, dag IOL,
1147 string asmbase, string asmstr, InstrItinClass itin,
1148 list<dag> pattern> {
1149 let BaseName = asmbase in {
1150 def NAME : XSForm_1<opcode, xo, OOL, IOL,
1151 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1152 pattern>, RecFormRel;
1154 def o : XSForm_1<opcode, xo, OOL, IOL,
1155 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1156 []>, isDOT, RecFormRel;
1160 multiclass XForm_26r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
1161 string asmbase, string asmstr, InstrItinClass itin,
1162 list<dag> pattern> {
1163 let BaseName = asmbase in {
1164 def NAME : XForm_26<opcode, xo, OOL, IOL,
1165 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1166 pattern>, RecFormRel;
1168 def o : XForm_26<opcode, xo, OOL, IOL,
1169 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1170 []>, isDOT, RecFormRel;
1174 multiclass XForm_28r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
1175 string asmbase, string asmstr, InstrItinClass itin,
1176 list<dag> pattern> {
1177 let BaseName = asmbase in {
1178 def NAME : XForm_28<opcode, xo, OOL, IOL,
1179 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1180 pattern>, RecFormRel;
1182 def o : XForm_28<opcode, xo, OOL, IOL,
1183 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1184 []>, isDOT, RecFormRel;
1188 multiclass AForm_1r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL,
1189 string asmbase, string asmstr, InstrItinClass itin,
1190 list<dag> pattern> {
1191 let BaseName = asmbase in {
1192 def NAME : AForm_1<opcode, xo, OOL, IOL,
1193 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1194 pattern>, RecFormRel;
1196 def o : AForm_1<opcode, xo, OOL, IOL,
1197 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1198 []>, isDOT, RecFormRel;
1202 multiclass AForm_2r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL,
1203 string asmbase, string asmstr, InstrItinClass itin,
1204 list<dag> pattern> {
1205 let BaseName = asmbase in {
1206 def NAME : AForm_2<opcode, xo, OOL, IOL,
1207 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1208 pattern>, RecFormRel;
1210 def o : AForm_2<opcode, xo, OOL, IOL,
1211 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1212 []>, isDOT, RecFormRel;
1216 multiclass AForm_3r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL,
1217 string asmbase, string asmstr, InstrItinClass itin,
1218 list<dag> pattern> {
1219 let BaseName = asmbase in {
1220 def NAME : AForm_3<opcode, xo, OOL, IOL,
1221 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1222 pattern>, RecFormRel;
1224 def o : AForm_3<opcode, xo, OOL, IOL,
1225 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1226 []>, isDOT, RecFormRel;
1230 //===----------------------------------------------------------------------===//
1231 // PowerPC Instruction Definitions.
1233 // Pseudo instructions:
1235 let hasCtrlDep = 1 in {
1236 let Defs = [R1], Uses = [R1] in {
1237 def ADJCALLSTACKDOWN : PPCEmitTimePseudo<(outs), (ins u16imm:$amt1, u16imm:$amt2),
1238 "#ADJCALLSTACKDOWN $amt1 $amt2",
1239 [(callseq_start timm:$amt1, timm:$amt2)]>;
1240 def ADJCALLSTACKUP : PPCEmitTimePseudo<(outs), (ins u16imm:$amt1, u16imm:$amt2),
1241 "#ADJCALLSTACKUP $amt1 $amt2",
1242 [(callseq_end timm:$amt1, timm:$amt2)]>;
1245 def UPDATE_VRSAVE : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc:$rS),
1246 "UPDATE_VRSAVE $rD, $rS", []>;
1249 let Defs = [R1], Uses = [R1] in
1250 def DYNALLOC : PPCEmitTimePseudo<(outs gprc:$result), (ins gprc:$negsize, memri:$fpsi), "#DYNALLOC",
1252 (PPCdynalloc i32:$negsize, iaddr:$fpsi))]>;
1253 def DYNAREAOFFSET : PPCEmitTimePseudo<(outs i32imm:$result), (ins memri:$fpsi), "#DYNAREAOFFSET",
1254 [(set i32:$result, (PPCdynareaoffset iaddr:$fpsi))]>;
1256 // SELECT_CC_* - Used to implement the SELECT_CC DAG operation. Expanded after
1257 // instruction selection into a branch sequence.
1258 let PPC970_Single = 1 in {
1259 // Note that SELECT_CC_I4 and SELECT_CC_I8 use the no-r0 register classes
1260 // because either operand might become the first operand in an isel, and
1261 // that operand cannot be r0.
1262 def SELECT_CC_I4 : PPCCustomInserterPseudo<(outs gprc:$dst), (ins crrc:$cond,
1263 gprc_nor0:$T, gprc_nor0:$F,
1264 i32imm:$BROPC), "#SELECT_CC_I4",
1266 def SELECT_CC_I8 : PPCCustomInserterPseudo<(outs g8rc:$dst), (ins crrc:$cond,
1267 g8rc_nox0:$T, g8rc_nox0:$F,
1268 i32imm:$BROPC), "#SELECT_CC_I8",
1270 def SELECT_CC_F4 : PPCCustomInserterPseudo<(outs f4rc:$dst), (ins crrc:$cond, f4rc:$T, f4rc:$F,
1271 i32imm:$BROPC), "#SELECT_CC_F4",
1273 def SELECT_CC_F8 : PPCCustomInserterPseudo<(outs f8rc:$dst), (ins crrc:$cond, f8rc:$T, f8rc:$F,
1274 i32imm:$BROPC), "#SELECT_CC_F8",
1276 def SELECT_CC_F16 : PPCCustomInserterPseudo<(outs vrrc:$dst), (ins crrc:$cond, vrrc:$T, vrrc:$F,
1277 i32imm:$BROPC), "#SELECT_CC_F16",
1279 def SELECT_CC_VRRC: PPCCustomInserterPseudo<(outs vrrc:$dst), (ins crrc:$cond, vrrc:$T, vrrc:$F,
1280 i32imm:$BROPC), "#SELECT_CC_VRRC",
1283 // SELECT_* pseudo instructions, like SELECT_CC_* but taking condition
1284 // register bit directly.
1285 def SELECT_I4 : PPCCustomInserterPseudo<(outs gprc:$dst), (ins crbitrc:$cond,
1286 gprc_nor0:$T, gprc_nor0:$F), "#SELECT_I4",
1287 [(set i32:$dst, (select i1:$cond, i32:$T, i32:$F))]>;
1288 def SELECT_I8 : PPCCustomInserterPseudo<(outs g8rc:$dst), (ins crbitrc:$cond,
1289 g8rc_nox0:$T, g8rc_nox0:$F), "#SELECT_I8",
1290 [(set i64:$dst, (select i1:$cond, i64:$T, i64:$F))]>;
1291 let Predicates = [HasFPU] in {
1292 def SELECT_F4 : PPCCustomInserterPseudo<(outs f4rc:$dst), (ins crbitrc:$cond,
1293 f4rc:$T, f4rc:$F), "#SELECT_F4",
1294 [(set f32:$dst, (select i1:$cond, f32:$T, f32:$F))]>;
1295 def SELECT_F8 : PPCCustomInserterPseudo<(outs f8rc:$dst), (ins crbitrc:$cond,
1296 f8rc:$T, f8rc:$F), "#SELECT_F8",
1297 [(set f64:$dst, (select i1:$cond, f64:$T, f64:$F))]>;
1298 def SELECT_F16 : PPCCustomInserterPseudo<(outs vrrc:$dst), (ins crbitrc:$cond,
1299 vrrc:$T, vrrc:$F), "#SELECT_F16",
1300 [(set f128:$dst, (select i1:$cond, f128:$T, f128:$F))]>;
1302 def SELECT_VRRC: PPCCustomInserterPseudo<(outs vrrc:$dst), (ins crbitrc:$cond,
1303 vrrc:$T, vrrc:$F), "#SELECT_VRRC",
1305 (select i1:$cond, v4i32:$T, v4i32:$F))]>;
1308 // SPILL_CR - Indicate that we're dumping the CR register, so we'll need to
1309 // scavenge a register for it.
1310 let mayStore = 1 in {
1311 def SPILL_CR : PPCEmitTimePseudo<(outs), (ins crrc:$cond, memri:$F),
1313 def SPILL_CRBIT : PPCEmitTimePseudo<(outs), (ins crbitrc:$cond, memri:$F),
1314 "#SPILL_CRBIT", []>;
1317 // RESTORE_CR - Indicate that we're restoring the CR register (previously
1318 // spilled), so we'll need to scavenge a register for it.
1319 let mayLoad = 1 in {
1320 def RESTORE_CR : PPCEmitTimePseudo<(outs crrc:$cond), (ins memri:$F),
1322 def RESTORE_CRBIT : PPCEmitTimePseudo<(outs crbitrc:$cond), (ins memri:$F),
1323 "#RESTORE_CRBIT", []>;
1326 let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7 in {
1327 let isReturn = 1, Uses = [LR, RM] in
1328 def BLR : XLForm_2_ext<19, 16, 20, 0, 0, (outs), (ins), "blr", IIC_BrB,
1329 [(retflag)]>, Requires<[In32BitMode]>;
1330 let isBranch = 1, isIndirectBranch = 1, Uses = [CTR] in {
1331 def BCTR : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
1334 let isCodeGenOnly = 1 in {
1335 def BCCCTR : XLForm_2_br<19, 528, 0, (outs), (ins pred:$cond),
1336 "b${cond:cc}ctr${cond:pm} ${cond:reg}", IIC_BrB,
1339 def BCCTR : XLForm_2_br2<19, 528, 12, 0, (outs), (ins crbitrc:$bi),
1340 "bcctr 12, $bi, 0", IIC_BrB, []>;
1341 def BCCTRn : XLForm_2_br2<19, 528, 4, 0, (outs), (ins crbitrc:$bi),
1342 "bcctr 4, $bi, 0", IIC_BrB, []>;
1347 // Set the float rounding mode.
1348 let Uses = [RM], Defs = [RM] in {
1349 def SETRNDi : PPCCustomInserterPseudo<(outs f8rc:$FRT), (ins u2imm:$RND),
1350 "#SETRNDi", [(set f64:$FRT, (int_ppc_setrnd (i32 imm:$RND)))]>;
1352 def SETRND : PPCCustomInserterPseudo<(outs f8rc:$FRT), (ins gprc:$in),
1353 "#SETRND", [(set f64:$FRT, (int_ppc_setrnd gprc :$in))]>;
1357 def MovePCtoLR : PPCEmitTimePseudo<(outs), (ins), "#MovePCtoLR", []>,
1360 def MoveGOTtoLR : PPCEmitTimePseudo<(outs), (ins), "#MoveGOTtoLR", []>,
1363 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7 in {
1364 let isBarrier = 1 in {
1365 def B : IForm<18, 0, 0, (outs), (ins directbrtarget:$dst),
1368 def BA : IForm<18, 1, 0, (outs), (ins absdirectbrtarget:$dst),
1369 "ba $dst", IIC_BrB, []>;
1372 // BCC represents an arbitrary conditional branch on a predicate.
1373 // FIXME: should be able to write a pattern for PPCcondbranch, but can't use
1374 // a two-value operand where a dag node expects two operands. :(
1375 let isCodeGenOnly = 1 in {
1376 class BCC_class : BForm<16, 0, 0, (outs), (ins pred:$cond, condbrtarget:$dst),
1377 "b${cond:cc}${cond:pm} ${cond:reg}, $dst"
1378 /*[(PPCcondbranch crrc:$crS, imm:$opc, bb:$dst)]*/>;
1379 def BCC : BCC_class;
1381 // The same as BCC, except that it's not a terminator. Used for introducing
1382 // control flow dependency without creating new blocks.
1383 let isTerminator = 0 in def CTRL_DEP : BCC_class;
1385 def BCCA : BForm<16, 1, 0, (outs), (ins pred:$cond, abscondbrtarget:$dst),
1386 "b${cond:cc}a${cond:pm} ${cond:reg}, $dst">;
1388 let isReturn = 1, Uses = [LR, RM] in
1389 def BCCLR : XLForm_2_br<19, 16, 0, (outs), (ins pred:$cond),
1390 "b${cond:cc}lr${cond:pm} ${cond:reg}", IIC_BrB, []>;
1393 let isCodeGenOnly = 1 in {
1394 let Pattern = [(brcond i1:$bi, bb:$dst)] in
1395 def BC : BForm_4<16, 12, 0, 0, (outs), (ins crbitrc:$bi, condbrtarget:$dst),
1396 "bc 12, $bi, $dst">;
1398 let Pattern = [(brcond (not i1:$bi), bb:$dst)] in
1399 def BCn : BForm_4<16, 4, 0, 0, (outs), (ins crbitrc:$bi, condbrtarget:$dst),
1402 let isReturn = 1, Uses = [LR, RM] in
1403 def BCLR : XLForm_2_br2<19, 16, 12, 0, (outs), (ins crbitrc:$bi),
1404 "bclr 12, $bi, 0", IIC_BrB, []>;
1405 def BCLRn : XLForm_2_br2<19, 16, 4, 0, (outs), (ins crbitrc:$bi),
1406 "bclr 4, $bi, 0", IIC_BrB, []>;
1409 let isReturn = 1, Defs = [CTR], Uses = [CTR, LR, RM] in {
1410 def BDZLR : XLForm_2_ext<19, 16, 18, 0, 0, (outs), (ins),
1411 "bdzlr", IIC_BrB, []>;
1412 def BDNZLR : XLForm_2_ext<19, 16, 16, 0, 0, (outs), (ins),
1413 "bdnzlr", IIC_BrB, []>;
1414 def BDZLRp : XLForm_2_ext<19, 16, 27, 0, 0, (outs), (ins),
1415 "bdzlr+", IIC_BrB, []>;
1416 def BDNZLRp: XLForm_2_ext<19, 16, 25, 0, 0, (outs), (ins),
1417 "bdnzlr+", IIC_BrB, []>;
1418 def BDZLRm : XLForm_2_ext<19, 16, 26, 0, 0, (outs), (ins),
1419 "bdzlr-", IIC_BrB, []>;
1420 def BDNZLRm: XLForm_2_ext<19, 16, 24, 0, 0, (outs), (ins),
1421 "bdnzlr-", IIC_BrB, []>;
1424 let Defs = [CTR], Uses = [CTR] in {
1425 def BDZ : BForm_1<16, 18, 0, 0, (outs), (ins condbrtarget:$dst),
1427 def BDNZ : BForm_1<16, 16, 0, 0, (outs), (ins condbrtarget:$dst),
1429 def BDZA : BForm_1<16, 18, 1, 0, (outs), (ins abscondbrtarget:$dst),
1431 def BDNZA : BForm_1<16, 16, 1, 0, (outs), (ins abscondbrtarget:$dst),
1433 def BDZp : BForm_1<16, 27, 0, 0, (outs), (ins condbrtarget:$dst),
1435 def BDNZp: BForm_1<16, 25, 0, 0, (outs), (ins condbrtarget:$dst),
1437 def BDZAp : BForm_1<16, 27, 1, 0, (outs), (ins abscondbrtarget:$dst),
1439 def BDNZAp: BForm_1<16, 25, 1, 0, (outs), (ins abscondbrtarget:$dst),
1441 def BDZm : BForm_1<16, 26, 0, 0, (outs), (ins condbrtarget:$dst),
1443 def BDNZm: BForm_1<16, 24, 0, 0, (outs), (ins condbrtarget:$dst),
1445 def BDZAm : BForm_1<16, 26, 1, 0, (outs), (ins abscondbrtarget:$dst),
1447 def BDNZAm: BForm_1<16, 24, 1, 0, (outs), (ins abscondbrtarget:$dst),
1452 // The unconditional BCL used by the SjLj setjmp code.
1453 let isCall = 1, hasCtrlDep = 1, isCodeGenOnly = 1, PPC970_Unit = 7 in {
1454 let Defs = [LR], Uses = [RM] in {
1455 def BCLalways : BForm_2<16, 20, 31, 0, 1, (outs), (ins condbrtarget:$dst),
1456 "bcl 20, 31, $dst">;
1460 let isCall = 1, PPC970_Unit = 7, Defs = [LR] in {
1461 // Convenient aliases for call instructions
1462 let Uses = [RM] in {
1463 def BL : IForm<18, 0, 1, (outs), (ins calltarget:$func),
1464 "bl $func", IIC_BrB, []>; // See Pat patterns below.
1465 def BLA : IForm<18, 1, 1, (outs), (ins abscalltarget:$func),
1466 "bla $func", IIC_BrB, [(PPCcall (i32 imm:$func))]>;
1468 let isCodeGenOnly = 1 in {
1469 def BL_TLS : IForm<18, 0, 1, (outs), (ins tlscall32:$func),
1470 "bl $func", IIC_BrB, []>;
1471 def BCCL : BForm<16, 0, 1, (outs), (ins pred:$cond, condbrtarget:$dst),
1472 "b${cond:cc}l${cond:pm} ${cond:reg}, $dst">;
1473 def BCCLA : BForm<16, 1, 1, (outs), (ins pred:$cond, abscondbrtarget:$dst),
1474 "b${cond:cc}la${cond:pm} ${cond:reg}, $dst">;
1476 def BCL : BForm_4<16, 12, 0, 1, (outs),
1477 (ins crbitrc:$bi, condbrtarget:$dst),
1478 "bcl 12, $bi, $dst">;
1479 def BCLn : BForm_4<16, 4, 0, 1, (outs),
1480 (ins crbitrc:$bi, condbrtarget:$dst),
1481 "bcl 4, $bi, $dst">;
1482 def BL_NOP : IForm_and_DForm_4_zero<18, 0, 1, 24,
1483 (outs), (ins calltarget:$func),
1484 "bl $func\n\tnop", IIC_BrB, []>;
1487 let Uses = [CTR, RM] in {
1488 def BCTRL : XLForm_2_ext<19, 528, 20, 0, 1, (outs), (ins),
1489 "bctrl", IIC_BrB, [(PPCbctrl)]>,
1490 Requires<[In32BitMode]>;
1492 let isCodeGenOnly = 1 in {
1493 def BCCCTRL : XLForm_2_br<19, 528, 1, (outs), (ins pred:$cond),
1494 "b${cond:cc}ctrl${cond:pm} ${cond:reg}", IIC_BrB,
1497 def BCCTRL : XLForm_2_br2<19, 528, 12, 1, (outs), (ins crbitrc:$bi),
1498 "bcctrl 12, $bi, 0", IIC_BrB, []>;
1499 def BCCTRLn : XLForm_2_br2<19, 528, 4, 1, (outs), (ins crbitrc:$bi),
1500 "bcctrl 4, $bi, 0", IIC_BrB, []>;
1503 let Uses = [LR, RM] in {
1504 def BLRL : XLForm_2_ext<19, 16, 20, 0, 1, (outs), (ins),
1505 "blrl", IIC_BrB, []>;
1507 let isCodeGenOnly = 1 in {
1508 def BCCLRL : XLForm_2_br<19, 16, 1, (outs), (ins pred:$cond),
1509 "b${cond:cc}lrl${cond:pm} ${cond:reg}", IIC_BrB,
1512 def BCLRL : XLForm_2_br2<19, 16, 12, 1, (outs), (ins crbitrc:$bi),
1513 "bclrl 12, $bi, 0", IIC_BrB, []>;
1514 def BCLRLn : XLForm_2_br2<19, 16, 4, 1, (outs), (ins crbitrc:$bi),
1515 "bclrl 4, $bi, 0", IIC_BrB, []>;
1518 let Defs = [CTR], Uses = [CTR, RM] in {
1519 def BDZL : BForm_1<16, 18, 0, 1, (outs), (ins condbrtarget:$dst),
1521 def BDNZL : BForm_1<16, 16, 0, 1, (outs), (ins condbrtarget:$dst),
1523 def BDZLA : BForm_1<16, 18, 1, 1, (outs), (ins abscondbrtarget:$dst),
1525 def BDNZLA : BForm_1<16, 16, 1, 1, (outs), (ins abscondbrtarget:$dst),
1527 def BDZLp : BForm_1<16, 27, 0, 1, (outs), (ins condbrtarget:$dst),
1529 def BDNZLp: BForm_1<16, 25, 0, 1, (outs), (ins condbrtarget:$dst),
1531 def BDZLAp : BForm_1<16, 27, 1, 1, (outs), (ins abscondbrtarget:$dst),
1533 def BDNZLAp: BForm_1<16, 25, 1, 1, (outs), (ins abscondbrtarget:$dst),
1535 def BDZLm : BForm_1<16, 26, 0, 1, (outs), (ins condbrtarget:$dst),
1537 def BDNZLm: BForm_1<16, 24, 0, 1, (outs), (ins condbrtarget:$dst),
1539 def BDZLAm : BForm_1<16, 26, 1, 1, (outs), (ins abscondbrtarget:$dst),
1541 def BDNZLAm: BForm_1<16, 24, 1, 1, (outs), (ins abscondbrtarget:$dst),
1544 let Defs = [CTR], Uses = [CTR, LR, RM] in {
1545 def BDZLRL : XLForm_2_ext<19, 16, 18, 0, 1, (outs), (ins),
1546 "bdzlrl", IIC_BrB, []>;
1547 def BDNZLRL : XLForm_2_ext<19, 16, 16, 0, 1, (outs), (ins),
1548 "bdnzlrl", IIC_BrB, []>;
1549 def BDZLRLp : XLForm_2_ext<19, 16, 27, 0, 1, (outs), (ins),
1550 "bdzlrl+", IIC_BrB, []>;
1551 def BDNZLRLp: XLForm_2_ext<19, 16, 25, 0, 1, (outs), (ins),
1552 "bdnzlrl+", IIC_BrB, []>;
1553 def BDZLRLm : XLForm_2_ext<19, 16, 26, 0, 1, (outs), (ins),
1554 "bdzlrl-", IIC_BrB, []>;
1555 def BDNZLRLm: XLForm_2_ext<19, 16, 24, 0, 1, (outs), (ins),
1556 "bdnzlrl-", IIC_BrB, []>;
1560 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
1561 def TCRETURNdi :PPCEmitTimePseudo< (outs),
1562 (ins calltarget:$dst, i32imm:$offset),
1563 "#TC_RETURNd $dst $offset",
1567 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
1568 def TCRETURNai :PPCEmitTimePseudo<(outs), (ins abscalltarget:$func, i32imm:$offset),
1569 "#TC_RETURNa $func $offset",
1570 [(PPCtc_return (i32 imm:$func), imm:$offset)]>;
1572 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
1573 def TCRETURNri : PPCEmitTimePseudo<(outs), (ins CTRRC:$dst, i32imm:$offset),
1574 "#TC_RETURNr $dst $offset",
1578 let isCodeGenOnly = 1 in {
1580 let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, isBranch = 1,
1581 isIndirectBranch = 1, isCall = 1, isReturn = 1, Uses = [CTR, RM] in
1582 def TAILBCTR : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
1583 []>, Requires<[In32BitMode]>;
1585 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
1586 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
1587 def TAILB : IForm<18, 0, 0, (outs), (ins calltarget:$dst),
1591 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
1592 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
1593 def TAILBA : IForm<18, 0, 0, (outs), (ins abscalltarget:$dst),
1599 // While longjmp is a control-flow barrier (fallthrough isn't allowed), setjmp
1601 let hasSideEffects = 1 in {
1603 def EH_SjLj_SetJmp32 : PPCCustomInserterPseudo<(outs gprc:$dst), (ins memr:$buf),
1604 "#EH_SJLJ_SETJMP32",
1605 [(set i32:$dst, (PPCeh_sjlj_setjmp addr:$buf))]>,
1606 Requires<[In32BitMode]>;
1609 let hasSideEffects = 1, isBarrier = 1 in {
1610 let isTerminator = 1 in
1611 def EH_SjLj_LongJmp32 : PPCCustomInserterPseudo<(outs), (ins memr:$buf),
1612 "#EH_SJLJ_LONGJMP32",
1613 [(PPCeh_sjlj_longjmp addr:$buf)]>,
1614 Requires<[In32BitMode]>;
1617 // This pseudo is never removed from the function, as it serves as
1618 // a terminator. Size is set to 0 to prevent the builtin assembler
1619 // from emitting it.
1620 let isBranch = 1, isTerminator = 1, Size = 0 in {
1621 def EH_SjLj_Setup : PPCEmitTimePseudo<(outs), (ins directbrtarget:$dst),
1622 "#EH_SjLj_Setup\t$dst", []>;
1626 let PPC970_Unit = 7 in {
1627 def SC : SCForm<17, 1, (outs), (ins i32imm:$lev),
1628 "sc $lev", IIC_BrB, [(PPCsc (i32 imm:$lev))]>;
1631 // Branch history rolling buffer.
1632 def CLRBHRB : XForm_0<31, 430, (outs), (ins), "clrbhrb", IIC_BrB,
1634 PPC970_DGroup_Single;
1635 // The $dmy argument used for MFBHRBE is not needed; however, including
1636 // it avoids automatic generation of PPCFastISel::fastEmit_i(), which
1637 // interferes with necessary special handling (see PPCFastISel.cpp).
1638 def MFBHRBE : XFXForm_3p<31, 302, (outs gprc:$rD),
1639 (ins u10imm:$imm, u10imm:$dmy),
1640 "mfbhrbe $rD, $imm", IIC_BrB,
1642 (PPCmfbhrbe imm:$imm, imm:$dmy))]>,
1643 PPC970_DGroup_First;
1645 def RFEBB : XLForm_S<19, 146, (outs), (ins u1imm:$imm), "rfebb $imm",
1646 IIC_BrB, [(PPCrfebb (i32 imm:$imm))]>,
1647 PPC970_DGroup_Single;
1649 // DCB* instructions.
1650 def DCBA : DCB_Form<758, 0, (outs), (ins memrr:$dst), "dcba $dst",
1651 IIC_LdStDCBF, [(int_ppc_dcba xoaddr:$dst)]>,
1652 PPC970_DGroup_Single;
1653 def DCBI : DCB_Form<470, 0, (outs), (ins memrr:$dst), "dcbi $dst",
1654 IIC_LdStDCBF, [(int_ppc_dcbi xoaddr:$dst)]>,
1655 PPC970_DGroup_Single;
1656 def DCBST : DCB_Form<54, 0, (outs), (ins memrr:$dst), "dcbst $dst",
1657 IIC_LdStDCBF, [(int_ppc_dcbst xoaddr:$dst)]>,
1658 PPC970_DGroup_Single;
1659 def DCBZ : DCB_Form<1014, 0, (outs), (ins memrr:$dst), "dcbz $dst",
1660 IIC_LdStDCBF, [(int_ppc_dcbz xoaddr:$dst)]>,
1661 PPC970_DGroup_Single;
1662 def DCBZL : DCB_Form<1014, 1, (outs), (ins memrr:$dst), "dcbzl $dst",
1663 IIC_LdStDCBF, [(int_ppc_dcbzl xoaddr:$dst)]>,
1664 PPC970_DGroup_Single;
1666 def DCBF : DCB_Form_hint<86, (outs), (ins u5imm:$TH, memrr:$dst),
1667 "dcbf $dst, $TH", IIC_LdStDCBF, []>,
1668 PPC970_DGroup_Single;
1670 let hasSideEffects = 0, mayLoad = 1, mayStore = 1 in {
1671 def DCBT : DCB_Form_hint<278, (outs), (ins u5imm:$TH, memrr:$dst),
1672 "dcbt $dst, $TH", IIC_LdStDCBF, []>,
1673 PPC970_DGroup_Single;
1674 def DCBTST : DCB_Form_hint<246, (outs), (ins u5imm:$TH, memrr:$dst),
1675 "dcbtst $dst, $TH", IIC_LdStDCBF, []>,
1676 PPC970_DGroup_Single;
1677 } // hasSideEffects = 0
1679 def ICBLC : XForm_icbt<31, 230, (outs), (ins u4imm:$CT, memrr:$src),
1680 "icblc $CT, $src", IIC_LdStStore>, Requires<[HasICBT]>;
1681 def ICBLQ : XForm_icbt<31, 198, (outs), (ins u4imm:$CT, memrr:$src),
1682 "icblq. $CT, $src", IIC_LdStLoad>, Requires<[HasICBT]>;
1683 def ICBT : XForm_icbt<31, 22, (outs), (ins u4imm:$CT, memrr:$src),
1684 "icbt $CT, $src", IIC_LdStLoad>, Requires<[HasICBT]>;
1685 def ICBTLS : XForm_icbt<31, 486, (outs), (ins u4imm:$CT, memrr:$src),
1686 "icbtls $CT, $src", IIC_LdStLoad>, Requires<[HasICBT]>;
1688 def : Pat<(int_ppc_dcbt xoaddr:$dst),
1689 (DCBT 0, xoaddr:$dst)>;
1690 def : Pat<(int_ppc_dcbtst xoaddr:$dst),
1691 (DCBTST 0, xoaddr:$dst)>;
1692 def : Pat<(int_ppc_dcbf xoaddr:$dst),
1693 (DCBF 0, xoaddr:$dst)>;
1695 def : Pat<(prefetch xoaddr:$dst, (i32 0), imm, (i32 1)),
1696 (DCBT 0, xoaddr:$dst)>; // data prefetch for loads
1697 def : Pat<(prefetch xoaddr:$dst, (i32 1), imm, (i32 1)),
1698 (DCBTST 0, xoaddr:$dst)>; // data prefetch for stores
1699 def : Pat<(prefetch xoaddr:$dst, (i32 0), imm, (i32 0)),
1700 (ICBT 0, xoaddr:$dst)>, Requires<[HasICBT]>; // inst prefetch (for read)
1702 // Atomic operations
1703 // FIXME: some of these might be used with constant operands. This will result
1704 // in constant materialization instructions that may be redundant. We currently
1705 // clean this up in PPCMIPeephole with calls to
1706 // PPCInstrInfo::convertToImmediateForm() but we should probably not emit them
1707 // in the first place.
1708 let Defs = [CR0] in {
1709 def ATOMIC_LOAD_ADD_I8 : PPCCustomInserterPseudo<
1710 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I8",
1711 [(set i32:$dst, (atomic_load_add_8 xoaddr:$ptr, i32:$incr))]>;
1712 def ATOMIC_LOAD_SUB_I8 : PPCCustomInserterPseudo<
1713 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I8",
1714 [(set i32:$dst, (atomic_load_sub_8 xoaddr:$ptr, i32:$incr))]>;
1715 def ATOMIC_LOAD_AND_I8 : PPCCustomInserterPseudo<
1716 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I8",
1717 [(set i32:$dst, (atomic_load_and_8 xoaddr:$ptr, i32:$incr))]>;
1718 def ATOMIC_LOAD_OR_I8 : PPCCustomInserterPseudo<
1719 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I8",
1720 [(set i32:$dst, (atomic_load_or_8 xoaddr:$ptr, i32:$incr))]>;
1721 def ATOMIC_LOAD_XOR_I8 : PPCCustomInserterPseudo<
1722 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "ATOMIC_LOAD_XOR_I8",
1723 [(set i32:$dst, (atomic_load_xor_8 xoaddr:$ptr, i32:$incr))]>;
1724 def ATOMIC_LOAD_NAND_I8 : PPCCustomInserterPseudo<
1725 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I8",
1726 [(set i32:$dst, (atomic_load_nand_8 xoaddr:$ptr, i32:$incr))]>;
1727 def ATOMIC_LOAD_MIN_I8 : PPCCustomInserterPseudo<
1728 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MIN_I8",
1729 [(set i32:$dst, (atomic_load_min_8 xoaddr:$ptr, i32:$incr))]>;
1730 def ATOMIC_LOAD_MAX_I8 : PPCCustomInserterPseudo<
1731 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MAX_I8",
1732 [(set i32:$dst, (atomic_load_max_8 xoaddr:$ptr, i32:$incr))]>;
1733 def ATOMIC_LOAD_UMIN_I8 : PPCCustomInserterPseudo<
1734 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMIN_I8",
1735 [(set i32:$dst, (atomic_load_umin_8 xoaddr:$ptr, i32:$incr))]>;
1736 def ATOMIC_LOAD_UMAX_I8 : PPCCustomInserterPseudo<
1737 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMAX_I8",
1738 [(set i32:$dst, (atomic_load_umax_8 xoaddr:$ptr, i32:$incr))]>;
1739 def ATOMIC_LOAD_ADD_I16 : PPCCustomInserterPseudo<
1740 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I16",
1741 [(set i32:$dst, (atomic_load_add_16 xoaddr:$ptr, i32:$incr))]>;
1742 def ATOMIC_LOAD_SUB_I16 : PPCCustomInserterPseudo<
1743 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I16",
1744 [(set i32:$dst, (atomic_load_sub_16 xoaddr:$ptr, i32:$incr))]>;
1745 def ATOMIC_LOAD_AND_I16 : PPCCustomInserterPseudo<
1746 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I16",
1747 [(set i32:$dst, (atomic_load_and_16 xoaddr:$ptr, i32:$incr))]>;
1748 def ATOMIC_LOAD_OR_I16 : PPCCustomInserterPseudo<
1749 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I16",
1750 [(set i32:$dst, (atomic_load_or_16 xoaddr:$ptr, i32:$incr))]>;
1751 def ATOMIC_LOAD_XOR_I16 : PPCCustomInserterPseudo<
1752 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_XOR_I16",
1753 [(set i32:$dst, (atomic_load_xor_16 xoaddr:$ptr, i32:$incr))]>;
1754 def ATOMIC_LOAD_NAND_I16 : PPCCustomInserterPseudo<
1755 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I16",
1756 [(set i32:$dst, (atomic_load_nand_16 xoaddr:$ptr, i32:$incr))]>;
1757 def ATOMIC_LOAD_MIN_I16 : PPCCustomInserterPseudo<
1758 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MIN_I16",
1759 [(set i32:$dst, (atomic_load_min_16 xoaddr:$ptr, i32:$incr))]>;
1760 def ATOMIC_LOAD_MAX_I16 : PPCCustomInserterPseudo<
1761 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MAX_I16",
1762 [(set i32:$dst, (atomic_load_max_16 xoaddr:$ptr, i32:$incr))]>;
1763 def ATOMIC_LOAD_UMIN_I16 : PPCCustomInserterPseudo<
1764 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMIN_I16",
1765 [(set i32:$dst, (atomic_load_umin_16 xoaddr:$ptr, i32:$incr))]>;
1766 def ATOMIC_LOAD_UMAX_I16 : PPCCustomInserterPseudo<
1767 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMAX_I16",
1768 [(set i32:$dst, (atomic_load_umax_16 xoaddr:$ptr, i32:$incr))]>;
1769 def ATOMIC_LOAD_ADD_I32 : PPCCustomInserterPseudo<
1770 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I32",
1771 [(set i32:$dst, (atomic_load_add_32 xoaddr:$ptr, i32:$incr))]>;
1772 def ATOMIC_LOAD_SUB_I32 : PPCCustomInserterPseudo<
1773 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I32",
1774 [(set i32:$dst, (atomic_load_sub_32 xoaddr:$ptr, i32:$incr))]>;
1775 def ATOMIC_LOAD_AND_I32 : PPCCustomInserterPseudo<
1776 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I32",
1777 [(set i32:$dst, (atomic_load_and_32 xoaddr:$ptr, i32:$incr))]>;
1778 def ATOMIC_LOAD_OR_I32 : PPCCustomInserterPseudo<
1779 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I32",
1780 [(set i32:$dst, (atomic_load_or_32 xoaddr:$ptr, i32:$incr))]>;
1781 def ATOMIC_LOAD_XOR_I32 : PPCCustomInserterPseudo<
1782 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_XOR_I32",
1783 [(set i32:$dst, (atomic_load_xor_32 xoaddr:$ptr, i32:$incr))]>;
1784 def ATOMIC_LOAD_NAND_I32 : PPCCustomInserterPseudo<
1785 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I32",
1786 [(set i32:$dst, (atomic_load_nand_32 xoaddr:$ptr, i32:$incr))]>;
1787 def ATOMIC_LOAD_MIN_I32 : PPCCustomInserterPseudo<
1788 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MIN_I32",
1789 [(set i32:$dst, (atomic_load_min_32 xoaddr:$ptr, i32:$incr))]>;
1790 def ATOMIC_LOAD_MAX_I32 : PPCCustomInserterPseudo<
1791 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MAX_I32",
1792 [(set i32:$dst, (atomic_load_max_32 xoaddr:$ptr, i32:$incr))]>;
1793 def ATOMIC_LOAD_UMIN_I32 : PPCCustomInserterPseudo<
1794 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMIN_I32",
1795 [(set i32:$dst, (atomic_load_umin_32 xoaddr:$ptr, i32:$incr))]>;
1796 def ATOMIC_LOAD_UMAX_I32 : PPCCustomInserterPseudo<
1797 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMAX_I32",
1798 [(set i32:$dst, (atomic_load_umax_32 xoaddr:$ptr, i32:$incr))]>;
1800 def ATOMIC_CMP_SWAP_I8 : PPCCustomInserterPseudo<
1801 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I8",
1802 [(set i32:$dst, (atomic_cmp_swap_8 xoaddr:$ptr, i32:$old, i32:$new))]>;
1803 def ATOMIC_CMP_SWAP_I16 : PPCCustomInserterPseudo<
1804 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I16 $dst $ptr $old $new",
1805 [(set i32:$dst, (atomic_cmp_swap_16 xoaddr:$ptr, i32:$old, i32:$new))]>;
1806 def ATOMIC_CMP_SWAP_I32 : PPCCustomInserterPseudo<
1807 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I32 $dst $ptr $old $new",
1808 [(set i32:$dst, (atomic_cmp_swap_32 xoaddr:$ptr, i32:$old, i32:$new))]>;
1810 def ATOMIC_SWAP_I8 : PPCCustomInserterPseudo<
1811 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_i8",
1812 [(set i32:$dst, (atomic_swap_8 xoaddr:$ptr, i32:$new))]>;
1813 def ATOMIC_SWAP_I16 : PPCCustomInserterPseudo<
1814 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_I16",
1815 [(set i32:$dst, (atomic_swap_16 xoaddr:$ptr, i32:$new))]>;
1816 def ATOMIC_SWAP_I32 : PPCCustomInserterPseudo<
1817 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_I32",
1818 [(set i32:$dst, (atomic_swap_32 xoaddr:$ptr, i32:$new))]>;
1821 def : Pat<(PPCatomicCmpSwap_8 xoaddr:$ptr, i32:$old, i32:$new),
1822 (ATOMIC_CMP_SWAP_I8 xoaddr:$ptr, i32:$old, i32:$new)>;
1823 def : Pat<(PPCatomicCmpSwap_16 xoaddr:$ptr, i32:$old, i32:$new),
1824 (ATOMIC_CMP_SWAP_I16 xoaddr:$ptr, i32:$old, i32:$new)>;
1826 // Instructions to support atomic operations
1827 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in {
1828 def LBARX : XForm_1_memOp<31, 52, (outs gprc:$rD), (ins memrr:$src),
1829 "lbarx $rD, $src", IIC_LdStLWARX, []>,
1830 Requires<[HasPartwordAtomics]>;
1832 def LHARX : XForm_1_memOp<31, 116, (outs gprc:$rD), (ins memrr:$src),
1833 "lharx $rD, $src", IIC_LdStLWARX, []>,
1834 Requires<[HasPartwordAtomics]>;
1836 def LWARX : XForm_1_memOp<31, 20, (outs gprc:$rD), (ins memrr:$src),
1837 "lwarx $rD, $src", IIC_LdStLWARX, []>;
1839 // Instructions to support lock versions of atomics
1840 // (EH=1 - see Power ISA 2.07 Book II 4.4.2)
1841 def LBARXL : XForm_1_memOp<31, 52, (outs gprc:$rD), (ins memrr:$src),
1842 "lbarx $rD, $src, 1", IIC_LdStLWARX, []>, isDOT,
1843 Requires<[HasPartwordAtomics]>;
1845 def LHARXL : XForm_1_memOp<31, 116, (outs gprc:$rD), (ins memrr:$src),
1846 "lharx $rD, $src, 1", IIC_LdStLWARX, []>, isDOT,
1847 Requires<[HasPartwordAtomics]>;
1849 def LWARXL : XForm_1_memOp<31, 20, (outs gprc:$rD), (ins memrr:$src),
1850 "lwarx $rD, $src, 1", IIC_LdStLWARX, []>, isDOT;
1852 // The atomic instructions use the destination register as well as the next one
1853 // or two registers in order (modulo 31).
1854 let hasExtraSrcRegAllocReq = 1 in
1855 def LWAT : X_RD5_RS5_IM5<31, 582, (outs gprc:$rD), (ins gprc:$rA, u5imm:$FC),
1856 "lwat $rD, $rA, $FC", IIC_LdStLoad>,
1857 Requires<[IsISA3_0]>;
1860 let Defs = [CR0], mayStore = 1, mayLoad = 0, hasSideEffects = 0 in {
1861 def STBCX : XForm_1_memOp<31, 694, (outs), (ins gprc:$rS, memrr:$dst),
1862 "stbcx. $rS, $dst", IIC_LdStSTWCX, []>,
1863 isDOT, Requires<[HasPartwordAtomics]>;
1865 def STHCX : XForm_1_memOp<31, 726, (outs), (ins gprc:$rS, memrr:$dst),
1866 "sthcx. $rS, $dst", IIC_LdStSTWCX, []>,
1867 isDOT, Requires<[HasPartwordAtomics]>;
1869 def STWCX : XForm_1_memOp<31, 150, (outs), (ins gprc:$rS, memrr:$dst),
1870 "stwcx. $rS, $dst", IIC_LdStSTWCX, []>, isDOT;
1873 let mayStore = 1, mayLoad = 0, hasSideEffects = 0 in
1874 def STWAT : X_RD5_RS5_IM5<31, 710, (outs), (ins gprc:$rS, gprc:$rA, u5imm:$FC),
1875 "stwat $rS, $rA, $FC", IIC_LdStStore>,
1876 Requires<[IsISA3_0]>;
1878 let isTerminator = 1, isBarrier = 1, hasCtrlDep = 1 in
1879 def TRAP : XForm_24<31, 4, (outs), (ins), "trap", IIC_LdStLoad, [(trap)]>;
1881 def TWI : DForm_base<3, (outs), (ins u5imm:$to, gprc:$rA, s16imm:$imm),
1882 "twi $to, $rA, $imm", IIC_IntTrapW, []>;
1883 def TW : XForm_1<31, 4, (outs), (ins u5imm:$to, gprc:$rA, gprc:$rB),
1884 "tw $to, $rA, $rB", IIC_IntTrapW, []>;
1885 def TDI : DForm_base<2, (outs), (ins u5imm:$to, g8rc:$rA, s16imm:$imm),
1886 "tdi $to, $rA, $imm", IIC_IntTrapD, []>;
1887 def TD : XForm_1<31, 68, (outs), (ins u5imm:$to, g8rc:$rA, g8rc:$rB),
1888 "td $to, $rA, $rB", IIC_IntTrapD, []>;
1890 //===----------------------------------------------------------------------===//
1891 // PPC32 Load Instructions.
1894 // Unindexed (r+i) Loads.
1895 let PPC970_Unit = 2 in {
1896 def LBZ : DForm_1<34, (outs gprc:$rD), (ins memri:$src),
1897 "lbz $rD, $src", IIC_LdStLoad,
1898 [(set i32:$rD, (zextloadi8 iaddr:$src))]>;
1899 def LHA : DForm_1<42, (outs gprc:$rD), (ins memri:$src),
1900 "lha $rD, $src", IIC_LdStLHA,
1901 [(set i32:$rD, (sextloadi16 iaddr:$src))]>,
1902 PPC970_DGroup_Cracked;
1903 def LHZ : DForm_1<40, (outs gprc:$rD), (ins memri:$src),
1904 "lhz $rD, $src", IIC_LdStLoad,
1905 [(set i32:$rD, (zextloadi16 iaddr:$src))]>;
1906 def LWZ : DForm_1<32, (outs gprc:$rD), (ins memri:$src),
1907 "lwz $rD, $src", IIC_LdStLoad,
1908 [(set i32:$rD, (load iaddr:$src))]>;
1910 let Predicates = [HasFPU] in {
1911 def LFS : DForm_1<48, (outs f4rc:$rD), (ins memri:$src),
1912 "lfs $rD, $src", IIC_LdStLFD,
1913 [(set f32:$rD, (load iaddr:$src))]>;
1914 def LFD : DForm_1<50, (outs f8rc:$rD), (ins memri:$src),
1915 "lfd $rD, $src", IIC_LdStLFD,
1916 [(set f64:$rD, (load iaddr:$src))]>;
1920 // Unindexed (r+i) Loads with Update (preinc).
1921 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in {
1922 def LBZU : DForm_1<35, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1923 "lbzu $rD, $addr", IIC_LdStLoadUpd,
1924 []>, RegConstraint<"$addr.reg = $ea_result">,
1925 NoEncode<"$ea_result">;
1927 def LHAU : DForm_1<43, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1928 "lhau $rD, $addr", IIC_LdStLHAU,
1929 []>, RegConstraint<"$addr.reg = $ea_result">,
1930 NoEncode<"$ea_result">;
1932 def LHZU : DForm_1<41, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1933 "lhzu $rD, $addr", IIC_LdStLoadUpd,
1934 []>, RegConstraint<"$addr.reg = $ea_result">,
1935 NoEncode<"$ea_result">;
1937 def LWZU : DForm_1<33, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1938 "lwzu $rD, $addr", IIC_LdStLoadUpd,
1939 []>, RegConstraint<"$addr.reg = $ea_result">,
1940 NoEncode<"$ea_result">;
1942 let Predicates = [HasFPU] in {
1943 def LFSU : DForm_1<49, (outs f4rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1944 "lfsu $rD, $addr", IIC_LdStLFDU,
1945 []>, RegConstraint<"$addr.reg = $ea_result">,
1946 NoEncode<"$ea_result">;
1948 def LFDU : DForm_1<51, (outs f8rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1949 "lfdu $rD, $addr", IIC_LdStLFDU,
1950 []>, RegConstraint<"$addr.reg = $ea_result">,
1951 NoEncode<"$ea_result">;
1955 // Indexed (r+r) Loads with Update (preinc).
1956 def LBZUX : XForm_1_memOp<31, 119, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1958 "lbzux $rD, $addr", IIC_LdStLoadUpdX,
1959 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1960 NoEncode<"$ea_result">;
1962 def LHAUX : XForm_1_memOp<31, 375, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1964 "lhaux $rD, $addr", IIC_LdStLHAUX,
1965 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1966 NoEncode<"$ea_result">;
1968 def LHZUX : XForm_1_memOp<31, 311, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1970 "lhzux $rD, $addr", IIC_LdStLoadUpdX,
1971 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1972 NoEncode<"$ea_result">;
1974 def LWZUX : XForm_1_memOp<31, 55, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1976 "lwzux $rD, $addr", IIC_LdStLoadUpdX,
1977 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1978 NoEncode<"$ea_result">;
1980 let Predicates = [HasFPU] in {
1981 def LFSUX : XForm_1_memOp<31, 567, (outs f4rc:$rD, ptr_rc_nor0:$ea_result),
1983 "lfsux $rD, $addr", IIC_LdStLFDUX,
1984 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1985 NoEncode<"$ea_result">;
1987 def LFDUX : XForm_1_memOp<31, 631, (outs f8rc:$rD, ptr_rc_nor0:$ea_result),
1989 "lfdux $rD, $addr", IIC_LdStLFDUX,
1990 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1991 NoEncode<"$ea_result">;
1996 // Indexed (r+r) Loads.
1998 let PPC970_Unit = 2, mayLoad = 1, mayStore = 0 in {
1999 def LBZX : XForm_1_memOp<31, 87, (outs gprc:$rD), (ins memrr:$src),
2000 "lbzx $rD, $src", IIC_LdStLoad,
2001 [(set i32:$rD, (zextloadi8 xaddr:$src))]>;
2002 def LHAX : XForm_1_memOp<31, 343, (outs gprc:$rD), (ins memrr:$src),
2003 "lhax $rD, $src", IIC_LdStLHA,
2004 [(set i32:$rD, (sextloadi16 xaddr:$src))]>,
2005 PPC970_DGroup_Cracked;
2006 def LHZX : XForm_1_memOp<31, 279, (outs gprc:$rD), (ins memrr:$src),
2007 "lhzx $rD, $src", IIC_LdStLoad,
2008 [(set i32:$rD, (zextloadi16 xaddr:$src))]>;
2009 def LWZX : XForm_1_memOp<31, 23, (outs gprc:$rD), (ins memrr:$src),
2010 "lwzx $rD, $src", IIC_LdStLoad,
2011 [(set i32:$rD, (load xaddr:$src))]>;
2012 def LHBRX : XForm_1_memOp<31, 790, (outs gprc:$rD), (ins memrr:$src),
2013 "lhbrx $rD, $src", IIC_LdStLoad,
2014 [(set i32:$rD, (PPClbrx xoaddr:$src, i16))]>;
2015 def LWBRX : XForm_1_memOp<31, 534, (outs gprc:$rD), (ins memrr:$src),
2016 "lwbrx $rD, $src", IIC_LdStLoad,
2017 [(set i32:$rD, (PPClbrx xoaddr:$src, i32))]>;
2019 let Predicates = [HasFPU] in {
2020 def LFSX : XForm_25_memOp<31, 535, (outs f4rc:$frD), (ins memrr:$src),
2021 "lfsx $frD, $src", IIC_LdStLFD,
2022 [(set f32:$frD, (load xaddr:$src))]>;
2023 def LFDX : XForm_25_memOp<31, 599, (outs f8rc:$frD), (ins memrr:$src),
2024 "lfdx $frD, $src", IIC_LdStLFD,
2025 [(set f64:$frD, (load xaddr:$src))]>;
2027 def LFIWAX : XForm_25_memOp<31, 855, (outs f8rc:$frD), (ins memrr:$src),
2028 "lfiwax $frD, $src", IIC_LdStLFD,
2029 [(set f64:$frD, (PPClfiwax xoaddr:$src))]>;
2030 def LFIWZX : XForm_25_memOp<31, 887, (outs f8rc:$frD), (ins memrr:$src),
2031 "lfiwzx $frD, $src", IIC_LdStLFD,
2032 [(set f64:$frD, (PPClfiwzx xoaddr:$src))]>;
2037 def LMW : DForm_1<46, (outs gprc:$rD), (ins memri:$src),
2038 "lmw $rD, $src", IIC_LdStLMW, []>;
2040 //===----------------------------------------------------------------------===//
2041 // PPC32 Store Instructions.
2044 // Unindexed (r+i) Stores.
2045 let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in {
2046 def STB : DForm_1<38, (outs), (ins gprc:$rS, memri:$dst),
2047 "stb $rS, $dst", IIC_LdStStore,
2048 [(truncstorei8 i32:$rS, iaddr:$dst)]>;
2049 def STH : DForm_1<44, (outs), (ins gprc:$rS, memri:$dst),
2050 "sth $rS, $dst", IIC_LdStStore,
2051 [(truncstorei16 i32:$rS, iaddr:$dst)]>;
2052 def STW : DForm_1<36, (outs), (ins gprc:$rS, memri:$dst),
2053 "stw $rS, $dst", IIC_LdStStore,
2054 [(store i32:$rS, iaddr:$dst)]>;
2055 let Predicates = [HasFPU] in {
2056 def STFS : DForm_1<52, (outs), (ins f4rc:$rS, memri:$dst),
2057 "stfs $rS, $dst", IIC_LdStSTFD,
2058 [(store f32:$rS, iaddr:$dst)]>;
2059 def STFD : DForm_1<54, (outs), (ins f8rc:$rS, memri:$dst),
2060 "stfd $rS, $dst", IIC_LdStSTFD,
2061 [(store f64:$rS, iaddr:$dst)]>;
2065 // Unindexed (r+i) Stores with Update (preinc).
2066 let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in {
2067 def STBU : DForm_1<39, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst),
2068 "stbu $rS, $dst", IIC_LdStSTU, []>,
2069 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
2070 def STHU : DForm_1<45, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst),
2071 "sthu $rS, $dst", IIC_LdStSTU, []>,
2072 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
2073 def STWU : DForm_1<37, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst),
2074 "stwu $rS, $dst", IIC_LdStSTU, []>,
2075 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
2076 let Predicates = [HasFPU] in {
2077 def STFSU : DForm_1<53, (outs ptr_rc_nor0:$ea_res), (ins f4rc:$rS, memri:$dst),
2078 "stfsu $rS, $dst", IIC_LdStSTFDU, []>,
2079 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
2080 def STFDU : DForm_1<55, (outs ptr_rc_nor0:$ea_res), (ins f8rc:$rS, memri:$dst),
2081 "stfdu $rS, $dst", IIC_LdStSTFDU, []>,
2082 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
2086 // Patterns to match the pre-inc stores. We can't put the patterns on
2087 // the instruction definitions directly as ISel wants the address base
2088 // and offset to be separate operands, not a single complex operand.
2089 def : Pat<(pre_truncsti8 i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
2090 (STBU $rS, iaddroff:$ptroff, $ptrreg)>;
2091 def : Pat<(pre_truncsti16 i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
2092 (STHU $rS, iaddroff:$ptroff, $ptrreg)>;
2093 def : Pat<(pre_store i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
2094 (STWU $rS, iaddroff:$ptroff, $ptrreg)>;
2095 def : Pat<(pre_store f32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
2096 (STFSU $rS, iaddroff:$ptroff, $ptrreg)>;
2097 def : Pat<(pre_store f64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
2098 (STFDU $rS, iaddroff:$ptroff, $ptrreg)>;
2100 // Indexed (r+r) Stores.
2101 let PPC970_Unit = 2 in {
2102 def STBX : XForm_8_memOp<31, 215, (outs), (ins gprc:$rS, memrr:$dst),
2103 "stbx $rS, $dst", IIC_LdStStore,
2104 [(truncstorei8 i32:$rS, xaddr:$dst)]>,
2105 PPC970_DGroup_Cracked;
2106 def STHX : XForm_8_memOp<31, 407, (outs), (ins gprc:$rS, memrr:$dst),
2107 "sthx $rS, $dst", IIC_LdStStore,
2108 [(truncstorei16 i32:$rS, xaddr:$dst)]>,
2109 PPC970_DGroup_Cracked;
2110 def STWX : XForm_8_memOp<31, 151, (outs), (ins gprc:$rS, memrr:$dst),
2111 "stwx $rS, $dst", IIC_LdStStore,
2112 [(store i32:$rS, xaddr:$dst)]>,
2113 PPC970_DGroup_Cracked;
2115 def STHBRX: XForm_8_memOp<31, 918, (outs), (ins gprc:$rS, memrr:$dst),
2116 "sthbrx $rS, $dst", IIC_LdStStore,
2117 [(PPCstbrx i32:$rS, xoaddr:$dst, i16)]>,
2118 PPC970_DGroup_Cracked;
2119 def STWBRX: XForm_8_memOp<31, 662, (outs), (ins gprc:$rS, memrr:$dst),
2120 "stwbrx $rS, $dst", IIC_LdStStore,
2121 [(PPCstbrx i32:$rS, xoaddr:$dst, i32)]>,
2122 PPC970_DGroup_Cracked;
2124 let Predicates = [HasFPU] in {
2125 def STFIWX: XForm_28_memOp<31, 983, (outs), (ins f8rc:$frS, memrr:$dst),
2126 "stfiwx $frS, $dst", IIC_LdStSTFD,
2127 [(PPCstfiwx f64:$frS, xoaddr:$dst)]>;
2129 def STFSX : XForm_28_memOp<31, 663, (outs), (ins f4rc:$frS, memrr:$dst),
2130 "stfsx $frS, $dst", IIC_LdStSTFD,
2131 [(store f32:$frS, xaddr:$dst)]>;
2132 def STFDX : XForm_28_memOp<31, 727, (outs), (ins f8rc:$frS, memrr:$dst),
2133 "stfdx $frS, $dst", IIC_LdStSTFD,
2134 [(store f64:$frS, xaddr:$dst)]>;
2138 // Indexed (r+r) Stores with Update (preinc).
2139 let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in {
2140 def STBUX : XForm_8_memOp<31, 247, (outs ptr_rc_nor0:$ea_res),
2141 (ins gprc:$rS, memrr:$dst),
2142 "stbux $rS, $dst", IIC_LdStSTUX, []>,
2143 RegConstraint<"$dst.ptrreg = $ea_res">,
2144 NoEncode<"$ea_res">,
2145 PPC970_DGroup_Cracked;
2146 def STHUX : XForm_8_memOp<31, 439, (outs ptr_rc_nor0:$ea_res),
2147 (ins gprc:$rS, memrr:$dst),
2148 "sthux $rS, $dst", IIC_LdStSTUX, []>,
2149 RegConstraint<"$dst.ptrreg = $ea_res">,
2150 NoEncode<"$ea_res">,
2151 PPC970_DGroup_Cracked;
2152 def STWUX : XForm_8_memOp<31, 183, (outs ptr_rc_nor0:$ea_res),
2153 (ins gprc:$rS, memrr:$dst),
2154 "stwux $rS, $dst", IIC_LdStSTUX, []>,
2155 RegConstraint<"$dst.ptrreg = $ea_res">,
2156 NoEncode<"$ea_res">,
2157 PPC970_DGroup_Cracked;
2158 let Predicates = [HasFPU] in {
2159 def STFSUX: XForm_8_memOp<31, 695, (outs ptr_rc_nor0:$ea_res),
2160 (ins f4rc:$rS, memrr:$dst),
2161 "stfsux $rS, $dst", IIC_LdStSTFDU, []>,
2162 RegConstraint<"$dst.ptrreg = $ea_res">,
2163 NoEncode<"$ea_res">,
2164 PPC970_DGroup_Cracked;
2165 def STFDUX: XForm_8_memOp<31, 759, (outs ptr_rc_nor0:$ea_res),
2166 (ins f8rc:$rS, memrr:$dst),
2167 "stfdux $rS, $dst", IIC_LdStSTFDU, []>,
2168 RegConstraint<"$dst.ptrreg = $ea_res">,
2169 NoEncode<"$ea_res">,
2170 PPC970_DGroup_Cracked;
2174 // Patterns to match the pre-inc stores. We can't put the patterns on
2175 // the instruction definitions directly as ISel wants the address base
2176 // and offset to be separate operands, not a single complex operand.
2177 def : Pat<(pre_truncsti8 i32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2178 (STBUX $rS, $ptrreg, $ptroff)>;
2179 def : Pat<(pre_truncsti16 i32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2180 (STHUX $rS, $ptrreg, $ptroff)>;
2181 def : Pat<(pre_store i32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2182 (STWUX $rS, $ptrreg, $ptroff)>;
2183 let Predicates = [HasFPU] in {
2184 def : Pat<(pre_store f32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2185 (STFSUX $rS, $ptrreg, $ptroff)>;
2186 def : Pat<(pre_store f64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2187 (STFDUX $rS, $ptrreg, $ptroff)>;
2191 def STMW : DForm_1<47, (outs), (ins gprc:$rS, memri:$dst),
2192 "stmw $rS, $dst", IIC_LdStLMW, []>;
2194 def SYNC : XForm_24_sync<31, 598, (outs), (ins i32imm:$L),
2195 "sync $L", IIC_LdStSync, []>;
2197 let isCodeGenOnly = 1 in {
2198 def MSYNC : XForm_24_sync<31, 598, (outs), (ins),
2199 "msync", IIC_LdStSync, []> {
2204 def : Pat<(int_ppc_sync), (SYNC 0)>, Requires<[HasSYNC]>;
2205 def : Pat<(int_ppc_lwsync), (SYNC 1)>, Requires<[HasSYNC]>;
2206 def : Pat<(int_ppc_sync), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
2207 def : Pat<(int_ppc_lwsync), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
2209 //===----------------------------------------------------------------------===//
2210 // PPC32 Arithmetic Instructions.
2213 let PPC970_Unit = 1 in { // FXU Operations.
2214 def ADDI : DForm_2<14, (outs gprc:$rD), (ins gprc_nor0:$rA, s16imm:$imm),
2215 "addi $rD, $rA, $imm", IIC_IntSimple,
2216 [(set i32:$rD, (add i32:$rA, imm32SExt16:$imm))]>;
2217 let BaseName = "addic" in {
2218 let Defs = [CARRY] in
2219 def ADDIC : DForm_2<12, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
2220 "addic $rD, $rA, $imm", IIC_IntGeneral,
2221 [(set i32:$rD, (addc i32:$rA, imm32SExt16:$imm))]>,
2222 RecFormRel, PPC970_DGroup_Cracked;
2223 let Defs = [CARRY, CR0] in
2224 def ADDICo : DForm_2<13, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
2225 "addic. $rD, $rA, $imm", IIC_IntGeneral,
2226 []>, isDOT, RecFormRel;
2228 def ADDIS : DForm_2<15, (outs gprc:$rD), (ins gprc_nor0:$rA, s17imm:$imm),
2229 "addis $rD, $rA, $imm", IIC_IntSimple,
2230 [(set i32:$rD, (add i32:$rA, imm16ShiftedSExt:$imm))]>;
2231 let isCodeGenOnly = 1 in
2232 def LA : DForm_2<14, (outs gprc:$rD), (ins gprc_nor0:$rA, s16imm:$sym),
2233 "la $rD, $sym($rA)", IIC_IntGeneral,
2234 [(set i32:$rD, (add i32:$rA,
2235 (PPClo tglobaladdr:$sym, 0)))]>;
2236 def MULLI : DForm_2< 7, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
2237 "mulli $rD, $rA, $imm", IIC_IntMulLI,
2238 [(set i32:$rD, (mul i32:$rA, imm32SExt16:$imm))]>;
2239 let Defs = [CARRY] in
2240 def SUBFIC : DForm_2< 8, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
2241 "subfic $rD, $rA, $imm", IIC_IntGeneral,
2242 [(set i32:$rD, (subc imm32SExt16:$imm, i32:$rA))]>;
2244 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in {
2245 def LI : DForm_2_r0<14, (outs gprc:$rD), (ins s16imm:$imm),
2246 "li $rD, $imm", IIC_IntSimple,
2247 [(set i32:$rD, imm32SExt16:$imm)]>;
2248 def LIS : DForm_2_r0<15, (outs gprc:$rD), (ins s17imm:$imm),
2249 "lis $rD, $imm", IIC_IntSimple,
2250 [(set i32:$rD, imm16ShiftedSExt:$imm)]>;
2254 let PPC970_Unit = 1 in { // FXU Operations.
2255 let Defs = [CR0] in {
2256 def ANDIo : DForm_4<28, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2257 "andi. $dst, $src1, $src2", IIC_IntGeneral,
2258 [(set i32:$dst, (and i32:$src1, immZExt16:$src2))]>,
2260 def ANDISo : DForm_4<29, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2261 "andis. $dst, $src1, $src2", IIC_IntGeneral,
2262 [(set i32:$dst, (and i32:$src1, imm16ShiftedZExt:$src2))]>,
2265 def ORI : DForm_4<24, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2266 "ori $dst, $src1, $src2", IIC_IntSimple,
2267 [(set i32:$dst, (or i32:$src1, immZExt16:$src2))]>;
2268 def ORIS : DForm_4<25, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2269 "oris $dst, $src1, $src2", IIC_IntSimple,
2270 [(set i32:$dst, (or i32:$src1, imm16ShiftedZExt:$src2))]>;
2271 def XORI : DForm_4<26, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2272 "xori $dst, $src1, $src2", IIC_IntSimple,
2273 [(set i32:$dst, (xor i32:$src1, immZExt16:$src2))]>;
2274 def XORIS : DForm_4<27, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2275 "xoris $dst, $src1, $src2", IIC_IntSimple,
2276 [(set i32:$dst, (xor i32:$src1, imm16ShiftedZExt:$src2))]>;
2278 def NOP : DForm_4_zero<24, (outs), (ins), "nop", IIC_IntSimple,
2280 let isCodeGenOnly = 1 in {
2281 // The POWER6 and POWER7 have special group-terminating nops.
2282 def NOP_GT_PWR6 : DForm_4_fixedreg_zero<24, 1, (outs), (ins),
2283 "ori 1, 1, 0", IIC_IntSimple, []>;
2284 def NOP_GT_PWR7 : DForm_4_fixedreg_zero<24, 2, (outs), (ins),
2285 "ori 2, 2, 0", IIC_IntSimple, []>;
2288 let isCompare = 1, hasSideEffects = 0 in {
2289 def CMPWI : DForm_5_ext<11, (outs crrc:$crD), (ins gprc:$rA, s16imm:$imm),
2290 "cmpwi $crD, $rA, $imm", IIC_IntCompare>;
2291 def CMPLWI : DForm_6_ext<10, (outs crrc:$dst), (ins gprc:$src1, u16imm:$src2),
2292 "cmplwi $dst, $src1, $src2", IIC_IntCompare>;
2293 def CMPRB : X_BF3_L1_RS5_RS5<31, 192, (outs crbitrc:$BF),
2294 (ins u1imm:$L, g8rc:$rA, g8rc:$rB),
2295 "cmprb $BF, $L, $rA, $rB", IIC_IntCompare, []>,
2296 Requires<[IsISA3_0]>;
2300 let PPC970_Unit = 1, hasSideEffects = 0 in { // FXU Operations.
2301 let isCommutable = 1 in {
2302 defm NAND : XForm_6r<31, 476, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2303 "nand", "$rA, $rS, $rB", IIC_IntSimple,
2304 [(set i32:$rA, (not (and i32:$rS, i32:$rB)))]>;
2305 defm AND : XForm_6r<31, 28, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2306 "and", "$rA, $rS, $rB", IIC_IntSimple,
2307 [(set i32:$rA, (and i32:$rS, i32:$rB))]>;
2309 defm ANDC : XForm_6r<31, 60, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2310 "andc", "$rA, $rS, $rB", IIC_IntSimple,
2311 [(set i32:$rA, (and i32:$rS, (not i32:$rB)))]>;
2312 let isCommutable = 1 in {
2313 defm OR : XForm_6r<31, 444, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2314 "or", "$rA, $rS, $rB", IIC_IntSimple,
2315 [(set i32:$rA, (or i32:$rS, i32:$rB))]>;
2316 defm NOR : XForm_6r<31, 124, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2317 "nor", "$rA, $rS, $rB", IIC_IntSimple,
2318 [(set i32:$rA, (not (or i32:$rS, i32:$rB)))]>;
2320 defm ORC : XForm_6r<31, 412, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2321 "orc", "$rA, $rS, $rB", IIC_IntSimple,
2322 [(set i32:$rA, (or i32:$rS, (not i32:$rB)))]>;
2323 let isCommutable = 1 in {
2324 defm EQV : XForm_6r<31, 284, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2325 "eqv", "$rA, $rS, $rB", IIC_IntSimple,
2326 [(set i32:$rA, (not (xor i32:$rS, i32:$rB)))]>;
2327 defm XOR : XForm_6r<31, 316, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2328 "xor", "$rA, $rS, $rB", IIC_IntSimple,
2329 [(set i32:$rA, (xor i32:$rS, i32:$rB))]>;
2331 defm SLW : XForm_6r<31, 24, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2332 "slw", "$rA, $rS, $rB", IIC_IntGeneral,
2333 [(set i32:$rA, (PPCshl i32:$rS, i32:$rB))]>;
2334 defm SRW : XForm_6r<31, 536, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2335 "srw", "$rA, $rS, $rB", IIC_IntGeneral,
2336 [(set i32:$rA, (PPCsrl i32:$rS, i32:$rB))]>;
2337 defm SRAW : XForm_6rc<31, 792, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2338 "sraw", "$rA, $rS, $rB", IIC_IntShift,
2339 [(set i32:$rA, (PPCsra i32:$rS, i32:$rB))]>;
2342 let PPC970_Unit = 1 in { // FXU Operations.
2343 let hasSideEffects = 0 in {
2344 defm SRAWI : XForm_10rc<31, 824, (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH),
2345 "srawi", "$rA, $rS, $SH", IIC_IntShift,
2346 [(set i32:$rA, (sra i32:$rS, (i32 imm:$SH)))]>;
2347 defm CNTLZW : XForm_11r<31, 26, (outs gprc:$rA), (ins gprc:$rS),
2348 "cntlzw", "$rA, $rS", IIC_IntGeneral,
2349 [(set i32:$rA, (ctlz i32:$rS))]>;
2350 defm CNTTZW : XForm_11r<31, 538, (outs gprc:$rA), (ins gprc:$rS),
2351 "cnttzw", "$rA, $rS", IIC_IntGeneral,
2352 [(set i32:$rA, (cttz i32:$rS))]>, Requires<[IsISA3_0]>;
2353 defm EXTSB : XForm_11r<31, 954, (outs gprc:$rA), (ins gprc:$rS),
2354 "extsb", "$rA, $rS", IIC_IntSimple,
2355 [(set i32:$rA, (sext_inreg i32:$rS, i8))]>;
2356 defm EXTSH : XForm_11r<31, 922, (outs gprc:$rA), (ins gprc:$rS),
2357 "extsh", "$rA, $rS", IIC_IntSimple,
2358 [(set i32:$rA, (sext_inreg i32:$rS, i16))]>;
2360 let isCommutable = 1 in
2361 def CMPB : XForm_6<31, 508, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2362 "cmpb $rA, $rS, $rB", IIC_IntGeneral,
2363 [(set i32:$rA, (PPCcmpb i32:$rS, i32:$rB))]>;
2365 let isCompare = 1, hasSideEffects = 0 in {
2366 def CMPW : XForm_16_ext<31, 0, (outs crrc:$crD), (ins gprc:$rA, gprc:$rB),
2367 "cmpw $crD, $rA, $rB", IIC_IntCompare>;
2368 def CMPLW : XForm_16_ext<31, 32, (outs crrc:$crD), (ins gprc:$rA, gprc:$rB),
2369 "cmplw $crD, $rA, $rB", IIC_IntCompare>;
2372 let PPC970_Unit = 3, Predicates = [HasFPU] in { // FPU Operations.
2373 //def FCMPO : XForm_17<63, 32, (outs CRRC:$crD), (ins FPRC:$fA, FPRC:$fB),
2374 // "fcmpo $crD, $fA, $fB", IIC_FPCompare>;
2375 let isCompare = 1, hasSideEffects = 0 in {
2376 def FCMPUS : XForm_17<63, 0, (outs crrc:$crD), (ins f4rc:$fA, f4rc:$fB),
2377 "fcmpu $crD, $fA, $fB", IIC_FPCompare>;
2378 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2379 def FCMPUD : XForm_17<63, 0, (outs crrc:$crD), (ins f8rc:$fA, f8rc:$fB),
2380 "fcmpu $crD, $fA, $fB", IIC_FPCompare>;
2383 def FTDIV: XForm_17<63, 128, (outs crrc:$crD), (ins f8rc:$fA, f8rc:$fB),
2384 "ftdiv $crD, $fA, $fB", IIC_FPCompare>;
2385 def FTSQRT: XForm_17a<63, 160, (outs crrc:$crD), (ins f8rc:$fB),
2386 "ftsqrt $crD, $fB", IIC_FPCompare>;
2388 let Uses = [RM] in {
2389 let hasSideEffects = 0 in {
2390 defm FCTIW : XForm_26r<63, 14, (outs f8rc:$frD), (ins f8rc:$frB),
2391 "fctiw", "$frD, $frB", IIC_FPGeneral,
2393 defm FCTIWU : XForm_26r<63, 142, (outs f8rc:$frD), (ins f8rc:$frB),
2394 "fctiwu", "$frD, $frB", IIC_FPGeneral,
2396 defm FCTIWZ : XForm_26r<63, 15, (outs f8rc:$frD), (ins f8rc:$frB),
2397 "fctiwz", "$frD, $frB", IIC_FPGeneral,
2398 [(set f64:$frD, (PPCfctiwz f64:$frB))]>;
2400 defm FRSP : XForm_26r<63, 12, (outs f4rc:$frD), (ins f8rc:$frB),
2401 "frsp", "$frD, $frB", IIC_FPGeneral,
2402 [(set f32:$frD, (fpround f64:$frB))]>;
2404 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2405 defm FRIND : XForm_26r<63, 392, (outs f8rc:$frD), (ins f8rc:$frB),
2406 "frin", "$frD, $frB", IIC_FPGeneral,
2407 [(set f64:$frD, (fround f64:$frB))]>;
2408 defm FRINS : XForm_26r<63, 392, (outs f4rc:$frD), (ins f4rc:$frB),
2409 "frin", "$frD, $frB", IIC_FPGeneral,
2410 [(set f32:$frD, (fround f32:$frB))]>;
2413 let hasSideEffects = 0 in {
2414 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2415 defm FRIPD : XForm_26r<63, 456, (outs f8rc:$frD), (ins f8rc:$frB),
2416 "frip", "$frD, $frB", IIC_FPGeneral,
2417 [(set f64:$frD, (fceil f64:$frB))]>;
2418 defm FRIPS : XForm_26r<63, 456, (outs f4rc:$frD), (ins f4rc:$frB),
2419 "frip", "$frD, $frB", IIC_FPGeneral,
2420 [(set f32:$frD, (fceil f32:$frB))]>;
2421 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2422 defm FRIZD : XForm_26r<63, 424, (outs f8rc:$frD), (ins f8rc:$frB),
2423 "friz", "$frD, $frB", IIC_FPGeneral,
2424 [(set f64:$frD, (ftrunc f64:$frB))]>;
2425 defm FRIZS : XForm_26r<63, 424, (outs f4rc:$frD), (ins f4rc:$frB),
2426 "friz", "$frD, $frB", IIC_FPGeneral,
2427 [(set f32:$frD, (ftrunc f32:$frB))]>;
2428 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2429 defm FRIMD : XForm_26r<63, 488, (outs f8rc:$frD), (ins f8rc:$frB),
2430 "frim", "$frD, $frB", IIC_FPGeneral,
2431 [(set f64:$frD, (ffloor f64:$frB))]>;
2432 defm FRIMS : XForm_26r<63, 488, (outs f4rc:$frD), (ins f4rc:$frB),
2433 "frim", "$frD, $frB", IIC_FPGeneral,
2434 [(set f32:$frD, (ffloor f32:$frB))]>;
2436 defm FSQRT : XForm_26r<63, 22, (outs f8rc:$frD), (ins f8rc:$frB),
2437 "fsqrt", "$frD, $frB", IIC_FPSqrtD,
2438 [(set f64:$frD, (fsqrt f64:$frB))]>;
2439 defm FSQRTS : XForm_26r<59, 22, (outs f4rc:$frD), (ins f4rc:$frB),
2440 "fsqrts", "$frD, $frB", IIC_FPSqrtS,
2441 [(set f32:$frD, (fsqrt f32:$frB))]>;
2446 /// Note that FMR is defined as pseudo-ops on the PPC970 because they are
2447 /// often coalesced away and we don't want the dispatch group builder to think
2448 /// that they will fill slots (which could cause the load of a LSU reject to
2449 /// sneak into a d-group with a store).
2450 let hasSideEffects = 0, Predicates = [HasFPU] in
2451 defm FMR : XForm_26r<63, 72, (outs f4rc:$frD), (ins f4rc:$frB),
2452 "fmr", "$frD, $frB", IIC_FPGeneral,
2453 []>, // (set f32:$frD, f32:$frB)
2456 let PPC970_Unit = 3, hasSideEffects = 0, Predicates = [HasFPU] in { // FPU Operations.
2457 // These are artificially split into two different forms, for 4/8 byte FP.
2458 defm FABSS : XForm_26r<63, 264, (outs f4rc:$frD), (ins f4rc:$frB),
2459 "fabs", "$frD, $frB", IIC_FPGeneral,
2460 [(set f32:$frD, (fabs f32:$frB))]>;
2461 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2462 defm FABSD : XForm_26r<63, 264, (outs f8rc:$frD), (ins f8rc:$frB),
2463 "fabs", "$frD, $frB", IIC_FPGeneral,
2464 [(set f64:$frD, (fabs f64:$frB))]>;
2465 defm FNABSS : XForm_26r<63, 136, (outs f4rc:$frD), (ins f4rc:$frB),
2466 "fnabs", "$frD, $frB", IIC_FPGeneral,
2467 [(set f32:$frD, (fneg (fabs f32:$frB)))]>;
2468 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2469 defm FNABSD : XForm_26r<63, 136, (outs f8rc:$frD), (ins f8rc:$frB),
2470 "fnabs", "$frD, $frB", IIC_FPGeneral,
2471 [(set f64:$frD, (fneg (fabs f64:$frB)))]>;
2472 defm FNEGS : XForm_26r<63, 40, (outs f4rc:$frD), (ins f4rc:$frB),
2473 "fneg", "$frD, $frB", IIC_FPGeneral,
2474 [(set f32:$frD, (fneg f32:$frB))]>;
2475 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2476 defm FNEGD : XForm_26r<63, 40, (outs f8rc:$frD), (ins f8rc:$frB),
2477 "fneg", "$frD, $frB", IIC_FPGeneral,
2478 [(set f64:$frD, (fneg f64:$frB))]>;
2480 defm FCPSGNS : XForm_28r<63, 8, (outs f4rc:$frD), (ins f4rc:$frA, f4rc:$frB),
2481 "fcpsgn", "$frD, $frA, $frB", IIC_FPGeneral,
2482 [(set f32:$frD, (fcopysign f32:$frB, f32:$frA))]>;
2483 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2484 defm FCPSGND : XForm_28r<63, 8, (outs f8rc:$frD), (ins f8rc:$frA, f8rc:$frB),
2485 "fcpsgn", "$frD, $frA, $frB", IIC_FPGeneral,
2486 [(set f64:$frD, (fcopysign f64:$frB, f64:$frA))]>;
2488 // Reciprocal estimates.
2489 defm FRE : XForm_26r<63, 24, (outs f8rc:$frD), (ins f8rc:$frB),
2490 "fre", "$frD, $frB", IIC_FPGeneral,
2491 [(set f64:$frD, (PPCfre f64:$frB))]>;
2492 defm FRES : XForm_26r<59, 24, (outs f4rc:$frD), (ins f4rc:$frB),
2493 "fres", "$frD, $frB", IIC_FPGeneral,
2494 [(set f32:$frD, (PPCfre f32:$frB))]>;
2495 defm FRSQRTE : XForm_26r<63, 26, (outs f8rc:$frD), (ins f8rc:$frB),
2496 "frsqrte", "$frD, $frB", IIC_FPGeneral,
2497 [(set f64:$frD, (PPCfrsqrte f64:$frB))]>;
2498 defm FRSQRTES : XForm_26r<59, 26, (outs f4rc:$frD), (ins f4rc:$frB),
2499 "frsqrtes", "$frD, $frB", IIC_FPGeneral,
2500 [(set f32:$frD, (PPCfrsqrte f32:$frB))]>;
2503 // XL-Form instructions. condition register logical ops.
2505 let hasSideEffects = 0 in
2506 def MCRF : XLForm_3<19, 0, (outs crrc:$BF), (ins crrc:$BFA),
2507 "mcrf $BF, $BFA", IIC_BrMCR>,
2508 PPC970_DGroup_First, PPC970_Unit_CRU;
2510 // FIXME: According to the ISA (section 2.5.1 of version 2.06), the
2511 // condition-register logical instructions have preferred forms. Specifically,
2512 // it is preferred that the bit specified by the BT field be in the same
2513 // condition register as that specified by the bit BB. We might want to account
2514 // for this via hinting the register allocator and anti-dep breakers, or we
2515 // could constrain the register class to force this constraint and then loosen
2516 // it during register allocation via convertToThreeAddress or some similar
2519 let isCommutable = 1 in {
2520 def CRAND : XLForm_1<19, 257, (outs crbitrc:$CRD),
2521 (ins crbitrc:$CRA, crbitrc:$CRB),
2522 "crand $CRD, $CRA, $CRB", IIC_BrCR,
2523 [(set i1:$CRD, (and i1:$CRA, i1:$CRB))]>;
2525 def CRNAND : XLForm_1<19, 225, (outs crbitrc:$CRD),
2526 (ins crbitrc:$CRA, crbitrc:$CRB),
2527 "crnand $CRD, $CRA, $CRB", IIC_BrCR,
2528 [(set i1:$CRD, (not (and i1:$CRA, i1:$CRB)))]>;
2530 def CROR : XLForm_1<19, 449, (outs crbitrc:$CRD),
2531 (ins crbitrc:$CRA, crbitrc:$CRB),
2532 "cror $CRD, $CRA, $CRB", IIC_BrCR,
2533 [(set i1:$CRD, (or i1:$CRA, i1:$CRB))]>;
2535 def CRXOR : XLForm_1<19, 193, (outs crbitrc:$CRD),
2536 (ins crbitrc:$CRA, crbitrc:$CRB),
2537 "crxor $CRD, $CRA, $CRB", IIC_BrCR,
2538 [(set i1:$CRD, (xor i1:$CRA, i1:$CRB))]>;
2540 def CRNOR : XLForm_1<19, 33, (outs crbitrc:$CRD),
2541 (ins crbitrc:$CRA, crbitrc:$CRB),
2542 "crnor $CRD, $CRA, $CRB", IIC_BrCR,
2543 [(set i1:$CRD, (not (or i1:$CRA, i1:$CRB)))]>;
2545 def CREQV : XLForm_1<19, 289, (outs crbitrc:$CRD),
2546 (ins crbitrc:$CRA, crbitrc:$CRB),
2547 "creqv $CRD, $CRA, $CRB", IIC_BrCR,
2548 [(set i1:$CRD, (not (xor i1:$CRA, i1:$CRB)))]>;
2551 def CRANDC : XLForm_1<19, 129, (outs crbitrc:$CRD),
2552 (ins crbitrc:$CRA, crbitrc:$CRB),
2553 "crandc $CRD, $CRA, $CRB", IIC_BrCR,
2554 [(set i1:$CRD, (and i1:$CRA, (not i1:$CRB)))]>;
2556 def CRORC : XLForm_1<19, 417, (outs crbitrc:$CRD),
2557 (ins crbitrc:$CRA, crbitrc:$CRB),
2558 "crorc $CRD, $CRA, $CRB", IIC_BrCR,
2559 [(set i1:$CRD, (or i1:$CRA, (not i1:$CRB)))]>;
2561 let isCodeGenOnly = 1 in {
2562 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
2563 def CRSET : XLForm_1_ext<19, 289, (outs crbitrc:$dst), (ins),
2564 "creqv $dst, $dst, $dst", IIC_BrCR,
2565 [(set i1:$dst, 1)]>;
2567 def CRUNSET: XLForm_1_ext<19, 193, (outs crbitrc:$dst), (ins),
2568 "crxor $dst, $dst, $dst", IIC_BrCR,
2569 [(set i1:$dst, 0)]>;
2572 let Defs = [CR1EQ], CRD = 6 in {
2573 def CR6SET : XLForm_1_ext<19, 289, (outs), (ins),
2574 "creqv 6, 6, 6", IIC_BrCR,
2577 def CR6UNSET: XLForm_1_ext<19, 193, (outs), (ins),
2578 "crxor 6, 6, 6", IIC_BrCR,
2583 // XFX-Form instructions. Instructions that deal with SPRs.
2586 def MFSPR : XFXForm_1<31, 339, (outs gprc:$RT), (ins i32imm:$SPR),
2587 "mfspr $RT, $SPR", IIC_SprMFSPR>;
2588 def MTSPR : XFXForm_1<31, 467, (outs), (ins i32imm:$SPR, gprc:$RT),
2589 "mtspr $SPR, $RT", IIC_SprMTSPR>;
2591 def MFTB : XFXForm_1<31, 371, (outs gprc:$RT), (ins i32imm:$SPR),
2592 "mftb $RT, $SPR", IIC_SprMFTB>;
2594 def MFPMR : XFXForm_1<31, 334, (outs gprc:$RT), (ins i32imm:$SPR),
2595 "mfpmr $RT, $SPR", IIC_SprMFPMR>;
2597 def MTPMR : XFXForm_1<31, 462, (outs), (ins i32imm:$SPR, gprc:$RT),
2598 "mtpmr $SPR, $RT", IIC_SprMTPMR>;
2601 // A pseudo-instruction used to implement the read of the 64-bit cycle counter
2602 // on a 32-bit target.
2603 let hasSideEffects = 1 in
2604 def ReadTB : PPCCustomInserterPseudo<(outs gprc:$lo, gprc:$hi), (ins),
2607 let Uses = [CTR] in {
2608 def MFCTR : XFXForm_1_ext<31, 339, 9, (outs gprc:$rT), (ins),
2609 "mfctr $rT", IIC_SprMFSPR>,
2610 PPC970_DGroup_First, PPC970_Unit_FXU;
2612 let Defs = [CTR], Pattern = [(PPCmtctr i32:$rS)] in {
2613 def MTCTR : XFXForm_7_ext<31, 467, 9, (outs), (ins gprc:$rS),
2614 "mtctr $rS", IIC_SprMTSPR>,
2615 PPC970_DGroup_First, PPC970_Unit_FXU;
2617 let hasSideEffects = 1, isCodeGenOnly = 1, Defs = [CTR] in {
2618 let Pattern = [(int_set_loop_iterations i32:$rS)] in
2619 def MTCTRloop : XFXForm_7_ext<31, 467, 9, (outs), (ins gprc:$rS),
2620 "mtctr $rS", IIC_SprMTSPR>,
2621 PPC970_DGroup_First, PPC970_Unit_FXU;
2624 let Defs = [LR] in {
2625 def MTLR : XFXForm_7_ext<31, 467, 8, (outs), (ins gprc:$rS),
2626 "mtlr $rS", IIC_SprMTSPR>,
2627 PPC970_DGroup_First, PPC970_Unit_FXU;
2629 let Uses = [LR] in {
2630 def MFLR : XFXForm_1_ext<31, 339, 8, (outs gprc:$rT), (ins),
2631 "mflr $rT", IIC_SprMFSPR>,
2632 PPC970_DGroup_First, PPC970_Unit_FXU;
2635 let isCodeGenOnly = 1 in {
2636 // Move to/from VRSAVE: despite being a SPR, the VRSAVE register is renamed
2637 // like a GPR on the PPC970. As such, copies in and out have the same
2638 // performance characteristics as an OR instruction.
2639 def MTVRSAVE : XFXForm_7_ext<31, 467, 256, (outs), (ins gprc:$rS),
2640 "mtspr 256, $rS", IIC_IntGeneral>,
2641 PPC970_DGroup_Single, PPC970_Unit_FXU;
2642 def MFVRSAVE : XFXForm_1_ext<31, 339, 256, (outs gprc:$rT), (ins),
2643 "mfspr $rT, 256", IIC_IntGeneral>,
2644 PPC970_DGroup_First, PPC970_Unit_FXU;
2646 def MTVRSAVEv : XFXForm_7_ext<31, 467, 256,
2647 (outs VRSAVERC:$reg), (ins gprc:$rS),
2648 "mtspr 256, $rS", IIC_IntGeneral>,
2649 PPC970_DGroup_Single, PPC970_Unit_FXU;
2650 def MFVRSAVEv : XFXForm_1_ext<31, 339, 256, (outs gprc:$rT),
2651 (ins VRSAVERC:$reg),
2652 "mfspr $rT, 256", IIC_IntGeneral>,
2653 PPC970_DGroup_First, PPC970_Unit_FXU;
2656 // Aliases for mtvrsave/mfvrsave to mfspr/mtspr.
2657 def : InstAlias<"mtvrsave $rS", (MTVRSAVE gprc:$rS)>;
2658 def : InstAlias<"mfvrsave $rS", (MFVRSAVE gprc:$rS)>;
2660 // SPILL_VRSAVE - Indicate that we're dumping the VRSAVE register,
2661 // so we'll need to scavenge a register for it.
2663 def SPILL_VRSAVE : PPCEmitTimePseudo<(outs), (ins VRSAVERC:$vrsave, memri:$F),
2664 "#SPILL_VRSAVE", []>;
2666 // RESTORE_VRSAVE - Indicate that we're restoring the VRSAVE register (previously
2667 // spilled), so we'll need to scavenge a register for it.
2669 def RESTORE_VRSAVE : PPCEmitTimePseudo<(outs VRSAVERC:$vrsave), (ins memri:$F),
2670 "#RESTORE_VRSAVE", []>;
2672 let hasSideEffects = 0 in {
2673 // mtocrf's input needs to be prepared by shifting by an amount dependent
2674 // on the cr register selected. Thus, post-ra anti-dep breaking must not
2675 // later change that register assignment.
2676 let hasExtraDefRegAllocReq = 1 in {
2677 def MTOCRF: XFXForm_5a<31, 144, (outs crbitm:$FXM), (ins gprc:$ST),
2678 "mtocrf $FXM, $ST", IIC_BrMCRX>,
2679 PPC970_DGroup_First, PPC970_Unit_CRU;
2681 // Similarly to mtocrf, the mask for mtcrf must be prepared in a way that
2682 // is dependent on the cr fields being set.
2683 def MTCRF : XFXForm_5<31, 144, (outs), (ins i32imm:$FXM, gprc:$rS),
2684 "mtcrf $FXM, $rS", IIC_BrMCRX>,
2685 PPC970_MicroCode, PPC970_Unit_CRU;
2686 } // hasExtraDefRegAllocReq = 1
2688 // mfocrf's input needs to be prepared by shifting by an amount dependent
2689 // on the cr register selected. Thus, post-ra anti-dep breaking must not
2690 // later change that register assignment.
2691 let hasExtraSrcRegAllocReq = 1 in {
2692 def MFOCRF: XFXForm_5a<31, 19, (outs gprc:$rT), (ins crbitm:$FXM),
2693 "mfocrf $rT, $FXM", IIC_SprMFCRF>,
2694 PPC970_DGroup_First, PPC970_Unit_CRU;
2696 // Similarly to mfocrf, the mask for mfcrf must be prepared in a way that
2697 // is dependent on the cr fields being copied.
2698 def MFCR : XFXForm_3<31, 19, (outs gprc:$rT), (ins),
2699 "mfcr $rT", IIC_SprMFCR>,
2700 PPC970_MicroCode, PPC970_Unit_CRU;
2701 } // hasExtraSrcRegAllocReq = 1
2703 def MCRXRX : X_BF3<31, 576, (outs crrc:$BF), (ins),
2704 "mcrxrx $BF", IIC_BrMCRX>, Requires<[IsISA3_0]>;
2705 } // hasSideEffects = 0
2707 let Predicates = [HasFPU] in {
2708 // Custom inserter instruction to perform FADD in round-to-zero mode.
2709 let Uses = [RM] in {
2710 def FADDrtz: PPCCustomInserterPseudo<(outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB), "",
2711 [(set f64:$FRT, (PPCfaddrtz f64:$FRA, f64:$FRB))]>;
2714 // The above pseudo gets expanded to make use of the following instructions
2715 // to manipulate FPSCR. Note that FPSCR is not modeled at the DAG level.
2716 let Uses = [RM], Defs = [RM] in {
2717 def MTFSB0 : XForm_43<63, 70, (outs), (ins u5imm:$FM),
2718 "mtfsb0 $FM", IIC_IntMTFSB0, []>,
2719 PPC970_DGroup_Single, PPC970_Unit_FPU;
2720 def MTFSB1 : XForm_43<63, 38, (outs), (ins u5imm:$FM),
2721 "mtfsb1 $FM", IIC_IntMTFSB0, []>,
2722 PPC970_DGroup_Single, PPC970_Unit_FPU;
2723 let isCodeGenOnly = 1 in
2724 def MTFSFb : XFLForm<63, 711, (outs), (ins i32imm:$FM, f8rc:$rT),
2725 "mtfsf $FM, $rT", IIC_IntMTFSB0, []>,
2726 PPC970_DGroup_Single, PPC970_Unit_FPU;
2728 let Uses = [RM] in {
2729 def MFFS : XForm_42<63, 583, (outs f8rc:$rT), (ins),
2730 "mffs $rT", IIC_IntMFFS,
2731 [(set f64:$rT, (PPCmffs))]>,
2732 PPC970_DGroup_Single, PPC970_Unit_FPU;
2735 def MFFSo : XForm_42<63, 583, (outs f8rc:$rT), (ins),
2736 "mffs. $rT", IIC_IntMFFS, []>, isDOT;
2738 def MFFSCE : X_FRT5_XO2_XO3_XO10<63, 0, 1, 583, (outs f8rc:$rT), (ins),
2739 "mffsce $rT", IIC_IntMFFS, []>,
2740 PPC970_DGroup_Single, PPC970_Unit_FPU;
2742 def MFFSCDRN : X_FRT5_XO2_XO3_FRB5_XO10<63, 2, 4, 583, (outs f8rc:$rT),
2743 (ins f8rc:$FRB), "mffscdrn $rT, $FRB",
2745 PPC970_DGroup_Single, PPC970_Unit_FPU;
2747 def MFFSCDRNI : X_FRT5_XO2_XO3_DRM3_XO10<63, 2, 5, 583, (outs f8rc:$rT),
2749 "mffscdrni $rT, $DRM",
2751 PPC970_DGroup_Single, PPC970_Unit_FPU;
2753 def MFFSCRN : X_FRT5_XO2_XO3_FRB5_XO10<63, 2, 6, 583, (outs f8rc:$rT),
2754 (ins f8rc:$FRB), "mffscrn $rT, $FRB",
2756 PPC970_DGroup_Single, PPC970_Unit_FPU;
2758 def MFFSCRNI : X_FRT5_XO2_XO3_RM2_X10<63, 2, 7, 583, (outs f8rc:$rT),
2759 (ins u2imm:$RM), "mffscrni $rT, $RM",
2761 PPC970_DGroup_Single, PPC970_Unit_FPU;
2763 def MFFSL : X_FRT5_XO2_XO3_XO10<63, 3, 0, 583, (outs f8rc:$rT), (ins),
2764 "mffsl $rT", IIC_IntMFFS, []>,
2765 PPC970_DGroup_Single, PPC970_Unit_FPU;
2769 let Predicates = [IsISA3_0] in {
2770 def MODSW : XForm_8<31, 779, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2771 "modsw $rT, $rA, $rB", IIC_IntDivW,
2772 [(set i32:$rT, (srem i32:$rA, i32:$rB))]>;
2773 def MODUW : XForm_8<31, 267, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2774 "moduw $rT, $rA, $rB", IIC_IntDivW,
2775 [(set i32:$rT, (urem i32:$rA, i32:$rB))]>;
2778 let PPC970_Unit = 1, hasSideEffects = 0 in { // FXU Operations.
2779 // XO-Form instructions. Arithmetic instructions that can set overflow bit
2780 let isCommutable = 1 in
2781 defm ADD4 : XOForm_1r<31, 266, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2782 "add", "$rT, $rA, $rB", IIC_IntSimple,
2783 [(set i32:$rT, (add i32:$rA, i32:$rB))]>;
2784 let isCodeGenOnly = 1 in
2785 def ADD4TLS : XOForm_1<31, 266, 0, (outs gprc:$rT), (ins gprc:$rA, tlsreg32:$rB),
2786 "add $rT, $rA, $rB", IIC_IntSimple,
2787 [(set i32:$rT, (add i32:$rA, tglobaltlsaddr:$rB))]>;
2788 let isCommutable = 1 in
2789 defm ADDC : XOForm_1rc<31, 10, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2790 "addc", "$rT, $rA, $rB", IIC_IntGeneral,
2791 [(set i32:$rT, (addc i32:$rA, i32:$rB))]>,
2792 PPC970_DGroup_Cracked;
2794 defm DIVW : XOForm_1rcr<31, 491, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2795 "divw", "$rT, $rA, $rB", IIC_IntDivW,
2796 [(set i32:$rT, (sdiv i32:$rA, i32:$rB))]>;
2797 defm DIVWU : XOForm_1rcr<31, 459, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2798 "divwu", "$rT, $rA, $rB", IIC_IntDivW,
2799 [(set i32:$rT, (udiv i32:$rA, i32:$rB))]>;
2800 def DIVWE : XOForm_1<31, 427, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2801 "divwe $rT, $rA, $rB", IIC_IntDivW,
2802 [(set i32:$rT, (int_ppc_divwe gprc:$rA, gprc:$rB))]>,
2803 Requires<[HasExtDiv]>;
2805 def DIVWEo : XOForm_1<31, 427, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2806 "divwe. $rT, $rA, $rB", IIC_IntDivW,
2807 []>, isDOT, PPC970_DGroup_Cracked, PPC970_DGroup_First,
2808 Requires<[HasExtDiv]>;
2809 def DIVWEU : XOForm_1<31, 395, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2810 "divweu $rT, $rA, $rB", IIC_IntDivW,
2811 [(set i32:$rT, (int_ppc_divweu gprc:$rA, gprc:$rB))]>,
2812 Requires<[HasExtDiv]>;
2814 def DIVWEUo : XOForm_1<31, 395, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2815 "divweu. $rT, $rA, $rB", IIC_IntDivW,
2816 []>, isDOT, PPC970_DGroup_Cracked, PPC970_DGroup_First,
2817 Requires<[HasExtDiv]>;
2818 let isCommutable = 1 in {
2819 defm MULHW : XOForm_1r<31, 75, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2820 "mulhw", "$rT, $rA, $rB", IIC_IntMulHW,
2821 [(set i32:$rT, (mulhs i32:$rA, i32:$rB))]>;
2822 defm MULHWU : XOForm_1r<31, 11, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2823 "mulhwu", "$rT, $rA, $rB", IIC_IntMulHWU,
2824 [(set i32:$rT, (mulhu i32:$rA, i32:$rB))]>;
2825 defm MULLW : XOForm_1r<31, 235, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2826 "mullw", "$rT, $rA, $rB", IIC_IntMulHW,
2827 [(set i32:$rT, (mul i32:$rA, i32:$rB))]>;
2829 defm SUBF : XOForm_1r<31, 40, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2830 "subf", "$rT, $rA, $rB", IIC_IntGeneral,
2831 [(set i32:$rT, (sub i32:$rB, i32:$rA))]>;
2832 defm SUBFC : XOForm_1rc<31, 8, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2833 "subfc", "$rT, $rA, $rB", IIC_IntGeneral,
2834 [(set i32:$rT, (subc i32:$rB, i32:$rA))]>,
2835 PPC970_DGroup_Cracked;
2836 defm NEG : XOForm_3r<31, 104, 0, (outs gprc:$rT), (ins gprc:$rA),
2837 "neg", "$rT, $rA", IIC_IntSimple,
2838 [(set i32:$rT, (ineg i32:$rA))]>;
2839 let Uses = [CARRY] in {
2840 let isCommutable = 1 in
2841 defm ADDE : XOForm_1rc<31, 138, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2842 "adde", "$rT, $rA, $rB", IIC_IntGeneral,
2843 [(set i32:$rT, (adde i32:$rA, i32:$rB))]>;
2844 defm ADDME : XOForm_3rc<31, 234, 0, (outs gprc:$rT), (ins gprc:$rA),
2845 "addme", "$rT, $rA", IIC_IntGeneral,
2846 [(set i32:$rT, (adde i32:$rA, -1))]>;
2847 defm ADDZE : XOForm_3rc<31, 202, 0, (outs gprc:$rT), (ins gprc:$rA),
2848 "addze", "$rT, $rA", IIC_IntGeneral,
2849 [(set i32:$rT, (adde i32:$rA, 0))]>;
2850 defm SUBFE : XOForm_1rc<31, 136, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2851 "subfe", "$rT, $rA, $rB", IIC_IntGeneral,
2852 [(set i32:$rT, (sube i32:$rB, i32:$rA))]>;
2853 defm SUBFME : XOForm_3rc<31, 232, 0, (outs gprc:$rT), (ins gprc:$rA),
2854 "subfme", "$rT, $rA", IIC_IntGeneral,
2855 [(set i32:$rT, (sube -1, i32:$rA))]>;
2856 defm SUBFZE : XOForm_3rc<31, 200, 0, (outs gprc:$rT), (ins gprc:$rA),
2857 "subfze", "$rT, $rA", IIC_IntGeneral,
2858 [(set i32:$rT, (sube 0, i32:$rA))]>;
2862 // A-Form instructions. Most of the instructions executed in the FPU are of
2865 let PPC970_Unit = 3, hasSideEffects = 0, Predicates = [HasFPU] in { // FPU Operations.
2866 let Uses = [RM] in {
2867 let isCommutable = 1 in {
2868 defm FMADD : AForm_1r<63, 29,
2869 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2870 "fmadd", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2871 [(set f64:$FRT, (fma f64:$FRA, f64:$FRC, f64:$FRB))]>;
2872 defm FMADDS : AForm_1r<59, 29,
2873 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2874 "fmadds", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2875 [(set f32:$FRT, (fma f32:$FRA, f32:$FRC, f32:$FRB))]>;
2876 defm FMSUB : AForm_1r<63, 28,
2877 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2878 "fmsub", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2880 (fma f64:$FRA, f64:$FRC, (fneg f64:$FRB)))]>;
2881 defm FMSUBS : AForm_1r<59, 28,
2882 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2883 "fmsubs", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2885 (fma f32:$FRA, f32:$FRC, (fneg f32:$FRB)))]>;
2886 defm FNMADD : AForm_1r<63, 31,
2887 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2888 "fnmadd", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2890 (fneg (fma f64:$FRA, f64:$FRC, f64:$FRB)))]>;
2891 defm FNMADDS : AForm_1r<59, 31,
2892 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2893 "fnmadds", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2895 (fneg (fma f32:$FRA, f32:$FRC, f32:$FRB)))]>;
2896 defm FNMSUB : AForm_1r<63, 30,
2897 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2898 "fnmsub", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2899 [(set f64:$FRT, (fneg (fma f64:$FRA, f64:$FRC,
2900 (fneg f64:$FRB))))]>;
2901 defm FNMSUBS : AForm_1r<59, 30,
2902 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2903 "fnmsubs", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2904 [(set f32:$FRT, (fneg (fma f32:$FRA, f32:$FRC,
2905 (fneg f32:$FRB))))]>;
2908 // FSEL is artificially split into 4 and 8-byte forms for the result. To avoid
2909 // having 4 of these, force the comparison to always be an 8-byte double (code
2910 // should use an FMRSD if the input comparison value really wants to be a float)
2911 // and 4/8 byte forms for the result and operand type..
2912 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2913 defm FSELD : AForm_1r<63, 23,
2914 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2915 "fsel", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2916 [(set f64:$FRT, (PPCfsel f64:$FRA, f64:$FRC, f64:$FRB))]>;
2917 defm FSELS : AForm_1r<63, 23,
2918 (outs f4rc:$FRT), (ins f8rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2919 "fsel", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2920 [(set f32:$FRT, (PPCfsel f64:$FRA, f32:$FRC, f32:$FRB))]>;
2921 let Uses = [RM] in {
2922 let isCommutable = 1 in {
2923 defm FADD : AForm_2r<63, 21,
2924 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB),
2925 "fadd", "$FRT, $FRA, $FRB", IIC_FPAddSub,
2926 [(set f64:$FRT, (fadd f64:$FRA, f64:$FRB))]>;
2927 defm FADDS : AForm_2r<59, 21,
2928 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB),
2929 "fadds", "$FRT, $FRA, $FRB", IIC_FPGeneral,
2930 [(set f32:$FRT, (fadd f32:$FRA, f32:$FRB))]>;
2932 defm FDIV : AForm_2r<63, 18,
2933 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB),
2934 "fdiv", "$FRT, $FRA, $FRB", IIC_FPDivD,
2935 [(set f64:$FRT, (fdiv f64:$FRA, f64:$FRB))]>;
2936 defm FDIVS : AForm_2r<59, 18,
2937 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB),
2938 "fdivs", "$FRT, $FRA, $FRB", IIC_FPDivS,
2939 [(set f32:$FRT, (fdiv f32:$FRA, f32:$FRB))]>;
2940 let isCommutable = 1 in {
2941 defm FMUL : AForm_3r<63, 25,
2942 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC),
2943 "fmul", "$FRT, $FRA, $FRC", IIC_FPFused,
2944 [(set f64:$FRT, (fmul f64:$FRA, f64:$FRC))]>;
2945 defm FMULS : AForm_3r<59, 25,
2946 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC),
2947 "fmuls", "$FRT, $FRA, $FRC", IIC_FPGeneral,
2948 [(set f32:$FRT, (fmul f32:$FRA, f32:$FRC))]>;
2950 defm FSUB : AForm_2r<63, 20,
2951 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB),
2952 "fsub", "$FRT, $FRA, $FRB", IIC_FPAddSub,
2953 [(set f64:$FRT, (fsub f64:$FRA, f64:$FRB))]>;
2954 defm FSUBS : AForm_2r<59, 20,
2955 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB),
2956 "fsubs", "$FRT, $FRA, $FRB", IIC_FPGeneral,
2957 [(set f32:$FRT, (fsub f32:$FRA, f32:$FRB))]>;
2961 let hasSideEffects = 0 in {
2962 let PPC970_Unit = 1 in { // FXU Operations.
2964 def ISEL : AForm_4<31, 15,
2965 (outs gprc:$rT), (ins gprc_nor0:$rA, gprc:$rB, crbitrc:$cond),
2966 "isel $rT, $rA, $rB, $cond", IIC_IntISEL,
2970 let PPC970_Unit = 1 in { // FXU Operations.
2971 // M-Form instructions. rotate and mask instructions.
2973 let isCommutable = 1 in {
2974 // RLWIMI can be commuted if the rotate amount is zero.
2975 defm RLWIMI : MForm_2r<20, (outs gprc:$rA),
2976 (ins gprc:$rSi, gprc:$rS, u5imm:$SH, u5imm:$MB,
2977 u5imm:$ME), "rlwimi", "$rA, $rS, $SH, $MB, $ME",
2978 IIC_IntRotate, []>, PPC970_DGroup_Cracked,
2979 RegConstraint<"$rSi = $rA">, NoEncode<"$rSi">;
2981 let BaseName = "rlwinm" in {
2982 def RLWINM : MForm_2<21,
2983 (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
2984 "rlwinm $rA, $rS, $SH, $MB, $ME", IIC_IntGeneral,
2987 def RLWINMo : MForm_2<21,
2988 (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
2989 "rlwinm. $rA, $rS, $SH, $MB, $ME", IIC_IntGeneral,
2990 []>, isDOT, RecFormRel, PPC970_DGroup_Cracked;
2992 defm RLWNM : MForm_2r<23, (outs gprc:$rA),
2993 (ins gprc:$rS, gprc:$rB, u5imm:$MB, u5imm:$ME),
2994 "rlwnm", "$rA, $rS, $rB, $MB, $ME", IIC_IntGeneral,
2997 } // hasSideEffects = 0
2999 //===----------------------------------------------------------------------===//
3000 // PowerPC Instruction Patterns
3003 // Arbitrary immediate support. Implement in terms of LIS/ORI.
3004 def : Pat<(i32 imm:$imm),
3005 (ORI (LIS (HI16 imm:$imm)), (LO16 imm:$imm))>;
3007 // Implement the 'not' operation with the NOR instruction.
3008 def i32not : OutPatFrag<(ops node:$in),
3010 def : Pat<(not i32:$in),
3013 // ADD an arbitrary immediate.
3014 def : Pat<(add i32:$in, imm:$imm),
3015 (ADDIS (ADDI $in, (LO16 imm:$imm)), (HA16 imm:$imm))>;
3016 // OR an arbitrary immediate.
3017 def : Pat<(or i32:$in, imm:$imm),
3018 (ORIS (ORI $in, (LO16 imm:$imm)), (HI16 imm:$imm))>;
3019 // XOR an arbitrary immediate.
3020 def : Pat<(xor i32:$in, imm:$imm),
3021 (XORIS (XORI $in, (LO16 imm:$imm)), (HI16 imm:$imm))>;
3023 def : Pat<(sub imm32SExt16:$imm, i32:$in),
3024 (SUBFIC $in, imm:$imm)>;
3027 def : Pat<(shl i32:$in, (i32 imm:$imm)),
3028 (RLWINM $in, imm:$imm, 0, (SHL32 imm:$imm))>;
3029 def : Pat<(srl i32:$in, (i32 imm:$imm)),
3030 (RLWINM $in, (SRL32 imm:$imm), imm:$imm, 31)>;
3033 def : Pat<(rotl i32:$in, i32:$sh),
3034 (RLWNM $in, $sh, 0, 31)>;
3035 def : Pat<(rotl i32:$in, (i32 imm:$imm)),
3036 (RLWINM $in, imm:$imm, 0, 31)>;
3039 def : Pat<(and (rotl i32:$in, i32:$sh), maskimm32:$imm),
3040 (RLWNM $in, $sh, (MB maskimm32:$imm), (ME maskimm32:$imm))>;
3043 def : Pat<(PPCcall (i32 tglobaladdr:$dst)),
3044 (BL tglobaladdr:$dst)>;
3046 def : Pat<(PPCcall (i32 texternalsym:$dst)),
3047 (BL texternalsym:$dst)>;
3049 // Calls for AIX only
3050 def : Pat<(PPCcall (i32 mcsym:$dst)),
3052 def : Pat<(PPCcall_nop (i32 mcsym:$dst)),
3053 (BL_NOP mcsym:$dst)>;
3055 def : Pat<(PPCtc_return (i32 tglobaladdr:$dst), imm:$imm),
3056 (TCRETURNdi tglobaladdr:$dst, imm:$imm)>;
3058 def : Pat<(PPCtc_return (i32 texternalsym:$dst), imm:$imm),
3059 (TCRETURNdi texternalsym:$dst, imm:$imm)>;
3061 def : Pat<(PPCtc_return CTRRC:$dst, imm:$imm),
3062 (TCRETURNri CTRRC:$dst, imm:$imm)>;
3066 // Hi and Lo for Darwin Global Addresses.
3067 def : Pat<(PPChi tglobaladdr:$in, 0), (LIS tglobaladdr:$in)>;
3068 def : Pat<(PPClo tglobaladdr:$in, 0), (LI tglobaladdr:$in)>;
3069 def : Pat<(PPChi tconstpool:$in, 0), (LIS tconstpool:$in)>;
3070 def : Pat<(PPClo tconstpool:$in, 0), (LI tconstpool:$in)>;
3071 def : Pat<(PPChi tjumptable:$in, 0), (LIS tjumptable:$in)>;
3072 def : Pat<(PPClo tjumptable:$in, 0), (LI tjumptable:$in)>;
3073 def : Pat<(PPChi tblockaddress:$in, 0), (LIS tblockaddress:$in)>;
3074 def : Pat<(PPClo tblockaddress:$in, 0), (LI tblockaddress:$in)>;
3075 def : Pat<(PPChi tglobaltlsaddr:$g, i32:$in),
3076 (ADDIS $in, tglobaltlsaddr:$g)>;
3077 def : Pat<(PPClo tglobaltlsaddr:$g, i32:$in),
3078 (ADDI $in, tglobaltlsaddr:$g)>;
3079 def : Pat<(add i32:$in, (PPChi tglobaladdr:$g, 0)),
3080 (ADDIS $in, tglobaladdr:$g)>;
3081 def : Pat<(add i32:$in, (PPChi tconstpool:$g, 0)),
3082 (ADDIS $in, tconstpool:$g)>;
3083 def : Pat<(add i32:$in, (PPChi tjumptable:$g, 0)),
3084 (ADDIS $in, tjumptable:$g)>;
3085 def : Pat<(add i32:$in, (PPChi tblockaddress:$g, 0)),
3086 (ADDIS $in, tblockaddress:$g)>;
3088 // Support for thread-local storage.
3089 def PPC32GOT: PPCEmitTimePseudo<(outs gprc:$rD), (ins), "#PPC32GOT",
3090 [(set i32:$rD, (PPCppc32GOT))]>;
3092 // Get the _GLOBAL_OFFSET_TABLE_ in PIC mode.
3093 // This uses two output registers, the first as the real output, the second as a
3094 // temporary register, used internally in code generation.
3095 def PPC32PICGOT: PPCEmitTimePseudo<(outs gprc:$rD, gprc:$rT), (ins), "#PPC32PICGOT",
3096 []>, NoEncode<"$rT">;
3098 def LDgotTprelL32: PPCEmitTimePseudo<(outs gprc:$rD), (ins s16imm:$disp, gprc_nor0:$reg),
3101 (PPCldGotTprelL tglobaltlsaddr:$disp, i32:$reg))]>;
3102 def : Pat<(PPCaddTls i32:$in, tglobaltlsaddr:$g),
3103 (ADD4TLS $in, tglobaltlsaddr:$g)>;
3105 def ADDItlsgdL32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
3108 (PPCaddiTlsgdL i32:$reg, tglobaltlsaddr:$disp))]>;
3109 // LR is a true define, while the rest of the Defs are clobbers. R3 is
3110 // explicitly defined when this op is created, so not mentioned here.
3111 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
3112 Defs = [R0,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
3113 def GETtlsADDR32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc:$reg, tlsgd32:$sym),
3116 (PPCgetTlsAddr i32:$reg, tglobaltlsaddr:$sym))]>;
3117 // Combined op for ADDItlsgdL32 and GETtlsADDR32, late expanded. R3 and LR
3118 // are true defines while the rest of the Defs are clobbers.
3119 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
3120 Defs = [R0,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
3121 def ADDItlsgdLADDR32 : PPCEmitTimePseudo<(outs gprc:$rD),
3122 (ins gprc_nor0:$reg, s16imm:$disp, tlsgd32:$sym),
3123 "#ADDItlsgdLADDR32",
3125 (PPCaddiTlsgdLAddr i32:$reg,
3126 tglobaltlsaddr:$disp,
3127 tglobaltlsaddr:$sym))]>;
3128 def ADDItlsldL32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
3131 (PPCaddiTlsldL i32:$reg, tglobaltlsaddr:$disp))]>;
3132 // LR is a true define, while the rest of the Defs are clobbers. R3 is
3133 // explicitly defined when this op is created, so not mentioned here.
3134 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
3135 Defs = [R0,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
3136 def GETtlsldADDR32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc:$reg, tlsgd32:$sym),
3139 (PPCgetTlsldAddr i32:$reg,
3140 tglobaltlsaddr:$sym))]>;
3141 // Combined op for ADDItlsldL32 and GETtlsADDR32, late expanded. R3 and LR
3142 // are true defines while the rest of the Defs are clobbers.
3143 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
3144 Defs = [R0,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
3145 def ADDItlsldLADDR32 : PPCEmitTimePseudo<(outs gprc:$rD),
3146 (ins gprc_nor0:$reg, s16imm:$disp, tlsgd32:$sym),
3147 "#ADDItlsldLADDR32",
3149 (PPCaddiTlsldLAddr i32:$reg,
3150 tglobaltlsaddr:$disp,
3151 tglobaltlsaddr:$sym))]>;
3152 def ADDIdtprelL32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
3155 (PPCaddiDtprelL i32:$reg, tglobaltlsaddr:$disp))]>;
3156 def ADDISdtprelHA32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
3159 (PPCaddisDtprelHA i32:$reg,
3160 tglobaltlsaddr:$disp))]>;
3162 // Support for Position-independent code
3163 def LWZtoc : PPCEmitTimePseudo<(outs gprc:$rD), (ins tocentry32:$disp, gprc:$reg),
3166 (PPCtoc_entry tglobaladdr:$disp, i32:$reg))]>;
3167 def LWZtocL : PPCEmitTimePseudo<(outs gprc:$rD), (ins tocentry32:$disp, gprc_nor0:$reg),
3170 (PPCtoc_entry tglobaladdr:$disp, i32:$reg))]>;
3171 def ADDIStocHA : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, tocentry32:$disp),
3174 (PPCtoc_entry i32:$reg, tglobaladdr:$disp))]>;
3176 // Get Global (GOT) Base Register offset, from the word immediately preceding
3177 // the function label.
3178 def UpdateGBR : PPCEmitTimePseudo<(outs gprc:$rD, gprc:$rT), (ins gprc:$rI), "#UpdateGBR", []>;
3181 // Standard shifts. These are represented separately from the real shifts above
3182 // so that we can distinguish between shifts that allow 5-bit and 6-bit shift
3184 def : Pat<(sra i32:$rS, i32:$rB),
3186 def : Pat<(srl i32:$rS, i32:$rB),
3188 def : Pat<(shl i32:$rS, i32:$rB),
3191 def : Pat<(zextloadi1 iaddr:$src),
3193 def : Pat<(zextloadi1 xaddr:$src),
3195 def : Pat<(extloadi1 iaddr:$src),
3197 def : Pat<(extloadi1 xaddr:$src),
3199 def : Pat<(extloadi8 iaddr:$src),
3201 def : Pat<(extloadi8 xaddr:$src),
3203 def : Pat<(extloadi16 iaddr:$src),
3205 def : Pat<(extloadi16 xaddr:$src),
3207 let Predicates = [HasFPU] in {
3208 def : Pat<(f64 (extloadf32 iaddr:$src)),
3209 (COPY_TO_REGCLASS (LFS iaddr:$src), F8RC)>;
3210 def : Pat<(f64 (extloadf32 xaddr:$src)),
3211 (COPY_TO_REGCLASS (LFSX xaddr:$src), F8RC)>;
3213 def : Pat<(f64 (fpextend f32:$src)),
3214 (COPY_TO_REGCLASS $src, F8RC)>;
3217 // Only seq_cst fences require the heavyweight sync (SYNC 0).
3218 // All others can use the lightweight sync (SYNC 1).
3219 // source: http://www.cl.cam.ac.uk/~pes20/cpp/cpp0xmappings.html
3220 // The rule for seq_cst is duplicated to work with both 64 bits and 32 bits
3221 // versions of Power.
3222 def : Pat<(atomic_fence (i64 7), (imm)), (SYNC 0)>, Requires<[HasSYNC]>;
3223 def : Pat<(atomic_fence (i32 7), (imm)), (SYNC 0)>, Requires<[HasSYNC]>;
3224 def : Pat<(atomic_fence (imm), (imm)), (SYNC 1)>, Requires<[HasSYNC]>;
3225 def : Pat<(atomic_fence (imm), (imm)), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
3227 let Predicates = [HasFPU] in {
3228 // Additional FNMSUB patterns: -a*c + b == -(a*c - b)
3229 def : Pat<(fma (fneg f64:$A), f64:$C, f64:$B),
3230 (FNMSUB $A, $C, $B)>;
3231 def : Pat<(fma f64:$A, (fneg f64:$C), f64:$B),
3232 (FNMSUB $A, $C, $B)>;
3233 def : Pat<(fma (fneg f32:$A), f32:$C, f32:$B),
3234 (FNMSUBS $A, $C, $B)>;
3235 def : Pat<(fma f32:$A, (fneg f32:$C), f32:$B),
3236 (FNMSUBS $A, $C, $B)>;
3238 // FCOPYSIGN's operand types need not agree.
3239 def : Pat<(fcopysign f64:$frB, f32:$frA),
3240 (FCPSGND (COPY_TO_REGCLASS $frA, F8RC), $frB)>;
3241 def : Pat<(fcopysign f32:$frB, f64:$frA),
3242 (FCPSGNS (COPY_TO_REGCLASS $frA, F4RC), $frB)>;
3245 include "PPCInstrAltivec.td"
3246 include "PPCInstrSPE.td"
3247 include "PPCInstr64Bit.td"
3248 include "PPCInstrVSX.td"
3249 include "PPCInstrQPX.td"
3250 include "PPCInstrHTM.td"
3252 def crnot : OutPatFrag<(ops node:$in),
3254 def : Pat<(not i1:$in),
3257 // Patterns for arithmetic i1 operations.
3258 def : Pat<(add i1:$a, i1:$b),
3260 def : Pat<(sub i1:$a, i1:$b),
3262 def : Pat<(mul i1:$a, i1:$b),
3265 // We're sometimes asked to materialize i1 -1, which is just 1 in this case
3266 // (-1 is used to mean all bits set).
3267 def : Pat<(i1 -1), (CRSET)>;
3269 // i1 extensions, implemented in terms of isel.
3270 def : Pat<(i32 (zext i1:$in)),
3271 (SELECT_I4 $in, (LI 1), (LI 0))>;
3272 def : Pat<(i32 (sext i1:$in)),
3273 (SELECT_I4 $in, (LI -1), (LI 0))>;
3275 def : Pat<(i64 (zext i1:$in)),
3276 (SELECT_I8 $in, (LI8 1), (LI8 0))>;
3277 def : Pat<(i64 (sext i1:$in)),
3278 (SELECT_I8 $in, (LI8 -1), (LI8 0))>;
3280 // FIXME: We should choose either a zext or a sext based on other constants
3282 def : Pat<(i32 (anyext i1:$in)),
3283 (SELECT_I4 $in, (LI 1), (LI 0))>;
3284 def : Pat<(i64 (anyext i1:$in)),
3285 (SELECT_I8 $in, (LI8 1), (LI8 0))>;
3287 // match setcc on i1 variables.
3305 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETLT)),
3307 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETULT)),
3326 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETLE)),
3328 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETULE)),
3331 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETEQ)),
3345 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETGE)),
3347 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETUGE)),
3361 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETGT)),
3363 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETUGT)),
3366 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETNE)),
3369 // match setcc on non-i1 (non-vector) variables. Note that SETUEQ, SETOGE,
3370 // SETOLE, SETONE, SETULT and SETUGT should be expanded by legalize for
3371 // floating-point types.
3373 multiclass CRNotPat<dag pattern, dag result> {
3374 def : Pat<pattern, (crnot result)>;
3375 def : Pat<(not pattern), result>;
3377 // We can also fold the crnot into an extension:
3378 def : Pat<(i32 (zext pattern)),
3379 (SELECT_I4 result, (LI 0), (LI 1))>;
3380 def : Pat<(i32 (sext pattern)),
3381 (SELECT_I4 result, (LI 0), (LI -1))>;
3383 // We can also fold the crnot into an extension:
3384 def : Pat<(i64 (zext pattern)),
3385 (SELECT_I8 result, (LI8 0), (LI8 1))>;
3386 def : Pat<(i64 (sext pattern)),
3387 (SELECT_I8 result, (LI8 0), (LI8 -1))>;
3389 // FIXME: We should choose either a zext or a sext based on other constants
3391 def : Pat<(i32 (anyext pattern)),
3392 (SELECT_I4 result, (LI 0), (LI 1))>;
3394 def : Pat<(i64 (anyext pattern)),
3395 (SELECT_I8 result, (LI8 0), (LI8 1))>;
3398 // FIXME: Because of what seems like a bug in TableGen's type-inference code,
3399 // we need to write imm:$imm in the output patterns below, not just $imm, or
3400 // else the resulting matcher will not correctly add the immediate operand
3401 // (making it a register operand instead).
3404 multiclass ExtSetCCPat<CondCode cc, PatFrag pfrag,
3405 OutPatFrag rfrag, OutPatFrag rfrag8> {
3406 def : Pat<(i32 (zext (i1 (pfrag i32:$s1, cc)))),
3408 def : Pat<(i64 (zext (i1 (pfrag i64:$s1, cc)))),
3410 def : Pat<(i64 (zext (i1 (pfrag i32:$s1, cc)))),
3411 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1), sub_32)>;
3412 def : Pat<(i32 (zext (i1 (pfrag i64:$s1, cc)))),
3413 (EXTRACT_SUBREG (rfrag8 $s1), sub_32)>;
3415 def : Pat<(i32 (anyext (i1 (pfrag i32:$s1, cc)))),
3417 def : Pat<(i64 (anyext (i1 (pfrag i64:$s1, cc)))),
3419 def : Pat<(i64 (anyext (i1 (pfrag i32:$s1, cc)))),
3420 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1), sub_32)>;
3421 def : Pat<(i32 (anyext (i1 (pfrag i64:$s1, cc)))),
3422 (EXTRACT_SUBREG (rfrag8 $s1), sub_32)>;
3425 // Note that we do all inversions below with i(32|64)not, instead of using
3426 // (xori x, 1) because on the A2 nor has single-cycle latency while xori
3427 // has 2-cycle latency.
3429 defm : ExtSetCCPat<SETEQ,
3430 PatFrag<(ops node:$in, node:$cc),
3431 (setcc $in, 0, $cc)>,
3432 OutPatFrag<(ops node:$in),
3433 (RLWINM (CNTLZW $in), 27, 31, 31)>,
3434 OutPatFrag<(ops node:$in),
3435 (RLDICL (CNTLZD $in), 58, 63)> >;
3437 defm : ExtSetCCPat<SETNE,
3438 PatFrag<(ops node:$in, node:$cc),
3439 (setcc $in, 0, $cc)>,
3440 OutPatFrag<(ops node:$in),
3441 (RLWINM (i32not (CNTLZW $in)), 27, 31, 31)>,
3442 OutPatFrag<(ops node:$in),
3443 (RLDICL (i64not (CNTLZD $in)), 58, 63)> >;
3445 defm : ExtSetCCPat<SETLT,
3446 PatFrag<(ops node:$in, node:$cc),
3447 (setcc $in, 0, $cc)>,
3448 OutPatFrag<(ops node:$in),
3449 (RLWINM $in, 1, 31, 31)>,
3450 OutPatFrag<(ops node:$in),
3451 (RLDICL $in, 1, 63)> >;
3453 defm : ExtSetCCPat<SETGE,
3454 PatFrag<(ops node:$in, node:$cc),
3455 (setcc $in, 0, $cc)>,
3456 OutPatFrag<(ops node:$in),
3457 (RLWINM (i32not $in), 1, 31, 31)>,
3458 OutPatFrag<(ops node:$in),
3459 (RLDICL (i64not $in), 1, 63)> >;
3461 defm : ExtSetCCPat<SETGT,
3462 PatFrag<(ops node:$in, node:$cc),
3463 (setcc $in, 0, $cc)>,
3464 OutPatFrag<(ops node:$in),
3465 (RLWINM (ANDC (NEG $in), $in), 1, 31, 31)>,
3466 OutPatFrag<(ops node:$in),
3467 (RLDICL (ANDC8 (NEG8 $in), $in), 1, 63)> >;
3469 defm : ExtSetCCPat<SETLE,
3470 PatFrag<(ops node:$in, node:$cc),
3471 (setcc $in, 0, $cc)>,
3472 OutPatFrag<(ops node:$in),
3473 (RLWINM (ORC $in, (NEG $in)), 1, 31, 31)>,
3474 OutPatFrag<(ops node:$in),
3475 (RLDICL (ORC8 $in, (NEG8 $in)), 1, 63)> >;
3477 defm : ExtSetCCPat<SETLT,
3478 PatFrag<(ops node:$in, node:$cc),
3479 (setcc $in, -1, $cc)>,
3480 OutPatFrag<(ops node:$in),
3481 (RLWINM (AND $in, (ADDI $in, 1)), 1, 31, 31)>,
3482 OutPatFrag<(ops node:$in),
3483 (RLDICL (AND8 $in, (ADDI8 $in, 1)), 1, 63)> >;
3485 defm : ExtSetCCPat<SETGE,
3486 PatFrag<(ops node:$in, node:$cc),
3487 (setcc $in, -1, $cc)>,
3488 OutPatFrag<(ops node:$in),
3489 (RLWINM (NAND $in, (ADDI $in, 1)), 1, 31, 31)>,
3490 OutPatFrag<(ops node:$in),
3491 (RLDICL (NAND8 $in, (ADDI8 $in, 1)), 1, 63)> >;
3493 defm : ExtSetCCPat<SETGT,
3494 PatFrag<(ops node:$in, node:$cc),
3495 (setcc $in, -1, $cc)>,
3496 OutPatFrag<(ops node:$in),
3497 (RLWINM (i32not $in), 1, 31, 31)>,
3498 OutPatFrag<(ops node:$in),
3499 (RLDICL (i64not $in), 1, 63)> >;
3501 defm : ExtSetCCPat<SETLE,
3502 PatFrag<(ops node:$in, node:$cc),
3503 (setcc $in, -1, $cc)>,
3504 OutPatFrag<(ops node:$in),
3505 (RLWINM $in, 1, 31, 31)>,
3506 OutPatFrag<(ops node:$in),
3507 (RLDICL $in, 1, 63)> >;
3509 // An extended SETCC with shift amount.
3510 multiclass ExtSetCCShiftPat<CondCode cc, PatFrag pfrag,
3511 OutPatFrag rfrag, OutPatFrag rfrag8> {
3512 def : Pat<(i32 (zext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
3514 def : Pat<(i64 (zext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
3516 def : Pat<(i64 (zext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
3517 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1, $sa), sub_32)>;
3518 def : Pat<(i32 (zext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
3519 (EXTRACT_SUBREG (rfrag8 $s1, $sa), sub_32)>;
3521 def : Pat<(i32 (anyext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
3523 def : Pat<(i64 (anyext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
3525 def : Pat<(i64 (anyext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
3526 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1, $sa), sub_32)>;
3527 def : Pat<(i32 (anyext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
3528 (EXTRACT_SUBREG (rfrag8 $s1, $sa), sub_32)>;
3531 defm : ExtSetCCShiftPat<SETNE,
3532 PatFrag<(ops node:$in, node:$sa, node:$cc),
3533 (setcc (and $in, (shl 1, $sa)), 0, $cc)>,
3534 OutPatFrag<(ops node:$in, node:$sa),
3535 (RLWNM $in, (SUBFIC $sa, 32), 31, 31)>,
3536 OutPatFrag<(ops node:$in, node:$sa),
3537 (RLDCL $in, (SUBFIC $sa, 64), 63)> >;
3539 defm : ExtSetCCShiftPat<SETEQ,
3540 PatFrag<(ops node:$in, node:$sa, node:$cc),
3541 (setcc (and $in, (shl 1, $sa)), 0, $cc)>,
3542 OutPatFrag<(ops node:$in, node:$sa),
3543 (RLWNM (i32not $in),
3544 (SUBFIC $sa, 32), 31, 31)>,
3545 OutPatFrag<(ops node:$in, node:$sa),
3546 (RLDCL (i64not $in),
3547 (SUBFIC $sa, 64), 63)> >;
3550 def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETULT)),
3551 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_lt)>;
3552 def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETLT)),
3553 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_lt)>;
3554 def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETUGT)),
3555 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_gt)>;
3556 def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETGT)),
3557 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_gt)>;
3558 def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETEQ)),
3559 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_eq)>;
3560 def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETEQ)),
3561 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_eq)>;
3563 // For non-equality comparisons, the default code would materialize the
3564 // constant, then compare against it, like this:
3566 // ori r2, r2, 22136
3569 // Since we are just comparing for equality, we can emit this instead:
3570 // xoris r0,r3,0x1234
3571 // cmplwi cr0,r0,0x5678
3574 def : Pat<(i1 (setcc i32:$s1, imm:$imm, SETEQ)),
3575 (EXTRACT_SUBREG (CMPLWI (XORIS $s1, (HI16 imm:$imm)),
3576 (LO16 imm:$imm)), sub_eq)>;
3578 defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETUGE)),
3579 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_lt)>;
3580 defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETGE)),
3581 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_lt)>;
3582 defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETULE)),
3583 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_gt)>;
3584 defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETLE)),
3585 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_gt)>;
3586 defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETNE)),
3587 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_eq)>;
3588 defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETNE)),
3589 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_eq)>;
3591 defm : CRNotPat<(i1 (setcc i32:$s1, imm:$imm, SETNE)),
3592 (EXTRACT_SUBREG (CMPLWI (XORIS $s1, (HI16 imm:$imm)),
3593 (LO16 imm:$imm)), sub_eq)>;
3595 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETULT)),
3596 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_lt)>;
3597 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETLT)),
3598 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_lt)>;
3599 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETUGT)),
3600 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_gt)>;
3601 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETGT)),
3602 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_gt)>;
3603 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETEQ)),
3604 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_eq)>;
3606 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETUGE)),
3607 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_lt)>;
3608 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETGE)),
3609 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_lt)>;
3610 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETULE)),
3611 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_gt)>;
3612 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETLE)),
3613 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_gt)>;
3614 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETNE)),
3615 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_eq)>;
3618 def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETULT)),
3619 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_lt)>;
3620 def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETLT)),
3621 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_lt)>;
3622 def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETUGT)),
3623 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_gt)>;
3624 def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETGT)),
3625 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_gt)>;
3626 def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETEQ)),
3627 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_eq)>;
3628 def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETEQ)),
3629 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_eq)>;
3631 // For non-equality comparisons, the default code would materialize the
3632 // constant, then compare against it, like this:
3634 // ori r2, r2, 22136
3637 // Since we are just comparing for equality, we can emit this instead:
3638 // xoris r0,r3,0x1234
3639 // cmpldi cr0,r0,0x5678
3642 def : Pat<(i1 (setcc i64:$s1, imm64ZExt32:$imm, SETEQ)),
3643 (EXTRACT_SUBREG (CMPLDI (XORIS8 $s1, (HI16 imm:$imm)),
3644 (LO16 imm:$imm)), sub_eq)>;
3646 defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETUGE)),
3647 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_lt)>;
3648 defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETGE)),
3649 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_lt)>;
3650 defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETULE)),
3651 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_gt)>;
3652 defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETLE)),
3653 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_gt)>;
3654 defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETNE)),
3655 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_eq)>;
3656 defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETNE)),
3657 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_eq)>;
3659 defm : CRNotPat<(i1 (setcc i64:$s1, imm64ZExt32:$imm, SETNE)),
3660 (EXTRACT_SUBREG (CMPLDI (XORIS8 $s1, (HI16 imm:$imm)),
3661 (LO16 imm:$imm)), sub_eq)>;
3663 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETULT)),
3664 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_lt)>;
3665 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETLT)),
3666 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_lt)>;
3667 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETUGT)),
3668 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_gt)>;
3669 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETGT)),
3670 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_gt)>;
3671 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETEQ)),
3672 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_eq)>;
3674 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETUGE)),
3675 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_lt)>;
3676 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETGE)),
3677 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_lt)>;
3678 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETULE)),
3679 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_gt)>;
3680 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETLE)),
3681 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_gt)>;
3682 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETNE)),
3683 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_eq)>;
3686 let Predicates = [HasFPU] in {
3687 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOLT)),
3688 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3689 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETLT)),
3690 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3691 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOGT)),
3692 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3693 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETGT)),
3694 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3695 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOEQ)),
3696 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3697 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETEQ)),
3698 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3699 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETUO)),
3700 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_un)>;
3702 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETUGE)),
3703 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3704 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETGE)),
3705 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3706 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETULE)),
3707 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3708 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETLE)),
3709 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3710 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETUNE)),
3711 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3712 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETNE)),
3713 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3714 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETO)),
3715 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_un)>;
3718 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOLT)),
3719 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3720 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETLT)),
3721 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3722 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOGT)),
3723 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3724 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETGT)),
3725 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3726 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOEQ)),
3727 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3728 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETEQ)),
3729 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3730 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETUO)),
3731 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_un)>;
3733 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETUGE)),
3734 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3735 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETGE)),
3736 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3737 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETULE)),
3738 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3739 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETLE)),
3740 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3741 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETUNE)),
3742 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3743 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETNE)),
3744 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3745 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETO)),
3746 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_un)>;
3749 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETOLT)),
3750 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_lt)>;
3751 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETLT)),
3752 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_lt)>;
3753 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETOGT)),
3754 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_gt)>;
3755 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETGT)),
3756 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_gt)>;
3757 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETOEQ)),
3758 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_eq)>;
3759 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETEQ)),
3760 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_eq)>;
3761 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETUO)),
3762 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_un)>;
3764 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETUGE)),
3765 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_lt)>;
3766 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETGE)),
3767 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_lt)>;
3768 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETULE)),
3769 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_gt)>;
3770 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETLE)),
3771 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_gt)>;
3772 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETUNE)),
3773 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_eq)>;
3774 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETNE)),
3775 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_eq)>;
3776 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETO)),
3777 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_un)>;
3781 // This must be in this file because it relies on patterns defined in this file
3782 // after the inclusion of the instruction sets.
3783 let Predicates = [HasSPE] in {
3785 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOLT)),
3786 (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>;
3787 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETLT)),
3788 (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>;
3789 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOGT)),
3790 (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>;
3791 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETGT)),
3792 (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>;
3793 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOEQ)),
3794 (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>;
3795 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETEQ)),
3796 (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>;
3798 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETUGE)),
3799 (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>;
3800 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETGE)),
3801 (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>;
3802 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETULE)),
3803 (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>;
3804 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETLE)),
3805 (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>;
3806 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETUNE)),
3807 (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>;
3808 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETNE)),
3809 (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>;
3812 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOLT)),
3813 (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>;
3814 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETLT)),
3815 (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>;
3816 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOGT)),
3817 (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>;
3818 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETGT)),
3819 (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>;
3820 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOEQ)),
3821 (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>;
3822 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETEQ)),
3823 (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>;
3825 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETUGE)),
3826 (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>;
3827 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETGE)),
3828 (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>;
3829 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETULE)),
3830 (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>;
3831 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETLE)),
3832 (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>;
3833 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETUNE)),
3834 (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>;
3835 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETNE)),
3836 (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>;
3838 // match select on i1 variables:
3839 def : Pat<(i1 (select i1:$cond, i1:$tval, i1:$fval)),
3840 (CROR (CRAND $cond , $tval),
3841 (CRAND (crnot $cond), $fval))>;
3843 // match selectcc on i1 variables:
3844 // select (lhs == rhs), tval, fval is:
3845 // ((lhs == rhs) & tval) | (!(lhs == rhs) & fval)
3846 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETLT)),
3847 (CROR (CRAND (CRANDC $lhs, $rhs), $tval),
3848 (CRAND (CRORC $rhs, $lhs), $fval))>;
3849 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETULT)),
3850 (CROR (CRAND (CRANDC $rhs, $lhs), $tval),
3851 (CRAND (CRORC $lhs, $rhs), $fval))>;
3852 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETLE)),
3853 (CROR (CRAND (CRORC $lhs, $rhs), $tval),
3854 (CRAND (CRANDC $rhs, $lhs), $fval))>;
3855 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETULE)),
3856 (CROR (CRAND (CRORC $rhs, $lhs), $tval),
3857 (CRAND (CRANDC $lhs, $rhs), $fval))>;
3858 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETEQ)),
3859 (CROR (CRAND (CREQV $lhs, $rhs), $tval),
3860 (CRAND (CRXOR $lhs, $rhs), $fval))>;
3861 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETGE)),
3862 (CROR (CRAND (CRORC $rhs, $lhs), $tval),
3863 (CRAND (CRANDC $lhs, $rhs), $fval))>;
3864 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETUGE)),
3865 (CROR (CRAND (CRORC $lhs, $rhs), $tval),
3866 (CRAND (CRANDC $rhs, $lhs), $fval))>;
3867 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETGT)),
3868 (CROR (CRAND (CRANDC $rhs, $lhs), $tval),
3869 (CRAND (CRORC $lhs, $rhs), $fval))>;
3870 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETUGT)),
3871 (CROR (CRAND (CRANDC $lhs, $rhs), $tval),
3872 (CRAND (CRORC $rhs, $lhs), $fval))>;
3873 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETNE)),
3874 (CROR (CRAND (CREQV $lhs, $rhs), $fval),
3875 (CRAND (CRXOR $lhs, $rhs), $tval))>;
3877 // match selectcc on i1 variables with non-i1 output.
3878 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETLT)),
3879 (SELECT_I4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3880 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETULT)),
3881 (SELECT_I4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3882 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETLE)),
3883 (SELECT_I4 (CRORC $lhs, $rhs), $tval, $fval)>;
3884 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETULE)),
3885 (SELECT_I4 (CRORC $rhs, $lhs), $tval, $fval)>;
3886 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETEQ)),
3887 (SELECT_I4 (CREQV $lhs, $rhs), $tval, $fval)>;
3888 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETGE)),
3889 (SELECT_I4 (CRORC $rhs, $lhs), $tval, $fval)>;
3890 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETUGE)),
3891 (SELECT_I4 (CRORC $lhs, $rhs), $tval, $fval)>;
3892 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETGT)),
3893 (SELECT_I4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3894 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETUGT)),
3895 (SELECT_I4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3896 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETNE)),
3897 (SELECT_I4 (CRXOR $lhs, $rhs), $tval, $fval)>;
3899 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETLT)),
3900 (SELECT_I8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3901 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETULT)),
3902 (SELECT_I8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3903 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETLE)),
3904 (SELECT_I8 (CRORC $lhs, $rhs), $tval, $fval)>;
3905 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETULE)),
3906 (SELECT_I8 (CRORC $rhs, $lhs), $tval, $fval)>;
3907 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETEQ)),
3908 (SELECT_I8 (CREQV $lhs, $rhs), $tval, $fval)>;
3909 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETGE)),
3910 (SELECT_I8 (CRORC $rhs, $lhs), $tval, $fval)>;
3911 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETUGE)),
3912 (SELECT_I8 (CRORC $lhs, $rhs), $tval, $fval)>;
3913 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETGT)),
3914 (SELECT_I8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3915 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETUGT)),
3916 (SELECT_I8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3917 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETNE)),
3918 (SELECT_I8 (CRXOR $lhs, $rhs), $tval, $fval)>;
3920 let Predicates = [HasFPU] in {
3921 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETLT)),
3922 (SELECT_F4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3923 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETULT)),
3924 (SELECT_F4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3925 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETLE)),
3926 (SELECT_F4 (CRORC $lhs, $rhs), $tval, $fval)>;
3927 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETULE)),
3928 (SELECT_F4 (CRORC $rhs, $lhs), $tval, $fval)>;
3929 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETEQ)),
3930 (SELECT_F4 (CREQV $lhs, $rhs), $tval, $fval)>;
3931 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETGE)),
3932 (SELECT_F4 (CRORC $rhs, $lhs), $tval, $fval)>;
3933 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETUGE)),
3934 (SELECT_F4 (CRORC $lhs, $rhs), $tval, $fval)>;
3935 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETGT)),
3936 (SELECT_F4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3937 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETUGT)),
3938 (SELECT_F4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3939 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETNE)),
3940 (SELECT_F4 (CRXOR $lhs, $rhs), $tval, $fval)>;
3942 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETLT)),
3943 (SELECT_F8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3944 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETULT)),
3945 (SELECT_F8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3946 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETLE)),
3947 (SELECT_F8 (CRORC $lhs, $rhs), $tval, $fval)>;
3948 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETULE)),
3949 (SELECT_F8 (CRORC $rhs, $lhs), $tval, $fval)>;
3950 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETEQ)),
3951 (SELECT_F8 (CREQV $lhs, $rhs), $tval, $fval)>;
3952 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETGE)),
3953 (SELECT_F8 (CRORC $rhs, $lhs), $tval, $fval)>;
3954 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETUGE)),
3955 (SELECT_F8 (CRORC $lhs, $rhs), $tval, $fval)>;
3956 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETGT)),
3957 (SELECT_F8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3958 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETUGT)),
3959 (SELECT_F8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3960 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETNE)),
3961 (SELECT_F8 (CRXOR $lhs, $rhs), $tval, $fval)>;
3964 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETLT)),
3965 (SELECT_F16 (CRANDC $lhs, $rhs), $tval, $fval)>;
3966 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETULT)),
3967 (SELECT_F16 (CRANDC $rhs, $lhs), $tval, $fval)>;
3968 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETLE)),
3969 (SELECT_F16 (CRORC $lhs, $rhs), $tval, $fval)>;
3970 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETULE)),
3971 (SELECT_F16 (CRORC $rhs, $lhs), $tval, $fval)>;
3972 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETEQ)),
3973 (SELECT_F16 (CREQV $lhs, $rhs), $tval, $fval)>;
3974 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETGE)),
3975 (SELECT_F16 (CRORC $rhs, $lhs), $tval, $fval)>;
3976 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETUGE)),
3977 (SELECT_F16 (CRORC $lhs, $rhs), $tval, $fval)>;
3978 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETGT)),
3979 (SELECT_F16 (CRANDC $rhs, $lhs), $tval, $fval)>;
3980 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETUGT)),
3981 (SELECT_F16 (CRANDC $lhs, $rhs), $tval, $fval)>;
3982 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETNE)),
3983 (SELECT_F16 (CRXOR $lhs, $rhs), $tval, $fval)>;
3985 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETLT)),
3986 (SELECT_VRRC (CRANDC $lhs, $rhs), $tval, $fval)>;
3987 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETULT)),
3988 (SELECT_VRRC (CRANDC $rhs, $lhs), $tval, $fval)>;
3989 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETLE)),
3990 (SELECT_VRRC (CRORC $lhs, $rhs), $tval, $fval)>;
3991 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETULE)),
3992 (SELECT_VRRC (CRORC $rhs, $lhs), $tval, $fval)>;
3993 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETEQ)),
3994 (SELECT_VRRC (CREQV $lhs, $rhs), $tval, $fval)>;
3995 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETGE)),
3996 (SELECT_VRRC (CRORC $rhs, $lhs), $tval, $fval)>;
3997 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETUGE)),
3998 (SELECT_VRRC (CRORC $lhs, $rhs), $tval, $fval)>;
3999 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETGT)),
4000 (SELECT_VRRC (CRANDC $rhs, $lhs), $tval, $fval)>;
4001 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETUGT)),
4002 (SELECT_VRRC (CRANDC $lhs, $rhs), $tval, $fval)>;
4003 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETNE)),
4004 (SELECT_VRRC (CRXOR $lhs, $rhs), $tval, $fval)>;
4006 def ANDIo_1_EQ_BIT : PPCCustomInserterPseudo<(outs crbitrc:$dst), (ins gprc:$in),
4008 [(set i1:$dst, (trunc (not i32:$in)))]>;
4009 def ANDIo_1_GT_BIT : PPCCustomInserterPseudo<(outs crbitrc:$dst), (ins gprc:$in),
4011 [(set i1:$dst, (trunc i32:$in))]>;
4013 def ANDIo_1_EQ_BIT8 : PPCCustomInserterPseudo<(outs crbitrc:$dst), (ins g8rc:$in),
4015 [(set i1:$dst, (trunc (not i64:$in)))]>;
4016 def ANDIo_1_GT_BIT8 : PPCCustomInserterPseudo<(outs crbitrc:$dst), (ins g8rc:$in),
4018 [(set i1:$dst, (trunc i64:$in))]>;
4020 def : Pat<(i1 (not (trunc i32:$in))),
4021 (ANDIo_1_EQ_BIT $in)>;
4022 def : Pat<(i1 (not (trunc i64:$in))),
4023 (ANDIo_1_EQ_BIT8 $in)>;
4025 //===----------------------------------------------------------------------===//
4026 // PowerPC Instructions used for assembler/disassembler only
4029 // FIXME: For B=0 or B > 8, the registers following RT are used.
4030 // WARNING: Do not add patterns for this instruction without fixing this.
4031 def LSWI : XForm_base_r3xo_memOp<31, 597, (outs gprc:$RT),
4032 (ins gprc:$A, u5imm:$B),
4033 "lswi $RT, $A, $B", IIC_LdStLoad, []>;
4035 // FIXME: For B=0 or B > 8, the registers following RT are used.
4036 // WARNING: Do not add patterns for this instruction without fixing this.
4037 def STSWI : XForm_base_r3xo_memOp<31, 725, (outs),
4038 (ins gprc:$RT, gprc:$A, u5imm:$B),
4039 "stswi $RT, $A, $B", IIC_LdStLoad, []>;
4041 def ISYNC : XLForm_2_ext<19, 150, 0, 0, 0, (outs), (ins),
4042 "isync", IIC_SprISYNC, []>;
4044 def ICBI : XForm_1a<31, 982, (outs), (ins memrr:$src),
4045 "icbi $src", IIC_LdStICBI, []>;
4047 // We used to have EIEIO as value but E[0-9A-Z] is a reserved name
4048 def EnforceIEIO : XForm_24_eieio<31, 854, (outs), (ins),
4049 "eieio", IIC_LdStLoad, []>;
4051 def WAIT : XForm_24_sync<31, 30, (outs), (ins i32imm:$L),
4052 "wait $L", IIC_LdStLoad, []>;
4054 def MBAR : XForm_mbar<31, 854, (outs), (ins u5imm:$MO),
4055 "mbar $MO", IIC_LdStLoad>, Requires<[IsBookE]>;
4057 def MTSR: XForm_sr<31, 210, (outs), (ins gprc:$RS, u4imm:$SR),
4058 "mtsr $SR, $RS", IIC_SprMTSR>;
4060 def MFSR: XForm_sr<31, 595, (outs gprc:$RS), (ins u4imm:$SR),
4061 "mfsr $RS, $SR", IIC_SprMFSR>;
4063 def MTSRIN: XForm_srin<31, 242, (outs), (ins gprc:$RS, gprc:$RB),
4064 "mtsrin $RS, $RB", IIC_SprMTSR>;
4066 def MFSRIN: XForm_srin<31, 659, (outs gprc:$RS), (ins gprc:$RB),
4067 "mfsrin $RS, $RB", IIC_SprMFSR>;
4069 def MTMSR: XForm_mtmsr<31, 146, (outs), (ins gprc:$RS, i32imm:$L),
4070 "mtmsr $RS, $L", IIC_SprMTMSR>;
4072 def WRTEE: XForm_mtmsr<31, 131, (outs), (ins gprc:$RS),
4073 "wrtee $RS", IIC_SprMTMSR>, Requires<[IsBookE]> {
4077 def WRTEEI: I<31, (outs), (ins i1imm:$E), "wrteei $E", IIC_SprMTMSR>,
4078 Requires<[IsBookE]> {
4082 let Inst{21-30} = 163;
4085 def DCCCI : XForm_tlb<454, (outs), (ins gprc:$A, gprc:$B),
4086 "dccci $A, $B", IIC_LdStLoad>, Requires<[IsPPC4xx]>;
4087 def ICCCI : XForm_tlb<966, (outs), (ins gprc:$A, gprc:$B),
4088 "iccci $A, $B", IIC_LdStLoad>, Requires<[IsPPC4xx]>;
4090 def : InstAlias<"dci 0", (DCCCI R0, R0)>, Requires<[IsPPC4xx]>;
4091 def : InstAlias<"dccci", (DCCCI R0, R0)>, Requires<[IsPPC4xx]>;
4092 def : InstAlias<"ici 0", (ICCCI R0, R0)>, Requires<[IsPPC4xx]>;
4093 def : InstAlias<"iccci", (ICCCI R0, R0)>, Requires<[IsPPC4xx]>;
4095 def MFMSR : XForm_rs<31, 83, (outs gprc:$RT), (ins),
4096 "mfmsr $RT", IIC_SprMFMSR, []>;
4098 def MTMSRD : XForm_mtmsr<31, 178, (outs), (ins gprc:$RS, i32imm:$L),
4099 "mtmsrd $RS, $L", IIC_SprMTMSRD>;
4101 def MCRFS : XLForm_3<63, 64, (outs crrc:$BF), (ins crrc:$BFA),
4102 "mcrfs $BF, $BFA", IIC_BrMCR>;
4104 def MTFSFI : XLForm_4<63, 134, (outs crrc:$BF), (ins i32imm:$U, i32imm:$W),
4105 "mtfsfi $BF, $U, $W", IIC_IntMFFS>;
4107 def MTFSFIo : XLForm_4<63, 134, (outs crrc:$BF), (ins i32imm:$U, i32imm:$W),
4108 "mtfsfi. $BF, $U, $W", IIC_IntMFFS>, isDOT;
4110 def : InstAlias<"mtfsfi $BF, $U", (MTFSFI crrc:$BF, i32imm:$U, 0)>;
4111 def : InstAlias<"mtfsfi. $BF, $U", (MTFSFIo crrc:$BF, i32imm:$U, 0)>;
4113 let Predicates = [HasFPU] in {
4114 def MTFSF : XFLForm_1<63, 711, (outs),
4115 (ins i32imm:$FLM, f8rc:$FRB, i32imm:$L, i32imm:$W),
4116 "mtfsf $FLM, $FRB, $L, $W", IIC_IntMFFS, []>;
4117 def MTFSFo : XFLForm_1<63, 711, (outs),
4118 (ins i32imm:$FLM, f8rc:$FRB, i32imm:$L, i32imm:$W),
4119 "mtfsf. $FLM, $FRB, $L, $W", IIC_IntMFFS, []>, isDOT;
4121 def : InstAlias<"mtfsf $FLM, $FRB", (MTFSF i32imm:$FLM, f8rc:$FRB, 0, 0)>;
4122 def : InstAlias<"mtfsf. $FLM, $FRB", (MTFSFo i32imm:$FLM, f8rc:$FRB, 0, 0)>;
4125 def SLBIE : XForm_16b<31, 434, (outs), (ins gprc:$RB),
4126 "slbie $RB", IIC_SprSLBIE, []>;
4128 def SLBMTE : XForm_26<31, 402, (outs), (ins gprc:$RS, gprc:$RB),
4129 "slbmte $RS, $RB", IIC_SprSLBMTE, []>;
4131 def SLBMFEE : XForm_26<31, 915, (outs gprc:$RT), (ins gprc:$RB),
4132 "slbmfee $RT, $RB", IIC_SprSLBMFEE, []>;
4134 def SLBMFEV : XLForm_1_gen<31, 851, (outs gprc:$RT), (ins gprc:$RB),
4135 "slbmfev $RT, $RB", IIC_SprSLBMFEV, []>;
4137 def SLBIA : XForm_0<31, 498, (outs), (ins), "slbia", IIC_SprSLBIA, []>;
4140 def SLBFEEo : XForm_26<31, 979, (outs gprc:$RT), (ins gprc:$RB),
4141 "slbfee. $RT, $RB", IIC_SprSLBFEE, []>, isDOT;
4143 def TLBIA : XForm_0<31, 370, (outs), (ins),
4144 "tlbia", IIC_SprTLBIA, []>;
4146 def TLBSYNC : XForm_0<31, 566, (outs), (ins),
4147 "tlbsync", IIC_SprTLBSYNC, []>;
4149 def TLBIEL : XForm_16b<31, 274, (outs), (ins gprc:$RB),
4150 "tlbiel $RB", IIC_SprTLBIEL, []>;
4152 def TLBLD : XForm_16b<31, 978, (outs), (ins gprc:$RB),
4153 "tlbld $RB", IIC_LdStLoad, []>, Requires<[IsPPC6xx]>;
4154 def TLBLI : XForm_16b<31, 1010, (outs), (ins gprc:$RB),
4155 "tlbli $RB", IIC_LdStLoad, []>, Requires<[IsPPC6xx]>;
4157 def TLBIE : XForm_26<31, 306, (outs), (ins gprc:$RS, gprc:$RB),
4158 "tlbie $RB,$RS", IIC_SprTLBIE, []>;
4160 def TLBSX : XForm_tlb<914, (outs), (ins gprc:$A, gprc:$B), "tlbsx $A, $B",
4161 IIC_LdStLoad>, Requires<[IsBookE]>;
4163 def TLBIVAX : XForm_tlb<786, (outs), (ins gprc:$A, gprc:$B), "tlbivax $A, $B",
4164 IIC_LdStLoad>, Requires<[IsBookE]>;
4166 def TLBRE : XForm_24_eieio<31, 946, (outs), (ins),
4167 "tlbre", IIC_LdStLoad, []>, Requires<[IsBookE]>;
4169 def TLBWE : XForm_24_eieio<31, 978, (outs), (ins),
4170 "tlbwe", IIC_LdStLoad, []>, Requires<[IsBookE]>;
4172 def TLBRE2 : XForm_tlbws<31, 946, (outs gprc:$RS), (ins gprc:$A, i1imm:$WS),
4173 "tlbre $RS, $A, $WS", IIC_LdStLoad, []>, Requires<[IsPPC4xx]>;
4175 def TLBWE2 : XForm_tlbws<31, 978, (outs), (ins gprc:$RS, gprc:$A, i1imm:$WS),
4176 "tlbwe $RS, $A, $WS", IIC_LdStLoad, []>, Requires<[IsPPC4xx]>;
4178 def TLBSX2 : XForm_base_r3xo<31, 914, (outs), (ins gprc:$RST, gprc:$A, gprc:$B),
4179 "tlbsx $RST, $A, $B", IIC_LdStLoad, []>,
4180 Requires<[IsPPC4xx]>;
4181 def TLBSX2D : XForm_base_r3xo<31, 914, (outs),
4182 (ins gprc:$RST, gprc:$A, gprc:$B),
4183 "tlbsx. $RST, $A, $B", IIC_LdStLoad, []>,
4184 Requires<[IsPPC4xx]>, isDOT;
4186 def RFID : XForm_0<19, 18, (outs), (ins), "rfid", IIC_IntRFID, []>;
4188 def RFI : XForm_0<19, 50, (outs), (ins), "rfi", IIC_SprRFI, []>,
4189 Requires<[IsBookE]>;
4190 def RFCI : XForm_0<19, 51, (outs), (ins), "rfci", IIC_BrB, []>,
4191 Requires<[IsBookE]>;
4193 def RFDI : XForm_0<19, 39, (outs), (ins), "rfdi", IIC_BrB, []>,
4195 def RFMCI : XForm_0<19, 38, (outs), (ins), "rfmci", IIC_BrB, []>,
4198 def MFDCR : XFXForm_1<31, 323, (outs gprc:$RT), (ins i32imm:$SPR),
4199 "mfdcr $RT, $SPR", IIC_SprMFSPR>, Requires<[IsPPC4xx]>;
4200 def MTDCR : XFXForm_1<31, 451, (outs), (ins gprc:$RT, i32imm:$SPR),
4201 "mtdcr $SPR, $RT", IIC_SprMTSPR>, Requires<[IsPPC4xx]>;
4203 def HRFID : XLForm_1_np<19, 274, (outs), (ins), "hrfid", IIC_BrB, []>;
4204 def NAP : XLForm_1_np<19, 434, (outs), (ins), "nap", IIC_BrB, []>;
4206 def ATTN : XForm_attn<0, 256, (outs), (ins), "attn", IIC_BrB>;
4208 def LBZCIX : XForm_base_r3xo_memOp<31, 853, (outs gprc:$RST),
4209 (ins gprc:$A, gprc:$B),
4210 "lbzcix $RST, $A, $B", IIC_LdStLoad, []>;
4211 def LHZCIX : XForm_base_r3xo_memOp<31, 821, (outs gprc:$RST),
4212 (ins gprc:$A, gprc:$B),
4213 "lhzcix $RST, $A, $B", IIC_LdStLoad, []>;
4214 def LWZCIX : XForm_base_r3xo_memOp<31, 789, (outs gprc:$RST),
4215 (ins gprc:$A, gprc:$B),
4216 "lwzcix $RST, $A, $B", IIC_LdStLoad, []>;
4217 def LDCIX : XForm_base_r3xo_memOp<31, 885, (outs gprc:$RST),
4218 (ins gprc:$A, gprc:$B),
4219 "ldcix $RST, $A, $B", IIC_LdStLoad, []>;
4221 def STBCIX : XForm_base_r3xo_memOp<31, 981, (outs),
4222 (ins gprc:$RST, gprc:$A, gprc:$B),
4223 "stbcix $RST, $A, $B", IIC_LdStLoad, []>;
4224 def STHCIX : XForm_base_r3xo_memOp<31, 949, (outs),
4225 (ins gprc:$RST, gprc:$A, gprc:$B),
4226 "sthcix $RST, $A, $B", IIC_LdStLoad, []>;
4227 def STWCIX : XForm_base_r3xo_memOp<31, 917, (outs),
4228 (ins gprc:$RST, gprc:$A, gprc:$B),
4229 "stwcix $RST, $A, $B", IIC_LdStLoad, []>;
4230 def STDCIX : XForm_base_r3xo_memOp<31, 1013, (outs),
4231 (ins gprc:$RST, gprc:$A, gprc:$B),
4232 "stdcix $RST, $A, $B", IIC_LdStLoad, []>;
4234 // External PID Load Store Instructions
4236 def LBEPX : XForm_1<31, 95, (outs gprc:$rD), (ins memrr:$src),
4237 "lbepx $rD, $src", IIC_LdStLoad, []>,
4240 def LFDEPX : XForm_25<31, 607, (outs f8rc:$frD), (ins memrr:$src),
4241 "lfdepx $frD, $src", IIC_LdStLFD, []>,
4244 def LHEPX : XForm_1<31, 287, (outs gprc:$rD), (ins memrr:$src),
4245 "lhepx $rD, $src", IIC_LdStLoad, []>,
4248 def LWEPX : XForm_1<31, 31, (outs gprc:$rD), (ins memrr:$src),
4249 "lwepx $rD, $src", IIC_LdStLoad, []>,
4252 def STBEPX : XForm_8<31, 223, (outs), (ins gprc:$rS, memrr:$dst),
4253 "stbepx $rS, $dst", IIC_LdStStore, []>,
4256 def STFDEPX : XForm_28_memOp<31, 735, (outs), (ins f8rc:$frS, memrr:$dst),
4257 "stfdepx $frS, $dst", IIC_LdStSTFD, []>,
4260 def STHEPX : XForm_8<31, 415, (outs), (ins gprc:$rS, memrr:$dst),
4261 "sthepx $rS, $dst", IIC_LdStStore, []>,
4264 def STWEPX : XForm_8<31, 159, (outs), (ins gprc:$rS, memrr:$dst),
4265 "stwepx $rS, $dst", IIC_LdStStore, []>,
4268 def DCBFEP : DCB_Form<127, 0, (outs), (ins memrr:$dst), "dcbfep $dst",
4269 IIC_LdStDCBF, []>, Requires<[IsE500]>;
4271 def DCBSTEP : DCB_Form<63, 0, (outs), (ins memrr:$dst), "dcbstep $dst",
4272 IIC_LdStDCBF, []>, Requires<[IsE500]>;
4274 def DCBTEP : DCB_Form_hint<319, (outs), (ins memrr:$dst, u5imm:$TH),
4275 "dcbtep $TH, $dst", IIC_LdStDCBF, []>,
4278 def DCBTSTEP : DCB_Form_hint<255, (outs), (ins memrr:$dst, u5imm:$TH),
4279 "dcbtstep $TH, $dst", IIC_LdStDCBF, []>,
4282 def DCBZEP : DCB_Form<1023, 0, (outs), (ins memrr:$dst), "dcbzep $dst",
4283 IIC_LdStDCBF, []>, Requires<[IsE500]>;
4285 def DCBZLEP : DCB_Form<1023, 1, (outs), (ins memrr:$dst), "dcbzlep $dst",
4286 IIC_LdStDCBF, []>, Requires<[IsE500]>;
4288 def ICBIEP : XForm_1a<31, 991, (outs), (ins memrr:$src), "icbiep $src",
4289 IIC_LdStICBI, []>, Requires<[IsE500]>;
4291 //===----------------------------------------------------------------------===//
4292 // PowerPC Assembler Instruction Aliases
4295 // Pseudo-instructions for alternate assembly syntax (never used by codegen).
4296 // These are aliases that require C++ handling to convert to the target
4297 // instruction, while InstAliases can be handled directly by tblgen.
4298 class PPCAsmPseudo<string asm, dag iops>
4300 let Namespace = "PPC";
4301 bit PPC64 = 0; // Default value, override with isPPC64
4303 let OutOperandList = (outs);
4304 let InOperandList = iops;
4306 let AsmString = asm;
4307 let isAsmParserOnly = 1;
4309 let hasNoSchedulingInfo = 1;
4312 def : InstAlias<"sc", (SC 0)>;
4314 def : InstAlias<"sync", (SYNC 0)>, Requires<[HasSYNC]>;
4315 def : InstAlias<"msync", (SYNC 0), 0>, Requires<[HasSYNC]>;
4316 def : InstAlias<"lwsync", (SYNC 1)>, Requires<[HasSYNC]>;
4317 def : InstAlias<"ptesync", (SYNC 2)>, Requires<[HasSYNC]>;
4319 def : InstAlias<"wait", (WAIT 0)>;
4320 def : InstAlias<"waitrsv", (WAIT 1)>;
4321 def : InstAlias<"waitimpl", (WAIT 2)>;
4323 def : InstAlias<"mbar", (MBAR 0)>, Requires<[IsBookE]>;
4325 def DCBTx : PPCAsmPseudo<"dcbt $dst", (ins memrr:$dst)>;
4326 def DCBTSTx : PPCAsmPseudo<"dcbtst $dst", (ins memrr:$dst)>;
4328 def DCBTCT : PPCAsmPseudo<"dcbtct $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
4329 def DCBTDS : PPCAsmPseudo<"dcbtds $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
4330 def DCBTT : PPCAsmPseudo<"dcbtt $dst", (ins memrr:$dst)>;
4332 def DCBTSTCT : PPCAsmPseudo<"dcbtstct $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
4333 def DCBTSTDS : PPCAsmPseudo<"dcbtstds $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
4334 def DCBTSTT : PPCAsmPseudo<"dcbtstt $dst", (ins memrr:$dst)>;
4336 def DCBFx : PPCAsmPseudo<"dcbf $dst", (ins memrr:$dst)>;
4337 def DCBFL : PPCAsmPseudo<"dcbfl $dst", (ins memrr:$dst)>;
4338 def DCBFLP : PPCAsmPseudo<"dcbflp $dst", (ins memrr:$dst)>;
4340 def : InstAlias<"crset $bx", (CREQV crbitrc:$bx, crbitrc:$bx, crbitrc:$bx)>;
4341 def : InstAlias<"crclr $bx", (CRXOR crbitrc:$bx, crbitrc:$bx, crbitrc:$bx)>;
4342 def : InstAlias<"crmove $bx, $by", (CROR crbitrc:$bx, crbitrc:$by, crbitrc:$by)>;
4343 def : InstAlias<"crnot $bx, $by", (CRNOR crbitrc:$bx, crbitrc:$by, crbitrc:$by)>;
4345 def : InstAlias<"mtxer $Rx", (MTSPR 1, gprc:$Rx)>;
4346 def : InstAlias<"mfxer $Rx", (MFSPR gprc:$Rx, 1)>;
4348 def : InstAlias<"mfrtcu $Rx", (MFSPR gprc:$Rx, 4)>;
4349 def : InstAlias<"mfrtcl $Rx", (MFSPR gprc:$Rx, 5)>;
4351 def : InstAlias<"mtdscr $Rx", (MTSPR 17, gprc:$Rx)>;
4352 def : InstAlias<"mfdscr $Rx", (MFSPR gprc:$Rx, 17)>;
4354 def : InstAlias<"mtdsisr $Rx", (MTSPR 18, gprc:$Rx)>;
4355 def : InstAlias<"mfdsisr $Rx", (MFSPR gprc:$Rx, 18)>;
4357 def : InstAlias<"mtdar $Rx", (MTSPR 19, gprc:$Rx)>;
4358 def : InstAlias<"mfdar $Rx", (MFSPR gprc:$Rx, 19)>;
4360 def : InstAlias<"mtdec $Rx", (MTSPR 22, gprc:$Rx)>;
4361 def : InstAlias<"mfdec $Rx", (MFSPR gprc:$Rx, 22)>;
4363 def : InstAlias<"mtsdr1 $Rx", (MTSPR 25, gprc:$Rx)>;
4364 def : InstAlias<"mfsdr1 $Rx", (MFSPR gprc:$Rx, 25)>;
4366 def : InstAlias<"mtsrr0 $Rx", (MTSPR 26, gprc:$Rx)>;
4367 def : InstAlias<"mfsrr0 $Rx", (MFSPR gprc:$Rx, 26)>;
4369 def : InstAlias<"mtsrr1 $Rx", (MTSPR 27, gprc:$Rx)>;
4370 def : InstAlias<"mfsrr1 $Rx", (MFSPR gprc:$Rx, 27)>;
4372 def : InstAlias<"mtsrr2 $Rx", (MTSPR 990, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4373 def : InstAlias<"mfsrr2 $Rx", (MFSPR gprc:$Rx, 990)>, Requires<[IsPPC4xx]>;
4375 def : InstAlias<"mtsrr3 $Rx", (MTSPR 991, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4376 def : InstAlias<"mfsrr3 $Rx", (MFSPR gprc:$Rx, 991)>, Requires<[IsPPC4xx]>;
4378 def : InstAlias<"mtcfar $Rx", (MTSPR 28, gprc:$Rx)>;
4379 def : InstAlias<"mfcfar $Rx", (MFSPR gprc:$Rx, 28)>;
4381 def : InstAlias<"mtamr $Rx", (MTSPR 29, gprc:$Rx)>;
4382 def : InstAlias<"mfamr $Rx", (MFSPR gprc:$Rx, 29)>;
4384 def : InstAlias<"mtpid $Rx", (MTSPR 48, gprc:$Rx)>, Requires<[IsBookE]>;
4385 def : InstAlias<"mfpid $Rx", (MFSPR gprc:$Rx, 48)>, Requires<[IsBookE]>;
4387 def : InstAlias<"mftb $Rx", (MFTB gprc:$Rx, 268)>;
4388 def : InstAlias<"mftbl $Rx", (MFTB gprc:$Rx, 268)>;
4389 def : InstAlias<"mftbu $Rx", (MFTB gprc:$Rx, 269)>;
4391 def : InstAlias<"mttbl $Rx", (MTSPR 284, gprc:$Rx)>;
4392 def : InstAlias<"mttbu $Rx", (MTSPR 285, gprc:$Rx)>;
4394 def : InstAlias<"mftblo $Rx", (MFSPR gprc:$Rx, 989)>, Requires<[IsPPC4xx]>;
4395 def : InstAlias<"mttblo $Rx", (MTSPR 989, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4396 def : InstAlias<"mftbhi $Rx", (MFSPR gprc:$Rx, 988)>, Requires<[IsPPC4xx]>;
4397 def : InstAlias<"mttbhi $Rx", (MTSPR 988, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4399 def : InstAlias<"xnop", (XORI R0, R0, 0)>;
4401 def : InstAlias<"mr $rA, $rB", (OR8 g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
4402 def : InstAlias<"mr. $rA, $rB", (OR8o g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
4404 def : InstAlias<"not $rA, $rB", (NOR8 g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
4405 def : InstAlias<"not. $rA, $rB", (NOR8o g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
4407 def : InstAlias<"mtcr $rA", (MTCRF8 255, g8rc:$rA)>;
4409 foreach BATR = 0-3 in {
4410 def : InstAlias<"mtdbatu "#BATR#", $Rx",
4411 (MTSPR !add(BATR, !add(BATR, 536)), gprc:$Rx)>,
4412 Requires<[IsPPC6xx]>;
4413 def : InstAlias<"mfdbatu $Rx, "#BATR,
4414 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 536)))>,
4415 Requires<[IsPPC6xx]>;
4416 def : InstAlias<"mtdbatl "#BATR#", $Rx",
4417 (MTSPR !add(BATR, !add(BATR, 537)), gprc:$Rx)>,
4418 Requires<[IsPPC6xx]>;
4419 def : InstAlias<"mfdbatl $Rx, "#BATR,
4420 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 537)))>,
4421 Requires<[IsPPC6xx]>;
4422 def : InstAlias<"mtibatu "#BATR#", $Rx",
4423 (MTSPR !add(BATR, !add(BATR, 528)), gprc:$Rx)>,
4424 Requires<[IsPPC6xx]>;
4425 def : InstAlias<"mfibatu $Rx, "#BATR,
4426 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 528)))>,
4427 Requires<[IsPPC6xx]>;
4428 def : InstAlias<"mtibatl "#BATR#", $Rx",
4429 (MTSPR !add(BATR, !add(BATR, 529)), gprc:$Rx)>,
4430 Requires<[IsPPC6xx]>;
4431 def : InstAlias<"mfibatl $Rx, "#BATR,
4432 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 529)))>,
4433 Requires<[IsPPC6xx]>;
4436 foreach BR = 0-7 in {
4437 def : InstAlias<"mfbr"#BR#" $Rx",
4438 (MFDCR gprc:$Rx, !add(BR, 0x80))>,
4439 Requires<[IsPPC4xx]>;
4440 def : InstAlias<"mtbr"#BR#" $Rx",
4441 (MTDCR gprc:$Rx, !add(BR, 0x80))>,
4442 Requires<[IsPPC4xx]>;
4445 def : InstAlias<"mtdccr $Rx", (MTSPR 1018, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4446 def : InstAlias<"mfdccr $Rx", (MFSPR gprc:$Rx, 1018)>, Requires<[IsPPC4xx]>;
4448 def : InstAlias<"mticcr $Rx", (MTSPR 1019, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4449 def : InstAlias<"mficcr $Rx", (MFSPR gprc:$Rx, 1019)>, Requires<[IsPPC4xx]>;
4451 def : InstAlias<"mtdear $Rx", (MTSPR 981, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4452 def : InstAlias<"mfdear $Rx", (MFSPR gprc:$Rx, 981)>, Requires<[IsPPC4xx]>;
4454 def : InstAlias<"mtesr $Rx", (MTSPR 980, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4455 def : InstAlias<"mfesr $Rx", (MFSPR gprc:$Rx, 980)>, Requires<[IsPPC4xx]>;
4457 def : InstAlias<"mfspefscr $Rx", (MFSPR gprc:$Rx, 512)>;
4458 def : InstAlias<"mtspefscr $Rx", (MTSPR 512, gprc:$Rx)>;
4460 def : InstAlias<"mttcr $Rx", (MTSPR 986, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4461 def : InstAlias<"mftcr $Rx", (MFSPR gprc:$Rx, 986)>, Requires<[IsPPC4xx]>;
4463 def LAx : PPCAsmPseudo<"la $rA, $addr", (ins gprc:$rA, memri:$addr)>;
4465 def SUBI : PPCAsmPseudo<"subi $rA, $rB, $imm",
4466 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4467 def SUBIS : PPCAsmPseudo<"subis $rA, $rB, $imm",
4468 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4469 def SUBIC : PPCAsmPseudo<"subic $rA, $rB, $imm",
4470 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4471 def SUBICo : PPCAsmPseudo<"subic. $rA, $rB, $imm",
4472 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4474 def : InstAlias<"sub $rA, $rB, $rC", (SUBF8 g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
4475 def : InstAlias<"sub. $rA, $rB, $rC", (SUBF8o g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
4476 def : InstAlias<"subc $rA, $rB, $rC", (SUBFC8 g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
4477 def : InstAlias<"subc. $rA, $rB, $rC", (SUBFC8o g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
4479 def : InstAlias<"mtmsrd $RS", (MTMSRD gprc:$RS, 0)>;
4480 def : InstAlias<"mtmsr $RS", (MTMSR gprc:$RS, 0)>;
4482 def : InstAlias<"mfasr $RT", (MFSPR gprc:$RT, 280)>;
4483 def : InstAlias<"mtasr $RT", (MTSPR 280, gprc:$RT)>;
4485 foreach SPRG = 0-3 in {
4486 def : InstAlias<"mfsprg $RT, "#SPRG, (MFSPR gprc:$RT, !add(SPRG, 272))>;
4487 def : InstAlias<"mfsprg"#SPRG#" $RT", (MFSPR gprc:$RT, !add(SPRG, 272))>;
4488 def : InstAlias<"mtsprg "#SPRG#", $RT", (MTSPR !add(SPRG, 272), gprc:$RT)>;
4489 def : InstAlias<"mtsprg"#SPRG#" $RT", (MTSPR !add(SPRG, 272), gprc:$RT)>;
4491 foreach SPRG = 4-7 in {
4492 def : InstAlias<"mfsprg $RT, "#SPRG, (MFSPR gprc:$RT, !add(SPRG, 256))>,
4493 Requires<[IsBookE]>;
4494 def : InstAlias<"mfsprg"#SPRG#" $RT", (MFSPR gprc:$RT, !add(SPRG, 256))>,
4495 Requires<[IsBookE]>;
4496 def : InstAlias<"mtsprg "#SPRG#", $RT", (MTSPR !add(SPRG, 256), gprc:$RT)>,
4497 Requires<[IsBookE]>;
4498 def : InstAlias<"mtsprg"#SPRG#" $RT", (MTSPR !add(SPRG, 256), gprc:$RT)>,
4499 Requires<[IsBookE]>;
4502 def : InstAlias<"mtasr $RS", (MTSPR 280, gprc:$RS)>;
4504 def : InstAlias<"mfdec $RT", (MFSPR gprc:$RT, 22)>;
4505 def : InstAlias<"mtdec $RT", (MTSPR 22, gprc:$RT)>;
4507 def : InstAlias<"mfpvr $RT", (MFSPR gprc:$RT, 287)>;
4509 def : InstAlias<"mfsdr1 $RT", (MFSPR gprc:$RT, 25)>;
4510 def : InstAlias<"mtsdr1 $RT", (MTSPR 25, gprc:$RT)>;
4512 def : InstAlias<"mfsrr0 $RT", (MFSPR gprc:$RT, 26)>;
4513 def : InstAlias<"mfsrr1 $RT", (MFSPR gprc:$RT, 27)>;
4514 def : InstAlias<"mtsrr0 $RT", (MTSPR 26, gprc:$RT)>;
4515 def : InstAlias<"mtsrr1 $RT", (MTSPR 27, gprc:$RT)>;
4517 def : InstAlias<"tlbie $RB", (TLBIE R0, gprc:$RB)>;
4519 def : InstAlias<"tlbrehi $RS, $A", (TLBRE2 gprc:$RS, gprc:$A, 0)>,
4520 Requires<[IsPPC4xx]>;
4521 def : InstAlias<"tlbrelo $RS, $A", (TLBRE2 gprc:$RS, gprc:$A, 1)>,
4522 Requires<[IsPPC4xx]>;
4523 def : InstAlias<"tlbwehi $RS, $A", (TLBWE2 gprc:$RS, gprc:$A, 0)>,
4524 Requires<[IsPPC4xx]>;
4525 def : InstAlias<"tlbwelo $RS, $A", (TLBWE2 gprc:$RS, gprc:$A, 1)>,
4526 Requires<[IsPPC4xx]>;
4528 def EXTLWI : PPCAsmPseudo<"extlwi $rA, $rS, $n, $b",
4529 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4530 def EXTLWIo : PPCAsmPseudo<"extlwi. $rA, $rS, $n, $b",
4531 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4532 def EXTRWI : PPCAsmPseudo<"extrwi $rA, $rS, $n, $b",
4533 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4534 def EXTRWIo : PPCAsmPseudo<"extrwi. $rA, $rS, $n, $b",
4535 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4536 def INSLWI : PPCAsmPseudo<"inslwi $rA, $rS, $n, $b",
4537 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4538 def INSLWIo : PPCAsmPseudo<"inslwi. $rA, $rS, $n, $b",
4539 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4540 def INSRWI : PPCAsmPseudo<"insrwi $rA, $rS, $n, $b",
4541 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4542 def INSRWIo : PPCAsmPseudo<"insrwi. $rA, $rS, $n, $b",
4543 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4544 def ROTRWI : PPCAsmPseudo<"rotrwi $rA, $rS, $n",
4545 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4546 def ROTRWIo : PPCAsmPseudo<"rotrwi. $rA, $rS, $n",
4547 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4548 def SLWI : PPCAsmPseudo<"slwi $rA, $rS, $n",
4549 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4550 def SLWIo : PPCAsmPseudo<"slwi. $rA, $rS, $n",
4551 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4552 def SRWI : PPCAsmPseudo<"srwi $rA, $rS, $n",
4553 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4554 def SRWIo : PPCAsmPseudo<"srwi. $rA, $rS, $n",
4555 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4556 def CLRRWI : PPCAsmPseudo<"clrrwi $rA, $rS, $n",
4557 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4558 def CLRRWIo : PPCAsmPseudo<"clrrwi. $rA, $rS, $n",
4559 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4560 def CLRLSLWI : PPCAsmPseudo<"clrlslwi $rA, $rS, $b, $n",
4561 (ins gprc:$rA, gprc:$rS, u5imm:$b, u5imm:$n)>;
4562 def CLRLSLWIo : PPCAsmPseudo<"clrlslwi. $rA, $rS, $b, $n",
4563 (ins gprc:$rA, gprc:$rS, u5imm:$b, u5imm:$n)>;
4565 def : InstAlias<"rotlwi $rA, $rS, $n", (RLWINM gprc:$rA, gprc:$rS, u5imm:$n, 0, 31)>;
4566 def : InstAlias<"rotlwi. $rA, $rS, $n", (RLWINMo gprc:$rA, gprc:$rS, u5imm:$n, 0, 31)>;
4567 def : InstAlias<"rotlw $rA, $rS, $rB", (RLWNM gprc:$rA, gprc:$rS, gprc:$rB, 0, 31)>;
4568 def : InstAlias<"rotlw. $rA, $rS, $rB", (RLWNMo gprc:$rA, gprc:$rS, gprc:$rB, 0, 31)>;
4569 def : InstAlias<"clrlwi $rA, $rS, $n", (RLWINM gprc:$rA, gprc:$rS, 0, u5imm:$n, 31)>;
4570 def : InstAlias<"clrlwi. $rA, $rS, $n", (RLWINMo gprc:$rA, gprc:$rS, 0, u5imm:$n, 31)>;
4572 def : InstAlias<"cntlzw $rA, $rS", (CNTLZW gprc:$rA, gprc:$rS)>;
4573 def : InstAlias<"cntlzw. $rA, $rS", (CNTLZWo gprc:$rA, gprc:$rS)>;
4574 // The POWER variant
4575 def : MnemonicAlias<"cntlz", "cntlzw">;
4576 def : MnemonicAlias<"cntlz.", "cntlzw.">;
4578 def EXTLDI : PPCAsmPseudo<"extldi $rA, $rS, $n, $b",
4579 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4580 def EXTLDIo : PPCAsmPseudo<"extldi. $rA, $rS, $n, $b",
4581 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4582 def EXTRDI : PPCAsmPseudo<"extrdi $rA, $rS, $n, $b",
4583 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4584 def EXTRDIo : PPCAsmPseudo<"extrdi. $rA, $rS, $n, $b",
4585 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4586 def INSRDI : PPCAsmPseudo<"insrdi $rA, $rS, $n, $b",
4587 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4588 def INSRDIo : PPCAsmPseudo<"insrdi. $rA, $rS, $n, $b",
4589 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4590 def ROTRDI : PPCAsmPseudo<"rotrdi $rA, $rS, $n",
4591 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4592 def ROTRDIo : PPCAsmPseudo<"rotrdi. $rA, $rS, $n",
4593 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4594 def SLDI : PPCAsmPseudo<"sldi $rA, $rS, $n",
4595 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4596 def SLDIo : PPCAsmPseudo<"sldi. $rA, $rS, $n",
4597 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4598 def SRDI : PPCAsmPseudo<"srdi $rA, $rS, $n",
4599 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4600 def SRDIo : PPCAsmPseudo<"srdi. $rA, $rS, $n",
4601 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4602 def CLRRDI : PPCAsmPseudo<"clrrdi $rA, $rS, $n",
4603 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4604 def CLRRDIo : PPCAsmPseudo<"clrrdi. $rA, $rS, $n",
4605 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4606 def CLRLSLDI : PPCAsmPseudo<"clrlsldi $rA, $rS, $b, $n",
4607 (ins g8rc:$rA, g8rc:$rS, u6imm:$b, u6imm:$n)>;
4608 def CLRLSLDIo : PPCAsmPseudo<"clrlsldi. $rA, $rS, $b, $n",
4609 (ins g8rc:$rA, g8rc:$rS, u6imm:$b, u6imm:$n)>;
4610 def SUBPCIS : PPCAsmPseudo<"subpcis $RT, $D", (ins g8rc:$RT, s16imm:$D)>;
4612 def : InstAlias<"rotldi $rA, $rS, $n", (RLDICL g8rc:$rA, g8rc:$rS, u6imm:$n, 0)>;
4613 def : InstAlias<"rotldi. $rA, $rS, $n", (RLDICLo g8rc:$rA, g8rc:$rS, u6imm:$n, 0)>;
4614 def : InstAlias<"rotld $rA, $rS, $rB", (RLDCL g8rc:$rA, g8rc:$rS, gprc:$rB, 0)>;
4615 def : InstAlias<"rotld. $rA, $rS, $rB", (RLDCLo g8rc:$rA, g8rc:$rS, gprc:$rB, 0)>;
4616 def : InstAlias<"clrldi $rA, $rS, $n", (RLDICL g8rc:$rA, g8rc:$rS, 0, u6imm:$n)>;
4617 def : InstAlias<"clrldi $rA, $rS, $n",
4618 (RLDICL_32_64 g8rc:$rA, gprc:$rS, 0, u6imm:$n)>;
4619 def : InstAlias<"clrldi. $rA, $rS, $n", (RLDICLo g8rc:$rA, g8rc:$rS, 0, u6imm:$n)>;
4620 def : InstAlias<"lnia $RT", (ADDPCIS g8rc:$RT, 0)>;
4622 def RLWINMbm : PPCAsmPseudo<"rlwinm $rA, $rS, $n, $b",
4623 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4624 def RLWINMobm : PPCAsmPseudo<"rlwinm. $rA, $rS, $n, $b",
4625 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4626 def RLWIMIbm : PPCAsmPseudo<"rlwimi $rA, $rS, $n, $b",
4627 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4628 def RLWIMIobm : PPCAsmPseudo<"rlwimi. $rA, $rS, $n, $b",
4629 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4630 def RLWNMbm : PPCAsmPseudo<"rlwnm $rA, $rS, $n, $b",
4631 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4632 def RLWNMobm : PPCAsmPseudo<"rlwnm. $rA, $rS, $n, $b",
4633 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4635 // These generic branch instruction forms are used for the assembler parser only.
4636 // Defs and Uses are conservative, since we don't know the BO value.
4637 let PPC970_Unit = 7, isBranch = 1 in {
4638 let Defs = [CTR], Uses = [CTR, RM] in {
4639 def gBC : BForm_3<16, 0, 0, (outs),
4640 (ins u5imm:$bo, crbitrc:$bi, condbrtarget:$dst),
4641 "bc $bo, $bi, $dst">;
4642 def gBCA : BForm_3<16, 1, 0, (outs),
4643 (ins u5imm:$bo, crbitrc:$bi, abscondbrtarget:$dst),
4644 "bca $bo, $bi, $dst">;
4645 let isAsmParserOnly = 1 in {
4646 def gBCat : BForm_3_at<16, 0, 0, (outs),
4647 (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
4649 "bc$at $bo, $bi, $dst">;
4650 def gBCAat : BForm_3_at<16, 1, 0, (outs),
4651 (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
4652 abscondbrtarget:$dst),
4653 "bca$at $bo, $bi, $dst">;
4654 } // isAsmParserOnly = 1
4656 let Defs = [LR, CTR], Uses = [CTR, RM] in {
4657 def gBCL : BForm_3<16, 0, 1, (outs),
4658 (ins u5imm:$bo, crbitrc:$bi, condbrtarget:$dst),
4659 "bcl $bo, $bi, $dst">;
4660 def gBCLA : BForm_3<16, 1, 1, (outs),
4661 (ins u5imm:$bo, crbitrc:$bi, abscondbrtarget:$dst),
4662 "bcla $bo, $bi, $dst">;
4663 let isAsmParserOnly = 1 in {
4664 def gBCLat : BForm_3_at<16, 0, 1, (outs),
4665 (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
4667 "bcl$at $bo, $bi, $dst">;
4668 def gBCLAat : BForm_3_at<16, 1, 1, (outs),
4669 (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
4670 abscondbrtarget:$dst),
4671 "bcla$at $bo, $bi, $dst">;
4672 } // // isAsmParserOnly = 1
4674 let Defs = [CTR], Uses = [CTR, LR, RM] in
4675 def gBCLR : XLForm_2<19, 16, 0, (outs),
4676 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
4677 "bclr $bo, $bi, $bh", IIC_BrB, []>;
4678 let Defs = [LR, CTR], Uses = [CTR, LR, RM] in
4679 def gBCLRL : XLForm_2<19, 16, 1, (outs),
4680 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
4681 "bclrl $bo, $bi, $bh", IIC_BrB, []>;
4682 let Defs = [CTR], Uses = [CTR, LR, RM] in
4683 def gBCCTR : XLForm_2<19, 528, 0, (outs),
4684 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
4685 "bcctr $bo, $bi, $bh", IIC_BrB, []>;
4686 let Defs = [LR, CTR], Uses = [CTR, LR, RM] in
4687 def gBCCTRL : XLForm_2<19, 528, 1, (outs),
4688 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
4689 "bcctrl $bo, $bi, $bh", IIC_BrB, []>;
4692 multiclass BranchSimpleMnemonicAT<string pm, int at> {
4693 def : InstAlias<"bc"#pm#" $bo, $bi, $dst", (gBCat u5imm:$bo, at, crbitrc:$bi,
4694 condbrtarget:$dst)>;
4695 def : InstAlias<"bca"#pm#" $bo, $bi, $dst", (gBCAat u5imm:$bo, at, crbitrc:$bi,
4696 condbrtarget:$dst)>;
4697 def : InstAlias<"bcl"#pm#" $bo, $bi, $dst", (gBCLat u5imm:$bo, at, crbitrc:$bi,
4698 condbrtarget:$dst)>;
4699 def : InstAlias<"bcla"#pm#" $bo, $bi, $dst", (gBCLAat u5imm:$bo, at, crbitrc:$bi,
4700 condbrtarget:$dst)>;
4702 defm : BranchSimpleMnemonicAT<"+", 3>;
4703 defm : BranchSimpleMnemonicAT<"-", 2>;
4705 def : InstAlias<"bclr $bo, $bi", (gBCLR u5imm:$bo, crbitrc:$bi, 0)>;
4706 def : InstAlias<"bclrl $bo, $bi", (gBCLRL u5imm:$bo, crbitrc:$bi, 0)>;
4707 def : InstAlias<"bcctr $bo, $bi", (gBCCTR u5imm:$bo, crbitrc:$bi, 0)>;
4708 def : InstAlias<"bcctrl $bo, $bi", (gBCCTRL u5imm:$bo, crbitrc:$bi, 0)>;
4710 multiclass BranchSimpleMnemonic1<string name, string pm, int bo> {
4711 def : InstAlias<"b"#name#pm#" $bi, $dst", (gBC bo, crbitrc:$bi, condbrtarget:$dst)>;
4712 def : InstAlias<"b"#name#"a"#pm#" $bi, $dst", (gBCA bo, crbitrc:$bi, abscondbrtarget:$dst)>;
4713 def : InstAlias<"b"#name#"lr"#pm#" $bi", (gBCLR bo, crbitrc:$bi, 0)>;
4714 def : InstAlias<"b"#name#"l"#pm#" $bi, $dst", (gBCL bo, crbitrc:$bi, condbrtarget:$dst)>;
4715 def : InstAlias<"b"#name#"la"#pm#" $bi, $dst", (gBCLA bo, crbitrc:$bi, abscondbrtarget:$dst)>;
4716 def : InstAlias<"b"#name#"lrl"#pm#" $bi", (gBCLRL bo, crbitrc:$bi, 0)>;
4718 multiclass BranchSimpleMnemonic2<string name, string pm, int bo>
4719 : BranchSimpleMnemonic1<name, pm, bo> {
4720 def : InstAlias<"b"#name#"ctr"#pm#" $bi", (gBCCTR bo, crbitrc:$bi, 0)>;
4721 def : InstAlias<"b"#name#"ctrl"#pm#" $bi", (gBCCTRL bo, crbitrc:$bi, 0)>;
4723 defm : BranchSimpleMnemonic2<"t", "", 12>;
4724 defm : BranchSimpleMnemonic2<"f", "", 4>;
4725 defm : BranchSimpleMnemonic2<"t", "-", 14>;
4726 defm : BranchSimpleMnemonic2<"f", "-", 6>;
4727 defm : BranchSimpleMnemonic2<"t", "+", 15>;
4728 defm : BranchSimpleMnemonic2<"f", "+", 7>;
4729 defm : BranchSimpleMnemonic1<"dnzt", "", 8>;
4730 defm : BranchSimpleMnemonic1<"dnzf", "", 0>;
4731 defm : BranchSimpleMnemonic1<"dzt", "", 10>;
4732 defm : BranchSimpleMnemonic1<"dzf", "", 2>;
4734 multiclass BranchExtendedMnemonicPM<string name, string pm, int bibo> {
4735 def : InstAlias<"b"#name#pm#" $cc, $dst",
4736 (BCC bibo, crrc:$cc, condbrtarget:$dst)>;
4737 def : InstAlias<"b"#name#pm#" $dst",
4738 (BCC bibo, CR0, condbrtarget:$dst)>;
4740 def : InstAlias<"b"#name#"a"#pm#" $cc, $dst",
4741 (BCCA bibo, crrc:$cc, abscondbrtarget:$dst)>;
4742 def : InstAlias<"b"#name#"a"#pm#" $dst",
4743 (BCCA bibo, CR0, abscondbrtarget:$dst)>;
4745 def : InstAlias<"b"#name#"lr"#pm#" $cc",
4746 (BCCLR bibo, crrc:$cc)>;
4747 def : InstAlias<"b"#name#"lr"#pm,
4750 def : InstAlias<"b"#name#"ctr"#pm#" $cc",
4751 (BCCCTR bibo, crrc:$cc)>;
4752 def : InstAlias<"b"#name#"ctr"#pm,
4753 (BCCCTR bibo, CR0)>;
4755 def : InstAlias<"b"#name#"l"#pm#" $cc, $dst",
4756 (BCCL bibo, crrc:$cc, condbrtarget:$dst)>;
4757 def : InstAlias<"b"#name#"l"#pm#" $dst",
4758 (BCCL bibo, CR0, condbrtarget:$dst)>;
4760 def : InstAlias<"b"#name#"la"#pm#" $cc, $dst",
4761 (BCCLA bibo, crrc:$cc, abscondbrtarget:$dst)>;
4762 def : InstAlias<"b"#name#"la"#pm#" $dst",
4763 (BCCLA bibo, CR0, abscondbrtarget:$dst)>;
4765 def : InstAlias<"b"#name#"lrl"#pm#" $cc",
4766 (BCCLRL bibo, crrc:$cc)>;
4767 def : InstAlias<"b"#name#"lrl"#pm,
4768 (BCCLRL bibo, CR0)>;
4770 def : InstAlias<"b"#name#"ctrl"#pm#" $cc",
4771 (BCCCTRL bibo, crrc:$cc)>;
4772 def : InstAlias<"b"#name#"ctrl"#pm,
4773 (BCCCTRL bibo, CR0)>;
4775 multiclass BranchExtendedMnemonic<string name, int bibo> {
4776 defm : BranchExtendedMnemonicPM<name, "", bibo>;
4777 defm : BranchExtendedMnemonicPM<name, "-", !add(bibo, 2)>;
4778 defm : BranchExtendedMnemonicPM<name, "+", !add(bibo, 3)>;
4780 defm : BranchExtendedMnemonic<"lt", 12>;
4781 defm : BranchExtendedMnemonic<"gt", 44>;
4782 defm : BranchExtendedMnemonic<"eq", 76>;
4783 defm : BranchExtendedMnemonic<"un", 108>;
4784 defm : BranchExtendedMnemonic<"so", 108>;
4785 defm : BranchExtendedMnemonic<"ge", 4>;
4786 defm : BranchExtendedMnemonic<"nl", 4>;
4787 defm : BranchExtendedMnemonic<"le", 36>;
4788 defm : BranchExtendedMnemonic<"ng", 36>;
4789 defm : BranchExtendedMnemonic<"ne", 68>;
4790 defm : BranchExtendedMnemonic<"nu", 100>;
4791 defm : BranchExtendedMnemonic<"ns", 100>;
4793 def : InstAlias<"cmpwi $rA, $imm", (CMPWI CR0, gprc:$rA, s16imm:$imm)>;
4794 def : InstAlias<"cmpw $rA, $rB", (CMPW CR0, gprc:$rA, gprc:$rB)>;
4795 def : InstAlias<"cmplwi $rA, $imm", (CMPLWI CR0, gprc:$rA, u16imm:$imm)>;
4796 def : InstAlias<"cmplw $rA, $rB", (CMPLW CR0, gprc:$rA, gprc:$rB)>;
4797 def : InstAlias<"cmpdi $rA, $imm", (CMPDI CR0, g8rc:$rA, s16imm64:$imm)>;
4798 def : InstAlias<"cmpd $rA, $rB", (CMPD CR0, g8rc:$rA, g8rc:$rB)>;
4799 def : InstAlias<"cmpldi $rA, $imm", (CMPLDI CR0, g8rc:$rA, u16imm64:$imm)>;
4800 def : InstAlias<"cmpld $rA, $rB", (CMPLD CR0, g8rc:$rA, g8rc:$rB)>;
4802 def : InstAlias<"cmpi $bf, 0, $rA, $imm", (CMPWI crrc:$bf, gprc:$rA, s16imm:$imm)>;
4803 def : InstAlias<"cmp $bf, 0, $rA, $rB", (CMPW crrc:$bf, gprc:$rA, gprc:$rB)>;
4804 def : InstAlias<"cmpli $bf, 0, $rA, $imm", (CMPLWI crrc:$bf, gprc:$rA, u16imm:$imm)>;
4805 def : InstAlias<"cmpl $bf, 0, $rA, $rB", (CMPLW crrc:$bf, gprc:$rA, gprc:$rB)>;
4806 def : InstAlias<"cmpi $bf, 1, $rA, $imm", (CMPDI crrc:$bf, g8rc:$rA, s16imm64:$imm)>;
4807 def : InstAlias<"cmp $bf, 1, $rA, $rB", (CMPD crrc:$bf, g8rc:$rA, g8rc:$rB)>;
4808 def : InstAlias<"cmpli $bf, 1, $rA, $imm", (CMPLDI crrc:$bf, g8rc:$rA, u16imm64:$imm)>;
4809 def : InstAlias<"cmpl $bf, 1, $rA, $rB", (CMPLD crrc:$bf, g8rc:$rA, g8rc:$rB)>;
4811 multiclass TrapExtendedMnemonic<string name, int to> {
4812 def : InstAlias<"td"#name#"i $rA, $imm", (TDI to, g8rc:$rA, s16imm:$imm)>;
4813 def : InstAlias<"td"#name#" $rA, $rB", (TD to, g8rc:$rA, g8rc:$rB)>;
4814 def : InstAlias<"tw"#name#"i $rA, $imm", (TWI to, gprc:$rA, s16imm:$imm)>;
4815 def : InstAlias<"tw"#name#" $rA, $rB", (TW to, gprc:$rA, gprc:$rB)>;
4817 defm : TrapExtendedMnemonic<"lt", 16>;
4818 defm : TrapExtendedMnemonic<"le", 20>;
4819 defm : TrapExtendedMnemonic<"eq", 4>;
4820 defm : TrapExtendedMnemonic<"ge", 12>;
4821 defm : TrapExtendedMnemonic<"gt", 8>;
4822 defm : TrapExtendedMnemonic<"nl", 12>;
4823 defm : TrapExtendedMnemonic<"ne", 24>;
4824 defm : TrapExtendedMnemonic<"ng", 20>;
4825 defm : TrapExtendedMnemonic<"llt", 2>;
4826 defm : TrapExtendedMnemonic<"lle", 6>;
4827 defm : TrapExtendedMnemonic<"lge", 5>;
4828 defm : TrapExtendedMnemonic<"lgt", 1>;
4829 defm : TrapExtendedMnemonic<"lnl", 5>;
4830 defm : TrapExtendedMnemonic<"lng", 6>;
4831 defm : TrapExtendedMnemonic<"u", 31>;
4834 def : Pat<(atomic_load_8 iaddr:$src), (LBZ memri:$src)>;
4835 def : Pat<(atomic_load_16 iaddr:$src), (LHZ memri:$src)>;
4836 def : Pat<(atomic_load_32 iaddr:$src), (LWZ memri:$src)>;
4837 def : Pat<(atomic_load_8 xaddr:$src), (LBZX memrr:$src)>;
4838 def : Pat<(atomic_load_16 xaddr:$src), (LHZX memrr:$src)>;
4839 def : Pat<(atomic_load_32 xaddr:$src), (LWZX memrr:$src)>;
4842 def : Pat<(atomic_store_8 iaddr:$ptr, i32:$val), (STB gprc:$val, memri:$ptr)>;
4843 def : Pat<(atomic_store_16 iaddr:$ptr, i32:$val), (STH gprc:$val, memri:$ptr)>;
4844 def : Pat<(atomic_store_32 iaddr:$ptr, i32:$val), (STW gprc:$val, memri:$ptr)>;
4845 def : Pat<(atomic_store_8 xaddr:$ptr, i32:$val), (STBX gprc:$val, memrr:$ptr)>;
4846 def : Pat<(atomic_store_16 xaddr:$ptr, i32:$val), (STHX gprc:$val, memrr:$ptr)>;
4847 def : Pat<(atomic_store_32 xaddr:$ptr, i32:$val), (STWX gprc:$val, memrr:$ptr)>;
4849 let Predicates = [IsISA3_0] in {
4851 // Copy-Paste Facility
4852 // We prefix 'CP' to COPY due to name conflict in Target.td. We also prefix to
4853 // PASTE for naming consistency.
4855 def CP_COPY : X_L1_RA5_RB5<31, 774, "copy" , gprc, IIC_LdStCOPY, []>;
4858 def CP_PASTE : X_L1_RA5_RB5<31, 902, "paste" , gprc, IIC_LdStPASTE, []>;
4860 let mayStore = 1, Defs = [CR0] in
4861 def CP_PASTEo : X_L1_RA5_RB5<31, 902, "paste.", gprc, IIC_LdStPASTE, []>, isDOT;
4863 def CP_COPYx : PPCAsmPseudo<"copy $rA, $rB" , (ins gprc:$rA, gprc:$rB)>;
4864 def CP_PASTEx : PPCAsmPseudo<"paste $rA, $rB", (ins gprc:$rA, gprc:$rB)>;
4865 def CP_COPY_FIRST : PPCAsmPseudo<"copy_first $rA, $rB",
4866 (ins gprc:$rA, gprc:$rB)>;
4867 def CP_PASTE_LAST : PPCAsmPseudo<"paste_last $rA, $rB",
4868 (ins gprc:$rA, gprc:$rB)>;
4869 def CP_ABORT : XForm_0<31, 838, (outs), (ins), "cp_abort", IIC_SprABORT, []>;
4871 // Message Synchronize
4872 def MSGSYNC : XForm_0<31, 886, (outs), (ins), "msgsync", IIC_SprMSGSYNC, []>;
4874 // Power-Saving Mode Instruction:
4875 def STOP : XForm_0<19, 370, (outs), (ins), "stop", IIC_SprSTOP, []>;
4879 // Fast 32-bit reverse bits algorithm:
4880 // Step 1: 1-bit swap (swap odd 1-bit and even 1-bit):
4881 // n = ((n >> 1) & 0x55555555) | ((n << 1) & 0xAAAAAAAA);
4882 // Step 2: 2-bit swap (swap odd 2-bit and even 2-bit):
4883 // n = ((n >> 2) & 0x33333333) | ((n << 2) & 0xCCCCCCCC);
4884 // Step 3: 4-bit swap (swap odd 4-bit and even 4-bit):
4885 // n = ((n >> 4) & 0x0F0F0F0F) | ((n << 4) & 0xF0F0F0F0);
4886 // Step 4: byte reverse (Suppose n = [B1,B2,B3,B4]):
4887 // Step 4.1: Put B4,B2 in the right position (rotate left 3 bytes):
4888 // n' = (n rotl 24); After which n' = [B4, B1, B2, B3]
4889 // Step 4.2: Insert B3 to the right position:
4890 // n' = rlwimi n', n, 8, 8, 15; After which n' = [B4, B3, B2, B3]
4891 // Step 4.3: Insert B1 to the right position:
4892 // n' = rlwimi n', n, 8, 24, 31; After which n' = [B4, B3, B2, B1]
4894 dag Lo1 = (ORI (LIS 0x5555), 0x5555);
4895 dag Hi1 = (ORI (LIS 0xAAAA), 0xAAAA);
4896 dag Lo2 = (ORI (LIS 0x3333), 0x3333);
4897 dag Hi2 = (ORI (LIS 0xCCCC), 0xCCCC);
4898 dag Lo4 = (ORI (LIS 0x0F0F), 0x0F0F);
4899 dag Hi4 = (ORI (LIS 0xF0F0), 0xF0F0);
4903 dag Right = (RLWINM $A, 31, 1, 31);
4904 dag Left = (RLWINM $A, 1, 0, 30);
4908 dag Bit = (OR (AND Shift1.Right, MaskValues.Lo1),
4909 (AND Shift1.Left, MaskValues.Hi1));
4913 dag Right = (RLWINM Swap1.Bit, 30, 2, 31);
4914 dag Left = (RLWINM Swap1.Bit, 2, 0, 29);
4918 dag Bits = (OR (AND Shift2.Right, MaskValues.Lo2),
4919 (AND Shift2.Left, MaskValues.Hi2));
4923 dag Right = (RLWINM Swap2.Bits, 28, 4, 31);
4924 dag Left = (RLWINM Swap2.Bits, 4, 0, 27);
4928 dag Bits = (OR (AND Shift4.Right, MaskValues.Lo4),
4929 (AND Shift4.Left, MaskValues.Hi4));
4933 dag Left3Bytes = (RLWINM Swap4.Bits, 24, 0, 31);
4936 def RotateInsertByte3 {
4937 dag Left = (RLWIMI Rotate.Left3Bytes, Swap4.Bits, 8, 8, 15);
4940 def RotateInsertByte1 {
4941 dag Left = (RLWIMI RotateInsertByte3.Left, Swap4.Bits, 8, 24, 31);
4944 def : Pat<(i32 (bitreverse i32:$A)),
4945 (RLDICL_32 RotateInsertByte1.Left, 0, 32)>;
4947 // Fast 64-bit reverse bits algorithm:
4948 // Step 1: 1-bit swap (swap odd 1-bit and even 1-bit):
4949 // n = ((n >> 1) & 0x5555555555555555) | ((n << 1) & 0xAAAAAAAAAAAAAAAA);
4950 // Step 2: 2-bit swap (swap odd 2-bit and even 2-bit):
4951 // n = ((n >> 2) & 0x3333333333333333) | ((n << 2) & 0xCCCCCCCCCCCCCCCC);
4952 // Step 3: 4-bit swap (swap odd 4-bit and even 4-bit):
4953 // n = ((n >> 4) & 0x0F0F0F0F0F0F0F0F) | ((n << 4) & 0xF0F0F0F0F0F0F0F0);
4954 // Step 4: byte reverse (Suppose n = [B0,B1,B2,B3,B4,B5,B6,B7]):
4955 // Apply the same byte reverse algorithm mentioned above for the fast 32-bit
4956 // reverse to both the high 32 bit and low 32 bit of the 64 bit value. And
4957 // then OR them together to get the final result.
4959 dag Lo1 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Lo1, sub_32));
4960 dag Hi1 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Hi1, sub_32));
4961 dag Lo2 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Lo2, sub_32));
4962 dag Hi2 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Hi2, sub_32));
4963 dag Lo4 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Lo4, sub_32));
4964 dag Hi4 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Hi4, sub_32));
4968 dag Lo1 = (ORI8 (ORIS8 (RLDICR MaskValues64.Lo1, 32, 31), 0x5555), 0x5555);
4969 dag Hi1 = (ORI8 (ORIS8 (RLDICR MaskValues64.Hi1, 32, 31), 0xAAAA), 0xAAAA);
4970 dag Lo2 = (ORI8 (ORIS8 (RLDICR MaskValues64.Lo2, 32, 31), 0x3333), 0x3333);
4971 dag Hi2 = (ORI8 (ORIS8 (RLDICR MaskValues64.Hi2, 32, 31), 0xCCCC), 0xCCCC);
4972 dag Lo4 = (ORI8 (ORIS8 (RLDICR MaskValues64.Lo4, 32, 31), 0x0F0F), 0x0F0F);
4973 dag Hi4 = (ORI8 (ORIS8 (RLDICR MaskValues64.Hi4, 32, 31), 0xF0F0), 0xF0F0);
4977 dag Swap1 = (OR8 (AND8 (RLDICL $A, 63, 1), DWMaskValues.Lo1),
4978 (AND8 (RLDICR $A, 1, 62), DWMaskValues.Hi1));
4979 dag Swap2 = (OR8 (AND8 (RLDICL Swap1, 62, 2), DWMaskValues.Lo2),
4980 (AND8 (RLDICR Swap1, 2, 61), DWMaskValues.Hi2));
4981 dag Swap4 = (OR8 (AND8 (RLDICL Swap2, 60, 4), DWMaskValues.Lo4),
4982 (AND8 (RLDICR Swap2, 4, 59), DWMaskValues.Hi4));
4985 // Intra-byte swap is done, now start inter-byte swap.
4987 dag Word = (i32 (EXTRACT_SUBREG DWSwapInByte.Swap4, sub_32));
4991 dag Word = (RLWINM DWBytes4567.Word, 24, 0, 31);
4995 dag Word = (RLWIMI DWBytes7456.Word, DWBytes4567.Word, 8, 8, 15);
4998 // B7 B6 B5 B4 in the right order
5000 dag Word = (RLWIMI DWBytes7656.Word, DWBytes4567.Word, 8, 24, 31);
5002 (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), Word, sub_32));
5006 dag Word = (i32 (EXTRACT_SUBREG (RLDICL DWSwapInByte.Swap4, 32, 32), sub_32));
5010 dag Word = (RLWINM DWBytes0123.Word, 24, 0, 31);
5014 dag Word = (RLWIMI DWBytes3012.Word, DWBytes0123.Word, 8, 8, 15);
5017 // B3 B2 B1 B0 in the right order
5019 dag Word = (RLWIMI DWBytes3212.Word, DWBytes0123.Word, 8, 24, 31);
5021 (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), Word, sub_32));
5024 // Now both high word and low word are reversed, next
5025 // swap the high word and low word.
5026 def : Pat<(i64 (bitreverse i64:$A)),
5027 (OR8 (RLDICR DWBytes7654.DWord, 32, 31), DWBytes3210.DWord)>;