1 //===-- PPCInstrInfo.td - The PowerPC Instruction Set ------*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the subset of the 32-bit PowerPC instruction set, as used
11 // by the PowerPC instruction selector.
13 //===----------------------------------------------------------------------===//
15 include "PPCInstrFormats.td"
17 //===----------------------------------------------------------------------===//
18 // PowerPC specific type constraints.
20 def SDT_PPCstfiwx : SDTypeProfile<0, 2, [ // stfiwx
21 SDTCisVT<0, f64>, SDTCisPtrTy<1>
23 def SDT_PPClfiwx : SDTypeProfile<1, 1, [ // lfiw[az]x
24 SDTCisVT<0, f64>, SDTCisPtrTy<1>
26 def SDT_PPCLxsizx : SDTypeProfile<1, 2, [
27 SDTCisVT<0, f64>, SDTCisPtrTy<1>, SDTCisPtrTy<2>
29 def SDT_PPCstxsix : SDTypeProfile<0, 3, [
30 SDTCisVT<0, f64>, SDTCisPtrTy<1>, SDTCisPtrTy<2>
32 def SDT_PPCVexts : SDTypeProfile<1, 2, [
33 SDTCisVT<0, f64>, SDTCisVT<1, f64>, SDTCisPtrTy<2>
35 def SDT_PPCSExtVElems : SDTypeProfile<1, 1, [
36 SDTCisVec<0>, SDTCisVec<1>
39 def SDT_PPCCallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32>,
41 def SDT_PPCCallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
43 def SDT_PPCvperm : SDTypeProfile<1, 3, [
44 SDTCisVT<3, v16i8>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>
47 def SDT_PPCVecSplat : SDTypeProfile<1, 2, [ SDTCisVec<0>,
48 SDTCisVec<1>, SDTCisInt<2>
51 def SDT_PPCVecShift : SDTypeProfile<1, 3, [ SDTCisVec<0>,
52 SDTCisVec<1>, SDTCisVec<2>, SDTCisPtrTy<3>
55 def SDT_PPCVecInsert : SDTypeProfile<1, 3, [ SDTCisVec<0>,
56 SDTCisVec<1>, SDTCisVec<2>, SDTCisInt<3>
59 def SDT_PPCVecReverse: SDTypeProfile<1, 1, [ SDTCisVec<0>,
63 def SDT_PPCxxpermdi: SDTypeProfile<1, 3, [ SDTCisVec<0>,
64 SDTCisVec<1>, SDTCisVec<2>, SDTCisInt<3>
67 def SDT_PPCvcmp : SDTypeProfile<1, 3, [
68 SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisVT<3, i32>
71 def SDT_PPCcondbr : SDTypeProfile<0, 3, [
72 SDTCisVT<0, i32>, SDTCisVT<2, OtherVT>
75 def SDT_PPClbrx : SDTypeProfile<1, 2, [
76 SDTCisInt<0>, SDTCisPtrTy<1>, SDTCisVT<2, OtherVT>
78 def SDT_PPCstbrx : SDTypeProfile<0, 3, [
79 SDTCisInt<0>, SDTCisPtrTy<1>, SDTCisVT<2, OtherVT>
82 def SDT_PPCTC_ret : SDTypeProfile<0, 2, [
83 SDTCisPtrTy<0>, SDTCisVT<1, i32>
86 def tocentry32 : Operand<iPTR> {
87 let MIOperandInfo = (ops i32imm:$imm);
90 def SDT_PPCqvfperm : SDTypeProfile<1, 3, [
91 SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisVec<3>
93 def SDT_PPCqvgpci : SDTypeProfile<1, 1, [
94 SDTCisVec<0>, SDTCisInt<1>
96 def SDT_PPCqvaligni : SDTypeProfile<1, 3, [
97 SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisInt<3>
99 def SDT_PPCqvesplati : SDTypeProfile<1, 2, [
100 SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisInt<2>
103 def SDT_PPCqbflt : SDTypeProfile<1, 1, [
104 SDTCisVec<0>, SDTCisVec<1>
107 def SDT_PPCqvlfsb : SDTypeProfile<1, 1, [
108 SDTCisVec<0>, SDTCisPtrTy<1>
111 //===----------------------------------------------------------------------===//
112 // PowerPC specific DAG Nodes.
115 def PPCfre : SDNode<"PPCISD::FRE", SDTFPUnaryOp, []>;
116 def PPCfrsqrte: SDNode<"PPCISD::FRSQRTE", SDTFPUnaryOp, []>;
118 def PPCfcfid : SDNode<"PPCISD::FCFID", SDTFPUnaryOp, []>;
119 def PPCfcfidu : SDNode<"PPCISD::FCFIDU", SDTFPUnaryOp, []>;
120 def PPCfcfids : SDNode<"PPCISD::FCFIDS", SDTFPRoundOp, []>;
121 def PPCfcfidus: SDNode<"PPCISD::FCFIDUS", SDTFPRoundOp, []>;
122 def PPCfctidz : SDNode<"PPCISD::FCTIDZ", SDTFPUnaryOp, []>;
123 def PPCfctiwz : SDNode<"PPCISD::FCTIWZ", SDTFPUnaryOp, []>;
124 def PPCfctiduz: SDNode<"PPCISD::FCTIDUZ",SDTFPUnaryOp, []>;
125 def PPCfctiwuz: SDNode<"PPCISD::FCTIWUZ",SDTFPUnaryOp, []>;
126 def PPCstfiwx : SDNode<"PPCISD::STFIWX", SDT_PPCstfiwx,
127 [SDNPHasChain, SDNPMayStore]>;
128 def PPClfiwax : SDNode<"PPCISD::LFIWAX", SDT_PPClfiwx,
129 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
130 def PPClfiwzx : SDNode<"PPCISD::LFIWZX", SDT_PPClfiwx,
131 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
132 def PPClxsizx : SDNode<"PPCISD::LXSIZX", SDT_PPCLxsizx,
133 [SDNPHasChain, SDNPMayLoad]>;
134 def PPCstxsix : SDNode<"PPCISD::STXSIX", SDT_PPCstxsix,
135 [SDNPHasChain, SDNPMayStore]>;
136 def PPCVexts : SDNode<"PPCISD::VEXTS", SDT_PPCVexts, []>;
137 def PPCSExtVElems : SDNode<"PPCISD::SExtVElems", SDT_PPCSExtVElems, []>;
139 // Extract FPSCR (not modeled at the DAG level).
140 def PPCmffs : SDNode<"PPCISD::MFFS",
141 SDTypeProfile<1, 0, [SDTCisVT<0, f64>]>, []>;
143 // Perform FADD in round-to-zero mode.
144 def PPCfaddrtz: SDNode<"PPCISD::FADDRTZ", SDTFPBinOp, []>;
147 def PPCfsel : SDNode<"PPCISD::FSEL",
148 // Type constraint for fsel.
149 SDTypeProfile<1, 3, [SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>,
150 SDTCisFP<0>, SDTCisVT<1, f64>]>, []>;
152 def PPChi : SDNode<"PPCISD::Hi", SDTIntBinOp, []>;
153 def PPClo : SDNode<"PPCISD::Lo", SDTIntBinOp, []>;
154 def PPCtoc_entry: SDNode<"PPCISD::TOC_ENTRY", SDTIntBinOp,
155 [SDNPMayLoad, SDNPMemOperand]>;
156 def PPCvmaddfp : SDNode<"PPCISD::VMADDFP", SDTFPTernaryOp, []>;
157 def PPCvnmsubfp : SDNode<"PPCISD::VNMSUBFP", SDTFPTernaryOp, []>;
159 def PPCppc32GOT : SDNode<"PPCISD::PPC32_GOT", SDTIntLeaf, []>;
161 def PPCaddisGotTprelHA : SDNode<"PPCISD::ADDIS_GOT_TPREL_HA", SDTIntBinOp>;
162 def PPCldGotTprelL : SDNode<"PPCISD::LD_GOT_TPREL_L", SDTIntBinOp,
164 def PPCaddTls : SDNode<"PPCISD::ADD_TLS", SDTIntBinOp, []>;
165 def PPCaddisTlsgdHA : SDNode<"PPCISD::ADDIS_TLSGD_HA", SDTIntBinOp>;
166 def PPCaddiTlsgdL : SDNode<"PPCISD::ADDI_TLSGD_L", SDTIntBinOp>;
167 def PPCgetTlsAddr : SDNode<"PPCISD::GET_TLS_ADDR", SDTIntBinOp>;
168 def PPCaddiTlsgdLAddr : SDNode<"PPCISD::ADDI_TLSGD_L_ADDR",
169 SDTypeProfile<1, 3, [
170 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
171 SDTCisSameAs<0, 3>, SDTCisInt<0> ]>>;
172 def PPCaddisTlsldHA : SDNode<"PPCISD::ADDIS_TLSLD_HA", SDTIntBinOp>;
173 def PPCaddiTlsldL : SDNode<"PPCISD::ADDI_TLSLD_L", SDTIntBinOp>;
174 def PPCgetTlsldAddr : SDNode<"PPCISD::GET_TLSLD_ADDR", SDTIntBinOp>;
175 def PPCaddiTlsldLAddr : SDNode<"PPCISD::ADDI_TLSLD_L_ADDR",
176 SDTypeProfile<1, 3, [
177 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
178 SDTCisSameAs<0, 3>, SDTCisInt<0> ]>>;
179 def PPCaddisDtprelHA : SDNode<"PPCISD::ADDIS_DTPREL_HA", SDTIntBinOp>;
180 def PPCaddiDtprelL : SDNode<"PPCISD::ADDI_DTPREL_L", SDTIntBinOp>;
182 def PPCvperm : SDNode<"PPCISD::VPERM", SDT_PPCvperm, []>;
183 def PPCxxsplt : SDNode<"PPCISD::XXSPLT", SDT_PPCVecSplat, []>;
184 def PPCvecinsert : SDNode<"PPCISD::VECINSERT", SDT_PPCVecInsert, []>;
185 def PPCxxreverse : SDNode<"PPCISD::XXREVERSE", SDT_PPCVecReverse, []>;
186 def PPCxxpermdi : SDNode<"PPCISD::XXPERMDI", SDT_PPCxxpermdi, []>;
187 def PPCvecshl : SDNode<"PPCISD::VECSHL", SDT_PPCVecShift, []>;
189 def PPCqvfperm : SDNode<"PPCISD::QVFPERM", SDT_PPCqvfperm, []>;
190 def PPCqvgpci : SDNode<"PPCISD::QVGPCI", SDT_PPCqvgpci, []>;
191 def PPCqvaligni : SDNode<"PPCISD::QVALIGNI", SDT_PPCqvaligni, []>;
192 def PPCqvesplati : SDNode<"PPCISD::QVESPLATI", SDT_PPCqvesplati, []>;
194 def PPCqbflt : SDNode<"PPCISD::QBFLT", SDT_PPCqbflt, []>;
196 def PPCqvlfsb : SDNode<"PPCISD::QVLFSb", SDT_PPCqvlfsb,
197 [SDNPHasChain, SDNPMayLoad]>;
199 def PPCcmpb : SDNode<"PPCISD::CMPB", SDTIntBinOp, []>;
201 // These nodes represent the 32-bit PPC shifts that operate on 6-bit shift
202 // amounts. These nodes are generated by the multi-precision shift code.
203 def PPCsrl : SDNode<"PPCISD::SRL" , SDTIntShiftOp>;
204 def PPCsra : SDNode<"PPCISD::SRA" , SDTIntShiftOp>;
205 def PPCshl : SDNode<"PPCISD::SHL" , SDTIntShiftOp>;
207 // These are target-independent nodes, but have target-specific formats.
208 def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_PPCCallSeqStart,
209 [SDNPHasChain, SDNPOutGlue]>;
210 def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_PPCCallSeqEnd,
211 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
213 def SDT_PPCCall : SDTypeProfile<0, -1, [SDTCisInt<0>]>;
214 def PPCcall : SDNode<"PPCISD::CALL", SDT_PPCCall,
215 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
217 def PPCcall_nop : SDNode<"PPCISD::CALL_NOP", SDT_PPCCall,
218 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
220 def PPCmtctr : SDNode<"PPCISD::MTCTR", SDT_PPCCall,
221 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
222 def PPCbctrl : SDNode<"PPCISD::BCTRL", SDTNone,
223 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
225 def PPCbctrl_load_toc : SDNode<"PPCISD::BCTRL_LOAD_TOC",
226 SDTypeProfile<0, 1, []>,
227 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
230 def retflag : SDNode<"PPCISD::RET_FLAG", SDTNone,
231 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
233 def PPCtc_return : SDNode<"PPCISD::TC_RETURN", SDT_PPCTC_ret,
234 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
236 def PPCeh_sjlj_setjmp : SDNode<"PPCISD::EH_SJLJ_SETJMP",
237 SDTypeProfile<1, 1, [SDTCisInt<0>,
239 [SDNPHasChain, SDNPSideEffect]>;
240 def PPCeh_sjlj_longjmp : SDNode<"PPCISD::EH_SJLJ_LONGJMP",
241 SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>,
242 [SDNPHasChain, SDNPSideEffect]>;
244 def SDT_PPCsc : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
245 def PPCsc : SDNode<"PPCISD::SC", SDT_PPCsc,
246 [SDNPHasChain, SDNPSideEffect]>;
248 def PPCclrbhrb : SDNode<"PPCISD::CLRBHRB", SDTNone,
249 [SDNPHasChain, SDNPSideEffect]>;
250 def PPCmfbhrbe : SDNode<"PPCISD::MFBHRBE", SDTIntBinOp, [SDNPHasChain]>;
251 def PPCrfebb : SDNode<"PPCISD::RFEBB", SDT_PPCsc,
252 [SDNPHasChain, SDNPSideEffect]>;
254 def PPCvcmp : SDNode<"PPCISD::VCMP" , SDT_PPCvcmp, []>;
255 def PPCvcmp_o : SDNode<"PPCISD::VCMPo", SDT_PPCvcmp, [SDNPOutGlue]>;
257 def PPCcondbranch : SDNode<"PPCISD::COND_BRANCH", SDT_PPCcondbr,
258 [SDNPHasChain, SDNPOptInGlue]>;
260 def PPClbrx : SDNode<"PPCISD::LBRX", SDT_PPClbrx,
261 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
262 def PPCstbrx : SDNode<"PPCISD::STBRX", SDT_PPCstbrx,
263 [SDNPHasChain, SDNPMayStore]>;
265 // Instructions to set/unset CR bit 6 for SVR4 vararg calls
266 def PPCcr6set : SDNode<"PPCISD::CR6SET", SDTNone,
267 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
268 def PPCcr6unset : SDNode<"PPCISD::CR6UNSET", SDTNone,
269 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
271 // Instructions to support dynamic alloca.
272 def SDTDynOp : SDTypeProfile<1, 2, []>;
273 def SDTDynAreaOp : SDTypeProfile<1, 1, []>;
274 def PPCdynalloc : SDNode<"PPCISD::DYNALLOC", SDTDynOp, [SDNPHasChain]>;
275 def PPCdynareaoffset : SDNode<"PPCISD::DYNAREAOFFSET", SDTDynAreaOp, [SDNPHasChain]>;
277 //===----------------------------------------------------------------------===//
278 // PowerPC specific transformation functions and pattern fragments.
281 def SHL32 : SDNodeXForm<imm, [{
282 // Transformation function: 31 - imm
283 return getI32Imm(31 - N->getZExtValue(), SDLoc(N));
286 def SRL32 : SDNodeXForm<imm, [{
287 // Transformation function: 32 - imm
288 return N->getZExtValue() ? getI32Imm(32 - N->getZExtValue(), SDLoc(N))
289 : getI32Imm(0, SDLoc(N));
292 def LO16 : SDNodeXForm<imm, [{
293 // Transformation function: get the low 16 bits.
294 return getI32Imm((unsigned short)N->getZExtValue(), SDLoc(N));
297 def HI16 : SDNodeXForm<imm, [{
298 // Transformation function: shift the immediate value down into the low bits.
299 return getI32Imm((unsigned)N->getZExtValue() >> 16, SDLoc(N));
302 def HA16 : SDNodeXForm<imm, [{
303 // Transformation function: shift the immediate value down into the low bits.
304 int Val = N->getZExtValue();
305 return getI32Imm((Val - (signed short)Val) >> 16, SDLoc(N));
307 def MB : SDNodeXForm<imm, [{
308 // Transformation function: get the start bit of a mask
310 (void)isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
311 return getI32Imm(mb, SDLoc(N));
314 def ME : SDNodeXForm<imm, [{
315 // Transformation function: get the end bit of a mask
317 (void)isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
318 return getI32Imm(me, SDLoc(N));
320 def maskimm32 : PatLeaf<(imm), [{
321 // maskImm predicate - True if immediate is a run of ones.
323 if (N->getValueType(0) == MVT::i32)
324 return isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
329 def imm32SExt16 : Operand<i32>, ImmLeaf<i32, [{
330 // imm32SExt16 predicate - True if the i32 immediate fits in a 16-bit
331 // sign extended field. Used by instructions like 'addi'.
332 return (int32_t)Imm == (short)Imm;
334 def imm64SExt16 : Operand<i64>, ImmLeaf<i64, [{
335 // imm64SExt16 predicate - True if the i64 immediate fits in a 16-bit
336 // sign extended field. Used by instructions like 'addi'.
337 return (int64_t)Imm == (short)Imm;
339 def immZExt16 : PatLeaf<(imm), [{
340 // immZExt16 predicate - True if the immediate fits in a 16-bit zero extended
341 // field. Used by instructions like 'ori'.
342 return (uint64_t)N->getZExtValue() == (unsigned short)N->getZExtValue();
344 def immAnyExt8 : ImmLeaf<i32, [{ return isInt<8>(Imm) || isUInt<8>(Imm); }]>;
345 def immSExt5NonZero : ImmLeaf<i32, [{ return Imm && isInt<5>(Imm); }]>;
347 // imm16Shifted* - These match immediates where the low 16-bits are zero. There
348 // are two forms: imm16ShiftedSExt and imm16ShiftedZExt. These two forms are
349 // identical in 32-bit mode, but in 64-bit mode, they return true if the
350 // immediate fits into a sign/zero extended 32-bit immediate (with the low bits
352 def imm16ShiftedZExt : PatLeaf<(imm), [{
353 // imm16ShiftedZExt predicate - True if only bits in the top 16-bits of the
354 // immediate are set. Used by instructions like 'xoris'.
355 return (N->getZExtValue() & ~uint64_t(0xFFFF0000)) == 0;
358 def imm16ShiftedSExt : PatLeaf<(imm), [{
359 // imm16ShiftedSExt predicate - True if only bits in the top 16-bits of the
360 // immediate are set. Used by instructions like 'addis'. Identical to
361 // imm16ShiftedZExt in 32-bit mode.
362 if (N->getZExtValue() & 0xFFFF) return false;
363 if (N->getValueType(0) == MVT::i32)
365 // For 64-bit, make sure it is sext right.
366 return N->getZExtValue() == (uint64_t)(int)N->getZExtValue();
369 def imm64ZExt32 : Operand<i64>, ImmLeaf<i64, [{
370 // imm64ZExt32 predicate - True if the i64 immediate fits in a 32-bit
371 // zero extended field.
372 return isUInt<32>(Imm);
375 // Some r+i load/store instructions (such as LD, STD, LDU, etc.) that require
376 // restricted memrix (4-aligned) constants are alignment sensitive. If these
377 // offsets are hidden behind TOC entries than the values of the lower-order
378 // bits cannot be checked directly. As a result, we need to also incorporate
379 // an alignment check into the relevant patterns.
381 def aligned4load : PatFrag<(ops node:$ptr), (load node:$ptr), [{
382 return cast<LoadSDNode>(N)->getAlignment() >= 4;
384 def aligned4store : PatFrag<(ops node:$val, node:$ptr),
385 (store node:$val, node:$ptr), [{
386 return cast<StoreSDNode>(N)->getAlignment() >= 4;
388 def aligned4sextloadi32 : PatFrag<(ops node:$ptr), (sextloadi32 node:$ptr), [{
389 return cast<LoadSDNode>(N)->getAlignment() >= 4;
391 def aligned4pre_store : PatFrag<
392 (ops node:$val, node:$base, node:$offset),
393 (pre_store node:$val, node:$base, node:$offset), [{
394 return cast<StoreSDNode>(N)->getAlignment() >= 4;
397 def unaligned4load : PatFrag<(ops node:$ptr), (load node:$ptr), [{
398 return cast<LoadSDNode>(N)->getAlignment() < 4;
400 def unaligned4store : PatFrag<(ops node:$val, node:$ptr),
401 (store node:$val, node:$ptr), [{
402 return cast<StoreSDNode>(N)->getAlignment() < 4;
404 def unaligned4sextloadi32 : PatFrag<(ops node:$ptr), (sextloadi32 node:$ptr), [{
405 return cast<LoadSDNode>(N)->getAlignment() < 4;
408 // This is a somewhat weaker condition than actually checking for 16-byte
409 // alignment. It is simply checking that the displacement can be represented
410 // as an immediate that is a multiple of 16 (i.e. the requirements for DQ-Form
412 def quadwOffsetLoad : PatFrag<(ops node:$ptr), (load node:$ptr), [{
413 return isOffsetMultipleOf(N, 16);
415 def quadwOffsetStore : PatFrag<(ops node:$val, node:$ptr),
416 (store node:$val, node:$ptr), [{
417 return isOffsetMultipleOf(N, 16);
419 def nonQuadwOffsetLoad : PatFrag<(ops node:$ptr), (load node:$ptr), [{
420 return !isOffsetMultipleOf(N, 16);
422 def nonQuadwOffsetStore : PatFrag<(ops node:$val, node:$ptr),
423 (store node:$val, node:$ptr), [{
424 return !isOffsetMultipleOf(N, 16);
427 //===----------------------------------------------------------------------===//
428 // PowerPC Flag Definitions.
430 class isPPC64 { bit PPC64 = 1; }
431 class isDOT { bit RC = 1; }
433 class RegConstraint<string C> {
434 string Constraints = C;
436 class NoEncode<string E> {
437 string DisableEncoding = E;
441 //===----------------------------------------------------------------------===//
442 // PowerPC Operand Definitions.
444 // In the default PowerPC assembler syntax, registers are specified simply
445 // by number, so they cannot be distinguished from immediate values (without
446 // looking at the opcode). This means that the default operand matching logic
447 // for the asm parser does not work, and we need to specify custom matchers.
448 // Since those can only be specified with RegisterOperand classes and not
449 // directly on the RegisterClass, all instructions patterns used by the asm
450 // parser need to use a RegisterOperand (instead of a RegisterClass) for
451 // all their register operands.
452 // For this purpose, we define one RegisterOperand for each RegisterClass,
453 // using the same name as the class, just in lower case.
455 def PPCRegGPRCAsmOperand : AsmOperandClass {
456 let Name = "RegGPRC"; let PredicateMethod = "isRegNumber";
458 def gprc : RegisterOperand<GPRC> {
459 let ParserMatchClass = PPCRegGPRCAsmOperand;
461 def PPCRegG8RCAsmOperand : AsmOperandClass {
462 let Name = "RegG8RC"; let PredicateMethod = "isRegNumber";
464 def g8rc : RegisterOperand<G8RC> {
465 let ParserMatchClass = PPCRegG8RCAsmOperand;
467 def PPCRegGPRCNoR0AsmOperand : AsmOperandClass {
468 let Name = "RegGPRCNoR0"; let PredicateMethod = "isRegNumber";
470 def gprc_nor0 : RegisterOperand<GPRC_NOR0> {
471 let ParserMatchClass = PPCRegGPRCNoR0AsmOperand;
473 def PPCRegG8RCNoX0AsmOperand : AsmOperandClass {
474 let Name = "RegG8RCNoX0"; let PredicateMethod = "isRegNumber";
476 def g8rc_nox0 : RegisterOperand<G8RC_NOX0> {
477 let ParserMatchClass = PPCRegG8RCNoX0AsmOperand;
479 def PPCRegF8RCAsmOperand : AsmOperandClass {
480 let Name = "RegF8RC"; let PredicateMethod = "isRegNumber";
482 def f8rc : RegisterOperand<F8RC> {
483 let ParserMatchClass = PPCRegF8RCAsmOperand;
485 def PPCRegF4RCAsmOperand : AsmOperandClass {
486 let Name = "RegF4RC"; let PredicateMethod = "isRegNumber";
488 def f4rc : RegisterOperand<F4RC> {
489 let ParserMatchClass = PPCRegF4RCAsmOperand;
491 def PPCRegVRRCAsmOperand : AsmOperandClass {
492 let Name = "RegVRRC"; let PredicateMethod = "isRegNumber";
494 def vrrc : RegisterOperand<VRRC> {
495 let ParserMatchClass = PPCRegVRRCAsmOperand;
497 def PPCRegVFRCAsmOperand : AsmOperandClass {
498 let Name = "RegVFRC"; let PredicateMethod = "isRegNumber";
500 def vfrc : RegisterOperand<VFRC> {
501 let ParserMatchClass = PPCRegVFRCAsmOperand;
503 def PPCRegCRBITRCAsmOperand : AsmOperandClass {
504 let Name = "RegCRBITRC"; let PredicateMethod = "isCRBitNumber";
506 def crbitrc : RegisterOperand<CRBITRC> {
507 let ParserMatchClass = PPCRegCRBITRCAsmOperand;
509 def PPCRegCRRCAsmOperand : AsmOperandClass {
510 let Name = "RegCRRC"; let PredicateMethod = "isCCRegNumber";
512 def crrc : RegisterOperand<CRRC> {
513 let ParserMatchClass = PPCRegCRRCAsmOperand;
515 def crrc0 : RegisterOperand<CRRC0> {
516 let ParserMatchClass = PPCRegCRRCAsmOperand;
519 def PPCU1ImmAsmOperand : AsmOperandClass {
520 let Name = "U1Imm"; let PredicateMethod = "isU1Imm";
521 let RenderMethod = "addImmOperands";
523 def u1imm : Operand<i32> {
524 let PrintMethod = "printU1ImmOperand";
525 let ParserMatchClass = PPCU1ImmAsmOperand;
528 def PPCU2ImmAsmOperand : AsmOperandClass {
529 let Name = "U2Imm"; let PredicateMethod = "isU2Imm";
530 let RenderMethod = "addImmOperands";
532 def u2imm : Operand<i32> {
533 let PrintMethod = "printU2ImmOperand";
534 let ParserMatchClass = PPCU2ImmAsmOperand;
537 def PPCATBitsAsHintAsmOperand : AsmOperandClass {
538 let Name = "ATBitsAsHint"; let PredicateMethod = "isATBitsAsHint";
539 let RenderMethod = "addImmOperands"; // Irrelevant, predicate always fails.
541 def atimm : Operand<i32> {
542 let PrintMethod = "printATBitsAsHint";
543 let ParserMatchClass = PPCATBitsAsHintAsmOperand;
546 def PPCU3ImmAsmOperand : AsmOperandClass {
547 let Name = "U3Imm"; let PredicateMethod = "isU3Imm";
548 let RenderMethod = "addImmOperands";
550 def u3imm : Operand<i32> {
551 let PrintMethod = "printU3ImmOperand";
552 let ParserMatchClass = PPCU3ImmAsmOperand;
555 def PPCU4ImmAsmOperand : AsmOperandClass {
556 let Name = "U4Imm"; let PredicateMethod = "isU4Imm";
557 let RenderMethod = "addImmOperands";
559 def u4imm : Operand<i32> {
560 let PrintMethod = "printU4ImmOperand";
561 let ParserMatchClass = PPCU4ImmAsmOperand;
563 def PPCS5ImmAsmOperand : AsmOperandClass {
564 let Name = "S5Imm"; let PredicateMethod = "isS5Imm";
565 let RenderMethod = "addImmOperands";
567 def s5imm : Operand<i32> {
568 let PrintMethod = "printS5ImmOperand";
569 let ParserMatchClass = PPCS5ImmAsmOperand;
570 let DecoderMethod = "decodeSImmOperand<5>";
572 def PPCU5ImmAsmOperand : AsmOperandClass {
573 let Name = "U5Imm"; let PredicateMethod = "isU5Imm";
574 let RenderMethod = "addImmOperands";
576 def u5imm : Operand<i32> {
577 let PrintMethod = "printU5ImmOperand";
578 let ParserMatchClass = PPCU5ImmAsmOperand;
579 let DecoderMethod = "decodeUImmOperand<5>";
581 def PPCU6ImmAsmOperand : AsmOperandClass {
582 let Name = "U6Imm"; let PredicateMethod = "isU6Imm";
583 let RenderMethod = "addImmOperands";
585 def u6imm : Operand<i32> {
586 let PrintMethod = "printU6ImmOperand";
587 let ParserMatchClass = PPCU6ImmAsmOperand;
588 let DecoderMethod = "decodeUImmOperand<6>";
590 def PPCU7ImmAsmOperand : AsmOperandClass {
591 let Name = "U7Imm"; let PredicateMethod = "isU7Imm";
592 let RenderMethod = "addImmOperands";
594 def u7imm : Operand<i32> {
595 let PrintMethod = "printU7ImmOperand";
596 let ParserMatchClass = PPCU7ImmAsmOperand;
597 let DecoderMethod = "decodeUImmOperand<7>";
599 def PPCU8ImmAsmOperand : AsmOperandClass {
600 let Name = "U8Imm"; let PredicateMethod = "isU8Imm";
601 let RenderMethod = "addImmOperands";
603 def u8imm : Operand<i32> {
604 let PrintMethod = "printU8ImmOperand";
605 let ParserMatchClass = PPCU8ImmAsmOperand;
606 let DecoderMethod = "decodeUImmOperand<8>";
608 def PPCU10ImmAsmOperand : AsmOperandClass {
609 let Name = "U10Imm"; let PredicateMethod = "isU10Imm";
610 let RenderMethod = "addImmOperands";
612 def u10imm : Operand<i32> {
613 let PrintMethod = "printU10ImmOperand";
614 let ParserMatchClass = PPCU10ImmAsmOperand;
615 let DecoderMethod = "decodeUImmOperand<10>";
617 def PPCU12ImmAsmOperand : AsmOperandClass {
618 let Name = "U12Imm"; let PredicateMethod = "isU12Imm";
619 let RenderMethod = "addImmOperands";
621 def u12imm : Operand<i32> {
622 let PrintMethod = "printU12ImmOperand";
623 let ParserMatchClass = PPCU12ImmAsmOperand;
624 let DecoderMethod = "decodeUImmOperand<12>";
626 def PPCS16ImmAsmOperand : AsmOperandClass {
627 let Name = "S16Imm"; let PredicateMethod = "isS16Imm";
628 let RenderMethod = "addS16ImmOperands";
630 def s16imm : Operand<i32> {
631 let PrintMethod = "printS16ImmOperand";
632 let EncoderMethod = "getImm16Encoding";
633 let ParserMatchClass = PPCS16ImmAsmOperand;
634 let DecoderMethod = "decodeSImmOperand<16>";
636 def PPCU16ImmAsmOperand : AsmOperandClass {
637 let Name = "U16Imm"; let PredicateMethod = "isU16Imm";
638 let RenderMethod = "addU16ImmOperands";
640 def u16imm : Operand<i32> {
641 let PrintMethod = "printU16ImmOperand";
642 let EncoderMethod = "getImm16Encoding";
643 let ParserMatchClass = PPCU16ImmAsmOperand;
644 let DecoderMethod = "decodeUImmOperand<16>";
646 def PPCS17ImmAsmOperand : AsmOperandClass {
647 let Name = "S17Imm"; let PredicateMethod = "isS17Imm";
648 let RenderMethod = "addS16ImmOperands";
650 def s17imm : Operand<i32> {
651 // This operand type is used for addis/lis to allow the assembler parser
652 // to accept immediates in the range -65536..65535 for compatibility with
653 // the GNU assembler. The operand is treated as 16-bit otherwise.
654 let PrintMethod = "printS16ImmOperand";
655 let EncoderMethod = "getImm16Encoding";
656 let ParserMatchClass = PPCS17ImmAsmOperand;
657 let DecoderMethod = "decodeSImmOperand<16>";
660 def fpimm0 : PatLeaf<(fpimm), [{ return N->isExactlyValue(+0.0); }]>;
662 def PPCDirectBrAsmOperand : AsmOperandClass {
663 let Name = "DirectBr"; let PredicateMethod = "isDirectBr";
664 let RenderMethod = "addBranchTargetOperands";
666 def directbrtarget : Operand<OtherVT> {
667 let PrintMethod = "printBranchOperand";
668 let EncoderMethod = "getDirectBrEncoding";
669 let ParserMatchClass = PPCDirectBrAsmOperand;
671 def absdirectbrtarget : Operand<OtherVT> {
672 let PrintMethod = "printAbsBranchOperand";
673 let EncoderMethod = "getAbsDirectBrEncoding";
674 let ParserMatchClass = PPCDirectBrAsmOperand;
676 def PPCCondBrAsmOperand : AsmOperandClass {
677 let Name = "CondBr"; let PredicateMethod = "isCondBr";
678 let RenderMethod = "addBranchTargetOperands";
680 def condbrtarget : Operand<OtherVT> {
681 let PrintMethod = "printBranchOperand";
682 let EncoderMethod = "getCondBrEncoding";
683 let ParserMatchClass = PPCCondBrAsmOperand;
685 def abscondbrtarget : Operand<OtherVT> {
686 let PrintMethod = "printAbsBranchOperand";
687 let EncoderMethod = "getAbsCondBrEncoding";
688 let ParserMatchClass = PPCCondBrAsmOperand;
690 def calltarget : Operand<iPTR> {
691 let PrintMethod = "printBranchOperand";
692 let EncoderMethod = "getDirectBrEncoding";
693 let ParserMatchClass = PPCDirectBrAsmOperand;
695 def abscalltarget : Operand<iPTR> {
696 let PrintMethod = "printAbsBranchOperand";
697 let EncoderMethod = "getAbsDirectBrEncoding";
698 let ParserMatchClass = PPCDirectBrAsmOperand;
700 def PPCCRBitMaskOperand : AsmOperandClass {
701 let Name = "CRBitMask"; let PredicateMethod = "isCRBitMask";
703 def crbitm: Operand<i8> {
704 let PrintMethod = "printcrbitm";
705 let EncoderMethod = "get_crbitm_encoding";
706 let DecoderMethod = "decodeCRBitMOperand";
707 let ParserMatchClass = PPCCRBitMaskOperand;
710 // A version of ptr_rc which excludes R0 (or X0 in 64-bit mode).
711 def PPCRegGxRCNoR0Operand : AsmOperandClass {
712 let Name = "RegGxRCNoR0"; let PredicateMethod = "isRegNumber";
714 def ptr_rc_nor0 : Operand<iPTR>, PointerLikeRegClass<1> {
715 let ParserMatchClass = PPCRegGxRCNoR0Operand;
717 // A version of ptr_rc usable with the asm parser.
718 def PPCRegGxRCOperand : AsmOperandClass {
719 let Name = "RegGxRC"; let PredicateMethod = "isRegNumber";
721 def ptr_rc_idx : Operand<iPTR>, PointerLikeRegClass<0> {
722 let ParserMatchClass = PPCRegGxRCOperand;
725 def PPCDispRIOperand : AsmOperandClass {
726 let Name = "DispRI"; let PredicateMethod = "isS16Imm";
727 let RenderMethod = "addS16ImmOperands";
729 def dispRI : Operand<iPTR> {
730 let ParserMatchClass = PPCDispRIOperand;
732 def PPCDispRIXOperand : AsmOperandClass {
733 let Name = "DispRIX"; let PredicateMethod = "isS16ImmX4";
734 let RenderMethod = "addImmOperands";
736 def dispRIX : Operand<iPTR> {
737 let ParserMatchClass = PPCDispRIXOperand;
739 def PPCDispRIX16Operand : AsmOperandClass {
740 let Name = "DispRIX16"; let PredicateMethod = "isS16ImmX16";
741 let RenderMethod = "addImmOperands";
743 def dispRIX16 : Operand<iPTR> {
744 let ParserMatchClass = PPCDispRIX16Operand;
746 def PPCDispSPE8Operand : AsmOperandClass {
747 let Name = "DispSPE8"; let PredicateMethod = "isU8ImmX8";
748 let RenderMethod = "addImmOperands";
750 def dispSPE8 : Operand<iPTR> {
751 let ParserMatchClass = PPCDispSPE8Operand;
753 def PPCDispSPE4Operand : AsmOperandClass {
754 let Name = "DispSPE4"; let PredicateMethod = "isU7ImmX4";
755 let RenderMethod = "addImmOperands";
757 def dispSPE4 : Operand<iPTR> {
758 let ParserMatchClass = PPCDispSPE4Operand;
760 def PPCDispSPE2Operand : AsmOperandClass {
761 let Name = "DispSPE2"; let PredicateMethod = "isU6ImmX2";
762 let RenderMethod = "addImmOperands";
764 def dispSPE2 : Operand<iPTR> {
765 let ParserMatchClass = PPCDispSPE2Operand;
768 def memri : Operand<iPTR> {
769 let PrintMethod = "printMemRegImm";
770 let MIOperandInfo = (ops dispRI:$imm, ptr_rc_nor0:$reg);
771 let EncoderMethod = "getMemRIEncoding";
772 let DecoderMethod = "decodeMemRIOperands";
774 def memrr : Operand<iPTR> {
775 let PrintMethod = "printMemRegReg";
776 let MIOperandInfo = (ops ptr_rc_nor0:$ptrreg, ptr_rc_idx:$offreg);
778 def memrix : Operand<iPTR> { // memri where the imm is 4-aligned.
779 let PrintMethod = "printMemRegImm";
780 let MIOperandInfo = (ops dispRIX:$imm, ptr_rc_nor0:$reg);
781 let EncoderMethod = "getMemRIXEncoding";
782 let DecoderMethod = "decodeMemRIXOperands";
784 def memrix16 : Operand<iPTR> { // memri, imm is 16-aligned, 12-bit, Inst{16:27}
785 let PrintMethod = "printMemRegImm";
786 let MIOperandInfo = (ops dispRIX16:$imm, ptr_rc_nor0:$reg);
787 let EncoderMethod = "getMemRIX16Encoding";
788 let DecoderMethod = "decodeMemRIX16Operands";
790 def spe8dis : Operand<iPTR> { // SPE displacement where the imm is 8-aligned.
791 let PrintMethod = "printMemRegImm";
792 let MIOperandInfo = (ops dispSPE8:$imm, ptr_rc_nor0:$reg);
793 let EncoderMethod = "getSPE8DisEncoding";
795 def spe4dis : Operand<iPTR> { // SPE displacement where the imm is 4-aligned.
796 let PrintMethod = "printMemRegImm";
797 let MIOperandInfo = (ops dispSPE4:$imm, ptr_rc_nor0:$reg);
798 let EncoderMethod = "getSPE4DisEncoding";
800 def spe2dis : Operand<iPTR> { // SPE displacement where the imm is 2-aligned.
801 let PrintMethod = "printMemRegImm";
802 let MIOperandInfo = (ops dispSPE2:$imm, ptr_rc_nor0:$reg);
803 let EncoderMethod = "getSPE2DisEncoding";
806 // A single-register address. This is used with the SjLj
807 // pseudo-instructions which tranlates to LD/LWZ. These instructions requires
808 // G8RC_NOX0 registers.
809 def memr : Operand<iPTR> {
810 let MIOperandInfo = (ops ptr_rc_nor0:$ptrreg);
812 def PPCTLSRegOperand : AsmOperandClass {
813 let Name = "TLSReg"; let PredicateMethod = "isTLSReg";
814 let RenderMethod = "addTLSRegOperands";
816 def tlsreg32 : Operand<i32> {
817 let EncoderMethod = "getTLSRegEncoding";
818 let ParserMatchClass = PPCTLSRegOperand;
820 def tlsgd32 : Operand<i32> {}
821 def tlscall32 : Operand<i32> {
822 let PrintMethod = "printTLSCall";
823 let MIOperandInfo = (ops calltarget:$func, tlsgd32:$sym);
824 let EncoderMethod = "getTLSCallEncoding";
827 // PowerPC Predicate operand.
828 def pred : Operand<OtherVT> {
829 let PrintMethod = "printPredicateOperand";
830 let MIOperandInfo = (ops i32imm:$bibo, crrc:$reg);
833 // Define PowerPC specific addressing mode.
834 def iaddr : ComplexPattern<iPTR, 2, "SelectAddrImm", [], []>;
835 def xaddr : ComplexPattern<iPTR, 2, "SelectAddrIdx", [], []>;
836 def xoaddr : ComplexPattern<iPTR, 2, "SelectAddrIdxOnly",[], []>;
837 def ixaddr : ComplexPattern<iPTR, 2, "SelectAddrImmX4", [], []>; // "std"
838 def iqaddr : ComplexPattern<iPTR, 2, "SelectAddrImmX16", [], []>; // "stxv"
840 // The address in a single register. This is used with the SjLj
841 // pseudo-instructions.
842 def addr : ComplexPattern<iPTR, 1, "SelectAddr",[], []>;
844 /// This is just the offset part of iaddr, used for preinc.
845 def iaddroff : ComplexPattern<iPTR, 1, "SelectAddrImmOffs", [], []>;
847 //===----------------------------------------------------------------------===//
848 // PowerPC Instruction Predicate Definitions.
849 def In32BitMode : Predicate<"!PPCSubTarget->isPPC64()">;
850 def In64BitMode : Predicate<"PPCSubTarget->isPPC64()">;
851 def IsBookE : Predicate<"PPCSubTarget->isBookE()">;
852 def IsNotBookE : Predicate<"!PPCSubTarget->isBookE()">;
853 def HasOnlyMSYNC : Predicate<"PPCSubTarget->hasOnlyMSYNC()">;
854 def HasSYNC : Predicate<"!PPCSubTarget->hasOnlyMSYNC()">;
855 def IsPPC4xx : Predicate<"PPCSubTarget->isPPC4xx()">;
856 def IsPPC6xx : Predicate<"PPCSubTarget->isPPC6xx()">;
857 def IsE500 : Predicate<"PPCSubTarget->isE500()">;
858 def HasSPE : Predicate<"PPCSubTarget->HasSPE()">;
859 def HasICBT : Predicate<"PPCSubTarget->hasICBT()">;
860 def HasPartwordAtomics : Predicate<"PPCSubTarget->hasPartwordAtomics()">;
861 def NoNaNsFPMath : Predicate<"TM.Options.NoNaNsFPMath">;
862 def NaNsFPMath : Predicate<"!TM.Options.NoNaNsFPMath">;
863 def HasBPERMD : Predicate<"PPCSubTarget->hasBPERMD()">;
864 def HasExtDiv : Predicate<"PPCSubTarget->hasExtDiv()">;
865 def IsISA3_0 : Predicate<"PPCSubTarget->isISA3_0()">;
867 //===----------------------------------------------------------------------===//
868 // PowerPC Multiclass Definitions.
870 multiclass XForm_6r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
871 string asmbase, string asmstr, InstrItinClass itin,
873 let BaseName = asmbase in {
874 def NAME : XForm_6<opcode, xo, OOL, IOL,
875 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
876 pattern>, RecFormRel;
878 def o : XForm_6<opcode, xo, OOL, IOL,
879 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
880 []>, isDOT, RecFormRel;
884 multiclass XForm_6rc<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
885 string asmbase, string asmstr, InstrItinClass itin,
887 let BaseName = asmbase in {
888 let Defs = [CARRY] in
889 def NAME : XForm_6<opcode, xo, OOL, IOL,
890 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
891 pattern>, RecFormRel;
892 let Defs = [CARRY, CR0] in
893 def o : XForm_6<opcode, xo, OOL, IOL,
894 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
895 []>, isDOT, RecFormRel;
899 multiclass XForm_10rc<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
900 string asmbase, string asmstr, InstrItinClass itin,
902 let BaseName = asmbase in {
903 let Defs = [CARRY] in
904 def NAME : XForm_10<opcode, xo, OOL, IOL,
905 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
906 pattern>, RecFormRel;
907 let Defs = [CARRY, CR0] in
908 def o : XForm_10<opcode, xo, OOL, IOL,
909 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
910 []>, isDOT, RecFormRel;
914 multiclass XForm_11r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
915 string asmbase, string asmstr, InstrItinClass itin,
917 let BaseName = asmbase in {
918 def NAME : XForm_11<opcode, xo, OOL, IOL,
919 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
920 pattern>, RecFormRel;
922 def o : XForm_11<opcode, xo, OOL, IOL,
923 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
924 []>, isDOT, RecFormRel;
928 multiclass XOForm_1r<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
929 string asmbase, string asmstr, InstrItinClass itin,
931 let BaseName = asmbase in {
932 def NAME : XOForm_1<opcode, xo, oe, OOL, IOL,
933 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
934 pattern>, RecFormRel;
936 def o : XOForm_1<opcode, xo, oe, OOL, IOL,
937 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
938 []>, isDOT, RecFormRel;
942 // Multiclass for instructions for which the non record form is not cracked
943 // and the record form is cracked (i.e. divw, mullw, etc.)
944 multiclass XOForm_1rcr<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
945 string asmbase, string asmstr, InstrItinClass itin,
947 let BaseName = asmbase in {
948 def NAME : XOForm_1<opcode, xo, oe, OOL, IOL,
949 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
950 pattern>, RecFormRel;
952 def o : XOForm_1<opcode, xo, oe, OOL, IOL,
953 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
954 []>, isDOT, RecFormRel, PPC970_DGroup_First,
955 PPC970_DGroup_Cracked;
959 multiclass XOForm_1rc<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
960 string asmbase, string asmstr, InstrItinClass itin,
962 let BaseName = asmbase in {
963 let Defs = [CARRY] in
964 def NAME : XOForm_1<opcode, xo, oe, OOL, IOL,
965 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
966 pattern>, RecFormRel;
967 let Defs = [CARRY, CR0] in
968 def o : XOForm_1<opcode, xo, oe, OOL, IOL,
969 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
970 []>, isDOT, RecFormRel;
974 multiclass XOForm_3r<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
975 string asmbase, string asmstr, InstrItinClass itin,
977 let BaseName = asmbase in {
978 def NAME : XOForm_3<opcode, xo, oe, OOL, IOL,
979 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
980 pattern>, RecFormRel;
982 def o : XOForm_3<opcode, xo, oe, OOL, IOL,
983 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
984 []>, isDOT, RecFormRel;
988 multiclass XOForm_3rc<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
989 string asmbase, string asmstr, InstrItinClass itin,
991 let BaseName = asmbase in {
992 let Defs = [CARRY] in
993 def NAME : XOForm_3<opcode, xo, oe, OOL, IOL,
994 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
995 pattern>, RecFormRel;
996 let Defs = [CARRY, CR0] in
997 def o : XOForm_3<opcode, xo, oe, OOL, IOL,
998 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
999 []>, isDOT, RecFormRel;
1003 multiclass MForm_2r<bits<6> opcode, dag OOL, dag IOL,
1004 string asmbase, string asmstr, InstrItinClass itin,
1005 list<dag> pattern> {
1006 let BaseName = asmbase in {
1007 def NAME : MForm_2<opcode, OOL, IOL,
1008 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1009 pattern>, RecFormRel;
1011 def o : MForm_2<opcode, OOL, IOL,
1012 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1013 []>, isDOT, RecFormRel;
1017 multiclass MDForm_1r<bits<6> opcode, bits<3> xo, dag OOL, dag IOL,
1018 string asmbase, string asmstr, InstrItinClass itin,
1019 list<dag> pattern> {
1020 let BaseName = asmbase in {
1021 def NAME : MDForm_1<opcode, xo, OOL, IOL,
1022 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1023 pattern>, RecFormRel;
1025 def o : MDForm_1<opcode, xo, OOL, IOL,
1026 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1027 []>, isDOT, RecFormRel;
1031 multiclass MDSForm_1r<bits<6> opcode, bits<4> xo, dag OOL, dag IOL,
1032 string asmbase, string asmstr, InstrItinClass itin,
1033 list<dag> pattern> {
1034 let BaseName = asmbase in {
1035 def NAME : MDSForm_1<opcode, xo, OOL, IOL,
1036 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1037 pattern>, RecFormRel;
1039 def o : MDSForm_1<opcode, xo, OOL, IOL,
1040 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1041 []>, isDOT, RecFormRel;
1045 multiclass XSForm_1rc<bits<6> opcode, bits<9> xo, dag OOL, dag IOL,
1046 string asmbase, string asmstr, InstrItinClass itin,
1047 list<dag> pattern> {
1048 let BaseName = asmbase in {
1049 let Defs = [CARRY] in
1050 def NAME : XSForm_1<opcode, xo, OOL, IOL,
1051 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1052 pattern>, RecFormRel;
1053 let Defs = [CARRY, CR0] in
1054 def o : XSForm_1<opcode, xo, OOL, IOL,
1055 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1056 []>, isDOT, RecFormRel;
1060 multiclass XSForm_1r<bits<6> opcode, bits<9> xo, dag OOL, dag IOL,
1061 string asmbase, string asmstr, InstrItinClass itin,
1062 list<dag> pattern> {
1063 let BaseName = asmbase in {
1064 def NAME : XSForm_1<opcode, xo, OOL, IOL,
1065 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1066 pattern>, RecFormRel;
1068 def o : XSForm_1<opcode, xo, OOL, IOL,
1069 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1070 []>, isDOT, RecFormRel;
1074 multiclass XForm_26r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
1075 string asmbase, string asmstr, InstrItinClass itin,
1076 list<dag> pattern> {
1077 let BaseName = asmbase in {
1078 def NAME : XForm_26<opcode, xo, OOL, IOL,
1079 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1080 pattern>, RecFormRel;
1082 def o : XForm_26<opcode, xo, OOL, IOL,
1083 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1084 []>, isDOT, RecFormRel;
1088 multiclass XForm_28r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
1089 string asmbase, string asmstr, InstrItinClass itin,
1090 list<dag> pattern> {
1091 let BaseName = asmbase in {
1092 def NAME : XForm_28<opcode, xo, OOL, IOL,
1093 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1094 pattern>, RecFormRel;
1096 def o : XForm_28<opcode, xo, OOL, IOL,
1097 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1098 []>, isDOT, RecFormRel;
1102 multiclass AForm_1r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL,
1103 string asmbase, string asmstr, InstrItinClass itin,
1104 list<dag> pattern> {
1105 let BaseName = asmbase in {
1106 def NAME : AForm_1<opcode, xo, OOL, IOL,
1107 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1108 pattern>, RecFormRel;
1110 def o : AForm_1<opcode, xo, OOL, IOL,
1111 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1112 []>, isDOT, RecFormRel;
1116 multiclass AForm_2r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL,
1117 string asmbase, string asmstr, InstrItinClass itin,
1118 list<dag> pattern> {
1119 let BaseName = asmbase in {
1120 def NAME : AForm_2<opcode, xo, OOL, IOL,
1121 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1122 pattern>, RecFormRel;
1124 def o : AForm_2<opcode, xo, OOL, IOL,
1125 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1126 []>, isDOT, RecFormRel;
1130 multiclass AForm_3r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL,
1131 string asmbase, string asmstr, InstrItinClass itin,
1132 list<dag> pattern> {
1133 let BaseName = asmbase in {
1134 def NAME : AForm_3<opcode, xo, OOL, IOL,
1135 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1136 pattern>, RecFormRel;
1138 def o : AForm_3<opcode, xo, OOL, IOL,
1139 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1140 []>, isDOT, RecFormRel;
1144 //===----------------------------------------------------------------------===//
1145 // PowerPC Instruction Definitions.
1147 // Pseudo-instructions:
1149 let hasCtrlDep = 1 in {
1150 let Defs = [R1], Uses = [R1] in {
1151 def ADJCALLSTACKDOWN : Pseudo<(outs), (ins u16imm:$amt1, u16imm:$amt2),
1152 "#ADJCALLSTACKDOWN $amt1 $amt2",
1153 [(callseq_start timm:$amt1, timm:$amt2)]>;
1154 def ADJCALLSTACKUP : Pseudo<(outs), (ins u16imm:$amt1, u16imm:$amt2),
1155 "#ADJCALLSTACKUP $amt1 $amt2",
1156 [(callseq_end timm:$amt1, timm:$amt2)]>;
1159 def UPDATE_VRSAVE : Pseudo<(outs gprc:$rD), (ins gprc:$rS),
1160 "UPDATE_VRSAVE $rD, $rS", []>;
1163 let Defs = [R1], Uses = [R1] in
1164 def DYNALLOC : Pseudo<(outs gprc:$result), (ins gprc:$negsize, memri:$fpsi), "#DYNALLOC",
1166 (PPCdynalloc i32:$negsize, iaddr:$fpsi))]>;
1167 def DYNAREAOFFSET : Pseudo<(outs i32imm:$result), (ins memri:$fpsi), "#DYNAREAOFFSET",
1168 [(set i32:$result, (PPCdynareaoffset iaddr:$fpsi))]>;
1170 // SELECT_CC_* - Used to implement the SELECT_CC DAG operation. Expanded after
1171 // instruction selection into a branch sequence.
1172 let usesCustomInserter = 1, // Expanded after instruction selection.
1173 PPC970_Single = 1 in {
1174 // Note that SELECT_CC_I4 and SELECT_CC_I8 use the no-r0 register classes
1175 // because either operand might become the first operand in an isel, and
1176 // that operand cannot be r0.
1177 def SELECT_CC_I4 : Pseudo<(outs gprc:$dst), (ins crrc:$cond,
1178 gprc_nor0:$T, gprc_nor0:$F,
1179 i32imm:$BROPC), "#SELECT_CC_I4",
1181 def SELECT_CC_I8 : Pseudo<(outs g8rc:$dst), (ins crrc:$cond,
1182 g8rc_nox0:$T, g8rc_nox0:$F,
1183 i32imm:$BROPC), "#SELECT_CC_I8",
1185 def SELECT_CC_F4 : Pseudo<(outs f4rc:$dst), (ins crrc:$cond, f4rc:$T, f4rc:$F,
1186 i32imm:$BROPC), "#SELECT_CC_F4",
1188 def SELECT_CC_F8 : Pseudo<(outs f8rc:$dst), (ins crrc:$cond, f8rc:$T, f8rc:$F,
1189 i32imm:$BROPC), "#SELECT_CC_F8",
1191 def SELECT_CC_VRRC: Pseudo<(outs vrrc:$dst), (ins crrc:$cond, vrrc:$T, vrrc:$F,
1192 i32imm:$BROPC), "#SELECT_CC_VRRC",
1195 // SELECT_* pseudo instructions, like SELECT_CC_* but taking condition
1196 // register bit directly.
1197 def SELECT_I4 : Pseudo<(outs gprc:$dst), (ins crbitrc:$cond,
1198 gprc_nor0:$T, gprc_nor0:$F), "#SELECT_I4",
1199 [(set i32:$dst, (select i1:$cond, i32:$T, i32:$F))]>;
1200 def SELECT_I8 : Pseudo<(outs g8rc:$dst), (ins crbitrc:$cond,
1201 g8rc_nox0:$T, g8rc_nox0:$F), "#SELECT_I8",
1202 [(set i64:$dst, (select i1:$cond, i64:$T, i64:$F))]>;
1203 def SELECT_F4 : Pseudo<(outs f4rc:$dst), (ins crbitrc:$cond,
1204 f4rc:$T, f4rc:$F), "#SELECT_F4",
1205 [(set f32:$dst, (select i1:$cond, f32:$T, f32:$F))]>;
1206 def SELECT_F8 : Pseudo<(outs f8rc:$dst), (ins crbitrc:$cond,
1207 f8rc:$T, f8rc:$F), "#SELECT_F8",
1208 [(set f64:$dst, (select i1:$cond, f64:$T, f64:$F))]>;
1209 def SELECT_VRRC: Pseudo<(outs vrrc:$dst), (ins crbitrc:$cond,
1210 vrrc:$T, vrrc:$F), "#SELECT_VRRC",
1212 (select i1:$cond, v4i32:$T, v4i32:$F))]>;
1215 // SPILL_CR - Indicate that we're dumping the CR register, so we'll need to
1216 // scavenge a register for it.
1217 let mayStore = 1 in {
1218 def SPILL_CR : Pseudo<(outs), (ins crrc:$cond, memri:$F),
1220 def SPILL_CRBIT : Pseudo<(outs), (ins crbitrc:$cond, memri:$F),
1221 "#SPILL_CRBIT", []>;
1224 // RESTORE_CR - Indicate that we're restoring the CR register (previously
1225 // spilled), so we'll need to scavenge a register for it.
1226 let mayLoad = 1 in {
1227 def RESTORE_CR : Pseudo<(outs crrc:$cond), (ins memri:$F),
1229 def RESTORE_CRBIT : Pseudo<(outs crbitrc:$cond), (ins memri:$F),
1230 "#RESTORE_CRBIT", []>;
1233 let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7 in {
1234 let isReturn = 1, Uses = [LR, RM] in
1235 def BLR : XLForm_2_ext<19, 16, 20, 0, 0, (outs), (ins), "blr", IIC_BrB,
1236 [(retflag)]>, Requires<[In32BitMode]>;
1237 let isBranch = 1, isIndirectBranch = 1, Uses = [CTR] in {
1238 def BCTR : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
1241 let isCodeGenOnly = 1 in {
1242 def BCCCTR : XLForm_2_br<19, 528, 0, (outs), (ins pred:$cond),
1243 "b${cond:cc}ctr${cond:pm} ${cond:reg}", IIC_BrB,
1246 def BCCTR : XLForm_2_br2<19, 528, 12, 0, (outs), (ins crbitrc:$bi),
1247 "bcctr 12, $bi, 0", IIC_BrB, []>;
1248 def BCCTRn : XLForm_2_br2<19, 528, 4, 0, (outs), (ins crbitrc:$bi),
1249 "bcctr 4, $bi, 0", IIC_BrB, []>;
1255 def MovePCtoLR : Pseudo<(outs), (ins), "#MovePCtoLR", []>,
1258 def MoveGOTtoLR : Pseudo<(outs), (ins), "#MoveGOTtoLR", []>,
1261 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7 in {
1262 let isBarrier = 1 in {
1263 def B : IForm<18, 0, 0, (outs), (ins directbrtarget:$dst),
1266 def BA : IForm<18, 1, 0, (outs), (ins absdirectbrtarget:$dst),
1267 "ba $dst", IIC_BrB, []>;
1270 // BCC represents an arbitrary conditional branch on a predicate.
1271 // FIXME: should be able to write a pattern for PPCcondbranch, but can't use
1272 // a two-value operand where a dag node expects two operands. :(
1273 let isCodeGenOnly = 1 in {
1274 class BCC_class : BForm<16, 0, 0, (outs), (ins pred:$cond, condbrtarget:$dst),
1275 "b${cond:cc}${cond:pm} ${cond:reg}, $dst"
1276 /*[(PPCcondbranch crrc:$crS, imm:$opc, bb:$dst)]*/>;
1277 def BCC : BCC_class;
1279 // The same as BCC, except that it's not a terminator. Used for introducing
1280 // control flow dependency without creating new blocks.
1281 let isTerminator = 0 in def CTRL_DEP : BCC_class;
1283 def BCCA : BForm<16, 1, 0, (outs), (ins pred:$cond, abscondbrtarget:$dst),
1284 "b${cond:cc}a${cond:pm} ${cond:reg}, $dst">;
1286 let isReturn = 1, Uses = [LR, RM] in
1287 def BCCLR : XLForm_2_br<19, 16, 0, (outs), (ins pred:$cond),
1288 "b${cond:cc}lr${cond:pm} ${cond:reg}", IIC_BrB, []>;
1291 let isCodeGenOnly = 1 in {
1292 let Pattern = [(brcond i1:$bi, bb:$dst)] in
1293 def BC : BForm_4<16, 12, 0, 0, (outs), (ins crbitrc:$bi, condbrtarget:$dst),
1294 "bc 12, $bi, $dst">;
1296 let Pattern = [(brcond (not i1:$bi), bb:$dst)] in
1297 def BCn : BForm_4<16, 4, 0, 0, (outs), (ins crbitrc:$bi, condbrtarget:$dst),
1300 let isReturn = 1, Uses = [LR, RM] in
1301 def BCLR : XLForm_2_br2<19, 16, 12, 0, (outs), (ins crbitrc:$bi),
1302 "bclr 12, $bi, 0", IIC_BrB, []>;
1303 def BCLRn : XLForm_2_br2<19, 16, 4, 0, (outs), (ins crbitrc:$bi),
1304 "bclr 4, $bi, 0", IIC_BrB, []>;
1307 let isReturn = 1, Defs = [CTR], Uses = [CTR, LR, RM] in {
1308 def BDZLR : XLForm_2_ext<19, 16, 18, 0, 0, (outs), (ins),
1309 "bdzlr", IIC_BrB, []>;
1310 def BDNZLR : XLForm_2_ext<19, 16, 16, 0, 0, (outs), (ins),
1311 "bdnzlr", IIC_BrB, []>;
1312 def BDZLRp : XLForm_2_ext<19, 16, 27, 0, 0, (outs), (ins),
1313 "bdzlr+", IIC_BrB, []>;
1314 def BDNZLRp: XLForm_2_ext<19, 16, 25, 0, 0, (outs), (ins),
1315 "bdnzlr+", IIC_BrB, []>;
1316 def BDZLRm : XLForm_2_ext<19, 16, 26, 0, 0, (outs), (ins),
1317 "bdzlr-", IIC_BrB, []>;
1318 def BDNZLRm: XLForm_2_ext<19, 16, 24, 0, 0, (outs), (ins),
1319 "bdnzlr-", IIC_BrB, []>;
1322 let Defs = [CTR], Uses = [CTR] in {
1323 def BDZ : BForm_1<16, 18, 0, 0, (outs), (ins condbrtarget:$dst),
1325 def BDNZ : BForm_1<16, 16, 0, 0, (outs), (ins condbrtarget:$dst),
1327 def BDZA : BForm_1<16, 18, 1, 0, (outs), (ins abscondbrtarget:$dst),
1329 def BDNZA : BForm_1<16, 16, 1, 0, (outs), (ins abscondbrtarget:$dst),
1331 def BDZp : BForm_1<16, 27, 0, 0, (outs), (ins condbrtarget:$dst),
1333 def BDNZp: BForm_1<16, 25, 0, 0, (outs), (ins condbrtarget:$dst),
1335 def BDZAp : BForm_1<16, 27, 1, 0, (outs), (ins abscondbrtarget:$dst),
1337 def BDNZAp: BForm_1<16, 25, 1, 0, (outs), (ins abscondbrtarget:$dst),
1339 def BDZm : BForm_1<16, 26, 0, 0, (outs), (ins condbrtarget:$dst),
1341 def BDNZm: BForm_1<16, 24, 0, 0, (outs), (ins condbrtarget:$dst),
1343 def BDZAm : BForm_1<16, 26, 1, 0, (outs), (ins abscondbrtarget:$dst),
1345 def BDNZAm: BForm_1<16, 24, 1, 0, (outs), (ins abscondbrtarget:$dst),
1350 // The unconditional BCL used by the SjLj setjmp code.
1351 let isCall = 1, hasCtrlDep = 1, isCodeGenOnly = 1, PPC970_Unit = 7 in {
1352 let Defs = [LR], Uses = [RM] in {
1353 def BCLalways : BForm_2<16, 20, 31, 0, 1, (outs), (ins condbrtarget:$dst),
1354 "bcl 20, 31, $dst">;
1358 let isCall = 1, PPC970_Unit = 7, Defs = [LR] in {
1359 // Convenient aliases for call instructions
1360 let Uses = [RM] in {
1361 def BL : IForm<18, 0, 1, (outs), (ins calltarget:$func),
1362 "bl $func", IIC_BrB, []>; // See Pat patterns below.
1363 def BLA : IForm<18, 1, 1, (outs), (ins abscalltarget:$func),
1364 "bla $func", IIC_BrB, [(PPCcall (i32 imm:$func))]>;
1366 let isCodeGenOnly = 1 in {
1367 def BL_TLS : IForm<18, 0, 1, (outs), (ins tlscall32:$func),
1368 "bl $func", IIC_BrB, []>;
1369 def BCCL : BForm<16, 0, 1, (outs), (ins pred:$cond, condbrtarget:$dst),
1370 "b${cond:cc}l${cond:pm} ${cond:reg}, $dst">;
1371 def BCCLA : BForm<16, 1, 1, (outs), (ins pred:$cond, abscondbrtarget:$dst),
1372 "b${cond:cc}la${cond:pm} ${cond:reg}, $dst">;
1374 def BCL : BForm_4<16, 12, 0, 1, (outs),
1375 (ins crbitrc:$bi, condbrtarget:$dst),
1376 "bcl 12, $bi, $dst">;
1377 def BCLn : BForm_4<16, 4, 0, 1, (outs),
1378 (ins crbitrc:$bi, condbrtarget:$dst),
1379 "bcl 4, $bi, $dst">;
1382 let Uses = [CTR, RM] in {
1383 def BCTRL : XLForm_2_ext<19, 528, 20, 0, 1, (outs), (ins),
1384 "bctrl", IIC_BrB, [(PPCbctrl)]>,
1385 Requires<[In32BitMode]>;
1387 let isCodeGenOnly = 1 in {
1388 def BCCCTRL : XLForm_2_br<19, 528, 1, (outs), (ins pred:$cond),
1389 "b${cond:cc}ctrl${cond:pm} ${cond:reg}", IIC_BrB,
1392 def BCCTRL : XLForm_2_br2<19, 528, 12, 1, (outs), (ins crbitrc:$bi),
1393 "bcctrl 12, $bi, 0", IIC_BrB, []>;
1394 def BCCTRLn : XLForm_2_br2<19, 528, 4, 1, (outs), (ins crbitrc:$bi),
1395 "bcctrl 4, $bi, 0", IIC_BrB, []>;
1398 let Uses = [LR, RM] in {
1399 def BLRL : XLForm_2_ext<19, 16, 20, 0, 1, (outs), (ins),
1400 "blrl", IIC_BrB, []>;
1402 let isCodeGenOnly = 1 in {
1403 def BCCLRL : XLForm_2_br<19, 16, 1, (outs), (ins pred:$cond),
1404 "b${cond:cc}lrl${cond:pm} ${cond:reg}", IIC_BrB,
1407 def BCLRL : XLForm_2_br2<19, 16, 12, 1, (outs), (ins crbitrc:$bi),
1408 "bclrl 12, $bi, 0", IIC_BrB, []>;
1409 def BCLRLn : XLForm_2_br2<19, 16, 4, 1, (outs), (ins crbitrc:$bi),
1410 "bclrl 4, $bi, 0", IIC_BrB, []>;
1413 let Defs = [CTR], Uses = [CTR, RM] in {
1414 def BDZL : BForm_1<16, 18, 0, 1, (outs), (ins condbrtarget:$dst),
1416 def BDNZL : BForm_1<16, 16, 0, 1, (outs), (ins condbrtarget:$dst),
1418 def BDZLA : BForm_1<16, 18, 1, 1, (outs), (ins abscondbrtarget:$dst),
1420 def BDNZLA : BForm_1<16, 16, 1, 1, (outs), (ins abscondbrtarget:$dst),
1422 def BDZLp : BForm_1<16, 27, 0, 1, (outs), (ins condbrtarget:$dst),
1424 def BDNZLp: BForm_1<16, 25, 0, 1, (outs), (ins condbrtarget:$dst),
1426 def BDZLAp : BForm_1<16, 27, 1, 1, (outs), (ins abscondbrtarget:$dst),
1428 def BDNZLAp: BForm_1<16, 25, 1, 1, (outs), (ins abscondbrtarget:$dst),
1430 def BDZLm : BForm_1<16, 26, 0, 1, (outs), (ins condbrtarget:$dst),
1432 def BDNZLm: BForm_1<16, 24, 0, 1, (outs), (ins condbrtarget:$dst),
1434 def BDZLAm : BForm_1<16, 26, 1, 1, (outs), (ins abscondbrtarget:$dst),
1436 def BDNZLAm: BForm_1<16, 24, 1, 1, (outs), (ins abscondbrtarget:$dst),
1439 let Defs = [CTR], Uses = [CTR, LR, RM] in {
1440 def BDZLRL : XLForm_2_ext<19, 16, 18, 0, 1, (outs), (ins),
1441 "bdzlrl", IIC_BrB, []>;
1442 def BDNZLRL : XLForm_2_ext<19, 16, 16, 0, 1, (outs), (ins),
1443 "bdnzlrl", IIC_BrB, []>;
1444 def BDZLRLp : XLForm_2_ext<19, 16, 27, 0, 1, (outs), (ins),
1445 "bdzlrl+", IIC_BrB, []>;
1446 def BDNZLRLp: XLForm_2_ext<19, 16, 25, 0, 1, (outs), (ins),
1447 "bdnzlrl+", IIC_BrB, []>;
1448 def BDZLRLm : XLForm_2_ext<19, 16, 26, 0, 1, (outs), (ins),
1449 "bdzlrl-", IIC_BrB, []>;
1450 def BDNZLRLm: XLForm_2_ext<19, 16, 24, 0, 1, (outs), (ins),
1451 "bdnzlrl-", IIC_BrB, []>;
1455 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
1456 def TCRETURNdi :Pseudo< (outs),
1457 (ins calltarget:$dst, i32imm:$offset),
1458 "#TC_RETURNd $dst $offset",
1462 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
1463 def TCRETURNai :Pseudo<(outs), (ins abscalltarget:$func, i32imm:$offset),
1464 "#TC_RETURNa $func $offset",
1465 [(PPCtc_return (i32 imm:$func), imm:$offset)]>;
1467 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
1468 def TCRETURNri : Pseudo<(outs), (ins CTRRC:$dst, i32imm:$offset),
1469 "#TC_RETURNr $dst $offset",
1473 let isCodeGenOnly = 1 in {
1475 let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, isBranch = 1,
1476 isIndirectBranch = 1, isCall = 1, isReturn = 1, Uses = [CTR, RM] in
1477 def TAILBCTR : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
1478 []>, Requires<[In32BitMode]>;
1480 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
1481 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
1482 def TAILB : IForm<18, 0, 0, (outs), (ins calltarget:$dst),
1486 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
1487 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
1488 def TAILBA : IForm<18, 0, 0, (outs), (ins abscalltarget:$dst),
1494 let hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
1496 def EH_SjLj_SetJmp32 : Pseudo<(outs gprc:$dst), (ins memr:$buf),
1497 "#EH_SJLJ_SETJMP32",
1498 [(set i32:$dst, (PPCeh_sjlj_setjmp addr:$buf))]>,
1499 Requires<[In32BitMode]>;
1500 let isTerminator = 1 in
1501 def EH_SjLj_LongJmp32 : Pseudo<(outs), (ins memr:$buf),
1502 "#EH_SJLJ_LONGJMP32",
1503 [(PPCeh_sjlj_longjmp addr:$buf)]>,
1504 Requires<[In32BitMode]>;
1507 // This pseudo is never removed from the function, as it serves as
1508 // a terminator. Size is set to 0 to prevent the builtin assembler
1509 // from emitting it.
1510 let isBranch = 1, isTerminator = 1, Size = 0 in {
1511 def EH_SjLj_Setup : Pseudo<(outs), (ins directbrtarget:$dst),
1512 "#EH_SjLj_Setup\t$dst", []>;
1516 let PPC970_Unit = 7 in {
1517 def SC : SCForm<17, 1, (outs), (ins i32imm:$lev),
1518 "sc $lev", IIC_BrB, [(PPCsc (i32 imm:$lev))]>;
1521 // Branch history rolling buffer.
1522 def CLRBHRB : XForm_0<31, 430, (outs), (ins), "clrbhrb", IIC_BrB,
1524 PPC970_DGroup_Single;
1525 // The $dmy argument used for MFBHRBE is not needed; however, including
1526 // it avoids automatic generation of PPCFastISel::fastEmit_i(), which
1527 // interferes with necessary special handling (see PPCFastISel.cpp).
1528 def MFBHRBE : XFXForm_3p<31, 302, (outs gprc:$rD),
1529 (ins u10imm:$imm, u10imm:$dmy),
1530 "mfbhrbe $rD, $imm", IIC_BrB,
1532 (PPCmfbhrbe imm:$imm, imm:$dmy))]>,
1533 PPC970_DGroup_First;
1535 def RFEBB : XLForm_S<19, 146, (outs), (ins u1imm:$imm), "rfebb $imm",
1536 IIC_BrB, [(PPCrfebb (i32 imm:$imm))]>,
1537 PPC970_DGroup_Single;
1539 // DCB* instructions.
1540 def DCBA : DCB_Form<758, 0, (outs), (ins memrr:$dst), "dcba $dst",
1541 IIC_LdStDCBF, [(int_ppc_dcba xoaddr:$dst)]>,
1542 PPC970_DGroup_Single;
1543 def DCBI : DCB_Form<470, 0, (outs), (ins memrr:$dst), "dcbi $dst",
1544 IIC_LdStDCBF, [(int_ppc_dcbi xoaddr:$dst)]>,
1545 PPC970_DGroup_Single;
1546 def DCBST : DCB_Form<54, 0, (outs), (ins memrr:$dst), "dcbst $dst",
1547 IIC_LdStDCBF, [(int_ppc_dcbst xoaddr:$dst)]>,
1548 PPC970_DGroup_Single;
1549 def DCBZ : DCB_Form<1014, 0, (outs), (ins memrr:$dst), "dcbz $dst",
1550 IIC_LdStDCBF, [(int_ppc_dcbz xoaddr:$dst)]>,
1551 PPC970_DGroup_Single;
1552 def DCBZL : DCB_Form<1014, 1, (outs), (ins memrr:$dst), "dcbzl $dst",
1553 IIC_LdStDCBF, [(int_ppc_dcbzl xoaddr:$dst)]>,
1554 PPC970_DGroup_Single;
1556 def DCBF : DCB_Form_hint<86, (outs), (ins u5imm:$TH, memrr:$dst),
1557 "dcbf $dst, $TH", IIC_LdStDCBF, []>,
1558 PPC970_DGroup_Single;
1560 let hasSideEffects = 0, mayLoad = 1, mayStore = 1 in {
1561 def DCBT : DCB_Form_hint<278, (outs), (ins u5imm:$TH, memrr:$dst),
1562 "dcbt $dst, $TH", IIC_LdStDCBF, []>,
1563 PPC970_DGroup_Single;
1564 def DCBTST : DCB_Form_hint<246, (outs), (ins u5imm:$TH, memrr:$dst),
1565 "dcbtst $dst, $TH", IIC_LdStDCBF, []>,
1566 PPC970_DGroup_Single;
1567 } // hasSideEffects = 0
1569 def ICBLC : XForm_icbt<31, 230, (outs), (ins u4imm:$CT, memrr:$src),
1570 "icblc $CT, $src", IIC_LdStStore>, Requires<[HasICBT]>;
1571 def ICBLQ : XForm_icbt<31, 198, (outs), (ins u4imm:$CT, memrr:$src),
1572 "icblq. $CT, $src", IIC_LdStLoad>, Requires<[HasICBT]>;
1573 def ICBT : XForm_icbt<31, 22, (outs), (ins u4imm:$CT, memrr:$src),
1574 "icbt $CT, $src", IIC_LdStLoad>, Requires<[HasICBT]>;
1575 def ICBTLS : XForm_icbt<31, 486, (outs), (ins u4imm:$CT, memrr:$src),
1576 "icbtls $CT, $src", IIC_LdStLoad>, Requires<[HasICBT]>;
1578 def : Pat<(int_ppc_dcbt xoaddr:$dst),
1579 (DCBT 0, xoaddr:$dst)>;
1580 def : Pat<(int_ppc_dcbtst xoaddr:$dst),
1581 (DCBTST 0, xoaddr:$dst)>;
1582 def : Pat<(int_ppc_dcbf xoaddr:$dst),
1583 (DCBF 0, xoaddr:$dst)>;
1585 def : Pat<(prefetch xoaddr:$dst, (i32 0), imm, (i32 1)),
1586 (DCBT 0, xoaddr:$dst)>; // data prefetch for loads
1587 def : Pat<(prefetch xoaddr:$dst, (i32 1), imm, (i32 1)),
1588 (DCBTST 0, xoaddr:$dst)>; // data prefetch for stores
1589 def : Pat<(prefetch xoaddr:$dst, (i32 0), imm, (i32 0)),
1590 (ICBT 0, xoaddr:$dst)>, Requires<[HasICBT]>; // inst prefetch (for read)
1592 // Atomic operations
1593 // FIXME: some of these might be used with constant operands. This will result
1594 // in constant materialization instructions that may be redundant. We currently
1595 // clean this up in PPCMIPeephole with calls to
1596 // PPCInstrInfo::convertToImmediateForm() but we should probably not emit them
1597 // in the first place.
1598 let usesCustomInserter = 1 in {
1599 let Defs = [CR0] in {
1600 def ATOMIC_LOAD_ADD_I8 : Pseudo<
1601 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I8",
1602 [(set i32:$dst, (atomic_load_add_8 xoaddr:$ptr, i32:$incr))]>;
1603 def ATOMIC_LOAD_SUB_I8 : Pseudo<
1604 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I8",
1605 [(set i32:$dst, (atomic_load_sub_8 xoaddr:$ptr, i32:$incr))]>;
1606 def ATOMIC_LOAD_AND_I8 : Pseudo<
1607 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I8",
1608 [(set i32:$dst, (atomic_load_and_8 xoaddr:$ptr, i32:$incr))]>;
1609 def ATOMIC_LOAD_OR_I8 : Pseudo<
1610 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I8",
1611 [(set i32:$dst, (atomic_load_or_8 xoaddr:$ptr, i32:$incr))]>;
1612 def ATOMIC_LOAD_XOR_I8 : Pseudo<
1613 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "ATOMIC_LOAD_XOR_I8",
1614 [(set i32:$dst, (atomic_load_xor_8 xoaddr:$ptr, i32:$incr))]>;
1615 def ATOMIC_LOAD_NAND_I8 : Pseudo<
1616 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I8",
1617 [(set i32:$dst, (atomic_load_nand_8 xoaddr:$ptr, i32:$incr))]>;
1618 def ATOMIC_LOAD_MIN_I8 : Pseudo<
1619 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MIN_I8",
1620 [(set i32:$dst, (atomic_load_min_8 xoaddr:$ptr, i32:$incr))]>;
1621 def ATOMIC_LOAD_MAX_I8 : Pseudo<
1622 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MAX_I8",
1623 [(set i32:$dst, (atomic_load_max_8 xoaddr:$ptr, i32:$incr))]>;
1624 def ATOMIC_LOAD_UMIN_I8 : Pseudo<
1625 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMIN_I8",
1626 [(set i32:$dst, (atomic_load_umin_8 xoaddr:$ptr, i32:$incr))]>;
1627 def ATOMIC_LOAD_UMAX_I8 : Pseudo<
1628 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMAX_I8",
1629 [(set i32:$dst, (atomic_load_umax_8 xoaddr:$ptr, i32:$incr))]>;
1630 def ATOMIC_LOAD_ADD_I16 : Pseudo<
1631 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I16",
1632 [(set i32:$dst, (atomic_load_add_16 xoaddr:$ptr, i32:$incr))]>;
1633 def ATOMIC_LOAD_SUB_I16 : Pseudo<
1634 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I16",
1635 [(set i32:$dst, (atomic_load_sub_16 xoaddr:$ptr, i32:$incr))]>;
1636 def ATOMIC_LOAD_AND_I16 : Pseudo<
1637 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I16",
1638 [(set i32:$dst, (atomic_load_and_16 xoaddr:$ptr, i32:$incr))]>;
1639 def ATOMIC_LOAD_OR_I16 : Pseudo<
1640 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I16",
1641 [(set i32:$dst, (atomic_load_or_16 xoaddr:$ptr, i32:$incr))]>;
1642 def ATOMIC_LOAD_XOR_I16 : Pseudo<
1643 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_XOR_I16",
1644 [(set i32:$dst, (atomic_load_xor_16 xoaddr:$ptr, i32:$incr))]>;
1645 def ATOMIC_LOAD_NAND_I16 : Pseudo<
1646 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I16",
1647 [(set i32:$dst, (atomic_load_nand_16 xoaddr:$ptr, i32:$incr))]>;
1648 def ATOMIC_LOAD_MIN_I16 : Pseudo<
1649 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MIN_I16",
1650 [(set i32:$dst, (atomic_load_min_16 xoaddr:$ptr, i32:$incr))]>;
1651 def ATOMIC_LOAD_MAX_I16 : Pseudo<
1652 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MAX_I16",
1653 [(set i32:$dst, (atomic_load_max_16 xoaddr:$ptr, i32:$incr))]>;
1654 def ATOMIC_LOAD_UMIN_I16 : Pseudo<
1655 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMIN_I16",
1656 [(set i32:$dst, (atomic_load_umin_16 xoaddr:$ptr, i32:$incr))]>;
1657 def ATOMIC_LOAD_UMAX_I16 : Pseudo<
1658 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMAX_I16",
1659 [(set i32:$dst, (atomic_load_umax_16 xoaddr:$ptr, i32:$incr))]>;
1660 def ATOMIC_LOAD_ADD_I32 : Pseudo<
1661 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I32",
1662 [(set i32:$dst, (atomic_load_add_32 xoaddr:$ptr, i32:$incr))]>;
1663 def ATOMIC_LOAD_SUB_I32 : Pseudo<
1664 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I32",
1665 [(set i32:$dst, (atomic_load_sub_32 xoaddr:$ptr, i32:$incr))]>;
1666 def ATOMIC_LOAD_AND_I32 : Pseudo<
1667 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I32",
1668 [(set i32:$dst, (atomic_load_and_32 xoaddr:$ptr, i32:$incr))]>;
1669 def ATOMIC_LOAD_OR_I32 : Pseudo<
1670 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I32",
1671 [(set i32:$dst, (atomic_load_or_32 xoaddr:$ptr, i32:$incr))]>;
1672 def ATOMIC_LOAD_XOR_I32 : Pseudo<
1673 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_XOR_I32",
1674 [(set i32:$dst, (atomic_load_xor_32 xoaddr:$ptr, i32:$incr))]>;
1675 def ATOMIC_LOAD_NAND_I32 : Pseudo<
1676 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I32",
1677 [(set i32:$dst, (atomic_load_nand_32 xoaddr:$ptr, i32:$incr))]>;
1678 def ATOMIC_LOAD_MIN_I32 : Pseudo<
1679 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MIN_I32",
1680 [(set i32:$dst, (atomic_load_min_32 xoaddr:$ptr, i32:$incr))]>;
1681 def ATOMIC_LOAD_MAX_I32 : Pseudo<
1682 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MAX_I32",
1683 [(set i32:$dst, (atomic_load_max_32 xoaddr:$ptr, i32:$incr))]>;
1684 def ATOMIC_LOAD_UMIN_I32 : Pseudo<
1685 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMIN_I32",
1686 [(set i32:$dst, (atomic_load_umin_32 xoaddr:$ptr, i32:$incr))]>;
1687 def ATOMIC_LOAD_UMAX_I32 : Pseudo<
1688 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMAX_I32",
1689 [(set i32:$dst, (atomic_load_umax_32 xoaddr:$ptr, i32:$incr))]>;
1691 def ATOMIC_CMP_SWAP_I8 : Pseudo<
1692 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I8",
1693 [(set i32:$dst, (atomic_cmp_swap_8 xoaddr:$ptr, i32:$old, i32:$new))]>;
1694 def ATOMIC_CMP_SWAP_I16 : Pseudo<
1695 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I16 $dst $ptr $old $new",
1696 [(set i32:$dst, (atomic_cmp_swap_16 xoaddr:$ptr, i32:$old, i32:$new))]>;
1697 def ATOMIC_CMP_SWAP_I32 : Pseudo<
1698 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I32 $dst $ptr $old $new",
1699 [(set i32:$dst, (atomic_cmp_swap_32 xoaddr:$ptr, i32:$old, i32:$new))]>;
1701 def ATOMIC_SWAP_I8 : Pseudo<
1702 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_i8",
1703 [(set i32:$dst, (atomic_swap_8 xoaddr:$ptr, i32:$new))]>;
1704 def ATOMIC_SWAP_I16 : Pseudo<
1705 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_I16",
1706 [(set i32:$dst, (atomic_swap_16 xoaddr:$ptr, i32:$new))]>;
1707 def ATOMIC_SWAP_I32 : Pseudo<
1708 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_I32",
1709 [(set i32:$dst, (atomic_swap_32 xoaddr:$ptr, i32:$new))]>;
1713 // Instructions to support atomic operations
1714 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in {
1715 def LBARX : XForm_1<31, 52, (outs gprc:$rD), (ins memrr:$src),
1716 "lbarx $rD, $src", IIC_LdStLWARX, []>,
1717 Requires<[HasPartwordAtomics]>;
1719 def LHARX : XForm_1<31, 116, (outs gprc:$rD), (ins memrr:$src),
1720 "lharx $rD, $src", IIC_LdStLWARX, []>,
1721 Requires<[HasPartwordAtomics]>;
1723 def LWARX : XForm_1<31, 20, (outs gprc:$rD), (ins memrr:$src),
1724 "lwarx $rD, $src", IIC_LdStLWARX, []>;
1726 // Instructions to support lock versions of atomics
1727 // (EH=1 - see Power ISA 2.07 Book II 4.4.2)
1728 def LBARXL : XForm_1<31, 52, (outs gprc:$rD), (ins memrr:$src),
1729 "lbarx $rD, $src, 1", IIC_LdStLWARX, []>, isDOT,
1730 Requires<[HasPartwordAtomics]>;
1732 def LHARXL : XForm_1<31, 116, (outs gprc:$rD), (ins memrr:$src),
1733 "lharx $rD, $src, 1", IIC_LdStLWARX, []>, isDOT,
1734 Requires<[HasPartwordAtomics]>;
1736 def LWARXL : XForm_1<31, 20, (outs gprc:$rD), (ins memrr:$src),
1737 "lwarx $rD, $src, 1", IIC_LdStLWARX, []>, isDOT;
1739 // The atomic instructions use the destination register as well as the next one
1740 // or two registers in order (modulo 31).
1741 let hasExtraSrcRegAllocReq = 1 in
1742 def LWAT : X_RD5_RS5_IM5<31, 582, (outs gprc:$rD), (ins gprc:$rA, u5imm:$FC),
1743 "lwat $rD, $rA, $FC", IIC_LdStLoad>,
1744 Requires<[IsISA3_0]>;
1747 let Defs = [CR0], mayStore = 1, mayLoad = 0, hasSideEffects = 0 in {
1748 def STBCX : XForm_1<31, 694, (outs), (ins gprc:$rS, memrr:$dst),
1749 "stbcx. $rS, $dst", IIC_LdStSTWCX, []>,
1750 isDOT, Requires<[HasPartwordAtomics]>;
1752 def STHCX : XForm_1<31, 726, (outs), (ins gprc:$rS, memrr:$dst),
1753 "sthcx. $rS, $dst", IIC_LdStSTWCX, []>,
1754 isDOT, Requires<[HasPartwordAtomics]>;
1756 def STWCX : XForm_1<31, 150, (outs), (ins gprc:$rS, memrr:$dst),
1757 "stwcx. $rS, $dst", IIC_LdStSTWCX, []>, isDOT;
1760 let mayStore = 1, mayLoad = 0, hasSideEffects = 0 in
1761 def STWAT : X_RD5_RS5_IM5<31, 710, (outs), (ins gprc:$rS, gprc:$rA, u5imm:$FC),
1762 "stwat $rS, $rA, $FC", IIC_LdStStore>,
1763 Requires<[IsISA3_0]>;
1765 let isTerminator = 1, isBarrier = 1, hasCtrlDep = 1 in
1766 def TRAP : XForm_24<31, 4, (outs), (ins), "trap", IIC_LdStLoad, [(trap)]>;
1768 def TWI : DForm_base<3, (outs), (ins u5imm:$to, gprc:$rA, s16imm:$imm),
1769 "twi $to, $rA, $imm", IIC_IntTrapW, []>;
1770 def TW : XForm_1<31, 4, (outs), (ins u5imm:$to, gprc:$rA, gprc:$rB),
1771 "tw $to, $rA, $rB", IIC_IntTrapW, []>;
1772 def TDI : DForm_base<2, (outs), (ins u5imm:$to, g8rc:$rA, s16imm:$imm),
1773 "tdi $to, $rA, $imm", IIC_IntTrapD, []>;
1774 def TD : XForm_1<31, 68, (outs), (ins u5imm:$to, g8rc:$rA, g8rc:$rB),
1775 "td $to, $rA, $rB", IIC_IntTrapD, []>;
1777 //===----------------------------------------------------------------------===//
1778 // PPC32 Load Instructions.
1781 // Unindexed (r+i) Loads.
1782 let PPC970_Unit = 2 in {
1783 def LBZ : DForm_1<34, (outs gprc:$rD), (ins memri:$src),
1784 "lbz $rD, $src", IIC_LdStLoad,
1785 [(set i32:$rD, (zextloadi8 iaddr:$src))]>;
1786 def LHA : DForm_1<42, (outs gprc:$rD), (ins memri:$src),
1787 "lha $rD, $src", IIC_LdStLHA,
1788 [(set i32:$rD, (sextloadi16 iaddr:$src))]>,
1789 PPC970_DGroup_Cracked;
1790 def LHZ : DForm_1<40, (outs gprc:$rD), (ins memri:$src),
1791 "lhz $rD, $src", IIC_LdStLoad,
1792 [(set i32:$rD, (zextloadi16 iaddr:$src))]>;
1793 def LWZ : DForm_1<32, (outs gprc:$rD), (ins memri:$src),
1794 "lwz $rD, $src", IIC_LdStLoad,
1795 [(set i32:$rD, (load iaddr:$src))]>;
1797 def LFS : DForm_1<48, (outs f4rc:$rD), (ins memri:$src),
1798 "lfs $rD, $src", IIC_LdStLFD,
1799 [(set f32:$rD, (load iaddr:$src))]>;
1800 def LFD : DForm_1<50, (outs f8rc:$rD), (ins memri:$src),
1801 "lfd $rD, $src", IIC_LdStLFD,
1802 [(set f64:$rD, (load iaddr:$src))]>;
1805 // Unindexed (r+i) Loads with Update (preinc).
1806 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in {
1807 def LBZU : DForm_1<35, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1808 "lbzu $rD, $addr", IIC_LdStLoadUpd,
1809 []>, RegConstraint<"$addr.reg = $ea_result">,
1810 NoEncode<"$ea_result">;
1812 def LHAU : DForm_1<43, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1813 "lhau $rD, $addr", IIC_LdStLHAU,
1814 []>, RegConstraint<"$addr.reg = $ea_result">,
1815 NoEncode<"$ea_result">;
1817 def LHZU : DForm_1<41, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1818 "lhzu $rD, $addr", IIC_LdStLoadUpd,
1819 []>, RegConstraint<"$addr.reg = $ea_result">,
1820 NoEncode<"$ea_result">;
1822 def LWZU : DForm_1<33, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1823 "lwzu $rD, $addr", IIC_LdStLoadUpd,
1824 []>, RegConstraint<"$addr.reg = $ea_result">,
1825 NoEncode<"$ea_result">;
1827 def LFSU : DForm_1<49, (outs f4rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1828 "lfsu $rD, $addr", IIC_LdStLFDU,
1829 []>, RegConstraint<"$addr.reg = $ea_result">,
1830 NoEncode<"$ea_result">;
1832 def LFDU : DForm_1<51, (outs f8rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1833 "lfdu $rD, $addr", IIC_LdStLFDU,
1834 []>, RegConstraint<"$addr.reg = $ea_result">,
1835 NoEncode<"$ea_result">;
1838 // Indexed (r+r) Loads with Update (preinc).
1839 def LBZUX : XForm_1<31, 119, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1841 "lbzux $rD, $addr", IIC_LdStLoadUpdX,
1842 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1843 NoEncode<"$ea_result">;
1845 def LHAUX : XForm_1<31, 375, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1847 "lhaux $rD, $addr", IIC_LdStLHAUX,
1848 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1849 NoEncode<"$ea_result">;
1851 def LHZUX : XForm_1<31, 311, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1853 "lhzux $rD, $addr", IIC_LdStLoadUpdX,
1854 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1855 NoEncode<"$ea_result">;
1857 def LWZUX : XForm_1<31, 55, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1859 "lwzux $rD, $addr", IIC_LdStLoadUpdX,
1860 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1861 NoEncode<"$ea_result">;
1863 def LFSUX : XForm_1<31, 567, (outs f4rc:$rD, ptr_rc_nor0:$ea_result),
1865 "lfsux $rD, $addr", IIC_LdStLFDUX,
1866 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1867 NoEncode<"$ea_result">;
1869 def LFDUX : XForm_1<31, 631, (outs f8rc:$rD, ptr_rc_nor0:$ea_result),
1871 "lfdux $rD, $addr", IIC_LdStLFDUX,
1872 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1873 NoEncode<"$ea_result">;
1877 // Indexed (r+r) Loads.
1879 let PPC970_Unit = 2, mayLoad = 1, mayStore = 0 in {
1880 def LBZX : XForm_1<31, 87, (outs gprc:$rD), (ins memrr:$src),
1881 "lbzx $rD, $src", IIC_LdStLoad,
1882 [(set i32:$rD, (zextloadi8 xaddr:$src))]>;
1883 def LHAX : XForm_1<31, 343, (outs gprc:$rD), (ins memrr:$src),
1884 "lhax $rD, $src", IIC_LdStLHA,
1885 [(set i32:$rD, (sextloadi16 xaddr:$src))]>,
1886 PPC970_DGroup_Cracked;
1887 def LHZX : XForm_1<31, 279, (outs gprc:$rD), (ins memrr:$src),
1888 "lhzx $rD, $src", IIC_LdStLoad,
1889 [(set i32:$rD, (zextloadi16 xaddr:$src))]>;
1890 def LWZX : XForm_1<31, 23, (outs gprc:$rD), (ins memrr:$src),
1891 "lwzx $rD, $src", IIC_LdStLoad,
1892 [(set i32:$rD, (load xaddr:$src))]>;
1893 def LHBRX : XForm_1<31, 790, (outs gprc:$rD), (ins memrr:$src),
1894 "lhbrx $rD, $src", IIC_LdStLoad,
1895 [(set i32:$rD, (PPClbrx xoaddr:$src, i16))]>;
1896 def LWBRX : XForm_1<31, 534, (outs gprc:$rD), (ins memrr:$src),
1897 "lwbrx $rD, $src", IIC_LdStLoad,
1898 [(set i32:$rD, (PPClbrx xoaddr:$src, i32))]>;
1900 def LFSX : XForm_25<31, 535, (outs f4rc:$frD), (ins memrr:$src),
1901 "lfsx $frD, $src", IIC_LdStLFD,
1902 [(set f32:$frD, (load xaddr:$src))]>;
1903 def LFDX : XForm_25<31, 599, (outs f8rc:$frD), (ins memrr:$src),
1904 "lfdx $frD, $src", IIC_LdStLFD,
1905 [(set f64:$frD, (load xaddr:$src))]>;
1907 def LFIWAX : XForm_25<31, 855, (outs f8rc:$frD), (ins memrr:$src),
1908 "lfiwax $frD, $src", IIC_LdStLFD,
1909 [(set f64:$frD, (PPClfiwax xoaddr:$src))]>;
1910 def LFIWZX : XForm_25<31, 887, (outs f8rc:$frD), (ins memrr:$src),
1911 "lfiwzx $frD, $src", IIC_LdStLFD,
1912 [(set f64:$frD, (PPClfiwzx xoaddr:$src))]>;
1916 def LMW : DForm_1<46, (outs gprc:$rD), (ins memri:$src),
1917 "lmw $rD, $src", IIC_LdStLMW, []>;
1919 //===----------------------------------------------------------------------===//
1920 // PPC32 Store Instructions.
1923 // Unindexed (r+i) Stores.
1924 let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in {
1925 def STB : DForm_1<38, (outs), (ins gprc:$rS, memri:$src),
1926 "stb $rS, $src", IIC_LdStStore,
1927 [(truncstorei8 i32:$rS, iaddr:$src)]>;
1928 def STH : DForm_1<44, (outs), (ins gprc:$rS, memri:$src),
1929 "sth $rS, $src", IIC_LdStStore,
1930 [(truncstorei16 i32:$rS, iaddr:$src)]>;
1931 def STW : DForm_1<36, (outs), (ins gprc:$rS, memri:$src),
1932 "stw $rS, $src", IIC_LdStStore,
1933 [(store i32:$rS, iaddr:$src)]>;
1934 def STFS : DForm_1<52, (outs), (ins f4rc:$rS, memri:$dst),
1935 "stfs $rS, $dst", IIC_LdStSTFD,
1936 [(store f32:$rS, iaddr:$dst)]>;
1937 def STFD : DForm_1<54, (outs), (ins f8rc:$rS, memri:$dst),
1938 "stfd $rS, $dst", IIC_LdStSTFD,
1939 [(store f64:$rS, iaddr:$dst)]>;
1942 // Unindexed (r+i) Stores with Update (preinc).
1943 let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in {
1944 def STBU : DForm_1<39, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst),
1945 "stbu $rS, $dst", IIC_LdStStoreUpd, []>,
1946 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
1947 def STHU : DForm_1<45, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst),
1948 "sthu $rS, $dst", IIC_LdStStoreUpd, []>,
1949 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
1950 def STWU : DForm_1<37, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst),
1951 "stwu $rS, $dst", IIC_LdStStoreUpd, []>,
1952 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
1953 def STFSU : DForm_1<53, (outs ptr_rc_nor0:$ea_res), (ins f4rc:$rS, memri:$dst),
1954 "stfsu $rS, $dst", IIC_LdStSTFDU, []>,
1955 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
1956 def STFDU : DForm_1<55, (outs ptr_rc_nor0:$ea_res), (ins f8rc:$rS, memri:$dst),
1957 "stfdu $rS, $dst", IIC_LdStSTFDU, []>,
1958 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
1961 // Patterns to match the pre-inc stores. We can't put the patterns on
1962 // the instruction definitions directly as ISel wants the address base
1963 // and offset to be separate operands, not a single complex operand.
1964 def : Pat<(pre_truncsti8 i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1965 (STBU $rS, iaddroff:$ptroff, $ptrreg)>;
1966 def : Pat<(pre_truncsti16 i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1967 (STHU $rS, iaddroff:$ptroff, $ptrreg)>;
1968 def : Pat<(pre_store i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1969 (STWU $rS, iaddroff:$ptroff, $ptrreg)>;
1970 def : Pat<(pre_store f32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1971 (STFSU $rS, iaddroff:$ptroff, $ptrreg)>;
1972 def : Pat<(pre_store f64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1973 (STFDU $rS, iaddroff:$ptroff, $ptrreg)>;
1975 // Indexed (r+r) Stores.
1976 let PPC970_Unit = 2 in {
1977 def STBX : XForm_8<31, 215, (outs), (ins gprc:$rS, memrr:$dst),
1978 "stbx $rS, $dst", IIC_LdStStore,
1979 [(truncstorei8 i32:$rS, xaddr:$dst)]>,
1980 PPC970_DGroup_Cracked;
1981 def STHX : XForm_8<31, 407, (outs), (ins gprc:$rS, memrr:$dst),
1982 "sthx $rS, $dst", IIC_LdStStore,
1983 [(truncstorei16 i32:$rS, xaddr:$dst)]>,
1984 PPC970_DGroup_Cracked;
1985 def STWX : XForm_8<31, 151, (outs), (ins gprc:$rS, memrr:$dst),
1986 "stwx $rS, $dst", IIC_LdStStore,
1987 [(store i32:$rS, xaddr:$dst)]>,
1988 PPC970_DGroup_Cracked;
1990 def STHBRX: XForm_8<31, 918, (outs), (ins gprc:$rS, memrr:$dst),
1991 "sthbrx $rS, $dst", IIC_LdStStore,
1992 [(PPCstbrx i32:$rS, xoaddr:$dst, i16)]>,
1993 PPC970_DGroup_Cracked;
1994 def STWBRX: XForm_8<31, 662, (outs), (ins gprc:$rS, memrr:$dst),
1995 "stwbrx $rS, $dst", IIC_LdStStore,
1996 [(PPCstbrx i32:$rS, xoaddr:$dst, i32)]>,
1997 PPC970_DGroup_Cracked;
1999 def STFIWX: XForm_28<31, 983, (outs), (ins f8rc:$frS, memrr:$dst),
2000 "stfiwx $frS, $dst", IIC_LdStSTFD,
2001 [(PPCstfiwx f64:$frS, xoaddr:$dst)]>;
2003 def STFSX : XForm_28<31, 663, (outs), (ins f4rc:$frS, memrr:$dst),
2004 "stfsx $frS, $dst", IIC_LdStSTFD,
2005 [(store f32:$frS, xaddr:$dst)]>;
2006 def STFDX : XForm_28<31, 727, (outs), (ins f8rc:$frS, memrr:$dst),
2007 "stfdx $frS, $dst", IIC_LdStSTFD,
2008 [(store f64:$frS, xaddr:$dst)]>;
2011 // Indexed (r+r) Stores with Update (preinc).
2012 let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in {
2013 def STBUX : XForm_8<31, 247, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memrr:$dst),
2014 "stbux $rS, $dst", IIC_LdStStoreUpd, []>,
2015 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
2016 PPC970_DGroup_Cracked;
2017 def STHUX : XForm_8<31, 439, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memrr:$dst),
2018 "sthux $rS, $dst", IIC_LdStStoreUpd, []>,
2019 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
2020 PPC970_DGroup_Cracked;
2021 def STWUX : XForm_8<31, 183, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memrr:$dst),
2022 "stwux $rS, $dst", IIC_LdStStoreUpd, []>,
2023 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
2024 PPC970_DGroup_Cracked;
2025 def STFSUX: XForm_8<31, 695, (outs ptr_rc_nor0:$ea_res), (ins f4rc:$rS, memrr:$dst),
2026 "stfsux $rS, $dst", IIC_LdStSTFDU, []>,
2027 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
2028 PPC970_DGroup_Cracked;
2029 def STFDUX: XForm_8<31, 759, (outs ptr_rc_nor0:$ea_res), (ins f8rc:$rS, memrr:$dst),
2030 "stfdux $rS, $dst", IIC_LdStSTFDU, []>,
2031 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
2032 PPC970_DGroup_Cracked;
2035 // Patterns to match the pre-inc stores. We can't put the patterns on
2036 // the instruction definitions directly as ISel wants the address base
2037 // and offset to be separate operands, not a single complex operand.
2038 def : Pat<(pre_truncsti8 i32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2039 (STBUX $rS, $ptrreg, $ptroff)>;
2040 def : Pat<(pre_truncsti16 i32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2041 (STHUX $rS, $ptrreg, $ptroff)>;
2042 def : Pat<(pre_store i32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2043 (STWUX $rS, $ptrreg, $ptroff)>;
2044 def : Pat<(pre_store f32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2045 (STFSUX $rS, $ptrreg, $ptroff)>;
2046 def : Pat<(pre_store f64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2047 (STFDUX $rS, $ptrreg, $ptroff)>;
2050 def STMW : DForm_1<47, (outs), (ins gprc:$rS, memri:$dst),
2051 "stmw $rS, $dst", IIC_LdStLMW, []>;
2053 def SYNC : XForm_24_sync<31, 598, (outs), (ins i32imm:$L),
2054 "sync $L", IIC_LdStSync, []>;
2056 let isCodeGenOnly = 1 in {
2057 def MSYNC : XForm_24_sync<31, 598, (outs), (ins),
2058 "msync", IIC_LdStSync, []> {
2063 def : Pat<(int_ppc_sync), (SYNC 0)>, Requires<[HasSYNC]>;
2064 def : Pat<(int_ppc_lwsync), (SYNC 1)>, Requires<[HasSYNC]>;
2065 def : Pat<(int_ppc_sync), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
2066 def : Pat<(int_ppc_lwsync), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
2068 //===----------------------------------------------------------------------===//
2069 // PPC32 Arithmetic Instructions.
2072 let PPC970_Unit = 1 in { // FXU Operations.
2073 def ADDI : DForm_2<14, (outs gprc:$rD), (ins gprc_nor0:$rA, s16imm:$imm),
2074 "addi $rD, $rA, $imm", IIC_IntSimple,
2075 [(set i32:$rD, (add i32:$rA, imm32SExt16:$imm))]>;
2076 let BaseName = "addic" in {
2077 let Defs = [CARRY] in
2078 def ADDIC : DForm_2<12, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
2079 "addic $rD, $rA, $imm", IIC_IntGeneral,
2080 [(set i32:$rD, (addc i32:$rA, imm32SExt16:$imm))]>,
2081 RecFormRel, PPC970_DGroup_Cracked;
2082 let Defs = [CARRY, CR0] in
2083 def ADDICo : DForm_2<13, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
2084 "addic. $rD, $rA, $imm", IIC_IntGeneral,
2085 []>, isDOT, RecFormRel;
2087 def ADDIS : DForm_2<15, (outs gprc:$rD), (ins gprc_nor0:$rA, s17imm:$imm),
2088 "addis $rD, $rA, $imm", IIC_IntSimple,
2089 [(set i32:$rD, (add i32:$rA, imm16ShiftedSExt:$imm))]>;
2090 let isCodeGenOnly = 1 in
2091 def LA : DForm_2<14, (outs gprc:$rD), (ins gprc_nor0:$rA, s16imm:$sym),
2092 "la $rD, $sym($rA)", IIC_IntGeneral,
2093 [(set i32:$rD, (add i32:$rA,
2094 (PPClo tglobaladdr:$sym, 0)))]>;
2095 def MULLI : DForm_2< 7, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
2096 "mulli $rD, $rA, $imm", IIC_IntMulLI,
2097 [(set i32:$rD, (mul i32:$rA, imm32SExt16:$imm))]>;
2098 let Defs = [CARRY] in
2099 def SUBFIC : DForm_2< 8, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
2100 "subfic $rD, $rA, $imm", IIC_IntGeneral,
2101 [(set i32:$rD, (subc imm32SExt16:$imm, i32:$rA))]>;
2103 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in {
2104 def LI : DForm_2_r0<14, (outs gprc:$rD), (ins s16imm:$imm),
2105 "li $rD, $imm", IIC_IntSimple,
2106 [(set i32:$rD, imm32SExt16:$imm)]>;
2107 def LIS : DForm_2_r0<15, (outs gprc:$rD), (ins s17imm:$imm),
2108 "lis $rD, $imm", IIC_IntSimple,
2109 [(set i32:$rD, imm16ShiftedSExt:$imm)]>;
2113 let PPC970_Unit = 1 in { // FXU Operations.
2114 let Defs = [CR0] in {
2115 def ANDIo : DForm_4<28, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2116 "andi. $dst, $src1, $src2", IIC_IntGeneral,
2117 [(set i32:$dst, (and i32:$src1, immZExt16:$src2))]>,
2119 def ANDISo : DForm_4<29, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2120 "andis. $dst, $src1, $src2", IIC_IntGeneral,
2121 [(set i32:$dst, (and i32:$src1, imm16ShiftedZExt:$src2))]>,
2124 def ORI : DForm_4<24, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2125 "ori $dst, $src1, $src2", IIC_IntSimple,
2126 [(set i32:$dst, (or i32:$src1, immZExt16:$src2))]>;
2127 def ORIS : DForm_4<25, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2128 "oris $dst, $src1, $src2", IIC_IntSimple,
2129 [(set i32:$dst, (or i32:$src1, imm16ShiftedZExt:$src2))]>;
2130 def XORI : DForm_4<26, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2131 "xori $dst, $src1, $src2", IIC_IntSimple,
2132 [(set i32:$dst, (xor i32:$src1, immZExt16:$src2))]>;
2133 def XORIS : DForm_4<27, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2134 "xoris $dst, $src1, $src2", IIC_IntSimple,
2135 [(set i32:$dst, (xor i32:$src1, imm16ShiftedZExt:$src2))]>;
2137 def NOP : DForm_4_zero<24, (outs), (ins), "nop", IIC_IntSimple,
2139 let isCodeGenOnly = 1 in {
2140 // The POWER6 and POWER7 have special group-terminating nops.
2141 def NOP_GT_PWR6 : DForm_4_fixedreg_zero<24, 1, (outs), (ins),
2142 "ori 1, 1, 0", IIC_IntSimple, []>;
2143 def NOP_GT_PWR7 : DForm_4_fixedreg_zero<24, 2, (outs), (ins),
2144 "ori 2, 2, 0", IIC_IntSimple, []>;
2147 let isCompare = 1, hasSideEffects = 0 in {
2148 def CMPWI : DForm_5_ext<11, (outs crrc:$crD), (ins gprc:$rA, s16imm:$imm),
2149 "cmpwi $crD, $rA, $imm", IIC_IntCompare>;
2150 def CMPLWI : DForm_6_ext<10, (outs crrc:$dst), (ins gprc:$src1, u16imm:$src2),
2151 "cmplwi $dst, $src1, $src2", IIC_IntCompare>;
2152 def CMPRB : X_BF3_L1_RS5_RS5<31, 192, (outs crbitrc:$BF),
2153 (ins u1imm:$L, g8rc:$rA, g8rc:$rB),
2154 "cmprb $BF, $L, $rA, $rB", IIC_IntCompare, []>,
2155 Requires<[IsISA3_0]>;
2159 let PPC970_Unit = 1, hasSideEffects = 0 in { // FXU Operations.
2160 let isCommutable = 1 in {
2161 defm NAND : XForm_6r<31, 476, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2162 "nand", "$rA, $rS, $rB", IIC_IntSimple,
2163 [(set i32:$rA, (not (and i32:$rS, i32:$rB)))]>;
2164 defm AND : XForm_6r<31, 28, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2165 "and", "$rA, $rS, $rB", IIC_IntSimple,
2166 [(set i32:$rA, (and i32:$rS, i32:$rB))]>;
2168 defm ANDC : XForm_6r<31, 60, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2169 "andc", "$rA, $rS, $rB", IIC_IntSimple,
2170 [(set i32:$rA, (and i32:$rS, (not i32:$rB)))]>;
2171 let isCommutable = 1 in {
2172 defm OR : XForm_6r<31, 444, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2173 "or", "$rA, $rS, $rB", IIC_IntSimple,
2174 [(set i32:$rA, (or i32:$rS, i32:$rB))]>;
2175 defm NOR : XForm_6r<31, 124, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2176 "nor", "$rA, $rS, $rB", IIC_IntSimple,
2177 [(set i32:$rA, (not (or i32:$rS, i32:$rB)))]>;
2179 defm ORC : XForm_6r<31, 412, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2180 "orc", "$rA, $rS, $rB", IIC_IntSimple,
2181 [(set i32:$rA, (or i32:$rS, (not i32:$rB)))]>;
2182 let isCommutable = 1 in {
2183 defm EQV : XForm_6r<31, 284, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2184 "eqv", "$rA, $rS, $rB", IIC_IntSimple,
2185 [(set i32:$rA, (not (xor i32:$rS, i32:$rB)))]>;
2186 defm XOR : XForm_6r<31, 316, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2187 "xor", "$rA, $rS, $rB", IIC_IntSimple,
2188 [(set i32:$rA, (xor i32:$rS, i32:$rB))]>;
2190 defm SLW : XForm_6r<31, 24, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2191 "slw", "$rA, $rS, $rB", IIC_IntGeneral,
2192 [(set i32:$rA, (PPCshl i32:$rS, i32:$rB))]>;
2193 defm SRW : XForm_6r<31, 536, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2194 "srw", "$rA, $rS, $rB", IIC_IntGeneral,
2195 [(set i32:$rA, (PPCsrl i32:$rS, i32:$rB))]>;
2196 defm SRAW : XForm_6rc<31, 792, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2197 "sraw", "$rA, $rS, $rB", IIC_IntShift,
2198 [(set i32:$rA, (PPCsra i32:$rS, i32:$rB))]>;
2201 let PPC970_Unit = 1 in { // FXU Operations.
2202 let hasSideEffects = 0 in {
2203 defm SRAWI : XForm_10rc<31, 824, (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH),
2204 "srawi", "$rA, $rS, $SH", IIC_IntShift,
2205 [(set i32:$rA, (sra i32:$rS, (i32 imm:$SH)))]>;
2206 defm CNTLZW : XForm_11r<31, 26, (outs gprc:$rA), (ins gprc:$rS),
2207 "cntlzw", "$rA, $rS", IIC_IntGeneral,
2208 [(set i32:$rA, (ctlz i32:$rS))]>;
2209 defm CNTTZW : XForm_11r<31, 538, (outs gprc:$rA), (ins gprc:$rS),
2210 "cnttzw", "$rA, $rS", IIC_IntGeneral,
2211 [(set i32:$rA, (cttz i32:$rS))]>, Requires<[IsISA3_0]>;
2212 defm EXTSB : XForm_11r<31, 954, (outs gprc:$rA), (ins gprc:$rS),
2213 "extsb", "$rA, $rS", IIC_IntSimple,
2214 [(set i32:$rA, (sext_inreg i32:$rS, i8))]>;
2215 defm EXTSH : XForm_11r<31, 922, (outs gprc:$rA), (ins gprc:$rS),
2216 "extsh", "$rA, $rS", IIC_IntSimple,
2217 [(set i32:$rA, (sext_inreg i32:$rS, i16))]>;
2219 let isCommutable = 1 in
2220 def CMPB : XForm_6<31, 508, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2221 "cmpb $rA, $rS, $rB", IIC_IntGeneral,
2222 [(set i32:$rA, (PPCcmpb i32:$rS, i32:$rB))]>;
2224 let isCompare = 1, hasSideEffects = 0 in {
2225 def CMPW : XForm_16_ext<31, 0, (outs crrc:$crD), (ins gprc:$rA, gprc:$rB),
2226 "cmpw $crD, $rA, $rB", IIC_IntCompare>;
2227 def CMPLW : XForm_16_ext<31, 32, (outs crrc:$crD), (ins gprc:$rA, gprc:$rB),
2228 "cmplw $crD, $rA, $rB", IIC_IntCompare>;
2231 let PPC970_Unit = 3 in { // FPU Operations.
2232 //def FCMPO : XForm_17<63, 32, (outs CRRC:$crD), (ins FPRC:$fA, FPRC:$fB),
2233 // "fcmpo $crD, $fA, $fB", IIC_FPCompare>;
2234 let isCompare = 1, hasSideEffects = 0 in {
2235 def FCMPUS : XForm_17<63, 0, (outs crrc:$crD), (ins f4rc:$fA, f4rc:$fB),
2236 "fcmpu $crD, $fA, $fB", IIC_FPCompare>;
2237 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2238 def FCMPUD : XForm_17<63, 0, (outs crrc:$crD), (ins f8rc:$fA, f8rc:$fB),
2239 "fcmpu $crD, $fA, $fB", IIC_FPCompare>;
2242 def FTDIV: XForm_17<63, 128, (outs crrc:$crD), (ins f8rc:$fA, f8rc:$fB),
2243 "ftdiv $crD, $fA, $fB", IIC_FPCompare>;
2244 def FTSQRT: XForm_17a<63, 160, (outs crrc:$crD), (ins f8rc:$fB),
2245 "ftsqrt $crD, $fB", IIC_FPCompare>;
2247 let Uses = [RM] in {
2248 let hasSideEffects = 0 in {
2249 defm FCTIW : XForm_26r<63, 14, (outs f8rc:$frD), (ins f8rc:$frB),
2250 "fctiw", "$frD, $frB", IIC_FPGeneral,
2252 defm FCTIWU : XForm_26r<63, 142, (outs f8rc:$frD), (ins f8rc:$frB),
2253 "fctiwu", "$frD, $frB", IIC_FPGeneral,
2255 defm FCTIWZ : XForm_26r<63, 15, (outs f8rc:$frD), (ins f8rc:$frB),
2256 "fctiwz", "$frD, $frB", IIC_FPGeneral,
2257 [(set f64:$frD, (PPCfctiwz f64:$frB))]>;
2259 defm FRSP : XForm_26r<63, 12, (outs f4rc:$frD), (ins f8rc:$frB),
2260 "frsp", "$frD, $frB", IIC_FPGeneral,
2261 [(set f32:$frD, (fpround f64:$frB))]>;
2263 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2264 defm FRIND : XForm_26r<63, 392, (outs f8rc:$frD), (ins f8rc:$frB),
2265 "frin", "$frD, $frB", IIC_FPGeneral,
2266 [(set f64:$frD, (fround f64:$frB))]>;
2267 defm FRINS : XForm_26r<63, 392, (outs f4rc:$frD), (ins f4rc:$frB),
2268 "frin", "$frD, $frB", IIC_FPGeneral,
2269 [(set f32:$frD, (fround f32:$frB))]>;
2272 let hasSideEffects = 0 in {
2273 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2274 defm FRIPD : XForm_26r<63, 456, (outs f8rc:$frD), (ins f8rc:$frB),
2275 "frip", "$frD, $frB", IIC_FPGeneral,
2276 [(set f64:$frD, (fceil f64:$frB))]>;
2277 defm FRIPS : XForm_26r<63, 456, (outs f4rc:$frD), (ins f4rc:$frB),
2278 "frip", "$frD, $frB", IIC_FPGeneral,
2279 [(set f32:$frD, (fceil f32:$frB))]>;
2280 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2281 defm FRIZD : XForm_26r<63, 424, (outs f8rc:$frD), (ins f8rc:$frB),
2282 "friz", "$frD, $frB", IIC_FPGeneral,
2283 [(set f64:$frD, (ftrunc f64:$frB))]>;
2284 defm FRIZS : XForm_26r<63, 424, (outs f4rc:$frD), (ins f4rc:$frB),
2285 "friz", "$frD, $frB", IIC_FPGeneral,
2286 [(set f32:$frD, (ftrunc f32:$frB))]>;
2287 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2288 defm FRIMD : XForm_26r<63, 488, (outs f8rc:$frD), (ins f8rc:$frB),
2289 "frim", "$frD, $frB", IIC_FPGeneral,
2290 [(set f64:$frD, (ffloor f64:$frB))]>;
2291 defm FRIMS : XForm_26r<63, 488, (outs f4rc:$frD), (ins f4rc:$frB),
2292 "frim", "$frD, $frB", IIC_FPGeneral,
2293 [(set f32:$frD, (ffloor f32:$frB))]>;
2295 defm FSQRT : XForm_26r<63, 22, (outs f8rc:$frD), (ins f8rc:$frB),
2296 "fsqrt", "$frD, $frB", IIC_FPSqrtD,
2297 [(set f64:$frD, (fsqrt f64:$frB))]>;
2298 defm FSQRTS : XForm_26r<59, 22, (outs f4rc:$frD), (ins f4rc:$frB),
2299 "fsqrts", "$frD, $frB", IIC_FPSqrtS,
2300 [(set f32:$frD, (fsqrt f32:$frB))]>;
2305 /// Note that FMR is defined as pseudo-ops on the PPC970 because they are
2306 /// often coalesced away and we don't want the dispatch group builder to think
2307 /// that they will fill slots (which could cause the load of a LSU reject to
2308 /// sneak into a d-group with a store).
2309 let hasSideEffects = 0 in
2310 defm FMR : XForm_26r<63, 72, (outs f4rc:$frD), (ins f4rc:$frB),
2311 "fmr", "$frD, $frB", IIC_FPGeneral,
2312 []>, // (set f32:$frD, f32:$frB)
2315 let PPC970_Unit = 3, hasSideEffects = 0 in { // FPU Operations.
2316 // These are artificially split into two different forms, for 4/8 byte FP.
2317 defm FABSS : XForm_26r<63, 264, (outs f4rc:$frD), (ins f4rc:$frB),
2318 "fabs", "$frD, $frB", IIC_FPGeneral,
2319 [(set f32:$frD, (fabs f32:$frB))]>;
2320 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2321 defm FABSD : XForm_26r<63, 264, (outs f8rc:$frD), (ins f8rc:$frB),
2322 "fabs", "$frD, $frB", IIC_FPGeneral,
2323 [(set f64:$frD, (fabs f64:$frB))]>;
2324 defm FNABSS : XForm_26r<63, 136, (outs f4rc:$frD), (ins f4rc:$frB),
2325 "fnabs", "$frD, $frB", IIC_FPGeneral,
2326 [(set f32:$frD, (fneg (fabs f32:$frB)))]>;
2327 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2328 defm FNABSD : XForm_26r<63, 136, (outs f8rc:$frD), (ins f8rc:$frB),
2329 "fnabs", "$frD, $frB", IIC_FPGeneral,
2330 [(set f64:$frD, (fneg (fabs f64:$frB)))]>;
2331 defm FNEGS : XForm_26r<63, 40, (outs f4rc:$frD), (ins f4rc:$frB),
2332 "fneg", "$frD, $frB", IIC_FPGeneral,
2333 [(set f32:$frD, (fneg f32:$frB))]>;
2334 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2335 defm FNEGD : XForm_26r<63, 40, (outs f8rc:$frD), (ins f8rc:$frB),
2336 "fneg", "$frD, $frB", IIC_FPGeneral,
2337 [(set f64:$frD, (fneg f64:$frB))]>;
2339 defm FCPSGNS : XForm_28r<63, 8, (outs f4rc:$frD), (ins f4rc:$frA, f4rc:$frB),
2340 "fcpsgn", "$frD, $frA, $frB", IIC_FPGeneral,
2341 [(set f32:$frD, (fcopysign f32:$frB, f32:$frA))]>;
2342 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2343 defm FCPSGND : XForm_28r<63, 8, (outs f8rc:$frD), (ins f8rc:$frA, f8rc:$frB),
2344 "fcpsgn", "$frD, $frA, $frB", IIC_FPGeneral,
2345 [(set f64:$frD, (fcopysign f64:$frB, f64:$frA))]>;
2347 // Reciprocal estimates.
2348 defm FRE : XForm_26r<63, 24, (outs f8rc:$frD), (ins f8rc:$frB),
2349 "fre", "$frD, $frB", IIC_FPGeneral,
2350 [(set f64:$frD, (PPCfre f64:$frB))]>;
2351 defm FRES : XForm_26r<59, 24, (outs f4rc:$frD), (ins f4rc:$frB),
2352 "fres", "$frD, $frB", IIC_FPGeneral,
2353 [(set f32:$frD, (PPCfre f32:$frB))]>;
2354 defm FRSQRTE : XForm_26r<63, 26, (outs f8rc:$frD), (ins f8rc:$frB),
2355 "frsqrte", "$frD, $frB", IIC_FPGeneral,
2356 [(set f64:$frD, (PPCfrsqrte f64:$frB))]>;
2357 defm FRSQRTES : XForm_26r<59, 26, (outs f4rc:$frD), (ins f4rc:$frB),
2358 "frsqrtes", "$frD, $frB", IIC_FPGeneral,
2359 [(set f32:$frD, (PPCfrsqrte f32:$frB))]>;
2362 // XL-Form instructions. condition register logical ops.
2364 let hasSideEffects = 0 in
2365 def MCRF : XLForm_3<19, 0, (outs crrc:$BF), (ins crrc:$BFA),
2366 "mcrf $BF, $BFA", IIC_BrMCR>,
2367 PPC970_DGroup_First, PPC970_Unit_CRU;
2369 // FIXME: According to the ISA (section 2.5.1 of version 2.06), the
2370 // condition-register logical instructions have preferred forms. Specifically,
2371 // it is preferred that the bit specified by the BT field be in the same
2372 // condition register as that specified by the bit BB. We might want to account
2373 // for this via hinting the register allocator and anti-dep breakers, or we
2374 // could constrain the register class to force this constraint and then loosen
2375 // it during register allocation via convertToThreeAddress or some similar
2378 let isCommutable = 1 in {
2379 def CRAND : XLForm_1<19, 257, (outs crbitrc:$CRD),
2380 (ins crbitrc:$CRA, crbitrc:$CRB),
2381 "crand $CRD, $CRA, $CRB", IIC_BrCR,
2382 [(set i1:$CRD, (and i1:$CRA, i1:$CRB))]>;
2384 def CRNAND : XLForm_1<19, 225, (outs crbitrc:$CRD),
2385 (ins crbitrc:$CRA, crbitrc:$CRB),
2386 "crnand $CRD, $CRA, $CRB", IIC_BrCR,
2387 [(set i1:$CRD, (not (and i1:$CRA, i1:$CRB)))]>;
2389 def CROR : XLForm_1<19, 449, (outs crbitrc:$CRD),
2390 (ins crbitrc:$CRA, crbitrc:$CRB),
2391 "cror $CRD, $CRA, $CRB", IIC_BrCR,
2392 [(set i1:$CRD, (or i1:$CRA, i1:$CRB))]>;
2394 def CRXOR : XLForm_1<19, 193, (outs crbitrc:$CRD),
2395 (ins crbitrc:$CRA, crbitrc:$CRB),
2396 "crxor $CRD, $CRA, $CRB", IIC_BrCR,
2397 [(set i1:$CRD, (xor i1:$CRA, i1:$CRB))]>;
2399 def CRNOR : XLForm_1<19, 33, (outs crbitrc:$CRD),
2400 (ins crbitrc:$CRA, crbitrc:$CRB),
2401 "crnor $CRD, $CRA, $CRB", IIC_BrCR,
2402 [(set i1:$CRD, (not (or i1:$CRA, i1:$CRB)))]>;
2404 def CREQV : XLForm_1<19, 289, (outs crbitrc:$CRD),
2405 (ins crbitrc:$CRA, crbitrc:$CRB),
2406 "creqv $CRD, $CRA, $CRB", IIC_BrCR,
2407 [(set i1:$CRD, (not (xor i1:$CRA, i1:$CRB)))]>;
2410 def CRANDC : XLForm_1<19, 129, (outs crbitrc:$CRD),
2411 (ins crbitrc:$CRA, crbitrc:$CRB),
2412 "crandc $CRD, $CRA, $CRB", IIC_BrCR,
2413 [(set i1:$CRD, (and i1:$CRA, (not i1:$CRB)))]>;
2415 def CRORC : XLForm_1<19, 417, (outs crbitrc:$CRD),
2416 (ins crbitrc:$CRA, crbitrc:$CRB),
2417 "crorc $CRD, $CRA, $CRB", IIC_BrCR,
2418 [(set i1:$CRD, (or i1:$CRA, (not i1:$CRB)))]>;
2420 let isCodeGenOnly = 1 in {
2421 def CRSET : XLForm_1_ext<19, 289, (outs crbitrc:$dst), (ins),
2422 "creqv $dst, $dst, $dst", IIC_BrCR,
2423 [(set i1:$dst, 1)]>;
2425 def CRUNSET: XLForm_1_ext<19, 193, (outs crbitrc:$dst), (ins),
2426 "crxor $dst, $dst, $dst", IIC_BrCR,
2427 [(set i1:$dst, 0)]>;
2429 let Defs = [CR1EQ], CRD = 6 in {
2430 def CR6SET : XLForm_1_ext<19, 289, (outs), (ins),
2431 "creqv 6, 6, 6", IIC_BrCR,
2434 def CR6UNSET: XLForm_1_ext<19, 193, (outs), (ins),
2435 "crxor 6, 6, 6", IIC_BrCR,
2440 // XFX-Form instructions. Instructions that deal with SPRs.
2443 def MFSPR : XFXForm_1<31, 339, (outs gprc:$RT), (ins i32imm:$SPR),
2444 "mfspr $RT, $SPR", IIC_SprMFSPR>;
2445 def MTSPR : XFXForm_1<31, 467, (outs), (ins i32imm:$SPR, gprc:$RT),
2446 "mtspr $SPR, $RT", IIC_SprMTSPR>;
2448 def MFTB : XFXForm_1<31, 371, (outs gprc:$RT), (ins i32imm:$SPR),
2449 "mftb $RT, $SPR", IIC_SprMFTB>;
2451 def MFPMR : XFXForm_1<31, 334, (outs gprc:$RT), (ins i32imm:$SPR),
2452 "mfpmr $RT, $SPR", IIC_SprMFPMR>;
2454 def MTPMR : XFXForm_1<31, 462, (outs), (ins i32imm:$SPR, gprc:$RT),
2455 "mtpmr $SPR, $RT", IIC_SprMTPMR>;
2458 // A pseudo-instruction used to implement the read of the 64-bit cycle counter
2459 // on a 32-bit target.
2460 let hasSideEffects = 1, usesCustomInserter = 1 in
2461 def ReadTB : Pseudo<(outs gprc:$lo, gprc:$hi), (ins),
2464 let Uses = [CTR] in {
2465 def MFCTR : XFXForm_1_ext<31, 339, 9, (outs gprc:$rT), (ins),
2466 "mfctr $rT", IIC_SprMFSPR>,
2467 PPC970_DGroup_First, PPC970_Unit_FXU;
2469 let Defs = [CTR], Pattern = [(PPCmtctr i32:$rS)] in {
2470 def MTCTR : XFXForm_7_ext<31, 467, 9, (outs), (ins gprc:$rS),
2471 "mtctr $rS", IIC_SprMTSPR>,
2472 PPC970_DGroup_First, PPC970_Unit_FXU;
2474 let hasSideEffects = 1, isCodeGenOnly = 1, Defs = [CTR] in {
2475 let Pattern = [(int_ppc_mtctr i32:$rS)] in
2476 def MTCTRloop : XFXForm_7_ext<31, 467, 9, (outs), (ins gprc:$rS),
2477 "mtctr $rS", IIC_SprMTSPR>,
2478 PPC970_DGroup_First, PPC970_Unit_FXU;
2481 let Defs = [LR] in {
2482 def MTLR : XFXForm_7_ext<31, 467, 8, (outs), (ins gprc:$rS),
2483 "mtlr $rS", IIC_SprMTSPR>,
2484 PPC970_DGroup_First, PPC970_Unit_FXU;
2486 let Uses = [LR] in {
2487 def MFLR : XFXForm_1_ext<31, 339, 8, (outs gprc:$rT), (ins),
2488 "mflr $rT", IIC_SprMFSPR>,
2489 PPC970_DGroup_First, PPC970_Unit_FXU;
2492 let isCodeGenOnly = 1 in {
2493 // Move to/from VRSAVE: despite being a SPR, the VRSAVE register is renamed
2494 // like a GPR on the PPC970. As such, copies in and out have the same
2495 // performance characteristics as an OR instruction.
2496 def MTVRSAVE : XFXForm_7_ext<31, 467, 256, (outs), (ins gprc:$rS),
2497 "mtspr 256, $rS", IIC_IntGeneral>,
2498 PPC970_DGroup_Single, PPC970_Unit_FXU;
2499 def MFVRSAVE : XFXForm_1_ext<31, 339, 256, (outs gprc:$rT), (ins),
2500 "mfspr $rT, 256", IIC_IntGeneral>,
2501 PPC970_DGroup_First, PPC970_Unit_FXU;
2503 def MTVRSAVEv : XFXForm_7_ext<31, 467, 256,
2504 (outs VRSAVERC:$reg), (ins gprc:$rS),
2505 "mtspr 256, $rS", IIC_IntGeneral>,
2506 PPC970_DGroup_Single, PPC970_Unit_FXU;
2507 def MFVRSAVEv : XFXForm_1_ext<31, 339, 256, (outs gprc:$rT),
2508 (ins VRSAVERC:$reg),
2509 "mfspr $rT, 256", IIC_IntGeneral>,
2510 PPC970_DGroup_First, PPC970_Unit_FXU;
2513 // Aliases for mtvrsave/mfvrsave to mfspr/mtspr.
2514 def : InstAlias<"mtvrsave $rS", (MTVRSAVE gprc:$rS)>;
2515 def : InstAlias<"mfvrsave $rS", (MFVRSAVE gprc:$rS)>;
2517 // SPILL_VRSAVE - Indicate that we're dumping the VRSAVE register,
2518 // so we'll need to scavenge a register for it.
2520 def SPILL_VRSAVE : Pseudo<(outs), (ins VRSAVERC:$vrsave, memri:$F),
2521 "#SPILL_VRSAVE", []>;
2523 // RESTORE_VRSAVE - Indicate that we're restoring the VRSAVE register (previously
2524 // spilled), so we'll need to scavenge a register for it.
2526 def RESTORE_VRSAVE : Pseudo<(outs VRSAVERC:$vrsave), (ins memri:$F),
2527 "#RESTORE_VRSAVE", []>;
2529 let hasSideEffects = 0 in {
2530 // mtocrf's input needs to be prepared by shifting by an amount dependent
2531 // on the cr register selected. Thus, post-ra anti-dep breaking must not
2532 // later change that register assignment.
2533 let hasExtraDefRegAllocReq = 1 in {
2534 def MTOCRF: XFXForm_5a<31, 144, (outs crbitm:$FXM), (ins gprc:$ST),
2535 "mtocrf $FXM, $ST", IIC_BrMCRX>,
2536 PPC970_DGroup_First, PPC970_Unit_CRU;
2538 // Similarly to mtocrf, the mask for mtcrf must be prepared in a way that
2539 // is dependent on the cr fields being set.
2540 def MTCRF : XFXForm_5<31, 144, (outs), (ins i32imm:$FXM, gprc:$rS),
2541 "mtcrf $FXM, $rS", IIC_BrMCRX>,
2542 PPC970_MicroCode, PPC970_Unit_CRU;
2543 } // hasExtraDefRegAllocReq = 1
2545 // mfocrf's input needs to be prepared by shifting by an amount dependent
2546 // on the cr register selected. Thus, post-ra anti-dep breaking must not
2547 // later change that register assignment.
2548 let hasExtraSrcRegAllocReq = 1 in {
2549 def MFOCRF: XFXForm_5a<31, 19, (outs gprc:$rT), (ins crbitm:$FXM),
2550 "mfocrf $rT, $FXM", IIC_SprMFCRF>,
2551 PPC970_DGroup_First, PPC970_Unit_CRU;
2553 // Similarly to mfocrf, the mask for mfcrf must be prepared in a way that
2554 // is dependent on the cr fields being copied.
2555 def MFCR : XFXForm_3<31, 19, (outs gprc:$rT), (ins),
2556 "mfcr $rT", IIC_SprMFCR>,
2557 PPC970_MicroCode, PPC970_Unit_CRU;
2558 } // hasExtraSrcRegAllocReq = 1
2560 def MCRXRX : X_BF3<31, 576, (outs crrc:$BF), (ins),
2561 "mcrxrx $BF", IIC_BrMCRX>, Requires<[IsISA3_0]>;
2562 } // hasSideEffects = 0
2564 // Pseudo instruction to perform FADD in round-to-zero mode.
2565 let usesCustomInserter = 1, Uses = [RM] in {
2566 def FADDrtz: Pseudo<(outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB), "",
2567 [(set f64:$FRT, (PPCfaddrtz f64:$FRA, f64:$FRB))]>;
2570 // The above pseudo gets expanded to make use of the following instructions
2571 // to manipulate FPSCR. Note that FPSCR is not modeled at the DAG level.
2572 let Uses = [RM], Defs = [RM] in {
2573 def MTFSB0 : XForm_43<63, 70, (outs), (ins u5imm:$FM),
2574 "mtfsb0 $FM", IIC_IntMTFSB0, []>,
2575 PPC970_DGroup_Single, PPC970_Unit_FPU;
2576 def MTFSB1 : XForm_43<63, 38, (outs), (ins u5imm:$FM),
2577 "mtfsb1 $FM", IIC_IntMTFSB0, []>,
2578 PPC970_DGroup_Single, PPC970_Unit_FPU;
2579 let isCodeGenOnly = 1 in
2580 def MTFSFb : XFLForm<63, 711, (outs), (ins i32imm:$FM, f8rc:$rT),
2581 "mtfsf $FM, $rT", IIC_IntMTFSB0, []>,
2582 PPC970_DGroup_Single, PPC970_Unit_FPU;
2584 let Uses = [RM] in {
2585 def MFFS : XForm_42<63, 583, (outs f8rc:$rT), (ins),
2586 "mffs $rT", IIC_IntMFFS,
2587 [(set f64:$rT, (PPCmffs))]>,
2588 PPC970_DGroup_Single, PPC970_Unit_FPU;
2591 def MFFSo : XForm_42<63, 583, (outs f8rc:$rT), (ins),
2592 "mffs. $rT", IIC_IntMFFS, []>, isDOT;
2594 def MFFSCE : X_FRT5_XO2_XO3_XO10<63, 0, 1, 583, (outs f8rc:$rT), (ins),
2595 "mffsce $rT", IIC_IntMFFS, []>,
2596 PPC970_DGroup_Single, PPC970_Unit_FPU;
2598 def MFFSCDRN : X_FRT5_XO2_XO3_FRB5_XO10<63, 2, 4, 583, (outs f8rc:$rT),
2599 (ins f8rc:$FRB), "mffscdrn $rT, $FRB",
2601 PPC970_DGroup_Single, PPC970_Unit_FPU;
2603 def MFFSCDRNI : X_FRT5_XO2_XO3_DRM3_XO10<63, 2, 5, 583, (outs f8rc:$rT),
2605 "mffscdrni $rT, $DRM",
2607 PPC970_DGroup_Single, PPC970_Unit_FPU;
2609 def MFFSCRN : X_FRT5_XO2_XO3_FRB5_XO10<63, 2, 6, 583, (outs f8rc:$rT),
2610 (ins f8rc:$FRB), "mffscrn $rT, $FRB",
2612 PPC970_DGroup_Single, PPC970_Unit_FPU;
2614 def MFFSCRNI : X_FRT5_XO2_XO3_RM2_X10<63, 2, 7, 583, (outs f8rc:$rT),
2615 (ins u2imm:$RM), "mffscrni $rT, $RM",
2617 PPC970_DGroup_Single, PPC970_Unit_FPU;
2619 def MFFSL : X_FRT5_XO2_XO3_XO10<63, 3, 0, 583, (outs f8rc:$rT), (ins),
2620 "mffsl $rT", IIC_IntMFFS, []>,
2621 PPC970_DGroup_Single, PPC970_Unit_FPU;
2624 let Predicates = [IsISA3_0] in {
2625 def MODSW : XForm_8<31, 779, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2626 "modsw $rT, $rA, $rB", IIC_IntDivW,
2627 [(set i32:$rT, (srem i32:$rA, i32:$rB))]>;
2628 def MODUW : XForm_8<31, 267, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2629 "moduw $rT, $rA, $rB", IIC_IntDivW,
2630 [(set i32:$rT, (urem i32:$rA, i32:$rB))]>;
2633 let PPC970_Unit = 1, hasSideEffects = 0 in { // FXU Operations.
2634 // XO-Form instructions. Arithmetic instructions that can set overflow bit
2635 let isCommutable = 1 in
2636 defm ADD4 : XOForm_1r<31, 266, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2637 "add", "$rT, $rA, $rB", IIC_IntSimple,
2638 [(set i32:$rT, (add i32:$rA, i32:$rB))]>;
2639 let isCodeGenOnly = 1 in
2640 def ADD4TLS : XOForm_1<31, 266, 0, (outs gprc:$rT), (ins gprc:$rA, tlsreg32:$rB),
2641 "add $rT, $rA, $rB", IIC_IntSimple,
2642 [(set i32:$rT, (add i32:$rA, tglobaltlsaddr:$rB))]>;
2643 let isCommutable = 1 in
2644 defm ADDC : XOForm_1rc<31, 10, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2645 "addc", "$rT, $rA, $rB", IIC_IntGeneral,
2646 [(set i32:$rT, (addc i32:$rA, i32:$rB))]>,
2647 PPC970_DGroup_Cracked;
2649 defm DIVW : XOForm_1rcr<31, 491, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2650 "divw", "$rT, $rA, $rB", IIC_IntDivW,
2651 [(set i32:$rT, (sdiv i32:$rA, i32:$rB))]>;
2652 defm DIVWU : XOForm_1rcr<31, 459, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2653 "divwu", "$rT, $rA, $rB", IIC_IntDivW,
2654 [(set i32:$rT, (udiv i32:$rA, i32:$rB))]>;
2655 def DIVWE : XOForm_1<31, 427, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2656 "divwe $rT, $rA, $rB", IIC_IntDivW,
2657 [(set i32:$rT, (int_ppc_divwe gprc:$rA, gprc:$rB))]>,
2658 Requires<[HasExtDiv]>;
2660 def DIVWEo : XOForm_1<31, 427, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2661 "divwe. $rT, $rA, $rB", IIC_IntDivW,
2662 []>, isDOT, PPC970_DGroup_Cracked, PPC970_DGroup_First,
2663 Requires<[HasExtDiv]>;
2664 def DIVWEU : XOForm_1<31, 395, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2665 "divweu $rT, $rA, $rB", IIC_IntDivW,
2666 [(set i32:$rT, (int_ppc_divweu gprc:$rA, gprc:$rB))]>,
2667 Requires<[HasExtDiv]>;
2669 def DIVWEUo : XOForm_1<31, 395, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2670 "divweu. $rT, $rA, $rB", IIC_IntDivW,
2671 []>, isDOT, PPC970_DGroup_Cracked, PPC970_DGroup_First,
2672 Requires<[HasExtDiv]>;
2673 let isCommutable = 1 in {
2674 defm MULHW : XOForm_1r<31, 75, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2675 "mulhw", "$rT, $rA, $rB", IIC_IntMulHW,
2676 [(set i32:$rT, (mulhs i32:$rA, i32:$rB))]>;
2677 defm MULHWU : XOForm_1r<31, 11, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2678 "mulhwu", "$rT, $rA, $rB", IIC_IntMulHWU,
2679 [(set i32:$rT, (mulhu i32:$rA, i32:$rB))]>;
2680 defm MULLW : XOForm_1r<31, 235, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2681 "mullw", "$rT, $rA, $rB", IIC_IntMulHW,
2682 [(set i32:$rT, (mul i32:$rA, i32:$rB))]>;
2684 defm SUBF : XOForm_1r<31, 40, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2685 "subf", "$rT, $rA, $rB", IIC_IntGeneral,
2686 [(set i32:$rT, (sub i32:$rB, i32:$rA))]>;
2687 defm SUBFC : XOForm_1rc<31, 8, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2688 "subfc", "$rT, $rA, $rB", IIC_IntGeneral,
2689 [(set i32:$rT, (subc i32:$rB, i32:$rA))]>,
2690 PPC970_DGroup_Cracked;
2691 defm NEG : XOForm_3r<31, 104, 0, (outs gprc:$rT), (ins gprc:$rA),
2692 "neg", "$rT, $rA", IIC_IntSimple,
2693 [(set i32:$rT, (ineg i32:$rA))]>;
2694 let Uses = [CARRY] in {
2695 let isCommutable = 1 in
2696 defm ADDE : XOForm_1rc<31, 138, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2697 "adde", "$rT, $rA, $rB", IIC_IntGeneral,
2698 [(set i32:$rT, (adde i32:$rA, i32:$rB))]>;
2699 defm ADDME : XOForm_3rc<31, 234, 0, (outs gprc:$rT), (ins gprc:$rA),
2700 "addme", "$rT, $rA", IIC_IntGeneral,
2701 [(set i32:$rT, (adde i32:$rA, -1))]>;
2702 defm ADDZE : XOForm_3rc<31, 202, 0, (outs gprc:$rT), (ins gprc:$rA),
2703 "addze", "$rT, $rA", IIC_IntGeneral,
2704 [(set i32:$rT, (adde i32:$rA, 0))]>;
2705 defm SUBFE : XOForm_1rc<31, 136, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2706 "subfe", "$rT, $rA, $rB", IIC_IntGeneral,
2707 [(set i32:$rT, (sube i32:$rB, i32:$rA))]>;
2708 defm SUBFME : XOForm_3rc<31, 232, 0, (outs gprc:$rT), (ins gprc:$rA),
2709 "subfme", "$rT, $rA", IIC_IntGeneral,
2710 [(set i32:$rT, (sube -1, i32:$rA))]>;
2711 defm SUBFZE : XOForm_3rc<31, 200, 0, (outs gprc:$rT), (ins gprc:$rA),
2712 "subfze", "$rT, $rA", IIC_IntGeneral,
2713 [(set i32:$rT, (sube 0, i32:$rA))]>;
2717 // A-Form instructions. Most of the instructions executed in the FPU are of
2720 let PPC970_Unit = 3, hasSideEffects = 0 in { // FPU Operations.
2721 let Uses = [RM] in {
2722 let isCommutable = 1 in {
2723 defm FMADD : AForm_1r<63, 29,
2724 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2725 "fmadd", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2726 [(set f64:$FRT, (fma f64:$FRA, f64:$FRC, f64:$FRB))]>;
2727 defm FMADDS : AForm_1r<59, 29,
2728 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2729 "fmadds", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2730 [(set f32:$FRT, (fma f32:$FRA, f32:$FRC, f32:$FRB))]>;
2731 defm FMSUB : AForm_1r<63, 28,
2732 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2733 "fmsub", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2735 (fma f64:$FRA, f64:$FRC, (fneg f64:$FRB)))]>;
2736 defm FMSUBS : AForm_1r<59, 28,
2737 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2738 "fmsubs", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2740 (fma f32:$FRA, f32:$FRC, (fneg f32:$FRB)))]>;
2741 defm FNMADD : AForm_1r<63, 31,
2742 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2743 "fnmadd", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2745 (fneg (fma f64:$FRA, f64:$FRC, f64:$FRB)))]>;
2746 defm FNMADDS : AForm_1r<59, 31,
2747 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2748 "fnmadds", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2750 (fneg (fma f32:$FRA, f32:$FRC, f32:$FRB)))]>;
2751 defm FNMSUB : AForm_1r<63, 30,
2752 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2753 "fnmsub", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2754 [(set f64:$FRT, (fneg (fma f64:$FRA, f64:$FRC,
2755 (fneg f64:$FRB))))]>;
2756 defm FNMSUBS : AForm_1r<59, 30,
2757 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2758 "fnmsubs", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2759 [(set f32:$FRT, (fneg (fma f32:$FRA, f32:$FRC,
2760 (fneg f32:$FRB))))]>;
2763 // FSEL is artificially split into 4 and 8-byte forms for the result. To avoid
2764 // having 4 of these, force the comparison to always be an 8-byte double (code
2765 // should use an FMRSD if the input comparison value really wants to be a float)
2766 // and 4/8 byte forms for the result and operand type..
2767 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2768 defm FSELD : AForm_1r<63, 23,
2769 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2770 "fsel", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2771 [(set f64:$FRT, (PPCfsel f64:$FRA, f64:$FRC, f64:$FRB))]>;
2772 defm FSELS : AForm_1r<63, 23,
2773 (outs f4rc:$FRT), (ins f8rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2774 "fsel", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2775 [(set f32:$FRT, (PPCfsel f64:$FRA, f32:$FRC, f32:$FRB))]>;
2776 let Uses = [RM] in {
2777 let isCommutable = 1 in {
2778 defm FADD : AForm_2r<63, 21,
2779 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB),
2780 "fadd", "$FRT, $FRA, $FRB", IIC_FPAddSub,
2781 [(set f64:$FRT, (fadd f64:$FRA, f64:$FRB))]>;
2782 defm FADDS : AForm_2r<59, 21,
2783 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB),
2784 "fadds", "$FRT, $FRA, $FRB", IIC_FPGeneral,
2785 [(set f32:$FRT, (fadd f32:$FRA, f32:$FRB))]>;
2787 defm FDIV : AForm_2r<63, 18,
2788 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB),
2789 "fdiv", "$FRT, $FRA, $FRB", IIC_FPDivD,
2790 [(set f64:$FRT, (fdiv f64:$FRA, f64:$FRB))]>;
2791 defm FDIVS : AForm_2r<59, 18,
2792 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB),
2793 "fdivs", "$FRT, $FRA, $FRB", IIC_FPDivS,
2794 [(set f32:$FRT, (fdiv f32:$FRA, f32:$FRB))]>;
2795 let isCommutable = 1 in {
2796 defm FMUL : AForm_3r<63, 25,
2797 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC),
2798 "fmul", "$FRT, $FRA, $FRC", IIC_FPFused,
2799 [(set f64:$FRT, (fmul f64:$FRA, f64:$FRC))]>;
2800 defm FMULS : AForm_3r<59, 25,
2801 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC),
2802 "fmuls", "$FRT, $FRA, $FRC", IIC_FPGeneral,
2803 [(set f32:$FRT, (fmul f32:$FRA, f32:$FRC))]>;
2805 defm FSUB : AForm_2r<63, 20,
2806 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB),
2807 "fsub", "$FRT, $FRA, $FRB", IIC_FPAddSub,
2808 [(set f64:$FRT, (fsub f64:$FRA, f64:$FRB))]>;
2809 defm FSUBS : AForm_2r<59, 20,
2810 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB),
2811 "fsubs", "$FRT, $FRA, $FRB", IIC_FPGeneral,
2812 [(set f32:$FRT, (fsub f32:$FRA, f32:$FRB))]>;
2816 let hasSideEffects = 0 in {
2817 let PPC970_Unit = 1 in { // FXU Operations.
2819 def ISEL : AForm_4<31, 15,
2820 (outs gprc:$rT), (ins gprc_nor0:$rA, gprc:$rB, crbitrc:$cond),
2821 "isel $rT, $rA, $rB, $cond", IIC_IntISEL,
2825 let PPC970_Unit = 1 in { // FXU Operations.
2826 // M-Form instructions. rotate and mask instructions.
2828 let isCommutable = 1 in {
2829 // RLWIMI can be commuted if the rotate amount is zero.
2830 defm RLWIMI : MForm_2r<20, (outs gprc:$rA),
2831 (ins gprc:$rSi, gprc:$rS, u5imm:$SH, u5imm:$MB,
2832 u5imm:$ME), "rlwimi", "$rA, $rS, $SH, $MB, $ME",
2833 IIC_IntRotate, []>, PPC970_DGroup_Cracked,
2834 RegConstraint<"$rSi = $rA">, NoEncode<"$rSi">;
2836 let BaseName = "rlwinm" in {
2837 def RLWINM : MForm_2<21,
2838 (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
2839 "rlwinm $rA, $rS, $SH, $MB, $ME", IIC_IntGeneral,
2842 def RLWINMo : MForm_2<21,
2843 (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
2844 "rlwinm. $rA, $rS, $SH, $MB, $ME", IIC_IntGeneral,
2845 []>, isDOT, RecFormRel, PPC970_DGroup_Cracked;
2847 defm RLWNM : MForm_2r<23, (outs gprc:$rA),
2848 (ins gprc:$rS, gprc:$rB, u5imm:$MB, u5imm:$ME),
2849 "rlwnm", "$rA, $rS, $rB, $MB, $ME", IIC_IntGeneral,
2852 } // hasSideEffects = 0
2854 //===----------------------------------------------------------------------===//
2855 // PowerPC Instruction Patterns
2858 // Arbitrary immediate support. Implement in terms of LIS/ORI.
2859 def : Pat<(i32 imm:$imm),
2860 (ORI (LIS (HI16 imm:$imm)), (LO16 imm:$imm))>;
2862 // Implement the 'not' operation with the NOR instruction.
2863 def i32not : OutPatFrag<(ops node:$in),
2865 def : Pat<(not i32:$in),
2868 // ADD an arbitrary immediate.
2869 def : Pat<(add i32:$in, imm:$imm),
2870 (ADDIS (ADDI $in, (LO16 imm:$imm)), (HA16 imm:$imm))>;
2871 // OR an arbitrary immediate.
2872 def : Pat<(or i32:$in, imm:$imm),
2873 (ORIS (ORI $in, (LO16 imm:$imm)), (HI16 imm:$imm))>;
2874 // XOR an arbitrary immediate.
2875 def : Pat<(xor i32:$in, imm:$imm),
2876 (XORIS (XORI $in, (LO16 imm:$imm)), (HI16 imm:$imm))>;
2878 def : Pat<(sub imm32SExt16:$imm, i32:$in),
2879 (SUBFIC $in, imm:$imm)>;
2882 def : Pat<(shl i32:$in, (i32 imm:$imm)),
2883 (RLWINM $in, imm:$imm, 0, (SHL32 imm:$imm))>;
2884 def : Pat<(srl i32:$in, (i32 imm:$imm)),
2885 (RLWINM $in, (SRL32 imm:$imm), imm:$imm, 31)>;
2888 def : Pat<(rotl i32:$in, i32:$sh),
2889 (RLWNM $in, $sh, 0, 31)>;
2890 def : Pat<(rotl i32:$in, (i32 imm:$imm)),
2891 (RLWINM $in, imm:$imm, 0, 31)>;
2894 def : Pat<(and (rotl i32:$in, i32:$sh), maskimm32:$imm),
2895 (RLWNM $in, $sh, (MB maskimm32:$imm), (ME maskimm32:$imm))>;
2898 def : Pat<(PPCcall (i32 tglobaladdr:$dst)),
2899 (BL tglobaladdr:$dst)>;
2900 def : Pat<(PPCcall (i32 texternalsym:$dst)),
2901 (BL texternalsym:$dst)>;
2903 def : Pat<(PPCtc_return (i32 tglobaladdr:$dst), imm:$imm),
2904 (TCRETURNdi tglobaladdr:$dst, imm:$imm)>;
2906 def : Pat<(PPCtc_return (i32 texternalsym:$dst), imm:$imm),
2907 (TCRETURNdi texternalsym:$dst, imm:$imm)>;
2909 def : Pat<(PPCtc_return CTRRC:$dst, imm:$imm),
2910 (TCRETURNri CTRRC:$dst, imm:$imm)>;
2914 // Hi and Lo for Darwin Global Addresses.
2915 def : Pat<(PPChi tglobaladdr:$in, 0), (LIS tglobaladdr:$in)>;
2916 def : Pat<(PPClo tglobaladdr:$in, 0), (LI tglobaladdr:$in)>;
2917 def : Pat<(PPChi tconstpool:$in, 0), (LIS tconstpool:$in)>;
2918 def : Pat<(PPClo tconstpool:$in, 0), (LI tconstpool:$in)>;
2919 def : Pat<(PPChi tjumptable:$in, 0), (LIS tjumptable:$in)>;
2920 def : Pat<(PPClo tjumptable:$in, 0), (LI tjumptable:$in)>;
2921 def : Pat<(PPChi tblockaddress:$in, 0), (LIS tblockaddress:$in)>;
2922 def : Pat<(PPClo tblockaddress:$in, 0), (LI tblockaddress:$in)>;
2923 def : Pat<(PPChi tglobaltlsaddr:$g, i32:$in),
2924 (ADDIS $in, tglobaltlsaddr:$g)>;
2925 def : Pat<(PPClo tglobaltlsaddr:$g, i32:$in),
2926 (ADDI $in, tglobaltlsaddr:$g)>;
2927 def : Pat<(add i32:$in, (PPChi tglobaladdr:$g, 0)),
2928 (ADDIS $in, tglobaladdr:$g)>;
2929 def : Pat<(add i32:$in, (PPChi tconstpool:$g, 0)),
2930 (ADDIS $in, tconstpool:$g)>;
2931 def : Pat<(add i32:$in, (PPChi tjumptable:$g, 0)),
2932 (ADDIS $in, tjumptable:$g)>;
2933 def : Pat<(add i32:$in, (PPChi tblockaddress:$g, 0)),
2934 (ADDIS $in, tblockaddress:$g)>;
2936 // Support for thread-local storage.
2937 def PPC32GOT: Pseudo<(outs gprc:$rD), (ins), "#PPC32GOT",
2938 [(set i32:$rD, (PPCppc32GOT))]>;
2940 // Get the _GLOBAL_OFFSET_TABLE_ in PIC mode.
2941 // This uses two output registers, the first as the real output, the second as a
2942 // temporary register, used internally in code generation.
2943 def PPC32PICGOT: Pseudo<(outs gprc:$rD, gprc:$rT), (ins), "#PPC32PICGOT",
2944 []>, NoEncode<"$rT">;
2946 def LDgotTprelL32: Pseudo<(outs gprc:$rD), (ins s16imm:$disp, gprc_nor0:$reg),
2949 (PPCldGotTprelL tglobaltlsaddr:$disp, i32:$reg))]>;
2950 def : Pat<(PPCaddTls i32:$in, tglobaltlsaddr:$g),
2951 (ADD4TLS $in, tglobaltlsaddr:$g)>;
2953 def ADDItlsgdL32 : Pseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
2956 (PPCaddiTlsgdL i32:$reg, tglobaltlsaddr:$disp))]>;
2957 // LR is a true define, while the rest of the Defs are clobbers. R3 is
2958 // explicitly defined when this op is created, so not mentioned here.
2959 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
2960 Defs = [R0,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
2961 def GETtlsADDR32 : Pseudo<(outs gprc:$rD), (ins gprc:$reg, tlsgd32:$sym),
2964 (PPCgetTlsAddr i32:$reg, tglobaltlsaddr:$sym))]>;
2965 // Combined op for ADDItlsgdL32 and GETtlsADDR32, late expanded. R3 and LR
2966 // are true defines while the rest of the Defs are clobbers.
2967 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
2968 Defs = [R0,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
2969 def ADDItlsgdLADDR32 : Pseudo<(outs gprc:$rD),
2970 (ins gprc_nor0:$reg, s16imm:$disp, tlsgd32:$sym),
2971 "#ADDItlsgdLADDR32",
2973 (PPCaddiTlsgdLAddr i32:$reg,
2974 tglobaltlsaddr:$disp,
2975 tglobaltlsaddr:$sym))]>;
2976 def ADDItlsldL32 : Pseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
2979 (PPCaddiTlsldL i32:$reg, tglobaltlsaddr:$disp))]>;
2980 // LR is a true define, while the rest of the Defs are clobbers. R3 is
2981 // explicitly defined when this op is created, so not mentioned here.
2982 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
2983 Defs = [R0,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
2984 def GETtlsldADDR32 : Pseudo<(outs gprc:$rD), (ins gprc:$reg, tlsgd32:$sym),
2987 (PPCgetTlsldAddr i32:$reg,
2988 tglobaltlsaddr:$sym))]>;
2989 // Combined op for ADDItlsldL32 and GETtlsADDR32, late expanded. R3 and LR
2990 // are true defines while the rest of the Defs are clobbers.
2991 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
2992 Defs = [R0,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
2993 def ADDItlsldLADDR32 : Pseudo<(outs gprc:$rD),
2994 (ins gprc_nor0:$reg, s16imm:$disp, tlsgd32:$sym),
2995 "#ADDItlsldLADDR32",
2997 (PPCaddiTlsldLAddr i32:$reg,
2998 tglobaltlsaddr:$disp,
2999 tglobaltlsaddr:$sym))]>;
3000 def ADDIdtprelL32 : Pseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
3003 (PPCaddiDtprelL i32:$reg, tglobaltlsaddr:$disp))]>;
3004 def ADDISdtprelHA32 : Pseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
3007 (PPCaddisDtprelHA i32:$reg,
3008 tglobaltlsaddr:$disp))]>;
3010 // Support for Position-independent code
3011 def LWZtoc : Pseudo<(outs gprc:$rD), (ins tocentry32:$disp, gprc:$reg),
3014 (PPCtoc_entry tglobaladdr:$disp, i32:$reg))]>;
3015 // Get Global (GOT) Base Register offset, from the word immediately preceding
3016 // the function label.
3017 def UpdateGBR : Pseudo<(outs gprc:$rD, gprc:$rT), (ins gprc:$rI), "#UpdateGBR", []>;
3020 // Standard shifts. These are represented separately from the real shifts above
3021 // so that we can distinguish between shifts that allow 5-bit and 6-bit shift
3023 def : Pat<(sra i32:$rS, i32:$rB),
3025 def : Pat<(srl i32:$rS, i32:$rB),
3027 def : Pat<(shl i32:$rS, i32:$rB),
3030 def : Pat<(zextloadi1 iaddr:$src),
3032 def : Pat<(zextloadi1 xaddr:$src),
3034 def : Pat<(extloadi1 iaddr:$src),
3036 def : Pat<(extloadi1 xaddr:$src),
3038 def : Pat<(extloadi8 iaddr:$src),
3040 def : Pat<(extloadi8 xaddr:$src),
3042 def : Pat<(extloadi16 iaddr:$src),
3044 def : Pat<(extloadi16 xaddr:$src),
3046 def : Pat<(f64 (extloadf32 iaddr:$src)),
3047 (COPY_TO_REGCLASS (LFS iaddr:$src), F8RC)>;
3048 def : Pat<(f64 (extloadf32 xaddr:$src)),
3049 (COPY_TO_REGCLASS (LFSX xaddr:$src), F8RC)>;
3051 def : Pat<(f64 (fpextend f32:$src)),
3052 (COPY_TO_REGCLASS $src, F8RC)>;
3054 // Only seq_cst fences require the heavyweight sync (SYNC 0).
3055 // All others can use the lightweight sync (SYNC 1).
3056 // source: http://www.cl.cam.ac.uk/~pes20/cpp/cpp0xmappings.html
3057 // The rule for seq_cst is duplicated to work with both 64 bits and 32 bits
3058 // versions of Power.
3059 def : Pat<(atomic_fence (i64 7), (imm)), (SYNC 0)>, Requires<[HasSYNC]>;
3060 def : Pat<(atomic_fence (i32 7), (imm)), (SYNC 0)>, Requires<[HasSYNC]>;
3061 def : Pat<(atomic_fence (imm), (imm)), (SYNC 1)>, Requires<[HasSYNC]>;
3062 def : Pat<(atomic_fence (imm), (imm)), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
3064 // Additional FNMSUB patterns: -a*c + b == -(a*c - b)
3065 def : Pat<(fma (fneg f64:$A), f64:$C, f64:$B),
3066 (FNMSUB $A, $C, $B)>;
3067 def : Pat<(fma f64:$A, (fneg f64:$C), f64:$B),
3068 (FNMSUB $A, $C, $B)>;
3069 def : Pat<(fma (fneg f32:$A), f32:$C, f32:$B),
3070 (FNMSUBS $A, $C, $B)>;
3071 def : Pat<(fma f32:$A, (fneg f32:$C), f32:$B),
3072 (FNMSUBS $A, $C, $B)>;
3074 // FCOPYSIGN's operand types need not agree.
3075 def : Pat<(fcopysign f64:$frB, f32:$frA),
3076 (FCPSGND (COPY_TO_REGCLASS $frA, F8RC), $frB)>;
3077 def : Pat<(fcopysign f32:$frB, f64:$frA),
3078 (FCPSGNS (COPY_TO_REGCLASS $frA, F4RC), $frB)>;
3080 include "PPCInstrAltivec.td"
3081 include "PPCInstrSPE.td"
3082 include "PPCInstr64Bit.td"
3083 include "PPCInstrVSX.td"
3084 include "PPCInstrQPX.td"
3085 include "PPCInstrHTM.td"
3087 def crnot : OutPatFrag<(ops node:$in),
3089 def : Pat<(not i1:$in),
3092 // Patterns for arithmetic i1 operations.
3093 def : Pat<(add i1:$a, i1:$b),
3095 def : Pat<(sub i1:$a, i1:$b),
3097 def : Pat<(mul i1:$a, i1:$b),
3100 // We're sometimes asked to materialize i1 -1, which is just 1 in this case
3101 // (-1 is used to mean all bits set).
3102 def : Pat<(i1 -1), (CRSET)>;
3104 // i1 extensions, implemented in terms of isel.
3105 def : Pat<(i32 (zext i1:$in)),
3106 (SELECT_I4 $in, (LI 1), (LI 0))>;
3107 def : Pat<(i32 (sext i1:$in)),
3108 (SELECT_I4 $in, (LI -1), (LI 0))>;
3110 def : Pat<(i64 (zext i1:$in)),
3111 (SELECT_I8 $in, (LI8 1), (LI8 0))>;
3112 def : Pat<(i64 (sext i1:$in)),
3113 (SELECT_I8 $in, (LI8 -1), (LI8 0))>;
3115 // FIXME: We should choose either a zext or a sext based on other constants
3117 def : Pat<(i32 (anyext i1:$in)),
3118 (SELECT_I4 $in, (LI 1), (LI 0))>;
3119 def : Pat<(i64 (anyext i1:$in)),
3120 (SELECT_I8 $in, (LI8 1), (LI8 0))>;
3122 // match setcc on i1 variables.
3140 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETLT)),
3142 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETULT)),
3161 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETLE)),
3163 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETULE)),
3166 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETEQ)),
3180 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETGE)),
3182 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETUGE)),
3196 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETGT)),
3198 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETUGT)),
3201 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETNE)),
3204 // match setcc on non-i1 (non-vector) variables. Note that SETUEQ, SETOGE,
3205 // SETOLE, SETONE, SETULT and SETUGT should be expanded by legalize for
3206 // floating-point types.
3208 multiclass CRNotPat<dag pattern, dag result> {
3209 def : Pat<pattern, (crnot result)>;
3210 def : Pat<(not pattern), result>;
3212 // We can also fold the crnot into an extension:
3213 def : Pat<(i32 (zext pattern)),
3214 (SELECT_I4 result, (LI 0), (LI 1))>;
3215 def : Pat<(i32 (sext pattern)),
3216 (SELECT_I4 result, (LI 0), (LI -1))>;
3218 // We can also fold the crnot into an extension:
3219 def : Pat<(i64 (zext pattern)),
3220 (SELECT_I8 result, (LI8 0), (LI8 1))>;
3221 def : Pat<(i64 (sext pattern)),
3222 (SELECT_I8 result, (LI8 0), (LI8 -1))>;
3224 // FIXME: We should choose either a zext or a sext based on other constants
3226 def : Pat<(i32 (anyext pattern)),
3227 (SELECT_I4 result, (LI 0), (LI 1))>;
3229 def : Pat<(i64 (anyext pattern)),
3230 (SELECT_I8 result, (LI8 0), (LI8 1))>;
3233 // FIXME: Because of what seems like a bug in TableGen's type-inference code,
3234 // we need to write imm:$imm in the output patterns below, not just $imm, or
3235 // else the resulting matcher will not correctly add the immediate operand
3236 // (making it a register operand instead).
3239 multiclass ExtSetCCPat<CondCode cc, PatFrag pfrag,
3240 OutPatFrag rfrag, OutPatFrag rfrag8> {
3241 def : Pat<(i32 (zext (i1 (pfrag i32:$s1, cc)))),
3243 def : Pat<(i64 (zext (i1 (pfrag i64:$s1, cc)))),
3245 def : Pat<(i64 (zext (i1 (pfrag i32:$s1, cc)))),
3246 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1), sub_32)>;
3247 def : Pat<(i32 (zext (i1 (pfrag i64:$s1, cc)))),
3248 (EXTRACT_SUBREG (rfrag8 $s1), sub_32)>;
3250 def : Pat<(i32 (anyext (i1 (pfrag i32:$s1, cc)))),
3252 def : Pat<(i64 (anyext (i1 (pfrag i64:$s1, cc)))),
3254 def : Pat<(i64 (anyext (i1 (pfrag i32:$s1, cc)))),
3255 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1), sub_32)>;
3256 def : Pat<(i32 (anyext (i1 (pfrag i64:$s1, cc)))),
3257 (EXTRACT_SUBREG (rfrag8 $s1), sub_32)>;
3260 // Note that we do all inversions below with i(32|64)not, instead of using
3261 // (xori x, 1) because on the A2 nor has single-cycle latency while xori
3262 // has 2-cycle latency.
3264 defm : ExtSetCCPat<SETEQ,
3265 PatFrag<(ops node:$in, node:$cc),
3266 (setcc $in, 0, $cc)>,
3267 OutPatFrag<(ops node:$in),
3268 (RLWINM (CNTLZW $in), 27, 31, 31)>,
3269 OutPatFrag<(ops node:$in),
3270 (RLDICL (CNTLZD $in), 58, 63)> >;
3272 defm : ExtSetCCPat<SETNE,
3273 PatFrag<(ops node:$in, node:$cc),
3274 (setcc $in, 0, $cc)>,
3275 OutPatFrag<(ops node:$in),
3276 (RLWINM (i32not (CNTLZW $in)), 27, 31, 31)>,
3277 OutPatFrag<(ops node:$in),
3278 (RLDICL (i64not (CNTLZD $in)), 58, 63)> >;
3280 defm : ExtSetCCPat<SETLT,
3281 PatFrag<(ops node:$in, node:$cc),
3282 (setcc $in, 0, $cc)>,
3283 OutPatFrag<(ops node:$in),
3284 (RLWINM $in, 1, 31, 31)>,
3285 OutPatFrag<(ops node:$in),
3286 (RLDICL $in, 1, 63)> >;
3288 defm : ExtSetCCPat<SETGE,
3289 PatFrag<(ops node:$in, node:$cc),
3290 (setcc $in, 0, $cc)>,
3291 OutPatFrag<(ops node:$in),
3292 (RLWINM (i32not $in), 1, 31, 31)>,
3293 OutPatFrag<(ops node:$in),
3294 (RLDICL (i64not $in), 1, 63)> >;
3296 defm : ExtSetCCPat<SETGT,
3297 PatFrag<(ops node:$in, node:$cc),
3298 (setcc $in, 0, $cc)>,
3299 OutPatFrag<(ops node:$in),
3300 (RLWINM (ANDC (NEG $in), $in), 1, 31, 31)>,
3301 OutPatFrag<(ops node:$in),
3302 (RLDICL (ANDC8 (NEG8 $in), $in), 1, 63)> >;
3304 defm : ExtSetCCPat<SETLE,
3305 PatFrag<(ops node:$in, node:$cc),
3306 (setcc $in, 0, $cc)>,
3307 OutPatFrag<(ops node:$in),
3308 (RLWINM (ORC $in, (NEG $in)), 1, 31, 31)>,
3309 OutPatFrag<(ops node:$in),
3310 (RLDICL (ORC8 $in, (NEG8 $in)), 1, 63)> >;
3312 defm : ExtSetCCPat<SETLT,
3313 PatFrag<(ops node:$in, node:$cc),
3314 (setcc $in, -1, $cc)>,
3315 OutPatFrag<(ops node:$in),
3316 (RLWINM (AND $in, (ADDI $in, 1)), 1, 31, 31)>,
3317 OutPatFrag<(ops node:$in),
3318 (RLDICL (AND8 $in, (ADDI8 $in, 1)), 1, 63)> >;
3320 defm : ExtSetCCPat<SETGE,
3321 PatFrag<(ops node:$in, node:$cc),
3322 (setcc $in, -1, $cc)>,
3323 OutPatFrag<(ops node:$in),
3324 (RLWINM (NAND $in, (ADDI $in, 1)), 1, 31, 31)>,
3325 OutPatFrag<(ops node:$in),
3326 (RLDICL (NAND8 $in, (ADDI8 $in, 1)), 1, 63)> >;
3328 defm : ExtSetCCPat<SETGT,
3329 PatFrag<(ops node:$in, node:$cc),
3330 (setcc $in, -1, $cc)>,
3331 OutPatFrag<(ops node:$in),
3332 (RLWINM (i32not $in), 1, 31, 31)>,
3333 OutPatFrag<(ops node:$in),
3334 (RLDICL (i64not $in), 1, 63)> >;
3336 defm : ExtSetCCPat<SETLE,
3337 PatFrag<(ops node:$in, node:$cc),
3338 (setcc $in, -1, $cc)>,
3339 OutPatFrag<(ops node:$in),
3340 (RLWINM $in, 1, 31, 31)>,
3341 OutPatFrag<(ops node:$in),
3342 (RLDICL $in, 1, 63)> >;
3344 // An extended SETCC with shift amount.
3345 multiclass ExtSetCCShiftPat<CondCode cc, PatFrag pfrag,
3346 OutPatFrag rfrag, OutPatFrag rfrag8> {
3347 def : Pat<(i32 (zext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
3349 def : Pat<(i64 (zext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
3351 def : Pat<(i64 (zext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
3352 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1, $sa), sub_32)>;
3353 def : Pat<(i32 (zext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
3354 (EXTRACT_SUBREG (rfrag8 $s1, $sa), sub_32)>;
3356 def : Pat<(i32 (anyext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
3358 def : Pat<(i64 (anyext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
3360 def : Pat<(i64 (anyext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
3361 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1, $sa), sub_32)>;
3362 def : Pat<(i32 (anyext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
3363 (EXTRACT_SUBREG (rfrag8 $s1, $sa), sub_32)>;
3366 defm : ExtSetCCShiftPat<SETNE,
3367 PatFrag<(ops node:$in, node:$sa, node:$cc),
3368 (setcc (and $in, (shl 1, $sa)), 0, $cc)>,
3369 OutPatFrag<(ops node:$in, node:$sa),
3370 (RLWNM $in, (SUBFIC $sa, 32), 31, 31)>,
3371 OutPatFrag<(ops node:$in, node:$sa),
3372 (RLDCL $in, (SUBFIC $sa, 64), 63)> >;
3374 defm : ExtSetCCShiftPat<SETEQ,
3375 PatFrag<(ops node:$in, node:$sa, node:$cc),
3376 (setcc (and $in, (shl 1, $sa)), 0, $cc)>,
3377 OutPatFrag<(ops node:$in, node:$sa),
3378 (RLWNM (i32not $in),
3379 (SUBFIC $sa, 32), 31, 31)>,
3380 OutPatFrag<(ops node:$in, node:$sa),
3381 (RLDCL (i64not $in),
3382 (SUBFIC $sa, 64), 63)> >;
3385 def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETULT)),
3386 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_lt)>;
3387 def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETLT)),
3388 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_lt)>;
3389 def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETUGT)),
3390 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_gt)>;
3391 def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETGT)),
3392 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_gt)>;
3393 def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETEQ)),
3394 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_eq)>;
3395 def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETEQ)),
3396 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_eq)>;
3398 // For non-equality comparisons, the default code would materialize the
3399 // constant, then compare against it, like this:
3401 // ori r2, r2, 22136
3404 // Since we are just comparing for equality, we can emit this instead:
3405 // xoris r0,r3,0x1234
3406 // cmplwi cr0,r0,0x5678
3409 def : Pat<(i1 (setcc i32:$s1, imm:$imm, SETEQ)),
3410 (EXTRACT_SUBREG (CMPLWI (XORIS $s1, (HI16 imm:$imm)),
3411 (LO16 imm:$imm)), sub_eq)>;
3413 defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETUGE)),
3414 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_lt)>;
3415 defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETGE)),
3416 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_lt)>;
3417 defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETULE)),
3418 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_gt)>;
3419 defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETLE)),
3420 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_gt)>;
3421 defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETNE)),
3422 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_eq)>;
3423 defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETNE)),
3424 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_eq)>;
3426 defm : CRNotPat<(i1 (setcc i32:$s1, imm:$imm, SETNE)),
3427 (EXTRACT_SUBREG (CMPLWI (XORIS $s1, (HI16 imm:$imm)),
3428 (LO16 imm:$imm)), sub_eq)>;
3430 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETULT)),
3431 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_lt)>;
3432 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETLT)),
3433 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_lt)>;
3434 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETUGT)),
3435 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_gt)>;
3436 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETGT)),
3437 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_gt)>;
3438 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETEQ)),
3439 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_eq)>;
3441 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETUGE)),
3442 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_lt)>;
3443 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETGE)),
3444 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_lt)>;
3445 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETULE)),
3446 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_gt)>;
3447 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETLE)),
3448 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_gt)>;
3449 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETNE)),
3450 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_eq)>;
3453 def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETULT)),
3454 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_lt)>;
3455 def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETLT)),
3456 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_lt)>;
3457 def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETUGT)),
3458 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_gt)>;
3459 def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETGT)),
3460 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_gt)>;
3461 def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETEQ)),
3462 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_eq)>;
3463 def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETEQ)),
3464 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_eq)>;
3466 // For non-equality comparisons, the default code would materialize the
3467 // constant, then compare against it, like this:
3469 // ori r2, r2, 22136
3472 // Since we are just comparing for equality, we can emit this instead:
3473 // xoris r0,r3,0x1234
3474 // cmpldi cr0,r0,0x5678
3477 def : Pat<(i1 (setcc i64:$s1, imm64ZExt32:$imm, SETEQ)),
3478 (EXTRACT_SUBREG (CMPLDI (XORIS8 $s1, (HI16 imm:$imm)),
3479 (LO16 imm:$imm)), sub_eq)>;
3481 defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETUGE)),
3482 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_lt)>;
3483 defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETGE)),
3484 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_lt)>;
3485 defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETULE)),
3486 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_gt)>;
3487 defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETLE)),
3488 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_gt)>;
3489 defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETNE)),
3490 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_eq)>;
3491 defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETNE)),
3492 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_eq)>;
3494 defm : CRNotPat<(i1 (setcc i64:$s1, imm64ZExt32:$imm, SETNE)),
3495 (EXTRACT_SUBREG (CMPLDI (XORIS8 $s1, (HI16 imm:$imm)),
3496 (LO16 imm:$imm)), sub_eq)>;
3498 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETULT)),
3499 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_lt)>;
3500 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETLT)),
3501 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_lt)>;
3502 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETUGT)),
3503 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_gt)>;
3504 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETGT)),
3505 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_gt)>;
3506 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETEQ)),
3507 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_eq)>;
3509 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETUGE)),
3510 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_lt)>;
3511 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETGE)),
3512 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_lt)>;
3513 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETULE)),
3514 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_gt)>;
3515 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETLE)),
3516 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_gt)>;
3517 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETNE)),
3518 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_eq)>;
3521 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOLT)),
3522 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3523 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETLT)),
3524 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3525 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOGT)),
3526 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3527 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETGT)),
3528 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3529 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOEQ)),
3530 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3531 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETEQ)),
3532 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3533 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETUO)),
3534 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_un)>;
3536 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETUGE)),
3537 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3538 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETGE)),
3539 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3540 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETULE)),
3541 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3542 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETLE)),
3543 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3544 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETUNE)),
3545 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3546 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETNE)),
3547 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3548 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETO)),
3549 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_un)>;
3552 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOLT)),
3553 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3554 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETLT)),
3555 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3556 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOGT)),
3557 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3558 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETGT)),
3559 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3560 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOEQ)),
3561 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3562 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETEQ)),
3563 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3564 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETUO)),
3565 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_un)>;
3567 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETUGE)),
3568 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3569 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETGE)),
3570 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3571 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETULE)),
3572 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3573 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETLE)),
3574 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3575 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETUNE)),
3576 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3577 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETNE)),
3578 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3579 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETO)),
3580 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_un)>;
3582 // match select on i1 variables:
3583 def : Pat<(i1 (select i1:$cond, i1:$tval, i1:$fval)),
3584 (CROR (CRAND $cond , $tval),
3585 (CRAND (crnot $cond), $fval))>;
3587 // match selectcc on i1 variables:
3588 // select (lhs == rhs), tval, fval is:
3589 // ((lhs == rhs) & tval) | (!(lhs == rhs) & fval)
3590 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETLT)),
3591 (CROR (CRAND (CRANDC $lhs, $rhs), $tval),
3592 (CRAND (CRORC $rhs, $lhs), $fval))>;
3593 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETULT)),
3594 (CROR (CRAND (CRANDC $rhs, $lhs), $tval),
3595 (CRAND (CRORC $lhs, $rhs), $fval))>;
3596 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETLE)),
3597 (CROR (CRAND (CRORC $lhs, $rhs), $tval),
3598 (CRAND (CRANDC $rhs, $lhs), $fval))>;
3599 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETULE)),
3600 (CROR (CRAND (CRORC $rhs, $lhs), $tval),
3601 (CRAND (CRANDC $lhs, $rhs), $fval))>;
3602 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETEQ)),
3603 (CROR (CRAND (CREQV $lhs, $rhs), $tval),
3604 (CRAND (CRXOR $lhs, $rhs), $fval))>;
3605 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETGE)),
3606 (CROR (CRAND (CRORC $rhs, $lhs), $tval),
3607 (CRAND (CRANDC $lhs, $rhs), $fval))>;
3608 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETUGE)),
3609 (CROR (CRAND (CRORC $lhs, $rhs), $tval),
3610 (CRAND (CRANDC $rhs, $lhs), $fval))>;
3611 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETGT)),
3612 (CROR (CRAND (CRANDC $rhs, $lhs), $tval),
3613 (CRAND (CRORC $lhs, $rhs), $fval))>;
3614 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETUGT)),
3615 (CROR (CRAND (CRANDC $lhs, $rhs), $tval),
3616 (CRAND (CRORC $rhs, $lhs), $fval))>;
3617 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETNE)),
3618 (CROR (CRAND (CREQV $lhs, $rhs), $fval),
3619 (CRAND (CRXOR $lhs, $rhs), $tval))>;
3621 // match selectcc on i1 variables with non-i1 output.
3622 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETLT)),
3623 (SELECT_I4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3624 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETULT)),
3625 (SELECT_I4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3626 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETLE)),
3627 (SELECT_I4 (CRORC $lhs, $rhs), $tval, $fval)>;
3628 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETULE)),
3629 (SELECT_I4 (CRORC $rhs, $lhs), $tval, $fval)>;
3630 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETEQ)),
3631 (SELECT_I4 (CREQV $lhs, $rhs), $tval, $fval)>;
3632 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETGE)),
3633 (SELECT_I4 (CRORC $rhs, $lhs), $tval, $fval)>;
3634 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETUGE)),
3635 (SELECT_I4 (CRORC $lhs, $rhs), $tval, $fval)>;
3636 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETGT)),
3637 (SELECT_I4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3638 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETUGT)),
3639 (SELECT_I4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3640 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETNE)),
3641 (SELECT_I4 (CRXOR $lhs, $rhs), $tval, $fval)>;
3643 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETLT)),
3644 (SELECT_I8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3645 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETULT)),
3646 (SELECT_I8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3647 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETLE)),
3648 (SELECT_I8 (CRORC $lhs, $rhs), $tval, $fval)>;
3649 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETULE)),
3650 (SELECT_I8 (CRORC $rhs, $lhs), $tval, $fval)>;
3651 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETEQ)),
3652 (SELECT_I8 (CREQV $lhs, $rhs), $tval, $fval)>;
3653 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETGE)),
3654 (SELECT_I8 (CRORC $rhs, $lhs), $tval, $fval)>;
3655 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETUGE)),
3656 (SELECT_I8 (CRORC $lhs, $rhs), $tval, $fval)>;
3657 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETGT)),
3658 (SELECT_I8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3659 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETUGT)),
3660 (SELECT_I8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3661 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETNE)),
3662 (SELECT_I8 (CRXOR $lhs, $rhs), $tval, $fval)>;
3664 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETLT)),
3665 (SELECT_F4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3666 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETULT)),
3667 (SELECT_F4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3668 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETLE)),
3669 (SELECT_F4 (CRORC $lhs, $rhs), $tval, $fval)>;
3670 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETULE)),
3671 (SELECT_F4 (CRORC $rhs, $lhs), $tval, $fval)>;
3672 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETEQ)),
3673 (SELECT_F4 (CREQV $lhs, $rhs), $tval, $fval)>;
3674 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETGE)),
3675 (SELECT_F4 (CRORC $rhs, $lhs), $tval, $fval)>;
3676 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETUGE)),
3677 (SELECT_F4 (CRORC $lhs, $rhs), $tval, $fval)>;
3678 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETGT)),
3679 (SELECT_F4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3680 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETUGT)),
3681 (SELECT_F4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3682 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETNE)),
3683 (SELECT_F4 (CRXOR $lhs, $rhs), $tval, $fval)>;
3685 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETLT)),
3686 (SELECT_F8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3687 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETULT)),
3688 (SELECT_F8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3689 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETLE)),
3690 (SELECT_F8 (CRORC $lhs, $rhs), $tval, $fval)>;
3691 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETULE)),
3692 (SELECT_F8 (CRORC $rhs, $lhs), $tval, $fval)>;
3693 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETEQ)),
3694 (SELECT_F8 (CREQV $lhs, $rhs), $tval, $fval)>;
3695 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETGE)),
3696 (SELECT_F8 (CRORC $rhs, $lhs), $tval, $fval)>;
3697 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETUGE)),
3698 (SELECT_F8 (CRORC $lhs, $rhs), $tval, $fval)>;
3699 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETGT)),
3700 (SELECT_F8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3701 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETUGT)),
3702 (SELECT_F8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3703 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETNE)),
3704 (SELECT_F8 (CRXOR $lhs, $rhs), $tval, $fval)>;
3706 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETLT)),
3707 (SELECT_VRRC (CRANDC $lhs, $rhs), $tval, $fval)>;
3708 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETULT)),
3709 (SELECT_VRRC (CRANDC $rhs, $lhs), $tval, $fval)>;
3710 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETLE)),
3711 (SELECT_VRRC (CRORC $lhs, $rhs), $tval, $fval)>;
3712 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETULE)),
3713 (SELECT_VRRC (CRORC $rhs, $lhs), $tval, $fval)>;
3714 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETEQ)),
3715 (SELECT_VRRC (CREQV $lhs, $rhs), $tval, $fval)>;
3716 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETGE)),
3717 (SELECT_VRRC (CRORC $rhs, $lhs), $tval, $fval)>;
3718 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETUGE)),
3719 (SELECT_VRRC (CRORC $lhs, $rhs), $tval, $fval)>;
3720 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETGT)),
3721 (SELECT_VRRC (CRANDC $rhs, $lhs), $tval, $fval)>;
3722 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETUGT)),
3723 (SELECT_VRRC (CRANDC $lhs, $rhs), $tval, $fval)>;
3724 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETNE)),
3725 (SELECT_VRRC (CRXOR $lhs, $rhs), $tval, $fval)>;
3727 let usesCustomInserter = 1 in {
3728 def ANDIo_1_EQ_BIT : Pseudo<(outs crbitrc:$dst), (ins gprc:$in),
3730 [(set i1:$dst, (trunc (not i32:$in)))]>;
3731 def ANDIo_1_GT_BIT : Pseudo<(outs crbitrc:$dst), (ins gprc:$in),
3733 [(set i1:$dst, (trunc i32:$in))]>;
3735 def ANDIo_1_EQ_BIT8 : Pseudo<(outs crbitrc:$dst), (ins g8rc:$in),
3737 [(set i1:$dst, (trunc (not i64:$in)))]>;
3738 def ANDIo_1_GT_BIT8 : Pseudo<(outs crbitrc:$dst), (ins g8rc:$in),
3740 [(set i1:$dst, (trunc i64:$in))]>;
3743 def : Pat<(i1 (not (trunc i32:$in))),
3744 (ANDIo_1_EQ_BIT $in)>;
3745 def : Pat<(i1 (not (trunc i64:$in))),
3746 (ANDIo_1_EQ_BIT8 $in)>;
3748 //===----------------------------------------------------------------------===//
3749 // PowerPC Instructions used for assembler/disassembler only
3752 // FIXME: For B=0 or B > 8, the registers following RT are used.
3753 // WARNING: Do not add patterns for this instruction without fixing this.
3754 def LSWI : XForm_base_r3xo<31, 597, (outs gprc:$RT), (ins gprc:$A, u5imm:$B),
3755 "lswi $RT, $A, $B", IIC_LdStLoad, []>;
3757 // FIXME: For B=0 or B > 8, the registers following RT are used.
3758 // WARNING: Do not add patterns for this instruction without fixing this.
3759 def STSWI : XForm_base_r3xo<31, 725, (outs), (ins gprc:$RT, gprc:$A, u5imm:$B),
3760 "stswi $RT, $A, $B", IIC_LdStLoad, []>;
3762 def ISYNC : XLForm_2_ext<19, 150, 0, 0, 0, (outs), (ins),
3763 "isync", IIC_SprISYNC, []>;
3765 def ICBI : XForm_1a<31, 982, (outs), (ins memrr:$src),
3766 "icbi $src", IIC_LdStICBI, []>;
3768 // We used to have EIEIO as value but E[0-9A-Z] is a reserved name
3769 def EnforceIEIO : XForm_24_eieio<31, 854, (outs), (ins),
3770 "eieio", IIC_LdStLoad, []>;
3772 def WAIT : XForm_24_sync<31, 62, (outs), (ins i32imm:$L),
3773 "wait $L", IIC_LdStLoad, []>;
3775 def MBAR : XForm_mbar<31, 854, (outs), (ins u5imm:$MO),
3776 "mbar $MO", IIC_LdStLoad>, Requires<[IsBookE]>;
3778 def MTSR: XForm_sr<31, 210, (outs), (ins gprc:$RS, u4imm:$SR),
3779 "mtsr $SR, $RS", IIC_SprMTSR>;
3781 def MFSR: XForm_sr<31, 595, (outs gprc:$RS), (ins u4imm:$SR),
3782 "mfsr $RS, $SR", IIC_SprMFSR>;
3784 def MTSRIN: XForm_srin<31, 242, (outs), (ins gprc:$RS, gprc:$RB),
3785 "mtsrin $RS, $RB", IIC_SprMTSR>;
3787 def MFSRIN: XForm_srin<31, 659, (outs gprc:$RS), (ins gprc:$RB),
3788 "mfsrin $RS, $RB", IIC_SprMFSR>;
3790 def MTMSR: XForm_mtmsr<31, 146, (outs), (ins gprc:$RS, i32imm:$L),
3791 "mtmsr $RS, $L", IIC_SprMTMSR>;
3793 def WRTEE: XForm_mtmsr<31, 131, (outs), (ins gprc:$RS),
3794 "wrtee $RS", IIC_SprMTMSR>, Requires<[IsBookE]> {
3798 def WRTEEI: I<31, (outs), (ins i1imm:$E), "wrteei $E", IIC_SprMTMSR>,
3799 Requires<[IsBookE]> {
3803 let Inst{21-30} = 163;
3806 def DCCCI : XForm_tlb<454, (outs), (ins gprc:$A, gprc:$B),
3807 "dccci $A, $B", IIC_LdStLoad>, Requires<[IsPPC4xx]>;
3808 def ICCCI : XForm_tlb<966, (outs), (ins gprc:$A, gprc:$B),
3809 "iccci $A, $B", IIC_LdStLoad>, Requires<[IsPPC4xx]>;
3811 def : InstAlias<"dci 0", (DCCCI R0, R0)>, Requires<[IsPPC4xx]>;
3812 def : InstAlias<"dccci", (DCCCI R0, R0)>, Requires<[IsPPC4xx]>;
3813 def : InstAlias<"ici 0", (ICCCI R0, R0)>, Requires<[IsPPC4xx]>;
3814 def : InstAlias<"iccci", (ICCCI R0, R0)>, Requires<[IsPPC4xx]>;
3816 def MFMSR : XForm_rs<31, 83, (outs gprc:$RT), (ins),
3817 "mfmsr $RT", IIC_SprMFMSR, []>;
3819 def MTMSRD : XForm_mtmsr<31, 178, (outs), (ins gprc:$RS, i32imm:$L),
3820 "mtmsrd $RS, $L", IIC_SprMTMSRD>;
3822 def MCRFS : XLForm_3<63, 64, (outs crrc:$BF), (ins crrc:$BFA),
3823 "mcrfs $BF, $BFA", IIC_BrMCR>;
3825 def MTFSFI : XLForm_4<63, 134, (outs crrc:$BF), (ins i32imm:$U, i32imm:$W),
3826 "mtfsfi $BF, $U, $W", IIC_IntMFFS>;
3828 def MTFSFIo : XLForm_4<63, 134, (outs crrc:$BF), (ins i32imm:$U, i32imm:$W),
3829 "mtfsfi. $BF, $U, $W", IIC_IntMFFS>, isDOT;
3831 def : InstAlias<"mtfsfi $BF, $U", (MTFSFI crrc:$BF, i32imm:$U, 0)>;
3832 def : InstAlias<"mtfsfi. $BF, $U", (MTFSFIo crrc:$BF, i32imm:$U, 0)>;
3834 def MTFSF : XFLForm_1<63, 711, (outs),
3835 (ins i32imm:$FLM, f8rc:$FRB, i32imm:$L, i32imm:$W),
3836 "mtfsf $FLM, $FRB, $L, $W", IIC_IntMFFS, []>;
3837 def MTFSFo : XFLForm_1<63, 711, (outs),
3838 (ins i32imm:$FLM, f8rc:$FRB, i32imm:$L, i32imm:$W),
3839 "mtfsf. $FLM, $FRB, $L, $W", IIC_IntMFFS, []>, isDOT;
3841 def : InstAlias<"mtfsf $FLM, $FRB", (MTFSF i32imm:$FLM, f8rc:$FRB, 0, 0)>;
3842 def : InstAlias<"mtfsf. $FLM, $FRB", (MTFSFo i32imm:$FLM, f8rc:$FRB, 0, 0)>;
3844 def SLBIE : XForm_16b<31, 434, (outs), (ins gprc:$RB),
3845 "slbie $RB", IIC_SprSLBIE, []>;
3847 def SLBMTE : XForm_26<31, 402, (outs), (ins gprc:$RS, gprc:$RB),
3848 "slbmte $RS, $RB", IIC_SprSLBMTE, []>;
3850 def SLBMFEE : XForm_26<31, 915, (outs gprc:$RT), (ins gprc:$RB),
3851 "slbmfee $RT, $RB", IIC_SprSLBMFEE, []>;
3853 def SLBMFEV : XLForm_1_gen<31, 851, (outs gprc:$RT), (ins gprc:$RB),
3854 "slbmfev $RT, $RB", IIC_SprSLBMFEV, []>;
3856 def SLBIA : XForm_0<31, 498, (outs), (ins), "slbia", IIC_SprSLBIA, []>;
3858 def TLBIA : XForm_0<31, 370, (outs), (ins),
3859 "tlbia", IIC_SprTLBIA, []>;
3861 def TLBSYNC : XForm_0<31, 566, (outs), (ins),
3862 "tlbsync", IIC_SprTLBSYNC, []>;
3864 def TLBIEL : XForm_16b<31, 274, (outs), (ins gprc:$RB),
3865 "tlbiel $RB", IIC_SprTLBIEL, []>;
3867 def TLBLD : XForm_16b<31, 978, (outs), (ins gprc:$RB),
3868 "tlbld $RB", IIC_LdStLoad, []>, Requires<[IsPPC6xx]>;
3869 def TLBLI : XForm_16b<31, 1010, (outs), (ins gprc:$RB),
3870 "tlbli $RB", IIC_LdStLoad, []>, Requires<[IsPPC6xx]>;
3872 def TLBIE : XForm_26<31, 306, (outs), (ins gprc:$RS, gprc:$RB),
3873 "tlbie $RB,$RS", IIC_SprTLBIE, []>;
3875 def TLBSX : XForm_tlb<914, (outs), (ins gprc:$A, gprc:$B), "tlbsx $A, $B",
3876 IIC_LdStLoad>, Requires<[IsBookE]>;
3878 def TLBIVAX : XForm_tlb<786, (outs), (ins gprc:$A, gprc:$B), "tlbivax $A, $B",
3879 IIC_LdStLoad>, Requires<[IsBookE]>;
3881 def TLBRE : XForm_24_eieio<31, 946, (outs), (ins),
3882 "tlbre", IIC_LdStLoad, []>, Requires<[IsBookE]>;
3884 def TLBWE : XForm_24_eieio<31, 978, (outs), (ins),
3885 "tlbwe", IIC_LdStLoad, []>, Requires<[IsBookE]>;
3887 def TLBRE2 : XForm_tlbws<31, 946, (outs gprc:$RS), (ins gprc:$A, i1imm:$WS),
3888 "tlbre $RS, $A, $WS", IIC_LdStLoad, []>, Requires<[IsPPC4xx]>;
3890 def TLBWE2 : XForm_tlbws<31, 978, (outs), (ins gprc:$RS, gprc:$A, i1imm:$WS),
3891 "tlbwe $RS, $A, $WS", IIC_LdStLoad, []>, Requires<[IsPPC4xx]>;
3893 def TLBSX2 : XForm_base_r3xo<31, 914, (outs), (ins gprc:$RST, gprc:$A, gprc:$B),
3894 "tlbsx $RST, $A, $B", IIC_LdStLoad, []>,
3895 Requires<[IsPPC4xx]>;
3896 def TLBSX2D : XForm_base_r3xo<31, 914, (outs),
3897 (ins gprc:$RST, gprc:$A, gprc:$B),
3898 "tlbsx. $RST, $A, $B", IIC_LdStLoad, []>,
3899 Requires<[IsPPC4xx]>, isDOT;
3901 def RFID : XForm_0<19, 18, (outs), (ins), "rfid", IIC_IntRFID, []>;
3903 def RFI : XForm_0<19, 50, (outs), (ins), "rfi", IIC_SprRFI, []>,
3904 Requires<[IsBookE]>;
3905 def RFCI : XForm_0<19, 51, (outs), (ins), "rfci", IIC_BrB, []>,
3906 Requires<[IsBookE]>;
3908 def RFDI : XForm_0<19, 39, (outs), (ins), "rfdi", IIC_BrB, []>,
3910 def RFMCI : XForm_0<19, 38, (outs), (ins), "rfmci", IIC_BrB, []>,
3913 def MFDCR : XFXForm_1<31, 323, (outs gprc:$RT), (ins i32imm:$SPR),
3914 "mfdcr $RT, $SPR", IIC_SprMFSPR>, Requires<[IsPPC4xx]>;
3915 def MTDCR : XFXForm_1<31, 451, (outs), (ins gprc:$RT, i32imm:$SPR),
3916 "mtdcr $SPR, $RT", IIC_SprMTSPR>, Requires<[IsPPC4xx]>;
3918 def HRFID : XLForm_1_np<19, 274, (outs), (ins), "hrfid", IIC_BrB, []>;
3919 def NAP : XLForm_1_np<19, 434, (outs), (ins), "nap", IIC_BrB, []>;
3921 def ATTN : XForm_attn<0, 256, (outs), (ins), "attn", IIC_BrB>;
3923 def LBZCIX : XForm_base_r3xo<31, 853, (outs gprc:$RST), (ins gprc:$A, gprc:$B),
3924 "lbzcix $RST, $A, $B", IIC_LdStLoad, []>;
3925 def LHZCIX : XForm_base_r3xo<31, 821, (outs gprc:$RST), (ins gprc:$A, gprc:$B),
3926 "lhzcix $RST, $A, $B", IIC_LdStLoad, []>;
3927 def LWZCIX : XForm_base_r3xo<31, 789, (outs gprc:$RST), (ins gprc:$A, gprc:$B),
3928 "lwzcix $RST, $A, $B", IIC_LdStLoad, []>;
3929 def LDCIX : XForm_base_r3xo<31, 885, (outs gprc:$RST), (ins gprc:$A, gprc:$B),
3930 "ldcix $RST, $A, $B", IIC_LdStLoad, []>;
3932 def STBCIX : XForm_base_r3xo<31, 981, (outs), (ins gprc:$RST, gprc:$A, gprc:$B),
3933 "stbcix $RST, $A, $B", IIC_LdStLoad, []>;
3934 def STHCIX : XForm_base_r3xo<31, 949, (outs), (ins gprc:$RST, gprc:$A, gprc:$B),
3935 "sthcix $RST, $A, $B", IIC_LdStLoad, []>;
3936 def STWCIX : XForm_base_r3xo<31, 917, (outs), (ins gprc:$RST, gprc:$A, gprc:$B),
3937 "stwcix $RST, $A, $B", IIC_LdStLoad, []>;
3938 def STDCIX : XForm_base_r3xo<31, 1013, (outs), (ins gprc:$RST, gprc:$A, gprc:$B),
3939 "stdcix $RST, $A, $B", IIC_LdStLoad, []>;
3941 // External PID Load Store Instructions
3943 def LBEPX : XForm_1<31, 95, (outs gprc:$rD), (ins memrr:$src),
3944 "lbepx $rD, $src", IIC_LdStLoad, []>,
3947 def LFDEPX : XForm_25<31, 607, (outs f8rc:$frD), (ins memrr:$src),
3948 "lfdepx $frD, $src", IIC_LdStLFD, []>,
3951 def LHEPX : XForm_1<31, 287, (outs gprc:$rD), (ins memrr:$src),
3952 "lhepx $rD, $src", IIC_LdStLoad, []>,
3955 def LWEPX : XForm_1<31, 31, (outs gprc:$rD), (ins memrr:$src),
3956 "lwepx $rD, $src", IIC_LdStLoad, []>,
3959 def STBEPX : XForm_8<31, 223, (outs), (ins gprc:$rS, memrr:$dst),
3960 "stbepx $rS, $dst", IIC_LdStStore, []>,
3963 def STFDEPX : XForm_28<31, 735, (outs), (ins f8rc:$frS, memrr:$dst),
3964 "stfdepx $frS, $dst", IIC_LdStSTFD, []>,
3967 def STHEPX : XForm_8<31, 415, (outs), (ins gprc:$rS, memrr:$dst),
3968 "sthepx $rS, $dst", IIC_LdStStore, []>,
3971 def STWEPX : XForm_8<31, 159, (outs), (ins gprc:$rS, memrr:$dst),
3972 "stwepx $rS, $dst", IIC_LdStStore, []>,
3975 def DCBFEP : DCB_Form<127, 0, (outs), (ins memrr:$dst), "dcbfep $dst",
3976 IIC_LdStDCBF, []>, Requires<[IsE500]>;
3978 def DCBSTEP : DCB_Form<63, 0, (outs), (ins memrr:$dst), "dcbstep $dst",
3979 IIC_LdStDCBF, []>, Requires<[IsE500]>;
3981 def DCBTEP : DCB_Form_hint<319, (outs), (ins memrr:$dst, u5imm:$TH),
3982 "dcbtep $TH, $dst", IIC_LdStDCBF, []>,
3985 def DCBTSTEP : DCB_Form_hint<255, (outs), (ins memrr:$dst, u5imm:$TH),
3986 "dcbtstep $TH, $dst", IIC_LdStDCBF, []>,
3989 def DCBZEP : DCB_Form<1023, 0, (outs), (ins memrr:$dst), "dcbzep $dst",
3990 IIC_LdStDCBF, []>, Requires<[IsE500]>;
3992 def DCBZLEP : DCB_Form<1023, 1, (outs), (ins memrr:$dst), "dcbzlep $dst",
3993 IIC_LdStDCBF, []>, Requires<[IsE500]>;
3995 def ICBIEP : XForm_1a<31, 991, (outs), (ins memrr:$src), "icbiep $src",
3996 IIC_LdStICBI, []>, Requires<[IsE500]>;
3998 //===----------------------------------------------------------------------===//
3999 // PowerPC Assembler Instruction Aliases
4002 // Pseudo-instructions for alternate assembly syntax (never used by codegen).
4003 // These are aliases that require C++ handling to convert to the target
4004 // instruction, while InstAliases can be handled directly by tblgen.
4005 class PPCAsmPseudo<string asm, dag iops>
4007 let Namespace = "PPC";
4008 bit PPC64 = 0; // Default value, override with isPPC64
4010 let OutOperandList = (outs);
4011 let InOperandList = iops;
4013 let AsmString = asm;
4014 let isAsmParserOnly = 1;
4016 let hasNoSchedulingInfo = 1;
4019 def : InstAlias<"sc", (SC 0)>;
4021 def : InstAlias<"sync", (SYNC 0)>, Requires<[HasSYNC]>;
4022 def : InstAlias<"msync", (SYNC 0), 0>, Requires<[HasSYNC]>;
4023 def : InstAlias<"lwsync", (SYNC 1)>, Requires<[HasSYNC]>;
4024 def : InstAlias<"ptesync", (SYNC 2)>, Requires<[HasSYNC]>;
4026 def : InstAlias<"wait", (WAIT 0)>;
4027 def : InstAlias<"waitrsv", (WAIT 1)>;
4028 def : InstAlias<"waitimpl", (WAIT 2)>;
4030 def : InstAlias<"mbar", (MBAR 0)>, Requires<[IsBookE]>;
4032 def DCBTx : PPCAsmPseudo<"dcbt $dst", (ins memrr:$dst)>;
4033 def DCBTSTx : PPCAsmPseudo<"dcbtst $dst", (ins memrr:$dst)>;
4035 def DCBTCT : PPCAsmPseudo<"dcbtct $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
4036 def DCBTDS : PPCAsmPseudo<"dcbtds $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
4037 def DCBTT : PPCAsmPseudo<"dcbtt $dst", (ins memrr:$dst)>;
4039 def DCBTSTCT : PPCAsmPseudo<"dcbtstct $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
4040 def DCBTSTDS : PPCAsmPseudo<"dcbtstds $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
4041 def DCBTSTT : PPCAsmPseudo<"dcbtstt $dst", (ins memrr:$dst)>;
4043 def DCBFx : PPCAsmPseudo<"dcbf $dst", (ins memrr:$dst)>;
4044 def DCBFL : PPCAsmPseudo<"dcbfl $dst", (ins memrr:$dst)>;
4045 def DCBFLP : PPCAsmPseudo<"dcbflp $dst", (ins memrr:$dst)>;
4047 def : InstAlias<"crset $bx", (CREQV crbitrc:$bx, crbitrc:$bx, crbitrc:$bx)>;
4048 def : InstAlias<"crclr $bx", (CRXOR crbitrc:$bx, crbitrc:$bx, crbitrc:$bx)>;
4049 def : InstAlias<"crmove $bx, $by", (CROR crbitrc:$bx, crbitrc:$by, crbitrc:$by)>;
4050 def : InstAlias<"crnot $bx, $by", (CRNOR crbitrc:$bx, crbitrc:$by, crbitrc:$by)>;
4052 def : InstAlias<"mtxer $Rx", (MTSPR 1, gprc:$Rx)>;
4053 def : InstAlias<"mfxer $Rx", (MFSPR gprc:$Rx, 1)>;
4055 def : InstAlias<"mfrtcu $Rx", (MFSPR gprc:$Rx, 4)>;
4056 def : InstAlias<"mfrtcl $Rx", (MFSPR gprc:$Rx, 5)>;
4058 def : InstAlias<"mtdscr $Rx", (MTSPR 17, gprc:$Rx)>;
4059 def : InstAlias<"mfdscr $Rx", (MFSPR gprc:$Rx, 17)>;
4061 def : InstAlias<"mtdsisr $Rx", (MTSPR 18, gprc:$Rx)>;
4062 def : InstAlias<"mfdsisr $Rx", (MFSPR gprc:$Rx, 18)>;
4064 def : InstAlias<"mtdar $Rx", (MTSPR 19, gprc:$Rx)>;
4065 def : InstAlias<"mfdar $Rx", (MFSPR gprc:$Rx, 19)>;
4067 def : InstAlias<"mtdec $Rx", (MTSPR 22, gprc:$Rx)>;
4068 def : InstAlias<"mfdec $Rx", (MFSPR gprc:$Rx, 22)>;
4070 def : InstAlias<"mtsdr1 $Rx", (MTSPR 25, gprc:$Rx)>;
4071 def : InstAlias<"mfsdr1 $Rx", (MFSPR gprc:$Rx, 25)>;
4073 def : InstAlias<"mtsrr0 $Rx", (MTSPR 26, gprc:$Rx)>;
4074 def : InstAlias<"mfsrr0 $Rx", (MFSPR gprc:$Rx, 26)>;
4076 def : InstAlias<"mtsrr1 $Rx", (MTSPR 27, gprc:$Rx)>;
4077 def : InstAlias<"mfsrr1 $Rx", (MFSPR gprc:$Rx, 27)>;
4079 def : InstAlias<"mtsrr2 $Rx", (MTSPR 990, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4080 def : InstAlias<"mfsrr2 $Rx", (MFSPR gprc:$Rx, 990)>, Requires<[IsPPC4xx]>;
4082 def : InstAlias<"mtsrr3 $Rx", (MTSPR 991, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4083 def : InstAlias<"mfsrr3 $Rx", (MFSPR gprc:$Rx, 991)>, Requires<[IsPPC4xx]>;
4085 def : InstAlias<"mtcfar $Rx", (MTSPR 28, gprc:$Rx)>;
4086 def : InstAlias<"mfcfar $Rx", (MFSPR gprc:$Rx, 28)>;
4088 def : InstAlias<"mtamr $Rx", (MTSPR 29, gprc:$Rx)>;
4089 def : InstAlias<"mfamr $Rx", (MFSPR gprc:$Rx, 29)>;
4091 def : InstAlias<"mtpid $Rx", (MTSPR 48, gprc:$Rx)>, Requires<[IsBookE]>;
4092 def : InstAlias<"mfpid $Rx", (MFSPR gprc:$Rx, 48)>, Requires<[IsBookE]>;
4094 def : InstAlias<"mftb $Rx", (MFTB gprc:$Rx, 268)>;
4095 def : InstAlias<"mftbl $Rx", (MFTB gprc:$Rx, 268)>;
4096 def : InstAlias<"mftbu $Rx", (MFTB gprc:$Rx, 269)>;
4098 def : InstAlias<"mttbl $Rx", (MTSPR 284, gprc:$Rx)>;
4099 def : InstAlias<"mttbu $Rx", (MTSPR 285, gprc:$Rx)>;
4101 def : InstAlias<"mftblo $Rx", (MFSPR gprc:$Rx, 989)>, Requires<[IsPPC4xx]>;
4102 def : InstAlias<"mttblo $Rx", (MTSPR 989, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4103 def : InstAlias<"mftbhi $Rx", (MFSPR gprc:$Rx, 988)>, Requires<[IsPPC4xx]>;
4104 def : InstAlias<"mttbhi $Rx", (MTSPR 988, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4106 def : InstAlias<"xnop", (XORI R0, R0, 0)>;
4108 def : InstAlias<"mr $rA, $rB", (OR8 g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
4109 def : InstAlias<"mr. $rA, $rB", (OR8o g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
4111 def : InstAlias<"not $rA, $rB", (NOR8 g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
4112 def : InstAlias<"not. $rA, $rB", (NOR8o g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
4114 def : InstAlias<"mtcr $rA", (MTCRF8 255, g8rc:$rA)>;
4116 foreach BATR = 0-3 in {
4117 def : InstAlias<"mtdbatu "#BATR#", $Rx",
4118 (MTSPR !add(BATR, !add(BATR, 536)), gprc:$Rx)>,
4119 Requires<[IsPPC6xx]>;
4120 def : InstAlias<"mfdbatu $Rx, "#BATR,
4121 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 536)))>,
4122 Requires<[IsPPC6xx]>;
4123 def : InstAlias<"mtdbatl "#BATR#", $Rx",
4124 (MTSPR !add(BATR, !add(BATR, 537)), gprc:$Rx)>,
4125 Requires<[IsPPC6xx]>;
4126 def : InstAlias<"mfdbatl $Rx, "#BATR,
4127 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 537)))>,
4128 Requires<[IsPPC6xx]>;
4129 def : InstAlias<"mtibatu "#BATR#", $Rx",
4130 (MTSPR !add(BATR, !add(BATR, 528)), gprc:$Rx)>,
4131 Requires<[IsPPC6xx]>;
4132 def : InstAlias<"mfibatu $Rx, "#BATR,
4133 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 528)))>,
4134 Requires<[IsPPC6xx]>;
4135 def : InstAlias<"mtibatl "#BATR#", $Rx",
4136 (MTSPR !add(BATR, !add(BATR, 529)), gprc:$Rx)>,
4137 Requires<[IsPPC6xx]>;
4138 def : InstAlias<"mfibatl $Rx, "#BATR,
4139 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 529)))>,
4140 Requires<[IsPPC6xx]>;
4143 foreach BR = 0-7 in {
4144 def : InstAlias<"mfbr"#BR#" $Rx",
4145 (MFDCR gprc:$Rx, !add(BR, 0x80))>,
4146 Requires<[IsPPC4xx]>;
4147 def : InstAlias<"mtbr"#BR#" $Rx",
4148 (MTDCR gprc:$Rx, !add(BR, 0x80))>,
4149 Requires<[IsPPC4xx]>;
4152 def : InstAlias<"mtdccr $Rx", (MTSPR 1018, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4153 def : InstAlias<"mfdccr $Rx", (MFSPR gprc:$Rx, 1018)>, Requires<[IsPPC4xx]>;
4155 def : InstAlias<"mticcr $Rx", (MTSPR 1019, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4156 def : InstAlias<"mficcr $Rx", (MFSPR gprc:$Rx, 1019)>, Requires<[IsPPC4xx]>;
4158 def : InstAlias<"mtdear $Rx", (MTSPR 981, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4159 def : InstAlias<"mfdear $Rx", (MFSPR gprc:$Rx, 981)>, Requires<[IsPPC4xx]>;
4161 def : InstAlias<"mtesr $Rx", (MTSPR 980, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4162 def : InstAlias<"mfesr $Rx", (MFSPR gprc:$Rx, 980)>, Requires<[IsPPC4xx]>;
4164 def : InstAlias<"mfspefscr $Rx", (MFSPR gprc:$Rx, 512)>;
4165 def : InstAlias<"mtspefscr $Rx", (MTSPR 512, gprc:$Rx)>;
4167 def : InstAlias<"mttcr $Rx", (MTSPR 986, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4168 def : InstAlias<"mftcr $Rx", (MFSPR gprc:$Rx, 986)>, Requires<[IsPPC4xx]>;
4170 def LAx : PPCAsmPseudo<"la $rA, $addr", (ins gprc:$rA, memri:$addr)>;
4172 def SUBI : PPCAsmPseudo<"subi $rA, $rB, $imm",
4173 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4174 def SUBIS : PPCAsmPseudo<"subis $rA, $rB, $imm",
4175 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4176 def SUBIC : PPCAsmPseudo<"subic $rA, $rB, $imm",
4177 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4178 def SUBICo : PPCAsmPseudo<"subic. $rA, $rB, $imm",
4179 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4181 def : InstAlias<"sub $rA, $rB, $rC", (SUBF8 g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
4182 def : InstAlias<"sub. $rA, $rB, $rC", (SUBF8o g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
4183 def : InstAlias<"subc $rA, $rB, $rC", (SUBFC8 g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
4184 def : InstAlias<"subc. $rA, $rB, $rC", (SUBFC8o g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
4186 def : InstAlias<"mtmsrd $RS", (MTMSRD gprc:$RS, 0)>;
4187 def : InstAlias<"mtmsr $RS", (MTMSR gprc:$RS, 0)>;
4189 def : InstAlias<"mfasr $RT", (MFSPR gprc:$RT, 280)>;
4190 def : InstAlias<"mtasr $RT", (MTSPR 280, gprc:$RT)>;
4192 foreach SPRG = 0-3 in {
4193 def : InstAlias<"mfsprg $RT, "#SPRG, (MFSPR gprc:$RT, !add(SPRG, 272))>;
4194 def : InstAlias<"mfsprg"#SPRG#" $RT", (MFSPR gprc:$RT, !add(SPRG, 272))>;
4195 def : InstAlias<"mtsprg "#SPRG#", $RT", (MTSPR !add(SPRG, 272), gprc:$RT)>;
4196 def : InstAlias<"mtsprg"#SPRG#" $RT", (MTSPR !add(SPRG, 272), gprc:$RT)>;
4198 foreach SPRG = 4-7 in {
4199 def : InstAlias<"mfsprg $RT, "#SPRG, (MFSPR gprc:$RT, !add(SPRG, 256))>,
4200 Requires<[IsBookE]>;
4201 def : InstAlias<"mfsprg"#SPRG#" $RT", (MFSPR gprc:$RT, !add(SPRG, 256))>,
4202 Requires<[IsBookE]>;
4203 def : InstAlias<"mtsprg "#SPRG#", $RT", (MTSPR !add(SPRG, 256), gprc:$RT)>,
4204 Requires<[IsBookE]>;
4205 def : InstAlias<"mtsprg"#SPRG#" $RT", (MTSPR !add(SPRG, 256), gprc:$RT)>,
4206 Requires<[IsBookE]>;
4209 def : InstAlias<"mtasr $RS", (MTSPR 280, gprc:$RS)>;
4211 def : InstAlias<"mfdec $RT", (MFSPR gprc:$RT, 22)>;
4212 def : InstAlias<"mtdec $RT", (MTSPR 22, gprc:$RT)>;
4214 def : InstAlias<"mfpvr $RT", (MFSPR gprc:$RT, 287)>;
4216 def : InstAlias<"mfsdr1 $RT", (MFSPR gprc:$RT, 25)>;
4217 def : InstAlias<"mtsdr1 $RT", (MTSPR 25, gprc:$RT)>;
4219 def : InstAlias<"mfsrr0 $RT", (MFSPR gprc:$RT, 26)>;
4220 def : InstAlias<"mfsrr1 $RT", (MFSPR gprc:$RT, 27)>;
4221 def : InstAlias<"mtsrr0 $RT", (MTSPR 26, gprc:$RT)>;
4222 def : InstAlias<"mtsrr1 $RT", (MTSPR 27, gprc:$RT)>;
4224 def : InstAlias<"tlbie $RB", (TLBIE R0, gprc:$RB)>;
4226 def : InstAlias<"tlbrehi $RS, $A", (TLBRE2 gprc:$RS, gprc:$A, 0)>,
4227 Requires<[IsPPC4xx]>;
4228 def : InstAlias<"tlbrelo $RS, $A", (TLBRE2 gprc:$RS, gprc:$A, 1)>,
4229 Requires<[IsPPC4xx]>;
4230 def : InstAlias<"tlbwehi $RS, $A", (TLBWE2 gprc:$RS, gprc:$A, 0)>,
4231 Requires<[IsPPC4xx]>;
4232 def : InstAlias<"tlbwelo $RS, $A", (TLBWE2 gprc:$RS, gprc:$A, 1)>,
4233 Requires<[IsPPC4xx]>;
4235 def EXTLWI : PPCAsmPseudo<"extlwi $rA, $rS, $n, $b",
4236 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4237 def EXTLWIo : PPCAsmPseudo<"extlwi. $rA, $rS, $n, $b",
4238 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4239 def EXTRWI : PPCAsmPseudo<"extrwi $rA, $rS, $n, $b",
4240 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4241 def EXTRWIo : PPCAsmPseudo<"extrwi. $rA, $rS, $n, $b",
4242 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4243 def INSLWI : PPCAsmPseudo<"inslwi $rA, $rS, $n, $b",
4244 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4245 def INSLWIo : PPCAsmPseudo<"inslwi. $rA, $rS, $n, $b",
4246 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4247 def INSRWI : PPCAsmPseudo<"insrwi $rA, $rS, $n, $b",
4248 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4249 def INSRWIo : PPCAsmPseudo<"insrwi. $rA, $rS, $n, $b",
4250 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4251 def ROTRWI : PPCAsmPseudo<"rotrwi $rA, $rS, $n",
4252 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4253 def ROTRWIo : PPCAsmPseudo<"rotrwi. $rA, $rS, $n",
4254 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4255 def SLWI : PPCAsmPseudo<"slwi $rA, $rS, $n",
4256 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4257 def SLWIo : PPCAsmPseudo<"slwi. $rA, $rS, $n",
4258 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4259 def SRWI : PPCAsmPseudo<"srwi $rA, $rS, $n",
4260 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4261 def SRWIo : PPCAsmPseudo<"srwi. $rA, $rS, $n",
4262 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4263 def CLRRWI : PPCAsmPseudo<"clrrwi $rA, $rS, $n",
4264 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4265 def CLRRWIo : PPCAsmPseudo<"clrrwi. $rA, $rS, $n",
4266 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4267 def CLRLSLWI : PPCAsmPseudo<"clrlslwi $rA, $rS, $b, $n",
4268 (ins gprc:$rA, gprc:$rS, u5imm:$b, u5imm:$n)>;
4269 def CLRLSLWIo : PPCAsmPseudo<"clrlslwi. $rA, $rS, $b, $n",
4270 (ins gprc:$rA, gprc:$rS, u5imm:$b, u5imm:$n)>;
4272 def : InstAlias<"rotlwi $rA, $rS, $n", (RLWINM gprc:$rA, gprc:$rS, u5imm:$n, 0, 31)>;
4273 def : InstAlias<"rotlwi. $rA, $rS, $n", (RLWINMo gprc:$rA, gprc:$rS, u5imm:$n, 0, 31)>;
4274 def : InstAlias<"rotlw $rA, $rS, $rB", (RLWNM gprc:$rA, gprc:$rS, gprc:$rB, 0, 31)>;
4275 def : InstAlias<"rotlw. $rA, $rS, $rB", (RLWNMo gprc:$rA, gprc:$rS, gprc:$rB, 0, 31)>;
4276 def : InstAlias<"clrlwi $rA, $rS, $n", (RLWINM gprc:$rA, gprc:$rS, 0, u5imm:$n, 31)>;
4277 def : InstAlias<"clrlwi. $rA, $rS, $n", (RLWINMo gprc:$rA, gprc:$rS, 0, u5imm:$n, 31)>;
4279 def : InstAlias<"cntlzw $rA, $rS", (CNTLZW gprc:$rA, gprc:$rS)>;
4280 def : InstAlias<"cntlzw. $rA, $rS", (CNTLZWo gprc:$rA, gprc:$rS)>;
4281 // The POWER variant
4282 def : MnemonicAlias<"cntlz", "cntlzw">;
4283 def : MnemonicAlias<"cntlz.", "cntlzw.">;
4285 def EXTLDI : PPCAsmPseudo<"extldi $rA, $rS, $n, $b",
4286 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4287 def EXTLDIo : PPCAsmPseudo<"extldi. $rA, $rS, $n, $b",
4288 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4289 def EXTRDI : PPCAsmPseudo<"extrdi $rA, $rS, $n, $b",
4290 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4291 def EXTRDIo : PPCAsmPseudo<"extrdi. $rA, $rS, $n, $b",
4292 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4293 def INSRDI : PPCAsmPseudo<"insrdi $rA, $rS, $n, $b",
4294 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4295 def INSRDIo : PPCAsmPseudo<"insrdi. $rA, $rS, $n, $b",
4296 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4297 def ROTRDI : PPCAsmPseudo<"rotrdi $rA, $rS, $n",
4298 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4299 def ROTRDIo : PPCAsmPseudo<"rotrdi. $rA, $rS, $n",
4300 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4301 def SLDI : PPCAsmPseudo<"sldi $rA, $rS, $n",
4302 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4303 def SLDIo : PPCAsmPseudo<"sldi. $rA, $rS, $n",
4304 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4305 def SRDI : PPCAsmPseudo<"srdi $rA, $rS, $n",
4306 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4307 def SRDIo : PPCAsmPseudo<"srdi. $rA, $rS, $n",
4308 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4309 def CLRRDI : PPCAsmPseudo<"clrrdi $rA, $rS, $n",
4310 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4311 def CLRRDIo : PPCAsmPseudo<"clrrdi. $rA, $rS, $n",
4312 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4313 def CLRLSLDI : PPCAsmPseudo<"clrlsldi $rA, $rS, $b, $n",
4314 (ins g8rc:$rA, g8rc:$rS, u6imm:$b, u6imm:$n)>;
4315 def CLRLSLDIo : PPCAsmPseudo<"clrlsldi. $rA, $rS, $b, $n",
4316 (ins g8rc:$rA, g8rc:$rS, u6imm:$b, u6imm:$n)>;
4317 def SUBPCIS : PPCAsmPseudo<"subpcis $RT, $D", (ins g8rc:$RT, s16imm:$D)>;
4319 def : InstAlias<"rotldi $rA, $rS, $n", (RLDICL g8rc:$rA, g8rc:$rS, u6imm:$n, 0)>;
4320 def : InstAlias<"rotldi. $rA, $rS, $n", (RLDICLo g8rc:$rA, g8rc:$rS, u6imm:$n, 0)>;
4321 def : InstAlias<"rotld $rA, $rS, $rB", (RLDCL g8rc:$rA, g8rc:$rS, gprc:$rB, 0)>;
4322 def : InstAlias<"rotld. $rA, $rS, $rB", (RLDCLo g8rc:$rA, g8rc:$rS, gprc:$rB, 0)>;
4323 def : InstAlias<"clrldi $rA, $rS, $n", (RLDICL g8rc:$rA, g8rc:$rS, 0, u6imm:$n)>;
4324 def : InstAlias<"clrldi $rA, $rS, $n",
4325 (RLDICL_32_64 g8rc:$rA, gprc:$rS, 0, u6imm:$n)>;
4326 def : InstAlias<"clrldi. $rA, $rS, $n", (RLDICLo g8rc:$rA, g8rc:$rS, 0, u6imm:$n)>;
4327 def : InstAlias<"lnia $RT", (ADDPCIS g8rc:$RT, 0)>;
4329 def RLWINMbm : PPCAsmPseudo<"rlwinm $rA, $rS, $n, $b",
4330 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4331 def RLWINMobm : PPCAsmPseudo<"rlwinm. $rA, $rS, $n, $b",
4332 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4333 def RLWIMIbm : PPCAsmPseudo<"rlwimi $rA, $rS, $n, $b",
4334 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4335 def RLWIMIobm : PPCAsmPseudo<"rlwimi. $rA, $rS, $n, $b",
4336 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4337 def RLWNMbm : PPCAsmPseudo<"rlwnm $rA, $rS, $n, $b",
4338 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4339 def RLWNMobm : PPCAsmPseudo<"rlwnm. $rA, $rS, $n, $b",
4340 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4342 // These generic branch instruction forms are used for the assembler parser only.
4343 // Defs and Uses are conservative, since we don't know the BO value.
4344 let PPC970_Unit = 7, isBranch = 1 in {
4345 let Defs = [CTR], Uses = [CTR, RM] in {
4346 def gBC : BForm_3<16, 0, 0, (outs),
4347 (ins u5imm:$bo, crbitrc:$bi, condbrtarget:$dst),
4348 "bc $bo, $bi, $dst">;
4349 def gBCA : BForm_3<16, 1, 0, (outs),
4350 (ins u5imm:$bo, crbitrc:$bi, abscondbrtarget:$dst),
4351 "bca $bo, $bi, $dst">;
4352 let isAsmParserOnly = 1 in {
4353 def gBCat : BForm_3_at<16, 0, 0, (outs),
4354 (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
4356 "bc$at $bo, $bi, $dst">;
4357 def gBCAat : BForm_3_at<16, 1, 0, (outs),
4358 (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
4359 abscondbrtarget:$dst),
4360 "bca$at $bo, $bi, $dst">;
4361 } // isAsmParserOnly = 1
4363 let Defs = [LR, CTR], Uses = [CTR, RM] in {
4364 def gBCL : BForm_3<16, 0, 1, (outs),
4365 (ins u5imm:$bo, crbitrc:$bi, condbrtarget:$dst),
4366 "bcl $bo, $bi, $dst">;
4367 def gBCLA : BForm_3<16, 1, 1, (outs),
4368 (ins u5imm:$bo, crbitrc:$bi, abscondbrtarget:$dst),
4369 "bcla $bo, $bi, $dst">;
4370 let isAsmParserOnly = 1 in {
4371 def gBCLat : BForm_3_at<16, 0, 1, (outs),
4372 (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
4374 "bcl$at $bo, $bi, $dst">;
4375 def gBCLAat : BForm_3_at<16, 1, 1, (outs),
4376 (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
4377 abscondbrtarget:$dst),
4378 "bcla$at $bo, $bi, $dst">;
4379 } // // isAsmParserOnly = 1
4381 let Defs = [CTR], Uses = [CTR, LR, RM] in
4382 def gBCLR : XLForm_2<19, 16, 0, (outs),
4383 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
4384 "bclr $bo, $bi, $bh", IIC_BrB, []>;
4385 let Defs = [LR, CTR], Uses = [CTR, LR, RM] in
4386 def gBCLRL : XLForm_2<19, 16, 1, (outs),
4387 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
4388 "bclrl $bo, $bi, $bh", IIC_BrB, []>;
4389 let Defs = [CTR], Uses = [CTR, LR, RM] in
4390 def gBCCTR : XLForm_2<19, 528, 0, (outs),
4391 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
4392 "bcctr $bo, $bi, $bh", IIC_BrB, []>;
4393 let Defs = [LR, CTR], Uses = [CTR, LR, RM] in
4394 def gBCCTRL : XLForm_2<19, 528, 1, (outs),
4395 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
4396 "bcctrl $bo, $bi, $bh", IIC_BrB, []>;
4399 multiclass BranchSimpleMnemonicAT<string pm, int at> {
4400 def : InstAlias<"bc"#pm#" $bo, $bi, $dst", (gBCat u5imm:$bo, at, crbitrc:$bi,
4401 condbrtarget:$dst)>;
4402 def : InstAlias<"bca"#pm#" $bo, $bi, $dst", (gBCAat u5imm:$bo, at, crbitrc:$bi,
4403 condbrtarget:$dst)>;
4404 def : InstAlias<"bcl"#pm#" $bo, $bi, $dst", (gBCLat u5imm:$bo, at, crbitrc:$bi,
4405 condbrtarget:$dst)>;
4406 def : InstAlias<"bcla"#pm#" $bo, $bi, $dst", (gBCLAat u5imm:$bo, at, crbitrc:$bi,
4407 condbrtarget:$dst)>;
4409 defm : BranchSimpleMnemonicAT<"+", 3>;
4410 defm : BranchSimpleMnemonicAT<"-", 2>;
4412 def : InstAlias<"bclr $bo, $bi", (gBCLR u5imm:$bo, crbitrc:$bi, 0)>;
4413 def : InstAlias<"bclrl $bo, $bi", (gBCLRL u5imm:$bo, crbitrc:$bi, 0)>;
4414 def : InstAlias<"bcctr $bo, $bi", (gBCCTR u5imm:$bo, crbitrc:$bi, 0)>;
4415 def : InstAlias<"bcctrl $bo, $bi", (gBCCTRL u5imm:$bo, crbitrc:$bi, 0)>;
4417 multiclass BranchSimpleMnemonic1<string name, string pm, int bo> {
4418 def : InstAlias<"b"#name#pm#" $bi, $dst", (gBC bo, crbitrc:$bi, condbrtarget:$dst)>;
4419 def : InstAlias<"b"#name#"a"#pm#" $bi, $dst", (gBCA bo, crbitrc:$bi, abscondbrtarget:$dst)>;
4420 def : InstAlias<"b"#name#"lr"#pm#" $bi", (gBCLR bo, crbitrc:$bi, 0)>;
4421 def : InstAlias<"b"#name#"l"#pm#" $bi, $dst", (gBCL bo, crbitrc:$bi, condbrtarget:$dst)>;
4422 def : InstAlias<"b"#name#"la"#pm#" $bi, $dst", (gBCLA bo, crbitrc:$bi, abscondbrtarget:$dst)>;
4423 def : InstAlias<"b"#name#"lrl"#pm#" $bi", (gBCLRL bo, crbitrc:$bi, 0)>;
4425 multiclass BranchSimpleMnemonic2<string name, string pm, int bo>
4426 : BranchSimpleMnemonic1<name, pm, bo> {
4427 def : InstAlias<"b"#name#"ctr"#pm#" $bi", (gBCCTR bo, crbitrc:$bi, 0)>;
4428 def : InstAlias<"b"#name#"ctrl"#pm#" $bi", (gBCCTRL bo, crbitrc:$bi, 0)>;
4430 defm : BranchSimpleMnemonic2<"t", "", 12>;
4431 defm : BranchSimpleMnemonic2<"f", "", 4>;
4432 defm : BranchSimpleMnemonic2<"t", "-", 14>;
4433 defm : BranchSimpleMnemonic2<"f", "-", 6>;
4434 defm : BranchSimpleMnemonic2<"t", "+", 15>;
4435 defm : BranchSimpleMnemonic2<"f", "+", 7>;
4436 defm : BranchSimpleMnemonic1<"dnzt", "", 8>;
4437 defm : BranchSimpleMnemonic1<"dnzf", "", 0>;
4438 defm : BranchSimpleMnemonic1<"dzt", "", 10>;
4439 defm : BranchSimpleMnemonic1<"dzf", "", 2>;
4441 multiclass BranchExtendedMnemonicPM<string name, string pm, int bibo> {
4442 def : InstAlias<"b"#name#pm#" $cc, $dst",
4443 (BCC bibo, crrc:$cc, condbrtarget:$dst)>;
4444 def : InstAlias<"b"#name#pm#" $dst",
4445 (BCC bibo, CR0, condbrtarget:$dst)>;
4447 def : InstAlias<"b"#name#"a"#pm#" $cc, $dst",
4448 (BCCA bibo, crrc:$cc, abscondbrtarget:$dst)>;
4449 def : InstAlias<"b"#name#"a"#pm#" $dst",
4450 (BCCA bibo, CR0, abscondbrtarget:$dst)>;
4452 def : InstAlias<"b"#name#"lr"#pm#" $cc",
4453 (BCCLR bibo, crrc:$cc)>;
4454 def : InstAlias<"b"#name#"lr"#pm,
4457 def : InstAlias<"b"#name#"ctr"#pm#" $cc",
4458 (BCCCTR bibo, crrc:$cc)>;
4459 def : InstAlias<"b"#name#"ctr"#pm,
4460 (BCCCTR bibo, CR0)>;
4462 def : InstAlias<"b"#name#"l"#pm#" $cc, $dst",
4463 (BCCL bibo, crrc:$cc, condbrtarget:$dst)>;
4464 def : InstAlias<"b"#name#"l"#pm#" $dst",
4465 (BCCL bibo, CR0, condbrtarget:$dst)>;
4467 def : InstAlias<"b"#name#"la"#pm#" $cc, $dst",
4468 (BCCLA bibo, crrc:$cc, abscondbrtarget:$dst)>;
4469 def : InstAlias<"b"#name#"la"#pm#" $dst",
4470 (BCCLA bibo, CR0, abscondbrtarget:$dst)>;
4472 def : InstAlias<"b"#name#"lrl"#pm#" $cc",
4473 (BCCLRL bibo, crrc:$cc)>;
4474 def : InstAlias<"b"#name#"lrl"#pm,
4475 (BCCLRL bibo, CR0)>;
4477 def : InstAlias<"b"#name#"ctrl"#pm#" $cc",
4478 (BCCCTRL bibo, crrc:$cc)>;
4479 def : InstAlias<"b"#name#"ctrl"#pm,
4480 (BCCCTRL bibo, CR0)>;
4482 multiclass BranchExtendedMnemonic<string name, int bibo> {
4483 defm : BranchExtendedMnemonicPM<name, "", bibo>;
4484 defm : BranchExtendedMnemonicPM<name, "-", !add(bibo, 2)>;
4485 defm : BranchExtendedMnemonicPM<name, "+", !add(bibo, 3)>;
4487 defm : BranchExtendedMnemonic<"lt", 12>;
4488 defm : BranchExtendedMnemonic<"gt", 44>;
4489 defm : BranchExtendedMnemonic<"eq", 76>;
4490 defm : BranchExtendedMnemonic<"un", 108>;
4491 defm : BranchExtendedMnemonic<"so", 108>;
4492 defm : BranchExtendedMnemonic<"ge", 4>;
4493 defm : BranchExtendedMnemonic<"nl", 4>;
4494 defm : BranchExtendedMnemonic<"le", 36>;
4495 defm : BranchExtendedMnemonic<"ng", 36>;
4496 defm : BranchExtendedMnemonic<"ne", 68>;
4497 defm : BranchExtendedMnemonic<"nu", 100>;
4498 defm : BranchExtendedMnemonic<"ns", 100>;
4500 def : InstAlias<"cmpwi $rA, $imm", (CMPWI CR0, gprc:$rA, s16imm:$imm)>;
4501 def : InstAlias<"cmpw $rA, $rB", (CMPW CR0, gprc:$rA, gprc:$rB)>;
4502 def : InstAlias<"cmplwi $rA, $imm", (CMPLWI CR0, gprc:$rA, u16imm:$imm)>;
4503 def : InstAlias<"cmplw $rA, $rB", (CMPLW CR0, gprc:$rA, gprc:$rB)>;
4504 def : InstAlias<"cmpdi $rA, $imm", (CMPDI CR0, g8rc:$rA, s16imm64:$imm)>;
4505 def : InstAlias<"cmpd $rA, $rB", (CMPD CR0, g8rc:$rA, g8rc:$rB)>;
4506 def : InstAlias<"cmpldi $rA, $imm", (CMPLDI CR0, g8rc:$rA, u16imm64:$imm)>;
4507 def : InstAlias<"cmpld $rA, $rB", (CMPLD CR0, g8rc:$rA, g8rc:$rB)>;
4509 def : InstAlias<"cmpi $bf, 0, $rA, $imm", (CMPWI crrc:$bf, gprc:$rA, s16imm:$imm)>;
4510 def : InstAlias<"cmp $bf, 0, $rA, $rB", (CMPW crrc:$bf, gprc:$rA, gprc:$rB)>;
4511 def : InstAlias<"cmpli $bf, 0, $rA, $imm", (CMPLWI crrc:$bf, gprc:$rA, u16imm:$imm)>;
4512 def : InstAlias<"cmpl $bf, 0, $rA, $rB", (CMPLW crrc:$bf, gprc:$rA, gprc:$rB)>;
4513 def : InstAlias<"cmpi $bf, 1, $rA, $imm", (CMPDI crrc:$bf, g8rc:$rA, s16imm64:$imm)>;
4514 def : InstAlias<"cmp $bf, 1, $rA, $rB", (CMPD crrc:$bf, g8rc:$rA, g8rc:$rB)>;
4515 def : InstAlias<"cmpli $bf, 1, $rA, $imm", (CMPLDI crrc:$bf, g8rc:$rA, u16imm64:$imm)>;
4516 def : InstAlias<"cmpl $bf, 1, $rA, $rB", (CMPLD crrc:$bf, g8rc:$rA, g8rc:$rB)>;
4518 multiclass TrapExtendedMnemonic<string name, int to> {
4519 def : InstAlias<"td"#name#"i $rA, $imm", (TDI to, g8rc:$rA, s16imm:$imm)>;
4520 def : InstAlias<"td"#name#" $rA, $rB", (TD to, g8rc:$rA, g8rc:$rB)>;
4521 def : InstAlias<"tw"#name#"i $rA, $imm", (TWI to, gprc:$rA, s16imm:$imm)>;
4522 def : InstAlias<"tw"#name#" $rA, $rB", (TW to, gprc:$rA, gprc:$rB)>;
4524 defm : TrapExtendedMnemonic<"lt", 16>;
4525 defm : TrapExtendedMnemonic<"le", 20>;
4526 defm : TrapExtendedMnemonic<"eq", 4>;
4527 defm : TrapExtendedMnemonic<"ge", 12>;
4528 defm : TrapExtendedMnemonic<"gt", 8>;
4529 defm : TrapExtendedMnemonic<"nl", 12>;
4530 defm : TrapExtendedMnemonic<"ne", 24>;
4531 defm : TrapExtendedMnemonic<"ng", 20>;
4532 defm : TrapExtendedMnemonic<"llt", 2>;
4533 defm : TrapExtendedMnemonic<"lle", 6>;
4534 defm : TrapExtendedMnemonic<"lge", 5>;
4535 defm : TrapExtendedMnemonic<"lgt", 1>;
4536 defm : TrapExtendedMnemonic<"lnl", 5>;
4537 defm : TrapExtendedMnemonic<"lng", 6>;
4538 defm : TrapExtendedMnemonic<"u", 31>;
4541 def : Pat<(atomic_load_8 iaddr:$src), (LBZ memri:$src)>;
4542 def : Pat<(atomic_load_16 iaddr:$src), (LHZ memri:$src)>;
4543 def : Pat<(atomic_load_32 iaddr:$src), (LWZ memri:$src)>;
4544 def : Pat<(atomic_load_8 xaddr:$src), (LBZX memrr:$src)>;
4545 def : Pat<(atomic_load_16 xaddr:$src), (LHZX memrr:$src)>;
4546 def : Pat<(atomic_load_32 xaddr:$src), (LWZX memrr:$src)>;
4549 def : Pat<(atomic_store_8 iaddr:$ptr, i32:$val), (STB gprc:$val, memri:$ptr)>;
4550 def : Pat<(atomic_store_16 iaddr:$ptr, i32:$val), (STH gprc:$val, memri:$ptr)>;
4551 def : Pat<(atomic_store_32 iaddr:$ptr, i32:$val), (STW gprc:$val, memri:$ptr)>;
4552 def : Pat<(atomic_store_8 xaddr:$ptr, i32:$val), (STBX gprc:$val, memrr:$ptr)>;
4553 def : Pat<(atomic_store_16 xaddr:$ptr, i32:$val), (STHX gprc:$val, memrr:$ptr)>;
4554 def : Pat<(atomic_store_32 xaddr:$ptr, i32:$val), (STWX gprc:$val, memrr:$ptr)>;
4556 let Predicates = [IsISA3_0] in {
4558 // Copy-Paste Facility
4559 // We prefix 'CP' to COPY due to name conflict in Target.td. We also prefix to
4560 // PASTE for naming consistency.
4562 def CP_COPY : X_L1_RA5_RB5<31, 774, "copy" , gprc, IIC_LdStCOPY, []>;
4565 def CP_PASTE : X_L1_RA5_RB5<31, 902, "paste" , gprc, IIC_LdStPASTE, []>;
4567 let mayStore = 1, Defs = [CR0] in
4568 def CP_PASTEo : X_L1_RA5_RB5<31, 902, "paste.", gprc, IIC_LdStPASTE, []>, isDOT;
4570 def CP_COPYx : PPCAsmPseudo<"copy $rA, $rB" , (ins gprc:$rA, gprc:$rB)>;
4571 def CP_PASTEx : PPCAsmPseudo<"paste $rA, $rB", (ins gprc:$rA, gprc:$rB)>;
4572 def CP_COPY_FIRST : PPCAsmPseudo<"copy_first $rA, $rB",
4573 (ins gprc:$rA, gprc:$rB)>;
4574 def CP_PASTE_LAST : PPCAsmPseudo<"paste_last $rA, $rB",
4575 (ins gprc:$rA, gprc:$rB)>;
4576 def CP_ABORT : XForm_0<31, 838, (outs), (ins), "cp_abort", IIC_SprABORT, []>;
4578 // Message Synchronize
4579 def MSGSYNC : XForm_0<31, 886, (outs), (ins), "msgsync", IIC_SprMSGSYNC, []>;
4581 // Power-Saving Mode Instruction:
4582 def STOP : XForm_0<19, 370, (outs), (ins), "stop", IIC_SprSTOP, []>;
4586 // Fast 32-bit reverse bits algorithm:
4587 // Step 1: 1-bit swap (swap odd 1-bit and even 1-bit):
4588 // n = ((n >> 1) & 0x55555555) | ((n << 1) & 0xAAAAAAAA);
4589 // Step 2: 2-bit swap (swap odd 2-bit and even 2-bit):
4590 // n = ((n >> 2) & 0x33333333) | ((n << 2) & 0xCCCCCCCC);
4591 // Step 3: 4-bit swap (swap odd 4-bit and even 4-bit):
4592 // n = ((n >> 4) & 0x0F0F0F0F) | ((n << 4) & 0xF0F0F0F0);
4593 // Step 4: byte reverse (Suppose n = [B1,B2,B3,B4]):
4594 // Step 4.1: Put B4,B2 in the right position (rotate left 3 bytes):
4595 // n' = (n rotl 24); After which n' = [B4, B1, B2, B3]
4596 // Step 4.2: Insert B3 to the right position:
4597 // n' = rlwimi n', n, 8, 8, 15; After which n' = [B4, B3, B2, B3]
4598 // Step 4.3: Insert B1 to the right position:
4599 // n' = rlwimi n', n, 8, 24, 31; After which n' = [B4, B3, B2, B1]
4601 dag Lo1 = (ORI (LIS 0x5555), 0x5555);
4602 dag Hi1 = (ORI (LIS 0xAAAA), 0xAAAA);
4603 dag Lo2 = (ORI (LIS 0x3333), 0x3333);
4604 dag Hi2 = (ORI (LIS 0xCCCC), 0xCCCC);
4605 dag Lo4 = (ORI (LIS 0x0F0F), 0x0F0F);
4606 dag Hi4 = (ORI (LIS 0xF0F0), 0xF0F0);
4610 dag Right = (RLWINM $A, 31, 1, 31);
4611 dag Left = (RLWINM $A, 1, 0, 30);
4615 dag Bit = (OR (AND Shift1.Right, MaskValues.Lo1),
4616 (AND Shift1.Left, MaskValues.Hi1));
4620 dag Right = (RLWINM Swap1.Bit, 30, 2, 31);
4621 dag Left = (RLWINM Swap1.Bit, 2, 0, 29);
4625 dag Bits = (OR (AND Shift2.Right, MaskValues.Lo2),
4626 (AND Shift2.Left, MaskValues.Hi2));
4630 dag Right = (RLWINM Swap2.Bits, 28, 4, 31);
4631 dag Left = (RLWINM Swap2.Bits, 4, 0, 27);
4635 dag Bits = (OR (AND Shift4.Right, MaskValues.Lo4),
4636 (AND Shift4.Left, MaskValues.Hi4));
4640 dag Left3Bytes = (RLWINM Swap4.Bits, 24, 0, 31);
4643 def RotateInsertByte3 {
4644 dag Left = (RLWIMI Rotate.Left3Bytes, Swap4.Bits, 8, 8, 15);
4647 def RotateInsertByte1 {
4648 dag Left = (RLWIMI RotateInsertByte3.Left, Swap4.Bits, 8, 24, 31);
4651 def : Pat<(i32 (bitreverse i32:$A)),
4652 (RLDICL_32 RotateInsertByte1.Left, 0, 32)>;
4654 // Fast 64-bit reverse bits algorithm:
4655 // Step 1: 1-bit swap (swap odd 1-bit and even 1-bit):
4656 // n = ((n >> 1) & 0x5555555555555555) | ((n << 1) & 0xAAAAAAAAAAAAAAAA);
4657 // Step 2: 2-bit swap (swap odd 2-bit and even 2-bit):
4658 // n = ((n >> 2) & 0x3333333333333333) | ((n << 2) & 0xCCCCCCCCCCCCCCCC);
4659 // Step 3: 4-bit swap (swap odd 4-bit and even 4-bit):
4660 // n = ((n >> 4) & 0x0F0F0F0F0F0F0F0F) | ((n << 4) & 0xF0F0F0F0F0F0F0F0);
4661 // Step 4: byte reverse (Suppose n = [B0,B1,B2,B3,B4,B5,B6,B7]):
4662 // Apply the same byte reverse algorithm mentioned above for the fast 32-bit
4663 // reverse to both the high 32 bit and low 32 bit of the 64 bit value. And
4664 // then OR them together to get the final result.
4666 dag Lo1 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Lo1, sub_32));
4667 dag Hi1 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Hi1, sub_32));
4668 dag Lo2 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Lo2, sub_32));
4669 dag Hi2 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Hi2, sub_32));
4670 dag Lo4 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Lo4, sub_32));
4671 dag Hi4 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Hi4, sub_32));
4675 dag Lo1 = (ORI8 (ORIS8 (RLDICR MaskValues64.Lo1, 32, 31), 0x5555), 0x5555);
4676 dag Hi1 = (ORI8 (ORIS8 (RLDICR MaskValues64.Hi1, 32, 31), 0xAAAA), 0xAAAA);
4677 dag Lo2 = (ORI8 (ORIS8 (RLDICR MaskValues64.Lo2, 32, 31), 0x3333), 0x3333);
4678 dag Hi2 = (ORI8 (ORIS8 (RLDICR MaskValues64.Hi2, 32, 31), 0xCCCC), 0xCCCC);
4679 dag Lo4 = (ORI8 (ORIS8 (RLDICR MaskValues64.Lo4, 32, 31), 0x0F0F), 0x0F0F);
4680 dag Hi4 = (ORI8 (ORIS8 (RLDICR MaskValues64.Hi4, 32, 31), 0xF0F0), 0xF0F0);
4684 dag Swap1 = (OR8 (AND8 (RLDICL $A, 63, 1), DWMaskValues.Lo1),
4685 (AND8 (RLDICR $A, 1, 62), DWMaskValues.Hi1));
4686 dag Swap2 = (OR8 (AND8 (RLDICL DWSwapInByte.Swap1, 62, 2), DWMaskValues.Lo2),
4687 (AND8 (RLDICR DWSwapInByte.Swap1, 2, 61), DWMaskValues.Hi2));
4688 dag Swap4 = (OR8 (AND8 (RLDICL DWSwapInByte.Swap2, 60, 4), DWMaskValues.Lo4),
4689 (AND8 (RLDICR DWSwapInByte.Swap2, 4, 59), DWMaskValues.Hi4));
4692 // Intra-byte swap is done, now start inter-byte swap.
4694 dag Word = (i32 (EXTRACT_SUBREG DWSwapInByte.Swap4, sub_32));
4698 dag Word = (RLWINM DWBytes4567.Word, 24, 0, 31);
4702 dag Word = (RLWIMI DWBytes7456.Word, DWBytes4567.Word, 8, 8, 15);
4705 // B7 B6 B5 B4 in the right order
4707 dag Word = (RLWIMI DWBytes7656.Word, DWBytes4567.Word, 8, 24, 31);
4709 (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), DWBytes7654.Word, sub_32));
4713 dag Word = (i32 (EXTRACT_SUBREG (RLDICL DWSwapInByte.Swap4, 32, 32), sub_32));
4717 dag Word = (RLWINM DWBytes0123.Word, 24, 0, 31);
4721 dag Word = (RLWIMI DWBytes3012.Word, DWBytes0123.Word, 8, 8, 15);
4724 // B3 B2 B1 B0 in the right order
4726 dag Word = (RLWIMI DWBytes3212.Word, DWBytes0123.Word, 8, 24, 31);
4728 (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), DWBytes3210.Word, sub_32));
4731 // Now both high word and low word are reversed, next
4732 // swap the high word and low word.
4733 def : Pat<(i64 (bitreverse i64:$A)),
4734 (OR8 (RLDICR DWBytes7654.DWord, 32, 31), DWBytes3210.DWord)>;