This patch fixes the Altivec addend construction for the fused multiply-add
[oota-llvm.git] / lib / Target / PowerPC / PPCInstrInfo.td
1 //===-- PPCInstrInfo.td - The PowerPC Instruction Set ------*- tablegen -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file describes the subset of the 32-bit PowerPC instruction set, as used
11 // by the PowerPC instruction selector.
12 //
13 //===----------------------------------------------------------------------===//
14
15 include "PPCInstrFormats.td"
16
17 //===----------------------------------------------------------------------===//
18 // PowerPC specific type constraints.
19 //
20 def SDT_PPCstfiwx : SDTypeProfile<0, 2, [ // stfiwx
21   SDTCisVT<0, f64>, SDTCisPtrTy<1>
22 ]>;
23 def SDT_PPCCallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
24 def SDT_PPCCallSeqEnd   : SDCallSeqEnd<[ SDTCisVT<0, i32>,
25                                          SDTCisVT<1, i32> ]>;
26 def SDT_PPCvperm   : SDTypeProfile<1, 3, [
27   SDTCisVT<3, v16i8>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>
28 ]>;
29
30 def SDT_PPCvcmp : SDTypeProfile<1, 3, [
31   SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisVT<3, i32>
32 ]>;
33
34 def SDT_PPCcondbr : SDTypeProfile<0, 3, [
35   SDTCisVT<0, i32>, SDTCisVT<2, OtherVT>
36 ]>;
37
38 def SDT_PPClbrx : SDTypeProfile<1, 2, [
39   SDTCisVT<0, i32>, SDTCisPtrTy<1>, SDTCisVT<2, OtherVT>
40 ]>;
41 def SDT_PPCstbrx : SDTypeProfile<0, 3, [
42   SDTCisVT<0, i32>, SDTCisPtrTy<1>, SDTCisVT<2, OtherVT>
43 ]>;
44
45 def SDT_PPClarx : SDTypeProfile<1, 1, [
46   SDTCisInt<0>, SDTCisPtrTy<1>
47 ]>;
48 def SDT_PPCstcx : SDTypeProfile<0, 2, [
49   SDTCisInt<0>, SDTCisPtrTy<1>
50 ]>;
51
52 def SDT_PPCTC_ret : SDTypeProfile<0, 2, [
53   SDTCisPtrTy<0>, SDTCisVT<1, i32>
54 ]>;
55
56 def SDT_PPCnop : SDTypeProfile<0, 0, []>;
57
58 //===----------------------------------------------------------------------===//
59 // PowerPC specific DAG Nodes.
60 //
61
62 def PPCfcfid  : SDNode<"PPCISD::FCFID" , SDTFPUnaryOp, []>;
63 def PPCfctidz : SDNode<"PPCISD::FCTIDZ", SDTFPUnaryOp, []>;
64 def PPCfctiwz : SDNode<"PPCISD::FCTIWZ", SDTFPUnaryOp, []>;
65 def PPCstfiwx : SDNode<"PPCISD::STFIWX", SDT_PPCstfiwx,
66                        [SDNPHasChain, SDNPMayStore]>;
67
68 // This sequence is used for long double->int conversions.  It changes the
69 // bits in the FPSCR which is not modelled.  
70 def PPCmffs   : SDNode<"PPCISD::MFFS", SDTypeProfile<1, 0, [SDTCisVT<0, f64>]>,
71                         [SDNPOutGlue]>;
72 def PPCmtfsb0 : SDNode<"PPCISD::MTFSB0", SDTypeProfile<0, 1, [SDTCisInt<0>]>,
73                        [SDNPInGlue, SDNPOutGlue]>;
74 def PPCmtfsb1 : SDNode<"PPCISD::MTFSB1", SDTypeProfile<0, 1, [SDTCisInt<0>]>,
75                        [SDNPInGlue, SDNPOutGlue]>;
76 def PPCfaddrtz: SDNode<"PPCISD::FADDRTZ", SDTFPBinOp,
77                        [SDNPInGlue, SDNPOutGlue]>;
78 def PPCmtfsf  : SDNode<"PPCISD::MTFSF", SDTypeProfile<1, 3, 
79                        [SDTCisVT<0, f64>, SDTCisInt<1>, SDTCisVT<2, f64>,
80                         SDTCisVT<3, f64>]>,
81                        [SDNPInGlue]>;
82
83 def PPCfsel   : SDNode<"PPCISD::FSEL",  
84    // Type constraint for fsel.
85    SDTypeProfile<1, 3, [SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>, 
86                         SDTCisFP<0>, SDTCisVT<1, f64>]>, []>;
87
88 def PPChi       : SDNode<"PPCISD::Hi", SDTIntBinOp, []>;
89 def PPClo       : SDNode<"PPCISD::Lo", SDTIntBinOp, []>;
90 def PPCtoc_entry: SDNode<"PPCISD::TOC_ENTRY", SDTIntBinOp, [SDNPMayLoad]>;
91 def PPCvmaddfp  : SDNode<"PPCISD::VMADDFP", SDTFPTernaryOp, []>;
92 def PPCvnmsubfp : SDNode<"PPCISD::VNMSUBFP", SDTFPTernaryOp, []>;
93
94 def PPCvperm    : SDNode<"PPCISD::VPERM", SDT_PPCvperm, []>;
95
96 // These nodes represent the 32-bit PPC shifts that operate on 6-bit shift
97 // amounts.  These nodes are generated by the multi-precision shift code.
98 def PPCsrl        : SDNode<"PPCISD::SRL"       , SDTIntShiftOp>;
99 def PPCsra        : SDNode<"PPCISD::SRA"       , SDTIntShiftOp>;
100 def PPCshl        : SDNode<"PPCISD::SHL"       , SDTIntShiftOp>;
101
102 def PPCextsw_32   : SDNode<"PPCISD::EXTSW_32"  , SDTIntUnaryOp>;
103 def PPCstd_32     : SDNode<"PPCISD::STD_32"    , SDTStore,
104                            [SDNPHasChain, SDNPMayStore]>;
105
106 // These are target-independent nodes, but have target-specific formats.
107 def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_PPCCallSeqStart,
108                            [SDNPHasChain, SDNPOutGlue]>;
109 def callseq_end   : SDNode<"ISD::CALLSEQ_END",   SDT_PPCCallSeqEnd,
110                            [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
111
112 def SDT_PPCCall   : SDTypeProfile<0, -1, [SDTCisInt<0>]>;
113 def PPCcall_Darwin : SDNode<"PPCISD::CALL_Darwin", SDT_PPCCall,
114                             [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
115                              SDNPVariadic]>;
116 def PPCcall_SVR4  : SDNode<"PPCISD::CALL_SVR4", SDT_PPCCall,
117                            [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
118                             SDNPVariadic]>;
119 def PPCcall_nop_SVR4  : SDNode<"PPCISD::CALL_NOP_SVR4", SDT_PPCCall,
120                                [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
121                                 SDNPVariadic]>;
122 def PPCnop : SDNode<"PPCISD::NOP", SDT_PPCnop, [SDNPInGlue, SDNPOutGlue]>;
123 def PPCload   : SDNode<"PPCISD::LOAD", SDTypeProfile<1, 1, []>,
124                        [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
125 def PPCload_toc : SDNode<"PPCISD::LOAD_TOC", SDTypeProfile<0, 1, []>,
126                           [SDNPHasChain, SDNPSideEffect,
127                            SDNPInGlue, SDNPOutGlue]>;
128 def PPCtoc_restore : SDNode<"PPCISD::TOC_RESTORE", SDTypeProfile<0, 0, []>,
129                             [SDNPHasChain, SDNPSideEffect,
130                              SDNPInGlue, SDNPOutGlue]>;
131 def PPCmtctr      : SDNode<"PPCISD::MTCTR", SDT_PPCCall,
132                            [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
133 def PPCbctrl_Darwin  : SDNode<"PPCISD::BCTRL_Darwin", SDTNone,
134                               [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
135                                SDNPVariadic]>;
136
137 def PPCbctrl_SVR4  : SDNode<"PPCISD::BCTRL_SVR4", SDTNone,
138                             [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
139                              SDNPVariadic]>;
140
141 def retflag       : SDNode<"PPCISD::RET_FLAG", SDTNone,
142                            [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
143
144 def PPCtc_return : SDNode<"PPCISD::TC_RETURN", SDT_PPCTC_ret,
145                         [SDNPHasChain,  SDNPOptInGlue, SDNPVariadic]>;
146
147 def PPCvcmp       : SDNode<"PPCISD::VCMP" , SDT_PPCvcmp, []>;
148 def PPCvcmp_o     : SDNode<"PPCISD::VCMPo", SDT_PPCvcmp, [SDNPOutGlue]>;
149
150 def PPCcondbranch : SDNode<"PPCISD::COND_BRANCH", SDT_PPCcondbr,
151                            [SDNPHasChain, SDNPOptInGlue]>;
152
153 def PPClbrx       : SDNode<"PPCISD::LBRX", SDT_PPClbrx,
154                            [SDNPHasChain, SDNPMayLoad]>;
155 def PPCstbrx      : SDNode<"PPCISD::STBRX", SDT_PPCstbrx,
156                            [SDNPHasChain, SDNPMayStore]>;
157
158 // Instructions to set/unset CR bit 6 for SVR4 vararg calls
159 def PPCcr6set   : SDNode<"PPCISD::CR6SET", SDTNone,
160                          [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
161 def PPCcr6unset : SDNode<"PPCISD::CR6UNSET", SDTNone,
162                          [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
163
164 // Instructions to support atomic operations
165 def PPClarx      : SDNode<"PPCISD::LARX", SDT_PPClarx,
166                           [SDNPHasChain, SDNPMayLoad]>;
167 def PPCstcx      : SDNode<"PPCISD::STCX", SDT_PPCstcx,
168                           [SDNPHasChain, SDNPMayStore]>;
169
170 // Instructions to support medium code model
171 def PPCaddisTocHA : SDNode<"PPCISD::ADDIS_TOC_HA", SDTIntBinOp, []>;
172 def PPCldTocL     : SDNode<"PPCISD::LD_TOC_L", SDTIntBinOp, [SDNPMayLoad]>;
173 def PPCaddiTocL   : SDNode<"PPCISD::ADDI_TOC_L", SDTIntBinOp, []>;
174
175
176 // Instructions to support dynamic alloca.
177 def SDTDynOp  : SDTypeProfile<1, 2, []>;
178 def PPCdynalloc   : SDNode<"PPCISD::DYNALLOC", SDTDynOp, [SDNPHasChain]>;
179
180 //===----------------------------------------------------------------------===//
181 // PowerPC specific transformation functions and pattern fragments.
182 //
183
184 def SHL32 : SDNodeXForm<imm, [{
185   // Transformation function: 31 - imm
186   return getI32Imm(31 - N->getZExtValue());
187 }]>;
188
189 def SRL32 : SDNodeXForm<imm, [{
190   // Transformation function: 32 - imm
191   return N->getZExtValue() ? getI32Imm(32 - N->getZExtValue()) : getI32Imm(0);
192 }]>;
193
194 def LO16 : SDNodeXForm<imm, [{
195   // Transformation function: get the low 16 bits.
196   return getI32Imm((unsigned short)N->getZExtValue());
197 }]>;
198
199 def HI16 : SDNodeXForm<imm, [{
200   // Transformation function: shift the immediate value down into the low bits.
201   return getI32Imm((unsigned)N->getZExtValue() >> 16);
202 }]>;
203
204 def HA16 : SDNodeXForm<imm, [{
205   // Transformation function: shift the immediate value down into the low bits.
206   signed int Val = N->getZExtValue();
207   return getI32Imm((Val - (signed short)Val) >> 16);
208 }]>;
209 def MB : SDNodeXForm<imm, [{
210   // Transformation function: get the start bit of a mask
211   unsigned mb = 0, me;
212   (void)isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
213   return getI32Imm(mb);
214 }]>;
215
216 def ME : SDNodeXForm<imm, [{
217   // Transformation function: get the end bit of a mask
218   unsigned mb, me = 0;
219   (void)isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
220   return getI32Imm(me);
221 }]>;
222 def maskimm32 : PatLeaf<(imm), [{
223   // maskImm predicate - True if immediate is a run of ones.
224   unsigned mb, me;
225   if (N->getValueType(0) == MVT::i32)
226     return isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
227   else
228     return false;
229 }]>;
230
231 def immSExt16  : PatLeaf<(imm), [{
232   // immSExt16 predicate - True if the immediate fits in a 16-bit sign extended
233   // field.  Used by instructions like 'addi'.
234   if (N->getValueType(0) == MVT::i32)
235     return (int32_t)N->getZExtValue() == (short)N->getZExtValue();
236   else
237     return (int64_t)N->getZExtValue() == (short)N->getZExtValue();
238 }]>;
239 def immZExt16  : PatLeaf<(imm), [{
240   // immZExt16 predicate - True if the immediate fits in a 16-bit zero extended
241   // field.  Used by instructions like 'ori'.
242   return (uint64_t)N->getZExtValue() == (unsigned short)N->getZExtValue();
243 }], LO16>;
244
245 // imm16Shifted* - These match immediates where the low 16-bits are zero.  There
246 // are two forms: imm16ShiftedSExt and imm16ShiftedZExt.  These two forms are
247 // identical in 32-bit mode, but in 64-bit mode, they return true if the
248 // immediate fits into a sign/zero extended 32-bit immediate (with the low bits
249 // clear).
250 def imm16ShiftedZExt : PatLeaf<(imm), [{
251   // imm16ShiftedZExt predicate - True if only bits in the top 16-bits of the
252   // immediate are set.  Used by instructions like 'xoris'.
253   return (N->getZExtValue() & ~uint64_t(0xFFFF0000)) == 0;
254 }], HI16>;
255
256 def imm16ShiftedSExt : PatLeaf<(imm), [{
257   // imm16ShiftedSExt predicate - True if only bits in the top 16-bits of the
258   // immediate are set.  Used by instructions like 'addis'.  Identical to 
259   // imm16ShiftedZExt in 32-bit mode.
260   if (N->getZExtValue() & 0xFFFF) return false;
261   if (N->getValueType(0) == MVT::i32)
262     return true;
263   // For 64-bit, make sure it is sext right.
264   return N->getZExtValue() == (uint64_t)(int)N->getZExtValue();
265 }], HI16>;
266
267
268 //===----------------------------------------------------------------------===//
269 // PowerPC Flag Definitions.
270
271 class isPPC64 { bit PPC64 = 1; }
272 class isDOT   {
273   list<Register> Defs = [CR0];
274   bit RC  = 1;
275 }
276
277 class RegConstraint<string C> {
278   string Constraints = C;
279 }
280 class NoEncode<string E> {
281   string DisableEncoding = E;
282 }
283
284
285 //===----------------------------------------------------------------------===//
286 // PowerPC Operand Definitions.
287
288 def s5imm   : Operand<i32> {
289   let PrintMethod = "printS5ImmOperand";
290 }
291 def u5imm   : Operand<i32> {
292   let PrintMethod = "printU5ImmOperand";
293 }
294 def u6imm   : Operand<i32> {
295   let PrintMethod = "printU6ImmOperand";
296 }
297 def s16imm  : Operand<i32> {
298   let PrintMethod = "printS16ImmOperand";
299 }
300 def u16imm  : Operand<i32> {
301   let PrintMethod = "printU16ImmOperand";
302 }
303 def s16immX4  : Operand<i32> {   // Multiply imm by 4 before printing.
304   let PrintMethod = "printS16X4ImmOperand";
305 }
306 def directbrtarget : Operand<OtherVT> {
307   let PrintMethod = "printBranchOperand";
308   let EncoderMethod = "getDirectBrEncoding";
309 }
310 def condbrtarget : Operand<OtherVT> {
311   let PrintMethod = "printBranchOperand";
312   let EncoderMethod = "getCondBrEncoding";
313 }
314 def calltarget : Operand<iPTR> {
315   let EncoderMethod = "getDirectBrEncoding";
316 }
317 def aaddr : Operand<iPTR> {
318   let PrintMethod = "printAbsAddrOperand";
319 }
320 def symbolHi: Operand<i32> {
321   let PrintMethod = "printSymbolHi";
322   let EncoderMethod = "getHA16Encoding";
323 }
324 def symbolLo: Operand<i32> {
325   let PrintMethod = "printSymbolLo";
326   let EncoderMethod = "getLO16Encoding";
327 }
328 def crbitm: Operand<i8> {
329   let PrintMethod = "printcrbitm";
330   let EncoderMethod = "get_crbitm_encoding";
331 }
332 // Address operands
333 def memri : Operand<iPTR> {
334   let PrintMethod = "printMemRegImm";
335   let MIOperandInfo = (ops i32imm:$imm, ptr_rc:$reg);
336   let EncoderMethod = "getMemRIEncoding";
337 }
338 def memrr : Operand<iPTR> {
339   let PrintMethod = "printMemRegReg";
340   let MIOperandInfo = (ops ptr_rc:$offreg, ptr_rc:$ptrreg);
341 }
342 def memrix : Operand<iPTR> {   // memri where the imm is shifted 2 bits.
343   let PrintMethod = "printMemRegImmShifted";
344   let MIOperandInfo = (ops i32imm:$imm, ptr_rc:$reg);
345   let EncoderMethod = "getMemRIXEncoding";
346 }
347
348 // PowerPC Predicate operand.  20 = (0<<5)|20 = always, CR0 is a dummy reg
349 // that doesn't matter.
350 def pred : PredicateOperand<OtherVT, (ops imm, CRRC),
351                                      (ops (i32 20), (i32 zero_reg))> {
352   let PrintMethod = "printPredicateOperand";
353 }
354
355 // Define PowerPC specific addressing mode.
356 def iaddr  : ComplexPattern<iPTR, 2, "SelectAddrImm",    [], []>;
357 def xaddr  : ComplexPattern<iPTR, 2, "SelectAddrIdx",    [], []>;
358 def xoaddr : ComplexPattern<iPTR, 2, "SelectAddrIdxOnly",[], []>;
359 def ixaddr : ComplexPattern<iPTR, 2, "SelectAddrImmShift", [], []>; // "std"
360
361 /// This is just the offset part of iaddr, used for preinc.
362 def iaddroff : ComplexPattern<iPTR, 1, "SelectAddrImmOffs", [], []>;
363 def xaddroff : ComplexPattern<iPTR, 1, "SelectAddrIdxOffs", [], []>;
364
365 //===----------------------------------------------------------------------===//
366 // PowerPC Instruction Predicate Definitions.
367 def In32BitMode  : Predicate<"!PPCSubTarget.isPPC64()">;
368 def In64BitMode  : Predicate<"PPCSubTarget.isPPC64()">;
369 def IsBookE  : Predicate<"PPCSubTarget.isBookE()">;
370
371 //===----------------------------------------------------------------------===//
372 // PowerPC Instruction Definitions.
373
374 // Pseudo-instructions:
375
376 let hasCtrlDep = 1 in {
377 let Defs = [R1], Uses = [R1] in {
378 def ADJCALLSTACKDOWN : Pseudo<(outs), (ins u16imm:$amt), "#ADJCALLSTACKDOWN $amt",
379                               [(callseq_start timm:$amt)]>;
380 def ADJCALLSTACKUP   : Pseudo<(outs), (ins u16imm:$amt1, u16imm:$amt2), "#ADJCALLSTACKUP $amt1 $amt2",
381                               [(callseq_end timm:$amt1, timm:$amt2)]>;
382 }
383
384 def UPDATE_VRSAVE    : Pseudo<(outs GPRC:$rD), (ins GPRC:$rS),
385                               "UPDATE_VRSAVE $rD, $rS", []>;
386 }
387
388 let Defs = [R1], Uses = [R1] in
389 def DYNALLOC : Pseudo<(outs GPRC:$result), (ins GPRC:$negsize, memri:$fpsi), "#DYNALLOC",
390                        [(set GPRC:$result,
391                              (PPCdynalloc GPRC:$negsize, iaddr:$fpsi))]>;
392                          
393 // SELECT_CC_* - Used to implement the SELECT_CC DAG operation.  Expanded after
394 // instruction selection into a branch sequence.
395 let usesCustomInserter = 1,    // Expanded after instruction selection.
396     PPC970_Single = 1 in {
397   def SELECT_CC_I4 : Pseudo<(outs GPRC:$dst), (ins CRRC:$cond, GPRC:$T, GPRC:$F,
398                               i32imm:$BROPC), "#SELECT_CC_I4",
399                               []>;
400   def SELECT_CC_I8 : Pseudo<(outs G8RC:$dst), (ins CRRC:$cond, G8RC:$T, G8RC:$F,
401                               i32imm:$BROPC), "#SELECT_CC_I8",
402                               []>;
403   def SELECT_CC_F4  : Pseudo<(outs F4RC:$dst), (ins CRRC:$cond, F4RC:$T, F4RC:$F,
404                               i32imm:$BROPC), "#SELECT_CC_F4",
405                               []>;
406   def SELECT_CC_F8  : Pseudo<(outs F8RC:$dst), (ins CRRC:$cond, F8RC:$T, F8RC:$F,
407                               i32imm:$BROPC), "#SELECT_CC_F8",
408                               []>;
409   def SELECT_CC_VRRC: Pseudo<(outs VRRC:$dst), (ins CRRC:$cond, VRRC:$T, VRRC:$F,
410                               i32imm:$BROPC), "#SELECT_CC_VRRC",
411                               []>;
412 }
413
414 // SPILL_CR - Indicate that we're dumping the CR register, so we'll need to
415 // scavenge a register for it.
416 let mayStore = 1 in
417 def SPILL_CR : Pseudo<(outs), (ins CRRC:$cond, memri:$F),
418                      "#SPILL_CR", []>;
419
420 // RESTORE_CR - Indicate that we're restoring the CR register (previously
421 // spilled), so we'll need to scavenge a register for it.
422 let mayLoad = 1 in
423 def RESTORE_CR : Pseudo<(outs CRRC:$cond), (ins memri:$F),
424                      "#RESTORE_CR", []>;
425
426 let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7 in {
427   let isCodeGenOnly = 1, isReturn = 1, Uses = [LR, RM] in
428     def BLR : XLForm_2_br<19, 16, 0, (outs), (ins pred:$p),
429                           "b${p:cc}lr ${p:reg}", BrB, 
430                           [(retflag)]>;
431   let isBranch = 1, isIndirectBranch = 1, Uses = [CTR] in
432     def BCTR : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", BrB, []>;
433 }
434
435 let Defs = [LR] in
436   def MovePCtoLR : Pseudo<(outs), (ins), "#MovePCtoLR", []>,
437                    PPC970_Unit_BRU;
438
439 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7 in {
440   let isBarrier = 1 in {
441   def B   : IForm<18, 0, 0, (outs), (ins directbrtarget:$dst),
442                   "b $dst", BrB,
443                   [(br bb:$dst)]>;
444   }
445
446   // BCC represents an arbitrary conditional branch on a predicate.
447   // FIXME: should be able to write a pattern for PPCcondbranch, but can't use
448   // a two-value operand where a dag node expects two operands. :(
449   let isCodeGenOnly = 1 in
450     def BCC : BForm<16, 0, 0, (outs), (ins pred:$cond, condbrtarget:$dst),
451                     "b${cond:cc} ${cond:reg}, $dst"
452                     /*[(PPCcondbranch CRRC:$crS, imm:$opc, bb:$dst)]*/>;
453
454   let Defs = [CTR], Uses = [CTR] in {
455     def BDZ  : BForm_1<16, 18, 0, 0, (outs), (ins condbrtarget:$dst),
456                        "bdz $dst">;
457     def BDNZ : BForm_1<16, 16, 0, 0, (outs), (ins condbrtarget:$dst),
458                        "bdnz $dst">;
459   }
460 }
461
462 // Darwin ABI Calls.
463 let isCall = 1, PPC970_Unit = 7, Defs = [LR] in {
464   // Convenient aliases for call instructions
465   let Uses = [RM] in {
466     def BL_Darwin  : IForm<18, 0, 1,
467                            (outs), (ins calltarget:$func), 
468                            "bl $func", BrB, []>;  // See Pat patterns below.
469     def BLA_Darwin : IForm<18, 1, 1, 
470                           (outs), (ins aaddr:$func),
471                           "bla $func", BrB, [(PPCcall_Darwin (i32 imm:$func))]>;
472   }
473   let Uses = [CTR, RM] in {
474     def BCTRL_Darwin : XLForm_2_ext<19, 528, 20, 0, 1, 
475                                   (outs), (ins),
476                                   "bctrl", BrB,
477                                   [(PPCbctrl_Darwin)]>, Requires<[In32BitMode]>;
478   }
479 }
480
481 // SVR4 ABI Calls.
482 let isCall = 1, PPC970_Unit = 7, Defs = [LR] in {
483   // Convenient aliases for call instructions
484   let Uses = [RM] in {
485     def BL_SVR4  : IForm<18, 0, 1,
486                         (outs), (ins calltarget:$func), 
487                         "bl $func", BrB, []>;  // See Pat patterns below.
488     def BLA_SVR4 : IForm<18, 1, 1,
489                         (outs), (ins aaddr:$func),
490                         "bla $func", BrB,
491                         [(PPCcall_SVR4 (i32 imm:$func))]>;
492   }
493   let Uses = [CTR, RM] in {
494     def BCTRL_SVR4 : XLForm_2_ext<19, 528, 20, 0, 1,
495                                 (outs), (ins),
496                                 "bctrl", BrB,
497                                 [(PPCbctrl_SVR4)]>, Requires<[In32BitMode]>;
498   }
499 }
500
501
502 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
503 def TCRETURNdi :Pseudo< (outs),
504                         (ins calltarget:$dst, i32imm:$offset),
505                  "#TC_RETURNd $dst $offset",
506                  []>;
507
508
509 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
510 def TCRETURNai :Pseudo<(outs), (ins aaddr:$func, i32imm:$offset),
511                  "#TC_RETURNa $func $offset",
512                  [(PPCtc_return (i32 imm:$func), imm:$offset)]>;
513
514 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
515 def TCRETURNri : Pseudo<(outs), (ins CTRRC:$dst, i32imm:$offset),
516                  "#TC_RETURNr $dst $offset",
517                  []>;
518
519
520 let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, isBranch = 1,
521     isIndirectBranch = 1, isCall = 1, isReturn = 1, Uses = [CTR, RM]  in
522 def TAILBCTR : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", BrB, []>,
523      Requires<[In32BitMode]>;
524
525
526
527 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
528     isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
529 def TAILB   : IForm<18, 0, 0, (outs), (ins calltarget:$dst),
530                   "b $dst", BrB,
531                   []>;
532
533
534 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
535     isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
536 def TAILBA   : IForm<18, 0, 0, (outs), (ins aaddr:$dst),
537                   "ba $dst", BrB,
538                   []>;
539
540
541 // DCB* instructions.
542 def DCBA   : DCB_Form<758, 0, (outs), (ins memrr:$dst),
543                       "dcba $dst", LdStDCBF, [(int_ppc_dcba xoaddr:$dst)]>,
544                       PPC970_DGroup_Single;
545 def DCBF   : DCB_Form<86, 0, (outs), (ins memrr:$dst),
546                       "dcbf $dst", LdStDCBF, [(int_ppc_dcbf xoaddr:$dst)]>,
547                       PPC970_DGroup_Single;
548 def DCBI   : DCB_Form<470, 0, (outs), (ins memrr:$dst),
549                       "dcbi $dst", LdStDCBF, [(int_ppc_dcbi xoaddr:$dst)]>,
550                       PPC970_DGroup_Single;
551 def DCBST  : DCB_Form<54, 0, (outs), (ins memrr:$dst),
552                       "dcbst $dst", LdStDCBF, [(int_ppc_dcbst xoaddr:$dst)]>,
553                       PPC970_DGroup_Single;
554 def DCBT   : DCB_Form<278, 0, (outs), (ins memrr:$dst),
555                       "dcbt $dst", LdStDCBF, [(int_ppc_dcbt xoaddr:$dst)]>,
556                       PPC970_DGroup_Single;
557 def DCBTST : DCB_Form<246, 0, (outs), (ins memrr:$dst),
558                       "dcbtst $dst", LdStDCBF, [(int_ppc_dcbtst xoaddr:$dst)]>,
559                       PPC970_DGroup_Single;
560 def DCBZ   : DCB_Form<1014, 0, (outs), (ins memrr:$dst),
561                       "dcbz $dst", LdStDCBF, [(int_ppc_dcbz xoaddr:$dst)]>,
562                       PPC970_DGroup_Single;
563 def DCBZL  : DCB_Form<1014, 1, (outs), (ins memrr:$dst),
564                       "dcbzl $dst", LdStDCBF, [(int_ppc_dcbzl xoaddr:$dst)]>,
565                       PPC970_DGroup_Single;
566
567 def : Pat<(prefetch xoaddr:$dst, (i32 0), imm, (i32 1)),
568           (DCBT xoaddr:$dst)>;
569
570 // Atomic operations
571 let usesCustomInserter = 1 in {
572   let Defs = [CR0] in {
573     def ATOMIC_LOAD_ADD_I8 : Pseudo<
574       (outs GPRC:$dst), (ins memrr:$ptr, GPRC:$incr), "#ATOMIC_LOAD_ADD_I8",
575       [(set GPRC:$dst, (atomic_load_add_8 xoaddr:$ptr, GPRC:$incr))]>;
576     def ATOMIC_LOAD_SUB_I8 : Pseudo<
577       (outs GPRC:$dst), (ins memrr:$ptr, GPRC:$incr), "#ATOMIC_LOAD_SUB_I8",
578       [(set GPRC:$dst, (atomic_load_sub_8 xoaddr:$ptr, GPRC:$incr))]>;
579     def ATOMIC_LOAD_AND_I8 : Pseudo<
580       (outs GPRC:$dst), (ins memrr:$ptr, GPRC:$incr), "#ATOMIC_LOAD_AND_I8",
581       [(set GPRC:$dst, (atomic_load_and_8 xoaddr:$ptr, GPRC:$incr))]>;
582     def ATOMIC_LOAD_OR_I8 : Pseudo<
583       (outs GPRC:$dst), (ins memrr:$ptr, GPRC:$incr), "#ATOMIC_LOAD_OR_I8",
584       [(set GPRC:$dst, (atomic_load_or_8 xoaddr:$ptr, GPRC:$incr))]>;
585     def ATOMIC_LOAD_XOR_I8 : Pseudo<
586       (outs GPRC:$dst), (ins memrr:$ptr, GPRC:$incr), "ATOMIC_LOAD_XOR_I8",
587       [(set GPRC:$dst, (atomic_load_xor_8 xoaddr:$ptr, GPRC:$incr))]>;
588     def ATOMIC_LOAD_NAND_I8 : Pseudo<
589       (outs GPRC:$dst), (ins memrr:$ptr, GPRC:$incr), "#ATOMIC_LOAD_NAND_I8",
590       [(set GPRC:$dst, (atomic_load_nand_8 xoaddr:$ptr, GPRC:$incr))]>;
591     def ATOMIC_LOAD_ADD_I16 : Pseudo<
592       (outs GPRC:$dst), (ins memrr:$ptr, GPRC:$incr), "#ATOMIC_LOAD_ADD_I16",
593       [(set GPRC:$dst, (atomic_load_add_16 xoaddr:$ptr, GPRC:$incr))]>;
594     def ATOMIC_LOAD_SUB_I16 : Pseudo<
595       (outs GPRC:$dst), (ins memrr:$ptr, GPRC:$incr), "#ATOMIC_LOAD_SUB_I16",
596       [(set GPRC:$dst, (atomic_load_sub_16 xoaddr:$ptr, GPRC:$incr))]>;
597     def ATOMIC_LOAD_AND_I16 : Pseudo<
598       (outs GPRC:$dst), (ins memrr:$ptr, GPRC:$incr), "#ATOMIC_LOAD_AND_I16",
599       [(set GPRC:$dst, (atomic_load_and_16 xoaddr:$ptr, GPRC:$incr))]>;
600     def ATOMIC_LOAD_OR_I16 : Pseudo<
601       (outs GPRC:$dst), (ins memrr:$ptr, GPRC:$incr), "#ATOMIC_LOAD_OR_I16",
602       [(set GPRC:$dst, (atomic_load_or_16 xoaddr:$ptr, GPRC:$incr))]>;
603     def ATOMIC_LOAD_XOR_I16 : Pseudo<
604       (outs GPRC:$dst), (ins memrr:$ptr, GPRC:$incr), "#ATOMIC_LOAD_XOR_I16",
605       [(set GPRC:$dst, (atomic_load_xor_16 xoaddr:$ptr, GPRC:$incr))]>;
606     def ATOMIC_LOAD_NAND_I16 : Pseudo<
607       (outs GPRC:$dst), (ins memrr:$ptr, GPRC:$incr), "#ATOMIC_LOAD_NAND_I16",
608       [(set GPRC:$dst, (atomic_load_nand_16 xoaddr:$ptr, GPRC:$incr))]>;
609     def ATOMIC_LOAD_ADD_I32 : Pseudo<
610       (outs GPRC:$dst), (ins memrr:$ptr, GPRC:$incr), "#ATOMIC_LOAD_ADD_I32",
611       [(set GPRC:$dst, (atomic_load_add_32 xoaddr:$ptr, GPRC:$incr))]>;
612     def ATOMIC_LOAD_SUB_I32 : Pseudo<
613       (outs GPRC:$dst), (ins memrr:$ptr, GPRC:$incr), "#ATOMIC_LOAD_SUB_I32",
614       [(set GPRC:$dst, (atomic_load_sub_32 xoaddr:$ptr, GPRC:$incr))]>;
615     def ATOMIC_LOAD_AND_I32 : Pseudo<
616       (outs GPRC:$dst), (ins memrr:$ptr, GPRC:$incr), "#ATOMIC_LOAD_AND_I32",
617       [(set GPRC:$dst, (atomic_load_and_32 xoaddr:$ptr, GPRC:$incr))]>;
618     def ATOMIC_LOAD_OR_I32 : Pseudo<
619       (outs GPRC:$dst), (ins memrr:$ptr, GPRC:$incr), "#ATOMIC_LOAD_OR_I32",
620       [(set GPRC:$dst, (atomic_load_or_32 xoaddr:$ptr, GPRC:$incr))]>;
621     def ATOMIC_LOAD_XOR_I32 : Pseudo<
622       (outs GPRC:$dst), (ins memrr:$ptr, GPRC:$incr), "#ATOMIC_LOAD_XOR_I32",
623       [(set GPRC:$dst, (atomic_load_xor_32 xoaddr:$ptr, GPRC:$incr))]>;
624     def ATOMIC_LOAD_NAND_I32 : Pseudo<
625       (outs GPRC:$dst), (ins memrr:$ptr, GPRC:$incr), "#ATOMIC_LOAD_NAND_I32",
626       [(set GPRC:$dst, (atomic_load_nand_32 xoaddr:$ptr, GPRC:$incr))]>;
627
628     def ATOMIC_CMP_SWAP_I8 : Pseudo<
629       (outs GPRC:$dst), (ins memrr:$ptr, GPRC:$old, GPRC:$new), "#ATOMIC_CMP_SWAP_I8",
630       [(set GPRC:$dst, 
631                     (atomic_cmp_swap_8 xoaddr:$ptr, GPRC:$old, GPRC:$new))]>;
632     def ATOMIC_CMP_SWAP_I16 : Pseudo<
633       (outs GPRC:$dst), (ins memrr:$ptr, GPRC:$old, GPRC:$new), "#ATOMIC_CMP_SWAP_I16 $dst $ptr $old $new",
634       [(set GPRC:$dst, 
635                     (atomic_cmp_swap_16 xoaddr:$ptr, GPRC:$old, GPRC:$new))]>;
636     def ATOMIC_CMP_SWAP_I32 : Pseudo<
637       (outs GPRC:$dst), (ins memrr:$ptr, GPRC:$old, GPRC:$new), "#ATOMIC_CMP_SWAP_I32 $dst $ptr $old $new",
638       [(set GPRC:$dst, 
639                     (atomic_cmp_swap_32 xoaddr:$ptr, GPRC:$old, GPRC:$new))]>;
640
641     def ATOMIC_SWAP_I8 : Pseudo<
642       (outs GPRC:$dst), (ins memrr:$ptr, GPRC:$new), "#ATOMIC_SWAP_i8",
643       [(set GPRC:$dst, (atomic_swap_8 xoaddr:$ptr, GPRC:$new))]>;
644     def ATOMIC_SWAP_I16 : Pseudo<
645       (outs GPRC:$dst), (ins memrr:$ptr, GPRC:$new), "#ATOMIC_SWAP_I16",
646       [(set GPRC:$dst, (atomic_swap_16 xoaddr:$ptr, GPRC:$new))]>;
647     def ATOMIC_SWAP_I32 : Pseudo<
648       (outs GPRC:$dst), (ins memrr:$ptr, GPRC:$new), "#ATOMIC_SWAP_I32",
649       [(set GPRC:$dst, (atomic_swap_32 xoaddr:$ptr, GPRC:$new))]>;
650   }
651 }
652
653 // Instructions to support atomic operations
654 def LWARX : XForm_1<31,  20, (outs GPRC:$rD), (ins memrr:$src),
655                    "lwarx $rD, $src", LdStLWARX,
656                    [(set GPRC:$rD, (PPClarx xoaddr:$src))]>;
657
658 let Defs = [CR0] in
659 def STWCX : XForm_1<31, 150, (outs), (ins GPRC:$rS, memrr:$dst),
660                    "stwcx. $rS, $dst", LdStSTWCX,
661                    [(PPCstcx GPRC:$rS, xoaddr:$dst)]>,
662                    isDOT;
663
664 let isTerminator = 1, isBarrier = 1, hasCtrlDep = 1 in
665 def TRAP  : XForm_24<31, 4, (outs), (ins), "trap", LdStLoad, [(trap)]>;
666
667 //===----------------------------------------------------------------------===//
668 // PPC32 Load Instructions.
669 //
670
671 // Unindexed (r+i) Loads. 
672 let canFoldAsLoad = 1, PPC970_Unit = 2 in {
673 def LBZ : DForm_1<34, (outs GPRC:$rD), (ins memri:$src),
674                   "lbz $rD, $src", LdStLoad,
675                   [(set GPRC:$rD, (zextloadi8 iaddr:$src))]>;
676 def LHA : DForm_1<42, (outs GPRC:$rD), (ins memri:$src),
677                   "lha $rD, $src", LdStLHA,
678                   [(set GPRC:$rD, (sextloadi16 iaddr:$src))]>,
679                   PPC970_DGroup_Cracked;
680 def LHZ : DForm_1<40, (outs GPRC:$rD), (ins memri:$src),
681                   "lhz $rD, $src", LdStLoad,
682                   [(set GPRC:$rD, (zextloadi16 iaddr:$src))]>;
683 def LWZ : DForm_1<32, (outs GPRC:$rD), (ins memri:$src),
684                   "lwz $rD, $src", LdStLoad,
685                   [(set GPRC:$rD, (load iaddr:$src))]>;
686
687 def LFS : DForm_1<48, (outs F4RC:$rD), (ins memri:$src),
688                   "lfs $rD, $src", LdStLFD,
689                   [(set F4RC:$rD, (load iaddr:$src))]>;
690 def LFD : DForm_1<50, (outs F8RC:$rD), (ins memri:$src),
691                   "lfd $rD, $src", LdStLFD,
692                   [(set F8RC:$rD, (load iaddr:$src))]>;
693
694
695 // Unindexed (r+i) Loads with Update (preinc).
696 let mayLoad = 1 in {
697 def LBZU : DForm_1<35, (outs GPRC:$rD, ptr_rc:$ea_result), (ins memri:$addr),
698                    "lbzu $rD, $addr", LdStLoadUpd,
699                    []>, RegConstraint<"$addr.reg = $ea_result">,
700                    NoEncode<"$ea_result">;
701
702 def LHAU : DForm_1<43, (outs GPRC:$rD, ptr_rc:$ea_result), (ins memri:$addr),
703                    "lhau $rD, $addr", LdStLHAU,
704                    []>, RegConstraint<"$addr.reg = $ea_result">,
705                    NoEncode<"$ea_result">;
706
707 def LHZU : DForm_1<41, (outs GPRC:$rD, ptr_rc:$ea_result), (ins memri:$addr),
708                    "lhzu $rD, $addr", LdStLoadUpd,
709                    []>, RegConstraint<"$addr.reg = $ea_result">,
710                    NoEncode<"$ea_result">;
711
712 def LWZU : DForm_1<33, (outs GPRC:$rD, ptr_rc:$ea_result), (ins memri:$addr),
713                    "lwzu $rD, $addr", LdStLoadUpd,
714                    []>, RegConstraint<"$addr.reg = $ea_result">,
715                    NoEncode<"$ea_result">;
716
717 def LFSU : DForm_1<49, (outs F4RC:$rD, ptr_rc:$ea_result), (ins memri:$addr),
718                   "lfsu $rD, $addr", LdStLFDU,
719                   []>, RegConstraint<"$addr.reg = $ea_result">,
720                    NoEncode<"$ea_result">;
721
722 def LFDU : DForm_1<51, (outs F8RC:$rD, ptr_rc:$ea_result), (ins memri:$addr),
723                   "lfdu $rD, $addr", LdStLFDU,
724                   []>, RegConstraint<"$addr.reg = $ea_result">,
725                    NoEncode<"$ea_result">;
726
727
728 // Indexed (r+r) Loads with Update (preinc).
729 def LBZUX : XForm_1<31, 119, (outs GPRC:$rD, ptr_rc:$ea_result),
730                    (ins memrr:$addr),
731                    "lbzux $rD, $addr", LdStLoadUpd,
732                    []>, RegConstraint<"$addr.offreg = $ea_result">,
733                    NoEncode<"$ea_result">;
734
735 def LHAUX : XForm_1<31, 375, (outs GPRC:$rD, ptr_rc:$ea_result),
736                    (ins memrr:$addr),
737                    "lhaux $rD, $addr", LdStLHAU,
738                    []>, RegConstraint<"$addr.offreg = $ea_result">,
739                    NoEncode<"$ea_result">;
740
741 def LHZUX : XForm_1<31, 311, (outs GPRC:$rD, ptr_rc:$ea_result),
742                    (ins memrr:$addr),
743                    "lhzux $rD, $addr", LdStLoadUpd,
744                    []>, RegConstraint<"$addr.offreg = $ea_result">,
745                    NoEncode<"$ea_result">;
746
747 def LWZUX : XForm_1<31, 55, (outs GPRC:$rD, ptr_rc:$ea_result),
748                    (ins memrr:$addr),
749                    "lwzux $rD, $addr", LdStLoadUpd,
750                    []>, RegConstraint<"$addr.offreg = $ea_result">,
751                    NoEncode<"$ea_result">;
752
753 def LFSUX : XForm_1<31, 567, (outs F4RC:$rD, ptr_rc:$ea_result),
754                    (ins memrr:$addr),
755                    "lfsux $rD, $addr", LdStLFDU,
756                    []>, RegConstraint<"$addr.offreg = $ea_result">,
757                    NoEncode<"$ea_result">;
758
759 def LFDUX : XForm_1<31, 631, (outs F8RC:$rD, ptr_rc:$ea_result),
760                    (ins memrr:$addr),
761                    "lfdux $rD, $addr", LdStLFDU,
762                    []>, RegConstraint<"$addr.offreg = $ea_result">,
763                    NoEncode<"$ea_result">;
764 }
765 }
766
767 // Indexed (r+r) Loads.
768 //
769 let canFoldAsLoad = 1, PPC970_Unit = 2 in {
770 def LBZX : XForm_1<31,  87, (outs GPRC:$rD), (ins memrr:$src),
771                    "lbzx $rD, $src", LdStLoad,
772                    [(set GPRC:$rD, (zextloadi8 xaddr:$src))]>;
773 def LHAX : XForm_1<31, 343, (outs GPRC:$rD), (ins memrr:$src),
774                    "lhax $rD, $src", LdStLHA,
775                    [(set GPRC:$rD, (sextloadi16 xaddr:$src))]>,
776                    PPC970_DGroup_Cracked;
777 def LHZX : XForm_1<31, 279, (outs GPRC:$rD), (ins memrr:$src),
778                    "lhzx $rD, $src", LdStLoad,
779                    [(set GPRC:$rD, (zextloadi16 xaddr:$src))]>;
780 def LWZX : XForm_1<31,  23, (outs GPRC:$rD), (ins memrr:$src),
781                    "lwzx $rD, $src", LdStLoad,
782                    [(set GPRC:$rD, (load xaddr:$src))]>;
783                    
784                    
785 def LHBRX : XForm_1<31, 790, (outs GPRC:$rD), (ins memrr:$src),
786                    "lhbrx $rD, $src", LdStLoad,
787                    [(set GPRC:$rD, (PPClbrx xoaddr:$src, i16))]>;
788 def LWBRX : XForm_1<31,  534, (outs GPRC:$rD), (ins memrr:$src),
789                    "lwbrx $rD, $src", LdStLoad,
790                    [(set GPRC:$rD, (PPClbrx xoaddr:$src, i32))]>;
791
792 def LFSX   : XForm_25<31, 535, (outs F4RC:$frD), (ins memrr:$src),
793                       "lfsx $frD, $src", LdStLFD,
794                       [(set F4RC:$frD, (load xaddr:$src))]>;
795 def LFDX   : XForm_25<31, 599, (outs F8RC:$frD), (ins memrr:$src),
796                       "lfdx $frD, $src", LdStLFD,
797                       [(set F8RC:$frD, (load xaddr:$src))]>;
798 }
799
800 //===----------------------------------------------------------------------===//
801 // PPC32 Store Instructions.
802 //
803
804 // Unindexed (r+i) Stores.
805 let PPC970_Unit = 2 in {
806 def STB  : DForm_1<38, (outs), (ins GPRC:$rS, memri:$src),
807                    "stb $rS, $src", LdStStore,
808                    [(truncstorei8 GPRC:$rS, iaddr:$src)]>;
809 def STH  : DForm_1<44, (outs), (ins GPRC:$rS, memri:$src),
810                    "sth $rS, $src", LdStStore,
811                    [(truncstorei16 GPRC:$rS, iaddr:$src)]>;
812 def STW  : DForm_1<36, (outs), (ins GPRC:$rS, memri:$src),
813                    "stw $rS, $src", LdStStore,
814                    [(store GPRC:$rS, iaddr:$src)]>;
815 def STFS : DForm_1<52, (outs), (ins F4RC:$rS, memri:$dst),
816                    "stfs $rS, $dst", LdStSTFD,
817                    [(store F4RC:$rS, iaddr:$dst)]>;
818 def STFD : DForm_1<54, (outs), (ins F8RC:$rS, memri:$dst),
819                    "stfd $rS, $dst", LdStSTFD,
820                    [(store F8RC:$rS, iaddr:$dst)]>;
821 }
822
823 // Unindexed (r+i) Stores with Update (preinc).
824 let PPC970_Unit = 2 in {
825 def STBU  : DForm_1a<39, (outs ptr_rc:$ea_res), (ins GPRC:$rS,
826                              symbolLo:$ptroff, ptr_rc:$ptrreg),
827                     "stbu $rS, $ptroff($ptrreg)", LdStStoreUpd,
828                     [(set ptr_rc:$ea_res,
829                           (pre_truncsti8 GPRC:$rS, ptr_rc:$ptrreg, 
830                                          iaddroff:$ptroff))]>,
831                     RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">;
832 def STHU  : DForm_1a<45, (outs ptr_rc:$ea_res), (ins GPRC:$rS,
833                              symbolLo:$ptroff, ptr_rc:$ptrreg),
834                     "sthu $rS, $ptroff($ptrreg)", LdStStoreUpd,
835                     [(set ptr_rc:$ea_res,
836                         (pre_truncsti16 GPRC:$rS, ptr_rc:$ptrreg, 
837                                         iaddroff:$ptroff))]>,
838                     RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">;
839 def STWU  : DForm_1a<37, (outs ptr_rc:$ea_res), (ins GPRC:$rS,
840                              symbolLo:$ptroff, ptr_rc:$ptrreg),
841                     "stwu $rS, $ptroff($ptrreg)", LdStStoreUpd,
842                     [(set ptr_rc:$ea_res, (pre_store GPRC:$rS, ptr_rc:$ptrreg, 
843                                                      iaddroff:$ptroff))]>,
844                     RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">;
845 def STFSU : DForm_1a<37, (outs ptr_rc:$ea_res), (ins F4RC:$rS,
846                              symbolLo:$ptroff, ptr_rc:$ptrreg),
847                     "stfsu $rS, $ptroff($ptrreg)", LdStSTFDU,
848                     [(set ptr_rc:$ea_res, (pre_store F4RC:$rS,  ptr_rc:$ptrreg, 
849                                           iaddroff:$ptroff))]>,
850                     RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">;
851 def STFDU : DForm_1a<37, (outs ptr_rc:$ea_res), (ins F8RC:$rS,
852                              symbolLo:$ptroff, ptr_rc:$ptrreg),
853                     "stfdu $rS, $ptroff($ptrreg)", LdStSTFDU,
854                     [(set ptr_rc:$ea_res, (pre_store F8RC:$rS, ptr_rc:$ptrreg, 
855                                           iaddroff:$ptroff))]>,
856                     RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">;
857 }
858
859
860 // Indexed (r+r) Stores.
861 //
862 let PPC970_Unit = 2 in {
863 def STBX  : XForm_8<31, 215, (outs), (ins GPRC:$rS, memrr:$dst),
864                    "stbx $rS, $dst", LdStStore,
865                    [(truncstorei8 GPRC:$rS, xaddr:$dst)]>, 
866                    PPC970_DGroup_Cracked;
867 def STHX  : XForm_8<31, 407, (outs), (ins GPRC:$rS, memrr:$dst),
868                    "sthx $rS, $dst", LdStStore,
869                    [(truncstorei16 GPRC:$rS, xaddr:$dst)]>, 
870                    PPC970_DGroup_Cracked;
871 def STWX  : XForm_8<31, 151, (outs), (ins GPRC:$rS, memrr:$dst),
872                    "stwx $rS, $dst", LdStStore,
873                    [(store GPRC:$rS, xaddr:$dst)]>,
874                    PPC970_DGroup_Cracked;
875  
876 def STBUX : XForm_8<31, 247, (outs ptr_rc:$ea_res),
877                              (ins GPRC:$rS, ptr_rc:$ptroff, ptr_rc:$ptrreg),
878                    "stbux $rS, $ptroff, $ptrreg", LdStStoreUpd,
879                    [(set ptr_rc:$ea_res,
880                       (pre_truncsti8 GPRC:$rS,
881                                      ptr_rc:$ptrreg, xaddroff:$ptroff))]>,
882                    RegConstraint<"$ptroff = $ea_res">, NoEncode<"$ea_res">,
883                    PPC970_DGroup_Cracked;
884  
885 def STHUX : XForm_8<31, 439, (outs ptr_rc:$ea_res),
886                              (ins GPRC:$rS, ptr_rc:$ptroff, ptr_rc:$ptrreg),
887                    "sthux $rS, $ptroff, $ptrreg", LdStStoreUpd,
888                    [(set ptr_rc:$ea_res,
889                       (pre_truncsti16 GPRC:$rS,
890                                       ptr_rc:$ptrreg, xaddroff:$ptroff))]>,
891                    RegConstraint<"$ptroff = $ea_res">, NoEncode<"$ea_res">,
892                    PPC970_DGroup_Cracked;
893                  
894 def STWUX : XForm_8<31, 183, (outs ptr_rc:$ea_res),
895                              (ins GPRC:$rS, ptr_rc:$ptroff, ptr_rc:$ptrreg),
896                    "stwux $rS, $ptroff, $ptrreg", LdStStoreUpd,
897                    [(set ptr_rc:$ea_res,
898                       (pre_store GPRC:$rS, ptr_rc:$ptrreg, xaddroff:$ptroff))]>,
899                    RegConstraint<"$ptroff = $ea_res">, NoEncode<"$ea_res">,
900                    PPC970_DGroup_Cracked;
901
902 def STFSUX : XForm_8<31, 695, (outs ptr_rc:$ea_res),
903                               (ins F4RC:$rS, ptr_rc:$ptroff, ptr_rc:$ptrreg),
904                     "stfsux $rS, $ptroff, $ptrreg", LdStSTFDU,
905                     [(set ptr_rc:$ea_res,
906                        (pre_store F4RC:$rS, ptr_rc:$ptrreg, xaddroff:$ptroff))]>,
907                     RegConstraint<"$ptroff = $ea_res">, NoEncode<"$ea_res">,
908                     PPC970_DGroup_Cracked;
909
910 def STFDUX : XForm_8<31, 759, (outs ptr_rc:$ea_res),
911                               (ins F8RC:$rS, ptr_rc:$ptroff, ptr_rc:$ptrreg),
912                     "stfdux $rS, $ptroff, $ptrreg", LdStSTFDU,
913                     [(set ptr_rc:$ea_res,
914                        (pre_store F8RC:$rS, ptr_rc:$ptrreg, xaddroff:$ptroff))]>,
915                     RegConstraint<"$ptroff = $ea_res">, NoEncode<"$ea_res">,
916                     PPC970_DGroup_Cracked;
917
918 def STHBRX: XForm_8<31, 918, (outs), (ins GPRC:$rS, memrr:$dst),
919                    "sthbrx $rS, $dst", LdStStore,
920                    [(PPCstbrx GPRC:$rS, xoaddr:$dst, i16)]>, 
921                    PPC970_DGroup_Cracked;
922 def STWBRX: XForm_8<31, 662, (outs), (ins GPRC:$rS, memrr:$dst),
923                    "stwbrx $rS, $dst", LdStStore,
924                    [(PPCstbrx GPRC:$rS, xoaddr:$dst, i32)]>,
925                    PPC970_DGroup_Cracked;
926
927 def STFIWX: XForm_28<31, 983, (outs), (ins F8RC:$frS, memrr:$dst),
928                      "stfiwx $frS, $dst", LdStSTFD,
929                      [(PPCstfiwx F8RC:$frS, xoaddr:$dst)]>;
930                      
931 def STFSX : XForm_28<31, 663, (outs), (ins F4RC:$frS, memrr:$dst),
932                      "stfsx $frS, $dst", LdStSTFD,
933                      [(store F4RC:$frS, xaddr:$dst)]>;
934 def STFDX : XForm_28<31, 727, (outs), (ins F8RC:$frS, memrr:$dst),
935                      "stfdx $frS, $dst", LdStSTFD,
936                      [(store F8RC:$frS, xaddr:$dst)]>;
937 }
938
939 def SYNC : XForm_24_sync<31, 598, (outs), (ins),
940                         "sync", LdStSync,
941                         [(int_ppc_sync)]>;
942
943 //===----------------------------------------------------------------------===//
944 // PPC32 Arithmetic Instructions.
945 //
946
947 let PPC970_Unit = 1 in {  // FXU Operations.
948 def ADDI   : DForm_2<14, (outs GPRC:$rD), (ins GPRC:$rA, s16imm:$imm),
949                      "addi $rD, $rA, $imm", IntSimple,
950                      [(set GPRC:$rD, (add GPRC:$rA, immSExt16:$imm))]>;
951 def ADDIL  : DForm_2<14, (outs GPRC:$rD), (ins GPRC:$rA, symbolLo:$imm),
952                      "addi $rD, $rA, $imm", IntSimple,
953                      [(set GPRC:$rD, (add GPRC:$rA, immSExt16:$imm))]>;
954 let Defs = [CARRY] in {
955 def ADDIC  : DForm_2<12, (outs GPRC:$rD), (ins GPRC:$rA, s16imm:$imm),
956                      "addic $rD, $rA, $imm", IntGeneral,
957                      [(set GPRC:$rD, (addc GPRC:$rA, immSExt16:$imm))]>,
958                      PPC970_DGroup_Cracked;
959 def ADDICo : DForm_2<13, (outs GPRC:$rD), (ins GPRC:$rA, s16imm:$imm),
960                      "addic. $rD, $rA, $imm", IntGeneral,
961                      []>;
962 }
963 def ADDIS  : DForm_2<15, (outs GPRC:$rD), (ins GPRC:$rA, symbolHi:$imm),
964                      "addis $rD, $rA, $imm", IntSimple,
965                      [(set GPRC:$rD, (add GPRC:$rA, imm16ShiftedSExt:$imm))]>;
966 def LA     : DForm_2<14, (outs GPRC:$rD), (ins GPRC:$rA, symbolLo:$sym),
967                      "la $rD, $sym($rA)", IntGeneral,
968                      [(set GPRC:$rD, (add GPRC:$rA,
969                                           (PPClo tglobaladdr:$sym, 0)))]>;
970 def MULLI  : DForm_2< 7, (outs GPRC:$rD), (ins GPRC:$rA, s16imm:$imm),
971                      "mulli $rD, $rA, $imm", IntMulLI,
972                      [(set GPRC:$rD, (mul GPRC:$rA, immSExt16:$imm))]>;
973 let Defs = [CARRY] in {
974 def SUBFIC : DForm_2< 8, (outs GPRC:$rD), (ins GPRC:$rA, s16imm:$imm),
975                      "subfic $rD, $rA, $imm", IntGeneral,
976                      [(set GPRC:$rD, (subc immSExt16:$imm, GPRC:$rA))]>;
977 }
978
979 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in {
980   def LI  : DForm_2_r0<14, (outs GPRC:$rD), (ins symbolLo:$imm),
981                        "li $rD, $imm", IntSimple,
982                        [(set GPRC:$rD, immSExt16:$imm)]>;
983   def LIS : DForm_2_r0<15, (outs GPRC:$rD), (ins symbolHi:$imm),
984                        "lis $rD, $imm", IntSimple,
985                        [(set GPRC:$rD, imm16ShiftedSExt:$imm)]>;
986 }
987 }
988
989 let PPC970_Unit = 1 in {  // FXU Operations.
990 def ANDIo : DForm_4<28, (outs GPRC:$dst), (ins GPRC:$src1, u16imm:$src2),
991                     "andi. $dst, $src1, $src2", IntGeneral,
992                     [(set GPRC:$dst, (and GPRC:$src1, immZExt16:$src2))]>,
993                     isDOT;
994 def ANDISo : DForm_4<29, (outs GPRC:$dst), (ins GPRC:$src1, u16imm:$src2),
995                     "andis. $dst, $src1, $src2", IntGeneral,
996                     [(set GPRC:$dst, (and GPRC:$src1,imm16ShiftedZExt:$src2))]>,
997                     isDOT;
998 def ORI   : DForm_4<24, (outs GPRC:$dst), (ins GPRC:$src1, u16imm:$src2),
999                     "ori $dst, $src1, $src2", IntSimple,
1000                     [(set GPRC:$dst, (or GPRC:$src1, immZExt16:$src2))]>;
1001 def ORIS  : DForm_4<25, (outs GPRC:$dst), (ins GPRC:$src1, u16imm:$src2),
1002                     "oris $dst, $src1, $src2", IntSimple,
1003                     [(set GPRC:$dst, (or GPRC:$src1, imm16ShiftedZExt:$src2))]>;
1004 def XORI  : DForm_4<26, (outs GPRC:$dst), (ins GPRC:$src1, u16imm:$src2),
1005                     "xori $dst, $src1, $src2", IntSimple,
1006                     [(set GPRC:$dst, (xor GPRC:$src1, immZExt16:$src2))]>;
1007 def XORIS : DForm_4<27, (outs GPRC:$dst), (ins GPRC:$src1, u16imm:$src2),
1008                     "xoris $dst, $src1, $src2", IntSimple,
1009                     [(set GPRC:$dst, (xor GPRC:$src1,imm16ShiftedZExt:$src2))]>;
1010 def NOP   : DForm_4_zero<24, (outs), (ins), "nop", IntSimple,
1011                          []>;
1012 def CMPWI : DForm_5_ext<11, (outs CRRC:$crD), (ins GPRC:$rA, s16imm:$imm),
1013                         "cmpwi $crD, $rA, $imm", IntCompare>;
1014 def CMPLWI : DForm_6_ext<10, (outs CRRC:$dst), (ins GPRC:$src1, u16imm:$src2),
1015                          "cmplwi $dst, $src1, $src2", IntCompare>;
1016 }
1017
1018
1019 let PPC970_Unit = 1 in {  // FXU Operations.
1020 def NAND : XForm_6<31, 476, (outs GPRC:$rA), (ins GPRC:$rS, GPRC:$rB),
1021                    "nand $rA, $rS, $rB", IntSimple,
1022                    [(set GPRC:$rA, (not (and GPRC:$rS, GPRC:$rB)))]>;
1023 def AND  : XForm_6<31,  28, (outs GPRC:$rA), (ins GPRC:$rS, GPRC:$rB),
1024                    "and $rA, $rS, $rB", IntSimple,
1025                    [(set GPRC:$rA, (and GPRC:$rS, GPRC:$rB))]>;
1026 def ANDC : XForm_6<31,  60, (outs GPRC:$rA), (ins GPRC:$rS, GPRC:$rB),
1027                    "andc $rA, $rS, $rB", IntSimple,
1028                    [(set GPRC:$rA, (and GPRC:$rS, (not GPRC:$rB)))]>;
1029 def OR   : XForm_6<31, 444, (outs GPRC:$rA), (ins GPRC:$rS, GPRC:$rB),
1030                    "or $rA, $rS, $rB", IntSimple,
1031                    [(set GPRC:$rA, (or GPRC:$rS, GPRC:$rB))]>;
1032 def NOR  : XForm_6<31, 124, (outs GPRC:$rA), (ins GPRC:$rS, GPRC:$rB),
1033                    "nor $rA, $rS, $rB", IntSimple,
1034                    [(set GPRC:$rA, (not (or GPRC:$rS, GPRC:$rB)))]>;
1035 def ORC  : XForm_6<31, 412, (outs GPRC:$rA), (ins GPRC:$rS, GPRC:$rB),
1036                    "orc $rA, $rS, $rB", IntSimple,
1037                    [(set GPRC:$rA, (or GPRC:$rS, (not GPRC:$rB)))]>;
1038 def EQV  : XForm_6<31, 284, (outs GPRC:$rA), (ins GPRC:$rS, GPRC:$rB),
1039                    "eqv $rA, $rS, $rB", IntSimple,
1040                    [(set GPRC:$rA, (not (xor GPRC:$rS, GPRC:$rB)))]>;
1041 def XOR  : XForm_6<31, 316, (outs GPRC:$rA), (ins GPRC:$rS, GPRC:$rB),
1042                    "xor $rA, $rS, $rB", IntSimple,
1043                    [(set GPRC:$rA, (xor GPRC:$rS, GPRC:$rB))]>;
1044 def SLW  : XForm_6<31,  24, (outs GPRC:$rA), (ins GPRC:$rS, GPRC:$rB),
1045                    "slw $rA, $rS, $rB", IntGeneral,
1046                    [(set GPRC:$rA, (PPCshl GPRC:$rS, GPRC:$rB))]>;
1047 def SRW  : XForm_6<31, 536, (outs GPRC:$rA), (ins GPRC:$rS, GPRC:$rB),
1048                    "srw $rA, $rS, $rB", IntGeneral,
1049                    [(set GPRC:$rA, (PPCsrl GPRC:$rS, GPRC:$rB))]>;
1050 let Defs = [CARRY] in {
1051 def SRAW : XForm_6<31, 792, (outs GPRC:$rA), (ins GPRC:$rS, GPRC:$rB),
1052                    "sraw $rA, $rS, $rB", IntShift,
1053                    [(set GPRC:$rA, (PPCsra GPRC:$rS, GPRC:$rB))]>;
1054 }
1055 }
1056
1057 let PPC970_Unit = 1 in {  // FXU Operations.
1058 let Defs = [CARRY] in {
1059 def SRAWI : XForm_10<31, 824, (outs GPRC:$rA), (ins GPRC:$rS, u5imm:$SH), 
1060                      "srawi $rA, $rS, $SH", IntShift,
1061                      [(set GPRC:$rA, (sra GPRC:$rS, (i32 imm:$SH)))]>;
1062 }
1063 def CNTLZW : XForm_11<31,  26, (outs GPRC:$rA), (ins GPRC:$rS),
1064                       "cntlzw $rA, $rS", IntGeneral,
1065                       [(set GPRC:$rA, (ctlz GPRC:$rS))]>;
1066 def EXTSB  : XForm_11<31, 954, (outs GPRC:$rA), (ins GPRC:$rS),
1067                       "extsb $rA, $rS", IntSimple,
1068                       [(set GPRC:$rA, (sext_inreg GPRC:$rS, i8))]>;
1069 def EXTSH  : XForm_11<31, 922, (outs GPRC:$rA), (ins GPRC:$rS),
1070                       "extsh $rA, $rS", IntSimple,
1071                       [(set GPRC:$rA, (sext_inreg GPRC:$rS, i16))]>;
1072
1073 def CMPW   : XForm_16_ext<31, 0, (outs CRRC:$crD), (ins GPRC:$rA, GPRC:$rB),
1074                           "cmpw $crD, $rA, $rB", IntCompare>;
1075 def CMPLW  : XForm_16_ext<31, 32, (outs CRRC:$crD), (ins GPRC:$rA, GPRC:$rB),
1076                           "cmplw $crD, $rA, $rB", IntCompare>;
1077 }
1078 let PPC970_Unit = 3 in {  // FPU Operations.
1079 //def FCMPO  : XForm_17<63, 32, (outs CRRC:$crD), (ins FPRC:$fA, FPRC:$fB),
1080 //                      "fcmpo $crD, $fA, $fB", FPCompare>;
1081 def FCMPUS : XForm_17<63, 0, (outs CRRC:$crD), (ins F4RC:$fA, F4RC:$fB),
1082                       "fcmpu $crD, $fA, $fB", FPCompare>;
1083 def FCMPUD : XForm_17<63, 0, (outs CRRC:$crD), (ins F8RC:$fA, F8RC:$fB),
1084                       "fcmpu $crD, $fA, $fB", FPCompare>;
1085
1086 let Uses = [RM] in {
1087   def FCTIWZ : XForm_26<63, 15, (outs F8RC:$frD), (ins F8RC:$frB),
1088                         "fctiwz $frD, $frB", FPGeneral,
1089                         [(set F8RC:$frD, (PPCfctiwz F8RC:$frB))]>;
1090   def FRSP   : XForm_26<63, 12, (outs F4RC:$frD), (ins F8RC:$frB),
1091                         "frsp $frD, $frB", FPGeneral,
1092                         [(set F4RC:$frD, (fround F8RC:$frB))]>;
1093   def FSQRT  : XForm_26<63, 22, (outs F8RC:$frD), (ins F8RC:$frB),
1094                         "fsqrt $frD, $frB", FPSqrt,
1095                         [(set F8RC:$frD, (fsqrt F8RC:$frB))]>;
1096   def FSQRTS : XForm_26<59, 22, (outs F4RC:$frD), (ins F4RC:$frB),
1097                         "fsqrts $frD, $frB", FPSqrt,
1098                         [(set F4RC:$frD, (fsqrt F4RC:$frB))]>;
1099   }
1100 }
1101
1102 /// Note that FMR is defined as pseudo-ops on the PPC970 because they are
1103 /// often coalesced away and we don't want the dispatch group builder to think
1104 /// that they will fill slots (which could cause the load of a LSU reject to
1105 /// sneak into a d-group with a store).
1106 def FMR   : XForm_26<63, 72, (outs F4RC:$frD), (ins F4RC:$frB),
1107                      "fmr $frD, $frB", FPGeneral,
1108                      []>,  // (set F4RC:$frD, F4RC:$frB)
1109                      PPC970_Unit_Pseudo;
1110
1111 let PPC970_Unit = 3 in {  // FPU Operations.
1112 // These are artificially split into two different forms, for 4/8 byte FP.
1113 def FABSS  : XForm_26<63, 264, (outs F4RC:$frD), (ins F4RC:$frB),
1114                       "fabs $frD, $frB", FPGeneral,
1115                       [(set F4RC:$frD, (fabs F4RC:$frB))]>;
1116 def FABSD  : XForm_26<63, 264, (outs F8RC:$frD), (ins F8RC:$frB),
1117                       "fabs $frD, $frB", FPGeneral,
1118                       [(set F8RC:$frD, (fabs F8RC:$frB))]>;
1119 def FNABSS : XForm_26<63, 136, (outs F4RC:$frD), (ins F4RC:$frB),
1120                       "fnabs $frD, $frB", FPGeneral,
1121                       [(set F4RC:$frD, (fneg (fabs F4RC:$frB)))]>;
1122 def FNABSD : XForm_26<63, 136, (outs F8RC:$frD), (ins F8RC:$frB),
1123                       "fnabs $frD, $frB", FPGeneral,
1124                       [(set F8RC:$frD, (fneg (fabs F8RC:$frB)))]>;
1125 def FNEGS  : XForm_26<63, 40, (outs F4RC:$frD), (ins F4RC:$frB),
1126                       "fneg $frD, $frB", FPGeneral,
1127                       [(set F4RC:$frD, (fneg F4RC:$frB))]>;
1128 def FNEGD  : XForm_26<63, 40, (outs F8RC:$frD), (ins F8RC:$frB),
1129                       "fneg $frD, $frB", FPGeneral,
1130                       [(set F8RC:$frD, (fneg F8RC:$frB))]>;
1131 }
1132                       
1133
1134 // XL-Form instructions.  condition register logical ops.
1135 //
1136 def MCRF   : XLForm_3<19, 0, (outs CRRC:$BF), (ins CRRC:$BFA),
1137                       "mcrf $BF, $BFA", BrMCR>,
1138              PPC970_DGroup_First, PPC970_Unit_CRU;
1139
1140 def CREQV  : XLForm_1<19, 289, (outs CRBITRC:$CRD),
1141                                (ins CRBITRC:$CRA, CRBITRC:$CRB),
1142                       "creqv $CRD, $CRA, $CRB", BrCR,
1143                       []>;
1144
1145 def CROR  : XLForm_1<19, 449, (outs CRBITRC:$CRD),
1146                                (ins CRBITRC:$CRA, CRBITRC:$CRB),
1147                       "cror $CRD, $CRA, $CRB", BrCR,
1148                       []>;
1149
1150 def CRSET  : XLForm_1_ext<19, 289, (outs CRBITRC:$dst), (ins),
1151               "creqv $dst, $dst, $dst", BrCR,
1152               []>;
1153
1154 def CRUNSET: XLForm_1_ext<19, 193, (outs CRBITRC:$dst), (ins),
1155               "crxor $dst, $dst, $dst", BrCR,
1156               []>;
1157
1158 let Defs = [CR1EQ], CRD = 6 in {
1159 def CR6SET  : XLForm_1_ext<19, 289, (outs), (ins),
1160               "creqv 6, 6, 6", BrCR,
1161               [(PPCcr6set)]>;
1162
1163 def CR6UNSET: XLForm_1_ext<19, 193, (outs), (ins),
1164               "crxor 6, 6, 6", BrCR,
1165               [(PPCcr6unset)]>;
1166 }
1167
1168 // XFX-Form instructions.  Instructions that deal with SPRs.
1169 //
1170 let Uses = [CTR] in {
1171 def MFCTR : XFXForm_1_ext<31, 339, 9, (outs GPRC:$rT), (ins),
1172                           "mfctr $rT", SprMFSPR>,
1173             PPC970_DGroup_First, PPC970_Unit_FXU;
1174 }
1175 let Defs = [CTR], Pattern = [(PPCmtctr GPRC:$rS)] in {
1176 def MTCTR : XFXForm_7_ext<31, 467, 9, (outs), (ins GPRC:$rS),
1177                           "mtctr $rS", SprMTSPR>,
1178             PPC970_DGroup_First, PPC970_Unit_FXU;
1179 }
1180
1181 let Defs = [LR] in {
1182 def MTLR  : XFXForm_7_ext<31, 467, 8, (outs), (ins GPRC:$rS),
1183                           "mtlr $rS", SprMTSPR>,
1184             PPC970_DGroup_First, PPC970_Unit_FXU;
1185 }
1186 let Uses = [LR] in {
1187 def MFLR  : XFXForm_1_ext<31, 339, 8, (outs GPRC:$rT), (ins),
1188                           "mflr $rT", SprMFSPR>,
1189             PPC970_DGroup_First, PPC970_Unit_FXU;
1190 }
1191
1192 // Move to/from VRSAVE: despite being a SPR, the VRSAVE register is renamed like
1193 // a GPR on the PPC970.  As such, copies in and out have the same performance
1194 // characteristics as an OR instruction.
1195 def MTVRSAVE : XFXForm_7_ext<31, 467, 256, (outs), (ins GPRC:$rS),
1196                              "mtspr 256, $rS", IntGeneral>,
1197                PPC970_DGroup_Single, PPC970_Unit_FXU;
1198 def MFVRSAVE : XFXForm_1_ext<31, 339, 256, (outs GPRC:$rT), (ins),
1199                              "mfspr $rT, 256", IntGeneral>,
1200                PPC970_DGroup_First, PPC970_Unit_FXU;
1201
1202 def MTCRF : XFXForm_5<31, 144, (outs crbitm:$FXM), (ins GPRC:$rS),
1203                       "mtcrf $FXM, $rS", BrMCRX>,
1204             PPC970_MicroCode, PPC970_Unit_CRU;
1205
1206 // This is a pseudo for MFCR, which implicitly uses all 8 of its subregisters;
1207 // declaring that here gives the local register allocator problems with this:
1208 //  vreg = MCRF  CR0
1209 //  MFCR  <kill of whatever preg got assigned to vreg>
1210 // while not declaring it breaks DeadMachineInstructionElimination.
1211 // As it turns out, in all cases where we currently use this,
1212 // we're only interested in one subregister of it.  Represent this in the
1213 // instruction to keep the register allocator from becoming confused.
1214 //
1215 // FIXME: Make this a real Pseudo instruction when the JIT switches to MC.
1216 def MFCRpseud: XFXForm_3<31, 19, (outs GPRC:$rT), (ins crbitm:$FXM),
1217                        "#MFCRpseud", SprMFCR>,
1218             PPC970_MicroCode, PPC970_Unit_CRU;
1219             
1220 def MFCR : XFXForm_3<31, 19, (outs GPRC:$rT), (ins),
1221                      "mfcr $rT", SprMFCR>,
1222                      PPC970_MicroCode, PPC970_Unit_CRU;
1223
1224 def MFOCRF: XFXForm_5a<31, 19, (outs GPRC:$rT), (ins crbitm:$FXM),
1225                        "mfocrf $rT, $FXM", SprMFCR>,
1226             PPC970_DGroup_First, PPC970_Unit_CRU;
1227
1228 // Instructions to manipulate FPSCR.  Only long double handling uses these.
1229 // FPSCR is not modelled; we use the SDNode Flag to keep things in order.
1230
1231 let Uses = [RM], Defs = [RM] in { 
1232   def MTFSB0 : XForm_43<63, 70, (outs), (ins u5imm:$FM),
1233                          "mtfsb0 $FM", IntMTFSB0,
1234                         [(PPCmtfsb0 (i32 imm:$FM))]>,
1235                PPC970_DGroup_Single, PPC970_Unit_FPU;
1236   def MTFSB1 : XForm_43<63, 38, (outs), (ins u5imm:$FM),
1237                          "mtfsb1 $FM", IntMTFSB0,
1238                         [(PPCmtfsb1 (i32 imm:$FM))]>,
1239                PPC970_DGroup_Single, PPC970_Unit_FPU;
1240   // MTFSF does not actually produce an FP result.  We pretend it copies
1241   // input reg B to the output.  If we didn't do this it would look like the
1242   // instruction had no outputs (because we aren't modelling the FPSCR) and
1243   // it would be deleted.
1244   def MTFSF  : XFLForm<63, 711, (outs F8RC:$FRA),
1245                                 (ins i32imm:$FM, F8RC:$rT, F8RC:$FRB),
1246                          "mtfsf $FM, $rT", "$FRB = $FRA", IntMTFSB0,
1247                          [(set F8RC:$FRA, (PPCmtfsf (i32 imm:$FM), 
1248                                                      F8RC:$rT, F8RC:$FRB))]>,
1249                PPC970_DGroup_Single, PPC970_Unit_FPU;
1250 }
1251 let Uses = [RM] in {
1252   def MFFS   : XForm_42<63, 583, (outs F8RC:$rT), (ins), 
1253                          "mffs $rT", IntMFFS,
1254                          [(set F8RC:$rT, (PPCmffs))]>,
1255                PPC970_DGroup_Single, PPC970_Unit_FPU;
1256   def FADDrtz: AForm_2<63, 21,
1257                       (outs F8RC:$FRT), (ins F8RC:$FRA, F8RC:$FRB),
1258                       "fadd $FRT, $FRA, $FRB", FPAddSub,
1259                       [(set F8RC:$FRT, (PPCfaddrtz F8RC:$FRA, F8RC:$FRB))]>,
1260                PPC970_DGroup_Single, PPC970_Unit_FPU;
1261 }
1262
1263
1264 let PPC970_Unit = 1 in {  // FXU Operations.
1265
1266 // XO-Form instructions.  Arithmetic instructions that can set overflow bit
1267 //
1268 def ADD4  : XOForm_1<31, 266, 0, (outs GPRC:$rT), (ins GPRC:$rA, GPRC:$rB),
1269                      "add $rT, $rA, $rB", IntSimple,
1270                      [(set GPRC:$rT, (add GPRC:$rA, GPRC:$rB))]>;
1271 let Defs = [CARRY] in {
1272 def ADDC  : XOForm_1<31, 10, 0, (outs GPRC:$rT), (ins GPRC:$rA, GPRC:$rB),
1273                      "addc $rT, $rA, $rB", IntGeneral,
1274                      [(set GPRC:$rT, (addc GPRC:$rA, GPRC:$rB))]>,
1275                      PPC970_DGroup_Cracked;
1276 }
1277 def DIVW  : XOForm_1<31, 491, 0, (outs GPRC:$rT), (ins GPRC:$rA, GPRC:$rB),
1278                      "divw $rT, $rA, $rB", IntDivW,
1279                      [(set GPRC:$rT, (sdiv GPRC:$rA, GPRC:$rB))]>,
1280                      PPC970_DGroup_First, PPC970_DGroup_Cracked;
1281 def DIVWU : XOForm_1<31, 459, 0, (outs GPRC:$rT), (ins GPRC:$rA, GPRC:$rB),
1282                      "divwu $rT, $rA, $rB", IntDivW,
1283                      [(set GPRC:$rT, (udiv GPRC:$rA, GPRC:$rB))]>,
1284                      PPC970_DGroup_First, PPC970_DGroup_Cracked;
1285 def MULHW : XOForm_1<31, 75, 0, (outs GPRC:$rT), (ins GPRC:$rA, GPRC:$rB),
1286                      "mulhw $rT, $rA, $rB", IntMulHW,
1287                      [(set GPRC:$rT, (mulhs GPRC:$rA, GPRC:$rB))]>;
1288 def MULHWU : XOForm_1<31, 11, 0, (outs GPRC:$rT), (ins GPRC:$rA, GPRC:$rB),
1289                      "mulhwu $rT, $rA, $rB", IntMulHWU,
1290                      [(set GPRC:$rT, (mulhu GPRC:$rA, GPRC:$rB))]>;
1291 def MULLW : XOForm_1<31, 235, 0, (outs GPRC:$rT), (ins GPRC:$rA, GPRC:$rB),
1292                      "mullw $rT, $rA, $rB", IntMulHW,
1293                      [(set GPRC:$rT, (mul GPRC:$rA, GPRC:$rB))]>;
1294 def SUBF  : XOForm_1<31, 40, 0, (outs GPRC:$rT), (ins GPRC:$rA, GPRC:$rB),
1295                      "subf $rT, $rA, $rB", IntGeneral,
1296                      [(set GPRC:$rT, (sub GPRC:$rB, GPRC:$rA))]>;
1297 let Defs = [CARRY] in {
1298 def SUBFC : XOForm_1<31, 8, 0, (outs GPRC:$rT), (ins GPRC:$rA, GPRC:$rB),
1299                      "subfc $rT, $rA, $rB", IntGeneral,
1300                      [(set GPRC:$rT, (subc GPRC:$rB, GPRC:$rA))]>,
1301                      PPC970_DGroup_Cracked;
1302 }
1303 def NEG    : XOForm_3<31, 104, 0, (outs GPRC:$rT), (ins GPRC:$rA),
1304                       "neg $rT, $rA", IntSimple,
1305                       [(set GPRC:$rT, (ineg GPRC:$rA))]>;
1306 let Uses = [CARRY], Defs = [CARRY] in {
1307 def ADDE  : XOForm_1<31, 138, 0, (outs GPRC:$rT), (ins GPRC:$rA, GPRC:$rB),
1308                       "adde $rT, $rA, $rB", IntGeneral,
1309                       [(set GPRC:$rT, (adde GPRC:$rA, GPRC:$rB))]>;
1310 def ADDME  : XOForm_3<31, 234, 0, (outs GPRC:$rT), (ins GPRC:$rA),
1311                       "addme $rT, $rA", IntGeneral,
1312                       [(set GPRC:$rT, (adde GPRC:$rA, -1))]>;
1313 def ADDZE  : XOForm_3<31, 202, 0, (outs GPRC:$rT), (ins GPRC:$rA),
1314                       "addze $rT, $rA", IntGeneral,
1315                       [(set GPRC:$rT, (adde GPRC:$rA, 0))]>;
1316 def SUBFE : XOForm_1<31, 136, 0, (outs GPRC:$rT), (ins GPRC:$rA, GPRC:$rB),
1317                       "subfe $rT, $rA, $rB", IntGeneral,
1318                       [(set GPRC:$rT, (sube GPRC:$rB, GPRC:$rA))]>;
1319 def SUBFME : XOForm_3<31, 232, 0, (outs GPRC:$rT), (ins GPRC:$rA),
1320                       "subfme $rT, $rA", IntGeneral,
1321                       [(set GPRC:$rT, (sube -1, GPRC:$rA))]>;
1322 def SUBFZE : XOForm_3<31, 200, 0, (outs GPRC:$rT), (ins GPRC:$rA),
1323                       "subfze $rT, $rA", IntGeneral,
1324                       [(set GPRC:$rT, (sube 0, GPRC:$rA))]>;
1325 }
1326 }
1327
1328 // A-Form instructions.  Most of the instructions executed in the FPU are of
1329 // this type.
1330 //
1331 let PPC970_Unit = 3 in {  // FPU Operations.
1332 let Uses = [RM] in {
1333   def FMADD : AForm_1<63, 29, 
1334                       (outs F8RC:$FRT), (ins F8RC:$FRA, F8RC:$FRC, F8RC:$FRB),
1335                       "fmadd $FRT, $FRA, $FRC, $FRB", FPFused,
1336                       [(set F8RC:$FRT,
1337                             (fma F8RC:$FRA, F8RC:$FRC, F8RC:$FRB))]>;
1338   def FMADDS : AForm_1<59, 29,
1339                       (outs F4RC:$FRT), (ins F4RC:$FRA, F4RC:$FRC, F4RC:$FRB),
1340                       "fmadds $FRT, $FRA, $FRC, $FRB", FPGeneral,
1341                       [(set F4RC:$FRT,
1342                             (fma F4RC:$FRA, F4RC:$FRC, F4RC:$FRB))]>;
1343   def FMSUB : AForm_1<63, 28,
1344                       (outs F8RC:$FRT), (ins F8RC:$FRA, F8RC:$FRC, F8RC:$FRB),
1345                       "fmsub $FRT, $FRA, $FRC, $FRB", FPFused,
1346                       [(set F8RC:$FRT,
1347                             (fma F8RC:$FRA, F8RC:$FRC, (fneg F8RC:$FRB)))]>;
1348   def FMSUBS : AForm_1<59, 28,
1349                       (outs F4RC:$FRT), (ins F4RC:$FRA, F4RC:$FRC, F4RC:$FRB),
1350                       "fmsubs $FRT, $FRA, $FRC, $FRB", FPGeneral,
1351                       [(set F4RC:$FRT,
1352                             (fma F4RC:$FRA, F4RC:$FRC, (fneg F4RC:$FRB)))]>;
1353   def FNMADD : AForm_1<63, 31,
1354                       (outs F8RC:$FRT), (ins F8RC:$FRA, F8RC:$FRC, F8RC:$FRB),
1355                       "fnmadd $FRT, $FRA, $FRC, $FRB", FPFused,
1356                       [(set F8RC:$FRT,
1357                             (fneg (fma F8RC:$FRA, F8RC:$FRC, F8RC:$FRB)))]>;
1358   def FNMADDS : AForm_1<59, 31,
1359                       (outs F4RC:$FRT), (ins F4RC:$FRA, F4RC:$FRC, F4RC:$FRB),
1360                       "fnmadds $FRT, $FRA, $FRC, $FRB", FPGeneral,
1361                       [(set F4RC:$FRT,
1362                             (fneg (fma F4RC:$FRA, F4RC:$FRC, F4RC:$FRB)))]>;
1363   def FNMSUB : AForm_1<63, 30,
1364                       (outs F8RC:$FRT), (ins F8RC:$FRA, F8RC:$FRC, F8RC:$FRB),
1365                       "fnmsub $FRT, $FRA, $FRC, $FRB", FPFused,
1366                       [(set F8RC:$FRT, (fneg (fma F8RC:$FRA, F8RC:$FRC,
1367                                                   (fneg F8RC:$FRB))))]>;
1368   def FNMSUBS : AForm_1<59, 30,
1369                       (outs F4RC:$FRT), (ins F4RC:$FRA, F4RC:$FRC, F4RC:$FRB),
1370                       "fnmsubs $FRT, $FRA, $FRC, $FRB", FPGeneral,
1371                       [(set F4RC:$FRT, (fneg (fma F4RC:$FRA, F4RC:$FRC,
1372                                                   (fneg F4RC:$FRB))))]>;
1373 }
1374 // FSEL is artificially split into 4 and 8-byte forms for the result.  To avoid
1375 // having 4 of these, force the comparison to always be an 8-byte double (code
1376 // should use an FMRSD if the input comparison value really wants to be a float)
1377 // and 4/8 byte forms for the result and operand type..
1378 def FSELD : AForm_1<63, 23,
1379                     (outs F8RC:$FRT), (ins F8RC:$FRA, F8RC:$FRC, F8RC:$FRB),
1380                     "fsel $FRT, $FRA, $FRC, $FRB", FPGeneral,
1381                     [(set F8RC:$FRT, (PPCfsel F8RC:$FRA,F8RC:$FRC,F8RC:$FRB))]>;
1382 def FSELS : AForm_1<63, 23,
1383                      (outs F4RC:$FRT), (ins F8RC:$FRA, F4RC:$FRC, F4RC:$FRB),
1384                      "fsel $FRT, $FRA, $FRC, $FRB", FPGeneral,
1385                     [(set F4RC:$FRT, (PPCfsel F8RC:$FRA,F4RC:$FRC,F4RC:$FRB))]>;
1386 let Uses = [RM] in {
1387   def FADD  : AForm_2<63, 21,
1388                       (outs F8RC:$FRT), (ins F8RC:$FRA, F8RC:$FRB),
1389                       "fadd $FRT, $FRA, $FRB", FPAddSub,
1390                       [(set F8RC:$FRT, (fadd F8RC:$FRA, F8RC:$FRB))]>;
1391   def FADDS : AForm_2<59, 21,
1392                       (outs F4RC:$FRT), (ins F4RC:$FRA, F4RC:$FRB),
1393                       "fadds $FRT, $FRA, $FRB", FPGeneral,
1394                       [(set F4RC:$FRT, (fadd F4RC:$FRA, F4RC:$FRB))]>;
1395   def FDIV  : AForm_2<63, 18,
1396                       (outs F8RC:$FRT), (ins F8RC:$FRA, F8RC:$FRB),
1397                       "fdiv $FRT, $FRA, $FRB", FPDivD,
1398                       [(set F8RC:$FRT, (fdiv F8RC:$FRA, F8RC:$FRB))]>;
1399   def FDIVS : AForm_2<59, 18,
1400                       (outs F4RC:$FRT), (ins F4RC:$FRA, F4RC:$FRB),
1401                       "fdivs $FRT, $FRA, $FRB", FPDivS,
1402                       [(set F4RC:$FRT, (fdiv F4RC:$FRA, F4RC:$FRB))]>;
1403   def FMUL  : AForm_3<63, 25,
1404                       (outs F8RC:$FRT), (ins F8RC:$FRA, F8RC:$FRC),
1405                       "fmul $FRT, $FRA, $FRC", FPFused,
1406                       [(set F8RC:$FRT, (fmul F8RC:$FRA, F8RC:$FRC))]>;
1407   def FMULS : AForm_3<59, 25,
1408                       (outs F4RC:$FRT), (ins F4RC:$FRA, F4RC:$FRC),
1409                       "fmuls $FRT, $FRA, $FRC", FPGeneral,
1410                       [(set F4RC:$FRT, (fmul F4RC:$FRA, F4RC:$FRC))]>;
1411   def FSUB  : AForm_2<63, 20,
1412                       (outs F8RC:$FRT), (ins F8RC:$FRA, F8RC:$FRB),
1413                       "fsub $FRT, $FRA, $FRB", FPAddSub,
1414                       [(set F8RC:$FRT, (fsub F8RC:$FRA, F8RC:$FRB))]>;
1415   def FSUBS : AForm_2<59, 20,
1416                       (outs F4RC:$FRT), (ins F4RC:$FRA, F4RC:$FRB),
1417                       "fsubs $FRT, $FRA, $FRB", FPGeneral,
1418                       [(set F4RC:$FRT, (fsub F4RC:$FRA, F4RC:$FRB))]>;
1419   }
1420 }
1421
1422 let PPC970_Unit = 1 in {  // FXU Operations.
1423   def ISEL  : AForm_4<31, 15,
1424                      (outs GPRC:$rT), (ins GPRC:$rA, GPRC:$rB, pred:$cond),
1425                      "isel $rT, $rA, $rB, $cond", IntGeneral,
1426                      []>;
1427 }
1428
1429 let PPC970_Unit = 1 in {  // FXU Operations.
1430 // M-Form instructions.  rotate and mask instructions.
1431 //
1432 let isCommutable = 1 in {
1433 // RLWIMI can be commuted if the rotate amount is zero.
1434 def RLWIMI : MForm_2<20,
1435                      (outs GPRC:$rA), (ins GPRC:$rSi, GPRC:$rS, u5imm:$SH, u5imm:$MB, 
1436                       u5imm:$ME), "rlwimi $rA, $rS, $SH, $MB, $ME", IntRotate,
1437                       []>, PPC970_DGroup_Cracked, RegConstraint<"$rSi = $rA">,
1438                       NoEncode<"$rSi">;
1439 }
1440 def RLWINM : MForm_2<21,
1441                      (outs GPRC:$rA), (ins GPRC:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
1442                      "rlwinm $rA, $rS, $SH, $MB, $ME", IntGeneral,
1443                      []>;
1444 def RLWINMo : MForm_2<21,
1445                      (outs GPRC:$rA), (ins GPRC:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
1446                      "rlwinm. $rA, $rS, $SH, $MB, $ME", IntGeneral,
1447                      []>, isDOT, PPC970_DGroup_Cracked;
1448 def RLWNM  : MForm_2<23,
1449                      (outs GPRC:$rA), (ins GPRC:$rS, GPRC:$rB, u5imm:$MB, u5imm:$ME),
1450                      "rlwnm $rA, $rS, $rB, $MB, $ME", IntGeneral,
1451                      []>;
1452 }
1453
1454
1455 //===----------------------------------------------------------------------===//
1456 // PowerPC Instruction Patterns
1457 //
1458
1459 // Arbitrary immediate support.  Implement in terms of LIS/ORI.
1460 def : Pat<(i32 imm:$imm),
1461           (ORI (LIS (HI16 imm:$imm)), (LO16 imm:$imm))>;
1462
1463 // Implement the 'not' operation with the NOR instruction.
1464 def NOT : Pat<(not GPRC:$in),
1465               (NOR GPRC:$in, GPRC:$in)>;
1466
1467 // ADD an arbitrary immediate.
1468 def : Pat<(add GPRC:$in, imm:$imm),
1469           (ADDIS (ADDI GPRC:$in, (LO16 imm:$imm)), (HA16 imm:$imm))>;
1470 // OR an arbitrary immediate.
1471 def : Pat<(or GPRC:$in, imm:$imm),
1472           (ORIS (ORI GPRC:$in, (LO16 imm:$imm)), (HI16 imm:$imm))>;
1473 // XOR an arbitrary immediate.
1474 def : Pat<(xor GPRC:$in, imm:$imm),
1475           (XORIS (XORI GPRC:$in, (LO16 imm:$imm)), (HI16 imm:$imm))>;
1476 // SUBFIC
1477 def : Pat<(sub  immSExt16:$imm, GPRC:$in),
1478           (SUBFIC GPRC:$in, imm:$imm)>;
1479
1480 // SHL/SRL
1481 def : Pat<(shl GPRC:$in, (i32 imm:$imm)),
1482           (RLWINM GPRC:$in, imm:$imm, 0, (SHL32 imm:$imm))>;
1483 def : Pat<(srl GPRC:$in, (i32 imm:$imm)),
1484           (RLWINM GPRC:$in, (SRL32 imm:$imm), imm:$imm, 31)>;
1485
1486 // ROTL
1487 def : Pat<(rotl GPRC:$in, GPRC:$sh),
1488           (RLWNM GPRC:$in, GPRC:$sh, 0, 31)>;
1489 def : Pat<(rotl GPRC:$in, (i32 imm:$imm)),
1490           (RLWINM GPRC:$in, imm:$imm, 0, 31)>;
1491
1492 // RLWNM
1493 def : Pat<(and (rotl GPRC:$in, GPRC:$sh), maskimm32:$imm),
1494           (RLWNM GPRC:$in, GPRC:$sh, (MB maskimm32:$imm), (ME maskimm32:$imm))>;
1495
1496 // Calls
1497 def : Pat<(PPCcall_Darwin (i32 tglobaladdr:$dst)),
1498           (BL_Darwin tglobaladdr:$dst)>;
1499 def : Pat<(PPCcall_Darwin (i32 texternalsym:$dst)),
1500           (BL_Darwin texternalsym:$dst)>;
1501 def : Pat<(PPCcall_SVR4 (i32 tglobaladdr:$dst)),
1502           (BL_SVR4 tglobaladdr:$dst)>;
1503 def : Pat<(PPCcall_SVR4 (i32 texternalsym:$dst)),
1504           (BL_SVR4 texternalsym:$dst)>;
1505
1506
1507 def : Pat<(PPCtc_return (i32 tglobaladdr:$dst),  imm:$imm),
1508           (TCRETURNdi tglobaladdr:$dst, imm:$imm)>;
1509
1510 def : Pat<(PPCtc_return (i32 texternalsym:$dst), imm:$imm),
1511           (TCRETURNdi texternalsym:$dst, imm:$imm)>;
1512
1513 def : Pat<(PPCtc_return CTRRC:$dst, imm:$imm),
1514           (TCRETURNri CTRRC:$dst, imm:$imm)>;
1515
1516
1517
1518 // Hi and Lo for Darwin Global Addresses.
1519 def : Pat<(PPChi tglobaladdr:$in, 0), (LIS tglobaladdr:$in)>;
1520 def : Pat<(PPClo tglobaladdr:$in, 0), (LI tglobaladdr:$in)>;
1521 def : Pat<(PPChi tconstpool:$in, 0), (LIS tconstpool:$in)>;
1522 def : Pat<(PPClo tconstpool:$in, 0), (LI tconstpool:$in)>;
1523 def : Pat<(PPChi tjumptable:$in, 0), (LIS tjumptable:$in)>;
1524 def : Pat<(PPClo tjumptable:$in, 0), (LI tjumptable:$in)>;
1525 def : Pat<(PPChi tblockaddress:$in, 0), (LIS tblockaddress:$in)>;
1526 def : Pat<(PPClo tblockaddress:$in, 0), (LI tblockaddress:$in)>;
1527 def : Pat<(PPChi tglobaltlsaddr:$g, GPRC:$in),
1528           (ADDIS GPRC:$in, tglobaltlsaddr:$g)>;
1529 def : Pat<(PPClo tglobaltlsaddr:$g, GPRC:$in),
1530           (ADDIL GPRC:$in, tglobaltlsaddr:$g)>;
1531 def : Pat<(add GPRC:$in, (PPChi tglobaladdr:$g, 0)),
1532           (ADDIS GPRC:$in, tglobaladdr:$g)>;
1533 def : Pat<(add GPRC:$in, (PPChi tconstpool:$g, 0)),
1534           (ADDIS GPRC:$in, tconstpool:$g)>;
1535 def : Pat<(add GPRC:$in, (PPChi tjumptable:$g, 0)),
1536           (ADDIS GPRC:$in, tjumptable:$g)>;
1537 def : Pat<(add GPRC:$in, (PPChi tblockaddress:$g, 0)),
1538           (ADDIS GPRC:$in, tblockaddress:$g)>;
1539
1540 // Standard shifts.  These are represented separately from the real shifts above
1541 // so that we can distinguish between shifts that allow 5-bit and 6-bit shift
1542 // amounts.
1543 def : Pat<(sra GPRC:$rS, GPRC:$rB),
1544           (SRAW GPRC:$rS, GPRC:$rB)>;
1545 def : Pat<(srl GPRC:$rS, GPRC:$rB),
1546           (SRW GPRC:$rS, GPRC:$rB)>;
1547 def : Pat<(shl GPRC:$rS, GPRC:$rB),
1548           (SLW GPRC:$rS, GPRC:$rB)>;
1549
1550 def : Pat<(zextloadi1 iaddr:$src),
1551           (LBZ iaddr:$src)>;
1552 def : Pat<(zextloadi1 xaddr:$src),
1553           (LBZX xaddr:$src)>;
1554 def : Pat<(extloadi1 iaddr:$src),
1555           (LBZ iaddr:$src)>;
1556 def : Pat<(extloadi1 xaddr:$src),
1557           (LBZX xaddr:$src)>;
1558 def : Pat<(extloadi8 iaddr:$src),
1559           (LBZ iaddr:$src)>;
1560 def : Pat<(extloadi8 xaddr:$src),
1561           (LBZX xaddr:$src)>;
1562 def : Pat<(extloadi16 iaddr:$src),
1563           (LHZ iaddr:$src)>;
1564 def : Pat<(extloadi16 xaddr:$src),
1565           (LHZX xaddr:$src)>;
1566 def : Pat<(f64 (extloadf32 iaddr:$src)),
1567           (COPY_TO_REGCLASS (LFS iaddr:$src), F8RC)>;
1568 def : Pat<(f64 (extloadf32 xaddr:$src)),
1569           (COPY_TO_REGCLASS (LFSX xaddr:$src), F8RC)>;
1570
1571 def : Pat<(f64 (fextend F4RC:$src)),
1572           (COPY_TO_REGCLASS F4RC:$src, F8RC)>;
1573
1574 // Memory barriers
1575 def : Pat<(membarrier (i32 imm /*ll*/),
1576                       (i32 imm /*ls*/),
1577                       (i32 imm /*sl*/),
1578                       (i32 imm /*ss*/),
1579                       (i32 imm /*device*/)),
1580            (SYNC)>;
1581
1582 def : Pat<(atomic_fence (imm), (imm)), (SYNC)>;
1583
1584 include "PPCInstrAltivec.td"
1585 include "PPCInstr64Bit.td"