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