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>
27 def SDT_PPCCallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
28 def SDT_PPCCallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
30 def SDT_PPCvperm : SDTypeProfile<1, 3, [
31 SDTCisVT<3, v16i8>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>
34 def SDT_PPCvcmp : SDTypeProfile<1, 3, [
35 SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisVT<3, i32>
38 def SDT_PPCcondbr : SDTypeProfile<0, 3, [
39 SDTCisVT<0, i32>, SDTCisVT<2, OtherVT>
42 def SDT_PPClbrx : SDTypeProfile<1, 2, [
43 SDTCisInt<0>, SDTCisPtrTy<1>, SDTCisVT<2, OtherVT>
45 def SDT_PPCstbrx : SDTypeProfile<0, 3, [
46 SDTCisInt<0>, SDTCisPtrTy<1>, SDTCisVT<2, OtherVT>
49 def SDT_PPClarx : SDTypeProfile<1, 1, [
50 SDTCisInt<0>, SDTCisPtrTy<1>
52 def SDT_PPCstcx : SDTypeProfile<0, 2, [
53 SDTCisInt<0>, SDTCisPtrTy<1>
56 def SDT_PPCTC_ret : SDTypeProfile<0, 2, [
57 SDTCisPtrTy<0>, SDTCisVT<1, i32>
60 def tocentry32 : Operand<iPTR> {
61 let MIOperandInfo = (ops i32imm:$imm);
64 def SDT_PPCqvfperm : SDTypeProfile<1, 3, [
65 SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisVec<3>
67 def SDT_PPCqvgpci : SDTypeProfile<1, 1, [
68 SDTCisVec<0>, SDTCisInt<1>
70 def SDT_PPCqvaligni : SDTypeProfile<1, 3, [
71 SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisInt<3>
73 def SDT_PPCqvesplati : SDTypeProfile<1, 2, [
74 SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisInt<2>
77 def SDT_PPCqbflt : SDTypeProfile<1, 1, [
78 SDTCisVec<0>, SDTCisVec<1>
81 def SDT_PPCqvlfsb : SDTypeProfile<1, 1, [
82 SDTCisVec<0>, SDTCisPtrTy<1>
85 //===----------------------------------------------------------------------===//
86 // PowerPC specific DAG Nodes.
89 def PPCfre : SDNode<"PPCISD::FRE", SDTFPUnaryOp, []>;
90 def PPCfrsqrte: SDNode<"PPCISD::FRSQRTE", SDTFPUnaryOp, []>;
92 def PPCfcfid : SDNode<"PPCISD::FCFID", SDTFPUnaryOp, []>;
93 def PPCfcfidu : SDNode<"PPCISD::FCFIDU", SDTFPUnaryOp, []>;
94 def PPCfcfids : SDNode<"PPCISD::FCFIDS", SDTFPRoundOp, []>;
95 def PPCfcfidus: SDNode<"PPCISD::FCFIDUS", SDTFPRoundOp, []>;
96 def PPCfctidz : SDNode<"PPCISD::FCTIDZ", SDTFPUnaryOp, []>;
97 def PPCfctiwz : SDNode<"PPCISD::FCTIWZ", SDTFPUnaryOp, []>;
98 def PPCfctiduz: SDNode<"PPCISD::FCTIDUZ",SDTFPUnaryOp, []>;
99 def PPCfctiwuz: SDNode<"PPCISD::FCTIWUZ",SDTFPUnaryOp, []>;
100 def PPCstfiwx : SDNode<"PPCISD::STFIWX", SDT_PPCstfiwx,
101 [SDNPHasChain, SDNPMayStore]>;
102 def PPClfiwax : SDNode<"PPCISD::LFIWAX", SDT_PPClfiwx,
103 [SDNPHasChain, SDNPMayLoad]>;
104 def PPClfiwzx : SDNode<"PPCISD::LFIWZX", SDT_PPClfiwx,
105 [SDNPHasChain, SDNPMayLoad]>;
107 // Extract FPSCR (not modeled at the DAG level).
108 def PPCmffs : SDNode<"PPCISD::MFFS",
109 SDTypeProfile<1, 0, [SDTCisVT<0, f64>]>, []>;
111 // Perform FADD in round-to-zero mode.
112 def PPCfaddrtz: SDNode<"PPCISD::FADDRTZ", SDTFPBinOp, []>;
115 def PPCfsel : SDNode<"PPCISD::FSEL",
116 // Type constraint for fsel.
117 SDTypeProfile<1, 3, [SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>,
118 SDTCisFP<0>, SDTCisVT<1, f64>]>, []>;
120 def PPChi : SDNode<"PPCISD::Hi", SDTIntBinOp, []>;
121 def PPClo : SDNode<"PPCISD::Lo", SDTIntBinOp, []>;
122 def PPCtoc_entry: SDNode<"PPCISD::TOC_ENTRY", SDTIntBinOp, [SDNPMayLoad]>;
123 def PPCvmaddfp : SDNode<"PPCISD::VMADDFP", SDTFPTernaryOp, []>;
124 def PPCvnmsubfp : SDNode<"PPCISD::VNMSUBFP", SDTFPTernaryOp, []>;
126 def PPCppc32GOT : SDNode<"PPCISD::PPC32_GOT", SDTIntLeaf, []>;
128 def PPCaddisGotTprelHA : SDNode<"PPCISD::ADDIS_GOT_TPREL_HA", SDTIntBinOp>;
129 def PPCldGotTprelL : SDNode<"PPCISD::LD_GOT_TPREL_L", SDTIntBinOp,
131 def PPCaddTls : SDNode<"PPCISD::ADD_TLS", SDTIntBinOp, []>;
132 def PPCaddisTlsgdHA : SDNode<"PPCISD::ADDIS_TLSGD_HA", SDTIntBinOp>;
133 def PPCaddiTlsgdL : SDNode<"PPCISD::ADDI_TLSGD_L", SDTIntBinOp>;
134 def PPCgetTlsAddr : SDNode<"PPCISD::GET_TLS_ADDR", SDTIntBinOp>;
135 def PPCaddiTlsgdLAddr : SDNode<"PPCISD::ADDI_TLSGD_L_ADDR",
136 SDTypeProfile<1, 3, [
137 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
138 SDTCisSameAs<0, 3>, SDTCisInt<0> ]>>;
139 def PPCaddisTlsldHA : SDNode<"PPCISD::ADDIS_TLSLD_HA", SDTIntBinOp>;
140 def PPCaddiTlsldL : SDNode<"PPCISD::ADDI_TLSLD_L", SDTIntBinOp>;
141 def PPCgetTlsldAddr : SDNode<"PPCISD::GET_TLSLD_ADDR", SDTIntBinOp>;
142 def PPCaddiTlsldLAddr : SDNode<"PPCISD::ADDI_TLSLD_L_ADDR",
143 SDTypeProfile<1, 3, [
144 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
145 SDTCisSameAs<0, 3>, SDTCisInt<0> ]>>;
146 def PPCaddisDtprelHA : SDNode<"PPCISD::ADDIS_DTPREL_HA", SDTIntBinOp>;
147 def PPCaddiDtprelL : SDNode<"PPCISD::ADDI_DTPREL_L", SDTIntBinOp>;
149 def PPCvperm : SDNode<"PPCISD::VPERM", SDT_PPCvperm, []>;
151 def PPCqvfperm : SDNode<"PPCISD::QVFPERM", SDT_PPCqvfperm, []>;
152 def PPCqvgpci : SDNode<"PPCISD::QVGPCI", SDT_PPCqvgpci, []>;
153 def PPCqvaligni : SDNode<"PPCISD::QVALIGNI", SDT_PPCqvaligni, []>;
154 def PPCqvesplati : SDNode<"PPCISD::QVESPLATI", SDT_PPCqvesplati, []>;
156 def PPCqbflt : SDNode<"PPCISD::QBFLT", SDT_PPCqbflt, []>;
158 def PPCqvlfsb : SDNode<"PPCISD::QVLFSb", SDT_PPCqvlfsb,
159 [SDNPHasChain, SDNPMayLoad]>;
161 def PPCcmpb : SDNode<"PPCISD::CMPB", SDTIntBinOp, []>;
163 // These nodes represent the 32-bit PPC shifts that operate on 6-bit shift
164 // amounts. These nodes are generated by the multi-precision shift code.
165 def PPCsrl : SDNode<"PPCISD::SRL" , SDTIntShiftOp>;
166 def PPCsra : SDNode<"PPCISD::SRA" , SDTIntShiftOp>;
167 def PPCshl : SDNode<"PPCISD::SHL" , SDTIntShiftOp>;
169 // These are target-independent nodes, but have target-specific formats.
170 def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_PPCCallSeqStart,
171 [SDNPHasChain, SDNPOutGlue]>;
172 def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_PPCCallSeqEnd,
173 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
175 def SDT_PPCCall : SDTypeProfile<0, -1, [SDTCisInt<0>]>;
176 def PPCcall : SDNode<"PPCISD::CALL", SDT_PPCCall,
177 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
179 def PPCcall_nop : SDNode<"PPCISD::CALL_NOP", SDT_PPCCall,
180 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
182 def PPCmtctr : SDNode<"PPCISD::MTCTR", SDT_PPCCall,
183 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
184 def PPCbctrl : SDNode<"PPCISD::BCTRL", SDTNone,
185 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
187 def PPCbctrl_load_toc : SDNode<"PPCISD::BCTRL_LOAD_TOC",
188 SDTypeProfile<0, 1, []>,
189 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
192 def retflag : SDNode<"PPCISD::RET_FLAG", SDTNone,
193 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
195 def PPCtc_return : SDNode<"PPCISD::TC_RETURN", SDT_PPCTC_ret,
196 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
198 def PPCeh_sjlj_setjmp : SDNode<"PPCISD::EH_SJLJ_SETJMP",
199 SDTypeProfile<1, 1, [SDTCisInt<0>,
201 [SDNPHasChain, SDNPSideEffect]>;
202 def PPCeh_sjlj_longjmp : SDNode<"PPCISD::EH_SJLJ_LONGJMP",
203 SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>,
204 [SDNPHasChain, SDNPSideEffect]>;
206 def SDT_PPCsc : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
207 def PPCsc : SDNode<"PPCISD::SC", SDT_PPCsc,
208 [SDNPHasChain, SDNPSideEffect]>;
210 def PPCvcmp : SDNode<"PPCISD::VCMP" , SDT_PPCvcmp, []>;
211 def PPCvcmp_o : SDNode<"PPCISD::VCMPo", SDT_PPCvcmp, [SDNPOutGlue]>;
213 def PPCcondbranch : SDNode<"PPCISD::COND_BRANCH", SDT_PPCcondbr,
214 [SDNPHasChain, SDNPOptInGlue]>;
216 def PPClbrx : SDNode<"PPCISD::LBRX", SDT_PPClbrx,
217 [SDNPHasChain, SDNPMayLoad]>;
218 def PPCstbrx : SDNode<"PPCISD::STBRX", SDT_PPCstbrx,
219 [SDNPHasChain, SDNPMayStore]>;
221 // Instructions to set/unset CR bit 6 for SVR4 vararg calls
222 def PPCcr6set : SDNode<"PPCISD::CR6SET", SDTNone,
223 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
224 def PPCcr6unset : SDNode<"PPCISD::CR6UNSET", SDTNone,
225 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
227 // Instructions to support atomic operations
228 def PPClarx : SDNode<"PPCISD::LARX", SDT_PPClarx,
229 [SDNPHasChain, SDNPMayLoad]>;
230 def PPCstcx : SDNode<"PPCISD::STCX", SDT_PPCstcx,
231 [SDNPHasChain, SDNPMayStore]>;
233 // Instructions to support dynamic alloca.
234 def SDTDynOp : SDTypeProfile<1, 2, []>;
235 def PPCdynalloc : SDNode<"PPCISD::DYNALLOC", SDTDynOp, [SDNPHasChain]>;
237 //===----------------------------------------------------------------------===//
238 // PowerPC specific transformation functions and pattern fragments.
241 def SHL32 : SDNodeXForm<imm, [{
242 // Transformation function: 31 - imm
243 return getI32Imm(31 - N->getZExtValue());
246 def SRL32 : SDNodeXForm<imm, [{
247 // Transformation function: 32 - imm
248 return N->getZExtValue() ? getI32Imm(32 - N->getZExtValue()) : getI32Imm(0);
251 def LO16 : SDNodeXForm<imm, [{
252 // Transformation function: get the low 16 bits.
253 return getI32Imm((unsigned short)N->getZExtValue());
256 def HI16 : SDNodeXForm<imm, [{
257 // Transformation function: shift the immediate value down into the low bits.
258 return getI32Imm((unsigned)N->getZExtValue() >> 16);
261 def HA16 : SDNodeXForm<imm, [{
262 // Transformation function: shift the immediate value down into the low bits.
263 signed int Val = N->getZExtValue();
264 return getI32Imm((Val - (signed short)Val) >> 16);
266 def MB : SDNodeXForm<imm, [{
267 // Transformation function: get the start bit of a mask
269 (void)isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
270 return getI32Imm(mb);
273 def ME : SDNodeXForm<imm, [{
274 // Transformation function: get the end bit of a mask
276 (void)isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
277 return getI32Imm(me);
279 def maskimm32 : PatLeaf<(imm), [{
280 // maskImm predicate - True if immediate is a run of ones.
282 if (N->getValueType(0) == MVT::i32)
283 return isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
288 def imm32SExt16 : Operand<i32>, ImmLeaf<i32, [{
289 // imm32SExt16 predicate - True if the i32 immediate fits in a 16-bit
290 // sign extended field. Used by instructions like 'addi'.
291 return (int32_t)Imm == (short)Imm;
293 def imm64SExt16 : Operand<i64>, ImmLeaf<i64, [{
294 // imm64SExt16 predicate - True if the i64 immediate fits in a 16-bit
295 // sign extended field. Used by instructions like 'addi'.
296 return (int64_t)Imm == (short)Imm;
298 def immZExt16 : PatLeaf<(imm), [{
299 // immZExt16 predicate - True if the immediate fits in a 16-bit zero extended
300 // field. Used by instructions like 'ori'.
301 return (uint64_t)N->getZExtValue() == (unsigned short)N->getZExtValue();
304 // imm16Shifted* - These match immediates where the low 16-bits are zero. There
305 // are two forms: imm16ShiftedSExt and imm16ShiftedZExt. These two forms are
306 // identical in 32-bit mode, but in 64-bit mode, they return true if the
307 // immediate fits into a sign/zero extended 32-bit immediate (with the low bits
309 def imm16ShiftedZExt : PatLeaf<(imm), [{
310 // imm16ShiftedZExt predicate - True if only bits in the top 16-bits of the
311 // immediate are set. Used by instructions like 'xoris'.
312 return (N->getZExtValue() & ~uint64_t(0xFFFF0000)) == 0;
315 def imm16ShiftedSExt : PatLeaf<(imm), [{
316 // imm16ShiftedSExt predicate - True if only bits in the top 16-bits of the
317 // immediate are set. Used by instructions like 'addis'. Identical to
318 // imm16ShiftedZExt in 32-bit mode.
319 if (N->getZExtValue() & 0xFFFF) return false;
320 if (N->getValueType(0) == MVT::i32)
322 // For 64-bit, make sure it is sext right.
323 return N->getZExtValue() == (uint64_t)(int)N->getZExtValue();
326 def imm64ZExt32 : Operand<i64>, ImmLeaf<i64, [{
327 // imm64ZExt32 predicate - True if the i64 immediate fits in a 32-bit
328 // zero extended field.
329 return isUInt<32>(Imm);
332 // Some r+i load/store instructions (such as LD, STD, LDU, etc.) that require
333 // restricted memrix (4-aligned) constants are alignment sensitive. If these
334 // offsets are hidden behind TOC entries than the values of the lower-order
335 // bits cannot be checked directly. As a result, we need to also incorporate
336 // an alignment check into the relevant patterns.
338 def aligned4load : PatFrag<(ops node:$ptr), (load node:$ptr), [{
339 return cast<LoadSDNode>(N)->getAlignment() >= 4;
341 def aligned4store : PatFrag<(ops node:$val, node:$ptr),
342 (store node:$val, node:$ptr), [{
343 return cast<StoreSDNode>(N)->getAlignment() >= 4;
345 def aligned4sextloadi32 : PatFrag<(ops node:$ptr), (sextloadi32 node:$ptr), [{
346 return cast<LoadSDNode>(N)->getAlignment() >= 4;
348 def aligned4pre_store : PatFrag<
349 (ops node:$val, node:$base, node:$offset),
350 (pre_store node:$val, node:$base, node:$offset), [{
351 return cast<StoreSDNode>(N)->getAlignment() >= 4;
354 def unaligned4load : PatFrag<(ops node:$ptr), (load node:$ptr), [{
355 return cast<LoadSDNode>(N)->getAlignment() < 4;
357 def unaligned4store : PatFrag<(ops node:$val, node:$ptr),
358 (store node:$val, node:$ptr), [{
359 return cast<StoreSDNode>(N)->getAlignment() < 4;
361 def unaligned4sextloadi32 : PatFrag<(ops node:$ptr), (sextloadi32 node:$ptr), [{
362 return cast<LoadSDNode>(N)->getAlignment() < 4;
365 //===----------------------------------------------------------------------===//
366 // PowerPC Flag Definitions.
368 class isPPC64 { bit PPC64 = 1; }
369 class isDOT { bit RC = 1; }
371 class RegConstraint<string C> {
372 string Constraints = C;
374 class NoEncode<string E> {
375 string DisableEncoding = E;
379 //===----------------------------------------------------------------------===//
380 // PowerPC Operand Definitions.
382 // In the default PowerPC assembler syntax, registers are specified simply
383 // by number, so they cannot be distinguished from immediate values (without
384 // looking at the opcode). This means that the default operand matching logic
385 // for the asm parser does not work, and we need to specify custom matchers.
386 // Since those can only be specified with RegisterOperand classes and not
387 // directly on the RegisterClass, all instructions patterns used by the asm
388 // parser need to use a RegisterOperand (instead of a RegisterClass) for
389 // all their register operands.
390 // For this purpose, we define one RegisterOperand for each RegisterClass,
391 // using the same name as the class, just in lower case.
393 def PPCRegGPRCAsmOperand : AsmOperandClass {
394 let Name = "RegGPRC"; let PredicateMethod = "isRegNumber";
396 def gprc : RegisterOperand<GPRC> {
397 let ParserMatchClass = PPCRegGPRCAsmOperand;
399 def PPCRegG8RCAsmOperand : AsmOperandClass {
400 let Name = "RegG8RC"; let PredicateMethod = "isRegNumber";
402 def g8rc : RegisterOperand<G8RC> {
403 let ParserMatchClass = PPCRegG8RCAsmOperand;
405 def PPCRegGPRCNoR0AsmOperand : AsmOperandClass {
406 let Name = "RegGPRCNoR0"; let PredicateMethod = "isRegNumber";
408 def gprc_nor0 : RegisterOperand<GPRC_NOR0> {
409 let ParserMatchClass = PPCRegGPRCNoR0AsmOperand;
411 def PPCRegG8RCNoX0AsmOperand : AsmOperandClass {
412 let Name = "RegG8RCNoX0"; let PredicateMethod = "isRegNumber";
414 def g8rc_nox0 : RegisterOperand<G8RC_NOX0> {
415 let ParserMatchClass = PPCRegG8RCNoX0AsmOperand;
417 def PPCRegF8RCAsmOperand : AsmOperandClass {
418 let Name = "RegF8RC"; let PredicateMethod = "isRegNumber";
420 def f8rc : RegisterOperand<F8RC> {
421 let ParserMatchClass = PPCRegF8RCAsmOperand;
423 def PPCRegF4RCAsmOperand : AsmOperandClass {
424 let Name = "RegF4RC"; let PredicateMethod = "isRegNumber";
426 def f4rc : RegisterOperand<F4RC> {
427 let ParserMatchClass = PPCRegF4RCAsmOperand;
429 def PPCRegVRRCAsmOperand : AsmOperandClass {
430 let Name = "RegVRRC"; let PredicateMethod = "isRegNumber";
432 def vrrc : RegisterOperand<VRRC> {
433 let ParserMatchClass = PPCRegVRRCAsmOperand;
435 def PPCRegCRBITRCAsmOperand : AsmOperandClass {
436 let Name = "RegCRBITRC"; let PredicateMethod = "isCRBitNumber";
438 def crbitrc : RegisterOperand<CRBITRC> {
439 let ParserMatchClass = PPCRegCRBITRCAsmOperand;
441 def PPCRegCRRCAsmOperand : AsmOperandClass {
442 let Name = "RegCRRC"; let PredicateMethod = "isCCRegNumber";
444 def crrc : RegisterOperand<CRRC> {
445 let ParserMatchClass = PPCRegCRRCAsmOperand;
448 def PPCU2ImmAsmOperand : AsmOperandClass {
449 let Name = "U2Imm"; let PredicateMethod = "isU2Imm";
450 let RenderMethod = "addImmOperands";
452 def u2imm : Operand<i32> {
453 let PrintMethod = "printU2ImmOperand";
454 let ParserMatchClass = PPCU2ImmAsmOperand;
457 def PPCU4ImmAsmOperand : AsmOperandClass {
458 let Name = "U4Imm"; let PredicateMethod = "isU4Imm";
459 let RenderMethod = "addImmOperands";
461 def u4imm : Operand<i32> {
462 let PrintMethod = "printU4ImmOperand";
463 let ParserMatchClass = PPCU4ImmAsmOperand;
465 def PPCS5ImmAsmOperand : AsmOperandClass {
466 let Name = "S5Imm"; let PredicateMethod = "isS5Imm";
467 let RenderMethod = "addImmOperands";
469 def s5imm : Operand<i32> {
470 let PrintMethod = "printS5ImmOperand";
471 let ParserMatchClass = PPCS5ImmAsmOperand;
472 let DecoderMethod = "decodeSImmOperand<5>";
474 def PPCU5ImmAsmOperand : AsmOperandClass {
475 let Name = "U5Imm"; let PredicateMethod = "isU5Imm";
476 let RenderMethod = "addImmOperands";
478 def u5imm : Operand<i32> {
479 let PrintMethod = "printU5ImmOperand";
480 let ParserMatchClass = PPCU5ImmAsmOperand;
481 let DecoderMethod = "decodeUImmOperand<5>";
483 def PPCU6ImmAsmOperand : AsmOperandClass {
484 let Name = "U6Imm"; let PredicateMethod = "isU6Imm";
485 let RenderMethod = "addImmOperands";
487 def u6imm : Operand<i32> {
488 let PrintMethod = "printU6ImmOperand";
489 let ParserMatchClass = PPCU6ImmAsmOperand;
490 let DecoderMethod = "decodeUImmOperand<6>";
492 def PPCU12ImmAsmOperand : AsmOperandClass {
493 let Name = "U12Imm"; let PredicateMethod = "isU12Imm";
494 let RenderMethod = "addImmOperands";
496 def u12imm : Operand<i32> {
497 let PrintMethod = "printU12ImmOperand";
498 let ParserMatchClass = PPCU12ImmAsmOperand;
499 let DecoderMethod = "decodeUImmOperand<12>";
501 def PPCS16ImmAsmOperand : AsmOperandClass {
502 let Name = "S16Imm"; let PredicateMethod = "isS16Imm";
503 let RenderMethod = "addS16ImmOperands";
505 def s16imm : Operand<i32> {
506 let PrintMethod = "printS16ImmOperand";
507 let EncoderMethod = "getImm16Encoding";
508 let ParserMatchClass = PPCS16ImmAsmOperand;
509 let DecoderMethod = "decodeSImmOperand<16>";
511 def PPCU16ImmAsmOperand : AsmOperandClass {
512 let Name = "U16Imm"; let PredicateMethod = "isU16Imm";
513 let RenderMethod = "addU16ImmOperands";
515 def u16imm : Operand<i32> {
516 let PrintMethod = "printU16ImmOperand";
517 let EncoderMethod = "getImm16Encoding";
518 let ParserMatchClass = PPCU16ImmAsmOperand;
519 let DecoderMethod = "decodeUImmOperand<16>";
521 def PPCS17ImmAsmOperand : AsmOperandClass {
522 let Name = "S17Imm"; let PredicateMethod = "isS17Imm";
523 let RenderMethod = "addS16ImmOperands";
525 def s17imm : Operand<i32> {
526 // This operand type is used for addis/lis to allow the assembler parser
527 // to accept immediates in the range -65536..65535 for compatibility with
528 // the GNU assembler. The operand is treated as 16-bit otherwise.
529 let PrintMethod = "printS16ImmOperand";
530 let EncoderMethod = "getImm16Encoding";
531 let ParserMatchClass = PPCS17ImmAsmOperand;
532 let DecoderMethod = "decodeSImmOperand<16>";
534 def PPCDirectBrAsmOperand : AsmOperandClass {
535 let Name = "DirectBr"; let PredicateMethod = "isDirectBr";
536 let RenderMethod = "addBranchTargetOperands";
538 def directbrtarget : Operand<OtherVT> {
539 let PrintMethod = "printBranchOperand";
540 let EncoderMethod = "getDirectBrEncoding";
541 let ParserMatchClass = PPCDirectBrAsmOperand;
543 def absdirectbrtarget : Operand<OtherVT> {
544 let PrintMethod = "printAbsBranchOperand";
545 let EncoderMethod = "getAbsDirectBrEncoding";
546 let ParserMatchClass = PPCDirectBrAsmOperand;
548 def PPCCondBrAsmOperand : AsmOperandClass {
549 let Name = "CondBr"; let PredicateMethod = "isCondBr";
550 let RenderMethod = "addBranchTargetOperands";
552 def condbrtarget : Operand<OtherVT> {
553 let PrintMethod = "printBranchOperand";
554 let EncoderMethod = "getCondBrEncoding";
555 let ParserMatchClass = PPCCondBrAsmOperand;
557 def abscondbrtarget : Operand<OtherVT> {
558 let PrintMethod = "printAbsBranchOperand";
559 let EncoderMethod = "getAbsCondBrEncoding";
560 let ParserMatchClass = PPCCondBrAsmOperand;
562 def calltarget : Operand<iPTR> {
563 let PrintMethod = "printBranchOperand";
564 let EncoderMethod = "getDirectBrEncoding";
565 let ParserMatchClass = PPCDirectBrAsmOperand;
567 def abscalltarget : Operand<iPTR> {
568 let PrintMethod = "printAbsBranchOperand";
569 let EncoderMethod = "getAbsDirectBrEncoding";
570 let ParserMatchClass = PPCDirectBrAsmOperand;
572 def PPCCRBitMaskOperand : AsmOperandClass {
573 let Name = "CRBitMask"; let PredicateMethod = "isCRBitMask";
575 def crbitm: Operand<i8> {
576 let PrintMethod = "printcrbitm";
577 let EncoderMethod = "get_crbitm_encoding";
578 let DecoderMethod = "decodeCRBitMOperand";
579 let ParserMatchClass = PPCCRBitMaskOperand;
582 // A version of ptr_rc which excludes R0 (or X0 in 64-bit mode).
583 def PPCRegGxRCNoR0Operand : AsmOperandClass {
584 let Name = "RegGxRCNoR0"; let PredicateMethod = "isRegNumber";
586 def ptr_rc_nor0 : Operand<iPTR>, PointerLikeRegClass<1> {
587 let ParserMatchClass = PPCRegGxRCNoR0Operand;
589 // A version of ptr_rc usable with the asm parser.
590 def PPCRegGxRCOperand : AsmOperandClass {
591 let Name = "RegGxRC"; let PredicateMethod = "isRegNumber";
593 def ptr_rc_idx : Operand<iPTR>, PointerLikeRegClass<0> {
594 let ParserMatchClass = PPCRegGxRCOperand;
597 def PPCDispRIOperand : AsmOperandClass {
598 let Name = "DispRI"; let PredicateMethod = "isS16Imm";
599 let RenderMethod = "addS16ImmOperands";
601 def dispRI : Operand<iPTR> {
602 let ParserMatchClass = PPCDispRIOperand;
604 def PPCDispRIXOperand : AsmOperandClass {
605 let Name = "DispRIX"; let PredicateMethod = "isS16ImmX4";
606 let RenderMethod = "addImmOperands";
608 def dispRIX : Operand<iPTR> {
609 let ParserMatchClass = PPCDispRIXOperand;
611 def PPCDispSPE8Operand : AsmOperandClass {
612 let Name = "DispSPE8"; let PredicateMethod = "isU8ImmX8";
613 let RenderMethod = "addImmOperands";
615 def dispSPE8 : Operand<iPTR> {
616 let ParserMatchClass = PPCDispSPE8Operand;
618 def PPCDispSPE4Operand : AsmOperandClass {
619 let Name = "DispSPE4"; let PredicateMethod = "isU7ImmX4";
620 let RenderMethod = "addImmOperands";
622 def dispSPE4 : Operand<iPTR> {
623 let ParserMatchClass = PPCDispSPE4Operand;
625 def PPCDispSPE2Operand : AsmOperandClass {
626 let Name = "DispSPE2"; let PredicateMethod = "isU6ImmX2";
627 let RenderMethod = "addImmOperands";
629 def dispSPE2 : Operand<iPTR> {
630 let ParserMatchClass = PPCDispSPE2Operand;
633 def memri : Operand<iPTR> {
634 let PrintMethod = "printMemRegImm";
635 let MIOperandInfo = (ops dispRI:$imm, ptr_rc_nor0:$reg);
636 let EncoderMethod = "getMemRIEncoding";
637 let DecoderMethod = "decodeMemRIOperands";
639 def memrr : Operand<iPTR> {
640 let PrintMethod = "printMemRegReg";
641 let MIOperandInfo = (ops ptr_rc_nor0:$ptrreg, ptr_rc_idx:$offreg);
643 def memrix : Operand<iPTR> { // memri where the imm is 4-aligned.
644 let PrintMethod = "printMemRegImm";
645 let MIOperandInfo = (ops dispRIX:$imm, ptr_rc_nor0:$reg);
646 let EncoderMethod = "getMemRIXEncoding";
647 let DecoderMethod = "decodeMemRIXOperands";
649 def spe8dis : Operand<iPTR> { // SPE displacement where the imm is 8-aligned.
650 let PrintMethod = "printMemRegImm";
651 let MIOperandInfo = (ops dispSPE8:$imm, ptr_rc_nor0:$reg);
652 let EncoderMethod = "getSPE8DisEncoding";
654 def spe4dis : Operand<iPTR> { // SPE displacement where the imm is 4-aligned.
655 let PrintMethod = "printMemRegImm";
656 let MIOperandInfo = (ops dispSPE4:$imm, ptr_rc_nor0:$reg);
657 let EncoderMethod = "getSPE4DisEncoding";
659 def spe2dis : Operand<iPTR> { // SPE displacement where the imm is 2-aligned.
660 let PrintMethod = "printMemRegImm";
661 let MIOperandInfo = (ops dispSPE2:$imm, ptr_rc_nor0:$reg);
662 let EncoderMethod = "getSPE2DisEncoding";
665 // A single-register address. This is used with the SjLj
666 // pseudo-instructions.
667 def memr : Operand<iPTR> {
668 let MIOperandInfo = (ops ptr_rc:$ptrreg);
670 def PPCTLSRegOperand : AsmOperandClass {
671 let Name = "TLSReg"; let PredicateMethod = "isTLSReg";
672 let RenderMethod = "addTLSRegOperands";
674 def tlsreg32 : Operand<i32> {
675 let EncoderMethod = "getTLSRegEncoding";
676 let ParserMatchClass = PPCTLSRegOperand;
678 def tlsgd32 : Operand<i32> {}
679 def tlscall32 : Operand<i32> {
680 let PrintMethod = "printTLSCall";
681 let MIOperandInfo = (ops calltarget:$func, tlsgd32:$sym);
682 let EncoderMethod = "getTLSCallEncoding";
685 // PowerPC Predicate operand.
686 def pred : Operand<OtherVT> {
687 let PrintMethod = "printPredicateOperand";
688 let MIOperandInfo = (ops i32imm:$bibo, crrc:$reg);
691 // Define PowerPC specific addressing mode.
692 def iaddr : ComplexPattern<iPTR, 2, "SelectAddrImm", [], []>;
693 def xaddr : ComplexPattern<iPTR, 2, "SelectAddrIdx", [], []>;
694 def xoaddr : ComplexPattern<iPTR, 2, "SelectAddrIdxOnly",[], []>;
695 def ixaddr : ComplexPattern<iPTR, 2, "SelectAddrImmX4", [], []>; // "std"
697 // The address in a single register. This is used with the SjLj
698 // pseudo-instructions.
699 def addr : ComplexPattern<iPTR, 1, "SelectAddr",[], []>;
701 /// This is just the offset part of iaddr, used for preinc.
702 def iaddroff : ComplexPattern<iPTR, 1, "SelectAddrImmOffs", [], []>;
704 //===----------------------------------------------------------------------===//
705 // PowerPC Instruction Predicate Definitions.
706 def In32BitMode : Predicate<"!PPCSubTarget->isPPC64()">;
707 def In64BitMode : Predicate<"PPCSubTarget->isPPC64()">;
708 def IsBookE : Predicate<"PPCSubTarget->isBookE()">;
709 def IsNotBookE : Predicate<"!PPCSubTarget->isBookE()">;
710 def HasOnlyMSYNC : Predicate<"PPCSubTarget->hasOnlyMSYNC()">;
711 def HasSYNC : Predicate<"!PPCSubTarget->hasOnlyMSYNC()">;
712 def IsPPC4xx : Predicate<"PPCSubTarget->isPPC4xx()">;
713 def IsPPC6xx : Predicate<"PPCSubTarget->isPPC6xx()">;
714 def IsE500 : Predicate<"PPCSubTarget->isE500()">;
715 def HasSPE : Predicate<"PPCSubTarget->HasSPE()">;
716 def HasICBT : Predicate<"PPCSubTarget->hasICBT()">;
718 def NoNaNsFPMath : Predicate<"TM.Options.NoNaNsFPMath">;
719 def NaNsFPMath : Predicate<"!TM.Options.NoNaNsFPMath">;
721 //===----------------------------------------------------------------------===//
722 // PowerPC Multiclass Definitions.
724 multiclass XForm_6r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
725 string asmbase, string asmstr, InstrItinClass itin,
727 let BaseName = asmbase in {
728 def NAME : XForm_6<opcode, xo, OOL, IOL,
729 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
730 pattern>, RecFormRel;
732 def o : XForm_6<opcode, xo, OOL, IOL,
733 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
734 []>, isDOT, RecFormRel;
738 multiclass XForm_6rc<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
739 string asmbase, string asmstr, InstrItinClass itin,
741 let BaseName = asmbase in {
742 let Defs = [CARRY] in
743 def NAME : XForm_6<opcode, xo, OOL, IOL,
744 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
745 pattern>, RecFormRel;
746 let Defs = [CARRY, CR0] in
747 def o : XForm_6<opcode, xo, OOL, IOL,
748 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
749 []>, isDOT, RecFormRel;
753 multiclass XForm_10rc<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
754 string asmbase, string asmstr, InstrItinClass itin,
756 let BaseName = asmbase in {
757 let Defs = [CARRY] in
758 def NAME : XForm_10<opcode, xo, OOL, IOL,
759 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
760 pattern>, RecFormRel;
761 let Defs = [CARRY, CR0] in
762 def o : XForm_10<opcode, xo, OOL, IOL,
763 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
764 []>, isDOT, RecFormRel;
768 multiclass XForm_11r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
769 string asmbase, string asmstr, InstrItinClass itin,
771 let BaseName = asmbase in {
772 def NAME : XForm_11<opcode, xo, OOL, IOL,
773 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
774 pattern>, RecFormRel;
776 def o : XForm_11<opcode, xo, OOL, IOL,
777 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
778 []>, isDOT, RecFormRel;
782 multiclass XOForm_1r<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
783 string asmbase, string asmstr, InstrItinClass itin,
785 let BaseName = asmbase in {
786 def NAME : XOForm_1<opcode, xo, oe, OOL, IOL,
787 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
788 pattern>, RecFormRel;
790 def o : XOForm_1<opcode, xo, oe, OOL, IOL,
791 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
792 []>, isDOT, RecFormRel;
796 multiclass XOForm_1rc<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
797 string asmbase, string asmstr, InstrItinClass itin,
799 let BaseName = asmbase in {
800 let Defs = [CARRY] in
801 def NAME : XOForm_1<opcode, xo, oe, OOL, IOL,
802 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
803 pattern>, RecFormRel;
804 let Defs = [CARRY, CR0] in
805 def o : XOForm_1<opcode, xo, oe, OOL, IOL,
806 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
807 []>, isDOT, RecFormRel;
811 multiclass XOForm_3r<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
812 string asmbase, string asmstr, InstrItinClass itin,
814 let BaseName = asmbase in {
815 def NAME : XOForm_3<opcode, xo, oe, OOL, IOL,
816 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
817 pattern>, RecFormRel;
819 def o : XOForm_3<opcode, xo, oe, OOL, IOL,
820 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
821 []>, isDOT, RecFormRel;
825 multiclass XOForm_3rc<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
826 string asmbase, string asmstr, InstrItinClass itin,
828 let BaseName = asmbase in {
829 let Defs = [CARRY] in
830 def NAME : XOForm_3<opcode, xo, oe, OOL, IOL,
831 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
832 pattern>, RecFormRel;
833 let Defs = [CARRY, CR0] in
834 def o : XOForm_3<opcode, xo, oe, OOL, IOL,
835 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
836 []>, isDOT, RecFormRel;
840 multiclass MForm_2r<bits<6> opcode, dag OOL, dag IOL,
841 string asmbase, string asmstr, InstrItinClass itin,
843 let BaseName = asmbase in {
844 def NAME : MForm_2<opcode, OOL, IOL,
845 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
846 pattern>, RecFormRel;
848 def o : MForm_2<opcode, OOL, IOL,
849 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
850 []>, isDOT, RecFormRel;
854 multiclass MDForm_1r<bits<6> opcode, bits<3> xo, dag OOL, dag IOL,
855 string asmbase, string asmstr, InstrItinClass itin,
857 let BaseName = asmbase in {
858 def NAME : MDForm_1<opcode, xo, OOL, IOL,
859 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
860 pattern>, RecFormRel;
862 def o : MDForm_1<opcode, xo, OOL, IOL,
863 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
864 []>, isDOT, RecFormRel;
868 multiclass MDSForm_1r<bits<6> opcode, bits<4> xo, dag OOL, dag IOL,
869 string asmbase, string asmstr, InstrItinClass itin,
871 let BaseName = asmbase in {
872 def NAME : MDSForm_1<opcode, xo, OOL, IOL,
873 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
874 pattern>, RecFormRel;
876 def o : MDSForm_1<opcode, xo, OOL, IOL,
877 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
878 []>, isDOT, RecFormRel;
882 multiclass XSForm_1rc<bits<6> opcode, bits<9> xo, dag OOL, dag IOL,
883 string asmbase, string asmstr, InstrItinClass itin,
885 let BaseName = asmbase in {
886 let Defs = [CARRY] in
887 def NAME : XSForm_1<opcode, xo, OOL, IOL,
888 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
889 pattern>, RecFormRel;
890 let Defs = [CARRY, CR0] in
891 def o : XSForm_1<opcode, xo, OOL, IOL,
892 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
893 []>, isDOT, RecFormRel;
897 multiclass XForm_26r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
898 string asmbase, string asmstr, InstrItinClass itin,
900 let BaseName = asmbase in {
901 def NAME : XForm_26<opcode, xo, OOL, IOL,
902 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
903 pattern>, RecFormRel;
905 def o : XForm_26<opcode, xo, OOL, IOL,
906 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
907 []>, isDOT, RecFormRel;
911 multiclass XForm_28r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
912 string asmbase, string asmstr, InstrItinClass itin,
914 let BaseName = asmbase in {
915 def NAME : XForm_28<opcode, xo, OOL, IOL,
916 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
917 pattern>, RecFormRel;
919 def o : XForm_28<opcode, xo, OOL, IOL,
920 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
921 []>, isDOT, RecFormRel;
925 multiclass AForm_1r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL,
926 string asmbase, string asmstr, InstrItinClass itin,
928 let BaseName = asmbase in {
929 def NAME : AForm_1<opcode, xo, OOL, IOL,
930 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
931 pattern>, RecFormRel;
933 def o : AForm_1<opcode, xo, OOL, IOL,
934 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
935 []>, isDOT, RecFormRel;
939 multiclass AForm_2r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL,
940 string asmbase, string asmstr, InstrItinClass itin,
942 let BaseName = asmbase in {
943 def NAME : AForm_2<opcode, xo, OOL, IOL,
944 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
945 pattern>, RecFormRel;
947 def o : AForm_2<opcode, xo, OOL, IOL,
948 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
949 []>, isDOT, RecFormRel;
953 multiclass AForm_3r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL,
954 string asmbase, string asmstr, InstrItinClass itin,
956 let BaseName = asmbase in {
957 def NAME : AForm_3<opcode, xo, OOL, IOL,
958 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
959 pattern>, RecFormRel;
961 def o : AForm_3<opcode, xo, OOL, IOL,
962 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
963 []>, isDOT, RecFormRel;
967 //===----------------------------------------------------------------------===//
968 // PowerPC Instruction Definitions.
970 // Pseudo-instructions:
972 let hasCtrlDep = 1 in {
973 let Defs = [R1], Uses = [R1] in {
974 def ADJCALLSTACKDOWN : Pseudo<(outs), (ins u16imm:$amt), "#ADJCALLSTACKDOWN $amt",
975 [(callseq_start timm:$amt)]>;
976 def ADJCALLSTACKUP : Pseudo<(outs), (ins u16imm:$amt1, u16imm:$amt2), "#ADJCALLSTACKUP $amt1 $amt2",
977 [(callseq_end timm:$amt1, timm:$amt2)]>;
980 def UPDATE_VRSAVE : Pseudo<(outs gprc:$rD), (ins gprc:$rS),
981 "UPDATE_VRSAVE $rD, $rS", []>;
984 let Defs = [R1], Uses = [R1] in
985 def DYNALLOC : Pseudo<(outs gprc:$result), (ins gprc:$negsize, memri:$fpsi), "#DYNALLOC",
987 (PPCdynalloc i32:$negsize, iaddr:$fpsi))]>;
989 // SELECT_CC_* - Used to implement the SELECT_CC DAG operation. Expanded after
990 // instruction selection into a branch sequence.
991 let usesCustomInserter = 1, // Expanded after instruction selection.
992 PPC970_Single = 1 in {
993 // Note that SELECT_CC_I4 and SELECT_CC_I8 use the no-r0 register classes
994 // because either operand might become the first operand in an isel, and
995 // that operand cannot be r0.
996 def SELECT_CC_I4 : Pseudo<(outs gprc:$dst), (ins crrc:$cond,
997 gprc_nor0:$T, gprc_nor0:$F,
998 i32imm:$BROPC), "#SELECT_CC_I4",
1000 def SELECT_CC_I8 : Pseudo<(outs g8rc:$dst), (ins crrc:$cond,
1001 g8rc_nox0:$T, g8rc_nox0:$F,
1002 i32imm:$BROPC), "#SELECT_CC_I8",
1004 def SELECT_CC_F4 : Pseudo<(outs f4rc:$dst), (ins crrc:$cond, f4rc:$T, f4rc:$F,
1005 i32imm:$BROPC), "#SELECT_CC_F4",
1007 def SELECT_CC_F8 : Pseudo<(outs f8rc:$dst), (ins crrc:$cond, f8rc:$T, f8rc:$F,
1008 i32imm:$BROPC), "#SELECT_CC_F8",
1010 def SELECT_CC_VRRC: Pseudo<(outs vrrc:$dst), (ins crrc:$cond, vrrc:$T, vrrc:$F,
1011 i32imm:$BROPC), "#SELECT_CC_VRRC",
1014 // SELECT_* pseudo instructions, like SELECT_CC_* but taking condition
1015 // register bit directly.
1016 def SELECT_I4 : Pseudo<(outs gprc:$dst), (ins crbitrc:$cond,
1017 gprc_nor0:$T, gprc_nor0:$F), "#SELECT_I4",
1018 [(set i32:$dst, (select i1:$cond, i32:$T, i32:$F))]>;
1019 def SELECT_I8 : Pseudo<(outs g8rc:$dst), (ins crbitrc:$cond,
1020 g8rc_nox0:$T, g8rc_nox0:$F), "#SELECT_I8",
1021 [(set i64:$dst, (select i1:$cond, i64:$T, i64:$F))]>;
1022 def SELECT_F4 : Pseudo<(outs f4rc:$dst), (ins crbitrc:$cond,
1023 f4rc:$T, f4rc:$F), "#SELECT_F4",
1024 [(set f32:$dst, (select i1:$cond, f32:$T, f32:$F))]>;
1025 def SELECT_F8 : Pseudo<(outs f8rc:$dst), (ins crbitrc:$cond,
1026 f8rc:$T, f8rc:$F), "#SELECT_F8",
1027 [(set f64:$dst, (select i1:$cond, f64:$T, f64:$F))]>;
1028 def SELECT_VRRC: Pseudo<(outs vrrc:$dst), (ins crbitrc:$cond,
1029 vrrc:$T, vrrc:$F), "#SELECT_VRRC",
1031 (select i1:$cond, v4i32:$T, v4i32:$F))]>;
1034 // SPILL_CR - Indicate that we're dumping the CR register, so we'll need to
1035 // scavenge a register for it.
1036 let mayStore = 1 in {
1037 def SPILL_CR : Pseudo<(outs), (ins crrc:$cond, memri:$F),
1039 def SPILL_CRBIT : Pseudo<(outs), (ins crbitrc:$cond, memri:$F),
1040 "#SPILL_CRBIT", []>;
1043 // RESTORE_CR - Indicate that we're restoring the CR register (previously
1044 // spilled), so we'll need to scavenge a register for it.
1045 let mayLoad = 1 in {
1046 def RESTORE_CR : Pseudo<(outs crrc:$cond), (ins memri:$F),
1048 def RESTORE_CRBIT : Pseudo<(outs crbitrc:$cond), (ins memri:$F),
1049 "#RESTORE_CRBIT", []>;
1052 let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7 in {
1053 let isReturn = 1, Uses = [LR, RM] in
1054 def BLR : XLForm_2_ext<19, 16, 20, 0, 0, (outs), (ins), "blr", IIC_BrB,
1055 [(retflag)]>, Requires<[In32BitMode]>;
1056 let isBranch = 1, isIndirectBranch = 1, Uses = [CTR] in {
1057 def BCTR : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
1060 let isCodeGenOnly = 1 in {
1061 def BCCCTR : XLForm_2_br<19, 528, 0, (outs), (ins pred:$cond),
1062 "b${cond:cc}ctr${cond:pm} ${cond:reg}", IIC_BrB,
1065 def BCCTR : XLForm_2_br2<19, 528, 12, 0, (outs), (ins crbitrc:$bi),
1066 "bcctr 12, $bi, 0", IIC_BrB, []>;
1067 def BCCTRn : XLForm_2_br2<19, 528, 4, 0, (outs), (ins crbitrc:$bi),
1068 "bcctr 4, $bi, 0", IIC_BrB, []>;
1074 def MovePCtoLR : Pseudo<(outs), (ins), "#MovePCtoLR", []>,
1077 def MoveGOTtoLR : Pseudo<(outs), (ins), "#MoveGOTtoLR", []>,
1080 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7 in {
1081 let isBarrier = 1 in {
1082 def B : IForm<18, 0, 0, (outs), (ins directbrtarget:$dst),
1085 def BA : IForm<18, 1, 0, (outs), (ins absdirectbrtarget:$dst),
1086 "ba $dst", IIC_BrB, []>;
1089 // BCC represents an arbitrary conditional branch on a predicate.
1090 // FIXME: should be able to write a pattern for PPCcondbranch, but can't use
1091 // a two-value operand where a dag node expects two operands. :(
1092 let isCodeGenOnly = 1 in {
1093 def BCC : BForm<16, 0, 0, (outs), (ins pred:$cond, condbrtarget:$dst),
1094 "b${cond:cc}${cond:pm} ${cond:reg}, $dst"
1095 /*[(PPCcondbranch crrc:$crS, imm:$opc, bb:$dst)]*/>;
1096 def BCCA : BForm<16, 1, 0, (outs), (ins pred:$cond, abscondbrtarget:$dst),
1097 "b${cond:cc}a${cond:pm} ${cond:reg}, $dst">;
1099 let isReturn = 1, Uses = [LR, RM] in
1100 def BCCLR : XLForm_2_br<19, 16, 0, (outs), (ins pred:$cond),
1101 "b${cond:cc}lr${cond:pm} ${cond:reg}", IIC_BrB, []>;
1104 let isCodeGenOnly = 1 in {
1105 let Pattern = [(brcond i1:$bi, bb:$dst)] in
1106 def BC : BForm_4<16, 12, 0, 0, (outs), (ins crbitrc:$bi, condbrtarget:$dst),
1107 "bc 12, $bi, $dst">;
1109 let Pattern = [(brcond (not i1:$bi), bb:$dst)] in
1110 def BCn : BForm_4<16, 4, 0, 0, (outs), (ins crbitrc:$bi, condbrtarget:$dst),
1113 let isReturn = 1, Uses = [LR, RM] in
1114 def BCLR : XLForm_2_br2<19, 16, 12, 0, (outs), (ins crbitrc:$bi),
1115 "bclr 12, $bi, 0", IIC_BrB, []>;
1116 def BCLRn : XLForm_2_br2<19, 16, 4, 0, (outs), (ins crbitrc:$bi),
1117 "bclr 4, $bi, 0", IIC_BrB, []>;
1120 let isReturn = 1, Defs = [CTR], Uses = [CTR, LR, RM] in {
1121 def BDZLR : XLForm_2_ext<19, 16, 18, 0, 0, (outs), (ins),
1122 "bdzlr", IIC_BrB, []>;
1123 def BDNZLR : XLForm_2_ext<19, 16, 16, 0, 0, (outs), (ins),
1124 "bdnzlr", IIC_BrB, []>;
1125 def BDZLRp : XLForm_2_ext<19, 16, 27, 0, 0, (outs), (ins),
1126 "bdzlr+", IIC_BrB, []>;
1127 def BDNZLRp: XLForm_2_ext<19, 16, 25, 0, 0, (outs), (ins),
1128 "bdnzlr+", IIC_BrB, []>;
1129 def BDZLRm : XLForm_2_ext<19, 16, 26, 0, 0, (outs), (ins),
1130 "bdzlr-", IIC_BrB, []>;
1131 def BDNZLRm: XLForm_2_ext<19, 16, 24, 0, 0, (outs), (ins),
1132 "bdnzlr-", IIC_BrB, []>;
1135 let Defs = [CTR], Uses = [CTR] in {
1136 def BDZ : BForm_1<16, 18, 0, 0, (outs), (ins condbrtarget:$dst),
1138 def BDNZ : BForm_1<16, 16, 0, 0, (outs), (ins condbrtarget:$dst),
1140 def BDZA : BForm_1<16, 18, 1, 0, (outs), (ins abscondbrtarget:$dst),
1142 def BDNZA : BForm_1<16, 16, 1, 0, (outs), (ins abscondbrtarget:$dst),
1144 def BDZp : BForm_1<16, 27, 0, 0, (outs), (ins condbrtarget:$dst),
1146 def BDNZp: BForm_1<16, 25, 0, 0, (outs), (ins condbrtarget:$dst),
1148 def BDZAp : BForm_1<16, 27, 1, 0, (outs), (ins abscondbrtarget:$dst),
1150 def BDNZAp: BForm_1<16, 25, 1, 0, (outs), (ins abscondbrtarget:$dst),
1152 def BDZm : BForm_1<16, 26, 0, 0, (outs), (ins condbrtarget:$dst),
1154 def BDNZm: BForm_1<16, 24, 0, 0, (outs), (ins condbrtarget:$dst),
1156 def BDZAm : BForm_1<16, 26, 1, 0, (outs), (ins abscondbrtarget:$dst),
1158 def BDNZAm: BForm_1<16, 24, 1, 0, (outs), (ins abscondbrtarget:$dst),
1163 // The unconditional BCL used by the SjLj setjmp code.
1164 let isCall = 1, hasCtrlDep = 1, isCodeGenOnly = 1, PPC970_Unit = 7 in {
1165 let Defs = [LR], Uses = [RM] in {
1166 def BCLalways : BForm_2<16, 20, 31, 0, 1, (outs), (ins condbrtarget:$dst),
1167 "bcl 20, 31, $dst">;
1171 let isCall = 1, PPC970_Unit = 7, Defs = [LR] in {
1172 // Convenient aliases for call instructions
1173 let Uses = [RM] in {
1174 def BL : IForm<18, 0, 1, (outs), (ins calltarget:$func),
1175 "bl $func", IIC_BrB, []>; // See Pat patterns below.
1176 def BLA : IForm<18, 1, 1, (outs), (ins abscalltarget:$func),
1177 "bla $func", IIC_BrB, [(PPCcall (i32 imm:$func))]>;
1179 let isCodeGenOnly = 1 in {
1180 def BL_TLS : IForm<18, 0, 1, (outs), (ins tlscall32:$func),
1181 "bl $func", IIC_BrB, []>;
1182 def BCCL : BForm<16, 0, 1, (outs), (ins pred:$cond, condbrtarget:$dst),
1183 "b${cond:cc}l${cond:pm} ${cond:reg}, $dst">;
1184 def BCCLA : BForm<16, 1, 1, (outs), (ins pred:$cond, abscondbrtarget:$dst),
1185 "b${cond:cc}la${cond:pm} ${cond:reg}, $dst">;
1187 def BCL : BForm_4<16, 12, 0, 1, (outs),
1188 (ins crbitrc:$bi, condbrtarget:$dst),
1189 "bcl 12, $bi, $dst">;
1190 def BCLn : BForm_4<16, 4, 0, 1, (outs),
1191 (ins crbitrc:$bi, condbrtarget:$dst),
1192 "bcl 4, $bi, $dst">;
1195 let Uses = [CTR, RM] in {
1196 def BCTRL : XLForm_2_ext<19, 528, 20, 0, 1, (outs), (ins),
1197 "bctrl", IIC_BrB, [(PPCbctrl)]>,
1198 Requires<[In32BitMode]>;
1200 let isCodeGenOnly = 1 in {
1201 def BCCCTRL : XLForm_2_br<19, 528, 1, (outs), (ins pred:$cond),
1202 "b${cond:cc}ctrl${cond:pm} ${cond:reg}", IIC_BrB,
1205 def BCCTRL : XLForm_2_br2<19, 528, 12, 1, (outs), (ins crbitrc:$bi),
1206 "bcctrl 12, $bi, 0", IIC_BrB, []>;
1207 def BCCTRLn : XLForm_2_br2<19, 528, 4, 1, (outs), (ins crbitrc:$bi),
1208 "bcctrl 4, $bi, 0", IIC_BrB, []>;
1211 let Uses = [LR, RM] in {
1212 def BLRL : XLForm_2_ext<19, 16, 20, 0, 1, (outs), (ins),
1213 "blrl", IIC_BrB, []>;
1215 let isCodeGenOnly = 1 in {
1216 def BCCLRL : XLForm_2_br<19, 16, 1, (outs), (ins pred:$cond),
1217 "b${cond:cc}lrl${cond:pm} ${cond:reg}", IIC_BrB,
1220 def BCLRL : XLForm_2_br2<19, 16, 12, 1, (outs), (ins crbitrc:$bi),
1221 "bclrl 12, $bi, 0", IIC_BrB, []>;
1222 def BCLRLn : XLForm_2_br2<19, 16, 4, 1, (outs), (ins crbitrc:$bi),
1223 "bclrl 4, $bi, 0", IIC_BrB, []>;
1226 let Defs = [CTR], Uses = [CTR, RM] in {
1227 def BDZL : BForm_1<16, 18, 0, 1, (outs), (ins condbrtarget:$dst),
1229 def BDNZL : BForm_1<16, 16, 0, 1, (outs), (ins condbrtarget:$dst),
1231 def BDZLA : BForm_1<16, 18, 1, 1, (outs), (ins abscondbrtarget:$dst),
1233 def BDNZLA : BForm_1<16, 16, 1, 1, (outs), (ins abscondbrtarget:$dst),
1235 def BDZLp : BForm_1<16, 27, 0, 1, (outs), (ins condbrtarget:$dst),
1237 def BDNZLp: BForm_1<16, 25, 0, 1, (outs), (ins condbrtarget:$dst),
1239 def BDZLAp : BForm_1<16, 27, 1, 1, (outs), (ins abscondbrtarget:$dst),
1241 def BDNZLAp: BForm_1<16, 25, 1, 1, (outs), (ins abscondbrtarget:$dst),
1243 def BDZLm : BForm_1<16, 26, 0, 1, (outs), (ins condbrtarget:$dst),
1245 def BDNZLm: BForm_1<16, 24, 0, 1, (outs), (ins condbrtarget:$dst),
1247 def BDZLAm : BForm_1<16, 26, 1, 1, (outs), (ins abscondbrtarget:$dst),
1249 def BDNZLAm: BForm_1<16, 24, 1, 1, (outs), (ins abscondbrtarget:$dst),
1252 let Defs = [CTR], Uses = [CTR, LR, RM] in {
1253 def BDZLRL : XLForm_2_ext<19, 16, 18, 0, 1, (outs), (ins),
1254 "bdzlrl", IIC_BrB, []>;
1255 def BDNZLRL : XLForm_2_ext<19, 16, 16, 0, 1, (outs), (ins),
1256 "bdnzlrl", IIC_BrB, []>;
1257 def BDZLRLp : XLForm_2_ext<19, 16, 27, 0, 1, (outs), (ins),
1258 "bdzlrl+", IIC_BrB, []>;
1259 def BDNZLRLp: XLForm_2_ext<19, 16, 25, 0, 1, (outs), (ins),
1260 "bdnzlrl+", IIC_BrB, []>;
1261 def BDZLRLm : XLForm_2_ext<19, 16, 26, 0, 1, (outs), (ins),
1262 "bdzlrl-", IIC_BrB, []>;
1263 def BDNZLRLm: XLForm_2_ext<19, 16, 24, 0, 1, (outs), (ins),
1264 "bdnzlrl-", IIC_BrB, []>;
1268 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
1269 def TCRETURNdi :Pseudo< (outs),
1270 (ins calltarget:$dst, i32imm:$offset),
1271 "#TC_RETURNd $dst $offset",
1275 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
1276 def TCRETURNai :Pseudo<(outs), (ins abscalltarget:$func, i32imm:$offset),
1277 "#TC_RETURNa $func $offset",
1278 [(PPCtc_return (i32 imm:$func), imm:$offset)]>;
1280 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
1281 def TCRETURNri : Pseudo<(outs), (ins CTRRC:$dst, i32imm:$offset),
1282 "#TC_RETURNr $dst $offset",
1286 let isCodeGenOnly = 1 in {
1288 let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, isBranch = 1,
1289 isIndirectBranch = 1, isCall = 1, isReturn = 1, Uses = [CTR, RM] in
1290 def TAILBCTR : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
1291 []>, Requires<[In32BitMode]>;
1293 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
1294 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
1295 def TAILB : IForm<18, 0, 0, (outs), (ins calltarget:$dst),
1299 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
1300 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
1301 def TAILBA : IForm<18, 0, 0, (outs), (ins abscalltarget:$dst),
1307 let hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
1309 def EH_SjLj_SetJmp32 : Pseudo<(outs gprc:$dst), (ins memr:$buf),
1310 "#EH_SJLJ_SETJMP32",
1311 [(set i32:$dst, (PPCeh_sjlj_setjmp addr:$buf))]>,
1312 Requires<[In32BitMode]>;
1313 let isTerminator = 1 in
1314 def EH_SjLj_LongJmp32 : Pseudo<(outs), (ins memr:$buf),
1315 "#EH_SJLJ_LONGJMP32",
1316 [(PPCeh_sjlj_longjmp addr:$buf)]>,
1317 Requires<[In32BitMode]>;
1320 let isBranch = 1, isTerminator = 1 in {
1321 def EH_SjLj_Setup : Pseudo<(outs), (ins directbrtarget:$dst),
1322 "#EH_SjLj_Setup\t$dst", []>;
1326 let PPC970_Unit = 7 in {
1327 def SC : SCForm<17, 1, (outs), (ins i32imm:$lev),
1328 "sc $lev", IIC_BrB, [(PPCsc (i32 imm:$lev))]>;
1331 // DCB* instructions.
1332 def DCBA : DCB_Form<758, 0, (outs), (ins memrr:$dst), "dcba $dst",
1333 IIC_LdStDCBF, [(int_ppc_dcba xoaddr:$dst)]>,
1334 PPC970_DGroup_Single;
1335 def DCBF : DCB_Form<86, 0, (outs), (ins memrr:$dst), "dcbf $dst",
1336 IIC_LdStDCBF, [(int_ppc_dcbf xoaddr:$dst)]>,
1337 PPC970_DGroup_Single;
1338 def DCBI : DCB_Form<470, 0, (outs), (ins memrr:$dst), "dcbi $dst",
1339 IIC_LdStDCBF, [(int_ppc_dcbi xoaddr:$dst)]>,
1340 PPC970_DGroup_Single;
1341 def DCBST : DCB_Form<54, 0, (outs), (ins memrr:$dst), "dcbst $dst",
1342 IIC_LdStDCBF, [(int_ppc_dcbst xoaddr:$dst)]>,
1343 PPC970_DGroup_Single;
1344 def DCBT : DCB_Form<278, 0, (outs), (ins memrr:$dst), "dcbt $dst",
1345 IIC_LdStDCBF, [(int_ppc_dcbt xoaddr:$dst)]>,
1346 PPC970_DGroup_Single;
1347 def DCBTST : DCB_Form<246, 0, (outs), (ins memrr:$dst), "dcbtst $dst",
1348 IIC_LdStDCBF, [(int_ppc_dcbtst xoaddr:$dst)]>,
1349 PPC970_DGroup_Single;
1350 def DCBZ : DCB_Form<1014, 0, (outs), (ins memrr:$dst), "dcbz $dst",
1351 IIC_LdStDCBF, [(int_ppc_dcbz xoaddr:$dst)]>,
1352 PPC970_DGroup_Single;
1353 def DCBZL : DCB_Form<1014, 1, (outs), (ins memrr:$dst), "dcbzl $dst",
1354 IIC_LdStDCBF, [(int_ppc_dcbzl xoaddr:$dst)]>,
1355 PPC970_DGroup_Single;
1357 def ICBT : XForm_icbt<31, 22, (outs), (ins u4imm:$CT, memrr:$src),
1358 "icbt $CT, $src", IIC_LdStLoad>, Requires<[HasICBT]>;
1360 def : Pat<(prefetch xoaddr:$dst, (i32 0), imm, (i32 1)),
1361 (DCBT xoaddr:$dst)>; // data prefetch for loads
1362 def : Pat<(prefetch xoaddr:$dst, (i32 1), imm, (i32 1)),
1363 (DCBTST xoaddr:$dst)>; // data prefetch for stores
1364 def : Pat<(prefetch xoaddr:$dst, (i32 0), imm, (i32 0)),
1365 (ICBT 0, xoaddr:$dst)>, Requires<[HasICBT]>; // inst prefetch (for read)
1367 // Atomic operations
1368 let usesCustomInserter = 1 in {
1369 let Defs = [CR0] in {
1370 def ATOMIC_LOAD_ADD_I8 : Pseudo<
1371 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I8",
1372 [(set i32:$dst, (atomic_load_add_8 xoaddr:$ptr, i32:$incr))]>;
1373 def ATOMIC_LOAD_SUB_I8 : Pseudo<
1374 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I8",
1375 [(set i32:$dst, (atomic_load_sub_8 xoaddr:$ptr, i32:$incr))]>;
1376 def ATOMIC_LOAD_AND_I8 : Pseudo<
1377 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I8",
1378 [(set i32:$dst, (atomic_load_and_8 xoaddr:$ptr, i32:$incr))]>;
1379 def ATOMIC_LOAD_OR_I8 : Pseudo<
1380 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I8",
1381 [(set i32:$dst, (atomic_load_or_8 xoaddr:$ptr, i32:$incr))]>;
1382 def ATOMIC_LOAD_XOR_I8 : Pseudo<
1383 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "ATOMIC_LOAD_XOR_I8",
1384 [(set i32:$dst, (atomic_load_xor_8 xoaddr:$ptr, i32:$incr))]>;
1385 def ATOMIC_LOAD_NAND_I8 : Pseudo<
1386 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I8",
1387 [(set i32:$dst, (atomic_load_nand_8 xoaddr:$ptr, i32:$incr))]>;
1388 def ATOMIC_LOAD_ADD_I16 : Pseudo<
1389 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I16",
1390 [(set i32:$dst, (atomic_load_add_16 xoaddr:$ptr, i32:$incr))]>;
1391 def ATOMIC_LOAD_SUB_I16 : Pseudo<
1392 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I16",
1393 [(set i32:$dst, (atomic_load_sub_16 xoaddr:$ptr, i32:$incr))]>;
1394 def ATOMIC_LOAD_AND_I16 : Pseudo<
1395 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I16",
1396 [(set i32:$dst, (atomic_load_and_16 xoaddr:$ptr, i32:$incr))]>;
1397 def ATOMIC_LOAD_OR_I16 : Pseudo<
1398 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I16",
1399 [(set i32:$dst, (atomic_load_or_16 xoaddr:$ptr, i32:$incr))]>;
1400 def ATOMIC_LOAD_XOR_I16 : Pseudo<
1401 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_XOR_I16",
1402 [(set i32:$dst, (atomic_load_xor_16 xoaddr:$ptr, i32:$incr))]>;
1403 def ATOMIC_LOAD_NAND_I16 : Pseudo<
1404 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I16",
1405 [(set i32:$dst, (atomic_load_nand_16 xoaddr:$ptr, i32:$incr))]>;
1406 def ATOMIC_LOAD_ADD_I32 : Pseudo<
1407 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I32",
1408 [(set i32:$dst, (atomic_load_add_32 xoaddr:$ptr, i32:$incr))]>;
1409 def ATOMIC_LOAD_SUB_I32 : Pseudo<
1410 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I32",
1411 [(set i32:$dst, (atomic_load_sub_32 xoaddr:$ptr, i32:$incr))]>;
1412 def ATOMIC_LOAD_AND_I32 : Pseudo<
1413 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I32",
1414 [(set i32:$dst, (atomic_load_and_32 xoaddr:$ptr, i32:$incr))]>;
1415 def ATOMIC_LOAD_OR_I32 : Pseudo<
1416 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I32",
1417 [(set i32:$dst, (atomic_load_or_32 xoaddr:$ptr, i32:$incr))]>;
1418 def ATOMIC_LOAD_XOR_I32 : Pseudo<
1419 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_XOR_I32",
1420 [(set i32:$dst, (atomic_load_xor_32 xoaddr:$ptr, i32:$incr))]>;
1421 def ATOMIC_LOAD_NAND_I32 : Pseudo<
1422 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I32",
1423 [(set i32:$dst, (atomic_load_nand_32 xoaddr:$ptr, i32:$incr))]>;
1425 def ATOMIC_CMP_SWAP_I8 : Pseudo<
1426 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I8",
1427 [(set i32:$dst, (atomic_cmp_swap_8 xoaddr:$ptr, i32:$old, i32:$new))]>;
1428 def ATOMIC_CMP_SWAP_I16 : Pseudo<
1429 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I16 $dst $ptr $old $new",
1430 [(set i32:$dst, (atomic_cmp_swap_16 xoaddr:$ptr, i32:$old, i32:$new))]>;
1431 def ATOMIC_CMP_SWAP_I32 : Pseudo<
1432 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I32 $dst $ptr $old $new",
1433 [(set i32:$dst, (atomic_cmp_swap_32 xoaddr:$ptr, i32:$old, i32:$new))]>;
1435 def ATOMIC_SWAP_I8 : Pseudo<
1436 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_i8",
1437 [(set i32:$dst, (atomic_swap_8 xoaddr:$ptr, i32:$new))]>;
1438 def ATOMIC_SWAP_I16 : Pseudo<
1439 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_I16",
1440 [(set i32:$dst, (atomic_swap_16 xoaddr:$ptr, i32:$new))]>;
1441 def ATOMIC_SWAP_I32 : Pseudo<
1442 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_I32",
1443 [(set i32:$dst, (atomic_swap_32 xoaddr:$ptr, i32:$new))]>;
1447 // Instructions to support atomic operations
1448 def LWARX : XForm_1<31, 20, (outs gprc:$rD), (ins memrr:$src),
1449 "lwarx $rD, $src", IIC_LdStLWARX,
1450 [(set i32:$rD, (PPClarx xoaddr:$src))]>;
1453 def STWCX : XForm_1<31, 150, (outs), (ins gprc:$rS, memrr:$dst),
1454 "stwcx. $rS, $dst", IIC_LdStSTWCX,
1455 [(PPCstcx i32:$rS, xoaddr:$dst)]>,
1458 let isTerminator = 1, isBarrier = 1, hasCtrlDep = 1 in
1459 def TRAP : XForm_24<31, 4, (outs), (ins), "trap", IIC_LdStLoad, [(trap)]>;
1461 def TWI : DForm_base<3, (outs), (ins u5imm:$to, gprc:$rA, s16imm:$imm),
1462 "twi $to, $rA, $imm", IIC_IntTrapW, []>;
1463 def TW : XForm_1<31, 4, (outs), (ins u5imm:$to, gprc:$rA, gprc:$rB),
1464 "tw $to, $rA, $rB", IIC_IntTrapW, []>;
1465 def TDI : DForm_base<2, (outs), (ins u5imm:$to, g8rc:$rA, s16imm:$imm),
1466 "tdi $to, $rA, $imm", IIC_IntTrapD, []>;
1467 def TD : XForm_1<31, 68, (outs), (ins u5imm:$to, g8rc:$rA, g8rc:$rB),
1468 "td $to, $rA, $rB", IIC_IntTrapD, []>;
1470 //===----------------------------------------------------------------------===//
1471 // PPC32 Load Instructions.
1474 // Unindexed (r+i) Loads.
1475 let canFoldAsLoad = 1, PPC970_Unit = 2 in {
1476 def LBZ : DForm_1<34, (outs gprc:$rD), (ins memri:$src),
1477 "lbz $rD, $src", IIC_LdStLoad,
1478 [(set i32:$rD, (zextloadi8 iaddr:$src))]>;
1479 def LHA : DForm_1<42, (outs gprc:$rD), (ins memri:$src),
1480 "lha $rD, $src", IIC_LdStLHA,
1481 [(set i32:$rD, (sextloadi16 iaddr:$src))]>,
1482 PPC970_DGroup_Cracked;
1483 def LHZ : DForm_1<40, (outs gprc:$rD), (ins memri:$src),
1484 "lhz $rD, $src", IIC_LdStLoad,
1485 [(set i32:$rD, (zextloadi16 iaddr:$src))]>;
1486 def LWZ : DForm_1<32, (outs gprc:$rD), (ins memri:$src),
1487 "lwz $rD, $src", IIC_LdStLoad,
1488 [(set i32:$rD, (load iaddr:$src))]>;
1490 def LFS : DForm_1<48, (outs f4rc:$rD), (ins memri:$src),
1491 "lfs $rD, $src", IIC_LdStLFD,
1492 [(set f32:$rD, (load iaddr:$src))]>;
1493 def LFD : DForm_1<50, (outs f8rc:$rD), (ins memri:$src),
1494 "lfd $rD, $src", IIC_LdStLFD,
1495 [(set f64:$rD, (load iaddr:$src))]>;
1498 // Unindexed (r+i) Loads with Update (preinc).
1499 let mayLoad = 1, hasSideEffects = 0 in {
1500 def LBZU : DForm_1<35, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1501 "lbzu $rD, $addr", IIC_LdStLoadUpd,
1502 []>, RegConstraint<"$addr.reg = $ea_result">,
1503 NoEncode<"$ea_result">;
1505 def LHAU : DForm_1<43, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1506 "lhau $rD, $addr", IIC_LdStLHAU,
1507 []>, RegConstraint<"$addr.reg = $ea_result">,
1508 NoEncode<"$ea_result">;
1510 def LHZU : DForm_1<41, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1511 "lhzu $rD, $addr", IIC_LdStLoadUpd,
1512 []>, RegConstraint<"$addr.reg = $ea_result">,
1513 NoEncode<"$ea_result">;
1515 def LWZU : DForm_1<33, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1516 "lwzu $rD, $addr", IIC_LdStLoadUpd,
1517 []>, RegConstraint<"$addr.reg = $ea_result">,
1518 NoEncode<"$ea_result">;
1520 def LFSU : DForm_1<49, (outs f4rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1521 "lfsu $rD, $addr", IIC_LdStLFDU,
1522 []>, RegConstraint<"$addr.reg = $ea_result">,
1523 NoEncode<"$ea_result">;
1525 def LFDU : DForm_1<51, (outs f8rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1526 "lfdu $rD, $addr", IIC_LdStLFDU,
1527 []>, RegConstraint<"$addr.reg = $ea_result">,
1528 NoEncode<"$ea_result">;
1531 // Indexed (r+r) Loads with Update (preinc).
1532 def LBZUX : XForm_1<31, 119, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1534 "lbzux $rD, $addr", IIC_LdStLoadUpdX,
1535 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1536 NoEncode<"$ea_result">;
1538 def LHAUX : XForm_1<31, 375, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1540 "lhaux $rD, $addr", IIC_LdStLHAUX,
1541 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1542 NoEncode<"$ea_result">;
1544 def LHZUX : XForm_1<31, 311, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1546 "lhzux $rD, $addr", IIC_LdStLoadUpdX,
1547 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1548 NoEncode<"$ea_result">;
1550 def LWZUX : XForm_1<31, 55, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1552 "lwzux $rD, $addr", IIC_LdStLoadUpdX,
1553 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1554 NoEncode<"$ea_result">;
1556 def LFSUX : XForm_1<31, 567, (outs f4rc:$rD, ptr_rc_nor0:$ea_result),
1558 "lfsux $rD, $addr", IIC_LdStLFDUX,
1559 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1560 NoEncode<"$ea_result">;
1562 def LFDUX : XForm_1<31, 631, (outs f8rc:$rD, ptr_rc_nor0:$ea_result),
1564 "lfdux $rD, $addr", IIC_LdStLFDUX,
1565 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1566 NoEncode<"$ea_result">;
1570 // Indexed (r+r) Loads.
1572 let canFoldAsLoad = 1, PPC970_Unit = 2 in {
1573 def LBZX : XForm_1<31, 87, (outs gprc:$rD), (ins memrr:$src),
1574 "lbzx $rD, $src", IIC_LdStLoad,
1575 [(set i32:$rD, (zextloadi8 xaddr:$src))]>;
1576 def LHAX : XForm_1<31, 343, (outs gprc:$rD), (ins memrr:$src),
1577 "lhax $rD, $src", IIC_LdStLHA,
1578 [(set i32:$rD, (sextloadi16 xaddr:$src))]>,
1579 PPC970_DGroup_Cracked;
1580 def LHZX : XForm_1<31, 279, (outs gprc:$rD), (ins memrr:$src),
1581 "lhzx $rD, $src", IIC_LdStLoad,
1582 [(set i32:$rD, (zextloadi16 xaddr:$src))]>;
1583 def LWZX : XForm_1<31, 23, (outs gprc:$rD), (ins memrr:$src),
1584 "lwzx $rD, $src", IIC_LdStLoad,
1585 [(set i32:$rD, (load xaddr:$src))]>;
1588 def LHBRX : XForm_1<31, 790, (outs gprc:$rD), (ins memrr:$src),
1589 "lhbrx $rD, $src", IIC_LdStLoad,
1590 [(set i32:$rD, (PPClbrx xoaddr:$src, i16))]>;
1591 def LWBRX : XForm_1<31, 534, (outs gprc:$rD), (ins memrr:$src),
1592 "lwbrx $rD, $src", IIC_LdStLoad,
1593 [(set i32:$rD, (PPClbrx xoaddr:$src, i32))]>;
1595 def LFSX : XForm_25<31, 535, (outs f4rc:$frD), (ins memrr:$src),
1596 "lfsx $frD, $src", IIC_LdStLFD,
1597 [(set f32:$frD, (load xaddr:$src))]>;
1598 def LFDX : XForm_25<31, 599, (outs f8rc:$frD), (ins memrr:$src),
1599 "lfdx $frD, $src", IIC_LdStLFD,
1600 [(set f64:$frD, (load xaddr:$src))]>;
1602 def LFIWAX : XForm_25<31, 855, (outs f8rc:$frD), (ins memrr:$src),
1603 "lfiwax $frD, $src", IIC_LdStLFD,
1604 [(set f64:$frD, (PPClfiwax xoaddr:$src))]>;
1605 def LFIWZX : XForm_25<31, 887, (outs f8rc:$frD), (ins memrr:$src),
1606 "lfiwzx $frD, $src", IIC_LdStLFD,
1607 [(set f64:$frD, (PPClfiwzx xoaddr:$src))]>;
1611 def LMW : DForm_1<46, (outs gprc:$rD), (ins memri:$src),
1612 "lmw $rD, $src", IIC_LdStLMW, []>;
1614 //===----------------------------------------------------------------------===//
1615 // PPC32 Store Instructions.
1618 // Unindexed (r+i) Stores.
1619 let PPC970_Unit = 2 in {
1620 def STB : DForm_1<38, (outs), (ins gprc:$rS, memri:$src),
1621 "stb $rS, $src", IIC_LdStStore,
1622 [(truncstorei8 i32:$rS, iaddr:$src)]>;
1623 def STH : DForm_1<44, (outs), (ins gprc:$rS, memri:$src),
1624 "sth $rS, $src", IIC_LdStStore,
1625 [(truncstorei16 i32:$rS, iaddr:$src)]>;
1626 def STW : DForm_1<36, (outs), (ins gprc:$rS, memri:$src),
1627 "stw $rS, $src", IIC_LdStStore,
1628 [(store i32:$rS, iaddr:$src)]>;
1629 def STFS : DForm_1<52, (outs), (ins f4rc:$rS, memri:$dst),
1630 "stfs $rS, $dst", IIC_LdStSTFD,
1631 [(store f32:$rS, iaddr:$dst)]>;
1632 def STFD : DForm_1<54, (outs), (ins f8rc:$rS, memri:$dst),
1633 "stfd $rS, $dst", IIC_LdStSTFD,
1634 [(store f64:$rS, iaddr:$dst)]>;
1637 // Unindexed (r+i) Stores with Update (preinc).
1638 let PPC970_Unit = 2, mayStore = 1 in {
1639 def STBU : DForm_1<39, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst),
1640 "stbu $rS, $dst", IIC_LdStStoreUpd, []>,
1641 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
1642 def STHU : DForm_1<45, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst),
1643 "sthu $rS, $dst", IIC_LdStStoreUpd, []>,
1644 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
1645 def STWU : DForm_1<37, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst),
1646 "stwu $rS, $dst", IIC_LdStStoreUpd, []>,
1647 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
1648 def STFSU : DForm_1<53, (outs ptr_rc_nor0:$ea_res), (ins f4rc:$rS, memri:$dst),
1649 "stfsu $rS, $dst", IIC_LdStSTFDU, []>,
1650 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
1651 def STFDU : DForm_1<55, (outs ptr_rc_nor0:$ea_res), (ins f8rc:$rS, memri:$dst),
1652 "stfdu $rS, $dst", IIC_LdStSTFDU, []>,
1653 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
1656 // Patterns to match the pre-inc stores. We can't put the patterns on
1657 // the instruction definitions directly as ISel wants the address base
1658 // and offset to be separate operands, not a single complex operand.
1659 def : Pat<(pre_truncsti8 i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1660 (STBU $rS, iaddroff:$ptroff, $ptrreg)>;
1661 def : Pat<(pre_truncsti16 i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1662 (STHU $rS, iaddroff:$ptroff, $ptrreg)>;
1663 def : Pat<(pre_store i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1664 (STWU $rS, iaddroff:$ptroff, $ptrreg)>;
1665 def : Pat<(pre_store f32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1666 (STFSU $rS, iaddroff:$ptroff, $ptrreg)>;
1667 def : Pat<(pre_store f64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1668 (STFDU $rS, iaddroff:$ptroff, $ptrreg)>;
1670 // Indexed (r+r) Stores.
1671 let PPC970_Unit = 2 in {
1672 def STBX : XForm_8<31, 215, (outs), (ins gprc:$rS, memrr:$dst),
1673 "stbx $rS, $dst", IIC_LdStStore,
1674 [(truncstorei8 i32:$rS, xaddr:$dst)]>,
1675 PPC970_DGroup_Cracked;
1676 def STHX : XForm_8<31, 407, (outs), (ins gprc:$rS, memrr:$dst),
1677 "sthx $rS, $dst", IIC_LdStStore,
1678 [(truncstorei16 i32:$rS, xaddr:$dst)]>,
1679 PPC970_DGroup_Cracked;
1680 def STWX : XForm_8<31, 151, (outs), (ins gprc:$rS, memrr:$dst),
1681 "stwx $rS, $dst", IIC_LdStStore,
1682 [(store i32:$rS, xaddr:$dst)]>,
1683 PPC970_DGroup_Cracked;
1685 def STHBRX: XForm_8<31, 918, (outs), (ins gprc:$rS, memrr:$dst),
1686 "sthbrx $rS, $dst", IIC_LdStStore,
1687 [(PPCstbrx i32:$rS, xoaddr:$dst, i16)]>,
1688 PPC970_DGroup_Cracked;
1689 def STWBRX: XForm_8<31, 662, (outs), (ins gprc:$rS, memrr:$dst),
1690 "stwbrx $rS, $dst", IIC_LdStStore,
1691 [(PPCstbrx i32:$rS, xoaddr:$dst, i32)]>,
1692 PPC970_DGroup_Cracked;
1694 def STFIWX: XForm_28<31, 983, (outs), (ins f8rc:$frS, memrr:$dst),
1695 "stfiwx $frS, $dst", IIC_LdStSTFD,
1696 [(PPCstfiwx f64:$frS, xoaddr:$dst)]>;
1698 def STFSX : XForm_28<31, 663, (outs), (ins f4rc:$frS, memrr:$dst),
1699 "stfsx $frS, $dst", IIC_LdStSTFD,
1700 [(store f32:$frS, xaddr:$dst)]>;
1701 def STFDX : XForm_28<31, 727, (outs), (ins f8rc:$frS, memrr:$dst),
1702 "stfdx $frS, $dst", IIC_LdStSTFD,
1703 [(store f64:$frS, xaddr:$dst)]>;
1706 // Indexed (r+r) Stores with Update (preinc).
1707 let PPC970_Unit = 2, mayStore = 1 in {
1708 def STBUX : XForm_8<31, 247, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memrr:$dst),
1709 "stbux $rS, $dst", IIC_LdStStoreUpd, []>,
1710 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
1711 PPC970_DGroup_Cracked;
1712 def STHUX : XForm_8<31, 439, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memrr:$dst),
1713 "sthux $rS, $dst", IIC_LdStStoreUpd, []>,
1714 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
1715 PPC970_DGroup_Cracked;
1716 def STWUX : XForm_8<31, 183, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memrr:$dst),
1717 "stwux $rS, $dst", IIC_LdStStoreUpd, []>,
1718 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
1719 PPC970_DGroup_Cracked;
1720 def STFSUX: XForm_8<31, 695, (outs ptr_rc_nor0:$ea_res), (ins f4rc:$rS, memrr:$dst),
1721 "stfsux $rS, $dst", IIC_LdStSTFDU, []>,
1722 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
1723 PPC970_DGroup_Cracked;
1724 def STFDUX: XForm_8<31, 759, (outs ptr_rc_nor0:$ea_res), (ins f8rc:$rS, memrr:$dst),
1725 "stfdux $rS, $dst", IIC_LdStSTFDU, []>,
1726 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
1727 PPC970_DGroup_Cracked;
1730 // Patterns to match the pre-inc stores. We can't put the patterns on
1731 // the instruction definitions directly as ISel wants the address base
1732 // and offset to be separate operands, not a single complex operand.
1733 def : Pat<(pre_truncsti8 i32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1734 (STBUX $rS, $ptrreg, $ptroff)>;
1735 def : Pat<(pre_truncsti16 i32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1736 (STHUX $rS, $ptrreg, $ptroff)>;
1737 def : Pat<(pre_store i32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1738 (STWUX $rS, $ptrreg, $ptroff)>;
1739 def : Pat<(pre_store f32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1740 (STFSUX $rS, $ptrreg, $ptroff)>;
1741 def : Pat<(pre_store f64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1742 (STFDUX $rS, $ptrreg, $ptroff)>;
1745 def STMW : DForm_1<47, (outs), (ins gprc:$rS, memri:$dst),
1746 "stmw $rS, $dst", IIC_LdStLMW, []>;
1748 def SYNC : XForm_24_sync<31, 598, (outs), (ins i32imm:$L),
1749 "sync $L", IIC_LdStSync, []>;
1751 let isCodeGenOnly = 1 in {
1752 def MSYNC : XForm_24_sync<31, 598, (outs), (ins),
1753 "msync", IIC_LdStSync, []> {
1758 def : Pat<(int_ppc_sync), (SYNC 0)>, Requires<[HasSYNC]>;
1759 def : Pat<(int_ppc_lwsync), (SYNC 1)>, Requires<[HasSYNC]>;
1760 def : Pat<(int_ppc_sync), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
1761 def : Pat<(int_ppc_lwsync), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
1763 //===----------------------------------------------------------------------===//
1764 // PPC32 Arithmetic Instructions.
1767 let PPC970_Unit = 1 in { // FXU Operations.
1768 def ADDI : DForm_2<14, (outs gprc:$rD), (ins gprc_nor0:$rA, s16imm:$imm),
1769 "addi $rD, $rA, $imm", IIC_IntSimple,
1770 [(set i32:$rD, (add i32:$rA, imm32SExt16:$imm))]>;
1771 let BaseName = "addic" in {
1772 let Defs = [CARRY] in
1773 def ADDIC : DForm_2<12, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
1774 "addic $rD, $rA, $imm", IIC_IntGeneral,
1775 [(set i32:$rD, (addc i32:$rA, imm32SExt16:$imm))]>,
1776 RecFormRel, PPC970_DGroup_Cracked;
1777 let Defs = [CARRY, CR0] in
1778 def ADDICo : DForm_2<13, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
1779 "addic. $rD, $rA, $imm", IIC_IntGeneral,
1780 []>, isDOT, RecFormRel;
1782 def ADDIS : DForm_2<15, (outs gprc:$rD), (ins gprc_nor0:$rA, s17imm:$imm),
1783 "addis $rD, $rA, $imm", IIC_IntSimple,
1784 [(set i32:$rD, (add i32:$rA, imm16ShiftedSExt:$imm))]>;
1785 let isCodeGenOnly = 1 in
1786 def LA : DForm_2<14, (outs gprc:$rD), (ins gprc_nor0:$rA, s16imm:$sym),
1787 "la $rD, $sym($rA)", IIC_IntGeneral,
1788 [(set i32:$rD, (add i32:$rA,
1789 (PPClo tglobaladdr:$sym, 0)))]>;
1790 def MULLI : DForm_2< 7, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
1791 "mulli $rD, $rA, $imm", IIC_IntMulLI,
1792 [(set i32:$rD, (mul i32:$rA, imm32SExt16:$imm))]>;
1793 let Defs = [CARRY] in
1794 def SUBFIC : DForm_2< 8, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
1795 "subfic $rD, $rA, $imm", IIC_IntGeneral,
1796 [(set i32:$rD, (subc imm32SExt16:$imm, i32:$rA))]>;
1798 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in {
1799 def LI : DForm_2_r0<14, (outs gprc:$rD), (ins s16imm:$imm),
1800 "li $rD, $imm", IIC_IntSimple,
1801 [(set i32:$rD, imm32SExt16:$imm)]>;
1802 def LIS : DForm_2_r0<15, (outs gprc:$rD), (ins s17imm:$imm),
1803 "lis $rD, $imm", IIC_IntSimple,
1804 [(set i32:$rD, imm16ShiftedSExt:$imm)]>;
1808 let PPC970_Unit = 1 in { // FXU Operations.
1809 let Defs = [CR0] in {
1810 def ANDIo : DForm_4<28, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
1811 "andi. $dst, $src1, $src2", IIC_IntGeneral,
1812 [(set i32:$dst, (and i32:$src1, immZExt16:$src2))]>,
1814 def ANDISo : DForm_4<29, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
1815 "andis. $dst, $src1, $src2", IIC_IntGeneral,
1816 [(set i32:$dst, (and i32:$src1, imm16ShiftedZExt:$src2))]>,
1819 def ORI : DForm_4<24, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
1820 "ori $dst, $src1, $src2", IIC_IntSimple,
1821 [(set i32:$dst, (or i32:$src1, immZExt16:$src2))]>;
1822 def ORIS : DForm_4<25, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
1823 "oris $dst, $src1, $src2", IIC_IntSimple,
1824 [(set i32:$dst, (or i32:$src1, imm16ShiftedZExt:$src2))]>;
1825 def XORI : DForm_4<26, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
1826 "xori $dst, $src1, $src2", IIC_IntSimple,
1827 [(set i32:$dst, (xor i32:$src1, immZExt16:$src2))]>;
1828 def XORIS : DForm_4<27, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
1829 "xoris $dst, $src1, $src2", IIC_IntSimple,
1830 [(set i32:$dst, (xor i32:$src1, imm16ShiftedZExt:$src2))]>;
1832 def NOP : DForm_4_zero<24, (outs), (ins), "nop", IIC_IntSimple,
1834 let isCodeGenOnly = 1 in {
1835 // The POWER6 and POWER7 have special group-terminating nops.
1836 def NOP_GT_PWR6 : DForm_4_fixedreg_zero<24, 1, (outs), (ins),
1837 "ori 1, 1, 0", IIC_IntSimple, []>;
1838 def NOP_GT_PWR7 : DForm_4_fixedreg_zero<24, 2, (outs), (ins),
1839 "ori 2, 2, 0", IIC_IntSimple, []>;
1842 let isCompare = 1, hasSideEffects = 0 in {
1843 def CMPWI : DForm_5_ext<11, (outs crrc:$crD), (ins gprc:$rA, s16imm:$imm),
1844 "cmpwi $crD, $rA, $imm", IIC_IntCompare>;
1845 def CMPLWI : DForm_6_ext<10, (outs crrc:$dst), (ins gprc:$src1, u16imm:$src2),
1846 "cmplwi $dst, $src1, $src2", IIC_IntCompare>;
1850 let PPC970_Unit = 1, hasSideEffects = 0 in { // FXU Operations.
1851 let isCommutable = 1 in {
1852 defm NAND : XForm_6r<31, 476, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
1853 "nand", "$rA, $rS, $rB", IIC_IntSimple,
1854 [(set i32:$rA, (not (and i32:$rS, i32:$rB)))]>;
1855 defm AND : XForm_6r<31, 28, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
1856 "and", "$rA, $rS, $rB", IIC_IntSimple,
1857 [(set i32:$rA, (and i32:$rS, i32:$rB))]>;
1859 defm ANDC : XForm_6r<31, 60, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
1860 "andc", "$rA, $rS, $rB", IIC_IntSimple,
1861 [(set i32:$rA, (and i32:$rS, (not i32:$rB)))]>;
1862 let isCommutable = 1 in {
1863 defm OR : XForm_6r<31, 444, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
1864 "or", "$rA, $rS, $rB", IIC_IntSimple,
1865 [(set i32:$rA, (or i32:$rS, i32:$rB))]>;
1866 defm NOR : XForm_6r<31, 124, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
1867 "nor", "$rA, $rS, $rB", IIC_IntSimple,
1868 [(set i32:$rA, (not (or i32:$rS, i32:$rB)))]>;
1870 defm ORC : XForm_6r<31, 412, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
1871 "orc", "$rA, $rS, $rB", IIC_IntSimple,
1872 [(set i32:$rA, (or i32:$rS, (not i32:$rB)))]>;
1873 let isCommutable = 1 in {
1874 defm EQV : XForm_6r<31, 284, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
1875 "eqv", "$rA, $rS, $rB", IIC_IntSimple,
1876 [(set i32:$rA, (not (xor i32:$rS, i32:$rB)))]>;
1877 defm XOR : XForm_6r<31, 316, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
1878 "xor", "$rA, $rS, $rB", IIC_IntSimple,
1879 [(set i32:$rA, (xor i32:$rS, i32:$rB))]>;
1881 defm SLW : XForm_6r<31, 24, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
1882 "slw", "$rA, $rS, $rB", IIC_IntGeneral,
1883 [(set i32:$rA, (PPCshl i32:$rS, i32:$rB))]>;
1884 defm SRW : XForm_6r<31, 536, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
1885 "srw", "$rA, $rS, $rB", IIC_IntGeneral,
1886 [(set i32:$rA, (PPCsrl i32:$rS, i32:$rB))]>;
1887 defm SRAW : XForm_6rc<31, 792, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
1888 "sraw", "$rA, $rS, $rB", IIC_IntShift,
1889 [(set i32:$rA, (PPCsra i32:$rS, i32:$rB))]>;
1892 let PPC970_Unit = 1 in { // FXU Operations.
1893 let hasSideEffects = 0 in {
1894 defm SRAWI : XForm_10rc<31, 824, (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH),
1895 "srawi", "$rA, $rS, $SH", IIC_IntShift,
1896 [(set i32:$rA, (sra i32:$rS, (i32 imm:$SH)))]>;
1897 defm CNTLZW : XForm_11r<31, 26, (outs gprc:$rA), (ins gprc:$rS),
1898 "cntlzw", "$rA, $rS", IIC_IntGeneral,
1899 [(set i32:$rA, (ctlz i32:$rS))]>;
1900 defm EXTSB : XForm_11r<31, 954, (outs gprc:$rA), (ins gprc:$rS),
1901 "extsb", "$rA, $rS", IIC_IntSimple,
1902 [(set i32:$rA, (sext_inreg i32:$rS, i8))]>;
1903 defm EXTSH : XForm_11r<31, 922, (outs gprc:$rA), (ins gprc:$rS),
1904 "extsh", "$rA, $rS", IIC_IntSimple,
1905 [(set i32:$rA, (sext_inreg i32:$rS, i16))]>;
1907 let isCommutable = 1 in
1908 def CMPB : XForm_6<31, 508, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
1909 "cmpb $rA, $rS, $rB", IIC_IntGeneral,
1910 [(set i32:$rA, (PPCcmpb i32:$rS, i32:$rB))]>;
1912 let isCompare = 1, hasSideEffects = 0 in {
1913 def CMPW : XForm_16_ext<31, 0, (outs crrc:$crD), (ins gprc:$rA, gprc:$rB),
1914 "cmpw $crD, $rA, $rB", IIC_IntCompare>;
1915 def CMPLW : XForm_16_ext<31, 32, (outs crrc:$crD), (ins gprc:$rA, gprc:$rB),
1916 "cmplw $crD, $rA, $rB", IIC_IntCompare>;
1919 let PPC970_Unit = 3 in { // FPU Operations.
1920 //def FCMPO : XForm_17<63, 32, (outs CRRC:$crD), (ins FPRC:$fA, FPRC:$fB),
1921 // "fcmpo $crD, $fA, $fB", IIC_FPCompare>;
1922 let isCompare = 1, hasSideEffects = 0 in {
1923 def FCMPUS : XForm_17<63, 0, (outs crrc:$crD), (ins f4rc:$fA, f4rc:$fB),
1924 "fcmpu $crD, $fA, $fB", IIC_FPCompare>;
1925 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
1926 def FCMPUD : XForm_17<63, 0, (outs crrc:$crD), (ins f8rc:$fA, f8rc:$fB),
1927 "fcmpu $crD, $fA, $fB", IIC_FPCompare>;
1930 let Uses = [RM] in {
1931 let hasSideEffects = 0 in {
1932 defm FCTIW : XForm_26r<63, 14, (outs f8rc:$frD), (ins f8rc:$frB),
1933 "fctiw", "$frD, $frB", IIC_FPGeneral,
1935 defm FCTIWZ : XForm_26r<63, 15, (outs f8rc:$frD), (ins f8rc:$frB),
1936 "fctiwz", "$frD, $frB", IIC_FPGeneral,
1937 [(set f64:$frD, (PPCfctiwz f64:$frB))]>;
1939 defm FRSP : XForm_26r<63, 12, (outs f4rc:$frD), (ins f8rc:$frB),
1940 "frsp", "$frD, $frB", IIC_FPGeneral,
1941 [(set f32:$frD, (fround f64:$frB))]>;
1943 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
1944 defm FRIND : XForm_26r<63, 392, (outs f8rc:$frD), (ins f8rc:$frB),
1945 "frin", "$frD, $frB", IIC_FPGeneral,
1946 [(set f64:$frD, (frnd f64:$frB))]>;
1947 defm FRINS : XForm_26r<63, 392, (outs f4rc:$frD), (ins f4rc:$frB),
1948 "frin", "$frD, $frB", IIC_FPGeneral,
1949 [(set f32:$frD, (frnd f32:$frB))]>;
1952 let hasSideEffects = 0 in {
1953 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
1954 defm FRIPD : XForm_26r<63, 456, (outs f8rc:$frD), (ins f8rc:$frB),
1955 "frip", "$frD, $frB", IIC_FPGeneral,
1956 [(set f64:$frD, (fceil f64:$frB))]>;
1957 defm FRIPS : XForm_26r<63, 456, (outs f4rc:$frD), (ins f4rc:$frB),
1958 "frip", "$frD, $frB", IIC_FPGeneral,
1959 [(set f32:$frD, (fceil f32:$frB))]>;
1960 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
1961 defm FRIZD : XForm_26r<63, 424, (outs f8rc:$frD), (ins f8rc:$frB),
1962 "friz", "$frD, $frB", IIC_FPGeneral,
1963 [(set f64:$frD, (ftrunc f64:$frB))]>;
1964 defm FRIZS : XForm_26r<63, 424, (outs f4rc:$frD), (ins f4rc:$frB),
1965 "friz", "$frD, $frB", IIC_FPGeneral,
1966 [(set f32:$frD, (ftrunc f32:$frB))]>;
1967 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
1968 defm FRIMD : XForm_26r<63, 488, (outs f8rc:$frD), (ins f8rc:$frB),
1969 "frim", "$frD, $frB", IIC_FPGeneral,
1970 [(set f64:$frD, (ffloor f64:$frB))]>;
1971 defm FRIMS : XForm_26r<63, 488, (outs f4rc:$frD), (ins f4rc:$frB),
1972 "frim", "$frD, $frB", IIC_FPGeneral,
1973 [(set f32:$frD, (ffloor f32:$frB))]>;
1975 defm FSQRT : XForm_26r<63, 22, (outs f8rc:$frD), (ins f8rc:$frB),
1976 "fsqrt", "$frD, $frB", IIC_FPSqrtD,
1977 [(set f64:$frD, (fsqrt f64:$frB))]>;
1978 defm FSQRTS : XForm_26r<59, 22, (outs f4rc:$frD), (ins f4rc:$frB),
1979 "fsqrts", "$frD, $frB", IIC_FPSqrtS,
1980 [(set f32:$frD, (fsqrt f32:$frB))]>;
1985 /// Note that FMR is defined as pseudo-ops on the PPC970 because they are
1986 /// often coalesced away and we don't want the dispatch group builder to think
1987 /// that they will fill slots (which could cause the load of a LSU reject to
1988 /// sneak into a d-group with a store).
1989 let hasSideEffects = 0 in
1990 defm FMR : XForm_26r<63, 72, (outs f4rc:$frD), (ins f4rc:$frB),
1991 "fmr", "$frD, $frB", IIC_FPGeneral,
1992 []>, // (set f32:$frD, f32:$frB)
1995 let PPC970_Unit = 3, hasSideEffects = 0 in { // FPU Operations.
1996 // These are artificially split into two different forms, for 4/8 byte FP.
1997 defm FABSS : XForm_26r<63, 264, (outs f4rc:$frD), (ins f4rc:$frB),
1998 "fabs", "$frD, $frB", IIC_FPGeneral,
1999 [(set f32:$frD, (fabs f32:$frB))]>;
2000 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2001 defm FABSD : XForm_26r<63, 264, (outs f8rc:$frD), (ins f8rc:$frB),
2002 "fabs", "$frD, $frB", IIC_FPGeneral,
2003 [(set f64:$frD, (fabs f64:$frB))]>;
2004 defm FNABSS : XForm_26r<63, 136, (outs f4rc:$frD), (ins f4rc:$frB),
2005 "fnabs", "$frD, $frB", IIC_FPGeneral,
2006 [(set f32:$frD, (fneg (fabs f32:$frB)))]>;
2007 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2008 defm FNABSD : XForm_26r<63, 136, (outs f8rc:$frD), (ins f8rc:$frB),
2009 "fnabs", "$frD, $frB", IIC_FPGeneral,
2010 [(set f64:$frD, (fneg (fabs f64:$frB)))]>;
2011 defm FNEGS : XForm_26r<63, 40, (outs f4rc:$frD), (ins f4rc:$frB),
2012 "fneg", "$frD, $frB", IIC_FPGeneral,
2013 [(set f32:$frD, (fneg f32:$frB))]>;
2014 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2015 defm FNEGD : XForm_26r<63, 40, (outs f8rc:$frD), (ins f8rc:$frB),
2016 "fneg", "$frD, $frB", IIC_FPGeneral,
2017 [(set f64:$frD, (fneg f64:$frB))]>;
2019 defm FCPSGNS : XForm_28r<63, 8, (outs f4rc:$frD), (ins f4rc:$frA, f4rc:$frB),
2020 "fcpsgn", "$frD, $frA, $frB", IIC_FPGeneral,
2021 [(set f32:$frD, (fcopysign f32:$frB, f32:$frA))]>;
2022 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2023 defm FCPSGND : XForm_28r<63, 8, (outs f8rc:$frD), (ins f8rc:$frA, f8rc:$frB),
2024 "fcpsgn", "$frD, $frA, $frB", IIC_FPGeneral,
2025 [(set f64:$frD, (fcopysign f64:$frB, f64:$frA))]>;
2027 // Reciprocal estimates.
2028 defm FRE : XForm_26r<63, 24, (outs f8rc:$frD), (ins f8rc:$frB),
2029 "fre", "$frD, $frB", IIC_FPGeneral,
2030 [(set f64:$frD, (PPCfre f64:$frB))]>;
2031 defm FRES : XForm_26r<59, 24, (outs f4rc:$frD), (ins f4rc:$frB),
2032 "fres", "$frD, $frB", IIC_FPGeneral,
2033 [(set f32:$frD, (PPCfre f32:$frB))]>;
2034 defm FRSQRTE : XForm_26r<63, 26, (outs f8rc:$frD), (ins f8rc:$frB),
2035 "frsqrte", "$frD, $frB", IIC_FPGeneral,
2036 [(set f64:$frD, (PPCfrsqrte f64:$frB))]>;
2037 defm FRSQRTES : XForm_26r<59, 26, (outs f4rc:$frD), (ins f4rc:$frB),
2038 "frsqrtes", "$frD, $frB", IIC_FPGeneral,
2039 [(set f32:$frD, (PPCfrsqrte f32:$frB))]>;
2042 // XL-Form instructions. condition register logical ops.
2044 let hasSideEffects = 0 in
2045 def MCRF : XLForm_3<19, 0, (outs crrc:$BF), (ins crrc:$BFA),
2046 "mcrf $BF, $BFA", IIC_BrMCR>,
2047 PPC970_DGroup_First, PPC970_Unit_CRU;
2049 // FIXME: According to the ISA (section 2.5.1 of version 2.06), the
2050 // condition-register logical instructions have preferred forms. Specifically,
2051 // it is preferred that the bit specified by the BT field be in the same
2052 // condition register as that specified by the bit BB. We might want to account
2053 // for this via hinting the register allocator and anti-dep breakers, or we
2054 // could constrain the register class to force this constraint and then loosen
2055 // it during register allocation via convertToThreeAddress or some similar
2058 let isCommutable = 1 in {
2059 def CRAND : XLForm_1<19, 257, (outs crbitrc:$CRD),
2060 (ins crbitrc:$CRA, crbitrc:$CRB),
2061 "crand $CRD, $CRA, $CRB", IIC_BrCR,
2062 [(set i1:$CRD, (and i1:$CRA, i1:$CRB))]>;
2064 def CRNAND : XLForm_1<19, 225, (outs crbitrc:$CRD),
2065 (ins crbitrc:$CRA, crbitrc:$CRB),
2066 "crnand $CRD, $CRA, $CRB", IIC_BrCR,
2067 [(set i1:$CRD, (not (and i1:$CRA, i1:$CRB)))]>;
2069 def CROR : XLForm_1<19, 449, (outs crbitrc:$CRD),
2070 (ins crbitrc:$CRA, crbitrc:$CRB),
2071 "cror $CRD, $CRA, $CRB", IIC_BrCR,
2072 [(set i1:$CRD, (or i1:$CRA, i1:$CRB))]>;
2074 def CRXOR : XLForm_1<19, 193, (outs crbitrc:$CRD),
2075 (ins crbitrc:$CRA, crbitrc:$CRB),
2076 "crxor $CRD, $CRA, $CRB", IIC_BrCR,
2077 [(set i1:$CRD, (xor i1:$CRA, i1:$CRB))]>;
2079 def CRNOR : XLForm_1<19, 33, (outs crbitrc:$CRD),
2080 (ins crbitrc:$CRA, crbitrc:$CRB),
2081 "crnor $CRD, $CRA, $CRB", IIC_BrCR,
2082 [(set i1:$CRD, (not (or i1:$CRA, i1:$CRB)))]>;
2084 def CREQV : XLForm_1<19, 289, (outs crbitrc:$CRD),
2085 (ins crbitrc:$CRA, crbitrc:$CRB),
2086 "creqv $CRD, $CRA, $CRB", IIC_BrCR,
2087 [(set i1:$CRD, (not (xor i1:$CRA, i1:$CRB)))]>;
2090 def CRANDC : XLForm_1<19, 129, (outs crbitrc:$CRD),
2091 (ins crbitrc:$CRA, crbitrc:$CRB),
2092 "crandc $CRD, $CRA, $CRB", IIC_BrCR,
2093 [(set i1:$CRD, (and i1:$CRA, (not i1:$CRB)))]>;
2095 def CRORC : XLForm_1<19, 417, (outs crbitrc:$CRD),
2096 (ins crbitrc:$CRA, crbitrc:$CRB),
2097 "crorc $CRD, $CRA, $CRB", IIC_BrCR,
2098 [(set i1:$CRD, (or i1:$CRA, (not i1:$CRB)))]>;
2100 let isCodeGenOnly = 1 in {
2101 def CRSET : XLForm_1_ext<19, 289, (outs crbitrc:$dst), (ins),
2102 "creqv $dst, $dst, $dst", IIC_BrCR,
2103 [(set i1:$dst, 1)]>;
2105 def CRUNSET: XLForm_1_ext<19, 193, (outs crbitrc:$dst), (ins),
2106 "crxor $dst, $dst, $dst", IIC_BrCR,
2107 [(set i1:$dst, 0)]>;
2109 let Defs = [CR1EQ], CRD = 6 in {
2110 def CR6SET : XLForm_1_ext<19, 289, (outs), (ins),
2111 "creqv 6, 6, 6", IIC_BrCR,
2114 def CR6UNSET: XLForm_1_ext<19, 193, (outs), (ins),
2115 "crxor 6, 6, 6", IIC_BrCR,
2120 // XFX-Form instructions. Instructions that deal with SPRs.
2123 def MFSPR : XFXForm_1<31, 339, (outs gprc:$RT), (ins i32imm:$SPR),
2124 "mfspr $RT, $SPR", IIC_SprMFSPR>;
2125 def MTSPR : XFXForm_1<31, 467, (outs), (ins i32imm:$SPR, gprc:$RT),
2126 "mtspr $SPR, $RT", IIC_SprMTSPR>;
2128 def MFTB : XFXForm_1<31, 371, (outs gprc:$RT), (ins i32imm:$SPR),
2129 "mftb $RT, $SPR", IIC_SprMFTB>, Deprecated<DeprecatedMFTB>;
2131 // A pseudo-instruction used to implement the read of the 64-bit cycle counter
2132 // on a 32-bit target.
2133 let hasSideEffects = 1, usesCustomInserter = 1 in
2134 def ReadTB : Pseudo<(outs gprc:$lo, gprc:$hi), (ins),
2137 let Uses = [CTR] in {
2138 def MFCTR : XFXForm_1_ext<31, 339, 9, (outs gprc:$rT), (ins),
2139 "mfctr $rT", IIC_SprMFSPR>,
2140 PPC970_DGroup_First, PPC970_Unit_FXU;
2142 let Defs = [CTR], Pattern = [(PPCmtctr i32:$rS)] in {
2143 def MTCTR : XFXForm_7_ext<31, 467, 9, (outs), (ins gprc:$rS),
2144 "mtctr $rS", IIC_SprMTSPR>,
2145 PPC970_DGroup_First, PPC970_Unit_FXU;
2147 let hasSideEffects = 1, isCodeGenOnly = 1, Defs = [CTR] in {
2148 let Pattern = [(int_ppc_mtctr i32:$rS)] in
2149 def MTCTRloop : XFXForm_7_ext<31, 467, 9, (outs), (ins gprc:$rS),
2150 "mtctr $rS", IIC_SprMTSPR>,
2151 PPC970_DGroup_First, PPC970_Unit_FXU;
2154 let Defs = [LR] in {
2155 def MTLR : XFXForm_7_ext<31, 467, 8, (outs), (ins gprc:$rS),
2156 "mtlr $rS", IIC_SprMTSPR>,
2157 PPC970_DGroup_First, PPC970_Unit_FXU;
2159 let Uses = [LR] in {
2160 def MFLR : XFXForm_1_ext<31, 339, 8, (outs gprc:$rT), (ins),
2161 "mflr $rT", IIC_SprMFSPR>,
2162 PPC970_DGroup_First, PPC970_Unit_FXU;
2165 let isCodeGenOnly = 1 in {
2166 // Move to/from VRSAVE: despite being a SPR, the VRSAVE register is renamed
2167 // like a GPR on the PPC970. As such, copies in and out have the same
2168 // performance characteristics as an OR instruction.
2169 def MTVRSAVE : XFXForm_7_ext<31, 467, 256, (outs), (ins gprc:$rS),
2170 "mtspr 256, $rS", IIC_IntGeneral>,
2171 PPC970_DGroup_Single, PPC970_Unit_FXU;
2172 def MFVRSAVE : XFXForm_1_ext<31, 339, 256, (outs gprc:$rT), (ins),
2173 "mfspr $rT, 256", IIC_IntGeneral>,
2174 PPC970_DGroup_First, PPC970_Unit_FXU;
2176 def MTVRSAVEv : XFXForm_7_ext<31, 467, 256,
2177 (outs VRSAVERC:$reg), (ins gprc:$rS),
2178 "mtspr 256, $rS", IIC_IntGeneral>,
2179 PPC970_DGroup_Single, PPC970_Unit_FXU;
2180 def MFVRSAVEv : XFXForm_1_ext<31, 339, 256, (outs gprc:$rT),
2181 (ins VRSAVERC:$reg),
2182 "mfspr $rT, 256", IIC_IntGeneral>,
2183 PPC970_DGroup_First, PPC970_Unit_FXU;
2186 // SPILL_VRSAVE - Indicate that we're dumping the VRSAVE register,
2187 // so we'll need to scavenge a register for it.
2189 def SPILL_VRSAVE : Pseudo<(outs), (ins VRSAVERC:$vrsave, memri:$F),
2190 "#SPILL_VRSAVE", []>;
2192 // RESTORE_VRSAVE - Indicate that we're restoring the VRSAVE register (previously
2193 // spilled), so we'll need to scavenge a register for it.
2195 def RESTORE_VRSAVE : Pseudo<(outs VRSAVERC:$vrsave), (ins memri:$F),
2196 "#RESTORE_VRSAVE", []>;
2198 let hasSideEffects = 0 in {
2199 def MTOCRF: XFXForm_5a<31, 144, (outs crbitm:$FXM), (ins gprc:$ST),
2200 "mtocrf $FXM, $ST", IIC_BrMCRX>,
2201 PPC970_DGroup_First, PPC970_Unit_CRU;
2203 def MTCRF : XFXForm_5<31, 144, (outs), (ins i32imm:$FXM, gprc:$rS),
2204 "mtcrf $FXM, $rS", IIC_BrMCRX>,
2205 PPC970_MicroCode, PPC970_Unit_CRU;
2207 let hasExtraSrcRegAllocReq = 1 in // to enable post-ra anti-dep breaking.
2208 def MFOCRF: XFXForm_5a<31, 19, (outs gprc:$rT), (ins crbitm:$FXM),
2209 "mfocrf $rT, $FXM", IIC_SprMFCRF>,
2210 PPC970_DGroup_First, PPC970_Unit_CRU;
2212 def MFCR : XFXForm_3<31, 19, (outs gprc:$rT), (ins),
2213 "mfcr $rT", IIC_SprMFCR>,
2214 PPC970_MicroCode, PPC970_Unit_CRU;
2215 } // hasSideEffects = 0
2217 // Pseudo instruction to perform FADD in round-to-zero mode.
2218 let usesCustomInserter = 1, Uses = [RM] in {
2219 def FADDrtz: Pseudo<(outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB), "",
2220 [(set f64:$FRT, (PPCfaddrtz f64:$FRA, f64:$FRB))]>;
2223 // The above pseudo gets expanded to make use of the following instructions
2224 // to manipulate FPSCR. Note that FPSCR is not modeled at the DAG level.
2225 let Uses = [RM], Defs = [RM] in {
2226 def MTFSB0 : XForm_43<63, 70, (outs), (ins u5imm:$FM),
2227 "mtfsb0 $FM", IIC_IntMTFSB0, []>,
2228 PPC970_DGroup_Single, PPC970_Unit_FPU;
2229 def MTFSB1 : XForm_43<63, 38, (outs), (ins u5imm:$FM),
2230 "mtfsb1 $FM", IIC_IntMTFSB0, []>,
2231 PPC970_DGroup_Single, PPC970_Unit_FPU;
2232 let isCodeGenOnly = 1 in
2233 def MTFSFb : XFLForm<63, 711, (outs), (ins i32imm:$FM, f8rc:$rT),
2234 "mtfsf $FM, $rT", IIC_IntMTFSB0, []>,
2235 PPC970_DGroup_Single, PPC970_Unit_FPU;
2237 let Uses = [RM] in {
2238 def MFFS : XForm_42<63, 583, (outs f8rc:$rT), (ins),
2239 "mffs $rT", IIC_IntMFFS,
2240 [(set f64:$rT, (PPCmffs))]>,
2241 PPC970_DGroup_Single, PPC970_Unit_FPU;
2244 def MFFSo : XForm_42<63, 583, (outs f8rc:$rT), (ins),
2245 "mffs. $rT", IIC_IntMFFS, []>, isDOT;
2249 let PPC970_Unit = 1, hasSideEffects = 0 in { // FXU Operations.
2250 // XO-Form instructions. Arithmetic instructions that can set overflow bit
2251 let isCommutable = 1 in
2252 defm ADD4 : XOForm_1r<31, 266, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2253 "add", "$rT, $rA, $rB", IIC_IntSimple,
2254 [(set i32:$rT, (add i32:$rA, i32:$rB))]>;
2255 let isCodeGenOnly = 1 in
2256 def ADD4TLS : XOForm_1<31, 266, 0, (outs gprc:$rT), (ins gprc:$rA, tlsreg32:$rB),
2257 "add $rT, $rA, $rB", IIC_IntSimple,
2258 [(set i32:$rT, (add i32:$rA, tglobaltlsaddr:$rB))]>;
2259 let isCommutable = 1 in
2260 defm ADDC : XOForm_1rc<31, 10, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2261 "addc", "$rT, $rA, $rB", IIC_IntGeneral,
2262 [(set i32:$rT, (addc i32:$rA, i32:$rB))]>,
2263 PPC970_DGroup_Cracked;
2265 defm DIVW : XOForm_1r<31, 491, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2266 "divw", "$rT, $rA, $rB", IIC_IntDivW,
2267 [(set i32:$rT, (sdiv i32:$rA, i32:$rB))]>,
2268 PPC970_DGroup_First, PPC970_DGroup_Cracked;
2269 defm DIVWU : XOForm_1r<31, 459, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2270 "divwu", "$rT, $rA, $rB", IIC_IntDivW,
2271 [(set i32:$rT, (udiv i32:$rA, i32:$rB))]>,
2272 PPC970_DGroup_First, PPC970_DGroup_Cracked;
2273 let isCommutable = 1 in {
2274 defm MULHW : XOForm_1r<31, 75, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2275 "mulhw", "$rT, $rA, $rB", IIC_IntMulHW,
2276 [(set i32:$rT, (mulhs i32:$rA, i32:$rB))]>;
2277 defm MULHWU : XOForm_1r<31, 11, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2278 "mulhwu", "$rT, $rA, $rB", IIC_IntMulHWU,
2279 [(set i32:$rT, (mulhu i32:$rA, i32:$rB))]>;
2280 defm MULLW : XOForm_1r<31, 235, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2281 "mullw", "$rT, $rA, $rB", IIC_IntMulHW,
2282 [(set i32:$rT, (mul i32:$rA, i32:$rB))]>;
2284 defm SUBF : XOForm_1r<31, 40, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2285 "subf", "$rT, $rA, $rB", IIC_IntGeneral,
2286 [(set i32:$rT, (sub i32:$rB, i32:$rA))]>;
2287 defm SUBFC : XOForm_1rc<31, 8, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2288 "subfc", "$rT, $rA, $rB", IIC_IntGeneral,
2289 [(set i32:$rT, (subc i32:$rB, i32:$rA))]>,
2290 PPC970_DGroup_Cracked;
2291 defm NEG : XOForm_3r<31, 104, 0, (outs gprc:$rT), (ins gprc:$rA),
2292 "neg", "$rT, $rA", IIC_IntSimple,
2293 [(set i32:$rT, (ineg i32:$rA))]>;
2294 let Uses = [CARRY] in {
2295 let isCommutable = 1 in
2296 defm ADDE : XOForm_1rc<31, 138, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2297 "adde", "$rT, $rA, $rB", IIC_IntGeneral,
2298 [(set i32:$rT, (adde i32:$rA, i32:$rB))]>;
2299 defm ADDME : XOForm_3rc<31, 234, 0, (outs gprc:$rT), (ins gprc:$rA),
2300 "addme", "$rT, $rA", IIC_IntGeneral,
2301 [(set i32:$rT, (adde i32:$rA, -1))]>;
2302 defm ADDZE : XOForm_3rc<31, 202, 0, (outs gprc:$rT), (ins gprc:$rA),
2303 "addze", "$rT, $rA", IIC_IntGeneral,
2304 [(set i32:$rT, (adde i32:$rA, 0))]>;
2305 defm SUBFE : XOForm_1rc<31, 136, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2306 "subfe", "$rT, $rA, $rB", IIC_IntGeneral,
2307 [(set i32:$rT, (sube i32:$rB, i32:$rA))]>;
2308 defm SUBFME : XOForm_3rc<31, 232, 0, (outs gprc:$rT), (ins gprc:$rA),
2309 "subfme", "$rT, $rA", IIC_IntGeneral,
2310 [(set i32:$rT, (sube -1, i32:$rA))]>;
2311 defm SUBFZE : XOForm_3rc<31, 200, 0, (outs gprc:$rT), (ins gprc:$rA),
2312 "subfze", "$rT, $rA", IIC_IntGeneral,
2313 [(set i32:$rT, (sube 0, i32:$rA))]>;
2317 // A-Form instructions. Most of the instructions executed in the FPU are of
2320 let PPC970_Unit = 3, hasSideEffects = 0 in { // FPU Operations.
2321 let Uses = [RM] in {
2322 let isCommutable = 1 in {
2323 defm FMADD : AForm_1r<63, 29,
2324 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2325 "fmadd", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2326 [(set f64:$FRT, (fma f64:$FRA, f64:$FRC, f64:$FRB))]>;
2327 defm FMADDS : AForm_1r<59, 29,
2328 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2329 "fmadds", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2330 [(set f32:$FRT, (fma f32:$FRA, f32:$FRC, f32:$FRB))]>;
2331 defm FMSUB : AForm_1r<63, 28,
2332 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2333 "fmsub", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2335 (fma f64:$FRA, f64:$FRC, (fneg f64:$FRB)))]>;
2336 defm FMSUBS : AForm_1r<59, 28,
2337 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2338 "fmsubs", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2340 (fma f32:$FRA, f32:$FRC, (fneg f32:$FRB)))]>;
2341 defm FNMADD : AForm_1r<63, 31,
2342 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2343 "fnmadd", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2345 (fneg (fma f64:$FRA, f64:$FRC, f64:$FRB)))]>;
2346 defm FNMADDS : AForm_1r<59, 31,
2347 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2348 "fnmadds", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2350 (fneg (fma f32:$FRA, f32:$FRC, f32:$FRB)))]>;
2351 defm FNMSUB : AForm_1r<63, 30,
2352 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2353 "fnmsub", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2354 [(set f64:$FRT, (fneg (fma f64:$FRA, f64:$FRC,
2355 (fneg f64:$FRB))))]>;
2356 defm FNMSUBS : AForm_1r<59, 30,
2357 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2358 "fnmsubs", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2359 [(set f32:$FRT, (fneg (fma f32:$FRA, f32:$FRC,
2360 (fneg f32:$FRB))))]>;
2363 // FSEL is artificially split into 4 and 8-byte forms for the result. To avoid
2364 // having 4 of these, force the comparison to always be an 8-byte double (code
2365 // should use an FMRSD if the input comparison value really wants to be a float)
2366 // and 4/8 byte forms for the result and operand type..
2367 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2368 defm FSELD : AForm_1r<63, 23,
2369 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2370 "fsel", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2371 [(set f64:$FRT, (PPCfsel f64:$FRA, f64:$FRC, f64:$FRB))]>;
2372 defm FSELS : AForm_1r<63, 23,
2373 (outs f4rc:$FRT), (ins f8rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2374 "fsel", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2375 [(set f32:$FRT, (PPCfsel f64:$FRA, f32:$FRC, f32:$FRB))]>;
2376 let Uses = [RM] in {
2377 let isCommutable = 1 in {
2378 defm FADD : AForm_2r<63, 21,
2379 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB),
2380 "fadd", "$FRT, $FRA, $FRB", IIC_FPAddSub,
2381 [(set f64:$FRT, (fadd f64:$FRA, f64:$FRB))]>;
2382 defm FADDS : AForm_2r<59, 21,
2383 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB),
2384 "fadds", "$FRT, $FRA, $FRB", IIC_FPGeneral,
2385 [(set f32:$FRT, (fadd f32:$FRA, f32:$FRB))]>;
2387 defm FDIV : AForm_2r<63, 18,
2388 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB),
2389 "fdiv", "$FRT, $FRA, $FRB", IIC_FPDivD,
2390 [(set f64:$FRT, (fdiv f64:$FRA, f64:$FRB))]>;
2391 defm FDIVS : AForm_2r<59, 18,
2392 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB),
2393 "fdivs", "$FRT, $FRA, $FRB", IIC_FPDivS,
2394 [(set f32:$FRT, (fdiv f32:$FRA, f32:$FRB))]>;
2395 let isCommutable = 1 in {
2396 defm FMUL : AForm_3r<63, 25,
2397 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC),
2398 "fmul", "$FRT, $FRA, $FRC", IIC_FPFused,
2399 [(set f64:$FRT, (fmul f64:$FRA, f64:$FRC))]>;
2400 defm FMULS : AForm_3r<59, 25,
2401 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC),
2402 "fmuls", "$FRT, $FRA, $FRC", IIC_FPGeneral,
2403 [(set f32:$FRT, (fmul f32:$FRA, f32:$FRC))]>;
2405 defm FSUB : AForm_2r<63, 20,
2406 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB),
2407 "fsub", "$FRT, $FRA, $FRB", IIC_FPAddSub,
2408 [(set f64:$FRT, (fsub f64:$FRA, f64:$FRB))]>;
2409 defm FSUBS : AForm_2r<59, 20,
2410 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB),
2411 "fsubs", "$FRT, $FRA, $FRB", IIC_FPGeneral,
2412 [(set f32:$FRT, (fsub f32:$FRA, f32:$FRB))]>;
2416 let hasSideEffects = 0 in {
2417 let PPC970_Unit = 1 in { // FXU Operations.
2419 def ISEL : AForm_4<31, 15,
2420 (outs gprc:$rT), (ins gprc_nor0:$rA, gprc:$rB, crbitrc:$cond),
2421 "isel $rT, $rA, $rB, $cond", IIC_IntISEL,
2425 let PPC970_Unit = 1 in { // FXU Operations.
2426 // M-Form instructions. rotate and mask instructions.
2428 let isCommutable = 1 in {
2429 // RLWIMI can be commuted if the rotate amount is zero.
2430 defm RLWIMI : MForm_2r<20, (outs gprc:$rA),
2431 (ins gprc:$rSi, gprc:$rS, u5imm:$SH, u5imm:$MB,
2432 u5imm:$ME), "rlwimi", "$rA, $rS, $SH, $MB, $ME",
2433 IIC_IntRotate, []>, PPC970_DGroup_Cracked,
2434 RegConstraint<"$rSi = $rA">, NoEncode<"$rSi">;
2436 let BaseName = "rlwinm" in {
2437 def RLWINM : MForm_2<21,
2438 (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
2439 "rlwinm $rA, $rS, $SH, $MB, $ME", IIC_IntGeneral,
2442 def RLWINMo : MForm_2<21,
2443 (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
2444 "rlwinm. $rA, $rS, $SH, $MB, $ME", IIC_IntGeneral,
2445 []>, isDOT, RecFormRel, PPC970_DGroup_Cracked;
2447 defm RLWNM : MForm_2r<23, (outs gprc:$rA),
2448 (ins gprc:$rS, gprc:$rB, u5imm:$MB, u5imm:$ME),
2449 "rlwnm", "$rA, $rS, $rB, $MB, $ME", IIC_IntGeneral,
2452 } // hasSideEffects = 0
2454 //===----------------------------------------------------------------------===//
2455 // PowerPC Instruction Patterns
2458 // Arbitrary immediate support. Implement in terms of LIS/ORI.
2459 def : Pat<(i32 imm:$imm),
2460 (ORI (LIS (HI16 imm:$imm)), (LO16 imm:$imm))>;
2462 // Implement the 'not' operation with the NOR instruction.
2463 def i32not : OutPatFrag<(ops node:$in),
2465 def : Pat<(not i32:$in),
2468 // ADD an arbitrary immediate.
2469 def : Pat<(add i32:$in, imm:$imm),
2470 (ADDIS (ADDI $in, (LO16 imm:$imm)), (HA16 imm:$imm))>;
2471 // OR an arbitrary immediate.
2472 def : Pat<(or i32:$in, imm:$imm),
2473 (ORIS (ORI $in, (LO16 imm:$imm)), (HI16 imm:$imm))>;
2474 // XOR an arbitrary immediate.
2475 def : Pat<(xor i32:$in, imm:$imm),
2476 (XORIS (XORI $in, (LO16 imm:$imm)), (HI16 imm:$imm))>;
2478 def : Pat<(sub imm32SExt16:$imm, i32:$in),
2479 (SUBFIC $in, imm:$imm)>;
2482 def : Pat<(shl i32:$in, (i32 imm:$imm)),
2483 (RLWINM $in, imm:$imm, 0, (SHL32 imm:$imm))>;
2484 def : Pat<(srl i32:$in, (i32 imm:$imm)),
2485 (RLWINM $in, (SRL32 imm:$imm), imm:$imm, 31)>;
2488 def : Pat<(rotl i32:$in, i32:$sh),
2489 (RLWNM $in, $sh, 0, 31)>;
2490 def : Pat<(rotl i32:$in, (i32 imm:$imm)),
2491 (RLWINM $in, imm:$imm, 0, 31)>;
2494 def : Pat<(and (rotl i32:$in, i32:$sh), maskimm32:$imm),
2495 (RLWNM $in, $sh, (MB maskimm32:$imm), (ME maskimm32:$imm))>;
2498 def : Pat<(PPCcall (i32 tglobaladdr:$dst)),
2499 (BL tglobaladdr:$dst)>;
2500 def : Pat<(PPCcall (i32 texternalsym:$dst)),
2501 (BL texternalsym:$dst)>;
2503 def : Pat<(PPCtc_return (i32 tglobaladdr:$dst), imm:$imm),
2504 (TCRETURNdi tglobaladdr:$dst, imm:$imm)>;
2506 def : Pat<(PPCtc_return (i32 texternalsym:$dst), imm:$imm),
2507 (TCRETURNdi texternalsym:$dst, imm:$imm)>;
2509 def : Pat<(PPCtc_return CTRRC:$dst, imm:$imm),
2510 (TCRETURNri CTRRC:$dst, imm:$imm)>;
2514 // Hi and Lo for Darwin Global Addresses.
2515 def : Pat<(PPChi tglobaladdr:$in, 0), (LIS tglobaladdr:$in)>;
2516 def : Pat<(PPClo tglobaladdr:$in, 0), (LI tglobaladdr:$in)>;
2517 def : Pat<(PPChi tconstpool:$in, 0), (LIS tconstpool:$in)>;
2518 def : Pat<(PPClo tconstpool:$in, 0), (LI tconstpool:$in)>;
2519 def : Pat<(PPChi tjumptable:$in, 0), (LIS tjumptable:$in)>;
2520 def : Pat<(PPClo tjumptable:$in, 0), (LI tjumptable:$in)>;
2521 def : Pat<(PPChi tblockaddress:$in, 0), (LIS tblockaddress:$in)>;
2522 def : Pat<(PPClo tblockaddress:$in, 0), (LI tblockaddress:$in)>;
2523 def : Pat<(PPChi tglobaltlsaddr:$g, i32:$in),
2524 (ADDIS $in, tglobaltlsaddr:$g)>;
2525 def : Pat<(PPClo tglobaltlsaddr:$g, i32:$in),
2526 (ADDI $in, tglobaltlsaddr:$g)>;
2527 def : Pat<(add i32:$in, (PPChi tglobaladdr:$g, 0)),
2528 (ADDIS $in, tglobaladdr:$g)>;
2529 def : Pat<(add i32:$in, (PPChi tconstpool:$g, 0)),
2530 (ADDIS $in, tconstpool:$g)>;
2531 def : Pat<(add i32:$in, (PPChi tjumptable:$g, 0)),
2532 (ADDIS $in, tjumptable:$g)>;
2533 def : Pat<(add i32:$in, (PPChi tblockaddress:$g, 0)),
2534 (ADDIS $in, tblockaddress:$g)>;
2536 // Support for thread-local storage.
2537 def PPC32GOT: Pseudo<(outs gprc:$rD), (ins), "#PPC32GOT",
2538 [(set i32:$rD, (PPCppc32GOT))]>;
2540 // Get the _GLOBAL_OFFSET_TABLE_ in PIC mode.
2541 // This uses two output registers, the first as the real output, the second as a
2542 // temporary register, used internally in code generation.
2543 def PPC32PICGOT: Pseudo<(outs gprc:$rD, gprc:$rT), (ins), "#PPC32PICGOT",
2544 []>, NoEncode<"$rT">;
2546 def LDgotTprelL32: Pseudo<(outs gprc:$rD), (ins s16imm:$disp, gprc_nor0:$reg),
2549 (PPCldGotTprelL tglobaltlsaddr:$disp, i32:$reg))]>;
2550 def : Pat<(PPCaddTls i32:$in, tglobaltlsaddr:$g),
2551 (ADD4TLS $in, tglobaltlsaddr:$g)>;
2553 def ADDItlsgdL32 : Pseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
2556 (PPCaddiTlsgdL i32:$reg, tglobaltlsaddr:$disp))]>;
2557 // LR is a true define, while the rest of the Defs are clobbers. R3 is
2558 // explicitly defined when this op is created, so not mentioned here.
2559 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
2560 Defs = [R0,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
2561 def GETtlsADDR32 : Pseudo<(outs gprc:$rD), (ins gprc:$reg, tlsgd32:$sym),
2564 (PPCgetTlsAddr i32:$reg, tglobaltlsaddr:$sym))]>;
2565 // Combined op for ADDItlsgdL32 and GETtlsADDR32, late expanded. R3 and LR
2566 // are true defines while the rest of the Defs are clobbers.
2567 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
2568 Defs = [R0,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
2569 def ADDItlsgdLADDR32 : Pseudo<(outs gprc:$rD),
2570 (ins gprc_nor0:$reg, s16imm:$disp, tlsgd32:$sym),
2571 "#ADDItlsgdLADDR32",
2573 (PPCaddiTlsgdLAddr i32:$reg,
2574 tglobaltlsaddr:$disp,
2575 tglobaltlsaddr:$sym))]>;
2576 def ADDItlsldL32 : Pseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
2579 (PPCaddiTlsldL i32:$reg, tglobaltlsaddr:$disp))]>;
2580 // LR is a true define, while the rest of the Defs are clobbers. R3 is
2581 // explicitly defined when this op is created, so not mentioned here.
2582 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
2583 Defs = [R0,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
2584 def GETtlsldADDR32 : Pseudo<(outs gprc:$rD), (ins gprc:$reg, tlsgd32:$sym),
2587 (PPCgetTlsldAddr i32:$reg,
2588 tglobaltlsaddr:$sym))]>;
2589 // Combined op for ADDItlsldL32 and GETtlsADDR32, late expanded. R3 and LR
2590 // are true defines while the rest of the Defs are clobbers.
2591 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
2592 Defs = [R0,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
2593 def ADDItlsldLADDR32 : Pseudo<(outs gprc:$rD),
2594 (ins gprc_nor0:$reg, s16imm:$disp, tlsgd32:$sym),
2595 "#ADDItlsldLADDR32",
2597 (PPCaddiTlsldLAddr i32:$reg,
2598 tglobaltlsaddr:$disp,
2599 tglobaltlsaddr:$sym))]>;
2600 def ADDIdtprelL32 : Pseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
2603 (PPCaddiDtprelL i32:$reg, tglobaltlsaddr:$disp))]>;
2604 def ADDISdtprelHA32 : Pseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
2607 (PPCaddisDtprelHA i32:$reg,
2608 tglobaltlsaddr:$disp))]>;
2610 // Support for Position-independent code
2611 def LWZtoc : Pseudo<(outs gprc:$rD), (ins tocentry32:$disp, gprc:$reg),
2614 (PPCtoc_entry tglobaladdr:$disp, i32:$reg))]>;
2615 // Get Global (GOT) Base Register offset, from the word immediately preceding
2616 // the function label.
2617 def UpdateGBR : Pseudo<(outs gprc:$rD, gprc:$rT), (ins gprc:$rI), "#UpdateGBR", []>;
2620 // Standard shifts. These are represented separately from the real shifts above
2621 // so that we can distinguish between shifts that allow 5-bit and 6-bit shift
2623 def : Pat<(sra i32:$rS, i32:$rB),
2625 def : Pat<(srl i32:$rS, i32:$rB),
2627 def : Pat<(shl i32:$rS, i32:$rB),
2630 def : Pat<(zextloadi1 iaddr:$src),
2632 def : Pat<(zextloadi1 xaddr:$src),
2634 def : Pat<(extloadi1 iaddr:$src),
2636 def : Pat<(extloadi1 xaddr:$src),
2638 def : Pat<(extloadi8 iaddr:$src),
2640 def : Pat<(extloadi8 xaddr:$src),
2642 def : Pat<(extloadi16 iaddr:$src),
2644 def : Pat<(extloadi16 xaddr:$src),
2646 def : Pat<(f64 (extloadf32 iaddr:$src)),
2647 (COPY_TO_REGCLASS (LFS iaddr:$src), F8RC)>;
2648 def : Pat<(f64 (extloadf32 xaddr:$src)),
2649 (COPY_TO_REGCLASS (LFSX xaddr:$src), F8RC)>;
2651 def : Pat<(f64 (fextend f32:$src)),
2652 (COPY_TO_REGCLASS $src, F8RC)>;
2654 // Only seq_cst fences require the heavyweight sync (SYNC 0).
2655 // All others can use the lightweight sync (SYNC 1).
2656 // source: http://www.cl.cam.ac.uk/~pes20/cpp/cpp0xmappings.html
2657 // The rule for seq_cst is duplicated to work with both 64 bits and 32 bits
2658 // versions of Power.
2659 def : Pat<(atomic_fence (i64 7), (imm)), (SYNC 0)>, Requires<[HasSYNC]>;
2660 def : Pat<(atomic_fence (i32 7), (imm)), (SYNC 0)>, Requires<[HasSYNC]>;
2661 def : Pat<(atomic_fence (imm), (imm)), (SYNC 1)>, Requires<[HasSYNC]>;
2662 def : Pat<(atomic_fence (imm), (imm)), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
2664 // Additional FNMSUB patterns: -a*c + b == -(a*c - b)
2665 def : Pat<(fma (fneg f64:$A), f64:$C, f64:$B),
2666 (FNMSUB $A, $C, $B)>;
2667 def : Pat<(fma f64:$A, (fneg f64:$C), f64:$B),
2668 (FNMSUB $A, $C, $B)>;
2669 def : Pat<(fma (fneg f32:$A), f32:$C, f32:$B),
2670 (FNMSUBS $A, $C, $B)>;
2671 def : Pat<(fma f32:$A, (fneg f32:$C), f32:$B),
2672 (FNMSUBS $A, $C, $B)>;
2674 // FCOPYSIGN's operand types need not agree.
2675 def : Pat<(fcopysign f64:$frB, f32:$frA),
2676 (FCPSGND (COPY_TO_REGCLASS $frA, F8RC), $frB)>;
2677 def : Pat<(fcopysign f32:$frB, f64:$frA),
2678 (FCPSGNS (COPY_TO_REGCLASS $frA, F4RC), $frB)>;
2680 include "PPCInstrAltivec.td"
2681 include "PPCInstrSPE.td"
2682 include "PPCInstr64Bit.td"
2683 include "PPCInstrVSX.td"
2684 include "PPCInstrQPX.td"
2686 def crnot : OutPatFrag<(ops node:$in),
2688 def : Pat<(not i1:$in),
2691 // Patterns for arithmetic i1 operations.
2692 def : Pat<(add i1:$a, i1:$b),
2694 def : Pat<(sub i1:$a, i1:$b),
2696 def : Pat<(mul i1:$a, i1:$b),
2699 // We're sometimes asked to materialize i1 -1, which is just 1 in this case
2700 // (-1 is used to mean all bits set).
2701 def : Pat<(i1 -1), (CRSET)>;
2703 // i1 extensions, implemented in terms of isel.
2704 def : Pat<(i32 (zext i1:$in)),
2705 (SELECT_I4 $in, (LI 1), (LI 0))>;
2706 def : Pat<(i32 (sext i1:$in)),
2707 (SELECT_I4 $in, (LI -1), (LI 0))>;
2709 def : Pat<(i64 (zext i1:$in)),
2710 (SELECT_I8 $in, (LI8 1), (LI8 0))>;
2711 def : Pat<(i64 (sext i1:$in)),
2712 (SELECT_I8 $in, (LI8 -1), (LI8 0))>;
2714 // FIXME: We should choose either a zext or a sext based on other constants
2716 def : Pat<(i32 (anyext i1:$in)),
2717 (SELECT_I4 $in, (LI 1), (LI 0))>;
2718 def : Pat<(i64 (anyext i1:$in)),
2719 (SELECT_I8 $in, (LI8 1), (LI8 0))>;
2721 // match setcc on i1 variables.
2722 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETLT)),
2724 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETULT)),
2726 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETLE)),
2728 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETULE)),
2730 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETEQ)),
2732 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETGE)),
2734 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETUGE)),
2736 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETGT)),
2738 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETUGT)),
2740 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETNE)),
2743 // match setcc on non-i1 (non-vector) variables. Note that SETUEQ, SETOGE,
2744 // SETOLE, SETONE, SETULT and SETUGT should be expanded by legalize for
2745 // floating-point types.
2747 multiclass CRNotPat<dag pattern, dag result> {
2748 def : Pat<pattern, (crnot result)>;
2749 def : Pat<(not pattern), result>;
2751 // We can also fold the crnot into an extension:
2752 def : Pat<(i32 (zext pattern)),
2753 (SELECT_I4 result, (LI 0), (LI 1))>;
2754 def : Pat<(i32 (sext pattern)),
2755 (SELECT_I4 result, (LI 0), (LI -1))>;
2757 // We can also fold the crnot into an extension:
2758 def : Pat<(i64 (zext pattern)),
2759 (SELECT_I8 result, (LI8 0), (LI8 1))>;
2760 def : Pat<(i64 (sext pattern)),
2761 (SELECT_I8 result, (LI8 0), (LI8 -1))>;
2763 // FIXME: We should choose either a zext or a sext based on other constants
2765 def : Pat<(i32 (anyext pattern)),
2766 (SELECT_I4 result, (LI 0), (LI 1))>;
2768 def : Pat<(i64 (anyext pattern)),
2769 (SELECT_I8 result, (LI8 0), (LI8 1))>;
2772 // FIXME: Because of what seems like a bug in TableGen's type-inference code,
2773 // we need to write imm:$imm in the output patterns below, not just $imm, or
2774 // else the resulting matcher will not correctly add the immediate operand
2775 // (making it a register operand instead).
2778 multiclass ExtSetCCPat<CondCode cc, PatFrag pfrag,
2779 OutPatFrag rfrag, OutPatFrag rfrag8> {
2780 def : Pat<(i32 (zext (i1 (pfrag i32:$s1, cc)))),
2782 def : Pat<(i64 (zext (i1 (pfrag i64:$s1, cc)))),
2784 def : Pat<(i64 (zext (i1 (pfrag i32:$s1, cc)))),
2785 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1), sub_32)>;
2786 def : Pat<(i32 (zext (i1 (pfrag i64:$s1, cc)))),
2787 (EXTRACT_SUBREG (rfrag8 $s1), sub_32)>;
2789 def : Pat<(i32 (anyext (i1 (pfrag i32:$s1, cc)))),
2791 def : Pat<(i64 (anyext (i1 (pfrag i64:$s1, cc)))),
2793 def : Pat<(i64 (anyext (i1 (pfrag i32:$s1, cc)))),
2794 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1), sub_32)>;
2795 def : Pat<(i32 (anyext (i1 (pfrag i64:$s1, cc)))),
2796 (EXTRACT_SUBREG (rfrag8 $s1), sub_32)>;
2799 // Note that we do all inversions below with i(32|64)not, instead of using
2800 // (xori x, 1) because on the A2 nor has single-cycle latency while xori
2801 // has 2-cycle latency.
2803 defm : ExtSetCCPat<SETEQ,
2804 PatFrag<(ops node:$in, node:$cc),
2805 (setcc $in, 0, $cc)>,
2806 OutPatFrag<(ops node:$in),
2807 (RLWINM (CNTLZW $in), 27, 31, 31)>,
2808 OutPatFrag<(ops node:$in),
2809 (RLDICL (CNTLZD $in), 58, 63)> >;
2811 defm : ExtSetCCPat<SETNE,
2812 PatFrag<(ops node:$in, node:$cc),
2813 (setcc $in, 0, $cc)>,
2814 OutPatFrag<(ops node:$in),
2815 (RLWINM (i32not (CNTLZW $in)), 27, 31, 31)>,
2816 OutPatFrag<(ops node:$in),
2817 (RLDICL (i64not (CNTLZD $in)), 58, 63)> >;
2819 defm : ExtSetCCPat<SETLT,
2820 PatFrag<(ops node:$in, node:$cc),
2821 (setcc $in, 0, $cc)>,
2822 OutPatFrag<(ops node:$in),
2823 (RLWINM $in, 1, 31, 31)>,
2824 OutPatFrag<(ops node:$in),
2825 (RLDICL $in, 1, 63)> >;
2827 defm : ExtSetCCPat<SETGE,
2828 PatFrag<(ops node:$in, node:$cc),
2829 (setcc $in, 0, $cc)>,
2830 OutPatFrag<(ops node:$in),
2831 (RLWINM (i32not $in), 1, 31, 31)>,
2832 OutPatFrag<(ops node:$in),
2833 (RLDICL (i64not $in), 1, 63)> >;
2835 defm : ExtSetCCPat<SETGT,
2836 PatFrag<(ops node:$in, node:$cc),
2837 (setcc $in, 0, $cc)>,
2838 OutPatFrag<(ops node:$in),
2839 (RLWINM (ANDC (NEG $in), $in), 1, 31, 31)>,
2840 OutPatFrag<(ops node:$in),
2841 (RLDICL (ANDC8 (NEG8 $in), $in), 1, 63)> >;
2843 defm : ExtSetCCPat<SETLE,
2844 PatFrag<(ops node:$in, node:$cc),
2845 (setcc $in, 0, $cc)>,
2846 OutPatFrag<(ops node:$in),
2847 (RLWINM (ORC $in, (NEG $in)), 1, 31, 31)>,
2848 OutPatFrag<(ops node:$in),
2849 (RLDICL (ORC8 $in, (NEG8 $in)), 1, 63)> >;
2851 defm : ExtSetCCPat<SETLT,
2852 PatFrag<(ops node:$in, node:$cc),
2853 (setcc $in, -1, $cc)>,
2854 OutPatFrag<(ops node:$in),
2855 (RLWINM (AND $in, (ADDI $in, 1)), 1, 31, 31)>,
2856 OutPatFrag<(ops node:$in),
2857 (RLDICL (AND8 $in, (ADDI8 $in, 1)), 1, 63)> >;
2859 defm : ExtSetCCPat<SETGE,
2860 PatFrag<(ops node:$in, node:$cc),
2861 (setcc $in, -1, $cc)>,
2862 OutPatFrag<(ops node:$in),
2863 (RLWINM (NAND $in, (ADDI $in, 1)), 1, 31, 31)>,
2864 OutPatFrag<(ops node:$in),
2865 (RLDICL (NAND8 $in, (ADDI8 $in, 1)), 1, 63)> >;
2867 defm : ExtSetCCPat<SETGT,
2868 PatFrag<(ops node:$in, node:$cc),
2869 (setcc $in, -1, $cc)>,
2870 OutPatFrag<(ops node:$in),
2871 (RLWINM (i32not $in), 1, 31, 31)>,
2872 OutPatFrag<(ops node:$in),
2873 (RLDICL (i64not $in), 1, 63)> >;
2875 defm : ExtSetCCPat<SETLE,
2876 PatFrag<(ops node:$in, node:$cc),
2877 (setcc $in, -1, $cc)>,
2878 OutPatFrag<(ops node:$in),
2879 (RLWINM $in, 1, 31, 31)>,
2880 OutPatFrag<(ops node:$in),
2881 (RLDICL $in, 1, 63)> >;
2884 def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETULT)),
2885 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_lt)>;
2886 def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETLT)),
2887 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_lt)>;
2888 def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETUGT)),
2889 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_gt)>;
2890 def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETGT)),
2891 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_gt)>;
2892 def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETEQ)),
2893 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_eq)>;
2894 def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETEQ)),
2895 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_eq)>;
2897 // For non-equality comparisons, the default code would materialize the
2898 // constant, then compare against it, like this:
2900 // ori r2, r2, 22136
2903 // Since we are just comparing for equality, we can emit this instead:
2904 // xoris r0,r3,0x1234
2905 // cmplwi cr0,r0,0x5678
2908 def : Pat<(i1 (setcc i32:$s1, imm:$imm, SETEQ)),
2909 (EXTRACT_SUBREG (CMPLWI (XORIS $s1, (HI16 imm:$imm)),
2910 (LO16 imm:$imm)), sub_eq)>;
2912 defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETUGE)),
2913 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_lt)>;
2914 defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETGE)),
2915 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_lt)>;
2916 defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETULE)),
2917 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_gt)>;
2918 defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETLE)),
2919 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_gt)>;
2920 defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETNE)),
2921 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_eq)>;
2922 defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETNE)),
2923 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_eq)>;
2925 defm : CRNotPat<(i1 (setcc i32:$s1, imm:$imm, SETNE)),
2926 (EXTRACT_SUBREG (CMPLWI (XORIS $s1, (HI16 imm:$imm)),
2927 (LO16 imm:$imm)), sub_eq)>;
2929 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETULT)),
2930 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_lt)>;
2931 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETLT)),
2932 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_lt)>;
2933 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETUGT)),
2934 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_gt)>;
2935 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETGT)),
2936 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_gt)>;
2937 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETEQ)),
2938 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_eq)>;
2940 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETUGE)),
2941 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_lt)>;
2942 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETGE)),
2943 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_lt)>;
2944 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETULE)),
2945 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_gt)>;
2946 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETLE)),
2947 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_gt)>;
2948 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETNE)),
2949 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_eq)>;
2952 def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETULT)),
2953 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_lt)>;
2954 def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETLT)),
2955 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_lt)>;
2956 def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETUGT)),
2957 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_gt)>;
2958 def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETGT)),
2959 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_gt)>;
2960 def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETEQ)),
2961 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_eq)>;
2962 def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETEQ)),
2963 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_eq)>;
2965 // For non-equality comparisons, the default code would materialize the
2966 // constant, then compare against it, like this:
2968 // ori r2, r2, 22136
2971 // Since we are just comparing for equality, we can emit this instead:
2972 // xoris r0,r3,0x1234
2973 // cmpldi cr0,r0,0x5678
2976 def : Pat<(i1 (setcc i64:$s1, imm64ZExt32:$imm, SETEQ)),
2977 (EXTRACT_SUBREG (CMPLDI (XORIS8 $s1, (HI16 imm:$imm)),
2978 (LO16 imm:$imm)), sub_eq)>;
2980 defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETUGE)),
2981 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_lt)>;
2982 defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETGE)),
2983 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_lt)>;
2984 defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETULE)),
2985 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_gt)>;
2986 defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETLE)),
2987 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_gt)>;
2988 defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETNE)),
2989 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_eq)>;
2990 defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETNE)),
2991 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_eq)>;
2993 defm : CRNotPat<(i1 (setcc i64:$s1, imm64ZExt32:$imm, SETNE)),
2994 (EXTRACT_SUBREG (CMPLDI (XORIS8 $s1, (HI16 imm:$imm)),
2995 (LO16 imm:$imm)), sub_eq)>;
2997 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETULT)),
2998 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_lt)>;
2999 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETLT)),
3000 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_lt)>;
3001 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETUGT)),
3002 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_gt)>;
3003 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETGT)),
3004 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_gt)>;
3005 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETEQ)),
3006 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_eq)>;
3008 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETUGE)),
3009 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_lt)>;
3010 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETGE)),
3011 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_lt)>;
3012 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETULE)),
3013 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_gt)>;
3014 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETLE)),
3015 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_gt)>;
3016 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETNE)),
3017 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_eq)>;
3020 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOLT)),
3021 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3022 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETLT)),
3023 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3024 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOGT)),
3025 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3026 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETGT)),
3027 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3028 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOEQ)),
3029 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3030 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETEQ)),
3031 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3032 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETUO)),
3033 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_un)>;
3035 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETUGE)),
3036 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3037 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETGE)),
3038 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
3039 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETULE)),
3040 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3041 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETLE)),
3042 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
3043 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETUNE)),
3044 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3045 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETNE)),
3046 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
3047 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETO)),
3048 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_un)>;
3051 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOLT)),
3052 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3053 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETLT)),
3054 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3055 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOGT)),
3056 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3057 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETGT)),
3058 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3059 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOEQ)),
3060 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3061 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETEQ)),
3062 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3063 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETUO)),
3064 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_un)>;
3066 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETUGE)),
3067 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3068 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETGE)),
3069 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
3070 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETULE)),
3071 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3072 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETLE)),
3073 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
3074 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETUNE)),
3075 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3076 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETNE)),
3077 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3078 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETO)),
3079 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_un)>;
3081 // match select on i1 variables:
3082 def : Pat<(i1 (select i1:$cond, i1:$tval, i1:$fval)),
3083 (CROR (CRAND $cond , $tval),
3084 (CRAND (crnot $cond), $fval))>;
3086 // match selectcc on i1 variables:
3087 // select (lhs == rhs), tval, fval is:
3088 // ((lhs == rhs) & tval) | (!(lhs == rhs) & fval)
3089 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETLT)),
3090 (CROR (CRAND (CRANDC $rhs, $lhs), $tval),
3091 (CRAND (CRORC $lhs, $rhs), $fval))>;
3092 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETLE)),
3093 (CROR (CRAND (CRORC $rhs, $lhs), $tval),
3094 (CRAND (CRANDC $lhs, $rhs), $fval))>;
3095 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETEQ)),
3096 (CROR (CRAND (CREQV $lhs, $rhs), $tval),
3097 (CRAND (CRXOR $lhs, $rhs), $fval))>;
3098 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETGE)),
3099 (CROR (CRAND (CRORC $lhs, $rhs), $tval),
3100 (CRAND (CRANDC $rhs, $lhs), $fval))>;
3101 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETGT)),
3102 (CROR (CRAND (CRANDC $lhs, $rhs), $tval),
3103 (CRAND (CRORC $rhs, $lhs), $fval))>;
3104 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETNE)),
3105 (CROR (CRAND (CREQV $lhs, $rhs), $fval),
3106 (CRAND (CRXOR $lhs, $rhs), $tval))>;
3108 // match selectcc on i1 variables with non-i1 output.
3109 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETLT)),
3110 (SELECT_I4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3111 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETLE)),
3112 (SELECT_I4 (CRORC $rhs, $lhs), $tval, $fval)>;
3113 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETEQ)),
3114 (SELECT_I4 (CREQV $lhs, $rhs), $tval, $fval)>;
3115 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETGE)),
3116 (SELECT_I4 (CRORC $lhs, $rhs), $tval, $fval)>;
3117 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETGT)),
3118 (SELECT_I4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3119 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETNE)),
3120 (SELECT_I4 (CRXOR $lhs, $rhs), $tval, $fval)>;
3122 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETLT)),
3123 (SELECT_I8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3124 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETLE)),
3125 (SELECT_I8 (CRORC $rhs, $lhs), $tval, $fval)>;
3126 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETEQ)),
3127 (SELECT_I8 (CREQV $lhs, $rhs), $tval, $fval)>;
3128 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETGE)),
3129 (SELECT_I8 (CRORC $lhs, $rhs), $tval, $fval)>;
3130 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETGT)),
3131 (SELECT_I8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3132 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETNE)),
3133 (SELECT_I8 (CRXOR $lhs, $rhs), $tval, $fval)>;
3135 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETLT)),
3136 (SELECT_F4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3137 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETLE)),
3138 (SELECT_F4 (CRORC $rhs, $lhs), $tval, $fval)>;
3139 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETEQ)),
3140 (SELECT_F4 (CREQV $lhs, $rhs), $tval, $fval)>;
3141 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETGE)),
3142 (SELECT_F4 (CRORC $lhs, $rhs), $tval, $fval)>;
3143 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETGT)),
3144 (SELECT_F4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3145 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETNE)),
3146 (SELECT_F4 (CRXOR $lhs, $rhs), $tval, $fval)>;
3148 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETLT)),
3149 (SELECT_F8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3150 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETLE)),
3151 (SELECT_F8 (CRORC $rhs, $lhs), $tval, $fval)>;
3152 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETEQ)),
3153 (SELECT_F8 (CREQV $lhs, $rhs), $tval, $fval)>;
3154 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETGE)),
3155 (SELECT_F8 (CRORC $lhs, $rhs), $tval, $fval)>;
3156 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETGT)),
3157 (SELECT_F8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3158 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETNE)),
3159 (SELECT_F8 (CRXOR $lhs, $rhs), $tval, $fval)>;
3161 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETLT)),
3162 (SELECT_VRRC (CRANDC $rhs, $lhs), $tval, $fval)>;
3163 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETLE)),
3164 (SELECT_VRRC (CRORC $rhs, $lhs), $tval, $fval)>;
3165 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETEQ)),
3166 (SELECT_VRRC (CREQV $lhs, $rhs), $tval, $fval)>;
3167 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETGE)),
3168 (SELECT_VRRC (CRORC $lhs, $rhs), $tval, $fval)>;
3169 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETGT)),
3170 (SELECT_VRRC (CRANDC $lhs, $rhs), $tval, $fval)>;
3171 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETNE)),
3172 (SELECT_VRRC (CRXOR $lhs, $rhs), $tval, $fval)>;
3174 let usesCustomInserter = 1 in {
3175 def ANDIo_1_EQ_BIT : Pseudo<(outs crbitrc:$dst), (ins gprc:$in),
3177 [(set i1:$dst, (trunc (not i32:$in)))]>;
3178 def ANDIo_1_GT_BIT : Pseudo<(outs crbitrc:$dst), (ins gprc:$in),
3180 [(set i1:$dst, (trunc i32:$in))]>;
3182 def ANDIo_1_EQ_BIT8 : Pseudo<(outs crbitrc:$dst), (ins g8rc:$in),
3184 [(set i1:$dst, (trunc (not i64:$in)))]>;
3185 def ANDIo_1_GT_BIT8 : Pseudo<(outs crbitrc:$dst), (ins g8rc:$in),
3187 [(set i1:$dst, (trunc i64:$in))]>;
3190 def : Pat<(i1 (not (trunc i32:$in))),
3191 (ANDIo_1_EQ_BIT $in)>;
3192 def : Pat<(i1 (not (trunc i64:$in))),
3193 (ANDIo_1_EQ_BIT8 $in)>;
3195 //===----------------------------------------------------------------------===//
3196 // PowerPC Instructions used for assembler/disassembler only
3199 // FIXME: For B=0 or B > 8, the registers following RT are used.
3200 // WARNING: Do not add patterns for this instruction without fixing this.
3201 def LSWI : XForm_base_r3xo<31, 597, (outs gprc:$RT), (ins gprc:$A, u5imm:$B),
3202 "lswi $RT, $A, $B", IIC_LdStLoad, []>;
3204 // FIXME: For B=0 or B > 8, the registers following RT are used.
3205 // WARNING: Do not add patterns for this instruction without fixing this.
3206 def STSWI : XForm_base_r3xo<31, 725, (outs), (ins gprc:$RT, gprc:$A, u5imm:$B),
3207 "stswi $RT, $A, $B", IIC_LdStLoad, []>;
3209 def ISYNC : XLForm_2_ext<19, 150, 0, 0, 0, (outs), (ins),
3210 "isync", IIC_SprISYNC, []>;
3212 def ICBI : XForm_1a<31, 982, (outs), (ins memrr:$src),
3213 "icbi $src", IIC_LdStICBI, []>;
3215 // We used to have EIEIO as value but E[0-9A-Z] is a reserved name
3216 def EnforceIEIO : XForm_24_eieio<31, 854, (outs), (ins),
3217 "eieio", IIC_LdStLoad, []>;
3219 def WAIT : XForm_24_sync<31, 62, (outs), (ins i32imm:$L),
3220 "wait $L", IIC_LdStLoad, []>;
3222 def MBAR : XForm_mbar<31, 854, (outs), (ins u5imm:$MO),
3223 "mbar $MO", IIC_LdStLoad>, Requires<[IsBookE]>;
3225 def MTSR: XForm_sr<31, 210, (outs), (ins gprc:$RS, u4imm:$SR),
3226 "mtsr $SR, $RS", IIC_SprMTSR>;
3228 def MFSR: XForm_sr<31, 595, (outs gprc:$RS), (ins u4imm:$SR),
3229 "mfsr $RS, $SR", IIC_SprMFSR>;
3231 def MTSRIN: XForm_srin<31, 242, (outs), (ins gprc:$RS, gprc:$RB),
3232 "mtsrin $RS, $RB", IIC_SprMTSR>;
3234 def MFSRIN: XForm_srin<31, 659, (outs gprc:$RS), (ins gprc:$RB),
3235 "mfsrin $RS, $RB", IIC_SprMFSR>;
3237 def MTMSR: XForm_mtmsr<31, 146, (outs), (ins gprc:$RS, i32imm:$L),
3238 "mtmsr $RS, $L", IIC_SprMTMSR>;
3240 def WRTEE: XForm_mtmsr<31, 131, (outs), (ins gprc:$RS),
3241 "wrtee $RS", IIC_SprMTMSR>, Requires<[IsBookE]> {
3245 def WRTEEI: I<31, (outs), (ins i1imm:$E), "wrteei $E", IIC_SprMTMSR>,
3246 Requires<[IsBookE]> {
3250 let Inst{21-30} = 163;
3253 def DCCCI : XForm_tlb<454, (outs), (ins gprc:$A, gprc:$B),
3254 "dccci $A, $B", IIC_LdStLoad>, Requires<[IsPPC4xx]>;
3255 def ICCCI : XForm_tlb<966, (outs), (ins gprc:$A, gprc:$B),
3256 "iccci $A, $B", IIC_LdStLoad>, Requires<[IsPPC4xx]>;
3258 def : InstAlias<"dci 0", (DCCCI R0, R0)>, Requires<[IsPPC4xx]>;
3259 def : InstAlias<"dccci", (DCCCI R0, R0)>, Requires<[IsPPC4xx]>;
3260 def : InstAlias<"ici 0", (ICCCI R0, R0)>, Requires<[IsPPC4xx]>;
3261 def : InstAlias<"iccci", (ICCCI R0, R0)>, Requires<[IsPPC4xx]>;
3263 def MFMSR : XForm_rs<31, 83, (outs gprc:$RT), (ins),
3264 "mfmsr $RT", IIC_SprMFMSR, []>;
3266 def MTMSRD : XForm_mtmsr<31, 178, (outs), (ins gprc:$RS, i32imm:$L),
3267 "mtmsrd $RS, $L", IIC_SprMTMSRD>;
3269 def MCRFS : XLForm_3<63, 64, (outs crrc:$BF), (ins crrc:$BFA),
3270 "mcrfs $BF, $BFA", IIC_BrMCR>;
3272 def MTFSFI : XLForm_4<63, 134, (outs crrc:$BF), (ins i32imm:$U, i32imm:$W),
3273 "mtfsfi $BF, $U, $W", IIC_IntMFFS>;
3275 def MTFSFIo : XLForm_4<63, 134, (outs crrc:$BF), (ins i32imm:$U, i32imm:$W),
3276 "mtfsfi. $BF, $U, $W", IIC_IntMFFS>, isDOT;
3278 def : InstAlias<"mtfsfi $BF, $U", (MTFSFI crrc:$BF, i32imm:$U, 0)>;
3279 def : InstAlias<"mtfsfi. $BF, $U", (MTFSFIo crrc:$BF, i32imm:$U, 0)>;
3281 def MTFSF : XFLForm_1<63, 711, (outs),
3282 (ins i32imm:$FLM, f8rc:$FRB, i32imm:$L, i32imm:$W),
3283 "mtfsf $FLM, $FRB, $L, $W", IIC_IntMFFS, []>;
3284 def MTFSFo : XFLForm_1<63, 711, (outs),
3285 (ins i32imm:$FLM, f8rc:$FRB, i32imm:$L, i32imm:$W),
3286 "mtfsf. $FLM, $FRB, $L, $W", IIC_IntMFFS, []>, isDOT;
3288 def : InstAlias<"mtfsf $FLM, $FRB", (MTFSF i32imm:$FLM, f8rc:$FRB, 0, 0)>;
3289 def : InstAlias<"mtfsf. $FLM, $FRB", (MTFSFo i32imm:$FLM, f8rc:$FRB, 0, 0)>;
3291 def SLBIE : XForm_16b<31, 434, (outs), (ins gprc:$RB),
3292 "slbie $RB", IIC_SprSLBIE, []>;
3294 def SLBMTE : XForm_26<31, 402, (outs), (ins gprc:$RS, gprc:$RB),
3295 "slbmte $RS, $RB", IIC_SprSLBMTE, []>;
3297 def SLBMFEE : XForm_26<31, 915, (outs gprc:$RT), (ins gprc:$RB),
3298 "slbmfee $RT, $RB", IIC_SprSLBMFEE, []>;
3300 def SLBIA : XForm_0<31, 498, (outs), (ins), "slbia", IIC_SprSLBIA, []>;
3302 def TLBIA : XForm_0<31, 370, (outs), (ins),
3303 "tlbia", IIC_SprTLBIA, []>;
3305 def TLBSYNC : XForm_0<31, 566, (outs), (ins),
3306 "tlbsync", IIC_SprTLBSYNC, []>;
3308 def TLBIEL : XForm_16b<31, 274, (outs), (ins gprc:$RB),
3309 "tlbiel $RB", IIC_SprTLBIEL, []>;
3311 def TLBLD : XForm_16b<31, 978, (outs), (ins gprc:$RB),
3312 "tlbld $RB", IIC_LdStLoad, []>, Requires<[IsPPC6xx]>;
3313 def TLBLI : XForm_16b<31, 1010, (outs), (ins gprc:$RB),
3314 "tlbli $RB", IIC_LdStLoad, []>, Requires<[IsPPC6xx]>;
3316 def TLBIE : XForm_26<31, 306, (outs), (ins gprc:$RS, gprc:$RB),
3317 "tlbie $RB,$RS", IIC_SprTLBIE, []>;
3319 def TLBSX : XForm_tlb<914, (outs), (ins gprc:$A, gprc:$B), "tlbsx $A, $B",
3320 IIC_LdStLoad>, Requires<[IsBookE]>;
3322 def TLBIVAX : XForm_tlb<786, (outs), (ins gprc:$A, gprc:$B), "tlbivax $A, $B",
3323 IIC_LdStLoad>, Requires<[IsBookE]>;
3325 def TLBRE : XForm_24_eieio<31, 946, (outs), (ins),
3326 "tlbre", IIC_LdStLoad, []>, Requires<[IsBookE]>;
3328 def TLBWE : XForm_24_eieio<31, 978, (outs), (ins),
3329 "tlbwe", IIC_LdStLoad, []>, Requires<[IsBookE]>;
3331 def TLBRE2 : XForm_tlbws<31, 946, (outs gprc:$RS), (ins gprc:$A, i1imm:$WS),
3332 "tlbre $RS, $A, $WS", IIC_LdStLoad, []>, Requires<[IsPPC4xx]>;
3334 def TLBWE2 : XForm_tlbws<31, 978, (outs), (ins gprc:$RS, gprc:$A, i1imm:$WS),
3335 "tlbwe $RS, $A, $WS", IIC_LdStLoad, []>, Requires<[IsPPC4xx]>;
3337 def TLBSX2 : XForm_base_r3xo<31, 914, (outs), (ins gprc:$RST, gprc:$A, gprc:$B),
3338 "tlbsx $RST, $A, $B", IIC_LdStLoad, []>,
3339 Requires<[IsPPC4xx]>;
3340 def TLBSX2D : XForm_base_r3xo<31, 914, (outs),
3341 (ins gprc:$RST, gprc:$A, gprc:$B),
3342 "tlbsx. $RST, $A, $B", IIC_LdStLoad, []>,
3343 Requires<[IsPPC4xx]>, isDOT;
3345 def RFID : XForm_0<19, 18, (outs), (ins), "rfid", IIC_IntRFID, []>;
3347 def RFI : XForm_0<19, 50, (outs), (ins), "rfi", IIC_SprRFI, []>,
3348 Requires<[IsBookE]>;
3349 def RFCI : XForm_0<19, 51, (outs), (ins), "rfci", IIC_BrB, []>,
3350 Requires<[IsBookE]>;
3352 def RFDI : XForm_0<19, 39, (outs), (ins), "rfdi", IIC_BrB, []>,
3354 def RFMCI : XForm_0<19, 38, (outs), (ins), "rfmci", IIC_BrB, []>,
3357 def MFDCR : XFXForm_1<31, 323, (outs gprc:$RT), (ins i32imm:$SPR),
3358 "mfdcr $RT, $SPR", IIC_SprMFSPR>, Requires<[IsPPC4xx]>;
3359 def MTDCR : XFXForm_1<31, 451, (outs), (ins gprc:$RT, i32imm:$SPR),
3360 "mtdcr $SPR, $RT", IIC_SprMTSPR>, Requires<[IsPPC4xx]>;
3362 def ATTN : XForm_attn<0, 256, (outs), (ins), "attn", IIC_BrB>;
3364 def LBZCIX : XForm_base_r3xo<31, 853, (outs gprc:$RST), (ins gprc:$A, gprc:$B),
3365 "lbzcix $RST, $A, $B", IIC_LdStLoad, []>;
3366 def LHZCIX : XForm_base_r3xo<31, 821, (outs gprc:$RST), (ins gprc:$A, gprc:$B),
3367 "lhzcix $RST, $A, $B", IIC_LdStLoad, []>;
3368 def LWZCIX : XForm_base_r3xo<31, 789, (outs gprc:$RST), (ins gprc:$A, gprc:$B),
3369 "lwzcix $RST, $A, $B", IIC_LdStLoad, []>;
3370 def LDCIX : XForm_base_r3xo<31, 885, (outs gprc:$RST), (ins gprc:$A, gprc:$B),
3371 "ldcix $RST, $A, $B", IIC_LdStLoad, []>;
3373 def STBCIX : XForm_base_r3xo<31, 981, (outs), (ins gprc:$RST, gprc:$A, gprc:$B),
3374 "stbcix $RST, $A, $B", IIC_LdStLoad, []>;
3375 def STHCIX : XForm_base_r3xo<31, 949, (outs), (ins gprc:$RST, gprc:$A, gprc:$B),
3376 "sthcix $RST, $A, $B", IIC_LdStLoad, []>;
3377 def STWCIX : XForm_base_r3xo<31, 917, (outs), (ins gprc:$RST, gprc:$A, gprc:$B),
3378 "stwcix $RST, $A, $B", IIC_LdStLoad, []>;
3379 def STDCIX : XForm_base_r3xo<31, 1013, (outs), (ins gprc:$RST, gprc:$A, gprc:$B),
3380 "stdcix $RST, $A, $B", IIC_LdStLoad, []>;
3382 //===----------------------------------------------------------------------===//
3383 // PowerPC Assembler Instruction Aliases
3386 // Pseudo-instructions for alternate assembly syntax (never used by codegen).
3387 // These are aliases that require C++ handling to convert to the target
3388 // instruction, while InstAliases can be handled directly by tblgen.
3389 class PPCAsmPseudo<string asm, dag iops>
3391 let Namespace = "PPC";
3392 bit PPC64 = 0; // Default value, override with isPPC64
3394 let OutOperandList = (outs);
3395 let InOperandList = iops;
3397 let AsmString = asm;
3398 let isAsmParserOnly = 1;
3402 def : InstAlias<"sc", (SC 0)>;
3404 def : InstAlias<"sync", (SYNC 0)>, Requires<[HasSYNC]>;
3405 def : InstAlias<"msync", (SYNC 0)>, Requires<[HasSYNC]>;
3406 def : InstAlias<"lwsync", (SYNC 1)>, Requires<[HasSYNC]>;
3407 def : InstAlias<"ptesync", (SYNC 2)>, Requires<[HasSYNC]>;
3409 def : InstAlias<"wait", (WAIT 0)>;
3410 def : InstAlias<"waitrsv", (WAIT 1)>;
3411 def : InstAlias<"waitimpl", (WAIT 2)>;
3413 def : InstAlias<"mbar", (MBAR 0)>, Requires<[IsBookE]>;
3415 def : InstAlias<"crset $bx", (CREQV crbitrc:$bx, crbitrc:$bx, crbitrc:$bx)>;
3416 def : InstAlias<"crclr $bx", (CRXOR crbitrc:$bx, crbitrc:$bx, crbitrc:$bx)>;
3417 def : InstAlias<"crmove $bx, $by", (CROR crbitrc:$bx, crbitrc:$by, crbitrc:$by)>;
3418 def : InstAlias<"crnot $bx, $by", (CRNOR crbitrc:$bx, crbitrc:$by, crbitrc:$by)>;
3420 def : InstAlias<"mtxer $Rx", (MTSPR 1, gprc:$Rx)>;
3421 def : InstAlias<"mfxer $Rx", (MFSPR gprc:$Rx, 1)>;
3423 def : InstAlias<"mfrtcu $Rx", (MFSPR gprc:$Rx, 4)>;
3424 def : InstAlias<"mfrtcl $Rx", (MFSPR gprc:$Rx, 5)>;
3426 def : InstAlias<"mtdscr $Rx", (MTSPR 17, gprc:$Rx)>;
3427 def : InstAlias<"mfdscr $Rx", (MFSPR gprc:$Rx, 17)>;
3429 def : InstAlias<"mtdsisr $Rx", (MTSPR 18, gprc:$Rx)>;
3430 def : InstAlias<"mfdsisr $Rx", (MFSPR gprc:$Rx, 18)>;
3432 def : InstAlias<"mtdar $Rx", (MTSPR 19, gprc:$Rx)>;
3433 def : InstAlias<"mfdar $Rx", (MFSPR gprc:$Rx, 19)>;
3435 def : InstAlias<"mtdec $Rx", (MTSPR 22, gprc:$Rx)>;
3436 def : InstAlias<"mfdec $Rx", (MFSPR gprc:$Rx, 22)>;
3438 def : InstAlias<"mtsdr1 $Rx", (MTSPR 25, gprc:$Rx)>;
3439 def : InstAlias<"mfsdr1 $Rx", (MFSPR gprc:$Rx, 25)>;
3441 def : InstAlias<"mtsrr0 $Rx", (MTSPR 26, gprc:$Rx)>;
3442 def : InstAlias<"mfsrr0 $Rx", (MFSPR gprc:$Rx, 26)>;
3444 def : InstAlias<"mtsrr1 $Rx", (MTSPR 27, gprc:$Rx)>;
3445 def : InstAlias<"mfsrr1 $Rx", (MFSPR gprc:$Rx, 27)>;
3447 def : InstAlias<"mtsrr2 $Rx", (MTSPR 990, gprc:$Rx)>, Requires<[IsPPC4xx]>;
3448 def : InstAlias<"mfsrr2 $Rx", (MFSPR gprc:$Rx, 990)>, Requires<[IsPPC4xx]>;
3450 def : InstAlias<"mtsrr3 $Rx", (MTSPR 991, gprc:$Rx)>, Requires<[IsPPC4xx]>;
3451 def : InstAlias<"mfsrr3 $Rx", (MFSPR gprc:$Rx, 991)>, Requires<[IsPPC4xx]>;
3453 def : InstAlias<"mtcfar $Rx", (MTSPR 28, gprc:$Rx)>;
3454 def : InstAlias<"mfcfar $Rx", (MFSPR gprc:$Rx, 28)>;
3456 def : InstAlias<"mtamr $Rx", (MTSPR 29, gprc:$Rx)>;
3457 def : InstAlias<"mfamr $Rx", (MFSPR gprc:$Rx, 29)>;
3459 def : InstAlias<"mtpid $Rx", (MTSPR 48, gprc:$Rx)>, Requires<[IsBookE]>;
3460 def : InstAlias<"mfpid $Rx", (MFSPR gprc:$Rx, 48)>, Requires<[IsBookE]>;
3462 def : InstAlias<"mftb $Rx", (MFTB gprc:$Rx, 268)>;
3463 def : InstAlias<"mftbl $Rx", (MFTB gprc:$Rx, 268)>;
3464 def : InstAlias<"mftbu $Rx", (MFTB gprc:$Rx, 269)>;
3466 def : InstAlias<"mttbl $Rx", (MTSPR 284, gprc:$Rx)>;
3467 def : InstAlias<"mttbu $Rx", (MTSPR 285, gprc:$Rx)>;
3469 def : InstAlias<"mftblo $Rx", (MFSPR gprc:$Rx, 989)>, Requires<[IsPPC4xx]>;
3470 def : InstAlias<"mttblo $Rx", (MTSPR 989, gprc:$Rx)>, Requires<[IsPPC4xx]>;
3471 def : InstAlias<"mftbhi $Rx", (MFSPR gprc:$Rx, 988)>, Requires<[IsPPC4xx]>;
3472 def : InstAlias<"mttbhi $Rx", (MTSPR 988, gprc:$Rx)>, Requires<[IsPPC4xx]>;
3474 def : InstAlias<"xnop", (XORI R0, R0, 0)>;
3476 def : InstAlias<"mr $rA, $rB", (OR8 g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
3477 def : InstAlias<"mr. $rA, $rB", (OR8o g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
3479 def : InstAlias<"not $rA, $rB", (NOR8 g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
3480 def : InstAlias<"not. $rA, $rB", (NOR8o g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
3482 def : InstAlias<"mtcr $rA", (MTCRF8 255, g8rc:$rA)>;
3484 foreach BATR = 0-3 in {
3485 def : InstAlias<"mtdbatu "#BATR#", $Rx",
3486 (MTSPR !add(BATR, !add(BATR, 536)), gprc:$Rx)>,
3487 Requires<[IsPPC6xx]>;
3488 def : InstAlias<"mfdbatu $Rx, "#BATR,
3489 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 536)))>,
3490 Requires<[IsPPC6xx]>;
3491 def : InstAlias<"mtdbatl "#BATR#", $Rx",
3492 (MTSPR !add(BATR, !add(BATR, 537)), gprc:$Rx)>,
3493 Requires<[IsPPC6xx]>;
3494 def : InstAlias<"mfdbatl $Rx, "#BATR,
3495 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 537)))>,
3496 Requires<[IsPPC6xx]>;
3497 def : InstAlias<"mtibatu "#BATR#", $Rx",
3498 (MTSPR !add(BATR, !add(BATR, 528)), gprc:$Rx)>,
3499 Requires<[IsPPC6xx]>;
3500 def : InstAlias<"mfibatu $Rx, "#BATR,
3501 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 528)))>,
3502 Requires<[IsPPC6xx]>;
3503 def : InstAlias<"mtibatl "#BATR#", $Rx",
3504 (MTSPR !add(BATR, !add(BATR, 529)), gprc:$Rx)>,
3505 Requires<[IsPPC6xx]>;
3506 def : InstAlias<"mfibatl $Rx, "#BATR,
3507 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 529)))>,
3508 Requires<[IsPPC6xx]>;
3511 foreach BR = 0-7 in {
3512 def : InstAlias<"mfbr"#BR#" $Rx",
3513 (MFDCR gprc:$Rx, !add(BR, 0x80))>,
3514 Requires<[IsPPC4xx]>;
3515 def : InstAlias<"mtbr"#BR#" $Rx",
3516 (MTDCR gprc:$Rx, !add(BR, 0x80))>,
3517 Requires<[IsPPC4xx]>;
3520 def : InstAlias<"mtdccr $Rx", (MTSPR 1018, gprc:$Rx)>, Requires<[IsPPC4xx]>;
3521 def : InstAlias<"mfdccr $Rx", (MFSPR gprc:$Rx, 1018)>, Requires<[IsPPC4xx]>;
3523 def : InstAlias<"mticcr $Rx", (MTSPR 1019, gprc:$Rx)>, Requires<[IsPPC4xx]>;
3524 def : InstAlias<"mficcr $Rx", (MFSPR gprc:$Rx, 1019)>, Requires<[IsPPC4xx]>;
3526 def : InstAlias<"mtdear $Rx", (MTSPR 981, gprc:$Rx)>, Requires<[IsPPC4xx]>;
3527 def : InstAlias<"mfdear $Rx", (MFSPR gprc:$Rx, 981)>, Requires<[IsPPC4xx]>;
3529 def : InstAlias<"mtesr $Rx", (MTSPR 980, gprc:$Rx)>, Requires<[IsPPC4xx]>;
3530 def : InstAlias<"mfesr $Rx", (MFSPR gprc:$Rx, 980)>, Requires<[IsPPC4xx]>;
3532 def : InstAlias<"mfspefscr $Rx", (MFSPR gprc:$Rx, 512)>;
3533 def : InstAlias<"mtspefscr $Rx", (MTSPR 512, gprc:$Rx)>;
3535 def : InstAlias<"mttcr $Rx", (MTSPR 986, gprc:$Rx)>, Requires<[IsPPC4xx]>;
3536 def : InstAlias<"mftcr $Rx", (MFSPR gprc:$Rx, 986)>, Requires<[IsPPC4xx]>;
3538 def LAx : PPCAsmPseudo<"la $rA, $addr", (ins gprc:$rA, memri:$addr)>;
3540 def SUBI : PPCAsmPseudo<"subi $rA, $rB, $imm",
3541 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
3542 def SUBIS : PPCAsmPseudo<"subis $rA, $rB, $imm",
3543 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
3544 def SUBIC : PPCAsmPseudo<"subic $rA, $rB, $imm",
3545 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
3546 def SUBICo : PPCAsmPseudo<"subic. $rA, $rB, $imm",
3547 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
3549 def : InstAlias<"sub $rA, $rB, $rC", (SUBF8 g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
3550 def : InstAlias<"sub. $rA, $rB, $rC", (SUBF8o g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
3551 def : InstAlias<"subc $rA, $rB, $rC", (SUBFC8 g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
3552 def : InstAlias<"subc. $rA, $rB, $rC", (SUBFC8o g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
3554 def : InstAlias<"mtmsrd $RS", (MTMSRD gprc:$RS, 0)>;
3555 def : InstAlias<"mtmsr $RS", (MTMSR gprc:$RS, 0)>;
3557 def : InstAlias<"mfasr $RT", (MFSPR gprc:$RT, 280)>;
3558 def : InstAlias<"mtasr $RT", (MTSPR 280, gprc:$RT)>;
3560 foreach SPRG = 0-3 in {
3561 def : InstAlias<"mfsprg $RT, "#SPRG, (MFSPR gprc:$RT, !add(SPRG, 272))>;
3562 def : InstAlias<"mfsprg"#SPRG#" $RT", (MFSPR gprc:$RT, !add(SPRG, 272))>;
3563 def : InstAlias<"mtsprg "#SPRG#", $RT", (MTSPR !add(SPRG, 272), gprc:$RT)>;
3564 def : InstAlias<"mtsprg"#SPRG#" $RT", (MTSPR !add(SPRG, 272), gprc:$RT)>;
3566 foreach SPRG = 4-7 in {
3567 def : InstAlias<"mfsprg $RT, "#SPRG, (MFSPR gprc:$RT, !add(SPRG, 256))>,
3568 Requires<[IsBookE]>;
3569 def : InstAlias<"mfsprg"#SPRG#" $RT", (MFSPR gprc:$RT, !add(SPRG, 256))>,
3570 Requires<[IsBookE]>;
3571 def : InstAlias<"mtsprg "#SPRG#", $RT", (MTSPR !add(SPRG, 256), gprc:$RT)>,
3572 Requires<[IsBookE]>;
3573 def : InstAlias<"mtsprg"#SPRG#" $RT", (MTSPR !add(SPRG, 256), gprc:$RT)>,
3574 Requires<[IsBookE]>;
3577 def : InstAlias<"mtasr $RS", (MTSPR 280, gprc:$RS)>;
3579 def : InstAlias<"mfdec $RT", (MFSPR gprc:$RT, 22)>;
3580 def : InstAlias<"mtdec $RT", (MTSPR 22, gprc:$RT)>;
3582 def : InstAlias<"mfpvr $RT", (MFSPR gprc:$RT, 287)>;
3584 def : InstAlias<"mfsdr1 $RT", (MFSPR gprc:$RT, 25)>;
3585 def : InstAlias<"mtsdr1 $RT", (MTSPR 25, gprc:$RT)>;
3587 def : InstAlias<"mfsrr0 $RT", (MFSPR gprc:$RT, 26)>;
3588 def : InstAlias<"mfsrr1 $RT", (MFSPR gprc:$RT, 27)>;
3589 def : InstAlias<"mtsrr0 $RT", (MTSPR 26, gprc:$RT)>;
3590 def : InstAlias<"mtsrr1 $RT", (MTSPR 27, gprc:$RT)>;
3592 def : InstAlias<"tlbie $RB", (TLBIE R0, gprc:$RB)>;
3594 def : InstAlias<"tlbrehi $RS, $A", (TLBRE2 gprc:$RS, gprc:$A, 0)>,
3595 Requires<[IsPPC4xx]>;
3596 def : InstAlias<"tlbrelo $RS, $A", (TLBRE2 gprc:$RS, gprc:$A, 1)>,
3597 Requires<[IsPPC4xx]>;
3598 def : InstAlias<"tlbwehi $RS, $A", (TLBWE2 gprc:$RS, gprc:$A, 0)>,
3599 Requires<[IsPPC4xx]>;
3600 def : InstAlias<"tlbwelo $RS, $A", (TLBWE2 gprc:$RS, gprc:$A, 1)>,
3601 Requires<[IsPPC4xx]>;
3603 def EXTLWI : PPCAsmPseudo<"extlwi $rA, $rS, $n, $b",
3604 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
3605 def EXTLWIo : PPCAsmPseudo<"extlwi. $rA, $rS, $n, $b",
3606 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
3607 def EXTRWI : PPCAsmPseudo<"extrwi $rA, $rS, $n, $b",
3608 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
3609 def EXTRWIo : PPCAsmPseudo<"extrwi. $rA, $rS, $n, $b",
3610 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
3611 def INSLWI : PPCAsmPseudo<"inslwi $rA, $rS, $n, $b",
3612 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
3613 def INSLWIo : PPCAsmPseudo<"inslwi. $rA, $rS, $n, $b",
3614 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
3615 def INSRWI : PPCAsmPseudo<"insrwi $rA, $rS, $n, $b",
3616 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
3617 def INSRWIo : PPCAsmPseudo<"insrwi. $rA, $rS, $n, $b",
3618 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
3619 def ROTRWI : PPCAsmPseudo<"rotrwi $rA, $rS, $n",
3620 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
3621 def ROTRWIo : PPCAsmPseudo<"rotrwi. $rA, $rS, $n",
3622 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
3623 def SLWI : PPCAsmPseudo<"slwi $rA, $rS, $n",
3624 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
3625 def SLWIo : PPCAsmPseudo<"slwi. $rA, $rS, $n",
3626 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
3627 def SRWI : PPCAsmPseudo<"srwi $rA, $rS, $n",
3628 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
3629 def SRWIo : PPCAsmPseudo<"srwi. $rA, $rS, $n",
3630 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
3631 def CLRRWI : PPCAsmPseudo<"clrrwi $rA, $rS, $n",
3632 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
3633 def CLRRWIo : PPCAsmPseudo<"clrrwi. $rA, $rS, $n",
3634 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
3635 def CLRLSLWI : PPCAsmPseudo<"clrlslwi $rA, $rS, $b, $n",
3636 (ins gprc:$rA, gprc:$rS, u5imm:$b, u5imm:$n)>;
3637 def CLRLSLWIo : PPCAsmPseudo<"clrlslwi. $rA, $rS, $b, $n",
3638 (ins gprc:$rA, gprc:$rS, u5imm:$b, u5imm:$n)>;
3640 def : InstAlias<"rotlwi $rA, $rS, $n", (RLWINM gprc:$rA, gprc:$rS, u5imm:$n, 0, 31)>;
3641 def : InstAlias<"rotlwi. $rA, $rS, $n", (RLWINMo gprc:$rA, gprc:$rS, u5imm:$n, 0, 31)>;
3642 def : InstAlias<"rotlw $rA, $rS, $rB", (RLWNM gprc:$rA, gprc:$rS, gprc:$rB, 0, 31)>;
3643 def : InstAlias<"rotlw. $rA, $rS, $rB", (RLWNMo gprc:$rA, gprc:$rS, gprc:$rB, 0, 31)>;
3644 def : InstAlias<"clrlwi $rA, $rS, $n", (RLWINM gprc:$rA, gprc:$rS, 0, u5imm:$n, 31)>;
3645 def : InstAlias<"clrlwi. $rA, $rS, $n", (RLWINMo gprc:$rA, gprc:$rS, 0, u5imm:$n, 31)>;
3647 def : InstAlias<"cntlz $rA, $rS", (CNTLZW gprc:$rA, gprc:$rS)>;
3648 def : InstAlias<"cntlz. $rA, $rS", (CNTLZWo gprc:$rA, gprc:$rS)>;
3650 def EXTLDI : PPCAsmPseudo<"extldi $rA, $rS, $n, $b",
3651 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
3652 def EXTLDIo : PPCAsmPseudo<"extldi. $rA, $rS, $n, $b",
3653 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
3654 def EXTRDI : PPCAsmPseudo<"extrdi $rA, $rS, $n, $b",
3655 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
3656 def EXTRDIo : PPCAsmPseudo<"extrdi. $rA, $rS, $n, $b",
3657 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
3658 def INSRDI : PPCAsmPseudo<"insrdi $rA, $rS, $n, $b",
3659 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
3660 def INSRDIo : PPCAsmPseudo<"insrdi. $rA, $rS, $n, $b",
3661 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
3662 def ROTRDI : PPCAsmPseudo<"rotrdi $rA, $rS, $n",
3663 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
3664 def ROTRDIo : PPCAsmPseudo<"rotrdi. $rA, $rS, $n",
3665 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
3666 def SLDI : PPCAsmPseudo<"sldi $rA, $rS, $n",
3667 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
3668 def SLDIo : PPCAsmPseudo<"sldi. $rA, $rS, $n",
3669 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
3670 def SRDI : PPCAsmPseudo<"srdi $rA, $rS, $n",
3671 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
3672 def SRDIo : PPCAsmPseudo<"srdi. $rA, $rS, $n",
3673 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
3674 def CLRRDI : PPCAsmPseudo<"clrrdi $rA, $rS, $n",
3675 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
3676 def CLRRDIo : PPCAsmPseudo<"clrrdi. $rA, $rS, $n",
3677 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
3678 def CLRLSLDI : PPCAsmPseudo<"clrlsldi $rA, $rS, $b, $n",
3679 (ins g8rc:$rA, g8rc:$rS, u6imm:$b, u6imm:$n)>;
3680 def CLRLSLDIo : PPCAsmPseudo<"clrlsldi. $rA, $rS, $b, $n",
3681 (ins g8rc:$rA, g8rc:$rS, u6imm:$b, u6imm:$n)>;
3683 def : InstAlias<"rotldi $rA, $rS, $n", (RLDICL g8rc:$rA, g8rc:$rS, u6imm:$n, 0)>;
3684 def : InstAlias<"rotldi. $rA, $rS, $n", (RLDICLo g8rc:$rA, g8rc:$rS, u6imm:$n, 0)>;
3685 def : InstAlias<"rotld $rA, $rS, $rB", (RLDCL g8rc:$rA, g8rc:$rS, gprc:$rB, 0)>;
3686 def : InstAlias<"rotld. $rA, $rS, $rB", (RLDCLo g8rc:$rA, g8rc:$rS, gprc:$rB, 0)>;
3687 def : InstAlias<"clrldi $rA, $rS, $n", (RLDICL g8rc:$rA, g8rc:$rS, 0, u6imm:$n)>;
3688 def : InstAlias<"clrldi. $rA, $rS, $n", (RLDICLo g8rc:$rA, g8rc:$rS, 0, u6imm:$n)>;
3690 // These generic branch instruction forms are used for the assembler parser only.
3691 // Defs and Uses are conservative, since we don't know the BO value.
3692 let PPC970_Unit = 7 in {
3693 let Defs = [CTR], Uses = [CTR, RM] in {
3694 def gBC : BForm_3<16, 0, 0, (outs),
3695 (ins u5imm:$bo, crbitrc:$bi, condbrtarget:$dst),
3696 "bc $bo, $bi, $dst">;
3697 def gBCA : BForm_3<16, 1, 0, (outs),
3698 (ins u5imm:$bo, crbitrc:$bi, abscondbrtarget:$dst),
3699 "bca $bo, $bi, $dst">;
3701 let Defs = [LR, CTR], Uses = [CTR, RM] in {
3702 def gBCL : BForm_3<16, 0, 1, (outs),
3703 (ins u5imm:$bo, crbitrc:$bi, condbrtarget:$dst),
3704 "bcl $bo, $bi, $dst">;
3705 def gBCLA : BForm_3<16, 1, 1, (outs),
3706 (ins u5imm:$bo, crbitrc:$bi, abscondbrtarget:$dst),
3707 "bcla $bo, $bi, $dst">;
3709 let Defs = [CTR], Uses = [CTR, LR, RM] in
3710 def gBCLR : XLForm_2<19, 16, 0, (outs),
3711 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
3712 "bclr $bo, $bi, $bh", IIC_BrB, []>;
3713 let Defs = [LR, CTR], Uses = [CTR, LR, RM] in
3714 def gBCLRL : XLForm_2<19, 16, 1, (outs),
3715 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
3716 "bclrl $bo, $bi, $bh", IIC_BrB, []>;
3717 let Defs = [CTR], Uses = [CTR, LR, RM] in
3718 def gBCCTR : XLForm_2<19, 528, 0, (outs),
3719 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
3720 "bcctr $bo, $bi, $bh", IIC_BrB, []>;
3721 let Defs = [LR, CTR], Uses = [CTR, LR, RM] in
3722 def gBCCTRL : XLForm_2<19, 528, 1, (outs),
3723 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
3724 "bcctrl $bo, $bi, $bh", IIC_BrB, []>;
3726 def : InstAlias<"bclr $bo, $bi", (gBCLR u5imm:$bo, crbitrc:$bi, 0)>;
3727 def : InstAlias<"bclrl $bo, $bi", (gBCLRL u5imm:$bo, crbitrc:$bi, 0)>;
3728 def : InstAlias<"bcctr $bo, $bi", (gBCCTR u5imm:$bo, crbitrc:$bi, 0)>;
3729 def : InstAlias<"bcctrl $bo, $bi", (gBCCTRL u5imm:$bo, crbitrc:$bi, 0)>;
3731 multiclass BranchSimpleMnemonic1<string name, string pm, int bo> {
3732 def : InstAlias<"b"#name#pm#" $bi, $dst", (gBC bo, crbitrc:$bi, condbrtarget:$dst)>;
3733 def : InstAlias<"b"#name#"a"#pm#" $bi, $dst", (gBCA bo, crbitrc:$bi, abscondbrtarget:$dst)>;
3734 def : InstAlias<"b"#name#"lr"#pm#" $bi", (gBCLR bo, crbitrc:$bi, 0)>;
3735 def : InstAlias<"b"#name#"l"#pm#" $bi, $dst", (gBCL bo, crbitrc:$bi, condbrtarget:$dst)>;
3736 def : InstAlias<"b"#name#"la"#pm#" $bi, $dst", (gBCLA bo, crbitrc:$bi, abscondbrtarget:$dst)>;
3737 def : InstAlias<"b"#name#"lrl"#pm#" $bi", (gBCLRL bo, crbitrc:$bi, 0)>;
3739 multiclass BranchSimpleMnemonic2<string name, string pm, int bo>
3740 : BranchSimpleMnemonic1<name, pm, bo> {
3741 def : InstAlias<"b"#name#"ctr"#pm#" $bi", (gBCCTR bo, crbitrc:$bi, 0)>;
3742 def : InstAlias<"b"#name#"ctrl"#pm#" $bi", (gBCCTRL bo, crbitrc:$bi, 0)>;
3744 defm : BranchSimpleMnemonic2<"t", "", 12>;
3745 defm : BranchSimpleMnemonic2<"f", "", 4>;
3746 defm : BranchSimpleMnemonic2<"t", "-", 14>;
3747 defm : BranchSimpleMnemonic2<"f", "-", 6>;
3748 defm : BranchSimpleMnemonic2<"t", "+", 15>;
3749 defm : BranchSimpleMnemonic2<"f", "+", 7>;
3750 defm : BranchSimpleMnemonic1<"dnzt", "", 8>;
3751 defm : BranchSimpleMnemonic1<"dnzf", "", 0>;
3752 defm : BranchSimpleMnemonic1<"dzt", "", 10>;
3753 defm : BranchSimpleMnemonic1<"dzf", "", 2>;
3755 multiclass BranchExtendedMnemonicPM<string name, string pm, int bibo> {
3756 def : InstAlias<"b"#name#pm#" $cc, $dst",
3757 (BCC bibo, crrc:$cc, condbrtarget:$dst)>;
3758 def : InstAlias<"b"#name#pm#" $dst",
3759 (BCC bibo, CR0, condbrtarget:$dst)>;
3761 def : InstAlias<"b"#name#"a"#pm#" $cc, $dst",
3762 (BCCA bibo, crrc:$cc, abscondbrtarget:$dst)>;
3763 def : InstAlias<"b"#name#"a"#pm#" $dst",
3764 (BCCA bibo, CR0, abscondbrtarget:$dst)>;
3766 def : InstAlias<"b"#name#"lr"#pm#" $cc",
3767 (BCCLR bibo, crrc:$cc)>;
3768 def : InstAlias<"b"#name#"lr"#pm,
3771 def : InstAlias<"b"#name#"ctr"#pm#" $cc",
3772 (BCCCTR bibo, crrc:$cc)>;
3773 def : InstAlias<"b"#name#"ctr"#pm,
3774 (BCCCTR bibo, CR0)>;
3776 def : InstAlias<"b"#name#"l"#pm#" $cc, $dst",
3777 (BCCL bibo, crrc:$cc, condbrtarget:$dst)>;
3778 def : InstAlias<"b"#name#"l"#pm#" $dst",
3779 (BCCL bibo, CR0, condbrtarget:$dst)>;
3781 def : InstAlias<"b"#name#"la"#pm#" $cc, $dst",
3782 (BCCLA bibo, crrc:$cc, abscondbrtarget:$dst)>;
3783 def : InstAlias<"b"#name#"la"#pm#" $dst",
3784 (BCCLA bibo, CR0, abscondbrtarget:$dst)>;
3786 def : InstAlias<"b"#name#"lrl"#pm#" $cc",
3787 (BCCLRL bibo, crrc:$cc)>;
3788 def : InstAlias<"b"#name#"lrl"#pm,
3789 (BCCLRL bibo, CR0)>;
3791 def : InstAlias<"b"#name#"ctrl"#pm#" $cc",
3792 (BCCCTRL bibo, crrc:$cc)>;
3793 def : InstAlias<"b"#name#"ctrl"#pm,
3794 (BCCCTRL bibo, CR0)>;
3796 multiclass BranchExtendedMnemonic<string name, int bibo> {
3797 defm : BranchExtendedMnemonicPM<name, "", bibo>;
3798 defm : BranchExtendedMnemonicPM<name, "-", !add(bibo, 2)>;
3799 defm : BranchExtendedMnemonicPM<name, "+", !add(bibo, 3)>;
3801 defm : BranchExtendedMnemonic<"lt", 12>;
3802 defm : BranchExtendedMnemonic<"gt", 44>;
3803 defm : BranchExtendedMnemonic<"eq", 76>;
3804 defm : BranchExtendedMnemonic<"un", 108>;
3805 defm : BranchExtendedMnemonic<"so", 108>;
3806 defm : BranchExtendedMnemonic<"ge", 4>;
3807 defm : BranchExtendedMnemonic<"nl", 4>;
3808 defm : BranchExtendedMnemonic<"le", 36>;
3809 defm : BranchExtendedMnemonic<"ng", 36>;
3810 defm : BranchExtendedMnemonic<"ne", 68>;
3811 defm : BranchExtendedMnemonic<"nu", 100>;
3812 defm : BranchExtendedMnemonic<"ns", 100>;
3814 def : InstAlias<"cmpwi $rA, $imm", (CMPWI CR0, gprc:$rA, s16imm:$imm)>;
3815 def : InstAlias<"cmpw $rA, $rB", (CMPW CR0, gprc:$rA, gprc:$rB)>;
3816 def : InstAlias<"cmplwi $rA, $imm", (CMPLWI CR0, gprc:$rA, u16imm:$imm)>;
3817 def : InstAlias<"cmplw $rA, $rB", (CMPLW CR0, gprc:$rA, gprc:$rB)>;
3818 def : InstAlias<"cmpdi $rA, $imm", (CMPDI CR0, g8rc:$rA, s16imm64:$imm)>;
3819 def : InstAlias<"cmpd $rA, $rB", (CMPD CR0, g8rc:$rA, g8rc:$rB)>;
3820 def : InstAlias<"cmpldi $rA, $imm", (CMPLDI CR0, g8rc:$rA, u16imm64:$imm)>;
3821 def : InstAlias<"cmpld $rA, $rB", (CMPLD CR0, g8rc:$rA, g8rc:$rB)>;
3823 def : InstAlias<"cmpi $bf, 0, $rA, $imm", (CMPWI crrc:$bf, gprc:$rA, s16imm:$imm)>;
3824 def : InstAlias<"cmp $bf, 0, $rA, $rB", (CMPW crrc:$bf, gprc:$rA, gprc:$rB)>;
3825 def : InstAlias<"cmpli $bf, 0, $rA, $imm", (CMPLWI crrc:$bf, gprc:$rA, u16imm:$imm)>;
3826 def : InstAlias<"cmpl $bf, 0, $rA, $rB", (CMPLW crrc:$bf, gprc:$rA, gprc:$rB)>;
3827 def : InstAlias<"cmpi $bf, 1, $rA, $imm", (CMPDI crrc:$bf, g8rc:$rA, s16imm64:$imm)>;
3828 def : InstAlias<"cmp $bf, 1, $rA, $rB", (CMPD crrc:$bf, g8rc:$rA, g8rc:$rB)>;
3829 def : InstAlias<"cmpli $bf, 1, $rA, $imm", (CMPLDI crrc:$bf, g8rc:$rA, u16imm64:$imm)>;
3830 def : InstAlias<"cmpl $bf, 1, $rA, $rB", (CMPLD crrc:$bf, g8rc:$rA, g8rc:$rB)>;
3832 multiclass TrapExtendedMnemonic<string name, int to> {
3833 def : InstAlias<"td"#name#"i $rA, $imm", (TDI to, g8rc:$rA, s16imm:$imm)>;
3834 def : InstAlias<"td"#name#" $rA, $rB", (TD to, g8rc:$rA, g8rc:$rB)>;
3835 def : InstAlias<"tw"#name#"i $rA, $imm", (TWI to, gprc:$rA, s16imm:$imm)>;
3836 def : InstAlias<"tw"#name#" $rA, $rB", (TW to, gprc:$rA, gprc:$rB)>;
3838 defm : TrapExtendedMnemonic<"lt", 16>;
3839 defm : TrapExtendedMnemonic<"le", 20>;
3840 defm : TrapExtendedMnemonic<"eq", 4>;
3841 defm : TrapExtendedMnemonic<"ge", 12>;
3842 defm : TrapExtendedMnemonic<"gt", 8>;
3843 defm : TrapExtendedMnemonic<"nl", 12>;
3844 defm : TrapExtendedMnemonic<"ne", 24>;
3845 defm : TrapExtendedMnemonic<"ng", 20>;
3846 defm : TrapExtendedMnemonic<"llt", 2>;
3847 defm : TrapExtendedMnemonic<"lle", 6>;
3848 defm : TrapExtendedMnemonic<"lge", 5>;
3849 defm : TrapExtendedMnemonic<"lgt", 1>;
3850 defm : TrapExtendedMnemonic<"lnl", 5>;
3851 defm : TrapExtendedMnemonic<"lng", 6>;
3852 defm : TrapExtendedMnemonic<"u", 31>;
3855 def : Pat<(atomic_load_8 iaddr:$src), (LBZ memri:$src)>;
3856 def : Pat<(atomic_load_16 iaddr:$src), (LHZ memri:$src)>;
3857 def : Pat<(atomic_load_32 iaddr:$src), (LWZ memri:$src)>;
3858 def : Pat<(atomic_load_8 xaddr:$src), (LBZX memrr:$src)>;
3859 def : Pat<(atomic_load_16 xaddr:$src), (LHZX memrr:$src)>;
3860 def : Pat<(atomic_load_32 xaddr:$src), (LWZX memrr:$src)>;
3863 def : Pat<(atomic_store_8 iaddr:$ptr, i32:$val), (STB gprc:$val, memri:$ptr)>;
3864 def : Pat<(atomic_store_16 iaddr:$ptr, i32:$val), (STH gprc:$val, memri:$ptr)>;
3865 def : Pat<(atomic_store_32 iaddr:$ptr, i32:$val), (STW gprc:$val, memri:$ptr)>;
3866 def : Pat<(atomic_store_8 xaddr:$ptr, i32:$val), (STBX gprc:$val, memrr:$ptr)>;
3867 def : Pat<(atomic_store_16 xaddr:$ptr, i32:$val), (STHX gprc:$val, memrr:$ptr)>;
3868 def : Pat<(atomic_store_32 xaddr:$ptr, i32:$val), (STWX gprc:$val, memrr:$ptr)>;