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<GPRC> {
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<(i32 (zextloadi1 iaddr:$src)),
3193 def : Pat<(i32 (zextloadi1 xaddr:$src)),
3195 def : Pat<(i32 (extloadi1 iaddr:$src)),
3197 def : Pat<(i32 (extloadi1 xaddr:$src)),
3199 def : Pat<(i32 (extloadi8 iaddr:$src)),
3201 def : Pat<(i32 (extloadi8 xaddr:$src)),
3203 def : Pat<(i32 (extloadi16 iaddr:$src)),
3205 def : Pat<(i32 (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 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETULT)),
3579 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_lt)>;
3580 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETLT)),
3581 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_lt)>;
3582 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETUGT)),
3583 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_gt)>;
3584 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETGT)),
3585 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_gt)>;
3586 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETEQ)),
3587 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_eq)>;
3590 def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETULT)),
3591 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_lt)>;
3592 def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETLT)),
3593 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_lt)>;
3594 def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETUGT)),
3595 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_gt)>;
3596 def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETGT)),
3597 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_gt)>;
3598 def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETEQ)),
3599 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_eq)>;
3600 def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETEQ)),
3601 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_eq)>;
3603 // For non-equality comparisons, the default code would materialize the
3604 // constant, then compare against it, like this:
3606 // ori r2, r2, 22136
3609 // Since we are just comparing for equality, we can emit this instead:
3610 // xoris r0,r3,0x1234
3611 // cmpldi cr0,r0,0x5678
3614 def : Pat<(i1 (setcc i64:$s1, imm64ZExt32:$imm, SETEQ)),
3615 (EXTRACT_SUBREG (CMPLDI (XORIS8 $s1, (HI16 imm:$imm)),
3616 (LO16 imm:$imm)), sub_eq)>;
3618 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETULT)),
3619 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_lt)>;
3620 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETLT)),
3621 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_lt)>;
3622 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETUGT)),
3623 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_gt)>;
3624 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETGT)),
3625 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_gt)>;
3626 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETEQ)),
3627 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_eq)>;
3629 // Instantiations of CRNotPat for i32.
3630 defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETUGE)),
3631 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_lt)>;
3632 defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETGE)),
3633 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_lt)>;
3634 defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETULE)),
3635 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_gt)>;
3636 defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETLE)),
3637 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_gt)>;
3638 defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETNE)),
3639 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_eq)>;
3640 defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETNE)),
3641 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_eq)>;
3643 defm : CRNotPat<(i1 (setcc i32:$s1, imm:$imm, SETNE)),
3644 (EXTRACT_SUBREG (CMPLWI (XORIS $s1, (HI16 imm:$imm)),
3645 (LO16 imm:$imm)), sub_eq)>;
3647 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETUGE)),
3648 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_lt)>;
3649 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETGE)),
3650 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_lt)>;
3651 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETULE)),
3652 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_gt)>;
3653 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETLE)),
3654 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_gt)>;
3655 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETNE)),
3656 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_eq)>;
3658 // Instantiations of CRNotPat for i64.
3659 defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETUGE)),
3660 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_lt)>;
3661 defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETGE)),
3662 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_lt)>;
3663 defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETULE)),
3664 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_gt)>;
3665 defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETLE)),
3666 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_gt)>;
3667 defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETNE)),
3668 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_eq)>;
3669 defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETNE)),
3670 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_eq)>;
3672 defm : CRNotPat<(i1 (setcc i64:$s1, imm64ZExt32:$imm, SETNE)),
3673 (EXTRACT_SUBREG (CMPLDI (XORIS8 $s1, (HI16 imm:$imm)),
3674 (LO16 imm:$imm)), sub_eq)>;
3676 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETUGE)),
3677 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_lt)>;
3678 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETGE)),
3679 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_lt)>;
3680 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETULE)),
3681 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_gt)>;
3682 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETLE)),
3683 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_gt)>;
3684 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETNE)),
3685 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_eq)>;
3687 let Predicates = [HasFPU] in {
3688 // Instantiations of CRNotPat for f32.
3689 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETUGE)),
3690 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3691 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETGE)),
3692 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3693 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETULE)),
3694 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3695 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETLE)),
3696 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3697 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETUNE)),
3698 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3699 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETNE)),
3700 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3701 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETO)),
3702 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_un)>;
3704 // Instantiations of CRNotPat for f64.
3705 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETUGE)),
3706 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3707 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETGE)),
3708 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3709 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETULE)),
3710 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3711 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETLE)),
3712 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3713 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETUNE)),
3714 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3715 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETNE)),
3716 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3717 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETO)),
3718 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_un)>;
3720 // Instantiations of CRNotPat for f128.
3721 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETUGE)),
3722 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_lt)>;
3723 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETGE)),
3724 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_lt)>;
3725 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETULE)),
3726 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_gt)>;
3727 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETLE)),
3728 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_gt)>;
3729 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETUNE)),
3730 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_eq)>;
3731 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETNE)),
3732 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_eq)>;
3733 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETO)),
3734 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_un)>;
3738 let Predicates = [HasFPU] in {
3739 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOLT)),
3740 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3741 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETLT)),
3742 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3743 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOGT)),
3744 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3745 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETGT)),
3746 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3747 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOEQ)),
3748 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3749 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETEQ)),
3750 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3751 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETUO)),
3752 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_un)>;
3755 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOLT)),
3756 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3757 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETLT)),
3758 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3759 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOGT)),
3760 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3761 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETGT)),
3762 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3763 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOEQ)),
3764 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3765 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETEQ)),
3766 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3767 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETUO)),
3768 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_un)>;
3771 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETOLT)),
3772 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_lt)>;
3773 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETLT)),
3774 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_lt)>;
3775 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETOGT)),
3776 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_gt)>;
3777 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETGT)),
3778 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_gt)>;
3779 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETOEQ)),
3780 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_eq)>;
3781 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETEQ)),
3782 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_eq)>;
3783 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETUO)),
3784 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_un)>;
3788 // This must be in this file because it relies on patterns defined in this file
3789 // after the inclusion of the instruction sets.
3790 let Predicates = [HasSPE] in {
3792 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOLT)),
3793 (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>;
3794 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETLT)),
3795 (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>;
3796 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOGT)),
3797 (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>;
3798 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETGT)),
3799 (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>;
3800 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOEQ)),
3801 (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>;
3802 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETEQ)),
3803 (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>;
3805 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETUGE)),
3806 (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>;
3807 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETGE)),
3808 (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>;
3809 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETULE)),
3810 (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>;
3811 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETLE)),
3812 (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>;
3813 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETUNE)),
3814 (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>;
3815 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETNE)),
3816 (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>;
3819 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOLT)),
3820 (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>;
3821 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETLT)),
3822 (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>;
3823 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOGT)),
3824 (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>;
3825 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETGT)),
3826 (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>;
3827 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOEQ)),
3828 (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>;
3829 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETEQ)),
3830 (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>;
3832 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETUGE)),
3833 (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>;
3834 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETGE)),
3835 (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>;
3836 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETULE)),
3837 (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>;
3838 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETLE)),
3839 (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>;
3840 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETUNE)),
3841 (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>;
3842 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETNE)),
3843 (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>;
3845 // match select on i1 variables:
3846 def : Pat<(i1 (select i1:$cond, i1:$tval, i1:$fval)),
3847 (CROR (CRAND $cond , $tval),
3848 (CRAND (crnot $cond), $fval))>;
3850 // match selectcc on i1 variables:
3851 // select (lhs == rhs), tval, fval is:
3852 // ((lhs == rhs) & tval) | (!(lhs == rhs) & fval)
3853 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETLT)),
3854 (CROR (CRAND (CRANDC $lhs, $rhs), $tval),
3855 (CRAND (CRORC $rhs, $lhs), $fval))>;
3856 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETULT)),
3857 (CROR (CRAND (CRANDC $rhs, $lhs), $tval),
3858 (CRAND (CRORC $lhs, $rhs), $fval))>;
3859 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETLE)),
3860 (CROR (CRAND (CRORC $lhs, $rhs), $tval),
3861 (CRAND (CRANDC $rhs, $lhs), $fval))>;
3862 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETULE)),
3863 (CROR (CRAND (CRORC $rhs, $lhs), $tval),
3864 (CRAND (CRANDC $lhs, $rhs), $fval))>;
3865 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETEQ)),
3866 (CROR (CRAND (CREQV $lhs, $rhs), $tval),
3867 (CRAND (CRXOR $lhs, $rhs), $fval))>;
3868 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETGE)),
3869 (CROR (CRAND (CRORC $rhs, $lhs), $tval),
3870 (CRAND (CRANDC $lhs, $rhs), $fval))>;
3871 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETUGE)),
3872 (CROR (CRAND (CRORC $lhs, $rhs), $tval),
3873 (CRAND (CRANDC $rhs, $lhs), $fval))>;
3874 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETGT)),
3875 (CROR (CRAND (CRANDC $rhs, $lhs), $tval),
3876 (CRAND (CRORC $lhs, $rhs), $fval))>;
3877 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETUGT)),
3878 (CROR (CRAND (CRANDC $lhs, $rhs), $tval),
3879 (CRAND (CRORC $rhs, $lhs), $fval))>;
3880 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETNE)),
3881 (CROR (CRAND (CREQV $lhs, $rhs), $fval),
3882 (CRAND (CRXOR $lhs, $rhs), $tval))>;
3884 // match selectcc on i1 variables with non-i1 output.
3885 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETLT)),
3886 (SELECT_I4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3887 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETULT)),
3888 (SELECT_I4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3889 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETLE)),
3890 (SELECT_I4 (CRORC $lhs, $rhs), $tval, $fval)>;
3891 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETULE)),
3892 (SELECT_I4 (CRORC $rhs, $lhs), $tval, $fval)>;
3893 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETEQ)),
3894 (SELECT_I4 (CREQV $lhs, $rhs), $tval, $fval)>;
3895 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETGE)),
3896 (SELECT_I4 (CRORC $rhs, $lhs), $tval, $fval)>;
3897 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETUGE)),
3898 (SELECT_I4 (CRORC $lhs, $rhs), $tval, $fval)>;
3899 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETGT)),
3900 (SELECT_I4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3901 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETUGT)),
3902 (SELECT_I4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3903 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETNE)),
3904 (SELECT_I4 (CRXOR $lhs, $rhs), $tval, $fval)>;
3906 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETLT)),
3907 (SELECT_I8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3908 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETULT)),
3909 (SELECT_I8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3910 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETLE)),
3911 (SELECT_I8 (CRORC $lhs, $rhs), $tval, $fval)>;
3912 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETULE)),
3913 (SELECT_I8 (CRORC $rhs, $lhs), $tval, $fval)>;
3914 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETEQ)),
3915 (SELECT_I8 (CREQV $lhs, $rhs), $tval, $fval)>;
3916 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETGE)),
3917 (SELECT_I8 (CRORC $rhs, $lhs), $tval, $fval)>;
3918 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETUGE)),
3919 (SELECT_I8 (CRORC $lhs, $rhs), $tval, $fval)>;
3920 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETGT)),
3921 (SELECT_I8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3922 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETUGT)),
3923 (SELECT_I8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3924 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETNE)),
3925 (SELECT_I8 (CRXOR $lhs, $rhs), $tval, $fval)>;
3927 let Predicates = [HasFPU] in {
3928 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETLT)),
3929 (SELECT_F4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3930 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETULT)),
3931 (SELECT_F4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3932 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETLE)),
3933 (SELECT_F4 (CRORC $lhs, $rhs), $tval, $fval)>;
3934 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETULE)),
3935 (SELECT_F4 (CRORC $rhs, $lhs), $tval, $fval)>;
3936 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETEQ)),
3937 (SELECT_F4 (CREQV $lhs, $rhs), $tval, $fval)>;
3938 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETGE)),
3939 (SELECT_F4 (CRORC $rhs, $lhs), $tval, $fval)>;
3940 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETUGE)),
3941 (SELECT_F4 (CRORC $lhs, $rhs), $tval, $fval)>;
3942 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETGT)),
3943 (SELECT_F4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3944 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETUGT)),
3945 (SELECT_F4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3946 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETNE)),
3947 (SELECT_F4 (CRXOR $lhs, $rhs), $tval, $fval)>;
3949 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETLT)),
3950 (SELECT_F8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3951 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETULT)),
3952 (SELECT_F8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3953 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETLE)),
3954 (SELECT_F8 (CRORC $lhs, $rhs), $tval, $fval)>;
3955 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETULE)),
3956 (SELECT_F8 (CRORC $rhs, $lhs), $tval, $fval)>;
3957 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETEQ)),
3958 (SELECT_F8 (CREQV $lhs, $rhs), $tval, $fval)>;
3959 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETGE)),
3960 (SELECT_F8 (CRORC $rhs, $lhs), $tval, $fval)>;
3961 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETUGE)),
3962 (SELECT_F8 (CRORC $lhs, $rhs), $tval, $fval)>;
3963 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETGT)),
3964 (SELECT_F8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3965 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETUGT)),
3966 (SELECT_F8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3967 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETNE)),
3968 (SELECT_F8 (CRXOR $lhs, $rhs), $tval, $fval)>;
3971 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETLT)),
3972 (SELECT_F16 (CRANDC $lhs, $rhs), $tval, $fval)>;
3973 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETULT)),
3974 (SELECT_F16 (CRANDC $rhs, $lhs), $tval, $fval)>;
3975 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETLE)),
3976 (SELECT_F16 (CRORC $lhs, $rhs), $tval, $fval)>;
3977 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETULE)),
3978 (SELECT_F16 (CRORC $rhs, $lhs), $tval, $fval)>;
3979 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETEQ)),
3980 (SELECT_F16 (CREQV $lhs, $rhs), $tval, $fval)>;
3981 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETGE)),
3982 (SELECT_F16 (CRORC $rhs, $lhs), $tval, $fval)>;
3983 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETUGE)),
3984 (SELECT_F16 (CRORC $lhs, $rhs), $tval, $fval)>;
3985 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETGT)),
3986 (SELECT_F16 (CRANDC $rhs, $lhs), $tval, $fval)>;
3987 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETUGT)),
3988 (SELECT_F16 (CRANDC $lhs, $rhs), $tval, $fval)>;
3989 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETNE)),
3990 (SELECT_F16 (CRXOR $lhs, $rhs), $tval, $fval)>;
3992 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETLT)),
3993 (SELECT_VRRC (CRANDC $lhs, $rhs), $tval, $fval)>;
3994 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETULT)),
3995 (SELECT_VRRC (CRANDC $rhs, $lhs), $tval, $fval)>;
3996 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETLE)),
3997 (SELECT_VRRC (CRORC $lhs, $rhs), $tval, $fval)>;
3998 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETULE)),
3999 (SELECT_VRRC (CRORC $rhs, $lhs), $tval, $fval)>;
4000 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETEQ)),
4001 (SELECT_VRRC (CREQV $lhs, $rhs), $tval, $fval)>;
4002 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETGE)),
4003 (SELECT_VRRC (CRORC $rhs, $lhs), $tval, $fval)>;
4004 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETUGE)),
4005 (SELECT_VRRC (CRORC $lhs, $rhs), $tval, $fval)>;
4006 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETGT)),
4007 (SELECT_VRRC (CRANDC $rhs, $lhs), $tval, $fval)>;
4008 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETUGT)),
4009 (SELECT_VRRC (CRANDC $lhs, $rhs), $tval, $fval)>;
4010 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETNE)),
4011 (SELECT_VRRC (CRXOR $lhs, $rhs), $tval, $fval)>;
4013 def ANDIo_1_EQ_BIT : PPCCustomInserterPseudo<(outs crbitrc:$dst), (ins gprc:$in),
4015 [(set i1:$dst, (trunc (not i32:$in)))]>;
4016 def ANDIo_1_GT_BIT : PPCCustomInserterPseudo<(outs crbitrc:$dst), (ins gprc:$in),
4018 [(set i1:$dst, (trunc i32:$in))]>;
4020 def ANDIo_1_EQ_BIT8 : PPCCustomInserterPseudo<(outs crbitrc:$dst), (ins g8rc:$in),
4022 [(set i1:$dst, (trunc (not i64:$in)))]>;
4023 def ANDIo_1_GT_BIT8 : PPCCustomInserterPseudo<(outs crbitrc:$dst), (ins g8rc:$in),
4025 [(set i1:$dst, (trunc i64:$in))]>;
4027 def : Pat<(i1 (not (trunc i32:$in))),
4028 (ANDIo_1_EQ_BIT $in)>;
4029 def : Pat<(i1 (not (trunc i64:$in))),
4030 (ANDIo_1_EQ_BIT8 $in)>;
4032 //===----------------------------------------------------------------------===//
4033 // PowerPC Instructions used for assembler/disassembler only
4036 // FIXME: For B=0 or B > 8, the registers following RT are used.
4037 // WARNING: Do not add patterns for this instruction without fixing this.
4038 def LSWI : XForm_base_r3xo_memOp<31, 597, (outs gprc:$RT),
4039 (ins gprc:$A, u5imm:$B),
4040 "lswi $RT, $A, $B", IIC_LdStLoad, []>;
4042 // FIXME: For B=0 or B > 8, the registers following RT are used.
4043 // WARNING: Do not add patterns for this instruction without fixing this.
4044 def STSWI : XForm_base_r3xo_memOp<31, 725, (outs),
4045 (ins gprc:$RT, gprc:$A, u5imm:$B),
4046 "stswi $RT, $A, $B", IIC_LdStLoad, []>;
4048 def ISYNC : XLForm_2_ext<19, 150, 0, 0, 0, (outs), (ins),
4049 "isync", IIC_SprISYNC, []>;
4051 def ICBI : XForm_1a<31, 982, (outs), (ins memrr:$src),
4052 "icbi $src", IIC_LdStICBI, []>;
4054 // We used to have EIEIO as value but E[0-9A-Z] is a reserved name
4055 def EnforceIEIO : XForm_24_eieio<31, 854, (outs), (ins),
4056 "eieio", IIC_LdStLoad, []>;
4058 def WAIT : XForm_24_sync<31, 30, (outs), (ins i32imm:$L),
4059 "wait $L", IIC_LdStLoad, []>;
4061 def MBAR : XForm_mbar<31, 854, (outs), (ins u5imm:$MO),
4062 "mbar $MO", IIC_LdStLoad>, Requires<[IsBookE]>;
4064 def MTSR: XForm_sr<31, 210, (outs), (ins gprc:$RS, u4imm:$SR),
4065 "mtsr $SR, $RS", IIC_SprMTSR>;
4067 def MFSR: XForm_sr<31, 595, (outs gprc:$RS), (ins u4imm:$SR),
4068 "mfsr $RS, $SR", IIC_SprMFSR>;
4070 def MTSRIN: XForm_srin<31, 242, (outs), (ins gprc:$RS, gprc:$RB),
4071 "mtsrin $RS, $RB", IIC_SprMTSR>;
4073 def MFSRIN: XForm_srin<31, 659, (outs gprc:$RS), (ins gprc:$RB),
4074 "mfsrin $RS, $RB", IIC_SprMFSR>;
4076 def MTMSR: XForm_mtmsr<31, 146, (outs), (ins gprc:$RS, i32imm:$L),
4077 "mtmsr $RS, $L", IIC_SprMTMSR>;
4079 def WRTEE: XForm_mtmsr<31, 131, (outs), (ins gprc:$RS),
4080 "wrtee $RS", IIC_SprMTMSR>, Requires<[IsBookE]> {
4084 def WRTEEI: I<31, (outs), (ins i1imm:$E), "wrteei $E", IIC_SprMTMSR>,
4085 Requires<[IsBookE]> {
4089 let Inst{21-30} = 163;
4092 def DCCCI : XForm_tlb<454, (outs), (ins gprc:$A, gprc:$B),
4093 "dccci $A, $B", IIC_LdStLoad>, Requires<[IsPPC4xx]>;
4094 def ICCCI : XForm_tlb<966, (outs), (ins gprc:$A, gprc:$B),
4095 "iccci $A, $B", IIC_LdStLoad>, Requires<[IsPPC4xx]>;
4097 def : InstAlias<"dci 0", (DCCCI R0, R0)>, Requires<[IsPPC4xx]>;
4098 def : InstAlias<"dccci", (DCCCI R0, R0)>, Requires<[IsPPC4xx]>;
4099 def : InstAlias<"ici 0", (ICCCI R0, R0)>, Requires<[IsPPC4xx]>;
4100 def : InstAlias<"iccci", (ICCCI R0, R0)>, Requires<[IsPPC4xx]>;
4102 def MFMSR : XForm_rs<31, 83, (outs gprc:$RT), (ins),
4103 "mfmsr $RT", IIC_SprMFMSR, []>;
4105 def MTMSRD : XForm_mtmsr<31, 178, (outs), (ins gprc:$RS, i32imm:$L),
4106 "mtmsrd $RS, $L", IIC_SprMTMSRD>;
4108 def MCRFS : XLForm_3<63, 64, (outs crrc:$BF), (ins crrc:$BFA),
4109 "mcrfs $BF, $BFA", IIC_BrMCR>;
4111 def MTFSFI : XLForm_4<63, 134, (outs crrc:$BF), (ins i32imm:$U, i32imm:$W),
4112 "mtfsfi $BF, $U, $W", IIC_IntMFFS>;
4114 def MTFSFIo : XLForm_4<63, 134, (outs crrc:$BF), (ins i32imm:$U, i32imm:$W),
4115 "mtfsfi. $BF, $U, $W", IIC_IntMFFS>, isDOT;
4117 def : InstAlias<"mtfsfi $BF, $U", (MTFSFI crrc:$BF, i32imm:$U, 0)>;
4118 def : InstAlias<"mtfsfi. $BF, $U", (MTFSFIo crrc:$BF, i32imm:$U, 0)>;
4120 let Predicates = [HasFPU] in {
4121 def MTFSF : XFLForm_1<63, 711, (outs),
4122 (ins i32imm:$FLM, f8rc:$FRB, i32imm:$L, i32imm:$W),
4123 "mtfsf $FLM, $FRB, $L, $W", IIC_IntMFFS, []>;
4124 def MTFSFo : XFLForm_1<63, 711, (outs),
4125 (ins i32imm:$FLM, f8rc:$FRB, i32imm:$L, i32imm:$W),
4126 "mtfsf. $FLM, $FRB, $L, $W", IIC_IntMFFS, []>, isDOT;
4128 def : InstAlias<"mtfsf $FLM, $FRB", (MTFSF i32imm:$FLM, f8rc:$FRB, 0, 0)>;
4129 def : InstAlias<"mtfsf. $FLM, $FRB", (MTFSFo i32imm:$FLM, f8rc:$FRB, 0, 0)>;
4132 def SLBIE : XForm_16b<31, 434, (outs), (ins gprc:$RB),
4133 "slbie $RB", IIC_SprSLBIE, []>;
4135 def SLBMTE : XForm_26<31, 402, (outs), (ins gprc:$RS, gprc:$RB),
4136 "slbmte $RS, $RB", IIC_SprSLBMTE, []>;
4138 def SLBMFEE : XForm_26<31, 915, (outs gprc:$RT), (ins gprc:$RB),
4139 "slbmfee $RT, $RB", IIC_SprSLBMFEE, []>;
4141 def SLBMFEV : XLForm_1_gen<31, 851, (outs gprc:$RT), (ins gprc:$RB),
4142 "slbmfev $RT, $RB", IIC_SprSLBMFEV, []>;
4144 def SLBIA : XForm_0<31, 498, (outs), (ins), "slbia", IIC_SprSLBIA, []>;
4147 def SLBFEEo : XForm_26<31, 979, (outs gprc:$RT), (ins gprc:$RB),
4148 "slbfee. $RT, $RB", IIC_SprSLBFEE, []>, isDOT;
4150 def TLBIA : XForm_0<31, 370, (outs), (ins),
4151 "tlbia", IIC_SprTLBIA, []>;
4153 def TLBSYNC : XForm_0<31, 566, (outs), (ins),
4154 "tlbsync", IIC_SprTLBSYNC, []>;
4156 def TLBIEL : XForm_16b<31, 274, (outs), (ins gprc:$RB),
4157 "tlbiel $RB", IIC_SprTLBIEL, []>;
4159 def TLBLD : XForm_16b<31, 978, (outs), (ins gprc:$RB),
4160 "tlbld $RB", IIC_LdStLoad, []>, Requires<[IsPPC6xx]>;
4161 def TLBLI : XForm_16b<31, 1010, (outs), (ins gprc:$RB),
4162 "tlbli $RB", IIC_LdStLoad, []>, Requires<[IsPPC6xx]>;
4164 def TLBIE : XForm_26<31, 306, (outs), (ins gprc:$RS, gprc:$RB),
4165 "tlbie $RB,$RS", IIC_SprTLBIE, []>;
4167 def TLBSX : XForm_tlb<914, (outs), (ins gprc:$A, gprc:$B), "tlbsx $A, $B",
4168 IIC_LdStLoad>, Requires<[IsBookE]>;
4170 def TLBIVAX : XForm_tlb<786, (outs), (ins gprc:$A, gprc:$B), "tlbivax $A, $B",
4171 IIC_LdStLoad>, Requires<[IsBookE]>;
4173 def TLBRE : XForm_24_eieio<31, 946, (outs), (ins),
4174 "tlbre", IIC_LdStLoad, []>, Requires<[IsBookE]>;
4176 def TLBWE : XForm_24_eieio<31, 978, (outs), (ins),
4177 "tlbwe", IIC_LdStLoad, []>, Requires<[IsBookE]>;
4179 def TLBRE2 : XForm_tlbws<31, 946, (outs gprc:$RS), (ins gprc:$A, i1imm:$WS),
4180 "tlbre $RS, $A, $WS", IIC_LdStLoad, []>, Requires<[IsPPC4xx]>;
4182 def TLBWE2 : XForm_tlbws<31, 978, (outs), (ins gprc:$RS, gprc:$A, i1imm:$WS),
4183 "tlbwe $RS, $A, $WS", IIC_LdStLoad, []>, Requires<[IsPPC4xx]>;
4185 def TLBSX2 : XForm_base_r3xo<31, 914, (outs), (ins gprc:$RST, gprc:$A, gprc:$B),
4186 "tlbsx $RST, $A, $B", IIC_LdStLoad, []>,
4187 Requires<[IsPPC4xx]>;
4188 def TLBSX2D : XForm_base_r3xo<31, 914, (outs),
4189 (ins gprc:$RST, gprc:$A, gprc:$B),
4190 "tlbsx. $RST, $A, $B", IIC_LdStLoad, []>,
4191 Requires<[IsPPC4xx]>, isDOT;
4193 def RFID : XForm_0<19, 18, (outs), (ins), "rfid", IIC_IntRFID, []>;
4195 def RFI : XForm_0<19, 50, (outs), (ins), "rfi", IIC_SprRFI, []>,
4196 Requires<[IsBookE]>;
4197 def RFCI : XForm_0<19, 51, (outs), (ins), "rfci", IIC_BrB, []>,
4198 Requires<[IsBookE]>;
4200 def RFDI : XForm_0<19, 39, (outs), (ins), "rfdi", IIC_BrB, []>,
4202 def RFMCI : XForm_0<19, 38, (outs), (ins), "rfmci", IIC_BrB, []>,
4205 def MFDCR : XFXForm_1<31, 323, (outs gprc:$RT), (ins i32imm:$SPR),
4206 "mfdcr $RT, $SPR", IIC_SprMFSPR>, Requires<[IsPPC4xx]>;
4207 def MTDCR : XFXForm_1<31, 451, (outs), (ins gprc:$RT, i32imm:$SPR),
4208 "mtdcr $SPR, $RT", IIC_SprMTSPR>, Requires<[IsPPC4xx]>;
4210 def HRFID : XLForm_1_np<19, 274, (outs), (ins), "hrfid", IIC_BrB, []>;
4211 def NAP : XLForm_1_np<19, 434, (outs), (ins), "nap", IIC_BrB, []>;
4213 def ATTN : XForm_attn<0, 256, (outs), (ins), "attn", IIC_BrB>;
4215 def LBZCIX : XForm_base_r3xo_memOp<31, 853, (outs gprc:$RST),
4216 (ins gprc:$A, gprc:$B),
4217 "lbzcix $RST, $A, $B", IIC_LdStLoad, []>;
4218 def LHZCIX : XForm_base_r3xo_memOp<31, 821, (outs gprc:$RST),
4219 (ins gprc:$A, gprc:$B),
4220 "lhzcix $RST, $A, $B", IIC_LdStLoad, []>;
4221 def LWZCIX : XForm_base_r3xo_memOp<31, 789, (outs gprc:$RST),
4222 (ins gprc:$A, gprc:$B),
4223 "lwzcix $RST, $A, $B", IIC_LdStLoad, []>;
4224 def LDCIX : XForm_base_r3xo_memOp<31, 885, (outs gprc:$RST),
4225 (ins gprc:$A, gprc:$B),
4226 "ldcix $RST, $A, $B", IIC_LdStLoad, []>;
4228 def STBCIX : XForm_base_r3xo_memOp<31, 981, (outs),
4229 (ins gprc:$RST, gprc:$A, gprc:$B),
4230 "stbcix $RST, $A, $B", IIC_LdStLoad, []>;
4231 def STHCIX : XForm_base_r3xo_memOp<31, 949, (outs),
4232 (ins gprc:$RST, gprc:$A, gprc:$B),
4233 "sthcix $RST, $A, $B", IIC_LdStLoad, []>;
4234 def STWCIX : XForm_base_r3xo_memOp<31, 917, (outs),
4235 (ins gprc:$RST, gprc:$A, gprc:$B),
4236 "stwcix $RST, $A, $B", IIC_LdStLoad, []>;
4237 def STDCIX : XForm_base_r3xo_memOp<31, 1013, (outs),
4238 (ins gprc:$RST, gprc:$A, gprc:$B),
4239 "stdcix $RST, $A, $B", IIC_LdStLoad, []>;
4241 // External PID Load Store Instructions
4243 def LBEPX : XForm_1<31, 95, (outs gprc:$rD), (ins memrr:$src),
4244 "lbepx $rD, $src", IIC_LdStLoad, []>,
4247 def LFDEPX : XForm_25<31, 607, (outs f8rc:$frD), (ins memrr:$src),
4248 "lfdepx $frD, $src", IIC_LdStLFD, []>,
4251 def LHEPX : XForm_1<31, 287, (outs gprc:$rD), (ins memrr:$src),
4252 "lhepx $rD, $src", IIC_LdStLoad, []>,
4255 def LWEPX : XForm_1<31, 31, (outs gprc:$rD), (ins memrr:$src),
4256 "lwepx $rD, $src", IIC_LdStLoad, []>,
4259 def STBEPX : XForm_8<31, 223, (outs), (ins gprc:$rS, memrr:$dst),
4260 "stbepx $rS, $dst", IIC_LdStStore, []>,
4263 def STFDEPX : XForm_28_memOp<31, 735, (outs), (ins f8rc:$frS, memrr:$dst),
4264 "stfdepx $frS, $dst", IIC_LdStSTFD, []>,
4267 def STHEPX : XForm_8<31, 415, (outs), (ins gprc:$rS, memrr:$dst),
4268 "sthepx $rS, $dst", IIC_LdStStore, []>,
4271 def STWEPX : XForm_8<31, 159, (outs), (ins gprc:$rS, memrr:$dst),
4272 "stwepx $rS, $dst", IIC_LdStStore, []>,
4275 def DCBFEP : DCB_Form<127, 0, (outs), (ins memrr:$dst), "dcbfep $dst",
4276 IIC_LdStDCBF, []>, Requires<[IsE500]>;
4278 def DCBSTEP : DCB_Form<63, 0, (outs), (ins memrr:$dst), "dcbstep $dst",
4279 IIC_LdStDCBF, []>, Requires<[IsE500]>;
4281 def DCBTEP : DCB_Form_hint<319, (outs), (ins memrr:$dst, u5imm:$TH),
4282 "dcbtep $TH, $dst", IIC_LdStDCBF, []>,
4285 def DCBTSTEP : DCB_Form_hint<255, (outs), (ins memrr:$dst, u5imm:$TH),
4286 "dcbtstep $TH, $dst", IIC_LdStDCBF, []>,
4289 def DCBZEP : DCB_Form<1023, 0, (outs), (ins memrr:$dst), "dcbzep $dst",
4290 IIC_LdStDCBF, []>, Requires<[IsE500]>;
4292 def DCBZLEP : DCB_Form<1023, 1, (outs), (ins memrr:$dst), "dcbzlep $dst",
4293 IIC_LdStDCBF, []>, Requires<[IsE500]>;
4295 def ICBIEP : XForm_1a<31, 991, (outs), (ins memrr:$src), "icbiep $src",
4296 IIC_LdStICBI, []>, Requires<[IsE500]>;
4298 //===----------------------------------------------------------------------===//
4299 // PowerPC Assembler Instruction Aliases
4302 // Pseudo-instructions for alternate assembly syntax (never used by codegen).
4303 // These are aliases that require C++ handling to convert to the target
4304 // instruction, while InstAliases can be handled directly by tblgen.
4305 class PPCAsmPseudo<string asm, dag iops>
4307 let Namespace = "PPC";
4308 bit PPC64 = 0; // Default value, override with isPPC64
4310 let OutOperandList = (outs);
4311 let InOperandList = iops;
4313 let AsmString = asm;
4314 let isAsmParserOnly = 1;
4316 let hasNoSchedulingInfo = 1;
4319 def : InstAlias<"sc", (SC 0)>;
4321 def : InstAlias<"sync", (SYNC 0)>, Requires<[HasSYNC]>;
4322 def : InstAlias<"msync", (SYNC 0), 0>, Requires<[HasSYNC]>;
4323 def : InstAlias<"lwsync", (SYNC 1)>, Requires<[HasSYNC]>;
4324 def : InstAlias<"ptesync", (SYNC 2)>, Requires<[HasSYNC]>;
4326 def : InstAlias<"wait", (WAIT 0)>;
4327 def : InstAlias<"waitrsv", (WAIT 1)>;
4328 def : InstAlias<"waitimpl", (WAIT 2)>;
4330 def : InstAlias<"mbar", (MBAR 0)>, Requires<[IsBookE]>;
4332 def DCBTx : PPCAsmPseudo<"dcbt $dst", (ins memrr:$dst)>;
4333 def DCBTSTx : PPCAsmPseudo<"dcbtst $dst", (ins memrr:$dst)>;
4335 def DCBTCT : PPCAsmPseudo<"dcbtct $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
4336 def DCBTDS : PPCAsmPseudo<"dcbtds $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
4337 def DCBTT : PPCAsmPseudo<"dcbtt $dst", (ins memrr:$dst)>;
4339 def DCBTSTCT : PPCAsmPseudo<"dcbtstct $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
4340 def DCBTSTDS : PPCAsmPseudo<"dcbtstds $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
4341 def DCBTSTT : PPCAsmPseudo<"dcbtstt $dst", (ins memrr:$dst)>;
4343 def DCBFx : PPCAsmPseudo<"dcbf $dst", (ins memrr:$dst)>;
4344 def DCBFL : PPCAsmPseudo<"dcbfl $dst", (ins memrr:$dst)>;
4345 def DCBFLP : PPCAsmPseudo<"dcbflp $dst", (ins memrr:$dst)>;
4347 def : InstAlias<"crset $bx", (CREQV crbitrc:$bx, crbitrc:$bx, crbitrc:$bx)>;
4348 def : InstAlias<"crclr $bx", (CRXOR crbitrc:$bx, crbitrc:$bx, crbitrc:$bx)>;
4349 def : InstAlias<"crmove $bx, $by", (CROR crbitrc:$bx, crbitrc:$by, crbitrc:$by)>;
4350 def : InstAlias<"crnot $bx, $by", (CRNOR crbitrc:$bx, crbitrc:$by, crbitrc:$by)>;
4352 def : InstAlias<"mtxer $Rx", (MTSPR 1, gprc:$Rx)>;
4353 def : InstAlias<"mfxer $Rx", (MFSPR gprc:$Rx, 1)>;
4355 def : InstAlias<"mfrtcu $Rx", (MFSPR gprc:$Rx, 4)>;
4356 def : InstAlias<"mfrtcl $Rx", (MFSPR gprc:$Rx, 5)>;
4358 def : InstAlias<"mtdscr $Rx", (MTSPR 17, gprc:$Rx)>;
4359 def : InstAlias<"mfdscr $Rx", (MFSPR gprc:$Rx, 17)>;
4361 def : InstAlias<"mtdsisr $Rx", (MTSPR 18, gprc:$Rx)>;
4362 def : InstAlias<"mfdsisr $Rx", (MFSPR gprc:$Rx, 18)>;
4364 def : InstAlias<"mtdar $Rx", (MTSPR 19, gprc:$Rx)>;
4365 def : InstAlias<"mfdar $Rx", (MFSPR gprc:$Rx, 19)>;
4367 def : InstAlias<"mtdec $Rx", (MTSPR 22, gprc:$Rx)>;
4368 def : InstAlias<"mfdec $Rx", (MFSPR gprc:$Rx, 22)>;
4370 def : InstAlias<"mtsdr1 $Rx", (MTSPR 25, gprc:$Rx)>;
4371 def : InstAlias<"mfsdr1 $Rx", (MFSPR gprc:$Rx, 25)>;
4373 def : InstAlias<"mtsrr0 $Rx", (MTSPR 26, gprc:$Rx)>;
4374 def : InstAlias<"mfsrr0 $Rx", (MFSPR gprc:$Rx, 26)>;
4376 def : InstAlias<"mtsrr1 $Rx", (MTSPR 27, gprc:$Rx)>;
4377 def : InstAlias<"mfsrr1 $Rx", (MFSPR gprc:$Rx, 27)>;
4379 def : InstAlias<"mtsrr2 $Rx", (MTSPR 990, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4380 def : InstAlias<"mfsrr2 $Rx", (MFSPR gprc:$Rx, 990)>, Requires<[IsPPC4xx]>;
4382 def : InstAlias<"mtsrr3 $Rx", (MTSPR 991, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4383 def : InstAlias<"mfsrr3 $Rx", (MFSPR gprc:$Rx, 991)>, Requires<[IsPPC4xx]>;
4385 def : InstAlias<"mtcfar $Rx", (MTSPR 28, gprc:$Rx)>;
4386 def : InstAlias<"mfcfar $Rx", (MFSPR gprc:$Rx, 28)>;
4388 def : InstAlias<"mtamr $Rx", (MTSPR 29, gprc:$Rx)>;
4389 def : InstAlias<"mfamr $Rx", (MFSPR gprc:$Rx, 29)>;
4391 def : InstAlias<"mtpid $Rx", (MTSPR 48, gprc:$Rx)>, Requires<[IsBookE]>;
4392 def : InstAlias<"mfpid $Rx", (MFSPR gprc:$Rx, 48)>, Requires<[IsBookE]>;
4394 def : InstAlias<"mftb $Rx", (MFTB gprc:$Rx, 268)>;
4395 def : InstAlias<"mftbl $Rx", (MFTB gprc:$Rx, 268)>;
4396 def : InstAlias<"mftbu $Rx", (MFTB gprc:$Rx, 269)>;
4398 def : InstAlias<"mttbl $Rx", (MTSPR 284, gprc:$Rx)>;
4399 def : InstAlias<"mttbu $Rx", (MTSPR 285, gprc:$Rx)>;
4401 def : InstAlias<"mftblo $Rx", (MFSPR gprc:$Rx, 989)>, Requires<[IsPPC4xx]>;
4402 def : InstAlias<"mttblo $Rx", (MTSPR 989, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4403 def : InstAlias<"mftbhi $Rx", (MFSPR gprc:$Rx, 988)>, Requires<[IsPPC4xx]>;
4404 def : InstAlias<"mttbhi $Rx", (MTSPR 988, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4406 def : InstAlias<"xnop", (XORI R0, R0, 0)>;
4408 def : InstAlias<"mr $rA, $rB", (OR8 g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
4409 def : InstAlias<"mr. $rA, $rB", (OR8o g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
4411 def : InstAlias<"not $rA, $rB", (NOR8 g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
4412 def : InstAlias<"not. $rA, $rB", (NOR8o g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
4414 def : InstAlias<"mtcr $rA", (MTCRF8 255, g8rc:$rA)>;
4416 foreach BATR = 0-3 in {
4417 def : InstAlias<"mtdbatu "#BATR#", $Rx",
4418 (MTSPR !add(BATR, !add(BATR, 536)), gprc:$Rx)>,
4419 Requires<[IsPPC6xx]>;
4420 def : InstAlias<"mfdbatu $Rx, "#BATR,
4421 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 536)))>,
4422 Requires<[IsPPC6xx]>;
4423 def : InstAlias<"mtdbatl "#BATR#", $Rx",
4424 (MTSPR !add(BATR, !add(BATR, 537)), gprc:$Rx)>,
4425 Requires<[IsPPC6xx]>;
4426 def : InstAlias<"mfdbatl $Rx, "#BATR,
4427 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 537)))>,
4428 Requires<[IsPPC6xx]>;
4429 def : InstAlias<"mtibatu "#BATR#", $Rx",
4430 (MTSPR !add(BATR, !add(BATR, 528)), gprc:$Rx)>,
4431 Requires<[IsPPC6xx]>;
4432 def : InstAlias<"mfibatu $Rx, "#BATR,
4433 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 528)))>,
4434 Requires<[IsPPC6xx]>;
4435 def : InstAlias<"mtibatl "#BATR#", $Rx",
4436 (MTSPR !add(BATR, !add(BATR, 529)), gprc:$Rx)>,
4437 Requires<[IsPPC6xx]>;
4438 def : InstAlias<"mfibatl $Rx, "#BATR,
4439 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 529)))>,
4440 Requires<[IsPPC6xx]>;
4443 foreach BR = 0-7 in {
4444 def : InstAlias<"mfbr"#BR#" $Rx",
4445 (MFDCR gprc:$Rx, !add(BR, 0x80))>,
4446 Requires<[IsPPC4xx]>;
4447 def : InstAlias<"mtbr"#BR#" $Rx",
4448 (MTDCR gprc:$Rx, !add(BR, 0x80))>,
4449 Requires<[IsPPC4xx]>;
4452 def : InstAlias<"mtdccr $Rx", (MTSPR 1018, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4453 def : InstAlias<"mfdccr $Rx", (MFSPR gprc:$Rx, 1018)>, Requires<[IsPPC4xx]>;
4455 def : InstAlias<"mticcr $Rx", (MTSPR 1019, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4456 def : InstAlias<"mficcr $Rx", (MFSPR gprc:$Rx, 1019)>, Requires<[IsPPC4xx]>;
4458 def : InstAlias<"mtdear $Rx", (MTSPR 981, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4459 def : InstAlias<"mfdear $Rx", (MFSPR gprc:$Rx, 981)>, Requires<[IsPPC4xx]>;
4461 def : InstAlias<"mtesr $Rx", (MTSPR 980, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4462 def : InstAlias<"mfesr $Rx", (MFSPR gprc:$Rx, 980)>, Requires<[IsPPC4xx]>;
4464 def : InstAlias<"mfspefscr $Rx", (MFSPR gprc:$Rx, 512)>;
4465 def : InstAlias<"mtspefscr $Rx", (MTSPR 512, gprc:$Rx)>;
4467 def : InstAlias<"mttcr $Rx", (MTSPR 986, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4468 def : InstAlias<"mftcr $Rx", (MFSPR gprc:$Rx, 986)>, Requires<[IsPPC4xx]>;
4470 def LAx : PPCAsmPseudo<"la $rA, $addr", (ins gprc:$rA, memri:$addr)>;
4472 def SUBI : PPCAsmPseudo<"subi $rA, $rB, $imm",
4473 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4474 def SUBIS : PPCAsmPseudo<"subis $rA, $rB, $imm",
4475 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4476 def SUBIC : PPCAsmPseudo<"subic $rA, $rB, $imm",
4477 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4478 def SUBICo : PPCAsmPseudo<"subic. $rA, $rB, $imm",
4479 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4481 def : InstAlias<"sub $rA, $rB, $rC", (SUBF8 g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
4482 def : InstAlias<"sub. $rA, $rB, $rC", (SUBF8o g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
4483 def : InstAlias<"subc $rA, $rB, $rC", (SUBFC8 g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
4484 def : InstAlias<"subc. $rA, $rB, $rC", (SUBFC8o g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
4486 def : InstAlias<"mtmsrd $RS", (MTMSRD gprc:$RS, 0)>;
4487 def : InstAlias<"mtmsr $RS", (MTMSR gprc:$RS, 0)>;
4489 def : InstAlias<"mfasr $RT", (MFSPR gprc:$RT, 280)>;
4490 def : InstAlias<"mtasr $RT", (MTSPR 280, gprc:$RT)>;
4492 foreach SPRG = 0-3 in {
4493 def : InstAlias<"mfsprg $RT, "#SPRG, (MFSPR gprc:$RT, !add(SPRG, 272))>;
4494 def : InstAlias<"mfsprg"#SPRG#" $RT", (MFSPR gprc:$RT, !add(SPRG, 272))>;
4495 def : InstAlias<"mtsprg "#SPRG#", $RT", (MTSPR !add(SPRG, 272), gprc:$RT)>;
4496 def : InstAlias<"mtsprg"#SPRG#" $RT", (MTSPR !add(SPRG, 272), gprc:$RT)>;
4498 foreach SPRG = 4-7 in {
4499 def : InstAlias<"mfsprg $RT, "#SPRG, (MFSPR gprc:$RT, !add(SPRG, 256))>,
4500 Requires<[IsBookE]>;
4501 def : InstAlias<"mfsprg"#SPRG#" $RT", (MFSPR gprc:$RT, !add(SPRG, 256))>,
4502 Requires<[IsBookE]>;
4503 def : InstAlias<"mtsprg "#SPRG#", $RT", (MTSPR !add(SPRG, 256), gprc:$RT)>,
4504 Requires<[IsBookE]>;
4505 def : InstAlias<"mtsprg"#SPRG#" $RT", (MTSPR !add(SPRG, 256), gprc:$RT)>,
4506 Requires<[IsBookE]>;
4509 def : InstAlias<"mtasr $RS", (MTSPR 280, gprc:$RS)>;
4511 def : InstAlias<"mfdec $RT", (MFSPR gprc:$RT, 22)>;
4512 def : InstAlias<"mtdec $RT", (MTSPR 22, gprc:$RT)>;
4514 def : InstAlias<"mfpvr $RT", (MFSPR gprc:$RT, 287)>;
4516 def : InstAlias<"mfsdr1 $RT", (MFSPR gprc:$RT, 25)>;
4517 def : InstAlias<"mtsdr1 $RT", (MTSPR 25, gprc:$RT)>;
4519 def : InstAlias<"mfsrr0 $RT", (MFSPR gprc:$RT, 26)>;
4520 def : InstAlias<"mfsrr1 $RT", (MFSPR gprc:$RT, 27)>;
4521 def : InstAlias<"mtsrr0 $RT", (MTSPR 26, gprc:$RT)>;
4522 def : InstAlias<"mtsrr1 $RT", (MTSPR 27, gprc:$RT)>;
4524 def : InstAlias<"tlbie $RB", (TLBIE R0, gprc:$RB)>;
4526 def : InstAlias<"tlbrehi $RS, $A", (TLBRE2 gprc:$RS, gprc:$A, 0)>,
4527 Requires<[IsPPC4xx]>;
4528 def : InstAlias<"tlbrelo $RS, $A", (TLBRE2 gprc:$RS, gprc:$A, 1)>,
4529 Requires<[IsPPC4xx]>;
4530 def : InstAlias<"tlbwehi $RS, $A", (TLBWE2 gprc:$RS, gprc:$A, 0)>,
4531 Requires<[IsPPC4xx]>;
4532 def : InstAlias<"tlbwelo $RS, $A", (TLBWE2 gprc:$RS, gprc:$A, 1)>,
4533 Requires<[IsPPC4xx]>;
4535 def EXTLWI : PPCAsmPseudo<"extlwi $rA, $rS, $n, $b",
4536 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4537 def EXTLWIo : PPCAsmPseudo<"extlwi. $rA, $rS, $n, $b",
4538 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4539 def EXTRWI : PPCAsmPseudo<"extrwi $rA, $rS, $n, $b",
4540 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4541 def EXTRWIo : PPCAsmPseudo<"extrwi. $rA, $rS, $n, $b",
4542 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4543 def INSLWI : PPCAsmPseudo<"inslwi $rA, $rS, $n, $b",
4544 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4545 def INSLWIo : PPCAsmPseudo<"inslwi. $rA, $rS, $n, $b",
4546 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4547 def INSRWI : PPCAsmPseudo<"insrwi $rA, $rS, $n, $b",
4548 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4549 def INSRWIo : PPCAsmPseudo<"insrwi. $rA, $rS, $n, $b",
4550 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4551 def ROTRWI : PPCAsmPseudo<"rotrwi $rA, $rS, $n",
4552 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4553 def ROTRWIo : PPCAsmPseudo<"rotrwi. $rA, $rS, $n",
4554 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4555 def SLWI : PPCAsmPseudo<"slwi $rA, $rS, $n",
4556 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4557 def SLWIo : PPCAsmPseudo<"slwi. $rA, $rS, $n",
4558 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4559 def SRWI : PPCAsmPseudo<"srwi $rA, $rS, $n",
4560 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4561 def SRWIo : PPCAsmPseudo<"srwi. $rA, $rS, $n",
4562 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4563 def CLRRWI : PPCAsmPseudo<"clrrwi $rA, $rS, $n",
4564 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4565 def CLRRWIo : PPCAsmPseudo<"clrrwi. $rA, $rS, $n",
4566 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4567 def CLRLSLWI : PPCAsmPseudo<"clrlslwi $rA, $rS, $b, $n",
4568 (ins gprc:$rA, gprc:$rS, u5imm:$b, u5imm:$n)>;
4569 def CLRLSLWIo : PPCAsmPseudo<"clrlslwi. $rA, $rS, $b, $n",
4570 (ins gprc:$rA, gprc:$rS, u5imm:$b, u5imm:$n)>;
4572 def : InstAlias<"rotlwi $rA, $rS, $n", (RLWINM gprc:$rA, gprc:$rS, u5imm:$n, 0, 31)>;
4573 def : InstAlias<"rotlwi. $rA, $rS, $n", (RLWINMo gprc:$rA, gprc:$rS, u5imm:$n, 0, 31)>;
4574 def : InstAlias<"rotlw $rA, $rS, $rB", (RLWNM gprc:$rA, gprc:$rS, gprc:$rB, 0, 31)>;
4575 def : InstAlias<"rotlw. $rA, $rS, $rB", (RLWNMo gprc:$rA, gprc:$rS, gprc:$rB, 0, 31)>;
4576 def : InstAlias<"clrlwi $rA, $rS, $n", (RLWINM gprc:$rA, gprc:$rS, 0, u5imm:$n, 31)>;
4577 def : InstAlias<"clrlwi. $rA, $rS, $n", (RLWINMo gprc:$rA, gprc:$rS, 0, u5imm:$n, 31)>;
4579 def : InstAlias<"cntlzw $rA, $rS", (CNTLZW gprc:$rA, gprc:$rS)>;
4580 def : InstAlias<"cntlzw. $rA, $rS", (CNTLZWo gprc:$rA, gprc:$rS)>;
4581 // The POWER variant
4582 def : MnemonicAlias<"cntlz", "cntlzw">;
4583 def : MnemonicAlias<"cntlz.", "cntlzw.">;
4585 def EXTLDI : PPCAsmPseudo<"extldi $rA, $rS, $n, $b",
4586 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4587 def EXTLDIo : PPCAsmPseudo<"extldi. $rA, $rS, $n, $b",
4588 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4589 def EXTRDI : PPCAsmPseudo<"extrdi $rA, $rS, $n, $b",
4590 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4591 def EXTRDIo : PPCAsmPseudo<"extrdi. $rA, $rS, $n, $b",
4592 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4593 def INSRDI : PPCAsmPseudo<"insrdi $rA, $rS, $n, $b",
4594 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4595 def INSRDIo : PPCAsmPseudo<"insrdi. $rA, $rS, $n, $b",
4596 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4597 def ROTRDI : PPCAsmPseudo<"rotrdi $rA, $rS, $n",
4598 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4599 def ROTRDIo : PPCAsmPseudo<"rotrdi. $rA, $rS, $n",
4600 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4601 def SLDI : PPCAsmPseudo<"sldi $rA, $rS, $n",
4602 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4603 def SLDIo : PPCAsmPseudo<"sldi. $rA, $rS, $n",
4604 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4605 def SRDI : PPCAsmPseudo<"srdi $rA, $rS, $n",
4606 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4607 def SRDIo : PPCAsmPseudo<"srdi. $rA, $rS, $n",
4608 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4609 def CLRRDI : PPCAsmPseudo<"clrrdi $rA, $rS, $n",
4610 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4611 def CLRRDIo : PPCAsmPseudo<"clrrdi. $rA, $rS, $n",
4612 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4613 def CLRLSLDI : PPCAsmPseudo<"clrlsldi $rA, $rS, $b, $n",
4614 (ins g8rc:$rA, g8rc:$rS, u6imm:$b, u6imm:$n)>;
4615 def CLRLSLDIo : PPCAsmPseudo<"clrlsldi. $rA, $rS, $b, $n",
4616 (ins g8rc:$rA, g8rc:$rS, u6imm:$b, u6imm:$n)>;
4617 def SUBPCIS : PPCAsmPseudo<"subpcis $RT, $D", (ins g8rc:$RT, s16imm:$D)>;
4619 def : InstAlias<"rotldi $rA, $rS, $n", (RLDICL g8rc:$rA, g8rc:$rS, u6imm:$n, 0)>;
4620 def : InstAlias<"rotldi. $rA, $rS, $n", (RLDICLo g8rc:$rA, g8rc:$rS, u6imm:$n, 0)>;
4621 def : InstAlias<"rotld $rA, $rS, $rB", (RLDCL g8rc:$rA, g8rc:$rS, gprc:$rB, 0)>;
4622 def : InstAlias<"rotld. $rA, $rS, $rB", (RLDCLo g8rc:$rA, g8rc:$rS, gprc:$rB, 0)>;
4623 def : InstAlias<"clrldi $rA, $rS, $n", (RLDICL g8rc:$rA, g8rc:$rS, 0, u6imm:$n)>;
4624 def : InstAlias<"clrldi $rA, $rS, $n",
4625 (RLDICL_32_64 g8rc:$rA, gprc:$rS, 0, u6imm:$n)>;
4626 def : InstAlias<"clrldi. $rA, $rS, $n", (RLDICLo g8rc:$rA, g8rc:$rS, 0, u6imm:$n)>;
4627 def : InstAlias<"lnia $RT", (ADDPCIS g8rc:$RT, 0)>;
4629 def RLWINMbm : PPCAsmPseudo<"rlwinm $rA, $rS, $n, $b",
4630 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4631 def RLWINMobm : PPCAsmPseudo<"rlwinm. $rA, $rS, $n, $b",
4632 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4633 def RLWIMIbm : PPCAsmPseudo<"rlwimi $rA, $rS, $n, $b",
4634 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4635 def RLWIMIobm : PPCAsmPseudo<"rlwimi. $rA, $rS, $n, $b",
4636 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4637 def RLWNMbm : PPCAsmPseudo<"rlwnm $rA, $rS, $n, $b",
4638 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4639 def RLWNMobm : PPCAsmPseudo<"rlwnm. $rA, $rS, $n, $b",
4640 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4642 // These generic branch instruction forms are used for the assembler parser only.
4643 // Defs and Uses are conservative, since we don't know the BO value.
4644 let PPC970_Unit = 7, isBranch = 1 in {
4645 let Defs = [CTR], Uses = [CTR, RM] in {
4646 def gBC : BForm_3<16, 0, 0, (outs),
4647 (ins u5imm:$bo, crbitrc:$bi, condbrtarget:$dst),
4648 "bc $bo, $bi, $dst">;
4649 def gBCA : BForm_3<16, 1, 0, (outs),
4650 (ins u5imm:$bo, crbitrc:$bi, abscondbrtarget:$dst),
4651 "bca $bo, $bi, $dst">;
4652 let isAsmParserOnly = 1 in {
4653 def gBCat : BForm_3_at<16, 0, 0, (outs),
4654 (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
4656 "bc$at $bo, $bi, $dst">;
4657 def gBCAat : BForm_3_at<16, 1, 0, (outs),
4658 (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
4659 abscondbrtarget:$dst),
4660 "bca$at $bo, $bi, $dst">;
4661 } // isAsmParserOnly = 1
4663 let Defs = [LR, CTR], Uses = [CTR, RM] in {
4664 def gBCL : BForm_3<16, 0, 1, (outs),
4665 (ins u5imm:$bo, crbitrc:$bi, condbrtarget:$dst),
4666 "bcl $bo, $bi, $dst">;
4667 def gBCLA : BForm_3<16, 1, 1, (outs),
4668 (ins u5imm:$bo, crbitrc:$bi, abscondbrtarget:$dst),
4669 "bcla $bo, $bi, $dst">;
4670 let isAsmParserOnly = 1 in {
4671 def gBCLat : BForm_3_at<16, 0, 1, (outs),
4672 (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
4674 "bcl$at $bo, $bi, $dst">;
4675 def gBCLAat : BForm_3_at<16, 1, 1, (outs),
4676 (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
4677 abscondbrtarget:$dst),
4678 "bcla$at $bo, $bi, $dst">;
4679 } // // isAsmParserOnly = 1
4681 let Defs = [CTR], Uses = [CTR, LR, RM] in
4682 def gBCLR : XLForm_2<19, 16, 0, (outs),
4683 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
4684 "bclr $bo, $bi, $bh", IIC_BrB, []>;
4685 let Defs = [LR, CTR], Uses = [CTR, LR, RM] in
4686 def gBCLRL : XLForm_2<19, 16, 1, (outs),
4687 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
4688 "bclrl $bo, $bi, $bh", IIC_BrB, []>;
4689 let Defs = [CTR], Uses = [CTR, LR, RM] in
4690 def gBCCTR : XLForm_2<19, 528, 0, (outs),
4691 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
4692 "bcctr $bo, $bi, $bh", IIC_BrB, []>;
4693 let Defs = [LR, CTR], Uses = [CTR, LR, RM] in
4694 def gBCCTRL : XLForm_2<19, 528, 1, (outs),
4695 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
4696 "bcctrl $bo, $bi, $bh", IIC_BrB, []>;
4699 multiclass BranchSimpleMnemonicAT<string pm, int at> {
4700 def : InstAlias<"bc"#pm#" $bo, $bi, $dst", (gBCat u5imm:$bo, at, crbitrc:$bi,
4701 condbrtarget:$dst)>;
4702 def : InstAlias<"bca"#pm#" $bo, $bi, $dst", (gBCAat u5imm:$bo, at, crbitrc:$bi,
4703 condbrtarget:$dst)>;
4704 def : InstAlias<"bcl"#pm#" $bo, $bi, $dst", (gBCLat u5imm:$bo, at, crbitrc:$bi,
4705 condbrtarget:$dst)>;
4706 def : InstAlias<"bcla"#pm#" $bo, $bi, $dst", (gBCLAat u5imm:$bo, at, crbitrc:$bi,
4707 condbrtarget:$dst)>;
4709 defm : BranchSimpleMnemonicAT<"+", 3>;
4710 defm : BranchSimpleMnemonicAT<"-", 2>;
4712 def : InstAlias<"bclr $bo, $bi", (gBCLR u5imm:$bo, crbitrc:$bi, 0)>;
4713 def : InstAlias<"bclrl $bo, $bi", (gBCLRL u5imm:$bo, crbitrc:$bi, 0)>;
4714 def : InstAlias<"bcctr $bo, $bi", (gBCCTR u5imm:$bo, crbitrc:$bi, 0)>;
4715 def : InstAlias<"bcctrl $bo, $bi", (gBCCTRL u5imm:$bo, crbitrc:$bi, 0)>;
4717 multiclass BranchSimpleMnemonic1<string name, string pm, int bo> {
4718 def : InstAlias<"b"#name#pm#" $bi, $dst", (gBC bo, crbitrc:$bi, condbrtarget:$dst)>;
4719 def : InstAlias<"b"#name#"a"#pm#" $bi, $dst", (gBCA bo, crbitrc:$bi, abscondbrtarget:$dst)>;
4720 def : InstAlias<"b"#name#"lr"#pm#" $bi", (gBCLR bo, crbitrc:$bi, 0)>;
4721 def : InstAlias<"b"#name#"l"#pm#" $bi, $dst", (gBCL bo, crbitrc:$bi, condbrtarget:$dst)>;
4722 def : InstAlias<"b"#name#"la"#pm#" $bi, $dst", (gBCLA bo, crbitrc:$bi, abscondbrtarget:$dst)>;
4723 def : InstAlias<"b"#name#"lrl"#pm#" $bi", (gBCLRL bo, crbitrc:$bi, 0)>;
4725 multiclass BranchSimpleMnemonic2<string name, string pm, int bo>
4726 : BranchSimpleMnemonic1<name, pm, bo> {
4727 def : InstAlias<"b"#name#"ctr"#pm#" $bi", (gBCCTR bo, crbitrc:$bi, 0)>;
4728 def : InstAlias<"b"#name#"ctrl"#pm#" $bi", (gBCCTRL bo, crbitrc:$bi, 0)>;
4730 defm : BranchSimpleMnemonic2<"t", "", 12>;
4731 defm : BranchSimpleMnemonic2<"f", "", 4>;
4732 defm : BranchSimpleMnemonic2<"t", "-", 14>;
4733 defm : BranchSimpleMnemonic2<"f", "-", 6>;
4734 defm : BranchSimpleMnemonic2<"t", "+", 15>;
4735 defm : BranchSimpleMnemonic2<"f", "+", 7>;
4736 defm : BranchSimpleMnemonic1<"dnzt", "", 8>;
4737 defm : BranchSimpleMnemonic1<"dnzf", "", 0>;
4738 defm : BranchSimpleMnemonic1<"dzt", "", 10>;
4739 defm : BranchSimpleMnemonic1<"dzf", "", 2>;
4741 multiclass BranchExtendedMnemonicPM<string name, string pm, int bibo> {
4742 def : InstAlias<"b"#name#pm#" $cc, $dst",
4743 (BCC bibo, crrc:$cc, condbrtarget:$dst)>;
4744 def : InstAlias<"b"#name#pm#" $dst",
4745 (BCC bibo, CR0, condbrtarget:$dst)>;
4747 def : InstAlias<"b"#name#"a"#pm#" $cc, $dst",
4748 (BCCA bibo, crrc:$cc, abscondbrtarget:$dst)>;
4749 def : InstAlias<"b"#name#"a"#pm#" $dst",
4750 (BCCA bibo, CR0, abscondbrtarget:$dst)>;
4752 def : InstAlias<"b"#name#"lr"#pm#" $cc",
4753 (BCCLR bibo, crrc:$cc)>;
4754 def : InstAlias<"b"#name#"lr"#pm,
4757 def : InstAlias<"b"#name#"ctr"#pm#" $cc",
4758 (BCCCTR bibo, crrc:$cc)>;
4759 def : InstAlias<"b"#name#"ctr"#pm,
4760 (BCCCTR bibo, CR0)>;
4762 def : InstAlias<"b"#name#"l"#pm#" $cc, $dst",
4763 (BCCL bibo, crrc:$cc, condbrtarget:$dst)>;
4764 def : InstAlias<"b"#name#"l"#pm#" $dst",
4765 (BCCL bibo, CR0, condbrtarget:$dst)>;
4767 def : InstAlias<"b"#name#"la"#pm#" $cc, $dst",
4768 (BCCLA bibo, crrc:$cc, abscondbrtarget:$dst)>;
4769 def : InstAlias<"b"#name#"la"#pm#" $dst",
4770 (BCCLA bibo, CR0, abscondbrtarget:$dst)>;
4772 def : InstAlias<"b"#name#"lrl"#pm#" $cc",
4773 (BCCLRL bibo, crrc:$cc)>;
4774 def : InstAlias<"b"#name#"lrl"#pm,
4775 (BCCLRL bibo, CR0)>;
4777 def : InstAlias<"b"#name#"ctrl"#pm#" $cc",
4778 (BCCCTRL bibo, crrc:$cc)>;
4779 def : InstAlias<"b"#name#"ctrl"#pm,
4780 (BCCCTRL bibo, CR0)>;
4782 multiclass BranchExtendedMnemonic<string name, int bibo> {
4783 defm : BranchExtendedMnemonicPM<name, "", bibo>;
4784 defm : BranchExtendedMnemonicPM<name, "-", !add(bibo, 2)>;
4785 defm : BranchExtendedMnemonicPM<name, "+", !add(bibo, 3)>;
4787 defm : BranchExtendedMnemonic<"lt", 12>;
4788 defm : BranchExtendedMnemonic<"gt", 44>;
4789 defm : BranchExtendedMnemonic<"eq", 76>;
4790 defm : BranchExtendedMnemonic<"un", 108>;
4791 defm : BranchExtendedMnemonic<"so", 108>;
4792 defm : BranchExtendedMnemonic<"ge", 4>;
4793 defm : BranchExtendedMnemonic<"nl", 4>;
4794 defm : BranchExtendedMnemonic<"le", 36>;
4795 defm : BranchExtendedMnemonic<"ng", 36>;
4796 defm : BranchExtendedMnemonic<"ne", 68>;
4797 defm : BranchExtendedMnemonic<"nu", 100>;
4798 defm : BranchExtendedMnemonic<"ns", 100>;
4800 def : InstAlias<"cmpwi $rA, $imm", (CMPWI CR0, gprc:$rA, s16imm:$imm)>;
4801 def : InstAlias<"cmpw $rA, $rB", (CMPW CR0, gprc:$rA, gprc:$rB)>;
4802 def : InstAlias<"cmplwi $rA, $imm", (CMPLWI CR0, gprc:$rA, u16imm:$imm)>;
4803 def : InstAlias<"cmplw $rA, $rB", (CMPLW CR0, gprc:$rA, gprc:$rB)>;
4804 def : InstAlias<"cmpdi $rA, $imm", (CMPDI CR0, g8rc:$rA, s16imm64:$imm)>;
4805 def : InstAlias<"cmpd $rA, $rB", (CMPD CR0, g8rc:$rA, g8rc:$rB)>;
4806 def : InstAlias<"cmpldi $rA, $imm", (CMPLDI CR0, g8rc:$rA, u16imm64:$imm)>;
4807 def : InstAlias<"cmpld $rA, $rB", (CMPLD CR0, g8rc:$rA, g8rc:$rB)>;
4809 def : InstAlias<"cmpi $bf, 0, $rA, $imm", (CMPWI crrc:$bf, gprc:$rA, s16imm:$imm)>;
4810 def : InstAlias<"cmp $bf, 0, $rA, $rB", (CMPW crrc:$bf, gprc:$rA, gprc:$rB)>;
4811 def : InstAlias<"cmpli $bf, 0, $rA, $imm", (CMPLWI crrc:$bf, gprc:$rA, u16imm:$imm)>;
4812 def : InstAlias<"cmpl $bf, 0, $rA, $rB", (CMPLW crrc:$bf, gprc:$rA, gprc:$rB)>;
4813 def : InstAlias<"cmpi $bf, 1, $rA, $imm", (CMPDI crrc:$bf, g8rc:$rA, s16imm64:$imm)>;
4814 def : InstAlias<"cmp $bf, 1, $rA, $rB", (CMPD crrc:$bf, g8rc:$rA, g8rc:$rB)>;
4815 def : InstAlias<"cmpli $bf, 1, $rA, $imm", (CMPLDI crrc:$bf, g8rc:$rA, u16imm64:$imm)>;
4816 def : InstAlias<"cmpl $bf, 1, $rA, $rB", (CMPLD crrc:$bf, g8rc:$rA, g8rc:$rB)>;
4818 multiclass TrapExtendedMnemonic<string name, int to> {
4819 def : InstAlias<"td"#name#"i $rA, $imm", (TDI to, g8rc:$rA, s16imm:$imm)>;
4820 def : InstAlias<"td"#name#" $rA, $rB", (TD to, g8rc:$rA, g8rc:$rB)>;
4821 def : InstAlias<"tw"#name#"i $rA, $imm", (TWI to, gprc:$rA, s16imm:$imm)>;
4822 def : InstAlias<"tw"#name#" $rA, $rB", (TW to, gprc:$rA, gprc:$rB)>;
4824 defm : TrapExtendedMnemonic<"lt", 16>;
4825 defm : TrapExtendedMnemonic<"le", 20>;
4826 defm : TrapExtendedMnemonic<"eq", 4>;
4827 defm : TrapExtendedMnemonic<"ge", 12>;
4828 defm : TrapExtendedMnemonic<"gt", 8>;
4829 defm : TrapExtendedMnemonic<"nl", 12>;
4830 defm : TrapExtendedMnemonic<"ne", 24>;
4831 defm : TrapExtendedMnemonic<"ng", 20>;
4832 defm : TrapExtendedMnemonic<"llt", 2>;
4833 defm : TrapExtendedMnemonic<"lle", 6>;
4834 defm : TrapExtendedMnemonic<"lge", 5>;
4835 defm : TrapExtendedMnemonic<"lgt", 1>;
4836 defm : TrapExtendedMnemonic<"lnl", 5>;
4837 defm : TrapExtendedMnemonic<"lng", 6>;
4838 defm : TrapExtendedMnemonic<"u", 31>;
4841 def : Pat<(atomic_load_8 iaddr:$src), (LBZ memri:$src)>;
4842 def : Pat<(atomic_load_16 iaddr:$src), (LHZ memri:$src)>;
4843 def : Pat<(atomic_load_32 iaddr:$src), (LWZ memri:$src)>;
4844 def : Pat<(atomic_load_8 xaddr:$src), (LBZX memrr:$src)>;
4845 def : Pat<(atomic_load_16 xaddr:$src), (LHZX memrr:$src)>;
4846 def : Pat<(atomic_load_32 xaddr:$src), (LWZX memrr:$src)>;
4849 def : Pat<(atomic_store_8 iaddr:$ptr, i32:$val), (STB gprc:$val, memri:$ptr)>;
4850 def : Pat<(atomic_store_16 iaddr:$ptr, i32:$val), (STH gprc:$val, memri:$ptr)>;
4851 def : Pat<(atomic_store_32 iaddr:$ptr, i32:$val), (STW gprc:$val, memri:$ptr)>;
4852 def : Pat<(atomic_store_8 xaddr:$ptr, i32:$val), (STBX gprc:$val, memrr:$ptr)>;
4853 def : Pat<(atomic_store_16 xaddr:$ptr, i32:$val), (STHX gprc:$val, memrr:$ptr)>;
4854 def : Pat<(atomic_store_32 xaddr:$ptr, i32:$val), (STWX gprc:$val, memrr:$ptr)>;
4856 let Predicates = [IsISA3_0] in {
4858 // Copy-Paste Facility
4859 // We prefix 'CP' to COPY due to name conflict in Target.td. We also prefix to
4860 // PASTE for naming consistency.
4862 def CP_COPY : X_L1_RA5_RB5<31, 774, "copy" , gprc, IIC_LdStCOPY, []>;
4865 def CP_PASTE : X_L1_RA5_RB5<31, 902, "paste" , gprc, IIC_LdStPASTE, []>;
4867 let mayStore = 1, Defs = [CR0] in
4868 def CP_PASTEo : X_L1_RA5_RB5<31, 902, "paste.", gprc, IIC_LdStPASTE, []>, isDOT;
4870 def CP_COPYx : PPCAsmPseudo<"copy $rA, $rB" , (ins gprc:$rA, gprc:$rB)>;
4871 def CP_PASTEx : PPCAsmPseudo<"paste $rA, $rB", (ins gprc:$rA, gprc:$rB)>;
4872 def CP_COPY_FIRST : PPCAsmPseudo<"copy_first $rA, $rB",
4873 (ins gprc:$rA, gprc:$rB)>;
4874 def CP_PASTE_LAST : PPCAsmPseudo<"paste_last $rA, $rB",
4875 (ins gprc:$rA, gprc:$rB)>;
4876 def CP_ABORT : XForm_0<31, 838, (outs), (ins), "cp_abort", IIC_SprABORT, []>;
4878 // Message Synchronize
4879 def MSGSYNC : XForm_0<31, 886, (outs), (ins), "msgsync", IIC_SprMSGSYNC, []>;
4881 // Power-Saving Mode Instruction:
4882 def STOP : XForm_0<19, 370, (outs), (ins), "stop", IIC_SprSTOP, []>;
4886 // Fast 32-bit reverse bits algorithm:
4887 // Step 1: 1-bit swap (swap odd 1-bit and even 1-bit):
4888 // n = ((n >> 1) & 0x55555555) | ((n << 1) & 0xAAAAAAAA);
4889 // Step 2: 2-bit swap (swap odd 2-bit and even 2-bit):
4890 // n = ((n >> 2) & 0x33333333) | ((n << 2) & 0xCCCCCCCC);
4891 // Step 3: 4-bit swap (swap odd 4-bit and even 4-bit):
4892 // n = ((n >> 4) & 0x0F0F0F0F) | ((n << 4) & 0xF0F0F0F0);
4893 // Step 4: byte reverse (Suppose n = [B1,B2,B3,B4]):
4894 // Step 4.1: Put B4,B2 in the right position (rotate left 3 bytes):
4895 // n' = (n rotl 24); After which n' = [B4, B1, B2, B3]
4896 // Step 4.2: Insert B3 to the right position:
4897 // n' = rlwimi n', n, 8, 8, 15; After which n' = [B4, B3, B2, B3]
4898 // Step 4.3: Insert B1 to the right position:
4899 // n' = rlwimi n', n, 8, 24, 31; After which n' = [B4, B3, B2, B1]
4901 dag Lo1 = (ORI (LIS 0x5555), 0x5555);
4902 dag Hi1 = (ORI (LIS 0xAAAA), 0xAAAA);
4903 dag Lo2 = (ORI (LIS 0x3333), 0x3333);
4904 dag Hi2 = (ORI (LIS 0xCCCC), 0xCCCC);
4905 dag Lo4 = (ORI (LIS 0x0F0F), 0x0F0F);
4906 dag Hi4 = (ORI (LIS 0xF0F0), 0xF0F0);
4910 dag Right = (RLWINM $A, 31, 1, 31);
4911 dag Left = (RLWINM $A, 1, 0, 30);
4915 dag Bit = (OR (AND Shift1.Right, MaskValues.Lo1),
4916 (AND Shift1.Left, MaskValues.Hi1));
4920 dag Right = (RLWINM Swap1.Bit, 30, 2, 31);
4921 dag Left = (RLWINM Swap1.Bit, 2, 0, 29);
4925 dag Bits = (OR (AND Shift2.Right, MaskValues.Lo2),
4926 (AND Shift2.Left, MaskValues.Hi2));
4930 dag Right = (RLWINM Swap2.Bits, 28, 4, 31);
4931 dag Left = (RLWINM Swap2.Bits, 4, 0, 27);
4935 dag Bits = (OR (AND Shift4.Right, MaskValues.Lo4),
4936 (AND Shift4.Left, MaskValues.Hi4));
4940 dag Left3Bytes = (RLWINM Swap4.Bits, 24, 0, 31);
4943 def RotateInsertByte3 {
4944 dag Left = (RLWIMI Rotate.Left3Bytes, Swap4.Bits, 8, 8, 15);
4947 def RotateInsertByte1 {
4948 dag Left = (RLWIMI RotateInsertByte3.Left, Swap4.Bits, 8, 24, 31);
4951 def : Pat<(i32 (bitreverse i32:$A)),
4952 (RLDICL_32 RotateInsertByte1.Left, 0, 32)>;
4954 // Fast 64-bit reverse bits algorithm:
4955 // Step 1: 1-bit swap (swap odd 1-bit and even 1-bit):
4956 // n = ((n >> 1) & 0x5555555555555555) | ((n << 1) & 0xAAAAAAAAAAAAAAAA);
4957 // Step 2: 2-bit swap (swap odd 2-bit and even 2-bit):
4958 // n = ((n >> 2) & 0x3333333333333333) | ((n << 2) & 0xCCCCCCCCCCCCCCCC);
4959 // Step 3: 4-bit swap (swap odd 4-bit and even 4-bit):
4960 // n = ((n >> 4) & 0x0F0F0F0F0F0F0F0F) | ((n << 4) & 0xF0F0F0F0F0F0F0F0);
4961 // Step 4: byte reverse (Suppose n = [B0,B1,B2,B3,B4,B5,B6,B7]):
4962 // Apply the same byte reverse algorithm mentioned above for the fast 32-bit
4963 // reverse to both the high 32 bit and low 32 bit of the 64 bit value. And
4964 // then OR them together to get the final result.
4966 dag Lo1 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Lo1, sub_32));
4967 dag Hi1 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Hi1, sub_32));
4968 dag Lo2 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Lo2, sub_32));
4969 dag Hi2 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Hi2, sub_32));
4970 dag Lo4 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Lo4, sub_32));
4971 dag Hi4 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Hi4, sub_32));
4975 dag Lo1 = (ORI8 (ORIS8 (RLDICR MaskValues64.Lo1, 32, 31), 0x5555), 0x5555);
4976 dag Hi1 = (ORI8 (ORIS8 (RLDICR MaskValues64.Hi1, 32, 31), 0xAAAA), 0xAAAA);
4977 dag Lo2 = (ORI8 (ORIS8 (RLDICR MaskValues64.Lo2, 32, 31), 0x3333), 0x3333);
4978 dag Hi2 = (ORI8 (ORIS8 (RLDICR MaskValues64.Hi2, 32, 31), 0xCCCC), 0xCCCC);
4979 dag Lo4 = (ORI8 (ORIS8 (RLDICR MaskValues64.Lo4, 32, 31), 0x0F0F), 0x0F0F);
4980 dag Hi4 = (ORI8 (ORIS8 (RLDICR MaskValues64.Hi4, 32, 31), 0xF0F0), 0xF0F0);
4984 dag Swap1 = (OR8 (AND8 (RLDICL $A, 63, 1), DWMaskValues.Lo1),
4985 (AND8 (RLDICR $A, 1, 62), DWMaskValues.Hi1));
4986 dag Swap2 = (OR8 (AND8 (RLDICL Swap1, 62, 2), DWMaskValues.Lo2),
4987 (AND8 (RLDICR Swap1, 2, 61), DWMaskValues.Hi2));
4988 dag Swap4 = (OR8 (AND8 (RLDICL Swap2, 60, 4), DWMaskValues.Lo4),
4989 (AND8 (RLDICR Swap2, 4, 59), DWMaskValues.Hi4));
4992 // Intra-byte swap is done, now start inter-byte swap.
4994 dag Word = (i32 (EXTRACT_SUBREG DWSwapInByte.Swap4, sub_32));
4998 dag Word = (RLWINM DWBytes4567.Word, 24, 0, 31);
5002 dag Word = (RLWIMI DWBytes7456.Word, DWBytes4567.Word, 8, 8, 15);
5005 // B7 B6 B5 B4 in the right order
5007 dag Word = (RLWIMI DWBytes7656.Word, DWBytes4567.Word, 8, 24, 31);
5009 (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), Word, sub_32));
5013 dag Word = (i32 (EXTRACT_SUBREG (RLDICL DWSwapInByte.Swap4, 32, 32), sub_32));
5017 dag Word = (RLWINM DWBytes0123.Word, 24, 0, 31);
5021 dag Word = (RLWIMI DWBytes3012.Word, DWBytes0123.Word, 8, 8, 15);
5024 // B3 B2 B1 B0 in the right order
5026 dag Word = (RLWIMI DWBytes3212.Word, DWBytes0123.Word, 8, 24, 31);
5028 (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), Word, sub_32));
5031 // Now both high word and low word are reversed, next
5032 // swap the high word and low word.
5033 def : Pat<(i64 (bitreverse i64:$A)),
5034 (OR8 (RLDICR DWBytes7654.DWord, 32, 31), DWBytes3210.DWord)>;