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 //===----------------------------------------------------------------------===//
65 // PowerPC specific DAG Nodes.
68 def PPCfre : SDNode<"PPCISD::FRE", SDTFPUnaryOp, []>;
69 def PPCfrsqrte: SDNode<"PPCISD::FRSQRTE", SDTFPUnaryOp, []>;
71 def PPCfcfid : SDNode<"PPCISD::FCFID", SDTFPUnaryOp, []>;
72 def PPCfcfidu : SDNode<"PPCISD::FCFIDU", SDTFPUnaryOp, []>;
73 def PPCfcfids : SDNode<"PPCISD::FCFIDS", SDTFPRoundOp, []>;
74 def PPCfcfidus: SDNode<"PPCISD::FCFIDUS", SDTFPRoundOp, []>;
75 def PPCfctidz : SDNode<"PPCISD::FCTIDZ", SDTFPUnaryOp, []>;
76 def PPCfctiwz : SDNode<"PPCISD::FCTIWZ", SDTFPUnaryOp, []>;
77 def PPCfctiduz: SDNode<"PPCISD::FCTIDUZ",SDTFPUnaryOp, []>;
78 def PPCfctiwuz: SDNode<"PPCISD::FCTIWUZ",SDTFPUnaryOp, []>;
79 def PPCstfiwx : SDNode<"PPCISD::STFIWX", SDT_PPCstfiwx,
80 [SDNPHasChain, SDNPMayStore]>;
81 def PPClfiwax : SDNode<"PPCISD::LFIWAX", SDT_PPClfiwx,
82 [SDNPHasChain, SDNPMayLoad]>;
83 def PPClfiwzx : SDNode<"PPCISD::LFIWZX", SDT_PPClfiwx,
84 [SDNPHasChain, SDNPMayLoad]>;
86 // Extract FPSCR (not modeled at the DAG level).
87 def PPCmffs : SDNode<"PPCISD::MFFS",
88 SDTypeProfile<1, 0, [SDTCisVT<0, f64>]>, []>;
90 // Perform FADD in round-to-zero mode.
91 def PPCfaddrtz: SDNode<"PPCISD::FADDRTZ", SDTFPBinOp, []>;
94 def PPCfsel : SDNode<"PPCISD::FSEL",
95 // Type constraint for fsel.
96 SDTypeProfile<1, 3, [SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>,
97 SDTCisFP<0>, SDTCisVT<1, f64>]>, []>;
99 def PPChi : SDNode<"PPCISD::Hi", SDTIntBinOp, []>;
100 def PPClo : SDNode<"PPCISD::Lo", SDTIntBinOp, []>;
101 def PPCtoc_entry: SDNode<"PPCISD::TOC_ENTRY", SDTIntBinOp, [SDNPMayLoad]>;
102 def PPCvmaddfp : SDNode<"PPCISD::VMADDFP", SDTFPTernaryOp, []>;
103 def PPCvnmsubfp : SDNode<"PPCISD::VNMSUBFP", SDTFPTernaryOp, []>;
105 def PPCppc32GOT : SDNode<"PPCISD::PPC32_GOT", SDTIntLeaf, []>;
107 def PPCaddisGotTprelHA : SDNode<"PPCISD::ADDIS_GOT_TPREL_HA", SDTIntBinOp>;
108 def PPCldGotTprelL : SDNode<"PPCISD::LD_GOT_TPREL_L", SDTIntBinOp,
110 def PPCaddTls : SDNode<"PPCISD::ADD_TLS", SDTIntBinOp, []>;
111 def PPCaddisTlsgdHA : SDNode<"PPCISD::ADDIS_TLSGD_HA", SDTIntBinOp>;
112 def PPCaddiTlsgdL : SDNode<"PPCISD::ADDI_TLSGD_L", SDTIntBinOp>;
113 def PPCaddisTlsldHA : SDNode<"PPCISD::ADDIS_TLSLD_HA", SDTIntBinOp>;
114 def PPCaddiTlsldL : SDNode<"PPCISD::ADDI_TLSLD_L", SDTIntBinOp>;
115 def PPCaddisDtprelHA : SDNode<"PPCISD::ADDIS_DTPREL_HA", SDTIntBinOp,
117 def PPCaddiDtprelL : SDNode<"PPCISD::ADDI_DTPREL_L", SDTIntBinOp>;
119 def PPCvperm : SDNode<"PPCISD::VPERM", SDT_PPCvperm, []>;
121 def PPCcmpb : SDNode<"PPCISD::CMPB", SDTIntBinOp, []>;
123 // These nodes represent the 32-bit PPC shifts that operate on 6-bit shift
124 // amounts. These nodes are generated by the multi-precision shift code.
125 def PPCsrl : SDNode<"PPCISD::SRL" , SDTIntShiftOp>;
126 def PPCsra : SDNode<"PPCISD::SRA" , SDTIntShiftOp>;
127 def PPCshl : SDNode<"PPCISD::SHL" , SDTIntShiftOp>;
129 // These are target-independent nodes, but have target-specific formats.
130 def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_PPCCallSeqStart,
131 [SDNPHasChain, SDNPOutGlue]>;
132 def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_PPCCallSeqEnd,
133 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
135 def SDT_PPCCall : SDTypeProfile<0, -1, [SDTCisInt<0>]>;
136 def PPCcall : SDNode<"PPCISD::CALL", SDT_PPCCall,
137 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
139 def PPCcall_tls : SDNode<"PPCISD::CALL_TLS", SDT_PPCCall,
140 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
142 def PPCcall_nop : SDNode<"PPCISD::CALL_NOP", SDT_PPCCall,
143 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
145 def PPCcall_nop_tls : SDNode<"PPCISD::CALL_NOP_TLS", SDT_PPCCall,
146 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
148 def PPCmtctr : SDNode<"PPCISD::MTCTR", SDT_PPCCall,
149 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
150 def PPCbctrl : SDNode<"PPCISD::BCTRL", SDTNone,
151 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
153 def PPCbctrl_load_toc : SDNode<"PPCISD::BCTRL_LOAD_TOC",
154 SDTypeProfile<0, 1, []>,
155 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
158 def retflag : SDNode<"PPCISD::RET_FLAG", SDTNone,
159 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
161 def PPCtc_return : SDNode<"PPCISD::TC_RETURN", SDT_PPCTC_ret,
162 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
164 def PPCeh_sjlj_setjmp : SDNode<"PPCISD::EH_SJLJ_SETJMP",
165 SDTypeProfile<1, 1, [SDTCisInt<0>,
167 [SDNPHasChain, SDNPSideEffect]>;
168 def PPCeh_sjlj_longjmp : SDNode<"PPCISD::EH_SJLJ_LONGJMP",
169 SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>,
170 [SDNPHasChain, SDNPSideEffect]>;
172 def SDT_PPCsc : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
173 def PPCsc : SDNode<"PPCISD::SC", SDT_PPCsc,
174 [SDNPHasChain, SDNPSideEffect]>;
176 def PPCvcmp : SDNode<"PPCISD::VCMP" , SDT_PPCvcmp, []>;
177 def PPCvcmp_o : SDNode<"PPCISD::VCMPo", SDT_PPCvcmp, [SDNPOutGlue]>;
179 def PPCcondbranch : SDNode<"PPCISD::COND_BRANCH", SDT_PPCcondbr,
180 [SDNPHasChain, SDNPOptInGlue]>;
182 def PPClbrx : SDNode<"PPCISD::LBRX", SDT_PPClbrx,
183 [SDNPHasChain, SDNPMayLoad]>;
184 def PPCstbrx : SDNode<"PPCISD::STBRX", SDT_PPCstbrx,
185 [SDNPHasChain, SDNPMayStore]>;
187 // Instructions to set/unset CR bit 6 for SVR4 vararg calls
188 def PPCcr6set : SDNode<"PPCISD::CR6SET", SDTNone,
189 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
190 def PPCcr6unset : SDNode<"PPCISD::CR6UNSET", SDTNone,
191 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
193 // Instructions to support atomic operations
194 def PPClarx : SDNode<"PPCISD::LARX", SDT_PPClarx,
195 [SDNPHasChain, SDNPMayLoad]>;
196 def PPCstcx : SDNode<"PPCISD::STCX", SDT_PPCstcx,
197 [SDNPHasChain, SDNPMayStore]>;
199 // Instructions to support medium and large code model
200 def PPCaddisTocHA : SDNode<"PPCISD::ADDIS_TOC_HA", SDTIntBinOp, []>;
201 def PPCldTocL : SDNode<"PPCISD::LD_TOC_L", SDTIntBinOp, [SDNPMayLoad]>;
202 def PPCaddiTocL : SDNode<"PPCISD::ADDI_TOC_L", SDTIntBinOp, []>;
205 // Instructions to support dynamic alloca.
206 def SDTDynOp : SDTypeProfile<1, 2, []>;
207 def PPCdynalloc : SDNode<"PPCISD::DYNALLOC", SDTDynOp, [SDNPHasChain]>;
209 //===----------------------------------------------------------------------===//
210 // PowerPC specific transformation functions and pattern fragments.
213 def SHL32 : SDNodeXForm<imm, [{
214 // Transformation function: 31 - imm
215 return getI32Imm(31 - N->getZExtValue());
218 def SRL32 : SDNodeXForm<imm, [{
219 // Transformation function: 32 - imm
220 return N->getZExtValue() ? getI32Imm(32 - N->getZExtValue()) : getI32Imm(0);
223 def LO16 : SDNodeXForm<imm, [{
224 // Transformation function: get the low 16 bits.
225 return getI32Imm((unsigned short)N->getZExtValue());
228 def HI16 : SDNodeXForm<imm, [{
229 // Transformation function: shift the immediate value down into the low bits.
230 return getI32Imm((unsigned)N->getZExtValue() >> 16);
233 def HA16 : SDNodeXForm<imm, [{
234 // Transformation function: shift the immediate value down into the low bits.
235 signed int Val = N->getZExtValue();
236 return getI32Imm((Val - (signed short)Val) >> 16);
238 def MB : SDNodeXForm<imm, [{
239 // Transformation function: get the start bit of a mask
241 (void)isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
242 return getI32Imm(mb);
245 def ME : SDNodeXForm<imm, [{
246 // Transformation function: get the end bit of a mask
248 (void)isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
249 return getI32Imm(me);
251 def maskimm32 : PatLeaf<(imm), [{
252 // maskImm predicate - True if immediate is a run of ones.
254 if (N->getValueType(0) == MVT::i32)
255 return isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
260 def imm32SExt16 : Operand<i32>, ImmLeaf<i32, [{
261 // imm32SExt16 predicate - True if the i32 immediate fits in a 16-bit
262 // sign extended field. Used by instructions like 'addi'.
263 return (int32_t)Imm == (short)Imm;
265 def imm64SExt16 : Operand<i64>, ImmLeaf<i64, [{
266 // imm64SExt16 predicate - True if the i64 immediate fits in a 16-bit
267 // sign extended field. Used by instructions like 'addi'.
268 return (int64_t)Imm == (short)Imm;
270 def immZExt16 : PatLeaf<(imm), [{
271 // immZExt16 predicate - True if the immediate fits in a 16-bit zero extended
272 // field. Used by instructions like 'ori'.
273 return (uint64_t)N->getZExtValue() == (unsigned short)N->getZExtValue();
276 // imm16Shifted* - These match immediates where the low 16-bits are zero. There
277 // are two forms: imm16ShiftedSExt and imm16ShiftedZExt. These two forms are
278 // identical in 32-bit mode, but in 64-bit mode, they return true if the
279 // immediate fits into a sign/zero extended 32-bit immediate (with the low bits
281 def imm16ShiftedZExt : PatLeaf<(imm), [{
282 // imm16ShiftedZExt predicate - True if only bits in the top 16-bits of the
283 // immediate are set. Used by instructions like 'xoris'.
284 return (N->getZExtValue() & ~uint64_t(0xFFFF0000)) == 0;
287 def imm16ShiftedSExt : PatLeaf<(imm), [{
288 // imm16ShiftedSExt predicate - True if only bits in the top 16-bits of the
289 // immediate are set. Used by instructions like 'addis'. Identical to
290 // imm16ShiftedZExt in 32-bit mode.
291 if (N->getZExtValue() & 0xFFFF) return false;
292 if (N->getValueType(0) == MVT::i32)
294 // For 64-bit, make sure it is sext right.
295 return N->getZExtValue() == (uint64_t)(int)N->getZExtValue();
298 def imm64ZExt32 : Operand<i64>, ImmLeaf<i64, [{
299 // imm64ZExt32 predicate - True if the i64 immediate fits in a 32-bit
300 // zero extended field.
301 return isUInt<32>(Imm);
304 // Some r+i load/store instructions (such as LD, STD, LDU, etc.) that require
305 // restricted memrix (4-aligned) constants are alignment sensitive. If these
306 // offsets are hidden behind TOC entries than the values of the lower-order
307 // bits cannot be checked directly. As a result, we need to also incorporate
308 // an alignment check into the relevant patterns.
310 def aligned4load : PatFrag<(ops node:$ptr), (load node:$ptr), [{
311 return cast<LoadSDNode>(N)->getAlignment() >= 4;
313 def aligned4store : PatFrag<(ops node:$val, node:$ptr),
314 (store node:$val, node:$ptr), [{
315 return cast<StoreSDNode>(N)->getAlignment() >= 4;
317 def aligned4sextloadi32 : PatFrag<(ops node:$ptr), (sextloadi32 node:$ptr), [{
318 return cast<LoadSDNode>(N)->getAlignment() >= 4;
320 def aligned4pre_store : PatFrag<
321 (ops node:$val, node:$base, node:$offset),
322 (pre_store node:$val, node:$base, node:$offset), [{
323 return cast<StoreSDNode>(N)->getAlignment() >= 4;
326 def unaligned4load : PatFrag<(ops node:$ptr), (load node:$ptr), [{
327 return cast<LoadSDNode>(N)->getAlignment() < 4;
329 def unaligned4store : PatFrag<(ops node:$val, node:$ptr),
330 (store node:$val, node:$ptr), [{
331 return cast<StoreSDNode>(N)->getAlignment() < 4;
333 def unaligned4sextloadi32 : PatFrag<(ops node:$ptr), (sextloadi32 node:$ptr), [{
334 return cast<LoadSDNode>(N)->getAlignment() < 4;
337 //===----------------------------------------------------------------------===//
338 // PowerPC Flag Definitions.
340 class isPPC64 { bit PPC64 = 1; }
341 class isDOT { bit RC = 1; }
343 class RegConstraint<string C> {
344 string Constraints = C;
346 class NoEncode<string E> {
347 string DisableEncoding = E;
351 //===----------------------------------------------------------------------===//
352 // PowerPC Operand Definitions.
354 // In the default PowerPC assembler syntax, registers are specified simply
355 // by number, so they cannot be distinguished from immediate values (without
356 // looking at the opcode). This means that the default operand matching logic
357 // for the asm parser does not work, and we need to specify custom matchers.
358 // Since those can only be specified with RegisterOperand classes and not
359 // directly on the RegisterClass, all instructions patterns used by the asm
360 // parser need to use a RegisterOperand (instead of a RegisterClass) for
361 // all their register operands.
362 // For this purpose, we define one RegisterOperand for each RegisterClass,
363 // using the same name as the class, just in lower case.
365 def PPCRegGPRCAsmOperand : AsmOperandClass {
366 let Name = "RegGPRC"; let PredicateMethod = "isRegNumber";
368 def gprc : RegisterOperand<GPRC> {
369 let ParserMatchClass = PPCRegGPRCAsmOperand;
371 def PPCRegG8RCAsmOperand : AsmOperandClass {
372 let Name = "RegG8RC"; let PredicateMethod = "isRegNumber";
374 def g8rc : RegisterOperand<G8RC> {
375 let ParserMatchClass = PPCRegG8RCAsmOperand;
377 def PPCRegGPRCNoR0AsmOperand : AsmOperandClass {
378 let Name = "RegGPRCNoR0"; let PredicateMethod = "isRegNumber";
380 def gprc_nor0 : RegisterOperand<GPRC_NOR0> {
381 let ParserMatchClass = PPCRegGPRCNoR0AsmOperand;
383 def PPCRegG8RCNoX0AsmOperand : AsmOperandClass {
384 let Name = "RegG8RCNoX0"; let PredicateMethod = "isRegNumber";
386 def g8rc_nox0 : RegisterOperand<G8RC_NOX0> {
387 let ParserMatchClass = PPCRegG8RCNoX0AsmOperand;
389 def PPCRegF8RCAsmOperand : AsmOperandClass {
390 let Name = "RegF8RC"; let PredicateMethod = "isRegNumber";
392 def f8rc : RegisterOperand<F8RC> {
393 let ParserMatchClass = PPCRegF8RCAsmOperand;
395 def PPCRegF4RCAsmOperand : AsmOperandClass {
396 let Name = "RegF4RC"; let PredicateMethod = "isRegNumber";
398 def f4rc : RegisterOperand<F4RC> {
399 let ParserMatchClass = PPCRegF4RCAsmOperand;
401 def PPCRegVRRCAsmOperand : AsmOperandClass {
402 let Name = "RegVRRC"; let PredicateMethod = "isRegNumber";
404 def vrrc : RegisterOperand<VRRC> {
405 let ParserMatchClass = PPCRegVRRCAsmOperand;
407 def PPCRegCRBITRCAsmOperand : AsmOperandClass {
408 let Name = "RegCRBITRC"; let PredicateMethod = "isCRBitNumber";
410 def crbitrc : RegisterOperand<CRBITRC> {
411 let ParserMatchClass = PPCRegCRBITRCAsmOperand;
413 def PPCRegCRRCAsmOperand : AsmOperandClass {
414 let Name = "RegCRRC"; let PredicateMethod = "isCCRegNumber";
416 def crrc : RegisterOperand<CRRC> {
417 let ParserMatchClass = PPCRegCRRCAsmOperand;
420 def PPCU2ImmAsmOperand : AsmOperandClass {
421 let Name = "U2Imm"; let PredicateMethod = "isU2Imm";
422 let RenderMethod = "addImmOperands";
424 def u2imm : Operand<i32> {
425 let PrintMethod = "printU2ImmOperand";
426 let ParserMatchClass = PPCU2ImmAsmOperand;
429 def PPCU4ImmAsmOperand : AsmOperandClass {
430 let Name = "U4Imm"; let PredicateMethod = "isU4Imm";
431 let RenderMethod = "addImmOperands";
433 def u4imm : Operand<i32> {
434 let PrintMethod = "printU4ImmOperand";
435 let ParserMatchClass = PPCU4ImmAsmOperand;
437 def PPCS5ImmAsmOperand : AsmOperandClass {
438 let Name = "S5Imm"; let PredicateMethod = "isS5Imm";
439 let RenderMethod = "addImmOperands";
441 def s5imm : Operand<i32> {
442 let PrintMethod = "printS5ImmOperand";
443 let ParserMatchClass = PPCS5ImmAsmOperand;
444 let DecoderMethod = "decodeSImmOperand<5>";
446 def PPCU5ImmAsmOperand : AsmOperandClass {
447 let Name = "U5Imm"; let PredicateMethod = "isU5Imm";
448 let RenderMethod = "addImmOperands";
450 def u5imm : Operand<i32> {
451 let PrintMethod = "printU5ImmOperand";
452 let ParserMatchClass = PPCU5ImmAsmOperand;
453 let DecoderMethod = "decodeUImmOperand<5>";
455 def PPCU6ImmAsmOperand : AsmOperandClass {
456 let Name = "U6Imm"; let PredicateMethod = "isU6Imm";
457 let RenderMethod = "addImmOperands";
459 def u6imm : Operand<i32> {
460 let PrintMethod = "printU6ImmOperand";
461 let ParserMatchClass = PPCU6ImmAsmOperand;
462 let DecoderMethod = "decodeUImmOperand<6>";
464 def PPCS16ImmAsmOperand : AsmOperandClass {
465 let Name = "S16Imm"; let PredicateMethod = "isS16Imm";
466 let RenderMethod = "addS16ImmOperands";
468 def s16imm : Operand<i32> {
469 let PrintMethod = "printS16ImmOperand";
470 let EncoderMethod = "getImm16Encoding";
471 let ParserMatchClass = PPCS16ImmAsmOperand;
472 let DecoderMethod = "decodeSImmOperand<16>";
474 def PPCU16ImmAsmOperand : AsmOperandClass {
475 let Name = "U16Imm"; let PredicateMethod = "isU16Imm";
476 let RenderMethod = "addU16ImmOperands";
478 def u16imm : Operand<i32> {
479 let PrintMethod = "printU16ImmOperand";
480 let EncoderMethod = "getImm16Encoding";
481 let ParserMatchClass = PPCU16ImmAsmOperand;
482 let DecoderMethod = "decodeUImmOperand<16>";
484 def PPCS17ImmAsmOperand : AsmOperandClass {
485 let Name = "S17Imm"; let PredicateMethod = "isS17Imm";
486 let RenderMethod = "addS16ImmOperands";
488 def s17imm : Operand<i32> {
489 // This operand type is used for addis/lis to allow the assembler parser
490 // to accept immediates in the range -65536..65535 for compatibility with
491 // the GNU assembler. The operand is treated as 16-bit otherwise.
492 let PrintMethod = "printS16ImmOperand";
493 let EncoderMethod = "getImm16Encoding";
494 let ParserMatchClass = PPCS17ImmAsmOperand;
495 let DecoderMethod = "decodeSImmOperand<16>";
497 def PPCDirectBrAsmOperand : AsmOperandClass {
498 let Name = "DirectBr"; let PredicateMethod = "isDirectBr";
499 let RenderMethod = "addBranchTargetOperands";
501 def directbrtarget : Operand<OtherVT> {
502 let PrintMethod = "printBranchOperand";
503 let EncoderMethod = "getDirectBrEncoding";
504 let ParserMatchClass = PPCDirectBrAsmOperand;
506 def absdirectbrtarget : Operand<OtherVT> {
507 let PrintMethod = "printAbsBranchOperand";
508 let EncoderMethod = "getAbsDirectBrEncoding";
509 let ParserMatchClass = PPCDirectBrAsmOperand;
511 def PPCCondBrAsmOperand : AsmOperandClass {
512 let Name = "CondBr"; let PredicateMethod = "isCondBr";
513 let RenderMethod = "addBranchTargetOperands";
515 def condbrtarget : Operand<OtherVT> {
516 let PrintMethod = "printBranchOperand";
517 let EncoderMethod = "getCondBrEncoding";
518 let ParserMatchClass = PPCCondBrAsmOperand;
520 def abscondbrtarget : Operand<OtherVT> {
521 let PrintMethod = "printAbsBranchOperand";
522 let EncoderMethod = "getAbsCondBrEncoding";
523 let ParserMatchClass = PPCCondBrAsmOperand;
525 def calltarget : Operand<iPTR> {
526 let PrintMethod = "printBranchOperand";
527 let EncoderMethod = "getDirectBrEncoding";
528 let ParserMatchClass = PPCDirectBrAsmOperand;
530 def abscalltarget : Operand<iPTR> {
531 let PrintMethod = "printAbsBranchOperand";
532 let EncoderMethod = "getAbsDirectBrEncoding";
533 let ParserMatchClass = PPCDirectBrAsmOperand;
535 def PPCCRBitMaskOperand : AsmOperandClass {
536 let Name = "CRBitMask"; let PredicateMethod = "isCRBitMask";
538 def crbitm: Operand<i8> {
539 let PrintMethod = "printcrbitm";
540 let EncoderMethod = "get_crbitm_encoding";
541 let DecoderMethod = "decodeCRBitMOperand";
542 let ParserMatchClass = PPCCRBitMaskOperand;
545 // A version of ptr_rc which excludes R0 (or X0 in 64-bit mode).
546 def PPCRegGxRCNoR0Operand : AsmOperandClass {
547 let Name = "RegGxRCNoR0"; let PredicateMethod = "isRegNumber";
549 def ptr_rc_nor0 : Operand<iPTR>, PointerLikeRegClass<1> {
550 let ParserMatchClass = PPCRegGxRCNoR0Operand;
552 // A version of ptr_rc usable with the asm parser.
553 def PPCRegGxRCOperand : AsmOperandClass {
554 let Name = "RegGxRC"; let PredicateMethod = "isRegNumber";
556 def ptr_rc_idx : Operand<iPTR>, PointerLikeRegClass<0> {
557 let ParserMatchClass = PPCRegGxRCOperand;
560 def PPCDispRIOperand : AsmOperandClass {
561 let Name = "DispRI"; let PredicateMethod = "isS16Imm";
562 let RenderMethod = "addS16ImmOperands";
564 def dispRI : Operand<iPTR> {
565 let ParserMatchClass = PPCDispRIOperand;
567 def PPCDispRIXOperand : AsmOperandClass {
568 let Name = "DispRIX"; let PredicateMethod = "isS16ImmX4";
569 let RenderMethod = "addImmOperands";
571 def dispRIX : Operand<iPTR> {
572 let ParserMatchClass = PPCDispRIXOperand;
574 def PPCDispSPE8Operand : AsmOperandClass {
575 let Name = "DispSPE8"; let PredicateMethod = "isU8ImmX8";
576 let RenderMethod = "addImmOperands";
578 def dispSPE8 : Operand<iPTR> {
579 let ParserMatchClass = PPCDispSPE8Operand;
581 def PPCDispSPE4Operand : AsmOperandClass {
582 let Name = "DispSPE4"; let PredicateMethod = "isU7ImmX4";
583 let RenderMethod = "addImmOperands";
585 def dispSPE4 : Operand<iPTR> {
586 let ParserMatchClass = PPCDispSPE4Operand;
588 def PPCDispSPE2Operand : AsmOperandClass {
589 let Name = "DispSPE2"; let PredicateMethod = "isU6ImmX2";
590 let RenderMethod = "addImmOperands";
592 def dispSPE2 : Operand<iPTR> {
593 let ParserMatchClass = PPCDispSPE2Operand;
596 def memri : Operand<iPTR> {
597 let PrintMethod = "printMemRegImm";
598 let MIOperandInfo = (ops dispRI:$imm, ptr_rc_nor0:$reg);
599 let EncoderMethod = "getMemRIEncoding";
600 let DecoderMethod = "decodeMemRIOperands";
602 def memrr : Operand<iPTR> {
603 let PrintMethod = "printMemRegReg";
604 let MIOperandInfo = (ops ptr_rc_nor0:$ptrreg, ptr_rc_idx:$offreg);
606 def memrix : Operand<iPTR> { // memri where the imm is 4-aligned.
607 let PrintMethod = "printMemRegImm";
608 let MIOperandInfo = (ops dispRIX:$imm, ptr_rc_nor0:$reg);
609 let EncoderMethod = "getMemRIXEncoding";
610 let DecoderMethod = "decodeMemRIXOperands";
612 def spe8dis : Operand<iPTR> { // SPE displacement where the imm is 8-aligned.
613 let PrintMethod = "printMemRegImm";
614 let MIOperandInfo = (ops dispSPE8:$imm, ptr_rc_nor0:$reg);
615 let EncoderMethod = "getSPE8DisEncoding";
617 def spe4dis : Operand<iPTR> { // SPE displacement where the imm is 4-aligned.
618 let PrintMethod = "printMemRegImm";
619 let MIOperandInfo = (ops dispSPE4:$imm, ptr_rc_nor0:$reg);
620 let EncoderMethod = "getSPE4DisEncoding";
622 def spe2dis : Operand<iPTR> { // SPE displacement where the imm is 2-aligned.
623 let PrintMethod = "printMemRegImm";
624 let MIOperandInfo = (ops dispSPE2:$imm, ptr_rc_nor0:$reg);
625 let EncoderMethod = "getSPE2DisEncoding";
628 // A single-register address. This is used with the SjLj
629 // pseudo-instructions.
630 def memr : Operand<iPTR> {
631 let MIOperandInfo = (ops ptr_rc:$ptrreg);
633 def PPCTLSRegOperand : AsmOperandClass {
634 let Name = "TLSReg"; let PredicateMethod = "isTLSReg";
635 let RenderMethod = "addTLSRegOperands";
637 def tlsreg32 : Operand<i32> {
638 let EncoderMethod = "getTLSRegEncoding";
639 let ParserMatchClass = PPCTLSRegOperand;
641 def tlsgd32 : Operand<i32> {}
642 def tlscall32 : Operand<i32> {
643 let PrintMethod = "printTLSCall";
644 let MIOperandInfo = (ops calltarget:$func, tlsgd32:$sym);
645 let EncoderMethod = "getTLSCallEncoding";
648 // PowerPC Predicate operand.
649 def pred : Operand<OtherVT> {
650 let PrintMethod = "printPredicateOperand";
651 let MIOperandInfo = (ops i32imm:$bibo, crrc:$reg);
654 // Define PowerPC specific addressing mode.
655 def iaddr : ComplexPattern<iPTR, 2, "SelectAddrImm", [], []>;
656 def xaddr : ComplexPattern<iPTR, 2, "SelectAddrIdx", [], []>;
657 def xoaddr : ComplexPattern<iPTR, 2, "SelectAddrIdxOnly",[], []>;
658 def ixaddr : ComplexPattern<iPTR, 2, "SelectAddrImmX4", [], []>; // "std"
660 // The address in a single register. This is used with the SjLj
661 // pseudo-instructions.
662 def addr : ComplexPattern<iPTR, 1, "SelectAddr",[], []>;
664 /// This is just the offset part of iaddr, used for preinc.
665 def iaddroff : ComplexPattern<iPTR, 1, "SelectAddrImmOffs", [], []>;
667 //===----------------------------------------------------------------------===//
668 // PowerPC Instruction Predicate Definitions.
669 def In32BitMode : Predicate<"!PPCSubTarget->isPPC64()">;
670 def In64BitMode : Predicate<"PPCSubTarget->isPPC64()">;
671 def IsBookE : Predicate<"PPCSubTarget->isBookE()">;
672 def IsNotBookE : Predicate<"!PPCSubTarget->isBookE()">;
673 def HasOnlyMSYNC : Predicate<"PPCSubTarget->hasOnlyMSYNC()">;
674 def HasSYNC : Predicate<"!PPCSubTarget->hasOnlyMSYNC()">;
675 def IsPPC4xx : Predicate<"PPCSubTarget->isPPC4xx()">;
676 def IsPPC6xx : Predicate<"PPCSubTarget->isPPC6xx()">;
677 def IsE500 : Predicate<"PPCSubTarget->isE500()">;
678 def HasSPE : Predicate<"PPCSubTarget->HasSPE()">;
679 def HasICBT : Predicate<"PPCSubTarget->hasICBT()">;
680 //===----------------------------------------------------------------------===//
681 // PowerPC Multiclass Definitions.
683 multiclass XForm_6r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
684 string asmbase, string asmstr, InstrItinClass itin,
686 let BaseName = asmbase in {
687 def NAME : XForm_6<opcode, xo, OOL, IOL,
688 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
689 pattern>, RecFormRel;
691 def o : XForm_6<opcode, xo, OOL, IOL,
692 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
693 []>, isDOT, RecFormRel;
697 multiclass XForm_6rc<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
698 string asmbase, string asmstr, InstrItinClass itin,
700 let BaseName = asmbase in {
701 let Defs = [CARRY] in
702 def NAME : XForm_6<opcode, xo, OOL, IOL,
703 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
704 pattern>, RecFormRel;
705 let Defs = [CARRY, CR0] in
706 def o : XForm_6<opcode, xo, OOL, IOL,
707 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
708 []>, isDOT, RecFormRel;
712 multiclass XForm_10rc<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
713 string asmbase, string asmstr, InstrItinClass itin,
715 let BaseName = asmbase in {
716 let Defs = [CARRY] in
717 def NAME : XForm_10<opcode, xo, OOL, IOL,
718 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
719 pattern>, RecFormRel;
720 let Defs = [CARRY, CR0] in
721 def o : XForm_10<opcode, xo, OOL, IOL,
722 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
723 []>, isDOT, RecFormRel;
727 multiclass XForm_11r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
728 string asmbase, string asmstr, InstrItinClass itin,
730 let BaseName = asmbase in {
731 def NAME : XForm_11<opcode, xo, OOL, IOL,
732 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
733 pattern>, RecFormRel;
735 def o : XForm_11<opcode, xo, OOL, IOL,
736 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
737 []>, isDOT, RecFormRel;
741 multiclass XOForm_1r<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
742 string asmbase, string asmstr, InstrItinClass itin,
744 let BaseName = asmbase in {
745 def NAME : XOForm_1<opcode, xo, oe, OOL, IOL,
746 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
747 pattern>, RecFormRel;
749 def o : XOForm_1<opcode, xo, oe, OOL, IOL,
750 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
751 []>, isDOT, RecFormRel;
755 multiclass XOForm_1rc<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
756 string asmbase, string asmstr, InstrItinClass itin,
758 let BaseName = asmbase in {
759 let Defs = [CARRY] in
760 def NAME : XOForm_1<opcode, xo, oe, OOL, IOL,
761 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
762 pattern>, RecFormRel;
763 let Defs = [CARRY, CR0] in
764 def o : XOForm_1<opcode, xo, oe, OOL, IOL,
765 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
766 []>, isDOT, RecFormRel;
770 multiclass XOForm_3r<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
771 string asmbase, string asmstr, InstrItinClass itin,
773 let BaseName = asmbase in {
774 def NAME : XOForm_3<opcode, xo, oe, OOL, IOL,
775 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
776 pattern>, RecFormRel;
778 def o : XOForm_3<opcode, xo, oe, OOL, IOL,
779 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
780 []>, isDOT, RecFormRel;
784 multiclass XOForm_3rc<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
785 string asmbase, string asmstr, InstrItinClass itin,
787 let BaseName = asmbase in {
788 let Defs = [CARRY] in
789 def NAME : XOForm_3<opcode, xo, oe, OOL, IOL,
790 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
791 pattern>, RecFormRel;
792 let Defs = [CARRY, CR0] in
793 def o : XOForm_3<opcode, xo, oe, OOL, IOL,
794 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
795 []>, isDOT, RecFormRel;
799 multiclass MForm_2r<bits<6> opcode, dag OOL, dag IOL,
800 string asmbase, string asmstr, InstrItinClass itin,
802 let BaseName = asmbase in {
803 def NAME : MForm_2<opcode, OOL, IOL,
804 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
805 pattern>, RecFormRel;
807 def o : MForm_2<opcode, OOL, IOL,
808 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
809 []>, isDOT, RecFormRel;
813 multiclass MDForm_1r<bits<6> opcode, bits<3> xo, dag OOL, dag IOL,
814 string asmbase, string asmstr, InstrItinClass itin,
816 let BaseName = asmbase in {
817 def NAME : MDForm_1<opcode, xo, OOL, IOL,
818 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
819 pattern>, RecFormRel;
821 def o : MDForm_1<opcode, xo, OOL, IOL,
822 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
823 []>, isDOT, RecFormRel;
827 multiclass MDSForm_1r<bits<6> opcode, bits<4> xo, dag OOL, dag IOL,
828 string asmbase, string asmstr, InstrItinClass itin,
830 let BaseName = asmbase in {
831 def NAME : MDSForm_1<opcode, xo, OOL, IOL,
832 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
833 pattern>, RecFormRel;
835 def o : MDSForm_1<opcode, xo, OOL, IOL,
836 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
837 []>, isDOT, RecFormRel;
841 multiclass XSForm_1rc<bits<6> opcode, bits<9> xo, dag OOL, dag IOL,
842 string asmbase, string asmstr, InstrItinClass itin,
844 let BaseName = asmbase in {
845 let Defs = [CARRY] in
846 def NAME : XSForm_1<opcode, xo, OOL, IOL,
847 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
848 pattern>, RecFormRel;
849 let Defs = [CARRY, CR0] in
850 def o : XSForm_1<opcode, xo, OOL, IOL,
851 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
852 []>, isDOT, RecFormRel;
856 multiclass XForm_26r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
857 string asmbase, string asmstr, InstrItinClass itin,
859 let BaseName = asmbase in {
860 def NAME : XForm_26<opcode, xo, OOL, IOL,
861 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
862 pattern>, RecFormRel;
864 def o : XForm_26<opcode, xo, OOL, IOL,
865 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
866 []>, isDOT, RecFormRel;
870 multiclass XForm_28r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
871 string asmbase, string asmstr, InstrItinClass itin,
873 let BaseName = asmbase in {
874 def NAME : XForm_28<opcode, xo, OOL, IOL,
875 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
876 pattern>, RecFormRel;
878 def o : XForm_28<opcode, xo, OOL, IOL,
879 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
880 []>, isDOT, RecFormRel;
884 multiclass AForm_1r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL,
885 string asmbase, string asmstr, InstrItinClass itin,
887 let BaseName = asmbase in {
888 def NAME : AForm_1<opcode, xo, OOL, IOL,
889 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
890 pattern>, RecFormRel;
892 def o : AForm_1<opcode, xo, OOL, IOL,
893 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
894 []>, isDOT, RecFormRel;
898 multiclass AForm_2r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL,
899 string asmbase, string asmstr, InstrItinClass itin,
901 let BaseName = asmbase in {
902 def NAME : AForm_2<opcode, xo, OOL, IOL,
903 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
904 pattern>, RecFormRel;
906 def o : AForm_2<opcode, xo, OOL, IOL,
907 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
908 []>, isDOT, RecFormRel;
912 multiclass AForm_3r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL,
913 string asmbase, string asmstr, InstrItinClass itin,
915 let BaseName = asmbase in {
916 def NAME : AForm_3<opcode, xo, OOL, IOL,
917 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
918 pattern>, RecFormRel;
920 def o : AForm_3<opcode, xo, OOL, IOL,
921 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
922 []>, isDOT, RecFormRel;
926 //===----------------------------------------------------------------------===//
927 // PowerPC Instruction Definitions.
929 // Pseudo-instructions:
931 let hasCtrlDep = 1 in {
932 let Defs = [R1], Uses = [R1] in {
933 def ADJCALLSTACKDOWN : Pseudo<(outs), (ins u16imm:$amt), "#ADJCALLSTACKDOWN $amt",
934 [(callseq_start timm:$amt)]>;
935 def ADJCALLSTACKUP : Pseudo<(outs), (ins u16imm:$amt1, u16imm:$amt2), "#ADJCALLSTACKUP $amt1 $amt2",
936 [(callseq_end timm:$amt1, timm:$amt2)]>;
939 def UPDATE_VRSAVE : Pseudo<(outs gprc:$rD), (ins gprc:$rS),
940 "UPDATE_VRSAVE $rD, $rS", []>;
943 let Defs = [R1], Uses = [R1] in
944 def DYNALLOC : Pseudo<(outs gprc:$result), (ins gprc:$negsize, memri:$fpsi), "#DYNALLOC",
946 (PPCdynalloc i32:$negsize, iaddr:$fpsi))]>;
948 // SELECT_CC_* - Used to implement the SELECT_CC DAG operation. Expanded after
949 // instruction selection into a branch sequence.
950 let usesCustomInserter = 1, // Expanded after instruction selection.
951 PPC970_Single = 1 in {
952 // Note that SELECT_CC_I4 and SELECT_CC_I8 use the no-r0 register classes
953 // because either operand might become the first operand in an isel, and
954 // that operand cannot be r0.
955 def SELECT_CC_I4 : Pseudo<(outs gprc:$dst), (ins crrc:$cond,
956 gprc_nor0:$T, gprc_nor0:$F,
957 i32imm:$BROPC), "#SELECT_CC_I4",
959 def SELECT_CC_I8 : Pseudo<(outs g8rc:$dst), (ins crrc:$cond,
960 g8rc_nox0:$T, g8rc_nox0:$F,
961 i32imm:$BROPC), "#SELECT_CC_I8",
963 def SELECT_CC_F4 : Pseudo<(outs f4rc:$dst), (ins crrc:$cond, f4rc:$T, f4rc:$F,
964 i32imm:$BROPC), "#SELECT_CC_F4",
966 def SELECT_CC_F8 : Pseudo<(outs f8rc:$dst), (ins crrc:$cond, f8rc:$T, f8rc:$F,
967 i32imm:$BROPC), "#SELECT_CC_F8",
969 def SELECT_CC_VRRC: Pseudo<(outs vrrc:$dst), (ins crrc:$cond, vrrc:$T, vrrc:$F,
970 i32imm:$BROPC), "#SELECT_CC_VRRC",
973 // SELECT_* pseudo instructions, like SELECT_CC_* but taking condition
974 // register bit directly.
975 def SELECT_I4 : Pseudo<(outs gprc:$dst), (ins crbitrc:$cond,
976 gprc_nor0:$T, gprc_nor0:$F), "#SELECT_I4",
977 [(set i32:$dst, (select i1:$cond, i32:$T, i32:$F))]>;
978 def SELECT_I8 : Pseudo<(outs g8rc:$dst), (ins crbitrc:$cond,
979 g8rc_nox0:$T, g8rc_nox0:$F), "#SELECT_I8",
980 [(set i64:$dst, (select i1:$cond, i64:$T, i64:$F))]>;
981 def SELECT_F4 : Pseudo<(outs f4rc:$dst), (ins crbitrc:$cond,
982 f4rc:$T, f4rc:$F), "#SELECT_F4",
983 [(set f32:$dst, (select i1:$cond, f32:$T, f32:$F))]>;
984 def SELECT_F8 : Pseudo<(outs f8rc:$dst), (ins crbitrc:$cond,
985 f8rc:$T, f8rc:$F), "#SELECT_F8",
986 [(set f64:$dst, (select i1:$cond, f64:$T, f64:$F))]>;
987 def SELECT_VRRC: Pseudo<(outs vrrc:$dst), (ins crbitrc:$cond,
988 vrrc:$T, vrrc:$F), "#SELECT_VRRC",
990 (select i1:$cond, v4i32:$T, v4i32:$F))]>;
993 // SPILL_CR - Indicate that we're dumping the CR register, so we'll need to
994 // scavenge a register for it.
995 let mayStore = 1 in {
996 def SPILL_CR : Pseudo<(outs), (ins crrc:$cond, memri:$F),
998 def SPILL_CRBIT : Pseudo<(outs), (ins crbitrc:$cond, memri:$F),
1002 // RESTORE_CR - Indicate that we're restoring the CR register (previously
1003 // spilled), so we'll need to scavenge a register for it.
1004 let mayLoad = 1 in {
1005 def RESTORE_CR : Pseudo<(outs crrc:$cond), (ins memri:$F),
1007 def RESTORE_CRBIT : Pseudo<(outs crbitrc:$cond), (ins memri:$F),
1008 "#RESTORE_CRBIT", []>;
1011 let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7 in {
1012 let isReturn = 1, Uses = [LR, RM] in
1013 def BLR : XLForm_2_ext<19, 16, 20, 0, 0, (outs), (ins), "blr", IIC_BrB,
1014 [(retflag)]>, Requires<[In32BitMode]>;
1015 let isBranch = 1, isIndirectBranch = 1, Uses = [CTR] in {
1016 def BCTR : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
1019 let isCodeGenOnly = 1 in {
1020 def BCCCTR : XLForm_2_br<19, 528, 0, (outs), (ins pred:$cond),
1021 "b${cond:cc}ctr${cond:pm} ${cond:reg}", IIC_BrB,
1024 def BCCTR : XLForm_2_br2<19, 528, 12, 0, (outs), (ins crbitrc:$bi),
1025 "bcctr 12, $bi, 0", IIC_BrB, []>;
1026 def BCCTRn : XLForm_2_br2<19, 528, 4, 0, (outs), (ins crbitrc:$bi),
1027 "bcctr 4, $bi, 0", IIC_BrB, []>;
1033 def MovePCtoLR : Pseudo<(outs), (ins), "#MovePCtoLR", []>,
1036 def MoveGOTtoLR : Pseudo<(outs), (ins), "#MoveGOTtoLR", []>,
1039 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7 in {
1040 let isBarrier = 1 in {
1041 def B : IForm<18, 0, 0, (outs), (ins directbrtarget:$dst),
1044 def BA : IForm<18, 1, 0, (outs), (ins absdirectbrtarget:$dst),
1045 "ba $dst", IIC_BrB, []>;
1048 // BCC represents an arbitrary conditional branch on a predicate.
1049 // FIXME: should be able to write a pattern for PPCcondbranch, but can't use
1050 // a two-value operand where a dag node expects two operands. :(
1051 let isCodeGenOnly = 1 in {
1052 def BCC : BForm<16, 0, 0, (outs), (ins pred:$cond, condbrtarget:$dst),
1053 "b${cond:cc}${cond:pm} ${cond:reg}, $dst"
1054 /*[(PPCcondbranch crrc:$crS, imm:$opc, bb:$dst)]*/>;
1055 def BCCA : BForm<16, 1, 0, (outs), (ins pred:$cond, abscondbrtarget:$dst),
1056 "b${cond:cc}a${cond:pm} ${cond:reg}, $dst">;
1058 let isReturn = 1, Uses = [LR, RM] in
1059 def BCCLR : XLForm_2_br<19, 16, 0, (outs), (ins pred:$cond),
1060 "b${cond:cc}lr${cond:pm} ${cond:reg}", IIC_BrB, []>;
1063 let isCodeGenOnly = 1 in {
1064 let Pattern = [(brcond i1:$bi, bb:$dst)] in
1065 def BC : BForm_4<16, 12, 0, 0, (outs), (ins crbitrc:$bi, condbrtarget:$dst),
1066 "bc 12, $bi, $dst">;
1068 let Pattern = [(brcond (not i1:$bi), bb:$dst)] in
1069 def BCn : BForm_4<16, 4, 0, 0, (outs), (ins crbitrc:$bi, condbrtarget:$dst),
1072 let isReturn = 1, Uses = [LR, RM] in
1073 def BCLR : XLForm_2_br2<19, 16, 12, 0, (outs), (ins crbitrc:$bi),
1074 "bclr 12, $bi, 0", IIC_BrB, []>;
1075 def BCLRn : XLForm_2_br2<19, 16, 4, 0, (outs), (ins crbitrc:$bi),
1076 "bclr 4, $bi, 0", IIC_BrB, []>;
1079 let isReturn = 1, Defs = [CTR], Uses = [CTR, LR, RM] in {
1080 def BDZLR : XLForm_2_ext<19, 16, 18, 0, 0, (outs), (ins),
1081 "bdzlr", IIC_BrB, []>;
1082 def BDNZLR : XLForm_2_ext<19, 16, 16, 0, 0, (outs), (ins),
1083 "bdnzlr", IIC_BrB, []>;
1084 def BDZLRp : XLForm_2_ext<19, 16, 27, 0, 0, (outs), (ins),
1085 "bdzlr+", IIC_BrB, []>;
1086 def BDNZLRp: XLForm_2_ext<19, 16, 25, 0, 0, (outs), (ins),
1087 "bdnzlr+", IIC_BrB, []>;
1088 def BDZLRm : XLForm_2_ext<19, 16, 26, 0, 0, (outs), (ins),
1089 "bdzlr-", IIC_BrB, []>;
1090 def BDNZLRm: XLForm_2_ext<19, 16, 24, 0, 0, (outs), (ins),
1091 "bdnzlr-", IIC_BrB, []>;
1094 let Defs = [CTR], Uses = [CTR] in {
1095 def BDZ : BForm_1<16, 18, 0, 0, (outs), (ins condbrtarget:$dst),
1097 def BDNZ : BForm_1<16, 16, 0, 0, (outs), (ins condbrtarget:$dst),
1099 def BDZA : BForm_1<16, 18, 1, 0, (outs), (ins abscondbrtarget:$dst),
1101 def BDNZA : BForm_1<16, 16, 1, 0, (outs), (ins abscondbrtarget:$dst),
1103 def BDZp : BForm_1<16, 27, 0, 0, (outs), (ins condbrtarget:$dst),
1105 def BDNZp: BForm_1<16, 25, 0, 0, (outs), (ins condbrtarget:$dst),
1107 def BDZAp : BForm_1<16, 27, 1, 0, (outs), (ins abscondbrtarget:$dst),
1109 def BDNZAp: BForm_1<16, 25, 1, 0, (outs), (ins abscondbrtarget:$dst),
1111 def BDZm : BForm_1<16, 26, 0, 0, (outs), (ins condbrtarget:$dst),
1113 def BDNZm: BForm_1<16, 24, 0, 0, (outs), (ins condbrtarget:$dst),
1115 def BDZAm : BForm_1<16, 26, 1, 0, (outs), (ins abscondbrtarget:$dst),
1117 def BDNZAm: BForm_1<16, 24, 1, 0, (outs), (ins abscondbrtarget:$dst),
1122 // The unconditional BCL used by the SjLj setjmp code.
1123 let isCall = 1, hasCtrlDep = 1, isCodeGenOnly = 1, PPC970_Unit = 7 in {
1124 let Defs = [LR], Uses = [RM] in {
1125 def BCLalways : BForm_2<16, 20, 31, 0, 1, (outs), (ins condbrtarget:$dst),
1126 "bcl 20, 31, $dst">;
1130 let isCall = 1, PPC970_Unit = 7, Defs = [LR] in {
1131 // Convenient aliases for call instructions
1132 let Uses = [RM] in {
1133 def BL : IForm<18, 0, 1, (outs), (ins calltarget:$func),
1134 "bl $func", IIC_BrB, []>; // See Pat patterns below.
1135 def BLA : IForm<18, 1, 1, (outs), (ins abscalltarget:$func),
1136 "bla $func", IIC_BrB, [(PPCcall (i32 imm:$func))]>;
1138 let isCodeGenOnly = 1 in {
1139 def BL_TLS : IForm<18, 0, 1, (outs), (ins tlscall32:$func),
1140 "bl $func", IIC_BrB, []>;
1141 def BCCL : BForm<16, 0, 1, (outs), (ins pred:$cond, condbrtarget:$dst),
1142 "b${cond:cc}l${cond:pm} ${cond:reg}, $dst">;
1143 def BCCLA : BForm<16, 1, 1, (outs), (ins pred:$cond, abscondbrtarget:$dst),
1144 "b${cond:cc}la${cond:pm} ${cond:reg}, $dst">;
1146 def BCL : BForm_4<16, 12, 0, 1, (outs),
1147 (ins crbitrc:$bi, condbrtarget:$dst),
1148 "bcl 12, $bi, $dst">;
1149 def BCLn : BForm_4<16, 4, 0, 1, (outs),
1150 (ins crbitrc:$bi, condbrtarget:$dst),
1151 "bcl 4, $bi, $dst">;
1154 let Uses = [CTR, RM] in {
1155 def BCTRL : XLForm_2_ext<19, 528, 20, 0, 1, (outs), (ins),
1156 "bctrl", IIC_BrB, [(PPCbctrl)]>,
1157 Requires<[In32BitMode]>;
1159 let isCodeGenOnly = 1 in {
1160 def BCCCTRL : XLForm_2_br<19, 528, 1, (outs), (ins pred:$cond),
1161 "b${cond:cc}ctrl${cond:pm} ${cond:reg}", IIC_BrB,
1164 def BCCTRL : XLForm_2_br2<19, 528, 12, 1, (outs), (ins crbitrc:$bi),
1165 "bcctrl 12, $bi, 0", IIC_BrB, []>;
1166 def BCCTRLn : XLForm_2_br2<19, 528, 4, 1, (outs), (ins crbitrc:$bi),
1167 "bcctrl 4, $bi, 0", IIC_BrB, []>;
1170 let Uses = [LR, RM] in {
1171 def BLRL : XLForm_2_ext<19, 16, 20, 0, 1, (outs), (ins),
1172 "blrl", IIC_BrB, []>;
1174 let isCodeGenOnly = 1 in {
1175 def BCCLRL : XLForm_2_br<19, 16, 1, (outs), (ins pred:$cond),
1176 "b${cond:cc}lrl${cond:pm} ${cond:reg}", IIC_BrB,
1179 def BCLRL : XLForm_2_br2<19, 16, 12, 1, (outs), (ins crbitrc:$bi),
1180 "bclrl 12, $bi, 0", IIC_BrB, []>;
1181 def BCLRLn : XLForm_2_br2<19, 16, 4, 1, (outs), (ins crbitrc:$bi),
1182 "bclrl 4, $bi, 0", IIC_BrB, []>;
1185 let Defs = [CTR], Uses = [CTR, RM] in {
1186 def BDZL : BForm_1<16, 18, 0, 1, (outs), (ins condbrtarget:$dst),
1188 def BDNZL : BForm_1<16, 16, 0, 1, (outs), (ins condbrtarget:$dst),
1190 def BDZLA : BForm_1<16, 18, 1, 1, (outs), (ins abscondbrtarget:$dst),
1192 def BDNZLA : BForm_1<16, 16, 1, 1, (outs), (ins abscondbrtarget:$dst),
1194 def BDZLp : BForm_1<16, 27, 0, 1, (outs), (ins condbrtarget:$dst),
1196 def BDNZLp: BForm_1<16, 25, 0, 1, (outs), (ins condbrtarget:$dst),
1198 def BDZLAp : BForm_1<16, 27, 1, 1, (outs), (ins abscondbrtarget:$dst),
1200 def BDNZLAp: BForm_1<16, 25, 1, 1, (outs), (ins abscondbrtarget:$dst),
1202 def BDZLm : BForm_1<16, 26, 0, 1, (outs), (ins condbrtarget:$dst),
1204 def BDNZLm: BForm_1<16, 24, 0, 1, (outs), (ins condbrtarget:$dst),
1206 def BDZLAm : BForm_1<16, 26, 1, 1, (outs), (ins abscondbrtarget:$dst),
1208 def BDNZLAm: BForm_1<16, 24, 1, 1, (outs), (ins abscondbrtarget:$dst),
1211 let Defs = [CTR], Uses = [CTR, LR, RM] in {
1212 def BDZLRL : XLForm_2_ext<19, 16, 18, 0, 1, (outs), (ins),
1213 "bdzlrl", IIC_BrB, []>;
1214 def BDNZLRL : XLForm_2_ext<19, 16, 16, 0, 1, (outs), (ins),
1215 "bdnzlrl", IIC_BrB, []>;
1216 def BDZLRLp : XLForm_2_ext<19, 16, 27, 0, 1, (outs), (ins),
1217 "bdzlrl+", IIC_BrB, []>;
1218 def BDNZLRLp: XLForm_2_ext<19, 16, 25, 0, 1, (outs), (ins),
1219 "bdnzlrl+", IIC_BrB, []>;
1220 def BDZLRLm : XLForm_2_ext<19, 16, 26, 0, 1, (outs), (ins),
1221 "bdzlrl-", IIC_BrB, []>;
1222 def BDNZLRLm: XLForm_2_ext<19, 16, 24, 0, 1, (outs), (ins),
1223 "bdnzlrl-", IIC_BrB, []>;
1227 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
1228 def TCRETURNdi :Pseudo< (outs),
1229 (ins calltarget:$dst, i32imm:$offset),
1230 "#TC_RETURNd $dst $offset",
1234 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
1235 def TCRETURNai :Pseudo<(outs), (ins abscalltarget:$func, i32imm:$offset),
1236 "#TC_RETURNa $func $offset",
1237 [(PPCtc_return (i32 imm:$func), imm:$offset)]>;
1239 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
1240 def TCRETURNri : Pseudo<(outs), (ins CTRRC:$dst, i32imm:$offset),
1241 "#TC_RETURNr $dst $offset",
1245 let isCodeGenOnly = 1 in {
1247 let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, isBranch = 1,
1248 isIndirectBranch = 1, isCall = 1, isReturn = 1, Uses = [CTR, RM] in
1249 def TAILBCTR : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
1250 []>, Requires<[In32BitMode]>;
1252 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
1253 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
1254 def TAILB : IForm<18, 0, 0, (outs), (ins calltarget:$dst),
1258 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
1259 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
1260 def TAILBA : IForm<18, 0, 0, (outs), (ins abscalltarget:$dst),
1266 let hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
1268 def EH_SjLj_SetJmp32 : Pseudo<(outs gprc:$dst), (ins memr:$buf),
1269 "#EH_SJLJ_SETJMP32",
1270 [(set i32:$dst, (PPCeh_sjlj_setjmp addr:$buf))]>,
1271 Requires<[In32BitMode]>;
1272 let isTerminator = 1 in
1273 def EH_SjLj_LongJmp32 : Pseudo<(outs), (ins memr:$buf),
1274 "#EH_SJLJ_LONGJMP32",
1275 [(PPCeh_sjlj_longjmp addr:$buf)]>,
1276 Requires<[In32BitMode]>;
1279 let isBranch = 1, isTerminator = 1 in {
1280 def EH_SjLj_Setup : Pseudo<(outs), (ins directbrtarget:$dst),
1281 "#EH_SjLj_Setup\t$dst", []>;
1285 let PPC970_Unit = 7 in {
1286 def SC : SCForm<17, 1, (outs), (ins i32imm:$lev),
1287 "sc $lev", IIC_BrB, [(PPCsc (i32 imm:$lev))]>;
1290 // DCB* instructions.
1291 def DCBA : DCB_Form<758, 0, (outs), (ins memrr:$dst), "dcba $dst",
1292 IIC_LdStDCBF, [(int_ppc_dcba xoaddr:$dst)]>,
1293 PPC970_DGroup_Single;
1294 def DCBF : DCB_Form<86, 0, (outs), (ins memrr:$dst), "dcbf $dst",
1295 IIC_LdStDCBF, [(int_ppc_dcbf xoaddr:$dst)]>,
1296 PPC970_DGroup_Single;
1297 def DCBI : DCB_Form<470, 0, (outs), (ins memrr:$dst), "dcbi $dst",
1298 IIC_LdStDCBF, [(int_ppc_dcbi xoaddr:$dst)]>,
1299 PPC970_DGroup_Single;
1300 def DCBST : DCB_Form<54, 0, (outs), (ins memrr:$dst), "dcbst $dst",
1301 IIC_LdStDCBF, [(int_ppc_dcbst xoaddr:$dst)]>,
1302 PPC970_DGroup_Single;
1303 def DCBT : DCB_Form<278, 0, (outs), (ins memrr:$dst), "dcbt $dst",
1304 IIC_LdStDCBF, [(int_ppc_dcbt xoaddr:$dst)]>,
1305 PPC970_DGroup_Single;
1306 def DCBTST : DCB_Form<246, 0, (outs), (ins memrr:$dst), "dcbtst $dst",
1307 IIC_LdStDCBF, [(int_ppc_dcbtst xoaddr:$dst)]>,
1308 PPC970_DGroup_Single;
1309 def DCBZ : DCB_Form<1014, 0, (outs), (ins memrr:$dst), "dcbz $dst",
1310 IIC_LdStDCBF, [(int_ppc_dcbz xoaddr:$dst)]>,
1311 PPC970_DGroup_Single;
1312 def DCBZL : DCB_Form<1014, 1, (outs), (ins memrr:$dst), "dcbzl $dst",
1313 IIC_LdStDCBF, [(int_ppc_dcbzl xoaddr:$dst)]>,
1314 PPC970_DGroup_Single;
1316 def ICBT : XForm_icbt<31, 22, (outs), (ins u4imm:$CT, memrr:$src),
1317 "icbt $CT, $src", IIC_LdStLoad>, Requires<[HasICBT]>;
1319 def : Pat<(prefetch xoaddr:$dst, (i32 0), imm, (i32 1)),
1320 (DCBT xoaddr:$dst)>; // data prefetch for loads
1321 def : Pat<(prefetch xoaddr:$dst, (i32 1), imm, (i32 1)),
1322 (DCBTST xoaddr:$dst)>; // data prefetch for stores
1323 def : Pat<(prefetch xoaddr:$dst, (i32 0), imm, (i32 0)),
1324 (ICBT 0, xoaddr:$dst)>, Requires<[HasICBT]>; // inst prefetch (for read)
1326 // Atomic operations
1327 let usesCustomInserter = 1 in {
1328 let Defs = [CR0] in {
1329 def ATOMIC_LOAD_ADD_I8 : Pseudo<
1330 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I8",
1331 [(set i32:$dst, (atomic_load_add_8 xoaddr:$ptr, i32:$incr))]>;
1332 def ATOMIC_LOAD_SUB_I8 : Pseudo<
1333 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I8",
1334 [(set i32:$dst, (atomic_load_sub_8 xoaddr:$ptr, i32:$incr))]>;
1335 def ATOMIC_LOAD_AND_I8 : Pseudo<
1336 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I8",
1337 [(set i32:$dst, (atomic_load_and_8 xoaddr:$ptr, i32:$incr))]>;
1338 def ATOMIC_LOAD_OR_I8 : Pseudo<
1339 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I8",
1340 [(set i32:$dst, (atomic_load_or_8 xoaddr:$ptr, i32:$incr))]>;
1341 def ATOMIC_LOAD_XOR_I8 : Pseudo<
1342 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "ATOMIC_LOAD_XOR_I8",
1343 [(set i32:$dst, (atomic_load_xor_8 xoaddr:$ptr, i32:$incr))]>;
1344 def ATOMIC_LOAD_NAND_I8 : Pseudo<
1345 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I8",
1346 [(set i32:$dst, (atomic_load_nand_8 xoaddr:$ptr, i32:$incr))]>;
1347 def ATOMIC_LOAD_ADD_I16 : Pseudo<
1348 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I16",
1349 [(set i32:$dst, (atomic_load_add_16 xoaddr:$ptr, i32:$incr))]>;
1350 def ATOMIC_LOAD_SUB_I16 : Pseudo<
1351 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I16",
1352 [(set i32:$dst, (atomic_load_sub_16 xoaddr:$ptr, i32:$incr))]>;
1353 def ATOMIC_LOAD_AND_I16 : Pseudo<
1354 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I16",
1355 [(set i32:$dst, (atomic_load_and_16 xoaddr:$ptr, i32:$incr))]>;
1356 def ATOMIC_LOAD_OR_I16 : Pseudo<
1357 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I16",
1358 [(set i32:$dst, (atomic_load_or_16 xoaddr:$ptr, i32:$incr))]>;
1359 def ATOMIC_LOAD_XOR_I16 : Pseudo<
1360 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_XOR_I16",
1361 [(set i32:$dst, (atomic_load_xor_16 xoaddr:$ptr, i32:$incr))]>;
1362 def ATOMIC_LOAD_NAND_I16 : Pseudo<
1363 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I16",
1364 [(set i32:$dst, (atomic_load_nand_16 xoaddr:$ptr, i32:$incr))]>;
1365 def ATOMIC_LOAD_ADD_I32 : Pseudo<
1366 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I32",
1367 [(set i32:$dst, (atomic_load_add_32 xoaddr:$ptr, i32:$incr))]>;
1368 def ATOMIC_LOAD_SUB_I32 : Pseudo<
1369 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I32",
1370 [(set i32:$dst, (atomic_load_sub_32 xoaddr:$ptr, i32:$incr))]>;
1371 def ATOMIC_LOAD_AND_I32 : Pseudo<
1372 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I32",
1373 [(set i32:$dst, (atomic_load_and_32 xoaddr:$ptr, i32:$incr))]>;
1374 def ATOMIC_LOAD_OR_I32 : Pseudo<
1375 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I32",
1376 [(set i32:$dst, (atomic_load_or_32 xoaddr:$ptr, i32:$incr))]>;
1377 def ATOMIC_LOAD_XOR_I32 : Pseudo<
1378 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_XOR_I32",
1379 [(set i32:$dst, (atomic_load_xor_32 xoaddr:$ptr, i32:$incr))]>;
1380 def ATOMIC_LOAD_NAND_I32 : Pseudo<
1381 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I32",
1382 [(set i32:$dst, (atomic_load_nand_32 xoaddr:$ptr, i32:$incr))]>;
1384 def ATOMIC_CMP_SWAP_I8 : Pseudo<
1385 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I8",
1386 [(set i32:$dst, (atomic_cmp_swap_8 xoaddr:$ptr, i32:$old, i32:$new))]>;
1387 def ATOMIC_CMP_SWAP_I16 : Pseudo<
1388 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I16 $dst $ptr $old $new",
1389 [(set i32:$dst, (atomic_cmp_swap_16 xoaddr:$ptr, i32:$old, i32:$new))]>;
1390 def ATOMIC_CMP_SWAP_I32 : Pseudo<
1391 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I32 $dst $ptr $old $new",
1392 [(set i32:$dst, (atomic_cmp_swap_32 xoaddr:$ptr, i32:$old, i32:$new))]>;
1394 def ATOMIC_SWAP_I8 : Pseudo<
1395 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_i8",
1396 [(set i32:$dst, (atomic_swap_8 xoaddr:$ptr, i32:$new))]>;
1397 def ATOMIC_SWAP_I16 : Pseudo<
1398 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_I16",
1399 [(set i32:$dst, (atomic_swap_16 xoaddr:$ptr, i32:$new))]>;
1400 def ATOMIC_SWAP_I32 : Pseudo<
1401 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_I32",
1402 [(set i32:$dst, (atomic_swap_32 xoaddr:$ptr, i32:$new))]>;
1406 // Instructions to support atomic operations
1407 def LWARX : XForm_1<31, 20, (outs gprc:$rD), (ins memrr:$src),
1408 "lwarx $rD, $src", IIC_LdStLWARX,
1409 [(set i32:$rD, (PPClarx xoaddr:$src))]>;
1412 def STWCX : XForm_1<31, 150, (outs), (ins gprc:$rS, memrr:$dst),
1413 "stwcx. $rS, $dst", IIC_LdStSTWCX,
1414 [(PPCstcx i32:$rS, xoaddr:$dst)]>,
1417 let isTerminator = 1, isBarrier = 1, hasCtrlDep = 1 in
1418 def TRAP : XForm_24<31, 4, (outs), (ins), "trap", IIC_LdStLoad, [(trap)]>;
1420 def TWI : DForm_base<3, (outs), (ins u5imm:$to, gprc:$rA, s16imm:$imm),
1421 "twi $to, $rA, $imm", IIC_IntTrapW, []>;
1422 def TW : XForm_1<31, 4, (outs), (ins u5imm:$to, gprc:$rA, gprc:$rB),
1423 "tw $to, $rA, $rB", IIC_IntTrapW, []>;
1424 def TDI : DForm_base<2, (outs), (ins u5imm:$to, g8rc:$rA, s16imm:$imm),
1425 "tdi $to, $rA, $imm", IIC_IntTrapD, []>;
1426 def TD : XForm_1<31, 68, (outs), (ins u5imm:$to, g8rc:$rA, g8rc:$rB),
1427 "td $to, $rA, $rB", IIC_IntTrapD, []>;
1429 //===----------------------------------------------------------------------===//
1430 // PPC32 Load Instructions.
1433 // Unindexed (r+i) Loads.
1434 let canFoldAsLoad = 1, PPC970_Unit = 2 in {
1435 def LBZ : DForm_1<34, (outs gprc:$rD), (ins memri:$src),
1436 "lbz $rD, $src", IIC_LdStLoad,
1437 [(set i32:$rD, (zextloadi8 iaddr:$src))]>;
1438 def LHA : DForm_1<42, (outs gprc:$rD), (ins memri:$src),
1439 "lha $rD, $src", IIC_LdStLHA,
1440 [(set i32:$rD, (sextloadi16 iaddr:$src))]>,
1441 PPC970_DGroup_Cracked;
1442 def LHZ : DForm_1<40, (outs gprc:$rD), (ins memri:$src),
1443 "lhz $rD, $src", IIC_LdStLoad,
1444 [(set i32:$rD, (zextloadi16 iaddr:$src))]>;
1445 def LWZ : DForm_1<32, (outs gprc:$rD), (ins memri:$src),
1446 "lwz $rD, $src", IIC_LdStLoad,
1447 [(set i32:$rD, (load iaddr:$src))]>;
1449 def LFS : DForm_1<48, (outs f4rc:$rD), (ins memri:$src),
1450 "lfs $rD, $src", IIC_LdStLFD,
1451 [(set f32:$rD, (load iaddr:$src))]>;
1452 def LFD : DForm_1<50, (outs f8rc:$rD), (ins memri:$src),
1453 "lfd $rD, $src", IIC_LdStLFD,
1454 [(set f64:$rD, (load iaddr:$src))]>;
1457 // Unindexed (r+i) Loads with Update (preinc).
1458 let mayLoad = 1, hasSideEffects = 0 in {
1459 def LBZU : DForm_1<35, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1460 "lbzu $rD, $addr", IIC_LdStLoadUpd,
1461 []>, RegConstraint<"$addr.reg = $ea_result">,
1462 NoEncode<"$ea_result">;
1464 def LHAU : DForm_1<43, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1465 "lhau $rD, $addr", IIC_LdStLHAU,
1466 []>, RegConstraint<"$addr.reg = $ea_result">,
1467 NoEncode<"$ea_result">;
1469 def LHZU : DForm_1<41, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1470 "lhzu $rD, $addr", IIC_LdStLoadUpd,
1471 []>, RegConstraint<"$addr.reg = $ea_result">,
1472 NoEncode<"$ea_result">;
1474 def LWZU : DForm_1<33, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1475 "lwzu $rD, $addr", IIC_LdStLoadUpd,
1476 []>, RegConstraint<"$addr.reg = $ea_result">,
1477 NoEncode<"$ea_result">;
1479 def LFSU : DForm_1<49, (outs f4rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1480 "lfsu $rD, $addr", IIC_LdStLFDU,
1481 []>, RegConstraint<"$addr.reg = $ea_result">,
1482 NoEncode<"$ea_result">;
1484 def LFDU : DForm_1<51, (outs f8rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
1485 "lfdu $rD, $addr", IIC_LdStLFDU,
1486 []>, RegConstraint<"$addr.reg = $ea_result">,
1487 NoEncode<"$ea_result">;
1490 // Indexed (r+r) Loads with Update (preinc).
1491 def LBZUX : XForm_1<31, 119, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1493 "lbzux $rD, $addr", IIC_LdStLoadUpdX,
1494 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1495 NoEncode<"$ea_result">;
1497 def LHAUX : XForm_1<31, 375, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1499 "lhaux $rD, $addr", IIC_LdStLHAUX,
1500 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1501 NoEncode<"$ea_result">;
1503 def LHZUX : XForm_1<31, 311, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1505 "lhzux $rD, $addr", IIC_LdStLoadUpdX,
1506 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1507 NoEncode<"$ea_result">;
1509 def LWZUX : XForm_1<31, 55, (outs gprc:$rD, ptr_rc_nor0:$ea_result),
1511 "lwzux $rD, $addr", IIC_LdStLoadUpdX,
1512 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1513 NoEncode<"$ea_result">;
1515 def LFSUX : XForm_1<31, 567, (outs f4rc:$rD, ptr_rc_nor0:$ea_result),
1517 "lfsux $rD, $addr", IIC_LdStLFDUX,
1518 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1519 NoEncode<"$ea_result">;
1521 def LFDUX : XForm_1<31, 631, (outs f8rc:$rD, ptr_rc_nor0:$ea_result),
1523 "lfdux $rD, $addr", IIC_LdStLFDUX,
1524 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
1525 NoEncode<"$ea_result">;
1529 // Indexed (r+r) Loads.
1531 let canFoldAsLoad = 1, PPC970_Unit = 2 in {
1532 def LBZX : XForm_1<31, 87, (outs gprc:$rD), (ins memrr:$src),
1533 "lbzx $rD, $src", IIC_LdStLoad,
1534 [(set i32:$rD, (zextloadi8 xaddr:$src))]>;
1535 def LHAX : XForm_1<31, 343, (outs gprc:$rD), (ins memrr:$src),
1536 "lhax $rD, $src", IIC_LdStLHA,
1537 [(set i32:$rD, (sextloadi16 xaddr:$src))]>,
1538 PPC970_DGroup_Cracked;
1539 def LHZX : XForm_1<31, 279, (outs gprc:$rD), (ins memrr:$src),
1540 "lhzx $rD, $src", IIC_LdStLoad,
1541 [(set i32:$rD, (zextloadi16 xaddr:$src))]>;
1542 def LWZX : XForm_1<31, 23, (outs gprc:$rD), (ins memrr:$src),
1543 "lwzx $rD, $src", IIC_LdStLoad,
1544 [(set i32:$rD, (load xaddr:$src))]>;
1547 def LHBRX : XForm_1<31, 790, (outs gprc:$rD), (ins memrr:$src),
1548 "lhbrx $rD, $src", IIC_LdStLoad,
1549 [(set i32:$rD, (PPClbrx xoaddr:$src, i16))]>;
1550 def LWBRX : XForm_1<31, 534, (outs gprc:$rD), (ins memrr:$src),
1551 "lwbrx $rD, $src", IIC_LdStLoad,
1552 [(set i32:$rD, (PPClbrx xoaddr:$src, i32))]>;
1554 def LFSX : XForm_25<31, 535, (outs f4rc:$frD), (ins memrr:$src),
1555 "lfsx $frD, $src", IIC_LdStLFD,
1556 [(set f32:$frD, (load xaddr:$src))]>;
1557 def LFDX : XForm_25<31, 599, (outs f8rc:$frD), (ins memrr:$src),
1558 "lfdx $frD, $src", IIC_LdStLFD,
1559 [(set f64:$frD, (load xaddr:$src))]>;
1561 def LFIWAX : XForm_25<31, 855, (outs f8rc:$frD), (ins memrr:$src),
1562 "lfiwax $frD, $src", IIC_LdStLFD,
1563 [(set f64:$frD, (PPClfiwax xoaddr:$src))]>;
1564 def LFIWZX : XForm_25<31, 887, (outs f8rc:$frD), (ins memrr:$src),
1565 "lfiwzx $frD, $src", IIC_LdStLFD,
1566 [(set f64:$frD, (PPClfiwzx xoaddr:$src))]>;
1570 def LMW : DForm_1<46, (outs gprc:$rD), (ins memri:$src),
1571 "lmw $rD, $src", IIC_LdStLMW, []>;
1573 //===----------------------------------------------------------------------===//
1574 // PPC32 Store Instructions.
1577 // Unindexed (r+i) Stores.
1578 let PPC970_Unit = 2 in {
1579 def STB : DForm_1<38, (outs), (ins gprc:$rS, memri:$src),
1580 "stb $rS, $src", IIC_LdStStore,
1581 [(truncstorei8 i32:$rS, iaddr:$src)]>;
1582 def STH : DForm_1<44, (outs), (ins gprc:$rS, memri:$src),
1583 "sth $rS, $src", IIC_LdStStore,
1584 [(truncstorei16 i32:$rS, iaddr:$src)]>;
1585 def STW : DForm_1<36, (outs), (ins gprc:$rS, memri:$src),
1586 "stw $rS, $src", IIC_LdStStore,
1587 [(store i32:$rS, iaddr:$src)]>;
1588 def STFS : DForm_1<52, (outs), (ins f4rc:$rS, memri:$dst),
1589 "stfs $rS, $dst", IIC_LdStSTFD,
1590 [(store f32:$rS, iaddr:$dst)]>;
1591 def STFD : DForm_1<54, (outs), (ins f8rc:$rS, memri:$dst),
1592 "stfd $rS, $dst", IIC_LdStSTFD,
1593 [(store f64:$rS, iaddr:$dst)]>;
1596 // Unindexed (r+i) Stores with Update (preinc).
1597 let PPC970_Unit = 2, mayStore = 1 in {
1598 def STBU : DForm_1<39, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst),
1599 "stbu $rS, $dst", IIC_LdStStoreUpd, []>,
1600 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
1601 def STHU : DForm_1<45, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst),
1602 "sthu $rS, $dst", IIC_LdStStoreUpd, []>,
1603 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
1604 def STWU : DForm_1<37, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst),
1605 "stwu $rS, $dst", IIC_LdStStoreUpd, []>,
1606 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
1607 def STFSU : DForm_1<53, (outs ptr_rc_nor0:$ea_res), (ins f4rc:$rS, memri:$dst),
1608 "stfsu $rS, $dst", IIC_LdStSTFDU, []>,
1609 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
1610 def STFDU : DForm_1<55, (outs ptr_rc_nor0:$ea_res), (ins f8rc:$rS, memri:$dst),
1611 "stfdu $rS, $dst", IIC_LdStSTFDU, []>,
1612 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
1615 // Patterns to match the pre-inc stores. We can't put the patterns on
1616 // the instruction definitions directly as ISel wants the address base
1617 // and offset to be separate operands, not a single complex operand.
1618 def : Pat<(pre_truncsti8 i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1619 (STBU $rS, iaddroff:$ptroff, $ptrreg)>;
1620 def : Pat<(pre_truncsti16 i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1621 (STHU $rS, iaddroff:$ptroff, $ptrreg)>;
1622 def : Pat<(pre_store i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1623 (STWU $rS, iaddroff:$ptroff, $ptrreg)>;
1624 def : Pat<(pre_store f32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1625 (STFSU $rS, iaddroff:$ptroff, $ptrreg)>;
1626 def : Pat<(pre_store f64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1627 (STFDU $rS, iaddroff:$ptroff, $ptrreg)>;
1629 // Indexed (r+r) Stores.
1630 let PPC970_Unit = 2 in {
1631 def STBX : XForm_8<31, 215, (outs), (ins gprc:$rS, memrr:$dst),
1632 "stbx $rS, $dst", IIC_LdStStore,
1633 [(truncstorei8 i32:$rS, xaddr:$dst)]>,
1634 PPC970_DGroup_Cracked;
1635 def STHX : XForm_8<31, 407, (outs), (ins gprc:$rS, memrr:$dst),
1636 "sthx $rS, $dst", IIC_LdStStore,
1637 [(truncstorei16 i32:$rS, xaddr:$dst)]>,
1638 PPC970_DGroup_Cracked;
1639 def STWX : XForm_8<31, 151, (outs), (ins gprc:$rS, memrr:$dst),
1640 "stwx $rS, $dst", IIC_LdStStore,
1641 [(store i32:$rS, xaddr:$dst)]>,
1642 PPC970_DGroup_Cracked;
1644 def STHBRX: XForm_8<31, 918, (outs), (ins gprc:$rS, memrr:$dst),
1645 "sthbrx $rS, $dst", IIC_LdStStore,
1646 [(PPCstbrx i32:$rS, xoaddr:$dst, i16)]>,
1647 PPC970_DGroup_Cracked;
1648 def STWBRX: XForm_8<31, 662, (outs), (ins gprc:$rS, memrr:$dst),
1649 "stwbrx $rS, $dst", IIC_LdStStore,
1650 [(PPCstbrx i32:$rS, xoaddr:$dst, i32)]>,
1651 PPC970_DGroup_Cracked;
1653 def STFIWX: XForm_28<31, 983, (outs), (ins f8rc:$frS, memrr:$dst),
1654 "stfiwx $frS, $dst", IIC_LdStSTFD,
1655 [(PPCstfiwx f64:$frS, xoaddr:$dst)]>;
1657 def STFSX : XForm_28<31, 663, (outs), (ins f4rc:$frS, memrr:$dst),
1658 "stfsx $frS, $dst", IIC_LdStSTFD,
1659 [(store f32:$frS, xaddr:$dst)]>;
1660 def STFDX : XForm_28<31, 727, (outs), (ins f8rc:$frS, memrr:$dst),
1661 "stfdx $frS, $dst", IIC_LdStSTFD,
1662 [(store f64:$frS, xaddr:$dst)]>;
1665 // Indexed (r+r) Stores with Update (preinc).
1666 let PPC970_Unit = 2, mayStore = 1 in {
1667 def STBUX : XForm_8<31, 247, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memrr:$dst),
1668 "stbux $rS, $dst", IIC_LdStStoreUpd, []>,
1669 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
1670 PPC970_DGroup_Cracked;
1671 def STHUX : XForm_8<31, 439, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memrr:$dst),
1672 "sthux $rS, $dst", IIC_LdStStoreUpd, []>,
1673 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
1674 PPC970_DGroup_Cracked;
1675 def STWUX : XForm_8<31, 183, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memrr:$dst),
1676 "stwux $rS, $dst", IIC_LdStStoreUpd, []>,
1677 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
1678 PPC970_DGroup_Cracked;
1679 def STFSUX: XForm_8<31, 695, (outs ptr_rc_nor0:$ea_res), (ins f4rc:$rS, memrr:$dst),
1680 "stfsux $rS, $dst", IIC_LdStSTFDU, []>,
1681 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
1682 PPC970_DGroup_Cracked;
1683 def STFDUX: XForm_8<31, 759, (outs ptr_rc_nor0:$ea_res), (ins f8rc:$rS, memrr:$dst),
1684 "stfdux $rS, $dst", IIC_LdStSTFDU, []>,
1685 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
1686 PPC970_DGroup_Cracked;
1689 // Patterns to match the pre-inc stores. We can't put the patterns on
1690 // the instruction definitions directly as ISel wants the address base
1691 // and offset to be separate operands, not a single complex operand.
1692 def : Pat<(pre_truncsti8 i32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1693 (STBUX $rS, $ptrreg, $ptroff)>;
1694 def : Pat<(pre_truncsti16 i32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1695 (STHUX $rS, $ptrreg, $ptroff)>;
1696 def : Pat<(pre_store i32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1697 (STWUX $rS, $ptrreg, $ptroff)>;
1698 def : Pat<(pre_store f32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1699 (STFSUX $rS, $ptrreg, $ptroff)>;
1700 def : Pat<(pre_store f64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1701 (STFDUX $rS, $ptrreg, $ptroff)>;
1704 def STMW : DForm_1<47, (outs), (ins gprc:$rS, memri:$dst),
1705 "stmw $rS, $dst", IIC_LdStLMW, []>;
1707 def SYNC : XForm_24_sync<31, 598, (outs), (ins i32imm:$L),
1708 "sync $L", IIC_LdStSync, []>;
1710 let isCodeGenOnly = 1 in {
1711 def MSYNC : XForm_24_sync<31, 598, (outs), (ins),
1712 "msync", IIC_LdStSync, []> {
1717 def : Pat<(int_ppc_sync), (SYNC 0)>, Requires<[HasSYNC]>;
1718 def : Pat<(int_ppc_lwsync), (SYNC 1)>, Requires<[HasSYNC]>;
1719 def : Pat<(int_ppc_sync), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
1720 def : Pat<(int_ppc_lwsync), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
1722 //===----------------------------------------------------------------------===//
1723 // PPC32 Arithmetic Instructions.
1726 let PPC970_Unit = 1 in { // FXU Operations.
1727 def ADDI : DForm_2<14, (outs gprc:$rD), (ins gprc_nor0:$rA, s16imm:$imm),
1728 "addi $rD, $rA, $imm", IIC_IntSimple,
1729 [(set i32:$rD, (add i32:$rA, imm32SExt16:$imm))]>;
1730 let BaseName = "addic" in {
1731 let Defs = [CARRY] in
1732 def ADDIC : DForm_2<12, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
1733 "addic $rD, $rA, $imm", IIC_IntGeneral,
1734 [(set i32:$rD, (addc i32:$rA, imm32SExt16:$imm))]>,
1735 RecFormRel, PPC970_DGroup_Cracked;
1736 let Defs = [CARRY, CR0] in
1737 def ADDICo : DForm_2<13, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
1738 "addic. $rD, $rA, $imm", IIC_IntGeneral,
1739 []>, isDOT, RecFormRel;
1741 def ADDIS : DForm_2<15, (outs gprc:$rD), (ins gprc_nor0:$rA, s17imm:$imm),
1742 "addis $rD, $rA, $imm", IIC_IntSimple,
1743 [(set i32:$rD, (add i32:$rA, imm16ShiftedSExt:$imm))]>;
1744 let isCodeGenOnly = 1 in
1745 def LA : DForm_2<14, (outs gprc:$rD), (ins gprc_nor0:$rA, s16imm:$sym),
1746 "la $rD, $sym($rA)", IIC_IntGeneral,
1747 [(set i32:$rD, (add i32:$rA,
1748 (PPClo tglobaladdr:$sym, 0)))]>;
1749 def MULLI : DForm_2< 7, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
1750 "mulli $rD, $rA, $imm", IIC_IntMulLI,
1751 [(set i32:$rD, (mul i32:$rA, imm32SExt16:$imm))]>;
1752 let Defs = [CARRY] in
1753 def SUBFIC : DForm_2< 8, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm),
1754 "subfic $rD, $rA, $imm", IIC_IntGeneral,
1755 [(set i32:$rD, (subc imm32SExt16:$imm, i32:$rA))]>;
1757 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in {
1758 def LI : DForm_2_r0<14, (outs gprc:$rD), (ins s16imm:$imm),
1759 "li $rD, $imm", IIC_IntSimple,
1760 [(set i32:$rD, imm32SExt16:$imm)]>;
1761 def LIS : DForm_2_r0<15, (outs gprc:$rD), (ins s17imm:$imm),
1762 "lis $rD, $imm", IIC_IntSimple,
1763 [(set i32:$rD, imm16ShiftedSExt:$imm)]>;
1767 let PPC970_Unit = 1 in { // FXU Operations.
1768 let Defs = [CR0] in {
1769 def ANDIo : DForm_4<28, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
1770 "andi. $dst, $src1, $src2", IIC_IntGeneral,
1771 [(set i32:$dst, (and i32:$src1, immZExt16:$src2))]>,
1773 def ANDISo : DForm_4<29, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
1774 "andis. $dst, $src1, $src2", IIC_IntGeneral,
1775 [(set i32:$dst, (and i32:$src1, imm16ShiftedZExt:$src2))]>,
1778 def ORI : DForm_4<24, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
1779 "ori $dst, $src1, $src2", IIC_IntSimple,
1780 [(set i32:$dst, (or i32:$src1, immZExt16:$src2))]>;
1781 def ORIS : DForm_4<25, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
1782 "oris $dst, $src1, $src2", IIC_IntSimple,
1783 [(set i32:$dst, (or i32:$src1, imm16ShiftedZExt:$src2))]>;
1784 def XORI : DForm_4<26, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
1785 "xori $dst, $src1, $src2", IIC_IntSimple,
1786 [(set i32:$dst, (xor i32:$src1, immZExt16:$src2))]>;
1787 def XORIS : DForm_4<27, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2),
1788 "xoris $dst, $src1, $src2", IIC_IntSimple,
1789 [(set i32:$dst, (xor i32:$src1, imm16ShiftedZExt:$src2))]>;
1791 def NOP : DForm_4_zero<24, (outs), (ins), "nop", IIC_IntSimple,
1793 let isCodeGenOnly = 1 in {
1794 // The POWER6 and POWER7 have special group-terminating nops.
1795 def NOP_GT_PWR6 : DForm_4_fixedreg_zero<24, 1, (outs), (ins),
1796 "ori 1, 1, 0", IIC_IntSimple, []>;
1797 def NOP_GT_PWR7 : DForm_4_fixedreg_zero<24, 2, (outs), (ins),
1798 "ori 2, 2, 0", IIC_IntSimple, []>;
1801 let isCompare = 1, hasSideEffects = 0 in {
1802 def CMPWI : DForm_5_ext<11, (outs crrc:$crD), (ins gprc:$rA, s16imm:$imm),
1803 "cmpwi $crD, $rA, $imm", IIC_IntCompare>;
1804 def CMPLWI : DForm_6_ext<10, (outs crrc:$dst), (ins gprc:$src1, u16imm:$src2),
1805 "cmplwi $dst, $src1, $src2", IIC_IntCompare>;
1809 let PPC970_Unit = 1, hasSideEffects = 0 in { // FXU Operations.
1810 let isCommutable = 1 in {
1811 defm NAND : XForm_6r<31, 476, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
1812 "nand", "$rA, $rS, $rB", IIC_IntSimple,
1813 [(set i32:$rA, (not (and i32:$rS, i32:$rB)))]>;
1814 defm AND : XForm_6r<31, 28, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
1815 "and", "$rA, $rS, $rB", IIC_IntSimple,
1816 [(set i32:$rA, (and i32:$rS, i32:$rB))]>;
1818 defm ANDC : XForm_6r<31, 60, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
1819 "andc", "$rA, $rS, $rB", IIC_IntSimple,
1820 [(set i32:$rA, (and i32:$rS, (not i32:$rB)))]>;
1821 let isCommutable = 1 in {
1822 defm OR : XForm_6r<31, 444, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
1823 "or", "$rA, $rS, $rB", IIC_IntSimple,
1824 [(set i32:$rA, (or i32:$rS, i32:$rB))]>;
1825 defm NOR : XForm_6r<31, 124, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
1826 "nor", "$rA, $rS, $rB", IIC_IntSimple,
1827 [(set i32:$rA, (not (or i32:$rS, i32:$rB)))]>;
1829 defm ORC : XForm_6r<31, 412, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
1830 "orc", "$rA, $rS, $rB", IIC_IntSimple,
1831 [(set i32:$rA, (or i32:$rS, (not i32:$rB)))]>;
1832 let isCommutable = 1 in {
1833 defm EQV : XForm_6r<31, 284, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
1834 "eqv", "$rA, $rS, $rB", IIC_IntSimple,
1835 [(set i32:$rA, (not (xor i32:$rS, i32:$rB)))]>;
1836 defm XOR : XForm_6r<31, 316, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
1837 "xor", "$rA, $rS, $rB", IIC_IntSimple,
1838 [(set i32:$rA, (xor i32:$rS, i32:$rB))]>;
1840 defm SLW : XForm_6r<31, 24, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
1841 "slw", "$rA, $rS, $rB", IIC_IntGeneral,
1842 [(set i32:$rA, (PPCshl i32:$rS, i32:$rB))]>;
1843 defm SRW : XForm_6r<31, 536, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
1844 "srw", "$rA, $rS, $rB", IIC_IntGeneral,
1845 [(set i32:$rA, (PPCsrl i32:$rS, i32:$rB))]>;
1846 defm SRAW : XForm_6rc<31, 792, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
1847 "sraw", "$rA, $rS, $rB", IIC_IntShift,
1848 [(set i32:$rA, (PPCsra i32:$rS, i32:$rB))]>;
1851 let PPC970_Unit = 1 in { // FXU Operations.
1852 let hasSideEffects = 0 in {
1853 defm SRAWI : XForm_10rc<31, 824, (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH),
1854 "srawi", "$rA, $rS, $SH", IIC_IntShift,
1855 [(set i32:$rA, (sra i32:$rS, (i32 imm:$SH)))]>;
1856 defm CNTLZW : XForm_11r<31, 26, (outs gprc:$rA), (ins gprc:$rS),
1857 "cntlzw", "$rA, $rS", IIC_IntGeneral,
1858 [(set i32:$rA, (ctlz i32:$rS))]>;
1859 defm EXTSB : XForm_11r<31, 954, (outs gprc:$rA), (ins gprc:$rS),
1860 "extsb", "$rA, $rS", IIC_IntSimple,
1861 [(set i32:$rA, (sext_inreg i32:$rS, i8))]>;
1862 defm EXTSH : XForm_11r<31, 922, (outs gprc:$rA), (ins gprc:$rS),
1863 "extsh", "$rA, $rS", IIC_IntSimple,
1864 [(set i32:$rA, (sext_inreg i32:$rS, i16))]>;
1866 let isCommutable = 1 in
1867 def CMPB : XForm_6<31, 508, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB),
1868 "cmpb $rA, $rS, $rB", IIC_IntGeneral,
1869 [(set i32:$rA, (PPCcmpb i32:$rS, i32:$rB))]>;
1871 let isCompare = 1, hasSideEffects = 0 in {
1872 def CMPW : XForm_16_ext<31, 0, (outs crrc:$crD), (ins gprc:$rA, gprc:$rB),
1873 "cmpw $crD, $rA, $rB", IIC_IntCompare>;
1874 def CMPLW : XForm_16_ext<31, 32, (outs crrc:$crD), (ins gprc:$rA, gprc:$rB),
1875 "cmplw $crD, $rA, $rB", IIC_IntCompare>;
1878 let PPC970_Unit = 3 in { // FPU Operations.
1879 //def FCMPO : XForm_17<63, 32, (outs CRRC:$crD), (ins FPRC:$fA, FPRC:$fB),
1880 // "fcmpo $crD, $fA, $fB", IIC_FPCompare>;
1881 let isCompare = 1, hasSideEffects = 0 in {
1882 def FCMPUS : XForm_17<63, 0, (outs crrc:$crD), (ins f4rc:$fA, f4rc:$fB),
1883 "fcmpu $crD, $fA, $fB", IIC_FPCompare>;
1884 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
1885 def FCMPUD : XForm_17<63, 0, (outs crrc:$crD), (ins f8rc:$fA, f8rc:$fB),
1886 "fcmpu $crD, $fA, $fB", IIC_FPCompare>;
1889 let Uses = [RM] in {
1890 let hasSideEffects = 0 in {
1891 defm FCTIW : XForm_26r<63, 14, (outs f8rc:$frD), (ins f8rc:$frB),
1892 "fctiw", "$frD, $frB", IIC_FPGeneral,
1894 defm FCTIWZ : XForm_26r<63, 15, (outs f8rc:$frD), (ins f8rc:$frB),
1895 "fctiwz", "$frD, $frB", IIC_FPGeneral,
1896 [(set f64:$frD, (PPCfctiwz f64:$frB))]>;
1898 defm FRSP : XForm_26r<63, 12, (outs f4rc:$frD), (ins f8rc:$frB),
1899 "frsp", "$frD, $frB", IIC_FPGeneral,
1900 [(set f32:$frD, (fround f64:$frB))]>;
1902 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
1903 defm FRIND : XForm_26r<63, 392, (outs f8rc:$frD), (ins f8rc:$frB),
1904 "frin", "$frD, $frB", IIC_FPGeneral,
1905 [(set f64:$frD, (frnd f64:$frB))]>;
1906 defm FRINS : XForm_26r<63, 392, (outs f4rc:$frD), (ins f4rc:$frB),
1907 "frin", "$frD, $frB", IIC_FPGeneral,
1908 [(set f32:$frD, (frnd f32:$frB))]>;
1911 let hasSideEffects = 0 in {
1912 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
1913 defm FRIPD : XForm_26r<63, 456, (outs f8rc:$frD), (ins f8rc:$frB),
1914 "frip", "$frD, $frB", IIC_FPGeneral,
1915 [(set f64:$frD, (fceil f64:$frB))]>;
1916 defm FRIPS : XForm_26r<63, 456, (outs f4rc:$frD), (ins f4rc:$frB),
1917 "frip", "$frD, $frB", IIC_FPGeneral,
1918 [(set f32:$frD, (fceil f32:$frB))]>;
1919 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
1920 defm FRIZD : XForm_26r<63, 424, (outs f8rc:$frD), (ins f8rc:$frB),
1921 "friz", "$frD, $frB", IIC_FPGeneral,
1922 [(set f64:$frD, (ftrunc f64:$frB))]>;
1923 defm FRIZS : XForm_26r<63, 424, (outs f4rc:$frD), (ins f4rc:$frB),
1924 "friz", "$frD, $frB", IIC_FPGeneral,
1925 [(set f32:$frD, (ftrunc f32:$frB))]>;
1926 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
1927 defm FRIMD : XForm_26r<63, 488, (outs f8rc:$frD), (ins f8rc:$frB),
1928 "frim", "$frD, $frB", IIC_FPGeneral,
1929 [(set f64:$frD, (ffloor f64:$frB))]>;
1930 defm FRIMS : XForm_26r<63, 488, (outs f4rc:$frD), (ins f4rc:$frB),
1931 "frim", "$frD, $frB", IIC_FPGeneral,
1932 [(set f32:$frD, (ffloor f32:$frB))]>;
1934 defm FSQRT : XForm_26r<63, 22, (outs f8rc:$frD), (ins f8rc:$frB),
1935 "fsqrt", "$frD, $frB", IIC_FPSqrtD,
1936 [(set f64:$frD, (fsqrt f64:$frB))]>;
1937 defm FSQRTS : XForm_26r<59, 22, (outs f4rc:$frD), (ins f4rc:$frB),
1938 "fsqrts", "$frD, $frB", IIC_FPSqrtS,
1939 [(set f32:$frD, (fsqrt f32:$frB))]>;
1944 /// Note that FMR is defined as pseudo-ops on the PPC970 because they are
1945 /// often coalesced away and we don't want the dispatch group builder to think
1946 /// that they will fill slots (which could cause the load of a LSU reject to
1947 /// sneak into a d-group with a store).
1948 let hasSideEffects = 0 in
1949 defm FMR : XForm_26r<63, 72, (outs f4rc:$frD), (ins f4rc:$frB),
1950 "fmr", "$frD, $frB", IIC_FPGeneral,
1951 []>, // (set f32:$frD, f32:$frB)
1954 let PPC970_Unit = 3, hasSideEffects = 0 in { // FPU Operations.
1955 // These are artificially split into two different forms, for 4/8 byte FP.
1956 defm FABSS : XForm_26r<63, 264, (outs f4rc:$frD), (ins f4rc:$frB),
1957 "fabs", "$frD, $frB", IIC_FPGeneral,
1958 [(set f32:$frD, (fabs f32:$frB))]>;
1959 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
1960 defm FABSD : XForm_26r<63, 264, (outs f8rc:$frD), (ins f8rc:$frB),
1961 "fabs", "$frD, $frB", IIC_FPGeneral,
1962 [(set f64:$frD, (fabs f64:$frB))]>;
1963 defm FNABSS : XForm_26r<63, 136, (outs f4rc:$frD), (ins f4rc:$frB),
1964 "fnabs", "$frD, $frB", IIC_FPGeneral,
1965 [(set f32:$frD, (fneg (fabs f32:$frB)))]>;
1966 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
1967 defm FNABSD : XForm_26r<63, 136, (outs f8rc:$frD), (ins f8rc:$frB),
1968 "fnabs", "$frD, $frB", IIC_FPGeneral,
1969 [(set f64:$frD, (fneg (fabs f64:$frB)))]>;
1970 defm FNEGS : XForm_26r<63, 40, (outs f4rc:$frD), (ins f4rc:$frB),
1971 "fneg", "$frD, $frB", IIC_FPGeneral,
1972 [(set f32:$frD, (fneg f32:$frB))]>;
1973 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
1974 defm FNEGD : XForm_26r<63, 40, (outs f8rc:$frD), (ins f8rc:$frB),
1975 "fneg", "$frD, $frB", IIC_FPGeneral,
1976 [(set f64:$frD, (fneg f64:$frB))]>;
1978 defm FCPSGNS : XForm_28r<63, 8, (outs f4rc:$frD), (ins f4rc:$frA, f4rc:$frB),
1979 "fcpsgn", "$frD, $frA, $frB", IIC_FPGeneral,
1980 [(set f32:$frD, (fcopysign f32:$frB, f32:$frA))]>;
1981 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
1982 defm FCPSGND : XForm_28r<63, 8, (outs f8rc:$frD), (ins f8rc:$frA, f8rc:$frB),
1983 "fcpsgn", "$frD, $frA, $frB", IIC_FPGeneral,
1984 [(set f64:$frD, (fcopysign f64:$frB, f64:$frA))]>;
1986 // Reciprocal estimates.
1987 defm FRE : XForm_26r<63, 24, (outs f8rc:$frD), (ins f8rc:$frB),
1988 "fre", "$frD, $frB", IIC_FPGeneral,
1989 [(set f64:$frD, (PPCfre f64:$frB))]>;
1990 defm FRES : XForm_26r<59, 24, (outs f4rc:$frD), (ins f4rc:$frB),
1991 "fres", "$frD, $frB", IIC_FPGeneral,
1992 [(set f32:$frD, (PPCfre f32:$frB))]>;
1993 defm FRSQRTE : XForm_26r<63, 26, (outs f8rc:$frD), (ins f8rc:$frB),
1994 "frsqrte", "$frD, $frB", IIC_FPGeneral,
1995 [(set f64:$frD, (PPCfrsqrte f64:$frB))]>;
1996 defm FRSQRTES : XForm_26r<59, 26, (outs f4rc:$frD), (ins f4rc:$frB),
1997 "frsqrtes", "$frD, $frB", IIC_FPGeneral,
1998 [(set f32:$frD, (PPCfrsqrte f32:$frB))]>;
2001 // XL-Form instructions. condition register logical ops.
2003 let hasSideEffects = 0 in
2004 def MCRF : XLForm_3<19, 0, (outs crrc:$BF), (ins crrc:$BFA),
2005 "mcrf $BF, $BFA", IIC_BrMCR>,
2006 PPC970_DGroup_First, PPC970_Unit_CRU;
2008 // FIXME: According to the ISA (section 2.5.1 of version 2.06), the
2009 // condition-register logical instructions have preferred forms. Specifically,
2010 // it is preferred that the bit specified by the BT field be in the same
2011 // condition register as that specified by the bit BB. We might want to account
2012 // for this via hinting the register allocator and anti-dep breakers, or we
2013 // could constrain the register class to force this constraint and then loosen
2014 // it during register allocation via convertToThreeAddress or some similar
2017 let isCommutable = 1 in {
2018 def CRAND : XLForm_1<19, 257, (outs crbitrc:$CRD),
2019 (ins crbitrc:$CRA, crbitrc:$CRB),
2020 "crand $CRD, $CRA, $CRB", IIC_BrCR,
2021 [(set i1:$CRD, (and i1:$CRA, i1:$CRB))]>;
2023 def CRNAND : XLForm_1<19, 225, (outs crbitrc:$CRD),
2024 (ins crbitrc:$CRA, crbitrc:$CRB),
2025 "crnand $CRD, $CRA, $CRB", IIC_BrCR,
2026 [(set i1:$CRD, (not (and i1:$CRA, i1:$CRB)))]>;
2028 def CROR : XLForm_1<19, 449, (outs crbitrc:$CRD),
2029 (ins crbitrc:$CRA, crbitrc:$CRB),
2030 "cror $CRD, $CRA, $CRB", IIC_BrCR,
2031 [(set i1:$CRD, (or i1:$CRA, i1:$CRB))]>;
2033 def CRXOR : XLForm_1<19, 193, (outs crbitrc:$CRD),
2034 (ins crbitrc:$CRA, crbitrc:$CRB),
2035 "crxor $CRD, $CRA, $CRB", IIC_BrCR,
2036 [(set i1:$CRD, (xor i1:$CRA, i1:$CRB))]>;
2038 def CRNOR : XLForm_1<19, 33, (outs crbitrc:$CRD),
2039 (ins crbitrc:$CRA, crbitrc:$CRB),
2040 "crnor $CRD, $CRA, $CRB", IIC_BrCR,
2041 [(set i1:$CRD, (not (or i1:$CRA, i1:$CRB)))]>;
2043 def CREQV : XLForm_1<19, 289, (outs crbitrc:$CRD),
2044 (ins crbitrc:$CRA, crbitrc:$CRB),
2045 "creqv $CRD, $CRA, $CRB", IIC_BrCR,
2046 [(set i1:$CRD, (not (xor i1:$CRA, i1:$CRB)))]>;
2049 def CRANDC : XLForm_1<19, 129, (outs crbitrc:$CRD),
2050 (ins crbitrc:$CRA, crbitrc:$CRB),
2051 "crandc $CRD, $CRA, $CRB", IIC_BrCR,
2052 [(set i1:$CRD, (and i1:$CRA, (not i1:$CRB)))]>;
2054 def CRORC : XLForm_1<19, 417, (outs crbitrc:$CRD),
2055 (ins crbitrc:$CRA, crbitrc:$CRB),
2056 "crorc $CRD, $CRA, $CRB", IIC_BrCR,
2057 [(set i1:$CRD, (or i1:$CRA, (not i1:$CRB)))]>;
2059 let isCodeGenOnly = 1 in {
2060 def CRSET : XLForm_1_ext<19, 289, (outs crbitrc:$dst), (ins),
2061 "creqv $dst, $dst, $dst", IIC_BrCR,
2062 [(set i1:$dst, 1)]>;
2064 def CRUNSET: XLForm_1_ext<19, 193, (outs crbitrc:$dst), (ins),
2065 "crxor $dst, $dst, $dst", IIC_BrCR,
2066 [(set i1:$dst, 0)]>;
2068 let Defs = [CR1EQ], CRD = 6 in {
2069 def CR6SET : XLForm_1_ext<19, 289, (outs), (ins),
2070 "creqv 6, 6, 6", IIC_BrCR,
2073 def CR6UNSET: XLForm_1_ext<19, 193, (outs), (ins),
2074 "crxor 6, 6, 6", IIC_BrCR,
2079 // XFX-Form instructions. Instructions that deal with SPRs.
2082 def MFSPR : XFXForm_1<31, 339, (outs gprc:$RT), (ins i32imm:$SPR),
2083 "mfspr $RT, $SPR", IIC_SprMFSPR>;
2084 def MTSPR : XFXForm_1<31, 467, (outs), (ins i32imm:$SPR, gprc:$RT),
2085 "mtspr $SPR, $RT", IIC_SprMTSPR>;
2087 def MFTB : XFXForm_1<31, 371, (outs gprc:$RT), (ins i32imm:$SPR),
2088 "mftb $RT, $SPR", IIC_SprMFTB>, Deprecated<DeprecatedMFTB>;
2090 // A pseudo-instruction used to implement the read of the 64-bit cycle counter
2091 // on a 32-bit target.
2092 let hasSideEffects = 1, usesCustomInserter = 1 in
2093 def ReadTB : Pseudo<(outs gprc:$lo, gprc:$hi), (ins),
2096 let Uses = [CTR] in {
2097 def MFCTR : XFXForm_1_ext<31, 339, 9, (outs gprc:$rT), (ins),
2098 "mfctr $rT", IIC_SprMFSPR>,
2099 PPC970_DGroup_First, PPC970_Unit_FXU;
2101 let Defs = [CTR], Pattern = [(PPCmtctr i32:$rS)] in {
2102 def MTCTR : XFXForm_7_ext<31, 467, 9, (outs), (ins gprc:$rS),
2103 "mtctr $rS", IIC_SprMTSPR>,
2104 PPC970_DGroup_First, PPC970_Unit_FXU;
2106 let hasSideEffects = 1, isCodeGenOnly = 1, Defs = [CTR] in {
2107 let Pattern = [(int_ppc_mtctr i32:$rS)] in
2108 def MTCTRloop : XFXForm_7_ext<31, 467, 9, (outs), (ins gprc:$rS),
2109 "mtctr $rS", IIC_SprMTSPR>,
2110 PPC970_DGroup_First, PPC970_Unit_FXU;
2113 let Defs = [LR] in {
2114 def MTLR : XFXForm_7_ext<31, 467, 8, (outs), (ins gprc:$rS),
2115 "mtlr $rS", IIC_SprMTSPR>,
2116 PPC970_DGroup_First, PPC970_Unit_FXU;
2118 let Uses = [LR] in {
2119 def MFLR : XFXForm_1_ext<31, 339, 8, (outs gprc:$rT), (ins),
2120 "mflr $rT", IIC_SprMFSPR>,
2121 PPC970_DGroup_First, PPC970_Unit_FXU;
2124 let isCodeGenOnly = 1 in {
2125 // Move to/from VRSAVE: despite being a SPR, the VRSAVE register is renamed
2126 // like a GPR on the PPC970. As such, copies in and out have the same
2127 // performance characteristics as an OR instruction.
2128 def MTVRSAVE : XFXForm_7_ext<31, 467, 256, (outs), (ins gprc:$rS),
2129 "mtspr 256, $rS", IIC_IntGeneral>,
2130 PPC970_DGroup_Single, PPC970_Unit_FXU;
2131 def MFVRSAVE : XFXForm_1_ext<31, 339, 256, (outs gprc:$rT), (ins),
2132 "mfspr $rT, 256", IIC_IntGeneral>,
2133 PPC970_DGroup_First, PPC970_Unit_FXU;
2135 def MTVRSAVEv : XFXForm_7_ext<31, 467, 256,
2136 (outs VRSAVERC:$reg), (ins gprc:$rS),
2137 "mtspr 256, $rS", IIC_IntGeneral>,
2138 PPC970_DGroup_Single, PPC970_Unit_FXU;
2139 def MFVRSAVEv : XFXForm_1_ext<31, 339, 256, (outs gprc:$rT),
2140 (ins VRSAVERC:$reg),
2141 "mfspr $rT, 256", IIC_IntGeneral>,
2142 PPC970_DGroup_First, PPC970_Unit_FXU;
2145 // SPILL_VRSAVE - Indicate that we're dumping the VRSAVE register,
2146 // so we'll need to scavenge a register for it.
2148 def SPILL_VRSAVE : Pseudo<(outs), (ins VRSAVERC:$vrsave, memri:$F),
2149 "#SPILL_VRSAVE", []>;
2151 // RESTORE_VRSAVE - Indicate that we're restoring the VRSAVE register (previously
2152 // spilled), so we'll need to scavenge a register for it.
2154 def RESTORE_VRSAVE : Pseudo<(outs VRSAVERC:$vrsave), (ins memri:$F),
2155 "#RESTORE_VRSAVE", []>;
2157 let hasSideEffects = 0 in {
2158 def MTOCRF: XFXForm_5a<31, 144, (outs crbitm:$FXM), (ins gprc:$ST),
2159 "mtocrf $FXM, $ST", IIC_BrMCRX>,
2160 PPC970_DGroup_First, PPC970_Unit_CRU;
2162 def MTCRF : XFXForm_5<31, 144, (outs), (ins i32imm:$FXM, gprc:$rS),
2163 "mtcrf $FXM, $rS", IIC_BrMCRX>,
2164 PPC970_MicroCode, PPC970_Unit_CRU;
2166 let hasExtraSrcRegAllocReq = 1 in // to enable post-ra anti-dep breaking.
2167 def MFOCRF: XFXForm_5a<31, 19, (outs gprc:$rT), (ins crbitm:$FXM),
2168 "mfocrf $rT, $FXM", IIC_SprMFCRF>,
2169 PPC970_DGroup_First, PPC970_Unit_CRU;
2171 def MFCR : XFXForm_3<31, 19, (outs gprc:$rT), (ins),
2172 "mfcr $rT", IIC_SprMFCR>,
2173 PPC970_MicroCode, PPC970_Unit_CRU;
2174 } // hasSideEffects = 0
2176 // Pseudo instruction to perform FADD in round-to-zero mode.
2177 let usesCustomInserter = 1, Uses = [RM] in {
2178 def FADDrtz: Pseudo<(outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB), "",
2179 [(set f64:$FRT, (PPCfaddrtz f64:$FRA, f64:$FRB))]>;
2182 // The above pseudo gets expanded to make use of the following instructions
2183 // to manipulate FPSCR. Note that FPSCR is not modeled at the DAG level.
2184 let Uses = [RM], Defs = [RM] in {
2185 def MTFSB0 : XForm_43<63, 70, (outs), (ins u5imm:$FM),
2186 "mtfsb0 $FM", IIC_IntMTFSB0, []>,
2187 PPC970_DGroup_Single, PPC970_Unit_FPU;
2188 def MTFSB1 : XForm_43<63, 38, (outs), (ins u5imm:$FM),
2189 "mtfsb1 $FM", IIC_IntMTFSB0, []>,
2190 PPC970_DGroup_Single, PPC970_Unit_FPU;
2191 let isCodeGenOnly = 1 in
2192 def MTFSFb : XFLForm<63, 711, (outs), (ins i32imm:$FM, f8rc:$rT),
2193 "mtfsf $FM, $rT", IIC_IntMTFSB0, []>,
2194 PPC970_DGroup_Single, PPC970_Unit_FPU;
2196 let Uses = [RM] in {
2197 def MFFS : XForm_42<63, 583, (outs f8rc:$rT), (ins),
2198 "mffs $rT", IIC_IntMFFS,
2199 [(set f64:$rT, (PPCmffs))]>,
2200 PPC970_DGroup_Single, PPC970_Unit_FPU;
2203 def MFFSo : XForm_42<63, 583, (outs f8rc:$rT), (ins),
2204 "mffs. $rT", IIC_IntMFFS, []>, isDOT;
2208 let PPC970_Unit = 1, hasSideEffects = 0 in { // FXU Operations.
2209 // XO-Form instructions. Arithmetic instructions that can set overflow bit
2210 let isCommutable = 1 in
2211 defm ADD4 : XOForm_1r<31, 266, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2212 "add", "$rT, $rA, $rB", IIC_IntSimple,
2213 [(set i32:$rT, (add i32:$rA, i32:$rB))]>;
2214 let isCodeGenOnly = 1 in
2215 def ADD4TLS : XOForm_1<31, 266, 0, (outs gprc:$rT), (ins gprc:$rA, tlsreg32:$rB),
2216 "add $rT, $rA, $rB", IIC_IntSimple,
2217 [(set i32:$rT, (add i32:$rA, tglobaltlsaddr:$rB))]>;
2218 let isCommutable = 1 in
2219 defm ADDC : XOForm_1rc<31, 10, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2220 "addc", "$rT, $rA, $rB", IIC_IntGeneral,
2221 [(set i32:$rT, (addc i32:$rA, i32:$rB))]>,
2222 PPC970_DGroup_Cracked;
2224 defm DIVW : XOForm_1r<31, 491, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2225 "divw", "$rT, $rA, $rB", IIC_IntDivW,
2226 [(set i32:$rT, (sdiv i32:$rA, i32:$rB))]>,
2227 PPC970_DGroup_First, PPC970_DGroup_Cracked;
2228 defm DIVWU : XOForm_1r<31, 459, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2229 "divwu", "$rT, $rA, $rB", IIC_IntDivW,
2230 [(set i32:$rT, (udiv i32:$rA, i32:$rB))]>,
2231 PPC970_DGroup_First, PPC970_DGroup_Cracked;
2232 let isCommutable = 1 in {
2233 defm MULHW : XOForm_1r<31, 75, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2234 "mulhw", "$rT, $rA, $rB", IIC_IntMulHW,
2235 [(set i32:$rT, (mulhs i32:$rA, i32:$rB))]>;
2236 defm MULHWU : XOForm_1r<31, 11, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2237 "mulhwu", "$rT, $rA, $rB", IIC_IntMulHWU,
2238 [(set i32:$rT, (mulhu i32:$rA, i32:$rB))]>;
2239 defm MULLW : XOForm_1r<31, 235, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2240 "mullw", "$rT, $rA, $rB", IIC_IntMulHW,
2241 [(set i32:$rT, (mul i32:$rA, i32:$rB))]>;
2243 defm SUBF : XOForm_1r<31, 40, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2244 "subf", "$rT, $rA, $rB", IIC_IntGeneral,
2245 [(set i32:$rT, (sub i32:$rB, i32:$rA))]>;
2246 defm SUBFC : XOForm_1rc<31, 8, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2247 "subfc", "$rT, $rA, $rB", IIC_IntGeneral,
2248 [(set i32:$rT, (subc i32:$rB, i32:$rA))]>,
2249 PPC970_DGroup_Cracked;
2250 defm NEG : XOForm_3r<31, 104, 0, (outs gprc:$rT), (ins gprc:$rA),
2251 "neg", "$rT, $rA", IIC_IntSimple,
2252 [(set i32:$rT, (ineg i32:$rA))]>;
2253 let Uses = [CARRY] in {
2254 let isCommutable = 1 in
2255 defm ADDE : XOForm_1rc<31, 138, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2256 "adde", "$rT, $rA, $rB", IIC_IntGeneral,
2257 [(set i32:$rT, (adde i32:$rA, i32:$rB))]>;
2258 defm ADDME : XOForm_3rc<31, 234, 0, (outs gprc:$rT), (ins gprc:$rA),
2259 "addme", "$rT, $rA", IIC_IntGeneral,
2260 [(set i32:$rT, (adde i32:$rA, -1))]>;
2261 defm ADDZE : XOForm_3rc<31, 202, 0, (outs gprc:$rT), (ins gprc:$rA),
2262 "addze", "$rT, $rA", IIC_IntGeneral,
2263 [(set i32:$rT, (adde i32:$rA, 0))]>;
2264 defm SUBFE : XOForm_1rc<31, 136, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB),
2265 "subfe", "$rT, $rA, $rB", IIC_IntGeneral,
2266 [(set i32:$rT, (sube i32:$rB, i32:$rA))]>;
2267 defm SUBFME : XOForm_3rc<31, 232, 0, (outs gprc:$rT), (ins gprc:$rA),
2268 "subfme", "$rT, $rA", IIC_IntGeneral,
2269 [(set i32:$rT, (sube -1, i32:$rA))]>;
2270 defm SUBFZE : XOForm_3rc<31, 200, 0, (outs gprc:$rT), (ins gprc:$rA),
2271 "subfze", "$rT, $rA", IIC_IntGeneral,
2272 [(set i32:$rT, (sube 0, i32:$rA))]>;
2276 // A-Form instructions. Most of the instructions executed in the FPU are of
2279 let PPC970_Unit = 3, hasSideEffects = 0 in { // FPU Operations.
2280 let Uses = [RM] in {
2281 let isCommutable = 1 in {
2282 defm FMADD : AForm_1r<63, 29,
2283 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2284 "fmadd", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2285 [(set f64:$FRT, (fma f64:$FRA, f64:$FRC, f64:$FRB))]>;
2286 defm FMADDS : AForm_1r<59, 29,
2287 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2288 "fmadds", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2289 [(set f32:$FRT, (fma f32:$FRA, f32:$FRC, f32:$FRB))]>;
2290 defm FMSUB : AForm_1r<63, 28,
2291 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2292 "fmsub", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2294 (fma f64:$FRA, f64:$FRC, (fneg f64:$FRB)))]>;
2295 defm FMSUBS : AForm_1r<59, 28,
2296 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2297 "fmsubs", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2299 (fma f32:$FRA, f32:$FRC, (fneg f32:$FRB)))]>;
2300 defm FNMADD : AForm_1r<63, 31,
2301 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2302 "fnmadd", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2304 (fneg (fma f64:$FRA, f64:$FRC, f64:$FRB)))]>;
2305 defm FNMADDS : AForm_1r<59, 31,
2306 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2307 "fnmadds", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2309 (fneg (fma f32:$FRA, f32:$FRC, f32:$FRB)))]>;
2310 defm FNMSUB : AForm_1r<63, 30,
2311 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2312 "fnmsub", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2313 [(set f64:$FRT, (fneg (fma f64:$FRA, f64:$FRC,
2314 (fneg f64:$FRB))))]>;
2315 defm FNMSUBS : AForm_1r<59, 30,
2316 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2317 "fnmsubs", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2318 [(set f32:$FRT, (fneg (fma f32:$FRA, f32:$FRC,
2319 (fneg f32:$FRB))))]>;
2322 // FSEL is artificially split into 4 and 8-byte forms for the result. To avoid
2323 // having 4 of these, force the comparison to always be an 8-byte double (code
2324 // should use an FMRSD if the input comparison value really wants to be a float)
2325 // and 4/8 byte forms for the result and operand type..
2326 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2327 defm FSELD : AForm_1r<63, 23,
2328 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2329 "fsel", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2330 [(set f64:$FRT, (PPCfsel f64:$FRA, f64:$FRC, f64:$FRB))]>;
2331 defm FSELS : AForm_1r<63, 23,
2332 (outs f4rc:$FRT), (ins f8rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2333 "fsel", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2334 [(set f32:$FRT, (PPCfsel f64:$FRA, f32:$FRC, f32:$FRB))]>;
2335 let Uses = [RM] in {
2336 let isCommutable = 1 in {
2337 defm FADD : AForm_2r<63, 21,
2338 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB),
2339 "fadd", "$FRT, $FRA, $FRB", IIC_FPAddSub,
2340 [(set f64:$FRT, (fadd f64:$FRA, f64:$FRB))]>;
2341 defm FADDS : AForm_2r<59, 21,
2342 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB),
2343 "fadds", "$FRT, $FRA, $FRB", IIC_FPGeneral,
2344 [(set f32:$FRT, (fadd f32:$FRA, f32:$FRB))]>;
2346 defm FDIV : AForm_2r<63, 18,
2347 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB),
2348 "fdiv", "$FRT, $FRA, $FRB", IIC_FPDivD,
2349 [(set f64:$FRT, (fdiv f64:$FRA, f64:$FRB))]>;
2350 defm FDIVS : AForm_2r<59, 18,
2351 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB),
2352 "fdivs", "$FRT, $FRA, $FRB", IIC_FPDivS,
2353 [(set f32:$FRT, (fdiv f32:$FRA, f32:$FRB))]>;
2354 let isCommutable = 1 in {
2355 defm FMUL : AForm_3r<63, 25,
2356 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC),
2357 "fmul", "$FRT, $FRA, $FRC", IIC_FPFused,
2358 [(set f64:$FRT, (fmul f64:$FRA, f64:$FRC))]>;
2359 defm FMULS : AForm_3r<59, 25,
2360 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC),
2361 "fmuls", "$FRT, $FRA, $FRC", IIC_FPGeneral,
2362 [(set f32:$FRT, (fmul f32:$FRA, f32:$FRC))]>;
2364 defm FSUB : AForm_2r<63, 20,
2365 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB),
2366 "fsub", "$FRT, $FRA, $FRB", IIC_FPAddSub,
2367 [(set f64:$FRT, (fsub f64:$FRA, f64:$FRB))]>;
2368 defm FSUBS : AForm_2r<59, 20,
2369 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB),
2370 "fsubs", "$FRT, $FRA, $FRB", IIC_FPGeneral,
2371 [(set f32:$FRT, (fsub f32:$FRA, f32:$FRB))]>;
2375 let hasSideEffects = 0 in {
2376 let PPC970_Unit = 1 in { // FXU Operations.
2378 def ISEL : AForm_4<31, 15,
2379 (outs gprc:$rT), (ins gprc_nor0:$rA, gprc:$rB, crbitrc:$cond),
2380 "isel $rT, $rA, $rB, $cond", IIC_IntISEL,
2384 let PPC970_Unit = 1 in { // FXU Operations.
2385 // M-Form instructions. rotate and mask instructions.
2387 let isCommutable = 1 in {
2388 // RLWIMI can be commuted if the rotate amount is zero.
2389 defm RLWIMI : MForm_2r<20, (outs gprc:$rA),
2390 (ins gprc:$rSi, gprc:$rS, u5imm:$SH, u5imm:$MB,
2391 u5imm:$ME), "rlwimi", "$rA, $rS, $SH, $MB, $ME",
2392 IIC_IntRotate, []>, PPC970_DGroup_Cracked,
2393 RegConstraint<"$rSi = $rA">, NoEncode<"$rSi">;
2395 let BaseName = "rlwinm" in {
2396 def RLWINM : MForm_2<21,
2397 (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
2398 "rlwinm $rA, $rS, $SH, $MB, $ME", IIC_IntGeneral,
2401 def RLWINMo : MForm_2<21,
2402 (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
2403 "rlwinm. $rA, $rS, $SH, $MB, $ME", IIC_IntGeneral,
2404 []>, isDOT, RecFormRel, PPC970_DGroup_Cracked;
2406 defm RLWNM : MForm_2r<23, (outs gprc:$rA),
2407 (ins gprc:$rS, gprc:$rB, u5imm:$MB, u5imm:$ME),
2408 "rlwnm", "$rA, $rS, $rB, $MB, $ME", IIC_IntGeneral,
2411 } // hasSideEffects = 0
2413 //===----------------------------------------------------------------------===//
2414 // PowerPC Instruction Patterns
2417 // Arbitrary immediate support. Implement in terms of LIS/ORI.
2418 def : Pat<(i32 imm:$imm),
2419 (ORI (LIS (HI16 imm:$imm)), (LO16 imm:$imm))>;
2421 // Implement the 'not' operation with the NOR instruction.
2422 def i32not : OutPatFrag<(ops node:$in),
2424 def : Pat<(not i32:$in),
2427 // ADD an arbitrary immediate.
2428 def : Pat<(add i32:$in, imm:$imm),
2429 (ADDIS (ADDI $in, (LO16 imm:$imm)), (HA16 imm:$imm))>;
2430 // OR an arbitrary immediate.
2431 def : Pat<(or i32:$in, imm:$imm),
2432 (ORIS (ORI $in, (LO16 imm:$imm)), (HI16 imm:$imm))>;
2433 // XOR an arbitrary immediate.
2434 def : Pat<(xor i32:$in, imm:$imm),
2435 (XORIS (XORI $in, (LO16 imm:$imm)), (HI16 imm:$imm))>;
2437 def : Pat<(sub imm32SExt16:$imm, i32:$in),
2438 (SUBFIC $in, imm:$imm)>;
2441 def : Pat<(shl i32:$in, (i32 imm:$imm)),
2442 (RLWINM $in, imm:$imm, 0, (SHL32 imm:$imm))>;
2443 def : Pat<(srl i32:$in, (i32 imm:$imm)),
2444 (RLWINM $in, (SRL32 imm:$imm), imm:$imm, 31)>;
2447 def : Pat<(rotl i32:$in, i32:$sh),
2448 (RLWNM $in, $sh, 0, 31)>;
2449 def : Pat<(rotl i32:$in, (i32 imm:$imm)),
2450 (RLWINM $in, imm:$imm, 0, 31)>;
2453 def : Pat<(and (rotl i32:$in, i32:$sh), maskimm32:$imm),
2454 (RLWNM $in, $sh, (MB maskimm32:$imm), (ME maskimm32:$imm))>;
2457 def : Pat<(PPCcall (i32 tglobaladdr:$dst)),
2458 (BL tglobaladdr:$dst)>;
2459 def : Pat<(PPCcall (i32 texternalsym:$dst)),
2460 (BL texternalsym:$dst)>;
2462 def : Pat<(PPCcall_tls texternalsym:$func, tglobaltlsaddr:$sym),
2463 (BL_TLS texternalsym:$func, tglobaltlsaddr:$sym)>;
2465 def : Pat<(PPCtc_return (i32 tglobaladdr:$dst), imm:$imm),
2466 (TCRETURNdi tglobaladdr:$dst, imm:$imm)>;
2468 def : Pat<(PPCtc_return (i32 texternalsym:$dst), imm:$imm),
2469 (TCRETURNdi texternalsym:$dst, imm:$imm)>;
2471 def : Pat<(PPCtc_return CTRRC:$dst, imm:$imm),
2472 (TCRETURNri CTRRC:$dst, imm:$imm)>;
2476 // Hi and Lo for Darwin Global Addresses.
2477 def : Pat<(PPChi tglobaladdr:$in, 0), (LIS tglobaladdr:$in)>;
2478 def : Pat<(PPClo tglobaladdr:$in, 0), (LI tglobaladdr:$in)>;
2479 def : Pat<(PPChi tconstpool:$in, 0), (LIS tconstpool:$in)>;
2480 def : Pat<(PPClo tconstpool:$in, 0), (LI tconstpool:$in)>;
2481 def : Pat<(PPChi tjumptable:$in, 0), (LIS tjumptable:$in)>;
2482 def : Pat<(PPClo tjumptable:$in, 0), (LI tjumptable:$in)>;
2483 def : Pat<(PPChi tblockaddress:$in, 0), (LIS tblockaddress:$in)>;
2484 def : Pat<(PPClo tblockaddress:$in, 0), (LI tblockaddress:$in)>;
2485 def : Pat<(PPChi tglobaltlsaddr:$g, i32:$in),
2486 (ADDIS $in, tglobaltlsaddr:$g)>;
2487 def : Pat<(PPClo tglobaltlsaddr:$g, i32:$in),
2488 (ADDI $in, tglobaltlsaddr:$g)>;
2489 def : Pat<(add i32:$in, (PPChi tglobaladdr:$g, 0)),
2490 (ADDIS $in, tglobaladdr:$g)>;
2491 def : Pat<(add i32:$in, (PPChi tconstpool:$g, 0)),
2492 (ADDIS $in, tconstpool:$g)>;
2493 def : Pat<(add i32:$in, (PPChi tjumptable:$g, 0)),
2494 (ADDIS $in, tjumptable:$g)>;
2495 def : Pat<(add i32:$in, (PPChi tblockaddress:$g, 0)),
2496 (ADDIS $in, tblockaddress:$g)>;
2498 // Support for thread-local storage.
2499 def PPC32GOT: Pseudo<(outs gprc:$rD), (ins), "#PPC32GOT",
2500 [(set i32:$rD, (PPCppc32GOT))]>;
2502 // Get the _GLOBAL_OFFSET_TABLE_ in PIC mode.
2503 // This uses two output registers, the first as the real output, the second as a
2504 // temporary register, used internally in code generation.
2505 def PPC32PICGOT: Pseudo<(outs gprc:$rD, gprc:$rT), (ins), "#PPC32PICGOT",
2506 []>, NoEncode<"$rT">;
2508 def LDgotTprelL32: Pseudo<(outs gprc:$rD), (ins s16imm:$disp, gprc_nor0:$reg),
2511 (PPCldGotTprelL tglobaltlsaddr:$disp, i32:$reg))]>;
2512 def : Pat<(PPCaddTls i32:$in, tglobaltlsaddr:$g),
2513 (ADD4TLS $in, tglobaltlsaddr:$g)>;
2515 def ADDItlsgdL32 : Pseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
2518 (PPCaddiTlsgdL i32:$reg, tglobaltlsaddr:$disp))]>;
2519 def ADDItlsldL32 : Pseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
2522 (PPCaddiTlsldL i32:$reg, tglobaltlsaddr:$disp))]>;
2523 def ADDIdtprelL32 : Pseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
2526 (PPCaddiDtprelL i32:$reg, tglobaltlsaddr:$disp))]>;
2527 def ADDISdtprelHA32 : Pseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
2530 (PPCaddisDtprelHA i32:$reg,
2531 tglobaltlsaddr:$disp))]>;
2533 // Support for Position-independent code
2534 def LWZtoc : Pseudo<(outs gprc:$rD), (ins tocentry32:$disp, gprc:$reg),
2537 (PPCtoc_entry tglobaladdr:$disp, i32:$reg))]>;
2538 // Get Global (GOT) Base Register offset, from the word immediately preceding
2539 // the function label.
2540 def UpdateGBR : Pseudo<(outs gprc:$rD, gprc:$rT), (ins gprc:$rI), "#UpdateGBR", []>;
2543 // Standard shifts. These are represented separately from the real shifts above
2544 // so that we can distinguish between shifts that allow 5-bit and 6-bit shift
2546 def : Pat<(sra i32:$rS, i32:$rB),
2548 def : Pat<(srl i32:$rS, i32:$rB),
2550 def : Pat<(shl i32:$rS, i32:$rB),
2553 def : Pat<(zextloadi1 iaddr:$src),
2555 def : Pat<(zextloadi1 xaddr:$src),
2557 def : Pat<(extloadi1 iaddr:$src),
2559 def : Pat<(extloadi1 xaddr:$src),
2561 def : Pat<(extloadi8 iaddr:$src),
2563 def : Pat<(extloadi8 xaddr:$src),
2565 def : Pat<(extloadi16 iaddr:$src),
2567 def : Pat<(extloadi16 xaddr:$src),
2569 def : Pat<(f64 (extloadf32 iaddr:$src)),
2570 (COPY_TO_REGCLASS (LFS iaddr:$src), F8RC)>;
2571 def : Pat<(f64 (extloadf32 xaddr:$src)),
2572 (COPY_TO_REGCLASS (LFSX xaddr:$src), F8RC)>;
2574 def : Pat<(f64 (fextend f32:$src)),
2575 (COPY_TO_REGCLASS $src, F8RC)>;
2577 // Only seq_cst fences require the heavyweight sync (SYNC 0).
2578 // All others can use the lightweight sync (SYNC 1).
2579 // source: http://www.cl.cam.ac.uk/~pes20/cpp/cpp0xmappings.html
2580 // The rule for seq_cst is duplicated to work with both 64 bits and 32 bits
2581 // versions of Power.
2582 def : Pat<(atomic_fence (i64 7), (imm)), (SYNC 0)>, Requires<[HasSYNC]>;
2583 def : Pat<(atomic_fence (i32 7), (imm)), (SYNC 0)>, Requires<[HasSYNC]>;
2584 def : Pat<(atomic_fence (imm), (imm)), (SYNC 1)>, Requires<[HasSYNC]>;
2585 def : Pat<(atomic_fence (imm), (imm)), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
2587 // Additional FNMSUB patterns: -a*c + b == -(a*c - b)
2588 def : Pat<(fma (fneg f64:$A), f64:$C, f64:$B),
2589 (FNMSUB $A, $C, $B)>;
2590 def : Pat<(fma f64:$A, (fneg f64:$C), f64:$B),
2591 (FNMSUB $A, $C, $B)>;
2592 def : Pat<(fma (fneg f32:$A), f32:$C, f32:$B),
2593 (FNMSUBS $A, $C, $B)>;
2594 def : Pat<(fma f32:$A, (fneg f32:$C), f32:$B),
2595 (FNMSUBS $A, $C, $B)>;
2597 // FCOPYSIGN's operand types need not agree.
2598 def : Pat<(fcopysign f64:$frB, f32:$frA),
2599 (FCPSGND (COPY_TO_REGCLASS $frA, F8RC), $frB)>;
2600 def : Pat<(fcopysign f32:$frB, f64:$frA),
2601 (FCPSGNS (COPY_TO_REGCLASS $frA, F4RC), $frB)>;
2603 include "PPCInstrAltivec.td"
2604 include "PPCInstrSPE.td"
2605 include "PPCInstr64Bit.td"
2606 include "PPCInstrVSX.td"
2608 def crnot : OutPatFrag<(ops node:$in),
2610 def : Pat<(not i1:$in),
2613 // Patterns for arithmetic i1 operations.
2614 def : Pat<(add i1:$a, i1:$b),
2616 def : Pat<(sub i1:$a, i1:$b),
2618 def : Pat<(mul i1:$a, i1:$b),
2621 // We're sometimes asked to materialize i1 -1, which is just 1 in this case
2622 // (-1 is used to mean all bits set).
2623 def : Pat<(i1 -1), (CRSET)>;
2625 // i1 extensions, implemented in terms of isel.
2626 def : Pat<(i32 (zext i1:$in)),
2627 (SELECT_I4 $in, (LI 1), (LI 0))>;
2628 def : Pat<(i32 (sext i1:$in)),
2629 (SELECT_I4 $in, (LI -1), (LI 0))>;
2631 def : Pat<(i64 (zext i1:$in)),
2632 (SELECT_I8 $in, (LI8 1), (LI8 0))>;
2633 def : Pat<(i64 (sext i1:$in)),
2634 (SELECT_I8 $in, (LI8 -1), (LI8 0))>;
2636 // FIXME: We should choose either a zext or a sext based on other constants
2638 def : Pat<(i32 (anyext i1:$in)),
2639 (SELECT_I4 $in, (LI 1), (LI 0))>;
2640 def : Pat<(i64 (anyext i1:$in)),
2641 (SELECT_I8 $in, (LI8 1), (LI8 0))>;
2643 // match setcc on i1 variables.
2644 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETLT)),
2646 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETULT)),
2648 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETLE)),
2650 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETULE)),
2652 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETEQ)),
2654 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETGE)),
2656 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETUGE)),
2658 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETGT)),
2660 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETUGT)),
2662 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETNE)),
2665 // match setcc on non-i1 (non-vector) variables. Note that SETUEQ, SETOGE,
2666 // SETOLE, SETONE, SETULT and SETUGT should be expanded by legalize for
2667 // floating-point types.
2669 multiclass CRNotPat<dag pattern, dag result> {
2670 def : Pat<pattern, (crnot result)>;
2671 def : Pat<(not pattern), result>;
2673 // We can also fold the crnot into an extension:
2674 def : Pat<(i32 (zext pattern)),
2675 (SELECT_I4 result, (LI 0), (LI 1))>;
2676 def : Pat<(i32 (sext pattern)),
2677 (SELECT_I4 result, (LI 0), (LI -1))>;
2679 // We can also fold the crnot into an extension:
2680 def : Pat<(i64 (zext pattern)),
2681 (SELECT_I8 result, (LI8 0), (LI8 1))>;
2682 def : Pat<(i64 (sext pattern)),
2683 (SELECT_I8 result, (LI8 0), (LI8 -1))>;
2685 // FIXME: We should choose either a zext or a sext based on other constants
2687 def : Pat<(i32 (anyext pattern)),
2688 (SELECT_I4 result, (LI 0), (LI 1))>;
2690 def : Pat<(i64 (anyext pattern)),
2691 (SELECT_I8 result, (LI8 0), (LI8 1))>;
2694 // FIXME: Because of what seems like a bug in TableGen's type-inference code,
2695 // we need to write imm:$imm in the output patterns below, not just $imm, or
2696 // else the resulting matcher will not correctly add the immediate operand
2697 // (making it a register operand instead).
2700 multiclass ExtSetCCPat<CondCode cc, PatFrag pfrag,
2701 OutPatFrag rfrag, OutPatFrag rfrag8> {
2702 def : Pat<(i32 (zext (i1 (pfrag i32:$s1, cc)))),
2704 def : Pat<(i64 (zext (i1 (pfrag i64:$s1, cc)))),
2706 def : Pat<(i64 (zext (i1 (pfrag i32:$s1, cc)))),
2707 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1), sub_32)>;
2708 def : Pat<(i32 (zext (i1 (pfrag i64:$s1, cc)))),
2709 (EXTRACT_SUBREG (rfrag8 $s1), sub_32)>;
2711 def : Pat<(i32 (anyext (i1 (pfrag i32:$s1, cc)))),
2713 def : Pat<(i64 (anyext (i1 (pfrag i64:$s1, cc)))),
2715 def : Pat<(i64 (anyext (i1 (pfrag i32:$s1, cc)))),
2716 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1), sub_32)>;
2717 def : Pat<(i32 (anyext (i1 (pfrag i64:$s1, cc)))),
2718 (EXTRACT_SUBREG (rfrag8 $s1), sub_32)>;
2721 // Note that we do all inversions below with i(32|64)not, instead of using
2722 // (xori x, 1) because on the A2 nor has single-cycle latency while xori
2723 // has 2-cycle latency.
2725 defm : ExtSetCCPat<SETEQ,
2726 PatFrag<(ops node:$in, node:$cc),
2727 (setcc $in, 0, $cc)>,
2728 OutPatFrag<(ops node:$in),
2729 (RLWINM (CNTLZW $in), 27, 31, 31)>,
2730 OutPatFrag<(ops node:$in),
2731 (RLDICL (CNTLZD $in), 58, 63)> >;
2733 defm : ExtSetCCPat<SETNE,
2734 PatFrag<(ops node:$in, node:$cc),
2735 (setcc $in, 0, $cc)>,
2736 OutPatFrag<(ops node:$in),
2737 (RLWINM (i32not (CNTLZW $in)), 27, 31, 31)>,
2738 OutPatFrag<(ops node:$in),
2739 (RLDICL (i64not (CNTLZD $in)), 58, 63)> >;
2741 defm : ExtSetCCPat<SETLT,
2742 PatFrag<(ops node:$in, node:$cc),
2743 (setcc $in, 0, $cc)>,
2744 OutPatFrag<(ops node:$in),
2745 (RLWINM $in, 1, 31, 31)>,
2746 OutPatFrag<(ops node:$in),
2747 (RLDICL $in, 1, 63)> >;
2749 defm : ExtSetCCPat<SETGE,
2750 PatFrag<(ops node:$in, node:$cc),
2751 (setcc $in, 0, $cc)>,
2752 OutPatFrag<(ops node:$in),
2753 (RLWINM (i32not $in), 1, 31, 31)>,
2754 OutPatFrag<(ops node:$in),
2755 (RLDICL (i64not $in), 1, 63)> >;
2757 defm : ExtSetCCPat<SETGT,
2758 PatFrag<(ops node:$in, node:$cc),
2759 (setcc $in, 0, $cc)>,
2760 OutPatFrag<(ops node:$in),
2761 (RLWINM (ANDC (NEG $in), $in), 1, 31, 31)>,
2762 OutPatFrag<(ops node:$in),
2763 (RLDICL (ANDC8 (NEG8 $in), $in), 1, 63)> >;
2765 defm : ExtSetCCPat<SETLE,
2766 PatFrag<(ops node:$in, node:$cc),
2767 (setcc $in, 0, $cc)>,
2768 OutPatFrag<(ops node:$in),
2769 (RLWINM (ORC $in, (NEG $in)), 1, 31, 31)>,
2770 OutPatFrag<(ops node:$in),
2771 (RLDICL (ORC8 $in, (NEG8 $in)), 1, 63)> >;
2773 defm : ExtSetCCPat<SETLT,
2774 PatFrag<(ops node:$in, node:$cc),
2775 (setcc $in, -1, $cc)>,
2776 OutPatFrag<(ops node:$in),
2777 (RLWINM (AND $in, (ADDI $in, 1)), 1, 31, 31)>,
2778 OutPatFrag<(ops node:$in),
2779 (RLDICL (AND8 $in, (ADDI8 $in, 1)), 1, 63)> >;
2781 defm : ExtSetCCPat<SETGE,
2782 PatFrag<(ops node:$in, node:$cc),
2783 (setcc $in, -1, $cc)>,
2784 OutPatFrag<(ops node:$in),
2785 (RLWINM (NAND $in, (ADDI $in, 1)), 1, 31, 31)>,
2786 OutPatFrag<(ops node:$in),
2787 (RLDICL (NAND8 $in, (ADDI8 $in, 1)), 1, 63)> >;
2789 defm : ExtSetCCPat<SETGT,
2790 PatFrag<(ops node:$in, node:$cc),
2791 (setcc $in, -1, $cc)>,
2792 OutPatFrag<(ops node:$in),
2793 (RLWINM (i32not $in), 1, 31, 31)>,
2794 OutPatFrag<(ops node:$in),
2795 (RLDICL (i64not $in), 1, 63)> >;
2797 defm : ExtSetCCPat<SETLE,
2798 PatFrag<(ops node:$in, node:$cc),
2799 (setcc $in, -1, $cc)>,
2800 OutPatFrag<(ops node:$in),
2801 (RLWINM $in, 1, 31, 31)>,
2802 OutPatFrag<(ops node:$in),
2803 (RLDICL $in, 1, 63)> >;
2806 def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETULT)),
2807 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_lt)>;
2808 def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETLT)),
2809 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_lt)>;
2810 def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETUGT)),
2811 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_gt)>;
2812 def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETGT)),
2813 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_gt)>;
2814 def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETEQ)),
2815 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_eq)>;
2816 def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETEQ)),
2817 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_eq)>;
2819 // For non-equality comparisons, the default code would materialize the
2820 // constant, then compare against it, like this:
2822 // ori r2, r2, 22136
2825 // Since we are just comparing for equality, we can emit this instead:
2826 // xoris r0,r3,0x1234
2827 // cmplwi cr0,r0,0x5678
2830 def : Pat<(i1 (setcc i32:$s1, imm:$imm, SETEQ)),
2831 (EXTRACT_SUBREG (CMPLWI (XORIS $s1, (HI16 imm:$imm)),
2832 (LO16 imm:$imm)), sub_eq)>;
2834 defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETUGE)),
2835 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_lt)>;
2836 defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETGE)),
2837 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_lt)>;
2838 defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETULE)),
2839 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_gt)>;
2840 defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETLE)),
2841 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_gt)>;
2842 defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETNE)),
2843 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_eq)>;
2844 defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETNE)),
2845 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_eq)>;
2847 defm : CRNotPat<(i1 (setcc i32:$s1, imm:$imm, SETNE)),
2848 (EXTRACT_SUBREG (CMPLWI (XORIS $s1, (HI16 imm:$imm)),
2849 (LO16 imm:$imm)), sub_eq)>;
2851 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETULT)),
2852 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_lt)>;
2853 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETLT)),
2854 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_lt)>;
2855 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETUGT)),
2856 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_gt)>;
2857 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETGT)),
2858 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_gt)>;
2859 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETEQ)),
2860 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_eq)>;
2862 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETUGE)),
2863 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_lt)>;
2864 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETGE)),
2865 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_lt)>;
2866 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETULE)),
2867 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_gt)>;
2868 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETLE)),
2869 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_gt)>;
2870 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETNE)),
2871 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_eq)>;
2874 def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETULT)),
2875 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_lt)>;
2876 def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETLT)),
2877 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_lt)>;
2878 def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETUGT)),
2879 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_gt)>;
2880 def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETGT)),
2881 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_gt)>;
2882 def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETEQ)),
2883 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_eq)>;
2884 def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETEQ)),
2885 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_eq)>;
2887 // For non-equality comparisons, the default code would materialize the
2888 // constant, then compare against it, like this:
2890 // ori r2, r2, 22136
2893 // Since we are just comparing for equality, we can emit this instead:
2894 // xoris r0,r3,0x1234
2895 // cmpldi cr0,r0,0x5678
2898 def : Pat<(i1 (setcc i64:$s1, imm64ZExt32:$imm, SETEQ)),
2899 (EXTRACT_SUBREG (CMPLDI (XORIS8 $s1, (HI16 imm:$imm)),
2900 (LO16 imm:$imm)), sub_eq)>;
2902 defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETUGE)),
2903 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_lt)>;
2904 defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETGE)),
2905 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_lt)>;
2906 defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETULE)),
2907 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_gt)>;
2908 defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETLE)),
2909 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_gt)>;
2910 defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETNE)),
2911 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_eq)>;
2912 defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETNE)),
2913 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_eq)>;
2915 defm : CRNotPat<(i1 (setcc i64:$s1, imm64ZExt32:$imm, SETNE)),
2916 (EXTRACT_SUBREG (CMPLDI (XORIS8 $s1, (HI16 imm:$imm)),
2917 (LO16 imm:$imm)), sub_eq)>;
2919 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETULT)),
2920 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_lt)>;
2921 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETLT)),
2922 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_lt)>;
2923 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETUGT)),
2924 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_gt)>;
2925 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETGT)),
2926 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_gt)>;
2927 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETEQ)),
2928 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_eq)>;
2930 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETUGE)),
2931 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_lt)>;
2932 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETGE)),
2933 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_lt)>;
2934 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETULE)),
2935 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_gt)>;
2936 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETLE)),
2937 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_gt)>;
2938 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETNE)),
2939 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_eq)>;
2942 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOLT)),
2943 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
2944 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETLT)),
2945 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
2946 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOGT)),
2947 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
2948 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETGT)),
2949 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
2950 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOEQ)),
2951 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
2952 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETEQ)),
2953 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
2954 def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETUO)),
2955 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_un)>;
2957 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETUGE)),
2958 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
2959 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETGE)),
2960 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>;
2961 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETULE)),
2962 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
2963 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETLE)),
2964 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>;
2965 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETUNE)),
2966 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
2967 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETNE)),
2968 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>;
2969 defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETO)),
2970 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_un)>;
2973 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOLT)),
2974 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
2975 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETLT)),
2976 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
2977 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOGT)),
2978 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
2979 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETGT)),
2980 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
2981 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOEQ)),
2982 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
2983 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETEQ)),
2984 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
2985 def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETUO)),
2986 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_un)>;
2988 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETUGE)),
2989 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
2990 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETGE)),
2991 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>;
2992 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETULE)),
2993 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
2994 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETLE)),
2995 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>;
2996 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETUNE)),
2997 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
2998 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETNE)),
2999 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>;
3000 defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETO)),
3001 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_un)>;
3003 // match select on i1 variables:
3004 def : Pat<(i1 (select i1:$cond, i1:$tval, i1:$fval)),
3005 (CROR (CRAND $cond , $tval),
3006 (CRAND (crnot $cond), $fval))>;
3008 // match selectcc on i1 variables:
3009 // select (lhs == rhs), tval, fval is:
3010 // ((lhs == rhs) & tval) | (!(lhs == rhs) & fval)
3011 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETLT)),
3012 (CROR (CRAND (CRANDC $rhs, $lhs), $tval),
3013 (CRAND (CRORC $lhs, $rhs), $fval))>;
3014 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETLE)),
3015 (CROR (CRAND (CRORC $rhs, $lhs), $tval),
3016 (CRAND (CRANDC $lhs, $rhs), $fval))>;
3017 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETEQ)),
3018 (CROR (CRAND (CREQV $lhs, $rhs), $tval),
3019 (CRAND (CRXOR $lhs, $rhs), $fval))>;
3020 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETGE)),
3021 (CROR (CRAND (CRORC $lhs, $rhs), $tval),
3022 (CRAND (CRANDC $rhs, $lhs), $fval))>;
3023 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETGT)),
3024 (CROR (CRAND (CRANDC $lhs, $rhs), $tval),
3025 (CRAND (CRORC $rhs, $lhs), $fval))>;
3026 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETNE)),
3027 (CROR (CRAND (CREQV $lhs, $rhs), $fval),
3028 (CRAND (CRXOR $lhs, $rhs), $tval))>;
3030 // match selectcc on i1 variables with non-i1 output.
3031 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETLT)),
3032 (SELECT_I4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3033 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETLE)),
3034 (SELECT_I4 (CRORC $rhs, $lhs), $tval, $fval)>;
3035 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETEQ)),
3036 (SELECT_I4 (CREQV $lhs, $rhs), $tval, $fval)>;
3037 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETGE)),
3038 (SELECT_I4 (CRORC $lhs, $rhs), $tval, $fval)>;
3039 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETGT)),
3040 (SELECT_I4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3041 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETNE)),
3042 (SELECT_I4 (CRXOR $lhs, $rhs), $tval, $fval)>;
3044 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETLT)),
3045 (SELECT_I8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3046 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETLE)),
3047 (SELECT_I8 (CRORC $rhs, $lhs), $tval, $fval)>;
3048 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETEQ)),
3049 (SELECT_I8 (CREQV $lhs, $rhs), $tval, $fval)>;
3050 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETGE)),
3051 (SELECT_I8 (CRORC $lhs, $rhs), $tval, $fval)>;
3052 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETGT)),
3053 (SELECT_I8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3054 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETNE)),
3055 (SELECT_I8 (CRXOR $lhs, $rhs), $tval, $fval)>;
3057 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETLT)),
3058 (SELECT_F4 (CRANDC $rhs, $lhs), $tval, $fval)>;
3059 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETLE)),
3060 (SELECT_F4 (CRORC $rhs, $lhs), $tval, $fval)>;
3061 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETEQ)),
3062 (SELECT_F4 (CREQV $lhs, $rhs), $tval, $fval)>;
3063 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETGE)),
3064 (SELECT_F4 (CRORC $lhs, $rhs), $tval, $fval)>;
3065 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETGT)),
3066 (SELECT_F4 (CRANDC $lhs, $rhs), $tval, $fval)>;
3067 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETNE)),
3068 (SELECT_F4 (CRXOR $lhs, $rhs), $tval, $fval)>;
3070 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETLT)),
3071 (SELECT_F8 (CRANDC $rhs, $lhs), $tval, $fval)>;
3072 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETLE)),
3073 (SELECT_F8 (CRORC $rhs, $lhs), $tval, $fval)>;
3074 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETEQ)),
3075 (SELECT_F8 (CREQV $lhs, $rhs), $tval, $fval)>;
3076 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETGE)),
3077 (SELECT_F8 (CRORC $lhs, $rhs), $tval, $fval)>;
3078 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETGT)),
3079 (SELECT_F8 (CRANDC $lhs, $rhs), $tval, $fval)>;
3080 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETNE)),
3081 (SELECT_F8 (CRXOR $lhs, $rhs), $tval, $fval)>;
3083 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETLT)),
3084 (SELECT_VRRC (CRANDC $rhs, $lhs), $tval, $fval)>;
3085 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETLE)),
3086 (SELECT_VRRC (CRORC $rhs, $lhs), $tval, $fval)>;
3087 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETEQ)),
3088 (SELECT_VRRC (CREQV $lhs, $rhs), $tval, $fval)>;
3089 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETGE)),
3090 (SELECT_VRRC (CRORC $lhs, $rhs), $tval, $fval)>;
3091 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETGT)),
3092 (SELECT_VRRC (CRANDC $lhs, $rhs), $tval, $fval)>;
3093 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETNE)),
3094 (SELECT_VRRC (CRXOR $lhs, $rhs), $tval, $fval)>;
3096 let usesCustomInserter = 1 in {
3097 def ANDIo_1_EQ_BIT : Pseudo<(outs crbitrc:$dst), (ins gprc:$in),
3099 [(set i1:$dst, (trunc (not i32:$in)))]>;
3100 def ANDIo_1_GT_BIT : Pseudo<(outs crbitrc:$dst), (ins gprc:$in),
3102 [(set i1:$dst, (trunc i32:$in))]>;
3104 def ANDIo_1_EQ_BIT8 : Pseudo<(outs crbitrc:$dst), (ins g8rc:$in),
3106 [(set i1:$dst, (trunc (not i64:$in)))]>;
3107 def ANDIo_1_GT_BIT8 : Pseudo<(outs crbitrc:$dst), (ins g8rc:$in),
3109 [(set i1:$dst, (trunc i64:$in))]>;
3112 def : Pat<(i1 (not (trunc i32:$in))),
3113 (ANDIo_1_EQ_BIT $in)>;
3114 def : Pat<(i1 (not (trunc i64:$in))),
3115 (ANDIo_1_EQ_BIT8 $in)>;
3117 //===----------------------------------------------------------------------===//
3118 // PowerPC Instructions used for assembler/disassembler only
3121 // FIXME: For B=0 or B > 8, the registers following RT are used.
3122 // WARNING: Do not add patterns for this instruction without fixing this.
3123 def LSWI : XForm_base_r3xo<31, 597, (outs gprc:$RT), (ins gprc:$A, u5imm:$B),
3124 "lswi $RT, $A, $B", IIC_LdStLoad, []>;
3126 // FIXME: For B=0 or B > 8, the registers following RT are used.
3127 // WARNING: Do not add patterns for this instruction without fixing this.
3128 def STSWI : XForm_base_r3xo<31, 725, (outs), (ins gprc:$RT, gprc:$A, u5imm:$B),
3129 "stswi $RT, $A, $B", IIC_LdStLoad, []>;
3131 def ISYNC : XLForm_2_ext<19, 150, 0, 0, 0, (outs), (ins),
3132 "isync", IIC_SprISYNC, []>;
3134 def ICBI : XForm_1a<31, 982, (outs), (ins memrr:$src),
3135 "icbi $src", IIC_LdStICBI, []>;
3137 // We used to have EIEIO as value but E[0-9A-Z] is a reserved name
3138 def EnforceIEIO : XForm_24_eieio<31, 854, (outs), (ins),
3139 "eieio", IIC_LdStLoad, []>;
3141 def WAIT : XForm_24_sync<31, 62, (outs), (ins i32imm:$L),
3142 "wait $L", IIC_LdStLoad, []>;
3144 def MBAR : XForm_mbar<31, 854, (outs), (ins u5imm:$MO),
3145 "mbar $MO", IIC_LdStLoad>, Requires<[IsBookE]>;
3147 def MTSR: XForm_sr<31, 210, (outs), (ins gprc:$RS, u4imm:$SR),
3148 "mtsr $SR, $RS", IIC_SprMTSR>;
3150 def MFSR: XForm_sr<31, 595, (outs gprc:$RS), (ins u4imm:$SR),
3151 "mfsr $RS, $SR", IIC_SprMFSR>;
3153 def MTSRIN: XForm_srin<31, 242, (outs), (ins gprc:$RS, gprc:$RB),
3154 "mtsrin $RS, $RB", IIC_SprMTSR>;
3156 def MFSRIN: XForm_srin<31, 659, (outs gprc:$RS), (ins gprc:$RB),
3157 "mfsrin $RS, $RB", IIC_SprMFSR>;
3159 def MTMSR: XForm_mtmsr<31, 146, (outs), (ins gprc:$RS, i32imm:$L),
3160 "mtmsr $RS, $L", IIC_SprMTMSR>;
3162 def WRTEE: XForm_mtmsr<31, 131, (outs), (ins gprc:$RS),
3163 "wrtee $RS", IIC_SprMTMSR>, Requires<[IsBookE]> {
3167 def WRTEEI: I<31, (outs), (ins i1imm:$E), "wrteei $E", IIC_SprMTMSR>,
3168 Requires<[IsBookE]> {
3172 let Inst{21-30} = 163;
3175 def DCCCI : XForm_tlb<454, (outs), (ins gprc:$A, gprc:$B),
3176 "dccci $A, $B", IIC_LdStLoad>, Requires<[IsPPC4xx]>;
3177 def ICCCI : XForm_tlb<966, (outs), (ins gprc:$A, gprc:$B),
3178 "iccci $A, $B", IIC_LdStLoad>, Requires<[IsPPC4xx]>;
3180 def : InstAlias<"dci 0", (DCCCI R0, R0)>, Requires<[IsPPC4xx]>;
3181 def : InstAlias<"dccci", (DCCCI R0, R0)>, Requires<[IsPPC4xx]>;
3182 def : InstAlias<"ici 0", (ICCCI R0, R0)>, Requires<[IsPPC4xx]>;
3183 def : InstAlias<"iccci", (ICCCI R0, R0)>, Requires<[IsPPC4xx]>;
3185 def MFMSR : XForm_rs<31, 83, (outs gprc:$RT), (ins),
3186 "mfmsr $RT", IIC_SprMFMSR, []>;
3188 def MTMSRD : XForm_mtmsr<31, 178, (outs), (ins gprc:$RS, i32imm:$L),
3189 "mtmsrd $RS, $L", IIC_SprMTMSRD>;
3191 def MCRFS : XLForm_3<63, 64, (outs crrc:$BF), (ins crrc:$BFA),
3192 "mcrfs $BF, $BFA", IIC_BrMCR>;
3194 def MTFSFI : XLForm_4<63, 134, (outs crrc:$BF), (ins i32imm:$U, i32imm:$W),
3195 "mtfsfi $BF, $U, $W", IIC_IntMFFS>;
3197 def MTFSFIo : XLForm_4<63, 134, (outs crrc:$BF), (ins i32imm:$U, i32imm:$W),
3198 "mtfsfi. $BF, $U, $W", IIC_IntMFFS>, isDOT;
3200 def : InstAlias<"mtfsfi $BF, $U", (MTFSFI crrc:$BF, i32imm:$U, 0)>;
3201 def : InstAlias<"mtfsfi. $BF, $U", (MTFSFIo crrc:$BF, i32imm:$U, 0)>;
3203 def MTFSF : XFLForm_1<63, 711, (outs),
3204 (ins i32imm:$FLM, f8rc:$FRB, i32imm:$L, i32imm:$W),
3205 "mtfsf $FLM, $FRB, $L, $W", IIC_IntMFFS, []>;
3206 def MTFSFo : XFLForm_1<63, 711, (outs),
3207 (ins i32imm:$FLM, f8rc:$FRB, i32imm:$L, i32imm:$W),
3208 "mtfsf. $FLM, $FRB, $L, $W", IIC_IntMFFS, []>, isDOT;
3210 def : InstAlias<"mtfsf $FLM, $FRB", (MTFSF i32imm:$FLM, f8rc:$FRB, 0, 0)>;
3211 def : InstAlias<"mtfsf. $FLM, $FRB", (MTFSFo i32imm:$FLM, f8rc:$FRB, 0, 0)>;
3213 def SLBIE : XForm_16b<31, 434, (outs), (ins gprc:$RB),
3214 "slbie $RB", IIC_SprSLBIE, []>;
3216 def SLBMTE : XForm_26<31, 402, (outs), (ins gprc:$RS, gprc:$RB),
3217 "slbmte $RS, $RB", IIC_SprSLBMTE, []>;
3219 def SLBMFEE : XForm_26<31, 915, (outs gprc:$RT), (ins gprc:$RB),
3220 "slbmfee $RT, $RB", IIC_SprSLBMFEE, []>;
3222 def SLBIA : XForm_0<31, 498, (outs), (ins), "slbia", IIC_SprSLBIA, []>;
3224 def TLBIA : XForm_0<31, 370, (outs), (ins),
3225 "tlbia", IIC_SprTLBIA, []>;
3227 def TLBSYNC : XForm_0<31, 566, (outs), (ins),
3228 "tlbsync", IIC_SprTLBSYNC, []>;
3230 def TLBIEL : XForm_16b<31, 274, (outs), (ins gprc:$RB),
3231 "tlbiel $RB", IIC_SprTLBIEL, []>;
3233 def TLBLD : XForm_16b<31, 978, (outs), (ins gprc:$RB),
3234 "tlbld $RB", IIC_LdStLoad, []>, Requires<[IsPPC6xx]>;
3235 def TLBLI : XForm_16b<31, 1010, (outs), (ins gprc:$RB),
3236 "tlbli $RB", IIC_LdStLoad, []>, Requires<[IsPPC6xx]>;
3238 def TLBIE : XForm_26<31, 306, (outs), (ins gprc:$RS, gprc:$RB),
3239 "tlbie $RB,$RS", IIC_SprTLBIE, []>;
3241 def TLBSX : XForm_tlb<914, (outs), (ins gprc:$A, gprc:$B), "tlbsx $A, $B",
3242 IIC_LdStLoad>, Requires<[IsBookE]>;
3244 def TLBIVAX : XForm_tlb<786, (outs), (ins gprc:$A, gprc:$B), "tlbivax $A, $B",
3245 IIC_LdStLoad>, Requires<[IsBookE]>;
3247 def TLBRE : XForm_24_eieio<31, 946, (outs), (ins),
3248 "tlbre", IIC_LdStLoad, []>, Requires<[IsBookE]>;
3250 def TLBWE : XForm_24_eieio<31, 978, (outs), (ins),
3251 "tlbwe", IIC_LdStLoad, []>, Requires<[IsBookE]>;
3253 def TLBRE2 : XForm_tlbws<31, 946, (outs gprc:$RS), (ins gprc:$A, i1imm:$WS),
3254 "tlbre $RS, $A, $WS", IIC_LdStLoad, []>, Requires<[IsPPC4xx]>;
3256 def TLBWE2 : XForm_tlbws<31, 978, (outs), (ins gprc:$RS, gprc:$A, i1imm:$WS),
3257 "tlbwe $RS, $A, $WS", IIC_LdStLoad, []>, Requires<[IsPPC4xx]>;
3259 def TLBSX2 : XForm_base_r3xo<31, 914, (outs), (ins gprc:$RST, gprc:$A, gprc:$B),
3260 "tlbsx $RST, $A, $B", IIC_LdStLoad, []>,
3261 Requires<[IsPPC4xx]>;
3262 def TLBSX2D : XForm_base_r3xo<31, 914, (outs),
3263 (ins gprc:$RST, gprc:$A, gprc:$B),
3264 "tlbsx. $RST, $A, $B", IIC_LdStLoad, []>,
3265 Requires<[IsPPC4xx]>, isDOT;
3267 def RFID : XForm_0<19, 18, (outs), (ins), "rfid", IIC_IntRFID, []>;
3269 def RFI : XForm_0<19, 50, (outs), (ins), "rfi", IIC_SprRFI, []>,
3270 Requires<[IsBookE]>;
3271 def RFCI : XForm_0<19, 51, (outs), (ins), "rfci", IIC_BrB, []>,
3272 Requires<[IsBookE]>;
3274 def RFDI : XForm_0<19, 39, (outs), (ins), "rfdi", IIC_BrB, []>,
3276 def RFMCI : XForm_0<19, 38, (outs), (ins), "rfmci", IIC_BrB, []>,
3279 def MFDCR : XFXForm_1<31, 323, (outs gprc:$RT), (ins i32imm:$SPR),
3280 "mfdcr $RT, $SPR", IIC_SprMFSPR>, Requires<[IsPPC4xx]>;
3281 def MTDCR : XFXForm_1<31, 451, (outs), (ins gprc:$RT, i32imm:$SPR),
3282 "mtdcr $SPR, $RT", IIC_SprMTSPR>, Requires<[IsPPC4xx]>;
3284 def ATTN : XForm_attn<0, 256, (outs), (ins), "attn", IIC_BrB>;
3286 def LBZCIX : XForm_base_r3xo<31, 853, (outs gprc:$RST), (ins gprc:$A, gprc:$B),
3287 "lbzcix $RST, $A, $B", IIC_LdStLoad, []>;
3288 def LHZCIX : XForm_base_r3xo<31, 821, (outs gprc:$RST), (ins gprc:$A, gprc:$B),
3289 "lhzcix $RST, $A, $B", IIC_LdStLoad, []>;
3290 def LWZCIX : XForm_base_r3xo<31, 789, (outs gprc:$RST), (ins gprc:$A, gprc:$B),
3291 "lwzcix $RST, $A, $B", IIC_LdStLoad, []>;
3292 def LDCIX : XForm_base_r3xo<31, 885, (outs gprc:$RST), (ins gprc:$A, gprc:$B),
3293 "ldcix $RST, $A, $B", IIC_LdStLoad, []>;
3295 def STBCIX : XForm_base_r3xo<31, 981, (outs), (ins gprc:$RST, gprc:$A, gprc:$B),
3296 "stbcix $RST, $A, $B", IIC_LdStLoad, []>;
3297 def STHCIX : XForm_base_r3xo<31, 949, (outs), (ins gprc:$RST, gprc:$A, gprc:$B),
3298 "sthcix $RST, $A, $B", IIC_LdStLoad, []>;
3299 def STWCIX : XForm_base_r3xo<31, 917, (outs), (ins gprc:$RST, gprc:$A, gprc:$B),
3300 "stwcix $RST, $A, $B", IIC_LdStLoad, []>;
3301 def STDCIX : XForm_base_r3xo<31, 1013, (outs), (ins gprc:$RST, gprc:$A, gprc:$B),
3302 "stdcix $RST, $A, $B", IIC_LdStLoad, []>;
3304 //===----------------------------------------------------------------------===//
3305 // PowerPC Assembler Instruction Aliases
3308 // Pseudo-instructions for alternate assembly syntax (never used by codegen).
3309 // These are aliases that require C++ handling to convert to the target
3310 // instruction, while InstAliases can be handled directly by tblgen.
3311 class PPCAsmPseudo<string asm, dag iops>
3313 let Namespace = "PPC";
3314 bit PPC64 = 0; // Default value, override with isPPC64
3316 let OutOperandList = (outs);
3317 let InOperandList = iops;
3319 let AsmString = asm;
3320 let isAsmParserOnly = 1;
3324 def : InstAlias<"sc", (SC 0)>;
3326 def : InstAlias<"sync", (SYNC 0)>, Requires<[HasSYNC]>;
3327 def : InstAlias<"msync", (SYNC 0)>, Requires<[HasSYNC]>;
3328 def : InstAlias<"lwsync", (SYNC 1)>, Requires<[HasSYNC]>;
3329 def : InstAlias<"ptesync", (SYNC 2)>, Requires<[HasSYNC]>;
3331 def : InstAlias<"wait", (WAIT 0)>;
3332 def : InstAlias<"waitrsv", (WAIT 1)>;
3333 def : InstAlias<"waitimpl", (WAIT 2)>;
3335 def : InstAlias<"mbar", (MBAR 0)>, Requires<[IsBookE]>;
3337 def : InstAlias<"crset $bx", (CREQV crbitrc:$bx, crbitrc:$bx, crbitrc:$bx)>;
3338 def : InstAlias<"crclr $bx", (CRXOR crbitrc:$bx, crbitrc:$bx, crbitrc:$bx)>;
3339 def : InstAlias<"crmove $bx, $by", (CROR crbitrc:$bx, crbitrc:$by, crbitrc:$by)>;
3340 def : InstAlias<"crnot $bx, $by", (CRNOR crbitrc:$bx, crbitrc:$by, crbitrc:$by)>;
3342 def : InstAlias<"mtxer $Rx", (MTSPR 1, gprc:$Rx)>;
3343 def : InstAlias<"mfxer $Rx", (MFSPR gprc:$Rx, 1)>;
3345 def : InstAlias<"mfrtcu $Rx", (MFSPR gprc:$Rx, 4)>;
3346 def : InstAlias<"mfrtcl $Rx", (MFSPR gprc:$Rx, 5)>;
3348 def : InstAlias<"mtdscr $Rx", (MTSPR 17, gprc:$Rx)>;
3349 def : InstAlias<"mfdscr $Rx", (MFSPR gprc:$Rx, 17)>;
3351 def : InstAlias<"mtdsisr $Rx", (MTSPR 18, gprc:$Rx)>;
3352 def : InstAlias<"mfdsisr $Rx", (MFSPR gprc:$Rx, 18)>;
3354 def : InstAlias<"mtdar $Rx", (MTSPR 19, gprc:$Rx)>;
3355 def : InstAlias<"mfdar $Rx", (MFSPR gprc:$Rx, 19)>;
3357 def : InstAlias<"mtdec $Rx", (MTSPR 22, gprc:$Rx)>;
3358 def : InstAlias<"mfdec $Rx", (MFSPR gprc:$Rx, 22)>;
3360 def : InstAlias<"mtsdr1 $Rx", (MTSPR 25, gprc:$Rx)>;
3361 def : InstAlias<"mfsdr1 $Rx", (MFSPR gprc:$Rx, 25)>;
3363 def : InstAlias<"mtsrr0 $Rx", (MTSPR 26, gprc:$Rx)>;
3364 def : InstAlias<"mfsrr0 $Rx", (MFSPR gprc:$Rx, 26)>;
3366 def : InstAlias<"mtsrr1 $Rx", (MTSPR 27, gprc:$Rx)>;
3367 def : InstAlias<"mfsrr1 $Rx", (MFSPR gprc:$Rx, 27)>;
3369 def : InstAlias<"mtsrr2 $Rx", (MTSPR 990, gprc:$Rx)>, Requires<[IsPPC4xx]>;
3370 def : InstAlias<"mfsrr2 $Rx", (MFSPR gprc:$Rx, 990)>, Requires<[IsPPC4xx]>;
3372 def : InstAlias<"mtsrr3 $Rx", (MTSPR 991, gprc:$Rx)>, Requires<[IsPPC4xx]>;
3373 def : InstAlias<"mfsrr3 $Rx", (MFSPR gprc:$Rx, 991)>, Requires<[IsPPC4xx]>;
3375 def : InstAlias<"mtcfar $Rx", (MTSPR 28, gprc:$Rx)>;
3376 def : InstAlias<"mfcfar $Rx", (MFSPR gprc:$Rx, 28)>;
3378 def : InstAlias<"mtamr $Rx", (MTSPR 29, gprc:$Rx)>;
3379 def : InstAlias<"mfamr $Rx", (MFSPR gprc:$Rx, 29)>;
3381 def : InstAlias<"mtpid $Rx", (MTSPR 48, gprc:$Rx)>, Requires<[IsBookE]>;
3382 def : InstAlias<"mfpid $Rx", (MFSPR gprc:$Rx, 48)>, Requires<[IsBookE]>;
3384 def : InstAlias<"mftb $Rx", (MFTB gprc:$Rx, 268)>;
3385 def : InstAlias<"mftbl $Rx", (MFTB gprc:$Rx, 268)>;
3386 def : InstAlias<"mftbu $Rx", (MFTB gprc:$Rx, 269)>;
3388 def : InstAlias<"mttbl $Rx", (MTSPR 284, gprc:$Rx)>;
3389 def : InstAlias<"mttbu $Rx", (MTSPR 285, gprc:$Rx)>;
3391 def : InstAlias<"mftblo $Rx", (MFSPR gprc:$Rx, 989)>, Requires<[IsPPC4xx]>;
3392 def : InstAlias<"mttblo $Rx", (MTSPR 989, gprc:$Rx)>, Requires<[IsPPC4xx]>;
3393 def : InstAlias<"mftbhi $Rx", (MFSPR gprc:$Rx, 988)>, Requires<[IsPPC4xx]>;
3394 def : InstAlias<"mttbhi $Rx", (MTSPR 988, gprc:$Rx)>, Requires<[IsPPC4xx]>;
3396 def : InstAlias<"xnop", (XORI R0, R0, 0)>;
3398 def : InstAlias<"mr $rA, $rB", (OR8 g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
3399 def : InstAlias<"mr. $rA, $rB", (OR8o g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
3401 def : InstAlias<"not $rA, $rB", (NOR8 g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
3402 def : InstAlias<"not. $rA, $rB", (NOR8o g8rc:$rA, g8rc:$rB, g8rc:$rB)>;
3404 def : InstAlias<"mtcr $rA", (MTCRF8 255, g8rc:$rA)>;
3406 foreach BATR = 0-3 in {
3407 def : InstAlias<"mtdbatu "#BATR#", $Rx",
3408 (MTSPR !add(BATR, !add(BATR, 536)), gprc:$Rx)>,
3409 Requires<[IsPPC6xx]>;
3410 def : InstAlias<"mfdbatu $Rx, "#BATR,
3411 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 536)))>,
3412 Requires<[IsPPC6xx]>;
3413 def : InstAlias<"mtdbatl "#BATR#", $Rx",
3414 (MTSPR !add(BATR, !add(BATR, 537)), gprc:$Rx)>,
3415 Requires<[IsPPC6xx]>;
3416 def : InstAlias<"mfdbatl $Rx, "#BATR,
3417 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 537)))>,
3418 Requires<[IsPPC6xx]>;
3419 def : InstAlias<"mtibatu "#BATR#", $Rx",
3420 (MTSPR !add(BATR, !add(BATR, 528)), gprc:$Rx)>,
3421 Requires<[IsPPC6xx]>;
3422 def : InstAlias<"mfibatu $Rx, "#BATR,
3423 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 528)))>,
3424 Requires<[IsPPC6xx]>;
3425 def : InstAlias<"mtibatl "#BATR#", $Rx",
3426 (MTSPR !add(BATR, !add(BATR, 529)), gprc:$Rx)>,
3427 Requires<[IsPPC6xx]>;
3428 def : InstAlias<"mfibatl $Rx, "#BATR,
3429 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 529)))>,
3430 Requires<[IsPPC6xx]>;
3433 foreach BR = 0-7 in {
3434 def : InstAlias<"mfbr"#BR#" $Rx",
3435 (MFDCR gprc:$Rx, !add(BR, 0x80))>,
3436 Requires<[IsPPC4xx]>;
3437 def : InstAlias<"mtbr"#BR#" $Rx",
3438 (MTDCR gprc:$Rx, !add(BR, 0x80))>,
3439 Requires<[IsPPC4xx]>;
3442 def : InstAlias<"mtdccr $Rx", (MTSPR 1018, gprc:$Rx)>, Requires<[IsPPC4xx]>;
3443 def : InstAlias<"mfdccr $Rx", (MFSPR gprc:$Rx, 1018)>, Requires<[IsPPC4xx]>;
3445 def : InstAlias<"mticcr $Rx", (MTSPR 1019, gprc:$Rx)>, Requires<[IsPPC4xx]>;
3446 def : InstAlias<"mficcr $Rx", (MFSPR gprc:$Rx, 1019)>, Requires<[IsPPC4xx]>;
3448 def : InstAlias<"mtdear $Rx", (MTSPR 981, gprc:$Rx)>, Requires<[IsPPC4xx]>;
3449 def : InstAlias<"mfdear $Rx", (MFSPR gprc:$Rx, 981)>, Requires<[IsPPC4xx]>;
3451 def : InstAlias<"mtesr $Rx", (MTSPR 980, gprc:$Rx)>, Requires<[IsPPC4xx]>;
3452 def : InstAlias<"mfesr $Rx", (MFSPR gprc:$Rx, 980)>, Requires<[IsPPC4xx]>;
3454 def : InstAlias<"mfspefscr $Rx", (MFSPR gprc:$Rx, 512)>;
3455 def : InstAlias<"mtspefscr $Rx", (MTSPR 512, gprc:$Rx)>;
3457 def : InstAlias<"mttcr $Rx", (MTSPR 986, gprc:$Rx)>, Requires<[IsPPC4xx]>;
3458 def : InstAlias<"mftcr $Rx", (MFSPR gprc:$Rx, 986)>, Requires<[IsPPC4xx]>;
3460 def LAx : PPCAsmPseudo<"la $rA, $addr", (ins gprc:$rA, memri:$addr)>;
3462 def SUBI : PPCAsmPseudo<"subi $rA, $rB, $imm",
3463 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
3464 def SUBIS : PPCAsmPseudo<"subis $rA, $rB, $imm",
3465 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
3466 def SUBIC : PPCAsmPseudo<"subic $rA, $rB, $imm",
3467 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
3468 def SUBICo : PPCAsmPseudo<"subic. $rA, $rB, $imm",
3469 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
3471 def : InstAlias<"sub $rA, $rB, $rC", (SUBF8 g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
3472 def : InstAlias<"sub. $rA, $rB, $rC", (SUBF8o g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
3473 def : InstAlias<"subc $rA, $rB, $rC", (SUBFC8 g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
3474 def : InstAlias<"subc. $rA, $rB, $rC", (SUBFC8o g8rc:$rA, g8rc:$rC, g8rc:$rB)>;
3476 def : InstAlias<"mtmsrd $RS", (MTMSRD gprc:$RS, 0)>;
3477 def : InstAlias<"mtmsr $RS", (MTMSR gprc:$RS, 0)>;
3479 def : InstAlias<"mfasr $RT", (MFSPR gprc:$RT, 280)>;
3480 def : InstAlias<"mtasr $RT", (MTSPR 280, gprc:$RT)>;
3482 foreach SPRG = 0-3 in {
3483 def : InstAlias<"mfsprg $RT, "#SPRG, (MFSPR gprc:$RT, !add(SPRG, 272))>;
3484 def : InstAlias<"mfsprg"#SPRG#" $RT", (MFSPR gprc:$RT, !add(SPRG, 272))>;
3485 def : InstAlias<"mtsprg "#SPRG#", $RT", (MTSPR !add(SPRG, 272), gprc:$RT)>;
3486 def : InstAlias<"mtsprg"#SPRG#" $RT", (MTSPR !add(SPRG, 272), gprc:$RT)>;
3488 foreach SPRG = 4-7 in {
3489 def : InstAlias<"mfsprg $RT, "#SPRG, (MFSPR gprc:$RT, !add(SPRG, 256))>,
3490 Requires<[IsBookE]>;
3491 def : InstAlias<"mfsprg"#SPRG#" $RT", (MFSPR gprc:$RT, !add(SPRG, 256))>,
3492 Requires<[IsBookE]>;
3493 def : InstAlias<"mtsprg "#SPRG#", $RT", (MTSPR !add(SPRG, 256), gprc:$RT)>,
3494 Requires<[IsBookE]>;
3495 def : InstAlias<"mtsprg"#SPRG#" $RT", (MTSPR !add(SPRG, 256), gprc:$RT)>,
3496 Requires<[IsBookE]>;
3499 def : InstAlias<"mtasr $RS", (MTSPR 280, gprc:$RS)>;
3501 def : InstAlias<"mfdec $RT", (MFSPR gprc:$RT, 22)>;
3502 def : InstAlias<"mtdec $RT", (MTSPR 22, gprc:$RT)>;
3504 def : InstAlias<"mfpvr $RT", (MFSPR gprc:$RT, 287)>;
3506 def : InstAlias<"mfsdr1 $RT", (MFSPR gprc:$RT, 25)>;
3507 def : InstAlias<"mtsdr1 $RT", (MTSPR 25, gprc:$RT)>;
3509 def : InstAlias<"mfsrr0 $RT", (MFSPR gprc:$RT, 26)>;
3510 def : InstAlias<"mfsrr1 $RT", (MFSPR gprc:$RT, 27)>;
3511 def : InstAlias<"mtsrr0 $RT", (MTSPR 26, gprc:$RT)>;
3512 def : InstAlias<"mtsrr1 $RT", (MTSPR 27, gprc:$RT)>;
3514 def : InstAlias<"tlbie $RB", (TLBIE R0, gprc:$RB)>;
3516 def : InstAlias<"tlbrehi $RS, $A", (TLBRE2 gprc:$RS, gprc:$A, 0)>,
3517 Requires<[IsPPC4xx]>;
3518 def : InstAlias<"tlbrelo $RS, $A", (TLBRE2 gprc:$RS, gprc:$A, 1)>,
3519 Requires<[IsPPC4xx]>;
3520 def : InstAlias<"tlbwehi $RS, $A", (TLBWE2 gprc:$RS, gprc:$A, 0)>,
3521 Requires<[IsPPC4xx]>;
3522 def : InstAlias<"tlbwelo $RS, $A", (TLBWE2 gprc:$RS, gprc:$A, 1)>,
3523 Requires<[IsPPC4xx]>;
3525 def EXTLWI : PPCAsmPseudo<"extlwi $rA, $rS, $n, $b",
3526 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
3527 def EXTLWIo : PPCAsmPseudo<"extlwi. $rA, $rS, $n, $b",
3528 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
3529 def EXTRWI : PPCAsmPseudo<"extrwi $rA, $rS, $n, $b",
3530 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
3531 def EXTRWIo : PPCAsmPseudo<"extrwi. $rA, $rS, $n, $b",
3532 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
3533 def INSLWI : PPCAsmPseudo<"inslwi $rA, $rS, $n, $b",
3534 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
3535 def INSLWIo : PPCAsmPseudo<"inslwi. $rA, $rS, $n, $b",
3536 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
3537 def INSRWI : PPCAsmPseudo<"insrwi $rA, $rS, $n, $b",
3538 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
3539 def INSRWIo : PPCAsmPseudo<"insrwi. $rA, $rS, $n, $b",
3540 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
3541 def ROTRWI : PPCAsmPseudo<"rotrwi $rA, $rS, $n",
3542 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
3543 def ROTRWIo : PPCAsmPseudo<"rotrwi. $rA, $rS, $n",
3544 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
3545 def SLWI : PPCAsmPseudo<"slwi $rA, $rS, $n",
3546 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
3547 def SLWIo : PPCAsmPseudo<"slwi. $rA, $rS, $n",
3548 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
3549 def SRWI : PPCAsmPseudo<"srwi $rA, $rS, $n",
3550 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
3551 def SRWIo : PPCAsmPseudo<"srwi. $rA, $rS, $n",
3552 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
3553 def CLRRWI : PPCAsmPseudo<"clrrwi $rA, $rS, $n",
3554 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
3555 def CLRRWIo : PPCAsmPseudo<"clrrwi. $rA, $rS, $n",
3556 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
3557 def CLRLSLWI : PPCAsmPseudo<"clrlslwi $rA, $rS, $b, $n",
3558 (ins gprc:$rA, gprc:$rS, u5imm:$b, u5imm:$n)>;
3559 def CLRLSLWIo : PPCAsmPseudo<"clrlslwi. $rA, $rS, $b, $n",
3560 (ins gprc:$rA, gprc:$rS, u5imm:$b, u5imm:$n)>;
3562 def : InstAlias<"rotlwi $rA, $rS, $n", (RLWINM gprc:$rA, gprc:$rS, u5imm:$n, 0, 31)>;
3563 def : InstAlias<"rotlwi. $rA, $rS, $n", (RLWINMo gprc:$rA, gprc:$rS, u5imm:$n, 0, 31)>;
3564 def : InstAlias<"rotlw $rA, $rS, $rB", (RLWNM gprc:$rA, gprc:$rS, gprc:$rB, 0, 31)>;
3565 def : InstAlias<"rotlw. $rA, $rS, $rB", (RLWNMo gprc:$rA, gprc:$rS, gprc:$rB, 0, 31)>;
3566 def : InstAlias<"clrlwi $rA, $rS, $n", (RLWINM gprc:$rA, gprc:$rS, 0, u5imm:$n, 31)>;
3567 def : InstAlias<"clrlwi. $rA, $rS, $n", (RLWINMo gprc:$rA, gprc:$rS, 0, u5imm:$n, 31)>;
3569 def : InstAlias<"cntlz $rA, $rS", (CNTLZW gprc:$rA, gprc:$rS)>;
3570 def : InstAlias<"cntlz. $rA, $rS", (CNTLZWo gprc:$rA, gprc:$rS)>;
3572 def EXTLDI : PPCAsmPseudo<"extldi $rA, $rS, $n, $b",
3573 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
3574 def EXTLDIo : PPCAsmPseudo<"extldi. $rA, $rS, $n, $b",
3575 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
3576 def EXTRDI : PPCAsmPseudo<"extrdi $rA, $rS, $n, $b",
3577 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
3578 def EXTRDIo : PPCAsmPseudo<"extrdi. $rA, $rS, $n, $b",
3579 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
3580 def INSRDI : PPCAsmPseudo<"insrdi $rA, $rS, $n, $b",
3581 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
3582 def INSRDIo : PPCAsmPseudo<"insrdi. $rA, $rS, $n, $b",
3583 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
3584 def ROTRDI : PPCAsmPseudo<"rotrdi $rA, $rS, $n",
3585 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
3586 def ROTRDIo : PPCAsmPseudo<"rotrdi. $rA, $rS, $n",
3587 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
3588 def SLDI : PPCAsmPseudo<"sldi $rA, $rS, $n",
3589 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
3590 def SLDIo : PPCAsmPseudo<"sldi. $rA, $rS, $n",
3591 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
3592 def SRDI : PPCAsmPseudo<"srdi $rA, $rS, $n",
3593 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
3594 def SRDIo : PPCAsmPseudo<"srdi. $rA, $rS, $n",
3595 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
3596 def CLRRDI : PPCAsmPseudo<"clrrdi $rA, $rS, $n",
3597 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
3598 def CLRRDIo : PPCAsmPseudo<"clrrdi. $rA, $rS, $n",
3599 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
3600 def CLRLSLDI : PPCAsmPseudo<"clrlsldi $rA, $rS, $b, $n",
3601 (ins g8rc:$rA, g8rc:$rS, u6imm:$b, u6imm:$n)>;
3602 def CLRLSLDIo : PPCAsmPseudo<"clrlsldi. $rA, $rS, $b, $n",
3603 (ins g8rc:$rA, g8rc:$rS, u6imm:$b, u6imm:$n)>;
3605 def : InstAlias<"rotldi $rA, $rS, $n", (RLDICL g8rc:$rA, g8rc:$rS, u6imm:$n, 0)>;
3606 def : InstAlias<"rotldi. $rA, $rS, $n", (RLDICLo g8rc:$rA, g8rc:$rS, u6imm:$n, 0)>;
3607 def : InstAlias<"rotld $rA, $rS, $rB", (RLDCL g8rc:$rA, g8rc:$rS, gprc:$rB, 0)>;
3608 def : InstAlias<"rotld. $rA, $rS, $rB", (RLDCLo g8rc:$rA, g8rc:$rS, gprc:$rB, 0)>;
3609 def : InstAlias<"clrldi $rA, $rS, $n", (RLDICL g8rc:$rA, g8rc:$rS, 0, u6imm:$n)>;
3610 def : InstAlias<"clrldi. $rA, $rS, $n", (RLDICLo g8rc:$rA, g8rc:$rS, 0, u6imm:$n)>;
3612 // These generic branch instruction forms are used for the assembler parser only.
3613 // Defs and Uses are conservative, since we don't know the BO value.
3614 let PPC970_Unit = 7 in {
3615 let Defs = [CTR], Uses = [CTR, RM] in {
3616 def gBC : BForm_3<16, 0, 0, (outs),
3617 (ins u5imm:$bo, crbitrc:$bi, condbrtarget:$dst),
3618 "bc $bo, $bi, $dst">;
3619 def gBCA : BForm_3<16, 1, 0, (outs),
3620 (ins u5imm:$bo, crbitrc:$bi, abscondbrtarget:$dst),
3621 "bca $bo, $bi, $dst">;
3623 let Defs = [LR, CTR], Uses = [CTR, RM] in {
3624 def gBCL : BForm_3<16, 0, 1, (outs),
3625 (ins u5imm:$bo, crbitrc:$bi, condbrtarget:$dst),
3626 "bcl $bo, $bi, $dst">;
3627 def gBCLA : BForm_3<16, 1, 1, (outs),
3628 (ins u5imm:$bo, crbitrc:$bi, abscondbrtarget:$dst),
3629 "bcla $bo, $bi, $dst">;
3631 let Defs = [CTR], Uses = [CTR, LR, RM] in
3632 def gBCLR : XLForm_2<19, 16, 0, (outs),
3633 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
3634 "bclr $bo, $bi, $bh", IIC_BrB, []>;
3635 let Defs = [LR, CTR], Uses = [CTR, LR, RM] in
3636 def gBCLRL : XLForm_2<19, 16, 1, (outs),
3637 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
3638 "bclrl $bo, $bi, $bh", IIC_BrB, []>;
3639 let Defs = [CTR], Uses = [CTR, LR, RM] in
3640 def gBCCTR : XLForm_2<19, 528, 0, (outs),
3641 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
3642 "bcctr $bo, $bi, $bh", IIC_BrB, []>;
3643 let Defs = [LR, CTR], Uses = [CTR, LR, RM] in
3644 def gBCCTRL : XLForm_2<19, 528, 1, (outs),
3645 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh),
3646 "bcctrl $bo, $bi, $bh", IIC_BrB, []>;
3648 def : InstAlias<"bclr $bo, $bi", (gBCLR u5imm:$bo, crbitrc:$bi, 0)>;
3649 def : InstAlias<"bclrl $bo, $bi", (gBCLRL u5imm:$bo, crbitrc:$bi, 0)>;
3650 def : InstAlias<"bcctr $bo, $bi", (gBCCTR u5imm:$bo, crbitrc:$bi, 0)>;
3651 def : InstAlias<"bcctrl $bo, $bi", (gBCCTRL u5imm:$bo, crbitrc:$bi, 0)>;
3653 multiclass BranchSimpleMnemonic1<string name, string pm, int bo> {
3654 def : InstAlias<"b"#name#pm#" $bi, $dst", (gBC bo, crbitrc:$bi, condbrtarget:$dst)>;
3655 def : InstAlias<"b"#name#"a"#pm#" $bi, $dst", (gBCA bo, crbitrc:$bi, abscondbrtarget:$dst)>;
3656 def : InstAlias<"b"#name#"lr"#pm#" $bi", (gBCLR bo, crbitrc:$bi, 0)>;
3657 def : InstAlias<"b"#name#"l"#pm#" $bi, $dst", (gBCL bo, crbitrc:$bi, condbrtarget:$dst)>;
3658 def : InstAlias<"b"#name#"la"#pm#" $bi, $dst", (gBCLA bo, crbitrc:$bi, abscondbrtarget:$dst)>;
3659 def : InstAlias<"b"#name#"lrl"#pm#" $bi", (gBCLRL bo, crbitrc:$bi, 0)>;
3661 multiclass BranchSimpleMnemonic2<string name, string pm, int bo>
3662 : BranchSimpleMnemonic1<name, pm, bo> {
3663 def : InstAlias<"b"#name#"ctr"#pm#" $bi", (gBCCTR bo, crbitrc:$bi, 0)>;
3664 def : InstAlias<"b"#name#"ctrl"#pm#" $bi", (gBCCTRL bo, crbitrc:$bi, 0)>;
3666 defm : BranchSimpleMnemonic2<"t", "", 12>;
3667 defm : BranchSimpleMnemonic2<"f", "", 4>;
3668 defm : BranchSimpleMnemonic2<"t", "-", 14>;
3669 defm : BranchSimpleMnemonic2<"f", "-", 6>;
3670 defm : BranchSimpleMnemonic2<"t", "+", 15>;
3671 defm : BranchSimpleMnemonic2<"f", "+", 7>;
3672 defm : BranchSimpleMnemonic1<"dnzt", "", 8>;
3673 defm : BranchSimpleMnemonic1<"dnzf", "", 0>;
3674 defm : BranchSimpleMnemonic1<"dzt", "", 10>;
3675 defm : BranchSimpleMnemonic1<"dzf", "", 2>;
3677 multiclass BranchExtendedMnemonicPM<string name, string pm, int bibo> {
3678 def : InstAlias<"b"#name#pm#" $cc, $dst",
3679 (BCC bibo, crrc:$cc, condbrtarget:$dst)>;
3680 def : InstAlias<"b"#name#pm#" $dst",
3681 (BCC bibo, CR0, condbrtarget:$dst)>;
3683 def : InstAlias<"b"#name#"a"#pm#" $cc, $dst",
3684 (BCCA bibo, crrc:$cc, abscondbrtarget:$dst)>;
3685 def : InstAlias<"b"#name#"a"#pm#" $dst",
3686 (BCCA bibo, CR0, abscondbrtarget:$dst)>;
3688 def : InstAlias<"b"#name#"lr"#pm#" $cc",
3689 (BCCLR bibo, crrc:$cc)>;
3690 def : InstAlias<"b"#name#"lr"#pm,
3693 def : InstAlias<"b"#name#"ctr"#pm#" $cc",
3694 (BCCCTR bibo, crrc:$cc)>;
3695 def : InstAlias<"b"#name#"ctr"#pm,
3696 (BCCCTR bibo, CR0)>;
3698 def : InstAlias<"b"#name#"l"#pm#" $cc, $dst",
3699 (BCCL bibo, crrc:$cc, condbrtarget:$dst)>;
3700 def : InstAlias<"b"#name#"l"#pm#" $dst",
3701 (BCCL bibo, CR0, condbrtarget:$dst)>;
3703 def : InstAlias<"b"#name#"la"#pm#" $cc, $dst",
3704 (BCCLA bibo, crrc:$cc, abscondbrtarget:$dst)>;
3705 def : InstAlias<"b"#name#"la"#pm#" $dst",
3706 (BCCLA bibo, CR0, abscondbrtarget:$dst)>;
3708 def : InstAlias<"b"#name#"lrl"#pm#" $cc",
3709 (BCCLRL bibo, crrc:$cc)>;
3710 def : InstAlias<"b"#name#"lrl"#pm,
3711 (BCCLRL bibo, CR0)>;
3713 def : InstAlias<"b"#name#"ctrl"#pm#" $cc",
3714 (BCCCTRL bibo, crrc:$cc)>;
3715 def : InstAlias<"b"#name#"ctrl"#pm,
3716 (BCCCTRL bibo, CR0)>;
3718 multiclass BranchExtendedMnemonic<string name, int bibo> {
3719 defm : BranchExtendedMnemonicPM<name, "", bibo>;
3720 defm : BranchExtendedMnemonicPM<name, "-", !add(bibo, 2)>;
3721 defm : BranchExtendedMnemonicPM<name, "+", !add(bibo, 3)>;
3723 defm : BranchExtendedMnemonic<"lt", 12>;
3724 defm : BranchExtendedMnemonic<"gt", 44>;
3725 defm : BranchExtendedMnemonic<"eq", 76>;
3726 defm : BranchExtendedMnemonic<"un", 108>;
3727 defm : BranchExtendedMnemonic<"so", 108>;
3728 defm : BranchExtendedMnemonic<"ge", 4>;
3729 defm : BranchExtendedMnemonic<"nl", 4>;
3730 defm : BranchExtendedMnemonic<"le", 36>;
3731 defm : BranchExtendedMnemonic<"ng", 36>;
3732 defm : BranchExtendedMnemonic<"ne", 68>;
3733 defm : BranchExtendedMnemonic<"nu", 100>;
3734 defm : BranchExtendedMnemonic<"ns", 100>;
3736 def : InstAlias<"cmpwi $rA, $imm", (CMPWI CR0, gprc:$rA, s16imm:$imm)>;
3737 def : InstAlias<"cmpw $rA, $rB", (CMPW CR0, gprc:$rA, gprc:$rB)>;
3738 def : InstAlias<"cmplwi $rA, $imm", (CMPLWI CR0, gprc:$rA, u16imm:$imm)>;
3739 def : InstAlias<"cmplw $rA, $rB", (CMPLW CR0, gprc:$rA, gprc:$rB)>;
3740 def : InstAlias<"cmpdi $rA, $imm", (CMPDI CR0, g8rc:$rA, s16imm64:$imm)>;
3741 def : InstAlias<"cmpd $rA, $rB", (CMPD CR0, g8rc:$rA, g8rc:$rB)>;
3742 def : InstAlias<"cmpldi $rA, $imm", (CMPLDI CR0, g8rc:$rA, u16imm64:$imm)>;
3743 def : InstAlias<"cmpld $rA, $rB", (CMPLD CR0, g8rc:$rA, g8rc:$rB)>;
3745 def : InstAlias<"cmpi $bf, 0, $rA, $imm", (CMPWI crrc:$bf, gprc:$rA, s16imm:$imm)>;
3746 def : InstAlias<"cmp $bf, 0, $rA, $rB", (CMPW crrc:$bf, gprc:$rA, gprc:$rB)>;
3747 def : InstAlias<"cmpli $bf, 0, $rA, $imm", (CMPLWI crrc:$bf, gprc:$rA, u16imm:$imm)>;
3748 def : InstAlias<"cmpl $bf, 0, $rA, $rB", (CMPLW crrc:$bf, gprc:$rA, gprc:$rB)>;
3749 def : InstAlias<"cmpi $bf, 1, $rA, $imm", (CMPDI crrc:$bf, g8rc:$rA, s16imm64:$imm)>;
3750 def : InstAlias<"cmp $bf, 1, $rA, $rB", (CMPD crrc:$bf, g8rc:$rA, g8rc:$rB)>;
3751 def : InstAlias<"cmpli $bf, 1, $rA, $imm", (CMPLDI crrc:$bf, g8rc:$rA, u16imm64:$imm)>;
3752 def : InstAlias<"cmpl $bf, 1, $rA, $rB", (CMPLD crrc:$bf, g8rc:$rA, g8rc:$rB)>;
3754 multiclass TrapExtendedMnemonic<string name, int to> {
3755 def : InstAlias<"td"#name#"i $rA, $imm", (TDI to, g8rc:$rA, s16imm:$imm)>;
3756 def : InstAlias<"td"#name#" $rA, $rB", (TD to, g8rc:$rA, g8rc:$rB)>;
3757 def : InstAlias<"tw"#name#"i $rA, $imm", (TWI to, gprc:$rA, s16imm:$imm)>;
3758 def : InstAlias<"tw"#name#" $rA, $rB", (TW to, gprc:$rA, gprc:$rB)>;
3760 defm : TrapExtendedMnemonic<"lt", 16>;
3761 defm : TrapExtendedMnemonic<"le", 20>;
3762 defm : TrapExtendedMnemonic<"eq", 4>;
3763 defm : TrapExtendedMnemonic<"ge", 12>;
3764 defm : TrapExtendedMnemonic<"gt", 8>;
3765 defm : TrapExtendedMnemonic<"nl", 12>;
3766 defm : TrapExtendedMnemonic<"ne", 24>;
3767 defm : TrapExtendedMnemonic<"ng", 20>;
3768 defm : TrapExtendedMnemonic<"llt", 2>;
3769 defm : TrapExtendedMnemonic<"lle", 6>;
3770 defm : TrapExtendedMnemonic<"lge", 5>;
3771 defm : TrapExtendedMnemonic<"lgt", 1>;
3772 defm : TrapExtendedMnemonic<"lnl", 5>;
3773 defm : TrapExtendedMnemonic<"lng", 6>;
3774 defm : TrapExtendedMnemonic<"u", 31>;
3777 def : Pat<(atomic_load_8 iaddr:$src), (LBZ memri:$src)>;
3778 def : Pat<(atomic_load_16 iaddr:$src), (LHZ memri:$src)>;
3779 def : Pat<(atomic_load_32 iaddr:$src), (LWZ memri:$src)>;
3780 def : Pat<(atomic_load_8 xaddr:$src), (LBZX memrr:$src)>;
3781 def : Pat<(atomic_load_16 xaddr:$src), (LHZX memrr:$src)>;
3782 def : Pat<(atomic_load_32 xaddr:$src), (LWZX memrr:$src)>;
3785 def : Pat<(atomic_store_8 iaddr:$ptr, i32:$val), (STB gprc:$val, memri:$ptr)>;
3786 def : Pat<(atomic_store_16 iaddr:$ptr, i32:$val), (STH gprc:$val, memri:$ptr)>;
3787 def : Pat<(atomic_store_32 iaddr:$ptr, i32:$val), (STW gprc:$val, memri:$ptr)>;
3788 def : Pat<(atomic_store_8 xaddr:$ptr, i32:$val), (STBX gprc:$val, memrr:$ptr)>;
3789 def : Pat<(atomic_store_16 xaddr:$ptr, i32:$val), (STHX gprc:$val, memrr:$ptr)>;
3790 def : Pat<(atomic_store_32 xaddr:$ptr, i32:$val), (STWX gprc:$val, memrr:$ptr)>;