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>
36 def SDT_PPCCallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32>,
38 def SDT_PPCCallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
40 def SDT_PPCvperm : SDTypeProfile<1, 3, [
41 SDTCisVT<3, v16i8>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>
44 def SDT_PPCVecSplat : SDTypeProfile<1, 2, [ SDTCisVec<0>,
45 SDTCisVec<1>, SDTCisInt<2>
48 def SDT_PPCVecShift : SDTypeProfile<1, 3, [ SDTCisVec<0>,
49 SDTCisVec<1>, SDTCisVec<2>, SDTCisInt<3>
52 def SDT_PPCVecInsert : SDTypeProfile<1, 3, [ SDTCisVec<0>,
53 SDTCisVec<1>, SDTCisVec<2>, SDTCisInt<3>
56 def SDT_PPCvcmp : SDTypeProfile<1, 3, [
57 SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisVT<3, i32>
60 def SDT_PPCcondbr : SDTypeProfile<0, 3, [
61 SDTCisVT<0, i32>, SDTCisVT<2, OtherVT>
64 def SDT_PPClbrx : SDTypeProfile<1, 2, [
65 SDTCisInt<0>, SDTCisPtrTy<1>, SDTCisVT<2, OtherVT>
67 def SDT_PPCstbrx : SDTypeProfile<0, 3, [
68 SDTCisInt<0>, SDTCisPtrTy<1>, SDTCisVT<2, OtherVT>
71 def SDT_PPCTC_ret : SDTypeProfile<0, 2, [
72 SDTCisPtrTy<0>, SDTCisVT<1, i32>
75 def tocentry32 : Operand<iPTR> {
76 let MIOperandInfo = (ops i32imm:$imm);
79 def SDT_PPCqvfperm : SDTypeProfile<1, 3, [
80 SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisVec<3>
82 def SDT_PPCqvgpci : SDTypeProfile<1, 1, [
83 SDTCisVec<0>, SDTCisInt<1>
85 def SDT_PPCqvaligni : SDTypeProfile<1, 3, [
86 SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisInt<3>
88 def SDT_PPCqvesplati : SDTypeProfile<1, 2, [
89 SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisInt<2>
92 def SDT_PPCqbflt : SDTypeProfile<1, 1, [
93 SDTCisVec<0>, SDTCisVec<1>
96 def SDT_PPCqvlfsb : SDTypeProfile<1, 1, [
97 SDTCisVec<0>, SDTCisPtrTy<1>
100 //===----------------------------------------------------------------------===//
101 // PowerPC specific DAG Nodes.
104 def PPCfre : SDNode<"PPCISD::FRE", SDTFPUnaryOp, []>;
105 def PPCfrsqrte: SDNode<"PPCISD::FRSQRTE", SDTFPUnaryOp, []>;
107 def PPCfcfid : SDNode<"PPCISD::FCFID", SDTFPUnaryOp, []>;
108 def PPCfcfidu : SDNode<"PPCISD::FCFIDU", SDTFPUnaryOp, []>;
109 def PPCfcfids : SDNode<"PPCISD::FCFIDS", SDTFPRoundOp, []>;
110 def PPCfcfidus: SDNode<"PPCISD::FCFIDUS", SDTFPRoundOp, []>;
111 def PPCfctidz : SDNode<"PPCISD::FCTIDZ", SDTFPUnaryOp, []>;
112 def PPCfctiwz : SDNode<"PPCISD::FCTIWZ", SDTFPUnaryOp, []>;
113 def PPCfctiduz: SDNode<"PPCISD::FCTIDUZ",SDTFPUnaryOp, []>;
114 def PPCfctiwuz: SDNode<"PPCISD::FCTIWUZ",SDTFPUnaryOp, []>;
115 def PPCstfiwx : SDNode<"PPCISD::STFIWX", SDT_PPCstfiwx,
116 [SDNPHasChain, SDNPMayStore]>;
117 def PPClfiwax : SDNode<"PPCISD::LFIWAX", SDT_PPClfiwx,
118 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
119 def PPClfiwzx : SDNode<"PPCISD::LFIWZX", SDT_PPClfiwx,
120 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
121 def PPClxsizx : SDNode<"PPCISD::LXSIZX", SDT_PPCLxsizx,
122 [SDNPHasChain, SDNPMayLoad]>;
123 def PPCstxsix : SDNode<"PPCISD::STXSIX", SDT_PPCstxsix,
124 [SDNPHasChain, SDNPMayStore]>;
125 def PPCVexts : SDNode<"PPCISD::VEXTS", SDT_PPCVexts, []>;
127 // Extract FPSCR (not modeled at the DAG level).
128 def PPCmffs : SDNode<"PPCISD::MFFS",
129 SDTypeProfile<1, 0, [SDTCisVT<0, f64>]>, []>;
131 // Perform FADD in round-to-zero mode.
132 def PPCfaddrtz: SDNode<"PPCISD::FADDRTZ", SDTFPBinOp, []>;
135 def PPCfsel : SDNode<"PPCISD::FSEL",
136 // Type constraint for fsel.
137 SDTypeProfile<1, 3, [SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>,
138 SDTCisFP<0>, SDTCisVT<1, f64>]>, []>;
140 def PPChi : SDNode<"PPCISD::Hi", SDTIntBinOp, []>;
141 def PPClo : SDNode<"PPCISD::Lo", SDTIntBinOp, []>;
142 def PPCtoc_entry: SDNode<"PPCISD::TOC_ENTRY", SDTIntBinOp,
143 [SDNPMayLoad, SDNPMemOperand]>;
144 def PPCvmaddfp : SDNode<"PPCISD::VMADDFP", SDTFPTernaryOp, []>;
145 def PPCvnmsubfp : SDNode<"PPCISD::VNMSUBFP", SDTFPTernaryOp, []>;
147 def PPCppc32GOT : SDNode<"PPCISD::PPC32_GOT", SDTIntLeaf, []>;
149 def PPCaddisGotTprelHA : SDNode<"PPCISD::ADDIS_GOT_TPREL_HA", SDTIntBinOp>;
150 def PPCldGotTprelL : SDNode<"PPCISD::LD_GOT_TPREL_L", SDTIntBinOp,
152 def PPCaddTls : SDNode<"PPCISD::ADD_TLS", SDTIntBinOp, []>;
153 def PPCaddisTlsgdHA : SDNode<"PPCISD::ADDIS_TLSGD_HA", SDTIntBinOp>;
154 def PPCaddiTlsgdL : SDNode<"PPCISD::ADDI_TLSGD_L", SDTIntBinOp>;
155 def PPCgetTlsAddr : SDNode<"PPCISD::GET_TLS_ADDR", SDTIntBinOp>;
156 def PPCaddiTlsgdLAddr : SDNode<"PPCISD::ADDI_TLSGD_L_ADDR",
157 SDTypeProfile<1, 3, [
158 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
159 SDTCisSameAs<0, 3>, SDTCisInt<0> ]>>;
160 def PPCaddisTlsldHA : SDNode<"PPCISD::ADDIS_TLSLD_HA", SDTIntBinOp>;
161 def PPCaddiTlsldL : SDNode<"PPCISD::ADDI_TLSLD_L", SDTIntBinOp>;
162 def PPCgetTlsldAddr : SDNode<"PPCISD::GET_TLSLD_ADDR", SDTIntBinOp>;
163 def PPCaddiTlsldLAddr : SDNode<"PPCISD::ADDI_TLSLD_L_ADDR",
164 SDTypeProfile<1, 3, [
165 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
166 SDTCisSameAs<0, 3>, SDTCisInt<0> ]>>;
167 def PPCaddisDtprelHA : SDNode<"PPCISD::ADDIS_DTPREL_HA", SDTIntBinOp>;
168 def PPCaddiDtprelL : SDNode<"PPCISD::ADDI_DTPREL_L", SDTIntBinOp>;
170 def PPCvperm : SDNode<"PPCISD::VPERM", SDT_PPCvperm, []>;
171 def PPCxxsplt : SDNode<"PPCISD::XXSPLT", SDT_PPCVecSplat, []>;
172 def PPCxxinsert : SDNode<"PPCISD::XXINSERT", SDT_PPCVecInsert, []>;
173 def PPCvecshl : SDNode<"PPCISD::VECSHL", SDT_PPCVecShift, []>;
175 def PPCqvfperm : SDNode<"PPCISD::QVFPERM", SDT_PPCqvfperm, []>;
176 def PPCqvgpci : SDNode<"PPCISD::QVGPCI", SDT_PPCqvgpci, []>;
177 def PPCqvaligni : SDNode<"PPCISD::QVALIGNI", SDT_PPCqvaligni, []>;
178 def PPCqvesplati : SDNode<"PPCISD::QVESPLATI", SDT_PPCqvesplati, []>;
180 def PPCqbflt : SDNode<"PPCISD::QBFLT", SDT_PPCqbflt, []>;
182 def PPCqvlfsb : SDNode<"PPCISD::QVLFSb", SDT_PPCqvlfsb,
183 [SDNPHasChain, SDNPMayLoad]>;
185 def PPCcmpb : SDNode<"PPCISD::CMPB", SDTIntBinOp, []>;
187 // These nodes represent the 32-bit PPC shifts that operate on 6-bit shift
188 // amounts. These nodes are generated by the multi-precision shift code.
189 def PPCsrl : SDNode<"PPCISD::SRL" , SDTIntShiftOp>;
190 def PPCsra : SDNode<"PPCISD::SRA" , SDTIntShiftOp>;
191 def PPCshl : SDNode<"PPCISD::SHL" , SDTIntShiftOp>;
193 // These are target-independent nodes, but have target-specific formats.
194 def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_PPCCallSeqStart,
195 [SDNPHasChain, SDNPOutGlue]>;
196 def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_PPCCallSeqEnd,
197 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
199 def SDT_PPCCall : SDTypeProfile<0, -1, [SDTCisInt<0>]>;
200 def PPCcall : SDNode<"PPCISD::CALL", SDT_PPCCall,
201 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
203 def PPCcall_nop : SDNode<"PPCISD::CALL_NOP", SDT_PPCCall,
204 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
206 def PPCmtctr : SDNode<"PPCISD::MTCTR", SDT_PPCCall,
207 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
208 def PPCbctrl : SDNode<"PPCISD::BCTRL", SDTNone,
209 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
211 def PPCbctrl_load_toc : SDNode<"PPCISD::BCTRL_LOAD_TOC",
212 SDTypeProfile<0, 1, []>,
213 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
216 def retflag : SDNode<"PPCISD::RET_FLAG", SDTNone,
217 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
219 def PPCtc_return : SDNode<"PPCISD::TC_RETURN", SDT_PPCTC_ret,
220 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
222 def PPCeh_sjlj_setjmp : SDNode<"PPCISD::EH_SJLJ_SETJMP",
223 SDTypeProfile<1, 1, [SDTCisInt<0>,
225 [SDNPHasChain, SDNPSideEffect]>;
226 def PPCeh_sjlj_longjmp : SDNode<"PPCISD::EH_SJLJ_LONGJMP",
227 SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>,
228 [SDNPHasChain, SDNPSideEffect]>;
230 def SDT_PPCsc : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
231 def PPCsc : SDNode<"PPCISD::SC", SDT_PPCsc,
232 [SDNPHasChain, SDNPSideEffect]>;
234 def PPCclrbhrb : SDNode<"PPCISD::CLRBHRB", SDTNone,
235 [SDNPHasChain, SDNPSideEffect]>;
236 def PPCmfbhrbe : SDNode<"PPCISD::MFBHRBE", SDTIntBinOp, [SDNPHasChain]>;
237 def PPCrfebb : SDNode<"PPCISD::RFEBB", SDT_PPCsc,
238 [SDNPHasChain, SDNPSideEffect]>;
240 def PPCvcmp : SDNode<"PPCISD::VCMP" , SDT_PPCvcmp, []>;
241 def PPCvcmp_o : SDNode<"PPCISD::VCMPo", SDT_PPCvcmp, [SDNPOutGlue]>;
243 def PPCcondbranch : SDNode<"PPCISD::COND_BRANCH", SDT_PPCcondbr,
244 [SDNPHasChain, SDNPOptInGlue]>;
246 def PPClbrx : SDNode<"PPCISD::LBRX", SDT_PPClbrx,
247 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
248 def PPCstbrx : SDNode<"PPCISD::STBRX", SDT_PPCstbrx,
249 [SDNPHasChain, SDNPMayStore]>;
251 // Instructions to set/unset CR bit 6 for SVR4 vararg calls
252 def PPCcr6set : SDNode<"PPCISD::CR6SET", SDTNone,
253 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
254 def PPCcr6unset : SDNode<"PPCISD::CR6UNSET", SDTNone,
255 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
257 // Instructions to support dynamic alloca.
258 def SDTDynOp : SDTypeProfile<1, 2, []>;
259 def SDTDynAreaOp : SDTypeProfile<1, 1, []>;
260 def PPCdynalloc : SDNode<"PPCISD::DYNALLOC", SDTDynOp, [SDNPHasChain]>;
261 def PPCdynareaoffset : SDNode<"PPCISD::DYNAREAOFFSET", SDTDynAreaOp, [SDNPHasChain]>;
263 //===----------------------------------------------------------------------===//
264 // PowerPC specific transformation functions and pattern fragments.
267 def SHL32 : SDNodeXForm<imm, [{
268 // Transformation function: 31 - imm
269 return getI32Imm(31 - N->getZExtValue(), SDLoc(N));
272 def SRL32 : SDNodeXForm<imm, [{
273 // Transformation function: 32 - imm
274 return N->getZExtValue() ? getI32Imm(32 - N->getZExtValue(), SDLoc(N))
275 : getI32Imm(0, SDLoc(N));
278 def LO16 : SDNodeXForm<imm, [{
279 // Transformation function: get the low 16 bits.
280 return getI32Imm((unsigned short)N->getZExtValue(), SDLoc(N));
283 def HI16 : SDNodeXForm<imm, [{
284 // Transformation function: shift the immediate value down into the low bits.
285 return getI32Imm((unsigned)N->getZExtValue() >> 16, SDLoc(N));
288 def HA16 : SDNodeXForm<imm, [{
289 // Transformation function: shift the immediate value down into the low bits.
290 int Val = N->getZExtValue();
291 return getI32Imm((Val - (signed short)Val) >> 16, SDLoc(N));
293 def MB : SDNodeXForm<imm, [{
294 // Transformation function: get the start bit of a mask
296 (void)isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
297 return getI32Imm(mb, SDLoc(N));
300 def ME : SDNodeXForm<imm, [{
301 // Transformation function: get the end bit of a mask
303 (void)isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
304 return getI32Imm(me, SDLoc(N));
306 def maskimm32 : PatLeaf<(imm), [{
307 // maskImm predicate - True if immediate is a run of ones.
309 if (N->getValueType(0) == MVT::i32)
310 return isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
315 def imm32SExt16 : Operand<i32>, ImmLeaf<i32, [{
316 // imm32SExt16 predicate - True if the i32 immediate fits in a 16-bit
317 // sign extended field. Used by instructions like 'addi'.
318 return (int32_t)Imm == (short)Imm;
320 def imm64SExt16 : Operand<i64>, ImmLeaf<i64, [{
321 // imm64SExt16 predicate - True if the i64 immediate fits in a 16-bit
322 // sign extended field. Used by instructions like 'addi'.
323 return (int64_t)Imm == (short)Imm;
325 def immZExt16 : PatLeaf<(imm), [{
326 // immZExt16 predicate - True if the immediate fits in a 16-bit zero extended
327 // field. Used by instructions like 'ori'.
328 return (uint64_t)N->getZExtValue() == (unsigned short)N->getZExtValue();
330 def immAnyExt8 : ImmLeaf<i32, [{ return isInt<8>(Imm) || isUInt<8>(Imm); }]>;
331 def immSExt5NonZero : ImmLeaf<i32, [{ return Imm && isInt<5>(Imm); }]>;
333 // imm16Shifted* - These match immediates where the low 16-bits are zero. There
334 // are two forms: imm16ShiftedSExt and imm16ShiftedZExt. These two forms are
335 // identical in 32-bit mode, but in 64-bit mode, they return true if the
336 // immediate fits into a sign/zero extended 32-bit immediate (with the low bits
338 def imm16ShiftedZExt : PatLeaf<(imm), [{
339 // imm16ShiftedZExt predicate - True if only bits in the top 16-bits of the
340 // immediate are set. Used by instructions like 'xoris'.
341 return (N->getZExtValue() & ~uint64_t(0xFFFF0000)) == 0;
344 def imm16ShiftedSExt : PatLeaf<(imm), [{
345 // imm16ShiftedSExt predicate - True if only bits in the top 16-bits of the
346 // immediate are set. Used by instructions like 'addis'. Identical to
347 // imm16ShiftedZExt in 32-bit mode.
348 if (N->getZExtValue() & 0xFFFF) return false;
349 if (N->getValueType(0) == MVT::i32)
351 // For 64-bit, make sure it is sext right.
352 return N->getZExtValue() == (uint64_t)(int)N->getZExtValue();
355 def imm64ZExt32 : Operand<i64>, ImmLeaf<i64, [{
356 // imm64ZExt32 predicate - True if the i64 immediate fits in a 32-bit
357 // zero extended field.
358 return isUInt<32>(Imm);
361 // Some r+i load/store instructions (such as LD, STD, LDU, etc.) that require
362 // restricted memrix (4-aligned) constants are alignment sensitive. If these
363 // offsets are hidden behind TOC entries than the values of the lower-order
364 // bits cannot be checked directly. As a result, we need to also incorporate
365 // an alignment check into the relevant patterns.
367 def aligned4load : PatFrag<(ops node:$ptr), (load node:$ptr), [{
368 return cast<LoadSDNode>(N)->getAlignment() >= 4;
370 def aligned4store : PatFrag<(ops node:$val, node:$ptr),
371 (store node:$val, node:$ptr), [{
372 return cast<StoreSDNode>(N)->getAlignment() >= 4;
374 def aligned4sextloadi32 : PatFrag<(ops node:$ptr), (sextloadi32 node:$ptr), [{
375 return cast<LoadSDNode>(N)->getAlignment() >= 4;
377 def aligned4pre_store : PatFrag<
378 (ops node:$val, node:$base, node:$offset),
379 (pre_store node:$val, node:$base, node:$offset), [{
380 return cast<StoreSDNode>(N)->getAlignment() >= 4;
383 def unaligned4load : PatFrag<(ops node:$ptr), (load node:$ptr), [{
384 return cast<LoadSDNode>(N)->getAlignment() < 4;
386 def unaligned4store : PatFrag<(ops node:$val, node:$ptr),
387 (store node:$val, node:$ptr), [{
388 return cast<StoreSDNode>(N)->getAlignment() < 4;
390 def unaligned4sextloadi32 : PatFrag<(ops node:$ptr), (sextloadi32 node:$ptr), [{
391 return cast<LoadSDNode>(N)->getAlignment() < 4;
394 //===----------------------------------------------------------------------===//
395 // PowerPC Flag Definitions.
397 class isPPC64 { bit PPC64 = 1; }
398 class isDOT { bit RC = 1; }
400 class RegConstraint<string C> {
401 string Constraints = C;
403 class NoEncode<string E> {
404 string DisableEncoding = E;
408 //===----------------------------------------------------------------------===//
409 // PowerPC Operand Definitions.
411 // In the default PowerPC assembler syntax, registers are specified simply
412 // by number, so they cannot be distinguished from immediate values (without
413 // looking at the opcode). This means that the default operand matching logic
414 // for the asm parser does not work, and we need to specify custom matchers.
415 // Since those can only be specified with RegisterOperand classes and not
416 // directly on the RegisterClass, all instructions patterns used by the asm
417 // parser need to use a RegisterOperand (instead of a RegisterClass) for
418 // all their register operands.
419 // For this purpose, we define one RegisterOperand for each RegisterClass,
420 // using the same name as the class, just in lower case.
422 def PPCRegGPRCAsmOperand : AsmOperandClass {
423 let Name = "RegGPRC"; let PredicateMethod = "isRegNumber";
425 def gprc : RegisterOperand<GPRC> {
426 let ParserMatchClass = PPCRegGPRCAsmOperand;
428 def PPCRegG8RCAsmOperand : AsmOperandClass {
429 let Name = "RegG8RC"; let PredicateMethod = "isRegNumber";
431 def g8rc : RegisterOperand<G8RC> {
432 let ParserMatchClass = PPCRegG8RCAsmOperand;
434 def PPCRegGPRCNoR0AsmOperand : AsmOperandClass {
435 let Name = "RegGPRCNoR0"; let PredicateMethod = "isRegNumber";
437 def gprc_nor0 : RegisterOperand<GPRC_NOR0> {
438 let ParserMatchClass = PPCRegGPRCNoR0AsmOperand;
440 def PPCRegG8RCNoX0AsmOperand : AsmOperandClass {
441 let Name = "RegG8RCNoX0"; let PredicateMethod = "isRegNumber";
443 def g8rc_nox0 : RegisterOperand<G8RC_NOX0> {
444 let ParserMatchClass = PPCRegG8RCNoX0AsmOperand;
446 def PPCRegF8RCAsmOperand : AsmOperandClass {
447 let Name = "RegF8RC"; let PredicateMethod = "isRegNumber";
449 def f8rc : RegisterOperand<F8RC> {
450 let ParserMatchClass = PPCRegF8RCAsmOperand;
452 def PPCRegF4RCAsmOperand : AsmOperandClass {
453 let Name = "RegF4RC"; let PredicateMethod = "isRegNumber";
455 def f4rc : RegisterOperand<F4RC> {
456 let ParserMatchClass = PPCRegF4RCAsmOperand;
458 def PPCRegVRRCAsmOperand : AsmOperandClass {
459 let Name = "RegVRRC"; let PredicateMethod = "isRegNumber";
461 def vrrc : RegisterOperand<VRRC> {
462 let ParserMatchClass = PPCRegVRRCAsmOperand;
464 def PPCRegVFRCAsmOperand : AsmOperandClass {
465 let Name = "RegVFRC"; let PredicateMethod = "isRegNumber";
467 def vfrc : RegisterOperand<VFRC> {
468 let ParserMatchClass = PPCRegVFRCAsmOperand;
470 def PPCRegCRBITRCAsmOperand : AsmOperandClass {
471 let Name = "RegCRBITRC"; let PredicateMethod = "isCRBitNumber";
473 def crbitrc : RegisterOperand<CRBITRC> {
474 let ParserMatchClass = PPCRegCRBITRCAsmOperand;
476 def PPCRegCRRCAsmOperand : AsmOperandClass {
477 let Name = "RegCRRC"; let PredicateMethod = "isCCRegNumber";
479 def crrc : RegisterOperand<CRRC> {
480 let ParserMatchClass = PPCRegCRRCAsmOperand;
482 def crrc0 : RegisterOperand<CRRC0> {
483 let ParserMatchClass = PPCRegCRRCAsmOperand;
486 def PPCU1ImmAsmOperand : AsmOperandClass {
487 let Name = "U1Imm"; let PredicateMethod = "isU1Imm";
488 let RenderMethod = "addImmOperands";
490 def u1imm : Operand<i32> {
491 let PrintMethod = "printU1ImmOperand";
492 let ParserMatchClass = PPCU1ImmAsmOperand;
495 def PPCU2ImmAsmOperand : AsmOperandClass {
496 let Name = "U2Imm"; let PredicateMethod = "isU2Imm";
497 let RenderMethod = "addImmOperands";
499 def u2imm : Operand<i32> {
500 let PrintMethod = "printU2ImmOperand";
501 let ParserMatchClass = PPCU2ImmAsmOperand;
504 def PPCATBitsAsHintAsmOperand : AsmOperandClass {
505 let Name = "ATBitsAsHint"; let PredicateMethod = "isATBitsAsHint";
506 let RenderMethod = "addImmOperands"; // Irrelevant, predicate always fails.
508 def atimm : Operand<i32> {
509 let PrintMethod = "printATBitsAsHint";
510 let ParserMatchClass = PPCATBitsAsHintAsmOperand;
513 def PPCU3ImmAsmOperand : AsmOperandClass {
514 let Name = "U3Imm"; let PredicateMethod = "isU3Imm";
515 let RenderMethod = "addImmOperands";
517 def u3imm : Operand<i32> {
518 let PrintMethod = "printU3ImmOperand";
519 let ParserMatchClass = PPCU3ImmAsmOperand;
522 def PPCU4ImmAsmOperand : AsmOperandClass {
523 let Name = "U4Imm"; let PredicateMethod = "isU4Imm";
524 let RenderMethod = "addImmOperands";
526 def u4imm : Operand<i32> {
527 let PrintMethod = "printU4ImmOperand";
528 let ParserMatchClass = PPCU4ImmAsmOperand;
530 def PPCS5ImmAsmOperand : AsmOperandClass {
531 let Name = "S5Imm"; let PredicateMethod = "isS5Imm";
532 let RenderMethod = "addImmOperands";
534 def s5imm : Operand<i32> {
535 let PrintMethod = "printS5ImmOperand";
536 let ParserMatchClass = PPCS5ImmAsmOperand;
537 let DecoderMethod = "decodeSImmOperand<5>";
539 def PPCU5ImmAsmOperand : AsmOperandClass {
540 let Name = "U5Imm"; let PredicateMethod = "isU5Imm";
541 let RenderMethod = "addImmOperands";
543 def u5imm : Operand<i32> {
544 let PrintMethod = "printU5ImmOperand";
545 let ParserMatchClass = PPCU5ImmAsmOperand;
546 let DecoderMethod = "decodeUImmOperand<5>";
548 def PPCU6ImmAsmOperand : AsmOperandClass {
549 let Name = "U6Imm"; let PredicateMethod = "isU6Imm";
550 let RenderMethod = "addImmOperands";
552 def u6imm : Operand<i32> {
553 let PrintMethod = "printU6ImmOperand";
554 let ParserMatchClass = PPCU6ImmAsmOperand;
555 let DecoderMethod = "decodeUImmOperand<6>";
557 def PPCU7ImmAsmOperand : AsmOperandClass {
558 let Name = "U7Imm"; let PredicateMethod = "isU7Imm";
559 let RenderMethod = "addImmOperands";
561 def u7imm : Operand<i32> {
562 let PrintMethod = "printU7ImmOperand";
563 let ParserMatchClass = PPCU7ImmAsmOperand;
564 let DecoderMethod = "decodeUImmOperand<7>";
566 def PPCU8ImmAsmOperand : AsmOperandClass {
567 let Name = "U8Imm"; let PredicateMethod = "isU8Imm";
568 let RenderMethod = "addImmOperands";
570 def u8imm : Operand<i32> {
571 let PrintMethod = "printU8ImmOperand";
572 let ParserMatchClass = PPCU8ImmAsmOperand;
573 let DecoderMethod = "decodeUImmOperand<8>";
575 def PPCU10ImmAsmOperand : AsmOperandClass {
576 let Name = "U10Imm"; let PredicateMethod = "isU10Imm";
577 let RenderMethod = "addImmOperands";
579 def u10imm : Operand<i32> {
580 let PrintMethod = "printU10ImmOperand";
581 let ParserMatchClass = PPCU10ImmAsmOperand;
582 let DecoderMethod = "decodeUImmOperand<10>";
584 def PPCU12ImmAsmOperand : AsmOperandClass {
585 let Name = "U12Imm"; let PredicateMethod = "isU12Imm";
586 let RenderMethod = "addImmOperands";
588 def u12imm : Operand<i32> {
589 let PrintMethod = "printU12ImmOperand";
590 let ParserMatchClass = PPCU12ImmAsmOperand;
591 let DecoderMethod = "decodeUImmOperand<12>";
593 def PPCS16ImmAsmOperand : AsmOperandClass {
594 let Name = "S16Imm"; let PredicateMethod = "isS16Imm";
595 let RenderMethod = "addS16ImmOperands";
597 def s16imm : Operand<i32> {
598 let PrintMethod = "printS16ImmOperand";
599 let EncoderMethod = "getImm16Encoding";
600 let ParserMatchClass = PPCS16ImmAsmOperand;
601 let DecoderMethod = "decodeSImmOperand<16>";
603 def PPCU16ImmAsmOperand : AsmOperandClass {
604 let Name = "U16Imm"; let PredicateMethod = "isU16Imm";
605 let RenderMethod = "addU16ImmOperands";
607 def u16imm : Operand<i32> {
608 let PrintMethod = "printU16ImmOperand";
609 let EncoderMethod = "getImm16Encoding";
610 let ParserMatchClass = PPCU16ImmAsmOperand;
611 let DecoderMethod = "decodeUImmOperand<16>";
613 def PPCS17ImmAsmOperand : AsmOperandClass {
614 let Name = "S17Imm"; let PredicateMethod = "isS17Imm";
615 let RenderMethod = "addS16ImmOperands";
617 def s17imm : Operand<i32> {
618 // This operand type is used for addis/lis to allow the assembler parser
619 // to accept immediates in the range -65536..65535 for compatibility with
620 // the GNU assembler. The operand is treated as 16-bit otherwise.
621 let PrintMethod = "printS16ImmOperand";
622 let EncoderMethod = "getImm16Encoding";
623 let ParserMatchClass = PPCS17ImmAsmOperand;
624 let DecoderMethod = "decodeSImmOperand<16>";
627 def fpimm0 : PatLeaf<(fpimm), [{ return N->isExactlyValue(+0.0); }]>;
629 def PPCDirectBrAsmOperand : AsmOperandClass {
630 let Name = "DirectBr"; let PredicateMethod = "isDirectBr";
631 let RenderMethod = "addBranchTargetOperands";
633 def directbrtarget : Operand<OtherVT> {
634 let PrintMethod = "printBranchOperand";
635 let EncoderMethod = "getDirectBrEncoding";
636 let ParserMatchClass = PPCDirectBrAsmOperand;
638 def absdirectbrtarget : Operand<OtherVT> {
639 let PrintMethod = "printAbsBranchOperand";
640 let EncoderMethod = "getAbsDirectBrEncoding";
641 let ParserMatchClass = PPCDirectBrAsmOperand;
643 def PPCCondBrAsmOperand : AsmOperandClass {
644 let Name = "CondBr"; let PredicateMethod = "isCondBr";
645 let RenderMethod = "addBranchTargetOperands";
647 def condbrtarget : Operand<OtherVT> {
648 let PrintMethod = "printBranchOperand";
649 let EncoderMethod = "getCondBrEncoding";
650 let ParserMatchClass = PPCCondBrAsmOperand;
652 def abscondbrtarget : Operand<OtherVT> {
653 let PrintMethod = "printAbsBranchOperand";
654 let EncoderMethod = "getAbsCondBrEncoding";
655 let ParserMatchClass = PPCCondBrAsmOperand;
657 def calltarget : Operand<iPTR> {
658 let PrintMethod = "printBranchOperand";
659 let EncoderMethod = "getDirectBrEncoding";
660 let ParserMatchClass = PPCDirectBrAsmOperand;
662 def abscalltarget : Operand<iPTR> {
663 let PrintMethod = "printAbsBranchOperand";
664 let EncoderMethod = "getAbsDirectBrEncoding";
665 let ParserMatchClass = PPCDirectBrAsmOperand;
667 def PPCCRBitMaskOperand : AsmOperandClass {
668 let Name = "CRBitMask"; let PredicateMethod = "isCRBitMask";
670 def crbitm: Operand<i8> {
671 let PrintMethod = "printcrbitm";
672 let EncoderMethod = "get_crbitm_encoding";
673 let DecoderMethod = "decodeCRBitMOperand";
674 let ParserMatchClass = PPCCRBitMaskOperand;
677 // A version of ptr_rc which excludes R0 (or X0 in 64-bit mode).
678 def PPCRegGxRCNoR0Operand : AsmOperandClass {
679 let Name = "RegGxRCNoR0"; let PredicateMethod = "isRegNumber";
681 def ptr_rc_nor0 : Operand<iPTR>, PointerLikeRegClass<1> {
682 let ParserMatchClass = PPCRegGxRCNoR0Operand;
684 // A version of ptr_rc usable with the asm parser.
685 def PPCRegGxRCOperand : AsmOperandClass {
686 let Name = "RegGxRC"; let PredicateMethod = "isRegNumber";
688 def ptr_rc_idx : Operand<iPTR>, PointerLikeRegClass<0> {
689 let ParserMatchClass = PPCRegGxRCOperand;
692 def PPCDispRIOperand : AsmOperandClass {
693 let Name = "DispRI"; let PredicateMethod = "isS16Imm";
694 let RenderMethod = "addS16ImmOperands";
696 def dispRI : Operand<iPTR> {
697 let ParserMatchClass = PPCDispRIOperand;
699 def PPCDispRIXOperand : AsmOperandClass {
700 let Name = "DispRIX"; let PredicateMethod = "isS16ImmX4";
701 let RenderMethod = "addImmOperands";
703 def dispRIX : Operand<iPTR> {
704 let ParserMatchClass = PPCDispRIXOperand;
706 def PPCDispRIX16Operand : AsmOperandClass {
707 let Name = "DispRIX16"; let PredicateMethod = "isS16ImmX16";
708 let RenderMethod = "addImmOperands";
710 def dispRIX16 : Operand<iPTR> {
711 let ParserMatchClass = PPCDispRIX16Operand;
713 def PPCDispSPE8Operand : AsmOperandClass {
714 let Name = "DispSPE8"; let PredicateMethod = "isU8ImmX8";
715 let RenderMethod = "addImmOperands";
717 def dispSPE8 : Operand<iPTR> {
718 let ParserMatchClass = PPCDispSPE8Operand;
720 def PPCDispSPE4Operand : AsmOperandClass {
721 let Name = "DispSPE4"; let PredicateMethod = "isU7ImmX4";
722 let RenderMethod = "addImmOperands";
724 def dispSPE4 : Operand<iPTR> {
725 let ParserMatchClass = PPCDispSPE4Operand;
727 def PPCDispSPE2Operand : AsmOperandClass {
728 let Name = "DispSPE2"; let PredicateMethod = "isU6ImmX2";
729 let RenderMethod = "addImmOperands";
731 def dispSPE2 : Operand<iPTR> {
732 let ParserMatchClass = PPCDispSPE2Operand;
735 def memri : Operand<iPTR> {
736 let PrintMethod = "printMemRegImm";
737 let MIOperandInfo = (ops dispRI:$imm, ptr_rc_nor0:$reg);
738 let EncoderMethod = "getMemRIEncoding";
739 let DecoderMethod = "decodeMemRIOperands";
741 def memrr : Operand<iPTR> {
742 let PrintMethod = "printMemRegReg";
743 let MIOperandInfo = (ops ptr_rc_nor0:$ptrreg, ptr_rc_idx:$offreg);
745 def memrix : Operand<iPTR> { // memri where the imm is 4-aligned.
746 let PrintMethod = "printMemRegImm";
747 let MIOperandInfo = (ops dispRIX:$imm, ptr_rc_nor0:$reg);
748 let EncoderMethod = "getMemRIXEncoding";
749 let DecoderMethod = "decodeMemRIXOperands";
751 def memrix16 : Operand<iPTR> { // memri, imm is 16-aligned, 12-bit, Inst{16:27}
752 let PrintMethod = "printMemRegImm";
753 let MIOperandInfo = (ops dispRIX16:$imm, ptr_rc_nor0:$reg);
754 let EncoderMethod = "getMemRIX16Encoding";
755 let DecoderMethod = "decodeMemRIX16Operands";
757 def spe8dis : Operand<iPTR> { // SPE displacement where the imm is 8-aligned.
758 let PrintMethod = "printMemRegImm";
759 let MIOperandInfo = (ops dispSPE8:$imm, ptr_rc_nor0:$reg);
760 let EncoderMethod = "getSPE8DisEncoding";
762 def spe4dis : Operand<iPTR> { // SPE displacement where the imm is 4-aligned.
763 let PrintMethod = "printMemRegImm";
764 let MIOperandInfo = (ops dispSPE4:$imm, ptr_rc_nor0:$reg);
765 let EncoderMethod = "getSPE4DisEncoding";
767 def spe2dis : Operand<iPTR> { // SPE displacement where the imm is 2-aligned.
768 let PrintMethod = "printMemRegImm";
769 let MIOperandInfo = (ops dispSPE2:$imm, ptr_rc_nor0:$reg);
770 let EncoderMethod = "getSPE2DisEncoding";
773 // A single-register address. This is used with the SjLj
774 // pseudo-instructions which tranlates to LD/LWZ. These instructions requires
775 // G8RC_NOX0 registers.
776 def memr : Operand<iPTR> {
777 let MIOperandInfo = (ops ptr_rc_nor0:$ptrreg);
779 def PPCTLSRegOperand : AsmOperandClass {
780 let Name = "TLSReg"; let PredicateMethod = "isTLSReg";
781 let RenderMethod = "addTLSRegOperands";
783 def tlsreg32 : Operand<i32> {
784 let EncoderMethod = "getTLSRegEncoding";
785 let ParserMatchClass = PPCTLSRegOperand;
787 def tlsgd32 : Operand<i32> {}
788 def tlscall32 : Operand<i32> {
789 let PrintMethod = "printTLSCall";
790 let MIOperandInfo = (ops calltarget:$func, tlsgd32:$sym);
791 let EncoderMethod = "getTLSCallEncoding";
794 // PowerPC Predicate operand.
795 def pred : Operand<OtherVT> {
796 let PrintMethod = "printPredicateOperand";
797 let MIOperandInfo = (ops i32imm:$bibo, crrc:$reg);
800 // Define PowerPC specific addressing mode.
801 def iaddr : ComplexPattern<iPTR, 2, "SelectAddrImm", [], []>;
802 def xaddr : ComplexPattern<iPTR, 2, "SelectAddrIdx", [], []>;
803 def xoaddr : ComplexPattern<iPTR, 2, "SelectAddrIdxOnly",[], []>;
804 def ixaddr : ComplexPattern<iPTR, 2, "SelectAddrImmX4", [], []>; // "std"
806 // The address in a single register. This is used with the SjLj
807 // pseudo-instructions.
808 def addr : ComplexPattern<iPTR, 1, "SelectAddr",[], []>;
810 /// This is just the offset part of iaddr, used for preinc.
811 def iaddroff : ComplexPattern<iPTR, 1, "SelectAddrImmOffs", [], []>;
813 //===----------------------------------------------------------------------===//
814 // PowerPC Instruction Predicate Definitions.
815 def In32BitMode : Predicate<"!PPCSubTarget->isPPC64()">;
816 def In64BitMode : Predicate<"PPCSubTarget->isPPC64()">;
817 def IsBookE : Predicate<"PPCSubTarget->isBookE()">;
818 def IsNotBookE : Predicate<"!PPCSubTarget->isBookE()">;
819 def HasOnlyMSYNC : Predicate<"PPCSubTarget->hasOnlyMSYNC()">;
820 def HasSYNC : Predicate<"!PPCSubTarget->hasOnlyMSYNC()">;
821 def IsPPC4xx : Predicate<"PPCSubTarget->isPPC4xx()">;
822 def IsPPC6xx : Predicate<"PPCSubTarget->isPPC6xx()">;
823 def IsE500 : Predicate<"PPCSubTarget->isE500()">;
824 def HasSPE : Predicate<"PPCSubTarget->HasSPE()">;
825 def HasICBT : Predicate<"PPCSubTarget->hasICBT()">;
826 def HasPartwordAtomics : Predicate<"PPCSubTarget->hasPartwordAtomics()">;
827 def NoNaNsFPMath : Predicate<"TM.Options.NoNaNsFPMath">;
828 def NaNsFPMath : Predicate<"!TM.Options.NoNaNsFPMath">;
829 def HasBPERMD : Predicate<"PPCSubTarget->hasBPERMD()">;
830 def HasExtDiv : Predicate<"PPCSubTarget->hasExtDiv()">;
831 def IsISA3_0 : Predicate<"PPCSubTarget->isISA3_0()">;
833 //===----------------------------------------------------------------------===//
834 // PowerPC Multiclass Definitions.
836 multiclass XForm_6r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
837 string asmbase, string asmstr, InstrItinClass itin,
839 let BaseName = asmbase in {
840 def NAME : XForm_6<opcode, xo, OOL, IOL,
841 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
842 pattern>, RecFormRel;
844 def o : XForm_6<opcode, xo, OOL, IOL,
845 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
846 []>, isDOT, RecFormRel;
850 multiclass XForm_6rc<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
851 string asmbase, string asmstr, InstrItinClass itin,
853 let BaseName = asmbase in {
854 let Defs = [CARRY] in
855 def NAME : XForm_6<opcode, xo, OOL, IOL,
856 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
857 pattern>, RecFormRel;
858 let Defs = [CARRY, CR0] in
859 def o : XForm_6<opcode, xo, OOL, IOL,
860 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
861 []>, isDOT, RecFormRel;
865 multiclass XForm_10rc<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
866 string asmbase, string asmstr, InstrItinClass itin,
868 let BaseName = asmbase in {
869 let Defs = [CARRY] in
870 def NAME : XForm_10<opcode, xo, OOL, IOL,
871 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
872 pattern>, RecFormRel;
873 let Defs = [CARRY, CR0] in
874 def o : XForm_10<opcode, xo, OOL, IOL,
875 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
876 []>, isDOT, RecFormRel;
880 multiclass XForm_11r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
881 string asmbase, string asmstr, InstrItinClass itin,
883 let BaseName = asmbase in {
884 def NAME : XForm_11<opcode, xo, OOL, IOL,
885 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
886 pattern>, RecFormRel;
888 def o : XForm_11<opcode, xo, OOL, IOL,
889 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
890 []>, isDOT, RecFormRel;
894 multiclass XOForm_1r<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
895 string asmbase, string asmstr, InstrItinClass itin,
897 let BaseName = asmbase in {
898 def NAME : XOForm_1<opcode, xo, oe, OOL, IOL,
899 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
900 pattern>, RecFormRel;
902 def o : XOForm_1<opcode, xo, oe, OOL, IOL,
903 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
904 []>, isDOT, RecFormRel;
908 // Multiclass for instructions for which the non record form is not cracked
909 // and the record form is cracked (i.e. divw, mullw, etc.)
910 multiclass XOForm_1rcr<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
911 string asmbase, string asmstr, InstrItinClass itin,
913 let BaseName = asmbase in {
914 def NAME : XOForm_1<opcode, xo, oe, OOL, IOL,
915 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
916 pattern>, RecFormRel;
918 def o : XOForm_1<opcode, xo, oe, OOL, IOL,
919 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
920 []>, isDOT, RecFormRel, PPC970_DGroup_First,
921 PPC970_DGroup_Cracked;
925 multiclass XOForm_1rc<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
926 string asmbase, string asmstr, InstrItinClass itin,
928 let BaseName = asmbase in {
929 let Defs = [CARRY] in
930 def NAME : XOForm_1<opcode, xo, oe, OOL, IOL,
931 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
932 pattern>, RecFormRel;
933 let Defs = [CARRY, CR0] in
934 def o : XOForm_1<opcode, xo, oe, OOL, IOL,
935 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
936 []>, isDOT, RecFormRel;
940 multiclass XOForm_3r<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
941 string asmbase, string asmstr, InstrItinClass itin,
943 let BaseName = asmbase in {
944 def NAME : XOForm_3<opcode, xo, oe, OOL, IOL,
945 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
946 pattern>, RecFormRel;
948 def o : XOForm_3<opcode, xo, oe, OOL, IOL,
949 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
950 []>, isDOT, RecFormRel;
954 multiclass XOForm_3rc<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
955 string asmbase, string asmstr, InstrItinClass itin,
957 let BaseName = asmbase in {
958 let Defs = [CARRY] in
959 def NAME : XOForm_3<opcode, xo, oe, OOL, IOL,
960 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
961 pattern>, RecFormRel;
962 let Defs = [CARRY, CR0] in
963 def o : XOForm_3<opcode, xo, oe, OOL, IOL,
964 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
965 []>, isDOT, RecFormRel;
969 multiclass MForm_2r<bits<6> opcode, dag OOL, dag IOL,
970 string asmbase, string asmstr, InstrItinClass itin,
972 let BaseName = asmbase in {
973 def NAME : MForm_2<opcode, OOL, IOL,
974 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
975 pattern>, RecFormRel;
977 def o : MForm_2<opcode, OOL, IOL,
978 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
979 []>, isDOT, RecFormRel;
983 multiclass MDForm_1r<bits<6> opcode, bits<3> xo, dag OOL, dag IOL,
984 string asmbase, string asmstr, InstrItinClass itin,
986 let BaseName = asmbase in {
987 def NAME : MDForm_1<opcode, xo, OOL, IOL,
988 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
989 pattern>, RecFormRel;
991 def o : MDForm_1<opcode, xo, OOL, IOL,
992 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
993 []>, isDOT, RecFormRel;
997 multiclass MDSForm_1r<bits<6> opcode, bits<4> xo, dag OOL, dag IOL,
998 string asmbase, string asmstr, InstrItinClass itin,
1000 let BaseName = asmbase in {
1001 def NAME : MDSForm_1<opcode, xo, OOL, IOL,
1002 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1003 pattern>, RecFormRel;
1005 def o : MDSForm_1<opcode, xo, OOL, IOL,
1006 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1007 []>, isDOT, RecFormRel;
1011 multiclass XSForm_1rc<bits<6> opcode, bits<9> xo, dag OOL, dag IOL,
1012 string asmbase, string asmstr, InstrItinClass itin,
1013 list<dag> pattern> {
1014 let BaseName = asmbase in {
1015 let Defs = [CARRY] in
1016 def NAME : XSForm_1<opcode, xo, OOL, IOL,
1017 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1018 pattern>, RecFormRel;
1019 let Defs = [CARRY, CR0] in
1020 def o : XSForm_1<opcode, xo, OOL, IOL,
1021 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1022 []>, isDOT, RecFormRel;
1026 multiclass XForm_26r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
1027 string asmbase, string asmstr, InstrItinClass itin,
1028 list<dag> pattern> {
1029 let BaseName = asmbase in {
1030 def NAME : XForm_26<opcode, xo, OOL, IOL,
1031 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1032 pattern>, RecFormRel;
1034 def o : XForm_26<opcode, xo, OOL, IOL,
1035 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1036 []>, isDOT, RecFormRel;
1040 multiclass XForm_28r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
1041 string asmbase, string asmstr, InstrItinClass itin,
1042 list<dag> pattern> {
1043 let BaseName = asmbase in {
1044 def NAME : XForm_28<opcode, xo, OOL, IOL,
1045 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1046 pattern>, RecFormRel;
1048 def o : XForm_28<opcode, xo, OOL, IOL,
1049 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1050 []>, isDOT, RecFormRel;
1054 multiclass AForm_1r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL,
1055 string asmbase, string asmstr, InstrItinClass itin,
1056 list<dag> pattern> {
1057 let BaseName = asmbase in {
1058 def NAME : AForm_1<opcode, xo, OOL, IOL,
1059 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1060 pattern>, RecFormRel;
1062 def o : AForm_1<opcode, xo, OOL, IOL,
1063 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1064 []>, isDOT, RecFormRel;
1068 multiclass AForm_2r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL,
1069 string asmbase, string asmstr, InstrItinClass itin,
1070 list<dag> pattern> {
1071 let BaseName = asmbase in {
1072 def NAME : AForm_2<opcode, xo, OOL, IOL,
1073 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1074 pattern>, RecFormRel;
1076 def o : AForm_2<opcode, xo, OOL, IOL,
1077 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1078 []>, isDOT, RecFormRel;
1082 multiclass AForm_3r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL,
1083 string asmbase, string asmstr, InstrItinClass itin,
1084 list<dag> pattern> {
1085 let BaseName = asmbase in {
1086 def NAME : AForm_3<opcode, xo, OOL, IOL,
1087 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1088 pattern>, RecFormRel;
1090 def o : AForm_3<opcode, xo, OOL, IOL,
1091 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1092 []>, isDOT, RecFormRel;
1096 //===----------------------------------------------------------------------===//
1097 // PowerPC Instruction Definitions.
1099 // Pseudo-instructions:
1101 let hasCtrlDep = 1 in {
1102 let Defs = [R1], Uses = [R1] in {
1103 def ADJCALLSTACKDOWN : Pseudo<(outs), (ins u16imm:$amt1, u16imm:$amt2),
1104 "#ADJCALLSTACKDOWN $amt1 $amt2",
1105 [(callseq_start timm:$amt1, timm:$amt2)]>;
1106 def ADJCALLSTACKUP : Pseudo<(outs), (ins u16imm:$amt1, u16imm:$amt2),
1107 "#ADJCALLSTACKUP $amt1 $amt2",
1108 [(callseq_end timm:$amt1, timm:$amt2)]>;
1111 def UPDATE_VRSAVE : Pseudo<(outs gprc:$rD), (ins gprc:$rS),
1112 "UPDATE_VRSAVE $rD, $rS", []>;
1115 let Defs = [R1], Uses = [R1] in
1116 def DYNALLOC : Pseudo<(outs gprc:$result), (ins gprc:$negsize, memri:$fpsi), "#DYNALLOC",
1118 (PPCdynalloc i32:$negsize, iaddr:$fpsi))]>;
1119 def DYNAREAOFFSET : Pseudo<(outs i32imm:$result), (ins memri:$fpsi), "#DYNAREAOFFSET",
1120 [(set i32:$result, (PPCdynareaoffset iaddr:$fpsi))]>;
1122 // SELECT_CC_* - Used to implement the SELECT_CC DAG operation. Expanded after
1123 // instruction selection into a branch sequence.
1124 let usesCustomInserter = 1, // Expanded after instruction selection.
1125 PPC970_Single = 1 in {
1126 // Note that SELECT_CC_I4 and SELECT_CC_I8 use the no-r0 register classes
1127 // because either operand might become the first operand in an isel, and
1128 // that operand cannot be r0.
1129 def SELECT_CC_I4 : Pseudo<(outs gprc:$dst), (ins crrc:$cond,
1130 gprc_nor0:$T, gprc_nor0:$F,
1131 i32imm:$BROPC), "#SELECT_CC_I4",
1133 def SELECT_CC_I8 : Pseudo<(outs g8rc:$dst), (ins crrc:$cond,
1134 g8rc_nox0:$T, g8rc_nox0:$F,
1135 i32imm:$BROPC), "#SELECT_CC_I8",
1137 def SELECT_CC_F4 : Pseudo<(outs f4rc:$dst), (ins crrc:$cond, f4rc:$T, f4rc:$F,
1138 i32imm:$BROPC), "#SELECT_CC_F4",
1140 def SELECT_CC_F8 : Pseudo<(outs f8rc:$dst), (ins crrc:$cond, f8rc:$T, f8rc:$F,
1141 i32imm:$BROPC), "#SELECT_CC_F8",
1143 def SELECT_CC_VRRC: Pseudo<(outs vrrc:$dst), (ins crrc:$cond, vrrc:$T, vrrc:$F,
1144 i32imm:$BROPC), "#SELECT_CC_VRRC",
1147 // SELECT_* pseudo instructions, like SELECT_CC_* but taking condition
1148 // register bit directly.
1149 def SELECT_I4 : Pseudo<(outs gprc:$dst), (ins crbitrc:$cond,
1150 gprc_nor0:$T, gprc_nor0:$F), "#SELECT_I4",
1151 [(set i32:$dst, (select i1:$cond, i32:$T, i32:$F))]>;
1152 def SELECT_I8 : Pseudo<(outs g8rc:$dst), (ins crbitrc:$cond,
1153 g8rc_nox0:$T, g8rc_nox0:$F), "#SELECT_I8",
1154 [(set i64:$dst, (select i1:$cond, i64:$T, i64:$F))]>;
1155 def SELECT_F4 : Pseudo<(outs f4rc:$dst), (ins crbitrc:$cond,
1156 f4rc:$T, f4rc:$F), "#SELECT_F4",
1157 [(set f32:$dst, (select i1:$cond, f32:$T, f32:$F))]>;
1158 def SELECT_F8 : Pseudo<(outs f8rc:$dst), (ins crbitrc:$cond,
1159 f8rc:$T, f8rc:$F), "#SELECT_F8",
1160 [(set f64:$dst, (select i1:$cond, f64:$T, f64:$F))]>;
1161 def SELECT_VRRC: Pseudo<(outs vrrc:$dst), (ins crbitrc:$cond,
1162 vrrc:$T, vrrc:$F), "#SELECT_VRRC",
1164 (select i1:$cond, v4i32:$T, v4i32:$F))]>;
1167 // SPILL_CR - Indicate that we're dumping the CR register, so we'll need to
1168 // scavenge a register for it.
1169 let mayStore = 1 in {
1170 def SPILL_CR : Pseudo<(outs), (ins crrc:$cond, memri:$F),
1172 def SPILL_CRBIT : Pseudo<(outs), (ins crbitrc:$cond, memri:$F),
1173 "#SPILL_CRBIT", []>;
1176 // RESTORE_CR - Indicate that we're restoring the CR register (previously
1177 // spilled), so we'll need to scavenge a register for it.
1178 let mayLoad = 1 in {
1179 def RESTORE_CR : Pseudo<(outs crrc:$cond), (ins memri:$F),
1181 def RESTORE_CRBIT : Pseudo<(outs crbitrc:$cond), (ins memri:$F),
1182 "#RESTORE_CRBIT", []>;
1185 let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7 in {
1186 let isReturn = 1, Uses = [LR, RM] in
1187 def BLR : XLForm_2_ext<19, 16, 20, 0, 0, (outs), (ins), "blr", IIC_BrB,
1188 [(retflag)]>, Requires<[In32BitMode]>;
1189 let isBranch = 1, isIndirectBranch = 1, Uses = [CTR] in {
1190 def BCTR : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
1193 let isCodeGenOnly = 1 in {
1194 def BCCCTR : XLForm_2_br<19, 528, 0, (outs), (ins pred:$cond),
1195 "b${cond:cc}ctr${cond:pm} ${cond:reg}", IIC_BrB,
1198 def BCCTR : XLForm_2_br2<19, 528, 12, 0, (outs), (ins crbitrc:$bi),
1199 "bcctr 12, $bi, 0", IIC_BrB, []>;
1200 def BCCTRn : XLForm_2_br2<19, 528, 4, 0, (outs), (ins crbitrc:$bi),
1201 "bcctr 4, $bi, 0", IIC_BrB, []>;
1207 def MovePCtoLR : Pseudo<(outs), (ins), "#MovePCtoLR", []>,
1210 def MoveGOTtoLR : Pseudo<(outs), (ins), "#MoveGOTtoLR", []>,
1213 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7 in {
1214 let isBarrier = 1 in {
1215 def B : IForm<18, 0, 0, (outs), (ins directbrtarget:$dst),
1218 def BA : IForm<18, 1, 0, (outs), (ins absdirectbrtarget:$dst),
1219 "ba $dst", IIC_BrB, []>;
1222 // BCC represents an arbitrary conditional branch on a predicate.
1223 // FIXME: should be able to write a pattern for PPCcondbranch, but can't use
1224 // a two-value operand where a dag node expects two operands. :(
1225 let isCodeGenOnly = 1 in {
1226 class BCC_class : BForm<16, 0, 0, (outs), (ins pred:$cond, condbrtarget:$dst),
1227 "b${cond:cc}${cond:pm} ${cond:reg}, $dst"
1228 /*[(PPCcondbranch crrc:$crS, imm:$opc, bb:$dst)]*/>;
1229 def BCC : BCC_class;
1231 // The same as BCC, except that it's not a terminator. Used for introducing
1232 // control flow dependency without creating new blocks.
1233 let isTerminator = 0 in def CTRL_DEP : BCC_class;
1235 def BCCA : BForm<16, 1, 0, (outs), (ins pred:$cond, abscondbrtarget:$dst),
1236 "b${cond:cc}a${cond:pm} ${cond:reg}, $dst">;
1238 let isReturn = 1, Uses = [LR, RM] in
1239 def BCCLR : XLForm_2_br<19, 16, 0, (outs), (ins pred:$cond),
1240 "b${cond:cc}lr${cond:pm} ${cond:reg}", IIC_BrB, []>;
1243 let isCodeGenOnly = 1 in {
1244 let Pattern = [(brcond i1:$bi, bb:$dst)] in
1245 def BC : BForm_4<16, 12, 0, 0, (outs), (ins crbitrc:$bi, condbrtarget:$dst),
1246 "bc 12, $bi, $dst">;
1248 let Pattern = [(brcond (not i1:$bi), bb:$dst)] in
1249 def BCn : BForm_4<16, 4, 0, 0, (outs), (ins crbitrc:$bi, condbrtarget:$dst),
1252 let isReturn = 1, Uses = [LR, RM] in
1253 def BCLR : XLForm_2_br2<19, 16, 12, 0, (outs), (ins crbitrc:$bi),
1254 "bclr 12, $bi, 0", IIC_BrB, []>;
1255 def BCLRn : XLForm_2_br2<19, 16, 4, 0, (outs), (ins crbitrc:$bi),
1256 "bclr 4, $bi, 0", IIC_BrB, []>;
1259 let isReturn = 1, Defs = [CTR], Uses = [CTR, LR, RM] in {
1260 def BDZLR : XLForm_2_ext<19, 16, 18, 0, 0, (outs), (ins),
1261 "bdzlr", IIC_BrB, []>;
1262 def BDNZLR : XLForm_2_ext<19, 16, 16, 0, 0, (outs), (ins),
1263 "bdnzlr", IIC_BrB, []>;
1264 def BDZLRp : XLForm_2_ext<19, 16, 27, 0, 0, (outs), (ins),
1265 "bdzlr+", IIC_BrB, []>;
1266 def BDNZLRp: XLForm_2_ext<19, 16, 25, 0, 0, (outs), (ins),
1267 "bdnzlr+", IIC_BrB, []>;
1268 def BDZLRm : XLForm_2_ext<19, 16, 26, 0, 0, (outs), (ins),
1269 "bdzlr-", IIC_BrB, []>;
1270 def BDNZLRm: XLForm_2_ext<19, 16, 24, 0, 0, (outs), (ins),
1271 "bdnzlr-", IIC_BrB, []>;
1274 let Defs = [CTR], Uses = [CTR] in {
1275 def BDZ : BForm_1<16, 18, 0, 0, (outs), (ins condbrtarget:$dst),
1277 def BDNZ : BForm_1<16, 16, 0, 0, (outs), (ins condbrtarget:$dst),
1279 def BDZA : BForm_1<16, 18, 1, 0, (outs), (ins abscondbrtarget:$dst),
1281 def BDNZA : BForm_1<16, 16, 1, 0, (outs), (ins abscondbrtarget:$dst),
1283 def BDZp : BForm_1<16, 27, 0, 0, (outs), (ins condbrtarget:$dst),
1285 def BDNZp: BForm_1<16, 25, 0, 0, (outs), (ins condbrtarget:$dst),
1287 def BDZAp : BForm_1<16, 27, 1, 0, (outs), (ins abscondbrtarget:$dst),
1289 def BDNZAp: BForm_1<16, 25, 1, 0, (outs), (ins abscondbrtarget:$dst),
1291 def BDZm : BForm_1<16, 26, 0, 0, (outs), (ins condbrtarget:$dst),
1293 def BDNZm: BForm_1<16, 24, 0, 0, (outs), (ins condbrtarget:$dst),
1295 def BDZAm : BForm_1<16, 26, 1, 0, (outs), (ins abscondbrtarget:$dst),
1297 def BDNZAm: BForm_1<16, 24, 1, 0, (outs), (ins abscondbrtarget:$dst),
1302 // The unconditional BCL used by the SjLj setjmp code.
1303 let isCall = 1, hasCtrlDep = 1, isCodeGenOnly = 1, PPC970_Unit = 7 in {
1304 let Defs = [LR], Uses = [RM] in {
1305 def BCLalways : BForm_2<16, 20, 31, 0, 1, (outs), (ins condbrtarget:$dst),
1306 "bcl 20, 31, $dst">;
1310 let isCall = 1, PPC970_Unit = 7, Defs = [LR] in {
1311 // Convenient aliases for call instructions
1312 let Uses = [RM] in {
1313 def BL : IForm<18, 0, 1, (outs), (ins calltarget:$func),
1314 "bl $func", IIC_BrB, []>; // See Pat patterns below.
1315 def BLA : IForm<18, 1, 1, (outs), (ins abscalltarget:$func),
1316 "bla $func", IIC_BrB, [(PPCcall (i32 imm:$func))]>;
1318 let isCodeGenOnly = 1 in {
1319 def BL_TLS : IForm<18, 0, 1, (outs), (ins tlscall32:$func),
1320 "bl $func", IIC_BrB, []>;
1321 def BCCL : BForm<16, 0, 1, (outs), (ins pred:$cond, condbrtarget:$dst),
1322 "b${cond:cc}l${cond:pm} ${cond:reg}, $dst">;
1323 def BCCLA : BForm<16, 1, 1, (outs), (ins pred:$cond, abscondbrtarget:$dst),
1324 "b${cond:cc}la${cond:pm} ${cond:reg}, $dst">;
1326 def BCL : BForm_4<16, 12, 0, 1, (outs),
1327 (ins crbitrc:$bi, condbrtarget:$dst),
1328 "bcl 12, $bi, $dst">;
1329 def BCLn : BForm_4<16, 4, 0, 1, (outs),
1330 (ins crbitrc:$bi, condbrtarget:$dst),
1331 "bcl 4, $bi, $dst">;
1334 let Uses = [CTR, RM] in {
1335 def BCTRL : XLForm_2_ext<19, 528, 20, 0, 1, (outs), (ins),
1336 "bctrl", IIC_BrB, [(PPCbctrl)]>,
1337 Requires<[In32BitMode]>;
1339 let isCodeGenOnly = 1 in {
1340 def BCCCTRL : XLForm_2_br<19, 528, 1, (outs), (ins pred:$cond),
1341 "b${cond:cc}ctrl${cond:pm} ${cond:reg}", IIC_BrB,
1344 def BCCTRL : XLForm_2_br2<19, 528, 12, 1, (outs), (ins crbitrc:$bi),
1345 "bcctrl 12, $bi, 0", IIC_BrB, []>;
1346 def BCCTRLn : XLForm_2_br2<19, 528, 4, 1, (outs), (ins crbitrc:$bi),
1347 "bcctrl 4, $bi, 0", IIC_BrB, []>;
1350 let Uses = [LR, RM] in {
1351 def BLRL : XLForm_2_ext<19, 16, 20, 0, 1, (outs), (ins),
1352 "blrl", IIC_BrB, []>;
1354 let isCodeGenOnly = 1 in {
1355 def BCCLRL : XLForm_2_br<19, 16, 1, (outs), (ins pred:$cond),
1356 "b${cond:cc}lrl${cond:pm} ${cond:reg}", IIC_BrB,
1359 def BCLRL : XLForm_2_br2<19, 16, 12, 1, (outs), (ins crbitrc:$bi),
1360 "bclrl 12, $bi, 0", IIC_BrB, []>;
1361 def BCLRLn : XLForm_2_br2<19, 16, 4, 1, (outs), (ins crbitrc:$bi),
1362 "bclrl 4, $bi, 0", IIC_BrB, []>;
1365 let Defs = [CTR], Uses = [CTR, RM] in {
1366 def BDZL : BForm_1<16, 18, 0, 1, (outs), (ins condbrtarget:$dst),
1368 def BDNZL : BForm_1<16, 16, 0, 1, (outs), (ins condbrtarget:$dst),
1370 def BDZLA : BForm_1<16, 18, 1, 1, (outs), (ins abscondbrtarget:$dst),
1372 def BDNZLA : BForm_1<16, 16, 1, 1, (outs), (ins abscondbrtarget:$dst),
1374 def BDZLp : BForm_1<16, 27, 0, 1, (outs), (ins condbrtarget:$dst),
1376 def BDNZLp: BForm_1<16, 25, 0, 1, (outs), (ins condbrtarget:$dst),
1378 def BDZLAp : BForm_1<16, 27, 1, 1, (outs), (ins abscondbrtarget:$dst),
1380 def BDNZLAp: BForm_1<16, 25, 1, 1, (outs), (ins abscondbrtarget:$dst),
1382 def BDZLm : BForm_1<16, 26, 0, 1, (outs), (ins condbrtarget:$dst),
1384 def BDNZLm: BForm_1<16, 24, 0, 1, (outs), (ins condbrtarget:$dst),
1386 def BDZLAm : BForm_1<16, 26, 1, 1, (outs), (ins abscondbrtarget:$dst),
1388 def BDNZLAm: BForm_1<16, 24, 1, 1, (outs), (ins abscondbrtarget:$dst),
1391 let Defs = [CTR], Uses = [CTR, LR, RM] in {
1392 def BDZLRL : XLForm_2_ext<19, 16, 18, 0, 1, (outs), (ins),
1393 "bdzlrl", IIC_BrB, []>;
1394 def BDNZLRL : XLForm_2_ext<19, 16, 16, 0, 1, (outs), (ins),
1395 "bdnzlrl", IIC_BrB, []>;
1396 def BDZLRLp : XLForm_2_ext<19, 16, 27, 0, 1, (outs), (ins),
1397 "bdzlrl+", IIC_BrB, []>;
1398 def BDNZLRLp: XLForm_2_ext<19, 16, 25, 0, 1, (outs), (ins),
1399 "bdnzlrl+", IIC_BrB, []>;
1400 def BDZLRLm : XLForm_2_ext<19, 16, 26, 0, 1, (outs), (ins),
1401 "bdzlrl-", IIC_BrB, []>;
1402 def BDNZLRLm: XLForm_2_ext<19, 16, 24, 0, 1, (outs), (ins),
1403 "bdnzlrl-", IIC_BrB, []>;
1407 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
1408 def TCRETURNdi :Pseudo< (outs),
1409 (ins calltarget:$dst, i32imm:$offset),
1410 "#TC_RETURNd $dst $offset",
1414 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
1415 def TCRETURNai :Pseudo<(outs), (ins abscalltarget:$func, i32imm:$offset),
1416 "#TC_RETURNa $func $offset",
1417 [(PPCtc_return (i32 imm:$func), imm:$offset)]>;
1419 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
1420 def TCRETURNri : Pseudo<(outs), (ins CTRRC:$dst, i32imm:$offset),
1421 "#TC_RETURNr $dst $offset",
1425 let isCodeGenOnly = 1 in {
1427 let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, isBranch = 1,
1428 isIndirectBranch = 1, isCall = 1, isReturn = 1, Uses = [CTR, RM] in
1429 def TAILBCTR : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
1430 []>, Requires<[In32BitMode]>;
1432 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
1433 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
1434 def TAILB : IForm<18, 0, 0, (outs), (ins calltarget:$dst),
1438 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
1439 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
1440 def TAILBA : IForm<18, 0, 0, (outs), (ins abscalltarget:$dst),
1446 let hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
1448 def EH_SjLj_SetJmp32 : Pseudo<(outs gprc:$dst), (ins memr:$buf),
1449 "#EH_SJLJ_SETJMP32",
1450 [(set i32:$dst, (PPCeh_sjlj_setjmp addr:$buf))]>,
1451 Requires<[In32BitMode]>;
1452 let isTerminator = 1 in
1453 def EH_SjLj_LongJmp32 : Pseudo<(outs), (ins memr:$buf),
1454 "#EH_SJLJ_LONGJMP32",
1455 [(PPCeh_sjlj_longjmp addr:$buf)]>,
1456 Requires<[In32BitMode]>;
1459 // This pseudo is never removed from the function, as it serves as
1460 // a terminator. Size is set to 0 to prevent the builtin assembler
1461 // from emitting it.
1462 let isBranch = 1, isTerminator = 1, Size = 0 in {
1463 def EH_SjLj_Setup : Pseudo<(outs), (ins directbrtarget:$dst),
1464 "#EH_SjLj_Setup\t$dst", []>;
1468 let PPC970_Unit = 7 in {
1469 def SC : SCForm<17, 1, (outs), (ins i32imm:$lev),
1470 "sc $lev", IIC_BrB, [(PPCsc (i32 imm:$lev))]>;
1473 // Branch history rolling buffer.
1474 def CLRBHRB : XForm_0<31, 430, (outs), (ins), "clrbhrb", IIC_BrB,
1476 PPC970_DGroup_Single;
1477 // The $dmy argument used for MFBHRBE is not needed; however, including
1478 // it avoids automatic generation of PPCFastISel::fastEmit_i(), which
1479 // interferes with necessary special handling (see PPCFastISel.cpp).
1480 def MFBHRBE : XFXForm_3p<31, 302, (outs gprc:$rD),
1481 (ins u10imm:$imm, u10imm:$dmy),
1482 "mfbhrbe $rD, $imm", IIC_BrB,
1484 (PPCmfbhrbe imm:$imm, imm:$dmy))]>,
1485 PPC970_DGroup_First;
1487 def RFEBB : XLForm_S<19, 146, (outs), (ins u1imm:$imm), "rfebb $imm",
1488 IIC_BrB, [(PPCrfebb (i32 imm:$imm))]>,
1489 PPC970_DGroup_Single;
1491 // DCB* instructions.
1492 def DCBA : DCB_Form<758, 0, (outs), (ins memrr:$dst), "dcba $dst",
1493 IIC_LdStDCBF, [(int_ppc_dcba xoaddr:$dst)]>,
1494 PPC970_DGroup_Single;
1495 def DCBI : DCB_Form<470, 0, (outs), (ins memrr:$dst), "dcbi $dst",
1496 IIC_LdStDCBF, [(int_ppc_dcbi xoaddr:$dst)]>,
1497 PPC970_DGroup_Single;
1498 def DCBST : DCB_Form<54, 0, (outs), (ins memrr:$dst), "dcbst $dst",
1499 IIC_LdStDCBF, [(int_ppc_dcbst xoaddr:$dst)]>,
1500 PPC970_DGroup_Single;
1501 def DCBZ : DCB_Form<1014, 0, (outs), (ins memrr:$dst), "dcbz $dst",
1502 IIC_LdStDCBF, [(int_ppc_dcbz xoaddr:$dst)]>,
1503 PPC970_DGroup_Single;
1504 def DCBZL : DCB_Form<1014, 1, (outs), (ins memrr:$dst), "dcbzl $dst",
1505 IIC_LdStDCBF, [(int_ppc_dcbzl xoaddr:$dst)]>,
1506 PPC970_DGroup_Single;
1508 def DCBF : DCB_Form_hint<86, (outs), (ins u5imm:$TH, memrr:$dst),
1509 "dcbf $dst, $TH", IIC_LdStDCBF, []>,
1510 PPC970_DGroup_Single;
1512 let hasSideEffects = 0, mayLoad = 1, mayStore = 1 in {
1513 def DCBT : DCB_Form_hint<278, (outs), (ins u5imm:$TH, memrr:$dst),
1514 "dcbt $dst, $TH", IIC_LdStDCBF, []>,
1515 PPC970_DGroup_Single;
1516 def DCBTST : DCB_Form_hint<246, (outs), (ins u5imm:$TH, memrr:$dst),
1517 "dcbtst $dst, $TH", IIC_LdStDCBF, []>,
1518 PPC970_DGroup_Single;
1519 } // hasSideEffects = 0
1521 def ICBLC : XForm_icbt<31, 230, (outs), (ins u4imm:$CT, memrr:$src),
1522 "icblc $CT, $src", IIC_LdStStore>, Requires<[HasICBT]>;
1523 def ICBLQ : XForm_icbt<31, 198, (outs), (ins u4imm:$CT, memrr:$src),
1524 "icblq. $CT, $src", IIC_LdStLoad>, Requires<[HasICBT]>;
1525 def ICBT : XForm_icbt<31, 22, (outs), (ins u4imm:$CT, memrr:$src),
1526 "icbt $CT, $src", IIC_LdStLoad>, Requires<[HasICBT]>;
1527 def ICBTLS : XForm_icbt<31, 486, (outs), (ins u4imm:$CT, memrr:$src),
1528 "icbtls $CT, $src", IIC_LdStLoad>, Requires<[HasICBT]>;
1530 def : Pat<(int_ppc_dcbt xoaddr:$dst),
1531 (DCBT 0, xoaddr:$dst)>;
1532 def : Pat<(int_ppc_dcbtst xoaddr:$dst),
1533 (DCBTST 0, xoaddr:$dst)>;
1534 def : Pat<(int_ppc_dcbf xoaddr:$dst),
1535 (DCBF 0, xoaddr:$dst)>;
1537 def : Pat<(prefetch xoaddr:$dst, (i32 0), imm, (i32 1)),
1538 (DCBT 0, xoaddr:$dst)>; // data prefetch for loads
1539 def : Pat<(prefetch xoaddr:$dst, (i32 1), imm, (i32 1)),
1540 (DCBTST 0, xoaddr:$dst)>; // data prefetch for stores
1541 def : Pat<(prefetch xoaddr:$dst, (i32 0), imm, (i32 0)),
1542 (ICBT 0, xoaddr:$dst)>, Requires<[HasICBT]>; // inst prefetch (for read)
1544 // Atomic operations
1545 let usesCustomInserter = 1 in {
1546 let Defs = [CR0] in {
1547 def ATOMIC_LOAD_ADD_I8 : Pseudo<
1548 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I8",
1549 [(set i32:$dst, (atomic_load_add_8 xoaddr:$ptr, i32:$incr))]>;
1550 def ATOMIC_LOAD_SUB_I8 : Pseudo<
1551 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I8",
1552 [(set i32:$dst, (atomic_load_sub_8 xoaddr:$ptr, i32:$incr))]>;
1553 def ATOMIC_LOAD_AND_I8 : Pseudo<
1554 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I8",
1555 [(set i32:$dst, (atomic_load_and_8 xoaddr:$ptr, i32:$incr))]>;
1556 def ATOMIC_LOAD_OR_I8 : Pseudo<
1557 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I8",
1558 [(set i32:$dst, (atomic_load_or_8 xoaddr:$ptr, i32:$incr))]>;
1559 def ATOMIC_LOAD_XOR_I8 : Pseudo<
1560 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "ATOMIC_LOAD_XOR_I8",
1561 [(set i32:$dst, (atomic_load_xor_8 xoaddr:$ptr, i32:$incr))]>;
1562 def ATOMIC_LOAD_NAND_I8 : Pseudo<
1563 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I8",
1564 [(set i32:$dst, (atomic_load_nand_8 xoaddr:$ptr, i32:$incr))]>;
1565 def ATOMIC_LOAD_MIN_I8 : Pseudo<
1566 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MIN_I8",
1567 [(set i32:$dst, (atomic_load_min_8 xoaddr:$ptr, i32:$incr))]>;
1568 def ATOMIC_LOAD_MAX_I8 : Pseudo<
1569 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MAX_I8",
1570 [(set i32:$dst, (atomic_load_max_8 xoaddr:$ptr, i32:$incr))]>;
1571 def ATOMIC_LOAD_UMIN_I8 : Pseudo<
1572 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMIN_I8",
1573 [(set i32:$dst, (atomic_load_umin_8 xoaddr:$ptr, i32:$incr))]>;
1574 def ATOMIC_LOAD_UMAX_I8 : Pseudo<
1575 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMAX_I8",
1576 [(set i32:$dst, (atomic_load_umax_8 xoaddr:$ptr, i32:$incr))]>;
1577 def ATOMIC_LOAD_ADD_I16 : Pseudo<
1578 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I16",
1579 [(set i32:$dst, (atomic_load_add_16 xoaddr:$ptr, i32:$incr))]>;
1580 def ATOMIC_LOAD_SUB_I16 : Pseudo<
1581 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I16",
1582 [(set i32:$dst, (atomic_load_sub_16 xoaddr:$ptr, i32:$incr))]>;
1583 def ATOMIC_LOAD_AND_I16 : Pseudo<
1584 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I16",
1585 [(set i32:$dst, (atomic_load_and_16 xoaddr:$ptr, i32:$incr))]>;
1586 def ATOMIC_LOAD_OR_I16 : Pseudo<
1587 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I16",
1588 [(set i32:$dst, (atomic_load_or_16 xoaddr:$ptr, i32:$incr))]>;
1589 def ATOMIC_LOAD_XOR_I16 : Pseudo<
1590 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_XOR_I16",
1591 [(set i32:$dst, (atomic_load_xor_16 xoaddr:$ptr, i32:$incr))]>;
1592 def ATOMIC_LOAD_NAND_I16 : Pseudo<
1593 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I16",
1594 [(set i32:$dst, (atomic_load_nand_16 xoaddr:$ptr, i32:$incr))]>;
1595 def ATOMIC_LOAD_MIN_I16 : Pseudo<
1596 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MIN_I16",
1597 [(set i32:$dst, (atomic_load_min_16 xoaddr:$ptr, i32:$incr))]>;
1598 def ATOMIC_LOAD_MAX_I16 : Pseudo<
1599 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MAX_I16",
1600 [(set i32:$dst, (atomic_load_max_16 xoaddr:$ptr, i32:$incr))]>;
1601 def ATOMIC_LOAD_UMIN_I16 : Pseudo<
1602 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMIN_I16",
1603 [(set i32:$dst, (atomic_load_umin_16 xoaddr:$ptr, i32:$incr))]>;
1604 def ATOMIC_LOAD_UMAX_I16 : Pseudo<
1605 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMAX_I16",
1606 [(set i32:$dst, (atomic_load_umax_16 xoaddr:$ptr, i32:$incr))]>;
1607 def ATOMIC_LOAD_ADD_I32 : Pseudo<
1608 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I32",
1609 [(set i32:$dst, (atomic_load_add_32 xoaddr:$ptr, i32:$incr))]>;
1610 def ATOMIC_LOAD_SUB_I32 : Pseudo<
1611 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I32",
1612 [(set i32:$dst, (atomic_load_sub_32 xoaddr:$ptr, i32:$incr))]>;
1613 def ATOMIC_LOAD_AND_I32 : Pseudo<
1614 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I32",
1615 [(set i32:$dst, (atomic_load_and_32 xoaddr:$ptr, i32:$incr))]>;
1616 def ATOMIC_LOAD_OR_I32 : Pseudo<
1617 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I32",
1618 [(set i32:$dst, (atomic_load_or_32 xoaddr:$ptr, i32:$incr))]>;
1619 def ATOMIC_LOAD_XOR_I32 : Pseudo<
1620 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_XOR_I32",
1621 [(set i32:$dst, (atomic_load_xor_32 xoaddr:$ptr, i32:$incr))]>;
1622 def ATOMIC_LOAD_NAND_I32 : Pseudo<
1623 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I32",
1624 [(set i32:$dst, (atomic_load_nand_32 xoaddr:$ptr, i32:$incr))]>;
1625 def ATOMIC_LOAD_MIN_I32 : Pseudo<
1626 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MIN_I32",
1627 [(set i32:$dst, (atomic_load_min_32 xoaddr:$ptr, i32:$incr))]>;
1628 def ATOMIC_LOAD_MAX_I32 : Pseudo<
1629 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MAX_I32",
1630 [(set i32:$dst, (atomic_load_max_32 xoaddr:$ptr, i32:$incr))]>;
1631 def ATOMIC_LOAD_UMIN_I32 : Pseudo<
1632 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMIN_I32",
1633 [(set i32:$dst, (atomic_load_umin_32 xoaddr:$ptr, i32:$incr))]>;
1634 def ATOMIC_LOAD_UMAX_I32 : Pseudo<
1635 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMAX_I32",
1636 [(set i32:$dst, (atomic_load_umax_32 xoaddr:$ptr, i32:$incr))]>;
1638 def ATOMIC_CMP_SWAP_I8 : Pseudo<
1639 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I8",
1640 [(set i32:$dst, (atomic_cmp_swap_8 xoaddr:$ptr, i32:$old, i32:$new))]>;
1641 def ATOMIC_CMP_SWAP_I16 : Pseudo<
1642 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I16 $dst $ptr $old $new",
1643 [(set i32:$dst, (atomic_cmp_swap_16 xoaddr:$ptr, i32:$old, i32:$new))]>;
1644 def ATOMIC_CMP_SWAP_I32 : Pseudo<
1645 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I32 $dst $ptr $old $new",
1646 [(set i32:$dst, (atomic_cmp_swap_32 xoaddr:$ptr, i32:$old, i32:$new))]>;
1648 def ATOMIC_SWAP_I8 : Pseudo<
1649 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_i8",
1650 [(set i32:$dst, (atomic_swap_8 xoaddr:$ptr, i32:$new))]>;
1651 def ATOMIC_SWAP_I16 : Pseudo<
1652 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_I16",
1653 [(set i32:$dst, (atomic_swap_16 xoaddr:$ptr, i32:$new))]>;
1654 def ATOMIC_SWAP_I32 : Pseudo<
1655 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_I32",
1656 [(set i32:$dst, (atomic_swap_32 xoaddr:$ptr, i32:$new))]>;
1660 // Instructions to support atomic operations
1661 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in {
1662 def LBARX : XForm_1<31, 52, (outs gprc:$rD), (ins memrr:$src),
1663 "lbarx $rD, $src", IIC_LdStLWARX, []>,
1664 Requires<[HasPartwordAtomics]>;
1666 def LHARX : XForm_1<31, 116, (outs gprc:$rD), (ins memrr:$src),
1667 "lharx $rD, $src", IIC_LdStLWARX, []>,
1668 Requires<[HasPartwordAtomics]>;
1670 def LWARX : XForm_1<31, 20, (outs gprc:$rD), (ins memrr:$src),
1671 "lwarx $rD, $src", IIC_LdStLWARX, []>;
1673 // Instructions to support lock versions of atomics
1674 // (EH=1 - see Power ISA 2.07 Book II 4.4.2)
1675 def LBARXL : XForm_1<31, 52, (outs gprc:$rD), (ins memrr:$src),
1676 "lbarx $rD, $src, 1", IIC_LdStLWARX, []>, isDOT,
1677 Requires<[HasPartwordAtomics]>;
1679 def LHARXL : XForm_1<31, 116, (outs gprc:$rD), (ins memrr:$src),
1680 "lharx $rD, $src, 1", IIC_LdStLWARX, []>, isDOT,
1681 Requires<[HasPartwordAtomics]>;
1683 def LWARXL : XForm_1<31, 20, (outs gprc:$rD), (ins memrr:$src),
1684 "lwarx $rD, $src, 1", IIC_LdStLWARX, []>, isDOT;
1686 // The atomic instructions use the destination register as well as the next one
1687 // or two registers in order (modulo 31).
1688 let hasExtraSrcRegAllocReq = 1 in
1689 def LWAT : X_RD5_RS5_IM5<31, 582, (outs gprc:$rD), (ins gprc:$rA, u5imm:$FC),
1690 "lwat $rD, $rA, $FC", IIC_LdStLoad>,
1691 Requires<[IsISA3_0]>;
1694 let Defs = [CR0], mayStore = 1, mayLoad = 0, hasSideEffects = 0 in {
1695 def STBCX : XForm_1<31, 694, (outs), (ins gprc:$rS, memrr:$dst),
1696 "stbcx. $rS, $dst", IIC_LdStSTWCX, []>,
1697 isDOT, Requires<[HasPartwordAtomics]>;
1699 def STHCX : XForm_1<31, 726, (outs), (ins gprc:$rS, memrr:$dst),
1700 "sthcx. $rS, $dst", IIC_LdStSTWCX, []>,
1701 isDOT, Requires<[HasPartwordAtomics]>;
1703 def STWCX : XForm_1<31, 150, (outs), (ins gprc:$rS, memrr:$dst),
1704 "stwcx. $rS, $dst", IIC_LdStSTWCX, []>, isDOT;
1707 let mayStore = 1, mayLoad = 0, hasSideEffects = 0 in
1708 def STWAT : X_RD5_RS5_IM5<31, 710, (outs), (ins gprc:$rS, gprc:$rA, u5imm:$FC),
1709 "stwat $rS, $rA, $FC", IIC_LdStStore>,
1710 Requires<[IsISA3_0]>;
1712 let isTerminator = 1, isBarrier = 1, hasCtrlDep = 1 in
1713 def TRAP : XForm_24<31, 4, (outs), (ins), "trap", IIC_LdStLoad, [(trap)]>;
1715 def TWI : DForm_base<3, (outs), (ins u5imm:$to, gprc:$rA, s16imm:$imm),
1716 "twi $to, $rA, $imm", IIC_IntTrapW, []>;
1717 def TW : XForm_1<31, 4, (outs), (ins u5imm:$to, gprc:$rA, gprc:$rB),
1718 "tw $to, $rA, $rB", IIC_IntTrapW, []>;
1719 def TDI : DForm_base<2, (outs), (ins u5imm:$to, g8rc:$rA, s16imm:$imm),
1720 "tdi $to, $rA, $imm", IIC_IntTrapD, []>;
1721 def TD : XForm_1<31, 68, (outs), (ins u5imm:$to, g8rc:$rA, g8rc:$rB),
1722 "td $to, $rA, $rB", IIC_IntTrapD, []>;
1724 //===----------------------------------------------------------------------===//
1725 // PPC32 Load Instructions.
1728 // Unindexed (r+i) Loads.
1729 let PPC970_Unit = 2 in {
1730 def LBZ : DForm_1<34, (outs gprc:$rD), (ins memri:$src),
1731 "lbz $rD, $src", IIC_LdStLoad,
1732 [(set i32:$rD, (zextloadi8 iaddr:$src))]>;
1733 def LHA : DForm_1<42, (outs gprc:$rD), (ins memri:$src),
1734 "lha $rD, $src", IIC_LdStLHA,
1735 [(set i32:$rD, (sextloadi16 iaddr:$src))]>,
1736 PPC970_DGroup_Cracked;
1737 def LHZ : DForm_1<40, (outs gprc:$rD), (ins memri:$src),
1738 "lhz $rD, $src", IIC_LdStLoad,
1739 [(set i32:$rD, (zextloadi16 iaddr:$src))]>;
1740 def LWZ : DForm_1<32, (outs gprc:$rD), (ins memri:$src),
1741 "lwz $rD, $src", IIC_LdStLoad,
1742 [(set i32:$rD, (load iaddr:$src))]>;
1744 def LFS : DForm_1<48, (outs f4rc:$rD), (ins memri:$src),
1745 "lfs $rD, $src", IIC_LdStLFD,
1746 [(set f32:$rD, (load iaddr:$src))]>;
1747 def LFD : DForm_1<50, (outs f8rc:$rD), (ins memri:$src),
1748 "lfd $rD, $src", IIC_LdStLFD,
1749 [(set f64:$rD, (load iaddr:$src))]>;
1752 // Unindexed (r+i) Loads with Update (preinc).
1753 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in {
1754 def LBZU : DForm_1<35, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1755 "lbzu $rD, $addr", IIC_LdStLoadUpd,
1756 []>, RegConstraint<"$addr.reg = $ea_result">,
1757 NoEncode<"$ea_result">;
1759 def LHAU : DForm_1<43, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1760 "lhau $rD, $addr", IIC_LdStLHAU,
1761 []>, RegConstraint<"$addr.reg = $ea_result">,
1762 NoEncode<"$ea_result">;
1764 def LHZU : DForm_1<41, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1765 "lhzu $rD, $addr", IIC_LdStLoadUpd,
1766 []>, RegConstraint<"$addr.reg = $ea_result">,
1767 NoEncode<"$ea_result">;
1769 def LWZU : DForm_1<33, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1770 "lwzu $rD, $addr", IIC_LdStLoadUpd,
1771 []>, RegConstraint<"$addr.reg = $ea_result">,
1772 NoEncode<"$ea_result">;
1774 def LFSU : DForm_1<49, (outs f4rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1775 "lfsu $rD, $addr", IIC_LdStLFDU,
1776 []>, RegConstraint<"$addr.reg = $ea_result">,
1777 NoEncode<"$ea_result">;
1779 def LFDU : DForm_1<51, (outs f8rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1780 "lfdu $rD, $addr", IIC_LdStLFDU,
1781 []>, RegConstraint<"$addr.reg = $ea_result">,
1782 NoEncode<"$ea_result">;
1785 // Indexed (r+r) Loads with Update (preinc).
1786 def LBZUX : XForm_1<31, 119, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1788 "lbzux $rD, $addr", IIC_LdStLoadUpdX,
1789 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1790 NoEncode<"$ea_result">;
1792 def LHAUX : XForm_1<31, 375, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1794 "lhaux $rD, $addr", IIC_LdStLHAUX,
1795 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1796 NoEncode<"$ea_result">;
1798 def LHZUX : XForm_1<31, 311, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1800 "lhzux $rD, $addr", IIC_LdStLoadUpdX,
1801 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1802 NoEncode<"$ea_result">;
1804 def LWZUX : XForm_1<31, 55, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1806 "lwzux $rD, $addr", IIC_LdStLoadUpdX,
1807 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1808 NoEncode<"$ea_result">;
1810 def LFSUX : XForm_1<31, 567, (outs f4rc:$rD, ptr_rc_nor0:$ea_result),
1812 "lfsux $rD, $addr", IIC_LdStLFDUX,
1813 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1814 NoEncode<"$ea_result">;
1816 def LFDUX : XForm_1<31, 631, (outs f8rc:$rD, ptr_rc_nor0:$ea_result),
1818 "lfdux $rD, $addr", IIC_LdStLFDUX,
1819 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1820 NoEncode<"$ea_result">;
1824 // Indexed (r+r) Loads.
1826 let PPC970_Unit = 2, mayLoad = 1, mayStore = 0 in {
1827 def LBZX : XForm_1<31, 87, (outs gprc:$rD), (ins memrr:$src),
1828 "lbzx $rD, $src", IIC_LdStLoad,
1829 [(set i32:$rD, (zextloadi8 xaddr:$src))]>;
1830 def LHAX : XForm_1<31, 343, (outs gprc:$rD), (ins memrr:$src),
1831 "lhax $rD, $src", IIC_LdStLHA,
1832 [(set i32:$rD, (sextloadi16 xaddr:$src))]>,
1833 PPC970_DGroup_Cracked;
1834 def LHZX : XForm_1<31, 279, (outs gprc:$rD), (ins memrr:$src),
1835 "lhzx $rD, $src", IIC_LdStLoad,
1836 [(set i32:$rD, (zextloadi16 xaddr:$src))]>;
1837 def LWZX : XForm_1<31, 23, (outs gprc:$rD), (ins memrr:$src),
1838 "lwzx $rD, $src", IIC_LdStLoad,
1839 [(set i32:$rD, (load xaddr:$src))]>;
1840 def LHBRX : XForm_1<31, 790, (outs gprc:$rD), (ins memrr:$src),
1841 "lhbrx $rD, $src", IIC_LdStLoad,
1842 [(set i32:$rD, (PPClbrx xoaddr:$src, i16))]>;
1843 def LWBRX : XForm_1<31, 534, (outs gprc:$rD), (ins memrr:$src),
1844 "lwbrx $rD, $src", IIC_LdStLoad,
1845 [(set i32:$rD, (PPClbrx xoaddr:$src, i32))]>;
1847 def LFSX : XForm_25<31, 535, (outs f4rc:$frD), (ins memrr:$src),
1848 "lfsx $frD, $src", IIC_LdStLFD,
1849 [(set f32:$frD, (load xaddr:$src))]>;
1850 def LFDX : XForm_25<31, 599, (outs f8rc:$frD), (ins memrr:$src),
1851 "lfdx $frD, $src", IIC_LdStLFD,
1852 [(set f64:$frD, (load xaddr:$src))]>;
1854 def LFIWAX : XForm_25<31, 855, (outs f8rc:$frD), (ins memrr:$src),
1855 "lfiwax $frD, $src", IIC_LdStLFD,
1856 [(set f64:$frD, (PPClfiwax xoaddr:$src))]>;
1857 def LFIWZX : XForm_25<31, 887, (outs f8rc:$frD), (ins memrr:$src),
1858 "lfiwzx $frD, $src", IIC_LdStLFD,
1859 [(set f64:$frD, (PPClfiwzx xoaddr:$src))]>;
1863 def LMW : DForm_1<46, (outs gprc:$rD), (ins memri:$src),
1864 "lmw $rD, $src", IIC_LdStLMW, []>;
1866 //===----------------------------------------------------------------------===//
1867 // PPC32 Store Instructions.
1870 // Unindexed (r+i) Stores.
1871 let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in {
1872 def STB : DForm_1<38, (outs), (ins gprc:$rS, memri:$src),
1873 "stb $rS, $src", IIC_LdStStore,
1874 [(truncstorei8 i32:$rS, iaddr:$src)]>;
1875 def STH : DForm_1<44, (outs), (ins gprc:$rS, memri:$src),
1876 "sth $rS, $src", IIC_LdStStore,
1877 [(truncstorei16 i32:$rS, iaddr:$src)]>;
1878 def STW : DForm_1<36, (outs), (ins gprc:$rS, memri:$src),
1879 "stw $rS, $src", IIC_LdStStore,
1880 [(store i32:$rS, iaddr:$src)]>;
1881 def STFS : DForm_1<52, (outs), (ins f4rc:$rS, memri:$dst),
1882 "stfs $rS, $dst", IIC_LdStSTFD,
1883 [(store f32:$rS, iaddr:$dst)]>;
1884 def STFD : DForm_1<54, (outs), (ins f8rc:$rS, memri:$dst),
1885 "stfd $rS, $dst", IIC_LdStSTFD,
1886 [(store f64:$rS, iaddr:$dst)]>;
1889 // Unindexed (r+i) Stores with Update (preinc).
1890 let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in {
1891 def STBU : DForm_1<39, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst),
1892 "stbu $rS, $dst", IIC_LdStStoreUpd, []>,
1893 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
1894 def STHU : DForm_1<45, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst),
1895 "sthu $rS, $dst", IIC_LdStStoreUpd, []>,
1896 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
1897 def STWU : DForm_1<37, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst),
1898 "stwu $rS, $dst", IIC_LdStStoreUpd, []>,
1899 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
1900 def STFSU : DForm_1<53, (outs ptr_rc_nor0:$ea_res), (ins f4rc:$rS, memri:$dst),
1901 "stfsu $rS, $dst", IIC_LdStSTFDU, []>,
1902 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
1903 def STFDU : DForm_1<55, (outs ptr_rc_nor0:$ea_res), (ins f8rc:$rS, memri:$dst),
1904 "stfdu $rS, $dst", IIC_LdStSTFDU, []>,
1905 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
1908 // Patterns to match the pre-inc stores. We can't put the patterns on
1909 // the instruction definitions directly as ISel wants the address base
1910 // and offset to be separate operands, not a single complex operand.
1911 def : Pat<(pre_truncsti8 i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1912 (STBU $rS, iaddroff:$ptroff, $ptrreg)>;
1913 def : Pat<(pre_truncsti16 i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1914 (STHU $rS, iaddroff:$ptroff, $ptrreg)>;
1915 def : Pat<(pre_store i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1916 (STWU $rS, iaddroff:$ptroff, $ptrreg)>;
1917 def : Pat<(pre_store f32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1918 (STFSU $rS, iaddroff:$ptroff, $ptrreg)>;
1919 def : Pat<(pre_store f64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1920 (STFDU $rS, iaddroff:$ptroff, $ptrreg)>;
1922 // Indexed (r+r) Stores.
1923 let PPC970_Unit = 2 in {
1924 def STBX : XForm_8<31, 215, (outs), (ins gprc:$rS, memrr:$dst),
1925 "stbx $rS, $dst", IIC_LdStStore,
1926 [(truncstorei8 i32:$rS, xaddr:$dst)]>,
1927 PPC970_DGroup_Cracked;
1928 def STHX : XForm_8<31, 407, (outs), (ins gprc:$rS, memrr:$dst),
1929 "sthx $rS, $dst", IIC_LdStStore,
1930 [(truncstorei16 i32:$rS, xaddr:$dst)]>,
1931 PPC970_DGroup_Cracked;
1932 def STWX : XForm_8<31, 151, (outs), (ins gprc:$rS, memrr:$dst),
1933 "stwx $rS, $dst", IIC_LdStStore,
1934 [(store i32:$rS, xaddr:$dst)]>,
1935 PPC970_DGroup_Cracked;
1937 def STHBRX: XForm_8<31, 918, (outs), (ins gprc:$rS, memrr:$dst),
1938 "sthbrx $rS, $dst", IIC_LdStStore,
1939 [(PPCstbrx i32:$rS, xoaddr:$dst, i16)]>,
1940 PPC970_DGroup_Cracked;
1941 def STWBRX: XForm_8<31, 662, (outs), (ins gprc:$rS, memrr:$dst),
1942 "stwbrx $rS, $dst", IIC_LdStStore,
1943 [(PPCstbrx i32:$rS, xoaddr:$dst, i32)]>,
1944 PPC970_DGroup_Cracked;
1946 def STFIWX: XForm_28<31, 983, (outs), (ins f8rc:$frS, memrr:$dst),
1947 "stfiwx $frS, $dst", IIC_LdStSTFD,
1948 [(PPCstfiwx f64:$frS, xoaddr:$dst)]>;
1950 def STFSX : XForm_28<31, 663, (outs), (ins f4rc:$frS, memrr:$dst),
1951 "stfsx $frS, $dst", IIC_LdStSTFD,
1952 [(store f32:$frS, xaddr:$dst)]>;
1953 def STFDX : XForm_28<31, 727, (outs), (ins f8rc:$frS, memrr:$dst),
1954 "stfdx $frS, $dst", IIC_LdStSTFD,
1955 [(store f64:$frS, xaddr:$dst)]>;
1958 // Indexed (r+r) Stores with Update (preinc).
1959 let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in {
1960 def STBUX : XForm_8<31, 247, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memrr:$dst),
1961 "stbux $rS, $dst", IIC_LdStStoreUpd, []>,
1962 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
1963 PPC970_DGroup_Cracked;
1964 def STHUX : XForm_8<31, 439, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memrr:$dst),
1965 "sthux $rS, $dst", IIC_LdStStoreUpd, []>,
1966 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
1967 PPC970_DGroup_Cracked;
1968 def STWUX : XForm_8<31, 183, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memrr:$dst),
1969 "stwux $rS, $dst", IIC_LdStStoreUpd, []>,
1970 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
1971 PPC970_DGroup_Cracked;
1972 def STFSUX: XForm_8<31, 695, (outs ptr_rc_nor0:$ea_res), (ins f4rc:$rS, memrr:$dst),
1973 "stfsux $rS, $dst", IIC_LdStSTFDU, []>,
1974 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
1975 PPC970_DGroup_Cracked;
1976 def STFDUX: XForm_8<31, 759, (outs ptr_rc_nor0:$ea_res), (ins f8rc:$rS, memrr:$dst),
1977 "stfdux $rS, $dst", IIC_LdStSTFDU, []>,
1978 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
1979 PPC970_DGroup_Cracked;
1982 // Patterns to match the pre-inc stores. We can't put the patterns on
1983 // the instruction definitions directly as ISel wants the address base
1984 // and offset to be separate operands, not a single complex operand.
1985 def : Pat<(pre_truncsti8 i32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1986 (STBUX $rS, $ptrreg, $ptroff)>;
1987 def : Pat<(pre_truncsti16 i32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1988 (STHUX $rS, $ptrreg, $ptroff)>;
1989 def : Pat<(pre_store i32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1990 (STWUX $rS, $ptrreg, $ptroff)>;
1991 def : Pat<(pre_store f32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1992 (STFSUX $rS, $ptrreg, $ptroff)>;
1993 def : Pat<(pre_store f64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1994 (STFDUX $rS, $ptrreg, $ptroff)>;
1997 def STMW : DForm_1<47, (outs), (ins gprc:$rS, memri:$dst),
1998 "stmw $rS, $dst", IIC_LdStLMW, []>;
2000 def SYNC : XForm_24_sync<31, 598, (outs), (ins i32imm:$L),
2001 "sync $L", IIC_LdStSync, []>;
2003 let isCodeGenOnly = 1 in {
2004 def MSYNC : XForm_24_sync<31, 598, (outs), (ins),
2005 "msync", IIC_LdStSync, []> {
2010 def : Pat<(int_ppc_sync), (SYNC 0)>, Requires<[HasSYNC]>;
2011 def : Pat<(int_ppc_lwsync), (SYNC 1)>, Requires<[HasSYNC]>;
2012 def : Pat<(int_ppc_sync), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
2013 def : Pat<(int_ppc_lwsync), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
2015 //===----------------------------------------------------------------------===//
2016 // PPC32 Arithmetic Instructions.
2019 let PPC970_Unit = 1 in { // FXU Operations.
2020 def ADDI : DForm_2<14, (outs gprc:$rD), (ins gprc_nor0:$rA, s16imm:$imm),
2021 "addi $rD, $rA, $imm", IIC_IntSimple,
2022 [(set i32:$rD, (add i32:$rA, imm32SExt16:$imm))]>;
2023 let BaseName = "addic" in {
2024 let Defs = [CARRY] in
2025 def ADDIC : DForm_2<12, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
2026 "addic $rD, $rA, $imm", IIC_IntGeneral,
2027 [(set i32:$rD, (addc i32:$rA, imm32SExt16:$imm))]>,
2028 RecFormRel, PPC970_DGroup_Cracked;
2029 let Defs = [CARRY, CR0] in
2030 def ADDICo : DForm_2<13, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
2031 "addic. $rD, $rA, $imm", IIC_IntGeneral,
2032 []>, isDOT, RecFormRel;
2034 def ADDIS : DForm_2<15, (outs gprc:$rD), (ins gprc_nor0:$rA, s17imm:$imm),
2035 "addis $rD, $rA, $imm", IIC_IntSimple,
2036 [(set i32:$rD, (add i32:$rA, imm16ShiftedSExt:$imm))]>;
2037 let isCodeGenOnly = 1 in
2038 def LA : DForm_2<14, (outs gprc:$rD), (ins gprc_nor0:$rA, s16imm:$sym),
2039 "la $rD, $sym($rA)", IIC_IntGeneral,
2040 [(set i32:$rD, (add i32:$rA,
2041 (PPClo tglobaladdr:$sym, 0)))]>;
2042 def MULLI : DForm_2< 7, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
2043 "mulli $rD, $rA, $imm", IIC_IntMulLI,
2044 [(set i32:$rD, (mul i32:$rA, imm32SExt16:$imm))]>;
2045 let Defs = [CARRY] in
2046 def SUBFIC : DForm_2< 8, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
2047 "subfic $rD, $rA, $imm", IIC_IntGeneral,
2048 [(set i32:$rD, (subc imm32SExt16:$imm, i32:$rA))]>;
2050 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in {
2051 def LI : DForm_2_r0<14, (outs gprc:$rD), (ins s16imm:$imm),
2052 "li $rD, $imm", IIC_IntSimple,
2053 [(set i32:$rD, imm32SExt16:$imm)]>;
2054 def LIS : DForm_2_r0<15, (outs gprc:$rD), (ins s17imm:$imm),
2055 "lis $rD, $imm", IIC_IntSimple,
2056 [(set i32:$rD, imm16ShiftedSExt:$imm)]>;
2060 let PPC970_Unit = 1 in { // FXU Operations.
2061 let Defs = [CR0] in {
2062 def ANDIo : DForm_4<28, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2063 "andi. $dst, $src1, $src2", IIC_IntGeneral,
2064 [(set i32:$dst, (and i32:$src1, immZExt16:$src2))]>,
2066 def ANDISo : DForm_4<29, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2067 "andis. $dst, $src1, $src2", IIC_IntGeneral,
2068 [(set i32:$dst, (and i32:$src1, imm16ShiftedZExt:$src2))]>,
2071 def ORI : DForm_4<24, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2072 "ori $dst, $src1, $src2", IIC_IntSimple,
2073 [(set i32:$dst, (or i32:$src1, immZExt16:$src2))]>;
2074 def ORIS : DForm_4<25, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2075 "oris $dst, $src1, $src2", IIC_IntSimple,
2076 [(set i32:$dst, (or i32:$src1, imm16ShiftedZExt:$src2))]>;
2077 def XORI : DForm_4<26, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2078 "xori $dst, $src1, $src2", IIC_IntSimple,
2079 [(set i32:$dst, (xor i32:$src1, immZExt16:$src2))]>;
2080 def XORIS : DForm_4<27, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
2081 "xoris $dst, $src1, $src2", IIC_IntSimple,
2082 [(set i32:$dst, (xor i32:$src1, imm16ShiftedZExt:$src2))]>;
2084 def NOP : DForm_4_zero<24, (outs), (ins), "nop", IIC_IntSimple,
2086 let isCodeGenOnly = 1 in {
2087 // The POWER6 and POWER7 have special group-terminating nops.
2088 def NOP_GT_PWR6 : DForm_4_fixedreg_zero<24, 1, (outs), (ins),
2089 "ori 1, 1, 0", IIC_IntSimple, []>;
2090 def NOP_GT_PWR7 : DForm_4_fixedreg_zero<24, 2, (outs), (ins),
2091 "ori 2, 2, 0", IIC_IntSimple, []>;
2094 let isCompare = 1, hasSideEffects = 0 in {
2095 def CMPWI : DForm_5_ext<11, (outs crrc:$crD), (ins gprc:$rA, s16imm:$imm),
2096 "cmpwi $crD, $rA, $imm", IIC_IntCompare>;
2097 def CMPLWI : DForm_6_ext<10, (outs crrc:$dst), (ins gprc:$src1, u16imm:$src2),
2098 "cmplwi $dst, $src1, $src2", IIC_IntCompare>;
2099 def CMPRB : X_BF3_L1_RS5_RS5<31, 192, (outs crbitrc:$BF),
2100 (ins u1imm:$L, g8rc:$rA, g8rc:$rB),
2101 "cmprb $BF, $L, $rA, $rB", IIC_IntCompare, []>,
2102 Requires<[IsISA3_0]>;
2106 let PPC970_Unit = 1, hasSideEffects = 0 in { // FXU Operations.
2107 let isCommutable = 1 in {
2108 defm NAND : XForm_6r<31, 476, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2109 "nand", "$rA, $rS, $rB", IIC_IntSimple,
2110 [(set i32:$rA, (not (and i32:$rS, i32:$rB)))]>;
2111 defm AND : XForm_6r<31, 28, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2112 "and", "$rA, $rS, $rB", IIC_IntSimple,
2113 [(set i32:$rA, (and i32:$rS, i32:$rB))]>;
2115 defm ANDC : XForm_6r<31, 60, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2116 "andc", "$rA, $rS, $rB", IIC_IntSimple,
2117 [(set i32:$rA, (and i32:$rS, (not i32:$rB)))]>;
2118 let isCommutable = 1 in {
2119 defm OR : XForm_6r<31, 444, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2120 "or", "$rA, $rS, $rB", IIC_IntSimple,
2121 [(set i32:$rA, (or i32:$rS, i32:$rB))]>;
2122 defm NOR : XForm_6r<31, 124, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2123 "nor", "$rA, $rS, $rB", IIC_IntSimple,
2124 [(set i32:$rA, (not (or i32:$rS, i32:$rB)))]>;
2126 defm ORC : XForm_6r<31, 412, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2127 "orc", "$rA, $rS, $rB", IIC_IntSimple,
2128 [(set i32:$rA, (or i32:$rS, (not i32:$rB)))]>;
2129 let isCommutable = 1 in {
2130 defm EQV : XForm_6r<31, 284, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2131 "eqv", "$rA, $rS, $rB", IIC_IntSimple,
2132 [(set i32:$rA, (not (xor i32:$rS, i32:$rB)))]>;
2133 defm XOR : XForm_6r<31, 316, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2134 "xor", "$rA, $rS, $rB", IIC_IntSimple,
2135 [(set i32:$rA, (xor i32:$rS, i32:$rB))]>;
2137 defm SLW : XForm_6r<31, 24, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2138 "slw", "$rA, $rS, $rB", IIC_IntGeneral,
2139 [(set i32:$rA, (PPCshl i32:$rS, i32:$rB))]>;
2140 defm SRW : XForm_6r<31, 536, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2141 "srw", "$rA, $rS, $rB", IIC_IntGeneral,
2142 [(set i32:$rA, (PPCsrl i32:$rS, i32:$rB))]>;
2143 defm SRAW : XForm_6rc<31, 792, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2144 "sraw", "$rA, $rS, $rB", IIC_IntShift,
2145 [(set i32:$rA, (PPCsra i32:$rS, i32:$rB))]>;
2148 let PPC970_Unit = 1 in { // FXU Operations.
2149 let hasSideEffects = 0 in {
2150 defm SRAWI : XForm_10rc<31, 824, (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH),
2151 "srawi", "$rA, $rS, $SH", IIC_IntShift,
2152 [(set i32:$rA, (sra i32:$rS, (i32 imm:$SH)))]>;
2153 defm CNTLZW : XForm_11r<31, 26, (outs gprc:$rA), (ins gprc:$rS),
2154 "cntlzw", "$rA, $rS", IIC_IntGeneral,
2155 [(set i32:$rA, (ctlz i32:$rS))]>;
2156 defm CNTTZW : XForm_11r<31, 538, (outs gprc:$rA), (ins gprc:$rS),
2157 "cnttzw", "$rA, $rS", IIC_IntGeneral,
2158 [(set i32:$rA, (cttz i32:$rS))]>, Requires<[IsISA3_0]>;
2159 defm EXTSB : XForm_11r<31, 954, (outs gprc:$rA), (ins gprc:$rS),
2160 "extsb", "$rA, $rS", IIC_IntSimple,
2161 [(set i32:$rA, (sext_inreg i32:$rS, i8))]>;
2162 defm EXTSH : XForm_11r<31, 922, (outs gprc:$rA), (ins gprc:$rS),
2163 "extsh", "$rA, $rS", IIC_IntSimple,
2164 [(set i32:$rA, (sext_inreg i32:$rS, i16))]>;
2166 let isCommutable = 1 in
2167 def CMPB : XForm_6<31, 508, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
2168 "cmpb $rA, $rS, $rB", IIC_IntGeneral,
2169 [(set i32:$rA, (PPCcmpb i32:$rS, i32:$rB))]>;
2171 let isCompare = 1, hasSideEffects = 0 in {
2172 def CMPW : XForm_16_ext<31, 0, (outs crrc:$crD), (ins gprc:$rA, gprc:$rB),
2173 "cmpw $crD, $rA, $rB", IIC_IntCompare>;
2174 def CMPLW : XForm_16_ext<31, 32, (outs crrc:$crD), (ins gprc:$rA, gprc:$rB),
2175 "cmplw $crD, $rA, $rB", IIC_IntCompare>;
2178 let PPC970_Unit = 3 in { // FPU Operations.
2179 //def FCMPO : XForm_17<63, 32, (outs CRRC:$crD), (ins FPRC:$fA, FPRC:$fB),
2180 // "fcmpo $crD, $fA, $fB", IIC_FPCompare>;
2181 let isCompare = 1, hasSideEffects = 0 in {
2182 def FCMPUS : XForm_17<63, 0, (outs crrc:$crD), (ins f4rc:$fA, f4rc:$fB),
2183 "fcmpu $crD, $fA, $fB", IIC_FPCompare>;
2184 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2185 def FCMPUD : XForm_17<63, 0, (outs crrc:$crD), (ins f8rc:$fA, f8rc:$fB),
2186 "fcmpu $crD, $fA, $fB", IIC_FPCompare>;
2189 def FTDIV: XForm_17<63, 128, (outs crrc:$crD), (ins f8rc:$fA, f8rc:$fB),
2190 "ftdiv $crD, $fA, $fB", IIC_FPCompare>;
2191 def FTSQRT: XForm_17a<63, 160, (outs crrc:$crD), (ins f8rc:$fB),
2192 "ftsqrt $crD, $fB", IIC_FPCompare>;
2194 let Uses = [RM] in {
2195 let hasSideEffects = 0 in {
2196 defm FCTIW : XForm_26r<63, 14, (outs f8rc:$frD), (ins f8rc:$frB),
2197 "fctiw", "$frD, $frB", IIC_FPGeneral,
2199 defm FCTIWU : XForm_26r<63, 142, (outs f8rc:$frD), (ins f8rc:$frB),
2200 "fctiwu", "$frD, $frB", IIC_FPGeneral,
2202 defm FCTIWZ : XForm_26r<63, 15, (outs f8rc:$frD), (ins f8rc:$frB),
2203 "fctiwz", "$frD, $frB", IIC_FPGeneral,
2204 [(set f64:$frD, (PPCfctiwz f64:$frB))]>;
2206 defm FRSP : XForm_26r<63, 12, (outs f4rc:$frD), (ins f8rc:$frB),
2207 "frsp", "$frD, $frB", IIC_FPGeneral,
2208 [(set f32:$frD, (fpround f64:$frB))]>;
2210 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2211 defm FRIND : XForm_26r<63, 392, (outs f8rc:$frD), (ins f8rc:$frB),
2212 "frin", "$frD, $frB", IIC_FPGeneral,
2213 [(set f64:$frD, (fround f64:$frB))]>;
2214 defm FRINS : XForm_26r<63, 392, (outs f4rc:$frD), (ins f4rc:$frB),
2215 "frin", "$frD, $frB", IIC_FPGeneral,
2216 [(set f32:$frD, (fround f32:$frB))]>;
2219 let hasSideEffects = 0 in {
2220 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2221 defm FRIPD : XForm_26r<63, 456, (outs f8rc:$frD), (ins f8rc:$frB),
2222 "frip", "$frD, $frB", IIC_FPGeneral,
2223 [(set f64:$frD, (fceil f64:$frB))]>;
2224 defm FRIPS : XForm_26r<63, 456, (outs f4rc:$frD), (ins f4rc:$frB),
2225 "frip", "$frD, $frB", IIC_FPGeneral,
2226 [(set f32:$frD, (fceil f32:$frB))]>;
2227 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2228 defm FRIZD : XForm_26r<63, 424, (outs f8rc:$frD), (ins f8rc:$frB),
2229 "friz", "$frD, $frB", IIC_FPGeneral,
2230 [(set f64:$frD, (ftrunc f64:$frB))]>;
2231 defm FRIZS : XForm_26r<63, 424, (outs f4rc:$frD), (ins f4rc:$frB),
2232 "friz", "$frD, $frB", IIC_FPGeneral,
2233 [(set f32:$frD, (ftrunc f32:$frB))]>;
2234 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2235 defm FRIMD : XForm_26r<63, 488, (outs f8rc:$frD), (ins f8rc:$frB),
2236 "frim", "$frD, $frB", IIC_FPGeneral,
2237 [(set f64:$frD, (ffloor f64:$frB))]>;
2238 defm FRIMS : XForm_26r<63, 488, (outs f4rc:$frD), (ins f4rc:$frB),
2239 "frim", "$frD, $frB", IIC_FPGeneral,
2240 [(set f32:$frD, (ffloor f32:$frB))]>;
2242 defm FSQRT : XForm_26r<63, 22, (outs f8rc:$frD), (ins f8rc:$frB),
2243 "fsqrt", "$frD, $frB", IIC_FPSqrtD,
2244 [(set f64:$frD, (fsqrt f64:$frB))]>;
2245 defm FSQRTS : XForm_26r<59, 22, (outs f4rc:$frD), (ins f4rc:$frB),
2246 "fsqrts", "$frD, $frB", IIC_FPSqrtS,
2247 [(set f32:$frD, (fsqrt f32:$frB))]>;
2252 /// Note that FMR is defined as pseudo-ops on the PPC970 because they are
2253 /// often coalesced away and we don't want the dispatch group builder to think
2254 /// that they will fill slots (which could cause the load of a LSU reject to
2255 /// sneak into a d-group with a store).
2256 let hasSideEffects = 0 in
2257 defm FMR : XForm_26r<63, 72, (outs f4rc:$frD), (ins f4rc:$frB),
2258 "fmr", "$frD, $frB", IIC_FPGeneral,
2259 []>, // (set f32:$frD, f32:$frB)
2262 let PPC970_Unit = 3, hasSideEffects = 0 in { // FPU Operations.
2263 // These are artificially split into two different forms, for 4/8 byte FP.
2264 defm FABSS : XForm_26r<63, 264, (outs f4rc:$frD), (ins f4rc:$frB),
2265 "fabs", "$frD, $frB", IIC_FPGeneral,
2266 [(set f32:$frD, (fabs f32:$frB))]>;
2267 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2268 defm FABSD : XForm_26r<63, 264, (outs f8rc:$frD), (ins f8rc:$frB),
2269 "fabs", "$frD, $frB", IIC_FPGeneral,
2270 [(set f64:$frD, (fabs f64:$frB))]>;
2271 defm FNABSS : XForm_26r<63, 136, (outs f4rc:$frD), (ins f4rc:$frB),
2272 "fnabs", "$frD, $frB", IIC_FPGeneral,
2273 [(set f32:$frD, (fneg (fabs f32:$frB)))]>;
2274 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2275 defm FNABSD : XForm_26r<63, 136, (outs f8rc:$frD), (ins f8rc:$frB),
2276 "fnabs", "$frD, $frB", IIC_FPGeneral,
2277 [(set f64:$frD, (fneg (fabs f64:$frB)))]>;
2278 defm FNEGS : XForm_26r<63, 40, (outs f4rc:$frD), (ins f4rc:$frB),
2279 "fneg", "$frD, $frB", IIC_FPGeneral,
2280 [(set f32:$frD, (fneg f32:$frB))]>;
2281 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2282 defm FNEGD : XForm_26r<63, 40, (outs f8rc:$frD), (ins f8rc:$frB),
2283 "fneg", "$frD, $frB", IIC_FPGeneral,
2284 [(set f64:$frD, (fneg f64:$frB))]>;
2286 defm FCPSGNS : XForm_28r<63, 8, (outs f4rc:$frD), (ins f4rc:$frA, f4rc:$frB),
2287 "fcpsgn", "$frD, $frA, $frB", IIC_FPGeneral,
2288 [(set f32:$frD, (fcopysign f32:$frB, f32:$frA))]>;
2289 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2290 defm FCPSGND : XForm_28r<63, 8, (outs f8rc:$frD), (ins f8rc:$frA, f8rc:$frB),
2291 "fcpsgn", "$frD, $frA, $frB", IIC_FPGeneral,
2292 [(set f64:$frD, (fcopysign f64:$frB, f64:$frA))]>;
2294 // Reciprocal estimates.
2295 defm FRE : XForm_26r<63, 24, (outs f8rc:$frD), (ins f8rc:$frB),
2296 "fre", "$frD, $frB", IIC_FPGeneral,
2297 [(set f64:$frD, (PPCfre f64:$frB))]>;
2298 defm FRES : XForm_26r<59, 24, (outs f4rc:$frD), (ins f4rc:$frB),
2299 "fres", "$frD, $frB", IIC_FPGeneral,
2300 [(set f32:$frD, (PPCfre f32:$frB))]>;
2301 defm FRSQRTE : XForm_26r<63, 26, (outs f8rc:$frD), (ins f8rc:$frB),
2302 "frsqrte", "$frD, $frB", IIC_FPGeneral,
2303 [(set f64:$frD, (PPCfrsqrte f64:$frB))]>;
2304 defm FRSQRTES : XForm_26r<59, 26, (outs f4rc:$frD), (ins f4rc:$frB),
2305 "frsqrtes", "$frD, $frB", IIC_FPGeneral,
2306 [(set f32:$frD, (PPCfrsqrte f32:$frB))]>;
2309 // XL-Form instructions. condition register logical ops.
2311 let hasSideEffects = 0 in
2312 def MCRF : XLForm_3<19, 0, (outs crrc:$BF), (ins crrc:$BFA),
2313 "mcrf $BF, $BFA", IIC_BrMCR>,
2314 PPC970_DGroup_First, PPC970_Unit_CRU;
2316 // FIXME: According to the ISA (section 2.5.1 of version 2.06), the
2317 // condition-register logical instructions have preferred forms. Specifically,
2318 // it is preferred that the bit specified by the BT field be in the same
2319 // condition register as that specified by the bit BB. We might want to account
2320 // for this via hinting the register allocator and anti-dep breakers, or we
2321 // could constrain the register class to force this constraint and then loosen
2322 // it during register allocation via convertToThreeAddress or some similar
2325 let isCommutable = 1 in {
2326 def CRAND : XLForm_1<19, 257, (outs crbitrc:$CRD),
2327 (ins crbitrc:$CRA, crbitrc:$CRB),
2328 "crand $CRD, $CRA, $CRB", IIC_BrCR,
2329 [(set i1:$CRD, (and i1:$CRA, i1:$CRB))]>;
2331 def CRNAND : XLForm_1<19, 225, (outs crbitrc:$CRD),
2332 (ins crbitrc:$CRA, crbitrc:$CRB),
2333 "crnand $CRD, $CRA, $CRB", IIC_BrCR,
2334 [(set i1:$CRD, (not (and i1:$CRA, i1:$CRB)))]>;
2336 def CROR : XLForm_1<19, 449, (outs crbitrc:$CRD),
2337 (ins crbitrc:$CRA, crbitrc:$CRB),
2338 "cror $CRD, $CRA, $CRB", IIC_BrCR,
2339 [(set i1:$CRD, (or i1:$CRA, i1:$CRB))]>;
2341 def CRXOR : XLForm_1<19, 193, (outs crbitrc:$CRD),
2342 (ins crbitrc:$CRA, crbitrc:$CRB),
2343 "crxor $CRD, $CRA, $CRB", IIC_BrCR,
2344 [(set i1:$CRD, (xor i1:$CRA, i1:$CRB))]>;
2346 def CRNOR : XLForm_1<19, 33, (outs crbitrc:$CRD),
2347 (ins crbitrc:$CRA, crbitrc:$CRB),
2348 "crnor $CRD, $CRA, $CRB", IIC_BrCR,
2349 [(set i1:$CRD, (not (or i1:$CRA, i1:$CRB)))]>;
2351 def CREQV : XLForm_1<19, 289, (outs crbitrc:$CRD),
2352 (ins crbitrc:$CRA, crbitrc:$CRB),
2353 "creqv $CRD, $CRA, $CRB", IIC_BrCR,
2354 [(set i1:$CRD, (not (xor i1:$CRA, i1:$CRB)))]>;
2357 def CRANDC : XLForm_1<19, 129, (outs crbitrc:$CRD),
2358 (ins crbitrc:$CRA, crbitrc:$CRB),
2359 "crandc $CRD, $CRA, $CRB", IIC_BrCR,
2360 [(set i1:$CRD, (and i1:$CRA, (not i1:$CRB)))]>;
2362 def CRORC : XLForm_1<19, 417, (outs crbitrc:$CRD),
2363 (ins crbitrc:$CRA, crbitrc:$CRB),
2364 "crorc $CRD, $CRA, $CRB", IIC_BrCR,
2365 [(set i1:$CRD, (or i1:$CRA, (not i1:$CRB)))]>;
2367 let isCodeGenOnly = 1 in {
2368 def CRSET : XLForm_1_ext<19, 289, (outs crbitrc:$dst), (ins),
2369 "creqv $dst, $dst, $dst", IIC_BrCR,
2370 [(set i1:$dst, 1)]>;
2372 def CRUNSET: XLForm_1_ext<19, 193, (outs crbitrc:$dst), (ins),
2373 "crxor $dst, $dst, $dst", IIC_BrCR,
2374 [(set i1:$dst, 0)]>;
2376 let Defs = [CR1EQ], CRD = 6 in {
2377 def CR6SET : XLForm_1_ext<19, 289, (outs), (ins),
2378 "creqv 6, 6, 6", IIC_BrCR,
2381 def CR6UNSET: XLForm_1_ext<19, 193, (outs), (ins),
2382 "crxor 6, 6, 6", IIC_BrCR,
2387 // XFX-Form instructions. Instructions that deal with SPRs.
2390 def MFSPR : XFXForm_1<31, 339, (outs gprc:$RT), (ins i32imm:$SPR),
2391 "mfspr $RT, $SPR", IIC_SprMFSPR>;
2392 def MTSPR : XFXForm_1<31, 467, (outs), (ins i32imm:$SPR, gprc:$RT),
2393 "mtspr $SPR, $RT", IIC_SprMTSPR>;
2395 def MFTB : XFXForm_1<31, 371, (outs gprc:$RT), (ins i32imm:$SPR),
2396 "mftb $RT, $SPR", IIC_SprMFTB>;
2398 def MFPMR : XFXForm_1<31, 334, (outs gprc:$RT), (ins i32imm:$SPR),
2399 "mfpmr $RT, $SPR", IIC_SprMFPMR>;
2401 def MTPMR : XFXForm_1<31, 462, (outs), (ins i32imm:$SPR, gprc:$RT),
2402 "mtpmr $SPR, $RT", IIC_SprMTPMR>;
2405 // A pseudo-instruction used to implement the read of the 64-bit cycle counter
2406 // on a 32-bit target.
2407 let hasSideEffects = 1, usesCustomInserter = 1 in
2408 def ReadTB : Pseudo<(outs gprc:$lo, gprc:$hi), (ins),
2411 let Uses = [CTR] in {
2412 def MFCTR : XFXForm_1_ext<31, 339, 9, (outs gprc:$rT), (ins),
2413 "mfctr $rT", IIC_SprMFSPR>,
2414 PPC970_DGroup_First, PPC970_Unit_FXU;
2416 let Defs = [CTR], Pattern = [(PPCmtctr i32:$rS)] in {
2417 def MTCTR : XFXForm_7_ext<31, 467, 9, (outs), (ins gprc:$rS),
2418 "mtctr $rS", IIC_SprMTSPR>,
2419 PPC970_DGroup_First, PPC970_Unit_FXU;
2421 let hasSideEffects = 1, isCodeGenOnly = 1, Defs = [CTR] in {
2422 let Pattern = [(int_ppc_mtctr i32:$rS)] in
2423 def MTCTRloop : XFXForm_7_ext<31, 467, 9, (outs), (ins gprc:$rS),
2424 "mtctr $rS", IIC_SprMTSPR>,
2425 PPC970_DGroup_First, PPC970_Unit_FXU;
2428 let Defs = [LR] in {
2429 def MTLR : XFXForm_7_ext<31, 467, 8, (outs), (ins gprc:$rS),
2430 "mtlr $rS", IIC_SprMTSPR>,
2431 PPC970_DGroup_First, PPC970_Unit_FXU;
2433 let Uses = [LR] in {
2434 def MFLR : XFXForm_1_ext<31, 339, 8, (outs gprc:$rT), (ins),
2435 "mflr $rT", IIC_SprMFSPR>,
2436 PPC970_DGroup_First, PPC970_Unit_FXU;
2439 let isCodeGenOnly = 1 in {
2440 // Move to/from VRSAVE: despite being a SPR, the VRSAVE register is renamed
2441 // like a GPR on the PPC970. As such, copies in and out have the same
2442 // performance characteristics as an OR instruction.
2443 def MTVRSAVE : XFXForm_7_ext<31, 467, 256, (outs), (ins gprc:$rS),
2444 "mtspr 256, $rS", IIC_IntGeneral>,
2445 PPC970_DGroup_Single, PPC970_Unit_FXU;
2446 def MFVRSAVE : XFXForm_1_ext<31, 339, 256, (outs gprc:$rT), (ins),
2447 "mfspr $rT, 256", IIC_IntGeneral>,
2448 PPC970_DGroup_First, PPC970_Unit_FXU;
2450 def MTVRSAVEv : XFXForm_7_ext<31, 467, 256,
2451 (outs VRSAVERC:$reg), (ins gprc:$rS),
2452 "mtspr 256, $rS", IIC_IntGeneral>,
2453 PPC970_DGroup_Single, PPC970_Unit_FXU;
2454 def MFVRSAVEv : XFXForm_1_ext<31, 339, 256, (outs gprc:$rT),
2455 (ins VRSAVERC:$reg),
2456 "mfspr $rT, 256", IIC_IntGeneral>,
2457 PPC970_DGroup_First, PPC970_Unit_FXU;
2460 // Aliases for mtvrsave/mfvrsave to mfspr/mtspr.
2461 def : InstAlias<"mtvrsave $rS", (MTVRSAVE gprc:$rS)>;
2462 def : InstAlias<"mfvrsave $rS", (MFVRSAVE gprc:$rS)>;
2464 // SPILL_VRSAVE - Indicate that we're dumping the VRSAVE register,
2465 // so we'll need to scavenge a register for it.
2467 def SPILL_VRSAVE : Pseudo<(outs), (ins VRSAVERC:$vrsave, memri:$F),
2468 "#SPILL_VRSAVE", []>;
2470 // RESTORE_VRSAVE - Indicate that we're restoring the VRSAVE register (previously
2471 // spilled), so we'll need to scavenge a register for it.
2473 def RESTORE_VRSAVE : Pseudo<(outs VRSAVERC:$vrsave), (ins memri:$F),
2474 "#RESTORE_VRSAVE", []>;
2476 let hasSideEffects = 0 in {
2477 // mtocrf's input needs to be prepared by shifting by an amount dependent
2478 // on the cr register selected. Thus, post-ra anti-dep breaking must not
2479 // later change that register assignment.
2480 let hasExtraDefRegAllocReq = 1 in {
2481 def MTOCRF: XFXForm_5a<31, 144, (outs crbitm:$FXM), (ins gprc:$ST),
2482 "mtocrf $FXM, $ST", IIC_BrMCRX>,
2483 PPC970_DGroup_First, PPC970_Unit_CRU;
2485 // Similarly to mtocrf, the mask for mtcrf must be prepared in a way that
2486 // is dependent on the cr fields being set.
2487 def MTCRF : XFXForm_5<31, 144, (outs), (ins i32imm:$FXM, gprc:$rS),
2488 "mtcrf $FXM, $rS", IIC_BrMCRX>,
2489 PPC970_MicroCode, PPC970_Unit_CRU;
2490 } // hasExtraDefRegAllocReq = 1
2492 // mfocrf's input needs to be prepared by shifting by an amount dependent
2493 // on the cr register selected. Thus, post-ra anti-dep breaking must not
2494 // later change that register assignment.
2495 let hasExtraSrcRegAllocReq = 1 in {
2496 def MFOCRF: XFXForm_5a<31, 19, (outs gprc:$rT), (ins crbitm:$FXM),
2497 "mfocrf $rT, $FXM", IIC_SprMFCRF>,
2498 PPC970_DGroup_First, PPC970_Unit_CRU;
2500 // Similarly to mfocrf, the mask for mfcrf must be prepared in a way that
2501 // is dependent on the cr fields being copied.
2502 def MFCR : XFXForm_3<31, 19, (outs gprc:$rT), (ins),
2503 "mfcr $rT", IIC_SprMFCR>,
2504 PPC970_MicroCode, PPC970_Unit_CRU;
2505 } // hasExtraSrcRegAllocReq = 1
2507 def MCRXRX : X_BF3<31, 576, (outs crrc:$BF), (ins),
2508 "mcrxrx $BF", IIC_BrMCRX>, Requires<[IsISA3_0]>;
2509 } // hasSideEffects = 0
2511 // Pseudo instruction to perform FADD in round-to-zero mode.
2512 let usesCustomInserter = 1, Uses = [RM] in {
2513 def FADDrtz: Pseudo<(outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB), "",
2514 [(set f64:$FRT, (PPCfaddrtz f64:$FRA, f64:$FRB))]>;
2517 // The above pseudo gets expanded to make use of the following instructions
2518 // to manipulate FPSCR. Note that FPSCR is not modeled at the DAG level.
2519 let Uses = [RM], Defs = [RM] in {
2520 def MTFSB0 : XForm_43<63, 70, (outs), (ins u5imm:$FM),
2521 "mtfsb0 $FM", IIC_IntMTFSB0, []>,
2522 PPC970_DGroup_Single, PPC970_Unit_FPU;
2523 def MTFSB1 : XForm_43<63, 38, (outs), (ins u5imm:$FM),
2524 "mtfsb1 $FM", IIC_IntMTFSB0, []>,
2525 PPC970_DGroup_Single, PPC970_Unit_FPU;
2526 let isCodeGenOnly = 1 in
2527 def MTFSFb : XFLForm<63, 711, (outs), (ins i32imm:$FM, f8rc:$rT),
2528 "mtfsf $FM, $rT", IIC_IntMTFSB0, []>,
2529 PPC970_DGroup_Single, PPC970_Unit_FPU;
2531 let Uses = [RM] in {
2532 def MFFS : XForm_42<63, 583, (outs f8rc:$rT), (ins),
2533 "mffs $rT", IIC_IntMFFS,
2534 [(set f64:$rT, (PPCmffs))]>,
2535 PPC970_DGroup_Single, PPC970_Unit_FPU;
2538 def MFFSo : XForm_42<63, 583, (outs f8rc:$rT), (ins),
2539 "mffs. $rT", IIC_IntMFFS, []>, isDOT;
2543 let PPC970_Unit = 1, hasSideEffects = 0 in { // FXU Operations.
2544 // XO-Form instructions. Arithmetic instructions that can set overflow bit
2545 let isCommutable = 1 in
2546 defm ADD4 : XOForm_1r<31, 266, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2547 "add", "$rT, $rA, $rB", IIC_IntSimple,
2548 [(set i32:$rT, (add i32:$rA, i32:$rB))]>;
2549 let isCodeGenOnly = 1 in
2550 def ADD4TLS : XOForm_1<31, 266, 0, (outs gprc:$rT), (ins gprc:$rA, tlsreg32:$rB),
2551 "add $rT, $rA, $rB", IIC_IntSimple,
2552 [(set i32:$rT, (add i32:$rA, tglobaltlsaddr:$rB))]>;
2553 let isCommutable = 1 in
2554 defm ADDC : XOForm_1rc<31, 10, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2555 "addc", "$rT, $rA, $rB", IIC_IntGeneral,
2556 [(set i32:$rT, (addc i32:$rA, i32:$rB))]>,
2557 PPC970_DGroup_Cracked;
2559 defm DIVW : XOForm_1rcr<31, 491, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2560 "divw", "$rT, $rA, $rB", IIC_IntDivW,
2561 [(set i32:$rT, (sdiv i32:$rA, i32:$rB))]>;
2562 defm DIVWU : XOForm_1rcr<31, 459, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2563 "divwu", "$rT, $rA, $rB", IIC_IntDivW,
2564 [(set i32:$rT, (udiv i32:$rA, i32:$rB))]>;
2565 def DIVWE : XOForm_1<31, 427, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2566 "divwe $rT, $rA, $rB", IIC_IntDivW,
2567 [(set i32:$rT, (int_ppc_divwe gprc:$rA, gprc:$rB))]>,
2568 Requires<[HasExtDiv]>;
2570 def DIVWEo : XOForm_1<31, 427, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2571 "divwe. $rT, $rA, $rB", IIC_IntDivW,
2572 []>, isDOT, PPC970_DGroup_Cracked, PPC970_DGroup_First,
2573 Requires<[HasExtDiv]>;
2574 def DIVWEU : XOForm_1<31, 395, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2575 "divweu $rT, $rA, $rB", IIC_IntDivW,
2576 [(set i32:$rT, (int_ppc_divweu gprc:$rA, gprc:$rB))]>,
2577 Requires<[HasExtDiv]>;
2579 def DIVWEUo : XOForm_1<31, 395, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2580 "divweu. $rT, $rA, $rB", IIC_IntDivW,
2581 []>, isDOT, PPC970_DGroup_Cracked, PPC970_DGroup_First,
2582 Requires<[HasExtDiv]>;
2583 let isCommutable = 1 in {
2584 defm MULHW : XOForm_1r<31, 75, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2585 "mulhw", "$rT, $rA, $rB", IIC_IntMulHW,
2586 [(set i32:$rT, (mulhs i32:$rA, i32:$rB))]>;
2587 defm MULHWU : XOForm_1r<31, 11, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2588 "mulhwu", "$rT, $rA, $rB", IIC_IntMulHWU,
2589 [(set i32:$rT, (mulhu i32:$rA, i32:$rB))]>;
2590 defm MULLW : XOForm_1r<31, 235, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2591 "mullw", "$rT, $rA, $rB", IIC_IntMulHW,
2592 [(set i32:$rT, (mul i32:$rA, i32:$rB))]>;
2594 defm SUBF : XOForm_1r<31, 40, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2595 "subf", "$rT, $rA, $rB", IIC_IntGeneral,
2596 [(set i32:$rT, (sub i32:$rB, i32:$rA))]>;
2597 defm SUBFC : XOForm_1rc<31, 8, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2598 "subfc", "$rT, $rA, $rB", IIC_IntGeneral,
2599 [(set i32:$rT, (subc i32:$rB, i32:$rA))]>,
2600 PPC970_DGroup_Cracked;
2601 defm NEG : XOForm_3r<31, 104, 0, (outs gprc:$rT), (ins gprc:$rA),
2602 "neg", "$rT, $rA", IIC_IntSimple,
2603 [(set i32:$rT, (ineg i32:$rA))]>;
2604 let Uses = [CARRY] in {
2605 let isCommutable = 1 in
2606 defm ADDE : XOForm_1rc<31, 138, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2607 "adde", "$rT, $rA, $rB", IIC_IntGeneral,
2608 [(set i32:$rT, (adde i32:$rA, i32:$rB))]>;
2609 defm ADDME : XOForm_3rc<31, 234, 0, (outs gprc:$rT), (ins gprc:$rA),
2610 "addme", "$rT, $rA", IIC_IntGeneral,
2611 [(set i32:$rT, (adde i32:$rA, -1))]>;
2612 defm ADDZE : XOForm_3rc<31, 202, 0, (outs gprc:$rT), (ins gprc:$rA),
2613 "addze", "$rT, $rA", IIC_IntGeneral,
2614 [(set i32:$rT, (adde i32:$rA, 0))]>;
2615 defm SUBFE : XOForm_1rc<31, 136, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2616 "subfe", "$rT, $rA, $rB", IIC_IntGeneral,
2617 [(set i32:$rT, (sube i32:$rB, i32:$rA))]>;
2618 defm SUBFME : XOForm_3rc<31, 232, 0, (outs gprc:$rT), (ins gprc:$rA),
2619 "subfme", "$rT, $rA", IIC_IntGeneral,
2620 [(set i32:$rT, (sube -1, i32:$rA))]>;
2621 defm SUBFZE : XOForm_3rc<31, 200, 0, (outs gprc:$rT), (ins gprc:$rA),
2622 "subfze", "$rT, $rA", IIC_IntGeneral,
2623 [(set i32:$rT, (sube 0, i32:$rA))]>;
2627 // A-Form instructions. Most of the instructions executed in the FPU are of
2630 let PPC970_Unit = 3, hasSideEffects = 0 in { // FPU Operations.
2631 let Uses = [RM] in {
2632 let isCommutable = 1 in {
2633 defm FMADD : AForm_1r<63, 29,
2634 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2635 "fmadd", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2636 [(set f64:$FRT, (fma f64:$FRA, f64:$FRC, f64:$FRB))]>;
2637 defm FMADDS : AForm_1r<59, 29,
2638 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2639 "fmadds", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2640 [(set f32:$FRT, (fma f32:$FRA, f32:$FRC, f32:$FRB))]>;
2641 defm FMSUB : AForm_1r<63, 28,
2642 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2643 "fmsub", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2645 (fma f64:$FRA, f64:$FRC, (fneg f64:$FRB)))]>;
2646 defm FMSUBS : AForm_1r<59, 28,
2647 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2648 "fmsubs", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2650 (fma f32:$FRA, f32:$FRC, (fneg f32:$FRB)))]>;
2651 defm FNMADD : AForm_1r<63, 31,
2652 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2653 "fnmadd", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2655 (fneg (fma f64:$FRA, f64:$FRC, f64:$FRB)))]>;
2656 defm FNMADDS : AForm_1r<59, 31,
2657 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2658 "fnmadds", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2660 (fneg (fma f32:$FRA, f32:$FRC, f32:$FRB)))]>;
2661 defm FNMSUB : AForm_1r<63, 30,
2662 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2663 "fnmsub", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2664 [(set f64:$FRT, (fneg (fma f64:$FRA, f64:$FRC,
2665 (fneg f64:$FRB))))]>;
2666 defm FNMSUBS : AForm_1r<59, 30,
2667 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2668 "fnmsubs", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2669 [(set f32:$FRT, (fneg (fma f32:$FRA, f32:$FRC,
2670 (fneg f32:$FRB))))]>;
2673 // FSEL is artificially split into 4 and 8-byte forms for the result. To avoid
2674 // having 4 of these, force the comparison to always be an 8-byte double (code
2675 // should use an FMRSD if the input comparison value really wants to be a float)
2676 // and 4/8 byte forms for the result and operand type..
2677 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2678 defm FSELD : AForm_1r<63, 23,
2679 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2680 "fsel", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2681 [(set f64:$FRT, (PPCfsel f64:$FRA, f64:$FRC, f64:$FRB))]>;
2682 defm FSELS : AForm_1r<63, 23,
2683 (outs f4rc:$FRT), (ins f8rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2684 "fsel", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2685 [(set f32:$FRT, (PPCfsel f64:$FRA, f32:$FRC, f32:$FRB))]>;
2686 let Uses = [RM] in {
2687 let isCommutable = 1 in {
2688 defm FADD : AForm_2r<63, 21,
2689 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB),
2690 "fadd", "$FRT, $FRA, $FRB", IIC_FPAddSub,
2691 [(set f64:$FRT, (fadd f64:$FRA, f64:$FRB))]>;
2692 defm FADDS : AForm_2r<59, 21,
2693 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB),
2694 "fadds", "$FRT, $FRA, $FRB", IIC_FPGeneral,
2695 [(set f32:$FRT, (fadd f32:$FRA, f32:$FRB))]>;
2697 defm FDIV : AForm_2r<63, 18,
2698 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB),
2699 "fdiv", "$FRT, $FRA, $FRB", IIC_FPDivD,
2700 [(set f64:$FRT, (fdiv f64:$FRA, f64:$FRB))]>;
2701 defm FDIVS : AForm_2r<59, 18,
2702 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB),
2703 "fdivs", "$FRT, $FRA, $FRB", IIC_FPDivS,
2704 [(set f32:$FRT, (fdiv f32:$FRA, f32:$FRB))]>;
2705 let isCommutable = 1 in {
2706 defm FMUL : AForm_3r<63, 25,
2707 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC),
2708 "fmul", "$FRT, $FRA, $FRC", IIC_FPFused,
2709 [(set f64:$FRT, (fmul f64:$FRA, f64:$FRC))]>;
2710 defm FMULS : AForm_3r<59, 25,
2711 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC),
2712 "fmuls", "$FRT, $FRA, $FRC", IIC_FPGeneral,
2713 [(set f32:$FRT, (fmul f32:$FRA, f32:$FRC))]>;
2715 defm FSUB : AForm_2r<63, 20,
2716 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB),
2717 "fsub", "$FRT, $FRA, $FRB", IIC_FPAddSub,
2718 [(set f64:$FRT, (fsub f64:$FRA, f64:$FRB))]>;
2719 defm FSUBS : AForm_2r<59, 20,
2720 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB),
2721 "fsubs", "$FRT, $FRA, $FRB", IIC_FPGeneral,
2722 [(set f32:$FRT, (fsub f32:$FRA, f32:$FRB))]>;
2726 let hasSideEffects = 0 in {
2727 let PPC970_Unit = 1 in { // FXU Operations.
2729 def ISEL : AForm_4<31, 15,
2730 (outs gprc:$rT), (ins gprc_nor0:$rA, gprc:$rB, crbitrc:$cond),
2731 "isel $rT, $rA, $rB, $cond", IIC_IntISEL,
2735 let PPC970_Unit = 1 in { // FXU Operations.
2736 // M-Form instructions. rotate and mask instructions.
2738 let isCommutable = 1 in {
2739 // RLWIMI can be commuted if the rotate amount is zero.
2740 defm RLWIMI : MForm_2r<20, (outs gprc:$rA),
2741 (ins gprc:$rSi, gprc:$rS, u5imm:$SH, u5imm:$MB,
2742 u5imm:$ME), "rlwimi", "$rA, $rS, $SH, $MB, $ME",
2743 IIC_IntRotate, []>, PPC970_DGroup_Cracked,
2744 RegConstraint<"$rSi = $rA">, NoEncode<"$rSi">;
2746 let BaseName = "rlwinm" in {
2747 def RLWINM : MForm_2<21,
2748 (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
2749 "rlwinm $rA, $rS, $SH, $MB, $ME", IIC_IntGeneral,
2752 def RLWINMo : MForm_2<21,
2753 (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
2754 "rlwinm. $rA, $rS, $SH, $MB, $ME", IIC_IntGeneral,
2755 []>, isDOT, RecFormRel, PPC970_DGroup_Cracked;
2757 defm RLWNM : MForm_2r<23, (outs gprc:$rA),
2758 (ins gprc:$rS, gprc:$rB, u5imm:$MB, u5imm:$ME),
2759 "rlwnm", "$rA, $rS, $rB, $MB, $ME", IIC_IntGeneral,
2762 } // hasSideEffects = 0
2764 //===----------------------------------------------------------------------===//
2765 // PowerPC Instruction Patterns
2768 // Arbitrary immediate support. Implement in terms of LIS/ORI.
2769 def : Pat<(i32 imm:$imm),
2770 (ORI (LIS (HI16 imm:$imm)), (LO16 imm:$imm))>;
2772 // Implement the 'not' operation with the NOR instruction.
2773 def i32not : OutPatFrag<(ops node:$in),
2775 def : Pat<(not i32:$in),
2778 // ADD an arbitrary immediate.
2779 def : Pat<(add i32:$in, imm:$imm),
2780 (ADDIS (ADDI $in, (LO16 imm:$imm)), (HA16 imm:$imm))>;
2781 // OR an arbitrary immediate.
2782 def : Pat<(or i32:$in, imm:$imm),
2783 (ORIS (ORI $in, (LO16 imm:$imm)), (HI16 imm:$imm))>;
2784 // XOR an arbitrary immediate.
2785 def : Pat<(xor i32:$in, imm:$imm),
2786 (XORIS (XORI $in, (LO16 imm:$imm)), (HI16 imm:$imm))>;
2788 def : Pat<(sub imm32SExt16:$imm, i32:$in),
2789 (SUBFIC $in, imm:$imm)>;
2792 def : Pat<(shl i32:$in, (i32 imm:$imm)),
2793 (RLWINM $in, imm:$imm, 0, (SHL32 imm:$imm))>;
2794 def : Pat<(srl i32:$in, (i32 imm:$imm)),
2795 (RLWINM $in, (SRL32 imm:$imm), imm:$imm, 31)>;
2798 def : Pat<(rotl i32:$in, i32:$sh),
2799 (RLWNM $in, $sh, 0, 31)>;
2800 def : Pat<(rotl i32:$in, (i32 imm:$imm)),
2801 (RLWINM $in, imm:$imm, 0, 31)>;
2804 def : Pat<(and (rotl i32:$in, i32:$sh), maskimm32:$imm),
2805 (RLWNM $in, $sh, (MB maskimm32:$imm), (ME maskimm32:$imm))>;
2808 def : Pat<(PPCcall (i32 tglobaladdr:$dst)),
2809 (BL tglobaladdr:$dst)>;
2810 def : Pat<(PPCcall (i32 texternalsym:$dst)),
2811 (BL texternalsym:$dst)>;
2813 def : Pat<(PPCtc_return (i32 tglobaladdr:$dst), imm:$imm),
2814 (TCRETURNdi tglobaladdr:$dst, imm:$imm)>;
2816 def : Pat<(PPCtc_return (i32 texternalsym:$dst), imm:$imm),
2817 (TCRETURNdi texternalsym:$dst, imm:$imm)>;
2819 def : Pat<(PPCtc_return CTRRC:$dst, imm:$imm),
2820 (TCRETURNri CTRRC:$dst, imm:$imm)>;
2824 // Hi and Lo for Darwin Global Addresses.
2825 def : Pat<(PPChi tglobaladdr:$in, 0), (LIS tglobaladdr:$in)>;
2826 def : Pat<(PPClo tglobaladdr:$in, 0), (LI tglobaladdr:$in)>;
2827 def : Pat<(PPChi tconstpool:$in, 0), (LIS tconstpool:$in)>;
2828 def : Pat<(PPClo tconstpool:$in, 0), (LI tconstpool:$in)>;
2829 def : Pat<(PPChi tjumptable:$in, 0), (LIS tjumptable:$in)>;
2830 def : Pat<(PPClo tjumptable:$in, 0), (LI tjumptable:$in)>;
2831 def : Pat<(PPChi tblockaddress:$in, 0), (LIS tblockaddress:$in)>;
2832 def : Pat<(PPClo tblockaddress:$in, 0), (LI tblockaddress:$in)>;
2833 def : Pat<(PPChi tglobaltlsaddr:$g, i32:$in),
2834 (ADDIS $in, tglobaltlsaddr:$g)>;
2835 def : Pat<(PPClo tglobaltlsaddr:$g, i32:$in),
2836 (ADDI $in, tglobaltlsaddr:$g)>;
2837 def : Pat<(add i32:$in, (PPChi tglobaladdr:$g, 0)),
2838 (ADDIS $in, tglobaladdr:$g)>;
2839 def : Pat<(add i32:$in, (PPChi tconstpool:$g, 0)),
2840 (ADDIS $in, tconstpool:$g)>;
2841 def : Pat<(add i32:$in, (PPChi tjumptable:$g, 0)),
2842 (ADDIS $in, tjumptable:$g)>;
2843 def : Pat<(add i32:$in, (PPChi tblockaddress:$g, 0)),
2844 (ADDIS $in, tblockaddress:$g)>;
2846 // Support for thread-local storage.
2847 def PPC32GOT: Pseudo<(outs gprc:$rD), (ins), "#PPC32GOT",
2848 [(set i32:$rD, (PPCppc32GOT))]>;
2850 // Get the _GLOBAL_OFFSET_TABLE_ in PIC mode.
2851 // This uses two output registers, the first as the real output, the second as a
2852 // temporary register, used internally in code generation.
2853 def PPC32PICGOT: Pseudo<(outs gprc:$rD, gprc:$rT), (ins), "#PPC32PICGOT",
2854 []>, NoEncode<"$rT">;
2856 def LDgotTprelL32: Pseudo<(outs gprc:$rD), (ins s16imm:$disp, gprc_nor0:$reg),
2859 (PPCldGotTprelL tglobaltlsaddr:$disp, i32:$reg))]>;
2860 def : Pat<(PPCaddTls i32:$in, tglobaltlsaddr:$g),
2861 (ADD4TLS $in, tglobaltlsaddr:$g)>;
2863 def ADDItlsgdL32 : Pseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
2866 (PPCaddiTlsgdL i32:$reg, tglobaltlsaddr:$disp))]>;
2867 // LR is a true define, while the rest of the Defs are clobbers. R3 is
2868 // explicitly defined when this op is created, so not mentioned here.
2869 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
2870 Defs = [R0,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
2871 def GETtlsADDR32 : Pseudo<(outs gprc:$rD), (ins gprc:$reg, tlsgd32:$sym),
2874 (PPCgetTlsAddr i32:$reg, tglobaltlsaddr:$sym))]>;
2875 // Combined op for ADDItlsgdL32 and GETtlsADDR32, late expanded. R3 and LR
2876 // are true defines while the rest of the Defs are clobbers.
2877 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
2878 Defs = [R0,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
2879 def ADDItlsgdLADDR32 : Pseudo<(outs gprc:$rD),
2880 (ins gprc_nor0:$reg, s16imm:$disp, tlsgd32:$sym),
2881 "#ADDItlsgdLADDR32",
2883 (PPCaddiTlsgdLAddr i32:$reg,
2884 tglobaltlsaddr:$disp,
2885 tglobaltlsaddr:$sym))]>;
2886 def ADDItlsldL32 : Pseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
2889 (PPCaddiTlsldL i32:$reg, tglobaltlsaddr:$disp))]>;
2890 // LR is a true define, while the rest of the Defs are clobbers. R3 is
2891 // explicitly defined when this op is created, so not mentioned here.
2892 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
2893 Defs = [R0,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
2894 def GETtlsldADDR32 : Pseudo<(outs gprc:$rD), (ins gprc:$reg, tlsgd32:$sym),
2897 (PPCgetTlsldAddr i32:$reg,
2898 tglobaltlsaddr:$sym))]>;
2899 // Combined op for ADDItlsldL32 and GETtlsADDR32, late expanded. R3 and LR
2900 // are true defines while the rest of the Defs are clobbers.
2901 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
2902 Defs = [R0,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
2903 def ADDItlsldLADDR32 : Pseudo<(outs gprc:$rD),
2904 (ins gprc_nor0:$reg, s16imm:$disp, tlsgd32:$sym),
2905 "#ADDItlsldLADDR32",
2907 (PPCaddiTlsldLAddr i32:$reg,
2908 tglobaltlsaddr:$disp,
2909 tglobaltlsaddr:$sym))]>;
2910 def ADDIdtprelL32 : Pseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
2913 (PPCaddiDtprelL i32:$reg, tglobaltlsaddr:$disp))]>;
2914 def ADDISdtprelHA32 : Pseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
2917 (PPCaddisDtprelHA i32:$reg,
2918 tglobaltlsaddr:$disp))]>;
2920 // Support for Position-independent code
2921 def LWZtoc : Pseudo<(outs gprc:$rD), (ins tocentry32:$disp, gprc:$reg),
2924 (PPCtoc_entry tglobaladdr:$disp, i32:$reg))]>;
2925 // Get Global (GOT) Base Register offset, from the word immediately preceding
2926 // the function label.
2927 def UpdateGBR : Pseudo<(outs gprc:$rD, gprc:$rT), (ins gprc:$rI), "#UpdateGBR", []>;
2930 // Standard shifts. These are represented separately from the real shifts above
2931 // so that we can distinguish between shifts that allow 5-bit and 6-bit shift
2933 def : Pat<(sra i32:$rS, i32:$rB),
2935 def : Pat<(srl i32:$rS, i32:$rB),
2937 def : Pat<(shl i32:$rS, i32:$rB),
2940 def : Pat<(zextloadi1 iaddr:$src),
2942 def : Pat<(zextloadi1 xaddr:$src),
2944 def : Pat<(extloadi1 iaddr:$src),
2946 def : Pat<(extloadi1 xaddr:$src),
2948 def : Pat<(extloadi8 iaddr:$src),
2950 def : Pat<(extloadi8 xaddr:$src),
2952 def : Pat<(extloadi16 iaddr:$src),
2954 def : Pat<(extloadi16 xaddr:$src),
2956 def : Pat<(f64 (extloadf32 iaddr:$src)),
2957 (COPY_TO_REGCLASS (LFS iaddr:$src), F8RC)>;
2958 def : Pat<(f64 (extloadf32 xaddr:$src)),
2959 (COPY_TO_REGCLASS (LFSX xaddr:$src), F8RC)>;
2961 def : Pat<(f64 (fpextend f32:$src)),
2962 (COPY_TO_REGCLASS $src, F8RC)>;
2964 // Only seq_cst fences require the heavyweight sync (SYNC 0).
2965 // All others can use the lightweight sync (SYNC 1).
2966 // source: http://www.cl.cam.ac.uk/~pes20/cpp/cpp0xmappings.html
2967 // The rule for seq_cst is duplicated to work with both 64 bits and 32 bits
2968 // versions of Power.
2969 def : Pat<(atomic_fence (i64 7), (imm)), (SYNC 0)>, Requires<[HasSYNC]>;
2970 def : Pat<(atomic_fence (i32 7), (imm)), (SYNC 0)>, Requires<[HasSYNC]>;
2971 def : Pat<(atomic_fence (imm), (imm)), (SYNC 1)>, Requires<[HasSYNC]>;
2972 def : Pat<(atomic_fence (imm), (imm)), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
2974 // Additional FNMSUB patterns: -a*c + b == -(a*c - b)
2975 def : Pat<(fma (fneg f64:$A), f64:$C, f64:$B),
2976 (FNMSUB $A, $C, $B)>;
2977 def : Pat<(fma f64:$A, (fneg f64:$C), f64:$B),
2978 (FNMSUB $A, $C, $B)>;
2979 def : Pat<(fma (fneg f32:$A), f32:$C, f32:$B),
2980 (FNMSUBS $A, $C, $B)>;
2981 def : Pat<(fma f32:$A, (fneg f32:$C), f32:$B),
2982 (FNMSUBS $A, $C, $B)>;
2984 // FCOPYSIGN's operand types need not agree.
2985 def : Pat<(fcopysign f64:$frB, f32:$frA),
2986 (FCPSGND (COPY_TO_REGCLASS $frA, F8RC), $frB)>;
2987 def : Pat<(fcopysign f32:$frB, f64:$frA),
2988 (FCPSGNS (COPY_TO_REGCLASS $frA, F4RC), $frB)>;
2990 include "PPCInstrAltivec.td"
2991 include "PPCInstrSPE.td"
2992 include "PPCInstr64Bit.td"
2993 include "PPCInstrVSX.td"
2994 include "PPCInstrQPX.td"
2995 include "PPCInstrHTM.td"
2997 def crnot : OutPatFrag<(ops node:$in),
2999 def : Pat<(not i1:$in),
3002 // Patterns for arithmetic i1 operations.
3003 def : Pat<(add i1:$a, i1:$b),
3005 def : Pat<(sub i1:$a, i1:$b),
3007 def : Pat<(mul i1:$a, i1:$b),
3010 // We're sometimes asked to materialize i1 -1, which is just 1 in this case
3011 // (-1 is used to mean all bits set).
3012 def : Pat<(i1 -1), (CRSET)>;
3014 // i1 extensions, implemented in terms of isel.
3015 def : Pat<(i32 (zext i1:$in)),
3016 (SELECT_I4 $in, (LI 1), (LI 0))>;
3017 def : Pat<(i32 (sext i1:$in)),
3018 (SELECT_I4 $in, (LI -1), (LI 0))>;
3020 def : Pat<(i64 (zext i1:$in)),
3021 (SELECT_I8 $in, (LI8 1), (LI8 0))>;
3022 def : Pat<(i64 (sext i1:$in)),
3023 (SELECT_I8 $in, (LI8 -1), (LI8 0))>;
3025 // FIXME: We should choose either a zext or a sext based on other constants
3027 def : Pat<(i32 (anyext i1:$in)),
3028 (SELECT_I4 $in, (LI 1), (LI 0))>;
3029 def : Pat<(i64 (anyext i1:$in)),
3030 (SELECT_I8 $in, (LI8 1), (LI8 0))>;
3032 // match setcc on i1 variables.
3050 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETLT)),
3052 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETULT)),
3071 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETLE)),
3073 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETULE)),
3076 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETEQ)),
3090 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETGE)),
3092 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETUGE)),
3106 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETGT)),
3108 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETUGT)),
3111 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETNE)),
3114 // match setcc on non-i1 (non-vector) variables. Note that SETUEQ, SETOGE,
3115 // SETOLE, SETONE, SETULT and SETUGT should be expanded by legalize for
3116 // floating-point types.
3118 multiclass CRNotPat<dag pattern, dag result> {
3119 def : Pat<pattern, (crnot result)>;
3120 def : Pat<(not pattern), result>;
3122 // We can also fold the crnot into an extension:
3123 def : Pat<(i32 (zext pattern)),
3124 (SELECT_I4 result, (LI 0), (LI 1))>;
3125 def : Pat<(i32 (sext pattern)),
3126 (SELECT_I4 result, (LI 0), (LI -1))>;
3128 // We can also fold the crnot into an extension:
3129 def : Pat<(i64 (zext pattern)),
3130 (SELECT_I8 result, (LI8 0), (LI8 1))>;
3131 def : Pat<(i64 (sext pattern)),
3132 (SELECT_I8 result, (LI8 0), (LI8 -1))>;
3134 // FIXME: We should choose either a zext or a sext based on other constants
3136 def : Pat<(i32 (anyext pattern)),
3137 (SELECT_I4 result, (LI 0), (LI 1))>;
3139 def : Pat<(i64 (anyext pattern)),
3140 (SELECT_I8 result, (LI8 0), (LI8 1))>;
3143 // FIXME: Because of what seems like a bug in TableGen's type-inference code,
3144 // we need to write imm:$imm in the output patterns below, not just $imm, or
3145 // else the resulting matcher will not correctly add the immediate operand
3146 // (making it a register operand instead).
3149 multiclass ExtSetCCPat<CondCode cc, PatFrag pfrag,
3150 OutPatFrag rfrag, OutPatFrag rfrag8> {
3151 def : Pat<(i32 (zext (i1 (pfrag i32:$s1, cc)))),
3153 def : Pat<(i64 (zext (i1 (pfrag i64:$s1, cc)))),
3155 def : Pat<(i64 (zext (i1 (pfrag i32:$s1, cc)))),
3156 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1), sub_32)>;
3157 def : Pat<(i32 (zext (i1 (pfrag i64:$s1, cc)))),
3158 (EXTRACT_SUBREG (rfrag8 $s1), sub_32)>;
3160 def : Pat<(i32 (anyext (i1 (pfrag i32:$s1, cc)))),
3162 def : Pat<(i64 (anyext (i1 (pfrag i64:$s1, cc)))),
3164 def : Pat<(i64 (anyext (i1 (pfrag i32:$s1, cc)))),
3165 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1), sub_32)>;
3166 def : Pat<(i32 (anyext (i1 (pfrag i64:$s1, cc)))),
3167 (EXTRACT_SUBREG (rfrag8 $s1), sub_32)>;
3170 // Note that we do all inversions below with i(32|64)not, instead of using
3171 // (xori x, 1) because on the A2 nor has single-cycle latency while xori
3172 // has 2-cycle latency.
3174 defm : ExtSetCCPat<SETEQ,
3175 PatFrag<(ops node:$in, node:$cc),
3176 (setcc $in, 0, $cc)>,
3177 OutPatFrag<(ops node:$in),
3178 (RLWINM (CNTLZW $in), 27, 31, 31)>,
3179 OutPatFrag<(ops node:$in),
3180 (RLDICL (CNTLZD $in), 58, 63)> >;
3182 defm : ExtSetCCPat<SETNE,
3183 PatFrag<(ops node:$in, node:$cc),
3184 (setcc $in, 0, $cc)>,
3185 OutPatFrag<(ops node:$in),
3186 (RLWINM (i32not (CNTLZW $in)), 27, 31, 31)>,
3187 OutPatFrag<(ops node:$in),
3188 (RLDICL (i64not (CNTLZD $in)), 58, 63)> >;
3190 defm : ExtSetCCPat<SETLT,
3191 PatFrag<(ops node:$in, node:$cc),
3192 (setcc $in, 0, $cc)>,
3193 OutPatFrag<(ops node:$in),
3194 (RLWINM $in, 1, 31, 31)>,
3195 OutPatFrag<(ops node:$in),
3196 (RLDICL $in, 1, 63)> >;
3198 defm : ExtSetCCPat<SETGE,
3199 PatFrag<(ops node:$in, node:$cc),
3200 (setcc $in, 0, $cc)>,
3201 OutPatFrag<(ops node:$in),
3202 (RLWINM (i32not $in), 1, 31, 31)>,
3203 OutPatFrag<(ops node:$in),
3204 (RLDICL (i64not $in), 1, 63)> >;
3206 defm : ExtSetCCPat<SETGT,
3207 PatFrag<(ops node:$in, node:$cc),
3208 (setcc $in, 0, $cc)>,
3209 OutPatFrag<(ops node:$in),
3210 (RLWINM (ANDC (NEG $in), $in), 1, 31, 31)>,
3211 OutPatFrag<(ops node:$in),
3212 (RLDICL (ANDC8 (NEG8 $in), $in), 1, 63)> >;
3214 defm : ExtSetCCPat<SETLE,
3215 PatFrag<(ops node:$in, node:$cc),
3216 (setcc $in, 0, $cc)>,
3217 OutPatFrag<(ops node:$in),
3218 (RLWINM (ORC $in, (NEG $in)), 1, 31, 31)>,
3219 OutPatFrag<(ops node:$in),
3220 (RLDICL (ORC8 $in, (NEG8 $in)), 1, 63)> >;
3222 defm : ExtSetCCPat<SETLT,
3223 PatFrag<(ops node:$in, node:$cc),
3224 (setcc $in, -1, $cc)>,
3225 OutPatFrag<(ops node:$in),
3226 (RLWINM (AND $in, (ADDI $in, 1)), 1, 31, 31)>,
3227 OutPatFrag<(ops node:$in),
3228 (RLDICL (AND8 $in, (ADDI8 $in, 1)), 1, 63)> >;
3230 defm : ExtSetCCPat<SETGE,
3231 PatFrag<(ops node:$in, node:$cc),
3232 (setcc $in, -1, $cc)>,
3233 OutPatFrag<(ops node:$in),
3234 (RLWINM (NAND $in, (ADDI $in, 1)), 1, 31, 31)>,
3235 OutPatFrag<(ops node:$in),
3236 (RLDICL (NAND8 $in, (ADDI8 $in, 1)), 1, 63)> >;
3238 defm : ExtSetCCPat<SETGT,
3239 PatFrag<(ops node:$in, node:$cc),
3240 (setcc $in, -1, $cc)>,
3241 OutPatFrag<(ops node:$in),
3242 (RLWINM (i32not $in), 1, 31, 31)>,
3243 OutPatFrag<(ops node:$in),
3244 (RLDICL (i64not $in), 1, 63)> >;
3246 defm : ExtSetCCPat<SETLE,
3247 PatFrag<(ops node:$in, node:$cc),
3248 (setcc $in, -1, $cc)>,
3249 OutPatFrag<(ops node:$in),
3250 (RLWINM $in, 1, 31, 31)>,
3251 OutPatFrag<(ops node:$in),
3252 (RLDICL $in, 1, 63)> >;
3254 // An extended SETCC with shift amount.
3255 multiclass ExtSetCCShiftPat<CondCode cc, PatFrag pfrag,
3256 OutPatFrag rfrag, OutPatFrag rfrag8> {
3257 def : Pat<(i32 (zext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
3259 def : Pat<(i64 (zext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
3261 def : Pat<(i64 (zext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
3262 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1, $sa), sub_32)>;
3263 def : Pat<(i32 (zext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
3264 (EXTRACT_SUBREG (rfrag8 $s1, $sa), sub_32)>;
3266 def : Pat<(i32 (anyext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
3268 def : Pat<(i64 (anyext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
3270 def : Pat<(i64 (anyext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
3271 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1, $sa), sub_32)>;
3272 def : Pat<(i32 (anyext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
3273 (EXTRACT_SUBREG (rfrag8 $s1, $sa), sub_32)>;
3276 defm : ExtSetCCShiftPat<SETNE,
3277 PatFrag<(ops node:$in, node:$sa, node:$cc),
3278 (setcc (and $in, (shl 1, $sa)), 0, $cc)>,
3279 OutPatFrag<(ops node:$in, node:$sa),
3280 (RLWNM $in, (SUBFIC $sa, 32), 31, 31)>,
3281 OutPatFrag<(ops node:$in, node:$sa),
3282 (RLDCL $in, (SUBFIC $sa, 64), 63)> >;
3284 defm : ExtSetCCShiftPat<SETEQ,
3285 PatFrag<(ops node:$in, node:$sa, node:$cc),
3286 (setcc (and $in, (shl 1, $sa)), 0, $cc)>,
3287 OutPatFrag<(ops node:$in, node:$sa),
3288 (RLWNM (i32not $in),
3289 (SUBFIC $sa, 32), 31, 31)>,
3290 OutPatFrag<(ops node:$in, node:$sa),
3291 (RLDCL (i64not $in),
3292 (SUBFIC $sa, 64), 63)> >;
3295 def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETULT)),
3296 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_lt)>;
3297 def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETLT)),
3298 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_lt)>;
3299 def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETUGT)),
3300 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_gt)>;
3301 def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETGT)),
3302 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_gt)>;
3303 def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETEQ)),
3304 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_eq)>;
3305 def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETEQ)),
3306 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_eq)>;
3308 // For non-equality comparisons, the default code would materialize the
3309 // constant, then compare against it, like this:
3311 // ori r2, r2, 22136
3314 // Since we are just comparing for equality, we can emit this instead:
3315 // xoris r0,r3,0x1234
3316 // cmplwi cr0,r0,0x5678
3319 def : Pat<(i1 (setcc i32:$s1, imm:$imm, SETEQ)),
3320 (EXTRACT_SUBREG (CMPLWI (XORIS $s1, (HI16 imm:$imm)),
3321 (LO16 imm:$imm)), sub_eq)>;
3323 defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETUGE)),
3324 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_lt)>;
3325 defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETGE)),
3326 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_lt)>;
3327 defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETULE)),
3328 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_gt)>;
3329 defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETLE)),
3330 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_gt)>;
3331 defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETNE)),
3332 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_eq)>;
3333 defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETNE)),
3334 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_eq)>;
3336 defm : CRNotPat<(i1 (setcc i32:$s1, imm:$imm, SETNE)),
3337 (EXTRACT_SUBREG (CMPLWI (XORIS $s1, (HI16 imm:$imm)),
3338 (LO16 imm:$imm)), sub_eq)>;
3340 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETULT)),
3341 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_lt)>;
3342 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETLT)),
3343 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_lt)>;
3344 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETUGT)),
3345 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_gt)>;
3346 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETGT)),
3347 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_gt)>;
3348 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETEQ)),
3349 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_eq)>;
3351 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETUGE)),
3352 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_lt)>;
3353 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETGE)),
3354 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_lt)>;
3355 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETULE)),
3356 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_gt)>;
3357 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETLE)),
3358 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_gt)>;
3359 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETNE)),
3360 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_eq)>;
3363 def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETULT)),
3364 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_lt)>;
3365 def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETLT)),
3366 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_lt)>;
3367 def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETUGT)),
3368 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_gt)>;
3369 def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETGT)),
3370 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_gt)>;
3371 def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETEQ)),
3372 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_eq)>;
3373 def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETEQ)),
3374 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_eq)>;
3376 // For non-equality comparisons, the default code would materialize the
3377 // constant, then compare against it, like this:
3379 // ori r2, r2, 22136
3382 // Since we are just comparing for equality, we can emit this instead:
3383 // xoris r0,r3,0x1234
3384 // cmpldi cr0,r0,0x5678
3387 def : Pat<(i1 (setcc i64:$s1, imm64ZExt32:$imm, SETEQ)),
3388 (EXTRACT_SUBREG (CMPLDI (XORIS8 $s1, (HI16 imm:$imm)),
3389 (LO16 imm:$imm)), sub_eq)>;
3391 defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETUGE)),
3392 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_lt)>;
3393 defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETGE)),
3394 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_lt)>;
3395 defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETULE)),
3396 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_gt)>;
3397 defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETLE)),
3398 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_gt)>;
3399 defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETNE)),
3400 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_eq)>;
3401 defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETNE)),
3402 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_eq)>;
3404 defm : CRNotPat<(i1 (setcc i64:$s1, imm64ZExt32:$imm, SETNE)),
3405 (EXTRACT_SUBREG (CMPLDI (XORIS8 $s1, (HI16 imm:$imm)),
3406 (LO16 imm:$imm)), sub_eq)>;
3408 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETULT)),
3409 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_lt)>;
3410 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETLT)),
3411 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_lt)>;
3412 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETUGT)),
3413 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_gt)>;
3414 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETGT)),
3415 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_gt)>;
3416 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETEQ)),
3417 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_eq)>;
3419 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETUGE)),
3420 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_lt)>;
3421 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETGE)),
3422 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_lt)>;
3423 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETULE)),
3424 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_gt)>;
3425 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETLE)),
3426 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_gt)>;
3427 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETNE)),
3428 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_eq)>;
3431 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOLT)),
3432 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3433 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETLT)),
3434 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3435 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOGT)),
3436 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3437 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETGT)),
3438 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3439 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOEQ)),
3440 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3441 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETEQ)),
3442 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3443 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETUO)),
3444 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_un)>;
3446 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETUGE)),
3447 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3448 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETGE)),
3449 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3450 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETULE)),
3451 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3452 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETLE)),
3453 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3454 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETUNE)),
3455 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3456 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETNE)),
3457 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3458 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETO)),
3459 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_un)>;
3462 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOLT)),
3463 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3464 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETLT)),
3465 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3466 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOGT)),
3467 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3468 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETGT)),
3469 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3470 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOEQ)),
3471 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3472 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETEQ)),
3473 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3474 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETUO)),
3475 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_un)>;
3477 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETUGE)),
3478 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3479 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETGE)),
3480 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3481 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETULE)),
3482 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3483 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETLE)),
3484 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3485 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETUNE)),
3486 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3487 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETNE)),
3488 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3489 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETO)),
3490 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_un)>;
3492 // match select on i1 variables:
3493 def : Pat<(i1 (select i1:$cond, i1:$tval, i1:$fval)),
3494 (CROR (CRAND $cond , $tval),
3495 (CRAND (crnot $cond), $fval))>;
3497 // match selectcc on i1 variables:
3498 // select (lhs == rhs), tval, fval is:
3499 // ((lhs == rhs) & tval) | (!(lhs == rhs) & fval)
3500 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETLT)),
3501 (CROR (CRAND (CRANDC $lhs, $rhs), $tval),
3502 (CRAND (CRORC $rhs, $lhs), $fval))>;
3503 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETULT)),
3504 (CROR (CRAND (CRANDC $rhs, $lhs), $tval),
3505 (CRAND (CRORC $lhs, $rhs), $fval))>;
3506 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETLE)),
3507 (CROR (CRAND (CRORC $lhs, $rhs), $tval),
3508 (CRAND (CRANDC $rhs, $lhs), $fval))>;
3509 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETULE)),
3510 (CROR (CRAND (CRORC $rhs, $lhs), $tval),
3511 (CRAND (CRANDC $lhs, $rhs), $fval))>;
3512 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETEQ)),
3513 (CROR (CRAND (CREQV $lhs, $rhs), $tval),
3514 (CRAND (CRXOR $lhs, $rhs), $fval))>;
3515 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETGE)),
3516 (CROR (CRAND (CRORC $rhs, $lhs), $tval),
3517 (CRAND (CRANDC $lhs, $rhs), $fval))>;
3518 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETUGE)),
3519 (CROR (CRAND (CRORC $lhs, $rhs), $tval),
3520 (CRAND (CRANDC $rhs, $lhs), $fval))>;
3521 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETGT)),
3522 (CROR (CRAND (CRANDC $rhs, $lhs), $tval),
3523 (CRAND (CRORC $lhs, $rhs), $fval))>;
3524 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETUGT)),
3525 (CROR (CRAND (CRANDC $lhs, $rhs), $tval),
3526 (CRAND (CRORC $rhs, $lhs), $fval))>;
3527 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETNE)),
3528 (CROR (CRAND (CREQV $lhs, $rhs), $fval),
3529 (CRAND (CRXOR $lhs, $rhs), $tval))>;
3531 // match selectcc on i1 variables with non-i1 output.
3532 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETLT)),
3533 (SELECT_I4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3534 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETULT)),
3535 (SELECT_I4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3536 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETLE)),
3537 (SELECT_I4 (CRORC $lhs, $rhs), $tval, $fval)>;
3538 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETULE)),
3539 (SELECT_I4 (CRORC $rhs, $lhs), $tval, $fval)>;
3540 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETEQ)),
3541 (SELECT_I4 (CREQV $lhs, $rhs), $tval, $fval)>;
3542 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETGE)),
3543 (SELECT_I4 (CRORC $rhs, $lhs), $tval, $fval)>;
3544 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETUGE)),
3545 (SELECT_I4 (CRORC $lhs, $rhs), $tval, $fval)>;
3546 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETGT)),
3547 (SELECT_I4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3548 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETUGT)),
3549 (SELECT_I4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3550 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETNE)),
3551 (SELECT_I4 (CRXOR $lhs, $rhs), $tval, $fval)>;
3553 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETLT)),
3554 (SELECT_I8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3555 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETULT)),
3556 (SELECT_I8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3557 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETLE)),
3558 (SELECT_I8 (CRORC $lhs, $rhs), $tval, $fval)>;
3559 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETULE)),
3560 (SELECT_I8 (CRORC $rhs, $lhs), $tval, $fval)>;
3561 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETEQ)),
3562 (SELECT_I8 (CREQV $lhs, $rhs), $tval, $fval)>;
3563 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETGE)),
3564 (SELECT_I8 (CRORC $rhs, $lhs), $tval, $fval)>;
3565 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETUGE)),
3566 (SELECT_I8 (CRORC $lhs, $rhs), $tval, $fval)>;
3567 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETGT)),
3568 (SELECT_I8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3569 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETUGT)),
3570 (SELECT_I8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3571 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETNE)),
3572 (SELECT_I8 (CRXOR $lhs, $rhs), $tval, $fval)>;
3574 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETLT)),
3575 (SELECT_F4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3576 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETULT)),
3577 (SELECT_F4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3578 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETLE)),
3579 (SELECT_F4 (CRORC $lhs, $rhs), $tval, $fval)>;
3580 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETULE)),
3581 (SELECT_F4 (CRORC $rhs, $lhs), $tval, $fval)>;
3582 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETEQ)),
3583 (SELECT_F4 (CREQV $lhs, $rhs), $tval, $fval)>;
3584 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETGE)),
3585 (SELECT_F4 (CRORC $rhs, $lhs), $tval, $fval)>;
3586 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETUGE)),
3587 (SELECT_F4 (CRORC $lhs, $rhs), $tval, $fval)>;
3588 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETGT)),
3589 (SELECT_F4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3590 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETUGT)),
3591 (SELECT_F4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3592 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETNE)),
3593 (SELECT_F4 (CRXOR $lhs, $rhs), $tval, $fval)>;
3595 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETLT)),
3596 (SELECT_F8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3597 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETULT)),
3598 (SELECT_F8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3599 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETLE)),
3600 (SELECT_F8 (CRORC $lhs, $rhs), $tval, $fval)>;
3601 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETULE)),
3602 (SELECT_F8 (CRORC $rhs, $lhs), $tval, $fval)>;
3603 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETEQ)),
3604 (SELECT_F8 (CREQV $lhs, $rhs), $tval, $fval)>;
3605 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETGE)),
3606 (SELECT_F8 (CRORC $rhs, $lhs), $tval, $fval)>;
3607 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETUGE)),
3608 (SELECT_F8 (CRORC $lhs, $rhs), $tval, $fval)>;
3609 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETGT)),
3610 (SELECT_F8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3611 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETUGT)),
3612 (SELECT_F8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3613 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETNE)),
3614 (SELECT_F8 (CRXOR $lhs, $rhs), $tval, $fval)>;
3616 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETLT)),
3617 (SELECT_VRRC (CRANDC $lhs, $rhs), $tval, $fval)>;
3618 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETULT)),
3619 (SELECT_VRRC (CRANDC $rhs, $lhs), $tval, $fval)>;
3620 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETLE)),
3621 (SELECT_VRRC (CRORC $lhs, $rhs), $tval, $fval)>;
3622 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETULE)),
3623 (SELECT_VRRC (CRORC $rhs, $lhs), $tval, $fval)>;
3624 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETEQ)),
3625 (SELECT_VRRC (CREQV $lhs, $rhs), $tval, $fval)>;
3626 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETGE)),
3627 (SELECT_VRRC (CRORC $rhs, $lhs), $tval, $fval)>;
3628 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETUGE)),
3629 (SELECT_VRRC (CRORC $lhs, $rhs), $tval, $fval)>;
3630 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETGT)),
3631 (SELECT_VRRC (CRANDC $rhs, $lhs), $tval, $fval)>;
3632 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETUGT)),
3633 (SELECT_VRRC (CRANDC $lhs, $rhs), $tval, $fval)>;
3634 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETNE)),
3635 (SELECT_VRRC (CRXOR $lhs, $rhs), $tval, $fval)>;
3637 let usesCustomInserter = 1 in {
3638 def ANDIo_1_EQ_BIT : Pseudo<(outs crbitrc:$dst), (ins gprc:$in),
3640 [(set i1:$dst, (trunc (not i32:$in)))]>;
3641 def ANDIo_1_GT_BIT : Pseudo<(outs crbitrc:$dst), (ins gprc:$in),
3643 [(set i1:$dst, (trunc i32:$in))]>;
3645 def ANDIo_1_EQ_BIT8 : Pseudo<(outs crbitrc:$dst), (ins g8rc:$in),
3647 [(set i1:$dst, (trunc (not i64:$in)))]>;
3648 def ANDIo_1_GT_BIT8 : Pseudo<(outs crbitrc:$dst), (ins g8rc:$in),
3650 [(set i1:$dst, (trunc i64:$in))]>;
3653 def : Pat<(i1 (not (trunc i32:$in))),
3654 (ANDIo_1_EQ_BIT $in)>;
3655 def : Pat<(i1 (not (trunc i64:$in))),
3656 (ANDIo_1_EQ_BIT8 $in)>;
3658 //===----------------------------------------------------------------------===//
3659 // PowerPC Instructions used for assembler/disassembler only
3662 // FIXME: For B=0 or B > 8, the registers following RT are used.
3663 // WARNING: Do not add patterns for this instruction without fixing this.
3664 def LSWI : XForm_base_r3xo<31, 597, (outs gprc:$RT), (ins gprc:$A, u5imm:$B),
3665 "lswi $RT, $A, $B", IIC_LdStLoad, []>;
3667 // FIXME: For B=0 or B > 8, the registers following RT are used.
3668 // WARNING: Do not add patterns for this instruction without fixing this.
3669 def STSWI : XForm_base_r3xo<31, 725, (outs), (ins gprc:$RT, gprc:$A, u5imm:$B),
3670 "stswi $RT, $A, $B", IIC_LdStLoad, []>;
3672 def ISYNC : XLForm_2_ext<19, 150, 0, 0, 0, (outs), (ins),
3673 "isync", IIC_SprISYNC, []>;
3675 def ICBI : XForm_1a<31, 982, (outs), (ins memrr:$src),
3676 "icbi $src", IIC_LdStICBI, []>;
3678 // We used to have EIEIO as value but E[0-9A-Z] is a reserved name
3679 def EnforceIEIO : XForm_24_eieio<31, 854, (outs), (ins),
3680 "eieio", IIC_LdStLoad, []>;
3682 def WAIT : XForm_24_sync<31, 62, (outs), (ins i32imm:$L),
3683 "wait $L", IIC_LdStLoad, []>;
3685 def MBAR : XForm_mbar<31, 854, (outs), (ins u5imm:$MO),
3686 "mbar $MO", IIC_LdStLoad>, Requires<[IsBookE]>;
3688 def MTSR: XForm_sr<31, 210, (outs), (ins gprc:$RS, u4imm:$SR),
3689 "mtsr $SR, $RS", IIC_SprMTSR>;
3691 def MFSR: XForm_sr<31, 595, (outs gprc:$RS), (ins u4imm:$SR),
3692 "mfsr $RS, $SR", IIC_SprMFSR>;
3694 def MTSRIN: XForm_srin<31, 242, (outs), (ins gprc:$RS, gprc:$RB),
3695 "mtsrin $RS, $RB", IIC_SprMTSR>;
3697 def MFSRIN: XForm_srin<31, 659, (outs gprc:$RS), (ins gprc:$RB),
3698 "mfsrin $RS, $RB", IIC_SprMFSR>;
3700 def MTMSR: XForm_mtmsr<31, 146, (outs), (ins gprc:$RS, i32imm:$L),
3701 "mtmsr $RS, $L", IIC_SprMTMSR>;
3703 def WRTEE: XForm_mtmsr<31, 131, (outs), (ins gprc:$RS),
3704 "wrtee $RS", IIC_SprMTMSR>, Requires<[IsBookE]> {
3708 def WRTEEI: I<31, (outs), (ins i1imm:$E), "wrteei $E", IIC_SprMTMSR>,
3709 Requires<[IsBookE]> {
3713 let Inst{21-30} = 163;
3716 def DCCCI : XForm_tlb<454, (outs), (ins gprc:$A, gprc:$B),
3717 "dccci $A, $B", IIC_LdStLoad>, Requires<[IsPPC4xx]>;
3718 def ICCCI : XForm_tlb<966, (outs), (ins gprc:$A, gprc:$B),
3719 "iccci $A, $B", IIC_LdStLoad>, Requires<[IsPPC4xx]>;
3721 def : InstAlias<"dci 0", (DCCCI R0, R0)>, Requires<[IsPPC4xx]>;
3722 def : InstAlias<"dccci", (DCCCI R0, R0)>, Requires<[IsPPC4xx]>;
3723 def : InstAlias<"ici 0", (ICCCI R0, R0)>, Requires<[IsPPC4xx]>;
3724 def : InstAlias<"iccci", (ICCCI R0, R0)>, Requires<[IsPPC4xx]>;
3726 def MFMSR : XForm_rs<31, 83, (outs gprc:$RT), (ins),
3727 "mfmsr $RT", IIC_SprMFMSR, []>;
3729 def MTMSRD : XForm_mtmsr<31, 178, (outs), (ins gprc:$RS, i32imm:$L),
3730 "mtmsrd $RS, $L", IIC_SprMTMSRD>;
3732 def MCRFS : XLForm_3<63, 64, (outs crrc:$BF), (ins crrc:$BFA),
3733 "mcrfs $BF, $BFA", IIC_BrMCR>;
3735 def MTFSFI : XLForm_4<63, 134, (outs crrc:$BF), (ins i32imm:$U, i32imm:$W),
3736 "mtfsfi $BF, $U, $W", IIC_IntMFFS>;
3738 def MTFSFIo : XLForm_4<63, 134, (outs crrc:$BF), (ins i32imm:$U, i32imm:$W),
3739 "mtfsfi. $BF, $U, $W", IIC_IntMFFS>, isDOT;
3741 def : InstAlias<"mtfsfi $BF, $U", (MTFSFI crrc:$BF, i32imm:$U, 0)>;
3742 def : InstAlias<"mtfsfi. $BF, $U", (MTFSFIo crrc:$BF, i32imm:$U, 0)>;
3744 def MTFSF : XFLForm_1<63, 711, (outs),
3745 (ins i32imm:$FLM, f8rc:$FRB, i32imm:$L, i32imm:$W),
3746 "mtfsf $FLM, $FRB, $L, $W", IIC_IntMFFS, []>;
3747 def MTFSFo : XFLForm_1<63, 711, (outs),
3748 (ins i32imm:$FLM, f8rc:$FRB, i32imm:$L, i32imm:$W),
3749 "mtfsf. $FLM, $FRB, $L, $W", IIC_IntMFFS, []>, isDOT;
3751 def : InstAlias<"mtfsf $FLM, $FRB", (MTFSF i32imm:$FLM, f8rc:$FRB, 0, 0)>;
3752 def : InstAlias<"mtfsf. $FLM, $FRB", (MTFSFo i32imm:$FLM, f8rc:$FRB, 0, 0)>;
3754 def SLBIE : XForm_16b<31, 434, (outs), (ins gprc:$RB),
3755 "slbie $RB", IIC_SprSLBIE, []>;
3757 def SLBMTE : XForm_26<31, 402, (outs), (ins gprc:$RS, gprc:$RB),
3758 "slbmte $RS, $RB", IIC_SprSLBMTE, []>;
3760 def SLBMFEE : XForm_26<31, 915, (outs gprc:$RT), (ins gprc:$RB),
3761 "slbmfee $RT, $RB", IIC_SprSLBMFEE, []>;
3763 def SLBMFEV : XLForm_1_gen<31, 851, (outs gprc:$RT), (ins gprc:$RB),
3764 "slbmfev $RT, $RB", IIC_SprSLBMFEV, []>;
3766 def SLBIA : XForm_0<31, 498, (outs), (ins), "slbia", IIC_SprSLBIA, []>;
3768 def TLBIA : XForm_0<31, 370, (outs), (ins),
3769 "tlbia", IIC_SprTLBIA, []>;
3771 def TLBSYNC : XForm_0<31, 566, (outs), (ins),
3772 "tlbsync", IIC_SprTLBSYNC, []>;
3774 def TLBIEL : XForm_16b<31, 274, (outs), (ins gprc:$RB),
3775 "tlbiel $RB", IIC_SprTLBIEL, []>;
3777 def TLBLD : XForm_16b<31, 978, (outs), (ins gprc:$RB),
3778 "tlbld $RB", IIC_LdStLoad, []>, Requires<[IsPPC6xx]>;
3779 def TLBLI : XForm_16b<31, 1010, (outs), (ins gprc:$RB),
3780 "tlbli $RB", IIC_LdStLoad, []>, Requires<[IsPPC6xx]>;
3782 def TLBIE : XForm_26<31, 306, (outs), (ins gprc:$RS, gprc:$RB),
3783 "tlbie $RB,$RS", IIC_SprTLBIE, []>;
3785 def TLBSX : XForm_tlb<914, (outs), (ins gprc:$A, gprc:$B), "tlbsx $A, $B",
3786 IIC_LdStLoad>, Requires<[IsBookE]>;
3788 def TLBIVAX : XForm_tlb<786, (outs), (ins gprc:$A, gprc:$B), "tlbivax $A, $B",
3789 IIC_LdStLoad>, Requires<[IsBookE]>;
3791 def TLBRE : XForm_24_eieio<31, 946, (outs), (ins),
3792 "tlbre", IIC_LdStLoad, []>, Requires<[IsBookE]>;
3794 def TLBWE : XForm_24_eieio<31, 978, (outs), (ins),
3795 "tlbwe", IIC_LdStLoad, []>, Requires<[IsBookE]>;
3797 def TLBRE2 : XForm_tlbws<31, 946, (outs gprc:$RS), (ins gprc:$A, i1imm:$WS),
3798 "tlbre $RS, $A, $WS", IIC_LdStLoad, []>, Requires<[IsPPC4xx]>;
3800 def TLBWE2 : XForm_tlbws<31, 978, (outs), (ins gprc:$RS, gprc:$A, i1imm:$WS),
3801 "tlbwe $RS, $A, $WS", IIC_LdStLoad, []>, Requires<[IsPPC4xx]>;
3803 def TLBSX2 : XForm_base_r3xo<31, 914, (outs), (ins gprc:$RST, gprc:$A, gprc:$B),
3804 "tlbsx $RST, $A, $B", IIC_LdStLoad, []>,
3805 Requires<[IsPPC4xx]>;
3806 def TLBSX2D : XForm_base_r3xo<31, 914, (outs),
3807 (ins gprc:$RST, gprc:$A, gprc:$B),
3808 "tlbsx. $RST, $A, $B", IIC_LdStLoad, []>,
3809 Requires<[IsPPC4xx]>, isDOT;
3811 def RFID : XForm_0<19, 18, (outs), (ins), "rfid", IIC_IntRFID, []>;
3813 def RFI : XForm_0<19, 50, (outs), (ins), "rfi", IIC_SprRFI, []>,
3814 Requires<[IsBookE]>;
3815 def RFCI : XForm_0<19, 51, (outs), (ins), "rfci", IIC_BrB, []>,
3816 Requires<[IsBookE]>;
3818 def RFDI : XForm_0<19, 39, (outs), (ins), "rfdi", IIC_BrB, []>,
3820 def RFMCI : XForm_0<19, 38, (outs), (ins), "rfmci", IIC_BrB, []>,
3823 def MFDCR : XFXForm_1<31, 323, (outs gprc:$RT), (ins i32imm:$SPR),
3824 "mfdcr $RT, $SPR", IIC_SprMFSPR>, Requires<[IsPPC4xx]>;
3825 def MTDCR : XFXForm_1<31, 451, (outs), (ins gprc:$RT, i32imm:$SPR),
3826 "mtdcr $SPR, $RT", IIC_SprMTSPR>, Requires<[IsPPC4xx]>;
3828 def HRFID : XLForm_1_np<19, 274, (outs), (ins), "hrfid", IIC_BrB, []>;
3829 def NAP : XLForm_1_np<19, 434, (outs), (ins), "nap", IIC_BrB, []>;
3831 def ATTN : XForm_attn<0, 256, (outs), (ins), "attn", IIC_BrB>;
3833 def LBZCIX : XForm_base_r3xo<31, 853, (outs gprc:$RST), (ins gprc:$A, gprc:$B),
3834 "lbzcix $RST, $A, $B", IIC_LdStLoad, []>;
3835 def LHZCIX : XForm_base_r3xo<31, 821, (outs gprc:$RST), (ins gprc:$A, gprc:$B),
3836 "lhzcix $RST, $A, $B", IIC_LdStLoad, []>;
3837 def LWZCIX : XForm_base_r3xo<31, 789, (outs gprc:$RST), (ins gprc:$A, gprc:$B),
3838 "lwzcix $RST, $A, $B", IIC_LdStLoad, []>;
3839 def LDCIX : XForm_base_r3xo<31, 885, (outs gprc:$RST), (ins gprc:$A, gprc:$B),
3840 "ldcix $RST, $A, $B", IIC_LdStLoad, []>;
3842 def STBCIX : XForm_base_r3xo<31, 981, (outs), (ins gprc:$RST, gprc:$A, gprc:$B),
3843 "stbcix $RST, $A, $B", IIC_LdStLoad, []>;
3844 def STHCIX : XForm_base_r3xo<31, 949, (outs), (ins gprc:$RST, gprc:$A, gprc:$B),
3845 "sthcix $RST, $A, $B", IIC_LdStLoad, []>;
3846 def STWCIX : XForm_base_r3xo<31, 917, (outs), (ins gprc:$RST, gprc:$A, gprc:$B),
3847 "stwcix $RST, $A, $B", IIC_LdStLoad, []>;
3848 def STDCIX : XForm_base_r3xo<31, 1013, (outs), (ins gprc:$RST, gprc:$A, gprc:$B),
3849 "stdcix $RST, $A, $B", IIC_LdStLoad, []>;
3851 //===----------------------------------------------------------------------===//
3852 // PowerPC Assembler Instruction Aliases
3855 // Pseudo-instructions for alternate assembly syntax (never used by codegen).
3856 // These are aliases that require C++ handling to convert to the target
3857 // instruction, while InstAliases can be handled directly by tblgen.
3858 class PPCAsmPseudo<string asm, dag iops>
3860 let Namespace = "PPC";
3861 bit PPC64 = 0; // Default value, override with isPPC64
3863 let OutOperandList = (outs);
3864 let InOperandList = iops;
3866 let AsmString = asm;
3867 let isAsmParserOnly = 1;
3871 def : InstAlias<"sc", (SC 0)>;
3873 def : InstAlias<"sync", (SYNC 0)>, Requires<[HasSYNC]>;
3874 def : InstAlias<"msync", (SYNC 0), 0>, Requires<[HasSYNC]>;
3875 def : InstAlias<"lwsync", (SYNC 1)>, Requires<[HasSYNC]>;
3876 def : InstAlias<"ptesync", (SYNC 2)>, Requires<[HasSYNC]>;
3878 def : InstAlias<"wait", (WAIT 0)>;
3879 def : InstAlias<"waitrsv", (WAIT 1)>;
3880 def : InstAlias<"waitimpl", (WAIT 2)>;
3882 def : InstAlias<"mbar", (MBAR 0)>, Requires<[IsBookE]>;
3884 def DCBTx : PPCAsmPseudo<"dcbt $dst", (ins memrr:$dst)>;
3885 def DCBTSTx : PPCAsmPseudo<"dcbtst $dst", (ins memrr:$dst)>;
3887 def DCBTCT : PPCAsmPseudo<"dcbtct $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
3888 def DCBTDS : PPCAsmPseudo<"dcbtds $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
3889 def DCBTT : PPCAsmPseudo<"dcbtt $dst", (ins memrr:$dst)>;
3891 def DCBTSTCT : PPCAsmPseudo<"dcbtstct $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
3892 def DCBTSTDS : PPCAsmPseudo<"dcbtstds $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
3893 def DCBTSTT : PPCAsmPseudo<"dcbtstt $dst", (ins memrr:$dst)>;
3895 def DCBFx : PPCAsmPseudo<"dcbf $dst", (ins memrr:$dst)>;
3896 def DCBFL : PPCAsmPseudo<"dcbfl $dst", (ins memrr:$dst)>;
3897 def DCBFLP : PPCAsmPseudo<"dcbflp $dst", (ins memrr:$dst)>;
3899 def : InstAlias<"crset $bx", (CREQV crbitrc:$bx, crbitrc:$bx, crbitrc:$bx)>;
3900 def : InstAlias<"crclr $bx", (CRXOR crbitrc:$bx, crbitrc:$bx, crbitrc:$bx)>;
3901 def : InstAlias<"crmove $bx, $by", (CROR crbitrc:$bx, crbitrc:$by, crbitrc:$by)>;
3902 def : InstAlias<"crnot $bx, $by", (CRNOR crbitrc:$bx, crbitrc:$by, crbitrc:$by)>;
3904 def : InstAlias<"mtxer $Rx", (MTSPR 1, gprc:$Rx)>;
3905 def : InstAlias<"mfxer $Rx", (MFSPR gprc:$Rx, 1)>;
3907 def : InstAlias<"mfrtcu $Rx", (MFSPR gprc:$Rx, 4)>;
3908 def : InstAlias<"mfrtcl $Rx", (MFSPR gprc:$Rx, 5)>;
3910 def : InstAlias<"mtdscr $Rx", (MTSPR 17, gprc:$Rx)>;
3911 def : InstAlias<"mfdscr $Rx", (MFSPR gprc:$Rx, 17)>;
3913 def : InstAlias<"mtdsisr $Rx", (MTSPR 18, gprc:$Rx)>;
3914 def : InstAlias<"mfdsisr $Rx", (MFSPR gprc:$Rx, 18)>;
3916 def : InstAlias<"mtdar $Rx", (MTSPR 19, gprc:$Rx)>;
3917 def : InstAlias<"mfdar $Rx", (MFSPR gprc:$Rx, 19)>;
3919 def : InstAlias<"mtdec $Rx", (MTSPR 22, gprc:$Rx)>;
3920 def : InstAlias<"mfdec $Rx", (MFSPR gprc:$Rx, 22)>;
3922 def : InstAlias<"mtsdr1 $Rx", (MTSPR 25, gprc:$Rx)>;
3923 def : InstAlias<"mfsdr1 $Rx", (MFSPR gprc:$Rx, 25)>;
3925 def : InstAlias<"mtsrr0 $Rx", (MTSPR 26, gprc:$Rx)>;
3926 def : InstAlias<"mfsrr0 $Rx", (MFSPR gprc:$Rx, 26)>;
3928 def : InstAlias<"mtsrr1 $Rx", (MTSPR 27, gprc:$Rx)>;
3929 def : InstAlias<"mfsrr1 $Rx", (MFSPR gprc:$Rx, 27)>;
3931 def : InstAlias<"mtsrr2 $Rx", (MTSPR 990, gprc:$Rx)>, Requires<[IsPPC4xx]>;
3932 def : InstAlias<"mfsrr2 $Rx", (MFSPR gprc:$Rx, 990)>, Requires<[IsPPC4xx]>;
3934 def : InstAlias<"mtsrr3 $Rx", (MTSPR 991, gprc:$Rx)>, Requires<[IsPPC4xx]>;
3935 def : InstAlias<"mfsrr3 $Rx", (MFSPR gprc:$Rx, 991)>, Requires<[IsPPC4xx]>;
3937 def : InstAlias<"mtcfar $Rx", (MTSPR 28, gprc:$Rx)>;
3938 def : InstAlias<"mfcfar $Rx", (MFSPR gprc:$Rx, 28)>;
3940 def : InstAlias<"mtamr $Rx", (MTSPR 29, gprc:$Rx)>;
3941 def : InstAlias<"mfamr $Rx", (MFSPR gprc:$Rx, 29)>;
3943 def : InstAlias<"mtpid $Rx", (MTSPR 48, gprc:$Rx)>, Requires<[IsBookE]>;
3944 def : InstAlias<"mfpid $Rx", (MFSPR gprc:$Rx, 48)>, Requires<[IsBookE]>;
3946 def : InstAlias<"mftb $Rx", (MFTB gprc:$Rx, 268)>;
3947 def : InstAlias<"mftbl $Rx", (MFTB gprc:$Rx, 268)>;
3948 def : InstAlias<"mftbu $Rx", (MFTB gprc:$Rx, 269)>;
3950 def : InstAlias<"mttbl $Rx", (MTSPR 284, gprc:$Rx)>;
3951 def : InstAlias<"mttbu $Rx", (MTSPR 285, gprc:$Rx)>;
3953 def : InstAlias<"mftblo $Rx", (MFSPR gprc:$Rx, 989)>, Requires<[IsPPC4xx]>;
3954 def : InstAlias<"mttblo $Rx", (MTSPR 989, gprc:$Rx)>, Requires<[IsPPC4xx]>;
3955 def : InstAlias<"mftbhi $Rx", (MFSPR gprc:$Rx, 988)>, Requires<[IsPPC4xx]>;
3956 def : InstAlias<"mttbhi $Rx", (MTSPR 988, gprc:$Rx)>, Requires<[IsPPC4xx]>;
3958 def : InstAlias<"xnop", (XORI R0, R0, 0)>;
3960 def : InstAlias<"mr $rA, $rB", (OR8 g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
3961 def : InstAlias<"mr. $rA, $rB", (OR8o g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
3963 def : InstAlias<"not $rA, $rB", (NOR8 g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
3964 def : InstAlias<"not. $rA, $rB", (NOR8o g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
3966 def : InstAlias<"mtcr $rA", (MTCRF8 255, g8rc:$rA)>;
3968 foreach BATR = 0-3 in {
3969 def : InstAlias<"mtdbatu "#BATR#", $Rx",
3970 (MTSPR !add(BATR, !add(BATR, 536)), gprc:$Rx)>,
3971 Requires<[IsPPC6xx]>;
3972 def : InstAlias<"mfdbatu $Rx, "#BATR,
3973 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 536)))>,
3974 Requires<[IsPPC6xx]>;
3975 def : InstAlias<"mtdbatl "#BATR#", $Rx",
3976 (MTSPR !add(BATR, !add(BATR, 537)), gprc:$Rx)>,
3977 Requires<[IsPPC6xx]>;
3978 def : InstAlias<"mfdbatl $Rx, "#BATR,
3979 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 537)))>,
3980 Requires<[IsPPC6xx]>;
3981 def : InstAlias<"mtibatu "#BATR#", $Rx",
3982 (MTSPR !add(BATR, !add(BATR, 528)), gprc:$Rx)>,
3983 Requires<[IsPPC6xx]>;
3984 def : InstAlias<"mfibatu $Rx, "#BATR,
3985 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 528)))>,
3986 Requires<[IsPPC6xx]>;
3987 def : InstAlias<"mtibatl "#BATR#", $Rx",
3988 (MTSPR !add(BATR, !add(BATR, 529)), gprc:$Rx)>,
3989 Requires<[IsPPC6xx]>;
3990 def : InstAlias<"mfibatl $Rx, "#BATR,
3991 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 529)))>,
3992 Requires<[IsPPC6xx]>;
3995 foreach BR = 0-7 in {
3996 def : InstAlias<"mfbr"#BR#" $Rx",
3997 (MFDCR gprc:$Rx, !add(BR, 0x80))>,
3998 Requires<[IsPPC4xx]>;
3999 def : InstAlias<"mtbr"#BR#" $Rx",
4000 (MTDCR gprc:$Rx, !add(BR, 0x80))>,
4001 Requires<[IsPPC4xx]>;
4004 def : InstAlias<"mtdccr $Rx", (MTSPR 1018, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4005 def : InstAlias<"mfdccr $Rx", (MFSPR gprc:$Rx, 1018)>, Requires<[IsPPC4xx]>;
4007 def : InstAlias<"mticcr $Rx", (MTSPR 1019, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4008 def : InstAlias<"mficcr $Rx", (MFSPR gprc:$Rx, 1019)>, Requires<[IsPPC4xx]>;
4010 def : InstAlias<"mtdear $Rx", (MTSPR 981, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4011 def : InstAlias<"mfdear $Rx", (MFSPR gprc:$Rx, 981)>, Requires<[IsPPC4xx]>;
4013 def : InstAlias<"mtesr $Rx", (MTSPR 980, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4014 def : InstAlias<"mfesr $Rx", (MFSPR gprc:$Rx, 980)>, Requires<[IsPPC4xx]>;
4016 def : InstAlias<"mfspefscr $Rx", (MFSPR gprc:$Rx, 512)>;
4017 def : InstAlias<"mtspefscr $Rx", (MTSPR 512, gprc:$Rx)>;
4019 def : InstAlias<"mttcr $Rx", (MTSPR 986, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4020 def : InstAlias<"mftcr $Rx", (MFSPR gprc:$Rx, 986)>, Requires<[IsPPC4xx]>;
4022 def LAx : PPCAsmPseudo<"la $rA, $addr", (ins gprc:$rA, memri:$addr)>;
4024 def SUBI : PPCAsmPseudo<"subi $rA, $rB, $imm",
4025 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4026 def SUBIS : PPCAsmPseudo<"subis $rA, $rB, $imm",
4027 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4028 def SUBIC : PPCAsmPseudo<"subic $rA, $rB, $imm",
4029 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4030 def SUBICo : PPCAsmPseudo<"subic. $rA, $rB, $imm",
4031 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4033 def : InstAlias<"sub $rA, $rB, $rC", (SUBF8 g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
4034 def : InstAlias<"sub. $rA, $rB, $rC", (SUBF8o g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
4035 def : InstAlias<"subc $rA, $rB, $rC", (SUBFC8 g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
4036 def : InstAlias<"subc. $rA, $rB, $rC", (SUBFC8o g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
4038 def : InstAlias<"mtmsrd $RS", (MTMSRD gprc:$RS, 0)>;
4039 def : InstAlias<"mtmsr $RS", (MTMSR gprc:$RS, 0)>;
4041 def : InstAlias<"mfasr $RT", (MFSPR gprc:$RT, 280)>;
4042 def : InstAlias<"mtasr $RT", (MTSPR 280, gprc:$RT)>;
4044 foreach SPRG = 0-3 in {
4045 def : InstAlias<"mfsprg $RT, "#SPRG, (MFSPR gprc:$RT, !add(SPRG, 272))>;
4046 def : InstAlias<"mfsprg"#SPRG#" $RT", (MFSPR gprc:$RT, !add(SPRG, 272))>;
4047 def : InstAlias<"mtsprg "#SPRG#", $RT", (MTSPR !add(SPRG, 272), gprc:$RT)>;
4048 def : InstAlias<"mtsprg"#SPRG#" $RT", (MTSPR !add(SPRG, 272), gprc:$RT)>;
4050 foreach SPRG = 4-7 in {
4051 def : InstAlias<"mfsprg $RT, "#SPRG, (MFSPR gprc:$RT, !add(SPRG, 256))>,
4052 Requires<[IsBookE]>;
4053 def : InstAlias<"mfsprg"#SPRG#" $RT", (MFSPR gprc:$RT, !add(SPRG, 256))>,
4054 Requires<[IsBookE]>;
4055 def : InstAlias<"mtsprg "#SPRG#", $RT", (MTSPR !add(SPRG, 256), gprc:$RT)>,
4056 Requires<[IsBookE]>;
4057 def : InstAlias<"mtsprg"#SPRG#" $RT", (MTSPR !add(SPRG, 256), gprc:$RT)>,
4058 Requires<[IsBookE]>;
4061 def : InstAlias<"mtasr $RS", (MTSPR 280, gprc:$RS)>;
4063 def : InstAlias<"mfdec $RT", (MFSPR gprc:$RT, 22)>;
4064 def : InstAlias<"mtdec $RT", (MTSPR 22, gprc:$RT)>;
4066 def : InstAlias<"mfpvr $RT", (MFSPR gprc:$RT, 287)>;
4068 def : InstAlias<"mfsdr1 $RT", (MFSPR gprc:$RT, 25)>;
4069 def : InstAlias<"mtsdr1 $RT", (MTSPR 25, gprc:$RT)>;
4071 def : InstAlias<"mfsrr0 $RT", (MFSPR gprc:$RT, 26)>;
4072 def : InstAlias<"mfsrr1 $RT", (MFSPR gprc:$RT, 27)>;
4073 def : InstAlias<"mtsrr0 $RT", (MTSPR 26, gprc:$RT)>;
4074 def : InstAlias<"mtsrr1 $RT", (MTSPR 27, gprc:$RT)>;
4076 def : InstAlias<"tlbie $RB", (TLBIE R0, gprc:$RB)>;
4078 def : InstAlias<"tlbrehi $RS, $A", (TLBRE2 gprc:$RS, gprc:$A, 0)>,
4079 Requires<[IsPPC4xx]>;
4080 def : InstAlias<"tlbrelo $RS, $A", (TLBRE2 gprc:$RS, gprc:$A, 1)>,
4081 Requires<[IsPPC4xx]>;
4082 def : InstAlias<"tlbwehi $RS, $A", (TLBWE2 gprc:$RS, gprc:$A, 0)>,
4083 Requires<[IsPPC4xx]>;
4084 def : InstAlias<"tlbwelo $RS, $A", (TLBWE2 gprc:$RS, gprc:$A, 1)>,
4085 Requires<[IsPPC4xx]>;
4087 def EXTLWI : PPCAsmPseudo<"extlwi $rA, $rS, $n, $b",
4088 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4089 def EXTLWIo : PPCAsmPseudo<"extlwi. $rA, $rS, $n, $b",
4090 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4091 def EXTRWI : PPCAsmPseudo<"extrwi $rA, $rS, $n, $b",
4092 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4093 def EXTRWIo : PPCAsmPseudo<"extrwi. $rA, $rS, $n, $b",
4094 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4095 def INSLWI : PPCAsmPseudo<"inslwi $rA, $rS, $n, $b",
4096 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4097 def INSLWIo : PPCAsmPseudo<"inslwi. $rA, $rS, $n, $b",
4098 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4099 def INSRWI : PPCAsmPseudo<"insrwi $rA, $rS, $n, $b",
4100 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4101 def INSRWIo : PPCAsmPseudo<"insrwi. $rA, $rS, $n, $b",
4102 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4103 def ROTRWI : PPCAsmPseudo<"rotrwi $rA, $rS, $n",
4104 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4105 def ROTRWIo : PPCAsmPseudo<"rotrwi. $rA, $rS, $n",
4106 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4107 def SLWI : PPCAsmPseudo<"slwi $rA, $rS, $n",
4108 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4109 def SLWIo : PPCAsmPseudo<"slwi. $rA, $rS, $n",
4110 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4111 def SRWI : PPCAsmPseudo<"srwi $rA, $rS, $n",
4112 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4113 def SRWIo : PPCAsmPseudo<"srwi. $rA, $rS, $n",
4114 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4115 def CLRRWI : PPCAsmPseudo<"clrrwi $rA, $rS, $n",
4116 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4117 def CLRRWIo : PPCAsmPseudo<"clrrwi. $rA, $rS, $n",
4118 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4119 def CLRLSLWI : PPCAsmPseudo<"clrlslwi $rA, $rS, $b, $n",
4120 (ins gprc:$rA, gprc:$rS, u5imm:$b, u5imm:$n)>;
4121 def CLRLSLWIo : PPCAsmPseudo<"clrlslwi. $rA, $rS, $b, $n",
4122 (ins gprc:$rA, gprc:$rS, u5imm:$b, u5imm:$n)>;
4124 def : InstAlias<"rotlwi $rA, $rS, $n", (RLWINM gprc:$rA, gprc:$rS, u5imm:$n, 0, 31)>;
4125 def : InstAlias<"rotlwi. $rA, $rS, $n", (RLWINMo gprc:$rA, gprc:$rS, u5imm:$n, 0, 31)>;
4126 def : InstAlias<"rotlw $rA, $rS, $rB", (RLWNM gprc:$rA, gprc:$rS, gprc:$rB, 0, 31)>;
4127 def : InstAlias<"rotlw. $rA, $rS, $rB", (RLWNMo gprc:$rA, gprc:$rS, gprc:$rB, 0, 31)>;
4128 def : InstAlias<"clrlwi $rA, $rS, $n", (RLWINM gprc:$rA, gprc:$rS, 0, u5imm:$n, 31)>;
4129 def : InstAlias<"clrlwi. $rA, $rS, $n", (RLWINMo gprc:$rA, gprc:$rS, 0, u5imm:$n, 31)>;
4131 def : InstAlias<"cntlzw $rA, $rS", (CNTLZW gprc:$rA, gprc:$rS)>;
4132 def : InstAlias<"cntlzw. $rA, $rS", (CNTLZWo gprc:$rA, gprc:$rS)>;
4133 // The POWER variant
4134 def : MnemonicAlias<"cntlz", "cntlzw">;
4135 def : MnemonicAlias<"cntlz.", "cntlzw.">;
4137 def EXTLDI : PPCAsmPseudo<"extldi $rA, $rS, $n, $b",
4138 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4139 def EXTLDIo : PPCAsmPseudo<"extldi. $rA, $rS, $n, $b",
4140 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4141 def EXTRDI : PPCAsmPseudo<"extrdi $rA, $rS, $n, $b",
4142 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4143 def EXTRDIo : PPCAsmPseudo<"extrdi. $rA, $rS, $n, $b",
4144 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4145 def INSRDI : PPCAsmPseudo<"insrdi $rA, $rS, $n, $b",
4146 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4147 def INSRDIo : PPCAsmPseudo<"insrdi. $rA, $rS, $n, $b",
4148 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4149 def ROTRDI : PPCAsmPseudo<"rotrdi $rA, $rS, $n",
4150 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4151 def ROTRDIo : PPCAsmPseudo<"rotrdi. $rA, $rS, $n",
4152 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4153 def SLDI : PPCAsmPseudo<"sldi $rA, $rS, $n",
4154 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4155 def SLDIo : PPCAsmPseudo<"sldi. $rA, $rS, $n",
4156 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4157 def SRDI : PPCAsmPseudo<"srdi $rA, $rS, $n",
4158 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4159 def SRDIo : PPCAsmPseudo<"srdi. $rA, $rS, $n",
4160 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4161 def CLRRDI : PPCAsmPseudo<"clrrdi $rA, $rS, $n",
4162 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4163 def CLRRDIo : PPCAsmPseudo<"clrrdi. $rA, $rS, $n",
4164 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4165 def CLRLSLDI : PPCAsmPseudo<"clrlsldi $rA, $rS, $b, $n",
4166 (ins g8rc:$rA, g8rc:$rS, u6imm:$b, u6imm:$n)>;
4167 def CLRLSLDIo : PPCAsmPseudo<"clrlsldi. $rA, $rS, $b, $n",
4168 (ins g8rc:$rA, g8rc:$rS, u6imm:$b, u6imm:$n)>;
4170 def : InstAlias<"rotldi $rA, $rS, $n", (RLDICL g8rc:$rA, g8rc:$rS, u6imm:$n, 0)>;
4171 def : InstAlias<"rotldi. $rA, $rS, $n", (RLDICLo g8rc:$rA, g8rc:$rS, u6imm:$n, 0)>;
4172 def : InstAlias<"rotld $rA, $rS, $rB", (RLDCL g8rc:$rA, g8rc:$rS, gprc:$rB, 0)>;
4173 def : InstAlias<"rotld. $rA, $rS, $rB", (RLDCLo g8rc:$rA, g8rc:$rS, gprc:$rB, 0)>;
4174 def : InstAlias<"clrldi $rA, $rS, $n", (RLDICL g8rc:$rA, g8rc:$rS, 0, u6imm:$n)>;
4175 def : InstAlias<"clrldi $rA, $rS, $n",
4176 (RLDICL_32 gprc:$rA, gprc:$rS, 0, u6imm:$n)>;
4177 def : InstAlias<"clrldi. $rA, $rS, $n", (RLDICLo g8rc:$rA, g8rc:$rS, 0, u6imm:$n)>;
4179 def RLWINMbm : PPCAsmPseudo<"rlwinm $rA, $rS, $n, $b",
4180 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4181 def RLWINMobm : PPCAsmPseudo<"rlwinm. $rA, $rS, $n, $b",
4182 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4183 def RLWIMIbm : PPCAsmPseudo<"rlwimi $rA, $rS, $n, $b",
4184 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4185 def RLWIMIobm : PPCAsmPseudo<"rlwimi. $rA, $rS, $n, $b",
4186 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4187 def RLWNMbm : PPCAsmPseudo<"rlwnm $rA, $rS, $n, $b",
4188 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4189 def RLWNMobm : PPCAsmPseudo<"rlwnm. $rA, $rS, $n, $b",
4190 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4192 // These generic branch instruction forms are used for the assembler parser only.
4193 // Defs and Uses are conservative, since we don't know the BO value.
4194 let PPC970_Unit = 7 in {
4195 let Defs = [CTR], Uses = [CTR, RM] in {
4196 def gBC : BForm_3<16, 0, 0, (outs),
4197 (ins u5imm:$bo, crbitrc:$bi, condbrtarget:$dst),
4198 "bc $bo, $bi, $dst">;
4199 def gBCA : BForm_3<16, 1, 0, (outs),
4200 (ins u5imm:$bo, crbitrc:$bi, abscondbrtarget:$dst),
4201 "bca $bo, $bi, $dst">;
4202 let isAsmParserOnly = 1 in {
4203 def gBCat : BForm_3_at<16, 0, 0, (outs),
4204 (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
4206 "bc$at $bo, $bi, $dst">;
4207 def gBCAat : BForm_3_at<16, 1, 0, (outs),
4208 (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
4209 abscondbrtarget:$dst),
4210 "bca$at $bo, $bi, $dst">;
4211 } // isAsmParserOnly = 1
4213 let Defs = [LR, CTR], Uses = [CTR, RM] in {
4214 def gBCL : BForm_3<16, 0, 1, (outs),
4215 (ins u5imm:$bo, crbitrc:$bi, condbrtarget:$dst),
4216 "bcl $bo, $bi, $dst">;
4217 def gBCLA : BForm_3<16, 1, 1, (outs),
4218 (ins u5imm:$bo, crbitrc:$bi, abscondbrtarget:$dst),
4219 "bcla $bo, $bi, $dst">;
4220 let isAsmParserOnly = 1 in {
4221 def gBCLat : BForm_3_at<16, 0, 1, (outs),
4222 (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
4224 "bcl$at $bo, $bi, $dst">;
4225 def gBCLAat : BForm_3_at<16, 1, 1, (outs),
4226 (ins u5imm:$bo, atimm:$at, crbitrc:$bi,
4227 abscondbrtarget:$dst),
4228 "bcla$at $bo, $bi, $dst">;
4229 } // // isAsmParserOnly = 1
4231 let Defs = [CTR], Uses = [CTR, LR, RM] in
4232 def gBCLR : XLForm_2<19, 16, 0, (outs),
4233 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
4234 "bclr $bo, $bi, $bh", IIC_BrB, []>;
4235 let Defs = [LR, CTR], Uses = [CTR, LR, RM] in
4236 def gBCLRL : XLForm_2<19, 16, 1, (outs),
4237 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
4238 "bclrl $bo, $bi, $bh", IIC_BrB, []>;
4239 let Defs = [CTR], Uses = [CTR, LR, RM] in
4240 def gBCCTR : XLForm_2<19, 528, 0, (outs),
4241 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
4242 "bcctr $bo, $bi, $bh", IIC_BrB, []>;
4243 let Defs = [LR, CTR], Uses = [CTR, LR, RM] in
4244 def gBCCTRL : XLForm_2<19, 528, 1, (outs),
4245 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
4246 "bcctrl $bo, $bi, $bh", IIC_BrB, []>;
4249 multiclass BranchSimpleMnemonicAT<string pm, int at> {
4250 def : InstAlias<"bc"#pm#" $bo, $bi, $dst", (gBCat u5imm:$bo, at, crbitrc:$bi,
4251 condbrtarget:$dst)>;
4252 def : InstAlias<"bca"#pm#" $bo, $bi, $dst", (gBCAat u5imm:$bo, at, crbitrc:$bi,
4253 condbrtarget:$dst)>;
4254 def : InstAlias<"bcl"#pm#" $bo, $bi, $dst", (gBCLat u5imm:$bo, at, crbitrc:$bi,
4255 condbrtarget:$dst)>;
4256 def : InstAlias<"bcla"#pm#" $bo, $bi, $dst", (gBCLAat u5imm:$bo, at, crbitrc:$bi,
4257 condbrtarget:$dst)>;
4259 defm : BranchSimpleMnemonicAT<"+", 3>;
4260 defm : BranchSimpleMnemonicAT<"-", 2>;
4262 def : InstAlias<"bclr $bo, $bi", (gBCLR u5imm:$bo, crbitrc:$bi, 0)>;
4263 def : InstAlias<"bclrl $bo, $bi", (gBCLRL u5imm:$bo, crbitrc:$bi, 0)>;
4264 def : InstAlias<"bcctr $bo, $bi", (gBCCTR u5imm:$bo, crbitrc:$bi, 0)>;
4265 def : InstAlias<"bcctrl $bo, $bi", (gBCCTRL u5imm:$bo, crbitrc:$bi, 0)>;
4267 multiclass BranchSimpleMnemonic1<string name, string pm, int bo> {
4268 def : InstAlias<"b"#name#pm#" $bi, $dst", (gBC bo, crbitrc:$bi, condbrtarget:$dst)>;
4269 def : InstAlias<"b"#name#"a"#pm#" $bi, $dst", (gBCA bo, crbitrc:$bi, abscondbrtarget:$dst)>;
4270 def : InstAlias<"b"#name#"lr"#pm#" $bi", (gBCLR bo, crbitrc:$bi, 0)>;
4271 def : InstAlias<"b"#name#"l"#pm#" $bi, $dst", (gBCL bo, crbitrc:$bi, condbrtarget:$dst)>;
4272 def : InstAlias<"b"#name#"la"#pm#" $bi, $dst", (gBCLA bo, crbitrc:$bi, abscondbrtarget:$dst)>;
4273 def : InstAlias<"b"#name#"lrl"#pm#" $bi", (gBCLRL bo, crbitrc:$bi, 0)>;
4275 multiclass BranchSimpleMnemonic2<string name, string pm, int bo>
4276 : BranchSimpleMnemonic1<name, pm, bo> {
4277 def : InstAlias<"b"#name#"ctr"#pm#" $bi", (gBCCTR bo, crbitrc:$bi, 0)>;
4278 def : InstAlias<"b"#name#"ctrl"#pm#" $bi", (gBCCTRL bo, crbitrc:$bi, 0)>;
4280 defm : BranchSimpleMnemonic2<"t", "", 12>;
4281 defm : BranchSimpleMnemonic2<"f", "", 4>;
4282 defm : BranchSimpleMnemonic2<"t", "-", 14>;
4283 defm : BranchSimpleMnemonic2<"f", "-", 6>;
4284 defm : BranchSimpleMnemonic2<"t", "+", 15>;
4285 defm : BranchSimpleMnemonic2<"f", "+", 7>;
4286 defm : BranchSimpleMnemonic1<"dnzt", "", 8>;
4287 defm : BranchSimpleMnemonic1<"dnzf", "", 0>;
4288 defm : BranchSimpleMnemonic1<"dzt", "", 10>;
4289 defm : BranchSimpleMnemonic1<"dzf", "", 2>;
4291 multiclass BranchExtendedMnemonicPM<string name, string pm, int bibo> {
4292 def : InstAlias<"b"#name#pm#" $cc, $dst",
4293 (BCC bibo, crrc:$cc, condbrtarget:$dst)>;
4294 def : InstAlias<"b"#name#pm#" $dst",
4295 (BCC bibo, CR0, condbrtarget:$dst)>;
4297 def : InstAlias<"b"#name#"a"#pm#" $cc, $dst",
4298 (BCCA bibo, crrc:$cc, abscondbrtarget:$dst)>;
4299 def : InstAlias<"b"#name#"a"#pm#" $dst",
4300 (BCCA bibo, CR0, abscondbrtarget:$dst)>;
4302 def : InstAlias<"b"#name#"lr"#pm#" $cc",
4303 (BCCLR bibo, crrc:$cc)>;
4304 def : InstAlias<"b"#name#"lr"#pm,
4307 def : InstAlias<"b"#name#"ctr"#pm#" $cc",
4308 (BCCCTR bibo, crrc:$cc)>;
4309 def : InstAlias<"b"#name#"ctr"#pm,
4310 (BCCCTR bibo, CR0)>;
4312 def : InstAlias<"b"#name#"l"#pm#" $cc, $dst",
4313 (BCCL bibo, crrc:$cc, condbrtarget:$dst)>;
4314 def : InstAlias<"b"#name#"l"#pm#" $dst",
4315 (BCCL bibo, CR0, condbrtarget:$dst)>;
4317 def : InstAlias<"b"#name#"la"#pm#" $cc, $dst",
4318 (BCCLA bibo, crrc:$cc, abscondbrtarget:$dst)>;
4319 def : InstAlias<"b"#name#"la"#pm#" $dst",
4320 (BCCLA bibo, CR0, abscondbrtarget:$dst)>;
4322 def : InstAlias<"b"#name#"lrl"#pm#" $cc",
4323 (BCCLRL bibo, crrc:$cc)>;
4324 def : InstAlias<"b"#name#"lrl"#pm,
4325 (BCCLRL bibo, CR0)>;
4327 def : InstAlias<"b"#name#"ctrl"#pm#" $cc",
4328 (BCCCTRL bibo, crrc:$cc)>;
4329 def : InstAlias<"b"#name#"ctrl"#pm,
4330 (BCCCTRL bibo, CR0)>;
4332 multiclass BranchExtendedMnemonic<string name, int bibo> {
4333 defm : BranchExtendedMnemonicPM<name, "", bibo>;
4334 defm : BranchExtendedMnemonicPM<name, "-", !add(bibo, 2)>;
4335 defm : BranchExtendedMnemonicPM<name, "+", !add(bibo, 3)>;
4337 defm : BranchExtendedMnemonic<"lt", 12>;
4338 defm : BranchExtendedMnemonic<"gt", 44>;
4339 defm : BranchExtendedMnemonic<"eq", 76>;
4340 defm : BranchExtendedMnemonic<"un", 108>;
4341 defm : BranchExtendedMnemonic<"so", 108>;
4342 defm : BranchExtendedMnemonic<"ge", 4>;
4343 defm : BranchExtendedMnemonic<"nl", 4>;
4344 defm : BranchExtendedMnemonic<"le", 36>;
4345 defm : BranchExtendedMnemonic<"ng", 36>;
4346 defm : BranchExtendedMnemonic<"ne", 68>;
4347 defm : BranchExtendedMnemonic<"nu", 100>;
4348 defm : BranchExtendedMnemonic<"ns", 100>;
4350 def : InstAlias<"cmpwi $rA, $imm", (CMPWI CR0, gprc:$rA, s16imm:$imm)>;
4351 def : InstAlias<"cmpw $rA, $rB", (CMPW CR0, gprc:$rA, gprc:$rB)>;
4352 def : InstAlias<"cmplwi $rA, $imm", (CMPLWI CR0, gprc:$rA, u16imm:$imm)>;
4353 def : InstAlias<"cmplw $rA, $rB", (CMPLW CR0, gprc:$rA, gprc:$rB)>;
4354 def : InstAlias<"cmpdi $rA, $imm", (CMPDI CR0, g8rc:$rA, s16imm64:$imm)>;
4355 def : InstAlias<"cmpd $rA, $rB", (CMPD CR0, g8rc:$rA, g8rc:$rB)>;
4356 def : InstAlias<"cmpldi $rA, $imm", (CMPLDI CR0, g8rc:$rA, u16imm64:$imm)>;
4357 def : InstAlias<"cmpld $rA, $rB", (CMPLD CR0, g8rc:$rA, g8rc:$rB)>;
4359 def : InstAlias<"cmpi $bf, 0, $rA, $imm", (CMPWI crrc:$bf, gprc:$rA, s16imm:$imm)>;
4360 def : InstAlias<"cmp $bf, 0, $rA, $rB", (CMPW crrc:$bf, gprc:$rA, gprc:$rB)>;
4361 def : InstAlias<"cmpli $bf, 0, $rA, $imm", (CMPLWI crrc:$bf, gprc:$rA, u16imm:$imm)>;
4362 def : InstAlias<"cmpl $bf, 0, $rA, $rB", (CMPLW crrc:$bf, gprc:$rA, gprc:$rB)>;
4363 def : InstAlias<"cmpi $bf, 1, $rA, $imm", (CMPDI crrc:$bf, g8rc:$rA, s16imm64:$imm)>;
4364 def : InstAlias<"cmp $bf, 1, $rA, $rB", (CMPD crrc:$bf, g8rc:$rA, g8rc:$rB)>;
4365 def : InstAlias<"cmpli $bf, 1, $rA, $imm", (CMPLDI crrc:$bf, g8rc:$rA, u16imm64:$imm)>;
4366 def : InstAlias<"cmpl $bf, 1, $rA, $rB", (CMPLD crrc:$bf, g8rc:$rA, g8rc:$rB)>;
4368 multiclass TrapExtendedMnemonic<string name, int to> {
4369 def : InstAlias<"td"#name#"i $rA, $imm", (TDI to, g8rc:$rA, s16imm:$imm)>;
4370 def : InstAlias<"td"#name#" $rA, $rB", (TD to, g8rc:$rA, g8rc:$rB)>;
4371 def : InstAlias<"tw"#name#"i $rA, $imm", (TWI to, gprc:$rA, s16imm:$imm)>;
4372 def : InstAlias<"tw"#name#" $rA, $rB", (TW to, gprc:$rA, gprc:$rB)>;
4374 defm : TrapExtendedMnemonic<"lt", 16>;
4375 defm : TrapExtendedMnemonic<"le", 20>;
4376 defm : TrapExtendedMnemonic<"eq", 4>;
4377 defm : TrapExtendedMnemonic<"ge", 12>;
4378 defm : TrapExtendedMnemonic<"gt", 8>;
4379 defm : TrapExtendedMnemonic<"nl", 12>;
4380 defm : TrapExtendedMnemonic<"ne", 24>;
4381 defm : TrapExtendedMnemonic<"ng", 20>;
4382 defm : TrapExtendedMnemonic<"llt", 2>;
4383 defm : TrapExtendedMnemonic<"lle", 6>;
4384 defm : TrapExtendedMnemonic<"lge", 5>;
4385 defm : TrapExtendedMnemonic<"lgt", 1>;
4386 defm : TrapExtendedMnemonic<"lnl", 5>;
4387 defm : TrapExtendedMnemonic<"lng", 6>;
4388 defm : TrapExtendedMnemonic<"u", 31>;
4391 def : Pat<(atomic_load_8 iaddr:$src), (LBZ memri:$src)>;
4392 def : Pat<(atomic_load_16 iaddr:$src), (LHZ memri:$src)>;
4393 def : Pat<(atomic_load_32 iaddr:$src), (LWZ memri:$src)>;
4394 def : Pat<(atomic_load_8 xaddr:$src), (LBZX memrr:$src)>;
4395 def : Pat<(atomic_load_16 xaddr:$src), (LHZX memrr:$src)>;
4396 def : Pat<(atomic_load_32 xaddr:$src), (LWZX memrr:$src)>;
4399 def : Pat<(atomic_store_8 iaddr:$ptr, i32:$val), (STB gprc:$val, memri:$ptr)>;
4400 def : Pat<(atomic_store_16 iaddr:$ptr, i32:$val), (STH gprc:$val, memri:$ptr)>;
4401 def : Pat<(atomic_store_32 iaddr:$ptr, i32:$val), (STW gprc:$val, memri:$ptr)>;
4402 def : Pat<(atomic_store_8 xaddr:$ptr, i32:$val), (STBX gprc:$val, memrr:$ptr)>;
4403 def : Pat<(atomic_store_16 xaddr:$ptr, i32:$val), (STHX gprc:$val, memrr:$ptr)>;
4404 def : Pat<(atomic_store_32 xaddr:$ptr, i32:$val), (STWX gprc:$val, memrr:$ptr)>;
4406 let Predicates = [IsISA3_0] in {
4408 // Copy-Paste Facility
4409 // We prefix 'CP' to COPY due to name conflict in Target.td. We also prefix to
4410 // PASTE for naming consistency.
4412 def CP_COPY : X_L1_RA5_RB5<31, 774, "copy" , gprc, IIC_LdStCOPY, []>;
4415 def CP_PASTE : X_L1_RA5_RB5<31, 902, "paste" , gprc, IIC_LdStPASTE, []>;
4417 let mayStore = 1, Defs = [CR0] in
4418 def CP_PASTEo : X_L1_RA5_RB5<31, 902, "paste.", gprc, IIC_LdStPASTE, []>, isDOT;
4420 def CP_COPYx : PPCAsmPseudo<"copy $rA, $rB" , (ins gprc:$rA, gprc:$rB)>;
4421 def CP_PASTEx : PPCAsmPseudo<"paste $rA, $rB", (ins gprc:$rA, gprc:$rB)>;
4422 def CP_COPY_FIRST : PPCAsmPseudo<"copy_first $rA, $rB",
4423 (ins gprc:$rA, gprc:$rB)>;
4424 def CP_PASTE_LAST : PPCAsmPseudo<"paste_last $rA, $rB",
4425 (ins gprc:$rA, gprc:$rB)>;
4426 def CP_ABORT : XForm_0<31, 838, (outs), (ins), "cp_abort", IIC_SprABORT, []>;
4428 // Message Synchronize
4429 def MSGSYNC : XForm_0<31, 886, (outs), (ins), "msgsync", IIC_SprMSGSYNC, []>;
4431 // Power-Saving Mode Instruction:
4432 def STOP : XForm_0<19, 370, (outs), (ins), "stop", IIC_SprSTOP, []>;