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 // These are target-independent nodes, but have target-specific formats.
234 def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_PPCCallSeqStart,
235 [SDNPHasChain, SDNPOutGlue]>;
236 def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_PPCCallSeqEnd,
237 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
239 def SDT_PPCCall : SDTypeProfile<0, -1, [SDTCisInt<0>]>;
240 def PPCcall : SDNode<"PPCISD::CALL", SDT_PPCCall,
241 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
243 def PPCcall_nop : SDNode<"PPCISD::CALL_NOP", SDT_PPCCall,
244 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
246 def PPCmtctr : SDNode<"PPCISD::MTCTR", SDT_PPCCall,
247 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
248 def PPCbctrl : SDNode<"PPCISD::BCTRL", SDTNone,
249 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
251 def PPCbctrl_load_toc : SDNode<"PPCISD::BCTRL_LOAD_TOC",
252 SDTypeProfile<0, 1, []>,
253 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
256 def retflag : SDNode<"PPCISD::RET_FLAG", SDTNone,
257 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
259 def PPCtc_return : SDNode<"PPCISD::TC_RETURN", SDT_PPCTC_ret,
260 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
262 def PPCeh_sjlj_setjmp : SDNode<"PPCISD::EH_SJLJ_SETJMP",
263 SDTypeProfile<1, 1, [SDTCisInt<0>,
265 [SDNPHasChain, SDNPSideEffect]>;
266 def PPCeh_sjlj_longjmp : SDNode<"PPCISD::EH_SJLJ_LONGJMP",
267 SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>,
268 [SDNPHasChain, SDNPSideEffect]>;
270 def SDT_PPCsc : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
271 def PPCsc : SDNode<"PPCISD::SC", SDT_PPCsc,
272 [SDNPHasChain, SDNPSideEffect]>;
274 def PPCclrbhrb : SDNode<"PPCISD::CLRBHRB", SDTNone,
275 [SDNPHasChain, SDNPSideEffect]>;
276 def PPCmfbhrbe : SDNode<"PPCISD::MFBHRBE", SDTIntBinOp, [SDNPHasChain]>;
277 def PPCrfebb : SDNode<"PPCISD::RFEBB", SDT_PPCsc,
278 [SDNPHasChain, SDNPSideEffect]>;
280 def PPCvcmp : SDNode<"PPCISD::VCMP" , SDT_PPCvcmp, []>;
281 def PPCvcmp_o : SDNode<"PPCISD::VCMPo", SDT_PPCvcmp, [SDNPOutGlue]>;
283 def PPCcondbranch : SDNode<"PPCISD::COND_BRANCH", SDT_PPCcondbr,
284 [SDNPHasChain, SDNPOptInGlue]>;
286 // PPC-specific atomic operations.
287 def PPCatomicCmpSwap_8 :
288 SDNode<"PPCISD::ATOMIC_CMP_SWAP_8", SDTAtomic3,
289 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
290 def PPCatomicCmpSwap_16 :
291 SDNode<"PPCISD::ATOMIC_CMP_SWAP_16", SDTAtomic3,
292 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
293 def PPClbrx : SDNode<"PPCISD::LBRX", SDT_PPClbrx,
294 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
295 def PPCstbrx : SDNode<"PPCISD::STBRX", SDT_PPCstbrx,
296 [SDNPHasChain, SDNPMayStore]>;
298 // Instructions to set/unset CR bit 6 for SVR4 vararg calls
299 def PPCcr6set : SDNode<"PPCISD::CR6SET", SDTNone,
300 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
301 def PPCcr6unset : SDNode<"PPCISD::CR6UNSET", SDTNone,
302 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
304 // Instructions to support dynamic alloca.
305 def SDTDynOp : SDTypeProfile<1, 2, []>;
306 def SDTDynAreaOp : SDTypeProfile<1, 1, []>;
307 def PPCdynalloc : SDNode<"PPCISD::DYNALLOC", SDTDynOp, [SDNPHasChain]>;
308 def PPCdynareaoffset : SDNode<"PPCISD::DYNAREAOFFSET", SDTDynAreaOp, [SDNPHasChain]>;
310 //===----------------------------------------------------------------------===//
311 // PowerPC specific transformation functions and pattern fragments.
314 def SHL32 : SDNodeXForm<imm, [{
315 // Transformation function: 31 - imm
316 return getI32Imm(31 - N->getZExtValue(), SDLoc(N));
319 def SRL32 : SDNodeXForm<imm, [{
320 // Transformation function: 32 - imm
321 return N->getZExtValue() ? getI32Imm(32 - N->getZExtValue(), SDLoc(N))
322 : getI32Imm(0, SDLoc(N));
325 def LO16 : SDNodeXForm<imm, [{
326 // Transformation function: get the low 16 bits.
327 return getI32Imm((unsigned short)N->getZExtValue(), SDLoc(N));
330 def HI16 : SDNodeXForm<imm, [{
331 // Transformation function: shift the immediate value down into the low bits.
332 return getI32Imm((unsigned)N->getZExtValue() >> 16, SDLoc(N));
335 def HA16 : SDNodeXForm<imm, [{
336 // Transformation function: shift the immediate value down into the low bits.
337 long Val = N->getZExtValue();
338 return getI32Imm((Val - (signed short)Val) >> 16, SDLoc(N));
340 def MB : SDNodeXForm<imm, [{
341 // Transformation function: get the start bit of a mask
343 (void)isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
344 return getI32Imm(mb, SDLoc(N));
347 def ME : SDNodeXForm<imm, [{
348 // Transformation function: get the end bit of a mask
350 (void)isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
351 return getI32Imm(me, SDLoc(N));
353 def maskimm32 : PatLeaf<(imm), [{
354 // maskImm predicate - True if immediate is a run of ones.
356 if (N->getValueType(0) == MVT::i32)
357 return isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
362 def imm32SExt16 : Operand<i32>, ImmLeaf<i32, [{
363 // imm32SExt16 predicate - True if the i32 immediate fits in a 16-bit
364 // sign extended field. Used by instructions like 'addi'.
365 return (int32_t)Imm == (short)Imm;
367 def imm64SExt16 : Operand<i64>, ImmLeaf<i64, [{
368 // imm64SExt16 predicate - True if the i64 immediate fits in a 16-bit
369 // sign extended field. Used by instructions like 'addi'.
370 return (int64_t)Imm == (short)Imm;
372 def immZExt16 : PatLeaf<(imm), [{
373 // immZExt16 predicate - True if the immediate fits in a 16-bit zero extended
374 // field. Used by instructions like 'ori'.
375 return (uint64_t)N->getZExtValue() == (unsigned short)N->getZExtValue();
377 def immAnyExt8 : ImmLeaf<i32, [{ return isInt<8>(Imm) || isUInt<8>(Imm); }]>;
378 def immSExt5NonZero : ImmLeaf<i32, [{ return Imm && isInt<5>(Imm); }]>;
380 // imm16Shifted* - These match immediates where the low 16-bits are zero. There
381 // are two forms: imm16ShiftedSExt and imm16ShiftedZExt. These two forms are
382 // identical in 32-bit mode, but in 64-bit mode, they return true if the
383 // immediate fits into a sign/zero extended 32-bit immediate (with the low bits
385 def imm16ShiftedZExt : PatLeaf<(imm), [{
386 // imm16ShiftedZExt predicate - True if only bits in the top 16-bits of the
387 // immediate are set. Used by instructions like 'xoris'.
388 return (N->getZExtValue() & ~uint64_t(0xFFFF0000)) == 0;
391 def imm16ShiftedSExt : PatLeaf<(imm), [{
392 // imm16ShiftedSExt predicate - True if only bits in the top 16-bits of the
393 // immediate are set. Used by instructions like 'addis'. Identical to
394 // imm16ShiftedZExt in 32-bit mode.
395 if (N->getZExtValue() & 0xFFFF) return false;
396 if (N->getValueType(0) == MVT::i32)
398 // For 64-bit, make sure it is sext right.
399 return N->getZExtValue() == (uint64_t)(int)N->getZExtValue();
402 def imm64ZExt32 : Operand<i64>, ImmLeaf<i64, [{
403 // imm64ZExt32 predicate - True if the i64 immediate fits in a 32-bit
404 // zero extended field.
405 return isUInt<32>(Imm);
408 // Some r+i load/store instructions (such as LD, STD, LDU, etc.) that require
409 // restricted memrix (4-aligned) constants are alignment sensitive. If these
410 // offsets are hidden behind TOC entries than the values of the lower-order
411 // bits cannot be checked directly. As a result, we need to also incorporate
412 // an alignment check into the relevant patterns.
414 def aligned4load : PatFrag<(ops node:$ptr), (load node:$ptr), [{
415 return cast<LoadSDNode>(N)->getAlignment() >= 4;
417 def aligned4store : PatFrag<(ops node:$val, node:$ptr),
418 (store node:$val, node:$ptr), [{
419 return cast<StoreSDNode>(N)->getAlignment() >= 4;
421 def aligned4sextloadi32 : PatFrag<(ops node:$ptr), (sextloadi32 node:$ptr), [{
422 return cast<LoadSDNode>(N)->getAlignment() >= 4;
424 def aligned4pre_store : PatFrag<
425 (ops node:$val, node:$base, node:$offset),
426 (pre_store node:$val, node:$base, node:$offset), [{
427 return cast<StoreSDNode>(N)->getAlignment() >= 4;
430 def unaligned4load : PatFrag<(ops node:$ptr), (load node:$ptr), [{
431 return cast<LoadSDNode>(N)->getAlignment() < 4;
433 def unaligned4store : PatFrag<(ops node:$val, node:$ptr),
434 (store node:$val, node:$ptr), [{
435 return cast<StoreSDNode>(N)->getAlignment() < 4;
437 def unaligned4sextloadi32 : PatFrag<(ops node:$ptr), (sextloadi32 node:$ptr), [{
438 return cast<LoadSDNode>(N)->getAlignment() < 4;
441 // This is a somewhat weaker condition than actually checking for 16-byte
442 // alignment. It is simply checking that the displacement can be represented
443 // as an immediate that is a multiple of 16 (i.e. the requirements for DQ-Form
445 def quadwOffsetLoad : PatFrag<(ops node:$ptr), (load node:$ptr), [{
446 return isOffsetMultipleOf(N, 16);
448 def quadwOffsetStore : PatFrag<(ops node:$val, node:$ptr),
449 (store node:$val, node:$ptr), [{
450 return isOffsetMultipleOf(N, 16);
452 def nonQuadwOffsetLoad : PatFrag<(ops node:$ptr), (load node:$ptr), [{
453 return !isOffsetMultipleOf(N, 16);
455 def nonQuadwOffsetStore : PatFrag<(ops node:$val, node:$ptr),
456 (store node:$val, node:$ptr), [{
457 return !isOffsetMultipleOf(N, 16);
460 //===----------------------------------------------------------------------===//
461 // PowerPC Flag Definitions.
463 class isPPC64 { bit PPC64 = 1; }
464 class isDOT { bit RC = 1; }
466 class RegConstraint<string C> {
467 string Constraints = C;
469 class NoEncode<string E> {
470 string DisableEncoding = E;
474 //===----------------------------------------------------------------------===//
475 // PowerPC Operand Definitions.
477 // In the default PowerPC assembler syntax, registers are specified simply
478 // by number, so they cannot be distinguished from immediate values (without
479 // looking at the opcode). This means that the default operand matching logic
480 // for the asm parser does not work, and we need to specify custom matchers.
481 // Since those can only be specified with RegisterOperand classes and not
482 // directly on the RegisterClass, all instructions patterns used by the asm
483 // parser need to use a RegisterOperand (instead of a RegisterClass) for
484 // all their register operands.
485 // For this purpose, we define one RegisterOperand for each RegisterClass,
486 // using the same name as the class, just in lower case.
488 def PPCRegGPRCAsmOperand : AsmOperandClass {
489 let Name = "RegGPRC"; let PredicateMethod = "isRegNumber";
491 def gprc : RegisterOperand<GPRC> {
492 let ParserMatchClass = PPCRegGPRCAsmOperand;
494 def PPCRegG8RCAsmOperand : AsmOperandClass {
495 let Name = "RegG8RC"; let PredicateMethod = "isRegNumber";
497 def g8rc : RegisterOperand<G8RC> {
498 let ParserMatchClass = PPCRegG8RCAsmOperand;
500 def PPCRegGPRCNoR0AsmOperand : AsmOperandClass {
501 let Name = "RegGPRCNoR0"; let PredicateMethod = "isRegNumber";
503 def gprc_nor0 : RegisterOperand<GPRC_NOR0> {
504 let ParserMatchClass = PPCRegGPRCNoR0AsmOperand;
506 def PPCRegG8RCNoX0AsmOperand : AsmOperandClass {
507 let Name = "RegG8RCNoX0"; let PredicateMethod = "isRegNumber";
509 def g8rc_nox0 : RegisterOperand<G8RC_NOX0> {
510 let ParserMatchClass = PPCRegG8RCNoX0AsmOperand;
512 def PPCRegF8RCAsmOperand : AsmOperandClass {
513 let Name = "RegF8RC"; let PredicateMethod = "isRegNumber";
515 def f8rc : RegisterOperand<F8RC> {
516 let ParserMatchClass = PPCRegF8RCAsmOperand;
518 def PPCRegF4RCAsmOperand : AsmOperandClass {
519 let Name = "RegF4RC"; let PredicateMethod = "isRegNumber";
521 def f4rc : RegisterOperand<F4RC> {
522 let ParserMatchClass = PPCRegF4RCAsmOperand;
524 def PPCRegVRRCAsmOperand : AsmOperandClass {
525 let Name = "RegVRRC"; let PredicateMethod = "isRegNumber";
527 def vrrc : RegisterOperand<VRRC> {
528 let ParserMatchClass = PPCRegVRRCAsmOperand;
530 def PPCRegVFRCAsmOperand : AsmOperandClass {
531 let Name = "RegVFRC"; let PredicateMethod = "isRegNumber";
533 def vfrc : RegisterOperand<VFRC> {
534 let ParserMatchClass = PPCRegVFRCAsmOperand;
536 def PPCRegCRBITRCAsmOperand : AsmOperandClass {
537 let Name = "RegCRBITRC"; let PredicateMethod = "isCRBitNumber";
539 def crbitrc : RegisterOperand<CRBITRC> {
540 let ParserMatchClass = PPCRegCRBITRCAsmOperand;
542 def PPCRegCRRCAsmOperand : AsmOperandClass {
543 let Name = "RegCRRC"; let PredicateMethod = "isCCRegNumber";
545 def crrc : RegisterOperand<CRRC> {
546 let ParserMatchClass = PPCRegCRRCAsmOperand;
548 def crrc0 : RegisterOperand<CRRC0> {
549 let ParserMatchClass = PPCRegCRRCAsmOperand;
552 def PPCRegSPERCAsmOperand : AsmOperandClass {
553 let Name = "RegSPERC"; let PredicateMethod = "isRegNumber";
555 def sperc : RegisterOperand<SPERC> {
556 let ParserMatchClass = PPCRegSPERCAsmOperand;
558 def PPCRegSPE4RCAsmOperand : AsmOperandClass {
559 let Name = "RegSPE4RC"; let PredicateMethod = "isRegNumber";
561 def spe4rc : RegisterOperand<SPE4RC> {
562 let ParserMatchClass = PPCRegSPE4RCAsmOperand;
565 def PPCU1ImmAsmOperand : AsmOperandClass {
566 let Name = "U1Imm"; let PredicateMethod = "isU1Imm";
567 let RenderMethod = "addImmOperands";
569 def u1imm : Operand<i32> {
570 let PrintMethod = "printU1ImmOperand";
571 let ParserMatchClass = PPCU1ImmAsmOperand;
574 def PPCU2ImmAsmOperand : AsmOperandClass {
575 let Name = "U2Imm"; let PredicateMethod = "isU2Imm";
576 let RenderMethod = "addImmOperands";
578 def u2imm : Operand<i32> {
579 let PrintMethod = "printU2ImmOperand";
580 let ParserMatchClass = PPCU2ImmAsmOperand;
583 def PPCATBitsAsHintAsmOperand : AsmOperandClass {
584 let Name = "ATBitsAsHint"; let PredicateMethod = "isATBitsAsHint";
585 let RenderMethod = "addImmOperands"; // Irrelevant, predicate always fails.
587 def atimm : Operand<i32> {
588 let PrintMethod = "printATBitsAsHint";
589 let ParserMatchClass = PPCATBitsAsHintAsmOperand;
592 def PPCU3ImmAsmOperand : AsmOperandClass {
593 let Name = "U3Imm"; let PredicateMethod = "isU3Imm";
594 let RenderMethod = "addImmOperands";
596 def u3imm : Operand<i32> {
597 let PrintMethod = "printU3ImmOperand";
598 let ParserMatchClass = PPCU3ImmAsmOperand;
601 def PPCU4ImmAsmOperand : AsmOperandClass {
602 let Name = "U4Imm"; let PredicateMethod = "isU4Imm";
603 let RenderMethod = "addImmOperands";
605 def u4imm : Operand<i32> {
606 let PrintMethod = "printU4ImmOperand";
607 let ParserMatchClass = PPCU4ImmAsmOperand;
609 def PPCS5ImmAsmOperand : AsmOperandClass {
610 let Name = "S5Imm"; let PredicateMethod = "isS5Imm";
611 let RenderMethod = "addImmOperands";
613 def s5imm : Operand<i32> {
614 let PrintMethod = "printS5ImmOperand";
615 let ParserMatchClass = PPCS5ImmAsmOperand;
616 let DecoderMethod = "decodeSImmOperand<5>";
618 def PPCU5ImmAsmOperand : AsmOperandClass {
619 let Name = "U5Imm"; let PredicateMethod = "isU5Imm";
620 let RenderMethod = "addImmOperands";
622 def u5imm : Operand<i32> {
623 let PrintMethod = "printU5ImmOperand";
624 let ParserMatchClass = PPCU5ImmAsmOperand;
625 let DecoderMethod = "decodeUImmOperand<5>";
627 def PPCU6ImmAsmOperand : AsmOperandClass {
628 let Name = "U6Imm"; let PredicateMethod = "isU6Imm";
629 let RenderMethod = "addImmOperands";
631 def u6imm : Operand<i32> {
632 let PrintMethod = "printU6ImmOperand";
633 let ParserMatchClass = PPCU6ImmAsmOperand;
634 let DecoderMethod = "decodeUImmOperand<6>";
636 def PPCU7ImmAsmOperand : AsmOperandClass {
637 let Name = "U7Imm"; let PredicateMethod = "isU7Imm";
638 let RenderMethod = "addImmOperands";
640 def u7imm : Operand<i32> {
641 let PrintMethod = "printU7ImmOperand";
642 let ParserMatchClass = PPCU7ImmAsmOperand;
643 let DecoderMethod = "decodeUImmOperand<7>";
645 def PPCU8ImmAsmOperand : AsmOperandClass {
646 let Name = "U8Imm"; let PredicateMethod = "isU8Imm";
647 let RenderMethod = "addImmOperands";
649 def u8imm : Operand<i32> {
650 let PrintMethod = "printU8ImmOperand";
651 let ParserMatchClass = PPCU8ImmAsmOperand;
652 let DecoderMethod = "decodeUImmOperand<8>";
654 def PPCU10ImmAsmOperand : AsmOperandClass {
655 let Name = "U10Imm"; let PredicateMethod = "isU10Imm";
656 let RenderMethod = "addImmOperands";
658 def u10imm : Operand<i32> {
659 let PrintMethod = "printU10ImmOperand";
660 let ParserMatchClass = PPCU10ImmAsmOperand;
661 let DecoderMethod = "decodeUImmOperand<10>";
663 def PPCU12ImmAsmOperand : AsmOperandClass {
664 let Name = "U12Imm"; let PredicateMethod = "isU12Imm";
665 let RenderMethod = "addImmOperands";
667 def u12imm : Operand<i32> {
668 let PrintMethod = "printU12ImmOperand";
669 let ParserMatchClass = PPCU12ImmAsmOperand;
670 let DecoderMethod = "decodeUImmOperand<12>";
672 def PPCS16ImmAsmOperand : AsmOperandClass {
673 let Name = "S16Imm"; let PredicateMethod = "isS16Imm";
674 let RenderMethod = "addS16ImmOperands";
676 def s16imm : Operand<i32> {
677 let PrintMethod = "printS16ImmOperand";
678 let EncoderMethod = "getImm16Encoding";
679 let ParserMatchClass = PPCS16ImmAsmOperand;
680 let DecoderMethod = "decodeSImmOperand<16>";
682 def PPCU16ImmAsmOperand : AsmOperandClass {
683 let Name = "U16Imm"; let PredicateMethod = "isU16Imm";
684 let RenderMethod = "addU16ImmOperands";
686 def u16imm : Operand<i32> {
687 let PrintMethod = "printU16ImmOperand";
688 let EncoderMethod = "getImm16Encoding";
689 let ParserMatchClass = PPCU16ImmAsmOperand;
690 let DecoderMethod = "decodeUImmOperand<16>";
692 def PPCS17ImmAsmOperand : AsmOperandClass {
693 let Name = "S17Imm"; let PredicateMethod = "isS17Imm";
694 let RenderMethod = "addS16ImmOperands";
696 def s17imm : Operand<i32> {
697 // This operand type is used for addis/lis to allow the assembler parser
698 // to accept immediates in the range -65536..65535 for compatibility with
699 // the GNU assembler. The operand is treated as 16-bit otherwise.
700 let PrintMethod = "printS16ImmOperand";
701 let EncoderMethod = "getImm16Encoding";
702 let ParserMatchClass = PPCS17ImmAsmOperand;
703 let DecoderMethod = "decodeSImmOperand<16>";
706 def fpimm0 : PatLeaf<(fpimm), [{ return N->isExactlyValue(+0.0); }]>;
708 def PPCDirectBrAsmOperand : AsmOperandClass {
709 let Name = "DirectBr"; let PredicateMethod = "isDirectBr";
710 let RenderMethod = "addBranchTargetOperands";
712 def directbrtarget : Operand<OtherVT> {
713 let PrintMethod = "printBranchOperand";
714 let EncoderMethod = "getDirectBrEncoding";
715 let ParserMatchClass = PPCDirectBrAsmOperand;
717 def absdirectbrtarget : Operand<OtherVT> {
718 let PrintMethod = "printAbsBranchOperand";
719 let EncoderMethod = "getAbsDirectBrEncoding";
720 let ParserMatchClass = PPCDirectBrAsmOperand;
722 def PPCCondBrAsmOperand : AsmOperandClass {
723 let Name = "CondBr"; let PredicateMethod = "isCondBr";
724 let RenderMethod = "addBranchTargetOperands";
726 def condbrtarget : Operand<OtherVT> {
727 let PrintMethod = "printBranchOperand";
728 let EncoderMethod = "getCondBrEncoding";
729 let ParserMatchClass = PPCCondBrAsmOperand;
731 def abscondbrtarget : Operand<OtherVT> {
732 let PrintMethod = "printAbsBranchOperand";
733 let EncoderMethod = "getAbsCondBrEncoding";
734 let ParserMatchClass = PPCCondBrAsmOperand;
736 def calltarget : Operand<iPTR> {
737 let PrintMethod = "printBranchOperand";
738 let EncoderMethod = "getDirectBrEncoding";
739 let DecoderMethod = "DecodePCRel24BranchTarget";
740 let ParserMatchClass = PPCDirectBrAsmOperand;
741 let OperandType = "OPERAND_PCREL";
743 def abscalltarget : Operand<iPTR> {
744 let PrintMethod = "printAbsBranchOperand";
745 let EncoderMethod = "getAbsDirectBrEncoding";
746 let ParserMatchClass = PPCDirectBrAsmOperand;
748 def PPCCRBitMaskOperand : AsmOperandClass {
749 let Name = "CRBitMask"; let PredicateMethod = "isCRBitMask";
751 def crbitm: Operand<i8> {
752 let PrintMethod = "printcrbitm";
753 let EncoderMethod = "get_crbitm_encoding";
754 let DecoderMethod = "decodeCRBitMOperand";
755 let ParserMatchClass = PPCCRBitMaskOperand;
758 // A version of ptr_rc which excludes R0 (or X0 in 64-bit mode).
759 def PPCRegGxRCNoR0Operand : AsmOperandClass {
760 let Name = "RegGxRCNoR0"; let PredicateMethod = "isRegNumber";
762 def ptr_rc_nor0 : Operand<iPTR>, PointerLikeRegClass<1> {
763 let ParserMatchClass = PPCRegGxRCNoR0Operand;
765 // A version of ptr_rc usable with the asm parser.
766 def PPCRegGxRCOperand : AsmOperandClass {
767 let Name = "RegGxRC"; let PredicateMethod = "isRegNumber";
769 def ptr_rc_idx : Operand<iPTR>, PointerLikeRegClass<0> {
770 let ParserMatchClass = PPCRegGxRCOperand;
773 def PPCDispRIOperand : AsmOperandClass {
774 let Name = "DispRI"; let PredicateMethod = "isS16Imm";
775 let RenderMethod = "addS16ImmOperands";
777 def dispRI : Operand<iPTR> {
778 let ParserMatchClass = PPCDispRIOperand;
780 def PPCDispRIXOperand : AsmOperandClass {
781 let Name = "DispRIX"; let PredicateMethod = "isS16ImmX4";
782 let RenderMethod = "addImmOperands";
784 def dispRIX : Operand<iPTR> {
785 let ParserMatchClass = PPCDispRIXOperand;
787 def PPCDispRIX16Operand : AsmOperandClass {
788 let Name = "DispRIX16"; let PredicateMethod = "isS16ImmX16";
789 let RenderMethod = "addImmOperands";
791 def dispRIX16 : Operand<iPTR> {
792 let ParserMatchClass = PPCDispRIX16Operand;
794 def PPCDispSPE8Operand : AsmOperandClass {
795 let Name = "DispSPE8"; let PredicateMethod = "isU8ImmX8";
796 let RenderMethod = "addImmOperands";
798 def dispSPE8 : Operand<iPTR> {
799 let ParserMatchClass = PPCDispSPE8Operand;
801 def PPCDispSPE4Operand : AsmOperandClass {
802 let Name = "DispSPE4"; let PredicateMethod = "isU7ImmX4";
803 let RenderMethod = "addImmOperands";
805 def dispSPE4 : Operand<iPTR> {
806 let ParserMatchClass = PPCDispSPE4Operand;
808 def PPCDispSPE2Operand : AsmOperandClass {
809 let Name = "DispSPE2"; let PredicateMethod = "isU6ImmX2";
810 let RenderMethod = "addImmOperands";
812 def dispSPE2 : Operand<iPTR> {
813 let ParserMatchClass = PPCDispSPE2Operand;
816 def memri : Operand<iPTR> {
817 let PrintMethod = "printMemRegImm";
818 let MIOperandInfo = (ops dispRI:$imm, ptr_rc_nor0:$reg);
819 let EncoderMethod = "getMemRIEncoding";
820 let DecoderMethod = "decodeMemRIOperands";
822 def memrr : Operand<iPTR> {
823 let PrintMethod = "printMemRegReg";
824 let MIOperandInfo = (ops ptr_rc_nor0:$ptrreg, ptr_rc_idx:$offreg);
826 def memrix : Operand<iPTR> { // memri where the imm is 4-aligned.
827 let PrintMethod = "printMemRegImm";
828 let MIOperandInfo = (ops dispRIX:$imm, ptr_rc_nor0:$reg);
829 let EncoderMethod = "getMemRIXEncoding";
830 let DecoderMethod = "decodeMemRIXOperands";
832 def memrix16 : Operand<iPTR> { // memri, imm is 16-aligned, 12-bit, Inst{16:27}
833 let PrintMethod = "printMemRegImm";
834 let MIOperandInfo = (ops dispRIX16:$imm, ptr_rc_nor0:$reg);
835 let EncoderMethod = "getMemRIX16Encoding";
836 let DecoderMethod = "decodeMemRIX16Operands";
838 def spe8dis : Operand<iPTR> { // SPE displacement where the imm is 8-aligned.
839 let PrintMethod = "printMemRegImm";
840 let MIOperandInfo = (ops dispSPE8:$imm, ptr_rc_nor0:$reg);
841 let EncoderMethod = "getSPE8DisEncoding";
842 let DecoderMethod = "decodeSPE8Operands";
844 def spe4dis : Operand<iPTR> { // SPE displacement where the imm is 4-aligned.
845 let PrintMethod = "printMemRegImm";
846 let MIOperandInfo = (ops dispSPE4:$imm, ptr_rc_nor0:$reg);
847 let EncoderMethod = "getSPE4DisEncoding";
848 let DecoderMethod = "decodeSPE4Operands";
850 def spe2dis : Operand<iPTR> { // SPE displacement where the imm is 2-aligned.
851 let PrintMethod = "printMemRegImm";
852 let MIOperandInfo = (ops dispSPE2:$imm, ptr_rc_nor0:$reg);
853 let EncoderMethod = "getSPE2DisEncoding";
854 let DecoderMethod = "decodeSPE2Operands";
857 // A single-register address. This is used with the SjLj
858 // pseudo-instructions which tranlates to LD/LWZ. These instructions requires
859 // G8RC_NOX0 registers.
860 def memr : Operand<iPTR> {
861 let MIOperandInfo = (ops ptr_rc_nor0:$ptrreg);
863 def PPCTLSRegOperand : AsmOperandClass {
864 let Name = "TLSReg"; let PredicateMethod = "isTLSReg";
865 let RenderMethod = "addTLSRegOperands";
867 def tlsreg32 : Operand<i32> {
868 let EncoderMethod = "getTLSRegEncoding";
869 let ParserMatchClass = PPCTLSRegOperand;
871 def tlsgd32 : Operand<i32> {}
872 def tlscall32 : Operand<i32> {
873 let PrintMethod = "printTLSCall";
874 let MIOperandInfo = (ops calltarget:$func, tlsgd32:$sym);
875 let EncoderMethod = "getTLSCallEncoding";
878 // PowerPC Predicate operand.
879 def pred : Operand<OtherVT> {
880 let PrintMethod = "printPredicateOperand";
881 let MIOperandInfo = (ops i32imm:$bibo, crrc:$reg);
884 // Define PowerPC specific addressing mode.
885 def iaddr : ComplexPattern<iPTR, 2, "SelectAddrImm", [], []>;
886 def xaddr : ComplexPattern<iPTR, 2, "SelectAddrIdx", [], []>;
887 def xoaddr : ComplexPattern<iPTR, 2, "SelectAddrIdxOnly",[], []>;
888 def ixaddr : ComplexPattern<iPTR, 2, "SelectAddrImmX4", [], []>; // "std"
889 def iqaddr : ComplexPattern<iPTR, 2, "SelectAddrImmX16", [], []>; // "stxv"
891 // The address in a single register. This is used with the SjLj
892 // pseudo-instructions.
893 def addr : ComplexPattern<iPTR, 1, "SelectAddr",[], []>;
895 /// This is just the offset part of iaddr, used for preinc.
896 def iaddroff : ComplexPattern<iPTR, 1, "SelectAddrImmOffs", [], []>;
898 //===----------------------------------------------------------------------===//
899 // PowerPC Instruction Predicate Definitions.
900 def In32BitMode : Predicate<"!PPCSubTarget->isPPC64()">;
901 def In64BitMode : Predicate<"PPCSubTarget->isPPC64()">;
902 def IsBookE : Predicate<"PPCSubTarget->isBookE()">;
903 def IsNotBookE : Predicate<"!PPCSubTarget->isBookE()">;
904 def HasOnlyMSYNC : Predicate<"PPCSubTarget->hasOnlyMSYNC()">;
905 def HasSYNC : Predicate<"!PPCSubTarget->hasOnlyMSYNC()">;
906 def IsPPC4xx : Predicate<"PPCSubTarget->isPPC4xx()">;
907 def IsPPC6xx : Predicate<"PPCSubTarget->isPPC6xx()">;
908 def IsE500 : Predicate<"PPCSubTarget->isE500()">;
909 def HasSPE : Predicate<"PPCSubTarget->hasSPE()">;
910 def HasICBT : Predicate<"PPCSubTarget->hasICBT()">;
911 def HasPartwordAtomics : Predicate<"PPCSubTarget->hasPartwordAtomics()">;
912 def NoNaNsFPMath : Predicate<"TM.Options.NoNaNsFPMath">;
913 def NaNsFPMath : Predicate<"!TM.Options.NoNaNsFPMath">;
914 def HasBPERMD : Predicate<"PPCSubTarget->hasBPERMD()">;
915 def HasExtDiv : Predicate<"PPCSubTarget->hasExtDiv()">;
916 def IsISA3_0 : Predicate<"PPCSubTarget->isISA3_0()">;
917 def HasFPU : Predicate<"PPCSubTarget->hasFPU()">;
919 //===----------------------------------------------------------------------===//
920 // PowerPC Multiclass Definitions.
922 multiclass XForm_6r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
923 string asmbase, string asmstr, InstrItinClass itin,
925 let BaseName = asmbase in {
926 def NAME : XForm_6<opcode, xo, OOL, IOL,
927 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
928 pattern>, RecFormRel;
930 def o : XForm_6<opcode, xo, OOL, IOL,
931 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
932 []>, isDOT, RecFormRel;
936 multiclass XForm_6rc<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
937 string asmbase, string asmstr, InstrItinClass itin,
939 let BaseName = asmbase in {
940 let Defs = [CARRY] in
941 def NAME : XForm_6<opcode, xo, OOL, IOL,
942 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
943 pattern>, RecFormRel;
944 let Defs = [CARRY, CR0] in
945 def o : XForm_6<opcode, xo, OOL, IOL,
946 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
947 []>, isDOT, RecFormRel;
951 multiclass XForm_10rc<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
952 string asmbase, string asmstr, InstrItinClass itin,
954 let BaseName = asmbase in {
955 let Defs = [CARRY] in
956 def NAME : XForm_10<opcode, xo, OOL, IOL,
957 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
958 pattern>, RecFormRel;
959 let Defs = [CARRY, CR0] in
960 def o : XForm_10<opcode, xo, OOL, IOL,
961 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
962 []>, isDOT, RecFormRel;
966 multiclass XForm_11r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
967 string asmbase, string asmstr, InstrItinClass itin,
969 let BaseName = asmbase in {
970 def NAME : XForm_11<opcode, xo, OOL, IOL,
971 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
972 pattern>, RecFormRel;
974 def o : XForm_11<opcode, xo, OOL, IOL,
975 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
976 []>, isDOT, RecFormRel;
980 multiclass XOForm_1r<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
981 string asmbase, string asmstr, InstrItinClass itin,
983 let BaseName = asmbase in {
984 def NAME : XOForm_1<opcode, xo, oe, OOL, IOL,
985 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
986 pattern>, RecFormRel;
988 def o : XOForm_1<opcode, xo, oe, OOL, IOL,
989 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
990 []>, isDOT, RecFormRel;
994 // Multiclass for instructions for which the non record form is not cracked
995 // and the record form is cracked (i.e. divw, mullw, etc.)
996 multiclass XOForm_1rcr<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
997 string asmbase, string asmstr, InstrItinClass itin,
999 let BaseName = asmbase in {
1000 def NAME : XOForm_1<opcode, xo, oe, OOL, IOL,
1001 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1002 pattern>, RecFormRel;
1004 def o : XOForm_1<opcode, xo, oe, OOL, IOL,
1005 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1006 []>, isDOT, RecFormRel, PPC970_DGroup_First,
1007 PPC970_DGroup_Cracked;
1011 multiclass XOForm_1rc<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
1012 string asmbase, string asmstr, InstrItinClass itin,
1013 list<dag> pattern> {
1014 let BaseName = asmbase in {
1015 let Defs = [CARRY] in
1016 def NAME : XOForm_1<opcode, xo, oe, OOL, IOL,
1017 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1018 pattern>, RecFormRel;
1019 let Defs = [CARRY, CR0] in
1020 def o : XOForm_1<opcode, xo, oe, OOL, IOL,
1021 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1022 []>, isDOT, RecFormRel;
1026 multiclass XOForm_3r<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
1027 string asmbase, string asmstr, InstrItinClass itin,
1028 list<dag> pattern> {
1029 let BaseName = asmbase in {
1030 def NAME : XOForm_3<opcode, xo, oe, OOL, IOL,
1031 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1032 pattern>, RecFormRel;
1034 def o : XOForm_3<opcode, xo, oe, OOL, IOL,
1035 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1036 []>, isDOT, RecFormRel;
1040 multiclass XOForm_3rc<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
1041 string asmbase, string asmstr, InstrItinClass itin,
1042 list<dag> pattern> {
1043 let BaseName = asmbase in {
1044 let Defs = [CARRY] in
1045 def NAME : XOForm_3<opcode, xo, oe, OOL, IOL,
1046 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1047 pattern>, RecFormRel;
1048 let Defs = [CARRY, CR0] in
1049 def o : XOForm_3<opcode, xo, oe, OOL, IOL,
1050 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1051 []>, isDOT, RecFormRel;
1055 multiclass MForm_2r<bits<6> opcode, dag OOL, dag IOL,
1056 string asmbase, string asmstr, InstrItinClass itin,
1057 list<dag> pattern> {
1058 let BaseName = asmbase in {
1059 def NAME : MForm_2<opcode, OOL, IOL,
1060 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1061 pattern>, RecFormRel;
1063 def o : MForm_2<opcode, OOL, IOL,
1064 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1065 []>, isDOT, RecFormRel;
1069 multiclass MDForm_1r<bits<6> opcode, bits<3> xo, dag OOL, dag IOL,
1070 string asmbase, string asmstr, InstrItinClass itin,
1071 list<dag> pattern> {
1072 let BaseName = asmbase in {
1073 def NAME : MDForm_1<opcode, xo, OOL, IOL,
1074 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1075 pattern>, RecFormRel;
1077 def o : MDForm_1<opcode, xo, OOL, IOL,
1078 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1079 []>, isDOT, RecFormRel;
1083 multiclass MDSForm_1r<bits<6> opcode, bits<4> xo, dag OOL, dag IOL,
1084 string asmbase, string asmstr, InstrItinClass itin,
1085 list<dag> pattern> {
1086 let BaseName = asmbase in {
1087 def NAME : MDSForm_1<opcode, xo, OOL, IOL,
1088 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1089 pattern>, RecFormRel;
1091 def o : MDSForm_1<opcode, xo, OOL, IOL,
1092 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1093 []>, isDOT, RecFormRel;
1097 multiclass XSForm_1rc<bits<6> opcode, bits<9> xo, dag OOL, dag IOL,
1098 string asmbase, string asmstr, InstrItinClass itin,
1099 list<dag> pattern> {
1100 let BaseName = asmbase in {
1101 let Defs = [CARRY] in
1102 def NAME : XSForm_1<opcode, xo, OOL, IOL,
1103 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1104 pattern>, RecFormRel;
1105 let Defs = [CARRY, CR0] in
1106 def o : XSForm_1<opcode, xo, OOL, IOL,
1107 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1108 []>, isDOT, RecFormRel;
1112 multiclass XSForm_1r<bits<6> opcode, bits<9> xo, dag OOL, dag IOL,
1113 string asmbase, string asmstr, InstrItinClass itin,
1114 list<dag> pattern> {
1115 let BaseName = asmbase in {
1116 def NAME : XSForm_1<opcode, xo, OOL, IOL,
1117 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1118 pattern>, RecFormRel;
1120 def o : XSForm_1<opcode, xo, OOL, IOL,
1121 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1122 []>, isDOT, RecFormRel;
1126 multiclass XForm_26r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
1127 string asmbase, string asmstr, InstrItinClass itin,
1128 list<dag> pattern> {
1129 let BaseName = asmbase in {
1130 def NAME : XForm_26<opcode, xo, OOL, IOL,
1131 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1132 pattern>, RecFormRel;
1134 def o : XForm_26<opcode, xo, OOL, IOL,
1135 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1136 []>, isDOT, RecFormRel;
1140 multiclass XForm_28r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
1141 string asmbase, string asmstr, InstrItinClass itin,
1142 list<dag> pattern> {
1143 let BaseName = asmbase in {
1144 def NAME : XForm_28<opcode, xo, OOL, IOL,
1145 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1146 pattern>, RecFormRel;
1148 def o : XForm_28<opcode, xo, OOL, IOL,
1149 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1150 []>, isDOT, RecFormRel;
1154 multiclass AForm_1r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL,
1155 string asmbase, string asmstr, InstrItinClass itin,
1156 list<dag> pattern> {
1157 let BaseName = asmbase in {
1158 def NAME : AForm_1<opcode, xo, OOL, IOL,
1159 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1160 pattern>, RecFormRel;
1162 def o : AForm_1<opcode, xo, OOL, IOL,
1163 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1164 []>, isDOT, RecFormRel;
1168 multiclass AForm_2r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL,
1169 string asmbase, string asmstr, InstrItinClass itin,
1170 list<dag> pattern> {
1171 let BaseName = asmbase in {
1172 def NAME : AForm_2<opcode, xo, OOL, IOL,
1173 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1174 pattern>, RecFormRel;
1176 def o : AForm_2<opcode, xo, OOL, IOL,
1177 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1178 []>, isDOT, RecFormRel;
1182 multiclass AForm_3r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL,
1183 string asmbase, string asmstr, InstrItinClass itin,
1184 list<dag> pattern> {
1185 let BaseName = asmbase in {
1186 def NAME : AForm_3<opcode, xo, OOL, IOL,
1187 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1188 pattern>, RecFormRel;
1190 def o : AForm_3<opcode, xo, OOL, IOL,
1191 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1192 []>, isDOT, RecFormRel;
1196 //===----------------------------------------------------------------------===//
1197 // PowerPC Instruction Definitions.
1199 // Pseudo instructions:
1201 let hasCtrlDep = 1 in {
1202 let Defs = [R1], Uses = [R1] in {
1203 def ADJCALLSTACKDOWN : PPCEmitTimePseudo<(outs), (ins u16imm:$amt1, u16imm:$amt2),
1204 "#ADJCALLSTACKDOWN $amt1 $amt2",
1205 [(callseq_start timm:$amt1, timm:$amt2)]>;
1206 def ADJCALLSTACKUP : PPCEmitTimePseudo<(outs), (ins u16imm:$amt1, u16imm:$amt2),
1207 "#ADJCALLSTACKUP $amt1 $amt2",
1208 [(callseq_end timm:$amt1, timm:$amt2)]>;
1211 def UPDATE_VRSAVE : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc:$rS),
1212 "UPDATE_VRSAVE $rD, $rS", []>;
1215 let Defs = [R1], Uses = [R1] in
1216 def DYNALLOC : PPCEmitTimePseudo<(outs gprc:$result), (ins gprc:$negsize, memri:$fpsi), "#DYNALLOC",
1218 (PPCdynalloc i32:$negsize, iaddr:$fpsi))]>;
1219 def DYNAREAOFFSET : PPCEmitTimePseudo<(outs i32imm:$result), (ins memri:$fpsi), "#DYNAREAOFFSET",
1220 [(set i32:$result, (PPCdynareaoffset iaddr:$fpsi))]>;
1222 // SELECT_CC_* - Used to implement the SELECT_CC DAG operation. Expanded after
1223 // instruction selection into a branch sequence.
1224 let PPC970_Single = 1 in {
1225 // Note that SELECT_CC_I4 and SELECT_CC_I8 use the no-r0 register classes
1226 // because either operand might become the first operand in an isel, and
1227 // that operand cannot be r0.
1228 def SELECT_CC_I4 : PPCCustomInserterPseudo<(outs gprc:$dst), (ins crrc:$cond,
1229 gprc_nor0:$T, gprc_nor0:$F,
1230 i32imm:$BROPC), "#SELECT_CC_I4",
1232 def SELECT_CC_I8 : PPCCustomInserterPseudo<(outs g8rc:$dst), (ins crrc:$cond,
1233 g8rc_nox0:$T, g8rc_nox0:$F,
1234 i32imm:$BROPC), "#SELECT_CC_I8",
1236 def SELECT_CC_F4 : PPCCustomInserterPseudo<(outs f4rc:$dst), (ins crrc:$cond, f4rc:$T, f4rc:$F,
1237 i32imm:$BROPC), "#SELECT_CC_F4",
1239 def SELECT_CC_F8 : PPCCustomInserterPseudo<(outs f8rc:$dst), (ins crrc:$cond, f8rc:$T, f8rc:$F,
1240 i32imm:$BROPC), "#SELECT_CC_F8",
1242 def SELECT_CC_F16 : PPCCustomInserterPseudo<(outs vrrc:$dst), (ins crrc:$cond, vrrc:$T, vrrc:$F,
1243 i32imm:$BROPC), "#SELECT_CC_F16",
1245 def SELECT_CC_VRRC: PPCCustomInserterPseudo<(outs vrrc:$dst), (ins crrc:$cond, vrrc:$T, vrrc:$F,
1246 i32imm:$BROPC), "#SELECT_CC_VRRC",
1249 // SELECT_* pseudo instructions, like SELECT_CC_* but taking condition
1250 // register bit directly.
1251 def SELECT_I4 : PPCCustomInserterPseudo<(outs gprc:$dst), (ins crbitrc:$cond,
1252 gprc_nor0:$T, gprc_nor0:$F), "#SELECT_I4",
1253 [(set i32:$dst, (select i1:$cond, i32:$T, i32:$F))]>;
1254 def SELECT_I8 : PPCCustomInserterPseudo<(outs g8rc:$dst), (ins crbitrc:$cond,
1255 g8rc_nox0:$T, g8rc_nox0:$F), "#SELECT_I8",
1256 [(set i64:$dst, (select i1:$cond, i64:$T, i64:$F))]>;
1257 let Predicates = [HasFPU] in {
1258 def SELECT_F4 : PPCCustomInserterPseudo<(outs f4rc:$dst), (ins crbitrc:$cond,
1259 f4rc:$T, f4rc:$F), "#SELECT_F4",
1260 [(set f32:$dst, (select i1:$cond, f32:$T, f32:$F))]>;
1261 def SELECT_F8 : PPCCustomInserterPseudo<(outs f8rc:$dst), (ins crbitrc:$cond,
1262 f8rc:$T, f8rc:$F), "#SELECT_F8",
1263 [(set f64:$dst, (select i1:$cond, f64:$T, f64:$F))]>;
1264 def SELECT_F16 : PPCCustomInserterPseudo<(outs vrrc:$dst), (ins crbitrc:$cond,
1265 vrrc:$T, vrrc:$F), "#SELECT_F16",
1266 [(set f128:$dst, (select i1:$cond, f128:$T, f128:$F))]>;
1268 def SELECT_VRRC: PPCCustomInserterPseudo<(outs vrrc:$dst), (ins crbitrc:$cond,
1269 vrrc:$T, vrrc:$F), "#SELECT_VRRC",
1271 (select i1:$cond, v4i32:$T, v4i32:$F))]>;
1274 // SPILL_CR - Indicate that we're dumping the CR register, so we'll need to
1275 // scavenge a register for it.
1276 let mayStore = 1 in {
1277 def SPILL_CR : PPCEmitTimePseudo<(outs), (ins crrc:$cond, memri:$F),
1279 def SPILL_CRBIT : PPCEmitTimePseudo<(outs), (ins crbitrc:$cond, memri:$F),
1280 "#SPILL_CRBIT", []>;
1283 // RESTORE_CR - Indicate that we're restoring the CR register (previously
1284 // spilled), so we'll need to scavenge a register for it.
1285 let mayLoad = 1 in {
1286 def RESTORE_CR : PPCEmitTimePseudo<(outs crrc:$cond), (ins memri:$F),
1288 def RESTORE_CRBIT : PPCEmitTimePseudo<(outs crbitrc:$cond), (ins memri:$F),
1289 "#RESTORE_CRBIT", []>;
1292 let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7 in {
1293 let isReturn = 1, Uses = [LR, RM] in
1294 def BLR : XLForm_2_ext<19, 16, 20, 0, 0, (outs), (ins), "blr", IIC_BrB,
1295 [(retflag)]>, Requires<[In32BitMode]>;
1296 let isBranch = 1, isIndirectBranch = 1, Uses = [CTR] in {
1297 def BCTR : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
1300 let isCodeGenOnly = 1 in {
1301 def BCCCTR : XLForm_2_br<19, 528, 0, (outs), (ins pred:$cond),
1302 "b${cond:cc}ctr${cond:pm} ${cond:reg}", IIC_BrB,
1305 def BCCTR : XLForm_2_br2<19, 528, 12, 0, (outs), (ins crbitrc:$bi),
1306 "bcctr 12, $bi, 0", IIC_BrB, []>;
1307 def BCCTRn : XLForm_2_br2<19, 528, 4, 0, (outs), (ins crbitrc:$bi),
1308 "bcctr 4, $bi, 0", IIC_BrB, []>;
1314 def MovePCtoLR : PPCEmitTimePseudo<(outs), (ins), "#MovePCtoLR", []>,
1317 def MoveGOTtoLR : PPCEmitTimePseudo<(outs), (ins), "#MoveGOTtoLR", []>,
1320 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7 in {
1321 let isBarrier = 1 in {
1322 def B : IForm<18, 0, 0, (outs), (ins directbrtarget:$dst),
1325 def BA : IForm<18, 1, 0, (outs), (ins absdirectbrtarget:$dst),
1326 "ba $dst", IIC_BrB, []>;
1329 // BCC represents an arbitrary conditional branch on a predicate.
1330 // FIXME: should be able to write a pattern for PPCcondbranch, but can't use
1331 // a two-value operand where a dag node expects two operands. :(
1332 let isCodeGenOnly = 1 in {
1333 class BCC_class : BForm<16, 0, 0, (outs), (ins pred:$cond, condbrtarget:$dst),
1334 "b${cond:cc}${cond:pm} ${cond:reg}, $dst"
1335 /*[(PPCcondbranch crrc:$crS, imm:$opc, bb:$dst)]*/>;
1336 def BCC : BCC_class;
1338 // The same as BCC, except that it's not a terminator. Used for introducing
1339 // control flow dependency without creating new blocks.
1340 let isTerminator = 0 in def CTRL_DEP : BCC_class;
1342 def BCCA : BForm<16, 1, 0, (outs), (ins pred:$cond, abscondbrtarget:$dst),
1343 "b${cond:cc}a${cond:pm} ${cond:reg}, $dst">;
1345 let isReturn = 1, Uses = [LR, RM] in
1346 def BCCLR : XLForm_2_br<19, 16, 0, (outs), (ins pred:$cond),
1347 "b${cond:cc}lr${cond:pm} ${cond:reg}", IIC_BrB, []>;
1350 let isCodeGenOnly = 1 in {
1351 let Pattern = [(brcond i1:$bi, bb:$dst)] in
1352 def BC : BForm_4<16, 12, 0, 0, (outs), (ins crbitrc:$bi, condbrtarget:$dst),
1353 "bc 12, $bi, $dst">;
1355 let Pattern = [(brcond (not i1:$bi), bb:$dst)] in
1356 def BCn : BForm_4<16, 4, 0, 0, (outs), (ins crbitrc:$bi, condbrtarget:$dst),
1359 let isReturn = 1, Uses = [LR, RM] in
1360 def BCLR : XLForm_2_br2<19, 16, 12, 0, (outs), (ins crbitrc:$bi),
1361 "bclr 12, $bi, 0", IIC_BrB, []>;
1362 def BCLRn : XLForm_2_br2<19, 16, 4, 0, (outs), (ins crbitrc:$bi),
1363 "bclr 4, $bi, 0", IIC_BrB, []>;
1366 let isReturn = 1, Defs = [CTR], Uses = [CTR, LR, RM] in {
1367 def BDZLR : XLForm_2_ext<19, 16, 18, 0, 0, (outs), (ins),
1368 "bdzlr", IIC_BrB, []>;
1369 def BDNZLR : XLForm_2_ext<19, 16, 16, 0, 0, (outs), (ins),
1370 "bdnzlr", IIC_BrB, []>;
1371 def BDZLRp : XLForm_2_ext<19, 16, 27, 0, 0, (outs), (ins),
1372 "bdzlr+", IIC_BrB, []>;
1373 def BDNZLRp: XLForm_2_ext<19, 16, 25, 0, 0, (outs), (ins),
1374 "bdnzlr+", IIC_BrB, []>;
1375 def BDZLRm : XLForm_2_ext<19, 16, 26, 0, 0, (outs), (ins),
1376 "bdzlr-", IIC_BrB, []>;
1377 def BDNZLRm: XLForm_2_ext<19, 16, 24, 0, 0, (outs), (ins),
1378 "bdnzlr-", IIC_BrB, []>;
1381 let Defs = [CTR], Uses = [CTR] in {
1382 def BDZ : BForm_1<16, 18, 0, 0, (outs), (ins condbrtarget:$dst),
1384 def BDNZ : BForm_1<16, 16, 0, 0, (outs), (ins condbrtarget:$dst),
1386 def BDZA : BForm_1<16, 18, 1, 0, (outs), (ins abscondbrtarget:$dst),
1388 def BDNZA : BForm_1<16, 16, 1, 0, (outs), (ins abscondbrtarget:$dst),
1390 def BDZp : BForm_1<16, 27, 0, 0, (outs), (ins condbrtarget:$dst),
1392 def BDNZp: BForm_1<16, 25, 0, 0, (outs), (ins condbrtarget:$dst),
1394 def BDZAp : BForm_1<16, 27, 1, 0, (outs), (ins abscondbrtarget:$dst),
1396 def BDNZAp: BForm_1<16, 25, 1, 0, (outs), (ins abscondbrtarget:$dst),
1398 def BDZm : BForm_1<16, 26, 0, 0, (outs), (ins condbrtarget:$dst),
1400 def BDNZm: BForm_1<16, 24, 0, 0, (outs), (ins condbrtarget:$dst),
1402 def BDZAm : BForm_1<16, 26, 1, 0, (outs), (ins abscondbrtarget:$dst),
1404 def BDNZAm: BForm_1<16, 24, 1, 0, (outs), (ins abscondbrtarget:$dst),
1409 // The unconditional BCL used by the SjLj setjmp code.
1410 let isCall = 1, hasCtrlDep = 1, isCodeGenOnly = 1, PPC970_Unit = 7 in {
1411 let Defs = [LR], Uses = [RM] in {
1412 def BCLalways : BForm_2<16, 20, 31, 0, 1, (outs), (ins condbrtarget:$dst),
1413 "bcl 20, 31, $dst">;
1417 let isCall = 1, PPC970_Unit = 7, Defs = [LR] in {
1418 // Convenient aliases for call instructions
1419 let Uses = [RM] in {
1420 def BL : IForm<18, 0, 1, (outs), (ins calltarget:$func),
1421 "bl $func", IIC_BrB, []>; // See Pat patterns below.
1422 def BLA : IForm<18, 1, 1, (outs), (ins abscalltarget:$func),
1423 "bla $func", IIC_BrB, [(PPCcall (i32 imm:$func))]>;
1425 let isCodeGenOnly = 1 in {
1426 def BL_TLS : IForm<18, 0, 1, (outs), (ins tlscall32:$func),
1427 "bl $func", IIC_BrB, []>;
1428 def BCCL : BForm<16, 0, 1, (outs), (ins pred:$cond, condbrtarget:$dst),
1429 "b${cond:cc}l${cond:pm} ${cond:reg}, $dst">;
1430 def BCCLA : BForm<16, 1, 1, (outs), (ins pred:$cond, abscondbrtarget:$dst),
1431 "b${cond:cc}la${cond:pm} ${cond:reg}, $dst">;
1433 def BCL : BForm_4<16, 12, 0, 1, (outs),
1434 (ins crbitrc:$bi, condbrtarget:$dst),
1435 "bcl 12, $bi, $dst">;
1436 def BCLn : BForm_4<16, 4, 0, 1, (outs),
1437 (ins crbitrc:$bi, condbrtarget:$dst),
1438 "bcl 4, $bi, $dst">;
1441 let Uses = [CTR, RM] in {
1442 def BCTRL : XLForm_2_ext<19, 528, 20, 0, 1, (outs), (ins),
1443 "bctrl", IIC_BrB, [(PPCbctrl)]>,
1444 Requires<[In32BitMode]>;
1446 let isCodeGenOnly = 1 in {
1447 def BCCCTRL : XLForm_2_br<19, 528, 1, (outs), (ins pred:$cond),
1448 "b${cond:cc}ctrl${cond:pm} ${cond:reg}", IIC_BrB,
1451 def BCCTRL : XLForm_2_br2<19, 528, 12, 1, (outs), (ins crbitrc:$bi),
1452 "bcctrl 12, $bi, 0", IIC_BrB, []>;
1453 def BCCTRLn : XLForm_2_br2<19, 528, 4, 1, (outs), (ins crbitrc:$bi),
1454 "bcctrl 4, $bi, 0", IIC_BrB, []>;
1457 let Uses = [LR, RM] in {
1458 def BLRL : XLForm_2_ext<19, 16, 20, 0, 1, (outs), (ins),
1459 "blrl", IIC_BrB, []>;
1461 let isCodeGenOnly = 1 in {
1462 def BCCLRL : XLForm_2_br<19, 16, 1, (outs), (ins pred:$cond),
1463 "b${cond:cc}lrl${cond:pm} ${cond:reg}", IIC_BrB,
1466 def BCLRL : XLForm_2_br2<19, 16, 12, 1, (outs), (ins crbitrc:$bi),
1467 "bclrl 12, $bi, 0", IIC_BrB, []>;
1468 def BCLRLn : XLForm_2_br2<19, 16, 4, 1, (outs), (ins crbitrc:$bi),
1469 "bclrl 4, $bi, 0", IIC_BrB, []>;
1472 let Defs = [CTR], Uses = [CTR, RM] in {
1473 def BDZL : BForm_1<16, 18, 0, 1, (outs), (ins condbrtarget:$dst),
1475 def BDNZL : BForm_1<16, 16, 0, 1, (outs), (ins condbrtarget:$dst),
1477 def BDZLA : BForm_1<16, 18, 1, 1, (outs), (ins abscondbrtarget:$dst),
1479 def BDNZLA : BForm_1<16, 16, 1, 1, (outs), (ins abscondbrtarget:$dst),
1481 def BDZLp : BForm_1<16, 27, 0, 1, (outs), (ins condbrtarget:$dst),
1483 def BDNZLp: BForm_1<16, 25, 0, 1, (outs), (ins condbrtarget:$dst),
1485 def BDZLAp : BForm_1<16, 27, 1, 1, (outs), (ins abscondbrtarget:$dst),
1487 def BDNZLAp: BForm_1<16, 25, 1, 1, (outs), (ins abscondbrtarget:$dst),
1489 def BDZLm : BForm_1<16, 26, 0, 1, (outs), (ins condbrtarget:$dst),
1491 def BDNZLm: BForm_1<16, 24, 0, 1, (outs), (ins condbrtarget:$dst),
1493 def BDZLAm : BForm_1<16, 26, 1, 1, (outs), (ins abscondbrtarget:$dst),
1495 def BDNZLAm: BForm_1<16, 24, 1, 1, (outs), (ins abscondbrtarget:$dst),
1498 let Defs = [CTR], Uses = [CTR, LR, RM] in {
1499 def BDZLRL : XLForm_2_ext<19, 16, 18, 0, 1, (outs), (ins),
1500 "bdzlrl", IIC_BrB, []>;
1501 def BDNZLRL : XLForm_2_ext<19, 16, 16, 0, 1, (outs), (ins),
1502 "bdnzlrl", IIC_BrB, []>;
1503 def BDZLRLp : XLForm_2_ext<19, 16, 27, 0, 1, (outs), (ins),
1504 "bdzlrl+", IIC_BrB, []>;
1505 def BDNZLRLp: XLForm_2_ext<19, 16, 25, 0, 1, (outs), (ins),
1506 "bdnzlrl+", IIC_BrB, []>;
1507 def BDZLRLm : XLForm_2_ext<19, 16, 26, 0, 1, (outs), (ins),
1508 "bdzlrl-", IIC_BrB, []>;
1509 def BDNZLRLm: XLForm_2_ext<19, 16, 24, 0, 1, (outs), (ins),
1510 "bdnzlrl-", IIC_BrB, []>;
1514 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
1515 def TCRETURNdi :PPCEmitTimePseudo< (outs),
1516 (ins calltarget:$dst, i32imm:$offset),
1517 "#TC_RETURNd $dst $offset",
1521 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
1522 def TCRETURNai :PPCEmitTimePseudo<(outs), (ins abscalltarget:$func, i32imm:$offset),
1523 "#TC_RETURNa $func $offset",
1524 [(PPCtc_return (i32 imm:$func), imm:$offset)]>;
1526 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
1527 def TCRETURNri : PPCEmitTimePseudo<(outs), (ins CTRRC:$dst, i32imm:$offset),
1528 "#TC_RETURNr $dst $offset",
1532 let isCodeGenOnly = 1 in {
1534 let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, isBranch = 1,
1535 isIndirectBranch = 1, isCall = 1, isReturn = 1, Uses = [CTR, RM] in
1536 def TAILBCTR : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
1537 []>, Requires<[In32BitMode]>;
1539 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
1540 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
1541 def TAILB : IForm<18, 0, 0, (outs), (ins calltarget:$dst),
1545 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
1546 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
1547 def TAILBA : IForm<18, 0, 0, (outs), (ins abscalltarget:$dst),
1553 // While longjmp is a control-flow barrier (fallthrough isn't allowed), setjmp
1555 let hasSideEffects = 1 in {
1557 def EH_SjLj_SetJmp32 : PPCCustomInserterPseudo<(outs gprc:$dst), (ins memr:$buf),
1558 "#EH_SJLJ_SETJMP32",
1559 [(set i32:$dst, (PPCeh_sjlj_setjmp addr:$buf))]>,
1560 Requires<[In32BitMode]>;
1563 let hasSideEffects = 1, isBarrier = 1 in {
1564 let isTerminator = 1 in
1565 def EH_SjLj_LongJmp32 : PPCCustomInserterPseudo<(outs), (ins memr:$buf),
1566 "#EH_SJLJ_LONGJMP32",
1567 [(PPCeh_sjlj_longjmp addr:$buf)]>,
1568 Requires<[In32BitMode]>;
1571 // This pseudo is never removed from the function, as it serves as
1572 // a terminator. Size is set to 0 to prevent the builtin assembler
1573 // from emitting it.
1574 let isBranch = 1, isTerminator = 1, Size = 0 in {
1575 def EH_SjLj_Setup : PPCEmitTimePseudo<(outs), (ins directbrtarget:$dst),
1576 "#EH_SjLj_Setup\t$dst", []>;
1580 let PPC970_Unit = 7 in {
1581 def SC : SCForm<17, 1, (outs), (ins i32imm:$lev),
1582 "sc $lev", IIC_BrB, [(PPCsc (i32 imm:$lev))]>;
1585 // Branch history rolling buffer.
1586 def CLRBHRB : XForm_0<31, 430, (outs), (ins), "clrbhrb", IIC_BrB,
1588 PPC970_DGroup_Single;
1589 // The $dmy argument used for MFBHRBE is not needed; however, including
1590 // it avoids automatic generation of PPCFastISel::fastEmit_i(), which
1591 // interferes with necessary special handling (see PPCFastISel.cpp).
1592 def MFBHRBE : XFXForm_3p<31, 302, (outs gprc:$rD),
1593 (ins u10imm:$imm, u10imm:$dmy),
1594 "mfbhrbe $rD, $imm", IIC_BrB,
1596 (PPCmfbhrbe imm:$imm, imm:$dmy))]>,
1597 PPC970_DGroup_First;
1599 def RFEBB : XLForm_S<19, 146, (outs), (ins u1imm:$imm), "rfebb $imm",
1600 IIC_BrB, [(PPCrfebb (i32 imm:$imm))]>,
1601 PPC970_DGroup_Single;
1603 // DCB* instructions.
1604 def DCBA : DCB_Form<758, 0, (outs), (ins memrr:$dst), "dcba $dst",
1605 IIC_LdStDCBF, [(int_ppc_dcba xoaddr:$dst)]>,
1606 PPC970_DGroup_Single;
1607 def DCBI : DCB_Form<470, 0, (outs), (ins memrr:$dst), "dcbi $dst",
1608 IIC_LdStDCBF, [(int_ppc_dcbi xoaddr:$dst)]>,
1609 PPC970_DGroup_Single;
1610 def DCBST : DCB_Form<54, 0, (outs), (ins memrr:$dst), "dcbst $dst",
1611 IIC_LdStDCBF, [(int_ppc_dcbst xoaddr:$dst)]>,
1612 PPC970_DGroup_Single;
1613 def DCBZ : DCB_Form<1014, 0, (outs), (ins memrr:$dst), "dcbz $dst",
1614 IIC_LdStDCBF, [(int_ppc_dcbz xoaddr:$dst)]>,
1615 PPC970_DGroup_Single;
1616 def DCBZL : DCB_Form<1014, 1, (outs), (ins memrr:$dst), "dcbzl $dst",
1617 IIC_LdStDCBF, [(int_ppc_dcbzl xoaddr:$dst)]>,
1618 PPC970_DGroup_Single;
1620 def DCBF : DCB_Form_hint<86, (outs), (ins u5imm:$TH, memrr:$dst),
1621 "dcbf $dst, $TH", IIC_LdStDCBF, []>,
1622 PPC970_DGroup_Single;
1624 let hasSideEffects = 0, mayLoad = 1, mayStore = 1 in {
1625 def DCBT : DCB_Form_hint<278, (outs), (ins u5imm:$TH, memrr:$dst),
1626 "dcbt $dst, $TH", IIC_LdStDCBF, []>,
1627 PPC970_DGroup_Single;
1628 def DCBTST : DCB_Form_hint<246, (outs), (ins u5imm:$TH, memrr:$dst),
1629 "dcbtst $dst, $TH", IIC_LdStDCBF, []>,
1630 PPC970_DGroup_Single;
1631 } // hasSideEffects = 0
1633 def ICBLC : XForm_icbt<31, 230, (outs), (ins u4imm:$CT, memrr:$src),
1634 "icblc $CT, $src", IIC_LdStStore>, Requires<[HasICBT]>;
1635 def ICBLQ : XForm_icbt<31, 198, (outs), (ins u4imm:$CT, memrr:$src),
1636 "icblq. $CT, $src", IIC_LdStLoad>, Requires<[HasICBT]>;
1637 def ICBT : XForm_icbt<31, 22, (outs), (ins u4imm:$CT, memrr:$src),
1638 "icbt $CT, $src", IIC_LdStLoad>, Requires<[HasICBT]>;
1639 def ICBTLS : XForm_icbt<31, 486, (outs), (ins u4imm:$CT, memrr:$src),
1640 "icbtls $CT, $src", IIC_LdStLoad>, Requires<[HasICBT]>;
1642 def : Pat<(int_ppc_dcbt xoaddr:$dst),
1643 (DCBT 0, xoaddr:$dst)>;
1644 def : Pat<(int_ppc_dcbtst xoaddr:$dst),
1645 (DCBTST 0, xoaddr:$dst)>;
1646 def : Pat<(int_ppc_dcbf xoaddr:$dst),
1647 (DCBF 0, xoaddr:$dst)>;
1649 def : Pat<(prefetch xoaddr:$dst, (i32 0), imm, (i32 1)),
1650 (DCBT 0, xoaddr:$dst)>; // data prefetch for loads
1651 def : Pat<(prefetch xoaddr:$dst, (i32 1), imm, (i32 1)),
1652 (DCBTST 0, xoaddr:$dst)>; // data prefetch for stores
1653 def : Pat<(prefetch xoaddr:$dst, (i32 0), imm, (i32 0)),
1654 (ICBT 0, xoaddr:$dst)>, Requires<[HasICBT]>; // inst prefetch (for read)
1656 // Atomic operations
1657 // FIXME: some of these might be used with constant operands. This will result
1658 // in constant materialization instructions that may be redundant. We currently
1659 // clean this up in PPCMIPeephole with calls to
1660 // PPCInstrInfo::convertToImmediateForm() but we should probably not emit them
1661 // in the first place.
1662 let Defs = [CR0] in {
1663 def ATOMIC_LOAD_ADD_I8 : PPCCustomInserterPseudo<
1664 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I8",
1665 [(set i32:$dst, (atomic_load_add_8 xoaddr:$ptr, i32:$incr))]>;
1666 def ATOMIC_LOAD_SUB_I8 : PPCCustomInserterPseudo<
1667 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I8",
1668 [(set i32:$dst, (atomic_load_sub_8 xoaddr:$ptr, i32:$incr))]>;
1669 def ATOMIC_LOAD_AND_I8 : PPCCustomInserterPseudo<
1670 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I8",
1671 [(set i32:$dst, (atomic_load_and_8 xoaddr:$ptr, i32:$incr))]>;
1672 def ATOMIC_LOAD_OR_I8 : PPCCustomInserterPseudo<
1673 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I8",
1674 [(set i32:$dst, (atomic_load_or_8 xoaddr:$ptr, i32:$incr))]>;
1675 def ATOMIC_LOAD_XOR_I8 : PPCCustomInserterPseudo<
1676 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "ATOMIC_LOAD_XOR_I8",
1677 [(set i32:$dst, (atomic_load_xor_8 xoaddr:$ptr, i32:$incr))]>;
1678 def ATOMIC_LOAD_NAND_I8 : PPCCustomInserterPseudo<
1679 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I8",
1680 [(set i32:$dst, (atomic_load_nand_8 xoaddr:$ptr, i32:$incr))]>;
1681 def ATOMIC_LOAD_MIN_I8 : PPCCustomInserterPseudo<
1682 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MIN_I8",
1683 [(set i32:$dst, (atomic_load_min_8 xoaddr:$ptr, i32:$incr))]>;
1684 def ATOMIC_LOAD_MAX_I8 : PPCCustomInserterPseudo<
1685 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MAX_I8",
1686 [(set i32:$dst, (atomic_load_max_8 xoaddr:$ptr, i32:$incr))]>;
1687 def ATOMIC_LOAD_UMIN_I8 : PPCCustomInserterPseudo<
1688 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMIN_I8",
1689 [(set i32:$dst, (atomic_load_umin_8 xoaddr:$ptr, i32:$incr))]>;
1690 def ATOMIC_LOAD_UMAX_I8 : PPCCustomInserterPseudo<
1691 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMAX_I8",
1692 [(set i32:$dst, (atomic_load_umax_8 xoaddr:$ptr, i32:$incr))]>;
1693 def ATOMIC_LOAD_ADD_I16 : PPCCustomInserterPseudo<
1694 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I16",
1695 [(set i32:$dst, (atomic_load_add_16 xoaddr:$ptr, i32:$incr))]>;
1696 def ATOMIC_LOAD_SUB_I16 : PPCCustomInserterPseudo<
1697 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I16",
1698 [(set i32:$dst, (atomic_load_sub_16 xoaddr:$ptr, i32:$incr))]>;
1699 def ATOMIC_LOAD_AND_I16 : PPCCustomInserterPseudo<
1700 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I16",
1701 [(set i32:$dst, (atomic_load_and_16 xoaddr:$ptr, i32:$incr))]>;
1702 def ATOMIC_LOAD_OR_I16 : PPCCustomInserterPseudo<
1703 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I16",
1704 [(set i32:$dst, (atomic_load_or_16 xoaddr:$ptr, i32:$incr))]>;
1705 def ATOMIC_LOAD_XOR_I16 : PPCCustomInserterPseudo<
1706 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_XOR_I16",
1707 [(set i32:$dst, (atomic_load_xor_16 xoaddr:$ptr, i32:$incr))]>;
1708 def ATOMIC_LOAD_NAND_I16 : PPCCustomInserterPseudo<
1709 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I16",
1710 [(set i32:$dst, (atomic_load_nand_16 xoaddr:$ptr, i32:$incr))]>;
1711 def ATOMIC_LOAD_MIN_I16 : PPCCustomInserterPseudo<
1712 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MIN_I16",
1713 [(set i32:$dst, (atomic_load_min_16 xoaddr:$ptr, i32:$incr))]>;
1714 def ATOMIC_LOAD_MAX_I16 : PPCCustomInserterPseudo<
1715 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MAX_I16",
1716 [(set i32:$dst, (atomic_load_max_16 xoaddr:$ptr, i32:$incr))]>;
1717 def ATOMIC_LOAD_UMIN_I16 : PPCCustomInserterPseudo<
1718 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMIN_I16",
1719 [(set i32:$dst, (atomic_load_umin_16 xoaddr:$ptr, i32:$incr))]>;
1720 def ATOMIC_LOAD_UMAX_I16 : PPCCustomInserterPseudo<
1721 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMAX_I16",
1722 [(set i32:$dst, (atomic_load_umax_16 xoaddr:$ptr, i32:$incr))]>;
1723 def ATOMIC_LOAD_ADD_I32 : PPCCustomInserterPseudo<
1724 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I32",
1725 [(set i32:$dst, (atomic_load_add_32 xoaddr:$ptr, i32:$incr))]>;
1726 def ATOMIC_LOAD_SUB_I32 : PPCCustomInserterPseudo<
1727 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I32",
1728 [(set i32:$dst, (atomic_load_sub_32 xoaddr:$ptr, i32:$incr))]>;
1729 def ATOMIC_LOAD_AND_I32 : PPCCustomInserterPseudo<
1730 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I32",
1731 [(set i32:$dst, (atomic_load_and_32 xoaddr:$ptr, i32:$incr))]>;
1732 def ATOMIC_LOAD_OR_I32 : PPCCustomInserterPseudo<
1733 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I32",
1734 [(set i32:$dst, (atomic_load_or_32 xoaddr:$ptr, i32:$incr))]>;
1735 def ATOMIC_LOAD_XOR_I32 : PPCCustomInserterPseudo<
1736 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_XOR_I32",
1737 [(set i32:$dst, (atomic_load_xor_32 xoaddr:$ptr, i32:$incr))]>;
1738 def ATOMIC_LOAD_NAND_I32 : PPCCustomInserterPseudo<
1739 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I32",
1740 [(set i32:$dst, (atomic_load_nand_32 xoaddr:$ptr, i32:$incr))]>;
1741 def ATOMIC_LOAD_MIN_I32 : PPCCustomInserterPseudo<
1742 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MIN_I32",
1743 [(set i32:$dst, (atomic_load_min_32 xoaddr:$ptr, i32:$incr))]>;
1744 def ATOMIC_LOAD_MAX_I32 : PPCCustomInserterPseudo<
1745 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MAX_I32",
1746 [(set i32:$dst, (atomic_load_max_32 xoaddr:$ptr, i32:$incr))]>;
1747 def ATOMIC_LOAD_UMIN_I32 : PPCCustomInserterPseudo<
1748 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMIN_I32",
1749 [(set i32:$dst, (atomic_load_umin_32 xoaddr:$ptr, i32:$incr))]>;
1750 def ATOMIC_LOAD_UMAX_I32 : PPCCustomInserterPseudo<
1751 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMAX_I32",
1752 [(set i32:$dst, (atomic_load_umax_32 xoaddr:$ptr, i32:$incr))]>;
1754 def ATOMIC_CMP_SWAP_I8 : PPCCustomInserterPseudo<
1755 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I8",
1756 [(set i32:$dst, (atomic_cmp_swap_8 xoaddr:$ptr, i32:$old, i32:$new))]>;
1757 def ATOMIC_CMP_SWAP_I16 : PPCCustomInserterPseudo<
1758 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I16 $dst $ptr $old $new",
1759 [(set i32:$dst, (atomic_cmp_swap_16 xoaddr:$ptr, i32:$old, i32:$new))]>;
1760 def ATOMIC_CMP_SWAP_I32 : PPCCustomInserterPseudo<
1761 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I32 $dst $ptr $old $new",
1762 [(set i32:$dst, (atomic_cmp_swap_32 xoaddr:$ptr, i32:$old, i32:$new))]>;
1764 def ATOMIC_SWAP_I8 : PPCCustomInserterPseudo<
1765 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_i8",
1766 [(set i32:$dst, (atomic_swap_8 xoaddr:$ptr, i32:$new))]>;
1767 def ATOMIC_SWAP_I16 : PPCCustomInserterPseudo<
1768 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_I16",
1769 [(set i32:$dst, (atomic_swap_16 xoaddr:$ptr, i32:$new))]>;
1770 def ATOMIC_SWAP_I32 : PPCCustomInserterPseudo<
1771 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_I32",
1772 [(set i32:$dst, (atomic_swap_32 xoaddr:$ptr, i32:$new))]>;
1775 def : Pat<(PPCatomicCmpSwap_8 xoaddr:$ptr, i32:$old, i32:$new),
1776 (ATOMIC_CMP_SWAP_I8 xoaddr:$ptr, i32:$old, i32:$new)>;
1777 def : Pat<(PPCatomicCmpSwap_16 xoaddr:$ptr, i32:$old, i32:$new),
1778 (ATOMIC_CMP_SWAP_I16 xoaddr:$ptr, i32:$old, i32:$new)>;
1780 // Instructions to support atomic operations
1781 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in {
1782 def LBARX : XForm_1_memOp<31, 52, (outs gprc:$rD), (ins memrr:$src),
1783 "lbarx $rD, $src", IIC_LdStLWARX, []>,
1784 Requires<[HasPartwordAtomics]>;
1786 def LHARX : XForm_1_memOp<31, 116, (outs gprc:$rD), (ins memrr:$src),
1787 "lharx $rD, $src", IIC_LdStLWARX, []>,
1788 Requires<[HasPartwordAtomics]>;
1790 def LWARX : XForm_1_memOp<31, 20, (outs gprc:$rD), (ins memrr:$src),
1791 "lwarx $rD, $src", IIC_LdStLWARX, []>;
1793 // Instructions to support lock versions of atomics
1794 // (EH=1 - see Power ISA 2.07 Book II 4.4.2)
1795 def LBARXL : XForm_1_memOp<31, 52, (outs gprc:$rD), (ins memrr:$src),
1796 "lbarx $rD, $src, 1", IIC_LdStLWARX, []>, isDOT,
1797 Requires<[HasPartwordAtomics]>;
1799 def LHARXL : XForm_1_memOp<31, 116, (outs gprc:$rD), (ins memrr:$src),
1800 "lharx $rD, $src, 1", IIC_LdStLWARX, []>, isDOT,
1801 Requires<[HasPartwordAtomics]>;
1803 def LWARXL : XForm_1_memOp<31, 20, (outs gprc:$rD), (ins memrr:$src),
1804 "lwarx $rD, $src, 1", IIC_LdStLWARX, []>, isDOT;
1806 // The atomic instructions use the destination register as well as the next one
1807 // or two registers in order (modulo 31).
1808 let hasExtraSrcRegAllocReq = 1 in
1809 def LWAT : X_RD5_RS5_IM5<31, 582, (outs gprc:$rD), (ins gprc:$rA, u5imm:$FC),
1810 "lwat $rD, $rA, $FC", IIC_LdStLoad>,
1811 Requires<[IsISA3_0]>;
1814 let Defs = [CR0], mayStore = 1, mayLoad = 0, hasSideEffects = 0 in {
1815 def STBCX : XForm_1_memOp<31, 694, (outs), (ins gprc:$rS, memrr:$dst),
1816 "stbcx. $rS, $dst", IIC_LdStSTWCX, []>,
1817 isDOT, Requires<[HasPartwordAtomics]>;
1819 def STHCX : XForm_1_memOp<31, 726, (outs), (ins gprc:$rS, memrr:$dst),
1820 "sthcx. $rS, $dst", IIC_LdStSTWCX, []>,
1821 isDOT, Requires<[HasPartwordAtomics]>;
1823 def STWCX : XForm_1_memOp<31, 150, (outs), (ins gprc:$rS, memrr:$dst),
1824 "stwcx. $rS, $dst", IIC_LdStSTWCX, []>, isDOT;
1827 let mayStore = 1, mayLoad = 0, hasSideEffects = 0 in
1828 def STWAT : X_RD5_RS5_IM5<31, 710, (outs), (ins gprc:$rS, gprc:$rA, u5imm:$FC),
1829 "stwat $rS, $rA, $FC", IIC_LdStStore>,
1830 Requires<[IsISA3_0]>;
1832 let isTerminator = 1, isBarrier = 1, hasCtrlDep = 1 in
1833 def TRAP : XForm_24<31, 4, (outs), (ins), "trap", IIC_LdStLoad, [(trap)]>;
1835 def TWI : DForm_base<3, (outs), (ins u5imm:$to, gprc:$rA, s16imm:$imm),
1836 "twi $to, $rA, $imm", IIC_IntTrapW, []>;
1837 def TW : XForm_1<31, 4, (outs), (ins u5imm:$to, gprc:$rA, gprc:$rB),
1838 "tw $to, $rA, $rB", IIC_IntTrapW, []>;
1839 def TDI : DForm_base<2, (outs), (ins u5imm:$to, g8rc:$rA, s16imm:$imm),
1840 "tdi $to, $rA, $imm", IIC_IntTrapD, []>;
1841 def TD : XForm_1<31, 68, (outs), (ins u5imm:$to, g8rc:$rA, g8rc:$rB),
1842 "td $to, $rA, $rB", IIC_IntTrapD, []>;
1844 //===----------------------------------------------------------------------===//
1845 // PPC32 Load Instructions.
1848 // Unindexed (r+i) Loads.
1849 let PPC970_Unit = 2 in {
1850 def LBZ : DForm_1<34, (outs gprc:$rD), (ins memri:$src),
1851 "lbz $rD, $src", IIC_LdStLoad,
1852 [(set i32:$rD, (zextloadi8 iaddr:$src))]>;
1853 def LHA : DForm_1<42, (outs gprc:$rD), (ins memri:$src),
1854 "lha $rD, $src", IIC_LdStLHA,
1855 [(set i32:$rD, (sextloadi16 iaddr:$src))]>,
1856 PPC970_DGroup_Cracked;
1857 def LHZ : DForm_1<40, (outs gprc:$rD), (ins memri:$src),
1858 "lhz $rD, $src", IIC_LdStLoad,
1859 [(set i32:$rD, (zextloadi16 iaddr:$src))]>;
1860 def LWZ : DForm_1<32, (outs gprc:$rD), (ins memri:$src),
1861 "lwz $rD, $src", IIC_LdStLoad,
1862 [(set i32:$rD, (load iaddr:$src))]>;
1864 let Predicates = [HasFPU] in {
1865 def LFS : DForm_1<48, (outs f4rc:$rD), (ins memri:$src),
1866 "lfs $rD, $src", IIC_LdStLFD,
1867 [(set f32:$rD, (load iaddr:$src))]>;
1868 def LFD : DForm_1<50, (outs f8rc:$rD), (ins memri:$src),
1869 "lfd $rD, $src", IIC_LdStLFD,
1870 [(set f64:$rD, (load iaddr:$src))]>;
1874 // Unindexed (r+i) Loads with Update (preinc).
1875 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in {
1876 def LBZU : DForm_1<35, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1877 "lbzu $rD, $addr", IIC_LdStLoadUpd,
1878 []>, RegConstraint<"$addr.reg = $ea_result">,
1879 NoEncode<"$ea_result">;
1881 def LHAU : DForm_1<43, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1882 "lhau $rD, $addr", IIC_LdStLHAU,
1883 []>, RegConstraint<"$addr.reg = $ea_result">,
1884 NoEncode<"$ea_result">;
1886 def LHZU : DForm_1<41, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1887 "lhzu $rD, $addr", IIC_LdStLoadUpd,
1888 []>, RegConstraint<"$addr.reg = $ea_result">,
1889 NoEncode<"$ea_result">;
1891 def LWZU : DForm_1<33, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1892 "lwzu $rD, $addr", IIC_LdStLoadUpd,
1893 []>, RegConstraint<"$addr.reg = $ea_result">,
1894 NoEncode<"$ea_result">;
1896 let Predicates = [HasFPU] in {
1897 def LFSU : DForm_1<49, (outs f4rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1898 "lfsu $rD, $addr", IIC_LdStLFDU,
1899 []>, RegConstraint<"$addr.reg = $ea_result">,
1900 NoEncode<"$ea_result">;
1902 def LFDU : DForm_1<51, (outs f8rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1903 "lfdu $rD, $addr", IIC_LdStLFDU,
1904 []>, RegConstraint<"$addr.reg = $ea_result">,
1905 NoEncode<"$ea_result">;
1909 // Indexed (r+r) Loads with Update (preinc).
1910 def LBZUX : XForm_1_memOp<31, 119, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1912 "lbzux $rD, $addr", IIC_LdStLoadUpdX,
1913 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1914 NoEncode<"$ea_result">;
1916 def LHAUX : XForm_1_memOp<31, 375, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1918 "lhaux $rD, $addr", IIC_LdStLHAUX,
1919 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1920 NoEncode<"$ea_result">;
1922 def LHZUX : XForm_1_memOp<31, 311, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1924 "lhzux $rD, $addr", IIC_LdStLoadUpdX,
1925 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1926 NoEncode<"$ea_result">;
1928 def LWZUX : XForm_1_memOp<31, 55, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1930 "lwzux $rD, $addr", IIC_LdStLoadUpdX,
1931 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1932 NoEncode<"$ea_result">;
1934 let Predicates = [HasFPU] in {
1935 def LFSUX : XForm_1_memOp<31, 567, (outs f4rc:$rD, ptr_rc_nor0:$ea_result),
1937 "lfsux $rD, $addr", IIC_LdStLFDUX,
1938 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1939 NoEncode<"$ea_result">;
1941 def LFDUX : XForm_1_memOp<31, 631, (outs f8rc:$rD, ptr_rc_nor0:$ea_result),
1943 "lfdux $rD, $addr", IIC_LdStLFDUX,
1944 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1945 NoEncode<"$ea_result">;
1950 // Indexed (r+r) Loads.
1952 let PPC970_Unit = 2, mayLoad = 1, mayStore = 0 in {
1953 def LBZX : XForm_1_memOp<31, 87, (outs gprc:$rD), (ins memrr:$src),
1954 "lbzx $rD, $src", IIC_LdStLoad,
1955 [(set i32:$rD, (zextloadi8 xaddr:$src))]>;
1956 def LHAX : XForm_1_memOp<31, 343, (outs gprc:$rD), (ins memrr:$src),
1957 "lhax $rD, $src", IIC_LdStLHA,
1958 [(set i32:$rD, (sextloadi16 xaddr:$src))]>,
1959 PPC970_DGroup_Cracked;
1960 def LHZX : XForm_1_memOp<31, 279, (outs gprc:$rD), (ins memrr:$src),
1961 "lhzx $rD, $src", IIC_LdStLoad,
1962 [(set i32:$rD, (zextloadi16 xaddr:$src))]>;
1963 def LWZX : XForm_1_memOp<31, 23, (outs gprc:$rD), (ins memrr:$src),
1964 "lwzx $rD, $src", IIC_LdStLoad,
1965 [(set i32:$rD, (load xaddr:$src))]>;
1966 def LHBRX : XForm_1_memOp<31, 790, (outs gprc:$rD), (ins memrr:$src),
1967 "lhbrx $rD, $src", IIC_LdStLoad,
1968 [(set i32:$rD, (PPClbrx xoaddr:$src, i16))]>;
1969 def LWBRX : XForm_1_memOp<31, 534, (outs gprc:$rD), (ins memrr:$src),
1970 "lwbrx $rD, $src", IIC_LdStLoad,
1971 [(set i32:$rD, (PPClbrx xoaddr:$src, i32))]>;
1973 let Predicates = [HasFPU] in {
1974 def LFSX : XForm_25_memOp<31, 535, (outs f4rc:$frD), (ins memrr:$src),
1975 "lfsx $frD, $src", IIC_LdStLFD,
1976 [(set f32:$frD, (load xaddr:$src))]>;
1977 def LFDX : XForm_25_memOp<31, 599, (outs f8rc:$frD), (ins memrr:$src),
1978 "lfdx $frD, $src", IIC_LdStLFD,
1979 [(set f64:$frD, (load xaddr:$src))]>;
1981 def LFIWAX : XForm_25_memOp<31, 855, (outs f8rc:$frD), (ins memrr:$src),
1982 "lfiwax $frD, $src", IIC_LdStLFD,
1983 [(set f64:$frD, (PPClfiwax xoaddr:$src))]>;
1984 def LFIWZX : XForm_25_memOp<31, 887, (outs f8rc:$frD), (ins memrr:$src),
1985 "lfiwzx $frD, $src", IIC_LdStLFD,
1986 [(set f64:$frD, (PPClfiwzx xoaddr:$src))]>;
1991 def LMW : DForm_1<46, (outs gprc:$rD), (ins memri:$src),
1992 "lmw $rD, $src", IIC_LdStLMW, []>;
1994 //===----------------------------------------------------------------------===//
1995 // PPC32 Store Instructions.
1998 // Unindexed (r+i) Stores.
1999 let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in {
2000 def STB : DForm_1<38, (outs), (ins gprc:$rS, memri:$dst),
2001 "stb $rS, $dst", IIC_LdStStore,
2002 [(truncstorei8 i32:$rS, iaddr:$dst)]>;
2003 def STH : DForm_1<44, (outs), (ins gprc:$rS, memri:$dst),
2004 "sth $rS, $dst", IIC_LdStStore,
2005 [(truncstorei16 i32:$rS, iaddr:$dst)]>;
2006 def STW : DForm_1<36, (outs), (ins gprc:$rS, memri:$dst),
2007 "stw $rS, $dst", IIC_LdStStore,
2008 [(store i32:$rS, iaddr:$dst)]>;
2009 let Predicates = [HasFPU] in {
2010 def STFS : DForm_1<52, (outs), (ins f4rc:$rS, memri:$dst),
2011 "stfs $rS, $dst", IIC_LdStSTFD,
2012 [(store f32:$rS, iaddr:$dst)]>;
2013 def STFD : DForm_1<54, (outs), (ins f8rc:$rS, memri:$dst),
2014 "stfd $rS, $dst", IIC_LdStSTFD,
2015 [(store f64:$rS, iaddr:$dst)]>;
2019 // Unindexed (r+i) Stores with Update (preinc).
2020 let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in {
2021 def STBU : DForm_1<39, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst),
2022 "stbu $rS, $dst", IIC_LdStSTU, []>,
2023 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
2024 def STHU : DForm_1<45, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst),
2025 "sthu $rS, $dst", IIC_LdStSTU, []>,
2026 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
2027 def STWU : DForm_1<37, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst),
2028 "stwu $rS, $dst", IIC_LdStSTU, []>,
2029 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
2030 let Predicates = [HasFPU] in {
2031 def STFSU : DForm_1<53, (outs ptr_rc_nor0:$ea_res), (ins f4rc:$rS, memri:$dst),
2032 "stfsu $rS, $dst", IIC_LdStSTFDU, []>,
2033 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
2034 def STFDU : DForm_1<55, (outs ptr_rc_nor0:$ea_res), (ins f8rc:$rS, memri:$dst),
2035 "stfdu $rS, $dst", IIC_LdStSTFDU, []>,
2036 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
2040 // Patterns to match the pre-inc stores. We can't put the patterns on
2041 // the instruction definitions directly as ISel wants the address base
2042 // and offset to be separate operands, not a single complex operand.
2043 def : Pat<(pre_truncsti8 i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
2044 (STBU $rS, iaddroff:$ptroff, $ptrreg)>;
2045 def : Pat<(pre_truncsti16 i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
2046 (STHU $rS, iaddroff:$ptroff, $ptrreg)>;
2047 def : Pat<(pre_store i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
2048 (STWU $rS, iaddroff:$ptroff, $ptrreg)>;
2049 def : Pat<(pre_store f32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
2050 (STFSU $rS, iaddroff:$ptroff, $ptrreg)>;
2051 def : Pat<(pre_store f64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
2052 (STFDU $rS, iaddroff:$ptroff, $ptrreg)>;
2054 // Indexed (r+r) Stores.
2055 let PPC970_Unit = 2 in {
2056 def STBX : XForm_8_memOp<31, 215, (outs), (ins gprc:$rS, memrr:$dst),
2057 "stbx $rS, $dst", IIC_LdStStore,
2058 [(truncstorei8 i32:$rS, xaddr:$dst)]>,
2059 PPC970_DGroup_Cracked;
2060 def STHX : XForm_8_memOp<31, 407, (outs), (ins gprc:$rS, memrr:$dst),
2061 "sthx $rS, $dst", IIC_LdStStore,
2062 [(truncstorei16 i32:$rS, xaddr:$dst)]>,
2063 PPC970_DGroup_Cracked;
2064 def STWX : XForm_8_memOp<31, 151, (outs), (ins gprc:$rS, memrr:$dst),
2065 "stwx $rS, $dst", IIC_LdStStore,
2066 [(store i32:$rS, xaddr:$dst)]>,
2067 PPC970_DGroup_Cracked;
2069 def STHBRX: XForm_8_memOp<31, 918, (outs), (ins gprc:$rS, memrr:$dst),
2070 "sthbrx $rS, $dst", IIC_LdStStore,
2071 [(PPCstbrx i32:$rS, xoaddr:$dst, i16)]>,
2072 PPC970_DGroup_Cracked;
2073 def STWBRX: XForm_8_memOp<31, 662, (outs), (ins gprc:$rS, memrr:$dst),
2074 "stwbrx $rS, $dst", IIC_LdStStore,
2075 [(PPCstbrx i32:$rS, xoaddr:$dst, i32)]>,
2076 PPC970_DGroup_Cracked;
2078 let Predicates = [HasFPU] in {
2079 def STFIWX: XForm_28_memOp<31, 983, (outs), (ins f8rc:$frS, memrr:$dst),
2080 "stfiwx $frS, $dst", IIC_LdStSTFD,
2081 [(PPCstfiwx f64:$frS, xoaddr:$dst)]>;
2083 def STFSX : XForm_28_memOp<31, 663, (outs), (ins f4rc:$frS, memrr:$dst),
2084 "stfsx $frS, $dst", IIC_LdStSTFD,
2085 [(store f32:$frS, xaddr:$dst)]>;
2086 def STFDX : XForm_28_memOp<31, 727, (outs), (ins f8rc:$frS, memrr:$dst),
2087 "stfdx $frS, $dst", IIC_LdStSTFD,
2088 [(store f64:$frS, xaddr:$dst)]>;
2092 // Indexed (r+r) Stores with Update (preinc).
2093 let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in {
2094 def STBUX : XForm_8_memOp<31, 247, (outs ptr_rc_nor0:$ea_res),
2095 (ins gprc:$rS, memrr:$dst),
2096 "stbux $rS, $dst", IIC_LdStSTUX, []>,
2097 RegConstraint<"$dst.ptrreg = $ea_res">,
2098 NoEncode<"$ea_res">,
2099 PPC970_DGroup_Cracked;
2100 def STHUX : XForm_8_memOp<31, 439, (outs ptr_rc_nor0:$ea_res),
2101 (ins gprc:$rS, memrr:$dst),
2102 "sthux $rS, $dst", IIC_LdStSTUX, []>,
2103 RegConstraint<"$dst.ptrreg = $ea_res">,
2104 NoEncode<"$ea_res">,
2105 PPC970_DGroup_Cracked;
2106 def STWUX : XForm_8_memOp<31, 183, (outs ptr_rc_nor0:$ea_res),
2107 (ins gprc:$rS, memrr:$dst),
2108 "stwux $rS, $dst", IIC_LdStSTUX, []>,
2109 RegConstraint<"$dst.ptrreg = $ea_res">,
2110 NoEncode<"$ea_res">,
2111 PPC970_DGroup_Cracked;
2112 let Predicates = [HasFPU] in {
2113 def STFSUX: XForm_8_memOp<31, 695, (outs ptr_rc_nor0:$ea_res),
2114 (ins f4rc:$rS, memrr:$dst),
2115 "stfsux $rS, $dst", IIC_LdStSTFDU, []>,
2116 RegConstraint<"$dst.ptrreg = $ea_res">,
2117 NoEncode<"$ea_res">,
2118 PPC970_DGroup_Cracked;
2119 def STFDUX: XForm_8_memOp<31, 759, (outs ptr_rc_nor0:$ea_res),
2120 (ins f8rc:$rS, memrr:$dst),
2121 "stfdux $rS, $dst", IIC_LdStSTFDU, []>,
2122 RegConstraint<"$dst.ptrreg = $ea_res">,
2123 NoEncode<"$ea_res">,
2124 PPC970_DGroup_Cracked;
2128 // Patterns to match the pre-inc stores. We can't put the patterns on
2129 // the instruction definitions directly as ISel wants the address base
2130 // and offset to be separate operands, not a single complex operand.
2131 def : Pat<(pre_truncsti8 i32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2132 (STBUX $rS, $ptrreg, $ptroff)>;
2133 def : Pat<(pre_truncsti16 i32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2134 (STHUX $rS, $ptrreg, $ptroff)>;
2135 def : Pat<(pre_store i32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2136 (STWUX $rS, $ptrreg, $ptroff)>;
2137 let Predicates = [HasFPU] in {
2138 def : Pat<(pre_store f32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2139 (STFSUX $rS, $ptrreg, $ptroff)>;
2140 def : Pat<(pre_store f64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2141 (STFDUX $rS, $ptrreg, $ptroff)>;
2145 def STMW : DForm_1<47, (outs), (ins gprc:$rS, memri:$dst),
2146 "stmw $rS, $dst", IIC_LdStLMW, []>;
2148 def SYNC : XForm_24_sync<31, 598, (outs), (ins i32imm:$L),
2149 "sync $L", IIC_LdStSync, []>;
2151 let isCodeGenOnly = 1 in {
2152 def MSYNC : XForm_24_sync<31, 598, (outs), (ins),
2153 "msync", IIC_LdStSync, []> {
2158 def : Pat<(int_ppc_sync), (SYNC 0)>, Requires<[HasSYNC]>;
2159 def : Pat<(int_ppc_lwsync), (SYNC 1)>, Requires<[HasSYNC]>;
2160 def : Pat<(int_ppc_sync), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
2161 def : Pat<(int_ppc_lwsync), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
2163 //===----------------------------------------------------------------------===//
2164 // PPC32 Arithmetic Instructions.
2167 let PPC970_Unit = 1 in { // FXU Operations.
2168 def ADDI : DForm_2<14, (outs gprc:$rD), (ins gprc_nor0:$rA, s16imm:$imm),
2169 "addi $rD, $rA, $imm", IIC_IntSimple,
2170 [(set i32:$rD, (add i32:$rA, imm32SExt16:$imm))]>;
2171 let BaseName = "addic" in {
2172 let Defs = [CARRY] in
2173 def ADDIC : DForm_2<12, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
2174 "addic $rD, $rA, $imm", IIC_IntGeneral,
2175 [(set i32:$rD, (addc i32:$rA, imm32SExt16:$imm))]>,
2176 RecFormRel, PPC970_DGroup_Cracked;
2177 let Defs = [CARRY, CR0] in
2178 def ADDICo : DForm_2<13, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
2179 "addic. $rD, $rA, $imm", IIC_IntGeneral,
2180 []>, isDOT, RecFormRel;
2182 def ADDIS : DForm_2<15, (outs gprc:$rD), (ins gprc_nor0:$rA, s17imm:$imm),
2183 "addis $rD, $rA, $imm", IIC_IntSimple,
2184 [(set i32:$rD, (add i32:$rA, imm16ShiftedSExt:$imm))]>;
2185 let isCodeGenOnly = 1 in
2186 def LA : DForm_2<14, (outs gprc:$rD), (ins gprc_nor0:$rA, s16imm:$sym),
2187 "la $rD, $sym($rA)", IIC_IntGeneral,
2188 [(set i32:$rD, (add i32:$rA,
2189 (PPClo tglobaladdr:$sym, 0)))]>;
2190 def MULLI : DForm_2< 7, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
2191 "mulli $rD, $rA, $imm", IIC_IntMulLI,
2192 [(set i32:$rD, (mul i32:$rA, imm32SExt16:$imm))]>;
2193 let Defs = [CARRY] in
2194 def SUBFIC : DForm_2< 8, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
2195 "subfic $rD, $rA, $imm", IIC_IntGeneral,
2196 [(set i32:$rD, (subc imm32SExt16:$imm, i32:$rA))]>;
2198 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in {
2199 def LI : DForm_2_r0<14, (outs gprc:$rD), (ins s16imm:$imm),
2200 "li $rD, $imm", IIC_IntSimple,
2201 [(set i32:$rD, imm32SExt16:$imm)]>;
2202 def LIS : DForm_2_r0<15, (outs gprc:$rD), (ins s17imm:$imm),
2203 "lis $rD, $imm", IIC_IntSimple,
2204 [(set i32:$rD, imm16ShiftedSExt:$imm)]>;
2208 let PPC970_Unit = 1 in { // FXU Operations.
2209 let Defs = [CR0] in {
2210 def ANDIo : DForm_4<28, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2211 "andi. $dst, $src1, $src2", IIC_IntGeneral,
2212 [(set i32:$dst, (and i32:$src1, immZExt16:$src2))]>,
2214 def ANDISo : DForm_4<29, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2215 "andis. $dst, $src1, $src2", IIC_IntGeneral,
2216 [(set i32:$dst, (and i32:$src1, imm16ShiftedZExt:$src2))]>,
2219 def ORI : DForm_4<24, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2220 "ori $dst, $src1, $src2", IIC_IntSimple,
2221 [(set i32:$dst, (or i32:$src1, immZExt16:$src2))]>;
2222 def ORIS : DForm_4<25, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2223 "oris $dst, $src1, $src2", IIC_IntSimple,
2224 [(set i32:$dst, (or i32:$src1, imm16ShiftedZExt:$src2))]>;
2225 def XORI : DForm_4<26, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2226 "xori $dst, $src1, $src2", IIC_IntSimple,
2227 [(set i32:$dst, (xor i32:$src1, immZExt16:$src2))]>;
2228 def XORIS : DForm_4<27, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2229 "xoris $dst, $src1, $src2", IIC_IntSimple,
2230 [(set i32:$dst, (xor i32:$src1, imm16ShiftedZExt:$src2))]>;
2232 def NOP : DForm_4_zero<24, (outs), (ins), "nop", IIC_IntSimple,
2234 let isCodeGenOnly = 1 in {
2235 // The POWER6 and POWER7 have special group-terminating nops.
2236 def NOP_GT_PWR6 : DForm_4_fixedreg_zero<24, 1, (outs), (ins),
2237 "ori 1, 1, 0", IIC_IntSimple, []>;
2238 def NOP_GT_PWR7 : DForm_4_fixedreg_zero<24, 2, (outs), (ins),
2239 "ori 2, 2, 0", IIC_IntSimple, []>;
2242 let isCompare = 1, hasSideEffects = 0 in {
2243 def CMPWI : DForm_5_ext<11, (outs crrc:$crD), (ins gprc:$rA, s16imm:$imm),
2244 "cmpwi $crD, $rA, $imm", IIC_IntCompare>;
2245 def CMPLWI : DForm_6_ext<10, (outs crrc:$dst), (ins gprc:$src1, u16imm:$src2),
2246 "cmplwi $dst, $src1, $src2", IIC_IntCompare>;
2247 def CMPRB : X_BF3_L1_RS5_RS5<31, 192, (outs crbitrc:$BF),
2248 (ins u1imm:$L, g8rc:$rA, g8rc:$rB),
2249 "cmprb $BF, $L, $rA, $rB", IIC_IntCompare, []>,
2250 Requires<[IsISA3_0]>;
2254 let PPC970_Unit = 1, hasSideEffects = 0 in { // FXU Operations.
2255 let isCommutable = 1 in {
2256 defm NAND : XForm_6r<31, 476, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2257 "nand", "$rA, $rS, $rB", IIC_IntSimple,
2258 [(set i32:$rA, (not (and i32:$rS, i32:$rB)))]>;
2259 defm AND : XForm_6r<31, 28, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2260 "and", "$rA, $rS, $rB", IIC_IntSimple,
2261 [(set i32:$rA, (and i32:$rS, i32:$rB))]>;
2263 defm ANDC : XForm_6r<31, 60, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2264 "andc", "$rA, $rS, $rB", IIC_IntSimple,
2265 [(set i32:$rA, (and i32:$rS, (not i32:$rB)))]>;
2266 let isCommutable = 1 in {
2267 defm OR : XForm_6r<31, 444, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2268 "or", "$rA, $rS, $rB", IIC_IntSimple,
2269 [(set i32:$rA, (or i32:$rS, i32:$rB))]>;
2270 defm NOR : XForm_6r<31, 124, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2271 "nor", "$rA, $rS, $rB", IIC_IntSimple,
2272 [(set i32:$rA, (not (or i32:$rS, i32:$rB)))]>;
2274 defm ORC : XForm_6r<31, 412, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2275 "orc", "$rA, $rS, $rB", IIC_IntSimple,
2276 [(set i32:$rA, (or i32:$rS, (not i32:$rB)))]>;
2277 let isCommutable = 1 in {
2278 defm EQV : XForm_6r<31, 284, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2279 "eqv", "$rA, $rS, $rB", IIC_IntSimple,
2280 [(set i32:$rA, (not (xor i32:$rS, i32:$rB)))]>;
2281 defm XOR : XForm_6r<31, 316, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2282 "xor", "$rA, $rS, $rB", IIC_IntSimple,
2283 [(set i32:$rA, (xor i32:$rS, i32:$rB))]>;
2285 defm SLW : XForm_6r<31, 24, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2286 "slw", "$rA, $rS, $rB", IIC_IntGeneral,
2287 [(set i32:$rA, (PPCshl i32:$rS, i32:$rB))]>;
2288 defm SRW : XForm_6r<31, 536, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2289 "srw", "$rA, $rS, $rB", IIC_IntGeneral,
2290 [(set i32:$rA, (PPCsrl i32:$rS, i32:$rB))]>;
2291 defm SRAW : XForm_6rc<31, 792, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2292 "sraw", "$rA, $rS, $rB", IIC_IntShift,
2293 [(set i32:$rA, (PPCsra i32:$rS, i32:$rB))]>;
2296 let PPC970_Unit = 1 in { // FXU Operations.
2297 let hasSideEffects = 0 in {
2298 defm SRAWI : XForm_10rc<31, 824, (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH),
2299 "srawi", "$rA, $rS, $SH", IIC_IntShift,
2300 [(set i32:$rA, (sra i32:$rS, (i32 imm:$SH)))]>;
2301 defm CNTLZW : XForm_11r<31, 26, (outs gprc:$rA), (ins gprc:$rS),
2302 "cntlzw", "$rA, $rS", IIC_IntGeneral,
2303 [(set i32:$rA, (ctlz i32:$rS))]>;
2304 defm CNTTZW : XForm_11r<31, 538, (outs gprc:$rA), (ins gprc:$rS),
2305 "cnttzw", "$rA, $rS", IIC_IntGeneral,
2306 [(set i32:$rA, (cttz i32:$rS))]>, Requires<[IsISA3_0]>;
2307 defm EXTSB : XForm_11r<31, 954, (outs gprc:$rA), (ins gprc:$rS),
2308 "extsb", "$rA, $rS", IIC_IntSimple,
2309 [(set i32:$rA, (sext_inreg i32:$rS, i8))]>;
2310 defm EXTSH : XForm_11r<31, 922, (outs gprc:$rA), (ins gprc:$rS),
2311 "extsh", "$rA, $rS", IIC_IntSimple,
2312 [(set i32:$rA, (sext_inreg i32:$rS, i16))]>;
2314 let isCommutable = 1 in
2315 def CMPB : XForm_6<31, 508, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2316 "cmpb $rA, $rS, $rB", IIC_IntGeneral,
2317 [(set i32:$rA, (PPCcmpb i32:$rS, i32:$rB))]>;
2319 let isCompare = 1, hasSideEffects = 0 in {
2320 def CMPW : XForm_16_ext<31, 0, (outs crrc:$crD), (ins gprc:$rA, gprc:$rB),
2321 "cmpw $crD, $rA, $rB", IIC_IntCompare>;
2322 def CMPLW : XForm_16_ext<31, 32, (outs crrc:$crD), (ins gprc:$rA, gprc:$rB),
2323 "cmplw $crD, $rA, $rB", IIC_IntCompare>;
2326 let PPC970_Unit = 3, Predicates = [HasFPU] in { // FPU Operations.
2327 //def FCMPO : XForm_17<63, 32, (outs CRRC:$crD), (ins FPRC:$fA, FPRC:$fB),
2328 // "fcmpo $crD, $fA, $fB", IIC_FPCompare>;
2329 let isCompare = 1, hasSideEffects = 0 in {
2330 def FCMPUS : XForm_17<63, 0, (outs crrc:$crD), (ins f4rc:$fA, f4rc:$fB),
2331 "fcmpu $crD, $fA, $fB", IIC_FPCompare>;
2332 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2333 def FCMPUD : XForm_17<63, 0, (outs crrc:$crD), (ins f8rc:$fA, f8rc:$fB),
2334 "fcmpu $crD, $fA, $fB", IIC_FPCompare>;
2337 def FTDIV: XForm_17<63, 128, (outs crrc:$crD), (ins f8rc:$fA, f8rc:$fB),
2338 "ftdiv $crD, $fA, $fB", IIC_FPCompare>;
2339 def FTSQRT: XForm_17a<63, 160, (outs crrc:$crD), (ins f8rc:$fB),
2340 "ftsqrt $crD, $fB", IIC_FPCompare>;
2342 let Uses = [RM] in {
2343 let hasSideEffects = 0 in {
2344 defm FCTIW : XForm_26r<63, 14, (outs f8rc:$frD), (ins f8rc:$frB),
2345 "fctiw", "$frD, $frB", IIC_FPGeneral,
2347 defm FCTIWU : XForm_26r<63, 142, (outs f8rc:$frD), (ins f8rc:$frB),
2348 "fctiwu", "$frD, $frB", IIC_FPGeneral,
2350 defm FCTIWZ : XForm_26r<63, 15, (outs f8rc:$frD), (ins f8rc:$frB),
2351 "fctiwz", "$frD, $frB", IIC_FPGeneral,
2352 [(set f64:$frD, (PPCfctiwz f64:$frB))]>;
2354 defm FRSP : XForm_26r<63, 12, (outs f4rc:$frD), (ins f8rc:$frB),
2355 "frsp", "$frD, $frB", IIC_FPGeneral,
2356 [(set f32:$frD, (fpround f64:$frB))]>;
2358 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2359 defm FRIND : XForm_26r<63, 392, (outs f8rc:$frD), (ins f8rc:$frB),
2360 "frin", "$frD, $frB", IIC_FPGeneral,
2361 [(set f64:$frD, (fround f64:$frB))]>;
2362 defm FRINS : XForm_26r<63, 392, (outs f4rc:$frD), (ins f4rc:$frB),
2363 "frin", "$frD, $frB", IIC_FPGeneral,
2364 [(set f32:$frD, (fround f32:$frB))]>;
2367 let hasSideEffects = 0 in {
2368 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2369 defm FRIPD : XForm_26r<63, 456, (outs f8rc:$frD), (ins f8rc:$frB),
2370 "frip", "$frD, $frB", IIC_FPGeneral,
2371 [(set f64:$frD, (fceil f64:$frB))]>;
2372 defm FRIPS : XForm_26r<63, 456, (outs f4rc:$frD), (ins f4rc:$frB),
2373 "frip", "$frD, $frB", IIC_FPGeneral,
2374 [(set f32:$frD, (fceil f32:$frB))]>;
2375 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2376 defm FRIZD : XForm_26r<63, 424, (outs f8rc:$frD), (ins f8rc:$frB),
2377 "friz", "$frD, $frB", IIC_FPGeneral,
2378 [(set f64:$frD, (ftrunc f64:$frB))]>;
2379 defm FRIZS : XForm_26r<63, 424, (outs f4rc:$frD), (ins f4rc:$frB),
2380 "friz", "$frD, $frB", IIC_FPGeneral,
2381 [(set f32:$frD, (ftrunc f32:$frB))]>;
2382 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2383 defm FRIMD : XForm_26r<63, 488, (outs f8rc:$frD), (ins f8rc:$frB),
2384 "frim", "$frD, $frB", IIC_FPGeneral,
2385 [(set f64:$frD, (ffloor f64:$frB))]>;
2386 defm FRIMS : XForm_26r<63, 488, (outs f4rc:$frD), (ins f4rc:$frB),
2387 "frim", "$frD, $frB", IIC_FPGeneral,
2388 [(set f32:$frD, (ffloor f32:$frB))]>;
2390 defm FSQRT : XForm_26r<63, 22, (outs f8rc:$frD), (ins f8rc:$frB),
2391 "fsqrt", "$frD, $frB", IIC_FPSqrtD,
2392 [(set f64:$frD, (fsqrt f64:$frB))]>;
2393 defm FSQRTS : XForm_26r<59, 22, (outs f4rc:$frD), (ins f4rc:$frB),
2394 "fsqrts", "$frD, $frB", IIC_FPSqrtS,
2395 [(set f32:$frD, (fsqrt f32:$frB))]>;
2400 /// Note that FMR is defined as pseudo-ops on the PPC970 because they are
2401 /// often coalesced away and we don't want the dispatch group builder to think
2402 /// that they will fill slots (which could cause the load of a LSU reject to
2403 /// sneak into a d-group with a store).
2404 let hasSideEffects = 0, Predicates = [HasFPU] in
2405 defm FMR : XForm_26r<63, 72, (outs f4rc:$frD), (ins f4rc:$frB),
2406 "fmr", "$frD, $frB", IIC_FPGeneral,
2407 []>, // (set f32:$frD, f32:$frB)
2410 let PPC970_Unit = 3, hasSideEffects = 0, Predicates = [HasFPU] in { // FPU Operations.
2411 // These are artificially split into two different forms, for 4/8 byte FP.
2412 defm FABSS : XForm_26r<63, 264, (outs f4rc:$frD), (ins f4rc:$frB),
2413 "fabs", "$frD, $frB", IIC_FPGeneral,
2414 [(set f32:$frD, (fabs f32:$frB))]>;
2415 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2416 defm FABSD : XForm_26r<63, 264, (outs f8rc:$frD), (ins f8rc:$frB),
2417 "fabs", "$frD, $frB", IIC_FPGeneral,
2418 [(set f64:$frD, (fabs f64:$frB))]>;
2419 defm FNABSS : XForm_26r<63, 136, (outs f4rc:$frD), (ins f4rc:$frB),
2420 "fnabs", "$frD, $frB", IIC_FPGeneral,
2421 [(set f32:$frD, (fneg (fabs f32:$frB)))]>;
2422 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2423 defm FNABSD : XForm_26r<63, 136, (outs f8rc:$frD), (ins f8rc:$frB),
2424 "fnabs", "$frD, $frB", IIC_FPGeneral,
2425 [(set f64:$frD, (fneg (fabs f64:$frB)))]>;
2426 defm FNEGS : XForm_26r<63, 40, (outs f4rc:$frD), (ins f4rc:$frB),
2427 "fneg", "$frD, $frB", IIC_FPGeneral,
2428 [(set f32:$frD, (fneg f32:$frB))]>;
2429 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2430 defm FNEGD : XForm_26r<63, 40, (outs f8rc:$frD), (ins f8rc:$frB),
2431 "fneg", "$frD, $frB", IIC_FPGeneral,
2432 [(set f64:$frD, (fneg f64:$frB))]>;
2434 defm FCPSGNS : XForm_28r<63, 8, (outs f4rc:$frD), (ins f4rc:$frA, f4rc:$frB),
2435 "fcpsgn", "$frD, $frA, $frB", IIC_FPGeneral,
2436 [(set f32:$frD, (fcopysign f32:$frB, f32:$frA))]>;
2437 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2438 defm FCPSGND : XForm_28r<63, 8, (outs f8rc:$frD), (ins f8rc:$frA, f8rc:$frB),
2439 "fcpsgn", "$frD, $frA, $frB", IIC_FPGeneral,
2440 [(set f64:$frD, (fcopysign f64:$frB, f64:$frA))]>;
2442 // Reciprocal estimates.
2443 defm FRE : XForm_26r<63, 24, (outs f8rc:$frD), (ins f8rc:$frB),
2444 "fre", "$frD, $frB", IIC_FPGeneral,
2445 [(set f64:$frD, (PPCfre f64:$frB))]>;
2446 defm FRES : XForm_26r<59, 24, (outs f4rc:$frD), (ins f4rc:$frB),
2447 "fres", "$frD, $frB", IIC_FPGeneral,
2448 [(set f32:$frD, (PPCfre f32:$frB))]>;
2449 defm FRSQRTE : XForm_26r<63, 26, (outs f8rc:$frD), (ins f8rc:$frB),
2450 "frsqrte", "$frD, $frB", IIC_FPGeneral,
2451 [(set f64:$frD, (PPCfrsqrte f64:$frB))]>;
2452 defm FRSQRTES : XForm_26r<59, 26, (outs f4rc:$frD), (ins f4rc:$frB),
2453 "frsqrtes", "$frD, $frB", IIC_FPGeneral,
2454 [(set f32:$frD, (PPCfrsqrte f32:$frB))]>;
2457 // XL-Form instructions. condition register logical ops.
2459 let hasSideEffects = 0 in
2460 def MCRF : XLForm_3<19, 0, (outs crrc:$BF), (ins crrc:$BFA),
2461 "mcrf $BF, $BFA", IIC_BrMCR>,
2462 PPC970_DGroup_First, PPC970_Unit_CRU;
2464 // FIXME: According to the ISA (section 2.5.1 of version 2.06), the
2465 // condition-register logical instructions have preferred forms. Specifically,
2466 // it is preferred that the bit specified by the BT field be in the same
2467 // condition register as that specified by the bit BB. We might want to account
2468 // for this via hinting the register allocator and anti-dep breakers, or we
2469 // could constrain the register class to force this constraint and then loosen
2470 // it during register allocation via convertToThreeAddress or some similar
2473 let isCommutable = 1 in {
2474 def CRAND : XLForm_1<19, 257, (outs crbitrc:$CRD),
2475 (ins crbitrc:$CRA, crbitrc:$CRB),
2476 "crand $CRD, $CRA, $CRB", IIC_BrCR,
2477 [(set i1:$CRD, (and i1:$CRA, i1:$CRB))]>;
2479 def CRNAND : XLForm_1<19, 225, (outs crbitrc:$CRD),
2480 (ins crbitrc:$CRA, crbitrc:$CRB),
2481 "crnand $CRD, $CRA, $CRB", IIC_BrCR,
2482 [(set i1:$CRD, (not (and i1:$CRA, i1:$CRB)))]>;
2484 def CROR : XLForm_1<19, 449, (outs crbitrc:$CRD),
2485 (ins crbitrc:$CRA, crbitrc:$CRB),
2486 "cror $CRD, $CRA, $CRB", IIC_BrCR,
2487 [(set i1:$CRD, (or i1:$CRA, i1:$CRB))]>;
2489 def CRXOR : XLForm_1<19, 193, (outs crbitrc:$CRD),
2490 (ins crbitrc:$CRA, crbitrc:$CRB),
2491 "crxor $CRD, $CRA, $CRB", IIC_BrCR,
2492 [(set i1:$CRD, (xor i1:$CRA, i1:$CRB))]>;
2494 def CRNOR : XLForm_1<19, 33, (outs crbitrc:$CRD),
2495 (ins crbitrc:$CRA, crbitrc:$CRB),
2496 "crnor $CRD, $CRA, $CRB", IIC_BrCR,
2497 [(set i1:$CRD, (not (or i1:$CRA, i1:$CRB)))]>;
2499 def CREQV : XLForm_1<19, 289, (outs crbitrc:$CRD),
2500 (ins crbitrc:$CRA, crbitrc:$CRB),
2501 "creqv $CRD, $CRA, $CRB", IIC_BrCR,
2502 [(set i1:$CRD, (not (xor i1:$CRA, i1:$CRB)))]>;
2505 def CRANDC : XLForm_1<19, 129, (outs crbitrc:$CRD),
2506 (ins crbitrc:$CRA, crbitrc:$CRB),
2507 "crandc $CRD, $CRA, $CRB", IIC_BrCR,
2508 [(set i1:$CRD, (and i1:$CRA, (not i1:$CRB)))]>;
2510 def CRORC : XLForm_1<19, 417, (outs crbitrc:$CRD),
2511 (ins crbitrc:$CRA, crbitrc:$CRB),
2512 "crorc $CRD, $CRA, $CRB", IIC_BrCR,
2513 [(set i1:$CRD, (or i1:$CRA, (not i1:$CRB)))]>;
2515 let isCodeGenOnly = 1 in {
2516 def CRSET : XLForm_1_ext<19, 289, (outs crbitrc:$dst), (ins),
2517 "creqv $dst, $dst, $dst", IIC_BrCR,
2518 [(set i1:$dst, 1)]>;
2520 def CRUNSET: XLForm_1_ext<19, 193, (outs crbitrc:$dst), (ins),
2521 "crxor $dst, $dst, $dst", IIC_BrCR,
2522 [(set i1:$dst, 0)]>;
2524 let Defs = [CR1EQ], CRD = 6 in {
2525 def CR6SET : XLForm_1_ext<19, 289, (outs), (ins),
2526 "creqv 6, 6, 6", IIC_BrCR,
2529 def CR6UNSET: XLForm_1_ext<19, 193, (outs), (ins),
2530 "crxor 6, 6, 6", IIC_BrCR,
2535 // XFX-Form instructions. Instructions that deal with SPRs.
2538 def MFSPR : XFXForm_1<31, 339, (outs gprc:$RT), (ins i32imm:$SPR),
2539 "mfspr $RT, $SPR", IIC_SprMFSPR>;
2540 def MTSPR : XFXForm_1<31, 467, (outs), (ins i32imm:$SPR, gprc:$RT),
2541 "mtspr $SPR, $RT", IIC_SprMTSPR>;
2543 def MFTB : XFXForm_1<31, 371, (outs gprc:$RT), (ins i32imm:$SPR),
2544 "mftb $RT, $SPR", IIC_SprMFTB>;
2546 def MFPMR : XFXForm_1<31, 334, (outs gprc:$RT), (ins i32imm:$SPR),
2547 "mfpmr $RT, $SPR", IIC_SprMFPMR>;
2549 def MTPMR : XFXForm_1<31, 462, (outs), (ins i32imm:$SPR, gprc:$RT),
2550 "mtpmr $SPR, $RT", IIC_SprMTPMR>;
2553 // A pseudo-instruction used to implement the read of the 64-bit cycle counter
2554 // on a 32-bit target.
2555 let hasSideEffects = 1 in
2556 def ReadTB : PPCCustomInserterPseudo<(outs gprc:$lo, gprc:$hi), (ins),
2559 let Uses = [CTR] in {
2560 def MFCTR : XFXForm_1_ext<31, 339, 9, (outs gprc:$rT), (ins),
2561 "mfctr $rT", IIC_SprMFSPR>,
2562 PPC970_DGroup_First, PPC970_Unit_FXU;
2564 let Defs = [CTR], Pattern = [(PPCmtctr i32:$rS)] in {
2565 def MTCTR : XFXForm_7_ext<31, 467, 9, (outs), (ins gprc:$rS),
2566 "mtctr $rS", IIC_SprMTSPR>,
2567 PPC970_DGroup_First, PPC970_Unit_FXU;
2569 let hasSideEffects = 1, isCodeGenOnly = 1, Defs = [CTR] in {
2570 let Pattern = [(int_ppc_mtctr i32:$rS)] in
2571 def MTCTRloop : XFXForm_7_ext<31, 467, 9, (outs), (ins gprc:$rS),
2572 "mtctr $rS", IIC_SprMTSPR>,
2573 PPC970_DGroup_First, PPC970_Unit_FXU;
2576 let Defs = [LR] in {
2577 def MTLR : XFXForm_7_ext<31, 467, 8, (outs), (ins gprc:$rS),
2578 "mtlr $rS", IIC_SprMTSPR>,
2579 PPC970_DGroup_First, PPC970_Unit_FXU;
2581 let Uses = [LR] in {
2582 def MFLR : XFXForm_1_ext<31, 339, 8, (outs gprc:$rT), (ins),
2583 "mflr $rT", IIC_SprMFSPR>,
2584 PPC970_DGroup_First, PPC970_Unit_FXU;
2587 let isCodeGenOnly = 1 in {
2588 // Move to/from VRSAVE: despite being a SPR, the VRSAVE register is renamed
2589 // like a GPR on the PPC970. As such, copies in and out have the same
2590 // performance characteristics as an OR instruction.
2591 def MTVRSAVE : XFXForm_7_ext<31, 467, 256, (outs), (ins gprc:$rS),
2592 "mtspr 256, $rS", IIC_IntGeneral>,
2593 PPC970_DGroup_Single, PPC970_Unit_FXU;
2594 def MFVRSAVE : XFXForm_1_ext<31, 339, 256, (outs gprc:$rT), (ins),
2595 "mfspr $rT, 256", IIC_IntGeneral>,
2596 PPC970_DGroup_First, PPC970_Unit_FXU;
2598 def MTVRSAVEv : XFXForm_7_ext<31, 467, 256,
2599 (outs VRSAVERC:$reg), (ins gprc:$rS),
2600 "mtspr 256, $rS", IIC_IntGeneral>,
2601 PPC970_DGroup_Single, PPC970_Unit_FXU;
2602 def MFVRSAVEv : XFXForm_1_ext<31, 339, 256, (outs gprc:$rT),
2603 (ins VRSAVERC:$reg),
2604 "mfspr $rT, 256", IIC_IntGeneral>,
2605 PPC970_DGroup_First, PPC970_Unit_FXU;
2608 // Aliases for mtvrsave/mfvrsave to mfspr/mtspr.
2609 def : InstAlias<"mtvrsave $rS", (MTVRSAVE gprc:$rS)>;
2610 def : InstAlias<"mfvrsave $rS", (MFVRSAVE gprc:$rS)>;
2612 // SPILL_VRSAVE - Indicate that we're dumping the VRSAVE register,
2613 // so we'll need to scavenge a register for it.
2615 def SPILL_VRSAVE : PPCEmitTimePseudo<(outs), (ins VRSAVERC:$vrsave, memri:$F),
2616 "#SPILL_VRSAVE", []>;
2618 // RESTORE_VRSAVE - Indicate that we're restoring the VRSAVE register (previously
2619 // spilled), so we'll need to scavenge a register for it.
2621 def RESTORE_VRSAVE : PPCEmitTimePseudo<(outs VRSAVERC:$vrsave), (ins memri:$F),
2622 "#RESTORE_VRSAVE", []>;
2624 let hasSideEffects = 0 in {
2625 // mtocrf's input needs to be prepared by shifting by an amount dependent
2626 // on the cr register selected. Thus, post-ra anti-dep breaking must not
2627 // later change that register assignment.
2628 let hasExtraDefRegAllocReq = 1 in {
2629 def MTOCRF: XFXForm_5a<31, 144, (outs crbitm:$FXM), (ins gprc:$ST),
2630 "mtocrf $FXM, $ST", IIC_BrMCRX>,
2631 PPC970_DGroup_First, PPC970_Unit_CRU;
2633 // Similarly to mtocrf, the mask for mtcrf must be prepared in a way that
2634 // is dependent on the cr fields being set.
2635 def MTCRF : XFXForm_5<31, 144, (outs), (ins i32imm:$FXM, gprc:$rS),
2636 "mtcrf $FXM, $rS", IIC_BrMCRX>,
2637 PPC970_MicroCode, PPC970_Unit_CRU;
2638 } // hasExtraDefRegAllocReq = 1
2640 // mfocrf's input needs to be prepared by shifting by an amount dependent
2641 // on the cr register selected. Thus, post-ra anti-dep breaking must not
2642 // later change that register assignment.
2643 let hasExtraSrcRegAllocReq = 1 in {
2644 def MFOCRF: XFXForm_5a<31, 19, (outs gprc:$rT), (ins crbitm:$FXM),
2645 "mfocrf $rT, $FXM", IIC_SprMFCRF>,
2646 PPC970_DGroup_First, PPC970_Unit_CRU;
2648 // Similarly to mfocrf, the mask for mfcrf must be prepared in a way that
2649 // is dependent on the cr fields being copied.
2650 def MFCR : XFXForm_3<31, 19, (outs gprc:$rT), (ins),
2651 "mfcr $rT", IIC_SprMFCR>,
2652 PPC970_MicroCode, PPC970_Unit_CRU;
2653 } // hasExtraSrcRegAllocReq = 1
2655 def MCRXRX : X_BF3<31, 576, (outs crrc:$BF), (ins),
2656 "mcrxrx $BF", IIC_BrMCRX>, Requires<[IsISA3_0]>;
2657 } // hasSideEffects = 0
2659 let Predicates = [HasFPU] in {
2660 // Custom inserter instruction to perform FADD in round-to-zero mode.
2661 let Uses = [RM] in {
2662 def FADDrtz: PPCCustomInserterPseudo<(outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB), "",
2663 [(set f64:$FRT, (PPCfaddrtz f64:$FRA, f64:$FRB))]>;
2666 // The above pseudo gets expanded to make use of the following instructions
2667 // to manipulate FPSCR. Note that FPSCR is not modeled at the DAG level.
2668 let Uses = [RM], Defs = [RM] in {
2669 def MTFSB0 : XForm_43<63, 70, (outs), (ins u5imm:$FM),
2670 "mtfsb0 $FM", IIC_IntMTFSB0, []>,
2671 PPC970_DGroup_Single, PPC970_Unit_FPU;
2672 def MTFSB1 : XForm_43<63, 38, (outs), (ins u5imm:$FM),
2673 "mtfsb1 $FM", IIC_IntMTFSB0, []>,
2674 PPC970_DGroup_Single, PPC970_Unit_FPU;
2675 let isCodeGenOnly = 1 in
2676 def MTFSFb : XFLForm<63, 711, (outs), (ins i32imm:$FM, f8rc:$rT),
2677 "mtfsf $FM, $rT", IIC_IntMTFSB0, []>,
2678 PPC970_DGroup_Single, PPC970_Unit_FPU;
2680 let Uses = [RM] in {
2681 def MFFS : XForm_42<63, 583, (outs f8rc:$rT), (ins),
2682 "mffs $rT", IIC_IntMFFS,
2683 [(set f64:$rT, (PPCmffs))]>,
2684 PPC970_DGroup_Single, PPC970_Unit_FPU;
2687 def MFFSo : XForm_42<63, 583, (outs f8rc:$rT), (ins),
2688 "mffs. $rT", IIC_IntMFFS, []>, isDOT;
2690 def MFFSCE : X_FRT5_XO2_XO3_XO10<63, 0, 1, 583, (outs f8rc:$rT), (ins),
2691 "mffsce $rT", IIC_IntMFFS, []>,
2692 PPC970_DGroup_Single, PPC970_Unit_FPU;
2694 def MFFSCDRN : X_FRT5_XO2_XO3_FRB5_XO10<63, 2, 4, 583, (outs f8rc:$rT),
2695 (ins f8rc:$FRB), "mffscdrn $rT, $FRB",
2697 PPC970_DGroup_Single, PPC970_Unit_FPU;
2699 def MFFSCDRNI : X_FRT5_XO2_XO3_DRM3_XO10<63, 2, 5, 583, (outs f8rc:$rT),
2701 "mffscdrni $rT, $DRM",
2703 PPC970_DGroup_Single, PPC970_Unit_FPU;
2705 def MFFSCRN : X_FRT5_XO2_XO3_FRB5_XO10<63, 2, 6, 583, (outs f8rc:$rT),
2706 (ins f8rc:$FRB), "mffscrn $rT, $FRB",
2708 PPC970_DGroup_Single, PPC970_Unit_FPU;
2710 def MFFSCRNI : X_FRT5_XO2_XO3_RM2_X10<63, 2, 7, 583, (outs f8rc:$rT),
2711 (ins u2imm:$RM), "mffscrni $rT, $RM",
2713 PPC970_DGroup_Single, PPC970_Unit_FPU;
2715 def MFFSL : X_FRT5_XO2_XO3_XO10<63, 3, 0, 583, (outs f8rc:$rT), (ins),
2716 "mffsl $rT", IIC_IntMFFS, []>,
2717 PPC970_DGroup_Single, PPC970_Unit_FPU;
2721 let Predicates = [IsISA3_0] in {
2722 def MODSW : XForm_8<31, 779, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2723 "modsw $rT, $rA, $rB", IIC_IntDivW,
2724 [(set i32:$rT, (srem i32:$rA, i32:$rB))]>;
2725 def MODUW : XForm_8<31, 267, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2726 "moduw $rT, $rA, $rB", IIC_IntDivW,
2727 [(set i32:$rT, (urem i32:$rA, i32:$rB))]>;
2730 let PPC970_Unit = 1, hasSideEffects = 0 in { // FXU Operations.
2731 // XO-Form instructions. Arithmetic instructions that can set overflow bit
2732 let isCommutable = 1 in
2733 defm ADD4 : XOForm_1r<31, 266, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2734 "add", "$rT, $rA, $rB", IIC_IntSimple,
2735 [(set i32:$rT, (add i32:$rA, i32:$rB))]>;
2736 let isCodeGenOnly = 1 in
2737 def ADD4TLS : XOForm_1<31, 266, 0, (outs gprc:$rT), (ins gprc:$rA, tlsreg32:$rB),
2738 "add $rT, $rA, $rB", IIC_IntSimple,
2739 [(set i32:$rT, (add i32:$rA, tglobaltlsaddr:$rB))]>;
2740 let isCommutable = 1 in
2741 defm ADDC : XOForm_1rc<31, 10, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2742 "addc", "$rT, $rA, $rB", IIC_IntGeneral,
2743 [(set i32:$rT, (addc i32:$rA, i32:$rB))]>,
2744 PPC970_DGroup_Cracked;
2746 defm DIVW : XOForm_1rcr<31, 491, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2747 "divw", "$rT, $rA, $rB", IIC_IntDivW,
2748 [(set i32:$rT, (sdiv i32:$rA, i32:$rB))]>;
2749 defm DIVWU : XOForm_1rcr<31, 459, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2750 "divwu", "$rT, $rA, $rB", IIC_IntDivW,
2751 [(set i32:$rT, (udiv i32:$rA, i32:$rB))]>;
2752 def DIVWE : XOForm_1<31, 427, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2753 "divwe $rT, $rA, $rB", IIC_IntDivW,
2754 [(set i32:$rT, (int_ppc_divwe gprc:$rA, gprc:$rB))]>,
2755 Requires<[HasExtDiv]>;
2757 def DIVWEo : XOForm_1<31, 427, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2758 "divwe. $rT, $rA, $rB", IIC_IntDivW,
2759 []>, isDOT, PPC970_DGroup_Cracked, PPC970_DGroup_First,
2760 Requires<[HasExtDiv]>;
2761 def DIVWEU : XOForm_1<31, 395, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2762 "divweu $rT, $rA, $rB", IIC_IntDivW,
2763 [(set i32:$rT, (int_ppc_divweu gprc:$rA, gprc:$rB))]>,
2764 Requires<[HasExtDiv]>;
2766 def DIVWEUo : XOForm_1<31, 395, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2767 "divweu. $rT, $rA, $rB", IIC_IntDivW,
2768 []>, isDOT, PPC970_DGroup_Cracked, PPC970_DGroup_First,
2769 Requires<[HasExtDiv]>;
2770 let isCommutable = 1 in {
2771 defm MULHW : XOForm_1r<31, 75, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2772 "mulhw", "$rT, $rA, $rB", IIC_IntMulHW,
2773 [(set i32:$rT, (mulhs i32:$rA, i32:$rB))]>;
2774 defm MULHWU : XOForm_1r<31, 11, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2775 "mulhwu", "$rT, $rA, $rB", IIC_IntMulHWU,
2776 [(set i32:$rT, (mulhu i32:$rA, i32:$rB))]>;
2777 defm MULLW : XOForm_1r<31, 235, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2778 "mullw", "$rT, $rA, $rB", IIC_IntMulHW,
2779 [(set i32:$rT, (mul i32:$rA, i32:$rB))]>;
2781 defm SUBF : XOForm_1r<31, 40, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2782 "subf", "$rT, $rA, $rB", IIC_IntGeneral,
2783 [(set i32:$rT, (sub i32:$rB, i32:$rA))]>;
2784 defm SUBFC : XOForm_1rc<31, 8, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2785 "subfc", "$rT, $rA, $rB", IIC_IntGeneral,
2786 [(set i32:$rT, (subc i32:$rB, i32:$rA))]>,
2787 PPC970_DGroup_Cracked;
2788 defm NEG : XOForm_3r<31, 104, 0, (outs gprc:$rT), (ins gprc:$rA),
2789 "neg", "$rT, $rA", IIC_IntSimple,
2790 [(set i32:$rT, (ineg i32:$rA))]>;
2791 let Uses = [CARRY] in {
2792 let isCommutable = 1 in
2793 defm ADDE : XOForm_1rc<31, 138, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2794 "adde", "$rT, $rA, $rB", IIC_IntGeneral,
2795 [(set i32:$rT, (adde i32:$rA, i32:$rB))]>;
2796 defm ADDME : XOForm_3rc<31, 234, 0, (outs gprc:$rT), (ins gprc:$rA),
2797 "addme", "$rT, $rA", IIC_IntGeneral,
2798 [(set i32:$rT, (adde i32:$rA, -1))]>;
2799 defm ADDZE : XOForm_3rc<31, 202, 0, (outs gprc:$rT), (ins gprc:$rA),
2800 "addze", "$rT, $rA", IIC_IntGeneral,
2801 [(set i32:$rT, (adde i32:$rA, 0))]>;
2802 defm SUBFE : XOForm_1rc<31, 136, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2803 "subfe", "$rT, $rA, $rB", IIC_IntGeneral,
2804 [(set i32:$rT, (sube i32:$rB, i32:$rA))]>;
2805 defm SUBFME : XOForm_3rc<31, 232, 0, (outs gprc:$rT), (ins gprc:$rA),
2806 "subfme", "$rT, $rA", IIC_IntGeneral,
2807 [(set i32:$rT, (sube -1, i32:$rA))]>;
2808 defm SUBFZE : XOForm_3rc<31, 200, 0, (outs gprc:$rT), (ins gprc:$rA),
2809 "subfze", "$rT, $rA", IIC_IntGeneral,
2810 [(set i32:$rT, (sube 0, i32:$rA))]>;
2814 // A-Form instructions. Most of the instructions executed in the FPU are of
2817 let PPC970_Unit = 3, hasSideEffects = 0, Predicates = [HasFPU] in { // FPU Operations.
2818 let Uses = [RM] in {
2819 let isCommutable = 1 in {
2820 defm FMADD : AForm_1r<63, 29,
2821 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2822 "fmadd", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2823 [(set f64:$FRT, (fma f64:$FRA, f64:$FRC, f64:$FRB))]>;
2824 defm FMADDS : AForm_1r<59, 29,
2825 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2826 "fmadds", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2827 [(set f32:$FRT, (fma f32:$FRA, f32:$FRC, f32:$FRB))]>;
2828 defm FMSUB : AForm_1r<63, 28,
2829 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2830 "fmsub", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2832 (fma f64:$FRA, f64:$FRC, (fneg f64:$FRB)))]>;
2833 defm FMSUBS : AForm_1r<59, 28,
2834 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2835 "fmsubs", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2837 (fma f32:$FRA, f32:$FRC, (fneg f32:$FRB)))]>;
2838 defm FNMADD : AForm_1r<63, 31,
2839 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2840 "fnmadd", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2842 (fneg (fma f64:$FRA, f64:$FRC, f64:$FRB)))]>;
2843 defm FNMADDS : AForm_1r<59, 31,
2844 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2845 "fnmadds", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2847 (fneg (fma f32:$FRA, f32:$FRC, f32:$FRB)))]>;
2848 defm FNMSUB : AForm_1r<63, 30,
2849 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2850 "fnmsub", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2851 [(set f64:$FRT, (fneg (fma f64:$FRA, f64:$FRC,
2852 (fneg f64:$FRB))))]>;
2853 defm FNMSUBS : AForm_1r<59, 30,
2854 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2855 "fnmsubs", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2856 [(set f32:$FRT, (fneg (fma f32:$FRA, f32:$FRC,
2857 (fneg f32:$FRB))))]>;
2860 // FSEL is artificially split into 4 and 8-byte forms for the result. To avoid
2861 // having 4 of these, force the comparison to always be an 8-byte double (code
2862 // should use an FMRSD if the input comparison value really wants to be a float)
2863 // and 4/8 byte forms for the result and operand type..
2864 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2865 defm FSELD : AForm_1r<63, 23,
2866 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2867 "fsel", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2868 [(set f64:$FRT, (PPCfsel f64:$FRA, f64:$FRC, f64:$FRB))]>;
2869 defm FSELS : AForm_1r<63, 23,
2870 (outs f4rc:$FRT), (ins f8rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2871 "fsel", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2872 [(set f32:$FRT, (PPCfsel f64:$FRA, f32:$FRC, f32:$FRB))]>;
2873 let Uses = [RM] in {
2874 let isCommutable = 1 in {
2875 defm FADD : AForm_2r<63, 21,
2876 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB),
2877 "fadd", "$FRT, $FRA, $FRB", IIC_FPAddSub,
2878 [(set f64:$FRT, (fadd f64:$FRA, f64:$FRB))]>;
2879 defm FADDS : AForm_2r<59, 21,
2880 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB),
2881 "fadds", "$FRT, $FRA, $FRB", IIC_FPGeneral,
2882 [(set f32:$FRT, (fadd f32:$FRA, f32:$FRB))]>;
2884 defm FDIV : AForm_2r<63, 18,
2885 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB),
2886 "fdiv", "$FRT, $FRA, $FRB", IIC_FPDivD,
2887 [(set f64:$FRT, (fdiv f64:$FRA, f64:$FRB))]>;
2888 defm FDIVS : AForm_2r<59, 18,
2889 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB),
2890 "fdivs", "$FRT, $FRA, $FRB", IIC_FPDivS,
2891 [(set f32:$FRT, (fdiv f32:$FRA, f32:$FRB))]>;
2892 let isCommutable = 1 in {
2893 defm FMUL : AForm_3r<63, 25,
2894 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC),
2895 "fmul", "$FRT, $FRA, $FRC", IIC_FPFused,
2896 [(set f64:$FRT, (fmul f64:$FRA, f64:$FRC))]>;
2897 defm FMULS : AForm_3r<59, 25,
2898 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC),
2899 "fmuls", "$FRT, $FRA, $FRC", IIC_FPGeneral,
2900 [(set f32:$FRT, (fmul f32:$FRA, f32:$FRC))]>;
2902 defm FSUB : AForm_2r<63, 20,
2903 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB),
2904 "fsub", "$FRT, $FRA, $FRB", IIC_FPAddSub,
2905 [(set f64:$FRT, (fsub f64:$FRA, f64:$FRB))]>;
2906 defm FSUBS : AForm_2r<59, 20,
2907 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB),
2908 "fsubs", "$FRT, $FRA, $FRB", IIC_FPGeneral,
2909 [(set f32:$FRT, (fsub f32:$FRA, f32:$FRB))]>;
2913 let hasSideEffects = 0 in {
2914 let PPC970_Unit = 1 in { // FXU Operations.
2916 def ISEL : AForm_4<31, 15,
2917 (outs gprc:$rT), (ins gprc_nor0:$rA, gprc:$rB, crbitrc:$cond),
2918 "isel $rT, $rA, $rB, $cond", IIC_IntISEL,
2922 let PPC970_Unit = 1 in { // FXU Operations.
2923 // M-Form instructions. rotate and mask instructions.
2925 let isCommutable = 1 in {
2926 // RLWIMI can be commuted if the rotate amount is zero.
2927 defm RLWIMI : MForm_2r<20, (outs gprc:$rA),
2928 (ins gprc:$rSi, gprc:$rS, u5imm:$SH, u5imm:$MB,
2929 u5imm:$ME), "rlwimi", "$rA, $rS, $SH, $MB, $ME",
2930 IIC_IntRotate, []>, PPC970_DGroup_Cracked,
2931 RegConstraint<"$rSi = $rA">, NoEncode<"$rSi">;
2933 let BaseName = "rlwinm" in {
2934 def RLWINM : MForm_2<21,
2935 (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
2936 "rlwinm $rA, $rS, $SH, $MB, $ME", IIC_IntGeneral,
2939 def RLWINMo : MForm_2<21,
2940 (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
2941 "rlwinm. $rA, $rS, $SH, $MB, $ME", IIC_IntGeneral,
2942 []>, isDOT, RecFormRel, PPC970_DGroup_Cracked;
2944 defm RLWNM : MForm_2r<23, (outs gprc:$rA),
2945 (ins gprc:$rS, gprc:$rB, u5imm:$MB, u5imm:$ME),
2946 "rlwnm", "$rA, $rS, $rB, $MB, $ME", IIC_IntGeneral,
2949 } // hasSideEffects = 0
2951 //===----------------------------------------------------------------------===//
2952 // PowerPC Instruction Patterns
2955 // Arbitrary immediate support. Implement in terms of LIS/ORI.
2956 def : Pat<(i32 imm:$imm),
2957 (ORI (LIS (HI16 imm:$imm)), (LO16 imm:$imm))>;
2959 // Implement the 'not' operation with the NOR instruction.
2960 def i32not : OutPatFrag<(ops node:$in),
2962 def : Pat<(not i32:$in),
2965 // ADD an arbitrary immediate.
2966 def : Pat<(add i32:$in, imm:$imm),
2967 (ADDIS (ADDI $in, (LO16 imm:$imm)), (HA16 imm:$imm))>;
2968 // OR an arbitrary immediate.
2969 def : Pat<(or i32:$in, imm:$imm),
2970 (ORIS (ORI $in, (LO16 imm:$imm)), (HI16 imm:$imm))>;
2971 // XOR an arbitrary immediate.
2972 def : Pat<(xor i32:$in, imm:$imm),
2973 (XORIS (XORI $in, (LO16 imm:$imm)), (HI16 imm:$imm))>;
2975 def : Pat<(sub imm32SExt16:$imm, i32:$in),
2976 (SUBFIC $in, imm:$imm)>;
2979 def : Pat<(shl i32:$in, (i32 imm:$imm)),
2980 (RLWINM $in, imm:$imm, 0, (SHL32 imm:$imm))>;
2981 def : Pat<(srl i32:$in, (i32 imm:$imm)),
2982 (RLWINM $in, (SRL32 imm:$imm), imm:$imm, 31)>;
2985 def : Pat<(rotl i32:$in, i32:$sh),
2986 (RLWNM $in, $sh, 0, 31)>;
2987 def : Pat<(rotl i32:$in, (i32 imm:$imm)),
2988 (RLWINM $in, imm:$imm, 0, 31)>;
2991 def : Pat<(and (rotl i32:$in, i32:$sh), maskimm32:$imm),
2992 (RLWNM $in, $sh, (MB maskimm32:$imm), (ME maskimm32:$imm))>;
2995 def : Pat<(PPCcall (i32 tglobaladdr:$dst)),
2996 (BL tglobaladdr:$dst)>;
2997 def : Pat<(PPCcall (i32 texternalsym:$dst)),
2998 (BL texternalsym:$dst)>;
3000 def : Pat<(PPCtc_return (i32 tglobaladdr:$dst), imm:$imm),
3001 (TCRETURNdi tglobaladdr:$dst, imm:$imm)>;
3003 def : Pat<(PPCtc_return (i32 texternalsym:$dst), imm:$imm),
3004 (TCRETURNdi texternalsym:$dst, imm:$imm)>;
3006 def : Pat<(PPCtc_return CTRRC:$dst, imm:$imm),
3007 (TCRETURNri CTRRC:$dst, imm:$imm)>;
3011 // Hi and Lo for Darwin Global Addresses.
3012 def : Pat<(PPChi tglobaladdr:$in, 0), (LIS tglobaladdr:$in)>;
3013 def : Pat<(PPClo tglobaladdr:$in, 0), (LI tglobaladdr:$in)>;
3014 def : Pat<(PPChi tconstpool:$in, 0), (LIS tconstpool:$in)>;
3015 def : Pat<(PPClo tconstpool:$in, 0), (LI tconstpool:$in)>;
3016 def : Pat<(PPChi tjumptable:$in, 0), (LIS tjumptable:$in)>;
3017 def : Pat<(PPClo tjumptable:$in, 0), (LI tjumptable:$in)>;
3018 def : Pat<(PPChi tblockaddress:$in, 0), (LIS tblockaddress:$in)>;
3019 def : Pat<(PPClo tblockaddress:$in, 0), (LI tblockaddress:$in)>;
3020 def : Pat<(PPChi tglobaltlsaddr:$g, i32:$in),
3021 (ADDIS $in, tglobaltlsaddr:$g)>;
3022 def : Pat<(PPClo tglobaltlsaddr:$g, i32:$in),
3023 (ADDI $in, tglobaltlsaddr:$g)>;
3024 def : Pat<(add i32:$in, (PPChi tglobaladdr:$g, 0)),
3025 (ADDIS $in, tglobaladdr:$g)>;
3026 def : Pat<(add i32:$in, (PPChi tconstpool:$g, 0)),
3027 (ADDIS $in, tconstpool:$g)>;
3028 def : Pat<(add i32:$in, (PPChi tjumptable:$g, 0)),
3029 (ADDIS $in, tjumptable:$g)>;
3030 def : Pat<(add i32:$in, (PPChi tblockaddress:$g, 0)),
3031 (ADDIS $in, tblockaddress:$g)>;
3033 // Support for thread-local storage.
3034 def PPC32GOT: PPCEmitTimePseudo<(outs gprc:$rD), (ins), "#PPC32GOT",
3035 [(set i32:$rD, (PPCppc32GOT))]>;
3037 // Get the _GLOBAL_OFFSET_TABLE_ in PIC mode.
3038 // This uses two output registers, the first as the real output, the second as a
3039 // temporary register, used internally in code generation.
3040 def PPC32PICGOT: PPCEmitTimePseudo<(outs gprc:$rD, gprc:$rT), (ins), "#PPC32PICGOT",
3041 []>, NoEncode<"$rT">;
3043 def LDgotTprelL32: PPCEmitTimePseudo<(outs gprc:$rD), (ins s16imm:$disp, gprc_nor0:$reg),
3046 (PPCldGotTprelL tglobaltlsaddr:$disp, i32:$reg))]>;
3047 def : Pat<(PPCaddTls i32:$in, tglobaltlsaddr:$g),
3048 (ADD4TLS $in, tglobaltlsaddr:$g)>;
3050 def ADDItlsgdL32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
3053 (PPCaddiTlsgdL i32:$reg, tglobaltlsaddr:$disp))]>;
3054 // LR is a true define, while the rest of the Defs are clobbers. R3 is
3055 // explicitly defined when this op is created, so not mentioned here.
3056 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
3057 Defs = [R0,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
3058 def GETtlsADDR32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc:$reg, tlsgd32:$sym),
3061 (PPCgetTlsAddr i32:$reg, tglobaltlsaddr:$sym))]>;
3062 // Combined op for ADDItlsgdL32 and GETtlsADDR32, late expanded. R3 and LR
3063 // are true defines while the rest of the Defs are clobbers.
3064 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
3065 Defs = [R0,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
3066 def ADDItlsgdLADDR32 : PPCEmitTimePseudo<(outs gprc:$rD),
3067 (ins gprc_nor0:$reg, s16imm:$disp, tlsgd32:$sym),
3068 "#ADDItlsgdLADDR32",
3070 (PPCaddiTlsgdLAddr i32:$reg,
3071 tglobaltlsaddr:$disp,
3072 tglobaltlsaddr:$sym))]>;
3073 def ADDItlsldL32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
3076 (PPCaddiTlsldL i32:$reg, tglobaltlsaddr:$disp))]>;
3077 // LR is a true define, while the rest of the Defs are clobbers. R3 is
3078 // explicitly defined when this op is created, so not mentioned here.
3079 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
3080 Defs = [R0,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
3081 def GETtlsldADDR32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc:$reg, tlsgd32:$sym),
3084 (PPCgetTlsldAddr i32:$reg,
3085 tglobaltlsaddr:$sym))]>;
3086 // Combined op for ADDItlsldL32 and GETtlsADDR32, late expanded. R3 and LR
3087 // are true defines while the rest of the Defs are clobbers.
3088 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
3089 Defs = [R0,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
3090 def ADDItlsldLADDR32 : PPCEmitTimePseudo<(outs gprc:$rD),
3091 (ins gprc_nor0:$reg, s16imm:$disp, tlsgd32:$sym),
3092 "#ADDItlsldLADDR32",
3094 (PPCaddiTlsldLAddr i32:$reg,
3095 tglobaltlsaddr:$disp,
3096 tglobaltlsaddr:$sym))]>;
3097 def ADDIdtprelL32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
3100 (PPCaddiDtprelL i32:$reg, tglobaltlsaddr:$disp))]>;
3101 def ADDISdtprelHA32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
3104 (PPCaddisDtprelHA i32:$reg,
3105 tglobaltlsaddr:$disp))]>;
3107 // Support for Position-independent code
3108 def LWZtoc : PPCEmitTimePseudo<(outs gprc:$rD), (ins tocentry32:$disp, gprc:$reg),
3111 (PPCtoc_entry tglobaladdr:$disp, i32:$reg))]>;
3112 // Get Global (GOT) Base Register offset, from the word immediately preceding
3113 // the function label.
3114 def UpdateGBR : PPCEmitTimePseudo<(outs gprc:$rD, gprc:$rT), (ins gprc:$rI), "#UpdateGBR", []>;
3117 // Standard shifts. These are represented separately from the real shifts above
3118 // so that we can distinguish between shifts that allow 5-bit and 6-bit shift
3120 def : Pat<(sra i32:$rS, i32:$rB),
3122 def : Pat<(srl i32:$rS, i32:$rB),
3124 def : Pat<(shl i32:$rS, i32:$rB),
3127 def : Pat<(zextloadi1 iaddr:$src),
3129 def : Pat<(zextloadi1 xaddr:$src),
3131 def : Pat<(extloadi1 iaddr:$src),
3133 def : Pat<(extloadi1 xaddr:$src),
3135 def : Pat<(extloadi8 iaddr:$src),
3137 def : Pat<(extloadi8 xaddr:$src),
3139 def : Pat<(extloadi16 iaddr:$src),
3141 def : Pat<(extloadi16 xaddr:$src),
3143 let Predicates = [HasFPU] in {
3144 def : Pat<(f64 (extloadf32 iaddr:$src)),
3145 (COPY_TO_REGCLASS (LFS iaddr:$src), F8RC)>;
3146 def : Pat<(f64 (extloadf32 xaddr:$src)),
3147 (COPY_TO_REGCLASS (LFSX xaddr:$src), F8RC)>;
3149 def : Pat<(f64 (fpextend f32:$src)),
3150 (COPY_TO_REGCLASS $src, F8RC)>;
3153 // Only seq_cst fences require the heavyweight sync (SYNC 0).
3154 // All others can use the lightweight sync (SYNC 1).
3155 // source: http://www.cl.cam.ac.uk/~pes20/cpp/cpp0xmappings.html
3156 // The rule for seq_cst is duplicated to work with both 64 bits and 32 bits
3157 // versions of Power.
3158 def : Pat<(atomic_fence (i64 7), (imm)), (SYNC 0)>, Requires<[HasSYNC]>;
3159 def : Pat<(atomic_fence (i32 7), (imm)), (SYNC 0)>, Requires<[HasSYNC]>;
3160 def : Pat<(atomic_fence (imm), (imm)), (SYNC 1)>, Requires<[HasSYNC]>;
3161 def : Pat<(atomic_fence (imm), (imm)), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
3163 let Predicates = [HasFPU] in {
3164 // Additional FNMSUB patterns: -a*c + b == -(a*c - b)
3165 def : Pat<(fma (fneg f64:$A), f64:$C, f64:$B),
3166 (FNMSUB $A, $C, $B)>;
3167 def : Pat<(fma f64:$A, (fneg f64:$C), f64:$B),
3168 (FNMSUB $A, $C, $B)>;
3169 def : Pat<(fma (fneg f32:$A), f32:$C, f32:$B),
3170 (FNMSUBS $A, $C, $B)>;
3171 def : Pat<(fma f32:$A, (fneg f32:$C), f32:$B),
3172 (FNMSUBS $A, $C, $B)>;
3174 // FCOPYSIGN's operand types need not agree.
3175 def : Pat<(fcopysign f64:$frB, f32:$frA),
3176 (FCPSGND (COPY_TO_REGCLASS $frA, F8RC), $frB)>;
3177 def : Pat<(fcopysign f32:$frB, f64:$frA),
3178 (FCPSGNS (COPY_TO_REGCLASS $frA, F4RC), $frB)>;
3181 include "PPCInstrAltivec.td"
3182 include "PPCInstrSPE.td"
3183 include "PPCInstr64Bit.td"
3184 include "PPCInstrVSX.td"
3185 include "PPCInstrQPX.td"
3186 include "PPCInstrHTM.td"
3188 def crnot : OutPatFrag<(ops node:$in),
3190 def : Pat<(not i1:$in),
3193 // Patterns for arithmetic i1 operations.
3194 def : Pat<(add i1:$a, i1:$b),
3196 def : Pat<(sub i1:$a, i1:$b),
3198 def : Pat<(mul i1:$a, i1:$b),
3201 // We're sometimes asked to materialize i1 -1, which is just 1 in this case
3202 // (-1 is used to mean all bits set).
3203 def : Pat<(i1 -1), (CRSET)>;
3205 // i1 extensions, implemented in terms of isel.
3206 def : Pat<(i32 (zext i1:$in)),
3207 (SELECT_I4 $in, (LI 1), (LI 0))>;
3208 def : Pat<(i32 (sext i1:$in)),
3209 (SELECT_I4 $in, (LI -1), (LI 0))>;
3211 def : Pat<(i64 (zext i1:$in)),
3212 (SELECT_I8 $in, (LI8 1), (LI8 0))>;
3213 def : Pat<(i64 (sext i1:$in)),
3214 (SELECT_I8 $in, (LI8 -1), (LI8 0))>;
3216 // FIXME: We should choose either a zext or a sext based on other constants
3218 def : Pat<(i32 (anyext i1:$in)),
3219 (SELECT_I4 $in, (LI 1), (LI 0))>;
3220 def : Pat<(i64 (anyext i1:$in)),
3221 (SELECT_I8 $in, (LI8 1), (LI8 0))>;
3223 // match setcc on i1 variables.
3241 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETLT)),
3243 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETULT)),
3262 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETLE)),
3264 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETULE)),
3267 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETEQ)),
3281 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETGE)),
3283 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETUGE)),
3297 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETGT)),
3299 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETUGT)),
3302 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETNE)),
3305 // match setcc on non-i1 (non-vector) variables. Note that SETUEQ, SETOGE,
3306 // SETOLE, SETONE, SETULT and SETUGT should be expanded by legalize for
3307 // floating-point types.
3309 multiclass CRNotPat<dag pattern, dag result> {
3310 def : Pat<pattern, (crnot result)>;
3311 def : Pat<(not pattern), result>;
3313 // We can also fold the crnot into an extension:
3314 def : Pat<(i32 (zext pattern)),
3315 (SELECT_I4 result, (LI 0), (LI 1))>;
3316 def : Pat<(i32 (sext pattern)),
3317 (SELECT_I4 result, (LI 0), (LI -1))>;
3319 // We can also fold the crnot into an extension:
3320 def : Pat<(i64 (zext pattern)),
3321 (SELECT_I8 result, (LI8 0), (LI8 1))>;
3322 def : Pat<(i64 (sext pattern)),
3323 (SELECT_I8 result, (LI8 0), (LI8 -1))>;
3325 // FIXME: We should choose either a zext or a sext based on other constants
3327 def : Pat<(i32 (anyext pattern)),
3328 (SELECT_I4 result, (LI 0), (LI 1))>;
3330 def : Pat<(i64 (anyext pattern)),
3331 (SELECT_I8 result, (LI8 0), (LI8 1))>;
3334 // FIXME: Because of what seems like a bug in TableGen's type-inference code,
3335 // we need to write imm:$imm in the output patterns below, not just $imm, or
3336 // else the resulting matcher will not correctly add the immediate operand
3337 // (making it a register operand instead).
3340 multiclass ExtSetCCPat<CondCode cc, PatFrag pfrag,
3341 OutPatFrag rfrag, OutPatFrag rfrag8> {
3342 def : Pat<(i32 (zext (i1 (pfrag i32:$s1, cc)))),
3344 def : Pat<(i64 (zext (i1 (pfrag i64:$s1, cc)))),
3346 def : Pat<(i64 (zext (i1 (pfrag i32:$s1, cc)))),
3347 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1), sub_32)>;
3348 def : Pat<(i32 (zext (i1 (pfrag i64:$s1, cc)))),
3349 (EXTRACT_SUBREG (rfrag8 $s1), sub_32)>;
3351 def : Pat<(i32 (anyext (i1 (pfrag i32:$s1, cc)))),
3353 def : Pat<(i64 (anyext (i1 (pfrag i64:$s1, cc)))),
3355 def : Pat<(i64 (anyext (i1 (pfrag i32:$s1, cc)))),
3356 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1), sub_32)>;
3357 def : Pat<(i32 (anyext (i1 (pfrag i64:$s1, cc)))),
3358 (EXTRACT_SUBREG (rfrag8 $s1), sub_32)>;
3361 // Note that we do all inversions below with i(32|64)not, instead of using
3362 // (xori x, 1) because on the A2 nor has single-cycle latency while xori
3363 // has 2-cycle latency.
3365 defm : ExtSetCCPat<SETEQ,
3366 PatFrag<(ops node:$in, node:$cc),
3367 (setcc $in, 0, $cc)>,
3368 OutPatFrag<(ops node:$in),
3369 (RLWINM (CNTLZW $in), 27, 31, 31)>,
3370 OutPatFrag<(ops node:$in),
3371 (RLDICL (CNTLZD $in), 58, 63)> >;
3373 defm : ExtSetCCPat<SETNE,
3374 PatFrag<(ops node:$in, node:$cc),
3375 (setcc $in, 0, $cc)>,
3376 OutPatFrag<(ops node:$in),
3377 (RLWINM (i32not (CNTLZW $in)), 27, 31, 31)>,
3378 OutPatFrag<(ops node:$in),
3379 (RLDICL (i64not (CNTLZD $in)), 58, 63)> >;
3381 defm : ExtSetCCPat<SETLT,
3382 PatFrag<(ops node:$in, node:$cc),
3383 (setcc $in, 0, $cc)>,
3384 OutPatFrag<(ops node:$in),
3385 (RLWINM $in, 1, 31, 31)>,
3386 OutPatFrag<(ops node:$in),
3387 (RLDICL $in, 1, 63)> >;
3389 defm : ExtSetCCPat<SETGE,
3390 PatFrag<(ops node:$in, node:$cc),
3391 (setcc $in, 0, $cc)>,
3392 OutPatFrag<(ops node:$in),
3393 (RLWINM (i32not $in), 1, 31, 31)>,
3394 OutPatFrag<(ops node:$in),
3395 (RLDICL (i64not $in), 1, 63)> >;
3397 defm : ExtSetCCPat<SETGT,
3398 PatFrag<(ops node:$in, node:$cc),
3399 (setcc $in, 0, $cc)>,
3400 OutPatFrag<(ops node:$in),
3401 (RLWINM (ANDC (NEG $in), $in), 1, 31, 31)>,
3402 OutPatFrag<(ops node:$in),
3403 (RLDICL (ANDC8 (NEG8 $in), $in), 1, 63)> >;
3405 defm : ExtSetCCPat<SETLE,
3406 PatFrag<(ops node:$in, node:$cc),
3407 (setcc $in, 0, $cc)>,
3408 OutPatFrag<(ops node:$in),
3409 (RLWINM (ORC $in, (NEG $in)), 1, 31, 31)>,
3410 OutPatFrag<(ops node:$in),
3411 (RLDICL (ORC8 $in, (NEG8 $in)), 1, 63)> >;
3413 defm : ExtSetCCPat<SETLT,
3414 PatFrag<(ops node:$in, node:$cc),
3415 (setcc $in, -1, $cc)>,
3416 OutPatFrag<(ops node:$in),
3417 (RLWINM (AND $in, (ADDI $in, 1)), 1, 31, 31)>,
3418 OutPatFrag<(ops node:$in),
3419 (RLDICL (AND8 $in, (ADDI8 $in, 1)), 1, 63)> >;
3421 defm : ExtSetCCPat<SETGE,
3422 PatFrag<(ops node:$in, node:$cc),
3423 (setcc $in, -1, $cc)>,
3424 OutPatFrag<(ops node:$in),
3425 (RLWINM (NAND $in, (ADDI $in, 1)), 1, 31, 31)>,
3426 OutPatFrag<(ops node:$in),
3427 (RLDICL (NAND8 $in, (ADDI8 $in, 1)), 1, 63)> >;
3429 defm : ExtSetCCPat<SETGT,
3430 PatFrag<(ops node:$in, node:$cc),
3431 (setcc $in, -1, $cc)>,
3432 OutPatFrag<(ops node:$in),
3433 (RLWINM (i32not $in), 1, 31, 31)>,
3434 OutPatFrag<(ops node:$in),
3435 (RLDICL (i64not $in), 1, 63)> >;
3437 defm : ExtSetCCPat<SETLE,
3438 PatFrag<(ops node:$in, node:$cc),
3439 (setcc $in, -1, $cc)>,
3440 OutPatFrag<(ops node:$in),
3441 (RLWINM $in, 1, 31, 31)>,
3442 OutPatFrag<(ops node:$in),
3443 (RLDICL $in, 1, 63)> >;
3445 // An extended SETCC with shift amount.
3446 multiclass ExtSetCCShiftPat<CondCode cc, PatFrag pfrag,
3447 OutPatFrag rfrag, OutPatFrag rfrag8> {
3448 def : Pat<(i32 (zext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
3450 def : Pat<(i64 (zext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
3452 def : Pat<(i64 (zext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
3453 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1, $sa), sub_32)>;
3454 def : Pat<(i32 (zext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
3455 (EXTRACT_SUBREG (rfrag8 $s1, $sa), sub_32)>;
3457 def : Pat<(i32 (anyext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
3459 def : Pat<(i64 (anyext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
3461 def : Pat<(i64 (anyext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
3462 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1, $sa), sub_32)>;
3463 def : Pat<(i32 (anyext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
3464 (EXTRACT_SUBREG (rfrag8 $s1, $sa), sub_32)>;
3467 defm : ExtSetCCShiftPat<SETNE,
3468 PatFrag<(ops node:$in, node:$sa, node:$cc),
3469 (setcc (and $in, (shl 1, $sa)), 0, $cc)>,
3470 OutPatFrag<(ops node:$in, node:$sa),
3471 (RLWNM $in, (SUBFIC $sa, 32), 31, 31)>,
3472 OutPatFrag<(ops node:$in, node:$sa),
3473 (RLDCL $in, (SUBFIC $sa, 64), 63)> >;
3475 defm : ExtSetCCShiftPat<SETEQ,
3476 PatFrag<(ops node:$in, node:$sa, node:$cc),
3477 (setcc (and $in, (shl 1, $sa)), 0, $cc)>,
3478 OutPatFrag<(ops node:$in, node:$sa),
3479 (RLWNM (i32not $in),
3480 (SUBFIC $sa, 32), 31, 31)>,
3481 OutPatFrag<(ops node:$in, node:$sa),
3482 (RLDCL (i64not $in),
3483 (SUBFIC $sa, 64), 63)> >;
3486 def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETULT)),
3487 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_lt)>;
3488 def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETLT)),
3489 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_lt)>;
3490 def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETUGT)),
3491 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_gt)>;
3492 def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETGT)),
3493 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_gt)>;
3494 def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETEQ)),
3495 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_eq)>;
3496 def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETEQ)),
3497 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_eq)>;
3499 // For non-equality comparisons, the default code would materialize the
3500 // constant, then compare against it, like this:
3502 // ori r2, r2, 22136
3505 // Since we are just comparing for equality, we can emit this instead:
3506 // xoris r0,r3,0x1234
3507 // cmplwi cr0,r0,0x5678
3510 def : Pat<(i1 (setcc i32:$s1, imm:$imm, SETEQ)),
3511 (EXTRACT_SUBREG (CMPLWI (XORIS $s1, (HI16 imm:$imm)),
3512 (LO16 imm:$imm)), sub_eq)>;
3514 defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETUGE)),
3515 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_lt)>;
3516 defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETGE)),
3517 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_lt)>;
3518 defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETULE)),
3519 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_gt)>;
3520 defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETLE)),
3521 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_gt)>;
3522 defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETNE)),
3523 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_eq)>;
3524 defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETNE)),
3525 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_eq)>;
3527 defm : CRNotPat<(i1 (setcc i32:$s1, imm:$imm, SETNE)),
3528 (EXTRACT_SUBREG (CMPLWI (XORIS $s1, (HI16 imm:$imm)),
3529 (LO16 imm:$imm)), sub_eq)>;
3531 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETULT)),
3532 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_lt)>;
3533 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETLT)),
3534 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_lt)>;
3535 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETUGT)),
3536 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_gt)>;
3537 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETGT)),
3538 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_gt)>;
3539 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETEQ)),
3540 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_eq)>;
3542 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETUGE)),
3543 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_lt)>;
3544 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETGE)),
3545 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_lt)>;
3546 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETULE)),
3547 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_gt)>;
3548 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETLE)),
3549 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_gt)>;
3550 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETNE)),
3551 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_eq)>;
3554 def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETULT)),
3555 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_lt)>;
3556 def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETLT)),
3557 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_lt)>;
3558 def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETUGT)),
3559 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_gt)>;
3560 def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETGT)),
3561 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_gt)>;
3562 def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETEQ)),
3563 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_eq)>;
3564 def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETEQ)),
3565 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_eq)>;
3567 // For non-equality comparisons, the default code would materialize the
3568 // constant, then compare against it, like this:
3570 // ori r2, r2, 22136
3573 // Since we are just comparing for equality, we can emit this instead:
3574 // xoris r0,r3,0x1234
3575 // cmpldi cr0,r0,0x5678
3578 def : Pat<(i1 (setcc i64:$s1, imm64ZExt32:$imm, SETEQ)),
3579 (EXTRACT_SUBREG (CMPLDI (XORIS8 $s1, (HI16 imm:$imm)),
3580 (LO16 imm:$imm)), sub_eq)>;
3582 defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETUGE)),
3583 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_lt)>;
3584 defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETGE)),
3585 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_lt)>;
3586 defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETULE)),
3587 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_gt)>;
3588 defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETLE)),
3589 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_gt)>;
3590 defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETNE)),
3591 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_eq)>;
3592 defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETNE)),
3593 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_eq)>;
3595 defm : CRNotPat<(i1 (setcc i64:$s1, imm64ZExt32:$imm, SETNE)),
3596 (EXTRACT_SUBREG (CMPLDI (XORIS8 $s1, (HI16 imm:$imm)),
3597 (LO16 imm:$imm)), sub_eq)>;
3599 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETULT)),
3600 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_lt)>;
3601 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETLT)),
3602 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_lt)>;
3603 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETUGT)),
3604 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_gt)>;
3605 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETGT)),
3606 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_gt)>;
3607 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETEQ)),
3608 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_eq)>;
3610 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETUGE)),
3611 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_lt)>;
3612 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETGE)),
3613 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_lt)>;
3614 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETULE)),
3615 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_gt)>;
3616 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETLE)),
3617 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_gt)>;
3618 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETNE)),
3619 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_eq)>;
3622 let Predicates = [HasFPU] in {
3623 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOLT)),
3624 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3625 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETLT)),
3626 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3627 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOGT)),
3628 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3629 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETGT)),
3630 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3631 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOEQ)),
3632 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3633 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETEQ)),
3634 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3635 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETUO)),
3636 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_un)>;
3638 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETUGE)),
3639 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3640 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETGE)),
3641 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3642 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETULE)),
3643 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3644 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETLE)),
3645 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3646 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETUNE)),
3647 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3648 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETNE)),
3649 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3650 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETO)),
3651 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_un)>;
3654 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOLT)),
3655 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3656 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETLT)),
3657 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3658 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOGT)),
3659 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3660 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETGT)),
3661 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3662 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOEQ)),
3663 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3664 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETEQ)),
3665 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3666 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETUO)),
3667 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_un)>;
3669 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETUGE)),
3670 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3671 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETGE)),
3672 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3673 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETULE)),
3674 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3675 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETLE)),
3676 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3677 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETUNE)),
3678 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3679 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETNE)),
3680 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3681 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETO)),
3682 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_un)>;
3685 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETOLT)),
3686 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_lt)>;
3687 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETLT)),
3688 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_lt)>;
3689 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETOGT)),
3690 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_gt)>;
3691 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETGT)),
3692 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_gt)>;
3693 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETOEQ)),
3694 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_eq)>;
3695 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETEQ)),
3696 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_eq)>;
3697 def : Pat<(i1 (setcc f128:$s1, f128:$s2, SETUO)),
3698 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_un)>;
3700 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETUGE)),
3701 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_lt)>;
3702 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETGE)),
3703 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_lt)>;
3704 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETULE)),
3705 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_gt)>;
3706 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETLE)),
3707 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_gt)>;
3708 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETUNE)),
3709 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_eq)>;
3710 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETNE)),
3711 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_eq)>;
3712 defm : CRNotPat<(i1 (setcc f128:$s1, f128:$s2, SETO)),
3713 (EXTRACT_SUBREG (XSCMPUQP $s1, $s2), sub_un)>;
3717 // This must be in this file because it relies on patterns defined in this file
3718 // after the inclusion of the instruction sets.
3719 let Predicates = [HasSPE] in {
3721 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOLT)),
3722 (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>;
3723 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETLT)),
3724 (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>;
3725 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOGT)),
3726 (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>;
3727 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETGT)),
3728 (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>;
3729 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOEQ)),
3730 (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>;
3731 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETEQ)),
3732 (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>;
3734 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETUGE)),
3735 (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>;
3736 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETGE)),
3737 (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>;
3738 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETULE)),
3739 (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>;
3740 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETLE)),
3741 (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>;
3742 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETUNE)),
3743 (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>;
3744 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETNE)),
3745 (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>;
3748 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOLT)),
3749 (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>;
3750 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETLT)),
3751 (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>;
3752 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOGT)),
3753 (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>;
3754 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETGT)),
3755 (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>;
3756 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOEQ)),
3757 (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>;
3758 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETEQ)),
3759 (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>;
3761 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETUGE)),
3762 (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>;
3763 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETGE)),
3764 (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>;
3765 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETULE)),
3766 (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>;
3767 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETLE)),
3768 (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>;
3769 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETUNE)),
3770 (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>;
3771 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETNE)),
3772 (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>;
3774 // match select on i1 variables:
3775 def : Pat<(i1 (select i1:$cond, i1:$tval, i1:$fval)),
3776 (CROR (CRAND $cond , $tval),
3777 (CRAND (crnot $cond), $fval))>;
3779 // match selectcc on i1 variables:
3780 // select (lhs == rhs), tval, fval is:
3781 // ((lhs == rhs) & tval) | (!(lhs == rhs) & fval)
3782 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETLT)),
3783 (CROR (CRAND (CRANDC $lhs, $rhs), $tval),
3784 (CRAND (CRORC $rhs, $lhs), $fval))>;
3785 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETULT)),
3786 (CROR (CRAND (CRANDC $rhs, $lhs), $tval),
3787 (CRAND (CRORC $lhs, $rhs), $fval))>;
3788 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETLE)),
3789 (CROR (CRAND (CRORC $lhs, $rhs), $tval),
3790 (CRAND (CRANDC $rhs, $lhs), $fval))>;
3791 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETULE)),
3792 (CROR (CRAND (CRORC $rhs, $lhs), $tval),
3793 (CRAND (CRANDC $lhs, $rhs), $fval))>;
3794 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETEQ)),
3795 (CROR (CRAND (CREQV $lhs, $rhs), $tval),
3796 (CRAND (CRXOR $lhs, $rhs), $fval))>;
3797 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETGE)),
3798 (CROR (CRAND (CRORC $rhs, $lhs), $tval),
3799 (CRAND (CRANDC $lhs, $rhs), $fval))>;
3800 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETUGE)),
3801 (CROR (CRAND (CRORC $lhs, $rhs), $tval),
3802 (CRAND (CRANDC $rhs, $lhs), $fval))>;
3803 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETGT)),
3804 (CROR (CRAND (CRANDC $rhs, $lhs), $tval),
3805 (CRAND (CRORC $lhs, $rhs), $fval))>;
3806 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETUGT)),
3807 (CROR (CRAND (CRANDC $lhs, $rhs), $tval),
3808 (CRAND (CRORC $rhs, $lhs), $fval))>;
3809 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETNE)),
3810 (CROR (CRAND (CREQV $lhs, $rhs), $fval),
3811 (CRAND (CRXOR $lhs, $rhs), $tval))>;
3813 // match selectcc on i1 variables with non-i1 output.
3814 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETLT)),
3815 (SELECT_I4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3816 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETULT)),
3817 (SELECT_I4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3818 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETLE)),
3819 (SELECT_I4 (CRORC $lhs, $rhs), $tval, $fval)>;
3820 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETULE)),
3821 (SELECT_I4 (CRORC $rhs, $lhs), $tval, $fval)>;
3822 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETEQ)),
3823 (SELECT_I4 (CREQV $lhs, $rhs), $tval, $fval)>;
3824 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETGE)),
3825 (SELECT_I4 (CRORC $rhs, $lhs), $tval, $fval)>;
3826 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETUGE)),
3827 (SELECT_I4 (CRORC $lhs, $rhs), $tval, $fval)>;
3828 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETGT)),
3829 (SELECT_I4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3830 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETUGT)),
3831 (SELECT_I4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3832 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETNE)),
3833 (SELECT_I4 (CRXOR $lhs, $rhs), $tval, $fval)>;
3835 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETLT)),
3836 (SELECT_I8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3837 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETULT)),
3838 (SELECT_I8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3839 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETLE)),
3840 (SELECT_I8 (CRORC $lhs, $rhs), $tval, $fval)>;
3841 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETULE)),
3842 (SELECT_I8 (CRORC $rhs, $lhs), $tval, $fval)>;
3843 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETEQ)),
3844 (SELECT_I8 (CREQV $lhs, $rhs), $tval, $fval)>;
3845 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETGE)),
3846 (SELECT_I8 (CRORC $rhs, $lhs), $tval, $fval)>;
3847 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETUGE)),
3848 (SELECT_I8 (CRORC $lhs, $rhs), $tval, $fval)>;
3849 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETGT)),
3850 (SELECT_I8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3851 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETUGT)),
3852 (SELECT_I8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3853 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETNE)),
3854 (SELECT_I8 (CRXOR $lhs, $rhs), $tval, $fval)>;
3856 let Predicates = [HasFPU] in {
3857 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETLT)),
3858 (SELECT_F4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3859 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETULT)),
3860 (SELECT_F4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3861 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETLE)),
3862 (SELECT_F4 (CRORC $lhs, $rhs), $tval, $fval)>;
3863 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETULE)),
3864 (SELECT_F4 (CRORC $rhs, $lhs), $tval, $fval)>;
3865 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETEQ)),
3866 (SELECT_F4 (CREQV $lhs, $rhs), $tval, $fval)>;
3867 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETGE)),
3868 (SELECT_F4 (CRORC $rhs, $lhs), $tval, $fval)>;
3869 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETUGE)),
3870 (SELECT_F4 (CRORC $lhs, $rhs), $tval, $fval)>;
3871 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETGT)),
3872 (SELECT_F4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3873 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETUGT)),
3874 (SELECT_F4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3875 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETNE)),
3876 (SELECT_F4 (CRXOR $lhs, $rhs), $tval, $fval)>;
3878 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETLT)),
3879 (SELECT_F8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3880 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETULT)),
3881 (SELECT_F8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3882 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETLE)),
3883 (SELECT_F8 (CRORC $lhs, $rhs), $tval, $fval)>;
3884 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETULE)),
3885 (SELECT_F8 (CRORC $rhs, $lhs), $tval, $fval)>;
3886 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETEQ)),
3887 (SELECT_F8 (CREQV $lhs, $rhs), $tval, $fval)>;
3888 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETGE)),
3889 (SELECT_F8 (CRORC $rhs, $lhs), $tval, $fval)>;
3890 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETUGE)),
3891 (SELECT_F8 (CRORC $lhs, $rhs), $tval, $fval)>;
3892 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETGT)),
3893 (SELECT_F8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3894 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETUGT)),
3895 (SELECT_F8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3896 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETNE)),
3897 (SELECT_F8 (CRXOR $lhs, $rhs), $tval, $fval)>;
3900 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETLT)),
3901 (SELECT_F16 (CRANDC $lhs, $rhs), $tval, $fval)>;
3902 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETULT)),
3903 (SELECT_F16 (CRANDC $rhs, $lhs), $tval, $fval)>;
3904 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETLE)),
3905 (SELECT_F16 (CRORC $lhs, $rhs), $tval, $fval)>;
3906 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETULE)),
3907 (SELECT_F16 (CRORC $rhs, $lhs), $tval, $fval)>;
3908 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETEQ)),
3909 (SELECT_F16 (CREQV $lhs, $rhs), $tval, $fval)>;
3910 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETGE)),
3911 (SELECT_F16 (CRORC $rhs, $lhs), $tval, $fval)>;
3912 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETUGE)),
3913 (SELECT_F16 (CRORC $lhs, $rhs), $tval, $fval)>;
3914 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETGT)),
3915 (SELECT_F16 (CRANDC $rhs, $lhs), $tval, $fval)>;
3916 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETUGT)),
3917 (SELECT_F16 (CRANDC $lhs, $rhs), $tval, $fval)>;
3918 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETNE)),
3919 (SELECT_F16 (CRXOR $lhs, $rhs), $tval, $fval)>;
3921 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETLT)),
3922 (SELECT_VRRC (CRANDC $lhs, $rhs), $tval, $fval)>;
3923 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETULT)),
3924 (SELECT_VRRC (CRANDC $rhs, $lhs), $tval, $fval)>;
3925 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETLE)),
3926 (SELECT_VRRC (CRORC $lhs, $rhs), $tval, $fval)>;
3927 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETULE)),
3928 (SELECT_VRRC (CRORC $rhs, $lhs), $tval, $fval)>;
3929 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETEQ)),
3930 (SELECT_VRRC (CREQV $lhs, $rhs), $tval, $fval)>;
3931 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETGE)),
3932 (SELECT_VRRC (CRORC $rhs, $lhs), $tval, $fval)>;
3933 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETUGE)),
3934 (SELECT_VRRC (CRORC $lhs, $rhs), $tval, $fval)>;
3935 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETGT)),
3936 (SELECT_VRRC (CRANDC $rhs, $lhs), $tval, $fval)>;
3937 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETUGT)),
3938 (SELECT_VRRC (CRANDC $lhs, $rhs), $tval, $fval)>;
3939 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETNE)),
3940 (SELECT_VRRC (CRXOR $lhs, $rhs), $tval, $fval)>;
3942 def ANDIo_1_EQ_BIT : PPCCustomInserterPseudo<(outs crbitrc:$dst), (ins gprc:$in),
3944 [(set i1:$dst, (trunc (not i32:$in)))]>;
3945 def ANDIo_1_GT_BIT : PPCCustomInserterPseudo<(outs crbitrc:$dst), (ins gprc:$in),
3947 [(set i1:$dst, (trunc i32:$in))]>;
3949 def ANDIo_1_EQ_BIT8 : PPCCustomInserterPseudo<(outs crbitrc:$dst), (ins g8rc:$in),
3951 [(set i1:$dst, (trunc (not i64:$in)))]>;
3952 def ANDIo_1_GT_BIT8 : PPCCustomInserterPseudo<(outs crbitrc:$dst), (ins g8rc:$in),
3954 [(set i1:$dst, (trunc i64:$in))]>;
3956 def : Pat<(i1 (not (trunc i32:$in))),
3957 (ANDIo_1_EQ_BIT $in)>;
3958 def : Pat<(i1 (not (trunc i64:$in))),
3959 (ANDIo_1_EQ_BIT8 $in)>;
3961 //===----------------------------------------------------------------------===//
3962 // PowerPC Instructions used for assembler/disassembler only
3965 // FIXME: For B=0 or B > 8, the registers following RT are used.
3966 // WARNING: Do not add patterns for this instruction without fixing this.
3967 def LSWI : XForm_base_r3xo_memOp<31, 597, (outs gprc:$RT),
3968 (ins gprc:$A, u5imm:$B),
3969 "lswi $RT, $A, $B", IIC_LdStLoad, []>;
3971 // FIXME: For B=0 or B > 8, the registers following RT are used.
3972 // WARNING: Do not add patterns for this instruction without fixing this.
3973 def STSWI : XForm_base_r3xo_memOp<31, 725, (outs),
3974 (ins gprc:$RT, gprc:$A, u5imm:$B),
3975 "stswi $RT, $A, $B", IIC_LdStLoad, []>;
3977 def ISYNC : XLForm_2_ext<19, 150, 0, 0, 0, (outs), (ins),
3978 "isync", IIC_SprISYNC, []>;
3980 def ICBI : XForm_1a<31, 982, (outs), (ins memrr:$src),
3981 "icbi $src", IIC_LdStICBI, []>;
3983 // We used to have EIEIO as value but E[0-9A-Z] is a reserved name
3984 def EnforceIEIO : XForm_24_eieio<31, 854, (outs), (ins),
3985 "eieio", IIC_LdStLoad, []>;
3987 def WAIT : XForm_24_sync<31, 30, (outs), (ins i32imm:$L),
3988 "wait $L", IIC_LdStLoad, []>;
3990 def MBAR : XForm_mbar<31, 854, (outs), (ins u5imm:$MO),
3991 "mbar $MO", IIC_LdStLoad>, Requires<[IsBookE]>;
3993 def MTSR: XForm_sr<31, 210, (outs), (ins gprc:$RS, u4imm:$SR),
3994 "mtsr $SR, $RS", IIC_SprMTSR>;
3996 def MFSR: XForm_sr<31, 595, (outs gprc:$RS), (ins u4imm:$SR),
3997 "mfsr $RS, $SR", IIC_SprMFSR>;
3999 def MTSRIN: XForm_srin<31, 242, (outs), (ins gprc:$RS, gprc:$RB),
4000 "mtsrin $RS, $RB", IIC_SprMTSR>;
4002 def MFSRIN: XForm_srin<31, 659, (outs gprc:$RS), (ins gprc:$RB),
4003 "mfsrin $RS, $RB", IIC_SprMFSR>;
4005 def MTMSR: XForm_mtmsr<31, 146, (outs), (ins gprc:$RS, i32imm:$L),
4006 "mtmsr $RS, $L", IIC_SprMTMSR>;
4008 def WRTEE: XForm_mtmsr<31, 131, (outs), (ins gprc:$RS),
4009 "wrtee $RS", IIC_SprMTMSR>, Requires<[IsBookE]> {
4013 def WRTEEI: I<31, (outs), (ins i1imm:$E), "wrteei $E", IIC_SprMTMSR>,
4014 Requires<[IsBookE]> {
4018 let Inst{21-30} = 163;
4021 def DCCCI : XForm_tlb<454, (outs), (ins gprc:$A, gprc:$B),
4022 "dccci $A, $B", IIC_LdStLoad>, Requires<[IsPPC4xx]>;
4023 def ICCCI : XForm_tlb<966, (outs), (ins gprc:$A, gprc:$B),
4024 "iccci $A, $B", IIC_LdStLoad>, Requires<[IsPPC4xx]>;
4026 def : InstAlias<"dci 0", (DCCCI R0, R0)>, Requires<[IsPPC4xx]>;
4027 def : InstAlias<"dccci", (DCCCI R0, R0)>, Requires<[IsPPC4xx]>;
4028 def : InstAlias<"ici 0", (ICCCI R0, R0)>, Requires<[IsPPC4xx]>;
4029 def : InstAlias<"iccci", (ICCCI R0, R0)>, Requires<[IsPPC4xx]>;
4031 def MFMSR : XForm_rs<31, 83, (outs gprc:$RT), (ins),
4032 "mfmsr $RT", IIC_SprMFMSR, []>;
4034 def MTMSRD : XForm_mtmsr<31, 178, (outs), (ins gprc:$RS, i32imm:$L),
4035 "mtmsrd $RS, $L", IIC_SprMTMSRD>;
4037 def MCRFS : XLForm_3<63, 64, (outs crrc:$BF), (ins crrc:$BFA),
4038 "mcrfs $BF, $BFA", IIC_BrMCR>;
4040 def MTFSFI : XLForm_4<63, 134, (outs crrc:$BF), (ins i32imm:$U, i32imm:$W),
4041 "mtfsfi $BF, $U, $W", IIC_IntMFFS>;
4043 def MTFSFIo : XLForm_4<63, 134, (outs crrc:$BF), (ins i32imm:$U, i32imm:$W),
4044 "mtfsfi. $BF, $U, $W", IIC_IntMFFS>, isDOT;
4046 def : InstAlias<"mtfsfi $BF, $U", (MTFSFI crrc:$BF, i32imm:$U, 0)>;
4047 def : InstAlias<"mtfsfi. $BF, $U", (MTFSFIo crrc:$BF, i32imm:$U, 0)>;
4049 let Predicates = [HasFPU] in {
4050 def MTFSF : XFLForm_1<63, 711, (outs),
4051 (ins i32imm:$FLM, f8rc:$FRB, i32imm:$L, i32imm:$W),
4052 "mtfsf $FLM, $FRB, $L, $W", IIC_IntMFFS, []>;
4053 def MTFSFo : XFLForm_1<63, 711, (outs),
4054 (ins i32imm:$FLM, f8rc:$FRB, i32imm:$L, i32imm:$W),
4055 "mtfsf. $FLM, $FRB, $L, $W", IIC_IntMFFS, []>, isDOT;
4057 def : InstAlias<"mtfsf $FLM, $FRB", (MTFSF i32imm:$FLM, f8rc:$FRB, 0, 0)>;
4058 def : InstAlias<"mtfsf. $FLM, $FRB", (MTFSFo i32imm:$FLM, f8rc:$FRB, 0, 0)>;
4061 def SLBIE : XForm_16b<31, 434, (outs), (ins gprc:$RB),
4062 "slbie $RB", IIC_SprSLBIE, []>;
4064 def SLBMTE : XForm_26<31, 402, (outs), (ins gprc:$RS, gprc:$RB),
4065 "slbmte $RS, $RB", IIC_SprSLBMTE, []>;
4067 def SLBMFEE : XForm_26<31, 915, (outs gprc:$RT), (ins gprc:$RB),
4068 "slbmfee $RT, $RB", IIC_SprSLBMFEE, []>;
4070 def SLBMFEV : XLForm_1_gen<31, 851, (outs gprc:$RT), (ins gprc:$RB),
4071 "slbmfev $RT, $RB", IIC_SprSLBMFEV, []>;
4073 def SLBIA : XForm_0<31, 498, (outs), (ins), "slbia", IIC_SprSLBIA, []>;
4075 def TLBIA : XForm_0<31, 370, (outs), (ins),
4076 "tlbia", IIC_SprTLBIA, []>;
4078 def TLBSYNC : XForm_0<31, 566, (outs), (ins),
4079 "tlbsync", IIC_SprTLBSYNC, []>;
4081 def TLBIEL : XForm_16b<31, 274, (outs), (ins gprc:$RB),
4082 "tlbiel $RB", IIC_SprTLBIEL, []>;
4084 def TLBLD : XForm_16b<31, 978, (outs), (ins gprc:$RB),
4085 "tlbld $RB", IIC_LdStLoad, []>, Requires<[IsPPC6xx]>;
4086 def TLBLI : XForm_16b<31, 1010, (outs), (ins gprc:$RB),
4087 "tlbli $RB", IIC_LdStLoad, []>, Requires<[IsPPC6xx]>;
4089 def TLBIE : XForm_26<31, 306, (outs), (ins gprc:$RS, gprc:$RB),
4090 "tlbie $RB,$RS", IIC_SprTLBIE, []>;
4092 def TLBSX : XForm_tlb<914, (outs), (ins gprc:$A, gprc:$B), "tlbsx $A, $B",
4093 IIC_LdStLoad>, Requires<[IsBookE]>;
4095 def TLBIVAX : XForm_tlb<786, (outs), (ins gprc:$A, gprc:$B), "tlbivax $A, $B",
4096 IIC_LdStLoad>, Requires<[IsBookE]>;
4098 def TLBRE : XForm_24_eieio<31, 946, (outs), (ins),
4099 "tlbre", IIC_LdStLoad, []>, Requires<[IsBookE]>;
4101 def TLBWE : XForm_24_eieio<31, 978, (outs), (ins),
4102 "tlbwe", IIC_LdStLoad, []>, Requires<[IsBookE]>;
4104 def TLBRE2 : XForm_tlbws<31, 946, (outs gprc:$RS), (ins gprc:$A, i1imm:$WS),
4105 "tlbre $RS, $A, $WS", IIC_LdStLoad, []>, Requires<[IsPPC4xx]>;
4107 def TLBWE2 : XForm_tlbws<31, 978, (outs), (ins gprc:$RS, gprc:$A, i1imm:$WS),
4108 "tlbwe $RS, $A, $WS", IIC_LdStLoad, []>, Requires<[IsPPC4xx]>;
4110 def TLBSX2 : XForm_base_r3xo<31, 914, (outs), (ins gprc:$RST, gprc:$A, gprc:$B),
4111 "tlbsx $RST, $A, $B", IIC_LdStLoad, []>,
4112 Requires<[IsPPC4xx]>;
4113 def TLBSX2D : XForm_base_r3xo<31, 914, (outs),
4114 (ins gprc:$RST, gprc:$A, gprc:$B),
4115 "tlbsx. $RST, $A, $B", IIC_LdStLoad, []>,
4116 Requires<[IsPPC4xx]>, isDOT;
4118 def RFID : XForm_0<19, 18, (outs), (ins), "rfid", IIC_IntRFID, []>;
4120 def RFI : XForm_0<19, 50, (outs), (ins), "rfi", IIC_SprRFI, []>,
4121 Requires<[IsBookE]>;
4122 def RFCI : XForm_0<19, 51, (outs), (ins), "rfci", IIC_BrB, []>,
4123 Requires<[IsBookE]>;
4125 def RFDI : XForm_0<19, 39, (outs), (ins), "rfdi", IIC_BrB, []>,
4127 def RFMCI : XForm_0<19, 38, (outs), (ins), "rfmci", IIC_BrB, []>,
4130 def MFDCR : XFXForm_1<31, 323, (outs gprc:$RT), (ins i32imm:$SPR),
4131 "mfdcr $RT, $SPR", IIC_SprMFSPR>, Requires<[IsPPC4xx]>;
4132 def MTDCR : XFXForm_1<31, 451, (outs), (ins gprc:$RT, i32imm:$SPR),
4133 "mtdcr $SPR, $RT", IIC_SprMTSPR>, Requires<[IsPPC4xx]>;
4135 def HRFID : XLForm_1_np<19, 274, (outs), (ins), "hrfid", IIC_BrB, []>;
4136 def NAP : XLForm_1_np<19, 434, (outs), (ins), "nap", IIC_BrB, []>;
4138 def ATTN : XForm_attn<0, 256, (outs), (ins), "attn", IIC_BrB>;
4140 def LBZCIX : XForm_base_r3xo_memOp<31, 853, (outs gprc:$RST),
4141 (ins gprc:$A, gprc:$B),
4142 "lbzcix $RST, $A, $B", IIC_LdStLoad, []>;
4143 def LHZCIX : XForm_base_r3xo_memOp<31, 821, (outs gprc:$RST),
4144 (ins gprc:$A, gprc:$B),
4145 "lhzcix $RST, $A, $B", IIC_LdStLoad, []>;
4146 def LWZCIX : XForm_base_r3xo_memOp<31, 789, (outs gprc:$RST),
4147 (ins gprc:$A, gprc:$B),
4148 "lwzcix $RST, $A, $B", IIC_LdStLoad, []>;
4149 def LDCIX : XForm_base_r3xo_memOp<31, 885, (outs gprc:$RST),
4150 (ins gprc:$A, gprc:$B),
4151 "ldcix $RST, $A, $B", IIC_LdStLoad, []>;
4153 def STBCIX : XForm_base_r3xo_memOp<31, 981, (outs),
4154 (ins gprc:$RST, gprc:$A, gprc:$B),
4155 "stbcix $RST, $A, $B", IIC_LdStLoad, []>;
4156 def STHCIX : XForm_base_r3xo_memOp<31, 949, (outs),
4157 (ins gprc:$RST, gprc:$A, gprc:$B),
4158 "sthcix $RST, $A, $B", IIC_LdStLoad, []>;
4159 def STWCIX : XForm_base_r3xo_memOp<31, 917, (outs),
4160 (ins gprc:$RST, gprc:$A, gprc:$B),
4161 "stwcix $RST, $A, $B", IIC_LdStLoad, []>;
4162 def STDCIX : XForm_base_r3xo_memOp<31, 1013, (outs),
4163 (ins gprc:$RST, gprc:$A, gprc:$B),
4164 "stdcix $RST, $A, $B", IIC_LdStLoad, []>;
4166 // External PID Load Store Instructions
4168 def LBEPX : XForm_1<31, 95, (outs gprc:$rD), (ins memrr:$src),
4169 "lbepx $rD, $src", IIC_LdStLoad, []>,
4172 def LFDEPX : XForm_25<31, 607, (outs f8rc:$frD), (ins memrr:$src),
4173 "lfdepx $frD, $src", IIC_LdStLFD, []>,
4176 def LHEPX : XForm_1<31, 287, (outs gprc:$rD), (ins memrr:$src),
4177 "lhepx $rD, $src", IIC_LdStLoad, []>,
4180 def LWEPX : XForm_1<31, 31, (outs gprc:$rD), (ins memrr:$src),
4181 "lwepx $rD, $src", IIC_LdStLoad, []>,
4184 def STBEPX : XForm_8<31, 223, (outs), (ins gprc:$rS, memrr:$dst),
4185 "stbepx $rS, $dst", IIC_LdStStore, []>,
4188 def STFDEPX : XForm_28_memOp<31, 735, (outs), (ins f8rc:$frS, memrr:$dst),
4189 "stfdepx $frS, $dst", IIC_LdStSTFD, []>,
4192 def STHEPX : XForm_8<31, 415, (outs), (ins gprc:$rS, memrr:$dst),
4193 "sthepx $rS, $dst", IIC_LdStStore, []>,
4196 def STWEPX : XForm_8<31, 159, (outs), (ins gprc:$rS, memrr:$dst),
4197 "stwepx $rS, $dst", IIC_LdStStore, []>,
4200 def DCBFEP : DCB_Form<127, 0, (outs), (ins memrr:$dst), "dcbfep $dst",
4201 IIC_LdStDCBF, []>, Requires<[IsE500]>;
4203 def DCBSTEP : DCB_Form<63, 0, (outs), (ins memrr:$dst), "dcbstep $dst",
4204 IIC_LdStDCBF, []>, Requires<[IsE500]>;
4206 def DCBTEP : DCB_Form_hint<319, (outs), (ins memrr:$dst, u5imm:$TH),
4207 "dcbtep $TH, $dst", IIC_LdStDCBF, []>,
4210 def DCBTSTEP : DCB_Form_hint<255, (outs), (ins memrr:$dst, u5imm:$TH),
4211 "dcbtstep $TH, $dst", IIC_LdStDCBF, []>,
4214 def DCBZEP : DCB_Form<1023, 0, (outs), (ins memrr:$dst), "dcbzep $dst",
4215 IIC_LdStDCBF, []>, Requires<[IsE500]>;
4217 def DCBZLEP : DCB_Form<1023, 1, (outs), (ins memrr:$dst), "dcbzlep $dst",
4218 IIC_LdStDCBF, []>, Requires<[IsE500]>;
4220 def ICBIEP : XForm_1a<31, 991, (outs), (ins memrr:$src), "icbiep $src",
4221 IIC_LdStICBI, []>, Requires<[IsE500]>;
4223 //===----------------------------------------------------------------------===//
4224 // PowerPC Assembler Instruction Aliases
4227 // Pseudo-instructions for alternate assembly syntax (never used by codegen).
4228 // These are aliases that require C++ handling to convert to the target
4229 // instruction, while InstAliases can be handled directly by tblgen.
4230 class PPCAsmPseudo<string asm, dag iops>
4232 let Namespace = "PPC";
4233 bit PPC64 = 0; // Default value, override with isPPC64
4235 let OutOperandList = (outs);
4236 let InOperandList = iops;
4238 let AsmString = asm;
4239 let isAsmParserOnly = 1;
4241 let hasNoSchedulingInfo = 1;
4244 def : InstAlias<"sc", (SC 0)>;
4246 def : InstAlias<"sync", (SYNC 0)>, Requires<[HasSYNC]>;
4247 def : InstAlias<"msync", (SYNC 0), 0>, Requires<[HasSYNC]>;
4248 def : InstAlias<"lwsync", (SYNC 1)>, Requires<[HasSYNC]>;
4249 def : InstAlias<"ptesync", (SYNC 2)>, Requires<[HasSYNC]>;
4251 def : InstAlias<"wait", (WAIT 0)>;
4252 def : InstAlias<"waitrsv", (WAIT 1)>;
4253 def : InstAlias<"waitimpl", (WAIT 2)>;
4255 def : InstAlias<"mbar", (MBAR 0)>, Requires<[IsBookE]>;
4257 def DCBTx : PPCAsmPseudo<"dcbt $dst", (ins memrr:$dst)>;
4258 def DCBTSTx : PPCAsmPseudo<"dcbtst $dst", (ins memrr:$dst)>;
4260 def DCBTCT : PPCAsmPseudo<"dcbtct $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
4261 def DCBTDS : PPCAsmPseudo<"dcbtds $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
4262 def DCBTT : PPCAsmPseudo<"dcbtt $dst", (ins memrr:$dst)>;
4264 def DCBTSTCT : PPCAsmPseudo<"dcbtstct $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
4265 def DCBTSTDS : PPCAsmPseudo<"dcbtstds $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
4266 def DCBTSTT : PPCAsmPseudo<"dcbtstt $dst", (ins memrr:$dst)>;
4268 def DCBFx : PPCAsmPseudo<"dcbf $dst", (ins memrr:$dst)>;
4269 def DCBFL : PPCAsmPseudo<"dcbfl $dst", (ins memrr:$dst)>;
4270 def DCBFLP : PPCAsmPseudo<"dcbflp $dst", (ins memrr:$dst)>;
4272 def : InstAlias<"crset $bx", (CREQV crbitrc:$bx, crbitrc:$bx, crbitrc:$bx)>;
4273 def : InstAlias<"crclr $bx", (CRXOR crbitrc:$bx, crbitrc:$bx, crbitrc:$bx)>;
4274 def : InstAlias<"crmove $bx, $by", (CROR crbitrc:$bx, crbitrc:$by, crbitrc:$by)>;
4275 def : InstAlias<"crnot $bx, $by", (CRNOR crbitrc:$bx, crbitrc:$by, crbitrc:$by)>;
4277 def : InstAlias<"mtxer $Rx", (MTSPR 1, gprc:$Rx)>;
4278 def : InstAlias<"mfxer $Rx", (MFSPR gprc:$Rx, 1)>;
4280 def : InstAlias<"mfrtcu $Rx", (MFSPR gprc:$Rx, 4)>;
4281 def : InstAlias<"mfrtcl $Rx", (MFSPR gprc:$Rx, 5)>;
4283 def : InstAlias<"mtdscr $Rx", (MTSPR 17, gprc:$Rx)>;
4284 def : InstAlias<"mfdscr $Rx", (MFSPR gprc:$Rx, 17)>;
4286 def : InstAlias<"mtdsisr $Rx", (MTSPR 18, gprc:$Rx)>;
4287 def : InstAlias<"mfdsisr $Rx", (MFSPR gprc:$Rx, 18)>;
4289 def : InstAlias<"mtdar $Rx", (MTSPR 19, gprc:$Rx)>;
4290 def : InstAlias<"mfdar $Rx", (MFSPR gprc:$Rx, 19)>;
4292 def : InstAlias<"mtdec $Rx", (MTSPR 22, gprc:$Rx)>;
4293 def : InstAlias<"mfdec $Rx", (MFSPR gprc:$Rx, 22)>;
4295 def : InstAlias<"mtsdr1 $Rx", (MTSPR 25, gprc:$Rx)>;
4296 def : InstAlias<"mfsdr1 $Rx", (MFSPR gprc:$Rx, 25)>;
4298 def : InstAlias<"mtsrr0 $Rx", (MTSPR 26, gprc:$Rx)>;
4299 def : InstAlias<"mfsrr0 $Rx", (MFSPR gprc:$Rx, 26)>;
4301 def : InstAlias<"mtsrr1 $Rx", (MTSPR 27, gprc:$Rx)>;
4302 def : InstAlias<"mfsrr1 $Rx", (MFSPR gprc:$Rx, 27)>;
4304 def : InstAlias<"mtsrr2 $Rx", (MTSPR 990, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4305 def : InstAlias<"mfsrr2 $Rx", (MFSPR gprc:$Rx, 990)>, Requires<[IsPPC4xx]>;
4307 def : InstAlias<"mtsrr3 $Rx", (MTSPR 991, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4308 def : InstAlias<"mfsrr3 $Rx", (MFSPR gprc:$Rx, 991)>, Requires<[IsPPC4xx]>;
4310 def : InstAlias<"mtcfar $Rx", (MTSPR 28, gprc:$Rx)>;
4311 def : InstAlias<"mfcfar $Rx", (MFSPR gprc:$Rx, 28)>;
4313 def : InstAlias<"mtamr $Rx", (MTSPR 29, gprc:$Rx)>;
4314 def : InstAlias<"mfamr $Rx", (MFSPR gprc:$Rx, 29)>;
4316 def : InstAlias<"mtpid $Rx", (MTSPR 48, gprc:$Rx)>, Requires<[IsBookE]>;
4317 def : InstAlias<"mfpid $Rx", (MFSPR gprc:$Rx, 48)>, Requires<[IsBookE]>;
4319 def : InstAlias<"mftb $Rx", (MFTB gprc:$Rx, 268)>;
4320 def : InstAlias<"mftbl $Rx", (MFTB gprc:$Rx, 268)>;
4321 def : InstAlias<"mftbu $Rx", (MFTB gprc:$Rx, 269)>;
4323 def : InstAlias<"mttbl $Rx", (MTSPR 284, gprc:$Rx)>;
4324 def : InstAlias<"mttbu $Rx", (MTSPR 285, gprc:$Rx)>;
4326 def : InstAlias<"mftblo $Rx", (MFSPR gprc:$Rx, 989)>, Requires<[IsPPC4xx]>;
4327 def : InstAlias<"mttblo $Rx", (MTSPR 989, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4328 def : InstAlias<"mftbhi $Rx", (MFSPR gprc:$Rx, 988)>, Requires<[IsPPC4xx]>;
4329 def : InstAlias<"mttbhi $Rx", (MTSPR 988, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4331 def : InstAlias<"xnop", (XORI R0, R0, 0)>;
4333 def : InstAlias<"mr $rA, $rB", (OR8 g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
4334 def : InstAlias<"mr. $rA, $rB", (OR8o g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
4336 def : InstAlias<"not $rA, $rB", (NOR8 g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
4337 def : InstAlias<"not. $rA, $rB", (NOR8o g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
4339 def : InstAlias<"mtcr $rA", (MTCRF8 255, g8rc:$rA)>;
4341 foreach BATR = 0-3 in {
4342 def : InstAlias<"mtdbatu "#BATR#", $Rx",
4343 (MTSPR !add(BATR, !add(BATR, 536)), gprc:$Rx)>,
4344 Requires<[IsPPC6xx]>;
4345 def : InstAlias<"mfdbatu $Rx, "#BATR,
4346 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 536)))>,
4347 Requires<[IsPPC6xx]>;
4348 def : InstAlias<"mtdbatl "#BATR#", $Rx",
4349 (MTSPR !add(BATR, !add(BATR, 537)), gprc:$Rx)>,
4350 Requires<[IsPPC6xx]>;
4351 def : InstAlias<"mfdbatl $Rx, "#BATR,
4352 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 537)))>,
4353 Requires<[IsPPC6xx]>;
4354 def : InstAlias<"mtibatu "#BATR#", $Rx",
4355 (MTSPR !add(BATR, !add(BATR, 528)), gprc:$Rx)>,
4356 Requires<[IsPPC6xx]>;
4357 def : InstAlias<"mfibatu $Rx, "#BATR,
4358 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 528)))>,
4359 Requires<[IsPPC6xx]>;
4360 def : InstAlias<"mtibatl "#BATR#", $Rx",
4361 (MTSPR !add(BATR, !add(BATR, 529)), gprc:$Rx)>,
4362 Requires<[IsPPC6xx]>;
4363 def : InstAlias<"mfibatl $Rx, "#BATR,
4364 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 529)))>,
4365 Requires<[IsPPC6xx]>;
4368 foreach BR = 0-7 in {
4369 def : InstAlias<"mfbr"#BR#" $Rx",
4370 (MFDCR gprc:$Rx, !add(BR, 0x80))>,
4371 Requires<[IsPPC4xx]>;
4372 def : InstAlias<"mtbr"#BR#" $Rx",
4373 (MTDCR gprc:$Rx, !add(BR, 0x80))>,
4374 Requires<[IsPPC4xx]>;
4377 def : InstAlias<"mtdccr $Rx", (MTSPR 1018, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4378 def : InstAlias<"mfdccr $Rx", (MFSPR gprc:$Rx, 1018)>, Requires<[IsPPC4xx]>;
4380 def : InstAlias<"mticcr $Rx", (MTSPR 1019, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4381 def : InstAlias<"mficcr $Rx", (MFSPR gprc:$Rx, 1019)>, Requires<[IsPPC4xx]>;
4383 def : InstAlias<"mtdear $Rx", (MTSPR 981, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4384 def : InstAlias<"mfdear $Rx", (MFSPR gprc:$Rx, 981)>, Requires<[IsPPC4xx]>;
4386 def : InstAlias<"mtesr $Rx", (MTSPR 980, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4387 def : InstAlias<"mfesr $Rx", (MFSPR gprc:$Rx, 980)>, Requires<[IsPPC4xx]>;
4389 def : InstAlias<"mfspefscr $Rx", (MFSPR gprc:$Rx, 512)>;
4390 def : InstAlias<"mtspefscr $Rx", (MTSPR 512, gprc:$Rx)>;
4392 def : InstAlias<"mttcr $Rx", (MTSPR 986, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4393 def : InstAlias<"mftcr $Rx", (MFSPR gprc:$Rx, 986)>, Requires<[IsPPC4xx]>;
4395 def LAx : PPCAsmPseudo<"la $rA, $addr", (ins gprc:$rA, memri:$addr)>;
4397 def SUBI : PPCAsmPseudo<"subi $rA, $rB, $imm",
4398 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4399 def SUBIS : PPCAsmPseudo<"subis $rA, $rB, $imm",
4400 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4401 def SUBIC : PPCAsmPseudo<"subic $rA, $rB, $imm",
4402 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4403 def SUBICo : PPCAsmPseudo<"subic. $rA, $rB, $imm",
4404 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4406 def : InstAlias<"sub $rA, $rB, $rC", (SUBF8 g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
4407 def : InstAlias<"sub. $rA, $rB, $rC", (SUBF8o g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
4408 def : InstAlias<"subc $rA, $rB, $rC", (SUBFC8 g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
4409 def : InstAlias<"subc. $rA, $rB, $rC", (SUBFC8o g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
4411 def : InstAlias<"mtmsrd $RS", (MTMSRD gprc:$RS, 0)>;
4412 def : InstAlias<"mtmsr $RS", (MTMSR gprc:$RS, 0)>;
4414 def : InstAlias<"mfasr $RT", (MFSPR gprc:$RT, 280)>;
4415 def : InstAlias<"mtasr $RT", (MTSPR 280, gprc:$RT)>;
4417 foreach SPRG = 0-3 in {
4418 def : InstAlias<"mfsprg $RT, "#SPRG, (MFSPR gprc:$RT, !add(SPRG, 272))>;
4419 def : InstAlias<"mfsprg"#SPRG#" $RT", (MFSPR gprc:$RT, !add(SPRG, 272))>;
4420 def : InstAlias<"mtsprg "#SPRG#", $RT", (MTSPR !add(SPRG, 272), gprc:$RT)>;
4421 def : InstAlias<"mtsprg"#SPRG#" $RT", (MTSPR !add(SPRG, 272), gprc:$RT)>;
4423 foreach SPRG = 4-7 in {
4424 def : InstAlias<"mfsprg $RT, "#SPRG, (MFSPR gprc:$RT, !add(SPRG, 256))>,
4425 Requires<[IsBookE]>;
4426 def : InstAlias<"mfsprg"#SPRG#" $RT", (MFSPR gprc:$RT, !add(SPRG, 256))>,
4427 Requires<[IsBookE]>;
4428 def : InstAlias<"mtsprg "#SPRG#", $RT", (MTSPR !add(SPRG, 256), gprc:$RT)>,
4429 Requires<[IsBookE]>;
4430 def : InstAlias<"mtsprg"#SPRG#" $RT", (MTSPR !add(SPRG, 256), gprc:$RT)>,
4431 Requires<[IsBookE]>;
4434 def : InstAlias<"mtasr $RS", (MTSPR 280, gprc:$RS)>;
4436 def : InstAlias<"mfdec $RT", (MFSPR gprc:$RT, 22)>;
4437 def : InstAlias<"mtdec $RT", (MTSPR 22, gprc:$RT)>;
4439 def : InstAlias<"mfpvr $RT", (MFSPR gprc:$RT, 287)>;
4441 def : InstAlias<"mfsdr1 $RT", (MFSPR gprc:$RT, 25)>;
4442 def : InstAlias<"mtsdr1 $RT", (MTSPR 25, gprc:$RT)>;
4444 def : InstAlias<"mfsrr0 $RT", (MFSPR gprc:$RT, 26)>;
4445 def : InstAlias<"mfsrr1 $RT", (MFSPR gprc:$RT, 27)>;
4446 def : InstAlias<"mtsrr0 $RT", (MTSPR 26, gprc:$RT)>;
4447 def : InstAlias<"mtsrr1 $RT", (MTSPR 27, gprc:$RT)>;
4449 def : InstAlias<"tlbie $RB", (TLBIE R0, gprc:$RB)>;
4451 def : InstAlias<"tlbrehi $RS, $A", (TLBRE2 gprc:$RS, gprc:$A, 0)>,
4452 Requires<[IsPPC4xx]>;
4453 def : InstAlias<"tlbrelo $RS, $A", (TLBRE2 gprc:$RS, gprc:$A, 1)>,
4454 Requires<[IsPPC4xx]>;
4455 def : InstAlias<"tlbwehi $RS, $A", (TLBWE2 gprc:$RS, gprc:$A, 0)>,
4456 Requires<[IsPPC4xx]>;
4457 def : InstAlias<"tlbwelo $RS, $A", (TLBWE2 gprc:$RS, gprc:$A, 1)>,
4458 Requires<[IsPPC4xx]>;
4460 def EXTLWI : PPCAsmPseudo<"extlwi $rA, $rS, $n, $b",
4461 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4462 def EXTLWIo : PPCAsmPseudo<"extlwi. $rA, $rS, $n, $b",
4463 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4464 def EXTRWI : PPCAsmPseudo<"extrwi $rA, $rS, $n, $b",
4465 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4466 def EXTRWIo : PPCAsmPseudo<"extrwi. $rA, $rS, $n, $b",
4467 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4468 def INSLWI : PPCAsmPseudo<"inslwi $rA, $rS, $n, $b",
4469 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4470 def INSLWIo : PPCAsmPseudo<"inslwi. $rA, $rS, $n, $b",
4471 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4472 def INSRWI : PPCAsmPseudo<"insrwi $rA, $rS, $n, $b",
4473 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4474 def INSRWIo : PPCAsmPseudo<"insrwi. $rA, $rS, $n, $b",
4475 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4476 def ROTRWI : PPCAsmPseudo<"rotrwi $rA, $rS, $n",
4477 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4478 def ROTRWIo : PPCAsmPseudo<"rotrwi. $rA, $rS, $n",
4479 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4480 def SLWI : PPCAsmPseudo<"slwi $rA, $rS, $n",
4481 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4482 def SLWIo : PPCAsmPseudo<"slwi. $rA, $rS, $n",
4483 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4484 def SRWI : PPCAsmPseudo<"srwi $rA, $rS, $n",
4485 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4486 def SRWIo : PPCAsmPseudo<"srwi. $rA, $rS, $n",
4487 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4488 def CLRRWI : PPCAsmPseudo<"clrrwi $rA, $rS, $n",
4489 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4490 def CLRRWIo : PPCAsmPseudo<"clrrwi. $rA, $rS, $n",
4491 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4492 def CLRLSLWI : PPCAsmPseudo<"clrlslwi $rA, $rS, $b, $n",
4493 (ins gprc:$rA, gprc:$rS, u5imm:$b, u5imm:$n)>;
4494 def CLRLSLWIo : PPCAsmPseudo<"clrlslwi. $rA, $rS, $b, $n",
4495 (ins gprc:$rA, gprc:$rS, u5imm:$b, u5imm:$n)>;
4497 def : InstAlias<"rotlwi $rA, $rS, $n", (RLWINM gprc:$rA, gprc:$rS, u5imm:$n, 0, 31)>;
4498 def : InstAlias<"rotlwi. $rA, $rS, $n", (RLWINMo gprc:$rA, gprc:$rS, u5imm:$n, 0, 31)>;
4499 def : InstAlias<"rotlw $rA, $rS, $rB", (RLWNM gprc:$rA, gprc:$rS, gprc:$rB, 0, 31)>;
4500 def : InstAlias<"rotlw. $rA, $rS, $rB", (RLWNMo gprc:$rA, gprc:$rS, gprc:$rB, 0, 31)>;
4501 def : InstAlias<"clrlwi $rA, $rS, $n", (RLWINM gprc:$rA, gprc:$rS, 0, u5imm:$n, 31)>;
4502 def : InstAlias<"clrlwi. $rA, $rS, $n", (RLWINMo gprc:$rA, gprc:$rS, 0, u5imm:$n, 31)>;
4504 def : InstAlias<"cntlzw $rA, $rS", (CNTLZW gprc:$rA, gprc:$rS)>;
4505 def : InstAlias<"cntlzw. $rA, $rS", (CNTLZWo gprc:$rA, gprc:$rS)>;
4506 // The POWER variant
4507 def : MnemonicAlias<"cntlz", "cntlzw">;
4508 def : MnemonicAlias<"cntlz.", "cntlzw.">;
4510 def EXTLDI : PPCAsmPseudo<"extldi $rA, $rS, $n, $b",
4511 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4512 def EXTLDIo : PPCAsmPseudo<"extldi. $rA, $rS, $n, $b",
4513 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4514 def EXTRDI : PPCAsmPseudo<"extrdi $rA, $rS, $n, $b",
4515 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4516 def EXTRDIo : PPCAsmPseudo<"extrdi. $rA, $rS, $n, $b",
4517 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4518 def INSRDI : PPCAsmPseudo<"insrdi $rA, $rS, $n, $b",
4519 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4520 def INSRDIo : PPCAsmPseudo<"insrdi. $rA, $rS, $n, $b",
4521 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4522 def ROTRDI : PPCAsmPseudo<"rotrdi $rA, $rS, $n",
4523 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4524 def ROTRDIo : PPCAsmPseudo<"rotrdi. $rA, $rS, $n",
4525 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4526 def SLDI : PPCAsmPseudo<"sldi $rA, $rS, $n",
4527 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4528 def SLDIo : PPCAsmPseudo<"sldi. $rA, $rS, $n",
4529 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4530 def SRDI : PPCAsmPseudo<"srdi $rA, $rS, $n",
4531 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4532 def SRDIo : PPCAsmPseudo<"srdi. $rA, $rS, $n",
4533 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4534 def CLRRDI : PPCAsmPseudo<"clrrdi $rA, $rS, $n",
4535 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4536 def CLRRDIo : PPCAsmPseudo<"clrrdi. $rA, $rS, $n",
4537 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4538 def CLRLSLDI : PPCAsmPseudo<"clrlsldi $rA, $rS, $b, $n",
4539 (ins g8rc:$rA, g8rc:$rS, u6imm:$b, u6imm:$n)>;
4540 def CLRLSLDIo : PPCAsmPseudo<"clrlsldi. $rA, $rS, $b, $n",
4541 (ins g8rc:$rA, g8rc:$rS, u6imm:$b, u6imm:$n)>;
4542 def SUBPCIS : PPCAsmPseudo<"subpcis $RT, $D", (ins g8rc:$RT, s16imm:$D)>;
4544 def : InstAlias<"rotldi $rA, $rS, $n", (RLDICL g8rc:$rA, g8rc:$rS, u6imm:$n, 0)>;
4545 def : InstAlias<"rotldi. $rA, $rS, $n", (RLDICLo g8rc:$rA, g8rc:$rS, u6imm:$n, 0)>;
4546 def : InstAlias<"rotld $rA, $rS, $rB", (RLDCL g8rc:$rA, g8rc:$rS, gprc:$rB, 0)>;
4547 def : InstAlias<"rotld. $rA, $rS, $rB", (RLDCLo g8rc:$rA, g8rc:$rS, gprc:$rB, 0)>;
4548 def : InstAlias<"clrldi $rA, $rS, $n", (RLDICL g8rc:$rA, g8rc:$rS, 0, u6imm:$n)>;
4549 def : InstAlias<"clrldi $rA, $rS, $n",
4550 (RLDICL_32_64 g8rc:$rA, gprc:$rS, 0, u6imm:$n)>;
4551 def : InstAlias<"clrldi. $rA, $rS, $n", (RLDICLo g8rc:$rA, g8rc:$rS, 0, u6imm:$n)>;
4552 def : InstAlias<"lnia $RT", (ADDPCIS g8rc:$RT, 0)>;
4554 def RLWINMbm : PPCAsmPseudo<"rlwinm $rA, $rS, $n, $b",
4555 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4556 def RLWINMobm : PPCAsmPseudo<"rlwinm. $rA, $rS, $n, $b",
4557 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4558 def RLWIMIbm : PPCAsmPseudo<"rlwimi $rA, $rS, $n, $b",
4559 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4560 def RLWIMIobm : PPCAsmPseudo<"rlwimi. $rA, $rS, $n, $b",
4561 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4562 def RLWNMbm : PPCAsmPseudo<"rlwnm $rA, $rS, $n, $b",
4563 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4564 def RLWNMobm : PPCAsmPseudo<"rlwnm. $rA, $rS, $n, $b",
4565 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4567 // These generic branch instruction forms are used for the assembler parser only.
4568 // Defs and Uses are conservative, since we don't know the BO value.
4569 let PPC970_Unit = 7, isBranch = 1 in {
4570 let Defs = [CTR], Uses = [CTR, RM] in {
4571 def gBC : BForm_3<16, 0, 0, (outs),
4572 (ins u5imm:$bo, crbitrc:$bi, condbrtarget:$dst),
4573 "bc $bo, $bi, $dst">;
4574 def gBCA : BForm_3<16, 1, 0, (outs),
4575 (ins u5imm:$bo, crbitrc:$bi, abscondbrtarget:$dst),
4576 "bca $bo, $bi, $dst">;
4577 let isAsmParserOnly = 1 in {
4578 def gBCat : BForm_3_at<16, 0, 0, (outs),
4579 (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
4581 "bc$at $bo, $bi, $dst">;
4582 def gBCAat : BForm_3_at<16, 1, 0, (outs),
4583 (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
4584 abscondbrtarget:$dst),
4585 "bca$at $bo, $bi, $dst">;
4586 } // isAsmParserOnly = 1
4588 let Defs = [LR, CTR], Uses = [CTR, RM] in {
4589 def gBCL : BForm_3<16, 0, 1, (outs),
4590 (ins u5imm:$bo, crbitrc:$bi, condbrtarget:$dst),
4591 "bcl $bo, $bi, $dst">;
4592 def gBCLA : BForm_3<16, 1, 1, (outs),
4593 (ins u5imm:$bo, crbitrc:$bi, abscondbrtarget:$dst),
4594 "bcla $bo, $bi, $dst">;
4595 let isAsmParserOnly = 1 in {
4596 def gBCLat : BForm_3_at<16, 0, 1, (outs),
4597 (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
4599 "bcl$at $bo, $bi, $dst">;
4600 def gBCLAat : BForm_3_at<16, 1, 1, (outs),
4601 (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
4602 abscondbrtarget:$dst),
4603 "bcla$at $bo, $bi, $dst">;
4604 } // // isAsmParserOnly = 1
4606 let Defs = [CTR], Uses = [CTR, LR, RM] in
4607 def gBCLR : XLForm_2<19, 16, 0, (outs),
4608 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
4609 "bclr $bo, $bi, $bh", IIC_BrB, []>;
4610 let Defs = [LR, CTR], Uses = [CTR, LR, RM] in
4611 def gBCLRL : XLForm_2<19, 16, 1, (outs),
4612 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
4613 "bclrl $bo, $bi, $bh", IIC_BrB, []>;
4614 let Defs = [CTR], Uses = [CTR, LR, RM] in
4615 def gBCCTR : XLForm_2<19, 528, 0, (outs),
4616 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
4617 "bcctr $bo, $bi, $bh", IIC_BrB, []>;
4618 let Defs = [LR, CTR], Uses = [CTR, LR, RM] in
4619 def gBCCTRL : XLForm_2<19, 528, 1, (outs),
4620 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
4621 "bcctrl $bo, $bi, $bh", IIC_BrB, []>;
4624 multiclass BranchSimpleMnemonicAT<string pm, int at> {
4625 def : InstAlias<"bc"#pm#" $bo, $bi, $dst", (gBCat u5imm:$bo, at, crbitrc:$bi,
4626 condbrtarget:$dst)>;
4627 def : InstAlias<"bca"#pm#" $bo, $bi, $dst", (gBCAat u5imm:$bo, at, crbitrc:$bi,
4628 condbrtarget:$dst)>;
4629 def : InstAlias<"bcl"#pm#" $bo, $bi, $dst", (gBCLat u5imm:$bo, at, crbitrc:$bi,
4630 condbrtarget:$dst)>;
4631 def : InstAlias<"bcla"#pm#" $bo, $bi, $dst", (gBCLAat u5imm:$bo, at, crbitrc:$bi,
4632 condbrtarget:$dst)>;
4634 defm : BranchSimpleMnemonicAT<"+", 3>;
4635 defm : BranchSimpleMnemonicAT<"-", 2>;
4637 def : InstAlias<"bclr $bo, $bi", (gBCLR u5imm:$bo, crbitrc:$bi, 0)>;
4638 def : InstAlias<"bclrl $bo, $bi", (gBCLRL u5imm:$bo, crbitrc:$bi, 0)>;
4639 def : InstAlias<"bcctr $bo, $bi", (gBCCTR u5imm:$bo, crbitrc:$bi, 0)>;
4640 def : InstAlias<"bcctrl $bo, $bi", (gBCCTRL u5imm:$bo, crbitrc:$bi, 0)>;
4642 multiclass BranchSimpleMnemonic1<string name, string pm, int bo> {
4643 def : InstAlias<"b"#name#pm#" $bi, $dst", (gBC bo, crbitrc:$bi, condbrtarget:$dst)>;
4644 def : InstAlias<"b"#name#"a"#pm#" $bi, $dst", (gBCA bo, crbitrc:$bi, abscondbrtarget:$dst)>;
4645 def : InstAlias<"b"#name#"lr"#pm#" $bi", (gBCLR bo, crbitrc:$bi, 0)>;
4646 def : InstAlias<"b"#name#"l"#pm#" $bi, $dst", (gBCL bo, crbitrc:$bi, condbrtarget:$dst)>;
4647 def : InstAlias<"b"#name#"la"#pm#" $bi, $dst", (gBCLA bo, crbitrc:$bi, abscondbrtarget:$dst)>;
4648 def : InstAlias<"b"#name#"lrl"#pm#" $bi", (gBCLRL bo, crbitrc:$bi, 0)>;
4650 multiclass BranchSimpleMnemonic2<string name, string pm, int bo>
4651 : BranchSimpleMnemonic1<name, pm, bo> {
4652 def : InstAlias<"b"#name#"ctr"#pm#" $bi", (gBCCTR bo, crbitrc:$bi, 0)>;
4653 def : InstAlias<"b"#name#"ctrl"#pm#" $bi", (gBCCTRL bo, crbitrc:$bi, 0)>;
4655 defm : BranchSimpleMnemonic2<"t", "", 12>;
4656 defm : BranchSimpleMnemonic2<"f", "", 4>;
4657 defm : BranchSimpleMnemonic2<"t", "-", 14>;
4658 defm : BranchSimpleMnemonic2<"f", "-", 6>;
4659 defm : BranchSimpleMnemonic2<"t", "+", 15>;
4660 defm : BranchSimpleMnemonic2<"f", "+", 7>;
4661 defm : BranchSimpleMnemonic1<"dnzt", "", 8>;
4662 defm : BranchSimpleMnemonic1<"dnzf", "", 0>;
4663 defm : BranchSimpleMnemonic1<"dzt", "", 10>;
4664 defm : BranchSimpleMnemonic1<"dzf", "", 2>;
4666 multiclass BranchExtendedMnemonicPM<string name, string pm, int bibo> {
4667 def : InstAlias<"b"#name#pm#" $cc, $dst",
4668 (BCC bibo, crrc:$cc, condbrtarget:$dst)>;
4669 def : InstAlias<"b"#name#pm#" $dst",
4670 (BCC bibo, CR0, condbrtarget:$dst)>;
4672 def : InstAlias<"b"#name#"a"#pm#" $cc, $dst",
4673 (BCCA bibo, crrc:$cc, abscondbrtarget:$dst)>;
4674 def : InstAlias<"b"#name#"a"#pm#" $dst",
4675 (BCCA bibo, CR0, abscondbrtarget:$dst)>;
4677 def : InstAlias<"b"#name#"lr"#pm#" $cc",
4678 (BCCLR bibo, crrc:$cc)>;
4679 def : InstAlias<"b"#name#"lr"#pm,
4682 def : InstAlias<"b"#name#"ctr"#pm#" $cc",
4683 (BCCCTR bibo, crrc:$cc)>;
4684 def : InstAlias<"b"#name#"ctr"#pm,
4685 (BCCCTR bibo, CR0)>;
4687 def : InstAlias<"b"#name#"l"#pm#" $cc, $dst",
4688 (BCCL bibo, crrc:$cc, condbrtarget:$dst)>;
4689 def : InstAlias<"b"#name#"l"#pm#" $dst",
4690 (BCCL bibo, CR0, condbrtarget:$dst)>;
4692 def : InstAlias<"b"#name#"la"#pm#" $cc, $dst",
4693 (BCCLA bibo, crrc:$cc, abscondbrtarget:$dst)>;
4694 def : InstAlias<"b"#name#"la"#pm#" $dst",
4695 (BCCLA bibo, CR0, abscondbrtarget:$dst)>;
4697 def : InstAlias<"b"#name#"lrl"#pm#" $cc",
4698 (BCCLRL bibo, crrc:$cc)>;
4699 def : InstAlias<"b"#name#"lrl"#pm,
4700 (BCCLRL bibo, CR0)>;
4702 def : InstAlias<"b"#name#"ctrl"#pm#" $cc",
4703 (BCCCTRL bibo, crrc:$cc)>;
4704 def : InstAlias<"b"#name#"ctrl"#pm,
4705 (BCCCTRL bibo, CR0)>;
4707 multiclass BranchExtendedMnemonic<string name, int bibo> {
4708 defm : BranchExtendedMnemonicPM<name, "", bibo>;
4709 defm : BranchExtendedMnemonicPM<name, "-", !add(bibo, 2)>;
4710 defm : BranchExtendedMnemonicPM<name, "+", !add(bibo, 3)>;
4712 defm : BranchExtendedMnemonic<"lt", 12>;
4713 defm : BranchExtendedMnemonic<"gt", 44>;
4714 defm : BranchExtendedMnemonic<"eq", 76>;
4715 defm : BranchExtendedMnemonic<"un", 108>;
4716 defm : BranchExtendedMnemonic<"so", 108>;
4717 defm : BranchExtendedMnemonic<"ge", 4>;
4718 defm : BranchExtendedMnemonic<"nl", 4>;
4719 defm : BranchExtendedMnemonic<"le", 36>;
4720 defm : BranchExtendedMnemonic<"ng", 36>;
4721 defm : BranchExtendedMnemonic<"ne", 68>;
4722 defm : BranchExtendedMnemonic<"nu", 100>;
4723 defm : BranchExtendedMnemonic<"ns", 100>;
4725 def : InstAlias<"cmpwi $rA, $imm", (CMPWI CR0, gprc:$rA, s16imm:$imm)>;
4726 def : InstAlias<"cmpw $rA, $rB", (CMPW CR0, gprc:$rA, gprc:$rB)>;
4727 def : InstAlias<"cmplwi $rA, $imm", (CMPLWI CR0, gprc:$rA, u16imm:$imm)>;
4728 def : InstAlias<"cmplw $rA, $rB", (CMPLW CR0, gprc:$rA, gprc:$rB)>;
4729 def : InstAlias<"cmpdi $rA, $imm", (CMPDI CR0, g8rc:$rA, s16imm64:$imm)>;
4730 def : InstAlias<"cmpd $rA, $rB", (CMPD CR0, g8rc:$rA, g8rc:$rB)>;
4731 def : InstAlias<"cmpldi $rA, $imm", (CMPLDI CR0, g8rc:$rA, u16imm64:$imm)>;
4732 def : InstAlias<"cmpld $rA, $rB", (CMPLD CR0, g8rc:$rA, g8rc:$rB)>;
4734 def : InstAlias<"cmpi $bf, 0, $rA, $imm", (CMPWI crrc:$bf, gprc:$rA, s16imm:$imm)>;
4735 def : InstAlias<"cmp $bf, 0, $rA, $rB", (CMPW crrc:$bf, gprc:$rA, gprc:$rB)>;
4736 def : InstAlias<"cmpli $bf, 0, $rA, $imm", (CMPLWI crrc:$bf, gprc:$rA, u16imm:$imm)>;
4737 def : InstAlias<"cmpl $bf, 0, $rA, $rB", (CMPLW crrc:$bf, gprc:$rA, gprc:$rB)>;
4738 def : InstAlias<"cmpi $bf, 1, $rA, $imm", (CMPDI crrc:$bf, g8rc:$rA, s16imm64:$imm)>;
4739 def : InstAlias<"cmp $bf, 1, $rA, $rB", (CMPD crrc:$bf, g8rc:$rA, g8rc:$rB)>;
4740 def : InstAlias<"cmpli $bf, 1, $rA, $imm", (CMPLDI crrc:$bf, g8rc:$rA, u16imm64:$imm)>;
4741 def : InstAlias<"cmpl $bf, 1, $rA, $rB", (CMPLD crrc:$bf, g8rc:$rA, g8rc:$rB)>;
4743 multiclass TrapExtendedMnemonic<string name, int to> {
4744 def : InstAlias<"td"#name#"i $rA, $imm", (TDI to, g8rc:$rA, s16imm:$imm)>;
4745 def : InstAlias<"td"#name#" $rA, $rB", (TD to, g8rc:$rA, g8rc:$rB)>;
4746 def : InstAlias<"tw"#name#"i $rA, $imm", (TWI to, gprc:$rA, s16imm:$imm)>;
4747 def : InstAlias<"tw"#name#" $rA, $rB", (TW to, gprc:$rA, gprc:$rB)>;
4749 defm : TrapExtendedMnemonic<"lt", 16>;
4750 defm : TrapExtendedMnemonic<"le", 20>;
4751 defm : TrapExtendedMnemonic<"eq", 4>;
4752 defm : TrapExtendedMnemonic<"ge", 12>;
4753 defm : TrapExtendedMnemonic<"gt", 8>;
4754 defm : TrapExtendedMnemonic<"nl", 12>;
4755 defm : TrapExtendedMnemonic<"ne", 24>;
4756 defm : TrapExtendedMnemonic<"ng", 20>;
4757 defm : TrapExtendedMnemonic<"llt", 2>;
4758 defm : TrapExtendedMnemonic<"lle", 6>;
4759 defm : TrapExtendedMnemonic<"lge", 5>;
4760 defm : TrapExtendedMnemonic<"lgt", 1>;
4761 defm : TrapExtendedMnemonic<"lnl", 5>;
4762 defm : TrapExtendedMnemonic<"lng", 6>;
4763 defm : TrapExtendedMnemonic<"u", 31>;
4766 def : Pat<(atomic_load_8 iaddr:$src), (LBZ memri:$src)>;
4767 def : Pat<(atomic_load_16 iaddr:$src), (LHZ memri:$src)>;
4768 def : Pat<(atomic_load_32 iaddr:$src), (LWZ memri:$src)>;
4769 def : Pat<(atomic_load_8 xaddr:$src), (LBZX memrr:$src)>;
4770 def : Pat<(atomic_load_16 xaddr:$src), (LHZX memrr:$src)>;
4771 def : Pat<(atomic_load_32 xaddr:$src), (LWZX memrr:$src)>;
4774 def : Pat<(atomic_store_8 iaddr:$ptr, i32:$val), (STB gprc:$val, memri:$ptr)>;
4775 def : Pat<(atomic_store_16 iaddr:$ptr, i32:$val), (STH gprc:$val, memri:$ptr)>;
4776 def : Pat<(atomic_store_32 iaddr:$ptr, i32:$val), (STW gprc:$val, memri:$ptr)>;
4777 def : Pat<(atomic_store_8 xaddr:$ptr, i32:$val), (STBX gprc:$val, memrr:$ptr)>;
4778 def : Pat<(atomic_store_16 xaddr:$ptr, i32:$val), (STHX gprc:$val, memrr:$ptr)>;
4779 def : Pat<(atomic_store_32 xaddr:$ptr, i32:$val), (STWX gprc:$val, memrr:$ptr)>;
4781 let Predicates = [IsISA3_0] in {
4783 // Copy-Paste Facility
4784 // We prefix 'CP' to COPY due to name conflict in Target.td. We also prefix to
4785 // PASTE for naming consistency.
4787 def CP_COPY : X_L1_RA5_RB5<31, 774, "copy" , gprc, IIC_LdStCOPY, []>;
4790 def CP_PASTE : X_L1_RA5_RB5<31, 902, "paste" , gprc, IIC_LdStPASTE, []>;
4792 let mayStore = 1, Defs = [CR0] in
4793 def CP_PASTEo : X_L1_RA5_RB5<31, 902, "paste.", gprc, IIC_LdStPASTE, []>, isDOT;
4795 def CP_COPYx : PPCAsmPseudo<"copy $rA, $rB" , (ins gprc:$rA, gprc:$rB)>;
4796 def CP_PASTEx : PPCAsmPseudo<"paste $rA, $rB", (ins gprc:$rA, gprc:$rB)>;
4797 def CP_COPY_FIRST : PPCAsmPseudo<"copy_first $rA, $rB",
4798 (ins gprc:$rA, gprc:$rB)>;
4799 def CP_PASTE_LAST : PPCAsmPseudo<"paste_last $rA, $rB",
4800 (ins gprc:$rA, gprc:$rB)>;
4801 def CP_ABORT : XForm_0<31, 838, (outs), (ins), "cp_abort", IIC_SprABORT, []>;
4803 // Message Synchronize
4804 def MSGSYNC : XForm_0<31, 886, (outs), (ins), "msgsync", IIC_SprMSGSYNC, []>;
4806 // Power-Saving Mode Instruction:
4807 def STOP : XForm_0<19, 370, (outs), (ins), "stop", IIC_SprSTOP, []>;
4811 // Fast 32-bit reverse bits algorithm:
4812 // Step 1: 1-bit swap (swap odd 1-bit and even 1-bit):
4813 // n = ((n >> 1) & 0x55555555) | ((n << 1) & 0xAAAAAAAA);
4814 // Step 2: 2-bit swap (swap odd 2-bit and even 2-bit):
4815 // n = ((n >> 2) & 0x33333333) | ((n << 2) & 0xCCCCCCCC);
4816 // Step 3: 4-bit swap (swap odd 4-bit and even 4-bit):
4817 // n = ((n >> 4) & 0x0F0F0F0F) | ((n << 4) & 0xF0F0F0F0);
4818 // Step 4: byte reverse (Suppose n = [B1,B2,B3,B4]):
4819 // Step 4.1: Put B4,B2 in the right position (rotate left 3 bytes):
4820 // n' = (n rotl 24); After which n' = [B4, B1, B2, B3]
4821 // Step 4.2: Insert B3 to the right position:
4822 // n' = rlwimi n', n, 8, 8, 15; After which n' = [B4, B3, B2, B3]
4823 // Step 4.3: Insert B1 to the right position:
4824 // n' = rlwimi n', n, 8, 24, 31; After which n' = [B4, B3, B2, B1]
4826 dag Lo1 = (ORI (LIS 0x5555), 0x5555);
4827 dag Hi1 = (ORI (LIS 0xAAAA), 0xAAAA);
4828 dag Lo2 = (ORI (LIS 0x3333), 0x3333);
4829 dag Hi2 = (ORI (LIS 0xCCCC), 0xCCCC);
4830 dag Lo4 = (ORI (LIS 0x0F0F), 0x0F0F);
4831 dag Hi4 = (ORI (LIS 0xF0F0), 0xF0F0);
4835 dag Right = (RLWINM $A, 31, 1, 31);
4836 dag Left = (RLWINM $A, 1, 0, 30);
4840 dag Bit = (OR (AND Shift1.Right, MaskValues.Lo1),
4841 (AND Shift1.Left, MaskValues.Hi1));
4845 dag Right = (RLWINM Swap1.Bit, 30, 2, 31);
4846 dag Left = (RLWINM Swap1.Bit, 2, 0, 29);
4850 dag Bits = (OR (AND Shift2.Right, MaskValues.Lo2),
4851 (AND Shift2.Left, MaskValues.Hi2));
4855 dag Right = (RLWINM Swap2.Bits, 28, 4, 31);
4856 dag Left = (RLWINM Swap2.Bits, 4, 0, 27);
4860 dag Bits = (OR (AND Shift4.Right, MaskValues.Lo4),
4861 (AND Shift4.Left, MaskValues.Hi4));
4865 dag Left3Bytes = (RLWINM Swap4.Bits, 24, 0, 31);
4868 def RotateInsertByte3 {
4869 dag Left = (RLWIMI Rotate.Left3Bytes, Swap4.Bits, 8, 8, 15);
4872 def RotateInsertByte1 {
4873 dag Left = (RLWIMI RotateInsertByte3.Left, Swap4.Bits, 8, 24, 31);
4876 def : Pat<(i32 (bitreverse i32:$A)),
4877 (RLDICL_32 RotateInsertByte1.Left, 0, 32)>;
4879 // Fast 64-bit reverse bits algorithm:
4880 // Step 1: 1-bit swap (swap odd 1-bit and even 1-bit):
4881 // n = ((n >> 1) & 0x5555555555555555) | ((n << 1) & 0xAAAAAAAAAAAAAAAA);
4882 // Step 2: 2-bit swap (swap odd 2-bit and even 2-bit):
4883 // n = ((n >> 2) & 0x3333333333333333) | ((n << 2) & 0xCCCCCCCCCCCCCCCC);
4884 // Step 3: 4-bit swap (swap odd 4-bit and even 4-bit):
4885 // n = ((n >> 4) & 0x0F0F0F0F0F0F0F0F) | ((n << 4) & 0xF0F0F0F0F0F0F0F0);
4886 // Step 4: byte reverse (Suppose n = [B0,B1,B2,B3,B4,B5,B6,B7]):
4887 // Apply the same byte reverse algorithm mentioned above for the fast 32-bit
4888 // reverse to both the high 32 bit and low 32 bit of the 64 bit value. And
4889 // then OR them together to get the final result.
4891 dag Lo1 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Lo1, sub_32));
4892 dag Hi1 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Hi1, sub_32));
4893 dag Lo2 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Lo2, sub_32));
4894 dag Hi2 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Hi2, sub_32));
4895 dag Lo4 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Lo4, sub_32));
4896 dag Hi4 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Hi4, sub_32));
4900 dag Lo1 = (ORI8 (ORIS8 (RLDICR MaskValues64.Lo1, 32, 31), 0x5555), 0x5555);
4901 dag Hi1 = (ORI8 (ORIS8 (RLDICR MaskValues64.Hi1, 32, 31), 0xAAAA), 0xAAAA);
4902 dag Lo2 = (ORI8 (ORIS8 (RLDICR MaskValues64.Lo2, 32, 31), 0x3333), 0x3333);
4903 dag Hi2 = (ORI8 (ORIS8 (RLDICR MaskValues64.Hi2, 32, 31), 0xCCCC), 0xCCCC);
4904 dag Lo4 = (ORI8 (ORIS8 (RLDICR MaskValues64.Lo4, 32, 31), 0x0F0F), 0x0F0F);
4905 dag Hi4 = (ORI8 (ORIS8 (RLDICR MaskValues64.Hi4, 32, 31), 0xF0F0), 0xF0F0);
4909 dag Swap1 = (OR8 (AND8 (RLDICL $A, 63, 1), DWMaskValues.Lo1),
4910 (AND8 (RLDICR $A, 1, 62), DWMaskValues.Hi1));
4911 dag Swap2 = (OR8 (AND8 (RLDICL Swap1, 62, 2), DWMaskValues.Lo2),
4912 (AND8 (RLDICR Swap1, 2, 61), DWMaskValues.Hi2));
4913 dag Swap4 = (OR8 (AND8 (RLDICL Swap2, 60, 4), DWMaskValues.Lo4),
4914 (AND8 (RLDICR Swap2, 4, 59), DWMaskValues.Hi4));
4917 // Intra-byte swap is done, now start inter-byte swap.
4919 dag Word = (i32 (EXTRACT_SUBREG DWSwapInByte.Swap4, sub_32));
4923 dag Word = (RLWINM DWBytes4567.Word, 24, 0, 31);
4927 dag Word = (RLWIMI DWBytes7456.Word, DWBytes4567.Word, 8, 8, 15);
4930 // B7 B6 B5 B4 in the right order
4932 dag Word = (RLWIMI DWBytes7656.Word, DWBytes4567.Word, 8, 24, 31);
4934 (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), Word, sub_32));
4938 dag Word = (i32 (EXTRACT_SUBREG (RLDICL DWSwapInByte.Swap4, 32, 32), sub_32));
4942 dag Word = (RLWINM DWBytes0123.Word, 24, 0, 31);
4946 dag Word = (RLWIMI DWBytes3012.Word, DWBytes0123.Word, 8, 8, 15);
4949 // B3 B2 B1 B0 in the right order
4951 dag Word = (RLWIMI DWBytes3212.Word, DWBytes0123.Word, 8, 24, 31);
4953 (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), Word, sub_32));
4956 // Now both high word and low word are reversed, next
4957 // swap the high word and low word.
4958 def : Pat<(i64 (bitreverse i64:$A)),
4959 (OR8 (RLDICR DWBytes7654.DWord, 32, 31), DWBytes3210.DWord)>;