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 //===----------------------------------------------------------------------===//
118 // PowerPC specific DAG Nodes.
121 def PPCfre : SDNode<"PPCISD::FRE", SDTFPUnaryOp, []>;
122 def PPCfrsqrte: SDNode<"PPCISD::FRSQRTE", SDTFPUnaryOp, []>;
124 def PPCfcfid : SDNode<"PPCISD::FCFID", SDTFPUnaryOp, []>;
125 def PPCfcfidu : SDNode<"PPCISD::FCFIDU", SDTFPUnaryOp, []>;
126 def PPCfcfids : SDNode<"PPCISD::FCFIDS", SDTFPRoundOp, []>;
127 def PPCfcfidus: SDNode<"PPCISD::FCFIDUS", SDTFPRoundOp, []>;
128 def PPCfctidz : SDNode<"PPCISD::FCTIDZ", SDTFPUnaryOp, []>;
129 def PPCfctiwz : SDNode<"PPCISD::FCTIWZ", SDTFPUnaryOp, []>;
130 def PPCfctiduz: SDNode<"PPCISD::FCTIDUZ",SDTFPUnaryOp, []>;
131 def PPCfctiwuz: SDNode<"PPCISD::FCTIWUZ",SDTFPUnaryOp, []>;
133 def PPCcv_fp_to_uint_in_vsr:
134 SDNode<"PPCISD::FP_TO_UINT_IN_VSR", SDT_PPCcv_fp_to_int, []>;
135 def PPCcv_fp_to_sint_in_vsr:
136 SDNode<"PPCISD::FP_TO_SINT_IN_VSR", SDT_PPCcv_fp_to_int, []>;
137 def PPCstore_scal_int_from_vsr:
138 SDNode<"PPCISD::ST_VSR_SCAL_INT", SDT_PPCstore_scal_int_from_vsr,
139 [SDNPHasChain, SDNPMayStore]>;
140 def PPCstfiwx : SDNode<"PPCISD::STFIWX", SDT_PPCstfiwx,
141 [SDNPHasChain, SDNPMayStore]>;
142 def PPClfiwax : SDNode<"PPCISD::LFIWAX", SDT_PPClfiwx,
143 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
144 def PPClfiwzx : SDNode<"PPCISD::LFIWZX", SDT_PPClfiwx,
145 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
146 def PPClxsizx : SDNode<"PPCISD::LXSIZX", SDT_PPCLxsizx,
147 [SDNPHasChain, SDNPMayLoad]>;
148 def PPCstxsix : SDNode<"PPCISD::STXSIX", SDT_PPCstxsix,
149 [SDNPHasChain, SDNPMayStore]>;
150 def PPCVexts : SDNode<"PPCISD::VEXTS", SDT_PPCVexts, []>;
151 def PPCSExtVElems : SDNode<"PPCISD::SExtVElems", SDT_PPCSExtVElems, []>;
153 // Extract FPSCR (not modeled at the DAG level).
154 def PPCmffs : SDNode<"PPCISD::MFFS",
155 SDTypeProfile<1, 0, [SDTCisVT<0, f64>]>, []>;
157 // Perform FADD in round-to-zero mode.
158 def PPCfaddrtz: SDNode<"PPCISD::FADDRTZ", SDTFPBinOp, []>;
161 def PPCfsel : SDNode<"PPCISD::FSEL",
162 // Type constraint for fsel.
163 SDTypeProfile<1, 3, [SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>,
164 SDTCisFP<0>, SDTCisVT<1, f64>]>, []>;
166 def PPChi : SDNode<"PPCISD::Hi", SDTIntBinOp, []>;
167 def PPClo : SDNode<"PPCISD::Lo", SDTIntBinOp, []>;
168 def PPCtoc_entry: SDNode<"PPCISD::TOC_ENTRY", SDTIntBinOp,
169 [SDNPMayLoad, SDNPMemOperand]>;
170 def PPCvmaddfp : SDNode<"PPCISD::VMADDFP", SDTFPTernaryOp, []>;
171 def PPCvnmsubfp : SDNode<"PPCISD::VNMSUBFP", SDTFPTernaryOp, []>;
173 def PPCppc32GOT : SDNode<"PPCISD::PPC32_GOT", SDTIntLeaf, []>;
175 def PPCaddisGotTprelHA : SDNode<"PPCISD::ADDIS_GOT_TPREL_HA", SDTIntBinOp>;
176 def PPCldGotTprelL : SDNode<"PPCISD::LD_GOT_TPREL_L", SDTIntBinOp,
178 def PPCaddTls : SDNode<"PPCISD::ADD_TLS", SDTIntBinOp, []>;
179 def PPCaddisTlsgdHA : SDNode<"PPCISD::ADDIS_TLSGD_HA", SDTIntBinOp>;
180 def PPCaddiTlsgdL : SDNode<"PPCISD::ADDI_TLSGD_L", SDTIntBinOp>;
181 def PPCgetTlsAddr : SDNode<"PPCISD::GET_TLS_ADDR", SDTIntBinOp>;
182 def PPCaddiTlsgdLAddr : SDNode<"PPCISD::ADDI_TLSGD_L_ADDR",
183 SDTypeProfile<1, 3, [
184 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
185 SDTCisSameAs<0, 3>, SDTCisInt<0> ]>>;
186 def PPCaddisTlsldHA : SDNode<"PPCISD::ADDIS_TLSLD_HA", SDTIntBinOp>;
187 def PPCaddiTlsldL : SDNode<"PPCISD::ADDI_TLSLD_L", SDTIntBinOp>;
188 def PPCgetTlsldAddr : SDNode<"PPCISD::GET_TLSLD_ADDR", SDTIntBinOp>;
189 def PPCaddiTlsldLAddr : SDNode<"PPCISD::ADDI_TLSLD_L_ADDR",
190 SDTypeProfile<1, 3, [
191 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
192 SDTCisSameAs<0, 3>, SDTCisInt<0> ]>>;
193 def PPCaddisDtprelHA : SDNode<"PPCISD::ADDIS_DTPREL_HA", SDTIntBinOp>;
194 def PPCaddiDtprelL : SDNode<"PPCISD::ADDI_DTPREL_L", SDTIntBinOp>;
196 def PPCvperm : SDNode<"PPCISD::VPERM", SDT_PPCvperm, []>;
197 def PPCxxsplt : SDNode<"PPCISD::XXSPLT", SDT_PPCVecSplat, []>;
198 def PPCvecinsert : SDNode<"PPCISD::VECINSERT", SDT_PPCVecInsert, []>;
199 def PPCxxreverse : SDNode<"PPCISD::XXREVERSE", SDT_PPCVecReverse, []>;
200 def PPCxxpermdi : SDNode<"PPCISD::XXPERMDI", SDT_PPCxxpermdi, []>;
201 def PPCvecshl : SDNode<"PPCISD::VECSHL", SDT_PPCVecShift, []>;
203 def PPCqvfperm : SDNode<"PPCISD::QVFPERM", SDT_PPCqvfperm, []>;
204 def PPCqvgpci : SDNode<"PPCISD::QVGPCI", SDT_PPCqvgpci, []>;
205 def PPCqvaligni : SDNode<"PPCISD::QVALIGNI", SDT_PPCqvaligni, []>;
206 def PPCqvesplati : SDNode<"PPCISD::QVESPLATI", SDT_PPCqvesplati, []>;
208 def PPCqbflt : SDNode<"PPCISD::QBFLT", SDT_PPCqbflt, []>;
210 def PPCqvlfsb : SDNode<"PPCISD::QVLFSb", SDT_PPCqvlfsb,
211 [SDNPHasChain, SDNPMayLoad]>;
213 def PPCcmpb : SDNode<"PPCISD::CMPB", SDTIntBinOp, []>;
215 // These nodes represent the 32-bit PPC shifts that operate on 6-bit shift
216 // amounts. These nodes are generated by the multi-precision shift code.
217 def PPCsrl : SDNode<"PPCISD::SRL" , SDTIntShiftOp>;
218 def PPCsra : SDNode<"PPCISD::SRA" , SDTIntShiftOp>;
219 def PPCshl : SDNode<"PPCISD::SHL" , SDTIntShiftOp>;
221 // Move 2 i64 values into a VSX register
222 def PPCbuild_fp128: SDNode<"PPCISD::BUILD_FP128",
224 [SDTCisFP<0>, SDTCisSameSizeAs<1,2>,
228 // These are target-independent nodes, but have target-specific formats.
229 def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_PPCCallSeqStart,
230 [SDNPHasChain, SDNPOutGlue]>;
231 def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_PPCCallSeqEnd,
232 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
234 def SDT_PPCCall : SDTypeProfile<0, -1, [SDTCisInt<0>]>;
235 def PPCcall : SDNode<"PPCISD::CALL", SDT_PPCCall,
236 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
238 def PPCcall_nop : SDNode<"PPCISD::CALL_NOP", SDT_PPCCall,
239 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
241 def PPCmtctr : SDNode<"PPCISD::MTCTR", SDT_PPCCall,
242 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
243 def PPCbctrl : SDNode<"PPCISD::BCTRL", SDTNone,
244 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
246 def PPCbctrl_load_toc : SDNode<"PPCISD::BCTRL_LOAD_TOC",
247 SDTypeProfile<0, 1, []>,
248 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
251 def retflag : SDNode<"PPCISD::RET_FLAG", SDTNone,
252 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
254 def PPCtc_return : SDNode<"PPCISD::TC_RETURN", SDT_PPCTC_ret,
255 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
257 def PPCeh_sjlj_setjmp : SDNode<"PPCISD::EH_SJLJ_SETJMP",
258 SDTypeProfile<1, 1, [SDTCisInt<0>,
260 [SDNPHasChain, SDNPSideEffect]>;
261 def PPCeh_sjlj_longjmp : SDNode<"PPCISD::EH_SJLJ_LONGJMP",
262 SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>,
263 [SDNPHasChain, SDNPSideEffect]>;
265 def SDT_PPCsc : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
266 def PPCsc : SDNode<"PPCISD::SC", SDT_PPCsc,
267 [SDNPHasChain, SDNPSideEffect]>;
269 def PPCclrbhrb : SDNode<"PPCISD::CLRBHRB", SDTNone,
270 [SDNPHasChain, SDNPSideEffect]>;
271 def PPCmfbhrbe : SDNode<"PPCISD::MFBHRBE", SDTIntBinOp, [SDNPHasChain]>;
272 def PPCrfebb : SDNode<"PPCISD::RFEBB", SDT_PPCsc,
273 [SDNPHasChain, SDNPSideEffect]>;
275 def PPCvcmp : SDNode<"PPCISD::VCMP" , SDT_PPCvcmp, []>;
276 def PPCvcmp_o : SDNode<"PPCISD::VCMPo", SDT_PPCvcmp, [SDNPOutGlue]>;
278 def PPCcondbranch : SDNode<"PPCISD::COND_BRANCH", SDT_PPCcondbr,
279 [SDNPHasChain, SDNPOptInGlue]>;
281 // PPC-specific atomic operations.
282 def PPCatomicCmpSwap_8 :
283 SDNode<"PPCISD::ATOMIC_CMP_SWAP_8", SDTAtomic3,
284 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
285 def PPCatomicCmpSwap_16 :
286 SDNode<"PPCISD::ATOMIC_CMP_SWAP_16", SDTAtomic3,
287 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
288 def PPClbrx : SDNode<"PPCISD::LBRX", SDT_PPClbrx,
289 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
290 def PPCstbrx : SDNode<"PPCISD::STBRX", SDT_PPCstbrx,
291 [SDNPHasChain, SDNPMayStore]>;
293 // Instructions to set/unset CR bit 6 for SVR4 vararg calls
294 def PPCcr6set : SDNode<"PPCISD::CR6SET", SDTNone,
295 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
296 def PPCcr6unset : SDNode<"PPCISD::CR6UNSET", SDTNone,
297 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
299 // Instructions to support dynamic alloca.
300 def SDTDynOp : SDTypeProfile<1, 2, []>;
301 def SDTDynAreaOp : SDTypeProfile<1, 1, []>;
302 def PPCdynalloc : SDNode<"PPCISD::DYNALLOC", SDTDynOp, [SDNPHasChain]>;
303 def PPCdynareaoffset : SDNode<"PPCISD::DYNAREAOFFSET", SDTDynAreaOp, [SDNPHasChain]>;
305 //===----------------------------------------------------------------------===//
306 // PowerPC specific transformation functions and pattern fragments.
309 def SHL32 : SDNodeXForm<imm, [{
310 // Transformation function: 31 - imm
311 return getI32Imm(31 - N->getZExtValue(), SDLoc(N));
314 def SRL32 : SDNodeXForm<imm, [{
315 // Transformation function: 32 - imm
316 return N->getZExtValue() ? getI32Imm(32 - N->getZExtValue(), SDLoc(N))
317 : getI32Imm(0, SDLoc(N));
320 def LO16 : SDNodeXForm<imm, [{
321 // Transformation function: get the low 16 bits.
322 return getI32Imm((unsigned short)N->getZExtValue(), SDLoc(N));
325 def HI16 : SDNodeXForm<imm, [{
326 // Transformation function: shift the immediate value down into the low bits.
327 return getI32Imm((unsigned)N->getZExtValue() >> 16, SDLoc(N));
330 def HA16 : SDNodeXForm<imm, [{
331 // Transformation function: shift the immediate value down into the low bits.
332 long Val = N->getZExtValue();
333 return getI32Imm((Val - (signed short)Val) >> 16, SDLoc(N));
335 def MB : SDNodeXForm<imm, [{
336 // Transformation function: get the start bit of a mask
338 (void)isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
339 return getI32Imm(mb, SDLoc(N));
342 def ME : SDNodeXForm<imm, [{
343 // Transformation function: get the end bit of a mask
345 (void)isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
346 return getI32Imm(me, SDLoc(N));
348 def maskimm32 : PatLeaf<(imm), [{
349 // maskImm predicate - True if immediate is a run of ones.
351 if (N->getValueType(0) == MVT::i32)
352 return isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
357 def imm32SExt16 : Operand<i32>, ImmLeaf<i32, [{
358 // imm32SExt16 predicate - True if the i32 immediate fits in a 16-bit
359 // sign extended field. Used by instructions like 'addi'.
360 return (int32_t)Imm == (short)Imm;
362 def imm64SExt16 : Operand<i64>, ImmLeaf<i64, [{
363 // imm64SExt16 predicate - True if the i64 immediate fits in a 16-bit
364 // sign extended field. Used by instructions like 'addi'.
365 return (int64_t)Imm == (short)Imm;
367 def immZExt16 : PatLeaf<(imm), [{
368 // immZExt16 predicate - True if the immediate fits in a 16-bit zero extended
369 // field. Used by instructions like 'ori'.
370 return (uint64_t)N->getZExtValue() == (unsigned short)N->getZExtValue();
372 def immAnyExt8 : ImmLeaf<i32, [{ return isInt<8>(Imm) || isUInt<8>(Imm); }]>;
373 def immSExt5NonZero : ImmLeaf<i32, [{ return Imm && isInt<5>(Imm); }]>;
375 // imm16Shifted* - These match immediates where the low 16-bits are zero. There
376 // are two forms: imm16ShiftedSExt and imm16ShiftedZExt. These two forms are
377 // identical in 32-bit mode, but in 64-bit mode, they return true if the
378 // immediate fits into a sign/zero extended 32-bit immediate (with the low bits
380 def imm16ShiftedZExt : PatLeaf<(imm), [{
381 // imm16ShiftedZExt predicate - True if only bits in the top 16-bits of the
382 // immediate are set. Used by instructions like 'xoris'.
383 return (N->getZExtValue() & ~uint64_t(0xFFFF0000)) == 0;
386 def imm16ShiftedSExt : PatLeaf<(imm), [{
387 // imm16ShiftedSExt predicate - True if only bits in the top 16-bits of the
388 // immediate are set. Used by instructions like 'addis'. Identical to
389 // imm16ShiftedZExt in 32-bit mode.
390 if (N->getZExtValue() & 0xFFFF) return false;
391 if (N->getValueType(0) == MVT::i32)
393 // For 64-bit, make sure it is sext right.
394 return N->getZExtValue() == (uint64_t)(int)N->getZExtValue();
397 def imm64ZExt32 : Operand<i64>, ImmLeaf<i64, [{
398 // imm64ZExt32 predicate - True if the i64 immediate fits in a 32-bit
399 // zero extended field.
400 return isUInt<32>(Imm);
403 // Some r+i load/store instructions (such as LD, STD, LDU, etc.) that require
404 // restricted memrix (4-aligned) constants are alignment sensitive. If these
405 // offsets are hidden behind TOC entries than the values of the lower-order
406 // bits cannot be checked directly. As a result, we need to also incorporate
407 // an alignment check into the relevant patterns.
409 def aligned4load : PatFrag<(ops node:$ptr), (load node:$ptr), [{
410 return cast<LoadSDNode>(N)->getAlignment() >= 4;
412 def aligned4store : PatFrag<(ops node:$val, node:$ptr),
413 (store node:$val, node:$ptr), [{
414 return cast<StoreSDNode>(N)->getAlignment() >= 4;
416 def aligned4sextloadi32 : PatFrag<(ops node:$ptr), (sextloadi32 node:$ptr), [{
417 return cast<LoadSDNode>(N)->getAlignment() >= 4;
419 def aligned4pre_store : PatFrag<
420 (ops node:$val, node:$base, node:$offset),
421 (pre_store node:$val, node:$base, node:$offset), [{
422 return cast<StoreSDNode>(N)->getAlignment() >= 4;
425 def unaligned4load : PatFrag<(ops node:$ptr), (load node:$ptr), [{
426 return cast<LoadSDNode>(N)->getAlignment() < 4;
428 def unaligned4store : PatFrag<(ops node:$val, node:$ptr),
429 (store node:$val, node:$ptr), [{
430 return cast<StoreSDNode>(N)->getAlignment() < 4;
432 def unaligned4sextloadi32 : PatFrag<(ops node:$ptr), (sextloadi32 node:$ptr), [{
433 return cast<LoadSDNode>(N)->getAlignment() < 4;
436 // This is a somewhat weaker condition than actually checking for 16-byte
437 // alignment. It is simply checking that the displacement can be represented
438 // as an immediate that is a multiple of 16 (i.e. the requirements for DQ-Form
440 def quadwOffsetLoad : PatFrag<(ops node:$ptr), (load node:$ptr), [{
441 return isOffsetMultipleOf(N, 16);
443 def quadwOffsetStore : PatFrag<(ops node:$val, node:$ptr),
444 (store node:$val, node:$ptr), [{
445 return isOffsetMultipleOf(N, 16);
447 def nonQuadwOffsetLoad : PatFrag<(ops node:$ptr), (load node:$ptr), [{
448 return !isOffsetMultipleOf(N, 16);
450 def nonQuadwOffsetStore : PatFrag<(ops node:$val, node:$ptr),
451 (store node:$val, node:$ptr), [{
452 return !isOffsetMultipleOf(N, 16);
455 //===----------------------------------------------------------------------===//
456 // PowerPC Flag Definitions.
458 class isPPC64 { bit PPC64 = 1; }
459 class isDOT { bit RC = 1; }
461 class RegConstraint<string C> {
462 string Constraints = C;
464 class NoEncode<string E> {
465 string DisableEncoding = E;
469 //===----------------------------------------------------------------------===//
470 // PowerPC Operand Definitions.
472 // In the default PowerPC assembler syntax, registers are specified simply
473 // by number, so they cannot be distinguished from immediate values (without
474 // looking at the opcode). This means that the default operand matching logic
475 // for the asm parser does not work, and we need to specify custom matchers.
476 // Since those can only be specified with RegisterOperand classes and not
477 // directly on the RegisterClass, all instructions patterns used by the asm
478 // parser need to use a RegisterOperand (instead of a RegisterClass) for
479 // all their register operands.
480 // For this purpose, we define one RegisterOperand for each RegisterClass,
481 // using the same name as the class, just in lower case.
483 def PPCRegGPRCAsmOperand : AsmOperandClass {
484 let Name = "RegGPRC"; let PredicateMethod = "isRegNumber";
486 def gprc : RegisterOperand<GPRC> {
487 let ParserMatchClass = PPCRegGPRCAsmOperand;
489 def PPCRegG8RCAsmOperand : AsmOperandClass {
490 let Name = "RegG8RC"; let PredicateMethod = "isRegNumber";
492 def g8rc : RegisterOperand<G8RC> {
493 let ParserMatchClass = PPCRegG8RCAsmOperand;
495 def PPCRegGPRCNoR0AsmOperand : AsmOperandClass {
496 let Name = "RegGPRCNoR0"; let PredicateMethod = "isRegNumber";
498 def gprc_nor0 : RegisterOperand<GPRC_NOR0> {
499 let ParserMatchClass = PPCRegGPRCNoR0AsmOperand;
501 def PPCRegG8RCNoX0AsmOperand : AsmOperandClass {
502 let Name = "RegG8RCNoX0"; let PredicateMethod = "isRegNumber";
504 def g8rc_nox0 : RegisterOperand<G8RC_NOX0> {
505 let ParserMatchClass = PPCRegG8RCNoX0AsmOperand;
507 def PPCRegF8RCAsmOperand : AsmOperandClass {
508 let Name = "RegF8RC"; let PredicateMethod = "isRegNumber";
510 def f8rc : RegisterOperand<F8RC> {
511 let ParserMatchClass = PPCRegF8RCAsmOperand;
513 def PPCRegF4RCAsmOperand : AsmOperandClass {
514 let Name = "RegF4RC"; let PredicateMethod = "isRegNumber";
516 def f4rc : RegisterOperand<F4RC> {
517 let ParserMatchClass = PPCRegF4RCAsmOperand;
519 def PPCRegVRRCAsmOperand : AsmOperandClass {
520 let Name = "RegVRRC"; let PredicateMethod = "isRegNumber";
522 def vrrc : RegisterOperand<VRRC> {
523 let ParserMatchClass = PPCRegVRRCAsmOperand;
525 def PPCRegVFRCAsmOperand : AsmOperandClass {
526 let Name = "RegVFRC"; let PredicateMethod = "isRegNumber";
528 def vfrc : RegisterOperand<VFRC> {
529 let ParserMatchClass = PPCRegVFRCAsmOperand;
531 def PPCRegCRBITRCAsmOperand : AsmOperandClass {
532 let Name = "RegCRBITRC"; let PredicateMethod = "isCRBitNumber";
534 def crbitrc : RegisterOperand<CRBITRC> {
535 let ParserMatchClass = PPCRegCRBITRCAsmOperand;
537 def PPCRegCRRCAsmOperand : AsmOperandClass {
538 let Name = "RegCRRC"; let PredicateMethod = "isCCRegNumber";
540 def crrc : RegisterOperand<CRRC> {
541 let ParserMatchClass = PPCRegCRRCAsmOperand;
543 def crrc0 : RegisterOperand<CRRC0> {
544 let ParserMatchClass = PPCRegCRRCAsmOperand;
547 def PPCRegSPERCAsmOperand : AsmOperandClass {
548 let Name = "RegSPERC"; let PredicateMethod = "isRegNumber";
550 def sperc : RegisterOperand<SPERC> {
551 let ParserMatchClass = PPCRegSPERCAsmOperand;
553 def PPCRegSPE4RCAsmOperand : AsmOperandClass {
554 let Name = "RegSPE4RC"; let PredicateMethod = "isRegNumber";
556 def spe4rc : RegisterOperand<SPE4RC> {
557 let ParserMatchClass = PPCRegSPE4RCAsmOperand;
560 def PPCU1ImmAsmOperand : AsmOperandClass {
561 let Name = "U1Imm"; let PredicateMethod = "isU1Imm";
562 let RenderMethod = "addImmOperands";
564 def u1imm : Operand<i32> {
565 let PrintMethod = "printU1ImmOperand";
566 let ParserMatchClass = PPCU1ImmAsmOperand;
569 def PPCU2ImmAsmOperand : AsmOperandClass {
570 let Name = "U2Imm"; let PredicateMethod = "isU2Imm";
571 let RenderMethod = "addImmOperands";
573 def u2imm : Operand<i32> {
574 let PrintMethod = "printU2ImmOperand";
575 let ParserMatchClass = PPCU2ImmAsmOperand;
578 def PPCATBitsAsHintAsmOperand : AsmOperandClass {
579 let Name = "ATBitsAsHint"; let PredicateMethod = "isATBitsAsHint";
580 let RenderMethod = "addImmOperands"; // Irrelevant, predicate always fails.
582 def atimm : Operand<i32> {
583 let PrintMethod = "printATBitsAsHint";
584 let ParserMatchClass = PPCATBitsAsHintAsmOperand;
587 def PPCU3ImmAsmOperand : AsmOperandClass {
588 let Name = "U3Imm"; let PredicateMethod = "isU3Imm";
589 let RenderMethod = "addImmOperands";
591 def u3imm : Operand<i32> {
592 let PrintMethod = "printU3ImmOperand";
593 let ParserMatchClass = PPCU3ImmAsmOperand;
596 def PPCU4ImmAsmOperand : AsmOperandClass {
597 let Name = "U4Imm"; let PredicateMethod = "isU4Imm";
598 let RenderMethod = "addImmOperands";
600 def u4imm : Operand<i32> {
601 let PrintMethod = "printU4ImmOperand";
602 let ParserMatchClass = PPCU4ImmAsmOperand;
604 def PPCS5ImmAsmOperand : AsmOperandClass {
605 let Name = "S5Imm"; let PredicateMethod = "isS5Imm";
606 let RenderMethod = "addImmOperands";
608 def s5imm : Operand<i32> {
609 let PrintMethod = "printS5ImmOperand";
610 let ParserMatchClass = PPCS5ImmAsmOperand;
611 let DecoderMethod = "decodeSImmOperand<5>";
613 def PPCU5ImmAsmOperand : AsmOperandClass {
614 let Name = "U5Imm"; let PredicateMethod = "isU5Imm";
615 let RenderMethod = "addImmOperands";
617 def u5imm : Operand<i32> {
618 let PrintMethod = "printU5ImmOperand";
619 let ParserMatchClass = PPCU5ImmAsmOperand;
620 let DecoderMethod = "decodeUImmOperand<5>";
622 def PPCU6ImmAsmOperand : AsmOperandClass {
623 let Name = "U6Imm"; let PredicateMethod = "isU6Imm";
624 let RenderMethod = "addImmOperands";
626 def u6imm : Operand<i32> {
627 let PrintMethod = "printU6ImmOperand";
628 let ParserMatchClass = PPCU6ImmAsmOperand;
629 let DecoderMethod = "decodeUImmOperand<6>";
631 def PPCU7ImmAsmOperand : AsmOperandClass {
632 let Name = "U7Imm"; let PredicateMethod = "isU7Imm";
633 let RenderMethod = "addImmOperands";
635 def u7imm : Operand<i32> {
636 let PrintMethod = "printU7ImmOperand";
637 let ParserMatchClass = PPCU7ImmAsmOperand;
638 let DecoderMethod = "decodeUImmOperand<7>";
640 def PPCU8ImmAsmOperand : AsmOperandClass {
641 let Name = "U8Imm"; let PredicateMethod = "isU8Imm";
642 let RenderMethod = "addImmOperands";
644 def u8imm : Operand<i32> {
645 let PrintMethod = "printU8ImmOperand";
646 let ParserMatchClass = PPCU8ImmAsmOperand;
647 let DecoderMethod = "decodeUImmOperand<8>";
649 def PPCU10ImmAsmOperand : AsmOperandClass {
650 let Name = "U10Imm"; let PredicateMethod = "isU10Imm";
651 let RenderMethod = "addImmOperands";
653 def u10imm : Operand<i32> {
654 let PrintMethod = "printU10ImmOperand";
655 let ParserMatchClass = PPCU10ImmAsmOperand;
656 let DecoderMethod = "decodeUImmOperand<10>";
658 def PPCU12ImmAsmOperand : AsmOperandClass {
659 let Name = "U12Imm"; let PredicateMethod = "isU12Imm";
660 let RenderMethod = "addImmOperands";
662 def u12imm : Operand<i32> {
663 let PrintMethod = "printU12ImmOperand";
664 let ParserMatchClass = PPCU12ImmAsmOperand;
665 let DecoderMethod = "decodeUImmOperand<12>";
667 def PPCS16ImmAsmOperand : AsmOperandClass {
668 let Name = "S16Imm"; let PredicateMethod = "isS16Imm";
669 let RenderMethod = "addS16ImmOperands";
671 def s16imm : Operand<i32> {
672 let PrintMethod = "printS16ImmOperand";
673 let EncoderMethod = "getImm16Encoding";
674 let ParserMatchClass = PPCS16ImmAsmOperand;
675 let DecoderMethod = "decodeSImmOperand<16>";
677 def PPCU16ImmAsmOperand : AsmOperandClass {
678 let Name = "U16Imm"; let PredicateMethod = "isU16Imm";
679 let RenderMethod = "addU16ImmOperands";
681 def u16imm : Operand<i32> {
682 let PrintMethod = "printU16ImmOperand";
683 let EncoderMethod = "getImm16Encoding";
684 let ParserMatchClass = PPCU16ImmAsmOperand;
685 let DecoderMethod = "decodeUImmOperand<16>";
687 def PPCS17ImmAsmOperand : AsmOperandClass {
688 let Name = "S17Imm"; let PredicateMethod = "isS17Imm";
689 let RenderMethod = "addS16ImmOperands";
691 def s17imm : Operand<i32> {
692 // This operand type is used for addis/lis to allow the assembler parser
693 // to accept immediates in the range -65536..65535 for compatibility with
694 // the GNU assembler. The operand is treated as 16-bit otherwise.
695 let PrintMethod = "printS16ImmOperand";
696 let EncoderMethod = "getImm16Encoding";
697 let ParserMatchClass = PPCS17ImmAsmOperand;
698 let DecoderMethod = "decodeSImmOperand<16>";
701 def fpimm0 : PatLeaf<(fpimm), [{ return N->isExactlyValue(+0.0); }]>;
703 def PPCDirectBrAsmOperand : AsmOperandClass {
704 let Name = "DirectBr"; let PredicateMethod = "isDirectBr";
705 let RenderMethod = "addBranchTargetOperands";
707 def directbrtarget : Operand<OtherVT> {
708 let PrintMethod = "printBranchOperand";
709 let EncoderMethod = "getDirectBrEncoding";
710 let ParserMatchClass = PPCDirectBrAsmOperand;
712 def absdirectbrtarget : Operand<OtherVT> {
713 let PrintMethod = "printAbsBranchOperand";
714 let EncoderMethod = "getAbsDirectBrEncoding";
715 let ParserMatchClass = PPCDirectBrAsmOperand;
717 def PPCCondBrAsmOperand : AsmOperandClass {
718 let Name = "CondBr"; let PredicateMethod = "isCondBr";
719 let RenderMethod = "addBranchTargetOperands";
721 def condbrtarget : Operand<OtherVT> {
722 let PrintMethod = "printBranchOperand";
723 let EncoderMethod = "getCondBrEncoding";
724 let ParserMatchClass = PPCCondBrAsmOperand;
726 def abscondbrtarget : Operand<OtherVT> {
727 let PrintMethod = "printAbsBranchOperand";
728 let EncoderMethod = "getAbsCondBrEncoding";
729 let ParserMatchClass = PPCCondBrAsmOperand;
731 def calltarget : Operand<iPTR> {
732 let PrintMethod = "printBranchOperand";
733 let EncoderMethod = "getDirectBrEncoding";
734 let ParserMatchClass = PPCDirectBrAsmOperand;
736 def abscalltarget : Operand<iPTR> {
737 let PrintMethod = "printAbsBranchOperand";
738 let EncoderMethod = "getAbsDirectBrEncoding";
739 let ParserMatchClass = PPCDirectBrAsmOperand;
741 def PPCCRBitMaskOperand : AsmOperandClass {
742 let Name = "CRBitMask"; let PredicateMethod = "isCRBitMask";
744 def crbitm: Operand<i8> {
745 let PrintMethod = "printcrbitm";
746 let EncoderMethod = "get_crbitm_encoding";
747 let DecoderMethod = "decodeCRBitMOperand";
748 let ParserMatchClass = PPCCRBitMaskOperand;
751 // A version of ptr_rc which excludes R0 (or X0 in 64-bit mode).
752 def PPCRegGxRCNoR0Operand : AsmOperandClass {
753 let Name = "RegGxRCNoR0"; let PredicateMethod = "isRegNumber";
755 def ptr_rc_nor0 : Operand<iPTR>, PointerLikeRegClass<1> {
756 let ParserMatchClass = PPCRegGxRCNoR0Operand;
758 // A version of ptr_rc usable with the asm parser.
759 def PPCRegGxRCOperand : AsmOperandClass {
760 let Name = "RegGxRC"; let PredicateMethod = "isRegNumber";
762 def ptr_rc_idx : Operand<iPTR>, PointerLikeRegClass<0> {
763 let ParserMatchClass = PPCRegGxRCOperand;
766 def PPCDispRIOperand : AsmOperandClass {
767 let Name = "DispRI"; let PredicateMethod = "isS16Imm";
768 let RenderMethod = "addS16ImmOperands";
770 def dispRI : Operand<iPTR> {
771 let ParserMatchClass = PPCDispRIOperand;
773 def PPCDispRIXOperand : AsmOperandClass {
774 let Name = "DispRIX"; let PredicateMethod = "isS16ImmX4";
775 let RenderMethod = "addImmOperands";
777 def dispRIX : Operand<iPTR> {
778 let ParserMatchClass = PPCDispRIXOperand;
780 def PPCDispRIX16Operand : AsmOperandClass {
781 let Name = "DispRIX16"; let PredicateMethod = "isS16ImmX16";
782 let RenderMethod = "addImmOperands";
784 def dispRIX16 : Operand<iPTR> {
785 let ParserMatchClass = PPCDispRIX16Operand;
787 def PPCDispSPE8Operand : AsmOperandClass {
788 let Name = "DispSPE8"; let PredicateMethod = "isU8ImmX8";
789 let RenderMethod = "addImmOperands";
791 def dispSPE8 : Operand<iPTR> {
792 let ParserMatchClass = PPCDispSPE8Operand;
794 def PPCDispSPE4Operand : AsmOperandClass {
795 let Name = "DispSPE4"; let PredicateMethod = "isU7ImmX4";
796 let RenderMethod = "addImmOperands";
798 def dispSPE4 : Operand<iPTR> {
799 let ParserMatchClass = PPCDispSPE4Operand;
801 def PPCDispSPE2Operand : AsmOperandClass {
802 let Name = "DispSPE2"; let PredicateMethod = "isU6ImmX2";
803 let RenderMethod = "addImmOperands";
805 def dispSPE2 : Operand<iPTR> {
806 let ParserMatchClass = PPCDispSPE2Operand;
809 def memri : Operand<iPTR> {
810 let PrintMethod = "printMemRegImm";
811 let MIOperandInfo = (ops dispRI:$imm, ptr_rc_nor0:$reg);
812 let EncoderMethod = "getMemRIEncoding";
813 let DecoderMethod = "decodeMemRIOperands";
815 def memrr : Operand<iPTR> {
816 let PrintMethod = "printMemRegReg";
817 let MIOperandInfo = (ops ptr_rc_nor0:$ptrreg, ptr_rc_idx:$offreg);
819 def memrix : Operand<iPTR> { // memri where the imm is 4-aligned.
820 let PrintMethod = "printMemRegImm";
821 let MIOperandInfo = (ops dispRIX:$imm, ptr_rc_nor0:$reg);
822 let EncoderMethod = "getMemRIXEncoding";
823 let DecoderMethod = "decodeMemRIXOperands";
825 def memrix16 : Operand<iPTR> { // memri, imm is 16-aligned, 12-bit, Inst{16:27}
826 let PrintMethod = "printMemRegImm";
827 let MIOperandInfo = (ops dispRIX16:$imm, ptr_rc_nor0:$reg);
828 let EncoderMethod = "getMemRIX16Encoding";
829 let DecoderMethod = "decodeMemRIX16Operands";
831 def spe8dis : Operand<iPTR> { // SPE displacement where the imm is 8-aligned.
832 let PrintMethod = "printMemRegImm";
833 let MIOperandInfo = (ops dispSPE8:$imm, ptr_rc_nor0:$reg);
834 let EncoderMethod = "getSPE8DisEncoding";
835 let DecoderMethod = "decodeSPE8Operands";
837 def spe4dis : Operand<iPTR> { // SPE displacement where the imm is 4-aligned.
838 let PrintMethod = "printMemRegImm";
839 let MIOperandInfo = (ops dispSPE4:$imm, ptr_rc_nor0:$reg);
840 let EncoderMethod = "getSPE4DisEncoding";
841 let DecoderMethod = "decodeSPE4Operands";
843 def spe2dis : Operand<iPTR> { // SPE displacement where the imm is 2-aligned.
844 let PrintMethod = "printMemRegImm";
845 let MIOperandInfo = (ops dispSPE2:$imm, ptr_rc_nor0:$reg);
846 let EncoderMethod = "getSPE2DisEncoding";
847 let DecoderMethod = "decodeSPE2Operands";
850 // A single-register address. This is used with the SjLj
851 // pseudo-instructions which tranlates to LD/LWZ. These instructions requires
852 // G8RC_NOX0 registers.
853 def memr : Operand<iPTR> {
854 let MIOperandInfo = (ops ptr_rc_nor0:$ptrreg);
856 def PPCTLSRegOperand : AsmOperandClass {
857 let Name = "TLSReg"; let PredicateMethod = "isTLSReg";
858 let RenderMethod = "addTLSRegOperands";
860 def tlsreg32 : Operand<i32> {
861 let EncoderMethod = "getTLSRegEncoding";
862 let ParserMatchClass = PPCTLSRegOperand;
864 def tlsgd32 : Operand<i32> {}
865 def tlscall32 : Operand<i32> {
866 let PrintMethod = "printTLSCall";
867 let MIOperandInfo = (ops calltarget:$func, tlsgd32:$sym);
868 let EncoderMethod = "getTLSCallEncoding";
871 // PowerPC Predicate operand.
872 def pred : Operand<OtherVT> {
873 let PrintMethod = "printPredicateOperand";
874 let MIOperandInfo = (ops i32imm:$bibo, crrc:$reg);
877 // Define PowerPC specific addressing mode.
878 def iaddr : ComplexPattern<iPTR, 2, "SelectAddrImm", [], []>;
879 def xaddr : ComplexPattern<iPTR, 2, "SelectAddrIdx", [], []>;
880 def xoaddr : ComplexPattern<iPTR, 2, "SelectAddrIdxOnly",[], []>;
881 def ixaddr : ComplexPattern<iPTR, 2, "SelectAddrImmX4", [], []>; // "std"
882 def iqaddr : ComplexPattern<iPTR, 2, "SelectAddrImmX16", [], []>; // "stxv"
884 // The address in a single register. This is used with the SjLj
885 // pseudo-instructions.
886 def addr : ComplexPattern<iPTR, 1, "SelectAddr",[], []>;
888 /// This is just the offset part of iaddr, used for preinc.
889 def iaddroff : ComplexPattern<iPTR, 1, "SelectAddrImmOffs", [], []>;
891 //===----------------------------------------------------------------------===//
892 // PowerPC Instruction Predicate Definitions.
893 def In32BitMode : Predicate<"!PPCSubTarget->isPPC64()">;
894 def In64BitMode : Predicate<"PPCSubTarget->isPPC64()">;
895 def IsBookE : Predicate<"PPCSubTarget->isBookE()">;
896 def IsNotBookE : Predicate<"!PPCSubTarget->isBookE()">;
897 def HasOnlyMSYNC : Predicate<"PPCSubTarget->hasOnlyMSYNC()">;
898 def HasSYNC : Predicate<"!PPCSubTarget->hasOnlyMSYNC()">;
899 def IsPPC4xx : Predicate<"PPCSubTarget->isPPC4xx()">;
900 def IsPPC6xx : Predicate<"PPCSubTarget->isPPC6xx()">;
901 def IsE500 : Predicate<"PPCSubTarget->isE500()">;
902 def HasSPE : Predicate<"PPCSubTarget->hasSPE()">;
903 def HasICBT : Predicate<"PPCSubTarget->hasICBT()">;
904 def HasPartwordAtomics : Predicate<"PPCSubTarget->hasPartwordAtomics()">;
905 def NoNaNsFPMath : Predicate<"TM.Options.NoNaNsFPMath">;
906 def NaNsFPMath : Predicate<"!TM.Options.NoNaNsFPMath">;
907 def HasBPERMD : Predicate<"PPCSubTarget->hasBPERMD()">;
908 def HasExtDiv : Predicate<"PPCSubTarget->hasExtDiv()">;
909 def IsISA3_0 : Predicate<"PPCSubTarget->isISA3_0()">;
910 def HasFPU : Predicate<"PPCSubTarget->hasFPU()">;
912 //===----------------------------------------------------------------------===//
913 // PowerPC Multiclass Definitions.
915 multiclass XForm_6r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
916 string asmbase, string asmstr, InstrItinClass itin,
918 let BaseName = asmbase in {
919 def NAME : XForm_6<opcode, xo, OOL, IOL,
920 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
921 pattern>, RecFormRel;
923 def o : XForm_6<opcode, xo, OOL, IOL,
924 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
925 []>, isDOT, RecFormRel;
929 multiclass XForm_6rc<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
930 string asmbase, string asmstr, InstrItinClass itin,
932 let BaseName = asmbase in {
933 let Defs = [CARRY] in
934 def NAME : XForm_6<opcode, xo, OOL, IOL,
935 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
936 pattern>, RecFormRel;
937 let Defs = [CARRY, CR0] in
938 def o : XForm_6<opcode, xo, OOL, IOL,
939 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
940 []>, isDOT, RecFormRel;
944 multiclass XForm_10rc<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
945 string asmbase, string asmstr, InstrItinClass itin,
947 let BaseName = asmbase in {
948 let Defs = [CARRY] in
949 def NAME : XForm_10<opcode, xo, OOL, IOL,
950 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
951 pattern>, RecFormRel;
952 let Defs = [CARRY, CR0] in
953 def o : XForm_10<opcode, xo, OOL, IOL,
954 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
955 []>, isDOT, RecFormRel;
959 multiclass XForm_11r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
960 string asmbase, string asmstr, InstrItinClass itin,
962 let BaseName = asmbase in {
963 def NAME : XForm_11<opcode, xo, OOL, IOL,
964 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
965 pattern>, RecFormRel;
967 def o : XForm_11<opcode, xo, OOL, IOL,
968 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
969 []>, isDOT, RecFormRel;
973 multiclass XOForm_1r<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
974 string asmbase, string asmstr, InstrItinClass itin,
976 let BaseName = asmbase in {
977 def NAME : XOForm_1<opcode, xo, oe, OOL, IOL,
978 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
979 pattern>, RecFormRel;
981 def o : XOForm_1<opcode, xo, oe, OOL, IOL,
982 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
983 []>, isDOT, RecFormRel;
987 // Multiclass for instructions for which the non record form is not cracked
988 // and the record form is cracked (i.e. divw, mullw, etc.)
989 multiclass XOForm_1rcr<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
990 string asmbase, string asmstr, InstrItinClass itin,
992 let BaseName = asmbase in {
993 def NAME : XOForm_1<opcode, xo, oe, OOL, IOL,
994 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
995 pattern>, RecFormRel;
997 def o : XOForm_1<opcode, xo, oe, OOL, IOL,
998 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
999 []>, isDOT, RecFormRel, PPC970_DGroup_First,
1000 PPC970_DGroup_Cracked;
1004 multiclass XOForm_1rc<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
1005 string asmbase, string asmstr, InstrItinClass itin,
1006 list<dag> pattern> {
1007 let BaseName = asmbase in {
1008 let Defs = [CARRY] in
1009 def NAME : XOForm_1<opcode, xo, oe, OOL, IOL,
1010 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1011 pattern>, RecFormRel;
1012 let Defs = [CARRY, CR0] in
1013 def o : XOForm_1<opcode, xo, oe, OOL, IOL,
1014 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1015 []>, isDOT, RecFormRel;
1019 multiclass XOForm_3r<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
1020 string asmbase, string asmstr, InstrItinClass itin,
1021 list<dag> pattern> {
1022 let BaseName = asmbase in {
1023 def NAME : XOForm_3<opcode, xo, oe, OOL, IOL,
1024 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1025 pattern>, RecFormRel;
1027 def o : XOForm_3<opcode, xo, oe, OOL, IOL,
1028 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1029 []>, isDOT, RecFormRel;
1033 multiclass XOForm_3rc<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
1034 string asmbase, string asmstr, InstrItinClass itin,
1035 list<dag> pattern> {
1036 let BaseName = asmbase in {
1037 let Defs = [CARRY] in
1038 def NAME : XOForm_3<opcode, xo, oe, OOL, IOL,
1039 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1040 pattern>, RecFormRel;
1041 let Defs = [CARRY, CR0] in
1042 def o : XOForm_3<opcode, xo, oe, OOL, IOL,
1043 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1044 []>, isDOT, RecFormRel;
1048 multiclass MForm_2r<bits<6> opcode, dag OOL, dag IOL,
1049 string asmbase, string asmstr, InstrItinClass itin,
1050 list<dag> pattern> {
1051 let BaseName = asmbase in {
1052 def NAME : MForm_2<opcode, OOL, IOL,
1053 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1054 pattern>, RecFormRel;
1056 def o : MForm_2<opcode, OOL, IOL,
1057 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1058 []>, isDOT, RecFormRel;
1062 multiclass MDForm_1r<bits<6> opcode, bits<3> xo, dag OOL, dag IOL,
1063 string asmbase, string asmstr, InstrItinClass itin,
1064 list<dag> pattern> {
1065 let BaseName = asmbase in {
1066 def NAME : MDForm_1<opcode, xo, OOL, IOL,
1067 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1068 pattern>, RecFormRel;
1070 def o : MDForm_1<opcode, xo, OOL, IOL,
1071 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1072 []>, isDOT, RecFormRel;
1076 multiclass MDSForm_1r<bits<6> opcode, bits<4> xo, dag OOL, dag IOL,
1077 string asmbase, string asmstr, InstrItinClass itin,
1078 list<dag> pattern> {
1079 let BaseName = asmbase in {
1080 def NAME : MDSForm_1<opcode, xo, OOL, IOL,
1081 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1082 pattern>, RecFormRel;
1084 def o : MDSForm_1<opcode, xo, OOL, IOL,
1085 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1086 []>, isDOT, RecFormRel;
1090 multiclass XSForm_1rc<bits<6> opcode, bits<9> xo, dag OOL, dag IOL,
1091 string asmbase, string asmstr, InstrItinClass itin,
1092 list<dag> pattern> {
1093 let BaseName = asmbase in {
1094 let Defs = [CARRY] in
1095 def NAME : XSForm_1<opcode, xo, OOL, IOL,
1096 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1097 pattern>, RecFormRel;
1098 let Defs = [CARRY, CR0] in
1099 def o : XSForm_1<opcode, xo, OOL, IOL,
1100 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1101 []>, isDOT, RecFormRel;
1105 multiclass XSForm_1r<bits<6> opcode, bits<9> xo, dag OOL, dag IOL,
1106 string asmbase, string asmstr, InstrItinClass itin,
1107 list<dag> pattern> {
1108 let BaseName = asmbase in {
1109 def NAME : XSForm_1<opcode, xo, OOL, IOL,
1110 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1111 pattern>, RecFormRel;
1113 def o : XSForm_1<opcode, xo, OOL, IOL,
1114 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1115 []>, isDOT, RecFormRel;
1119 multiclass XForm_26r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
1120 string asmbase, string asmstr, InstrItinClass itin,
1121 list<dag> pattern> {
1122 let BaseName = asmbase in {
1123 def NAME : XForm_26<opcode, xo, OOL, IOL,
1124 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1125 pattern>, RecFormRel;
1127 def o : XForm_26<opcode, xo, OOL, IOL,
1128 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1129 []>, isDOT, RecFormRel;
1133 multiclass XForm_28r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
1134 string asmbase, string asmstr, InstrItinClass itin,
1135 list<dag> pattern> {
1136 let BaseName = asmbase in {
1137 def NAME : XForm_28<opcode, xo, OOL, IOL,
1138 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1139 pattern>, RecFormRel;
1141 def o : XForm_28<opcode, xo, OOL, IOL,
1142 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1143 []>, isDOT, RecFormRel;
1147 multiclass AForm_1r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL,
1148 string asmbase, string asmstr, InstrItinClass itin,
1149 list<dag> pattern> {
1150 let BaseName = asmbase in {
1151 def NAME : AForm_1<opcode, xo, OOL, IOL,
1152 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1153 pattern>, RecFormRel;
1155 def o : AForm_1<opcode, xo, OOL, IOL,
1156 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1157 []>, isDOT, RecFormRel;
1161 multiclass AForm_2r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL,
1162 string asmbase, string asmstr, InstrItinClass itin,
1163 list<dag> pattern> {
1164 let BaseName = asmbase in {
1165 def NAME : AForm_2<opcode, xo, OOL, IOL,
1166 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1167 pattern>, RecFormRel;
1169 def o : AForm_2<opcode, xo, OOL, IOL,
1170 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1171 []>, isDOT, RecFormRel;
1175 multiclass AForm_3r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL,
1176 string asmbase, string asmstr, InstrItinClass itin,
1177 list<dag> pattern> {
1178 let BaseName = asmbase in {
1179 def NAME : AForm_3<opcode, xo, OOL, IOL,
1180 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1181 pattern>, RecFormRel;
1183 def o : AForm_3<opcode, xo, OOL, IOL,
1184 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1185 []>, isDOT, RecFormRel;
1189 //===----------------------------------------------------------------------===//
1190 // PowerPC Instruction Definitions.
1192 // Pseudo-instructions:
1194 let hasCtrlDep = 1 in {
1195 let Defs = [R1], Uses = [R1] in {
1196 def ADJCALLSTACKDOWN : Pseudo<(outs), (ins u16imm:$amt1, u16imm:$amt2),
1197 "#ADJCALLSTACKDOWN $amt1 $amt2",
1198 [(callseq_start timm:$amt1, timm:$amt2)]>;
1199 def ADJCALLSTACKUP : Pseudo<(outs), (ins u16imm:$amt1, u16imm:$amt2),
1200 "#ADJCALLSTACKUP $amt1 $amt2",
1201 [(callseq_end timm:$amt1, timm:$amt2)]>;
1204 def UPDATE_VRSAVE : Pseudo<(outs gprc:$rD), (ins gprc:$rS),
1205 "UPDATE_VRSAVE $rD, $rS", []>;
1208 let Defs = [R1], Uses = [R1] in
1209 def DYNALLOC : Pseudo<(outs gprc:$result), (ins gprc:$negsize, memri:$fpsi), "#DYNALLOC",
1211 (PPCdynalloc i32:$negsize, iaddr:$fpsi))]>;
1212 def DYNAREAOFFSET : Pseudo<(outs i32imm:$result), (ins memri:$fpsi), "#DYNAREAOFFSET",
1213 [(set i32:$result, (PPCdynareaoffset iaddr:$fpsi))]>;
1215 // SELECT_CC_* - Used to implement the SELECT_CC DAG operation. Expanded after
1216 // instruction selection into a branch sequence.
1217 let usesCustomInserter = 1, // Expanded after instruction selection.
1218 PPC970_Single = 1 in {
1219 // Note that SELECT_CC_I4 and SELECT_CC_I8 use the no-r0 register classes
1220 // because either operand might become the first operand in an isel, and
1221 // that operand cannot be r0.
1222 def SELECT_CC_I4 : Pseudo<(outs gprc:$dst), (ins crrc:$cond,
1223 gprc_nor0:$T, gprc_nor0:$F,
1224 i32imm:$BROPC), "#SELECT_CC_I4",
1226 def SELECT_CC_I8 : Pseudo<(outs g8rc:$dst), (ins crrc:$cond,
1227 g8rc_nox0:$T, g8rc_nox0:$F,
1228 i32imm:$BROPC), "#SELECT_CC_I8",
1230 def SELECT_CC_F4 : Pseudo<(outs f4rc:$dst), (ins crrc:$cond, f4rc:$T, f4rc:$F,
1231 i32imm:$BROPC), "#SELECT_CC_F4",
1233 def SELECT_CC_F8 : Pseudo<(outs f8rc:$dst), (ins crrc:$cond, f8rc:$T, f8rc:$F,
1234 i32imm:$BROPC), "#SELECT_CC_F8",
1236 def SELECT_CC_F16 : Pseudo<(outs vrrc:$dst), (ins crrc:$cond, vrrc:$T, vrrc:$F,
1237 i32imm:$BROPC), "#SELECT_CC_F16",
1239 def SELECT_CC_VRRC: Pseudo<(outs vrrc:$dst), (ins crrc:$cond, vrrc:$T, vrrc:$F,
1240 i32imm:$BROPC), "#SELECT_CC_VRRC",
1243 // SELECT_* pseudo instructions, like SELECT_CC_* but taking condition
1244 // register bit directly.
1245 def SELECT_I4 : Pseudo<(outs gprc:$dst), (ins crbitrc:$cond,
1246 gprc_nor0:$T, gprc_nor0:$F), "#SELECT_I4",
1247 [(set i32:$dst, (select i1:$cond, i32:$T, i32:$F))]>;
1248 def SELECT_I8 : Pseudo<(outs g8rc:$dst), (ins crbitrc:$cond,
1249 g8rc_nox0:$T, g8rc_nox0:$F), "#SELECT_I8",
1250 [(set i64:$dst, (select i1:$cond, i64:$T, i64:$F))]>;
1251 let Predicates = [HasFPU] in {
1252 def SELECT_F4 : Pseudo<(outs f4rc:$dst), (ins crbitrc:$cond,
1253 f4rc:$T, f4rc:$F), "#SELECT_F4",
1254 [(set f32:$dst, (select i1:$cond, f32:$T, f32:$F))]>;
1255 def SELECT_F8 : Pseudo<(outs f8rc:$dst), (ins crbitrc:$cond,
1256 f8rc:$T, f8rc:$F), "#SELECT_F8",
1257 [(set f64:$dst, (select i1:$cond, f64:$T, f64:$F))]>;
1258 def SELECT_F16 : Pseudo<(outs vrrc:$dst), (ins crbitrc:$cond,
1259 vrrc:$T, vrrc:$F), "#SELECT_F16",
1260 [(set f128:$dst, (select i1:$cond, f128:$T, f128:$F))]>;
1262 def SELECT_VRRC: Pseudo<(outs vrrc:$dst), (ins crbitrc:$cond,
1263 vrrc:$T, vrrc:$F), "#SELECT_VRRC",
1265 (select i1:$cond, v4i32:$T, v4i32:$F))]>;
1268 // SPILL_CR - Indicate that we're dumping the CR register, so we'll need to
1269 // scavenge a register for it.
1270 let mayStore = 1 in {
1271 def SPILL_CR : Pseudo<(outs), (ins crrc:$cond, memri:$F),
1273 def SPILL_CRBIT : Pseudo<(outs), (ins crbitrc:$cond, memri:$F),
1274 "#SPILL_CRBIT", []>;
1277 // RESTORE_CR - Indicate that we're restoring the CR register (previously
1278 // spilled), so we'll need to scavenge a register for it.
1279 let mayLoad = 1 in {
1280 def RESTORE_CR : Pseudo<(outs crrc:$cond), (ins memri:$F),
1282 def RESTORE_CRBIT : Pseudo<(outs crbitrc:$cond), (ins memri:$F),
1283 "#RESTORE_CRBIT", []>;
1286 let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7 in {
1287 let isReturn = 1, Uses = [LR, RM] in
1288 def BLR : XLForm_2_ext<19, 16, 20, 0, 0, (outs), (ins), "blr", IIC_BrB,
1289 [(retflag)]>, Requires<[In32BitMode]>;
1290 let isBranch = 1, isIndirectBranch = 1, Uses = [CTR] in {
1291 def BCTR : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
1294 let isCodeGenOnly = 1 in {
1295 def BCCCTR : XLForm_2_br<19, 528, 0, (outs), (ins pred:$cond),
1296 "b${cond:cc}ctr${cond:pm} ${cond:reg}", IIC_BrB,
1299 def BCCTR : XLForm_2_br2<19, 528, 12, 0, (outs), (ins crbitrc:$bi),
1300 "bcctr 12, $bi, 0", IIC_BrB, []>;
1301 def BCCTRn : XLForm_2_br2<19, 528, 4, 0, (outs), (ins crbitrc:$bi),
1302 "bcctr 4, $bi, 0", IIC_BrB, []>;
1308 def MovePCtoLR : Pseudo<(outs), (ins), "#MovePCtoLR", []>,
1311 def MoveGOTtoLR : Pseudo<(outs), (ins), "#MoveGOTtoLR", []>,
1314 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7 in {
1315 let isBarrier = 1 in {
1316 def B : IForm<18, 0, 0, (outs), (ins directbrtarget:$dst),
1319 def BA : IForm<18, 1, 0, (outs), (ins absdirectbrtarget:$dst),
1320 "ba $dst", IIC_BrB, []>;
1323 // BCC represents an arbitrary conditional branch on a predicate.
1324 // FIXME: should be able to write a pattern for PPCcondbranch, but can't use
1325 // a two-value operand where a dag node expects two operands. :(
1326 let isCodeGenOnly = 1 in {
1327 class BCC_class : BForm<16, 0, 0, (outs), (ins pred:$cond, condbrtarget:$dst),
1328 "b${cond:cc}${cond:pm} ${cond:reg}, $dst"
1329 /*[(PPCcondbranch crrc:$crS, imm:$opc, bb:$dst)]*/>;
1330 def BCC : BCC_class;
1332 // The same as BCC, except that it's not a terminator. Used for introducing
1333 // control flow dependency without creating new blocks.
1334 let isTerminator = 0 in def CTRL_DEP : BCC_class;
1336 def BCCA : BForm<16, 1, 0, (outs), (ins pred:$cond, abscondbrtarget:$dst),
1337 "b${cond:cc}a${cond:pm} ${cond:reg}, $dst">;
1339 let isReturn = 1, Uses = [LR, RM] in
1340 def BCCLR : XLForm_2_br<19, 16, 0, (outs), (ins pred:$cond),
1341 "b${cond:cc}lr${cond:pm} ${cond:reg}", IIC_BrB, []>;
1344 let isCodeGenOnly = 1 in {
1345 let Pattern = [(brcond i1:$bi, bb:$dst)] in
1346 def BC : BForm_4<16, 12, 0, 0, (outs), (ins crbitrc:$bi, condbrtarget:$dst),
1347 "bc 12, $bi, $dst">;
1349 let Pattern = [(brcond (not i1:$bi), bb:$dst)] in
1350 def BCn : BForm_4<16, 4, 0, 0, (outs), (ins crbitrc:$bi, condbrtarget:$dst),
1353 let isReturn = 1, Uses = [LR, RM] in
1354 def BCLR : XLForm_2_br2<19, 16, 12, 0, (outs), (ins crbitrc:$bi),
1355 "bclr 12, $bi, 0", IIC_BrB, []>;
1356 def BCLRn : XLForm_2_br2<19, 16, 4, 0, (outs), (ins crbitrc:$bi),
1357 "bclr 4, $bi, 0", IIC_BrB, []>;
1360 let isReturn = 1, Defs = [CTR], Uses = [CTR, LR, RM] in {
1361 def BDZLR : XLForm_2_ext<19, 16, 18, 0, 0, (outs), (ins),
1362 "bdzlr", IIC_BrB, []>;
1363 def BDNZLR : XLForm_2_ext<19, 16, 16, 0, 0, (outs), (ins),
1364 "bdnzlr", IIC_BrB, []>;
1365 def BDZLRp : XLForm_2_ext<19, 16, 27, 0, 0, (outs), (ins),
1366 "bdzlr+", IIC_BrB, []>;
1367 def BDNZLRp: XLForm_2_ext<19, 16, 25, 0, 0, (outs), (ins),
1368 "bdnzlr+", IIC_BrB, []>;
1369 def BDZLRm : XLForm_2_ext<19, 16, 26, 0, 0, (outs), (ins),
1370 "bdzlr-", IIC_BrB, []>;
1371 def BDNZLRm: XLForm_2_ext<19, 16, 24, 0, 0, (outs), (ins),
1372 "bdnzlr-", IIC_BrB, []>;
1375 let Defs = [CTR], Uses = [CTR] in {
1376 def BDZ : BForm_1<16, 18, 0, 0, (outs), (ins condbrtarget:$dst),
1378 def BDNZ : BForm_1<16, 16, 0, 0, (outs), (ins condbrtarget:$dst),
1380 def BDZA : BForm_1<16, 18, 1, 0, (outs), (ins abscondbrtarget:$dst),
1382 def BDNZA : BForm_1<16, 16, 1, 0, (outs), (ins abscondbrtarget:$dst),
1384 def BDZp : BForm_1<16, 27, 0, 0, (outs), (ins condbrtarget:$dst),
1386 def BDNZp: BForm_1<16, 25, 0, 0, (outs), (ins condbrtarget:$dst),
1388 def BDZAp : BForm_1<16, 27, 1, 0, (outs), (ins abscondbrtarget:$dst),
1390 def BDNZAp: BForm_1<16, 25, 1, 0, (outs), (ins abscondbrtarget:$dst),
1392 def BDZm : BForm_1<16, 26, 0, 0, (outs), (ins condbrtarget:$dst),
1394 def BDNZm: BForm_1<16, 24, 0, 0, (outs), (ins condbrtarget:$dst),
1396 def BDZAm : BForm_1<16, 26, 1, 0, (outs), (ins abscondbrtarget:$dst),
1398 def BDNZAm: BForm_1<16, 24, 1, 0, (outs), (ins abscondbrtarget:$dst),
1403 // The unconditional BCL used by the SjLj setjmp code.
1404 let isCall = 1, hasCtrlDep = 1, isCodeGenOnly = 1, PPC970_Unit = 7 in {
1405 let Defs = [LR], Uses = [RM] in {
1406 def BCLalways : BForm_2<16, 20, 31, 0, 1, (outs), (ins condbrtarget:$dst),
1407 "bcl 20, 31, $dst">;
1411 let isCall = 1, PPC970_Unit = 7, Defs = [LR] in {
1412 // Convenient aliases for call instructions
1413 let Uses = [RM] in {
1414 def BL : IForm<18, 0, 1, (outs), (ins calltarget:$func),
1415 "bl $func", IIC_BrB, []>; // See Pat patterns below.
1416 def BLA : IForm<18, 1, 1, (outs), (ins abscalltarget:$func),
1417 "bla $func", IIC_BrB, [(PPCcall (i32 imm:$func))]>;
1419 let isCodeGenOnly = 1 in {
1420 def BL_TLS : IForm<18, 0, 1, (outs), (ins tlscall32:$func),
1421 "bl $func", IIC_BrB, []>;
1422 def BCCL : BForm<16, 0, 1, (outs), (ins pred:$cond, condbrtarget:$dst),
1423 "b${cond:cc}l${cond:pm} ${cond:reg}, $dst">;
1424 def BCCLA : BForm<16, 1, 1, (outs), (ins pred:$cond, abscondbrtarget:$dst),
1425 "b${cond:cc}la${cond:pm} ${cond:reg}, $dst">;
1427 def BCL : BForm_4<16, 12, 0, 1, (outs),
1428 (ins crbitrc:$bi, condbrtarget:$dst),
1429 "bcl 12, $bi, $dst">;
1430 def BCLn : BForm_4<16, 4, 0, 1, (outs),
1431 (ins crbitrc:$bi, condbrtarget:$dst),
1432 "bcl 4, $bi, $dst">;
1435 let Uses = [CTR, RM] in {
1436 def BCTRL : XLForm_2_ext<19, 528, 20, 0, 1, (outs), (ins),
1437 "bctrl", IIC_BrB, [(PPCbctrl)]>,
1438 Requires<[In32BitMode]>;
1440 let isCodeGenOnly = 1 in {
1441 def BCCCTRL : XLForm_2_br<19, 528, 1, (outs), (ins pred:$cond),
1442 "b${cond:cc}ctrl${cond:pm} ${cond:reg}", IIC_BrB,
1445 def BCCTRL : XLForm_2_br2<19, 528, 12, 1, (outs), (ins crbitrc:$bi),
1446 "bcctrl 12, $bi, 0", IIC_BrB, []>;
1447 def BCCTRLn : XLForm_2_br2<19, 528, 4, 1, (outs), (ins crbitrc:$bi),
1448 "bcctrl 4, $bi, 0", IIC_BrB, []>;
1451 let Uses = [LR, RM] in {
1452 def BLRL : XLForm_2_ext<19, 16, 20, 0, 1, (outs), (ins),
1453 "blrl", IIC_BrB, []>;
1455 let isCodeGenOnly = 1 in {
1456 def BCCLRL : XLForm_2_br<19, 16, 1, (outs), (ins pred:$cond),
1457 "b${cond:cc}lrl${cond:pm} ${cond:reg}", IIC_BrB,
1460 def BCLRL : XLForm_2_br2<19, 16, 12, 1, (outs), (ins crbitrc:$bi),
1461 "bclrl 12, $bi, 0", IIC_BrB, []>;
1462 def BCLRLn : XLForm_2_br2<19, 16, 4, 1, (outs), (ins crbitrc:$bi),
1463 "bclrl 4, $bi, 0", IIC_BrB, []>;
1466 let Defs = [CTR], Uses = [CTR, RM] in {
1467 def BDZL : BForm_1<16, 18, 0, 1, (outs), (ins condbrtarget:$dst),
1469 def BDNZL : BForm_1<16, 16, 0, 1, (outs), (ins condbrtarget:$dst),
1471 def BDZLA : BForm_1<16, 18, 1, 1, (outs), (ins abscondbrtarget:$dst),
1473 def BDNZLA : BForm_1<16, 16, 1, 1, (outs), (ins abscondbrtarget:$dst),
1475 def BDZLp : BForm_1<16, 27, 0, 1, (outs), (ins condbrtarget:$dst),
1477 def BDNZLp: BForm_1<16, 25, 0, 1, (outs), (ins condbrtarget:$dst),
1479 def BDZLAp : BForm_1<16, 27, 1, 1, (outs), (ins abscondbrtarget:$dst),
1481 def BDNZLAp: BForm_1<16, 25, 1, 1, (outs), (ins abscondbrtarget:$dst),
1483 def BDZLm : BForm_1<16, 26, 0, 1, (outs), (ins condbrtarget:$dst),
1485 def BDNZLm: BForm_1<16, 24, 0, 1, (outs), (ins condbrtarget:$dst),
1487 def BDZLAm : BForm_1<16, 26, 1, 1, (outs), (ins abscondbrtarget:$dst),
1489 def BDNZLAm: BForm_1<16, 24, 1, 1, (outs), (ins abscondbrtarget:$dst),
1492 let Defs = [CTR], Uses = [CTR, LR, RM] in {
1493 def BDZLRL : XLForm_2_ext<19, 16, 18, 0, 1, (outs), (ins),
1494 "bdzlrl", IIC_BrB, []>;
1495 def BDNZLRL : XLForm_2_ext<19, 16, 16, 0, 1, (outs), (ins),
1496 "bdnzlrl", IIC_BrB, []>;
1497 def BDZLRLp : XLForm_2_ext<19, 16, 27, 0, 1, (outs), (ins),
1498 "bdzlrl+", IIC_BrB, []>;
1499 def BDNZLRLp: XLForm_2_ext<19, 16, 25, 0, 1, (outs), (ins),
1500 "bdnzlrl+", IIC_BrB, []>;
1501 def BDZLRLm : XLForm_2_ext<19, 16, 26, 0, 1, (outs), (ins),
1502 "bdzlrl-", IIC_BrB, []>;
1503 def BDNZLRLm: XLForm_2_ext<19, 16, 24, 0, 1, (outs), (ins),
1504 "bdnzlrl-", IIC_BrB, []>;
1508 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
1509 def TCRETURNdi :Pseudo< (outs),
1510 (ins calltarget:$dst, i32imm:$offset),
1511 "#TC_RETURNd $dst $offset",
1515 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
1516 def TCRETURNai :Pseudo<(outs), (ins abscalltarget:$func, i32imm:$offset),
1517 "#TC_RETURNa $func $offset",
1518 [(PPCtc_return (i32 imm:$func), imm:$offset)]>;
1520 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
1521 def TCRETURNri : Pseudo<(outs), (ins CTRRC:$dst, i32imm:$offset),
1522 "#TC_RETURNr $dst $offset",
1526 let isCodeGenOnly = 1 in {
1528 let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, isBranch = 1,
1529 isIndirectBranch = 1, isCall = 1, isReturn = 1, Uses = [CTR, RM] in
1530 def TAILBCTR : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
1531 []>, Requires<[In32BitMode]>;
1533 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
1534 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
1535 def TAILB : IForm<18, 0, 0, (outs), (ins calltarget:$dst),
1539 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
1540 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
1541 def TAILBA : IForm<18, 0, 0, (outs), (ins abscalltarget:$dst),
1547 let hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
1549 def EH_SjLj_SetJmp32 : Pseudo<(outs gprc:$dst), (ins memr:$buf),
1550 "#EH_SJLJ_SETJMP32",
1551 [(set i32:$dst, (PPCeh_sjlj_setjmp addr:$buf))]>,
1552 Requires<[In32BitMode]>;
1553 let isTerminator = 1 in
1554 def EH_SjLj_LongJmp32 : Pseudo<(outs), (ins memr:$buf),
1555 "#EH_SJLJ_LONGJMP32",
1556 [(PPCeh_sjlj_longjmp addr:$buf)]>,
1557 Requires<[In32BitMode]>;
1560 // This pseudo is never removed from the function, as it serves as
1561 // a terminator. Size is set to 0 to prevent the builtin assembler
1562 // from emitting it.
1563 let isBranch = 1, isTerminator = 1, Size = 0 in {
1564 def EH_SjLj_Setup : Pseudo<(outs), (ins directbrtarget:$dst),
1565 "#EH_SjLj_Setup\t$dst", []>;
1569 let PPC970_Unit = 7 in {
1570 def SC : SCForm<17, 1, (outs), (ins i32imm:$lev),
1571 "sc $lev", IIC_BrB, [(PPCsc (i32 imm:$lev))]>;
1574 // Branch history rolling buffer.
1575 def CLRBHRB : XForm_0<31, 430, (outs), (ins), "clrbhrb", IIC_BrB,
1577 PPC970_DGroup_Single;
1578 // The $dmy argument used for MFBHRBE is not needed; however, including
1579 // it avoids automatic generation of PPCFastISel::fastEmit_i(), which
1580 // interferes with necessary special handling (see PPCFastISel.cpp).
1581 def MFBHRBE : XFXForm_3p<31, 302, (outs gprc:$rD),
1582 (ins u10imm:$imm, u10imm:$dmy),
1583 "mfbhrbe $rD, $imm", IIC_BrB,
1585 (PPCmfbhrbe imm:$imm, imm:$dmy))]>,
1586 PPC970_DGroup_First;
1588 def RFEBB : XLForm_S<19, 146, (outs), (ins u1imm:$imm), "rfebb $imm",
1589 IIC_BrB, [(PPCrfebb (i32 imm:$imm))]>,
1590 PPC970_DGroup_Single;
1592 // DCB* instructions.
1593 def DCBA : DCB_Form<758, 0, (outs), (ins memrr:$dst), "dcba $dst",
1594 IIC_LdStDCBF, [(int_ppc_dcba xoaddr:$dst)]>,
1595 PPC970_DGroup_Single;
1596 def DCBI : DCB_Form<470, 0, (outs), (ins memrr:$dst), "dcbi $dst",
1597 IIC_LdStDCBF, [(int_ppc_dcbi xoaddr:$dst)]>,
1598 PPC970_DGroup_Single;
1599 def DCBST : DCB_Form<54, 0, (outs), (ins memrr:$dst), "dcbst $dst",
1600 IIC_LdStDCBF, [(int_ppc_dcbst xoaddr:$dst)]>,
1601 PPC970_DGroup_Single;
1602 def DCBZ : DCB_Form<1014, 0, (outs), (ins memrr:$dst), "dcbz $dst",
1603 IIC_LdStDCBF, [(int_ppc_dcbz xoaddr:$dst)]>,
1604 PPC970_DGroup_Single;
1605 def DCBZL : DCB_Form<1014, 1, (outs), (ins memrr:$dst), "dcbzl $dst",
1606 IIC_LdStDCBF, [(int_ppc_dcbzl xoaddr:$dst)]>,
1607 PPC970_DGroup_Single;
1609 def DCBF : DCB_Form_hint<86, (outs), (ins u5imm:$TH, memrr:$dst),
1610 "dcbf $dst, $TH", IIC_LdStDCBF, []>,
1611 PPC970_DGroup_Single;
1613 let hasSideEffects = 0, mayLoad = 1, mayStore = 1 in {
1614 def DCBT : DCB_Form_hint<278, (outs), (ins u5imm:$TH, memrr:$dst),
1615 "dcbt $dst, $TH", IIC_LdStDCBF, []>,
1616 PPC970_DGroup_Single;
1617 def DCBTST : DCB_Form_hint<246, (outs), (ins u5imm:$TH, memrr:$dst),
1618 "dcbtst $dst, $TH", IIC_LdStDCBF, []>,
1619 PPC970_DGroup_Single;
1620 } // hasSideEffects = 0
1622 def ICBLC : XForm_icbt<31, 230, (outs), (ins u4imm:$CT, memrr:$src),
1623 "icblc $CT, $src", IIC_LdStStore>, Requires<[HasICBT]>;
1624 def ICBLQ : XForm_icbt<31, 198, (outs), (ins u4imm:$CT, memrr:$src),
1625 "icblq. $CT, $src", IIC_LdStLoad>, Requires<[HasICBT]>;
1626 def ICBT : XForm_icbt<31, 22, (outs), (ins u4imm:$CT, memrr:$src),
1627 "icbt $CT, $src", IIC_LdStLoad>, Requires<[HasICBT]>;
1628 def ICBTLS : XForm_icbt<31, 486, (outs), (ins u4imm:$CT, memrr:$src),
1629 "icbtls $CT, $src", IIC_LdStLoad>, Requires<[HasICBT]>;
1631 def : Pat<(int_ppc_dcbt xoaddr:$dst),
1632 (DCBT 0, xoaddr:$dst)>;
1633 def : Pat<(int_ppc_dcbtst xoaddr:$dst),
1634 (DCBTST 0, xoaddr:$dst)>;
1635 def : Pat<(int_ppc_dcbf xoaddr:$dst),
1636 (DCBF 0, xoaddr:$dst)>;
1638 def : Pat<(prefetch xoaddr:$dst, (i32 0), imm, (i32 1)),
1639 (DCBT 0, xoaddr:$dst)>; // data prefetch for loads
1640 def : Pat<(prefetch xoaddr:$dst, (i32 1), imm, (i32 1)),
1641 (DCBTST 0, xoaddr:$dst)>; // data prefetch for stores
1642 def : Pat<(prefetch xoaddr:$dst, (i32 0), imm, (i32 0)),
1643 (ICBT 0, xoaddr:$dst)>, Requires<[HasICBT]>; // inst prefetch (for read)
1645 // Atomic operations
1646 // FIXME: some of these might be used with constant operands. This will result
1647 // in constant materialization instructions that may be redundant. We currently
1648 // clean this up in PPCMIPeephole with calls to
1649 // PPCInstrInfo::convertToImmediateForm() but we should probably not emit them
1650 // in the first place.
1651 let usesCustomInserter = 1 in {
1652 let Defs = [CR0] in {
1653 def ATOMIC_LOAD_ADD_I8 : Pseudo<
1654 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I8",
1655 [(set i32:$dst, (atomic_load_add_8 xoaddr:$ptr, i32:$incr))]>;
1656 def ATOMIC_LOAD_SUB_I8 : Pseudo<
1657 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I8",
1658 [(set i32:$dst, (atomic_load_sub_8 xoaddr:$ptr, i32:$incr))]>;
1659 def ATOMIC_LOAD_AND_I8 : Pseudo<
1660 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I8",
1661 [(set i32:$dst, (atomic_load_and_8 xoaddr:$ptr, i32:$incr))]>;
1662 def ATOMIC_LOAD_OR_I8 : Pseudo<
1663 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I8",
1664 [(set i32:$dst, (atomic_load_or_8 xoaddr:$ptr, i32:$incr))]>;
1665 def ATOMIC_LOAD_XOR_I8 : Pseudo<
1666 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "ATOMIC_LOAD_XOR_I8",
1667 [(set i32:$dst, (atomic_load_xor_8 xoaddr:$ptr, i32:$incr))]>;
1668 def ATOMIC_LOAD_NAND_I8 : Pseudo<
1669 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I8",
1670 [(set i32:$dst, (atomic_load_nand_8 xoaddr:$ptr, i32:$incr))]>;
1671 def ATOMIC_LOAD_MIN_I8 : Pseudo<
1672 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MIN_I8",
1673 [(set i32:$dst, (atomic_load_min_8 xoaddr:$ptr, i32:$incr))]>;
1674 def ATOMIC_LOAD_MAX_I8 : Pseudo<
1675 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MAX_I8",
1676 [(set i32:$dst, (atomic_load_max_8 xoaddr:$ptr, i32:$incr))]>;
1677 def ATOMIC_LOAD_UMIN_I8 : Pseudo<
1678 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMIN_I8",
1679 [(set i32:$dst, (atomic_load_umin_8 xoaddr:$ptr, i32:$incr))]>;
1680 def ATOMIC_LOAD_UMAX_I8 : Pseudo<
1681 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMAX_I8",
1682 [(set i32:$dst, (atomic_load_umax_8 xoaddr:$ptr, i32:$incr))]>;
1683 def ATOMIC_LOAD_ADD_I16 : Pseudo<
1684 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I16",
1685 [(set i32:$dst, (atomic_load_add_16 xoaddr:$ptr, i32:$incr))]>;
1686 def ATOMIC_LOAD_SUB_I16 : Pseudo<
1687 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I16",
1688 [(set i32:$dst, (atomic_load_sub_16 xoaddr:$ptr, i32:$incr))]>;
1689 def ATOMIC_LOAD_AND_I16 : Pseudo<
1690 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I16",
1691 [(set i32:$dst, (atomic_load_and_16 xoaddr:$ptr, i32:$incr))]>;
1692 def ATOMIC_LOAD_OR_I16 : Pseudo<
1693 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I16",
1694 [(set i32:$dst, (atomic_load_or_16 xoaddr:$ptr, i32:$incr))]>;
1695 def ATOMIC_LOAD_XOR_I16 : Pseudo<
1696 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_XOR_I16",
1697 [(set i32:$dst, (atomic_load_xor_16 xoaddr:$ptr, i32:$incr))]>;
1698 def ATOMIC_LOAD_NAND_I16 : Pseudo<
1699 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I16",
1700 [(set i32:$dst, (atomic_load_nand_16 xoaddr:$ptr, i32:$incr))]>;
1701 def ATOMIC_LOAD_MIN_I16 : Pseudo<
1702 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MIN_I16",
1703 [(set i32:$dst, (atomic_load_min_16 xoaddr:$ptr, i32:$incr))]>;
1704 def ATOMIC_LOAD_MAX_I16 : Pseudo<
1705 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MAX_I16",
1706 [(set i32:$dst, (atomic_load_max_16 xoaddr:$ptr, i32:$incr))]>;
1707 def ATOMIC_LOAD_UMIN_I16 : Pseudo<
1708 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMIN_I16",
1709 [(set i32:$dst, (atomic_load_umin_16 xoaddr:$ptr, i32:$incr))]>;
1710 def ATOMIC_LOAD_UMAX_I16 : Pseudo<
1711 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMAX_I16",
1712 [(set i32:$dst, (atomic_load_umax_16 xoaddr:$ptr, i32:$incr))]>;
1713 def ATOMIC_LOAD_ADD_I32 : Pseudo<
1714 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I32",
1715 [(set i32:$dst, (atomic_load_add_32 xoaddr:$ptr, i32:$incr))]>;
1716 def ATOMIC_LOAD_SUB_I32 : Pseudo<
1717 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I32",
1718 [(set i32:$dst, (atomic_load_sub_32 xoaddr:$ptr, i32:$incr))]>;
1719 def ATOMIC_LOAD_AND_I32 : Pseudo<
1720 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I32",
1721 [(set i32:$dst, (atomic_load_and_32 xoaddr:$ptr, i32:$incr))]>;
1722 def ATOMIC_LOAD_OR_I32 : Pseudo<
1723 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I32",
1724 [(set i32:$dst, (atomic_load_or_32 xoaddr:$ptr, i32:$incr))]>;
1725 def ATOMIC_LOAD_XOR_I32 : Pseudo<
1726 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_XOR_I32",
1727 [(set i32:$dst, (atomic_load_xor_32 xoaddr:$ptr, i32:$incr))]>;
1728 def ATOMIC_LOAD_NAND_I32 : Pseudo<
1729 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I32",
1730 [(set i32:$dst, (atomic_load_nand_32 xoaddr:$ptr, i32:$incr))]>;
1731 def ATOMIC_LOAD_MIN_I32 : Pseudo<
1732 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MIN_I32",
1733 [(set i32:$dst, (atomic_load_min_32 xoaddr:$ptr, i32:$incr))]>;
1734 def ATOMIC_LOAD_MAX_I32 : Pseudo<
1735 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MAX_I32",
1736 [(set i32:$dst, (atomic_load_max_32 xoaddr:$ptr, i32:$incr))]>;
1737 def ATOMIC_LOAD_UMIN_I32 : Pseudo<
1738 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMIN_I32",
1739 [(set i32:$dst, (atomic_load_umin_32 xoaddr:$ptr, i32:$incr))]>;
1740 def ATOMIC_LOAD_UMAX_I32 : Pseudo<
1741 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMAX_I32",
1742 [(set i32:$dst, (atomic_load_umax_32 xoaddr:$ptr, i32:$incr))]>;
1744 def ATOMIC_CMP_SWAP_I8 : Pseudo<
1745 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I8",
1746 [(set i32:$dst, (atomic_cmp_swap_8 xoaddr:$ptr, i32:$old, i32:$new))]>;
1747 def ATOMIC_CMP_SWAP_I16 : Pseudo<
1748 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I16 $dst $ptr $old $new",
1749 [(set i32:$dst, (atomic_cmp_swap_16 xoaddr:$ptr, i32:$old, i32:$new))]>;
1750 def ATOMIC_CMP_SWAP_I32 : Pseudo<
1751 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I32 $dst $ptr $old $new",
1752 [(set i32:$dst, (atomic_cmp_swap_32 xoaddr:$ptr, i32:$old, i32:$new))]>;
1754 def ATOMIC_SWAP_I8 : Pseudo<
1755 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_i8",
1756 [(set i32:$dst, (atomic_swap_8 xoaddr:$ptr, i32:$new))]>;
1757 def ATOMIC_SWAP_I16 : Pseudo<
1758 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_I16",
1759 [(set i32:$dst, (atomic_swap_16 xoaddr:$ptr, i32:$new))]>;
1760 def ATOMIC_SWAP_I32 : Pseudo<
1761 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_I32",
1762 [(set i32:$dst, (atomic_swap_32 xoaddr:$ptr, i32:$new))]>;
1766 def : Pat<(PPCatomicCmpSwap_8 xoaddr:$ptr, i32:$old, i32:$new),
1767 (ATOMIC_CMP_SWAP_I8 xoaddr:$ptr, i32:$old, i32:$new)>;
1768 def : Pat<(PPCatomicCmpSwap_16 xoaddr:$ptr, i32:$old, i32:$new),
1769 (ATOMIC_CMP_SWAP_I16 xoaddr:$ptr, i32:$old, i32:$new)>;
1771 // Instructions to support atomic operations
1772 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in {
1773 def LBARX : XForm_1_memOp<31, 52, (outs gprc:$rD), (ins memrr:$src),
1774 "lbarx $rD, $src", IIC_LdStLWARX, []>,
1775 Requires<[HasPartwordAtomics]>;
1777 def LHARX : XForm_1_memOp<31, 116, (outs gprc:$rD), (ins memrr:$src),
1778 "lharx $rD, $src", IIC_LdStLWARX, []>,
1779 Requires<[HasPartwordAtomics]>;
1781 def LWARX : XForm_1_memOp<31, 20, (outs gprc:$rD), (ins memrr:$src),
1782 "lwarx $rD, $src", IIC_LdStLWARX, []>;
1784 // Instructions to support lock versions of atomics
1785 // (EH=1 - see Power ISA 2.07 Book II 4.4.2)
1786 def LBARXL : XForm_1_memOp<31, 52, (outs gprc:$rD), (ins memrr:$src),
1787 "lbarx $rD, $src, 1", IIC_LdStLWARX, []>, isDOT,
1788 Requires<[HasPartwordAtomics]>;
1790 def LHARXL : XForm_1_memOp<31, 116, (outs gprc:$rD), (ins memrr:$src),
1791 "lharx $rD, $src, 1", IIC_LdStLWARX, []>, isDOT,
1792 Requires<[HasPartwordAtomics]>;
1794 def LWARXL : XForm_1_memOp<31, 20, (outs gprc:$rD), (ins memrr:$src),
1795 "lwarx $rD, $src, 1", IIC_LdStLWARX, []>, isDOT;
1797 // The atomic instructions use the destination register as well as the next one
1798 // or two registers in order (modulo 31).
1799 let hasExtraSrcRegAllocReq = 1 in
1800 def LWAT : X_RD5_RS5_IM5<31, 582, (outs gprc:$rD), (ins gprc:$rA, u5imm:$FC),
1801 "lwat $rD, $rA, $FC", IIC_LdStLoad>,
1802 Requires<[IsISA3_0]>;
1805 let Defs = [CR0], mayStore = 1, mayLoad = 0, hasSideEffects = 0 in {
1806 def STBCX : XForm_1_memOp<31, 694, (outs), (ins gprc:$rS, memrr:$dst),
1807 "stbcx. $rS, $dst", IIC_LdStSTWCX, []>,
1808 isDOT, Requires<[HasPartwordAtomics]>;
1810 def STHCX : XForm_1_memOp<31, 726, (outs), (ins gprc:$rS, memrr:$dst),
1811 "sthcx. $rS, $dst", IIC_LdStSTWCX, []>,
1812 isDOT, Requires<[HasPartwordAtomics]>;
1814 def STWCX : XForm_1_memOp<31, 150, (outs), (ins gprc:$rS, memrr:$dst),
1815 "stwcx. $rS, $dst", IIC_LdStSTWCX, []>, isDOT;
1818 let mayStore = 1, mayLoad = 0, hasSideEffects = 0 in
1819 def STWAT : X_RD5_RS5_IM5<31, 710, (outs), (ins gprc:$rS, gprc:$rA, u5imm:$FC),
1820 "stwat $rS, $rA, $FC", IIC_LdStStore>,
1821 Requires<[IsISA3_0]>;
1823 let isTerminator = 1, isBarrier = 1, hasCtrlDep = 1 in
1824 def TRAP : XForm_24<31, 4, (outs), (ins), "trap", IIC_LdStLoad, [(trap)]>;
1826 def TWI : DForm_base<3, (outs), (ins u5imm:$to, gprc:$rA, s16imm:$imm),
1827 "twi $to, $rA, $imm", IIC_IntTrapW, []>;
1828 def TW : XForm_1<31, 4, (outs), (ins u5imm:$to, gprc:$rA, gprc:$rB),
1829 "tw $to, $rA, $rB", IIC_IntTrapW, []>;
1830 def TDI : DForm_base<2, (outs), (ins u5imm:$to, g8rc:$rA, s16imm:$imm),
1831 "tdi $to, $rA, $imm", IIC_IntTrapD, []>;
1832 def TD : XForm_1<31, 68, (outs), (ins u5imm:$to, g8rc:$rA, g8rc:$rB),
1833 "td $to, $rA, $rB", IIC_IntTrapD, []>;
1835 //===----------------------------------------------------------------------===//
1836 // PPC32 Load Instructions.
1839 // Unindexed (r+i) Loads.
1840 let PPC970_Unit = 2 in {
1841 def LBZ : DForm_1<34, (outs gprc:$rD), (ins memri:$src),
1842 "lbz $rD, $src", IIC_LdStLoad,
1843 [(set i32:$rD, (zextloadi8 iaddr:$src))]>;
1844 def LHA : DForm_1<42, (outs gprc:$rD), (ins memri:$src),
1845 "lha $rD, $src", IIC_LdStLHA,
1846 [(set i32:$rD, (sextloadi16 iaddr:$src))]>,
1847 PPC970_DGroup_Cracked;
1848 def LHZ : DForm_1<40, (outs gprc:$rD), (ins memri:$src),
1849 "lhz $rD, $src", IIC_LdStLoad,
1850 [(set i32:$rD, (zextloadi16 iaddr:$src))]>;
1851 def LWZ : DForm_1<32, (outs gprc:$rD), (ins memri:$src),
1852 "lwz $rD, $src", IIC_LdStLoad,
1853 [(set i32:$rD, (load iaddr:$src))]>;
1855 let Predicates = [HasFPU] in {
1856 def LFS : DForm_1<48, (outs f4rc:$rD), (ins memri:$src),
1857 "lfs $rD, $src", IIC_LdStLFD,
1858 [(set f32:$rD, (load iaddr:$src))]>;
1859 def LFD : DForm_1<50, (outs f8rc:$rD), (ins memri:$src),
1860 "lfd $rD, $src", IIC_LdStLFD,
1861 [(set f64:$rD, (load iaddr:$src))]>;
1865 // Unindexed (r+i) Loads with Update (preinc).
1866 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in {
1867 def LBZU : DForm_1<35, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1868 "lbzu $rD, $addr", IIC_LdStLoadUpd,
1869 []>, RegConstraint<"$addr.reg = $ea_result">,
1870 NoEncode<"$ea_result">;
1872 def LHAU : DForm_1<43, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1873 "lhau $rD, $addr", IIC_LdStLHAU,
1874 []>, RegConstraint<"$addr.reg = $ea_result">,
1875 NoEncode<"$ea_result">;
1877 def LHZU : DForm_1<41, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1878 "lhzu $rD, $addr", IIC_LdStLoadUpd,
1879 []>, RegConstraint<"$addr.reg = $ea_result">,
1880 NoEncode<"$ea_result">;
1882 def LWZU : DForm_1<33, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1883 "lwzu $rD, $addr", IIC_LdStLoadUpd,
1884 []>, RegConstraint<"$addr.reg = $ea_result">,
1885 NoEncode<"$ea_result">;
1887 let Predicates = [HasFPU] in {
1888 def LFSU : DForm_1<49, (outs f4rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1889 "lfsu $rD, $addr", IIC_LdStLFDU,
1890 []>, RegConstraint<"$addr.reg = $ea_result">,
1891 NoEncode<"$ea_result">;
1893 def LFDU : DForm_1<51, (outs f8rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1894 "lfdu $rD, $addr", IIC_LdStLFDU,
1895 []>, RegConstraint<"$addr.reg = $ea_result">,
1896 NoEncode<"$ea_result">;
1900 // Indexed (r+r) Loads with Update (preinc).
1901 def LBZUX : XForm_1_memOp<31, 119, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1903 "lbzux $rD, $addr", IIC_LdStLoadUpdX,
1904 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1905 NoEncode<"$ea_result">;
1907 def LHAUX : XForm_1_memOp<31, 375, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1909 "lhaux $rD, $addr", IIC_LdStLHAUX,
1910 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1911 NoEncode<"$ea_result">;
1913 def LHZUX : XForm_1_memOp<31, 311, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1915 "lhzux $rD, $addr", IIC_LdStLoadUpdX,
1916 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1917 NoEncode<"$ea_result">;
1919 def LWZUX : XForm_1_memOp<31, 55, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1921 "lwzux $rD, $addr", IIC_LdStLoadUpdX,
1922 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1923 NoEncode<"$ea_result">;
1925 let Predicates = [HasFPU] in {
1926 def LFSUX : XForm_1_memOp<31, 567, (outs f4rc:$rD, ptr_rc_nor0:$ea_result),
1928 "lfsux $rD, $addr", IIC_LdStLFDUX,
1929 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1930 NoEncode<"$ea_result">;
1932 def LFDUX : XForm_1_memOp<31, 631, (outs f8rc:$rD, ptr_rc_nor0:$ea_result),
1934 "lfdux $rD, $addr", IIC_LdStLFDUX,
1935 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1936 NoEncode<"$ea_result">;
1941 // Indexed (r+r) Loads.
1943 let PPC970_Unit = 2, mayLoad = 1, mayStore = 0 in {
1944 def LBZX : XForm_1_memOp<31, 87, (outs gprc:$rD), (ins memrr:$src),
1945 "lbzx $rD, $src", IIC_LdStLoad,
1946 [(set i32:$rD, (zextloadi8 xaddr:$src))]>;
1947 def LHAX : XForm_1_memOp<31, 343, (outs gprc:$rD), (ins memrr:$src),
1948 "lhax $rD, $src", IIC_LdStLHA,
1949 [(set i32:$rD, (sextloadi16 xaddr:$src))]>,
1950 PPC970_DGroup_Cracked;
1951 def LHZX : XForm_1_memOp<31, 279, (outs gprc:$rD), (ins memrr:$src),
1952 "lhzx $rD, $src", IIC_LdStLoad,
1953 [(set i32:$rD, (zextloadi16 xaddr:$src))]>;
1954 def LWZX : XForm_1_memOp<31, 23, (outs gprc:$rD), (ins memrr:$src),
1955 "lwzx $rD, $src", IIC_LdStLoad,
1956 [(set i32:$rD, (load xaddr:$src))]>;
1957 def LHBRX : XForm_1_memOp<31, 790, (outs gprc:$rD), (ins memrr:$src),
1958 "lhbrx $rD, $src", IIC_LdStLoad,
1959 [(set i32:$rD, (PPClbrx xoaddr:$src, i16))]>;
1960 def LWBRX : XForm_1_memOp<31, 534, (outs gprc:$rD), (ins memrr:$src),
1961 "lwbrx $rD, $src", IIC_LdStLoad,
1962 [(set i32:$rD, (PPClbrx xoaddr:$src, i32))]>;
1964 let Predicates = [HasFPU] in {
1965 def LFSX : XForm_25_memOp<31, 535, (outs f4rc:$frD), (ins memrr:$src),
1966 "lfsx $frD, $src", IIC_LdStLFD,
1967 [(set f32:$frD, (load xaddr:$src))]>;
1968 def LFDX : XForm_25_memOp<31, 599, (outs f8rc:$frD), (ins memrr:$src),
1969 "lfdx $frD, $src", IIC_LdStLFD,
1970 [(set f64:$frD, (load xaddr:$src))]>;
1972 def LFIWAX : XForm_25_memOp<31, 855, (outs f8rc:$frD), (ins memrr:$src),
1973 "lfiwax $frD, $src", IIC_LdStLFD,
1974 [(set f64:$frD, (PPClfiwax xoaddr:$src))]>;
1975 def LFIWZX : XForm_25_memOp<31, 887, (outs f8rc:$frD), (ins memrr:$src),
1976 "lfiwzx $frD, $src", IIC_LdStLFD,
1977 [(set f64:$frD, (PPClfiwzx xoaddr:$src))]>;
1982 def LMW : DForm_1<46, (outs gprc:$rD), (ins memri:$src),
1983 "lmw $rD, $src", IIC_LdStLMW, []>;
1985 //===----------------------------------------------------------------------===//
1986 // PPC32 Store Instructions.
1989 // Unindexed (r+i) Stores.
1990 let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in {
1991 def STB : DForm_1<38, (outs), (ins gprc:$rS, memri:$src),
1992 "stb $rS, $src", IIC_LdStStore,
1993 [(truncstorei8 i32:$rS, iaddr:$src)]>;
1994 def STH : DForm_1<44, (outs), (ins gprc:$rS, memri:$src),
1995 "sth $rS, $src", IIC_LdStStore,
1996 [(truncstorei16 i32:$rS, iaddr:$src)]>;
1997 def STW : DForm_1<36, (outs), (ins gprc:$rS, memri:$src),
1998 "stw $rS, $src", IIC_LdStStore,
1999 [(store i32:$rS, iaddr:$src)]>;
2000 let Predicates = [HasFPU] in {
2001 def STFS : DForm_1<52, (outs), (ins f4rc:$rS, memri:$dst),
2002 "stfs $rS, $dst", IIC_LdStSTFD,
2003 [(store f32:$rS, iaddr:$dst)]>;
2004 def STFD : DForm_1<54, (outs), (ins f8rc:$rS, memri:$dst),
2005 "stfd $rS, $dst", IIC_LdStSTFD,
2006 [(store f64:$rS, iaddr:$dst)]>;
2010 // Unindexed (r+i) Stores with Update (preinc).
2011 let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in {
2012 def STBU : DForm_1<39, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst),
2013 "stbu $rS, $dst", IIC_LdStStoreUpd, []>,
2014 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
2015 def STHU : DForm_1<45, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst),
2016 "sthu $rS, $dst", IIC_LdStStoreUpd, []>,
2017 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
2018 def STWU : DForm_1<37, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst),
2019 "stwu $rS, $dst", IIC_LdStStoreUpd, []>,
2020 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
2021 let Predicates = [HasFPU] in {
2022 def STFSU : DForm_1<53, (outs ptr_rc_nor0:$ea_res), (ins f4rc:$rS, memri:$dst),
2023 "stfsu $rS, $dst", IIC_LdStSTFDU, []>,
2024 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
2025 def STFDU : DForm_1<55, (outs ptr_rc_nor0:$ea_res), (ins f8rc:$rS, memri:$dst),
2026 "stfdu $rS, $dst", IIC_LdStSTFDU, []>,
2027 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
2031 // Patterns to match the pre-inc stores. We can't put the patterns on
2032 // the instruction definitions directly as ISel wants the address base
2033 // and offset to be separate operands, not a single complex operand.
2034 def : Pat<(pre_truncsti8 i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
2035 (STBU $rS, iaddroff:$ptroff, $ptrreg)>;
2036 def : Pat<(pre_truncsti16 i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
2037 (STHU $rS, iaddroff:$ptroff, $ptrreg)>;
2038 def : Pat<(pre_store i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
2039 (STWU $rS, iaddroff:$ptroff, $ptrreg)>;
2040 def : Pat<(pre_store f32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
2041 (STFSU $rS, iaddroff:$ptroff, $ptrreg)>;
2042 def : Pat<(pre_store f64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
2043 (STFDU $rS, iaddroff:$ptroff, $ptrreg)>;
2045 // Indexed (r+r) Stores.
2046 let PPC970_Unit = 2 in {
2047 def STBX : XForm_8_memOp<31, 215, (outs), (ins gprc:$rS, memrr:$dst),
2048 "stbx $rS, $dst", IIC_LdStStore,
2049 [(truncstorei8 i32:$rS, xaddr:$dst)]>,
2050 PPC970_DGroup_Cracked;
2051 def STHX : XForm_8_memOp<31, 407, (outs), (ins gprc:$rS, memrr:$dst),
2052 "sthx $rS, $dst", IIC_LdStStore,
2053 [(truncstorei16 i32:$rS, xaddr:$dst)]>,
2054 PPC970_DGroup_Cracked;
2055 def STWX : XForm_8_memOp<31, 151, (outs), (ins gprc:$rS, memrr:$dst),
2056 "stwx $rS, $dst", IIC_LdStStore,
2057 [(store i32:$rS, xaddr:$dst)]>,
2058 PPC970_DGroup_Cracked;
2060 def STHBRX: XForm_8_memOp<31, 918, (outs), (ins gprc:$rS, memrr:$dst),
2061 "sthbrx $rS, $dst", IIC_LdStStore,
2062 [(PPCstbrx i32:$rS, xoaddr:$dst, i16)]>,
2063 PPC970_DGroup_Cracked;
2064 def STWBRX: XForm_8_memOp<31, 662, (outs), (ins gprc:$rS, memrr:$dst),
2065 "stwbrx $rS, $dst", IIC_LdStStore,
2066 [(PPCstbrx i32:$rS, xoaddr:$dst, i32)]>,
2067 PPC970_DGroup_Cracked;
2069 let Predicates = [HasFPU] in {
2070 def STFIWX: XForm_28_memOp<31, 983, (outs), (ins f8rc:$frS, memrr:$dst),
2071 "stfiwx $frS, $dst", IIC_LdStSTFD,
2072 [(PPCstfiwx f64:$frS, xoaddr:$dst)]>;
2074 def STFSX : XForm_28_memOp<31, 663, (outs), (ins f4rc:$frS, memrr:$dst),
2075 "stfsx $frS, $dst", IIC_LdStSTFD,
2076 [(store f32:$frS, xaddr:$dst)]>;
2077 def STFDX : XForm_28_memOp<31, 727, (outs), (ins f8rc:$frS, memrr:$dst),
2078 "stfdx $frS, $dst", IIC_LdStSTFD,
2079 [(store f64:$frS, xaddr:$dst)]>;
2083 // Indexed (r+r) Stores with Update (preinc).
2084 let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in {
2085 def STBUX : XForm_8_memOp<31, 247, (outs ptr_rc_nor0:$ea_res),
2086 (ins gprc:$rS, memrr:$dst),
2087 "stbux $rS, $dst", IIC_LdStStoreUpd, []>,
2088 RegConstraint<"$dst.ptrreg = $ea_res">,
2089 NoEncode<"$ea_res">,
2090 PPC970_DGroup_Cracked;
2091 def STHUX : XForm_8_memOp<31, 439, (outs ptr_rc_nor0:$ea_res),
2092 (ins gprc:$rS, memrr:$dst),
2093 "sthux $rS, $dst", IIC_LdStStoreUpd, []>,
2094 RegConstraint<"$dst.ptrreg = $ea_res">,
2095 NoEncode<"$ea_res">,
2096 PPC970_DGroup_Cracked;
2097 def STWUX : XForm_8_memOp<31, 183, (outs ptr_rc_nor0:$ea_res),
2098 (ins gprc:$rS, memrr:$dst),
2099 "stwux $rS, $dst", IIC_LdStStoreUpd, []>,
2100 RegConstraint<"$dst.ptrreg = $ea_res">,
2101 NoEncode<"$ea_res">,
2102 PPC970_DGroup_Cracked;
2103 let Predicates = [HasFPU] in {
2104 def STFSUX: XForm_8_memOp<31, 695, (outs ptr_rc_nor0:$ea_res),
2105 (ins f4rc:$rS, memrr:$dst),
2106 "stfsux $rS, $dst", IIC_LdStSTFDU, []>,
2107 RegConstraint<"$dst.ptrreg = $ea_res">,
2108 NoEncode<"$ea_res">,
2109 PPC970_DGroup_Cracked;
2110 def STFDUX: XForm_8_memOp<31, 759, (outs ptr_rc_nor0:$ea_res),
2111 (ins f8rc:$rS, memrr:$dst),
2112 "stfdux $rS, $dst", IIC_LdStSTFDU, []>,
2113 RegConstraint<"$dst.ptrreg = $ea_res">,
2114 NoEncode<"$ea_res">,
2115 PPC970_DGroup_Cracked;
2119 // Patterns to match the pre-inc stores. We can't put the patterns on
2120 // the instruction definitions directly as ISel wants the address base
2121 // and offset to be separate operands, not a single complex operand.
2122 def : Pat<(pre_truncsti8 i32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2123 (STBUX $rS, $ptrreg, $ptroff)>;
2124 def : Pat<(pre_truncsti16 i32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2125 (STHUX $rS, $ptrreg, $ptroff)>;
2126 def : Pat<(pre_store i32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2127 (STWUX $rS, $ptrreg, $ptroff)>;
2128 let Predicates = [HasFPU] in {
2129 def : Pat<(pre_store f32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2130 (STFSUX $rS, $ptrreg, $ptroff)>;
2131 def : Pat<(pre_store f64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2132 (STFDUX $rS, $ptrreg, $ptroff)>;
2136 def STMW : DForm_1<47, (outs), (ins gprc:$rS, memri:$dst),
2137 "stmw $rS, $dst", IIC_LdStLMW, []>;
2139 def SYNC : XForm_24_sync<31, 598, (outs), (ins i32imm:$L),
2140 "sync $L", IIC_LdStSync, []>;
2142 let isCodeGenOnly = 1 in {
2143 def MSYNC : XForm_24_sync<31, 598, (outs), (ins),
2144 "msync", IIC_LdStSync, []> {
2149 def : Pat<(int_ppc_sync), (SYNC 0)>, Requires<[HasSYNC]>;
2150 def : Pat<(int_ppc_lwsync), (SYNC 1)>, Requires<[HasSYNC]>;
2151 def : Pat<(int_ppc_sync), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
2152 def : Pat<(int_ppc_lwsync), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
2154 //===----------------------------------------------------------------------===//
2155 // PPC32 Arithmetic Instructions.
2158 let PPC970_Unit = 1 in { // FXU Operations.
2159 def ADDI : DForm_2<14, (outs gprc:$rD), (ins gprc_nor0:$rA, s16imm:$imm),
2160 "addi $rD, $rA, $imm", IIC_IntSimple,
2161 [(set i32:$rD, (add i32:$rA, imm32SExt16:$imm))]>;
2162 let BaseName = "addic" in {
2163 let Defs = [CARRY] in
2164 def ADDIC : DForm_2<12, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
2165 "addic $rD, $rA, $imm", IIC_IntGeneral,
2166 [(set i32:$rD, (addc i32:$rA, imm32SExt16:$imm))]>,
2167 RecFormRel, PPC970_DGroup_Cracked;
2168 let Defs = [CARRY, CR0] in
2169 def ADDICo : DForm_2<13, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
2170 "addic. $rD, $rA, $imm", IIC_IntGeneral,
2171 []>, isDOT, RecFormRel;
2173 def ADDIS : DForm_2<15, (outs gprc:$rD), (ins gprc_nor0:$rA, s17imm:$imm),
2174 "addis $rD, $rA, $imm", IIC_IntSimple,
2175 [(set i32:$rD, (add i32:$rA, imm16ShiftedSExt:$imm))]>;
2176 let isCodeGenOnly = 1 in
2177 def LA : DForm_2<14, (outs gprc:$rD), (ins gprc_nor0:$rA, s16imm:$sym),
2178 "la $rD, $sym($rA)", IIC_IntGeneral,
2179 [(set i32:$rD, (add i32:$rA,
2180 (PPClo tglobaladdr:$sym, 0)))]>;
2181 def MULLI : DForm_2< 7, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
2182 "mulli $rD, $rA, $imm", IIC_IntMulLI,
2183 [(set i32:$rD, (mul i32:$rA, imm32SExt16:$imm))]>;
2184 let Defs = [CARRY] in
2185 def SUBFIC : DForm_2< 8, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
2186 "subfic $rD, $rA, $imm", IIC_IntGeneral,
2187 [(set i32:$rD, (subc imm32SExt16:$imm, i32:$rA))]>;
2189 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in {
2190 def LI : DForm_2_r0<14, (outs gprc:$rD), (ins s16imm:$imm),
2191 "li $rD, $imm", IIC_IntSimple,
2192 [(set i32:$rD, imm32SExt16:$imm)]>;
2193 def LIS : DForm_2_r0<15, (outs gprc:$rD), (ins s17imm:$imm),
2194 "lis $rD, $imm", IIC_IntSimple,
2195 [(set i32:$rD, imm16ShiftedSExt:$imm)]>;
2199 let PPC970_Unit = 1 in { // FXU Operations.
2200 let Defs = [CR0] in {
2201 def ANDIo : DForm_4<28, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2202 "andi. $dst, $src1, $src2", IIC_IntGeneral,
2203 [(set i32:$dst, (and i32:$src1, immZExt16:$src2))]>,
2205 def ANDISo : DForm_4<29, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2206 "andis. $dst, $src1, $src2", IIC_IntGeneral,
2207 [(set i32:$dst, (and i32:$src1, imm16ShiftedZExt:$src2))]>,
2210 def ORI : DForm_4<24, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2211 "ori $dst, $src1, $src2", IIC_IntSimple,
2212 [(set i32:$dst, (or i32:$src1, immZExt16:$src2))]>;
2213 def ORIS : DForm_4<25, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2214 "oris $dst, $src1, $src2", IIC_IntSimple,
2215 [(set i32:$dst, (or i32:$src1, imm16ShiftedZExt:$src2))]>;
2216 def XORI : DForm_4<26, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2217 "xori $dst, $src1, $src2", IIC_IntSimple,
2218 [(set i32:$dst, (xor i32:$src1, immZExt16:$src2))]>;
2219 def XORIS : DForm_4<27, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2220 "xoris $dst, $src1, $src2", IIC_IntSimple,
2221 [(set i32:$dst, (xor i32:$src1, imm16ShiftedZExt:$src2))]>;
2223 def NOP : DForm_4_zero<24, (outs), (ins), "nop", IIC_IntSimple,
2225 let isCodeGenOnly = 1 in {
2226 // The POWER6 and POWER7 have special group-terminating nops.
2227 def NOP_GT_PWR6 : DForm_4_fixedreg_zero<24, 1, (outs), (ins),
2228 "ori 1, 1, 0", IIC_IntSimple, []>;
2229 def NOP_GT_PWR7 : DForm_4_fixedreg_zero<24, 2, (outs), (ins),
2230 "ori 2, 2, 0", IIC_IntSimple, []>;
2233 let isCompare = 1, hasSideEffects = 0 in {
2234 def CMPWI : DForm_5_ext<11, (outs crrc:$crD), (ins gprc:$rA, s16imm:$imm),
2235 "cmpwi $crD, $rA, $imm", IIC_IntCompare>;
2236 def CMPLWI : DForm_6_ext<10, (outs crrc:$dst), (ins gprc:$src1, u16imm:$src2),
2237 "cmplwi $dst, $src1, $src2", IIC_IntCompare>;
2238 def CMPRB : X_BF3_L1_RS5_RS5<31, 192, (outs crbitrc:$BF),
2239 (ins u1imm:$L, g8rc:$rA, g8rc:$rB),
2240 "cmprb $BF, $L, $rA, $rB", IIC_IntCompare, []>,
2241 Requires<[IsISA3_0]>;
2245 let PPC970_Unit = 1, hasSideEffects = 0 in { // FXU Operations.
2246 let isCommutable = 1 in {
2247 defm NAND : XForm_6r<31, 476, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2248 "nand", "$rA, $rS, $rB", IIC_IntSimple,
2249 [(set i32:$rA, (not (and i32:$rS, i32:$rB)))]>;
2250 defm AND : XForm_6r<31, 28, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2251 "and", "$rA, $rS, $rB", IIC_IntSimple,
2252 [(set i32:$rA, (and i32:$rS, i32:$rB))]>;
2254 defm ANDC : XForm_6r<31, 60, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2255 "andc", "$rA, $rS, $rB", IIC_IntSimple,
2256 [(set i32:$rA, (and i32:$rS, (not i32:$rB)))]>;
2257 let isCommutable = 1 in {
2258 defm OR : XForm_6r<31, 444, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2259 "or", "$rA, $rS, $rB", IIC_IntSimple,
2260 [(set i32:$rA, (or i32:$rS, i32:$rB))]>;
2261 defm NOR : XForm_6r<31, 124, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2262 "nor", "$rA, $rS, $rB", IIC_IntSimple,
2263 [(set i32:$rA, (not (or i32:$rS, i32:$rB)))]>;
2265 defm ORC : XForm_6r<31, 412, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2266 "orc", "$rA, $rS, $rB", IIC_IntSimple,
2267 [(set i32:$rA, (or i32:$rS, (not i32:$rB)))]>;
2268 let isCommutable = 1 in {
2269 defm EQV : XForm_6r<31, 284, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2270 "eqv", "$rA, $rS, $rB", IIC_IntSimple,
2271 [(set i32:$rA, (not (xor i32:$rS, i32:$rB)))]>;
2272 defm XOR : XForm_6r<31, 316, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2273 "xor", "$rA, $rS, $rB", IIC_IntSimple,
2274 [(set i32:$rA, (xor i32:$rS, i32:$rB))]>;
2276 defm SLW : XForm_6r<31, 24, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2277 "slw", "$rA, $rS, $rB", IIC_IntGeneral,
2278 [(set i32:$rA, (PPCshl i32:$rS, i32:$rB))]>;
2279 defm SRW : XForm_6r<31, 536, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2280 "srw", "$rA, $rS, $rB", IIC_IntGeneral,
2281 [(set i32:$rA, (PPCsrl i32:$rS, i32:$rB))]>;
2282 defm SRAW : XForm_6rc<31, 792, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2283 "sraw", "$rA, $rS, $rB", IIC_IntShift,
2284 [(set i32:$rA, (PPCsra i32:$rS, i32:$rB))]>;
2287 let PPC970_Unit = 1 in { // FXU Operations.
2288 let hasSideEffects = 0 in {
2289 defm SRAWI : XForm_10rc<31, 824, (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH),
2290 "srawi", "$rA, $rS, $SH", IIC_IntShift,
2291 [(set i32:$rA, (sra i32:$rS, (i32 imm:$SH)))]>;
2292 defm CNTLZW : XForm_11r<31, 26, (outs gprc:$rA), (ins gprc:$rS),
2293 "cntlzw", "$rA, $rS", IIC_IntGeneral,
2294 [(set i32:$rA, (ctlz i32:$rS))]>;
2295 defm CNTTZW : XForm_11r<31, 538, (outs gprc:$rA), (ins gprc:$rS),
2296 "cnttzw", "$rA, $rS", IIC_IntGeneral,
2297 [(set i32:$rA, (cttz i32:$rS))]>, Requires<[IsISA3_0]>;
2298 defm EXTSB : XForm_11r<31, 954, (outs gprc:$rA), (ins gprc:$rS),
2299 "extsb", "$rA, $rS", IIC_IntSimple,
2300 [(set i32:$rA, (sext_inreg i32:$rS, i8))]>;
2301 defm EXTSH : XForm_11r<31, 922, (outs gprc:$rA), (ins gprc:$rS),
2302 "extsh", "$rA, $rS", IIC_IntSimple,
2303 [(set i32:$rA, (sext_inreg i32:$rS, i16))]>;
2305 let isCommutable = 1 in
2306 def CMPB : XForm_6<31, 508, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2307 "cmpb $rA, $rS, $rB", IIC_IntGeneral,
2308 [(set i32:$rA, (PPCcmpb i32:$rS, i32:$rB))]>;
2310 let isCompare = 1, hasSideEffects = 0 in {
2311 def CMPW : XForm_16_ext<31, 0, (outs crrc:$crD), (ins gprc:$rA, gprc:$rB),
2312 "cmpw $crD, $rA, $rB", IIC_IntCompare>;
2313 def CMPLW : XForm_16_ext<31, 32, (outs crrc:$crD), (ins gprc:$rA, gprc:$rB),
2314 "cmplw $crD, $rA, $rB", IIC_IntCompare>;
2317 let PPC970_Unit = 3, Predicates = [HasFPU] in { // FPU Operations.
2318 //def FCMPO : XForm_17<63, 32, (outs CRRC:$crD), (ins FPRC:$fA, FPRC:$fB),
2319 // "fcmpo $crD, $fA, $fB", IIC_FPCompare>;
2320 let isCompare = 1, hasSideEffects = 0 in {
2321 def FCMPUS : XForm_17<63, 0, (outs crrc:$crD), (ins f4rc:$fA, f4rc:$fB),
2322 "fcmpu $crD, $fA, $fB", IIC_FPCompare>;
2323 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2324 def FCMPUD : XForm_17<63, 0, (outs crrc:$crD), (ins f8rc:$fA, f8rc:$fB),
2325 "fcmpu $crD, $fA, $fB", IIC_FPCompare>;
2328 def FTDIV: XForm_17<63, 128, (outs crrc:$crD), (ins f8rc:$fA, f8rc:$fB),
2329 "ftdiv $crD, $fA, $fB", IIC_FPCompare>;
2330 def FTSQRT: XForm_17a<63, 160, (outs crrc:$crD), (ins f8rc:$fB),
2331 "ftsqrt $crD, $fB", IIC_FPCompare>;
2333 let Uses = [RM] in {
2334 let hasSideEffects = 0 in {
2335 defm FCTIW : XForm_26r<63, 14, (outs f8rc:$frD), (ins f8rc:$frB),
2336 "fctiw", "$frD, $frB", IIC_FPGeneral,
2338 defm FCTIWU : XForm_26r<63, 142, (outs f8rc:$frD), (ins f8rc:$frB),
2339 "fctiwu", "$frD, $frB", IIC_FPGeneral,
2341 defm FCTIWZ : XForm_26r<63, 15, (outs f8rc:$frD), (ins f8rc:$frB),
2342 "fctiwz", "$frD, $frB", IIC_FPGeneral,
2343 [(set f64:$frD, (PPCfctiwz f64:$frB))]>;
2345 defm FRSP : XForm_26r<63, 12, (outs f4rc:$frD), (ins f8rc:$frB),
2346 "frsp", "$frD, $frB", IIC_FPGeneral,
2347 [(set f32:$frD, (fpround f64:$frB))]>;
2349 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2350 defm FRIND : XForm_26r<63, 392, (outs f8rc:$frD), (ins f8rc:$frB),
2351 "frin", "$frD, $frB", IIC_FPGeneral,
2352 [(set f64:$frD, (fround f64:$frB))]>;
2353 defm FRINS : XForm_26r<63, 392, (outs f4rc:$frD), (ins f4rc:$frB),
2354 "frin", "$frD, $frB", IIC_FPGeneral,
2355 [(set f32:$frD, (fround f32:$frB))]>;
2358 let hasSideEffects = 0 in {
2359 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2360 defm FRIPD : XForm_26r<63, 456, (outs f8rc:$frD), (ins f8rc:$frB),
2361 "frip", "$frD, $frB", IIC_FPGeneral,
2362 [(set f64:$frD, (fceil f64:$frB))]>;
2363 defm FRIPS : XForm_26r<63, 456, (outs f4rc:$frD), (ins f4rc:$frB),
2364 "frip", "$frD, $frB", IIC_FPGeneral,
2365 [(set f32:$frD, (fceil f32:$frB))]>;
2366 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2367 defm FRIZD : XForm_26r<63, 424, (outs f8rc:$frD), (ins f8rc:$frB),
2368 "friz", "$frD, $frB", IIC_FPGeneral,
2369 [(set f64:$frD, (ftrunc f64:$frB))]>;
2370 defm FRIZS : XForm_26r<63, 424, (outs f4rc:$frD), (ins f4rc:$frB),
2371 "friz", "$frD, $frB", IIC_FPGeneral,
2372 [(set f32:$frD, (ftrunc f32:$frB))]>;
2373 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2374 defm FRIMD : XForm_26r<63, 488, (outs f8rc:$frD), (ins f8rc:$frB),
2375 "frim", "$frD, $frB", IIC_FPGeneral,
2376 [(set f64:$frD, (ffloor f64:$frB))]>;
2377 defm FRIMS : XForm_26r<63, 488, (outs f4rc:$frD), (ins f4rc:$frB),
2378 "frim", "$frD, $frB", IIC_FPGeneral,
2379 [(set f32:$frD, (ffloor f32:$frB))]>;
2381 defm FSQRT : XForm_26r<63, 22, (outs f8rc:$frD), (ins f8rc:$frB),
2382 "fsqrt", "$frD, $frB", IIC_FPSqrtD,
2383 [(set f64:$frD, (fsqrt f64:$frB))]>;
2384 defm FSQRTS : XForm_26r<59, 22, (outs f4rc:$frD), (ins f4rc:$frB),
2385 "fsqrts", "$frD, $frB", IIC_FPSqrtS,
2386 [(set f32:$frD, (fsqrt f32:$frB))]>;
2391 /// Note that FMR is defined as pseudo-ops on the PPC970 because they are
2392 /// often coalesced away and we don't want the dispatch group builder to think
2393 /// that they will fill slots (which could cause the load of a LSU reject to
2394 /// sneak into a d-group with a store).
2395 let hasSideEffects = 0, Predicates = [HasFPU] in
2396 defm FMR : XForm_26r<63, 72, (outs f4rc:$frD), (ins f4rc:$frB),
2397 "fmr", "$frD, $frB", IIC_FPGeneral,
2398 []>, // (set f32:$frD, f32:$frB)
2401 let PPC970_Unit = 3, hasSideEffects = 0, Predicates = [HasFPU] in { // FPU Operations.
2402 // These are artificially split into two different forms, for 4/8 byte FP.
2403 defm FABSS : XForm_26r<63, 264, (outs f4rc:$frD), (ins f4rc:$frB),
2404 "fabs", "$frD, $frB", IIC_FPGeneral,
2405 [(set f32:$frD, (fabs f32:$frB))]>;
2406 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2407 defm FABSD : XForm_26r<63, 264, (outs f8rc:$frD), (ins f8rc:$frB),
2408 "fabs", "$frD, $frB", IIC_FPGeneral,
2409 [(set f64:$frD, (fabs f64:$frB))]>;
2410 defm FNABSS : XForm_26r<63, 136, (outs f4rc:$frD), (ins f4rc:$frB),
2411 "fnabs", "$frD, $frB", IIC_FPGeneral,
2412 [(set f32:$frD, (fneg (fabs f32:$frB)))]>;
2413 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2414 defm FNABSD : XForm_26r<63, 136, (outs f8rc:$frD), (ins f8rc:$frB),
2415 "fnabs", "$frD, $frB", IIC_FPGeneral,
2416 [(set f64:$frD, (fneg (fabs f64:$frB)))]>;
2417 defm FNEGS : XForm_26r<63, 40, (outs f4rc:$frD), (ins f4rc:$frB),
2418 "fneg", "$frD, $frB", IIC_FPGeneral,
2419 [(set f32:$frD, (fneg f32:$frB))]>;
2420 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2421 defm FNEGD : XForm_26r<63, 40, (outs f8rc:$frD), (ins f8rc:$frB),
2422 "fneg", "$frD, $frB", IIC_FPGeneral,
2423 [(set f64:$frD, (fneg f64:$frB))]>;
2425 defm FCPSGNS : XForm_28r<63, 8, (outs f4rc:$frD), (ins f4rc:$frA, f4rc:$frB),
2426 "fcpsgn", "$frD, $frA, $frB", IIC_FPGeneral,
2427 [(set f32:$frD, (fcopysign f32:$frB, f32:$frA))]>;
2428 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2429 defm FCPSGND : XForm_28r<63, 8, (outs f8rc:$frD), (ins f8rc:$frA, f8rc:$frB),
2430 "fcpsgn", "$frD, $frA, $frB", IIC_FPGeneral,
2431 [(set f64:$frD, (fcopysign f64:$frB, f64:$frA))]>;
2433 // Reciprocal estimates.
2434 defm FRE : XForm_26r<63, 24, (outs f8rc:$frD), (ins f8rc:$frB),
2435 "fre", "$frD, $frB", IIC_FPGeneral,
2436 [(set f64:$frD, (PPCfre f64:$frB))]>;
2437 defm FRES : XForm_26r<59, 24, (outs f4rc:$frD), (ins f4rc:$frB),
2438 "fres", "$frD, $frB", IIC_FPGeneral,
2439 [(set f32:$frD, (PPCfre f32:$frB))]>;
2440 defm FRSQRTE : XForm_26r<63, 26, (outs f8rc:$frD), (ins f8rc:$frB),
2441 "frsqrte", "$frD, $frB", IIC_FPGeneral,
2442 [(set f64:$frD, (PPCfrsqrte f64:$frB))]>;
2443 defm FRSQRTES : XForm_26r<59, 26, (outs f4rc:$frD), (ins f4rc:$frB),
2444 "frsqrtes", "$frD, $frB", IIC_FPGeneral,
2445 [(set f32:$frD, (PPCfrsqrte f32:$frB))]>;
2448 // XL-Form instructions. condition register logical ops.
2450 let hasSideEffects = 0 in
2451 def MCRF : XLForm_3<19, 0, (outs crrc:$BF), (ins crrc:$BFA),
2452 "mcrf $BF, $BFA", IIC_BrMCR>,
2453 PPC970_DGroup_First, PPC970_Unit_CRU;
2455 // FIXME: According to the ISA (section 2.5.1 of version 2.06), the
2456 // condition-register logical instructions have preferred forms. Specifically,
2457 // it is preferred that the bit specified by the BT field be in the same
2458 // condition register as that specified by the bit BB. We might want to account
2459 // for this via hinting the register allocator and anti-dep breakers, or we
2460 // could constrain the register class to force this constraint and then loosen
2461 // it during register allocation via convertToThreeAddress or some similar
2464 let isCommutable = 1 in {
2465 def CRAND : XLForm_1<19, 257, (outs crbitrc:$CRD),
2466 (ins crbitrc:$CRA, crbitrc:$CRB),
2467 "crand $CRD, $CRA, $CRB", IIC_BrCR,
2468 [(set i1:$CRD, (and i1:$CRA, i1:$CRB))]>;
2470 def CRNAND : XLForm_1<19, 225, (outs crbitrc:$CRD),
2471 (ins crbitrc:$CRA, crbitrc:$CRB),
2472 "crnand $CRD, $CRA, $CRB", IIC_BrCR,
2473 [(set i1:$CRD, (not (and i1:$CRA, i1:$CRB)))]>;
2475 def CROR : XLForm_1<19, 449, (outs crbitrc:$CRD),
2476 (ins crbitrc:$CRA, crbitrc:$CRB),
2477 "cror $CRD, $CRA, $CRB", IIC_BrCR,
2478 [(set i1:$CRD, (or i1:$CRA, i1:$CRB))]>;
2480 def CRXOR : XLForm_1<19, 193, (outs crbitrc:$CRD),
2481 (ins crbitrc:$CRA, crbitrc:$CRB),
2482 "crxor $CRD, $CRA, $CRB", IIC_BrCR,
2483 [(set i1:$CRD, (xor i1:$CRA, i1:$CRB))]>;
2485 def CRNOR : XLForm_1<19, 33, (outs crbitrc:$CRD),
2486 (ins crbitrc:$CRA, crbitrc:$CRB),
2487 "crnor $CRD, $CRA, $CRB", IIC_BrCR,
2488 [(set i1:$CRD, (not (or i1:$CRA, i1:$CRB)))]>;
2490 def CREQV : XLForm_1<19, 289, (outs crbitrc:$CRD),
2491 (ins crbitrc:$CRA, crbitrc:$CRB),
2492 "creqv $CRD, $CRA, $CRB", IIC_BrCR,
2493 [(set i1:$CRD, (not (xor i1:$CRA, i1:$CRB)))]>;
2496 def CRANDC : XLForm_1<19, 129, (outs crbitrc:$CRD),
2497 (ins crbitrc:$CRA, crbitrc:$CRB),
2498 "crandc $CRD, $CRA, $CRB", IIC_BrCR,
2499 [(set i1:$CRD, (and i1:$CRA, (not i1:$CRB)))]>;
2501 def CRORC : XLForm_1<19, 417, (outs crbitrc:$CRD),
2502 (ins crbitrc:$CRA, crbitrc:$CRB),
2503 "crorc $CRD, $CRA, $CRB", IIC_BrCR,
2504 [(set i1:$CRD, (or i1:$CRA, (not i1:$CRB)))]>;
2506 let isCodeGenOnly = 1 in {
2507 def CRSET : XLForm_1_ext<19, 289, (outs crbitrc:$dst), (ins),
2508 "creqv $dst, $dst, $dst", IIC_BrCR,
2509 [(set i1:$dst, 1)]>;
2511 def CRUNSET: XLForm_1_ext<19, 193, (outs crbitrc:$dst), (ins),
2512 "crxor $dst, $dst, $dst", IIC_BrCR,
2513 [(set i1:$dst, 0)]>;
2515 let Defs = [CR1EQ], CRD = 6 in {
2516 def CR6SET : XLForm_1_ext<19, 289, (outs), (ins),
2517 "creqv 6, 6, 6", IIC_BrCR,
2520 def CR6UNSET: XLForm_1_ext<19, 193, (outs), (ins),
2521 "crxor 6, 6, 6", IIC_BrCR,
2526 // XFX-Form instructions. Instructions that deal with SPRs.
2529 def MFSPR : XFXForm_1<31, 339, (outs gprc:$RT), (ins i32imm:$SPR),
2530 "mfspr $RT, $SPR", IIC_SprMFSPR>;
2531 def MTSPR : XFXForm_1<31, 467, (outs), (ins i32imm:$SPR, gprc:$RT),
2532 "mtspr $SPR, $RT", IIC_SprMTSPR>;
2534 def MFTB : XFXForm_1<31, 371, (outs gprc:$RT), (ins i32imm:$SPR),
2535 "mftb $RT, $SPR", IIC_SprMFTB>;
2537 def MFPMR : XFXForm_1<31, 334, (outs gprc:$RT), (ins i32imm:$SPR),
2538 "mfpmr $RT, $SPR", IIC_SprMFPMR>;
2540 def MTPMR : XFXForm_1<31, 462, (outs), (ins i32imm:$SPR, gprc:$RT),
2541 "mtpmr $SPR, $RT", IIC_SprMTPMR>;
2544 // A pseudo-instruction used to implement the read of the 64-bit cycle counter
2545 // on a 32-bit target.
2546 let hasSideEffects = 1, usesCustomInserter = 1 in
2547 def ReadTB : Pseudo<(outs gprc:$lo, gprc:$hi), (ins),
2550 let Uses = [CTR] in {
2551 def MFCTR : XFXForm_1_ext<31, 339, 9, (outs gprc:$rT), (ins),
2552 "mfctr $rT", IIC_SprMFSPR>,
2553 PPC970_DGroup_First, PPC970_Unit_FXU;
2555 let Defs = [CTR], Pattern = [(PPCmtctr i32:$rS)] in {
2556 def MTCTR : XFXForm_7_ext<31, 467, 9, (outs), (ins gprc:$rS),
2557 "mtctr $rS", IIC_SprMTSPR>,
2558 PPC970_DGroup_First, PPC970_Unit_FXU;
2560 let hasSideEffects = 1, isCodeGenOnly = 1, Defs = [CTR] in {
2561 let Pattern = [(int_ppc_mtctr i32:$rS)] in
2562 def MTCTRloop : XFXForm_7_ext<31, 467, 9, (outs), (ins gprc:$rS),
2563 "mtctr $rS", IIC_SprMTSPR>,
2564 PPC970_DGroup_First, PPC970_Unit_FXU;
2567 let Defs = [LR] in {
2568 def MTLR : XFXForm_7_ext<31, 467, 8, (outs), (ins gprc:$rS),
2569 "mtlr $rS", IIC_SprMTSPR>,
2570 PPC970_DGroup_First, PPC970_Unit_FXU;
2572 let Uses = [LR] in {
2573 def MFLR : XFXForm_1_ext<31, 339, 8, (outs gprc:$rT), (ins),
2574 "mflr $rT", IIC_SprMFSPR>,
2575 PPC970_DGroup_First, PPC970_Unit_FXU;
2578 let isCodeGenOnly = 1 in {
2579 // Move to/from VRSAVE: despite being a SPR, the VRSAVE register is renamed
2580 // like a GPR on the PPC970. As such, copies in and out have the same
2581 // performance characteristics as an OR instruction.
2582 def MTVRSAVE : XFXForm_7_ext<31, 467, 256, (outs), (ins gprc:$rS),
2583 "mtspr 256, $rS", IIC_IntGeneral>,
2584 PPC970_DGroup_Single, PPC970_Unit_FXU;
2585 def MFVRSAVE : XFXForm_1_ext<31, 339, 256, (outs gprc:$rT), (ins),
2586 "mfspr $rT, 256", IIC_IntGeneral>,
2587 PPC970_DGroup_First, PPC970_Unit_FXU;
2589 def MTVRSAVEv : XFXForm_7_ext<31, 467, 256,
2590 (outs VRSAVERC:$reg), (ins gprc:$rS),
2591 "mtspr 256, $rS", IIC_IntGeneral>,
2592 PPC970_DGroup_Single, PPC970_Unit_FXU;
2593 def MFVRSAVEv : XFXForm_1_ext<31, 339, 256, (outs gprc:$rT),
2594 (ins VRSAVERC:$reg),
2595 "mfspr $rT, 256", IIC_IntGeneral>,
2596 PPC970_DGroup_First, PPC970_Unit_FXU;
2599 // Aliases for mtvrsave/mfvrsave to mfspr/mtspr.
2600 def : InstAlias<"mtvrsave $rS", (MTVRSAVE gprc:$rS)>;
2601 def : InstAlias<"mfvrsave $rS", (MFVRSAVE gprc:$rS)>;
2603 // SPILL_VRSAVE - Indicate that we're dumping the VRSAVE register,
2604 // so we'll need to scavenge a register for it.
2606 def SPILL_VRSAVE : Pseudo<(outs), (ins VRSAVERC:$vrsave, memri:$F),
2607 "#SPILL_VRSAVE", []>;
2609 // RESTORE_VRSAVE - Indicate that we're restoring the VRSAVE register (previously
2610 // spilled), so we'll need to scavenge a register for it.
2612 def RESTORE_VRSAVE : Pseudo<(outs VRSAVERC:$vrsave), (ins memri:$F),
2613 "#RESTORE_VRSAVE", []>;
2615 let hasSideEffects = 0 in {
2616 // mtocrf's input needs to be prepared by shifting by an amount dependent
2617 // on the cr register selected. Thus, post-ra anti-dep breaking must not
2618 // later change that register assignment.
2619 let hasExtraDefRegAllocReq = 1 in {
2620 def MTOCRF: XFXForm_5a<31, 144, (outs crbitm:$FXM), (ins gprc:$ST),
2621 "mtocrf $FXM, $ST", IIC_BrMCRX>,
2622 PPC970_DGroup_First, PPC970_Unit_CRU;
2624 // Similarly to mtocrf, the mask for mtcrf must be prepared in a way that
2625 // is dependent on the cr fields being set.
2626 def MTCRF : XFXForm_5<31, 144, (outs), (ins i32imm:$FXM, gprc:$rS),
2627 "mtcrf $FXM, $rS", IIC_BrMCRX>,
2628 PPC970_MicroCode, PPC970_Unit_CRU;
2629 } // hasExtraDefRegAllocReq = 1
2631 // mfocrf's input needs to be prepared by shifting by an amount dependent
2632 // on the cr register selected. Thus, post-ra anti-dep breaking must not
2633 // later change that register assignment.
2634 let hasExtraSrcRegAllocReq = 1 in {
2635 def MFOCRF: XFXForm_5a<31, 19, (outs gprc:$rT), (ins crbitm:$FXM),
2636 "mfocrf $rT, $FXM", IIC_SprMFCRF>,
2637 PPC970_DGroup_First, PPC970_Unit_CRU;
2639 // Similarly to mfocrf, the mask for mfcrf must be prepared in a way that
2640 // is dependent on the cr fields being copied.
2641 def MFCR : XFXForm_3<31, 19, (outs gprc:$rT), (ins),
2642 "mfcr $rT", IIC_SprMFCR>,
2643 PPC970_MicroCode, PPC970_Unit_CRU;
2644 } // hasExtraSrcRegAllocReq = 1
2646 def MCRXRX : X_BF3<31, 576, (outs crrc:$BF), (ins),
2647 "mcrxrx $BF", IIC_BrMCRX>, Requires<[IsISA3_0]>;
2648 } // hasSideEffects = 0
2650 let Predicates = [HasFPU] in {
2651 // Pseudo instruction to perform FADD in round-to-zero mode.
2652 let usesCustomInserter = 1, Uses = [RM] in {
2653 def FADDrtz: Pseudo<(outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB), "",
2654 [(set f64:$FRT, (PPCfaddrtz f64:$FRA, f64:$FRB))]>;
2657 // The above pseudo gets expanded to make use of the following instructions
2658 // to manipulate FPSCR. Note that FPSCR is not modeled at the DAG level.
2659 let Uses = [RM], Defs = [RM] in {
2660 def MTFSB0 : XForm_43<63, 70, (outs), (ins u5imm:$FM),
2661 "mtfsb0 $FM", IIC_IntMTFSB0, []>,
2662 PPC970_DGroup_Single, PPC970_Unit_FPU;
2663 def MTFSB1 : XForm_43<63, 38, (outs), (ins u5imm:$FM),
2664 "mtfsb1 $FM", IIC_IntMTFSB0, []>,
2665 PPC970_DGroup_Single, PPC970_Unit_FPU;
2666 let isCodeGenOnly = 1 in
2667 def MTFSFb : XFLForm<63, 711, (outs), (ins i32imm:$FM, f8rc:$rT),
2668 "mtfsf $FM, $rT", IIC_IntMTFSB0, []>,
2669 PPC970_DGroup_Single, PPC970_Unit_FPU;
2671 let Uses = [RM] in {
2672 def MFFS : XForm_42<63, 583, (outs f8rc:$rT), (ins),
2673 "mffs $rT", IIC_IntMFFS,
2674 [(set f64:$rT, (PPCmffs))]>,
2675 PPC970_DGroup_Single, PPC970_Unit_FPU;
2678 def MFFSo : XForm_42<63, 583, (outs f8rc:$rT), (ins),
2679 "mffs. $rT", IIC_IntMFFS, []>, isDOT;
2681 def MFFSCE : X_FRT5_XO2_XO3_XO10<63, 0, 1, 583, (outs f8rc:$rT), (ins),
2682 "mffsce $rT", IIC_IntMFFS, []>,
2683 PPC970_DGroup_Single, PPC970_Unit_FPU;
2685 def MFFSCDRN : X_FRT5_XO2_XO3_FRB5_XO10<63, 2, 4, 583, (outs f8rc:$rT),
2686 (ins f8rc:$FRB), "mffscdrn $rT, $FRB",
2688 PPC970_DGroup_Single, PPC970_Unit_FPU;
2690 def MFFSCDRNI : X_FRT5_XO2_XO3_DRM3_XO10<63, 2, 5, 583, (outs f8rc:$rT),
2692 "mffscdrni $rT, $DRM",
2694 PPC970_DGroup_Single, PPC970_Unit_FPU;
2696 def MFFSCRN : X_FRT5_XO2_XO3_FRB5_XO10<63, 2, 6, 583, (outs f8rc:$rT),
2697 (ins f8rc:$FRB), "mffscrn $rT, $FRB",
2699 PPC970_DGroup_Single, PPC970_Unit_FPU;
2701 def MFFSCRNI : X_FRT5_XO2_XO3_RM2_X10<63, 2, 7, 583, (outs f8rc:$rT),
2702 (ins u2imm:$RM), "mffscrni $rT, $RM",
2704 PPC970_DGroup_Single, PPC970_Unit_FPU;
2706 def MFFSL : X_FRT5_XO2_XO3_XO10<63, 3, 0, 583, (outs f8rc:$rT), (ins),
2707 "mffsl $rT", IIC_IntMFFS, []>,
2708 PPC970_DGroup_Single, PPC970_Unit_FPU;
2712 let Predicates = [IsISA3_0] in {
2713 def MODSW : XForm_8<31, 779, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2714 "modsw $rT, $rA, $rB", IIC_IntDivW,
2715 [(set i32:$rT, (srem i32:$rA, i32:$rB))]>;
2716 def MODUW : XForm_8<31, 267, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2717 "moduw $rT, $rA, $rB", IIC_IntDivW,
2718 [(set i32:$rT, (urem i32:$rA, i32:$rB))]>;
2721 let PPC970_Unit = 1, hasSideEffects = 0 in { // FXU Operations.
2722 // XO-Form instructions. Arithmetic instructions that can set overflow bit
2723 let isCommutable = 1 in
2724 defm ADD4 : XOForm_1r<31, 266, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2725 "add", "$rT, $rA, $rB", IIC_IntSimple,
2726 [(set i32:$rT, (add i32:$rA, i32:$rB))]>;
2727 let isCodeGenOnly = 1 in
2728 def ADD4TLS : XOForm_1<31, 266, 0, (outs gprc:$rT), (ins gprc:$rA, tlsreg32:$rB),
2729 "add $rT, $rA, $rB", IIC_IntSimple,
2730 [(set i32:$rT, (add i32:$rA, tglobaltlsaddr:$rB))]>;
2731 let isCommutable = 1 in
2732 defm ADDC : XOForm_1rc<31, 10, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2733 "addc", "$rT, $rA, $rB", IIC_IntGeneral,
2734 [(set i32:$rT, (addc i32:$rA, i32:$rB))]>,
2735 PPC970_DGroup_Cracked;
2737 defm DIVW : XOForm_1rcr<31, 491, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2738 "divw", "$rT, $rA, $rB", IIC_IntDivW,
2739 [(set i32:$rT, (sdiv i32:$rA, i32:$rB))]>;
2740 defm DIVWU : XOForm_1rcr<31, 459, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2741 "divwu", "$rT, $rA, $rB", IIC_IntDivW,
2742 [(set i32:$rT, (udiv i32:$rA, i32:$rB))]>;
2743 def DIVWE : XOForm_1<31, 427, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2744 "divwe $rT, $rA, $rB", IIC_IntDivW,
2745 [(set i32:$rT, (int_ppc_divwe gprc:$rA, gprc:$rB))]>,
2746 Requires<[HasExtDiv]>;
2748 def DIVWEo : XOForm_1<31, 427, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2749 "divwe. $rT, $rA, $rB", IIC_IntDivW,
2750 []>, isDOT, PPC970_DGroup_Cracked, PPC970_DGroup_First,
2751 Requires<[HasExtDiv]>;
2752 def DIVWEU : XOForm_1<31, 395, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2753 "divweu $rT, $rA, $rB", IIC_IntDivW,
2754 [(set i32:$rT, (int_ppc_divweu gprc:$rA, gprc:$rB))]>,
2755 Requires<[HasExtDiv]>;
2757 def DIVWEUo : XOForm_1<31, 395, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2758 "divweu. $rT, $rA, $rB", IIC_IntDivW,
2759 []>, isDOT, PPC970_DGroup_Cracked, PPC970_DGroup_First,
2760 Requires<[HasExtDiv]>;
2761 let isCommutable = 1 in {
2762 defm MULHW : XOForm_1r<31, 75, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2763 "mulhw", "$rT, $rA, $rB", IIC_IntMulHW,
2764 [(set i32:$rT, (mulhs i32:$rA, i32:$rB))]>;
2765 defm MULHWU : XOForm_1r<31, 11, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2766 "mulhwu", "$rT, $rA, $rB", IIC_IntMulHWU,
2767 [(set i32:$rT, (mulhu i32:$rA, i32:$rB))]>;
2768 defm MULLW : XOForm_1r<31, 235, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2769 "mullw", "$rT, $rA, $rB", IIC_IntMulHW,
2770 [(set i32:$rT, (mul i32:$rA, i32:$rB))]>;
2772 defm SUBF : XOForm_1r<31, 40, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2773 "subf", "$rT, $rA, $rB", IIC_IntGeneral,
2774 [(set i32:$rT, (sub i32:$rB, i32:$rA))]>;
2775 defm SUBFC : XOForm_1rc<31, 8, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2776 "subfc", "$rT, $rA, $rB", IIC_IntGeneral,
2777 [(set i32:$rT, (subc i32:$rB, i32:$rA))]>,
2778 PPC970_DGroup_Cracked;
2779 defm NEG : XOForm_3r<31, 104, 0, (outs gprc:$rT), (ins gprc:$rA),
2780 "neg", "$rT, $rA", IIC_IntSimple,
2781 [(set i32:$rT, (ineg i32:$rA))]>;
2782 let Uses = [CARRY] in {
2783 let isCommutable = 1 in
2784 defm ADDE : XOForm_1rc<31, 138, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2785 "adde", "$rT, $rA, $rB", IIC_IntGeneral,
2786 [(set i32:$rT, (adde i32:$rA, i32:$rB))]>;
2787 defm ADDME : XOForm_3rc<31, 234, 0, (outs gprc:$rT), (ins gprc:$rA),
2788 "addme", "$rT, $rA", IIC_IntGeneral,
2789 [(set i32:$rT, (adde i32:$rA, -1))]>;
2790 defm ADDZE : XOForm_3rc<31, 202, 0, (outs gprc:$rT), (ins gprc:$rA),
2791 "addze", "$rT, $rA", IIC_IntGeneral,
2792 [(set i32:$rT, (adde i32:$rA, 0))]>;
2793 defm SUBFE : XOForm_1rc<31, 136, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2794 "subfe", "$rT, $rA, $rB", IIC_IntGeneral,
2795 [(set i32:$rT, (sube i32:$rB, i32:$rA))]>;
2796 defm SUBFME : XOForm_3rc<31, 232, 0, (outs gprc:$rT), (ins gprc:$rA),
2797 "subfme", "$rT, $rA", IIC_IntGeneral,
2798 [(set i32:$rT, (sube -1, i32:$rA))]>;
2799 defm SUBFZE : XOForm_3rc<31, 200, 0, (outs gprc:$rT), (ins gprc:$rA),
2800 "subfze", "$rT, $rA", IIC_IntGeneral,
2801 [(set i32:$rT, (sube 0, i32:$rA))]>;
2805 // A-Form instructions. Most of the instructions executed in the FPU are of
2808 let PPC970_Unit = 3, hasSideEffects = 0, Predicates = [HasFPU] in { // FPU Operations.
2809 let Uses = [RM] in {
2810 let isCommutable = 1 in {
2811 defm FMADD : AForm_1r<63, 29,
2812 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2813 "fmadd", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2814 [(set f64:$FRT, (fma f64:$FRA, f64:$FRC, f64:$FRB))]>;
2815 defm FMADDS : AForm_1r<59, 29,
2816 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2817 "fmadds", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2818 [(set f32:$FRT, (fma f32:$FRA, f32:$FRC, f32:$FRB))]>;
2819 defm FMSUB : AForm_1r<63, 28,
2820 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2821 "fmsub", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2823 (fma f64:$FRA, f64:$FRC, (fneg f64:$FRB)))]>;
2824 defm FMSUBS : AForm_1r<59, 28,
2825 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2826 "fmsubs", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2828 (fma f32:$FRA, f32:$FRC, (fneg f32:$FRB)))]>;
2829 defm FNMADD : AForm_1r<63, 31,
2830 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2831 "fnmadd", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2833 (fneg (fma f64:$FRA, f64:$FRC, f64:$FRB)))]>;
2834 defm FNMADDS : AForm_1r<59, 31,
2835 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2836 "fnmadds", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2838 (fneg (fma f32:$FRA, f32:$FRC, f32:$FRB)))]>;
2839 defm FNMSUB : AForm_1r<63, 30,
2840 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2841 "fnmsub", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2842 [(set f64:$FRT, (fneg (fma f64:$FRA, f64:$FRC,
2843 (fneg f64:$FRB))))]>;
2844 defm FNMSUBS : AForm_1r<59, 30,
2845 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2846 "fnmsubs", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2847 [(set f32:$FRT, (fneg (fma f32:$FRA, f32:$FRC,
2848 (fneg f32:$FRB))))]>;
2851 // FSEL is artificially split into 4 and 8-byte forms for the result. To avoid
2852 // having 4 of these, force the comparison to always be an 8-byte double (code
2853 // should use an FMRSD if the input comparison value really wants to be a float)
2854 // and 4/8 byte forms for the result and operand type..
2855 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2856 defm FSELD : AForm_1r<63, 23,
2857 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2858 "fsel", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2859 [(set f64:$FRT, (PPCfsel f64:$FRA, f64:$FRC, f64:$FRB))]>;
2860 defm FSELS : AForm_1r<63, 23,
2861 (outs f4rc:$FRT), (ins f8rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2862 "fsel", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2863 [(set f32:$FRT, (PPCfsel f64:$FRA, f32:$FRC, f32:$FRB))]>;
2864 let Uses = [RM] in {
2865 let isCommutable = 1 in {
2866 defm FADD : AForm_2r<63, 21,
2867 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB),
2868 "fadd", "$FRT, $FRA, $FRB", IIC_FPAddSub,
2869 [(set f64:$FRT, (fadd f64:$FRA, f64:$FRB))]>;
2870 defm FADDS : AForm_2r<59, 21,
2871 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB),
2872 "fadds", "$FRT, $FRA, $FRB", IIC_FPGeneral,
2873 [(set f32:$FRT, (fadd f32:$FRA, f32:$FRB))]>;
2875 defm FDIV : AForm_2r<63, 18,
2876 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB),
2877 "fdiv", "$FRT, $FRA, $FRB", IIC_FPDivD,
2878 [(set f64:$FRT, (fdiv f64:$FRA, f64:$FRB))]>;
2879 defm FDIVS : AForm_2r<59, 18,
2880 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB),
2881 "fdivs", "$FRT, $FRA, $FRB", IIC_FPDivS,
2882 [(set f32:$FRT, (fdiv f32:$FRA, f32:$FRB))]>;
2883 let isCommutable = 1 in {
2884 defm FMUL : AForm_3r<63, 25,
2885 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC),
2886 "fmul", "$FRT, $FRA, $FRC", IIC_FPFused,
2887 [(set f64:$FRT, (fmul f64:$FRA, f64:$FRC))]>;
2888 defm FMULS : AForm_3r<59, 25,
2889 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC),
2890 "fmuls", "$FRT, $FRA, $FRC", IIC_FPGeneral,
2891 [(set f32:$FRT, (fmul f32:$FRA, f32:$FRC))]>;
2893 defm FSUB : AForm_2r<63, 20,
2894 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB),
2895 "fsub", "$FRT, $FRA, $FRB", IIC_FPAddSub,
2896 [(set f64:$FRT, (fsub f64:$FRA, f64:$FRB))]>;
2897 defm FSUBS : AForm_2r<59, 20,
2898 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB),
2899 "fsubs", "$FRT, $FRA, $FRB", IIC_FPGeneral,
2900 [(set f32:$FRT, (fsub f32:$FRA, f32:$FRB))]>;
2904 let hasSideEffects = 0 in {
2905 let PPC970_Unit = 1 in { // FXU Operations.
2907 def ISEL : AForm_4<31, 15,
2908 (outs gprc:$rT), (ins gprc_nor0:$rA, gprc:$rB, crbitrc:$cond),
2909 "isel $rT, $rA, $rB, $cond", IIC_IntISEL,
2913 let PPC970_Unit = 1 in { // FXU Operations.
2914 // M-Form instructions. rotate and mask instructions.
2916 let isCommutable = 1 in {
2917 // RLWIMI can be commuted if the rotate amount is zero.
2918 defm RLWIMI : MForm_2r<20, (outs gprc:$rA),
2919 (ins gprc:$rSi, gprc:$rS, u5imm:$SH, u5imm:$MB,
2920 u5imm:$ME), "rlwimi", "$rA, $rS, $SH, $MB, $ME",
2921 IIC_IntRotate, []>, PPC970_DGroup_Cracked,
2922 RegConstraint<"$rSi = $rA">, NoEncode<"$rSi">;
2924 let BaseName = "rlwinm" in {
2925 def RLWINM : MForm_2<21,
2926 (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
2927 "rlwinm $rA, $rS, $SH, $MB, $ME", IIC_IntGeneral,
2930 def RLWINMo : MForm_2<21,
2931 (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
2932 "rlwinm. $rA, $rS, $SH, $MB, $ME", IIC_IntGeneral,
2933 []>, isDOT, RecFormRel, PPC970_DGroup_Cracked;
2935 defm RLWNM : MForm_2r<23, (outs gprc:$rA),
2936 (ins gprc:$rS, gprc:$rB, u5imm:$MB, u5imm:$ME),
2937 "rlwnm", "$rA, $rS, $rB, $MB, $ME", IIC_IntGeneral,
2940 } // hasSideEffects = 0
2942 //===----------------------------------------------------------------------===//
2943 // PowerPC Instruction Patterns
2946 // Arbitrary immediate support. Implement in terms of LIS/ORI.
2947 def : Pat<(i32 imm:$imm),
2948 (ORI (LIS (HI16 imm:$imm)), (LO16 imm:$imm))>;
2950 // Implement the 'not' operation with the NOR instruction.
2951 def i32not : OutPatFrag<(ops node:$in),
2953 def : Pat<(not i32:$in),
2956 // ADD an arbitrary immediate.
2957 def : Pat<(add i32:$in, imm:$imm),
2958 (ADDIS (ADDI $in, (LO16 imm:$imm)), (HA16 imm:$imm))>;
2959 // OR an arbitrary immediate.
2960 def : Pat<(or i32:$in, imm:$imm),
2961 (ORIS (ORI $in, (LO16 imm:$imm)), (HI16 imm:$imm))>;
2962 // XOR an arbitrary immediate.
2963 def : Pat<(xor i32:$in, imm:$imm),
2964 (XORIS (XORI $in, (LO16 imm:$imm)), (HI16 imm:$imm))>;
2966 def : Pat<(sub imm32SExt16:$imm, i32:$in),
2967 (SUBFIC $in, imm:$imm)>;
2970 def : Pat<(shl i32:$in, (i32 imm:$imm)),
2971 (RLWINM $in, imm:$imm, 0, (SHL32 imm:$imm))>;
2972 def : Pat<(srl i32:$in, (i32 imm:$imm)),
2973 (RLWINM $in, (SRL32 imm:$imm), imm:$imm, 31)>;
2976 def : Pat<(rotl i32:$in, i32:$sh),
2977 (RLWNM $in, $sh, 0, 31)>;
2978 def : Pat<(rotl i32:$in, (i32 imm:$imm)),
2979 (RLWINM $in, imm:$imm, 0, 31)>;
2982 def : Pat<(and (rotl i32:$in, i32:$sh), maskimm32:$imm),
2983 (RLWNM $in, $sh, (MB maskimm32:$imm), (ME maskimm32:$imm))>;
2986 def : Pat<(PPCcall (i32 tglobaladdr:$dst)),
2987 (BL tglobaladdr:$dst)>;
2988 def : Pat<(PPCcall (i32 texternalsym:$dst)),
2989 (BL texternalsym:$dst)>;
2991 def : Pat<(PPCtc_return (i32 tglobaladdr:$dst), imm:$imm),
2992 (TCRETURNdi tglobaladdr:$dst, imm:$imm)>;
2994 def : Pat<(PPCtc_return (i32 texternalsym:$dst), imm:$imm),
2995 (TCRETURNdi texternalsym:$dst, imm:$imm)>;
2997 def : Pat<(PPCtc_return CTRRC:$dst, imm:$imm),
2998 (TCRETURNri CTRRC:$dst, imm:$imm)>;
3002 // Hi and Lo for Darwin Global Addresses.
3003 def : Pat<(PPChi tglobaladdr:$in, 0), (LIS tglobaladdr:$in)>;
3004 def : Pat<(PPClo tglobaladdr:$in, 0), (LI tglobaladdr:$in)>;
3005 def : Pat<(PPChi tconstpool:$in, 0), (LIS tconstpool:$in)>;
3006 def : Pat<(PPClo tconstpool:$in, 0), (LI tconstpool:$in)>;
3007 def : Pat<(PPChi tjumptable:$in, 0), (LIS tjumptable:$in)>;
3008 def : Pat<(PPClo tjumptable:$in, 0), (LI tjumptable:$in)>;
3009 def : Pat<(PPChi tblockaddress:$in, 0), (LIS tblockaddress:$in)>;
3010 def : Pat<(PPClo tblockaddress:$in, 0), (LI tblockaddress:$in)>;
3011 def : Pat<(PPChi tglobaltlsaddr:$g, i32:$in),
3012 (ADDIS $in, tglobaltlsaddr:$g)>;
3013 def : Pat<(PPClo tglobaltlsaddr:$g, i32:$in),
3014 (ADDI $in, tglobaltlsaddr:$g)>;
3015 def : Pat<(add i32:$in, (PPChi tglobaladdr:$g, 0)),
3016 (ADDIS $in, tglobaladdr:$g)>;
3017 def : Pat<(add i32:$in, (PPChi tconstpool:$g, 0)),
3018 (ADDIS $in, tconstpool:$g)>;
3019 def : Pat<(add i32:$in, (PPChi tjumptable:$g, 0)),
3020 (ADDIS $in, tjumptable:$g)>;
3021 def : Pat<(add i32:$in, (PPChi tblockaddress:$g, 0)),
3022 (ADDIS $in, tblockaddress:$g)>;
3024 // Support for thread-local storage.
3025 def PPC32GOT: Pseudo<(outs gprc:$rD), (ins), "#PPC32GOT",
3026 [(set i32:$rD, (PPCppc32GOT))]>;
3028 // Get the _GLOBAL_OFFSET_TABLE_ in PIC mode.
3029 // This uses two output registers, the first as the real output, the second as a
3030 // temporary register, used internally in code generation.
3031 def PPC32PICGOT: Pseudo<(outs gprc:$rD, gprc:$rT), (ins), "#PPC32PICGOT",
3032 []>, NoEncode<"$rT">;
3034 def LDgotTprelL32: Pseudo<(outs gprc:$rD), (ins s16imm:$disp, gprc_nor0:$reg),
3037 (PPCldGotTprelL tglobaltlsaddr:$disp, i32:$reg))]>;
3038 def : Pat<(PPCaddTls i32:$in, tglobaltlsaddr:$g),
3039 (ADD4TLS $in, tglobaltlsaddr:$g)>;
3041 def ADDItlsgdL32 : Pseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
3044 (PPCaddiTlsgdL i32:$reg, tglobaltlsaddr:$disp))]>;
3045 // LR is a true define, while the rest of the Defs are clobbers. R3 is
3046 // explicitly defined when this op is created, so not mentioned here.
3047 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
3048 Defs = [R0,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
3049 def GETtlsADDR32 : Pseudo<(outs gprc:$rD), (ins gprc:$reg, tlsgd32:$sym),
3052 (PPCgetTlsAddr i32:$reg, tglobaltlsaddr:$sym))]>;
3053 // Combined op for ADDItlsgdL32 and GETtlsADDR32, late expanded. R3 and LR
3054 // are true defines while the rest of the Defs are clobbers.
3055 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
3056 Defs = [R0,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
3057 def ADDItlsgdLADDR32 : Pseudo<(outs gprc:$rD),
3058 (ins gprc_nor0:$reg, s16imm:$disp, tlsgd32:$sym),
3059 "#ADDItlsgdLADDR32",
3061 (PPCaddiTlsgdLAddr i32:$reg,
3062 tglobaltlsaddr:$disp,
3063 tglobaltlsaddr:$sym))]>;
3064 def ADDItlsldL32 : Pseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
3067 (PPCaddiTlsldL i32:$reg, tglobaltlsaddr:$disp))]>;
3068 // LR is a true define, while the rest of the Defs are clobbers. R3 is
3069 // explicitly defined when this op is created, so not mentioned here.
3070 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
3071 Defs = [R0,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
3072 def GETtlsldADDR32 : Pseudo<(outs gprc:$rD), (ins gprc:$reg, tlsgd32:$sym),
3075 (PPCgetTlsldAddr i32:$reg,
3076 tglobaltlsaddr:$sym))]>;
3077 // Combined op for ADDItlsldL32 and GETtlsADDR32, late expanded. R3 and LR
3078 // are true defines while the rest of the Defs are clobbers.
3079 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
3080 Defs = [R0,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
3081 def ADDItlsldLADDR32 : Pseudo<(outs gprc:$rD),
3082 (ins gprc_nor0:$reg, s16imm:$disp, tlsgd32:$sym),
3083 "#ADDItlsldLADDR32",
3085 (PPCaddiTlsldLAddr i32:$reg,
3086 tglobaltlsaddr:$disp,
3087 tglobaltlsaddr:$sym))]>;
3088 def ADDIdtprelL32 : Pseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
3091 (PPCaddiDtprelL i32:$reg, tglobaltlsaddr:$disp))]>;
3092 def ADDISdtprelHA32 : Pseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
3095 (PPCaddisDtprelHA i32:$reg,
3096 tglobaltlsaddr:$disp))]>;
3098 // Support for Position-independent code
3099 def LWZtoc : Pseudo<(outs gprc:$rD), (ins tocentry32:$disp, gprc:$reg),
3102 (PPCtoc_entry tglobaladdr:$disp, i32:$reg))]>;
3103 // Get Global (GOT) Base Register offset, from the word immediately preceding
3104 // the function label.
3105 def UpdateGBR : Pseudo<(outs gprc:$rD, gprc:$rT), (ins gprc:$rI), "#UpdateGBR", []>;
3108 // Standard shifts. These are represented separately from the real shifts above
3109 // so that we can distinguish between shifts that allow 5-bit and 6-bit shift
3111 def : Pat<(sra i32:$rS, i32:$rB),
3113 def : Pat<(srl i32:$rS, i32:$rB),
3115 def : Pat<(shl i32:$rS, i32:$rB),
3118 def : Pat<(zextloadi1 iaddr:$src),
3120 def : Pat<(zextloadi1 xaddr:$src),
3122 def : Pat<(extloadi1 iaddr:$src),
3124 def : Pat<(extloadi1 xaddr:$src),
3126 def : Pat<(extloadi8 iaddr:$src),
3128 def : Pat<(extloadi8 xaddr:$src),
3130 def : Pat<(extloadi16 iaddr:$src),
3132 def : Pat<(extloadi16 xaddr:$src),
3134 let Predicates = [HasFPU] in {
3135 def : Pat<(f64 (extloadf32 iaddr:$src)),
3136 (COPY_TO_REGCLASS (LFS iaddr:$src), F8RC)>;
3137 def : Pat<(f64 (extloadf32 xaddr:$src)),
3138 (COPY_TO_REGCLASS (LFSX xaddr:$src), F8RC)>;
3140 def : Pat<(f64 (fpextend f32:$src)),
3141 (COPY_TO_REGCLASS $src, F8RC)>;
3144 // Only seq_cst fences require the heavyweight sync (SYNC 0).
3145 // All others can use the lightweight sync (SYNC 1).
3146 // source: http://www.cl.cam.ac.uk/~pes20/cpp/cpp0xmappings.html
3147 // The rule for seq_cst is duplicated to work with both 64 bits and 32 bits
3148 // versions of Power.
3149 def : Pat<(atomic_fence (i64 7), (imm)), (SYNC 0)>, Requires<[HasSYNC]>;
3150 def : Pat<(atomic_fence (i32 7), (imm)), (SYNC 0)>, Requires<[HasSYNC]>;
3151 def : Pat<(atomic_fence (imm), (imm)), (SYNC 1)>, Requires<[HasSYNC]>;
3152 def : Pat<(atomic_fence (imm), (imm)), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
3154 let Predicates = [HasFPU] in {
3155 // Additional FNMSUB patterns: -a*c + b == -(a*c - b)
3156 def : Pat<(fma (fneg f64:$A), f64:$C, f64:$B),
3157 (FNMSUB $A, $C, $B)>;
3158 def : Pat<(fma f64:$A, (fneg f64:$C), f64:$B),
3159 (FNMSUB $A, $C, $B)>;
3160 def : Pat<(fma (fneg f32:$A), f32:$C, f32:$B),
3161 (FNMSUBS $A, $C, $B)>;
3162 def : Pat<(fma f32:$A, (fneg f32:$C), f32:$B),
3163 (FNMSUBS $A, $C, $B)>;
3165 // FCOPYSIGN's operand types need not agree.
3166 def : Pat<(fcopysign f64:$frB, f32:$frA),
3167 (FCPSGND (COPY_TO_REGCLASS $frA, F8RC), $frB)>;
3168 def : Pat<(fcopysign f32:$frB, f64:$frA),
3169 (FCPSGNS (COPY_TO_REGCLASS $frA, F4RC), $frB)>;
3172 include "PPCInstrAltivec.td"
3173 include "PPCInstrSPE.td"
3174 include "PPCInstr64Bit.td"
3175 include "PPCInstrVSX.td"
3176 include "PPCInstrQPX.td"
3177 include "PPCInstrHTM.td"
3179 def crnot : OutPatFrag<(ops node:$in),
3181 def : Pat<(not i1:$in),
3184 // Patterns for arithmetic i1 operations.
3185 def : Pat<(add i1:$a, i1:$b),
3187 def : Pat<(sub i1:$a, i1:$b),
3189 def : Pat<(mul i1:$a, i1:$b),
3192 // We're sometimes asked to materialize i1 -1, which is just 1 in this case
3193 // (-1 is used to mean all bits set).
3194 def : Pat<(i1 -1), (CRSET)>;
3196 // i1 extensions, implemented in terms of isel.
3197 def : Pat<(i32 (zext i1:$in)),
3198 (SELECT_I4 $in, (LI 1), (LI 0))>;
3199 def : Pat<(i32 (sext i1:$in)),
3200 (SELECT_I4 $in, (LI -1), (LI 0))>;
3202 def : Pat<(i64 (zext i1:$in)),
3203 (SELECT_I8 $in, (LI8 1), (LI8 0))>;
3204 def : Pat<(i64 (sext i1:$in)),
3205 (SELECT_I8 $in, (LI8 -1), (LI8 0))>;
3207 // FIXME: We should choose either a zext or a sext based on other constants
3209 def : Pat<(i32 (anyext i1:$in)),
3210 (SELECT_I4 $in, (LI 1), (LI 0))>;
3211 def : Pat<(i64 (anyext i1:$in)),
3212 (SELECT_I8 $in, (LI8 1), (LI8 0))>;
3214 // match setcc on i1 variables.
3232 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETLT)),
3234 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETULT)),
3253 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETLE)),
3255 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETULE)),
3258 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETEQ)),
3272 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETGE)),
3274 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETUGE)),
3288 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETGT)),
3290 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETUGT)),
3293 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETNE)),
3296 // match setcc on non-i1 (non-vector) variables. Note that SETUEQ, SETOGE,
3297 // SETOLE, SETONE, SETULT and SETUGT should be expanded by legalize for
3298 // floating-point types.
3300 multiclass CRNotPat<dag pattern, dag result> {
3301 def : Pat<pattern, (crnot result)>;
3302 def : Pat<(not pattern), result>;
3304 // We can also fold the crnot into an extension:
3305 def : Pat<(i32 (zext pattern)),
3306 (SELECT_I4 result, (LI 0), (LI 1))>;
3307 def : Pat<(i32 (sext pattern)),
3308 (SELECT_I4 result, (LI 0), (LI -1))>;
3310 // We can also fold the crnot into an extension:
3311 def : Pat<(i64 (zext pattern)),
3312 (SELECT_I8 result, (LI8 0), (LI8 1))>;
3313 def : Pat<(i64 (sext pattern)),
3314 (SELECT_I8 result, (LI8 0), (LI8 -1))>;
3316 // FIXME: We should choose either a zext or a sext based on other constants
3318 def : Pat<(i32 (anyext pattern)),
3319 (SELECT_I4 result, (LI 0), (LI 1))>;
3321 def : Pat<(i64 (anyext pattern)),
3322 (SELECT_I8 result, (LI8 0), (LI8 1))>;
3325 // FIXME: Because of what seems like a bug in TableGen's type-inference code,
3326 // we need to write imm:$imm in the output patterns below, not just $imm, or
3327 // else the resulting matcher will not correctly add the immediate operand
3328 // (making it a register operand instead).
3331 multiclass ExtSetCCPat<CondCode cc, PatFrag pfrag,
3332 OutPatFrag rfrag, OutPatFrag rfrag8> {
3333 def : Pat<(i32 (zext (i1 (pfrag i32:$s1, cc)))),
3335 def : Pat<(i64 (zext (i1 (pfrag i64:$s1, cc)))),
3337 def : Pat<(i64 (zext (i1 (pfrag i32:$s1, cc)))),
3338 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1), sub_32)>;
3339 def : Pat<(i32 (zext (i1 (pfrag i64:$s1, cc)))),
3340 (EXTRACT_SUBREG (rfrag8 $s1), sub_32)>;
3342 def : Pat<(i32 (anyext (i1 (pfrag i32:$s1, cc)))),
3344 def : Pat<(i64 (anyext (i1 (pfrag i64:$s1, cc)))),
3346 def : Pat<(i64 (anyext (i1 (pfrag i32:$s1, cc)))),
3347 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1), sub_32)>;
3348 def : Pat<(i32 (anyext (i1 (pfrag i64:$s1, cc)))),
3349 (EXTRACT_SUBREG (rfrag8 $s1), sub_32)>;
3352 // Note that we do all inversions below with i(32|64)not, instead of using
3353 // (xori x, 1) because on the A2 nor has single-cycle latency while xori
3354 // has 2-cycle latency.
3356 defm : ExtSetCCPat<SETEQ,
3357 PatFrag<(ops node:$in, node:$cc),
3358 (setcc $in, 0, $cc)>,
3359 OutPatFrag<(ops node:$in),
3360 (RLWINM (CNTLZW $in), 27, 31, 31)>,
3361 OutPatFrag<(ops node:$in),
3362 (RLDICL (CNTLZD $in), 58, 63)> >;
3364 defm : ExtSetCCPat<SETNE,
3365 PatFrag<(ops node:$in, node:$cc),
3366 (setcc $in, 0, $cc)>,
3367 OutPatFrag<(ops node:$in),
3368 (RLWINM (i32not (CNTLZW $in)), 27, 31, 31)>,
3369 OutPatFrag<(ops node:$in),
3370 (RLDICL (i64not (CNTLZD $in)), 58, 63)> >;
3372 defm : ExtSetCCPat<SETLT,
3373 PatFrag<(ops node:$in, node:$cc),
3374 (setcc $in, 0, $cc)>,
3375 OutPatFrag<(ops node:$in),
3376 (RLWINM $in, 1, 31, 31)>,
3377 OutPatFrag<(ops node:$in),
3378 (RLDICL $in, 1, 63)> >;
3380 defm : ExtSetCCPat<SETGE,
3381 PatFrag<(ops node:$in, node:$cc),
3382 (setcc $in, 0, $cc)>,
3383 OutPatFrag<(ops node:$in),
3384 (RLWINM (i32not $in), 1, 31, 31)>,
3385 OutPatFrag<(ops node:$in),
3386 (RLDICL (i64not $in), 1, 63)> >;
3388 defm : ExtSetCCPat<SETGT,
3389 PatFrag<(ops node:$in, node:$cc),
3390 (setcc $in, 0, $cc)>,
3391 OutPatFrag<(ops node:$in),
3392 (RLWINM (ANDC (NEG $in), $in), 1, 31, 31)>,
3393 OutPatFrag<(ops node:$in),
3394 (RLDICL (ANDC8 (NEG8 $in), $in), 1, 63)> >;
3396 defm : ExtSetCCPat<SETLE,
3397 PatFrag<(ops node:$in, node:$cc),
3398 (setcc $in, 0, $cc)>,
3399 OutPatFrag<(ops node:$in),
3400 (RLWINM (ORC $in, (NEG $in)), 1, 31, 31)>,
3401 OutPatFrag<(ops node:$in),
3402 (RLDICL (ORC8 $in, (NEG8 $in)), 1, 63)> >;
3404 defm : ExtSetCCPat<SETLT,
3405 PatFrag<(ops node:$in, node:$cc),
3406 (setcc $in, -1, $cc)>,
3407 OutPatFrag<(ops node:$in),
3408 (RLWINM (AND $in, (ADDI $in, 1)), 1, 31, 31)>,
3409 OutPatFrag<(ops node:$in),
3410 (RLDICL (AND8 $in, (ADDI8 $in, 1)), 1, 63)> >;
3412 defm : ExtSetCCPat<SETGE,
3413 PatFrag<(ops node:$in, node:$cc),
3414 (setcc $in, -1, $cc)>,
3415 OutPatFrag<(ops node:$in),
3416 (RLWINM (NAND $in, (ADDI $in, 1)), 1, 31, 31)>,
3417 OutPatFrag<(ops node:$in),
3418 (RLDICL (NAND8 $in, (ADDI8 $in, 1)), 1, 63)> >;
3420 defm : ExtSetCCPat<SETGT,
3421 PatFrag<(ops node:$in, node:$cc),
3422 (setcc $in, -1, $cc)>,
3423 OutPatFrag<(ops node:$in),
3424 (RLWINM (i32not $in), 1, 31, 31)>,
3425 OutPatFrag<(ops node:$in),
3426 (RLDICL (i64not $in), 1, 63)> >;
3428 defm : ExtSetCCPat<SETLE,
3429 PatFrag<(ops node:$in, node:$cc),
3430 (setcc $in, -1, $cc)>,
3431 OutPatFrag<(ops node:$in),
3432 (RLWINM $in, 1, 31, 31)>,
3433 OutPatFrag<(ops node:$in),
3434 (RLDICL $in, 1, 63)> >;
3436 // An extended SETCC with shift amount.
3437 multiclass ExtSetCCShiftPat<CondCode cc, PatFrag pfrag,
3438 OutPatFrag rfrag, OutPatFrag rfrag8> {
3439 def : Pat<(i32 (zext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
3441 def : Pat<(i64 (zext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
3443 def : Pat<(i64 (zext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
3444 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1, $sa), sub_32)>;
3445 def : Pat<(i32 (zext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
3446 (EXTRACT_SUBREG (rfrag8 $s1, $sa), sub_32)>;
3448 def : Pat<(i32 (anyext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
3450 def : Pat<(i64 (anyext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
3452 def : Pat<(i64 (anyext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
3453 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1, $sa), sub_32)>;
3454 def : Pat<(i32 (anyext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
3455 (EXTRACT_SUBREG (rfrag8 $s1, $sa), sub_32)>;
3458 defm : ExtSetCCShiftPat<SETNE,
3459 PatFrag<(ops node:$in, node:$sa, node:$cc),
3460 (setcc (and $in, (shl 1, $sa)), 0, $cc)>,
3461 OutPatFrag<(ops node:$in, node:$sa),
3462 (RLWNM $in, (SUBFIC $sa, 32), 31, 31)>,
3463 OutPatFrag<(ops node:$in, node:$sa),
3464 (RLDCL $in, (SUBFIC $sa, 64), 63)> >;
3466 defm : ExtSetCCShiftPat<SETEQ,
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 (i32not $in),
3471 (SUBFIC $sa, 32), 31, 31)>,
3472 OutPatFrag<(ops node:$in, node:$sa),
3473 (RLDCL (i64not $in),
3474 (SUBFIC $sa, 64), 63)> >;
3477 def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETULT)),
3478 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_lt)>;
3479 def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETLT)),
3480 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_lt)>;
3481 def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETUGT)),
3482 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_gt)>;
3483 def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETGT)),
3484 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_gt)>;
3485 def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETEQ)),
3486 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_eq)>;
3487 def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETEQ)),
3488 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_eq)>;
3490 // For non-equality comparisons, the default code would materialize the
3491 // constant, then compare against it, like this:
3493 // ori r2, r2, 22136
3496 // Since we are just comparing for equality, we can emit this instead:
3497 // xoris r0,r3,0x1234
3498 // cmplwi cr0,r0,0x5678
3501 def : Pat<(i1 (setcc i32:$s1, imm:$imm, SETEQ)),
3502 (EXTRACT_SUBREG (CMPLWI (XORIS $s1, (HI16 imm:$imm)),
3503 (LO16 imm:$imm)), sub_eq)>;
3505 defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETUGE)),
3506 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_lt)>;
3507 defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETGE)),
3508 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_lt)>;
3509 defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETULE)),
3510 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_gt)>;
3511 defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETLE)),
3512 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_gt)>;
3513 defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETNE)),
3514 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_eq)>;
3515 defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETNE)),
3516 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_eq)>;
3518 defm : CRNotPat<(i1 (setcc i32:$s1, imm:$imm, SETNE)),
3519 (EXTRACT_SUBREG (CMPLWI (XORIS $s1, (HI16 imm:$imm)),
3520 (LO16 imm:$imm)), sub_eq)>;
3522 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETULT)),
3523 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_lt)>;
3524 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETLT)),
3525 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_lt)>;
3526 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETUGT)),
3527 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_gt)>;
3528 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETGT)),
3529 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_gt)>;
3530 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETEQ)),
3531 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_eq)>;
3533 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETUGE)),
3534 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_lt)>;
3535 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETGE)),
3536 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_lt)>;
3537 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETULE)),
3538 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_gt)>;
3539 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETLE)),
3540 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_gt)>;
3541 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETNE)),
3542 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_eq)>;
3545 def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETULT)),
3546 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_lt)>;
3547 def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETLT)),
3548 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_lt)>;
3549 def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETUGT)),
3550 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_gt)>;
3551 def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETGT)),
3552 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_gt)>;
3553 def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETEQ)),
3554 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_eq)>;
3555 def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETEQ)),
3556 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_eq)>;
3558 // For non-equality comparisons, the default code would materialize the
3559 // constant, then compare against it, like this:
3561 // ori r2, r2, 22136
3564 // Since we are just comparing for equality, we can emit this instead:
3565 // xoris r0,r3,0x1234
3566 // cmpldi cr0,r0,0x5678
3569 def : Pat<(i1 (setcc i64:$s1, imm64ZExt32:$imm, SETEQ)),
3570 (EXTRACT_SUBREG (CMPLDI (XORIS8 $s1, (HI16 imm:$imm)),
3571 (LO16 imm:$imm)), sub_eq)>;
3573 defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETUGE)),
3574 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_lt)>;
3575 defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETGE)),
3576 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_lt)>;
3577 defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETULE)),
3578 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_gt)>;
3579 defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETLE)),
3580 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_gt)>;
3581 defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETNE)),
3582 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_eq)>;
3583 defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETNE)),
3584 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_eq)>;
3586 defm : CRNotPat<(i1 (setcc i64:$s1, imm64ZExt32:$imm, SETNE)),
3587 (EXTRACT_SUBREG (CMPLDI (XORIS8 $s1, (HI16 imm:$imm)),
3588 (LO16 imm:$imm)), sub_eq)>;
3590 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETULT)),
3591 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_lt)>;
3592 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETLT)),
3593 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_lt)>;
3594 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETUGT)),
3595 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_gt)>;
3596 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETGT)),
3597 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_gt)>;
3598 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETEQ)),
3599 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_eq)>;
3601 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETUGE)),
3602 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_lt)>;
3603 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETGE)),
3604 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_lt)>;
3605 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETULE)),
3606 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_gt)>;
3607 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETLE)),
3608 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_gt)>;
3609 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETNE)),
3610 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_eq)>;
3613 let Predicates = [HasFPU] in {
3614 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOLT)),
3615 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3616 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETLT)),
3617 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3618 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOGT)),
3619 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3620 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETGT)),
3621 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3622 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOEQ)),
3623 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3624 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETEQ)),
3625 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3626 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETUO)),
3627 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_un)>;
3629 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETUGE)),
3630 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3631 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETGE)),
3632 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3633 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETULE)),
3634 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3635 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETLE)),
3636 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3637 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETUNE)),
3638 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3639 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETNE)),
3640 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3641 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETO)),
3642 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_un)>;
3645 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOLT)),
3646 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3647 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETLT)),
3648 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3649 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOGT)),
3650 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3651 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETGT)),
3652 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3653 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOEQ)),
3654 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3655 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETEQ)),
3656 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3657 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETUO)),
3658 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_un)>;
3660 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETUGE)),
3661 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3662 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETGE)),
3663 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3664 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETULE)),
3665 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3666 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETLE)),
3667 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3668 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETUNE)),
3669 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3670 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETNE)),
3671 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3672 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETO)),
3673 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_un)>;
3676 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETOLT)),
3677 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_lt)>;
3678 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETLT)),
3679 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_lt)>;
3680 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETOGT)),
3681 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_gt)>;
3682 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETGT)),
3683 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_gt)>;
3684 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETOEQ)),
3685 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_eq)>;
3686 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETEQ)),
3687 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_eq)>;
3688 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETUO)),
3689 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_un)>;
3691 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETUGE)),
3692 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_lt)>;
3693 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETGE)),
3694 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_lt)>;
3695 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETULE)),
3696 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_gt)>;
3697 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETLE)),
3698 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_gt)>;
3699 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETUNE)),
3700 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_eq)>;
3701 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETNE)),
3702 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_eq)>;
3703 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETO)),
3704 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_un)>;
3708 // This must be in this file because it relies on patterns defined in this file
3709 // after the inclusion of the instruction sets.
3710 let Predicates = [HasSPE] in {
3712 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOLT)),
3713 (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>;
3714 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETLT)),
3715 (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>;
3716 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOGT)),
3717 (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>;
3718 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETGT)),
3719 (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>;
3720 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOEQ)),
3721 (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>;
3722 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETEQ)),
3723 (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>;
3725 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETUGE)),
3726 (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>;
3727 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETGE)),
3728 (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>;
3729 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETULE)),
3730 (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>;
3731 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETLE)),
3732 (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>;
3733 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETUNE)),
3734 (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>;
3735 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETNE)),
3736 (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>;
3739 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOLT)),
3740 (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>;
3741 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETLT)),
3742 (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>;
3743 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOGT)),
3744 (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>;
3745 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETGT)),
3746 (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>;
3747 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOEQ)),
3748 (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>;
3749 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETEQ)),
3750 (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>;
3752 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETUGE)),
3753 (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>;
3754 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETGE)),
3755 (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>;
3756 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETULE)),
3757 (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>;
3758 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETLE)),
3759 (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>;
3760 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETUNE)),
3761 (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>;
3762 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETNE)),
3763 (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>;
3765 // match select on i1 variables:
3766 def : Pat<(i1 (select i1:$cond, i1:$tval, i1:$fval)),
3767 (CROR (CRAND $cond , $tval),
3768 (CRAND (crnot $cond), $fval))>;
3770 // match selectcc on i1 variables:
3771 // select (lhs == rhs), tval, fval is:
3772 // ((lhs == rhs) & tval) | (!(lhs == rhs) & fval)
3773 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETLT)),
3774 (CROR (CRAND (CRANDC $lhs, $rhs), $tval),
3775 (CRAND (CRORC $rhs, $lhs), $fval))>;
3776 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETULT)),
3777 (CROR (CRAND (CRANDC $rhs, $lhs), $tval),
3778 (CRAND (CRORC $lhs, $rhs), $fval))>;
3779 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETLE)),
3780 (CROR (CRAND (CRORC $lhs, $rhs), $tval),
3781 (CRAND (CRANDC $rhs, $lhs), $fval))>;
3782 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETULE)),
3783 (CROR (CRAND (CRORC $rhs, $lhs), $tval),
3784 (CRAND (CRANDC $lhs, $rhs), $fval))>;
3785 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETEQ)),
3786 (CROR (CRAND (CREQV $lhs, $rhs), $tval),
3787 (CRAND (CRXOR $lhs, $rhs), $fval))>;
3788 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETGE)),
3789 (CROR (CRAND (CRORC $rhs, $lhs), $tval),
3790 (CRAND (CRANDC $lhs, $rhs), $fval))>;
3791 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETUGE)),
3792 (CROR (CRAND (CRORC $lhs, $rhs), $tval),
3793 (CRAND (CRANDC $rhs, $lhs), $fval))>;
3794 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETGT)),
3795 (CROR (CRAND (CRANDC $rhs, $lhs), $tval),
3796 (CRAND (CRORC $lhs, $rhs), $fval))>;
3797 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETUGT)),
3798 (CROR (CRAND (CRANDC $lhs, $rhs), $tval),
3799 (CRAND (CRORC $rhs, $lhs), $fval))>;
3800 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETNE)),
3801 (CROR (CRAND (CREQV $lhs, $rhs), $fval),
3802 (CRAND (CRXOR $lhs, $rhs), $tval))>;
3804 // match selectcc on i1 variables with non-i1 output.
3805 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETLT)),
3806 (SELECT_I4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3807 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETULT)),
3808 (SELECT_I4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3809 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETLE)),
3810 (SELECT_I4 (CRORC $lhs, $rhs), $tval, $fval)>;
3811 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETULE)),
3812 (SELECT_I4 (CRORC $rhs, $lhs), $tval, $fval)>;
3813 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETEQ)),
3814 (SELECT_I4 (CREQV $lhs, $rhs), $tval, $fval)>;
3815 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETGE)),
3816 (SELECT_I4 (CRORC $rhs, $lhs), $tval, $fval)>;
3817 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETUGE)),
3818 (SELECT_I4 (CRORC $lhs, $rhs), $tval, $fval)>;
3819 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETGT)),
3820 (SELECT_I4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3821 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETUGT)),
3822 (SELECT_I4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3823 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETNE)),
3824 (SELECT_I4 (CRXOR $lhs, $rhs), $tval, $fval)>;
3826 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETLT)),
3827 (SELECT_I8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3828 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETULT)),
3829 (SELECT_I8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3830 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETLE)),
3831 (SELECT_I8 (CRORC $lhs, $rhs), $tval, $fval)>;
3832 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETULE)),
3833 (SELECT_I8 (CRORC $rhs, $lhs), $tval, $fval)>;
3834 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETEQ)),
3835 (SELECT_I8 (CREQV $lhs, $rhs), $tval, $fval)>;
3836 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETGE)),
3837 (SELECT_I8 (CRORC $rhs, $lhs), $tval, $fval)>;
3838 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETUGE)),
3839 (SELECT_I8 (CRORC $lhs, $rhs), $tval, $fval)>;
3840 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETGT)),
3841 (SELECT_I8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3842 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETUGT)),
3843 (SELECT_I8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3844 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETNE)),
3845 (SELECT_I8 (CRXOR $lhs, $rhs), $tval, $fval)>;
3847 let Predicates = [HasFPU] in {
3848 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETLT)),
3849 (SELECT_F4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3850 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETULT)),
3851 (SELECT_F4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3852 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETLE)),
3853 (SELECT_F4 (CRORC $lhs, $rhs), $tval, $fval)>;
3854 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETULE)),
3855 (SELECT_F4 (CRORC $rhs, $lhs), $tval, $fval)>;
3856 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETEQ)),
3857 (SELECT_F4 (CREQV $lhs, $rhs), $tval, $fval)>;
3858 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETGE)),
3859 (SELECT_F4 (CRORC $rhs, $lhs), $tval, $fval)>;
3860 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETUGE)),
3861 (SELECT_F4 (CRORC $lhs, $rhs), $tval, $fval)>;
3862 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETGT)),
3863 (SELECT_F4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3864 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETUGT)),
3865 (SELECT_F4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3866 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETNE)),
3867 (SELECT_F4 (CRXOR $lhs, $rhs), $tval, $fval)>;
3869 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETLT)),
3870 (SELECT_F8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3871 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETULT)),
3872 (SELECT_F8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3873 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETLE)),
3874 (SELECT_F8 (CRORC $lhs, $rhs), $tval, $fval)>;
3875 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETULE)),
3876 (SELECT_F8 (CRORC $rhs, $lhs), $tval, $fval)>;
3877 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETEQ)),
3878 (SELECT_F8 (CREQV $lhs, $rhs), $tval, $fval)>;
3879 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETGE)),
3880 (SELECT_F8 (CRORC $rhs, $lhs), $tval, $fval)>;
3881 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETUGE)),
3882 (SELECT_F8 (CRORC $lhs, $rhs), $tval, $fval)>;
3883 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETGT)),
3884 (SELECT_F8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3885 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETUGT)),
3886 (SELECT_F8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3887 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETNE)),
3888 (SELECT_F8 (CRXOR $lhs, $rhs), $tval, $fval)>;
3891 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETLT)),
3892 (SELECT_F16 (CRANDC $lhs, $rhs), $tval, $fval)>;
3893 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETULT)),
3894 (SELECT_F16 (CRANDC $rhs, $lhs), $tval, $fval)>;
3895 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETLE)),
3896 (SELECT_F16 (CRORC $lhs, $rhs), $tval, $fval)>;
3897 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETULE)),
3898 (SELECT_F16 (CRORC $rhs, $lhs), $tval, $fval)>;
3899 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETEQ)),
3900 (SELECT_F16 (CREQV $lhs, $rhs), $tval, $fval)>;
3901 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETGE)),
3902 (SELECT_F16 (CRORC $rhs, $lhs), $tval, $fval)>;
3903 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETUGE)),
3904 (SELECT_F16 (CRORC $lhs, $rhs), $tval, $fval)>;
3905 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETGT)),
3906 (SELECT_F16 (CRANDC $rhs, $lhs), $tval, $fval)>;
3907 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETUGT)),
3908 (SELECT_F16 (CRANDC $lhs, $rhs), $tval, $fval)>;
3909 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETNE)),
3910 (SELECT_F16 (CRXOR $lhs, $rhs), $tval, $fval)>;
3912 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETLT)),
3913 (SELECT_VRRC (CRANDC $lhs, $rhs), $tval, $fval)>;
3914 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETULT)),
3915 (SELECT_VRRC (CRANDC $rhs, $lhs), $tval, $fval)>;
3916 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETLE)),
3917 (SELECT_VRRC (CRORC $lhs, $rhs), $tval, $fval)>;
3918 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETULE)),
3919 (SELECT_VRRC (CRORC $rhs, $lhs), $tval, $fval)>;
3920 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETEQ)),
3921 (SELECT_VRRC (CREQV $lhs, $rhs), $tval, $fval)>;
3922 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETGE)),
3923 (SELECT_VRRC (CRORC $rhs, $lhs), $tval, $fval)>;
3924 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETUGE)),
3925 (SELECT_VRRC (CRORC $lhs, $rhs), $tval, $fval)>;
3926 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETGT)),
3927 (SELECT_VRRC (CRANDC $rhs, $lhs), $tval, $fval)>;
3928 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETUGT)),
3929 (SELECT_VRRC (CRANDC $lhs, $rhs), $tval, $fval)>;
3930 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETNE)),
3931 (SELECT_VRRC (CRXOR $lhs, $rhs), $tval, $fval)>;
3933 let usesCustomInserter = 1 in {
3934 def ANDIo_1_EQ_BIT : Pseudo<(outs crbitrc:$dst), (ins gprc:$in),
3936 [(set i1:$dst, (trunc (not i32:$in)))]>;
3937 def ANDIo_1_GT_BIT : Pseudo<(outs crbitrc:$dst), (ins gprc:$in),
3939 [(set i1:$dst, (trunc i32:$in))]>;
3941 def ANDIo_1_EQ_BIT8 : Pseudo<(outs crbitrc:$dst), (ins g8rc:$in),
3943 [(set i1:$dst, (trunc (not i64:$in)))]>;
3944 def ANDIo_1_GT_BIT8 : Pseudo<(outs crbitrc:$dst), (ins g8rc:$in),
3946 [(set i1:$dst, (trunc i64:$in))]>;
3949 def : Pat<(i1 (not (trunc i32:$in))),
3950 (ANDIo_1_EQ_BIT $in)>;
3951 def : Pat<(i1 (not (trunc i64:$in))),
3952 (ANDIo_1_EQ_BIT8 $in)>;
3954 //===----------------------------------------------------------------------===//
3955 // PowerPC Instructions used for assembler/disassembler only
3958 // FIXME: For B=0 or B > 8, the registers following RT are used.
3959 // WARNING: Do not add patterns for this instruction without fixing this.
3960 def LSWI : XForm_base_r3xo_memOp<31, 597, (outs gprc:$RT),
3961 (ins gprc:$A, u5imm:$B),
3962 "lswi $RT, $A, $B", IIC_LdStLoad, []>;
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 STSWI : XForm_base_r3xo_memOp<31, 725, (outs),
3967 (ins gprc:$RT, gprc:$A, u5imm:$B),
3968 "stswi $RT, $A, $B", IIC_LdStLoad, []>;
3970 def ISYNC : XLForm_2_ext<19, 150, 0, 0, 0, (outs), (ins),
3971 "isync", IIC_SprISYNC, []>;
3973 def ICBI : XForm_1a<31, 982, (outs), (ins memrr:$src),
3974 "icbi $src", IIC_LdStICBI, []>;
3976 // We used to have EIEIO as value but E[0-9A-Z] is a reserved name
3977 def EnforceIEIO : XForm_24_eieio<31, 854, (outs), (ins),
3978 "eieio", IIC_LdStLoad, []>;
3980 def WAIT : XForm_24_sync<31, 30, (outs), (ins i32imm:$L),
3981 "wait $L", IIC_LdStLoad, []>;
3983 def MBAR : XForm_mbar<31, 854, (outs), (ins u5imm:$MO),
3984 "mbar $MO", IIC_LdStLoad>, Requires<[IsBookE]>;
3986 def MTSR: XForm_sr<31, 210, (outs), (ins gprc:$RS, u4imm:$SR),
3987 "mtsr $SR, $RS", IIC_SprMTSR>;
3989 def MFSR: XForm_sr<31, 595, (outs gprc:$RS), (ins u4imm:$SR),
3990 "mfsr $RS, $SR", IIC_SprMFSR>;
3992 def MTSRIN: XForm_srin<31, 242, (outs), (ins gprc:$RS, gprc:$RB),
3993 "mtsrin $RS, $RB", IIC_SprMTSR>;
3995 def MFSRIN: XForm_srin<31, 659, (outs gprc:$RS), (ins gprc:$RB),
3996 "mfsrin $RS, $RB", IIC_SprMFSR>;
3998 def MTMSR: XForm_mtmsr<31, 146, (outs), (ins gprc:$RS, i32imm:$L),
3999 "mtmsr $RS, $L", IIC_SprMTMSR>;
4001 def WRTEE: XForm_mtmsr<31, 131, (outs), (ins gprc:$RS),
4002 "wrtee $RS", IIC_SprMTMSR>, Requires<[IsBookE]> {
4006 def WRTEEI: I<31, (outs), (ins i1imm:$E), "wrteei $E", IIC_SprMTMSR>,
4007 Requires<[IsBookE]> {
4011 let Inst{21-30} = 163;
4014 def DCCCI : XForm_tlb<454, (outs), (ins gprc:$A, gprc:$B),
4015 "dccci $A, $B", IIC_LdStLoad>, Requires<[IsPPC4xx]>;
4016 def ICCCI : XForm_tlb<966, (outs), (ins gprc:$A, gprc:$B),
4017 "iccci $A, $B", IIC_LdStLoad>, Requires<[IsPPC4xx]>;
4019 def : InstAlias<"dci 0", (DCCCI R0, R0)>, Requires<[IsPPC4xx]>;
4020 def : InstAlias<"dccci", (DCCCI R0, R0)>, Requires<[IsPPC4xx]>;
4021 def : InstAlias<"ici 0", (ICCCI R0, R0)>, Requires<[IsPPC4xx]>;
4022 def : InstAlias<"iccci", (ICCCI R0, R0)>, Requires<[IsPPC4xx]>;
4024 def MFMSR : XForm_rs<31, 83, (outs gprc:$RT), (ins),
4025 "mfmsr $RT", IIC_SprMFMSR, []>;
4027 def MTMSRD : XForm_mtmsr<31, 178, (outs), (ins gprc:$RS, i32imm:$L),
4028 "mtmsrd $RS, $L", IIC_SprMTMSRD>;
4030 def MCRFS : XLForm_3<63, 64, (outs crrc:$BF), (ins crrc:$BFA),
4031 "mcrfs $BF, $BFA", IIC_BrMCR>;
4033 def MTFSFI : XLForm_4<63, 134, (outs crrc:$BF), (ins i32imm:$U, i32imm:$W),
4034 "mtfsfi $BF, $U, $W", IIC_IntMFFS>;
4036 def MTFSFIo : XLForm_4<63, 134, (outs crrc:$BF), (ins i32imm:$U, i32imm:$W),
4037 "mtfsfi. $BF, $U, $W", IIC_IntMFFS>, isDOT;
4039 def : InstAlias<"mtfsfi $BF, $U", (MTFSFI crrc:$BF, i32imm:$U, 0)>;
4040 def : InstAlias<"mtfsfi. $BF, $U", (MTFSFIo crrc:$BF, i32imm:$U, 0)>;
4042 let Predicates = [HasFPU] in {
4043 def MTFSF : XFLForm_1<63, 711, (outs),
4044 (ins i32imm:$FLM, f8rc:$FRB, i32imm:$L, i32imm:$W),
4045 "mtfsf $FLM, $FRB, $L, $W", IIC_IntMFFS, []>;
4046 def MTFSFo : XFLForm_1<63, 711, (outs),
4047 (ins i32imm:$FLM, f8rc:$FRB, i32imm:$L, i32imm:$W),
4048 "mtfsf. $FLM, $FRB, $L, $W", IIC_IntMFFS, []>, isDOT;
4050 def : InstAlias<"mtfsf $FLM, $FRB", (MTFSF i32imm:$FLM, f8rc:$FRB, 0, 0)>;
4051 def : InstAlias<"mtfsf. $FLM, $FRB", (MTFSFo i32imm:$FLM, f8rc:$FRB, 0, 0)>;
4054 def SLBIE : XForm_16b<31, 434, (outs), (ins gprc:$RB),
4055 "slbie $RB", IIC_SprSLBIE, []>;
4057 def SLBMTE : XForm_26<31, 402, (outs), (ins gprc:$RS, gprc:$RB),
4058 "slbmte $RS, $RB", IIC_SprSLBMTE, []>;
4060 def SLBMFEE : XForm_26<31, 915, (outs gprc:$RT), (ins gprc:$RB),
4061 "slbmfee $RT, $RB", IIC_SprSLBMFEE, []>;
4063 def SLBMFEV : XLForm_1_gen<31, 851, (outs gprc:$RT), (ins gprc:$RB),
4064 "slbmfev $RT, $RB", IIC_SprSLBMFEV, []>;
4066 def SLBIA : XForm_0<31, 498, (outs), (ins), "slbia", IIC_SprSLBIA, []>;
4068 def TLBIA : XForm_0<31, 370, (outs), (ins),
4069 "tlbia", IIC_SprTLBIA, []>;
4071 def TLBSYNC : XForm_0<31, 566, (outs), (ins),
4072 "tlbsync", IIC_SprTLBSYNC, []>;
4074 def TLBIEL : XForm_16b<31, 274, (outs), (ins gprc:$RB),
4075 "tlbiel $RB", IIC_SprTLBIEL, []>;
4077 def TLBLD : XForm_16b<31, 978, (outs), (ins gprc:$RB),
4078 "tlbld $RB", IIC_LdStLoad, []>, Requires<[IsPPC6xx]>;
4079 def TLBLI : XForm_16b<31, 1010, (outs), (ins gprc:$RB),
4080 "tlbli $RB", IIC_LdStLoad, []>, Requires<[IsPPC6xx]>;
4082 def TLBIE : XForm_26<31, 306, (outs), (ins gprc:$RS, gprc:$RB),
4083 "tlbie $RB,$RS", IIC_SprTLBIE, []>;
4085 def TLBSX : XForm_tlb<914, (outs), (ins gprc:$A, gprc:$B), "tlbsx $A, $B",
4086 IIC_LdStLoad>, Requires<[IsBookE]>;
4088 def TLBIVAX : XForm_tlb<786, (outs), (ins gprc:$A, gprc:$B), "tlbivax $A, $B",
4089 IIC_LdStLoad>, Requires<[IsBookE]>;
4091 def TLBRE : XForm_24_eieio<31, 946, (outs), (ins),
4092 "tlbre", IIC_LdStLoad, []>, Requires<[IsBookE]>;
4094 def TLBWE : XForm_24_eieio<31, 978, (outs), (ins),
4095 "tlbwe", IIC_LdStLoad, []>, Requires<[IsBookE]>;
4097 def TLBRE2 : XForm_tlbws<31, 946, (outs gprc:$RS), (ins gprc:$A, i1imm:$WS),
4098 "tlbre $RS, $A, $WS", IIC_LdStLoad, []>, Requires<[IsPPC4xx]>;
4100 def TLBWE2 : XForm_tlbws<31, 978, (outs), (ins gprc:$RS, gprc:$A, i1imm:$WS),
4101 "tlbwe $RS, $A, $WS", IIC_LdStLoad, []>, Requires<[IsPPC4xx]>;
4103 def TLBSX2 : XForm_base_r3xo<31, 914, (outs), (ins gprc:$RST, gprc:$A, gprc:$B),
4104 "tlbsx $RST, $A, $B", IIC_LdStLoad, []>,
4105 Requires<[IsPPC4xx]>;
4106 def TLBSX2D : XForm_base_r3xo<31, 914, (outs),
4107 (ins gprc:$RST, gprc:$A, gprc:$B),
4108 "tlbsx. $RST, $A, $B", IIC_LdStLoad, []>,
4109 Requires<[IsPPC4xx]>, isDOT;
4111 def RFID : XForm_0<19, 18, (outs), (ins), "rfid", IIC_IntRFID, []>;
4113 def RFI : XForm_0<19, 50, (outs), (ins), "rfi", IIC_SprRFI, []>,
4114 Requires<[IsBookE]>;
4115 def RFCI : XForm_0<19, 51, (outs), (ins), "rfci", IIC_BrB, []>,
4116 Requires<[IsBookE]>;
4118 def RFDI : XForm_0<19, 39, (outs), (ins), "rfdi", IIC_BrB, []>,
4120 def RFMCI : XForm_0<19, 38, (outs), (ins), "rfmci", IIC_BrB, []>,
4123 def MFDCR : XFXForm_1<31, 323, (outs gprc:$RT), (ins i32imm:$SPR),
4124 "mfdcr $RT, $SPR", IIC_SprMFSPR>, Requires<[IsPPC4xx]>;
4125 def MTDCR : XFXForm_1<31, 451, (outs), (ins gprc:$RT, i32imm:$SPR),
4126 "mtdcr $SPR, $RT", IIC_SprMTSPR>, Requires<[IsPPC4xx]>;
4128 def HRFID : XLForm_1_np<19, 274, (outs), (ins), "hrfid", IIC_BrB, []>;
4129 def NAP : XLForm_1_np<19, 434, (outs), (ins), "nap", IIC_BrB, []>;
4131 def ATTN : XForm_attn<0, 256, (outs), (ins), "attn", IIC_BrB>;
4133 def LBZCIX : XForm_base_r3xo_memOp<31, 853, (outs gprc:$RST),
4134 (ins gprc:$A, gprc:$B),
4135 "lbzcix $RST, $A, $B", IIC_LdStLoad, []>;
4136 def LHZCIX : XForm_base_r3xo_memOp<31, 821, (outs gprc:$RST),
4137 (ins gprc:$A, gprc:$B),
4138 "lhzcix $RST, $A, $B", IIC_LdStLoad, []>;
4139 def LWZCIX : XForm_base_r3xo_memOp<31, 789, (outs gprc:$RST),
4140 (ins gprc:$A, gprc:$B),
4141 "lwzcix $RST, $A, $B", IIC_LdStLoad, []>;
4142 def LDCIX : XForm_base_r3xo_memOp<31, 885, (outs gprc:$RST),
4143 (ins gprc:$A, gprc:$B),
4144 "ldcix $RST, $A, $B", IIC_LdStLoad, []>;
4146 def STBCIX : XForm_base_r3xo_memOp<31, 981, (outs),
4147 (ins gprc:$RST, gprc:$A, gprc:$B),
4148 "stbcix $RST, $A, $B", IIC_LdStLoad, []>;
4149 def STHCIX : XForm_base_r3xo_memOp<31, 949, (outs),
4150 (ins gprc:$RST, gprc:$A, gprc:$B),
4151 "sthcix $RST, $A, $B", IIC_LdStLoad, []>;
4152 def STWCIX : XForm_base_r3xo_memOp<31, 917, (outs),
4153 (ins gprc:$RST, gprc:$A, gprc:$B),
4154 "stwcix $RST, $A, $B", IIC_LdStLoad, []>;
4155 def STDCIX : XForm_base_r3xo_memOp<31, 1013, (outs),
4156 (ins gprc:$RST, gprc:$A, gprc:$B),
4157 "stdcix $RST, $A, $B", IIC_LdStLoad, []>;
4159 // External PID Load Store Instructions
4161 def LBEPX : XForm_1<31, 95, (outs gprc:$rD), (ins memrr:$src),
4162 "lbepx $rD, $src", IIC_LdStLoad, []>,
4165 def LFDEPX : XForm_25<31, 607, (outs f8rc:$frD), (ins memrr:$src),
4166 "lfdepx $frD, $src", IIC_LdStLFD, []>,
4169 def LHEPX : XForm_1<31, 287, (outs gprc:$rD), (ins memrr:$src),
4170 "lhepx $rD, $src", IIC_LdStLoad, []>,
4173 def LWEPX : XForm_1<31, 31, (outs gprc:$rD), (ins memrr:$src),
4174 "lwepx $rD, $src", IIC_LdStLoad, []>,
4177 def STBEPX : XForm_8<31, 223, (outs), (ins gprc:$rS, memrr:$dst),
4178 "stbepx $rS, $dst", IIC_LdStStore, []>,
4181 def STFDEPX : XForm_28_memOp<31, 735, (outs), (ins f8rc:$frS, memrr:$dst),
4182 "stfdepx $frS, $dst", IIC_LdStSTFD, []>,
4185 def STHEPX : XForm_8<31, 415, (outs), (ins gprc:$rS, memrr:$dst),
4186 "sthepx $rS, $dst", IIC_LdStStore, []>,
4189 def STWEPX : XForm_8<31, 159, (outs), (ins gprc:$rS, memrr:$dst),
4190 "stwepx $rS, $dst", IIC_LdStStore, []>,
4193 def DCBFEP : DCB_Form<127, 0, (outs), (ins memrr:$dst), "dcbfep $dst",
4194 IIC_LdStDCBF, []>, Requires<[IsE500]>;
4196 def DCBSTEP : DCB_Form<63, 0, (outs), (ins memrr:$dst), "dcbstep $dst",
4197 IIC_LdStDCBF, []>, Requires<[IsE500]>;
4199 def DCBTEP : DCB_Form_hint<319, (outs), (ins memrr:$dst, u5imm:$TH),
4200 "dcbtep $TH, $dst", IIC_LdStDCBF, []>,
4203 def DCBTSTEP : DCB_Form_hint<255, (outs), (ins memrr:$dst, u5imm:$TH),
4204 "dcbtstep $TH, $dst", IIC_LdStDCBF, []>,
4207 def DCBZEP : DCB_Form<1023, 0, (outs), (ins memrr:$dst), "dcbzep $dst",
4208 IIC_LdStDCBF, []>, Requires<[IsE500]>;
4210 def DCBZLEP : DCB_Form<1023, 1, (outs), (ins memrr:$dst), "dcbzlep $dst",
4211 IIC_LdStDCBF, []>, Requires<[IsE500]>;
4213 def ICBIEP : XForm_1a<31, 991, (outs), (ins memrr:$src), "icbiep $src",
4214 IIC_LdStICBI, []>, Requires<[IsE500]>;
4216 //===----------------------------------------------------------------------===//
4217 // PowerPC Assembler Instruction Aliases
4220 // Pseudo-instructions for alternate assembly syntax (never used by codegen).
4221 // These are aliases that require C++ handling to convert to the target
4222 // instruction, while InstAliases can be handled directly by tblgen.
4223 class PPCAsmPseudo<string asm, dag iops>
4225 let Namespace = "PPC";
4226 bit PPC64 = 0; // Default value, override with isPPC64
4228 let OutOperandList = (outs);
4229 let InOperandList = iops;
4231 let AsmString = asm;
4232 let isAsmParserOnly = 1;
4234 let hasNoSchedulingInfo = 1;
4237 def : InstAlias<"sc", (SC 0)>;
4239 def : InstAlias<"sync", (SYNC 0)>, Requires<[HasSYNC]>;
4240 def : InstAlias<"msync", (SYNC 0), 0>, Requires<[HasSYNC]>;
4241 def : InstAlias<"lwsync", (SYNC 1)>, Requires<[HasSYNC]>;
4242 def : InstAlias<"ptesync", (SYNC 2)>, Requires<[HasSYNC]>;
4244 def : InstAlias<"wait", (WAIT 0)>;
4245 def : InstAlias<"waitrsv", (WAIT 1)>;
4246 def : InstAlias<"waitimpl", (WAIT 2)>;
4248 def : InstAlias<"mbar", (MBAR 0)>, Requires<[IsBookE]>;
4250 def DCBTx : PPCAsmPseudo<"dcbt $dst", (ins memrr:$dst)>;
4251 def DCBTSTx : PPCAsmPseudo<"dcbtst $dst", (ins memrr:$dst)>;
4253 def DCBTCT : PPCAsmPseudo<"dcbtct $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
4254 def DCBTDS : PPCAsmPseudo<"dcbtds $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
4255 def DCBTT : PPCAsmPseudo<"dcbtt $dst", (ins memrr:$dst)>;
4257 def DCBTSTCT : PPCAsmPseudo<"dcbtstct $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
4258 def DCBTSTDS : PPCAsmPseudo<"dcbtstds $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
4259 def DCBTSTT : PPCAsmPseudo<"dcbtstt $dst", (ins memrr:$dst)>;
4261 def DCBFx : PPCAsmPseudo<"dcbf $dst", (ins memrr:$dst)>;
4262 def DCBFL : PPCAsmPseudo<"dcbfl $dst", (ins memrr:$dst)>;
4263 def DCBFLP : PPCAsmPseudo<"dcbflp $dst", (ins memrr:$dst)>;
4265 def : InstAlias<"crset $bx", (CREQV crbitrc:$bx, crbitrc:$bx, crbitrc:$bx)>;
4266 def : InstAlias<"crclr $bx", (CRXOR crbitrc:$bx, crbitrc:$bx, crbitrc:$bx)>;
4267 def : InstAlias<"crmove $bx, $by", (CROR crbitrc:$bx, crbitrc:$by, crbitrc:$by)>;
4268 def : InstAlias<"crnot $bx, $by", (CRNOR crbitrc:$bx, crbitrc:$by, crbitrc:$by)>;
4270 def : InstAlias<"mtxer $Rx", (MTSPR 1, gprc:$Rx)>;
4271 def : InstAlias<"mfxer $Rx", (MFSPR gprc:$Rx, 1)>;
4273 def : InstAlias<"mfrtcu $Rx", (MFSPR gprc:$Rx, 4)>;
4274 def : InstAlias<"mfrtcl $Rx", (MFSPR gprc:$Rx, 5)>;
4276 def : InstAlias<"mtdscr $Rx", (MTSPR 17, gprc:$Rx)>;
4277 def : InstAlias<"mfdscr $Rx", (MFSPR gprc:$Rx, 17)>;
4279 def : InstAlias<"mtdsisr $Rx", (MTSPR 18, gprc:$Rx)>;
4280 def : InstAlias<"mfdsisr $Rx", (MFSPR gprc:$Rx, 18)>;
4282 def : InstAlias<"mtdar $Rx", (MTSPR 19, gprc:$Rx)>;
4283 def : InstAlias<"mfdar $Rx", (MFSPR gprc:$Rx, 19)>;
4285 def : InstAlias<"mtdec $Rx", (MTSPR 22, gprc:$Rx)>;
4286 def : InstAlias<"mfdec $Rx", (MFSPR gprc:$Rx, 22)>;
4288 def : InstAlias<"mtsdr1 $Rx", (MTSPR 25, gprc:$Rx)>;
4289 def : InstAlias<"mfsdr1 $Rx", (MFSPR gprc:$Rx, 25)>;
4291 def : InstAlias<"mtsrr0 $Rx", (MTSPR 26, gprc:$Rx)>;
4292 def : InstAlias<"mfsrr0 $Rx", (MFSPR gprc:$Rx, 26)>;
4294 def : InstAlias<"mtsrr1 $Rx", (MTSPR 27, gprc:$Rx)>;
4295 def : InstAlias<"mfsrr1 $Rx", (MFSPR gprc:$Rx, 27)>;
4297 def : InstAlias<"mtsrr2 $Rx", (MTSPR 990, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4298 def : InstAlias<"mfsrr2 $Rx", (MFSPR gprc:$Rx, 990)>, Requires<[IsPPC4xx]>;
4300 def : InstAlias<"mtsrr3 $Rx", (MTSPR 991, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4301 def : InstAlias<"mfsrr3 $Rx", (MFSPR gprc:$Rx, 991)>, Requires<[IsPPC4xx]>;
4303 def : InstAlias<"mtcfar $Rx", (MTSPR 28, gprc:$Rx)>;
4304 def : InstAlias<"mfcfar $Rx", (MFSPR gprc:$Rx, 28)>;
4306 def : InstAlias<"mtamr $Rx", (MTSPR 29, gprc:$Rx)>;
4307 def : InstAlias<"mfamr $Rx", (MFSPR gprc:$Rx, 29)>;
4309 def : InstAlias<"mtpid $Rx", (MTSPR 48, gprc:$Rx)>, Requires<[IsBookE]>;
4310 def : InstAlias<"mfpid $Rx", (MFSPR gprc:$Rx, 48)>, Requires<[IsBookE]>;
4312 def : InstAlias<"mftb $Rx", (MFTB gprc:$Rx, 268)>;
4313 def : InstAlias<"mftbl $Rx", (MFTB gprc:$Rx, 268)>;
4314 def : InstAlias<"mftbu $Rx", (MFTB gprc:$Rx, 269)>;
4316 def : InstAlias<"mttbl $Rx", (MTSPR 284, gprc:$Rx)>;
4317 def : InstAlias<"mttbu $Rx", (MTSPR 285, gprc:$Rx)>;
4319 def : InstAlias<"mftblo $Rx", (MFSPR gprc:$Rx, 989)>, Requires<[IsPPC4xx]>;
4320 def : InstAlias<"mttblo $Rx", (MTSPR 989, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4321 def : InstAlias<"mftbhi $Rx", (MFSPR gprc:$Rx, 988)>, Requires<[IsPPC4xx]>;
4322 def : InstAlias<"mttbhi $Rx", (MTSPR 988, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4324 def : InstAlias<"xnop", (XORI R0, R0, 0)>;
4326 def : InstAlias<"mr $rA, $rB", (OR8 g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
4327 def : InstAlias<"mr. $rA, $rB", (OR8o g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
4329 def : InstAlias<"not $rA, $rB", (NOR8 g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
4330 def : InstAlias<"not. $rA, $rB", (NOR8o g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
4332 def : InstAlias<"mtcr $rA", (MTCRF8 255, g8rc:$rA)>;
4334 foreach BATR = 0-3 in {
4335 def : InstAlias<"mtdbatu "#BATR#", $Rx",
4336 (MTSPR !add(BATR, !add(BATR, 536)), gprc:$Rx)>,
4337 Requires<[IsPPC6xx]>;
4338 def : InstAlias<"mfdbatu $Rx, "#BATR,
4339 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 536)))>,
4340 Requires<[IsPPC6xx]>;
4341 def : InstAlias<"mtdbatl "#BATR#", $Rx",
4342 (MTSPR !add(BATR, !add(BATR, 537)), gprc:$Rx)>,
4343 Requires<[IsPPC6xx]>;
4344 def : InstAlias<"mfdbatl $Rx, "#BATR,
4345 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 537)))>,
4346 Requires<[IsPPC6xx]>;
4347 def : InstAlias<"mtibatu "#BATR#", $Rx",
4348 (MTSPR !add(BATR, !add(BATR, 528)), gprc:$Rx)>,
4349 Requires<[IsPPC6xx]>;
4350 def : InstAlias<"mfibatu $Rx, "#BATR,
4351 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 528)))>,
4352 Requires<[IsPPC6xx]>;
4353 def : InstAlias<"mtibatl "#BATR#", $Rx",
4354 (MTSPR !add(BATR, !add(BATR, 529)), gprc:$Rx)>,
4355 Requires<[IsPPC6xx]>;
4356 def : InstAlias<"mfibatl $Rx, "#BATR,
4357 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 529)))>,
4358 Requires<[IsPPC6xx]>;
4361 foreach BR = 0-7 in {
4362 def : InstAlias<"mfbr"#BR#" $Rx",
4363 (MFDCR gprc:$Rx, !add(BR, 0x80))>,
4364 Requires<[IsPPC4xx]>;
4365 def : InstAlias<"mtbr"#BR#" $Rx",
4366 (MTDCR gprc:$Rx, !add(BR, 0x80))>,
4367 Requires<[IsPPC4xx]>;
4370 def : InstAlias<"mtdccr $Rx", (MTSPR 1018, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4371 def : InstAlias<"mfdccr $Rx", (MFSPR gprc:$Rx, 1018)>, Requires<[IsPPC4xx]>;
4373 def : InstAlias<"mticcr $Rx", (MTSPR 1019, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4374 def : InstAlias<"mficcr $Rx", (MFSPR gprc:$Rx, 1019)>, Requires<[IsPPC4xx]>;
4376 def : InstAlias<"mtdear $Rx", (MTSPR 981, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4377 def : InstAlias<"mfdear $Rx", (MFSPR gprc:$Rx, 981)>, Requires<[IsPPC4xx]>;
4379 def : InstAlias<"mtesr $Rx", (MTSPR 980, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4380 def : InstAlias<"mfesr $Rx", (MFSPR gprc:$Rx, 980)>, Requires<[IsPPC4xx]>;
4382 def : InstAlias<"mfspefscr $Rx", (MFSPR gprc:$Rx, 512)>;
4383 def : InstAlias<"mtspefscr $Rx", (MTSPR 512, gprc:$Rx)>;
4385 def : InstAlias<"mttcr $Rx", (MTSPR 986, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4386 def : InstAlias<"mftcr $Rx", (MFSPR gprc:$Rx, 986)>, Requires<[IsPPC4xx]>;
4388 def LAx : PPCAsmPseudo<"la $rA, $addr", (ins gprc:$rA, memri:$addr)>;
4390 def SUBI : PPCAsmPseudo<"subi $rA, $rB, $imm",
4391 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4392 def SUBIS : PPCAsmPseudo<"subis $rA, $rB, $imm",
4393 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4394 def SUBIC : PPCAsmPseudo<"subic $rA, $rB, $imm",
4395 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4396 def SUBICo : PPCAsmPseudo<"subic. $rA, $rB, $imm",
4397 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4399 def : InstAlias<"sub $rA, $rB, $rC", (SUBF8 g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
4400 def : InstAlias<"sub. $rA, $rB, $rC", (SUBF8o g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
4401 def : InstAlias<"subc $rA, $rB, $rC", (SUBFC8 g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
4402 def : InstAlias<"subc. $rA, $rB, $rC", (SUBFC8o g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
4404 def : InstAlias<"mtmsrd $RS", (MTMSRD gprc:$RS, 0)>;
4405 def : InstAlias<"mtmsr $RS", (MTMSR gprc:$RS, 0)>;
4407 def : InstAlias<"mfasr $RT", (MFSPR gprc:$RT, 280)>;
4408 def : InstAlias<"mtasr $RT", (MTSPR 280, gprc:$RT)>;
4410 foreach SPRG = 0-3 in {
4411 def : InstAlias<"mfsprg $RT, "#SPRG, (MFSPR gprc:$RT, !add(SPRG, 272))>;
4412 def : InstAlias<"mfsprg"#SPRG#" $RT", (MFSPR gprc:$RT, !add(SPRG, 272))>;
4413 def : InstAlias<"mtsprg "#SPRG#", $RT", (MTSPR !add(SPRG, 272), gprc:$RT)>;
4414 def : InstAlias<"mtsprg"#SPRG#" $RT", (MTSPR !add(SPRG, 272), gprc:$RT)>;
4416 foreach SPRG = 4-7 in {
4417 def : InstAlias<"mfsprg $RT, "#SPRG, (MFSPR gprc:$RT, !add(SPRG, 256))>,
4418 Requires<[IsBookE]>;
4419 def : InstAlias<"mfsprg"#SPRG#" $RT", (MFSPR gprc:$RT, !add(SPRG, 256))>,
4420 Requires<[IsBookE]>;
4421 def : InstAlias<"mtsprg "#SPRG#", $RT", (MTSPR !add(SPRG, 256), gprc:$RT)>,
4422 Requires<[IsBookE]>;
4423 def : InstAlias<"mtsprg"#SPRG#" $RT", (MTSPR !add(SPRG, 256), gprc:$RT)>,
4424 Requires<[IsBookE]>;
4427 def : InstAlias<"mtasr $RS", (MTSPR 280, gprc:$RS)>;
4429 def : InstAlias<"mfdec $RT", (MFSPR gprc:$RT, 22)>;
4430 def : InstAlias<"mtdec $RT", (MTSPR 22, gprc:$RT)>;
4432 def : InstAlias<"mfpvr $RT", (MFSPR gprc:$RT, 287)>;
4434 def : InstAlias<"mfsdr1 $RT", (MFSPR gprc:$RT, 25)>;
4435 def : InstAlias<"mtsdr1 $RT", (MTSPR 25, gprc:$RT)>;
4437 def : InstAlias<"mfsrr0 $RT", (MFSPR gprc:$RT, 26)>;
4438 def : InstAlias<"mfsrr1 $RT", (MFSPR gprc:$RT, 27)>;
4439 def : InstAlias<"mtsrr0 $RT", (MTSPR 26, gprc:$RT)>;
4440 def : InstAlias<"mtsrr1 $RT", (MTSPR 27, gprc:$RT)>;
4442 def : InstAlias<"tlbie $RB", (TLBIE R0, gprc:$RB)>;
4444 def : InstAlias<"tlbrehi $RS, $A", (TLBRE2 gprc:$RS, gprc:$A, 0)>,
4445 Requires<[IsPPC4xx]>;
4446 def : InstAlias<"tlbrelo $RS, $A", (TLBRE2 gprc:$RS, gprc:$A, 1)>,
4447 Requires<[IsPPC4xx]>;
4448 def : InstAlias<"tlbwehi $RS, $A", (TLBWE2 gprc:$RS, gprc:$A, 0)>,
4449 Requires<[IsPPC4xx]>;
4450 def : InstAlias<"tlbwelo $RS, $A", (TLBWE2 gprc:$RS, gprc:$A, 1)>,
4451 Requires<[IsPPC4xx]>;
4453 def EXTLWI : PPCAsmPseudo<"extlwi $rA, $rS, $n, $b",
4454 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4455 def EXTLWIo : PPCAsmPseudo<"extlwi. $rA, $rS, $n, $b",
4456 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4457 def EXTRWI : PPCAsmPseudo<"extrwi $rA, $rS, $n, $b",
4458 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4459 def EXTRWIo : PPCAsmPseudo<"extrwi. $rA, $rS, $n, $b",
4460 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4461 def INSLWI : PPCAsmPseudo<"inslwi $rA, $rS, $n, $b",
4462 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4463 def INSLWIo : PPCAsmPseudo<"inslwi. $rA, $rS, $n, $b",
4464 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4465 def INSRWI : PPCAsmPseudo<"insrwi $rA, $rS, $n, $b",
4466 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4467 def INSRWIo : PPCAsmPseudo<"insrwi. $rA, $rS, $n, $b",
4468 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4469 def ROTRWI : PPCAsmPseudo<"rotrwi $rA, $rS, $n",
4470 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4471 def ROTRWIo : PPCAsmPseudo<"rotrwi. $rA, $rS, $n",
4472 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4473 def SLWI : PPCAsmPseudo<"slwi $rA, $rS, $n",
4474 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4475 def SLWIo : PPCAsmPseudo<"slwi. $rA, $rS, $n",
4476 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4477 def SRWI : PPCAsmPseudo<"srwi $rA, $rS, $n",
4478 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4479 def SRWIo : PPCAsmPseudo<"srwi. $rA, $rS, $n",
4480 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4481 def CLRRWI : PPCAsmPseudo<"clrrwi $rA, $rS, $n",
4482 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4483 def CLRRWIo : PPCAsmPseudo<"clrrwi. $rA, $rS, $n",
4484 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4485 def CLRLSLWI : PPCAsmPseudo<"clrlslwi $rA, $rS, $b, $n",
4486 (ins gprc:$rA, gprc:$rS, u5imm:$b, u5imm:$n)>;
4487 def CLRLSLWIo : PPCAsmPseudo<"clrlslwi. $rA, $rS, $b, $n",
4488 (ins gprc:$rA, gprc:$rS, u5imm:$b, u5imm:$n)>;
4490 def : InstAlias<"rotlwi $rA, $rS, $n", (RLWINM gprc:$rA, gprc:$rS, u5imm:$n, 0, 31)>;
4491 def : InstAlias<"rotlwi. $rA, $rS, $n", (RLWINMo gprc:$rA, gprc:$rS, u5imm:$n, 0, 31)>;
4492 def : InstAlias<"rotlw $rA, $rS, $rB", (RLWNM gprc:$rA, gprc:$rS, gprc:$rB, 0, 31)>;
4493 def : InstAlias<"rotlw. $rA, $rS, $rB", (RLWNMo gprc:$rA, gprc:$rS, gprc:$rB, 0, 31)>;
4494 def : InstAlias<"clrlwi $rA, $rS, $n", (RLWINM gprc:$rA, gprc:$rS, 0, u5imm:$n, 31)>;
4495 def : InstAlias<"clrlwi. $rA, $rS, $n", (RLWINMo gprc:$rA, gprc:$rS, 0, u5imm:$n, 31)>;
4497 def : InstAlias<"cntlzw $rA, $rS", (CNTLZW gprc:$rA, gprc:$rS)>;
4498 def : InstAlias<"cntlzw. $rA, $rS", (CNTLZWo gprc:$rA, gprc:$rS)>;
4499 // The POWER variant
4500 def : MnemonicAlias<"cntlz", "cntlzw">;
4501 def : MnemonicAlias<"cntlz.", "cntlzw.">;
4503 def EXTLDI : PPCAsmPseudo<"extldi $rA, $rS, $n, $b",
4504 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4505 def EXTLDIo : PPCAsmPseudo<"extldi. $rA, $rS, $n, $b",
4506 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4507 def EXTRDI : PPCAsmPseudo<"extrdi $rA, $rS, $n, $b",
4508 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4509 def EXTRDIo : PPCAsmPseudo<"extrdi. $rA, $rS, $n, $b",
4510 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4511 def INSRDI : PPCAsmPseudo<"insrdi $rA, $rS, $n, $b",
4512 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4513 def INSRDIo : PPCAsmPseudo<"insrdi. $rA, $rS, $n, $b",
4514 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4515 def ROTRDI : PPCAsmPseudo<"rotrdi $rA, $rS, $n",
4516 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4517 def ROTRDIo : PPCAsmPseudo<"rotrdi. $rA, $rS, $n",
4518 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4519 def SLDI : PPCAsmPseudo<"sldi $rA, $rS, $n",
4520 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4521 def SLDIo : PPCAsmPseudo<"sldi. $rA, $rS, $n",
4522 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4523 def SRDI : PPCAsmPseudo<"srdi $rA, $rS, $n",
4524 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4525 def SRDIo : PPCAsmPseudo<"srdi. $rA, $rS, $n",
4526 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4527 def CLRRDI : PPCAsmPseudo<"clrrdi $rA, $rS, $n",
4528 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4529 def CLRRDIo : PPCAsmPseudo<"clrrdi. $rA, $rS, $n",
4530 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4531 def CLRLSLDI : PPCAsmPseudo<"clrlsldi $rA, $rS, $b, $n",
4532 (ins g8rc:$rA, g8rc:$rS, u6imm:$b, u6imm:$n)>;
4533 def CLRLSLDIo : PPCAsmPseudo<"clrlsldi. $rA, $rS, $b, $n",
4534 (ins g8rc:$rA, g8rc:$rS, u6imm:$b, u6imm:$n)>;
4535 def SUBPCIS : PPCAsmPseudo<"subpcis $RT, $D", (ins g8rc:$RT, s16imm:$D)>;
4537 def : InstAlias<"rotldi $rA, $rS, $n", (RLDICL g8rc:$rA, g8rc:$rS, u6imm:$n, 0)>;
4538 def : InstAlias<"rotldi. $rA, $rS, $n", (RLDICLo g8rc:$rA, g8rc:$rS, u6imm:$n, 0)>;
4539 def : InstAlias<"rotld $rA, $rS, $rB", (RLDCL g8rc:$rA, g8rc:$rS, gprc:$rB, 0)>;
4540 def : InstAlias<"rotld. $rA, $rS, $rB", (RLDCLo g8rc:$rA, g8rc:$rS, gprc:$rB, 0)>;
4541 def : InstAlias<"clrldi $rA, $rS, $n", (RLDICL g8rc:$rA, g8rc:$rS, 0, u6imm:$n)>;
4542 def : InstAlias<"clrldi $rA, $rS, $n",
4543 (RLDICL_32_64 g8rc:$rA, gprc:$rS, 0, u6imm:$n)>;
4544 def : InstAlias<"clrldi. $rA, $rS, $n", (RLDICLo g8rc:$rA, g8rc:$rS, 0, u6imm:$n)>;
4545 def : InstAlias<"lnia $RT", (ADDPCIS g8rc:$RT, 0)>;
4547 def RLWINMbm : PPCAsmPseudo<"rlwinm $rA, $rS, $n, $b",
4548 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4549 def RLWINMobm : PPCAsmPseudo<"rlwinm. $rA, $rS, $n, $b",
4550 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4551 def RLWIMIbm : PPCAsmPseudo<"rlwimi $rA, $rS, $n, $b",
4552 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4553 def RLWIMIobm : PPCAsmPseudo<"rlwimi. $rA, $rS, $n, $b",
4554 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4555 def RLWNMbm : PPCAsmPseudo<"rlwnm $rA, $rS, $n, $b",
4556 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4557 def RLWNMobm : PPCAsmPseudo<"rlwnm. $rA, $rS, $n, $b",
4558 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4560 // These generic branch instruction forms are used for the assembler parser only.
4561 // Defs and Uses are conservative, since we don't know the BO value.
4562 let PPC970_Unit = 7, isBranch = 1 in {
4563 let Defs = [CTR], Uses = [CTR, RM] in {
4564 def gBC : BForm_3<16, 0, 0, (outs),
4565 (ins u5imm:$bo, crbitrc:$bi, condbrtarget:$dst),
4566 "bc $bo, $bi, $dst">;
4567 def gBCA : BForm_3<16, 1, 0, (outs),
4568 (ins u5imm:$bo, crbitrc:$bi, abscondbrtarget:$dst),
4569 "bca $bo, $bi, $dst">;
4570 let isAsmParserOnly = 1 in {
4571 def gBCat : BForm_3_at<16, 0, 0, (outs),
4572 (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
4574 "bc$at $bo, $bi, $dst">;
4575 def gBCAat : BForm_3_at<16, 1, 0, (outs),
4576 (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
4577 abscondbrtarget:$dst),
4578 "bca$at $bo, $bi, $dst">;
4579 } // isAsmParserOnly = 1
4581 let Defs = [LR, CTR], Uses = [CTR, RM] in {
4582 def gBCL : BForm_3<16, 0, 1, (outs),
4583 (ins u5imm:$bo, crbitrc:$bi, condbrtarget:$dst),
4584 "bcl $bo, $bi, $dst">;
4585 def gBCLA : BForm_3<16, 1, 1, (outs),
4586 (ins u5imm:$bo, crbitrc:$bi, abscondbrtarget:$dst),
4587 "bcla $bo, $bi, $dst">;
4588 let isAsmParserOnly = 1 in {
4589 def gBCLat : BForm_3_at<16, 0, 1, (outs),
4590 (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
4592 "bcl$at $bo, $bi, $dst">;
4593 def gBCLAat : BForm_3_at<16, 1, 1, (outs),
4594 (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
4595 abscondbrtarget:$dst),
4596 "bcla$at $bo, $bi, $dst">;
4597 } // // isAsmParserOnly = 1
4599 let Defs = [CTR], Uses = [CTR, LR, RM] in
4600 def gBCLR : XLForm_2<19, 16, 0, (outs),
4601 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
4602 "bclr $bo, $bi, $bh", IIC_BrB, []>;
4603 let Defs = [LR, CTR], Uses = [CTR, LR, RM] in
4604 def gBCLRL : XLForm_2<19, 16, 1, (outs),
4605 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
4606 "bclrl $bo, $bi, $bh", IIC_BrB, []>;
4607 let Defs = [CTR], Uses = [CTR, LR, RM] in
4608 def gBCCTR : XLForm_2<19, 528, 0, (outs),
4609 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
4610 "bcctr $bo, $bi, $bh", IIC_BrB, []>;
4611 let Defs = [LR, CTR], Uses = [CTR, LR, RM] in
4612 def gBCCTRL : XLForm_2<19, 528, 1, (outs),
4613 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
4614 "bcctrl $bo, $bi, $bh", IIC_BrB, []>;
4617 multiclass BranchSimpleMnemonicAT<string pm, int at> {
4618 def : InstAlias<"bc"#pm#" $bo, $bi, $dst", (gBCat u5imm:$bo, at, crbitrc:$bi,
4619 condbrtarget:$dst)>;
4620 def : InstAlias<"bca"#pm#" $bo, $bi, $dst", (gBCAat u5imm:$bo, at, crbitrc:$bi,
4621 condbrtarget:$dst)>;
4622 def : InstAlias<"bcl"#pm#" $bo, $bi, $dst", (gBCLat u5imm:$bo, at, crbitrc:$bi,
4623 condbrtarget:$dst)>;
4624 def : InstAlias<"bcla"#pm#" $bo, $bi, $dst", (gBCLAat u5imm:$bo, at, crbitrc:$bi,
4625 condbrtarget:$dst)>;
4627 defm : BranchSimpleMnemonicAT<"+", 3>;
4628 defm : BranchSimpleMnemonicAT<"-", 2>;
4630 def : InstAlias<"bclr $bo, $bi", (gBCLR u5imm:$bo, crbitrc:$bi, 0)>;
4631 def : InstAlias<"bclrl $bo, $bi", (gBCLRL u5imm:$bo, crbitrc:$bi, 0)>;
4632 def : InstAlias<"bcctr $bo, $bi", (gBCCTR u5imm:$bo, crbitrc:$bi, 0)>;
4633 def : InstAlias<"bcctrl $bo, $bi", (gBCCTRL u5imm:$bo, crbitrc:$bi, 0)>;
4635 multiclass BranchSimpleMnemonic1<string name, string pm, int bo> {
4636 def : InstAlias<"b"#name#pm#" $bi, $dst", (gBC bo, crbitrc:$bi, condbrtarget:$dst)>;
4637 def : InstAlias<"b"#name#"a"#pm#" $bi, $dst", (gBCA bo, crbitrc:$bi, abscondbrtarget:$dst)>;
4638 def : InstAlias<"b"#name#"lr"#pm#" $bi", (gBCLR bo, crbitrc:$bi, 0)>;
4639 def : InstAlias<"b"#name#"l"#pm#" $bi, $dst", (gBCL bo, crbitrc:$bi, condbrtarget:$dst)>;
4640 def : InstAlias<"b"#name#"la"#pm#" $bi, $dst", (gBCLA bo, crbitrc:$bi, abscondbrtarget:$dst)>;
4641 def : InstAlias<"b"#name#"lrl"#pm#" $bi", (gBCLRL bo, crbitrc:$bi, 0)>;
4643 multiclass BranchSimpleMnemonic2<string name, string pm, int bo>
4644 : BranchSimpleMnemonic1<name, pm, bo> {
4645 def : InstAlias<"b"#name#"ctr"#pm#" $bi", (gBCCTR bo, crbitrc:$bi, 0)>;
4646 def : InstAlias<"b"#name#"ctrl"#pm#" $bi", (gBCCTRL bo, crbitrc:$bi, 0)>;
4648 defm : BranchSimpleMnemonic2<"t", "", 12>;
4649 defm : BranchSimpleMnemonic2<"f", "", 4>;
4650 defm : BranchSimpleMnemonic2<"t", "-", 14>;
4651 defm : BranchSimpleMnemonic2<"f", "-", 6>;
4652 defm : BranchSimpleMnemonic2<"t", "+", 15>;
4653 defm : BranchSimpleMnemonic2<"f", "+", 7>;
4654 defm : BranchSimpleMnemonic1<"dnzt", "", 8>;
4655 defm : BranchSimpleMnemonic1<"dnzf", "", 0>;
4656 defm : BranchSimpleMnemonic1<"dzt", "", 10>;
4657 defm : BranchSimpleMnemonic1<"dzf", "", 2>;
4659 multiclass BranchExtendedMnemonicPM<string name, string pm, int bibo> {
4660 def : InstAlias<"b"#name#pm#" $cc, $dst",
4661 (BCC bibo, crrc:$cc, condbrtarget:$dst)>;
4662 def : InstAlias<"b"#name#pm#" $dst",
4663 (BCC bibo, CR0, condbrtarget:$dst)>;
4665 def : InstAlias<"b"#name#"a"#pm#" $cc, $dst",
4666 (BCCA bibo, crrc:$cc, abscondbrtarget:$dst)>;
4667 def : InstAlias<"b"#name#"a"#pm#" $dst",
4668 (BCCA bibo, CR0, abscondbrtarget:$dst)>;
4670 def : InstAlias<"b"#name#"lr"#pm#" $cc",
4671 (BCCLR bibo, crrc:$cc)>;
4672 def : InstAlias<"b"#name#"lr"#pm,
4675 def : InstAlias<"b"#name#"ctr"#pm#" $cc",
4676 (BCCCTR bibo, crrc:$cc)>;
4677 def : InstAlias<"b"#name#"ctr"#pm,
4678 (BCCCTR bibo, CR0)>;
4680 def : InstAlias<"b"#name#"l"#pm#" $cc, $dst",
4681 (BCCL bibo, crrc:$cc, condbrtarget:$dst)>;
4682 def : InstAlias<"b"#name#"l"#pm#" $dst",
4683 (BCCL bibo, CR0, condbrtarget:$dst)>;
4685 def : InstAlias<"b"#name#"la"#pm#" $cc, $dst",
4686 (BCCLA bibo, crrc:$cc, abscondbrtarget:$dst)>;
4687 def : InstAlias<"b"#name#"la"#pm#" $dst",
4688 (BCCLA bibo, CR0, abscondbrtarget:$dst)>;
4690 def : InstAlias<"b"#name#"lrl"#pm#" $cc",
4691 (BCCLRL bibo, crrc:$cc)>;
4692 def : InstAlias<"b"#name#"lrl"#pm,
4693 (BCCLRL bibo, CR0)>;
4695 def : InstAlias<"b"#name#"ctrl"#pm#" $cc",
4696 (BCCCTRL bibo, crrc:$cc)>;
4697 def : InstAlias<"b"#name#"ctrl"#pm,
4698 (BCCCTRL bibo, CR0)>;
4700 multiclass BranchExtendedMnemonic<string name, int bibo> {
4701 defm : BranchExtendedMnemonicPM<name, "", bibo>;
4702 defm : BranchExtendedMnemonicPM<name, "-", !add(bibo, 2)>;
4703 defm : BranchExtendedMnemonicPM<name, "+", !add(bibo, 3)>;
4705 defm : BranchExtendedMnemonic<"lt", 12>;
4706 defm : BranchExtendedMnemonic<"gt", 44>;
4707 defm : BranchExtendedMnemonic<"eq", 76>;
4708 defm : BranchExtendedMnemonic<"un", 108>;
4709 defm : BranchExtendedMnemonic<"so", 108>;
4710 defm : BranchExtendedMnemonic<"ge", 4>;
4711 defm : BranchExtendedMnemonic<"nl", 4>;
4712 defm : BranchExtendedMnemonic<"le", 36>;
4713 defm : BranchExtendedMnemonic<"ng", 36>;
4714 defm : BranchExtendedMnemonic<"ne", 68>;
4715 defm : BranchExtendedMnemonic<"nu", 100>;
4716 defm : BranchExtendedMnemonic<"ns", 100>;
4718 def : InstAlias<"cmpwi $rA, $imm", (CMPWI CR0, gprc:$rA, s16imm:$imm)>;
4719 def : InstAlias<"cmpw $rA, $rB", (CMPW CR0, gprc:$rA, gprc:$rB)>;
4720 def : InstAlias<"cmplwi $rA, $imm", (CMPLWI CR0, gprc:$rA, u16imm:$imm)>;
4721 def : InstAlias<"cmplw $rA, $rB", (CMPLW CR0, gprc:$rA, gprc:$rB)>;
4722 def : InstAlias<"cmpdi $rA, $imm", (CMPDI CR0, g8rc:$rA, s16imm64:$imm)>;
4723 def : InstAlias<"cmpd $rA, $rB", (CMPD CR0, g8rc:$rA, g8rc:$rB)>;
4724 def : InstAlias<"cmpldi $rA, $imm", (CMPLDI CR0, g8rc:$rA, u16imm64:$imm)>;
4725 def : InstAlias<"cmpld $rA, $rB", (CMPLD CR0, g8rc:$rA, g8rc:$rB)>;
4727 def : InstAlias<"cmpi $bf, 0, $rA, $imm", (CMPWI crrc:$bf, gprc:$rA, s16imm:$imm)>;
4728 def : InstAlias<"cmp $bf, 0, $rA, $rB", (CMPW crrc:$bf, gprc:$rA, gprc:$rB)>;
4729 def : InstAlias<"cmpli $bf, 0, $rA, $imm", (CMPLWI crrc:$bf, gprc:$rA, u16imm:$imm)>;
4730 def : InstAlias<"cmpl $bf, 0, $rA, $rB", (CMPLW crrc:$bf, gprc:$rA, gprc:$rB)>;
4731 def : InstAlias<"cmpi $bf, 1, $rA, $imm", (CMPDI crrc:$bf, g8rc:$rA, s16imm64:$imm)>;
4732 def : InstAlias<"cmp $bf, 1, $rA, $rB", (CMPD crrc:$bf, g8rc:$rA, g8rc:$rB)>;
4733 def : InstAlias<"cmpli $bf, 1, $rA, $imm", (CMPLDI crrc:$bf, g8rc:$rA, u16imm64:$imm)>;
4734 def : InstAlias<"cmpl $bf, 1, $rA, $rB", (CMPLD crrc:$bf, g8rc:$rA, g8rc:$rB)>;
4736 multiclass TrapExtendedMnemonic<string name, int to> {
4737 def : InstAlias<"td"#name#"i $rA, $imm", (TDI to, g8rc:$rA, s16imm:$imm)>;
4738 def : InstAlias<"td"#name#" $rA, $rB", (TD to, g8rc:$rA, g8rc:$rB)>;
4739 def : InstAlias<"tw"#name#"i $rA, $imm", (TWI to, gprc:$rA, s16imm:$imm)>;
4740 def : InstAlias<"tw"#name#" $rA, $rB", (TW to, gprc:$rA, gprc:$rB)>;
4742 defm : TrapExtendedMnemonic<"lt", 16>;
4743 defm : TrapExtendedMnemonic<"le", 20>;
4744 defm : TrapExtendedMnemonic<"eq", 4>;
4745 defm : TrapExtendedMnemonic<"ge", 12>;
4746 defm : TrapExtendedMnemonic<"gt", 8>;
4747 defm : TrapExtendedMnemonic<"nl", 12>;
4748 defm : TrapExtendedMnemonic<"ne", 24>;
4749 defm : TrapExtendedMnemonic<"ng", 20>;
4750 defm : TrapExtendedMnemonic<"llt", 2>;
4751 defm : TrapExtendedMnemonic<"lle", 6>;
4752 defm : TrapExtendedMnemonic<"lge", 5>;
4753 defm : TrapExtendedMnemonic<"lgt", 1>;
4754 defm : TrapExtendedMnemonic<"lnl", 5>;
4755 defm : TrapExtendedMnemonic<"lng", 6>;
4756 defm : TrapExtendedMnemonic<"u", 31>;
4759 def : Pat<(atomic_load_8 iaddr:$src), (LBZ memri:$src)>;
4760 def : Pat<(atomic_load_16 iaddr:$src), (LHZ memri:$src)>;
4761 def : Pat<(atomic_load_32 iaddr:$src), (LWZ memri:$src)>;
4762 def : Pat<(atomic_load_8 xaddr:$src), (LBZX memrr:$src)>;
4763 def : Pat<(atomic_load_16 xaddr:$src), (LHZX memrr:$src)>;
4764 def : Pat<(atomic_load_32 xaddr:$src), (LWZX memrr:$src)>;
4767 def : Pat<(atomic_store_8 iaddr:$ptr, i32:$val), (STB gprc:$val, memri:$ptr)>;
4768 def : Pat<(atomic_store_16 iaddr:$ptr, i32:$val), (STH gprc:$val, memri:$ptr)>;
4769 def : Pat<(atomic_store_32 iaddr:$ptr, i32:$val), (STW gprc:$val, memri:$ptr)>;
4770 def : Pat<(atomic_store_8 xaddr:$ptr, i32:$val), (STBX gprc:$val, memrr:$ptr)>;
4771 def : Pat<(atomic_store_16 xaddr:$ptr, i32:$val), (STHX gprc:$val, memrr:$ptr)>;
4772 def : Pat<(atomic_store_32 xaddr:$ptr, i32:$val), (STWX gprc:$val, memrr:$ptr)>;
4774 let Predicates = [IsISA3_0] in {
4776 // Copy-Paste Facility
4777 // We prefix 'CP' to COPY due to name conflict in Target.td. We also prefix to
4778 // PASTE for naming consistency.
4780 def CP_COPY : X_L1_RA5_RB5<31, 774, "copy" , gprc, IIC_LdStCOPY, []>;
4783 def CP_PASTE : X_L1_RA5_RB5<31, 902, "paste" , gprc, IIC_LdStPASTE, []>;
4785 let mayStore = 1, Defs = [CR0] in
4786 def CP_PASTEo : X_L1_RA5_RB5<31, 902, "paste.", gprc, IIC_LdStPASTE, []>, isDOT;
4788 def CP_COPYx : PPCAsmPseudo<"copy $rA, $rB" , (ins gprc:$rA, gprc:$rB)>;
4789 def CP_PASTEx : PPCAsmPseudo<"paste $rA, $rB", (ins gprc:$rA, gprc:$rB)>;
4790 def CP_COPY_FIRST : PPCAsmPseudo<"copy_first $rA, $rB",
4791 (ins gprc:$rA, gprc:$rB)>;
4792 def CP_PASTE_LAST : PPCAsmPseudo<"paste_last $rA, $rB",
4793 (ins gprc:$rA, gprc:$rB)>;
4794 def CP_ABORT : XForm_0<31, 838, (outs), (ins), "cp_abort", IIC_SprABORT, []>;
4796 // Message Synchronize
4797 def MSGSYNC : XForm_0<31, 886, (outs), (ins), "msgsync", IIC_SprMSGSYNC, []>;
4799 // Power-Saving Mode Instruction:
4800 def STOP : XForm_0<19, 370, (outs), (ins), "stop", IIC_SprSTOP, []>;
4804 // Fast 32-bit reverse bits algorithm:
4805 // Step 1: 1-bit swap (swap odd 1-bit and even 1-bit):
4806 // n = ((n >> 1) & 0x55555555) | ((n << 1) & 0xAAAAAAAA);
4807 // Step 2: 2-bit swap (swap odd 2-bit and even 2-bit):
4808 // n = ((n >> 2) & 0x33333333) | ((n << 2) & 0xCCCCCCCC);
4809 // Step 3: 4-bit swap (swap odd 4-bit and even 4-bit):
4810 // n = ((n >> 4) & 0x0F0F0F0F) | ((n << 4) & 0xF0F0F0F0);
4811 // Step 4: byte reverse (Suppose n = [B1,B2,B3,B4]):
4812 // Step 4.1: Put B4,B2 in the right position (rotate left 3 bytes):
4813 // n' = (n rotl 24); After which n' = [B4, B1, B2, B3]
4814 // Step 4.2: Insert B3 to the right position:
4815 // n' = rlwimi n', n, 8, 8, 15; After which n' = [B4, B3, B2, B3]
4816 // Step 4.3: Insert B1 to the right position:
4817 // n' = rlwimi n', n, 8, 24, 31; After which n' = [B4, B3, B2, B1]
4819 dag Lo1 = (ORI (LIS 0x5555), 0x5555);
4820 dag Hi1 = (ORI (LIS 0xAAAA), 0xAAAA);
4821 dag Lo2 = (ORI (LIS 0x3333), 0x3333);
4822 dag Hi2 = (ORI (LIS 0xCCCC), 0xCCCC);
4823 dag Lo4 = (ORI (LIS 0x0F0F), 0x0F0F);
4824 dag Hi4 = (ORI (LIS 0xF0F0), 0xF0F0);
4828 dag Right = (RLWINM $A, 31, 1, 31);
4829 dag Left = (RLWINM $A, 1, 0, 30);
4833 dag Bit = (OR (AND Shift1.Right, MaskValues.Lo1),
4834 (AND Shift1.Left, MaskValues.Hi1));
4838 dag Right = (RLWINM Swap1.Bit, 30, 2, 31);
4839 dag Left = (RLWINM Swap1.Bit, 2, 0, 29);
4843 dag Bits = (OR (AND Shift2.Right, MaskValues.Lo2),
4844 (AND Shift2.Left, MaskValues.Hi2));
4848 dag Right = (RLWINM Swap2.Bits, 28, 4, 31);
4849 dag Left = (RLWINM Swap2.Bits, 4, 0, 27);
4853 dag Bits = (OR (AND Shift4.Right, MaskValues.Lo4),
4854 (AND Shift4.Left, MaskValues.Hi4));
4858 dag Left3Bytes = (RLWINM Swap4.Bits, 24, 0, 31);
4861 def RotateInsertByte3 {
4862 dag Left = (RLWIMI Rotate.Left3Bytes, Swap4.Bits, 8, 8, 15);
4865 def RotateInsertByte1 {
4866 dag Left = (RLWIMI RotateInsertByte3.Left, Swap4.Bits, 8, 24, 31);
4869 def : Pat<(i32 (bitreverse i32:$A)),
4870 (RLDICL_32 RotateInsertByte1.Left, 0, 32)>;
4872 // Fast 64-bit reverse bits algorithm:
4873 // Step 1: 1-bit swap (swap odd 1-bit and even 1-bit):
4874 // n = ((n >> 1) & 0x5555555555555555) | ((n << 1) & 0xAAAAAAAAAAAAAAAA);
4875 // Step 2: 2-bit swap (swap odd 2-bit and even 2-bit):
4876 // n = ((n >> 2) & 0x3333333333333333) | ((n << 2) & 0xCCCCCCCCCCCCCCCC);
4877 // Step 3: 4-bit swap (swap odd 4-bit and even 4-bit):
4878 // n = ((n >> 4) & 0x0F0F0F0F0F0F0F0F) | ((n << 4) & 0xF0F0F0F0F0F0F0F0);
4879 // Step 4: byte reverse (Suppose n = [B0,B1,B2,B3,B4,B5,B6,B7]):
4880 // Apply the same byte reverse algorithm mentioned above for the fast 32-bit
4881 // reverse to both the high 32 bit and low 32 bit of the 64 bit value. And
4882 // then OR them together to get the final result.
4884 dag Lo1 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Lo1, sub_32));
4885 dag Hi1 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Hi1, sub_32));
4886 dag Lo2 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Lo2, sub_32));
4887 dag Hi2 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Hi2, sub_32));
4888 dag Lo4 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Lo4, sub_32));
4889 dag Hi4 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Hi4, sub_32));
4893 dag Lo1 = (ORI8 (ORIS8 (RLDICR MaskValues64.Lo1, 32, 31), 0x5555), 0x5555);
4894 dag Hi1 = (ORI8 (ORIS8 (RLDICR MaskValues64.Hi1, 32, 31), 0xAAAA), 0xAAAA);
4895 dag Lo2 = (ORI8 (ORIS8 (RLDICR MaskValues64.Lo2, 32, 31), 0x3333), 0x3333);
4896 dag Hi2 = (ORI8 (ORIS8 (RLDICR MaskValues64.Hi2, 32, 31), 0xCCCC), 0xCCCC);
4897 dag Lo4 = (ORI8 (ORIS8 (RLDICR MaskValues64.Lo4, 32, 31), 0x0F0F), 0x0F0F);
4898 dag Hi4 = (ORI8 (ORIS8 (RLDICR MaskValues64.Hi4, 32, 31), 0xF0F0), 0xF0F0);
4902 dag Swap1 = (OR8 (AND8 (RLDICL $A, 63, 1), DWMaskValues.Lo1),
4903 (AND8 (RLDICR $A, 1, 62), DWMaskValues.Hi1));
4904 dag Swap2 = (OR8 (AND8 (RLDICL Swap1, 62, 2), DWMaskValues.Lo2),
4905 (AND8 (RLDICR Swap1, 2, 61), DWMaskValues.Hi2));
4906 dag Swap4 = (OR8 (AND8 (RLDICL Swap2, 60, 4), DWMaskValues.Lo4),
4907 (AND8 (RLDICR Swap2, 4, 59), DWMaskValues.Hi4));
4910 // Intra-byte swap is done, now start inter-byte swap.
4912 dag Word = (i32 (EXTRACT_SUBREG DWSwapInByte.Swap4, sub_32));
4916 dag Word = (RLWINM DWBytes4567.Word, 24, 0, 31);
4920 dag Word = (RLWIMI DWBytes7456.Word, DWBytes4567.Word, 8, 8, 15);
4923 // B7 B6 B5 B4 in the right order
4925 dag Word = (RLWIMI DWBytes7656.Word, DWBytes4567.Word, 8, 24, 31);
4927 (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), Word, sub_32));
4931 dag Word = (i32 (EXTRACT_SUBREG (RLDICL DWSwapInByte.Swap4, 32, 32), sub_32));
4935 dag Word = (RLWINM DWBytes0123.Word, 24, 0, 31);
4939 dag Word = (RLWIMI DWBytes3012.Word, DWBytes0123.Word, 8, 8, 15);
4942 // B3 B2 B1 B0 in the right order
4944 dag Word = (RLWIMI DWBytes3212.Word, DWBytes0123.Word, 8, 24, 31);
4946 (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), Word, sub_32));
4949 // Now both high word and low word are reversed, next
4950 // swap the high word and low word.
4951 def : Pat<(i64 (bitreverse i64:$A)),
4952 (OR8 (RLDICR DWBytes7654.DWord, 32, 31), DWBytes3210.DWord)>;