blob: 4c6b5dc730941d79fa84013765b7e93b0be4914c [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
Misha Brukman145a5a32004-11-15 21:20:09 +000017let isTerminator = 1 in {
18 let isReturn = 1 in
19 def BLR : XLForm_2_ext<19, 16, 20, 31, 1, 0, 0, (ops), "blr">;
20 def BCTR : XLForm_2_ext<19, 528, 20, 31, 1, 0, 0, (ops), "bctr">;
21}
Chris Lattner7bb424f2004-08-14 23:27:29 +000022
Nate Begemanc3306122004-08-21 05:56:39 +000023def u5imm : Operand<i8> {
24 let PrintMethod = "printU5ImmOperand";
25}
Nate Begeman07aada82004-08-30 02:28:06 +000026def u6imm : Operand<i8> {
27 let PrintMethod = "printU6ImmOperand";
28}
Nate Begemaned428532004-09-04 05:00:00 +000029def s16imm : Operand<i16> {
30 let PrintMethod = "printS16ImmOperand";
31}
Chris Lattner97b2a2e2004-08-15 05:20:16 +000032def u16imm : Operand<i16> {
33 let PrintMethod = "printU16ImmOperand";
34}
Nate Begemanb7a8f2c2004-09-02 08:13:00 +000035def target : Operand<i32> {
36 let PrintMethod = "printBranchOperand";
37}
38def piclabel: Operand<i32> {
39 let PrintMethod = "printPICLabel";
40}
Nate Begemaned428532004-09-04 05:00:00 +000041def symbolHi: Operand<i32> {
42 let PrintMethod = "printSymbolHi";
43}
44def symbolLo: Operand<i32> {
45 let PrintMethod = "printSymbolLo";
46}
Chris Lattner97b2a2e2004-08-15 05:20:16 +000047
Misha Brukman5dfe3a92004-06-21 16:55:25 +000048// Pseudo-instructions:
Nate Begemanb7a8f2c2004-09-02 08:13:00 +000049def PHI : Pseudo<(ops), "; PHI">;
Nate Begemanb816f022004-10-07 22:30:03 +000050let isLoad = 1 in {
Nate Begemanb7a8f2c2004-09-02 08:13:00 +000051def ADJCALLSTACKDOWN : Pseudo<(ops), "; ADJCALLSTACKDOWN">;
52def ADJCALLSTACKUP : Pseudo<(ops), "; ADJCALLSTACKUP">;
Nate Begemanb816f022004-10-07 22:30:03 +000053}
Nate Begemanb7a8f2c2004-09-02 08:13:00 +000054def IMPLICIT_DEF : Pseudo<(ops), "; IMPLICIT_DEF">;
55def MovePCtoLR : Pseudo<(ops piclabel:$label), "bl $label">;
Misha Brukman5dfe3a92004-06-21 16:55:25 +000056
Misha Brukmanb2edb442004-06-28 18:23:35 +000057let isBranch = 1, isTerminator = 1 in {
Nate Begemanb7a8f2c2004-09-02 08:13:00 +000058 def COND_BRANCH : Pseudo<(ops), "; COND_BRANCH">;
Misha Brukman40a55e12004-10-23 20:29:24 +000059 def B : IForm<18, 0, 0, 0, 0, (ops target:$func), "b $func">;
Chris Lattnerdd998852004-11-22 23:07:01 +000060//def BA : IForm<18, 1, 0, 0, 0, (ops target:$func), "ba $func">;
Misha Brukman40a55e12004-10-23 20:29:24 +000061 def BL : IForm<18, 0, 1, 0, 0, (ops target:$func), "bl $func">;
Chris Lattnerdd998852004-11-22 23:07:01 +000062//def BLA : IForm<18, 1, 1, 0, 0, (ops target:$func), "bla $func">;
63
Misha Brukman4ad7d1b2004-08-09 17:24:04 +000064 // FIXME: 4*CR# needs to be added to the BI field!
65 // This will only work for CR0 as it stands now
Nate Begemaned428532004-09-04 05:00:00 +000066 def BLT : BForm_ext<16, 0, 0, 12, 0, 0, 0, (ops CRRC:$crS, target:$block),
67 "blt $block">;
68 def BLE : BForm_ext<16, 0, 0, 4, 1, 0, 0, (ops CRRC:$crS, target:$block),
69 "ble $block">;
70 def BEQ : BForm_ext<16, 0, 0, 12, 2, 0, 0, (ops CRRC:$crS, target:$block),
71 "beq $block">;
72 def BGE : BForm_ext<16, 0, 0, 4, 0, 0, 0, (ops CRRC:$crS, target:$block),
73 "bge $block">;
74 def BGT : BForm_ext<16, 0, 0, 12, 1, 0, 0, (ops CRRC:$crS, target:$block),
75 "bgt $block">;
76 def BNE : BForm_ext<16, 0, 0, 4, 2, 0, 0, (ops CRRC:$crS, target:$block),
77 "bne $block">;
Misha Brukmanb2edb442004-06-28 18:23:35 +000078}
79
Misha Brukman5fa2b022004-06-29 23:37:36 +000080let isBranch = 1, isTerminator = 1, isCall = 1,
81 // All calls clobber the non-callee saved registers...
Misha Brukmanc661c302004-06-30 22:00:45 +000082 Defs = [R0,R2,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,
83 F0,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,
84 LR,XER,CTR,
85 CR0,CR1,CR5,CR6,CR7] in {
86 // Convenient aliases for call instructions
Nate Begemanb7a8f2c2004-09-02 08:13:00 +000087 def CALLpcrel : IForm<18, 0, 1, 0, 0, (ops target:$func), "bl $func">;
88 def CALLindirect : XLForm_2_ext<19, 528, 20, 31, 1, 0, 0, (ops), "bctrl">;
Misha Brukman5fa2b022004-06-29 23:37:36 +000089}
90
Nate Begeman07aada82004-08-30 02:28:06 +000091// D-Form instructions. Most instructions that perform an operation on a
92// register and an immediate are of this type.
93//
Nate Begemanb816f022004-10-07 22:30:03 +000094let isLoad = 1 in {
Nate Begemaned428532004-09-04 05:00:00 +000095def LBZ : DForm_1<35, 0, 0, (ops GPRC:$rD, s16imm:$disp, GPRC:$rA),
96 "lbz $rD, $disp($rA)">;
97def LHA : DForm_1<42, 0, 0, (ops GPRC:$rD, s16imm:$disp, GPRC:$rA),
98 "lha $rD, $disp($rA)">;
99def LHZ : DForm_1<40, 0, 0, (ops GPRC:$rD, s16imm:$disp, GPRC:$rA),
100 "lhz $rD, $disp($rA)">;
101def LMW : DForm_1<46, 0, 0, (ops GPRC:$rD, s16imm:$disp, GPRC:$rA),
102 "lmw $rD, $disp($rA)">;
103def LWZ : DForm_1<32, 0, 0, (ops GPRC:$rD, symbolLo:$disp, GPRC:$rA),
104 "lwz $rD, $disp($rA)">;
Misha Brukman145a5a32004-11-15 21:20:09 +0000105def LWZU : DForm_1<33, 0, 0, (ops GPRC:$rD, symbolLo:$disp, GPRC:$rA),
106 "lwzu $rD, $disp($rA)">;
Nate Begemanb816f022004-10-07 22:30:03 +0000107}
Nate Begemaned428532004-09-04 05:00:00 +0000108def ADDI : DForm_2<14, 0, 0, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
109 "addi $rD, $rA, $imm">;
110def ADDIC : DForm_2<12, 0, 0, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
111 "addic $rD, $rA, $imm">;
112def ADDICo : DForm_2<13, 0, 0, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
113 "addic. $rD, $rA, $imm">;
114def ADDIS : DForm_2<15, 0, 0, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
115 "addis $rD, $rA, $imm">;
116def LA : DForm_2<14, 0, 0, (ops GPRC:$rD, symbolLo:$sym, GPRC:$rA),
117 "la $rD, $sym($rA)">;
118def LOADHiAddr : DForm_2<15, 0, 0, (ops GPRC:$rD, GPRC:$rA, symbolHi:$sym),
119 "addis $rD, $rA, $sym">;
120def MULLI : DForm_2< 7, 0, 0, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
121 "mulli $rD, $rA, $imm">;
122def SUBFIC : DForm_2< 8, 0, 0, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
123 "subfic $rD, $rA, $imm">;
Nate Begemaned428532004-09-04 05:00:00 +0000124def LI : DForm_2_r0<14, 0, 0, (ops GPRC:$rD, s16imm:$imm),
125 "li $rD, $imm">;
126def LIS : DForm_2_r0<15, 0, 0, (ops GPRC:$rD, s16imm:$imm),
127 "lis $rD, $imm">;
Nate Begemanb816f022004-10-07 22:30:03 +0000128let isStore = 1 in {
Nate Begemaned428532004-09-04 05:00:00 +0000129def STMW : DForm_3<47, 0, 0, (ops GPRC:$rS, s16imm:$disp, GPRC:$rA),
130 "stmw $rS, $disp($rA)">;
131def STB : DForm_3<38, 0, 0, (ops GPRC:$rS, s16imm:$disp, GPRC:$rA),
132 "stb $rS, $disp($rA)">;
133def STBU : DForm_3<39, 0, 0, (ops GPRC:$rS, s16imm:$disp, GPRC:$rA),
134 "stbu $rS, $disp($rA)">;
135def STH : DForm_3<44, 0, 0, (ops GPRC:$rS, s16imm:$disp, GPRC:$rA),
136 "sth $rS, $disp($rA)">;
137def STHU : DForm_3<45, 0, 0, (ops GPRC:$rS, s16imm:$disp, GPRC:$rA),
138 "sthu $rS, $disp($rA)">;
139def STW : DForm_3<36, 0, 0, (ops GPRC:$rS, s16imm:$disp, GPRC:$rA),
140 "stw $rS, $disp($rA)">;
141def STWU : DForm_3<37, 0, 0, (ops GPRC:$rS, s16imm:$disp, GPRC:$rA),
142 "stwu $rS, $disp($rA)">;
Nate Begemanb816f022004-10-07 22:30:03 +0000143}
Nate Begeman6b3dc552004-08-29 22:45:13 +0000144def ANDIo : DForm_4<28, 0, 0,
Nate Begeman07aada82004-08-30 02:28:06 +0000145 (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
146 "andi. $dst, $src1, $src2">;
Nate Begemanb816f022004-10-07 22:30:03 +0000147def ANDISo : DForm_4<29, 0, 0,
148 (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
149 "andis. $dst, $src1, $src2">;
Nate Begeman07aada82004-08-30 02:28:06 +0000150def ORI : DForm_4<24, 0, 0,
151 (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
152 "ori $dst, $src1, $src2">;
153def ORIS : DForm_4<25, 0, 0,
154 (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
155 "oris $dst, $src1, $src2">;
Chris Lattner97b2a2e2004-08-15 05:20:16 +0000156def XORI : DForm_4<26, 0, 0,
Nate Begeman07aada82004-08-30 02:28:06 +0000157 (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
158 "xori $dst, $src1, $src2">;
Chris Lattner97b2a2e2004-08-15 05:20:16 +0000159def XORIS : DForm_4<27, 0, 0,
Nate Begeman07aada82004-08-30 02:28:06 +0000160 (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
161 "xoris $dst, $src1, $src2">;
Nate Begemaned428532004-09-04 05:00:00 +0000162def NOP : DForm_4_zero<24, 0, 0, (ops), "nop">;
163def CMPI : DForm_5<11, 0, 0, (ops CRRC:$crD, i1imm:$L, GPRC:$rA, s16imm:$imm),
164 "cmpi $crD, $L, $rA, $imm">;
165def CMPWI : DForm_5_ext<11, 0, 0, (ops CRRC:$crD, GPRC:$rA, s16imm:$imm),
166 "cmpwi $crD, $rA, $imm">;
167def CMPDI : DForm_5_ext<11, 1, 0, (ops CRRC:$crD, GPRC:$rA, s16imm:$imm),
168 "cmpdi $crD, $rA, $imm">;
Nate Begeman07aada82004-08-30 02:28:06 +0000169def CMPLI : DForm_6<10, 0, 0,
Nate Begemaned428532004-09-04 05:00:00 +0000170 (ops CRRC:$dst, i1imm:$size, GPRC:$src1, u16imm:$src2),
171 "cmpli $dst, $size, $src1, $src2">;
Nate Begeman6b3dc552004-08-29 22:45:13 +0000172def CMPLWI : DForm_6_ext<10, 0, 0,
173 (ops CRRC:$dst, GPRC:$src1, u16imm:$src2),
174 "cmplwi $dst, $src1, $src2">;
175def CMPLDI : DForm_6_ext<10, 1, 0,
176 (ops CRRC:$dst, GPRC:$src1, u16imm:$src2),
177 "cmpldi $dst, $src1, $src2">;
Nate Begemanb816f022004-10-07 22:30:03 +0000178let isLoad = 1 in {
Nate Begemaned428532004-09-04 05:00:00 +0000179def LFS : DForm_8<48, 0, 0, (ops GPRC:$rD, symbolLo:$disp, GPRC:$rA),
180 "lfs $rD, $disp($rA)">;
181def LFD : DForm_8<50, 0, 0, (ops GPRC:$rD, symbolLo:$disp, GPRC:$rA),
182 "lfd $rD, $disp($rA)">;
Nate Begemanb816f022004-10-07 22:30:03 +0000183}
184let isStore = 1 in {
Nate Begemaned428532004-09-04 05:00:00 +0000185def STFS : DForm_9<52, 0, 0, (ops GPRC:$rS, s16imm:$disp, GPRC:$rA),
186 "stfs $rS, $disp($rA)">;
187def STFD : DForm_9<54, 0, 0, (ops GPRC:$rS, s16imm:$disp, GPRC:$rA),
188 "stfd $rS, $disp($rA)">;
Nate Begemanb816f022004-10-07 22:30:03 +0000189}
Nate Begemaned428532004-09-04 05:00:00 +0000190
191// DS-Form instructions. Load/Store instructions available in PPC-64
192//
Nate Begemanb816f022004-10-07 22:30:03 +0000193let isLoad = 1 in {
Nate Begemaned428532004-09-04 05:00:00 +0000194def LWA : DSForm_1<58, 2, 1, 0, (ops GPRC:$rT, s16imm:$DS, GPRC:$rA),
195 "lwa $rT, $DS($rA)">;
196def LD : DSForm_2<58, 0, 1, 0, (ops GPRC:$rT, s16imm:$DS, GPRC:$rA),
197 "ld $rT, $DS($rA)">;
Nate Begemanb816f022004-10-07 22:30:03 +0000198}
199let isStore = 1 in {
Nate Begemaned428532004-09-04 05:00:00 +0000200def STD : DSForm_2<62, 0, 1, 0, (ops GPRC:$rT, s16imm:$DS, GPRC:$rA),
201 "std $rT, $DS($rA)">;
202def STDU : DSForm_2<62, 1, 1, 0, (ops GPRC:$rT, s16imm:$DS, GPRC:$rA),
203 "stdu $rT, $DS($rA)">;
Nate Begemanb816f022004-10-07 22:30:03 +0000204}
Nate Begemanc3306122004-08-21 05:56:39 +0000205
Nate Begeman07aada82004-08-30 02:28:06 +0000206// X-Form instructions. Most instructions that perform an operation on a
207// register and another register are of this type.
208//
Nate Begemanb816f022004-10-07 22:30:03 +0000209let isLoad = 1 in {
Nate Begemanc3306122004-08-21 05:56:39 +0000210def LBZX : XForm_1<31, 87, 0, 0, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
211 "lbzx $dst, $base, $index">;
212def LHAX : XForm_1<31, 343, 0, 0, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
213 "lhax $dst, $base, $index">;
214def LHZX : XForm_1<31, 279, 0, 0, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
215 "lhzx $dst, $base, $index">;
216def LWAX : XForm_1<31, 341, 1, 0, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
217 "lwax $dst, $base, $index">;
218def LWZX : XForm_1<31, 23, 0, 0, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
219 "lwzx $dst, $base, $index">;
220def LDX : XForm_1<31, 21, 1, 0, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
221 "ldx $dst, $base, $index">;
Nate Begemanb816f022004-10-07 22:30:03 +0000222}
Nate Begemanc3306122004-08-21 05:56:39 +0000223def MFCR : XForm_5<31, 19, 0, 0, (ops GPRC:$dst), "mfcr $dst">;
224def AND : XForm_6<31, 28, 0, 0, 0, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
225 "and $rA, $rS, $rB">;
226def ANDC : XForm_6<31, 60, 0, 0, 0, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
227 "andc $rA, $rS, $rB">;
228def EQV : XForm_6<31, 284, 0, 0, 0, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
229 "eqv $rA, $rS, $rB">;
230def NAND : XForm_6<31, 476, 0, 0, 0, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
231 "nand $rA, $rS, $rB">;
232def NOR : XForm_6<31, 124, 0, 0, 0, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
233 "nor $rA, $rS, $rB">;
234def OR : XForm_6<31, 444, 0, 0, 0, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
235 "or $rA, $rS, $rB">;
236def ORo : XForm_6<31, 444, 1, 0, 0, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
237 "or. $rA, $rS, $rB">;
238def ORC : XForm_6<31, 412, 0, 0, 0, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
239 "orc $rA, $rS, $rB">;
240def SLD : XForm_6<31, 27, 0, 1, 0, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
241 "sld $rA, $rS, $rB">;
242def SLW : XForm_6<31, 24, 0, 0, 0, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
243 "slw $rA, $rS, $rB">;
244def SRD : XForm_6<31, 539, 0, 1, 0, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
245 "srd $rA, $rS, $rB">;
246def SRW : XForm_6<31, 536, 0, 0, 0, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
247 "srw $rA, $rS, $rB">;
248def SRAD : XForm_6<31, 794, 0, 1, 0, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
249 "srad $rA, $rS, $rB">;
250def SRAW : XForm_6<31, 792, 0, 0, 0, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
251 "sraw $rA, $rS, $rB">;
252def XOR : XForm_6<31, 316, 0, 0, 0, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
253 "xor $rA, $rS, $rB">;
Nate Begemanb816f022004-10-07 22:30:03 +0000254let isStore = 1 in {
Nate Begemanc3306122004-08-21 05:56:39 +0000255def STBX : XForm_8<31, 215, 0, 0, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
256 "stbx $rS, $rA, $rB">;
257def STHX : XForm_8<31, 407, 0, 0, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
258 "sthx $rS, $rA, $rB">;
259def STWX : XForm_8<31, 151, 0, 0, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
260 "stwx $rS, $rA, $rB">;
261def STWUX : XForm_8<31, 183, 0, 0, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
262 "stwux $rS, $rA, $rB">;
263def STDX : XForm_8<31, 149, 1, 0, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
264 "stdx $rS, $rA, $rB">;
265def STDUX : XForm_8<31, 181, 1, 0, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
266 "stdux $rS, $rA, $rB">;
Nate Begemanb816f022004-10-07 22:30:03 +0000267}
Nate Begemanc3306122004-08-21 05:56:39 +0000268def SRAWI : XForm_10<31, 824, 0, 0, 0, (ops GPRC:$rA, GPRC:$rS, u5imm:$SH),
269 "srawi $rA, $rS, $SH">;
270def CNTLZW : XForm_11<31, 26, 0, 0, 0, (ops GPRC:$rA, GPRC:$rS),
271 "cntlzw $rA, $rS">;
272def EXTSB : XForm_11<31, 954, 0, 0, 0, (ops GPRC:$rA, GPRC:$rS),
273 "extsb $rA, $rS">;
274def EXTSH : XForm_11<31, 922, 0, 0, 0, (ops GPRC:$rA, GPRC:$rS),
275 "extsh $rA, $rS">;
Nate Begemand332fd52004-08-29 22:02:43 +0000276def EXTSW : XForm_11<31, 986, 0, 1, 0, (ops GPRC:$rA, GPRC:$rS),
277 "extsw $rA, $rS">;
Nate Begemanb7a8f2c2004-09-02 08:13:00 +0000278def CMP : XForm_16<31, 0, 0, 0,
279 (ops CRRC:$crD, i1imm:$long, GPRC:$rA, GPRC:$rB),
280 "cmp $crD, $long, $rA, $rB">;
281def CMPL : XForm_16<31, 32, 0, 0,
282 (ops CRRC:$crD, i1imm:$long, GPRC:$rA, GPRC:$rB),
283 "cmpl $crD, $long, $rA, $rB">;
284def CMPW : XForm_16_ext<31, 0, 0, 0,
285 (ops CRRC:$crD, GPRC:$rA, GPRC:$rB),
286 "cmpw $crD, $rA, $rB">;
287def CMPD : XForm_16_ext<31, 0, 1, 0,
288 (ops CRRC:$crD, GPRC:$rA, GPRC:$rB),
289 "cmpd $crD, $rA, $rB">;
290def CMPLW : XForm_16_ext<31, 32, 0, 0,
291 (ops CRRC:$crD, GPRC:$rA, GPRC:$rB),
292 "cmplw $crD, $rA, $rB">;
293def CMPLD : XForm_16_ext<31, 32, 1, 0,
294 (ops CRRC:$crD, GPRC:$rA, GPRC:$rB),
295 "cmpld $crD, $rA, $rB">;
Nate Begemancc8bd9c2004-08-31 02:28:08 +0000296def FCMPU : XForm_17<63, 0, 0, 0, (ops CRRC:$crD, FPRC:$fA, FPRC:$fB),
297 "fcmpu $crD, $fA, $fB">;
Nate Begemanb816f022004-10-07 22:30:03 +0000298let isLoad = 1 in {
Nate Begemancc8bd9c2004-08-31 02:28:08 +0000299def LFSX : XForm_25<31, 535, 0, 0, (ops FPRC:$dst, GPRC:$base, GPRC:$index),
300 "lfsx $dst, $base, $index">;
301def LFDX : XForm_25<31, 599, 0, 0, (ops FPRC:$dst, GPRC:$base, GPRC:$index),
302 "lfdx $dst, $base, $index">;
Nate Begemanb816f022004-10-07 22:30:03 +0000303}
Nate Begemand332fd52004-08-29 22:02:43 +0000304def FCFID : XForm_26<63, 846, 0, 1, 0, (ops FPRC:$frD, FPRC:$frB),
305 "fcfid $frD, $frB">;
306def FCTIDZ : XForm_26<63, 815, 0, 1, 0, (ops FPRC:$frD, FPRC:$frB),
307 "fctidz $frD, $frB">;
308def FCTIWZ : XForm_26<63, 15, 0, 0, 0, (ops FPRC:$frD, FPRC:$frB),
309 "fctiwz $frD, $frB">;
Nate Begemanc3306122004-08-21 05:56:39 +0000310def FMR : XForm_26<63, 72, 0, 0, 0, (ops FPRC:$frD, FPRC:$frB),
311 "fmr $frD, $frB">;
312def FNEG : XForm_26<63, 80, 0, 0, 0, (ops FPRC:$frD, FPRC:$frB),
313 "fneg $frD, $frB">;
314def FRSP : XForm_26<63, 12, 0, 0, 0, (ops FPRC:$frD, FPRC:$frB),
315 "frsp $frD, $frB">;
Nate Begemanb816f022004-10-07 22:30:03 +0000316let isStore = 1 in {
Nate Begemanc3306122004-08-21 05:56:39 +0000317def STFSX : XForm_28<31, 663, 0, 0, (ops FPRC:$frS, GPRC:$rA, GPRC:$rB),
318 "stfsx $frS, $rA, $rB">;
319def STFDX : XForm_28<31, 727, 0, 0, (ops FPRC:$frS, GPRC:$rA, GPRC:$rB),
320 "stfdx $frS, $rA, $rB">;
Nate Begemanb816f022004-10-07 22:30:03 +0000321}
Nate Begeman6b3dc552004-08-29 22:45:13 +0000322
Nate Begeman07aada82004-08-30 02:28:06 +0000323// XL-Form instructions. condition register logical ops.
324//
Nate Begemanc3306122004-08-21 05:56:39 +0000325def CRAND : XLForm_1<19, 257, 0, 0, (ops u5imm:$D, u5imm:$A, u5imm:$B),
326 "crand $D, $A, $B">;
327def CRANDC : XLForm_1<19, 129, 0, 0, (ops u5imm:$D, u5imm:$A, u5imm:$B),
328 "crandc $D, $A, $B">;
329def CRNOR : XLForm_1<19, 33, 0, 0, (ops u5imm:$D, u5imm:$A, u5imm:$B),
330 "crnor $D, $A, $B">;
331def CROR : XLForm_1<19, 449, 0, 0, (ops u5imm:$D, u5imm:$A, u5imm:$B),
332 "cror $D, $A, $B">;
Nate Begeman07aada82004-08-30 02:28:06 +0000333
334// XFX-Form instructions. Instructions that deal with SPRs
335//
Misha Brukmanda8d96d2004-10-23 06:05:49 +0000336// Note that although LR should be listed as `8' and CTR as `9' in the SPR
337// field, the manual lists the groups of bits as [5-9] = 0, [0-4] = 8 or 9
338// which means the SPR value needs to be multiplied by a factor of 32.
339def MFCTR : XFXForm_1_ext<31, 339, 288, 0, 0, (ops GPRC:$rT), "mfctr $rT">;
340def MFLR : XFXForm_1_ext<31, 339, 256, 0, 0, (ops GPRC:$rT), "mflr $rT">;
341def MTCTR : XFXForm_7_ext<31, 467, 288, 0, 0, (ops GPRC:$rS), "mtctr $rS">;
342def MTLR : XFXForm_7_ext<31, 467, 256, 0, 0, (ops GPRC:$rS), "mtlr $rS">;
Nate Begeman07aada82004-08-30 02:28:06 +0000343
344
345// XS-Form instructions. Just 'sradi'
346//
347def SRADI : XSForm_1<31, 413, 0, 1, 0, (ops GPRC:$rA, GPRC:$rS, u6imm:$SH),
348 "sradi $rA, $rS, $SH">;
349
350// XO-Form instructions. Arithmetic instructions that can set overflow bit
351//
352def ADD : XOForm_1<31, 266, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
353 "add $rT, $rA, $rB">;
354def ADDC : XOForm_1<31, 10, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
355 "addc $rT, $rA, $rB">;
356def ADDE : XOForm_1<31, 138, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
357 "adde $rT, $rA, $rB">;
Nate Begeman20136a22004-09-06 18:46:59 +0000358def DIVD : XOForm_1<31, 489, 0, 0, 1, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
359 "divd $rT, $rA, $rB">;
360def DIVDU : XOForm_1<31, 457, 0, 0, 1, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
361 "divdu $rT, $rA, $rB">;
Nate Begeman07aada82004-08-30 02:28:06 +0000362def DIVW : XOForm_1<31, 491, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
363 "divw $rT, $rA, $rB">;
364def DIVWU : XOForm_1<31, 459, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
365 "divwu $rT, $rA, $rB">;
366def MULHWU : XOForm_1<31, 11, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
367 "mulhwu $rT, $rA, $rB">;
368def MULLD : XOForm_1<31, 233, 0, 0, 1, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
369 "mulld $rT, $rA, $rB">;
370def MULLW : XOForm_1<31, 235, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
371 "mullw $rT, $rA, $rB">;
372def SUBF : XOForm_1<31, 40, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
373 "subf $rT, $rA, $rB">;
374def SUBFC : XOForm_1<31, 8, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
375 "subfc $rT, $rA, $rB">;
376def SUBFE : XOForm_1<31, 136, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
377 "subfe $rT, $rA, $rB">;
378def SUB : XOForm_1r<31, 40, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
379 "sub $rT, $rA, $rB">;
380def SUBC : XOForm_1r<31, 8, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
381 "subc $rT, $rA, $rB">;
Nate Begemana2de1022004-09-22 04:40:25 +0000382def ADDME : XOForm_3<31, 234, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA),
383 "addme $rT, $rA">;
Nate Begeman07aada82004-08-30 02:28:06 +0000384def ADDZE : XOForm_3<31, 202, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA),
385 "addze $rT, $rA">;
386def NEG : XOForm_3<31, 104, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA),
387 "neg $rT, $rA">;
388def SUBFZE : XOForm_3<31, 200, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA),
389 "subfze $rT, $rA">;
390
391// A-Form instructions. Most of the instructions executed in the FPU are of
392// this type.
393//
394def FMADD : AForm_1<63, 29, 0, 0, 0,
395 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRC, FPRC:$FRB),
396 "fmadd $FRT, $FRA, $FRC, $FRB">;
397def FSEL : AForm_1<63, 23, 0, 0, 0,
398 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRC, FPRC:$FRB),
399 "fsel $FRT, $FRA, $FRC, $FRB">;
400def FADD : AForm_2<63, 21, 0, 0, 0,
401 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
402 "fadd $FRT, $FRA, $FRB">;
403def FADDS : AForm_2<59, 21, 0, 0, 0,
404 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
405 "fadds $FRT, $FRA, $FRB">;
406def FDIV : AForm_2<63, 18, 0, 0, 0,
407 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
408 "fdiv $FRT, $FRA, $FRB">;
409def FDIVS : AForm_2<59, 18, 0, 0, 0,
410 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
411 "fdivs $FRT, $FRA, $FRB">;
412def FMUL : AForm_3<63, 25, 0, 0, 0,
413 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
414 "fmul $FRT, $FRA, $FRB">;
415def FMULS : AForm_3<59, 25, 0, 0, 0,
416 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
417 "fmuls $FRT, $FRA, $FRB">;
418def FSUB : AForm_2<63, 20, 0, 0, 0,
419 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
420 "fsub $FRT, $FRA, $FRB">;
421def FSUBS : AForm_2<59, 20, 0, 0, 0,
422 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
423 "fsubs $FRT, $FRA, $FRB">;
424
Nate Begemancc8bd9c2004-08-31 02:28:08 +0000425// M-Form instructions. rotate and mask instructions.
426//
Nate Begeman2d4c98d2004-10-16 20:43:38 +0000427let isTwoAddress = 1 in {
Nate Begemancc8bd9c2004-08-31 02:28:08 +0000428def RLWIMI : MForm_2<20, 0, 0, 0,
Nate Begeman2d4c98d2004-10-16 20:43:38 +0000429 (ops GPRC:$rA, GPRC:$rSi, GPRC:$rS, u5imm:$SH, u5imm:$MB,
430 u5imm:$ME), "rlwimi $rA, $rS, $SH, $MB, $ME">;
431}
Nate Begemancc8bd9c2004-08-31 02:28:08 +0000432def RLWINM : MForm_2<21, 0, 0, 0,
433 (ops GPRC:$rA, GPRC:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
434 "rlwinm $rA, $rS, $SH, $MB, $ME">;
435
436
437// MD-Form instructions. 64 bit rotate instructions.
438//
439def RLDICL : MDForm_1<30, 0, 0, 1, 0,
440 (ops GPRC:$rA, GPRC:$rS, u6imm:$SH, u6imm:$MB),
441 "rldicl $rA, $rS, $SH, $MB">;
442def RLDICR : MDForm_1<30, 1, 0, 1, 0,
443 (ops GPRC:$rA, GPRC:$rS, u6imm:$SH, u6imm:$ME),
444 "rldicr $rA, $rS, $SH, $ME">;
445
446