blob: 3d527206560ef64bfaa00263691cd5056e995107 [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 Madinaa8de8a52005-12-22 06:38:38 +000018//===----------------------------------------------------------------------===//
19// IA-64 specific DAG Nodes.
20//
21
22def IA64getfd : SDNode<"IA64ISD::GETFD", SDTFPToIntOp, []>;
23
24//===---------
25
Duraid Madinac252f332005-10-29 04:13:40 +000026def u2imm : Operand<i8>;
Duraid Madina91ed0a12005-03-17 18:17:03 +000027def u6imm : Operand<i8>;
Duraid Madinab484f7c2005-04-07 12:32:24 +000028def s8imm : Operand<i8> {
29 let PrintMethod = "printS8ImmOperand";
30}
Duraid Madinaf221c262005-10-28 17:46:35 +000031def s14imm : Operand<i64> {
Duraid Madinab484f7c2005-04-07 12:32:24 +000032 let PrintMethod = "printS14ImmOperand";
33}
Duraid Madinaa743e002005-12-22 03:56:03 +000034def s22imm : Operand<i64> {
Duraid Madinafb43ef72005-04-11 05:55:56 +000035 let PrintMethod = "printS22ImmOperand";
Duraid Madina91ed0a12005-03-17 18:17:03 +000036}
37def u64imm : Operand<i64> {
38 let PrintMethod = "printU64ImmOperand";
39}
Duraid Madina0a7c2b92005-04-14 10:08:01 +000040def s64imm : Operand<i64> {
41 let PrintMethod = "printS64ImmOperand";
42}
Duraid Madina91ed0a12005-03-17 18:17:03 +000043
Duraid Madinaf221c262005-10-28 17:46:35 +000044let PrintMethod = "printGlobalOperand" in
45 def globaladdress : Operand<i64>;
46
Duraid Madina91ed0a12005-03-17 18:17:03 +000047// the asmprinter needs to know about calls
48let PrintMethod = "printCallOperand" in
49 def calltarget : Operand<i64>;
50
Duraid Madinaf221c262005-10-28 17:46:35 +000051/* new daggy action!!! */
52
Duraid Madinac252f332005-10-29 04:13:40 +000053def is32ones : PatLeaf<(i64 imm), [{
54 // is32ones predicate - True if the immediate is 0x00000000FFFFFFFF
55 // Used to create ZXT4s appropriately
Duraid Madina7abaf902005-10-29 16:08:30 +000056 uint64_t v = (uint64_t)N->getValue();
Duraid Madinac252f332005-10-29 04:13:40 +000057 return (v == 0x00000000FFFFFFFFLL);
58}]>;
59
Duraid Madina7abaf902005-10-29 16:08:30 +000060// isMIXable predicates - True if the immediate is
61// 0xFF00FF00FF00FF00, 0x00FF00FF00FF00FF
62// etc, through 0x00000000FFFFFFFF
63// Used to test for the suitability of mix*
64def isMIX1Lable: PatLeaf<(i64 imm), [{
65 return((uint64_t)N->getValue()==0xFF00FF00FF00FF00LL);
66}]>;
67def isMIX1Rable: PatLeaf<(i64 imm), [{
68 return((uint64_t)N->getValue()==0x00FF00FF00FF00FFLL);
69}]>;
70def isMIX2Lable: PatLeaf<(i64 imm), [{
71 return((uint64_t)N->getValue()==0xFFFF0000FFFF0000LL);
72}]>;
73def isMIX2Rable: PatLeaf<(i64 imm), [{
74 return((uint64_t)N->getValue()==0x0000FFFF0000FFFFLL);
75}]>;
76def isMIX4Lable: PatLeaf<(i64 imm), [{
77 return((uint64_t)N->getValue()==0xFFFFFFFF00000000LL);
78}]>;
79def isMIX4Rable: PatLeaf<(i64 imm), [{
80 return((uint64_t)N->getValue()==0x00000000FFFFFFFFLL);
81}]>;
82
Duraid Madinac252f332005-10-29 04:13:40 +000083def isSHLADDimm: PatLeaf<(i64 imm), [{
84 // isSHLADDimm predicate - True if the immediate is exactly 1, 2, 3 or 4
85 // - 0 is *not* okay.
86 // Used to create shladd instructions appropriately
87 int64_t v = (int64_t)N->getValue();
88 return (v >= 1 && v <= 4);
89}]>;
90
Duraid Madinaf221c262005-10-28 17:46:35 +000091def immSExt14 : PatLeaf<(i64 imm), [{
92 // immSExt14 predicate - True if the immediate fits in a 14-bit sign extended
93 // field. Used by instructions like 'adds'.
94 int64_t v = (int64_t)N->getValue();
95 return (v <= 8191 && v >= -8192);
96}]>;
97
98def imm64 : PatLeaf<(i64 imm), [{
99 // imm64 predicate - True if the immediate fits in a 64-bit
100 // field - i.e., true. used to keep movl happy
101 return true;
102}]>;
103
Duraid Madinaa284b662005-11-01 01:29:55 +0000104def ADD : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
105 "add $dst = $src1, $src2;;",
106 [(set GR:$dst, (add GR:$src1, GR:$src2))]>;
107
108def ADD1 : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
109 "add $dst = $src1, $src2, 1;;",
110 [(set GR:$dst, (add (add GR:$src1, GR:$src2), 1))]>;
111
112def ADDS : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, s14imm:$imm),
113 "adds $dst = $imm, $src1;;",
114 [(set GR:$dst, (add GR:$src1, immSExt14:$imm))]>;
115
Duraid Madina7ac646e2005-11-04 00:57:56 +0000116def PADDS: AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, s14imm:$imm, PR:$qp),
117 "($qp) adds $dst = $imm, $src1;;",
118 []>;
119
Duraid Madinaa284b662005-11-01 01:29:55 +0000120def MOVL : AForm_DAG<0x03, 0x0b, (ops GR:$dst, s64imm:$imm),
121 "movl $dst = $imm;;",
122 [(set GR:$dst, imm64:$imm)]>;
123
124def ADDL_GA : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, globaladdress:$imm),
125 "addl $dst = $imm, $src1;;",
126 []>;
Duraid Madinaa743e002005-12-22 03:56:03 +0000127
128// hmm
129def ADDL_EA : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, calltarget:$imm),
130 "addl $dst = $imm, $src1;;",
131 []>;
132
Duraid Madinaa284b662005-11-01 01:29:55 +0000133def SUB : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
134 "sub $dst = $src1, $src2;;",
135 [(set GR:$dst, (sub GR:$src1, GR:$src2))]>;
136
137def SUB1 : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
138 "sub $dst = $src1, $src2, 1;;",
139 [(set GR:$dst, (add (sub GR: $src1, GR:$src2), -1))]>;
140
141let isTwoAddress = 1 in {
142def TPCADDIMM22 : AForm<0x03, 0x0b,
143 (ops GR:$dst, GR:$src1, s22imm:$imm, PR:$qp),
144 "($qp) add $dst = $imm, $dst;;">;
145def TPCMPIMM8NE : AForm<0x03, 0x0b,
146 (ops PR:$dst, PR:$src1, s22imm:$imm, GR:$src2, PR:$qp),
147 "($qp) cmp.ne $dst , p0 = $imm, $src2;;">;
148}
149
150// zero extend a bool (predicate reg) into an integer reg
151def ZXTb : Pat<(zext PR:$src),
152 (TPCADDIMM22 (ADDS r0, 0), 1, PR:$src)>;
153
154// normal sign/zero-extends
Duraid Madinac252f332005-10-29 04:13:40 +0000155def SXT1 : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src), "sxt1 $dst = $src;;",
156 [(set GR:$dst, (sext_inreg GR:$src, i8))]>;
157def ZXT1 : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src), "zxt1 $dst = $src;;",
158 [(set GR:$dst, (and GR:$src, 255))]>;
159def SXT2 : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src), "sxt2 $dst = $src;;",
160 [(set GR:$dst, (sext_inreg GR:$src, i16))]>;
161def ZXT2 : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src), "zxt2 $dst = $src;;",
162 [(set GR:$dst, (and GR:$src, 65535))]>;
163def SXT4 : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src), "sxt4 $dst = $src;;",
164 [(set GR:$dst, (sext_inreg GR:$src, i32))]>;
165def ZXT4 : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src), "zxt4 $dst = $src;;",
166 [(set GR:$dst, (and GR:$src, is32ones))]>;
167
Duraid Madina7abaf902005-10-29 16:08:30 +0000168// fixme: shrs vs shru?
169def MIX1L : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
170 "mix1.l $dst = $src1, $src2;;",
171 [(set GR:$dst, (or (and GR:$src1, isMIX1Lable),
Chris Lattnerc54cddd2005-12-05 02:34:29 +0000172 (and (srl GR:$src2, (i64 8)), isMIX1Lable)))]>;
Duraid Madina7abaf902005-10-29 16:08:30 +0000173
174def MIX2L : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
175 "mix2.l $dst = $src1, $src2;;",
176 [(set GR:$dst, (or (and GR:$src1, isMIX2Lable),
Chris Lattnerc54cddd2005-12-05 02:34:29 +0000177 (and (srl GR:$src2, (i64 16)), isMIX2Lable)))]>;
Duraid Madina7abaf902005-10-29 16:08:30 +0000178
179def MIX4L : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
180 "mix4.l $dst = $src1, $src2;;",
181 [(set GR:$dst, (or (and GR:$src1, isMIX4Lable),
Chris Lattnerc54cddd2005-12-05 02:34:29 +0000182 (and (srl GR:$src2, (i64 32)), isMIX4Lable)))]>;
Duraid Madina7abaf902005-10-29 16:08:30 +0000183
184def MIX1R : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
185 "mix1.r $dst = $src1, $src2;;",
Chris Lattnerc54cddd2005-12-05 02:34:29 +0000186 [(set GR:$dst, (or (and (shl GR:$src1, (i64 8)), isMIX1Rable),
Duraid Madina7abaf902005-10-29 16:08:30 +0000187 (and GR:$src2, isMIX1Rable)))]>;
188
189def MIX2R : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
190 "mix2.r $dst = $src1, $src2;;",
Chris Lattnerc54cddd2005-12-05 02:34:29 +0000191 [(set GR:$dst, (or (and (shl GR:$src1, (i64 16)), isMIX2Rable),
Duraid Madina7abaf902005-10-29 16:08:30 +0000192 (and GR:$src2, isMIX2Rable)))]>;
193
194def MIX4R : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
195 "mix4.r $dst = $src1, $src2;;",
Chris Lattnerc54cddd2005-12-05 02:34:29 +0000196 [(set GR:$dst, (or (and (shl GR:$src1, (i64 32)), isMIX4Rable),
Duraid Madina7abaf902005-10-29 16:08:30 +0000197 (and GR:$src2, isMIX4Rable)))]>;
198
Duraid Madinaf221c262005-10-28 17:46:35 +0000199def GETFSIGD : AForm_DAG<0x03, 0x0b, (ops GR:$dst, FP:$src),
200 "getf.sig $dst = $src;;",
201 []>;
202
203def SETFSIGD : AForm_DAG<0x03, 0x0b, (ops FP:$dst, GR:$src),
204 "setf.sig $dst = $src;;",
205 []>;
206
207def XMALD : AForm_DAG<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3),
208 "xma.l $dst = $src1, $src2, $src3;;",
209 []>;
Duraid Madina7abaf902005-10-29 16:08:30 +0000210def XMAHD : AForm_DAG<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3),
211 "xma.h $dst = $src1, $src2, $src3;;",
212 []>;
213def XMAHUD : AForm_DAG<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3),
214 "xma.hu $dst = $src1, $src2, $src3;;",
215 []>;
Duraid Madinaf221c262005-10-28 17:46:35 +0000216
217// pseudocode for integer multiplication
218def : Pat<(mul GR:$src1, GR:$src2),
219 (GETFSIGD (XMALD (SETFSIGD GR:$src1), (SETFSIGD GR:$src2), F0))>;
Duraid Madina7abaf902005-10-29 16:08:30 +0000220def : Pat<(mulhs GR:$src1, GR:$src2),
221 (GETFSIGD (XMAHD (SETFSIGD GR:$src1), (SETFSIGD GR:$src2), F0))>;
222def : Pat<(mulhu GR:$src1, GR:$src2),
223 (GETFSIGD (XMAHUD (SETFSIGD GR:$src1), (SETFSIGD GR:$src2), F0))>;
Duraid Madinaf221c262005-10-28 17:46:35 +0000224
225// TODO: addp4 (addp4 dst = src, r0 is a 32-bit add)
226// has imm form, too
227
228// def ADDS : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, s14imm:$imm),
229// "adds $dst = $imm, $src1;;">;
230
Duraid Madinaf221c262005-10-28 17:46:35 +0000231def AND : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
232 "and $dst = $src1, $src2;;",
233 [(set GR:$dst, (and GR:$src1, GR:$src2))]>;
234def ANDCM : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
235 "andcm $dst = $src1, $src2;;",
236 [(set GR:$dst, (and GR:$src1, (not GR:$src2)))]>;
237// TODO: and/andcm/or/xor/add/sub/shift immediate forms
238def OR : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
239 "or $dst = $src1, $src2;;",
240 [(set GR:$dst, (or GR:$src1, GR:$src2))]>;
241
242def pOR : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2, PR:$qp),
243 "($qp) or $dst = $src1, $src2;;">;
244
Duraid Madinaf221c262005-10-28 17:46:35 +0000245// the following are all a bit unfortunate: we throw away the complement
246// of the compare!
247def CMPEQ : AForm_DAG<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
248 "cmp.eq $dst, p0 = $src1, $src2;;",
249 [(set PR:$dst, (seteq GR:$src1, GR:$src2))]>;
250def CMPGT : AForm_DAG<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
251 "cmp.gt $dst, p0 = $src1, $src2;;",
252 [(set PR:$dst, (setgt GR:$src1, GR:$src2))]>;
253def CMPGE : AForm_DAG<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
254 "cmp.ge $dst, p0 = $src1, $src2;;",
255 [(set PR:$dst, (setge GR:$src1, GR:$src2))]>;
256def CMPLT : AForm_DAG<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
257 "cmp.lt $dst, p0 = $src1, $src2;;",
258 [(set PR:$dst, (setlt GR:$src1, GR:$src2))]>;
259def CMPLE : AForm_DAG<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
260 "cmp.le $dst, p0 = $src1, $src2;;",
261 [(set PR:$dst, (setle GR:$src1, GR:$src2))]>;
262def CMPNE : AForm_DAG<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
263 "cmp.ne $dst, p0 = $src1, $src2;;",
264 [(set PR:$dst, (setne GR:$src1, GR:$src2))]>;
265def CMPLTU: AForm_DAG<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
Duraid Madina57b7ee92005-10-30 10:14:19 +0000266 "cmp.ltu $dst, p0 = $src1, $src2;;",
Duraid Madinaf221c262005-10-28 17:46:35 +0000267 [(set PR:$dst, (setult GR:$src1, GR:$src2))]>;
268def CMPGTU: AForm_DAG<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
Duraid Madina57b7ee92005-10-30 10:14:19 +0000269 "cmp.gtu $dst, p0 = $src1, $src2;;",
Duraid Madinaf221c262005-10-28 17:46:35 +0000270 [(set PR:$dst, (setugt GR:$src1, GR:$src2))]>;
271def CMPLEU: AForm_DAG<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
Duraid Madina57b7ee92005-10-30 10:14:19 +0000272 "cmp.leu $dst, p0 = $src1, $src2;;",
Duraid Madinaf221c262005-10-28 17:46:35 +0000273 [(set PR:$dst, (setule GR:$src1, GR:$src2))]>;
274def CMPGEU: AForm_DAG<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2),
Duraid Madina57b7ee92005-10-30 10:14:19 +0000275 "cmp.geu $dst, p0 = $src1, $src2;;",
Duraid Madinaf221c262005-10-28 17:46:35 +0000276 [(set PR:$dst, (setuge GR:$src1, GR:$src2))]>;
277
Duraid Madina88fc69f2005-10-31 01:42:11 +0000278// and we do the whole thing again for FP compares!
279def FCMPEQ : AForm_DAG<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
280 "fcmp.eq $dst, p0 = $src1, $src2;;",
281 [(set PR:$dst, (seteq FP:$src1, FP:$src2))]>;
282def FCMPGT : AForm_DAG<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
283 "fcmp.gt $dst, p0 = $src1, $src2;;",
284 [(set PR:$dst, (setgt FP:$src1, FP:$src2))]>;
285def FCMPGE : AForm_DAG<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
286 "fcmp.ge $dst, p0 = $src1, $src2;;",
287 [(set PR:$dst, (setge FP:$src1, FP:$src2))]>;
288def FCMPLT : AForm_DAG<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
289 "fcmp.lt $dst, p0 = $src1, $src2;;",
290 [(set PR:$dst, (setlt FP:$src1, FP:$src2))]>;
291def FCMPLE : AForm_DAG<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
292 "fcmp.le $dst, p0 = $src1, $src2;;",
293 [(set PR:$dst, (setle FP:$src1, FP:$src2))]>;
294def FCMPNE : AForm_DAG<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
295 "fcmp.neq $dst, p0 = $src1, $src2;;",
296 [(set PR:$dst, (setne FP:$src1, FP:$src2))]>;
297def FCMPLTU: AForm_DAG<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
298 "fcmp.ltu $dst, p0 = $src1, $src2;;",
299 [(set PR:$dst, (setult FP:$src1, FP:$src2))]>;
300def FCMPGTU: AForm_DAG<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
301 "fcmp.gtu $dst, p0 = $src1, $src2;;",
302 [(set PR:$dst, (setugt FP:$src1, FP:$src2))]>;
303def FCMPLEU: AForm_DAG<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
304 "fcmp.leu $dst, p0 = $src1, $src2;;",
305 [(set PR:$dst, (setule FP:$src1, FP:$src2))]>;
306def FCMPGEU: AForm_DAG<0x03, 0x0b, (ops PR:$dst, FP:$src1, FP:$src2),
307 "fcmp.geu $dst, p0 = $src1, $src2;;",
308 [(set PR:$dst, (setuge FP:$src1, FP:$src2))]>;
309
Duraid Madina7ac646e2005-11-04 00:57:56 +0000310def PCMPEQUNCR0R0 : AForm<0x03, 0x0b, (ops PR:$dst, PR:$qp),
311 "($qp) cmp.eq.unc $dst, p0 = r0, r0;;">;
312
313def : Pat<(trunc GR:$src), // truncate i64 to i1
314 (CMPNE GR:$src, r0)>; // $src!=0? If so, PR:$dst=true
315
316let isTwoAddress=1 in {
317 def TPCMPEQR0R0 : AForm<0x03, 0x0b, (ops PR:$dst, PR:$bogus, PR:$qp),
318 "($qp) cmp.eq $dst, p0 = r0, r0;;">;
319 def TPCMPNER0R0 : AForm<0x03, 0x0b, (ops PR:$dst, PR:$bogus, PR:$qp),
320 "($qp) cmp.ne $dst, p0 = r0, r0;;">;
321}
322
323/* our pseudocode for OR on predicates is:
324pC = pA OR pB
325-------------
326(pA) cmp.eq.unc pC,p0 = r0,r0 // pC = pA
327 ;;
328(pB) cmp.eq pC,p0 = r0,r0 // if (pB) pC = 1 */
329
330def bOR : Pat<(or PR:$src1, PR:$src2),
331 (TPCMPEQR0R0 (PCMPEQUNCR0R0 PR:$src1), PR:$src2)>;
332
333/* our pseudocode for AND on predicates is:
334 *
335(pA) cmp.eq.unc pC,p0 = r0,r0 // pC = pA
336 cmp.eq pTemp,p0 = r0,r0 // pTemp = NOT pB
337 ;;
338(pB) cmp.ne pTemp,p0 = r0,r0
339 ;;
340(pTemp)cmp.ne pC,p0 = r0,r0 // if (NOT pB) pC = 0 */
341
342def bAND : Pat<(and PR:$src1, PR:$src2),
343 ( TPCMPNER0R0 (PCMPEQUNCR0R0 PR:$src1),
344 (TPCMPNER0R0 (CMPEQ r0, r0), PR:$src2) )>;
345
346/* one possible routine for XOR on predicates is:
347
348 // Compute px = py ^ pz
349 // using sum of products: px = (py & !pz) | (pz & !py)
350 // Uses 5 instructions in 3 cycles.
351 // cycle 1
352(pz) cmp.eq.unc px = r0, r0 // px = pz
353(py) cmp.eq.unc pt = r0, r0 // pt = py
354 ;;
355 // cycle 2
356(pt) cmp.ne.and px = r0, r0 // px = px & !pt (px = pz & !pt)
357(pz) cmp.ne.and pt = r0, r0 // pt = pt & !pz
358 ;;
359 } { .mmi
360 // cycle 3
361(pt) cmp.eq.or px = r0, r0 // px = px | pt
362
363*** Another, which we use here, requires one scratch GR. it is:
364
365 mov rt = 0 // initialize rt off critical path
366 ;;
367
368 // cycle 1
369(pz) cmp.eq.unc px = r0, r0 // px = pz
370(pz) mov rt = 1 // rt = pz
371 ;;
372 // cycle 2
373(py) cmp.ne px = 1, rt // if (py) px = !pz
374
375.. these routines kindly provided by Jim Hull
376*/
377
378def bXOR : Pat<(xor PR:$src1, PR:$src2),
379 (TPCMPIMM8NE (PCMPEQUNCR0R0 PR:$src2), 1,
380 (PADDS r0, 1, PR:$src2),
381 PR:$src1)>;
382
383def XOR : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
384 "xor $dst = $src1, $src2;;",
385 [(set GR:$dst, (xor GR:$src1, GR:$src2))]>;
386
387def SHLADD: AForm_DAG<0x03, 0x0b, (ops GR:$dst,GR:$src1,s64imm:$imm,GR:$src2),
388 "shladd $dst = $src1, $imm, $src2;;",
389 [(set GR:$dst, (add GR:$src2, (shl GR:$src1, isSHLADDimm:$imm)))]>;
390
391def SHL : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
392 "shl $dst = $src1, $src2;;",
393 [(set GR:$dst, (shl GR:$src1, GR:$src2))]>;
394
395def SHRU : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
396 "shr.u $dst = $src1, $src2;;",
397 [(set GR:$dst, (srl GR:$src1, GR:$src2))]>;
398
399def SHRS : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src1, GR:$src2),
400 "shr $dst = $src1, $src2;;",
401 [(set GR:$dst, (sra GR:$src1, GR:$src2))]>;
402
Duraid Madina17decbb2005-11-02 02:37:18 +0000403def MOV : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src), "mov $dst = $src;;">;
Duraid Madina76034f92005-11-14 01:17:30 +0000404def FMOV : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
405 "mov $dst = $src;;">; // XXX: there _is_ no fmov
Duraid Madina17decbb2005-11-02 02:37:18 +0000406def PMOV : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src, PR:$qp),
407 "($qp) mov $dst = $src;;">;
408
409def SPILL_ALL_PREDICATES_TO_GR : AForm<0x03, 0x0b, (ops GR:$dst),
410 "mov $dst = pr;;">;
411def FILL_ALL_PREDICATES_FROM_GR : AForm<0x03, 0x0b, (ops GR:$src),
412 "mov pr = $src;;">;
413
414let isTwoAddress = 1 in {
415 def CMOV : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src2, GR:$src, PR:$qp),
416 "($qp) mov $dst = $src;;">;
417}
418
419def PFMOV : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src, PR:$qp),
420 "($qp) mov $dst = $src;;">;
421
422let isTwoAddress = 1 in {
423 def CFMOV : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src2, FP:$src, PR:$qp),
424 "($qp) mov $dst = $src;;">;
425}
426
Duraid Madina17decbb2005-11-02 02:37:18 +0000427def SELECTINT : Pat<(select PR:$which, GR:$src1, GR:$src2),
428 (CMOV (MOV GR:$src2), GR:$src1, PR:$which)>; // note order!
Duraid Madina76034f92005-11-14 01:17:30 +0000429def SELECTFP : Pat<(select PR:$which, FP:$src1, FP:$src2),
430 (CFMOV (FMOV FP:$src2), FP:$src1, PR:$which)>; // note order!
Duraid Madina0d5d08b2006-01-11 01:21:12 +0000431// TODO: can do this faster, w/o using any integer regs (see pattern isel)
Duraid Madinac712fd62006-01-11 01:38:07 +0000432def SELECTBOOL : Pat<(select PR:$which, PR:$src1, PR:$src2), // note order!
433 (CMPNE (CMOV
434 (MOV (TPCADDIMM22 (ADDS r0, 0), 1, PR:$src2)),
435 (TPCADDIMM22 (ADDS r0, 0), 1, PR:$src1), PR:$which), r0)>;
Duraid Madina17decbb2005-11-02 02:37:18 +0000436
437// load constants of various sizes // FIXME: prettyprint -ve constants
438def : Pat<(i64 immSExt14:$imm), (ADDS r0, immSExt14:$imm)>;
439def : Pat<(i64 imm64:$imm), (MOVL imm64:$imm)>;
Chris Lattner674660f2005-11-03 05:45:34 +0000440def : Pat<(i1 -1), (CMPEQ r0, r0)>; // TODO: this should just be a ref to p0
Duraid Madinaf0f22a52005-11-03 10:09:32 +0000441def : Pat<(i1 0), (CMPNE r0, r0)>; // TODO: any instruction actually *using*
442 // this predicate should be killed!
Duraid Madina17decbb2005-11-02 02:37:18 +0000443
Duraid Madinaf221c262005-10-28 17:46:35 +0000444// TODO: support postincrement (reg, imm9) loads+stores - this needs more
445// tablegen support
446
Chris Lattner3e0335c2005-08-19 00:47:42 +0000447def PHI : PseudoInstIA64<(ops variable_ops), "PHI">;
448def IDEF : PseudoInstIA64<(ops variable_ops), "// IDEF">;
Duraid Madina88fc69f2005-10-31 01:42:11 +0000449
450def IDEF_GR_D : PseudoInstIA64_DAG<(ops GR:$reg), "// $reg = IDEF",
451 [(set GR:$reg, (undef))]>;
452def IDEF_FP_D : PseudoInstIA64_DAG<(ops FP:$reg), "// $reg = IDEF",
453 [(set FP:$reg, (undef))]>;
454def IDEF_PR_D : PseudoInstIA64_DAG<(ops PR:$reg), "// $reg = IDEF",
455 [(set PR:$reg, (undef))]>;
456
Chris Lattner3e0335c2005-08-19 00:47:42 +0000457def IUSE : PseudoInstIA64<(ops variable_ops), "// IUSE">;
458def ADJUSTCALLSTACKUP : PseudoInstIA64<(ops variable_ops),
459 "// ADJUSTCALLSTACKUP">;
460def ADJUSTCALLSTACKDOWN : PseudoInstIA64<(ops variable_ops),
461 "// ADJUSTCALLSTACKDOWN">;
Chris Lattner9e4a4ee2005-09-14 21:11:13 +0000462def PSEUDO_ALLOC : PseudoInstIA64<(ops GR:$foo), "// PSEUDO_ALLOC">;
Duraid Madina91ed0a12005-03-17 18:17:03 +0000463
464def ALLOC : AForm<0x03, 0x0b,
465 (ops GR:$dst, i8imm:$inputs, i8imm:$locals, i8imm:$outputs, i8imm:$rotating),
466 "alloc $dst = ar.pfs,$inputs,$locals,$outputs,$rotating;;">;
467
Duraid Madina91ed0a12005-03-17 18:17:03 +0000468let isTwoAddress = 1 in {
469 def TCMPNE : AForm<0x03, 0x0b,
470 (ops PR:$dst, PR:$src2, GR:$src3, GR:$src4),
471 "cmp.ne $dst, p0 = $src3, $src4;;">;
472
473 def TPCMPEQOR : AForm<0x03, 0x0b,
474 (ops PR:$dst, PR:$src2, GR:$src3, GR:$src4, PR:$qp),
475 "($qp) cmp.eq.or $dst, p0 = $src3, $src4;;">;
476
477 def TPCMPNE : AForm<0x03, 0x0b,
478 (ops PR:$dst, PR:$src2, GR:$src3, GR:$src4, PR:$qp),
479 "($qp) cmp.ne $dst, p0 = $src3, $src4;;">;
480
481 def TPCMPEQ : AForm<0x03, 0x0b,
482 (ops PR:$dst, PR:$src2, GR:$src3, GR:$src4, PR:$qp),
483 "($qp) cmp.eq $dst, p0 = $src3, $src4;;">;
484}
485
Duraid Madinafb43ef72005-04-11 05:55:56 +0000486def MOVSIMM14 : AForm<0x03, 0x0b, (ops GR:$dst, s14imm:$imm),
Duraid Madina91ed0a12005-03-17 18:17:03 +0000487 "mov $dst = $imm;;">;
Duraid Madinafb43ef72005-04-11 05:55:56 +0000488def MOVSIMM22 : AForm<0x03, 0x0b, (ops GR:$dst, s22imm:$imm),
489 "mov $dst = $imm;;">;
Duraid Madina0a7c2b92005-04-14 10:08:01 +0000490def MOVLIMM64 : AForm<0x03, 0x0b, (ops GR:$dst, s64imm:$imm),
Duraid Madina91ed0a12005-03-17 18:17:03 +0000491 "movl $dst = $imm;;">;
492
Duraid Madinafb43ef72005-04-11 05:55:56 +0000493def SHLI : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, u6imm:$imm),
494 "shl $dst = $src1, $imm;;">;
Duraid Madinafb43ef72005-04-11 05:55:56 +0000495def SHRUI : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, u6imm:$imm),
Duraid Madinab484f7c2005-04-07 12:32:24 +0000496 "shr.u $dst = $src1, $imm;;">;
Duraid Madinafb43ef72005-04-11 05:55:56 +0000497def SHRSI : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, u6imm:$imm),
Duraid Madinab484f7c2005-04-07 12:32:24 +0000498 "shr $dst = $src1, $imm;;">;
Duraid Madina91ed0a12005-03-17 18:17:03 +0000499
Duraid Madina41ff5022005-04-08 10:01:48 +0000500def EXTRU : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, u6imm:$imm1, u6imm:$imm2),
501 "extr.u $dst = $src1, $imm1, $imm2;;">;
502
Duraid Madina91ed0a12005-03-17 18:17:03 +0000503def DEPZ : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, u6imm:$imm1, u6imm:$imm2), "dep.z $dst = $src1, $imm1, $imm2;;">;
504
Duraid Madina91ed0a12005-03-17 18:17:03 +0000505def PCMPEQOR : AForm<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2, PR:$qp),
506 "($qp) cmp.eq.or $dst, p0 = $src1, $src2;;">;
507def PCMPEQUNC : AForm<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2, PR:$qp),
508 "($qp) cmp.eq.unc $dst, p0 = $src1, $src2;;">;
509def PCMPNE : AForm<0x03, 0x0b, (ops PR:$dst, GR:$src1, GR:$src2, PR:$qp),
510 "($qp) cmp.ne $dst, p0 = $src1, $src2;;">;
511
512// two destinations!
513def BCMPEQ : AForm<0x03, 0x0b, (ops PR:$dst1, PR:$dst2, GR:$src1, GR:$src2),
514 "cmp.eq $dst1, dst2 = $src1, $src2;;">;
515
Duraid Madinab484f7c2005-04-07 12:32:24 +0000516def ADDIMM14 : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, s14imm:$imm),
517 "adds $dst = $imm, $src1;;">;
Duraid Madina91ed0a12005-03-17 18:17:03 +0000518
Duraid Madinafb43ef72005-04-11 05:55:56 +0000519def ADDIMM22 : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, s22imm:$imm),
Duraid Madina91ed0a12005-03-17 18:17:03 +0000520 "add $dst = $imm, $src1;;">;
Duraid Madinafb43ef72005-04-11 05:55:56 +0000521def CADDIMM22 : AForm<0x03, 0x0b, (ops GR:$dst, GR:$src1, s22imm:$imm, PR:$qp),
Duraid Madina91ed0a12005-03-17 18:17:03 +0000522 "($qp) add $dst = $imm, $src1;;">;
523
Duraid Madinab484f7c2005-04-07 12:32:24 +0000524def SUBIMM8 : AForm<0x03, 0x0b, (ops GR:$dst, s8imm:$imm, GR:$src2),
525 "sub $dst = $imm, $src2;;">;
Duraid Madina91ed0a12005-03-17 18:17:03 +0000526
Evan Cheng14c53b42005-12-26 09:11:45 +0000527let isStore = 1, noResults = 1 in {
Duraid Madina7abaf902005-10-29 16:08:30 +0000528 def ST1 : AForm<0x03, 0x0b, (ops GR:$dstPtr, GR:$value),
529 "st1 [$dstPtr] = $value;;">;
530 def ST2 : AForm<0x03, 0x0b, (ops GR:$dstPtr, GR:$value),
531 "st2 [$dstPtr] = $value;;">;
532 def ST4 : AForm<0x03, 0x0b, (ops GR:$dstPtr, GR:$value),
533 "st4 [$dstPtr] = $value;;">;
534 def ST8 : AForm<0x03, 0x0b, (ops GR:$dstPtr, GR:$value),
535 "st8 [$dstPtr] = $value;;">;
536 def STF4 : AForm<0x03, 0x0b, (ops GR:$dstPtr, FP:$value),
537 "stfs [$dstPtr] = $value;;">;
538 def STF8 : AForm<0x03, 0x0b, (ops GR:$dstPtr, FP:$value),
539 "stfd [$dstPtr] = $value;;">;
Duraid Madina266ff602006-01-17 02:04:52 +0000540 def STF_SPILL : AForm<0x03, 0x0b, (ops GR:$dstPtr, FP:$value),
541 "stf.spill [$dstPtr] = $value;;">;
Duraid Madina7abaf902005-10-29 16:08:30 +0000542}
Duraid Madina91ed0a12005-03-17 18:17:03 +0000543
Duraid Madina7abaf902005-10-29 16:08:30 +0000544let isLoad = 1 in {
545 def LD1 : AForm<0x03, 0x0b, (ops GR:$dst, GR:$srcPtr),
546 "ld1 $dst = [$srcPtr];;">;
547 def LD2 : AForm<0x03, 0x0b, (ops GR:$dst, GR:$srcPtr),
548 "ld2 $dst = [$srcPtr];;">;
549 def LD4 : AForm<0x03, 0x0b, (ops GR:$dst, GR:$srcPtr),
550 "ld4 $dst = [$srcPtr];;">;
551 def LD8 : AForm<0x03, 0x0b, (ops GR:$dst, GR:$srcPtr),
552 "ld8 $dst = [$srcPtr];;">;
553 def LDF4 : AForm<0x03, 0x0b, (ops FP:$dst, GR:$srcPtr),
554 "ldfs $dst = [$srcPtr];;">;
555 def LDF8 : AForm<0x03, 0x0b, (ops FP:$dst, GR:$srcPtr),
556 "ldfd $dst = [$srcPtr];;">;
Duraid Madina266ff602006-01-17 02:04:52 +0000557 def LDF_FILL : AForm<0x03, 0x0b, (ops FP:$dst, GR:$srcPtr),
558 "ldf.fill $dst = [$srcPtr];;">;
Duraid Madina7abaf902005-10-29 16:08:30 +0000559}
Duraid Madina91ed0a12005-03-17 18:17:03 +0000560
Duraid Madina7abaf902005-10-29 16:08:30 +0000561def POPCNT : AForm_DAG<0x03, 0x0b, (ops GR:$dst, GR:$src),
562 "popcnt $dst = $src;;",
563 [(set GR:$dst, (ctpop GR:$src))]>;
Duraid Madina25163d82005-05-11 05:16:09 +0000564
Duraid Madina7abaf902005-10-29 16:08:30 +0000565// some FP stuff: // TODO: single-precision stuff?
566def FADD : AForm_DAG<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2),
567 "fadd $dst = $src1, $src2;;",
568 [(set FP:$dst, (fadd FP:$src1, FP:$src2))]>;
Duraid Madina91ed0a12005-03-17 18:17:03 +0000569def FADDS: AForm<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2),
570 "fadd.s $dst = $src1, $src2;;">;
Duraid Madina7abaf902005-10-29 16:08:30 +0000571def FSUB : AForm_DAG<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2),
572 "fsub $dst = $src1, $src2;;",
573 [(set FP:$dst, (fsub FP:$src1, FP:$src2))]>;
574def FMPY : AForm_DAG<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2),
575 "fmpy $dst = $src1, $src2;;",
576 [(set FP:$dst, (fmul FP:$src1, FP:$src2))]>;
Duraid Madina7abaf902005-10-29 16:08:30 +0000577def FMA : AForm_DAG<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3),
578 "fma $dst = $src1, $src2, $src3;;",
579 [(set FP:$dst, (fadd (fmul FP:$src1, FP:$src2), FP:$src3))]>;
580def FMS : AForm_DAG<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3),
581 "fms $dst = $src1, $src2, $src3;;",
582 [(set FP:$dst, (fsub (fmul FP:$src1, FP:$src2), FP:$src3))]>;
583def FNMA : AForm_DAG<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3),
584 "fnma $dst = $src1, $src2, $src3;;",
585 [(set FP:$dst, (fneg (fadd (fmul FP:$src1, FP:$src2), FP:$src3)))]>;
Duraid Madina17decbb2005-11-02 02:37:18 +0000586def FABS : AForm_DAG<0x03, 0x0b, (ops FP:$dst, FP:$src),
587 "fabs $dst = $src;;",
588 [(set FP:$dst, (fabs FP:$src))]>;
Duraid Madina7abaf902005-10-29 16:08:30 +0000589def FNEG : AForm_DAG<0x03, 0x0b, (ops FP:$dst, FP:$src),
590 "fneg $dst = $src;;",
591 [(set FP:$dst, (fneg FP:$src))]>;
Duraid Madina17decbb2005-11-02 02:37:18 +0000592def FNEGABS : AForm_DAG<0x03, 0x0b, (ops FP:$dst, FP:$src),
593 "fnegabs $dst = $src;;",
594 [(set FP:$dst, (fneg (fabs FP:$src)))]>;
Duraid Madina91ed0a12005-03-17 18:17:03 +0000595
Duraid Madinaba187772006-01-16 06:33:38 +0000596let isTwoAddress=1 in {
597def TCFMAS1 : AForm<0x03, 0x0b,
598 (ops FP:$dst, FP:$bogussrc, FP:$src1, FP:$src2, FP:$src3, PR:$qp),
599 "($qp) fma.s1 $dst = $src1, $src2, $src3;;">;
600def TCFMADS0 : AForm<0x03, 0x0b,
601 (ops FP:$dst, FP:$bogussrc, FP:$src1, FP:$src2, FP:$src3, PR:$qp),
602 "($qp) fma.d.s0 $dst = $src1, $src2, $src3;;">;
603}
604
Duraid Madina91ed0a12005-03-17 18:17:03 +0000605def CFMAS1 : AForm<0x03, 0x0b,
606 (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3, PR:$qp),
607 "($qp) fma.s1 $dst = $src1, $src2, $src3;;">;
608def CFNMAS1 : AForm<0x03, 0x0b,
609 (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3, PR:$qp),
610 "($qp) fnma.s1 $dst = $src1, $src2, $src3;;">;
611
Duraid Madinaba187772006-01-16 06:33:38 +0000612def CFMADS1 : AForm<0x03, 0x0b,
613 (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3, PR:$qp),
614 "($qp) fma.d.s1 $dst = $src1, $src2, $src3;;">;
615def CFMADS0 : AForm<0x03, 0x0b,
616 (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3, PR:$qp),
617 "($qp) fma.d.s0 $dst = $src1, $src2, $src3;;">;
618def CFNMADS1 : AForm<0x03, 0x0b,
619 (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3, PR:$qp),
620 "($qp) fnma.d.s1 $dst = $src1, $src2, $src3;;">;
621
622def FRCPAS0 : AForm<0x03, 0x0b, (ops FP:$dstFR, PR:$dstPR, FP:$src1, FP:$src2),
623 "frcpa.s0 $dstFR, $dstPR = $src1, $src2;;">;
Duraid Madina41ff5022005-04-08 10:01:48 +0000624def FRCPAS1 : AForm<0x03, 0x0b, (ops FP:$dstFR, PR:$dstPR, FP:$src1, FP:$src2),
625 "frcpa.s1 $dstFR, $dstPR = $src1, $src2;;">;
Duraid Madina91ed0a12005-03-17 18:17:03 +0000626
627def XMAL : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src1, FP:$src2, FP:$src3),
628 "xma.l $dst = $src1, $src2, $src3;;">;
629
630def FCVTXF : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
631 "fcvt.xf $dst = $src;;">;
632def FCVTXUF : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
633 "fcvt.xuf $dst = $src;;">;
634def FCVTXUFS1 : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
635 "fcvt.xuf.s1 $dst = $src;;">;
636def FCVTFX : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
637 "fcvt.fx $dst = $src;;">;
638def FCVTFXU : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
639 "fcvt.fxu $dst = $src;;">;
640
641def FCVTFXTRUNC : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
642 "fcvt.fx.trunc $dst = $src;;">;
643def FCVTFXUTRUNC : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
644 "fcvt.fxu.trunc $dst = $src;;">;
645
646def FCVTFXTRUNCS1 : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
647 "fcvt.fx.trunc.s1 $dst = $src;;">;
648def FCVTFXUTRUNCS1 : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
649 "fcvt.fxu.trunc.s1 $dst = $src;;">;
650
651def FNORMD : AForm<0x03, 0x0b, (ops FP:$dst, FP:$src),
652 "fnorm.d $dst = $src;;">;
653
Duraid Madina3608ab82005-12-22 07:13:51 +0000654def GETFD : AForm<0x03, 0x0b, (ops GR:$dst, FP:$src),
655 "getf.d $dst = $src;;">;
Duraid Madina91ed0a12005-03-17 18:17:03 +0000656def SETFD : AForm<0x03, 0x0b, (ops FP:$dst, GR:$src),
657 "setf.d $dst = $src;;">;
658
659def GETFSIG : AForm<0x03, 0x0b, (ops GR:$dst, FP:$src),
660 "getf.sig $dst = $src;;">;
661def SETFSIG : AForm<0x03, 0x0b, (ops FP:$dst, GR:$src),
662 "setf.sig $dst = $src;;">;
663
Duraid Madina6c912bf2005-11-01 03:07:25 +0000664// these four FP<->int conversion patterns need checking/cleaning
665def SINT_TO_FP : Pat<(sint_to_fp GR:$src),
666 (FNORMD (FCVTXF (SETFSIG GR:$src)))>;
667def UINT_TO_FP : Pat<(uint_to_fp GR:$src),
668 (FNORMD (FCVTXUF (SETFSIG GR:$src)))>;
Duraid Madinab81b6132005-11-01 03:32:15 +0000669def FP_TO_SINT : Pat<(i64 (fp_to_sint FP:$src)),
Duraid Madina6c912bf2005-11-01 03:07:25 +0000670 (GETFSIG (FCVTFXTRUNC FP:$src))>;
Duraid Madinab81b6132005-11-01 03:32:15 +0000671def FP_TO_UINT : Pat<(i64 (fp_to_uint FP:$src)),
Duraid Madina6c912bf2005-11-01 03:07:25 +0000672 (GETFSIG (FCVTFXUTRUNC FP:$src))>;
Duraid Madinab81b6132005-11-01 03:32:15 +0000673
Duraid Madina6c912bf2005-11-01 03:07:25 +0000674
Evan Cheng14c53b42005-12-26 09:11:45 +0000675let isTerminator = 1, isBranch = 1, noResults = 1 in {
Duraid Madinaf221c262005-10-28 17:46:35 +0000676 def BRL_NOTCALL : RawForm<0x03, 0xb0, (ops i64imm:$dst),
677 "(p0) brl.cond.sptk $dst;;">;
Duraid Madina91ed0a12005-03-17 18:17:03 +0000678 def BRLCOND_NOTCALL : RawForm<0x03, 0xb0, (ops PR:$qp, i64imm:$dst),
679 "($qp) brl.cond.sptk $dst;;">;
680 def BRCOND_NOTCALL : RawForm<0x03, 0xb0, (ops PR:$qp, GR:$dst),
681 "($qp) br.cond.sptk $dst;;">;
682}
683
Evan Cheng14c53b42005-12-26 09:11:45 +0000684let isCall = 1, noResults = 1, /* isTerminator = 1, isBranch = 1, */
Chris Lattner6b917672005-04-12 15:12:19 +0000685 Uses = [out0,out1,out2,out3,out4,out5,out6,out7],
Duraid Madina91ed0a12005-03-17 18:17:03 +0000686// all calls clobber non-callee-saved registers, and for now, they are these:
687 Defs = [r2,r3,r8,r9,r10,r11,r14,r15,r16,r17,r18,r19,r20,r21,r22,r23,r24,
688 r25,r26,r27,r28,r29,r30,r31,
689 p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,
690 F6,F7,F8,F9,F10,F11,F12,F13,F14,F15,
691 F32,F33,F34,F35,F36,F37,F38,F39,F40,F41,F42,F43,F44,F45,F46,F47,F48,F49,
692 F50,F51,F52,F53,F54,F55,F56,
693 F57,F58,F59,F60,F61,F62,F63,F64,F65,F66,F67,F68,F69,F70,F71,F72,F73,F74,
694 F75,F76,F77,F78,F79,F80,F81,
695 F82,F83,F84,F85,F86,F87,F88,F89,F90,F91,F92,F93,F94,F95,F96,F97,F98,F99,
696 F100,F101,F102,F103,F104,F105,
697 F106,F107,F108,F109,F110,F111,F112,F113,F114,F115,F116,F117,F118,F119,
698 F120,F121,F122,F123,F124,F125,F126,F127,
699 out0,out1,out2,out3,out4,out5,out6,out7] in {
Duraid Madinaf221c262005-10-28 17:46:35 +0000700// old pattern call
701 def BRCALL: RawForm<0x03, 0xb0, (ops calltarget:$dst),
Duraid Madina91ed0a12005-03-17 18:17:03 +0000702 "br.call.sptk rp = $dst;;">; // FIXME: teach llvm about branch regs?
Duraid Madinaf221c262005-10-28 17:46:35 +0000703// new daggy stuff!
Duraid Madinaa743e002005-12-22 03:56:03 +0000704
705// calls a globaladdress
Duraid Madina06dcc192005-12-25 14:07:01 +0000706 def BRCALL_IPREL_GA : RawForm<0x03, 0xb0, (ops calltarget:$dst),
Duraid Madinaf221c262005-10-28 17:46:35 +0000707 "br.call.sptk rp = $dst;;">; // FIXME: teach llvm about branch regs?
Duraid Madinaa743e002005-12-22 03:56:03 +0000708// calls an externalsymbol
Duraid Madina06dcc192005-12-25 14:07:01 +0000709 def BRCALL_IPREL_ES : RawForm<0x03, 0xb0, (ops calltarget:$dst),
Duraid Madinaa743e002005-12-22 03:56:03 +0000710 "br.call.sptk rp = $dst;;">; // FIXME: teach llvm about branch regs?
711// calls through a function descriptor
Duraid Madina06dcc192005-12-25 14:07:01 +0000712 def BRCALL_INDIRECT : RawForm<0x03, 0xb0, (ops GR:$branchreg),
Duraid Madinaf221c262005-10-28 17:46:35 +0000713 "br.call.sptk rp = $branchreg;;">; // FIXME: teach llvm about branch regs?
Duraid Madina91ed0a12005-03-17 18:17:03 +0000714 def BRLCOND_CALL : RawForm<0x03, 0xb0, (ops PR:$qp, i64imm:$dst),
715 "($qp) brl.cond.call.sptk $dst;;">;
716 def BRCOND_CALL : RawForm<0x03, 0xb0, (ops PR:$qp, GR:$dst),
717 "($qp) br.cond.call.sptk $dst;;">;
718}
719
Evan Cheng14c53b42005-12-26 09:11:45 +0000720let isTerminator = 1, isReturn = 1, noResults = 1 in
Duraid Madina91ed0a12005-03-17 18:17:03 +0000721 def RET : RawForm<0x03, 0xb0, (ops), "br.ret.sptk.many rp;;">; // return
722
723