blob: 1c8858171cc70182a87965ad89093d4bbb562dec [file] [log] [blame]
Duraid Madina9b9d45f2005-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
18def u6imm : Operand<i8>;
19def s16imm : Operand<i16>;
20def s21imm : Operand<i32> {
21 let PrintMethod = "printS21ImmOperand";
22}
23def u32imm : Operand<i32> {
24 let PrintMethod = "printU32ImmOperand";
25}
26def s32imm : Operand<i32> {
27 let PrintMethod = "printS32ImmOperand";
28}
29def u64imm : Operand<i64> {
30 let PrintMethod = "printU64ImmOperand";
31}
32
33// the asmprinter needs to know about calls
34let PrintMethod = "printCallOperand" in
35 def calltarget : Operand<i64>;
36
37def PHI : PseudoInstIA64<(ops), "PHI">;
38def IDEF : PseudoInstIA64<(ops), "// IDEF">;
Duraid Madina09c61b92005-04-04 04:50:57 +000039def IUSE : PseudoInstIA64<(ops), "// IUSE">;
Duraid Madina9b9d45f2005-03-17 18:17:03 +000040def WTF : PseudoInstIA64<(ops), "que??">;
41def ADJUSTCALLSTACKUP : PseudoInstIA64<(ops), "// ADJUSTCALLSTACKUP">;
42def ADJUSTCALLSTACKDOWN : PseudoInstIA64<(ops), "// ADJUSTCALLSTACKDOWN">;
43def PSEUDO_ALLOC : PseudoInstIA64<(ops), "// PSEUDO_ALLOC">;
44
45def ALLOC : AForm<0x03, 0x0b,
46 (ops GR:$dst, i8imm:$inputs, i8imm:$locals, i8imm:$outputs, i8imm:$rotating),
47 "alloc $dst = ar.pfs,$inputs,$locals,$outputs,$rotating;;">;
48
49def MOV : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src), "mov $dst = $src;;">;
50def PMOV : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src, PR:$qp),
51 "($qp) mov $dst = $src;;">;
52
53def SPILL_ALL_PREDICATES_TO_GR : AForm<0x03, 0x0b, (ops GR:$dst),
54 "mov $dst = pr;;">;
55def FILL_ALL_PREDICATES_FROM_GR : AForm<0x03, 0x0b, (ops GR:$src),
56 "mov pr = $src;;">;
57
58let isTwoAddress = 1 in {
59 def CMOV : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src2, GR:$src, PR:$qp),
60 "($qp) mov $dst = $src;;">;
61}
62
Duraid Madina291e1262005-03-31 07:32:32 +000063def PFMOV : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src, PR:$qp),
64 "($qp) mov $dst = $src;;">;
65
66let isTwoAddress = 1 in {
67 def CFMOV : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src2, FP:$src, PR:$qp),
68 "($qp) mov $dst = $src;;">;
69}
70
Duraid Madina9b9d45f2005-03-17 18:17:03 +000071let isTwoAddress = 1 in {
72 def TCMPNE : AForm<0x03, 0x0b,
73 (ops PR:$dst, PR:$src2, GR:$src3, GR:$src4),
74 "cmp.ne $dst, p0 = $src3, $src4;;">;
75
76 def TPCMPEQOR : AForm<0x03, 0x0b,
77 (ops PR:$dst, PR:$src2, GR:$src3, GR:$src4, PR:$qp),
78 "($qp) cmp.eq.or $dst, p0 = $src3, $src4;;">;
79
80 def TPCMPNE : AForm<0x03, 0x0b,
81 (ops PR:$dst, PR:$src2, GR:$src3, GR:$src4, PR:$qp),
82 "($qp) cmp.ne $dst, p0 = $src3, $src4;;">;
83
84 def TPCMPEQ : AForm<0x03, 0x0b,
85 (ops PR:$dst, PR:$src2, GR:$src3, GR:$src4, PR:$qp),
86 "($qp) cmp.eq $dst, p0 = $src3, $src4;;">;
87}
88
89def MOVI32 : AForm<0x03, 0x0b, (ops GR:$dst, u32imm:$imm),
90 "mov $dst = $imm;;">;
91def MOVLI32 : AForm<0x03, 0x0b, (ops GR:$dst, u32imm:$imm),
92 "movl $dst = $imm;;">;
93def MOVLSI32 : AForm<0x03, 0x0b, (ops GR:$dst, s32imm:$imm),
94 "movl $dst = $imm;;">;
95def MOVLI64 : AForm<0x03, 0x0b, (ops GR:$dst, u64imm:$imm),
96 "movl $dst = $imm;;">;
97
98def AND : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
99 "and $dst = $src1, $src2;;">;
100def OR : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
101 "or $dst = $src1, $src2;;">;
102def XOR : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
103 "xor $dst = $src1, $src2;;">;
104def SHL : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
105 "shl $dst = $src1, $src2;;">;
106def SHLI : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, s21imm:$imm),
107 "shl $dst = $src1, $imm;;">; // FIXME: 6 immediate bits, not 21
108def SHRU : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
109 "shr.u $dst = $src1, $src2;;">;
110def SHRS : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
111 "shr $dst = $src1, $src2;;">;
112
113def DEPZ : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, u6imm:$imm1, u6imm:$imm2), "dep.z $dst = $src1, $imm1, $imm2;;">;
114
115def SXT1 : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src), "sxt1 $dst = $src;;">;
116def ZXT1 : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src), "zxt1 $dst = $src;;">;
117def SXT2 : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src), "sxt2 $dst = $src;;">;
118def ZXT2 : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src), "zxt2 $dst = $src;;">;
119def SXT4 : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src), "sxt4 $dst = $src;;">;
120def ZXT4 : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src), "zxt4 $dst = $src;;">;
121
122// the following are all a bit unfortunate: we throw away the complement
123// of the compare!
124def CMPEQ : AForm<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
125 "cmp.eq $dst, p0 = $src1, $src2;;">;
126def CMPGT : AForm<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
127 "cmp.gt $dst, p0 = $src1, $src2;;">;
128def CMPGE : AForm<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
129 "cmp.ge $dst, p0 = $src1, $src2;;">;
130def CMPLT : AForm<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
131 "cmp.lt $dst, p0 = $src1, $src2;;">;
132def CMPLE : AForm<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
133 "cmp.le $dst, p0 = $src1, $src2;;">;
134def CMPNE : AForm<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
135 "cmp.ne $dst, p0 = $src1, $src2;;">;
136def CMPLTU : AForm<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
137 "cmp.ltu $dst, p0 = $src1, $src2;;">;
138def CMPGTU : AForm<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
139 "cmp.gtu $dst, p0 = $src1, $src2;;">;
140def CMPLEU : AForm<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
141 "cmp.leu $dst, p0 = $src1, $src2;;">;
142def CMPGEU : AForm<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
143 "cmp.geu $dst, p0 = $src1, $src2;;">;
144
145// and we do the whole thing again for FP compares!
146def FCMPEQ : AForm<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
147 "fcmp.eq $dst, p0 = $src1, $src2;;">;
148def FCMPGT : AForm<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
149 "fcmp.gt $dst, p0 = $src1, $src2;;">;
150def FCMPGE : AForm<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
151 "fcmp.ge $dst, p0 = $src1, $src2;;">;
152def FCMPLT : AForm<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
153 "fcmp.lt $dst, p0 = $src1, $src2;;">;
154def FCMPLE : AForm<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
155 "fcmp.le $dst, p0 = $src1, $src2;;">;
156def FCMPNE : AForm<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
157 "fcmp.neq $dst, p0 = $src1, $src2;;">;
158def FCMPLTU : AForm<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
159 "fcmp.ltu $dst, p0 = $src1, $src2;;">;
160def FCMPGTU : AForm<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
161 "fcmp.gtu $dst, p0 = $src1, $src2;;">;
162def FCMPLEU : AForm<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
163 "fcmp.leu $dst, p0 = $src1, $src2;;">;
164def FCMPGEU : AForm<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
165 "fcmp.geu $dst, p0 = $src1, $src2;;">;
166
167def PCMPEQOR : AForm<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2, PR:$qp),
168 "($qp) cmp.eq.or $dst, p0 = $src1, $src2;;">;
169def PCMPEQUNC : AForm<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2, PR:$qp),
170 "($qp) cmp.eq.unc $dst, p0 = $src1, $src2;;">;
171def PCMPNE : AForm<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2, PR:$qp),
172 "($qp) cmp.ne $dst, p0 = $src1, $src2;;">;
173
174// two destinations!
175def BCMPEQ : AForm<0x03, 0x0b, (ops PR:$dst1, PR:$dst2, GR:$src1, GR:$src2),
176 "cmp.eq $dst1, dst2 = $src1, $src2;;">;
177
178def ADD : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
179 "add $dst = $src1, $src2;;">;
180
181def ADDIMM22 : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, s21imm:$imm),
182 "add $dst = $imm, $src1;;">;
183def CADDIMM22 : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, s21imm:$imm, PR:$qp),
184 "($qp) add $dst = $imm, $src1;;">;
185
186let isTwoAddress = 1 in {
187def TPCADDIMM22 : AForm<0x03, 0x0b,
188 (ops GR:$dst, GR:$src1, s21imm:$imm, PR:$qp),
189 "($qp) add $dst = $imm, $dst;;">;
190def TPCMPIMM8NE : AForm<0x03, 0x0b,
191 (ops PR:$dst, PR:$src1, s21imm:$imm, GR:$src2, PR:$qp),
192 "($qp) cmp.ne $dst , p0 = $imm, $src2;;">;
193}
194
195def SUB : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
196 "sub $dst = $src1, $src2;;">;
197
198def ST1 : AForm<0x03, 0x0b, (ops GR:$dstPtr, GR:$value),
199 "st1 [$dstPtr] = $value;;">;
200def ST2 : AForm<0x03, 0x0b, (ops GR:$dstPtr, GR:$value),
201 "st2 [$dstPtr] = $value;;">;
202def ST4 : AForm<0x03, 0x0b, (ops GR:$dstPtr, GR:$value),
203 "st4 [$dstPtr] = $value;;">;
204def ST8 : AForm<0x03, 0x0b, (ops GR:$dstPtr, GR:$value),
205 "st8 [$dstPtr] = $value;;">;
206
207def LD1 : AForm<0x03, 0x0b, (ops GR:$dst, GR:$srcPtr),
208 "ld1 $dst = [$srcPtr];;">;
209def LD2 : AForm<0x03, 0x0b, (ops GR:$dst, GR:$srcPtr),
210 "ld2 $dst = [$srcPtr];;">;
211def LD4 : AForm<0x03, 0x0b, (ops GR:$dst, GR:$srcPtr),
212 "ld4 $dst = [$srcPtr];;">;
213def LD8 : AForm<0x03, 0x0b, (ops GR:$dst, GR:$srcPtr),
214 "ld8 $dst = [$srcPtr];;">;
215
216// some FP stuff:
217def FADD : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2),
218 "fadd $dst = $src1, $src2;;">;
219def FADDS: AForm<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2),
220 "fadd.s $dst = $src1, $src2;;">;
221def FSUB : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2),
222 "fsub $dst = $src1, $src2;;">;
223def FMPY : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2),
224 "fmpy $dst = $src1, $src2;;">;
225def FMOV : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
226 "mov $dst = $src;;">; // XXX: there _is_ no fmov
227def FMA : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3),
228 "fma $dst = $src1, $src2, $src3;;">;
Duraid Madinab366a022005-04-06 09:54:09 +0000229def FMS : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3),
230 "fms $dst = $src1, $src2, $src3;;">;
Duraid Madina9b9d45f2005-03-17 18:17:03 +0000231def FNMA : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3),
232 "fnma $dst = $src1, $src2, $src3;;">;
Duraid Madinaa7ee8b82005-04-02 05:18:38 +0000233def FABS : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
234 "fabs $dst = $src;;">;
235def FNEG : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
236 "fneg $dst = $src;;">;
Duraid Madina5c156b72005-04-02 10:06:27 +0000237def FNEGABS : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
238 "fnegabs $dst = $src;;">;
Duraid Madina9b9d45f2005-03-17 18:17:03 +0000239
240def CFMAS1 : AForm<0x03, 0x0b,
241 (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3, PR:$qp),
242 "($qp) fma.s1 $dst = $src1, $src2, $src3;;">;
243def CFNMAS1 : AForm<0x03, 0x0b,
244 (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3, PR:$qp),
245 "($qp) fnma.s1 $dst = $src1, $src2, $src3;;">;
246
247// FIXME: we 'explode' FRCPA (which should write two registers) into two
248// operations that write one each. this is a waste, and is also destroying
249// f127. not cool.
250def FRCPAS1FLOAT : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2),
251 "frcpa.s1 $dst , p0 = $src1, $src2;;">;
252// XXX: this _will_ break things: (f127)
253def FRCPAS1PREDICATE : AForm<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
254 "frcpa.s1 f127 , $dst = $src1, $src2;; // XXX FIXME!!!!">;
255
256def XMAL : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3),
257 "xma.l $dst = $src1, $src2, $src3;;">;
258
259def FCVTXF : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
260 "fcvt.xf $dst = $src;;">;
261def FCVTXUF : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
262 "fcvt.xuf $dst = $src;;">;
263def FCVTXUFS1 : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
264 "fcvt.xuf.s1 $dst = $src;;">;
265def FCVTFX : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
266 "fcvt.fx $dst = $src;;">;
267def FCVTFXU : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
268 "fcvt.fxu $dst = $src;;">;
269
270def FCVTFXTRUNC : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
271 "fcvt.fx.trunc $dst = $src;;">;
272def FCVTFXUTRUNC : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
273 "fcvt.fxu.trunc $dst = $src;;">;
274
275def FCVTFXTRUNCS1 : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
276 "fcvt.fx.trunc.s1 $dst = $src;;">;
277def FCVTFXUTRUNCS1 : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
278 "fcvt.fxu.trunc.s1 $dst = $src;;">;
279
280def FNORMD : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
281 "fnorm.d $dst = $src;;">;
282
283def GETFD : AForm<0x03, 0x0b, (ops GR:$dst, FP:$src),
284 "getf.d $dst = $src;;">;
285def SETFD : AForm<0x03, 0x0b, (ops FP:$dst, GR:$src),
286 "setf.d $dst = $src;;">;
287
288def GETFSIG : AForm<0x03, 0x0b, (ops GR:$dst, FP:$src),
289 "getf.sig $dst = $src;;">;
290def SETFSIG : AForm<0x03, 0x0b, (ops FP:$dst, GR:$src),
291 "setf.sig $dst = $src;;">;
292
293def LDF4 : AForm<0x03, 0x0b, (ops FP:$dst, GR:$srcPtr),
294 "ldfs $dst = [$srcPtr];;">;
295def LDF8 : AForm<0x03, 0x0b, (ops FP:$dst, GR:$srcPtr),
296 "ldfd $dst = [$srcPtr];;">;
297
298def STF4 : AForm<0x03, 0x0b, (ops GR:$dstPtr, FP:$value),
299 "stfs [$dstPtr] = $value;;">;
300def STF8 : AForm<0x03, 0x0b, (ops GR:$dstPtr, FP:$value),
301 "stfd [$dstPtr] = $value;;">;
302
303let isTerminator = 1, isBranch = 1 in {
304 def BRLCOND_NOTCALL : RawForm<0x03, 0xb0, (ops PR:$qp, i64imm:$dst),
305 "($qp) brl.cond.sptk $dst;;">;
306 def BRCOND_NOTCALL : RawForm<0x03, 0xb0, (ops PR:$qp, GR:$dst),
307 "($qp) br.cond.sptk $dst;;">;
308}
309
310let isCall = 1, isTerminator = 1, isBranch = 1,
311// all calls clobber non-callee-saved registers, and for now, they are these:
312 Defs = [r2,r3,r8,r9,r10,r11,r14,r15,r16,r17,r18,r19,r20,r21,r22,r23,r24,
313 r25,r26,r27,r28,r29,r30,r31,
314 p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,
315 F6,F7,F8,F9,F10,F11,F12,F13,F14,F15,
316 F32,F33,F34,F35,F36,F37,F38,F39,F40,F41,F42,F43,F44,F45,F46,F47,F48,F49,
317 F50,F51,F52,F53,F54,F55,F56,
318 F57,F58,F59,F60,F61,F62,F63,F64,F65,F66,F67,F68,F69,F70,F71,F72,F73,F74,
319 F75,F76,F77,F78,F79,F80,F81,
320 F82,F83,F84,F85,F86,F87,F88,F89,F90,F91,F92,F93,F94,F95,F96,F97,F98,F99,
321 F100,F101,F102,F103,F104,F105,
322 F106,F107,F108,F109,F110,F111,F112,F113,F114,F115,F116,F117,F118,F119,
323 F120,F121,F122,F123,F124,F125,F126,F127,
324 out0,out1,out2,out3,out4,out5,out6,out7] in {
325 def BRCALL : RawForm<0x03, 0xb0, (ops calltarget:$dst),
326 "br.call.sptk rp = $dst;;">; // FIXME: teach llvm about branch regs?
327 def BRLCOND_CALL : RawForm<0x03, 0xb0, (ops PR:$qp, i64imm:$dst),
328 "($qp) brl.cond.call.sptk $dst;;">;
329 def BRCOND_CALL : RawForm<0x03, 0xb0, (ops PR:$qp, GR:$dst),
330 "($qp) br.cond.call.sptk $dst;;">;
331}
332
333let isTerminator = 1, isReturn = 1 in
334 def RET : RawForm<0x03, 0xb0, (ops), "br.ret.sptk.many rp;;">; // return
335
336