1 //===- IA64InstrInfo.td - Describe the IA64 Instruction Set -----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
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.
14 //===----------------------------------------------------------------------===//
16 include "IA64InstrFormats.td"
18 //===----------------------------------------------------------------------===//
19 // IA-64 specific DAG Nodes.
22 def IA64getfd : SDNode<"IA64ISD::GETFD", SDTFPToIntOp, []>;
24 def retflag : SDNode<"IA64ISD::RET_FLAG", SDTNone,
25 [SDNPHasChain, SDNPOptInFlag]>;
30 class isA { bit A=1; } // I or M unit
31 class isM { bit M=1; } // M unit
32 class isI { bit I=1; } // I unit
33 class isB { bit B=1; } // B unit
34 class isF { bit F=1; } // F unit
35 class isLX { bit LX=1; } // I/B
39 def u2imm : Operand<i8>;
40 def u6imm : Operand<i8>;
41 def s8imm : Operand<i8> {
42 let PrintMethod = "printS8ImmOperand";
44 def s14imm : Operand<i64> {
45 let PrintMethod = "printS14ImmOperand";
47 def s22imm : Operand<i64> {
48 let PrintMethod = "printS22ImmOperand";
50 def u64imm : Operand<i64> {
51 let PrintMethod = "printU64ImmOperand";
53 def s64imm : Operand<i64> {
54 let PrintMethod = "printS64ImmOperand";
57 let PrintMethod = "printGlobalOperand" in
58 def globaladdress : Operand<i64>;
60 // the asmprinter needs to know about calls
61 let PrintMethod = "printCallOperand" in
62 def calltarget : Operand<i64>;
64 /* new daggy action!!! */
66 def is32ones : PatLeaf<(i64 imm), [{
67 // is32ones predicate - True if the immediate is 0x00000000FFFFFFFF
68 // Used to create ZXT4s appropriately
69 uint64_t v = (uint64_t)N->getZExtValue();
70 return (v == 0x00000000FFFFFFFFLL);
73 // isMIXable predicates - True if the immediate is
74 // 0xFF00FF00FF00FF00, 0x00FF00FF00FF00FF
75 // etc, through 0x00000000FFFFFFFF
76 // Used to test for the suitability of mix*
77 def isMIX1Lable: PatLeaf<(i64 imm), [{
78 return((uint64_t)N->getZExtValue()==0xFF00FF00FF00FF00LL);
80 def isMIX1Rable: PatLeaf<(i64 imm), [{
81 return((uint64_t)N->getZExtValue()==0x00FF00FF00FF00FFLL);
83 def isMIX2Lable: PatLeaf<(i64 imm), [{
84 return((uint64_t)N->getZExtValue()==0xFFFF0000FFFF0000LL);
86 def isMIX2Rable: PatLeaf<(i64 imm), [{
87 return((uint64_t)N->getZExtValue()==0x0000FFFF0000FFFFLL);
89 def isMIX4Lable: PatLeaf<(i64 imm), [{
90 return((uint64_t)N->getZExtValue()==0xFFFFFFFF00000000LL);
92 def isMIX4Rable: PatLeaf<(i64 imm), [{
93 return((uint64_t)N->getZExtValue()==0x00000000FFFFFFFFLL);
96 def isSHLADDimm: PatLeaf<(i64 imm), [{
97 // isSHLADDimm predicate - True if the immediate is exactly 1, 2, 3 or 4
99 // Used to create shladd instructions appropriately
100 int64_t v = (int64_t)N->getZExtValue();
101 return (v >= 1 && v <= 4);
104 def immSExt14 : PatLeaf<(i64 imm), [{
105 // immSExt14 predicate - True if the immediate fits in a 14-bit sign extended
106 // field. Used by instructions like 'adds'.
107 int64_t v = (int64_t)N->getZExtValue();
108 return (v <= 8191 && v >= -8192);
111 // imm64 predicate - True if the immediate fits in a 64-bit
112 // field - i.e., true. used to keep movl happy
113 def imm64 : PatLeaf<(i64 imm)>;
115 def ADD : AForm_DAG<0x03, 0x0b, (outs GR:$dst), (ins GR:$src1, GR:$src2),
116 "add $dst = $src1, $src2",
117 [(set GR:$dst, (add GR:$src1, GR:$src2))]>, isA;
119 def ADD1 : AForm_DAG<0x03, 0x0b, (outs GR:$dst), (ins GR:$src1, GR:$src2),
120 "add $dst = $src1, $src2, 1",
121 [(set GR:$dst, (add (add GR:$src1, GR:$src2), 1))]>, isA;
123 def ADDS : AForm_DAG<0x03, 0x0b, (outs GR:$dst), (ins GR:$src1, s14imm:$imm),
124 "adds $dst = $imm, $src1",
125 [(set GR:$dst, (add GR:$src1, immSExt14:$imm))]>, isA;
127 def MOVL : AForm_DAG<0x03, 0x0b, (outs GR:$dst), (ins s64imm:$imm),
129 [(set GR:$dst, imm64:$imm)]>, isLX;
131 def ADDL_GA : AForm_DAG<0x03, 0x0b, (outs GR:$dst), (ins GR:$src1, globaladdress:$imm),
132 "addl $dst = $imm, $src1",
136 def ADDL_EA : AForm_DAG<0x03, 0x0b, (outs GR:$dst), (ins GR:$src1, calltarget:$imm),
137 "addl $dst = $imm, $src1",
140 def SUB : AForm_DAG<0x03, 0x0b, (outs GR:$dst), (ins GR:$src1, GR:$src2),
141 "sub $dst = $src1, $src2",
142 [(set GR:$dst, (sub GR:$src1, GR:$src2))]>, isA;
144 def SUB1 : AForm_DAG<0x03, 0x0b, (outs GR:$dst), (ins GR:$src1, GR:$src2),
145 "sub $dst = $src1, $src2, 1",
146 [(set GR:$dst, (add (sub GR: $src1, GR:$src2), -1))]>, isA;
148 let isTwoAddress = 1 in {
149 def TPCADDIMM22 : AForm<0x03, 0x0b,
150 (outs GR:$dst), (ins GR:$src1, s22imm:$imm, PR:$qp),
151 "($qp) add $dst = $imm, $dst">, isA;
152 def TPCADDS : AForm_DAG<0x03, 0x0b,
153 (outs GR:$dst), (ins GR:$src1, s14imm:$imm, PR:$qp),
154 "($qp) adds $dst = $imm, $dst",
156 def TPCMPIMM8NE : AForm<0x03, 0x0b,
157 (outs PR:$dst), (ins PR:$src1, s22imm:$imm, GR:$src2, PR:$qp),
158 "($qp) cmp.ne $dst , p0 = $imm, $src2">, isA;
161 // zero extend a bool (predicate reg) into an integer reg
162 def ZXTb : Pat<(zext PR:$src),
163 (TPCADDIMM22 (ADDS r0, 0), 1, PR:$src)>;
164 def AXTb : Pat<(anyext PR:$src),
165 (TPCADDIMM22 (ADDS r0, 0), 1, PR:$src)>;
167 // normal sign/zero-extends
168 def SXT1 : AForm_DAG<0x03, 0x0b, (outs GR:$dst), (ins GR:$src), "sxt1 $dst = $src",
169 [(set GR:$dst, (sext_inreg GR:$src, i8))]>, isI;
170 def ZXT1 : AForm_DAG<0x03, 0x0b, (outs GR:$dst), (ins GR:$src), "zxt1 $dst = $src",
171 [(set GR:$dst, (and GR:$src, 255))]>, isI;
172 def SXT2 : AForm_DAG<0x03, 0x0b, (outs GR:$dst), (ins GR:$src), "sxt2 $dst = $src",
173 [(set GR:$dst, (sext_inreg GR:$src, i16))]>, isI;
174 def ZXT2 : AForm_DAG<0x03, 0x0b, (outs GR:$dst), (ins GR:$src), "zxt2 $dst = $src",
175 [(set GR:$dst, (and GR:$src, 65535))]>, isI;
176 def SXT4 : AForm_DAG<0x03, 0x0b, (outs GR:$dst), (ins GR:$src), "sxt4 $dst = $src",
177 [(set GR:$dst, (sext_inreg GR:$src, i32))]>, isI;
178 def ZXT4 : AForm_DAG<0x03, 0x0b, (outs GR:$dst), (ins GR:$src), "zxt4 $dst = $src",
179 [(set GR:$dst, (and GR:$src, is32ones))]>, isI;
181 // fixme: shrs vs shru?
182 def MIX1L : AForm_DAG<0x03, 0x0b, (outs GR:$dst), (ins GR:$src1, GR:$src2),
183 "mix1.l $dst = $src1, $src2",
184 [(set GR:$dst, (or (and GR:$src1, isMIX1Lable),
185 (and (srl GR:$src2, (i64 8)), isMIX1Lable)))]>, isI;
187 def MIX2L : AForm_DAG<0x03, 0x0b, (outs GR:$dst), (ins GR:$src1, GR:$src2),
188 "mix2.l $dst = $src1, $src2",
189 [(set GR:$dst, (or (and GR:$src1, isMIX2Lable),
190 (and (srl GR:$src2, (i64 16)), isMIX2Lable)))]>, isI;
192 def MIX4L : AForm_DAG<0x03, 0x0b, (outs GR:$dst), (ins GR:$src1, GR:$src2),
193 "mix4.l $dst = $src1, $src2",
194 [(set GR:$dst, (or (and GR:$src1, isMIX4Lable),
195 (and (srl GR:$src2, (i64 32)), isMIX4Lable)))]>, isI;
197 def MIX1R : AForm_DAG<0x03, 0x0b, (outs GR:$dst), (ins GR:$src1, GR:$src2),
198 "mix1.r $dst = $src1, $src2",
199 [(set GR:$dst, (or (and (shl GR:$src1, (i64 8)), isMIX1Rable),
200 (and GR:$src2, isMIX1Rable)))]>, isI;
202 def MIX2R : AForm_DAG<0x03, 0x0b, (outs GR:$dst), (ins GR:$src1, GR:$src2),
203 "mix2.r $dst = $src1, $src2",
204 [(set GR:$dst, (or (and (shl GR:$src1, (i64 16)), isMIX2Rable),
205 (and GR:$src2, isMIX2Rable)))]>, isI;
207 def MIX4R : AForm_DAG<0x03, 0x0b, (outs GR:$dst), (ins GR:$src1, GR:$src2),
208 "mix4.r $dst = $src1, $src2",
209 [(set GR:$dst, (or (and (shl GR:$src1, (i64 32)), isMIX4Rable),
210 (and GR:$src2, isMIX4Rable)))]>, isI;
212 def GETFSIGD : AForm_DAG<0x03, 0x0b, (outs GR:$dst), (ins FP:$src),
213 "getf.sig $dst = $src",
216 def SETFSIGD : AForm_DAG<0x03, 0x0b, (outs FP:$dst), (ins GR:$src),
217 "setf.sig $dst = $src",
220 def XMALD : AForm_DAG<0x03, 0x0b, (outs FP:$dst), (ins FP:$src1, FP:$src2, FP:$src3),
221 "xma.l $dst = $src1, $src2, $src3",
223 def XMAHD : AForm_DAG<0x03, 0x0b, (outs FP:$dst), (ins FP:$src1, FP:$src2, FP:$src3),
224 "xma.h $dst = $src1, $src2, $src3",
226 def XMAHUD : AForm_DAG<0x03, 0x0b, (outs FP:$dst), (ins FP:$src1, FP:$src2, FP:$src3),
227 "xma.hu $dst = $src1, $src2, $src3",
230 // pseudocode for integer multiplication
231 def : Pat<(mul GR:$src1, GR:$src2),
232 (GETFSIGD (XMALD (SETFSIGD GR:$src1), (SETFSIGD GR:$src2), F0))>;
233 def : Pat<(mulhs GR:$src1, GR:$src2),
234 (GETFSIGD (XMAHD (SETFSIGD GR:$src1), (SETFSIGD GR:$src2), F0))>;
235 def : Pat<(mulhu GR:$src1, GR:$src2),
236 (GETFSIGD (XMAHUD (SETFSIGD GR:$src1), (SETFSIGD GR:$src2), F0))>;
238 // TODO: addp4 (addp4 dst = src, r0 is a 32-bit add)
241 // def ADDS : AForm<0x03, 0x0b, (outs GR:$dst), (ins GR:$src1, s14imm:$imm),
242 // "adds $dst = $imm, $src1">;
244 def AND : AForm_DAG<0x03, 0x0b, (outs GR:$dst), (ins GR:$src1, GR:$src2),
245 "and $dst = $src1, $src2",
246 [(set GR:$dst, (and GR:$src1, GR:$src2))]>, isA;
247 def ANDCM : AForm_DAG<0x03, 0x0b, (outs GR:$dst), (ins GR:$src1, GR:$src2),
248 "andcm $dst = $src1, $src2",
249 [(set GR:$dst, (and GR:$src1, (not GR:$src2)))]>, isA;
250 // TODO: and/andcm/or/xor/add/sub/shift immediate forms
251 def OR : AForm_DAG<0x03, 0x0b, (outs GR:$dst), (ins GR:$src1, GR:$src2),
252 "or $dst = $src1, $src2",
253 [(set GR:$dst, (or GR:$src1, GR:$src2))]>, isA;
255 def pOR : AForm<0x03, 0x0b, (outs GR:$dst), (ins GR:$src1, GR:$src2, PR:$qp),
256 "($qp) or $dst = $src1, $src2">, isA;
258 // the following are all a bit unfortunate: we throw away the complement
260 def CMPEQ : AForm_DAG<0x03, 0x0b, (outs PR:$dst), (ins GR:$src1, GR:$src2),
261 "cmp.eq $dst, p0 = $src1, $src2",
262 [(set PR:$dst, (seteq GR:$src1, GR:$src2))]>, isA;
263 def CMPGT : AForm_DAG<0x03, 0x0b, (outs PR:$dst), (ins GR:$src1, GR:$src2),
264 "cmp.gt $dst, p0 = $src1, $src2",
265 [(set PR:$dst, (setgt GR:$src1, GR:$src2))]>, isA;
266 def CMPGE : AForm_DAG<0x03, 0x0b, (outs PR:$dst), (ins GR:$src1, GR:$src2),
267 "cmp.ge $dst, p0 = $src1, $src2",
268 [(set PR:$dst, (setge GR:$src1, GR:$src2))]>, isA;
269 def CMPLT : AForm_DAG<0x03, 0x0b, (outs PR:$dst), (ins GR:$src1, GR:$src2),
270 "cmp.lt $dst, p0 = $src1, $src2",
271 [(set PR:$dst, (setlt GR:$src1, GR:$src2))]>, isA;
272 def CMPLE : AForm_DAG<0x03, 0x0b, (outs PR:$dst), (ins GR:$src1, GR:$src2),
273 "cmp.le $dst, p0 = $src1, $src2",
274 [(set PR:$dst, (setle GR:$src1, GR:$src2))]>, isA;
275 def CMPNE : AForm_DAG<0x03, 0x0b, (outs PR:$dst), (ins GR:$src1, GR:$src2),
276 "cmp.ne $dst, p0 = $src1, $src2",
277 [(set PR:$dst, (setne GR:$src1, GR:$src2))]>, isA;
278 def CMPLTU: AForm_DAG<0x03, 0x0b, (outs PR:$dst), (ins GR:$src1, GR:$src2),
279 "cmp.ltu $dst, p0 = $src1, $src2",
280 [(set PR:$dst, (setult GR:$src1, GR:$src2))]>, isA;
281 def CMPGTU: AForm_DAG<0x03, 0x0b, (outs PR:$dst), (ins GR:$src1, GR:$src2),
282 "cmp.gtu $dst, p0 = $src1, $src2",
283 [(set PR:$dst, (setugt GR:$src1, GR:$src2))]>, isA;
284 def CMPLEU: AForm_DAG<0x03, 0x0b, (outs PR:$dst), (ins GR:$src1, GR:$src2),
285 "cmp.leu $dst, p0 = $src1, $src2",
286 [(set PR:$dst, (setule GR:$src1, GR:$src2))]>, isA;
287 def CMPGEU: AForm_DAG<0x03, 0x0b, (outs PR:$dst), (ins GR:$src1, GR:$src2),
288 "cmp.geu $dst, p0 = $src1, $src2",
289 [(set PR:$dst, (setuge GR:$src1, GR:$src2))]>, isA;
291 // and we do the whole thing again for FP compares!
292 def FCMPEQ : AForm_DAG<0x03, 0x0b, (outs PR:$dst), (ins FP:$src1, FP:$src2),
293 "fcmp.eq $dst, p0 = $src1, $src2",
294 [(set PR:$dst, (seteq FP:$src1, FP:$src2))]>, isF;
295 def FCMPGT : AForm_DAG<0x03, 0x0b, (outs PR:$dst), (ins FP:$src1, FP:$src2),
296 "fcmp.gt $dst, p0 = $src1, $src2",
297 [(set PR:$dst, (setgt FP:$src1, FP:$src2))]>, isF;
298 def FCMPGE : AForm_DAG<0x03, 0x0b, (outs PR:$dst), (ins FP:$src1, FP:$src2),
299 "fcmp.ge $dst, p0 = $src1, $src2",
300 [(set PR:$dst, (setge FP:$src1, FP:$src2))]>, isF;
301 def FCMPLT : AForm_DAG<0x03, 0x0b, (outs PR:$dst), (ins FP:$src1, FP:$src2),
302 "fcmp.lt $dst, p0 = $src1, $src2",
303 [(set PR:$dst, (setlt FP:$src1, FP:$src2))]>, isF;
304 def FCMPLE : AForm_DAG<0x03, 0x0b, (outs PR:$dst), (ins FP:$src1, FP:$src2),
305 "fcmp.le $dst, p0 = $src1, $src2",
306 [(set PR:$dst, (setle FP:$src1, FP:$src2))]>, isF;
307 def FCMPNE : AForm_DAG<0x03, 0x0b, (outs PR:$dst), (ins FP:$src1, FP:$src2),
308 "fcmp.neq $dst, p0 = $src1, $src2",
309 [(set PR:$dst, (setne FP:$src1, FP:$src2))]>, isF;
310 def FCMPLTU: AForm_DAG<0x03, 0x0b, (outs PR:$dst), (ins FP:$src1, FP:$src2),
311 "fcmp.lt $dst, p0 = $src1, $src2",
312 [(set PR:$dst, (setult FP:$src1, FP:$src2))]>, isF;
313 def FCMPGTU: AForm_DAG<0x03, 0x0b, (outs PR:$dst), (ins FP:$src1, FP:$src2),
314 "fcmp.gt $dst, p0 = $src1, $src2",
315 [(set PR:$dst, (setugt FP:$src1, FP:$src2))]>, isF;
316 def FCMPLEU: AForm_DAG<0x03, 0x0b, (outs PR:$dst), (ins FP:$src1, FP:$src2),
317 "fcmp.le $dst, p0 = $src1, $src2",
318 [(set PR:$dst, (setule FP:$src1, FP:$src2))]>, isF;
319 def FCMPGEU: AForm_DAG<0x03, 0x0b, (outs PR:$dst), (ins FP:$src1, FP:$src2),
320 "fcmp.ge $dst, p0 = $src1, $src2",
321 [(set PR:$dst, (setuge FP:$src1, FP:$src2))]>, isF;
323 def PCMPEQUNCR0R0 : AForm<0x03, 0x0b, (outs PR:$dst), (ins PR:$qp),
324 "($qp) cmp.eq.unc $dst, p0 = r0, r0">, isA;
326 def : Pat<(trunc GR:$src), // truncate i64 to i1
327 (CMPNE GR:$src, r0)>; // $src!=0? If so, PR:$dst=true
329 let isTwoAddress=1 in {
330 def TPCMPEQR0R0 : AForm<0x03, 0x0b, (outs PR:$dst), (ins PR:$bogus, PR:$qp),
331 "($qp) cmp.eq $dst, p0 = r0, r0">, isA;
332 def TPCMPNER0R0 : AForm<0x03, 0x0b, (outs PR:$dst), (ins PR:$bogus, PR:$qp),
333 "($qp) cmp.ne $dst, p0 = r0, r0">, isA;
336 /* our pseudocode for OR on predicates is:
339 (pA) cmp.eq.unc pC,p0 = r0,r0 // pC = pA
341 (pB) cmp.eq pC,p0 = r0,r0 // if (pB) pC = 1 */
343 def bOR : Pat<(or PR:$src1, PR:$src2),
344 (TPCMPEQR0R0 (PCMPEQUNCR0R0 PR:$src1), PR:$src2)>;
346 /* our pseudocode for AND on predicates is:
348 (pA) cmp.eq.unc pC,p0 = r0,r0 // pC = pA
349 cmp.eq pTemp,p0 = r0,r0 // pTemp = NOT pB
351 (pB) cmp.ne pTemp,p0 = r0,r0
353 (pTemp)cmp.ne pC,p0 = r0,r0 // if (NOT pB) pC = 0 */
355 def bAND : Pat<(and PR:$src1, PR:$src2),
356 ( TPCMPNER0R0 (PCMPEQUNCR0R0 PR:$src1),
357 (TPCMPNER0R0 (CMPEQ r0, r0), PR:$src2) )>;
359 /* one possible routine for XOR on predicates is:
361 // Compute px = py ^ pz
362 // using sum of products: px = (py & !pz) | (pz & !py)
363 // Uses 5 instructions in 3 cycles.
365 (pz) cmp.eq.unc px = r0, r0 // px = pz
366 (py) cmp.eq.unc pt = r0, r0 // pt = py
369 (pt) cmp.ne.and px = r0, r0 // px = px & !pt (px = pz & !pt)
370 (pz) cmp.ne.and pt = r0, r0 // pt = pt & !pz
374 (pt) cmp.eq.or px = r0, r0 // px = px | pt
376 *** Another, which we use here, requires one scratch GR. it is:
378 mov rt = 0 // initialize rt off critical path
382 (pz) cmp.eq.unc px = r0, r0 // px = pz
383 (pz) mov rt = 1 // rt = pz
386 (py) cmp.ne px = 1, rt // if (py) px = !pz
388 .. these routines kindly provided by Jim Hull
391 def bXOR : Pat<(xor PR:$src1, PR:$src2),
392 (TPCMPIMM8NE (PCMPEQUNCR0R0 PR:$src2), 1,
393 (TPCADDS (ADDS r0, 0), 1, PR:$src2),
396 def XOR : AForm_DAG<0x03, 0x0b, (outs GR:$dst), (ins GR:$src1, GR:$src2),
397 "xor $dst = $src1, $src2",
398 [(set GR:$dst, (xor GR:$src1, GR:$src2))]>, isA;
400 def SHLADD: AForm_DAG<0x03, 0x0b, (outs GR:$dst), (ins GR:$src1,s64imm:$imm,GR:$src2),
401 "shladd $dst = $src1, $imm, $src2",
402 [(set GR:$dst, (add GR:$src2, (shl GR:$src1, isSHLADDimm:$imm)))]>, isA;
404 def SHL : AForm_DAG<0x03, 0x0b, (outs GR:$dst), (ins GR:$src1, GR:$src2),
405 "shl $dst = $src1, $src2",
406 [(set GR:$dst, (shl GR:$src1, GR:$src2))]>, isI;
408 def SHRU : AForm_DAG<0x03, 0x0b, (outs GR:$dst), (ins GR:$src1, GR:$src2),
409 "shr.u $dst = $src1, $src2",
410 [(set GR:$dst, (srl GR:$src1, GR:$src2))]>, isI;
412 def SHRS : AForm_DAG<0x03, 0x0b, (outs GR:$dst), (ins GR:$src1, GR:$src2),
413 "shr $dst = $src1, $src2",
414 [(set GR:$dst, (sra GR:$src1, GR:$src2))]>, isI;
416 def MOV : AForm<0x03, 0x0b, (outs GR:$dst), (ins GR:$src), "mov $dst = $src">, isA;
417 def FMOV : AForm<0x03, 0x0b, (outs FP:$dst), (ins FP:$src),
418 "mov $dst = $src">, isF; // XXX: there _is_ no fmov
419 def PMOV : AForm<0x03, 0x0b, (outs GR:$dst), (ins GR:$src, PR:$qp),
420 "($qp) mov $dst = $src">, isA;
422 def SPILL_ALL_PREDICATES_TO_GR : AForm<0x03, 0x0b, (outs GR:$dst), (ins),
423 "mov $dst = pr">, isI;
424 def FILL_ALL_PREDICATES_FROM_GR : AForm<0x03, 0x0b, (outs), (ins GR:$src),
425 "mov pr = $src">, isI;
427 let isTwoAddress = 1 in {
428 def CMOV : AForm<0x03, 0x0b, (outs GR:$dst), (ins GR:$src2, GR:$src, PR:$qp),
429 "($qp) mov $dst = $src">, isA;
432 def PFMOV : AForm<0x03, 0x0b, (outs FP:$dst), (ins FP:$src, PR:$qp),
433 "($qp) mov $dst = $src">, isF;
435 let isTwoAddress = 1 in {
436 def CFMOV : AForm<0x03, 0x0b, (outs FP:$dst), (ins FP:$src2, FP:$src, PR:$qp),
437 "($qp) mov $dst = $src">, isF;
440 def SELECTINT : Pat<(select PR:$which, GR:$src1, GR:$src2),
441 (CMOV (MOV GR:$src2), GR:$src1, PR:$which)>; // note order!
442 def SELECTFP : Pat<(select PR:$which, FP:$src1, FP:$src2),
443 (CFMOV (FMOV FP:$src2), FP:$src1, PR:$which)>; // note order!
444 // TODO: can do this faster, w/o using any integer regs (see pattern isel)
445 def SELECTBOOL : Pat<(select PR:$which, PR:$src1, PR:$src2), // note order!
447 (MOV (TPCADDIMM22 (ADDS r0, 0), 1, PR:$src2)),
448 (TPCADDIMM22 (ADDS r0, 0), 1, PR:$src1), PR:$which), r0)>;
450 // load constants of various sizes // FIXME: prettyprint -ve constants
451 def : Pat<(i64 immSExt14:$imm), (ADDS r0, immSExt14:$imm)>;
452 def : Pat<(i1 -1), (CMPEQ r0, r0)>; // TODO: this should just be a ref to p0
453 def : Pat<(i1 0), (CMPNE r0, r0)>; // TODO: any instruction actually *using*
454 // this predicate should be killed!
456 // TODO: support postincrement (reg, imm9) loads+stores - this needs more
459 def IUSE : PseudoInstIA64<(outs), (ins variable_ops), "// IUSE">;
460 def ADJUSTCALLSTACKUP : PseudoInstIA64<(outs), (ins variable_ops),
461 "// ADJUSTCALLSTACKUP">;
462 def ADJUSTCALLSTACKDOWN : PseudoInstIA64<(outs), (ins variable_ops),
463 "// ADJUSTCALLSTACKDOWN">;
464 def PSEUDO_ALLOC : PseudoInstIA64<(outs), (ins GR:$foo), "// PSEUDO_ALLOC">;
466 def ALLOC : AForm<0x03, 0x0b,
467 (outs GR:$dst), (ins i8imm:$inputs, i8imm:$locals, i8imm:$outputs, i8imm:$rotating),
468 "alloc $dst = ar.pfs,$inputs,$locals,$outputs,$rotating">, isM;
470 let isTwoAddress = 1 in {
471 def TCMPNE : AForm<0x03, 0x0b,
472 (outs PR:$dst), (ins PR:$src2, GR:$src3, GR:$src4),
473 "cmp.ne $dst, p0 = $src3, $src4">, isA;
475 def TPCMPEQOR : AForm<0x03, 0x0b,
476 (outs PR:$dst), (ins PR:$src2, GR:$src3, GR:$src4, PR:$qp),
477 "($qp) cmp.eq.or $dst, p0 = $src3, $src4">, isA;
479 def TPCMPNE : AForm<0x03, 0x0b,
480 (outs PR:$dst), (ins PR:$src2, GR:$src3, GR:$src4, PR:$qp),
481 "($qp) cmp.ne $dst, p0 = $src3, $src4">, isA;
483 def TPCMPEQ : AForm<0x03, 0x0b,
484 (outs PR:$dst), (ins PR:$src2, GR:$src3, GR:$src4, PR:$qp),
485 "($qp) cmp.eq $dst, p0 = $src3, $src4">, isA;
488 def MOVSIMM14 : AForm<0x03, 0x0b, (outs GR:$dst), (ins s14imm:$imm),
489 "mov $dst = $imm">, isA;
490 def MOVSIMM22 : AForm<0x03, 0x0b, (outs GR:$dst), (ins s22imm:$imm),
491 "mov $dst = $imm">, isA;
492 def MOVLIMM64 : AForm<0x03, 0x0b, (outs GR:$dst), (ins s64imm:$imm),
493 "movl $dst = $imm">, isLX;
495 def SHLI : AForm<0x03, 0x0b, (outs GR:$dst), (ins GR:$src1, u6imm:$imm),
496 "shl $dst = $src1, $imm">, isI;
497 def SHRUI : AForm<0x03, 0x0b, (outs GR:$dst), (ins GR:$src1, u6imm:$imm),
498 "shr.u $dst = $src1, $imm">, isI;
499 def SHRSI : AForm<0x03, 0x0b, (outs GR:$dst), (ins GR:$src1, u6imm:$imm),
500 "shr $dst = $src1, $imm">, isI;
502 def EXTRU : AForm<0x03, 0x0b,
503 (outs GR:$dst), (ins GR:$src1, u6imm:$imm1, u6imm:$imm2),
504 "extr.u $dst = $src1, $imm1, $imm2">, isI;
506 def DEPZ : AForm<0x03, 0x0b,
507 (outs GR:$dst), (ins GR:$src1, u6imm:$imm1, u6imm:$imm2),
508 "dep.z $dst = $src1, $imm1, $imm2">, isI;
510 def PCMPEQOR : AForm<0x03, 0x0b, (outs PR:$dst), (ins GR:$src1, GR:$src2, PR:$qp),
511 "($qp) cmp.eq.or $dst, p0 = $src1, $src2">, isA;
512 def PCMPEQUNC : AForm<0x03, 0x0b, (outs PR:$dst), (ins GR:$src1, GR:$src2, PR:$qp),
513 "($qp) cmp.eq.unc $dst, p0 = $src1, $src2">, isA;
514 def PCMPNE : AForm<0x03, 0x0b, (outs PR:$dst), (ins GR:$src1, GR:$src2, PR:$qp),
515 "($qp) cmp.ne $dst, p0 = $src1, $src2">, isA;
518 def BCMPEQ : AForm<0x03, 0x0b, (outs PR:$dst1, PR:$dst2), (ins GR:$src1, GR:$src2),
519 "cmp.eq $dst1, dst2 = $src1, $src2">, isA;
521 def ADDIMM14 : AForm<0x03, 0x0b, (outs GR:$dst), (ins GR:$src1, s14imm:$imm),
522 "adds $dst = $imm, $src1">, isA;
524 def ADDIMM22 : AForm<0x03, 0x0b, (outs GR:$dst), (ins GR:$src1, s22imm:$imm),
525 "add $dst = $imm, $src1">, isA;
526 def CADDIMM22 : AForm<0x03, 0x0b, (outs GR:$dst), (ins GR:$src1, s22imm:$imm, PR:$qp),
527 "($qp) add $dst = $imm, $src1">, isA;
529 def SUBIMM8 : AForm<0x03, 0x0b, (outs GR:$dst), (ins s8imm:$imm, GR:$src2),
530 "sub $dst = $imm, $src2">, isA;
532 let mayStore = 1 in {
533 def ST1 : AForm<0x03, 0x0b, (outs), (ins GR:$dstPtr, GR:$value),
534 "st1 [$dstPtr] = $value">, isM;
535 def ST2 : AForm<0x03, 0x0b, (outs), (ins GR:$dstPtr, GR:$value),
536 "st2 [$dstPtr] = $value">, isM;
537 def ST4 : AForm<0x03, 0x0b, (outs), (ins GR:$dstPtr, GR:$value),
538 "st4 [$dstPtr] = $value">, isM;
539 def ST8 : AForm<0x03, 0x0b, (outs), (ins GR:$dstPtr, GR:$value),
540 "st8 [$dstPtr] = $value">, isM;
541 def STF4 : AForm<0x03, 0x0b, (outs), (ins GR:$dstPtr, FP:$value),
542 "stfs [$dstPtr] = $value">, isM;
543 def STF8 : AForm<0x03, 0x0b, (outs), (ins GR:$dstPtr, FP:$value),
544 "stfd [$dstPtr] = $value">, isM;
545 def STF_SPILL : AForm<0x03, 0x0b, (outs), (ins GR:$dstPtr, FP:$value),
546 "stf.spill [$dstPtr] = $value">, isM;
549 let canFoldAsLoad = 1 in {
550 def LD1 : AForm<0x03, 0x0b, (outs GR:$dst), (ins GR:$srcPtr),
551 "ld1 $dst = [$srcPtr]">, isM;
552 def LD2 : AForm<0x03, 0x0b, (outs GR:$dst), (ins GR:$srcPtr),
553 "ld2 $dst = [$srcPtr]">, isM;
554 def LD4 : AForm<0x03, 0x0b, (outs GR:$dst), (ins GR:$srcPtr),
555 "ld4 $dst = [$srcPtr]">, isM;
556 def LD8 : AForm<0x03, 0x0b, (outs GR:$dst), (ins GR:$srcPtr),
557 "ld8 $dst = [$srcPtr]">, isM;
558 def LDF4 : AForm<0x03, 0x0b, (outs FP:$dst), (ins GR:$srcPtr),
559 "ldfs $dst = [$srcPtr]">, isM;
560 def LDF8 : AForm<0x03, 0x0b, (outs FP:$dst), (ins GR:$srcPtr),
561 "ldfd $dst = [$srcPtr]">, isM;
562 def LDF_FILL : AForm<0x03, 0x0b, (outs FP:$dst), (ins GR:$srcPtr),
563 "ldf.fill $dst = [$srcPtr]">, isM;
566 def POPCNT : AForm_DAG<0x03, 0x0b, (outs GR:$dst), (ins GR:$src),
567 "popcnt $dst = $src",
568 [(set GR:$dst, (ctpop GR:$src))]>, isI;
570 // some FP stuff: // TODO: single-precision stuff?
571 def FADD : AForm_DAG<0x03, 0x0b, (outs FP:$dst), (ins FP:$src1, FP:$src2),
572 "fadd $dst = $src1, $src2",
573 [(set FP:$dst, (fadd FP:$src1, FP:$src2))]>, isF;
574 def FADDS: AForm<0x03, 0x0b, (outs FP:$dst), (ins FP:$src1, FP:$src2),
575 "fadd.s $dst = $src1, $src2">, isF;
576 def FSUB : AForm_DAG<0x03, 0x0b, (outs FP:$dst), (ins FP:$src1, FP:$src2),
577 "fsub $dst = $src1, $src2",
578 [(set FP:$dst, (fsub FP:$src1, FP:$src2))]>, isF;
579 def FMPY : AForm_DAG<0x03, 0x0b, (outs FP:$dst), (ins FP:$src1, FP:$src2),
580 "fmpy $dst = $src1, $src2",
581 [(set FP:$dst, (fmul FP:$src1, FP:$src2))]>, isF;
582 def FMA : AForm_DAG<0x03, 0x0b, (outs FP:$dst), (ins FP:$src1, FP:$src2, FP:$src3),
583 "fma $dst = $src1, $src2, $src3",
584 [(set FP:$dst, (fadd (fmul FP:$src1, FP:$src2), FP:$src3))]>, isF;
585 def FMS : AForm_DAG<0x03, 0x0b, (outs FP:$dst), (ins FP:$src1, FP:$src2, FP:$src3),
586 "fms $dst = $src1, $src2, $src3",
587 [(set FP:$dst, (fsub (fmul FP:$src1, FP:$src2), FP:$src3))]>, isF;
588 def FNMA : AForm_DAG<0x03, 0x0b, (outs FP:$dst), (ins FP:$src1, FP:$src2, FP:$src3),
589 "fnma $dst = $src1, $src2, $src3",
590 [(set FP:$dst, (fneg (fadd (fmul FP:$src1, FP:$src2), FP:$src3)))]>, isF;
591 def FABS : AForm_DAG<0x03, 0x0b, (outs FP:$dst), (ins FP:$src),
593 [(set FP:$dst, (fabs FP:$src))]>, isF;
594 def FNEG : AForm_DAG<0x03, 0x0b, (outs FP:$dst), (ins FP:$src),
596 [(set FP:$dst, (fneg FP:$src))]>, isF;
597 def FNEGABS : AForm_DAG<0x03, 0x0b, (outs FP:$dst), (ins FP:$src),
598 "fnegabs $dst = $src",
599 [(set FP:$dst, (fneg (fabs FP:$src)))]>, isF;
601 let isTwoAddress=1 in {
602 def TCFMAS1 : AForm<0x03, 0x0b,
603 (outs FP:$dst), (ins FP:$bogussrc, FP:$src1, FP:$src2, FP:$src3, PR:$qp),
604 "($qp) fma.s1 $dst = $src1, $src2, $src3">, isF;
605 def TCFMADS0 : AForm<0x03, 0x0b,
606 (outs FP:$dst), (ins FP:$bogussrc, FP:$src1, FP:$src2, FP:$src3, PR:$qp),
607 "($qp) fma.d.s0 $dst = $src1, $src2, $src3">, isF;
610 def CFMAS1 : AForm<0x03, 0x0b,
611 (outs FP:$dst), (ins FP:$src1, FP:$src2, FP:$src3, PR:$qp),
612 "($qp) fma.s1 $dst = $src1, $src2, $src3">, isF;
613 def CFNMAS1 : AForm<0x03, 0x0b,
614 (outs FP:$dst), (ins FP:$src1, FP:$src2, FP:$src3, PR:$qp),
615 "($qp) fnma.s1 $dst = $src1, $src2, $src3">, isF;
617 def CFMADS1 : AForm<0x03, 0x0b,
618 (outs FP:$dst), (ins FP:$src1, FP:$src2, FP:$src3, PR:$qp),
619 "($qp) fma.d.s1 $dst = $src1, $src2, $src3">, isF;
620 def CFMADS0 : AForm<0x03, 0x0b,
621 (outs FP:$dst), (ins FP:$src1, FP:$src2, FP:$src3, PR:$qp),
622 "($qp) fma.d.s0 $dst = $src1, $src2, $src3">, isF;
623 def CFNMADS1 : AForm<0x03, 0x0b,
624 (outs FP:$dst), (ins FP:$src1, FP:$src2, FP:$src3, PR:$qp),
625 "($qp) fnma.d.s1 $dst = $src1, $src2, $src3">, isF;
627 def FRCPAS0 : AForm<0x03, 0x0b, (outs FP:$dstFR, PR:$dstPR), (ins FP:$src1, FP:$src2),
628 "frcpa.s0 $dstFR, $dstPR = $src1, $src2">, isF;
629 def FRCPAS1 : AForm<0x03, 0x0b, (outs FP:$dstFR, PR:$dstPR), (ins FP:$src1, FP:$src2),
630 "frcpa.s1 $dstFR, $dstPR = $src1, $src2">, isF;
632 def XMAL : AForm<0x03, 0x0b, (outs FP:$dst), (ins FP:$src1, FP:$src2, FP:$src3),
633 "xma.l $dst = $src1, $src2, $src3">, isF;
635 def FCVTXF : AForm<0x03, 0x0b, (outs FP:$dst), (ins FP:$src),
636 "fcvt.xf $dst = $src">, isF;
637 def FCVTXUF : AForm<0x03, 0x0b, (outs FP:$dst), (ins FP:$src),
638 "fcvt.xuf $dst = $src">, isF;
639 def FCVTXUFS1 : AForm<0x03, 0x0b, (outs FP:$dst), (ins FP:$src),
640 "fcvt.xuf.s1 $dst = $src">, isF;
641 def FCVTFX : AForm<0x03, 0x0b, (outs FP:$dst), (ins FP:$src),
642 "fcvt.fx $dst = $src">, isF;
643 def FCVTFXU : AForm<0x03, 0x0b, (outs FP:$dst), (ins FP:$src),
644 "fcvt.fxu $dst = $src">, isF;
646 def FCVTFXTRUNC : AForm<0x03, 0x0b, (outs FP:$dst), (ins FP:$src),
647 "fcvt.fx.trunc $dst = $src">, isF;
648 def FCVTFXUTRUNC : AForm<0x03, 0x0b, (outs FP:$dst), (ins FP:$src),
649 "fcvt.fxu.trunc $dst = $src">, isF;
651 def FCVTFXTRUNCS1 : AForm<0x03, 0x0b, (outs FP:$dst), (ins FP:$src),
652 "fcvt.fx.trunc.s1 $dst = $src">, isF;
653 def FCVTFXUTRUNCS1 : AForm<0x03, 0x0b, (outs FP:$dst), (ins FP:$src),
654 "fcvt.fxu.trunc.s1 $dst = $src">, isF;
656 def FNORMD : AForm<0x03, 0x0b, (outs FP:$dst), (ins FP:$src),
657 "fnorm.d $dst = $src">, isF;
659 def GETFD : AForm<0x03, 0x0b, (outs GR:$dst), (ins FP:$src),
660 "getf.d $dst = $src">, isM;
661 def SETFD : AForm<0x03, 0x0b, (outs FP:$dst), (ins GR:$src),
662 "setf.d $dst = $src">, isM;
664 def GETFSIG : AForm<0x03, 0x0b, (outs GR:$dst), (ins FP:$src),
665 "getf.sig $dst = $src">, isM;
666 def SETFSIG : AForm<0x03, 0x0b, (outs FP:$dst), (ins GR:$src),
667 "setf.sig $dst = $src">, isM;
669 // these four FP<->int conversion patterns need checking/cleaning
670 def SINT_TO_FP : Pat<(sint_to_fp GR:$src),
671 (FNORMD (FCVTXF (SETFSIG GR:$src)))>;
672 def UINT_TO_FP : Pat<(uint_to_fp GR:$src),
673 (FNORMD (FCVTXUF (SETFSIG GR:$src)))>;
674 def FP_TO_SINT : Pat<(i64 (fp_to_sint FP:$src)),
675 (GETFSIG (FCVTFXTRUNC FP:$src))>;
676 def FP_TO_UINT : Pat<(i64 (fp_to_uint FP:$src)),
677 (GETFSIG (FCVTFXUTRUNC FP:$src))>;
679 def fpimm0 : PatLeaf<(fpimm), [{
680 return N->isExactlyValue(+0.0);
682 def fpimm1 : PatLeaf<(fpimm), [{
683 return N->isExactlyValue(+1.0);
685 def fpimmn0 : PatLeaf<(fpimm), [{
686 return N->isExactlyValue(-0.0);
688 def fpimmn1 : PatLeaf<(fpimm), [{
689 return N->isExactlyValue(-1.0);
692 def : Pat<(f64 fpimm0), (FMOV F0)>;
693 def : Pat<(f64 fpimm1), (FMOV F1)>;
694 def : Pat<(f64 fpimmn0), (FNEG F0)>;
695 def : Pat<(f64 fpimmn1), (FNEG F1)>;
697 let isTerminator = 1, isBranch = 1 in {
698 def BRL_NOTCALL : RawForm<0x03, 0xb0, (outs), (ins i64imm:$dst),
699 "(p0) brl.cond.sptk $dst">, isB;
700 def BRLCOND_NOTCALL : RawForm<0x03, 0xb0, (outs), (ins PR:$qp, i64imm:$dst),
701 "($qp) brl.cond.sptk $dst">, isB;
702 def BRCOND_NOTCALL : RawForm<0x03, 0xb0, (outs), (ins PR:$qp, GR:$dst),
703 "($qp) br.cond.sptk $dst">, isB;
706 let isCall = 1, /* isTerminator = 1, isBranch = 1, */
707 Uses = [out0,out1,out2,out3,out4,out5,out6,out7],
708 // all calls clobber non-callee-saved registers, and for now, they are these:
709 Defs = [r2,r3,r8,r9,r10,r11,r14,r15,r16,r17,r18,r19,r20,r21,r22,r23,r24,
710 r25,r26,r27,r28,r29,r30,r31,
711 p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,
712 F6,F7,F8,F9,F10,F11,F12,F13,F14,F15,
713 F32,F33,F34,F35,F36,F37,F38,F39,F40,F41,F42,F43,F44,F45,F46,F47,F48,F49,
714 F50,F51,F52,F53,F54,F55,F56,
715 F57,F58,F59,F60,F61,F62,F63,F64,F65,F66,F67,F68,F69,F70,F71,F72,F73,F74,
716 F75,F76,F77,F78,F79,F80,F81,
717 F82,F83,F84,F85,F86,F87,F88,F89,F90,F91,F92,F93,F94,F95,F96,F97,F98,F99,
718 F100,F101,F102,F103,F104,F105,
719 F106,F107,F108,F109,F110,F111,F112,F113,F114,F115,F116,F117,F118,F119,
720 F120,F121,F122,F123,F124,F125,F126,F127,
721 out0,out1,out2,out3,out4,out5,out6,out7] in {
723 def BRCALL: RawForm<0x03, 0xb0, (outs), (ins calltarget:$dst),
724 "br.call.sptk rp = $dst">, isB; // FIXME: teach llvm about branch regs?
727 // calls a globaladdress
728 def BRCALL_IPREL_GA : RawForm<0x03, 0xb0, (outs), (ins calltarget:$dst),
729 "br.call.sptk rp = $dst">, isB; // FIXME: teach llvm about branch regs?
730 // calls an externalsymbol
731 def BRCALL_IPREL_ES : RawForm<0x03, 0xb0, (outs), (ins calltarget:$dst),
732 "br.call.sptk rp = $dst">, isB; // FIXME: teach llvm about branch regs?
733 // calls through a function descriptor
734 def BRCALL_INDIRECT : RawForm<0x03, 0xb0, (outs), (ins GR:$branchreg),
735 "br.call.sptk rp = $branchreg">, isB; // FIXME: teach llvm about branch regs?
736 def BRLCOND_CALL : RawForm<0x03, 0xb0, (outs), (ins PR:$qp, i64imm:$dst),
737 "($qp) brl.cond.call.sptk $dst">, isB;
738 def BRCOND_CALL : RawForm<0x03, 0xb0, (outs), (ins PR:$qp, GR:$dst),
739 "($qp) br.cond.call.sptk $dst">, isB;
743 let isTerminator = 1, isReturn = 1 in
744 def RET : AForm_DAG<0x03, 0x0b, (outs), (ins),
745 "br.ret.sptk.many rp",
746 [(retflag)]>, isB; // return
747 def : Pat<(ret), (RET)>;
749 // the evil stop bit of despair
750 def STOP : PseudoInstIA64<(outs), (ins variable_ops), ";;">;