blob: 9813c967652e98731ea7be48c81fba04eaa3f8d2 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===- PPCInstrInfo.td - The PowerPC Instruction Set -------*- tablegen -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source 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
15include "PPCInstrFormats.td"
16
17//===----------------------------------------------------------------------===//
18// PowerPC specific type constraints.
19//
20def SDT_PPCstfiwx : SDTypeProfile<0, 2, [ // stfiwx
21 SDTCisVT<0, f64>, SDTCisPtrTy<1>
22]>;
23def SDT_PPCShiftOp : SDTypeProfile<1, 2, [ // PPCshl, PPCsra, PPCsrl
24 SDTCisVT<0, i32>, SDTCisVT<1, i32>, SDTCisVT<2, i32>
25]>;
26def SDT_PPCCallSeq : SDTypeProfile<0, 1, [ SDTCisVT<0, i32> ]>;
27
28def SDT_PPCvperm : SDTypeProfile<1, 3, [
29 SDTCisVT<3, v16i8>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>
30]>;
31
32def SDT_PPCvcmp : SDTypeProfile<1, 3, [
33 SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisVT<3, i32>
34]>;
35
36def SDT_PPCcondbr : SDTypeProfile<0, 3, [
37 SDTCisVT<0, i32>, SDTCisVT<2, OtherVT>
38]>;
39
40def SDT_PPClbrx : SDTypeProfile<1, 3, [
41 SDTCisVT<0, i32>, SDTCisPtrTy<1>, SDTCisVT<2, OtherVT>, SDTCisVT<3, OtherVT>
42]>;
43def SDT_PPCstbrx : SDTypeProfile<0, 4, [
44 SDTCisVT<0, i32>, SDTCisPtrTy<1>, SDTCisVT<2, OtherVT>, SDTCisVT<3, OtherVT>
45]>;
46
47//===----------------------------------------------------------------------===//
48// PowerPC specific DAG Nodes.
49//
50
51def PPCfcfid : SDNode<"PPCISD::FCFID" , SDTFPUnaryOp, []>;
52def PPCfctidz : SDNode<"PPCISD::FCTIDZ", SDTFPUnaryOp, []>;
53def PPCfctiwz : SDNode<"PPCISD::FCTIWZ", SDTFPUnaryOp, []>;
54def PPCstfiwx : SDNode<"PPCISD::STFIWX", SDT_PPCstfiwx, [SDNPHasChain]>;
55
56def PPCfsel : SDNode<"PPCISD::FSEL",
57 // Type constraint for fsel.
58 SDTypeProfile<1, 3, [SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>,
59 SDTCisFP<0>, SDTCisVT<1, f64>]>, []>;
60
61def PPChi : SDNode<"PPCISD::Hi", SDTIntBinOp, []>;
62def PPClo : SDNode<"PPCISD::Lo", SDTIntBinOp, []>;
63def PPCvmaddfp : SDNode<"PPCISD::VMADDFP", SDTFPTernaryOp, []>;
64def PPCvnmsubfp : SDNode<"PPCISD::VNMSUBFP", SDTFPTernaryOp, []>;
65
66def PPCvperm : SDNode<"PPCISD::VPERM", SDT_PPCvperm, []>;
67
68// These nodes represent the 32-bit PPC shifts that operate on 6-bit shift
69// amounts. These nodes are generated by the multi-precision shift code.
70def PPCsrl : SDNode<"PPCISD::SRL" , SDT_PPCShiftOp>;
71def PPCsra : SDNode<"PPCISD::SRA" , SDT_PPCShiftOp>;
72def PPCshl : SDNode<"PPCISD::SHL" , SDT_PPCShiftOp>;
73
74def PPCextsw_32 : SDNode<"PPCISD::EXTSW_32" , SDTIntUnaryOp>;
75def PPCstd_32 : SDNode<"PPCISD::STD_32" , SDTStore, [SDNPHasChain]>;
76
77// These are target-independent nodes, but have target-specific formats.
78def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_PPCCallSeq,
79 [SDNPHasChain, SDNPOutFlag]>;
80def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_PPCCallSeq,
81 [SDNPHasChain, SDNPOutFlag]>;
82
83def SDT_PPCCall : SDTypeProfile<0, -1, [SDTCisInt<0>]>;
84def PPCcall_Macho : SDNode<"PPCISD::CALL_Macho", SDT_PPCCall,
85 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
86def PPCcall_ELF : SDNode<"PPCISD::CALL_ELF", SDT_PPCCall,
87 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
88def PPCmtctr : SDNode<"PPCISD::MTCTR", SDT_PPCCall,
89 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
90def PPCbctrl_Macho : SDNode<"PPCISD::BCTRL_Macho", SDTRet,
91 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
92
93def PPCbctrl_ELF : SDNode<"PPCISD::BCTRL_ELF", SDTRet,
94 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
95
96def retflag : SDNode<"PPCISD::RET_FLAG", SDTRet,
97 [SDNPHasChain, SDNPOptInFlag]>;
98
99def PPCvcmp : SDNode<"PPCISD::VCMP" , SDT_PPCvcmp, []>;
100def PPCvcmp_o : SDNode<"PPCISD::VCMPo", SDT_PPCvcmp, [SDNPOutFlag]>;
101
102def PPCcondbranch : SDNode<"PPCISD::COND_BRANCH", SDT_PPCcondbr,
103 [SDNPHasChain, SDNPOptInFlag]>;
104
105def PPClbrx : SDNode<"PPCISD::LBRX", SDT_PPClbrx, [SDNPHasChain]>;
106def PPCstbrx : SDNode<"PPCISD::STBRX", SDT_PPCstbrx, [SDNPHasChain]>;
107
108// Instructions to support dynamic alloca.
109def SDTDynOp : SDTypeProfile<1, 2, []>;
110def PPCdynalloc : SDNode<"PPCISD::DYNALLOC", SDTDynOp, [SDNPHasChain]>;
111
112//===----------------------------------------------------------------------===//
113// PowerPC specific transformation functions and pattern fragments.
114//
115
116def SHL32 : SDNodeXForm<imm, [{
117 // Transformation function: 31 - imm
118 return getI32Imm(31 - N->getValue());
119}]>;
120
121def SRL32 : SDNodeXForm<imm, [{
122 // Transformation function: 32 - imm
123 return N->getValue() ? getI32Imm(32 - N->getValue()) : getI32Imm(0);
124}]>;
125
126def LO16 : SDNodeXForm<imm, [{
127 // Transformation function: get the low 16 bits.
128 return getI32Imm((unsigned short)N->getValue());
129}]>;
130
131def HI16 : SDNodeXForm<imm, [{
132 // Transformation function: shift the immediate value down into the low bits.
133 return getI32Imm((unsigned)N->getValue() >> 16);
134}]>;
135
136def HA16 : SDNodeXForm<imm, [{
137 // Transformation function: shift the immediate value down into the low bits.
138 signed int Val = N->getValue();
139 return getI32Imm((Val - (signed short)Val) >> 16);
140}]>;
141def MB : SDNodeXForm<imm, [{
142 // Transformation function: get the start bit of a mask
143 unsigned mb, me;
144 (void)isRunOfOnes((unsigned)N->getValue(), mb, me);
145 return getI32Imm(mb);
146}]>;
147
148def ME : SDNodeXForm<imm, [{
149 // Transformation function: get the end bit of a mask
150 unsigned mb, me;
151 (void)isRunOfOnes((unsigned)N->getValue(), mb, me);
152 return getI32Imm(me);
153}]>;
154def maskimm32 : PatLeaf<(imm), [{
155 // maskImm predicate - True if immediate is a run of ones.
156 unsigned mb, me;
157 if (N->getValueType(0) == MVT::i32)
158 return isRunOfOnes((unsigned)N->getValue(), mb, me);
159 else
160 return false;
161}]>;
162
163def immSExt16 : PatLeaf<(imm), [{
164 // immSExt16 predicate - True if the immediate fits in a 16-bit sign extended
165 // field. Used by instructions like 'addi'.
166 if (N->getValueType(0) == MVT::i32)
167 return (int32_t)N->getValue() == (short)N->getValue();
168 else
169 return (int64_t)N->getValue() == (short)N->getValue();
170}]>;
171def immZExt16 : PatLeaf<(imm), [{
172 // immZExt16 predicate - True if the immediate fits in a 16-bit zero extended
173 // field. Used by instructions like 'ori'.
174 return (uint64_t)N->getValue() == (unsigned short)N->getValue();
175}], LO16>;
176
177// imm16Shifted* - These match immediates where the low 16-bits are zero. There
178// are two forms: imm16ShiftedSExt and imm16ShiftedZExt. These two forms are
179// identical in 32-bit mode, but in 64-bit mode, they return true if the
180// immediate fits into a sign/zero extended 32-bit immediate (with the low bits
181// clear).
182def imm16ShiftedZExt : PatLeaf<(imm), [{
183 // imm16ShiftedZExt predicate - True if only bits in the top 16-bits of the
184 // immediate are set. Used by instructions like 'xoris'.
185 return (N->getValue() & ~uint64_t(0xFFFF0000)) == 0;
186}], HI16>;
187
188def imm16ShiftedSExt : PatLeaf<(imm), [{
189 // imm16ShiftedSExt predicate - True if only bits in the top 16-bits of the
190 // immediate are set. Used by instructions like 'addis'. Identical to
191 // imm16ShiftedZExt in 32-bit mode.
192 if (N->getValue() & 0xFFFF) return false;
193 if (N->getValueType(0) == MVT::i32)
194 return true;
195 // For 64-bit, make sure it is sext right.
196 return N->getValue() == (uint64_t)(int)N->getValue();
197}], HI16>;
198
199
200//===----------------------------------------------------------------------===//
201// PowerPC Flag Definitions.
202
203class isPPC64 { bit PPC64 = 1; }
204class isDOT {
205 list<Register> Defs = [CR0];
206 bit RC = 1;
207}
208
209class RegConstraint<string C> {
210 string Constraints = C;
211}
212class NoEncode<string E> {
213 string DisableEncoding = E;
214}
215
216
217//===----------------------------------------------------------------------===//
218// PowerPC Operand Definitions.
219
220def s5imm : Operand<i32> {
221 let PrintMethod = "printS5ImmOperand";
222}
223def u5imm : Operand<i32> {
224 let PrintMethod = "printU5ImmOperand";
225}
226def u6imm : Operand<i32> {
227 let PrintMethod = "printU6ImmOperand";
228}
229def s16imm : Operand<i32> {
230 let PrintMethod = "printS16ImmOperand";
231}
232def u16imm : Operand<i32> {
233 let PrintMethod = "printU16ImmOperand";
234}
235def s16immX4 : Operand<i32> { // Multiply imm by 4 before printing.
236 let PrintMethod = "printS16X4ImmOperand";
237}
238def target : Operand<OtherVT> {
239 let PrintMethod = "printBranchOperand";
240}
241def calltarget : Operand<iPTR> {
242 let PrintMethod = "printCallOperand";
243}
244def aaddr : Operand<iPTR> {
245 let PrintMethod = "printAbsAddrOperand";
246}
247def piclabel: Operand<iPTR> {
248 let PrintMethod = "printPICLabel";
249}
250def symbolHi: Operand<i32> {
251 let PrintMethod = "printSymbolHi";
252}
253def symbolLo: Operand<i32> {
254 let PrintMethod = "printSymbolLo";
255}
256def crbitm: Operand<i8> {
257 let PrintMethod = "printcrbitm";
258}
259// Address operands
260def memri : Operand<iPTR> {
261 let PrintMethod = "printMemRegImm";
262 let MIOperandInfo = (ops i32imm:$imm, ptr_rc:$reg);
263}
264def memrr : Operand<iPTR> {
265 let PrintMethod = "printMemRegReg";
266 let MIOperandInfo = (ops ptr_rc, ptr_rc);
267}
268def memrix : Operand<iPTR> { // memri where the imm is shifted 2 bits.
269 let PrintMethod = "printMemRegImmShifted";
270 let MIOperandInfo = (ops i32imm:$imm, ptr_rc:$reg);
271}
272
273// PowerPC Predicate operand. 20 = (0<<5)|20 = always, CR0 is a dummy reg
274// that doesn't matter.
275def pred : PredicateOperand<OtherVT, (ops imm, CRRC),
276 (ops (i32 20), CR0)> {
277 let PrintMethod = "printPredicateOperand";
278}
279
280// Define PowerPC specific addressing mode.
281def iaddr : ComplexPattern<iPTR, 2, "SelectAddrImm", [], []>;
282def xaddr : ComplexPattern<iPTR, 2, "SelectAddrIdx", [], []>;
283def xoaddr : ComplexPattern<iPTR, 2, "SelectAddrIdxOnly",[], []>;
284def ixaddr : ComplexPattern<iPTR, 2, "SelectAddrImmShift", [], []>; // "std"
285
286/// This is just the offset part of iaddr, used for preinc.
287def iaddroff : ComplexPattern<iPTR, 1, "SelectAddrImmOffs", [], []>;
288
289//===----------------------------------------------------------------------===//
290// PowerPC Instruction Predicate Definitions.
291def FPContractions : Predicate<"!NoExcessFPPrecision">;
292
293
294//===----------------------------------------------------------------------===//
295// PowerPC Instruction Definitions.
296
297// Pseudo-instructions:
298
299let hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000300def ADJCALLSTACKDOWN : Pseudo<(outs), (ins u16imm:$amt),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000301 "${:comment} ADJCALLSTACKDOWN",
302 [(callseq_start imm:$amt)]>, Imp<[R1],[R1]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000303def ADJCALLSTACKUP : Pseudo<(outs), (ins u16imm:$amt),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000304 "${:comment} ADJCALLSTACKUP",
305 [(callseq_end imm:$amt)]>, Imp<[R1],[R1]>;
306
Evan Chengb783fa32007-07-19 01:14:50 +0000307def UPDATE_VRSAVE : Pseudo<(outs GPRC:$rD), (ins GPRC:$rS),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000308 "UPDATE_VRSAVE $rD, $rS", []>;
309}
310
Evan Chengb783fa32007-07-19 01:14:50 +0000311def DYNALLOC : Pseudo<(outs GPRC:$result), (ins GPRC:$negsize, memri:$fpsi),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000312 "${:comment} DYNALLOC $result, $negsize, $fpsi",
313 [(set GPRC:$result,
314 (PPCdynalloc GPRC:$negsize, iaddr:$fpsi))]>,
315 Imp<[R1],[R1]>;
316
Evan Chengb783fa32007-07-19 01:14:50 +0000317def IMPLICIT_DEF_GPRC: Pseudo<(outs GPRC:$rD), (ins),
318 "${:comment}IMPLICIT_DEF_GPRC $rD",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000319 [(set GPRC:$rD, (undef))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000320def IMPLICIT_DEF_F8 : Pseudo<(outs F8RC:$rD), (ins),
321 "${:comment} IMPLICIT_DEF_F8 $rD",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000322 [(set F8RC:$rD, (undef))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000323def IMPLICIT_DEF_F4 : Pseudo<(outs F4RC:$rD), (ins),
324 "${:comment} IMPLICIT_DEF_F4 $rD",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000325 [(set F4RC:$rD, (undef))]>;
326
327// SELECT_CC_* - Used to implement the SELECT_CC DAG operation. Expanded by the
328// scheduler into a branch sequence.
329let usesCustomDAGSchedInserter = 1, // Expanded by the scheduler.
330 PPC970_Single = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000331 def SELECT_CC_I4 : Pseudo<(outs GPRC:$dst), (ins CRRC:$cond, GPRC:$T, GPRC:$F,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000332 i32imm:$BROPC), "${:comment} SELECT_CC PSEUDO!",
333 []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000334 def SELECT_CC_I8 : Pseudo<(outs G8RC:$dst), (ins CRRC:$cond, G8RC:$T, G8RC:$F,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000335 i32imm:$BROPC), "${:comment} SELECT_CC PSEUDO!",
336 []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000337 def SELECT_CC_F4 : Pseudo<(outs F4RC:$dst), (ins CRRC:$cond, F4RC:$T, F4RC:$F,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000338 i32imm:$BROPC), "${:comment} SELECT_CC PSEUDO!",
339 []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000340 def SELECT_CC_F8 : Pseudo<(outs F8RC:$dst), (ins CRRC:$cond, F8RC:$T, F8RC:$F,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000341 i32imm:$BROPC), "${:comment} SELECT_CC PSEUDO!",
342 []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000343 def SELECT_CC_VRRC: Pseudo<(outs VRRC:$dst), (ins CRRC:$cond, VRRC:$T, VRRC:$F,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000344 i32imm:$BROPC), "${:comment} SELECT_CC PSEUDO!",
345 []>;
346}
347
Evan Cheng37e7c752007-07-21 00:34:19 +0000348let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000349 let isReturn = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000350 def BLR : XLForm_2_br<19, 16, 0, (outs), (ins pred:$p),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000351 "b${p:cc}lr ${p:reg}", BrB,
352 [(retflag)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000353 def BCTR : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", BrB, []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000354}
355
356
357
358let Defs = [LR] in
Evan Chengb783fa32007-07-19 01:14:50 +0000359 def MovePCtoLR : Pseudo<(outs), (ins piclabel:$label), "bl $label", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000360 PPC970_Unit_BRU;
361
Evan Cheng37e7c752007-07-21 00:34:19 +0000362let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000363 let isBarrier = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000364 def B : IForm<18, 0, 0, (outs), (ins target:$dst),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000365 "b $dst", BrB,
366 [(br bb:$dst)]>;
367 }
368
369 // BCC represents an arbitrary conditional branch on a predicate.
370 // FIXME: should be able to write a pattern for PPCcondbranch, but can't use
371 // a two-value operand where a dag node expects two operands. :(
Evan Chengb783fa32007-07-19 01:14:50 +0000372 def BCC : BForm<16, 0, 0, (outs), (ins pred:$cond, target:$dst),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000373 "b${cond:cc} ${cond:reg}, $dst"
374 /*[(PPCcondbranch CRRC:$crS, imm:$opc, bb:$dst)]*/>;
375}
376
377// Macho ABI Calls.
Evan Cheng37e7c752007-07-21 00:34:19 +0000378let isCall = 1, PPC970_Unit = 7,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000379 // All calls clobber the non-callee saved registers...
380 Defs = [R0,R2,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,
381 F0,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,
382 V0,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11,V12,V13,V14,V15,V16,V17,V18,V19,
383 LR,CTR,
384 CR0,CR1,CR5,CR6,CR7] in {
385 // Convenient aliases for call instructions
386 def BL_Macho : IForm<18, 0, 1,
Evan Chengb783fa32007-07-19 01:14:50 +0000387 (outs), (ins calltarget:$func, variable_ops),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000388 "bl $func", BrB, []>; // See Pat patterns below.
389 def BLA_Macho : IForm<18, 1, 1,
Evan Chengb783fa32007-07-19 01:14:50 +0000390 (outs), (ins aaddr:$func, variable_ops),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000391 "bla $func", BrB, [(PPCcall_Macho (i32 imm:$func))]>;
392 def BCTRL_Macho : XLForm_2_ext<19, 528, 20, 0, 1,
Evan Chengb783fa32007-07-19 01:14:50 +0000393 (outs), (ins variable_ops),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000394 "bctrl", BrB,
395 [(PPCbctrl_Macho)]>;
396}
397
398// ELF ABI Calls.
Evan Cheng37e7c752007-07-21 00:34:19 +0000399let isCall = 1, PPC970_Unit = 7,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000400 // All calls clobber the non-callee saved registers...
401 Defs = [R0,R2,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,
402 F0,F1,F2,F3,F4,F5,F6,F7,F8,
403 V0,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11,V12,V13,V14,V15,V16,V17,V18,V19,
404 LR,CTR,
405 CR0,CR1,CR5,CR6,CR7] in {
406 // Convenient aliases for call instructions
407 def BL_ELF : IForm<18, 0, 1,
Evan Chengb783fa32007-07-19 01:14:50 +0000408 (outs), (ins calltarget:$func, variable_ops),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000409 "bl $func", BrB, []>; // See Pat patterns below.
410 def BLA_ELF : IForm<18, 1, 1,
Evan Chengb783fa32007-07-19 01:14:50 +0000411 (outs), (ins aaddr:$func, variable_ops),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000412 "bla $func", BrB,
413 [(PPCcall_ELF (i32 imm:$func))]>;
414 def BCTRL_ELF : XLForm_2_ext<19, 528, 20, 0, 1,
Evan Chengb783fa32007-07-19 01:14:50 +0000415 (outs), (ins variable_ops),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000416 "bctrl", BrB,
417 [(PPCbctrl_ELF)]>;
418}
419
420// DCB* instructions.
Evan Chengb783fa32007-07-19 01:14:50 +0000421def DCBA : DCB_Form<758, 0, (outs), (ins memrr:$dst),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000422 "dcba $dst", LdStDCBF, [(int_ppc_dcba xoaddr:$dst)]>,
423 PPC970_DGroup_Single;
Evan Chengb783fa32007-07-19 01:14:50 +0000424def DCBF : DCB_Form<86, 0, (outs), (ins memrr:$dst),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000425 "dcbf $dst", LdStDCBF, [(int_ppc_dcbf xoaddr:$dst)]>,
426 PPC970_DGroup_Single;
Evan Chengb783fa32007-07-19 01:14:50 +0000427def DCBI : DCB_Form<470, 0, (outs), (ins memrr:$dst),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000428 "dcbi $dst", LdStDCBF, [(int_ppc_dcbi xoaddr:$dst)]>,
429 PPC970_DGroup_Single;
Evan Chengb783fa32007-07-19 01:14:50 +0000430def DCBST : DCB_Form<54, 0, (outs), (ins memrr:$dst),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000431 "dcbst $dst", LdStDCBF, [(int_ppc_dcbst xoaddr:$dst)]>,
432 PPC970_DGroup_Single;
Evan Chengb783fa32007-07-19 01:14:50 +0000433def DCBT : DCB_Form<278, 0, (outs), (ins memrr:$dst),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000434 "dcbt $dst", LdStDCBF, [(int_ppc_dcbt xoaddr:$dst)]>,
435 PPC970_DGroup_Single;
Evan Chengb783fa32007-07-19 01:14:50 +0000436def DCBTST : DCB_Form<246, 0, (outs), (ins memrr:$dst),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000437 "dcbtst $dst", LdStDCBF, [(int_ppc_dcbtst xoaddr:$dst)]>,
438 PPC970_DGroup_Single;
Evan Chengb783fa32007-07-19 01:14:50 +0000439def DCBZ : DCB_Form<1014, 0, (outs), (ins memrr:$dst),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000440 "dcbz $dst", LdStDCBF, [(int_ppc_dcbz xoaddr:$dst)]>,
441 PPC970_DGroup_Single;
Evan Chengb783fa32007-07-19 01:14:50 +0000442def DCBZL : DCB_Form<1014, 1, (outs), (ins memrr:$dst),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000443 "dcbzl $dst", LdStDCBF, [(int_ppc_dcbzl xoaddr:$dst)]>,
444 PPC970_DGroup_Single;
445
446//===----------------------------------------------------------------------===//
447// PPC32 Load Instructions.
448//
449
450// Unindexed (r+i) Loads.
451let isLoad = 1, PPC970_Unit = 2 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000452def LBZ : DForm_1<34, (outs GPRC:$rD), (ins memri:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000453 "lbz $rD, $src", LdStGeneral,
454 [(set GPRC:$rD, (zextloadi8 iaddr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000455def LHA : DForm_1<42, (outs GPRC:$rD), (ins memri:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000456 "lha $rD, $src", LdStLHA,
457 [(set GPRC:$rD, (sextloadi16 iaddr:$src))]>,
458 PPC970_DGroup_Cracked;
Evan Chengb783fa32007-07-19 01:14:50 +0000459def LHZ : DForm_1<40, (outs GPRC:$rD), (ins memri:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000460 "lhz $rD, $src", LdStGeneral,
461 [(set GPRC:$rD, (zextloadi16 iaddr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000462def LWZ : DForm_1<32, (outs GPRC:$rD), (ins memri:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000463 "lwz $rD, $src", LdStGeneral,
464 [(set GPRC:$rD, (load iaddr:$src))]>;
465
Evan Chengb783fa32007-07-19 01:14:50 +0000466def LFS : DForm_1<48, (outs F4RC:$rD), (ins memri:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000467 "lfs $rD, $src", LdStLFDU,
468 [(set F4RC:$rD, (load iaddr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000469def LFD : DForm_1<50, (outs F8RC:$rD), (ins memri:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000470 "lfd $rD, $src", LdStLFD,
471 [(set F8RC:$rD, (load iaddr:$src))]>;
472
473
474// Unindexed (r+i) Loads with Update (preinc).
Evan Chengdcfb5cb2007-08-01 23:07:38 +0000475def LBZU : DForm_1<35, (outs GPRC:$rD, ptr_rc:$ea_result), (ins memri:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000476 "lbzu $rD, $addr", LdStGeneral,
477 []>, RegConstraint<"$addr.reg = $ea_result">,
478 NoEncode<"$ea_result">;
479
Evan Chengdcfb5cb2007-08-01 23:07:38 +0000480def LHAU : DForm_1<43, (outs GPRC:$rD, ptr_rc:$ea_result), (ins memri:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000481 "lhau $rD, $addr", LdStGeneral,
482 []>, RegConstraint<"$addr.reg = $ea_result">,
483 NoEncode<"$ea_result">;
484
Evan Chengdcfb5cb2007-08-01 23:07:38 +0000485def LHZU : DForm_1<41, (outs GPRC:$rD, ptr_rc:$ea_result), (ins memri:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000486 "lhzu $rD, $addr", LdStGeneral,
487 []>, RegConstraint<"$addr.reg = $ea_result">,
488 NoEncode<"$ea_result">;
489
Evan Chengdcfb5cb2007-08-01 23:07:38 +0000490def LWZU : DForm_1<33, (outs GPRC:$rD, ptr_rc:$ea_result), (ins memri:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000491 "lwzu $rD, $addr", LdStGeneral,
492 []>, RegConstraint<"$addr.reg = $ea_result">,
493 NoEncode<"$ea_result">;
494
Evan Chengdcfb5cb2007-08-01 23:07:38 +0000495def LFSU : DForm_1<49, (outs F4RC:$rD, ptr_rc:$ea_result), (ins memri:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000496 "lfs $rD, $addr", LdStLFDU,
497 []>, RegConstraint<"$addr.reg = $ea_result">,
498 NoEncode<"$ea_result">;
499
Evan Chengdcfb5cb2007-08-01 23:07:38 +0000500def LFDU : DForm_1<51, (outs F8RC:$rD, ptr_rc:$ea_result), (ins memri:$addr),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000501 "lfd $rD, $addr", LdStLFD,
502 []>, RegConstraint<"$addr.reg = $ea_result">,
503 NoEncode<"$ea_result">;
504}
505
506// Indexed (r+r) Loads.
507//
508let isLoad = 1, PPC970_Unit = 2 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000509def LBZX : XForm_1<31, 87, (outs GPRC:$rD), (ins memrr:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000510 "lbzx $rD, $src", LdStGeneral,
511 [(set GPRC:$rD, (zextloadi8 xaddr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000512def LHAX : XForm_1<31, 343, (outs GPRC:$rD), (ins memrr:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000513 "lhax $rD, $src", LdStLHA,
514 [(set GPRC:$rD, (sextloadi16 xaddr:$src))]>,
515 PPC970_DGroup_Cracked;
Evan Chengb783fa32007-07-19 01:14:50 +0000516def LHZX : XForm_1<31, 279, (outs GPRC:$rD), (ins memrr:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000517 "lhzx $rD, $src", LdStGeneral,
518 [(set GPRC:$rD, (zextloadi16 xaddr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000519def LWZX : XForm_1<31, 23, (outs GPRC:$rD), (ins memrr:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000520 "lwzx $rD, $src", LdStGeneral,
521 [(set GPRC:$rD, (load xaddr:$src))]>;
522
523
Evan Chengb783fa32007-07-19 01:14:50 +0000524def LHBRX : XForm_1<31, 790, (outs GPRC:$rD), (ins memrr:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000525 "lhbrx $rD, $src", LdStGeneral,
526 [(set GPRC:$rD, (PPClbrx xoaddr:$src, srcvalue:$sv, i16))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000527def LWBRX : XForm_1<31, 534, (outs GPRC:$rD), (ins memrr:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000528 "lwbrx $rD, $src", LdStGeneral,
529 [(set GPRC:$rD, (PPClbrx xoaddr:$src, srcvalue:$sv, i32))]>;
530
Evan Chengb783fa32007-07-19 01:14:50 +0000531def LFSX : XForm_25<31, 535, (outs F4RC:$frD), (ins memrr:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000532 "lfsx $frD, $src", LdStLFDU,
533 [(set F4RC:$frD, (load xaddr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000534def LFDX : XForm_25<31, 599, (outs F8RC:$frD), (ins memrr:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000535 "lfdx $frD, $src", LdStLFDU,
536 [(set F8RC:$frD, (load xaddr:$src))]>;
537}
538
539//===----------------------------------------------------------------------===//
540// PPC32 Store Instructions.
541//
542
543// Unindexed (r+i) Stores.
Evan Cheng37e7c752007-07-21 00:34:19 +0000544let isStore = 1, PPC970_Unit = 2 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000545def STB : DForm_1<38, (outs), (ins GPRC:$rS, memri:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000546 "stb $rS, $src", LdStGeneral,
547 [(truncstorei8 GPRC:$rS, iaddr:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000548def STH : DForm_1<44, (outs), (ins GPRC:$rS, memri:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000549 "sth $rS, $src", LdStGeneral,
550 [(truncstorei16 GPRC:$rS, iaddr:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000551def STW : DForm_1<36, (outs), (ins GPRC:$rS, memri:$src),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000552 "stw $rS, $src", LdStGeneral,
553 [(store GPRC:$rS, iaddr:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000554def STFS : DForm_1<52, (outs), (ins F4RC:$rS, memri:$dst),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000555 "stfs $rS, $dst", LdStUX,
556 [(store F4RC:$rS, iaddr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000557def STFD : DForm_1<54, (outs), (ins F8RC:$rS, memri:$dst),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000558 "stfd $rS, $dst", LdStUX,
559 [(store F8RC:$rS, iaddr:$dst)]>;
560}
561
562// Unindexed (r+i) Stores with Update (preinc).
563let isStore = 1, PPC970_Unit = 2 in {
Evan Chengeface712007-07-20 00:20:46 +0000564def STBU : DForm_1<39, (outs ptr_rc:$ea_res), (ins GPRC:$rS,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000565 symbolLo:$ptroff, ptr_rc:$ptrreg),
566 "stbu $rS, $ptroff($ptrreg)", LdStGeneral,
567 [(set ptr_rc:$ea_res,
568 (pre_truncsti8 GPRC:$rS, ptr_rc:$ptrreg,
569 iaddroff:$ptroff))]>,
570 RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">;
Evan Chengeface712007-07-20 00:20:46 +0000571def STHU : DForm_1<45, (outs ptr_rc:$ea_res), (ins GPRC:$rS,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000572 symbolLo:$ptroff, ptr_rc:$ptrreg),
573 "sthu $rS, $ptroff($ptrreg)", LdStGeneral,
574 [(set ptr_rc:$ea_res,
575 (pre_truncsti16 GPRC:$rS, ptr_rc:$ptrreg,
576 iaddroff:$ptroff))]>,
577 RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">;
Evan Chengeface712007-07-20 00:20:46 +0000578def STWU : DForm_1<37, (outs ptr_rc:$ea_res), (ins GPRC:$rS,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000579 symbolLo:$ptroff, ptr_rc:$ptrreg),
580 "stwu $rS, $ptroff($ptrreg)", LdStGeneral,
581 [(set ptr_rc:$ea_res, (pre_store GPRC:$rS, ptr_rc:$ptrreg,
582 iaddroff:$ptroff))]>,
583 RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">;
Evan Chengeface712007-07-20 00:20:46 +0000584def STFSU : DForm_1<37, (outs ptr_rc:$ea_res), (ins F4RC:$rS,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000585 symbolLo:$ptroff, ptr_rc:$ptrreg),
586 "stfsu $rS, $ptroff($ptrreg)", LdStGeneral,
587 [(set ptr_rc:$ea_res, (pre_store F4RC:$rS, ptr_rc:$ptrreg,
588 iaddroff:$ptroff))]>,
589 RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">;
Evan Chengeface712007-07-20 00:20:46 +0000590def STFDU : DForm_1<37, (outs ptr_rc:$ea_res), (ins F8RC:$rS,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000591 symbolLo:$ptroff, ptr_rc:$ptrreg),
592 "stfdu $rS, $ptroff($ptrreg)", LdStGeneral,
593 [(set ptr_rc:$ea_res, (pre_store F8RC:$rS, ptr_rc:$ptrreg,
594 iaddroff:$ptroff))]>,
595 RegConstraint<"$ptrreg = $ea_res">, NoEncode<"$ea_res">;
596}
597
598
599// Indexed (r+r) Stores.
600//
Evan Cheng37e7c752007-07-21 00:34:19 +0000601let isStore = 1, PPC970_Unit = 2 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000602def STBX : XForm_8<31, 215, (outs), (ins GPRC:$rS, memrr:$dst),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000603 "stbx $rS, $dst", LdStGeneral,
604 [(truncstorei8 GPRC:$rS, xaddr:$dst)]>,
605 PPC970_DGroup_Cracked;
Evan Chengb783fa32007-07-19 01:14:50 +0000606def STHX : XForm_8<31, 407, (outs), (ins GPRC:$rS, memrr:$dst),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000607 "sthx $rS, $dst", LdStGeneral,
608 [(truncstorei16 GPRC:$rS, xaddr:$dst)]>,
609 PPC970_DGroup_Cracked;
Evan Chengb783fa32007-07-19 01:14:50 +0000610def STWX : XForm_8<31, 151, (outs), (ins GPRC:$rS, memrr:$dst),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000611 "stwx $rS, $dst", LdStGeneral,
612 [(store GPRC:$rS, xaddr:$dst)]>,
613 PPC970_DGroup_Cracked;
Evan Chengb783fa32007-07-19 01:14:50 +0000614def STWUX : XForm_8<31, 183, (outs), (ins GPRC:$rS, GPRC:$rA, GPRC:$rB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000615 "stwux $rS, $rA, $rB", LdStGeneral,
616 []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000617def STHBRX: XForm_8<31, 918, (outs), (ins GPRC:$rS, memrr:$dst),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000618 "sthbrx $rS, $dst", LdStGeneral,
619 [(PPCstbrx GPRC:$rS, xoaddr:$dst, srcvalue:$dummy, i16)]>,
620 PPC970_DGroup_Cracked;
Evan Chengb783fa32007-07-19 01:14:50 +0000621def STWBRX: XForm_8<31, 662, (outs), (ins GPRC:$rS, memrr:$dst),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000622 "stwbrx $rS, $dst", LdStGeneral,
623 [(PPCstbrx GPRC:$rS, xoaddr:$dst, srcvalue:$dummy, i32)]>,
624 PPC970_DGroup_Cracked;
625
Evan Chengb783fa32007-07-19 01:14:50 +0000626def STFIWX: XForm_28<31, 983, (outs), (ins F8RC:$frS, memrr:$dst),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000627 "stfiwx $frS, $dst", LdStUX,
628 [(PPCstfiwx F8RC:$frS, xoaddr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000629def STFSX : XForm_28<31, 663, (outs), (ins F4RC:$frS, memrr:$dst),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000630 "stfsx $frS, $dst", LdStUX,
631 [(store F4RC:$frS, xaddr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000632def STFDX : XForm_28<31, 727, (outs), (ins F8RC:$frS, memrr:$dst),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000633 "stfdx $frS, $dst", LdStUX,
634 [(store F8RC:$frS, xaddr:$dst)]>;
635}
636
637
638//===----------------------------------------------------------------------===//
639// PPC32 Arithmetic Instructions.
640//
641
642let PPC970_Unit = 1 in { // FXU Operations.
Evan Chengb783fa32007-07-19 01:14:50 +0000643def ADDI : DForm_2<14, (outs GPRC:$rD), (ins GPRC:$rA, s16imm:$imm),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000644 "addi $rD, $rA, $imm", IntGeneral,
645 [(set GPRC:$rD, (add GPRC:$rA, immSExt16:$imm))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000646def ADDIC : DForm_2<12, (outs GPRC:$rD), (ins GPRC:$rA, s16imm:$imm),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000647 "addic $rD, $rA, $imm", IntGeneral,
648 [(set GPRC:$rD, (addc GPRC:$rA, immSExt16:$imm))]>,
649 PPC970_DGroup_Cracked;
Evan Chengb783fa32007-07-19 01:14:50 +0000650def ADDICo : DForm_2<13, (outs GPRC:$rD), (ins GPRC:$rA, s16imm:$imm),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000651 "addic. $rD, $rA, $imm", IntGeneral,
652 []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000653def ADDIS : DForm_2<15, (outs GPRC:$rD), (ins GPRC:$rA, symbolHi:$imm),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000654 "addis $rD, $rA, $imm", IntGeneral,
655 [(set GPRC:$rD, (add GPRC:$rA, imm16ShiftedSExt:$imm))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000656def LA : DForm_2<14, (outs GPRC:$rD), (ins GPRC:$rA, symbolLo:$sym),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000657 "la $rD, $sym($rA)", IntGeneral,
658 [(set GPRC:$rD, (add GPRC:$rA,
659 (PPClo tglobaladdr:$sym, 0)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000660def MULLI : DForm_2< 7, (outs GPRC:$rD), (ins GPRC:$rA, s16imm:$imm),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000661 "mulli $rD, $rA, $imm", IntMulLI,
662 [(set GPRC:$rD, (mul GPRC:$rA, immSExt16:$imm))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000663def SUBFIC : DForm_2< 8, (outs GPRC:$rD), (ins GPRC:$rA, s16imm:$imm),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000664 "subfic $rD, $rA, $imm", IntGeneral,
665 [(set GPRC:$rD, (subc immSExt16:$imm, GPRC:$rA))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000666def LI : DForm_2_r0<14, (outs GPRC:$rD), (ins symbolLo:$imm),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000667 "li $rD, $imm", IntGeneral,
668 [(set GPRC:$rD, immSExt16:$imm)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000669def LIS : DForm_2_r0<15, (outs GPRC:$rD), (ins symbolHi:$imm),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000670 "lis $rD, $imm", IntGeneral,
671 [(set GPRC:$rD, imm16ShiftedSExt:$imm)]>;
672}
673
674let PPC970_Unit = 1 in { // FXU Operations.
Evan Chengb783fa32007-07-19 01:14:50 +0000675def ANDIo : DForm_4<28, (outs GPRC:$dst), (ins GPRC:$src1, u16imm:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000676 "andi. $dst, $src1, $src2", IntGeneral,
677 [(set GPRC:$dst, (and GPRC:$src1, immZExt16:$src2))]>,
678 isDOT;
Evan Chengb783fa32007-07-19 01:14:50 +0000679def ANDISo : DForm_4<29, (outs GPRC:$dst), (ins GPRC:$src1, u16imm:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000680 "andis. $dst, $src1, $src2", IntGeneral,
681 [(set GPRC:$dst, (and GPRC:$src1,imm16ShiftedZExt:$src2))]>,
682 isDOT;
Evan Chengb783fa32007-07-19 01:14:50 +0000683def ORI : DForm_4<24, (outs GPRC:$dst), (ins GPRC:$src1, u16imm:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000684 "ori $dst, $src1, $src2", IntGeneral,
685 [(set GPRC:$dst, (or GPRC:$src1, immZExt16:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000686def ORIS : DForm_4<25, (outs GPRC:$dst), (ins GPRC:$src1, u16imm:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000687 "oris $dst, $src1, $src2", IntGeneral,
688 [(set GPRC:$dst, (or GPRC:$src1, imm16ShiftedZExt:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000689def XORI : DForm_4<26, (outs GPRC:$dst), (ins GPRC:$src1, u16imm:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000690 "xori $dst, $src1, $src2", IntGeneral,
691 [(set GPRC:$dst, (xor GPRC:$src1, immZExt16:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000692def XORIS : DForm_4<27, (outs GPRC:$dst), (ins GPRC:$src1, u16imm:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000693 "xoris $dst, $src1, $src2", IntGeneral,
694 [(set GPRC:$dst, (xor GPRC:$src1,imm16ShiftedZExt:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000695def NOP : DForm_4_zero<24, (outs), (ins), "nop", IntGeneral,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000696 []>;
Evan Chengdcfb5cb2007-08-01 23:07:38 +0000697def CMPWI : DForm_5_ext<11, (outs CRRC:$crD), (ins GPRC:$rA, s16imm:$imm),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000698 "cmpwi $crD, $rA, $imm", IntCompare>;
Evan Chengdcfb5cb2007-08-01 23:07:38 +0000699def CMPLWI : DForm_6_ext<10, (outs CRRC:$dst), (ins GPRC:$src1, u16imm:$src2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000700 "cmplwi $dst, $src1, $src2", IntCompare>;
701}
702
703
704let PPC970_Unit = 1 in { // FXU Operations.
Evan Chengb783fa32007-07-19 01:14:50 +0000705def NAND : XForm_6<31, 476, (outs GPRC:$rA), (ins GPRC:$rS, GPRC:$rB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000706 "nand $rA, $rS, $rB", IntGeneral,
707 [(set GPRC:$rA, (not (and GPRC:$rS, GPRC:$rB)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000708def AND : XForm_6<31, 28, (outs GPRC:$rA), (ins GPRC:$rS, GPRC:$rB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000709 "and $rA, $rS, $rB", IntGeneral,
710 [(set GPRC:$rA, (and GPRC:$rS, GPRC:$rB))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000711def ANDC : XForm_6<31, 60, (outs GPRC:$rA), (ins GPRC:$rS, GPRC:$rB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000712 "andc $rA, $rS, $rB", IntGeneral,
713 [(set GPRC:$rA, (and GPRC:$rS, (not GPRC:$rB)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000714def OR : XForm_6<31, 444, (outs GPRC:$rA), (ins GPRC:$rS, GPRC:$rB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000715 "or $rA, $rS, $rB", IntGeneral,
716 [(set GPRC:$rA, (or GPRC:$rS, GPRC:$rB))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000717def NOR : XForm_6<31, 124, (outs GPRC:$rA), (ins GPRC:$rS, GPRC:$rB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000718 "nor $rA, $rS, $rB", IntGeneral,
719 [(set GPRC:$rA, (not (or GPRC:$rS, GPRC:$rB)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000720def ORC : XForm_6<31, 412, (outs GPRC:$rA), (ins GPRC:$rS, GPRC:$rB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000721 "orc $rA, $rS, $rB", IntGeneral,
722 [(set GPRC:$rA, (or GPRC:$rS, (not GPRC:$rB)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000723def EQV : XForm_6<31, 284, (outs GPRC:$rA), (ins GPRC:$rS, GPRC:$rB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000724 "eqv $rA, $rS, $rB", IntGeneral,
725 [(set GPRC:$rA, (not (xor GPRC:$rS, GPRC:$rB)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000726def XOR : XForm_6<31, 316, (outs GPRC:$rA), (ins GPRC:$rS, GPRC:$rB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000727 "xor $rA, $rS, $rB", IntGeneral,
728 [(set GPRC:$rA, (xor GPRC:$rS, GPRC:$rB))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000729def SLW : XForm_6<31, 24, (outs GPRC:$rA), (ins GPRC:$rS, GPRC:$rB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000730 "slw $rA, $rS, $rB", IntGeneral,
731 [(set GPRC:$rA, (PPCshl GPRC:$rS, GPRC:$rB))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000732def SRW : XForm_6<31, 536, (outs GPRC:$rA), (ins GPRC:$rS, GPRC:$rB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000733 "srw $rA, $rS, $rB", IntGeneral,
734 [(set GPRC:$rA, (PPCsrl GPRC:$rS, GPRC:$rB))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000735def SRAW : XForm_6<31, 792, (outs GPRC:$rA), (ins GPRC:$rS, GPRC:$rB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000736 "sraw $rA, $rS, $rB", IntShift,
737 [(set GPRC:$rA, (PPCsra GPRC:$rS, GPRC:$rB))]>;
738}
739
740let PPC970_Unit = 1 in { // FXU Operations.
Evan Chengb783fa32007-07-19 01:14:50 +0000741def SRAWI : XForm_10<31, 824, (outs GPRC:$rA), (ins GPRC:$rS, u5imm:$SH),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000742 "srawi $rA, $rS, $SH", IntShift,
743 [(set GPRC:$rA, (sra GPRC:$rS, (i32 imm:$SH)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000744def CNTLZW : XForm_11<31, 26, (outs GPRC:$rA), (ins GPRC:$rS),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000745 "cntlzw $rA, $rS", IntGeneral,
746 [(set GPRC:$rA, (ctlz GPRC:$rS))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000747def EXTSB : XForm_11<31, 954, (outs GPRC:$rA), (ins GPRC:$rS),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000748 "extsb $rA, $rS", IntGeneral,
749 [(set GPRC:$rA, (sext_inreg GPRC:$rS, i8))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000750def EXTSH : XForm_11<31, 922, (outs GPRC:$rA), (ins GPRC:$rS),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000751 "extsh $rA, $rS", IntGeneral,
752 [(set GPRC:$rA, (sext_inreg GPRC:$rS, i16))]>;
753
Evan Chengb783fa32007-07-19 01:14:50 +0000754def CMPW : XForm_16_ext<31, 0, (outs CRRC:$crD), (ins GPRC:$rA, GPRC:$rB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000755 "cmpw $crD, $rA, $rB", IntCompare>;
Evan Chengb783fa32007-07-19 01:14:50 +0000756def CMPLW : XForm_16_ext<31, 32, (outs CRRC:$crD), (ins GPRC:$rA, GPRC:$rB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000757 "cmplw $crD, $rA, $rB", IntCompare>;
758}
759let PPC970_Unit = 3 in { // FPU Operations.
Evan Chengb783fa32007-07-19 01:14:50 +0000760//def FCMPO : XForm_17<63, 32, (outs CRRC:$crD), (ins FPRC:$fA, FPRC:$fB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000761// "fcmpo $crD, $fA, $fB", FPCompare>;
Evan Chengb783fa32007-07-19 01:14:50 +0000762def FCMPUS : XForm_17<63, 0, (outs CRRC:$crD), (ins F4RC:$fA, F4RC:$fB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000763 "fcmpu $crD, $fA, $fB", FPCompare>;
Evan Chengb783fa32007-07-19 01:14:50 +0000764def FCMPUD : XForm_17<63, 0, (outs CRRC:$crD), (ins F8RC:$fA, F8RC:$fB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000765 "fcmpu $crD, $fA, $fB", FPCompare>;
766
Evan Chengb783fa32007-07-19 01:14:50 +0000767def FCTIWZ : XForm_26<63, 15, (outs F8RC:$frD), (ins F8RC:$frB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000768 "fctiwz $frD, $frB", FPGeneral,
769 [(set F8RC:$frD, (PPCfctiwz F8RC:$frB))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000770def FRSP : XForm_26<63, 12, (outs F4RC:$frD), (ins F8RC:$frB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000771 "frsp $frD, $frB", FPGeneral,
772 [(set F4RC:$frD, (fround F8RC:$frB))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000773def FSQRT : XForm_26<63, 22, (outs F8RC:$frD), (ins F8RC:$frB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000774 "fsqrt $frD, $frB", FPSqrt,
775 [(set F8RC:$frD, (fsqrt F8RC:$frB))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000776def FSQRTS : XForm_26<59, 22, (outs F4RC:$frD), (ins F4RC:$frB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000777 "fsqrts $frD, $frB", FPSqrt,
778 [(set F4RC:$frD, (fsqrt F4RC:$frB))]>;
779}
780
781/// FMR is split into 3 versions, one for 4/8 byte FP, and one for extending.
782///
783/// Note that these are defined as pseudo-ops on the PPC970 because they are
784/// often coalesced away and we don't want the dispatch group builder to think
785/// that they will fill slots (which could cause the load of a LSU reject to
786/// sneak into a d-group with a store).
Evan Chengb783fa32007-07-19 01:14:50 +0000787def FMRS : XForm_26<63, 72, (outs F4RC:$frD), (ins F4RC:$frB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000788 "fmr $frD, $frB", FPGeneral,
789 []>, // (set F4RC:$frD, F4RC:$frB)
790 PPC970_Unit_Pseudo;
Evan Chengb783fa32007-07-19 01:14:50 +0000791def FMRD : XForm_26<63, 72, (outs F8RC:$frD), (ins F8RC:$frB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000792 "fmr $frD, $frB", FPGeneral,
793 []>, // (set F8RC:$frD, F8RC:$frB)
794 PPC970_Unit_Pseudo;
Evan Chengb783fa32007-07-19 01:14:50 +0000795def FMRSD : XForm_26<63, 72, (outs F8RC:$frD), (ins F4RC:$frB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000796 "fmr $frD, $frB", FPGeneral,
797 [(set F8RC:$frD, (fextend F4RC:$frB))]>,
798 PPC970_Unit_Pseudo;
799
800let PPC970_Unit = 3 in { // FPU Operations.
801// These are artificially split into two different forms, for 4/8 byte FP.
Evan Chengb783fa32007-07-19 01:14:50 +0000802def FABSS : XForm_26<63, 264, (outs F4RC:$frD), (ins F4RC:$frB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000803 "fabs $frD, $frB", FPGeneral,
804 [(set F4RC:$frD, (fabs F4RC:$frB))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000805def FABSD : XForm_26<63, 264, (outs F8RC:$frD), (ins F8RC:$frB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000806 "fabs $frD, $frB", FPGeneral,
807 [(set F8RC:$frD, (fabs F8RC:$frB))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000808def FNABSS : XForm_26<63, 136, (outs F4RC:$frD), (ins F4RC:$frB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000809 "fnabs $frD, $frB", FPGeneral,
810 [(set F4RC:$frD, (fneg (fabs F4RC:$frB)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000811def FNABSD : XForm_26<63, 136, (outs F8RC:$frD), (ins F8RC:$frB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000812 "fnabs $frD, $frB", FPGeneral,
813 [(set F8RC:$frD, (fneg (fabs F8RC:$frB)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000814def FNEGS : XForm_26<63, 40, (outs F4RC:$frD), (ins F4RC:$frB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000815 "fneg $frD, $frB", FPGeneral,
816 [(set F4RC:$frD, (fneg F4RC:$frB))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000817def FNEGD : XForm_26<63, 40, (outs F8RC:$frD), (ins F8RC:$frB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000818 "fneg $frD, $frB", FPGeneral,
819 [(set F8RC:$frD, (fneg F8RC:$frB))]>;
820}
821
822
823// XL-Form instructions. condition register logical ops.
824//
Evan Chengb783fa32007-07-19 01:14:50 +0000825def MCRF : XLForm_3<19, 0, (outs CRRC:$BF), (ins CRRC:$BFA),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000826 "mcrf $BF, $BFA", BrMCR>,
827 PPC970_DGroup_First, PPC970_Unit_CRU;
828
Evan Chengb783fa32007-07-19 01:14:50 +0000829def CREQV : XLForm_1<19, 289, (outs CRRC:$CRD), (ins CRRC:$CRA, CRRC:$CRB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000830 "creqv $CRD, $CRA, $CRB", BrCR,
831 []>;
832
Evan Chengb783fa32007-07-19 01:14:50 +0000833def SETCR : XLForm_1_ext<19, 289, (outs CRRC:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000834 "creqv $dst, $dst, $dst", BrCR,
835 []>;
836
837// XFX-Form instructions. Instructions that deal with SPRs.
838//
Evan Chengb783fa32007-07-19 01:14:50 +0000839def MFCTR : XFXForm_1_ext<31, 339, 9, (outs GPRC:$rT), (ins),
840 "mfctr $rT", SprMFSPR>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000841 PPC970_DGroup_First, PPC970_Unit_FXU;
842let Pattern = [(PPCmtctr GPRC:$rS)] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000843def MTCTR : XFXForm_7_ext<31, 467, 9, (outs), (ins GPRC:$rS),
844 "mtctr $rS", SprMTSPR>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000845 PPC970_DGroup_First, PPC970_Unit_FXU;
846}
847
Evan Chengb783fa32007-07-19 01:14:50 +0000848def MTLR : XFXForm_7_ext<31, 467, 8, (outs), (ins GPRC:$rS),
849 "mtlr $rS", SprMTSPR>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000850 PPC970_DGroup_First, PPC970_Unit_FXU;
Evan Chengb783fa32007-07-19 01:14:50 +0000851def MFLR : XFXForm_1_ext<31, 339, 8, (outs GPRC:$rT), (ins),
852 "mflr $rT", SprMFSPR>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000853 PPC970_DGroup_First, PPC970_Unit_FXU;
854
855// Move to/from VRSAVE: despite being a SPR, the VRSAVE register is renamed like
856// a GPR on the PPC970. As such, copies in and out have the same performance
857// characteristics as an OR instruction.
Evan Chengb783fa32007-07-19 01:14:50 +0000858def MTVRSAVE : XFXForm_7_ext<31, 467, 256, (outs), (ins GPRC:$rS),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000859 "mtspr 256, $rS", IntGeneral>,
860 PPC970_DGroup_Single, PPC970_Unit_FXU;
Evan Chengb783fa32007-07-19 01:14:50 +0000861def MFVRSAVE : XFXForm_1_ext<31, 339, 256, (outs GPRC:$rT), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000862 "mfspr $rT, 256", IntGeneral>,
863 PPC970_DGroup_First, PPC970_Unit_FXU;
864
Evan Chengb783fa32007-07-19 01:14:50 +0000865def MTCRF : XFXForm_5<31, 144, (outs), (ins crbitm:$FXM, GPRC:$rS),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000866 "mtcrf $FXM, $rS", BrMCRX>,
867 PPC970_MicroCode, PPC970_Unit_CRU;
Evan Chengb783fa32007-07-19 01:14:50 +0000868def MFCR : XFXForm_3<31, 19, (outs GPRC:$rT), (ins), "mfcr $rT", SprMFCR>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000869 PPC970_MicroCode, PPC970_Unit_CRU;
Evan Chengb783fa32007-07-19 01:14:50 +0000870def MFOCRF: XFXForm_5a<31, 19, (outs GPRC:$rT), (ins crbitm:$FXM),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000871 "mfcr $rT, $FXM", SprMFCR>,
872 PPC970_DGroup_First, PPC970_Unit_CRU;
873
874let PPC970_Unit = 1 in { // FXU Operations.
875
876// XO-Form instructions. Arithmetic instructions that can set overflow bit
877//
Evan Chengb783fa32007-07-19 01:14:50 +0000878def ADD4 : XOForm_1<31, 266, 0, (outs GPRC:$rT), (ins GPRC:$rA, GPRC:$rB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000879 "add $rT, $rA, $rB", IntGeneral,
880 [(set GPRC:$rT, (add GPRC:$rA, GPRC:$rB))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000881def ADDC : XOForm_1<31, 10, 0, (outs GPRC:$rT), (ins GPRC:$rA, GPRC:$rB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000882 "addc $rT, $rA, $rB", IntGeneral,
883 [(set GPRC:$rT, (addc GPRC:$rA, GPRC:$rB))]>,
884 PPC970_DGroup_Cracked;
Evan Chengb783fa32007-07-19 01:14:50 +0000885def ADDE : XOForm_1<31, 138, 0, (outs GPRC:$rT), (ins GPRC:$rA, GPRC:$rB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000886 "adde $rT, $rA, $rB", IntGeneral,
887 [(set GPRC:$rT, (adde GPRC:$rA, GPRC:$rB))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000888def DIVW : XOForm_1<31, 491, 0, (outs GPRC:$rT), (ins GPRC:$rA, GPRC:$rB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000889 "divw $rT, $rA, $rB", IntDivW,
890 [(set GPRC:$rT, (sdiv GPRC:$rA, GPRC:$rB))]>,
891 PPC970_DGroup_First, PPC970_DGroup_Cracked;
Evan Chengb783fa32007-07-19 01:14:50 +0000892def DIVWU : XOForm_1<31, 459, 0, (outs GPRC:$rT), (ins GPRC:$rA, GPRC:$rB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000893 "divwu $rT, $rA, $rB", IntDivW,
894 [(set GPRC:$rT, (udiv GPRC:$rA, GPRC:$rB))]>,
895 PPC970_DGroup_First, PPC970_DGroup_Cracked;
Evan Chengb783fa32007-07-19 01:14:50 +0000896def MULHW : XOForm_1<31, 75, 0, (outs GPRC:$rT), (ins GPRC:$rA, GPRC:$rB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000897 "mulhw $rT, $rA, $rB", IntMulHW,
898 [(set GPRC:$rT, (mulhs GPRC:$rA, GPRC:$rB))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000899def MULHWU : XOForm_1<31, 11, 0, (outs GPRC:$rT), (ins GPRC:$rA, GPRC:$rB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000900 "mulhwu $rT, $rA, $rB", IntMulHWU,
901 [(set GPRC:$rT, (mulhu GPRC:$rA, GPRC:$rB))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000902def MULLW : XOForm_1<31, 235, 0, (outs GPRC:$rT), (ins GPRC:$rA, GPRC:$rB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000903 "mullw $rT, $rA, $rB", IntMulHW,
904 [(set GPRC:$rT, (mul GPRC:$rA, GPRC:$rB))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000905def SUBF : XOForm_1<31, 40, 0, (outs GPRC:$rT), (ins GPRC:$rA, GPRC:$rB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000906 "subf $rT, $rA, $rB", IntGeneral,
907 [(set GPRC:$rT, (sub GPRC:$rB, GPRC:$rA))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000908def SUBFC : XOForm_1<31, 8, 0, (outs GPRC:$rT), (ins GPRC:$rA, GPRC:$rB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000909 "subfc $rT, $rA, $rB", IntGeneral,
910 [(set GPRC:$rT, (subc GPRC:$rB, GPRC:$rA))]>,
911 PPC970_DGroup_Cracked;
Evan Chengb783fa32007-07-19 01:14:50 +0000912def SUBFE : XOForm_1<31, 136, 0, (outs GPRC:$rT), (ins GPRC:$rA, GPRC:$rB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000913 "subfe $rT, $rA, $rB", IntGeneral,
914 [(set GPRC:$rT, (sube GPRC:$rB, GPRC:$rA))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000915def ADDME : XOForm_3<31, 234, 0, (outs GPRC:$rT), (ins GPRC:$rA),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000916 "addme $rT, $rA", IntGeneral,
917 [(set GPRC:$rT, (adde GPRC:$rA, immAllOnes))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000918def ADDZE : XOForm_3<31, 202, 0, (outs GPRC:$rT), (ins GPRC:$rA),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000919 "addze $rT, $rA", IntGeneral,
920 [(set GPRC:$rT, (adde GPRC:$rA, 0))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000921def NEG : XOForm_3<31, 104, 0, (outs GPRC:$rT), (ins GPRC:$rA),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000922 "neg $rT, $rA", IntGeneral,
923 [(set GPRC:$rT, (ineg GPRC:$rA))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000924def SUBFME : XOForm_3<31, 232, 0, (outs GPRC:$rT), (ins GPRC:$rA),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000925 "subfme $rT, $rA", IntGeneral,
926 [(set GPRC:$rT, (sube immAllOnes, GPRC:$rA))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000927def SUBFZE : XOForm_3<31, 200, 0, (outs GPRC:$rT), (ins GPRC:$rA),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000928 "subfze $rT, $rA", IntGeneral,
929 [(set GPRC:$rT, (sube 0, GPRC:$rA))]>;
930}
931
932// A-Form instructions. Most of the instructions executed in the FPU are of
933// this type.
934//
935let PPC970_Unit = 3 in { // FPU Operations.
936def FMADD : AForm_1<63, 29,
Evan Chengb783fa32007-07-19 01:14:50 +0000937 (outs F8RC:$FRT), (ins F8RC:$FRA, F8RC:$FRC, F8RC:$FRB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000938 "fmadd $FRT, $FRA, $FRC, $FRB", FPFused,
939 [(set F8RC:$FRT, (fadd (fmul F8RC:$FRA, F8RC:$FRC),
940 F8RC:$FRB))]>,
941 Requires<[FPContractions]>;
942def FMADDS : AForm_1<59, 29,
Evan Chengb783fa32007-07-19 01:14:50 +0000943 (outs F4RC:$FRT), (ins F4RC:$FRA, F4RC:$FRC, F4RC:$FRB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000944 "fmadds $FRT, $FRA, $FRC, $FRB", FPGeneral,
945 [(set F4RC:$FRT, (fadd (fmul F4RC:$FRA, F4RC:$FRC),
946 F4RC:$FRB))]>,
947 Requires<[FPContractions]>;
948def FMSUB : AForm_1<63, 28,
Evan Chengb783fa32007-07-19 01:14:50 +0000949 (outs F8RC:$FRT), (ins F8RC:$FRA, F8RC:$FRC, F8RC:$FRB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000950 "fmsub $FRT, $FRA, $FRC, $FRB", FPFused,
951 [(set F8RC:$FRT, (fsub (fmul F8RC:$FRA, F8RC:$FRC),
952 F8RC:$FRB))]>,
953 Requires<[FPContractions]>;
954def FMSUBS : AForm_1<59, 28,
Evan Chengb783fa32007-07-19 01:14:50 +0000955 (outs F4RC:$FRT), (ins F4RC:$FRA, F4RC:$FRC, F4RC:$FRB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000956 "fmsubs $FRT, $FRA, $FRC, $FRB", FPGeneral,
957 [(set F4RC:$FRT, (fsub (fmul F4RC:$FRA, F4RC:$FRC),
958 F4RC:$FRB))]>,
959 Requires<[FPContractions]>;
960def FNMADD : AForm_1<63, 31,
Evan Chengb783fa32007-07-19 01:14:50 +0000961 (outs F8RC:$FRT), (ins F8RC:$FRA, F8RC:$FRC, F8RC:$FRB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000962 "fnmadd $FRT, $FRA, $FRC, $FRB", FPFused,
963 [(set F8RC:$FRT, (fneg (fadd (fmul F8RC:$FRA, F8RC:$FRC),
964 F8RC:$FRB)))]>,
965 Requires<[FPContractions]>;
966def FNMADDS : AForm_1<59, 31,
Evan Chengb783fa32007-07-19 01:14:50 +0000967 (outs F4RC:$FRT), (ins F4RC:$FRA, F4RC:$FRC, F4RC:$FRB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000968 "fnmadds $FRT, $FRA, $FRC, $FRB", FPGeneral,
969 [(set F4RC:$FRT, (fneg (fadd (fmul F4RC:$FRA, F4RC:$FRC),
970 F4RC:$FRB)))]>,
971 Requires<[FPContractions]>;
972def FNMSUB : AForm_1<63, 30,
Evan Chengb783fa32007-07-19 01:14:50 +0000973 (outs F8RC:$FRT), (ins F8RC:$FRA, F8RC:$FRC, F8RC:$FRB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000974 "fnmsub $FRT, $FRA, $FRC, $FRB", FPFused,
975 [(set F8RC:$FRT, (fneg (fsub (fmul F8RC:$FRA, F8RC:$FRC),
976 F8RC:$FRB)))]>,
977 Requires<[FPContractions]>;
978def FNMSUBS : AForm_1<59, 30,
Evan Chengb783fa32007-07-19 01:14:50 +0000979 (outs F4RC:$FRT), (ins F4RC:$FRA, F4RC:$FRC, F4RC:$FRB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000980 "fnmsubs $FRT, $FRA, $FRC, $FRB", FPGeneral,
981 [(set F4RC:$FRT, (fneg (fsub (fmul F4RC:$FRA, F4RC:$FRC),
982 F4RC:$FRB)))]>,
983 Requires<[FPContractions]>;
984// FSEL is artificially split into 4 and 8-byte forms for the result. To avoid
985// having 4 of these, force the comparison to always be an 8-byte double (code
986// should use an FMRSD if the input comparison value really wants to be a float)
987// and 4/8 byte forms for the result and operand type..
988def FSELD : AForm_1<63, 23,
Evan Chengb783fa32007-07-19 01:14:50 +0000989 (outs F8RC:$FRT), (ins F8RC:$FRA, F8RC:$FRC, F8RC:$FRB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000990 "fsel $FRT, $FRA, $FRC, $FRB", FPGeneral,
991 [(set F8RC:$FRT, (PPCfsel F8RC:$FRA,F8RC:$FRC,F8RC:$FRB))]>;
992def FSELS : AForm_1<63, 23,
Evan Chengb783fa32007-07-19 01:14:50 +0000993 (outs F4RC:$FRT), (ins F8RC:$FRA, F4RC:$FRC, F4RC:$FRB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000994 "fsel $FRT, $FRA, $FRC, $FRB", FPGeneral,
995 [(set F4RC:$FRT, (PPCfsel F8RC:$FRA,F4RC:$FRC,F4RC:$FRB))]>;
996def FADD : AForm_2<63, 21,
Evan Chengb783fa32007-07-19 01:14:50 +0000997 (outs F8RC:$FRT), (ins F8RC:$FRA, F8RC:$FRB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000998 "fadd $FRT, $FRA, $FRB", FPGeneral,
999 [(set F8RC:$FRT, (fadd F8RC:$FRA, F8RC:$FRB))]>;
1000def FADDS : AForm_2<59, 21,
Evan Chengb783fa32007-07-19 01:14:50 +00001001 (outs F4RC:$FRT), (ins F4RC:$FRA, F4RC:$FRB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001002 "fadds $FRT, $FRA, $FRB", FPGeneral,
1003 [(set F4RC:$FRT, (fadd F4RC:$FRA, F4RC:$FRB))]>;
1004def FDIV : AForm_2<63, 18,
Evan Chengb783fa32007-07-19 01:14:50 +00001005 (outs F8RC:$FRT), (ins F8RC:$FRA, F8RC:$FRB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001006 "fdiv $FRT, $FRA, $FRB", FPDivD,
1007 [(set F8RC:$FRT, (fdiv F8RC:$FRA, F8RC:$FRB))]>;
1008def FDIVS : AForm_2<59, 18,
Evan Chengb783fa32007-07-19 01:14:50 +00001009 (outs F4RC:$FRT), (ins F4RC:$FRA, F4RC:$FRB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001010 "fdivs $FRT, $FRA, $FRB", FPDivS,
1011 [(set F4RC:$FRT, (fdiv F4RC:$FRA, F4RC:$FRB))]>;
1012def FMUL : AForm_3<63, 25,
Evan Chengb783fa32007-07-19 01:14:50 +00001013 (outs F8RC:$FRT), (ins F8RC:$FRA, F8RC:$FRB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001014 "fmul $FRT, $FRA, $FRB", FPFused,
1015 [(set F8RC:$FRT, (fmul F8RC:$FRA, F8RC:$FRB))]>;
1016def FMULS : AForm_3<59, 25,
Evan Chengb783fa32007-07-19 01:14:50 +00001017 (outs F4RC:$FRT), (ins F4RC:$FRA, F4RC:$FRB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001018 "fmuls $FRT, $FRA, $FRB", FPGeneral,
1019 [(set F4RC:$FRT, (fmul F4RC:$FRA, F4RC:$FRB))]>;
1020def FSUB : AForm_2<63, 20,
Evan Chengb783fa32007-07-19 01:14:50 +00001021 (outs F8RC:$FRT), (ins F8RC:$FRA, F8RC:$FRB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001022 "fsub $FRT, $FRA, $FRB", FPGeneral,
1023 [(set F8RC:$FRT, (fsub F8RC:$FRA, F8RC:$FRB))]>;
1024def FSUBS : AForm_2<59, 20,
Evan Chengb783fa32007-07-19 01:14:50 +00001025 (outs F4RC:$FRT), (ins F4RC:$FRA, F4RC:$FRB),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001026 "fsubs $FRT, $FRA, $FRB", FPGeneral,
1027 [(set F4RC:$FRT, (fsub F4RC:$FRA, F4RC:$FRB))]>;
1028}
1029
1030let PPC970_Unit = 1 in { // FXU Operations.
1031// M-Form instructions. rotate and mask instructions.
1032//
1033let isCommutable = 1 in {
1034// RLWIMI can be commuted if the rotate amount is zero.
1035def RLWIMI : MForm_2<20,
Evan Chengb783fa32007-07-19 01:14:50 +00001036 (outs GPRC:$rA), (ins GPRC:$rSi, GPRC:$rS, u5imm:$SH, u5imm:$MB,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001037 u5imm:$ME), "rlwimi $rA, $rS, $SH, $MB, $ME", IntRotate,
1038 []>, PPC970_DGroup_Cracked, RegConstraint<"$rSi = $rA">,
1039 NoEncode<"$rSi">;
1040}
1041def RLWINM : MForm_2<21,
Evan Chengb783fa32007-07-19 01:14:50 +00001042 (outs GPRC:$rA), (ins GPRC:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001043 "rlwinm $rA, $rS, $SH, $MB, $ME", IntGeneral,
1044 []>;
1045def RLWINMo : MForm_2<21,
Evan Chengb783fa32007-07-19 01:14:50 +00001046 (outs GPRC:$rA), (ins GPRC:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001047 "rlwinm. $rA, $rS, $SH, $MB, $ME", IntGeneral,
1048 []>, isDOT, PPC970_DGroup_Cracked;
1049def RLWNM : MForm_2<23,
Evan Chengb783fa32007-07-19 01:14:50 +00001050 (outs GPRC:$rA), (ins GPRC:$rS, GPRC:$rB, u5imm:$MB, u5imm:$ME),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001051 "rlwnm $rA, $rS, $rB, $MB, $ME", IntGeneral,
1052 []>;
1053}
1054
1055
1056//===----------------------------------------------------------------------===//
1057// DWARF Pseudo Instructions
1058//
1059
Evan Chengb783fa32007-07-19 01:14:50 +00001060def DWARF_LOC : Pseudo<(outs), (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001061 "${:comment} .loc $file, $line, $col",
1062 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
1063 (i32 imm:$file))]>;
1064
1065//===----------------------------------------------------------------------===//
1066// PowerPC Instruction Patterns
1067//
1068
1069// Arbitrary immediate support. Implement in terms of LIS/ORI.
1070def : Pat<(i32 imm:$imm),
1071 (ORI (LIS (HI16 imm:$imm)), (LO16 imm:$imm))>;
1072
1073// Implement the 'not' operation with the NOR instruction.
1074def NOT : Pat<(not GPRC:$in),
1075 (NOR GPRC:$in, GPRC:$in)>;
1076
1077// ADD an arbitrary immediate.
1078def : Pat<(add GPRC:$in, imm:$imm),
1079 (ADDIS (ADDI GPRC:$in, (LO16 imm:$imm)), (HA16 imm:$imm))>;
1080// OR an arbitrary immediate.
1081def : Pat<(or GPRC:$in, imm:$imm),
1082 (ORIS (ORI GPRC:$in, (LO16 imm:$imm)), (HI16 imm:$imm))>;
1083// XOR an arbitrary immediate.
1084def : Pat<(xor GPRC:$in, imm:$imm),
1085 (XORIS (XORI GPRC:$in, (LO16 imm:$imm)), (HI16 imm:$imm))>;
1086// SUBFIC
1087def : Pat<(sub immSExt16:$imm, GPRC:$in),
1088 (SUBFIC GPRC:$in, imm:$imm)>;
1089
1090// SHL/SRL
1091def : Pat<(shl GPRC:$in, (i32 imm:$imm)),
1092 (RLWINM GPRC:$in, imm:$imm, 0, (SHL32 imm:$imm))>;
1093def : Pat<(srl GPRC:$in, (i32 imm:$imm)),
1094 (RLWINM GPRC:$in, (SRL32 imm:$imm), imm:$imm, 31)>;
1095
1096// ROTL
1097def : Pat<(rotl GPRC:$in, GPRC:$sh),
1098 (RLWNM GPRC:$in, GPRC:$sh, 0, 31)>;
1099def : Pat<(rotl GPRC:$in, (i32 imm:$imm)),
1100 (RLWINM GPRC:$in, imm:$imm, 0, 31)>;
1101
1102// RLWNM
1103def : Pat<(and (rotl GPRC:$in, GPRC:$sh), maskimm32:$imm),
1104 (RLWNM GPRC:$in, GPRC:$sh, (MB maskimm32:$imm), (ME maskimm32:$imm))>;
1105
1106// Calls
1107def : Pat<(PPCcall_Macho (i32 tglobaladdr:$dst)),
1108 (BL_Macho tglobaladdr:$dst)>;
1109def : Pat<(PPCcall_Macho (i32 texternalsym:$dst)),
1110 (BL_Macho texternalsym:$dst)>;
1111def : Pat<(PPCcall_ELF (i32 tglobaladdr:$dst)),
1112 (BL_ELF tglobaladdr:$dst)>;
1113def : Pat<(PPCcall_ELF (i32 texternalsym:$dst)),
1114 (BL_ELF texternalsym:$dst)>;
1115
1116// Hi and Lo for Darwin Global Addresses.
1117def : Pat<(PPChi tglobaladdr:$in, 0), (LIS tglobaladdr:$in)>;
1118def : Pat<(PPClo tglobaladdr:$in, 0), (LI tglobaladdr:$in)>;
1119def : Pat<(PPChi tconstpool:$in, 0), (LIS tconstpool:$in)>;
1120def : Pat<(PPClo tconstpool:$in, 0), (LI tconstpool:$in)>;
1121def : Pat<(PPChi tjumptable:$in, 0), (LIS tjumptable:$in)>;
1122def : Pat<(PPClo tjumptable:$in, 0), (LI tjumptable:$in)>;
1123def : Pat<(add GPRC:$in, (PPChi tglobaladdr:$g, 0)),
1124 (ADDIS GPRC:$in, tglobaladdr:$g)>;
1125def : Pat<(add GPRC:$in, (PPChi tconstpool:$g, 0)),
1126 (ADDIS GPRC:$in, tconstpool:$g)>;
1127def : Pat<(add GPRC:$in, (PPChi tjumptable:$g, 0)),
1128 (ADDIS GPRC:$in, tjumptable:$g)>;
1129
1130// Fused negative multiply subtract, alternate pattern
1131def : Pat<(fsub F8RC:$B, (fmul F8RC:$A, F8RC:$C)),
1132 (FNMSUB F8RC:$A, F8RC:$C, F8RC:$B)>,
1133 Requires<[FPContractions]>;
1134def : Pat<(fsub F4RC:$B, (fmul F4RC:$A, F4RC:$C)),
1135 (FNMSUBS F4RC:$A, F4RC:$C, F4RC:$B)>,
1136 Requires<[FPContractions]>;
1137
1138// Standard shifts. These are represented separately from the real shifts above
1139// so that we can distinguish between shifts that allow 5-bit and 6-bit shift
1140// amounts.
1141def : Pat<(sra GPRC:$rS, GPRC:$rB),
1142 (SRAW GPRC:$rS, GPRC:$rB)>;
1143def : Pat<(srl GPRC:$rS, GPRC:$rB),
1144 (SRW GPRC:$rS, GPRC:$rB)>;
1145def : Pat<(shl GPRC:$rS, GPRC:$rB),
1146 (SLW GPRC:$rS, GPRC:$rB)>;
1147
1148def : Pat<(zextloadi1 iaddr:$src),
1149 (LBZ iaddr:$src)>;
1150def : Pat<(zextloadi1 xaddr:$src),
1151 (LBZX xaddr:$src)>;
1152def : Pat<(extloadi1 iaddr:$src),
1153 (LBZ iaddr:$src)>;
1154def : Pat<(extloadi1 xaddr:$src),
1155 (LBZX xaddr:$src)>;
1156def : Pat<(extloadi8 iaddr:$src),
1157 (LBZ iaddr:$src)>;
1158def : Pat<(extloadi8 xaddr:$src),
1159 (LBZX xaddr:$src)>;
1160def : Pat<(extloadi16 iaddr:$src),
1161 (LHZ iaddr:$src)>;
1162def : Pat<(extloadi16 xaddr:$src),
1163 (LHZX xaddr:$src)>;
1164def : Pat<(extloadf32 iaddr:$src),
1165 (FMRSD (LFS iaddr:$src))>;
1166def : Pat<(extloadf32 xaddr:$src),
1167 (FMRSD (LFSX xaddr:$src))>;
1168
1169include "PPCInstrAltivec.td"
1170include "PPCInstr64Bit.td"