blob: 429e9a6f63750be22a9bbf61a83fbeda5a91d07d [file] [log] [blame]
Duraid Madina91ed0a12005-03-17 18:17:03 +00001//===- IA64InstrInfo.td - Describe the IA64 Instruction Set -----*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by Duraid Madina and is distributed under the
6// University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file describes the IA64 instruction set, defining the instructions, and
11// properties of the instructions which are needed for code generation, machine
12// code emission, and analysis.
13//
14//===----------------------------------------------------------------------===//
15
16include "IA64InstrFormats.td"
17
Duraid Madinac252f332005-10-29 04:13:40 +000018def u2imm : Operand<i8>;
Duraid Madina91ed0a12005-03-17 18:17:03 +000019def u6imm : Operand<i8>;
Duraid Madinab484f7c2005-04-07 12:32:24 +000020def s8imm : Operand<i8> {
21 let PrintMethod = "printS8ImmOperand";
22}
Duraid Madinaf221c262005-10-28 17:46:35 +000023def s14imm : Operand<i64> {
Duraid Madinab484f7c2005-04-07 12:32:24 +000024 let PrintMethod = "printS14ImmOperand";
25}
Duraid Madinafb43ef72005-04-11 05:55:56 +000026def s22imm : Operand<i32> {
27 let PrintMethod = "printS22ImmOperand";
Duraid Madina91ed0a12005-03-17 18:17:03 +000028}
29def u64imm : Operand<i64> {
30 let PrintMethod = "printU64ImmOperand";
31}
Duraid Madina0a7c2b92005-04-14 10:08:01 +000032def s64imm : Operand<i64> {
33 let PrintMethod = "printS64ImmOperand";
34}
Duraid Madina91ed0a12005-03-17 18:17:03 +000035
Duraid Madinaf221c262005-10-28 17:46:35 +000036let PrintMethod = "printGlobalOperand" in
37 def globaladdress : Operand<i64>;
38
Duraid Madina91ed0a12005-03-17 18:17:03 +000039// the asmprinter needs to know about calls
40let PrintMethod = "printCallOperand" in
41 def calltarget : Operand<i64>;
42
Duraid Madinaf221c262005-10-28 17:46:35 +000043/* new daggy action!!! */
44
Duraid Madinac252f332005-10-29 04:13:40 +000045def is32ones : PatLeaf<(i64 imm), [{
46 // is32ones predicate - True if the immediate is 0x00000000FFFFFFFF
47 // Used to create ZXT4s appropriately
Duraid Madina7abaf902005-10-29 16:08:30 +000048 uint64_t v = (uint64_t)N->getValue();
Duraid Madinac252f332005-10-29 04:13:40 +000049 return (v == 0x00000000FFFFFFFFLL);
50}]>;
51
Duraid Madina7abaf902005-10-29 16:08:30 +000052// isMIXable predicates - True if the immediate is
53// 0xFF00FF00FF00FF00, 0x00FF00FF00FF00FF
54// etc, through 0x00000000FFFFFFFF
55// Used to test for the suitability of mix*
56def isMIX1Lable: PatLeaf<(i64 imm), [{
57 return((uint64_t)N->getValue()==0xFF00FF00FF00FF00LL);
58}]>;
59def isMIX1Rable: PatLeaf<(i64 imm), [{
60 return((uint64_t)N->getValue()==0x00FF00FF00FF00FFLL);
61}]>;
62def isMIX2Lable: PatLeaf<(i64 imm), [{
63 return((uint64_t)N->getValue()==0xFFFF0000FFFF0000LL);
64}]>;
65def isMIX2Rable: PatLeaf<(i64 imm), [{
66 return((uint64_t)N->getValue()==0x0000FFFF0000FFFFLL);
67}]>;
68def isMIX4Lable: PatLeaf<(i64 imm), [{
69 return((uint64_t)N->getValue()==0xFFFFFFFF00000000LL);
70}]>;
71def isMIX4Rable: PatLeaf<(i64 imm), [{
72 return((uint64_t)N->getValue()==0x00000000FFFFFFFFLL);
73}]>;
74
Duraid Madinac252f332005-10-29 04:13:40 +000075def isSHLADDimm: PatLeaf<(i64 imm), [{
76 // isSHLADDimm predicate - True if the immediate is exactly 1, 2, 3 or 4
77 // - 0 is *not* okay.
78 // Used to create shladd instructions appropriately
79 int64_t v = (int64_t)N->getValue();
80 return (v >= 1 && v <= 4);
81}]>;
82
Duraid Madinaf221c262005-10-28 17:46:35 +000083def immSExt14 : PatLeaf<(i64 imm), [{
84 // immSExt14 predicate - True if the immediate fits in a 14-bit sign extended
85 // field. Used by instructions like 'adds'.
86 int64_t v = (int64_t)N->getValue();
87 return (v <= 8191 && v >= -8192);
88}]>;
89
90def imm64 : PatLeaf<(i64 imm), [{
91 // imm64 predicate - True if the immediate fits in a 64-bit
92 // field - i.e., true. used to keep movl happy
93 return true;
94}]>;
95
Duraid Madinac252f332005-10-29 04:13:40 +000096def SXT1 : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src), "sxt1 $dst = $src;;",
97 [(set GR:$dst, (sext_inreg GR:$src, i8))]>;
98def ZXT1 : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src), "zxt1 $dst = $src;;",
99 [(set GR:$dst, (and GR:$src, 255))]>;
100def SXT2 : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src), "sxt2 $dst = $src;;",
101 [(set GR:$dst, (sext_inreg GR:$src, i16))]>;
102def ZXT2 : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src), "zxt2 $dst = $src;;",
103 [(set GR:$dst, (and GR:$src, 65535))]>;
104def SXT4 : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src), "sxt4 $dst = $src;;",
105 [(set GR:$dst, (sext_inreg GR:$src, i32))]>;
106def ZXT4 : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src), "zxt4 $dst = $src;;",
107 [(set GR:$dst, (and GR:$src, is32ones))]>;
108
Duraid Madina7abaf902005-10-29 16:08:30 +0000109// fixme: shrs vs shru?
110def MIX1L : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
111 "mix1.l $dst = $src1, $src2;;",
112 [(set GR:$dst, (or (and GR:$src1, isMIX1Lable),
113 (and (srl GR:$src2, 8), isMIX1Lable)))]>;
114
115def MIX2L : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
116 "mix2.l $dst = $src1, $src2;;",
117 [(set GR:$dst, (or (and GR:$src1, isMIX2Lable),
118 (and (srl GR:$src2, 16), isMIX2Lable)))]>;
119
120def MIX4L : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
121 "mix4.l $dst = $src1, $src2;;",
122 [(set GR:$dst, (or (and GR:$src1, isMIX4Lable),
123 (and (srl GR:$src2, 32), isMIX4Lable)))]>;
124
125def MIX1R : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
126 "mix1.r $dst = $src1, $src2;;",
127 [(set GR:$dst, (or (and (shl GR:$src1, 8), isMIX1Rable),
128 (and GR:$src2, isMIX1Rable)))]>;
129
130def MIX2R : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
131 "mix2.r $dst = $src1, $src2;;",
132 [(set GR:$dst, (or (and (shl GR:$src1, 16), isMIX2Rable),
133 (and GR:$src2, isMIX2Rable)))]>;
134
135def MIX4R : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
136 "mix4.r $dst = $src1, $src2;;",
137 [(set GR:$dst, (or (and (shl GR:$src1, 32), isMIX4Rable),
138 (and GR:$src2, isMIX4Rable)))]>;
139
Duraid Madinaf221c262005-10-28 17:46:35 +0000140def ADD : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
141 "add $dst = $src1, $src2;;",
142 [(set GR:$dst, (add GR:$src1, GR:$src2))]>;
143
144def ADD1 : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
145 "add $dst = $src1, $src2, 1;;",
146 [(set GR:$dst, (add (add GR:$src1, GR:$src2), 1))]>;
147
148def ADDS : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, s14imm:$imm),
149 "adds $dst = $imm, $src1;;",
150 [(set GR:$dst, (add GR:$src1, immSExt14:$imm))]>;
151
152def MOVL : AForm_DAG<0x03, 0x0b, (ops GR:$dst, s64imm:$imm),
153 "movl $dst = $imm;;",
154 [(set GR:$dst, imm64:$imm)]>;
155
156def ADDL_GA : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, globaladdress:$imm),
157 "addl $dst = $imm, $src1;;",
158 []>;
159
160def SUB : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
161 "sub $dst = $src1, $src2;;",
162 [(set GR:$dst, (sub GR:$src1, GR:$src2))]>;
163
164def SUB1 : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
165 "sub $dst = $src1, $src2, 1;;",
166 [(set GR:$dst, (add (sub GR: $src1, GR:$src2), -1))]>;
167
168def GETFSIGD : AForm_DAG<0x03, 0x0b, (ops GR:$dst, FP:$src),
169 "getf.sig $dst = $src;;",
170 []>;
171
172def SETFSIGD : AForm_DAG<0x03, 0x0b, (ops FP:$dst, GR:$src),
173 "setf.sig $dst = $src;;",
174 []>;
175
176def XMALD : AForm_DAG<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3),
177 "xma.l $dst = $src1, $src2, $src3;;",
178 []>;
Duraid Madina7abaf902005-10-29 16:08:30 +0000179def XMAHD : AForm_DAG<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3),
180 "xma.h $dst = $src1, $src2, $src3;;",
181 []>;
182def XMAHUD : AForm_DAG<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3),
183 "xma.hu $dst = $src1, $src2, $src3;;",
184 []>;
Duraid Madinaf221c262005-10-28 17:46:35 +0000185
186// pseudocode for integer multiplication
187def : Pat<(mul GR:$src1, GR:$src2),
188 (GETFSIGD (XMALD (SETFSIGD GR:$src1), (SETFSIGD GR:$src2), F0))>;
Duraid Madina7abaf902005-10-29 16:08:30 +0000189def : Pat<(mulhs GR:$src1, GR:$src2),
190 (GETFSIGD (XMAHD (SETFSIGD GR:$src1), (SETFSIGD GR:$src2), F0))>;
191def : Pat<(mulhu GR:$src1, GR:$src2),
192 (GETFSIGD (XMAHUD (SETFSIGD GR:$src1), (SETFSIGD GR:$src2), F0))>;
Duraid Madinaf221c262005-10-28 17:46:35 +0000193
194// TODO: addp4 (addp4 dst = src, r0 is a 32-bit add)
195// has imm form, too
196
197// def ADDS : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, s14imm:$imm),
198// "adds $dst = $imm, $src1;;">;
199
200// load constants of various sizes // FIXME: prettyprint -ve constants
201def : Pat<(i64 immSExt14:$imm), (ADDS r0, immSExt14:$imm)>;
202def : Pat<(i64 imm64:$imm), (MOVL imm64:$imm)>;
Duraid Madinac252f332005-10-29 04:13:40 +0000203// TODO: def : Pat<(i1 1), (MOV p0)>;
Duraid Madinaf221c262005-10-28 17:46:35 +0000204
205def AND : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
206 "and $dst = $src1, $src2;;",
207 [(set GR:$dst, (and GR:$src1, GR:$src2))]>;
208def ANDCM : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
209 "andcm $dst = $src1, $src2;;",
210 [(set GR:$dst, (and GR:$src1, (not GR:$src2)))]>;
211// TODO: and/andcm/or/xor/add/sub/shift immediate forms
212def OR : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
213 "or $dst = $src1, $src2;;",
214 [(set GR:$dst, (or GR:$src1, GR:$src2))]>;
215
216def pOR : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2, PR:$qp),
217 "($qp) or $dst = $src1, $src2;;">;
218
219def PCMPEQUNCR0R0 : AForm<0x03, 0x0b, (ops PR:$dst, PR:$qp),
220 "($qp) cmp.eq.unc $dst, p0 = r0, r0;;">;
221
222let isTwoAddress=1 in
223def TPCMPEQR0R0 : AForm<0x03, 0x0b, (ops PR:$dst, PR:$bogus, PR:$qp),
224 "($qp) cmp.eq $dst, p0 = r0, r0;;">;
225
226/* our pseudocode for OR on predicates is:
Duraid Madinaf221c262005-10-28 17:46:35 +0000227pC = pA OR pB
228-------------
Duraid Madinaf221c262005-10-28 17:46:35 +0000229(pA) cmp.eq.unc pC,p0 = r0,r0 // pC = pA
230 ;;
Duraid Madina7abaf902005-10-29 16:08:30 +0000231(pB) cmp.eq pC,p0 = r0,r0 // if (pB) pC = 1 */
Duraid Madinaf221c262005-10-28 17:46:35 +0000232
Duraid Madina7abaf902005-10-29 16:08:30 +0000233def bOR : Pat<(or PR:$src1, PR:$src2),
234 (TPCMPEQR0R0 (PCMPEQUNCR0R0 PR:$src1), PR:$src2)>;
Duraid Madinaf221c262005-10-28 17:46:35 +0000235
236// FIXME: these are bogus
Duraid Madinaf221c262005-10-28 17:46:35 +0000237def bXOR : Pat<(xor PR:$src1, PR:$src2),
238 (PCMPEQUNCR0R0 PR:$src1)>;
239
240def XOR : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
241 "xor $dst = $src1, $src2;;",
242 [(set GR:$dst, (xor GR:$src1, GR:$src2))]>;
243
Duraid Madinac252f332005-10-29 04:13:40 +0000244def SHLADD: AForm_DAG<0x03, 0x0b, (ops GR:$dst,GR:$src1,s64imm:$imm,GR:$src2),
245 "shladd $dst = $src1, $imm, $src2;;",
246 [(set GR:$dst, (add GR:$src2, (shl GR:$src1, isSHLADDimm:$imm)))]>;
247
Duraid Madinaf221c262005-10-28 17:46:35 +0000248def SHL : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
249 "shl $dst = $src1, $src2;;",
250 [(set GR:$dst, (shl GR:$src1, GR:$src2))]>;
251
Duraid Madinac252f332005-10-29 04:13:40 +0000252def SHRU : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
253 "shr.u $dst = $src1, $src2;;",
254 [(set GR:$dst, (srl GR:$src1, GR:$src2))]>;
255
256def SHRS : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
257 "shr $dst = $src1, $src2;;",
258 [(set GR:$dst, (sra GR:$src1, GR:$src2))]>;
259
Duraid Madinaf221c262005-10-28 17:46:35 +0000260// the following are all a bit unfortunate: we throw away the complement
261// of the compare!
262def CMPEQ : AForm_DAG<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
263 "cmp.eq $dst, p0 = $src1, $src2;;",
264 [(set PR:$dst, (seteq GR:$src1, GR:$src2))]>;
265def CMPGT : AForm_DAG<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
266 "cmp.gt $dst, p0 = $src1, $src2;;",
267 [(set PR:$dst, (setgt GR:$src1, GR:$src2))]>;
268def CMPGE : AForm_DAG<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
269 "cmp.ge $dst, p0 = $src1, $src2;;",
270 [(set PR:$dst, (setge GR:$src1, GR:$src2))]>;
271def CMPLT : AForm_DAG<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
272 "cmp.lt $dst, p0 = $src1, $src2;;",
273 [(set PR:$dst, (setlt GR:$src1, GR:$src2))]>;
274def CMPLE : AForm_DAG<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
275 "cmp.le $dst, p0 = $src1, $src2;;",
276 [(set PR:$dst, (setle GR:$src1, GR:$src2))]>;
277def CMPNE : AForm_DAG<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
278 "cmp.ne $dst, p0 = $src1, $src2;;",
279 [(set PR:$dst, (setne GR:$src1, GR:$src2))]>;
280def CMPLTU: AForm_DAG<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
Duraid Madina57b7ee92005-10-30 10:14:19 +0000281 "cmp.ltu $dst, p0 = $src1, $src2;;",
Duraid Madinaf221c262005-10-28 17:46:35 +0000282 [(set PR:$dst, (setult GR:$src1, GR:$src2))]>;
283def CMPGTU: AForm_DAG<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
Duraid Madina57b7ee92005-10-30 10:14:19 +0000284 "cmp.gtu $dst, p0 = $src1, $src2;;",
Duraid Madinaf221c262005-10-28 17:46:35 +0000285 [(set PR:$dst, (setugt GR:$src1, GR:$src2))]>;
286def CMPLEU: AForm_DAG<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
Duraid Madina57b7ee92005-10-30 10:14:19 +0000287 "cmp.leu $dst, p0 = $src1, $src2;;",
Duraid Madinaf221c262005-10-28 17:46:35 +0000288 [(set PR:$dst, (setule GR:$src1, GR:$src2))]>;
289def CMPGEU: AForm_DAG<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
Duraid Madina57b7ee92005-10-30 10:14:19 +0000290 "cmp.geu $dst, p0 = $src1, $src2;;",
Duraid Madinaf221c262005-10-28 17:46:35 +0000291 [(set PR:$dst, (setuge GR:$src1, GR:$src2))]>;
292
Duraid Madinaf221c262005-10-28 17:46:35 +0000293// TODO: support postincrement (reg, imm9) loads+stores - this needs more
294// tablegen support
295
Chris Lattner3e0335c2005-08-19 00:47:42 +0000296def PHI : PseudoInstIA64<(ops variable_ops), "PHI">;
297def IDEF : PseudoInstIA64<(ops variable_ops), "// IDEF">;
298def IUSE : PseudoInstIA64<(ops variable_ops), "// IUSE">;
299def ADJUSTCALLSTACKUP : PseudoInstIA64<(ops variable_ops),
300 "// ADJUSTCALLSTACKUP">;
301def ADJUSTCALLSTACKDOWN : PseudoInstIA64<(ops variable_ops),
302 "// ADJUSTCALLSTACKDOWN">;
Chris Lattner9e4a4ee2005-09-14 21:11:13 +0000303def PSEUDO_ALLOC : PseudoInstIA64<(ops GR:$foo), "// PSEUDO_ALLOC">;
Duraid Madina91ed0a12005-03-17 18:17:03 +0000304
305def ALLOC : AForm<0x03, 0x0b,
306 (ops GR:$dst, i8imm:$inputs, i8imm:$locals, i8imm:$outputs, i8imm:$rotating),
307 "alloc $dst = ar.pfs,$inputs,$locals,$outputs,$rotating;;">;
308
309def MOV : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src), "mov $dst = $src;;">;
310def PMOV : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src, PR:$qp),
311 "($qp) mov $dst = $src;;">;
312
313def SPILL_ALL_PREDICATES_TO_GR : AForm<0x03, 0x0b, (ops GR:$dst),
314 "mov $dst = pr;;">;
315def FILL_ALL_PREDICATES_FROM_GR : AForm<0x03, 0x0b, (ops GR:$src),
316 "mov pr = $src;;">;
317
318let isTwoAddress = 1 in {
319 def CMOV : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src2, GR:$src, PR:$qp),
320 "($qp) mov $dst = $src;;">;
321}
322
Duraid Madina73c27772005-03-31 07:32:32 +0000323def PFMOV : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src, PR:$qp),
324 "($qp) mov $dst = $src;;">;
325
326let isTwoAddress = 1 in {
327 def CFMOV : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src2, FP:$src, PR:$qp),
328 "($qp) mov $dst = $src;;">;
329}
330
Duraid Madina91ed0a12005-03-17 18:17:03 +0000331let isTwoAddress = 1 in {
332 def TCMPNE : AForm<0x03, 0x0b,
333 (ops PR:$dst, PR:$src2, GR:$src3, GR:$src4),
334 "cmp.ne $dst, p0 = $src3, $src4;;">;
335
336 def TPCMPEQOR : AForm<0x03, 0x0b,
337 (ops PR:$dst, PR:$src2, GR:$src3, GR:$src4, PR:$qp),
338 "($qp) cmp.eq.or $dst, p0 = $src3, $src4;;">;
339
340 def TPCMPNE : AForm<0x03, 0x0b,
341 (ops PR:$dst, PR:$src2, GR:$src3, GR:$src4, PR:$qp),
342 "($qp) cmp.ne $dst, p0 = $src3, $src4;;">;
343
344 def TPCMPEQ : AForm<0x03, 0x0b,
345 (ops PR:$dst, PR:$src2, GR:$src3, GR:$src4, PR:$qp),
346 "($qp) cmp.eq $dst, p0 = $src3, $src4;;">;
347}
348
Duraid Madinafb43ef72005-04-11 05:55:56 +0000349def MOVSIMM14 : AForm<0x03, 0x0b, (ops GR:$dst, s14imm:$imm),
Duraid Madina91ed0a12005-03-17 18:17:03 +0000350 "mov $dst = $imm;;">;
Duraid Madinafb43ef72005-04-11 05:55:56 +0000351def MOVSIMM22 : AForm<0x03, 0x0b, (ops GR:$dst, s22imm:$imm),
352 "mov $dst = $imm;;">;
Duraid Madina0a7c2b92005-04-14 10:08:01 +0000353def MOVLIMM64 : AForm<0x03, 0x0b, (ops GR:$dst, s64imm:$imm),
Duraid Madina91ed0a12005-03-17 18:17:03 +0000354 "movl $dst = $imm;;">;
355
Duraid Madinafb43ef72005-04-11 05:55:56 +0000356def SHLI : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, u6imm:$imm),
357 "shl $dst = $src1, $imm;;">;
Duraid Madinafb43ef72005-04-11 05:55:56 +0000358def SHRUI : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, u6imm:$imm),
Duraid Madinab484f7c2005-04-07 12:32:24 +0000359 "shr.u $dst = $src1, $imm;;">;
Duraid Madinafb43ef72005-04-11 05:55:56 +0000360def SHRSI : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, u6imm:$imm),
Duraid Madinab484f7c2005-04-07 12:32:24 +0000361 "shr $dst = $src1, $imm;;">;
Duraid Madina91ed0a12005-03-17 18:17:03 +0000362
Duraid Madina41ff5022005-04-08 10:01:48 +0000363def EXTRU : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, u6imm:$imm1, u6imm:$imm2),
364 "extr.u $dst = $src1, $imm1, $imm2;;">;
365
Duraid Madina91ed0a12005-03-17 18:17:03 +0000366def DEPZ : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, u6imm:$imm1, u6imm:$imm2), "dep.z $dst = $src1, $imm1, $imm2;;">;
367
Duraid Madina91ed0a12005-03-17 18:17:03 +0000368// and we do the whole thing again for FP compares!
369def FCMPEQ : AForm<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
370 "fcmp.eq $dst, p0 = $src1, $src2;;">;
371def FCMPGT : AForm<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
372 "fcmp.gt $dst, p0 = $src1, $src2;;">;
373def FCMPGE : AForm<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
374 "fcmp.ge $dst, p0 = $src1, $src2;;">;
375def FCMPLT : AForm<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
376 "fcmp.lt $dst, p0 = $src1, $src2;;">;
377def FCMPLE : AForm<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
378 "fcmp.le $dst, p0 = $src1, $src2;;">;
379def FCMPNE : AForm<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
380 "fcmp.neq $dst, p0 = $src1, $src2;;">;
381def FCMPLTU : AForm<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
382 "fcmp.ltu $dst, p0 = $src1, $src2;;">;
383def FCMPGTU : AForm<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
384 "fcmp.gtu $dst, p0 = $src1, $src2;;">;
385def FCMPLEU : AForm<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
386 "fcmp.leu $dst, p0 = $src1, $src2;;">;
387def FCMPGEU : AForm<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
388 "fcmp.geu $dst, p0 = $src1, $src2;;">;
389
390def PCMPEQOR : AForm<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2, PR:$qp),
391 "($qp) cmp.eq.or $dst, p0 = $src1, $src2;;">;
392def PCMPEQUNC : AForm<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2, PR:$qp),
393 "($qp) cmp.eq.unc $dst, p0 = $src1, $src2;;">;
394def PCMPNE : AForm<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2, PR:$qp),
395 "($qp) cmp.ne $dst, p0 = $src1, $src2;;">;
396
397// two destinations!
398def BCMPEQ : AForm<0x03, 0x0b, (ops PR:$dst1, PR:$dst2, GR:$src1, GR:$src2),
399 "cmp.eq $dst1, dst2 = $src1, $src2;;">;
400
Duraid Madinab484f7c2005-04-07 12:32:24 +0000401def ADDIMM14 : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, s14imm:$imm),
402 "adds $dst = $imm, $src1;;">;
Duraid Madina91ed0a12005-03-17 18:17:03 +0000403
Duraid Madinafb43ef72005-04-11 05:55:56 +0000404def ADDIMM22 : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, s22imm:$imm),
Duraid Madina91ed0a12005-03-17 18:17:03 +0000405 "add $dst = $imm, $src1;;">;
Duraid Madinafb43ef72005-04-11 05:55:56 +0000406def CADDIMM22 : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, s22imm:$imm, PR:$qp),
Duraid Madina91ed0a12005-03-17 18:17:03 +0000407 "($qp) add $dst = $imm, $src1;;">;
408
409let isTwoAddress = 1 in {
410def TPCADDIMM22 : AForm<0x03, 0x0b,
Duraid Madinafb43ef72005-04-11 05:55:56 +0000411 (ops GR:$dst, GR:$src1, s22imm:$imm, PR:$qp),
Duraid Madina91ed0a12005-03-17 18:17:03 +0000412 "($qp) add $dst = $imm, $dst;;">;
413def TPCMPIMM8NE : AForm<0x03, 0x0b,
Duraid Madinafb43ef72005-04-11 05:55:56 +0000414 (ops PR:$dst, PR:$src1, s22imm:$imm, GR:$src2, PR:$qp),
Duraid Madina91ed0a12005-03-17 18:17:03 +0000415 "($qp) cmp.ne $dst , p0 = $imm, $src2;;">;
416}
417
Duraid Madinab484f7c2005-04-07 12:32:24 +0000418def SUBIMM8 : AForm<0x03, 0x0b, (ops GR:$dst, s8imm:$imm, GR:$src2),
419 "sub $dst = $imm, $src2;;">;
Duraid Madina91ed0a12005-03-17 18:17:03 +0000420
Duraid Madina7abaf902005-10-29 16:08:30 +0000421let isStore = 1 in {
422 def ST1 : AForm<0x03, 0x0b, (ops GR:$dstPtr, GR:$value),
423 "st1 [$dstPtr] = $value;;">;
424 def ST2 : AForm<0x03, 0x0b, (ops GR:$dstPtr, GR:$value),
425 "st2 [$dstPtr] = $value;;">;
426 def ST4 : AForm<0x03, 0x0b, (ops GR:$dstPtr, GR:$value),
427 "st4 [$dstPtr] = $value;;">;
428 def ST8 : AForm<0x03, 0x0b, (ops GR:$dstPtr, GR:$value),
429 "st8 [$dstPtr] = $value;;">;
430 def STF4 : AForm<0x03, 0x0b, (ops GR:$dstPtr, FP:$value),
431 "stfs [$dstPtr] = $value;;">;
432 def STF8 : AForm<0x03, 0x0b, (ops GR:$dstPtr, FP:$value),
433 "stfd [$dstPtr] = $value;;">;
434}
Duraid Madina91ed0a12005-03-17 18:17:03 +0000435
Duraid Madina7abaf902005-10-29 16:08:30 +0000436let isLoad = 1 in {
437 def LD1 : AForm<0x03, 0x0b, (ops GR:$dst, GR:$srcPtr),
438 "ld1 $dst = [$srcPtr];;">;
439 def LD2 : AForm<0x03, 0x0b, (ops GR:$dst, GR:$srcPtr),
440 "ld2 $dst = [$srcPtr];;">;
441 def LD4 : AForm<0x03, 0x0b, (ops GR:$dst, GR:$srcPtr),
442 "ld4 $dst = [$srcPtr];;">;
443 def LD8 : AForm<0x03, 0x0b, (ops GR:$dst, GR:$srcPtr),
444 "ld8 $dst = [$srcPtr];;">;
445 def LDF4 : AForm<0x03, 0x0b, (ops FP:$dst, GR:$srcPtr),
446 "ldfs $dst = [$srcPtr];;">;
447 def LDF8 : AForm<0x03, 0x0b, (ops FP:$dst, GR:$srcPtr),
448 "ldfd $dst = [$srcPtr];;">;
449}
Duraid Madina91ed0a12005-03-17 18:17:03 +0000450
Duraid Madina7abaf902005-10-29 16:08:30 +0000451def POPCNT : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src),
452 "popcnt $dst = $src;;",
453 [(set GR:$dst, (ctpop GR:$src))]>;
Duraid Madina25163d82005-05-11 05:16:09 +0000454
Duraid Madina7abaf902005-10-29 16:08:30 +0000455// some FP stuff: // TODO: single-precision stuff?
456def FADD : AForm_DAG<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2),
457 "fadd $dst = $src1, $src2;;",
458 [(set FP:$dst, (fadd FP:$src1, FP:$src2))]>;
Duraid Madina91ed0a12005-03-17 18:17:03 +0000459def FADDS: AForm<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2),
460 "fadd.s $dst = $src1, $src2;;">;
Duraid Madina7abaf902005-10-29 16:08:30 +0000461def FSUB : AForm_DAG<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2),
462 "fsub $dst = $src1, $src2;;",
463 [(set FP:$dst, (fsub FP:$src1, FP:$src2))]>;
464def FMPY : AForm_DAG<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2),
465 "fmpy $dst = $src1, $src2;;",
466 [(set FP:$dst, (fmul FP:$src1, FP:$src2))]>;
Duraid Madina91ed0a12005-03-17 18:17:03 +0000467def FMOV : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
468 "mov $dst = $src;;">; // XXX: there _is_ no fmov
Duraid Madina7abaf902005-10-29 16:08:30 +0000469def FMA : AForm_DAG<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3),
470 "fma $dst = $src1, $src2, $src3;;",
471 [(set FP:$dst, (fadd (fmul FP:$src1, FP:$src2), FP:$src3))]>;
472def FMS : AForm_DAG<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3),
473 "fms $dst = $src1, $src2, $src3;;",
474 [(set FP:$dst, (fsub (fmul FP:$src1, FP:$src2), FP:$src3))]>;
475def FNMA : AForm_DAG<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3),
476 "fnma $dst = $src1, $src2, $src3;;",
477 [(set FP:$dst, (fneg (fadd (fmul FP:$src1, FP:$src2), FP:$src3)))]>;
Duraid Madina0720dc12005-04-02 05:18:38 +0000478def FABS : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
479 "fabs $dst = $src;;">;
Duraid Madina7abaf902005-10-29 16:08:30 +0000480def FNEG : AForm_DAG<0x03, 0x0b, (ops FP:$dst, FP:$src),
481 "fneg $dst = $src;;",
482 [(set FP:$dst, (fneg FP:$src))]>;
Duraid Madina0ccac382005-04-02 10:06:27 +0000483def FNEGABS : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
484 "fnegabs $dst = $src;;">;
Duraid Madina91ed0a12005-03-17 18:17:03 +0000485
486def CFMAS1 : AForm<0x03, 0x0b,
487 (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3, PR:$qp),
488 "($qp) fma.s1 $dst = $src1, $src2, $src3;;">;
489def CFNMAS1 : AForm<0x03, 0x0b,
490 (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3, PR:$qp),
491 "($qp) fnma.s1 $dst = $src1, $src2, $src3;;">;
492
Duraid Madina41ff5022005-04-08 10:01:48 +0000493def FRCPAS1 : AForm<0x03, 0x0b, (ops FP:$dstFR, PR:$dstPR, FP:$src1, FP:$src2),
494 "frcpa.s1 $dstFR, $dstPR = $src1, $src2;;">;
Duraid Madina91ed0a12005-03-17 18:17:03 +0000495
496def XMAL : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3),
497 "xma.l $dst = $src1, $src2, $src3;;">;
498
499def FCVTXF : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
500 "fcvt.xf $dst = $src;;">;
501def FCVTXUF : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
502 "fcvt.xuf $dst = $src;;">;
503def FCVTXUFS1 : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
504 "fcvt.xuf.s1 $dst = $src;;">;
505def FCVTFX : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
506 "fcvt.fx $dst = $src;;">;
507def FCVTFXU : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
508 "fcvt.fxu $dst = $src;;">;
509
510def FCVTFXTRUNC : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
511 "fcvt.fx.trunc $dst = $src;;">;
512def FCVTFXUTRUNC : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
513 "fcvt.fxu.trunc $dst = $src;;">;
514
515def FCVTFXTRUNCS1 : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
516 "fcvt.fx.trunc.s1 $dst = $src;;">;
517def FCVTFXUTRUNCS1 : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
518 "fcvt.fxu.trunc.s1 $dst = $src;;">;
519
520def FNORMD : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
521 "fnorm.d $dst = $src;;">;
522
523def GETFD : AForm<0x03, 0x0b, (ops GR:$dst, FP:$src),
524 "getf.d $dst = $src;;">;
525def SETFD : AForm<0x03, 0x0b, (ops FP:$dst, GR:$src),
526 "setf.d $dst = $src;;">;
527
528def GETFSIG : AForm<0x03, 0x0b, (ops GR:$dst, FP:$src),
529 "getf.sig $dst = $src;;">;
530def SETFSIG : AForm<0x03, 0x0b, (ops FP:$dst, GR:$src),
531 "setf.sig $dst = $src;;">;
532
Duraid Madina91ed0a12005-03-17 18:17:03 +0000533let isTerminator = 1, isBranch = 1 in {
Duraid Madinaf221c262005-10-28 17:46:35 +0000534 def BRL_NOTCALL : RawForm<0x03, 0xb0, (ops i64imm:$dst),
535 "(p0) brl.cond.sptk $dst;;">;
Duraid Madina91ed0a12005-03-17 18:17:03 +0000536 def BRLCOND_NOTCALL : RawForm<0x03, 0xb0, (ops PR:$qp, i64imm:$dst),
537 "($qp) brl.cond.sptk $dst;;">;
538 def BRCOND_NOTCALL : RawForm<0x03, 0xb0, (ops PR:$qp, GR:$dst),
539 "($qp) br.cond.sptk $dst;;">;
540}
541
542let isCall = 1, isTerminator = 1, isBranch = 1,
Chris Lattner6b917672005-04-12 15:12:19 +0000543 Uses = [out0,out1,out2,out3,out4,out5,out6,out7],
Duraid Madina91ed0a12005-03-17 18:17:03 +0000544// all calls clobber non-callee-saved registers, and for now, they are these:
545 Defs = [r2,r3,r8,r9,r10,r11,r14,r15,r16,r17,r18,r19,r20,r21,r22,r23,r24,
546 r25,r26,r27,r28,r29,r30,r31,
547 p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,
548 F6,F7,F8,F9,F10,F11,F12,F13,F14,F15,
549 F32,F33,F34,F35,F36,F37,F38,F39,F40,F41,F42,F43,F44,F45,F46,F47,F48,F49,
550 F50,F51,F52,F53,F54,F55,F56,
551 F57,F58,F59,F60,F61,F62,F63,F64,F65,F66,F67,F68,F69,F70,F71,F72,F73,F74,
552 F75,F76,F77,F78,F79,F80,F81,
553 F82,F83,F84,F85,F86,F87,F88,F89,F90,F91,F92,F93,F94,F95,F96,F97,F98,F99,
554 F100,F101,F102,F103,F104,F105,
555 F106,F107,F108,F109,F110,F111,F112,F113,F114,F115,F116,F117,F118,F119,
556 F120,F121,F122,F123,F124,F125,F126,F127,
557 out0,out1,out2,out3,out4,out5,out6,out7] in {
Duraid Madinaf221c262005-10-28 17:46:35 +0000558// old pattern call
559 def BRCALL: RawForm<0x03, 0xb0, (ops calltarget:$dst),
Duraid Madina91ed0a12005-03-17 18:17:03 +0000560 "br.call.sptk rp = $dst;;">; // FIXME: teach llvm about branch regs?
Duraid Madinaf221c262005-10-28 17:46:35 +0000561// new daggy stuff!
562 def BRCALL_IPREL : RawForm<0x03, 0xb0, (ops calltarget:$dst, variable_ops),
563 "br.call.sptk rp = $dst;;">; // FIXME: teach llvm about branch regs?
564 def BRCALL_INDIRECT : RawForm<0x03, 0xb0, (ops GR:$branchreg, variable_ops),
565 "br.call.sptk rp = $branchreg;;">; // FIXME: teach llvm about branch regs?
Duraid Madina91ed0a12005-03-17 18:17:03 +0000566 def BRLCOND_CALL : RawForm<0x03, 0xb0, (ops PR:$qp, i64imm:$dst),
567 "($qp) brl.cond.call.sptk $dst;;">;
568 def BRCOND_CALL : RawForm<0x03, 0xb0, (ops PR:$qp, GR:$dst),
569 "($qp) br.cond.call.sptk $dst;;">;
570}
571
572let isTerminator = 1, isReturn = 1 in
573 def RET : RawForm<0x03, 0xb0, (ops), "br.ret.sptk.many rp;;">; // return
574
575