blob: e1ae7d13d5c4c369c851c567db57fd5478b2c0b6 [file] [log] [blame]
Misha Brukmanbc9ccf62005-02-04 20:25:52 +00001//===- AlphaInstrInfo.td - The Alpha Instruction Set -------*- tablegen -*-===//
Andrew Lenharth304d0f32005-01-22 23:41:55 +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//
10//
11//===----------------------------------------------------------------------===//
12
13include "AlphaInstrFormats.td"
14
Andrew Lenharth4907d222005-10-20 00:28:31 +000015//********************
16//Paterns for matching
17//********************
Andrew Lenharthfe9234d2005-10-21 01:24:05 +000018
Andrew Lenharth756fbeb2005-10-22 22:06:58 +000019def immUExt8 : PatLeaf<(imm), [{
20 // immUExt8 predicate - True if the immediate fits in a 8-bit zero extended
21 // field. Used by instructions like 'addi'.
22 return (unsigned long)N->getValue() == (unsigned char)N->getValue();
23}]>;
24def immSExt16 : PatLeaf<(imm), [{
25 // immSExt16 predicate - True if the immediate fits in a 16-bit sign extended
26 // field. Used by instructions like 'lda'.
27 return (int)N->getValue() == (short)N->getValue();
28}]>;
29
Andrew Lenharthfe9234d2005-10-21 01:24:05 +000030def iZAPX : SDNodeXForm<imm, [{
31 // Transformation function: get the imm to ZAPi
32 uint64_t UImm = (uint64_t)N->getValue();
33 unsigned int build = 0;
34 for(int i = 0; i < 8; ++i)
35 {
36 if ((UImm & 0x00FF) == 0x00FF)
37 build |= 1 << i;
38 else if ((UImm & 0x00FF) != 0)
39 { build = 0; break; }
40 UImm >>= 8;
41 }
42 return getI64Imm(build);
43}]>;
Andrew Lenharthfe9234d2005-10-21 01:24:05 +000044def immZAP : PatLeaf<(imm), [{
45 // immZAP predicate - True if the immediate fits is suitable for use in a
46 // ZAP instruction
47 uint64_t UImm = (uint64_t)N->getValue();
48 unsigned int build = 0;
49 for(int i = 0; i < 8; ++i)
50 {
51 if ((UImm & 0x00FF) == 0x00FF)
52 build |= 1 << i;
53 else if ((UImm & 0x00FF) != 0)
54 { build = 0; break; }
55 UImm >>= 8;
56 }
57 return build != 0;
Andrew Lenharth8b7f14e2005-10-23 03:43:48 +000058}], iZAPX>;
Andrew Lenharthfe9234d2005-10-21 01:24:05 +000059
60
61def intop : PatFrag<(ops node:$op), (sext_inreg node:$op, i32)>;
62def add4 : PatFrag<(ops node:$op1, node:$op2),
63 (add (shl node:$op1, 2), node:$op2)>;
64def sub4 : PatFrag<(ops node:$op1, node:$op2),
65 (sub (shl node:$op1, 2), node:$op2)>;
66def add8 : PatFrag<(ops node:$op1, node:$op2),
67 (add (shl node:$op1, 3), node:$op2)>;
68def sub8 : PatFrag<(ops node:$op1, node:$op2),
69 (sub (shl node:$op1, 3), node:$op2)>;
Andrew Lenharth4907d222005-10-20 00:28:31 +000070
Andrew Lenharth304d0f32005-01-22 23:41:55 +000071 // //#define FP $15
72 // //#define RA $26
73 // //#define PV $27
74 // //#define GP $29
75 // //#define SP $30
76
Chris Lattner80132a42005-08-19 00:51:37 +000077def PHI : PseudoInstAlpha<(ops variable_ops), "#phi">;
Andrew Lenharth2b6c4f52005-02-25 22:55:15 +000078def IDEF : PseudoInstAlpha<(ops GPRC:$RA), "#idef $RA">;
Chris Lattner80132a42005-08-19 00:51:37 +000079def WTF : PseudoInstAlpha<(ops variable_ops), "#wtf">;
80def ADJUSTSTACKUP : PseudoInstAlpha<(ops variable_ops), "ADJUP">;
81def ADJUSTSTACKDOWN : PseudoInstAlpha<(ops variable_ops), "ADJDOWN">;
Andrew Lenharth556c44e2005-04-13 16:19:50 +000082def ALTENT : PseudoInstAlpha<(ops s64imm:$TARGET), "$TARGET:\n">;
Andrew Lenharth95762122005-03-31 21:24:06 +000083def PCLABEL : PseudoInstAlpha<(ops s64imm:$num), "PCMARKER_$num:\n">;
Andrew Lenharth06ef8842005-06-29 18:54:02 +000084def MEMLABEL : PseudoInstAlpha<(ops s64imm:$i, s64imm:$j, s64imm:$k, s64imm:$m),
85 "LSMARKER$$$i$$$j$$$k$$$m:\n">;
Andrew Lenharth95762122005-03-31 21:24:06 +000086
Andrew Lenharth304d0f32005-01-22 23:41:55 +000087//*****************
88//These are shortcuts, the assembler expands them
89//*****************
90//AT = R28
91//T0-T7 = R1 - R8
92//T8-T11 = R22-R25
93
Andrew Lenharthdc0b71b2005-03-22 00:24:07 +000094//An even better improvement on the Int = SetCC(FP): SelectCC!
Andrew Lenharth0eaf6ce2005-04-02 21:06:51 +000095//These are evil because they hide control flow in a MBB
96//really the ISel should emit multiple MBB
Andrew Lenharthdc0b71b2005-03-22 00:24:07 +000097let isTwoAddress = 1 in {
Andrew Lenharth0eaf6ce2005-04-02 21:06:51 +000098//Conditional move of an int based on a FP CC
Andrew Lenharth5cefc5e2005-11-09 19:17:08 +000099 def CMOVEQ_FP : PseudoInstAlpha<(ops GPRC:$RDEST, GPRC:$RSRC_F, GPRC:$RSRC_T, F8RC:$RCOND),
Andrew Lenharthdc0b71b2005-03-22 00:24:07 +0000100 "fbne $RCOND, 42f\n\tbis $RSRC_T,$RSRC_T,$RDEST\n42:\n">;
Andrew Lenharth5cefc5e2005-11-09 19:17:08 +0000101 def CMOVEQi_FP : PseudoInstAlpha<(ops GPRC:$RDEST, GPRC:$RSRC_F, u8imm:$L, F8RC:$RCOND),
Andrew Lenharthf29dc072005-03-22 16:42:52 +0000102 "fbne $RCOND, 42f\n\taddq $$31,$L,$RDEST\n42:\n">;
Andrew Lenharthdc0b71b2005-03-22 00:24:07 +0000103
Andrew Lenharth5cefc5e2005-11-09 19:17:08 +0000104 def CMOVNE_FP : PseudoInstAlpha<(ops GPRC:$RDEST, GPRC:$RSRC_F, GPRC:$RSRC_T, F8RC:$RCOND),
Andrew Lenharthdc0b71b2005-03-22 00:24:07 +0000105 "fbeq $RCOND, 42f\n\tbis $RSRC_T,$RSRC_T,$RDEST\n42:\n">;
Andrew Lenharth5cefc5e2005-11-09 19:17:08 +0000106 def CMOVNEi_FP : PseudoInstAlpha<(ops GPRC:$RDEST, GPRC:$RSRC_F, u8imm:$L, F8RC:$RCOND),
Andrew Lenharthf29dc072005-03-22 16:42:52 +0000107 "fbeq $RCOND, 42f\n\taddq $$31,$L,$RDEST\n42:\n">;
Andrew Lenharth0eaf6ce2005-04-02 21:06:51 +0000108//Conditional move of an FP based on a Int CC
Andrew Lenharth5cefc5e2005-11-09 19:17:08 +0000109 def FCMOVEQ_INT : PseudoInstAlpha<(ops GPRC:$RDEST, GPRC:$RSRC_F, GPRC:$RSRC_T, F8RC:$RCOND),
Andrew Lenharth0eaf6ce2005-04-02 21:06:51 +0000110 "bne $RCOND, 42f\n\tcpys $RSRC_T,$RSRC_T,$RDEST\n42:\n">;
Andrew Lenharth5cefc5e2005-11-09 19:17:08 +0000111 def FCMOVNE_INT : PseudoInstAlpha<(ops GPRC:$RDEST, GPRC:$RSRC_F, GPRC:$RSRC_T, F8RC:$RCOND),
Andrew Lenharth0eaf6ce2005-04-02 21:06:51 +0000112 "beq $RCOND, 42f\n\tcpys $RSRC_T,$RSRC_T,$RDEST\n42:\n">;
Andrew Lenharthdc0b71b2005-03-22 00:24:07 +0000113}
Andrew Lenharthca3d59b2005-03-14 19:23:45 +0000114
Andrew Lenharth304d0f32005-01-22 23:41:55 +0000115//***********************
116//Real instructions
117//***********************
118
119//Operation Form:
Andrew Lenharth304d0f32005-01-22 23:41:55 +0000120
Andrew Lenharthd4bdd542005-02-05 16:41:03 +0000121//conditional moves, int
Andrew Lenharth1f347a32005-10-20 23:58:36 +0000122def CMOVEQ : OForm4< 0x11, 0x24, "cmoveq $RCOND,$RSRC,$RDEST">; //CMOVE if RCOND = zero
123def CMOVEQi : OForm4L< 0x11, 0x24, "cmoveq $RCOND,$L,$RDEST">; //CMOVE if RCOND = zero
124def CMOVGE : OForm4< 0x11, 0x46, "cmovge $RCOND,$RSRC,$RDEST">; //CMOVE if RCOND >= zero
125def CMOVGEi : OForm4L< 0x11, 0x46, "cmovge $RCOND,$L,$RDEST">; //CMOVE if RCOND >= zero
126def CMOVGT : OForm4< 0x11, 0x66, "cmovgt $RCOND,$RSRC,$RDEST">; //CMOVE if RCOND > zero
127def CMOVGTi : OForm4L< 0x11, 0x66, "cmovgt $RCOND,$L,$RDEST">; //CMOVE if RCOND > zero
128def CMOVLBC : OForm4< 0x11, 0x16, "cmovlbc $RCOND,$RSRC,$RDEST">; //CMOVE if RCOND low bit clear
129def CMOVLBCi : OForm4L< 0x11, 0x16, "cmovlbc $RCOND,$L,$RDEST">; //CMOVE if RCOND low bit clear
130def CMOVLBS : OForm4< 0x11, 0x14, "cmovlbs $RCOND,$RSRC,$RDEST">; //CMOVE if RCOND low bit set
131def CMOVLBSi : OForm4L< 0x11, 0x14, "cmovlbs $RCOND,$L,$RDEST">; //CMOVE if RCOND low bit set
132def CMOVLE : OForm4< 0x11, 0x64, "cmovle $RCOND,$RSRC,$RDEST">; //CMOVE if RCOND <= zero
133def CMOVLEi : OForm4L< 0x11, 0x64, "cmovle $RCOND,$L,$RDEST">; //CMOVE if RCOND <= zero
134def CMOVLT : OForm4< 0x11, 0x44, "cmovlt $RCOND,$RSRC,$RDEST">; //CMOVE if RCOND < zero
135def CMOVLTi : OForm4L< 0x11, 0x44, "cmovlt $RCOND,$L,$RDEST">; //CMOVE if RCOND < zero
136def CMOVNE : OForm4< 0x11, 0x26, "cmovne $RCOND,$RSRC,$RDEST">; //CMOVE if RCOND != zero
137def CMOVNEi : OForm4L< 0x11, 0x26, "cmovne $RCOND,$L,$RDEST">; //CMOVE if RCOND != zero
Andrew Lenharthd4bdd542005-02-05 16:41:03 +0000138
139//conditional moves, fp
Andrew Lenharth5cefc5e2005-11-09 19:17:08 +0000140let OperandList = (ops F8RC:$RDEST, F8RC:$RSRC2, F8RC:$RSRC, F8RC:$RCOND),
141 isTwoAddress = 1 in {
142def FCMOVEQ : FPForm<0x17, 0x02A, "fcmoveq $RCOND,$RSRC,$RDEST",[]>; //FCMOVE if = zero
143def FCMOVGE : FPForm<0x17, 0x02D, "fcmovge $RCOND,$RSRC,$RDEST",[]>; //FCMOVE if >= zero
144def FCMOVGT : FPForm<0x17, 0x02F, "fcmovgt $RCOND,$RSRC,$RDEST",[]>; //FCMOVE if > zero
145def FCMOVLE : FPForm<0x17, 0x02E, "fcmovle $RCOND,$RSRC,$RDEST",[]>; //FCMOVE if <= zero
146def FCMOVLT : FPForm<0x17, 0x02C, "fcmovlt $RCOND,$RSRC,$RDEST",[]>; // FCMOVE if < zero
147def FCMOVNE : FPForm<0x17, 0x02B, "fcmovne $RCOND,$RSRC,$RDEST",[]>; //FCMOVE if != zero
148}
Andrew Lenharth304d0f32005-01-22 23:41:55 +0000149
Andrew Lenharth4907d222005-10-20 00:28:31 +0000150def ADDL : OForm< 0x10, 0x00, "addl $RA,$RB,$RC",
Andrew Lenharth892ade72005-10-20 14:42:48 +0000151 [(set GPRC:$RC, (intop (add GPRC:$RA, GPRC:$RB)))]>;
Andrew Lenharth4907d222005-10-20 00:28:31 +0000152def ADDLi : OFormL<0x10, 0x00, "addl $RA,$L,$RC",
Andrew Lenharth892ade72005-10-20 14:42:48 +0000153 [(set GPRC:$RC, (intop (add GPRC:$RA, immUExt8:$L)))]>;
Andrew Lenharth4907d222005-10-20 00:28:31 +0000154def ADDQ : OForm< 0x10, 0x20, "addq $RA,$RB,$RC",
155 [(set GPRC:$RC, (add GPRC:$RA, GPRC:$RB))]>;
156def ADDQi : OFormL<0x10, 0x20, "addq $RA,$L,$RC",
157 [(set GPRC:$RC, (add GPRC:$RA, immUExt8:$L))]>;
Andrew Lenharth4907d222005-10-20 00:28:31 +0000158def AND : OForm< 0x11, 0x00, "and $RA,$RB,$RC",
159 [(set GPRC:$RC, (and GPRC:$RA, GPRC:$RB))]>;
160def ANDi : OFormL<0x11, 0x00, "and $RA,$L,$RC",
161 [(set GPRC:$RC, (and GPRC:$RA, immUExt8:$L))]>;
162def BIC : OForm< 0x11, 0x08, "bic $RA,$RB,$RC",
163 [(set GPRC:$RC, (and GPRC:$RA, (not GPRC:$RB)))]>;
164def BICi : OFormL<0x11, 0x08, "bic $RA,$L,$RC", []>;
165// [(set GPRC:$RC, (and GPRC:$RA, (not immUExt8:$L)))]>; //FIXME?
166def BIS : OForm< 0x11, 0x20, "bis $RA,$RB,$RC",
167 [(set GPRC:$RC, (or GPRC:$RA, GPRC:$RB))]>;
168def BISi : OFormL<0x11, 0x20, "bis $RA,$L,$RC",
169 [(set GPRC:$RC, (or GPRC:$RA, immUExt8:$L))]>;
Andrew Lenharth1f347a32005-10-20 23:58:36 +0000170def CTLZ : OForm2<0x1C, 0x32, "CTLZ $RB,$RC",
Andrew Lenharth964b6aa2005-10-20 19:39:24 +0000171 [(set GPRC:$RC, (ctlz GPRC:$RB))]>;
Andrew Lenharth1f347a32005-10-20 23:58:36 +0000172def CTPOP : OForm2<0x1C, 0x30, "CTPOP $RB,$RC",
Andrew Lenharth964b6aa2005-10-20 19:39:24 +0000173 [(set GPRC:$RC, (ctpop GPRC:$RB))]>;
Andrew Lenharth1f347a32005-10-20 23:58:36 +0000174def CTTZ : OForm2<0x1C, 0x33, "CTTZ $RB,$RC",
Andrew Lenharth964b6aa2005-10-20 19:39:24 +0000175 [(set GPRC:$RC, (cttz GPRC:$RB))]>;
Andrew Lenharth4907d222005-10-20 00:28:31 +0000176def EQV : OForm< 0x11, 0x48, "eqv $RA,$RB,$RC",
177 [(set GPRC:$RC, (xor GPRC:$RA, (not GPRC:$RB)))]>;
178def EQVi : OFormL<0x11, 0x48, "eqv $RA,$L,$RC", []>;
179// [(set GPRC:$RC, (xor GPRC:$RA, (not immUExt8:$L)))]>;
180//def EXTBL : OForm< 0x12, 0x06, "EXTBL $RA,$RB,$RC", []>; //Extract byte low
181//def EXTBLi : OFormL<0x12, 0x06, "EXTBL $RA,$L,$RC", []>; //Extract byte low
182//def EXTLH : OForm< 0x12, 0x6A, "EXTLH $RA,$RB,$RC", []>; //Extract longword high
183//def EXTLHi : OFormL<0x12, 0x6A, "EXTLH $RA,$L,$RC", []>; //Extract longword high
184//def EXTLL : OForm< 0x12, 0x26, "EXTLL $RA,$RB,$RC", []>; //Extract longword low
185//def EXTLLi : OFormL<0x12, 0x26, "EXTLL $RA,$L,$RC", []>; //Extract longword low
186//def EXTQH : OForm< 0x12, 0x7A, "EXTQH $RA,$RB,$RC", []>; //Extract quadword high
187//def EXTQHi : OFormL<0x12, 0x7A, "EXTQH $RA,$L,$RC", []>; //Extract quadword high
188//def EXTQ : OForm< 0x12, 0x36, "EXTQ $RA,$RB,$RC", []>; //Extract quadword low
189//def EXTQi : OFormL<0x12, 0x36, "EXTQ $RA,$L,$RC", []>; //Extract quadword low
190//def EXTWH : OForm< 0x12, 0x5A, "EXTWH $RA,$RB,$RC", []>; //Extract word high
191//def EXTWHi : OFormL<0x12, 0x5A, "EXTWH $RA,$L,$RC", []>; //Extract word high
192//def EXTWL : OForm< 0x12, 0x16, "EXTWL $RA,$RB,$RC", []>; //Extract word low
193//def EXTWLi : OFormL<0x12, 0x16, "EXTWL $RA,$L,$RC", []>; //Extract word low
194//def IMPLVER : OForm< 0x11, 0x6C, "IMPLVER $RA,$RB,$RC", []>; //Implementation version
195//def IMPLVERi : OFormL<0x11, 0x6C, "IMPLVER $RA,$L,$RC", []>; //Implementation version
196//def INSBL : OForm< 0x12, 0x0B, "INSBL $RA,$RB,$RC", []>; //Insert byte low
197//def INSBLi : OFormL<0x12, 0x0B, "INSBL $RA,$L,$RC", []>; //Insert byte low
198//def INSLH : OForm< 0x12, 0x67, "INSLH $RA,$RB,$RC", []>; //Insert longword high
199//def INSLHi : OFormL<0x12, 0x67, "INSLH $RA,$L,$RC", []>; //Insert longword high
200//def INSLL : OForm< 0x12, 0x2B, "INSLL $RA,$RB,$RC", []>; //Insert longword low
201//def INSLLi : OFormL<0x12, 0x2B, "INSLL $RA,$L,$RC", []>; //Insert longword low
202//def INSQH : OForm< 0x12, 0x77, "INSQH $RA,$RB,$RC", []>; //Insert quadword high
203//def INSQHi : OFormL<0x12, 0x77, "INSQH $RA,$L,$RC", []>; //Insert quadword high
204//def INSQL : OForm< 0x12, 0x3B, "INSQL $RA,$RB,$RC", []>; //Insert quadword low
205//def INSQLi : OFormL<0x12, 0x3B, "INSQL $RA,$L,$RC", []>; //Insert quadword low
206//def INSWH : OForm< 0x12, 0x57, "INSWH $RA,$RB,$RC", []>; //Insert word high
207//def INSWHi : OFormL<0x12, 0x57, "INSWH $RA,$L,$RC", []>; //Insert word high
208//def INSWL : OForm< 0x12, 0x1B, "INSWL $RA,$RB,$RC", []>; //Insert word low
209//def INSWLi : OFormL<0x12, 0x1B, "INSWL $RA,$L,$RC", []>; //Insert word low
210//def MSKBL : OForm< 0x12, 0x02, "MSKBL $RA,$RB,$RC", []>; //Mask byte low
211//def MSKBLi : OFormL<0x12, 0x02, "MSKBL $RA,$L,$RC", []>; //Mask byte low
212//def MSKLH : OForm< 0x12, 0x62, "MSKLH $RA,$RB,$RC", []>; //Mask longword high
213//def MSKLHi : OFormL<0x12, 0x62, "MSKLH $RA,$L,$RC", []>; //Mask longword high
214//def MSKLL : OForm< 0x12, 0x22, "MSKLL $RA,$RB,$RC", []>; //Mask longword low
215//def MSKLLi : OFormL<0x12, 0x22, "MSKLL $RA,$L,$RC", []>; //Mask longword low
216//def MSKQH : OForm< 0x12, 0x72, "MSKQH $RA,$RB,$RC", []>; //Mask quadword high
217//def MSKQHi : OFormL<0x12, 0x72, "MSKQH $RA,$L,$RC", []>; //Mask quadword high
218//def MSKQL : OForm< 0x12, 0x32, "MSKQL $RA,$RB,$RC", []>; //Mask quadword low
219//def MSKQLi : OFormL<0x12, 0x32, "MSKQL $RA,$L,$RC", []>; //Mask quadword low
220//def MSKWH : OForm< 0x12, 0x52, "MSKWH $RA,$RB,$RC", []>; //Mask word high
221//def MSKWHi : OFormL<0x12, 0x52, "MSKWH $RA,$L,$RC", []>; //Mask word high
222//def MSKWL : OForm< 0x12, 0x12, "MSKWL $RA,$RB,$RC", []>; //Mask word low
223//def MSKWLi : OFormL<0x12, 0x12, "MSKWL $RA,$L,$RC", []>; //Mask word low
Chris Lattnerae4be982005-10-20 04:21:06 +0000224
Andrew Lenharth4907d222005-10-20 00:28:31 +0000225def MULL : OForm< 0x13, 0x00, "mull $RA,$RB,$RC",
Chris Lattnerae4be982005-10-20 04:21:06 +0000226 [(set GPRC:$RC, (intop (mul GPRC:$RA, GPRC:$RB)))]>;
Andrew Lenharth4907d222005-10-20 00:28:31 +0000227def MULLi : OFormL<0x13, 0x00, "mull $RA,$L,$RC",
Andrew Lenharth892ade72005-10-20 14:42:48 +0000228 [(set GPRC:$RC, (intop (mul GPRC:$RA, immUExt8:$L)))]>;
Andrew Lenharth4907d222005-10-20 00:28:31 +0000229def MULQ : OForm< 0x13, 0x20, "mulq $RA,$RB,$RC",
230 [(set GPRC:$RC, (mul GPRC:$RA, GPRC:$RB))]>;
231def MULQi : OFormL<0x13, 0x20, "mulq $RA,$L,$RC",
232 [(set GPRC:$RC, (mul GPRC:$RA, immUExt8:$L))]>;
233def ORNOT : OForm< 0x11, 0x28, "ornot $RA,$RB,$RC",
234 [(set GPRC:$RC, (or GPRC:$RA, (not GPRC:$RB)))]>;
235def ORNOTi : OFormL<0x11, 0x28, "ornot $RA,$L,$RC", []>;
236// [(set GPRC:$RC, (or GPRC:$RA, (not immUExt8:$L)))]>;
237def S4ADDL : OForm< 0x10, 0x02, "s4addl $RA,$RB,$RC",
Chris Lattnerae4be982005-10-20 04:21:06 +0000238 [(set GPRC:$RC, (intop (add4 GPRC:$RA, GPRC:$RB)))]>;
Andrew Lenharth4907d222005-10-20 00:28:31 +0000239def S4ADDLi : OFormL<0x10, 0x02, "s4addl $RA,$L,$RC",
Andrew Lenharth892ade72005-10-20 14:42:48 +0000240 [(set GPRC:$RC, (intop (add4 GPRC:$RA, immUExt8:$L)))]>;
Andrew Lenharth4907d222005-10-20 00:28:31 +0000241def S4ADDQ : OForm< 0x10, 0x22, "s4addq $RA,$RB,$RC",
Andrew Lenharth892ade72005-10-20 14:42:48 +0000242 [(set GPRC:$RC, (add4 GPRC:$RA, GPRC:$RB))]>;
Andrew Lenharth4907d222005-10-20 00:28:31 +0000243def S4ADDQi : OFormL<0x10, 0x22, "s4addq $RA,$L,$RC",
Andrew Lenharth892ade72005-10-20 14:42:48 +0000244 [(set GPRC:$RC, (add4 GPRC:$RA, immUExt8:$L))]>;
Andrew Lenharth4907d222005-10-20 00:28:31 +0000245def S4SUBL : OForm< 0x10, 0x0B, "s4subl $RA,$RB,$RC",
Andrew Lenharth892ade72005-10-20 14:42:48 +0000246 [(set GPRC:$RC, (intop (sub4 GPRC:$RA, GPRC:$RB)))]>;
Andrew Lenharth4907d222005-10-20 00:28:31 +0000247def S4SUBLi : OFormL<0x10, 0x0B, "s4subl $RA,$L,$RC",
Andrew Lenharth892ade72005-10-20 14:42:48 +0000248 [(set GPRC:$RC, (intop (sub4 GPRC:$RA, immUExt8:$L)))]>;
Andrew Lenharth4907d222005-10-20 00:28:31 +0000249def S4SUBQ : OForm< 0x10, 0x2B, "s4subq $RA,$RB,$RC",
Andrew Lenharth892ade72005-10-20 14:42:48 +0000250 [(set GPRC:$RC, (sub4 GPRC:$RA, GPRC:$RB))]>;
Andrew Lenharth4907d222005-10-20 00:28:31 +0000251def S4SUBQi : OFormL<0x10, 0x2B, "s4subq $RA,$L,$RC",
Andrew Lenharth892ade72005-10-20 14:42:48 +0000252 [(set GPRC:$RC, (sub4 GPRC:$RA, immUExt8:$L))]>;
Andrew Lenharth4907d222005-10-20 00:28:31 +0000253def S8ADDL : OForm< 0x10, 0x12, "s8addl $RA,$RB,$RC",
Andrew Lenharth892ade72005-10-20 14:42:48 +0000254 [(set GPRC:$RC, (intop (add8 GPRC:$RA, GPRC:$RB)))]>;
Andrew Lenharth4907d222005-10-20 00:28:31 +0000255def S8ADDLi : OFormL<0x10, 0x12, "s8addl $RA,$L,$RC",
Andrew Lenharth892ade72005-10-20 14:42:48 +0000256 [(set GPRC:$RC, (intop (add8 GPRC:$RA, immUExt8:$L)))]>;
Andrew Lenharth4907d222005-10-20 00:28:31 +0000257def S8ADDQ : OForm< 0x10, 0x32, "s8addq $RA,$RB,$RC",
Andrew Lenharth892ade72005-10-20 14:42:48 +0000258 [(set GPRC:$RC, (add8 GPRC:$RA, GPRC:$RB))]>;
Andrew Lenharth4907d222005-10-20 00:28:31 +0000259def S8ADDQi : OFormL<0x10, 0x32, "s8addq $RA,$L,$RC",
Andrew Lenharth892ade72005-10-20 14:42:48 +0000260 [(set GPRC:$RC, (add8 GPRC:$RA, immUExt8:$L))]>;
Andrew Lenharth4907d222005-10-20 00:28:31 +0000261def S8SUBL : OForm< 0x10, 0x1B, "s8subl $RA,$RB,$RC",
Chris Lattnerae4be982005-10-20 04:21:06 +0000262 [(set GPRC:$RC, (intop (sub8 GPRC:$RA, GPRC:$RB)))]>;
Andrew Lenharth4907d222005-10-20 00:28:31 +0000263def S8SUBLi : OFormL<0x10, 0x1B, "s8subl $RA,$L,$RC",
Andrew Lenharth892ade72005-10-20 14:42:48 +0000264 [(set GPRC:$RC, (intop (sub8 GPRC:$RA, immUExt8:$L)))]>;
Andrew Lenharth4907d222005-10-20 00:28:31 +0000265def S8SUBQ : OForm< 0x10, 0x3B, "s8subq $RA,$RB,$RC",
Andrew Lenharth892ade72005-10-20 14:42:48 +0000266 [(set GPRC:$RC, (sub8 GPRC:$RA, GPRC:$RB))]>;
Andrew Lenharth4907d222005-10-20 00:28:31 +0000267def S8SUBQi : OFormL<0x10, 0x3B, "s8subq $RA,$L,$RC",
Andrew Lenharth892ade72005-10-20 14:42:48 +0000268 [(set GPRC:$RC, (sub8 GPRC:$RA, immUExt8:$L))]>;
Andrew Lenharth1f347a32005-10-20 23:58:36 +0000269def SEXTB : OForm2<0x1C, 0x00, "sextb $RB,$RC",
Andrew Lenharth964b6aa2005-10-20 19:39:24 +0000270 [(set GPRC:$RC, (sext_inreg GPRC:$RB, i8))]>;
Andrew Lenharth1f347a32005-10-20 23:58:36 +0000271def SEXTW : OForm2<0x1C, 0x01, "sextw $RB,$RC",
Andrew Lenharth964b6aa2005-10-20 19:39:24 +0000272 [(set GPRC:$RC, (sext_inreg GPRC:$RB, i16))]>;
Andrew Lenharth4907d222005-10-20 00:28:31 +0000273def SL : OForm< 0x12, 0x39, "sll $RA,$RB,$RC",
274 [(set GPRC:$RC, (shl GPRC:$RA, GPRC:$RB))]>;
275def SLi : OFormL<0x12, 0x39, "sll $RA,$L,$RC",
276 [(set GPRC:$RC, (shl GPRC:$RA, immUExt8:$L))]>;
277def SRA : OForm< 0x12, 0x3C, "sra $RA,$RB,$RC",
278 [(set GPRC:$RC, (sra GPRC:$RA, GPRC:$RB))]>;
279def SRAi : OFormL<0x12, 0x3C, "sra $RA,$L,$RC",
280 [(set GPRC:$RC, (sra GPRC:$RA, immUExt8:$L))]>;
281def SRL : OForm< 0x12, 0x34, "srl $RA,$RB,$RC",
282 [(set GPRC:$RC, (srl GPRC:$RA, GPRC:$RB))]>;
283def SRLi : OFormL<0x12, 0x34, "srl $RA,$L,$RC",
284 [(set GPRC:$RC, (srl GPRC:$RA, immUExt8:$L))]>;
285def SUBL : OForm< 0x10, 0x09, "subl $RA,$RB,$RC",
Andrew Lenharth892ade72005-10-20 14:42:48 +0000286 [(set GPRC:$RC, (intop (sub GPRC:$RA, GPRC:$RB)))]>;
Andrew Lenharth4907d222005-10-20 00:28:31 +0000287def SUBLi : OFormL<0x10, 0x09, "subl $RA,$L,$RC",
Andrew Lenharth892ade72005-10-20 14:42:48 +0000288 [(set GPRC:$RC, (intop (sub GPRC:$RA, immUExt8:$L)))]>;
Andrew Lenharth4907d222005-10-20 00:28:31 +0000289def SUBQ : OForm< 0x10, 0x29, "subq $RA,$RB,$RC",
290 [(set GPRC:$RC, (sub GPRC:$RA, GPRC:$RB))]>;
291def SUBQi : OFormL<0x10, 0x29, "subq $RA,$L,$RC",
292 [(set GPRC:$RC, (sub GPRC:$RA, immUExt8:$L))]>;
Andrew Lenharth964b6aa2005-10-20 19:39:24 +0000293def UMULH : OForm< 0x13, 0x30, "umulh $RA,$RB,$RC",
294 [(set GPRC:$RC, (mulhu GPRC:$RA, GPRC:$RB))]>;
295def UMULHi : OFormL<0x13, 0x30, "umulh $RA,$L,$RC",
296 [(set GPRC:$RC, (mulhu GPRC:$RA, immUExt8:$L))]>;
Andrew Lenharth4907d222005-10-20 00:28:31 +0000297def XOR : OForm< 0x11, 0x40, "xor $RA,$RB,$RC",
298 [(set GPRC:$RC, (xor GPRC:$RA, GPRC:$RB))]>;
299def XORi : OFormL<0x11, 0x40, "xor $RA,$L,$RC",
300 [(set GPRC:$RC, (xor GPRC:$RA, immUExt8:$L))]>;
Andrew Lenharthfe9234d2005-10-21 01:24:05 +0000301//FIXME: what to do about zap? the cases it catches are very complex
Andrew Lenharth4907d222005-10-20 00:28:31 +0000302def ZAP : OForm< 0x12, 0x30, "zap $RA,$RB,$RC", []>; //Zero bytes
Andrew Lenharthfe9234d2005-10-21 01:24:05 +0000303//ZAPi is useless give ZAPNOTi
Andrew Lenharth4907d222005-10-20 00:28:31 +0000304def ZAPi : OFormL<0x12, 0x30, "zap $RA,$L,$RC", []>; //Zero bytes
Andrew Lenharthfe9234d2005-10-21 01:24:05 +0000305//FIXME: what to do about zapnot? see ZAP :)
Andrew Lenharth4907d222005-10-20 00:28:31 +0000306def ZAPNOT : OForm< 0x12, 0x31, "zapnot $RA,$RB,$RC", []>; //Zero bytes not
Andrew Lenharth8b7f14e2005-10-23 03:43:48 +0000307def ZAPNOTi : OFormL<0x12, 0x31, "zapnot $RA,$L,$RC",
308 [(set GPRC:$RC, (and GPRC:$RA, immZAP:$L))]>;
Andrew Lenharth2d6f0222005-01-24 19:44:07 +0000309
Andrew Lenharth3d65d312005-01-27 03:49:45 +0000310//Comparison, int
Andrew Lenharth2012cc02005-10-26 18:44:45 +0000311//So this is a waste of what this instruction can do, but it still saves something
312def CMPBGE : OForm< 0x10, 0x0F, "cmpbge $RA,$RB,$RC",
313 [(set GPRC:$RC, (setuge (and GPRC:$RA, 255), (and GPRC:$RB, 255)))]>;
314def CMPBGEi : OFormL<0x10, 0x0F, "cmpbge $RA,$L,$RC",
315 [(set GPRC:$RC, (setuge (and GPRC:$RA, 255), immUExt8:$L))]>;
316def CMPEQ : OForm< 0x10, 0x2D, "cmpeq $RA,$RB,$RC",
317 [(set GPRC:$RC, (seteq GPRC:$RA, GPRC:$RB))]>;
318def CMPEQi : OFormL<0x10, 0x2D, "cmpeq $RA,$L,$RC",
319 [(set GPRC:$RC, (seteq GPRC:$RA, immUExt8:$L))]>;
320def CMPLE : OForm< 0x10, 0x6D, "cmple $RA,$RB,$RC",
321 [(set GPRC:$RC, (setle GPRC:$RA, GPRC:$RB))]>;
322def CMPLEi : OFormL<0x10, 0x6D, "cmple $RA,$L,$RC",
323 [(set GPRC:$RC, (setle GPRC:$RA, immUExt8:$L))]>;
324def CMPLT : OForm< 0x10, 0x4D, "cmplt $RA,$RB,$RC",
325 [(set GPRC:$RC, (setlt GPRC:$RA, GPRC:$RB))]>;
326def CMPLTi : OFormL<0x10, 0x4D, "cmplt $RA,$L,$RC",
327 [(set GPRC:$RC, (setlt GPRC:$RA, immUExt8:$L))]>;
328def CMPULE : OForm< 0x10, 0x3D, "cmpule $RA,$RB,$RC",
329 [(set GPRC:$RC, (setule GPRC:$RA, GPRC:$RB))]>;
330def CMPULEi : OFormL<0x10, 0x3D, "cmpule $RA,$L,$RC",
331 [(set GPRC:$RC, (setule GPRC:$RA, immUExt8:$L))]>;
332def CMPULT : OForm< 0x10, 0x1D, "cmpult $RA,$RB,$RC",
333 [(set GPRC:$RC, (setlt GPRC:$RA, GPRC:$RB))]>;
334def CMPULTi : OFormL<0x10, 0x1D, "cmpult $RA,$L,$RC",
335 [(set GPRC:$RC, (setlt GPRC:$RA, immUExt8:$L))]>;
336
337//Patterns for unsupported int comparisons
338def : Pat<(setueq GPRC:$X, GPRC:$Y), (CMPEQ GPRC:$X, GPRC:$Y)>;
339def : Pat<(setueq GPRC:$X, immUExt8:$Y), (CMPEQi GPRC:$X, immUExt8:$Y)>;
340
341def : Pat<(setugt GPRC:$X, GPRC:$Y), (CMPULT GPRC:$Y, GPRC:$X)>;
342def : Pat<(setugt immUExt8:$X, GPRC:$Y), (CMPULTi GPRC:$Y, immUExt8:$X)>;
343
344def : Pat<(setuge GPRC:$X, GPRC:$Y), (CMPULE GPRC:$Y, GPRC:$X)>;
345def : Pat<(setuge immUExt8:$X, GPRC:$Y), (CMPULEi GPRC:$Y, immUExt8:$X)>;
346
347def : Pat<(setgt GPRC:$X, GPRC:$Y), (CMPLT GPRC:$Y, GPRC:$X)>;
348def : Pat<(setgt immUExt8:$X, GPRC:$Y), (CMPLTi GPRC:$Y, immUExt8:$X)>;
349
350def : Pat<(setge GPRC:$X, GPRC:$Y), (CMPLE GPRC:$Y, GPRC:$X)>;
351def : Pat<(setge immUExt8:$X, GPRC:$Y), (CMPLEi GPRC:$Y, immUExt8:$X)>;
352
353def : Pat<(setne GPRC:$X, GPRC:$Y), (CMPEQi (CMPEQ GPRC:$X, GPRC:$Y), 0)>;
354def : Pat<(setne GPRC:$X, immUExt8:$Y), (CMPEQi (CMPEQi GPRC:$X, immUExt8:$Y), 0)>;
355
356def : Pat<(setune GPRC:$X, GPRC:$Y), (CMPEQi (CMPEQ GPRC:$X, GPRC:$Y), 0)>;
357def : Pat<(setune GPRC:$X, immUExt8:$Y), (CMPEQi (CMPEQ GPRC:$X, immUExt8:$Y), 0)>;
358
Andrew Lenharth3d65d312005-01-27 03:49:45 +0000359
Andrew Lenharth4907d222005-10-20 00:28:31 +0000360let isReturn = 1, isTerminator = 1 in
Andrew Lenharthf3f951a2005-07-22 20:50:29 +0000361 def RET : MbrForm< 0x1A, 0x02, (ops GPRC:$RD, GPRC:$RS, s64imm:$DISP), "ret $RD,($RS),$DISP">; //Return from subroutine
Andrew Lenharth4907d222005-10-20 00:28:31 +0000362//DAG Version:
363let isReturn = 1, isTerminator = 1, Ra = 31, Rb = 26, disp = 1, Uses = [R26] in
364 def RETDAG : MbrForm< 0x1A, 0x02, (ops), "ret $$31,($$26),1">; //Return from subroutine
Andrew Lenharth304d0f32005-01-22 23:41:55 +0000365
Andrew Lenharthf3f951a2005-07-22 20:50:29 +0000366def JMP : MbrForm< 0x1A, 0x00, (ops GPRC:$RD, GPRC:$RS, GPRC:$DISP), "jmp $RD,($RS),$DISP">; //Jump
Andrew Lenharth7b2a5272005-01-30 20:42:36 +0000367let isCall = 1,
368 Defs = [R0, R1, R2, R3, R4, R5, R6, R7, R8, R16, R17, R18, R19,
Andrew Lenharth63f2ab22005-02-10 06:25:22 +0000369 R20, R21, R22, R23, R24, R25, R27, R28, R29,
Andrew Lenharth7b2a5272005-01-30 20:42:36 +0000370 F0, F1,
371 F10, F11, F12, F13, F14, F15, F16, F17, F18, F19,
Andrew Lenharth1e0d9bd2005-04-14 17:34:20 +0000372 F20, F21, F22, F23, F24, F25, F26, F27, F28, F29, F30], Uses = [R29] in {
Andrew Lenharthf3f951a2005-07-22 20:50:29 +0000373 def JSR : MbrForm< 0x1A, 0x01, (ops GPRC:$RD, GPRC:$RS, s14imm:$DISP), "jsr $RD,($RS),$DISP">; //Jump to subroutine
374 def BSR : BForm<0x34, "bsr $RA,$DISP">; //Branch to subroutine
Andrew Lenharth7b2a5272005-01-30 20:42:36 +0000375}
Andrew Lenharth8b7f14e2005-10-23 03:43:48 +0000376let isCall = 1,
377 Defs = [R0, R1, R2, R3, R4, R5, R6, R7, R8, R16, R17, R18, R19,
378 R20, R21, R22, R23, R24, R25, R26, R27, R28, R29,
379 F0, F1,
380 F10, F11, F12, F13, F14, F15, F16, F17, F18, F19,
381 F20, F21, F22, F23, F24, F25, F26, F27, F28, F29, F30], Uses = [R27, R29] in {
382 def JSRDAG : MbrForm< 0x1A, 0x01, (ops ), "jsr $$26,($$27),0">; //Jump to subroutine
383}
Andrew Lenharthcf8bf382005-07-01 19:12:13 +0000384let isCall = 1, Defs = [R24, R25, R27, R28], Uses = [R24, R25] in
Andrew Lenharthf3f951a2005-07-22 20:50:29 +0000385 def JSRs : MbrForm< 0x1A, 0x01, (ops GPRC:$RD, GPRC:$RS, s14imm:$DISP), "jsr $RD,($RS),$DISP">; //Jump to div or rem
Andrew Lenharthcf8bf382005-07-01 19:12:13 +0000386
Andrew Lenharthf3f951a2005-07-22 20:50:29 +0000387def JSR_COROUTINE : MbrForm< 0x1A, 0x03, (ops GPRC:$RD, GPRC:$RS, s14imm:$DISP), "jsr_coroutine $RD,($RS),$DISP">; //Jump to subroutine return
388def BR : BForm<0x30, "br $RA,$DISP">; //Branch
Andrew Lenharth304d0f32005-01-22 23:41:55 +0000389
Andrew Lenharth756fbeb2005-10-22 22:06:58 +0000390def BR_DAG : BFormD<0x30, "br $$31,$DISP">; //Branch
391
Andrew Lenharth3e98fde2005-01-26 21:54:09 +0000392//Stores, int
Andrew Lenharthf3f951a2005-07-22 20:50:29 +0000393def STB : MForm<0x0E, "stb $RA,$DISP($RB)">; // Store byte
394def STW : MForm<0x0D, "stw $RA,$DISP($RB)">; // Store word
395def STL : MForm<0x2C, "stl $RA,$DISP($RB)">; // Store longword
396def STQ : MForm<0x2D, "stq $RA,$DISP($RB)">; //Store quadword
Andrew Lenharth304d0f32005-01-22 23:41:55 +0000397
Andrew Lenharth3e98fde2005-01-26 21:54:09 +0000398//Loads, int
Andrew Lenharthf3f951a2005-07-22 20:50:29 +0000399def LDL : MForm<0x28, "ldl $RA,$DISP($RB)">; // Load sign-extended longword
400def LDQ : MForm<0x29, "ldq $RA,$DISP($RB)">; //Load quadword
401def LDBU : MForm<0x0A, "ldbu $RA,$DISP($RB)">; //Load zero-extended byte
402def LDWU : MForm<0x0C, "ldwu $RA,$DISP($RB)">; //Load zero-extended word
Andrew Lenharth2f8fb772005-01-25 00:35:34 +0000403
Andrew Lenharth3e98fde2005-01-26 21:54:09 +0000404//Stores, float
Andrew Lenharthf3f951a2005-07-22 20:50:29 +0000405def STS : MForm<0x26, "sts $RA,$DISP($RB)">; //Store S_floating
406def STT : MForm<0x27, "stt $RA,$DISP($RB)">; //Store T_floating
Andrew Lenharth304d0f32005-01-22 23:41:55 +0000407
Andrew Lenharth3e98fde2005-01-26 21:54:09 +0000408//Loads, float
Andrew Lenharthf3f951a2005-07-22 20:50:29 +0000409def LDS : MForm<0x22, "lds $RA,$DISP($RB)">; //Load S_floating
410def LDT : MForm<0x23, "ldt $RA,$DISP($RB)">; //Load T_floating
Andrew Lenharthc1faced2005-02-01 01:37:24 +0000411
412//Load address
Andrew Lenharthf3f951a2005-07-22 20:50:29 +0000413def LDA : MForm<0x08, "lda $RA,$DISP($RB)">; //Load address
414def LDAH : MForm<0x09, "ldah $RA,$DISP($RB)">; //Load address high
Andrew Lenharth3e98fde2005-01-26 21:54:09 +0000415
416
Andrew Lenharthc7989ce2005-06-29 00:31:08 +0000417//Loads, int, Rellocated Low form
Andrew Lenharth1f3e8082005-08-12 16:14:08 +0000418def LDLr : MForm<0x28, "ldl $RA,$DISP($RB)\t\t!gprellow">; // Load sign-extended longword
419def LDQr : MForm<0x29, "ldq $RA,$DISP($RB)\t\t!gprellow">; //Load quadword
420def LDBUr : MForm<0x0A, "ldbu $RA,$DISP($RB)\t\t!gprellow">; //Load zero-extended byte
421def LDWUr : MForm<0x0C, "ldwu $RA,$DISP($RB)\t\t!gprellow">; //Load zero-extended word
Andrew Lenharthfe895e32005-06-27 17:15:36 +0000422
Andrew Lenharthc7989ce2005-06-29 00:31:08 +0000423//Loads, float, Rellocated Low form
Andrew Lenharth1f3e8082005-08-12 16:14:08 +0000424def LDSr : MForm<0x22, "lds $RA,$DISP($RB)\t\t!gprellow">; //Load S_floating
425def LDTr : MForm<0x23, "ldt $RA,$DISP($RB)\t\t!gprellow">; //Load T_floating
Andrew Lenharthfe895e32005-06-27 17:15:36 +0000426
Andrew Lenharthc7989ce2005-06-29 00:31:08 +0000427//Load address, rellocated low and high form
Andrew Lenharth1f3e8082005-08-12 16:14:08 +0000428def LDAr : MForm<0x08, "lda $RA,$DISP($RB)\t\t!gprellow">; //Load address
429def LDAHr : MForm<0x09, "ldah $RA,$DISP($RB)\t\t!gprelhigh">; //Load address high
Andrew Lenharthf3f951a2005-07-22 20:50:29 +0000430
431//load address, rellocated gpdist form
Andrew Lenharth1f3e8082005-08-12 16:14:08 +0000432def LDAg : MgForm<0x08, "lda $RA,0($RB)\t\t!gpdisp!$NUM">; //Load address
433def LDAHg : MgForm<0x09, "ldah $RA,0($RB)\t\t!gpdisp!$NUM">; //Load address
Andrew Lenharthf3f951a2005-07-22 20:50:29 +0000434
Andrew Lenharthfe895e32005-06-27 17:15:36 +0000435
Andrew Lenharthc7989ce2005-06-29 00:31:08 +0000436//Load quad, rellocated literal form
Andrew Lenharth1f3e8082005-08-12 16:14:08 +0000437def LDQl : MForm<0x29, "ldq $RA,$DISP($RB)\t\t!literal">; //Load quadword
Andrew Lenharthfe895e32005-06-27 17:15:36 +0000438
Andrew Lenharthfce587e2005-06-29 00:39:17 +0000439//Stores, int
Andrew Lenharth1f3e8082005-08-12 16:14:08 +0000440def STBr : MForm<0x0E, "stb $RA,$DISP($RB)\t\t!gprellow">; // Store byte
441def STWr : MForm<0x0D, "stw $RA,$DISP($RB)\t\t!gprellow">; // Store word
442def STLr : MForm<0x2C, "stl $RA,$DISP($RB)\t\t!gprellow">; // Store longword
443def STQr : MForm<0x2D, "stq $RA,$DISP($RB)\t\t!gprellow">; //Store quadword
Andrew Lenharthfce587e2005-06-29 00:39:17 +0000444
445//Stores, float
Andrew Lenharth1f3e8082005-08-12 16:14:08 +0000446def STSr : MForm<0x26, "sts $RA,$DISP($RB)\t\t!gprellow">; //Store S_floating
447def STTr : MForm<0x27, "stt $RA,$DISP($RB)\t\t!gprellow">; //Store T_floating
Andrew Lenharthfce587e2005-06-29 00:39:17 +0000448
449
Andrew Lenharth3e98fde2005-01-26 21:54:09 +0000450//Branches, int
Andrew Lenharthf3f951a2005-07-22 20:50:29 +0000451def BEQ : BForm<0x39, "beq $RA,$DISP">; //Branch if = zero
452def BGE : BForm<0x3E, "bge $RA,$DISP">; //Branch if >= zero
453def BGT : BForm<0x3F, "bgt $RA,$DISP">; //Branch if > zero
454def BLBC : BForm<0x38, "blbc $RA,$DISP">; //Branch if low bit clear
455def BLBS : BForm<0x3C, "blbs $RA,$DISP">; //Branch if low bit set
456def BLE : BForm<0x3B, "ble $RA,$DISP">; //Branch if <= zero
457def BLT : BForm<0x3A, "blt $RA,$DISP">; //Branch if < zero
458def BNE : BForm<0x3D, "bne $RA,$DISP">; //Branch if != zero
Andrew Lenharth304d0f32005-01-22 23:41:55 +0000459
Andrew Lenharth3e98fde2005-01-26 21:54:09 +0000460//Branches, float
Andrew Lenharthf3f951a2005-07-22 20:50:29 +0000461def FBEQ : FBForm<0x31, "fbeq $RA,$DISP">; //Floating branch if = zero
462def FBGE : FBForm<0x36, "fbge $RA,$DISP">; //Floating branch if >= zero
463def FBGT : FBForm<0x37, "fbgt $RA,$DISP">; //Floating branch if > zero
464def FBLE : FBForm<0x33, "fble $RA,$DISP">; //Floating branch if <= zero
465def FBLT : FBForm<0x32, "fblt $RA,$DISP">; //Floating branch if < zero
466def FBNE : FBForm<0x35, "fbne $RA,$DISP">; //Floating branch if != zero
Andrew Lenharth3e98fde2005-01-26 21:54:09 +0000467
Andrew Lenharth51b8d542005-11-11 16:47:30 +0000468def RPCC : MfcForm<0x18, 0xC000, "rpcc $RA">; //Read process cycle counter
469
Andrew Lenharth3e98fde2005-01-26 21:54:09 +0000470//Basic Floating point ops
Andrew Lenharth3e98fde2005-01-26 21:54:09 +0000471
Andrew Lenharth5cefc5e2005-11-09 19:17:08 +0000472//Floats
Andrew Lenharth98a32d02005-01-26 23:56:48 +0000473
Andrew Lenharth5cefc5e2005-11-09 19:17:08 +0000474let OperandList = (ops F4RC:$RC, F4RC:$RB), Fa = 31 in
475def SQRTS : FPForm<0x14, 0x58B, "sqrts/su $RB,$RC",
476 [(set F4RC:$RC, (fsqrt F4RC:$RB))]>;
477
478let OperandList = (ops F4RC:$RC, F4RC:$RA, F4RC:$RB) in {
479def ADDS : FPForm<0x16, 0x580, "adds/su $RA,$RB,$RC",
480 [(set F4RC:$RC, (fadd F4RC:$RA, F4RC:$RB))]>;
481def SUBS : FPForm<0x16, 0x581, "subs/su $RA,$RB,$RC",
482 [(set F4RC:$RC, (fsub F4RC:$RA, F4RC:$RB))]>;
483def DIVS : FPForm<0x16, 0x583, "divs/su $RA,$RB,$RC",
484 [(set F4RC:$RC, (fdiv F4RC:$RA, F4RC:$RB))]>;
485def MULS : FPForm<0x16, 0x582, "muls/su $RA,$RB,$RC",
486 [(set F4RC:$RC, (fmul F4RC:$RA, F4RC:$RB))]>;
487
488def CPYSS : FPForm<0x17, 0x020, "cpys $RA,$RB,$RC",[]>; //Copy sign
489def CPYSES : FPForm<0x17, 0x022, "cpyse $RA,$RB,$RC",[]>; //Copy sign and exponent
490def CPYSNS : FPForm<0x17, 0x021, "cpysn $RA,$RB,$RC",[]>; //Copy sign negate
491}
492
493//Doubles
494
495let OperandList = (ops F8RC:$RC, F8RC:$RB), Fa = 31 in
496def SQRTT : FPForm<0x14, 0x5AB, "sqrtt/su $RB,$RC",
497 [(set F8RC:$RC, (fsqrt F8RC:$RB))]>;
498
499let OperandList = (ops F8RC:$RC, F8RC:$RA, F8RC:$RB) in {
500def ADDT : FPForm<0x16, 0x5A0, "addt/su $RA,$RB,$RC",
501 [(set F8RC:$RC, (fadd F8RC:$RA, F8RC:$RB))]>;
502def SUBT : FPForm<0x16, 0x5A1, "subt/su $RA,$RB,$RC",
503 [(set F8RC:$RC, (fsub F8RC:$RA, F8RC:$RB))]>;
504def DIVT : FPForm<0x16, 0x5A3, "divt/su $RA,$RB,$RC",
505 [(set F8RC:$RC, (fdiv F8RC:$RA, F8RC:$RB))]>;
506def MULT : FPForm<0x16, 0x5A2, "mult/su $RA,$RB,$RC",
507 [(set F8RC:$RC, (fmul F8RC:$RA, F8RC:$RB))]>;
508
509def CPYST : FPForm<0x17, 0x020, "cpys $RA,$RB,$RC",[]>; //Copy sign
510def CPYSET : FPForm<0x17, 0x022, "cpyse $RA,$RB,$RC",[]>; //Copy sign and exponent
511def CPYSNT : FPForm<0x17, 0x021, "cpysn $RA,$RB,$RC",[]>; //Copy sign negate
512
513def CMPTEQ : FPForm<0x16, 0x5A5, "cmpteq/su $RA,$RB,$RC", []>;
514// [(set F8RC:$RC, (seteq F8RC:$RA, F8RC:$RB))]>;
515def CMPTLE : FPForm<0x16, 0x5A7, "cmptle/su $RA,$RB,$RC", []>;
516// [(set F8RC:$RC, (setle F8RC:$RA, F8RC:$RB))]>;
517def CMPTLT : FPForm<0x16, 0x5A6, "cmptlt/su $RA,$RB,$RC", []>;
518// [(set F8RC:$RC, (setlt F8RC:$RA, F8RC:$RB))]>;
519def CMPTUN : FPForm<0x16, 0x5A4, "cmptun/su $RA,$RB,$RC", []>;
520// [(set F8RC:$RC, (setuo F8RC:$RA, F8RC:$RB))]>;
521}
522//TODO: Add lots more FP patterns
523
524
525
526let OperandList = (ops GPRC:$RC, F4RC:$RA), Fb = 31 in
527def FTOIS : FPForm<0x1C, 0x078, "ftois $RA,$RC",[]>; //Floating to integer move, S_floating
528let OperandList = (ops GPRC:$RC, F8RC:$RA), Fb = 31 in
529def FTOIT : FPForm<0x1C, 0x070, "ftoit $RA,$RC",[]>; //Floating to integer move, T_floating
530let OperandList = (ops F4RC:$RC, GPRC:$RA), Fb = 31 in
531def ITOFS : FPForm<0x14, 0x004, "itofs $RA,$RC",[]>; //Integer to floating move, S_floating
532let OperandList = (ops F8RC:$RC, GPRC:$RA), Fb = 31 in
533def ITOFT : FPForm<0x14, 0x024, "itoft $RA,$RC",[]>; //Integer to floating move, T_floating
534
535
536let OperandList = (ops F4RC:$RC, F8RC:$RB), Fa = 31 in
537def CVTQS : FPForm<0x16, 0x7BC, "cvtqs/sui $RB,$RC",[]>; //Convert quadword to S_floating
538let OperandList = (ops F8RC:$RC, F8RC:$RB), Fa = 31 in
539def CVTQT : FPForm<0x16, 0x7BE, "cvtqt/sui $RB,$RC",[]>; //Convert quadword to T_floating
540let OperandList = (ops F8RC:$RC, F8RC:$RB), Fa = 31 in
541def CVTTQ : FPForm<0x16, 0x52F, "cvttq/svc $RB,$RC",[]>; //Convert T_floating to quadword
542let OperandList = (ops F8RC:$RC, F4RC:$RB), Fa = 31 in
543def CVTST : FPForm<0x16, 0x6AC, "cvtst/s $RB,$RC",
544 [(set F8RC:$RC, (fextend F4RC:$RB))]>;
545let OperandList = (ops F4RC:$RC, F8RC:$RB), Fa = 31 in
546def CVTTS : FPForm<0x16, 0x7AC, "cvtts/sui $RB,$RC",
547 [(set F4RC:$RC, (fround F8RC:$RB))]>;
Andrew Lenharthd2bb9602005-01-27 07:50:35 +0000548
Andrew Lenharth3e98fde2005-01-26 21:54:09 +0000549//S_floating : IEEE Single
550//T_floating : IEEE Double
551
Andrew Lenharth5cefc5e2005-11-09 19:17:08 +0000552//Unused instructions
Andrew Lenharth304d0f32005-01-22 23:41:55 +0000553//Mnemonic Format Opcode Description
Andrew Lenharth304d0f32005-01-22 23:41:55 +0000554//CALL_PAL Pcd 00 Trap to PALcode
555//ECB Mfc 18.E800 Evict cache block
556//EXCB Mfc 18.0400 Exception barrier
557//FETCH Mfc 18.8000 Prefetch data
558//FETCH_M Mfc 18.A000 Prefetch data, modify intent
Andrew Lenharth304d0f32005-01-22 23:41:55 +0000559//LDL_L Mem 2A Load sign-extended longword locked
560//LDQ_L Mem 2B Load quadword locked
561//LDQ_U Mem 0B Load unaligned quadword
562//MB Mfc 18.4000 Memory barrier
Andrew Lenharth304d0f32005-01-22 23:41:55 +0000563//STL_C Mem 2E Store longword conditional
564//STQ_C Mem 2F Store quadword conditional
565//STQ_U Mem 0F Store unaligned quadword
566//TRAPB Mfc 18.0000 Trap barrier
567//WH64 Mfc 18.F800 Write hint  64 bytes
568//WMB Mfc 18.4400 Write memory barrier
Andrew Lenharth304d0f32005-01-22 23:41:55 +0000569//MF_FPCR F-P 17.025 Move from FPCR
570//MT_FPCR F-P 17.024 Move to FPCR
Andrew Lenharth5cefc5e2005-11-09 19:17:08 +0000571//There are in the Multimedia extentions, so let's not use them yet
572//def MAXSB8 : OForm<0x1C, 0x3E, "MAXSB8 $RA,$RB,$RC">; //Vector signed byte maximum
573//def MAXSW4 : OForm< 0x1C, 0x3F, "MAXSW4 $RA,$RB,$RC">; //Vector signed word maximum
574//def MAXUB8 : OForm<0x1C, 0x3C, "MAXUB8 $RA,$RB,$RC">; //Vector unsigned byte maximum
575//def MAXUW4 : OForm< 0x1C, 0x3D, "MAXUW4 $RA,$RB,$RC">; //Vector unsigned word maximum
576//def MINSB8 : OForm< 0x1C, 0x38, "MINSB8 $RA,$RB,$RC">; //Vector signed byte minimum
577//def MINSW4 : OForm< 0x1C, 0x39, "MINSW4 $RA,$RB,$RC">; //Vector signed word minimum
578//def MINUB8 : OForm< 0x1C, 0x3A, "MINUB8 $RA,$RB,$RC">; //Vector unsigned byte minimum
579//def MINUW4 : OForm< 0x1C, 0x3B, "MINUW4 $RA,$RB,$RC">; //Vector unsigned word minimum
580//def PERR : OForm< 0x1C, 0x31, "PERR $RA,$RB,$RC">; //Pixel error
581//def PKLB : OForm< 0x1C, 0x37, "PKLB $RA,$RB,$RC">; //Pack longwords to bytes
582//def PKWB : OForm<0x1C, 0x36, "PKWB $RA,$RB,$RC">; //Pack words to bytes
583//def UNPKBL : OForm< 0x1C, 0x35, "UNPKBL $RA,$RB,$RC">; //Unpack bytes to longwords
584//def UNPKBW : OForm< 0x1C, 0x34, "UNPKBW $RA,$RB,$RC">; //Unpack bytes to words
585//CVTLQ F-P 17.010 Convert longword to quadword
586//CVTQL F-P 17.030 Convert quadword to longword
587//def AMASK : OForm< 0x11, 0x61, "AMASK $RA,$RB,$RC", []>; //Architecture mask
588//def AMASKi : OFormL<0x11, 0x61, "AMASK $RA,$L,$RC", []>; //Architecture mask
589
590
591
Andrew Lenharth756fbeb2005-10-22 22:06:58 +0000592
593def : Pat<(i64 immSExt16:$imm),
594 (LDA immSExt16:$imm, R31)>;