blob: 69cc55fc796d3f7af2b49469c7412225e831ad2d [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 Brukman5dfe3a92004-06-21 16:55:25 +000017let isTerminator = 1, isReturn = 1 in
Nate Begemanb7a8f2c2004-09-02 08:13:00 +000018 def BLR : XLForm_2_ext<19, 16, 20, 31, 1, 0, 0, (ops), "blr">;
Chris Lattner7bb424f2004-08-14 23:27:29 +000019
Nate Begemanc3306122004-08-21 05:56:39 +000020def u5imm : Operand<i8> {
21 let PrintMethod = "printU5ImmOperand";
22}
Nate Begeman07aada82004-08-30 02:28:06 +000023def u6imm : Operand<i8> {
24 let PrintMethod = "printU6ImmOperand";
25}
Nate Begemaned428532004-09-04 05:00:00 +000026def s16imm : Operand<i16> {
27 let PrintMethod = "printS16ImmOperand";
28}
Chris Lattner97b2a2e2004-08-15 05:20:16 +000029def u16imm : Operand<i16> {
30 let PrintMethod = "printU16ImmOperand";
31}
Nate Begemanb7a8f2c2004-09-02 08:13:00 +000032def target : Operand<i32> {
33 let PrintMethod = "printBranchOperand";
34}
35def piclabel: Operand<i32> {
36 let PrintMethod = "printPICLabel";
37}
Nate Begemaned428532004-09-04 05:00:00 +000038def symbolHi: Operand<i32> {
39 let PrintMethod = "printSymbolHi";
40}
41def symbolLo: Operand<i32> {
42 let PrintMethod = "printSymbolLo";
43}
Chris Lattner97b2a2e2004-08-15 05:20:16 +000044
Misha Brukman5dfe3a92004-06-21 16:55:25 +000045// Pseudo-instructions:
Nate Begemanb7a8f2c2004-09-02 08:13:00 +000046def PHI : Pseudo<(ops), "; PHI">;
Nate Begemanb816f022004-10-07 22:30:03 +000047let isLoad = 1 in {
Nate Begemanb7a8f2c2004-09-02 08:13:00 +000048def ADJCALLSTACKDOWN : Pseudo<(ops), "; ADJCALLSTACKDOWN">;
49def ADJCALLSTACKUP : Pseudo<(ops), "; ADJCALLSTACKUP">;
Nate Begemanb816f022004-10-07 22:30:03 +000050}
Nate Begemanb7a8f2c2004-09-02 08:13:00 +000051def IMPLICIT_DEF : Pseudo<(ops), "; IMPLICIT_DEF">;
52def MovePCtoLR : Pseudo<(ops piclabel:$label), "bl $label">;
Misha Brukman5dfe3a92004-06-21 16:55:25 +000053
Misha Brukmanb2edb442004-06-28 18:23:35 +000054let isBranch = 1, isTerminator = 1 in {
Nate Begemanb7a8f2c2004-09-02 08:13:00 +000055 def COND_BRANCH : Pseudo<(ops), "; COND_BRANCH">;
Misha Brukman40a55e12004-10-23 20:29:24 +000056 def B : IForm<18, 0, 0, 0, 0, (ops target:$func), "b $func">;
57 def BA : IForm<18, 1, 0, 0, 0, (ops target:$func), "ba $func">;
58 def BL : IForm<18, 0, 1, 0, 0, (ops target:$func), "bl $func">;
59 def BLA : IForm<18, 1, 1, 0, 0, (ops target:$func), "bla $func">;
Misha Brukman4ad7d1b2004-08-09 17:24:04 +000060 // FIXME: 4*CR# needs to be added to the BI field!
61 // This will only work for CR0 as it stands now
Nate Begemaned428532004-09-04 05:00:00 +000062 def BLT : BForm_ext<16, 0, 0, 12, 0, 0, 0, (ops CRRC:$crS, target:$block),
63 "blt $block">;
64 def BLE : BForm_ext<16, 0, 0, 4, 1, 0, 0, (ops CRRC:$crS, target:$block),
65 "ble $block">;
66 def BEQ : BForm_ext<16, 0, 0, 12, 2, 0, 0, (ops CRRC:$crS, target:$block),
67 "beq $block">;
68 def BGE : BForm_ext<16, 0, 0, 4, 0, 0, 0, (ops CRRC:$crS, target:$block),
69 "bge $block">;
70 def BGT : BForm_ext<16, 0, 0, 12, 1, 0, 0, (ops CRRC:$crS, target:$block),
71 "bgt $block">;
72 def BNE : BForm_ext<16, 0, 0, 4, 2, 0, 0, (ops CRRC:$crS, target:$block),
73 "bne $block">;
Misha Brukmanb2edb442004-06-28 18:23:35 +000074}
75
Misha Brukman5fa2b022004-06-29 23:37:36 +000076let isBranch = 1, isTerminator = 1, isCall = 1,
77 // All calls clobber the non-callee saved registers...
Misha Brukmanc661c302004-06-30 22:00:45 +000078 Defs = [R0,R2,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,
79 F0,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,
80 LR,XER,CTR,
81 CR0,CR1,CR5,CR6,CR7] in {
82 // Convenient aliases for call instructions
Nate Begemanb7a8f2c2004-09-02 08:13:00 +000083 def CALLpcrel : IForm<18, 0, 1, 0, 0, (ops target:$func), "bl $func">;
84 def CALLindirect : XLForm_2_ext<19, 528, 20, 31, 1, 0, 0, (ops), "bctrl">;
Misha Brukman5fa2b022004-06-29 23:37:36 +000085}
86
Nate Begeman07aada82004-08-30 02:28:06 +000087// D-Form instructions. Most instructions that perform an operation on a
88// register and an immediate are of this type.
89//
Nate Begemanb816f022004-10-07 22:30:03 +000090let isLoad = 1 in {
Nate Begemaned428532004-09-04 05:00:00 +000091def LBZ : DForm_1<35, 0, 0, (ops GPRC:$rD, s16imm:$disp, GPRC:$rA),
92 "lbz $rD, $disp($rA)">;
93def LHA : DForm_1<42, 0, 0, (ops GPRC:$rD, s16imm:$disp, GPRC:$rA),
94 "lha $rD, $disp($rA)">;
95def LHZ : DForm_1<40, 0, 0, (ops GPRC:$rD, s16imm:$disp, GPRC:$rA),
96 "lhz $rD, $disp($rA)">;
97def LMW : DForm_1<46, 0, 0, (ops GPRC:$rD, s16imm:$disp, GPRC:$rA),
98 "lmw $rD, $disp($rA)">;
99def LWZ : DForm_1<32, 0, 0, (ops GPRC:$rD, symbolLo:$disp, GPRC:$rA),
100 "lwz $rD, $disp($rA)">;
Nate Begemanb816f022004-10-07 22:30:03 +0000101}
Nate Begemaned428532004-09-04 05:00:00 +0000102def ADDI : DForm_2<14, 0, 0, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
103 "addi $rD, $rA, $imm">;
104def ADDIC : DForm_2<12, 0, 0, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
105 "addic $rD, $rA, $imm">;
106def ADDICo : DForm_2<13, 0, 0, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
107 "addic. $rD, $rA, $imm">;
108def ADDIS : DForm_2<15, 0, 0, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
109 "addis $rD, $rA, $imm">;
110def LA : DForm_2<14, 0, 0, (ops GPRC:$rD, symbolLo:$sym, GPRC:$rA),
111 "la $rD, $sym($rA)">;
112def LOADHiAddr : DForm_2<15, 0, 0, (ops GPRC:$rD, GPRC:$rA, symbolHi:$sym),
113 "addis $rD, $rA, $sym">;
114def MULLI : DForm_2< 7, 0, 0, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
115 "mulli $rD, $rA, $imm">;
116def SUBFIC : DForm_2< 8, 0, 0, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
117 "subfic $rD, $rA, $imm">;
Nate Begemaned428532004-09-04 05:00:00 +0000118def LI : DForm_2_r0<14, 0, 0, (ops GPRC:$rD, s16imm:$imm),
119 "li $rD, $imm">;
120def LIS : DForm_2_r0<15, 0, 0, (ops GPRC:$rD, s16imm:$imm),
121 "lis $rD, $imm">;
Nate Begemanb816f022004-10-07 22:30:03 +0000122let isStore = 1 in {
Nate Begemaned428532004-09-04 05:00:00 +0000123def STMW : DForm_3<47, 0, 0, (ops GPRC:$rS, s16imm:$disp, GPRC:$rA),
124 "stmw $rS, $disp($rA)">;
125def STB : DForm_3<38, 0, 0, (ops GPRC:$rS, s16imm:$disp, GPRC:$rA),
126 "stb $rS, $disp($rA)">;
127def STBU : DForm_3<39, 0, 0, (ops GPRC:$rS, s16imm:$disp, GPRC:$rA),
128 "stbu $rS, $disp($rA)">;
129def STH : DForm_3<44, 0, 0, (ops GPRC:$rS, s16imm:$disp, GPRC:$rA),
130 "sth $rS, $disp($rA)">;
131def STHU : DForm_3<45, 0, 0, (ops GPRC:$rS, s16imm:$disp, GPRC:$rA),
132 "sthu $rS, $disp($rA)">;
133def STW : DForm_3<36, 0, 0, (ops GPRC:$rS, s16imm:$disp, GPRC:$rA),
134 "stw $rS, $disp($rA)">;
135def STWU : DForm_3<37, 0, 0, (ops GPRC:$rS, s16imm:$disp, GPRC:$rA),
136 "stwu $rS, $disp($rA)">;
Nate Begemanb816f022004-10-07 22:30:03 +0000137}
Nate Begeman6b3dc552004-08-29 22:45:13 +0000138def ANDIo : DForm_4<28, 0, 0,
Nate Begeman07aada82004-08-30 02:28:06 +0000139 (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
140 "andi. $dst, $src1, $src2">;
Nate Begemanb816f022004-10-07 22:30:03 +0000141def ANDISo : DForm_4<29, 0, 0,
142 (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
143 "andis. $dst, $src1, $src2">;
Nate Begeman07aada82004-08-30 02:28:06 +0000144def ORI : DForm_4<24, 0, 0,
145 (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
146 "ori $dst, $src1, $src2">;
147def ORIS : DForm_4<25, 0, 0,
148 (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
149 "oris $dst, $src1, $src2">;
Chris Lattner97b2a2e2004-08-15 05:20:16 +0000150def XORI : DForm_4<26, 0, 0,
Nate Begeman07aada82004-08-30 02:28:06 +0000151 (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
152 "xori $dst, $src1, $src2">;
Chris Lattner97b2a2e2004-08-15 05:20:16 +0000153def XORIS : DForm_4<27, 0, 0,
Nate Begeman07aada82004-08-30 02:28:06 +0000154 (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
155 "xoris $dst, $src1, $src2">;
Nate Begemaned428532004-09-04 05:00:00 +0000156def NOP : DForm_4_zero<24, 0, 0, (ops), "nop">;
157def CMPI : DForm_5<11, 0, 0, (ops CRRC:$crD, i1imm:$L, GPRC:$rA, s16imm:$imm),
158 "cmpi $crD, $L, $rA, $imm">;
159def CMPWI : DForm_5_ext<11, 0, 0, (ops CRRC:$crD, GPRC:$rA, s16imm:$imm),
160 "cmpwi $crD, $rA, $imm">;
161def CMPDI : DForm_5_ext<11, 1, 0, (ops CRRC:$crD, GPRC:$rA, s16imm:$imm),
162 "cmpdi $crD, $rA, $imm">;
Nate Begeman07aada82004-08-30 02:28:06 +0000163def CMPLI : DForm_6<10, 0, 0,
Nate Begemaned428532004-09-04 05:00:00 +0000164 (ops CRRC:$dst, i1imm:$size, GPRC:$src1, u16imm:$src2),
165 "cmpli $dst, $size, $src1, $src2">;
Nate Begeman6b3dc552004-08-29 22:45:13 +0000166def CMPLWI : DForm_6_ext<10, 0, 0,
167 (ops CRRC:$dst, GPRC:$src1, u16imm:$src2),
168 "cmplwi $dst, $src1, $src2">;
169def CMPLDI : DForm_6_ext<10, 1, 0,
170 (ops CRRC:$dst, GPRC:$src1, u16imm:$src2),
171 "cmpldi $dst, $src1, $src2">;
Nate Begemanb816f022004-10-07 22:30:03 +0000172let isLoad = 1 in {
Nate Begemaned428532004-09-04 05:00:00 +0000173def LFS : DForm_8<48, 0, 0, (ops GPRC:$rD, symbolLo:$disp, GPRC:$rA),
174 "lfs $rD, $disp($rA)">;
175def LFD : DForm_8<50, 0, 0, (ops GPRC:$rD, symbolLo:$disp, GPRC:$rA),
176 "lfd $rD, $disp($rA)">;
Nate Begemanb816f022004-10-07 22:30:03 +0000177}
178let isStore = 1 in {
Nate Begemaned428532004-09-04 05:00:00 +0000179def STFS : DForm_9<52, 0, 0, (ops GPRC:$rS, s16imm:$disp, GPRC:$rA),
180 "stfs $rS, $disp($rA)">;
181def STFD : DForm_9<54, 0, 0, (ops GPRC:$rS, s16imm:$disp, GPRC:$rA),
182 "stfd $rS, $disp($rA)">;
Nate Begemanb816f022004-10-07 22:30:03 +0000183}
Nate Begemaned428532004-09-04 05:00:00 +0000184
185// DS-Form instructions. Load/Store instructions available in PPC-64
186//
Nate Begemanb816f022004-10-07 22:30:03 +0000187let isLoad = 1 in {
Nate Begemaned428532004-09-04 05:00:00 +0000188def LWA : DSForm_1<58, 2, 1, 0, (ops GPRC:$rT, s16imm:$DS, GPRC:$rA),
189 "lwa $rT, $DS($rA)">;
190def LD : DSForm_2<58, 0, 1, 0, (ops GPRC:$rT, s16imm:$DS, GPRC:$rA),
191 "ld $rT, $DS($rA)">;
Nate Begemanb816f022004-10-07 22:30:03 +0000192}
193let isStore = 1 in {
Nate Begemaned428532004-09-04 05:00:00 +0000194def STD : DSForm_2<62, 0, 1, 0, (ops GPRC:$rT, s16imm:$DS, GPRC:$rA),
195 "std $rT, $DS($rA)">;
196def STDU : DSForm_2<62, 1, 1, 0, (ops GPRC:$rT, s16imm:$DS, GPRC:$rA),
197 "stdu $rT, $DS($rA)">;
Nate Begemanb816f022004-10-07 22:30:03 +0000198}
Nate Begemanc3306122004-08-21 05:56:39 +0000199
Nate Begeman07aada82004-08-30 02:28:06 +0000200// X-Form instructions. Most instructions that perform an operation on a
201// register and another register are of this type.
202//
Nate Begemanb816f022004-10-07 22:30:03 +0000203let isLoad = 1 in {
Nate Begemanc3306122004-08-21 05:56:39 +0000204def LBZX : XForm_1<31, 87, 0, 0, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
205 "lbzx $dst, $base, $index">;
206def LHAX : XForm_1<31, 343, 0, 0, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
207 "lhax $dst, $base, $index">;
208def LHZX : XForm_1<31, 279, 0, 0, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
209 "lhzx $dst, $base, $index">;
210def LWAX : XForm_1<31, 341, 1, 0, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
211 "lwax $dst, $base, $index">;
212def LWZX : XForm_1<31, 23, 0, 0, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
213 "lwzx $dst, $base, $index">;
214def LDX : XForm_1<31, 21, 1, 0, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
215 "ldx $dst, $base, $index">;
Nate Begemanb816f022004-10-07 22:30:03 +0000216}
Nate Begemanc3306122004-08-21 05:56:39 +0000217def MFCR : XForm_5<31, 19, 0, 0, (ops GPRC:$dst), "mfcr $dst">;
218def AND : XForm_6<31, 28, 0, 0, 0, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
219 "and $rA, $rS, $rB">;
220def ANDC : XForm_6<31, 60, 0, 0, 0, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
221 "andc $rA, $rS, $rB">;
222def EQV : XForm_6<31, 284, 0, 0, 0, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
223 "eqv $rA, $rS, $rB">;
224def NAND : XForm_6<31, 476, 0, 0, 0, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
225 "nand $rA, $rS, $rB">;
226def NOR : XForm_6<31, 124, 0, 0, 0, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
227 "nor $rA, $rS, $rB">;
228def OR : XForm_6<31, 444, 0, 0, 0, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
229 "or $rA, $rS, $rB">;
230def ORo : XForm_6<31, 444, 1, 0, 0, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
231 "or. $rA, $rS, $rB">;
232def ORC : XForm_6<31, 412, 0, 0, 0, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
233 "orc $rA, $rS, $rB">;
234def SLD : XForm_6<31, 27, 0, 1, 0, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
235 "sld $rA, $rS, $rB">;
236def SLW : XForm_6<31, 24, 0, 0, 0, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
237 "slw $rA, $rS, $rB">;
238def SRD : XForm_6<31, 539, 0, 1, 0, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
239 "srd $rA, $rS, $rB">;
240def SRW : XForm_6<31, 536, 0, 0, 0, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
241 "srw $rA, $rS, $rB">;
242def SRAD : XForm_6<31, 794, 0, 1, 0, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
243 "srad $rA, $rS, $rB">;
244def SRAW : XForm_6<31, 792, 0, 0, 0, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
245 "sraw $rA, $rS, $rB">;
246def XOR : XForm_6<31, 316, 0, 0, 0, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
247 "xor $rA, $rS, $rB">;
Nate Begemanb816f022004-10-07 22:30:03 +0000248let isStore = 1 in {
Nate Begemanc3306122004-08-21 05:56:39 +0000249def STBX : XForm_8<31, 215, 0, 0, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
250 "stbx $rS, $rA, $rB">;
251def STHX : XForm_8<31, 407, 0, 0, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
252 "sthx $rS, $rA, $rB">;
253def STWX : XForm_8<31, 151, 0, 0, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
254 "stwx $rS, $rA, $rB">;
255def STWUX : XForm_8<31, 183, 0, 0, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
256 "stwux $rS, $rA, $rB">;
257def STDX : XForm_8<31, 149, 1, 0, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
258 "stdx $rS, $rA, $rB">;
259def STDUX : XForm_8<31, 181, 1, 0, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
260 "stdux $rS, $rA, $rB">;
Nate Begemanb816f022004-10-07 22:30:03 +0000261}
Nate Begemanc3306122004-08-21 05:56:39 +0000262def SRAWI : XForm_10<31, 824, 0, 0, 0, (ops GPRC:$rA, GPRC:$rS, u5imm:$SH),
263 "srawi $rA, $rS, $SH">;
264def CNTLZW : XForm_11<31, 26, 0, 0, 0, (ops GPRC:$rA, GPRC:$rS),
265 "cntlzw $rA, $rS">;
266def EXTSB : XForm_11<31, 954, 0, 0, 0, (ops GPRC:$rA, GPRC:$rS),
267 "extsb $rA, $rS">;
268def EXTSH : XForm_11<31, 922, 0, 0, 0, (ops GPRC:$rA, GPRC:$rS),
269 "extsh $rA, $rS">;
Nate Begemand332fd52004-08-29 22:02:43 +0000270def EXTSW : XForm_11<31, 986, 0, 1, 0, (ops GPRC:$rA, GPRC:$rS),
271 "extsw $rA, $rS">;
Nate Begemanb7a8f2c2004-09-02 08:13:00 +0000272def CMP : XForm_16<31, 0, 0, 0,
273 (ops CRRC:$crD, i1imm:$long, GPRC:$rA, GPRC:$rB),
274 "cmp $crD, $long, $rA, $rB">;
275def CMPL : XForm_16<31, 32, 0, 0,
276 (ops CRRC:$crD, i1imm:$long, GPRC:$rA, GPRC:$rB),
277 "cmpl $crD, $long, $rA, $rB">;
278def CMPW : XForm_16_ext<31, 0, 0, 0,
279 (ops CRRC:$crD, GPRC:$rA, GPRC:$rB),
280 "cmpw $crD, $rA, $rB">;
281def CMPD : XForm_16_ext<31, 0, 1, 0,
282 (ops CRRC:$crD, GPRC:$rA, GPRC:$rB),
283 "cmpd $crD, $rA, $rB">;
284def CMPLW : XForm_16_ext<31, 32, 0, 0,
285 (ops CRRC:$crD, GPRC:$rA, GPRC:$rB),
286 "cmplw $crD, $rA, $rB">;
287def CMPLD : XForm_16_ext<31, 32, 1, 0,
288 (ops CRRC:$crD, GPRC:$rA, GPRC:$rB),
289 "cmpld $crD, $rA, $rB">;
Nate Begemancc8bd9c2004-08-31 02:28:08 +0000290def FCMPU : XForm_17<63, 0, 0, 0, (ops CRRC:$crD, FPRC:$fA, FPRC:$fB),
291 "fcmpu $crD, $fA, $fB">;
Nate Begemanb816f022004-10-07 22:30:03 +0000292let isLoad = 1 in {
Nate Begemancc8bd9c2004-08-31 02:28:08 +0000293def LFSX : XForm_25<31, 535, 0, 0, (ops FPRC:$dst, GPRC:$base, GPRC:$index),
294 "lfsx $dst, $base, $index">;
295def LFDX : XForm_25<31, 599, 0, 0, (ops FPRC:$dst, GPRC:$base, GPRC:$index),
296 "lfdx $dst, $base, $index">;
Nate Begemanb816f022004-10-07 22:30:03 +0000297}
Nate Begemand332fd52004-08-29 22:02:43 +0000298def FCFID : XForm_26<63, 846, 0, 1, 0, (ops FPRC:$frD, FPRC:$frB),
299 "fcfid $frD, $frB">;
300def FCTIDZ : XForm_26<63, 815, 0, 1, 0, (ops FPRC:$frD, FPRC:$frB),
301 "fctidz $frD, $frB">;
302def FCTIWZ : XForm_26<63, 15, 0, 0, 0, (ops FPRC:$frD, FPRC:$frB),
303 "fctiwz $frD, $frB">;
Nate Begemanc3306122004-08-21 05:56:39 +0000304def FMR : XForm_26<63, 72, 0, 0, 0, (ops FPRC:$frD, FPRC:$frB),
305 "fmr $frD, $frB">;
306def FNEG : XForm_26<63, 80, 0, 0, 0, (ops FPRC:$frD, FPRC:$frB),
307 "fneg $frD, $frB">;
308def FRSP : XForm_26<63, 12, 0, 0, 0, (ops FPRC:$frD, FPRC:$frB),
309 "frsp $frD, $frB">;
Nate Begemanb816f022004-10-07 22:30:03 +0000310let isStore = 1 in {
Nate Begemanc3306122004-08-21 05:56:39 +0000311def STFSX : XForm_28<31, 663, 0, 0, (ops FPRC:$frS, GPRC:$rA, GPRC:$rB),
312 "stfsx $frS, $rA, $rB">;
313def STFDX : XForm_28<31, 727, 0, 0, (ops FPRC:$frS, GPRC:$rA, GPRC:$rB),
314 "stfdx $frS, $rA, $rB">;
Nate Begemanb816f022004-10-07 22:30:03 +0000315}
Nate Begeman6b3dc552004-08-29 22:45:13 +0000316
Nate Begeman07aada82004-08-30 02:28:06 +0000317// XL-Form instructions. condition register logical ops.
318//
Nate Begemanc3306122004-08-21 05:56:39 +0000319def CRAND : XLForm_1<19, 257, 0, 0, (ops u5imm:$D, u5imm:$A, u5imm:$B),
320 "crand $D, $A, $B">;
321def CRANDC : XLForm_1<19, 129, 0, 0, (ops u5imm:$D, u5imm:$A, u5imm:$B),
322 "crandc $D, $A, $B">;
323def CRNOR : XLForm_1<19, 33, 0, 0, (ops u5imm:$D, u5imm:$A, u5imm:$B),
324 "crnor $D, $A, $B">;
325def CROR : XLForm_1<19, 449, 0, 0, (ops u5imm:$D, u5imm:$A, u5imm:$B),
326 "cror $D, $A, $B">;
Nate Begeman07aada82004-08-30 02:28:06 +0000327
328// XFX-Form instructions. Instructions that deal with SPRs
329//
Misha Brukmanda8d96d2004-10-23 06:05:49 +0000330// Note that although LR should be listed as `8' and CTR as `9' in the SPR
331// field, the manual lists the groups of bits as [5-9] = 0, [0-4] = 8 or 9
332// which means the SPR value needs to be multiplied by a factor of 32.
333def MFCTR : XFXForm_1_ext<31, 339, 288, 0, 0, (ops GPRC:$rT), "mfctr $rT">;
334def MFLR : XFXForm_1_ext<31, 339, 256, 0, 0, (ops GPRC:$rT), "mflr $rT">;
335def MTCTR : XFXForm_7_ext<31, 467, 288, 0, 0, (ops GPRC:$rS), "mtctr $rS">;
336def MTLR : XFXForm_7_ext<31, 467, 256, 0, 0, (ops GPRC:$rS), "mtlr $rS">;
Nate Begeman07aada82004-08-30 02:28:06 +0000337
338
339// XS-Form instructions. Just 'sradi'
340//
341def SRADI : XSForm_1<31, 413, 0, 1, 0, (ops GPRC:$rA, GPRC:$rS, u6imm:$SH),
342 "sradi $rA, $rS, $SH">;
343
344// XO-Form instructions. Arithmetic instructions that can set overflow bit
345//
346def ADD : XOForm_1<31, 266, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
347 "add $rT, $rA, $rB">;
348def ADDC : XOForm_1<31, 10, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
349 "addc $rT, $rA, $rB">;
350def ADDE : XOForm_1<31, 138, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
351 "adde $rT, $rA, $rB">;
Nate Begeman20136a22004-09-06 18:46:59 +0000352def DIVD : XOForm_1<31, 489, 0, 0, 1, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
353 "divd $rT, $rA, $rB">;
354def DIVDU : XOForm_1<31, 457, 0, 0, 1, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
355 "divdu $rT, $rA, $rB">;
Nate Begeman07aada82004-08-30 02:28:06 +0000356def DIVW : XOForm_1<31, 491, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
357 "divw $rT, $rA, $rB">;
358def DIVWU : XOForm_1<31, 459, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
359 "divwu $rT, $rA, $rB">;
360def MULHWU : XOForm_1<31, 11, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
361 "mulhwu $rT, $rA, $rB">;
362def MULLD : XOForm_1<31, 233, 0, 0, 1, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
363 "mulld $rT, $rA, $rB">;
364def MULLW : XOForm_1<31, 235, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
365 "mullw $rT, $rA, $rB">;
366def SUBF : XOForm_1<31, 40, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
367 "subf $rT, $rA, $rB">;
368def SUBFC : XOForm_1<31, 8, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
369 "subfc $rT, $rA, $rB">;
370def SUBFE : XOForm_1<31, 136, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
371 "subfe $rT, $rA, $rB">;
372def SUB : XOForm_1r<31, 40, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
373 "sub $rT, $rA, $rB">;
374def SUBC : XOForm_1r<31, 8, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
375 "subc $rT, $rA, $rB">;
Nate Begemana2de1022004-09-22 04:40:25 +0000376def ADDME : XOForm_3<31, 234, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA),
377 "addme $rT, $rA">;
Nate Begeman07aada82004-08-30 02:28:06 +0000378def ADDZE : XOForm_3<31, 202, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA),
379 "addze $rT, $rA">;
380def NEG : XOForm_3<31, 104, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA),
381 "neg $rT, $rA">;
382def SUBFZE : XOForm_3<31, 200, 0, 0, 0, 0, (ops GPRC:$rT, GPRC:$rA),
383 "subfze $rT, $rA">;
384
385// A-Form instructions. Most of the instructions executed in the FPU are of
386// this type.
387//
388def FMADD : AForm_1<63, 29, 0, 0, 0,
389 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRC, FPRC:$FRB),
390 "fmadd $FRT, $FRA, $FRC, $FRB">;
391def FSEL : AForm_1<63, 23, 0, 0, 0,
392 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRC, FPRC:$FRB),
393 "fsel $FRT, $FRA, $FRC, $FRB">;
394def FADD : AForm_2<63, 21, 0, 0, 0,
395 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
396 "fadd $FRT, $FRA, $FRB">;
397def FADDS : AForm_2<59, 21, 0, 0, 0,
398 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
399 "fadds $FRT, $FRA, $FRB">;
400def FDIV : AForm_2<63, 18, 0, 0, 0,
401 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
402 "fdiv $FRT, $FRA, $FRB">;
403def FDIVS : AForm_2<59, 18, 0, 0, 0,
404 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
405 "fdivs $FRT, $FRA, $FRB">;
406def FMUL : AForm_3<63, 25, 0, 0, 0,
407 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
408 "fmul $FRT, $FRA, $FRB">;
409def FMULS : AForm_3<59, 25, 0, 0, 0,
410 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
411 "fmuls $FRT, $FRA, $FRB">;
412def FSUB : AForm_2<63, 20, 0, 0, 0,
413 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
414 "fsub $FRT, $FRA, $FRB">;
415def FSUBS : AForm_2<59, 20, 0, 0, 0,
416 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
417 "fsubs $FRT, $FRA, $FRB">;
418
Nate Begemancc8bd9c2004-08-31 02:28:08 +0000419// M-Form instructions. rotate and mask instructions.
420//
Nate Begeman2d4c98d2004-10-16 20:43:38 +0000421let isTwoAddress = 1 in {
Nate Begemancc8bd9c2004-08-31 02:28:08 +0000422def RLWIMI : MForm_2<20, 0, 0, 0,
Nate Begeman2d4c98d2004-10-16 20:43:38 +0000423 (ops GPRC:$rA, GPRC:$rSi, GPRC:$rS, u5imm:$SH, u5imm:$MB,
424 u5imm:$ME), "rlwimi $rA, $rS, $SH, $MB, $ME">;
425}
Nate Begemancc8bd9c2004-08-31 02:28:08 +0000426def RLWINM : MForm_2<21, 0, 0, 0,
427 (ops GPRC:$rA, GPRC:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
428 "rlwinm $rA, $rS, $SH, $MB, $ME">;
429
430
431// MD-Form instructions. 64 bit rotate instructions.
432//
433def RLDICL : MDForm_1<30, 0, 0, 1, 0,
434 (ops GPRC:$rA, GPRC:$rS, u6imm:$SH, u6imm:$MB),
435 "rldicl $rA, $rS, $SH, $MB">;
436def RLDICR : MDForm_1<30, 1, 0, 1, 0,
437 (ops GPRC:$rA, GPRC:$rS, u6imm:$SH, u6imm:$ME),
438 "rldicr $rA, $rS, $SH, $ME">;
439
440