blob: 97764219545ac1e6ebc9fa9d92a1367b5d1e4b37 [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 Madinaa284b662005-11-01 01:29:55 +000096def ADD : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
97 "add $dst = $src1, $src2;;",
98 [(set GR:$dst, (add GR:$src1, GR:$src2))]>;
99
100def ADD1 : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
101 "add $dst = $src1, $src2, 1;;",
102 [(set GR:$dst, (add (add GR:$src1, GR:$src2), 1))]>;
103
104def ADDS : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, s14imm:$imm),
105 "adds $dst = $imm, $src1;;",
106 [(set GR:$dst, (add GR:$src1, immSExt14:$imm))]>;
107
108def MOVL : AForm_DAG<0x03, 0x0b, (ops GR:$dst, s64imm:$imm),
109 "movl $dst = $imm;;",
110 [(set GR:$dst, imm64:$imm)]>;
111
112def ADDL_GA : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, globaladdress:$imm),
113 "addl $dst = $imm, $src1;;",
114 []>;
115
116def SUB : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
117 "sub $dst = $src1, $src2;;",
118 [(set GR:$dst, (sub GR:$src1, GR:$src2))]>;
119
120def SUB1 : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
121 "sub $dst = $src1, $src2, 1;;",
122 [(set GR:$dst, (add (sub GR: $src1, GR:$src2), -1))]>;
123
124let isTwoAddress = 1 in {
125def TPCADDIMM22 : AForm<0x03, 0x0b,
126 (ops GR:$dst, GR:$src1, s22imm:$imm, PR:$qp),
127 "($qp) add $dst = $imm, $dst;;">;
128def TPCMPIMM8NE : AForm<0x03, 0x0b,
129 (ops PR:$dst, PR:$src1, s22imm:$imm, GR:$src2, PR:$qp),
130 "($qp) cmp.ne $dst , p0 = $imm, $src2;;">;
131}
132
133// zero extend a bool (predicate reg) into an integer reg
134def ZXTb : Pat<(zext PR:$src),
135 (TPCADDIMM22 (ADDS r0, 0), 1, PR:$src)>;
136
137// normal sign/zero-extends
Duraid Madinac252f332005-10-29 04:13:40 +0000138def SXT1 : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src), "sxt1 $dst = $src;;",
139 [(set GR:$dst, (sext_inreg GR:$src, i8))]>;
140def ZXT1 : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src), "zxt1 $dst = $src;;",
141 [(set GR:$dst, (and GR:$src, 255))]>;
142def SXT2 : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src), "sxt2 $dst = $src;;",
143 [(set GR:$dst, (sext_inreg GR:$src, i16))]>;
144def ZXT2 : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src), "zxt2 $dst = $src;;",
145 [(set GR:$dst, (and GR:$src, 65535))]>;
146def SXT4 : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src), "sxt4 $dst = $src;;",
147 [(set GR:$dst, (sext_inreg GR:$src, i32))]>;
148def ZXT4 : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src), "zxt4 $dst = $src;;",
149 [(set GR:$dst, (and GR:$src, is32ones))]>;
150
Duraid Madina7abaf902005-10-29 16:08:30 +0000151// fixme: shrs vs shru?
152def MIX1L : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
153 "mix1.l $dst = $src1, $src2;;",
154 [(set GR:$dst, (or (and GR:$src1, isMIX1Lable),
155 (and (srl GR:$src2, 8), isMIX1Lable)))]>;
156
157def MIX2L : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
158 "mix2.l $dst = $src1, $src2;;",
159 [(set GR:$dst, (or (and GR:$src1, isMIX2Lable),
160 (and (srl GR:$src2, 16), isMIX2Lable)))]>;
161
162def MIX4L : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
163 "mix4.l $dst = $src1, $src2;;",
164 [(set GR:$dst, (or (and GR:$src1, isMIX4Lable),
165 (and (srl GR:$src2, 32), isMIX4Lable)))]>;
166
167def MIX1R : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
168 "mix1.r $dst = $src1, $src2;;",
169 [(set GR:$dst, (or (and (shl GR:$src1, 8), isMIX1Rable),
170 (and GR:$src2, isMIX1Rable)))]>;
171
172def MIX2R : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
173 "mix2.r $dst = $src1, $src2;;",
174 [(set GR:$dst, (or (and (shl GR:$src1, 16), isMIX2Rable),
175 (and GR:$src2, isMIX2Rable)))]>;
176
177def MIX4R : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
178 "mix4.r $dst = $src1, $src2;;",
179 [(set GR:$dst, (or (and (shl GR:$src1, 32), isMIX4Rable),
180 (and GR:$src2, isMIX4Rable)))]>;
181
Duraid Madinaf221c262005-10-28 17:46:35 +0000182def GETFSIGD : AForm_DAG<0x03, 0x0b, (ops GR:$dst, FP:$src),
183 "getf.sig $dst = $src;;",
184 []>;
185
186def SETFSIGD : AForm_DAG<0x03, 0x0b, (ops FP:$dst, GR:$src),
187 "setf.sig $dst = $src;;",
188 []>;
189
190def XMALD : AForm_DAG<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3),
191 "xma.l $dst = $src1, $src2, $src3;;",
192 []>;
Duraid Madina7abaf902005-10-29 16:08:30 +0000193def XMAHD : AForm_DAG<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3),
194 "xma.h $dst = $src1, $src2, $src3;;",
195 []>;
196def XMAHUD : AForm_DAG<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3),
197 "xma.hu $dst = $src1, $src2, $src3;;",
198 []>;
Duraid Madinaf221c262005-10-28 17:46:35 +0000199
200// pseudocode for integer multiplication
201def : Pat<(mul GR:$src1, GR:$src2),
202 (GETFSIGD (XMALD (SETFSIGD GR:$src1), (SETFSIGD GR:$src2), F0))>;
Duraid Madina7abaf902005-10-29 16:08:30 +0000203def : Pat<(mulhs GR:$src1, GR:$src2),
204 (GETFSIGD (XMAHD (SETFSIGD GR:$src1), (SETFSIGD GR:$src2), F0))>;
205def : Pat<(mulhu GR:$src1, GR:$src2),
206 (GETFSIGD (XMAHUD (SETFSIGD GR:$src1), (SETFSIGD GR:$src2), F0))>;
Duraid Madinaf221c262005-10-28 17:46:35 +0000207
208// TODO: addp4 (addp4 dst = src, r0 is a 32-bit add)
209// has imm form, too
210
211// def ADDS : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, s14imm:$imm),
212// "adds $dst = $imm, $src1;;">;
213
Duraid Madinaf221c262005-10-28 17:46:35 +0000214def AND : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
215 "and $dst = $src1, $src2;;",
216 [(set GR:$dst, (and GR:$src1, GR:$src2))]>;
217def ANDCM : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
218 "andcm $dst = $src1, $src2;;",
219 [(set GR:$dst, (and GR:$src1, (not GR:$src2)))]>;
220// TODO: and/andcm/or/xor/add/sub/shift immediate forms
221def OR : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
222 "or $dst = $src1, $src2;;",
223 [(set GR:$dst, (or GR:$src1, GR:$src2))]>;
224
225def pOR : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2, PR:$qp),
226 "($qp) or $dst = $src1, $src2;;">;
227
228def PCMPEQUNCR0R0 : AForm<0x03, 0x0b, (ops PR:$dst, PR:$qp),
229 "($qp) cmp.eq.unc $dst, p0 = r0, r0;;">;
230
231let isTwoAddress=1 in
232def TPCMPEQR0R0 : AForm<0x03, 0x0b, (ops PR:$dst, PR:$bogus, PR:$qp),
233 "($qp) cmp.eq $dst, p0 = r0, r0;;">;
234
235/* our pseudocode for OR on predicates is:
Duraid Madinaf221c262005-10-28 17:46:35 +0000236pC = pA OR pB
237-------------
Duraid Madinaf221c262005-10-28 17:46:35 +0000238(pA) cmp.eq.unc pC,p0 = r0,r0 // pC = pA
239 ;;
Duraid Madina7abaf902005-10-29 16:08:30 +0000240(pB) cmp.eq pC,p0 = r0,r0 // if (pB) pC = 1 */
Duraid Madinaf221c262005-10-28 17:46:35 +0000241
Duraid Madina7abaf902005-10-29 16:08:30 +0000242def bOR : Pat<(or PR:$src1, PR:$src2),
243 (TPCMPEQR0R0 (PCMPEQUNCR0R0 PR:$src1), PR:$src2)>;
Duraid Madinaf221c262005-10-28 17:46:35 +0000244
245// FIXME: these are bogus
Duraid Madinaf221c262005-10-28 17:46:35 +0000246def bXOR : Pat<(xor PR:$src1, PR:$src2),
247 (PCMPEQUNCR0R0 PR:$src1)>;
248
249def XOR : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
250 "xor $dst = $src1, $src2;;",
251 [(set GR:$dst, (xor GR:$src1, GR:$src2))]>;
252
Duraid Madinac252f332005-10-29 04:13:40 +0000253def SHLADD: AForm_DAG<0x03, 0x0b, (ops GR:$dst,GR:$src1,s64imm:$imm,GR:$src2),
254 "shladd $dst = $src1, $imm, $src2;;",
255 [(set GR:$dst, (add GR:$src2, (shl GR:$src1, isSHLADDimm:$imm)))]>;
256
Duraid Madinaf221c262005-10-28 17:46:35 +0000257def SHL : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
258 "shl $dst = $src1, $src2;;",
259 [(set GR:$dst, (shl GR:$src1, GR:$src2))]>;
260
Duraid Madinac252f332005-10-29 04:13:40 +0000261def SHRU : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
262 "shr.u $dst = $src1, $src2;;",
263 [(set GR:$dst, (srl GR:$src1, GR:$src2))]>;
264
265def SHRS : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
266 "shr $dst = $src1, $src2;;",
267 [(set GR:$dst, (sra GR:$src1, GR:$src2))]>;
268
Duraid Madinaf221c262005-10-28 17:46:35 +0000269// the following are all a bit unfortunate: we throw away the complement
270// of the compare!
271def CMPEQ : AForm_DAG<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
272 "cmp.eq $dst, p0 = $src1, $src2;;",
273 [(set PR:$dst, (seteq GR:$src1, GR:$src2))]>;
274def CMPGT : AForm_DAG<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
275 "cmp.gt $dst, p0 = $src1, $src2;;",
276 [(set PR:$dst, (setgt GR:$src1, GR:$src2))]>;
277def CMPGE : AForm_DAG<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
278 "cmp.ge $dst, p0 = $src1, $src2;;",
279 [(set PR:$dst, (setge GR:$src1, GR:$src2))]>;
280def CMPLT : AForm_DAG<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
281 "cmp.lt $dst, p0 = $src1, $src2;;",
282 [(set PR:$dst, (setlt GR:$src1, GR:$src2))]>;
283def CMPLE : AForm_DAG<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
284 "cmp.le $dst, p0 = $src1, $src2;;",
285 [(set PR:$dst, (setle GR:$src1, GR:$src2))]>;
286def CMPNE : AForm_DAG<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
287 "cmp.ne $dst, p0 = $src1, $src2;;",
288 [(set PR:$dst, (setne GR:$src1, GR:$src2))]>;
289def CMPLTU: AForm_DAG<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
Duraid Madina57b7ee92005-10-30 10:14:19 +0000290 "cmp.ltu $dst, p0 = $src1, $src2;;",
Duraid Madinaf221c262005-10-28 17:46:35 +0000291 [(set PR:$dst, (setult GR:$src1, GR:$src2))]>;
292def CMPGTU: AForm_DAG<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
Duraid Madina57b7ee92005-10-30 10:14:19 +0000293 "cmp.gtu $dst, p0 = $src1, $src2;;",
Duraid Madinaf221c262005-10-28 17:46:35 +0000294 [(set PR:$dst, (setugt GR:$src1, GR:$src2))]>;
295def CMPLEU: AForm_DAG<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
Duraid Madina57b7ee92005-10-30 10:14:19 +0000296 "cmp.leu $dst, p0 = $src1, $src2;;",
Duraid Madinaf221c262005-10-28 17:46:35 +0000297 [(set PR:$dst, (setule GR:$src1, GR:$src2))]>;
298def CMPGEU: AForm_DAG<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
Duraid Madina57b7ee92005-10-30 10:14:19 +0000299 "cmp.geu $dst, p0 = $src1, $src2;;",
Duraid Madinaf221c262005-10-28 17:46:35 +0000300 [(set PR:$dst, (setuge GR:$src1, GR:$src2))]>;
301
Duraid Madina88fc69f2005-10-31 01:42:11 +0000302// and we do the whole thing again for FP compares!
303def FCMPEQ : AForm_DAG<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
304 "fcmp.eq $dst, p0 = $src1, $src2;;",
305 [(set PR:$dst, (seteq FP:$src1, FP:$src2))]>;
306def FCMPGT : AForm_DAG<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
307 "fcmp.gt $dst, p0 = $src1, $src2;;",
308 [(set PR:$dst, (setgt FP:$src1, FP:$src2))]>;
309def FCMPGE : AForm_DAG<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
310 "fcmp.ge $dst, p0 = $src1, $src2;;",
311 [(set PR:$dst, (setge FP:$src1, FP:$src2))]>;
312def FCMPLT : AForm_DAG<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
313 "fcmp.lt $dst, p0 = $src1, $src2;;",
314 [(set PR:$dst, (setlt FP:$src1, FP:$src2))]>;
315def FCMPLE : AForm_DAG<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
316 "fcmp.le $dst, p0 = $src1, $src2;;",
317 [(set PR:$dst, (setle FP:$src1, FP:$src2))]>;
318def FCMPNE : AForm_DAG<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
319 "fcmp.neq $dst, p0 = $src1, $src2;;",
320 [(set PR:$dst, (setne FP:$src1, FP:$src2))]>;
321def FCMPLTU: AForm_DAG<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
322 "fcmp.ltu $dst, p0 = $src1, $src2;;",
323 [(set PR:$dst, (setult FP:$src1, FP:$src2))]>;
324def FCMPGTU: AForm_DAG<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
325 "fcmp.gtu $dst, p0 = $src1, $src2;;",
326 [(set PR:$dst, (setugt FP:$src1, FP:$src2))]>;
327def FCMPLEU: AForm_DAG<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
328 "fcmp.leu $dst, p0 = $src1, $src2;;",
329 [(set PR:$dst, (setule FP:$src1, FP:$src2))]>;
330def FCMPGEU: AForm_DAG<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
331 "fcmp.geu $dst, p0 = $src1, $src2;;",
332 [(set PR:$dst, (setuge FP:$src1, FP:$src2))]>;
333
Duraid Madina17decbb2005-11-02 02:37:18 +0000334def MOV : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src), "mov $dst = $src;;">;
335def PMOV : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src, PR:$qp),
336 "($qp) mov $dst = $src;;">;
337
338def SPILL_ALL_PREDICATES_TO_GR : AForm<0x03, 0x0b, (ops GR:$dst),
339 "mov $dst = pr;;">;
340def FILL_ALL_PREDICATES_FROM_GR : AForm<0x03, 0x0b, (ops GR:$src),
341 "mov pr = $src;;">;
342
343let isTwoAddress = 1 in {
344 def CMOV : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src2, GR:$src, PR:$qp),
345 "($qp) mov $dst = $src;;">;
346}
347
348def PFMOV : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src, PR:$qp),
349 "($qp) mov $dst = $src;;">;
350
351let isTwoAddress = 1 in {
352 def CFMOV : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src2, FP:$src, PR:$qp),
353 "($qp) mov $dst = $src;;">;
354}
355
356// TODO: select FPs, bools
357def SELECTINT : Pat<(select PR:$which, GR:$src1, GR:$src2),
358 (CMOV (MOV GR:$src2), GR:$src1, PR:$which)>; // note order!
359
360// load constants of various sizes // FIXME: prettyprint -ve constants
361def : Pat<(i64 immSExt14:$imm), (ADDS r0, immSExt14:$imm)>;
362def : Pat<(i64 imm64:$imm), (MOVL imm64:$imm)>;
363//FIXME: tablegen coughs on this next one:
364//def : Pat<(i1 1), (CMPEQ r0, r0)>; // TODO: this should just be a ref to p0
365
Duraid Madinaf221c262005-10-28 17:46:35 +0000366// TODO: support postincrement (reg, imm9) loads+stores - this needs more
367// tablegen support
368
Chris Lattner3e0335c2005-08-19 00:47:42 +0000369def PHI : PseudoInstIA64<(ops variable_ops), "PHI">;
370def IDEF : PseudoInstIA64<(ops variable_ops), "// IDEF">;
Duraid Madina88fc69f2005-10-31 01:42:11 +0000371
372def IDEF_GR_D : PseudoInstIA64_DAG<(ops GR:$reg), "// $reg = IDEF",
373 [(set GR:$reg, (undef))]>;
374def IDEF_FP_D : PseudoInstIA64_DAG<(ops FP:$reg), "// $reg = IDEF",
375 [(set FP:$reg, (undef))]>;
376def IDEF_PR_D : PseudoInstIA64_DAG<(ops PR:$reg), "// $reg = IDEF",
377 [(set PR:$reg, (undef))]>;
378
Chris Lattner3e0335c2005-08-19 00:47:42 +0000379def IUSE : PseudoInstIA64<(ops variable_ops), "// IUSE">;
380def ADJUSTCALLSTACKUP : PseudoInstIA64<(ops variable_ops),
381 "// ADJUSTCALLSTACKUP">;
382def ADJUSTCALLSTACKDOWN : PseudoInstIA64<(ops variable_ops),
383 "// ADJUSTCALLSTACKDOWN">;
Chris Lattner9e4a4ee2005-09-14 21:11:13 +0000384def PSEUDO_ALLOC : PseudoInstIA64<(ops GR:$foo), "// PSEUDO_ALLOC">;
Duraid Madina91ed0a12005-03-17 18:17:03 +0000385
386def ALLOC : AForm<0x03, 0x0b,
387 (ops GR:$dst, i8imm:$inputs, i8imm:$locals, i8imm:$outputs, i8imm:$rotating),
388 "alloc $dst = ar.pfs,$inputs,$locals,$outputs,$rotating;;">;
389
Duraid Madina91ed0a12005-03-17 18:17:03 +0000390let isTwoAddress = 1 in {
391 def TCMPNE : AForm<0x03, 0x0b,
392 (ops PR:$dst, PR:$src2, GR:$src3, GR:$src4),
393 "cmp.ne $dst, p0 = $src3, $src4;;">;
394
395 def TPCMPEQOR : AForm<0x03, 0x0b,
396 (ops PR:$dst, PR:$src2, GR:$src3, GR:$src4, PR:$qp),
397 "($qp) cmp.eq.or $dst, p0 = $src3, $src4;;">;
398
399 def TPCMPNE : AForm<0x03, 0x0b,
400 (ops PR:$dst, PR:$src2, GR:$src3, GR:$src4, PR:$qp),
401 "($qp) cmp.ne $dst, p0 = $src3, $src4;;">;
402
403 def TPCMPEQ : AForm<0x03, 0x0b,
404 (ops PR:$dst, PR:$src2, GR:$src3, GR:$src4, PR:$qp),
405 "($qp) cmp.eq $dst, p0 = $src3, $src4;;">;
406}
407
Duraid Madinafb43ef72005-04-11 05:55:56 +0000408def MOVSIMM14 : AForm<0x03, 0x0b, (ops GR:$dst, s14imm:$imm),
Duraid Madina91ed0a12005-03-17 18:17:03 +0000409 "mov $dst = $imm;;">;
Duraid Madinafb43ef72005-04-11 05:55:56 +0000410def MOVSIMM22 : AForm<0x03, 0x0b, (ops GR:$dst, s22imm:$imm),
411 "mov $dst = $imm;;">;
Duraid Madina0a7c2b92005-04-14 10:08:01 +0000412def MOVLIMM64 : AForm<0x03, 0x0b, (ops GR:$dst, s64imm:$imm),
Duraid Madina91ed0a12005-03-17 18:17:03 +0000413 "movl $dst = $imm;;">;
414
Duraid Madinafb43ef72005-04-11 05:55:56 +0000415def SHLI : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, u6imm:$imm),
416 "shl $dst = $src1, $imm;;">;
Duraid Madinafb43ef72005-04-11 05:55:56 +0000417def SHRUI : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, u6imm:$imm),
Duraid Madinab484f7c2005-04-07 12:32:24 +0000418 "shr.u $dst = $src1, $imm;;">;
Duraid Madinafb43ef72005-04-11 05:55:56 +0000419def SHRSI : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, u6imm:$imm),
Duraid Madinab484f7c2005-04-07 12:32:24 +0000420 "shr $dst = $src1, $imm;;">;
Duraid Madina91ed0a12005-03-17 18:17:03 +0000421
Duraid Madina41ff5022005-04-08 10:01:48 +0000422def EXTRU : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, u6imm:$imm1, u6imm:$imm2),
423 "extr.u $dst = $src1, $imm1, $imm2;;">;
424
Duraid Madina91ed0a12005-03-17 18:17:03 +0000425def DEPZ : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, u6imm:$imm1, u6imm:$imm2), "dep.z $dst = $src1, $imm1, $imm2;;">;
426
Duraid Madina91ed0a12005-03-17 18:17:03 +0000427def PCMPEQOR : AForm<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2, PR:$qp),
428 "($qp) cmp.eq.or $dst, p0 = $src1, $src2;;">;
429def PCMPEQUNC : AForm<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2, PR:$qp),
430 "($qp) cmp.eq.unc $dst, p0 = $src1, $src2;;">;
431def PCMPNE : AForm<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2, PR:$qp),
432 "($qp) cmp.ne $dst, p0 = $src1, $src2;;">;
433
434// two destinations!
435def BCMPEQ : AForm<0x03, 0x0b, (ops PR:$dst1, PR:$dst2, GR:$src1, GR:$src2),
436 "cmp.eq $dst1, dst2 = $src1, $src2;;">;
437
Duraid Madinab484f7c2005-04-07 12:32:24 +0000438def ADDIMM14 : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, s14imm:$imm),
439 "adds $dst = $imm, $src1;;">;
Duraid Madina91ed0a12005-03-17 18:17:03 +0000440
Duraid Madinafb43ef72005-04-11 05:55:56 +0000441def ADDIMM22 : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, s22imm:$imm),
Duraid Madina91ed0a12005-03-17 18:17:03 +0000442 "add $dst = $imm, $src1;;">;
Duraid Madinafb43ef72005-04-11 05:55:56 +0000443def CADDIMM22 : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, s22imm:$imm, PR:$qp),
Duraid Madina91ed0a12005-03-17 18:17:03 +0000444 "($qp) add $dst = $imm, $src1;;">;
445
Duraid Madinab484f7c2005-04-07 12:32:24 +0000446def SUBIMM8 : AForm<0x03, 0x0b, (ops GR:$dst, s8imm:$imm, GR:$src2),
447 "sub $dst = $imm, $src2;;">;
Duraid Madina91ed0a12005-03-17 18:17:03 +0000448
Duraid Madina7abaf902005-10-29 16:08:30 +0000449let isStore = 1 in {
450 def ST1 : AForm<0x03, 0x0b, (ops GR:$dstPtr, GR:$value),
451 "st1 [$dstPtr] = $value;;">;
452 def ST2 : AForm<0x03, 0x0b, (ops GR:$dstPtr, GR:$value),
453 "st2 [$dstPtr] = $value;;">;
454 def ST4 : AForm<0x03, 0x0b, (ops GR:$dstPtr, GR:$value),
455 "st4 [$dstPtr] = $value;;">;
456 def ST8 : AForm<0x03, 0x0b, (ops GR:$dstPtr, GR:$value),
457 "st8 [$dstPtr] = $value;;">;
458 def STF4 : AForm<0x03, 0x0b, (ops GR:$dstPtr, FP:$value),
459 "stfs [$dstPtr] = $value;;">;
460 def STF8 : AForm<0x03, 0x0b, (ops GR:$dstPtr, FP:$value),
461 "stfd [$dstPtr] = $value;;">;
462}
Duraid Madina91ed0a12005-03-17 18:17:03 +0000463
Duraid Madina7abaf902005-10-29 16:08:30 +0000464let isLoad = 1 in {
465 def LD1 : AForm<0x03, 0x0b, (ops GR:$dst, GR:$srcPtr),
466 "ld1 $dst = [$srcPtr];;">;
467 def LD2 : AForm<0x03, 0x0b, (ops GR:$dst, GR:$srcPtr),
468 "ld2 $dst = [$srcPtr];;">;
469 def LD4 : AForm<0x03, 0x0b, (ops GR:$dst, GR:$srcPtr),
470 "ld4 $dst = [$srcPtr];;">;
471 def LD8 : AForm<0x03, 0x0b, (ops GR:$dst, GR:$srcPtr),
472 "ld8 $dst = [$srcPtr];;">;
473 def LDF4 : AForm<0x03, 0x0b, (ops FP:$dst, GR:$srcPtr),
474 "ldfs $dst = [$srcPtr];;">;
475 def LDF8 : AForm<0x03, 0x0b, (ops FP:$dst, GR:$srcPtr),
476 "ldfd $dst = [$srcPtr];;">;
477}
Duraid Madina91ed0a12005-03-17 18:17:03 +0000478
Duraid Madina7abaf902005-10-29 16:08:30 +0000479def POPCNT : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src),
480 "popcnt $dst = $src;;",
481 [(set GR:$dst, (ctpop GR:$src))]>;
Duraid Madina25163d82005-05-11 05:16:09 +0000482
Duraid Madina7abaf902005-10-29 16:08:30 +0000483// some FP stuff: // TODO: single-precision stuff?
484def FADD : AForm_DAG<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2),
485 "fadd $dst = $src1, $src2;;",
486 [(set FP:$dst, (fadd FP:$src1, FP:$src2))]>;
Duraid Madina91ed0a12005-03-17 18:17:03 +0000487def FADDS: AForm<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2),
488 "fadd.s $dst = $src1, $src2;;">;
Duraid Madina7abaf902005-10-29 16:08:30 +0000489def FSUB : AForm_DAG<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2),
490 "fsub $dst = $src1, $src2;;",
491 [(set FP:$dst, (fsub FP:$src1, FP:$src2))]>;
492def FMPY : AForm_DAG<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2),
493 "fmpy $dst = $src1, $src2;;",
494 [(set FP:$dst, (fmul FP:$src1, FP:$src2))]>;
Duraid Madina91ed0a12005-03-17 18:17:03 +0000495def FMOV : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
496 "mov $dst = $src;;">; // XXX: there _is_ no fmov
Duraid Madina7abaf902005-10-29 16:08:30 +0000497def FMA : AForm_DAG<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3),
498 "fma $dst = $src1, $src2, $src3;;",
499 [(set FP:$dst, (fadd (fmul FP:$src1, FP:$src2), FP:$src3))]>;
500def FMS : AForm_DAG<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3),
501 "fms $dst = $src1, $src2, $src3;;",
502 [(set FP:$dst, (fsub (fmul FP:$src1, FP:$src2), FP:$src3))]>;
503def FNMA : AForm_DAG<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3),
504 "fnma $dst = $src1, $src2, $src3;;",
505 [(set FP:$dst, (fneg (fadd (fmul FP:$src1, FP:$src2), FP:$src3)))]>;
Duraid Madina17decbb2005-11-02 02:37:18 +0000506def FABS : AForm_DAG<0x03, 0x0b, (ops FP:$dst, FP:$src),
507 "fabs $dst = $src;;",
508 [(set FP:$dst, (fabs FP:$src))]>;
Duraid Madina7abaf902005-10-29 16:08:30 +0000509def FNEG : AForm_DAG<0x03, 0x0b, (ops FP:$dst, FP:$src),
510 "fneg $dst = $src;;",
511 [(set FP:$dst, (fneg FP:$src))]>;
Duraid Madina17decbb2005-11-02 02:37:18 +0000512def FNEGABS : AForm_DAG<0x03, 0x0b, (ops FP:$dst, FP:$src),
513 "fnegabs $dst = $src;;",
514 [(set FP:$dst, (fneg (fabs FP:$src)))]>;
Duraid Madina91ed0a12005-03-17 18:17:03 +0000515
516def CFMAS1 : AForm<0x03, 0x0b,
517 (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3, PR:$qp),
518 "($qp) fma.s1 $dst = $src1, $src2, $src3;;">;
519def CFNMAS1 : AForm<0x03, 0x0b,
520 (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3, PR:$qp),
521 "($qp) fnma.s1 $dst = $src1, $src2, $src3;;">;
522
Duraid Madina41ff5022005-04-08 10:01:48 +0000523def FRCPAS1 : AForm<0x03, 0x0b, (ops FP:$dstFR, PR:$dstPR, FP:$src1, FP:$src2),
524 "frcpa.s1 $dstFR, $dstPR = $src1, $src2;;">;
Duraid Madina91ed0a12005-03-17 18:17:03 +0000525
526def XMAL : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3),
527 "xma.l $dst = $src1, $src2, $src3;;">;
528
529def FCVTXF : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
530 "fcvt.xf $dst = $src;;">;
531def FCVTXUF : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
532 "fcvt.xuf $dst = $src;;">;
533def FCVTXUFS1 : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
534 "fcvt.xuf.s1 $dst = $src;;">;
535def FCVTFX : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
536 "fcvt.fx $dst = $src;;">;
537def FCVTFXU : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
538 "fcvt.fxu $dst = $src;;">;
539
540def FCVTFXTRUNC : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
541 "fcvt.fx.trunc $dst = $src;;">;
542def FCVTFXUTRUNC : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
543 "fcvt.fxu.trunc $dst = $src;;">;
544
545def FCVTFXTRUNCS1 : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
546 "fcvt.fx.trunc.s1 $dst = $src;;">;
547def FCVTFXUTRUNCS1 : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
548 "fcvt.fxu.trunc.s1 $dst = $src;;">;
549
550def FNORMD : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
551 "fnorm.d $dst = $src;;">;
552
553def GETFD : AForm<0x03, 0x0b, (ops GR:$dst, FP:$src),
554 "getf.d $dst = $src;;">;
555def SETFD : AForm<0x03, 0x0b, (ops FP:$dst, GR:$src),
556 "setf.d $dst = $src;;">;
557
558def GETFSIG : AForm<0x03, 0x0b, (ops GR:$dst, FP:$src),
559 "getf.sig $dst = $src;;">;
560def SETFSIG : AForm<0x03, 0x0b, (ops FP:$dst, GR:$src),
561 "setf.sig $dst = $src;;">;
562
Duraid Madina6c912bf2005-11-01 03:07:25 +0000563// these four FP<->int conversion patterns need checking/cleaning
564def SINT_TO_FP : Pat<(sint_to_fp GR:$src),
565 (FNORMD (FCVTXF (SETFSIG GR:$src)))>;
566def UINT_TO_FP : Pat<(uint_to_fp GR:$src),
567 (FNORMD (FCVTXUF (SETFSIG GR:$src)))>;
Duraid Madinab81b6132005-11-01 03:32:15 +0000568def FP_TO_SINT : Pat<(i64 (fp_to_sint FP:$src)),
Duraid Madina6c912bf2005-11-01 03:07:25 +0000569 (GETFSIG (FCVTFXTRUNC FP:$src))>;
Duraid Madinab81b6132005-11-01 03:32:15 +0000570def FP_TO_UINT : Pat<(i64 (fp_to_uint FP:$src)),
Duraid Madina6c912bf2005-11-01 03:07:25 +0000571 (GETFSIG (FCVTFXUTRUNC FP:$src))>;
Duraid Madinab81b6132005-11-01 03:32:15 +0000572
Duraid Madina6c912bf2005-11-01 03:07:25 +0000573
Duraid Madina91ed0a12005-03-17 18:17:03 +0000574let isTerminator = 1, isBranch = 1 in {
Duraid Madinaf221c262005-10-28 17:46:35 +0000575 def BRL_NOTCALL : RawForm<0x03, 0xb0, (ops i64imm:$dst),
576 "(p0) brl.cond.sptk $dst;;">;
Duraid Madina91ed0a12005-03-17 18:17:03 +0000577 def BRLCOND_NOTCALL : RawForm<0x03, 0xb0, (ops PR:$qp, i64imm:$dst),
578 "($qp) brl.cond.sptk $dst;;">;
579 def BRCOND_NOTCALL : RawForm<0x03, 0xb0, (ops PR:$qp, GR:$dst),
580 "($qp) br.cond.sptk $dst;;">;
581}
582
583let isCall = 1, isTerminator = 1, isBranch = 1,
Chris Lattner6b917672005-04-12 15:12:19 +0000584 Uses = [out0,out1,out2,out3,out4,out5,out6,out7],
Duraid Madina91ed0a12005-03-17 18:17:03 +0000585// all calls clobber non-callee-saved registers, and for now, they are these:
586 Defs = [r2,r3,r8,r9,r10,r11,r14,r15,r16,r17,r18,r19,r20,r21,r22,r23,r24,
587 r25,r26,r27,r28,r29,r30,r31,
588 p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,
589 F6,F7,F8,F9,F10,F11,F12,F13,F14,F15,
590 F32,F33,F34,F35,F36,F37,F38,F39,F40,F41,F42,F43,F44,F45,F46,F47,F48,F49,
591 F50,F51,F52,F53,F54,F55,F56,
592 F57,F58,F59,F60,F61,F62,F63,F64,F65,F66,F67,F68,F69,F70,F71,F72,F73,F74,
593 F75,F76,F77,F78,F79,F80,F81,
594 F82,F83,F84,F85,F86,F87,F88,F89,F90,F91,F92,F93,F94,F95,F96,F97,F98,F99,
595 F100,F101,F102,F103,F104,F105,
596 F106,F107,F108,F109,F110,F111,F112,F113,F114,F115,F116,F117,F118,F119,
597 F120,F121,F122,F123,F124,F125,F126,F127,
598 out0,out1,out2,out3,out4,out5,out6,out7] in {
Duraid Madinaf221c262005-10-28 17:46:35 +0000599// old pattern call
600 def BRCALL: RawForm<0x03, 0xb0, (ops calltarget:$dst),
Duraid Madina91ed0a12005-03-17 18:17:03 +0000601 "br.call.sptk rp = $dst;;">; // FIXME: teach llvm about branch regs?
Duraid Madinaf221c262005-10-28 17:46:35 +0000602// new daggy stuff!
603 def BRCALL_IPREL : RawForm<0x03, 0xb0, (ops calltarget:$dst, variable_ops),
604 "br.call.sptk rp = $dst;;">; // FIXME: teach llvm about branch regs?
605 def BRCALL_INDIRECT : RawForm<0x03, 0xb0, (ops GR:$branchreg, variable_ops),
606 "br.call.sptk rp = $branchreg;;">; // FIXME: teach llvm about branch regs?
Duraid Madina91ed0a12005-03-17 18:17:03 +0000607 def BRLCOND_CALL : RawForm<0x03, 0xb0, (ops PR:$qp, i64imm:$dst),
608 "($qp) brl.cond.call.sptk $dst;;">;
609 def BRCOND_CALL : RawForm<0x03, 0xb0, (ops PR:$qp, GR:$dst),
610 "($qp) br.cond.call.sptk $dst;;">;
611}
612
613let isTerminator = 1, isReturn = 1 in
614 def RET : RawForm<0x03, 0xb0, (ops), "br.ret.sptk.many rp;;">; // return
615
616