]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/ia64/ia64.md
Use sjlj unwind.
[thirdparty/gcc.git] / gcc / config / ia64 / ia64.md
CommitLineData
c65ebc55 1;; IA-64 Machine description template
bbbbb16a 2;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
c75c517d 3;; 2009, 2010 Free Software Foundation, Inc.
c65ebc55
JW
4;; Contributed by James E. Wilson <wilson@cygnus.com> and
5;; David Mosberger <davidm@hpl.hp.com>.
6
3bed2930 7;; This file is part of GCC.
c65ebc55 8
3bed2930 9;; GCC is free software; you can redistribute it and/or modify
c65ebc55 10;; it under the terms of the GNU General Public License as published by
2f83c7d6 11;; the Free Software Foundation; either version 3, or (at your option)
c65ebc55
JW
12;; any later version.
13
3bed2930 14;; GCC is distributed in the hope that it will be useful,
c65ebc55
JW
15;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17;; GNU General Public License for more details.
18
19;; You should have received a copy of the GNU General Public License
2f83c7d6
NC
20;; along with GCC; see the file COPYING3. If not see
21;; <http://www.gnu.org/licenses/>.
c65ebc55
JW
22
23;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
24
c65ebc55
JW
25;; ??? register_operand accepts (subreg:DI (mem:SI X)) which forces later
26;; reload. This will be fixed once scheduling support is turned on.
27
28;; ??? Optimize for post-increment addressing modes.
29
30;; ??? fselect is not supported, because there is no integer register
31;; equivalent.
32
33;; ??? fp abs/min/max instructions may also work for integer values.
34
35;; ??? Would a predicate_reg_operand predicate be useful? The HP one is buggy,
36;; it assumes the operand is a register and takes REGNO of it without checking.
37
38;; ??? Would a branch_reg_operand predicate be useful? The HP one is buggy,
39;; it assumes the operand is a register and takes REGNO of it without checking.
40
41;; ??? Go through list of documented named patterns and look for more to
42;; implement.
43
44;; ??? Go through instruction manual and look for more instructions that
45;; can be emitted.
46
47;; ??? Add function unit scheduling info for Itanium (TM) processor.
48
26102535
RH
49;; ??? Need a better way to describe alternate fp status registers.
50
086c0f96 51(define_constants
7b6e506e
RH
52 [; Relocations
53 (UNSPEC_LTOFF_DTPMOD 0)
54 (UNSPEC_LTOFF_DTPREL 1)
55 (UNSPEC_DTPREL 2)
56 (UNSPEC_LTOFF_TPREL 3)
57 (UNSPEC_TPREL 4)
5e6c8b64 58 (UNSPEC_DTPMOD 5)
7b6e506e
RH
59
60 (UNSPEC_LD_BASE 9)
61 (UNSPEC_GR_SPILL 10)
62 (UNSPEC_GR_RESTORE 11)
63 (UNSPEC_FR_SPILL 12)
64 (UNSPEC_FR_RESTORE 13)
65 (UNSPEC_FR_RECIP_APPROX 14)
66 (UNSPEC_PRED_REL_MUTEX 15)
c407570a 67 (UNSPEC_GETF_EXP 16)
7b6e506e
RH
68 (UNSPEC_PIC_CALL 17)
69 (UNSPEC_MF 18)
70 (UNSPEC_CMPXCHG_ACQ 19)
71 (UNSPEC_FETCHADD_ACQ 20)
72 (UNSPEC_BSP_VALUE 21)
73 (UNSPEC_FLUSHRS 22)
74 (UNSPEC_BUNDLE_SELECTOR 23)
086c0f96
RH
75 (UNSPEC_ADDP4 24)
76 (UNSPEC_PROLOGUE_USE 25)
af1e5518 77 (UNSPEC_RET_ADDR 26)
b38ba463
ZW
78 (UNSPEC_SETF_EXP 27)
79 (UNSPEC_FR_SQRT_RECIP_APPROX 28)
f526a3c8 80 (UNSPEC_SHRP 29)
046625fa 81 (UNSPEC_COPYSIGN 30)
b4e3537b 82 (UNSPEC_VECT_EXTR 31)
048d0d36
MK
83 (UNSPEC_LDA 40)
84 (UNSPEC_LDS 41)
388092d5
AB
85 (UNSPEC_LDS_A 42)
86 (UNSPEC_LDSA 43)
87 (UNSPEC_LDCCLR 44)
88 (UNSPEC_LDCNC 45)
89 (UNSPEC_CHKACLR 46)
90 (UNSPEC_CHKANC 47)
91 (UNSPEC_CHKS 48)
92 (UNSPEC_FR_RECIP_APPROX_RES 49)
93 (UNSPEC_FR_SQRT_RECIP_APPROX_RES 50)
086c0f96
RH
94 ])
95
96(define_constants
97 [(UNSPECV_ALLOC 0)
98 (UNSPECV_BLOCKAGE 1)
99 (UNSPECV_INSN_GROUP_BARRIER 2)
100 (UNSPECV_BREAK 3)
7b6e506e
RH
101 (UNSPECV_SET_BSP 4)
102 (UNSPECV_PSAC_ALL 5) ; pred.safe_across_calls
103 (UNSPECV_PSAC_NORMAL 6)
b39eb2f9 104 (UNSPECV_SETJMP_RECEIVER 7)
39a5cfa4 105 (UNSPECV_GOTO_RECEIVER 8)
086c0f96 106 ])
e543e219 107
7905f799 108(include "predicates.md")
13f70342 109(include "constraints.md")
c65ebc55
JW
110\f
111;; ::::::::::::::::::::
112;; ::
113;; :: Attributes
114;; ::
115;; ::::::::::::::::::::
116
30028c85
VM
117;; Processor type. This attribute must exactly match the processor_type
118;; enumeration in ia64.h.
bbbbb16a
ILT
119(define_attr "cpu" "itanium,itanium2"
120 (const (symbol_ref "((enum attr_cpu) ia64_tune)")))
30028c85 121
c65ebc55
JW
122;; Instruction type. This primarily determines how instructions can be
123;; packed in bundles, and secondarily affects scheduling to function units.
124
125;; A alu, can go in I or M syllable of a bundle
126;; I integer
127;; M memory
128;; F floating-point
129;; B branch
130;; L long immediate, takes two syllables
131;; S stop bit
132
133;; ??? Should not have any pattern with type unknown. Perhaps add code to
134;; check this in md_reorg? Currently use unknown for patterns which emit
135;; multiple instructions, patterns which emit 0 instructions, and patterns
136;; which emit instruction that can go in any slot (e.g. nop).
137
1d5d7a21 138(define_attr "itanium_class" "unknown,ignore,stop_bit,br,fcmp,fcvtfx,fld,
a71aef0b 139 fldp,fmac,fmisc,frar_i,frar_m,frbr,frfr,frpr,ialu,icmp,ilog,ishf,
048d0d36 140 ld,chk_s_i,chk_s_f,chk_a,long_i,mmalua,mmmul,mmshf,mmshfi,rse_m,scall,sem,stf,
f61134e8
RH
141 st,syst_m0, syst_m,tbit,toar_i,toar_m,tobr,tofr,topr,xmpy,xtd,nop,
142 nop_b,nop_f,nop_i,nop_m,nop_x,lfetch,pre_cycle"
1d5d7a21 143 (const_string "unknown"))
52e12ad0 144
048d0d36 145;; chk_s_i has an I and an M form; use type A for convenience.
2130b7fb 146(define_attr "type" "unknown,A,I,M,F,B,L,X,S"
a71aef0b 147 (cond [(eq_attr "itanium_class" "ld,st,fld,fldp,stf,sem,nop_m") (const_string "M")
52e12ad0
BS
148 (eq_attr "itanium_class" "rse_m,syst_m,syst_m0") (const_string "M")
149 (eq_attr "itanium_class" "frar_m,toar_m,frfr,tofr") (const_string "M")
44eca121 150 (eq_attr "itanium_class" "lfetch") (const_string "M")
048d0d36
MK
151 (eq_attr "itanium_class" "chk_s_f,chk_a") (const_string "M")
152 (eq_attr "itanium_class" "chk_s_i,ialu,icmp,ilog,mmalua")
f61134e8 153 (const_string "A")
2130b7fb
BS
154 (eq_attr "itanium_class" "fmisc,fmac,fcmp,xmpy") (const_string "F")
155 (eq_attr "itanium_class" "fcvtfx,nop_f") (const_string "F")
52e12ad0
BS
156 (eq_attr "itanium_class" "frar_i,toar_i,frbr,tobr") (const_string "I")
157 (eq_attr "itanium_class" "frpr,topr,ishf,xtd,tbit") (const_string "I")
2130b7fb
BS
158 (eq_attr "itanium_class" "mmmul,mmshf,mmshfi,nop_i") (const_string "I")
159 (eq_attr "itanium_class" "br,scall,nop_b") (const_string "B")
52e12ad0 160 (eq_attr "itanium_class" "stop_bit") (const_string "S")
2130b7fb 161 (eq_attr "itanium_class" "nop_x") (const_string "X")
52e12ad0
BS
162 (eq_attr "itanium_class" "long_i") (const_string "L")]
163 (const_string "unknown")))
c65ebc55 164
2130b7fb
BS
165(define_attr "itanium_requires_unit0" "no,yes"
166 (cond [(eq_attr "itanium_class" "syst_m0,sem,frfr,rse_m") (const_string "yes")
167 (eq_attr "itanium_class" "toar_m,frar_m") (const_string "yes")
168 (eq_attr "itanium_class" "frbr,tobr,mmmul") (const_string "yes")
169 (eq_attr "itanium_class" "tbit,ishf,topr,frpr") (const_string "yes")
170 (eq_attr "itanium_class" "toar_i,frar_i") (const_string "yes")
171 (eq_attr "itanium_class" "fmisc,fcmp") (const_string "yes")]
172 (const_string "no")))
173
e5bde68a
RH
174;; Predication. True iff this instruction can be predicated.
175
176(define_attr "predicable" "no,yes" (const_string "yes"))
177
fa978426
AS
178;; Empty. True iff this insn does not generate any code.
179
180(define_attr "empty" "no,yes" (const_string "no"))
181
68e11b42
JW
182;; True iff this insn must be the first insn of an instruction group.
183;; This is true for the alloc instruction, and will also be true of others
184;; when we have full intrinsics support.
185
186(define_attr "first_insn" "no,yes" (const_string "no"))
048d0d36
MK
187
188(define_attr "data_speculative" "no,yes" (const_string "no"))
189
190(define_attr "control_speculative" "no,yes" (const_string "no"))
191
192(define_attr "check_load" "no,yes" (const_string "no"))
388092d5
AB
193
194(define_attr "speculable1" "no,yes" (const_string "no"))
195
196(define_attr "speculable2" "no,yes" (const_string "no"))
c65ebc55 197\f
30028c85
VM
198;; DFA descriptions of ia64 processors used for insn scheduling and
199;; bundling.
200
201(automata_option "ndfa")
202
203;; Uncomment the following line to output automata for debugging.
204;; (automata_option "v")
205
206(automata_option "w")
207
30028c85
VM
208(include "itanium2.md")
209
c65ebc55
JW
210\f
211;; ::::::::::::::::::::
212;; ::
213;; :: Moves
214;; ::
215;; ::::::::::::::::::::
216
f2f90c63
RH
217;; Set of a single predicate register. This is only used to implement
218;; pr-to-pr move and complement.
219
33620355
EB
220(define_insn "movcci"
221 [(set (match_operand:CCI 0 "destination_operand" "=c,c,?c,?*r, c,*r,*m,*r")
222 (match_operand:CCI 1 "move_operand" " O,n, c, c,*r,*m,*r,*r"))]
f2f90c63
RH
223 ""
224 "@
225 cmp.ne %0, p0 = r0, r0
226 cmp.eq %0, p0 = r0, r0
33620355
EB
227 (%1) cmp.eq.unc %0, p0 = r0, r0
228 #
229 tbit.nz %0, p0 = %1, 0
230 ld1%O1 %0 = %1%P1
231 st1%Q0 %0 = %1%P0
232 mov %0 = %1"
233 [(set_attr "itanium_class" "icmp,icmp,icmp,unknown,tbit,ld,st,ialu")
f2f90c63
RH
234 (set_attr "predicable" "no")])
235
33620355
EB
236(define_split
237 [(set (match_operand:CCI 0 "register_operand" "")
238 (match_operand:CCI 1 "register_operand" ""))]
239 "reload_completed
240 && GET_CODE (operands[0]) == REG && GR_REGNO_P (REGNO (operands[0]))
241 && GET_CODE (operands[1]) == REG && PR_REGNO_P (REGNO (operands[1]))"
242 [(set (match_dup 2) (const_int 0))
243 (cond_exec (ne (match_dup 3) (const_int 0))
244 (set (match_dup 2) (const_int 1)))]
245 "operands[2] = gen_rtx_REG (BImode, REGNO (operands[0]));
246 operands[3] = gen_rtx_REG (BImode, REGNO (operands[1]));")
247
f2f90c63 248(define_insn "movbi"
b6fb7d46
JW
249 [(set (match_operand:BI 0 "destination_operand" "=c,c,?c,?*r, c,*r,*r,*m,*r")
250 (match_operand:BI 1 "move_operand" " O,n, c, c,*r, n,*m,*r,*r"))]
f2f90c63
RH
251 ""
252 "@
253 cmp.ne %0, %I0 = r0, r0
254 cmp.eq %0, %I0 = r0, r0
255 #
256 #
257 tbit.nz %0, %I0 = %1, 0
258 adds %0 = %1, r0
259 ld1%O1 %0 = %1%P1
cd5c4048
RH
260 st1%Q0 %0 = %1%P0
261 mov %0 = %1"
388092d5
AB
262 [(set_attr "itanium_class" "icmp,icmp,unknown,unknown,tbit,ialu,ld,st,ialu")
263 (set_attr "speculable1" "yes")
264 (set_attr "speculable2" "no, no, no, no, no, no, yes,no,no")])
f2f90c63
RH
265
266(define_split
267 [(set (match_operand:BI 0 "register_operand" "")
268 (match_operand:BI 1 "register_operand" ""))]
269 "reload_completed
270 && GET_CODE (operands[0]) == REG && GR_REGNO_P (REGNO (operands[0]))
271 && GET_CODE (operands[1]) == REG && PR_REGNO_P (REGNO (operands[1]))"
272 [(cond_exec (ne (match_dup 1) (const_int 0))
273 (set (match_dup 0) (const_int 1)))
274 (cond_exec (eq (match_dup 1) (const_int 0))
275 (set (match_dup 0) (const_int 0)))]
276 "")
277
278(define_split
279 [(set (match_operand:BI 0 "register_operand" "")
280 (match_operand:BI 1 "register_operand" ""))]
281 "reload_completed
282 && GET_CODE (operands[0]) == REG && PR_REGNO_P (REGNO (operands[0]))
283 && GET_CODE (operands[1]) == REG && PR_REGNO_P (REGNO (operands[1]))"
284 [(set (match_dup 2) (match_dup 4))
285 (set (match_dup 3) (match_dup 5))
086c0f96 286 (set (match_dup 0) (unspec:BI [(match_dup 0)] UNSPEC_PRED_REL_MUTEX))]
f2f90c63
RH
287 "operands[2] = gen_rtx_REG (CCImode, REGNO (operands[0]));
288 operands[3] = gen_rtx_REG (CCImode, REGNO (operands[0]) + 1);
289 operands[4] = gen_rtx_REG (CCImode, REGNO (operands[1]));
290 operands[5] = gen_rtx_REG (CCImode, REGNO (operands[1]) + 1);")
291
c65ebc55
JW
292(define_expand "movqi"
293 [(set (match_operand:QI 0 "general_operand" "")
294 (match_operand:QI 1 "general_operand" ""))]
295 ""
c65ebc55 296{
7b6e506e
RH
297 rtx op1 = ia64_expand_move (operands[0], operands[1]);
298 if (!op1)
299 DONE;
300 operands[1] = op1;
1d5d7a21 301})
c65ebc55 302
388092d5 303(define_insn "movqi_internal"
4b983fdc
RH
304 [(set (match_operand:QI 0 "destination_operand" "=r,r,r, m, r,*f,*f")
305 (match_operand:QI 1 "move_operand" "rO,J,m,rO,*f,rO,*f"))]
aebf2462 306 "ia64_move_ok (operands[0], operands[1])"
c65ebc55 307 "@
13da91fd 308 mov %0 = %r1
c65ebc55
JW
309 addl %0 = %1, r0
310 ld1%O1 %0 = %1%P1
13da91fd 311 st1%Q0 %0 = %r1%P0
c65ebc55 312 getf.sig %0 = %1
13da91fd
RH
313 setf.sig %0 = %r1
314 mov %0 = %1"
388092d5
AB
315 [(set_attr "itanium_class" "ialu,ialu,ld,st,frfr,tofr,fmisc")
316 (set_attr "speculable1" "yes")
317 (set_attr "speculable2" "no, no, yes,no,no, no, no")])
c65ebc55
JW
318
319(define_expand "movhi"
320 [(set (match_operand:HI 0 "general_operand" "")
321 (match_operand:HI 1 "general_operand" ""))]
322 ""
c65ebc55 323{
7b6e506e
RH
324 rtx op1 = ia64_expand_move (operands[0], operands[1]);
325 if (!op1)
326 DONE;
327 operands[1] = op1;
1d5d7a21 328})
c65ebc55 329
388092d5 330(define_insn "movhi_internal"
4b983fdc
RH
331 [(set (match_operand:HI 0 "destination_operand" "=r,r,r, m, r,*f,*f")
332 (match_operand:HI 1 "move_operand" "rO,J,m,rO,*f,rO,*f"))]
aebf2462 333 "ia64_move_ok (operands[0], operands[1])"
c65ebc55 334 "@
13da91fd 335 mov %0 = %r1
c65ebc55
JW
336 addl %0 = %1, r0
337 ld2%O1 %0 = %1%P1
13da91fd 338 st2%Q0 %0 = %r1%P0
c65ebc55 339 getf.sig %0 = %1
13da91fd
RH
340 setf.sig %0 = %r1
341 mov %0 = %1"
388092d5
AB
342 [(set_attr "itanium_class" "ialu,ialu,ld,st,frfr,tofr,fmisc")
343 (set_attr "speculable1" "yes")
344 (set_attr "speculable2" "no, no, yes,no,no, no, no")])
c65ebc55
JW
345
346(define_expand "movsi"
347 [(set (match_operand:SI 0 "general_operand" "")
348 (match_operand:SI 1 "general_operand" ""))]
349 ""
c65ebc55 350{
7b6e506e
RH
351 rtx op1 = ia64_expand_move (operands[0], operands[1]);
352 if (!op1)
353 DONE;
354 operands[1] = op1;
1d5d7a21 355})
c65ebc55 356
388092d5 357(define_insn "movsi_internal"
4e483a22
JB
358 [(set (match_operand:SI 0 "destination_operand" "=r,r,r,r,r, m, r,*f,*f, r,*d")
359 (match_operand:SI 1 "move_operand" "rO,J,j,i,m,rO,*f,rO,*f,*d,rK"))]
aebf2462 360 "ia64_move_ok (operands[0], operands[1])"
c65ebc55 361 "@
13da91fd 362 mov %0 = %r1
c65ebc55 363 addl %0 = %1, r0
4e483a22 364 addp4 %0 = %1 - 0x100000000, r0
c65ebc55
JW
365 movl %0 = %1
366 ld4%O1 %0 = %1%P1
13da91fd 367 st4%Q0 %0 = %r1%P0
c65ebc55 368 getf.sig %0 = %1
13da91fd 369 setf.sig %0 = %r1
97e242b0
RH
370 mov %0 = %1
371 mov %0 = %1
372 mov %0 = %r1"
1d5d7a21 373 ;; frar_m, toar_m ??? why not frar_i and toar_i
388092d5
AB
374 [(set_attr "itanium_class" "ialu,ialu,ialu,long_i,ld,st,frfr,tofr,fmisc,frar_m,toar_m")
375 (set_attr "speculable1" "yes")
376 (set_attr "speculable2" "no, no, no, no, yes,no,no, no, no, no, no")])
c65ebc55
JW
377
378(define_expand "movdi"
379 [(set (match_operand:DI 0 "general_operand" "")
380 (match_operand:DI 1 "general_operand" ""))]
381 ""
c65ebc55 382{
7b6e506e
RH
383 rtx op1 = ia64_expand_move (operands[0], operands[1]);
384 if (!op1)
385 DONE;
386 operands[1] = op1;
1d5d7a21 387})
c65ebc55 388
388092d5 389(define_insn "movdi_internal"
4b983fdc 390 [(set (match_operand:DI 0 "destination_operand"
4e483a22 391 "=r,r,r,r,r, m, r,*f,*f,*f, Q, r,*b, r,*e, r,*d, r,*c")
4b983fdc 392 (match_operand:DI 1 "move_operand"
4e483a22 393 "rO,JT,j,i,m,rO,*f,rO,*f, Q,*f,*b,rO,*e,rK,*d,rK,*c,rO"))]
aebf2462 394 "ia64_move_ok (operands[0], operands[1])"
9b7bf67d
RH
395{
396 static const char * const alt[] = {
1d5d7a21
RH
397 "%,mov %0 = %r1",
398 "%,addl %0 = %1, r0",
4e483a22 399 "%,addp4 %0 = %1 - 0x100000000, r0",
1d5d7a21
RH
400 "%,movl %0 = %1",
401 "%,ld8%O1 %0 = %1%P1",
402 "%,st8%Q0 %0 = %r1%P0",
403 "%,getf.sig %0 = %1",
404 "%,setf.sig %0 = %r1",
405 "%,mov %0 = %1",
406 "%,ldf8 %0 = %1%P1",
407 "%,stf8 %0 = %1%P0",
408 "%,mov %0 = %1",
409 "%,mov %0 = %r1",
410 "%,mov %0 = %1",
411 "%,mov %0 = %1",
412 "%,mov %0 = %1",
413 "%,mov %0 = %1",
414 "mov %0 = pr",
415 "mov pr = %1, -1"
9b7bf67d
RH
416 };
417
e820471b
NS
418 gcc_assert (which_alternative != 2 || TARGET_NO_PIC
419 || !symbolic_operand (operands[1], VOIDmode));
9b7bf67d
RH
420
421 return alt[which_alternative];
1d5d7a21 422}
388092d5
AB
423 [(set_attr "itanium_class" "ialu,ialu,ialu,long_i,ld,st,frfr,tofr,fmisc,fld,stf,frbr,tobr,frar_i,toar_i,frar_m,toar_m,frpr,topr")
424 (set_attr "speculable1" "yes")
425 (set_attr "speculable2" "no, no, no, no, yes,no,no, no, no, yes,no, no, no, no, no, no, no, no, no")])
c65ebc55 426
3abcb3a7 427(define_mode_iterator MODE [BI QI HI SI DI SF DF XF TI])
f90b7a5a 428(define_mode_iterator MODE_FOR_CMP [BI SI DI SF DF XF (TF "TARGET_HPUX")])
3abcb3a7 429(define_mode_iterator MODE_FOR_EXTEND [QI HI SI])
048d0d36
MK
430
431(define_mode_attr output_a [
432 (BI "ld1.a %0 = %1%P1")
433 (QI "ld1.a %0 = %1%P1")
434 (HI "ld2.a %0 = %1%P1")
435 (SI "ld4.a %0 = %1%P1")
436 (DI
437 "@
438 ld8.a %0 = %1%P1
439 ldf8.a %0 = %1%P1")
440 (SF
441 "@
442 ldfs.a %0 = %1%P1
443 ld4.a %0 = %1%P1")
444 (DF
445 "@
446 ldfd.a %0 = %1%P1
447 ld8.a %0 = %1%P1")
448 (XF "ldfe.a %0 = %1%P1")
449 (TI "ldfp8.a %X0 = %1%P1")])
450
451(define_mode_attr output_s [
452 (BI "ld1.s %0 = %1%P1")
453 (QI "ld1.s %0 = %1%P1")
454 (HI "ld2.s %0 = %1%P1")
455 (SI "ld4.s %0 = %1%P1")
456 (DI
457 "@
458 ld8.s %0 = %1%P1
459 ldf8.s %0 = %1%P1")
460 (SF
461 "@
462 ldfs.s %0 = %1%P1
463 ld4.s %0 = %1%P1")
464 (DF
465 "@
466 ldfd.s %0 = %1%P1
467 ld8.s %0 = %1%P1")
468 (XF "ldfe.s %0 = %1%P1")
469 (TI "ldfp8.s %X0 = %1%P1")])
470
471(define_mode_attr output_sa [
472 (BI "ld1.sa %0 = %1%P1")
473 (QI "ld1.sa %0 = %1%P1")
474 (HI "ld2.sa %0 = %1%P1")
475 (SI "ld4.sa %0 = %1%P1")
476 (DI
477 "@
478 ld8.sa %0 = %1%P1
479 ldf8.sa %0 = %1%P1")
480 (SF
481 "@
482 ldfs.sa %0 = %1%P1
483 ld4.sa %0 = %1%P1")
484 (DF
485 "@
486 ldfd.sa %0 = %1%P1
487 ld8.sa %0 = %1%P1")
488 (XF "ldfe.sa %0 = %1%P1")
489 (TI "ldfp8.sa %X0 = %1%P1")])
490
491(define_mode_attr output_c_clr [
492 (BI "ld1.c.clr%O1 %0 = %1%P1")
493 (QI "ld1.c.clr%O1 %0 = %1%P1")
494 (HI "ld2.c.clr%O1 %0 = %1%P1")
495 (SI "ld4.c.clr%O1 %0 = %1%P1")
496 (DI
497 "@
498 ld8.c.clr%O1 %0 = %1%P1
499 ldf8.c.clr %0 = %1%P1")
500 (SF
501 "@
502 ldfs.c.clr %0 = %1%P1
503 ld4.c.clr%O1 %0 = %1%P1")
504 (DF
505 "@
506 ldfd.c.clr %0 = %1%P1
507 ld8.c.clr%O1 %0 = %1%P1")
508 (XF "ldfe.c.clr %0 = %1%P1")
509 (TI "ldfp8.c.clr %X0 = %1%P1")])
510
388092d5
AB
511(define_mode_attr output_c_nc [
512 (BI "ld1.c.nc%O1 %0 = %1%P1")
513 (QI "ld1.c.nc%O1 %0 = %1%P1")
514 (HI "ld2.c.nc%O1 %0 = %1%P1")
515 (SI "ld4.c.nc%O1 %0 = %1%P1")
516 (DI
517 "@
518 ld8.c.nc%O1 %0 = %1%P1
519 ldf8.c.nc %0 = %1%P1")
520 (SF
521 "@
522 ldfs.c.nc %0 = %1%P1
523 ld4.c.nc%O1 %0 = %1%P1")
524 (DF
525 "@
526 ldfd.c.nc %0 = %1%P1
527 ld8.c.nc%O1 %0 = %1%P1")
528 (XF "ldfe.c.nc %0 = %1%P1")
529 (TI "ldfp8.c.nc %X0 = %1%P1")])
530
048d0d36
MK
531(define_mode_attr ld_reg_constr [(BI "=*r") (QI "=r") (HI "=r") (SI "=r") (DI "=r,*f") (SF "=f,*r") (DF "=f,*r") (XF "=f") (TI "=*x")])
532(define_mode_attr ldc_reg_constr [(BI "+*r") (QI "+r") (HI "+r") (SI "+r") (DI "+r,*f") (SF "+f,*r") (DF "+f,*r") (XF "+f") (TI "+*x")])
533(define_mode_attr chk_reg_constr [(BI "*r") (QI "r") (HI "r") (SI "r") (DI "r,*f") (SF "f,*r") (DF "f,*r") (XF "f") (TI "*x")])
534
535(define_mode_attr mem_constr [(BI "*m") (QI "m") (HI "m") (SI "m") (DI "m,Q") (SF "Q,m") (DF "Q,m") (XF "m") (TI "Q")])
536
f6ec1d11
MK
537;; Define register predicate prefix.
538;; We can generate speculative loads only for general and fp registers - this
ea2c620c 539;; is constrained in ia64.c: ia64_speculate_insn ().
048d0d36
MK
540(define_mode_attr reg_pred_prefix [(BI "gr") (QI "gr") (HI "gr") (SI "gr") (DI "grfr") (SF "grfr") (DF "grfr") (XF "fr") (TI "fr")])
541
542(define_mode_attr ld_class [(BI "ld") (QI "ld") (HI "ld") (SI "ld") (DI "ld,fld") (SF "fld,ld") (DF "fld,ld") (XF "fld") (TI "fldp")])
543(define_mode_attr chka_class [(BI "chk_a") (QI "chk_a") (HI "chk_a") (SI "chk_a") (DI "chk_a,chk_a") (SF "chk_a,chk_a") (DF "chk_a,chk_a") (XF "chk_a") (TI "chk_a")])
544(define_mode_attr chks_class [(BI "chk_s_i") (QI "chk_s_i") (HI "chk_s_i") (SI "chk_s_i") (DI "chk_s_i,chk_s_f") (SF "chk_s_f,chk_s_i") (DF "chk_s_f,chk_s_i") (XF "chk_s_f") (TI "chk_s_i")])
545
546(define_mode_attr attr_yes [(BI "yes") (QI "yes") (HI "yes") (SI "yes") (DI "yes,yes") (SF "yes,yes") (DF "yes,yes") (XF "yes") (TI "yes")])
547
548(define_insn "mov<mode>_advanced"
549 [(set (match_operand:MODE 0 "<reg_pred_prefix>_register_operand" "<ld_reg_constr>")
550 (unspec:MODE [(match_operand:MODE 1 "memory_operand" "<mem_constr>")] UNSPEC_LDA))]
551 "ia64_move_ok (operands[0], operands[1])"
552 "<output_a>"
553 [(set_attr "itanium_class" "<ld_class>")
554 (set_attr "data_speculative" "<attr_yes>")])
555
556(define_insn "zero_extend<mode>di2_advanced"
557 [(set (match_operand:DI 0 "gr_register_operand" "=r")
558 (zero_extend:DI (unspec:MODE_FOR_EXTEND [(match_operand:MODE_FOR_EXTEND 1 "memory_operand" "<mem_constr>")] UNSPEC_LDA)))]
559 ""
560 "<output_a>"
561 [(set_attr "itanium_class" "<ld_class>")
562 (set_attr "data_speculative" "<attr_yes>")])
563
564(define_insn "mov<mode>_speculative"
565 [(set (match_operand:MODE 0 "<reg_pred_prefix>_register_operand" "<ld_reg_constr>")
566 (unspec:MODE [(match_operand:MODE 1 "memory_operand" "<mem_constr>")] UNSPEC_LDS))]
567 "ia64_move_ok (operands[0], operands[1])"
568 "<output_s>"
569 [(set_attr "itanium_class" "<ld_class>")
570 (set_attr "control_speculative" "<attr_yes>")])
571
572(define_insn "zero_extend<mode>di2_speculative"
573 [(set (match_operand:DI 0 "gr_register_operand" "=r")
574 (zero_extend:DI (unspec:MODE_FOR_EXTEND [(match_operand:MODE_FOR_EXTEND 1 "memory_operand" "<mem_constr>")] UNSPEC_LDS)))]
575 ""
576 "<output_s>"
577 [(set_attr "itanium_class" "<ld_class>")
578 (set_attr "control_speculative" "<attr_yes>")])
579
580(define_insn "mov<mode>_speculative_advanced"
581 [(set (match_operand:MODE 0 "<reg_pred_prefix>_register_operand" "<ld_reg_constr>")
582 (unspec:MODE [(match_operand:MODE 1 "memory_operand" "<mem_constr>")] UNSPEC_LDSA))]
583 "ia64_move_ok (operands[0], operands[1])"
584 "<output_sa>"
585 [(set_attr "itanium_class" "<ld_class>")
586 (set_attr "data_speculative" "<attr_yes>")
587 (set_attr "control_speculative" "<attr_yes>")])
588
388092d5
AB
589(define_insn "mov<mode>_speculative_a"
590 [(set (match_operand:MODE 0 "<reg_pred_prefix>_register_operand" "<ld_reg_constr>")
591 (unspec:MODE [(match_operand:MODE 1 "memory_operand" "<mem_constr>")] UNSPEC_LDS_A))]
592 "ia64_move_ok (operands[0], operands[1])"
593 "<output_sa>"
594 [(set_attr "itanium_class" "<ld_class>")
595 (set_attr "data_speculative" "<attr_yes>")
596 (set_attr "control_speculative" "<attr_yes>")])
597
048d0d36
MK
598(define_insn "zero_extend<mode>di2_speculative_advanced"
599 [(set (match_operand:DI 0 "gr_register_operand" "=r")
600 (zero_extend:DI (unspec:MODE_FOR_EXTEND [(match_operand:MODE_FOR_EXTEND 1 "memory_operand" "<mem_constr>")] UNSPEC_LDSA)))]
601 ""
602 "<output_sa>"
603 [(set_attr "itanium_class" "<ld_class>")
604 (set_attr "data_speculative" "<attr_yes>")
605 (set_attr "control_speculative" "<attr_yes>")])
606
388092d5
AB
607(define_insn "zero_extend<mode>di2_speculative_a"
608 [(set (match_operand:DI 0 "gr_register_operand" "=r")
609 (zero_extend:DI (unspec:MODE_FOR_EXTEND [(match_operand:MODE_FOR_EXTEND 1 "memory_operand" "<mem_constr>")] UNSPEC_LDS_A)))]
610 ""
611 "<output_sa>"
612 [(set_attr "itanium_class" "<ld_class>")
613 (set_attr "data_speculative" "<attr_yes>")
614 (set_attr "control_speculative" "<attr_yes>")])
615
048d0d36
MK
616(define_insn "mov<mode>_clr"
617 [(set (match_operand:MODE 0 "<reg_pred_prefix>_register_operand" "<ldc_reg_constr>")
618 (if_then_else:MODE (ne (unspec [(match_dup 0)] UNSPEC_LDCCLR) (const_int 0))
619 (match_operand:MODE 1 "memory_operand" "<mem_constr>")
620 (match_dup 0)))]
621 "ia64_move_ok (operands[0], operands[1])"
622 "<output_c_clr>"
623 [(set_attr "itanium_class" "<ld_class>")
624 (set_attr "check_load" "<attr_yes>")])
625
388092d5
AB
626(define_insn "mov<mode>_nc"
627 [(set (match_operand:MODE 0 "<reg_pred_prefix>_register_operand" "<ldc_reg_constr>")
628 (if_then_else:MODE (ne (unspec [(match_dup 0)] UNSPEC_LDCNC) (const_int 0))
629 (match_operand:MODE 1 "memory_operand" "<mem_constr>")
630 (match_dup 0)))]
631 "ia64_move_ok (operands[0], operands[1])"
632 "<output_c_nc>"
633 [(set_attr "itanium_class" "<ld_class>")
634 (set_attr "check_load" "<attr_yes>")])
635
048d0d36
MK
636(define_insn "zero_extend<mode>di2_clr"
637 [(set (match_operand:DI 0 "gr_register_operand" "+r")
638 (if_then_else:DI (ne (unspec [(match_dup 0)] UNSPEC_LDCCLR) (const_int 0))
639 (zero_extend:DI (match_operand:MODE_FOR_EXTEND 1 "memory_operand" "<mem_constr>"))
640 (match_dup 0)))]
641 ""
642 "<output_c_clr>"
643 [(set_attr "itanium_class" "<ld_class>")
644 (set_attr "check_load" "<attr_yes>")])
645
388092d5
AB
646(define_insn "zero_extend<mode>di2_nc"
647 [(set (match_operand:DI 0 "gr_register_operand" "+r")
648 (if_then_else:DI (ne (unspec [(match_dup 0)] UNSPEC_LDCNC) (const_int 0))
649 (zero_extend:DI (match_operand:MODE_FOR_EXTEND 1 "memory_operand" "<mem_constr>"))
650 (match_dup 0)))]
651 ""
652 "<output_c_nc>"
653 [(set_attr "itanium_class" "<ld_class>")
654 (set_attr "check_load" "<attr_yes>")])
655
048d0d36
MK
656(define_insn "advanced_load_check_clr_<mode>"
657 [(set (pc)
658 (if_then_else (ne (unspec [(match_operand:MODE 0 "<reg_pred_prefix>_register_operand" "<chk_reg_constr>")] UNSPEC_CHKACLR) (const_int 0))
659 (pc)
660 (label_ref (match_operand 1 "" ""))))]
661 ""
662 "chk.a.clr %0, %l1"
663 [(set_attr "itanium_class" "<chka_class>")])
664
388092d5
AB
665(define_insn "advanced_load_check_nc_<mode>"
666 [(set (pc)
667 (if_then_else (ne (unspec [(match_operand:MODE 0 "<reg_pred_prefix>_register_operand" "<chk_reg_constr>")] UNSPEC_CHKANC) (const_int 0))
668 (pc)
669 (label_ref (match_operand 1 "" ""))))]
670 ""
671 "chk.a.clr %0, %l1"
672 [(set_attr "itanium_class" "<chka_class>")])
673
048d0d36
MK
674(define_insn "speculation_check_<mode>"
675 [(set (pc)
676 (if_then_else (ne (unspec [(match_operand:MODE 0 "<reg_pred_prefix>_register_operand" "<chk_reg_constr>")] UNSPEC_CHKS) (const_int 0))
677 (pc)
678 (label_ref (match_operand 1 "" ""))))]
679 ""
680 "chk.s %0, %l1"
681 [(set_attr "itanium_class" "<chks_class>")])
682
9b7bf67d 683(define_split
21515593
RH
684 [(set (match_operand 0 "register_operand" "")
685 (match_operand 1 "symbolic_operand" ""))]
5e6c8b64 686 "reload_completed"
9b7bf67d 687 [(const_int 0)]
9b7bf67d 688{
5e6c8b64
RH
689 if (ia64_expand_load_address (operands[0], operands[1]))
690 DONE;
691 else
692 FAIL;
1d5d7a21 693})
9b7bf67d 694
c65ebc55 695(define_expand "load_fptr"
5e6c8b64
RH
696 [(set (match_operand:DI 0 "register_operand" "")
697 (plus:DI (match_dup 2) (match_operand 1 "function_operand" "")))
698 (set (match_dup 0) (match_dup 3))]
699 "reload_completed"
c65ebc55 700{
5e6c8b64
RH
701 operands[2] = pic_offset_table_rtx;
702 operands[3] = gen_const_mem (DImode, operands[0]);
1d5d7a21 703})
c65ebc55
JW
704
705(define_insn "*load_fptr_internal1"
706 [(set (match_operand:DI 0 "register_operand" "=r")
5da4f548 707 (plus:DI (reg:DI 1) (match_operand 1 "function_operand" "s")))]
5e6c8b64 708 "reload_completed"
c65ebc55 709 "addl %0 = @ltoff(@fptr(%1)), gp"
52e12ad0 710 [(set_attr "itanium_class" "ialu")])
c65ebc55
JW
711
712(define_insn "load_gprel"
713 [(set (match_operand:DI 0 "register_operand" "=r")
5da4f548 714 (plus:DI (reg:DI 1) (match_operand 1 "sdata_symbolic_operand" "s")))]
5e6c8b64 715 "reload_completed"
c65ebc55 716 "addl %0 = @gprel(%1), gp"
52e12ad0 717 [(set_attr "itanium_class" "ialu")])
c65ebc55 718
5e6c8b64 719(define_insn "*gprel64_offset"
59da9a7d
JW
720 [(set (match_operand:DI 0 "register_operand" "=r")
721 (minus:DI (match_operand:DI 1 "symbolic_operand" "") (reg:DI 1)))]
5e6c8b64 722 "reload_completed"
59da9a7d 723 "movl %0 = @gprel(%1)"
52e12ad0 724 [(set_attr "itanium_class" "long_i")])
59da9a7d
JW
725
726(define_expand "load_gprel64"
5e6c8b64
RH
727 [(set (match_operand:DI 0 "register_operand" "")
728 (minus:DI (match_operand:DI 1 "symbolic_operand" "") (match_dup 2)))
729 (set (match_dup 0)
730 (plus:DI (match_dup 2) (match_dup 0)))]
731 "reload_completed"
ec039e3c 732{
5e6c8b64 733 operands[2] = pic_offset_table_rtx;
1d5d7a21 734})
59da9a7d 735
af1e5518
RH
736;; This is used as a placeholder for the return address during early
737;; compilation. We won't know where we've placed this until during
738;; reload, at which point it can wind up in b0, a general register,
739;; or memory. The only safe destination under these conditions is a
740;; general register.
741
742(define_insn_and_split "*movdi_ret_addr"
743 [(set (match_operand:DI 0 "register_operand" "=r")
744 (unspec:DI [(const_int 0)] UNSPEC_RET_ADDR))]
745 ""
746 "#"
747 "reload_completed"
748 [(const_int 0)]
749{
750 ia64_split_return_addr_rtx (operands[0]);
751 DONE;
752}
753 [(set_attr "itanium_class" "ialu")])
754
ef1ecf87 755(define_insn "*load_symptr_high"
c65ebc55 756 [(set (match_operand:DI 0 "register_operand" "=r")
ef1ecf87
RH
757 (plus:DI (high:DI (match_operand 1 "got_symbolic_operand" "s"))
758 (match_operand:DI 2 "register_operand" "a")))]
5e6c8b64 759 "reload_completed"
ef1ecf87
RH
760{
761 if (HAVE_AS_LTOFFX_LDXMOV_RELOCS)
762 return "%,addl %0 = @ltoffx(%1), %2";
763 else
764 return "%,addl %0 = @ltoff(%1), %2";
765}
52e12ad0 766 [(set_attr "itanium_class" "ialu")])
c65ebc55 767
ef1ecf87
RH
768(define_insn "*load_symptr_low"
769 [(set (match_operand:DI 0 "register_operand" "=r")
770 (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
771 (match_operand 2 "got_symbolic_operand" "s")))]
5e6c8b64 772 "reload_completed"
ef1ecf87
RH
773{
774 if (HAVE_AS_LTOFFX_LDXMOV_RELOCS)
775 return "%,ld8.mov %0 = [%1], %2";
776 else
777 return "%,ld8 %0 = [%1]";
778}
779 [(set_attr "itanium_class" "ld")])
780
5e6c8b64 781(define_insn_and_split "load_dtpmod"
7b6e506e 782 [(set (match_operand:DI 0 "register_operand" "=r")
5e2b4439 783 (unspec:DI [(match_operand 1 "tls_symbolic_operand" "")]
5e6c8b64 784 UNSPEC_DTPMOD))]
7b6e506e 785 ""
5e6c8b64
RH
786 "#"
787 "reload_completed"
788 [(set (match_dup 0)
789 (plus:DI (unspec:DI [(match_dup 1)] UNSPEC_LTOFF_DTPMOD)
790 (match_dup 2)))
791 (set (match_dup 0) (match_dup 3))]
792{
793 operands[2] = pic_offset_table_rtx;
794 operands[3] = gen_const_mem (DImode, operands[0]);
795})
7b6e506e 796
5e6c8b64 797(define_insn "*load_ltoff_dtpmod"
7b6e506e 798 [(set (match_operand:DI 0 "register_operand" "=r")
5e2b4439 799 (plus:DI (unspec:DI [(match_operand 1 "tls_symbolic_operand" "")]
5e6c8b64
RH
800 UNSPEC_LTOFF_DTPMOD)
801 (match_operand:DI 2 "register_operand" "a")))]
802 "reload_completed"
803 "addl %0 = @ltoff(@dtpmod(%1)), %2"
7b6e506e
RH
804 [(set_attr "itanium_class" "ialu")])
805
806(define_expand "load_dtprel"
807 [(set (match_operand:DI 0 "register_operand" "")
5e2b4439 808 (unspec:DI [(match_operand 1 "tls_symbolic_operand" "")]
7b6e506e
RH
809 UNSPEC_DTPREL))]
810 ""
811 "")
812
813(define_insn "*load_dtprel64"
814 [(set (match_operand:DI 0 "register_operand" "=r")
5e2b4439 815 (unspec:DI [(match_operand 1 "ld_tls_symbolic_operand" "")]
7b6e506e
RH
816 UNSPEC_DTPREL))]
817 "TARGET_TLS64"
818 "movl %0 = @dtprel(%1)"
819 [(set_attr "itanium_class" "long_i")])
820
821(define_insn "*load_dtprel22"
822 [(set (match_operand:DI 0 "register_operand" "=r")
5e2b4439 823 (unspec:DI [(match_operand 1 "ld_tls_symbolic_operand" "")]
7b6e506e
RH
824 UNSPEC_DTPREL))]
825 ""
826 "addl %0 = @dtprel(%1), r0"
827 [(set_attr "itanium_class" "ialu")])
828
5e6c8b64
RH
829(define_insn_and_split "*load_dtprel_gd"
830 [(set (match_operand:DI 0 "register_operand" "=r")
5e2b4439 831 (unspec:DI [(match_operand 1 "tls_symbolic_operand" "")]
5e6c8b64
RH
832 UNSPEC_DTPREL))]
833 ""
834 "#"
835 "reload_completed"
836 [(set (match_dup 0)
837 (plus:DI (unspec:DI [(match_dup 1)] UNSPEC_LTOFF_DTPREL)
838 (match_dup 2)))
839 (set (match_dup 0) (match_dup 3))]
840{
841 operands[2] = pic_offset_table_rtx;
842 operands[3] = gen_const_mem (DImode, operands[0]);
843})
844
845(define_insn "*load_ltoff_dtprel"
846 [(set (match_operand:DI 0 "register_operand" "=r")
5e2b4439 847 (plus:DI (unspec:DI [(match_operand 1 "tls_symbolic_operand" "")]
5e6c8b64
RH
848 UNSPEC_LTOFF_DTPREL)
849 (match_operand:DI 2 "register_operand" "a")))]
850 ""
851 "addl %0 = @ltoff(@dtprel(%1)), %2"
852 [(set_attr "itanium_class" "ialu")])
853
7b6e506e
RH
854(define_expand "add_dtprel"
855 [(set (match_operand:DI 0 "register_operand" "")
5e2b4439 856 (plus:DI (unspec:DI [(match_operand 1 "ld_tls_symbolic_operand" "")]
5e6c8b64
RH
857 UNSPEC_DTPREL)
858 (match_operand:DI 2 "register_operand" "")))]
7b6e506e
RH
859 "!TARGET_TLS64"
860 "")
861
862(define_insn "*add_dtprel14"
863 [(set (match_operand:DI 0 "register_operand" "=r")
5e2b4439 864 (plus:DI (unspec:DI [(match_operand 1 "ld_tls_symbolic_operand" "")]
5e6c8b64
RH
865 UNSPEC_DTPREL)
866 (match_operand:DI 2 "register_operand" "r")))]
7b6e506e 867 "TARGET_TLS14"
5e6c8b64 868 "adds %0 = @dtprel(%1), %2"
7b6e506e
RH
869 [(set_attr "itanium_class" "ialu")])
870
871(define_insn "*add_dtprel22"
872 [(set (match_operand:DI 0 "register_operand" "=r")
5e2b4439 873 (plus:DI (unspec:DI [(match_operand 1 "ld_tls_symbolic_operand" "")]
5e6c8b64
RH
874 UNSPEC_DTPREL)
875 (match_operand:DI 2 "register_operand" "a")))]
7b6e506e 876 "TARGET_TLS22"
5e6c8b64 877 "addl %0 = @dtprel(%1), %2"
7b6e506e
RH
878 [(set_attr "itanium_class" "ialu")])
879
880(define_expand "load_tprel"
881 [(set (match_operand:DI 0 "register_operand" "")
5e2b4439 882 (unspec:DI [(match_operand 1 "tls_symbolic_operand" "")]
7b6e506e
RH
883 UNSPEC_TPREL))]
884 ""
885 "")
886
887(define_insn "*load_tprel64"
888 [(set (match_operand:DI 0 "register_operand" "=r")
5e2b4439 889 (unspec:DI [(match_operand 1 "le_tls_symbolic_operand" "")]
7b6e506e
RH
890 UNSPEC_TPREL))]
891 "TARGET_TLS64"
892 "movl %0 = @tprel(%1)"
893 [(set_attr "itanium_class" "long_i")])
894
895(define_insn "*load_tprel22"
896 [(set (match_operand:DI 0 "register_operand" "=r")
5e2b4439 897 (unspec:DI [(match_operand 1 "le_tls_symbolic_operand" "")]
7b6e506e
RH
898 UNSPEC_TPREL))]
899 ""
900 "addl %0 = @tprel(%1), r0"
901 [(set_attr "itanium_class" "ialu")])
902
5e6c8b64
RH
903(define_insn_and_split "*load_tprel_ie"
904 [(set (match_operand:DI 0 "register_operand" "=r")
5e2b4439 905 (unspec:DI [(match_operand 1 "ie_tls_symbolic_operand" "")]
5e6c8b64
RH
906 UNSPEC_TPREL))]
907 ""
908 "#"
909 "reload_completed"
910 [(set (match_dup 0)
911 (plus:DI (unspec:DI [(match_dup 1)] UNSPEC_LTOFF_TPREL)
912 (match_dup 2)))
913 (set (match_dup 0) (match_dup 3))]
914{
915 operands[2] = pic_offset_table_rtx;
916 operands[3] = gen_const_mem (DImode, operands[0]);
917})
918
919(define_insn "*load_ltoff_tprel"
920 [(set (match_operand:DI 0 "register_operand" "=r")
5e2b4439 921 (plus:DI (unspec:DI [(match_operand 1 "ie_tls_symbolic_operand" "")]
5e6c8b64
RH
922 UNSPEC_LTOFF_TPREL)
923 (match_operand:DI 2 "register_operand" "a")))]
924 ""
925 "addl %0 = @ltoff(@tprel(%1)), %2"
926 [(set_attr "itanium_class" "ialu")])
927
7b6e506e
RH
928(define_expand "add_tprel"
929 [(set (match_operand:DI 0 "register_operand" "")
5e2b4439 930 (plus:DI (unspec:DI [(match_operand 1 "le_tls_symbolic_operand" "")]
5e6c8b64
RH
931 UNSPEC_TPREL)
932 (match_operand:DI 2 "register_operand" "")))]
7b6e506e
RH
933 "!TARGET_TLS64"
934 "")
935
936(define_insn "*add_tprel14"
937 [(set (match_operand:DI 0 "register_operand" "=r")
5e2b4439 938 (plus:DI (unspec:DI [(match_operand 1 "le_tls_symbolic_operand" "")]
5e6c8b64
RH
939 UNSPEC_TPREL)
940 (match_operand:DI 2 "register_operand" "r")))]
7b6e506e 941 "TARGET_TLS14"
5e6c8b64 942 "adds %0 = @tprel(%1), %2"
7b6e506e
RH
943 [(set_attr "itanium_class" "ialu")])
944
945(define_insn "*add_tprel22"
946 [(set (match_operand:DI 0 "register_operand" "=r")
5e2b4439 947 (plus:DI (unspec:DI [(match_operand 1 "le_tls_symbolic_operand" "")]
5e6c8b64
RH
948 UNSPEC_TPREL)
949 (match_operand:DI 2 "register_operand" "a")))]
7b6e506e 950 "TARGET_TLS22"
5e6c8b64 951 "addl %0 = @tprel(%1), %2"
7b6e506e
RH
952 [(set_attr "itanium_class" "ialu")])
953
3f622353 954;; With no offsettable memory references, we've got to have a scratch
2ffe0e02
ZW
955;; around to play with the second word. However, in order to avoid a
956;; reload nightmare we lie, claim we don't need one, and fix it up
957;; in ia64_split_tmode_move.
3f622353 958(define_expand "movti"
2ffe0e02
ZW
959 [(set (match_operand:TI 0 "general_operand" "")
960 (match_operand:TI 1 "general_operand" ""))]
3f622353 961 ""
3f622353 962{
7b6e506e
RH
963 rtx op1 = ia64_expand_move (operands[0], operands[1]);
964 if (!op1)
965 DONE;
966 operands[1] = op1;
1d5d7a21 967})
3f622353 968
388092d5 969(define_insn_and_split "movti_internal"
b6fb7d46
JW
970 [(set (match_operand:TI 0 "destination_operand" "=r, *fm,*x,*f, Q")
971 (match_operand:TI 1 "general_operand" "r*fim,r, Q, *fOQ,*f"))]
3f622353 972 "ia64_move_ok (operands[0], operands[1])"
a71aef0b
JB
973 "@
974 #
975 #
976 ldfp8 %X0 = %1%P1
977 #
978 #"
979 "reload_completed && !ia64_load_pair_ok(operands[0], operands[1])"
3f622353 980 [(const_int 0)]
3f622353 981{
f57fc998 982 ia64_split_tmode_move (operands);
3f622353 983 DONE;
1d5d7a21 984}
388092d5
AB
985 [(set_attr "itanium_class" "unknown,unknown,fldp,unknown,unknown")
986 (set_attr "speculable1" "yes")
987 (set_attr "speculable2" "no, no, yes, no, no")])
e314e331 988
c65ebc55
JW
989;; Floating Point Moves
990;;
991;; Note - Patterns for SF mode moves are compulsory, but
05713b80 992;; patterns for DF are optional, as GCC can synthesize them.
c65ebc55
JW
993
994(define_expand "movsf"
995 [(set (match_operand:SF 0 "general_operand" "")
996 (match_operand:SF 1 "general_operand" ""))]
997 ""
c65ebc55 998{
7b6e506e
RH
999 rtx op1 = ia64_expand_move (operands[0], operands[1]);
1000 if (!op1)
1001 DONE;
1002 operands[1] = op1;
1d5d7a21 1003})
c65ebc55 1004
388092d5 1005(define_insn "movsf_internal"
735b94a7
SE
1006 [(set (match_operand:SF 0 "destination_operand" "=f,f, Q,*r, f,*r,*r, m,*r")
1007 (match_operand:SF 1 "general_operand" "fG,Q,fG,fG,*r,*r, m,*r, F"))]
aebf2462 1008 "ia64_move_ok (operands[0], operands[1])"
c65ebc55 1009 "@
1d5d7a21
RH
1010 mov %0 = %F1
1011 ldfs %0 = %1%P1
1012 stfs %0 = %F1%P0
1013 getf.s %0 = %F1
1014 setf.s %0 = %1
1015 mov %0 = %1
1016 ld4%O1 %0 = %1%P1
735b94a7
SE
1017 st4%Q0 %0 = %1%P0
1018 movl %0 = %G1"
1019 [(set_attr "itanium_class" "fmisc,fld,stf,frfr,tofr,ialu,ld,st,long_i")
388092d5 1020 (set_attr "speculable1" "yes")
735b94a7 1021 (set_attr "speculable2" "no, yes,no, no, no, no, yes,no,no")])
c65ebc55
JW
1022
1023(define_expand "movdf"
1024 [(set (match_operand:DF 0 "general_operand" "")
1025 (match_operand:DF 1 "general_operand" ""))]
1026 ""
c65ebc55 1027{
7b6e506e
RH
1028 rtx op1 = ia64_expand_move (operands[0], operands[1]);
1029 if (!op1)
1030 DONE;
1031 operands[1] = op1;
1d5d7a21 1032})
c65ebc55 1033
388092d5 1034(define_insn "movdf_internal"
735b94a7
SE
1035 [(set (match_operand:DF 0 "destination_operand" "=f,f, Q,*r, f,*r,*r, m,*r")
1036 (match_operand:DF 1 "general_operand" "fG,Q,fG,fG,*r,*r, m,*r, F"))]
aebf2462 1037 "ia64_move_ok (operands[0], operands[1])"
c65ebc55 1038 "@
1d5d7a21
RH
1039 mov %0 = %F1
1040 ldfd %0 = %1%P1
1041 stfd %0 = %F1%P0
1042 getf.d %0 = %F1
1043 setf.d %0 = %1
1044 mov %0 = %1
1045 ld8%O1 %0 = %1%P1
735b94a7
SE
1046 st8%Q0 %0 = %1%P0
1047 movl %0 = %G1"
1048 [(set_attr "itanium_class" "fmisc,fld,stf,frfr,tofr,ialu,ld,st,long_i")
388092d5 1049 (set_attr "speculable1" "yes")
735b94a7 1050 (set_attr "speculable2" "no, yes,no, no, no, no, yes,no,no")])
c65ebc55 1051
3f622353
RH
1052;; With no offsettable memory references, we've got to have a scratch
1053;; around to play with the second word if the variable winds up in GRs.
02befdf4
ZW
1054(define_expand "movxf"
1055 [(set (match_operand:XF 0 "general_operand" "")
1056 (match_operand:XF 1 "general_operand" ""))]
1057 ""
e5bde68a 1058{
4de67c26
JM
1059 if (ia64_expand_movxf_movrf (XFmode, operands))
1060 DONE;
1d5d7a21 1061})
e5bde68a 1062
3b572406 1063;; ??? There's no easy way to mind volatile acquire/release semantics.
75cdbeb8 1064
388092d5 1065(define_insn "movxf_internal"
78d8e0f9
ZW
1066 [(set (match_operand:XF 0 "destination_operand" "=f,f, m")
1067 (match_operand:XF 1 "general_operand" "fG,m,fG"))]
02befdf4 1068 "ia64_move_ok (operands[0], operands[1])"
e5bde68a 1069 "@
1d5d7a21
RH
1070 mov %0 = %F1
1071 ldfe %0 = %1%P1
1072 stfe %0 = %F1%P0"
388092d5
AB
1073 [(set_attr "itanium_class" "fmisc,fld,stf")
1074 (set_attr "speculable1" "yes")
1075 (set_attr "speculable2" "no, yes,no")])
f57fc998 1076
4de67c26
JM
1077;; Same as for movxf, but for RFmode.
1078(define_expand "movrf"
1079 [(set (match_operand:RF 0 "general_operand" "")
1080 (match_operand:RF 1 "general_operand" ""))]
1081 ""
1082{
1083 if (ia64_expand_movxf_movrf (RFmode, operands))
1084 DONE;
1085})
1086
1087(define_insn "*movrf_internal"
1088 [(set (match_operand:RF 0 "destination_operand" "=f,f, m")
1089 (match_operand:RF 1 "general_operand" "fG,m,fG"))]
1090 "ia64_move_ok (operands[0], operands[1])"
1091 "@
1092 mov %0 = %F1
1093 ldf.fill %0 = %1%P1
1094 stf.spill %0 = %F1%P0"
1095 [(set_attr "itanium_class" "fmisc,fld,stf")])
1096
f57fc998 1097;; Better code generation via insns that deal with TFmode register pairs
2ffe0e02 1098;; directly. Same concerns apply as for TImode.
f57fc998 1099(define_expand "movtf"
2ffe0e02
ZW
1100 [(set (match_operand:TF 0 "general_operand" "")
1101 (match_operand:TF 1 "general_operand" ""))]
f57fc998
ZW
1102 ""
1103{
1104 rtx op1 = ia64_expand_move (operands[0], operands[1]);
1105 if (!op1)
1106 DONE;
1107 operands[1] = op1;
1108})
1109
1110(define_insn_and_split "*movtf_internal"
e77ee95d 1111 [(set (match_operand:TF 0 "destination_operand" "=r,r,m")
2ffe0e02 1112 (match_operand:TF 1 "general_operand" "ri,m,r"))]
f57fc998
ZW
1113 "ia64_move_ok (operands[0], operands[1])"
1114 "#"
1115 "reload_completed"
1116 [(const_int 0)]
1117{
1118 ia64_split_tmode_move (operands);
1119 DONE;
1120}
1121 [(set_attr "itanium_class" "unknown")
1122 (set_attr "predicable" "no")])
1123
c65ebc55
JW
1124\f
1125;; ::::::::::::::::::::
1126;; ::
1127;; :: Conversions
1128;; ::
1129;; ::::::::::::::::::::
1130
1131;; Signed conversions from a smaller integer to a larger integer
1132
1133(define_insn "extendqidi2"
0551c32d
RH
1134 [(set (match_operand:DI 0 "gr_register_operand" "=r")
1135 (sign_extend:DI (match_operand:QI 1 "gr_register_operand" "r")))]
c65ebc55
JW
1136 ""
1137 "sxt1 %0 = %1"
52e12ad0 1138 [(set_attr "itanium_class" "xtd")])
c65ebc55
JW
1139
1140(define_insn "extendhidi2"
0551c32d
RH
1141 [(set (match_operand:DI 0 "gr_register_operand" "=r")
1142 (sign_extend:DI (match_operand:HI 1 "gr_register_operand" "r")))]
c65ebc55
JW
1143 ""
1144 "sxt2 %0 = %1"
52e12ad0 1145 [(set_attr "itanium_class" "xtd")])
c65ebc55
JW
1146
1147(define_insn "extendsidi2"
655f2eb9
RH
1148 [(set (match_operand:DI 0 "grfr_register_operand" "=r,?f")
1149 (sign_extend:DI (match_operand:SI 1 "grfr_register_operand" "r,f")))]
c65ebc55
JW
1150 ""
1151 "@
1152 sxt4 %0 = %1
aebf2462 1153 fsxt.r %0 = %1, %1"
52e12ad0 1154 [(set_attr "itanium_class" "xtd,fmisc")])
c65ebc55
JW
1155
1156;; Unsigned conversions from a smaller integer to a larger integer
1157
1158(define_insn "zero_extendqidi2"
0551c32d
RH
1159 [(set (match_operand:DI 0 "gr_register_operand" "=r,r")
1160 (zero_extend:DI (match_operand:QI 1 "gr_nonimmediate_operand" "r,m")))]
c65ebc55
JW
1161 ""
1162 "@
1163 zxt1 %0 = %1
1164 ld1%O1 %0 = %1%P1"
388092d5
AB
1165 [(set_attr "itanium_class" "xtd,ld")
1166 (set_attr "speculable1" "yes")
1167 (set_attr "speculable2" "no, yes")])
c65ebc55
JW
1168
1169(define_insn "zero_extendhidi2"
0551c32d
RH
1170 [(set (match_operand:DI 0 "gr_register_operand" "=r,r")
1171 (zero_extend:DI (match_operand:HI 1 "gr_nonimmediate_operand" "r,m")))]
c65ebc55
JW
1172 ""
1173 "@
1174 zxt2 %0 = %1
1175 ld2%O1 %0 = %1%P1"
388092d5
AB
1176 [(set_attr "itanium_class" "xtd,ld")
1177 (set_attr "speculable1" "yes")
1178 (set_attr "speculable2" "no, yes")])
c65ebc55
JW
1179
1180(define_insn "zero_extendsidi2"
655f2eb9 1181 [(set (match_operand:DI 0 "grfr_register_operand" "=r,r,?f")
0551c32d 1182 (zero_extend:DI
655f2eb9 1183 (match_operand:SI 1 "grfr_nonimmediate_operand" "r,m,f")))]
c65ebc55
JW
1184 ""
1185 "@
d3f6e07b 1186 addp4 %0 = %1, r0
c65ebc55 1187 ld4%O1 %0 = %1%P1
aebf2462 1188 fmix.r %0 = f0, %1"
388092d5
AB
1189 [(set_attr "itanium_class" "ialu,ld,fmisc")
1190 (set_attr "speculable1" "yes")
1191 (set_attr "speculable2" "no, yes,no")])
c65ebc55
JW
1192
1193;; Convert between floating point types of different sizes.
1194
640cea5f
JW
1195;; At first glance, it would appear that emitting fnorm for an extending
1196;; conversion is unnecessary. However, the stf and getf instructions work
1197;; correctly only if the input is properly rounded for its type. In
1198;; particular, we get the wrong result for getf.d/stfd if the input is a
1199;; denorm single. Since we don't know what the next instruction will be, we
1200;; have to emit an fnorm.
1201
e8e20f18
RH
1202;; ??? Optimization opportunity here. Get rid of the insn altogether
1203;; when we can. Should probably use a scheme like has been proposed
1204;; for ia32 in dealing with operands that match unary operators. This
640cea5f
JW
1205;; would let combine merge the thing into adjacent insns. See also how the
1206;; mips port handles SIGN_EXTEND as operands to integer arithmetic insns via
1207;; se_register_operand.
c65ebc55 1208
640cea5f
JW
1209(define_insn "extendsfdf2"
1210 [(set (match_operand:DF 0 "fr_register_operand" "=f")
6adb807e 1211 (float_extend:DF (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")))]
c65ebc55 1212 ""
6adb807e 1213 "fnorm.d %0 = %F1"
640cea5f 1214 [(set_attr "itanium_class" "fmac")])
c65ebc55 1215
02befdf4
ZW
1216(define_insn "extendsfxf2"
1217 [(set (match_operand:XF 0 "fr_register_operand" "=f")
6adb807e 1218 (float_extend:XF (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")))]
02befdf4 1219 ""
6adb807e 1220 "fnorm %0 = %F1"
640cea5f 1221 [(set_attr "itanium_class" "fmac")])
3f622353 1222
02befdf4
ZW
1223(define_insn "extenddfxf2"
1224 [(set (match_operand:XF 0 "fr_register_operand" "=f")
6adb807e 1225 (float_extend:XF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")))]
02befdf4 1226 ""
6adb807e 1227 "fnorm %0 = %F1"
640cea5f 1228 [(set_attr "itanium_class" "fmac")])
3f622353 1229
c65ebc55 1230(define_insn "truncdfsf2"
0551c32d 1231 [(set (match_operand:SF 0 "fr_register_operand" "=f")
6adb807e 1232 (float_truncate:SF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")))]
c65ebc55 1233 ""
6adb807e 1234 "fnorm.s %0 = %F1"
52e12ad0 1235 [(set_attr "itanium_class" "fmac")])
c65ebc55 1236
02befdf4 1237(define_insn "truncxfsf2"
0551c32d 1238 [(set (match_operand:SF 0 "fr_register_operand" "=f")
6adb807e 1239 (float_truncate:SF (match_operand:XF 1 "fr_reg_or_fp01_operand" "fG")))]
02befdf4 1240 ""
6adb807e 1241 "fnorm.s %0 = %F1"
52e12ad0 1242 [(set_attr "itanium_class" "fmac")])
c65ebc55 1243
02befdf4 1244(define_insn "truncxfdf2"
0551c32d 1245 [(set (match_operand:DF 0 "fr_register_operand" "=f")
6adb807e 1246 (float_truncate:DF (match_operand:XF 1 "fr_reg_or_fp01_operand" "fG")))]
02befdf4 1247 ""
6adb807e 1248 "fnorm.d %0 = %F1"
52e12ad0 1249 [(set_attr "itanium_class" "fmac")])
e5bde68a
RH
1250
1251;; Convert between signed integer types and floating point.
1252
49df2fb8
SE
1253(define_insn "floatdirf2"
1254 [(set (match_operand:RF 0 "fr_register_operand" "=f")
1255 (float:RF (match_operand:DI 1 "fr_reg_or_fp01_operand" "fG")))]
1256 ""
1257 "fcvt.xf %0 = %F1"
1258 [(set_attr "itanium_class" "fcvtfx")])
1259
02befdf4
ZW
1260(define_insn "floatdixf2"
1261 [(set (match_operand:XF 0 "fr_register_operand" "=f")
6adb807e 1262 (float:XF (match_operand:DI 1 "fr_reg_or_fp01_operand" "fG")))]
02befdf4 1263 ""
6adb807e 1264 "fcvt.xf %0 = %F1"
52e12ad0 1265 [(set_attr "itanium_class" "fcvtfx")])
c65ebc55
JW
1266
1267(define_insn "fix_truncsfdi2"
0551c32d 1268 [(set (match_operand:DI 0 "fr_register_operand" "=f")
6adb807e 1269 (fix:DI (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")))]
c65ebc55 1270 ""
6adb807e 1271 "fcvt.fx.trunc %0 = %F1"
52e12ad0 1272 [(set_attr "itanium_class" "fcvtfx")])
c65ebc55
JW
1273
1274(define_insn "fix_truncdfdi2"
0551c32d 1275 [(set (match_operand:DI 0 "fr_register_operand" "=f")
6adb807e 1276 (fix:DI (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")))]
c65ebc55 1277 ""
6adb807e 1278 "fcvt.fx.trunc %0 = %F1"
52e12ad0 1279 [(set_attr "itanium_class" "fcvtfx")])
c65ebc55 1280
02befdf4 1281(define_insn "fix_truncxfdi2"
0551c32d 1282 [(set (match_operand:DI 0 "fr_register_operand" "=f")
6adb807e 1283 (fix:DI (match_operand:XF 1 "fr_reg_or_fp01_operand" "fG")))]
02befdf4 1284 ""
6adb807e 1285 "fcvt.fx.trunc %0 = %F1"
52e12ad0 1286 [(set_attr "itanium_class" "fcvtfx")])
3f622353 1287
49df2fb8 1288(define_insn "fix_truncrfdi2"
655f2eb9 1289 [(set (match_operand:DI 0 "fr_register_operand" "=f")
49df2fb8 1290 (fix:DI (match_operand:RF 1 "fr_reg_or_fp01_operand" "fG")))]
02befdf4 1291 ""
49df2fb8 1292 "fcvt.fx.trunc %0 = %F1"
52e12ad0 1293 [(set_attr "itanium_class" "fcvtfx")])
655f2eb9 1294
c65ebc55
JW
1295;; Convert between unsigned integer types and floating point.
1296
1297(define_insn "floatunsdisf2"
0551c32d 1298 [(set (match_operand:SF 0 "fr_register_operand" "=f")
6adb807e 1299 (unsigned_float:SF (match_operand:DI 1 "fr_reg_or_fp01_operand" "fG")))]
c65ebc55 1300 ""
6adb807e 1301 "fcvt.xuf.s %0 = %F1"
52e12ad0 1302 [(set_attr "itanium_class" "fcvtfx")])
c65ebc55
JW
1303
1304(define_insn "floatunsdidf2"
0551c32d 1305 [(set (match_operand:DF 0 "fr_register_operand" "=f")
6adb807e 1306 (unsigned_float:DF (match_operand:DI 1 "fr_reg_or_fp01_operand" "fG")))]
c65ebc55 1307 ""
6adb807e 1308 "fcvt.xuf.d %0 = %F1"
52e12ad0 1309 [(set_attr "itanium_class" "fcvtfx")])
c65ebc55 1310
02befdf4
ZW
1311(define_insn "floatunsdixf2"
1312 [(set (match_operand:XF 0 "fr_register_operand" "=f")
6adb807e 1313 (unsigned_float:XF (match_operand:DI 1 "fr_reg_or_fp01_operand" "fG")))]
02befdf4 1314 ""
6adb807e 1315 "fcvt.xuf %0 = %F1"
52e12ad0 1316 [(set_attr "itanium_class" "fcvtfx")])
3f622353 1317
49df2fb8
SE
1318(define_insn "floatunsdirf2"
1319 [(set (match_operand:RF 0 "fr_register_operand" "=f")
1320 (unsigned_float:RF (match_operand:DI 1 "fr_reg_or_fp01_operand" "fG")))]
1321 ""
1322 "fcvt.xuf %0 = %F1"
1323 [(set_attr "itanium_class" "fcvtfx")])
1324
c65ebc55 1325(define_insn "fixuns_truncsfdi2"
0551c32d 1326 [(set (match_operand:DI 0 "fr_register_operand" "=f")
6adb807e 1327 (unsigned_fix:DI (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")))]
c65ebc55 1328 ""
6adb807e 1329 "fcvt.fxu.trunc %0 = %F1"
52e12ad0 1330 [(set_attr "itanium_class" "fcvtfx")])
c65ebc55
JW
1331
1332(define_insn "fixuns_truncdfdi2"
0551c32d 1333 [(set (match_operand:DI 0 "fr_register_operand" "=f")
6adb807e 1334 (unsigned_fix:DI (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")))]
c65ebc55 1335 ""
6adb807e 1336 "fcvt.fxu.trunc %0 = %F1"
52e12ad0 1337 [(set_attr "itanium_class" "fcvtfx")])
c65ebc55 1338
02befdf4 1339(define_insn "fixuns_truncxfdi2"
0551c32d 1340 [(set (match_operand:DI 0 "fr_register_operand" "=f")
6adb807e 1341 (unsigned_fix:DI (match_operand:XF 1 "fr_reg_or_fp01_operand" "fG")))]
02befdf4 1342 ""
6adb807e 1343 "fcvt.fxu.trunc %0 = %F1"
52e12ad0 1344 [(set_attr "itanium_class" "fcvtfx")])
655f2eb9 1345
49df2fb8 1346(define_insn "fixuns_truncrfdi2"
655f2eb9 1347 [(set (match_operand:DI 0 "fr_register_operand" "=f")
49df2fb8 1348 (unsigned_fix:DI (match_operand:RF 1 "fr_reg_or_fp01_operand" "fG")))]
02befdf4 1349 ""
49df2fb8 1350 "fcvt.fxu.trunc %0 = %F1"
52e12ad0 1351 [(set_attr "itanium_class" "fcvtfx")])
c65ebc55
JW
1352\f
1353;; ::::::::::::::::::::
1354;; ::
1355;; :: Bit field extraction
1356;; ::
1357;; ::::::::::::::::::::
1358
c65ebc55 1359(define_insn "extv"
0551c32d
RH
1360 [(set (match_operand:DI 0 "gr_register_operand" "=r")
1361 (sign_extract:DI (match_operand:DI 1 "gr_register_operand" "r")
5d48891e
SE
1362 (match_operand:DI 2 "extr_len_operand" "n")
1363 (match_operand:DI 3 "shift_count_operand" "M")))]
c65ebc55
JW
1364 ""
1365 "extr %0 = %1, %3, %2"
52e12ad0 1366 [(set_attr "itanium_class" "ishf")])
c65ebc55
JW
1367
1368(define_insn "extzv"
0551c32d
RH
1369 [(set (match_operand:DI 0 "gr_register_operand" "=r")
1370 (zero_extract:DI (match_operand:DI 1 "gr_register_operand" "r")
5d48891e
SE
1371 (match_operand:DI 2 "extr_len_operand" "n")
1372 (match_operand:DI 3 "shift_count_operand" "M")))]
c65ebc55
JW
1373 ""
1374 "extr.u %0 = %1, %3, %2"
52e12ad0 1375 [(set_attr "itanium_class" "ishf")])
c65ebc55
JW
1376
1377;; Insert a bit field.
1378;; Can have 3 operands, source1 (inserter), source2 (insertee), dest.
1379;; Source1 can be 0 or -1.
1380;; Source2 can be 0.
1381
1382;; ??? Actual dep instruction is more powerful than what these insv
1383;; patterns support. Unfortunately, combine is unable to create patterns
1384;; where source2 != dest.
1385
1386(define_expand "insv"
0551c32d 1387 [(set (zero_extract:DI (match_operand:DI 0 "gr_register_operand" "")
c65ebc55
JW
1388 (match_operand:DI 1 "const_int_operand" "")
1389 (match_operand:DI 2 "const_int_operand" ""))
1390 (match_operand:DI 3 "nonmemory_operand" ""))]
1391 ""
c65ebc55
JW
1392{
1393 int width = INTVAL (operands[1]);
1394 int shift = INTVAL (operands[2]);
1395
1396 /* If operand[3] is a constant, and isn't 0 or -1, then load it into a
1397 pseudo. */
1398 if (! register_operand (operands[3], DImode)
1399 && operands[3] != const0_rtx && operands[3] != constm1_rtx)
1400 operands[3] = force_reg (DImode, operands[3]);
1401
1402 /* If this is a single dep instruction, we have nothing to do. */
1403 if (! ((register_operand (operands[3], DImode) && width <= 16)
1404 || operands[3] == const0_rtx || operands[3] == constm1_rtx))
1405 {
1406 /* Check for cases that can be implemented with a mix instruction. */
1407 if (width == 32 && shift == 0)
1408 {
1409 /* Directly generating the mix4left instruction confuses
1410 optimize_bit_field in function.c. Since this is performing
1411 a useful optimization, we defer generation of the complicated
1412 mix4left RTL to the first splitting phase. */
1413 rtx tmp = gen_reg_rtx (DImode);
1414 emit_insn (gen_shift_mix4left (operands[0], operands[3], tmp));
1415 DONE;
1416 }
1417 else if (width == 32 && shift == 32)
1418 {
1419 emit_insn (gen_mix4right (operands[0], operands[3]));
1420 DONE;
1421 }
1422
d2ba6dcf
JW
1423 /* We could handle remaining cases by emitting multiple dep
1424 instructions.
1425
1426 If we need more than two dep instructions then we lose. A 6
1427 insn sequence mov mask1,mov mask2,shl;;and,and;;or is better than
1428 mov;;dep,shr;;dep,shr;;dep. The former can be executed in 3 cycles,
1429 the latter is 6 cycles on an Itanium (TM) processor, because there is
1430 only one function unit that can execute dep and shr immed.
1431
1432 If we only need two dep instruction, then we still lose.
1433 mov;;dep,shr;;dep is still 4 cycles. Even if we optimize away
1434 the unnecessary mov, this is still undesirable because it will be
1435 hard to optimize, and it creates unnecessary pressure on the I0
1436 function unit. */
1437
c65ebc55
JW
1438 FAIL;
1439
1440#if 0
1441 /* This code may be useful for other IA-64 processors, so we leave it in
1442 for now. */
1443 while (width > 16)
1444 {
1445 rtx tmp;
1446
1447 emit_insn (gen_insv (operands[0], GEN_INT (16), GEN_INT (shift),
1448 operands[3]));
1449 shift += 16;
1450 width -= 16;
1451 tmp = gen_reg_rtx (DImode);
1452 emit_insn (gen_lshrdi3 (tmp, operands[3], GEN_INT (16)));
1453 operands[3] = tmp;
1454 }
1455 operands[1] = GEN_INT (width);
1456 operands[2] = GEN_INT (shift);
1457#endif
1458 }
1d5d7a21 1459})
c65ebc55
JW
1460
1461(define_insn "*insv_internal"
0551c32d 1462 [(set (zero_extract:DI (match_operand:DI 0 "gr_register_operand" "+r")
c65ebc55
JW
1463 (match_operand:DI 1 "const_int_operand" "n")
1464 (match_operand:DI 2 "const_int_operand" "n"))
1465 (match_operand:DI 3 "nonmemory_operand" "rP"))]
0551c32d 1466 "(gr_register_operand (operands[3], DImode) && INTVAL (operands[1]) <= 16)
c65ebc55
JW
1467 || operands[3] == const0_rtx || operands[3] == constm1_rtx"
1468 "dep %0 = %3, %0, %2, %1"
52e12ad0 1469 [(set_attr "itanium_class" "ishf")])
c65ebc55 1470
43a88a8c 1471;; Combine doesn't like to create bit-field insertions into zero.
d3f6e07b
JB
1472(define_insn "*shladdp4_internal"
1473 [(set (match_operand:DI 0 "gr_register_operand" "=r")
1474 (and:DI (ashift:DI (match_operand:DI 1 "gr_register_operand" "r")
1475 (match_operand:DI 2 "shladd_log2_operand" "n"))
1476 (match_operand:DI 3 "const_int_operand" "n")))]
1477 "ia64_depz_field_mask (operands[3], operands[2]) + INTVAL (operands[2]) == 32"
1478 "shladdp4 %0 = %1, %2, r0"
1479 [(set_attr "itanium_class" "ialu")])
1480
041f25e6 1481(define_insn "*depz_internal"
0551c32d
RH
1482 [(set (match_operand:DI 0 "gr_register_operand" "=r")
1483 (and:DI (ashift:DI (match_operand:DI 1 "gr_register_operand" "r")
13f70342 1484 (match_operand:DI 2 "const_int_operand" "M"))
041f25e6 1485 (match_operand:DI 3 "const_int_operand" "n")))]
13f70342 1486 "satisfies_constraint_M (operands[2])
041f25e6 1487 && ia64_depz_field_mask (operands[3], operands[2]) > 0"
041f25e6
RH
1488{
1489 operands[3] = GEN_INT (ia64_depz_field_mask (operands[3], operands[2]));
1d5d7a21
RH
1490 return "%,dep.z %0 = %1, %2, %3";
1491}
52e12ad0 1492 [(set_attr "itanium_class" "ishf")])
041f25e6 1493
c65ebc55 1494(define_insn "shift_mix4left"
0551c32d 1495 [(set (zero_extract:DI (match_operand:DI 0 "gr_register_operand" "+r")
c65ebc55 1496 (const_int 32) (const_int 0))
0551c32d
RH
1497 (match_operand:DI 1 "gr_register_operand" "r"))
1498 (clobber (match_operand:DI 2 "gr_register_operand" "=r"))]
c65ebc55
JW
1499 ""
1500 "#"
52e12ad0 1501 [(set_attr "itanium_class" "unknown")])
c65ebc55 1502
c65ebc55
JW
1503(define_split
1504 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "")
1505 (const_int 32) (const_int 0))
1506 (match_operand:DI 1 "register_operand" ""))
1507 (clobber (match_operand:DI 2 "register_operand" ""))]
06a419ff 1508 ""
c65ebc55
JW
1509 [(set (match_dup 3) (ashift:DI (match_dup 1) (const_int 32)))
1510 (set (zero_extract:DI (match_dup 0) (const_int 32) (const_int 0))
1511 (lshiftrt:DI (match_dup 3) (const_int 32)))]
1512 "operands[3] = operands[2];")
1513
1514(define_insn "*mix4left"
0551c32d 1515 [(set (zero_extract:DI (match_operand:DI 0 "gr_register_operand" "+r")
c65ebc55 1516 (const_int 32) (const_int 0))
0551c32d 1517 (lshiftrt:DI (match_operand:DI 1 "gr_register_operand" "r")
c65ebc55
JW
1518 (const_int 32)))]
1519 ""
1520 "mix4.l %0 = %0, %r1"
52e12ad0 1521 [(set_attr "itanium_class" "mmshf")])
c65ebc55
JW
1522
1523(define_insn "mix4right"
0551c32d 1524 [(set (zero_extract:DI (match_operand:DI 0 "gr_register_operand" "+r")
c65ebc55 1525 (const_int 32) (const_int 32))
0551c32d 1526 (match_operand:DI 1 "gr_reg_or_0_operand" "rO"))]
c65ebc55
JW
1527 ""
1528 "mix4.r %0 = %r1, %0"
52e12ad0 1529 [(set_attr "itanium_class" "mmshf")])
c65ebc55
JW
1530
1531;; This is used by the rotrsi3 pattern.
1532
1533(define_insn "*mix4right_3op"
0551c32d
RH
1534 [(set (match_operand:DI 0 "gr_register_operand" "=r")
1535 (ior:DI (zero_extend:DI (match_operand:SI 1 "gr_register_operand" "r"))
1536 (ashift:DI (zero_extend:DI
1537 (match_operand:SI 2 "gr_register_operand" "r"))
c65ebc55
JW
1538 (const_int 32))))]
1539 ""
fa9a44e8 1540 "mix4.r %0 = %2, %1"
52e12ad0 1541 [(set_attr "itanium_class" "mmshf")])
c65ebc55
JW
1542
1543\f
1544;; ::::::::::::::::::::
cf1f6ae3 1545;; ::
27a9b99d 1546;; :: 1-bit Integer arithmetic
f2f90c63
RH
1547;; ::
1548;; ::::::::::::::::::::
1549
1550(define_insn_and_split "andbi3"
1551 [(set (match_operand:BI 0 "register_operand" "=c,c,r")
1552 (and:BI (match_operand:BI 1 "register_operand" "%0,0,r")
1553 (match_operand:BI 2 "register_operand" "c,r,r")))]
1554 ""
1555 "@
1556 #
1557 tbit.nz.and.orcm %0, %I0 = %2, 0
1558 and %0 = %2, %1"
1559 "reload_completed
1560 && GET_CODE (operands[0]) == REG && PR_REGNO_P (REGNO (operands[0]))
1561 && GET_CODE (operands[2]) == REG && PR_REGNO_P (REGNO (operands[2]))"
1562 [(cond_exec (eq (match_dup 2) (const_int 0))
1563 (set (match_dup 0) (and:BI (ne:BI (const_int 0) (const_int 0))
1564 (match_dup 0))))]
1565 ""
52e12ad0 1566 [(set_attr "itanium_class" "unknown,tbit,ilog")])
f2f90c63
RH
1567
1568(define_insn_and_split "*andcmbi3"
1569 [(set (match_operand:BI 0 "register_operand" "=c,c,r")
1570 (and:BI (not:BI (match_operand:BI 1 "register_operand" "c,r,r"))
1571 (match_operand:BI 2 "register_operand" "0,0,r")))]
1572 ""
1573 "@
1574 #
967603ef 1575 tbit.z.and.orcm %0, %I0 = %1, 0
f2f90c63
RH
1576 andcm %0 = %2, %1"
1577 "reload_completed
1578 && GET_CODE (operands[0]) == REG && PR_REGNO_P (REGNO (operands[0]))
967603ef 1579 && GET_CODE (operands[1]) == REG && PR_REGNO_P (REGNO (operands[1]))"
f2f90c63
RH
1580 [(cond_exec (ne (match_dup 1) (const_int 0))
1581 (set (match_dup 0) (and:BI (ne:BI (const_int 0) (const_int 0))
1582 (match_dup 0))))]
1583 ""
52e12ad0 1584 [(set_attr "itanium_class" "unknown,tbit,ilog")])
f2f90c63
RH
1585
1586(define_insn_and_split "iorbi3"
1587 [(set (match_operand:BI 0 "register_operand" "=c,c,r")
1588 (ior:BI (match_operand:BI 1 "register_operand" "%0,0,r")
1589 (match_operand:BI 2 "register_operand" "c,r,r")))]
1590 ""
1591 "@
1592 #
1593 tbit.nz.or.andcm %0, %I0 = %2, 0
1594 or %0 = %2, %1"
1595 "reload_completed
1596 && GET_CODE (operands[0]) == REG && PR_REGNO_P (REGNO (operands[0]))
1597 && GET_CODE (operands[2]) == REG && PR_REGNO_P (REGNO (operands[2]))"
1598 [(cond_exec (ne (match_dup 2) (const_int 0))
1599 (set (match_dup 0) (ior:BI (eq:BI (const_int 0) (const_int 0))
1600 (match_dup 0))))]
1601 ""
52e12ad0 1602 [(set_attr "itanium_class" "unknown,tbit,ilog")])
f2f90c63
RH
1603
1604(define_insn_and_split "*iorcmbi3"
1605 [(set (match_operand:BI 0 "register_operand" "=c,c")
1606 (ior:BI (not:BI (match_operand:BI 1 "register_operand" "c,r"))
1607 (match_operand:BI 2 "register_operand" "0,0")))]
1608 ""
1609 "@
1610 #
967603ef 1611 tbit.z.or.andcm %0, %I0 = %1, 0"
f2f90c63
RH
1612 "reload_completed
1613 && GET_CODE (operands[0]) == REG && PR_REGNO_P (REGNO (operands[0]))
967603ef 1614 && GET_CODE (operands[1]) == REG && PR_REGNO_P (REGNO (operands[1]))"
f2f90c63
RH
1615 [(cond_exec (eq (match_dup 1) (const_int 0))
1616 (set (match_dup 0) (ior:BI (eq:BI (const_int 0) (const_int 0))
1617 (match_dup 0))))]
1618 ""
52e12ad0 1619 [(set_attr "itanium_class" "unknown,tbit")])
f2f90c63
RH
1620
1621(define_insn "one_cmplbi2"
1622 [(set (match_operand:BI 0 "register_operand" "=c,r,c,&c")
1623 (not:BI (match_operand:BI 1 "register_operand" "r,r,0,c")))
1624 (clobber (match_scratch:BI 2 "=X,X,c,X"))]
1625 ""
1626 "@
1627 tbit.z %0, %I0 = %1, 0
1628 xor %0 = 1, %1
1629 #
1630 #"
52e12ad0 1631 [(set_attr "itanium_class" "tbit,ilog,unknown,unknown")])
f2f90c63
RH
1632
1633(define_split
1634 [(set (match_operand:BI 0 "register_operand" "")
1635 (not:BI (match_operand:BI 1 "register_operand" "")))
1636 (clobber (match_scratch:BI 2 ""))]
1637 "reload_completed
1638 && GET_CODE (operands[0]) == REG && PR_REGNO_P (REGNO (operands[0]))
f2f90c63
RH
1639 && rtx_equal_p (operands[0], operands[1])"
1640 [(set (match_dup 4) (match_dup 3))
1641 (set (match_dup 0) (const_int 1))
1642 (cond_exec (ne (match_dup 2) (const_int 0))
1643 (set (match_dup 0) (const_int 0)))
086c0f96 1644 (set (match_dup 0) (unspec:BI [(match_dup 0)] UNSPEC_PRED_REL_MUTEX))]
f2f90c63
RH
1645 "operands[3] = gen_rtx_REG (CCImode, REGNO (operands[1]));
1646 operands[4] = gen_rtx_REG (CCImode, REGNO (operands[2]));")
1647
1648(define_split
1649 [(set (match_operand:BI 0 "register_operand" "")
1650 (not:BI (match_operand:BI 1 "register_operand" "")))
1651 (clobber (match_scratch:BI 2 ""))]
1652 "reload_completed
1653 && GET_CODE (operands[0]) == REG && PR_REGNO_P (REGNO (operands[0]))
1654 && GET_CODE (operands[1]) == REG && PR_REGNO_P (REGNO (operands[1]))
1655 && ! rtx_equal_p (operands[0], operands[1])"
1656 [(cond_exec (ne (match_dup 1) (const_int 0))
1657 (set (match_dup 0) (const_int 0)))
1658 (cond_exec (eq (match_dup 1) (const_int 0))
1659 (set (match_dup 0) (const_int 1)))
086c0f96 1660 (set (match_dup 0) (unspec:BI [(match_dup 0)] UNSPEC_PRED_REL_MUTEX))]
f2f90c63
RH
1661 "")
1662
1663(define_insn "*cmpsi_and_0"
1664 [(set (match_operand:BI 0 "register_operand" "=c")
1665 (and:BI (match_operator:BI 4 "predicate_operator"
1666 [(match_operand:SI 2 "gr_reg_or_0_operand" "rO")
1667 (match_operand:SI 3 "gr_reg_or_8bit_operand" "rK")])
1668 (match_operand:BI 1 "register_operand" "0")))]
1669 ""
1670 "cmp4.%C4.and.orcm %0, %I0 = %3, %r2"
52e12ad0 1671 [(set_attr "itanium_class" "icmp")])
f2f90c63
RH
1672
1673(define_insn "*cmpsi_and_1"
1674 [(set (match_operand:BI 0 "register_operand" "=c")
1675 (and:BI (match_operator:BI 3 "signed_inequality_operator"
1676 [(match_operand:SI 2 "gr_register_operand" "r")
1677 (const_int 0)])
1678 (match_operand:BI 1 "register_operand" "0")))]
1679 ""
1680 "cmp4.%C3.and.orcm %0, %I0 = r0, %2"
52e12ad0 1681 [(set_attr "itanium_class" "icmp")])
f2f90c63
RH
1682
1683(define_insn "*cmpsi_andnot_0"
1684 [(set (match_operand:BI 0 "register_operand" "=c")
1685 (and:BI (not:BI (match_operator:BI 4 "predicate_operator"
1686 [(match_operand:SI 2 "gr_reg_or_0_operand" "rO")
1687 (match_operand:SI 3 "gr_reg_or_8bit_operand" "rK")]))
1688 (match_operand:BI 1 "register_operand" "0")))]
1689 ""
1690 "cmp4.%C4.or.andcm %I0, %0 = %3, %r2"
52e12ad0 1691 [(set_attr "itanium_class" "icmp")])
f2f90c63
RH
1692
1693(define_insn "*cmpsi_andnot_1"
1694 [(set (match_operand:BI 0 "register_operand" "=c")
1695 (and:BI (not:BI (match_operator:BI 3 "signed_inequality_operator"
1696 [(match_operand:SI 2 "gr_register_operand" "r")
1697 (const_int 0)]))
1698 (match_operand:BI 1 "register_operand" "0")))]
1699 ""
1700 "cmp4.%C3.or.andcm %I0, %0 = r0, %2"
52e12ad0 1701 [(set_attr "itanium_class" "icmp")])
f2f90c63
RH
1702
1703(define_insn "*cmpdi_and_0"
1704 [(set (match_operand:BI 0 "register_operand" "=c")
1705 (and:BI (match_operator:BI 4 "predicate_operator"
1706 [(match_operand:DI 2 "gr_register_operand" "r")
1707 (match_operand:DI 3 "gr_reg_or_8bit_operand" "rK")])
1708 (match_operand:BI 1 "register_operand" "0")))]
1709 ""
1710 "cmp.%C4.and.orcm %0, %I0 = %3, %2"
52e12ad0 1711 [(set_attr "itanium_class" "icmp")])
f2f90c63
RH
1712
1713(define_insn "*cmpdi_and_1"
1714 [(set (match_operand:BI 0 "register_operand" "=c")
1715 (and:BI (match_operator:BI 3 "signed_inequality_operator"
1716 [(match_operand:DI 2 "gr_register_operand" "r")
1717 (const_int 0)])
1718 (match_operand:BI 1 "register_operand" "0")))]
1719 ""
1720 "cmp.%C3.and.orcm %0, %I0 = r0, %2"
52e12ad0 1721 [(set_attr "itanium_class" "icmp")])
f2f90c63
RH
1722
1723(define_insn "*cmpdi_andnot_0"
1724 [(set (match_operand:BI 0 "register_operand" "=c")
1725 (and:BI (not:BI (match_operator:BI 4 "predicate_operator"
1726 [(match_operand:DI 2 "gr_register_operand" "r")
1727 (match_operand:DI 3 "gr_reg_or_8bit_operand" "rK")]))
1728 (match_operand:BI 1 "register_operand" "0")))]
1729 ""
1730 "cmp.%C4.or.andcm %I0, %0 = %3, %2"
52e12ad0 1731 [(set_attr "itanium_class" "icmp")])
f2f90c63
RH
1732
1733(define_insn "*cmpdi_andnot_1"
1734 [(set (match_operand:BI 0 "register_operand" "=c")
1735 (and:BI (not:BI (match_operator:BI 3 "signed_inequality_operator"
1736 [(match_operand:DI 2 "gr_register_operand" "r")
1737 (const_int 0)]))
1738 (match_operand:BI 1 "register_operand" "0")))]
1739 ""
1740 "cmp.%C3.or.andcm %I0, %0 = r0, %2"
52e12ad0 1741 [(set_attr "itanium_class" "icmp")])
f2f90c63
RH
1742
1743(define_insn "*tbit_and_0"
1744 [(set (match_operand:BI 0 "register_operand" "=c")
1745 (and:BI (ne:BI (and:DI (match_operand:DI 1 "gr_register_operand" "r")
1746 (const_int 1))
1747 (const_int 0))
c77e04ae 1748 (match_operand:BI 2 "register_operand" "0")))]
f2f90c63
RH
1749 ""
1750 "tbit.nz.and.orcm %0, %I0 = %1, 0"
52e12ad0 1751 [(set_attr "itanium_class" "tbit")])
f2f90c63
RH
1752
1753(define_insn "*tbit_and_1"
1754 [(set (match_operand:BI 0 "register_operand" "=c")
1755 (and:BI (eq:BI (and:DI (match_operand:DI 1 "gr_register_operand" "r")
1756 (const_int 1))
1757 (const_int 0))
c77e04ae 1758 (match_operand:BI 2 "register_operand" "0")))]
f2f90c63
RH
1759 ""
1760 "tbit.z.and.orcm %0, %I0 = %1, 0"
52e12ad0 1761 [(set_attr "itanium_class" "tbit")])
f2f90c63
RH
1762
1763(define_insn "*tbit_and_2"
1764 [(set (match_operand:BI 0 "register_operand" "=c")
1765 (and:BI (ne:BI (zero_extract:DI
1766 (match_operand:DI 1 "gr_register_operand" "r")
1767 (const_int 1)
5d48891e 1768 (match_operand:DI 2 "shift_count_operand" "M"))
f2f90c63
RH
1769 (const_int 0))
1770 (match_operand:BI 3 "register_operand" "0")))]
1771 ""
1772 "tbit.nz.and.orcm %0, %I0 = %1, %2"
52e12ad0 1773 [(set_attr "itanium_class" "tbit")])
f2f90c63
RH
1774
1775(define_insn "*tbit_and_3"
1776 [(set (match_operand:BI 0 "register_operand" "=c")
1777 (and:BI (eq:BI (zero_extract:DI
1778 (match_operand:DI 1 "gr_register_operand" "r")
1779 (const_int 1)
5d48891e 1780 (match_operand:DI 2 "shift_count_operand" "M"))
f2f90c63
RH
1781 (const_int 0))
1782 (match_operand:BI 3 "register_operand" "0")))]
1783 ""
1784 "tbit.z.and.orcm %0, %I0 = %1, %2"
52e12ad0 1785 [(set_attr "itanium_class" "tbit")])
f2f90c63
RH
1786
1787(define_insn "*cmpsi_or_0"
1788 [(set (match_operand:BI 0 "register_operand" "=c")
1789 (ior:BI (match_operator:BI 4 "predicate_operator"
1790 [(match_operand:SI 2 "gr_reg_or_0_operand" "rO")
1791 (match_operand:SI 3 "gr_reg_or_8bit_operand" "rK")])
1792 (match_operand:BI 1 "register_operand" "0")))]
1793 ""
1794 "cmp4.%C4.or.andcm %0, %I0 = %3, %r2"
52e12ad0 1795 [(set_attr "itanium_class" "icmp")])
f2f90c63
RH
1796
1797(define_insn "*cmpsi_or_1"
1798 [(set (match_operand:BI 0 "register_operand" "=c")
1799 (ior:BI (match_operator:BI 3 "signed_inequality_operator"
1800 [(match_operand:SI 2 "gr_register_operand" "r")
1801 (const_int 0)])
1802 (match_operand:BI 1 "register_operand" "0")))]
1803 ""
1804 "cmp4.%C3.or.andcm %0, %I0 = r0, %2"
52e12ad0 1805 [(set_attr "itanium_class" "icmp")])
f2f90c63
RH
1806
1807(define_insn "*cmpsi_orcm_0"
1808 [(set (match_operand:BI 0 "register_operand" "=c")
1809 (ior:BI (not:BI (match_operator:BI 4 "predicate_operator"
1810 [(match_operand:SI 2 "gr_reg_or_0_operand" "rO")
1811 (match_operand:SI 3 "gr_reg_or_8bit_operand" "rK")]))
1812 (match_operand:BI 1 "register_operand" "0")))]
1813 ""
1814 "cmp4.%C4.and.orcm %I0, %0 = %3, %r2"
52e12ad0 1815 [(set_attr "itanium_class" "icmp")])
f2f90c63
RH
1816
1817(define_insn "*cmpsi_orcm_1"
1818 [(set (match_operand:BI 0 "register_operand" "=c")
1819 (ior:BI (not:BI (match_operator:BI 3 "signed_inequality_operator"
1820 [(match_operand:SI 2 "gr_register_operand" "r")
1821 (const_int 0)]))
1822 (match_operand:BI 1 "register_operand" "0")))]
1823 ""
1824 "cmp4.%C3.and.orcm %I0, %0 = r0, %2"
52e12ad0 1825 [(set_attr "itanium_class" "icmp")])
f2f90c63
RH
1826
1827(define_insn "*cmpdi_or_0"
1828 [(set (match_operand:BI 0 "register_operand" "=c")
1829 (ior:BI (match_operator:BI 4 "predicate_operator"
1830 [(match_operand:DI 2 "gr_register_operand" "r")
1831 (match_operand:DI 3 "gr_reg_or_8bit_operand" "rK")])
1832 (match_operand:BI 1 "register_operand" "0")))]
1833 ""
1834 "cmp.%C4.or.andcm %0, %I0 = %3, %2"
52e12ad0 1835 [(set_attr "itanium_class" "icmp")])
f2f90c63
RH
1836
1837(define_insn "*cmpdi_or_1"
1838 [(set (match_operand:BI 0 "register_operand" "=c")
1839 (ior:BI (match_operator:BI 3 "signed_inequality_operator"
1840 [(match_operand:DI 2 "gr_register_operand" "r")
1841 (const_int 0)])
1842 (match_operand:BI 1 "register_operand" "0")))]
1843 ""
1844 "cmp.%C3.or.andcm %0, %I0 = r0, %2"
52e12ad0 1845 [(set_attr "itanium_class" "icmp")])
f2f90c63
RH
1846
1847(define_insn "*cmpdi_orcm_0"
1848 [(set (match_operand:BI 0 "register_operand" "=c")
1849 (ior:BI (not:BI (match_operator:BI 4 "predicate_operator"
1850 [(match_operand:DI 2 "gr_register_operand" "r")
1851 (match_operand:DI 3 "gr_reg_or_8bit_operand" "rK")]))
1852 (match_operand:BI 1 "register_operand" "0")))]
1853 ""
1854 "cmp.%C4.and.orcm %I0, %0 = %3, %2"
52e12ad0 1855 [(set_attr "itanium_class" "icmp")])
f2f90c63
RH
1856
1857(define_insn "*cmpdi_orcm_1"
1858 [(set (match_operand:BI 0 "register_operand" "=c")
1859 (ior:BI (not:BI (match_operator:BI 3 "signed_inequality_operator"
1860 [(match_operand:DI 2 "gr_register_operand" "r")
1861 (const_int 0)]))
1862 (match_operand:BI 1 "register_operand" "0")))]
1863 ""
1864 "cmp.%C3.and.orcm %I0, %0 = r0, %2"
52e12ad0 1865 [(set_attr "itanium_class" "icmp")])
f2f90c63
RH
1866
1867(define_insn "*tbit_or_0"
1868 [(set (match_operand:BI 0 "register_operand" "=c")
1869 (ior:BI (ne:BI (and:DI (match_operand:DI 1 "gr_register_operand" "r")
1870 (const_int 1))
1871 (const_int 0))
c77e04ae 1872 (match_operand:BI 2 "register_operand" "0")))]
f2f90c63
RH
1873 ""
1874 "tbit.nz.or.andcm %0, %I0 = %1, 0"
52e12ad0 1875 [(set_attr "itanium_class" "tbit")])
f2f90c63
RH
1876
1877(define_insn "*tbit_or_1"
1878 [(set (match_operand:BI 0 "register_operand" "=c")
1879 (ior:BI (eq:BI (and:DI (match_operand:DI 1 "gr_register_operand" "r")
1880 (const_int 1))
1881 (const_int 0))
c77e04ae 1882 (match_operand:BI 2 "register_operand" "0")))]
f2f90c63
RH
1883 ""
1884 "tbit.z.or.andcm %0, %I0 = %1, 0"
52e12ad0 1885 [(set_attr "itanium_class" "tbit")])
f2f90c63
RH
1886
1887(define_insn "*tbit_or_2"
1888 [(set (match_operand:BI 0 "register_operand" "=c")
1889 (ior:BI (ne:BI (zero_extract:DI
1890 (match_operand:DI 1 "gr_register_operand" "r")
1891 (const_int 1)
5d48891e 1892 (match_operand:DI 2 "shift_count_operand" "M"))
f2f90c63
RH
1893 (const_int 0))
1894 (match_operand:BI 3 "register_operand" "0")))]
1895 ""
1896 "tbit.nz.or.andcm %0, %I0 = %1, %2"
52e12ad0 1897 [(set_attr "itanium_class" "tbit")])
f2f90c63
RH
1898
1899(define_insn "*tbit_or_3"
1900 [(set (match_operand:BI 0 "register_operand" "=c")
1901 (ior:BI (eq:BI (zero_extract:DI
1902 (match_operand:DI 1 "gr_register_operand" "r")
1903 (const_int 1)
5d48891e 1904 (match_operand:DI 2 "shift_count_operand" "M"))
f2f90c63
RH
1905 (const_int 0))
1906 (match_operand:BI 3 "register_operand" "0")))]
1907 ""
1908 "tbit.z.or.andcm %0, %I0 = %1, %2"
52e12ad0 1909 [(set_attr "itanium_class" "tbit")])
f2f90c63
RH
1910
1911;; Transform test of and/or of setcc into parallel comparisons.
1912
1913(define_split
1914 [(set (match_operand:BI 0 "register_operand" "")
1915 (ne:BI (and:DI (ne:DI (match_operand:BI 2 "register_operand" "")
1916 (const_int 0))
1917 (match_operand:DI 3 "register_operand" ""))
1918 (const_int 0)))]
1919 ""
1920 [(set (match_dup 0)
1921 (and:BI (ne:BI (and:DI (match_dup 3) (const_int 1)) (const_int 0))
1922 (match_dup 2)))]
1923 "")
1924
1925(define_split
1926 [(set (match_operand:BI 0 "register_operand" "")
1927 (eq:BI (and:DI (ne:DI (match_operand:BI 2 "register_operand" "")
1928 (const_int 0))
1929 (match_operand:DI 3 "register_operand" ""))
1930 (const_int 0)))]
1931 ""
1932 [(set (match_dup 0)
1933 (and:BI (ne:BI (and:DI (match_dup 3) (const_int 1)) (const_int 0))
1934 (match_dup 2)))
1935 (parallel [(set (match_dup 0) (not:BI (match_dup 0)))
1936 (clobber (scratch))])]
1937 "")
1938
1939(define_split
1940 [(set (match_operand:BI 0 "register_operand" "")
1941 (ne:BI (ior:DI (ne:DI (match_operand:BI 2 "register_operand" "")
1942 (const_int 0))
1943 (match_operand:DI 3 "register_operand" ""))
1944 (const_int 0)))]
1945 ""
1946 [(set (match_dup 0)
1947 (ior:BI (ne:BI (match_dup 3) (const_int 0))
1948 (match_dup 2)))]
1949 "")
1950
1951(define_split
1952 [(set (match_operand:BI 0 "register_operand" "")
1953 (eq:BI (ior:DI (ne:DI (match_operand:BI 2 "register_operand" "")
1954 (const_int 0))
1955 (match_operand:DI 3 "register_operand" ""))
1956 (const_int 0)))]
1957 ""
1958 [(set (match_dup 0)
1959 (ior:BI (ne:BI (match_dup 3) (const_int 0))
1960 (match_dup 2)))
1961 (parallel [(set (match_dup 0) (not:BI (match_dup 0)))
1962 (clobber (scratch))])]
1963 "")
1964
1965;; ??? Incredibly hackish. Either need four proper patterns with all
1966;; the alternatives, or rely on sched1 to split the insn and hope that
1967;; nothing bad happens to the comparisons in the meantime.
1968;;
1969;; Alternately, adjust combine to allow 2->2 and 3->3 splits, assuming
1970;; that we're doing height reduction.
1971;
1972;(define_insn_and_split ""
1973; [(set (match_operand:BI 0 "register_operand" "=c")
1974; (and:BI (and:BI (match_operator:BI 1 "comparison_operator"
1975; [(match_operand 2 "" "")
1976; (match_operand 3 "" "")])
1977; (match_operator:BI 4 "comparison_operator"
1978; [(match_operand 5 "" "")
1979; (match_operand 6 "" "")]))
1980; (match_dup 0)))]
1981; "flag_schedule_insns"
1982; "#"
1983; ""
1984; [(set (match_dup 0) (and:BI (match_dup 1) (match_dup 0)))
1985; (set (match_dup 0) (and:BI (match_dup 4) (match_dup 0)))]
1986; "")
1987;
1988;(define_insn_and_split ""
1989; [(set (match_operand:BI 0 "register_operand" "=c")
1990; (ior:BI (ior:BI (match_operator:BI 1 "comparison_operator"
1991; [(match_operand 2 "" "")
1992; (match_operand 3 "" "")])
1993; (match_operator:BI 4 "comparison_operator"
1994; [(match_operand 5 "" "")
1995; (match_operand 6 "" "")]))
1996; (match_dup 0)))]
1997; "flag_schedule_insns"
1998; "#"
1999; ""
2000; [(set (match_dup 0) (ior:BI (match_dup 1) (match_dup 0)))
2001; (set (match_dup 0) (ior:BI (match_dup 4) (match_dup 0)))]
2002; "")
2003;
2004;(define_split
2005; [(set (match_operand:BI 0 "register_operand" "")
2006; (and:BI (and:BI (match_operator:BI 1 "comparison_operator"
2007; [(match_operand 2 "" "")
2008; (match_operand 3 "" "")])
2009; (match_operand:BI 7 "register_operand" ""))
2010; (and:BI (match_operator:BI 4 "comparison_operator"
2011; [(match_operand 5 "" "")
2012; (match_operand 6 "" "")])
2013; (match_operand:BI 8 "register_operand" ""))))]
2014; ""
2015; [(set (match_dup 0) (and:BI (match_dup 7) (match_dup 8)))
2016; (set (match_dup 0) (and:BI (and:BI (match_dup 1) (match_dup 4))
2017; (match_dup 0)))]
2018; "")
2019;
2020;(define_split
2021; [(set (match_operand:BI 0 "register_operand" "")
2022; (ior:BI (ior:BI (match_operator:BI 1 "comparison_operator"
2023; [(match_operand 2 "" "")
2024; (match_operand 3 "" "")])
2025; (match_operand:BI 7 "register_operand" ""))
2026; (ior:BI (match_operator:BI 4 "comparison_operator"
2027; [(match_operand 5 "" "")
2028; (match_operand 6 "" "")])
2029; (match_operand:BI 8 "register_operand" ""))))]
2030; ""
2031; [(set (match_dup 0) (ior:BI (match_dup 7) (match_dup 8)))
2032; (set (match_dup 0) (ior:BI (ior:BI (match_dup 1) (match_dup 4))
2033; (match_dup 0)))]
2034; "")
2035
2036;; Try harder to avoid predicate copies by duplicating compares.
2037;; Note that we'll have already split the predicate copy, which
2038;; is kind of a pain, but oh well.
2039
2040(define_peephole2
2041 [(set (match_operand:BI 0 "register_operand" "")
2042 (match_operand:BI 1 "comparison_operator" ""))
2043 (set (match_operand:CCI 2 "register_operand" "")
2044 (match_operand:CCI 3 "register_operand" ""))
2045 (set (match_operand:CCI 4 "register_operand" "")
2046 (match_operand:CCI 5 "register_operand" ""))
2047 (set (match_operand:BI 6 "register_operand" "")
086c0f96 2048 (unspec:BI [(match_dup 6)] UNSPEC_PRED_REL_MUTEX))]
f2f90c63
RH
2049 "REGNO (operands[3]) == REGNO (operands[0])
2050 && REGNO (operands[4]) == REGNO (operands[0]) + 1
2051 && REGNO (operands[4]) == REGNO (operands[2]) + 1
2052 && REGNO (operands[6]) == REGNO (operands[2])"
2053 [(set (match_dup 0) (match_dup 1))
2054 (set (match_dup 6) (match_dup 7))]
2055 "operands[7] = copy_rtx (operands[1]);")
2056\f
2057;; ::::::::::::::::::::
2058;; ::
27a9b99d 2059;; :: 16-bit Integer arithmetic
cf1f6ae3
RH
2060;; ::
2061;; ::::::::::::::::::::
2062
2063(define_insn "mulhi3"
2064 [(set (match_operand:HI 0 "gr_register_operand" "=r")
2065 (mult:HI (match_operand:HI 1 "gr_register_operand" "r")
2066 (match_operand:HI 2 "gr_register_operand" "r")))]
2067 ""
2a7ffc85 2068 "pmpy2.r %0 = %1, %2"
52e12ad0 2069 [(set_attr "itanium_class" "mmmul")])
cf1f6ae3
RH
2070
2071\f
2072;; ::::::::::::::::::::
c65ebc55 2073;; ::
27a9b99d 2074;; :: 32-bit Integer arithmetic
c65ebc55
JW
2075;; ::
2076;; ::::::::::::::::::::
2077
058557c4 2078(define_insn "addsi3"
0551c32d
RH
2079 [(set (match_operand:SI 0 "gr_register_operand" "=r,r,r")
2080 (plus:SI (match_operand:SI 1 "gr_register_operand" "%r,r,a")
2081 (match_operand:SI 2 "gr_reg_or_22bit_operand" "r,I,J")))]
c65ebc55
JW
2082 ""
2083 "@
1d5d7a21
RH
2084 add %0 = %1, %2
2085 adds %0 = %2, %1
2086 addl %0 = %2, %1"
52e12ad0 2087 [(set_attr "itanium_class" "ialu")])
c65ebc55
JW
2088
2089(define_insn "*addsi3_plus1"
0551c32d
RH
2090 [(set (match_operand:SI 0 "gr_register_operand" "=r")
2091 (plus:SI (plus:SI (match_operand:SI 1 "gr_register_operand" "r")
2092 (match_operand:SI 2 "gr_register_operand" "r"))
c65ebc55
JW
2093 (const_int 1)))]
2094 ""
2095 "add %0 = %1, %2, 1"
52e12ad0 2096 [(set_attr "itanium_class" "ialu")])
c65ebc55 2097
5527bf14 2098(define_insn "*addsi3_plus1_alt"
0551c32d
RH
2099 [(set (match_operand:SI 0 "gr_register_operand" "=r")
2100 (plus:SI (mult:SI (match_operand:SI 1 "gr_register_operand" "r")
5527bf14
RH
2101 (const_int 2))
2102 (const_int 1)))]
2103 ""
2104 "add %0 = %1, %1, 1"
52e12ad0 2105 [(set_attr "itanium_class" "ialu")])
5527bf14 2106
058557c4 2107(define_insn "*addsi3_shladd"
0551c32d
RH
2108 [(set (match_operand:SI 0 "gr_register_operand" "=r")
2109 (plus:SI (mult:SI (match_operand:SI 1 "gr_register_operand" "r")
058557c4 2110 (match_operand:SI 2 "shladd_operand" "n"))
0551c32d 2111 (match_operand:SI 3 "gr_register_operand" "r")))]
c65ebc55 2112 ""
058557c4 2113 "shladd %0 = %1, %S2, %3"
52e12ad0 2114 [(set_attr "itanium_class" "ialu")])
c65ebc55 2115
058557c4 2116(define_insn "subsi3"
0551c32d
RH
2117 [(set (match_operand:SI 0 "gr_register_operand" "=r")
2118 (minus:SI (match_operand:SI 1 "gr_reg_or_8bit_operand" "rK")
2119 (match_operand:SI 2 "gr_register_operand" "r")))]
c65ebc55
JW
2120 ""
2121 "sub %0 = %1, %2"
52e12ad0 2122 [(set_attr "itanium_class" "ialu")])
c65ebc55
JW
2123
2124(define_insn "*subsi3_minus1"
0551c32d
RH
2125 [(set (match_operand:SI 0 "gr_register_operand" "=r")
2126 (plus:SI (not:SI (match_operand:SI 1 "gr_register_operand" "r"))
2127 (match_operand:SI 2 "gr_register_operand" "r")))]
c65ebc55
JW
2128 ""
2129 "sub %0 = %2, %1, 1"
52e12ad0
BS
2130 [(set_attr "itanium_class" "ialu")])
2131
2132;; ??? Could add maddsi3 patterns patterned after the madddi3 patterns.
c65ebc55 2133
058557c4 2134(define_insn "mulsi3"
0551c32d 2135 [(set (match_operand:SI 0 "fr_register_operand" "=f")
11a13704
RH
2136 (mult:SI (match_operand:SI 1 "grfr_register_operand" "f")
2137 (match_operand:SI 2 "grfr_register_operand" "f")))]
c65ebc55 2138 ""
aebf2462 2139 "xmpy.l %0 = %1, %2"
52e12ad0 2140 [(set_attr "itanium_class" "xmpy")])
c65ebc55 2141
655f2eb9 2142(define_insn "maddsi4"
11a13704
RH
2143 [(set (match_operand:SI 0 "fr_register_operand" "=f")
2144 (plus:SI (mult:SI (match_operand:SI 1 "grfr_register_operand" "f")
2145 (match_operand:SI 2 "grfr_register_operand" "f"))
2146 (match_operand:SI 3 "grfr_register_operand" "f")))]
2147 ""
aebf2462 2148 "xma.l %0 = %1, %2, %3"
52e12ad0 2149 [(set_attr "itanium_class" "xmpy")])
11a13704 2150
058557c4 2151(define_insn "negsi2"
0551c32d
RH
2152 [(set (match_operand:SI 0 "gr_register_operand" "=r")
2153 (neg:SI (match_operand:SI 1 "gr_register_operand" "r")))]
c65ebc55
JW
2154 ""
2155 "sub %0 = r0, %1"
52e12ad0 2156 [(set_attr "itanium_class" "ialu")])
c65ebc55
JW
2157
2158(define_expand "abssi2"
2159 [(set (match_dup 2)
f2f90c63 2160 (ge:BI (match_operand:SI 1 "gr_register_operand" "") (const_int 0)))
0551c32d 2161 (set (match_operand:SI 0 "gr_register_operand" "")
f2f90c63 2162 (if_then_else:SI (eq (match_dup 2) (const_int 0))
e5bde68a
RH
2163 (neg:SI (match_dup 1))
2164 (match_dup 1)))]
c65ebc55 2165 ""
1d5d7a21 2166 { operands[2] = gen_reg_rtx (BImode); })
c65ebc55
JW
2167
2168(define_expand "sminsi3"
2169 [(set (match_dup 3)
f2f90c63 2170 (ge:BI (match_operand:SI 1 "gr_register_operand" "")
0551c32d
RH
2171 (match_operand:SI 2 "gr_register_operand" "")))
2172 (set (match_operand:SI 0 "gr_register_operand" "")
f2f90c63 2173 (if_then_else:SI (ne (match_dup 3) (const_int 0))
c65ebc55
JW
2174 (match_dup 2) (match_dup 1)))]
2175 ""
1d5d7a21 2176 { operands[3] = gen_reg_rtx (BImode); })
c65ebc55
JW
2177
2178(define_expand "smaxsi3"
2179 [(set (match_dup 3)
f2f90c63 2180 (ge:BI (match_operand:SI 1 "gr_register_operand" "")
0551c32d
RH
2181 (match_operand:SI 2 "gr_register_operand" "")))
2182 (set (match_operand:SI 0 "gr_register_operand" "")
f2f90c63 2183 (if_then_else:SI (ne (match_dup 3) (const_int 0))
c65ebc55
JW
2184 (match_dup 1) (match_dup 2)))]
2185 ""
1d5d7a21 2186 { operands[3] = gen_reg_rtx (BImode); })
c65ebc55
JW
2187
2188(define_expand "uminsi3"
2189 [(set (match_dup 3)
f2f90c63 2190 (geu:BI (match_operand:SI 1 "gr_register_operand" "")
0551c32d
RH
2191 (match_operand:SI 2 "gr_register_operand" "")))
2192 (set (match_operand:SI 0 "gr_register_operand" "")
f2f90c63 2193 (if_then_else:SI (ne (match_dup 3) (const_int 0))
c65ebc55
JW
2194 (match_dup 2) (match_dup 1)))]
2195 ""
1d5d7a21 2196 { operands[3] = gen_reg_rtx (BImode); })
c65ebc55
JW
2197
2198(define_expand "umaxsi3"
2199 [(set (match_dup 3)
f2f90c63 2200 (geu:BI (match_operand:SI 1 "gr_register_operand" "")
0551c32d
RH
2201 (match_operand:SI 2 "gr_register_operand" "")))
2202 (set (match_operand:SI 0 "gr_register_operand" "")
f2f90c63 2203 (if_then_else:SI (ne (match_dup 3) (const_int 0))
c65ebc55
JW
2204 (match_dup 1) (match_dup 2)))]
2205 ""
1d5d7a21 2206 { operands[3] = gen_reg_rtx (BImode); })
c65ebc55
JW
2207\f
2208;; ::::::::::::::::::::
2209;; ::
27a9b99d 2210;; :: 64-bit Integer arithmetic
c65ebc55
JW
2211;; ::
2212;; ::::::::::::::::::::
2213
2214(define_insn "adddi3"
0551c32d
RH
2215 [(set (match_operand:DI 0 "gr_register_operand" "=r,r,r")
2216 (plus:DI (match_operand:DI 1 "gr_register_operand" "%r,r,a")
2217 (match_operand:DI 2 "gr_reg_or_22bit_operand" "r,I,J")))]
c65ebc55
JW
2218 ""
2219 "@
1d5d7a21
RH
2220 add %0 = %1, %2
2221 adds %0 = %2, %1
2222 addl %0 = %2, %1"
52e12ad0 2223 [(set_attr "itanium_class" "ialu")])
c65ebc55
JW
2224
2225(define_insn "*adddi3_plus1"
0551c32d
RH
2226 [(set (match_operand:DI 0 "gr_register_operand" "=r")
2227 (plus:DI (plus:DI (match_operand:DI 1 "gr_register_operand" "r")
2228 (match_operand:DI 2 "gr_register_operand" "r"))
c65ebc55
JW
2229 (const_int 1)))]
2230 ""
2231 "add %0 = %1, %2, 1"
52e12ad0 2232 [(set_attr "itanium_class" "ialu")])
c65ebc55 2233
5527bf14
RH
2234;; This has some of the same problems as shladd. We let the shladd
2235;; eliminator hack handle it, which results in the 1 being forced into
2236;; a register, but not more ugliness here.
2237(define_insn "*adddi3_plus1_alt"
0551c32d
RH
2238 [(set (match_operand:DI 0 "gr_register_operand" "=r")
2239 (plus:DI (mult:DI (match_operand:DI 1 "gr_register_operand" "r")
5527bf14
RH
2240 (const_int 2))
2241 (const_int 1)))]
2242 ""
2243 "add %0 = %1, %1, 1"
52e12ad0 2244 [(set_attr "itanium_class" "ialu")])
5527bf14 2245
c65ebc55 2246(define_insn "subdi3"
0551c32d
RH
2247 [(set (match_operand:DI 0 "gr_register_operand" "=r")
2248 (minus:DI (match_operand:DI 1 "gr_reg_or_8bit_operand" "rK")
2249 (match_operand:DI 2 "gr_register_operand" "r")))]
c65ebc55
JW
2250 ""
2251 "sub %0 = %1, %2"
52e12ad0 2252 [(set_attr "itanium_class" "ialu")])
c65ebc55
JW
2253
2254(define_insn "*subdi3_minus1"
0551c32d
RH
2255 [(set (match_operand:DI 0 "gr_register_operand" "=r")
2256 (plus:DI (not:DI (match_operand:DI 1 "gr_register_operand" "r"))
2257 (match_operand:DI 2 "gr_register_operand" "r")))]
c65ebc55
JW
2258 ""
2259 "sub %0 = %2, %1, 1"
52e12ad0 2260 [(set_attr "itanium_class" "ialu")])
c65ebc55 2261
cee58bc0
RH
2262;; ??? Use grfr instead of fr because of virtual register elimination
2263;; and silly test cases multiplying by the frame pointer.
c65ebc55 2264(define_insn "muldi3"
0551c32d 2265 [(set (match_operand:DI 0 "fr_register_operand" "=f")
cee58bc0
RH
2266 (mult:DI (match_operand:DI 1 "grfr_register_operand" "f")
2267 (match_operand:DI 2 "grfr_register_operand" "f")))]
c65ebc55 2268 ""
aebf2462 2269 "xmpy.l %0 = %1, %2"
52e12ad0 2270 [(set_attr "itanium_class" "xmpy")])
c65ebc55
JW
2271
2272;; ??? If operand 3 is an eliminable reg, then register elimination causes the
2273;; same problem that we have with shladd below. Unfortunately, this case is
2274;; much harder to fix because the multiply puts the result in an FP register,
2275;; but the add needs inputs from a general register. We add a spurious clobber
2276;; here so that it will be present just in case register elimination gives us
2277;; the funny result.
2278
2279;; ??? Maybe validate_changes should try adding match_scratch clobbers?
2280
2281;; ??? Maybe we should change how adds are canonicalized.
2282
655f2eb9 2283(define_insn "madddi4"
0551c32d 2284 [(set (match_operand:DI 0 "fr_register_operand" "=f")
11a13704
RH
2285 (plus:DI (mult:DI (match_operand:DI 1 "grfr_register_operand" "f")
2286 (match_operand:DI 2 "grfr_register_operand" "f"))
2287 (match_operand:DI 3 "grfr_register_operand" "f")))
c65ebc55
JW
2288 (clobber (match_scratch:DI 4 "=X"))]
2289 ""
aebf2462 2290 "xma.l %0 = %1, %2, %3"
52e12ad0 2291 [(set_attr "itanium_class" "xmpy")])
c65ebc55
JW
2292
2293;; This can be created by register elimination if operand3 of shladd is an
2294;; eliminable register or has reg_equiv_constant set.
2295
2296;; We have to use nonmemory_operand for operand 4, to ensure that the
2297;; validate_changes call inside eliminate_regs will always succeed. If it
655f2eb9 2298;; doesn't succeed, then this remain a madddi4 pattern, and will be reloaded
c65ebc55
JW
2299;; incorrectly.
2300
655f2eb9 2301(define_insn "*madddi4_elim"
c65ebc55 2302 [(set (match_operand:DI 0 "register_operand" "=&r")
13da91fd
RH
2303 (plus:DI (plus:DI (mult:DI (match_operand:DI 1 "register_operand" "f")
2304 (match_operand:DI 2 "register_operand" "f"))
2305 (match_operand:DI 3 "register_operand" "f"))
c65ebc55 2306 (match_operand:DI 4 "nonmemory_operand" "rI")))
13da91fd 2307 (clobber (match_scratch:DI 5 "=f"))]
c65ebc55
JW
2308 "reload_in_progress"
2309 "#"
52e12ad0 2310 [(set_attr "itanium_class" "unknown")])
c65ebc55 2311
c65ebc55
JW
2312(define_split
2313 [(set (match_operand:DI 0 "register_operand" "")
2314 (plus:DI (plus:DI (mult:DI (match_operand:DI 1 "register_operand" "")
2315 (match_operand:DI 2 "register_operand" ""))
2316 (match_operand:DI 3 "register_operand" ""))
0551c32d 2317 (match_operand:DI 4 "gr_reg_or_14bit_operand" "")))
c65ebc55
JW
2318 (clobber (match_scratch:DI 5 ""))]
2319 "reload_completed"
2320 [(parallel [(set (match_dup 5) (plus:DI (mult:DI (match_dup 1) (match_dup 2))
2321 (match_dup 3)))
2322 (clobber (match_dup 0))])
c65ebc55 2323 (set (match_dup 0) (match_dup 5))
c65ebc55
JW
2324 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 4)))]
2325 "")
2326
c65ebc55 2327(define_insn "smuldi3_highpart"
0551c32d 2328 [(set (match_operand:DI 0 "fr_register_operand" "=f")
c65ebc55
JW
2329 (truncate:DI
2330 (lshiftrt:TI
0551c32d 2331 (mult:TI (sign_extend:TI
6adb807e 2332 (match_operand:DI 1 "fr_reg_or_fp01_operand" "fG"))
0551c32d 2333 (sign_extend:TI
6adb807e 2334 (match_operand:DI 2 "fr_reg_or_fp01_operand" "fG")))
c65ebc55
JW
2335 (const_int 64))))]
2336 ""
6adb807e 2337 "xmpy.h %0 = %F1, %F2"
52e12ad0 2338 [(set_attr "itanium_class" "xmpy")])
c65ebc55
JW
2339
2340(define_insn "umuldi3_highpart"
0551c32d 2341 [(set (match_operand:DI 0 "fr_register_operand" "=f")
c65ebc55
JW
2342 (truncate:DI
2343 (lshiftrt:TI
0551c32d 2344 (mult:TI (zero_extend:TI
6adb807e 2345 (match_operand:DI 1 "fr_reg_or_fp01_operand" "fG"))
0551c32d 2346 (zero_extend:TI
6adb807e 2347 (match_operand:DI 2 "fr_reg_or_fp01_operand" "fG")))
c65ebc55
JW
2348 (const_int 64))))]
2349 ""
6adb807e 2350 "xmpy.hu %0 = %F1, %F2"
52e12ad0 2351 [(set_attr "itanium_class" "xmpy")])
c65ebc55
JW
2352
2353(define_insn "negdi2"
0551c32d
RH
2354 [(set (match_operand:DI 0 "gr_register_operand" "=r")
2355 (neg:DI (match_operand:DI 1 "gr_register_operand" "r")))]
c65ebc55
JW
2356 ""
2357 "sub %0 = r0, %1"
52e12ad0 2358 [(set_attr "itanium_class" "ialu")])
c65ebc55
JW
2359
2360(define_expand "absdi2"
2361 [(set (match_dup 2)
f2f90c63 2362 (ge:BI (match_operand:DI 1 "gr_register_operand" "") (const_int 0)))
0551c32d 2363 (set (match_operand:DI 0 "gr_register_operand" "")
f2f90c63 2364 (if_then_else:DI (eq (match_dup 2) (const_int 0))
e5bde68a
RH
2365 (neg:DI (match_dup 1))
2366 (match_dup 1)))]
c65ebc55 2367 ""
1d5d7a21 2368 { operands[2] = gen_reg_rtx (BImode); })
c65ebc55
JW
2369
2370(define_expand "smindi3"
2371 [(set (match_dup 3)
f2f90c63 2372 (ge:BI (match_operand:DI 1 "gr_register_operand" "")
0551c32d
RH
2373 (match_operand:DI 2 "gr_register_operand" "")))
2374 (set (match_operand:DI 0 "gr_register_operand" "")
f2f90c63 2375 (if_then_else:DI (ne (match_dup 3) (const_int 0))
c65ebc55
JW
2376 (match_dup 2) (match_dup 1)))]
2377 ""
1d5d7a21 2378 { operands[3] = gen_reg_rtx (BImode); })
c65ebc55
JW
2379
2380(define_expand "smaxdi3"
2381 [(set (match_dup 3)
f2f90c63 2382 (ge:BI (match_operand:DI 1 "gr_register_operand" "")
0551c32d
RH
2383 (match_operand:DI 2 "gr_register_operand" "")))
2384 (set (match_operand:DI 0 "gr_register_operand" "")
f2f90c63 2385 (if_then_else:DI (ne (match_dup 3) (const_int 0))
c65ebc55
JW
2386 (match_dup 1) (match_dup 2)))]
2387 ""
1d5d7a21 2388 { operands[3] = gen_reg_rtx (BImode); })
c65ebc55
JW
2389
2390(define_expand "umindi3"
2391 [(set (match_dup 3)
f2f90c63 2392 (geu:BI (match_operand:DI 1 "gr_register_operand" "")
0551c32d
RH
2393 (match_operand:DI 2 "gr_register_operand" "")))
2394 (set (match_operand:DI 0 "gr_register_operand" "")
f2f90c63 2395 (if_then_else:DI (ne (match_dup 3) (const_int 0))
c65ebc55
JW
2396 (match_dup 2) (match_dup 1)))]
2397 ""
1d5d7a21 2398 { operands[3] = gen_reg_rtx (BImode); })
c65ebc55
JW
2399
2400(define_expand "umaxdi3"
2401 [(set (match_dup 3)
f2f90c63 2402 (geu:BI (match_operand:DI 1 "gr_register_operand" "")
0551c32d
RH
2403 (match_operand:DI 2 "gr_register_operand" "")))
2404 (set (match_operand:DI 0 "gr_register_operand" "")
f2f90c63 2405 (if_then_else:DI (ne (match_dup 3) (const_int 0))
c65ebc55
JW
2406 (match_dup 1) (match_dup 2)))]
2407 ""
1d5d7a21 2408 { operands[3] = gen_reg_rtx (BImode); })
c65ebc55
JW
2409
2410(define_expand "ffsdi2"
2411 [(set (match_dup 6)
f2f90c63 2412 (eq:BI (match_operand:DI 1 "gr_register_operand" "") (const_int 0)))
c65ebc55
JW
2413 (set (match_dup 2) (plus:DI (match_dup 1) (const_int -1)))
2414 (set (match_dup 5) (const_int 0))
2415 (set (match_dup 3) (xor:DI (match_dup 1) (match_dup 2)))
c407570a 2416 (set (match_dup 4) (popcount:DI (match_dup 3)))
0551c32d 2417 (set (match_operand:DI 0 "gr_register_operand" "")
f2f90c63 2418 (if_then_else:DI (ne (match_dup 6) (const_int 0))
c65ebc55
JW
2419 (match_dup 5) (match_dup 4)))]
2420 ""
c65ebc55
JW
2421{
2422 operands[2] = gen_reg_rtx (DImode);
2423 operands[3] = gen_reg_rtx (DImode);
2424 operands[4] = gen_reg_rtx (DImode);
2425 operands[5] = gen_reg_rtx (DImode);
f2f90c63 2426 operands[6] = gen_reg_rtx (BImode);
1d5d7a21 2427})
c65ebc55 2428
c407570a
RH
2429(define_expand "ctzdi2"
2430 [(set (match_dup 2) (plus:DI (match_operand:DI 1 "gr_register_operand" "")
2431 (const_int -1)))
2432 (set (match_dup 3) (not:DI (match_dup 1)))
2433 (set (match_dup 4) (and:DI (match_dup 2) (match_dup 3)))
2434 (set (match_operand:DI 0 "gr_register_operand" "")
2435 (popcount:DI (match_dup 4)))]
2436 ""
2437{
2438 operands[2] = gen_reg_rtx (DImode);
2439 operands[3] = gen_reg_rtx (DImode);
2440 operands[4] = gen_reg_rtx (DImode);
2441})
2442
c407570a
RH
2443;; Note the computation here is op0 = 63 - (exp - 0xffff).
2444(define_expand "clzdi2"
2445 [(set (match_dup 2)
6adb807e 2446 (unsigned_float:XF (match_operand:DI 1 "fr_reg_or_fp01_operand" "")))
c407570a
RH
2447 (set (match_dup 3)
2448 (unspec:DI [(match_dup 2)] UNSPEC_GETF_EXP))
2449 (set (match_dup 4) (const_int 65598))
2450 (set (match_operand:DI 0 "gr_register_operand" "")
2451 (minus:DI (match_dup 4) (match_dup 3)))]
02befdf4 2452 ""
c407570a 2453{
02befdf4 2454 operands[2] = gen_reg_rtx (XFmode);
c407570a
RH
2455 operands[3] = gen_reg_rtx (DImode);
2456 operands[4] = gen_reg_rtx (DImode);
2457})
2458
2459(define_insn "popcountdi2"
0551c32d 2460 [(set (match_operand:DI 0 "gr_register_operand" "=r")
c407570a 2461 (popcount:DI (match_operand:DI 1 "gr_register_operand" "r")))]
c65ebc55
JW
2462 ""
2463 "popcnt %0 = %1"
52e12ad0 2464 [(set_attr "itanium_class" "mmmul")])
c65ebc55 2465
ff848f0e
RS
2466(define_insn "bswapdi2"
2467 [(set (match_operand:DI 0 "gr_register_operand" "=r")
2468 (bswap:DI (match_operand:DI 1 "gr_register_operand" "r")))]
2469 ""
2470 "mux1 %0 = %1, @rev"
2471 [(set_attr "itanium_class" "mmshf")])
2472
02befdf4 2473(define_insn "*getf_exp_xf"
c407570a 2474 [(set (match_operand:DI 0 "gr_register_operand" "=r")
6adb807e 2475 (unspec:DI [(match_operand:XF 1 "fr_reg_or_fp01_operand" "fG")]
c407570a 2476 UNSPEC_GETF_EXP))]
02befdf4 2477 ""
6adb807e 2478 "getf.exp %0 = %F1"
c407570a 2479 [(set_attr "itanium_class" "frfr")])
c65ebc55
JW
2480\f
2481;; ::::::::::::::::::::
2482;; ::
27a9b99d 2483;; :: 128-bit Integer arithmetic
a71aef0b
JB
2484;; ::
2485;; ::::::::::::::::::::
2486
2487(define_insn "addti3"
2488 [(set (match_operand:TI 0 "gr_register_operand" "=&r")
2489 (plus:TI (match_operand:TI 1 "gr_register_operand" "%r")
2490 (match_operand:TI 2 "gr_reg_or_14bit_operand" "rI")))
2491 (clobber (match_scratch:BI 3 "=&c"))]
2492 ""
2493 "#"
2494 [(set_attr "itanium_class" "unknown")])
2495
2496(define_split
2497 [(set (match_operand:TI 0 "register_operand" "")
2498 (plus:TI (match_operand:TI 1 "register_operand" "")
2499 (match_operand:TI 2 "register_operand" "")))
2500 (clobber (match_scratch:BI 3 ""))]
2501 "reload_completed"
2502 [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))
2503 (set (match_dup 3) (ltu:BI (match_dup 0) (match_dup 1)))
2504 (cond_exec (eq (match_dup 3) (const_int 0))
2505 (set (match_dup 4) (plus:DI (match_dup 5) (match_dup 6))))
2506 (cond_exec (ne (match_dup 3) (const_int 0))
2507 (set (match_dup 4)
2508 (plus:DI (plus:DI (match_dup 5) (match_dup 6))
2509 (const_int 1))))]
2510{
2511 operands[4] = gen_highpart (DImode, operands[0]);
2512 operands[0] = gen_lowpart (DImode, operands[0]);
2513 operands[5] = gen_highpart (DImode, operands[1]);
2514 operands[1] = gen_lowpart (DImode, operands[1]);
2515 operands[6] = gen_highpart (DImode, operands[2]);
2516 operands[2] = gen_lowpart (DImode, operands[2]);
2517})
2518
2519(define_split
2520 [(set (match_operand:TI 0 "register_operand" "")
2521 (plus:TI (match_operand:TI 1 "register_operand" "")
2522 (match_operand:TI 2 "immediate_operand" "")))
2523 (clobber (match_scratch:BI 3 ""))]
2524 "reload_completed"
2525 [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))
2526 (set (match_dup 3) (ltu:BI (match_dup 0) (match_dup 1)))
2527 (cond_exec (eq (match_dup 3) (const_int 0))
2528 (set (match_dup 4)
2529 (plus:DI (match_dup 5) (match_dup 6))))
2530 (cond_exec (ne (match_dup 3) (const_int 0))
2531 (set (match_dup 4)
2532 (plus:DI (match_dup 5) (match_dup 7))))]
2533{
2534 operands[4] = gen_highpart (DImode, operands[0]);
2535 operands[0] = gen_lowpart (DImode, operands[0]);
2536 operands[5] = gen_highpart (DImode, operands[1]);
2537 operands[1] = gen_lowpart (DImode, operands[1]);
2538 operands[6] = INTVAL (operands[2]) < 0 ? constm1_rtx : const0_rtx;
2539 operands[7] = INTVAL (operands[2]) < 0 ? const0_rtx : const1_rtx;
2540})
2541
2542(define_insn "subti3"
2543 [(set (match_operand:TI 0 "gr_register_operand" "=&r")
2544 (minus:TI (match_operand:TI 1 "gr_reg_or_8bit_operand" "rK")
2545 (match_operand:TI 2 "gr_register_operand" "r")))
2546 (clobber (match_scratch:BI 3 "=&c"))]
2547 ""
2548 "#"
2549 [(set_attr "itanium_class" "unknown")])
2550
2551(define_split
2552 [(set (match_operand:TI 0 "register_operand" "")
2553 (minus:TI (match_operand:TI 1 "register_operand" "")
2554 (match_operand:TI 2 "register_operand" "")))
2555 (clobber (match_scratch:BI 3 "=&c"))]
2556 "reload_completed"
2557 [(set (match_dup 0) (minus:DI (match_dup 1) (match_dup 2)))
2558 (set (match_dup 3) (ltu:BI (match_dup 1) (match_dup 0)))
2559 (cond_exec (eq (match_dup 3) (const_int 0))
2560 (set (match_dup 4) (minus:DI (match_dup 5) (match_dup 6))))
2561 (cond_exec (ne (match_dup 3) (const_int 0))
2562 (set (match_dup 4)
2563 (plus:DI (not:DI (match_dup 6)) (match_dup 5))))]
2564{
2565 operands[4] = gen_highpart (DImode, operands[0]);
2566 operands[0] = gen_lowpart (DImode, operands[0]);
2567 operands[5] = gen_highpart (DImode, operands[1]);
2568 operands[1] = gen_lowpart (DImode, operands[1]);
2569 operands[6] = gen_highpart (DImode, operands[2]);
2570 operands[2] = gen_lowpart (DImode, operands[2]);
2571})
2572
2573(define_split
2574 [(set (match_operand:TI 0 "register_operand" "")
2575 (minus:TI (match_operand:TI 1 "immediate_operand" "")
2576 (match_operand:TI 2 "register_operand" "")))
2577 (clobber (match_scratch:BI 3 "=&c"))]
13f70342 2578 "reload_completed && satisfies_constraint_K (operands[1])"
a71aef0b
JB
2579 [(set (match_dup 0) (minus:DI (match_dup 1) (match_dup 2)))
2580 (set (match_dup 3) (gtu:BI (match_dup 0) (match_dup 1)))
2581 (cond_exec (ne (match_dup 3) (const_int 0))
2582 (set (match_dup 4) (minus:DI (match_dup 6) (match_dup 5))))
2583 (cond_exec (eq (match_dup 3) (const_int 0))
2584 (set (match_dup 4) (minus:DI (match_dup 7) (match_dup 5))))]
2585{
2586 operands[4] = gen_highpart (DImode, operands[0]);
2587 operands[0] = gen_lowpart (DImode, operands[0]);
2588 operands[5] = gen_highpart (DImode, operands[2]);
2589 operands[2] = gen_lowpart (DImode, operands[2]);
2590 operands[6] = INTVAL (operands[1]) < 0 ? GEN_INT (-2) : constm1_rtx;
2591 operands[7] = INTVAL (operands[1]) < 0 ? constm1_rtx : const0_rtx;
2592})
2593
2594(define_expand "mulditi3"
2595 [(set (match_operand:TI 0 "fr_register_operand" "")
2596 (mult:TI (sign_extend:TI
6adb807e 2597 (match_operand:DI 1 "fr_reg_or_fp01_operand" ""))
a71aef0b 2598 (sign_extend:TI
6adb807e 2599 (match_operand:DI 2 "fr_reg_or_fp01_operand" ""))))]
a71aef0b
JB
2600 ""
2601 "")
2602
2603(define_insn_and_split "*mulditi3_internal"
2604 [(set (match_operand:TI 0 "fr_register_operand" "=&f")
2605 (mult:TI (sign_extend:TI
6adb807e 2606 (match_operand:DI 1 "fr_reg_or_fp01_operand" "fG"))
a71aef0b 2607 (sign_extend:TI
6adb807e 2608 (match_operand:DI 2 "fr_reg_or_fp01_operand" "fG"))))]
a71aef0b
JB
2609 ""
2610 "#"
2611 "reload_completed"
2612 [(set (match_dup 0) (mult:DI (match_dup 1) (match_dup 2)))
2613 (set (match_dup 3) (truncate:DI
2614 (lshiftrt:TI
2615 (mult:TI (sign_extend:TI (match_dup 1))
2616 (sign_extend:TI (match_dup 2)))
2617 (const_int 64))))]
2618{
2619 operands[3] = gen_highpart (DImode, operands[0]);
2620 operands[0] = gen_lowpart (DImode, operands[0]);
2621}
2622 [(set_attr "itanium_class" "unknown")])
2623
2624(define_expand "umulditi3"
2625 [(set (match_operand:TI 0 "fr_register_operand" "")
2626 (mult:TI (zero_extend:TI
6adb807e 2627 (match_operand:DI 1 "fr_reg_or_fp01_operand" ""))
a71aef0b 2628 (zero_extend:TI
6adb807e 2629 (match_operand:DI 2 "fr_reg_or_fp01_operand" ""))))]
a71aef0b
JB
2630 ""
2631 "")
2632
2633(define_insn_and_split "*umulditi3_internal"
2634 [(set (match_operand:TI 0 "fr_register_operand" "=&f")
2635 (mult:TI (zero_extend:TI
6adb807e 2636 (match_operand:DI 1 "fr_reg_or_fp01_operand" "fG"))
a71aef0b 2637 (zero_extend:TI
6adb807e 2638 (match_operand:DI 2 "fr_reg_or_fp01_operand" "fG"))))]
a71aef0b
JB
2639 ""
2640 "#"
2641 "reload_completed"
2642 [(set (match_dup 0) (mult:DI (match_dup 1) (match_dup 2)))
2643 (set (match_dup 3) (truncate:DI
2644 (lshiftrt:TI
2645 (mult:TI (zero_extend:TI (match_dup 1))
2646 (zero_extend:TI (match_dup 2)))
2647 (const_int 64))))]
2648{
2649 operands[3] = gen_highpart (DImode, operands[0]);
2650 operands[0] = gen_lowpart (DImode, operands[0]);
2651}
2652 [(set_attr "itanium_class" "unknown")])
2653
2654(define_insn_and_split "negti2"
2655 [(set (match_operand:TI 0 "gr_register_operand" "=&r")
2656 (neg:TI (match_operand:TI 1 "gr_register_operand" "r")))
2657 (clobber (match_scratch:BI 2 "=&c"))]
2658 ""
2659 "#"
2660 "reload_completed"
2661 [(set (match_dup 2) (eq:BI (match_dup 1) (const_int 0)))
2662 (set (match_dup 0) (minus:DI (const_int 0) (match_dup 1)))
2663 (cond_exec (eq (match_dup 2) (const_int 0))
2664 (set (match_dup 3) (minus:DI (const_int -1) (match_dup 4))))
2665 (cond_exec (ne (match_dup 2) (const_int 0))
2666 (set (match_dup 3) (minus:DI (const_int 0) (match_dup 4))))]
2667{
2668 operands[3] = gen_highpart (DImode, operands[0]);
2669 operands[0] = gen_lowpart (DImode, operands[0]);
2670 operands[4] = gen_highpart (DImode, operands[1]);
2671 operands[1] = gen_lowpart (DImode, operands[1]);
2672}
2673 [(set_attr "itanium_class" "unknown")])
2674\f
2675;; ::::::::::::::::::::
2676;; ::
27a9b99d 2677;; :: 32-bit floating point arithmetic
c65ebc55
JW
2678;; ::
2679;; ::::::::::::::::::::
2680
2681(define_insn "addsf3"
0551c32d 2682 [(set (match_operand:SF 0 "fr_register_operand" "=f")
33974673
SE
2683 (plus:SF (match_operand:SF 1 "fr_reg_or_fp01_operand" "%fG")
2684 (match_operand:SF 2 "fr_reg_or_signed_fp01_operand" "fZ")))]
c65ebc55 2685 ""
6adb807e 2686 "fadd.s %0 = %F1, %F2"
52e12ad0 2687 [(set_attr "itanium_class" "fmac")])
c65ebc55
JW
2688
2689(define_insn "subsf3"
0551c32d
RH
2690 [(set (match_operand:SF 0 "fr_register_operand" "=f")
2691 (minus:SF (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")
33974673 2692 (match_operand:SF 2 "fr_reg_or_signed_fp01_operand" "fZ")))]
c65ebc55 2693 ""
aebf2462 2694 "fsub.s %0 = %F1, %F2"
52e12ad0 2695 [(set_attr "itanium_class" "fmac")])
c65ebc55
JW
2696
2697(define_insn "mulsf3"
0551c32d 2698 [(set (match_operand:SF 0 "fr_register_operand" "=f")
6adb807e
SE
2699 (mult:SF (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")
2700 (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")))]
c65ebc55 2701 ""
6adb807e 2702 "fmpy.s %0 = %F1, %F2"
52e12ad0 2703 [(set_attr "itanium_class" "fmac")])
c65ebc55
JW
2704
2705(define_insn "abssf2"
0551c32d 2706 [(set (match_operand:SF 0 "fr_register_operand" "=f")
6adb807e 2707 (abs:SF (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")))]
c65ebc55 2708 ""
6adb807e 2709 "fabs %0 = %F1"
52e12ad0 2710 [(set_attr "itanium_class" "fmisc")])
c65ebc55
JW
2711
2712(define_insn "negsf2"
0551c32d 2713 [(set (match_operand:SF 0 "fr_register_operand" "=f")
6adb807e 2714 (neg:SF (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")))]
c65ebc55 2715 ""
6adb807e 2716 "fneg %0 = %F1"
52e12ad0 2717 [(set_attr "itanium_class" "fmisc")])
c65ebc55
JW
2718
2719(define_insn "*nabssf2"
0551c32d 2720 [(set (match_operand:SF 0 "fr_register_operand" "=f")
6adb807e 2721 (neg:SF (abs:SF (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG"))))]
c65ebc55 2722 ""
6adb807e 2723 "fnegabs %0 = %F1"
52e12ad0 2724 [(set_attr "itanium_class" "fmisc")])
c65ebc55 2725
046625fa
RH
2726(define_insn "copysignsf3"
2727 [(set (match_operand:SF 0 "register_operand" "=f")
2728 (unspec:SF [(match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")
2729 (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")]
2730 UNSPEC_COPYSIGN))]
2731 ""
2732 "fmerge.s %0 = %F2, %F1"
2733 [(set_attr "itanium_class" "fmisc")])
2734
2735(define_insn "*ncopysignsf3"
2736 [(set (match_operand:SF 0 "register_operand" "=f")
2737 (neg:SF (unspec:SF [(match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")
2738 (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")]
2739 UNSPEC_COPYSIGN)))]
2740 ""
2741 "fmerge.ns %0 = %F2, %F1"
2742 [(set_attr "itanium_class" "fmisc")])
2743
7ae4d8d4 2744(define_insn "sminsf3"
0551c32d 2745 [(set (match_operand:SF 0 "fr_register_operand" "=f")
6adb807e 2746 (smin:SF (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")
0551c32d 2747 (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")))]
c65ebc55 2748 ""
6adb807e 2749 "fmin %0 = %F1, %F2"
52e12ad0 2750 [(set_attr "itanium_class" "fmisc")])
c65ebc55 2751
7ae4d8d4 2752(define_insn "smaxsf3"
0551c32d 2753 [(set (match_operand:SF 0 "fr_register_operand" "=f")
6adb807e 2754 (smax:SF (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")
0551c32d 2755 (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")))]
c65ebc55 2756 ""
6adb807e 2757 "fmax %0 = %F1, %F2"
52e12ad0 2758 [(set_attr "itanium_class" "fmisc")])
c65ebc55 2759
655f2eb9 2760(define_insn "*maddsf4"
0551c32d 2761 [(set (match_operand:SF 0 "fr_register_operand" "=f")
6adb807e
SE
2762 (plus:SF (mult:SF (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")
2763 (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG"))
33974673 2764 (match_operand:SF 3 "fr_reg_or_signed_fp01_operand" "fZ")))]
583ca921 2765 "TARGET_FUSED_MADD"
6adb807e 2766 "fma.s %0 = %F1, %F2, %F3"
52e12ad0 2767 [(set_attr "itanium_class" "fmac")])
c65ebc55 2768
655f2eb9 2769(define_insn "*msubsf4"
0551c32d 2770 [(set (match_operand:SF 0 "fr_register_operand" "=f")
6adb807e
SE
2771 (minus:SF (mult:SF (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")
2772 (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG"))
33974673 2773 (match_operand:SF 3 "fr_reg_or_signed_fp01_operand" "fZ")))]
583ca921 2774 "TARGET_FUSED_MADD"
6adb807e 2775 "fms.s %0 = %F1, %F2, %F3"
52e12ad0 2776 [(set_attr "itanium_class" "fmac")])
c65ebc55
JW
2777
2778(define_insn "*nmulsf3"
0551c32d 2779 [(set (match_operand:SF 0 "fr_register_operand" "=f")
6adb807e
SE
2780 (neg:SF (mult:SF (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")
2781 (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG"))))]
c65ebc55 2782 ""
6adb807e 2783 "fnmpy.s %0 = %F1, %F2"
52e12ad0 2784 [(set_attr "itanium_class" "fmac")])
c65ebc55 2785
655f2eb9 2786(define_insn "*nmaddsf4"
0551c32d 2787 [(set (match_operand:SF 0 "fr_register_operand" "=f")
52ad4d7b 2788 (minus:SF (match_operand:SF 3 "fr_reg_or_fp01_operand" "fG")
6adb807e
SE
2789 (mult:SF (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")
2790 (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG"))))]
583ca921 2791 "TARGET_FUSED_MADD"
6adb807e 2792 "fnma.s %0 = %F1, %F2, %F3"
52e12ad0 2793 [(set_attr "itanium_class" "fmac")])
c65ebc55
JW
2794\f
2795;; ::::::::::::::::::::
2796;; ::
27a9b99d 2797;; :: 64-bit floating point arithmetic
c65ebc55
JW
2798;; ::
2799;; ::::::::::::::::::::
2800
2801(define_insn "adddf3"
0551c32d 2802 [(set (match_operand:DF 0 "fr_register_operand" "=f")
33974673
SE
2803 (plus:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "%fG")
2804 (match_operand:DF 2 "fr_reg_or_signed_fp01_operand" "fZ")))]
c65ebc55 2805 ""
6adb807e 2806 "fadd.d %0 = %F1, %F2"
52e12ad0 2807 [(set_attr "itanium_class" "fmac")])
c65ebc55 2808
26102535
RH
2809(define_insn "*adddf3_trunc"
2810 [(set (match_operand:SF 0 "fr_register_operand" "=f")
2811 (float_truncate:SF
33974673
SE
2812 (plus:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "%fG")
2813 (match_operand:DF 2 "fr_reg_or_signed_fp01_operand" "fZ"))))]
26102535 2814 ""
6adb807e 2815 "fadd.s %0 = %F1, %F2"
52e12ad0 2816 [(set_attr "itanium_class" "fmac")])
26102535 2817
c65ebc55 2818(define_insn "subdf3"
0551c32d
RH
2819 [(set (match_operand:DF 0 "fr_register_operand" "=f")
2820 (minus:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
33974673 2821 (match_operand:DF 2 "fr_reg_or_signed_fp01_operand" "fZ")))]
c65ebc55 2822 ""
aebf2462 2823 "fsub.d %0 = %F1, %F2"
52e12ad0 2824 [(set_attr "itanium_class" "fmac")])
c65ebc55 2825
26102535
RH
2826(define_insn "*subdf3_trunc"
2827 [(set (match_operand:SF 0 "fr_register_operand" "=f")
2828 (float_truncate:SF
2829 (minus:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
33974673 2830 (match_operand:DF 2 "fr_reg_or_signed_fp01_operand" "fZ"))))]
26102535 2831 ""
aebf2462 2832 "fsub.s %0 = %F1, %F2"
52e12ad0 2833 [(set_attr "itanium_class" "fmac")])
26102535 2834
c65ebc55 2835(define_insn "muldf3"
0551c32d 2836 [(set (match_operand:DF 0 "fr_register_operand" "=f")
6adb807e
SE
2837 (mult:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
2838 (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")))]
c65ebc55 2839 ""
6adb807e 2840 "fmpy.d %0 = %F1, %F2"
52e12ad0 2841 [(set_attr "itanium_class" "fmac")])
c65ebc55 2842
26102535
RH
2843(define_insn "*muldf3_trunc"
2844 [(set (match_operand:SF 0 "fr_register_operand" "=f")
2845 (float_truncate:SF
6adb807e
SE
2846 (mult:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
2847 (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG"))))]
26102535 2848 ""
6adb807e 2849 "fmpy.s %0 = %F1, %F2"
52e12ad0 2850 [(set_attr "itanium_class" "fmac")])
26102535 2851
c65ebc55 2852(define_insn "absdf2"
0551c32d 2853 [(set (match_operand:DF 0 "fr_register_operand" "=f")
6adb807e 2854 (abs:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")))]
c65ebc55 2855 ""
6adb807e 2856 "fabs %0 = %F1"
52e12ad0 2857 [(set_attr "itanium_class" "fmisc")])
c65ebc55
JW
2858
2859(define_insn "negdf2"
0551c32d 2860 [(set (match_operand:DF 0 "fr_register_operand" "=f")
6adb807e 2861 (neg:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")))]
c65ebc55 2862 ""
6adb807e 2863 "fneg %0 = %F1"
52e12ad0 2864 [(set_attr "itanium_class" "fmisc")])
c65ebc55
JW
2865
2866(define_insn "*nabsdf2"
0551c32d 2867 [(set (match_operand:DF 0 "fr_register_operand" "=f")
6adb807e 2868 (neg:DF (abs:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG"))))]
c65ebc55 2869 ""
6adb807e 2870 "fnegabs %0 = %F1"
52e12ad0 2871 [(set_attr "itanium_class" "fmisc")])
c65ebc55 2872
046625fa
RH
2873(define_insn "copysigndf3"
2874 [(set (match_operand:DF 0 "register_operand" "=f")
2875 (unspec:DF [(match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
2876 (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")]
2877 UNSPEC_COPYSIGN))]
2878 ""
2879 "fmerge.s %0 = %F2, %F1"
2880 [(set_attr "itanium_class" "fmisc")])
2881
2882(define_insn "*ncopysigndf3"
2883 [(set (match_operand:DF 0 "register_operand" "=f")
2884 (neg:DF (unspec:DF [(match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
2885 (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")]
2886 UNSPEC_COPYSIGN)))]
2887 ""
2888 "fmerge.ns %0 = %F2, %F1"
2889 [(set_attr "itanium_class" "fmisc")])
2890
7ae4d8d4 2891(define_insn "smindf3"
0551c32d 2892 [(set (match_operand:DF 0 "fr_register_operand" "=f")
6adb807e 2893 (smin:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
0551c32d 2894 (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")))]
c65ebc55 2895 ""
6adb807e 2896 "fmin %0 = %F1, %F2"
52e12ad0 2897 [(set_attr "itanium_class" "fmisc")])
c65ebc55 2898
7ae4d8d4 2899(define_insn "smaxdf3"
0551c32d 2900 [(set (match_operand:DF 0 "fr_register_operand" "=f")
6adb807e 2901 (smax:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
0551c32d 2902 (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")))]
c65ebc55 2903 ""
6adb807e 2904 "fmax %0 = %F1, %F2"
52e12ad0 2905 [(set_attr "itanium_class" "fmisc")])
c65ebc55 2906
655f2eb9 2907(define_insn "*madddf4"
0551c32d 2908 [(set (match_operand:DF 0 "fr_register_operand" "=f")
6adb807e
SE
2909 (plus:DF (mult:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
2910 (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG"))
33974673 2911 (match_operand:DF 3 "fr_reg_or_signed_fp01_operand" "fZ")))]
583ca921 2912 "TARGET_FUSED_MADD"
6adb807e 2913 "fma.d %0 = %F1, %F2, %F3"
52e12ad0 2914 [(set_attr "itanium_class" "fmac")])
c65ebc55 2915
26102535
RH
2916(define_insn "*madddf4_trunc"
2917 [(set (match_operand:SF 0 "fr_register_operand" "=f")
2918 (float_truncate:SF
6adb807e
SE
2919 (plus:DF (mult:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
2920 (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG"))
33974673 2921 (match_operand:DF 3 "fr_reg_or_signed_fp01_operand" "fZ"))))]
583ca921 2922 "TARGET_FUSED_MADD"
6adb807e 2923 "fma.s %0 = %F1, %F2, %F3"
52e12ad0 2924 [(set_attr "itanium_class" "fmac")])
26102535 2925
655f2eb9 2926(define_insn "*msubdf4"
0551c32d 2927 [(set (match_operand:DF 0 "fr_register_operand" "=f")
6adb807e
SE
2928 (minus:DF (mult:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
2929 (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG"))
33974673 2930 (match_operand:DF 3 "fr_reg_or_signed_fp01_operand" "fZ")))]
583ca921 2931 "TARGET_FUSED_MADD"
6adb807e 2932 "fms.d %0 = %F1, %F2, %F3"
52e12ad0 2933 [(set_attr "itanium_class" "fmac")])
c65ebc55 2934
26102535
RH
2935(define_insn "*msubdf4_trunc"
2936 [(set (match_operand:SF 0 "fr_register_operand" "=f")
2937 (float_truncate:SF
6adb807e
SE
2938 (minus:DF (mult:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
2939 (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG"))
33974673 2940 (match_operand:DF 3 "fr_reg_or_signed_fp01_operand" "fZ"))))]
583ca921 2941 "TARGET_FUSED_MADD"
6adb807e 2942 "fms.s %0 = %F1, %F2, %F3"
52e12ad0 2943 [(set_attr "itanium_class" "fmac")])
26102535 2944
c65ebc55 2945(define_insn "*nmuldf3"
0551c32d 2946 [(set (match_operand:DF 0 "fr_register_operand" "=f")
6adb807e
SE
2947 (neg:DF (mult:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
2948 (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG"))))]
c65ebc55 2949 ""
6adb807e 2950 "fnmpy.d %0 = %F1, %F2"
52e12ad0 2951 [(set_attr "itanium_class" "fmac")])
c65ebc55 2952
26102535
RH
2953(define_insn "*nmuldf3_trunc"
2954 [(set (match_operand:SF 0 "fr_register_operand" "=f")
2955 (float_truncate:SF
6adb807e
SE
2956 (neg:DF (mult:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
2957 (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")))))]
26102535 2958 ""
6adb807e 2959 "fnmpy.s %0 = %F1, %F2"
52e12ad0 2960 [(set_attr "itanium_class" "fmac")])
26102535 2961
655f2eb9 2962(define_insn "*nmadddf4"
0551c32d 2963 [(set (match_operand:DF 0 "fr_register_operand" "=f")
52ad4d7b 2964 (minus:DF (match_operand:DF 3 "fr_reg_or_fp01_operand" "fG")
6adb807e
SE
2965 (mult:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
2966 (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG"))))]
583ca921 2967 "TARGET_FUSED_MADD"
6adb807e 2968 "fnma.d %0 = %F1, %F2, %F3"
52e12ad0 2969 [(set_attr "itanium_class" "fmac")])
26102535 2970
52ad4d7b 2971(define_insn "*nmadddf4_truncsf"
26102535
RH
2972 [(set (match_operand:SF 0 "fr_register_operand" "=f")
2973 (float_truncate:SF
52ad4d7b 2974 (minus:DF (match_operand:DF 3 "fr_reg_or_fp01_operand" "fG")
6adb807e
SE
2975 (mult:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
2976 (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")))))]
583ca921 2977 "TARGET_FUSED_MADD"
6adb807e 2978 "fnma.s %0 = %F1, %F2, %F3"
52e12ad0 2979 [(set_attr "itanium_class" "fmac")])
3f622353
RH
2980\f
2981;; ::::::::::::::::::::
2982;; ::
27a9b99d 2983;; :: 80-bit floating point arithmetic
3f622353
RH
2984;; ::
2985;; ::::::::::::::::::::
2986
02befdf4
ZW
2987(define_insn "addxf3"
2988 [(set (match_operand:XF 0 "fr_register_operand" "=f")
33974673
SE
2989 (plus:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "%fG")
2990 (match_operand:XF 2 "xfreg_or_signed_fp01_operand" "fZ")))]
02befdf4 2991 ""
aebf2462 2992 "fadd %0 = %F1, %F2"
52e12ad0 2993 [(set_attr "itanium_class" "fmac")])
3f622353 2994
02befdf4 2995(define_insn "*addxf3_truncsf"
26102535
RH
2996 [(set (match_operand:SF 0 "fr_register_operand" "=f")
2997 (float_truncate:SF
33974673
SE
2998 (plus:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "%fG")
2999 (match_operand:XF 2 "xfreg_or_signed_fp01_operand" "fZ"))))]
02befdf4 3000 ""
aebf2462 3001 "fadd.s %0 = %F1, %F2"
52e12ad0 3002 [(set_attr "itanium_class" "fmac")])
26102535 3003
02befdf4 3004(define_insn "*addxf3_truncdf"
26102535
RH
3005 [(set (match_operand:DF 0 "fr_register_operand" "=f")
3006 (float_truncate:DF
33974673
SE
3007 (plus:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "%fG")
3008 (match_operand:XF 2 "xfreg_or_signed_fp01_operand" "fZ"))))]
02befdf4 3009 ""
aebf2462 3010 "fadd.d %0 = %F1, %F2"
52e12ad0 3011 [(set_attr "itanium_class" "fmac")])
26102535 3012
02befdf4
ZW
3013(define_insn "subxf3"
3014 [(set (match_operand:XF 0 "fr_register_operand" "=f")
3015 (minus:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
33974673 3016 (match_operand:XF 2 "xfreg_or_signed_fp01_operand" "fZ")))]
02befdf4 3017 ""
aebf2462 3018 "fsub %0 = %F1, %F2"
52e12ad0 3019 [(set_attr "itanium_class" "fmac")])
3f622353 3020
02befdf4 3021(define_insn "*subxf3_truncsf"
26102535
RH
3022 [(set (match_operand:SF 0 "fr_register_operand" "=f")
3023 (float_truncate:SF
02befdf4 3024 (minus:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
33974673 3025 (match_operand:XF 2 "xfreg_or_signed_fp01_operand" "fZ"))))]
02befdf4 3026 ""
aebf2462 3027 "fsub.s %0 = %F1, %F2"
52e12ad0 3028 [(set_attr "itanium_class" "fmac")])
26102535 3029
02befdf4 3030(define_insn "*subxf3_truncdf"
26102535
RH
3031 [(set (match_operand:DF 0 "fr_register_operand" "=f")
3032 (float_truncate:DF
02befdf4 3033 (minus:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
33974673 3034 (match_operand:XF 2 "xfreg_or_signed_fp01_operand" "fZ"))))]
02befdf4 3035 ""
aebf2462 3036 "fsub.d %0 = %F1, %F2"
52e12ad0 3037 [(set_attr "itanium_class" "fmac")])
26102535 3038
02befdf4
ZW
3039(define_insn "mulxf3"
3040 [(set (match_operand:XF 0 "fr_register_operand" "=f")
3041 (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3042 (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")))]
3043 ""
aebf2462 3044 "fmpy %0 = %F1, %F2"
52e12ad0 3045 [(set_attr "itanium_class" "fmac")])
3f622353 3046
02befdf4 3047(define_insn "*mulxf3_truncsf"
26102535
RH
3048 [(set (match_operand:SF 0 "fr_register_operand" "=f")
3049 (float_truncate:SF
02befdf4
ZW
3050 (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3051 (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))))]
3052 ""
aebf2462 3053 "fmpy.s %0 = %F1, %F2"
52e12ad0 3054 [(set_attr "itanium_class" "fmac")])
26102535 3055
02befdf4 3056(define_insn "*mulxf3_truncdf"
26102535
RH
3057 [(set (match_operand:DF 0 "fr_register_operand" "=f")
3058 (float_truncate:DF
02befdf4
ZW
3059 (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3060 (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))))]
3061 ""
aebf2462 3062 "fmpy.d %0 = %F1, %F2"
52e12ad0 3063 [(set_attr "itanium_class" "fmac")])
26102535 3064
02befdf4
ZW
3065(define_insn "absxf2"
3066 [(set (match_operand:XF 0 "fr_register_operand" "=f")
3067 (abs:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")))]
3068 ""
aebf2462 3069 "fabs %0 = %F1"
52e12ad0 3070 [(set_attr "itanium_class" "fmisc")])
3f622353 3071
02befdf4
ZW
3072(define_insn "negxf2"
3073 [(set (match_operand:XF 0 "fr_register_operand" "=f")
3074 (neg:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")))]
3075 ""
aebf2462 3076 "fneg %0 = %F1"
52e12ad0 3077 [(set_attr "itanium_class" "fmisc")])
3f622353 3078
02befdf4
ZW
3079(define_insn "*nabsxf2"
3080 [(set (match_operand:XF 0 "fr_register_operand" "=f")
3081 (neg:XF (abs:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG"))))]
3082 ""
aebf2462 3083 "fnegabs %0 = %F1"
52e12ad0 3084 [(set_attr "itanium_class" "fmisc")])
3f622353 3085
046625fa
RH
3086(define_insn "copysignxf3"
3087 [(set (match_operand:XF 0 "register_operand" "=f")
3088 (unspec:XF [(match_operand:XF 1 "fr_reg_or_fp01_operand" "fG")
3089 (match_operand:XF 2 "fr_reg_or_fp01_operand" "fG")]
3090 UNSPEC_COPYSIGN))]
3091 ""
3092 "fmerge.s %0 = %F2, %F1"
3093 [(set_attr "itanium_class" "fmisc")])
3094
3095(define_insn "*ncopysignxf3"
3096 [(set (match_operand:XF 0 "register_operand" "=f")
3097 (neg:XF (unspec:XF [(match_operand:XF 1 "fr_reg_or_fp01_operand" "fG")
3098 (match_operand:XF 2 "fr_reg_or_fp01_operand" "fG")]
3099 UNSPEC_COPYSIGN)))]
3100 ""
3101 "fmerge.ns %0 = %F2, %F1"
3102 [(set_attr "itanium_class" "fmisc")])
3103
7ae4d8d4 3104(define_insn "sminxf3"
02befdf4
ZW
3105 [(set (match_operand:XF 0 "fr_register_operand" "=f")
3106 (smin:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3107 (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")))]
3108 ""
aebf2462 3109 "fmin %0 = %F1, %F2"
52e12ad0 3110 [(set_attr "itanium_class" "fmisc")])
3f622353 3111
7ae4d8d4 3112(define_insn "smaxxf3"
02befdf4
ZW
3113 [(set (match_operand:XF 0 "fr_register_operand" "=f")
3114 (smax:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3115 (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")))]
3116 ""
aebf2462 3117 "fmax %0 = %F1, %F2"
52e12ad0 3118 [(set_attr "itanium_class" "fmisc")])
3f622353 3119
02befdf4
ZW
3120(define_insn "*maddxf4"
3121 [(set (match_operand:XF 0 "fr_register_operand" "=f")
3122 (plus:XF (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3123 (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))
33974673 3124 (match_operand:XF 3 "xfreg_or_signed_fp01_operand" "fZ")))]
583ca921 3125 "TARGET_FUSED_MADD"
aebf2462 3126 "fma %0 = %F1, %F2, %F3"
52e12ad0 3127 [(set_attr "itanium_class" "fmac")])
3f622353 3128
02befdf4 3129(define_insn "*maddxf4_truncsf"
26102535
RH
3130 [(set (match_operand:SF 0 "fr_register_operand" "=f")
3131 (float_truncate:SF
02befdf4
ZW
3132 (plus:XF (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3133 (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))
33974673 3134 (match_operand:XF 3 "xfreg_or_signed_fp01_operand" "fZ"))))]
583ca921 3135 "TARGET_FUSED_MADD"
aebf2462 3136 "fma.s %0 = %F1, %F2, %F3"
52e12ad0 3137 [(set_attr "itanium_class" "fmac")])
26102535 3138
02befdf4 3139(define_insn "*maddxf4_truncdf"
26102535
RH
3140 [(set (match_operand:DF 0 "fr_register_operand" "=f")
3141 (float_truncate:DF
02befdf4
ZW
3142 (plus:XF (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3143 (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))
33974673 3144 (match_operand:XF 3 "xfreg_or_signed_fp01_operand" "fZ"))))]
583ca921 3145 "TARGET_FUSED_MADD"
aebf2462 3146 "fma.d %0 = %F1, %F2, %F3"
52e12ad0 3147 [(set_attr "itanium_class" "fmac")])
26102535 3148
02befdf4
ZW
3149(define_insn "*msubxf4"
3150 [(set (match_operand:XF 0 "fr_register_operand" "=f")
3151 (minus:XF (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3152 (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))
33974673 3153 (match_operand:XF 3 "xfreg_or_signed_fp01_operand" "fZ")))]
583ca921 3154 "TARGET_FUSED_MADD"
aebf2462 3155 "fms %0 = %F1, %F2, %F3"
52e12ad0 3156 [(set_attr "itanium_class" "fmac")])
3f622353 3157
02befdf4 3158(define_insn "*msubxf4_truncsf"
26102535
RH
3159 [(set (match_operand:SF 0 "fr_register_operand" "=f")
3160 (float_truncate:SF
02befdf4
ZW
3161 (minus:XF (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3162 (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))
33974673 3163 (match_operand:XF 3 "xfreg_or_signed_fp01_operand" "fZ"))))]
583ca921 3164 "TARGET_FUSED_MADD"
aebf2462 3165 "fms.s %0 = %F1, %F2, %F3"
52e12ad0 3166 [(set_attr "itanium_class" "fmac")])
26102535 3167
02befdf4 3168(define_insn "*msubxf4_truncdf"
26102535
RH
3169 [(set (match_operand:DF 0 "fr_register_operand" "=f")
3170 (float_truncate:DF
02befdf4
ZW
3171 (minus:XF (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3172 (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))
33974673 3173 (match_operand:XF 3 "xfreg_or_signed_fp01_operand" "fZ"))))]
583ca921 3174 "TARGET_FUSED_MADD"
aebf2462 3175 "fms.d %0 = %F1, %F2, %F3"
52e12ad0 3176 [(set_attr "itanium_class" "fmac")])
26102535 3177
02befdf4
ZW
3178(define_insn "*nmulxf3"
3179 [(set (match_operand:XF 0 "fr_register_operand" "=f")
3180 (neg:XF (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3181 (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))))]
3182 ""
aebf2462 3183 "fnmpy %0 = %F1, %F2"
52e12ad0 3184 [(set_attr "itanium_class" "fmac")])
c65ebc55 3185
02befdf4 3186(define_insn "*nmulxf3_truncsf"
26102535
RH
3187 [(set (match_operand:SF 0 "fr_register_operand" "=f")
3188 (float_truncate:SF
02befdf4
ZW
3189 (neg:XF (mult:XF
3190 (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3191 (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")))))]
3192 ""
aebf2462 3193 "fnmpy.s %0 = %F1, %F2"
52e12ad0 3194 [(set_attr "itanium_class" "fmac")])
26102535 3195
02befdf4 3196(define_insn "*nmulxf3_truncdf"
26102535
RH
3197 [(set (match_operand:DF 0 "fr_register_operand" "=f")
3198 (float_truncate:DF
02befdf4
ZW
3199 (neg:XF (mult:XF
3200 (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3201 (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")))))]
3202 ""
aebf2462 3203 "fnmpy.d %0 = %F1, %F2"
52e12ad0 3204 [(set_attr "itanium_class" "fmac")])
26102535 3205
02befdf4
ZW
3206(define_insn "*nmaddxf4"
3207 [(set (match_operand:XF 0 "fr_register_operand" "=f")
52ad4d7b
ZW
3208 (minus:XF (match_operand:XF 3 "xfreg_or_fp01_operand" "fG")
3209 (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3210 (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")
3211 )))]
583ca921 3212 "TARGET_FUSED_MADD"
aebf2462 3213 "fnma %0 = %F1, %F2, %F3"
52e12ad0 3214 [(set_attr "itanium_class" "fmac")])
655f2eb9 3215
02befdf4 3216(define_insn "*nmaddxf4_truncsf"
26102535
RH
3217 [(set (match_operand:SF 0 "fr_register_operand" "=f")
3218 (float_truncate:SF
52ad4d7b
ZW
3219 (minus:XF (match_operand:XF 3 "xfreg_or_fp01_operand" "fG")
3220 (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3221 (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")
3222 ))))]
583ca921 3223 "TARGET_FUSED_MADD"
aebf2462 3224 "fnma.s %0 = %F1, %F2, %F3"
52e12ad0 3225 [(set_attr "itanium_class" "fmac")])
26102535 3226
02befdf4 3227(define_insn "*nmaddxf4_truncdf"
26102535
RH
3228 [(set (match_operand:DF 0 "fr_register_operand" "=f")
3229 (float_truncate:DF
52ad4d7b
ZW
3230 (minus:XF (match_operand:XF 3 "xfreg_or_fp01_operand" "fG")
3231 (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3232 (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")
3233 ))))]
583ca921 3234 "TARGET_FUSED_MADD"
aebf2462 3235 "fnma.d %0 = %F1, %F2, %F3"
52e12ad0 3236 [(set_attr "itanium_class" "fmac")])
c65ebc55
JW
3237\f
3238;; ::::::::::::::::::::
3239;; ::
27a9b99d 3240;; :: 32-bit Integer Shifts and Rotates
c65ebc55
JW
3241;; ::
3242;; ::::::::::::::::::::
3243
9c668921 3244(define_expand "ashlsi3"
0551c32d
RH
3245 [(set (match_operand:SI 0 "gr_register_operand" "")
3246 (ashift:SI (match_operand:SI 1 "gr_register_operand" "")
3247 (match_operand:SI 2 "gr_reg_or_5bit_operand" "")))]
9c668921 3248 ""
9c668921
RH
3249{
3250 if (GET_CODE (operands[2]) != CONST_INT)
3251 {
3252 /* Why oh why didn't Intel arrange for SHIFT_COUNT_TRUNCATED? Now
3253 we've got to get rid of stray bits outside the SImode register. */
3254 rtx subshift = gen_reg_rtx (DImode);
3255 emit_insn (gen_zero_extendsidi2 (subshift, operands[2]));
3256 operands[2] = subshift;
3257 }
1d5d7a21 3258})
9c668921
RH
3259
3260(define_insn "*ashlsi3_internal"
0551c32d
RH
3261 [(set (match_operand:SI 0 "gr_register_operand" "=r,r,r")
3262 (ashift:SI (match_operand:SI 1 "gr_register_operand" "r,r,r")
3263 (match_operand:DI 2 "gr_reg_or_5bit_operand" "R,n,r")))]
c65ebc55 3264 ""
041f25e6
RH
3265 "@
3266 shladd %0 = %1, %2, r0
3267 dep.z %0 = %1, %2, %E2
3268 shl %0 = %1, %2"
52e12ad0 3269 [(set_attr "itanium_class" "ialu,ishf,mmshf")])
c65ebc55
JW
3270
3271(define_expand "ashrsi3"
0551c32d
RH
3272 [(set (match_operand:SI 0 "gr_register_operand" "")
3273 (ashiftrt:SI (match_operand:SI 1 "gr_register_operand" "")
3274 (match_operand:SI 2 "gr_reg_or_5bit_operand" "")))]
c65ebc55 3275 ""
c65ebc55 3276{
041f25e6
RH
3277 rtx subtarget = gen_reg_rtx (DImode);
3278 if (GET_CODE (operands[2]) == CONST_INT)
3279 emit_insn (gen_extv (subtarget, gen_lowpart (DImode, operands[1]),
3280 GEN_INT (32 - INTVAL (operands[2])), operands[2]));
3281 else
3282 {
9c668921 3283 rtx subshift = gen_reg_rtx (DImode);
041f25e6 3284 emit_insn (gen_extendsidi2 (subtarget, operands[1]));
9c668921
RH
3285 emit_insn (gen_zero_extendsidi2 (subshift, operands[2]));
3286 emit_insn (gen_ashrdi3 (subtarget, subtarget, subshift));
041f25e6
RH
3287 }
3288 emit_move_insn (gen_lowpart (DImode, operands[0]), subtarget);
3289 DONE;
1d5d7a21 3290})
c65ebc55 3291
c65ebc55 3292(define_expand "lshrsi3"
0551c32d
RH
3293 [(set (match_operand:SI 0 "gr_register_operand" "")
3294 (lshiftrt:SI (match_operand:SI 1 "gr_register_operand" "")
3295 (match_operand:SI 2 "gr_reg_or_5bit_operand" "")))]
c65ebc55 3296 ""
c65ebc55 3297{
041f25e6
RH
3298 rtx subtarget = gen_reg_rtx (DImode);
3299 if (GET_CODE (operands[2]) == CONST_INT)
3300 emit_insn (gen_extzv (subtarget, gen_lowpart (DImode, operands[1]),
3301 GEN_INT (32 - INTVAL (operands[2])), operands[2]));
3302 else
3303 {
9c668921 3304 rtx subshift = gen_reg_rtx (DImode);
041f25e6 3305 emit_insn (gen_zero_extendsidi2 (subtarget, operands[1]));
9c668921
RH
3306 emit_insn (gen_zero_extendsidi2 (subshift, operands[2]));
3307 emit_insn (gen_lshrdi3 (subtarget, subtarget, subshift));
041f25e6
RH
3308 }
3309 emit_move_insn (gen_lowpart (DImode, operands[0]), subtarget);
3310 DONE;
1d5d7a21 3311})
c65ebc55 3312
c65ebc55 3313;; Use mix4.r/shr to implement rotrsi3. We only get 32 bits of valid result
66db6b45
RH
3314;; here, instead of 64 like the patterns above. Keep the pattern together
3315;; until after combine; otherwise it won't get matched often.
c65ebc55
JW
3316
3317(define_expand "rotrsi3"
66db6b45
RH
3318 [(set (match_operand:SI 0 "gr_register_operand" "")
3319 (rotatert:SI (match_operand:SI 1 "gr_register_operand" "")
3320 (match_operand:SI 2 "gr_reg_or_5bit_operand" "")))]
3321 ""
66db6b45
RH
3322{
3323 if (GET_MODE (operands[2]) != VOIDmode)
3324 {
3325 rtx tmp = gen_reg_rtx (DImode);
3326 emit_insn (gen_zero_extendsidi2 (tmp, operands[2]));
3327 operands[2] = tmp;
3328 }
1d5d7a21 3329})
66db6b45
RH
3330
3331(define_insn_and_split "*rotrsi3_internal"
3332 [(set (match_operand:SI 0 "gr_register_operand" "=&r")
3333 (rotatert:SI (match_operand:SI 1 "gr_register_operand" "r")
3334 (match_operand:DI 2 "gr_reg_or_5bit_operand" "rM")))]
3335 ""
3336 "#"
3337 "reload_completed"
c65ebc55 3338 [(set (match_dup 3)
66db6b45 3339 (ior:DI (zero_extend:DI (match_dup 1))
c65ebc55
JW
3340 (ashift:DI (zero_extend:DI (match_dup 1)) (const_int 32))))
3341 (set (match_dup 3)
66db6b45
RH
3342 (lshiftrt:DI (match_dup 3) (match_dup 2)))]
3343 "operands[3] = gen_rtx_REG (DImode, REGNO (operands[0]));")
3344
3345(define_expand "rotlsi3"
3346 [(set (match_operand:SI 0 "gr_register_operand" "")
3347 (rotate:SI (match_operand:SI 1 "gr_register_operand" "")
3348 (match_operand:SI 2 "gr_reg_or_5bit_operand" "")))]
c65ebc55 3349 ""
c65ebc55
JW
3350{
3351 if (! shift_32bit_count_operand (operands[2], SImode))
66db6b45
RH
3352 {
3353 rtx tmp = gen_reg_rtx (SImode);
3354 emit_insn (gen_subsi3 (tmp, GEN_INT (32), operands[2]));
3355 emit_insn (gen_rotrsi3 (operands[0], operands[1], tmp));
3356 DONE;
3357 }
1d5d7a21 3358})
66db6b45
RH
3359
3360(define_insn_and_split "*rotlsi3_internal"
3361 [(set (match_operand:SI 0 "gr_register_operand" "=r")
3362 (rotate:SI (match_operand:SI 1 "gr_register_operand" "r")
3363 (match_operand:SI 2 "shift_32bit_count_operand" "n")))]
3364 ""
51094457
JB
3365 "mux2 %0 = %1, 0xe1"
3366 "reload_completed && INTVAL (operands[2]) != 16"
66db6b45
RH
3367 [(set (match_dup 3)
3368 (ior:DI (zero_extend:DI (match_dup 1))
3369 (ashift:DI (zero_extend:DI (match_dup 1)) (const_int 32))))
3370 (set (match_dup 3)
3371 (lshiftrt:DI (match_dup 3) (match_dup 2)))]
1d5d7a21
RH
3372{
3373 operands[3] = gen_rtx_REG (DImode, REGNO (operands[0]));
3374 operands[2] = GEN_INT (32 - INTVAL (operands[2]));
51094457
JB
3375}
3376 [(set_attr "itanium_class" "mmshf")])
c65ebc55
JW
3377\f
3378;; ::::::::::::::::::::
3379;; ::
27a9b99d 3380;; :: 64-bit Integer Shifts and Rotates
c65ebc55
JW
3381;; ::
3382;; ::::::::::::::::::::
3383
3384(define_insn "ashldi3"
52e12ad0
BS
3385 [(set (match_operand:DI 0 "gr_register_operand" "=r,r,r")
3386 (ashift:DI (match_operand:DI 1 "gr_register_operand" "r,r,r")
3387 (match_operand:DI 2 "gr_reg_or_6bit_operand" "R,r,rM")))]
c65ebc55 3388 ""
041f25e6
RH
3389 "@
3390 shladd %0 = %1, %2, r0
52e12ad0 3391 shl %0 = %1, %2
041f25e6 3392 shl %0 = %1, %2"
52e12ad0 3393 [(set_attr "itanium_class" "ialu,mmshf,mmshfi")])
c65ebc55
JW
3394
3395;; ??? Maybe combine this with the multiply and add instruction?
3396
3397(define_insn "*shladd"
0551c32d
RH
3398 [(set (match_operand:DI 0 "gr_register_operand" "=r")
3399 (plus:DI (mult:DI (match_operand:DI 1 "gr_register_operand" "r")
c65ebc55 3400 (match_operand:DI 2 "shladd_operand" "n"))
0551c32d 3401 (match_operand:DI 3 "gr_register_operand" "r")))]
c65ebc55
JW
3402 ""
3403 "shladd %0 = %1, %S2, %3"
52e12ad0 3404 [(set_attr "itanium_class" "ialu")])
c65ebc55
JW
3405
3406;; This can be created by register elimination if operand3 of shladd is an
3407;; eliminable register or has reg_equiv_constant set.
3408
3409;; We have to use nonmemory_operand for operand 4, to ensure that the
3410;; validate_changes call inside eliminate_regs will always succeed. If it
3411;; doesn't succeed, then this remain a shladd pattern, and will be reloaded
3412;; incorrectly.
3413
5527bf14 3414(define_insn_and_split "*shladd_elim"
0551c32d
RH
3415 [(set (match_operand:DI 0 "gr_register_operand" "=&r")
3416 (plus:DI (plus:DI (mult:DI (match_operand:DI 1 "gr_register_operand" "r")
c65ebc55 3417 (match_operand:DI 2 "shladd_operand" "n"))
5527bf14 3418 (match_operand:DI 3 "nonmemory_operand" "r"))
c65ebc55
JW
3419 (match_operand:DI 4 "nonmemory_operand" "rI")))]
3420 "reload_in_progress"
e820471b 3421 "* gcc_unreachable ();"
c65ebc55
JW
3422 "reload_completed"
3423 [(set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (match_dup 2))
3424 (match_dup 3)))
c65ebc55 3425 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 4)))]
5527bf14 3426 ""
52e12ad0 3427 [(set_attr "itanium_class" "unknown")])
c65ebc55
JW
3428
3429(define_insn "ashrdi3"
52e12ad0
BS
3430 [(set (match_operand:DI 0 "gr_register_operand" "=r,r")
3431 (ashiftrt:DI (match_operand:DI 1 "gr_register_operand" "r,r")
3432 (match_operand:DI 2 "gr_reg_or_6bit_operand" "r,rM")))]
c65ebc55 3433 ""
52e12ad0
BS
3434 "@
3435 shr %0 = %1, %2
3436 shr %0 = %1, %2"
3437 [(set_attr "itanium_class" "mmshf,mmshfi")])
c65ebc55
JW
3438
3439(define_insn "lshrdi3"
52e12ad0
BS
3440 [(set (match_operand:DI 0 "gr_register_operand" "=r,r")
3441 (lshiftrt:DI (match_operand:DI 1 "gr_register_operand" "r,r")
3442 (match_operand:DI 2 "gr_reg_or_6bit_operand" "r,rM")))]
c65ebc55 3443 ""
52e12ad0
BS
3444 "@
3445 shr.u %0 = %1, %2
3446 shr.u %0 = %1, %2"
3447 [(set_attr "itanium_class" "mmshf,mmshfi")])
c65ebc55
JW
3448
3449;; Using a predicate that accepts only constants doesn't work, because optabs
3450;; will load the operand into a register and call the pattern if the predicate
3451;; did not accept it on the first try. So we use nonmemory_operand and then
3452;; verify that we have an appropriate constant in the expander.
3453
3454(define_expand "rotrdi3"
0551c32d
RH
3455 [(set (match_operand:DI 0 "gr_register_operand" "")
3456 (rotatert:DI (match_operand:DI 1 "gr_register_operand" "")
c65ebc55
JW
3457 (match_operand:DI 2 "nonmemory_operand" "")))]
3458 ""
c65ebc55
JW
3459{
3460 if (! shift_count_operand (operands[2], DImode))
3461 FAIL;
1d5d7a21 3462})
c65ebc55
JW
3463
3464(define_insn "*rotrdi3_internal"
0551c32d
RH
3465 [(set (match_operand:DI 0 "gr_register_operand" "=r")
3466 (rotatert:DI (match_operand:DI 1 "gr_register_operand" "r")
c65ebc55
JW
3467 (match_operand:DI 2 "shift_count_operand" "M")))]
3468 ""
3469 "shrp %0 = %1, %1, %2"
52e12ad0 3470 [(set_attr "itanium_class" "ishf")])
c65ebc55 3471
66db6b45
RH
3472(define_expand "rotldi3"
3473 [(set (match_operand:DI 0 "gr_register_operand" "")
3474 (rotate:DI (match_operand:DI 1 "gr_register_operand" "")
3475 (match_operand:DI 2 "nonmemory_operand" "")))]
3476 ""
66db6b45
RH
3477{
3478 if (! shift_count_operand (operands[2], DImode))
3479 FAIL;
1d5d7a21 3480})
66db6b45
RH
3481
3482(define_insn "*rotldi3_internal"
3483 [(set (match_operand:DI 0 "gr_register_operand" "=r")
3484 (rotate:DI (match_operand:DI 1 "gr_register_operand" "r")
3485 (match_operand:DI 2 "shift_count_operand" "M")))]
3486 ""
3487 "shrp %0 = %1, %1, %e2"
52e12ad0 3488 [(set_attr "itanium_class" "ishf")])
f526a3c8
RH
3489\f
3490;; ::::::::::::::::::::
3491;; ::
27a9b99d 3492;; :: 128-bit Integer Shifts and Rotates
f526a3c8
RH
3493;; ::
3494;; ::::::::::::::::::::
3495
16d8386b
JB
3496(define_expand "ashlti3"
3497 [(set (match_operand:TI 0 "gr_register_operand" "")
3498 (ashift:TI (match_operand:TI 1 "gr_register_operand" "")
3499 (match_operand:DI 2 "nonmemory_operand" "")))]
3500 ""
3501{
3502 if (!dshift_count_operand (operands[2], DImode))
3503 FAIL;
3504})
3505
3506(define_insn_and_split "*ashlti3_internal"
3507 [(set (match_operand:TI 0 "gr_register_operand" "=&r")
3508 (ashift:TI (match_operand:TI 1 "gr_register_operand" "r")
3509 (match_operand:DI 2 "dshift_count_operand" "n")))]
3510 ""
3511 "#"
3512 "reload_completed"
3513 [(const_int 0)]
3514{
3515 HOST_WIDE_INT shift = INTVAL (operands[2]);
3516 rtx rl = gen_lowpart (DImode, operands[0]);
3517 rtx rh = gen_highpart (DImode, operands[0]);
3518 rtx lo = gen_lowpart (DImode, operands[1]);
3519 rtx shiftlo = GEN_INT (shift & 63);
3520
3521 if (shift & 64)
3522 {
3523 emit_move_insn (rl, const0_rtx);
3524 if (shift & 63)
3525 emit_insn (gen_ashldi3 (rh, lo, shiftlo));
3526 else
3527 emit_move_insn (rh, lo);
3528 }
3529 else
3530 {
3531 rtx hi = gen_highpart (DImode, operands[1]);
3532
3533 emit_insn (gen_shrp (rh, hi, lo, GEN_INT (-shift & 63)));
3534 emit_insn (gen_ashldi3 (rl, lo, shiftlo));
3535 }
3536 DONE;
3537})
3538
f526a3c8
RH
3539(define_expand "ashrti3"
3540 [(set (match_operand:TI 0 "gr_register_operand" "")
3541 (ashiftrt:TI (match_operand:TI 1 "gr_register_operand" "")
3542 (match_operand:DI 2 "nonmemory_operand" "")))]
3543 ""
3544{
3545 if (!dshift_count_operand (operands[2], DImode))
3546 FAIL;
3547})
3548
3549(define_insn_and_split "*ashrti3_internal"
16d8386b 3550 [(set (match_operand:TI 0 "gr_register_operand" "=&r")
f526a3c8
RH
3551 (ashiftrt:TI (match_operand:TI 1 "gr_register_operand" "r")
3552 (match_operand:DI 2 "dshift_count_operand" "n")))]
3553 ""
3554 "#"
3555 "reload_completed"
3556 [(const_int 0)]
3557{
3558 HOST_WIDE_INT shift = INTVAL (operands[2]);
16d8386b
JB
3559 rtx rl = gen_lowpart (DImode, operands[0]);
3560 rtx rh = gen_highpart (DImode, operands[0]);
f526a3c8
RH
3561 rtx hi = gen_highpart (DImode, operands[1]);
3562 rtx shiftlo = GEN_INT (shift & 63);
3563
3564 if (shift & 64)
3565 {
16d8386b
JB
3566 if (shift & 63)
3567 emit_insn (gen_ashrdi3 (rl, hi, shiftlo));
3568 else
3569 emit_move_insn (rl, hi);
3570 emit_insn (gen_ashrdi3 (rh, hi, GEN_INT (63)));
f526a3c8
RH
3571 }
3572 else
3573 {
16d8386b
JB
3574 rtx lo = gen_lowpart (DImode, operands[1]);
3575
3576 emit_insn (gen_shrp (rl, hi, lo, shiftlo));
3577 emit_insn (gen_ashrdi3 (rh, hi, shiftlo));
f526a3c8
RH
3578 }
3579 DONE;
3580})
3581
3582(define_expand "lshrti3"
3583 [(set (match_operand:TI 0 "gr_register_operand" "")
3584 (lshiftrt:TI (match_operand:TI 1 "gr_register_operand" "")
3585 (match_operand:DI 2 "nonmemory_operand" "")))]
3586 ""
3587{
3588 if (!dshift_count_operand (operands[2], DImode))
3589 FAIL;
3590})
3591
3592(define_insn_and_split "*lshrti3_internal"
16d8386b 3593 [(set (match_operand:TI 0 "gr_register_operand" "=&r")
f526a3c8
RH
3594 (lshiftrt:TI (match_operand:TI 1 "gr_register_operand" "r")
3595 (match_operand:DI 2 "dshift_count_operand" "n")))]
3596 ""
3597 "#"
3598 "reload_completed"
3599 [(const_int 0)]
3600{
3601 HOST_WIDE_INT shift = INTVAL (operands[2]);
16d8386b
JB
3602 rtx rl = gen_lowpart (DImode, operands[0]);
3603 rtx rh = gen_highpart (DImode, operands[0]);
f526a3c8
RH
3604 rtx hi = gen_highpart (DImode, operands[1]);
3605 rtx shiftlo = GEN_INT (shift & 63);
3606
3607 if (shift & 64)
3608 {
16d8386b
JB
3609 if (shift & 63)
3610 emit_insn (gen_lshrdi3 (rl, hi, shiftlo));
3611 else
3612 emit_move_insn (rl, hi);
3613 emit_move_insn (rh, const0_rtx);
f526a3c8
RH
3614 }
3615 else
3616 {
16d8386b
JB
3617 rtx lo = gen_lowpart (DImode, operands[1]);
3618
3619 emit_insn (gen_shrp (rl, hi, lo, shiftlo));
3620 emit_insn (gen_lshrdi3 (rh, hi, shiftlo));
f526a3c8
RH
3621 }
3622 DONE;
3623})
3624
a71aef0b
JB
3625(define_expand "rotlti3"
3626 [(set (match_operand:TI 0 "gr_register_operand" "")
3627 (rotate:TI (match_operand:TI 1 "gr_register_operand" "")
3628 (match_operand:DI 2 "nonmemory_operand" "")))]
3629 ""
3630{
3631 if (! dshift_count_operand (operands[2], DImode))
3632 FAIL;
3633})
3634
3635(define_insn_and_split "*rotlti3_internal"
3636 [(set (match_operand:TI 0 "gr_register_operand" "=&r")
3637 (rotate:TI (match_operand:TI 1 "gr_register_operand" "r")
3638 (match_operand:DI 2 "dshift_count_operand" "n")))]
3639 ""
3640 "#"
3641 "reload_completed"
3642 [(const_int 0)]
3643{
3644 HOST_WIDE_INT count = INTVAL (operands[2]);
3645 rtx rl = gen_lowpart (DImode, operands[0]);
3646 rtx rh = gen_highpart (DImode, operands[0]);
3647 rtx lo = gen_lowpart (DImode, operands[1]);
3648 rtx hi = gen_highpart (DImode, operands[1]);
3649 rtx countlo = GEN_INT (-count & 63);
3650
3651 if (count & 64)
3652 {
3653 if (count & 63)
3654 {
3655 emit_insn (gen_shrp (rl, hi, lo, countlo));
3656 emit_insn (gen_shrp (rh, lo, hi, countlo));
3657 }
3658 else
3659 {
3660 emit_move_insn (rl, hi);
3661 emit_move_insn (rh, lo);
3662 }
3663 }
3664 else
3665 {
3666 emit_insn (gen_shrp (rl, lo, hi, countlo));
3667 emit_insn (gen_shrp (rh, hi, lo, countlo));
3668 }
3669 DONE;
3670}
3671 [(set_attr "itanium_class" "unknown")])
3672
f526a3c8
RH
3673(define_insn "shrp"
3674 [(set (match_operand:DI 0 "gr_register_operand" "=r")
3675 (unspec:DI [(match_operand:DI 1 "gr_register_operand" "r")
3676 (match_operand:DI 2 "gr_register_operand" "r")
3677 (match_operand:DI 3 "shift_count_operand" "M")]
3678 UNSPEC_SHRP))]
3679 ""
3680 "shrp %0 = %1, %2, %3"
3681 [(set_attr "itanium_class" "ishf")])
c65ebc55
JW
3682\f
3683;; ::::::::::::::::::::
3684;; ::
27a9b99d 3685;; :: 32-bit Integer Logical operations
c65ebc55
JW
3686;; ::
3687;; ::::::::::::::::::::
3688
3689;; We don't seem to need any other 32-bit logical operations, because gcc
3690;; generates zero-extend;zero-extend;DImode-op, which combine optimizes to
3691;; DImode-op;zero-extend, and then we can optimize away the zero-extend.
3692;; This doesn't work for unary logical operations, because we don't call
3693;; apply_distributive_law for them.
3694
3695;; ??? Likewise, this doesn't work for andnot, which isn't handled by
3696;; apply_distributive_law. We get inefficient code for
3697;; int sub4 (int i, int j) { return i & ~j; }
3698;; We could convert (and (not (sign_extend A)) (sign_extend B)) to
3699;; (zero_extend (and (not A) B)) in combine.
3700;; Or maybe fix this by adding andsi3/iorsi3/xorsi3 patterns like the
3701;; one_cmplsi2 pattern.
3702
058557c4 3703(define_insn "one_cmplsi2"
0551c32d
RH
3704 [(set (match_operand:SI 0 "gr_register_operand" "=r")
3705 (not:SI (match_operand:SI 1 "gr_register_operand" "r")))]
c65ebc55
JW
3706 ""
3707 "andcm %0 = -1, %1"
52e12ad0 3708 [(set_attr "itanium_class" "ilog")])
c65ebc55
JW
3709\f
3710;; ::::::::::::::::::::
3711;; ::
27a9b99d 3712;; :: 64-bit Integer Logical operations
c65ebc55
JW
3713;; ::
3714;; ::::::::::::::::::::
3715
3716(define_insn "anddi3"
0551c32d
RH
3717 [(set (match_operand:DI 0 "grfr_register_operand" "=r,*f")
3718 (and:DI (match_operand:DI 1 "grfr_register_operand" "%r,*f")
3719 (match_operand:DI 2 "grfr_reg_or_8bit_operand" "rK,*f")))]
c65ebc55
JW
3720 ""
3721 "@
3722 and %0 = %2, %1
aebf2462 3723 fand %0 = %2, %1"
52e12ad0 3724 [(set_attr "itanium_class" "ilog,fmisc")])
c65ebc55
JW
3725
3726(define_insn "*andnot"
0551c32d
RH
3727 [(set (match_operand:DI 0 "grfr_register_operand" "=r,*f")
3728 (and:DI (not:DI (match_operand:DI 1 "grfr_register_operand" "r,*f"))
3729 (match_operand:DI 2 "grfr_reg_or_8bit_operand" "rK,*f")))]
c65ebc55
JW
3730 ""
3731 "@
3732 andcm %0 = %2, %1
aebf2462 3733 fandcm %0 = %2, %1"
52e12ad0 3734 [(set_attr "itanium_class" "ilog,fmisc")])
c65ebc55
JW
3735
3736(define_insn "iordi3"
0551c32d
RH
3737 [(set (match_operand:DI 0 "grfr_register_operand" "=r,*f")
3738 (ior:DI (match_operand:DI 1 "grfr_register_operand" "%r,*f")
3739 (match_operand:DI 2 "grfr_reg_or_8bit_operand" "rK,*f")))]
c65ebc55
JW
3740 ""
3741 "@
3742 or %0 = %2, %1
aebf2462 3743 for %0 = %2, %1"
52e12ad0 3744 [(set_attr "itanium_class" "ilog,fmisc")])
c65ebc55
JW
3745
3746(define_insn "xordi3"
0551c32d
RH
3747 [(set (match_operand:DI 0 "grfr_register_operand" "=r,*f")
3748 (xor:DI (match_operand:DI 1 "grfr_register_operand" "%r,*f")
3749 (match_operand:DI 2 "grfr_reg_or_8bit_operand" "rK,*f")))]
c65ebc55
JW
3750 ""
3751 "@
3752 xor %0 = %2, %1
aebf2462 3753 fxor %0 = %2, %1"
52e12ad0 3754 [(set_attr "itanium_class" "ilog,fmisc")])
c65ebc55
JW
3755
3756(define_insn "one_cmpldi2"
0551c32d
RH
3757 [(set (match_operand:DI 0 "gr_register_operand" "=r")
3758 (not:DI (match_operand:DI 1 "gr_register_operand" "r")))]
c65ebc55
JW
3759 ""
3760 "andcm %0 = -1, %1"
52e12ad0 3761 [(set_attr "itanium_class" "ilog")])
c65ebc55
JW
3762\f
3763;; ::::::::::::::::::::
3764;; ::
3765;; :: Comparisons
3766;; ::
3767;; ::::::::::::::::::::
3768
f90b7a5a
PB
3769(define_expand "cbranchbi4"
3770 [(set (pc)
3771 (if_then_else (match_operator 0 "ia64_cbranch_operator"
3772 [(match_operand:BI 1 "register_operand" "")
3773 (match_operand:BI 2 "const_int_operand" "")])
3774 (label_ref (match_operand 3 "" ""))
3775 (pc)))]
f2f90c63 3776 ""
f90b7a5a 3777 "ia64_expand_compare (&operands[0], &operands[1], &operands[2]);")
f2f90c63 3778
f90b7a5a
PB
3779(define_expand "cbranchsi4"
3780 [(set (pc)
3781 (if_then_else (match_operator 0 "ia64_cbranch_operator"
3782 [(match_operand:SI 1 "gr_register_operand" "")
3783 (match_operand:SI 2 "gr_reg_or_8bit_and_adjusted_operand" "")])
3784 (label_ref (match_operand 3 "" ""))
3785 (pc)))]
c65ebc55 3786 ""
f90b7a5a 3787 "ia64_expand_compare (&operands[0], &operands[1], &operands[2]);")
c65ebc55 3788
f90b7a5a
PB
3789(define_expand "cbranchdi4"
3790 [(set (pc)
3791 (if_then_else (match_operator 0 "ia64_cbranch_operator"
3792 [(match_operand:DI 1 "gr_register_operand" "")
3793 (match_operand:DI 2 "gr_reg_or_8bit_and_adjusted_operand" "")])
3794 (label_ref (match_operand 3 "" ""))
3795 (pc)))]
c65ebc55 3796 ""
f90b7a5a 3797 "ia64_expand_compare (&operands[0], &operands[1], &operands[2]);")
c65ebc55 3798
f90b7a5a
PB
3799(define_expand "cbranchsf4"
3800 [(set (pc)
3801 (if_then_else (match_operator 0 "ia64_cbranch_operator"
3802 [(match_operand:SF 1 "fr_reg_or_fp01_operand" "")
3803 (match_operand:SF 2 "fr_reg_or_fp01_operand" "")])
3804 (label_ref (match_operand 3 "" ""))
3805 (pc)))]
c65ebc55 3806 ""
f90b7a5a 3807 "ia64_expand_compare (&operands[0], &operands[1], &operands[2]);")
c65ebc55 3808
f90b7a5a
PB
3809(define_expand "cbranchdf4"
3810 [(set (pc)
3811 (if_then_else (match_operator 0 "ia64_cbranch_operator"
3812 [(match_operand:DF 1 "fr_reg_or_fp01_operand" "")
3813 (match_operand:DF 2 "fr_reg_or_fp01_operand" "")])
3814 (label_ref (match_operand 3 "" ""))
3815 (pc)))]
c65ebc55 3816 ""
f90b7a5a 3817 "ia64_expand_compare (&operands[0], &operands[1], &operands[2]);")
c65ebc55 3818
f90b7a5a
PB
3819(define_expand "cbranchxf4"
3820 [(set (pc)
3821 (if_then_else (match_operator 0 "ia64_cbranch_operator"
3822 [(match_operand:XF 1 "xfreg_or_fp01_operand" "")
3823 (match_operand:XF 2 "xfreg_or_fp01_operand" "")])
3824 (label_ref (match_operand 3 "" ""))
3825 (pc)))]
02befdf4 3826 ""
f90b7a5a 3827 "ia64_expand_compare (&operands[0], &operands[1], &operands[2]);")
c65ebc55 3828
f90b7a5a
PB
3829(define_expand "cbranchtf4"
3830 [(set (pc)
3831 (if_then_else (match_operator 0 "ia64_cbranch_operator"
3832 [(match_operand:TF 1 "gr_register_operand" "")
3833 (match_operand:TF 2 "gr_register_operand" "")])
3834 (label_ref (match_operand 3 "" ""))
3835 (pc)))]
24ea7948 3836 "TARGET_HPUX"
f90b7a5a
PB
3837 "ia64_expand_compare (&operands[0], &operands[1], &operands[2]);")
3838
24ea7948 3839
c65ebc55 3840(define_insn "*cmpsi_normal"
f2f90c63
RH
3841 [(set (match_operand:BI 0 "register_operand" "=c")
3842 (match_operator:BI 1 "normal_comparison_operator"
0551c32d
RH
3843 [(match_operand:SI 2 "gr_register_operand" "r")
3844 (match_operand:SI 3 "gr_reg_or_8bit_operand" "rK")]))]
c65ebc55
JW
3845 ""
3846 "cmp4.%C1 %0, %I0 = %3, %2"
52e12ad0 3847 [(set_attr "itanium_class" "icmp")])
c65ebc55 3848
18a3c539
JW
3849;; We use %r3 because it is possible for us to match a 0, and two of the
3850;; unsigned comparisons don't accept immediate operands of zero.
3851
c65ebc55 3852(define_insn "*cmpsi_adjusted"
f2f90c63
RH
3853 [(set (match_operand:BI 0 "register_operand" "=c")
3854 (match_operator:BI 1 "adjusted_comparison_operator"
0551c32d
RH
3855 [(match_operand:SI 2 "gr_register_operand" "r")
3856 (match_operand:SI 3 "gr_reg_or_8bit_adjusted_operand" "rL")]))]
c65ebc55 3857 ""
18a3c539 3858 "cmp4.%C1 %0, %I0 = %r3, %2"
52e12ad0 3859 [(set_attr "itanium_class" "icmp")])
c65ebc55
JW
3860
3861(define_insn "*cmpdi_normal"
f2f90c63
RH
3862 [(set (match_operand:BI 0 "register_operand" "=c")
3863 (match_operator:BI 1 "normal_comparison_operator"
3864 [(match_operand:DI 2 "gr_reg_or_0_operand" "rO")
0551c32d 3865 (match_operand:DI 3 "gr_reg_or_8bit_operand" "rK")]))]
c65ebc55 3866 ""
f2f90c63 3867 "cmp.%C1 %0, %I0 = %3, %r2"
52e12ad0 3868 [(set_attr "itanium_class" "icmp")])
c65ebc55 3869
18a3c539
JW
3870;; We use %r3 because it is possible for us to match a 0, and two of the
3871;; unsigned comparisons don't accept immediate operands of zero.
3872
c65ebc55 3873(define_insn "*cmpdi_adjusted"
f2f90c63
RH
3874 [(set (match_operand:BI 0 "register_operand" "=c")
3875 (match_operator:BI 1 "adjusted_comparison_operator"
0551c32d
RH
3876 [(match_operand:DI 2 "gr_register_operand" "r")
3877 (match_operand:DI 3 "gr_reg_or_8bit_adjusted_operand" "rL")]))]
c65ebc55 3878 ""
18a3c539 3879 "cmp.%C1 %0, %I0 = %r3, %2"
52e12ad0 3880 [(set_attr "itanium_class" "icmp")])
c65ebc55
JW
3881
3882(define_insn "*cmpsf_internal"
f2f90c63
RH
3883 [(set (match_operand:BI 0 "register_operand" "=c")
3884 (match_operator:BI 1 "comparison_operator"
0551c32d
RH
3885 [(match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")
3886 (match_operand:SF 3 "fr_reg_or_fp01_operand" "fG")]))]
c65ebc55
JW
3887 ""
3888 "fcmp.%D1 %0, %I0 = %F2, %F3"
52e12ad0 3889 [(set_attr "itanium_class" "fcmp")])
c65ebc55
JW
3890
3891(define_insn "*cmpdf_internal"
f2f90c63
RH
3892 [(set (match_operand:BI 0 "register_operand" "=c")
3893 (match_operator:BI 1 "comparison_operator"
0551c32d
RH
3894 [(match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")
3895 (match_operand:DF 3 "fr_reg_or_fp01_operand" "fG")]))]
c65ebc55
JW
3896 ""
3897 "fcmp.%D1 %0, %I0 = %F2, %F3"
52e12ad0 3898 [(set_attr "itanium_class" "fcmp")])
c65ebc55 3899
02befdf4 3900(define_insn "*cmpxf_internal"
f2f90c63
RH
3901 [(set (match_operand:BI 0 "register_operand" "=c")
3902 (match_operator:BI 1 "comparison_operator"
02befdf4
ZW
3903 [(match_operand:XF 2 "xfreg_or_fp01_operand" "fG")
3904 (match_operand:XF 3 "xfreg_or_fp01_operand" "fG")]))]
3905 ""
3f622353 3906 "fcmp.%D1 %0, %I0 = %F2, %F3"
52e12ad0 3907 [(set_attr "itanium_class" "fcmp")])
3f622353 3908
c65ebc55
JW
3909;; ??? Can this pattern be generated?
3910
3911(define_insn "*bit_zero"
f2f90c63
RH
3912 [(set (match_operand:BI 0 "register_operand" "=c")
3913 (eq:BI (zero_extract:DI (match_operand:DI 1 "gr_register_operand" "r")
c65ebc55 3914 (const_int 1)
5d48891e 3915 (match_operand:DI 2 "shift_count_operand" "M"))
c65ebc55
JW
3916 (const_int 0)))]
3917 ""
3918 "tbit.z %0, %I0 = %1, %2"
52e12ad0 3919 [(set_attr "itanium_class" "tbit")])
c65ebc55
JW
3920
3921(define_insn "*bit_one"
f2f90c63
RH
3922 [(set (match_operand:BI 0 "register_operand" "=c")
3923 (ne:BI (zero_extract:DI (match_operand:DI 1 "gr_register_operand" "r")
c65ebc55 3924 (const_int 1)
5d48891e 3925 (match_operand:DI 2 "shift_count_operand" "M"))
c65ebc55
JW
3926 (const_int 0)))]
3927 ""
3928 "tbit.nz %0, %I0 = %1, %2"
52e12ad0 3929 [(set_attr "itanium_class" "tbit")])
c65ebc55
JW
3930\f
3931;; ::::::::::::::::::::
3932;; ::
3933;; :: Branches
3934;; ::
3935;; ::::::::::::::::::::
3936
6b6c1201 3937(define_insn "*br_true"
c65ebc55 3938 [(set (pc)
6b6c1201 3939 (if_then_else (match_operator 0 "predicate_operator"
f2f90c63 3940 [(match_operand:BI 1 "register_operand" "c")
6b6c1201
RH
3941 (const_int 0)])
3942 (label_ref (match_operand 2 "" ""))
c65ebc55
JW
3943 (pc)))]
3944 ""
85548039 3945 "(%J0) br.cond%+ %l2"
52e12ad0 3946 [(set_attr "itanium_class" "br")
e5bde68a 3947 (set_attr "predicable" "no")])
c65ebc55 3948
6b6c1201 3949(define_insn "*br_false"
c65ebc55 3950 [(set (pc)
6b6c1201 3951 (if_then_else (match_operator 0 "predicate_operator"
f2f90c63 3952 [(match_operand:BI 1 "register_operand" "c")
6b6c1201 3953 (const_int 0)])
c65ebc55 3954 (pc)
6b6c1201 3955 (label_ref (match_operand 2 "" ""))))]
c65ebc55 3956 ""
85548039 3957 "(%j0) br.cond%+ %l2"
52e12ad0 3958 [(set_attr "itanium_class" "br")
e5bde68a 3959 (set_attr "predicable" "no")])
c65ebc55
JW
3960\f
3961;; ::::::::::::::::::::
3962;; ::
5527bf14
RH
3963;; :: Counted loop operations
3964;; ::
3965;; ::::::::::::::::::::
3966
3967(define_expand "doloop_end"
3968 [(use (match_operand 0 "" "")) ; loop pseudo
3969 (use (match_operand 1 "" "")) ; iterations; zero if unknown
3970 (use (match_operand 2 "" "")) ; max iterations
3971 (use (match_operand 3 "" "")) ; loop level
3972 (use (match_operand 4 "" ""))] ; label
3973 ""
5527bf14
RH
3974{
3975 /* Only use cloop on innermost loops. */
3976 if (INTVAL (operands[3]) > 1)
3977 FAIL;
3978 emit_jump_insn (gen_doloop_end_internal (gen_rtx_REG (DImode, AR_LC_REGNUM),
3979 operands[4]));
3980 DONE;
1d5d7a21 3981})
5527bf14
RH
3982
3983(define_insn "doloop_end_internal"
3984 [(set (pc) (if_then_else (ne (match_operand:DI 0 "ar_lc_reg_operand" "")
3985 (const_int 0))
3986 (label_ref (match_operand 1 "" ""))
3987 (pc)))
3988 (set (match_dup 0) (if_then_else:DI (ne (match_dup 0) (const_int 0))
147d5f6f
AM
3989 (plus:DI (match_dup 0) (const_int -1))
3990 (match_dup 0)))]
5527bf14
RH
3991 ""
3992 "br.cloop.sptk.few %l1"
52e12ad0 3993 [(set_attr "itanium_class" "br")
5527bf14
RH
3994 (set_attr "predicable" "no")])
3995\f
3996;; ::::::::::::::::::::
3997;; ::
c65ebc55
JW
3998;; :: Set flag operations
3999;; ::
4000;; ::::::::::::::::::::
4001
f90b7a5a
PB
4002(define_expand "cstorebi4"
4003 [(set (match_operand:DI 0 "gr_register_operand" "")
4004 (match_operator:DI 1 "ia64_cbranch_operator"
4005 [(match_operand:BI 2 "register_operand" "")
4006 (match_operand:BI 3 "const_int_operand" "")]))]
c65ebc55 4007 ""
bf321310 4008 "ia64_expand_compare (&operands[1], &operands[2], &operands[3]);")
c65ebc55 4009
f90b7a5a
PB
4010(define_expand "cstoresi4"
4011 [(set (match_operand:DI 0 "gr_register_operand" "")
4012 (match_operator:DI 1 "ia64_cbranch_operator"
4013 [(match_operand:SI 2 "gr_register_operand" "")
4014 (match_operand:SI 3 "gr_reg_or_8bit_and_adjusted_operand" "")]))]
c65ebc55 4015 ""
f90b7a5a 4016 "ia64_expand_compare (&operands[1], &operands[2], &operands[3]);")
c65ebc55 4017
f90b7a5a
PB
4018(define_expand "cstoredi4"
4019 [(set (match_operand:DI 0 "gr_register_operand" "")
4020 (match_operator:DI 1 "ia64_cbranch_operator"
4021 [(match_operand:DI 2 "gr_register_operand" "")
4022 (match_operand:DI 3 "gr_reg_or_8bit_and_adjusted_operand" "")]))]
c65ebc55 4023 ""
f90b7a5a 4024 "ia64_expand_compare (&operands[1], &operands[2], &operands[3]);")
c65ebc55 4025
f90b7a5a
PB
4026(define_expand "cstoresf4"
4027 [(set (match_operand:DI 0 "gr_register_operand" "")
4028 (match_operator:DI 1 "ia64_cbranch_operator"
4029 [(match_operand:SF 2 "fr_reg_or_fp01_operand" "")
4030 (match_operand:SF 3 "fr_reg_or_fp01_operand" "")]))]
c65ebc55 4031 ""
f90b7a5a 4032 "ia64_expand_compare (&operands[1], &operands[2], &operands[3]);")
c65ebc55 4033
f90b7a5a
PB
4034(define_expand "cstoredf4"
4035 [(set (match_operand:DI 0 "gr_register_operand" "")
4036 (match_operator:DI 1 "ia64_cbranch_operator"
4037 [(match_operand:DF 2 "fr_reg_or_fp01_operand" "")
4038 (match_operand:DF 3 "fr_reg_or_fp01_operand" "")]))]
c65ebc55 4039 ""
f90b7a5a 4040 "ia64_expand_compare (&operands[1], &operands[2], &operands[3]);")
c65ebc55 4041
f90b7a5a
PB
4042(define_expand "cstorexf4"
4043 [(set (match_operand:DI 0 "gr_register_operand" "")
4044 (match_operator:DI 1 "ia64_cbranch_operator"
4045 [(match_operand:XF 2 "xfreg_or_fp01_operand" "")
4046 (match_operand:XF 3 "xfreg_or_fp01_operand" "")]))]
c65ebc55 4047 ""
f90b7a5a 4048 "ia64_expand_compare (&operands[1], &operands[2], &operands[3]);")
c65ebc55 4049
f90b7a5a
PB
4050(define_expand "cstoretf4"
4051 [(set (match_operand:DI 0 "gr_register_operand" "")
4052 (match_operator:DI 1 "ia64_cbranch_operator"
4053 [(match_operand:TF 2 "gr_register_operand" "")
4054 (match_operand:TF 3 "gr_register_operand" "")]))]
4055 "TARGET_HPUX"
4056 "ia64_expand_compare (&operands[1], &operands[2], &operands[3]);")
e57b9d65 4057
c65ebc55
JW
4058;; Don't allow memory as destination here, because cmov/cmov/st is more
4059;; efficient than mov/mov/cst/cst.
4060
0551c32d
RH
4061(define_insn_and_split "*sne_internal"
4062 [(set (match_operand:DI 0 "gr_register_operand" "=r")
f2f90c63 4063 (ne:DI (match_operand:BI 1 "register_operand" "c")
c65ebc55
JW
4064 (const_int 0)))]
4065 ""
4066 "#"
c65ebc55 4067 "reload_completed"
f2f90c63
RH
4068 [(cond_exec (ne (match_dup 1) (const_int 0))
4069 (set (match_dup 0) (const_int 1)))
4070 (cond_exec (eq (match_dup 1) (const_int 0))
4071 (set (match_dup 0) (const_int 0)))]
0551c32d 4072 ""
52e12ad0 4073 [(set_attr "itanium_class" "unknown")])
c65ebc55 4074
0551c32d
RH
4075(define_insn_and_split "*seq_internal"
4076 [(set (match_operand:DI 0 "gr_register_operand" "=r")
f2f90c63 4077 (eq:DI (match_operand:BI 1 "register_operand" "c")
c65ebc55
JW
4078 (const_int 0)))]
4079 ""
4080 "#"
c65ebc55 4081 "reload_completed"
f2f90c63
RH
4082 [(cond_exec (ne (match_dup 1) (const_int 0))
4083 (set (match_dup 0) (const_int 0)))
4084 (cond_exec (eq (match_dup 1) (const_int 0))
4085 (set (match_dup 0) (const_int 1)))]
0551c32d 4086 ""
52e12ad0 4087 [(set_attr "itanium_class" "unknown")])
c65ebc55
JW
4088\f
4089;; ::::::::::::::::::::
4090;; ::
4091;; :: Conditional move instructions.
4092;; ::
4093;; ::::::::::::::::::::
4094
4095;; ??? Add movXXcc patterns?
4096
c65ebc55
JW
4097;;
4098;; DImode if_then_else patterns.
4099;;
4100
75cdbeb8 4101(define_insn "*cmovdi_internal"
cd17b213 4102 [(set (match_operand:DI 0 "not_postinc_destination_operand"
cd5c4048 4103 "= r, r, r, r, r, r, r, r, r, r, m, Q, *f,*b,*d*e")
e5bde68a 4104 (if_then_else:DI
f2f90c63
RH
4105 (match_operator 4 "predicate_operator"
4106 [(match_operand:BI 1 "register_operand"
cd5c4048 4107 "c,c,c,c,c,c,c,c,c,c,c,c,c,c,c")
e5bde68a 4108 (const_int 0)])
cd17b213 4109 (match_operand:DI 2 "not_postinc_move_operand"
cd5c4048 4110 "rim, *f, *b,*d*e,rim,rim, rim,*f,*b,*d*e,rO,*f,rOQ,rO, rK")
cd17b213 4111 (match_operand:DI 3 "not_postinc_move_operand"
cd5c4048 4112 "rim,rim,rim, rim, *f, *b,*d*e,*f,*b,*d*e,rO,*f,rOQ,rO, rK")))]
aebf2462 4113 "ia64_move_ok (operands[0], operands[2])
f2f90c63 4114 && ia64_move_ok (operands[0], operands[3])"
e820471b 4115 { gcc_unreachable (); }
75cdbeb8
RH
4116 [(set_attr "predicable" "no")])
4117
4118(define_split
cd17b213 4119 [(set (match_operand 0 "not_postinc_destination_operand" "")
75cdbeb8 4120 (if_then_else
f2f90c63
RH
4121 (match_operator 4 "predicate_operator"
4122 [(match_operand:BI 1 "register_operand" "")
75cdbeb8 4123 (const_int 0)])
cd17b213
SE
4124 (match_operand 2 "not_postinc_move_operand" "")
4125 (match_operand 3 "not_postinc_move_operand" "")))]
3b572406
RH
4126 "reload_completed"
4127 [(const_int 0)]
e5bde68a 4128{
21515593
RH
4129 bool emitted_something = false;
4130 rtx dest = operands[0];
4131 rtx srct = operands[2];
4132 rtx srcf = operands[3];
4133 rtx cond = operands[4];
2f937369 4134
21515593 4135 if (! rtx_equal_p (dest, srct))
e5bde68a 4136 {
21515593
RH
4137 ia64_emit_cond_move (dest, srct, cond);
4138 emitted_something = true;
e5bde68a 4139 }
21515593 4140 if (! rtx_equal_p (dest, srcf))
3b572406 4141 {
21515593
RH
4142 cond = gen_rtx_fmt_ee (GET_CODE (cond) == NE ? EQ : NE,
4143 VOIDmode, operands[1], const0_rtx);
4144 ia64_emit_cond_move (dest, srcf, cond);
4145 emitted_something = true;
3b572406 4146 }
2f937369 4147 if (! emitted_something)
f9974026 4148 emit_note (NOTE_INSN_DELETED);
3b572406 4149 DONE;
1d5d7a21 4150})
c65ebc55
JW
4151
4152;; Absolute value pattern.
4153
4154(define_insn "*absdi2_internal"
0551c32d 4155 [(set (match_operand:DI 0 "gr_register_operand" "=r,r")
e5bde68a 4156 (if_then_else:DI
f2f90c63
RH
4157 (match_operator 4 "predicate_operator"
4158 [(match_operand:BI 1 "register_operand" "c,c")
e5bde68a 4159 (const_int 0)])
0551c32d
RH
4160 (neg:DI (match_operand:DI 2 "gr_reg_or_22bit_operand" "rI,rI"))
4161 (match_operand:DI 3 "gr_reg_or_22bit_operand" "0,rI")))]
c65ebc55 4162 ""
e5bde68a 4163 "#"
52e12ad0 4164 [(set_attr "itanium_class" "ialu,unknown")
3b572406 4165 (set_attr "predicable" "no")])
c65ebc55
JW
4166
4167(define_split
4168 [(set (match_operand:DI 0 "register_operand" "")
e5bde68a 4169 (if_then_else:DI
f2f90c63
RH
4170 (match_operator 4 "predicate_operator"
4171 [(match_operand:BI 1 "register_operand" "c,c")
e5bde68a 4172 (const_int 0)])
0551c32d
RH
4173 (neg:DI (match_operand:DI 2 "gr_reg_or_22bit_operand" ""))
4174 (match_operand:DI 3 "gr_reg_or_22bit_operand" "")))]
e5bde68a
RH
4175 "reload_completed && rtx_equal_p (operands[0], operands[3])"
4176 [(cond_exec
4177 (match_dup 4)
4178 (set (match_dup 0)
4179 (neg:DI (match_dup 2))))]
c65ebc55
JW
4180 "")
4181
e5bde68a
RH
4182(define_split
4183 [(set (match_operand:DI 0 "register_operand" "")
4184 (if_then_else:DI
f2f90c63
RH
4185 (match_operator 4 "predicate_operator"
4186 [(match_operand:BI 1 "register_operand" "c,c")
e5bde68a 4187 (const_int 0)])
0551c32d
RH
4188 (neg:DI (match_operand:DI 2 "gr_reg_or_22bit_operand" ""))
4189 (match_operand:DI 3 "gr_reg_or_22bit_operand" "")))]
e5bde68a
RH
4190 "reload_completed"
4191 [(cond_exec
4192 (match_dup 4)
4193 (set (match_dup 0) (neg:DI (match_dup 2))))
4194 (cond_exec
4195 (match_dup 5)
4196 (set (match_dup 0) (match_dup 3)))]
e5bde68a
RH
4197{
4198 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[4]) == NE ? EQ : NE,
f2f90c63 4199 VOIDmode, operands[1], const0_rtx);
1d5d7a21 4200})
c65ebc55
JW
4201
4202;;
4203;; SImode if_then_else patterns.
4204;;
4205
75cdbeb8 4206(define_insn "*cmovsi_internal"
cd17b213
SE
4207 [(set (match_operand:SI 0 "not_postinc_destination_operand"
4208 "=r,m,*f,r,m,*f,r,m,*f")
e5bde68a 4209 (if_then_else:SI
f2f90c63
RH
4210 (match_operator 4 "predicate_operator"
4211 [(match_operand:BI 1 "register_operand" "c,c,c,c,c,c,c,c,c")
e5bde68a 4212 (const_int 0)])
cd17b213 4213 (match_operand:SI 2 "not_postinc_move_operand"
3b572406 4214 "0,0,0,rim*f,rO,rO,rim*f,rO,rO")
cd17b213 4215 (match_operand:SI 3 "not_postinc_move_operand"
3b572406 4216 "rim*f,rO,rO,0,0,0,rim*f,rO,rO")))]
aebf2462 4217 "ia64_move_ok (operands[0], operands[2])
f2f90c63 4218 && ia64_move_ok (operands[0], operands[3])"
e820471b 4219 { gcc_unreachable (); }
3b572406 4220 [(set_attr "predicable" "no")])
c65ebc55
JW
4221
4222(define_insn "*abssi2_internal"
0551c32d 4223 [(set (match_operand:SI 0 "gr_register_operand" "=r,r")
e5bde68a 4224 (if_then_else:SI
f2f90c63
RH
4225 (match_operator 4 "predicate_operator"
4226 [(match_operand:BI 1 "register_operand" "c,c")
e5bde68a 4227 (const_int 0)])
0551c32d
RH
4228 (neg:SI (match_operand:SI 3 "gr_reg_or_22bit_operand" "rI,rI"))
4229 (match_operand:SI 2 "gr_reg_or_22bit_operand" "0,rI")))]
c65ebc55 4230 ""
e5bde68a 4231 "#"
52e12ad0 4232 [(set_attr "itanium_class" "ialu,unknown")
3b572406 4233 (set_attr "predicable" "no")])
c65ebc55
JW
4234
4235(define_split
4236 [(set (match_operand:SI 0 "register_operand" "")
e5bde68a 4237 (if_then_else:SI
f2f90c63
RH
4238 (match_operator 4 "predicate_operator"
4239 [(match_operand:BI 1 "register_operand" "c,c")
e5bde68a 4240 (const_int 0)])
0551c32d
RH
4241 (neg:SI (match_operand:SI 2 "gr_reg_or_22bit_operand" ""))
4242 (match_operand:SI 3 "gr_reg_or_22bit_operand" "")))]
e5bde68a
RH
4243 "reload_completed && rtx_equal_p (operands[0], operands[3])"
4244 [(cond_exec
4245 (match_dup 4)
4246 (set (match_dup 0)
4247 (neg:SI (match_dup 2))))]
c65ebc55
JW
4248 "")
4249
e5bde68a
RH
4250(define_split
4251 [(set (match_operand:SI 0 "register_operand" "")
4252 (if_then_else:SI
f2f90c63
RH
4253 (match_operator 4 "predicate_operator"
4254 [(match_operand:BI 1 "register_operand" "c,c")
e5bde68a 4255 (const_int 0)])
0551c32d
RH
4256 (neg:SI (match_operand:SI 2 "gr_reg_or_22bit_operand" ""))
4257 (match_operand:SI 3 "gr_reg_or_22bit_operand" "")))]
e5bde68a
RH
4258 "reload_completed"
4259 [(cond_exec
4260 (match_dup 4)
4261 (set (match_dup 0) (neg:SI (match_dup 2))))
4262 (cond_exec
4263 (match_dup 5)
4264 (set (match_dup 0) (match_dup 3)))]
e5bde68a
RH
4265{
4266 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[4]) == NE ? EQ : NE,
f2f90c63 4267 VOIDmode, operands[1], const0_rtx);
1d5d7a21 4268})
e5bde68a 4269
7dcc803e 4270(define_insn_and_split "*cond_opsi2_internal"
acb0638d
BS
4271 [(set (match_operand:SI 0 "gr_register_operand" "=r")
4272 (match_operator:SI 5 "condop_operator"
4273 [(if_then_else:SI
4274 (match_operator 6 "predicate_operator"
4275 [(match_operand:BI 1 "register_operand" "c")
4276 (const_int 0)])
4277 (match_operand:SI 2 "gr_register_operand" "r")
4278 (match_operand:SI 3 "gr_register_operand" "r"))
4279 (match_operand:SI 4 "gr_register_operand" "r")]))]
4280 ""
4281 "#"
acb0638d
BS
4282 "reload_completed"
4283 [(cond_exec
4284 (match_dup 6)
4285 (set (match_dup 0) (match_op_dup:SI 5 [(match_dup 2) (match_dup 4)])))
4286 (cond_exec
4287 (match_dup 7)
4288 (set (match_dup 0) (match_op_dup:SI 5 [(match_dup 3) (match_dup 4)])))]
acb0638d
BS
4289{
4290 operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[6]) == NE ? EQ : NE,
4291 VOIDmode, operands[1], const0_rtx);
1d5d7a21 4292}
7dcc803e
BS
4293 [(set_attr "itanium_class" "ialu")
4294 (set_attr "predicable" "no")])
4295
acb0638d 4296
7dcc803e 4297(define_insn_and_split "*cond_opsi2_internal_b"
acb0638d
BS
4298 [(set (match_operand:SI 0 "gr_register_operand" "=r")
4299 (match_operator:SI 5 "condop_operator"
4300 [(match_operand:SI 4 "gr_register_operand" "r")
4301 (if_then_else:SI
4302 (match_operator 6 "predicate_operator"
4303 [(match_operand:BI 1 "register_operand" "c")
4304 (const_int 0)])
4305 (match_operand:SI 2 "gr_register_operand" "r")
4306 (match_operand:SI 3 "gr_register_operand" "r"))]))]
4307 ""
4308 "#"
acb0638d
BS
4309 "reload_completed"
4310 [(cond_exec
4311 (match_dup 6)
4312 (set (match_dup 0) (match_op_dup:SI 5 [(match_dup 4) (match_dup 2)])))
4313 (cond_exec
4314 (match_dup 7)
4315 (set (match_dup 0) (match_op_dup:SI 5 [(match_dup 4) (match_dup 3)])))]
acb0638d
BS
4316{
4317 operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[6]) == NE ? EQ : NE,
4318 VOIDmode, operands[1], const0_rtx);
1d5d7a21 4319}
7dcc803e
BS
4320 [(set_attr "itanium_class" "ialu")
4321 (set_attr "predicable" "no")])
acb0638d 4322
c65ebc55
JW
4323\f
4324;; ::::::::::::::::::::
4325;; ::
4326;; :: Call and branch instructions
4327;; ::
4328;; ::::::::::::::::::::
4329
4330;; Subroutine call instruction returning no value. Operand 0 is the function
4331;; to call; operand 1 is the number of bytes of arguments pushed (in mode
4332;; `SImode', except it is normally a `const_int'); operand 2 is the number of
4333;; registers used as operands.
4334
4335;; On most machines, operand 2 is not actually stored into the RTL pattern. It
4336;; is supplied for the sake of some RISC machines which need to put this
4337;; information into the assembler code; they can put it in the RTL instead of
4338;; operand 1.
4339
4340(define_expand "call"
4341 [(use (match_operand:DI 0 "" ""))
4342 (use (match_operand 1 "" ""))
4343 (use (match_operand 2 "" ""))
4344 (use (match_operand 3 "" ""))]
4345 ""
c65ebc55 4346{
599aedd9 4347 ia64_expand_call (NULL_RTX, operands[0], operands[2], false);
c65ebc55 4348 DONE;
1d5d7a21 4349})
c65ebc55 4350
2ed4af6f
RH
4351(define_expand "sibcall"
4352 [(use (match_operand:DI 0 "" ""))
4353 (use (match_operand 1 "" ""))
4354 (use (match_operand 2 "" ""))
4355 (use (match_operand 3 "" ""))]
c65ebc55 4356 ""
c65ebc55 4357{
599aedd9 4358 ia64_expand_call (NULL_RTX, operands[0], operands[2], true);
2ed4af6f 4359 DONE;
1d5d7a21 4360})
c65ebc55 4361
c65ebc55 4362;; Subroutine call instruction returning a value. Operand 0 is the hard
2ed4af6f
RH
4363;; register in which the value is returned. There are three more operands,
4364;; the same as the three operands of the `call' instruction (but with numbers
c65ebc55 4365;; increased by one).
2ed4af6f 4366;;
c65ebc55
JW
4367;; Subroutines that return `BLKmode' objects use the `call' insn.
4368
4369(define_expand "call_value"
4370 [(use (match_operand 0 "" ""))
4371 (use (match_operand:DI 1 "" ""))
4372 (use (match_operand 2 "" ""))
4373 (use (match_operand 3 "" ""))
4374 (use (match_operand 4 "" ""))]
4375 ""
c65ebc55 4376{
599aedd9 4377 ia64_expand_call (operands[0], operands[1], operands[3], false);
c65ebc55 4378 DONE;
1d5d7a21 4379})
c65ebc55 4380
2ed4af6f
RH
4381(define_expand "sibcall_value"
4382 [(use (match_operand 0 "" ""))
4383 (use (match_operand:DI 1 "" ""))
4384 (use (match_operand 2 "" ""))
4385 (use (match_operand 3 "" ""))
4386 (use (match_operand 4 "" ""))]
c65ebc55 4387 ""
c65ebc55 4388{
599aedd9 4389 ia64_expand_call (operands[0], operands[1], operands[3], true);
2ed4af6f 4390 DONE;
1d5d7a21 4391})
c65ebc55 4392
c65ebc55
JW
4393;; Call subroutine returning any type.
4394
4395(define_expand "untyped_call"
4396 [(parallel [(call (match_operand 0 "" "")
4397 (const_int 0))
4398 (match_operand 1 "" "")
4399 (match_operand 2 "" "")])]
4400 ""
c65ebc55
JW
4401{
4402 int i;
4403
4404 emit_call_insn (gen_call (operands[0], const0_rtx, NULL, const0_rtx));
4405
4406 for (i = 0; i < XVECLEN (operands[2], 0); i++)
4407 {
4408 rtx set = XVECEXP (operands[2], 0, i);
4409 emit_move_insn (SET_DEST (set), SET_SRC (set));
4410 }
4411
4412 /* The optimizer does not know that the call sets the function value
4413 registers we stored in the result block. We avoid problems by
4414 claiming that all hard registers are used and clobbered at this
4415 point. */
4416 emit_insn (gen_blockage ());
4417
4418 DONE;
1d5d7a21 4419})
c65ebc55 4420
599aedd9 4421(define_insn "call_nogp"
67b476d1 4422 [(call (mem:DI (match_operand:DI 0 "call_operand" "?b,s"))
599aedd9
RH
4423 (const_int 0))
4424 (clobber (match_operand:DI 1 "register_operand" "=b,b"))]
2ed4af6f 4425 ""
599aedd9 4426 "br.call%+.many %1 = %0"
52e12ad0 4427 [(set_attr "itanium_class" "br,scall")])
2ed4af6f 4428
599aedd9 4429(define_insn "call_value_nogp"
75293ad6 4430 [(set (match_operand 0 "" "=X,X")
67b476d1 4431 (call (mem:DI (match_operand:DI 1 "call_operand" "?b,s"))
599aedd9
RH
4432 (const_int 0)))
4433 (clobber (match_operand:DI 2 "register_operand" "=b,b"))]
2ed4af6f 4434 ""
599aedd9 4435 "br.call%+.many %2 = %1"
52e12ad0 4436 [(set_attr "itanium_class" "br,scall")])
2ed4af6f 4437
599aedd9 4438(define_insn "sibcall_nogp"
67b476d1 4439 [(call (mem:DI (match_operand:DI 0 "call_operand" "?b,s"))
599aedd9 4440 (const_int 0))]
2ed4af6f
RH
4441 ""
4442 "br%+.many %0"
52e12ad0 4443 [(set_attr "itanium_class" "br,scall")])
2ed4af6f 4444
599aedd9 4445(define_insn "call_gp"
67b476d1 4446 [(call (mem:DI (match_operand:DI 0 "call_operand" "?r,s"))
599aedd9
RH
4447 (const_int 1))
4448 (clobber (match_operand:DI 1 "register_operand" "=b,b"))
4449 (clobber (match_scratch:DI 2 "=&r,X"))
4450 (clobber (match_scratch:DI 3 "=b,X"))]
2ed4af6f 4451 ""
599aedd9 4452 "#"
52e12ad0 4453 [(set_attr "itanium_class" "br,scall")])
2ed4af6f 4454
599aedd9
RH
4455;; Irritatingly, we don't have access to INSN within the split body.
4456;; See commentary in ia64_split_call as to why these aren't peep2.
4457(define_split
4458 [(call (mem (match_operand 0 "call_operand" ""))
4459 (const_int 1))
4460 (clobber (match_operand:DI 1 "register_operand" ""))
4461 (clobber (match_scratch:DI 2 ""))
4462 (clobber (match_scratch:DI 3 ""))]
4463 "reload_completed && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
4464 [(const_int 0)]
4465{
4466 ia64_split_call (NULL_RTX, operands[0], operands[1], operands[2],
4467 operands[3], true, false);
4468 DONE;
4469})
4470
4471(define_split
4472 [(call (mem (match_operand 0 "call_operand" ""))
4473 (const_int 1))
4474 (clobber (match_operand:DI 1 "register_operand" ""))
4475 (clobber (match_scratch:DI 2 ""))
4476 (clobber (match_scratch:DI 3 ""))]
4477 "reload_completed"
4478 [(const_int 0)]
4479{
4480 ia64_split_call (NULL_RTX, operands[0], operands[1], operands[2],
4481 operands[3], false, false);
4482 DONE;
4483})
4484
4485(define_insn "call_value_gp"
75293ad6 4486 [(set (match_operand 0 "" "=X,X")
67b476d1 4487 (call (mem:DI (match_operand:DI 1 "call_operand" "?r,s"))
599aedd9
RH
4488 (const_int 1)))
4489 (clobber (match_operand:DI 2 "register_operand" "=b,b"))
4490 (clobber (match_scratch:DI 3 "=&r,X"))
4491 (clobber (match_scratch:DI 4 "=b,X"))]
2ed4af6f 4492 ""
599aedd9 4493 "#"
52e12ad0 4494 [(set_attr "itanium_class" "br,scall")])
2ed4af6f 4495
599aedd9
RH
4496(define_split
4497 [(set (match_operand 0 "" "")
4498 (call (mem:DI (match_operand:DI 1 "call_operand" ""))
4499 (const_int 1)))
4500 (clobber (match_operand:DI 2 "register_operand" ""))
4501 (clobber (match_scratch:DI 3 ""))
4502 (clobber (match_scratch:DI 4 ""))]
4503 "reload_completed && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
4504 [(const_int 0)]
4505{
4506 ia64_split_call (operands[0], operands[1], operands[2], operands[3],
4507 operands[4], true, false);
4508 DONE;
4509})
4510
4511(define_split
4512 [(set (match_operand 0 "" "")
4513 (call (mem:DI (match_operand:DI 1 "call_operand" ""))
4514 (const_int 1)))
4515 (clobber (match_operand:DI 2 "register_operand" ""))
4516 (clobber (match_scratch:DI 3 ""))
4517 (clobber (match_scratch:DI 4 ""))]
4518 "reload_completed"
4519 [(const_int 0)]
4520{
4521 ia64_split_call (operands[0], operands[1], operands[2], operands[3],
4522 operands[4], false, false);
4523 DONE;
4524})
4525
4526(define_insn_and_split "sibcall_gp"
67b476d1 4527 [(call (mem:DI (match_operand:DI 0 "call_operand" "?r,s"))
599aedd9
RH
4528 (const_int 1))
4529 (clobber (match_scratch:DI 1 "=&r,X"))
4530 (clobber (match_scratch:DI 2 "=b,X"))]
2ed4af6f 4531 ""
599aedd9
RH
4532 "#"
4533 "reload_completed"
4534 [(const_int 0)]
4535{
4536 ia64_split_call (NULL_RTX, operands[0], NULL_RTX, operands[1],
4537 operands[2], true, true);
4538 DONE;
4539}
52e12ad0 4540 [(set_attr "itanium_class" "br")])
2ed4af6f 4541
c65ebc55
JW
4542(define_insn "return_internal"
4543 [(return)
4544 (use (match_operand:DI 0 "register_operand" "b"))]
4545 ""
4546 "br.ret.sptk.many %0"
52e12ad0 4547 [(set_attr "itanium_class" "br")])
c65ebc55
JW
4548
4549(define_insn "return"
4550 [(return)]
4551 "ia64_direct_return ()"
4552 "br.ret.sptk.many rp"
52e12ad0 4553 [(set_attr "itanium_class" "br")])
c65ebc55 4554
6b6c1201 4555(define_insn "*return_true"
c65ebc55 4556 [(set (pc)
6b6c1201 4557 (if_then_else (match_operator 0 "predicate_operator"
f2f90c63 4558 [(match_operand:BI 1 "register_operand" "c")
6b6c1201 4559 (const_int 0)])
c65ebc55
JW
4560 (return)
4561 (pc)))]
4562 "ia64_direct_return ()"
13da91fd 4563 "(%J0) br.ret%+.many rp"
52e12ad0 4564 [(set_attr "itanium_class" "br")
e5bde68a 4565 (set_attr "predicable" "no")])
c65ebc55 4566
6b6c1201 4567(define_insn "*return_false"
c65ebc55 4568 [(set (pc)
6b6c1201 4569 (if_then_else (match_operator 0 "predicate_operator"
f2f90c63 4570 [(match_operand:BI 1 "register_operand" "c")
6b6c1201 4571 (const_int 0)])
c65ebc55
JW
4572 (pc)
4573 (return)))]
4574 "ia64_direct_return ()"
13da91fd 4575 "(%j0) br.ret%+.many rp"
52e12ad0 4576 [(set_attr "itanium_class" "br")
e5bde68a 4577 (set_attr "predicable" "no")])
c65ebc55
JW
4578
4579(define_insn "jump"
4580 [(set (pc) (label_ref (match_operand 0 "" "")))]
4581 ""
4582 "br %l0"
52e12ad0 4583 [(set_attr "itanium_class" "br")])
c65ebc55
JW
4584
4585(define_insn "indirect_jump"
4586 [(set (pc) (match_operand:DI 0 "register_operand" "b"))]
4587 ""
4588 "br %0"
52e12ad0 4589 [(set_attr "itanium_class" "br")])
c65ebc55
JW
4590
4591(define_expand "tablejump"
340f7e7c
RH
4592 [(parallel [(set (pc) (match_operand:DI 0 "memory_operand" ""))
4593 (use (label_ref (match_operand 1 "" "")))])]
c65ebc55 4594 ""
c65ebc55 4595{
340f7e7c
RH
4596 rtx op0 = operands[0];
4597 rtx addr;
4598
4599 /* ??? Bother -- do_tablejump is "helpful" and pulls the table
4600 element into a register without bothering to see whether that
4601 is necessary given the operand predicate. Check for MEM just
4602 in case someone fixes this. */
4603 if (GET_CODE (op0) == MEM)
4604 addr = XEXP (op0, 0);
4605 else
4606 {
4607 /* Otherwise, cheat and guess that the previous insn in the
4608 stream was the memory load. Grab the address from that.
4609 Note we have to momentarily pop out of the sequence started
4610 by the insn-emit wrapper in order to grab the last insn. */
4611 rtx last, set;
4612
4613 end_sequence ();
4614 last = get_last_insn ();
4615 start_sequence ();
4616 set = single_set (last);
4617
e820471b
NS
4618 gcc_assert (rtx_equal_p (SET_DEST (set), op0)
4619 && GET_CODE (SET_SRC (set)) == MEM);
340f7e7c 4620 addr = XEXP (SET_SRC (set), 0);
e820471b 4621 gcc_assert (!rtx_equal_p (addr, op0));
340f7e7c 4622 }
c65ebc55 4623
340f7e7c
RH
4624 /* Jump table elements are stored pc-relative. That is, a displacement
4625 from the entry to the label. Thus to convert to an absolute address
4626 we add the address of the memory from which the value is loaded. */
4627 operands[0] = expand_simple_binop (DImode, PLUS, op0, addr,
4628 NULL_RTX, 1, OPTAB_DIRECT);
4629})
c65ebc55 4630
340f7e7c 4631(define_insn "*tablejump_internal"
c65ebc55
JW
4632 [(set (pc) (match_operand:DI 0 "register_operand" "b"))
4633 (use (label_ref (match_operand 1 "" "")))]
4634 ""
4635 "br %0"
52e12ad0 4636 [(set_attr "itanium_class" "br")])
c65ebc55
JW
4637
4638\f
4639;; ::::::::::::::::::::
4640;; ::
4641;; :: Prologue and Epilogue instructions
4642;; ::
4643;; ::::::::::::::::::::
4644
4645(define_expand "prologue"
4646 [(const_int 1)]
4647 ""
c65ebc55
JW
4648{
4649 ia64_expand_prologue ();
4650 DONE;
1d5d7a21 4651})
c65ebc55
JW
4652
4653(define_expand "epilogue"
2ed4af6f
RH
4654 [(return)]
4655 ""
2ed4af6f
RH
4656{
4657 ia64_expand_epilogue (0);
4658 DONE;
1d5d7a21 4659})
2ed4af6f
RH
4660
4661(define_expand "sibcall_epilogue"
4662 [(return)]
c65ebc55 4663 ""
c65ebc55 4664{
2ed4af6f 4665 ia64_expand_epilogue (1);
c65ebc55 4666 DONE;
1d5d7a21 4667})
c65ebc55
JW
4668
4669;; This prevents the scheduler from moving the SP decrement past FP-relative
4670;; stack accesses. This is the same as adddi3 plus the extra set.
4671
4672(define_insn "prologue_allocate_stack"
4673 [(set (match_operand:DI 0 "register_operand" "=r,r,r")
4674 (plus:DI (match_operand:DI 1 "register_operand" "%r,r,a")
0551c32d 4675 (match_operand:DI 2 "gr_reg_or_22bit_operand" "r,I,J")))
bdbe5b8d 4676 (set (match_operand:DI 3 "register_operand" "+r,r,r")
c65ebc55
JW
4677 (match_dup 3))]
4678 ""
4679 "@
1d5d7a21
RH
4680 add %0 = %1, %2
4681 adds %0 = %2, %1
4682 addl %0 = %2, %1"
52e12ad0 4683 [(set_attr "itanium_class" "ialu")])
c65ebc55
JW
4684
4685;; This prevents the scheduler from moving the SP restore past FP-relative
4686;; stack accesses. This is similar to movdi plus the extra set.
4687
4688(define_insn "epilogue_deallocate_stack"
4689 [(set (match_operand:DI 0 "register_operand" "=r")
4690 (match_operand:DI 1 "register_operand" "+r"))
4691 (set (match_dup 1) (match_dup 1))]
4692 ""
4693 "mov %0 = %1"
52e12ad0 4694 [(set_attr "itanium_class" "ialu")])
c65ebc55 4695
1d5d7a21
RH
4696;; As USE insns aren't meaningful after reload, this is used instead
4697;; to prevent deleting instructions setting registers for EH handling
4698(define_insn "prologue_use"
4699 [(unspec:DI [(match_operand:DI 0 "register_operand" "")]
4700 UNSPEC_PROLOGUE_USE)]
4701 ""
4702 ""
4703 [(set_attr "itanium_class" "ignore")
fa978426
AS
4704 (set_attr "predicable" "no")
4705 (set_attr "empty" "yes")])
1d5d7a21 4706
c65ebc55
JW
4707;; Allocate a new register frame.
4708
4709(define_insn "alloc"
4710 [(set (match_operand:DI 0 "register_operand" "=r")
086c0f96 4711 (unspec_volatile:DI [(const_int 0)] UNSPECV_ALLOC))
c65ebc55
JW
4712 (use (match_operand:DI 1 "const_int_operand" "i"))
4713 (use (match_operand:DI 2 "const_int_operand" "i"))
4714 (use (match_operand:DI 3 "const_int_operand" "i"))
4715 (use (match_operand:DI 4 "const_int_operand" "i"))]
4716 ""
4717 "alloc %0 = ar.pfs, %1, %2, %3, %4"
52e12ad0 4718 [(set_attr "itanium_class" "syst_m0")
68e11b42
JW
4719 (set_attr "predicable" "no")
4720 (set_attr "first_insn" "yes")])
c65ebc55 4721
97e242b0
RH
4722;; Modifies ar.unat
4723(define_expand "gr_spill"
870f9ec0
RH
4724 [(parallel [(set (match_operand:DI 0 "memory_operand" "=m")
4725 (unspec:DI [(match_operand:DI 1 "register_operand" "r")
086c0f96
RH
4726 (match_operand:DI 2 "const_int_operand" "")]
4727 UNSPEC_GR_SPILL))
870f9ec0 4728 (clobber (match_dup 3))])]
97e242b0 4729 ""
870f9ec0 4730 "operands[3] = gen_rtx_REG (DImode, AR_UNAT_REGNUM);")
97e242b0 4731
870f9ec0 4732(define_insn "gr_spill_internal"
b6fb7d46 4733 [(set (match_operand:DI 0 "destination_operand" "=m")
870f9ec0 4734 (unspec:DI [(match_operand:DI 1 "register_operand" "r")
086c0f96
RH
4735 (match_operand:DI 2 "const_int_operand" "")]
4736 UNSPEC_GR_SPILL))
870f9ec0 4737 (clobber (match_operand:DI 3 "register_operand" ""))]
c65ebc55 4738 ""
2130b7fb 4739{
1d5d7a21
RH
4740 /* Note that we use a C output pattern here to avoid the predicate
4741 being automatically added before the .mem.offset directive. */
4742 return ".mem.offset %2, 0\;%,st8.spill %0 = %1%P0";
4743}
52e12ad0 4744 [(set_attr "itanium_class" "st")])
c65ebc55 4745
97e242b0
RH
4746;; Reads ar.unat
4747(define_expand "gr_restore"
870f9ec0
RH
4748 [(parallel [(set (match_operand:DI 0 "register_operand" "=r")
4749 (unspec:DI [(match_operand:DI 1 "memory_operand" "m")
086c0f96
RH
4750 (match_operand:DI 2 "const_int_operand" "")]
4751 UNSPEC_GR_RESTORE))
870f9ec0 4752 (use (match_dup 3))])]
97e242b0 4753 ""
870f9ec0 4754 "operands[3] = gen_rtx_REG (DImode, AR_UNAT_REGNUM);")
97e242b0 4755
870f9ec0 4756(define_insn "gr_restore_internal"
c65ebc55 4757 [(set (match_operand:DI 0 "register_operand" "=r")
870f9ec0 4758 (unspec:DI [(match_operand:DI 1 "memory_operand" "m")
086c0f96
RH
4759 (match_operand:DI 2 "const_int_operand" "")]
4760 UNSPEC_GR_RESTORE))
870f9ec0 4761 (use (match_operand:DI 3 "register_operand" ""))]
c65ebc55 4762 ""
1d5d7a21 4763 { return ".mem.offset %2, 0\;%,ld8.fill %0 = %1%P1"; }
52e12ad0 4764 [(set_attr "itanium_class" "ld")])
c65ebc55
JW
4765
4766(define_insn "fr_spill"
b6fb7d46 4767 [(set (match_operand:XF 0 "destination_operand" "=m")
02befdf4 4768 (unspec:XF [(match_operand:XF 1 "register_operand" "f")]
086c0f96 4769 UNSPEC_FR_SPILL))]
c65ebc55
JW
4770 ""
4771 "stf.spill %0 = %1%P0"
52e12ad0 4772 [(set_attr "itanium_class" "stf")])
c65ebc55
JW
4773
4774(define_insn "fr_restore"
02befdf4
ZW
4775 [(set (match_operand:XF 0 "register_operand" "=f")
4776 (unspec:XF [(match_operand:XF 1 "memory_operand" "m")]
086c0f96 4777 UNSPEC_FR_RESTORE))]
c65ebc55
JW
4778 ""
4779 "ldf.fill %0 = %1%P1"
52e12ad0 4780 [(set_attr "itanium_class" "fld")])
c65ebc55 4781
0024a804
JW
4782;; ??? The explicit stop is not ideal. It would be better if
4783;; rtx_needs_barrier took care of this, but this is something that can be
4784;; fixed later. This avoids an RSE DV.
4785
0c96007e
AM
4786(define_insn "bsp_value"
4787 [(set (match_operand:DI 0 "register_operand" "=r")
086c0f96 4788 (unspec:DI [(const_int 0)] UNSPEC_BSP_VALUE))]
0c96007e 4789 ""
582d11e6
JW
4790 "*
4791{
4792 return \";;\;%,mov %0 = ar.bsp\";
4793}"
52e12ad0 4794 [(set_attr "itanium_class" "frar_i")])
0c96007e
AM
4795
4796(define_insn "set_bsp"
086c0f96
RH
4797 [(unspec_volatile [(match_operand:DI 0 "register_operand" "r")]
4798 UNSPECV_SET_BSP)]
0c96007e 4799 ""
1d5d7a21
RH
4800 "flushrs
4801 mov r19=ar.rsc
4802 ;;
4803 and r19=0x1c,r19
4804 ;;
4805 mov ar.rsc=r19
4806 ;;
4807 mov ar.bspstore=%0
4808 ;;
4809 or r19=0x3,r19
4810 ;;
4811 loadrs
4812 invala
4813 ;;
4814 mov ar.rsc=r19"
52e12ad0 4815 [(set_attr "itanium_class" "unknown")
e5bde68a 4816 (set_attr "predicable" "no")])
ce152ef8 4817
0024a804
JW
4818;; ??? The explicit stops are not ideal. It would be better if
4819;; rtx_needs_barrier took care of this, but this is something that can be
4820;; fixed later. This avoids an RSE DV.
4821
ce152ef8 4822(define_insn "flushrs"
086c0f96 4823 [(unspec [(const_int 0)] UNSPEC_FLUSHRS)]
ce152ef8 4824 ""
0024a804 4825 ";;\;flushrs\;;;"
582d11e6
JW
4826 [(set_attr "itanium_class" "rse_m")
4827 (set_attr "predicable" "no")])
c65ebc55
JW
4828\f
4829;; ::::::::::::::::::::
4830;; ::
4831;; :: Miscellaneous instructions
4832;; ::
4833;; ::::::::::::::::::::
4834
839a4992 4835;; ??? Emitting a NOP instruction isn't very useful. This should probably
c65ebc55
JW
4836;; be emitting ";;" to force a break in the instruction packing.
4837
4838;; No operation, needed in case the user uses -g but not -O.
4839(define_insn "nop"
4840 [(const_int 0)]
4841 ""
4842 "nop 0"
30028c85 4843 [(set_attr "itanium_class" "nop")])
c65ebc55 4844
2130b7fb
BS
4845(define_insn "nop_m"
4846 [(const_int 1)]
4847 ""
4848 "nop.m 0"
4849 [(set_attr "itanium_class" "nop_m")])
4850
4851(define_insn "nop_i"
4852 [(const_int 2)]
4853 ""
4854 "nop.i 0"
4855 [(set_attr "itanium_class" "nop_i")])
4856
4857(define_insn "nop_f"
4858 [(const_int 3)]
4859 ""
4860 "nop.f 0"
4861 [(set_attr "itanium_class" "nop_f")])
4862
4863(define_insn "nop_b"
4864 [(const_int 4)]
4865 ""
4866 "nop.b 0"
4867 [(set_attr "itanium_class" "nop_b")])
4868
4869(define_insn "nop_x"
4870 [(const_int 5)]
4871 ""
4872 ""
fa978426
AS
4873 [(set_attr "itanium_class" "nop_x")
4874 (set_attr "empty" "yes")])
2130b7fb 4875
30028c85
VM
4876;; The following insn will be never generated. It is used only by
4877;; insn scheduler to change state before advancing cycle.
4878(define_insn "pre_cycle"
4879 [(const_int 6)]
4880 ""
4881 ""
4882 [(set_attr "itanium_class" "pre_cycle")])
4883
2130b7fb 4884(define_insn "bundle_selector"
086c0f96 4885 [(unspec [(match_operand 0 "const_int_operand" "")] UNSPEC_BUNDLE_SELECTOR)]
2130b7fb 4886 ""
1d5d7a21 4887 { return get_bundle_name (INTVAL (operands[0])); }
2130b7fb
BS
4888 [(set_attr "itanium_class" "ignore")
4889 (set_attr "predicable" "no")])
4890
c65ebc55
JW
4891;; Pseudo instruction that prevents the scheduler from moving code above this
4892;; point.
4893(define_insn "blockage"
086c0f96 4894 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
c65ebc55
JW
4895 ""
4896 ""
52e12ad0 4897 [(set_attr "itanium_class" "ignore")
e5bde68a 4898 (set_attr "predicable" "no")])
c65ebc55
JW
4899
4900(define_insn "insn_group_barrier"
086c0f96
RH
4901 [(unspec_volatile [(match_operand 0 "const_int_operand" "")]
4902 UNSPECV_INSN_GROUP_BARRIER)]
c65ebc55
JW
4903 ""
4904 ";;"
52e12ad0 4905 [(set_attr "itanium_class" "stop_bit")
fa978426
AS
4906 (set_attr "predicable" "no")
4907 (set_attr "empty" "yes")])
c65ebc55 4908
26406018
RH
4909(define_expand "trap"
4910 [(trap_if (const_int 1) (const_int 0))]
4911 ""
4912 "")
4913
4914;; ??? We don't have a match-any slot type. Setting the type to unknown
4915;; produces worse code that setting the slot type to A.
4916
4917(define_insn "*trap"
4918 [(trap_if (const_int 1) (match_operand 0 "const_int_operand" ""))]
4919 ""
4920 "break %0"
048d0d36 4921 [(set_attr "itanium_class" "chk_s_i")])
26406018 4922
f90b7a5a
PB
4923(define_expand "ctrapbi4"
4924 [(trap_if (match_operator 0 "ia64_cbranch_operator"
4925 [(match_operand:BI 1 "register_operand" "")
4926 (match_operand:BI 2 "const_int_operand" "")])
4927 (match_operand 3 "" ""))]
26406018 4928 ""
f90b7a5a
PB
4929 "ia64_expand_compare (&operands[0], &operands[1], &operands[2]);")
4930
4931(define_expand "ctrapsi4"
4932 [(trap_if (match_operator 0 "ia64_cbranch_operator"
4933 [(match_operand:SI 1 "gr_register_operand" "")
4934 (match_operand:SI 2 "gr_reg_or_8bit_and_adjusted_operand" "")])
4935 (match_operand 3 "" ""))]
4936 ""
4937 "ia64_expand_compare (&operands[0], &operands[1], &operands[2]);")
4938
4939(define_expand "ctrapdi4"
4940 [(trap_if (match_operator 0 "ia64_cbranch_operator"
4941 [(match_operand:DI 1 "gr_register_operand" "")
4942 (match_operand:DI 2 "gr_reg_or_8bit_and_adjusted_operand" "")])
4943 (match_operand 3 "" ""))]
4944 ""
4945 "ia64_expand_compare (&operands[0], &operands[1], &operands[2]);")
4946
4947(define_expand "ctrapsf4"
4948 [(trap_if (match_operator 0 "ia64_cbranch_operator"
4949 [(match_operand:SF 1 "fr_reg_or_fp01_operand" "")
4950 (match_operand:SF 2 "fr_reg_or_fp01_operand" "")])
4951 (match_operand 3 "" ""))]
4952 ""
4953 "ia64_expand_compare (&operands[0], &operands[1], &operands[2]);")
4954
4955(define_expand "ctrapdf4"
4956 [(trap_if (match_operator 0 "ia64_cbranch_operator"
4957 [(match_operand:DF 1 "fr_reg_or_fp01_operand" "")
4958 (match_operand:DF 2 "fr_reg_or_fp01_operand" "")])
4959 (match_operand 3 "" ""))]
4960 ""
4961 "ia64_expand_compare (&operands[0], &operands[1], &operands[2]);")
4962
4963(define_expand "ctrapxf4"
4964 [(trap_if (match_operator 0 "ia64_cbranch_operator"
4965 [(match_operand:XF 1 "xfreg_or_fp01_operand" "")
4966 (match_operand:XF 2 "xfreg_or_fp01_operand" "")])
4967 (match_operand 3 "" ""))]
4968 ""
4969 "ia64_expand_compare (&operands[0], &operands[1], &operands[2]);")
4970
4971(define_expand "ctraptf4"
4972 [(trap_if (match_operator 0 "ia64_cbranch_operator"
4973 [(match_operand:TF 1 "gr_register_operand" "")
4974 (match_operand:TF 2 "gr_register_operand" "")])
4975 (match_operand 3 "" ""))]
4976 "TARGET_HPUX"
4977 "ia64_expand_compare (&operands[0], &operands[1], &operands[2]);")
4978
26406018
RH
4979
4980(define_insn "*conditional_trap"
4981 [(trap_if (match_operator 0 "predicate_operator"
4982 [(match_operand:BI 1 "register_operand" "c")
4983 (const_int 0)])
4984 (match_operand 2 "const_int_operand" ""))]
4985 ""
5cf63e3f 4986 "(%J0) break %2"
048d0d36 4987 [(set_attr "itanium_class" "chk_s_i")
26406018
RH
4988 (set_attr "predicable" "no")])
4989
f12f25a7 4990(define_insn "break_f"
086c0f96 4991 [(unspec_volatile [(const_int 0)] UNSPECV_BREAK)]
f12f25a7
RH
4992 ""
4993 "break.f 0"
4994 [(set_attr "itanium_class" "nop_f")])
44eca121
JJ
4995
4996(define_insn "prefetch"
4997 [(prefetch (match_operand:DI 0 "address_operand" "p")
4998 (match_operand:DI 1 "const_int_operand" "n")
4999 (match_operand:DI 2 "const_int_operand" "n"))]
5000 ""
5001{
5002 static const char * const alt[2][4] = {
b3656137 5003 {
92cbea22
L
5004 "%,lfetch.nta [%0]",
5005 "%,lfetch.nt1 [%0]",
5006 "%,lfetch.nt2 [%0]",
5007 "%,lfetch [%0]"
b3656137
KG
5008 },
5009 {
92cbea22
L
5010 "%,lfetch.excl.nta [%0]",
5011 "%,lfetch.excl.nt1 [%0]",
5012 "%,lfetch.excl.nt2 [%0]",
5013 "%,lfetch.excl [%0]"
b3656137 5014 }
44eca121
JJ
5015 };
5016 int i = (INTVAL (operands[1]));
5017 int j = (INTVAL (operands[2]));
5018
e820471b
NS
5019 gcc_assert (i == 0 || i == 1);
5020 gcc_assert (j >= 0 && j <= 3);
44eca121
JJ
5021 return alt[i][j];
5022}
5023 [(set_attr "itanium_class" "lfetch")])
c65ebc55
JW
5024\f
5025;; Non-local goto support.
5026
5027(define_expand "save_stack_nonlocal"
5028 [(use (match_operand:OI 0 "memory_operand" ""))
5029 (use (match_operand:DI 1 "register_operand" ""))]
5030 ""
c65ebc55
JW
5031{
5032 emit_library_call (gen_rtx_SYMBOL_REF (Pmode,
5033 \"__ia64_save_stack_nonlocal\"),
bbbbb16a 5034 LCT_NORMAL, VOIDmode, 2, XEXP (operands[0], 0), Pmode,
c65ebc55
JW
5035 operands[1], Pmode);
5036 DONE;
1d5d7a21 5037})
c65ebc55
JW
5038
5039(define_expand "nonlocal_goto"
5040 [(use (match_operand 0 "general_operand" ""))
5041 (use (match_operand 1 "general_operand" ""))
5042 (use (match_operand 2 "general_operand" ""))
5043 (use (match_operand 3 "general_operand" ""))]
5044 ""
c65ebc55 5045{
c65ebc55 5046 emit_library_call (gen_rtx_SYMBOL_REF (Pmode, \"__ia64_nonlocal_goto\"),
8206fc89 5047 LCT_NORETURN, VOIDmode, 3,
7c2b017c 5048 operands[1], Pmode,
c65ebc55 5049 copy_to_reg (XEXP (operands[2], 0)), Pmode,
7c2b017c 5050 operands[3], Pmode);
c65ebc55
JW
5051 emit_barrier ();
5052 DONE;
1d5d7a21 5053})
c65ebc55 5054
39a5cfa4
SE
5055(define_insn_and_split "nonlocal_goto_receiver"
5056 [(unspec_volatile [(const_int 0)] UNSPECV_GOTO_RECEIVER)]
5057 ""
5058 "#"
5059 "reload_completed"
5060 [(const_int 0)]
5061{
5062 ia64_reload_gp ();
5063 DONE;
5064})
5065
b39eb2f9
RH
5066(define_insn_and_split "builtin_setjmp_receiver"
5067 [(unspec_volatile [(match_operand:DI 0 "" "")] UNSPECV_SETJMP_RECEIVER)]
97e242b0 5068 ""
b39eb2f9
RH
5069 "#"
5070 "reload_completed"
5071 [(const_int 0)]
97e242b0 5072{
599aedd9 5073 ia64_reload_gp ();
c65ebc55 5074 DONE;
1d5d7a21 5075})
c65ebc55 5076
0c96007e
AM
5077(define_expand "eh_epilogue"
5078 [(use (match_operand:DI 0 "register_operand" "r"))
5079 (use (match_operand:DI 1 "register_operand" "r"))
5080 (use (match_operand:DI 2 "register_operand" "r"))]
5081 ""
0c96007e
AM
5082{
5083 rtx bsp = gen_rtx_REG (Pmode, 10);
5084 rtx sp = gen_rtx_REG (Pmode, 9);
5085
5086 if (GET_CODE (operands[0]) != REG || REGNO (operands[0]) != 10)
5087 {
5088 emit_move_insn (bsp, operands[0]);
5089 operands[0] = bsp;
5090 }
5091 if (GET_CODE (operands[2]) != REG || REGNO (operands[2]) != 9)
5092 {
5093 emit_move_insn (sp, operands[2]);
5094 operands[2] = sp;
5095 }
c41c1387
RS
5096 emit_use (sp);
5097 emit_use (bsp);
0c96007e
AM
5098
5099 cfun->machine->ia64_eh_epilogue_sp = sp;
5100 cfun->machine->ia64_eh_epilogue_bsp = bsp;
1d5d7a21 5101})
9525c690
JW
5102\f
5103;; Builtin apply support.
5104
5105(define_expand "restore_stack_nonlocal"
5106 [(use (match_operand:DI 0 "register_operand" ""))
5107 (use (match_operand:OI 1 "memory_operand" ""))]
5108 ""
9525c690
JW
5109{
5110 emit_library_call (gen_rtx_SYMBOL_REF (Pmode,
1d5d7a21 5111 "__ia64_restore_stack_nonlocal"),
bbbbb16a 5112 LCT_NORMAL, VOIDmode, 1,
9525c690
JW
5113 copy_to_reg (XEXP (operands[1], 0)), Pmode);
5114 DONE;
1d5d7a21 5115})
9525c690 5116
e5bde68a
RH
5117\f
5118;; Predication.
5119
5120(define_cond_exec
5121 [(match_operator 0 "predicate_operator"
f2f90c63 5122 [(match_operand:BI 1 "register_operand" "c")
e5bde68a
RH
5123 (const_int 0)])]
5124 ""
5125 "(%J0)")
3b572406
RH
5126
5127(define_insn "pred_rel_mutex"
f2f90c63 5128 [(set (match_operand:BI 0 "register_operand" "+c")
086c0f96 5129 (unspec:BI [(match_dup 0)] UNSPEC_PRED_REL_MUTEX))]
3b572406 5130 ""
054451ea 5131 ".pred.rel.mutex %0, %I0"
52e12ad0 5132 [(set_attr "itanium_class" "ignore")
3b572406 5133 (set_attr "predicable" "no")])
ca3920ad
JW
5134
5135(define_insn "safe_across_calls_all"
086c0f96 5136 [(unspec_volatile [(const_int 0)] UNSPECV_PSAC_ALL)]
ca3920ad
JW
5137 ""
5138 ".pred.safe_across_calls p1-p63"
52e12ad0 5139 [(set_attr "itanium_class" "ignore")
ca3920ad
JW
5140 (set_attr "predicable" "no")])
5141
5142(define_insn "safe_across_calls_normal"
086c0f96 5143 [(unspec_volatile [(const_int 0)] UNSPECV_PSAC_NORMAL)]
ca3920ad 5144 ""
ca3920ad 5145{
1bc7c5b6 5146 emit_safe_across_calls ();
1d5d7a21
RH
5147 return "";
5148}
52e12ad0 5149 [(set_attr "itanium_class" "ignore")
ca3920ad
JW
5150 (set_attr "predicable" "no")])
5151
27a9b99d 5152;; UNSPEC instruction definition to "swizzle" 32-bit pointer into 64-bit
6dd12198
SE
5153;; pointer. This is used by the HP-UX 32 bit mode.
5154
5155(define_insn "ptr_extend"
5156 [(set (match_operand:DI 0 "gr_register_operand" "=r")
086c0f96
RH
5157 (unspec:DI [(match_operand:SI 1 "gr_register_operand" "r")]
5158 UNSPEC_ADDP4))]
6dd12198
SE
5159 ""
5160 "addp4 %0 = 0,%1"
5161 [(set_attr "itanium_class" "ialu")])
5162
e206a74f
SE
5163;;
5164;; Optimizations for ptr_extend
5165
36c216e5 5166(define_insn "ptr_extend_plus_imm"
e206a74f
SE
5167 [(set (match_operand:DI 0 "gr_register_operand" "=r")
5168 (unspec:DI
5169 [(plus:SI (match_operand:SI 1 "basereg_operand" "r")
5170 (match_operand:SI 2 "gr_reg_or_14bit_operand" "rI"))]
086c0f96 5171 UNSPEC_ADDP4))]
08744705 5172 "addp4_optimize_ok (operands[1], operands[2])"
e206a74f
SE
5173 "addp4 %0 = %2, %1"
5174 [(set_attr "itanium_class" "ialu")])
5175
5176(define_insn "*ptr_extend_plus_2"
5177 [(set (match_operand:DI 0 "gr_register_operand" "=r")
5178 (unspec:DI
5179 [(plus:SI (match_operand:SI 1 "gr_register_operand" "r")
5180 (match_operand:SI 2 "basereg_operand" "r"))]
086c0f96 5181 UNSPEC_ADDP4))]
08744705 5182 "addp4_optimize_ok (operands[1], operands[2])"
e206a74f
SE
5183 "addp4 %0 = %1, %2"
5184 [(set_attr "itanium_class" "ialu")])
f61134e8 5185
d26afa4f
SE
5186;;
5187;; Get instruction pointer
5188
5189(define_insn "ip_value"
5190 [(set (match_operand:DI 0 "register_operand" "=r")
5191 (pc))]
5192 ""
5193 "mov %0 = ip"
6107a6ae 5194 [(set_attr "itanium_class" "frbr")])
d26afa4f 5195
f61134e8
RH
5196;; Vector operations
5197(include "vect.md")
af795c3c
RH
5198;; Atomic operations
5199(include "sync.md")
4883241c
SE
5200;; New division operations
5201(include "div.md")