blob: d774f8455a24931c4414c435323b423a5e724f40 [file] [log] [blame]
Misha Brukman8c02c1c2004-07-27 23:29:16 +00001//===- PowerPCInstrInfo.td - The PowerPC Instruction Set -----*- tablegen -*-=//
Misha Brukman5dfe3a92004-06-21 16:55:25 +00002//
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//
Misha Brukman4ad7d1b2004-08-09 17:24:04 +000010// This file describes the subset of the 32-bit PowerPC instruction set, as used
11// by the PowerPC instruction selector.
Misha Brukman5dfe3a92004-06-21 16:55:25 +000012//
13//===----------------------------------------------------------------------===//
14
Misha Brukman28791dd2004-08-02 16:54:54 +000015include "PowerPCInstrFormats.td"
Misha Brukman5dfe3a92004-06-21 16:55:25 +000016
Chris Lattner47f01f12005-09-08 19:50:41 +000017//===----------------------------------------------------------------------===//
18// Selection DAG Type Constraint definitions.
19//
Chris Lattnerb85c64c2005-09-08 23:17:26 +000020// Note that the semantics of these constraints are hard coded into tblgen. To
21// modify or add constraints, you have to hack tblgen.
Chris Lattner47f01f12005-09-08 19:50:41 +000022//
23
24class SDTypeConstraint<int opnum> {
25 int OperandNum = opnum;
26}
27
28// SDTCisVT - The specified operand has exactly this VT.
29class SDTCisVT <int OpNum, ValueType vt> : SDTypeConstraint<OpNum> {
30 ValueType VT = vt;
31}
32
33// SDTCisInt - The specified operand is has integer type.
34class SDTCisInt<int OpNum> : SDTypeConstraint<OpNum>;
35
36// SDTCisFP - The specified operand is has floating point type.
37class SDTCisFP <int OpNum> : SDTypeConstraint<OpNum>;
38
39// SDTCisSameAs - The two specified operands have identical types.
40class SDTCisSameAs<int OpNum, int OtherOp> : SDTypeConstraint<OpNum> {
41 int OtherOperandNum = OtherOp;
42}
43
44// SDTCisVTSmallerThanOp - The specified operand is a VT SDNode, and its type is
45// smaller than the 'Other' operand.
46class SDTCisVTSmallerThanOp<int OpNum, int OtherOp> : SDTypeConstraint<OpNum> {
47 int OtherOperandNum = OtherOp;
48}
49
50//===----------------------------------------------------------------------===//
51// Selection DAG Type Profile definitions.
52//
53// These use the constraints defined above to describe the type requirements of
54// the various nodes. These are not hard coded into tblgen, allowing targets to
55// add their own if needed.
56//
57
58// SDTypeProfile - This profile describes the type requirements of a Selection
59// DAG node.
60class SDTypeProfile<int numresults, int numoperands,
61 list<SDTypeConstraint> constraints> {
62 int NumResults = numresults;
63 int NumOperands = numoperands;
64 list<SDTypeConstraint> Constraints = constraints;
65}
66
67// Builtin profiles.
68def SDTImm : SDTypeProfile<1, 0, [SDTCisInt<0>]>; // for 'imm'.
69def SDTVT : SDTypeProfile<1, 0, [SDTCisVT<0, OtherVT>]>; // for 'vt'
Chris Lattnerb85c64c2005-09-08 23:17:26 +000070def SDTBinOp : SDTypeProfile<1, 2, [ // add, mul, etc.
71 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>
72]>;
Chris Lattner47f01f12005-09-08 19:50:41 +000073def SDTIntBinOp : SDTypeProfile<1, 2, [ // and, or, xor, udiv, etc.
74 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisInt<0>
75]>;
76def SDTIntUnaryOp : SDTypeProfile<1, 1, [ // ctlz
77 SDTCisSameAs<0, 1>, SDTCisInt<0>
78]>;
79def SDTExtInreg : SDTypeProfile<1, 2, [ // sext_inreg
80 SDTCisSameAs<0, 1>, SDTCisInt<0>, SDTCisVT<2, OtherVT>,
81 SDTCisVTSmallerThanOp<2, 1>
82]>;
83
84
85//===----------------------------------------------------------------------===//
86// Selection DAG Node definitions.
87//
88class SDNode<string opcode, SDTypeProfile typeprof, string sdclass = "SDNode"> {
Chris Lattner7cd09cf2005-09-03 00:21:51 +000089 string Opcode = opcode;
90 string SDClass = sdclass;
Chris Lattner47f01f12005-09-08 19:50:41 +000091 SDTypeProfile TypeProfile = typeprof;
Chris Lattner6159fb22005-09-02 22:35:53 +000092}
93
Chris Lattner218a15d2005-09-02 21:18:00 +000094def set;
Chris Lattnere147ceb2005-09-03 01:28:40 +000095def node;
Chris Lattner7cd09cf2005-09-03 00:21:51 +000096
Chris Lattner47f01f12005-09-08 19:50:41 +000097def imm : SDNode<"ISD::Constant" , SDTImm , "ConstantSDNode">;
98def vt : SDNode<"ISD::VALUETYPE" , SDTVT , "VTSDNode">;
99def and : SDNode<"ISD::AND" , SDTIntBinOp>;
100def or : SDNode<"ISD::OR" , SDTIntBinOp>;
101def xor : SDNode<"ISD::XOR" , SDTIntBinOp>;
102def add : SDNode<"ISD::ADD" , SDTBinOp>;
103def sub : SDNode<"ISD::SUB" , SDTBinOp>;
104def mul : SDNode<"ISD::MUL" , SDTBinOp>;
105def sdiv : SDNode<"ISD::SDIV" , SDTBinOp>;
106def udiv : SDNode<"ISD::UDIV" , SDTIntBinOp>;
107def mulhs : SDNode<"ISD::MULHS" , SDTIntBinOp>;
108def mulhu : SDNode<"ISD::MULHU" , SDTIntBinOp>;
109def sext_inreg : SDNode<"ISD::SIGN_EXTEND_INREG", SDTExtInreg>;
110def ctlz : SDNode<"ISD::CTLZ" , SDTIntUnaryOp>;
111
Chris Lattner2eb25172005-09-09 00:39:56 +0000112//===----------------------------------------------------------------------===//
113// Selection DAG Node Transformation Functions.
114//
115// This mechanism allows targets to manipulate nodes in the output DAG once a
116// match has been formed. This is typically used to manipulate immediate
117// values.
118//
119class SDNodeXForm<SDNode opc, code xformFunction> {
120 SDNode Opcode = opc;
121 code XFormFunction = xformFunction;
122}
123
124def NOOP_SDNodeXForm : SDNodeXForm<imm, [{}]>;
125
Chris Lattner47f01f12005-09-08 19:50:41 +0000126
127//===----------------------------------------------------------------------===//
128// Selection DAG Pattern Fragments.
129//
Chris Lattner2eb25172005-09-09 00:39:56 +0000130// Pattern fragments are reusable chunks of dags that match specific things.
131// They can take arguments and have C++ predicates that control whether they
132// match. They are intended to make the patterns for common instructions more
133// compact and readable.
134//
Chris Lattner6159fb22005-09-02 22:35:53 +0000135
Chris Lattner7cd09cf2005-09-03 00:21:51 +0000136/// PatFrag - Represents a pattern fragment. This can match something on the
137/// DAG, frame a single node to multiply nested other fragments.
138///
Chris Lattner2eb25172005-09-09 00:39:56 +0000139class PatFrag<dag ops, dag frag, code pred = [{}],
140 SDNodeXForm xform = NOOP_SDNodeXForm> {
Chris Lattnere147ceb2005-09-03 01:28:40 +0000141 dag Operands = ops;
Chris Lattner7cd09cf2005-09-03 00:21:51 +0000142 dag Fragment = frag;
143 code Predicate = pred;
Chris Lattner2eb25172005-09-09 00:39:56 +0000144 SDNodeXForm OperandTransform = xform;
Chris Lattner7cd09cf2005-09-03 00:21:51 +0000145}
Chris Lattner3e63ead2005-09-08 17:33:10 +0000146
147// PatLeaf's are pattern fragments that have no operands. This is just a helper
148// to define immediates and other common things concisely.
Chris Lattner2eb25172005-09-09 00:39:56 +0000149class PatLeaf<dag frag, code pred = [{}], SDNodeXForm xform = NOOP_SDNodeXForm>
Chris Lattner3e63ead2005-09-08 17:33:10 +0000150 : PatFrag<(ops), frag, pred, xform>;
Chris Lattner7cd09cf2005-09-03 00:21:51 +0000151
152// Leaf fragments.
153
Chris Lattnere147ceb2005-09-03 01:28:40 +0000154def immAllOnes : PatLeaf<(imm), [{ return N->isAllOnesValue(); }]>;
155def immZero : PatLeaf<(imm), [{ return N->isNullValue(); }]>;
Chris Lattner7cd09cf2005-09-03 00:21:51 +0000156
Chris Lattnere147ceb2005-09-03 01:28:40 +0000157def vtInt : PatLeaf<(vt), [{ return MVT::isInteger(N->getVT()); }]>;
158def vtFP : PatLeaf<(vt), [{ return MVT::isFloatingPoint(N->getVT()); }]>;
Chris Lattner7cd09cf2005-09-03 00:21:51 +0000159
160// Other helper fragments.
161
Chris Lattnere147ceb2005-09-03 01:28:40 +0000162def not : PatFrag<(ops node:$in), (xor node:$in, immAllOnes)>;
163def ineg : PatFrag<(ops node:$in), (sub immZero, node:$in)>;
164
Chris Lattner2eb25172005-09-09 00:39:56 +0000165//===----------------------------------------------------------------------===//
166// Selection DAG Pattern Support.
167//
168// Patterns are what are actually matched against the target-flavored
169// instruction selection DAG. Instructions defined by the target implicitly
170// define patterns in most cases, but patterns can also be explicitly added when
171// an operation is defined by a sequence of instructions (e.g. loading a large
172// immediate value on RISC targets that do not support immediates as large as
173// their GPRs).
174//
175
176class Pattern<dag patternToMatch, list<dag> resultInstrs> {
177 dag PatternToMatch = patternToMatch;
178 list<dag> ResultInstrs = resultInstrs;
179}
180
181// Pat - A simple (but common) form of a pattern, which produces a simple result
182// not needing a full list.
183class Pat<dag pattern, dag result> : Pattern<pattern, [result]>;
Chris Lattner47f01f12005-09-08 19:50:41 +0000184
Chris Lattner47f01f12005-09-08 19:50:41 +0000185//===----------------------------------------------------------------------===//
Chris Lattner2eb25172005-09-09 00:39:56 +0000186// PowerPC specific transformation functions and pattern fragments.
187//
188def LO16 : SDNodeXForm<imm, [{
189 // Transformation function: get the low 16 bits.
190 return getI32Imm((unsigned short)N->getValue());
191}]>;
192
193def HI16 : SDNodeXForm<imm, [{
194 // Transformation function: shift the immediate value down into the low bits.
195 return getI32Imm((unsigned)N->getValue() >> 16);
196}]>;
Chris Lattner3e63ead2005-09-08 17:33:10 +0000197
198def immSExt16 : PatLeaf<(imm), [{
199 // immSExt16 predicate - True if the immediate fits in a 16-bit sign extended
200 // field. Used by instructions like 'addi'.
201 return (int)N->getValue() == (short)N->getValue();
202}]>;
Chris Lattnerbfde0802005-09-08 17:40:49 +0000203def immZExt16 : PatLeaf<(imm), [{
204 // immZExt16 predicate - True if the immediate fits in a 16-bit zero extended
205 // field. Used by instructions like 'ori'.
206 return (unsigned)N->getValue() == (unsigned short)N->getValue();
Chris Lattner2eb25172005-09-09 00:39:56 +0000207}], LO16>;
208
Chris Lattner3e63ead2005-09-08 17:33:10 +0000209def imm16Shifted : PatLeaf<(imm), [{
210 // imm16Shifted predicate - True if only bits in the top 16-bits of the
211 // immediate are set. Used by instructions like 'addis'.
212 return ((unsigned)N->getValue() & 0xFFFF0000U) == (unsigned)N->getValue();
Chris Lattner2eb25172005-09-09 00:39:56 +0000213}], HI16>;
Chris Lattner3e63ead2005-09-08 17:33:10 +0000214
Chris Lattnerbfde0802005-09-08 17:40:49 +0000215/*
216// Example of a legalize expander: Only for PPC64.
217def : Expander<(set i64:$dst, (fp_to_sint f64:$src)),
218 [(set f64:$tmp , (FCTIDZ f64:$src)),
219 (set i32:$tmpFI, (CreateNewFrameIndex 8, 8)),
220 (store f64:$tmp, i32:$tmpFI),
221 (set i64:$dst, (load i32:$tmpFI))],
222 Subtarget_PPC64>;
223*/
Chris Lattner3e63ead2005-09-08 17:33:10 +0000224
Chris Lattner47f01f12005-09-08 19:50:41 +0000225//===----------------------------------------------------------------------===//
226// PowerPC Flag Definitions.
227
Chris Lattner0bdc6f12005-04-19 04:32:54 +0000228class isPPC64 { bit PPC64 = 1; }
229class isVMX { bit VMX = 1; }
Chris Lattner883059f2005-04-19 05:15:18 +0000230class isDOT {
231 list<Register> Defs = [CR0];
232 bit RC = 1;
233}
Chris Lattner0bdc6f12005-04-19 04:32:54 +0000234
Chris Lattner47f01f12005-09-08 19:50:41 +0000235
236
237//===----------------------------------------------------------------------===//
238// PowerPC Operand Definitions.
Chris Lattner7bb424f2004-08-14 23:27:29 +0000239
Chris Lattner4345a4a2005-09-14 20:53:05 +0000240def u5imm : Operand<i32> {
Nate Begemanc3306122004-08-21 05:56:39 +0000241 let PrintMethod = "printU5ImmOperand";
242}
Chris Lattner4345a4a2005-09-14 20:53:05 +0000243def u6imm : Operand<i32> {
Nate Begeman07aada82004-08-30 02:28:06 +0000244 let PrintMethod = "printU6ImmOperand";
245}
Chris Lattner4345a4a2005-09-14 20:53:05 +0000246def s16imm : Operand<i32> {
Nate Begemaned428532004-09-04 05:00:00 +0000247 let PrintMethod = "printS16ImmOperand";
248}
Chris Lattner4345a4a2005-09-14 20:53:05 +0000249def u16imm : Operand<i32> {
Chris Lattner97b2a2e2004-08-15 05:20:16 +0000250 let PrintMethod = "printU16ImmOperand";
251}
Nate Begemanb7a8f2c2004-09-02 08:13:00 +0000252def target : Operand<i32> {
253 let PrintMethod = "printBranchOperand";
254}
255def piclabel: Operand<i32> {
256 let PrintMethod = "printPICLabel";
257}
Nate Begemaned428532004-09-04 05:00:00 +0000258def symbolHi: Operand<i32> {
259 let PrintMethod = "printSymbolHi";
260}
261def symbolLo: Operand<i32> {
262 let PrintMethod = "printSymbolLo";
263}
Nate Begemanadeb43d2005-07-20 22:42:00 +0000264def crbitm: Operand<i8> {
265 let PrintMethod = "printcrbitm";
266}
Chris Lattner97b2a2e2004-08-15 05:20:16 +0000267
Chris Lattner47f01f12005-09-08 19:50:41 +0000268
269
270//===----------------------------------------------------------------------===//
271// PowerPC Instruction Definitions.
272
Misha Brukman5dfe3a92004-06-21 16:55:25 +0000273// Pseudo-instructions:
Chris Lattner45fcb8f2005-08-18 23:25:33 +0000274def PHI : Pseudo<(ops variable_ops), "; PHI">;
Chris Lattner47f01f12005-09-08 19:50:41 +0000275
Nate Begemanb816f022004-10-07 22:30:03 +0000276let isLoad = 1 in {
Chris Lattner43ef1312005-09-14 21:10:24 +0000277def ADJCALLSTACKDOWN : Pseudo<(ops u16imm:$amt), "; ADJCALLSTACKDOWN">;
278def ADJCALLSTACKUP : Pseudo<(ops u16imm:$amt), "; ADJCALLSTACKUP">;
Nate Begemanb816f022004-10-07 22:30:03 +0000279}
Chris Lattner2b544002005-08-24 23:08:16 +0000280def IMPLICIT_DEF_GPR : Pseudo<(ops GPRC:$rD), "; $rD = IMPLICIT_DEF_GPRC">;
281def IMPLICIT_DEF_FP : Pseudo<(ops FPRC:$rD), "; %rD = IMPLICIT_DEF_FP">;
Chris Lattner7a823bd2005-02-15 20:26:49 +0000282
Chris Lattner8a2d3ca2005-08-26 21:23:58 +0000283// SELECT_CC_* - Used to implement the SELECT_CC DAG operation. Expanded by the
284// scheduler into a branch sequence.
285let usesCustomDAGSchedInserter = 1 in { // Expanded by the scheduler.
286 def SELECT_CC_Int : Pseudo<(ops GPRC:$dst, CRRC:$cond, GPRC:$T, GPRC:$F,
287 i32imm:$BROPC), "; SELECT_CC PSEUDO!">;
288 def SELECT_CC_FP : Pseudo<(ops FPRC:$dst, CRRC:$cond, FPRC:$T, FPRC:$F,
Chris Lattner218a15d2005-09-02 21:18:00 +0000289 i32imm:$BROPC), "; SELECT_CC PSEUDO!">;
Chris Lattner8a2d3ca2005-08-26 21:23:58 +0000290}
291
292
Chris Lattner47f01f12005-09-08 19:50:41 +0000293let isTerminator = 1 in {
294 let isReturn = 1 in
295 def BLR : XLForm_2_ext<19, 16, 20, 0, 0, (ops), "blr">;
296 def BCTR : XLForm_2_ext<19, 528, 20, 0, 0, (ops), "bctr">;
297}
298
Chris Lattner7a823bd2005-02-15 20:26:49 +0000299let Defs = [LR] in
300 def MovePCtoLR : Pseudo<(ops piclabel:$label), "bl $label">;
Misha Brukman5dfe3a92004-06-21 16:55:25 +0000301
Misha Brukmanb2edb442004-06-28 18:23:35 +0000302let isBranch = 1, isTerminator = 1 in {
Chris Lattner43ef1312005-09-14 21:10:24 +0000303 def COND_BRANCH : Pseudo<(ops CRRC:$crS, u16imm:$opc,
304 target:$true, target:$false),
Chris Lattner45fcb8f2005-08-18 23:25:33 +0000305 "; COND_BRANCH">;
Chris Lattnera611ab72005-04-19 05:00:59 +0000306 def B : IForm<18, 0, 0, (ops target:$func), "b $func">;
307//def BA : IForm<18, 1, 0, (ops target:$func), "ba $func">;
308 def BL : IForm<18, 0, 1, (ops target:$func), "bl $func">;
309//def BLA : IForm<18, 1, 1, (ops target:$func), "bla $func">;
Chris Lattnerdd998852004-11-22 23:07:01 +0000310
Misha Brukman4ad7d1b2004-08-09 17:24:04 +0000311 // FIXME: 4*CR# needs to be added to the BI field!
312 // This will only work for CR0 as it stands now
Nate Begeman6718f112005-08-26 04:11:42 +0000313 def BLT : BForm<16, 0, 0, 12, 0, (ops CRRC:$crS, target:$block),
Chris Lattnere3f1c972005-08-26 23:42:05 +0000314 "blt $crS, $block">;
Nate Begeman6718f112005-08-26 04:11:42 +0000315 def BLE : BForm<16, 0, 0, 4, 1, (ops CRRC:$crS, target:$block),
Chris Lattnere3f1c972005-08-26 23:42:05 +0000316 "ble $crS, $block">;
Nate Begeman6718f112005-08-26 04:11:42 +0000317 def BEQ : BForm<16, 0, 0, 12, 2, (ops CRRC:$crS, target:$block),
Chris Lattnere3f1c972005-08-26 23:42:05 +0000318 "beq $crS, $block">;
Nate Begeman6718f112005-08-26 04:11:42 +0000319 def BGE : BForm<16, 0, 0, 4, 0, (ops CRRC:$crS, target:$block),
Chris Lattnere3f1c972005-08-26 23:42:05 +0000320 "bge $crS, $block">;
Nate Begeman6718f112005-08-26 04:11:42 +0000321 def BGT : BForm<16, 0, 0, 12, 1, (ops CRRC:$crS, target:$block),
Chris Lattnere3f1c972005-08-26 23:42:05 +0000322 "bgt $crS, $block">;
Nate Begeman6718f112005-08-26 04:11:42 +0000323 def BNE : BForm<16, 0, 0, 4, 2, (ops CRRC:$crS, target:$block),
Chris Lattnere3f1c972005-08-26 23:42:05 +0000324 "bne $crS, $block">;
Misha Brukmanb2edb442004-06-28 18:23:35 +0000325}
326
Chris Lattnerfc879282005-05-15 20:11:44 +0000327let isCall = 1,
Misha Brukman5fa2b022004-06-29 23:37:36 +0000328 // All calls clobber the non-callee saved registers...
Misha Brukmanc661c302004-06-30 22:00:45 +0000329 Defs = [R0,R2,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,
330 F0,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,
Chris Lattner1f24df62005-08-22 22:32:13 +0000331 LR,CTR,
Misha Brukmanc661c302004-06-30 22:00:45 +0000332 CR0,CR1,CR5,CR6,CR7] in {
333 // Convenient aliases for call instructions
Chris Lattner45fcb8f2005-08-18 23:25:33 +0000334 def CALLpcrel : IForm<18, 0, 1, (ops target:$func, variable_ops), "bl $func">;
335 def CALLindirect : XLForm_2_ext<19, 528, 20, 0, 1,
336 (ops variable_ops), "bctrl">;
Misha Brukman5fa2b022004-06-29 23:37:36 +0000337}
338
Nate Begeman07aada82004-08-30 02:28:06 +0000339// D-Form instructions. Most instructions that perform an operation on a
340// register and an immediate are of this type.
341//
Nate Begemanb816f022004-10-07 22:30:03 +0000342let isLoad = 1 in {
Nate Begeman2497e632005-07-21 20:44:43 +0000343def LBZ : DForm_1<34, (ops GPRC:$rD, symbolLo:$disp, GPRC:$rA),
Nate Begemaned428532004-09-04 05:00:00 +0000344 "lbz $rD, $disp($rA)">;
Nate Begeman2497e632005-07-21 20:44:43 +0000345def LHA : DForm_1<42, (ops GPRC:$rD, symbolLo:$disp, GPRC:$rA),
Nate Begemaned428532004-09-04 05:00:00 +0000346 "lha $rD, $disp($rA)">;
Nate Begeman2497e632005-07-21 20:44:43 +0000347def LHZ : DForm_1<40, (ops GPRC:$rD, symbolLo:$disp, GPRC:$rA),
Nate Begemaned428532004-09-04 05:00:00 +0000348 "lhz $rD, $disp($rA)">;
Chris Lattner57226fb2005-04-19 04:59:28 +0000349def LMW : DForm_1<46, (ops GPRC:$rD, s16imm:$disp, GPRC:$rA),
Nate Begemaned428532004-09-04 05:00:00 +0000350 "lmw $rD, $disp($rA)">;
Chris Lattner57226fb2005-04-19 04:59:28 +0000351def LWZ : DForm_1<32, (ops GPRC:$rD, symbolLo:$disp, GPRC:$rA),
Nate Begemaned428532004-09-04 05:00:00 +0000352 "lwz $rD, $disp($rA)">;
Nate Begeman2497e632005-07-21 20:44:43 +0000353def LWZU : DForm_1<35, (ops GPRC:$rD, s16imm:$disp, GPRC:$rA),
Misha Brukman145a5a32004-11-15 21:20:09 +0000354 "lwzu $rD, $disp($rA)">;
Nate Begemanb816f022004-10-07 22:30:03 +0000355}
Chris Lattner57226fb2005-04-19 04:59:28 +0000356def ADDI : DForm_2<14, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
Chris Lattner3e63ead2005-09-08 17:33:10 +0000357 "addi $rD, $rA, $imm",
358 [(set GPRC:$rD, (add GPRC:$rA, immSExt16:$imm))]>;
Chris Lattner57226fb2005-04-19 04:59:28 +0000359def ADDIC : DForm_2<12, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
Chris Lattner3e63ead2005-09-08 17:33:10 +0000360 "addic $rD, $rA, $imm",
361 []>;
Chris Lattner57226fb2005-04-19 04:59:28 +0000362def ADDICo : DForm_2<13, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
Chris Lattner3e63ead2005-09-08 17:33:10 +0000363 "addic. $rD, $rA, $imm",
364 []>;
Nate Begeman2497e632005-07-21 20:44:43 +0000365def ADDIS : DForm_2<15, (ops GPRC:$rD, GPRC:$rA, symbolHi:$imm),
Chris Lattner3e63ead2005-09-08 17:33:10 +0000366 "addis $rD, $rA, $imm",
367 [(set GPRC:$rD, (add GPRC:$rA, imm16Shifted:$imm))]>;
Chris Lattner57226fb2005-04-19 04:59:28 +0000368def LA : DForm_2<14, (ops GPRC:$rD, GPRC:$rA, symbolLo:$sym),
Chris Lattner3e63ead2005-09-08 17:33:10 +0000369 "la $rD, $sym($rA)",
370 []>;
Chris Lattner57226fb2005-04-19 04:59:28 +0000371def MULLI : DForm_2< 7, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
Chris Lattner3e63ead2005-09-08 17:33:10 +0000372 "mulli $rD, $rA, $imm",
373 [(set GPRC:$rD, (mul GPRC:$rA, immSExt16:$imm))]>;
Chris Lattner57226fb2005-04-19 04:59:28 +0000374def SUBFIC : DForm_2< 8, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
Chris Lattner3e63ead2005-09-08 17:33:10 +0000375 "subfic $rD, $rA, $imm",
376 []>;
Chris Lattner57226fb2005-04-19 04:59:28 +0000377def LI : DForm_2_r0<14, (ops GPRC:$rD, s16imm:$imm),
Chris Lattner3e63ead2005-09-08 17:33:10 +0000378 "li $rD, $imm",
379 [(set GPRC:$rD, immSExt16:$imm)]>;
Nate Begeman2497e632005-07-21 20:44:43 +0000380def LIS : DForm_2_r0<15, (ops GPRC:$rD, symbolHi:$imm),
Chris Lattner3e63ead2005-09-08 17:33:10 +0000381 "lis $rD, $imm",
382 [(set GPRC:$rD, imm16Shifted:$imm)]>;
Nate Begemanb816f022004-10-07 22:30:03 +0000383let isStore = 1 in {
Chris Lattner57226fb2005-04-19 04:59:28 +0000384def STMW : DForm_3<47, (ops GPRC:$rS, s16imm:$disp, GPRC:$rA),
Nate Begemaned428532004-09-04 05:00:00 +0000385 "stmw $rS, $disp($rA)">;
Nate Begeman2497e632005-07-21 20:44:43 +0000386def STB : DForm_3<38, (ops GPRC:$rS, symbolLo:$disp, GPRC:$rA),
Nate Begemaned428532004-09-04 05:00:00 +0000387 "stb $rS, $disp($rA)">;
Nate Begeman2497e632005-07-21 20:44:43 +0000388def STH : DForm_3<44, (ops GPRC:$rS, symbolLo:$disp, GPRC:$rA),
Nate Begemaned428532004-09-04 05:00:00 +0000389 "sth $rS, $disp($rA)">;
Nate Begeman2497e632005-07-21 20:44:43 +0000390def STW : DForm_3<36, (ops GPRC:$rS, symbolLo:$disp, GPRC:$rA),
Nate Begemaned428532004-09-04 05:00:00 +0000391 "stw $rS, $disp($rA)">;
Chris Lattner57226fb2005-04-19 04:59:28 +0000392def STWU : DForm_3<37, (ops GPRC:$rS, s16imm:$disp, GPRC:$rA),
Nate Begemaned428532004-09-04 05:00:00 +0000393 "stwu $rS, $disp($rA)">;
Nate Begemanb816f022004-10-07 22:30:03 +0000394}
Chris Lattner57226fb2005-04-19 04:59:28 +0000395def ANDIo : DForm_4<28, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
Chris Lattnerbfde0802005-09-08 17:40:49 +0000396 "andi. $dst, $src1, $src2",
397 []>, isDOT;
Chris Lattner57226fb2005-04-19 04:59:28 +0000398def ANDISo : DForm_4<29, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
Chris Lattnerbfde0802005-09-08 17:40:49 +0000399 "andis. $dst, $src1, $src2",
400 []>, isDOT;
Chris Lattner57226fb2005-04-19 04:59:28 +0000401def ORI : DForm_4<24, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
Chris Lattnerbfde0802005-09-08 17:40:49 +0000402 "ori $dst, $src1, $src2",
Chris Lattnerc36d0652005-09-14 18:18:39 +0000403 [(set GPRC:$dst, (or GPRC:$src1, immZExt16:$src2))]>;
Chris Lattner57226fb2005-04-19 04:59:28 +0000404def ORIS : DForm_4<25, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
Chris Lattnerbfde0802005-09-08 17:40:49 +0000405 "oris $dst, $src1, $src2",
Chris Lattnerc36d0652005-09-14 18:18:39 +0000406 [(set GPRC:$dst, (or GPRC:$src1, imm16Shifted:$src2))]>;
Chris Lattner57226fb2005-04-19 04:59:28 +0000407def XORI : DForm_4<26, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
Chris Lattnerbfde0802005-09-08 17:40:49 +0000408 "xori $dst, $src1, $src2",
Chris Lattnerc36d0652005-09-14 18:18:39 +0000409 [(set GPRC:$dst, (xor GPRC:$src1, immZExt16:$src2))]>;
Chris Lattner57226fb2005-04-19 04:59:28 +0000410def XORIS : DForm_4<27, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
Chris Lattnerbfde0802005-09-08 17:40:49 +0000411 "xoris $dst, $src1, $src2",
Chris Lattner4345a4a2005-09-14 20:53:05 +0000412 [(set GPRC:$dst, (xor GPRC:$src1, imm16Shifted:$src2))]>;
Chris Lattner57226fb2005-04-19 04:59:28 +0000413def NOP : DForm_4_zero<24, (ops), "nop">;
414def CMPI : DForm_5<11, (ops CRRC:$crD, i1imm:$L, GPRC:$rA, s16imm:$imm),
Nate Begemaned428532004-09-04 05:00:00 +0000415 "cmpi $crD, $L, $rA, $imm">;
Chris Lattner57226fb2005-04-19 04:59:28 +0000416def CMPWI : DForm_5_ext<11, (ops CRRC:$crD, GPRC:$rA, s16imm:$imm),
Nate Begemaned428532004-09-04 05:00:00 +0000417 "cmpwi $crD, $rA, $imm">;
Chris Lattner57226fb2005-04-19 04:59:28 +0000418def CMPDI : DForm_5_ext<11, (ops CRRC:$crD, GPRC:$rA, s16imm:$imm),
419 "cmpdi $crD, $rA, $imm">, isPPC64;
420def CMPLI : DForm_6<10, (ops CRRC:$dst, i1imm:$size, GPRC:$src1, u16imm:$src2),
Nate Begemaned428532004-09-04 05:00:00 +0000421 "cmpli $dst, $size, $src1, $src2">;
Chris Lattner57226fb2005-04-19 04:59:28 +0000422def CMPLWI : DForm_6_ext<10, (ops CRRC:$dst, GPRC:$src1, u16imm:$src2),
Nate Begeman6b3dc552004-08-29 22:45:13 +0000423 "cmplwi $dst, $src1, $src2">;
Chris Lattner57226fb2005-04-19 04:59:28 +0000424def CMPLDI : DForm_6_ext<10, (ops CRRC:$dst, GPRC:$src1, u16imm:$src2),
425 "cmpldi $dst, $src1, $src2">, isPPC64;
Nate Begemanb816f022004-10-07 22:30:03 +0000426let isLoad = 1 in {
Chris Lattnerfdf83662005-08-25 00:26:22 +0000427def LFS : DForm_8<48, (ops FPRC:$rD, symbolLo:$disp, GPRC:$rA),
Nate Begemaned428532004-09-04 05:00:00 +0000428 "lfs $rD, $disp($rA)">;
Chris Lattnerfdf83662005-08-25 00:26:22 +0000429def LFD : DForm_8<50, (ops FPRC:$rD, symbolLo:$disp, GPRC:$rA),
Nate Begemaned428532004-09-04 05:00:00 +0000430 "lfd $rD, $disp($rA)">;
Nate Begemanb816f022004-10-07 22:30:03 +0000431}
432let isStore = 1 in {
Chris Lattnerfdf83662005-08-25 00:26:22 +0000433def STFS : DForm_9<52, (ops FPRC:$rS, symbolLo:$disp, GPRC:$rA),
Nate Begemaned428532004-09-04 05:00:00 +0000434 "stfs $rS, $disp($rA)">;
Chris Lattnerfdf83662005-08-25 00:26:22 +0000435def STFD : DForm_9<54, (ops FPRC:$rS, symbolLo:$disp, GPRC:$rA),
Nate Begemaned428532004-09-04 05:00:00 +0000436 "stfd $rS, $disp($rA)">;
Nate Begemanb816f022004-10-07 22:30:03 +0000437}
Nate Begemaned428532004-09-04 05:00:00 +0000438
439// DS-Form instructions. Load/Store instructions available in PPC-64
440//
Nate Begemanb816f022004-10-07 22:30:03 +0000441let isLoad = 1 in {
Chris Lattner57226fb2005-04-19 04:59:28 +0000442def LWA : DSForm_1<58, 2, (ops GPRC:$rT, s16imm:$DS, GPRC:$rA),
443 "lwa $rT, $DS($rA)">, isPPC64;
444def LD : DSForm_2<58, 0, (ops GPRC:$rT, s16imm:$DS, GPRC:$rA),
445 "ld $rT, $DS($rA)">, isPPC64;
Nate Begemanb816f022004-10-07 22:30:03 +0000446}
447let isStore = 1 in {
Chris Lattner57226fb2005-04-19 04:59:28 +0000448def STD : DSForm_2<62, 0, (ops GPRC:$rT, s16imm:$DS, GPRC:$rA),
449 "std $rT, $DS($rA)">, isPPC64;
450def STDU : DSForm_2<62, 1, (ops GPRC:$rT, s16imm:$DS, GPRC:$rA),
451 "stdu $rT, $DS($rA)">, isPPC64;
Nate Begemanb816f022004-10-07 22:30:03 +0000452}
Nate Begemanc3306122004-08-21 05:56:39 +0000453
Nate Begeman07aada82004-08-30 02:28:06 +0000454// X-Form instructions. Most instructions that perform an operation on a
455// register and another register are of this type.
456//
Nate Begemanb816f022004-10-07 22:30:03 +0000457let isLoad = 1 in {
Chris Lattnere19d0b12005-04-19 04:51:30 +0000458def LBZX : XForm_1<31, 87, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
Nate Begemanc3306122004-08-21 05:56:39 +0000459 "lbzx $dst, $base, $index">;
Chris Lattnere19d0b12005-04-19 04:51:30 +0000460def LHAX : XForm_1<31, 343, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
Nate Begemanc3306122004-08-21 05:56:39 +0000461 "lhax $dst, $base, $index">;
Chris Lattnere19d0b12005-04-19 04:51:30 +0000462def LHZX : XForm_1<31, 279, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
Nate Begemanc3306122004-08-21 05:56:39 +0000463 "lhzx $dst, $base, $index">;
Chris Lattnere19d0b12005-04-19 04:51:30 +0000464def LWAX : XForm_1<31, 341, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
465 "lwax $dst, $base, $index">, isPPC64;
466def LWZX : XForm_1<31, 23, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
Nate Begemanc3306122004-08-21 05:56:39 +0000467 "lwzx $dst, $base, $index">;
Chris Lattnere19d0b12005-04-19 04:51:30 +0000468def LDX : XForm_1<31, 21, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
469 "ldx $dst, $base, $index">, isPPC64;
Nate Begemanb816f022004-10-07 22:30:03 +0000470}
Chris Lattner7cd09cf2005-09-03 00:21:51 +0000471def NAND : XForm_6<31, 476, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
472 "nand $rA, $rS, $rB",
473 [(set GPRC:$rA, (not (and GPRC:$rS, GPRC:$rB)))]>;
Chris Lattner883059f2005-04-19 05:15:18 +0000474def AND : XForm_6<31, 28, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
Chris Lattner6159fb22005-09-02 22:35:53 +0000475 "and $rA, $rS, $rB",
Chris Lattnerc36d0652005-09-14 18:18:39 +0000476 [(set GPRC:$rA, (and GPRC:$rS, GPRC:$rB))]>;
Chris Lattner883059f2005-04-19 05:15:18 +0000477def ANDo : XForm_6<31, 28, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
Chris Lattner6159fb22005-09-02 22:35:53 +0000478 "and. $rA, $rS, $rB",
479 []>, isDOT;
Chris Lattner883059f2005-04-19 05:15:18 +0000480def ANDC : XForm_6<31, 60, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
Chris Lattner6159fb22005-09-02 22:35:53 +0000481 "andc $rA, $rS, $rB",
Chris Lattner7cd09cf2005-09-03 00:21:51 +0000482 [(set GPRC:$rA, (and GPRC:$rS, (not GPRC:$rB)))]>;
Chris Lattner883059f2005-04-19 05:15:18 +0000483def OR : XForm_6<31, 444, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
Chris Lattner6159fb22005-09-02 22:35:53 +0000484 "or $rA, $rS, $rB",
Chris Lattnerc36d0652005-09-14 18:18:39 +0000485 [(set GPRC:$rA, (or GPRC:$rS, GPRC:$rB))]>;
Chris Lattner7cd09cf2005-09-03 00:21:51 +0000486def NOR : XForm_6<31, 124, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
487 "nor $rA, $rS, $rB",
488 [(set GPRC:$rA, (not (or GPRC:$rS, GPRC:$rB)))]>;
Chris Lattner883059f2005-04-19 05:15:18 +0000489def ORo : XForm_6<31, 444, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
Chris Lattner6159fb22005-09-02 22:35:53 +0000490 "or. $rA, $rS, $rB",
491 []>, isDOT;
Chris Lattner883059f2005-04-19 05:15:18 +0000492def ORC : XForm_6<31, 412, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
Chris Lattner6159fb22005-09-02 22:35:53 +0000493 "orc $rA, $rS, $rB",
Chris Lattner7cd09cf2005-09-03 00:21:51 +0000494 [(set GPRC:$rA, (or GPRC:$rS, (not GPRC:$rB)))]>;
495def EQV : XForm_6<31, 284, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
496 "eqv $rA, $rS, $rB",
Chris Lattnerc36d0652005-09-14 18:18:39 +0000497 [(set GPRC:$rA, (not (xor GPRC:$rS, GPRC:$rB)))]>;
Chris Lattner7cd09cf2005-09-03 00:21:51 +0000498def XOR : XForm_6<31, 316, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
499 "xor $rA, $rS, $rB",
Chris Lattnerc36d0652005-09-14 18:18:39 +0000500 [(set GPRC:$rA, (xor GPRC:$rS, GPRC:$rB))]>;
Chris Lattner883059f2005-04-19 05:15:18 +0000501def SLD : XForm_6<31, 27, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
Chris Lattner6159fb22005-09-02 22:35:53 +0000502 "sld $rA, $rS, $rB",
503 []>, isPPC64;
Chris Lattner883059f2005-04-19 05:15:18 +0000504def SLW : XForm_6<31, 24, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
Chris Lattner6159fb22005-09-02 22:35:53 +0000505 "slw $rA, $rS, $rB",
506 []>;
Chris Lattner883059f2005-04-19 05:15:18 +0000507def SRD : XForm_6<31, 539, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
Chris Lattner6159fb22005-09-02 22:35:53 +0000508 "srd $rA, $rS, $rB",
509 []>, isPPC64;
Chris Lattner883059f2005-04-19 05:15:18 +0000510def SRW : XForm_6<31, 536, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
Chris Lattner6159fb22005-09-02 22:35:53 +0000511 "srw $rA, $rS, $rB",
512 []>;
Chris Lattner883059f2005-04-19 05:15:18 +0000513def SRAD : XForm_6<31, 794, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
Chris Lattner6159fb22005-09-02 22:35:53 +0000514 "srad $rA, $rS, $rB",
515 []>, isPPC64;
Chris Lattner883059f2005-04-19 05:15:18 +0000516def SRAW : XForm_6<31, 792, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
Chris Lattner6159fb22005-09-02 22:35:53 +0000517 "sraw $rA, $rS, $rB",
518 []>;
Nate Begemanb816f022004-10-07 22:30:03 +0000519let isStore = 1 in {
Chris Lattnere19d0b12005-04-19 04:51:30 +0000520def STBX : XForm_8<31, 215, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
Nate Begemanc3306122004-08-21 05:56:39 +0000521 "stbx $rS, $rA, $rB">;
Chris Lattnere19d0b12005-04-19 04:51:30 +0000522def STHX : XForm_8<31, 407, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
Nate Begemanc3306122004-08-21 05:56:39 +0000523 "sthx $rS, $rA, $rB">;
Chris Lattnere19d0b12005-04-19 04:51:30 +0000524def STWX : XForm_8<31, 151, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
Nate Begemanc3306122004-08-21 05:56:39 +0000525 "stwx $rS, $rA, $rB">;
Chris Lattnere19d0b12005-04-19 04:51:30 +0000526def STWUX : XForm_8<31, 183, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
Nate Begemanc3306122004-08-21 05:56:39 +0000527 "stwux $rS, $rA, $rB">;
Chris Lattnere19d0b12005-04-19 04:51:30 +0000528def STDX : XForm_8<31, 149, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
529 "stdx $rS, $rA, $rB">, isPPC64;
530def STDUX : XForm_8<31, 181, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
531 "stdux $rS, $rA, $rB">, isPPC64;
Nate Begemanb816f022004-10-07 22:30:03 +0000532}
Chris Lattner883059f2005-04-19 05:15:18 +0000533def SRAWI : XForm_10<31, 824, (ops GPRC:$rA, GPRC:$rS, u5imm:$SH),
Nate Begemanc3306122004-08-21 05:56:39 +0000534 "srawi $rA, $rS, $SH">;
Chris Lattner883059f2005-04-19 05:15:18 +0000535def CNTLZW : XForm_11<31, 26, (ops GPRC:$rA, GPRC:$rS),
Chris Lattner6159fb22005-09-02 22:35:53 +0000536 "cntlzw $rA, $rS",
537 [(set GPRC:$rA, (ctlz GPRC:$rS))]>;
Chris Lattner883059f2005-04-19 05:15:18 +0000538def EXTSB : XForm_11<31, 954, (ops GPRC:$rA, GPRC:$rS),
Chris Lattner6159fb22005-09-02 22:35:53 +0000539 "extsb $rA, $rS",
540 [(set GPRC:$rA, (sext_inreg GPRC:$rS, i8))]>;
Chris Lattner883059f2005-04-19 05:15:18 +0000541def EXTSH : XForm_11<31, 922, (ops GPRC:$rA, GPRC:$rS),
Chris Lattner6159fb22005-09-02 22:35:53 +0000542 "extsh $rA, $rS",
543 [(set GPRC:$rA, (sext_inreg GPRC:$rS, i16))]>;
Chris Lattner883059f2005-04-19 05:15:18 +0000544def EXTSW : XForm_11<31, 986, (ops GPRC:$rA, GPRC:$rS),
Chris Lattner6159fb22005-09-02 22:35:53 +0000545 "extsw $rA, $rS",
546 []>, isPPC64;
Chris Lattnere19d0b12005-04-19 04:51:30 +0000547def CMP : XForm_16<31, 0, (ops CRRC:$crD, i1imm:$long, GPRC:$rA, GPRC:$rB),
Nate Begemanb7a8f2c2004-09-02 08:13:00 +0000548 "cmp $crD, $long, $rA, $rB">;
Chris Lattnere19d0b12005-04-19 04:51:30 +0000549def CMPL : XForm_16<31, 32, (ops CRRC:$crD, i1imm:$long, GPRC:$rA, GPRC:$rB),
Nate Begemanb7a8f2c2004-09-02 08:13:00 +0000550 "cmpl $crD, $long, $rA, $rB">;
Chris Lattnere19d0b12005-04-19 04:51:30 +0000551def CMPW : XForm_16_ext<31, 0, (ops CRRC:$crD, GPRC:$rA, GPRC:$rB),
Nate Begemanb7a8f2c2004-09-02 08:13:00 +0000552 "cmpw $crD, $rA, $rB">;
Chris Lattnere19d0b12005-04-19 04:51:30 +0000553def CMPD : XForm_16_ext<31, 0, (ops CRRC:$crD, GPRC:$rA, GPRC:$rB),
554 "cmpd $crD, $rA, $rB">, isPPC64;
555def CMPLW : XForm_16_ext<31, 32, (ops CRRC:$crD, GPRC:$rA, GPRC:$rB),
Nate Begemanb7a8f2c2004-09-02 08:13:00 +0000556 "cmplw $crD, $rA, $rB">;
Chris Lattnere19d0b12005-04-19 04:51:30 +0000557def CMPLD : XForm_16_ext<31, 32, (ops CRRC:$crD, GPRC:$rA, GPRC:$rB),
558 "cmpld $crD, $rA, $rB">, isPPC64;
559def FCMPO : XForm_17<63, 32, (ops CRRC:$crD, FPRC:$fA, FPRC:$fB),
Nate Begeman33162522005-03-29 21:54:38 +0000560 "fcmpo $crD, $fA, $fB">;
Chris Lattnere19d0b12005-04-19 04:51:30 +0000561def FCMPU : XForm_17<63, 0, (ops CRRC:$crD, FPRC:$fA, FPRC:$fB),
Nate Begemancc8bd9c2004-08-31 02:28:08 +0000562 "fcmpu $crD, $fA, $fB">;
Nate Begemanb816f022004-10-07 22:30:03 +0000563let isLoad = 1 in {
Chris Lattnere19d0b12005-04-19 04:51:30 +0000564def LFSX : XForm_25<31, 535, (ops FPRC:$dst, GPRC:$base, GPRC:$index),
Nate Begemancc8bd9c2004-08-31 02:28:08 +0000565 "lfsx $dst, $base, $index">;
Chris Lattnere19d0b12005-04-19 04:51:30 +0000566def LFDX : XForm_25<31, 599, (ops FPRC:$dst, GPRC:$base, GPRC:$index),
Nate Begemancc8bd9c2004-08-31 02:28:08 +0000567 "lfdx $dst, $base, $index">;
Nate Begemanb816f022004-10-07 22:30:03 +0000568}
Chris Lattner883059f2005-04-19 05:15:18 +0000569def FCFID : XForm_26<63, 846, (ops FPRC:$frD, FPRC:$frB),
Chris Lattnere19d0b12005-04-19 04:51:30 +0000570 "fcfid $frD, $frB">, isPPC64;
Chris Lattner883059f2005-04-19 05:15:18 +0000571def FCTIDZ : XForm_26<63, 815, (ops FPRC:$frD, FPRC:$frB),
Chris Lattnere19d0b12005-04-19 04:51:30 +0000572 "fctidz $frD, $frB">, isPPC64;
Chris Lattner883059f2005-04-19 05:15:18 +0000573def FCTIWZ : XForm_26<63, 15, (ops FPRC:$frD, FPRC:$frB),
Nate Begemand332fd52004-08-29 22:02:43 +0000574 "fctiwz $frD, $frB">;
Chris Lattner883059f2005-04-19 05:15:18 +0000575def FABS : XForm_26<63, 264, (ops FPRC:$frD, FPRC:$frB),
Nate Begeman27eeb002005-04-02 05:59:34 +0000576 "fabs $frD, $frB">;
Chris Lattner883059f2005-04-19 05:15:18 +0000577def FMR : XForm_26<63, 72, (ops FPRC:$frD, FPRC:$frB),
Nate Begemanc3306122004-08-21 05:56:39 +0000578 "fmr $frD, $frB">;
Chris Lattner883059f2005-04-19 05:15:18 +0000579def FNABS : XForm_26<63, 136, (ops FPRC:$frD, FPRC:$frB),
Nate Begeman27eeb002005-04-02 05:59:34 +0000580 "fnabs $frD, $frB">;
Chris Lattner883059f2005-04-19 05:15:18 +0000581def FNEG : XForm_26<63, 40, (ops FPRC:$frD, FPRC:$frB),
Nate Begemanc3306122004-08-21 05:56:39 +0000582 "fneg $frD, $frB">;
Chris Lattner883059f2005-04-19 05:15:18 +0000583def FRSP : XForm_26<63, 12, (ops FPRC:$frD, FPRC:$frB),
Nate Begemanc3306122004-08-21 05:56:39 +0000584 "frsp $frD, $frB">;
Nate Begemanadeb43d2005-07-20 22:42:00 +0000585def FSQRT : XForm_26<63, 22, (ops FPRC:$frD, FPRC:$frB),
586 "fsqrt $frD, $frB">;
587def FSQRTS : XForm_26<59, 22, (ops FPRC:$frD, FPRC:$frB),
588 "fsqrts $frD, $frB">;
589
Nate Begemanb816f022004-10-07 22:30:03 +0000590let isStore = 1 in {
Chris Lattnere19d0b12005-04-19 04:51:30 +0000591def STFSX : XForm_28<31, 663, (ops FPRC:$frS, GPRC:$rA, GPRC:$rB),
Nate Begemanc3306122004-08-21 05:56:39 +0000592 "stfsx $frS, $rA, $rB">;
Chris Lattnere19d0b12005-04-19 04:51:30 +0000593def STFDX : XForm_28<31, 727, (ops FPRC:$frS, GPRC:$rA, GPRC:$rB),
Nate Begemanc3306122004-08-21 05:56:39 +0000594 "stfdx $frS, $rA, $rB">;
Nate Begemanb816f022004-10-07 22:30:03 +0000595}
Nate Begeman6b3dc552004-08-29 22:45:13 +0000596
Nate Begeman07aada82004-08-30 02:28:06 +0000597// XL-Form instructions. condition register logical ops.
598//
Chris Lattnere19d0b12005-04-19 04:51:30 +0000599def MCRF : XLForm_3<19, 0, (ops CRRC:$BF, CRRC:$BFA),
Nate Begeman7bfba7d2005-04-14 09:45:08 +0000600 "mcrf $BF, $BFA">;
Nate Begeman07aada82004-08-30 02:28:06 +0000601
602// XFX-Form instructions. Instructions that deal with SPRs
603//
Misha Brukmanda8d96d2004-10-23 06:05:49 +0000604// Note that although LR should be listed as `8' and CTR as `9' in the SPR
605// field, the manual lists the groups of bits as [5-9] = 0, [0-4] = 8 or 9
606// which means the SPR value needs to be multiplied by a factor of 32.
Chris Lattner5035cef2005-04-19 04:40:07 +0000607def MFCTR : XFXForm_1_ext<31, 339, 288, (ops GPRC:$rT), "mfctr $rT">;
608def MFLR : XFXForm_1_ext<31, 339, 256, (ops GPRC:$rT), "mflr $rT">;
609def MFCR : XFXForm_3<31, 19, (ops GPRC:$rT), "mfcr $rT">;
Chris Lattner28b9cc22005-08-26 22:05:54 +0000610def MTCRF : XFXForm_5<31, 144, (ops crbitm:$FXM, GPRC:$rS),
Nate Begeman7af02482005-04-12 07:04:16 +0000611 "mtcrf $FXM, $rS">;
Nate Begeman394cd132005-08-08 20:04:52 +0000612def MFOCRF : XFXForm_5a<31, 19, (ops GPRC:$rT, crbitm:$FXM),
613 "mfcr $rT, $FXM">;
Chris Lattner5035cef2005-04-19 04:40:07 +0000614def MTCTR : XFXForm_7_ext<31, 467, 288, (ops GPRC:$rS), "mtctr $rS">;
615def MTLR : XFXForm_7_ext<31, 467, 256, (ops GPRC:$rS), "mtlr $rS">;
Nate Begeman07aada82004-08-30 02:28:06 +0000616
Nate Begeman07aada82004-08-30 02:28:06 +0000617// XS-Form instructions. Just 'sradi'
618//
Chris Lattner883059f2005-04-19 05:15:18 +0000619def SRADI : XSForm_1<31, 413, (ops GPRC:$rA, GPRC:$rS, u6imm:$SH),
Chris Lattner5035cef2005-04-19 04:40:07 +0000620 "sradi $rA, $rS, $SH">, isPPC64;
Nate Begeman07aada82004-08-30 02:28:06 +0000621
622// XO-Form instructions. Arithmetic instructions that can set overflow bit
623//
Chris Lattner14522e32005-04-19 05:21:30 +0000624def ADD : XOForm_1<31, 266, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
Chris Lattner218a15d2005-09-02 21:18:00 +0000625 "add $rT, $rA, $rB",
626 [(set GPRC:$rT, (add GPRC:$rA, GPRC:$rB))]>;
Chris Lattner14522e32005-04-19 05:21:30 +0000627def ADDC : XOForm_1<31, 10, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
Chris Lattner218a15d2005-09-02 21:18:00 +0000628 "addc $rT, $rA, $rB",
629 []>;
Chris Lattner14522e32005-04-19 05:21:30 +0000630def ADDE : XOForm_1<31, 138, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
Chris Lattner218a15d2005-09-02 21:18:00 +0000631 "adde $rT, $rA, $rB",
632 []>;
Chris Lattner14522e32005-04-19 05:21:30 +0000633def DIVD : XOForm_1<31, 489, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
Chris Lattner218a15d2005-09-02 21:18:00 +0000634 "divd $rT, $rA, $rB",
635 []>, isPPC64;
Chris Lattner14522e32005-04-19 05:21:30 +0000636def DIVDU : XOForm_1<31, 457, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
Chris Lattner218a15d2005-09-02 21:18:00 +0000637 "divdu $rT, $rA, $rB",
638 []>, isPPC64;
Chris Lattner14522e32005-04-19 05:21:30 +0000639def DIVW : XOForm_1<31, 491, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
Chris Lattner218a15d2005-09-02 21:18:00 +0000640 "divw $rT, $rA, $rB",
641 [(set GPRC:$rT, (sdiv GPRC:$rA, GPRC:$rB))]>;
Chris Lattner14522e32005-04-19 05:21:30 +0000642def DIVWU : XOForm_1<31, 459, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
Chris Lattner218a15d2005-09-02 21:18:00 +0000643 "divwu $rT, $rA, $rB",
644 [(set GPRC:$rT, (udiv GPRC:$rA, GPRC:$rB))]>;
Chris Lattner14522e32005-04-19 05:21:30 +0000645def MULHW : XOForm_1<31, 75, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
Chris Lattner218a15d2005-09-02 21:18:00 +0000646 "mulhw $rT, $rA, $rB",
647 [(set GPRC:$rT, (mulhs GPRC:$rA, GPRC:$rB))]>;
Chris Lattner14522e32005-04-19 05:21:30 +0000648def MULHWU : XOForm_1<31, 11, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
Chris Lattner218a15d2005-09-02 21:18:00 +0000649 "mulhwu $rT, $rA, $rB",
650 [(set GPRC:$rT, (mulhu GPRC:$rA, GPRC:$rB))]>;
Chris Lattner14522e32005-04-19 05:21:30 +0000651def MULLD : XOForm_1<31, 233, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
Chris Lattner218a15d2005-09-02 21:18:00 +0000652 "mulld $rT, $rA, $rB",
653 []>, isPPC64;
Chris Lattner14522e32005-04-19 05:21:30 +0000654def MULLW : XOForm_1<31, 235, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
Chris Lattner218a15d2005-09-02 21:18:00 +0000655 "mullw $rT, $rA, $rB",
656 [(set GPRC:$rT, (mul GPRC:$rA, GPRC:$rB))]>;
Chris Lattner14522e32005-04-19 05:21:30 +0000657def SUBF : XOForm_1<31, 40, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
Chris Lattner218a15d2005-09-02 21:18:00 +0000658 "subf $rT, $rA, $rB",
659 [(set GPRC:$rT, (sub GPRC:$rB, GPRC:$rA))]>;
Chris Lattner14522e32005-04-19 05:21:30 +0000660def SUBFC : XOForm_1<31, 8, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
Chris Lattner218a15d2005-09-02 21:18:00 +0000661 "subfc $rT, $rA, $rB",
662 []>;
Chris Lattner14522e32005-04-19 05:21:30 +0000663def SUBFE : XOForm_1<31, 136, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
Chris Lattner218a15d2005-09-02 21:18:00 +0000664 "subfe $rT, $rA, $rB",
665 []>;
Chris Lattner14522e32005-04-19 05:21:30 +0000666def ADDME : XOForm_3<31, 234, 0, (ops GPRC:$rT, GPRC:$rA),
Chris Lattnerd1cdc702005-09-08 17:01:54 +0000667 "addme $rT, $rA",
668 []>;
Chris Lattner14522e32005-04-19 05:21:30 +0000669def ADDZE : XOForm_3<31, 202, 0, (ops GPRC:$rT, GPRC:$rA),
Chris Lattnerd1cdc702005-09-08 17:01:54 +0000670 "addze $rT, $rA",
671 []>;
Chris Lattner14522e32005-04-19 05:21:30 +0000672def NEG : XOForm_3<31, 104, 0, (ops GPRC:$rT, GPRC:$rA),
Chris Lattnerd1cdc702005-09-08 17:01:54 +0000673 "neg $rT, $rA",
674 [(set GPRC:$rT, (ineg GPRC:$rA))]>;
Chris Lattner14522e32005-04-19 05:21:30 +0000675def SUBFZE : XOForm_3<31, 200, 0, (ops GPRC:$rT, GPRC:$rA),
Chris Lattnerd1cdc702005-09-08 17:01:54 +0000676 "subfze $rT, $rA",
677 []>;
Nate Begeman07aada82004-08-30 02:28:06 +0000678
679// A-Form instructions. Most of the instructions executed in the FPU are of
680// this type.
681//
Chris Lattner14522e32005-04-19 05:21:30 +0000682def FMADD : AForm_1<63, 29,
Nate Begeman07aada82004-08-30 02:28:06 +0000683 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRC, FPRC:$FRB),
684 "fmadd $FRT, $FRA, $FRC, $FRB">;
Chris Lattner14522e32005-04-19 05:21:30 +0000685def FMADDS : AForm_1<59, 29,
Nate Begeman178bb342005-04-04 23:01:51 +0000686 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRC, FPRC:$FRB),
687 "fmadds $FRT, $FRA, $FRC, $FRB">;
Chris Lattner14522e32005-04-19 05:21:30 +0000688def FMSUB : AForm_1<63, 28,
Nate Begeman178bb342005-04-04 23:01:51 +0000689 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRC, FPRC:$FRB),
690 "fmsub $FRT, $FRA, $FRC, $FRB">;
Chris Lattner14522e32005-04-19 05:21:30 +0000691def FMSUBS : AForm_1<59, 28,
Nate Begeman178bb342005-04-04 23:01:51 +0000692 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRC, FPRC:$FRB),
693 "fmsubs $FRT, $FRA, $FRC, $FRB">;
Chris Lattner14522e32005-04-19 05:21:30 +0000694def FNMADD : AForm_1<63, 31,
Nate Begeman178bb342005-04-04 23:01:51 +0000695 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRC, FPRC:$FRB),
696 "fnmadd $FRT, $FRA, $FRC, $FRB">;
Chris Lattner14522e32005-04-19 05:21:30 +0000697def FNMADDS : AForm_1<59, 31,
Nate Begeman178bb342005-04-04 23:01:51 +0000698 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRC, FPRC:$FRB),
699 "fnmadds $FRT, $FRA, $FRC, $FRB">;
Chris Lattner14522e32005-04-19 05:21:30 +0000700def FNMSUB : AForm_1<63, 30,
Nate Begeman178bb342005-04-04 23:01:51 +0000701 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRC, FPRC:$FRB),
702 "fnmsub $FRT, $FRA, $FRC, $FRB">;
Chris Lattner14522e32005-04-19 05:21:30 +0000703def FNMSUBS : AForm_1<59, 30,
Nate Begeman178bb342005-04-04 23:01:51 +0000704 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRC, FPRC:$FRB),
705 "fnmsubs $FRT, $FRA, $FRC, $FRB">;
Chris Lattner14522e32005-04-19 05:21:30 +0000706def FSEL : AForm_1<63, 23,
Nate Begeman07aada82004-08-30 02:28:06 +0000707 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRC, FPRC:$FRB),
708 "fsel $FRT, $FRA, $FRC, $FRB">;
Chris Lattner14522e32005-04-19 05:21:30 +0000709def FADD : AForm_2<63, 21,
Nate Begeman07aada82004-08-30 02:28:06 +0000710 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
711 "fadd $FRT, $FRA, $FRB">;
Chris Lattner14522e32005-04-19 05:21:30 +0000712def FADDS : AForm_2<59, 21,
Nate Begeman07aada82004-08-30 02:28:06 +0000713 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
714 "fadds $FRT, $FRA, $FRB">;
Chris Lattner14522e32005-04-19 05:21:30 +0000715def FDIV : AForm_2<63, 18,
Nate Begeman07aada82004-08-30 02:28:06 +0000716 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
717 "fdiv $FRT, $FRA, $FRB">;
Chris Lattner14522e32005-04-19 05:21:30 +0000718def FDIVS : AForm_2<59, 18,
Nate Begeman07aada82004-08-30 02:28:06 +0000719 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
720 "fdivs $FRT, $FRA, $FRB">;
Chris Lattner14522e32005-04-19 05:21:30 +0000721def FMUL : AForm_3<63, 25,
Nate Begeman07aada82004-08-30 02:28:06 +0000722 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
723 "fmul $FRT, $FRA, $FRB">;
Chris Lattner14522e32005-04-19 05:21:30 +0000724def FMULS : AForm_3<59, 25,
Nate Begeman07aada82004-08-30 02:28:06 +0000725 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
726 "fmuls $FRT, $FRA, $FRB">;
Chris Lattner14522e32005-04-19 05:21:30 +0000727def FSUB : AForm_2<63, 20,
Nate Begeman07aada82004-08-30 02:28:06 +0000728 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
729 "fsub $FRT, $FRA, $FRB">;
Chris Lattner14522e32005-04-19 05:21:30 +0000730def FSUBS : AForm_2<59, 20,
Nate Begeman07aada82004-08-30 02:28:06 +0000731 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
732 "fsubs $FRT, $FRA, $FRB">;
733
Nate Begemancc8bd9c2004-08-31 02:28:08 +0000734// M-Form instructions. rotate and mask instructions.
735//
Chris Lattner043870d2005-09-09 18:17:41 +0000736let isTwoAddress = 1, isCommutable = 1 in {
737// RLWIMI can be commuted if the rotate amount is zero.
Chris Lattner14522e32005-04-19 05:21:30 +0000738def RLWIMI : MForm_2<20,
Nate Begeman2d4c98d2004-10-16 20:43:38 +0000739 (ops GPRC:$rA, GPRC:$rSi, GPRC:$rS, u5imm:$SH, u5imm:$MB,
740 u5imm:$ME), "rlwimi $rA, $rS, $SH, $MB, $ME">;
741}
Chris Lattner14522e32005-04-19 05:21:30 +0000742def RLWINM : MForm_2<21,
Nate Begemancc8bd9c2004-08-31 02:28:08 +0000743 (ops GPRC:$rA, GPRC:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
744 "rlwinm $rA, $rS, $SH, $MB, $ME">;
Chris Lattner14522e32005-04-19 05:21:30 +0000745def RLWINMo : MForm_2<21,
Nate Begeman9f833d32005-04-12 00:10:02 +0000746 (ops GPRC:$rA, GPRC:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
Chris Lattner14522e32005-04-19 05:21:30 +0000747 "rlwinm. $rA, $rS, $SH, $MB, $ME">, isDOT;
748def RLWNM : MForm_2<23,
Nate Begemancd08e4c2005-04-09 20:09:12 +0000749 (ops GPRC:$rA, GPRC:$rS, GPRC:$rB, u5imm:$MB, u5imm:$ME),
750 "rlwnm $rA, $rS, $rB, $MB, $ME">;
Nate Begemancc8bd9c2004-08-31 02:28:08 +0000751
752// MD-Form instructions. 64 bit rotate instructions.
753//
Chris Lattner14522e32005-04-19 05:21:30 +0000754def RLDICL : MDForm_1<30, 0,
Nate Begemancc8bd9c2004-08-31 02:28:08 +0000755 (ops GPRC:$rA, GPRC:$rS, u6imm:$SH, u6imm:$MB),
Chris Lattner0bdc6f12005-04-19 04:32:54 +0000756 "rldicl $rA, $rS, $SH, $MB">, isPPC64;
Chris Lattner14522e32005-04-19 05:21:30 +0000757def RLDICR : MDForm_1<30, 1,
Nate Begemancc8bd9c2004-08-31 02:28:08 +0000758 (ops GPRC:$rA, GPRC:$rS, u6imm:$SH, u6imm:$ME),
Chris Lattner0bdc6f12005-04-19 04:32:54 +0000759 "rldicr $rA, $rS, $SH, $ME">, isPPC64;
Nate Begemancc8bd9c2004-08-31 02:28:08 +0000760
Chris Lattner2eb25172005-09-09 00:39:56 +0000761//===----------------------------------------------------------------------===//
762// PowerPC Instruction Patterns
763//
764
Chris Lattner30e21a42005-09-26 22:20:16 +0000765// Arbitrary immediate support. Implement in terms of LIS/ORI.
766def : Pat<(i32 imm:$imm),
767 (ORI (LIS (HI16 imm:$imm)), (LO16 imm:$imm))>;
Chris Lattner91da8622005-09-28 17:13:15 +0000768
Chris Lattnercfc828a2005-09-28 18:10:51 +0000769
Chris Lattner91da8622005-09-28 17:13:15 +0000770// Implement the 'not' operation with the NOR instruction.
771def NOT : Pat<(not GPRC:$in),
772 (NOR GPRC:$in, GPRC:$in)>;
773
Chris Lattnercfc828a2005-09-28 18:10:51 +0000774// EQV patterns
775def EQV1 : Pat<(xor (not GPRC:$in1), GPRC:$in2),
776 (EQV GPRC:$in1, GPRC:$in2)>;
777// FIXME: This should be autogenerated from the above due to xor commutativity.
778def EQV2 : Pat<(xor GPRC:$in1, (not GPRC:$in2)),
779 (EQV GPRC:$in1, GPRC:$in2)>;
780
Chris Lattner2eb25172005-09-09 00:39:56 +0000781// or by an arbitrary immediate.
782def : Pat<(or GPRC:$in, imm:$imm),
783 (ORIS (ORI GPRC:$in, (LO16 imm:$imm)), (HI16 imm:$imm))>;
784// xor by an arbitrary immediate.
785def : Pat<(xor GPRC:$in, imm:$imm),
786 (XORIS (XORI GPRC:$in, (LO16 imm:$imm)), (HI16 imm:$imm))>;
787
Chris Lattnerea874f32005-09-24 00:41:58 +0000788
Chris Lattnercfc828a2005-09-28 18:10:51 +0000789
Chris Lattnerea874f32005-09-24 00:41:58 +0000790// Same as above, but using a temporary. FIXME: implement temporaries :)
Chris Lattner4ac85b32005-09-15 21:44:00 +0000791/*
Chris Lattnerc36d0652005-09-14 18:18:39 +0000792def : Pattern<(xor GPRC:$in, imm:$imm),
793 [(set GPRC:$tmp, (XORI GPRC:$in, (LO16 imm:$imm))),
794 (XORIS GPRC:$tmp, (HI16 imm:$imm))]>;
Chris Lattner4ac85b32005-09-15 21:44:00 +0000795*/
Chris Lattnerc36d0652005-09-14 18:18:39 +0000796
797
Chris Lattner2eb25172005-09-09 00:39:56 +0000798//===----------------------------------------------------------------------===//
799// PowerPCInstrInfo Definition
800//
Chris Lattnerbe686a82004-12-16 16:31:57 +0000801def PowerPCInstrInfo : InstrInfo {
802 let PHIInst = PHI;
803
804 let TSFlagsFields = [ "VMX", "PPC64" ];
805 let TSFlagsShifts = [ 0, 1 ];
806
807 let isLittleEndianEncoding = 1;
808}
Chris Lattner2eb25172005-09-09 00:39:56 +0000809