1 //===-- PPCInstrInfo.td - The PowerPC Instruction Set ------*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the subset of the 32-bit PowerPC instruction set, as used
11 // by the PowerPC instruction selector.
13 //===----------------------------------------------------------------------===//
15 include "PPCInstrFormats.td"
17 //===----------------------------------------------------------------------===//
18 // PowerPC specific type constraints.
20 def SDT_PPCstfiwx : SDTypeProfile<0, 2, [ // stfiwx
21 SDTCisVT<0, f64>, SDTCisPtrTy<1>
23 def SDT_PPClfiwx : SDTypeProfile<1, 1, [ // lfiw[az]x
24 SDTCisVT<0, f64>, SDTCisPtrTy<1>
26 def SDT_PPCLxsizx : SDTypeProfile<1, 2, [
27 SDTCisVT<0, f64>, SDTCisPtrTy<1>, SDTCisPtrTy<2>
29 def SDT_PPCstxsix : SDTypeProfile<0, 3, [
30 SDTCisVT<0, f64>, SDTCisPtrTy<1>, SDTCisPtrTy<2>
32 def SDT_PPCcv_fp_to_int : SDTypeProfile<1, 1, [
33 SDTCisFP<0>, SDTCisFP<1>
35 def SDT_PPCstore_scal_int_from_vsr : SDTypeProfile<0, 3, [
36 SDTCisVT<0, f64>, SDTCisPtrTy<1>, SDTCisPtrTy<2>
38 def SDT_PPCVexts : SDTypeProfile<1, 2, [
39 SDTCisVT<0, f64>, SDTCisVT<1, f64>, SDTCisPtrTy<2>
41 def SDT_PPCSExtVElems : SDTypeProfile<1, 1, [
42 SDTCisVec<0>, SDTCisVec<1>
45 def SDT_PPCCallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32>,
47 def SDT_PPCCallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
49 def SDT_PPCvperm : SDTypeProfile<1, 3, [
50 SDTCisVT<3, v16i8>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>
53 def SDT_PPCVecSplat : SDTypeProfile<1, 2, [ SDTCisVec<0>,
54 SDTCisVec<1>, SDTCisInt<2>
57 def SDT_PPCVecShift : SDTypeProfile<1, 3, [ SDTCisVec<0>,
58 SDTCisVec<1>, SDTCisVec<2>, SDTCisPtrTy<3>
61 def SDT_PPCVecInsert : SDTypeProfile<1, 3, [ SDTCisVec<0>,
62 SDTCisVec<1>, SDTCisVec<2>, SDTCisInt<3>
65 def SDT_PPCVecReverse: SDTypeProfile<1, 1, [ SDTCisVec<0>,
69 def SDT_PPCxxpermdi: SDTypeProfile<1, 3, [ SDTCisVec<0>,
70 SDTCisVec<1>, SDTCisVec<2>, SDTCisInt<3>
73 def SDT_PPCvcmp : SDTypeProfile<1, 3, [
74 SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisVT<3, i32>
77 def SDT_PPCcondbr : SDTypeProfile<0, 3, [
78 SDTCisVT<0, i32>, SDTCisVT<2, OtherVT>
81 def SDT_PPClbrx : SDTypeProfile<1, 2, [
82 SDTCisInt<0>, SDTCisPtrTy<1>, SDTCisVT<2, OtherVT>
84 def SDT_PPCstbrx : SDTypeProfile<0, 3, [
85 SDTCisInt<0>, SDTCisPtrTy<1>, SDTCisVT<2, OtherVT>
88 def SDT_PPCTC_ret : SDTypeProfile<0, 2, [
89 SDTCisPtrTy<0>, SDTCisVT<1, i32>
92 def tocentry32 : Operand<iPTR> {
93 let MIOperandInfo = (ops i32imm:$imm);
96 def SDT_PPCqvfperm : SDTypeProfile<1, 3, [
97 SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisVec<3>
99 def SDT_PPCqvgpci : SDTypeProfile<1, 1, [
100 SDTCisVec<0>, SDTCisInt<1>
102 def SDT_PPCqvaligni : SDTypeProfile<1, 3, [
103 SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisInt<3>
105 def SDT_PPCqvesplati : SDTypeProfile<1, 2, [
106 SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisInt<2>
109 def SDT_PPCqbflt : SDTypeProfile<1, 1, [
110 SDTCisVec<0>, SDTCisVec<1>
113 def SDT_PPCqvlfsb : SDTypeProfile<1, 1, [
114 SDTCisVec<0>, SDTCisPtrTy<1>
117 def SDT_PPCextswsli : SDTypeProfile<1, 2, [ // extswsli
118 SDTCisInt<0>, SDTCisInt<1>, SDTCisOpSmallerThanOp<1, 0>, SDTCisInt<2>
121 //===----------------------------------------------------------------------===//
122 // PowerPC specific DAG Nodes.
125 def PPCfre : SDNode<"PPCISD::FRE", SDTFPUnaryOp, []>;
126 def PPCfrsqrte: SDNode<"PPCISD::FRSQRTE", SDTFPUnaryOp, []>;
128 def PPCfcfid : SDNode<"PPCISD::FCFID", SDTFPUnaryOp, []>;
129 def PPCfcfidu : SDNode<"PPCISD::FCFIDU", SDTFPUnaryOp, []>;
130 def PPCfcfids : SDNode<"PPCISD::FCFIDS", SDTFPRoundOp, []>;
131 def PPCfcfidus: SDNode<"PPCISD::FCFIDUS", SDTFPRoundOp, []>;
132 def PPCfctidz : SDNode<"PPCISD::FCTIDZ", SDTFPUnaryOp, []>;
133 def PPCfctiwz : SDNode<"PPCISD::FCTIWZ", SDTFPUnaryOp, []>;
134 def PPCfctiduz: SDNode<"PPCISD::FCTIDUZ",SDTFPUnaryOp, []>;
135 def PPCfctiwuz: SDNode<"PPCISD::FCTIWUZ",SDTFPUnaryOp, []>;
137 def PPCcv_fp_to_uint_in_vsr:
138 SDNode<"PPCISD::FP_TO_UINT_IN_VSR", SDT_PPCcv_fp_to_int, []>;
139 def PPCcv_fp_to_sint_in_vsr:
140 SDNode<"PPCISD::FP_TO_SINT_IN_VSR", SDT_PPCcv_fp_to_int, []>;
141 def PPCstore_scal_int_from_vsr:
142 SDNode<"PPCISD::ST_VSR_SCAL_INT", SDT_PPCstore_scal_int_from_vsr,
143 [SDNPHasChain, SDNPMayStore]>;
144 def PPCstfiwx : SDNode<"PPCISD::STFIWX", SDT_PPCstfiwx,
145 [SDNPHasChain, SDNPMayStore]>;
146 def PPClfiwax : SDNode<"PPCISD::LFIWAX", SDT_PPClfiwx,
147 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
148 def PPClfiwzx : SDNode<"PPCISD::LFIWZX", SDT_PPClfiwx,
149 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
150 def PPClxsizx : SDNode<"PPCISD::LXSIZX", SDT_PPCLxsizx,
151 [SDNPHasChain, SDNPMayLoad]>;
152 def PPCstxsix : SDNode<"PPCISD::STXSIX", SDT_PPCstxsix,
153 [SDNPHasChain, SDNPMayStore]>;
154 def PPCVexts : SDNode<"PPCISD::VEXTS", SDT_PPCVexts, []>;
155 def PPCSExtVElems : SDNode<"PPCISD::SExtVElems", SDT_PPCSExtVElems, []>;
157 // Extract FPSCR (not modeled at the DAG level).
158 def PPCmffs : SDNode<"PPCISD::MFFS",
159 SDTypeProfile<1, 0, [SDTCisVT<0, f64>]>, []>;
161 // Perform FADD in round-to-zero mode.
162 def PPCfaddrtz: SDNode<"PPCISD::FADDRTZ", SDTFPBinOp, []>;
165 def PPCfsel : SDNode<"PPCISD::FSEL",
166 // Type constraint for fsel.
167 SDTypeProfile<1, 3, [SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>,
168 SDTCisFP<0>, SDTCisVT<1, f64>]>, []>;
170 def PPChi : SDNode<"PPCISD::Hi", SDTIntBinOp, []>;
171 def PPClo : SDNode<"PPCISD::Lo", SDTIntBinOp, []>;
172 def PPCtoc_entry: SDNode<"PPCISD::TOC_ENTRY", SDTIntBinOp,
173 [SDNPMayLoad, SDNPMemOperand]>;
174 def PPCvmaddfp : SDNode<"PPCISD::VMADDFP", SDTFPTernaryOp, []>;
175 def PPCvnmsubfp : SDNode<"PPCISD::VNMSUBFP", SDTFPTernaryOp, []>;
177 def PPCppc32GOT : SDNode<"PPCISD::PPC32_GOT", SDTIntLeaf, []>;
179 def PPCaddisGotTprelHA : SDNode<"PPCISD::ADDIS_GOT_TPREL_HA", SDTIntBinOp>;
180 def PPCldGotTprelL : SDNode<"PPCISD::LD_GOT_TPREL_L", SDTIntBinOp,
182 def PPCaddTls : SDNode<"PPCISD::ADD_TLS", SDTIntBinOp, []>;
183 def PPCaddisTlsgdHA : SDNode<"PPCISD::ADDIS_TLSGD_HA", SDTIntBinOp>;
184 def PPCaddiTlsgdL : SDNode<"PPCISD::ADDI_TLSGD_L", SDTIntBinOp>;
185 def PPCgetTlsAddr : SDNode<"PPCISD::GET_TLS_ADDR", SDTIntBinOp>;
186 def PPCaddiTlsgdLAddr : SDNode<"PPCISD::ADDI_TLSGD_L_ADDR",
187 SDTypeProfile<1, 3, [
188 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
189 SDTCisSameAs<0, 3>, SDTCisInt<0> ]>>;
190 def PPCaddisTlsldHA : SDNode<"PPCISD::ADDIS_TLSLD_HA", SDTIntBinOp>;
191 def PPCaddiTlsldL : SDNode<"PPCISD::ADDI_TLSLD_L", SDTIntBinOp>;
192 def PPCgetTlsldAddr : SDNode<"PPCISD::GET_TLSLD_ADDR", SDTIntBinOp>;
193 def PPCaddiTlsldLAddr : SDNode<"PPCISD::ADDI_TLSLD_L_ADDR",
194 SDTypeProfile<1, 3, [
195 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
196 SDTCisSameAs<0, 3>, SDTCisInt<0> ]>>;
197 def PPCaddisDtprelHA : SDNode<"PPCISD::ADDIS_DTPREL_HA", SDTIntBinOp>;
198 def PPCaddiDtprelL : SDNode<"PPCISD::ADDI_DTPREL_L", SDTIntBinOp>;
200 def PPCvperm : SDNode<"PPCISD::VPERM", SDT_PPCvperm, []>;
201 def PPCxxsplt : SDNode<"PPCISD::XXSPLT", SDT_PPCVecSplat, []>;
202 def PPCvecinsert : SDNode<"PPCISD::VECINSERT", SDT_PPCVecInsert, []>;
203 def PPCxxreverse : SDNode<"PPCISD::XXREVERSE", SDT_PPCVecReverse, []>;
204 def PPCxxpermdi : SDNode<"PPCISD::XXPERMDI", SDT_PPCxxpermdi, []>;
205 def PPCvecshl : SDNode<"PPCISD::VECSHL", SDT_PPCVecShift, []>;
207 def PPCqvfperm : SDNode<"PPCISD::QVFPERM", SDT_PPCqvfperm, []>;
208 def PPCqvgpci : SDNode<"PPCISD::QVGPCI", SDT_PPCqvgpci, []>;
209 def PPCqvaligni : SDNode<"PPCISD::QVALIGNI", SDT_PPCqvaligni, []>;
210 def PPCqvesplati : SDNode<"PPCISD::QVESPLATI", SDT_PPCqvesplati, []>;
212 def PPCqbflt : SDNode<"PPCISD::QBFLT", SDT_PPCqbflt, []>;
214 def PPCqvlfsb : SDNode<"PPCISD::QVLFSb", SDT_PPCqvlfsb,
215 [SDNPHasChain, SDNPMayLoad]>;
217 def PPCcmpb : SDNode<"PPCISD::CMPB", SDTIntBinOp, []>;
219 // These nodes represent the 32-bit PPC shifts that operate on 6-bit shift
220 // amounts. These nodes are generated by the multi-precision shift code.
221 def PPCsrl : SDNode<"PPCISD::SRL" , SDTIntShiftOp>;
222 def PPCsra : SDNode<"PPCISD::SRA" , SDTIntShiftOp>;
223 def PPCshl : SDNode<"PPCISD::SHL" , SDTIntShiftOp>;
225 def PPCextswsli : SDNode<"PPCISD::EXTSWSLI" , SDT_PPCextswsli>;
227 // Move 2 i64 values into a VSX register
228 def PPCbuild_fp128: SDNode<"PPCISD::BUILD_FP128",
230 [SDTCisFP<0>, SDTCisSameSizeAs<1,2>,
234 // These are target-independent nodes, but have target-specific formats.
235 def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_PPCCallSeqStart,
236 [SDNPHasChain, SDNPOutGlue]>;
237 def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_PPCCallSeqEnd,
238 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
240 def SDT_PPCCall : SDTypeProfile<0, -1, [SDTCisInt<0>]>;
241 def PPCcall : SDNode<"PPCISD::CALL", SDT_PPCCall,
242 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
244 def PPCcall_nop : SDNode<"PPCISD::CALL_NOP", SDT_PPCCall,
245 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
247 def PPCmtctr : SDNode<"PPCISD::MTCTR", SDT_PPCCall,
248 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
249 def PPCbctrl : SDNode<"PPCISD::BCTRL", SDTNone,
250 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
252 def PPCbctrl_load_toc : SDNode<"PPCISD::BCTRL_LOAD_TOC",
253 SDTypeProfile<0, 1, []>,
254 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
257 def retflag : SDNode<"PPCISD::RET_FLAG", SDTNone,
258 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
260 def PPCtc_return : SDNode<"PPCISD::TC_RETURN", SDT_PPCTC_ret,
261 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
263 def PPCeh_sjlj_setjmp : SDNode<"PPCISD::EH_SJLJ_SETJMP",
264 SDTypeProfile<1, 1, [SDTCisInt<0>,
266 [SDNPHasChain, SDNPSideEffect]>;
267 def PPCeh_sjlj_longjmp : SDNode<"PPCISD::EH_SJLJ_LONGJMP",
268 SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>,
269 [SDNPHasChain, SDNPSideEffect]>;
271 def SDT_PPCsc : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
272 def PPCsc : SDNode<"PPCISD::SC", SDT_PPCsc,
273 [SDNPHasChain, SDNPSideEffect]>;
275 def PPCclrbhrb : SDNode<"PPCISD::CLRBHRB", SDTNone,
276 [SDNPHasChain, SDNPSideEffect]>;
277 def PPCmfbhrbe : SDNode<"PPCISD::MFBHRBE", SDTIntBinOp, [SDNPHasChain]>;
278 def PPCrfebb : SDNode<"PPCISD::RFEBB", SDT_PPCsc,
279 [SDNPHasChain, SDNPSideEffect]>;
281 def PPCvcmp : SDNode<"PPCISD::VCMP" , SDT_PPCvcmp, []>;
282 def PPCvcmp_o : SDNode<"PPCISD::VCMPo", SDT_PPCvcmp, [SDNPOutGlue]>;
284 def PPCcondbranch : SDNode<"PPCISD::COND_BRANCH", SDT_PPCcondbr,
285 [SDNPHasChain, SDNPOptInGlue]>;
287 // PPC-specific atomic operations.
288 def PPCatomicCmpSwap_8 :
289 SDNode<"PPCISD::ATOMIC_CMP_SWAP_8", SDTAtomic3,
290 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
291 def PPCatomicCmpSwap_16 :
292 SDNode<"PPCISD::ATOMIC_CMP_SWAP_16", SDTAtomic3,
293 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
294 def PPClbrx : SDNode<"PPCISD::LBRX", SDT_PPClbrx,
295 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
296 def PPCstbrx : SDNode<"PPCISD::STBRX", SDT_PPCstbrx,
297 [SDNPHasChain, SDNPMayStore]>;
299 // Instructions to set/unset CR bit 6 for SVR4 vararg calls
300 def PPCcr6set : SDNode<"PPCISD::CR6SET", SDTNone,
301 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
302 def PPCcr6unset : SDNode<"PPCISD::CR6UNSET", SDTNone,
303 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
305 // Instructions to support dynamic alloca.
306 def SDTDynOp : SDTypeProfile<1, 2, []>;
307 def SDTDynAreaOp : SDTypeProfile<1, 1, []>;
308 def PPCdynalloc : SDNode<"PPCISD::DYNALLOC", SDTDynOp, [SDNPHasChain]>;
309 def PPCdynareaoffset : SDNode<"PPCISD::DYNAREAOFFSET", SDTDynAreaOp, [SDNPHasChain]>;
311 //===----------------------------------------------------------------------===//
312 // PowerPC specific transformation functions and pattern fragments.
315 def SHL32 : SDNodeXForm<imm, [{
316 // Transformation function: 31 - imm
317 return getI32Imm(31 - N->getZExtValue(), SDLoc(N));
320 def SRL32 : SDNodeXForm<imm, [{
321 // Transformation function: 32 - imm
322 return N->getZExtValue() ? getI32Imm(32 - N->getZExtValue(), SDLoc(N))
323 : getI32Imm(0, SDLoc(N));
326 def LO16 : SDNodeXForm<imm, [{
327 // Transformation function: get the low 16 bits.
328 return getI32Imm((unsigned short)N->getZExtValue(), SDLoc(N));
331 def HI16 : SDNodeXForm<imm, [{
332 // Transformation function: shift the immediate value down into the low bits.
333 return getI32Imm((unsigned)N->getZExtValue() >> 16, SDLoc(N));
336 def HA16 : SDNodeXForm<imm, [{
337 // Transformation function: shift the immediate value down into the low bits.
338 long Val = N->getZExtValue();
339 return getI32Imm((Val - (signed short)Val) >> 16, SDLoc(N));
341 def MB : SDNodeXForm<imm, [{
342 // Transformation function: get the start bit of a mask
344 (void)isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
345 return getI32Imm(mb, SDLoc(N));
348 def ME : SDNodeXForm<imm, [{
349 // Transformation function: get the end bit of a mask
351 (void)isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
352 return getI32Imm(me, SDLoc(N));
354 def maskimm32 : PatLeaf<(imm), [{
355 // maskImm predicate - True if immediate is a run of ones.
357 if (N->getValueType(0) == MVT::i32)
358 return isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
363 def imm32SExt16 : Operand<i32>, ImmLeaf<i32, [{
364 // imm32SExt16 predicate - True if the i32 immediate fits in a 16-bit
365 // sign extended field. Used by instructions like 'addi'.
366 return (int32_t)Imm == (short)Imm;
368 def imm64SExt16 : Operand<i64>, ImmLeaf<i64, [{
369 // imm64SExt16 predicate - True if the i64 immediate fits in a 16-bit
370 // sign extended field. Used by instructions like 'addi'.
371 return (int64_t)Imm == (short)Imm;
373 def immZExt16 : PatLeaf<(imm), [{
374 // immZExt16 predicate - True if the immediate fits in a 16-bit zero extended
375 // field. Used by instructions like 'ori'.
376 return (uint64_t)N->getZExtValue() == (unsigned short)N->getZExtValue();
378 def immAnyExt8 : ImmLeaf<i32, [{ return isInt<8>(Imm) || isUInt<8>(Imm); }]>;
379 def immSExt5NonZero : ImmLeaf<i32, [{ return Imm && isInt<5>(Imm); }]>;
381 // imm16Shifted* - These match immediates where the low 16-bits are zero. There
382 // are two forms: imm16ShiftedSExt and imm16ShiftedZExt. These two forms are
383 // identical in 32-bit mode, but in 64-bit mode, they return true if the
384 // immediate fits into a sign/zero extended 32-bit immediate (with the low bits
386 def imm16ShiftedZExt : PatLeaf<(imm), [{
387 // imm16ShiftedZExt predicate - True if only bits in the top 16-bits of the
388 // immediate are set. Used by instructions like 'xoris'.
389 return (N->getZExtValue() & ~uint64_t(0xFFFF0000)) == 0;
392 def imm16ShiftedSExt : PatLeaf<(imm), [{
393 // imm16ShiftedSExt predicate - True if only bits in the top 16-bits of the
394 // immediate are set. Used by instructions like 'addis'. Identical to
395 // imm16ShiftedZExt in 32-bit mode.
396 if (N->getZExtValue() & 0xFFFF) return false;
397 if (N->getValueType(0) == MVT::i32)
399 // For 64-bit, make sure it is sext right.
400 return N->getZExtValue() == (uint64_t)(int)N->getZExtValue();
403 def imm64ZExt32 : Operand<i64>, ImmLeaf<i64, [{
404 // imm64ZExt32 predicate - True if the i64 immediate fits in a 32-bit
405 // zero extended field.
406 return isUInt<32>(Imm);
409 // Some r+i load/store instructions (such as LD, STD, LDU, etc.) that require
410 // restricted memrix (4-aligned) constants are alignment sensitive. If these
411 // offsets are hidden behind TOC entries than the values of the lower-order
412 // bits cannot be checked directly. As a result, we need to also incorporate
413 // an alignment check into the relevant patterns.
415 def aligned4load : PatFrag<(ops node:$ptr), (load node:$ptr), [{
416 return cast<LoadSDNode>(N)->getAlignment() >= 4;
418 def aligned4store : PatFrag<(ops node:$val, node:$ptr),
419 (store node:$val, node:$ptr), [{
420 return cast<StoreSDNode>(N)->getAlignment() >= 4;
422 def aligned4sextloadi32 : PatFrag<(ops node:$ptr), (sextloadi32 node:$ptr), [{
423 return cast<LoadSDNode>(N)->getAlignment() >= 4;
425 def aligned4pre_store : PatFrag<
426 (ops node:$val, node:$base, node:$offset),
427 (pre_store node:$val, node:$base, node:$offset), [{
428 return cast<StoreSDNode>(N)->getAlignment() >= 4;
431 def unaligned4load : PatFrag<(ops node:$ptr), (load node:$ptr), [{
432 return cast<LoadSDNode>(N)->getAlignment() < 4;
434 def unaligned4store : PatFrag<(ops node:$val, node:$ptr),
435 (store node:$val, node:$ptr), [{
436 return cast<StoreSDNode>(N)->getAlignment() < 4;
438 def unaligned4sextloadi32 : PatFrag<(ops node:$ptr), (sextloadi32 node:$ptr), [{
439 return cast<LoadSDNode>(N)->getAlignment() < 4;
442 // This is a somewhat weaker condition than actually checking for 16-byte
443 // alignment. It is simply checking that the displacement can be represented
444 // as an immediate that is a multiple of 16 (i.e. the requirements for DQ-Form
446 def quadwOffsetLoad : PatFrag<(ops node:$ptr), (load node:$ptr), [{
447 return isOffsetMultipleOf(N, 16);
449 def quadwOffsetStore : PatFrag<(ops node:$val, node:$ptr),
450 (store node:$val, node:$ptr), [{
451 return isOffsetMultipleOf(N, 16);
453 def nonQuadwOffsetLoad : PatFrag<(ops node:$ptr), (load node:$ptr), [{
454 return !isOffsetMultipleOf(N, 16);
456 def nonQuadwOffsetStore : PatFrag<(ops node:$val, node:$ptr),
457 (store node:$val, node:$ptr), [{
458 return !isOffsetMultipleOf(N, 16);
461 //===----------------------------------------------------------------------===//
462 // PowerPC Flag Definitions.
464 class isPPC64 { bit PPC64 = 1; }
465 class isDOT { bit RC = 1; }
467 class RegConstraint<string C> {
468 string Constraints = C;
470 class NoEncode<string E> {
471 string DisableEncoding = E;
475 //===----------------------------------------------------------------------===//
476 // PowerPC Operand Definitions.
478 // In the default PowerPC assembler syntax, registers are specified simply
479 // by number, so they cannot be distinguished from immediate values (without
480 // looking at the opcode). This means that the default operand matching logic
481 // for the asm parser does not work, and we need to specify custom matchers.
482 // Since those can only be specified with RegisterOperand classes and not
483 // directly on the RegisterClass, all instructions patterns used by the asm
484 // parser need to use a RegisterOperand (instead of a RegisterClass) for
485 // all their register operands.
486 // For this purpose, we define one RegisterOperand for each RegisterClass,
487 // using the same name as the class, just in lower case.
489 def PPCRegGPRCAsmOperand : AsmOperandClass {
490 let Name = "RegGPRC"; let PredicateMethod = "isRegNumber";
492 def gprc : RegisterOperand<GPRC> {
493 let ParserMatchClass = PPCRegGPRCAsmOperand;
495 def PPCRegG8RCAsmOperand : AsmOperandClass {
496 let Name = "RegG8RC"; let PredicateMethod = "isRegNumber";
498 def g8rc : RegisterOperand<G8RC> {
499 let ParserMatchClass = PPCRegG8RCAsmOperand;
501 def PPCRegGPRCNoR0AsmOperand : AsmOperandClass {
502 let Name = "RegGPRCNoR0"; let PredicateMethod = "isRegNumber";
504 def gprc_nor0 : RegisterOperand<GPRC_NOR0> {
505 let ParserMatchClass = PPCRegGPRCNoR0AsmOperand;
507 def PPCRegG8RCNoX0AsmOperand : AsmOperandClass {
508 let Name = "RegG8RCNoX0"; let PredicateMethod = "isRegNumber";
510 def g8rc_nox0 : RegisterOperand<G8RC_NOX0> {
511 let ParserMatchClass = PPCRegG8RCNoX0AsmOperand;
513 def PPCRegF8RCAsmOperand : AsmOperandClass {
514 let Name = "RegF8RC"; let PredicateMethod = "isRegNumber";
516 def f8rc : RegisterOperand<F8RC> {
517 let ParserMatchClass = PPCRegF8RCAsmOperand;
519 def PPCRegF4RCAsmOperand : AsmOperandClass {
520 let Name = "RegF4RC"; let PredicateMethod = "isRegNumber";
522 def f4rc : RegisterOperand<F4RC> {
523 let ParserMatchClass = PPCRegF4RCAsmOperand;
525 def PPCRegVRRCAsmOperand : AsmOperandClass {
526 let Name = "RegVRRC"; let PredicateMethod = "isRegNumber";
528 def vrrc : RegisterOperand<VRRC> {
529 let ParserMatchClass = PPCRegVRRCAsmOperand;
531 def PPCRegVFRCAsmOperand : AsmOperandClass {
532 let Name = "RegVFRC"; let PredicateMethod = "isRegNumber";
534 def vfrc : RegisterOperand<VFRC> {
535 let ParserMatchClass = PPCRegVFRCAsmOperand;
537 def PPCRegCRBITRCAsmOperand : AsmOperandClass {
538 let Name = "RegCRBITRC"; let PredicateMethod = "isCRBitNumber";
540 def crbitrc : RegisterOperand<CRBITRC> {
541 let ParserMatchClass = PPCRegCRBITRCAsmOperand;
543 def PPCRegCRRCAsmOperand : AsmOperandClass {
544 let Name = "RegCRRC"; let PredicateMethod = "isCCRegNumber";
546 def crrc : RegisterOperand<CRRC> {
547 let ParserMatchClass = PPCRegCRRCAsmOperand;
549 def crrc0 : RegisterOperand<CRRC0> {
550 let ParserMatchClass = PPCRegCRRCAsmOperand;
553 def PPCRegSPERCAsmOperand : AsmOperandClass {
554 let Name = "RegSPERC"; let PredicateMethod = "isRegNumber";
556 def sperc : RegisterOperand<SPERC> {
557 let ParserMatchClass = PPCRegSPERCAsmOperand;
559 def PPCRegSPE4RCAsmOperand : AsmOperandClass {
560 let Name = "RegSPE4RC"; let PredicateMethod = "isRegNumber";
562 def spe4rc : RegisterOperand<SPE4RC> {
563 let ParserMatchClass = PPCRegSPE4RCAsmOperand;
566 def PPCU1ImmAsmOperand : AsmOperandClass {
567 let Name = "U1Imm"; let PredicateMethod = "isU1Imm";
568 let RenderMethod = "addImmOperands";
570 def u1imm : Operand<i32> {
571 let PrintMethod = "printU1ImmOperand";
572 let ParserMatchClass = PPCU1ImmAsmOperand;
575 def PPCU2ImmAsmOperand : AsmOperandClass {
576 let Name = "U2Imm"; let PredicateMethod = "isU2Imm";
577 let RenderMethod = "addImmOperands";
579 def u2imm : Operand<i32> {
580 let PrintMethod = "printU2ImmOperand";
581 let ParserMatchClass = PPCU2ImmAsmOperand;
584 def PPCATBitsAsHintAsmOperand : AsmOperandClass {
585 let Name = "ATBitsAsHint"; let PredicateMethod = "isATBitsAsHint";
586 let RenderMethod = "addImmOperands"; // Irrelevant, predicate always fails.
588 def atimm : Operand<i32> {
589 let PrintMethod = "printATBitsAsHint";
590 let ParserMatchClass = PPCATBitsAsHintAsmOperand;
593 def PPCU3ImmAsmOperand : AsmOperandClass {
594 let Name = "U3Imm"; let PredicateMethod = "isU3Imm";
595 let RenderMethod = "addImmOperands";
597 def u3imm : Operand<i32> {
598 let PrintMethod = "printU3ImmOperand";
599 let ParserMatchClass = PPCU3ImmAsmOperand;
602 def PPCU4ImmAsmOperand : AsmOperandClass {
603 let Name = "U4Imm"; let PredicateMethod = "isU4Imm";
604 let RenderMethod = "addImmOperands";
606 def u4imm : Operand<i32> {
607 let PrintMethod = "printU4ImmOperand";
608 let ParserMatchClass = PPCU4ImmAsmOperand;
610 def PPCS5ImmAsmOperand : AsmOperandClass {
611 let Name = "S5Imm"; let PredicateMethod = "isS5Imm";
612 let RenderMethod = "addImmOperands";
614 def s5imm : Operand<i32> {
615 let PrintMethod = "printS5ImmOperand";
616 let ParserMatchClass = PPCS5ImmAsmOperand;
617 let DecoderMethod = "decodeSImmOperand<5>";
619 def PPCU5ImmAsmOperand : AsmOperandClass {
620 let Name = "U5Imm"; let PredicateMethod = "isU5Imm";
621 let RenderMethod = "addImmOperands";
623 def u5imm : Operand<i32> {
624 let PrintMethod = "printU5ImmOperand";
625 let ParserMatchClass = PPCU5ImmAsmOperand;
626 let DecoderMethod = "decodeUImmOperand<5>";
628 def PPCU6ImmAsmOperand : AsmOperandClass {
629 let Name = "U6Imm"; let PredicateMethod = "isU6Imm";
630 let RenderMethod = "addImmOperands";
632 def u6imm : Operand<i32> {
633 let PrintMethod = "printU6ImmOperand";
634 let ParserMatchClass = PPCU6ImmAsmOperand;
635 let DecoderMethod = "decodeUImmOperand<6>";
637 def PPCU7ImmAsmOperand : AsmOperandClass {
638 let Name = "U7Imm"; let PredicateMethod = "isU7Imm";
639 let RenderMethod = "addImmOperands";
641 def u7imm : Operand<i32> {
642 let PrintMethod = "printU7ImmOperand";
643 let ParserMatchClass = PPCU7ImmAsmOperand;
644 let DecoderMethod = "decodeUImmOperand<7>";
646 def PPCU8ImmAsmOperand : AsmOperandClass {
647 let Name = "U8Imm"; let PredicateMethod = "isU8Imm";
648 let RenderMethod = "addImmOperands";
650 def u8imm : Operand<i32> {
651 let PrintMethod = "printU8ImmOperand";
652 let ParserMatchClass = PPCU8ImmAsmOperand;
653 let DecoderMethod = "decodeUImmOperand<8>";
655 def PPCU10ImmAsmOperand : AsmOperandClass {
656 let Name = "U10Imm"; let PredicateMethod = "isU10Imm";
657 let RenderMethod = "addImmOperands";
659 def u10imm : Operand<i32> {
660 let PrintMethod = "printU10ImmOperand";
661 let ParserMatchClass = PPCU10ImmAsmOperand;
662 let DecoderMethod = "decodeUImmOperand<10>";
664 def PPCU12ImmAsmOperand : AsmOperandClass {
665 let Name = "U12Imm"; let PredicateMethod = "isU12Imm";
666 let RenderMethod = "addImmOperands";
668 def u12imm : Operand<i32> {
669 let PrintMethod = "printU12ImmOperand";
670 let ParserMatchClass = PPCU12ImmAsmOperand;
671 let DecoderMethod = "decodeUImmOperand<12>";
673 def PPCS16ImmAsmOperand : AsmOperandClass {
674 let Name = "S16Imm"; let PredicateMethod = "isS16Imm";
675 let RenderMethod = "addS16ImmOperands";
677 def s16imm : Operand<i32> {
678 let PrintMethod = "printS16ImmOperand";
679 let EncoderMethod = "getImm16Encoding";
680 let ParserMatchClass = PPCS16ImmAsmOperand;
681 let DecoderMethod = "decodeSImmOperand<16>";
683 def PPCU16ImmAsmOperand : AsmOperandClass {
684 let Name = "U16Imm"; let PredicateMethod = "isU16Imm";
685 let RenderMethod = "addU16ImmOperands";
687 def u16imm : Operand<i32> {
688 let PrintMethod = "printU16ImmOperand";
689 let EncoderMethod = "getImm16Encoding";
690 let ParserMatchClass = PPCU16ImmAsmOperand;
691 let DecoderMethod = "decodeUImmOperand<16>";
693 def PPCS17ImmAsmOperand : AsmOperandClass {
694 let Name = "S17Imm"; let PredicateMethod = "isS17Imm";
695 let RenderMethod = "addS16ImmOperands";
697 def s17imm : Operand<i32> {
698 // This operand type is used for addis/lis to allow the assembler parser
699 // to accept immediates in the range -65536..65535 for compatibility with
700 // the GNU assembler. The operand is treated as 16-bit otherwise.
701 let PrintMethod = "printS16ImmOperand";
702 let EncoderMethod = "getImm16Encoding";
703 let ParserMatchClass = PPCS17ImmAsmOperand;
704 let DecoderMethod = "decodeSImmOperand<16>";
707 def fpimm0 : PatLeaf<(fpimm), [{ return N->isExactlyValue(+0.0); }]>;
709 def PPCDirectBrAsmOperand : AsmOperandClass {
710 let Name = "DirectBr"; let PredicateMethod = "isDirectBr";
711 let RenderMethod = "addBranchTargetOperands";
713 def directbrtarget : Operand<OtherVT> {
714 let PrintMethod = "printBranchOperand";
715 let EncoderMethod = "getDirectBrEncoding";
716 let ParserMatchClass = PPCDirectBrAsmOperand;
718 def absdirectbrtarget : Operand<OtherVT> {
719 let PrintMethod = "printAbsBranchOperand";
720 let EncoderMethod = "getAbsDirectBrEncoding";
721 let ParserMatchClass = PPCDirectBrAsmOperand;
723 def PPCCondBrAsmOperand : AsmOperandClass {
724 let Name = "CondBr"; let PredicateMethod = "isCondBr";
725 let RenderMethod = "addBranchTargetOperands";
727 def condbrtarget : Operand<OtherVT> {
728 let PrintMethod = "printBranchOperand";
729 let EncoderMethod = "getCondBrEncoding";
730 let ParserMatchClass = PPCCondBrAsmOperand;
732 def abscondbrtarget : Operand<OtherVT> {
733 let PrintMethod = "printAbsBranchOperand";
734 let EncoderMethod = "getAbsCondBrEncoding";
735 let ParserMatchClass = PPCCondBrAsmOperand;
737 def calltarget : Operand<iPTR> {
738 let PrintMethod = "printBranchOperand";
739 let EncoderMethod = "getDirectBrEncoding";
740 let ParserMatchClass = PPCDirectBrAsmOperand;
742 def abscalltarget : Operand<iPTR> {
743 let PrintMethod = "printAbsBranchOperand";
744 let EncoderMethod = "getAbsDirectBrEncoding";
745 let ParserMatchClass = PPCDirectBrAsmOperand;
747 def PPCCRBitMaskOperand : AsmOperandClass {
748 let Name = "CRBitMask"; let PredicateMethod = "isCRBitMask";
750 def crbitm: Operand<i8> {
751 let PrintMethod = "printcrbitm";
752 let EncoderMethod = "get_crbitm_encoding";
753 let DecoderMethod = "decodeCRBitMOperand";
754 let ParserMatchClass = PPCCRBitMaskOperand;
757 // A version of ptr_rc which excludes R0 (or X0 in 64-bit mode).
758 def PPCRegGxRCNoR0Operand : AsmOperandClass {
759 let Name = "RegGxRCNoR0"; let PredicateMethod = "isRegNumber";
761 def ptr_rc_nor0 : Operand<iPTR>, PointerLikeRegClass<1> {
762 let ParserMatchClass = PPCRegGxRCNoR0Operand;
764 // A version of ptr_rc usable with the asm parser.
765 def PPCRegGxRCOperand : AsmOperandClass {
766 let Name = "RegGxRC"; let PredicateMethod = "isRegNumber";
768 def ptr_rc_idx : Operand<iPTR>, PointerLikeRegClass<0> {
769 let ParserMatchClass = PPCRegGxRCOperand;
772 def PPCDispRIOperand : AsmOperandClass {
773 let Name = "DispRI"; let PredicateMethod = "isS16Imm";
774 let RenderMethod = "addS16ImmOperands";
776 def dispRI : Operand<iPTR> {
777 let ParserMatchClass = PPCDispRIOperand;
779 def PPCDispRIXOperand : AsmOperandClass {
780 let Name = "DispRIX"; let PredicateMethod = "isS16ImmX4";
781 let RenderMethod = "addImmOperands";
783 def dispRIX : Operand<iPTR> {
784 let ParserMatchClass = PPCDispRIXOperand;
786 def PPCDispRIX16Operand : AsmOperandClass {
787 let Name = "DispRIX16"; let PredicateMethod = "isS16ImmX16";
788 let RenderMethod = "addImmOperands";
790 def dispRIX16 : Operand<iPTR> {
791 let ParserMatchClass = PPCDispRIX16Operand;
793 def PPCDispSPE8Operand : AsmOperandClass {
794 let Name = "DispSPE8"; let PredicateMethod = "isU8ImmX8";
795 let RenderMethod = "addImmOperands";
797 def dispSPE8 : Operand<iPTR> {
798 let ParserMatchClass = PPCDispSPE8Operand;
800 def PPCDispSPE4Operand : AsmOperandClass {
801 let Name = "DispSPE4"; let PredicateMethod = "isU7ImmX4";
802 let RenderMethod = "addImmOperands";
804 def dispSPE4 : Operand<iPTR> {
805 let ParserMatchClass = PPCDispSPE4Operand;
807 def PPCDispSPE2Operand : AsmOperandClass {
808 let Name = "DispSPE2"; let PredicateMethod = "isU6ImmX2";
809 let RenderMethod = "addImmOperands";
811 def dispSPE2 : Operand<iPTR> {
812 let ParserMatchClass = PPCDispSPE2Operand;
815 def memri : Operand<iPTR> {
816 let PrintMethod = "printMemRegImm";
817 let MIOperandInfo = (ops dispRI:$imm, ptr_rc_nor0:$reg);
818 let EncoderMethod = "getMemRIEncoding";
819 let DecoderMethod = "decodeMemRIOperands";
821 def memrr : Operand<iPTR> {
822 let PrintMethod = "printMemRegReg";
823 let MIOperandInfo = (ops ptr_rc_nor0:$ptrreg, ptr_rc_idx:$offreg);
825 def memrix : Operand<iPTR> { // memri where the imm is 4-aligned.
826 let PrintMethod = "printMemRegImm";
827 let MIOperandInfo = (ops dispRIX:$imm, ptr_rc_nor0:$reg);
828 let EncoderMethod = "getMemRIXEncoding";
829 let DecoderMethod = "decodeMemRIXOperands";
831 def memrix16 : Operand<iPTR> { // memri, imm is 16-aligned, 12-bit, Inst{16:27}
832 let PrintMethod = "printMemRegImm";
833 let MIOperandInfo = (ops dispRIX16:$imm, ptr_rc_nor0:$reg);
834 let EncoderMethod = "getMemRIX16Encoding";
835 let DecoderMethod = "decodeMemRIX16Operands";
837 def spe8dis : Operand<iPTR> { // SPE displacement where the imm is 8-aligned.
838 let PrintMethod = "printMemRegImm";
839 let MIOperandInfo = (ops dispSPE8:$imm, ptr_rc_nor0:$reg);
840 let EncoderMethod = "getSPE8DisEncoding";
841 let DecoderMethod = "decodeSPE8Operands";
843 def spe4dis : Operand<iPTR> { // SPE displacement where the imm is 4-aligned.
844 let PrintMethod = "printMemRegImm";
845 let MIOperandInfo = (ops dispSPE4:$imm, ptr_rc_nor0:$reg);
846 let EncoderMethod = "getSPE4DisEncoding";
847 let DecoderMethod = "decodeSPE4Operands";
849 def spe2dis : Operand<iPTR> { // SPE displacement where the imm is 2-aligned.
850 let PrintMethod = "printMemRegImm";
851 let MIOperandInfo = (ops dispSPE2:$imm, ptr_rc_nor0:$reg);
852 let EncoderMethod = "getSPE2DisEncoding";
853 let DecoderMethod = "decodeSPE2Operands";
856 // A single-register address. This is used with the SjLj
857 // pseudo-instructions which tranlates to LD/LWZ. These instructions requires
858 // G8RC_NOX0 registers.
859 def memr : Operand<iPTR> {
860 let MIOperandInfo = (ops ptr_rc_nor0:$ptrreg);
862 def PPCTLSRegOperand : AsmOperandClass {
863 let Name = "TLSReg"; let PredicateMethod = "isTLSReg";
864 let RenderMethod = "addTLSRegOperands";
866 def tlsreg32 : Operand<i32> {
867 let EncoderMethod = "getTLSRegEncoding";
868 let ParserMatchClass = PPCTLSRegOperand;
870 def tlsgd32 : Operand<i32> {}
871 def tlscall32 : Operand<i32> {
872 let PrintMethod = "printTLSCall";
873 let MIOperandInfo = (ops calltarget:$func, tlsgd32:$sym);
874 let EncoderMethod = "getTLSCallEncoding";
877 // PowerPC Predicate operand.
878 def pred : Operand<OtherVT> {
879 let PrintMethod = "printPredicateOperand";
880 let MIOperandInfo = (ops i32imm:$bibo, crrc:$reg);
883 // Define PowerPC specific addressing mode.
884 def iaddr : ComplexPattern<iPTR, 2, "SelectAddrImm", [], []>;
885 def xaddr : ComplexPattern<iPTR, 2, "SelectAddrIdx", [], []>;
886 def xoaddr : ComplexPattern<iPTR, 2, "SelectAddrIdxOnly",[], []>;
887 def ixaddr : ComplexPattern<iPTR, 2, "SelectAddrImmX4", [], []>; // "std"
888 def iqaddr : ComplexPattern<iPTR, 2, "SelectAddrImmX16", [], []>; // "stxv"
890 // The address in a single register. This is used with the SjLj
891 // pseudo-instructions.
892 def addr : ComplexPattern<iPTR, 1, "SelectAddr",[], []>;
894 /// This is just the offset part of iaddr, used for preinc.
895 def iaddroff : ComplexPattern<iPTR, 1, "SelectAddrImmOffs", [], []>;
897 //===----------------------------------------------------------------------===//
898 // PowerPC Instruction Predicate Definitions.
899 def In32BitMode : Predicate<"!PPCSubTarget->isPPC64()">;
900 def In64BitMode : Predicate<"PPCSubTarget->isPPC64()">;
901 def IsBookE : Predicate<"PPCSubTarget->isBookE()">;
902 def IsNotBookE : Predicate<"!PPCSubTarget->isBookE()">;
903 def HasOnlyMSYNC : Predicate<"PPCSubTarget->hasOnlyMSYNC()">;
904 def HasSYNC : Predicate<"!PPCSubTarget->hasOnlyMSYNC()">;
905 def IsPPC4xx : Predicate<"PPCSubTarget->isPPC4xx()">;
906 def IsPPC6xx : Predicate<"PPCSubTarget->isPPC6xx()">;
907 def IsE500 : Predicate<"PPCSubTarget->isE500()">;
908 def HasSPE : Predicate<"PPCSubTarget->hasSPE()">;
909 def HasICBT : Predicate<"PPCSubTarget->hasICBT()">;
910 def HasPartwordAtomics : Predicate<"PPCSubTarget->hasPartwordAtomics()">;
911 def NoNaNsFPMath : Predicate<"TM.Options.NoNaNsFPMath">;
912 def NaNsFPMath : Predicate<"!TM.Options.NoNaNsFPMath">;
913 def HasBPERMD : Predicate<"PPCSubTarget->hasBPERMD()">;
914 def HasExtDiv : Predicate<"PPCSubTarget->hasExtDiv()">;
915 def IsISA3_0 : Predicate<"PPCSubTarget->isISA3_0()">;
916 def HasFPU : Predicate<"PPCSubTarget->hasFPU()">;
918 //===----------------------------------------------------------------------===//
919 // PowerPC Multiclass Definitions.
921 multiclass XForm_6r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
922 string asmbase, string asmstr, InstrItinClass itin,
924 let BaseName = asmbase in {
925 def NAME : XForm_6<opcode, xo, OOL, IOL,
926 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
927 pattern>, RecFormRel;
929 def o : XForm_6<opcode, xo, OOL, IOL,
930 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
931 []>, isDOT, RecFormRel;
935 multiclass XForm_6rc<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
936 string asmbase, string asmstr, InstrItinClass itin,
938 let BaseName = asmbase in {
939 let Defs = [CARRY] in
940 def NAME : XForm_6<opcode, xo, OOL, IOL,
941 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
942 pattern>, RecFormRel;
943 let Defs = [CARRY, CR0] in
944 def o : XForm_6<opcode, xo, OOL, IOL,
945 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
946 []>, isDOT, RecFormRel;
950 multiclass XForm_10rc<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
951 string asmbase, string asmstr, InstrItinClass itin,
953 let BaseName = asmbase in {
954 let Defs = [CARRY] in
955 def NAME : XForm_10<opcode, xo, OOL, IOL,
956 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
957 pattern>, RecFormRel;
958 let Defs = [CARRY, CR0] in
959 def o : XForm_10<opcode, xo, OOL, IOL,
960 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
961 []>, isDOT, RecFormRel;
965 multiclass XForm_11r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
966 string asmbase, string asmstr, InstrItinClass itin,
968 let BaseName = asmbase in {
969 def NAME : XForm_11<opcode, xo, OOL, IOL,
970 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
971 pattern>, RecFormRel;
973 def o : XForm_11<opcode, xo, OOL, IOL,
974 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
975 []>, isDOT, RecFormRel;
979 multiclass XOForm_1r<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
980 string asmbase, string asmstr, InstrItinClass itin,
982 let BaseName = asmbase in {
983 def NAME : XOForm_1<opcode, xo, oe, OOL, IOL,
984 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
985 pattern>, RecFormRel;
987 def o : XOForm_1<opcode, xo, oe, OOL, IOL,
988 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
989 []>, isDOT, RecFormRel;
993 // Multiclass for instructions for which the non record form is not cracked
994 // and the record form is cracked (i.e. divw, mullw, etc.)
995 multiclass XOForm_1rcr<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
996 string asmbase, string asmstr, InstrItinClass itin,
998 let BaseName = asmbase in {
999 def NAME : XOForm_1<opcode, xo, oe, OOL, IOL,
1000 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1001 pattern>, RecFormRel;
1003 def o : XOForm_1<opcode, xo, oe, OOL, IOL,
1004 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1005 []>, isDOT, RecFormRel, PPC970_DGroup_First,
1006 PPC970_DGroup_Cracked;
1010 multiclass XOForm_1rc<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
1011 string asmbase, string asmstr, InstrItinClass itin,
1012 list<dag> pattern> {
1013 let BaseName = asmbase in {
1014 let Defs = [CARRY] in
1015 def NAME : XOForm_1<opcode, xo, oe, OOL, IOL,
1016 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1017 pattern>, RecFormRel;
1018 let Defs = [CARRY, CR0] in
1019 def o : XOForm_1<opcode, xo, oe, OOL, IOL,
1020 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1021 []>, isDOT, RecFormRel;
1025 multiclass XOForm_3r<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
1026 string asmbase, string asmstr, InstrItinClass itin,
1027 list<dag> pattern> {
1028 let BaseName = asmbase in {
1029 def NAME : XOForm_3<opcode, xo, oe, OOL, IOL,
1030 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1031 pattern>, RecFormRel;
1033 def o : XOForm_3<opcode, xo, oe, OOL, IOL,
1034 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1035 []>, isDOT, RecFormRel;
1039 multiclass XOForm_3rc<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
1040 string asmbase, string asmstr, InstrItinClass itin,
1041 list<dag> pattern> {
1042 let BaseName = asmbase in {
1043 let Defs = [CARRY] in
1044 def NAME : XOForm_3<opcode, xo, oe, OOL, IOL,
1045 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1046 pattern>, RecFormRel;
1047 let Defs = [CARRY, CR0] in
1048 def o : XOForm_3<opcode, xo, oe, OOL, IOL,
1049 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1050 []>, isDOT, RecFormRel;
1054 multiclass MForm_2r<bits<6> opcode, dag OOL, dag IOL,
1055 string asmbase, string asmstr, InstrItinClass itin,
1056 list<dag> pattern> {
1057 let BaseName = asmbase in {
1058 def NAME : MForm_2<opcode, OOL, IOL,
1059 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1060 pattern>, RecFormRel;
1062 def o : MForm_2<opcode, OOL, IOL,
1063 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1064 []>, isDOT, RecFormRel;
1068 multiclass MDForm_1r<bits<6> opcode, bits<3> xo, dag OOL, dag IOL,
1069 string asmbase, string asmstr, InstrItinClass itin,
1070 list<dag> pattern> {
1071 let BaseName = asmbase in {
1072 def NAME : MDForm_1<opcode, xo, OOL, IOL,
1073 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1074 pattern>, RecFormRel;
1076 def o : MDForm_1<opcode, xo, OOL, IOL,
1077 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1078 []>, isDOT, RecFormRel;
1082 multiclass MDSForm_1r<bits<6> opcode, bits<4> xo, dag OOL, dag IOL,
1083 string asmbase, string asmstr, InstrItinClass itin,
1084 list<dag> pattern> {
1085 let BaseName = asmbase in {
1086 def NAME : MDSForm_1<opcode, xo, OOL, IOL,
1087 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1088 pattern>, RecFormRel;
1090 def o : MDSForm_1<opcode, xo, OOL, IOL,
1091 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1092 []>, isDOT, RecFormRel;
1096 multiclass XSForm_1rc<bits<6> opcode, bits<9> xo, dag OOL, dag IOL,
1097 string asmbase, string asmstr, InstrItinClass itin,
1098 list<dag> pattern> {
1099 let BaseName = asmbase in {
1100 let Defs = [CARRY] in
1101 def NAME : XSForm_1<opcode, xo, OOL, IOL,
1102 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1103 pattern>, RecFormRel;
1104 let Defs = [CARRY, CR0] in
1105 def o : XSForm_1<opcode, xo, OOL, IOL,
1106 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1107 []>, isDOT, RecFormRel;
1111 multiclass XSForm_1r<bits<6> opcode, bits<9> xo, dag OOL, dag IOL,
1112 string asmbase, string asmstr, InstrItinClass itin,
1113 list<dag> pattern> {
1114 let BaseName = asmbase in {
1115 def NAME : XSForm_1<opcode, xo, OOL, IOL,
1116 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1117 pattern>, RecFormRel;
1119 def o : XSForm_1<opcode, xo, OOL, IOL,
1120 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1121 []>, isDOT, RecFormRel;
1125 multiclass XForm_26r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
1126 string asmbase, string asmstr, InstrItinClass itin,
1127 list<dag> pattern> {
1128 let BaseName = asmbase in {
1129 def NAME : XForm_26<opcode, xo, OOL, IOL,
1130 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1131 pattern>, RecFormRel;
1133 def o : XForm_26<opcode, xo, OOL, IOL,
1134 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1135 []>, isDOT, RecFormRel;
1139 multiclass XForm_28r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
1140 string asmbase, string asmstr, InstrItinClass itin,
1141 list<dag> pattern> {
1142 let BaseName = asmbase in {
1143 def NAME : XForm_28<opcode, xo, OOL, IOL,
1144 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1145 pattern>, RecFormRel;
1147 def o : XForm_28<opcode, xo, OOL, IOL,
1148 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1149 []>, isDOT, RecFormRel;
1153 multiclass AForm_1r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL,
1154 string asmbase, string asmstr, InstrItinClass itin,
1155 list<dag> pattern> {
1156 let BaseName = asmbase in {
1157 def NAME : AForm_1<opcode, xo, OOL, IOL,
1158 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1159 pattern>, RecFormRel;
1161 def o : AForm_1<opcode, xo, OOL, IOL,
1162 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1163 []>, isDOT, RecFormRel;
1167 multiclass AForm_2r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL,
1168 string asmbase, string asmstr, InstrItinClass itin,
1169 list<dag> pattern> {
1170 let BaseName = asmbase in {
1171 def NAME : AForm_2<opcode, xo, OOL, IOL,
1172 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1173 pattern>, RecFormRel;
1175 def o : AForm_2<opcode, xo, OOL, IOL,
1176 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1177 []>, isDOT, RecFormRel;
1181 multiclass AForm_3r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL,
1182 string asmbase, string asmstr, InstrItinClass itin,
1183 list<dag> pattern> {
1184 let BaseName = asmbase in {
1185 def NAME : AForm_3<opcode, xo, OOL, IOL,
1186 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1187 pattern>, RecFormRel;
1189 def o : AForm_3<opcode, xo, OOL, IOL,
1190 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1191 []>, isDOT, RecFormRel;
1195 //===----------------------------------------------------------------------===//
1196 // PowerPC Instruction Definitions.
1198 // Pseudo instructions:
1200 let hasCtrlDep = 1 in {
1201 let Defs = [R1], Uses = [R1] in {
1202 def ADJCALLSTACKDOWN : PPCEmitTimePseudo<(outs), (ins u16imm:$amt1, u16imm:$amt2),
1203 "#ADJCALLSTACKDOWN $amt1 $amt2",
1204 [(callseq_start timm:$amt1, timm:$amt2)]>;
1205 def ADJCALLSTACKUP : PPCEmitTimePseudo<(outs), (ins u16imm:$amt1, u16imm:$amt2),
1206 "#ADJCALLSTACKUP $amt1 $amt2",
1207 [(callseq_end timm:$amt1, timm:$amt2)]>;
1210 def UPDATE_VRSAVE : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc:$rS),
1211 "UPDATE_VRSAVE $rD, $rS", []>;
1214 let Defs = [R1], Uses = [R1] in
1215 def DYNALLOC : PPCEmitTimePseudo<(outs gprc:$result), (ins gprc:$negsize, memri:$fpsi), "#DYNALLOC",
1217 (PPCdynalloc i32:$negsize, iaddr:$fpsi))]>;
1218 def DYNAREAOFFSET : PPCEmitTimePseudo<(outs i32imm:$result), (ins memri:$fpsi), "#DYNAREAOFFSET",
1219 [(set i32:$result, (PPCdynareaoffset iaddr:$fpsi))]>;
1221 // SELECT_CC_* - Used to implement the SELECT_CC DAG operation. Expanded after
1222 // instruction selection into a branch sequence.
1223 let PPC970_Single = 1 in {
1224 // Note that SELECT_CC_I4 and SELECT_CC_I8 use the no-r0 register classes
1225 // because either operand might become the first operand in an isel, and
1226 // that operand cannot be r0.
1227 def SELECT_CC_I4 : PPCCustomInserterPseudo<(outs gprc:$dst), (ins crrc:$cond,
1228 gprc_nor0:$T, gprc_nor0:$F,
1229 i32imm:$BROPC), "#SELECT_CC_I4",
1231 def SELECT_CC_I8 : PPCCustomInserterPseudo<(outs g8rc:$dst), (ins crrc:$cond,
1232 g8rc_nox0:$T, g8rc_nox0:$F,
1233 i32imm:$BROPC), "#SELECT_CC_I8",
1235 def SELECT_CC_F4 : PPCCustomInserterPseudo<(outs f4rc:$dst), (ins crrc:$cond, f4rc:$T, f4rc:$F,
1236 i32imm:$BROPC), "#SELECT_CC_F4",
1238 def SELECT_CC_F8 : PPCCustomInserterPseudo<(outs f8rc:$dst), (ins crrc:$cond, f8rc:$T, f8rc:$F,
1239 i32imm:$BROPC), "#SELECT_CC_F8",
1241 def SELECT_CC_F16 : PPCCustomInserterPseudo<(outs vrrc:$dst), (ins crrc:$cond, vrrc:$T, vrrc:$F,
1242 i32imm:$BROPC), "#SELECT_CC_F16",
1244 def SELECT_CC_VRRC: PPCCustomInserterPseudo<(outs vrrc:$dst), (ins crrc:$cond, vrrc:$T, vrrc:$F,
1245 i32imm:$BROPC), "#SELECT_CC_VRRC",
1248 // SELECT_* pseudo instructions, like SELECT_CC_* but taking condition
1249 // register bit directly.
1250 def SELECT_I4 : PPCCustomInserterPseudo<(outs gprc:$dst), (ins crbitrc:$cond,
1251 gprc_nor0:$T, gprc_nor0:$F), "#SELECT_I4",
1252 [(set i32:$dst, (select i1:$cond, i32:$T, i32:$F))]>;
1253 def SELECT_I8 : PPCCustomInserterPseudo<(outs g8rc:$dst), (ins crbitrc:$cond,
1254 g8rc_nox0:$T, g8rc_nox0:$F), "#SELECT_I8",
1255 [(set i64:$dst, (select i1:$cond, i64:$T, i64:$F))]>;
1256 let Predicates = [HasFPU] in {
1257 def SELECT_F4 : PPCCustomInserterPseudo<(outs f4rc:$dst), (ins crbitrc:$cond,
1258 f4rc:$T, f4rc:$F), "#SELECT_F4",
1259 [(set f32:$dst, (select i1:$cond, f32:$T, f32:$F))]>;
1260 def SELECT_F8 : PPCCustomInserterPseudo<(outs f8rc:$dst), (ins crbitrc:$cond,
1261 f8rc:$T, f8rc:$F), "#SELECT_F8",
1262 [(set f64:$dst, (select i1:$cond, f64:$T, f64:$F))]>;
1263 def SELECT_F16 : PPCCustomInserterPseudo<(outs vrrc:$dst), (ins crbitrc:$cond,
1264 vrrc:$T, vrrc:$F), "#SELECT_F16",
1265 [(set f128:$dst, (select i1:$cond, f128:$T, f128:$F))]>;
1267 def SELECT_VRRC: PPCCustomInserterPseudo<(outs vrrc:$dst), (ins crbitrc:$cond,
1268 vrrc:$T, vrrc:$F), "#SELECT_VRRC",
1270 (select i1:$cond, v4i32:$T, v4i32:$F))]>;
1273 // SPILL_CR - Indicate that we're dumping the CR register, so we'll need to
1274 // scavenge a register for it.
1275 let mayStore = 1 in {
1276 def SPILL_CR : PPCEmitTimePseudo<(outs), (ins crrc:$cond, memri:$F),
1278 def SPILL_CRBIT : PPCEmitTimePseudo<(outs), (ins crbitrc:$cond, memri:$F),
1279 "#SPILL_CRBIT", []>;
1282 // RESTORE_CR - Indicate that we're restoring the CR register (previously
1283 // spilled), so we'll need to scavenge a register for it.
1284 let mayLoad = 1 in {
1285 def RESTORE_CR : PPCEmitTimePseudo<(outs crrc:$cond), (ins memri:$F),
1287 def RESTORE_CRBIT : PPCEmitTimePseudo<(outs crbitrc:$cond), (ins memri:$F),
1288 "#RESTORE_CRBIT", []>;
1291 let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7 in {
1292 let isReturn = 1, Uses = [LR, RM] in
1293 def BLR : XLForm_2_ext<19, 16, 20, 0, 0, (outs), (ins), "blr", IIC_BrB,
1294 [(retflag)]>, Requires<[In32BitMode]>;
1295 let isBranch = 1, isIndirectBranch = 1, Uses = [CTR] in {
1296 def BCTR : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
1299 let isCodeGenOnly = 1 in {
1300 def BCCCTR : XLForm_2_br<19, 528, 0, (outs), (ins pred:$cond),
1301 "b${cond:cc}ctr${cond:pm} ${cond:reg}", IIC_BrB,
1304 def BCCTR : XLForm_2_br2<19, 528, 12, 0, (outs), (ins crbitrc:$bi),
1305 "bcctr 12, $bi, 0", IIC_BrB, []>;
1306 def BCCTRn : XLForm_2_br2<19, 528, 4, 0, (outs), (ins crbitrc:$bi),
1307 "bcctr 4, $bi, 0", IIC_BrB, []>;
1313 def MovePCtoLR : PPCEmitTimePseudo<(outs), (ins), "#MovePCtoLR", []>,
1316 def MoveGOTtoLR : PPCEmitTimePseudo<(outs), (ins), "#MoveGOTtoLR", []>,
1319 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7 in {
1320 let isBarrier = 1 in {
1321 def B : IForm<18, 0, 0, (outs), (ins directbrtarget:$dst),
1324 def BA : IForm<18, 1, 0, (outs), (ins absdirectbrtarget:$dst),
1325 "ba $dst", IIC_BrB, []>;
1328 // BCC represents an arbitrary conditional branch on a predicate.
1329 // FIXME: should be able to write a pattern for PPCcondbranch, but can't use
1330 // a two-value operand where a dag node expects two operands. :(
1331 let isCodeGenOnly = 1 in {
1332 class BCC_class : BForm<16, 0, 0, (outs), (ins pred:$cond, condbrtarget:$dst),
1333 "b${cond:cc}${cond:pm} ${cond:reg}, $dst"
1334 /*[(PPCcondbranch crrc:$crS, imm:$opc, bb:$dst)]*/>;
1335 def BCC : BCC_class;
1337 // The same as BCC, except that it's not a terminator. Used for introducing
1338 // control flow dependency without creating new blocks.
1339 let isTerminator = 0 in def CTRL_DEP : BCC_class;
1341 def BCCA : BForm<16, 1, 0, (outs), (ins pred:$cond, abscondbrtarget:$dst),
1342 "b${cond:cc}a${cond:pm} ${cond:reg}, $dst">;
1344 let isReturn = 1, Uses = [LR, RM] in
1345 def BCCLR : XLForm_2_br<19, 16, 0, (outs), (ins pred:$cond),
1346 "b${cond:cc}lr${cond:pm} ${cond:reg}", IIC_BrB, []>;
1349 let isCodeGenOnly = 1 in {
1350 let Pattern = [(brcond i1:$bi, bb:$dst)] in
1351 def BC : BForm_4<16, 12, 0, 0, (outs), (ins crbitrc:$bi, condbrtarget:$dst),
1352 "bc 12, $bi, $dst">;
1354 let Pattern = [(brcond (not i1:$bi), bb:$dst)] in
1355 def BCn : BForm_4<16, 4, 0, 0, (outs), (ins crbitrc:$bi, condbrtarget:$dst),
1358 let isReturn = 1, Uses = [LR, RM] in
1359 def BCLR : XLForm_2_br2<19, 16, 12, 0, (outs), (ins crbitrc:$bi),
1360 "bclr 12, $bi, 0", IIC_BrB, []>;
1361 def BCLRn : XLForm_2_br2<19, 16, 4, 0, (outs), (ins crbitrc:$bi),
1362 "bclr 4, $bi, 0", IIC_BrB, []>;
1365 let isReturn = 1, Defs = [CTR], Uses = [CTR, LR, RM] in {
1366 def BDZLR : XLForm_2_ext<19, 16, 18, 0, 0, (outs), (ins),
1367 "bdzlr", IIC_BrB, []>;
1368 def BDNZLR : XLForm_2_ext<19, 16, 16, 0, 0, (outs), (ins),
1369 "bdnzlr", IIC_BrB, []>;
1370 def BDZLRp : XLForm_2_ext<19, 16, 27, 0, 0, (outs), (ins),
1371 "bdzlr+", IIC_BrB, []>;
1372 def BDNZLRp: XLForm_2_ext<19, 16, 25, 0, 0, (outs), (ins),
1373 "bdnzlr+", IIC_BrB, []>;
1374 def BDZLRm : XLForm_2_ext<19, 16, 26, 0, 0, (outs), (ins),
1375 "bdzlr-", IIC_BrB, []>;
1376 def BDNZLRm: XLForm_2_ext<19, 16, 24, 0, 0, (outs), (ins),
1377 "bdnzlr-", IIC_BrB, []>;
1380 let Defs = [CTR], Uses = [CTR] in {
1381 def BDZ : BForm_1<16, 18, 0, 0, (outs), (ins condbrtarget:$dst),
1383 def BDNZ : BForm_1<16, 16, 0, 0, (outs), (ins condbrtarget:$dst),
1385 def BDZA : BForm_1<16, 18, 1, 0, (outs), (ins abscondbrtarget:$dst),
1387 def BDNZA : BForm_1<16, 16, 1, 0, (outs), (ins abscondbrtarget:$dst),
1389 def BDZp : BForm_1<16, 27, 0, 0, (outs), (ins condbrtarget:$dst),
1391 def BDNZp: BForm_1<16, 25, 0, 0, (outs), (ins condbrtarget:$dst),
1393 def BDZAp : BForm_1<16, 27, 1, 0, (outs), (ins abscondbrtarget:$dst),
1395 def BDNZAp: BForm_1<16, 25, 1, 0, (outs), (ins abscondbrtarget:$dst),
1397 def BDZm : BForm_1<16, 26, 0, 0, (outs), (ins condbrtarget:$dst),
1399 def BDNZm: BForm_1<16, 24, 0, 0, (outs), (ins condbrtarget:$dst),
1401 def BDZAm : BForm_1<16, 26, 1, 0, (outs), (ins abscondbrtarget:$dst),
1403 def BDNZAm: BForm_1<16, 24, 1, 0, (outs), (ins abscondbrtarget:$dst),
1408 // The unconditional BCL used by the SjLj setjmp code.
1409 let isCall = 1, hasCtrlDep = 1, isCodeGenOnly = 1, PPC970_Unit = 7 in {
1410 let Defs = [LR], Uses = [RM] in {
1411 def BCLalways : BForm_2<16, 20, 31, 0, 1, (outs), (ins condbrtarget:$dst),
1412 "bcl 20, 31, $dst">;
1416 let isCall = 1, PPC970_Unit = 7, Defs = [LR] in {
1417 // Convenient aliases for call instructions
1418 let Uses = [RM] in {
1419 def BL : IForm<18, 0, 1, (outs), (ins calltarget:$func),
1420 "bl $func", IIC_BrB, []>; // See Pat patterns below.
1421 def BLA : IForm<18, 1, 1, (outs), (ins abscalltarget:$func),
1422 "bla $func", IIC_BrB, [(PPCcall (i32 imm:$func))]>;
1424 let isCodeGenOnly = 1 in {
1425 def BL_TLS : IForm<18, 0, 1, (outs), (ins tlscall32:$func),
1426 "bl $func", IIC_BrB, []>;
1427 def BCCL : BForm<16, 0, 1, (outs), (ins pred:$cond, condbrtarget:$dst),
1428 "b${cond:cc}l${cond:pm} ${cond:reg}, $dst">;
1429 def BCCLA : BForm<16, 1, 1, (outs), (ins pred:$cond, abscondbrtarget:$dst),
1430 "b${cond:cc}la${cond:pm} ${cond:reg}, $dst">;
1432 def BCL : BForm_4<16, 12, 0, 1, (outs),
1433 (ins crbitrc:$bi, condbrtarget:$dst),
1434 "bcl 12, $bi, $dst">;
1435 def BCLn : BForm_4<16, 4, 0, 1, (outs),
1436 (ins crbitrc:$bi, condbrtarget:$dst),
1437 "bcl 4, $bi, $dst">;
1440 let Uses = [CTR, RM] in {
1441 def BCTRL : XLForm_2_ext<19, 528, 20, 0, 1, (outs), (ins),
1442 "bctrl", IIC_BrB, [(PPCbctrl)]>,
1443 Requires<[In32BitMode]>;
1445 let isCodeGenOnly = 1 in {
1446 def BCCCTRL : XLForm_2_br<19, 528, 1, (outs), (ins pred:$cond),
1447 "b${cond:cc}ctrl${cond:pm} ${cond:reg}", IIC_BrB,
1450 def BCCTRL : XLForm_2_br2<19, 528, 12, 1, (outs), (ins crbitrc:$bi),
1451 "bcctrl 12, $bi, 0", IIC_BrB, []>;
1452 def BCCTRLn : XLForm_2_br2<19, 528, 4, 1, (outs), (ins crbitrc:$bi),
1453 "bcctrl 4, $bi, 0", IIC_BrB, []>;
1456 let Uses = [LR, RM] in {
1457 def BLRL : XLForm_2_ext<19, 16, 20, 0, 1, (outs), (ins),
1458 "blrl", IIC_BrB, []>;
1460 let isCodeGenOnly = 1 in {
1461 def BCCLRL : XLForm_2_br<19, 16, 1, (outs), (ins pred:$cond),
1462 "b${cond:cc}lrl${cond:pm} ${cond:reg}", IIC_BrB,
1465 def BCLRL : XLForm_2_br2<19, 16, 12, 1, (outs), (ins crbitrc:$bi),
1466 "bclrl 12, $bi, 0", IIC_BrB, []>;
1467 def BCLRLn : XLForm_2_br2<19, 16, 4, 1, (outs), (ins crbitrc:$bi),
1468 "bclrl 4, $bi, 0", IIC_BrB, []>;
1471 let Defs = [CTR], Uses = [CTR, RM] in {
1472 def BDZL : BForm_1<16, 18, 0, 1, (outs), (ins condbrtarget:$dst),
1474 def BDNZL : BForm_1<16, 16, 0, 1, (outs), (ins condbrtarget:$dst),
1476 def BDZLA : BForm_1<16, 18, 1, 1, (outs), (ins abscondbrtarget:$dst),
1478 def BDNZLA : BForm_1<16, 16, 1, 1, (outs), (ins abscondbrtarget:$dst),
1480 def BDZLp : BForm_1<16, 27, 0, 1, (outs), (ins condbrtarget:$dst),
1482 def BDNZLp: BForm_1<16, 25, 0, 1, (outs), (ins condbrtarget:$dst),
1484 def BDZLAp : BForm_1<16, 27, 1, 1, (outs), (ins abscondbrtarget:$dst),
1486 def BDNZLAp: BForm_1<16, 25, 1, 1, (outs), (ins abscondbrtarget:$dst),
1488 def BDZLm : BForm_1<16, 26, 0, 1, (outs), (ins condbrtarget:$dst),
1490 def BDNZLm: BForm_1<16, 24, 0, 1, (outs), (ins condbrtarget:$dst),
1492 def BDZLAm : BForm_1<16, 26, 1, 1, (outs), (ins abscondbrtarget:$dst),
1494 def BDNZLAm: BForm_1<16, 24, 1, 1, (outs), (ins abscondbrtarget:$dst),
1497 let Defs = [CTR], Uses = [CTR, LR, RM] in {
1498 def BDZLRL : XLForm_2_ext<19, 16, 18, 0, 1, (outs), (ins),
1499 "bdzlrl", IIC_BrB, []>;
1500 def BDNZLRL : XLForm_2_ext<19, 16, 16, 0, 1, (outs), (ins),
1501 "bdnzlrl", IIC_BrB, []>;
1502 def BDZLRLp : XLForm_2_ext<19, 16, 27, 0, 1, (outs), (ins),
1503 "bdzlrl+", IIC_BrB, []>;
1504 def BDNZLRLp: XLForm_2_ext<19, 16, 25, 0, 1, (outs), (ins),
1505 "bdnzlrl+", IIC_BrB, []>;
1506 def BDZLRLm : XLForm_2_ext<19, 16, 26, 0, 1, (outs), (ins),
1507 "bdzlrl-", IIC_BrB, []>;
1508 def BDNZLRLm: XLForm_2_ext<19, 16, 24, 0, 1, (outs), (ins),
1509 "bdnzlrl-", IIC_BrB, []>;
1513 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
1514 def TCRETURNdi :PPCEmitTimePseudo< (outs),
1515 (ins calltarget:$dst, i32imm:$offset),
1516 "#TC_RETURNd $dst $offset",
1520 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
1521 def TCRETURNai :PPCEmitTimePseudo<(outs), (ins abscalltarget:$func, i32imm:$offset),
1522 "#TC_RETURNa $func $offset",
1523 [(PPCtc_return (i32 imm:$func), imm:$offset)]>;
1525 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
1526 def TCRETURNri : PPCEmitTimePseudo<(outs), (ins CTRRC:$dst, i32imm:$offset),
1527 "#TC_RETURNr $dst $offset",
1531 let isCodeGenOnly = 1 in {
1533 let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, isBranch = 1,
1534 isIndirectBranch = 1, isCall = 1, isReturn = 1, Uses = [CTR, RM] in
1535 def TAILBCTR : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
1536 []>, Requires<[In32BitMode]>;
1538 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
1539 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
1540 def TAILB : IForm<18, 0, 0, (outs), (ins calltarget:$dst),
1544 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
1545 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
1546 def TAILBA : IForm<18, 0, 0, (outs), (ins abscalltarget:$dst),
1552 // While longjmp is a control-flow barrier (fallthrough isn't allowed), setjmp
1554 let hasSideEffects = 1 in {
1556 def EH_SjLj_SetJmp32 : PPCCustomInserterPseudo<(outs gprc:$dst), (ins memr:$buf),
1557 "#EH_SJLJ_SETJMP32",
1558 [(set i32:$dst, (PPCeh_sjlj_setjmp addr:$buf))]>,
1559 Requires<[In32BitMode]>;
1562 let hasSideEffects = 1, isBarrier = 1 in {
1563 let isTerminator = 1 in
1564 def EH_SjLj_LongJmp32 : PPCCustomInserterPseudo<(outs), (ins memr:$buf),
1565 "#EH_SJLJ_LONGJMP32",
1566 [(PPCeh_sjlj_longjmp addr:$buf)]>,
1567 Requires<[In32BitMode]>;
1570 // This pseudo is never removed from the function, as it serves as
1571 // a terminator. Size is set to 0 to prevent the builtin assembler
1572 // from emitting it.
1573 let isBranch = 1, isTerminator = 1, Size = 0 in {
1574 def EH_SjLj_Setup : PPCEmitTimePseudo<(outs), (ins directbrtarget:$dst),
1575 "#EH_SjLj_Setup\t$dst", []>;
1579 let PPC970_Unit = 7 in {
1580 def SC : SCForm<17, 1, (outs), (ins i32imm:$lev),
1581 "sc $lev", IIC_BrB, [(PPCsc (i32 imm:$lev))]>;
1584 // Branch history rolling buffer.
1585 def CLRBHRB : XForm_0<31, 430, (outs), (ins), "clrbhrb", IIC_BrB,
1587 PPC970_DGroup_Single;
1588 // The $dmy argument used for MFBHRBE is not needed; however, including
1589 // it avoids automatic generation of PPCFastISel::fastEmit_i(), which
1590 // interferes with necessary special handling (see PPCFastISel.cpp).
1591 def MFBHRBE : XFXForm_3p<31, 302, (outs gprc:$rD),
1592 (ins u10imm:$imm, u10imm:$dmy),
1593 "mfbhrbe $rD, $imm", IIC_BrB,
1595 (PPCmfbhrbe imm:$imm, imm:$dmy))]>,
1596 PPC970_DGroup_First;
1598 def RFEBB : XLForm_S<19, 146, (outs), (ins u1imm:$imm), "rfebb $imm",
1599 IIC_BrB, [(PPCrfebb (i32 imm:$imm))]>,
1600 PPC970_DGroup_Single;
1602 // DCB* instructions.
1603 def DCBA : DCB_Form<758, 0, (outs), (ins memrr:$dst), "dcba $dst",
1604 IIC_LdStDCBF, [(int_ppc_dcba xoaddr:$dst)]>,
1605 PPC970_DGroup_Single;
1606 def DCBI : DCB_Form<470, 0, (outs), (ins memrr:$dst), "dcbi $dst",
1607 IIC_LdStDCBF, [(int_ppc_dcbi xoaddr:$dst)]>,
1608 PPC970_DGroup_Single;
1609 def DCBST : DCB_Form<54, 0, (outs), (ins memrr:$dst), "dcbst $dst",
1610 IIC_LdStDCBF, [(int_ppc_dcbst xoaddr:$dst)]>,
1611 PPC970_DGroup_Single;
1612 def DCBZ : DCB_Form<1014, 0, (outs), (ins memrr:$dst), "dcbz $dst",
1613 IIC_LdStDCBF, [(int_ppc_dcbz xoaddr:$dst)]>,
1614 PPC970_DGroup_Single;
1615 def DCBZL : DCB_Form<1014, 1, (outs), (ins memrr:$dst), "dcbzl $dst",
1616 IIC_LdStDCBF, [(int_ppc_dcbzl xoaddr:$dst)]>,
1617 PPC970_DGroup_Single;
1619 def DCBF : DCB_Form_hint<86, (outs), (ins u5imm:$TH, memrr:$dst),
1620 "dcbf $dst, $TH", IIC_LdStDCBF, []>,
1621 PPC970_DGroup_Single;
1623 let hasSideEffects = 0, mayLoad = 1, mayStore = 1 in {
1624 def DCBT : DCB_Form_hint<278, (outs), (ins u5imm:$TH, memrr:$dst),
1625 "dcbt $dst, $TH", IIC_LdStDCBF, []>,
1626 PPC970_DGroup_Single;
1627 def DCBTST : DCB_Form_hint<246, (outs), (ins u5imm:$TH, memrr:$dst),
1628 "dcbtst $dst, $TH", IIC_LdStDCBF, []>,
1629 PPC970_DGroup_Single;
1630 } // hasSideEffects = 0
1632 def ICBLC : XForm_icbt<31, 230, (outs), (ins u4imm:$CT, memrr:$src),
1633 "icblc $CT, $src", IIC_LdStStore>, Requires<[HasICBT]>;
1634 def ICBLQ : XForm_icbt<31, 198, (outs), (ins u4imm:$CT, memrr:$src),
1635 "icblq. $CT, $src", IIC_LdStLoad>, Requires<[HasICBT]>;
1636 def ICBT : XForm_icbt<31, 22, (outs), (ins u4imm:$CT, memrr:$src),
1637 "icbt $CT, $src", IIC_LdStLoad>, Requires<[HasICBT]>;
1638 def ICBTLS : XForm_icbt<31, 486, (outs), (ins u4imm:$CT, memrr:$src),
1639 "icbtls $CT, $src", IIC_LdStLoad>, Requires<[HasICBT]>;
1641 def : Pat<(int_ppc_dcbt xoaddr:$dst),
1642 (DCBT 0, xoaddr:$dst)>;
1643 def : Pat<(int_ppc_dcbtst xoaddr:$dst),
1644 (DCBTST 0, xoaddr:$dst)>;
1645 def : Pat<(int_ppc_dcbf xoaddr:$dst),
1646 (DCBF 0, xoaddr:$dst)>;
1648 def : Pat<(prefetch xoaddr:$dst, (i32 0), imm, (i32 1)),
1649 (DCBT 0, xoaddr:$dst)>; // data prefetch for loads
1650 def : Pat<(prefetch xoaddr:$dst, (i32 1), imm, (i32 1)),
1651 (DCBTST 0, xoaddr:$dst)>; // data prefetch for stores
1652 def : Pat<(prefetch xoaddr:$dst, (i32 0), imm, (i32 0)),
1653 (ICBT 0, xoaddr:$dst)>, Requires<[HasICBT]>; // inst prefetch (for read)
1655 // Atomic operations
1656 // FIXME: some of these might be used with constant operands. This will result
1657 // in constant materialization instructions that may be redundant. We currently
1658 // clean this up in PPCMIPeephole with calls to
1659 // PPCInstrInfo::convertToImmediateForm() but we should probably not emit them
1660 // in the first place.
1661 let Defs = [CR0] in {
1662 def ATOMIC_LOAD_ADD_I8 : PPCCustomInserterPseudo<
1663 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I8",
1664 [(set i32:$dst, (atomic_load_add_8 xoaddr:$ptr, i32:$incr))]>;
1665 def ATOMIC_LOAD_SUB_I8 : PPCCustomInserterPseudo<
1666 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I8",
1667 [(set i32:$dst, (atomic_load_sub_8 xoaddr:$ptr, i32:$incr))]>;
1668 def ATOMIC_LOAD_AND_I8 : PPCCustomInserterPseudo<
1669 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I8",
1670 [(set i32:$dst, (atomic_load_and_8 xoaddr:$ptr, i32:$incr))]>;
1671 def ATOMIC_LOAD_OR_I8 : PPCCustomInserterPseudo<
1672 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I8",
1673 [(set i32:$dst, (atomic_load_or_8 xoaddr:$ptr, i32:$incr))]>;
1674 def ATOMIC_LOAD_XOR_I8 : PPCCustomInserterPseudo<
1675 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "ATOMIC_LOAD_XOR_I8",
1676 [(set i32:$dst, (atomic_load_xor_8 xoaddr:$ptr, i32:$incr))]>;
1677 def ATOMIC_LOAD_NAND_I8 : PPCCustomInserterPseudo<
1678 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I8",
1679 [(set i32:$dst, (atomic_load_nand_8 xoaddr:$ptr, i32:$incr))]>;
1680 def ATOMIC_LOAD_MIN_I8 : PPCCustomInserterPseudo<
1681 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MIN_I8",
1682 [(set i32:$dst, (atomic_load_min_8 xoaddr:$ptr, i32:$incr))]>;
1683 def ATOMIC_LOAD_MAX_I8 : PPCCustomInserterPseudo<
1684 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MAX_I8",
1685 [(set i32:$dst, (atomic_load_max_8 xoaddr:$ptr, i32:$incr))]>;
1686 def ATOMIC_LOAD_UMIN_I8 : PPCCustomInserterPseudo<
1687 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMIN_I8",
1688 [(set i32:$dst, (atomic_load_umin_8 xoaddr:$ptr, i32:$incr))]>;
1689 def ATOMIC_LOAD_UMAX_I8 : PPCCustomInserterPseudo<
1690 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMAX_I8",
1691 [(set i32:$dst, (atomic_load_umax_8 xoaddr:$ptr, i32:$incr))]>;
1692 def ATOMIC_LOAD_ADD_I16 : PPCCustomInserterPseudo<
1693 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I16",
1694 [(set i32:$dst, (atomic_load_add_16 xoaddr:$ptr, i32:$incr))]>;
1695 def ATOMIC_LOAD_SUB_I16 : PPCCustomInserterPseudo<
1696 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I16",
1697 [(set i32:$dst, (atomic_load_sub_16 xoaddr:$ptr, i32:$incr))]>;
1698 def ATOMIC_LOAD_AND_I16 : PPCCustomInserterPseudo<
1699 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I16",
1700 [(set i32:$dst, (atomic_load_and_16 xoaddr:$ptr, i32:$incr))]>;
1701 def ATOMIC_LOAD_OR_I16 : PPCCustomInserterPseudo<
1702 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I16",
1703 [(set i32:$dst, (atomic_load_or_16 xoaddr:$ptr, i32:$incr))]>;
1704 def ATOMIC_LOAD_XOR_I16 : PPCCustomInserterPseudo<
1705 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_XOR_I16",
1706 [(set i32:$dst, (atomic_load_xor_16 xoaddr:$ptr, i32:$incr))]>;
1707 def ATOMIC_LOAD_NAND_I16 : PPCCustomInserterPseudo<
1708 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I16",
1709 [(set i32:$dst, (atomic_load_nand_16 xoaddr:$ptr, i32:$incr))]>;
1710 def ATOMIC_LOAD_MIN_I16 : PPCCustomInserterPseudo<
1711 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MIN_I16",
1712 [(set i32:$dst, (atomic_load_min_16 xoaddr:$ptr, i32:$incr))]>;
1713 def ATOMIC_LOAD_MAX_I16 : PPCCustomInserterPseudo<
1714 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MAX_I16",
1715 [(set i32:$dst, (atomic_load_max_16 xoaddr:$ptr, i32:$incr))]>;
1716 def ATOMIC_LOAD_UMIN_I16 : PPCCustomInserterPseudo<
1717 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMIN_I16",
1718 [(set i32:$dst, (atomic_load_umin_16 xoaddr:$ptr, i32:$incr))]>;
1719 def ATOMIC_LOAD_UMAX_I16 : PPCCustomInserterPseudo<
1720 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMAX_I16",
1721 [(set i32:$dst, (atomic_load_umax_16 xoaddr:$ptr, i32:$incr))]>;
1722 def ATOMIC_LOAD_ADD_I32 : PPCCustomInserterPseudo<
1723 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I32",
1724 [(set i32:$dst, (atomic_load_add_32 xoaddr:$ptr, i32:$incr))]>;
1725 def ATOMIC_LOAD_SUB_I32 : PPCCustomInserterPseudo<
1726 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I32",
1727 [(set i32:$dst, (atomic_load_sub_32 xoaddr:$ptr, i32:$incr))]>;
1728 def ATOMIC_LOAD_AND_I32 : PPCCustomInserterPseudo<
1729 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I32",
1730 [(set i32:$dst, (atomic_load_and_32 xoaddr:$ptr, i32:$incr))]>;
1731 def ATOMIC_LOAD_OR_I32 : PPCCustomInserterPseudo<
1732 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I32",
1733 [(set i32:$dst, (atomic_load_or_32 xoaddr:$ptr, i32:$incr))]>;
1734 def ATOMIC_LOAD_XOR_I32 : PPCCustomInserterPseudo<
1735 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_XOR_I32",
1736 [(set i32:$dst, (atomic_load_xor_32 xoaddr:$ptr, i32:$incr))]>;
1737 def ATOMIC_LOAD_NAND_I32 : PPCCustomInserterPseudo<
1738 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I32",
1739 [(set i32:$dst, (atomic_load_nand_32 xoaddr:$ptr, i32:$incr))]>;
1740 def ATOMIC_LOAD_MIN_I32 : PPCCustomInserterPseudo<
1741 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MIN_I32",
1742 [(set i32:$dst, (atomic_load_min_32 xoaddr:$ptr, i32:$incr))]>;
1743 def ATOMIC_LOAD_MAX_I32 : PPCCustomInserterPseudo<
1744 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MAX_I32",
1745 [(set i32:$dst, (atomic_load_max_32 xoaddr:$ptr, i32:$incr))]>;
1746 def ATOMIC_LOAD_UMIN_I32 : PPCCustomInserterPseudo<
1747 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMIN_I32",
1748 [(set i32:$dst, (atomic_load_umin_32 xoaddr:$ptr, i32:$incr))]>;
1749 def ATOMIC_LOAD_UMAX_I32 : PPCCustomInserterPseudo<
1750 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMAX_I32",
1751 [(set i32:$dst, (atomic_load_umax_32 xoaddr:$ptr, i32:$incr))]>;
1753 def ATOMIC_CMP_SWAP_I8 : PPCCustomInserterPseudo<
1754 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I8",
1755 [(set i32:$dst, (atomic_cmp_swap_8 xoaddr:$ptr, i32:$old, i32:$new))]>;
1756 def ATOMIC_CMP_SWAP_I16 : PPCCustomInserterPseudo<
1757 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I16 $dst $ptr $old $new",
1758 [(set i32:$dst, (atomic_cmp_swap_16 xoaddr:$ptr, i32:$old, i32:$new))]>;
1759 def ATOMIC_CMP_SWAP_I32 : PPCCustomInserterPseudo<
1760 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I32 $dst $ptr $old $new",
1761 [(set i32:$dst, (atomic_cmp_swap_32 xoaddr:$ptr, i32:$old, i32:$new))]>;
1763 def ATOMIC_SWAP_I8 : PPCCustomInserterPseudo<
1764 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_i8",
1765 [(set i32:$dst, (atomic_swap_8 xoaddr:$ptr, i32:$new))]>;
1766 def ATOMIC_SWAP_I16 : PPCCustomInserterPseudo<
1767 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_I16",
1768 [(set i32:$dst, (atomic_swap_16 xoaddr:$ptr, i32:$new))]>;
1769 def ATOMIC_SWAP_I32 : PPCCustomInserterPseudo<
1770 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_I32",
1771 [(set i32:$dst, (atomic_swap_32 xoaddr:$ptr, i32:$new))]>;
1774 def : Pat<(PPCatomicCmpSwap_8 xoaddr:$ptr, i32:$old, i32:$new),
1775 (ATOMIC_CMP_SWAP_I8 xoaddr:$ptr, i32:$old, i32:$new)>;
1776 def : Pat<(PPCatomicCmpSwap_16 xoaddr:$ptr, i32:$old, i32:$new),
1777 (ATOMIC_CMP_SWAP_I16 xoaddr:$ptr, i32:$old, i32:$new)>;
1779 // Instructions to support atomic operations
1780 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in {
1781 def LBARX : XForm_1_memOp<31, 52, (outs gprc:$rD), (ins memrr:$src),
1782 "lbarx $rD, $src", IIC_LdStLWARX, []>,
1783 Requires<[HasPartwordAtomics]>;
1785 def LHARX : XForm_1_memOp<31, 116, (outs gprc:$rD), (ins memrr:$src),
1786 "lharx $rD, $src", IIC_LdStLWARX, []>,
1787 Requires<[HasPartwordAtomics]>;
1789 def LWARX : XForm_1_memOp<31, 20, (outs gprc:$rD), (ins memrr:$src),
1790 "lwarx $rD, $src", IIC_LdStLWARX, []>;
1792 // Instructions to support lock versions of atomics
1793 // (EH=1 - see Power ISA 2.07 Book II 4.4.2)
1794 def LBARXL : XForm_1_memOp<31, 52, (outs gprc:$rD), (ins memrr:$src),
1795 "lbarx $rD, $src, 1", IIC_LdStLWARX, []>, isDOT,
1796 Requires<[HasPartwordAtomics]>;
1798 def LHARXL : XForm_1_memOp<31, 116, (outs gprc:$rD), (ins memrr:$src),
1799 "lharx $rD, $src, 1", IIC_LdStLWARX, []>, isDOT,
1800 Requires<[HasPartwordAtomics]>;
1802 def LWARXL : XForm_1_memOp<31, 20, (outs gprc:$rD), (ins memrr:$src),
1803 "lwarx $rD, $src, 1", IIC_LdStLWARX, []>, isDOT;
1805 // The atomic instructions use the destination register as well as the next one
1806 // or two registers in order (modulo 31).
1807 let hasExtraSrcRegAllocReq = 1 in
1808 def LWAT : X_RD5_RS5_IM5<31, 582, (outs gprc:$rD), (ins gprc:$rA, u5imm:$FC),
1809 "lwat $rD, $rA, $FC", IIC_LdStLoad>,
1810 Requires<[IsISA3_0]>;
1813 let Defs = [CR0], mayStore = 1, mayLoad = 0, hasSideEffects = 0 in {
1814 def STBCX : XForm_1_memOp<31, 694, (outs), (ins gprc:$rS, memrr:$dst),
1815 "stbcx. $rS, $dst", IIC_LdStSTWCX, []>,
1816 isDOT, Requires<[HasPartwordAtomics]>;
1818 def STHCX : XForm_1_memOp<31, 726, (outs), (ins gprc:$rS, memrr:$dst),
1819 "sthcx. $rS, $dst", IIC_LdStSTWCX, []>,
1820 isDOT, Requires<[HasPartwordAtomics]>;
1822 def STWCX : XForm_1_memOp<31, 150, (outs), (ins gprc:$rS, memrr:$dst),
1823 "stwcx. $rS, $dst", IIC_LdStSTWCX, []>, isDOT;
1826 let mayStore = 1, mayLoad = 0, hasSideEffects = 0 in
1827 def STWAT : X_RD5_RS5_IM5<31, 710, (outs), (ins gprc:$rS, gprc:$rA, u5imm:$FC),
1828 "stwat $rS, $rA, $FC", IIC_LdStStore>,
1829 Requires<[IsISA3_0]>;
1831 let isTerminator = 1, isBarrier = 1, hasCtrlDep = 1 in
1832 def TRAP : XForm_24<31, 4, (outs), (ins), "trap", IIC_LdStLoad, [(trap)]>;
1834 def TWI : DForm_base<3, (outs), (ins u5imm:$to, gprc:$rA, s16imm:$imm),
1835 "twi $to, $rA, $imm", IIC_IntTrapW, []>;
1836 def TW : XForm_1<31, 4, (outs), (ins u5imm:$to, gprc:$rA, gprc:$rB),
1837 "tw $to, $rA, $rB", IIC_IntTrapW, []>;
1838 def TDI : DForm_base<2, (outs), (ins u5imm:$to, g8rc:$rA, s16imm:$imm),
1839 "tdi $to, $rA, $imm", IIC_IntTrapD, []>;
1840 def TD : XForm_1<31, 68, (outs), (ins u5imm:$to, g8rc:$rA, g8rc:$rB),
1841 "td $to, $rA, $rB", IIC_IntTrapD, []>;
1843 //===----------------------------------------------------------------------===//
1844 // PPC32 Load Instructions.
1847 // Unindexed (r+i) Loads.
1848 let PPC970_Unit = 2 in {
1849 def LBZ : DForm_1<34, (outs gprc:$rD), (ins memri:$src),
1850 "lbz $rD, $src", IIC_LdStLoad,
1851 [(set i32:$rD, (zextloadi8 iaddr:$src))]>;
1852 def LHA : DForm_1<42, (outs gprc:$rD), (ins memri:$src),
1853 "lha $rD, $src", IIC_LdStLHA,
1854 [(set i32:$rD, (sextloadi16 iaddr:$src))]>,
1855 PPC970_DGroup_Cracked;
1856 def LHZ : DForm_1<40, (outs gprc:$rD), (ins memri:$src),
1857 "lhz $rD, $src", IIC_LdStLoad,
1858 [(set i32:$rD, (zextloadi16 iaddr:$src))]>;
1859 def LWZ : DForm_1<32, (outs gprc:$rD), (ins memri:$src),
1860 "lwz $rD, $src", IIC_LdStLoad,
1861 [(set i32:$rD, (load iaddr:$src))]>;
1863 let Predicates = [HasFPU] in {
1864 def LFS : DForm_1<48, (outs f4rc:$rD), (ins memri:$src),
1865 "lfs $rD, $src", IIC_LdStLFD,
1866 [(set f32:$rD, (load iaddr:$src))]>;
1867 def LFD : DForm_1<50, (outs f8rc:$rD), (ins memri:$src),
1868 "lfd $rD, $src", IIC_LdStLFD,
1869 [(set f64:$rD, (load iaddr:$src))]>;
1873 // Unindexed (r+i) Loads with Update (preinc).
1874 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in {
1875 def LBZU : DForm_1<35, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1876 "lbzu $rD, $addr", IIC_LdStLoadUpd,
1877 []>, RegConstraint<"$addr.reg = $ea_result">,
1878 NoEncode<"$ea_result">;
1880 def LHAU : DForm_1<43, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1881 "lhau $rD, $addr", IIC_LdStLHAU,
1882 []>, RegConstraint<"$addr.reg = $ea_result">,
1883 NoEncode<"$ea_result">;
1885 def LHZU : DForm_1<41, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1886 "lhzu $rD, $addr", IIC_LdStLoadUpd,
1887 []>, RegConstraint<"$addr.reg = $ea_result">,
1888 NoEncode<"$ea_result">;
1890 def LWZU : DForm_1<33, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1891 "lwzu $rD, $addr", IIC_LdStLoadUpd,
1892 []>, RegConstraint<"$addr.reg = $ea_result">,
1893 NoEncode<"$ea_result">;
1895 let Predicates = [HasFPU] in {
1896 def LFSU : DForm_1<49, (outs f4rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1897 "lfsu $rD, $addr", IIC_LdStLFDU,
1898 []>, RegConstraint<"$addr.reg = $ea_result">,
1899 NoEncode<"$ea_result">;
1901 def LFDU : DForm_1<51, (outs f8rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1902 "lfdu $rD, $addr", IIC_LdStLFDU,
1903 []>, RegConstraint<"$addr.reg = $ea_result">,
1904 NoEncode<"$ea_result">;
1908 // Indexed (r+r) Loads with Update (preinc).
1909 def LBZUX : XForm_1_memOp<31, 119, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1911 "lbzux $rD, $addr", IIC_LdStLoadUpdX,
1912 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1913 NoEncode<"$ea_result">;
1915 def LHAUX : XForm_1_memOp<31, 375, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1917 "lhaux $rD, $addr", IIC_LdStLHAUX,
1918 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1919 NoEncode<"$ea_result">;
1921 def LHZUX : XForm_1_memOp<31, 311, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1923 "lhzux $rD, $addr", IIC_LdStLoadUpdX,
1924 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1925 NoEncode<"$ea_result">;
1927 def LWZUX : XForm_1_memOp<31, 55, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1929 "lwzux $rD, $addr", IIC_LdStLoadUpdX,
1930 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1931 NoEncode<"$ea_result">;
1933 let Predicates = [HasFPU] in {
1934 def LFSUX : XForm_1_memOp<31, 567, (outs f4rc:$rD, ptr_rc_nor0:$ea_result),
1936 "lfsux $rD, $addr", IIC_LdStLFDUX,
1937 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1938 NoEncode<"$ea_result">;
1940 def LFDUX : XForm_1_memOp<31, 631, (outs f8rc:$rD, ptr_rc_nor0:$ea_result),
1942 "lfdux $rD, $addr", IIC_LdStLFDUX,
1943 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1944 NoEncode<"$ea_result">;
1949 // Indexed (r+r) Loads.
1951 let PPC970_Unit = 2, mayLoad = 1, mayStore = 0 in {
1952 def LBZX : XForm_1_memOp<31, 87, (outs gprc:$rD), (ins memrr:$src),
1953 "lbzx $rD, $src", IIC_LdStLoad,
1954 [(set i32:$rD, (zextloadi8 xaddr:$src))]>;
1955 def LHAX : XForm_1_memOp<31, 343, (outs gprc:$rD), (ins memrr:$src),
1956 "lhax $rD, $src", IIC_LdStLHA,
1957 [(set i32:$rD, (sextloadi16 xaddr:$src))]>,
1958 PPC970_DGroup_Cracked;
1959 def LHZX : XForm_1_memOp<31, 279, (outs gprc:$rD), (ins memrr:$src),
1960 "lhzx $rD, $src", IIC_LdStLoad,
1961 [(set i32:$rD, (zextloadi16 xaddr:$src))]>;
1962 def LWZX : XForm_1_memOp<31, 23, (outs gprc:$rD), (ins memrr:$src),
1963 "lwzx $rD, $src", IIC_LdStLoad,
1964 [(set i32:$rD, (load xaddr:$src))]>;
1965 def LHBRX : XForm_1_memOp<31, 790, (outs gprc:$rD), (ins memrr:$src),
1966 "lhbrx $rD, $src", IIC_LdStLoad,
1967 [(set i32:$rD, (PPClbrx xoaddr:$src, i16))]>;
1968 def LWBRX : XForm_1_memOp<31, 534, (outs gprc:$rD), (ins memrr:$src),
1969 "lwbrx $rD, $src", IIC_LdStLoad,
1970 [(set i32:$rD, (PPClbrx xoaddr:$src, i32))]>;
1972 let Predicates = [HasFPU] in {
1973 def LFSX : XForm_25_memOp<31, 535, (outs f4rc:$frD), (ins memrr:$src),
1974 "lfsx $frD, $src", IIC_LdStLFD,
1975 [(set f32:$frD, (load xaddr:$src))]>;
1976 def LFDX : XForm_25_memOp<31, 599, (outs f8rc:$frD), (ins memrr:$src),
1977 "lfdx $frD, $src", IIC_LdStLFD,
1978 [(set f64:$frD, (load xaddr:$src))]>;
1980 def LFIWAX : XForm_25_memOp<31, 855, (outs f8rc:$frD), (ins memrr:$src),
1981 "lfiwax $frD, $src", IIC_LdStLFD,
1982 [(set f64:$frD, (PPClfiwax xoaddr:$src))]>;
1983 def LFIWZX : XForm_25_memOp<31, 887, (outs f8rc:$frD), (ins memrr:$src),
1984 "lfiwzx $frD, $src", IIC_LdStLFD,
1985 [(set f64:$frD, (PPClfiwzx xoaddr:$src))]>;
1990 def LMW : DForm_1<46, (outs gprc:$rD), (ins memri:$src),
1991 "lmw $rD, $src", IIC_LdStLMW, []>;
1993 //===----------------------------------------------------------------------===//
1994 // PPC32 Store Instructions.
1997 // Unindexed (r+i) Stores.
1998 let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in {
1999 def STB : DForm_1<38, (outs), (ins gprc:$rS, memri:$dst),
2000 "stb $rS, $dst", IIC_LdStStore,
2001 [(truncstorei8 i32:$rS, iaddr:$dst)]>;
2002 def STH : DForm_1<44, (outs), (ins gprc:$rS, memri:$dst),
2003 "sth $rS, $dst", IIC_LdStStore,
2004 [(truncstorei16 i32:$rS, iaddr:$dst)]>;
2005 def STW : DForm_1<36, (outs), (ins gprc:$rS, memri:$dst),
2006 "stw $rS, $dst", IIC_LdStStore,
2007 [(store i32:$rS, iaddr:$dst)]>;
2008 let Predicates = [HasFPU] in {
2009 def STFS : DForm_1<52, (outs), (ins f4rc:$rS, memri:$dst),
2010 "stfs $rS, $dst", IIC_LdStSTFD,
2011 [(store f32:$rS, iaddr:$dst)]>;
2012 def STFD : DForm_1<54, (outs), (ins f8rc:$rS, memri:$dst),
2013 "stfd $rS, $dst", IIC_LdStSTFD,
2014 [(store f64:$rS, iaddr:$dst)]>;
2018 // Unindexed (r+i) Stores with Update (preinc).
2019 let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in {
2020 def STBU : DForm_1<39, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst),
2021 "stbu $rS, $dst", IIC_LdStSTU, []>,
2022 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
2023 def STHU : DForm_1<45, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst),
2024 "sthu $rS, $dst", IIC_LdStSTU, []>,
2025 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
2026 def STWU : DForm_1<37, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst),
2027 "stwu $rS, $dst", IIC_LdStSTU, []>,
2028 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
2029 let Predicates = [HasFPU] in {
2030 def STFSU : DForm_1<53, (outs ptr_rc_nor0:$ea_res), (ins f4rc:$rS, memri:$dst),
2031 "stfsu $rS, $dst", IIC_LdStSTFDU, []>,
2032 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
2033 def STFDU : DForm_1<55, (outs ptr_rc_nor0:$ea_res), (ins f8rc:$rS, memri:$dst),
2034 "stfdu $rS, $dst", IIC_LdStSTFDU, []>,
2035 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
2039 // Patterns to match the pre-inc stores. We can't put the patterns on
2040 // the instruction definitions directly as ISel wants the address base
2041 // and offset to be separate operands, not a single complex operand.
2042 def : Pat<(pre_truncsti8 i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
2043 (STBU $rS, iaddroff:$ptroff, $ptrreg)>;
2044 def : Pat<(pre_truncsti16 i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
2045 (STHU $rS, iaddroff:$ptroff, $ptrreg)>;
2046 def : Pat<(pre_store i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
2047 (STWU $rS, iaddroff:$ptroff, $ptrreg)>;
2048 def : Pat<(pre_store f32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
2049 (STFSU $rS, iaddroff:$ptroff, $ptrreg)>;
2050 def : Pat<(pre_store f64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
2051 (STFDU $rS, iaddroff:$ptroff, $ptrreg)>;
2053 // Indexed (r+r) Stores.
2054 let PPC970_Unit = 2 in {
2055 def STBX : XForm_8_memOp<31, 215, (outs), (ins gprc:$rS, memrr:$dst),
2056 "stbx $rS, $dst", IIC_LdStStore,
2057 [(truncstorei8 i32:$rS, xaddr:$dst)]>,
2058 PPC970_DGroup_Cracked;
2059 def STHX : XForm_8_memOp<31, 407, (outs), (ins gprc:$rS, memrr:$dst),
2060 "sthx $rS, $dst", IIC_LdStStore,
2061 [(truncstorei16 i32:$rS, xaddr:$dst)]>,
2062 PPC970_DGroup_Cracked;
2063 def STWX : XForm_8_memOp<31, 151, (outs), (ins gprc:$rS, memrr:$dst),
2064 "stwx $rS, $dst", IIC_LdStStore,
2065 [(store i32:$rS, xaddr:$dst)]>,
2066 PPC970_DGroup_Cracked;
2068 def STHBRX: XForm_8_memOp<31, 918, (outs), (ins gprc:$rS, memrr:$dst),
2069 "sthbrx $rS, $dst", IIC_LdStStore,
2070 [(PPCstbrx i32:$rS, xoaddr:$dst, i16)]>,
2071 PPC970_DGroup_Cracked;
2072 def STWBRX: XForm_8_memOp<31, 662, (outs), (ins gprc:$rS, memrr:$dst),
2073 "stwbrx $rS, $dst", IIC_LdStStore,
2074 [(PPCstbrx i32:$rS, xoaddr:$dst, i32)]>,
2075 PPC970_DGroup_Cracked;
2077 let Predicates = [HasFPU] in {
2078 def STFIWX: XForm_28_memOp<31, 983, (outs), (ins f8rc:$frS, memrr:$dst),
2079 "stfiwx $frS, $dst", IIC_LdStSTFD,
2080 [(PPCstfiwx f64:$frS, xoaddr:$dst)]>;
2082 def STFSX : XForm_28_memOp<31, 663, (outs), (ins f4rc:$frS, memrr:$dst),
2083 "stfsx $frS, $dst", IIC_LdStSTFD,
2084 [(store f32:$frS, xaddr:$dst)]>;
2085 def STFDX : XForm_28_memOp<31, 727, (outs), (ins f8rc:$frS, memrr:$dst),
2086 "stfdx $frS, $dst", IIC_LdStSTFD,
2087 [(store f64:$frS, xaddr:$dst)]>;
2091 // Indexed (r+r) Stores with Update (preinc).
2092 let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in {
2093 def STBUX : XForm_8_memOp<31, 247, (outs ptr_rc_nor0:$ea_res),
2094 (ins gprc:$rS, memrr:$dst),
2095 "stbux $rS, $dst", IIC_LdStSTUX, []>,
2096 RegConstraint<"$dst.ptrreg = $ea_res">,
2097 NoEncode<"$ea_res">,
2098 PPC970_DGroup_Cracked;
2099 def STHUX : XForm_8_memOp<31, 439, (outs ptr_rc_nor0:$ea_res),
2100 (ins gprc:$rS, memrr:$dst),
2101 "sthux $rS, $dst", IIC_LdStSTUX, []>,
2102 RegConstraint<"$dst.ptrreg = $ea_res">,
2103 NoEncode<"$ea_res">,
2104 PPC970_DGroup_Cracked;
2105 def STWUX : XForm_8_memOp<31, 183, (outs ptr_rc_nor0:$ea_res),
2106 (ins gprc:$rS, memrr:$dst),
2107 "stwux $rS, $dst", IIC_LdStSTUX, []>,
2108 RegConstraint<"$dst.ptrreg = $ea_res">,
2109 NoEncode<"$ea_res">,
2110 PPC970_DGroup_Cracked;
2111 let Predicates = [HasFPU] in {
2112 def STFSUX: XForm_8_memOp<31, 695, (outs ptr_rc_nor0:$ea_res),
2113 (ins f4rc:$rS, memrr:$dst),
2114 "stfsux $rS, $dst", IIC_LdStSTFDU, []>,
2115 RegConstraint<"$dst.ptrreg = $ea_res">,
2116 NoEncode<"$ea_res">,
2117 PPC970_DGroup_Cracked;
2118 def STFDUX: XForm_8_memOp<31, 759, (outs ptr_rc_nor0:$ea_res),
2119 (ins f8rc:$rS, memrr:$dst),
2120 "stfdux $rS, $dst", IIC_LdStSTFDU, []>,
2121 RegConstraint<"$dst.ptrreg = $ea_res">,
2122 NoEncode<"$ea_res">,
2123 PPC970_DGroup_Cracked;
2127 // Patterns to match the pre-inc stores. We can't put the patterns on
2128 // the instruction definitions directly as ISel wants the address base
2129 // and offset to be separate operands, not a single complex operand.
2130 def : Pat<(pre_truncsti8 i32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2131 (STBUX $rS, $ptrreg, $ptroff)>;
2132 def : Pat<(pre_truncsti16 i32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2133 (STHUX $rS, $ptrreg, $ptroff)>;
2134 def : Pat<(pre_store i32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2135 (STWUX $rS, $ptrreg, $ptroff)>;
2136 let Predicates = [HasFPU] in {
2137 def : Pat<(pre_store f32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2138 (STFSUX $rS, $ptrreg, $ptroff)>;
2139 def : Pat<(pre_store f64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2140 (STFDUX $rS, $ptrreg, $ptroff)>;
2144 def STMW : DForm_1<47, (outs), (ins gprc:$rS, memri:$dst),
2145 "stmw $rS, $dst", IIC_LdStLMW, []>;
2147 def SYNC : XForm_24_sync<31, 598, (outs), (ins i32imm:$L),
2148 "sync $L", IIC_LdStSync, []>;
2150 let isCodeGenOnly = 1 in {
2151 def MSYNC : XForm_24_sync<31, 598, (outs), (ins),
2152 "msync", IIC_LdStSync, []> {
2157 def : Pat<(int_ppc_sync), (SYNC 0)>, Requires<[HasSYNC]>;
2158 def : Pat<(int_ppc_lwsync), (SYNC 1)>, Requires<[HasSYNC]>;
2159 def : Pat<(int_ppc_sync), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
2160 def : Pat<(int_ppc_lwsync), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
2162 //===----------------------------------------------------------------------===//
2163 // PPC32 Arithmetic Instructions.
2166 let PPC970_Unit = 1 in { // FXU Operations.
2167 def ADDI : DForm_2<14, (outs gprc:$rD), (ins gprc_nor0:$rA, s16imm:$imm),
2168 "addi $rD, $rA, $imm", IIC_IntSimple,
2169 [(set i32:$rD, (add i32:$rA, imm32SExt16:$imm))]>;
2170 let BaseName = "addic" in {
2171 let Defs = [CARRY] in
2172 def ADDIC : DForm_2<12, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
2173 "addic $rD, $rA, $imm", IIC_IntGeneral,
2174 [(set i32:$rD, (addc i32:$rA, imm32SExt16:$imm))]>,
2175 RecFormRel, PPC970_DGroup_Cracked;
2176 let Defs = [CARRY, CR0] in
2177 def ADDICo : DForm_2<13, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
2178 "addic. $rD, $rA, $imm", IIC_IntGeneral,
2179 []>, isDOT, RecFormRel;
2181 def ADDIS : DForm_2<15, (outs gprc:$rD), (ins gprc_nor0:$rA, s17imm:$imm),
2182 "addis $rD, $rA, $imm", IIC_IntSimple,
2183 [(set i32:$rD, (add i32:$rA, imm16ShiftedSExt:$imm))]>;
2184 let isCodeGenOnly = 1 in
2185 def LA : DForm_2<14, (outs gprc:$rD), (ins gprc_nor0:$rA, s16imm:$sym),
2186 "la $rD, $sym($rA)", IIC_IntGeneral,
2187 [(set i32:$rD, (add i32:$rA,
2188 (PPClo tglobaladdr:$sym, 0)))]>;
2189 def MULLI : DForm_2< 7, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
2190 "mulli $rD, $rA, $imm", IIC_IntMulLI,
2191 [(set i32:$rD, (mul i32:$rA, imm32SExt16:$imm))]>;
2192 let Defs = [CARRY] in
2193 def SUBFIC : DForm_2< 8, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
2194 "subfic $rD, $rA, $imm", IIC_IntGeneral,
2195 [(set i32:$rD, (subc imm32SExt16:$imm, i32:$rA))]>;
2197 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in {
2198 def LI : DForm_2_r0<14, (outs gprc:$rD), (ins s16imm:$imm),
2199 "li $rD, $imm", IIC_IntSimple,
2200 [(set i32:$rD, imm32SExt16:$imm)]>;
2201 def LIS : DForm_2_r0<15, (outs gprc:$rD), (ins s17imm:$imm),
2202 "lis $rD, $imm", IIC_IntSimple,
2203 [(set i32:$rD, imm16ShiftedSExt:$imm)]>;
2207 let PPC970_Unit = 1 in { // FXU Operations.
2208 let Defs = [CR0] in {
2209 def ANDIo : DForm_4<28, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2210 "andi. $dst, $src1, $src2", IIC_IntGeneral,
2211 [(set i32:$dst, (and i32:$src1, immZExt16:$src2))]>,
2213 def ANDISo : DForm_4<29, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2214 "andis. $dst, $src1, $src2", IIC_IntGeneral,
2215 [(set i32:$dst, (and i32:$src1, imm16ShiftedZExt:$src2))]>,
2218 def ORI : DForm_4<24, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2219 "ori $dst, $src1, $src2", IIC_IntSimple,
2220 [(set i32:$dst, (or i32:$src1, immZExt16:$src2))]>;
2221 def ORIS : DForm_4<25, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2222 "oris $dst, $src1, $src2", IIC_IntSimple,
2223 [(set i32:$dst, (or i32:$src1, imm16ShiftedZExt:$src2))]>;
2224 def XORI : DForm_4<26, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2225 "xori $dst, $src1, $src2", IIC_IntSimple,
2226 [(set i32:$dst, (xor i32:$src1, immZExt16:$src2))]>;
2227 def XORIS : DForm_4<27, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2228 "xoris $dst, $src1, $src2", IIC_IntSimple,
2229 [(set i32:$dst, (xor i32:$src1, imm16ShiftedZExt:$src2))]>;
2231 def NOP : DForm_4_zero<24, (outs), (ins), "nop", IIC_IntSimple,
2233 let isCodeGenOnly = 1 in {
2234 // The POWER6 and POWER7 have special group-terminating nops.
2235 def NOP_GT_PWR6 : DForm_4_fixedreg_zero<24, 1, (outs), (ins),
2236 "ori 1, 1, 0", IIC_IntSimple, []>;
2237 def NOP_GT_PWR7 : DForm_4_fixedreg_zero<24, 2, (outs), (ins),
2238 "ori 2, 2, 0", IIC_IntSimple, []>;
2241 let isCompare = 1, hasSideEffects = 0 in {
2242 def CMPWI : DForm_5_ext<11, (outs crrc:$crD), (ins gprc:$rA, s16imm:$imm),
2243 "cmpwi $crD, $rA, $imm", IIC_IntCompare>;
2244 def CMPLWI : DForm_6_ext<10, (outs crrc:$dst), (ins gprc:$src1, u16imm:$src2),
2245 "cmplwi $dst, $src1, $src2", IIC_IntCompare>;
2246 def CMPRB : X_BF3_L1_RS5_RS5<31, 192, (outs crbitrc:$BF),
2247 (ins u1imm:$L, g8rc:$rA, g8rc:$rB),
2248 "cmprb $BF, $L, $rA, $rB", IIC_IntCompare, []>,
2249 Requires<[IsISA3_0]>;
2253 let PPC970_Unit = 1, hasSideEffects = 0 in { // FXU Operations.
2254 let isCommutable = 1 in {
2255 defm NAND : XForm_6r<31, 476, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2256 "nand", "$rA, $rS, $rB", IIC_IntSimple,
2257 [(set i32:$rA, (not (and i32:$rS, i32:$rB)))]>;
2258 defm AND : XForm_6r<31, 28, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2259 "and", "$rA, $rS, $rB", IIC_IntSimple,
2260 [(set i32:$rA, (and i32:$rS, i32:$rB))]>;
2262 defm ANDC : XForm_6r<31, 60, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2263 "andc", "$rA, $rS, $rB", IIC_IntSimple,
2264 [(set i32:$rA, (and i32:$rS, (not i32:$rB)))]>;
2265 let isCommutable = 1 in {
2266 defm OR : XForm_6r<31, 444, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2267 "or", "$rA, $rS, $rB", IIC_IntSimple,
2268 [(set i32:$rA, (or i32:$rS, i32:$rB))]>;
2269 defm NOR : XForm_6r<31, 124, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2270 "nor", "$rA, $rS, $rB", IIC_IntSimple,
2271 [(set i32:$rA, (not (or i32:$rS, i32:$rB)))]>;
2273 defm ORC : XForm_6r<31, 412, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2274 "orc", "$rA, $rS, $rB", IIC_IntSimple,
2275 [(set i32:$rA, (or i32:$rS, (not i32:$rB)))]>;
2276 let isCommutable = 1 in {
2277 defm EQV : XForm_6r<31, 284, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2278 "eqv", "$rA, $rS, $rB", IIC_IntSimple,
2279 [(set i32:$rA, (not (xor i32:$rS, i32:$rB)))]>;
2280 defm XOR : XForm_6r<31, 316, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2281 "xor", "$rA, $rS, $rB", IIC_IntSimple,
2282 [(set i32:$rA, (xor i32:$rS, i32:$rB))]>;
2284 defm SLW : XForm_6r<31, 24, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2285 "slw", "$rA, $rS, $rB", IIC_IntGeneral,
2286 [(set i32:$rA, (PPCshl i32:$rS, i32:$rB))]>;
2287 defm SRW : XForm_6r<31, 536, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2288 "srw", "$rA, $rS, $rB", IIC_IntGeneral,
2289 [(set i32:$rA, (PPCsrl i32:$rS, i32:$rB))]>;
2290 defm SRAW : XForm_6rc<31, 792, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2291 "sraw", "$rA, $rS, $rB", IIC_IntShift,
2292 [(set i32:$rA, (PPCsra i32:$rS, i32:$rB))]>;
2295 let PPC970_Unit = 1 in { // FXU Operations.
2296 let hasSideEffects = 0 in {
2297 defm SRAWI : XForm_10rc<31, 824, (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH),
2298 "srawi", "$rA, $rS, $SH", IIC_IntShift,
2299 [(set i32:$rA, (sra i32:$rS, (i32 imm:$SH)))]>;
2300 defm CNTLZW : XForm_11r<31, 26, (outs gprc:$rA), (ins gprc:$rS),
2301 "cntlzw", "$rA, $rS", IIC_IntGeneral,
2302 [(set i32:$rA, (ctlz i32:$rS))]>;
2303 defm CNTTZW : XForm_11r<31, 538, (outs gprc:$rA), (ins gprc:$rS),
2304 "cnttzw", "$rA, $rS", IIC_IntGeneral,
2305 [(set i32:$rA, (cttz i32:$rS))]>, Requires<[IsISA3_0]>;
2306 defm EXTSB : XForm_11r<31, 954, (outs gprc:$rA), (ins gprc:$rS),
2307 "extsb", "$rA, $rS", IIC_IntSimple,
2308 [(set i32:$rA, (sext_inreg i32:$rS, i8))]>;
2309 defm EXTSH : XForm_11r<31, 922, (outs gprc:$rA), (ins gprc:$rS),
2310 "extsh", "$rA, $rS", IIC_IntSimple,
2311 [(set i32:$rA, (sext_inreg i32:$rS, i16))]>;
2313 let isCommutable = 1 in
2314 def CMPB : XForm_6<31, 508, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2315 "cmpb $rA, $rS, $rB", IIC_IntGeneral,
2316 [(set i32:$rA, (PPCcmpb i32:$rS, i32:$rB))]>;
2318 let isCompare = 1, hasSideEffects = 0 in {
2319 def CMPW : XForm_16_ext<31, 0, (outs crrc:$crD), (ins gprc:$rA, gprc:$rB),
2320 "cmpw $crD, $rA, $rB", IIC_IntCompare>;
2321 def CMPLW : XForm_16_ext<31, 32, (outs crrc:$crD), (ins gprc:$rA, gprc:$rB),
2322 "cmplw $crD, $rA, $rB", IIC_IntCompare>;
2325 let PPC970_Unit = 3, Predicates = [HasFPU] in { // FPU Operations.
2326 //def FCMPO : XForm_17<63, 32, (outs CRRC:$crD), (ins FPRC:$fA, FPRC:$fB),
2327 // "fcmpo $crD, $fA, $fB", IIC_FPCompare>;
2328 let isCompare = 1, hasSideEffects = 0 in {
2329 def FCMPUS : XForm_17<63, 0, (outs crrc:$crD), (ins f4rc:$fA, f4rc:$fB),
2330 "fcmpu $crD, $fA, $fB", IIC_FPCompare>;
2331 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2332 def FCMPUD : XForm_17<63, 0, (outs crrc:$crD), (ins f8rc:$fA, f8rc:$fB),
2333 "fcmpu $crD, $fA, $fB", IIC_FPCompare>;
2336 def FTDIV: XForm_17<63, 128, (outs crrc:$crD), (ins f8rc:$fA, f8rc:$fB),
2337 "ftdiv $crD, $fA, $fB", IIC_FPCompare>;
2338 def FTSQRT: XForm_17a<63, 160, (outs crrc:$crD), (ins f8rc:$fB),
2339 "ftsqrt $crD, $fB", IIC_FPCompare>;
2341 let Uses = [RM] in {
2342 let hasSideEffects = 0 in {
2343 defm FCTIW : XForm_26r<63, 14, (outs f8rc:$frD), (ins f8rc:$frB),
2344 "fctiw", "$frD, $frB", IIC_FPGeneral,
2346 defm FCTIWU : XForm_26r<63, 142, (outs f8rc:$frD), (ins f8rc:$frB),
2347 "fctiwu", "$frD, $frB", IIC_FPGeneral,
2349 defm FCTIWZ : XForm_26r<63, 15, (outs f8rc:$frD), (ins f8rc:$frB),
2350 "fctiwz", "$frD, $frB", IIC_FPGeneral,
2351 [(set f64:$frD, (PPCfctiwz f64:$frB))]>;
2353 defm FRSP : XForm_26r<63, 12, (outs f4rc:$frD), (ins f8rc:$frB),
2354 "frsp", "$frD, $frB", IIC_FPGeneral,
2355 [(set f32:$frD, (fpround f64:$frB))]>;
2357 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2358 defm FRIND : XForm_26r<63, 392, (outs f8rc:$frD), (ins f8rc:$frB),
2359 "frin", "$frD, $frB", IIC_FPGeneral,
2360 [(set f64:$frD, (fround f64:$frB))]>;
2361 defm FRINS : XForm_26r<63, 392, (outs f4rc:$frD), (ins f4rc:$frB),
2362 "frin", "$frD, $frB", IIC_FPGeneral,
2363 [(set f32:$frD, (fround f32:$frB))]>;
2366 let hasSideEffects = 0 in {
2367 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2368 defm FRIPD : XForm_26r<63, 456, (outs f8rc:$frD), (ins f8rc:$frB),
2369 "frip", "$frD, $frB", IIC_FPGeneral,
2370 [(set f64:$frD, (fceil f64:$frB))]>;
2371 defm FRIPS : XForm_26r<63, 456, (outs f4rc:$frD), (ins f4rc:$frB),
2372 "frip", "$frD, $frB", IIC_FPGeneral,
2373 [(set f32:$frD, (fceil f32:$frB))]>;
2374 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2375 defm FRIZD : XForm_26r<63, 424, (outs f8rc:$frD), (ins f8rc:$frB),
2376 "friz", "$frD, $frB", IIC_FPGeneral,
2377 [(set f64:$frD, (ftrunc f64:$frB))]>;
2378 defm FRIZS : XForm_26r<63, 424, (outs f4rc:$frD), (ins f4rc:$frB),
2379 "friz", "$frD, $frB", IIC_FPGeneral,
2380 [(set f32:$frD, (ftrunc f32:$frB))]>;
2381 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2382 defm FRIMD : XForm_26r<63, 488, (outs f8rc:$frD), (ins f8rc:$frB),
2383 "frim", "$frD, $frB", IIC_FPGeneral,
2384 [(set f64:$frD, (ffloor f64:$frB))]>;
2385 defm FRIMS : XForm_26r<63, 488, (outs f4rc:$frD), (ins f4rc:$frB),
2386 "frim", "$frD, $frB", IIC_FPGeneral,
2387 [(set f32:$frD, (ffloor f32:$frB))]>;
2389 defm FSQRT : XForm_26r<63, 22, (outs f8rc:$frD), (ins f8rc:$frB),
2390 "fsqrt", "$frD, $frB", IIC_FPSqrtD,
2391 [(set f64:$frD, (fsqrt f64:$frB))]>;
2392 defm FSQRTS : XForm_26r<59, 22, (outs f4rc:$frD), (ins f4rc:$frB),
2393 "fsqrts", "$frD, $frB", IIC_FPSqrtS,
2394 [(set f32:$frD, (fsqrt f32:$frB))]>;
2399 /// Note that FMR is defined as pseudo-ops on the PPC970 because they are
2400 /// often coalesced away and we don't want the dispatch group builder to think
2401 /// that they will fill slots (which could cause the load of a LSU reject to
2402 /// sneak into a d-group with a store).
2403 let hasSideEffects = 0, Predicates = [HasFPU] in
2404 defm FMR : XForm_26r<63, 72, (outs f4rc:$frD), (ins f4rc:$frB),
2405 "fmr", "$frD, $frB", IIC_FPGeneral,
2406 []>, // (set f32:$frD, f32:$frB)
2409 let PPC970_Unit = 3, hasSideEffects = 0, Predicates = [HasFPU] in { // FPU Operations.
2410 // These are artificially split into two different forms, for 4/8 byte FP.
2411 defm FABSS : XForm_26r<63, 264, (outs f4rc:$frD), (ins f4rc:$frB),
2412 "fabs", "$frD, $frB", IIC_FPGeneral,
2413 [(set f32:$frD, (fabs f32:$frB))]>;
2414 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2415 defm FABSD : XForm_26r<63, 264, (outs f8rc:$frD), (ins f8rc:$frB),
2416 "fabs", "$frD, $frB", IIC_FPGeneral,
2417 [(set f64:$frD, (fabs f64:$frB))]>;
2418 defm FNABSS : XForm_26r<63, 136, (outs f4rc:$frD), (ins f4rc:$frB),
2419 "fnabs", "$frD, $frB", IIC_FPGeneral,
2420 [(set f32:$frD, (fneg (fabs f32:$frB)))]>;
2421 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2422 defm FNABSD : XForm_26r<63, 136, (outs f8rc:$frD), (ins f8rc:$frB),
2423 "fnabs", "$frD, $frB", IIC_FPGeneral,
2424 [(set f64:$frD, (fneg (fabs f64:$frB)))]>;
2425 defm FNEGS : XForm_26r<63, 40, (outs f4rc:$frD), (ins f4rc:$frB),
2426 "fneg", "$frD, $frB", IIC_FPGeneral,
2427 [(set f32:$frD, (fneg f32:$frB))]>;
2428 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2429 defm FNEGD : XForm_26r<63, 40, (outs f8rc:$frD), (ins f8rc:$frB),
2430 "fneg", "$frD, $frB", IIC_FPGeneral,
2431 [(set f64:$frD, (fneg f64:$frB))]>;
2433 defm FCPSGNS : XForm_28r<63, 8, (outs f4rc:$frD), (ins f4rc:$frA, f4rc:$frB),
2434 "fcpsgn", "$frD, $frA, $frB", IIC_FPGeneral,
2435 [(set f32:$frD, (fcopysign f32:$frB, f32:$frA))]>;
2436 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2437 defm FCPSGND : XForm_28r<63, 8, (outs f8rc:$frD), (ins f8rc:$frA, f8rc:$frB),
2438 "fcpsgn", "$frD, $frA, $frB", IIC_FPGeneral,
2439 [(set f64:$frD, (fcopysign f64:$frB, f64:$frA))]>;
2441 // Reciprocal estimates.
2442 defm FRE : XForm_26r<63, 24, (outs f8rc:$frD), (ins f8rc:$frB),
2443 "fre", "$frD, $frB", IIC_FPGeneral,
2444 [(set f64:$frD, (PPCfre f64:$frB))]>;
2445 defm FRES : XForm_26r<59, 24, (outs f4rc:$frD), (ins f4rc:$frB),
2446 "fres", "$frD, $frB", IIC_FPGeneral,
2447 [(set f32:$frD, (PPCfre f32:$frB))]>;
2448 defm FRSQRTE : XForm_26r<63, 26, (outs f8rc:$frD), (ins f8rc:$frB),
2449 "frsqrte", "$frD, $frB", IIC_FPGeneral,
2450 [(set f64:$frD, (PPCfrsqrte f64:$frB))]>;
2451 defm FRSQRTES : XForm_26r<59, 26, (outs f4rc:$frD), (ins f4rc:$frB),
2452 "frsqrtes", "$frD, $frB", IIC_FPGeneral,
2453 [(set f32:$frD, (PPCfrsqrte f32:$frB))]>;
2456 // XL-Form instructions. condition register logical ops.
2458 let hasSideEffects = 0 in
2459 def MCRF : XLForm_3<19, 0, (outs crrc:$BF), (ins crrc:$BFA),
2460 "mcrf $BF, $BFA", IIC_BrMCR>,
2461 PPC970_DGroup_First, PPC970_Unit_CRU;
2463 // FIXME: According to the ISA (section 2.5.1 of version 2.06), the
2464 // condition-register logical instructions have preferred forms. Specifically,
2465 // it is preferred that the bit specified by the BT field be in the same
2466 // condition register as that specified by the bit BB. We might want to account
2467 // for this via hinting the register allocator and anti-dep breakers, or we
2468 // could constrain the register class to force this constraint and then loosen
2469 // it during register allocation via convertToThreeAddress or some similar
2472 let isCommutable = 1 in {
2473 def CRAND : XLForm_1<19, 257, (outs crbitrc:$CRD),
2474 (ins crbitrc:$CRA, crbitrc:$CRB),
2475 "crand $CRD, $CRA, $CRB", IIC_BrCR,
2476 [(set i1:$CRD, (and i1:$CRA, i1:$CRB))]>;
2478 def CRNAND : XLForm_1<19, 225, (outs crbitrc:$CRD),
2479 (ins crbitrc:$CRA, crbitrc:$CRB),
2480 "crnand $CRD, $CRA, $CRB", IIC_BrCR,
2481 [(set i1:$CRD, (not (and i1:$CRA, i1:$CRB)))]>;
2483 def CROR : XLForm_1<19, 449, (outs crbitrc:$CRD),
2484 (ins crbitrc:$CRA, crbitrc:$CRB),
2485 "cror $CRD, $CRA, $CRB", IIC_BrCR,
2486 [(set i1:$CRD, (or i1:$CRA, i1:$CRB))]>;
2488 def CRXOR : XLForm_1<19, 193, (outs crbitrc:$CRD),
2489 (ins crbitrc:$CRA, crbitrc:$CRB),
2490 "crxor $CRD, $CRA, $CRB", IIC_BrCR,
2491 [(set i1:$CRD, (xor i1:$CRA, i1:$CRB))]>;
2493 def CRNOR : XLForm_1<19, 33, (outs crbitrc:$CRD),
2494 (ins crbitrc:$CRA, crbitrc:$CRB),
2495 "crnor $CRD, $CRA, $CRB", IIC_BrCR,
2496 [(set i1:$CRD, (not (or i1:$CRA, i1:$CRB)))]>;
2498 def CREQV : XLForm_1<19, 289, (outs crbitrc:$CRD),
2499 (ins crbitrc:$CRA, crbitrc:$CRB),
2500 "creqv $CRD, $CRA, $CRB", IIC_BrCR,
2501 [(set i1:$CRD, (not (xor i1:$CRA, i1:$CRB)))]>;
2504 def CRANDC : XLForm_1<19, 129, (outs crbitrc:$CRD),
2505 (ins crbitrc:$CRA, crbitrc:$CRB),
2506 "crandc $CRD, $CRA, $CRB", IIC_BrCR,
2507 [(set i1:$CRD, (and i1:$CRA, (not i1:$CRB)))]>;
2509 def CRORC : XLForm_1<19, 417, (outs crbitrc:$CRD),
2510 (ins crbitrc:$CRA, crbitrc:$CRB),
2511 "crorc $CRD, $CRA, $CRB", IIC_BrCR,
2512 [(set i1:$CRD, (or i1:$CRA, (not i1:$CRB)))]>;
2514 let isCodeGenOnly = 1 in {
2515 def CRSET : XLForm_1_ext<19, 289, (outs crbitrc:$dst), (ins),
2516 "creqv $dst, $dst, $dst", IIC_BrCR,
2517 [(set i1:$dst, 1)]>;
2519 def CRUNSET: XLForm_1_ext<19, 193, (outs crbitrc:$dst), (ins),
2520 "crxor $dst, $dst, $dst", IIC_BrCR,
2521 [(set i1:$dst, 0)]>;
2523 let Defs = [CR1EQ], CRD = 6 in {
2524 def CR6SET : XLForm_1_ext<19, 289, (outs), (ins),
2525 "creqv 6, 6, 6", IIC_BrCR,
2528 def CR6UNSET: XLForm_1_ext<19, 193, (outs), (ins),
2529 "crxor 6, 6, 6", IIC_BrCR,
2534 // XFX-Form instructions. Instructions that deal with SPRs.
2537 def MFSPR : XFXForm_1<31, 339, (outs gprc:$RT), (ins i32imm:$SPR),
2538 "mfspr $RT, $SPR", IIC_SprMFSPR>;
2539 def MTSPR : XFXForm_1<31, 467, (outs), (ins i32imm:$SPR, gprc:$RT),
2540 "mtspr $SPR, $RT", IIC_SprMTSPR>;
2542 def MFTB : XFXForm_1<31, 371, (outs gprc:$RT), (ins i32imm:$SPR),
2543 "mftb $RT, $SPR", IIC_SprMFTB>;
2545 def MFPMR : XFXForm_1<31, 334, (outs gprc:$RT), (ins i32imm:$SPR),
2546 "mfpmr $RT, $SPR", IIC_SprMFPMR>;
2548 def MTPMR : XFXForm_1<31, 462, (outs), (ins i32imm:$SPR, gprc:$RT),
2549 "mtpmr $SPR, $RT", IIC_SprMTPMR>;
2552 // A pseudo-instruction used to implement the read of the 64-bit cycle counter
2553 // on a 32-bit target.
2554 let hasSideEffects = 1 in
2555 def ReadTB : PPCCustomInserterPseudo<(outs gprc:$lo, gprc:$hi), (ins),
2558 let Uses = [CTR] in {
2559 def MFCTR : XFXForm_1_ext<31, 339, 9, (outs gprc:$rT), (ins),
2560 "mfctr $rT", IIC_SprMFSPR>,
2561 PPC970_DGroup_First, PPC970_Unit_FXU;
2563 let Defs = [CTR], Pattern = [(PPCmtctr i32:$rS)] in {
2564 def MTCTR : XFXForm_7_ext<31, 467, 9, (outs), (ins gprc:$rS),
2565 "mtctr $rS", IIC_SprMTSPR>,
2566 PPC970_DGroup_First, PPC970_Unit_FXU;
2568 let hasSideEffects = 1, isCodeGenOnly = 1, Defs = [CTR] in {
2569 let Pattern = [(int_ppc_mtctr i32:$rS)] in
2570 def MTCTRloop : XFXForm_7_ext<31, 467, 9, (outs), (ins gprc:$rS),
2571 "mtctr $rS", IIC_SprMTSPR>,
2572 PPC970_DGroup_First, PPC970_Unit_FXU;
2575 let Defs = [LR] in {
2576 def MTLR : XFXForm_7_ext<31, 467, 8, (outs), (ins gprc:$rS),
2577 "mtlr $rS", IIC_SprMTSPR>,
2578 PPC970_DGroup_First, PPC970_Unit_FXU;
2580 let Uses = [LR] in {
2581 def MFLR : XFXForm_1_ext<31, 339, 8, (outs gprc:$rT), (ins),
2582 "mflr $rT", IIC_SprMFSPR>,
2583 PPC970_DGroup_First, PPC970_Unit_FXU;
2586 let isCodeGenOnly = 1 in {
2587 // Move to/from VRSAVE: despite being a SPR, the VRSAVE register is renamed
2588 // like a GPR on the PPC970. As such, copies in and out have the same
2589 // performance characteristics as an OR instruction.
2590 def MTVRSAVE : XFXForm_7_ext<31, 467, 256, (outs), (ins gprc:$rS),
2591 "mtspr 256, $rS", IIC_IntGeneral>,
2592 PPC970_DGroup_Single, PPC970_Unit_FXU;
2593 def MFVRSAVE : XFXForm_1_ext<31, 339, 256, (outs gprc:$rT), (ins),
2594 "mfspr $rT, 256", IIC_IntGeneral>,
2595 PPC970_DGroup_First, PPC970_Unit_FXU;
2597 def MTVRSAVEv : XFXForm_7_ext<31, 467, 256,
2598 (outs VRSAVERC:$reg), (ins gprc:$rS),
2599 "mtspr 256, $rS", IIC_IntGeneral>,
2600 PPC970_DGroup_Single, PPC970_Unit_FXU;
2601 def MFVRSAVEv : XFXForm_1_ext<31, 339, 256, (outs gprc:$rT),
2602 (ins VRSAVERC:$reg),
2603 "mfspr $rT, 256", IIC_IntGeneral>,
2604 PPC970_DGroup_First, PPC970_Unit_FXU;
2607 // Aliases for mtvrsave/mfvrsave to mfspr/mtspr.
2608 def : InstAlias<"mtvrsave $rS", (MTVRSAVE gprc:$rS)>;
2609 def : InstAlias<"mfvrsave $rS", (MFVRSAVE gprc:$rS)>;
2611 // SPILL_VRSAVE - Indicate that we're dumping the VRSAVE register,
2612 // so we'll need to scavenge a register for it.
2614 def SPILL_VRSAVE : PPCEmitTimePseudo<(outs), (ins VRSAVERC:$vrsave, memri:$F),
2615 "#SPILL_VRSAVE", []>;
2617 // RESTORE_VRSAVE - Indicate that we're restoring the VRSAVE register (previously
2618 // spilled), so we'll need to scavenge a register for it.
2620 def RESTORE_VRSAVE : PPCEmitTimePseudo<(outs VRSAVERC:$vrsave), (ins memri:$F),
2621 "#RESTORE_VRSAVE", []>;
2623 let hasSideEffects = 0 in {
2624 // mtocrf's input needs to be prepared by shifting by an amount dependent
2625 // on the cr register selected. Thus, post-ra anti-dep breaking must not
2626 // later change that register assignment.
2627 let hasExtraDefRegAllocReq = 1 in {
2628 def MTOCRF: XFXForm_5a<31, 144, (outs crbitm:$FXM), (ins gprc:$ST),
2629 "mtocrf $FXM, $ST", IIC_BrMCRX>,
2630 PPC970_DGroup_First, PPC970_Unit_CRU;
2632 // Similarly to mtocrf, the mask for mtcrf must be prepared in a way that
2633 // is dependent on the cr fields being set.
2634 def MTCRF : XFXForm_5<31, 144, (outs), (ins i32imm:$FXM, gprc:$rS),
2635 "mtcrf $FXM, $rS", IIC_BrMCRX>,
2636 PPC970_MicroCode, PPC970_Unit_CRU;
2637 } // hasExtraDefRegAllocReq = 1
2639 // mfocrf's input needs to be prepared by shifting by an amount dependent
2640 // on the cr register selected. Thus, post-ra anti-dep breaking must not
2641 // later change that register assignment.
2642 let hasExtraSrcRegAllocReq = 1 in {
2643 def MFOCRF: XFXForm_5a<31, 19, (outs gprc:$rT), (ins crbitm:$FXM),
2644 "mfocrf $rT, $FXM", IIC_SprMFCRF>,
2645 PPC970_DGroup_First, PPC970_Unit_CRU;
2647 // Similarly to mfocrf, the mask for mfcrf must be prepared in a way that
2648 // is dependent on the cr fields being copied.
2649 def MFCR : XFXForm_3<31, 19, (outs gprc:$rT), (ins),
2650 "mfcr $rT", IIC_SprMFCR>,
2651 PPC970_MicroCode, PPC970_Unit_CRU;
2652 } // hasExtraSrcRegAllocReq = 1
2654 def MCRXRX : X_BF3<31, 576, (outs crrc:$BF), (ins),
2655 "mcrxrx $BF", IIC_BrMCRX>, Requires<[IsISA3_0]>;
2656 } // hasSideEffects = 0
2658 let Predicates = [HasFPU] in {
2659 // Custom inserter instruction to perform FADD in round-to-zero mode.
2660 let Uses = [RM] in {
2661 def FADDrtz: PPCCustomInserterPseudo<(outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB), "",
2662 [(set f64:$FRT, (PPCfaddrtz f64:$FRA, f64:$FRB))]>;
2665 // The above pseudo gets expanded to make use of the following instructions
2666 // to manipulate FPSCR. Note that FPSCR is not modeled at the DAG level.
2667 let Uses = [RM], Defs = [RM] in {
2668 def MTFSB0 : XForm_43<63, 70, (outs), (ins u5imm:$FM),
2669 "mtfsb0 $FM", IIC_IntMTFSB0, []>,
2670 PPC970_DGroup_Single, PPC970_Unit_FPU;
2671 def MTFSB1 : XForm_43<63, 38, (outs), (ins u5imm:$FM),
2672 "mtfsb1 $FM", IIC_IntMTFSB0, []>,
2673 PPC970_DGroup_Single, PPC970_Unit_FPU;
2674 let isCodeGenOnly = 1 in
2675 def MTFSFb : XFLForm<63, 711, (outs), (ins i32imm:$FM, f8rc:$rT),
2676 "mtfsf $FM, $rT", IIC_IntMTFSB0, []>,
2677 PPC970_DGroup_Single, PPC970_Unit_FPU;
2679 let Uses = [RM] in {
2680 def MFFS : XForm_42<63, 583, (outs f8rc:$rT), (ins),
2681 "mffs $rT", IIC_IntMFFS,
2682 [(set f64:$rT, (PPCmffs))]>,
2683 PPC970_DGroup_Single, PPC970_Unit_FPU;
2686 def MFFSo : XForm_42<63, 583, (outs f8rc:$rT), (ins),
2687 "mffs. $rT", IIC_IntMFFS, []>, isDOT;
2689 def MFFSCE : X_FRT5_XO2_XO3_XO10<63, 0, 1, 583, (outs f8rc:$rT), (ins),
2690 "mffsce $rT", IIC_IntMFFS, []>,
2691 PPC970_DGroup_Single, PPC970_Unit_FPU;
2693 def MFFSCDRN : X_FRT5_XO2_XO3_FRB5_XO10<63, 2, 4, 583, (outs f8rc:$rT),
2694 (ins f8rc:$FRB), "mffscdrn $rT, $FRB",
2696 PPC970_DGroup_Single, PPC970_Unit_FPU;
2698 def MFFSCDRNI : X_FRT5_XO2_XO3_DRM3_XO10<63, 2, 5, 583, (outs f8rc:$rT),
2700 "mffscdrni $rT, $DRM",
2702 PPC970_DGroup_Single, PPC970_Unit_FPU;
2704 def MFFSCRN : X_FRT5_XO2_XO3_FRB5_XO10<63, 2, 6, 583, (outs f8rc:$rT),
2705 (ins f8rc:$FRB), "mffscrn $rT, $FRB",
2707 PPC970_DGroup_Single, PPC970_Unit_FPU;
2709 def MFFSCRNI : X_FRT5_XO2_XO3_RM2_X10<63, 2, 7, 583, (outs f8rc:$rT),
2710 (ins u2imm:$RM), "mffscrni $rT, $RM",
2712 PPC970_DGroup_Single, PPC970_Unit_FPU;
2714 def MFFSL : X_FRT5_XO2_XO3_XO10<63, 3, 0, 583, (outs f8rc:$rT), (ins),
2715 "mffsl $rT", IIC_IntMFFS, []>,
2716 PPC970_DGroup_Single, PPC970_Unit_FPU;
2720 let Predicates = [IsISA3_0] in {
2721 def MODSW : XForm_8<31, 779, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2722 "modsw $rT, $rA, $rB", IIC_IntDivW,
2723 [(set i32:$rT, (srem i32:$rA, i32:$rB))]>;
2724 def MODUW : XForm_8<31, 267, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2725 "moduw $rT, $rA, $rB", IIC_IntDivW,
2726 [(set i32:$rT, (urem i32:$rA, i32:$rB))]>;
2729 let PPC970_Unit = 1, hasSideEffects = 0 in { // FXU Operations.
2730 // XO-Form instructions. Arithmetic instructions that can set overflow bit
2731 let isCommutable = 1 in
2732 defm ADD4 : XOForm_1r<31, 266, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2733 "add", "$rT, $rA, $rB", IIC_IntSimple,
2734 [(set i32:$rT, (add i32:$rA, i32:$rB))]>;
2735 let isCodeGenOnly = 1 in
2736 def ADD4TLS : XOForm_1<31, 266, 0, (outs gprc:$rT), (ins gprc:$rA, tlsreg32:$rB),
2737 "add $rT, $rA, $rB", IIC_IntSimple,
2738 [(set i32:$rT, (add i32:$rA, tglobaltlsaddr:$rB))]>;
2739 let isCommutable = 1 in
2740 defm ADDC : XOForm_1rc<31, 10, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2741 "addc", "$rT, $rA, $rB", IIC_IntGeneral,
2742 [(set i32:$rT, (addc i32:$rA, i32:$rB))]>,
2743 PPC970_DGroup_Cracked;
2745 defm DIVW : XOForm_1rcr<31, 491, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2746 "divw", "$rT, $rA, $rB", IIC_IntDivW,
2747 [(set i32:$rT, (sdiv i32:$rA, i32:$rB))]>;
2748 defm DIVWU : XOForm_1rcr<31, 459, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2749 "divwu", "$rT, $rA, $rB", IIC_IntDivW,
2750 [(set i32:$rT, (udiv i32:$rA, i32:$rB))]>;
2751 def DIVWE : XOForm_1<31, 427, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2752 "divwe $rT, $rA, $rB", IIC_IntDivW,
2753 [(set i32:$rT, (int_ppc_divwe gprc:$rA, gprc:$rB))]>,
2754 Requires<[HasExtDiv]>;
2756 def DIVWEo : XOForm_1<31, 427, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2757 "divwe. $rT, $rA, $rB", IIC_IntDivW,
2758 []>, isDOT, PPC970_DGroup_Cracked, PPC970_DGroup_First,
2759 Requires<[HasExtDiv]>;
2760 def DIVWEU : XOForm_1<31, 395, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2761 "divweu $rT, $rA, $rB", IIC_IntDivW,
2762 [(set i32:$rT, (int_ppc_divweu gprc:$rA, gprc:$rB))]>,
2763 Requires<[HasExtDiv]>;
2765 def DIVWEUo : XOForm_1<31, 395, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2766 "divweu. $rT, $rA, $rB", IIC_IntDivW,
2767 []>, isDOT, PPC970_DGroup_Cracked, PPC970_DGroup_First,
2768 Requires<[HasExtDiv]>;
2769 let isCommutable = 1 in {
2770 defm MULHW : XOForm_1r<31, 75, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2771 "mulhw", "$rT, $rA, $rB", IIC_IntMulHW,
2772 [(set i32:$rT, (mulhs i32:$rA, i32:$rB))]>;
2773 defm MULHWU : XOForm_1r<31, 11, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2774 "mulhwu", "$rT, $rA, $rB", IIC_IntMulHWU,
2775 [(set i32:$rT, (mulhu i32:$rA, i32:$rB))]>;
2776 defm MULLW : XOForm_1r<31, 235, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2777 "mullw", "$rT, $rA, $rB", IIC_IntMulHW,
2778 [(set i32:$rT, (mul i32:$rA, i32:$rB))]>;
2780 defm SUBF : XOForm_1r<31, 40, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2781 "subf", "$rT, $rA, $rB", IIC_IntGeneral,
2782 [(set i32:$rT, (sub i32:$rB, i32:$rA))]>;
2783 defm SUBFC : XOForm_1rc<31, 8, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2784 "subfc", "$rT, $rA, $rB", IIC_IntGeneral,
2785 [(set i32:$rT, (subc i32:$rB, i32:$rA))]>,
2786 PPC970_DGroup_Cracked;
2787 defm NEG : XOForm_3r<31, 104, 0, (outs gprc:$rT), (ins gprc:$rA),
2788 "neg", "$rT, $rA", IIC_IntSimple,
2789 [(set i32:$rT, (ineg i32:$rA))]>;
2790 let Uses = [CARRY] in {
2791 let isCommutable = 1 in
2792 defm ADDE : XOForm_1rc<31, 138, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2793 "adde", "$rT, $rA, $rB", IIC_IntGeneral,
2794 [(set i32:$rT, (adde i32:$rA, i32:$rB))]>;
2795 defm ADDME : XOForm_3rc<31, 234, 0, (outs gprc:$rT), (ins gprc:$rA),
2796 "addme", "$rT, $rA", IIC_IntGeneral,
2797 [(set i32:$rT, (adde i32:$rA, -1))]>;
2798 defm ADDZE : XOForm_3rc<31, 202, 0, (outs gprc:$rT), (ins gprc:$rA),
2799 "addze", "$rT, $rA", IIC_IntGeneral,
2800 [(set i32:$rT, (adde i32:$rA, 0))]>;
2801 defm SUBFE : XOForm_1rc<31, 136, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2802 "subfe", "$rT, $rA, $rB", IIC_IntGeneral,
2803 [(set i32:$rT, (sube i32:$rB, i32:$rA))]>;
2804 defm SUBFME : XOForm_3rc<31, 232, 0, (outs gprc:$rT), (ins gprc:$rA),
2805 "subfme", "$rT, $rA", IIC_IntGeneral,
2806 [(set i32:$rT, (sube -1, i32:$rA))]>;
2807 defm SUBFZE : XOForm_3rc<31, 200, 0, (outs gprc:$rT), (ins gprc:$rA),
2808 "subfze", "$rT, $rA", IIC_IntGeneral,
2809 [(set i32:$rT, (sube 0, i32:$rA))]>;
2813 // A-Form instructions. Most of the instructions executed in the FPU are of
2816 let PPC970_Unit = 3, hasSideEffects = 0, Predicates = [HasFPU] in { // FPU Operations.
2817 let Uses = [RM] in {
2818 let isCommutable = 1 in {
2819 defm FMADD : AForm_1r<63, 29,
2820 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2821 "fmadd", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2822 [(set f64:$FRT, (fma f64:$FRA, f64:$FRC, f64:$FRB))]>;
2823 defm FMADDS : AForm_1r<59, 29,
2824 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2825 "fmadds", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2826 [(set f32:$FRT, (fma f32:$FRA, f32:$FRC, f32:$FRB))]>;
2827 defm FMSUB : AForm_1r<63, 28,
2828 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2829 "fmsub", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2831 (fma f64:$FRA, f64:$FRC, (fneg f64:$FRB)))]>;
2832 defm FMSUBS : AForm_1r<59, 28,
2833 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2834 "fmsubs", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2836 (fma f32:$FRA, f32:$FRC, (fneg f32:$FRB)))]>;
2837 defm FNMADD : AForm_1r<63, 31,
2838 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2839 "fnmadd", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2841 (fneg (fma f64:$FRA, f64:$FRC, f64:$FRB)))]>;
2842 defm FNMADDS : AForm_1r<59, 31,
2843 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2844 "fnmadds", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2846 (fneg (fma f32:$FRA, f32:$FRC, f32:$FRB)))]>;
2847 defm FNMSUB : AForm_1r<63, 30,
2848 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2849 "fnmsub", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2850 [(set f64:$FRT, (fneg (fma f64:$FRA, f64:$FRC,
2851 (fneg f64:$FRB))))]>;
2852 defm FNMSUBS : AForm_1r<59, 30,
2853 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2854 "fnmsubs", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2855 [(set f32:$FRT, (fneg (fma f32:$FRA, f32:$FRC,
2856 (fneg f32:$FRB))))]>;
2859 // FSEL is artificially split into 4 and 8-byte forms for the result. To avoid
2860 // having 4 of these, force the comparison to always be an 8-byte double (code
2861 // should use an FMRSD if the input comparison value really wants to be a float)
2862 // and 4/8 byte forms for the result and operand type..
2863 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2864 defm FSELD : AForm_1r<63, 23,
2865 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2866 "fsel", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2867 [(set f64:$FRT, (PPCfsel f64:$FRA, f64:$FRC, f64:$FRB))]>;
2868 defm FSELS : AForm_1r<63, 23,
2869 (outs f4rc:$FRT), (ins f8rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2870 "fsel", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2871 [(set f32:$FRT, (PPCfsel f64:$FRA, f32:$FRC, f32:$FRB))]>;
2872 let Uses = [RM] in {
2873 let isCommutable = 1 in {
2874 defm FADD : AForm_2r<63, 21,
2875 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB),
2876 "fadd", "$FRT, $FRA, $FRB", IIC_FPAddSub,
2877 [(set f64:$FRT, (fadd f64:$FRA, f64:$FRB))]>;
2878 defm FADDS : AForm_2r<59, 21,
2879 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB),
2880 "fadds", "$FRT, $FRA, $FRB", IIC_FPGeneral,
2881 [(set f32:$FRT, (fadd f32:$FRA, f32:$FRB))]>;
2883 defm FDIV : AForm_2r<63, 18,
2884 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB),
2885 "fdiv", "$FRT, $FRA, $FRB", IIC_FPDivD,
2886 [(set f64:$FRT, (fdiv f64:$FRA, f64:$FRB))]>;
2887 defm FDIVS : AForm_2r<59, 18,
2888 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB),
2889 "fdivs", "$FRT, $FRA, $FRB", IIC_FPDivS,
2890 [(set f32:$FRT, (fdiv f32:$FRA, f32:$FRB))]>;
2891 let isCommutable = 1 in {
2892 defm FMUL : AForm_3r<63, 25,
2893 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC),
2894 "fmul", "$FRT, $FRA, $FRC", IIC_FPFused,
2895 [(set f64:$FRT, (fmul f64:$FRA, f64:$FRC))]>;
2896 defm FMULS : AForm_3r<59, 25,
2897 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC),
2898 "fmuls", "$FRT, $FRA, $FRC", IIC_FPGeneral,
2899 [(set f32:$FRT, (fmul f32:$FRA, f32:$FRC))]>;
2901 defm FSUB : AForm_2r<63, 20,
2902 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB),
2903 "fsub", "$FRT, $FRA, $FRB", IIC_FPAddSub,
2904 [(set f64:$FRT, (fsub f64:$FRA, f64:$FRB))]>;
2905 defm FSUBS : AForm_2r<59, 20,
2906 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB),
2907 "fsubs", "$FRT, $FRA, $FRB", IIC_FPGeneral,
2908 [(set f32:$FRT, (fsub f32:$FRA, f32:$FRB))]>;
2912 let hasSideEffects = 0 in {
2913 let PPC970_Unit = 1 in { // FXU Operations.
2915 def ISEL : AForm_4<31, 15,
2916 (outs gprc:$rT), (ins gprc_nor0:$rA, gprc:$rB, crbitrc:$cond),
2917 "isel $rT, $rA, $rB, $cond", IIC_IntISEL,
2921 let PPC970_Unit = 1 in { // FXU Operations.
2922 // M-Form instructions. rotate and mask instructions.
2924 let isCommutable = 1 in {
2925 // RLWIMI can be commuted if the rotate amount is zero.
2926 defm RLWIMI : MForm_2r<20, (outs gprc:$rA),
2927 (ins gprc:$rSi, gprc:$rS, u5imm:$SH, u5imm:$MB,
2928 u5imm:$ME), "rlwimi", "$rA, $rS, $SH, $MB, $ME",
2929 IIC_IntRotate, []>, PPC970_DGroup_Cracked,
2930 RegConstraint<"$rSi = $rA">, NoEncode<"$rSi">;
2932 let BaseName = "rlwinm" in {
2933 def RLWINM : MForm_2<21,
2934 (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
2935 "rlwinm $rA, $rS, $SH, $MB, $ME", IIC_IntGeneral,
2938 def RLWINMo : MForm_2<21,
2939 (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
2940 "rlwinm. $rA, $rS, $SH, $MB, $ME", IIC_IntGeneral,
2941 []>, isDOT, RecFormRel, PPC970_DGroup_Cracked;
2943 defm RLWNM : MForm_2r<23, (outs gprc:$rA),
2944 (ins gprc:$rS, gprc:$rB, u5imm:$MB, u5imm:$ME),
2945 "rlwnm", "$rA, $rS, $rB, $MB, $ME", IIC_IntGeneral,
2948 } // hasSideEffects = 0
2950 //===----------------------------------------------------------------------===//
2951 // PowerPC Instruction Patterns
2954 // Arbitrary immediate support. Implement in terms of LIS/ORI.
2955 def : Pat<(i32 imm:$imm),
2956 (ORI (LIS (HI16 imm:$imm)), (LO16 imm:$imm))>;
2958 // Implement the 'not' operation with the NOR instruction.
2959 def i32not : OutPatFrag<(ops node:$in),
2961 def : Pat<(not i32:$in),
2964 // ADD an arbitrary immediate.
2965 def : Pat<(add i32:$in, imm:$imm),
2966 (ADDIS (ADDI $in, (LO16 imm:$imm)), (HA16 imm:$imm))>;
2967 // OR an arbitrary immediate.
2968 def : Pat<(or i32:$in, imm:$imm),
2969 (ORIS (ORI $in, (LO16 imm:$imm)), (HI16 imm:$imm))>;
2970 // XOR an arbitrary immediate.
2971 def : Pat<(xor i32:$in, imm:$imm),
2972 (XORIS (XORI $in, (LO16 imm:$imm)), (HI16 imm:$imm))>;
2974 def : Pat<(sub imm32SExt16:$imm, i32:$in),
2975 (SUBFIC $in, imm:$imm)>;
2978 def : Pat<(shl i32:$in, (i32 imm:$imm)),
2979 (RLWINM $in, imm:$imm, 0, (SHL32 imm:$imm))>;
2980 def : Pat<(srl i32:$in, (i32 imm:$imm)),
2981 (RLWINM $in, (SRL32 imm:$imm), imm:$imm, 31)>;
2984 def : Pat<(rotl i32:$in, i32:$sh),
2985 (RLWNM $in, $sh, 0, 31)>;
2986 def : Pat<(rotl i32:$in, (i32 imm:$imm)),
2987 (RLWINM $in, imm:$imm, 0, 31)>;
2990 def : Pat<(and (rotl i32:$in, i32:$sh), maskimm32:$imm),
2991 (RLWNM $in, $sh, (MB maskimm32:$imm), (ME maskimm32:$imm))>;
2994 def : Pat<(PPCcall (i32 tglobaladdr:$dst)),
2995 (BL tglobaladdr:$dst)>;
2996 def : Pat<(PPCcall (i32 texternalsym:$dst)),
2997 (BL texternalsym:$dst)>;
2999 def : Pat<(PPCtc_return (i32 tglobaladdr:$dst), imm:$imm),
3000 (TCRETURNdi tglobaladdr:$dst, imm:$imm)>;
3002 def : Pat<(PPCtc_return (i32 texternalsym:$dst), imm:$imm),
3003 (TCRETURNdi texternalsym:$dst, imm:$imm)>;
3005 def : Pat<(PPCtc_return CTRRC:$dst, imm:$imm),
3006 (TCRETURNri CTRRC:$dst, imm:$imm)>;
3010 // Hi and Lo for Darwin Global Addresses.
3011 def : Pat<(PPChi tglobaladdr:$in, 0), (LIS tglobaladdr:$in)>;
3012 def : Pat<(PPClo tglobaladdr:$in, 0), (LI tglobaladdr:$in)>;
3013 def : Pat<(PPChi tconstpool:$in, 0), (LIS tconstpool:$in)>;
3014 def : Pat<(PPClo tconstpool:$in, 0), (LI tconstpool:$in)>;
3015 def : Pat<(PPChi tjumptable:$in, 0), (LIS tjumptable:$in)>;
3016 def : Pat<(PPClo tjumptable:$in, 0), (LI tjumptable:$in)>;
3017 def : Pat<(PPChi tblockaddress:$in, 0), (LIS tblockaddress:$in)>;
3018 def : Pat<(PPClo tblockaddress:$in, 0), (LI tblockaddress:$in)>;
3019 def : Pat<(PPChi tglobaltlsaddr:$g, i32:$in),
3020 (ADDIS $in, tglobaltlsaddr:$g)>;
3021 def : Pat<(PPClo tglobaltlsaddr:$g, i32:$in),
3022 (ADDI $in, tglobaltlsaddr:$g)>;
3023 def : Pat<(add i32:$in, (PPChi tglobaladdr:$g, 0)),
3024 (ADDIS $in, tglobaladdr:$g)>;
3025 def : Pat<(add i32:$in, (PPChi tconstpool:$g, 0)),
3026 (ADDIS $in, tconstpool:$g)>;
3027 def : Pat<(add i32:$in, (PPChi tjumptable:$g, 0)),
3028 (ADDIS $in, tjumptable:$g)>;
3029 def : Pat<(add i32:$in, (PPChi tblockaddress:$g, 0)),
3030 (ADDIS $in, tblockaddress:$g)>;
3032 // Support for thread-local storage.
3033 def PPC32GOT: PPCEmitTimePseudo<(outs gprc:$rD), (ins), "#PPC32GOT",
3034 [(set i32:$rD, (PPCppc32GOT))]>;
3036 // Get the _GLOBAL_OFFSET_TABLE_ in PIC mode.
3037 // This uses two output registers, the first as the real output, the second as a
3038 // temporary register, used internally in code generation.
3039 def PPC32PICGOT: PPCEmitTimePseudo<(outs gprc:$rD, gprc:$rT), (ins), "#PPC32PICGOT",
3040 []>, NoEncode<"$rT">;
3042 def LDgotTprelL32: PPCEmitTimePseudo<(outs gprc:$rD), (ins s16imm:$disp, gprc_nor0:$reg),
3045 (PPCldGotTprelL tglobaltlsaddr:$disp, i32:$reg))]>;
3046 def : Pat<(PPCaddTls i32:$in, tglobaltlsaddr:$g),
3047 (ADD4TLS $in, tglobaltlsaddr:$g)>;
3049 def ADDItlsgdL32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
3052 (PPCaddiTlsgdL i32:$reg, tglobaltlsaddr:$disp))]>;
3053 // LR is a true define, while the rest of the Defs are clobbers. R3 is
3054 // explicitly defined when this op is created, so not mentioned here.
3055 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
3056 Defs = [R0,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
3057 def GETtlsADDR32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc:$reg, tlsgd32:$sym),
3060 (PPCgetTlsAddr i32:$reg, tglobaltlsaddr:$sym))]>;
3061 // Combined op for ADDItlsgdL32 and GETtlsADDR32, late expanded. R3 and LR
3062 // are true defines while the rest of the Defs are clobbers.
3063 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
3064 Defs = [R0,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
3065 def ADDItlsgdLADDR32 : PPCEmitTimePseudo<(outs gprc:$rD),
3066 (ins gprc_nor0:$reg, s16imm:$disp, tlsgd32:$sym),
3067 "#ADDItlsgdLADDR32",
3069 (PPCaddiTlsgdLAddr i32:$reg,
3070 tglobaltlsaddr:$disp,
3071 tglobaltlsaddr:$sym))]>;
3072 def ADDItlsldL32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
3075 (PPCaddiTlsldL i32:$reg, tglobaltlsaddr:$disp))]>;
3076 // LR is a true define, while the rest of the Defs are clobbers. R3 is
3077 // explicitly defined when this op is created, so not mentioned here.
3078 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
3079 Defs = [R0,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
3080 def GETtlsldADDR32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc:$reg, tlsgd32:$sym),
3083 (PPCgetTlsldAddr i32:$reg,
3084 tglobaltlsaddr:$sym))]>;
3085 // Combined op for ADDItlsldL32 and GETtlsADDR32, late expanded. R3 and LR
3086 // are true defines while the rest of the Defs are clobbers.
3087 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
3088 Defs = [R0,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
3089 def ADDItlsldLADDR32 : PPCEmitTimePseudo<(outs gprc:$rD),
3090 (ins gprc_nor0:$reg, s16imm:$disp, tlsgd32:$sym),
3091 "#ADDItlsldLADDR32",
3093 (PPCaddiTlsldLAddr i32:$reg,
3094 tglobaltlsaddr:$disp,
3095 tglobaltlsaddr:$sym))]>;
3096 def ADDIdtprelL32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
3099 (PPCaddiDtprelL i32:$reg, tglobaltlsaddr:$disp))]>;
3100 def ADDISdtprelHA32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
3103 (PPCaddisDtprelHA i32:$reg,
3104 tglobaltlsaddr:$disp))]>;
3106 // Support for Position-independent code
3107 def LWZtoc : PPCEmitTimePseudo<(outs gprc:$rD), (ins tocentry32:$disp, gprc:$reg),
3110 (PPCtoc_entry tglobaladdr:$disp, i32:$reg))]>;
3111 // Get Global (GOT) Base Register offset, from the word immediately preceding
3112 // the function label.
3113 def UpdateGBR : PPCEmitTimePseudo<(outs gprc:$rD, gprc:$rT), (ins gprc:$rI), "#UpdateGBR", []>;
3116 // Standard shifts. These are represented separately from the real shifts above
3117 // so that we can distinguish between shifts that allow 5-bit and 6-bit shift
3119 def : Pat<(sra i32:$rS, i32:$rB),
3121 def : Pat<(srl i32:$rS, i32:$rB),
3123 def : Pat<(shl i32:$rS, i32:$rB),
3126 def : Pat<(zextloadi1 iaddr:$src),
3128 def : Pat<(zextloadi1 xaddr:$src),
3130 def : Pat<(extloadi1 iaddr:$src),
3132 def : Pat<(extloadi1 xaddr:$src),
3134 def : Pat<(extloadi8 iaddr:$src),
3136 def : Pat<(extloadi8 xaddr:$src),
3138 def : Pat<(extloadi16 iaddr:$src),
3140 def : Pat<(extloadi16 xaddr:$src),
3142 let Predicates = [HasFPU] in {
3143 def : Pat<(f64 (extloadf32 iaddr:$src)),
3144 (COPY_TO_REGCLASS (LFS iaddr:$src), F8RC)>;
3145 def : Pat<(f64 (extloadf32 xaddr:$src)),
3146 (COPY_TO_REGCLASS (LFSX xaddr:$src), F8RC)>;
3148 def : Pat<(f64 (fpextend f32:$src)),
3149 (COPY_TO_REGCLASS $src, F8RC)>;
3152 // Only seq_cst fences require the heavyweight sync (SYNC 0).
3153 // All others can use the lightweight sync (SYNC 1).
3154 // source: http://www.cl.cam.ac.uk/~pes20/cpp/cpp0xmappings.html
3155 // The rule for seq_cst is duplicated to work with both 64 bits and 32 bits
3156 // versions of Power.
3157 def : Pat<(atomic_fence (i64 7), (imm)), (SYNC 0)>, Requires<[HasSYNC]>;
3158 def : Pat<(atomic_fence (i32 7), (imm)), (SYNC 0)>, Requires<[HasSYNC]>;
3159 def : Pat<(atomic_fence (imm), (imm)), (SYNC 1)>, Requires<[HasSYNC]>;
3160 def : Pat<(atomic_fence (imm), (imm)), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
3162 let Predicates = [HasFPU] in {
3163 // Additional FNMSUB patterns: -a*c + b == -(a*c - b)
3164 def : Pat<(fma (fneg f64:$A), f64:$C, f64:$B),
3165 (FNMSUB $A, $C, $B)>;
3166 def : Pat<(fma f64:$A, (fneg f64:$C), f64:$B),
3167 (FNMSUB $A, $C, $B)>;
3168 def : Pat<(fma (fneg f32:$A), f32:$C, f32:$B),
3169 (FNMSUBS $A, $C, $B)>;
3170 def : Pat<(fma f32:$A, (fneg f32:$C), f32:$B),
3171 (FNMSUBS $A, $C, $B)>;
3173 // FCOPYSIGN's operand types need not agree.
3174 def : Pat<(fcopysign f64:$frB, f32:$frA),
3175 (FCPSGND (COPY_TO_REGCLASS $frA, F8RC), $frB)>;
3176 def : Pat<(fcopysign f32:$frB, f64:$frA),
3177 (FCPSGNS (COPY_TO_REGCLASS $frA, F4RC), $frB)>;
3180 include "PPCInstrAltivec.td"
3181 include "PPCInstrSPE.td"
3182 include "PPCInstr64Bit.td"
3183 include "PPCInstrVSX.td"
3184 include "PPCInstrQPX.td"
3185 include "PPCInstrHTM.td"
3187 def crnot : OutPatFrag<(ops node:$in),
3189 def : Pat<(not i1:$in),
3192 // Patterns for arithmetic i1 operations.
3193 def : Pat<(add i1:$a, i1:$b),
3195 def : Pat<(sub i1:$a, i1:$b),
3197 def : Pat<(mul i1:$a, i1:$b),
3200 // We're sometimes asked to materialize i1 -1, which is just 1 in this case
3201 // (-1 is used to mean all bits set).
3202 def : Pat<(i1 -1), (CRSET)>;
3204 // i1 extensions, implemented in terms of isel.
3205 def : Pat<(i32 (zext i1:$in)),
3206 (SELECT_I4 $in, (LI 1), (LI 0))>;
3207 def : Pat<(i32 (sext i1:$in)),
3208 (SELECT_I4 $in, (LI -1), (LI 0))>;
3210 def : Pat<(i64 (zext i1:$in)),
3211 (SELECT_I8 $in, (LI8 1), (LI8 0))>;
3212 def : Pat<(i64 (sext i1:$in)),
3213 (SELECT_I8 $in, (LI8 -1), (LI8 0))>;
3215 // FIXME: We should choose either a zext or a sext based on other constants
3217 def : Pat<(i32 (anyext i1:$in)),
3218 (SELECT_I4 $in, (LI 1), (LI 0))>;
3219 def : Pat<(i64 (anyext i1:$in)),
3220 (SELECT_I8 $in, (LI8 1), (LI8 0))>;
3222 // match setcc on i1 variables.
3240 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETLT)),
3242 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETULT)),
3261 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETLE)),
3263 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETULE)),
3266 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETEQ)),
3280 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETGE)),
3282 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETUGE)),
3296 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETGT)),
3298 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETUGT)),
3301 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETNE)),
3304 // match setcc on non-i1 (non-vector) variables. Note that SETUEQ, SETOGE,
3305 // SETOLE, SETONE, SETULT and SETUGT should be expanded by legalize for
3306 // floating-point types.
3308 multiclass CRNotPat<dag pattern, dag result> {
3309 def : Pat<pattern, (crnot result)>;
3310 def : Pat<(not pattern), result>;
3312 // We can also fold the crnot into an extension:
3313 def : Pat<(i32 (zext pattern)),
3314 (SELECT_I4 result, (LI 0), (LI 1))>;
3315 def : Pat<(i32 (sext pattern)),
3316 (SELECT_I4 result, (LI 0), (LI -1))>;
3318 // We can also fold the crnot into an extension:
3319 def : Pat<(i64 (zext pattern)),
3320 (SELECT_I8 result, (LI8 0), (LI8 1))>;
3321 def : Pat<(i64 (sext pattern)),
3322 (SELECT_I8 result, (LI8 0), (LI8 -1))>;
3324 // FIXME: We should choose either a zext or a sext based on other constants
3326 def : Pat<(i32 (anyext pattern)),
3327 (SELECT_I4 result, (LI 0), (LI 1))>;
3329 def : Pat<(i64 (anyext pattern)),
3330 (SELECT_I8 result, (LI8 0), (LI8 1))>;
3333 // FIXME: Because of what seems like a bug in TableGen's type-inference code,
3334 // we need to write imm:$imm in the output patterns below, not just $imm, or
3335 // else the resulting matcher will not correctly add the immediate operand
3336 // (making it a register operand instead).
3339 multiclass ExtSetCCPat<CondCode cc, PatFrag pfrag,
3340 OutPatFrag rfrag, OutPatFrag rfrag8> {
3341 def : Pat<(i32 (zext (i1 (pfrag i32:$s1, cc)))),
3343 def : Pat<(i64 (zext (i1 (pfrag i64:$s1, cc)))),
3345 def : Pat<(i64 (zext (i1 (pfrag i32:$s1, cc)))),
3346 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1), sub_32)>;
3347 def : Pat<(i32 (zext (i1 (pfrag i64:$s1, cc)))),
3348 (EXTRACT_SUBREG (rfrag8 $s1), sub_32)>;
3350 def : Pat<(i32 (anyext (i1 (pfrag i32:$s1, cc)))),
3352 def : Pat<(i64 (anyext (i1 (pfrag i64:$s1, cc)))),
3354 def : Pat<(i64 (anyext (i1 (pfrag i32:$s1, cc)))),
3355 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1), sub_32)>;
3356 def : Pat<(i32 (anyext (i1 (pfrag i64:$s1, cc)))),
3357 (EXTRACT_SUBREG (rfrag8 $s1), sub_32)>;
3360 // Note that we do all inversions below with i(32|64)not, instead of using
3361 // (xori x, 1) because on the A2 nor has single-cycle latency while xori
3362 // has 2-cycle latency.
3364 defm : ExtSetCCPat<SETEQ,
3365 PatFrag<(ops node:$in, node:$cc),
3366 (setcc $in, 0, $cc)>,
3367 OutPatFrag<(ops node:$in),
3368 (RLWINM (CNTLZW $in), 27, 31, 31)>,
3369 OutPatFrag<(ops node:$in),
3370 (RLDICL (CNTLZD $in), 58, 63)> >;
3372 defm : ExtSetCCPat<SETNE,
3373 PatFrag<(ops node:$in, node:$cc),
3374 (setcc $in, 0, $cc)>,
3375 OutPatFrag<(ops node:$in),
3376 (RLWINM (i32not (CNTLZW $in)), 27, 31, 31)>,
3377 OutPatFrag<(ops node:$in),
3378 (RLDICL (i64not (CNTLZD $in)), 58, 63)> >;
3380 defm : ExtSetCCPat<SETLT,
3381 PatFrag<(ops node:$in, node:$cc),
3382 (setcc $in, 0, $cc)>,
3383 OutPatFrag<(ops node:$in),
3384 (RLWINM $in, 1, 31, 31)>,
3385 OutPatFrag<(ops node:$in),
3386 (RLDICL $in, 1, 63)> >;
3388 defm : ExtSetCCPat<SETGE,
3389 PatFrag<(ops node:$in, node:$cc),
3390 (setcc $in, 0, $cc)>,
3391 OutPatFrag<(ops node:$in),
3392 (RLWINM (i32not $in), 1, 31, 31)>,
3393 OutPatFrag<(ops node:$in),
3394 (RLDICL (i64not $in), 1, 63)> >;
3396 defm : ExtSetCCPat<SETGT,
3397 PatFrag<(ops node:$in, node:$cc),
3398 (setcc $in, 0, $cc)>,
3399 OutPatFrag<(ops node:$in),
3400 (RLWINM (ANDC (NEG $in), $in), 1, 31, 31)>,
3401 OutPatFrag<(ops node:$in),
3402 (RLDICL (ANDC8 (NEG8 $in), $in), 1, 63)> >;
3404 defm : ExtSetCCPat<SETLE,
3405 PatFrag<(ops node:$in, node:$cc),
3406 (setcc $in, 0, $cc)>,
3407 OutPatFrag<(ops node:$in),
3408 (RLWINM (ORC $in, (NEG $in)), 1, 31, 31)>,
3409 OutPatFrag<(ops node:$in),
3410 (RLDICL (ORC8 $in, (NEG8 $in)), 1, 63)> >;
3412 defm : ExtSetCCPat<SETLT,
3413 PatFrag<(ops node:$in, node:$cc),
3414 (setcc $in, -1, $cc)>,
3415 OutPatFrag<(ops node:$in),
3416 (RLWINM (AND $in, (ADDI $in, 1)), 1, 31, 31)>,
3417 OutPatFrag<(ops node:$in),
3418 (RLDICL (AND8 $in, (ADDI8 $in, 1)), 1, 63)> >;
3420 defm : ExtSetCCPat<SETGE,
3421 PatFrag<(ops node:$in, node:$cc),
3422 (setcc $in, -1, $cc)>,
3423 OutPatFrag<(ops node:$in),
3424 (RLWINM (NAND $in, (ADDI $in, 1)), 1, 31, 31)>,
3425 OutPatFrag<(ops node:$in),
3426 (RLDICL (NAND8 $in, (ADDI8 $in, 1)), 1, 63)> >;
3428 defm : ExtSetCCPat<SETGT,
3429 PatFrag<(ops node:$in, node:$cc),
3430 (setcc $in, -1, $cc)>,
3431 OutPatFrag<(ops node:$in),
3432 (RLWINM (i32not $in), 1, 31, 31)>,
3433 OutPatFrag<(ops node:$in),
3434 (RLDICL (i64not $in), 1, 63)> >;
3436 defm : ExtSetCCPat<SETLE,
3437 PatFrag<(ops node:$in, node:$cc),
3438 (setcc $in, -1, $cc)>,
3439 OutPatFrag<(ops node:$in),
3440 (RLWINM $in, 1, 31, 31)>,
3441 OutPatFrag<(ops node:$in),
3442 (RLDICL $in, 1, 63)> >;
3444 // An extended SETCC with shift amount.
3445 multiclass ExtSetCCShiftPat<CondCode cc, PatFrag pfrag,
3446 OutPatFrag rfrag, OutPatFrag rfrag8> {
3447 def : Pat<(i32 (zext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
3449 def : Pat<(i64 (zext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
3451 def : Pat<(i64 (zext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
3452 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1, $sa), sub_32)>;
3453 def : Pat<(i32 (zext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
3454 (EXTRACT_SUBREG (rfrag8 $s1, $sa), sub_32)>;
3456 def : Pat<(i32 (anyext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
3458 def : Pat<(i64 (anyext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
3460 def : Pat<(i64 (anyext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
3461 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1, $sa), sub_32)>;
3462 def : Pat<(i32 (anyext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
3463 (EXTRACT_SUBREG (rfrag8 $s1, $sa), sub_32)>;
3466 defm : ExtSetCCShiftPat<SETNE,
3467 PatFrag<(ops node:$in, node:$sa, node:$cc),
3468 (setcc (and $in, (shl 1, $sa)), 0, $cc)>,
3469 OutPatFrag<(ops node:$in, node:$sa),
3470 (RLWNM $in, (SUBFIC $sa, 32), 31, 31)>,
3471 OutPatFrag<(ops node:$in, node:$sa),
3472 (RLDCL $in, (SUBFIC $sa, 64), 63)> >;
3474 defm : ExtSetCCShiftPat<SETEQ,
3475 PatFrag<(ops node:$in, node:$sa, node:$cc),
3476 (setcc (and $in, (shl 1, $sa)), 0, $cc)>,
3477 OutPatFrag<(ops node:$in, node:$sa),
3478 (RLWNM (i32not $in),
3479 (SUBFIC $sa, 32), 31, 31)>,
3480 OutPatFrag<(ops node:$in, node:$sa),
3481 (RLDCL (i64not $in),
3482 (SUBFIC $sa, 64), 63)> >;
3485 def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETULT)),
3486 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_lt)>;
3487 def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETLT)),
3488 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_lt)>;
3489 def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETUGT)),
3490 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_gt)>;
3491 def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETGT)),
3492 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_gt)>;
3493 def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETEQ)),
3494 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_eq)>;
3495 def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETEQ)),
3496 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_eq)>;
3498 // For non-equality comparisons, the default code would materialize the
3499 // constant, then compare against it, like this:
3501 // ori r2, r2, 22136
3504 // Since we are just comparing for equality, we can emit this instead:
3505 // xoris r0,r3,0x1234
3506 // cmplwi cr0,r0,0x5678
3509 def : Pat<(i1 (setcc i32:$s1, imm:$imm, SETEQ)),
3510 (EXTRACT_SUBREG (CMPLWI (XORIS $s1, (HI16 imm:$imm)),
3511 (LO16 imm:$imm)), sub_eq)>;
3513 defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETUGE)),
3514 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_lt)>;
3515 defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETGE)),
3516 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_lt)>;
3517 defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETULE)),
3518 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_gt)>;
3519 defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETLE)),
3520 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_gt)>;
3521 defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETNE)),
3522 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_eq)>;
3523 defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETNE)),
3524 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_eq)>;
3526 defm : CRNotPat<(i1 (setcc i32:$s1, imm:$imm, SETNE)),
3527 (EXTRACT_SUBREG (CMPLWI (XORIS $s1, (HI16 imm:$imm)),
3528 (LO16 imm:$imm)), sub_eq)>;
3530 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETULT)),
3531 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_lt)>;
3532 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETLT)),
3533 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_lt)>;
3534 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETUGT)),
3535 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_gt)>;
3536 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETGT)),
3537 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_gt)>;
3538 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETEQ)),
3539 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_eq)>;
3541 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETUGE)),
3542 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_lt)>;
3543 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETGE)),
3544 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_lt)>;
3545 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETULE)),
3546 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_gt)>;
3547 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETLE)),
3548 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_gt)>;
3549 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETNE)),
3550 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_eq)>;
3553 def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETULT)),
3554 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_lt)>;
3555 def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETLT)),
3556 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_lt)>;
3557 def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETUGT)),
3558 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_gt)>;
3559 def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETGT)),
3560 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_gt)>;
3561 def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETEQ)),
3562 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_eq)>;
3563 def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETEQ)),
3564 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_eq)>;
3566 // For non-equality comparisons, the default code would materialize the
3567 // constant, then compare against it, like this:
3569 // ori r2, r2, 22136
3572 // Since we are just comparing for equality, we can emit this instead:
3573 // xoris r0,r3,0x1234
3574 // cmpldi cr0,r0,0x5678
3577 def : Pat<(i1 (setcc i64:$s1, imm64ZExt32:$imm, SETEQ)),
3578 (EXTRACT_SUBREG (CMPLDI (XORIS8 $s1, (HI16 imm:$imm)),
3579 (LO16 imm:$imm)), sub_eq)>;
3581 defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETUGE)),
3582 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_lt)>;
3583 defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETGE)),
3584 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_lt)>;
3585 defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETULE)),
3586 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_gt)>;
3587 defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETLE)),
3588 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_gt)>;
3589 defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETNE)),
3590 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_eq)>;
3591 defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETNE)),
3592 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_eq)>;
3594 defm : CRNotPat<(i1 (setcc i64:$s1, imm64ZExt32:$imm, SETNE)),
3595 (EXTRACT_SUBREG (CMPLDI (XORIS8 $s1, (HI16 imm:$imm)),
3596 (LO16 imm:$imm)), sub_eq)>;
3598 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETULT)),
3599 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_lt)>;
3600 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETLT)),
3601 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_lt)>;
3602 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETUGT)),
3603 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_gt)>;
3604 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETGT)),
3605 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_gt)>;
3606 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETEQ)),
3607 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_eq)>;
3609 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETUGE)),
3610 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_lt)>;
3611 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETGE)),
3612 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_lt)>;
3613 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETULE)),
3614 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_gt)>;
3615 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETLE)),
3616 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_gt)>;
3617 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETNE)),
3618 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_eq)>;
3621 let Predicates = [HasFPU] in {
3622 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOLT)),
3623 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3624 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETLT)),
3625 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3626 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOGT)),
3627 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3628 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETGT)),
3629 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3630 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOEQ)),
3631 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3632 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETEQ)),
3633 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3634 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETUO)),
3635 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_un)>;
3637 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETUGE)),
3638 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3639 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETGE)),
3640 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3641 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETULE)),
3642 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3643 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETLE)),
3644 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3645 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETUNE)),
3646 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3647 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETNE)),
3648 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3649 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETO)),
3650 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_un)>;
3653 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOLT)),
3654 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3655 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETLT)),
3656 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3657 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOGT)),
3658 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3659 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETGT)),
3660 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3661 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOEQ)),
3662 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3663 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETEQ)),
3664 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3665 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETUO)),
3666 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_un)>;
3668 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETUGE)),
3669 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3670 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETGE)),
3671 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3672 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETULE)),
3673 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3674 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETLE)),
3675 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3676 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETUNE)),
3677 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3678 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETNE)),
3679 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3680 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETO)),
3681 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_un)>;
3684 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETOLT)),
3685 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_lt)>;
3686 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETLT)),
3687 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_lt)>;
3688 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETOGT)),
3689 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_gt)>;
3690 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETGT)),
3691 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_gt)>;
3692 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETOEQ)),
3693 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_eq)>;
3694 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETEQ)),
3695 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_eq)>;
3696 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETUO)),
3697 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_un)>;
3699 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETUGE)),
3700 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_lt)>;
3701 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETGE)),
3702 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_lt)>;
3703 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETULE)),
3704 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_gt)>;
3705 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETLE)),
3706 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_gt)>;
3707 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETUNE)),
3708 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_eq)>;
3709 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETNE)),
3710 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_eq)>;
3711 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETO)),
3712 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_un)>;
3716 // This must be in this file because it relies on patterns defined in this file
3717 // after the inclusion of the instruction sets.
3718 let Predicates = [HasSPE] in {
3720 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOLT)),
3721 (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>;
3722 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETLT)),
3723 (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>;
3724 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOGT)),
3725 (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>;
3726 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETGT)),
3727 (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>;
3728 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOEQ)),
3729 (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>;
3730 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETEQ)),
3731 (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>;
3733 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETUGE)),
3734 (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>;
3735 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETGE)),
3736 (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>;
3737 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETULE)),
3738 (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>;
3739 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETLE)),
3740 (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>;
3741 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETUNE)),
3742 (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>;
3743 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETNE)),
3744 (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>;
3747 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOLT)),
3748 (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>;
3749 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETLT)),
3750 (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>;
3751 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOGT)),
3752 (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>;
3753 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETGT)),
3754 (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>;
3755 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOEQ)),
3756 (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>;
3757 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETEQ)),
3758 (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>;
3760 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETUGE)),
3761 (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>;
3762 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETGE)),
3763 (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>;
3764 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETULE)),
3765 (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>;
3766 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETLE)),
3767 (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>;
3768 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETUNE)),
3769 (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>;
3770 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETNE)),
3771 (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>;
3773 // match select on i1 variables:
3774 def : Pat<(i1 (select i1:$cond, i1:$tval, i1:$fval)),
3775 (CROR (CRAND $cond , $tval),
3776 (CRAND (crnot $cond), $fval))>;
3778 // match selectcc on i1 variables:
3779 // select (lhs == rhs), tval, fval is:
3780 // ((lhs == rhs) & tval) | (!(lhs == rhs) & fval)
3781 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETLT)),
3782 (CROR (CRAND (CRANDC $lhs, $rhs), $tval),
3783 (CRAND (CRORC $rhs, $lhs), $fval))>;
3784 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETULT)),
3785 (CROR (CRAND (CRANDC $rhs, $lhs), $tval),
3786 (CRAND (CRORC $lhs, $rhs), $fval))>;
3787 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETLE)),
3788 (CROR (CRAND (CRORC $lhs, $rhs), $tval),
3789 (CRAND (CRANDC $rhs, $lhs), $fval))>;
3790 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETULE)),
3791 (CROR (CRAND (CRORC $rhs, $lhs), $tval),
3792 (CRAND (CRANDC $lhs, $rhs), $fval))>;
3793 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETEQ)),
3794 (CROR (CRAND (CREQV $lhs, $rhs), $tval),
3795 (CRAND (CRXOR $lhs, $rhs), $fval))>;
3796 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETGE)),
3797 (CROR (CRAND (CRORC $rhs, $lhs), $tval),
3798 (CRAND (CRANDC $lhs, $rhs), $fval))>;
3799 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETUGE)),
3800 (CROR (CRAND (CRORC $lhs, $rhs), $tval),
3801 (CRAND (CRANDC $rhs, $lhs), $fval))>;
3802 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETGT)),
3803 (CROR (CRAND (CRANDC $rhs, $lhs), $tval),
3804 (CRAND (CRORC $lhs, $rhs), $fval))>;
3805 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETUGT)),
3806 (CROR (CRAND (CRANDC $lhs, $rhs), $tval),
3807 (CRAND (CRORC $rhs, $lhs), $fval))>;
3808 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETNE)),
3809 (CROR (CRAND (CREQV $lhs, $rhs), $fval),
3810 (CRAND (CRXOR $lhs, $rhs), $tval))>;
3812 // match selectcc on i1 variables with non-i1 output.
3813 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETLT)),
3814 (SELECT_I4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3815 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETULT)),
3816 (SELECT_I4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3817 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETLE)),
3818 (SELECT_I4 (CRORC $lhs, $rhs), $tval, $fval)>;
3819 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETULE)),
3820 (SELECT_I4 (CRORC $rhs, $lhs), $tval, $fval)>;
3821 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETEQ)),
3822 (SELECT_I4 (CREQV $lhs, $rhs), $tval, $fval)>;
3823 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETGE)),
3824 (SELECT_I4 (CRORC $rhs, $lhs), $tval, $fval)>;
3825 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETUGE)),
3826 (SELECT_I4 (CRORC $lhs, $rhs), $tval, $fval)>;
3827 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETGT)),
3828 (SELECT_I4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3829 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETUGT)),
3830 (SELECT_I4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3831 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETNE)),
3832 (SELECT_I4 (CRXOR $lhs, $rhs), $tval, $fval)>;
3834 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETLT)),
3835 (SELECT_I8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3836 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETULT)),
3837 (SELECT_I8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3838 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETLE)),
3839 (SELECT_I8 (CRORC $lhs, $rhs), $tval, $fval)>;
3840 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETULE)),
3841 (SELECT_I8 (CRORC $rhs, $lhs), $tval, $fval)>;
3842 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETEQ)),
3843 (SELECT_I8 (CREQV $lhs, $rhs), $tval, $fval)>;
3844 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETGE)),
3845 (SELECT_I8 (CRORC $rhs, $lhs), $tval, $fval)>;
3846 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETUGE)),
3847 (SELECT_I8 (CRORC $lhs, $rhs), $tval, $fval)>;
3848 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETGT)),
3849 (SELECT_I8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3850 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETUGT)),
3851 (SELECT_I8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3852 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETNE)),
3853 (SELECT_I8 (CRXOR $lhs, $rhs), $tval, $fval)>;
3855 let Predicates = [HasFPU] in {
3856 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETLT)),
3857 (SELECT_F4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3858 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETULT)),
3859 (SELECT_F4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3860 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETLE)),
3861 (SELECT_F4 (CRORC $lhs, $rhs), $tval, $fval)>;
3862 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETULE)),
3863 (SELECT_F4 (CRORC $rhs, $lhs), $tval, $fval)>;
3864 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETEQ)),
3865 (SELECT_F4 (CREQV $lhs, $rhs), $tval, $fval)>;
3866 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETGE)),
3867 (SELECT_F4 (CRORC $rhs, $lhs), $tval, $fval)>;
3868 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETUGE)),
3869 (SELECT_F4 (CRORC $lhs, $rhs), $tval, $fval)>;
3870 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETGT)),
3871 (SELECT_F4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3872 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETUGT)),
3873 (SELECT_F4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3874 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETNE)),
3875 (SELECT_F4 (CRXOR $lhs, $rhs), $tval, $fval)>;
3877 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETLT)),
3878 (SELECT_F8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3879 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETULT)),
3880 (SELECT_F8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3881 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETLE)),
3882 (SELECT_F8 (CRORC $lhs, $rhs), $tval, $fval)>;
3883 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETULE)),
3884 (SELECT_F8 (CRORC $rhs, $lhs), $tval, $fval)>;
3885 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETEQ)),
3886 (SELECT_F8 (CREQV $lhs, $rhs), $tval, $fval)>;
3887 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETGE)),
3888 (SELECT_F8 (CRORC $rhs, $lhs), $tval, $fval)>;
3889 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETUGE)),
3890 (SELECT_F8 (CRORC $lhs, $rhs), $tval, $fval)>;
3891 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETGT)),
3892 (SELECT_F8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3893 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETUGT)),
3894 (SELECT_F8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3895 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETNE)),
3896 (SELECT_F8 (CRXOR $lhs, $rhs), $tval, $fval)>;
3899 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETLT)),
3900 (SELECT_F16 (CRANDC $lhs, $rhs), $tval, $fval)>;
3901 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETULT)),
3902 (SELECT_F16 (CRANDC $rhs, $lhs), $tval, $fval)>;
3903 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETLE)),
3904 (SELECT_F16 (CRORC $lhs, $rhs), $tval, $fval)>;
3905 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETULE)),
3906 (SELECT_F16 (CRORC $rhs, $lhs), $tval, $fval)>;
3907 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETEQ)),
3908 (SELECT_F16 (CREQV $lhs, $rhs), $tval, $fval)>;
3909 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETGE)),
3910 (SELECT_F16 (CRORC $rhs, $lhs), $tval, $fval)>;
3911 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETUGE)),
3912 (SELECT_F16 (CRORC $lhs, $rhs), $tval, $fval)>;
3913 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETGT)),
3914 (SELECT_F16 (CRANDC $rhs, $lhs), $tval, $fval)>;
3915 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETUGT)),
3916 (SELECT_F16 (CRANDC $lhs, $rhs), $tval, $fval)>;
3917 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETNE)),
3918 (SELECT_F16 (CRXOR $lhs, $rhs), $tval, $fval)>;
3920 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETLT)),
3921 (SELECT_VRRC (CRANDC $lhs, $rhs), $tval, $fval)>;
3922 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETULT)),
3923 (SELECT_VRRC (CRANDC $rhs, $lhs), $tval, $fval)>;
3924 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETLE)),
3925 (SELECT_VRRC (CRORC $lhs, $rhs), $tval, $fval)>;
3926 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETULE)),
3927 (SELECT_VRRC (CRORC $rhs, $lhs), $tval, $fval)>;
3928 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETEQ)),
3929 (SELECT_VRRC (CREQV $lhs, $rhs), $tval, $fval)>;
3930 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETGE)),
3931 (SELECT_VRRC (CRORC $rhs, $lhs), $tval, $fval)>;
3932 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETUGE)),
3933 (SELECT_VRRC (CRORC $lhs, $rhs), $tval, $fval)>;
3934 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETGT)),
3935 (SELECT_VRRC (CRANDC $rhs, $lhs), $tval, $fval)>;
3936 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETUGT)),
3937 (SELECT_VRRC (CRANDC $lhs, $rhs), $tval, $fval)>;
3938 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETNE)),
3939 (SELECT_VRRC (CRXOR $lhs, $rhs), $tval, $fval)>;
3941 def ANDIo_1_EQ_BIT : PPCCustomInserterPseudo<(outs crbitrc:$dst), (ins gprc:$in),
3943 [(set i1:$dst, (trunc (not i32:$in)))]>;
3944 def ANDIo_1_GT_BIT : PPCCustomInserterPseudo<(outs crbitrc:$dst), (ins gprc:$in),
3946 [(set i1:$dst, (trunc i32:$in))]>;
3948 def ANDIo_1_EQ_BIT8 : PPCCustomInserterPseudo<(outs crbitrc:$dst), (ins g8rc:$in),
3950 [(set i1:$dst, (trunc (not i64:$in)))]>;
3951 def ANDIo_1_GT_BIT8 : PPCCustomInserterPseudo<(outs crbitrc:$dst), (ins g8rc:$in),
3953 [(set i1:$dst, (trunc i64:$in))]>;
3955 def : Pat<(i1 (not (trunc i32:$in))),
3956 (ANDIo_1_EQ_BIT $in)>;
3957 def : Pat<(i1 (not (trunc i64:$in))),
3958 (ANDIo_1_EQ_BIT8 $in)>;
3960 //===----------------------------------------------------------------------===//
3961 // PowerPC Instructions used for assembler/disassembler only
3964 // FIXME: For B=0 or B > 8, the registers following RT are used.
3965 // WARNING: Do not add patterns for this instruction without fixing this.
3966 def LSWI : XForm_base_r3xo_memOp<31, 597, (outs gprc:$RT),
3967 (ins gprc:$A, u5imm:$B),
3968 "lswi $RT, $A, $B", IIC_LdStLoad, []>;
3970 // FIXME: For B=0 or B > 8, the registers following RT are used.
3971 // WARNING: Do not add patterns for this instruction without fixing this.
3972 def STSWI : XForm_base_r3xo_memOp<31, 725, (outs),
3973 (ins gprc:$RT, gprc:$A, u5imm:$B),
3974 "stswi $RT, $A, $B", IIC_LdStLoad, []>;
3976 def ISYNC : XLForm_2_ext<19, 150, 0, 0, 0, (outs), (ins),
3977 "isync", IIC_SprISYNC, []>;
3979 def ICBI : XForm_1a<31, 982, (outs), (ins memrr:$src),
3980 "icbi $src", IIC_LdStICBI, []>;
3982 // We used to have EIEIO as value but E[0-9A-Z] is a reserved name
3983 def EnforceIEIO : XForm_24_eieio<31, 854, (outs), (ins),
3984 "eieio", IIC_LdStLoad, []>;
3986 def WAIT : XForm_24_sync<31, 30, (outs), (ins i32imm:$L),
3987 "wait $L", IIC_LdStLoad, []>;
3989 def MBAR : XForm_mbar<31, 854, (outs), (ins u5imm:$MO),
3990 "mbar $MO", IIC_LdStLoad>, Requires<[IsBookE]>;
3992 def MTSR: XForm_sr<31, 210, (outs), (ins gprc:$RS, u4imm:$SR),
3993 "mtsr $SR, $RS", IIC_SprMTSR>;
3995 def MFSR: XForm_sr<31, 595, (outs gprc:$RS), (ins u4imm:$SR),
3996 "mfsr $RS, $SR", IIC_SprMFSR>;
3998 def MTSRIN: XForm_srin<31, 242, (outs), (ins gprc:$RS, gprc:$RB),
3999 "mtsrin $RS, $RB", IIC_SprMTSR>;
4001 def MFSRIN: XForm_srin<31, 659, (outs gprc:$RS), (ins gprc:$RB),
4002 "mfsrin $RS, $RB", IIC_SprMFSR>;
4004 def MTMSR: XForm_mtmsr<31, 146, (outs), (ins gprc:$RS, i32imm:$L),
4005 "mtmsr $RS, $L", IIC_SprMTMSR>;
4007 def WRTEE: XForm_mtmsr<31, 131, (outs), (ins gprc:$RS),
4008 "wrtee $RS", IIC_SprMTMSR>, Requires<[IsBookE]> {
4012 def WRTEEI: I<31, (outs), (ins i1imm:$E), "wrteei $E", IIC_SprMTMSR>,
4013 Requires<[IsBookE]> {
4017 let Inst{21-30} = 163;
4020 def DCCCI : XForm_tlb<454, (outs), (ins gprc:$A, gprc:$B),
4021 "dccci $A, $B", IIC_LdStLoad>, Requires<[IsPPC4xx]>;
4022 def ICCCI : XForm_tlb<966, (outs), (ins gprc:$A, gprc:$B),
4023 "iccci $A, $B", IIC_LdStLoad>, Requires<[IsPPC4xx]>;
4025 def : InstAlias<"dci 0", (DCCCI R0, R0)>, Requires<[IsPPC4xx]>;
4026 def : InstAlias<"dccci", (DCCCI R0, R0)>, Requires<[IsPPC4xx]>;
4027 def : InstAlias<"ici 0", (ICCCI R0, R0)>, Requires<[IsPPC4xx]>;
4028 def : InstAlias<"iccci", (ICCCI R0, R0)>, Requires<[IsPPC4xx]>;
4030 def MFMSR : XForm_rs<31, 83, (outs gprc:$RT), (ins),
4031 "mfmsr $RT", IIC_SprMFMSR, []>;
4033 def MTMSRD : XForm_mtmsr<31, 178, (outs), (ins gprc:$RS, i32imm:$L),
4034 "mtmsrd $RS, $L", IIC_SprMTMSRD>;
4036 def MCRFS : XLForm_3<63, 64, (outs crrc:$BF), (ins crrc:$BFA),
4037 "mcrfs $BF, $BFA", IIC_BrMCR>;
4039 def MTFSFI : XLForm_4<63, 134, (outs crrc:$BF), (ins i32imm:$U, i32imm:$W),
4040 "mtfsfi $BF, $U, $W", IIC_IntMFFS>;
4042 def MTFSFIo : XLForm_4<63, 134, (outs crrc:$BF), (ins i32imm:$U, i32imm:$W),
4043 "mtfsfi. $BF, $U, $W", IIC_IntMFFS>, isDOT;
4045 def : InstAlias<"mtfsfi $BF, $U", (MTFSFI crrc:$BF, i32imm:$U, 0)>;
4046 def : InstAlias<"mtfsfi. $BF, $U", (MTFSFIo crrc:$BF, i32imm:$U, 0)>;
4048 let Predicates = [HasFPU] in {
4049 def MTFSF : XFLForm_1<63, 711, (outs),
4050 (ins i32imm:$FLM, f8rc:$FRB, i32imm:$L, i32imm:$W),
4051 "mtfsf $FLM, $FRB, $L, $W", IIC_IntMFFS, []>;
4052 def MTFSFo : XFLForm_1<63, 711, (outs),
4053 (ins i32imm:$FLM, f8rc:$FRB, i32imm:$L, i32imm:$W),
4054 "mtfsf. $FLM, $FRB, $L, $W", IIC_IntMFFS, []>, isDOT;
4056 def : InstAlias<"mtfsf $FLM, $FRB", (MTFSF i32imm:$FLM, f8rc:$FRB, 0, 0)>;
4057 def : InstAlias<"mtfsf. $FLM, $FRB", (MTFSFo i32imm:$FLM, f8rc:$FRB, 0, 0)>;
4060 def SLBIE : XForm_16b<31, 434, (outs), (ins gprc:$RB),
4061 "slbie $RB", IIC_SprSLBIE, []>;
4063 def SLBMTE : XForm_26<31, 402, (outs), (ins gprc:$RS, gprc:$RB),
4064 "slbmte $RS, $RB", IIC_SprSLBMTE, []>;
4066 def SLBMFEE : XForm_26<31, 915, (outs gprc:$RT), (ins gprc:$RB),
4067 "slbmfee $RT, $RB", IIC_SprSLBMFEE, []>;
4069 def SLBMFEV : XLForm_1_gen<31, 851, (outs gprc:$RT), (ins gprc:$RB),
4070 "slbmfev $RT, $RB", IIC_SprSLBMFEV, []>;
4072 def SLBIA : XForm_0<31, 498, (outs), (ins), "slbia", IIC_SprSLBIA, []>;
4074 def TLBIA : XForm_0<31, 370, (outs), (ins),
4075 "tlbia", IIC_SprTLBIA, []>;
4077 def TLBSYNC : XForm_0<31, 566, (outs), (ins),
4078 "tlbsync", IIC_SprTLBSYNC, []>;
4080 def TLBIEL : XForm_16b<31, 274, (outs), (ins gprc:$RB),
4081 "tlbiel $RB", IIC_SprTLBIEL, []>;
4083 def TLBLD : XForm_16b<31, 978, (outs), (ins gprc:$RB),
4084 "tlbld $RB", IIC_LdStLoad, []>, Requires<[IsPPC6xx]>;
4085 def TLBLI : XForm_16b<31, 1010, (outs), (ins gprc:$RB),
4086 "tlbli $RB", IIC_LdStLoad, []>, Requires<[IsPPC6xx]>;
4088 def TLBIE : XForm_26<31, 306, (outs), (ins gprc:$RS, gprc:$RB),
4089 "tlbie $RB,$RS", IIC_SprTLBIE, []>;
4091 def TLBSX : XForm_tlb<914, (outs), (ins gprc:$A, gprc:$B), "tlbsx $A, $B",
4092 IIC_LdStLoad>, Requires<[IsBookE]>;
4094 def TLBIVAX : XForm_tlb<786, (outs), (ins gprc:$A, gprc:$B), "tlbivax $A, $B",
4095 IIC_LdStLoad>, Requires<[IsBookE]>;
4097 def TLBRE : XForm_24_eieio<31, 946, (outs), (ins),
4098 "tlbre", IIC_LdStLoad, []>, Requires<[IsBookE]>;
4100 def TLBWE : XForm_24_eieio<31, 978, (outs), (ins),
4101 "tlbwe", IIC_LdStLoad, []>, Requires<[IsBookE]>;
4103 def TLBRE2 : XForm_tlbws<31, 946, (outs gprc:$RS), (ins gprc:$A, i1imm:$WS),
4104 "tlbre $RS, $A, $WS", IIC_LdStLoad, []>, Requires<[IsPPC4xx]>;
4106 def TLBWE2 : XForm_tlbws<31, 978, (outs), (ins gprc:$RS, gprc:$A, i1imm:$WS),
4107 "tlbwe $RS, $A, $WS", IIC_LdStLoad, []>, Requires<[IsPPC4xx]>;
4109 def TLBSX2 : XForm_base_r3xo<31, 914, (outs), (ins gprc:$RST, gprc:$A, gprc:$B),
4110 "tlbsx $RST, $A, $B", IIC_LdStLoad, []>,
4111 Requires<[IsPPC4xx]>;
4112 def TLBSX2D : XForm_base_r3xo<31, 914, (outs),
4113 (ins gprc:$RST, gprc:$A, gprc:$B),
4114 "tlbsx. $RST, $A, $B", IIC_LdStLoad, []>,
4115 Requires<[IsPPC4xx]>, isDOT;
4117 def RFID : XForm_0<19, 18, (outs), (ins), "rfid", IIC_IntRFID, []>;
4119 def RFI : XForm_0<19, 50, (outs), (ins), "rfi", IIC_SprRFI, []>,
4120 Requires<[IsBookE]>;
4121 def RFCI : XForm_0<19, 51, (outs), (ins), "rfci", IIC_BrB, []>,
4122 Requires<[IsBookE]>;
4124 def RFDI : XForm_0<19, 39, (outs), (ins), "rfdi", IIC_BrB, []>,
4126 def RFMCI : XForm_0<19, 38, (outs), (ins), "rfmci", IIC_BrB, []>,
4129 def MFDCR : XFXForm_1<31, 323, (outs gprc:$RT), (ins i32imm:$SPR),
4130 "mfdcr $RT, $SPR", IIC_SprMFSPR>, Requires<[IsPPC4xx]>;
4131 def MTDCR : XFXForm_1<31, 451, (outs), (ins gprc:$RT, i32imm:$SPR),
4132 "mtdcr $SPR, $RT", IIC_SprMTSPR>, Requires<[IsPPC4xx]>;
4134 def HRFID : XLForm_1_np<19, 274, (outs), (ins), "hrfid", IIC_BrB, []>;
4135 def NAP : XLForm_1_np<19, 434, (outs), (ins), "nap", IIC_BrB, []>;
4137 def ATTN : XForm_attn<0, 256, (outs), (ins), "attn", IIC_BrB>;
4139 def LBZCIX : XForm_base_r3xo_memOp<31, 853, (outs gprc:$RST),
4140 (ins gprc:$A, gprc:$B),
4141 "lbzcix $RST, $A, $B", IIC_LdStLoad, []>;
4142 def LHZCIX : XForm_base_r3xo_memOp<31, 821, (outs gprc:$RST),
4143 (ins gprc:$A, gprc:$B),
4144 "lhzcix $RST, $A, $B", IIC_LdStLoad, []>;
4145 def LWZCIX : XForm_base_r3xo_memOp<31, 789, (outs gprc:$RST),
4146 (ins gprc:$A, gprc:$B),
4147 "lwzcix $RST, $A, $B", IIC_LdStLoad, []>;
4148 def LDCIX : XForm_base_r3xo_memOp<31, 885, (outs gprc:$RST),
4149 (ins gprc:$A, gprc:$B),
4150 "ldcix $RST, $A, $B", IIC_LdStLoad, []>;
4152 def STBCIX : XForm_base_r3xo_memOp<31, 981, (outs),
4153 (ins gprc:$RST, gprc:$A, gprc:$B),
4154 "stbcix $RST, $A, $B", IIC_LdStLoad, []>;
4155 def STHCIX : XForm_base_r3xo_memOp<31, 949, (outs),
4156 (ins gprc:$RST, gprc:$A, gprc:$B),
4157 "sthcix $RST, $A, $B", IIC_LdStLoad, []>;
4158 def STWCIX : XForm_base_r3xo_memOp<31, 917, (outs),
4159 (ins gprc:$RST, gprc:$A, gprc:$B),
4160 "stwcix $RST, $A, $B", IIC_LdStLoad, []>;
4161 def STDCIX : XForm_base_r3xo_memOp<31, 1013, (outs),
4162 (ins gprc:$RST, gprc:$A, gprc:$B),
4163 "stdcix $RST, $A, $B", IIC_LdStLoad, []>;
4165 // External PID Load Store Instructions
4167 def LBEPX : XForm_1<31, 95, (outs gprc:$rD), (ins memrr:$src),
4168 "lbepx $rD, $src", IIC_LdStLoad, []>,
4171 def LFDEPX : XForm_25<31, 607, (outs f8rc:$frD), (ins memrr:$src),
4172 "lfdepx $frD, $src", IIC_LdStLFD, []>,
4175 def LHEPX : XForm_1<31, 287, (outs gprc:$rD), (ins memrr:$src),
4176 "lhepx $rD, $src", IIC_LdStLoad, []>,
4179 def LWEPX : XForm_1<31, 31, (outs gprc:$rD), (ins memrr:$src),
4180 "lwepx $rD, $src", IIC_LdStLoad, []>,
4183 def STBEPX : XForm_8<31, 223, (outs), (ins gprc:$rS, memrr:$dst),
4184 "stbepx $rS, $dst", IIC_LdStStore, []>,
4187 def STFDEPX : XForm_28_memOp<31, 735, (outs), (ins f8rc:$frS, memrr:$dst),
4188 "stfdepx $frS, $dst", IIC_LdStSTFD, []>,
4191 def STHEPX : XForm_8<31, 415, (outs), (ins gprc:$rS, memrr:$dst),
4192 "sthepx $rS, $dst", IIC_LdStStore, []>,
4195 def STWEPX : XForm_8<31, 159, (outs), (ins gprc:$rS, memrr:$dst),
4196 "stwepx $rS, $dst", IIC_LdStStore, []>,
4199 def DCBFEP : DCB_Form<127, 0, (outs), (ins memrr:$dst), "dcbfep $dst",
4200 IIC_LdStDCBF, []>, Requires<[IsE500]>;
4202 def DCBSTEP : DCB_Form<63, 0, (outs), (ins memrr:$dst), "dcbstep $dst",
4203 IIC_LdStDCBF, []>, Requires<[IsE500]>;
4205 def DCBTEP : DCB_Form_hint<319, (outs), (ins memrr:$dst, u5imm:$TH),
4206 "dcbtep $TH, $dst", IIC_LdStDCBF, []>,
4209 def DCBTSTEP : DCB_Form_hint<255, (outs), (ins memrr:$dst, u5imm:$TH),
4210 "dcbtstep $TH, $dst", IIC_LdStDCBF, []>,
4213 def DCBZEP : DCB_Form<1023, 0, (outs), (ins memrr:$dst), "dcbzep $dst",
4214 IIC_LdStDCBF, []>, Requires<[IsE500]>;
4216 def DCBZLEP : DCB_Form<1023, 1, (outs), (ins memrr:$dst), "dcbzlep $dst",
4217 IIC_LdStDCBF, []>, Requires<[IsE500]>;
4219 def ICBIEP : XForm_1a<31, 991, (outs), (ins memrr:$src), "icbiep $src",
4220 IIC_LdStICBI, []>, Requires<[IsE500]>;
4222 //===----------------------------------------------------------------------===//
4223 // PowerPC Assembler Instruction Aliases
4226 // Pseudo-instructions for alternate assembly syntax (never used by codegen).
4227 // These are aliases that require C++ handling to convert to the target
4228 // instruction, while InstAliases can be handled directly by tblgen.
4229 class PPCAsmPseudo<string asm, dag iops>
4231 let Namespace = "PPC";
4232 bit PPC64 = 0; // Default value, override with isPPC64
4234 let OutOperandList = (outs);
4235 let InOperandList = iops;
4237 let AsmString = asm;
4238 let isAsmParserOnly = 1;
4240 let hasNoSchedulingInfo = 1;
4243 def : InstAlias<"sc", (SC 0)>;
4245 def : InstAlias<"sync", (SYNC 0)>, Requires<[HasSYNC]>;
4246 def : InstAlias<"msync", (SYNC 0), 0>, Requires<[HasSYNC]>;
4247 def : InstAlias<"lwsync", (SYNC 1)>, Requires<[HasSYNC]>;
4248 def : InstAlias<"ptesync", (SYNC 2)>, Requires<[HasSYNC]>;
4250 def : InstAlias<"wait", (WAIT 0)>;
4251 def : InstAlias<"waitrsv", (WAIT 1)>;
4252 def : InstAlias<"waitimpl", (WAIT 2)>;
4254 def : InstAlias<"mbar", (MBAR 0)>, Requires<[IsBookE]>;
4256 def DCBTx : PPCAsmPseudo<"dcbt $dst", (ins memrr:$dst)>;
4257 def DCBTSTx : PPCAsmPseudo<"dcbtst $dst", (ins memrr:$dst)>;
4259 def DCBTCT : PPCAsmPseudo<"dcbtct $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
4260 def DCBTDS : PPCAsmPseudo<"dcbtds $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
4261 def DCBTT : PPCAsmPseudo<"dcbtt $dst", (ins memrr:$dst)>;
4263 def DCBTSTCT : PPCAsmPseudo<"dcbtstct $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
4264 def DCBTSTDS : PPCAsmPseudo<"dcbtstds $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
4265 def DCBTSTT : PPCAsmPseudo<"dcbtstt $dst", (ins memrr:$dst)>;
4267 def DCBFx : PPCAsmPseudo<"dcbf $dst", (ins memrr:$dst)>;
4268 def DCBFL : PPCAsmPseudo<"dcbfl $dst", (ins memrr:$dst)>;
4269 def DCBFLP : PPCAsmPseudo<"dcbflp $dst", (ins memrr:$dst)>;
4271 def : InstAlias<"crset $bx", (CREQV crbitrc:$bx, crbitrc:$bx, crbitrc:$bx)>;
4272 def : InstAlias<"crclr $bx", (CRXOR crbitrc:$bx, crbitrc:$bx, crbitrc:$bx)>;
4273 def : InstAlias<"crmove $bx, $by", (CROR crbitrc:$bx, crbitrc:$by, crbitrc:$by)>;
4274 def : InstAlias<"crnot $bx, $by", (CRNOR crbitrc:$bx, crbitrc:$by, crbitrc:$by)>;
4276 def : InstAlias<"mtxer $Rx", (MTSPR 1, gprc:$Rx)>;
4277 def : InstAlias<"mfxer $Rx", (MFSPR gprc:$Rx, 1)>;
4279 def : InstAlias<"mfrtcu $Rx", (MFSPR gprc:$Rx, 4)>;
4280 def : InstAlias<"mfrtcl $Rx", (MFSPR gprc:$Rx, 5)>;
4282 def : InstAlias<"mtdscr $Rx", (MTSPR 17, gprc:$Rx)>;
4283 def : InstAlias<"mfdscr $Rx", (MFSPR gprc:$Rx, 17)>;
4285 def : InstAlias<"mtdsisr $Rx", (MTSPR 18, gprc:$Rx)>;
4286 def : InstAlias<"mfdsisr $Rx", (MFSPR gprc:$Rx, 18)>;
4288 def : InstAlias<"mtdar $Rx", (MTSPR 19, gprc:$Rx)>;
4289 def : InstAlias<"mfdar $Rx", (MFSPR gprc:$Rx, 19)>;
4291 def : InstAlias<"mtdec $Rx", (MTSPR 22, gprc:$Rx)>;
4292 def : InstAlias<"mfdec $Rx", (MFSPR gprc:$Rx, 22)>;
4294 def : InstAlias<"mtsdr1 $Rx", (MTSPR 25, gprc:$Rx)>;
4295 def : InstAlias<"mfsdr1 $Rx", (MFSPR gprc:$Rx, 25)>;
4297 def : InstAlias<"mtsrr0 $Rx", (MTSPR 26, gprc:$Rx)>;
4298 def : InstAlias<"mfsrr0 $Rx", (MFSPR gprc:$Rx, 26)>;
4300 def : InstAlias<"mtsrr1 $Rx", (MTSPR 27, gprc:$Rx)>;
4301 def : InstAlias<"mfsrr1 $Rx", (MFSPR gprc:$Rx, 27)>;
4303 def : InstAlias<"mtsrr2 $Rx", (MTSPR 990, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4304 def : InstAlias<"mfsrr2 $Rx", (MFSPR gprc:$Rx, 990)>, Requires<[IsPPC4xx]>;
4306 def : InstAlias<"mtsrr3 $Rx", (MTSPR 991, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4307 def : InstAlias<"mfsrr3 $Rx", (MFSPR gprc:$Rx, 991)>, Requires<[IsPPC4xx]>;
4309 def : InstAlias<"mtcfar $Rx", (MTSPR 28, gprc:$Rx)>;
4310 def : InstAlias<"mfcfar $Rx", (MFSPR gprc:$Rx, 28)>;
4312 def : InstAlias<"mtamr $Rx", (MTSPR 29, gprc:$Rx)>;
4313 def : InstAlias<"mfamr $Rx", (MFSPR gprc:$Rx, 29)>;
4315 def : InstAlias<"mtpid $Rx", (MTSPR 48, gprc:$Rx)>, Requires<[IsBookE]>;
4316 def : InstAlias<"mfpid $Rx", (MFSPR gprc:$Rx, 48)>, Requires<[IsBookE]>;
4318 def : InstAlias<"mftb $Rx", (MFTB gprc:$Rx, 268)>;
4319 def : InstAlias<"mftbl $Rx", (MFTB gprc:$Rx, 268)>;
4320 def : InstAlias<"mftbu $Rx", (MFTB gprc:$Rx, 269)>;
4322 def : InstAlias<"mttbl $Rx", (MTSPR 284, gprc:$Rx)>;
4323 def : InstAlias<"mttbu $Rx", (MTSPR 285, gprc:$Rx)>;
4325 def : InstAlias<"mftblo $Rx", (MFSPR gprc:$Rx, 989)>, Requires<[IsPPC4xx]>;
4326 def : InstAlias<"mttblo $Rx", (MTSPR 989, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4327 def : InstAlias<"mftbhi $Rx", (MFSPR gprc:$Rx, 988)>, Requires<[IsPPC4xx]>;
4328 def : InstAlias<"mttbhi $Rx", (MTSPR 988, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4330 def : InstAlias<"xnop", (XORI R0, R0, 0)>;
4332 def : InstAlias<"mr $rA, $rB", (OR8 g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
4333 def : InstAlias<"mr. $rA, $rB", (OR8o g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
4335 def : InstAlias<"not $rA, $rB", (NOR8 g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
4336 def : InstAlias<"not. $rA, $rB", (NOR8o g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
4338 def : InstAlias<"mtcr $rA", (MTCRF8 255, g8rc:$rA)>;
4340 foreach BATR = 0-3 in {
4341 def : InstAlias<"mtdbatu "#BATR#", $Rx",
4342 (MTSPR !add(BATR, !add(BATR, 536)), gprc:$Rx)>,
4343 Requires<[IsPPC6xx]>;
4344 def : InstAlias<"mfdbatu $Rx, "#BATR,
4345 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 536)))>,
4346 Requires<[IsPPC6xx]>;
4347 def : InstAlias<"mtdbatl "#BATR#", $Rx",
4348 (MTSPR !add(BATR, !add(BATR, 537)), gprc:$Rx)>,
4349 Requires<[IsPPC6xx]>;
4350 def : InstAlias<"mfdbatl $Rx, "#BATR,
4351 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 537)))>,
4352 Requires<[IsPPC6xx]>;
4353 def : InstAlias<"mtibatu "#BATR#", $Rx",
4354 (MTSPR !add(BATR, !add(BATR, 528)), gprc:$Rx)>,
4355 Requires<[IsPPC6xx]>;
4356 def : InstAlias<"mfibatu $Rx, "#BATR,
4357 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 528)))>,
4358 Requires<[IsPPC6xx]>;
4359 def : InstAlias<"mtibatl "#BATR#", $Rx",
4360 (MTSPR !add(BATR, !add(BATR, 529)), gprc:$Rx)>,
4361 Requires<[IsPPC6xx]>;
4362 def : InstAlias<"mfibatl $Rx, "#BATR,
4363 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 529)))>,
4364 Requires<[IsPPC6xx]>;
4367 foreach BR = 0-7 in {
4368 def : InstAlias<"mfbr"#BR#" $Rx",
4369 (MFDCR gprc:$Rx, !add(BR, 0x80))>,
4370 Requires<[IsPPC4xx]>;
4371 def : InstAlias<"mtbr"#BR#" $Rx",
4372 (MTDCR gprc:$Rx, !add(BR, 0x80))>,
4373 Requires<[IsPPC4xx]>;
4376 def : InstAlias<"mtdccr $Rx", (MTSPR 1018, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4377 def : InstAlias<"mfdccr $Rx", (MFSPR gprc:$Rx, 1018)>, Requires<[IsPPC4xx]>;
4379 def : InstAlias<"mticcr $Rx", (MTSPR 1019, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4380 def : InstAlias<"mficcr $Rx", (MFSPR gprc:$Rx, 1019)>, Requires<[IsPPC4xx]>;
4382 def : InstAlias<"mtdear $Rx", (MTSPR 981, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4383 def : InstAlias<"mfdear $Rx", (MFSPR gprc:$Rx, 981)>, Requires<[IsPPC4xx]>;
4385 def : InstAlias<"mtesr $Rx", (MTSPR 980, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4386 def : InstAlias<"mfesr $Rx", (MFSPR gprc:$Rx, 980)>, Requires<[IsPPC4xx]>;
4388 def : InstAlias<"mfspefscr $Rx", (MFSPR gprc:$Rx, 512)>;
4389 def : InstAlias<"mtspefscr $Rx", (MTSPR 512, gprc:$Rx)>;
4391 def : InstAlias<"mttcr $Rx", (MTSPR 986, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4392 def : InstAlias<"mftcr $Rx", (MFSPR gprc:$Rx, 986)>, Requires<[IsPPC4xx]>;
4394 def LAx : PPCAsmPseudo<"la $rA, $addr", (ins gprc:$rA, memri:$addr)>;
4396 def SUBI : PPCAsmPseudo<"subi $rA, $rB, $imm",
4397 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4398 def SUBIS : PPCAsmPseudo<"subis $rA, $rB, $imm",
4399 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4400 def SUBIC : PPCAsmPseudo<"subic $rA, $rB, $imm",
4401 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4402 def SUBICo : PPCAsmPseudo<"subic. $rA, $rB, $imm",
4403 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4405 def : InstAlias<"sub $rA, $rB, $rC", (SUBF8 g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
4406 def : InstAlias<"sub. $rA, $rB, $rC", (SUBF8o g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
4407 def : InstAlias<"subc $rA, $rB, $rC", (SUBFC8 g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
4408 def : InstAlias<"subc. $rA, $rB, $rC", (SUBFC8o g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
4410 def : InstAlias<"mtmsrd $RS", (MTMSRD gprc:$RS, 0)>;
4411 def : InstAlias<"mtmsr $RS", (MTMSR gprc:$RS, 0)>;
4413 def : InstAlias<"mfasr $RT", (MFSPR gprc:$RT, 280)>;
4414 def : InstAlias<"mtasr $RT", (MTSPR 280, gprc:$RT)>;
4416 foreach SPRG = 0-3 in {
4417 def : InstAlias<"mfsprg $RT, "#SPRG, (MFSPR gprc:$RT, !add(SPRG, 272))>;
4418 def : InstAlias<"mfsprg"#SPRG#" $RT", (MFSPR gprc:$RT, !add(SPRG, 272))>;
4419 def : InstAlias<"mtsprg "#SPRG#", $RT", (MTSPR !add(SPRG, 272), gprc:$RT)>;
4420 def : InstAlias<"mtsprg"#SPRG#" $RT", (MTSPR !add(SPRG, 272), gprc:$RT)>;
4422 foreach SPRG = 4-7 in {
4423 def : InstAlias<"mfsprg $RT, "#SPRG, (MFSPR gprc:$RT, !add(SPRG, 256))>,
4424 Requires<[IsBookE]>;
4425 def : InstAlias<"mfsprg"#SPRG#" $RT", (MFSPR gprc:$RT, !add(SPRG, 256))>,
4426 Requires<[IsBookE]>;
4427 def : InstAlias<"mtsprg "#SPRG#", $RT", (MTSPR !add(SPRG, 256), gprc:$RT)>,
4428 Requires<[IsBookE]>;
4429 def : InstAlias<"mtsprg"#SPRG#" $RT", (MTSPR !add(SPRG, 256), gprc:$RT)>,
4430 Requires<[IsBookE]>;
4433 def : InstAlias<"mtasr $RS", (MTSPR 280, gprc:$RS)>;
4435 def : InstAlias<"mfdec $RT", (MFSPR gprc:$RT, 22)>;
4436 def : InstAlias<"mtdec $RT", (MTSPR 22, gprc:$RT)>;
4438 def : InstAlias<"mfpvr $RT", (MFSPR gprc:$RT, 287)>;
4440 def : InstAlias<"mfsdr1 $RT", (MFSPR gprc:$RT, 25)>;
4441 def : InstAlias<"mtsdr1 $RT", (MTSPR 25, gprc:$RT)>;
4443 def : InstAlias<"mfsrr0 $RT", (MFSPR gprc:$RT, 26)>;
4444 def : InstAlias<"mfsrr1 $RT", (MFSPR gprc:$RT, 27)>;
4445 def : InstAlias<"mtsrr0 $RT", (MTSPR 26, gprc:$RT)>;
4446 def : InstAlias<"mtsrr1 $RT", (MTSPR 27, gprc:$RT)>;
4448 def : InstAlias<"tlbie $RB", (TLBIE R0, gprc:$RB)>;
4450 def : InstAlias<"tlbrehi $RS, $A", (TLBRE2 gprc:$RS, gprc:$A, 0)>,
4451 Requires<[IsPPC4xx]>;
4452 def : InstAlias<"tlbrelo $RS, $A", (TLBRE2 gprc:$RS, gprc:$A, 1)>,
4453 Requires<[IsPPC4xx]>;
4454 def : InstAlias<"tlbwehi $RS, $A", (TLBWE2 gprc:$RS, gprc:$A, 0)>,
4455 Requires<[IsPPC4xx]>;
4456 def : InstAlias<"tlbwelo $RS, $A", (TLBWE2 gprc:$RS, gprc:$A, 1)>,
4457 Requires<[IsPPC4xx]>;
4459 def EXTLWI : PPCAsmPseudo<"extlwi $rA, $rS, $n, $b",
4460 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4461 def EXTLWIo : PPCAsmPseudo<"extlwi. $rA, $rS, $n, $b",
4462 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4463 def EXTRWI : PPCAsmPseudo<"extrwi $rA, $rS, $n, $b",
4464 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4465 def EXTRWIo : PPCAsmPseudo<"extrwi. $rA, $rS, $n, $b",
4466 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4467 def INSLWI : PPCAsmPseudo<"inslwi $rA, $rS, $n, $b",
4468 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4469 def INSLWIo : PPCAsmPseudo<"inslwi. $rA, $rS, $n, $b",
4470 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4471 def INSRWI : PPCAsmPseudo<"insrwi $rA, $rS, $n, $b",
4472 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4473 def INSRWIo : PPCAsmPseudo<"insrwi. $rA, $rS, $n, $b",
4474 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4475 def ROTRWI : PPCAsmPseudo<"rotrwi $rA, $rS, $n",
4476 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4477 def ROTRWIo : PPCAsmPseudo<"rotrwi. $rA, $rS, $n",
4478 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4479 def SLWI : PPCAsmPseudo<"slwi $rA, $rS, $n",
4480 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4481 def SLWIo : PPCAsmPseudo<"slwi. $rA, $rS, $n",
4482 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4483 def SRWI : PPCAsmPseudo<"srwi $rA, $rS, $n",
4484 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4485 def SRWIo : PPCAsmPseudo<"srwi. $rA, $rS, $n",
4486 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4487 def CLRRWI : PPCAsmPseudo<"clrrwi $rA, $rS, $n",
4488 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4489 def CLRRWIo : PPCAsmPseudo<"clrrwi. $rA, $rS, $n",
4490 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4491 def CLRLSLWI : PPCAsmPseudo<"clrlslwi $rA, $rS, $b, $n",
4492 (ins gprc:$rA, gprc:$rS, u5imm:$b, u5imm:$n)>;
4493 def CLRLSLWIo : PPCAsmPseudo<"clrlslwi. $rA, $rS, $b, $n",
4494 (ins gprc:$rA, gprc:$rS, u5imm:$b, u5imm:$n)>;
4496 def : InstAlias<"rotlwi $rA, $rS, $n", (RLWINM gprc:$rA, gprc:$rS, u5imm:$n, 0, 31)>;
4497 def : InstAlias<"rotlwi. $rA, $rS, $n", (RLWINMo gprc:$rA, gprc:$rS, u5imm:$n, 0, 31)>;
4498 def : InstAlias<"rotlw $rA, $rS, $rB", (RLWNM gprc:$rA, gprc:$rS, gprc:$rB, 0, 31)>;
4499 def : InstAlias<"rotlw. $rA, $rS, $rB", (RLWNMo gprc:$rA, gprc:$rS, gprc:$rB, 0, 31)>;
4500 def : InstAlias<"clrlwi $rA, $rS, $n", (RLWINM gprc:$rA, gprc:$rS, 0, u5imm:$n, 31)>;
4501 def : InstAlias<"clrlwi. $rA, $rS, $n", (RLWINMo gprc:$rA, gprc:$rS, 0, u5imm:$n, 31)>;
4503 def : InstAlias<"cntlzw $rA, $rS", (CNTLZW gprc:$rA, gprc:$rS)>;
4504 def : InstAlias<"cntlzw. $rA, $rS", (CNTLZWo gprc:$rA, gprc:$rS)>;
4505 // The POWER variant
4506 def : MnemonicAlias<"cntlz", "cntlzw">;
4507 def : MnemonicAlias<"cntlz.", "cntlzw.">;
4509 def EXTLDI : PPCAsmPseudo<"extldi $rA, $rS, $n, $b",
4510 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4511 def EXTLDIo : PPCAsmPseudo<"extldi. $rA, $rS, $n, $b",
4512 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4513 def EXTRDI : PPCAsmPseudo<"extrdi $rA, $rS, $n, $b",
4514 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4515 def EXTRDIo : PPCAsmPseudo<"extrdi. $rA, $rS, $n, $b",
4516 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4517 def INSRDI : PPCAsmPseudo<"insrdi $rA, $rS, $n, $b",
4518 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4519 def INSRDIo : PPCAsmPseudo<"insrdi. $rA, $rS, $n, $b",
4520 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4521 def ROTRDI : PPCAsmPseudo<"rotrdi $rA, $rS, $n",
4522 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4523 def ROTRDIo : PPCAsmPseudo<"rotrdi. $rA, $rS, $n",
4524 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4525 def SLDI : PPCAsmPseudo<"sldi $rA, $rS, $n",
4526 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4527 def SLDIo : PPCAsmPseudo<"sldi. $rA, $rS, $n",
4528 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4529 def SRDI : PPCAsmPseudo<"srdi $rA, $rS, $n",
4530 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4531 def SRDIo : PPCAsmPseudo<"srdi. $rA, $rS, $n",
4532 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4533 def CLRRDI : PPCAsmPseudo<"clrrdi $rA, $rS, $n",
4534 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4535 def CLRRDIo : PPCAsmPseudo<"clrrdi. $rA, $rS, $n",
4536 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4537 def CLRLSLDI : PPCAsmPseudo<"clrlsldi $rA, $rS, $b, $n",
4538 (ins g8rc:$rA, g8rc:$rS, u6imm:$b, u6imm:$n)>;
4539 def CLRLSLDIo : PPCAsmPseudo<"clrlsldi. $rA, $rS, $b, $n",
4540 (ins g8rc:$rA, g8rc:$rS, u6imm:$b, u6imm:$n)>;
4541 def SUBPCIS : PPCAsmPseudo<"subpcis $RT, $D", (ins g8rc:$RT, s16imm:$D)>;
4543 def : InstAlias<"rotldi $rA, $rS, $n", (RLDICL g8rc:$rA, g8rc:$rS, u6imm:$n, 0)>;
4544 def : InstAlias<"rotldi. $rA, $rS, $n", (RLDICLo g8rc:$rA, g8rc:$rS, u6imm:$n, 0)>;
4545 def : InstAlias<"rotld $rA, $rS, $rB", (RLDCL g8rc:$rA, g8rc:$rS, gprc:$rB, 0)>;
4546 def : InstAlias<"rotld. $rA, $rS, $rB", (RLDCLo g8rc:$rA, g8rc:$rS, gprc:$rB, 0)>;
4547 def : InstAlias<"clrldi $rA, $rS, $n", (RLDICL g8rc:$rA, g8rc:$rS, 0, u6imm:$n)>;
4548 def : InstAlias<"clrldi $rA, $rS, $n",
4549 (RLDICL_32_64 g8rc:$rA, gprc:$rS, 0, u6imm:$n)>;
4550 def : InstAlias<"clrldi. $rA, $rS, $n", (RLDICLo g8rc:$rA, g8rc:$rS, 0, u6imm:$n)>;
4551 def : InstAlias<"lnia $RT", (ADDPCIS g8rc:$RT, 0)>;
4553 def RLWINMbm : PPCAsmPseudo<"rlwinm $rA, $rS, $n, $b",
4554 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4555 def RLWINMobm : PPCAsmPseudo<"rlwinm. $rA, $rS, $n, $b",
4556 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4557 def RLWIMIbm : PPCAsmPseudo<"rlwimi $rA, $rS, $n, $b",
4558 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4559 def RLWIMIobm : PPCAsmPseudo<"rlwimi. $rA, $rS, $n, $b",
4560 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4561 def RLWNMbm : PPCAsmPseudo<"rlwnm $rA, $rS, $n, $b",
4562 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4563 def RLWNMobm : PPCAsmPseudo<"rlwnm. $rA, $rS, $n, $b",
4564 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4566 // These generic branch instruction forms are used for the assembler parser only.
4567 // Defs and Uses are conservative, since we don't know the BO value.
4568 let PPC970_Unit = 7, isBranch = 1 in {
4569 let Defs = [CTR], Uses = [CTR, RM] in {
4570 def gBC : BForm_3<16, 0, 0, (outs),
4571 (ins u5imm:$bo, crbitrc:$bi, condbrtarget:$dst),
4572 "bc $bo, $bi, $dst">;
4573 def gBCA : BForm_3<16, 1, 0, (outs),
4574 (ins u5imm:$bo, crbitrc:$bi, abscondbrtarget:$dst),
4575 "bca $bo, $bi, $dst">;
4576 let isAsmParserOnly = 1 in {
4577 def gBCat : BForm_3_at<16, 0, 0, (outs),
4578 (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
4580 "bc$at $bo, $bi, $dst">;
4581 def gBCAat : BForm_3_at<16, 1, 0, (outs),
4582 (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
4583 abscondbrtarget:$dst),
4584 "bca$at $bo, $bi, $dst">;
4585 } // isAsmParserOnly = 1
4587 let Defs = [LR, CTR], Uses = [CTR, RM] in {
4588 def gBCL : BForm_3<16, 0, 1, (outs),
4589 (ins u5imm:$bo, crbitrc:$bi, condbrtarget:$dst),
4590 "bcl $bo, $bi, $dst">;
4591 def gBCLA : BForm_3<16, 1, 1, (outs),
4592 (ins u5imm:$bo, crbitrc:$bi, abscondbrtarget:$dst),
4593 "bcla $bo, $bi, $dst">;
4594 let isAsmParserOnly = 1 in {
4595 def gBCLat : BForm_3_at<16, 0, 1, (outs),
4596 (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
4598 "bcl$at $bo, $bi, $dst">;
4599 def gBCLAat : BForm_3_at<16, 1, 1, (outs),
4600 (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
4601 abscondbrtarget:$dst),
4602 "bcla$at $bo, $bi, $dst">;
4603 } // // isAsmParserOnly = 1
4605 let Defs = [CTR], Uses = [CTR, LR, RM] in
4606 def gBCLR : XLForm_2<19, 16, 0, (outs),
4607 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
4608 "bclr $bo, $bi, $bh", IIC_BrB, []>;
4609 let Defs = [LR, CTR], Uses = [CTR, LR, RM] in
4610 def gBCLRL : XLForm_2<19, 16, 1, (outs),
4611 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
4612 "bclrl $bo, $bi, $bh", IIC_BrB, []>;
4613 let Defs = [CTR], Uses = [CTR, LR, RM] in
4614 def gBCCTR : XLForm_2<19, 528, 0, (outs),
4615 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
4616 "bcctr $bo, $bi, $bh", IIC_BrB, []>;
4617 let Defs = [LR, CTR], Uses = [CTR, LR, RM] in
4618 def gBCCTRL : XLForm_2<19, 528, 1, (outs),
4619 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
4620 "bcctrl $bo, $bi, $bh", IIC_BrB, []>;
4623 multiclass BranchSimpleMnemonicAT<string pm, int at> {
4624 def : InstAlias<"bc"#pm#" $bo, $bi, $dst", (gBCat u5imm:$bo, at, crbitrc:$bi,
4625 condbrtarget:$dst)>;
4626 def : InstAlias<"bca"#pm#" $bo, $bi, $dst", (gBCAat u5imm:$bo, at, crbitrc:$bi,
4627 condbrtarget:$dst)>;
4628 def : InstAlias<"bcl"#pm#" $bo, $bi, $dst", (gBCLat u5imm:$bo, at, crbitrc:$bi,
4629 condbrtarget:$dst)>;
4630 def : InstAlias<"bcla"#pm#" $bo, $bi, $dst", (gBCLAat u5imm:$bo, at, crbitrc:$bi,
4631 condbrtarget:$dst)>;
4633 defm : BranchSimpleMnemonicAT<"+", 3>;
4634 defm : BranchSimpleMnemonicAT<"-", 2>;
4636 def : InstAlias<"bclr $bo, $bi", (gBCLR u5imm:$bo, crbitrc:$bi, 0)>;
4637 def : InstAlias<"bclrl $bo, $bi", (gBCLRL u5imm:$bo, crbitrc:$bi, 0)>;
4638 def : InstAlias<"bcctr $bo, $bi", (gBCCTR u5imm:$bo, crbitrc:$bi, 0)>;
4639 def : InstAlias<"bcctrl $bo, $bi", (gBCCTRL u5imm:$bo, crbitrc:$bi, 0)>;
4641 multiclass BranchSimpleMnemonic1<string name, string pm, int bo> {
4642 def : InstAlias<"b"#name#pm#" $bi, $dst", (gBC bo, crbitrc:$bi, condbrtarget:$dst)>;
4643 def : InstAlias<"b"#name#"a"#pm#" $bi, $dst", (gBCA bo, crbitrc:$bi, abscondbrtarget:$dst)>;
4644 def : InstAlias<"b"#name#"lr"#pm#" $bi", (gBCLR bo, crbitrc:$bi, 0)>;
4645 def : InstAlias<"b"#name#"l"#pm#" $bi, $dst", (gBCL bo, crbitrc:$bi, condbrtarget:$dst)>;
4646 def : InstAlias<"b"#name#"la"#pm#" $bi, $dst", (gBCLA bo, crbitrc:$bi, abscondbrtarget:$dst)>;
4647 def : InstAlias<"b"#name#"lrl"#pm#" $bi", (gBCLRL bo, crbitrc:$bi, 0)>;
4649 multiclass BranchSimpleMnemonic2<string name, string pm, int bo>
4650 : BranchSimpleMnemonic1<name, pm, bo> {
4651 def : InstAlias<"b"#name#"ctr"#pm#" $bi", (gBCCTR bo, crbitrc:$bi, 0)>;
4652 def : InstAlias<"b"#name#"ctrl"#pm#" $bi", (gBCCTRL bo, crbitrc:$bi, 0)>;
4654 defm : BranchSimpleMnemonic2<"t", "", 12>;
4655 defm : BranchSimpleMnemonic2<"f", "", 4>;
4656 defm : BranchSimpleMnemonic2<"t", "-", 14>;
4657 defm : BranchSimpleMnemonic2<"f", "-", 6>;
4658 defm : BranchSimpleMnemonic2<"t", "+", 15>;
4659 defm : BranchSimpleMnemonic2<"f", "+", 7>;
4660 defm : BranchSimpleMnemonic1<"dnzt", "", 8>;
4661 defm : BranchSimpleMnemonic1<"dnzf", "", 0>;
4662 defm : BranchSimpleMnemonic1<"dzt", "", 10>;
4663 defm : BranchSimpleMnemonic1<"dzf", "", 2>;
4665 multiclass BranchExtendedMnemonicPM<string name, string pm, int bibo> {
4666 def : InstAlias<"b"#name#pm#" $cc, $dst",
4667 (BCC bibo, crrc:$cc, condbrtarget:$dst)>;
4668 def : InstAlias<"b"#name#pm#" $dst",
4669 (BCC bibo, CR0, condbrtarget:$dst)>;
4671 def : InstAlias<"b"#name#"a"#pm#" $cc, $dst",
4672 (BCCA bibo, crrc:$cc, abscondbrtarget:$dst)>;
4673 def : InstAlias<"b"#name#"a"#pm#" $dst",
4674 (BCCA bibo, CR0, abscondbrtarget:$dst)>;
4676 def : InstAlias<"b"#name#"lr"#pm#" $cc",
4677 (BCCLR bibo, crrc:$cc)>;
4678 def : InstAlias<"b"#name#"lr"#pm,
4681 def : InstAlias<"b"#name#"ctr"#pm#" $cc",
4682 (BCCCTR bibo, crrc:$cc)>;
4683 def : InstAlias<"b"#name#"ctr"#pm,
4684 (BCCCTR bibo, CR0)>;
4686 def : InstAlias<"b"#name#"l"#pm#" $cc, $dst",
4687 (BCCL bibo, crrc:$cc, condbrtarget:$dst)>;
4688 def : InstAlias<"b"#name#"l"#pm#" $dst",
4689 (BCCL bibo, CR0, condbrtarget:$dst)>;
4691 def : InstAlias<"b"#name#"la"#pm#" $cc, $dst",
4692 (BCCLA bibo, crrc:$cc, abscondbrtarget:$dst)>;
4693 def : InstAlias<"b"#name#"la"#pm#" $dst",
4694 (BCCLA bibo, CR0, abscondbrtarget:$dst)>;
4696 def : InstAlias<"b"#name#"lrl"#pm#" $cc",
4697 (BCCLRL bibo, crrc:$cc)>;
4698 def : InstAlias<"b"#name#"lrl"#pm,
4699 (BCCLRL bibo, CR0)>;
4701 def : InstAlias<"b"#name#"ctrl"#pm#" $cc",
4702 (BCCCTRL bibo, crrc:$cc)>;
4703 def : InstAlias<"b"#name#"ctrl"#pm,
4704 (BCCCTRL bibo, CR0)>;
4706 multiclass BranchExtendedMnemonic<string name, int bibo> {
4707 defm : BranchExtendedMnemonicPM<name, "", bibo>;
4708 defm : BranchExtendedMnemonicPM<name, "-", !add(bibo, 2)>;
4709 defm : BranchExtendedMnemonicPM<name, "+", !add(bibo, 3)>;
4711 defm : BranchExtendedMnemonic<"lt", 12>;
4712 defm : BranchExtendedMnemonic<"gt", 44>;
4713 defm : BranchExtendedMnemonic<"eq", 76>;
4714 defm : BranchExtendedMnemonic<"un", 108>;
4715 defm : BranchExtendedMnemonic<"so", 108>;
4716 defm : BranchExtendedMnemonic<"ge", 4>;
4717 defm : BranchExtendedMnemonic<"nl", 4>;
4718 defm : BranchExtendedMnemonic<"le", 36>;
4719 defm : BranchExtendedMnemonic<"ng", 36>;
4720 defm : BranchExtendedMnemonic<"ne", 68>;
4721 defm : BranchExtendedMnemonic<"nu", 100>;
4722 defm : BranchExtendedMnemonic<"ns", 100>;
4724 def : InstAlias<"cmpwi $rA, $imm", (CMPWI CR0, gprc:$rA, s16imm:$imm)>;
4725 def : InstAlias<"cmpw $rA, $rB", (CMPW CR0, gprc:$rA, gprc:$rB)>;
4726 def : InstAlias<"cmplwi $rA, $imm", (CMPLWI CR0, gprc:$rA, u16imm:$imm)>;
4727 def : InstAlias<"cmplw $rA, $rB", (CMPLW CR0, gprc:$rA, gprc:$rB)>;
4728 def : InstAlias<"cmpdi $rA, $imm", (CMPDI CR0, g8rc:$rA, s16imm64:$imm)>;
4729 def : InstAlias<"cmpd $rA, $rB", (CMPD CR0, g8rc:$rA, g8rc:$rB)>;
4730 def : InstAlias<"cmpldi $rA, $imm", (CMPLDI CR0, g8rc:$rA, u16imm64:$imm)>;
4731 def : InstAlias<"cmpld $rA, $rB", (CMPLD CR0, g8rc:$rA, g8rc:$rB)>;
4733 def : InstAlias<"cmpi $bf, 0, $rA, $imm", (CMPWI crrc:$bf, gprc:$rA, s16imm:$imm)>;
4734 def : InstAlias<"cmp $bf, 0, $rA, $rB", (CMPW crrc:$bf, gprc:$rA, gprc:$rB)>;
4735 def : InstAlias<"cmpli $bf, 0, $rA, $imm", (CMPLWI crrc:$bf, gprc:$rA, u16imm:$imm)>;
4736 def : InstAlias<"cmpl $bf, 0, $rA, $rB", (CMPLW crrc:$bf, gprc:$rA, gprc:$rB)>;
4737 def : InstAlias<"cmpi $bf, 1, $rA, $imm", (CMPDI crrc:$bf, g8rc:$rA, s16imm64:$imm)>;
4738 def : InstAlias<"cmp $bf, 1, $rA, $rB", (CMPD crrc:$bf, g8rc:$rA, g8rc:$rB)>;
4739 def : InstAlias<"cmpli $bf, 1, $rA, $imm", (CMPLDI crrc:$bf, g8rc:$rA, u16imm64:$imm)>;
4740 def : InstAlias<"cmpl $bf, 1, $rA, $rB", (CMPLD crrc:$bf, g8rc:$rA, g8rc:$rB)>;
4742 multiclass TrapExtendedMnemonic<string name, int to> {
4743 def : InstAlias<"td"#name#"i $rA, $imm", (TDI to, g8rc:$rA, s16imm:$imm)>;
4744 def : InstAlias<"td"#name#" $rA, $rB", (TD to, g8rc:$rA, g8rc:$rB)>;
4745 def : InstAlias<"tw"#name#"i $rA, $imm", (TWI to, gprc:$rA, s16imm:$imm)>;
4746 def : InstAlias<"tw"#name#" $rA, $rB", (TW to, gprc:$rA, gprc:$rB)>;
4748 defm : TrapExtendedMnemonic<"lt", 16>;
4749 defm : TrapExtendedMnemonic<"le", 20>;
4750 defm : TrapExtendedMnemonic<"eq", 4>;
4751 defm : TrapExtendedMnemonic<"ge", 12>;
4752 defm : TrapExtendedMnemonic<"gt", 8>;
4753 defm : TrapExtendedMnemonic<"nl", 12>;
4754 defm : TrapExtendedMnemonic<"ne", 24>;
4755 defm : TrapExtendedMnemonic<"ng", 20>;
4756 defm : TrapExtendedMnemonic<"llt", 2>;
4757 defm : TrapExtendedMnemonic<"lle", 6>;
4758 defm : TrapExtendedMnemonic<"lge", 5>;
4759 defm : TrapExtendedMnemonic<"lgt", 1>;
4760 defm : TrapExtendedMnemonic<"lnl", 5>;
4761 defm : TrapExtendedMnemonic<"lng", 6>;
4762 defm : TrapExtendedMnemonic<"u", 31>;
4765 def : Pat<(atomic_load_8 iaddr:$src), (LBZ memri:$src)>;
4766 def : Pat<(atomic_load_16 iaddr:$src), (LHZ memri:$src)>;
4767 def : Pat<(atomic_load_32 iaddr:$src), (LWZ memri:$src)>;
4768 def : Pat<(atomic_load_8 xaddr:$src), (LBZX memrr:$src)>;
4769 def : Pat<(atomic_load_16 xaddr:$src), (LHZX memrr:$src)>;
4770 def : Pat<(atomic_load_32 xaddr:$src), (LWZX memrr:$src)>;
4773 def : Pat<(atomic_store_8 iaddr:$ptr, i32:$val), (STB gprc:$val, memri:$ptr)>;
4774 def : Pat<(atomic_store_16 iaddr:$ptr, i32:$val), (STH gprc:$val, memri:$ptr)>;
4775 def : Pat<(atomic_store_32 iaddr:$ptr, i32:$val), (STW gprc:$val, memri:$ptr)>;
4776 def : Pat<(atomic_store_8 xaddr:$ptr, i32:$val), (STBX gprc:$val, memrr:$ptr)>;
4777 def : Pat<(atomic_store_16 xaddr:$ptr, i32:$val), (STHX gprc:$val, memrr:$ptr)>;
4778 def : Pat<(atomic_store_32 xaddr:$ptr, i32:$val), (STWX gprc:$val, memrr:$ptr)>;
4780 let Predicates = [IsISA3_0] in {
4782 // Copy-Paste Facility
4783 // We prefix 'CP' to COPY due to name conflict in Target.td. We also prefix to
4784 // PASTE for naming consistency.
4786 def CP_COPY : X_L1_RA5_RB5<31, 774, "copy" , gprc, IIC_LdStCOPY, []>;
4789 def CP_PASTE : X_L1_RA5_RB5<31, 902, "paste" , gprc, IIC_LdStPASTE, []>;
4791 let mayStore = 1, Defs = [CR0] in
4792 def CP_PASTEo : X_L1_RA5_RB5<31, 902, "paste.", gprc, IIC_LdStPASTE, []>, isDOT;
4794 def CP_COPYx : PPCAsmPseudo<"copy $rA, $rB" , (ins gprc:$rA, gprc:$rB)>;
4795 def CP_PASTEx : PPCAsmPseudo<"paste $rA, $rB", (ins gprc:$rA, gprc:$rB)>;
4796 def CP_COPY_FIRST : PPCAsmPseudo<"copy_first $rA, $rB",
4797 (ins gprc:$rA, gprc:$rB)>;
4798 def CP_PASTE_LAST : PPCAsmPseudo<"paste_last $rA, $rB",
4799 (ins gprc:$rA, gprc:$rB)>;
4800 def CP_ABORT : XForm_0<31, 838, (outs), (ins), "cp_abort", IIC_SprABORT, []>;
4802 // Message Synchronize
4803 def MSGSYNC : XForm_0<31, 886, (outs), (ins), "msgsync", IIC_SprMSGSYNC, []>;
4805 // Power-Saving Mode Instruction:
4806 def STOP : XForm_0<19, 370, (outs), (ins), "stop", IIC_SprSTOP, []>;
4810 // Fast 32-bit reverse bits algorithm:
4811 // Step 1: 1-bit swap (swap odd 1-bit and even 1-bit):
4812 // n = ((n >> 1) & 0x55555555) | ((n << 1) & 0xAAAAAAAA);
4813 // Step 2: 2-bit swap (swap odd 2-bit and even 2-bit):
4814 // n = ((n >> 2) & 0x33333333) | ((n << 2) & 0xCCCCCCCC);
4815 // Step 3: 4-bit swap (swap odd 4-bit and even 4-bit):
4816 // n = ((n >> 4) & 0x0F0F0F0F) | ((n << 4) & 0xF0F0F0F0);
4817 // Step 4: byte reverse (Suppose n = [B1,B2,B3,B4]):
4818 // Step 4.1: Put B4,B2 in the right position (rotate left 3 bytes):
4819 // n' = (n rotl 24); After which n' = [B4, B1, B2, B3]
4820 // Step 4.2: Insert B3 to the right position:
4821 // n' = rlwimi n', n, 8, 8, 15; After which n' = [B4, B3, B2, B3]
4822 // Step 4.3: Insert B1 to the right position:
4823 // n' = rlwimi n', n, 8, 24, 31; After which n' = [B4, B3, B2, B1]
4825 dag Lo1 = (ORI (LIS 0x5555), 0x5555);
4826 dag Hi1 = (ORI (LIS 0xAAAA), 0xAAAA);
4827 dag Lo2 = (ORI (LIS 0x3333), 0x3333);
4828 dag Hi2 = (ORI (LIS 0xCCCC), 0xCCCC);
4829 dag Lo4 = (ORI (LIS 0x0F0F), 0x0F0F);
4830 dag Hi4 = (ORI (LIS 0xF0F0), 0xF0F0);
4834 dag Right = (RLWINM $A, 31, 1, 31);
4835 dag Left = (RLWINM $A, 1, 0, 30);
4839 dag Bit = (OR (AND Shift1.Right, MaskValues.Lo1),
4840 (AND Shift1.Left, MaskValues.Hi1));
4844 dag Right = (RLWINM Swap1.Bit, 30, 2, 31);
4845 dag Left = (RLWINM Swap1.Bit, 2, 0, 29);
4849 dag Bits = (OR (AND Shift2.Right, MaskValues.Lo2),
4850 (AND Shift2.Left, MaskValues.Hi2));
4854 dag Right = (RLWINM Swap2.Bits, 28, 4, 31);
4855 dag Left = (RLWINM Swap2.Bits, 4, 0, 27);
4859 dag Bits = (OR (AND Shift4.Right, MaskValues.Lo4),
4860 (AND Shift4.Left, MaskValues.Hi4));
4864 dag Left3Bytes = (RLWINM Swap4.Bits, 24, 0, 31);
4867 def RotateInsertByte3 {
4868 dag Left = (RLWIMI Rotate.Left3Bytes, Swap4.Bits, 8, 8, 15);
4871 def RotateInsertByte1 {
4872 dag Left = (RLWIMI RotateInsertByte3.Left, Swap4.Bits, 8, 24, 31);
4875 def : Pat<(i32 (bitreverse i32:$A)),
4876 (RLDICL_32 RotateInsertByte1.Left, 0, 32)>;
4878 // Fast 64-bit reverse bits algorithm:
4879 // Step 1: 1-bit swap (swap odd 1-bit and even 1-bit):
4880 // n = ((n >> 1) & 0x5555555555555555) | ((n << 1) & 0xAAAAAAAAAAAAAAAA);
4881 // Step 2: 2-bit swap (swap odd 2-bit and even 2-bit):
4882 // n = ((n >> 2) & 0x3333333333333333) | ((n << 2) & 0xCCCCCCCCCCCCCCCC);
4883 // Step 3: 4-bit swap (swap odd 4-bit and even 4-bit):
4884 // n = ((n >> 4) & 0x0F0F0F0F0F0F0F0F) | ((n << 4) & 0xF0F0F0F0F0F0F0F0);
4885 // Step 4: byte reverse (Suppose n = [B0,B1,B2,B3,B4,B5,B6,B7]):
4886 // Apply the same byte reverse algorithm mentioned above for the fast 32-bit
4887 // reverse to both the high 32 bit and low 32 bit of the 64 bit value. And
4888 // then OR them together to get the final result.
4890 dag Lo1 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Lo1, sub_32));
4891 dag Hi1 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Hi1, sub_32));
4892 dag Lo2 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Lo2, sub_32));
4893 dag Hi2 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Hi2, sub_32));
4894 dag Lo4 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Lo4, sub_32));
4895 dag Hi4 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Hi4, sub_32));
4899 dag Lo1 = (ORI8 (ORIS8 (RLDICR MaskValues64.Lo1, 32, 31), 0x5555), 0x5555);
4900 dag Hi1 = (ORI8 (ORIS8 (RLDICR MaskValues64.Hi1, 32, 31), 0xAAAA), 0xAAAA);
4901 dag Lo2 = (ORI8 (ORIS8 (RLDICR MaskValues64.Lo2, 32, 31), 0x3333), 0x3333);
4902 dag Hi2 = (ORI8 (ORIS8 (RLDICR MaskValues64.Hi2, 32, 31), 0xCCCC), 0xCCCC);
4903 dag Lo4 = (ORI8 (ORIS8 (RLDICR MaskValues64.Lo4, 32, 31), 0x0F0F), 0x0F0F);
4904 dag Hi4 = (ORI8 (ORIS8 (RLDICR MaskValues64.Hi4, 32, 31), 0xF0F0), 0xF0F0);
4908 dag Swap1 = (OR8 (AND8 (RLDICL $A, 63, 1), DWMaskValues.Lo1),
4909 (AND8 (RLDICR $A, 1, 62), DWMaskValues.Hi1));
4910 dag Swap2 = (OR8 (AND8 (RLDICL Swap1, 62, 2), DWMaskValues.Lo2),
4911 (AND8 (RLDICR Swap1, 2, 61), DWMaskValues.Hi2));
4912 dag Swap4 = (OR8 (AND8 (RLDICL Swap2, 60, 4), DWMaskValues.Lo4),
4913 (AND8 (RLDICR Swap2, 4, 59), DWMaskValues.Hi4));
4916 // Intra-byte swap is done, now start inter-byte swap.
4918 dag Word = (i32 (EXTRACT_SUBREG DWSwapInByte.Swap4, sub_32));
4922 dag Word = (RLWINM DWBytes4567.Word, 24, 0, 31);
4926 dag Word = (RLWIMI DWBytes7456.Word, DWBytes4567.Word, 8, 8, 15);
4929 // B7 B6 B5 B4 in the right order
4931 dag Word = (RLWIMI DWBytes7656.Word, DWBytes4567.Word, 8, 24, 31);
4933 (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), Word, sub_32));
4937 dag Word = (i32 (EXTRACT_SUBREG (RLDICL DWSwapInByte.Swap4, 32, 32), sub_32));
4941 dag Word = (RLWINM DWBytes0123.Word, 24, 0, 31);
4945 dag Word = (RLWIMI DWBytes3012.Word, DWBytes0123.Word, 8, 8, 15);
4948 // B3 B2 B1 B0 in the right order
4950 dag Word = (RLWIMI DWBytes3212.Word, DWBytes0123.Word, 8, 24, 31);
4952 (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), Word, sub_32));
4955 // Now both high word and low word are reversed, next
4956 // swap the high word and low word.
4957 def : Pat<(i64 (bitreverse i64:$A)),
4958 (OR8 (RLDICR DWBytes7654.DWord, 32, 31), DWBytes3210.DWord)>;