1 //===-- PPCInstrInfo.td - The PowerPC Instruction Set ------*- tablegen -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file describes the subset of the 32-bit PowerPC instruction set, as used
10 // by the PowerPC instruction selector.
12 //===----------------------------------------------------------------------===//
14 include "PPCInstrFormats.td"
16 //===----------------------------------------------------------------------===//
17 // PowerPC specific type constraints.
19 def SDT_PPCstfiwx : SDTypeProfile<0, 2, [ // stfiwx
20 SDTCisVT<0, f64>, SDTCisPtrTy<1>
22 def SDT_PPClfiwx : SDTypeProfile<1, 1, [ // lfiw[az]x
23 SDTCisVT<0, f64>, SDTCisPtrTy<1>
25 def SDT_PPCLxsizx : SDTypeProfile<1, 2, [
26 SDTCisVT<0, f64>, SDTCisPtrTy<1>, SDTCisPtrTy<2>
28 def SDT_PPCstxsix : SDTypeProfile<0, 3, [
29 SDTCisVT<0, f64>, SDTCisPtrTy<1>, SDTCisPtrTy<2>
31 def SDT_PPCcv_fp_to_int : SDTypeProfile<1, 1, [
32 SDTCisFP<0>, SDTCisFP<1>
34 def SDT_PPCstore_scal_int_from_vsr : SDTypeProfile<0, 3, [
35 SDTCisVT<0, f64>, SDTCisPtrTy<1>, SDTCisPtrTy<2>
37 def SDT_PPCVexts : SDTypeProfile<1, 2, [
38 SDTCisVT<0, f64>, SDTCisVT<1, f64>, SDTCisPtrTy<2>
40 def SDT_PPCSExtVElems : SDTypeProfile<1, 1, [
41 SDTCisVec<0>, SDTCisVec<1>
44 def SDT_PPCCallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32>,
46 def SDT_PPCCallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
48 def SDT_PPCvperm : SDTypeProfile<1, 3, [
49 SDTCisVT<3, v16i8>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>
52 def SDT_PPCVecSplat : SDTypeProfile<1, 2, [ SDTCisVec<0>,
53 SDTCisVec<1>, SDTCisInt<2>
56 def SDT_PPCVecShift : SDTypeProfile<1, 3, [ SDTCisVec<0>,
57 SDTCisVec<1>, SDTCisVec<2>, SDTCisPtrTy<3>
60 def SDT_PPCVecInsert : SDTypeProfile<1, 3, [ SDTCisVec<0>,
61 SDTCisVec<1>, SDTCisVec<2>, SDTCisInt<3>
64 def SDT_PPCVecReverse: SDTypeProfile<1, 1, [ SDTCisVec<0>,
68 def SDT_PPCxxpermdi: SDTypeProfile<1, 3, [ SDTCisVec<0>,
69 SDTCisVec<1>, SDTCisVec<2>, SDTCisInt<3>
72 def SDT_PPCvcmp : SDTypeProfile<1, 3, [
73 SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisVT<3, i32>
76 def SDT_PPCcondbr : SDTypeProfile<0, 3, [
77 SDTCisVT<0, i32>, SDTCisVT<2, OtherVT>
80 def SDT_PPClbrx : SDTypeProfile<1, 2, [
81 SDTCisInt<0>, SDTCisPtrTy<1>, SDTCisVT<2, OtherVT>
83 def SDT_PPCstbrx : SDTypeProfile<0, 3, [
84 SDTCisInt<0>, SDTCisPtrTy<1>, SDTCisVT<2, OtherVT>
87 def SDT_PPCTC_ret : SDTypeProfile<0, 2, [
88 SDTCisPtrTy<0>, SDTCisVT<1, i32>
91 def tocentry32 : Operand<iPTR> {
92 let MIOperandInfo = (ops i32imm:$imm);
95 def SDT_PPCqvfperm : SDTypeProfile<1, 3, [
96 SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisVec<3>
98 def SDT_PPCqvgpci : SDTypeProfile<1, 1, [
99 SDTCisVec<0>, SDTCisInt<1>
101 def SDT_PPCqvaligni : SDTypeProfile<1, 3, [
102 SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisInt<3>
104 def SDT_PPCqvesplati : SDTypeProfile<1, 2, [
105 SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisInt<2>
108 def SDT_PPCqbflt : SDTypeProfile<1, 1, [
109 SDTCisVec<0>, SDTCisVec<1>
112 def SDT_PPCqvlfsb : SDTypeProfile<1, 1, [
113 SDTCisVec<0>, SDTCisPtrTy<1>
116 def SDT_PPCextswsli : SDTypeProfile<1, 2, [ // extswsli
117 SDTCisInt<0>, SDTCisInt<1>, SDTCisOpSmallerThanOp<1, 0>, SDTCisInt<2>
120 //===----------------------------------------------------------------------===//
121 // PowerPC specific DAG Nodes.
124 def PPCfre : SDNode<"PPCISD::FRE", SDTFPUnaryOp, []>;
125 def PPCfrsqrte: SDNode<"PPCISD::FRSQRTE", SDTFPUnaryOp, []>;
127 def PPCfcfid : SDNode<"PPCISD::FCFID", SDTFPUnaryOp, []>;
128 def PPCfcfidu : SDNode<"PPCISD::FCFIDU", SDTFPUnaryOp, []>;
129 def PPCfcfids : SDNode<"PPCISD::FCFIDS", SDTFPRoundOp, []>;
130 def PPCfcfidus: SDNode<"PPCISD::FCFIDUS", SDTFPRoundOp, []>;
131 def PPCfctidz : SDNode<"PPCISD::FCTIDZ", SDTFPUnaryOp, []>;
132 def PPCfctiwz : SDNode<"PPCISD::FCTIWZ", SDTFPUnaryOp, []>;
133 def PPCfctiduz: SDNode<"PPCISD::FCTIDUZ",SDTFPUnaryOp, []>;
134 def PPCfctiwuz: SDNode<"PPCISD::FCTIWUZ",SDTFPUnaryOp, []>;
136 def PPCcv_fp_to_uint_in_vsr:
137 SDNode<"PPCISD::FP_TO_UINT_IN_VSR", SDT_PPCcv_fp_to_int, []>;
138 def PPCcv_fp_to_sint_in_vsr:
139 SDNode<"PPCISD::FP_TO_SINT_IN_VSR", SDT_PPCcv_fp_to_int, []>;
140 def PPCstore_scal_int_from_vsr:
141 SDNode<"PPCISD::ST_VSR_SCAL_INT", SDT_PPCstore_scal_int_from_vsr,
142 [SDNPHasChain, SDNPMayStore]>;
143 def PPCstfiwx : SDNode<"PPCISD::STFIWX", SDT_PPCstfiwx,
144 [SDNPHasChain, SDNPMayStore]>;
145 def PPClfiwax : SDNode<"PPCISD::LFIWAX", SDT_PPClfiwx,
146 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
147 def PPClfiwzx : SDNode<"PPCISD::LFIWZX", SDT_PPClfiwx,
148 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
149 def PPClxsizx : SDNode<"PPCISD::LXSIZX", SDT_PPCLxsizx,
150 [SDNPHasChain, SDNPMayLoad]>;
151 def PPCstxsix : SDNode<"PPCISD::STXSIX", SDT_PPCstxsix,
152 [SDNPHasChain, SDNPMayStore]>;
153 def PPCVexts : SDNode<"PPCISD::VEXTS", SDT_PPCVexts, []>;
154 def PPCSExtVElems : SDNode<"PPCISD::SExtVElems", SDT_PPCSExtVElems, []>;
156 // Extract FPSCR (not modeled at the DAG level).
157 def PPCmffs : SDNode<"PPCISD::MFFS",
158 SDTypeProfile<1, 0, [SDTCisVT<0, f64>]>, []>;
160 // Perform FADD in round-to-zero mode.
161 def PPCfaddrtz: SDNode<"PPCISD::FADDRTZ", SDTFPBinOp, []>;
164 def PPCfsel : SDNode<"PPCISD::FSEL",
165 // Type constraint for fsel.
166 SDTypeProfile<1, 3, [SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>,
167 SDTCisFP<0>, SDTCisVT<1, f64>]>, []>;
169 def PPChi : SDNode<"PPCISD::Hi", SDTIntBinOp, []>;
170 def PPClo : SDNode<"PPCISD::Lo", SDTIntBinOp, []>;
171 def PPCtoc_entry: SDNode<"PPCISD::TOC_ENTRY", SDTIntBinOp,
172 [SDNPMayLoad, SDNPMemOperand]>;
173 def PPCvmaddfp : SDNode<"PPCISD::VMADDFP", SDTFPTernaryOp, []>;
174 def PPCvnmsubfp : SDNode<"PPCISD::VNMSUBFP", SDTFPTernaryOp, []>;
176 def PPCppc32GOT : SDNode<"PPCISD::PPC32_GOT", SDTIntLeaf, []>;
178 def PPCaddisGotTprelHA : SDNode<"PPCISD::ADDIS_GOT_TPREL_HA", SDTIntBinOp>;
179 def PPCldGotTprelL : SDNode<"PPCISD::LD_GOT_TPREL_L", SDTIntBinOp,
181 def PPCaddTls : SDNode<"PPCISD::ADD_TLS", SDTIntBinOp, []>;
182 def PPCaddisTlsgdHA : SDNode<"PPCISD::ADDIS_TLSGD_HA", SDTIntBinOp>;
183 def PPCaddiTlsgdL : SDNode<"PPCISD::ADDI_TLSGD_L", SDTIntBinOp>;
184 def PPCgetTlsAddr : SDNode<"PPCISD::GET_TLS_ADDR", SDTIntBinOp>;
185 def PPCaddiTlsgdLAddr : SDNode<"PPCISD::ADDI_TLSGD_L_ADDR",
186 SDTypeProfile<1, 3, [
187 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
188 SDTCisSameAs<0, 3>, SDTCisInt<0> ]>>;
189 def PPCaddisTlsldHA : SDNode<"PPCISD::ADDIS_TLSLD_HA", SDTIntBinOp>;
190 def PPCaddiTlsldL : SDNode<"PPCISD::ADDI_TLSLD_L", SDTIntBinOp>;
191 def PPCgetTlsldAddr : SDNode<"PPCISD::GET_TLSLD_ADDR", SDTIntBinOp>;
192 def PPCaddiTlsldLAddr : SDNode<"PPCISD::ADDI_TLSLD_L_ADDR",
193 SDTypeProfile<1, 3, [
194 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
195 SDTCisSameAs<0, 3>, SDTCisInt<0> ]>>;
196 def PPCaddisDtprelHA : SDNode<"PPCISD::ADDIS_DTPREL_HA", SDTIntBinOp>;
197 def PPCaddiDtprelL : SDNode<"PPCISD::ADDI_DTPREL_L", SDTIntBinOp>;
199 def PPCvperm : SDNode<"PPCISD::VPERM", SDT_PPCvperm, []>;
200 def PPCxxsplt : SDNode<"PPCISD::XXSPLT", SDT_PPCVecSplat, []>;
201 def PPCvecinsert : SDNode<"PPCISD::VECINSERT", SDT_PPCVecInsert, []>;
202 def PPCxxreverse : SDNode<"PPCISD::XXREVERSE", SDT_PPCVecReverse, []>;
203 def PPCxxpermdi : SDNode<"PPCISD::XXPERMDI", SDT_PPCxxpermdi, []>;
204 def PPCvecshl : SDNode<"PPCISD::VECSHL", SDT_PPCVecShift, []>;
206 def PPCqvfperm : SDNode<"PPCISD::QVFPERM", SDT_PPCqvfperm, []>;
207 def PPCqvgpci : SDNode<"PPCISD::QVGPCI", SDT_PPCqvgpci, []>;
208 def PPCqvaligni : SDNode<"PPCISD::QVALIGNI", SDT_PPCqvaligni, []>;
209 def PPCqvesplati : SDNode<"PPCISD::QVESPLATI", SDT_PPCqvesplati, []>;
211 def PPCqbflt : SDNode<"PPCISD::QBFLT", SDT_PPCqbflt, []>;
213 def PPCqvlfsb : SDNode<"PPCISD::QVLFSb", SDT_PPCqvlfsb,
214 [SDNPHasChain, SDNPMayLoad]>;
216 def PPCcmpb : SDNode<"PPCISD::CMPB", SDTIntBinOp, []>;
218 // These nodes represent the 32-bit PPC shifts that operate on 6-bit shift
219 // amounts. These nodes are generated by the multi-precision shift code.
220 def PPCsrl : SDNode<"PPCISD::SRL" , SDTIntShiftOp>;
221 def PPCsra : SDNode<"PPCISD::SRA" , SDTIntShiftOp>;
222 def PPCshl : SDNode<"PPCISD::SHL" , SDTIntShiftOp>;
224 def PPCextswsli : SDNode<"PPCISD::EXTSWSLI" , SDT_PPCextswsli>;
226 // Move 2 i64 values into a VSX register
227 def PPCbuild_fp128: SDNode<"PPCISD::BUILD_FP128",
229 [SDTCisFP<0>, SDTCisSameSizeAs<1,2>,
233 def PPCbuild_spe64: SDNode<"PPCISD::BUILD_SPE64",
235 [SDTCisVT<0, f64>, SDTCisVT<1,i32>,
239 def PPCextract_spe : SDNode<"PPCISD::EXTRACT_SPE",
241 [SDTCisVT<0, i32>, SDTCisVT<1, f64>,
245 // These are target-independent nodes, but have target-specific formats.
246 def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_PPCCallSeqStart,
247 [SDNPHasChain, SDNPOutGlue]>;
248 def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_PPCCallSeqEnd,
249 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
251 def SDT_PPCCall : SDTypeProfile<0, -1, [SDTCisInt<0>]>;
252 def PPCcall : SDNode<"PPCISD::CALL", SDT_PPCCall,
253 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
255 def PPCcall_nop : SDNode<"PPCISD::CALL_NOP", SDT_PPCCall,
256 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
258 def PPCmtctr : SDNode<"PPCISD::MTCTR", SDT_PPCCall,
259 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
260 def PPCbctrl : SDNode<"PPCISD::BCTRL", SDTNone,
261 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
263 def PPCbctrl_load_toc : SDNode<"PPCISD::BCTRL_LOAD_TOC",
264 SDTypeProfile<0, 1, []>,
265 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
268 def retflag : SDNode<"PPCISD::RET_FLAG", SDTNone,
269 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
271 def PPCtc_return : SDNode<"PPCISD::TC_RETURN", SDT_PPCTC_ret,
272 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
274 def PPCeh_sjlj_setjmp : SDNode<"PPCISD::EH_SJLJ_SETJMP",
275 SDTypeProfile<1, 1, [SDTCisInt<0>,
277 [SDNPHasChain, SDNPSideEffect]>;
278 def PPCeh_sjlj_longjmp : SDNode<"PPCISD::EH_SJLJ_LONGJMP",
279 SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>,
280 [SDNPHasChain, SDNPSideEffect]>;
282 def SDT_PPCsc : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
283 def PPCsc : SDNode<"PPCISD::SC", SDT_PPCsc,
284 [SDNPHasChain, SDNPSideEffect]>;
286 def PPCclrbhrb : SDNode<"PPCISD::CLRBHRB", SDTNone,
287 [SDNPHasChain, SDNPSideEffect]>;
288 def PPCmfbhrbe : SDNode<"PPCISD::MFBHRBE", SDTIntBinOp, [SDNPHasChain]>;
289 def PPCrfebb : SDNode<"PPCISD::RFEBB", SDT_PPCsc,
290 [SDNPHasChain, SDNPSideEffect]>;
292 def PPCvcmp : SDNode<"PPCISD::VCMP" , SDT_PPCvcmp, []>;
293 def PPCvcmp_o : SDNode<"PPCISD::VCMPo", SDT_PPCvcmp, [SDNPOutGlue]>;
295 def PPCcondbranch : SDNode<"PPCISD::COND_BRANCH", SDT_PPCcondbr,
296 [SDNPHasChain, SDNPOptInGlue]>;
298 // PPC-specific atomic operations.
299 def PPCatomicCmpSwap_8 :
300 SDNode<"PPCISD::ATOMIC_CMP_SWAP_8", SDTAtomic3,
301 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
302 def PPCatomicCmpSwap_16 :
303 SDNode<"PPCISD::ATOMIC_CMP_SWAP_16", SDTAtomic3,
304 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
305 def PPClbrx : SDNode<"PPCISD::LBRX", SDT_PPClbrx,
306 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
307 def PPCstbrx : SDNode<"PPCISD::STBRX", SDT_PPCstbrx,
308 [SDNPHasChain, SDNPMayStore]>;
310 // Instructions to set/unset CR bit 6 for SVR4 vararg calls
311 def PPCcr6set : SDNode<"PPCISD::CR6SET", SDTNone,
312 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
313 def PPCcr6unset : SDNode<"PPCISD::CR6UNSET", SDTNone,
314 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
316 // Instructions to support dynamic alloca.
317 def SDTDynOp : SDTypeProfile<1, 2, []>;
318 def SDTDynAreaOp : SDTypeProfile<1, 1, []>;
319 def PPCdynalloc : SDNode<"PPCISD::DYNALLOC", SDTDynOp, [SDNPHasChain]>;
320 def PPCdynareaoffset : SDNode<"PPCISD::DYNAREAOFFSET", SDTDynAreaOp, [SDNPHasChain]>;
322 //===----------------------------------------------------------------------===//
323 // PowerPC specific transformation functions and pattern fragments.
326 def SHL32 : SDNodeXForm<imm, [{
327 // Transformation function: 31 - imm
328 return getI32Imm(31 - N->getZExtValue(), SDLoc(N));
331 def SRL32 : SDNodeXForm<imm, [{
332 // Transformation function: 32 - imm
333 return N->getZExtValue() ? getI32Imm(32 - N->getZExtValue(), SDLoc(N))
334 : getI32Imm(0, SDLoc(N));
337 def LO16 : SDNodeXForm<imm, [{
338 // Transformation function: get the low 16 bits.
339 return getI32Imm((unsigned short)N->getZExtValue(), SDLoc(N));
342 def HI16 : SDNodeXForm<imm, [{
343 // Transformation function: shift the immediate value down into the low bits.
344 return getI32Imm((unsigned)N->getZExtValue() >> 16, SDLoc(N));
347 def HA16 : SDNodeXForm<imm, [{
348 // Transformation function: shift the immediate value down into the low bits.
349 long Val = N->getZExtValue();
350 return getI32Imm((Val - (signed short)Val) >> 16, SDLoc(N));
352 def MB : SDNodeXForm<imm, [{
353 // Transformation function: get the start bit of a mask
355 (void)isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
356 return getI32Imm(mb, SDLoc(N));
359 def ME : SDNodeXForm<imm, [{
360 // Transformation function: get the end bit of a mask
362 (void)isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
363 return getI32Imm(me, SDLoc(N));
365 def maskimm32 : PatLeaf<(imm), [{
366 // maskImm predicate - True if immediate is a run of ones.
368 if (N->getValueType(0) == MVT::i32)
369 return isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
374 def imm32SExt16 : Operand<i32>, ImmLeaf<i32, [{
375 // imm32SExt16 predicate - True if the i32 immediate fits in a 16-bit
376 // sign extended field. Used by instructions like 'addi'.
377 return (int32_t)Imm == (short)Imm;
379 def imm64SExt16 : Operand<i64>, ImmLeaf<i64, [{
380 // imm64SExt16 predicate - True if the i64 immediate fits in a 16-bit
381 // sign extended field. Used by instructions like 'addi'.
382 return (int64_t)Imm == (short)Imm;
384 def immZExt16 : PatLeaf<(imm), [{
385 // immZExt16 predicate - True if the immediate fits in a 16-bit zero extended
386 // field. Used by instructions like 'ori'.
387 return (uint64_t)N->getZExtValue() == (unsigned short)N->getZExtValue();
389 def immAnyExt8 : ImmLeaf<i32, [{ return isInt<8>(Imm) || isUInt<8>(Imm); }]>;
390 def immSExt5NonZero : ImmLeaf<i32, [{ return Imm && isInt<5>(Imm); }]>;
392 // imm16Shifted* - These match immediates where the low 16-bits are zero. There
393 // are two forms: imm16ShiftedSExt and imm16ShiftedZExt. These two forms are
394 // identical in 32-bit mode, but in 64-bit mode, they return true if the
395 // immediate fits into a sign/zero extended 32-bit immediate (with the low bits
397 def imm16ShiftedZExt : PatLeaf<(imm), [{
398 // imm16ShiftedZExt predicate - True if only bits in the top 16-bits of the
399 // immediate are set. Used by instructions like 'xoris'.
400 return (N->getZExtValue() & ~uint64_t(0xFFFF0000)) == 0;
403 def imm16ShiftedSExt : PatLeaf<(imm), [{
404 // imm16ShiftedSExt predicate - True if only bits in the top 16-bits of the
405 // immediate are set. Used by instructions like 'addis'. Identical to
406 // imm16ShiftedZExt in 32-bit mode.
407 if (N->getZExtValue() & 0xFFFF) return false;
408 if (N->getValueType(0) == MVT::i32)
410 // For 64-bit, make sure it is sext right.
411 return N->getZExtValue() == (uint64_t)(int)N->getZExtValue();
414 def imm64ZExt32 : Operand<i64>, ImmLeaf<i64, [{
415 // imm64ZExt32 predicate - True if the i64 immediate fits in a 32-bit
416 // zero extended field.
417 return isUInt<32>(Imm);
420 // Some r+i load/store instructions (such as LD, STD, LDU, etc.) that require
421 // restricted memrix (4-aligned) constants are alignment sensitive. If these
422 // offsets are hidden behind TOC entries than the values of the lower-order
423 // bits cannot be checked directly. As a result, we need to also incorporate
424 // an alignment check into the relevant patterns.
426 def aligned4load : PatFrag<(ops node:$ptr), (load node:$ptr), [{
427 return cast<LoadSDNode>(N)->getAlignment() >= 4;
429 def aligned4store : PatFrag<(ops node:$val, node:$ptr),
430 (store node:$val, node:$ptr), [{
431 return cast<StoreSDNode>(N)->getAlignment() >= 4;
433 def aligned4sextloadi32 : PatFrag<(ops node:$ptr), (sextloadi32 node:$ptr), [{
434 return cast<LoadSDNode>(N)->getAlignment() >= 4;
436 def aligned4pre_store : PatFrag<
437 (ops node:$val, node:$base, node:$offset),
438 (pre_store node:$val, node:$base, node:$offset), [{
439 return cast<StoreSDNode>(N)->getAlignment() >= 4;
442 def unaligned4load : PatFrag<(ops node:$ptr), (load node:$ptr), [{
443 return cast<LoadSDNode>(N)->getAlignment() < 4;
445 def unaligned4store : PatFrag<(ops node:$val, node:$ptr),
446 (store node:$val, node:$ptr), [{
447 return cast<StoreSDNode>(N)->getAlignment() < 4;
449 def unaligned4sextloadi32 : PatFrag<(ops node:$ptr), (sextloadi32 node:$ptr), [{
450 return cast<LoadSDNode>(N)->getAlignment() < 4;
453 // This is a somewhat weaker condition than actually checking for 16-byte
454 // alignment. It is simply checking that the displacement can be represented
455 // as an immediate that is a multiple of 16 (i.e. the requirements for DQ-Form
457 def quadwOffsetLoad : PatFrag<(ops node:$ptr), (load node:$ptr), [{
458 return isOffsetMultipleOf(N, 16);
460 def quadwOffsetStore : PatFrag<(ops node:$val, node:$ptr),
461 (store node:$val, node:$ptr), [{
462 return isOffsetMultipleOf(N, 16);
464 def nonQuadwOffsetLoad : PatFrag<(ops node:$ptr), (load node:$ptr), [{
465 return !isOffsetMultipleOf(N, 16);
467 def nonQuadwOffsetStore : PatFrag<(ops node:$val, node:$ptr),
468 (store node:$val, node:$ptr), [{
469 return !isOffsetMultipleOf(N, 16);
472 // PatFrag for binary operation whose operands are both non-constant
473 class BinOpWithoutSImm16Operand<SDNode opcode> :
474 PatFrag<(ops node:$left, node:$right), (opcode node:$left, node:$right), [{
476 return !isIntS16Immediate(N->getOperand(0), Imm)
477 && !isIntS16Immediate(N->getOperand(1), Imm);
480 def add_without_simm16 : BinOpWithoutSImm16Operand<add>;
481 def mul_without_simm16 : BinOpWithoutSImm16Operand<mul>;
483 //===----------------------------------------------------------------------===//
484 // PowerPC Flag Definitions.
486 class isPPC64 { bit PPC64 = 1; }
487 class isDOT { bit RC = 1; }
489 class RegConstraint<string C> {
490 string Constraints = C;
492 class NoEncode<string E> {
493 string DisableEncoding = E;
497 //===----------------------------------------------------------------------===//
498 // PowerPC Operand Definitions.
500 // In the default PowerPC assembler syntax, registers are specified simply
501 // by number, so they cannot be distinguished from immediate values (without
502 // looking at the opcode). This means that the default operand matching logic
503 // for the asm parser does not work, and we need to specify custom matchers.
504 // Since those can only be specified with RegisterOperand classes and not
505 // directly on the RegisterClass, all instructions patterns used by the asm
506 // parser need to use a RegisterOperand (instead of a RegisterClass) for
507 // all their register operands.
508 // For this purpose, we define one RegisterOperand for each RegisterClass,
509 // using the same name as the class, just in lower case.
511 def PPCRegGPRCAsmOperand : AsmOperandClass {
512 let Name = "RegGPRC"; let PredicateMethod = "isRegNumber";
514 def gprc : RegisterOperand<GPRC> {
515 let ParserMatchClass = PPCRegGPRCAsmOperand;
517 def PPCRegG8RCAsmOperand : AsmOperandClass {
518 let Name = "RegG8RC"; let PredicateMethod = "isRegNumber";
520 def g8rc : RegisterOperand<G8RC> {
521 let ParserMatchClass = PPCRegG8RCAsmOperand;
523 def PPCRegGPRCNoR0AsmOperand : AsmOperandClass {
524 let Name = "RegGPRCNoR0"; let PredicateMethod = "isRegNumber";
526 def gprc_nor0 : RegisterOperand<GPRC_NOR0> {
527 let ParserMatchClass = PPCRegGPRCNoR0AsmOperand;
529 def PPCRegG8RCNoX0AsmOperand : AsmOperandClass {
530 let Name = "RegG8RCNoX0"; let PredicateMethod = "isRegNumber";
532 def g8rc_nox0 : RegisterOperand<G8RC_NOX0> {
533 let ParserMatchClass = PPCRegG8RCNoX0AsmOperand;
535 def PPCRegF8RCAsmOperand : AsmOperandClass {
536 let Name = "RegF8RC"; let PredicateMethod = "isRegNumber";
538 def f8rc : RegisterOperand<F8RC> {
539 let ParserMatchClass = PPCRegF8RCAsmOperand;
541 def PPCRegF4RCAsmOperand : AsmOperandClass {
542 let Name = "RegF4RC"; let PredicateMethod = "isRegNumber";
544 def f4rc : RegisterOperand<F4RC> {
545 let ParserMatchClass = PPCRegF4RCAsmOperand;
547 def PPCRegVRRCAsmOperand : AsmOperandClass {
548 let Name = "RegVRRC"; let PredicateMethod = "isRegNumber";
550 def vrrc : RegisterOperand<VRRC> {
551 let ParserMatchClass = PPCRegVRRCAsmOperand;
553 def PPCRegVFRCAsmOperand : AsmOperandClass {
554 let Name = "RegVFRC"; let PredicateMethod = "isRegNumber";
556 def vfrc : RegisterOperand<VFRC> {
557 let ParserMatchClass = PPCRegVFRCAsmOperand;
559 def PPCRegCRBITRCAsmOperand : AsmOperandClass {
560 let Name = "RegCRBITRC"; let PredicateMethod = "isCRBitNumber";
562 def crbitrc : RegisterOperand<CRBITRC> {
563 let ParserMatchClass = PPCRegCRBITRCAsmOperand;
565 def PPCRegCRRCAsmOperand : AsmOperandClass {
566 let Name = "RegCRRC"; let PredicateMethod = "isCCRegNumber";
568 def crrc : RegisterOperand<CRRC> {
569 let ParserMatchClass = PPCRegCRRCAsmOperand;
571 def PPCRegSPERCAsmOperand : AsmOperandClass {
572 let Name = "RegSPERC"; let PredicateMethod = "isRegNumber";
574 def sperc : RegisterOperand<SPERC> {
575 let ParserMatchClass = PPCRegSPERCAsmOperand;
577 def PPCRegSPE4RCAsmOperand : AsmOperandClass {
578 let Name = "RegSPE4RC"; let PredicateMethod = "isRegNumber";
580 def spe4rc : RegisterOperand<SPE4RC> {
581 let ParserMatchClass = PPCRegSPE4RCAsmOperand;
584 def PPCU1ImmAsmOperand : AsmOperandClass {
585 let Name = "U1Imm"; let PredicateMethod = "isU1Imm";
586 let RenderMethod = "addImmOperands";
588 def u1imm : Operand<i32> {
589 let PrintMethod = "printU1ImmOperand";
590 let ParserMatchClass = PPCU1ImmAsmOperand;
593 def PPCU2ImmAsmOperand : AsmOperandClass {
594 let Name = "U2Imm"; let PredicateMethod = "isU2Imm";
595 let RenderMethod = "addImmOperands";
597 def u2imm : Operand<i32> {
598 let PrintMethod = "printU2ImmOperand";
599 let ParserMatchClass = PPCU2ImmAsmOperand;
602 def PPCATBitsAsHintAsmOperand : AsmOperandClass {
603 let Name = "ATBitsAsHint"; let PredicateMethod = "isATBitsAsHint";
604 let RenderMethod = "addImmOperands"; // Irrelevant, predicate always fails.
606 def atimm : Operand<i32> {
607 let PrintMethod = "printATBitsAsHint";
608 let ParserMatchClass = PPCATBitsAsHintAsmOperand;
611 def PPCU3ImmAsmOperand : AsmOperandClass {
612 let Name = "U3Imm"; let PredicateMethod = "isU3Imm";
613 let RenderMethod = "addImmOperands";
615 def u3imm : Operand<i32> {
616 let PrintMethod = "printU3ImmOperand";
617 let ParserMatchClass = PPCU3ImmAsmOperand;
620 def PPCU4ImmAsmOperand : AsmOperandClass {
621 let Name = "U4Imm"; let PredicateMethod = "isU4Imm";
622 let RenderMethod = "addImmOperands";
624 def u4imm : Operand<i32> {
625 let PrintMethod = "printU4ImmOperand";
626 let ParserMatchClass = PPCU4ImmAsmOperand;
628 def PPCS5ImmAsmOperand : AsmOperandClass {
629 let Name = "S5Imm"; let PredicateMethod = "isS5Imm";
630 let RenderMethod = "addImmOperands";
632 def s5imm : Operand<i32> {
633 let PrintMethod = "printS5ImmOperand";
634 let ParserMatchClass = PPCS5ImmAsmOperand;
635 let DecoderMethod = "decodeSImmOperand<5>";
637 def PPCU5ImmAsmOperand : AsmOperandClass {
638 let Name = "U5Imm"; let PredicateMethod = "isU5Imm";
639 let RenderMethod = "addImmOperands";
641 def u5imm : Operand<i32> {
642 let PrintMethod = "printU5ImmOperand";
643 let ParserMatchClass = PPCU5ImmAsmOperand;
644 let DecoderMethod = "decodeUImmOperand<5>";
646 def PPCU6ImmAsmOperand : AsmOperandClass {
647 let Name = "U6Imm"; let PredicateMethod = "isU6Imm";
648 let RenderMethod = "addImmOperands";
650 def u6imm : Operand<i32> {
651 let PrintMethod = "printU6ImmOperand";
652 let ParserMatchClass = PPCU6ImmAsmOperand;
653 let DecoderMethod = "decodeUImmOperand<6>";
655 def PPCU7ImmAsmOperand : AsmOperandClass {
656 let Name = "U7Imm"; let PredicateMethod = "isU7Imm";
657 let RenderMethod = "addImmOperands";
659 def u7imm : Operand<i32> {
660 let PrintMethod = "printU7ImmOperand";
661 let ParserMatchClass = PPCU7ImmAsmOperand;
662 let DecoderMethod = "decodeUImmOperand<7>";
664 def PPCU8ImmAsmOperand : AsmOperandClass {
665 let Name = "U8Imm"; let PredicateMethod = "isU8Imm";
666 let RenderMethod = "addImmOperands";
668 def u8imm : Operand<i32> {
669 let PrintMethod = "printU8ImmOperand";
670 let ParserMatchClass = PPCU8ImmAsmOperand;
671 let DecoderMethod = "decodeUImmOperand<8>";
673 def PPCU10ImmAsmOperand : AsmOperandClass {
674 let Name = "U10Imm"; let PredicateMethod = "isU10Imm";
675 let RenderMethod = "addImmOperands";
677 def u10imm : Operand<i32> {
678 let PrintMethod = "printU10ImmOperand";
679 let ParserMatchClass = PPCU10ImmAsmOperand;
680 let DecoderMethod = "decodeUImmOperand<10>";
682 def PPCU12ImmAsmOperand : AsmOperandClass {
683 let Name = "U12Imm"; let PredicateMethod = "isU12Imm";
684 let RenderMethod = "addImmOperands";
686 def u12imm : Operand<i32> {
687 let PrintMethod = "printU12ImmOperand";
688 let ParserMatchClass = PPCU12ImmAsmOperand;
689 let DecoderMethod = "decodeUImmOperand<12>";
691 def PPCS16ImmAsmOperand : AsmOperandClass {
692 let Name = "S16Imm"; let PredicateMethod = "isS16Imm";
693 let RenderMethod = "addS16ImmOperands";
695 def s16imm : Operand<i32> {
696 let PrintMethod = "printS16ImmOperand";
697 let EncoderMethod = "getImm16Encoding";
698 let ParserMatchClass = PPCS16ImmAsmOperand;
699 let DecoderMethod = "decodeSImmOperand<16>";
701 def PPCU16ImmAsmOperand : AsmOperandClass {
702 let Name = "U16Imm"; let PredicateMethod = "isU16Imm";
703 let RenderMethod = "addU16ImmOperands";
705 def u16imm : Operand<i32> {
706 let PrintMethod = "printU16ImmOperand";
707 let EncoderMethod = "getImm16Encoding";
708 let ParserMatchClass = PPCU16ImmAsmOperand;
709 let DecoderMethod = "decodeUImmOperand<16>";
711 def PPCS17ImmAsmOperand : AsmOperandClass {
712 let Name = "S17Imm"; let PredicateMethod = "isS17Imm";
713 let RenderMethod = "addS16ImmOperands";
715 def s17imm : Operand<i32> {
716 // This operand type is used for addis/lis to allow the assembler parser
717 // to accept immediates in the range -65536..65535 for compatibility with
718 // the GNU assembler. The operand is treated as 16-bit otherwise.
719 let PrintMethod = "printS16ImmOperand";
720 let EncoderMethod = "getImm16Encoding";
721 let ParserMatchClass = PPCS17ImmAsmOperand;
722 let DecoderMethod = "decodeSImmOperand<16>";
725 def fpimm0 : PatLeaf<(fpimm), [{ return N->isExactlyValue(+0.0); }]>;
727 def PPCDirectBrAsmOperand : AsmOperandClass {
728 let Name = "DirectBr"; let PredicateMethod = "isDirectBr";
729 let RenderMethod = "addBranchTargetOperands";
731 def directbrtarget : Operand<OtherVT> {
732 let PrintMethod = "printBranchOperand";
733 let EncoderMethod = "getDirectBrEncoding";
734 let ParserMatchClass = PPCDirectBrAsmOperand;
736 def absdirectbrtarget : Operand<OtherVT> {
737 let PrintMethod = "printAbsBranchOperand";
738 let EncoderMethod = "getAbsDirectBrEncoding";
739 let ParserMatchClass = PPCDirectBrAsmOperand;
741 def PPCCondBrAsmOperand : AsmOperandClass {
742 let Name = "CondBr"; let PredicateMethod = "isCondBr";
743 let RenderMethod = "addBranchTargetOperands";
745 def condbrtarget : Operand<OtherVT> {
746 let PrintMethod = "printBranchOperand";
747 let EncoderMethod = "getCondBrEncoding";
748 let ParserMatchClass = PPCCondBrAsmOperand;
750 def abscondbrtarget : Operand<OtherVT> {
751 let PrintMethod = "printAbsBranchOperand";
752 let EncoderMethod = "getAbsCondBrEncoding";
753 let ParserMatchClass = PPCCondBrAsmOperand;
755 def calltarget : Operand<iPTR> {
756 let PrintMethod = "printBranchOperand";
757 let EncoderMethod = "getDirectBrEncoding";
758 let DecoderMethod = "DecodePCRel24BranchTarget";
759 let ParserMatchClass = PPCDirectBrAsmOperand;
760 let OperandType = "OPERAND_PCREL";
762 def abscalltarget : Operand<iPTR> {
763 let PrintMethod = "printAbsBranchOperand";
764 let EncoderMethod = "getAbsDirectBrEncoding";
765 let ParserMatchClass = PPCDirectBrAsmOperand;
767 def PPCCRBitMaskOperand : AsmOperandClass {
768 let Name = "CRBitMask"; let PredicateMethod = "isCRBitMask";
770 def crbitm: Operand<i8> {
771 let PrintMethod = "printcrbitm";
772 let EncoderMethod = "get_crbitm_encoding";
773 let DecoderMethod = "decodeCRBitMOperand";
774 let ParserMatchClass = PPCCRBitMaskOperand;
777 // A version of ptr_rc which excludes R0 (or X0 in 64-bit mode).
778 def PPCRegGxRCNoR0Operand : AsmOperandClass {
779 let Name = "RegGxRCNoR0"; let PredicateMethod = "isRegNumber";
781 def ptr_rc_nor0 : Operand<iPTR>, PointerLikeRegClass<1> {
782 let ParserMatchClass = PPCRegGxRCNoR0Operand;
784 // A version of ptr_rc usable with the asm parser.
785 def PPCRegGxRCOperand : AsmOperandClass {
786 let Name = "RegGxRC"; let PredicateMethod = "isRegNumber";
788 def ptr_rc_idx : Operand<iPTR>, PointerLikeRegClass<0> {
789 let ParserMatchClass = PPCRegGxRCOperand;
792 def PPCDispRIOperand : AsmOperandClass {
793 let Name = "DispRI"; let PredicateMethod = "isS16Imm";
794 let RenderMethod = "addS16ImmOperands";
796 def dispRI : Operand<iPTR> {
797 let ParserMatchClass = PPCDispRIOperand;
799 def PPCDispRIXOperand : AsmOperandClass {
800 let Name = "DispRIX"; let PredicateMethod = "isS16ImmX4";
801 let RenderMethod = "addImmOperands";
803 def dispRIX : Operand<iPTR> {
804 let ParserMatchClass = PPCDispRIXOperand;
806 def PPCDispRIX16Operand : AsmOperandClass {
807 let Name = "DispRIX16"; let PredicateMethod = "isS16ImmX16";
808 let RenderMethod = "addImmOperands";
810 def dispRIX16 : Operand<iPTR> {
811 let ParserMatchClass = PPCDispRIX16Operand;
813 def PPCDispSPE8Operand : AsmOperandClass {
814 let Name = "DispSPE8"; let PredicateMethod = "isU8ImmX8";
815 let RenderMethod = "addImmOperands";
817 def dispSPE8 : Operand<iPTR> {
818 let ParserMatchClass = PPCDispSPE8Operand;
820 def PPCDispSPE4Operand : AsmOperandClass {
821 let Name = "DispSPE4"; let PredicateMethod = "isU7ImmX4";
822 let RenderMethod = "addImmOperands";
824 def dispSPE4 : Operand<iPTR> {
825 let ParserMatchClass = PPCDispSPE4Operand;
827 def PPCDispSPE2Operand : AsmOperandClass {
828 let Name = "DispSPE2"; let PredicateMethod = "isU6ImmX2";
829 let RenderMethod = "addImmOperands";
831 def dispSPE2 : Operand<iPTR> {
832 let ParserMatchClass = PPCDispSPE2Operand;
835 def memri : Operand<iPTR> {
836 let PrintMethod = "printMemRegImm";
837 let MIOperandInfo = (ops dispRI:$imm, ptr_rc_nor0:$reg);
838 let EncoderMethod = "getMemRIEncoding";
839 let DecoderMethod = "decodeMemRIOperands";
841 def memrr : Operand<iPTR> {
842 let PrintMethod = "printMemRegReg";
843 let MIOperandInfo = (ops ptr_rc_nor0:$ptrreg, ptr_rc_idx:$offreg);
845 def memrix : Operand<iPTR> { // memri where the imm is 4-aligned.
846 let PrintMethod = "printMemRegImm";
847 let MIOperandInfo = (ops dispRIX:$imm, ptr_rc_nor0:$reg);
848 let EncoderMethod = "getMemRIXEncoding";
849 let DecoderMethod = "decodeMemRIXOperands";
851 def memrix16 : Operand<iPTR> { // memri, imm is 16-aligned, 12-bit, Inst{16:27}
852 let PrintMethod = "printMemRegImm";
853 let MIOperandInfo = (ops dispRIX16:$imm, ptr_rc_nor0:$reg);
854 let EncoderMethod = "getMemRIX16Encoding";
855 let DecoderMethod = "decodeMemRIX16Operands";
857 def spe8dis : Operand<iPTR> { // SPE displacement where the imm is 8-aligned.
858 let PrintMethod = "printMemRegImm";
859 let MIOperandInfo = (ops dispSPE8:$imm, ptr_rc_nor0:$reg);
860 let EncoderMethod = "getSPE8DisEncoding";
861 let DecoderMethod = "decodeSPE8Operands";
863 def spe4dis : Operand<iPTR> { // SPE displacement where the imm is 4-aligned.
864 let PrintMethod = "printMemRegImm";
865 let MIOperandInfo = (ops dispSPE4:$imm, ptr_rc_nor0:$reg);
866 let EncoderMethod = "getSPE4DisEncoding";
867 let DecoderMethod = "decodeSPE4Operands";
869 def spe2dis : Operand<iPTR> { // SPE displacement where the imm is 2-aligned.
870 let PrintMethod = "printMemRegImm";
871 let MIOperandInfo = (ops dispSPE2:$imm, ptr_rc_nor0:$reg);
872 let EncoderMethod = "getSPE2DisEncoding";
873 let DecoderMethod = "decodeSPE2Operands";
876 // A single-register address. This is used with the SjLj
877 // pseudo-instructions which tranlates to LD/LWZ. These instructions requires
878 // G8RC_NOX0 registers.
879 def memr : Operand<iPTR> {
880 let MIOperandInfo = (ops ptr_rc_nor0:$ptrreg);
882 def PPCTLSRegOperand : AsmOperandClass {
883 let Name = "TLSReg"; let PredicateMethod = "isTLSReg";
884 let RenderMethod = "addTLSRegOperands";
886 def tlsreg32 : Operand<i32> {
887 let EncoderMethod = "getTLSRegEncoding";
888 let ParserMatchClass = PPCTLSRegOperand;
890 def tlsgd32 : Operand<i32> {}
891 def tlscall32 : Operand<i32> {
892 let PrintMethod = "printTLSCall";
893 let MIOperandInfo = (ops calltarget:$func, tlsgd32:$sym);
894 let EncoderMethod = "getTLSCallEncoding";
897 // PowerPC Predicate operand.
898 def pred : Operand<OtherVT> {
899 let PrintMethod = "printPredicateOperand";
900 let MIOperandInfo = (ops i32imm:$bibo, crrc:$reg);
903 // Define PowerPC specific addressing mode.
906 def iaddr : ComplexPattern<iPTR, 2, "SelectAddrImm", [], []>; // "stb"
908 def iaddrX4 : ComplexPattern<iPTR, 2, "SelectAddrImmX4", [], []>; // "std"
910 def iaddrX16 : ComplexPattern<iPTR, 2, "SelectAddrImmX16", [], []>; // "stxv"
912 // Below forms are all x-form addressing mode, use three different ones so we
913 // can make a accurate check for x-form instructions in ISEL.
914 // x-form addressing mode whose associated diplacement form is D.
915 def xaddr : ComplexPattern<iPTR, 2, "SelectAddrIdx", [], []>; // "stbx"
916 // x-form addressing mode whose associated diplacement form is DS.
917 def xaddrX4 : ComplexPattern<iPTR, 2, "SelectAddrIdxX4", [], []>; // "stdx"
918 // x-form addressing mode whose associated diplacement form is DQ.
919 def xaddrX16 : ComplexPattern<iPTR, 2, "SelectAddrIdxX16", [], []>; // "stxvx"
921 def xoaddr : ComplexPattern<iPTR, 2, "SelectAddrIdxOnly",[], []>;
923 // The address in a single register. This is used with the SjLj
924 // pseudo-instructions.
925 def addr : ComplexPattern<iPTR, 1, "SelectAddr",[], []>;
927 /// This is just the offset part of iaddr, used for preinc.
928 def iaddroff : ComplexPattern<iPTR, 1, "SelectAddrImmOffs", [], []>;
930 //===----------------------------------------------------------------------===//
931 // PowerPC Instruction Predicate Definitions.
932 def In32BitMode : Predicate<"!PPCSubTarget->isPPC64()">;
933 def In64BitMode : Predicate<"PPCSubTarget->isPPC64()">;
934 def IsBookE : Predicate<"PPCSubTarget->isBookE()">;
935 def IsNotBookE : Predicate<"!PPCSubTarget->isBookE()">;
936 def HasOnlyMSYNC : Predicate<"PPCSubTarget->hasOnlyMSYNC()">;
937 def HasSYNC : Predicate<"!PPCSubTarget->hasOnlyMSYNC()">;
938 def IsPPC4xx : Predicate<"PPCSubTarget->isPPC4xx()">;
939 def IsPPC6xx : Predicate<"PPCSubTarget->isPPC6xx()">;
940 def IsE500 : Predicate<"PPCSubTarget->isE500()">;
941 def HasSPE : Predicate<"PPCSubTarget->hasSPE()">;
942 def HasICBT : Predicate<"PPCSubTarget->hasICBT()">;
943 def HasPartwordAtomics : Predicate<"PPCSubTarget->hasPartwordAtomics()">;
944 def NoNaNsFPMath : Predicate<"TM.Options.NoNaNsFPMath">;
945 def NaNsFPMath : Predicate<"!TM.Options.NoNaNsFPMath">;
946 def HasBPERMD : Predicate<"PPCSubTarget->hasBPERMD()">;
947 def HasExtDiv : Predicate<"PPCSubTarget->hasExtDiv()">;
948 def IsISA3_0 : Predicate<"PPCSubTarget->isISA3_0()">;
949 def HasFPU : Predicate<"PPCSubTarget->hasFPU()">;
951 //===----------------------------------------------------------------------===//
952 // PowerPC Multiclass Definitions.
954 multiclass XForm_6r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
955 string asmbase, string asmstr, InstrItinClass itin,
957 let BaseName = asmbase in {
958 def NAME : XForm_6<opcode, xo, OOL, IOL,
959 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
960 pattern>, RecFormRel;
962 def o : XForm_6<opcode, xo, OOL, IOL,
963 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
964 []>, isDOT, RecFormRel;
968 multiclass XForm_6rc<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
969 string asmbase, string asmstr, InstrItinClass itin,
971 let BaseName = asmbase in {
972 let Defs = [CARRY] in
973 def NAME : XForm_6<opcode, xo, OOL, IOL,
974 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
975 pattern>, RecFormRel;
976 let Defs = [CARRY, CR0] in
977 def o : XForm_6<opcode, xo, OOL, IOL,
978 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
979 []>, isDOT, RecFormRel;
983 multiclass XForm_10rc<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
984 string asmbase, string asmstr, InstrItinClass itin,
986 let BaseName = asmbase in {
987 let Defs = [CARRY] in
988 def NAME : XForm_10<opcode, xo, OOL, IOL,
989 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
990 pattern>, RecFormRel;
991 let Defs = [CARRY, CR0] in
992 def o : XForm_10<opcode, xo, OOL, IOL,
993 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
994 []>, isDOT, RecFormRel;
998 multiclass XForm_11r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
999 string asmbase, string asmstr, InstrItinClass itin,
1000 list<dag> pattern> {
1001 let BaseName = asmbase in {
1002 def NAME : XForm_11<opcode, xo, OOL, IOL,
1003 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1004 pattern>, RecFormRel;
1006 def o : XForm_11<opcode, xo, OOL, IOL,
1007 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1008 []>, isDOT, RecFormRel;
1012 multiclass XOForm_1r<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
1013 string asmbase, string asmstr, InstrItinClass itin,
1014 list<dag> pattern> {
1015 let BaseName = asmbase in {
1016 def NAME : XOForm_1<opcode, xo, oe, OOL, IOL,
1017 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1018 pattern>, RecFormRel;
1020 def o : XOForm_1<opcode, xo, oe, OOL, IOL,
1021 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1022 []>, isDOT, RecFormRel;
1026 // Multiclass for instructions for which the non record form is not cracked
1027 // and the record form is cracked (i.e. divw, mullw, etc.)
1028 multiclass XOForm_1rcr<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
1029 string asmbase, string asmstr, InstrItinClass itin,
1030 list<dag> pattern> {
1031 let BaseName = asmbase in {
1032 def NAME : XOForm_1<opcode, xo, oe, OOL, IOL,
1033 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1034 pattern>, RecFormRel;
1036 def o : XOForm_1<opcode, xo, oe, OOL, IOL,
1037 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1038 []>, isDOT, RecFormRel, PPC970_DGroup_First,
1039 PPC970_DGroup_Cracked;
1043 multiclass XOForm_1rc<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
1044 string asmbase, string asmstr, InstrItinClass itin,
1045 list<dag> pattern> {
1046 let BaseName = asmbase in {
1047 let Defs = [CARRY] in
1048 def NAME : XOForm_1<opcode, xo, oe, OOL, IOL,
1049 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1050 pattern>, RecFormRel;
1051 let Defs = [CARRY, CR0] in
1052 def o : XOForm_1<opcode, xo, oe, OOL, IOL,
1053 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1054 []>, isDOT, RecFormRel;
1058 multiclass XOForm_3r<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
1059 string asmbase, string asmstr, InstrItinClass itin,
1060 list<dag> pattern> {
1061 let BaseName = asmbase in {
1062 def NAME : XOForm_3<opcode, xo, oe, OOL, IOL,
1063 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1064 pattern>, RecFormRel;
1066 def o : XOForm_3<opcode, xo, oe, OOL, IOL,
1067 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1068 []>, isDOT, RecFormRel;
1072 multiclass XOForm_3rc<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
1073 string asmbase, string asmstr, InstrItinClass itin,
1074 list<dag> pattern> {
1075 let BaseName = asmbase in {
1076 let Defs = [CARRY] in
1077 def NAME : XOForm_3<opcode, xo, oe, OOL, IOL,
1078 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1079 pattern>, RecFormRel;
1080 let Defs = [CARRY, CR0] in
1081 def o : XOForm_3<opcode, xo, oe, OOL, IOL,
1082 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1083 []>, isDOT, RecFormRel;
1087 multiclass MForm_2r<bits<6> opcode, dag OOL, dag IOL,
1088 string asmbase, string asmstr, InstrItinClass itin,
1089 list<dag> pattern> {
1090 let BaseName = asmbase in {
1091 def NAME : MForm_2<opcode, OOL, IOL,
1092 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1093 pattern>, RecFormRel;
1095 def o : MForm_2<opcode, OOL, IOL,
1096 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1097 []>, isDOT, RecFormRel;
1101 multiclass MDForm_1r<bits<6> opcode, bits<3> xo, dag OOL, dag IOL,
1102 string asmbase, string asmstr, InstrItinClass itin,
1103 list<dag> pattern> {
1104 let BaseName = asmbase in {
1105 def NAME : MDForm_1<opcode, xo, OOL, IOL,
1106 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1107 pattern>, RecFormRel;
1109 def o : MDForm_1<opcode, xo, OOL, IOL,
1110 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1111 []>, isDOT, RecFormRel;
1115 multiclass MDSForm_1r<bits<6> opcode, bits<4> xo, dag OOL, dag IOL,
1116 string asmbase, string asmstr, InstrItinClass itin,
1117 list<dag> pattern> {
1118 let BaseName = asmbase in {
1119 def NAME : MDSForm_1<opcode, xo, OOL, IOL,
1120 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1121 pattern>, RecFormRel;
1123 def o : MDSForm_1<opcode, xo, OOL, IOL,
1124 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1125 []>, isDOT, RecFormRel;
1129 multiclass XSForm_1rc<bits<6> opcode, bits<9> xo, dag OOL, dag IOL,
1130 string asmbase, string asmstr, InstrItinClass itin,
1131 list<dag> pattern> {
1132 let BaseName = asmbase in {
1133 let Defs = [CARRY] in
1134 def NAME : XSForm_1<opcode, xo, OOL, IOL,
1135 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1136 pattern>, RecFormRel;
1137 let Defs = [CARRY, CR0] in
1138 def o : XSForm_1<opcode, xo, OOL, IOL,
1139 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1140 []>, isDOT, RecFormRel;
1144 multiclass XSForm_1r<bits<6> opcode, bits<9> xo, dag OOL, dag IOL,
1145 string asmbase, string asmstr, InstrItinClass itin,
1146 list<dag> pattern> {
1147 let BaseName = asmbase in {
1148 def NAME : XSForm_1<opcode, xo, OOL, IOL,
1149 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1150 pattern>, RecFormRel;
1152 def o : XSForm_1<opcode, xo, OOL, IOL,
1153 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1154 []>, isDOT, RecFormRel;
1158 multiclass XForm_26r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
1159 string asmbase, string asmstr, InstrItinClass itin,
1160 list<dag> pattern> {
1161 let BaseName = asmbase in {
1162 def NAME : XForm_26<opcode, xo, OOL, IOL,
1163 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1164 pattern>, RecFormRel;
1166 def o : XForm_26<opcode, xo, OOL, IOL,
1167 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1168 []>, isDOT, RecFormRel;
1172 multiclass XForm_28r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
1173 string asmbase, string asmstr, InstrItinClass itin,
1174 list<dag> pattern> {
1175 let BaseName = asmbase in {
1176 def NAME : XForm_28<opcode, xo, OOL, IOL,
1177 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1178 pattern>, RecFormRel;
1180 def o : XForm_28<opcode, xo, OOL, IOL,
1181 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1182 []>, isDOT, RecFormRel;
1186 multiclass AForm_1r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL,
1187 string asmbase, string asmstr, InstrItinClass itin,
1188 list<dag> pattern> {
1189 let BaseName = asmbase in {
1190 def NAME : AForm_1<opcode, xo, OOL, IOL,
1191 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1192 pattern>, RecFormRel;
1194 def o : AForm_1<opcode, xo, OOL, IOL,
1195 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1196 []>, isDOT, RecFormRel;
1200 multiclass AForm_2r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL,
1201 string asmbase, string asmstr, InstrItinClass itin,
1202 list<dag> pattern> {
1203 let BaseName = asmbase in {
1204 def NAME : AForm_2<opcode, xo, OOL, IOL,
1205 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1206 pattern>, RecFormRel;
1208 def o : AForm_2<opcode, xo, OOL, IOL,
1209 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1210 []>, isDOT, RecFormRel;
1214 multiclass AForm_3r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL,
1215 string asmbase, string asmstr, InstrItinClass itin,
1216 list<dag> pattern> {
1217 let BaseName = asmbase in {
1218 def NAME : AForm_3<opcode, xo, OOL, IOL,
1219 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1220 pattern>, RecFormRel;
1222 def o : AForm_3<opcode, xo, OOL, IOL,
1223 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1224 []>, isDOT, RecFormRel;
1228 //===----------------------------------------------------------------------===//
1229 // PowerPC Instruction Definitions.
1231 // Pseudo instructions:
1233 let hasCtrlDep = 1 in {
1234 let Defs = [R1], Uses = [R1] in {
1235 def ADJCALLSTACKDOWN : PPCEmitTimePseudo<(outs), (ins u16imm:$amt1, u16imm:$amt2),
1236 "#ADJCALLSTACKDOWN $amt1 $amt2",
1237 [(callseq_start timm:$amt1, timm:$amt2)]>;
1238 def ADJCALLSTACKUP : PPCEmitTimePseudo<(outs), (ins u16imm:$amt1, u16imm:$amt2),
1239 "#ADJCALLSTACKUP $amt1 $amt2",
1240 [(callseq_end timm:$amt1, timm:$amt2)]>;
1243 def UPDATE_VRSAVE : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc:$rS),
1244 "UPDATE_VRSAVE $rD, $rS", []>;
1247 let Defs = [R1], Uses = [R1] in
1248 def DYNALLOC : PPCEmitTimePseudo<(outs gprc:$result), (ins gprc:$negsize, memri:$fpsi), "#DYNALLOC",
1250 (PPCdynalloc i32:$negsize, iaddr:$fpsi))]>;
1251 def DYNAREAOFFSET : PPCEmitTimePseudo<(outs i32imm:$result), (ins memri:$fpsi), "#DYNAREAOFFSET",
1252 [(set i32:$result, (PPCdynareaoffset iaddr:$fpsi))]>;
1254 // SELECT_CC_* - Used to implement the SELECT_CC DAG operation. Expanded after
1255 // instruction selection into a branch sequence.
1256 let PPC970_Single = 1 in {
1257 // Note that SELECT_CC_I4 and SELECT_CC_I8 use the no-r0 register classes
1258 // because either operand might become the first operand in an isel, and
1259 // that operand cannot be r0.
1260 def SELECT_CC_I4 : PPCCustomInserterPseudo<(outs gprc:$dst), (ins crrc:$cond,
1261 gprc_nor0:$T, gprc_nor0:$F,
1262 i32imm:$BROPC), "#SELECT_CC_I4",
1264 def SELECT_CC_I8 : PPCCustomInserterPseudo<(outs g8rc:$dst), (ins crrc:$cond,
1265 g8rc_nox0:$T, g8rc_nox0:$F,
1266 i32imm:$BROPC), "#SELECT_CC_I8",
1268 def SELECT_CC_F4 : PPCCustomInserterPseudo<(outs f4rc:$dst), (ins crrc:$cond, f4rc:$T, f4rc:$F,
1269 i32imm:$BROPC), "#SELECT_CC_F4",
1271 def SELECT_CC_F8 : PPCCustomInserterPseudo<(outs f8rc:$dst), (ins crrc:$cond, f8rc:$T, f8rc:$F,
1272 i32imm:$BROPC), "#SELECT_CC_F8",
1274 def SELECT_CC_F16 : PPCCustomInserterPseudo<(outs vrrc:$dst), (ins crrc:$cond, vrrc:$T, vrrc:$F,
1275 i32imm:$BROPC), "#SELECT_CC_F16",
1277 def SELECT_CC_VRRC: PPCCustomInserterPseudo<(outs vrrc:$dst), (ins crrc:$cond, vrrc:$T, vrrc:$F,
1278 i32imm:$BROPC), "#SELECT_CC_VRRC",
1281 // SELECT_* pseudo instructions, like SELECT_CC_* but taking condition
1282 // register bit directly.
1283 def SELECT_I4 : PPCCustomInserterPseudo<(outs gprc:$dst), (ins crbitrc:$cond,
1284 gprc_nor0:$T, gprc_nor0:$F), "#SELECT_I4",
1285 [(set i32:$dst, (select i1:$cond, i32:$T, i32:$F))]>;
1286 def SELECT_I8 : PPCCustomInserterPseudo<(outs g8rc:$dst), (ins crbitrc:$cond,
1287 g8rc_nox0:$T, g8rc_nox0:$F), "#SELECT_I8",
1288 [(set i64:$dst, (select i1:$cond, i64:$T, i64:$F))]>;
1289 let Predicates = [HasFPU] in {
1290 def SELECT_F4 : PPCCustomInserterPseudo<(outs f4rc:$dst), (ins crbitrc:$cond,
1291 f4rc:$T, f4rc:$F), "#SELECT_F4",
1292 [(set f32:$dst, (select i1:$cond, f32:$T, f32:$F))]>;
1293 def SELECT_F8 : PPCCustomInserterPseudo<(outs f8rc:$dst), (ins crbitrc:$cond,
1294 f8rc:$T, f8rc:$F), "#SELECT_F8",
1295 [(set f64:$dst, (select i1:$cond, f64:$T, f64:$F))]>;
1296 def SELECT_F16 : PPCCustomInserterPseudo<(outs vrrc:$dst), (ins crbitrc:$cond,
1297 vrrc:$T, vrrc:$F), "#SELECT_F16",
1298 [(set f128:$dst, (select i1:$cond, f128:$T, f128:$F))]>;
1300 def SELECT_VRRC: PPCCustomInserterPseudo<(outs vrrc:$dst), (ins crbitrc:$cond,
1301 vrrc:$T, vrrc:$F), "#SELECT_VRRC",
1303 (select i1:$cond, v4i32:$T, v4i32:$F))]>;
1306 // SPILL_CR - Indicate that we're dumping the CR register, so we'll need to
1307 // scavenge a register for it.
1308 let mayStore = 1 in {
1309 def SPILL_CR : PPCEmitTimePseudo<(outs), (ins crrc:$cond, memri:$F),
1311 def SPILL_CRBIT : PPCEmitTimePseudo<(outs), (ins crbitrc:$cond, memri:$F),
1312 "#SPILL_CRBIT", []>;
1315 // RESTORE_CR - Indicate that we're restoring the CR register (previously
1316 // spilled), so we'll need to scavenge a register for it.
1317 let mayLoad = 1 in {
1318 def RESTORE_CR : PPCEmitTimePseudo<(outs crrc:$cond), (ins memri:$F),
1320 def RESTORE_CRBIT : PPCEmitTimePseudo<(outs crbitrc:$cond), (ins memri:$F),
1321 "#RESTORE_CRBIT", []>;
1324 let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7 in {
1325 let isReturn = 1, Uses = [LR, RM] in
1326 def BLR : XLForm_2_ext<19, 16, 20, 0, 0, (outs), (ins), "blr", IIC_BrB,
1327 [(retflag)]>, Requires<[In32BitMode]>;
1328 let isBranch = 1, isIndirectBranch = 1, Uses = [CTR] in {
1329 def BCTR : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
1332 let isCodeGenOnly = 1 in {
1333 def BCCCTR : XLForm_2_br<19, 528, 0, (outs), (ins pred:$cond),
1334 "b${cond:cc}ctr${cond:pm} ${cond:reg}", IIC_BrB,
1337 def BCCTR : XLForm_2_br2<19, 528, 12, 0, (outs), (ins crbitrc:$bi),
1338 "bcctr 12, $bi, 0", IIC_BrB, []>;
1339 def BCCTRn : XLForm_2_br2<19, 528, 4, 0, (outs), (ins crbitrc:$bi),
1340 "bcctr 4, $bi, 0", IIC_BrB, []>;
1345 // Set the float rounding mode.
1346 let Uses = [RM], Defs = [RM] in {
1347 def SETRNDi : PPCCustomInserterPseudo<(outs f8rc:$FRT), (ins u2imm:$RND),
1348 "#SETRNDi", [(set f64:$FRT, (int_ppc_setrnd (i32 imm:$RND)))]>;
1350 def SETRND : PPCCustomInserterPseudo<(outs f8rc:$FRT), (ins gprc:$in),
1351 "#SETRND", [(set f64:$FRT, (int_ppc_setrnd gprc :$in))]>;
1355 def MovePCtoLR : PPCEmitTimePseudo<(outs), (ins), "#MovePCtoLR", []>,
1358 def MoveGOTtoLR : PPCEmitTimePseudo<(outs), (ins), "#MoveGOTtoLR", []>,
1361 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7 in {
1362 let isBarrier = 1 in {
1363 def B : IForm<18, 0, 0, (outs), (ins directbrtarget:$dst),
1366 def BA : IForm<18, 1, 0, (outs), (ins absdirectbrtarget:$dst),
1367 "ba $dst", IIC_BrB, []>;
1370 // BCC represents an arbitrary conditional branch on a predicate.
1371 // FIXME: should be able to write a pattern for PPCcondbranch, but can't use
1372 // a two-value operand where a dag node expects two operands. :(
1373 let isCodeGenOnly = 1 in {
1374 class BCC_class : BForm<16, 0, 0, (outs), (ins pred:$cond, condbrtarget:$dst),
1375 "b${cond:cc}${cond:pm} ${cond:reg}, $dst"
1376 /*[(PPCcondbranch crrc:$crS, imm:$opc, bb:$dst)]*/>;
1377 def BCC : BCC_class;
1379 // The same as BCC, except that it's not a terminator. Used for introducing
1380 // control flow dependency without creating new blocks.
1381 let isTerminator = 0 in def CTRL_DEP : BCC_class;
1383 def BCCA : BForm<16, 1, 0, (outs), (ins pred:$cond, abscondbrtarget:$dst),
1384 "b${cond:cc}a${cond:pm} ${cond:reg}, $dst">;
1386 let isReturn = 1, Uses = [LR, RM] in
1387 def BCCLR : XLForm_2_br<19, 16, 0, (outs), (ins pred:$cond),
1388 "b${cond:cc}lr${cond:pm} ${cond:reg}", IIC_BrB, []>;
1391 let isCodeGenOnly = 1 in {
1392 let Pattern = [(brcond i1:$bi, bb:$dst)] in
1393 def BC : BForm_4<16, 12, 0, 0, (outs), (ins crbitrc:$bi, condbrtarget:$dst),
1394 "bc 12, $bi, $dst">;
1396 let Pattern = [(brcond (not i1:$bi), bb:$dst)] in
1397 def BCn : BForm_4<16, 4, 0, 0, (outs), (ins crbitrc:$bi, condbrtarget:$dst),
1400 let isReturn = 1, Uses = [LR, RM] in
1401 def BCLR : XLForm_2_br2<19, 16, 12, 0, (outs), (ins crbitrc:$bi),
1402 "bclr 12, $bi, 0", IIC_BrB, []>;
1403 def BCLRn : XLForm_2_br2<19, 16, 4, 0, (outs), (ins crbitrc:$bi),
1404 "bclr 4, $bi, 0", IIC_BrB, []>;
1407 let isReturn = 1, Defs = [CTR], Uses = [CTR, LR, RM] in {
1408 def BDZLR : XLForm_2_ext<19, 16, 18, 0, 0, (outs), (ins),
1409 "bdzlr", IIC_BrB, []>;
1410 def BDNZLR : XLForm_2_ext<19, 16, 16, 0, 0, (outs), (ins),
1411 "bdnzlr", IIC_BrB, []>;
1412 def BDZLRp : XLForm_2_ext<19, 16, 27, 0, 0, (outs), (ins),
1413 "bdzlr+", IIC_BrB, []>;
1414 def BDNZLRp: XLForm_2_ext<19, 16, 25, 0, 0, (outs), (ins),
1415 "bdnzlr+", IIC_BrB, []>;
1416 def BDZLRm : XLForm_2_ext<19, 16, 26, 0, 0, (outs), (ins),
1417 "bdzlr-", IIC_BrB, []>;
1418 def BDNZLRm: XLForm_2_ext<19, 16, 24, 0, 0, (outs), (ins),
1419 "bdnzlr-", IIC_BrB, []>;
1422 let Defs = [CTR], Uses = [CTR] in {
1423 def BDZ : BForm_1<16, 18, 0, 0, (outs), (ins condbrtarget:$dst),
1425 def BDNZ : BForm_1<16, 16, 0, 0, (outs), (ins condbrtarget:$dst),
1427 def BDZA : BForm_1<16, 18, 1, 0, (outs), (ins abscondbrtarget:$dst),
1429 def BDNZA : BForm_1<16, 16, 1, 0, (outs), (ins abscondbrtarget:$dst),
1431 def BDZp : BForm_1<16, 27, 0, 0, (outs), (ins condbrtarget:$dst),
1433 def BDNZp: BForm_1<16, 25, 0, 0, (outs), (ins condbrtarget:$dst),
1435 def BDZAp : BForm_1<16, 27, 1, 0, (outs), (ins abscondbrtarget:$dst),
1437 def BDNZAp: BForm_1<16, 25, 1, 0, (outs), (ins abscondbrtarget:$dst),
1439 def BDZm : BForm_1<16, 26, 0, 0, (outs), (ins condbrtarget:$dst),
1441 def BDNZm: BForm_1<16, 24, 0, 0, (outs), (ins condbrtarget:$dst),
1443 def BDZAm : BForm_1<16, 26, 1, 0, (outs), (ins abscondbrtarget:$dst),
1445 def BDNZAm: BForm_1<16, 24, 1, 0, (outs), (ins abscondbrtarget:$dst),
1450 // The unconditional BCL used by the SjLj setjmp code.
1451 let isCall = 1, hasCtrlDep = 1, isCodeGenOnly = 1, PPC970_Unit = 7 in {
1452 let Defs = [LR], Uses = [RM] in {
1453 def BCLalways : BForm_2<16, 20, 31, 0, 1, (outs), (ins condbrtarget:$dst),
1454 "bcl 20, 31, $dst">;
1458 let isCall = 1, PPC970_Unit = 7, Defs = [LR] in {
1459 // Convenient aliases for call instructions
1460 let Uses = [RM] in {
1461 def BL : IForm<18, 0, 1, (outs), (ins calltarget:$func),
1462 "bl $func", IIC_BrB, []>; // See Pat patterns below.
1463 def BLA : IForm<18, 1, 1, (outs), (ins abscalltarget:$func),
1464 "bla $func", IIC_BrB, [(PPCcall (i32 imm:$func))]>;
1466 let isCodeGenOnly = 1 in {
1467 def BL_TLS : IForm<18, 0, 1, (outs), (ins tlscall32:$func),
1468 "bl $func", IIC_BrB, []>;
1469 def BCCL : BForm<16, 0, 1, (outs), (ins pred:$cond, condbrtarget:$dst),
1470 "b${cond:cc}l${cond:pm} ${cond:reg}, $dst">;
1471 def BCCLA : BForm<16, 1, 1, (outs), (ins pred:$cond, abscondbrtarget:$dst),
1472 "b${cond:cc}la${cond:pm} ${cond:reg}, $dst">;
1474 def BCL : BForm_4<16, 12, 0, 1, (outs),
1475 (ins crbitrc:$bi, condbrtarget:$dst),
1476 "bcl 12, $bi, $dst">;
1477 def BCLn : BForm_4<16, 4, 0, 1, (outs),
1478 (ins crbitrc:$bi, condbrtarget:$dst),
1479 "bcl 4, $bi, $dst">;
1480 def BL_NOP : IForm_and_DForm_4_zero<18, 0, 1, 24,
1481 (outs), (ins calltarget:$func),
1482 "bl $func\n\tnop", IIC_BrB, []>;
1485 let Uses = [CTR, RM] in {
1486 def BCTRL : XLForm_2_ext<19, 528, 20, 0, 1, (outs), (ins),
1487 "bctrl", IIC_BrB, [(PPCbctrl)]>,
1488 Requires<[In32BitMode]>;
1490 let isCodeGenOnly = 1 in {
1491 def BCCCTRL : XLForm_2_br<19, 528, 1, (outs), (ins pred:$cond),
1492 "b${cond:cc}ctrl${cond:pm} ${cond:reg}", IIC_BrB,
1495 def BCCTRL : XLForm_2_br2<19, 528, 12, 1, (outs), (ins crbitrc:$bi),
1496 "bcctrl 12, $bi, 0", IIC_BrB, []>;
1497 def BCCTRLn : XLForm_2_br2<19, 528, 4, 1, (outs), (ins crbitrc:$bi),
1498 "bcctrl 4, $bi, 0", IIC_BrB, []>;
1501 let Uses = [LR, RM] in {
1502 def BLRL : XLForm_2_ext<19, 16, 20, 0, 1, (outs), (ins),
1503 "blrl", IIC_BrB, []>;
1505 let isCodeGenOnly = 1 in {
1506 def BCCLRL : XLForm_2_br<19, 16, 1, (outs), (ins pred:$cond),
1507 "b${cond:cc}lrl${cond:pm} ${cond:reg}", IIC_BrB,
1510 def BCLRL : XLForm_2_br2<19, 16, 12, 1, (outs), (ins crbitrc:$bi),
1511 "bclrl 12, $bi, 0", IIC_BrB, []>;
1512 def BCLRLn : XLForm_2_br2<19, 16, 4, 1, (outs), (ins crbitrc:$bi),
1513 "bclrl 4, $bi, 0", IIC_BrB, []>;
1516 let Defs = [CTR], Uses = [CTR, RM] in {
1517 def BDZL : BForm_1<16, 18, 0, 1, (outs), (ins condbrtarget:$dst),
1519 def BDNZL : BForm_1<16, 16, 0, 1, (outs), (ins condbrtarget:$dst),
1521 def BDZLA : BForm_1<16, 18, 1, 1, (outs), (ins abscondbrtarget:$dst),
1523 def BDNZLA : BForm_1<16, 16, 1, 1, (outs), (ins abscondbrtarget:$dst),
1525 def BDZLp : BForm_1<16, 27, 0, 1, (outs), (ins condbrtarget:$dst),
1527 def BDNZLp: BForm_1<16, 25, 0, 1, (outs), (ins condbrtarget:$dst),
1529 def BDZLAp : BForm_1<16, 27, 1, 1, (outs), (ins abscondbrtarget:$dst),
1531 def BDNZLAp: BForm_1<16, 25, 1, 1, (outs), (ins abscondbrtarget:$dst),
1533 def BDZLm : BForm_1<16, 26, 0, 1, (outs), (ins condbrtarget:$dst),
1535 def BDNZLm: BForm_1<16, 24, 0, 1, (outs), (ins condbrtarget:$dst),
1537 def BDZLAm : BForm_1<16, 26, 1, 1, (outs), (ins abscondbrtarget:$dst),
1539 def BDNZLAm: BForm_1<16, 24, 1, 1, (outs), (ins abscondbrtarget:$dst),
1542 let Defs = [CTR], Uses = [CTR, LR, RM] in {
1543 def BDZLRL : XLForm_2_ext<19, 16, 18, 0, 1, (outs), (ins),
1544 "bdzlrl", IIC_BrB, []>;
1545 def BDNZLRL : XLForm_2_ext<19, 16, 16, 0, 1, (outs), (ins),
1546 "bdnzlrl", IIC_BrB, []>;
1547 def BDZLRLp : XLForm_2_ext<19, 16, 27, 0, 1, (outs), (ins),
1548 "bdzlrl+", IIC_BrB, []>;
1549 def BDNZLRLp: XLForm_2_ext<19, 16, 25, 0, 1, (outs), (ins),
1550 "bdnzlrl+", IIC_BrB, []>;
1551 def BDZLRLm : XLForm_2_ext<19, 16, 26, 0, 1, (outs), (ins),
1552 "bdzlrl-", IIC_BrB, []>;
1553 def BDNZLRLm: XLForm_2_ext<19, 16, 24, 0, 1, (outs), (ins),
1554 "bdnzlrl-", IIC_BrB, []>;
1558 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
1559 def TCRETURNdi :PPCEmitTimePseudo< (outs),
1560 (ins calltarget:$dst, i32imm:$offset),
1561 "#TC_RETURNd $dst $offset",
1565 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
1566 def TCRETURNai :PPCEmitTimePseudo<(outs), (ins abscalltarget:$func, i32imm:$offset),
1567 "#TC_RETURNa $func $offset",
1568 [(PPCtc_return (i32 imm:$func), imm:$offset)]>;
1570 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
1571 def TCRETURNri : PPCEmitTimePseudo<(outs), (ins CTRRC:$dst, i32imm:$offset),
1572 "#TC_RETURNr $dst $offset",
1576 let isCodeGenOnly = 1 in {
1578 let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, isBranch = 1,
1579 isIndirectBranch = 1, isCall = 1, isReturn = 1, Uses = [CTR, RM] in
1580 def TAILBCTR : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
1581 []>, Requires<[In32BitMode]>;
1583 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
1584 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
1585 def TAILB : IForm<18, 0, 0, (outs), (ins calltarget:$dst),
1589 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
1590 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
1591 def TAILBA : IForm<18, 0, 0, (outs), (ins abscalltarget:$dst),
1597 // While longjmp is a control-flow barrier (fallthrough isn't allowed), setjmp
1599 let hasSideEffects = 1 in {
1601 def EH_SjLj_SetJmp32 : PPCCustomInserterPseudo<(outs gprc:$dst), (ins memr:$buf),
1602 "#EH_SJLJ_SETJMP32",
1603 [(set i32:$dst, (PPCeh_sjlj_setjmp addr:$buf))]>,
1604 Requires<[In32BitMode]>;
1607 let hasSideEffects = 1, isBarrier = 1 in {
1608 let isTerminator = 1 in
1609 def EH_SjLj_LongJmp32 : PPCCustomInserterPseudo<(outs), (ins memr:$buf),
1610 "#EH_SJLJ_LONGJMP32",
1611 [(PPCeh_sjlj_longjmp addr:$buf)]>,
1612 Requires<[In32BitMode]>;
1615 // This pseudo is never removed from the function, as it serves as
1616 // a terminator. Size is set to 0 to prevent the builtin assembler
1617 // from emitting it.
1618 let isBranch = 1, isTerminator = 1, Size = 0 in {
1619 def EH_SjLj_Setup : PPCEmitTimePseudo<(outs), (ins directbrtarget:$dst),
1620 "#EH_SjLj_Setup\t$dst", []>;
1624 let PPC970_Unit = 7 in {
1625 def SC : SCForm<17, 1, (outs), (ins i32imm:$lev),
1626 "sc $lev", IIC_BrB, [(PPCsc (i32 imm:$lev))]>;
1629 // Branch history rolling buffer.
1630 def CLRBHRB : XForm_0<31, 430, (outs), (ins), "clrbhrb", IIC_BrB,
1632 PPC970_DGroup_Single;
1633 // The $dmy argument used for MFBHRBE is not needed; however, including
1634 // it avoids automatic generation of PPCFastISel::fastEmit_i(), which
1635 // interferes with necessary special handling (see PPCFastISel.cpp).
1636 def MFBHRBE : XFXForm_3p<31, 302, (outs gprc:$rD),
1637 (ins u10imm:$imm, u10imm:$dmy),
1638 "mfbhrbe $rD, $imm", IIC_BrB,
1640 (PPCmfbhrbe imm:$imm, imm:$dmy))]>,
1641 PPC970_DGroup_First;
1643 def RFEBB : XLForm_S<19, 146, (outs), (ins u1imm:$imm), "rfebb $imm",
1644 IIC_BrB, [(PPCrfebb (i32 imm:$imm))]>,
1645 PPC970_DGroup_Single;
1647 // DCB* instructions.
1648 def DCBA : DCB_Form<758, 0, (outs), (ins memrr:$dst), "dcba $dst",
1649 IIC_LdStDCBF, [(int_ppc_dcba xoaddr:$dst)]>,
1650 PPC970_DGroup_Single;
1651 def DCBI : DCB_Form<470, 0, (outs), (ins memrr:$dst), "dcbi $dst",
1652 IIC_LdStDCBF, [(int_ppc_dcbi xoaddr:$dst)]>,
1653 PPC970_DGroup_Single;
1654 def DCBST : DCB_Form<54, 0, (outs), (ins memrr:$dst), "dcbst $dst",
1655 IIC_LdStDCBF, [(int_ppc_dcbst xoaddr:$dst)]>,
1656 PPC970_DGroup_Single;
1657 def DCBZ : DCB_Form<1014, 0, (outs), (ins memrr:$dst), "dcbz $dst",
1658 IIC_LdStDCBF, [(int_ppc_dcbz xoaddr:$dst)]>,
1659 PPC970_DGroup_Single;
1660 def DCBZL : DCB_Form<1014, 1, (outs), (ins memrr:$dst), "dcbzl $dst",
1661 IIC_LdStDCBF, [(int_ppc_dcbzl xoaddr:$dst)]>,
1662 PPC970_DGroup_Single;
1664 def DCBF : DCB_Form_hint<86, (outs), (ins u5imm:$TH, memrr:$dst),
1665 "dcbf $dst, $TH", IIC_LdStDCBF, []>,
1666 PPC970_DGroup_Single;
1668 let hasSideEffects = 0, mayLoad = 1, mayStore = 1 in {
1669 def DCBT : DCB_Form_hint<278, (outs), (ins u5imm:$TH, memrr:$dst),
1670 "dcbt $dst, $TH", IIC_LdStDCBF, []>,
1671 PPC970_DGroup_Single;
1672 def DCBTST : DCB_Form_hint<246, (outs), (ins u5imm:$TH, memrr:$dst),
1673 "dcbtst $dst, $TH", IIC_LdStDCBF, []>,
1674 PPC970_DGroup_Single;
1675 } // hasSideEffects = 0
1677 def ICBLC : XForm_icbt<31, 230, (outs), (ins u4imm:$CT, memrr:$src),
1678 "icblc $CT, $src", IIC_LdStStore>, Requires<[HasICBT]>;
1679 def ICBLQ : XForm_icbt<31, 198, (outs), (ins u4imm:$CT, memrr:$src),
1680 "icblq. $CT, $src", IIC_LdStLoad>, Requires<[HasICBT]>;
1681 def ICBT : XForm_icbt<31, 22, (outs), (ins u4imm:$CT, memrr:$src),
1682 "icbt $CT, $src", IIC_LdStLoad>, Requires<[HasICBT]>;
1683 def ICBTLS : XForm_icbt<31, 486, (outs), (ins u4imm:$CT, memrr:$src),
1684 "icbtls $CT, $src", IIC_LdStLoad>, Requires<[HasICBT]>;
1686 def : Pat<(int_ppc_dcbt xoaddr:$dst),
1687 (DCBT 0, xoaddr:$dst)>;
1688 def : Pat<(int_ppc_dcbtst xoaddr:$dst),
1689 (DCBTST 0, xoaddr:$dst)>;
1690 def : Pat<(int_ppc_dcbf xoaddr:$dst),
1691 (DCBF 0, xoaddr:$dst)>;
1693 def : Pat<(prefetch xoaddr:$dst, (i32 0), imm, (i32 1)),
1694 (DCBT 0, xoaddr:$dst)>; // data prefetch for loads
1695 def : Pat<(prefetch xoaddr:$dst, (i32 1), imm, (i32 1)),
1696 (DCBTST 0, xoaddr:$dst)>; // data prefetch for stores
1697 def : Pat<(prefetch xoaddr:$dst, (i32 0), imm, (i32 0)),
1698 (ICBT 0, xoaddr:$dst)>, Requires<[HasICBT]>; // inst prefetch (for read)
1700 // Atomic operations
1701 // FIXME: some of these might be used with constant operands. This will result
1702 // in constant materialization instructions that may be redundant. We currently
1703 // clean this up in PPCMIPeephole with calls to
1704 // PPCInstrInfo::convertToImmediateForm() but we should probably not emit them
1705 // in the first place.
1706 let Defs = [CR0] in {
1707 def ATOMIC_LOAD_ADD_I8 : PPCCustomInserterPseudo<
1708 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I8",
1709 [(set i32:$dst, (atomic_load_add_8 xoaddr:$ptr, i32:$incr))]>;
1710 def ATOMIC_LOAD_SUB_I8 : PPCCustomInserterPseudo<
1711 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I8",
1712 [(set i32:$dst, (atomic_load_sub_8 xoaddr:$ptr, i32:$incr))]>;
1713 def ATOMIC_LOAD_AND_I8 : PPCCustomInserterPseudo<
1714 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I8",
1715 [(set i32:$dst, (atomic_load_and_8 xoaddr:$ptr, i32:$incr))]>;
1716 def ATOMIC_LOAD_OR_I8 : PPCCustomInserterPseudo<
1717 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I8",
1718 [(set i32:$dst, (atomic_load_or_8 xoaddr:$ptr, i32:$incr))]>;
1719 def ATOMIC_LOAD_XOR_I8 : PPCCustomInserterPseudo<
1720 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "ATOMIC_LOAD_XOR_I8",
1721 [(set i32:$dst, (atomic_load_xor_8 xoaddr:$ptr, i32:$incr))]>;
1722 def ATOMIC_LOAD_NAND_I8 : PPCCustomInserterPseudo<
1723 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I8",
1724 [(set i32:$dst, (atomic_load_nand_8 xoaddr:$ptr, i32:$incr))]>;
1725 def ATOMIC_LOAD_MIN_I8 : PPCCustomInserterPseudo<
1726 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MIN_I8",
1727 [(set i32:$dst, (atomic_load_min_8 xoaddr:$ptr, i32:$incr))]>;
1728 def ATOMIC_LOAD_MAX_I8 : PPCCustomInserterPseudo<
1729 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MAX_I8",
1730 [(set i32:$dst, (atomic_load_max_8 xoaddr:$ptr, i32:$incr))]>;
1731 def ATOMIC_LOAD_UMIN_I8 : PPCCustomInserterPseudo<
1732 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMIN_I8",
1733 [(set i32:$dst, (atomic_load_umin_8 xoaddr:$ptr, i32:$incr))]>;
1734 def ATOMIC_LOAD_UMAX_I8 : PPCCustomInserterPseudo<
1735 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMAX_I8",
1736 [(set i32:$dst, (atomic_load_umax_8 xoaddr:$ptr, i32:$incr))]>;
1737 def ATOMIC_LOAD_ADD_I16 : PPCCustomInserterPseudo<
1738 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I16",
1739 [(set i32:$dst, (atomic_load_add_16 xoaddr:$ptr, i32:$incr))]>;
1740 def ATOMIC_LOAD_SUB_I16 : PPCCustomInserterPseudo<
1741 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I16",
1742 [(set i32:$dst, (atomic_load_sub_16 xoaddr:$ptr, i32:$incr))]>;
1743 def ATOMIC_LOAD_AND_I16 : PPCCustomInserterPseudo<
1744 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I16",
1745 [(set i32:$dst, (atomic_load_and_16 xoaddr:$ptr, i32:$incr))]>;
1746 def ATOMIC_LOAD_OR_I16 : PPCCustomInserterPseudo<
1747 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I16",
1748 [(set i32:$dst, (atomic_load_or_16 xoaddr:$ptr, i32:$incr))]>;
1749 def ATOMIC_LOAD_XOR_I16 : PPCCustomInserterPseudo<
1750 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_XOR_I16",
1751 [(set i32:$dst, (atomic_load_xor_16 xoaddr:$ptr, i32:$incr))]>;
1752 def ATOMIC_LOAD_NAND_I16 : PPCCustomInserterPseudo<
1753 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I16",
1754 [(set i32:$dst, (atomic_load_nand_16 xoaddr:$ptr, i32:$incr))]>;
1755 def ATOMIC_LOAD_MIN_I16 : PPCCustomInserterPseudo<
1756 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MIN_I16",
1757 [(set i32:$dst, (atomic_load_min_16 xoaddr:$ptr, i32:$incr))]>;
1758 def ATOMIC_LOAD_MAX_I16 : PPCCustomInserterPseudo<
1759 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MAX_I16",
1760 [(set i32:$dst, (atomic_load_max_16 xoaddr:$ptr, i32:$incr))]>;
1761 def ATOMIC_LOAD_UMIN_I16 : PPCCustomInserterPseudo<
1762 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMIN_I16",
1763 [(set i32:$dst, (atomic_load_umin_16 xoaddr:$ptr, i32:$incr))]>;
1764 def ATOMIC_LOAD_UMAX_I16 : PPCCustomInserterPseudo<
1765 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMAX_I16",
1766 [(set i32:$dst, (atomic_load_umax_16 xoaddr:$ptr, i32:$incr))]>;
1767 def ATOMIC_LOAD_ADD_I32 : PPCCustomInserterPseudo<
1768 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I32",
1769 [(set i32:$dst, (atomic_load_add_32 xoaddr:$ptr, i32:$incr))]>;
1770 def ATOMIC_LOAD_SUB_I32 : PPCCustomInserterPseudo<
1771 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I32",
1772 [(set i32:$dst, (atomic_load_sub_32 xoaddr:$ptr, i32:$incr))]>;
1773 def ATOMIC_LOAD_AND_I32 : PPCCustomInserterPseudo<
1774 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I32",
1775 [(set i32:$dst, (atomic_load_and_32 xoaddr:$ptr, i32:$incr))]>;
1776 def ATOMIC_LOAD_OR_I32 : PPCCustomInserterPseudo<
1777 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I32",
1778 [(set i32:$dst, (atomic_load_or_32 xoaddr:$ptr, i32:$incr))]>;
1779 def ATOMIC_LOAD_XOR_I32 : PPCCustomInserterPseudo<
1780 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_XOR_I32",
1781 [(set i32:$dst, (atomic_load_xor_32 xoaddr:$ptr, i32:$incr))]>;
1782 def ATOMIC_LOAD_NAND_I32 : PPCCustomInserterPseudo<
1783 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I32",
1784 [(set i32:$dst, (atomic_load_nand_32 xoaddr:$ptr, i32:$incr))]>;
1785 def ATOMIC_LOAD_MIN_I32 : PPCCustomInserterPseudo<
1786 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MIN_I32",
1787 [(set i32:$dst, (atomic_load_min_32 xoaddr:$ptr, i32:$incr))]>;
1788 def ATOMIC_LOAD_MAX_I32 : PPCCustomInserterPseudo<
1789 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MAX_I32",
1790 [(set i32:$dst, (atomic_load_max_32 xoaddr:$ptr, i32:$incr))]>;
1791 def ATOMIC_LOAD_UMIN_I32 : PPCCustomInserterPseudo<
1792 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMIN_I32",
1793 [(set i32:$dst, (atomic_load_umin_32 xoaddr:$ptr, i32:$incr))]>;
1794 def ATOMIC_LOAD_UMAX_I32 : PPCCustomInserterPseudo<
1795 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMAX_I32",
1796 [(set i32:$dst, (atomic_load_umax_32 xoaddr:$ptr, i32:$incr))]>;
1798 def ATOMIC_CMP_SWAP_I8 : PPCCustomInserterPseudo<
1799 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I8",
1800 [(set i32:$dst, (atomic_cmp_swap_8 xoaddr:$ptr, i32:$old, i32:$new))]>;
1801 def ATOMIC_CMP_SWAP_I16 : PPCCustomInserterPseudo<
1802 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I16 $dst $ptr $old $new",
1803 [(set i32:$dst, (atomic_cmp_swap_16 xoaddr:$ptr, i32:$old, i32:$new))]>;
1804 def ATOMIC_CMP_SWAP_I32 : PPCCustomInserterPseudo<
1805 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I32 $dst $ptr $old $new",
1806 [(set i32:$dst, (atomic_cmp_swap_32 xoaddr:$ptr, i32:$old, i32:$new))]>;
1808 def ATOMIC_SWAP_I8 : PPCCustomInserterPseudo<
1809 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_i8",
1810 [(set i32:$dst, (atomic_swap_8 xoaddr:$ptr, i32:$new))]>;
1811 def ATOMIC_SWAP_I16 : PPCCustomInserterPseudo<
1812 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_I16",
1813 [(set i32:$dst, (atomic_swap_16 xoaddr:$ptr, i32:$new))]>;
1814 def ATOMIC_SWAP_I32 : PPCCustomInserterPseudo<
1815 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_I32",
1816 [(set i32:$dst, (atomic_swap_32 xoaddr:$ptr, i32:$new))]>;
1819 def : Pat<(PPCatomicCmpSwap_8 xoaddr:$ptr, i32:$old, i32:$new),
1820 (ATOMIC_CMP_SWAP_I8 xoaddr:$ptr, i32:$old, i32:$new)>;
1821 def : Pat<(PPCatomicCmpSwap_16 xoaddr:$ptr, i32:$old, i32:$new),
1822 (ATOMIC_CMP_SWAP_I16 xoaddr:$ptr, i32:$old, i32:$new)>;
1824 // Instructions to support atomic operations
1825 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in {
1826 def LBARX : XForm_1_memOp<31, 52, (outs gprc:$rD), (ins memrr:$src),
1827 "lbarx $rD, $src", IIC_LdStLWARX, []>,
1828 Requires<[HasPartwordAtomics]>;
1830 def LHARX : XForm_1_memOp<31, 116, (outs gprc:$rD), (ins memrr:$src),
1831 "lharx $rD, $src", IIC_LdStLWARX, []>,
1832 Requires<[HasPartwordAtomics]>;
1834 def LWARX : XForm_1_memOp<31, 20, (outs gprc:$rD), (ins memrr:$src),
1835 "lwarx $rD, $src", IIC_LdStLWARX, []>;
1837 // Instructions to support lock versions of atomics
1838 // (EH=1 - see Power ISA 2.07 Book II 4.4.2)
1839 def LBARXL : XForm_1_memOp<31, 52, (outs gprc:$rD), (ins memrr:$src),
1840 "lbarx $rD, $src, 1", IIC_LdStLWARX, []>, isDOT,
1841 Requires<[HasPartwordAtomics]>;
1843 def LHARXL : XForm_1_memOp<31, 116, (outs gprc:$rD), (ins memrr:$src),
1844 "lharx $rD, $src, 1", IIC_LdStLWARX, []>, isDOT,
1845 Requires<[HasPartwordAtomics]>;
1847 def LWARXL : XForm_1_memOp<31, 20, (outs gprc:$rD), (ins memrr:$src),
1848 "lwarx $rD, $src, 1", IIC_LdStLWARX, []>, isDOT;
1850 // The atomic instructions use the destination register as well as the next one
1851 // or two registers in order (modulo 31).
1852 let hasExtraSrcRegAllocReq = 1 in
1853 def LWAT : X_RD5_RS5_IM5<31, 582, (outs gprc:$rD), (ins gprc:$rA, u5imm:$FC),
1854 "lwat $rD, $rA, $FC", IIC_LdStLoad>,
1855 Requires<[IsISA3_0]>;
1858 let Defs = [CR0], mayStore = 1, mayLoad = 0, hasSideEffects = 0 in {
1859 def STBCX : XForm_1_memOp<31, 694, (outs), (ins gprc:$rS, memrr:$dst),
1860 "stbcx. $rS, $dst", IIC_LdStSTWCX, []>,
1861 isDOT, Requires<[HasPartwordAtomics]>;
1863 def STHCX : XForm_1_memOp<31, 726, (outs), (ins gprc:$rS, memrr:$dst),
1864 "sthcx. $rS, $dst", IIC_LdStSTWCX, []>,
1865 isDOT, Requires<[HasPartwordAtomics]>;
1867 def STWCX : XForm_1_memOp<31, 150, (outs), (ins gprc:$rS, memrr:$dst),
1868 "stwcx. $rS, $dst", IIC_LdStSTWCX, []>, isDOT;
1871 let mayStore = 1, mayLoad = 0, hasSideEffects = 0 in
1872 def STWAT : X_RD5_RS5_IM5<31, 710, (outs), (ins gprc:$rS, gprc:$rA, u5imm:$FC),
1873 "stwat $rS, $rA, $FC", IIC_LdStStore>,
1874 Requires<[IsISA3_0]>;
1876 let isTerminator = 1, isBarrier = 1, hasCtrlDep = 1 in
1877 def TRAP : XForm_24<31, 4, (outs), (ins), "trap", IIC_LdStLoad, [(trap)]>;
1879 def TWI : DForm_base<3, (outs), (ins u5imm:$to, gprc:$rA, s16imm:$imm),
1880 "twi $to, $rA, $imm", IIC_IntTrapW, []>;
1881 def TW : XForm_1<31, 4, (outs), (ins u5imm:$to, gprc:$rA, gprc:$rB),
1882 "tw $to, $rA, $rB", IIC_IntTrapW, []>;
1883 def TDI : DForm_base<2, (outs), (ins u5imm:$to, g8rc:$rA, s16imm:$imm),
1884 "tdi $to, $rA, $imm", IIC_IntTrapD, []>;
1885 def TD : XForm_1<31, 68, (outs), (ins u5imm:$to, g8rc:$rA, g8rc:$rB),
1886 "td $to, $rA, $rB", IIC_IntTrapD, []>;
1888 //===----------------------------------------------------------------------===//
1889 // PPC32 Load Instructions.
1892 // Unindexed (r+i) Loads.
1893 let PPC970_Unit = 2 in {
1894 def LBZ : DForm_1<34, (outs gprc:$rD), (ins memri:$src),
1895 "lbz $rD, $src", IIC_LdStLoad,
1896 [(set i32:$rD, (zextloadi8 iaddr:$src))]>;
1897 def LHA : DForm_1<42, (outs gprc:$rD), (ins memri:$src),
1898 "lha $rD, $src", IIC_LdStLHA,
1899 [(set i32:$rD, (sextloadi16 iaddr:$src))]>,
1900 PPC970_DGroup_Cracked;
1901 def LHZ : DForm_1<40, (outs gprc:$rD), (ins memri:$src),
1902 "lhz $rD, $src", IIC_LdStLoad,
1903 [(set i32:$rD, (zextloadi16 iaddr:$src))]>;
1904 def LWZ : DForm_1<32, (outs gprc:$rD), (ins memri:$src),
1905 "lwz $rD, $src", IIC_LdStLoad,
1906 [(set i32:$rD, (load iaddr:$src))]>;
1908 let Predicates = [HasFPU] in {
1909 def LFS : DForm_1<48, (outs f4rc:$rD), (ins memri:$src),
1910 "lfs $rD, $src", IIC_LdStLFD,
1911 [(set f32:$rD, (load iaddr:$src))]>;
1912 def LFD : DForm_1<50, (outs f8rc:$rD), (ins memri:$src),
1913 "lfd $rD, $src", IIC_LdStLFD,
1914 [(set f64:$rD, (load iaddr:$src))]>;
1918 // Unindexed (r+i) Loads with Update (preinc).
1919 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in {
1920 def LBZU : DForm_1<35, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1921 "lbzu $rD, $addr", IIC_LdStLoadUpd,
1922 []>, RegConstraint<"$addr.reg = $ea_result">,
1923 NoEncode<"$ea_result">;
1925 def LHAU : DForm_1<43, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1926 "lhau $rD, $addr", IIC_LdStLHAU,
1927 []>, RegConstraint<"$addr.reg = $ea_result">,
1928 NoEncode<"$ea_result">;
1930 def LHZU : DForm_1<41, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1931 "lhzu $rD, $addr", IIC_LdStLoadUpd,
1932 []>, RegConstraint<"$addr.reg = $ea_result">,
1933 NoEncode<"$ea_result">;
1935 def LWZU : DForm_1<33, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1936 "lwzu $rD, $addr", IIC_LdStLoadUpd,
1937 []>, RegConstraint<"$addr.reg = $ea_result">,
1938 NoEncode<"$ea_result">;
1940 let Predicates = [HasFPU] in {
1941 def LFSU : DForm_1<49, (outs f4rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1942 "lfsu $rD, $addr", IIC_LdStLFDU,
1943 []>, RegConstraint<"$addr.reg = $ea_result">,
1944 NoEncode<"$ea_result">;
1946 def LFDU : DForm_1<51, (outs f8rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1947 "lfdu $rD, $addr", IIC_LdStLFDU,
1948 []>, RegConstraint<"$addr.reg = $ea_result">,
1949 NoEncode<"$ea_result">;
1953 // Indexed (r+r) Loads with Update (preinc).
1954 def LBZUX : XForm_1_memOp<31, 119, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1956 "lbzux $rD, $addr", IIC_LdStLoadUpdX,
1957 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1958 NoEncode<"$ea_result">;
1960 def LHAUX : XForm_1_memOp<31, 375, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1962 "lhaux $rD, $addr", IIC_LdStLHAUX,
1963 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1964 NoEncode<"$ea_result">;
1966 def LHZUX : XForm_1_memOp<31, 311, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1968 "lhzux $rD, $addr", IIC_LdStLoadUpdX,
1969 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1970 NoEncode<"$ea_result">;
1972 def LWZUX : XForm_1_memOp<31, 55, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1974 "lwzux $rD, $addr", IIC_LdStLoadUpdX,
1975 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1976 NoEncode<"$ea_result">;
1978 let Predicates = [HasFPU] in {
1979 def LFSUX : XForm_1_memOp<31, 567, (outs f4rc:$rD, ptr_rc_nor0:$ea_result),
1981 "lfsux $rD, $addr", IIC_LdStLFDUX,
1982 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1983 NoEncode<"$ea_result">;
1985 def LFDUX : XForm_1_memOp<31, 631, (outs f8rc:$rD, ptr_rc_nor0:$ea_result),
1987 "lfdux $rD, $addr", IIC_LdStLFDUX,
1988 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1989 NoEncode<"$ea_result">;
1994 // Indexed (r+r) Loads.
1996 let PPC970_Unit = 2, mayLoad = 1, mayStore = 0 in {
1997 def LBZX : XForm_1_memOp<31, 87, (outs gprc:$rD), (ins memrr:$src),
1998 "lbzx $rD, $src", IIC_LdStLoad,
1999 [(set i32:$rD, (zextloadi8 xaddr:$src))]>;
2000 def LHAX : XForm_1_memOp<31, 343, (outs gprc:$rD), (ins memrr:$src),
2001 "lhax $rD, $src", IIC_LdStLHA,
2002 [(set i32:$rD, (sextloadi16 xaddr:$src))]>,
2003 PPC970_DGroup_Cracked;
2004 def LHZX : XForm_1_memOp<31, 279, (outs gprc:$rD), (ins memrr:$src),
2005 "lhzx $rD, $src", IIC_LdStLoad,
2006 [(set i32:$rD, (zextloadi16 xaddr:$src))]>;
2007 def LWZX : XForm_1_memOp<31, 23, (outs gprc:$rD), (ins memrr:$src),
2008 "lwzx $rD, $src", IIC_LdStLoad,
2009 [(set i32:$rD, (load xaddr:$src))]>;
2010 def LHBRX : XForm_1_memOp<31, 790, (outs gprc:$rD), (ins memrr:$src),
2011 "lhbrx $rD, $src", IIC_LdStLoad,
2012 [(set i32:$rD, (PPClbrx xoaddr:$src, i16))]>;
2013 def LWBRX : XForm_1_memOp<31, 534, (outs gprc:$rD), (ins memrr:$src),
2014 "lwbrx $rD, $src", IIC_LdStLoad,
2015 [(set i32:$rD, (PPClbrx xoaddr:$src, i32))]>;
2017 let Predicates = [HasFPU] in {
2018 def LFSX : XForm_25_memOp<31, 535, (outs f4rc:$frD), (ins memrr:$src),
2019 "lfsx $frD, $src", IIC_LdStLFD,
2020 [(set f32:$frD, (load xaddr:$src))]>;
2021 def LFDX : XForm_25_memOp<31, 599, (outs f8rc:$frD), (ins memrr:$src),
2022 "lfdx $frD, $src", IIC_LdStLFD,
2023 [(set f64:$frD, (load xaddr:$src))]>;
2025 def LFIWAX : XForm_25_memOp<31, 855, (outs f8rc:$frD), (ins memrr:$src),
2026 "lfiwax $frD, $src", IIC_LdStLFD,
2027 [(set f64:$frD, (PPClfiwax xoaddr:$src))]>;
2028 def LFIWZX : XForm_25_memOp<31, 887, (outs f8rc:$frD), (ins memrr:$src),
2029 "lfiwzx $frD, $src", IIC_LdStLFD,
2030 [(set f64:$frD, (PPClfiwzx xoaddr:$src))]>;
2035 def LMW : DForm_1<46, (outs gprc:$rD), (ins memri:$src),
2036 "lmw $rD, $src", IIC_LdStLMW, []>;
2038 //===----------------------------------------------------------------------===//
2039 // PPC32 Store Instructions.
2042 // Unindexed (r+i) Stores.
2043 let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in {
2044 def STB : DForm_1<38, (outs), (ins gprc:$rS, memri:$dst),
2045 "stb $rS, $dst", IIC_LdStStore,
2046 [(truncstorei8 i32:$rS, iaddr:$dst)]>;
2047 def STH : DForm_1<44, (outs), (ins gprc:$rS, memri:$dst),
2048 "sth $rS, $dst", IIC_LdStStore,
2049 [(truncstorei16 i32:$rS, iaddr:$dst)]>;
2050 def STW : DForm_1<36, (outs), (ins gprc:$rS, memri:$dst),
2051 "stw $rS, $dst", IIC_LdStStore,
2052 [(store i32:$rS, iaddr:$dst)]>;
2053 let Predicates = [HasFPU] in {
2054 def STFS : DForm_1<52, (outs), (ins f4rc:$rS, memri:$dst),
2055 "stfs $rS, $dst", IIC_LdStSTFD,
2056 [(store f32:$rS, iaddr:$dst)]>;
2057 def STFD : DForm_1<54, (outs), (ins f8rc:$rS, memri:$dst),
2058 "stfd $rS, $dst", IIC_LdStSTFD,
2059 [(store f64:$rS, iaddr:$dst)]>;
2063 // Unindexed (r+i) Stores with Update (preinc).
2064 let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in {
2065 def STBU : DForm_1<39, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst),
2066 "stbu $rS, $dst", IIC_LdStSTU, []>,
2067 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
2068 def STHU : DForm_1<45, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst),
2069 "sthu $rS, $dst", IIC_LdStSTU, []>,
2070 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
2071 def STWU : DForm_1<37, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst),
2072 "stwu $rS, $dst", IIC_LdStSTU, []>,
2073 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
2074 let Predicates = [HasFPU] in {
2075 def STFSU : DForm_1<53, (outs ptr_rc_nor0:$ea_res), (ins f4rc:$rS, memri:$dst),
2076 "stfsu $rS, $dst", IIC_LdStSTFDU, []>,
2077 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
2078 def STFDU : DForm_1<55, (outs ptr_rc_nor0:$ea_res), (ins f8rc:$rS, memri:$dst),
2079 "stfdu $rS, $dst", IIC_LdStSTFDU, []>,
2080 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
2084 // Patterns to match the pre-inc stores. We can't put the patterns on
2085 // the instruction definitions directly as ISel wants the address base
2086 // and offset to be separate operands, not a single complex operand.
2087 def : Pat<(pre_truncsti8 i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
2088 (STBU $rS, iaddroff:$ptroff, $ptrreg)>;
2089 def : Pat<(pre_truncsti16 i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
2090 (STHU $rS, iaddroff:$ptroff, $ptrreg)>;
2091 def : Pat<(pre_store i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
2092 (STWU $rS, iaddroff:$ptroff, $ptrreg)>;
2093 def : Pat<(pre_store f32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
2094 (STFSU $rS, iaddroff:$ptroff, $ptrreg)>;
2095 def : Pat<(pre_store f64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
2096 (STFDU $rS, iaddroff:$ptroff, $ptrreg)>;
2098 // Indexed (r+r) Stores.
2099 let PPC970_Unit = 2 in {
2100 def STBX : XForm_8_memOp<31, 215, (outs), (ins gprc:$rS, memrr:$dst),
2101 "stbx $rS, $dst", IIC_LdStStore,
2102 [(truncstorei8 i32:$rS, xaddr:$dst)]>,
2103 PPC970_DGroup_Cracked;
2104 def STHX : XForm_8_memOp<31, 407, (outs), (ins gprc:$rS, memrr:$dst),
2105 "sthx $rS, $dst", IIC_LdStStore,
2106 [(truncstorei16 i32:$rS, xaddr:$dst)]>,
2107 PPC970_DGroup_Cracked;
2108 def STWX : XForm_8_memOp<31, 151, (outs), (ins gprc:$rS, memrr:$dst),
2109 "stwx $rS, $dst", IIC_LdStStore,
2110 [(store i32:$rS, xaddr:$dst)]>,
2111 PPC970_DGroup_Cracked;
2113 def STHBRX: XForm_8_memOp<31, 918, (outs), (ins gprc:$rS, memrr:$dst),
2114 "sthbrx $rS, $dst", IIC_LdStStore,
2115 [(PPCstbrx i32:$rS, xoaddr:$dst, i16)]>,
2116 PPC970_DGroup_Cracked;
2117 def STWBRX: XForm_8_memOp<31, 662, (outs), (ins gprc:$rS, memrr:$dst),
2118 "stwbrx $rS, $dst", IIC_LdStStore,
2119 [(PPCstbrx i32:$rS, xoaddr:$dst, i32)]>,
2120 PPC970_DGroup_Cracked;
2122 let Predicates = [HasFPU] in {
2123 def STFIWX: XForm_28_memOp<31, 983, (outs), (ins f8rc:$frS, memrr:$dst),
2124 "stfiwx $frS, $dst", IIC_LdStSTFD,
2125 [(PPCstfiwx f64:$frS, xoaddr:$dst)]>;
2127 def STFSX : XForm_28_memOp<31, 663, (outs), (ins f4rc:$frS, memrr:$dst),
2128 "stfsx $frS, $dst", IIC_LdStSTFD,
2129 [(store f32:$frS, xaddr:$dst)]>;
2130 def STFDX : XForm_28_memOp<31, 727, (outs), (ins f8rc:$frS, memrr:$dst),
2131 "stfdx $frS, $dst", IIC_LdStSTFD,
2132 [(store f64:$frS, xaddr:$dst)]>;
2136 // Indexed (r+r) Stores with Update (preinc).
2137 let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in {
2138 def STBUX : XForm_8_memOp<31, 247, (outs ptr_rc_nor0:$ea_res),
2139 (ins gprc:$rS, memrr:$dst),
2140 "stbux $rS, $dst", IIC_LdStSTUX, []>,
2141 RegConstraint<"$dst.ptrreg = $ea_res">,
2142 NoEncode<"$ea_res">,
2143 PPC970_DGroup_Cracked;
2144 def STHUX : XForm_8_memOp<31, 439, (outs ptr_rc_nor0:$ea_res),
2145 (ins gprc:$rS, memrr:$dst),
2146 "sthux $rS, $dst", IIC_LdStSTUX, []>,
2147 RegConstraint<"$dst.ptrreg = $ea_res">,
2148 NoEncode<"$ea_res">,
2149 PPC970_DGroup_Cracked;
2150 def STWUX : XForm_8_memOp<31, 183, (outs ptr_rc_nor0:$ea_res),
2151 (ins gprc:$rS, memrr:$dst),
2152 "stwux $rS, $dst", IIC_LdStSTUX, []>,
2153 RegConstraint<"$dst.ptrreg = $ea_res">,
2154 NoEncode<"$ea_res">,
2155 PPC970_DGroup_Cracked;
2156 let Predicates = [HasFPU] in {
2157 def STFSUX: XForm_8_memOp<31, 695, (outs ptr_rc_nor0:$ea_res),
2158 (ins f4rc:$rS, memrr:$dst),
2159 "stfsux $rS, $dst", IIC_LdStSTFDU, []>,
2160 RegConstraint<"$dst.ptrreg = $ea_res">,
2161 NoEncode<"$ea_res">,
2162 PPC970_DGroup_Cracked;
2163 def STFDUX: XForm_8_memOp<31, 759, (outs ptr_rc_nor0:$ea_res),
2164 (ins f8rc:$rS, memrr:$dst),
2165 "stfdux $rS, $dst", IIC_LdStSTFDU, []>,
2166 RegConstraint<"$dst.ptrreg = $ea_res">,
2167 NoEncode<"$ea_res">,
2168 PPC970_DGroup_Cracked;
2172 // Patterns to match the pre-inc stores. We can't put the patterns on
2173 // the instruction definitions directly as ISel wants the address base
2174 // and offset to be separate operands, not a single complex operand.
2175 def : Pat<(pre_truncsti8 i32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2176 (STBUX $rS, $ptrreg, $ptroff)>;
2177 def : Pat<(pre_truncsti16 i32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2178 (STHUX $rS, $ptrreg, $ptroff)>;
2179 def : Pat<(pre_store i32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2180 (STWUX $rS, $ptrreg, $ptroff)>;
2181 let Predicates = [HasFPU] in {
2182 def : Pat<(pre_store f32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2183 (STFSUX $rS, $ptrreg, $ptroff)>;
2184 def : Pat<(pre_store f64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2185 (STFDUX $rS, $ptrreg, $ptroff)>;
2189 def STMW : DForm_1<47, (outs), (ins gprc:$rS, memri:$dst),
2190 "stmw $rS, $dst", IIC_LdStLMW, []>;
2192 def SYNC : XForm_24_sync<31, 598, (outs), (ins i32imm:$L),
2193 "sync $L", IIC_LdStSync, []>;
2195 let isCodeGenOnly = 1 in {
2196 def MSYNC : XForm_24_sync<31, 598, (outs), (ins),
2197 "msync", IIC_LdStSync, []> {
2202 def : Pat<(int_ppc_sync), (SYNC 0)>, Requires<[HasSYNC]>;
2203 def : Pat<(int_ppc_lwsync), (SYNC 1)>, Requires<[HasSYNC]>;
2204 def : Pat<(int_ppc_sync), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
2205 def : Pat<(int_ppc_lwsync), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
2207 //===----------------------------------------------------------------------===//
2208 // PPC32 Arithmetic Instructions.
2211 let PPC970_Unit = 1 in { // FXU Operations.
2212 def ADDI : DForm_2<14, (outs gprc:$rD), (ins gprc_nor0:$rA, s16imm:$imm),
2213 "addi $rD, $rA, $imm", IIC_IntSimple,
2214 [(set i32:$rD, (add i32:$rA, imm32SExt16:$imm))]>;
2215 let BaseName = "addic" in {
2216 let Defs = [CARRY] in
2217 def ADDIC : DForm_2<12, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
2218 "addic $rD, $rA, $imm", IIC_IntGeneral,
2219 [(set i32:$rD, (addc i32:$rA, imm32SExt16:$imm))]>,
2220 RecFormRel, PPC970_DGroup_Cracked;
2221 let Defs = [CARRY, CR0] in
2222 def ADDICo : DForm_2<13, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
2223 "addic. $rD, $rA, $imm", IIC_IntGeneral,
2224 []>, isDOT, RecFormRel;
2226 def ADDIS : DForm_2<15, (outs gprc:$rD), (ins gprc_nor0:$rA, s17imm:$imm),
2227 "addis $rD, $rA, $imm", IIC_IntSimple,
2228 [(set i32:$rD, (add i32:$rA, imm16ShiftedSExt:$imm))]>;
2229 let isCodeGenOnly = 1 in
2230 def LA : DForm_2<14, (outs gprc:$rD), (ins gprc_nor0:$rA, s16imm:$sym),
2231 "la $rD, $sym($rA)", IIC_IntGeneral,
2232 [(set i32:$rD, (add i32:$rA,
2233 (PPClo tglobaladdr:$sym, 0)))]>;
2234 def MULLI : DForm_2< 7, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
2235 "mulli $rD, $rA, $imm", IIC_IntMulLI,
2236 [(set i32:$rD, (mul i32:$rA, imm32SExt16:$imm))]>;
2237 let Defs = [CARRY] in
2238 def SUBFIC : DForm_2< 8, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
2239 "subfic $rD, $rA, $imm", IIC_IntGeneral,
2240 [(set i32:$rD, (subc imm32SExt16:$imm, i32:$rA))]>;
2242 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in {
2243 def LI : DForm_2_r0<14, (outs gprc:$rD), (ins s16imm:$imm),
2244 "li $rD, $imm", IIC_IntSimple,
2245 [(set i32:$rD, imm32SExt16:$imm)]>;
2246 def LIS : DForm_2_r0<15, (outs gprc:$rD), (ins s17imm:$imm),
2247 "lis $rD, $imm", IIC_IntSimple,
2248 [(set i32:$rD, imm16ShiftedSExt:$imm)]>;
2252 let PPC970_Unit = 1 in { // FXU Operations.
2253 let Defs = [CR0] in {
2254 def ANDIo : DForm_4<28, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2255 "andi. $dst, $src1, $src2", IIC_IntGeneral,
2256 [(set i32:$dst, (and i32:$src1, immZExt16:$src2))]>,
2258 def ANDISo : DForm_4<29, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2259 "andis. $dst, $src1, $src2", IIC_IntGeneral,
2260 [(set i32:$dst, (and i32:$src1, imm16ShiftedZExt:$src2))]>,
2263 def ORI : DForm_4<24, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2264 "ori $dst, $src1, $src2", IIC_IntSimple,
2265 [(set i32:$dst, (or i32:$src1, immZExt16:$src2))]>;
2266 def ORIS : DForm_4<25, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2267 "oris $dst, $src1, $src2", IIC_IntSimple,
2268 [(set i32:$dst, (or i32:$src1, imm16ShiftedZExt:$src2))]>;
2269 def XORI : DForm_4<26, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2270 "xori $dst, $src1, $src2", IIC_IntSimple,
2271 [(set i32:$dst, (xor i32:$src1, immZExt16:$src2))]>;
2272 def XORIS : DForm_4<27, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2273 "xoris $dst, $src1, $src2", IIC_IntSimple,
2274 [(set i32:$dst, (xor i32:$src1, imm16ShiftedZExt:$src2))]>;
2276 def NOP : DForm_4_zero<24, (outs), (ins), "nop", IIC_IntSimple,
2278 let isCodeGenOnly = 1 in {
2279 // The POWER6 and POWER7 have special group-terminating nops.
2280 def NOP_GT_PWR6 : DForm_4_fixedreg_zero<24, 1, (outs), (ins),
2281 "ori 1, 1, 0", IIC_IntSimple, []>;
2282 def NOP_GT_PWR7 : DForm_4_fixedreg_zero<24, 2, (outs), (ins),
2283 "ori 2, 2, 0", IIC_IntSimple, []>;
2286 let isCompare = 1, hasSideEffects = 0 in {
2287 def CMPWI : DForm_5_ext<11, (outs crrc:$crD), (ins gprc:$rA, s16imm:$imm),
2288 "cmpwi $crD, $rA, $imm", IIC_IntCompare>;
2289 def CMPLWI : DForm_6_ext<10, (outs crrc:$dst), (ins gprc:$src1, u16imm:$src2),
2290 "cmplwi $dst, $src1, $src2", IIC_IntCompare>;
2291 def CMPRB : X_BF3_L1_RS5_RS5<31, 192, (outs crbitrc:$BF),
2292 (ins u1imm:$L, g8rc:$rA, g8rc:$rB),
2293 "cmprb $BF, $L, $rA, $rB", IIC_IntCompare, []>,
2294 Requires<[IsISA3_0]>;
2298 let PPC970_Unit = 1, hasSideEffects = 0 in { // FXU Operations.
2299 let isCommutable = 1 in {
2300 defm NAND : XForm_6r<31, 476, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2301 "nand", "$rA, $rS, $rB", IIC_IntSimple,
2302 [(set i32:$rA, (not (and i32:$rS, i32:$rB)))]>;
2303 defm AND : XForm_6r<31, 28, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2304 "and", "$rA, $rS, $rB", IIC_IntSimple,
2305 [(set i32:$rA, (and i32:$rS, i32:$rB))]>;
2307 defm ANDC : XForm_6r<31, 60, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2308 "andc", "$rA, $rS, $rB", IIC_IntSimple,
2309 [(set i32:$rA, (and i32:$rS, (not i32:$rB)))]>;
2310 let isCommutable = 1 in {
2311 defm OR : XForm_6r<31, 444, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2312 "or", "$rA, $rS, $rB", IIC_IntSimple,
2313 [(set i32:$rA, (or i32:$rS, i32:$rB))]>;
2314 defm NOR : XForm_6r<31, 124, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2315 "nor", "$rA, $rS, $rB", IIC_IntSimple,
2316 [(set i32:$rA, (not (or i32:$rS, i32:$rB)))]>;
2318 defm ORC : XForm_6r<31, 412, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2319 "orc", "$rA, $rS, $rB", IIC_IntSimple,
2320 [(set i32:$rA, (or i32:$rS, (not i32:$rB)))]>;
2321 let isCommutable = 1 in {
2322 defm EQV : XForm_6r<31, 284, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2323 "eqv", "$rA, $rS, $rB", IIC_IntSimple,
2324 [(set i32:$rA, (not (xor i32:$rS, i32:$rB)))]>;
2325 defm XOR : XForm_6r<31, 316, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2326 "xor", "$rA, $rS, $rB", IIC_IntSimple,
2327 [(set i32:$rA, (xor i32:$rS, i32:$rB))]>;
2329 defm SLW : XForm_6r<31, 24, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2330 "slw", "$rA, $rS, $rB", IIC_IntGeneral,
2331 [(set i32:$rA, (PPCshl i32:$rS, i32:$rB))]>;
2332 defm SRW : XForm_6r<31, 536, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2333 "srw", "$rA, $rS, $rB", IIC_IntGeneral,
2334 [(set i32:$rA, (PPCsrl i32:$rS, i32:$rB))]>;
2335 defm SRAW : XForm_6rc<31, 792, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2336 "sraw", "$rA, $rS, $rB", IIC_IntShift,
2337 [(set i32:$rA, (PPCsra i32:$rS, i32:$rB))]>;
2340 let PPC970_Unit = 1 in { // FXU Operations.
2341 let hasSideEffects = 0 in {
2342 defm SRAWI : XForm_10rc<31, 824, (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH),
2343 "srawi", "$rA, $rS, $SH", IIC_IntShift,
2344 [(set i32:$rA, (sra i32:$rS, (i32 imm:$SH)))]>;
2345 defm CNTLZW : XForm_11r<31, 26, (outs gprc:$rA), (ins gprc:$rS),
2346 "cntlzw", "$rA, $rS", IIC_IntGeneral,
2347 [(set i32:$rA, (ctlz i32:$rS))]>;
2348 defm CNTTZW : XForm_11r<31, 538, (outs gprc:$rA), (ins gprc:$rS),
2349 "cnttzw", "$rA, $rS", IIC_IntGeneral,
2350 [(set i32:$rA, (cttz i32:$rS))]>, Requires<[IsISA3_0]>;
2351 defm EXTSB : XForm_11r<31, 954, (outs gprc:$rA), (ins gprc:$rS),
2352 "extsb", "$rA, $rS", IIC_IntSimple,
2353 [(set i32:$rA, (sext_inreg i32:$rS, i8))]>;
2354 defm EXTSH : XForm_11r<31, 922, (outs gprc:$rA), (ins gprc:$rS),
2355 "extsh", "$rA, $rS", IIC_IntSimple,
2356 [(set i32:$rA, (sext_inreg i32:$rS, i16))]>;
2358 let isCommutable = 1 in
2359 def CMPB : XForm_6<31, 508, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2360 "cmpb $rA, $rS, $rB", IIC_IntGeneral,
2361 [(set i32:$rA, (PPCcmpb i32:$rS, i32:$rB))]>;
2363 let isCompare = 1, hasSideEffects = 0 in {
2364 def CMPW : XForm_16_ext<31, 0, (outs crrc:$crD), (ins gprc:$rA, gprc:$rB),
2365 "cmpw $crD, $rA, $rB", IIC_IntCompare>;
2366 def CMPLW : XForm_16_ext<31, 32, (outs crrc:$crD), (ins gprc:$rA, gprc:$rB),
2367 "cmplw $crD, $rA, $rB", IIC_IntCompare>;
2370 let PPC970_Unit = 3, Predicates = [HasFPU] in { // FPU Operations.
2371 //def FCMPO : XForm_17<63, 32, (outs CRRC:$crD), (ins FPRC:$fA, FPRC:$fB),
2372 // "fcmpo $crD, $fA, $fB", IIC_FPCompare>;
2373 let isCompare = 1, hasSideEffects = 0 in {
2374 def FCMPUS : XForm_17<63, 0, (outs crrc:$crD), (ins f4rc:$fA, f4rc:$fB),
2375 "fcmpu $crD, $fA, $fB", IIC_FPCompare>;
2376 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2377 def FCMPUD : XForm_17<63, 0, (outs crrc:$crD), (ins f8rc:$fA, f8rc:$fB),
2378 "fcmpu $crD, $fA, $fB", IIC_FPCompare>;
2381 def FTDIV: XForm_17<63, 128, (outs crrc:$crD), (ins f8rc:$fA, f8rc:$fB),
2382 "ftdiv $crD, $fA, $fB", IIC_FPCompare>;
2383 def FTSQRT: XForm_17a<63, 160, (outs crrc:$crD), (ins f8rc:$fB),
2384 "ftsqrt $crD, $fB", IIC_FPCompare>;
2386 let Uses = [RM] in {
2387 let hasSideEffects = 0 in {
2388 defm FCTIW : XForm_26r<63, 14, (outs f8rc:$frD), (ins f8rc:$frB),
2389 "fctiw", "$frD, $frB", IIC_FPGeneral,
2391 defm FCTIWU : XForm_26r<63, 142, (outs f8rc:$frD), (ins f8rc:$frB),
2392 "fctiwu", "$frD, $frB", IIC_FPGeneral,
2394 defm FCTIWZ : XForm_26r<63, 15, (outs f8rc:$frD), (ins f8rc:$frB),
2395 "fctiwz", "$frD, $frB", IIC_FPGeneral,
2396 [(set f64:$frD, (PPCfctiwz f64:$frB))]>;
2398 defm FRSP : XForm_26r<63, 12, (outs f4rc:$frD), (ins f8rc:$frB),
2399 "frsp", "$frD, $frB", IIC_FPGeneral,
2400 [(set f32:$frD, (fpround f64:$frB))]>;
2402 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2403 defm FRIND : XForm_26r<63, 392, (outs f8rc:$frD), (ins f8rc:$frB),
2404 "frin", "$frD, $frB", IIC_FPGeneral,
2405 [(set f64:$frD, (fround f64:$frB))]>;
2406 defm FRINS : XForm_26r<63, 392, (outs f4rc:$frD), (ins f4rc:$frB),
2407 "frin", "$frD, $frB", IIC_FPGeneral,
2408 [(set f32:$frD, (fround f32:$frB))]>;
2411 let hasSideEffects = 0 in {
2412 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2413 defm FRIPD : XForm_26r<63, 456, (outs f8rc:$frD), (ins f8rc:$frB),
2414 "frip", "$frD, $frB", IIC_FPGeneral,
2415 [(set f64:$frD, (fceil f64:$frB))]>;
2416 defm FRIPS : XForm_26r<63, 456, (outs f4rc:$frD), (ins f4rc:$frB),
2417 "frip", "$frD, $frB", IIC_FPGeneral,
2418 [(set f32:$frD, (fceil f32:$frB))]>;
2419 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2420 defm FRIZD : XForm_26r<63, 424, (outs f8rc:$frD), (ins f8rc:$frB),
2421 "friz", "$frD, $frB", IIC_FPGeneral,
2422 [(set f64:$frD, (ftrunc f64:$frB))]>;
2423 defm FRIZS : XForm_26r<63, 424, (outs f4rc:$frD), (ins f4rc:$frB),
2424 "friz", "$frD, $frB", IIC_FPGeneral,
2425 [(set f32:$frD, (ftrunc f32:$frB))]>;
2426 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2427 defm FRIMD : XForm_26r<63, 488, (outs f8rc:$frD), (ins f8rc:$frB),
2428 "frim", "$frD, $frB", IIC_FPGeneral,
2429 [(set f64:$frD, (ffloor f64:$frB))]>;
2430 defm FRIMS : XForm_26r<63, 488, (outs f4rc:$frD), (ins f4rc:$frB),
2431 "frim", "$frD, $frB", IIC_FPGeneral,
2432 [(set f32:$frD, (ffloor f32:$frB))]>;
2434 defm FSQRT : XForm_26r<63, 22, (outs f8rc:$frD), (ins f8rc:$frB),
2435 "fsqrt", "$frD, $frB", IIC_FPSqrtD,
2436 [(set f64:$frD, (fsqrt f64:$frB))]>;
2437 defm FSQRTS : XForm_26r<59, 22, (outs f4rc:$frD), (ins f4rc:$frB),
2438 "fsqrts", "$frD, $frB", IIC_FPSqrtS,
2439 [(set f32:$frD, (fsqrt f32:$frB))]>;
2444 /// Note that FMR is defined as pseudo-ops on the PPC970 because they are
2445 /// often coalesced away and we don't want the dispatch group builder to think
2446 /// that they will fill slots (which could cause the load of a LSU reject to
2447 /// sneak into a d-group with a store).
2448 let hasSideEffects = 0, Predicates = [HasFPU] in
2449 defm FMR : XForm_26r<63, 72, (outs f4rc:$frD), (ins f4rc:$frB),
2450 "fmr", "$frD, $frB", IIC_FPGeneral,
2451 []>, // (set f32:$frD, f32:$frB)
2454 let PPC970_Unit = 3, hasSideEffects = 0, Predicates = [HasFPU] in { // FPU Operations.
2455 // These are artificially split into two different forms, for 4/8 byte FP.
2456 defm FABSS : XForm_26r<63, 264, (outs f4rc:$frD), (ins f4rc:$frB),
2457 "fabs", "$frD, $frB", IIC_FPGeneral,
2458 [(set f32:$frD, (fabs f32:$frB))]>;
2459 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2460 defm FABSD : XForm_26r<63, 264, (outs f8rc:$frD), (ins f8rc:$frB),
2461 "fabs", "$frD, $frB", IIC_FPGeneral,
2462 [(set f64:$frD, (fabs f64:$frB))]>;
2463 defm FNABSS : XForm_26r<63, 136, (outs f4rc:$frD), (ins f4rc:$frB),
2464 "fnabs", "$frD, $frB", IIC_FPGeneral,
2465 [(set f32:$frD, (fneg (fabs f32:$frB)))]>;
2466 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2467 defm FNABSD : XForm_26r<63, 136, (outs f8rc:$frD), (ins f8rc:$frB),
2468 "fnabs", "$frD, $frB", IIC_FPGeneral,
2469 [(set f64:$frD, (fneg (fabs f64:$frB)))]>;
2470 defm FNEGS : XForm_26r<63, 40, (outs f4rc:$frD), (ins f4rc:$frB),
2471 "fneg", "$frD, $frB", IIC_FPGeneral,
2472 [(set f32:$frD, (fneg f32:$frB))]>;
2473 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2474 defm FNEGD : XForm_26r<63, 40, (outs f8rc:$frD), (ins f8rc:$frB),
2475 "fneg", "$frD, $frB", IIC_FPGeneral,
2476 [(set f64:$frD, (fneg f64:$frB))]>;
2478 defm FCPSGNS : XForm_28r<63, 8, (outs f4rc:$frD), (ins f4rc:$frA, f4rc:$frB),
2479 "fcpsgn", "$frD, $frA, $frB", IIC_FPGeneral,
2480 [(set f32:$frD, (fcopysign f32:$frB, f32:$frA))]>;
2481 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2482 defm FCPSGND : XForm_28r<63, 8, (outs f8rc:$frD), (ins f8rc:$frA, f8rc:$frB),
2483 "fcpsgn", "$frD, $frA, $frB", IIC_FPGeneral,
2484 [(set f64:$frD, (fcopysign f64:$frB, f64:$frA))]>;
2486 // Reciprocal estimates.
2487 defm FRE : XForm_26r<63, 24, (outs f8rc:$frD), (ins f8rc:$frB),
2488 "fre", "$frD, $frB", IIC_FPGeneral,
2489 [(set f64:$frD, (PPCfre f64:$frB))]>;
2490 defm FRES : XForm_26r<59, 24, (outs f4rc:$frD), (ins f4rc:$frB),
2491 "fres", "$frD, $frB", IIC_FPGeneral,
2492 [(set f32:$frD, (PPCfre f32:$frB))]>;
2493 defm FRSQRTE : XForm_26r<63, 26, (outs f8rc:$frD), (ins f8rc:$frB),
2494 "frsqrte", "$frD, $frB", IIC_FPGeneral,
2495 [(set f64:$frD, (PPCfrsqrte f64:$frB))]>;
2496 defm FRSQRTES : XForm_26r<59, 26, (outs f4rc:$frD), (ins f4rc:$frB),
2497 "frsqrtes", "$frD, $frB", IIC_FPGeneral,
2498 [(set f32:$frD, (PPCfrsqrte f32:$frB))]>;
2501 // XL-Form instructions. condition register logical ops.
2503 let hasSideEffects = 0 in
2504 def MCRF : XLForm_3<19, 0, (outs crrc:$BF), (ins crrc:$BFA),
2505 "mcrf $BF, $BFA", IIC_BrMCR>,
2506 PPC970_DGroup_First, PPC970_Unit_CRU;
2508 // FIXME: According to the ISA (section 2.5.1 of version 2.06), the
2509 // condition-register logical instructions have preferred forms. Specifically,
2510 // it is preferred that the bit specified by the BT field be in the same
2511 // condition register as that specified by the bit BB. We might want to account
2512 // for this via hinting the register allocator and anti-dep breakers, or we
2513 // could constrain the register class to force this constraint and then loosen
2514 // it during register allocation via convertToThreeAddress or some similar
2517 let isCommutable = 1 in {
2518 def CRAND : XLForm_1<19, 257, (outs crbitrc:$CRD),
2519 (ins crbitrc:$CRA, crbitrc:$CRB),
2520 "crand $CRD, $CRA, $CRB", IIC_BrCR,
2521 [(set i1:$CRD, (and i1:$CRA, i1:$CRB))]>;
2523 def CRNAND : XLForm_1<19, 225, (outs crbitrc:$CRD),
2524 (ins crbitrc:$CRA, crbitrc:$CRB),
2525 "crnand $CRD, $CRA, $CRB", IIC_BrCR,
2526 [(set i1:$CRD, (not (and i1:$CRA, i1:$CRB)))]>;
2528 def CROR : XLForm_1<19, 449, (outs crbitrc:$CRD),
2529 (ins crbitrc:$CRA, crbitrc:$CRB),
2530 "cror $CRD, $CRA, $CRB", IIC_BrCR,
2531 [(set i1:$CRD, (or i1:$CRA, i1:$CRB))]>;
2533 def CRXOR : XLForm_1<19, 193, (outs crbitrc:$CRD),
2534 (ins crbitrc:$CRA, crbitrc:$CRB),
2535 "crxor $CRD, $CRA, $CRB", IIC_BrCR,
2536 [(set i1:$CRD, (xor i1:$CRA, i1:$CRB))]>;
2538 def CRNOR : XLForm_1<19, 33, (outs crbitrc:$CRD),
2539 (ins crbitrc:$CRA, crbitrc:$CRB),
2540 "crnor $CRD, $CRA, $CRB", IIC_BrCR,
2541 [(set i1:$CRD, (not (or i1:$CRA, i1:$CRB)))]>;
2543 def CREQV : XLForm_1<19, 289, (outs crbitrc:$CRD),
2544 (ins crbitrc:$CRA, crbitrc:$CRB),
2545 "creqv $CRD, $CRA, $CRB", IIC_BrCR,
2546 [(set i1:$CRD, (not (xor i1:$CRA, i1:$CRB)))]>;
2549 def CRANDC : XLForm_1<19, 129, (outs crbitrc:$CRD),
2550 (ins crbitrc:$CRA, crbitrc:$CRB),
2551 "crandc $CRD, $CRA, $CRB", IIC_BrCR,
2552 [(set i1:$CRD, (and i1:$CRA, (not i1:$CRB)))]>;
2554 def CRORC : XLForm_1<19, 417, (outs crbitrc:$CRD),
2555 (ins crbitrc:$CRA, crbitrc:$CRB),
2556 "crorc $CRD, $CRA, $CRB", IIC_BrCR,
2557 [(set i1:$CRD, (or i1:$CRA, (not i1:$CRB)))]>;
2559 let isCodeGenOnly = 1 in {
2560 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
2561 def CRSET : XLForm_1_ext<19, 289, (outs crbitrc:$dst), (ins),
2562 "creqv $dst, $dst, $dst", IIC_BrCR,
2563 [(set i1:$dst, 1)]>;
2565 def CRUNSET: XLForm_1_ext<19, 193, (outs crbitrc:$dst), (ins),
2566 "crxor $dst, $dst, $dst", IIC_BrCR,
2567 [(set i1:$dst, 0)]>;
2570 let Defs = [CR1EQ], CRD = 6 in {
2571 def CR6SET : XLForm_1_ext<19, 289, (outs), (ins),
2572 "creqv 6, 6, 6", IIC_BrCR,
2575 def CR6UNSET: XLForm_1_ext<19, 193, (outs), (ins),
2576 "crxor 6, 6, 6", IIC_BrCR,
2581 // XFX-Form instructions. Instructions that deal with SPRs.
2584 def MFSPR : XFXForm_1<31, 339, (outs gprc:$RT), (ins i32imm:$SPR),
2585 "mfspr $RT, $SPR", IIC_SprMFSPR>;
2586 def MTSPR : XFXForm_1<31, 467, (outs), (ins i32imm:$SPR, gprc:$RT),
2587 "mtspr $SPR, $RT", IIC_SprMTSPR>;
2589 def MFTB : XFXForm_1<31, 371, (outs gprc:$RT), (ins i32imm:$SPR),
2590 "mftb $RT, $SPR", IIC_SprMFTB>;
2592 def MFPMR : XFXForm_1<31, 334, (outs gprc:$RT), (ins i32imm:$SPR),
2593 "mfpmr $RT, $SPR", IIC_SprMFPMR>;
2595 def MTPMR : XFXForm_1<31, 462, (outs), (ins i32imm:$SPR, gprc:$RT),
2596 "mtpmr $SPR, $RT", IIC_SprMTPMR>;
2599 // A pseudo-instruction used to implement the read of the 64-bit cycle counter
2600 // on a 32-bit target.
2601 let hasSideEffects = 1 in
2602 def ReadTB : PPCCustomInserterPseudo<(outs gprc:$lo, gprc:$hi), (ins),
2605 let Uses = [CTR] in {
2606 def MFCTR : XFXForm_1_ext<31, 339, 9, (outs gprc:$rT), (ins),
2607 "mfctr $rT", IIC_SprMFSPR>,
2608 PPC970_DGroup_First, PPC970_Unit_FXU;
2610 let Defs = [CTR], Pattern = [(PPCmtctr i32:$rS)] in {
2611 def MTCTR : XFXForm_7_ext<31, 467, 9, (outs), (ins gprc:$rS),
2612 "mtctr $rS", IIC_SprMTSPR>,
2613 PPC970_DGroup_First, PPC970_Unit_FXU;
2615 let hasSideEffects = 1, isCodeGenOnly = 1, Defs = [CTR] in {
2616 let Pattern = [(int_set_loop_iterations i32:$rS)] in
2617 def MTCTRloop : XFXForm_7_ext<31, 467, 9, (outs), (ins gprc:$rS),
2618 "mtctr $rS", IIC_SprMTSPR>,
2619 PPC970_DGroup_First, PPC970_Unit_FXU;
2622 let Defs = [LR] in {
2623 def MTLR : XFXForm_7_ext<31, 467, 8, (outs), (ins gprc:$rS),
2624 "mtlr $rS", IIC_SprMTSPR>,
2625 PPC970_DGroup_First, PPC970_Unit_FXU;
2627 let Uses = [LR] in {
2628 def MFLR : XFXForm_1_ext<31, 339, 8, (outs gprc:$rT), (ins),
2629 "mflr $rT", IIC_SprMFSPR>,
2630 PPC970_DGroup_First, PPC970_Unit_FXU;
2633 let isCodeGenOnly = 1 in {
2634 // Move to/from VRSAVE: despite being a SPR, the VRSAVE register is renamed
2635 // like a GPR on the PPC970. As such, copies in and out have the same
2636 // performance characteristics as an OR instruction.
2637 def MTVRSAVE : XFXForm_7_ext<31, 467, 256, (outs), (ins gprc:$rS),
2638 "mtspr 256, $rS", IIC_IntGeneral>,
2639 PPC970_DGroup_Single, PPC970_Unit_FXU;
2640 def MFVRSAVE : XFXForm_1_ext<31, 339, 256, (outs gprc:$rT), (ins),
2641 "mfspr $rT, 256", IIC_IntGeneral>,
2642 PPC970_DGroup_First, PPC970_Unit_FXU;
2644 def MTVRSAVEv : XFXForm_7_ext<31, 467, 256,
2645 (outs VRSAVERC:$reg), (ins gprc:$rS),
2646 "mtspr 256, $rS", IIC_IntGeneral>,
2647 PPC970_DGroup_Single, PPC970_Unit_FXU;
2648 def MFVRSAVEv : XFXForm_1_ext<31, 339, 256, (outs gprc:$rT),
2649 (ins VRSAVERC:$reg),
2650 "mfspr $rT, 256", IIC_IntGeneral>,
2651 PPC970_DGroup_First, PPC970_Unit_FXU;
2654 // Aliases for mtvrsave/mfvrsave to mfspr/mtspr.
2655 def : InstAlias<"mtvrsave $rS", (MTVRSAVE gprc:$rS)>;
2656 def : InstAlias<"mfvrsave $rS", (MFVRSAVE gprc:$rS)>;
2658 // SPILL_VRSAVE - Indicate that we're dumping the VRSAVE register,
2659 // so we'll need to scavenge a register for it.
2661 def SPILL_VRSAVE : PPCEmitTimePseudo<(outs), (ins VRSAVERC:$vrsave, memri:$F),
2662 "#SPILL_VRSAVE", []>;
2664 // RESTORE_VRSAVE - Indicate that we're restoring the VRSAVE register (previously
2665 // spilled), so we'll need to scavenge a register for it.
2667 def RESTORE_VRSAVE : PPCEmitTimePseudo<(outs VRSAVERC:$vrsave), (ins memri:$F),
2668 "#RESTORE_VRSAVE", []>;
2670 let hasSideEffects = 0 in {
2671 // mtocrf's input needs to be prepared by shifting by an amount dependent
2672 // on the cr register selected. Thus, post-ra anti-dep breaking must not
2673 // later change that register assignment.
2674 let hasExtraDefRegAllocReq = 1 in {
2675 def MTOCRF: XFXForm_5a<31, 144, (outs crbitm:$FXM), (ins gprc:$ST),
2676 "mtocrf $FXM, $ST", IIC_BrMCRX>,
2677 PPC970_DGroup_First, PPC970_Unit_CRU;
2679 // Similarly to mtocrf, the mask for mtcrf must be prepared in a way that
2680 // is dependent on the cr fields being set.
2681 def MTCRF : XFXForm_5<31, 144, (outs), (ins i32imm:$FXM, gprc:$rS),
2682 "mtcrf $FXM, $rS", IIC_BrMCRX>,
2683 PPC970_MicroCode, PPC970_Unit_CRU;
2684 } // hasExtraDefRegAllocReq = 1
2686 // mfocrf's input needs to be prepared by shifting by an amount dependent
2687 // on the cr register selected. Thus, post-ra anti-dep breaking must not
2688 // later change that register assignment.
2689 let hasExtraSrcRegAllocReq = 1 in {
2690 def MFOCRF: XFXForm_5a<31, 19, (outs gprc:$rT), (ins crbitm:$FXM),
2691 "mfocrf $rT, $FXM", IIC_SprMFCRF>,
2692 PPC970_DGroup_First, PPC970_Unit_CRU;
2694 // Similarly to mfocrf, the mask for mfcrf must be prepared in a way that
2695 // is dependent on the cr fields being copied.
2696 def MFCR : XFXForm_3<31, 19, (outs gprc:$rT), (ins),
2697 "mfcr $rT", IIC_SprMFCR>,
2698 PPC970_MicroCode, PPC970_Unit_CRU;
2699 } // hasExtraSrcRegAllocReq = 1
2701 def MCRXRX : X_BF3<31, 576, (outs crrc:$BF), (ins),
2702 "mcrxrx $BF", IIC_BrMCRX>, Requires<[IsISA3_0]>;
2703 } // hasSideEffects = 0
2705 let Predicates = [HasFPU] in {
2706 // Custom inserter instruction to perform FADD in round-to-zero mode.
2707 let Uses = [RM] in {
2708 def FADDrtz: PPCCustomInserterPseudo<(outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB), "",
2709 [(set f64:$FRT, (PPCfaddrtz f64:$FRA, f64:$FRB))]>;
2712 // The above pseudo gets expanded to make use of the following instructions
2713 // to manipulate FPSCR. Note that FPSCR is not modeled at the DAG level.
2714 let Uses = [RM], Defs = [RM] in {
2715 def MTFSB0 : XForm_43<63, 70, (outs), (ins u5imm:$FM),
2716 "mtfsb0 $FM", IIC_IntMTFSB0, []>,
2717 PPC970_DGroup_Single, PPC970_Unit_FPU;
2718 def MTFSB1 : XForm_43<63, 38, (outs), (ins u5imm:$FM),
2719 "mtfsb1 $FM", IIC_IntMTFSB0, []>,
2720 PPC970_DGroup_Single, PPC970_Unit_FPU;
2721 let isCodeGenOnly = 1 in
2722 def MTFSFb : XFLForm<63, 711, (outs), (ins i32imm:$FM, f8rc:$rT),
2723 "mtfsf $FM, $rT", IIC_IntMTFSB0, []>,
2724 PPC970_DGroup_Single, PPC970_Unit_FPU;
2726 let Uses = [RM] in {
2727 def MFFS : XForm_42<63, 583, (outs f8rc:$rT), (ins),
2728 "mffs $rT", IIC_IntMFFS,
2729 [(set f64:$rT, (PPCmffs))]>,
2730 PPC970_DGroup_Single, PPC970_Unit_FPU;
2733 def MFFSo : XForm_42<63, 583, (outs f8rc:$rT), (ins),
2734 "mffs. $rT", IIC_IntMFFS, []>, isDOT;
2736 def MFFSCE : X_FRT5_XO2_XO3_XO10<63, 0, 1, 583, (outs f8rc:$rT), (ins),
2737 "mffsce $rT", IIC_IntMFFS, []>,
2738 PPC970_DGroup_Single, PPC970_Unit_FPU;
2740 def MFFSCDRN : X_FRT5_XO2_XO3_FRB5_XO10<63, 2, 4, 583, (outs f8rc:$rT),
2741 (ins f8rc:$FRB), "mffscdrn $rT, $FRB",
2743 PPC970_DGroup_Single, PPC970_Unit_FPU;
2745 def MFFSCDRNI : X_FRT5_XO2_XO3_DRM3_XO10<63, 2, 5, 583, (outs f8rc:$rT),
2747 "mffscdrni $rT, $DRM",
2749 PPC970_DGroup_Single, PPC970_Unit_FPU;
2751 def MFFSCRN : X_FRT5_XO2_XO3_FRB5_XO10<63, 2, 6, 583, (outs f8rc:$rT),
2752 (ins f8rc:$FRB), "mffscrn $rT, $FRB",
2754 PPC970_DGroup_Single, PPC970_Unit_FPU;
2756 def MFFSCRNI : X_FRT5_XO2_XO3_RM2_X10<63, 2, 7, 583, (outs f8rc:$rT),
2757 (ins u2imm:$RM), "mffscrni $rT, $RM",
2759 PPC970_DGroup_Single, PPC970_Unit_FPU;
2761 def MFFSL : X_FRT5_XO2_XO3_XO10<63, 3, 0, 583, (outs f8rc:$rT), (ins),
2762 "mffsl $rT", IIC_IntMFFS, []>,
2763 PPC970_DGroup_Single, PPC970_Unit_FPU;
2767 let Predicates = [IsISA3_0] in {
2768 def MODSW : XForm_8<31, 779, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2769 "modsw $rT, $rA, $rB", IIC_IntDivW,
2770 [(set i32:$rT, (srem i32:$rA, i32:$rB))]>;
2771 def MODUW : XForm_8<31, 267, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2772 "moduw $rT, $rA, $rB", IIC_IntDivW,
2773 [(set i32:$rT, (urem i32:$rA, i32:$rB))]>;
2776 let PPC970_Unit = 1, hasSideEffects = 0 in { // FXU Operations.
2777 // XO-Form instructions. Arithmetic instructions that can set overflow bit
2778 let isCommutable = 1 in
2779 defm ADD4 : XOForm_1r<31, 266, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2780 "add", "$rT, $rA, $rB", IIC_IntSimple,
2781 [(set i32:$rT, (add i32:$rA, i32:$rB))]>;
2782 let isCodeGenOnly = 1 in
2783 def ADD4TLS : XOForm_1<31, 266, 0, (outs gprc:$rT), (ins gprc:$rA, tlsreg32:$rB),
2784 "add $rT, $rA, $rB", IIC_IntSimple,
2785 [(set i32:$rT, (add i32:$rA, tglobaltlsaddr:$rB))]>;
2786 let isCommutable = 1 in
2787 defm ADDC : XOForm_1rc<31, 10, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2788 "addc", "$rT, $rA, $rB", IIC_IntGeneral,
2789 [(set i32:$rT, (addc i32:$rA, i32:$rB))]>,
2790 PPC970_DGroup_Cracked;
2792 defm DIVW : XOForm_1rcr<31, 491, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2793 "divw", "$rT, $rA, $rB", IIC_IntDivW,
2794 [(set i32:$rT, (sdiv i32:$rA, i32:$rB))]>;
2795 defm DIVWU : XOForm_1rcr<31, 459, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2796 "divwu", "$rT, $rA, $rB", IIC_IntDivW,
2797 [(set i32:$rT, (udiv i32:$rA, i32:$rB))]>;
2798 def DIVWE : XOForm_1<31, 427, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2799 "divwe $rT, $rA, $rB", IIC_IntDivW,
2800 [(set i32:$rT, (int_ppc_divwe gprc:$rA, gprc:$rB))]>,
2801 Requires<[HasExtDiv]>;
2803 def DIVWEo : XOForm_1<31, 427, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2804 "divwe. $rT, $rA, $rB", IIC_IntDivW,
2805 []>, isDOT, PPC970_DGroup_Cracked, PPC970_DGroup_First,
2806 Requires<[HasExtDiv]>;
2807 def DIVWEU : XOForm_1<31, 395, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2808 "divweu $rT, $rA, $rB", IIC_IntDivW,
2809 [(set i32:$rT, (int_ppc_divweu gprc:$rA, gprc:$rB))]>,
2810 Requires<[HasExtDiv]>;
2812 def DIVWEUo : XOForm_1<31, 395, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2813 "divweu. $rT, $rA, $rB", IIC_IntDivW,
2814 []>, isDOT, PPC970_DGroup_Cracked, PPC970_DGroup_First,
2815 Requires<[HasExtDiv]>;
2816 let isCommutable = 1 in {
2817 defm MULHW : XOForm_1r<31, 75, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2818 "mulhw", "$rT, $rA, $rB", IIC_IntMulHW,
2819 [(set i32:$rT, (mulhs i32:$rA, i32:$rB))]>;
2820 defm MULHWU : XOForm_1r<31, 11, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2821 "mulhwu", "$rT, $rA, $rB", IIC_IntMulHWU,
2822 [(set i32:$rT, (mulhu i32:$rA, i32:$rB))]>;
2823 defm MULLW : XOForm_1r<31, 235, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2824 "mullw", "$rT, $rA, $rB", IIC_IntMulHW,
2825 [(set i32:$rT, (mul i32:$rA, i32:$rB))]>;
2827 defm SUBF : XOForm_1r<31, 40, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2828 "subf", "$rT, $rA, $rB", IIC_IntGeneral,
2829 [(set i32:$rT, (sub i32:$rB, i32:$rA))]>;
2830 defm SUBFC : XOForm_1rc<31, 8, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2831 "subfc", "$rT, $rA, $rB", IIC_IntGeneral,
2832 [(set i32:$rT, (subc i32:$rB, i32:$rA))]>,
2833 PPC970_DGroup_Cracked;
2834 defm NEG : XOForm_3r<31, 104, 0, (outs gprc:$rT), (ins gprc:$rA),
2835 "neg", "$rT, $rA", IIC_IntSimple,
2836 [(set i32:$rT, (ineg i32:$rA))]>;
2837 let Uses = [CARRY] in {
2838 let isCommutable = 1 in
2839 defm ADDE : XOForm_1rc<31, 138, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2840 "adde", "$rT, $rA, $rB", IIC_IntGeneral,
2841 [(set i32:$rT, (adde i32:$rA, i32:$rB))]>;
2842 defm ADDME : XOForm_3rc<31, 234, 0, (outs gprc:$rT), (ins gprc:$rA),
2843 "addme", "$rT, $rA", IIC_IntGeneral,
2844 [(set i32:$rT, (adde i32:$rA, -1))]>;
2845 defm ADDZE : XOForm_3rc<31, 202, 0, (outs gprc:$rT), (ins gprc:$rA),
2846 "addze", "$rT, $rA", IIC_IntGeneral,
2847 [(set i32:$rT, (adde i32:$rA, 0))]>;
2848 defm SUBFE : XOForm_1rc<31, 136, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2849 "subfe", "$rT, $rA, $rB", IIC_IntGeneral,
2850 [(set i32:$rT, (sube i32:$rB, i32:$rA))]>;
2851 defm SUBFME : XOForm_3rc<31, 232, 0, (outs gprc:$rT), (ins gprc:$rA),
2852 "subfme", "$rT, $rA", IIC_IntGeneral,
2853 [(set i32:$rT, (sube -1, i32:$rA))]>;
2854 defm SUBFZE : XOForm_3rc<31, 200, 0, (outs gprc:$rT), (ins gprc:$rA),
2855 "subfze", "$rT, $rA", IIC_IntGeneral,
2856 [(set i32:$rT, (sube 0, i32:$rA))]>;
2860 // A-Form instructions. Most of the instructions executed in the FPU are of
2863 let PPC970_Unit = 3, hasSideEffects = 0, Predicates = [HasFPU] in { // FPU Operations.
2864 let Uses = [RM] in {
2865 let isCommutable = 1 in {
2866 defm FMADD : AForm_1r<63, 29,
2867 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2868 "fmadd", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2869 [(set f64:$FRT, (fma f64:$FRA, f64:$FRC, f64:$FRB))]>;
2870 defm FMADDS : AForm_1r<59, 29,
2871 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2872 "fmadds", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2873 [(set f32:$FRT, (fma f32:$FRA, f32:$FRC, f32:$FRB))]>;
2874 defm FMSUB : AForm_1r<63, 28,
2875 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2876 "fmsub", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2878 (fma f64:$FRA, f64:$FRC, (fneg f64:$FRB)))]>;
2879 defm FMSUBS : AForm_1r<59, 28,
2880 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2881 "fmsubs", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2883 (fma f32:$FRA, f32:$FRC, (fneg f32:$FRB)))]>;
2884 defm FNMADD : AForm_1r<63, 31,
2885 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2886 "fnmadd", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2888 (fneg (fma f64:$FRA, f64:$FRC, f64:$FRB)))]>;
2889 defm FNMADDS : AForm_1r<59, 31,
2890 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2891 "fnmadds", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2893 (fneg (fma f32:$FRA, f32:$FRC, f32:$FRB)))]>;
2894 defm FNMSUB : AForm_1r<63, 30,
2895 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2896 "fnmsub", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2897 [(set f64:$FRT, (fneg (fma f64:$FRA, f64:$FRC,
2898 (fneg f64:$FRB))))]>;
2899 defm FNMSUBS : AForm_1r<59, 30,
2900 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2901 "fnmsubs", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2902 [(set f32:$FRT, (fneg (fma f32:$FRA, f32:$FRC,
2903 (fneg f32:$FRB))))]>;
2906 // FSEL is artificially split into 4 and 8-byte forms for the result. To avoid
2907 // having 4 of these, force the comparison to always be an 8-byte double (code
2908 // should use an FMRSD if the input comparison value really wants to be a float)
2909 // and 4/8 byte forms for the result and operand type..
2910 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2911 defm FSELD : AForm_1r<63, 23,
2912 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2913 "fsel", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2914 [(set f64:$FRT, (PPCfsel f64:$FRA, f64:$FRC, f64:$FRB))]>;
2915 defm FSELS : AForm_1r<63, 23,
2916 (outs f4rc:$FRT), (ins f8rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2917 "fsel", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2918 [(set f32:$FRT, (PPCfsel f64:$FRA, f32:$FRC, f32:$FRB))]>;
2919 let Uses = [RM] in {
2920 let isCommutable = 1 in {
2921 defm FADD : AForm_2r<63, 21,
2922 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB),
2923 "fadd", "$FRT, $FRA, $FRB", IIC_FPAddSub,
2924 [(set f64:$FRT, (fadd f64:$FRA, f64:$FRB))]>;
2925 defm FADDS : AForm_2r<59, 21,
2926 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB),
2927 "fadds", "$FRT, $FRA, $FRB", IIC_FPGeneral,
2928 [(set f32:$FRT, (fadd f32:$FRA, f32:$FRB))]>;
2930 defm FDIV : AForm_2r<63, 18,
2931 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB),
2932 "fdiv", "$FRT, $FRA, $FRB", IIC_FPDivD,
2933 [(set f64:$FRT, (fdiv f64:$FRA, f64:$FRB))]>;
2934 defm FDIVS : AForm_2r<59, 18,
2935 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB),
2936 "fdivs", "$FRT, $FRA, $FRB", IIC_FPDivS,
2937 [(set f32:$FRT, (fdiv f32:$FRA, f32:$FRB))]>;
2938 let isCommutable = 1 in {
2939 defm FMUL : AForm_3r<63, 25,
2940 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC),
2941 "fmul", "$FRT, $FRA, $FRC", IIC_FPFused,
2942 [(set f64:$FRT, (fmul f64:$FRA, f64:$FRC))]>;
2943 defm FMULS : AForm_3r<59, 25,
2944 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC),
2945 "fmuls", "$FRT, $FRA, $FRC", IIC_FPGeneral,
2946 [(set f32:$FRT, (fmul f32:$FRA, f32:$FRC))]>;
2948 defm FSUB : AForm_2r<63, 20,
2949 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB),
2950 "fsub", "$FRT, $FRA, $FRB", IIC_FPAddSub,
2951 [(set f64:$FRT, (fsub f64:$FRA, f64:$FRB))]>;
2952 defm FSUBS : AForm_2r<59, 20,
2953 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB),
2954 "fsubs", "$FRT, $FRA, $FRB", IIC_FPGeneral,
2955 [(set f32:$FRT, (fsub f32:$FRA, f32:$FRB))]>;
2959 let hasSideEffects = 0 in {
2960 let PPC970_Unit = 1 in { // FXU Operations.
2962 def ISEL : AForm_4<31, 15,
2963 (outs gprc:$rT), (ins gprc_nor0:$rA, gprc:$rB, crbitrc:$cond),
2964 "isel $rT, $rA, $rB, $cond", IIC_IntISEL,
2968 let PPC970_Unit = 1 in { // FXU Operations.
2969 // M-Form instructions. rotate and mask instructions.
2971 let isCommutable = 1 in {
2972 // RLWIMI can be commuted if the rotate amount is zero.
2973 defm RLWIMI : MForm_2r<20, (outs gprc:$rA),
2974 (ins gprc:$rSi, gprc:$rS, u5imm:$SH, u5imm:$MB,
2975 u5imm:$ME), "rlwimi", "$rA, $rS, $SH, $MB, $ME",
2976 IIC_IntRotate, []>, PPC970_DGroup_Cracked,
2977 RegConstraint<"$rSi = $rA">, NoEncode<"$rSi">;
2979 let BaseName = "rlwinm" in {
2980 def RLWINM : MForm_2<21,
2981 (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
2982 "rlwinm $rA, $rS, $SH, $MB, $ME", IIC_IntGeneral,
2985 def RLWINMo : MForm_2<21,
2986 (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
2987 "rlwinm. $rA, $rS, $SH, $MB, $ME", IIC_IntGeneral,
2988 []>, isDOT, RecFormRel, PPC970_DGroup_Cracked;
2990 defm RLWNM : MForm_2r<23, (outs gprc:$rA),
2991 (ins gprc:$rS, gprc:$rB, u5imm:$MB, u5imm:$ME),
2992 "rlwnm", "$rA, $rS, $rB, $MB, $ME", IIC_IntGeneral,
2995 } // hasSideEffects = 0
2997 //===----------------------------------------------------------------------===//
2998 // PowerPC Instruction Patterns
3001 // Arbitrary immediate support. Implement in terms of LIS/ORI.
3002 def : Pat<(i32 imm:$imm),
3003 (ORI (LIS (HI16 imm:$imm)), (LO16 imm:$imm))>;
3005 // Implement the 'not' operation with the NOR instruction.
3006 def i32not : OutPatFrag<(ops node:$in),
3008 def : Pat<(not i32:$in),
3011 // ADD an arbitrary immediate.
3012 def : Pat<(add i32:$in, imm:$imm),
3013 (ADDIS (ADDI $in, (LO16 imm:$imm)), (HA16 imm:$imm))>;
3014 // OR an arbitrary immediate.
3015 def : Pat<(or i32:$in, imm:$imm),
3016 (ORIS (ORI $in, (LO16 imm:$imm)), (HI16 imm:$imm))>;
3017 // XOR an arbitrary immediate.
3018 def : Pat<(xor i32:$in, imm:$imm),
3019 (XORIS (XORI $in, (LO16 imm:$imm)), (HI16 imm:$imm))>;
3021 def : Pat<(sub imm32SExt16:$imm, i32:$in),
3022 (SUBFIC $in, imm:$imm)>;
3025 def : Pat<(shl i32:$in, (i32 imm:$imm)),
3026 (RLWINM $in, imm:$imm, 0, (SHL32 imm:$imm))>;
3027 def : Pat<(srl i32:$in, (i32 imm:$imm)),
3028 (RLWINM $in, (SRL32 imm:$imm), imm:$imm, 31)>;
3031 def : Pat<(rotl i32:$in, i32:$sh),
3032 (RLWNM $in, $sh, 0, 31)>;
3033 def : Pat<(rotl i32:$in, (i32 imm:$imm)),
3034 (RLWINM $in, imm:$imm, 0, 31)>;
3037 def : Pat<(and (rotl i32:$in, i32:$sh), maskimm32:$imm),
3038 (RLWNM $in, $sh, (MB maskimm32:$imm), (ME maskimm32:$imm))>;
3041 def : Pat<(PPCcall (i32 tglobaladdr:$dst)),
3042 (BL tglobaladdr:$dst)>;
3044 def : Pat<(PPCcall (i32 texternalsym:$dst)),
3045 (BL texternalsym:$dst)>;
3047 // Calls for AIX only
3048 def : Pat<(PPCcall (i32 mcsym:$dst)),
3050 def : Pat<(PPCcall_nop (i32 mcsym:$dst)),
3051 (BL_NOP mcsym:$dst)>;
3053 def : Pat<(PPCtc_return (i32 tglobaladdr:$dst), imm:$imm),
3054 (TCRETURNdi tglobaladdr:$dst, imm:$imm)>;
3056 def : Pat<(PPCtc_return (i32 texternalsym:$dst), imm:$imm),
3057 (TCRETURNdi texternalsym:$dst, imm:$imm)>;
3059 def : Pat<(PPCtc_return CTRRC:$dst, imm:$imm),
3060 (TCRETURNri CTRRC:$dst, imm:$imm)>;
3064 // Hi and Lo for Darwin Global Addresses.
3065 def : Pat<(PPChi tglobaladdr:$in, 0), (LIS tglobaladdr:$in)>;
3066 def : Pat<(PPClo tglobaladdr:$in, 0), (LI tglobaladdr:$in)>;
3067 def : Pat<(PPChi tconstpool:$in, 0), (LIS tconstpool:$in)>;
3068 def : Pat<(PPClo tconstpool:$in, 0), (LI tconstpool:$in)>;
3069 def : Pat<(PPChi tjumptable:$in, 0), (LIS tjumptable:$in)>;
3070 def : Pat<(PPClo tjumptable:$in, 0), (LI tjumptable:$in)>;
3071 def : Pat<(PPChi tblockaddress:$in, 0), (LIS tblockaddress:$in)>;
3072 def : Pat<(PPClo tblockaddress:$in, 0), (LI tblockaddress:$in)>;
3073 def : Pat<(PPChi tglobaltlsaddr:$g, i32:$in),
3074 (ADDIS $in, tglobaltlsaddr:$g)>;
3075 def : Pat<(PPClo tglobaltlsaddr:$g, i32:$in),
3076 (ADDI $in, tglobaltlsaddr:$g)>;
3077 def : Pat<(add i32:$in, (PPChi tglobaladdr:$g, 0)),
3078 (ADDIS $in, tglobaladdr:$g)>;
3079 def : Pat<(add i32:$in, (PPChi tconstpool:$g, 0)),
3080 (ADDIS $in, tconstpool:$g)>;
3081 def : Pat<(add i32:$in, (PPChi tjumptable:$g, 0)),
3082 (ADDIS $in, tjumptable:$g)>;
3083 def : Pat<(add i32:$in, (PPChi tblockaddress:$g, 0)),
3084 (ADDIS $in, tblockaddress:$g)>;
3086 // Support for thread-local storage.
3087 def PPC32GOT: PPCEmitTimePseudo<(outs gprc:$rD), (ins), "#PPC32GOT",
3088 [(set i32:$rD, (PPCppc32GOT))]>;
3090 // Get the _GLOBAL_OFFSET_TABLE_ in PIC mode.
3091 // This uses two output registers, the first as the real output, the second as a
3092 // temporary register, used internally in code generation.
3093 def PPC32PICGOT: PPCEmitTimePseudo<(outs gprc:$rD, gprc:$rT), (ins), "#PPC32PICGOT",
3094 []>, NoEncode<"$rT">;
3096 def LDgotTprelL32: PPCEmitTimePseudo<(outs gprc:$rD), (ins s16imm:$disp, gprc_nor0:$reg),
3099 (PPCldGotTprelL tglobaltlsaddr:$disp, i32:$reg))]>;
3100 def : Pat<(PPCaddTls i32:$in, tglobaltlsaddr:$g),
3101 (ADD4TLS $in, tglobaltlsaddr:$g)>;
3103 def ADDItlsgdL32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
3106 (PPCaddiTlsgdL i32:$reg, tglobaltlsaddr:$disp))]>;
3107 // LR is a true define, while the rest of the Defs are clobbers. R3 is
3108 // explicitly defined when this op is created, so not mentioned here.
3109 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
3110 Defs = [R0,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
3111 def GETtlsADDR32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc:$reg, tlsgd32:$sym),
3114 (PPCgetTlsAddr i32:$reg, tglobaltlsaddr:$sym))]>;
3115 // Combined op for ADDItlsgdL32 and GETtlsADDR32, late expanded. R3 and LR
3116 // are true defines while the rest of the Defs are clobbers.
3117 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
3118 Defs = [R0,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
3119 def ADDItlsgdLADDR32 : PPCEmitTimePseudo<(outs gprc:$rD),
3120 (ins gprc_nor0:$reg, s16imm:$disp, tlsgd32:$sym),
3121 "#ADDItlsgdLADDR32",
3123 (PPCaddiTlsgdLAddr i32:$reg,
3124 tglobaltlsaddr:$disp,
3125 tglobaltlsaddr:$sym))]>;
3126 def ADDItlsldL32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
3129 (PPCaddiTlsldL i32:$reg, tglobaltlsaddr:$disp))]>;
3130 // LR is a true define, while the rest of the Defs are clobbers. R3 is
3131 // explicitly defined when this op is created, so not mentioned here.
3132 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
3133 Defs = [R0,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
3134 def GETtlsldADDR32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc:$reg, tlsgd32:$sym),
3137 (PPCgetTlsldAddr i32:$reg,
3138 tglobaltlsaddr:$sym))]>;
3139 // Combined op for ADDItlsldL32 and GETtlsADDR32, late expanded. R3 and LR
3140 // are true defines while the rest of the Defs are clobbers.
3141 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
3142 Defs = [R0,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
3143 def ADDItlsldLADDR32 : PPCEmitTimePseudo<(outs gprc:$rD),
3144 (ins gprc_nor0:$reg, s16imm:$disp, tlsgd32:$sym),
3145 "#ADDItlsldLADDR32",
3147 (PPCaddiTlsldLAddr i32:$reg,
3148 tglobaltlsaddr:$disp,
3149 tglobaltlsaddr:$sym))]>;
3150 def ADDIdtprelL32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
3153 (PPCaddiDtprelL i32:$reg, tglobaltlsaddr:$disp))]>;
3154 def ADDISdtprelHA32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
3157 (PPCaddisDtprelHA i32:$reg,
3158 tglobaltlsaddr:$disp))]>;
3160 // Support for Position-independent code
3161 def LWZtoc : PPCEmitTimePseudo<(outs gprc:$rD), (ins tocentry32:$disp, gprc:$reg),
3164 (PPCtoc_entry tglobaladdr:$disp, i32:$reg))]>;
3165 // Get Global (GOT) Base Register offset, from the word immediately preceding
3166 // the function label.
3167 def UpdateGBR : PPCEmitTimePseudo<(outs gprc:$rD, gprc:$rT), (ins gprc:$rI), "#UpdateGBR", []>;
3170 // Standard shifts. These are represented separately from the real shifts above
3171 // so that we can distinguish between shifts that allow 5-bit and 6-bit shift
3173 def : Pat<(sra i32:$rS, i32:$rB),
3175 def : Pat<(srl i32:$rS, i32:$rB),
3177 def : Pat<(shl i32:$rS, i32:$rB),
3180 def : Pat<(zextloadi1 iaddr:$src),
3182 def : Pat<(zextloadi1 xaddr:$src),
3184 def : Pat<(extloadi1 iaddr:$src),
3186 def : Pat<(extloadi1 xaddr:$src),
3188 def : Pat<(extloadi8 iaddr:$src),
3190 def : Pat<(extloadi8 xaddr:$src),
3192 def : Pat<(extloadi16 iaddr:$src),
3194 def : Pat<(extloadi16 xaddr:$src),
3196 let Predicates = [HasFPU] in {
3197 def : Pat<(f64 (extloadf32 iaddr:$src)),
3198 (COPY_TO_REGCLASS (LFS iaddr:$src), F8RC)>;
3199 def : Pat<(f64 (extloadf32 xaddr:$src)),
3200 (COPY_TO_REGCLASS (LFSX xaddr:$src), F8RC)>;
3202 def : Pat<(f64 (fpextend f32:$src)),
3203 (COPY_TO_REGCLASS $src, F8RC)>;
3206 // Only seq_cst fences require the heavyweight sync (SYNC 0).
3207 // All others can use the lightweight sync (SYNC 1).
3208 // source: http://www.cl.cam.ac.uk/~pes20/cpp/cpp0xmappings.html
3209 // The rule for seq_cst is duplicated to work with both 64 bits and 32 bits
3210 // versions of Power.
3211 def : Pat<(atomic_fence (i64 7), (imm)), (SYNC 0)>, Requires<[HasSYNC]>;
3212 def : Pat<(atomic_fence (i32 7), (imm)), (SYNC 0)>, Requires<[HasSYNC]>;
3213 def : Pat<(atomic_fence (imm), (imm)), (SYNC 1)>, Requires<[HasSYNC]>;
3214 def : Pat<(atomic_fence (imm), (imm)), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
3216 let Predicates = [HasFPU] in {
3217 // Additional FNMSUB patterns: -a*c + b == -(a*c - b)
3218 def : Pat<(fma (fneg f64:$A), f64:$C, f64:$B),
3219 (FNMSUB $A, $C, $B)>;
3220 def : Pat<(fma f64:$A, (fneg f64:$C), f64:$B),
3221 (FNMSUB $A, $C, $B)>;
3222 def : Pat<(fma (fneg f32:$A), f32:$C, f32:$B),
3223 (FNMSUBS $A, $C, $B)>;
3224 def : Pat<(fma f32:$A, (fneg f32:$C), f32:$B),
3225 (FNMSUBS $A, $C, $B)>;
3227 // FCOPYSIGN's operand types need not agree.
3228 def : Pat<(fcopysign f64:$frB, f32:$frA),
3229 (FCPSGND (COPY_TO_REGCLASS $frA, F8RC), $frB)>;
3230 def : Pat<(fcopysign f32:$frB, f64:$frA),
3231 (FCPSGNS (COPY_TO_REGCLASS $frA, F4RC), $frB)>;
3234 include "PPCInstrAltivec.td"
3235 include "PPCInstrSPE.td"
3236 include "PPCInstr64Bit.td"
3237 include "PPCInstrVSX.td"
3238 include "PPCInstrQPX.td"
3239 include "PPCInstrHTM.td"
3241 def crnot : OutPatFrag<(ops node:$in),
3243 def : Pat<(not i1:$in),
3246 // Patterns for arithmetic i1 operations.
3247 def : Pat<(add i1:$a, i1:$b),
3249 def : Pat<(sub i1:$a, i1:$b),
3251 def : Pat<(mul i1:$a, i1:$b),
3254 // We're sometimes asked to materialize i1 -1, which is just 1 in this case
3255 // (-1 is used to mean all bits set).
3256 def : Pat<(i1 -1), (CRSET)>;
3258 // i1 extensions, implemented in terms of isel.
3259 def : Pat<(i32 (zext i1:$in)),
3260 (SELECT_I4 $in, (LI 1), (LI 0))>;
3261 def : Pat<(i32 (sext i1:$in)),
3262 (SELECT_I4 $in, (LI -1), (LI 0))>;
3264 def : Pat<(i64 (zext i1:$in)),
3265 (SELECT_I8 $in, (LI8 1), (LI8 0))>;
3266 def : Pat<(i64 (sext i1:$in)),
3267 (SELECT_I8 $in, (LI8 -1), (LI8 0))>;
3269 // FIXME: We should choose either a zext or a sext based on other constants
3271 def : Pat<(i32 (anyext i1:$in)),
3272 (SELECT_I4 $in, (LI 1), (LI 0))>;
3273 def : Pat<(i64 (anyext i1:$in)),
3274 (SELECT_I8 $in, (LI8 1), (LI8 0))>;
3276 // match setcc on i1 variables.
3294 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETLT)),
3296 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETULT)),
3315 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETLE)),
3317 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETULE)),
3320 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETEQ)),
3334 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETGE)),
3336 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETUGE)),
3350 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETGT)),
3352 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETUGT)),
3355 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETNE)),
3358 // match setcc on non-i1 (non-vector) variables. Note that SETUEQ, SETOGE,
3359 // SETOLE, SETONE, SETULT and SETUGT should be expanded by legalize for
3360 // floating-point types.
3362 multiclass CRNotPat<dag pattern, dag result> {
3363 def : Pat<pattern, (crnot result)>;
3364 def : Pat<(not pattern), result>;
3366 // We can also fold the crnot into an extension:
3367 def : Pat<(i32 (zext pattern)),
3368 (SELECT_I4 result, (LI 0), (LI 1))>;
3369 def : Pat<(i32 (sext pattern)),
3370 (SELECT_I4 result, (LI 0), (LI -1))>;
3372 // We can also fold the crnot into an extension:
3373 def : Pat<(i64 (zext pattern)),
3374 (SELECT_I8 result, (LI8 0), (LI8 1))>;
3375 def : Pat<(i64 (sext pattern)),
3376 (SELECT_I8 result, (LI8 0), (LI8 -1))>;
3378 // FIXME: We should choose either a zext or a sext based on other constants
3380 def : Pat<(i32 (anyext pattern)),
3381 (SELECT_I4 result, (LI 0), (LI 1))>;
3383 def : Pat<(i64 (anyext pattern)),
3384 (SELECT_I8 result, (LI8 0), (LI8 1))>;
3387 // FIXME: Because of what seems like a bug in TableGen's type-inference code,
3388 // we need to write imm:$imm in the output patterns below, not just $imm, or
3389 // else the resulting matcher will not correctly add the immediate operand
3390 // (making it a register operand instead).
3393 multiclass ExtSetCCPat<CondCode cc, PatFrag pfrag,
3394 OutPatFrag rfrag, OutPatFrag rfrag8> {
3395 def : Pat<(i32 (zext (i1 (pfrag i32:$s1, cc)))),
3397 def : Pat<(i64 (zext (i1 (pfrag i64:$s1, cc)))),
3399 def : Pat<(i64 (zext (i1 (pfrag i32:$s1, cc)))),
3400 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1), sub_32)>;
3401 def : Pat<(i32 (zext (i1 (pfrag i64:$s1, cc)))),
3402 (EXTRACT_SUBREG (rfrag8 $s1), sub_32)>;
3404 def : Pat<(i32 (anyext (i1 (pfrag i32:$s1, cc)))),
3406 def : Pat<(i64 (anyext (i1 (pfrag i64:$s1, cc)))),
3408 def : Pat<(i64 (anyext (i1 (pfrag i32:$s1, cc)))),
3409 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1), sub_32)>;
3410 def : Pat<(i32 (anyext (i1 (pfrag i64:$s1, cc)))),
3411 (EXTRACT_SUBREG (rfrag8 $s1), sub_32)>;
3414 // Note that we do all inversions below with i(32|64)not, instead of using
3415 // (xori x, 1) because on the A2 nor has single-cycle latency while xori
3416 // has 2-cycle latency.
3418 defm : ExtSetCCPat<SETEQ,
3419 PatFrag<(ops node:$in, node:$cc),
3420 (setcc $in, 0, $cc)>,
3421 OutPatFrag<(ops node:$in),
3422 (RLWINM (CNTLZW $in), 27, 31, 31)>,
3423 OutPatFrag<(ops node:$in),
3424 (RLDICL (CNTLZD $in), 58, 63)> >;
3426 defm : ExtSetCCPat<SETNE,
3427 PatFrag<(ops node:$in, node:$cc),
3428 (setcc $in, 0, $cc)>,
3429 OutPatFrag<(ops node:$in),
3430 (RLWINM (i32not (CNTLZW $in)), 27, 31, 31)>,
3431 OutPatFrag<(ops node:$in),
3432 (RLDICL (i64not (CNTLZD $in)), 58, 63)> >;
3434 defm : ExtSetCCPat<SETLT,
3435 PatFrag<(ops node:$in, node:$cc),
3436 (setcc $in, 0, $cc)>,
3437 OutPatFrag<(ops node:$in),
3438 (RLWINM $in, 1, 31, 31)>,
3439 OutPatFrag<(ops node:$in),
3440 (RLDICL $in, 1, 63)> >;
3442 defm : ExtSetCCPat<SETGE,
3443 PatFrag<(ops node:$in, node:$cc),
3444 (setcc $in, 0, $cc)>,
3445 OutPatFrag<(ops node:$in),
3446 (RLWINM (i32not $in), 1, 31, 31)>,
3447 OutPatFrag<(ops node:$in),
3448 (RLDICL (i64not $in), 1, 63)> >;
3450 defm : ExtSetCCPat<SETGT,
3451 PatFrag<(ops node:$in, node:$cc),
3452 (setcc $in, 0, $cc)>,
3453 OutPatFrag<(ops node:$in),
3454 (RLWINM (ANDC (NEG $in), $in), 1, 31, 31)>,
3455 OutPatFrag<(ops node:$in),
3456 (RLDICL (ANDC8 (NEG8 $in), $in), 1, 63)> >;
3458 defm : ExtSetCCPat<SETLE,
3459 PatFrag<(ops node:$in, node:$cc),
3460 (setcc $in, 0, $cc)>,
3461 OutPatFrag<(ops node:$in),
3462 (RLWINM (ORC $in, (NEG $in)), 1, 31, 31)>,
3463 OutPatFrag<(ops node:$in),
3464 (RLDICL (ORC8 $in, (NEG8 $in)), 1, 63)> >;
3466 defm : ExtSetCCPat<SETLT,
3467 PatFrag<(ops node:$in, node:$cc),
3468 (setcc $in, -1, $cc)>,
3469 OutPatFrag<(ops node:$in),
3470 (RLWINM (AND $in, (ADDI $in, 1)), 1, 31, 31)>,
3471 OutPatFrag<(ops node:$in),
3472 (RLDICL (AND8 $in, (ADDI8 $in, 1)), 1, 63)> >;
3474 defm : ExtSetCCPat<SETGE,
3475 PatFrag<(ops node:$in, node:$cc),
3476 (setcc $in, -1, $cc)>,
3477 OutPatFrag<(ops node:$in),
3478 (RLWINM (NAND $in, (ADDI $in, 1)), 1, 31, 31)>,
3479 OutPatFrag<(ops node:$in),
3480 (RLDICL (NAND8 $in, (ADDI8 $in, 1)), 1, 63)> >;
3482 defm : ExtSetCCPat<SETGT,
3483 PatFrag<(ops node:$in, node:$cc),
3484 (setcc $in, -1, $cc)>,
3485 OutPatFrag<(ops node:$in),
3486 (RLWINM (i32not $in), 1, 31, 31)>,
3487 OutPatFrag<(ops node:$in),
3488 (RLDICL (i64not $in), 1, 63)> >;
3490 defm : ExtSetCCPat<SETLE,
3491 PatFrag<(ops node:$in, node:$cc),
3492 (setcc $in, -1, $cc)>,
3493 OutPatFrag<(ops node:$in),
3494 (RLWINM $in, 1, 31, 31)>,
3495 OutPatFrag<(ops node:$in),
3496 (RLDICL $in, 1, 63)> >;
3498 // An extended SETCC with shift amount.
3499 multiclass ExtSetCCShiftPat<CondCode cc, PatFrag pfrag,
3500 OutPatFrag rfrag, OutPatFrag rfrag8> {
3501 def : Pat<(i32 (zext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
3503 def : Pat<(i64 (zext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
3505 def : Pat<(i64 (zext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
3506 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1, $sa), sub_32)>;
3507 def : Pat<(i32 (zext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
3508 (EXTRACT_SUBREG (rfrag8 $s1, $sa), sub_32)>;
3510 def : Pat<(i32 (anyext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
3512 def : Pat<(i64 (anyext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
3514 def : Pat<(i64 (anyext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
3515 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1, $sa), sub_32)>;
3516 def : Pat<(i32 (anyext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
3517 (EXTRACT_SUBREG (rfrag8 $s1, $sa), sub_32)>;
3520 defm : ExtSetCCShiftPat<SETNE,
3521 PatFrag<(ops node:$in, node:$sa, node:$cc),
3522 (setcc (and $in, (shl 1, $sa)), 0, $cc)>,
3523 OutPatFrag<(ops node:$in, node:$sa),
3524 (RLWNM $in, (SUBFIC $sa, 32), 31, 31)>,
3525 OutPatFrag<(ops node:$in, node:$sa),
3526 (RLDCL $in, (SUBFIC $sa, 64), 63)> >;
3528 defm : ExtSetCCShiftPat<SETEQ,
3529 PatFrag<(ops node:$in, node:$sa, node:$cc),
3530 (setcc (and $in, (shl 1, $sa)), 0, $cc)>,
3531 OutPatFrag<(ops node:$in, node:$sa),
3532 (RLWNM (i32not $in),
3533 (SUBFIC $sa, 32), 31, 31)>,
3534 OutPatFrag<(ops node:$in, node:$sa),
3535 (RLDCL (i64not $in),
3536 (SUBFIC $sa, 64), 63)> >;
3539 def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETULT)),
3540 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_lt)>;
3541 def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETLT)),
3542 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_lt)>;
3543 def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETUGT)),
3544 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_gt)>;
3545 def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETGT)),
3546 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_gt)>;
3547 def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETEQ)),
3548 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_eq)>;
3549 def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETEQ)),
3550 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_eq)>;
3552 // For non-equality comparisons, the default code would materialize the
3553 // constant, then compare against it, like this:
3555 // ori r2, r2, 22136
3558 // Since we are just comparing for equality, we can emit this instead:
3559 // xoris r0,r3,0x1234
3560 // cmplwi cr0,r0,0x5678
3563 def : Pat<(i1 (setcc i32:$s1, imm:$imm, SETEQ)),
3564 (EXTRACT_SUBREG (CMPLWI (XORIS $s1, (HI16 imm:$imm)),
3565 (LO16 imm:$imm)), sub_eq)>;
3567 defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETUGE)),
3568 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_lt)>;
3569 defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETGE)),
3570 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_lt)>;
3571 defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETULE)),
3572 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_gt)>;
3573 defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETLE)),
3574 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_gt)>;
3575 defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETNE)),
3576 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_eq)>;
3577 defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETNE)),
3578 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_eq)>;
3580 defm : CRNotPat<(i1 (setcc i32:$s1, imm:$imm, SETNE)),
3581 (EXTRACT_SUBREG (CMPLWI (XORIS $s1, (HI16 imm:$imm)),
3582 (LO16 imm:$imm)), sub_eq)>;
3584 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETULT)),
3585 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_lt)>;
3586 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETLT)),
3587 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_lt)>;
3588 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETUGT)),
3589 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_gt)>;
3590 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETGT)),
3591 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_gt)>;
3592 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETEQ)),
3593 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_eq)>;
3595 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETUGE)),
3596 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_lt)>;
3597 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETGE)),
3598 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_lt)>;
3599 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETULE)),
3600 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_gt)>;
3601 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETLE)),
3602 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_gt)>;
3603 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETNE)),
3604 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_eq)>;
3607 def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETULT)),
3608 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_lt)>;
3609 def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETLT)),
3610 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_lt)>;
3611 def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETUGT)),
3612 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_gt)>;
3613 def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETGT)),
3614 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_gt)>;
3615 def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETEQ)),
3616 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_eq)>;
3617 def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETEQ)),
3618 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_eq)>;
3620 // For non-equality comparisons, the default code would materialize the
3621 // constant, then compare against it, like this:
3623 // ori r2, r2, 22136
3626 // Since we are just comparing for equality, we can emit this instead:
3627 // xoris r0,r3,0x1234
3628 // cmpldi cr0,r0,0x5678
3631 def : Pat<(i1 (setcc i64:$s1, imm64ZExt32:$imm, SETEQ)),
3632 (EXTRACT_SUBREG (CMPLDI (XORIS8 $s1, (HI16 imm:$imm)),
3633 (LO16 imm:$imm)), sub_eq)>;
3635 defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETUGE)),
3636 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_lt)>;
3637 defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETGE)),
3638 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_lt)>;
3639 defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETULE)),
3640 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_gt)>;
3641 defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETLE)),
3642 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_gt)>;
3643 defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETNE)),
3644 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_eq)>;
3645 defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETNE)),
3646 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_eq)>;
3648 defm : CRNotPat<(i1 (setcc i64:$s1, imm64ZExt32:$imm, SETNE)),
3649 (EXTRACT_SUBREG (CMPLDI (XORIS8 $s1, (HI16 imm:$imm)),
3650 (LO16 imm:$imm)), sub_eq)>;
3652 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETULT)),
3653 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_lt)>;
3654 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETLT)),
3655 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_lt)>;
3656 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETUGT)),
3657 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_gt)>;
3658 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETGT)),
3659 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_gt)>;
3660 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETEQ)),
3661 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_eq)>;
3663 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETUGE)),
3664 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_lt)>;
3665 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETGE)),
3666 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_lt)>;
3667 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETULE)),
3668 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_gt)>;
3669 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETLE)),
3670 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_gt)>;
3671 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETNE)),
3672 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_eq)>;
3675 let Predicates = [HasFPU] in {
3676 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOLT)),
3677 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3678 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETLT)),
3679 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3680 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOGT)),
3681 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3682 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETGT)),
3683 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3684 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOEQ)),
3685 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3686 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETEQ)),
3687 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3688 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETUO)),
3689 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_un)>;
3691 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETUGE)),
3692 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3693 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETGE)),
3694 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3695 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETULE)),
3696 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3697 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETLE)),
3698 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3699 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETUNE)),
3700 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3701 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETNE)),
3702 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3703 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETO)),
3704 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_un)>;
3707 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOLT)),
3708 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3709 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETLT)),
3710 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3711 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOGT)),
3712 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3713 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETGT)),
3714 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3715 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOEQ)),
3716 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3717 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETEQ)),
3718 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3719 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETUO)),
3720 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_un)>;
3722 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETUGE)),
3723 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3724 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETGE)),
3725 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3726 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETULE)),
3727 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3728 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETLE)),
3729 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3730 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETUNE)),
3731 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3732 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETNE)),
3733 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3734 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETO)),
3735 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_un)>;
3738 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETOLT)),
3739 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_lt)>;
3740 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETLT)),
3741 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_lt)>;
3742 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETOGT)),
3743 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_gt)>;
3744 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETGT)),
3745 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_gt)>;
3746 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETOEQ)),
3747 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_eq)>;
3748 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETEQ)),
3749 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_eq)>;
3750 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETUO)),
3751 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_un)>;
3753 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETUGE)),
3754 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_lt)>;
3755 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETGE)),
3756 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_lt)>;
3757 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETULE)),
3758 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_gt)>;
3759 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETLE)),
3760 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_gt)>;
3761 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETUNE)),
3762 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_eq)>;
3763 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETNE)),
3764 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_eq)>;
3765 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETO)),
3766 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_un)>;
3770 // This must be in this file because it relies on patterns defined in this file
3771 // after the inclusion of the instruction sets.
3772 let Predicates = [HasSPE] in {
3774 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOLT)),
3775 (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>;
3776 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETLT)),
3777 (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>;
3778 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOGT)),
3779 (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>;
3780 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETGT)),
3781 (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>;
3782 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOEQ)),
3783 (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>;
3784 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETEQ)),
3785 (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>;
3787 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETUGE)),
3788 (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>;
3789 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETGE)),
3790 (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>;
3791 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETULE)),
3792 (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>;
3793 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETLE)),
3794 (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>;
3795 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETUNE)),
3796 (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>;
3797 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETNE)),
3798 (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>;
3801 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOLT)),
3802 (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>;
3803 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETLT)),
3804 (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>;
3805 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOGT)),
3806 (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>;
3807 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETGT)),
3808 (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>;
3809 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOEQ)),
3810 (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>;
3811 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETEQ)),
3812 (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>;
3814 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETUGE)),
3815 (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>;
3816 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETGE)),
3817 (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>;
3818 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETULE)),
3819 (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>;
3820 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETLE)),
3821 (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>;
3822 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETUNE)),
3823 (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>;
3824 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETNE)),
3825 (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>;
3827 // match select on i1 variables:
3828 def : Pat<(i1 (select i1:$cond, i1:$tval, i1:$fval)),
3829 (CROR (CRAND $cond , $tval),
3830 (CRAND (crnot $cond), $fval))>;
3832 // match selectcc on i1 variables:
3833 // select (lhs == rhs), tval, fval is:
3834 // ((lhs == rhs) & tval) | (!(lhs == rhs) & fval)
3835 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETLT)),
3836 (CROR (CRAND (CRANDC $lhs, $rhs), $tval),
3837 (CRAND (CRORC $rhs, $lhs), $fval))>;
3838 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETULT)),
3839 (CROR (CRAND (CRANDC $rhs, $lhs), $tval),
3840 (CRAND (CRORC $lhs, $rhs), $fval))>;
3841 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETLE)),
3842 (CROR (CRAND (CRORC $lhs, $rhs), $tval),
3843 (CRAND (CRANDC $rhs, $lhs), $fval))>;
3844 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETULE)),
3845 (CROR (CRAND (CRORC $rhs, $lhs), $tval),
3846 (CRAND (CRANDC $lhs, $rhs), $fval))>;
3847 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETEQ)),
3848 (CROR (CRAND (CREQV $lhs, $rhs), $tval),
3849 (CRAND (CRXOR $lhs, $rhs), $fval))>;
3850 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETGE)),
3851 (CROR (CRAND (CRORC $rhs, $lhs), $tval),
3852 (CRAND (CRANDC $lhs, $rhs), $fval))>;
3853 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETUGE)),
3854 (CROR (CRAND (CRORC $lhs, $rhs), $tval),
3855 (CRAND (CRANDC $rhs, $lhs), $fval))>;
3856 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETGT)),
3857 (CROR (CRAND (CRANDC $rhs, $lhs), $tval),
3858 (CRAND (CRORC $lhs, $rhs), $fval))>;
3859 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETUGT)),
3860 (CROR (CRAND (CRANDC $lhs, $rhs), $tval),
3861 (CRAND (CRORC $rhs, $lhs), $fval))>;
3862 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETNE)),
3863 (CROR (CRAND (CREQV $lhs, $rhs), $fval),
3864 (CRAND (CRXOR $lhs, $rhs), $tval))>;
3866 // match selectcc on i1 variables with non-i1 output.
3867 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETLT)),
3868 (SELECT_I4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3869 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETULT)),
3870 (SELECT_I4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3871 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETLE)),
3872 (SELECT_I4 (CRORC $lhs, $rhs), $tval, $fval)>;
3873 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETULE)),
3874 (SELECT_I4 (CRORC $rhs, $lhs), $tval, $fval)>;
3875 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETEQ)),
3876 (SELECT_I4 (CREQV $lhs, $rhs), $tval, $fval)>;
3877 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETGE)),
3878 (SELECT_I4 (CRORC $rhs, $lhs), $tval, $fval)>;
3879 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETUGE)),
3880 (SELECT_I4 (CRORC $lhs, $rhs), $tval, $fval)>;
3881 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETGT)),
3882 (SELECT_I4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3883 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETUGT)),
3884 (SELECT_I4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3885 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETNE)),
3886 (SELECT_I4 (CRXOR $lhs, $rhs), $tval, $fval)>;
3888 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETLT)),
3889 (SELECT_I8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3890 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETULT)),
3891 (SELECT_I8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3892 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETLE)),
3893 (SELECT_I8 (CRORC $lhs, $rhs), $tval, $fval)>;
3894 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETULE)),
3895 (SELECT_I8 (CRORC $rhs, $lhs), $tval, $fval)>;
3896 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETEQ)),
3897 (SELECT_I8 (CREQV $lhs, $rhs), $tval, $fval)>;
3898 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETGE)),
3899 (SELECT_I8 (CRORC $rhs, $lhs), $tval, $fval)>;
3900 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETUGE)),
3901 (SELECT_I8 (CRORC $lhs, $rhs), $tval, $fval)>;
3902 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETGT)),
3903 (SELECT_I8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3904 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETUGT)),
3905 (SELECT_I8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3906 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETNE)),
3907 (SELECT_I8 (CRXOR $lhs, $rhs), $tval, $fval)>;
3909 let Predicates = [HasFPU] in {
3910 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETLT)),
3911 (SELECT_F4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3912 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETULT)),
3913 (SELECT_F4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3914 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETLE)),
3915 (SELECT_F4 (CRORC $lhs, $rhs), $tval, $fval)>;
3916 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETULE)),
3917 (SELECT_F4 (CRORC $rhs, $lhs), $tval, $fval)>;
3918 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETEQ)),
3919 (SELECT_F4 (CREQV $lhs, $rhs), $tval, $fval)>;
3920 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETGE)),
3921 (SELECT_F4 (CRORC $rhs, $lhs), $tval, $fval)>;
3922 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETUGE)),
3923 (SELECT_F4 (CRORC $lhs, $rhs), $tval, $fval)>;
3924 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETGT)),
3925 (SELECT_F4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3926 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETUGT)),
3927 (SELECT_F4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3928 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETNE)),
3929 (SELECT_F4 (CRXOR $lhs, $rhs), $tval, $fval)>;
3931 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETLT)),
3932 (SELECT_F8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3933 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETULT)),
3934 (SELECT_F8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3935 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETLE)),
3936 (SELECT_F8 (CRORC $lhs, $rhs), $tval, $fval)>;
3937 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETULE)),
3938 (SELECT_F8 (CRORC $rhs, $lhs), $tval, $fval)>;
3939 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETEQ)),
3940 (SELECT_F8 (CREQV $lhs, $rhs), $tval, $fval)>;
3941 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETGE)),
3942 (SELECT_F8 (CRORC $rhs, $lhs), $tval, $fval)>;
3943 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETUGE)),
3944 (SELECT_F8 (CRORC $lhs, $rhs), $tval, $fval)>;
3945 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETGT)),
3946 (SELECT_F8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3947 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETUGT)),
3948 (SELECT_F8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3949 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETNE)),
3950 (SELECT_F8 (CRXOR $lhs, $rhs), $tval, $fval)>;
3953 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETLT)),
3954 (SELECT_F16 (CRANDC $lhs, $rhs), $tval, $fval)>;
3955 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETULT)),
3956 (SELECT_F16 (CRANDC $rhs, $lhs), $tval, $fval)>;
3957 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETLE)),
3958 (SELECT_F16 (CRORC $lhs, $rhs), $tval, $fval)>;
3959 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETULE)),
3960 (SELECT_F16 (CRORC $rhs, $lhs), $tval, $fval)>;
3961 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETEQ)),
3962 (SELECT_F16 (CREQV $lhs, $rhs), $tval, $fval)>;
3963 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETGE)),
3964 (SELECT_F16 (CRORC $rhs, $lhs), $tval, $fval)>;
3965 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETUGE)),
3966 (SELECT_F16 (CRORC $lhs, $rhs), $tval, $fval)>;
3967 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETGT)),
3968 (SELECT_F16 (CRANDC $rhs, $lhs), $tval, $fval)>;
3969 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETUGT)),
3970 (SELECT_F16 (CRANDC $lhs, $rhs), $tval, $fval)>;
3971 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETNE)),
3972 (SELECT_F16 (CRXOR $lhs, $rhs), $tval, $fval)>;
3974 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETLT)),
3975 (SELECT_VRRC (CRANDC $lhs, $rhs), $tval, $fval)>;
3976 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETULT)),
3977 (SELECT_VRRC (CRANDC $rhs, $lhs), $tval, $fval)>;
3978 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETLE)),
3979 (SELECT_VRRC (CRORC $lhs, $rhs), $tval, $fval)>;
3980 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETULE)),
3981 (SELECT_VRRC (CRORC $rhs, $lhs), $tval, $fval)>;
3982 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETEQ)),
3983 (SELECT_VRRC (CREQV $lhs, $rhs), $tval, $fval)>;
3984 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETGE)),
3985 (SELECT_VRRC (CRORC $rhs, $lhs), $tval, $fval)>;
3986 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETUGE)),
3987 (SELECT_VRRC (CRORC $lhs, $rhs), $tval, $fval)>;
3988 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETGT)),
3989 (SELECT_VRRC (CRANDC $rhs, $lhs), $tval, $fval)>;
3990 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETUGT)),
3991 (SELECT_VRRC (CRANDC $lhs, $rhs), $tval, $fval)>;
3992 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETNE)),
3993 (SELECT_VRRC (CRXOR $lhs, $rhs), $tval, $fval)>;
3995 def ANDIo_1_EQ_BIT : PPCCustomInserterPseudo<(outs crbitrc:$dst), (ins gprc:$in),
3997 [(set i1:$dst, (trunc (not i32:$in)))]>;
3998 def ANDIo_1_GT_BIT : PPCCustomInserterPseudo<(outs crbitrc:$dst), (ins gprc:$in),
4000 [(set i1:$dst, (trunc i32:$in))]>;
4002 def ANDIo_1_EQ_BIT8 : PPCCustomInserterPseudo<(outs crbitrc:$dst), (ins g8rc:$in),
4004 [(set i1:$dst, (trunc (not i64:$in)))]>;
4005 def ANDIo_1_GT_BIT8 : PPCCustomInserterPseudo<(outs crbitrc:$dst), (ins g8rc:$in),
4007 [(set i1:$dst, (trunc i64:$in))]>;
4009 def : Pat<(i1 (not (trunc i32:$in))),
4010 (ANDIo_1_EQ_BIT $in)>;
4011 def : Pat<(i1 (not (trunc i64:$in))),
4012 (ANDIo_1_EQ_BIT8 $in)>;
4014 //===----------------------------------------------------------------------===//
4015 // PowerPC Instructions used for assembler/disassembler only
4018 // FIXME: For B=0 or B > 8, the registers following RT are used.
4019 // WARNING: Do not add patterns for this instruction without fixing this.
4020 def LSWI : XForm_base_r3xo_memOp<31, 597, (outs gprc:$RT),
4021 (ins gprc:$A, u5imm:$B),
4022 "lswi $RT, $A, $B", IIC_LdStLoad, []>;
4024 // FIXME: For B=0 or B > 8, the registers following RT are used.
4025 // WARNING: Do not add patterns for this instruction without fixing this.
4026 def STSWI : XForm_base_r3xo_memOp<31, 725, (outs),
4027 (ins gprc:$RT, gprc:$A, u5imm:$B),
4028 "stswi $RT, $A, $B", IIC_LdStLoad, []>;
4030 def ISYNC : XLForm_2_ext<19, 150, 0, 0, 0, (outs), (ins),
4031 "isync", IIC_SprISYNC, []>;
4033 def ICBI : XForm_1a<31, 982, (outs), (ins memrr:$src),
4034 "icbi $src", IIC_LdStICBI, []>;
4036 // We used to have EIEIO as value but E[0-9A-Z] is a reserved name
4037 def EnforceIEIO : XForm_24_eieio<31, 854, (outs), (ins),
4038 "eieio", IIC_LdStLoad, []>;
4040 def WAIT : XForm_24_sync<31, 30, (outs), (ins i32imm:$L),
4041 "wait $L", IIC_LdStLoad, []>;
4043 def MBAR : XForm_mbar<31, 854, (outs), (ins u5imm:$MO),
4044 "mbar $MO", IIC_LdStLoad>, Requires<[IsBookE]>;
4046 def MTSR: XForm_sr<31, 210, (outs), (ins gprc:$RS, u4imm:$SR),
4047 "mtsr $SR, $RS", IIC_SprMTSR>;
4049 def MFSR: XForm_sr<31, 595, (outs gprc:$RS), (ins u4imm:$SR),
4050 "mfsr $RS, $SR", IIC_SprMFSR>;
4052 def MTSRIN: XForm_srin<31, 242, (outs), (ins gprc:$RS, gprc:$RB),
4053 "mtsrin $RS, $RB", IIC_SprMTSR>;
4055 def MFSRIN: XForm_srin<31, 659, (outs gprc:$RS), (ins gprc:$RB),
4056 "mfsrin $RS, $RB", IIC_SprMFSR>;
4058 def MTMSR: XForm_mtmsr<31, 146, (outs), (ins gprc:$RS, i32imm:$L),
4059 "mtmsr $RS, $L", IIC_SprMTMSR>;
4061 def WRTEE: XForm_mtmsr<31, 131, (outs), (ins gprc:$RS),
4062 "wrtee $RS", IIC_SprMTMSR>, Requires<[IsBookE]> {
4066 def WRTEEI: I<31, (outs), (ins i1imm:$E), "wrteei $E", IIC_SprMTMSR>,
4067 Requires<[IsBookE]> {
4071 let Inst{21-30} = 163;
4074 def DCCCI : XForm_tlb<454, (outs), (ins gprc:$A, gprc:$B),
4075 "dccci $A, $B", IIC_LdStLoad>, Requires<[IsPPC4xx]>;
4076 def ICCCI : XForm_tlb<966, (outs), (ins gprc:$A, gprc:$B),
4077 "iccci $A, $B", IIC_LdStLoad>, Requires<[IsPPC4xx]>;
4079 def : InstAlias<"dci 0", (DCCCI R0, R0)>, Requires<[IsPPC4xx]>;
4080 def : InstAlias<"dccci", (DCCCI R0, R0)>, Requires<[IsPPC4xx]>;
4081 def : InstAlias<"ici 0", (ICCCI R0, R0)>, Requires<[IsPPC4xx]>;
4082 def : InstAlias<"iccci", (ICCCI R0, R0)>, Requires<[IsPPC4xx]>;
4084 def MFMSR : XForm_rs<31, 83, (outs gprc:$RT), (ins),
4085 "mfmsr $RT", IIC_SprMFMSR, []>;
4087 def MTMSRD : XForm_mtmsr<31, 178, (outs), (ins gprc:$RS, i32imm:$L),
4088 "mtmsrd $RS, $L", IIC_SprMTMSRD>;
4090 def MCRFS : XLForm_3<63, 64, (outs crrc:$BF), (ins crrc:$BFA),
4091 "mcrfs $BF, $BFA", IIC_BrMCR>;
4093 def MTFSFI : XLForm_4<63, 134, (outs crrc:$BF), (ins i32imm:$U, i32imm:$W),
4094 "mtfsfi $BF, $U, $W", IIC_IntMFFS>;
4096 def MTFSFIo : XLForm_4<63, 134, (outs crrc:$BF), (ins i32imm:$U, i32imm:$W),
4097 "mtfsfi. $BF, $U, $W", IIC_IntMFFS>, isDOT;
4099 def : InstAlias<"mtfsfi $BF, $U", (MTFSFI crrc:$BF, i32imm:$U, 0)>;
4100 def : InstAlias<"mtfsfi. $BF, $U", (MTFSFIo crrc:$BF, i32imm:$U, 0)>;
4102 let Predicates = [HasFPU] in {
4103 def MTFSF : XFLForm_1<63, 711, (outs),
4104 (ins i32imm:$FLM, f8rc:$FRB, i32imm:$L, i32imm:$W),
4105 "mtfsf $FLM, $FRB, $L, $W", IIC_IntMFFS, []>;
4106 def MTFSFo : XFLForm_1<63, 711, (outs),
4107 (ins i32imm:$FLM, f8rc:$FRB, i32imm:$L, i32imm:$W),
4108 "mtfsf. $FLM, $FRB, $L, $W", IIC_IntMFFS, []>, isDOT;
4110 def : InstAlias<"mtfsf $FLM, $FRB", (MTFSF i32imm:$FLM, f8rc:$FRB, 0, 0)>;
4111 def : InstAlias<"mtfsf. $FLM, $FRB", (MTFSFo i32imm:$FLM, f8rc:$FRB, 0, 0)>;
4114 def SLBIE : XForm_16b<31, 434, (outs), (ins gprc:$RB),
4115 "slbie $RB", IIC_SprSLBIE, []>;
4117 def SLBMTE : XForm_26<31, 402, (outs), (ins gprc:$RS, gprc:$RB),
4118 "slbmte $RS, $RB", IIC_SprSLBMTE, []>;
4120 def SLBMFEE : XForm_26<31, 915, (outs gprc:$RT), (ins gprc:$RB),
4121 "slbmfee $RT, $RB", IIC_SprSLBMFEE, []>;
4123 def SLBMFEV : XLForm_1_gen<31, 851, (outs gprc:$RT), (ins gprc:$RB),
4124 "slbmfev $RT, $RB", IIC_SprSLBMFEV, []>;
4126 def SLBIA : XForm_0<31, 498, (outs), (ins), "slbia", IIC_SprSLBIA, []>;
4129 def SLBFEEo : XForm_26<31, 979, (outs gprc:$RT), (ins gprc:$RB),
4130 "slbfee. $RT, $RB", IIC_SprSLBFEE, []>, isDOT;
4132 def TLBIA : XForm_0<31, 370, (outs), (ins),
4133 "tlbia", IIC_SprTLBIA, []>;
4135 def TLBSYNC : XForm_0<31, 566, (outs), (ins),
4136 "tlbsync", IIC_SprTLBSYNC, []>;
4138 def TLBIEL : XForm_16b<31, 274, (outs), (ins gprc:$RB),
4139 "tlbiel $RB", IIC_SprTLBIEL, []>;
4141 def TLBLD : XForm_16b<31, 978, (outs), (ins gprc:$RB),
4142 "tlbld $RB", IIC_LdStLoad, []>, Requires<[IsPPC6xx]>;
4143 def TLBLI : XForm_16b<31, 1010, (outs), (ins gprc:$RB),
4144 "tlbli $RB", IIC_LdStLoad, []>, Requires<[IsPPC6xx]>;
4146 def TLBIE : XForm_26<31, 306, (outs), (ins gprc:$RS, gprc:$RB),
4147 "tlbie $RB,$RS", IIC_SprTLBIE, []>;
4149 def TLBSX : XForm_tlb<914, (outs), (ins gprc:$A, gprc:$B), "tlbsx $A, $B",
4150 IIC_LdStLoad>, Requires<[IsBookE]>;
4152 def TLBIVAX : XForm_tlb<786, (outs), (ins gprc:$A, gprc:$B), "tlbivax $A, $B",
4153 IIC_LdStLoad>, Requires<[IsBookE]>;
4155 def TLBRE : XForm_24_eieio<31, 946, (outs), (ins),
4156 "tlbre", IIC_LdStLoad, []>, Requires<[IsBookE]>;
4158 def TLBWE : XForm_24_eieio<31, 978, (outs), (ins),
4159 "tlbwe", IIC_LdStLoad, []>, Requires<[IsBookE]>;
4161 def TLBRE2 : XForm_tlbws<31, 946, (outs gprc:$RS), (ins gprc:$A, i1imm:$WS),
4162 "tlbre $RS, $A, $WS", IIC_LdStLoad, []>, Requires<[IsPPC4xx]>;
4164 def TLBWE2 : XForm_tlbws<31, 978, (outs), (ins gprc:$RS, gprc:$A, i1imm:$WS),
4165 "tlbwe $RS, $A, $WS", IIC_LdStLoad, []>, Requires<[IsPPC4xx]>;
4167 def TLBSX2 : XForm_base_r3xo<31, 914, (outs), (ins gprc:$RST, gprc:$A, gprc:$B),
4168 "tlbsx $RST, $A, $B", IIC_LdStLoad, []>,
4169 Requires<[IsPPC4xx]>;
4170 def TLBSX2D : XForm_base_r3xo<31, 914, (outs),
4171 (ins gprc:$RST, gprc:$A, gprc:$B),
4172 "tlbsx. $RST, $A, $B", IIC_LdStLoad, []>,
4173 Requires<[IsPPC4xx]>, isDOT;
4175 def RFID : XForm_0<19, 18, (outs), (ins), "rfid", IIC_IntRFID, []>;
4177 def RFI : XForm_0<19, 50, (outs), (ins), "rfi", IIC_SprRFI, []>,
4178 Requires<[IsBookE]>;
4179 def RFCI : XForm_0<19, 51, (outs), (ins), "rfci", IIC_BrB, []>,
4180 Requires<[IsBookE]>;
4182 def RFDI : XForm_0<19, 39, (outs), (ins), "rfdi", IIC_BrB, []>,
4184 def RFMCI : XForm_0<19, 38, (outs), (ins), "rfmci", IIC_BrB, []>,
4187 def MFDCR : XFXForm_1<31, 323, (outs gprc:$RT), (ins i32imm:$SPR),
4188 "mfdcr $RT, $SPR", IIC_SprMFSPR>, Requires<[IsPPC4xx]>;
4189 def MTDCR : XFXForm_1<31, 451, (outs), (ins gprc:$RT, i32imm:$SPR),
4190 "mtdcr $SPR, $RT", IIC_SprMTSPR>, Requires<[IsPPC4xx]>;
4192 def HRFID : XLForm_1_np<19, 274, (outs), (ins), "hrfid", IIC_BrB, []>;
4193 def NAP : XLForm_1_np<19, 434, (outs), (ins), "nap", IIC_BrB, []>;
4195 def ATTN : XForm_attn<0, 256, (outs), (ins), "attn", IIC_BrB>;
4197 def LBZCIX : XForm_base_r3xo_memOp<31, 853, (outs gprc:$RST),
4198 (ins gprc:$A, gprc:$B),
4199 "lbzcix $RST, $A, $B", IIC_LdStLoad, []>;
4200 def LHZCIX : XForm_base_r3xo_memOp<31, 821, (outs gprc:$RST),
4201 (ins gprc:$A, gprc:$B),
4202 "lhzcix $RST, $A, $B", IIC_LdStLoad, []>;
4203 def LWZCIX : XForm_base_r3xo_memOp<31, 789, (outs gprc:$RST),
4204 (ins gprc:$A, gprc:$B),
4205 "lwzcix $RST, $A, $B", IIC_LdStLoad, []>;
4206 def LDCIX : XForm_base_r3xo_memOp<31, 885, (outs gprc:$RST),
4207 (ins gprc:$A, gprc:$B),
4208 "ldcix $RST, $A, $B", IIC_LdStLoad, []>;
4210 def STBCIX : XForm_base_r3xo_memOp<31, 981, (outs),
4211 (ins gprc:$RST, gprc:$A, gprc:$B),
4212 "stbcix $RST, $A, $B", IIC_LdStLoad, []>;
4213 def STHCIX : XForm_base_r3xo_memOp<31, 949, (outs),
4214 (ins gprc:$RST, gprc:$A, gprc:$B),
4215 "sthcix $RST, $A, $B", IIC_LdStLoad, []>;
4216 def STWCIX : XForm_base_r3xo_memOp<31, 917, (outs),
4217 (ins gprc:$RST, gprc:$A, gprc:$B),
4218 "stwcix $RST, $A, $B", IIC_LdStLoad, []>;
4219 def STDCIX : XForm_base_r3xo_memOp<31, 1013, (outs),
4220 (ins gprc:$RST, gprc:$A, gprc:$B),
4221 "stdcix $RST, $A, $B", IIC_LdStLoad, []>;
4223 // External PID Load Store Instructions
4225 def LBEPX : XForm_1<31, 95, (outs gprc:$rD), (ins memrr:$src),
4226 "lbepx $rD, $src", IIC_LdStLoad, []>,
4229 def LFDEPX : XForm_25<31, 607, (outs f8rc:$frD), (ins memrr:$src),
4230 "lfdepx $frD, $src", IIC_LdStLFD, []>,
4233 def LHEPX : XForm_1<31, 287, (outs gprc:$rD), (ins memrr:$src),
4234 "lhepx $rD, $src", IIC_LdStLoad, []>,
4237 def LWEPX : XForm_1<31, 31, (outs gprc:$rD), (ins memrr:$src),
4238 "lwepx $rD, $src", IIC_LdStLoad, []>,
4241 def STBEPX : XForm_8<31, 223, (outs), (ins gprc:$rS, memrr:$dst),
4242 "stbepx $rS, $dst", IIC_LdStStore, []>,
4245 def STFDEPX : XForm_28_memOp<31, 735, (outs), (ins f8rc:$frS, memrr:$dst),
4246 "stfdepx $frS, $dst", IIC_LdStSTFD, []>,
4249 def STHEPX : XForm_8<31, 415, (outs), (ins gprc:$rS, memrr:$dst),
4250 "sthepx $rS, $dst", IIC_LdStStore, []>,
4253 def STWEPX : XForm_8<31, 159, (outs), (ins gprc:$rS, memrr:$dst),
4254 "stwepx $rS, $dst", IIC_LdStStore, []>,
4257 def DCBFEP : DCB_Form<127, 0, (outs), (ins memrr:$dst), "dcbfep $dst",
4258 IIC_LdStDCBF, []>, Requires<[IsE500]>;
4260 def DCBSTEP : DCB_Form<63, 0, (outs), (ins memrr:$dst), "dcbstep $dst",
4261 IIC_LdStDCBF, []>, Requires<[IsE500]>;
4263 def DCBTEP : DCB_Form_hint<319, (outs), (ins memrr:$dst, u5imm:$TH),
4264 "dcbtep $TH, $dst", IIC_LdStDCBF, []>,
4267 def DCBTSTEP : DCB_Form_hint<255, (outs), (ins memrr:$dst, u5imm:$TH),
4268 "dcbtstep $TH, $dst", IIC_LdStDCBF, []>,
4271 def DCBZEP : DCB_Form<1023, 0, (outs), (ins memrr:$dst), "dcbzep $dst",
4272 IIC_LdStDCBF, []>, Requires<[IsE500]>;
4274 def DCBZLEP : DCB_Form<1023, 1, (outs), (ins memrr:$dst), "dcbzlep $dst",
4275 IIC_LdStDCBF, []>, Requires<[IsE500]>;
4277 def ICBIEP : XForm_1a<31, 991, (outs), (ins memrr:$src), "icbiep $src",
4278 IIC_LdStICBI, []>, Requires<[IsE500]>;
4280 //===----------------------------------------------------------------------===//
4281 // PowerPC Assembler Instruction Aliases
4284 // Pseudo-instructions for alternate assembly syntax (never used by codegen).
4285 // These are aliases that require C++ handling to convert to the target
4286 // instruction, while InstAliases can be handled directly by tblgen.
4287 class PPCAsmPseudo<string asm, dag iops>
4289 let Namespace = "PPC";
4290 bit PPC64 = 0; // Default value, override with isPPC64
4292 let OutOperandList = (outs);
4293 let InOperandList = iops;
4295 let AsmString = asm;
4296 let isAsmParserOnly = 1;
4298 let hasNoSchedulingInfo = 1;
4301 def : InstAlias<"sc", (SC 0)>;
4303 def : InstAlias<"sync", (SYNC 0)>, Requires<[HasSYNC]>;
4304 def : InstAlias<"msync", (SYNC 0), 0>, Requires<[HasSYNC]>;
4305 def : InstAlias<"lwsync", (SYNC 1)>, Requires<[HasSYNC]>;
4306 def : InstAlias<"ptesync", (SYNC 2)>, Requires<[HasSYNC]>;
4308 def : InstAlias<"wait", (WAIT 0)>;
4309 def : InstAlias<"waitrsv", (WAIT 1)>;
4310 def : InstAlias<"waitimpl", (WAIT 2)>;
4312 def : InstAlias<"mbar", (MBAR 0)>, Requires<[IsBookE]>;
4314 def DCBTx : PPCAsmPseudo<"dcbt $dst", (ins memrr:$dst)>;
4315 def DCBTSTx : PPCAsmPseudo<"dcbtst $dst", (ins memrr:$dst)>;
4317 def DCBTCT : PPCAsmPseudo<"dcbtct $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
4318 def DCBTDS : PPCAsmPseudo<"dcbtds $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
4319 def DCBTT : PPCAsmPseudo<"dcbtt $dst", (ins memrr:$dst)>;
4321 def DCBTSTCT : PPCAsmPseudo<"dcbtstct $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
4322 def DCBTSTDS : PPCAsmPseudo<"dcbtstds $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
4323 def DCBTSTT : PPCAsmPseudo<"dcbtstt $dst", (ins memrr:$dst)>;
4325 def DCBFx : PPCAsmPseudo<"dcbf $dst", (ins memrr:$dst)>;
4326 def DCBFL : PPCAsmPseudo<"dcbfl $dst", (ins memrr:$dst)>;
4327 def DCBFLP : PPCAsmPseudo<"dcbflp $dst", (ins memrr:$dst)>;
4329 def : InstAlias<"crset $bx", (CREQV crbitrc:$bx, crbitrc:$bx, crbitrc:$bx)>;
4330 def : InstAlias<"crclr $bx", (CRXOR crbitrc:$bx, crbitrc:$bx, crbitrc:$bx)>;
4331 def : InstAlias<"crmove $bx, $by", (CROR crbitrc:$bx, crbitrc:$by, crbitrc:$by)>;
4332 def : InstAlias<"crnot $bx, $by", (CRNOR crbitrc:$bx, crbitrc:$by, crbitrc:$by)>;
4334 def : InstAlias<"mtxer $Rx", (MTSPR 1, gprc:$Rx)>;
4335 def : InstAlias<"mfxer $Rx", (MFSPR gprc:$Rx, 1)>;
4337 def : InstAlias<"mfrtcu $Rx", (MFSPR gprc:$Rx, 4)>;
4338 def : InstAlias<"mfrtcl $Rx", (MFSPR gprc:$Rx, 5)>;
4340 def : InstAlias<"mtdscr $Rx", (MTSPR 17, gprc:$Rx)>;
4341 def : InstAlias<"mfdscr $Rx", (MFSPR gprc:$Rx, 17)>;
4343 def : InstAlias<"mtdsisr $Rx", (MTSPR 18, gprc:$Rx)>;
4344 def : InstAlias<"mfdsisr $Rx", (MFSPR gprc:$Rx, 18)>;
4346 def : InstAlias<"mtdar $Rx", (MTSPR 19, gprc:$Rx)>;
4347 def : InstAlias<"mfdar $Rx", (MFSPR gprc:$Rx, 19)>;
4349 def : InstAlias<"mtdec $Rx", (MTSPR 22, gprc:$Rx)>;
4350 def : InstAlias<"mfdec $Rx", (MFSPR gprc:$Rx, 22)>;
4352 def : InstAlias<"mtsdr1 $Rx", (MTSPR 25, gprc:$Rx)>;
4353 def : InstAlias<"mfsdr1 $Rx", (MFSPR gprc:$Rx, 25)>;
4355 def : InstAlias<"mtsrr0 $Rx", (MTSPR 26, gprc:$Rx)>;
4356 def : InstAlias<"mfsrr0 $Rx", (MFSPR gprc:$Rx, 26)>;
4358 def : InstAlias<"mtsrr1 $Rx", (MTSPR 27, gprc:$Rx)>;
4359 def : InstAlias<"mfsrr1 $Rx", (MFSPR gprc:$Rx, 27)>;
4361 def : InstAlias<"mtsrr2 $Rx", (MTSPR 990, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4362 def : InstAlias<"mfsrr2 $Rx", (MFSPR gprc:$Rx, 990)>, Requires<[IsPPC4xx]>;
4364 def : InstAlias<"mtsrr3 $Rx", (MTSPR 991, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4365 def : InstAlias<"mfsrr3 $Rx", (MFSPR gprc:$Rx, 991)>, Requires<[IsPPC4xx]>;
4367 def : InstAlias<"mtcfar $Rx", (MTSPR 28, gprc:$Rx)>;
4368 def : InstAlias<"mfcfar $Rx", (MFSPR gprc:$Rx, 28)>;
4370 def : InstAlias<"mtamr $Rx", (MTSPR 29, gprc:$Rx)>;
4371 def : InstAlias<"mfamr $Rx", (MFSPR gprc:$Rx, 29)>;
4373 def : InstAlias<"mtpid $Rx", (MTSPR 48, gprc:$Rx)>, Requires<[IsBookE]>;
4374 def : InstAlias<"mfpid $Rx", (MFSPR gprc:$Rx, 48)>, Requires<[IsBookE]>;
4376 def : InstAlias<"mftb $Rx", (MFTB gprc:$Rx, 268)>;
4377 def : InstAlias<"mftbl $Rx", (MFTB gprc:$Rx, 268)>;
4378 def : InstAlias<"mftbu $Rx", (MFTB gprc:$Rx, 269)>;
4380 def : InstAlias<"mttbl $Rx", (MTSPR 284, gprc:$Rx)>;
4381 def : InstAlias<"mttbu $Rx", (MTSPR 285, gprc:$Rx)>;
4383 def : InstAlias<"mftblo $Rx", (MFSPR gprc:$Rx, 989)>, Requires<[IsPPC4xx]>;
4384 def : InstAlias<"mttblo $Rx", (MTSPR 989, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4385 def : InstAlias<"mftbhi $Rx", (MFSPR gprc:$Rx, 988)>, Requires<[IsPPC4xx]>;
4386 def : InstAlias<"mttbhi $Rx", (MTSPR 988, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4388 def : InstAlias<"xnop", (XORI R0, R0, 0)>;
4390 def : InstAlias<"mr $rA, $rB", (OR8 g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
4391 def : InstAlias<"mr. $rA, $rB", (OR8o g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
4393 def : InstAlias<"not $rA, $rB", (NOR8 g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
4394 def : InstAlias<"not. $rA, $rB", (NOR8o g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
4396 def : InstAlias<"mtcr $rA", (MTCRF8 255, g8rc:$rA)>;
4398 foreach BATR = 0-3 in {
4399 def : InstAlias<"mtdbatu "#BATR#", $Rx",
4400 (MTSPR !add(BATR, !add(BATR, 536)), gprc:$Rx)>,
4401 Requires<[IsPPC6xx]>;
4402 def : InstAlias<"mfdbatu $Rx, "#BATR,
4403 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 536)))>,
4404 Requires<[IsPPC6xx]>;
4405 def : InstAlias<"mtdbatl "#BATR#", $Rx",
4406 (MTSPR !add(BATR, !add(BATR, 537)), gprc:$Rx)>,
4407 Requires<[IsPPC6xx]>;
4408 def : InstAlias<"mfdbatl $Rx, "#BATR,
4409 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 537)))>,
4410 Requires<[IsPPC6xx]>;
4411 def : InstAlias<"mtibatu "#BATR#", $Rx",
4412 (MTSPR !add(BATR, !add(BATR, 528)), gprc:$Rx)>,
4413 Requires<[IsPPC6xx]>;
4414 def : InstAlias<"mfibatu $Rx, "#BATR,
4415 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 528)))>,
4416 Requires<[IsPPC6xx]>;
4417 def : InstAlias<"mtibatl "#BATR#", $Rx",
4418 (MTSPR !add(BATR, !add(BATR, 529)), gprc:$Rx)>,
4419 Requires<[IsPPC6xx]>;
4420 def : InstAlias<"mfibatl $Rx, "#BATR,
4421 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 529)))>,
4422 Requires<[IsPPC6xx]>;
4425 foreach BR = 0-7 in {
4426 def : InstAlias<"mfbr"#BR#" $Rx",
4427 (MFDCR gprc:$Rx, !add(BR, 0x80))>,
4428 Requires<[IsPPC4xx]>;
4429 def : InstAlias<"mtbr"#BR#" $Rx",
4430 (MTDCR gprc:$Rx, !add(BR, 0x80))>,
4431 Requires<[IsPPC4xx]>;
4434 def : InstAlias<"mtdccr $Rx", (MTSPR 1018, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4435 def : InstAlias<"mfdccr $Rx", (MFSPR gprc:$Rx, 1018)>, Requires<[IsPPC4xx]>;
4437 def : InstAlias<"mticcr $Rx", (MTSPR 1019, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4438 def : InstAlias<"mficcr $Rx", (MFSPR gprc:$Rx, 1019)>, Requires<[IsPPC4xx]>;
4440 def : InstAlias<"mtdear $Rx", (MTSPR 981, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4441 def : InstAlias<"mfdear $Rx", (MFSPR gprc:$Rx, 981)>, Requires<[IsPPC4xx]>;
4443 def : InstAlias<"mtesr $Rx", (MTSPR 980, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4444 def : InstAlias<"mfesr $Rx", (MFSPR gprc:$Rx, 980)>, Requires<[IsPPC4xx]>;
4446 def : InstAlias<"mfspefscr $Rx", (MFSPR gprc:$Rx, 512)>;
4447 def : InstAlias<"mtspefscr $Rx", (MTSPR 512, gprc:$Rx)>;
4449 def : InstAlias<"mttcr $Rx", (MTSPR 986, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4450 def : InstAlias<"mftcr $Rx", (MFSPR gprc:$Rx, 986)>, Requires<[IsPPC4xx]>;
4452 def LAx : PPCAsmPseudo<"la $rA, $addr", (ins gprc:$rA, memri:$addr)>;
4454 def SUBI : PPCAsmPseudo<"subi $rA, $rB, $imm",
4455 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4456 def SUBIS : PPCAsmPseudo<"subis $rA, $rB, $imm",
4457 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4458 def SUBIC : PPCAsmPseudo<"subic $rA, $rB, $imm",
4459 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4460 def SUBICo : PPCAsmPseudo<"subic. $rA, $rB, $imm",
4461 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4463 def : InstAlias<"sub $rA, $rB, $rC", (SUBF8 g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
4464 def : InstAlias<"sub. $rA, $rB, $rC", (SUBF8o g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
4465 def : InstAlias<"subc $rA, $rB, $rC", (SUBFC8 g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
4466 def : InstAlias<"subc. $rA, $rB, $rC", (SUBFC8o g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
4468 def : InstAlias<"mtmsrd $RS", (MTMSRD gprc:$RS, 0)>;
4469 def : InstAlias<"mtmsr $RS", (MTMSR gprc:$RS, 0)>;
4471 def : InstAlias<"mfasr $RT", (MFSPR gprc:$RT, 280)>;
4472 def : InstAlias<"mtasr $RT", (MTSPR 280, gprc:$RT)>;
4474 foreach SPRG = 0-3 in {
4475 def : InstAlias<"mfsprg $RT, "#SPRG, (MFSPR gprc:$RT, !add(SPRG, 272))>;
4476 def : InstAlias<"mfsprg"#SPRG#" $RT", (MFSPR gprc:$RT, !add(SPRG, 272))>;
4477 def : InstAlias<"mtsprg "#SPRG#", $RT", (MTSPR !add(SPRG, 272), gprc:$RT)>;
4478 def : InstAlias<"mtsprg"#SPRG#" $RT", (MTSPR !add(SPRG, 272), gprc:$RT)>;
4480 foreach SPRG = 4-7 in {
4481 def : InstAlias<"mfsprg $RT, "#SPRG, (MFSPR gprc:$RT, !add(SPRG, 256))>,
4482 Requires<[IsBookE]>;
4483 def : InstAlias<"mfsprg"#SPRG#" $RT", (MFSPR gprc:$RT, !add(SPRG, 256))>,
4484 Requires<[IsBookE]>;
4485 def : InstAlias<"mtsprg "#SPRG#", $RT", (MTSPR !add(SPRG, 256), gprc:$RT)>,
4486 Requires<[IsBookE]>;
4487 def : InstAlias<"mtsprg"#SPRG#" $RT", (MTSPR !add(SPRG, 256), gprc:$RT)>,
4488 Requires<[IsBookE]>;
4491 def : InstAlias<"mtasr $RS", (MTSPR 280, gprc:$RS)>;
4493 def : InstAlias<"mfdec $RT", (MFSPR gprc:$RT, 22)>;
4494 def : InstAlias<"mtdec $RT", (MTSPR 22, gprc:$RT)>;
4496 def : InstAlias<"mfpvr $RT", (MFSPR gprc:$RT, 287)>;
4498 def : InstAlias<"mfsdr1 $RT", (MFSPR gprc:$RT, 25)>;
4499 def : InstAlias<"mtsdr1 $RT", (MTSPR 25, gprc:$RT)>;
4501 def : InstAlias<"mfsrr0 $RT", (MFSPR gprc:$RT, 26)>;
4502 def : InstAlias<"mfsrr1 $RT", (MFSPR gprc:$RT, 27)>;
4503 def : InstAlias<"mtsrr0 $RT", (MTSPR 26, gprc:$RT)>;
4504 def : InstAlias<"mtsrr1 $RT", (MTSPR 27, gprc:$RT)>;
4506 def : InstAlias<"tlbie $RB", (TLBIE R0, gprc:$RB)>;
4508 def : InstAlias<"tlbrehi $RS, $A", (TLBRE2 gprc:$RS, gprc:$A, 0)>,
4509 Requires<[IsPPC4xx]>;
4510 def : InstAlias<"tlbrelo $RS, $A", (TLBRE2 gprc:$RS, gprc:$A, 1)>,
4511 Requires<[IsPPC4xx]>;
4512 def : InstAlias<"tlbwehi $RS, $A", (TLBWE2 gprc:$RS, gprc:$A, 0)>,
4513 Requires<[IsPPC4xx]>;
4514 def : InstAlias<"tlbwelo $RS, $A", (TLBWE2 gprc:$RS, gprc:$A, 1)>,
4515 Requires<[IsPPC4xx]>;
4517 def EXTLWI : PPCAsmPseudo<"extlwi $rA, $rS, $n, $b",
4518 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4519 def EXTLWIo : PPCAsmPseudo<"extlwi. $rA, $rS, $n, $b",
4520 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4521 def EXTRWI : PPCAsmPseudo<"extrwi $rA, $rS, $n, $b",
4522 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4523 def EXTRWIo : PPCAsmPseudo<"extrwi. $rA, $rS, $n, $b",
4524 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4525 def INSLWI : PPCAsmPseudo<"inslwi $rA, $rS, $n, $b",
4526 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4527 def INSLWIo : PPCAsmPseudo<"inslwi. $rA, $rS, $n, $b",
4528 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4529 def INSRWI : PPCAsmPseudo<"insrwi $rA, $rS, $n, $b",
4530 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4531 def INSRWIo : PPCAsmPseudo<"insrwi. $rA, $rS, $n, $b",
4532 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4533 def ROTRWI : PPCAsmPseudo<"rotrwi $rA, $rS, $n",
4534 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4535 def ROTRWIo : PPCAsmPseudo<"rotrwi. $rA, $rS, $n",
4536 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4537 def SLWI : PPCAsmPseudo<"slwi $rA, $rS, $n",
4538 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4539 def SLWIo : PPCAsmPseudo<"slwi. $rA, $rS, $n",
4540 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4541 def SRWI : PPCAsmPseudo<"srwi $rA, $rS, $n",
4542 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4543 def SRWIo : PPCAsmPseudo<"srwi. $rA, $rS, $n",
4544 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4545 def CLRRWI : PPCAsmPseudo<"clrrwi $rA, $rS, $n",
4546 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4547 def CLRRWIo : PPCAsmPseudo<"clrrwi. $rA, $rS, $n",
4548 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4549 def CLRLSLWI : PPCAsmPseudo<"clrlslwi $rA, $rS, $b, $n",
4550 (ins gprc:$rA, gprc:$rS, u5imm:$b, u5imm:$n)>;
4551 def CLRLSLWIo : PPCAsmPseudo<"clrlslwi. $rA, $rS, $b, $n",
4552 (ins gprc:$rA, gprc:$rS, u5imm:$b, u5imm:$n)>;
4554 def : InstAlias<"rotlwi $rA, $rS, $n", (RLWINM gprc:$rA, gprc:$rS, u5imm:$n, 0, 31)>;
4555 def : InstAlias<"rotlwi. $rA, $rS, $n", (RLWINMo gprc:$rA, gprc:$rS, u5imm:$n, 0, 31)>;
4556 def : InstAlias<"rotlw $rA, $rS, $rB", (RLWNM gprc:$rA, gprc:$rS, gprc:$rB, 0, 31)>;
4557 def : InstAlias<"rotlw. $rA, $rS, $rB", (RLWNMo gprc:$rA, gprc:$rS, gprc:$rB, 0, 31)>;
4558 def : InstAlias<"clrlwi $rA, $rS, $n", (RLWINM gprc:$rA, gprc:$rS, 0, u5imm:$n, 31)>;
4559 def : InstAlias<"clrlwi. $rA, $rS, $n", (RLWINMo gprc:$rA, gprc:$rS, 0, u5imm:$n, 31)>;
4561 def : InstAlias<"cntlzw $rA, $rS", (CNTLZW gprc:$rA, gprc:$rS)>;
4562 def : InstAlias<"cntlzw. $rA, $rS", (CNTLZWo gprc:$rA, gprc:$rS)>;
4563 // The POWER variant
4564 def : MnemonicAlias<"cntlz", "cntlzw">;
4565 def : MnemonicAlias<"cntlz.", "cntlzw.">;
4567 def EXTLDI : PPCAsmPseudo<"extldi $rA, $rS, $n, $b",
4568 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4569 def EXTLDIo : PPCAsmPseudo<"extldi. $rA, $rS, $n, $b",
4570 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4571 def EXTRDI : PPCAsmPseudo<"extrdi $rA, $rS, $n, $b",
4572 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4573 def EXTRDIo : PPCAsmPseudo<"extrdi. $rA, $rS, $n, $b",
4574 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4575 def INSRDI : PPCAsmPseudo<"insrdi $rA, $rS, $n, $b",
4576 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4577 def INSRDIo : PPCAsmPseudo<"insrdi. $rA, $rS, $n, $b",
4578 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4579 def ROTRDI : PPCAsmPseudo<"rotrdi $rA, $rS, $n",
4580 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4581 def ROTRDIo : PPCAsmPseudo<"rotrdi. $rA, $rS, $n",
4582 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4583 def SLDI : PPCAsmPseudo<"sldi $rA, $rS, $n",
4584 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4585 def SLDIo : PPCAsmPseudo<"sldi. $rA, $rS, $n",
4586 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4587 def SRDI : PPCAsmPseudo<"srdi $rA, $rS, $n",
4588 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4589 def SRDIo : PPCAsmPseudo<"srdi. $rA, $rS, $n",
4590 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4591 def CLRRDI : PPCAsmPseudo<"clrrdi $rA, $rS, $n",
4592 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4593 def CLRRDIo : PPCAsmPseudo<"clrrdi. $rA, $rS, $n",
4594 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4595 def CLRLSLDI : PPCAsmPseudo<"clrlsldi $rA, $rS, $b, $n",
4596 (ins g8rc:$rA, g8rc:$rS, u6imm:$b, u6imm:$n)>;
4597 def CLRLSLDIo : PPCAsmPseudo<"clrlsldi. $rA, $rS, $b, $n",
4598 (ins g8rc:$rA, g8rc:$rS, u6imm:$b, u6imm:$n)>;
4599 def SUBPCIS : PPCAsmPseudo<"subpcis $RT, $D", (ins g8rc:$RT, s16imm:$D)>;
4601 def : InstAlias<"rotldi $rA, $rS, $n", (RLDICL g8rc:$rA, g8rc:$rS, u6imm:$n, 0)>;
4602 def : InstAlias<"rotldi. $rA, $rS, $n", (RLDICLo g8rc:$rA, g8rc:$rS, u6imm:$n, 0)>;
4603 def : InstAlias<"rotld $rA, $rS, $rB", (RLDCL g8rc:$rA, g8rc:$rS, gprc:$rB, 0)>;
4604 def : InstAlias<"rotld. $rA, $rS, $rB", (RLDCLo g8rc:$rA, g8rc:$rS, gprc:$rB, 0)>;
4605 def : InstAlias<"clrldi $rA, $rS, $n", (RLDICL g8rc:$rA, g8rc:$rS, 0, u6imm:$n)>;
4606 def : InstAlias<"clrldi $rA, $rS, $n",
4607 (RLDICL_32_64 g8rc:$rA, gprc:$rS, 0, u6imm:$n)>;
4608 def : InstAlias<"clrldi. $rA, $rS, $n", (RLDICLo g8rc:$rA, g8rc:$rS, 0, u6imm:$n)>;
4609 def : InstAlias<"lnia $RT", (ADDPCIS g8rc:$RT, 0)>;
4611 def RLWINMbm : PPCAsmPseudo<"rlwinm $rA, $rS, $n, $b",
4612 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4613 def RLWINMobm : PPCAsmPseudo<"rlwinm. $rA, $rS, $n, $b",
4614 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4615 def RLWIMIbm : PPCAsmPseudo<"rlwimi $rA, $rS, $n, $b",
4616 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4617 def RLWIMIobm : PPCAsmPseudo<"rlwimi. $rA, $rS, $n, $b",
4618 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4619 def RLWNMbm : PPCAsmPseudo<"rlwnm $rA, $rS, $n, $b",
4620 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4621 def RLWNMobm : PPCAsmPseudo<"rlwnm. $rA, $rS, $n, $b",
4622 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4624 // These generic branch instruction forms are used for the assembler parser only.
4625 // Defs and Uses are conservative, since we don't know the BO value.
4626 let PPC970_Unit = 7, isBranch = 1 in {
4627 let Defs = [CTR], Uses = [CTR, RM] in {
4628 def gBC : BForm_3<16, 0, 0, (outs),
4629 (ins u5imm:$bo, crbitrc:$bi, condbrtarget:$dst),
4630 "bc $bo, $bi, $dst">;
4631 def gBCA : BForm_3<16, 1, 0, (outs),
4632 (ins u5imm:$bo, crbitrc:$bi, abscondbrtarget:$dst),
4633 "bca $bo, $bi, $dst">;
4634 let isAsmParserOnly = 1 in {
4635 def gBCat : BForm_3_at<16, 0, 0, (outs),
4636 (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
4638 "bc$at $bo, $bi, $dst">;
4639 def gBCAat : BForm_3_at<16, 1, 0, (outs),
4640 (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
4641 abscondbrtarget:$dst),
4642 "bca$at $bo, $bi, $dst">;
4643 } // isAsmParserOnly = 1
4645 let Defs = [LR, CTR], Uses = [CTR, RM] in {
4646 def gBCL : BForm_3<16, 0, 1, (outs),
4647 (ins u5imm:$bo, crbitrc:$bi, condbrtarget:$dst),
4648 "bcl $bo, $bi, $dst">;
4649 def gBCLA : BForm_3<16, 1, 1, (outs),
4650 (ins u5imm:$bo, crbitrc:$bi, abscondbrtarget:$dst),
4651 "bcla $bo, $bi, $dst">;
4652 let isAsmParserOnly = 1 in {
4653 def gBCLat : BForm_3_at<16, 0, 1, (outs),
4654 (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
4656 "bcl$at $bo, $bi, $dst">;
4657 def gBCLAat : BForm_3_at<16, 1, 1, (outs),
4658 (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
4659 abscondbrtarget:$dst),
4660 "bcla$at $bo, $bi, $dst">;
4661 } // // isAsmParserOnly = 1
4663 let Defs = [CTR], Uses = [CTR, LR, RM] in
4664 def gBCLR : XLForm_2<19, 16, 0, (outs),
4665 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
4666 "bclr $bo, $bi, $bh", IIC_BrB, []>;
4667 let Defs = [LR, CTR], Uses = [CTR, LR, RM] in
4668 def gBCLRL : XLForm_2<19, 16, 1, (outs),
4669 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
4670 "bclrl $bo, $bi, $bh", IIC_BrB, []>;
4671 let Defs = [CTR], Uses = [CTR, LR, RM] in
4672 def gBCCTR : XLForm_2<19, 528, 0, (outs),
4673 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
4674 "bcctr $bo, $bi, $bh", IIC_BrB, []>;
4675 let Defs = [LR, CTR], Uses = [CTR, LR, RM] in
4676 def gBCCTRL : XLForm_2<19, 528, 1, (outs),
4677 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
4678 "bcctrl $bo, $bi, $bh", IIC_BrB, []>;
4681 multiclass BranchSimpleMnemonicAT<string pm, int at> {
4682 def : InstAlias<"bc"#pm#" $bo, $bi, $dst", (gBCat u5imm:$bo, at, crbitrc:$bi,
4683 condbrtarget:$dst)>;
4684 def : InstAlias<"bca"#pm#" $bo, $bi, $dst", (gBCAat u5imm:$bo, at, crbitrc:$bi,
4685 condbrtarget:$dst)>;
4686 def : InstAlias<"bcl"#pm#" $bo, $bi, $dst", (gBCLat u5imm:$bo, at, crbitrc:$bi,
4687 condbrtarget:$dst)>;
4688 def : InstAlias<"bcla"#pm#" $bo, $bi, $dst", (gBCLAat u5imm:$bo, at, crbitrc:$bi,
4689 condbrtarget:$dst)>;
4691 defm : BranchSimpleMnemonicAT<"+", 3>;
4692 defm : BranchSimpleMnemonicAT<"-", 2>;
4694 def : InstAlias<"bclr $bo, $bi", (gBCLR u5imm:$bo, crbitrc:$bi, 0)>;
4695 def : InstAlias<"bclrl $bo, $bi", (gBCLRL u5imm:$bo, crbitrc:$bi, 0)>;
4696 def : InstAlias<"bcctr $bo, $bi", (gBCCTR u5imm:$bo, crbitrc:$bi, 0)>;
4697 def : InstAlias<"bcctrl $bo, $bi", (gBCCTRL u5imm:$bo, crbitrc:$bi, 0)>;
4699 multiclass BranchSimpleMnemonic1<string name, string pm, int bo> {
4700 def : InstAlias<"b"#name#pm#" $bi, $dst", (gBC bo, crbitrc:$bi, condbrtarget:$dst)>;
4701 def : InstAlias<"b"#name#"a"#pm#" $bi, $dst", (gBCA bo, crbitrc:$bi, abscondbrtarget:$dst)>;
4702 def : InstAlias<"b"#name#"lr"#pm#" $bi", (gBCLR bo, crbitrc:$bi, 0)>;
4703 def : InstAlias<"b"#name#"l"#pm#" $bi, $dst", (gBCL bo, crbitrc:$bi, condbrtarget:$dst)>;
4704 def : InstAlias<"b"#name#"la"#pm#" $bi, $dst", (gBCLA bo, crbitrc:$bi, abscondbrtarget:$dst)>;
4705 def : InstAlias<"b"#name#"lrl"#pm#" $bi", (gBCLRL bo, crbitrc:$bi, 0)>;
4707 multiclass BranchSimpleMnemonic2<string name, string pm, int bo>
4708 : BranchSimpleMnemonic1<name, pm, bo> {
4709 def : InstAlias<"b"#name#"ctr"#pm#" $bi", (gBCCTR bo, crbitrc:$bi, 0)>;
4710 def : InstAlias<"b"#name#"ctrl"#pm#" $bi", (gBCCTRL bo, crbitrc:$bi, 0)>;
4712 defm : BranchSimpleMnemonic2<"t", "", 12>;
4713 defm : BranchSimpleMnemonic2<"f", "", 4>;
4714 defm : BranchSimpleMnemonic2<"t", "-", 14>;
4715 defm : BranchSimpleMnemonic2<"f", "-", 6>;
4716 defm : BranchSimpleMnemonic2<"t", "+", 15>;
4717 defm : BranchSimpleMnemonic2<"f", "+", 7>;
4718 defm : BranchSimpleMnemonic1<"dnzt", "", 8>;
4719 defm : BranchSimpleMnemonic1<"dnzf", "", 0>;
4720 defm : BranchSimpleMnemonic1<"dzt", "", 10>;
4721 defm : BranchSimpleMnemonic1<"dzf", "", 2>;
4723 multiclass BranchExtendedMnemonicPM<string name, string pm, int bibo> {
4724 def : InstAlias<"b"#name#pm#" $cc, $dst",
4725 (BCC bibo, crrc:$cc, condbrtarget:$dst)>;
4726 def : InstAlias<"b"#name#pm#" $dst",
4727 (BCC bibo, CR0, condbrtarget:$dst)>;
4729 def : InstAlias<"b"#name#"a"#pm#" $cc, $dst",
4730 (BCCA bibo, crrc:$cc, abscondbrtarget:$dst)>;
4731 def : InstAlias<"b"#name#"a"#pm#" $dst",
4732 (BCCA bibo, CR0, abscondbrtarget:$dst)>;
4734 def : InstAlias<"b"#name#"lr"#pm#" $cc",
4735 (BCCLR bibo, crrc:$cc)>;
4736 def : InstAlias<"b"#name#"lr"#pm,
4739 def : InstAlias<"b"#name#"ctr"#pm#" $cc",
4740 (BCCCTR bibo, crrc:$cc)>;
4741 def : InstAlias<"b"#name#"ctr"#pm,
4742 (BCCCTR bibo, CR0)>;
4744 def : InstAlias<"b"#name#"l"#pm#" $cc, $dst",
4745 (BCCL bibo, crrc:$cc, condbrtarget:$dst)>;
4746 def : InstAlias<"b"#name#"l"#pm#" $dst",
4747 (BCCL bibo, CR0, condbrtarget:$dst)>;
4749 def : InstAlias<"b"#name#"la"#pm#" $cc, $dst",
4750 (BCCLA bibo, crrc:$cc, abscondbrtarget:$dst)>;
4751 def : InstAlias<"b"#name#"la"#pm#" $dst",
4752 (BCCLA bibo, CR0, abscondbrtarget:$dst)>;
4754 def : InstAlias<"b"#name#"lrl"#pm#" $cc",
4755 (BCCLRL bibo, crrc:$cc)>;
4756 def : InstAlias<"b"#name#"lrl"#pm,
4757 (BCCLRL bibo, CR0)>;
4759 def : InstAlias<"b"#name#"ctrl"#pm#" $cc",
4760 (BCCCTRL bibo, crrc:$cc)>;
4761 def : InstAlias<"b"#name#"ctrl"#pm,
4762 (BCCCTRL bibo, CR0)>;
4764 multiclass BranchExtendedMnemonic<string name, int bibo> {
4765 defm : BranchExtendedMnemonicPM<name, "", bibo>;
4766 defm : BranchExtendedMnemonicPM<name, "-", !add(bibo, 2)>;
4767 defm : BranchExtendedMnemonicPM<name, "+", !add(bibo, 3)>;
4769 defm : BranchExtendedMnemonic<"lt", 12>;
4770 defm : BranchExtendedMnemonic<"gt", 44>;
4771 defm : BranchExtendedMnemonic<"eq", 76>;
4772 defm : BranchExtendedMnemonic<"un", 108>;
4773 defm : BranchExtendedMnemonic<"so", 108>;
4774 defm : BranchExtendedMnemonic<"ge", 4>;
4775 defm : BranchExtendedMnemonic<"nl", 4>;
4776 defm : BranchExtendedMnemonic<"le", 36>;
4777 defm : BranchExtendedMnemonic<"ng", 36>;
4778 defm : BranchExtendedMnemonic<"ne", 68>;
4779 defm : BranchExtendedMnemonic<"nu", 100>;
4780 defm : BranchExtendedMnemonic<"ns", 100>;
4782 def : InstAlias<"cmpwi $rA, $imm", (CMPWI CR0, gprc:$rA, s16imm:$imm)>;
4783 def : InstAlias<"cmpw $rA, $rB", (CMPW CR0, gprc:$rA, gprc:$rB)>;
4784 def : InstAlias<"cmplwi $rA, $imm", (CMPLWI CR0, gprc:$rA, u16imm:$imm)>;
4785 def : InstAlias<"cmplw $rA, $rB", (CMPLW CR0, gprc:$rA, gprc:$rB)>;
4786 def : InstAlias<"cmpdi $rA, $imm", (CMPDI CR0, g8rc:$rA, s16imm64:$imm)>;
4787 def : InstAlias<"cmpd $rA, $rB", (CMPD CR0, g8rc:$rA, g8rc:$rB)>;
4788 def : InstAlias<"cmpldi $rA, $imm", (CMPLDI CR0, g8rc:$rA, u16imm64:$imm)>;
4789 def : InstAlias<"cmpld $rA, $rB", (CMPLD CR0, g8rc:$rA, g8rc:$rB)>;
4791 def : InstAlias<"cmpi $bf, 0, $rA, $imm", (CMPWI crrc:$bf, gprc:$rA, s16imm:$imm)>;
4792 def : InstAlias<"cmp $bf, 0, $rA, $rB", (CMPW crrc:$bf, gprc:$rA, gprc:$rB)>;
4793 def : InstAlias<"cmpli $bf, 0, $rA, $imm", (CMPLWI crrc:$bf, gprc:$rA, u16imm:$imm)>;
4794 def : InstAlias<"cmpl $bf, 0, $rA, $rB", (CMPLW crrc:$bf, gprc:$rA, gprc:$rB)>;
4795 def : InstAlias<"cmpi $bf, 1, $rA, $imm", (CMPDI crrc:$bf, g8rc:$rA, s16imm64:$imm)>;
4796 def : InstAlias<"cmp $bf, 1, $rA, $rB", (CMPD crrc:$bf, g8rc:$rA, g8rc:$rB)>;
4797 def : InstAlias<"cmpli $bf, 1, $rA, $imm", (CMPLDI crrc:$bf, g8rc:$rA, u16imm64:$imm)>;
4798 def : InstAlias<"cmpl $bf, 1, $rA, $rB", (CMPLD crrc:$bf, g8rc:$rA, g8rc:$rB)>;
4800 multiclass TrapExtendedMnemonic<string name, int to> {
4801 def : InstAlias<"td"#name#"i $rA, $imm", (TDI to, g8rc:$rA, s16imm:$imm)>;
4802 def : InstAlias<"td"#name#" $rA, $rB", (TD to, g8rc:$rA, g8rc:$rB)>;
4803 def : InstAlias<"tw"#name#"i $rA, $imm", (TWI to, gprc:$rA, s16imm:$imm)>;
4804 def : InstAlias<"tw"#name#" $rA, $rB", (TW to, gprc:$rA, gprc:$rB)>;
4806 defm : TrapExtendedMnemonic<"lt", 16>;
4807 defm : TrapExtendedMnemonic<"le", 20>;
4808 defm : TrapExtendedMnemonic<"eq", 4>;
4809 defm : TrapExtendedMnemonic<"ge", 12>;
4810 defm : TrapExtendedMnemonic<"gt", 8>;
4811 defm : TrapExtendedMnemonic<"nl", 12>;
4812 defm : TrapExtendedMnemonic<"ne", 24>;
4813 defm : TrapExtendedMnemonic<"ng", 20>;
4814 defm : TrapExtendedMnemonic<"llt", 2>;
4815 defm : TrapExtendedMnemonic<"lle", 6>;
4816 defm : TrapExtendedMnemonic<"lge", 5>;
4817 defm : TrapExtendedMnemonic<"lgt", 1>;
4818 defm : TrapExtendedMnemonic<"lnl", 5>;
4819 defm : TrapExtendedMnemonic<"lng", 6>;
4820 defm : TrapExtendedMnemonic<"u", 31>;
4823 def : Pat<(atomic_load_8 iaddr:$src), (LBZ memri:$src)>;
4824 def : Pat<(atomic_load_16 iaddr:$src), (LHZ memri:$src)>;
4825 def : Pat<(atomic_load_32 iaddr:$src), (LWZ memri:$src)>;
4826 def : Pat<(atomic_load_8 xaddr:$src), (LBZX memrr:$src)>;
4827 def : Pat<(atomic_load_16 xaddr:$src), (LHZX memrr:$src)>;
4828 def : Pat<(atomic_load_32 xaddr:$src), (LWZX memrr:$src)>;
4831 def : Pat<(atomic_store_8 iaddr:$ptr, i32:$val), (STB gprc:$val, memri:$ptr)>;
4832 def : Pat<(atomic_store_16 iaddr:$ptr, i32:$val), (STH gprc:$val, memri:$ptr)>;
4833 def : Pat<(atomic_store_32 iaddr:$ptr, i32:$val), (STW gprc:$val, memri:$ptr)>;
4834 def : Pat<(atomic_store_8 xaddr:$ptr, i32:$val), (STBX gprc:$val, memrr:$ptr)>;
4835 def : Pat<(atomic_store_16 xaddr:$ptr, i32:$val), (STHX gprc:$val, memrr:$ptr)>;
4836 def : Pat<(atomic_store_32 xaddr:$ptr, i32:$val), (STWX gprc:$val, memrr:$ptr)>;
4838 let Predicates = [IsISA3_0] in {
4840 // Copy-Paste Facility
4841 // We prefix 'CP' to COPY due to name conflict in Target.td. We also prefix to
4842 // PASTE for naming consistency.
4844 def CP_COPY : X_L1_RA5_RB5<31, 774, "copy" , gprc, IIC_LdStCOPY, []>;
4847 def CP_PASTE : X_L1_RA5_RB5<31, 902, "paste" , gprc, IIC_LdStPASTE, []>;
4849 let mayStore = 1, Defs = [CR0] in
4850 def CP_PASTEo : X_L1_RA5_RB5<31, 902, "paste.", gprc, IIC_LdStPASTE, []>, isDOT;
4852 def CP_COPYx : PPCAsmPseudo<"copy $rA, $rB" , (ins gprc:$rA, gprc:$rB)>;
4853 def CP_PASTEx : PPCAsmPseudo<"paste $rA, $rB", (ins gprc:$rA, gprc:$rB)>;
4854 def CP_COPY_FIRST : PPCAsmPseudo<"copy_first $rA, $rB",
4855 (ins gprc:$rA, gprc:$rB)>;
4856 def CP_PASTE_LAST : PPCAsmPseudo<"paste_last $rA, $rB",
4857 (ins gprc:$rA, gprc:$rB)>;
4858 def CP_ABORT : XForm_0<31, 838, (outs), (ins), "cp_abort", IIC_SprABORT, []>;
4860 // Message Synchronize
4861 def MSGSYNC : XForm_0<31, 886, (outs), (ins), "msgsync", IIC_SprMSGSYNC, []>;
4863 // Power-Saving Mode Instruction:
4864 def STOP : XForm_0<19, 370, (outs), (ins), "stop", IIC_SprSTOP, []>;
4868 // Fast 32-bit reverse bits algorithm:
4869 // Step 1: 1-bit swap (swap odd 1-bit and even 1-bit):
4870 // n = ((n >> 1) & 0x55555555) | ((n << 1) & 0xAAAAAAAA);
4871 // Step 2: 2-bit swap (swap odd 2-bit and even 2-bit):
4872 // n = ((n >> 2) & 0x33333333) | ((n << 2) & 0xCCCCCCCC);
4873 // Step 3: 4-bit swap (swap odd 4-bit and even 4-bit):
4874 // n = ((n >> 4) & 0x0F0F0F0F) | ((n << 4) & 0xF0F0F0F0);
4875 // Step 4: byte reverse (Suppose n = [B1,B2,B3,B4]):
4876 // Step 4.1: Put B4,B2 in the right position (rotate left 3 bytes):
4877 // n' = (n rotl 24); After which n' = [B4, B1, B2, B3]
4878 // Step 4.2: Insert B3 to the right position:
4879 // n' = rlwimi n', n, 8, 8, 15; After which n' = [B4, B3, B2, B3]
4880 // Step 4.3: Insert B1 to the right position:
4881 // n' = rlwimi n', n, 8, 24, 31; After which n' = [B4, B3, B2, B1]
4883 dag Lo1 = (ORI (LIS 0x5555), 0x5555);
4884 dag Hi1 = (ORI (LIS 0xAAAA), 0xAAAA);
4885 dag Lo2 = (ORI (LIS 0x3333), 0x3333);
4886 dag Hi2 = (ORI (LIS 0xCCCC), 0xCCCC);
4887 dag Lo4 = (ORI (LIS 0x0F0F), 0x0F0F);
4888 dag Hi4 = (ORI (LIS 0xF0F0), 0xF0F0);
4892 dag Right = (RLWINM $A, 31, 1, 31);
4893 dag Left = (RLWINM $A, 1, 0, 30);
4897 dag Bit = (OR (AND Shift1.Right, MaskValues.Lo1),
4898 (AND Shift1.Left, MaskValues.Hi1));
4902 dag Right = (RLWINM Swap1.Bit, 30, 2, 31);
4903 dag Left = (RLWINM Swap1.Bit, 2, 0, 29);
4907 dag Bits = (OR (AND Shift2.Right, MaskValues.Lo2),
4908 (AND Shift2.Left, MaskValues.Hi2));
4912 dag Right = (RLWINM Swap2.Bits, 28, 4, 31);
4913 dag Left = (RLWINM Swap2.Bits, 4, 0, 27);
4917 dag Bits = (OR (AND Shift4.Right, MaskValues.Lo4),
4918 (AND Shift4.Left, MaskValues.Hi4));
4922 dag Left3Bytes = (RLWINM Swap4.Bits, 24, 0, 31);
4925 def RotateInsertByte3 {
4926 dag Left = (RLWIMI Rotate.Left3Bytes, Swap4.Bits, 8, 8, 15);
4929 def RotateInsertByte1 {
4930 dag Left = (RLWIMI RotateInsertByte3.Left, Swap4.Bits, 8, 24, 31);
4933 def : Pat<(i32 (bitreverse i32:$A)),
4934 (RLDICL_32 RotateInsertByte1.Left, 0, 32)>;
4936 // Fast 64-bit reverse bits algorithm:
4937 // Step 1: 1-bit swap (swap odd 1-bit and even 1-bit):
4938 // n = ((n >> 1) & 0x5555555555555555) | ((n << 1) & 0xAAAAAAAAAAAAAAAA);
4939 // Step 2: 2-bit swap (swap odd 2-bit and even 2-bit):
4940 // n = ((n >> 2) & 0x3333333333333333) | ((n << 2) & 0xCCCCCCCCCCCCCCCC);
4941 // Step 3: 4-bit swap (swap odd 4-bit and even 4-bit):
4942 // n = ((n >> 4) & 0x0F0F0F0F0F0F0F0F) | ((n << 4) & 0xF0F0F0F0F0F0F0F0);
4943 // Step 4: byte reverse (Suppose n = [B0,B1,B2,B3,B4,B5,B6,B7]):
4944 // Apply the same byte reverse algorithm mentioned above for the fast 32-bit
4945 // reverse to both the high 32 bit and low 32 bit of the 64 bit value. And
4946 // then OR them together to get the final result.
4948 dag Lo1 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Lo1, sub_32));
4949 dag Hi1 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Hi1, sub_32));
4950 dag Lo2 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Lo2, sub_32));
4951 dag Hi2 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Hi2, sub_32));
4952 dag Lo4 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Lo4, sub_32));
4953 dag Hi4 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Hi4, sub_32));
4957 dag Lo1 = (ORI8 (ORIS8 (RLDICR MaskValues64.Lo1, 32, 31), 0x5555), 0x5555);
4958 dag Hi1 = (ORI8 (ORIS8 (RLDICR MaskValues64.Hi1, 32, 31), 0xAAAA), 0xAAAA);
4959 dag Lo2 = (ORI8 (ORIS8 (RLDICR MaskValues64.Lo2, 32, 31), 0x3333), 0x3333);
4960 dag Hi2 = (ORI8 (ORIS8 (RLDICR MaskValues64.Hi2, 32, 31), 0xCCCC), 0xCCCC);
4961 dag Lo4 = (ORI8 (ORIS8 (RLDICR MaskValues64.Lo4, 32, 31), 0x0F0F), 0x0F0F);
4962 dag Hi4 = (ORI8 (ORIS8 (RLDICR MaskValues64.Hi4, 32, 31), 0xF0F0), 0xF0F0);
4966 dag Swap1 = (OR8 (AND8 (RLDICL $A, 63, 1), DWMaskValues.Lo1),
4967 (AND8 (RLDICR $A, 1, 62), DWMaskValues.Hi1));
4968 dag Swap2 = (OR8 (AND8 (RLDICL Swap1, 62, 2), DWMaskValues.Lo2),
4969 (AND8 (RLDICR Swap1, 2, 61), DWMaskValues.Hi2));
4970 dag Swap4 = (OR8 (AND8 (RLDICL Swap2, 60, 4), DWMaskValues.Lo4),
4971 (AND8 (RLDICR Swap2, 4, 59), DWMaskValues.Hi4));
4974 // Intra-byte swap is done, now start inter-byte swap.
4976 dag Word = (i32 (EXTRACT_SUBREG DWSwapInByte.Swap4, sub_32));
4980 dag Word = (RLWINM DWBytes4567.Word, 24, 0, 31);
4984 dag Word = (RLWIMI DWBytes7456.Word, DWBytes4567.Word, 8, 8, 15);
4987 // B7 B6 B5 B4 in the right order
4989 dag Word = (RLWIMI DWBytes7656.Word, DWBytes4567.Word, 8, 24, 31);
4991 (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), Word, sub_32));
4995 dag Word = (i32 (EXTRACT_SUBREG (RLDICL DWSwapInByte.Swap4, 32, 32), sub_32));
4999 dag Word = (RLWINM DWBytes0123.Word, 24, 0, 31);
5003 dag Word = (RLWIMI DWBytes3012.Word, DWBytes0123.Word, 8, 8, 15);
5006 // B3 B2 B1 B0 in the right order
5008 dag Word = (RLWIMI DWBytes3212.Word, DWBytes0123.Word, 8, 24, 31);
5010 (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), Word, sub_32));
5013 // Now both high word and low word are reversed, next
5014 // swap the high word and low word.
5015 def : Pat<(i64 (bitreverse i64:$A)),
5016 (OR8 (RLDICR DWBytes7654.DWord, 32, 31), DWBytes3210.DWord)>;