OSDN Git Service

b88a8c096bf41a64508bb611a023c70fd158d6ab
[pf3gnuchains/gcc-fork.git] / gcc / config / pa / pa.md
1 ;;- Machine description for HP PA-RISC architecture for GCC compiler
2 ;;   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
3 ;;   2002, 2003, 2004 Free Software Foundation, Inc.
4 ;;   Contributed by the Center for Software Science at the University
5 ;;   of Utah.
6
7 ;; This file is part of GCC.
8
9 ;; GCC is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; any later version.
13
14 ;; GCC is distributed in the hope that it will be useful,
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
20 ;; along with GCC; see the file COPYING.  If not, write to
21 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
23
24 ;; This gcc Version 2 machine description is inspired by sparc.md and
25 ;; mips.md.
26
27 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
28
29 ;; Insn type.  Used to default other attribute values.
30
31 ;; type "unary" insns have one input operand (1) and one output operand (0)
32 ;; type "binary" insns have two input operands (1,2) and one output (0)
33
34 (define_attr "type"
35   "move,unary,binary,shift,nullshift,compare,load,store,uncond_branch,btable_branch,branch,cbranch,fbranch,call,dyncall,fpload,fpstore,fpalu,fpcc,fpmulsgl,fpmuldbl,fpdivsgl,fpdivdbl,fpsqrtsgl,fpsqrtdbl,multi,milli,parallel_branch"
36   (const_string "binary"))
37
38 (define_attr "pa_combine_type"
39   "fmpy,faddsub,uncond_branch,addmove,none"
40   (const_string "none"))
41
42 ;; Processor type (for scheduling, not code generation) -- this attribute
43 ;; must exactly match the processor_type enumeration in pa.h.
44 ;;
45 ;; FIXME: Add 800 scheduling for completeness?
46
47 (define_attr "cpu" "700,7100,7100LC,7200,7300,8000" (const (symbol_ref "pa_cpu_attr")))
48
49 ;; Length (in # of bytes).
50 (define_attr "length" ""
51   (cond [(eq_attr "type" "load,fpload")
52          (if_then_else (match_operand 1 "symbolic_memory_operand" "")
53                        (const_int 8) (const_int 4))
54
55          (eq_attr "type" "store,fpstore")
56          (if_then_else (match_operand 0 "symbolic_memory_operand" "")
57                        (const_int 8) (const_int 4))
58
59          (eq_attr "type" "binary,shift,nullshift")
60          (if_then_else (match_operand 2 "arith_operand" "")
61                        (const_int 4) (const_int 12))
62
63          (eq_attr "type" "move,unary,shift,nullshift")
64          (if_then_else (match_operand 1 "arith_operand" "")
65                        (const_int 4) (const_int 8))]
66
67         (const_int 4)))
68
69 (define_asm_attributes
70   [(set_attr "length" "4")
71    (set_attr "type" "multi")])
72
73 ;; Attributes for instruction and branch scheduling
74
75 ;; For conditional branches.
76 (define_attr "in_branch_delay" "false,true"
77   (if_then_else (and (eq_attr "type" "!uncond_branch,btable_branch,branch,cbranch,fbranch,call,dyncall,multi,milli,parallel_branch")
78                      (eq_attr "length" "4"))
79                 (const_string "true")
80                 (const_string "false")))
81
82 ;; Disallow instructions which use the FPU since they will tie up the FPU
83 ;; even if the instruction is nullified.
84 (define_attr "in_nullified_branch_delay" "false,true"
85   (if_then_else (and (eq_attr "type" "!uncond_branch,btable_branch,branch,cbranch,fbranch,call,dyncall,multi,milli,fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpdivdbl,fpsqrtsgl,fpsqrtdbl,parallel_branch")
86                      (eq_attr "length" "4"))
87                 (const_string "true")
88                 (const_string "false")))
89
90 ;; For calls and millicode calls.  Allow unconditional branches in the
91 ;; delay slot.
92 (define_attr "in_call_delay" "false,true"
93   (cond [(and (eq_attr "type" "!uncond_branch,btable_branch,branch,cbranch,fbranch,call,dyncall,multi,milli,parallel_branch")
94               (eq_attr "length" "4"))
95            (const_string "true")
96          (eq_attr "type" "uncond_branch")
97            (if_then_else (ne (symbol_ref "TARGET_JUMP_IN_DELAY")
98                              (const_int 0))
99                          (const_string "true")
100                          (const_string "false"))]
101         (const_string "false")))
102
103
104 ;; Call delay slot description.
105 (define_delay (eq_attr "type" "call")
106   [(eq_attr "in_call_delay" "true") (nil) (nil)])
107
108 ;; Millicode call delay slot description.
109 (define_delay (eq_attr "type" "milli")
110   [(eq_attr "in_call_delay" "true") (nil) (nil)])
111
112 ;; Return and other similar instructions.
113 (define_delay (eq_attr "type" "btable_branch,branch,parallel_branch")
114   [(eq_attr "in_branch_delay" "true") (nil) (nil)])
115
116 ;; Floating point conditional branch delay slot description and
117 (define_delay (eq_attr "type" "fbranch")
118   [(eq_attr "in_branch_delay" "true")
119    (eq_attr "in_nullified_branch_delay" "true")
120    (nil)])
121
122 ;; Integer conditional branch delay slot description.
123 ;; Nullification of conditional branches on the PA is dependent on the
124 ;; direction of the branch.  Forward branches nullify true and
125 ;; backward branches nullify false.  If the direction is unknown
126 ;; then nullification is not allowed.
127 (define_delay (eq_attr "type" "cbranch")
128   [(eq_attr "in_branch_delay" "true")
129    (and (eq_attr "in_nullified_branch_delay" "true")
130         (attr_flag "forward"))
131    (and (eq_attr "in_nullified_branch_delay" "true")
132         (attr_flag "backward"))])
133
134 (define_delay (and (eq_attr "type" "uncond_branch")
135                    (eq (symbol_ref "following_call (insn)")
136                        (const_int 0)))
137   [(eq_attr "in_branch_delay" "true") (nil) (nil)])
138
139 ;; Memory. Disregarding Cache misses, the Mustang memory times are:
140 ;; load: 2, fpload: 3
141 ;; store, fpstore: 3, no D-cache operations should be scheduled.
142
143 ;; The Timex (aka 700) has two floating-point units: ALU, and MUL/DIV/SQRT.
144 ;; Timings:
145 ;; Instruction  Time    Unit    Minimum Distance (unit contention)
146 ;; fcpy         3       ALU     2
147 ;; fabs         3       ALU     2
148 ;; fadd         3       ALU     2
149 ;; fsub         3       ALU     2
150 ;; fcmp         3       ALU     2
151 ;; fcnv         3       ALU     2
152 ;; fmpyadd      3       ALU,MPY 2
153 ;; fmpysub      3       ALU,MPY 2
154 ;; fmpycfxt     3       ALU,MPY 2
155 ;; fmpy         3       MPY     2
156 ;; fmpyi        3       MPY     2
157 ;; fdiv,sgl     10      MPY     10
158 ;; fdiv,dbl     12      MPY     12
159 ;; fsqrt,sgl    14      MPY     14
160 ;; fsqrt,dbl    18      MPY     18
161 ;;
162 ;; We don't model fmpyadd/fmpysub properly as those instructions
163 ;; keep both the FP ALU and MPY units busy.  Given that these
164 ;; processors are obsolete, I'm not going to spend the time to
165 ;; model those instructions correctly.
166
167 (define_automaton "pa700")
168 (define_cpu_unit "dummy_700,mem_700,fpalu_700,fpmpy_700" "pa700")
169
170 (define_insn_reservation "W0" 4
171   (and (eq_attr "type" "fpcc")
172        (eq_attr "cpu" "700"))
173   "fpalu_700*2")
174
175 (define_insn_reservation "W1" 3
176   (and (eq_attr "type" "fpalu")
177        (eq_attr "cpu" "700"))
178   "fpalu_700*2")
179
180 (define_insn_reservation "W2" 3
181   (and (eq_attr "type" "fpmulsgl,fpmuldbl")
182        (eq_attr "cpu" "700"))
183   "fpmpy_700*2")
184
185 (define_insn_reservation "W3" 10
186   (and (eq_attr "type" "fpdivsgl")
187        (eq_attr "cpu" "700"))
188   "fpmpy_700*10")
189
190 (define_insn_reservation "W4" 12
191   (and (eq_attr "type" "fpdivdbl")
192        (eq_attr "cpu" "700"))
193   "fpmpy_700*12")
194
195 (define_insn_reservation "W5" 14
196   (and (eq_attr "type" "fpsqrtsgl")
197        (eq_attr "cpu" "700"))
198   "fpmpy_700*14")
199
200 (define_insn_reservation "W6" 18
201   (and (eq_attr "type" "fpsqrtdbl")
202        (eq_attr "cpu" "700"))
203   "fpmpy_700*18")
204
205 (define_insn_reservation "W7" 2
206   (and (eq_attr "type" "load")
207        (eq_attr "cpu" "700"))
208   "mem_700")
209
210 (define_insn_reservation "W8" 2
211   (and (eq_attr "type" "fpload")
212        (eq_attr "cpu" "700"))
213   "mem_700")
214
215 (define_insn_reservation "W9" 3
216   (and (eq_attr "type" "store")
217        (eq_attr "cpu" "700"))
218   "mem_700*3")
219
220 (define_insn_reservation "W10" 3
221   (and (eq_attr "type" "fpstore")
222        (eq_attr "cpu" "700"))
223   "mem_700*3")
224
225 (define_insn_reservation "W11" 1
226   (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpdivdbl,fpsqrtsgl,fpsqrtdbl,load,fpload,store,fpstore")
227        (eq_attr "cpu" "700"))
228   "dummy_700")
229
230 ;; We have a bypass for all computations in the FP unit which feed an
231 ;; FP store as long as the sizes are the same.
232 (define_bypass 2 "W1,W2" "W10" "hppa_fpstore_bypass_p")
233 (define_bypass 9 "W3" "W10" "hppa_fpstore_bypass_p")
234 (define_bypass 11 "W4" "W10" "hppa_fpstore_bypass_p")
235 (define_bypass 13 "W5" "W10" "hppa_fpstore_bypass_p")
236 (define_bypass 17 "W6" "W10" "hppa_fpstore_bypass_p")
237
238 ;; We have an "anti-bypass" for FP loads which feed an FP store.
239 (define_bypass 4 "W8" "W10" "hppa_fpstore_bypass_p")
240
241 ;; Function units for the 7100 and 7150.  The 7100/7150 can dual-issue
242 ;; floating point computations with non-floating point computations (fp loads
243 ;; and stores are not fp computations).
244 ;;
245 ;; Memory. Disregarding Cache misses, memory loads take two cycles; stores also
246 ;; take two cycles, during which no Dcache operations should be scheduled.
247 ;; Any special cases are handled in pa_adjust_cost.  The 7100, 7150 and 7100LC
248 ;; all have the same memory characteristics if one disregards cache misses.
249 ;;
250 ;; The 7100/7150 has three floating-point units: ALU, MUL, and DIV.
251 ;; There's no value in modeling the ALU and MUL separately though
252 ;; since there can never be a functional unit conflict given the
253 ;; latency and issue rates for those units.
254 ;;
255 ;; Timings:
256 ;; Instruction  Time    Unit    Minimum Distance (unit contention)
257 ;; fcpy         2       ALU     1
258 ;; fabs         2       ALU     1
259 ;; fadd         2       ALU     1
260 ;; fsub         2       ALU     1
261 ;; fcmp         2       ALU     1
262 ;; fcnv         2       ALU     1
263 ;; fmpyadd      2       ALU,MPY 1
264 ;; fmpysub      2       ALU,MPY 1
265 ;; fmpycfxt     2       ALU,MPY 1
266 ;; fmpy         2       MPY     1
267 ;; fmpyi        2       MPY     1
268 ;; fdiv,sgl     8       DIV     8
269 ;; fdiv,dbl     15      DIV     15
270 ;; fsqrt,sgl    8       DIV     8
271 ;; fsqrt,dbl    15      DIV     15
272
273 (define_automaton "pa7100")
274 (define_cpu_unit "i_7100, f_7100,fpmac_7100,fpdivsqrt_7100,mem_7100" "pa7100")
275
276 (define_insn_reservation "X0" 2
277   (and (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
278        (eq_attr "cpu" "7100"))
279   "f_7100,fpmac_7100")
280
281 (define_insn_reservation "X1" 8
282   (and (eq_attr "type" "fpdivsgl,fpsqrtsgl")
283        (eq_attr "cpu" "7100"))
284   "f_7100+fpdivsqrt_7100,fpdivsqrt_7100*7")
285
286 (define_insn_reservation "X2" 15
287   (and (eq_attr "type" "fpdivdbl,fpsqrtdbl")
288        (eq_attr "cpu" "7100"))
289   "f_7100+fpdivsqrt_7100,fpdivsqrt_7100*14")
290
291 (define_insn_reservation "X3" 2
292   (and (eq_attr "type" "load")
293        (eq_attr "cpu" "7100"))
294   "i_7100+mem_7100")
295
296 (define_insn_reservation "X4" 2
297   (and (eq_attr "type" "fpload")
298        (eq_attr "cpu" "7100"))
299   "i_7100+mem_7100")
300
301 (define_insn_reservation "X5" 2
302   (and (eq_attr "type" "store")
303        (eq_attr "cpu" "7100"))
304   "i_7100+mem_7100,mem_7100")
305
306 (define_insn_reservation "X6" 2
307   (and (eq_attr "type" "fpstore")
308        (eq_attr "cpu" "7100"))
309   "i_7100+mem_7100,mem_7100")
310
311 (define_insn_reservation "X7" 1
312   (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl,load,fpload,store,fpstore")
313        (eq_attr "cpu" "7100"))
314   "i_7100")
315
316 ;; We have a bypass for all computations in the FP unit which feed an
317 ;; FP store as long as the sizes are the same.
318 (define_bypass 1 "X0" "X6" "hppa_fpstore_bypass_p")
319 (define_bypass 7 "X1" "X6" "hppa_fpstore_bypass_p")
320 (define_bypass 14 "X2" "X6" "hppa_fpstore_bypass_p")
321
322 ;; We have an "anti-bypass" for FP loads which feed an FP store.
323 (define_bypass 3 "X4" "X6" "hppa_fpstore_bypass_p")
324
325 ;; The 7100LC has three floating-point units: ALU, MUL, and DIV.
326 ;; There's no value in modeling the ALU and MUL separately though
327 ;; since there can never be a functional unit conflict that
328 ;; can be avoided given the latency, issue rates and mandatory
329 ;; one cycle cpu-wide lock for a double precision fp multiply.
330 ;;
331 ;; Timings:
332 ;; Instruction  Time    Unit    Minimum Distance (unit contention)
333 ;; fcpy         2       ALU     1
334 ;; fabs         2       ALU     1
335 ;; fadd         2       ALU     1
336 ;; fsub         2       ALU     1
337 ;; fcmp         2       ALU     1
338 ;; fcnv         2       ALU     1
339 ;; fmpyadd,sgl  2       ALU,MPY 1
340 ;; fmpyadd,dbl  3       ALU,MPY 2
341 ;; fmpysub,sgl  2       ALU,MPY 1
342 ;; fmpysub,dbl  3       ALU,MPY 2
343 ;; fmpycfxt,sgl 2       ALU,MPY 1
344 ;; fmpycfxt,dbl 3       ALU,MPY 2
345 ;; fmpy,sgl     2       MPY     1
346 ;; fmpy,dbl     3       MPY     2
347 ;; fmpyi        3       MPY     2
348 ;; fdiv,sgl     8       DIV     8
349 ;; fdiv,dbl     15      DIV     15
350 ;; fsqrt,sgl    8       DIV     8
351 ;; fsqrt,dbl    15      DIV     15
352 ;;
353 ;; The PA7200 is just like the PA7100LC except that there is
354 ;; no store-store penalty.
355 ;;
356 ;; The PA7300 is just like the PA7200 except that there is
357 ;; no store-load penalty.
358 ;;
359 ;; Note there are some aspects of the 7100LC we are not modeling
360 ;; at the moment.  I'll be reviewing the 7100LC scheduling info
361 ;; shortly and updating this description.
362 ;;
363 ;;   load-load pairs
364 ;;   store-store pairs
365 ;;   other issue modeling
366
367 (define_automaton "pa7100lc")
368 (define_cpu_unit "i0_7100lc, i1_7100lc, f_7100lc" "pa7100lc")
369 (define_cpu_unit "fpmac_7100lc" "pa7100lc")
370 (define_cpu_unit "mem_7100lc" "pa7100lc")
371
372 ;; Double precision multiplies lock the entire CPU for one
373 ;; cycle.  There is no way to avoid this lock and trying to
374 ;; schedule around the lock is pointless and thus there is no
375 ;; value in trying to model this lock.
376 ;;
377 ;; Not modeling the lock allows us to treat fp multiplies just
378 ;; like any other FP alu instruction.  It allows for a smaller
379 ;; DFA and may reduce register pressure.
380 (define_insn_reservation "Y0" 2
381   (and (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
382        (eq_attr "cpu" "7100LC,7200,7300"))
383   "f_7100lc,fpmac_7100lc")
384
385 ;; fp division and sqrt instructions lock the entire CPU for
386 ;; 7 cycles (single precision) or 14 cycles (double precision).
387 ;; There is no way to avoid this lock and trying to schedule
388 ;; around the lock is pointless and thus there is no value in
389 ;; trying to model this lock.  Not modeling the lock allows
390 ;; for a smaller DFA and may reduce register pressure.
391 (define_insn_reservation "Y1" 1
392   (and (eq_attr "type" "fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl")
393        (eq_attr "cpu" "7100LC,7200,7300"))
394   "f_7100lc")
395
396 (define_insn_reservation "Y2" 2
397   (and (eq_attr "type" "load")
398        (eq_attr "cpu" "7100LC,7200,7300"))
399   "i1_7100lc+mem_7100lc")
400
401 (define_insn_reservation "Y3" 2
402   (and (eq_attr "type" "fpload")
403        (eq_attr "cpu" "7100LC,7200,7300"))
404   "i1_7100lc+mem_7100lc")
405
406 (define_insn_reservation "Y4" 2
407   (and (eq_attr "type" "store")
408        (eq_attr "cpu" "7100LC"))
409   "i1_7100lc+mem_7100lc,mem_7100lc")
410
411 (define_insn_reservation "Y5" 2
412   (and (eq_attr "type" "fpstore")
413        (eq_attr "cpu" "7100LC"))
414   "i1_7100lc+mem_7100lc,mem_7100lc")
415
416 (define_insn_reservation "Y6" 1
417   (and (eq_attr "type" "shift,nullshift")
418        (eq_attr "cpu" "7100LC,7200,7300"))
419   "i1_7100lc")
420
421 (define_insn_reservation "Y7" 1
422   (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl,load,fpload,store,fpstore,shift,nullshift")
423        (eq_attr "cpu" "7100LC,7200,7300"))
424   "(i0_7100lc|i1_7100lc)")
425
426 ;; The 7200 has a store-load penalty
427 (define_insn_reservation "Y8" 2
428   (and (eq_attr "type" "store")
429        (eq_attr "cpu" "7200"))
430   "i1_7100lc,mem_7100lc")
431
432 (define_insn_reservation "Y9" 2
433   (and (eq_attr "type" "fpstore")
434        (eq_attr "cpu" "7200"))
435   "i1_7100lc,mem_7100lc")
436
437 ;; The 7300 has no penalty for store-store or store-load
438 (define_insn_reservation "Y10" 2
439   (and (eq_attr "type" "store")
440        (eq_attr "cpu" "7300"))
441   "i1_7100lc")
442
443 (define_insn_reservation "Y11" 2
444   (and (eq_attr "type" "fpstore")
445        (eq_attr "cpu" "7300"))
446   "i1_7100lc")
447
448 ;; We have an "anti-bypass" for FP loads which feed an FP store.
449 (define_bypass 3 "Y3" "Y5,Y9,Y11" "hppa_fpstore_bypass_p")
450
451 ;; Scheduling for the PA8000 is somewhat different than scheduling for a
452 ;; traditional architecture.
453 ;;
454 ;; The PA8000 has a large (56) entry reorder buffer that is split between
455 ;; memory and non-memory operations.
456 ;;
457 ;; The PA8000 can issue two memory and two non-memory operations per cycle to
458 ;; the function units, with the exception of branches and multi-output
459 ;; instructions.  The PA8000 can retire two non-memory operations per cycle
460 ;; and two memory operations per cycle, only one of which may be a store.
461 ;;
462 ;; Given the large reorder buffer, the processor can hide most latencies.
463 ;; According to HP, they've got the best results by scheduling for retirement
464 ;; bandwidth with limited latency scheduling for floating point operations.
465 ;; Latency for integer operations and memory references is ignored.
466 ;;
467 ;;
468 ;; We claim floating point operations have a 2 cycle latency and are
469 ;; fully pipelined, except for div and sqrt which are not pipelined and
470 ;; take from 17 to 31 cycles to complete.
471 ;;
472 ;; It's worth noting that there is no way to saturate all the functional
473 ;; units on the PA8000 as there is not enough issue bandwidth.
474
475 (define_automaton "pa8000")
476 (define_cpu_unit "inm0_8000, inm1_8000, im0_8000, im1_8000" "pa8000")
477 (define_cpu_unit "rnm0_8000, rnm1_8000, rm0_8000, rm1_8000" "pa8000")
478 (define_cpu_unit "store_8000" "pa8000")
479 (define_cpu_unit "f0_8000, f1_8000" "pa8000")
480 (define_cpu_unit "fdivsqrt0_8000, fdivsqrt1_8000" "pa8000")
481 (define_reservation "inm_8000" "inm0_8000 | inm1_8000")
482 (define_reservation "im_8000" "im0_8000 | im1_8000")
483 (define_reservation "rnm_8000" "rnm0_8000 | rnm1_8000")
484 (define_reservation "rm_8000" "rm0_8000 | rm1_8000")
485 (define_reservation "f_8000" "f0_8000 | f1_8000")
486 (define_reservation "fdivsqrt_8000" "fdivsqrt0_8000 | fdivsqrt1_8000")
487
488 ;; We can issue any two memops per cycle, but we can only retire
489 ;; one memory store per cycle.  We assume that the reorder buffer
490 ;; will hide any memory latencies per HP's recommendation.
491 (define_insn_reservation "Z0" 0
492   (and
493     (eq_attr "type" "load,fpload")
494     (eq_attr "cpu" "8000"))
495   "im_8000,rm_8000")
496
497 (define_insn_reservation "Z1" 0
498   (and
499     (eq_attr "type" "store,fpstore")
500     (eq_attr "cpu" "8000"))
501   "im_8000,rm_8000+store_8000")
502
503 ;; We can issue and retire two non-memory operations per cycle with
504 ;; a few exceptions (branches).  This group catches those we want
505 ;; to assume have zero latency.
506 (define_insn_reservation "Z2" 0
507   (and
508     (eq_attr "type" "!load,fpload,store,fpstore,uncond_branch,btable_branch,branch,cbranch,fbranch,call,dyncall,multi,milli,parallel_branch,fpcc,fpalu,fpmulsgl,fpmuldbl,fpsqrtsgl,fpsqrtdbl,fpdivsgl,fpdivdbl")
509     (eq_attr "cpu" "8000"))
510   "inm_8000,rnm_8000")
511
512 ;; Branches use both slots in the non-memory issue and
513 ;; retirement unit.
514 (define_insn_reservation "Z3" 0
515   (and
516     (eq_attr "type" "uncond_branch,btable_branch,branch,cbranch,fbranch,call,dyncall,multi,milli,parallel_branch")
517     (eq_attr "cpu" "8000"))
518   "inm0_8000+inm1_8000,rnm0_8000+rnm1_8000")
519
520 ;; We partial latency schedule the floating point units.
521 ;; They can issue/retire two at a time in the non-memory
522 ;; units.  We fix their latency at 2 cycles and they
523 ;; are fully pipelined.
524 (define_insn_reservation "Z4" 1
525  (and
526    (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
527    (eq_attr "cpu" "8000"))
528  "inm_8000,f_8000,rnm_8000")
529
530 ;; The fdivsqrt units are not pipelined and have a very long latency.  
531 ;; To keep the DFA from exploding, we do not show all the
532 ;; reservations for the divsqrt unit.
533 (define_insn_reservation "Z5" 17
534  (and
535    (eq_attr "type" "fpdivsgl,fpsqrtsgl")
536    (eq_attr "cpu" "8000"))
537  "inm_8000,fdivsqrt_8000*6,rnm_8000")
538
539 (define_insn_reservation "Z6" 31
540  (and
541    (eq_attr "type" "fpdivdbl,fpsqrtdbl")
542    (eq_attr "cpu" "8000"))
543  "inm_8000,fdivsqrt_8000*6,rnm_8000")
544
545
546 \f
547 ;; Compare instructions.
548 ;; This controls RTL generation and register allocation.
549
550 ;; We generate RTL for comparisons and branches by having the cmpxx
551 ;; patterns store away the operands.  Then, the scc and bcc patterns
552 ;; emit RTL for both the compare and the branch.
553 ;;
554
555 (define_expand "cmpdi"
556   [(set (reg:CC 0)
557         (compare:CC (match_operand:DI 0 "reg_or_0_operand" "")
558                     (match_operand:DI 1 "register_operand" "")))]
559   "TARGET_64BIT"
560
561   "
562 {
563  hppa_compare_op0 = operands[0];
564  hppa_compare_op1 = operands[1];
565  hppa_branch_type = CMP_SI;
566  DONE;
567 }")
568
569 (define_expand "cmpsi"
570   [(set (reg:CC 0)
571         (compare:CC (match_operand:SI 0 "reg_or_0_operand" "")
572                     (match_operand:SI 1 "arith5_operand" "")))]
573   ""
574   "
575 {
576  hppa_compare_op0 = operands[0];
577  hppa_compare_op1 = operands[1];
578  hppa_branch_type = CMP_SI;
579  DONE;
580 }")
581
582 (define_expand "cmpsf"
583   [(set (reg:CCFP 0)
584         (compare:CCFP (match_operand:SF 0 "reg_or_0_operand" "")
585                       (match_operand:SF 1 "reg_or_0_operand" "")))]
586   "! TARGET_SOFT_FLOAT"
587   "
588 {
589   hppa_compare_op0 = operands[0];
590   hppa_compare_op1 = operands[1];
591   hppa_branch_type = CMP_SF;
592   DONE;
593 }")
594
595 (define_expand "cmpdf"
596   [(set (reg:CCFP 0)
597       (compare:CCFP (match_operand:DF 0 "reg_or_0_operand" "")
598                     (match_operand:DF 1 "reg_or_0_operand" "")))]
599   "! TARGET_SOFT_FLOAT"
600   "
601 {
602   hppa_compare_op0 = operands[0];
603   hppa_compare_op1 = operands[1];
604   hppa_branch_type = CMP_DF;
605   DONE;
606 }")
607
608 (define_insn ""
609   [(set (reg:CCFP 0)
610         (match_operator:CCFP 2 "comparison_operator"
611                              [(match_operand:SF 0 "reg_or_0_operand" "fG")
612                               (match_operand:SF 1 "reg_or_0_operand" "fG")]))]
613   "! TARGET_SOFT_FLOAT"
614   "fcmp,sgl,%Y2 %f0,%f1"
615   [(set_attr "length" "4")
616    (set_attr "type" "fpcc")])
617
618 (define_insn ""
619   [(set (reg:CCFP 0)
620         (match_operator:CCFP 2 "comparison_operator"
621                              [(match_operand:DF 0 "reg_or_0_operand" "fG")
622                               (match_operand:DF 1 "reg_or_0_operand" "fG")]))]
623   "! TARGET_SOFT_FLOAT"
624   "fcmp,dbl,%Y2 %f0,%f1"
625   [(set_attr "length" "4")
626    (set_attr "type" "fpcc")])
627
628 ;; Provide a means to emit the movccfp0 and movccfp1 optimization
629 ;; placeholders.  This is necessary in rare situations when a
630 ;; placeholder is re-emitted (see PR 8705).
631
632 (define_expand "movccfp"
633   [(set (reg:CCFP 0)
634         (match_operand 0 "const_int_operand" ""))]
635   "! TARGET_SOFT_FLOAT"
636   "
637 {
638   if ((unsigned HOST_WIDE_INT) INTVAL (operands[0]) > 1)
639     FAIL;
640 }")
641
642 ;; The following patterns are optimization placeholders.  In almost
643 ;; all cases, the user of the condition code will be simplified and the
644 ;; original condition code setting insn should be eliminated.
645
646 (define_insn "*movccfp0"
647   [(set (reg:CCFP 0)
648         (const_int 0))]
649   "! TARGET_SOFT_FLOAT"
650   "fcmp,dbl,= %%fr0,%%fr0"
651   [(set_attr "length" "4")
652    (set_attr "type" "fpcc")])
653
654 (define_insn "*movccfp1"
655   [(set (reg:CCFP 0)
656         (const_int 1))]
657   "! TARGET_SOFT_FLOAT"
658   "fcmp,dbl,!= %%fr0,%%fr0"
659   [(set_attr "length" "4")
660    (set_attr "type" "fpcc")])
661
662 ;; scc insns.
663
664 (define_expand "seq"
665   [(set (match_operand:SI 0 "register_operand" "")
666         (eq:SI (match_dup 1)
667                (match_dup 2)))]
668   "!TARGET_64BIT"
669   "
670 {
671   /* fp scc patterns rarely match, and are not a win on the PA.  */
672   if (hppa_branch_type != CMP_SI)
673     FAIL;
674   /* set up operands from compare.  */
675   operands[1] = hppa_compare_op0;
676   operands[2] = hppa_compare_op1;
677   /* fall through and generate default code */
678 }")
679
680 (define_expand "sne"
681   [(set (match_operand:SI 0 "register_operand" "")
682         (ne:SI (match_dup 1)
683                (match_dup 2)))]
684   "!TARGET_64BIT"
685   "
686 {
687   /* fp scc patterns rarely match, and are not a win on the PA.  */
688   if (hppa_branch_type != CMP_SI)
689     FAIL;
690   operands[1] = hppa_compare_op0;
691   operands[2] = hppa_compare_op1;
692 }")
693
694 (define_expand "slt"
695   [(set (match_operand:SI 0 "register_operand" "")
696         (lt:SI (match_dup 1)
697                (match_dup 2)))]
698   "!TARGET_64BIT"
699   "
700 {
701   /* fp scc patterns rarely match, and are not a win on the PA.  */
702   if (hppa_branch_type != CMP_SI)
703     FAIL;
704   operands[1] = hppa_compare_op0;
705   operands[2] = hppa_compare_op1;
706 }")
707
708 (define_expand "sgt"
709   [(set (match_operand:SI 0 "register_operand" "")
710         (gt:SI (match_dup 1)
711                (match_dup 2)))]
712   "!TARGET_64BIT"
713   "
714 {
715   /* fp scc patterns rarely match, and are not a win on the PA.  */
716   if (hppa_branch_type != CMP_SI)
717     FAIL;
718   operands[1] = hppa_compare_op0;
719   operands[2] = hppa_compare_op1;
720 }")
721
722 (define_expand "sle"
723   [(set (match_operand:SI 0 "register_operand" "")
724         (le:SI (match_dup 1)
725                (match_dup 2)))]
726   "!TARGET_64BIT"
727   "
728 {
729   /* fp scc patterns rarely match, and are not a win on the PA.  */
730   if (hppa_branch_type != CMP_SI)
731     FAIL;
732   operands[1] = hppa_compare_op0;
733   operands[2] = hppa_compare_op1;
734 }")
735
736 (define_expand "sge"
737   [(set (match_operand:SI 0 "register_operand" "")
738         (ge:SI (match_dup 1)
739                (match_dup 2)))]
740   "!TARGET_64BIT"
741   "
742 {
743   /* fp scc patterns rarely match, and are not a win on the PA.  */
744   if (hppa_branch_type != CMP_SI)
745     FAIL;
746   operands[1] = hppa_compare_op0;
747   operands[2] = hppa_compare_op1;
748 }")
749
750 (define_expand "sltu"
751   [(set (match_operand:SI 0 "register_operand" "")
752         (ltu:SI (match_dup 1)
753                 (match_dup 2)))]
754   "!TARGET_64BIT"
755   "
756 {
757   if (hppa_branch_type != CMP_SI)
758     FAIL;
759   operands[1] = hppa_compare_op0;
760   operands[2] = hppa_compare_op1;
761 }")
762
763 (define_expand "sgtu"
764   [(set (match_operand:SI 0 "register_operand" "")
765         (gtu:SI (match_dup 1)
766                 (match_dup 2)))]
767   "!TARGET_64BIT"
768   "
769 {
770   if (hppa_branch_type != CMP_SI)
771     FAIL;
772   operands[1] = hppa_compare_op0;
773   operands[2] = hppa_compare_op1;
774 }")
775
776 (define_expand "sleu"
777   [(set (match_operand:SI 0 "register_operand" "")
778         (leu:SI (match_dup 1)
779                 (match_dup 2)))]
780   "!TARGET_64BIT"
781   "
782 {
783   if (hppa_branch_type != CMP_SI)
784     FAIL;
785   operands[1] = hppa_compare_op0;
786   operands[2] = hppa_compare_op1;
787 }")
788
789 (define_expand "sgeu"
790   [(set (match_operand:SI 0 "register_operand" "")
791         (geu:SI (match_dup 1)
792                 (match_dup 2)))]
793   "!TARGET_64BIT"
794   "
795 {
796   if (hppa_branch_type != CMP_SI)
797     FAIL;
798   operands[1] = hppa_compare_op0;
799   operands[2] = hppa_compare_op1;
800 }")
801
802 ;; Instruction canonicalization puts immediate operands second, which
803 ;; is the reverse of what we want.
804
805 (define_insn "scc"
806   [(set (match_operand:SI 0 "register_operand" "=r")
807         (match_operator:SI 3 "comparison_operator"
808                            [(match_operand:SI 1 "register_operand" "r")
809                             (match_operand:SI 2 "arith11_operand" "rI")]))]
810   ""
811   "{com%I2clr|cmp%I2clr},%B3 %2,%1,%0\;ldi 1,%0"
812   [(set_attr "type" "binary")
813    (set_attr "length" "8")])
814
815 (define_insn ""
816   [(set (match_operand:DI 0 "register_operand" "=r")
817         (match_operator:DI 3 "comparison_operator"
818                            [(match_operand:DI 1 "register_operand" "r")
819                             (match_operand:DI 2 "arith11_operand" "rI")]))]
820   "TARGET_64BIT"
821   "cmp%I2clr,*%B3 %2,%1,%0\;ldi 1,%0"
822   [(set_attr "type" "binary")
823    (set_attr "length" "8")])
824
825 (define_insn "iorscc"
826   [(set (match_operand:SI 0 "register_operand" "=r")
827         (ior:SI (match_operator:SI 3 "comparison_operator"
828                                    [(match_operand:SI 1 "register_operand" "r")
829                                     (match_operand:SI 2 "arith11_operand" "rI")])
830                 (match_operator:SI 6 "comparison_operator"
831                                    [(match_operand:SI 4 "register_operand" "r")
832                                     (match_operand:SI 5 "arith11_operand" "rI")])))]
833   ""
834   "{com%I2clr|cmp%I2clr},%S3 %2,%1,%%r0\;{com%I5clr|cmp%I5clr},%B6 %5,%4,%0\;ldi 1,%0"
835   [(set_attr "type" "binary")
836    (set_attr "length" "12")])
837
838 (define_insn ""
839   [(set (match_operand:DI 0 "register_operand" "=r")
840         (ior:DI (match_operator:DI 3 "comparison_operator"
841                                    [(match_operand:DI 1 "register_operand" "r")
842                                     (match_operand:DI 2 "arith11_operand" "rI")])
843                 (match_operator:DI 6 "comparison_operator"
844                                    [(match_operand:DI 4 "register_operand" "r")
845                                     (match_operand:DI 5 "arith11_operand" "rI")])))]
846   "TARGET_64BIT"
847   "cmp%I2clr,*%S3 %2,%1,%%r0\;cmp%I5clr,*%B6 %5,%4,%0\;ldi 1,%0"
848   [(set_attr "type" "binary")
849    (set_attr "length" "12")])
850
851 ;; Combiner patterns for common operations performed with the output
852 ;; from an scc insn (negscc and incscc).
853 (define_insn "negscc"
854   [(set (match_operand:SI 0 "register_operand" "=r")
855         (neg:SI (match_operator:SI 3 "comparison_operator"
856                [(match_operand:SI 1 "register_operand" "r")
857                 (match_operand:SI 2 "arith11_operand" "rI")])))]
858   ""
859   "{com%I2clr|cmp%I2clr},%B3 %2,%1,%0\;ldi -1,%0"
860   [(set_attr "type" "binary")
861    (set_attr "length" "8")])
862
863 (define_insn ""
864   [(set (match_operand:DI 0 "register_operand" "=r")
865         (neg:DI (match_operator:DI 3 "comparison_operator"
866                [(match_operand:DI 1 "register_operand" "r")
867                 (match_operand:DI 2 "arith11_operand" "rI")])))]
868   "TARGET_64BIT"
869   "cmp%I2clr,*%B3 %2,%1,%0\;ldi -1,%0"
870   [(set_attr "type" "binary")
871    (set_attr "length" "8")])
872
873 ;; Patterns for adding/subtracting the result of a boolean expression from
874 ;; a register.  First we have special patterns that make use of the carry
875 ;; bit, and output only two instructions.  For the cases we can't in
876 ;; general do in two instructions, the incscc pattern at the end outputs
877 ;; two or three instructions.
878
879 (define_insn ""
880   [(set (match_operand:SI 0 "register_operand" "=r")
881         (plus:SI (leu:SI (match_operand:SI 2 "register_operand" "r")
882                          (match_operand:SI 3 "arith11_operand" "rI"))
883                  (match_operand:SI 1 "register_operand" "r")))]
884   ""
885   "sub%I3 %3,%2,%%r0\;{addc|add,c} %%r0,%1,%0"
886   [(set_attr "type" "binary")
887    (set_attr "length" "8")])
888
889 (define_insn ""
890   [(set (match_operand:DI 0 "register_operand" "=r")
891         (plus:DI (leu:DI (match_operand:DI 2 "register_operand" "r")
892                          (match_operand:DI 3 "arith11_operand" "rI"))
893                  (match_operand:DI 1 "register_operand" "r")))]
894   "TARGET_64BIT"
895   "sub%I3 %3,%2,%%r0\;add,dc %%r0,%1,%0"
896   [(set_attr "type" "binary")
897    (set_attr "length" "8")])
898
899 ; This need only accept registers for op3, since canonicalization
900 ; replaces geu with gtu when op3 is an integer.
901 (define_insn ""
902   [(set (match_operand:SI 0 "register_operand" "=r")
903         (plus:SI (geu:SI (match_operand:SI 2 "register_operand" "r")
904                          (match_operand:SI 3 "register_operand" "r"))
905                  (match_operand:SI 1 "register_operand" "r")))]
906   ""
907   "sub %2,%3,%%r0\;{addc|add,c} %%r0,%1,%0"
908   [(set_attr "type" "binary")
909    (set_attr "length" "8")])
910
911 (define_insn ""
912   [(set (match_operand:DI 0 "register_operand" "=r")
913         (plus:DI (geu:DI (match_operand:DI 2 "register_operand" "r")
914                          (match_operand:DI 3 "register_operand" "r"))
915                  (match_operand:DI 1 "register_operand" "r")))]
916   "TARGET_64BIT"
917   "sub %2,%3,%%r0\;add,dc %%r0,%1,%0"
918   [(set_attr "type" "binary")
919    (set_attr "length" "8")])
920
921 ; Match only integers for op3 here.  This is used as canonical form of the
922 ; geu pattern when op3 is an integer.  Don't match registers since we can't
923 ; make better code than the general incscc pattern.
924 (define_insn ""
925   [(set (match_operand:SI 0 "register_operand" "=r")
926         (plus:SI (gtu:SI (match_operand:SI 2 "register_operand" "r")
927                          (match_operand:SI 3 "int11_operand" "I"))
928                  (match_operand:SI 1 "register_operand" "r")))]
929   ""
930   "addi %k3,%2,%%r0\;{addc|add,c} %%r0,%1,%0"
931   [(set_attr "type" "binary")
932    (set_attr "length" "8")])
933
934 (define_insn ""
935   [(set (match_operand:DI 0 "register_operand" "=r")
936         (plus:DI (gtu:DI (match_operand:DI 2 "register_operand" "r")
937                          (match_operand:DI 3 "int11_operand" "I"))
938                  (match_operand:DI 1 "register_operand" "r")))]
939   "TARGET_64BIT"
940   "addi %k3,%2,%%r0\;add,dc %%r0,%1,%0"
941   [(set_attr "type" "binary")
942    (set_attr "length" "8")])
943
944 (define_insn "incscc"
945   [(set (match_operand:SI 0 "register_operand" "=r,r")
946         (plus:SI (match_operator:SI 4 "comparison_operator"
947                     [(match_operand:SI 2 "register_operand" "r,r")
948                      (match_operand:SI 3 "arith11_operand" "rI,rI")])
949                  (match_operand:SI 1 "register_operand" "0,?r")))]
950   ""
951   "@
952    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi 1,%0,%0
953    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi,tr 1,%1,%0\;copy %1,%0"
954   [(set_attr "type" "binary,binary")
955    (set_attr "length" "8,12")])
956
957 (define_insn ""
958   [(set (match_operand:DI 0 "register_operand" "=r,r")
959         (plus:DI (match_operator:DI 4 "comparison_operator"
960                     [(match_operand:DI 2 "register_operand" "r,r")
961                      (match_operand:DI 3 "arith11_operand" "rI,rI")])
962                  (match_operand:DI 1 "register_operand" "0,?r")))]
963   "TARGET_64BIT"
964   "@
965    cmp%I3clr,*%B4 %3,%2,%%r0\;addi 1,%0,%0
966    cmp%I3clr,*%B4 %3,%2,%%r0\;addi,tr 1,%1,%0\;copy %1,%0"
967   [(set_attr "type" "binary,binary")
968    (set_attr "length" "8,12")])
969
970 (define_insn ""
971   [(set (match_operand:SI 0 "register_operand" "=r")
972         (minus:SI (match_operand:SI 1 "register_operand" "r")
973                   (gtu:SI (match_operand:SI 2 "register_operand" "r")
974                           (match_operand:SI 3 "arith11_operand" "rI"))))]
975   ""
976   "sub%I3 %3,%2,%%r0\;{subb|sub,b} %1,%%r0,%0"
977   [(set_attr "type" "binary")
978    (set_attr "length" "8")])
979
980 (define_insn ""
981   [(set (match_operand:DI 0 "register_operand" "=r")
982         (minus:DI (match_operand:DI 1 "register_operand" "r")
983                   (gtu:DI (match_operand:DI 2 "register_operand" "r")
984                           (match_operand:DI 3 "arith11_operand" "rI"))))]
985   "TARGET_64BIT"
986   "sub%I3 %3,%2,%%r0\;sub,db %1,%%r0,%0"
987   [(set_attr "type" "binary")
988    (set_attr "length" "8")])
989
990 (define_insn ""
991   [(set (match_operand:SI 0 "register_operand" "=r")
992         (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
993                             (gtu:SI (match_operand:SI 2 "register_operand" "r")
994                                     (match_operand:SI 3 "arith11_operand" "rI")))
995                   (match_operand:SI 4 "register_operand" "r")))]
996   ""
997   "sub%I3 %3,%2,%%r0\;{subb|sub,b} %1,%4,%0"
998   [(set_attr "type" "binary")
999    (set_attr "length" "8")])
1000
1001 (define_insn ""
1002   [(set (match_operand:DI 0 "register_operand" "=r")
1003         (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
1004                             (gtu:DI (match_operand:DI 2 "register_operand" "r")
1005                                     (match_operand:DI 3 "arith11_operand" "rI")))
1006                   (match_operand:DI 4 "register_operand" "r")))]
1007   "TARGET_64BIT"
1008   "sub%I3 %3,%2,%%r0\;sub,db %1,%4,%0"
1009   [(set_attr "type" "binary")
1010    (set_attr "length" "8")])
1011
1012 ; This need only accept registers for op3, since canonicalization
1013 ; replaces ltu with leu when op3 is an integer.
1014 (define_insn ""
1015   [(set (match_operand:SI 0 "register_operand" "=r")
1016         (minus:SI (match_operand:SI 1 "register_operand" "r")
1017                   (ltu:SI (match_operand:SI 2 "register_operand" "r")
1018                           (match_operand:SI 3 "register_operand" "r"))))]
1019   ""
1020   "sub %2,%3,%%r0\;{subb|sub,b} %1,%%r0,%0"
1021   [(set_attr "type" "binary")
1022    (set_attr "length" "8")])
1023
1024 (define_insn ""
1025   [(set (match_operand:DI 0 "register_operand" "=r")
1026         (minus:DI (match_operand:DI 1 "register_operand" "r")
1027                   (ltu:DI (match_operand:DI 2 "register_operand" "r")
1028                           (match_operand:DI 3 "register_operand" "r"))))]
1029   "TARGET_64BIT"
1030   "sub %2,%3,%%r0\;sub,db %1,%%r0,%0"
1031   [(set_attr "type" "binary")
1032    (set_attr "length" "8")])
1033
1034 (define_insn ""
1035   [(set (match_operand:SI 0 "register_operand" "=r")
1036         (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
1037                             (ltu:SI (match_operand:SI 2 "register_operand" "r")
1038                                     (match_operand:SI 3 "register_operand" "r")))
1039                   (match_operand:SI 4 "register_operand" "r")))]
1040   ""
1041   "sub %2,%3,%%r0\;{subb|sub,b} %1,%4,%0"
1042   [(set_attr "type" "binary")
1043    (set_attr "length" "8")])
1044
1045 (define_insn ""
1046   [(set (match_operand:DI 0 "register_operand" "=r")
1047         (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
1048                             (ltu:DI (match_operand:DI 2 "register_operand" "r")
1049                                     (match_operand:DI 3 "register_operand" "r")))
1050                   (match_operand:DI 4 "register_operand" "r")))]
1051   "TARGET_64BIT"
1052   "sub %2,%3,%%r0\;sub,db %1,%4,%0"
1053   [(set_attr "type" "binary")
1054    (set_attr "length" "8")])
1055
1056 ; Match only integers for op3 here.  This is used as canonical form of the
1057 ; ltu pattern when op3 is an integer.  Don't match registers since we can't
1058 ; make better code than the general incscc pattern.
1059 (define_insn ""
1060   [(set (match_operand:SI 0 "register_operand" "=r")
1061         (minus:SI (match_operand:SI 1 "register_operand" "r")
1062                   (leu:SI (match_operand:SI 2 "register_operand" "r")
1063                           (match_operand:SI 3 "int11_operand" "I"))))]
1064   ""
1065   "addi %k3,%2,%%r0\;{subb|sub,b} %1,%%r0,%0"
1066   [(set_attr "type" "binary")
1067    (set_attr "length" "8")])
1068
1069 (define_insn ""
1070   [(set (match_operand:DI 0 "register_operand" "=r")
1071         (minus:DI (match_operand:DI 1 "register_operand" "r")
1072                   (leu:DI (match_operand:DI 2 "register_operand" "r")
1073                           (match_operand:DI 3 "int11_operand" "I"))))]
1074   "TARGET_64BIT"
1075   "addi %k3,%2,%%r0\;sub,db %1,%%r0,%0"
1076   [(set_attr "type" "binary")
1077    (set_attr "length" "8")])
1078
1079 (define_insn ""
1080   [(set (match_operand:SI 0 "register_operand" "=r")
1081         (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
1082                             (leu:SI (match_operand:SI 2 "register_operand" "r")
1083                                     (match_operand:SI 3 "int11_operand" "I")))
1084                   (match_operand:SI 4 "register_operand" "r")))]
1085   ""
1086   "addi %k3,%2,%%r0\;{subb|sub,b} %1,%4,%0"
1087   [(set_attr "type" "binary")
1088    (set_attr "length" "8")])
1089
1090 (define_insn ""
1091   [(set (match_operand:DI 0 "register_operand" "=r")
1092         (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
1093                             (leu:DI (match_operand:DI 2 "register_operand" "r")
1094                                     (match_operand:DI 3 "int11_operand" "I")))
1095                   (match_operand:DI 4 "register_operand" "r")))]
1096   "TARGET_64BIT"
1097   "addi %k3,%2,%%r0\;sub,db %1,%4,%0"
1098   [(set_attr "type" "binary")
1099    (set_attr "length" "8")])
1100
1101 (define_insn "decscc"
1102   [(set (match_operand:SI 0 "register_operand" "=r,r")
1103         (minus:SI (match_operand:SI 1 "register_operand" "0,?r")
1104                   (match_operator:SI 4 "comparison_operator"
1105                      [(match_operand:SI 2 "register_operand" "r,r")
1106                       (match_operand:SI 3 "arith11_operand" "rI,rI")])))]
1107   ""
1108   "@
1109    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi -1,%0,%0
1110    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi,tr -1,%1,%0\;copy %1,%0"
1111   [(set_attr "type" "binary,binary")
1112    (set_attr "length" "8,12")])
1113
1114 (define_insn ""
1115   [(set (match_operand:DI 0 "register_operand" "=r,r")
1116         (minus:DI (match_operand:DI 1 "register_operand" "0,?r")
1117                   (match_operator:DI 4 "comparison_operator"
1118                      [(match_operand:DI 2 "register_operand" "r,r")
1119                       (match_operand:DI 3 "arith11_operand" "rI,rI")])))]
1120   "TARGET_64BIT"
1121   "@
1122    cmp%I3clr,*%B4 %3,%2,%%r0\;addi -1,%0,%0
1123    cmp%I3clr,*%B4 %3,%2,%%r0\;addi,tr -1,%1,%0\;copy %1,%0"
1124   [(set_attr "type" "binary,binary")
1125    (set_attr "length" "8,12")])
1126
1127 ; Patterns for max and min.  (There is no need for an earlyclobber in the
1128 ; last alternative since the middle alternative will match if op0 == op1.)
1129
1130 (define_insn "sminsi3"
1131   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1132         (smin:SI (match_operand:SI 1 "register_operand" "%0,0,r")
1133                  (match_operand:SI 2 "arith11_operand" "r,I,M")))]
1134   ""
1135   "@
1136   {comclr|cmpclr},> %2,%0,%%r0\;copy %2,%0
1137   {comiclr|cmpiclr},> %2,%0,%%r0\;ldi %2,%0
1138   {comclr|cmpclr},> %1,%r2,%0\;copy %1,%0"
1139 [(set_attr "type" "multi,multi,multi")
1140  (set_attr "length" "8,8,8")])
1141
1142 (define_insn "smindi3"
1143   [(set (match_operand:DI 0 "register_operand" "=r,r,r")
1144         (smin:DI (match_operand:DI 1 "register_operand" "%0,0,r")
1145                  (match_operand:DI 2 "arith11_operand" "r,I,M")))]
1146   "TARGET_64BIT"
1147   "@
1148   cmpclr,*> %2,%0,%%r0\;copy %2,%0
1149   cmpiclr,*> %2,%0,%%r0\;ldi %2,%0
1150   cmpclr,*> %1,%r2,%0\;copy %1,%0"
1151 [(set_attr "type" "multi,multi,multi")
1152  (set_attr "length" "8,8,8")])
1153
1154 (define_insn "uminsi3"
1155   [(set (match_operand:SI 0 "register_operand" "=r,r")
1156         (umin:SI (match_operand:SI 1 "register_operand" "%0,0")
1157                  (match_operand:SI 2 "arith11_operand" "r,I")))]
1158   ""
1159   "@
1160   {comclr|cmpclr},>> %2,%0,%%r0\;copy %2,%0
1161   {comiclr|cmpiclr},>> %2,%0,%%r0\;ldi %2,%0"
1162 [(set_attr "type" "multi,multi")
1163  (set_attr "length" "8,8")])
1164
1165 (define_insn "umindi3"
1166   [(set (match_operand:DI 0 "register_operand" "=r,r")
1167         (umin:DI (match_operand:DI 1 "register_operand" "%0,0")
1168                  (match_operand:DI 2 "arith11_operand" "r,I")))]
1169   "TARGET_64BIT"
1170   "@
1171   cmpclr,*>> %2,%0,%%r0\;copy %2,%0
1172   cmpiclr,*>> %2,%0,%%r0\;ldi %2,%0"
1173 [(set_attr "type" "multi,multi")
1174  (set_attr "length" "8,8")])
1175
1176 (define_insn "smaxsi3"
1177   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1178         (smax:SI (match_operand:SI 1 "register_operand" "%0,0,r")
1179                  (match_operand:SI 2 "arith11_operand" "r,I,M")))]
1180   ""
1181   "@
1182   {comclr|cmpclr},< %2,%0,%%r0\;copy %2,%0
1183   {comiclr|cmpiclr},< %2,%0,%%r0\;ldi %2,%0
1184   {comclr|cmpclr},< %1,%r2,%0\;copy %1,%0"
1185 [(set_attr "type" "multi,multi,multi")
1186  (set_attr "length" "8,8,8")])
1187
1188 (define_insn "smaxdi3"
1189   [(set (match_operand:DI 0 "register_operand" "=r,r,r")
1190         (smax:DI (match_operand:DI 1 "register_operand" "%0,0,r")
1191                  (match_operand:DI 2 "arith11_operand" "r,I,M")))]
1192   "TARGET_64BIT"
1193   "@
1194   cmpclr,*< %2,%0,%%r0\;copy %2,%0
1195   cmpiclr,*< %2,%0,%%r0\;ldi %2,%0
1196   cmpclr,*< %1,%r2,%0\;copy %1,%0"
1197 [(set_attr "type" "multi,multi,multi")
1198  (set_attr "length" "8,8,8")])
1199
1200 (define_insn "umaxsi3"
1201   [(set (match_operand:SI 0 "register_operand" "=r,r")
1202         (umax:SI (match_operand:SI 1 "register_operand" "%0,0")
1203                  (match_operand:SI 2 "arith11_operand" "r,I")))]
1204   ""
1205   "@
1206   {comclr|cmpclr},<< %2,%0,%%r0\;copy %2,%0
1207   {comiclr|cmpiclr},<< %2,%0,%%r0\;ldi %2,%0"
1208 [(set_attr "type" "multi,multi")
1209  (set_attr "length" "8,8")])
1210
1211 (define_insn "umaxdi3"
1212   [(set (match_operand:DI 0 "register_operand" "=r,r")
1213         (umax:DI (match_operand:DI 1 "register_operand" "%0,0")
1214                  (match_operand:DI 2 "arith11_operand" "r,I")))]
1215   "TARGET_64BIT"
1216   "@
1217   cmpclr,*<< %2,%0,%%r0\;copy %2,%0
1218   cmpiclr,*<< %2,%0,%%r0\;ldi %2,%0"
1219 [(set_attr "type" "multi,multi")
1220  (set_attr "length" "8,8")])
1221
1222 (define_insn "abssi2"
1223   [(set (match_operand:SI 0 "register_operand" "=r")
1224         (abs:SI (match_operand:SI 1 "register_operand" "r")))]
1225   ""
1226   "or,>= %%r0,%1,%0\;subi 0,%0,%0"
1227   [(set_attr "type" "multi")
1228    (set_attr "length" "8")])
1229
1230 (define_insn "absdi2"
1231   [(set (match_operand:DI 0 "register_operand" "=r")
1232         (abs:DI (match_operand:DI 1 "register_operand" "r")))]
1233   "TARGET_64BIT"
1234   "or,*>= %%r0,%1,%0\;subi 0,%0,%0"
1235   [(set_attr "type" "multi")
1236    (set_attr "length" "8")])
1237
1238 ;;; Experimental conditional move patterns
1239
1240 (define_expand "movsicc"
1241   [(set (match_operand:SI 0 "register_operand" "")
1242         (if_then_else:SI
1243          (match_operator 1 "comparison_operator"
1244             [(match_dup 4)
1245              (match_dup 5)])
1246          (match_operand:SI 2 "reg_or_cint_move_operand" "")
1247          (match_operand:SI 3 "reg_or_cint_move_operand" "")))]
1248   ""
1249   "
1250 {
1251   enum rtx_code code = GET_CODE (operands[1]);
1252
1253   if (hppa_branch_type != CMP_SI)
1254     FAIL;
1255
1256   if (GET_MODE (hppa_compare_op0) != GET_MODE (hppa_compare_op1)
1257       || GET_MODE (hppa_compare_op0) != GET_MODE (operands[0]))
1258     FAIL;
1259
1260   /* operands[1] is currently the result of compare_from_rtx.  We want to
1261      emit a compare of the original operands.  */
1262   operands[1] = gen_rtx_fmt_ee (code, SImode, hppa_compare_op0, hppa_compare_op1);
1263   operands[4] = hppa_compare_op0;
1264   operands[5] = hppa_compare_op1;
1265 }")
1266
1267 ;; We used to accept any register for op1.
1268 ;;
1269 ;; However, it loses sometimes because the compiler will end up using
1270 ;; different registers for op0 and op1 in some critical cases.  local-alloc
1271 ;; will  not tie op0 and op1 because op0 is used in multiple basic blocks.
1272 ;;
1273 ;; If/when global register allocation supports tying we should allow any
1274 ;; register for op1 again.
1275 (define_insn ""
1276   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
1277         (if_then_else:SI
1278          (match_operator 2 "comparison_operator"
1279             [(match_operand:SI 3 "register_operand" "r,r,r,r")
1280              (match_operand:SI 4 "arith11_operand" "rI,rI,rI,rI")])
1281          (match_operand:SI 1 "reg_or_cint_move_operand" "0,J,N,K")
1282          (const_int 0)))]
1283   ""
1284   "@
1285    {com%I4clr|cmp%I4clr},%S2 %4,%3,%%r0\;ldi 0,%0
1286    {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;ldi %1,%0
1287    {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;ldil L'%1,%0
1288    {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;{zdepi|depwi,z} %Z1,%0"
1289   [(set_attr "type" "multi,multi,multi,nullshift")
1290    (set_attr "length" "8,8,8,8")])
1291
1292 (define_insn ""
1293   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r,r,r")
1294         (if_then_else:SI
1295          (match_operator 5 "comparison_operator"
1296             [(match_operand:SI 3 "register_operand" "r,r,r,r,r,r,r,r")
1297              (match_operand:SI 4 "arith11_operand" "rI,rI,rI,rI,rI,rI,rI,rI")])
1298          (match_operand:SI 1 "reg_or_cint_move_operand" "0,0,0,0,r,J,N,K")
1299          (match_operand:SI 2 "reg_or_cint_move_operand" "r,J,N,K,0,0,0,0")))]
1300   ""
1301   "@
1302    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;copy %2,%0
1303    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;ldi %2,%0
1304    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;ldil L'%2,%0
1305    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;{zdepi|depwi,z} %Z2,%0
1306    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;copy %1,%0
1307    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;ldi %1,%0
1308    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;ldil L'%1,%0
1309    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;{zdepi|depwi,z} %Z1,%0"
1310   [(set_attr "type" "multi,multi,multi,nullshift,multi,multi,multi,nullshift")
1311    (set_attr "length" "8,8,8,8,8,8,8,8")])
1312
1313 (define_expand "movdicc"
1314   [(set (match_operand:DI 0 "register_operand" "")
1315         (if_then_else:DI
1316          (match_operator 1 "comparison_operator"
1317             [(match_dup 4)
1318              (match_dup 5)])
1319          (match_operand:DI 2 "reg_or_cint_move_operand" "")
1320          (match_operand:DI 3 "reg_or_cint_move_operand" "")))]
1321   "TARGET_64BIT"
1322   "
1323 {
1324   enum rtx_code code = GET_CODE (operands[1]);
1325
1326   if (hppa_branch_type != CMP_SI)
1327     FAIL;
1328
1329   if (GET_MODE (hppa_compare_op0) != GET_MODE (hppa_compare_op1)
1330       || GET_MODE (hppa_compare_op0) != GET_MODE (operands[0]))
1331     FAIL;
1332
1333   /* operands[1] is currently the result of compare_from_rtx.  We want to
1334      emit a compare of the original operands.  */
1335   operands[1] = gen_rtx_fmt_ee (code, DImode, hppa_compare_op0, hppa_compare_op1);
1336   operands[4] = hppa_compare_op0;
1337   operands[5] = hppa_compare_op1;
1338 }")
1339
1340 ; We need the first constraint alternative in order to avoid
1341 ; earlyclobbers on all other alternatives.
1342 (define_insn ""
1343   [(set (match_operand:DI 0 "register_operand" "=r,r,r,r,r")
1344         (if_then_else:DI
1345          (match_operator 2 "comparison_operator"
1346             [(match_operand:DI 3 "register_operand" "r,r,r,r,r")
1347              (match_operand:DI 4 "arith11_operand" "rI,rI,rI,rI,rI")])
1348          (match_operand:DI 1 "reg_or_cint_move_operand" "0,r,J,N,K")
1349          (const_int 0)))]
1350   "TARGET_64BIT"
1351   "@
1352    cmp%I4clr,*%S2 %4,%3,%%r0\;ldi 0,%0
1353    cmp%I4clr,*%B2 %4,%3,%0\;copy %1,%0
1354    cmp%I4clr,*%B2 %4,%3,%0\;ldi %1,%0
1355    cmp%I4clr,*%B2 %4,%3,%0\;ldil L'%1,%0
1356    cmp%I4clr,*%B2 %4,%3,%0\;depdi,z %z1,%0"
1357   [(set_attr "type" "multi,multi,multi,multi,nullshift")
1358    (set_attr "length" "8,8,8,8,8")])
1359
1360 (define_insn ""
1361   [(set (match_operand:DI 0 "register_operand" "=r,r,r,r,r,r,r,r")
1362         (if_then_else:DI
1363          (match_operator 5 "comparison_operator"
1364             [(match_operand:DI 3 "register_operand" "r,r,r,r,r,r,r,r")
1365              (match_operand:DI 4 "arith11_operand" "rI,rI,rI,rI,rI,rI,rI,rI")])
1366          (match_operand:DI 1 "reg_or_cint_move_operand" "0,0,0,0,r,J,N,K")
1367          (match_operand:DI 2 "reg_or_cint_move_operand" "r,J,N,K,0,0,0,0")))]
1368   "TARGET_64BIT"
1369   "@
1370    cmp%I4clr,*%S5 %4,%3,%%r0\;copy %2,%0
1371    cmp%I4clr,*%S5 %4,%3,%%r0\;ldi %2,%0
1372    cmp%I4clr,*%S5 %4,%3,%%r0\;ldil L'%2,%0
1373    cmp%I4clr,*%S5 %4,%3,%%r0\;depdi,z %z2,%0
1374    cmp%I4clr,*%B5 %4,%3,%%r0\;copy %1,%0
1375    cmp%I4clr,*%B5 %4,%3,%%r0\;ldi %1,%0
1376    cmp%I4clr,*%B5 %4,%3,%%r0\;ldil L'%1,%0
1377    cmp%I4clr,*%B5 %4,%3,%%r0\;depdi,z %z1,%0"
1378   [(set_attr "type" "multi,multi,multi,nullshift,multi,multi,multi,nullshift")
1379    (set_attr "length" "8,8,8,8,8,8,8,8")])
1380
1381 ;; Conditional Branches
1382
1383 (define_expand "beq"
1384   [(set (pc)
1385         (if_then_else (eq (match_dup 1) (match_dup 2))
1386                       (label_ref (match_operand 0 "" ""))
1387                       (pc)))]
1388   ""
1389   "
1390 {
1391   if (hppa_branch_type != CMP_SI)
1392     {
1393       emit_insn (gen_cmp_fp (EQ, hppa_compare_op0, hppa_compare_op1));
1394       emit_bcond_fp (NE, operands[0]);
1395       DONE;
1396     }
1397   /* set up operands from compare.  */
1398   operands[1] = hppa_compare_op0;
1399   operands[2] = hppa_compare_op1;
1400   /* fall through and generate default code */
1401 }")
1402
1403 (define_expand "bne"
1404   [(set (pc)
1405         (if_then_else (ne (match_dup 1) (match_dup 2))
1406                       (label_ref (match_operand 0 "" ""))
1407                       (pc)))]
1408   ""
1409   "
1410 {
1411   if (hppa_branch_type != CMP_SI)
1412     {
1413       emit_insn (gen_cmp_fp (NE, hppa_compare_op0, hppa_compare_op1));
1414       emit_bcond_fp (NE, operands[0]);
1415       DONE;
1416     }
1417   operands[1] = hppa_compare_op0;
1418   operands[2] = hppa_compare_op1;
1419 }")
1420
1421 (define_expand "bgt"
1422   [(set (pc)
1423         (if_then_else (gt (match_dup 1) (match_dup 2))
1424                       (label_ref (match_operand 0 "" ""))
1425                       (pc)))]
1426   ""
1427   "
1428 {
1429   if (hppa_branch_type != CMP_SI)
1430     {
1431       emit_insn (gen_cmp_fp (GT, hppa_compare_op0, hppa_compare_op1));
1432       emit_bcond_fp (NE, operands[0]);
1433       DONE;
1434     }
1435   operands[1] = hppa_compare_op0;
1436   operands[2] = hppa_compare_op1;
1437 }")
1438
1439 (define_expand "blt"
1440   [(set (pc)
1441         (if_then_else (lt (match_dup 1) (match_dup 2))
1442                       (label_ref (match_operand 0 "" ""))
1443                       (pc)))]
1444   ""
1445   "
1446 {
1447   if (hppa_branch_type != CMP_SI)
1448     {
1449       emit_insn (gen_cmp_fp (LT, hppa_compare_op0, hppa_compare_op1));
1450       emit_bcond_fp (NE, operands[0]);
1451       DONE;
1452     }
1453   operands[1] = hppa_compare_op0;
1454   operands[2] = hppa_compare_op1;
1455 }")
1456
1457 (define_expand "bge"
1458   [(set (pc)
1459         (if_then_else (ge (match_dup 1) (match_dup 2))
1460                       (label_ref (match_operand 0 "" ""))
1461                       (pc)))]
1462   ""
1463   "
1464 {
1465   if (hppa_branch_type != CMP_SI)
1466     {
1467       emit_insn (gen_cmp_fp (GE, hppa_compare_op0, hppa_compare_op1));
1468       emit_bcond_fp (NE, operands[0]);
1469       DONE;
1470     }
1471   operands[1] = hppa_compare_op0;
1472   operands[2] = hppa_compare_op1;
1473 }")
1474
1475 (define_expand "ble"
1476   [(set (pc)
1477         (if_then_else (le (match_dup 1) (match_dup 2))
1478                       (label_ref (match_operand 0 "" ""))
1479                       (pc)))]
1480   ""
1481   "
1482 {
1483   if (hppa_branch_type != CMP_SI)
1484     {
1485       emit_insn (gen_cmp_fp (LE, hppa_compare_op0, hppa_compare_op1));
1486       emit_bcond_fp (NE, operands[0]);
1487       DONE;
1488     }
1489   operands[1] = hppa_compare_op0;
1490   operands[2] = hppa_compare_op1;
1491 }")
1492
1493 (define_expand "bgtu"
1494   [(set (pc)
1495         (if_then_else (gtu (match_dup 1) (match_dup 2))
1496                       (label_ref (match_operand 0 "" ""))
1497                       (pc)))]
1498   ""
1499   "
1500 {
1501   if (hppa_branch_type != CMP_SI)
1502     FAIL;
1503   operands[1] = hppa_compare_op0;
1504   operands[2] = hppa_compare_op1;
1505 }")
1506
1507 (define_expand "bltu"
1508   [(set (pc)
1509         (if_then_else (ltu (match_dup 1) (match_dup 2))
1510                       (label_ref (match_operand 0 "" ""))
1511                       (pc)))]
1512   ""
1513   "
1514 {
1515   if (hppa_branch_type != CMP_SI)
1516     FAIL;
1517   operands[1] = hppa_compare_op0;
1518   operands[2] = hppa_compare_op1;
1519 }")
1520
1521 (define_expand "bgeu"
1522   [(set (pc)
1523         (if_then_else (geu (match_dup 1) (match_dup 2))
1524                       (label_ref (match_operand 0 "" ""))
1525                       (pc)))]
1526   ""
1527   "
1528 {
1529   if (hppa_branch_type != CMP_SI)
1530     FAIL;
1531   operands[1] = hppa_compare_op0;
1532   operands[2] = hppa_compare_op1;
1533 }")
1534
1535 (define_expand "bleu"
1536   [(set (pc)
1537         (if_then_else (leu (match_dup 1) (match_dup 2))
1538                       (label_ref (match_operand 0 "" ""))
1539                       (pc)))]
1540   ""
1541   "
1542 {
1543   if (hppa_branch_type != CMP_SI)
1544     FAIL;
1545   operands[1] = hppa_compare_op0;
1546   operands[2] = hppa_compare_op1;
1547 }")
1548
1549 (define_expand "bltgt"
1550   [(set (pc)
1551         (if_then_else (ltgt (match_dup 1) (match_dup 2))
1552                       (label_ref (match_operand 0 "" ""))
1553                       (pc)))]
1554   ""
1555   "
1556 {
1557   if (hppa_branch_type == CMP_SI)
1558     FAIL;
1559   emit_insn (gen_cmp_fp (LTGT, hppa_compare_op0, hppa_compare_op1));
1560   emit_bcond_fp (NE, operands[0]);
1561   DONE;
1562 }")
1563
1564 (define_expand "bunle"
1565   [(set (pc)
1566         (if_then_else (unle (match_dup 1) (match_dup 2))
1567                       (label_ref (match_operand 0 "" ""))
1568                       (pc)))]
1569   ""
1570   "
1571 {
1572   if (hppa_branch_type == CMP_SI)
1573     FAIL;
1574   emit_insn (gen_cmp_fp (UNLE, hppa_compare_op0, hppa_compare_op1));
1575   emit_bcond_fp (NE, operands[0]);
1576   DONE;
1577 }")
1578
1579 (define_expand "bunlt"
1580   [(set (pc)
1581         (if_then_else (unlt (match_dup 1) (match_dup 2))
1582                       (label_ref (match_operand 0 "" ""))
1583                       (pc)))]
1584   ""
1585   "
1586 {
1587   if (hppa_branch_type == CMP_SI)
1588     FAIL;
1589   emit_insn (gen_cmp_fp (UNLT, hppa_compare_op0, hppa_compare_op1));
1590   emit_bcond_fp (NE, operands[0]);
1591   DONE;
1592 }")
1593
1594 (define_expand "bunge"
1595   [(set (pc)
1596         (if_then_else (unge (match_dup 1) (match_dup 2))
1597                       (label_ref (match_operand 0 "" ""))
1598                       (pc)))]
1599   ""
1600   "
1601 {
1602   if (hppa_branch_type == CMP_SI)
1603     FAIL;
1604   emit_insn (gen_cmp_fp (UNGE, hppa_compare_op0, hppa_compare_op1));
1605   emit_bcond_fp (NE, operands[0]);
1606   DONE;
1607 }")
1608
1609 (define_expand "bungt"
1610   [(set (pc)
1611         (if_then_else (ungt (match_dup 1) (match_dup 2))
1612                       (label_ref (match_operand 0 "" ""))
1613                       (pc)))]
1614   ""
1615   "
1616 {
1617   if (hppa_branch_type == CMP_SI)
1618     FAIL;
1619   emit_insn (gen_cmp_fp (UNGT, hppa_compare_op0, hppa_compare_op1));
1620   emit_bcond_fp (NE, operands[0]);
1621   DONE;
1622 }")
1623
1624 (define_expand "buneq"
1625   [(set (pc)
1626         (if_then_else (uneq (match_dup 1) (match_dup 2))
1627                       (label_ref (match_operand 0 "" ""))
1628                       (pc)))]
1629   ""
1630   "
1631 {
1632   if (hppa_branch_type == CMP_SI)
1633     FAIL;
1634   emit_insn (gen_cmp_fp (UNEQ, hppa_compare_op0, hppa_compare_op1));
1635   emit_bcond_fp (NE, operands[0]);
1636   DONE;
1637 }")
1638
1639 (define_expand "bunordered"
1640   [(set (pc)
1641         (if_then_else (unordered (match_dup 1) (match_dup 2))
1642                       (label_ref (match_operand 0 "" ""))
1643                       (pc)))]
1644   ""
1645   "
1646 {
1647   if (hppa_branch_type == CMP_SI)
1648     FAIL;
1649   emit_insn (gen_cmp_fp (UNORDERED, hppa_compare_op0, hppa_compare_op1));
1650   emit_bcond_fp (NE, operands[0]);
1651   DONE;
1652 }")
1653
1654 (define_expand "bordered"
1655   [(set (pc)
1656         (if_then_else (ordered (match_dup 1) (match_dup 2))
1657                       (label_ref (match_operand 0 "" ""))
1658                       (pc)))]
1659   ""
1660   "
1661 {
1662   if (hppa_branch_type == CMP_SI)
1663     FAIL;
1664   emit_insn (gen_cmp_fp (ORDERED, hppa_compare_op0, hppa_compare_op1));
1665   emit_bcond_fp (NE, operands[0]);
1666   DONE;
1667 }")
1668
1669 ;; Match the branch patterns.
1670
1671
1672 ;; Note a long backward conditional branch with an annulled delay slot
1673 ;; has a length of 12.
1674 (define_insn ""
1675   [(set (pc)
1676         (if_then_else
1677          (match_operator 3 "comparison_operator"
1678                          [(match_operand:SI 1 "reg_or_0_operand" "rM")
1679                           (match_operand:SI 2 "arith5_operand" "rL")])
1680          (label_ref (match_operand 0 "" ""))
1681          (pc)))]
1682   ""
1683   "*
1684 {
1685   return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1686                          get_attr_length (insn), 0, insn);
1687 }"
1688 [(set_attr "type" "cbranch")
1689  (set (attr "length")
1690     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1691                (const_int 8184))
1692            (const_int 4)
1693            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1694                (const_int 262100))
1695            (const_int 8)
1696            (eq (symbol_ref "flag_pic") (const_int 0))
1697            (const_int 20)]
1698           (const_int 28)))])
1699
1700 ;; Match the negated branch.
1701
1702 (define_insn ""
1703   [(set (pc)
1704         (if_then_else
1705          (match_operator 3 "comparison_operator"
1706                          [(match_operand:SI 1 "reg_or_0_operand" "rM")
1707                           (match_operand:SI 2 "arith5_operand" "rL")])
1708          (pc)
1709          (label_ref (match_operand 0 "" ""))))]
1710   ""
1711   "*
1712 {
1713   return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1714                          get_attr_length (insn), 1, insn);
1715 }"
1716 [(set_attr "type" "cbranch")
1717  (set (attr "length")
1718     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1719                (const_int 8184))
1720            (const_int 4)
1721            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1722                (const_int 262100))
1723            (const_int 8)
1724            (eq (symbol_ref "flag_pic") (const_int 0))
1725            (const_int 20)]
1726           (const_int 28)))])
1727
1728 (define_insn ""
1729   [(set (pc)
1730         (if_then_else
1731          (match_operator 3 "comparison_operator"
1732                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1733                           (match_operand:DI 2 "reg_or_0_operand" "rM")])
1734          (label_ref (match_operand 0 "" ""))
1735          (pc)))]
1736   "TARGET_64BIT"
1737   "*
1738 {
1739   return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1740                          get_attr_length (insn), 0, insn);
1741 }"
1742 [(set_attr "type" "cbranch")
1743  (set (attr "length")
1744     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1745                (const_int 8184))
1746            (const_int 4)
1747            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1748                (const_int 262100))
1749            (const_int 8)
1750            (eq (symbol_ref "flag_pic") (const_int 0))
1751            (const_int 20)]
1752           (const_int 28)))])
1753
1754 ;; Match the negated branch.
1755
1756 (define_insn ""
1757   [(set (pc)
1758         (if_then_else
1759          (match_operator 3 "comparison_operator"
1760                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1761                           (match_operand:DI 2 "reg_or_0_operand" "rM")])
1762          (pc)
1763          (label_ref (match_operand 0 "" ""))))]
1764   "TARGET_64BIT"
1765   "*
1766 {
1767   return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1768                          get_attr_length (insn), 1, insn);
1769 }"
1770 [(set_attr "type" "cbranch")
1771  (set (attr "length")
1772     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1773                (const_int 8184))
1774            (const_int 4)
1775            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1776                (const_int 262100))
1777            (const_int 8)
1778            (eq (symbol_ref "flag_pic") (const_int 0))
1779            (const_int 20)]
1780           (const_int 28)))])
1781 (define_insn ""
1782   [(set (pc)
1783         (if_then_else
1784          (match_operator 3 "cmpib_comparison_operator"
1785                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1786                           (match_operand:DI 2 "arith5_operand" "rL")])
1787          (label_ref (match_operand 0 "" ""))
1788          (pc)))]
1789   "TARGET_64BIT"
1790   "*
1791 {
1792   return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1793                          get_attr_length (insn), 0, insn);
1794 }"
1795 [(set_attr "type" "cbranch")
1796  (set (attr "length")
1797     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1798                (const_int 8184))
1799            (const_int 4)
1800            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1801                (const_int 262100))
1802            (const_int 8)
1803            (eq (symbol_ref "flag_pic") (const_int 0))
1804            (const_int 20)]
1805           (const_int 28)))])
1806
1807 ;; Match the negated branch.
1808
1809 (define_insn ""
1810   [(set (pc)
1811         (if_then_else
1812          (match_operator 3 "cmpib_comparison_operator"
1813                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1814                           (match_operand:DI 2 "arith5_operand" "rL")])
1815          (pc)
1816          (label_ref (match_operand 0 "" ""))))]
1817   "TARGET_64BIT"
1818   "*
1819 {
1820   return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1821                          get_attr_length (insn), 1, insn);
1822 }"
1823 [(set_attr "type" "cbranch")
1824  (set (attr "length")
1825     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1826                (const_int 8184))
1827            (const_int 4)
1828            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1829                (const_int 262100))
1830            (const_int 8)
1831            (eq (symbol_ref "flag_pic") (const_int 0))
1832            (const_int 20)]
1833           (const_int 28)))])
1834
1835 ;; Branch on Bit patterns.
1836 (define_insn ""
1837   [(set (pc)
1838         (if_then_else
1839          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1840                               (const_int 1)
1841                               (match_operand:SI 1 "uint5_operand" ""))
1842              (const_int 0))
1843          (label_ref (match_operand 2 "" ""))
1844          (pc)))]
1845   ""
1846   "*
1847 {
1848   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1849                          get_attr_length (insn), 0, insn, 0);
1850 }"
1851 [(set_attr "type" "cbranch")
1852  (set (attr "length")
1853     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1854                       (const_int 8184))
1855            (const_int 4)
1856            (const_int 8)))])
1857
1858 (define_insn ""
1859   [(set (pc)
1860         (if_then_else
1861          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1862                               (const_int 1)
1863                               (match_operand:DI 1 "uint32_operand" ""))
1864              (const_int 0))
1865          (label_ref (match_operand 2 "" ""))
1866          (pc)))]
1867   "TARGET_64BIT"
1868   "*
1869 {
1870   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1871                          get_attr_length (insn), 0, insn, 0);
1872 }"
1873 [(set_attr "type" "cbranch")
1874  (set (attr "length")
1875     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1876                       (const_int 8184))
1877            (const_int 4)
1878            (const_int 8)))])
1879
1880 (define_insn ""
1881   [(set (pc)
1882         (if_then_else
1883          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1884                               (const_int 1)
1885                               (match_operand:SI 1 "uint5_operand" ""))
1886              (const_int 0))
1887          (pc)
1888          (label_ref (match_operand 2 "" ""))))]
1889   ""
1890   "*
1891 {
1892   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1893                          get_attr_length (insn), 1, insn, 0);
1894 }"
1895 [(set_attr "type" "cbranch")
1896  (set (attr "length")
1897     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1898                       (const_int 8184))
1899            (const_int 4)
1900            (const_int 8)))])
1901
1902 (define_insn ""
1903   [(set (pc)
1904         (if_then_else
1905          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1906                               (const_int 1)
1907                               (match_operand:DI 1 "uint32_operand" ""))
1908              (const_int 0))
1909          (pc)
1910          (label_ref (match_operand 2 "" ""))))]
1911   "TARGET_64BIT"
1912   "*
1913 {
1914   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1915                          get_attr_length (insn), 1, insn, 0);
1916 }"
1917 [(set_attr "type" "cbranch")
1918  (set (attr "length")
1919     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1920                       (const_int 8184))
1921            (const_int 4)
1922            (const_int 8)))])
1923
1924 (define_insn ""
1925   [(set (pc)
1926         (if_then_else
1927          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1928                               (const_int 1)
1929                               (match_operand:SI 1 "uint5_operand" ""))
1930              (const_int 0))
1931          (label_ref (match_operand 2 "" ""))
1932          (pc)))]
1933   ""
1934   "*
1935 {
1936   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1937                          get_attr_length (insn), 0, insn, 1);
1938 }"
1939 [(set_attr "type" "cbranch")
1940  (set (attr "length")
1941     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1942                       (const_int 8184))
1943            (const_int 4)
1944            (const_int 8)))])
1945
1946 (define_insn ""
1947   [(set (pc)
1948         (if_then_else
1949          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1950                               (const_int 1)
1951                               (match_operand:DI 1 "uint32_operand" ""))
1952              (const_int 0))
1953          (label_ref (match_operand 2 "" ""))
1954          (pc)))]
1955   "TARGET_64BIT"
1956   "*
1957 {
1958   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1959                          get_attr_length (insn), 0, insn, 1);
1960 }"
1961 [(set_attr "type" "cbranch")
1962  (set (attr "length")
1963     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1964                       (const_int 8184))
1965            (const_int 4)
1966            (const_int 8)))])
1967
1968 (define_insn ""
1969   [(set (pc)
1970         (if_then_else
1971          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1972                               (const_int 1)
1973                               (match_operand:SI 1 "uint5_operand" ""))
1974              (const_int 0))
1975          (pc)
1976          (label_ref (match_operand 2 "" ""))))]
1977   ""
1978   "*
1979 {
1980   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1981                          get_attr_length (insn), 1, insn, 1);
1982 }"
1983 [(set_attr "type" "cbranch")
1984  (set (attr "length")
1985     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1986                       (const_int 8184))
1987            (const_int 4)
1988            (const_int 8)))])
1989
1990 (define_insn ""
1991   [(set (pc)
1992         (if_then_else
1993          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1994                               (const_int 1)
1995                               (match_operand:DI 1 "uint32_operand" ""))
1996              (const_int 0))
1997          (pc)
1998          (label_ref (match_operand 2 "" ""))))]
1999   "TARGET_64BIT"
2000   "*
2001 {
2002   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
2003                          get_attr_length (insn), 1, insn, 1);
2004 }"
2005 [(set_attr "type" "cbranch")
2006  (set (attr "length")
2007     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2008                       (const_int 8184))
2009            (const_int 4)
2010            (const_int 8)))])
2011
2012 ;; Branch on Variable Bit patterns.
2013 (define_insn ""
2014   [(set (pc)
2015         (if_then_else
2016          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
2017                               (const_int 1)
2018                               (match_operand:SI 1 "register_operand" "q"))
2019              (const_int 0))
2020          (label_ref (match_operand 2 "" ""))
2021          (pc)))]
2022   ""
2023   "*
2024 {
2025   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
2026                      get_attr_length (insn), 0, insn, 0);
2027 }"
2028 [(set_attr "type" "cbranch")
2029  (set (attr "length")
2030     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2031                       (const_int 8184))
2032            (const_int 4)
2033            (const_int 8)))])
2034
2035 (define_insn ""
2036   [(set (pc)
2037         (if_then_else
2038          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2039                               (const_int 1)
2040                               (match_operand:DI 1 "register_operand" "q"))
2041              (const_int 0))
2042          (label_ref (match_operand 2 "" ""))
2043          (pc)))]
2044   "TARGET_64BIT"
2045   "*
2046 {
2047   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
2048                      get_attr_length (insn), 0, insn, 0);
2049 }"
2050 [(set_attr "type" "cbranch")
2051  (set (attr "length")
2052     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2053                       (const_int 8184))
2054            (const_int 4)
2055            (const_int 8)))])
2056
2057 (define_insn ""
2058   [(set (pc)
2059         (if_then_else
2060          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
2061                               (const_int 1)
2062                               (match_operand:SI 1 "register_operand" "q"))
2063              (const_int 0))
2064          (pc)
2065          (label_ref (match_operand 2 "" ""))))]
2066   ""
2067   "*
2068 {
2069   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
2070                      get_attr_length (insn), 1, insn, 0);
2071 }"
2072 [(set_attr "type" "cbranch")
2073  (set (attr "length")
2074     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2075                       (const_int 8184))
2076            (const_int 4)
2077            (const_int 8)))])
2078
2079 (define_insn ""
2080   [(set (pc)
2081         (if_then_else
2082          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2083                               (const_int 1)
2084                               (match_operand:DI 1 "register_operand" "q"))
2085              (const_int 0))
2086          (pc)
2087          (label_ref (match_operand 2 "" ""))))]
2088   "TARGET_64BIT"
2089   "*
2090 {
2091   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
2092                      get_attr_length (insn), 1, insn, 0);
2093 }"
2094 [(set_attr "type" "cbranch")
2095  (set (attr "length")
2096     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2097                       (const_int 8184))
2098            (const_int 4)
2099            (const_int 8)))])
2100
2101 (define_insn ""
2102   [(set (pc)
2103         (if_then_else
2104          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
2105                               (const_int 1)
2106                               (match_operand:SI 1 "register_operand" "q"))
2107              (const_int 0))
2108          (label_ref (match_operand 2 "" ""))
2109          (pc)))]
2110   ""
2111   "*
2112 {
2113   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
2114                      get_attr_length (insn), 0, insn, 1);
2115 }"
2116 [(set_attr "type" "cbranch")
2117  (set (attr "length")
2118     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2119                       (const_int 8184))
2120            (const_int 4)
2121            (const_int 8)))])
2122
2123 (define_insn ""
2124   [(set (pc)
2125         (if_then_else
2126          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2127                               (const_int 1)
2128                               (match_operand:DI 1 "register_operand" "q"))
2129              (const_int 0))
2130          (label_ref (match_operand 2 "" ""))
2131          (pc)))]
2132   "TARGET_64BIT"
2133   "*
2134 {
2135   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
2136                      get_attr_length (insn), 0, insn, 1);
2137 }"
2138 [(set_attr "type" "cbranch")
2139  (set (attr "length")
2140     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2141                       (const_int 8184))
2142            (const_int 4)
2143            (const_int 8)))])
2144
2145 (define_insn ""
2146   [(set (pc)
2147         (if_then_else
2148          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
2149                               (const_int 1)
2150                               (match_operand:SI 1 "register_operand" "q"))
2151              (const_int 0))
2152          (pc)
2153          (label_ref (match_operand 2 "" ""))))]
2154   ""
2155   "*
2156 {
2157   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
2158                      get_attr_length (insn), 1, insn, 1);
2159 }"
2160 [(set_attr "type" "cbranch")
2161  (set (attr "length")
2162     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2163                       (const_int 8184))
2164            (const_int 4)
2165            (const_int 8)))])
2166
2167 (define_insn ""
2168   [(set (pc)
2169         (if_then_else
2170          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2171                               (const_int 1)
2172                               (match_operand:DI 1 "register_operand" "q"))
2173              (const_int 0))
2174          (pc)
2175          (label_ref (match_operand 2 "" ""))))]
2176   "TARGET_64BIT"
2177   "*
2178 {
2179   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
2180                      get_attr_length (insn), 1, insn, 1);
2181 }"
2182 [(set_attr "type" "cbranch")
2183  (set (attr "length")
2184     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2185                       (const_int 8184))
2186            (const_int 4)
2187            (const_int 8)))])
2188
2189 ;; Floating point branches
2190 (define_insn ""
2191   [(set (pc) (if_then_else (ne (reg:CCFP 0) (const_int 0))
2192                            (label_ref (match_operand 0 "" ""))
2193                            (pc)))]
2194   "! TARGET_SOFT_FLOAT"
2195   "*
2196 {
2197   if (INSN_ANNULLED_BRANCH_P (insn))
2198     return \"ftest\;b,n %0\";
2199   else
2200     return \"ftest\;b%* %0\";
2201 }"
2202   [(set_attr "type" "fbranch")
2203    (set_attr "length" "8")])
2204
2205 (define_insn ""
2206   [(set (pc) (if_then_else (ne (reg:CCFP 0) (const_int 0))
2207                            (pc)
2208                            (label_ref (match_operand 0 "" ""))))]
2209   "! TARGET_SOFT_FLOAT"
2210   "*
2211 {
2212   if (INSN_ANNULLED_BRANCH_P (insn))
2213     return \"ftest\;add,tr %%r0,%%r0,%%r0\;b,n %0\";
2214   else
2215     return \"ftest\;add,tr %%r0,%%r0,%%r0\;b%* %0\";
2216 }"
2217   [(set_attr "type" "fbranch")
2218    (set_attr "length" "12")])
2219
2220 ;; Move instructions
2221
2222 (define_expand "movsi"
2223   [(set (match_operand:SI 0 "general_operand" "")
2224         (match_operand:SI 1 "general_operand" ""))]
2225   ""
2226   "
2227 {
2228   if (emit_move_sequence (operands, SImode, 0))
2229     DONE;
2230 }")
2231
2232 ;; Reloading an SImode or DImode value requires a scratch register if
2233 ;; going in to or out of float point registers.
2234
2235 (define_expand "reload_insi"
2236   [(set (match_operand:SI 0 "register_operand" "=Z")
2237         (match_operand:SI 1 "non_hard_reg_operand" ""))
2238    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
2239   ""
2240   "
2241 {
2242   if (emit_move_sequence (operands, SImode, operands[2]))
2243     DONE;
2244
2245   /* We don't want the clobber emitted, so handle this ourselves.  */
2246   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
2247   DONE;
2248 }")
2249
2250 (define_expand "reload_outsi"
2251   [(set (match_operand:SI 0 "non_hard_reg_operand" "")
2252         (match_operand:SI 1  "register_operand" "Z"))
2253    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
2254   ""
2255   "
2256 {
2257   if (emit_move_sequence (operands, SImode, operands[2]))
2258     DONE;
2259
2260   /* We don't want the clobber emitted, so handle this ourselves.  */
2261   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
2262   DONE;
2263 }")
2264
2265 (define_insn ""
2266   [(set (match_operand:SI 0 "move_dest_operand"
2267                           "=r,r,r,r,r,r,Q,!*q,!r,!*f,*f,T")
2268         (match_operand:SI 1 "move_src_operand"
2269                           "A,r,J,N,K,RQ,rM,!rM,!*q,!*fM,RT,*f"))]
2270   "(register_operand (operands[0], SImode)
2271     || reg_or_0_operand (operands[1], SImode))
2272    && !TARGET_SOFT_FLOAT"
2273   "@
2274    ldw RT'%A1,%0
2275    copy %1,%0
2276    ldi %1,%0
2277    ldil L'%1,%0
2278    {zdepi|depwi,z} %Z1,%0
2279    ldw%M1 %1,%0
2280    stw%M0 %r1,%0
2281    mtsar %r1
2282    {mfctl|mfctl,w} %%sar,%0
2283    fcpy,sgl %f1,%0
2284    fldw%F1 %1,%0
2285    fstw%F0 %1,%0"
2286   [(set_attr "type" "load,move,move,move,shift,load,store,move,move,fpalu,fpload,fpstore")
2287    (set_attr "pa_combine_type" "addmove")
2288    (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4")])
2289
2290 (define_insn ""
2291   [(set (match_operand:SI 0 "indexed_memory_operand" "=R")
2292         (match_operand:SI 1 "register_operand" "f"))]
2293   "!TARGET_SOFT_FLOAT
2294    && !TARGET_DISABLE_INDEXING
2295    && reload_completed"
2296   "fstw%F0 %1,%0"
2297   [(set_attr "type" "fpstore")
2298    (set_attr "pa_combine_type" "addmove")
2299    (set_attr "length" "4")])
2300
2301 ; Rewrite RTL using an indexed store.  This will allow the insn that
2302 ; computes the address to be deleted if the register it sets is dead.
2303 (define_peephole2
2304   [(set (match_operand:SI 0 "register_operand" "")
2305         (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "")
2306                           (const_int 4))
2307                  (match_operand:SI 2 "register_operand" "")))
2308    (set (mem:SI (match_dup 0))
2309         (match_operand:SI 3 "register_operand" ""))]
2310   "!TARGET_SOFT_FLOAT
2311    && REG_OK_FOR_BASE_P (operands[2])
2312    && FP_REGNO_P (REGNO (operands[3]))"
2313   [(set (mem:SI (plus:SI (mult:SI (match_dup 1) (const_int 4)) (match_dup 2)))
2314         (match_dup 3))
2315    (set (match_dup 0) (plus:SI (mult:SI (match_dup 1) (const_int 4))
2316                                (match_dup 2)))]
2317   "")
2318
2319 (define_peephole2
2320   [(set (match_operand:SI 0 "register_operand" "")
2321         (plus:SI (match_operand:SI 2 "register_operand" "")
2322                  (mult:SI (match_operand:SI 1 "register_operand" "")
2323                           (const_int 4))))
2324    (set (mem:SI (match_dup 0))
2325         (match_operand:SI 3 "register_operand" ""))]
2326   "!TARGET_SOFT_FLOAT
2327    && REG_OK_FOR_BASE_P (operands[2])
2328    && FP_REGNO_P (REGNO (operands[3]))"
2329   [(set (mem:SI (plus:SI (mult:SI (match_dup 1) (const_int 4)) (match_dup 2)))
2330         (match_dup 3))
2331    (set (match_dup 0) (plus:SI (mult:SI (match_dup 1) (const_int 4))
2332                                (match_dup 2)))]
2333   "")
2334
2335 (define_peephole2
2336   [(set (match_operand:DI 0 "register_operand" "")
2337         (plus:DI (mult:DI (match_operand:DI 1 "register_operand" "")
2338                           (const_int 4))
2339                  (match_operand:DI 2 "register_operand" "")))
2340    (set (mem:SI (match_dup 0))
2341         (match_operand:SI 3 "register_operand" ""))]
2342   "!TARGET_SOFT_FLOAT
2343    && TARGET_64BIT
2344    && REG_OK_FOR_BASE_P (operands[2])
2345    && FP_REGNO_P (REGNO (operands[3]))"
2346   [(set (mem:SI (plus:DI (mult:DI (match_dup 1) (const_int 4)) (match_dup 2)))
2347         (match_dup 3))
2348    (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 4))
2349                                (match_dup 2)))]
2350   "")
2351
2352 (define_peephole2
2353   [(set (match_operand:DI 0 "register_operand" "")
2354         (plus:DI (match_operand:DI 2 "register_operand" "")
2355                  (mult:DI (match_operand:DI 1 "register_operand" "")
2356                           (const_int 4))))
2357    (set (mem:SI (match_dup 0))
2358         (match_operand:SI 3 "register_operand" ""))]
2359   "!TARGET_SOFT_FLOAT
2360    && TARGET_64BIT
2361    && REG_OK_FOR_BASE_P (operands[2])
2362    && FP_REGNO_P (REGNO (operands[3]))"
2363   [(set (mem:SI (plus:DI (mult:DI (match_dup 1) (const_int 4)) (match_dup 2)))
2364         (match_dup 3))
2365    (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 4))
2366                                (match_dup 2)))]
2367   "")
2368
2369 (define_peephole2
2370   [(set (match_operand:SI 0 "register_operand" "")
2371         (plus:SI (match_operand:SI 1 "register_operand" "")
2372                  (match_operand:SI 2 "register_operand" "")))
2373    (set (mem:SI (match_dup 0))
2374         (match_operand:SI 3 "register_operand" ""))]
2375   "!TARGET_SOFT_FLOAT
2376    && REG_OK_FOR_BASE_P (operands[1])
2377    && (TARGET_NO_SPACE_REGS
2378        || (!REG_POINTER (operands[1]) && REG_POINTER (operands[2])))
2379    && FP_REGNO_P (REGNO (operands[3]))"
2380   [(set (mem:SI (plus:SI (match_dup 1) (match_dup 2)))
2381         (match_dup 3))
2382    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
2383   "")
2384
2385 (define_peephole2
2386   [(set (match_operand:SI 0 "register_operand" "")
2387         (plus:SI (match_operand:SI 1 "register_operand" "")
2388                  (match_operand:SI 2 "register_operand" "")))
2389    (set (mem:SI (match_dup 0))
2390         (match_operand:SI 3 "register_operand" ""))]
2391   "!TARGET_SOFT_FLOAT
2392    && REG_OK_FOR_BASE_P (operands[2])
2393    && (TARGET_NO_SPACE_REGS
2394        || (REG_POINTER (operands[1]) && !REG_POINTER (operands[2])))
2395    && FP_REGNO_P (REGNO (operands[3]))"
2396   [(set (mem:SI (plus:SI (match_dup 2) (match_dup 1)))
2397         (match_dup 3))
2398    (set (match_dup 0) (plus:SI (match_dup 2) (match_dup 1)))]
2399   "")
2400
2401 (define_peephole2
2402   [(set (match_operand:DI 0 "register_operand" "")
2403         (plus:DI (match_operand:DI 1 "register_operand" "")
2404                  (match_operand:DI 2 "register_operand" "")))
2405    (set (mem:SI (match_dup 0))
2406         (match_operand:SI 3 "register_operand" ""))]
2407   "!TARGET_SOFT_FLOAT
2408    && TARGET_64BIT
2409    && REG_OK_FOR_BASE_P (operands[1])
2410    && (TARGET_NO_SPACE_REGS
2411        || (!REG_POINTER (operands[1]) && REG_POINTER (operands[2])))
2412    && FP_REGNO_P (REGNO (operands[3]))"
2413   [(set (mem:SI (plus:DI (match_dup 1) (match_dup 2)))
2414         (match_dup 3))
2415    (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
2416   "")
2417
2418 (define_peephole2
2419   [(set (match_operand:DI 0 "register_operand" "")
2420         (plus:DI (match_operand:DI 1 "register_operand" "")
2421                  (match_operand:DI 2 "register_operand" "")))
2422    (set (mem:SI (match_dup 0))
2423         (match_operand:SI 3 "register_operand" ""))]
2424   "!TARGET_SOFT_FLOAT
2425    && TARGET_64BIT
2426    && REG_OK_FOR_BASE_P (operands[2])
2427    && (TARGET_NO_SPACE_REGS
2428        || (REG_POINTER (operands[1]) && !REG_POINTER (operands[2])))
2429    && FP_REGNO_P (REGNO (operands[3]))"
2430   [(set (mem:SI (plus:DI (match_dup 2) (match_dup 1)))
2431         (match_dup 3))
2432    (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
2433   "")
2434
2435 (define_insn ""
2436   [(set (match_operand:SI 0 "move_dest_operand"
2437                           "=r,r,r,r,r,r,Q,!*q,!r")
2438         (match_operand:SI 1 "move_src_operand"
2439                           "A,r,J,N,K,RQ,rM,!rM,!*q"))]
2440   "(register_operand (operands[0], SImode)
2441     || reg_or_0_operand (operands[1], SImode))
2442    && TARGET_SOFT_FLOAT"
2443   "@
2444    ldw RT'%A1,%0
2445    copy %1,%0
2446    ldi %1,%0
2447    ldil L'%1,%0
2448    {zdepi|depwi,z} %Z1,%0
2449    ldw%M1 %1,%0
2450    stw%M0 %r1,%0
2451    mtsar %r1
2452    {mfctl|mfctl,w} %%sar,%0"
2453   [(set_attr "type" "load,move,move,move,move,load,store,move,move")
2454    (set_attr "pa_combine_type" "addmove")
2455    (set_attr "length" "4,4,4,4,4,4,4,4,4")])
2456
2457 ;; Load or store with base-register modification.
2458 (define_insn ""
2459   [(set (match_operand:SI 0 "register_operand" "=r")
2460         (mem:SI (plus:DI (match_operand:DI 1 "register_operand" "+r")
2461                          (match_operand:DI 2 "int5_operand" "L"))))
2462    (set (match_dup 1)
2463         (plus:DI (match_dup 1) (match_dup 2)))]
2464   "TARGET_64BIT"
2465   "ldw,mb %2(%1),%0"
2466   [(set_attr "type" "load")
2467    (set_attr "length" "4")])
2468
2469 ; And a zero extended variant.
2470 (define_insn ""
2471   [(set (match_operand:DI 0 "register_operand" "=r")
2472         (zero_extend:DI (mem:SI
2473                           (plus:DI
2474                             (match_operand:DI 1 "register_operand" "+r")
2475                             (match_operand:DI 2 "int5_operand" "L")))))
2476    (set (match_dup 1)
2477         (plus:DI (match_dup 1) (match_dup 2)))]
2478   "TARGET_64BIT"
2479   "ldw,mb %2(%1),%0"
2480   [(set_attr "type" "load")
2481    (set_attr "length" "4")])
2482
2483 (define_expand "pre_load"
2484   [(parallel [(set (match_operand:SI 0 "register_operand" "")
2485               (mem (plus (match_operand 1 "register_operand" "")
2486                                (match_operand 2 "pre_cint_operand" ""))))
2487               (set (match_dup 1)
2488                    (plus (match_dup 1) (match_dup 2)))])]
2489   ""
2490   "
2491 {
2492   if (TARGET_64BIT)
2493     {
2494       emit_insn (gen_pre_ldd (operands[0], operands[1], operands[2]));
2495       DONE;
2496     }
2497   emit_insn (gen_pre_ldw (operands[0], operands[1], operands[2]));
2498   DONE;
2499 }")
2500
2501 (define_insn "pre_ldw"
2502   [(set (match_operand:SI 0 "register_operand" "=r")
2503         (mem:SI (plus:SI (match_operand:SI 1 "register_operand" "+r")
2504                          (match_operand:SI 2 "pre_cint_operand" ""))))
2505    (set (match_dup 1)
2506         (plus:SI (match_dup 1) (match_dup 2)))]
2507   ""
2508   "*
2509 {
2510   if (INTVAL (operands[2]) < 0)
2511     return \"{ldwm|ldw,mb} %2(%1),%0\";
2512   return \"{ldws|ldw},mb %2(%1),%0\";
2513 }"
2514   [(set_attr "type" "load")
2515    (set_attr "length" "4")])
2516
2517 (define_insn "pre_ldd"
2518   [(set (match_operand:DI 0 "register_operand" "=r")
2519         (mem:DI (plus:DI (match_operand:DI 1 "register_operand" "+r")
2520                          (match_operand:DI 2 "pre_cint_operand" ""))))
2521    (set (match_dup 1)
2522         (plus:DI (match_dup 1) (match_dup 2)))]
2523   "TARGET_64BIT"
2524   "ldd,mb %2(%1),%0"
2525   [(set_attr "type" "load")
2526    (set_attr "length" "4")])
2527
2528 (define_insn ""
2529   [(set (mem:SI (plus:SI (match_operand:SI 0 "register_operand" "+r")
2530                          (match_operand:SI 1 "pre_cint_operand" "")))
2531         (match_operand:SI 2 "reg_or_0_operand" "rM"))
2532    (set (match_dup 0)
2533         (plus:SI (match_dup 0) (match_dup 1)))]
2534   ""
2535   "*
2536 {
2537   if (INTVAL (operands[1]) < 0)
2538     return \"{stwm|stw,mb} %r2,%1(%0)\";
2539   return \"{stws|stw},mb %r2,%1(%0)\";
2540 }"
2541   [(set_attr "type" "store")
2542    (set_attr "length" "4")])
2543
2544 (define_insn ""
2545   [(set (match_operand:SI 0 "register_operand" "=r")
2546         (mem:SI (match_operand:SI 1 "register_operand" "+r")))
2547    (set (match_dup 1)
2548         (plus:SI (match_dup 1)
2549                  (match_operand:SI 2 "post_cint_operand" "")))]
2550   ""
2551   "*
2552 {
2553   if (INTVAL (operands[2]) > 0)
2554     return \"{ldwm|ldw,ma} %2(%1),%0\";
2555   return \"{ldws|ldw},ma %2(%1),%0\";
2556 }"
2557   [(set_attr "type" "load")
2558    (set_attr "length" "4")])
2559
2560 (define_expand "post_store"
2561   [(parallel [(set (mem (match_operand 0 "register_operand" ""))
2562                    (match_operand 1 "reg_or_0_operand" ""))
2563               (set (match_dup 0)
2564                    (plus (match_dup 0)
2565                          (match_operand 2 "post_cint_operand" "")))])]
2566   ""
2567   "
2568 {
2569   if (TARGET_64BIT)
2570     {
2571       emit_insn (gen_post_std (operands[0], operands[1], operands[2]));
2572       DONE;
2573     }
2574   emit_insn (gen_post_stw (operands[0], operands[1], operands[2]));
2575   DONE;
2576 }")
2577
2578 (define_insn "post_stw"
2579   [(set (mem:SI (match_operand:SI 0 "register_operand" "+r"))
2580         (match_operand:SI 1 "reg_or_0_operand" "rM"))
2581    (set (match_dup 0)
2582         (plus:SI (match_dup 0)
2583                  (match_operand:SI 2 "post_cint_operand" "")))]
2584   ""
2585   "*
2586 {
2587   if (INTVAL (operands[2]) > 0)
2588     return \"{stwm|stw,ma} %r1,%2(%0)\";
2589   return \"{stws|stw},ma %r1,%2(%0)\";
2590 }"
2591   [(set_attr "type" "store")
2592    (set_attr "length" "4")])
2593
2594 (define_insn "post_std"
2595   [(set (mem:DI (match_operand:DI 0 "register_operand" "+r"))
2596         (match_operand:DI 1 "reg_or_0_operand" "rM"))
2597    (set (match_dup 0)
2598         (plus:DI (match_dup 0)
2599                  (match_operand:DI 2 "post_cint_operand" "")))]
2600   "TARGET_64BIT"
2601   "std,ma %r1,%2(%0)"
2602   [(set_attr "type" "store")
2603    (set_attr "length" "4")])
2604
2605 ;; For loading the address of a label while generating PIC code.
2606 ;; Note since this pattern can be created at reload time (via movsi), all
2607 ;; the same rules for movsi apply here.  (no new pseudos, no temporaries).
2608 (define_insn ""
2609   [(set (match_operand 0 "pmode_register_operand" "=a")
2610         (match_operand 1 "pic_label_operand" ""))]
2611   "TARGET_PA_20"
2612   "*
2613 {
2614   rtx xoperands[3];
2615
2616   xoperands[0] = operands[0];
2617   xoperands[1] = operands[1];
2618   xoperands[2] = gen_label_rtx ();
2619
2620   (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
2621                                      CODE_LABEL_NUMBER (xoperands[2]));
2622   output_asm_insn (\"mfia %0\", xoperands);
2623
2624   /* If we're trying to load the address of a label that happens to be
2625      close, then we can use a shorter sequence.  */
2626   if (GET_CODE (operands[1]) == LABEL_REF
2627       && INSN_ADDRESSES_SET_P ()
2628       && abs (INSN_ADDRESSES (INSN_UID (XEXP (operands[1], 0)))
2629                 - INSN_ADDRESSES (INSN_UID (insn))) < 8100)
2630     output_asm_insn (\"ldo %1-%2(%0),%0\", xoperands);
2631   else
2632     {
2633       output_asm_insn (\"addil L%%%1-%2,%0\", xoperands);
2634       output_asm_insn (\"ldo R%%%1-%2(%0),%0\", xoperands);
2635     }
2636   return \"\";
2637 }"
2638   [(set_attr "type" "multi")
2639    (set_attr "length" "12")])           ; 8 or 12
2640
2641 (define_insn ""
2642   [(set (match_operand 0 "pmode_register_operand" "=a")
2643         (match_operand 1 "pic_label_operand" ""))]
2644   "!TARGET_PA_20"
2645   "*
2646 {
2647   rtx xoperands[3];
2648
2649   xoperands[0] = operands[0];
2650   xoperands[1] = operands[1];
2651   xoperands[2] = gen_label_rtx ();
2652
2653   output_asm_insn (\"bl .+8,%0\", xoperands);
2654   output_asm_insn (\"depi 0,31,2,%0\", xoperands);
2655   (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
2656                                      CODE_LABEL_NUMBER (xoperands[2]));
2657
2658   /* If we're trying to load the address of a label that happens to be
2659      close, then we can use a shorter sequence.  */
2660   if (GET_CODE (operands[1]) == LABEL_REF
2661       && INSN_ADDRESSES_SET_P ()
2662       && abs (INSN_ADDRESSES (INSN_UID (XEXP (operands[1], 0)))
2663                 - INSN_ADDRESSES (INSN_UID (insn))) < 8100)
2664     output_asm_insn (\"ldo %1-%2(%0),%0\", xoperands);
2665   else
2666     {
2667       output_asm_insn (\"addil L%%%1-%2,%0\", xoperands);
2668       output_asm_insn (\"ldo R%%%1-%2(%0),%0\", xoperands);
2669     }
2670   return \"\";
2671 }"
2672   [(set_attr "type" "multi")
2673    (set_attr "length" "16")])           ; 12 or 16
2674
2675 (define_insn ""
2676   [(set (match_operand:SI 0 "register_operand" "=a")
2677         (plus:SI (match_operand:SI 1 "register_operand" "r")
2678                  (high:SI (match_operand 2 "" ""))))]
2679   "symbolic_operand (operands[2], Pmode)
2680    && ! function_label_operand (operands[2], Pmode)
2681    && flag_pic"
2682   "addil LT'%G2,%1"
2683   [(set_attr "type" "binary")
2684    (set_attr "length" "4")])
2685
2686 (define_insn ""
2687   [(set (match_operand:DI 0 "register_operand" "=a")
2688         (plus:DI (match_operand:DI 1 "register_operand" "r")
2689                  (high:DI (match_operand 2 "" ""))))]
2690   "symbolic_operand (operands[2], Pmode)
2691    && ! function_label_operand (operands[2], Pmode)
2692    && TARGET_64BIT
2693    && flag_pic"
2694   "addil LT'%G2,%1"
2695   [(set_attr "type" "binary")
2696    (set_attr "length" "4")])
2697
2698 ;; Always use addil rather than ldil;add sequences.  This allows the
2699 ;; HP linker to eliminate the dp relocation if the symbolic operand
2700 ;; lives in the TEXT space.
2701 (define_insn ""
2702   [(set (match_operand:SI 0 "register_operand" "=a")
2703         (high:SI (match_operand 1 "" "")))]
2704   "symbolic_operand (operands[1], Pmode)
2705    && ! function_label_operand (operands[1], Pmode)
2706    && ! read_only_operand (operands[1], Pmode)
2707    && ! flag_pic"
2708   "*
2709 {
2710   if (TARGET_LONG_LOAD_STORE)
2711     return \"addil NLR'%H1,%%r27\;ldo N'%H1(%%r1),%%r1\";
2712   else
2713     return \"addil LR'%H1,%%r27\";
2714 }"
2715   [(set_attr "type" "binary")
2716    (set (attr "length")
2717       (if_then_else (eq (symbol_ref "TARGET_LONG_LOAD_STORE") (const_int 0))
2718                     (const_int 4)
2719                     (const_int 8)))])
2720
2721
2722 ;; This is for use in the prologue/epilogue code.  We need it
2723 ;; to add large constants to a stack pointer or frame pointer.
2724 ;; Because of the additional %r1 pressure, we probably do not
2725 ;; want to use this in general code, so make it available
2726 ;; only after reload.
2727 (define_insn ""
2728   [(set (match_operand:SI 0 "register_operand" "=!a,*r")
2729         (plus:SI (match_operand:SI 1 "register_operand" "r,r")
2730                  (high:SI (match_operand 2 "const_int_operand" ""))))]
2731   "reload_completed"
2732   "@
2733    addil L'%G2,%1
2734    ldil L'%G2,%0\;{addl|add,l} %0,%1,%0"
2735   [(set_attr "type" "binary,binary")
2736    (set_attr "length" "4,8")])
2737
2738 (define_insn ""
2739   [(set (match_operand:DI 0 "register_operand" "=!a,*r")
2740         (plus:DI (match_operand:DI 1 "register_operand" "r,r")
2741                  (high:DI (match_operand 2 "const_int_operand" ""))))]
2742   "reload_completed && TARGET_64BIT"
2743   "@
2744    addil L'%G2,%1
2745    ldil L'%G2,%0\;{addl|add,l} %0,%1,%0"
2746   [(set_attr "type" "binary,binary")
2747    (set_attr "length" "4,8")])
2748
2749 (define_insn ""
2750   [(set (match_operand:SI 0 "register_operand" "=r")
2751         (high:SI (match_operand 1 "" "")))]
2752   "(!flag_pic || !symbolic_operand (operands[1], Pmode))
2753     && !is_function_label_plus_const (operands[1])"
2754   "*
2755 {
2756   if (symbolic_operand (operands[1], Pmode))
2757     return \"ldil LR'%H1,%0\";
2758   else
2759     return \"ldil L'%G1,%0\";
2760 }"
2761   [(set_attr "type" "move")
2762    (set_attr "length" "4")])
2763
2764 (define_insn ""
2765   [(set (match_operand:DI 0 "register_operand" "=r")
2766         (high:DI (match_operand 1 "const_int_operand" "")))]
2767   "TARGET_64BIT"
2768   "ldil L'%G1,%0";
2769   [(set_attr "type" "move")
2770    (set_attr "length" "4")])
2771
2772 (define_insn ""
2773   [(set (match_operand:DI 0 "register_operand" "=r")
2774         (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
2775                    (match_operand:DI 2 "const_int_operand" "i")))]
2776   "TARGET_64BIT"
2777   "ldo R'%G2(%1),%0";
2778   [(set_attr "type" "move")
2779    (set_attr "length" "4")])
2780
2781 (define_insn ""
2782   [(set (match_operand:SI 0 "register_operand" "=r")
2783         (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
2784                    (match_operand:SI 2 "immediate_operand" "i")))]
2785   "!is_function_label_plus_const (operands[2])"
2786   "*
2787 {
2788   if (flag_pic && symbolic_operand (operands[2], Pmode))
2789     abort ();
2790   else if (symbolic_operand (operands[2], Pmode))
2791     return \"ldo RR'%G2(%1),%0\";
2792   else
2793     return \"ldo R'%G2(%1),%0\";
2794 }"
2795   [(set_attr "type" "move")
2796    (set_attr "length" "4")])
2797
2798 ;; Now that a symbolic_address plus a constant is broken up early
2799 ;; in the compilation phase (for better CSE) we need a special
2800 ;; combiner pattern to load the symbolic address plus the constant
2801 ;; in only 2 instructions. (For cases where the symbolic address
2802 ;; was not a common subexpression.)
2803 (define_split
2804   [(set (match_operand:SI 0 "register_operand" "")
2805         (match_operand:SI 1 "symbolic_operand" ""))
2806    (clobber (match_operand:SI 2 "register_operand" ""))]
2807   "! (flag_pic && pic_label_operand (operands[1], SImode))"
2808   [(set (match_dup 2) (high:SI (match_dup 1)))
2809    (set (match_dup 0) (lo_sum:SI (match_dup 2) (match_dup 1)))]
2810   "")
2811
2812 ;; hppa_legitimize_address goes to a great deal of trouble to
2813 ;; create addresses which use indexing.  In some cases, this
2814 ;; is a lose because there isn't any store instructions which
2815 ;; allow indexed addresses (with integer register source).
2816 ;;
2817 ;; These define_splits try to turn a 3 insn store into
2818 ;; a 2 insn store with some creative RTL rewriting.
2819 (define_split
2820   [(set (mem:SI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2821                                (match_operand:SI 1 "shadd_operand" ""))
2822                    (plus:SI (match_operand:SI 2 "register_operand" "")
2823                             (match_operand:SI 3 "const_int_operand" ""))))
2824         (match_operand:SI 4 "register_operand" ""))
2825    (clobber (match_operand:SI 5 "register_operand" ""))]
2826   ""
2827   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
2828                                (match_dup 2)))
2829    (set (mem:SI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2830   "")
2831
2832 (define_split
2833   [(set (mem:HI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2834                                (match_operand:SI 1 "shadd_operand" ""))
2835                    (plus:SI (match_operand:SI 2 "register_operand" "")
2836                             (match_operand:SI 3 "const_int_operand" ""))))
2837         (match_operand:HI 4 "register_operand" ""))
2838    (clobber (match_operand:SI 5 "register_operand" ""))]
2839   ""
2840   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
2841                                (match_dup 2)))
2842    (set (mem:HI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2843   "")
2844
2845 (define_split
2846   [(set (mem:QI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2847                                (match_operand:SI 1 "shadd_operand" ""))
2848                    (plus:SI (match_operand:SI 2 "register_operand" "")
2849                             (match_operand:SI 3 "const_int_operand" ""))))
2850         (match_operand:QI 4 "register_operand" ""))
2851    (clobber (match_operand:SI 5 "register_operand" ""))]
2852   ""
2853   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
2854                                (match_dup 2)))
2855    (set (mem:QI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2856   "")
2857
2858 (define_expand "movhi"
2859   [(set (match_operand:HI 0 "general_operand" "")
2860         (match_operand:HI 1 "general_operand" ""))]
2861   ""
2862   "
2863 {
2864   if (emit_move_sequence (operands, HImode, 0))
2865     DONE;
2866 }")
2867
2868 (define_insn ""
2869   [(set (match_operand:HI 0 "move_dest_operand"
2870                           "=r,r,r,r,r,Q,!*q,!r,!*f")
2871         (match_operand:HI 1 "move_src_operand"
2872                           "r,J,N,K,RQ,rM,!rM,!*q,!*fM"))]
2873   "register_operand (operands[0], HImode)
2874    || reg_or_0_operand (operands[1], HImode)"
2875   "@
2876    copy %1,%0
2877    ldi %1,%0
2878    ldil L'%1,%0
2879    {zdepi|depwi,z} %Z1,%0
2880    ldh%M1 %1,%0
2881    sth%M0 %r1,%0
2882    mtsar %r1
2883    {mfctl|mfctl,w} %sar,%0
2884    fcpy,sgl %f1,%0"
2885   [(set_attr "type" "move,move,move,shift,load,store,move,move,fpalu")
2886    (set_attr "pa_combine_type" "addmove")
2887    (set_attr "length" "4,4,4,4,4,4,4,4,4")])
2888
2889 (define_insn ""
2890   [(set (match_operand:HI 0 "register_operand" "=r")
2891         (mem:HI (plus:SI (match_operand:SI 1 "register_operand" "+r")
2892                          (match_operand:SI 2 "int5_operand" "L"))))
2893    (set (match_dup 1)
2894         (plus:SI (match_dup 1) (match_dup 2)))]
2895   ""
2896   "{ldhs|ldh},mb %2(%1),%0"
2897   [(set_attr "type" "load")
2898    (set_attr "length" "4")])
2899
2900 (define_insn ""
2901   [(set (match_operand:HI 0 "register_operand" "=r")
2902         (mem:HI (plus:DI (match_operand:DI 1 "register_operand" "+r")
2903                          (match_operand:DI 2 "int5_operand" "L"))))
2904    (set (match_dup 1)
2905         (plus:DI (match_dup 1) (match_dup 2)))]
2906   "TARGET_64BIT"
2907   "ldh,mb %2(%1),%0"
2908   [(set_attr "type" "load")
2909    (set_attr "length" "4")])
2910
2911 ; And a zero extended variant.
2912 (define_insn ""
2913   [(set (match_operand:DI 0 "register_operand" "=r")
2914         (zero_extend:DI (mem:HI
2915                           (plus:DI
2916                             (match_operand:DI 1 "register_operand" "+r")
2917                             (match_operand:DI 2 "int5_operand" "L")))))
2918    (set (match_dup 1)
2919         (plus:DI (match_dup 1) (match_dup 2)))]
2920   "TARGET_64BIT"
2921   "ldh,mb %2(%1),%0"
2922   [(set_attr "type" "load")
2923    (set_attr "length" "4")])
2924
2925 (define_insn ""
2926   [(set (match_operand:SI 0 "register_operand" "=r")
2927         (zero_extend:SI (mem:HI
2928                           (plus:SI
2929                             (match_operand:SI 1 "register_operand" "+r")
2930                             (match_operand:SI 2 "int5_operand" "L")))))
2931    (set (match_dup 1)
2932         (plus:SI (match_dup 1) (match_dup 2)))]
2933   ""
2934   "{ldhs|ldh},mb %2(%1),%0"
2935   [(set_attr "type" "load")
2936    (set_attr "length" "4")])
2937
2938 (define_insn ""
2939   [(set (match_operand:SI 0 "register_operand" "=r")
2940         (zero_extend:SI (mem:HI
2941                           (plus:DI
2942                             (match_operand:DI 1 "register_operand" "+r")
2943                             (match_operand:DI 2 "int5_operand" "L")))))
2944    (set (match_dup 1)
2945         (plus:DI (match_dup 1) (match_dup 2)))]
2946   "TARGET_64BIT"
2947   "ldh,mb %2(%1),%0"
2948   [(set_attr "type" "load")
2949    (set_attr "length" "4")])
2950
2951 (define_insn ""
2952   [(set (mem:HI (plus:SI (match_operand:SI 0 "register_operand" "+r")
2953                          (match_operand:SI 1 "int5_operand" "L")))
2954         (match_operand:HI 2 "reg_or_0_operand" "rM"))
2955    (set (match_dup 0)
2956         (plus:SI (match_dup 0) (match_dup 1)))]
2957   ""
2958   "{sths|sth},mb %r2,%1(%0)"
2959   [(set_attr "type" "store")
2960    (set_attr "length" "4")])
2961
2962 (define_insn ""
2963   [(set (mem:HI (plus:DI (match_operand:DI 0 "register_operand" "+r")
2964                          (match_operand:DI 1 "int5_operand" "L")))
2965         (match_operand:HI 2 "reg_or_0_operand" "rM"))
2966    (set (match_dup 0)
2967         (plus:DI (match_dup 0) (match_dup 1)))]
2968   "TARGET_64BIT"
2969   "sth,mb %r2,%1(%0)"
2970   [(set_attr "type" "store")
2971    (set_attr "length" "4")])
2972
2973 (define_insn ""
2974   [(set (match_operand:HI 0 "register_operand" "=r")
2975         (plus:HI (match_operand:HI 1 "register_operand" "r")
2976                  (match_operand 2 "const_int_operand" "J")))]
2977   ""
2978   "ldo %2(%1),%0"
2979   [(set_attr "type" "binary")
2980    (set_attr "pa_combine_type" "addmove")
2981    (set_attr "length" "4")])
2982
2983 (define_expand "movqi"
2984   [(set (match_operand:QI 0 "general_operand" "")
2985         (match_operand:QI 1 "general_operand" ""))]
2986   ""
2987   "
2988 {
2989   if (emit_move_sequence (operands, QImode, 0))
2990     DONE;
2991 }")
2992
2993 (define_insn ""
2994   [(set (match_operand:QI 0 "move_dest_operand"
2995                           "=r,r,r,r,r,Q,!*q,!r,!*f")
2996         (match_operand:QI 1 "move_src_operand"
2997                           "r,J,N,K,RQ,rM,!rM,!*q,!*fM"))]
2998   "register_operand (operands[0], QImode)
2999    || reg_or_0_operand (operands[1], QImode)"
3000   "@
3001    copy %1,%0
3002    ldi %1,%0
3003    ldil L'%1,%0
3004    {zdepi|depwi,z} %Z1,%0
3005    ldb%M1 %1,%0
3006    stb%M0 %r1,%0
3007    mtsar %r1
3008    {mfctl|mfctl,w} %%sar,%0
3009    fcpy,sgl %f1,%0"
3010   [(set_attr "type" "move,move,move,shift,load,store,move,move,fpalu")
3011    (set_attr "pa_combine_type" "addmove")
3012    (set_attr "length" "4,4,4,4,4,4,4,4,4")])
3013
3014 (define_insn ""
3015   [(set (match_operand:QI 0 "register_operand" "=r")
3016         (mem:QI (plus:SI (match_operand:SI 1 "register_operand" "+r")
3017                          (match_operand:SI 2 "int5_operand" "L"))))
3018    (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
3019   ""
3020   "{ldbs|ldb},mb %2(%1),%0"
3021   [(set_attr "type" "load")
3022    (set_attr "length" "4")])
3023
3024 (define_insn ""
3025   [(set (match_operand:QI 0 "register_operand" "=r")
3026         (mem:QI (plus:DI (match_operand:DI 1 "register_operand" "+r")
3027                          (match_operand:DI 2 "int5_operand" "L"))))
3028    (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3029   "TARGET_64BIT"
3030   "ldb,mb %2(%1),%0"
3031   [(set_attr "type" "load")
3032    (set_attr "length" "4")])
3033
3034 ; Now the same thing with zero extensions.
3035 (define_insn ""
3036   [(set (match_operand:DI 0 "register_operand" "=r")
3037         (zero_extend:DI (mem:QI (plus:DI
3038                                   (match_operand:DI 1 "register_operand" "+r")
3039                                   (match_operand:DI 2 "int5_operand" "L")))))
3040    (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3041   "TARGET_64BIT"
3042   "ldb,mb %2(%1),%0"
3043   [(set_attr "type" "load")
3044    (set_attr "length" "4")])
3045
3046 (define_insn ""
3047   [(set (match_operand:SI 0 "register_operand" "=r")
3048         (zero_extend:SI (mem:QI (plus:SI
3049                                   (match_operand:SI 1 "register_operand" "+r")
3050                                   (match_operand:SI 2 "int5_operand" "L")))))
3051    (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
3052   ""
3053   "{ldbs|ldb},mb %2(%1),%0"
3054   [(set_attr "type" "load")
3055    (set_attr "length" "4")])
3056
3057 (define_insn ""
3058   [(set (match_operand:SI 0 "register_operand" "=r")
3059         (zero_extend:SI (mem:QI (plus:DI
3060                                   (match_operand:DI 1 "register_operand" "+r")
3061                                   (match_operand:DI 2 "int5_operand" "L")))))
3062    (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3063   "TARGET_64BIT"
3064   "ldb,mb %2(%1),%0"
3065   [(set_attr "type" "load")
3066    (set_attr "length" "4")])
3067
3068 (define_insn ""
3069   [(set (match_operand:HI 0 "register_operand" "=r")
3070         (zero_extend:HI (mem:QI (plus:SI
3071                                   (match_operand:SI 1 "register_operand" "+r")
3072                                   (match_operand:SI 2 "int5_operand" "L")))))
3073    (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
3074   ""
3075   "{ldbs|ldb},mb %2(%1),%0"
3076   [(set_attr "type" "load")
3077    (set_attr "length" "4")])
3078
3079 (define_insn ""
3080   [(set (match_operand:HI 0 "register_operand" "=r")
3081         (zero_extend:HI (mem:QI (plus:DI
3082                                   (match_operand:DI 1 "register_operand" "+r")
3083                                   (match_operand:DI 2 "int5_operand" "L")))))
3084    (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3085   "TARGET_64BIT"
3086   "ldb,mb %2(%1),%0"
3087   [(set_attr "type" "load")
3088    (set_attr "length" "4")])
3089
3090 (define_insn ""
3091   [(set (mem:QI (plus:SI (match_operand:SI 0 "register_operand" "+r")
3092                          (match_operand:SI 1 "int5_operand" "L")))
3093         (match_operand:QI 2 "reg_or_0_operand" "rM"))
3094    (set (match_dup 0)
3095         (plus:SI (match_dup 0) (match_dup 1)))]
3096   ""
3097   "{stbs|stb},mb %r2,%1(%0)"
3098   [(set_attr "type" "store")
3099    (set_attr "length" "4")])
3100
3101 (define_insn ""
3102   [(set (mem:QI (plus:DI (match_operand:DI 0 "register_operand" "+r")
3103                          (match_operand:DI 1 "int5_operand" "L")))
3104         (match_operand:QI 2 "reg_or_0_operand" "rM"))
3105    (set (match_dup 0)
3106         (plus:DI (match_dup 0) (match_dup 1)))]
3107   "TARGET_64BIT"
3108   "stb,mb %r2,%1(%0)"
3109   [(set_attr "type" "store")
3110    (set_attr "length" "4")])
3111
3112 ;; The definition of this insn does not really explain what it does,
3113 ;; but it should suffice that anything generated as this insn will be
3114 ;; recognized as a movstrsi operation, and that it will not successfully
3115 ;; combine with anything.
3116 (define_expand "movstrsi"
3117   [(parallel [(set (match_operand:BLK 0 "" "")
3118                    (match_operand:BLK 1 "" ""))
3119               (clobber (match_dup 4))
3120               (clobber (match_dup 5))
3121               (clobber (match_dup 6))
3122               (clobber (match_dup 7))
3123               (clobber (match_dup 8))
3124               (use (match_operand:SI 2 "arith_operand" ""))
3125               (use (match_operand:SI 3 "const_int_operand" ""))])]
3126   "!TARGET_64BIT && optimize > 0"
3127   "
3128 {
3129   int size, align;
3130
3131   /* HP provides very fast block move library routine for the PA;
3132      this routine includes:
3133
3134         4x4 byte at a time block moves,
3135         1x4 byte at a time with alignment checked at runtime with
3136             attempts to align the source and destination as needed
3137         1x1 byte loop
3138
3139      With that in mind, here's the heuristics to try and guess when
3140      the inlined block move will be better than the library block
3141      move:
3142
3143         If the size isn't constant, then always use the library routines.
3144
3145         If the size is large in respect to the known alignment, then use
3146         the library routines.
3147
3148         If the size is small in respect to the known alignment, then open
3149         code the copy (since that will lead to better scheduling).
3150
3151         Else use the block move pattern.   */
3152
3153   /* Undetermined size, use the library routine.  */
3154   if (GET_CODE (operands[2]) != CONST_INT)
3155     FAIL;
3156
3157   size = INTVAL (operands[2]);
3158   align = INTVAL (operands[3]);
3159   align = align > 4 ? 4 : align;
3160
3161   /* If size/alignment is large, then use the library routines.  */
3162   if (size / align > 16)
3163     FAIL;
3164
3165   /* This does happen, but not often enough to worry much about.  */
3166   if (size / align < MOVE_RATIO)
3167     FAIL;
3168   
3169   /* Fall through means we're going to use our block move pattern.  */
3170   operands[0]
3171     = replace_equiv_address (operands[0],
3172                              copy_to_mode_reg (SImode, XEXP (operands[0], 0)));
3173   operands[1]
3174     = replace_equiv_address (operands[1],
3175                              copy_to_mode_reg (SImode, XEXP (operands[1], 0)));
3176   operands[4] = gen_reg_rtx (SImode);
3177   operands[5] = gen_reg_rtx (SImode);
3178   operands[6] = gen_reg_rtx (SImode);
3179   operands[7] = gen_reg_rtx (SImode);
3180   operands[8] = gen_reg_rtx (SImode);
3181 }")
3182
3183 ;; The operand constraints are written like this to support both compile-time
3184 ;; and run-time determined byte counts.  The expander and output_block_move
3185 ;; only support compile-time determined counts at this time.
3186 ;;
3187 ;; If the count is run-time determined, the register with the byte count
3188 ;; is clobbered by the copying code, and therefore it is forced to operand 2.
3189 ;;
3190 ;; We used to clobber operands 0 and 1.  However, a change to regrename.c
3191 ;; broke this semantic for pseudo registers.  We can't use match_scratch
3192 ;; as this requires two registers in the class R1_REGS when the MEMs for
3193 ;; operands 0 and 1 are both equivalent to symbolic MEMs.  Thus, we are
3194 ;; forced to internally copy operands 0 and 1 to operands 7 and 8,
3195 ;; respectively.  We then split or peephole optimize after reload.
3196 (define_insn "movstrsi_prereload"
3197   [(set (mem:BLK (match_operand:SI 0 "register_operand" "r,r"))
3198         (mem:BLK (match_operand:SI 1 "register_operand" "r,r")))
3199    (clobber (match_operand:SI 2 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3200    (clobber (match_operand:SI 3 "register_operand" "=&r,&r"))   ;item tmp1
3201    (clobber (match_operand:SI 6 "register_operand" "=&r,&r"))   ;item tmp2
3202    (clobber (match_operand:SI 7 "register_operand" "=&r,&r"))   ;item tmp3
3203    (clobber (match_operand:SI 8 "register_operand" "=&r,&r"))   ;item tmp4
3204    (use (match_operand:SI 4 "arith_operand" "J,2"))      ;byte count
3205    (use (match_operand:SI 5 "const_int_operand" "n,n"))] ;alignment
3206   "!TARGET_64BIT"
3207   "#"
3208   [(set_attr "type" "multi,multi")])
3209
3210 (define_split
3211   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3212                    (match_operand:BLK 1 "memory_operand" ""))
3213               (clobber (match_operand:SI 2 "register_operand" ""))
3214               (clobber (match_operand:SI 3 "register_operand" ""))
3215               (clobber (match_operand:SI 6 "register_operand" ""))
3216               (clobber (match_operand:SI 7 "register_operand" ""))
3217               (clobber (match_operand:SI 8 "register_operand" ""))
3218               (use (match_operand:SI 4 "arith_operand" ""))
3219               (use (match_operand:SI 5 "const_int_operand" ""))])]
3220   "!TARGET_64BIT && reload_completed && !flag_peephole2
3221    && GET_CODE (operands[0]) == MEM
3222    && register_operand (XEXP (operands[0], 0), SImode)
3223    && GET_CODE (operands[1]) == MEM
3224    && register_operand (XEXP (operands[1], 0), SImode)"
3225   [(set (match_dup 7) (match_dup 9))
3226    (set (match_dup 8) (match_dup 10))
3227    (parallel [(set (match_dup 0) (match_dup 1))
3228               (clobber (match_dup 2))
3229               (clobber (match_dup 3))
3230               (clobber (match_dup 6))
3231               (clobber (match_dup 7))
3232               (clobber (match_dup 8))
3233               (use (match_dup 4))
3234               (use (match_dup 5))
3235               (const_int 0)])]
3236   "
3237 {
3238   operands[9] = XEXP (operands[0], 0);
3239   operands[10] = XEXP (operands[1], 0);
3240   operands[0] = replace_equiv_address (operands[0], operands[7]);
3241   operands[1] = replace_equiv_address (operands[1], operands[8]);
3242 }")
3243
3244 (define_peephole2
3245   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3246                    (match_operand:BLK 1 "memory_operand" ""))
3247               (clobber (match_operand:SI 2 "register_operand" ""))
3248               (clobber (match_operand:SI 3 "register_operand" ""))
3249               (clobber (match_operand:SI 6 "register_operand" ""))
3250               (clobber (match_operand:SI 7 "register_operand" ""))
3251               (clobber (match_operand:SI 8 "register_operand" ""))
3252               (use (match_operand:SI 4 "arith_operand" ""))
3253               (use (match_operand:SI 5 "const_int_operand" ""))])]
3254   "!TARGET_64BIT
3255    && GET_CODE (operands[0]) == MEM
3256    && register_operand (XEXP (operands[0], 0), SImode)
3257    && GET_CODE (operands[1]) == MEM
3258    && register_operand (XEXP (operands[1], 0), SImode)"
3259   [(parallel [(set (match_dup 0) (match_dup 1))
3260               (clobber (match_dup 2))
3261               (clobber (match_dup 3))
3262               (clobber (match_dup 6))
3263               (clobber (match_dup 7))
3264               (clobber (match_dup 8))
3265               (use (match_dup 4))
3266               (use (match_dup 5))
3267               (const_int 0)])]
3268   "
3269 {
3270   rtx addr = XEXP (operands[0], 0);
3271   if (dead_or_set_p (curr_insn, addr))
3272     operands[7] = addr;
3273   else
3274     {
3275       emit_insn (gen_rtx_SET (VOIDmode, operands[7], addr));
3276       operands[0] = replace_equiv_address (operands[0], operands[7]);
3277     }
3278
3279   addr = XEXP (operands[1], 0);
3280   if (dead_or_set_p (curr_insn, addr))
3281     operands[8] = addr;
3282   else
3283     {
3284       emit_insn (gen_rtx_SET (VOIDmode, operands[8], addr));
3285       operands[1] = replace_equiv_address (operands[1], operands[8]);
3286     }
3287 }")
3288
3289 (define_insn "movstrsi_postreload"
3290   [(set (mem:BLK (match_operand:SI 0 "register_operand" "+r,r"))
3291         (mem:BLK (match_operand:SI 1 "register_operand" "+r,r")))
3292    (clobber (match_operand:SI 2 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3293    (clobber (match_operand:SI 3 "register_operand" "=&r,&r"))   ;item tmp1
3294    (clobber (match_operand:SI 6 "register_operand" "=&r,&r"))   ;item tmp2
3295    (clobber (match_dup 0))
3296    (clobber (match_dup 1))
3297    (use (match_operand:SI 4 "arith_operand" "J,2"))      ;byte count
3298    (use (match_operand:SI 5 "const_int_operand" "n,n"))  ;alignment
3299    (const_int 0)]
3300   "!TARGET_64BIT && reload_completed"
3301   "* return output_block_move (operands, !which_alternative);"
3302   [(set_attr "type" "multi,multi")])
3303
3304 (define_expand "movstrdi"
3305   [(parallel [(set (match_operand:BLK 0 "" "")
3306                    (match_operand:BLK 1 "" ""))
3307               (clobber (match_dup 4))
3308               (clobber (match_dup 5))
3309               (clobber (match_dup 6))
3310               (clobber (match_dup 7))
3311               (clobber (match_dup 8))
3312               (use (match_operand:DI 2 "arith_operand" ""))
3313               (use (match_operand:DI 3 "const_int_operand" ""))])]
3314   "TARGET_64BIT && optimize > 0"
3315   "
3316 {
3317   int size, align;
3318
3319   /* HP provides very fast block move library routine for the PA;
3320      this routine includes:
3321
3322         4x4 byte at a time block moves,
3323         1x4 byte at a time with alignment checked at runtime with
3324             attempts to align the source and destination as needed
3325         1x1 byte loop
3326
3327      With that in mind, here's the heuristics to try and guess when
3328      the inlined block move will be better than the library block
3329      move:
3330
3331         If the size isn't constant, then always use the library routines.
3332
3333         If the size is large in respect to the known alignment, then use
3334         the library routines.
3335
3336         If the size is small in respect to the known alignment, then open
3337         code the copy (since that will lead to better scheduling).
3338
3339         Else use the block move pattern.   */
3340
3341   /* Undetermined size, use the library routine.  */
3342   if (GET_CODE (operands[2]) != CONST_INT)
3343     FAIL;
3344
3345   size = INTVAL (operands[2]);
3346   align = INTVAL (operands[3]);
3347   align = align > 8 ? 8 : align;
3348
3349   /* If size/alignment is large, then use the library routines.  */
3350   if (size / align > 16)
3351     FAIL;
3352
3353   /* This does happen, but not often enough to worry much about.  */
3354   if (size / align < MOVE_RATIO)
3355     FAIL;
3356   
3357   /* Fall through means we're going to use our block move pattern.  */
3358   operands[0]
3359     = replace_equiv_address (operands[0],
3360                              copy_to_mode_reg (DImode, XEXP (operands[0], 0)));
3361   operands[1]
3362     = replace_equiv_address (operands[1],
3363                              copy_to_mode_reg (DImode, XEXP (operands[1], 0)));
3364   operands[4] = gen_reg_rtx (DImode);
3365   operands[5] = gen_reg_rtx (DImode);
3366   operands[6] = gen_reg_rtx (DImode);
3367   operands[7] = gen_reg_rtx (DImode);
3368   operands[8] = gen_reg_rtx (DImode);
3369 }")
3370
3371 ;; The operand constraints are written like this to support both compile-time
3372 ;; and run-time determined byte counts.  The expander and output_block_move
3373 ;; only support compile-time determined counts at this time.
3374 ;;
3375 ;; If the count is run-time determined, the register with the byte count
3376 ;; is clobbered by the copying code, and therefore it is forced to operand 2.
3377 ;;
3378 ;; We used to clobber operands 0 and 1.  However, a change to regrename.c
3379 ;; broke this semantic for pseudo registers.  We can't use match_scratch
3380 ;; as this requires two registers in the class R1_REGS when the MEMs for
3381 ;; operands 0 and 1 are both equivalent to symbolic MEMs.  Thus, we are
3382 ;; forced to internally copy operands 0 and 1 to operands 7 and 8,
3383 ;; respectively.  We then split or peephole optimize after reload.
3384 (define_insn "movstrdi_prereload"
3385   [(set (mem:BLK (match_operand:DI 0 "register_operand" "r,r"))
3386         (mem:BLK (match_operand:DI 1 "register_operand" "r,r")))
3387    (clobber (match_operand:DI 2 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3388    (clobber (match_operand:DI 3 "register_operand" "=&r,&r"))   ;item tmp1
3389    (clobber (match_operand:DI 6 "register_operand" "=&r,&r"))   ;item tmp2
3390    (clobber (match_operand:DI 7 "register_operand" "=&r,&r"))   ;item tmp3
3391    (clobber (match_operand:DI 8 "register_operand" "=&r,&r"))   ;item tmp4
3392    (use (match_operand:DI 4 "arith_operand" "J,2"))      ;byte count
3393    (use (match_operand:DI 5 "const_int_operand" "n,n"))] ;alignment
3394   "TARGET_64BIT"
3395   "#"
3396   [(set_attr "type" "multi,multi")])
3397
3398 (define_split
3399   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3400                    (match_operand:BLK 1 "memory_operand" ""))
3401               (clobber (match_operand:DI 2 "register_operand" ""))
3402               (clobber (match_operand:DI 3 "register_operand" ""))
3403               (clobber (match_operand:DI 6 "register_operand" ""))
3404               (clobber (match_operand:DI 7 "register_operand" ""))
3405               (clobber (match_operand:DI 8 "register_operand" ""))
3406               (use (match_operand:DI 4 "arith_operand" ""))
3407               (use (match_operand:DI 5 "const_int_operand" ""))])]
3408   "TARGET_64BIT && reload_completed && !flag_peephole2
3409    && GET_CODE (operands[0]) == MEM
3410    && register_operand (XEXP (operands[0], 0), DImode)
3411    && GET_CODE (operands[1]) == MEM
3412    && register_operand (XEXP (operands[1], 0), DImode)"
3413   [(set (match_dup 7) (match_dup 9))
3414    (set (match_dup 8) (match_dup 10))
3415    (parallel [(set (match_dup 0) (match_dup 1))
3416               (clobber (match_dup 2))
3417               (clobber (match_dup 3))
3418               (clobber (match_dup 6))
3419               (clobber (match_dup 7))
3420               (clobber (match_dup 8))
3421               (use (match_dup 4))
3422               (use (match_dup 5))
3423               (const_int 0)])]
3424   "
3425 {
3426   operands[9] = XEXP (operands[0], 0);
3427   operands[10] = XEXP (operands[1], 0);
3428   operands[0] = replace_equiv_address (operands[0], operands[7]);
3429   operands[1] = replace_equiv_address (operands[1], operands[8]);
3430 }")
3431
3432 (define_peephole2
3433   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3434                    (match_operand:BLK 1 "memory_operand" ""))
3435               (clobber (match_operand:DI 2 "register_operand" ""))
3436               (clobber (match_operand:DI 3 "register_operand" ""))
3437               (clobber (match_operand:DI 6 "register_operand" ""))
3438               (clobber (match_operand:DI 7 "register_operand" ""))
3439               (clobber (match_operand:DI 8 "register_operand" ""))
3440               (use (match_operand:DI 4 "arith_operand" ""))
3441               (use (match_operand:DI 5 "const_int_operand" ""))])]
3442   "TARGET_64BIT
3443    && GET_CODE (operands[0]) == MEM
3444    && register_operand (XEXP (operands[0], 0), DImode)
3445    && GET_CODE (operands[1]) == MEM
3446    && register_operand (XEXP (operands[1], 0), DImode)"
3447   [(parallel [(set (match_dup 0) (match_dup 1))
3448               (clobber (match_dup 2))
3449               (clobber (match_dup 3))
3450               (clobber (match_dup 6))
3451               (clobber (match_dup 7))
3452               (clobber (match_dup 8))
3453               (use (match_dup 4))
3454               (use (match_dup 5))
3455               (const_int 0)])]
3456   "
3457 {
3458   rtx addr = XEXP (operands[0], 0);
3459   if (dead_or_set_p (curr_insn, addr))
3460     operands[7] = addr;
3461   else
3462     {
3463       emit_insn (gen_rtx_SET (VOIDmode, operands[7], addr));
3464       operands[0] = replace_equiv_address (operands[0], operands[7]);
3465     }
3466
3467   addr = XEXP (operands[1], 0);
3468   if (dead_or_set_p (curr_insn, addr))
3469     operands[8] = addr;
3470   else
3471     {
3472       emit_insn (gen_rtx_SET (VOIDmode, operands[8], addr));
3473       operands[1] = replace_equiv_address (operands[1], operands[8]);
3474     }
3475 }")
3476
3477 (define_insn "movstrdi_postreload"
3478   [(set (mem:BLK (match_operand:DI 0 "register_operand" "+r,r"))
3479         (mem:BLK (match_operand:DI 1 "register_operand" "+r,r")))
3480    (clobber (match_operand:DI 2 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3481    (clobber (match_operand:DI 3 "register_operand" "=&r,&r"))   ;item tmp1
3482    (clobber (match_operand:DI 6 "register_operand" "=&r,&r"))   ;item tmp2
3483    (clobber (match_dup 0))
3484    (clobber (match_dup 1))
3485    (use (match_operand:DI 4 "arith_operand" "J,2"))      ;byte count
3486    (use (match_operand:DI 5 "const_int_operand" "n,n"))  ;alignment
3487    (const_int 0)]
3488   "TARGET_64BIT && reload_completed"
3489   "* return output_block_move (operands, !which_alternative);"
3490   [(set_attr "type" "multi,multi")])
3491
3492 (define_expand "clrstrsi"
3493   [(parallel [(set (match_operand:BLK 0 "" "")
3494                    (const_int 0))
3495               (clobber (match_dup 3))
3496               (clobber (match_dup 4))
3497               (use (match_operand:SI 1 "arith_operand" ""))
3498               (use (match_operand:SI 2 "const_int_operand" ""))])]
3499   "!TARGET_64BIT && optimize > 0"
3500   "
3501 {
3502   int size, align;
3503
3504   /* Undetermined size, use the library routine.  */
3505   if (GET_CODE (operands[1]) != CONST_INT)
3506     FAIL;
3507
3508   size = INTVAL (operands[1]);
3509   align = INTVAL (operands[2]);
3510   align = align > 4 ? 4 : align;
3511
3512   /* If size/alignment is large, then use the library routines.  */
3513   if (size / align > 16)
3514     FAIL;
3515
3516   /* This does happen, but not often enough to worry much about.  */
3517   if (size / align < MOVE_RATIO)
3518     FAIL;
3519   
3520   /* Fall through means we're going to use our block clear pattern.  */
3521   operands[0]
3522     = replace_equiv_address (operands[0],
3523                              copy_to_mode_reg (SImode, XEXP (operands[0], 0)));
3524   operands[3] = gen_reg_rtx (SImode);
3525   operands[4] = gen_reg_rtx (SImode);
3526 }")
3527
3528 (define_insn "clrstrsi_prereload"
3529   [(set (mem:BLK (match_operand:SI 0 "register_operand" "r,r"))
3530         (const_int 0))
3531    (clobber (match_operand:SI 1 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3532    (clobber (match_operand:SI 4 "register_operand" "=&r,&r"))   ;tmp1
3533    (use (match_operand:SI 2 "arith_operand" "J,1"))      ;byte count
3534    (use (match_operand:SI 3 "const_int_operand" "n,n"))] ;alignment
3535   "!TARGET_64BIT"
3536   "#"
3537   [(set_attr "type" "multi,multi")])
3538
3539 (define_split
3540   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3541                    (const_int 0))
3542               (clobber (match_operand:SI 1 "register_operand" ""))
3543               (clobber (match_operand:SI 4 "register_operand" ""))
3544               (use (match_operand:SI 2 "arith_operand" ""))
3545               (use (match_operand:SI 3 "const_int_operand" ""))])]
3546   "!TARGET_64BIT && reload_completed && !flag_peephole2
3547    && GET_CODE (operands[0]) == MEM
3548    && register_operand (XEXP (operands[0], 0), SImode)"
3549   [(set (match_dup 4) (match_dup 5))
3550    (parallel [(set (match_dup 0) (const_int 0))
3551               (clobber (match_dup 1))
3552               (clobber (match_dup 4))
3553               (use (match_dup 2))
3554               (use (match_dup 3))
3555               (const_int 0)])]
3556   "
3557 {
3558   operands[5] = XEXP (operands[0], 0);
3559   operands[0] = replace_equiv_address (operands[0], operands[4]);
3560 }")
3561
3562 (define_peephole2
3563   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3564                    (const_int 0))
3565               (clobber (match_operand:SI 1 "register_operand" ""))
3566               (clobber (match_operand:SI 4 "register_operand" ""))
3567               (use (match_operand:SI 2 "arith_operand" ""))
3568               (use (match_operand:SI 3 "const_int_operand" ""))])]
3569   "!TARGET_64BIT
3570    && GET_CODE (operands[0]) == MEM
3571    && register_operand (XEXP (operands[0], 0), SImode)"
3572   [(parallel [(set (match_dup 0) (const_int 0))
3573               (clobber (match_dup 1))
3574               (clobber (match_dup 4))
3575               (use (match_dup 2))
3576               (use (match_dup 3))
3577               (const_int 0)])]
3578   "
3579 {
3580   rtx addr = XEXP (operands[0], 0);
3581   if (dead_or_set_p (curr_insn, addr))
3582     operands[4] = addr;
3583   else
3584     {
3585       emit_insn (gen_rtx_SET (VOIDmode, operands[4], addr));
3586       operands[0] = replace_equiv_address (operands[0], operands[4]);
3587     }
3588 }")
3589
3590 (define_insn "clrstrsi_postreload"
3591   [(set (mem:BLK (match_operand:SI 0 "register_operand" "+r,r"))
3592         (const_int 0))
3593    (clobber (match_operand:SI 1 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3594    (clobber (match_dup 0))
3595    (use (match_operand:SI 2 "arith_operand" "J,1"))      ;byte count
3596    (use (match_operand:SI 3 "const_int_operand" "n,n"))  ;alignment
3597    (const_int 0)]
3598   "!TARGET_64BIT && reload_completed"
3599   "* return output_block_clear (operands, !which_alternative);"
3600   [(set_attr "type" "multi,multi")])
3601
3602 (define_expand "clrstrdi"
3603   [(parallel [(set (match_operand:BLK 0 "" "")
3604                    (const_int 0))
3605               (clobber (match_dup 3))
3606               (clobber (match_dup 4))
3607               (use (match_operand:DI 1 "arith_operand" ""))
3608               (use (match_operand:DI 2 "const_int_operand" ""))])]
3609   "TARGET_64BIT && optimize > 0"
3610   "
3611 {
3612   int size, align;
3613
3614   /* Undetermined size, use the library routine.  */
3615   if (GET_CODE (operands[1]) != CONST_INT)
3616     FAIL;
3617
3618   size = INTVAL (operands[1]);
3619   align = INTVAL (operands[2]);
3620   align = align > 8 ? 8 : align;
3621
3622   /* If size/alignment is large, then use the library routines.  */
3623   if (size / align > 16)
3624     FAIL;
3625
3626   /* This does happen, but not often enough to worry much about.  */
3627   if (size / align < MOVE_RATIO)
3628     FAIL;
3629   
3630   /* Fall through means we're going to use our block clear pattern.  */
3631   operands[0]
3632     = replace_equiv_address (operands[0],
3633                              copy_to_mode_reg (DImode, XEXP (operands[0], 0)));
3634   operands[3] = gen_reg_rtx (DImode);
3635   operands[4] = gen_reg_rtx (DImode);
3636 }")
3637
3638 (define_insn "clrstrdi_prereload"
3639   [(set (mem:BLK (match_operand:DI 0 "register_operand" "r,r"))
3640         (const_int 0))
3641    (clobber (match_operand:DI 1 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3642    (clobber (match_operand:DI 4 "register_operand" "=&r,&r"))   ;item tmp1
3643    (use (match_operand:DI 2 "arith_operand" "J,1"))      ;byte count
3644    (use (match_operand:DI 3 "const_int_operand" "n,n"))] ;alignment
3645   "TARGET_64BIT"
3646   "#"
3647   [(set_attr "type" "multi,multi")])
3648
3649 (define_split
3650   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3651                    (const_int 0))
3652               (clobber (match_operand:DI 1 "register_operand" ""))
3653               (clobber (match_operand:DI 4 "register_operand" ""))
3654               (use (match_operand:DI 2 "arith_operand" ""))
3655               (use (match_operand:DI 3 "const_int_operand" ""))])]
3656   "TARGET_64BIT && reload_completed && !flag_peephole2
3657    && GET_CODE (operands[0]) == MEM
3658    && register_operand (XEXP (operands[0], 0), DImode)"
3659   [(set (match_dup 4) (match_dup 5))
3660    (parallel [(set (match_dup 0) (const_int 0))
3661               (clobber (match_dup 1))
3662               (clobber (match_dup 4))
3663               (use (match_dup 2))
3664               (use (match_dup 3))
3665               (const_int 0)])]
3666   "
3667 {
3668   operands[5] = XEXP (operands[0], 0);
3669   operands[0] = replace_equiv_address (operands[0], operands[4]);
3670 }")
3671
3672 (define_peephole2
3673   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3674                    (const_int 0))
3675               (clobber (match_operand:DI 1 "register_operand" ""))
3676               (clobber (match_operand:DI 4 "register_operand" ""))
3677               (use (match_operand:DI 2 "arith_operand" ""))
3678               (use (match_operand:DI 3 "const_int_operand" ""))])]
3679   "TARGET_64BIT
3680    && GET_CODE (operands[0]) == MEM
3681    && register_operand (XEXP (operands[0], 0), DImode)"
3682   [(parallel [(set (match_dup 0) (const_int 0))
3683               (clobber (match_dup 1))
3684               (clobber (match_dup 4))
3685               (use (match_dup 2))
3686               (use (match_dup 3))
3687               (const_int 0)])]
3688   "
3689 {  
3690   rtx addr = XEXP (operands[0], 0);
3691   if (dead_or_set_p (curr_insn, addr))
3692     operands[4] = addr;
3693   else
3694     {
3695       emit_insn (gen_rtx_SET (VOIDmode, operands[4], addr));
3696       operands[0] = replace_equiv_address (operands[0], operands[4]);
3697     }
3698 }")
3699
3700 (define_insn "clrstrdi_postreload"
3701   [(set (mem:BLK (match_operand:DI 0 "register_operand" "+r,r"))
3702         (const_int 0))
3703    (clobber (match_operand:DI 1 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3704    (clobber (match_dup 0))
3705    (use (match_operand:DI 2 "arith_operand" "J,1"))      ;byte count
3706    (use (match_operand:DI 3 "const_int_operand" "n,n"))  ;alignment
3707    (const_int 0)]
3708   "TARGET_64BIT && reload_completed"
3709   "* return output_block_clear (operands, !which_alternative);"
3710   [(set_attr "type" "multi,multi")])
3711 \f
3712 ;; Floating point move insns
3713
3714 ;; This pattern forces (set (reg:DF ...) (const_double ...))
3715 ;; to be reloaded by putting the constant into memory when
3716 ;; reg is a floating point register.
3717 ;;
3718 ;; For integer registers we use ldil;ldo to set the appropriate
3719 ;; value.
3720 ;;
3721 ;; This must come before the movdf pattern, and it must be present
3722 ;; to handle obscure reloading cases.
3723 (define_insn ""
3724   [(set (match_operand:DF 0 "register_operand" "=?r,f")
3725         (match_operand:DF 1 "" "?F,m"))]
3726   "GET_CODE (operands[1]) == CONST_DOUBLE
3727    && operands[1] != CONST0_RTX (DFmode)
3728    && !TARGET_64BIT
3729    && !TARGET_SOFT_FLOAT"
3730   "* return (which_alternative == 0 ? output_move_double (operands)
3731                                     : \"fldd%F1 %1,%0\");"
3732   [(set_attr "type" "move,fpload")
3733    (set_attr "length" "16,4")])
3734
3735 (define_expand "movdf"
3736   [(set (match_operand:DF 0 "general_operand" "")
3737         (match_operand:DF 1 "general_operand" ""))]
3738   ""
3739   "
3740 {
3741   if (GET_CODE (operands[1]) == CONST_DOUBLE && TARGET_64BIT)
3742     operands[1] = force_const_mem (DFmode, operands[1]);
3743
3744   if (emit_move_sequence (operands, DFmode, 0))
3745     DONE;
3746 }")
3747
3748 ;; Reloading an SImode or DImode value requires a scratch register if
3749 ;; going in to or out of float point registers.
3750
3751 (define_expand "reload_indf"
3752   [(set (match_operand:DF 0 "register_operand" "=Z")
3753         (match_operand:DF 1 "non_hard_reg_operand" ""))
3754    (clobber (match_operand:DF 2 "register_operand" "=&r"))]
3755   ""
3756   "
3757 {
3758   if (emit_move_sequence (operands, DFmode, operands[2]))
3759     DONE;
3760
3761   /* We don't want the clobber emitted, so handle this ourselves.  */
3762   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
3763   DONE;
3764 }")
3765
3766 (define_expand "reload_outdf" 
3767  [(set (match_operand:DF 0 "non_hard_reg_operand" "")
3768         (match_operand:DF 1  "register_operand" "Z"))
3769    (clobber (match_operand:DF 2 "register_operand" "=&r"))]
3770   ""
3771   "
3772 {
3773   if (emit_move_sequence (operands, DFmode, operands[2]))
3774     DONE;
3775
3776   /* We don't want the clobber emitted, so handle this ourselves.  */
3777   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
3778   DONE;
3779 }")
3780
3781 (define_insn ""
3782   [(set (match_operand:DF 0 "move_dest_operand"
3783                           "=f,*r,Q,?o,?Q,f,*r,*r")
3784         (match_operand:DF 1 "reg_or_0_or_nonsymb_mem_operand"
3785                           "fG,*rG,f,*r,*r,RQ,o,RQ"))]
3786   "(register_operand (operands[0], DFmode)
3787     || reg_or_0_operand (operands[1], DFmode))
3788    && !(GET_CODE (operands[1]) == CONST_DOUBLE
3789         && GET_CODE (operands[0]) == MEM)
3790    && !TARGET_64BIT
3791    && !TARGET_SOFT_FLOAT"
3792   "*
3793 {
3794   if (FP_REG_P (operands[0]) || FP_REG_P (operands[1])
3795       || operands[1] == CONST0_RTX (DFmode))
3796     return output_fp_move_double (operands);
3797   return output_move_double (operands);
3798 }"
3799   [(set_attr "type" "fpalu,move,fpstore,store,store,fpload,load,load")
3800    (set_attr "length" "4,8,4,8,16,4,8,16")])
3801
3802 (define_insn ""
3803   [(set (match_operand:DF 0 "indexed_memory_operand" "=R")
3804         (match_operand:DF 1 "reg_or_0_operand" "f"))]
3805   "!TARGET_SOFT_FLOAT
3806    && !TARGET_DISABLE_INDEXING
3807    && reload_completed"
3808   "fstd%F0 %1,%0"
3809   [(set_attr "type" "fpstore")
3810    (set_attr "pa_combine_type" "addmove")
3811    (set_attr "length" "4")])
3812
3813 (define_peephole2
3814   [(set (match_operand:SI 0 "register_operand" "")
3815         (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "")
3816                           (const_int 8))
3817                  (match_operand:SI 2 "register_operand" "")))
3818    (set (mem:DF (match_dup 0))
3819         (match_operand:DF 3 "register_operand" ""))]
3820   "!TARGET_SOFT_FLOAT
3821    && REG_OK_FOR_BASE_P (operands[2])
3822    && FP_REGNO_P (REGNO (operands[3]))"
3823   [(set (mem:DF (plus:SI (mult:SI (match_dup 1) (const_int 8)) (match_dup 2)))
3824         (match_dup 3))
3825    (set (match_dup 0) (plus:SI (mult:SI (match_dup 1) (const_int 8))
3826                                (match_dup 2)))]
3827   "")
3828
3829 (define_peephole2
3830   [(set (match_operand:SI 0 "register_operand" "")
3831         (plus:SI (match_operand:SI 2 "register_operand" "")
3832                  (mult:SI (match_operand:SI 1 "register_operand" "")
3833                           (const_int 8))))
3834    (set (mem:DF (match_dup 0))
3835         (match_operand:DF 3 "register_operand" ""))]
3836   "!TARGET_SOFT_FLOAT
3837    && REG_OK_FOR_BASE_P (operands[2])
3838    && FP_REGNO_P (REGNO (operands[3]))"
3839   [(set (mem:DF (plus:SI (mult:SI (match_dup 1) (const_int 8)) (match_dup 2)))
3840         (match_dup 3))
3841    (set (match_dup 0) (plus:SI (mult:SI (match_dup 1) (const_int 8))
3842                                (match_dup 2)))]
3843   "")
3844
3845 (define_peephole2
3846   [(set (match_operand:DI 0 "register_operand" "")
3847         (plus:DI (mult:DI (match_operand:DI 1 "register_operand" "")
3848                           (const_int 8))
3849                  (match_operand:DI 2 "register_operand" "")))
3850    (set (mem:DF (match_dup 0))
3851         (match_operand:DF 3 "register_operand" ""))]
3852   "!TARGET_SOFT_FLOAT
3853    && TARGET_64BIT
3854    && REG_OK_FOR_BASE_P (operands[2])
3855    && FP_REGNO_P (REGNO (operands[3]))"
3856   [(set (mem:DF (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
3857         (match_dup 3))
3858    (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 8))
3859                                (match_dup 2)))]
3860   "")
3861
3862 (define_peephole2
3863   [(set (match_operand:DI 0 "register_operand" "")
3864         (plus:DI (match_operand:DI 2 "register_operand" "")
3865                  (mult:DI (match_operand:DI 1 "register_operand" "")
3866                           (const_int 8))))
3867    (set (mem:DF (match_dup 0))
3868         (match_operand:DF 3 "register_operand" ""))]
3869   "!TARGET_SOFT_FLOAT
3870    && TARGET_64BIT
3871    && REG_OK_FOR_BASE_P (operands[2])
3872    && FP_REGNO_P (REGNO (operands[3]))"
3873   [(set (mem:DF (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
3874         (match_dup 3))
3875    (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 8))
3876                                (match_dup 2)))]
3877   "")
3878
3879 (define_peephole2
3880   [(set (match_operand:SI 0 "register_operand" "")
3881         (plus:SI (match_operand:SI 1 "register_operand" "")
3882                  (match_operand:SI 2 "register_operand" "")))
3883    (set (mem:DF (match_dup 0))
3884         (match_operand:DF 3 "register_operand" ""))]
3885   "!TARGET_SOFT_FLOAT
3886    && REG_OK_FOR_BASE_P (operands[1])
3887    && (TARGET_NO_SPACE_REGS
3888        || (!REG_POINTER (operands[1]) && REG_POINTER (operands[2])))
3889    && FP_REGNO_P (REGNO (operands[3]))"
3890   [(set (mem:DF (plus:SI (match_dup 1) (match_dup 2)))
3891         (match_dup 3))
3892    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
3893   "")
3894
3895 (define_peephole2
3896   [(set (match_operand:SI 0 "register_operand" "")
3897         (plus:SI (match_operand:SI 1 "register_operand" "")
3898                  (match_operand:SI 2 "register_operand" "")))
3899    (set (mem:DF (match_dup 0))
3900         (match_operand:DF 3 "register_operand" ""))]
3901   "!TARGET_SOFT_FLOAT
3902    && REG_OK_FOR_BASE_P (operands[2])
3903    && (TARGET_NO_SPACE_REGS
3904        || (REG_POINTER (operands[1]) && !REG_POINTER (operands[2])))
3905    && FP_REGNO_P (REGNO (operands[3]))"
3906   [(set (mem:DF (plus:SI (match_dup 2) (match_dup 1)))
3907         (match_dup 3))
3908    (set (match_dup 0) (plus:SI (match_dup 2) (match_dup 1)))]
3909   "")
3910
3911 (define_peephole2
3912   [(set (match_operand:DI 0 "register_operand" "")
3913         (plus:DI (match_operand:DI 1 "register_operand" "")
3914                  (match_operand:DI 2 "register_operand" "")))
3915    (set (mem:DF (match_dup 0))
3916         (match_operand:DF 3 "register_operand" ""))]
3917   "!TARGET_SOFT_FLOAT
3918    && TARGET_64BIT
3919    && REG_OK_FOR_BASE_P (operands[1])
3920    && (TARGET_NO_SPACE_REGS
3921        || (!REG_POINTER (operands[1]) && REG_POINTER (operands[2])))
3922    && FP_REGNO_P (REGNO (operands[3]))"
3923   [(set (mem:DF (plus:DI (match_dup 1) (match_dup 2)))
3924         (match_dup 3))
3925    (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
3926   "")
3927
3928 (define_peephole2
3929   [(set (match_operand:DI 0 "register_operand" "")
3930         (plus:DI (match_operand:DI 1 "register_operand" "")
3931                  (match_operand:DI 2 "register_operand" "")))
3932    (set (mem:DF (match_dup 0))
3933         (match_operand:DF 3 "register_operand" ""))]
3934   "!TARGET_SOFT_FLOAT
3935    && TARGET_64BIT
3936    && REG_OK_FOR_BASE_P (operands[2])
3937    && (TARGET_NO_SPACE_REGS
3938        || (REG_POINTER (operands[1]) && !REG_POINTER (operands[2])))
3939    && FP_REGNO_P (REGNO (operands[3]))"
3940   [(set (mem:DF (plus:DI (match_dup 2) (match_dup 1)))
3941         (match_dup 3))
3942    (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
3943   "")
3944
3945 (define_insn ""
3946   [(set (match_operand:DF 0 "move_dest_operand"
3947                           "=r,?o,?Q,r,r")
3948         (match_operand:DF 1 "reg_or_0_or_nonsymb_mem_operand"
3949                           "rG,r,r,o,RQ"))]
3950   "(register_operand (operands[0], DFmode)
3951     || reg_or_0_operand (operands[1], DFmode))
3952    && !TARGET_64BIT
3953    && TARGET_SOFT_FLOAT"
3954   "*
3955 {
3956   return output_move_double (operands);
3957 }"
3958   [(set_attr "type" "move,store,store,load,load")
3959    (set_attr "length" "8,8,16,8,16")])
3960
3961 (define_insn ""
3962   [(set (match_operand:DF 0 "move_dest_operand"
3963                           "=!*r,*r,*r,*r,*r,Q,f,f,T")
3964         (match_operand:DF 1 "move_src_operand"
3965                           "!*r,J,N,K,RQ,*rM,fM,RT,f"))]
3966   "(register_operand (operands[0], DFmode)
3967     || reg_or_0_operand (operands[1], DFmode))
3968    && !TARGET_SOFT_FLOAT && TARGET_64BIT"
3969   "@
3970    copy %1,%0
3971    ldi %1,%0
3972    ldil L'%1,%0
3973    depdi,z %z1,%0
3974    ldd%M1 %1,%0
3975    std%M0 %r1,%0
3976    fcpy,dbl %f1,%0
3977    fldd%F1 %1,%0
3978    fstd%F0 %1,%0"
3979   [(set_attr "type" "move,move,move,shift,load,store,fpalu,fpload,fpstore")
3980    (set_attr "pa_combine_type" "addmove")
3981    (set_attr "length" "4,4,4,4,4,4,4,4,4")])
3982
3983 \f
3984 (define_expand "movdi"
3985   [(set (match_operand:DI 0 "general_operand" "")
3986         (match_operand:DI 1 "general_operand" ""))]
3987   ""
3988   "
3989 {
3990   if (GET_CODE (operands[1]) == CONST_DOUBLE && TARGET_64BIT)
3991     operands[1] = force_const_mem (DImode, operands[1]);
3992
3993   if (emit_move_sequence (operands, DImode, 0))
3994     DONE;
3995 }")
3996
3997 (define_expand "reload_indi"
3998   [(set (match_operand:DI 0 "register_operand" "=Z")
3999         (match_operand:DI 1 "non_hard_reg_operand" ""))
4000    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
4001   ""
4002   "
4003 {
4004   if (emit_move_sequence (operands, DImode, operands[2]))
4005     DONE;
4006
4007   /* We don't want the clobber emitted, so handle this ourselves.  */
4008   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
4009   DONE;
4010 }")
4011
4012 (define_expand "reload_outdi"
4013   [(set (match_operand:DI 0 "non_hard_reg_operand" "")
4014         (match_operand:DI 1 "register_operand" "Z"))
4015    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
4016   ""
4017   "
4018 {
4019   if (emit_move_sequence (operands, DImode, operands[2]))
4020     DONE;
4021
4022   /* We don't want the clobber emitted, so handle this ourselves.  */
4023   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
4024   DONE;
4025 }")
4026
4027 (define_insn ""
4028   [(set (match_operand:DI 0 "register_operand" "=r")
4029         (high:DI (match_operand 1 "" "")))]
4030   "!TARGET_64BIT"
4031   "*
4032 {
4033   rtx op0 = operands[0];
4034   rtx op1 = operands[1];
4035
4036   if (GET_CODE (op1) == CONST_INT)
4037     {
4038       operands[0] = operand_subword (op0, 1, 0, DImode);
4039       output_asm_insn (\"ldil L'%1,%0\", operands);
4040
4041       operands[0] = operand_subword (op0, 0, 0, DImode);
4042       if (INTVAL (op1) < 0)
4043         output_asm_insn (\"ldi -1,%0\", operands);
4044       else
4045         output_asm_insn (\"ldi 0,%0\", operands);
4046       return \"\";
4047     }
4048   else if (GET_CODE (op1) == CONST_DOUBLE)
4049     {
4050       operands[0] = operand_subword (op0, 1, 0, DImode);
4051       operands[1] = GEN_INT (CONST_DOUBLE_LOW (op1));
4052       output_asm_insn (\"ldil L'%1,%0\", operands);
4053
4054       operands[0] = operand_subword (op0, 0, 0, DImode);
4055       operands[1] = GEN_INT (CONST_DOUBLE_HIGH (op1));
4056       output_asm_insn (singlemove_string (operands), operands);
4057       return \"\";
4058     }
4059   else
4060     abort ();
4061 }"
4062   [(set_attr "type" "move")
4063    (set_attr "length" "8")])
4064
4065 (define_insn ""
4066   [(set (match_operand:DI 0 "move_dest_operand"
4067                           "=r,o,Q,r,r,r,*f,*f,T")
4068         (match_operand:DI 1 "general_operand"
4069                           "rM,r,r,o*R,Q,i,*fM,RT,*f"))]
4070   "(register_operand (operands[0], DImode)
4071     || reg_or_0_operand (operands[1], DImode))
4072    && !TARGET_64BIT
4073    && !TARGET_SOFT_FLOAT"
4074   "*
4075 {
4076   if (FP_REG_P (operands[0]) || FP_REG_P (operands[1])
4077       || (operands[1] == CONST0_RTX (DImode)))
4078     return output_fp_move_double (operands);
4079   return output_move_double (operands);
4080 }"
4081   [(set_attr "type" "move,store,store,load,load,multi,fpalu,fpload,fpstore")
4082    (set_attr "length" "8,8,16,8,16,16,4,4,4")])
4083
4084 (define_insn ""
4085   [(set (match_operand:DI 0 "move_dest_operand"
4086                           "=r,r,r,r,r,r,Q,!*q,!r,!*f,*f,T")
4087         (match_operand:DI 1 "move_src_operand"
4088                           "A,r,J,N,K,RQ,rM,!rM,!*q,!*fM,RT,*f"))]
4089   "(register_operand (operands[0], DImode)
4090     || reg_or_0_operand (operands[1], DImode))
4091    && !TARGET_SOFT_FLOAT && TARGET_64BIT"
4092   "@
4093    ldd RT'%A1,%0
4094    copy %1,%0
4095    ldi %1,%0
4096    ldil L'%1,%0
4097    depdi,z %z1,%0
4098    ldd%M1 %1,%0
4099    std%M0 %r1,%0
4100    mtsar %r1
4101    {mfctl|mfctl,w} %%sar,%0
4102    fcpy,dbl %f1,%0
4103    fldd%F1 %1,%0
4104    fstd%F0 %1,%0"
4105   [(set_attr "type" "load,move,move,move,shift,load,store,move,move,fpalu,fpload,fpstore")
4106    (set_attr "pa_combine_type" "addmove")
4107    (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4")])
4108
4109 (define_insn ""
4110   [(set (match_operand:DI 0 "indexed_memory_operand" "=R")
4111         (match_operand:DI 1 "register_operand" "f"))]
4112   "!TARGET_SOFT_FLOAT
4113    && TARGET_64BIT
4114    && !TARGET_DISABLE_INDEXING
4115    && reload_completed"
4116   "fstd%F0 %1,%0"
4117   [(set_attr "type" "fpstore")
4118    (set_attr "pa_combine_type" "addmove")
4119    (set_attr "length" "4")])
4120
4121 (define_peephole2
4122   [(set (match_operand:DI 0 "register_operand" "")
4123         (plus:DI (mult:DI (match_operand:DI 1 "register_operand" "")
4124                           (const_int 8))
4125                  (match_operand:DI 2 "register_operand" "")))
4126    (set (mem:DI (match_dup 0))
4127         (match_operand:DI 3 "register_operand" ""))]
4128   "!TARGET_SOFT_FLOAT
4129    && TARGET_64BIT
4130    && REG_OK_FOR_BASE_P (operands[2])
4131    && FP_REGNO_P (REGNO (operands[3]))"
4132   [(set (mem:DI (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
4133         (match_dup 3))
4134    (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 8))
4135                                (match_dup 2)))]
4136   "")
4137
4138 (define_peephole2
4139   [(set (match_operand:DI 0 "register_operand" "")
4140         (plus:DI (match_operand:DI 2 "register_operand" "")
4141                  (mult:DI (match_operand:DI 1 "register_operand" "")
4142                           (const_int 8))))
4143    (set (mem:DI (match_dup 0))
4144         (match_operand:DI 3 "register_operand" ""))]
4145   "!TARGET_SOFT_FLOAT
4146    && TARGET_64BIT
4147    && REG_OK_FOR_BASE_P (operands[2])
4148    && FP_REGNO_P (REGNO (operands[3]))"
4149   [(set (mem:DI (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
4150         (match_dup 3))
4151    (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 8))
4152                                (match_dup 2)))]
4153   "")
4154
4155 (define_peephole2
4156   [(set (match_operand:DI 0 "register_operand" "")
4157         (plus:DI (match_operand:DI 1 "register_operand" "")
4158                  (match_operand:DI 2 "register_operand" "")))
4159    (set (mem:DI (match_dup 0))
4160         (match_operand:DI 3 "register_operand" ""))]
4161   "!TARGET_SOFT_FLOAT
4162    && TARGET_64BIT
4163    && REG_OK_FOR_BASE_P (operands[1])
4164    && (TARGET_NO_SPACE_REGS
4165        || (!REG_POINTER (operands[1]) && REG_POINTER (operands[2])))
4166    && FP_REGNO_P (REGNO (operands[3]))"
4167   [(set (mem:DI (plus:DI (match_dup 1) (match_dup 2)))
4168         (match_dup 3))
4169    (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
4170   "")
4171
4172 (define_peephole2
4173   [(set (match_operand:DI 0 "register_operand" "")
4174         (plus:DI (match_operand:DI 1 "register_operand" "")
4175                  (match_operand:DI 2 "register_operand" "")))
4176    (set (mem:DI (match_dup 0))
4177         (match_operand:DI 3 "register_operand" ""))]
4178   "!TARGET_SOFT_FLOAT
4179    && TARGET_64BIT
4180    && REG_OK_FOR_BASE_P (operands[2])
4181    && (TARGET_NO_SPACE_REGS
4182        || (REG_POINTER (operands[1]) && !REG_POINTER (operands[2])))
4183    && FP_REGNO_P (REGNO (operands[3]))"
4184   [(set (mem:DI (plus:DI (match_dup 2) (match_dup 1)))
4185         (match_dup 3))
4186    (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
4187   "")
4188
4189 (define_insn ""
4190   [(set (match_operand:DI 0 "move_dest_operand"
4191                           "=r,o,Q,r,r,r")
4192         (match_operand:DI 1 "general_operand"
4193                           "rM,r,r,o,Q,i"))]
4194   "(register_operand (operands[0], DImode)
4195     || reg_or_0_operand (operands[1], DImode))
4196    && !TARGET_64BIT
4197    && TARGET_SOFT_FLOAT"
4198   "*
4199 {
4200   return output_move_double (operands);
4201 }"
4202   [(set_attr "type" "move,store,store,load,load,multi")
4203    (set_attr "length" "8,8,16,8,16,16")])
4204
4205 (define_insn ""
4206   [(set (match_operand:DI 0 "register_operand" "=r,&r")
4207         (lo_sum:DI (match_operand:DI 1 "register_operand" "0,r")
4208                    (match_operand:DI 2 "immediate_operand" "i,i")))]
4209   "!TARGET_64BIT"
4210   "*
4211 {
4212   /* Don't output a 64 bit constant, since we can't trust the assembler to
4213      handle it correctly.  */
4214   if (GET_CODE (operands[2]) == CONST_DOUBLE)
4215     operands[2] = GEN_INT (CONST_DOUBLE_LOW (operands[2]));
4216   if (which_alternative == 1)
4217     output_asm_insn (\"copy %1,%0\", operands);
4218   return \"ldo R'%G2(%R1),%R0\";
4219 }"
4220   [(set_attr "type" "move,move")
4221    (set_attr "length" "4,8")])
4222
4223 ;; This pattern forces (set (reg:SF ...) (const_double ...))
4224 ;; to be reloaded by putting the constant into memory when
4225 ;; reg is a floating point register.
4226 ;;
4227 ;; For integer registers we use ldil;ldo to set the appropriate
4228 ;; value.
4229 ;;
4230 ;; This must come before the movsf pattern, and it must be present
4231 ;; to handle obscure reloading cases.
4232 (define_insn ""
4233   [(set (match_operand:SF 0 "register_operand" "=?r,f")
4234         (match_operand:SF 1 "" "?F,m"))]
4235   "GET_CODE (operands[1]) == CONST_DOUBLE
4236    && operands[1] != CONST0_RTX (SFmode)
4237    && ! TARGET_SOFT_FLOAT"
4238   "* return (which_alternative == 0 ? singlemove_string (operands)
4239                                     : \" fldw%F1 %1,%0\");"
4240   [(set_attr "type" "move,fpload")
4241    (set_attr "length" "8,4")])
4242
4243 (define_expand "movsf"
4244   [(set (match_operand:SF 0 "general_operand" "")
4245         (match_operand:SF 1 "general_operand" ""))]
4246   ""
4247   "
4248 {
4249   if (emit_move_sequence (operands, SFmode, 0))
4250     DONE;
4251 }")
4252
4253 ;; Reloading an SImode or DImode value requires a scratch register if
4254 ;; going in to or out of float point registers.
4255
4256 (define_expand "reload_insf"
4257   [(set (match_operand:SF 0 "register_operand" "=Z")
4258         (match_operand:SF 1 "non_hard_reg_operand" ""))
4259    (clobber (match_operand:SF 2 "register_operand" "=&r"))]
4260   ""
4261   "
4262 {
4263   if (emit_move_sequence (operands, SFmode, operands[2]))
4264     DONE;
4265
4266   /* We don't want the clobber emitted, so handle this ourselves.  */
4267   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
4268   DONE;
4269 }")
4270
4271 (define_expand "reload_outsf"
4272   [(set (match_operand:SF 0 "non_hard_reg_operand" "")
4273         (match_operand:SF 1  "register_operand" "Z"))
4274    (clobber (match_operand:SF 2 "register_operand" "=&r"))]
4275   ""
4276   "
4277 {
4278   if (emit_move_sequence (operands, SFmode, operands[2]))
4279     DONE;
4280
4281   /* We don't want the clobber emitted, so handle this ourselves.  */
4282   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
4283   DONE;
4284 }")
4285
4286 (define_insn ""
4287   [(set (match_operand:SF 0 "move_dest_operand"
4288                           "=f,!*r,f,*r,Q,Q")
4289         (match_operand:SF 1 "reg_or_0_or_nonsymb_mem_operand"
4290                           "fG,!*rG,RQ,RQ,f,*rG"))]
4291   "(register_operand (operands[0], SFmode)
4292     || reg_or_0_operand (operands[1], SFmode))
4293    && !TARGET_SOFT_FLOAT"
4294   "@
4295    fcpy,sgl %f1,%0
4296    copy %r1,%0
4297    fldw%F1 %1,%0
4298    ldw%M1 %1,%0
4299    fstw%F0 %1,%0
4300    stw%M0 %r1,%0"
4301   [(set_attr "type" "fpalu,move,fpload,load,fpstore,store")
4302    (set_attr "pa_combine_type" "addmove")
4303    (set_attr "length" "4,4,4,4,4,4")])
4304
4305 (define_insn ""
4306   [(set (match_operand:SF 0 "indexed_memory_operand" "=R")
4307         (match_operand:SF 1 "register_operand" "f"))]
4308   "!TARGET_SOFT_FLOAT
4309    && !TARGET_DISABLE_INDEXING
4310    && reload_completed"
4311   "fstw%F0 %1,%0"
4312   [(set_attr "type" "fpstore")
4313    (set_attr "pa_combine_type" "addmove")
4314    (set_attr "length" "4")])
4315
4316 (define_peephole2
4317   [(set (match_operand:SI 0 "register_operand" "")
4318         (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "")
4319                           (const_int 4))
4320                  (match_operand:SI 2 "register_operand" "")))
4321    (set (mem:SF (match_dup 0))
4322         (match_operand:SF 3 "register_operand" ""))]
4323   "!TARGET_SOFT_FLOAT
4324    && REG_OK_FOR_BASE_P (operands[2])
4325    && FP_REGNO_P (REGNO (operands[3]))"
4326   [(set (mem:SF (plus:SI (mult:SI (match_dup 1) (const_int 4)) (match_dup 2)))
4327         (match_dup 3))
4328    (set (match_dup 0) (plus:SI (mult:SI (match_dup 1) (const_int 4))
4329                                (match_dup 2)))]
4330   "")
4331
4332 (define_peephole2
4333   [(set (match_operand:SI 0 "register_operand" "")
4334         (plus:SI (match_operand:SI 2 "register_operand" "")
4335                  (mult:SI (match_operand:SI 1 "register_operand" "")
4336                           (const_int 4))))
4337    (set (mem:SF (match_dup 0))
4338         (match_operand:SF 3 "register_operand" ""))]
4339   "!TARGET_SOFT_FLOAT
4340    && REG_OK_FOR_BASE_P (operands[2])
4341    && FP_REGNO_P (REGNO (operands[3]))"
4342   [(set (mem:SF (plus:SI (mult:SI (match_dup 1) (const_int 4)) (match_dup 2)))
4343         (match_dup 3))
4344    (set (match_dup 0) (plus:SI (mult:SI (match_dup 1) (const_int 4))
4345                                (match_dup 2)))]
4346   "")
4347
4348 (define_peephole2
4349   [(set (match_operand:DI 0 "register_operand" "")
4350         (plus:DI (mult:DI (match_operand:DI 1 "register_operand" "")
4351                           (const_int 4))
4352                  (match_operand:DI 2 "register_operand" "")))
4353    (set (mem:SF (match_dup 0))
4354         (match_operand:SF 3 "register_operand" ""))]
4355   "!TARGET_SOFT_FLOAT
4356    && TARGET_64BIT
4357    && REG_OK_FOR_BASE_P (operands[2])
4358    && FP_REGNO_P (REGNO (operands[3]))"
4359   [(set (mem:SF (plus:DI (mult:DI (match_dup 1) (const_int 4)) (match_dup 2)))
4360         (match_dup 3))
4361    (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 4))
4362                                (match_dup 2)))]
4363   "")
4364
4365 (define_peephole2
4366   [(set (match_operand:DI 0 "register_operand" "")
4367         (plus:DI (match_operand:DI 2 "register_operand" "")
4368                  (mult:DI (match_operand:DI 1 "register_operand" "")
4369                           (const_int 4))))
4370    (set (mem:SF (match_dup 0))
4371         (match_operand:SF 3 "register_operand" ""))]
4372   "!TARGET_SOFT_FLOAT
4373    && TARGET_64BIT
4374    && REG_OK_FOR_BASE_P (operands[2])
4375    && FP_REGNO_P (REGNO (operands[3]))"
4376   [(set (mem:SF (plus:DI (mult:DI (match_dup 1) (const_int 4)) (match_dup 2)))
4377         (match_dup 3))
4378    (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 4))
4379                                (match_dup 2)))]
4380   "")
4381
4382 (define_peephole2
4383   [(set (match_operand:SI 0 "register_operand" "")
4384         (plus:SI (match_operand:SI 1 "register_operand" "")
4385                  (match_operand:SI 2 "register_operand" "")))
4386    (set (mem:SF (match_dup 0))
4387         (match_operand:SF 3 "register_operand" ""))]
4388   "!TARGET_SOFT_FLOAT
4389    && REG_OK_FOR_BASE_P (operands[1])
4390    && (TARGET_NO_SPACE_REGS
4391        || (!REG_POINTER (operands[1]) && REG_POINTER (operands[2])))
4392    && FP_REGNO_P (REGNO (operands[3]))"
4393   [(set (mem:SF (plus:SI (match_dup 1) (match_dup 2)))
4394         (match_dup 3))
4395    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
4396   "")
4397
4398 (define_peephole2
4399   [(set (match_operand:SI 0 "register_operand" "")
4400         (plus:SI (match_operand:SI 1 "register_operand" "")
4401                  (match_operand:SI 2 "register_operand" "")))
4402    (set (mem:SF (match_dup 0))
4403         (match_operand:SF 3 "register_operand" ""))]
4404   "!TARGET_SOFT_FLOAT
4405    && REG_OK_FOR_BASE_P (operands[2])
4406    && (TARGET_NO_SPACE_REGS
4407        || (REG_POINTER (operands[1]) && !REG_POINTER (operands[2])))
4408    && FP_REGNO_P (REGNO (operands[3]))"
4409   [(set (mem:SF (plus:SI (match_dup 2) (match_dup 1)))
4410         (match_dup 3))
4411    (set (match_dup 0) (plus:SI (match_dup 2) (match_dup 1)))]
4412   "")
4413
4414 (define_peephole2
4415   [(set (match_operand:DI 0 "register_operand" "")
4416         (plus:DI (match_operand:DI 1 "register_operand" "")
4417                  (match_operand:DI 2 "register_operand" "")))
4418    (set (mem:SF (match_dup 0))
4419         (match_operand:SF 3 "register_operand" ""))]
4420   "!TARGET_SOFT_FLOAT
4421    && TARGET_64BIT
4422    && REG_OK_FOR_BASE_P (operands[1])
4423    && (TARGET_NO_SPACE_REGS
4424        || (!REG_POINTER (operands[1]) && REG_POINTER (operands[2])))
4425    && FP_REGNO_P (REGNO (operands[3]))"
4426   [(set (mem:SF (plus:DI (match_dup 1) (match_dup 2)))
4427         (match_dup 3))
4428    (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
4429   "")
4430
4431 (define_peephole2
4432   [(set (match_operand:DI 0 "register_operand" "")
4433         (plus:DI (match_operand:DI 1 "register_operand" "")
4434                  (match_operand:DI 2 "register_operand" "")))
4435    (set (mem:SF (match_dup 0))
4436         (match_operand:SF 3 "register_operand" ""))]
4437   "!TARGET_SOFT_FLOAT
4438    && TARGET_64BIT
4439    && REG_OK_FOR_BASE_P (operands[2])
4440    && (TARGET_NO_SPACE_REGS
4441        || (REG_POINTER (operands[1]) && !REG_POINTER (operands[2])))
4442    && FP_REGNO_P (REGNO (operands[3]))"
4443   [(set (mem:SF (plus:DI (match_dup 2) (match_dup 1)))
4444         (match_dup 3))
4445    (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
4446   "")
4447
4448 (define_insn ""
4449   [(set (match_operand:SF 0 "move_dest_operand"
4450                           "=r,r,Q")
4451         (match_operand:SF 1 "reg_or_0_or_nonsymb_mem_operand"
4452                           "rG,RQ,rG"))]
4453   "(register_operand (operands[0], SFmode)
4454     || reg_or_0_operand (operands[1], SFmode))
4455    && TARGET_SOFT_FLOAT"
4456   "@
4457    copy %r1,%0
4458    ldw%M1 %1,%0
4459    stw%M0 %r1,%0"
4460   [(set_attr "type" "move,load,store")
4461    (set_attr "pa_combine_type" "addmove")
4462    (set_attr "length" "4,4,4")])
4463
4464 \f
4465
4466 ;;- zero extension instructions
4467 ;; We have define_expand for zero extension patterns to make sure the
4468 ;; operands get loaded into registers.  The define_insns accept
4469 ;; memory operands.  This gives us better overall code than just
4470 ;; having a pattern that does or does not accept memory operands.
4471
4472 (define_expand "zero_extendqihi2"
4473   [(set (match_operand:HI 0 "register_operand" "")
4474         (zero_extend:HI
4475          (match_operand:QI 1 "register_operand" "")))]
4476   ""
4477   "")
4478
4479 (define_insn ""
4480   [(set (match_operand:HI 0 "register_operand" "=r,r")
4481         (zero_extend:HI
4482          (match_operand:QI 1 "move_src_operand" "r,RQ")))]
4483   "GET_CODE (operands[1]) != CONST_INT"
4484   "@
4485    {extru|extrw,u} %1,31,8,%0
4486    ldb%M1 %1,%0"
4487   [(set_attr "type" "shift,load")
4488    (set_attr "length" "4,4")])
4489
4490 (define_expand "zero_extendqisi2"
4491   [(set (match_operand:SI 0 "register_operand" "")
4492         (zero_extend:SI
4493          (match_operand:QI 1 "register_operand" "")))]
4494   ""
4495   "")
4496
4497 (define_insn ""
4498   [(set (match_operand:SI 0 "register_operand" "=r,r")
4499         (zero_extend:SI
4500          (match_operand:QI 1 "move_src_operand" "r,RQ")))]
4501   "GET_CODE (operands[1]) != CONST_INT"
4502   "@
4503    {extru|extrw,u} %1,31,8,%0
4504    ldb%M1 %1,%0"
4505   [(set_attr "type" "shift,load")
4506    (set_attr "length" "4,4")])
4507
4508 (define_expand "zero_extendhisi2"
4509   [(set (match_operand:SI 0 "register_operand" "")
4510         (zero_extend:SI
4511          (match_operand:HI 1 "register_operand" "")))]
4512   ""
4513   "")
4514
4515 (define_insn ""
4516   [(set (match_operand:SI 0 "register_operand" "=r,r")
4517         (zero_extend:SI
4518          (match_operand:HI 1 "move_src_operand" "r,RQ")))]
4519   "GET_CODE (operands[1]) != CONST_INT"
4520   "@
4521    {extru|extrw,u} %1,31,16,%0
4522    ldh%M1 %1,%0"
4523   [(set_attr "type" "shift,load")
4524    (set_attr "length" "4,4")])
4525
4526 (define_expand "zero_extendqidi2"
4527   [(set (match_operand:DI 0 "register_operand" "")
4528         (zero_extend:DI
4529          (match_operand:QI 1 "register_operand" "")))]
4530   "TARGET_64BIT"
4531   "")
4532
4533 (define_insn ""
4534   [(set (match_operand:DI 0 "register_operand" "=r,r")
4535         (zero_extend:DI
4536          (match_operand:QI 1 "move_src_operand" "r,RQ")))]
4537   "TARGET_64BIT && GET_CODE (operands[1]) != CONST_INT"
4538   "@
4539    extrd,u %1,63,8,%0
4540    ldb%M1 %1,%0"
4541   [(set_attr "type" "shift,load")
4542    (set_attr "length" "4,4")])
4543
4544 (define_expand "zero_extendhidi2"
4545   [(set (match_operand:DI 0 "register_operand" "")
4546         (zero_extend:DI
4547          (match_operand:HI 1 "register_operand" "")))]
4548   "TARGET_64BIT"
4549   "")
4550
4551 (define_insn ""
4552   [(set (match_operand:DI 0 "register_operand" "=r,r")
4553         (zero_extend:DI
4554          (match_operand:HI 1 "move_src_operand" "r,RQ")))]
4555   "TARGET_64BIT && GET_CODE (operands[1]) != CONST_INT"
4556   "@
4557    extrd,u %1,63,16,%0
4558    ldh%M1 %1,%0"
4559   [(set_attr "type" "shift,load")
4560    (set_attr "length" "4,4")])
4561
4562 (define_expand "zero_extendsidi2"
4563   [(set (match_operand:DI 0 "register_operand" "")
4564         (zero_extend:DI
4565          (match_operand:SI 1 "register_operand" "")))]
4566   "TARGET_64BIT"
4567   "")
4568
4569 (define_insn ""
4570   [(set (match_operand:DI 0 "register_operand" "=r,r")
4571         (zero_extend:DI
4572          (match_operand:SI 1 "move_src_operand" "r,RQ")))]
4573   "TARGET_64BIT && GET_CODE (operands[1]) != CONST_INT"
4574   "@
4575    extrd,u %1,63,32,%0
4576    ldw%M1 %1,%0"
4577   [(set_attr "type" "shift,load")
4578    (set_attr "length" "4,4")])
4579
4580 ;;- sign extension instructions
4581
4582 (define_insn "extendhisi2"
4583   [(set (match_operand:SI 0 "register_operand" "=r")
4584         (sign_extend:SI (match_operand:HI 1 "register_operand" "r")))]
4585   ""
4586   "{extrs|extrw,s} %1,31,16,%0"
4587   [(set_attr "type" "shift")
4588    (set_attr "length" "4")])
4589
4590 (define_insn "extendqihi2"
4591   [(set (match_operand:HI 0 "register_operand" "=r")
4592         (sign_extend:HI (match_operand:QI 1 "register_operand" "r")))]
4593   ""
4594   "{extrs|extrw,s} %1,31,8,%0"
4595   [(set_attr "type" "shift") 
4596   (set_attr "length" "4")])
4597
4598 (define_insn "extendqisi2"
4599   [(set (match_operand:SI 0 "register_operand" "=r")
4600         (sign_extend:SI (match_operand:QI 1 "register_operand" "r")))]
4601   ""
4602   "{extrs|extrw,s} %1,31,8,%0"
4603   [(set_attr "type" "shift")
4604    (set_attr "length" "4")])
4605
4606 (define_insn "extendqidi2"
4607   [(set (match_operand:DI 0 "register_operand" "=r")
4608         (sign_extend:DI (match_operand:QI 1 "register_operand" "r")))]
4609   "TARGET_64BIT"
4610   "extrd,s %1,63,8,%0"
4611   [(set_attr "type" "shift") 
4612   (set_attr "length" "4")])
4613
4614 (define_insn "extendhidi2"
4615   [(set (match_operand:DI 0 "register_operand" "=r")
4616         (sign_extend:DI (match_operand:HI 1 "register_operand" "r")))]
4617   "TARGET_64BIT"
4618   "extrd,s %1,63,16,%0"
4619   [(set_attr "type" "shift") 
4620   (set_attr "length" "4")])
4621
4622 (define_insn "extendsidi2"
4623   [(set (match_operand:DI 0 "register_operand" "=r")
4624         (sign_extend:DI (match_operand:SI 1 "register_operand" "r")))]
4625   "TARGET_64BIT"
4626   "extrd,s %1,63,32,%0"
4627   [(set_attr "type" "shift") 
4628   (set_attr "length" "4")])
4629
4630 \f
4631 ;; Conversions between float and double.
4632
4633 (define_insn "extendsfdf2"
4634   [(set (match_operand:DF 0 "register_operand" "=f")
4635         (float_extend:DF
4636          (match_operand:SF 1 "register_operand" "f")))]
4637   "! TARGET_SOFT_FLOAT"
4638   "{fcnvff|fcnv},sgl,dbl %1,%0"
4639   [(set_attr "type" "fpalu")
4640    (set_attr "length" "4")])
4641
4642 (define_insn "truncdfsf2"
4643   [(set (match_operand:SF 0 "register_operand" "=f")
4644         (float_truncate:SF
4645          (match_operand:DF 1 "register_operand" "f")))]
4646   "! TARGET_SOFT_FLOAT"
4647   "{fcnvff|fcnv},dbl,sgl %1,%0"
4648   [(set_attr "type" "fpalu")
4649    (set_attr "length" "4")])
4650
4651 ;; Conversion between fixed point and floating point.
4652 ;; Note that among the fix-to-float insns
4653 ;; the ones that start with SImode come first.
4654 ;; That is so that an operand that is a CONST_INT
4655 ;; (and therefore lacks a specific machine mode).
4656 ;; will be recognized as SImode (which is always valid)
4657 ;; rather than as QImode or HImode.
4658
4659 ;; This pattern forces (set (reg:SF ...) (float:SF (const_int ...)))
4660 ;; to be reloaded by putting the constant into memory.
4661 ;; It must come before the more general floatsisf2 pattern.
4662 (define_insn ""
4663   [(set (match_operand:SF 0 "register_operand" "=f")
4664         (float:SF (match_operand:SI 1 "const_int_operand" "m")))]
4665   "! TARGET_SOFT_FLOAT"
4666   "fldw%F1 %1,%0\;{fcnvxf,sgl,sgl|fcnv,w,sgl} %0,%0"
4667   [(set_attr "type" "fpalu")
4668    (set_attr "length" "8")])
4669
4670 (define_insn "floatsisf2"
4671   [(set (match_operand:SF 0 "register_operand" "=f")
4672         (float:SF (match_operand:SI 1 "register_operand" "f")))]
4673   "! TARGET_SOFT_FLOAT"
4674   "{fcnvxf,sgl,sgl|fcnv,w,sgl} %1,%0"
4675   [(set_attr "type" "fpalu")
4676    (set_attr "length" "4")])
4677
4678 ;; This pattern forces (set (reg:DF ...) (float:DF (const_int ...)))
4679 ;; to be reloaded by putting the constant into memory.
4680 ;; It must come before the more general floatsidf2 pattern.
4681 (define_insn ""
4682   [(set (match_operand:DF 0 "register_operand" "=f")
4683         (float:DF (match_operand:SI 1 "const_int_operand" "m")))]
4684   "! TARGET_SOFT_FLOAT"
4685   "fldw%F1 %1,%0\;{fcnvxf,sgl,dbl|fcnv,w,dbl} %0,%0"
4686   [(set_attr "type" "fpalu")
4687    (set_attr "length" "8")])
4688
4689 (define_insn "floatsidf2"
4690   [(set (match_operand:DF 0 "register_operand" "=f")
4691         (float:DF (match_operand:SI 1 "register_operand" "f")))]
4692   "! TARGET_SOFT_FLOAT"
4693   "{fcnvxf,sgl,dbl|fcnv,w,dbl} %1,%0"
4694   [(set_attr "type" "fpalu")
4695    (set_attr "length" "4")])
4696
4697 (define_expand "floatunssisf2"
4698   [(set (subreg:SI (match_dup 2) 4)
4699         (match_operand:SI 1 "register_operand" ""))
4700    (set (subreg:SI (match_dup 2) 0)
4701         (const_int 0))
4702    (set (match_operand:SF 0 "register_operand" "")
4703         (float:SF (match_dup 2)))]
4704   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4705   "
4706 {
4707   if (TARGET_PA_20)
4708     {
4709       emit_insn (gen_floatunssisf2_pa20 (operands[0], operands[1]));
4710       DONE;
4711     }
4712   operands[2] = gen_reg_rtx (DImode);
4713 }")
4714
4715 (define_expand "floatunssidf2"
4716   [(set (subreg:SI (match_dup 2) 4)
4717         (match_operand:SI 1 "register_operand" ""))
4718    (set (subreg:SI (match_dup 2) 0)
4719         (const_int 0))
4720    (set (match_operand:DF 0 "register_operand" "")
4721         (float:DF (match_dup 2)))]
4722   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4723   "
4724 {
4725   if (TARGET_PA_20)
4726     {
4727       emit_insn (gen_floatunssidf2_pa20 (operands[0], operands[1]));
4728       DONE;
4729     }
4730   operands[2] = gen_reg_rtx (DImode);
4731 }")
4732
4733 (define_insn "floatdisf2"
4734   [(set (match_operand:SF 0 "register_operand" "=f")
4735         (float:SF (match_operand:DI 1 "register_operand" "f")))]
4736   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4737   "{fcnvxf,dbl,sgl|fcnv,dw,sgl} %1,%0"
4738   [(set_attr "type" "fpalu")
4739    (set_attr "length" "4")])
4740
4741 (define_insn "floatdidf2"
4742   [(set (match_operand:DF 0 "register_operand" "=f")
4743         (float:DF (match_operand:DI 1 "register_operand" "f")))]
4744   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4745   "{fcnvxf,dbl,dbl|fcnv,dw,dbl} %1,%0"
4746   [(set_attr "type" "fpalu")
4747    (set_attr "length" "4")])
4748
4749 ;; Convert a float to an actual integer.
4750 ;; Truncation is performed as part of the conversion.
4751
4752 (define_insn "fix_truncsfsi2"
4753   [(set (match_operand:SI 0 "register_operand" "=f")
4754         (fix:SI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
4755   "! TARGET_SOFT_FLOAT"
4756   "{fcnvfxt,sgl,sgl|fcnv,t,sgl,w} %1,%0"
4757   [(set_attr "type" "fpalu")
4758    (set_attr "length" "4")])
4759
4760 (define_insn "fix_truncdfsi2"
4761   [(set (match_operand:SI 0 "register_operand" "=f")
4762         (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
4763   "! TARGET_SOFT_FLOAT"
4764   "{fcnvfxt,dbl,sgl|fcnv,t,dbl,w} %1,%0"
4765   [(set_attr "type" "fpalu")
4766    (set_attr "length" "4")])
4767
4768 (define_insn "fix_truncsfdi2"
4769   [(set (match_operand:DI 0 "register_operand" "=f")
4770         (fix:DI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
4771   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4772   "{fcnvfxt,sgl,dbl|fcnv,t,sgl,dw} %1,%0"
4773   [(set_attr "type" "fpalu")
4774    (set_attr "length" "4")])
4775
4776 (define_insn "fix_truncdfdi2"
4777   [(set (match_operand:DI 0 "register_operand" "=f")
4778         (fix:DI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
4779   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4780   "{fcnvfxt,dbl,dbl|fcnv,t,dbl,dw} %1,%0"
4781   [(set_attr "type" "fpalu")
4782    (set_attr "length" "4")])
4783
4784 (define_insn "floatunssidf2_pa20"
4785   [(set (match_operand:DF 0 "register_operand" "=f")
4786         (unsigned_float:DF (match_operand:SI 1 "register_operand" "f")))]
4787   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4788   "fcnv,uw,dbl %1,%0"
4789   [(set_attr "type" "fpalu")
4790    (set_attr "length" "4")])
4791
4792 (define_insn "floatunssisf2_pa20"
4793   [(set (match_operand:SF 0 "register_operand" "=f")
4794         (unsigned_float:SF (match_operand:SI 1 "register_operand" "f")))]
4795   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4796   "fcnv,uw,sgl %1,%0"
4797   [(set_attr "type" "fpalu")
4798    (set_attr "length" "4")])
4799
4800 (define_insn "floatunsdisf2"
4801   [(set (match_operand:SF 0 "register_operand" "=f")
4802         (unsigned_float:SF (match_operand:DI 1 "register_operand" "f")))]
4803   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4804   "fcnv,udw,sgl %1,%0"
4805   [(set_attr "type" "fpalu")
4806    (set_attr "length" "4")])
4807
4808 (define_insn "floatunsdidf2"
4809   [(set (match_operand:DF 0 "register_operand" "=f")
4810         (unsigned_float:DF (match_operand:DI 1 "register_operand" "f")))]
4811   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4812   "fcnv,udw,dbl %1,%0"
4813   [(set_attr "type" "fpalu")
4814    (set_attr "length" "4")])
4815
4816 (define_insn "fixuns_truncsfsi2"
4817   [(set (match_operand:SI 0 "register_operand" "=f")
4818         (unsigned_fix:SI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
4819   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4820   "fcnv,t,sgl,uw %1,%0"
4821   [(set_attr "type" "fpalu")
4822    (set_attr "length" "4")])
4823
4824 (define_insn "fixuns_truncdfsi2"
4825   [(set (match_operand:SI 0 "register_operand" "=f")
4826         (unsigned_fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
4827   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4828   "fcnv,t,dbl,uw %1,%0"
4829   [(set_attr "type" "fpalu")
4830    (set_attr "length" "4")])
4831
4832 (define_insn "fixuns_truncsfdi2"
4833   [(set (match_operand:DI 0 "register_operand" "=f")
4834         (unsigned_fix:DI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
4835   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4836   "fcnv,t,sgl,udw %1,%0"
4837   [(set_attr "type" "fpalu")
4838    (set_attr "length" "4")])
4839
4840 (define_insn "fixuns_truncdfdi2"
4841   [(set (match_operand:DI 0 "register_operand" "=f")
4842         (unsigned_fix:DI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
4843   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4844   "fcnv,t,dbl,udw %1,%0"
4845   [(set_attr "type" "fpalu")
4846    (set_attr "length" "4")])
4847 \f
4848 ;;- arithmetic instructions
4849
4850 (define_expand "adddi3"
4851   [(set (match_operand:DI 0 "register_operand" "")
4852         (plus:DI (match_operand:DI 1 "register_operand" "")
4853                  (match_operand:DI 2 "adddi3_operand" "")))]
4854   ""
4855   "")
4856
4857 (define_insn ""
4858   [(set (match_operand:DI 0 "register_operand" "=r")
4859         (plus:DI (match_operand:DI 1 "register_operand" "%r")
4860                  (match_operand:DI 2 "arith11_operand" "rI")))]
4861   "!TARGET_64BIT"
4862   "*
4863 {
4864   if (GET_CODE (operands[2]) == CONST_INT)
4865     {
4866       if (INTVAL (operands[2]) >= 0)
4867         return \"addi %2,%R1,%R0\;{addc|add,c} %1,%%r0,%0\";
4868       else
4869         return \"addi %2,%R1,%R0\;{subb|sub,b} %1,%%r0,%0\";
4870     }
4871   else
4872     return \"add %R2,%R1,%R0\;{addc|add,c} %2,%1,%0\";
4873 }"
4874   [(set_attr "type" "binary")
4875    (set_attr "length" "8")])
4876
4877 (define_insn ""
4878   [(set (match_operand:DI 0 "register_operand" "=r,r")
4879         (plus:DI (match_operand:DI 1 "register_operand" "%r,r")
4880                  (match_operand:DI 2 "arith_operand" "r,J")))]
4881   "TARGET_64BIT"
4882   "@
4883    add,l %1,%2,%0
4884    ldo %2(%1),%0"
4885   [(set_attr "type" "binary,binary")
4886    (set_attr "pa_combine_type" "addmove")
4887    (set_attr "length" "4,4")])
4888
4889 (define_insn ""
4890   [(set (match_operand:DI 0 "register_operand" "=r")
4891         (plus:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
4892                  (match_operand:DI 2 "register_operand" "r")))]
4893   "TARGET_64BIT"
4894   "uaddcm %2,%1,%0"
4895   [(set_attr "type" "binary")
4896    (set_attr "length" "4")])
4897
4898 (define_insn ""
4899   [(set (match_operand:SI 0 "register_operand" "=r")
4900         (plus:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
4901                  (match_operand:SI 2 "register_operand" "r")))]
4902   ""
4903   "uaddcm %2,%1,%0"
4904   [(set_attr "type" "binary")
4905    (set_attr "length" "4")])
4906
4907 ;; define_splits to optimize cases of adding a constant integer
4908 ;; to a register when the constant does not fit in 14 bits.  */
4909 (define_split
4910   [(set (match_operand:SI 0 "register_operand" "")
4911         (plus:SI (match_operand:SI 1 "register_operand" "")
4912                  (match_operand:SI 2 "const_int_operand" "")))
4913    (clobber (match_operand:SI 4 "register_operand" ""))]
4914   "! cint_ok_for_move (INTVAL (operands[2]))
4915    && VAL_14_BITS_P (INTVAL (operands[2]) >> 1)"
4916   [(set (match_dup 4) (plus:SI (match_dup 1) (match_dup 2)))
4917    (set (match_dup 0) (plus:SI (match_dup 4) (match_dup 3)))]
4918   "
4919 {
4920   int val = INTVAL (operands[2]);
4921   int low = (val < 0) ? -0x2000 : 0x1fff;
4922   int rest = val - low;
4923
4924   operands[2] = GEN_INT (rest);
4925   operands[3] = GEN_INT (low);
4926 }")
4927
4928 (define_split
4929   [(set (match_operand:SI 0 "register_operand" "")
4930         (plus:SI (match_operand:SI 1 "register_operand" "")
4931                  (match_operand:SI 2 "const_int_operand" "")))
4932    (clobber (match_operand:SI 4 "register_operand" ""))]
4933   "! cint_ok_for_move (INTVAL (operands[2]))"
4934   [(set (match_dup 4) (match_dup 2))
4935    (set (match_dup 0) (plus:SI (mult:SI (match_dup 4) (match_dup 3))
4936                                (match_dup 1)))]
4937   "
4938 {
4939   HOST_WIDE_INT intval = INTVAL (operands[2]);
4940
4941   /* Try dividing the constant by 2, then 4, and finally 8 to see
4942      if we can get a constant which can be loaded into a register
4943      in a single instruction (cint_ok_for_move). 
4944
4945      If that fails, try to negate the constant and subtract it
4946      from our input operand.  */
4947   if (intval % 2 == 0 && cint_ok_for_move (intval / 2))
4948     {
4949       operands[2] = GEN_INT (intval / 2);
4950       operands[3] = const2_rtx;
4951     }
4952   else if (intval % 4 == 0 && cint_ok_for_move (intval / 4))
4953     {
4954       operands[2] = GEN_INT (intval / 4);
4955       operands[3] = GEN_INT (4);
4956     }
4957   else if (intval % 8 == 0 && cint_ok_for_move (intval / 8))
4958     {
4959       operands[2] = GEN_INT (intval / 8);
4960       operands[3] = GEN_INT (8);
4961     }
4962   else if (cint_ok_for_move (-intval))
4963     {
4964       emit_insn (gen_rtx_SET (VOIDmode, operands[4], GEN_INT (-intval)));
4965       emit_insn (gen_subsi3 (operands[0], operands[1], operands[4]));
4966       DONE;
4967     }
4968   else
4969     FAIL;
4970 }")
4971
4972 (define_insn "addsi3"
4973   [(set (match_operand:SI 0 "register_operand" "=r,r")
4974         (plus:SI (match_operand:SI 1 "register_operand" "%r,r")
4975                  (match_operand:SI 2 "arith_operand" "r,J")))]
4976   ""
4977   "@
4978    {addl|add,l} %1,%2,%0
4979    ldo %2(%1),%0"
4980   [(set_attr "type" "binary,binary")
4981    (set_attr "pa_combine_type" "addmove")
4982    (set_attr "length" "4,4")])
4983
4984 (define_expand "subdi3"
4985   [(set (match_operand:DI 0 "register_operand" "")
4986         (minus:DI (match_operand:DI 1 "register_operand" "")
4987                   (match_operand:DI 2 "register_operand" "")))]
4988   ""
4989   "")
4990
4991 (define_insn ""
4992   [(set (match_operand:DI 0 "register_operand" "=r")
4993         (minus:DI (match_operand:DI 1 "register_operand" "r")
4994                   (match_operand:DI 2 "register_operand" "r")))]
4995   "!TARGET_64BIT"
4996   "sub %R1,%R2,%R0\;{subb|sub,b} %1,%2,%0"
4997   [(set_attr "type" "binary")
4998   (set_attr "length" "8")])
4999
5000 (define_insn ""
5001   [(set (match_operand:DI 0 "register_operand" "=r,r,!q")
5002         (minus:DI (match_operand:DI 1 "arith11_operand" "r,I,!U")
5003                   (match_operand:DI 2 "register_operand" "r,r,!r")))]
5004   "TARGET_64BIT"
5005   "@
5006    sub %1,%2,%0
5007    subi %1,%2,%0
5008    mtsarcm %2"
5009   [(set_attr "type" "binary,binary,move")
5010   (set_attr "length" "4,4,4")])
5011
5012 (define_expand "subsi3"
5013   [(set (match_operand:SI 0 "register_operand" "")
5014         (minus:SI (match_operand:SI 1 "arith11_operand" "")
5015                   (match_operand:SI 2 "register_operand" "")))]
5016   ""
5017   "")
5018
5019 (define_insn ""
5020   [(set (match_operand:SI 0 "register_operand" "=r,r")
5021         (minus:SI (match_operand:SI 1 "arith11_operand" "r,I")
5022                   (match_operand:SI 2 "register_operand" "r,r")))]
5023   "!TARGET_PA_20"
5024   "@
5025    sub %1,%2,%0
5026    subi %1,%2,%0"
5027   [(set_attr "type" "binary,binary")
5028    (set_attr "length" "4,4")])
5029
5030 (define_insn ""
5031   [(set (match_operand:SI 0 "register_operand" "=r,r,!q")
5032         (minus:SI (match_operand:SI 1 "arith11_operand" "r,I,!S")
5033                   (match_operand:SI 2 "register_operand" "r,r,!r")))]
5034   "TARGET_PA_20"
5035   "@
5036    sub %1,%2,%0
5037    subi %1,%2,%0
5038    mtsarcm %2"
5039   [(set_attr "type" "binary,binary,move")
5040    (set_attr "length" "4,4,4")])
5041
5042 ;; Clobbering a "register_operand" instead of a match_scratch
5043 ;; in operand3 of millicode calls avoids spilling %r1 and
5044 ;; produces better code.
5045
5046 ;; The mulsi3 insns set up registers for the millicode call.
5047 (define_expand "mulsi3"
5048   [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5049    (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5050    (parallel [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
5051               (clobber (match_dup 3))
5052               (clobber (reg:SI 26))
5053               (clobber (reg:SI 25))
5054               (clobber (match_dup 4))])
5055    (set (match_operand:SI 0 "general_operand" "") (reg:SI 29))]
5056   ""
5057   "
5058 {
5059   operands[4] = gen_rtx_REG (SImode, TARGET_64BIT ? 2 : 31);
5060   if (TARGET_PA_11 && !TARGET_DISABLE_FPREGS && !TARGET_SOFT_FLOAT)
5061     {
5062       rtx scratch = gen_reg_rtx (DImode);
5063       operands[1] = force_reg (SImode, operands[1]);
5064       operands[2] = force_reg (SImode, operands[2]);
5065       emit_insn (gen_umulsidi3 (scratch, operands[1], operands[2]));
5066       emit_insn (gen_movsi (operands[0],
5067                             gen_rtx_SUBREG (SImode, scratch,
5068                                             GET_MODE_SIZE (SImode))));
5069       DONE;
5070     }
5071   operands[3] = gen_reg_rtx (SImode);
5072 }")
5073
5074 (define_insn "umulsidi3"
5075   [(set (match_operand:DI 0 "nonimmediate_operand" "=f")
5076         (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "f"))
5077                  (zero_extend:DI (match_operand:SI 2 "nonimmediate_operand" "f"))))]
5078   "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT"
5079   "xmpyu %1,%2,%0"
5080   [(set_attr "type" "fpmuldbl")
5081    (set_attr "length" "4")])
5082
5083 (define_insn ""
5084   [(set (match_operand:DI 0 "nonimmediate_operand" "=f")
5085         (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "f"))
5086                  (match_operand:DI 2 "uint32_operand" "f")))]
5087   "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT && !TARGET_64BIT"
5088   "xmpyu %1,%R2,%0"
5089   [(set_attr "type" "fpmuldbl")
5090    (set_attr "length" "4")])
5091
5092 (define_insn ""
5093   [(set (match_operand:DI 0 "nonimmediate_operand" "=f")
5094         (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "f"))
5095                  (match_operand:DI 2 "uint32_operand" "f")))]
5096   "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT && TARGET_64BIT"
5097   "xmpyu %1,%2R,%0"
5098   [(set_attr "type" "fpmuldbl")
5099    (set_attr "length" "4")])
5100
5101 (define_insn ""
5102   [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
5103    (clobber (match_operand:SI 0 "register_operand" "=a"))
5104    (clobber (reg:SI 26))
5105    (clobber (reg:SI 25))
5106    (clobber (reg:SI 31))]
5107   "!TARGET_64BIT"
5108   "* return output_mul_insn (0, insn);"
5109   [(set_attr "type" "milli")
5110    (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5111
5112 (define_insn ""
5113   [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
5114    (clobber (match_operand:SI 0 "register_operand" "=a"))
5115    (clobber (reg:SI 26))
5116    (clobber (reg:SI 25))
5117    (clobber (reg:SI 2))]
5118   "TARGET_64BIT"
5119   "* return output_mul_insn (0, insn);"
5120   [(set_attr "type" "milli")
5121    (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5122
5123 (define_expand "muldi3"
5124   [(set (match_operand:DI 0 "register_operand" "")
5125         (mult:DI (match_operand:DI 1 "register_operand" "")
5126                  (match_operand:DI 2 "register_operand" "")))]
5127   "TARGET_64BIT && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT"
5128   "
5129 {
5130   rtx low_product = gen_reg_rtx (DImode);
5131   rtx cross_product1 = gen_reg_rtx (DImode);
5132   rtx cross_product2 = gen_reg_rtx (DImode);
5133   rtx cross_scratch = gen_reg_rtx (DImode);
5134   rtx cross_product = gen_reg_rtx (DImode);
5135   rtx op1l, op1r, op2l, op2r;
5136   rtx op1shifted, op2shifted;
5137
5138   op1shifted = gen_reg_rtx (DImode);
5139   op2shifted = gen_reg_rtx (DImode);
5140   op1l = gen_reg_rtx (SImode);
5141   op1r = gen_reg_rtx (SImode);
5142   op2l = gen_reg_rtx (SImode);
5143   op2r = gen_reg_rtx (SImode);
5144
5145   emit_move_insn (op1shifted, gen_rtx_LSHIFTRT (DImode, operands[1],
5146                                                 GEN_INT (32)));
5147   emit_move_insn (op2shifted, gen_rtx_LSHIFTRT (DImode, operands[2],
5148                                                 GEN_INT (32)));
5149   op1r = gen_rtx_SUBREG (SImode, operands[1], 4);
5150   op2r = gen_rtx_SUBREG (SImode, operands[2], 4);
5151   op1l = gen_rtx_SUBREG (SImode, op1shifted, 4);
5152   op2l = gen_rtx_SUBREG (SImode, op2shifted, 4);
5153
5154   /* Emit multiplies for the cross products.  */
5155   emit_insn (gen_umulsidi3 (cross_product1, op2r, op1l));
5156   emit_insn (gen_umulsidi3 (cross_product2, op2l, op1r));
5157
5158   /* Emit a multiply for the low sub-word.  */
5159   emit_insn (gen_umulsidi3 (low_product, copy_rtx (op2r), copy_rtx (op1r)));
5160
5161   /* Sum the cross products and shift them into proper position.  */
5162   emit_insn (gen_adddi3 (cross_scratch, cross_product1, cross_product2));
5163   emit_insn (gen_ashldi3 (cross_product, cross_scratch, GEN_INT (32)));
5164
5165   /* Add the cross product to the low product and store the result
5166      into the output operand .  */
5167   emit_insn (gen_adddi3 (operands[0], cross_product, low_product));
5168   DONE;
5169 }")
5170
5171 ;;; Division and mod.
5172 (define_expand "divsi3"
5173   [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5174    (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5175    (parallel [(set (reg:SI 29) (div:SI (reg:SI 26) (reg:SI 25)))
5176               (clobber (match_dup 3))
5177               (clobber (match_dup 4))
5178               (clobber (reg:SI 26))
5179               (clobber (reg:SI 25))
5180               (clobber (match_dup 5))])
5181    (set (match_operand:SI 0 "general_operand" "") (reg:SI 29))]
5182   ""
5183   "
5184 {
5185   operands[3] = gen_reg_rtx (SImode);
5186   if (TARGET_64BIT)
5187     {
5188       operands[5] = gen_rtx_REG (SImode, 2);
5189       operands[4] = operands[5];
5190     }
5191   else
5192     {
5193       operands[5] = gen_rtx_REG (SImode, 31);
5194       operands[4] = gen_reg_rtx (SImode);
5195     }
5196   if (GET_CODE (operands[2]) == CONST_INT && emit_hpdiv_const (operands, 0))
5197     DONE;
5198 }")
5199
5200 (define_insn ""
5201   [(set (reg:SI 29)
5202         (div:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5203    (clobber (match_operand:SI 1 "register_operand" "=a"))
5204    (clobber (match_operand:SI 2 "register_operand" "=&r"))
5205    (clobber (reg:SI 26))
5206    (clobber (reg:SI 25))
5207    (clobber (reg:SI 31))]
5208   "!TARGET_64BIT"
5209   "*
5210    return output_div_insn (operands, 0, insn);"
5211   [(set_attr "type" "milli")
5212    (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5213
5214 (define_insn ""
5215   [(set (reg:SI 29)
5216         (div:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5217    (clobber (match_operand:SI 1 "register_operand" "=a"))
5218    (clobber (match_operand:SI 2 "register_operand" "=&r"))
5219    (clobber (reg:SI 26))
5220    (clobber (reg:SI 25))
5221    (clobber (reg:SI 2))]
5222   "TARGET_64BIT"
5223   "*
5224    return output_div_insn (operands, 0, insn);"
5225   [(set_attr "type" "milli")
5226    (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5227
5228 (define_expand "udivsi3"
5229   [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5230    (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5231    (parallel [(set (reg:SI 29) (udiv:SI (reg:SI 26) (reg:SI 25)))
5232               (clobber (match_dup 3))
5233               (clobber (match_dup 4))
5234               (clobber (reg:SI 26))
5235               (clobber (reg:SI 25))
5236               (clobber (match_dup 5))])
5237    (set (match_operand:SI 0 "general_operand" "") (reg:SI 29))]
5238   ""
5239   "
5240 {
5241   operands[3] = gen_reg_rtx (SImode);
5242
5243   if (TARGET_64BIT)
5244     {
5245       operands[5] = gen_rtx_REG (SImode, 2);
5246       operands[4] = operands[5];
5247     }
5248   else
5249     {
5250       operands[5] = gen_rtx_REG (SImode, 31);
5251       operands[4] = gen_reg_rtx (SImode);
5252     }
5253   if (GET_CODE (operands[2]) == CONST_INT && emit_hpdiv_const (operands, 1))
5254     DONE;
5255 }")
5256
5257 (define_insn ""
5258   [(set (reg:SI 29)
5259         (udiv:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5260    (clobber (match_operand:SI 1 "register_operand" "=a"))
5261    (clobber (match_operand:SI 2 "register_operand" "=&r"))
5262    (clobber (reg:SI 26))
5263    (clobber (reg:SI 25))
5264    (clobber (reg:SI 31))]
5265   "!TARGET_64BIT"
5266   "*
5267    return output_div_insn (operands, 1, insn);"
5268   [(set_attr "type" "milli")
5269    (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5270
5271 (define_insn ""
5272   [(set (reg:SI 29)
5273         (udiv:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5274    (clobber (match_operand:SI 1 "register_operand" "=a"))
5275    (clobber (match_operand:SI 2 "register_operand" "=&r"))
5276    (clobber (reg:SI 26))
5277    (clobber (reg:SI 25))
5278    (clobber (reg:SI 2))]
5279   "TARGET_64BIT"
5280   "*
5281    return output_div_insn (operands, 1, insn);"
5282   [(set_attr "type" "milli")
5283    (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5284
5285 (define_expand "modsi3"
5286   [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5287    (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5288    (parallel [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
5289               (clobber (match_dup 3))
5290               (clobber (match_dup 4))
5291               (clobber (reg:SI 26))
5292               (clobber (reg:SI 25))
5293               (clobber (match_dup 5))])
5294    (set (match_operand:SI 0 "general_operand" "") (reg:SI 29))]
5295   ""
5296   "
5297 {
5298   if (TARGET_64BIT)
5299     {
5300       operands[5] = gen_rtx_REG (SImode, 2);
5301       operands[4] = operands[5];
5302     }
5303   else
5304     {
5305       operands[5] = gen_rtx_REG (SImode, 31);
5306       operands[4] = gen_reg_rtx (SImode);
5307     }
5308   operands[3] = gen_reg_rtx (SImode);
5309 }")
5310
5311 (define_insn ""
5312   [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
5313    (clobber (match_operand:SI 0 "register_operand" "=a"))
5314    (clobber (match_operand:SI 1 "register_operand" "=&r"))
5315    (clobber (reg:SI 26))
5316    (clobber (reg:SI 25))
5317    (clobber (reg:SI 31))]
5318   "!TARGET_64BIT"
5319   "*
5320   return output_mod_insn (0, insn);"
5321   [(set_attr "type" "milli")
5322    (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5323
5324 (define_insn ""
5325   [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
5326    (clobber (match_operand:SI 0 "register_operand" "=a"))
5327    (clobber (match_operand:SI 1 "register_operand" "=&r"))
5328    (clobber (reg:SI 26))
5329    (clobber (reg:SI 25))
5330    (clobber (reg:SI 2))]
5331   "TARGET_64BIT"
5332   "*
5333   return output_mod_insn (0, insn);"
5334   [(set_attr "type" "milli")
5335    (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5336
5337 (define_expand "umodsi3"
5338   [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5339    (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5340    (parallel [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
5341               (clobber (match_dup 3))
5342               (clobber (match_dup 4))
5343               (clobber (reg:SI 26))
5344               (clobber (reg:SI 25))
5345               (clobber (match_dup 5))])
5346    (set (match_operand:SI 0 "general_operand" "") (reg:SI 29))]
5347   ""
5348   "
5349 {
5350   if (TARGET_64BIT)
5351     {
5352       operands[5] = gen_rtx_REG (SImode, 2);
5353       operands[4] = operands[5];
5354     }
5355   else
5356     {
5357       operands[5] = gen_rtx_REG (SImode, 31);
5358       operands[4] = gen_reg_rtx (SImode);
5359     }
5360   operands[3] = gen_reg_rtx (SImode);
5361 }")
5362
5363 (define_insn ""
5364   [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
5365    (clobber (match_operand:SI 0 "register_operand" "=a"))
5366    (clobber (match_operand:SI 1 "register_operand" "=&r"))
5367    (clobber (reg:SI 26))
5368    (clobber (reg:SI 25))
5369    (clobber (reg:SI 31))]
5370   "!TARGET_64BIT"
5371   "*
5372   return output_mod_insn (1, insn);"
5373   [(set_attr "type" "milli")
5374    (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5375
5376 (define_insn ""
5377   [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
5378    (clobber (match_operand:SI 0 "register_operand" "=a"))
5379    (clobber (match_operand:SI 1 "register_operand" "=&r"))
5380    (clobber (reg:SI 26))
5381    (clobber (reg:SI 25))
5382    (clobber (reg:SI 2))]
5383   "TARGET_64BIT"
5384   "*
5385   return output_mod_insn (1, insn);"
5386   [(set_attr "type" "milli")
5387    (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5388
5389 ;;- and instructions
5390 ;; We define DImode `and` so with DImode `not` we can get
5391 ;; DImode `andn`.  Other combinations are possible.
5392
5393 (define_expand "anddi3"
5394   [(set (match_operand:DI 0 "register_operand" "")
5395         (and:DI (match_operand:DI 1 "and_operand" "")
5396                 (match_operand:DI 2 "and_operand" "")))]
5397   ""
5398   "
5399 {
5400   if (TARGET_64BIT)
5401     {
5402       /* One operand must be a register operand.  */
5403       if (!register_operand (operands[1], DImode)
5404           && !register_operand (operands[2], DImode))
5405         FAIL;
5406     }
5407   else
5408     {
5409       /* Both operands must be register operands.  */
5410       if (!register_operand (operands[1], DImode)
5411           || !register_operand (operands[2], DImode))
5412         FAIL;
5413     }
5414 }")
5415
5416 (define_insn ""
5417   [(set (match_operand:DI 0 "register_operand" "=r")
5418         (and:DI (match_operand:DI 1 "register_operand" "%r")
5419                 (match_operand:DI 2 "register_operand" "r")))]
5420   "!TARGET_64BIT"
5421   "and %1,%2,%0\;and %R1,%R2,%R0"
5422   [(set_attr "type" "binary")
5423    (set_attr "length" "8")])
5424
5425 (define_insn ""
5426   [(set (match_operand:DI 0 "register_operand" "=r,r")
5427         (and:DI (match_operand:DI 1 "register_operand" "%?r,0")
5428                 (match_operand:DI 2 "and_operand" "rO,P")))]
5429   "TARGET_64BIT"
5430   "* return output_64bit_and (operands); "
5431   [(set_attr "type" "binary")
5432    (set_attr "length" "4")])
5433
5434 ; The ? for op1 makes reload prefer zdepi instead of loading a huge
5435 ; constant with ldil;ldo.
5436 (define_insn "andsi3"
5437   [(set (match_operand:SI 0 "register_operand" "=r,r")
5438         (and:SI (match_operand:SI 1 "register_operand" "%?r,0")
5439                 (match_operand:SI 2 "and_operand" "rO,P")))]
5440   ""
5441   "* return output_and (operands); "
5442   [(set_attr "type" "binary,shift")
5443    (set_attr "length" "4,4")])
5444
5445 (define_insn ""
5446   [(set (match_operand:DI 0 "register_operand" "=r")
5447         (and:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
5448                 (match_operand:DI 2 "register_operand" "r")))]
5449   "!TARGET_64BIT"
5450   "andcm %2,%1,%0\;andcm %R2,%R1,%R0"
5451   [(set_attr "type" "binary")
5452    (set_attr "length" "8")])
5453
5454 (define_insn ""
5455   [(set (match_operand:DI 0 "register_operand" "=r")
5456         (and:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
5457                 (match_operand:DI 2 "register_operand" "r")))]
5458   "TARGET_64BIT"
5459   "andcm %2,%1,%0"
5460   [(set_attr "type" "binary")
5461    (set_attr "length" "4")])
5462
5463 (define_insn ""
5464   [(set (match_operand:SI 0 "register_operand" "=r")
5465         (and:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
5466                 (match_operand:SI 2 "register_operand" "r")))]
5467   ""
5468   "andcm %2,%1,%0"
5469   [(set_attr "type" "binary")
5470   (set_attr "length" "4")])
5471
5472 (define_expand "iordi3"
5473   [(set (match_operand:DI 0 "register_operand" "")
5474         (ior:DI (match_operand:DI 1 "ior_operand" "")
5475                 (match_operand:DI 2 "ior_operand" "")))]
5476   ""
5477   "
5478 {
5479   if (TARGET_64BIT)
5480     {
5481       /* One operand must be a register operand.  */
5482       if (!register_operand (operands[1], DImode)
5483           && !register_operand (operands[2], DImode))
5484         FAIL;
5485     }
5486   else
5487     {
5488       /* Both operands must be register operands.  */
5489       if (!register_operand (operands[1], DImode)
5490           || !register_operand (operands[2], DImode))
5491         FAIL;
5492     }
5493 }")
5494
5495 (define_insn ""
5496   [(set (match_operand:DI 0 "register_operand" "=r")
5497         (ior:DI (match_operand:DI 1 "register_operand" "%r")
5498                 (match_operand:DI 2 "register_operand" "r")))]
5499   "!TARGET_64BIT"
5500   "or %1,%2,%0\;or %R1,%R2,%R0"
5501   [(set_attr "type" "binary")
5502    (set_attr "length" "8")])
5503
5504 (define_insn ""
5505   [(set (match_operand:DI 0 "register_operand" "=r,r")
5506         (ior:DI (match_operand:DI 1 "register_operand" "0,0")
5507                 (match_operand:DI 2 "ior_operand" "M,i")))]
5508   "TARGET_64BIT"
5509   "* return output_64bit_ior (operands); "
5510   [(set_attr "type" "binary,shift")
5511    (set_attr "length" "4,4")])
5512
5513 (define_insn ""
5514   [(set (match_operand:DI 0 "register_operand" "=r")
5515         (ior:DI (match_operand:DI 1 "register_operand" "%r")
5516                 (match_operand:DI 2 "register_operand" "r")))]
5517   "TARGET_64BIT"
5518   "or %1,%2,%0"
5519   [(set_attr "type" "binary")
5520    (set_attr "length" "4")])
5521
5522 ;; Need a define_expand because we've run out of CONST_OK... characters.
5523 (define_expand "iorsi3"
5524   [(set (match_operand:SI 0 "register_operand" "")
5525         (ior:SI (match_operand:SI 1 "register_operand" "")
5526                 (match_operand:SI 2 "arith32_operand" "")))]
5527   ""
5528   "
5529 {
5530   if (! (ior_operand (operands[2], SImode)
5531          || register_operand (operands[2], SImode)))
5532     operands[2] = force_reg (SImode, operands[2]);
5533 }")
5534
5535 (define_insn ""
5536   [(set (match_operand:SI 0 "register_operand" "=r,r")
5537         (ior:SI (match_operand:SI 1 "register_operand" "0,0")
5538                 (match_operand:SI 2 "ior_operand" "M,i")))]
5539   ""
5540   "* return output_ior (operands); "
5541   [(set_attr "type" "binary,shift")
5542    (set_attr "length" "4,4")])
5543
5544 (define_insn ""
5545   [(set (match_operand:SI 0 "register_operand" "=r")
5546         (ior:SI (match_operand:SI 1 "register_operand" "%r")
5547                 (match_operand:SI 2 "register_operand" "r")))]
5548   ""
5549   "or %1,%2,%0"
5550   [(set_attr "type" "binary")
5551    (set_attr "length" "4")])
5552
5553 (define_expand "xordi3"
5554   [(set (match_operand:DI 0 "register_operand" "")
5555         (xor:DI (match_operand:DI 1 "register_operand" "")
5556                 (match_operand:DI 2 "register_operand" "")))]
5557   ""
5558   "
5559 {
5560 }")
5561
5562 (define_insn ""
5563   [(set (match_operand:DI 0 "register_operand" "=r")
5564         (xor:DI (match_operand:DI 1 "register_operand" "%r")
5565                 (match_operand:DI 2 "register_operand" "r")))]
5566   "!TARGET_64BIT"
5567   "xor %1,%2,%0\;xor %R1,%R2,%R0"
5568   [(set_attr "type" "binary")
5569    (set_attr "length" "8")])
5570
5571 (define_insn ""
5572   [(set (match_operand:DI 0 "register_operand" "=r")
5573         (xor:DI (match_operand:DI 1 "register_operand" "%r")
5574                 (match_operand:DI 2 "register_operand" "r")))]
5575   "TARGET_64BIT"
5576   "xor %1,%2,%0"
5577   [(set_attr "type" "binary")
5578    (set_attr "length" "4")])
5579
5580 (define_insn "xorsi3"
5581   [(set (match_operand:SI 0 "register_operand" "=r")
5582         (xor:SI (match_operand:SI 1 "register_operand" "%r")
5583                 (match_operand:SI 2 "register_operand" "r")))]
5584   ""
5585   "xor %1,%2,%0"
5586   [(set_attr "type" "binary")
5587    (set_attr "length" "4")])
5588
5589 (define_expand "negdi2"
5590   [(set (match_operand:DI 0 "register_operand" "")
5591         (neg:DI (match_operand:DI 1 "register_operand" "")))]
5592   ""
5593   "")
5594
5595 (define_insn ""
5596   [(set (match_operand:DI 0 "register_operand" "=r")
5597         (neg:DI (match_operand:DI 1 "register_operand" "r")))]
5598   "!TARGET_64BIT"
5599   "sub %%r0,%R1,%R0\;{subb|sub,b} %%r0,%1,%0"
5600   [(set_attr "type" "unary")
5601    (set_attr "length" "8")])
5602
5603 (define_insn ""
5604   [(set (match_operand:DI 0 "register_operand" "=r")
5605         (neg:DI (match_operand:DI 1 "register_operand" "r")))]
5606   "TARGET_64BIT"
5607   "sub %%r0,%1,%0"
5608   [(set_attr "type" "unary")
5609    (set_attr "length" "4")])
5610
5611 (define_insn "negsi2"
5612   [(set (match_operand:SI 0 "register_operand" "=r")
5613         (neg:SI (match_operand:SI 1 "register_operand" "r")))]
5614   ""
5615   "sub %%r0,%1,%0"
5616   [(set_attr "type" "unary")
5617    (set_attr "length" "4")])
5618
5619 (define_expand "one_cmpldi2"
5620   [(set (match_operand:DI 0 "register_operand" "")
5621         (not:DI (match_operand:DI 1 "register_operand" "")))]
5622   ""
5623   "
5624 {
5625 }")
5626
5627 (define_insn ""
5628   [(set (match_operand:DI 0 "register_operand" "=r")
5629         (not:DI (match_operand:DI 1 "register_operand" "r")))]
5630   "!TARGET_64BIT"
5631   "uaddcm %%r0,%1,%0\;uaddcm %%r0,%R1,%R0"
5632   [(set_attr "type" "unary")
5633    (set_attr "length" "8")])
5634
5635 (define_insn ""
5636   [(set (match_operand:DI 0 "register_operand" "=r")
5637         (not:DI (match_operand:DI 1 "register_operand" "r")))]
5638   "TARGET_64BIT"
5639   "uaddcm %%r0,%1,%0"
5640   [(set_attr "type" "unary")
5641    (set_attr "length" "4")])
5642
5643 (define_insn "one_cmplsi2"
5644   [(set (match_operand:SI 0 "register_operand" "=r")
5645         (not:SI (match_operand:SI 1 "register_operand" "r")))]
5646   ""
5647   "uaddcm %%r0,%1,%0"
5648   [(set_attr "type" "unary")
5649    (set_attr "length" "4")])
5650 \f
5651 ;; Floating point arithmetic instructions.
5652
5653 (define_insn "adddf3"
5654   [(set (match_operand:DF 0 "register_operand" "=f")
5655         (plus:DF (match_operand:DF 1 "register_operand" "f")
5656                  (match_operand:DF 2 "register_operand" "f")))]
5657   "! TARGET_SOFT_FLOAT"
5658   "fadd,dbl %1,%2,%0"
5659   [(set_attr "type" "fpalu")
5660    (set_attr "pa_combine_type" "faddsub")
5661    (set_attr "length" "4")])
5662
5663 (define_insn "addsf3"
5664   [(set (match_operand:SF 0 "register_operand" "=f")
5665         (plus:SF (match_operand:SF 1 "register_operand" "f")
5666                  (match_operand:SF 2 "register_operand" "f")))]
5667   "! TARGET_SOFT_FLOAT"
5668   "fadd,sgl %1,%2,%0"
5669   [(set_attr "type" "fpalu")
5670    (set_attr "pa_combine_type" "faddsub")
5671    (set_attr "length" "4")])
5672
5673 (define_insn "subdf3"
5674   [(set (match_operand:DF 0 "register_operand" "=f")
5675         (minus:DF (match_operand:DF 1 "register_operand" "f")
5676                   (match_operand:DF 2 "register_operand" "f")))]
5677   "! TARGET_SOFT_FLOAT"
5678   "fsub,dbl %1,%2,%0"
5679   [(set_attr "type" "fpalu")
5680    (set_attr "pa_combine_type" "faddsub")
5681    (set_attr "length" "4")])
5682
5683 (define_insn "subsf3"
5684   [(set (match_operand:SF 0 "register_operand" "=f")
5685         (minus:SF (match_operand:SF 1 "register_operand" "f")
5686                   (match_operand:SF 2 "register_operand" "f")))]
5687   "! TARGET_SOFT_FLOAT"
5688   "fsub,sgl %1,%2,%0"
5689   [(set_attr "type" "fpalu")
5690    (set_attr "pa_combine_type" "faddsub")
5691    (set_attr "length" "4")])
5692
5693 (define_insn "muldf3"
5694   [(set (match_operand:DF 0 "register_operand" "=f")
5695         (mult:DF (match_operand:DF 1 "register_operand" "f")
5696                  (match_operand:DF 2 "register_operand" "f")))]
5697   "! TARGET_SOFT_FLOAT"
5698   "fmpy,dbl %1,%2,%0"
5699   [(set_attr "type" "fpmuldbl")
5700    (set_attr "pa_combine_type" "fmpy")
5701    (set_attr "length" "4")])
5702
5703 (define_insn "mulsf3"
5704   [(set (match_operand:SF 0 "register_operand" "=f")
5705         (mult:SF (match_operand:SF 1 "register_operand" "f")
5706                  (match_operand:SF 2 "register_operand" "f")))]
5707   "! TARGET_SOFT_FLOAT"
5708   "fmpy,sgl %1,%2,%0"
5709   [(set_attr "type" "fpmulsgl")
5710    (set_attr "pa_combine_type" "fmpy")
5711    (set_attr "length" "4")])
5712
5713 (define_insn "divdf3"
5714   [(set (match_operand:DF 0 "register_operand" "=f")
5715         (div:DF (match_operand:DF 1 "register_operand" "f")
5716                 (match_operand:DF 2 "register_operand" "f")))]
5717   "! TARGET_SOFT_FLOAT"
5718   "fdiv,dbl %1,%2,%0"
5719   [(set_attr "type" "fpdivdbl")
5720    (set_attr "length" "4")])
5721
5722 (define_insn "divsf3"
5723   [(set (match_operand:SF 0 "register_operand" "=f")
5724         (div:SF (match_operand:SF 1 "register_operand" "f")
5725                 (match_operand:SF 2 "register_operand" "f")))]
5726   "! TARGET_SOFT_FLOAT"
5727   "fdiv,sgl %1,%2,%0"
5728   [(set_attr "type" "fpdivsgl")
5729    (set_attr "length" "4")])
5730
5731 ;; Processors prior to PA 2.0 don't have a fneg instruction.  Fast
5732 ;; negation can be done by subtracting from plus zero.  However, this
5733 ;; violates the IEEE standard when negating plus and minus zero.
5734 (define_expand "negdf2"
5735   [(parallel [(set (match_operand:DF 0 "register_operand" "")
5736                    (neg:DF (match_operand:DF 1 "register_operand" "")))
5737               (use (match_dup 2))])]
5738   "! TARGET_SOFT_FLOAT"
5739 {
5740   if (TARGET_PA_20 || flag_unsafe_math_optimizations)
5741     emit_insn (gen_negdf2_fast (operands[0], operands[1]));
5742   else
5743     {
5744       operands[2] = force_reg (DFmode,
5745         CONST_DOUBLE_FROM_REAL_VALUE (dconstm1, DFmode));
5746       emit_insn (gen_muldf3 (operands[0], operands[1], operands[2]));
5747     }
5748   DONE;
5749 })
5750
5751 (define_insn "negdf2_fast"
5752   [(set (match_operand:DF 0 "register_operand" "=f")
5753         (neg:DF (match_operand:DF 1 "register_operand" "f")))]
5754   "! TARGET_SOFT_FLOAT && (TARGET_PA_20 || flag_unsafe_math_optimizations)"
5755   "*
5756 {
5757   if (TARGET_PA_20)
5758     return \"fneg,dbl %1,%0\";
5759   else
5760     return \"fsub,dbl %%fr0,%1,%0\";
5761 }"
5762   [(set_attr "type" "fpalu")
5763    (set_attr "length" "4")])
5764
5765 (define_expand "negsf2"
5766   [(parallel [(set (match_operand:SF 0 "register_operand" "")
5767                    (neg:SF (match_operand:SF 1 "register_operand" "")))
5768               (use (match_dup 2))])]
5769   "! TARGET_SOFT_FLOAT"
5770 {
5771   if (TARGET_PA_20 || flag_unsafe_math_optimizations)
5772     emit_insn (gen_negsf2_fast (operands[0], operands[1]));
5773   else
5774     {
5775       operands[2] = force_reg (SFmode,
5776         CONST_DOUBLE_FROM_REAL_VALUE (dconstm1, SFmode));
5777       emit_insn (gen_mulsf3 (operands[0], operands[1], operands[2]));
5778     }
5779   DONE;
5780 })
5781
5782 (define_insn "negsf2_fast"
5783   [(set (match_operand:SF 0 "register_operand" "=f")
5784         (neg:SF (match_operand:SF 1 "register_operand" "f")))]
5785   "! TARGET_SOFT_FLOAT && (TARGET_PA_20 || flag_unsafe_math_optimizations)"
5786   "*
5787 {
5788   if (TARGET_PA_20)
5789     return \"fneg,sgl %1,%0\";
5790   else
5791     return \"fsub,sgl %%fr0,%1,%0\";
5792 }"
5793   [(set_attr "type" "fpalu")
5794    (set_attr "length" "4")])
5795
5796 (define_insn "absdf2"
5797   [(set (match_operand:DF 0 "register_operand" "=f")
5798         (abs:DF (match_operand:DF 1 "register_operand" "f")))]
5799   "! TARGET_SOFT_FLOAT"
5800   "fabs,dbl %1,%0"
5801   [(set_attr "type" "fpalu")
5802    (set_attr "length" "4")])
5803
5804 (define_insn "abssf2"
5805   [(set (match_operand:SF 0 "register_operand" "=f")
5806         (abs:SF (match_operand:SF 1 "register_operand" "f")))]
5807   "! TARGET_SOFT_FLOAT"
5808   "fabs,sgl %1,%0"
5809   [(set_attr "type" "fpalu")
5810    (set_attr "length" "4")])
5811
5812 (define_insn "sqrtdf2"
5813   [(set (match_operand:DF 0 "register_operand" "=f")
5814         (sqrt:DF (match_operand:DF 1 "register_operand" "f")))]
5815   "! TARGET_SOFT_FLOAT"
5816   "fsqrt,dbl %1,%0"
5817   [(set_attr "type" "fpsqrtdbl")
5818    (set_attr "length" "4")])
5819
5820 (define_insn "sqrtsf2"
5821   [(set (match_operand:SF 0 "register_operand" "=f")
5822         (sqrt:SF (match_operand:SF 1 "register_operand" "f")))]
5823   "! TARGET_SOFT_FLOAT"
5824   "fsqrt,sgl %1,%0"
5825   [(set_attr "type" "fpsqrtsgl")
5826    (set_attr "length" "4")])
5827
5828 ;; PA 2.0 floating point instructions
5829
5830 ; fmpyfadd patterns
5831 (define_insn ""
5832   [(set (match_operand:DF 0 "register_operand" "=f")
5833         (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
5834                           (match_operand:DF 2 "register_operand" "f"))
5835                  (match_operand:DF 3 "register_operand" "f")))]
5836   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
5837   "fmpyfadd,dbl %1,%2,%3,%0"
5838   [(set_attr "type" "fpmuldbl")
5839    (set_attr "length" "4")])
5840
5841 (define_insn ""
5842   [(set (match_operand:DF 0 "register_operand" "=f")
5843         (plus:DF (match_operand:DF 1 "register_operand" "f")
5844                  (mult:DF (match_operand:DF 2 "register_operand" "f")
5845                           (match_operand:DF 3 "register_operand" "f"))))]
5846   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
5847   "fmpyfadd,dbl %2,%3,%1,%0"
5848   [(set_attr "type" "fpmuldbl")
5849    (set_attr "length" "4")])
5850
5851 (define_insn ""
5852   [(set (match_operand:SF 0 "register_operand" "=f")
5853         (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
5854                           (match_operand:SF 2 "register_operand" "f"))
5855                  (match_operand:SF 3 "register_operand" "f")))]
5856   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
5857   "fmpyfadd,sgl %1,%2,%3,%0"
5858   [(set_attr "type" "fpmulsgl")
5859    (set_attr "length" "4")])
5860
5861 (define_insn ""
5862   [(set (match_operand:SF 0 "register_operand" "=f")
5863         (plus:SF (match_operand:SF 1 "register_operand" "f")
5864                  (mult:SF (match_operand:SF 2 "register_operand" "f")
5865                           (match_operand:SF 3 "register_operand" "f"))))]
5866   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
5867   "fmpyfadd,sgl %2,%3,%1,%0"
5868   [(set_attr "type" "fpmulsgl")
5869    (set_attr "length" "4")])
5870
5871 ; fmpynfadd patterns
5872 (define_insn ""
5873   [(set (match_operand:DF 0 "register_operand" "=f")
5874         (minus:DF (match_operand:DF 1 "register_operand" "f")
5875                   (mult:DF (match_operand:DF 2 "register_operand" "f")
5876                            (match_operand:DF 3 "register_operand" "f"))))]
5877   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
5878   "fmpynfadd,dbl %2,%3,%1,%0"
5879   [(set_attr "type" "fpmuldbl")
5880    (set_attr "length" "4")])
5881
5882 (define_insn ""
5883   [(set (match_operand:SF 0 "register_operand" "=f")
5884         (minus:SF (match_operand:SF 1 "register_operand" "f")
5885                   (mult:SF (match_operand:SF 2 "register_operand" "f")
5886                            (match_operand:SF 3 "register_operand" "f"))))]
5887   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
5888   "fmpynfadd,sgl %2,%3,%1,%0"
5889   [(set_attr "type" "fpmulsgl")
5890    (set_attr "length" "4")])
5891
5892 ; fnegabs patterns
5893 (define_insn ""
5894   [(set (match_operand:DF 0 "register_operand" "=f")
5895         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))]
5896   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
5897   "fnegabs,dbl %1,%0"
5898   [(set_attr "type" "fpalu")
5899    (set_attr "length" "4")])
5900
5901 (define_insn ""
5902   [(set (match_operand:SF 0 "register_operand" "=f")
5903         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))]
5904   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
5905   "fnegabs,sgl %1,%0"
5906   [(set_attr "type" "fpalu")
5907    (set_attr "length" "4")])
5908
5909 ;; Generating a fused multiply sequence is a win for this case as it will
5910 ;; reduce the latency for the fused case without impacting the plain
5911 ;; multiply case.
5912 ;;
5913 ;; Similar possibilities exist for fnegabs, shadd and other insns which
5914 ;; perform two operations with the result of the first feeding the second.
5915 (define_insn ""
5916   [(set (match_operand:DF 0 "register_operand" "=f")
5917         (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
5918                           (match_operand:DF 2 "register_operand" "f"))
5919                  (match_operand:DF 3 "register_operand" "f")))
5920    (set (match_operand:DF 4 "register_operand" "=&f")
5921         (mult:DF (match_dup 1) (match_dup 2)))]
5922   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
5923     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
5924           || reg_overlap_mentioned_p (operands[4], operands[2])))"
5925   "#"
5926   [(set_attr "type" "fpmuldbl")
5927    (set_attr "length" "8")])
5928
5929 ;; We want to split this up during scheduling since we want both insns
5930 ;; to schedule independently.
5931 (define_split
5932   [(set (match_operand:DF 0 "register_operand" "")
5933         (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "")
5934                           (match_operand:DF 2 "register_operand" ""))
5935                  (match_operand:DF 3 "register_operand" "")))
5936    (set (match_operand:DF 4 "register_operand" "")
5937         (mult:DF (match_dup 1) (match_dup 2)))]
5938   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5939   [(set (match_dup 4) (mult:DF (match_dup 1) (match_dup 2)))
5940    (set (match_dup 0) (plus:DF (mult:DF (match_dup 1) (match_dup 2))
5941                                (match_dup 3)))]
5942   "")
5943
5944 (define_insn ""
5945   [(set (match_operand:SF 0 "register_operand" "=f")
5946         (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
5947                           (match_operand:SF 2 "register_operand" "f"))
5948                  (match_operand:SF 3 "register_operand" "f")))
5949    (set (match_operand:SF 4 "register_operand" "=&f")
5950         (mult:SF (match_dup 1) (match_dup 2)))]
5951   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
5952     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
5953           || reg_overlap_mentioned_p (operands[4], operands[2])))"
5954   "#"
5955   [(set_attr "type" "fpmuldbl")
5956    (set_attr "length" "8")])
5957
5958 ;; We want to split this up during scheduling since we want both insns
5959 ;; to schedule independently.
5960 (define_split
5961   [(set (match_operand:SF 0 "register_operand" "")
5962         (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "")
5963                           (match_operand:SF 2 "register_operand" ""))
5964                  (match_operand:SF 3 "register_operand" "")))
5965    (set (match_operand:SF 4 "register_operand" "")
5966         (mult:SF (match_dup 1) (match_dup 2)))]
5967   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5968   [(set (match_dup 4) (mult:SF (match_dup 1) (match_dup 2)))
5969    (set (match_dup 0) (plus:SF (mult:SF (match_dup 1) (match_dup 2))
5970                                (match_dup 3)))]
5971   "")
5972
5973 ;; Negating a multiply can be faked by adding zero in a fused multiply-add
5974 ;; instruction.
5975 (define_insn ""
5976   [(set (match_operand:DF 0 "register_operand" "=f")
5977         (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
5978                          (match_operand:DF 2 "register_operand" "f"))))]
5979   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5980   "fmpynfadd,dbl %1,%2,%%fr0,%0"
5981   [(set_attr "type" "fpmuldbl")
5982    (set_attr "length" "4")])
5983
5984 (define_insn ""
5985   [(set (match_operand:SF 0 "register_operand" "=f")
5986         (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
5987                          (match_operand:SF 2 "register_operand" "f"))))]
5988   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5989   "fmpynfadd,sgl %1,%2,%%fr0,%0"
5990   [(set_attr "type" "fpmuldbl")
5991    (set_attr "length" "4")])
5992
5993 (define_insn ""
5994   [(set (match_operand:DF 0 "register_operand" "=f")
5995         (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
5996                          (match_operand:DF 2 "register_operand" "f"))))
5997    (set (match_operand:DF 3 "register_operand" "=&f")
5998         (mult:DF (match_dup 1) (match_dup 2)))]
5999   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6000     && ! (reg_overlap_mentioned_p (operands[3], operands[1])
6001           || reg_overlap_mentioned_p (operands[3], operands[2])))"
6002   "#"
6003   [(set_attr "type" "fpmuldbl")
6004    (set_attr "length" "8")])
6005
6006 (define_split
6007   [(set (match_operand:DF 0 "register_operand" "")
6008         (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "")
6009                          (match_operand:DF 2 "register_operand" ""))))
6010    (set (match_operand:DF 3 "register_operand" "")
6011         (mult:DF (match_dup 1) (match_dup 2)))]
6012   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6013   [(set (match_dup 3) (mult:DF (match_dup 1) (match_dup 2)))
6014    (set (match_dup 0) (neg:DF (mult:DF (match_dup 1) (match_dup 2))))]
6015   "")
6016
6017 (define_insn ""
6018   [(set (match_operand:SF 0 "register_operand" "=f")
6019         (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
6020                          (match_operand:SF 2 "register_operand" "f"))))
6021    (set (match_operand:SF 3 "register_operand" "=&f")
6022         (mult:SF (match_dup 1) (match_dup 2)))]
6023   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6024     && ! (reg_overlap_mentioned_p (operands[3], operands[1])
6025           || reg_overlap_mentioned_p (operands[3], operands[2])))"
6026   "#"
6027   [(set_attr "type" "fpmuldbl")
6028    (set_attr "length" "8")])
6029
6030 (define_split
6031   [(set (match_operand:SF 0 "register_operand" "")
6032         (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "")
6033                          (match_operand:SF 2 "register_operand" ""))))
6034    (set (match_operand:SF 3 "register_operand" "")
6035         (mult:SF (match_dup 1) (match_dup 2)))]
6036   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6037   [(set (match_dup 3) (mult:SF (match_dup 1) (match_dup 2)))
6038    (set (match_dup 0) (neg:SF (mult:SF (match_dup 1) (match_dup 2))))]
6039   "")
6040
6041 ;; Now fused multiplies with the result of the multiply negated.
6042 (define_insn ""
6043   [(set (match_operand:DF 0 "register_operand" "=f")
6044         (plus:DF (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
6045                                   (match_operand:DF 2 "register_operand" "f")))
6046                  (match_operand:DF 3 "register_operand" "f")))]
6047   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6048   "fmpynfadd,dbl %1,%2,%3,%0"
6049   [(set_attr "type" "fpmuldbl")
6050    (set_attr "length" "4")])
6051
6052 (define_insn ""
6053   [(set (match_operand:SF 0 "register_operand" "=f")
6054         (plus:SF (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
6055                          (match_operand:SF 2 "register_operand" "f")))
6056                  (match_operand:SF 3 "register_operand" "f")))]
6057   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6058   "fmpynfadd,sgl %1,%2,%3,%0"
6059   [(set_attr "type" "fpmuldbl")
6060    (set_attr "length" "4")])
6061
6062 (define_insn ""
6063   [(set (match_operand:DF 0 "register_operand" "=f")
6064         (plus:DF (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
6065                                   (match_operand:DF 2 "register_operand" "f")))
6066                  (match_operand:DF 3 "register_operand" "f")))
6067    (set (match_operand:DF 4 "register_operand" "=&f")
6068         (mult:DF (match_dup 1) (match_dup 2)))]
6069   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6070     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
6071           || reg_overlap_mentioned_p (operands[4], operands[2])))"
6072   "#"
6073   [(set_attr "type" "fpmuldbl")
6074    (set_attr "length" "8")])
6075
6076 (define_split
6077   [(set (match_operand:DF 0 "register_operand" "")
6078         (plus:DF (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "")
6079                                   (match_operand:DF 2 "register_operand" "")))
6080                  (match_operand:DF 3 "register_operand" "")))
6081    (set (match_operand:DF 4 "register_operand" "")
6082         (mult:DF (match_dup 1) (match_dup 2)))]
6083   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6084   [(set (match_dup 4) (mult:DF (match_dup 1) (match_dup 2)))
6085    (set (match_dup 0) (plus:DF (neg:DF (mult:DF (match_dup 1) (match_dup 2)))
6086                                (match_dup 3)))]
6087   "")
6088
6089 (define_insn ""
6090   [(set (match_operand:SF 0 "register_operand" "=f")
6091         (plus:SF (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
6092                                   (match_operand:SF 2 "register_operand" "f")))
6093                  (match_operand:SF 3 "register_operand" "f")))
6094    (set (match_operand:SF 4 "register_operand" "=&f")
6095         (mult:SF (match_dup 1) (match_dup 2)))]
6096   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6097     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
6098           || reg_overlap_mentioned_p (operands[4], operands[2])))"
6099   "#"
6100   [(set_attr "type" "fpmuldbl")
6101    (set_attr "length" "8")])
6102
6103 (define_split
6104   [(set (match_operand:SF 0 "register_operand" "")
6105         (plus:SF (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "")
6106                                   (match_operand:SF 2 "register_operand" "")))
6107                  (match_operand:SF 3 "register_operand" "")))
6108    (set (match_operand:SF 4 "register_operand" "")
6109         (mult:SF (match_dup 1) (match_dup 2)))]
6110   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6111   [(set (match_dup 4) (mult:SF (match_dup 1) (match_dup 2)))
6112    (set (match_dup 0) (plus:SF (neg:SF (mult:SF (match_dup 1) (match_dup 2)))
6113                                (match_dup 3)))]
6114   "")
6115
6116 (define_insn ""
6117   [(set (match_operand:DF 0 "register_operand" "=f")
6118         (minus:DF (match_operand:DF 3 "register_operand" "f")
6119                   (mult:DF (match_operand:DF 1 "register_operand" "f")
6120                            (match_operand:DF 2 "register_operand" "f"))))
6121    (set (match_operand:DF 4 "register_operand" "=&f")
6122         (mult:DF (match_dup 1) (match_dup 2)))]
6123   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6124     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
6125           || reg_overlap_mentioned_p (operands[4], operands[2])))"
6126   "#"
6127   [(set_attr "type" "fpmuldbl")
6128    (set_attr "length" "8")])
6129
6130 (define_split
6131   [(set (match_operand:DF 0 "register_operand" "")
6132         (minus:DF (match_operand:DF 3 "register_operand" "")
6133                   (mult:DF (match_operand:DF 1 "register_operand" "")
6134                            (match_operand:DF 2 "register_operand" ""))))
6135    (set (match_operand:DF 4 "register_operand" "")
6136         (mult:DF (match_dup 1) (match_dup 2)))]
6137   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6138   [(set (match_dup 4) (mult:DF (match_dup 1) (match_dup 2)))
6139    (set (match_dup 0) (minus:DF (match_dup 3)
6140                                 (mult:DF (match_dup 1) (match_dup 2))))]
6141   "")
6142
6143 (define_insn ""
6144   [(set (match_operand:SF 0 "register_operand" "=f")
6145         (minus:SF (match_operand:SF 3 "register_operand" "f")
6146                   (mult:SF (match_operand:SF 1 "register_operand" "f")
6147                            (match_operand:SF 2 "register_operand" "f"))))
6148    (set (match_operand:SF 4 "register_operand" "=&f")
6149         (mult:SF (match_dup 1) (match_dup 2)))]
6150   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6151     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
6152           || reg_overlap_mentioned_p (operands[4], operands[2])))"
6153   "#"
6154   [(set_attr "type" "fpmuldbl")
6155    (set_attr "length" "8")])
6156
6157 (define_split
6158   [(set (match_operand:SF 0 "register_operand" "")
6159         (minus:SF (match_operand:SF 3 "register_operand" "")
6160                   (mult:SF (match_operand:SF 1 "register_operand" "")
6161                            (match_operand:SF 2 "register_operand" ""))))
6162    (set (match_operand:SF 4 "register_operand" "")
6163         (mult:SF (match_dup 1) (match_dup 2)))]
6164   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6165   [(set (match_dup 4) (mult:SF (match_dup 1) (match_dup 2)))
6166    (set (match_dup 0) (minus:SF (match_dup 3)
6167                                 (mult:SF (match_dup 1) (match_dup 2))))]
6168   "")
6169
6170 (define_insn ""
6171   [(set (match_operand:DF 0 "register_operand" "=f")
6172         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))
6173    (set (match_operand:DF 2 "register_operand" "=&f") (abs:DF (match_dup 1)))]
6174   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6175     && ! reg_overlap_mentioned_p (operands[2], operands[1]))"
6176   "#"
6177   [(set_attr "type" "fpalu")
6178    (set_attr "length" "8")])
6179
6180 (define_split
6181   [(set (match_operand:DF 0 "register_operand" "")
6182         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" ""))))
6183    (set (match_operand:DF 2 "register_operand" "") (abs:DF (match_dup 1)))]
6184   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6185   [(set (match_dup 2) (abs:DF (match_dup 1)))
6186    (set (match_dup 0) (neg:DF (abs:DF (match_dup 1))))]
6187   "")
6188
6189 (define_insn ""
6190   [(set (match_operand:SF 0 "register_operand" "=f")
6191         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))
6192    (set (match_operand:SF 2 "register_operand" "=&f") (abs:SF (match_dup 1)))]
6193   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6194     && ! reg_overlap_mentioned_p (operands[2], operands[1]))"
6195   "#"
6196   [(set_attr "type" "fpalu")
6197    (set_attr "length" "8")])
6198
6199 (define_split
6200   [(set (match_operand:SF 0 "register_operand" "")
6201         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" ""))))
6202    (set (match_operand:SF 2 "register_operand" "") (abs:SF (match_dup 1)))]
6203   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6204   [(set (match_dup 2) (abs:SF (match_dup 1)))
6205    (set (match_dup 0) (neg:SF (abs:SF (match_dup 1))))]
6206   "")
6207 \f
6208 ;;- Shift instructions
6209
6210 ;; Optimized special case of shifting.
6211
6212 (define_insn ""
6213   [(set (match_operand:SI 0 "register_operand" "=r")
6214         (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
6215                      (const_int 24)))]
6216   ""
6217   "ldb%M1 %1,%0"
6218   [(set_attr "type" "load")
6219    (set_attr "length" "4")])
6220
6221 (define_insn ""
6222   [(set (match_operand:SI 0 "register_operand" "=r")
6223         (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
6224                      (const_int 16)))]
6225   ""
6226   "ldh%M1 %1,%0"
6227   [(set_attr "type" "load")
6228    (set_attr "length" "4")])
6229
6230 (define_insn ""
6231   [(set (match_operand:SI 0 "register_operand" "=r")
6232         (plus:SI (mult:SI (match_operand:SI 2 "register_operand" "r")
6233                           (match_operand:SI 3 "shadd_operand" ""))
6234                  (match_operand:SI 1 "register_operand" "r")))]
6235   ""
6236   "{sh%O3addl %2,%1,%0|shladd,l %2,%O3,%1,%0} "
6237   [(set_attr "type" "binary")
6238    (set_attr "length" "4")])
6239
6240 (define_insn ""
6241   [(set (match_operand:DI 0 "register_operand" "=r")
6242         (plus:DI (mult:DI (match_operand:DI 2 "register_operand" "r")
6243                           (match_operand:DI 3 "shadd_operand" ""))
6244                  (match_operand:DI 1 "register_operand" "r")))]
6245   "TARGET_64BIT"
6246   "shladd,l %2,%O3,%1,%0"
6247   [(set_attr "type" "binary")
6248    (set_attr "length" "4")])
6249
6250 (define_expand "ashlsi3"
6251   [(set (match_operand:SI 0 "register_operand" "")
6252         (ashift:SI (match_operand:SI 1 "lhs_lshift_operand" "")
6253                    (match_operand:SI 2 "arith32_operand" "")))]
6254   ""
6255   "
6256 {
6257   if (GET_CODE (operands[2]) != CONST_INT)
6258     {
6259       rtx temp = gen_reg_rtx (SImode);
6260       emit_insn (gen_subsi3 (temp, GEN_INT (31), operands[2]));
6261       if (GET_CODE (operands[1]) == CONST_INT)
6262         emit_insn (gen_zvdep_imm32 (operands[0], operands[1], temp));
6263       else
6264         emit_insn (gen_zvdep32 (operands[0], operands[1], temp));
6265       DONE;
6266     }
6267   /* Make sure both inputs are not constants,
6268      there are no patterns for that.  */
6269   operands[1] = force_reg (SImode, operands[1]);
6270 }")
6271
6272 (define_insn ""
6273   [(set (match_operand:SI 0 "register_operand" "=r")
6274         (ashift:SI (match_operand:SI 1 "register_operand" "r")
6275                    (match_operand:SI 2 "const_int_operand" "n")))]
6276   ""
6277   "{zdep|depw,z} %1,%P2,%L2,%0"
6278   [(set_attr "type" "shift")
6279    (set_attr "length" "4")])
6280
6281 ; Match cases of op1 a CONST_INT here that zvdep_imm32 doesn't handle.
6282 ; Doing it like this makes slightly better code since reload can
6283 ; replace a register with a known value in range -16..15 with a
6284 ; constant.  Ideally, we would like to merge zvdep32 and zvdep_imm32,
6285 ; but since we have no more CONST_OK... characters, that is not
6286 ; possible.
6287 (define_insn "zvdep32"
6288   [(set (match_operand:SI 0 "register_operand" "=r,r")
6289         (ashift:SI (match_operand:SI 1 "arith5_operand" "r,L")
6290                    (minus:SI (const_int 31)
6291                              (match_operand:SI 2 "register_operand" "q,q"))))]
6292   ""
6293   "@
6294    {zvdep %1,32,%0|depw,z %1,%%sar,32,%0}
6295    {zvdepi %1,32,%0|depwi,z %1,%%sar,32,%0}"
6296   [(set_attr "type" "shift,shift")
6297    (set_attr "length" "4,4")])
6298
6299 (define_insn "zvdep_imm32"
6300   [(set (match_operand:SI 0 "register_operand" "=r")
6301         (ashift:SI (match_operand:SI 1 "lhs_lshift_cint_operand" "")
6302                    (minus:SI (const_int 31)
6303                              (match_operand:SI 2 "register_operand" "q"))))]
6304   ""
6305   "*
6306 {
6307   int x = INTVAL (operands[1]);
6308   operands[2] = GEN_INT (4 + exact_log2 ((x >> 4) + 1));
6309   operands[1] = GEN_INT ((x & 0xf) - 0x10);
6310   return \"{zvdepi %1,%2,%0|depwi,z %1,%%sar,%2,%0}\";
6311 }"
6312   [(set_attr "type" "shift")
6313    (set_attr "length" "4")])
6314
6315 (define_insn "vdepi_ior"
6316   [(set (match_operand:SI 0 "register_operand" "=r")
6317         (ior:SI (ashift:SI (match_operand:SI 1 "const_int_operand" "")
6318                            (minus:SI (const_int 31)
6319                                      (match_operand:SI 2 "register_operand" "q")))
6320                 (match_operand:SI 3 "register_operand" "0")))]
6321   ; accept ...0001...1, can this be generalized?
6322   "exact_log2 (INTVAL (operands[1]) + 1) >= 0"
6323   "*
6324 {
6325   int x = INTVAL (operands[1]);
6326   operands[2] = GEN_INT (exact_log2 (x + 1));
6327   return \"{vdepi -1,%2,%0|depwi -1,%%sar,%2,%0}\";
6328 }"
6329   [(set_attr "type" "shift")
6330    (set_attr "length" "4")])
6331
6332 (define_insn "vdepi_and"
6333   [(set (match_operand:SI 0 "register_operand" "=r")
6334         (and:SI (rotate:SI (match_operand:SI 1 "const_int_operand" "")
6335                            (minus:SI (const_int 31)
6336                                      (match_operand:SI 2 "register_operand" "q")))
6337                 (match_operand:SI 3 "register_operand" "0")))]
6338   ; this can be generalized...!
6339   "INTVAL (operands[1]) == -2"
6340   "*
6341 {
6342   int x = INTVAL (operands[1]);
6343   operands[2] = GEN_INT (exact_log2 ((~x) + 1));
6344   return \"{vdepi 0,%2,%0|depwi 0,%%sar,%2,%0}\";
6345 }"
6346   [(set_attr "type" "shift")
6347    (set_attr "length" "4")])
6348
6349 (define_expand "ashldi3"
6350   [(set (match_operand:DI 0 "register_operand" "")
6351         (ashift:DI (match_operand:DI 1 "lhs_lshift_operand" "")
6352                    (match_operand:DI 2 "arith32_operand" "")))]
6353   "TARGET_64BIT"
6354   "
6355 {
6356   if (GET_CODE (operands[2]) != CONST_INT)
6357     {
6358       rtx temp = gen_reg_rtx (DImode);
6359       emit_insn (gen_subdi3 (temp, GEN_INT (63), operands[2]));
6360       if (GET_CODE (operands[1]) == CONST_INT)
6361         emit_insn (gen_zvdep_imm64 (operands[0], operands[1], temp));
6362       else
6363         emit_insn (gen_zvdep64 (operands[0], operands[1], temp));
6364       DONE;
6365     }
6366   /* Make sure both inputs are not constants,
6367      there are no patterns for that.  */
6368   operands[1] = force_reg (DImode, operands[1]);
6369 }")
6370
6371 (define_insn ""
6372   [(set (match_operand:DI 0 "register_operand" "=r")
6373         (ashift:DI (match_operand:DI 1 "register_operand" "r")
6374                    (match_operand:DI 2 "const_int_operand" "n")))]
6375   "TARGET_64BIT"
6376   "depd,z %1,%p2,%Q2,%0"
6377   [(set_attr "type" "shift")
6378    (set_attr "length" "4")])
6379
6380 ; Match cases of op1 a CONST_INT here that zvdep_imm64 doesn't handle.
6381 ; Doing it like this makes slightly better code since reload can
6382 ; replace a register with a known value in range -16..15 with a
6383 ; constant.  Ideally, we would like to merge zvdep64 and zvdep_imm64,
6384 ; but since we have no more CONST_OK... characters, that is not
6385 ; possible.
6386 (define_insn "zvdep64"
6387   [(set (match_operand:DI 0 "register_operand" "=r,r")
6388         (ashift:DI (match_operand:DI 1 "arith5_operand" "r,L")
6389                    (minus:DI (const_int 63)
6390                              (match_operand:DI 2 "register_operand" "q,q"))))]
6391   "TARGET_64BIT"
6392   "@
6393    depd,z %1,%%sar,64,%0
6394    depdi,z %1,%%sar,64,%0"
6395   [(set_attr "type" "shift,shift")
6396    (set_attr "length" "4,4")])
6397
6398 (define_insn "zvdep_imm64"
6399   [(set (match_operand:DI 0 "register_operand" "=r")
6400         (ashift:DI (match_operand:DI 1 "lhs_lshift_cint_operand" "")
6401                    (minus:DI (const_int 63)
6402                              (match_operand:DI 2 "register_operand" "q"))))]
6403   "TARGET_64BIT"
6404   "*
6405 {
6406   int x = INTVAL (operands[1]);
6407   operands[2] = GEN_INT (4 + exact_log2 ((x >> 4) + 1));
6408   operands[1] = GEN_INT ((x & 0x1f) - 0x20);
6409   return \"depdi,z %1,%%sar,%2,%0\";
6410 }"
6411   [(set_attr "type" "shift")
6412    (set_attr "length" "4")])
6413
6414 (define_insn ""
6415   [(set (match_operand:DI 0 "register_operand" "=r")
6416         (ior:DI (ashift:DI (match_operand:DI 1 "const_int_operand" "")
6417                            (minus:DI (const_int 63)
6418                                      (match_operand:DI 2 "register_operand" "q")))
6419                 (match_operand:DI 3 "register_operand" "0")))]
6420   ; accept ...0001...1, can this be generalized?
6421   "TARGET_64BIT && exact_log2 (INTVAL (operands[1]) + 1) >= 0"
6422   "*
6423 {
6424   int x = INTVAL (operands[1]);
6425   operands[2] = GEN_INT (exact_log2 (x + 1));
6426   return \"depdi -1,%%sar,%2,%0\";
6427 }"
6428   [(set_attr "type" "shift")
6429    (set_attr "length" "4")])
6430
6431 (define_insn ""
6432   [(set (match_operand:DI 0 "register_operand" "=r")
6433         (and:DI (rotate:DI (match_operand:DI 1 "const_int_operand" "")
6434                            (minus:DI (const_int 63)
6435                                      (match_operand:DI 2 "register_operand" "q")))
6436                 (match_operand:DI 3 "register_operand" "0")))]
6437   ; this can be generalized...!
6438   "TARGET_64BIT && INTVAL (operands[1]) == -2"
6439   "*
6440 {
6441   int x = INTVAL (operands[1]);
6442   operands[2] = GEN_INT (exact_log2 ((~x) + 1));
6443   return \"depdi 0,%%sar,%2,%0\";
6444 }"
6445   [(set_attr "type" "shift")
6446    (set_attr "length" "4")])
6447
6448 (define_expand "ashrsi3"
6449   [(set (match_operand:SI 0 "register_operand" "")
6450         (ashiftrt:SI (match_operand:SI 1 "register_operand" "")
6451                      (match_operand:SI 2 "arith32_operand" "")))]
6452   ""
6453   "
6454 {
6455   if (GET_CODE (operands[2]) != CONST_INT)
6456     {
6457       rtx temp = gen_reg_rtx (SImode);
6458       emit_insn (gen_subsi3 (temp, GEN_INT (31), operands[2]));
6459       emit_insn (gen_vextrs32 (operands[0], operands[1], temp));
6460       DONE;
6461     }
6462 }")
6463
6464 (define_insn ""
6465   [(set (match_operand:SI 0 "register_operand" "=r")
6466         (ashiftrt:SI (match_operand:SI 1 "register_operand" "r")
6467                      (match_operand:SI 2 "const_int_operand" "n")))]
6468   ""
6469   "{extrs|extrw,s} %1,%P2,%L2,%0"
6470   [(set_attr "type" "shift")
6471    (set_attr "length" "4")])
6472
6473 (define_insn "vextrs32"
6474   [(set (match_operand:SI 0 "register_operand" "=r")
6475         (ashiftrt:SI (match_operand:SI 1 "register_operand" "r")
6476                      (minus:SI (const_int 31)
6477                                (match_operand:SI 2 "register_operand" "q"))))]
6478   ""
6479   "{vextrs %1,32,%0|extrw,s %1,%%sar,32,%0}"
6480   [(set_attr "type" "shift")
6481    (set_attr "length" "4")])
6482
6483 (define_expand "ashrdi3"
6484   [(set (match_operand:DI 0 "register_operand" "")
6485         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
6486                      (match_operand:DI 2 "arith32_operand" "")))]
6487   "TARGET_64BIT"
6488   "
6489 {
6490   if (GET_CODE (operands[2]) != CONST_INT)
6491     {
6492       rtx temp = gen_reg_rtx (DImode);
6493       emit_insn (gen_subdi3 (temp, GEN_INT (63), operands[2]));
6494       emit_insn (gen_vextrs64 (operands[0], operands[1], temp));
6495       DONE;
6496     }
6497 }")
6498
6499 (define_insn ""
6500   [(set (match_operand:DI 0 "register_operand" "=r")
6501         (ashiftrt:DI (match_operand:DI 1 "register_operand" "r")
6502                      (match_operand:DI 2 "const_int_operand" "n")))]
6503   "TARGET_64BIT"
6504   "extrd,s %1,%p2,%Q2,%0"
6505   [(set_attr "type" "shift")
6506    (set_attr "length" "4")])
6507
6508 (define_insn "vextrs64"
6509   [(set (match_operand:DI 0 "register_operand" "=r")
6510         (ashiftrt:DI (match_operand:DI 1 "register_operand" "r")
6511                      (minus:DI (const_int 63)
6512                                (match_operand:DI 2 "register_operand" "q"))))]
6513   "TARGET_64BIT"
6514   "extrd,s %1,%%sar,64,%0"
6515   [(set_attr "type" "shift")
6516    (set_attr "length" "4")])
6517
6518 (define_insn "lshrsi3"
6519   [(set (match_operand:SI 0 "register_operand" "=r,r")
6520         (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
6521                      (match_operand:SI 2 "arith32_operand" "q,n")))]
6522   ""
6523   "@
6524    {vshd %%r0,%1,%0|shrpw %%r0,%1,%%sar,%0}
6525    {extru|extrw,u} %1,%P2,%L2,%0"
6526   [(set_attr "type" "shift")
6527    (set_attr "length" "4")])
6528
6529 (define_insn "lshrdi3"
6530   [(set (match_operand:DI 0 "register_operand" "=r,r")
6531         (lshiftrt:DI (match_operand:DI 1 "register_operand" "r,r")
6532                      (match_operand:DI 2 "arith32_operand" "q,n")))]
6533   "TARGET_64BIT"
6534   "@
6535    shrpd %%r0,%1,%%sar,%0
6536    extrd,u %1,%p2,%Q2,%0"
6537   [(set_attr "type" "shift")
6538    (set_attr "length" "4")])
6539
6540 (define_insn "rotrsi3"
6541   [(set (match_operand:SI 0 "register_operand" "=r,r")
6542         (rotatert:SI (match_operand:SI 1 "register_operand" "r,r")
6543                      (match_operand:SI 2 "arith32_operand" "q,n")))]
6544   ""
6545   "*
6546 {
6547   if (GET_CODE (operands[2]) == CONST_INT)
6548     {
6549       operands[2] = GEN_INT (INTVAL (operands[2]) & 31);
6550       return \"{shd|shrpw} %1,%1,%2,%0\";
6551     }
6552   else
6553     return \"{vshd %1,%1,%0|shrpw %1,%1,%%sar,%0}\";
6554 }"
6555   [(set_attr "type" "shift")
6556    (set_attr "length" "4")])
6557
6558 (define_expand "rotlsi3"
6559   [(set (match_operand:SI 0 "register_operand" "")
6560         (rotate:SI (match_operand:SI 1 "register_operand" "")
6561                    (match_operand:SI 2 "arith32_operand" "")))]
6562   ""
6563   "
6564 {
6565   if (GET_CODE (operands[2]) != CONST_INT)
6566     {
6567       rtx temp = gen_reg_rtx (SImode);
6568       emit_insn (gen_subsi3 (temp, GEN_INT (32), operands[2]));
6569       emit_insn (gen_rotrsi3 (operands[0], operands[1], temp));
6570       DONE;
6571     }
6572   /* Else expand normally.  */
6573 }")
6574
6575 (define_insn ""
6576   [(set (match_operand:SI 0 "register_operand" "=r")
6577         (rotate:SI (match_operand:SI 1 "register_operand" "r")
6578                    (match_operand:SI 2 "const_int_operand" "n")))]
6579   ""
6580   "*
6581 {
6582   operands[2] = GEN_INT ((32 - INTVAL (operands[2])) & 31);
6583   return \"{shd|shrpw} %1,%1,%2,%0\";
6584 }"
6585   [(set_attr "type" "shift")
6586    (set_attr "length" "4")])
6587
6588 (define_insn ""
6589   [(set (match_operand:SI 0 "register_operand" "=r")
6590         (match_operator:SI 5 "plus_xor_ior_operator"
6591           [(ashift:SI (match_operand:SI 1 "register_operand" "r")
6592                       (match_operand:SI 3 "const_int_operand" "n"))
6593            (lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
6594                         (match_operand:SI 4 "const_int_operand" "n"))]))]
6595   "INTVAL (operands[3]) + INTVAL (operands[4]) == 32"
6596   "{shd|shrpw} %1,%2,%4,%0"
6597   [(set_attr "type" "shift")
6598    (set_attr "length" "4")])
6599
6600 (define_insn ""
6601   [(set (match_operand:SI 0 "register_operand" "=r")
6602         (match_operator:SI 5 "plus_xor_ior_operator"
6603           [(lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
6604                         (match_operand:SI 4 "const_int_operand" "n"))
6605            (ashift:SI (match_operand:SI 1 "register_operand" "r")
6606                       (match_operand:SI 3 "const_int_operand" "n"))]))]
6607   "INTVAL (operands[3]) + INTVAL (operands[4]) == 32"
6608   "{shd|shrpw} %1,%2,%4,%0"
6609   [(set_attr "type" "shift")
6610    (set_attr "length" "4")])
6611
6612 (define_insn ""
6613   [(set (match_operand:SI 0 "register_operand" "=r")
6614         (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
6615                            (match_operand:SI 2 "const_int_operand" ""))
6616                 (match_operand:SI 3 "const_int_operand" "")))]
6617   "exact_log2 (1 + (INTVAL (operands[3]) >> (INTVAL (operands[2]) & 31))) >= 0"
6618   "*
6619 {
6620   int cnt = INTVAL (operands[2]) & 31;
6621   operands[3] = GEN_INT (exact_log2 (1 + (INTVAL (operands[3]) >> cnt)));
6622   operands[2] = GEN_INT (31 - cnt);
6623   return \"{zdep|depw,z} %1,%2,%3,%0\";
6624 }"
6625   [(set_attr "type" "shift")
6626    (set_attr "length" "4")])
6627 \f
6628 ;; Unconditional and other jump instructions.
6629
6630 ;; This can only be used in a leaf function, so we do
6631 ;; not need to use the PIC register when generating PIC code.
6632 (define_insn "return"
6633   [(return)
6634    (use (reg:SI 2))
6635    (const_int 0)]
6636   "hppa_can_use_return_insn_p ()"
6637   "*
6638 {
6639   if (TARGET_PA_20)
6640     return \"bve%* (%%r2)\";
6641   return \"bv%* %%r0(%%r2)\";
6642 }"
6643   [(set_attr "type" "branch")
6644    (set_attr "length" "4")])
6645
6646 ;; Emit a different pattern for functions which have non-trivial
6647 ;; epilogues so as not to confuse jump and reorg.
6648 (define_insn "return_internal"
6649   [(return)
6650    (use (reg:SI 2))
6651    (const_int 1)]
6652   ""
6653   "*
6654 {
6655   if (TARGET_PA_20)
6656     return \"bve%* (%%r2)\";
6657   return \"bv%* %%r0(%%r2)\";
6658 }"
6659   [(set_attr "type" "branch")
6660    (set_attr "length" "4")])
6661
6662 ;; This is used for eh returns which bypass the return stub.
6663 (define_insn "return_external_pic"
6664   [(return)
6665    (clobber (reg:SI 1))
6666    (use (reg:SI 2))]
6667   "!TARGET_NO_SPACE_REGS
6668    && !TARGET_PA_20
6669    && flag_pic && current_function_calls_eh_return"
6670   "ldsid (%%sr0,%%r2),%%r1\;mtsp %%r1,%%sr0\;be%* 0(%%sr0,%%r2)"
6671   [(set_attr "type" "branch")
6672    (set_attr "length" "12")])
6673
6674 (define_expand "prologue"
6675   [(const_int 0)]
6676   ""
6677   "hppa_expand_prologue ();DONE;")
6678
6679 (define_expand "sibcall_epilogue"
6680   [(return)]
6681   ""
6682   "
6683 {
6684   hppa_expand_epilogue ();
6685   DONE;
6686 }")
6687
6688 (define_expand "epilogue"
6689   [(return)]
6690   ""
6691   "
6692 {
6693   /* Try to use the trivial return first.  Else use the full
6694      epilogue.  */
6695   if (hppa_can_use_return_insn_p ())
6696     emit_jump_insn (gen_return ());
6697   else
6698     {
6699       rtx x;
6700
6701       hppa_expand_epilogue ();
6702
6703       /* EH returns bypass the normal return stub.  Thus, we must do an
6704          interspace branch to return from functions that call eh_return.
6705          This is only a problem for returns from shared code on ports
6706          using space registers.  */
6707       if (!TARGET_NO_SPACE_REGS
6708           && !TARGET_PA_20
6709           && flag_pic && current_function_calls_eh_return)
6710         x = gen_return_external_pic ();
6711       else
6712         x = gen_return_internal ();
6713
6714       emit_jump_insn (x);
6715     }
6716   DONE;
6717 }")
6718
6719 ; Used by hppa_profile_hook to load the starting address of the current
6720 ; function; operand 1 contains the address of the label in operand 3
6721 (define_insn "load_offset_label_address"
6722   [(set (match_operand:SI 0 "register_operand" "=r")
6723         (plus:SI (match_operand:SI 1 "register_operand" "r")
6724                  (minus:SI (match_operand:SI 2 "" "")
6725                            (label_ref:SI (match_operand 3 "" "")))))]
6726   ""
6727   "ldo %2-%l3(%1),%0"
6728   [(set_attr "type" "multi")
6729    (set_attr "length" "4")])
6730
6731 ; Output a code label and load its address.
6732 (define_insn "lcla1"
6733   [(set (match_operand:SI 0 "register_operand" "=r")
6734         (label_ref:SI (match_operand 1 "" "")))
6735    (const_int 0)]
6736   "!TARGET_PA_20"
6737   "*
6738 {
6739   output_asm_insn (\"bl .+8,%0\;depi 0,31,2,%0\", operands);
6740   (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
6741                                      CODE_LABEL_NUMBER (operands[1]));
6742   return \"\";
6743 }"
6744   [(set_attr "type" "multi")
6745    (set_attr "length" "8")])
6746
6747 (define_insn "lcla2"
6748   [(set (match_operand:SI 0 "register_operand" "=r")
6749         (label_ref:SI (match_operand 1 "" "")))
6750    (const_int 0)]
6751   "TARGET_PA_20"
6752   "*
6753 {
6754   (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
6755                                      CODE_LABEL_NUMBER (operands[1]));
6756   return \"mfia %0\";
6757 }"
6758   [(set_attr "type" "move")
6759    (set_attr "length" "4")])
6760
6761 (define_insn "blockage"
6762   [(unspec_volatile [(const_int 2)] 0)]
6763   ""
6764   ""
6765   [(set_attr "length" "0")])
6766
6767 (define_insn "jump"
6768   [(set (pc) (label_ref (match_operand 0 "" "")))]
6769   ""
6770   "*
6771 {
6772   /* An unconditional branch which can reach its target.  */
6773   if (get_attr_length (insn) != 24
6774       && get_attr_length (insn) != 16)
6775     return \"b%* %l0\";
6776
6777   return output_lbranch (operands[0], insn);
6778 }"
6779   [(set_attr "type" "uncond_branch")
6780    (set_attr "pa_combine_type" "uncond_branch")
6781    (set (attr "length")
6782     (cond [(eq (symbol_ref "jump_in_call_delay (insn)") (const_int 1))
6783            (if_then_else (lt (abs (minus (match_dup 0)
6784                                          (plus (pc) (const_int 8))))
6785                              (const_int 8184))
6786                          (const_int 4)
6787                          (const_int 8))
6788            (ge (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
6789                (const_int 262100))
6790            (if_then_else (eq (symbol_ref "flag_pic") (const_int 0))
6791                          (const_int 16)
6792                          (const_int 24))]
6793           (const_int 4)))])
6794
6795 ;;; Hope this is only within a function...
6796 (define_insn "indirect_jump"
6797   [(set (pc) (match_operand 0 "register_operand" "r"))]
6798   "GET_MODE (operands[0]) == word_mode"
6799   "bv%* %%r0(%0)"
6800   [(set_attr "type" "branch")
6801    (set_attr "length" "4")])
6802
6803 ;;; This jump is used in branch tables where the insn length is fixed.
6804 ;;; The length of this insn is adjusted if the delay slot is not filled.
6805 (define_insn "short_jump"
6806   [(set (pc) (label_ref (match_operand 0 "" "")))
6807    (const_int 0)]
6808   ""
6809   "b%* %l0%#"
6810   [(set_attr "type" "btable_branch")
6811    (set_attr "length" "4")])
6812
6813 ;; Subroutines of "casesi".
6814 ;; operand 0 is index
6815 ;; operand 1 is the minimum bound
6816 ;; operand 2 is the maximum bound - minimum bound + 1
6817 ;; operand 3 is CODE_LABEL for the table;
6818 ;; operand 4 is the CODE_LABEL to go to if index out of range.
6819
6820 (define_expand "casesi"
6821   [(match_operand:SI 0 "general_operand" "")
6822    (match_operand:SI 1 "const_int_operand" "")
6823    (match_operand:SI 2 "const_int_operand" "")
6824    (match_operand 3 "" "")
6825    (match_operand 4 "" "")]
6826   ""
6827   "
6828 {
6829   if (GET_CODE (operands[0]) != REG)
6830     operands[0] = force_reg (SImode, operands[0]);
6831
6832   if (operands[1] != const0_rtx)
6833     {
6834       rtx index = gen_reg_rtx (SImode);
6835
6836       operands[1] = GEN_INT (-INTVAL (operands[1]));
6837       if (!INT_14_BITS (operands[1]))
6838         operands[1] = force_reg (SImode, operands[1]);
6839       emit_insn (gen_addsi3 (index, operands[0], operands[1]));
6840       operands[0] = index;
6841     }
6842
6843   /* In 64bit mode we must make sure to wipe the upper bits of the register
6844      just in case the addition overflowed or we had random bits in the
6845      high part of the register.  */
6846   if (TARGET_64BIT)
6847     {
6848       rtx index = gen_reg_rtx (DImode);
6849
6850       emit_insn (gen_extendsidi2 (index, operands[0]));
6851       operands[0] = gen_rtx_SUBREG (SImode, index, 4);
6852     }
6853
6854   if (!INT_5_BITS (operands[2]))
6855     operands[2] = force_reg (SImode, operands[2]);
6856
6857   /* This branch prevents us finding an insn for the delay slot of the
6858      following vectored branch.  It might be possible to use the delay
6859      slot if an index value of -1 was used to transfer to the out-of-range
6860      label.  In order to do this, we would have to output the -1 vector
6861      element after the delay insn.  The casesi output code would have to
6862      check if the casesi insn is in a delay branch sequence and output
6863      the delay insn if one is found.  If this was done, then it might
6864      then be worthwhile to split the casesi patterns to improve scheduling.
6865      However, it's not clear that all this extra complexity is worth
6866      the effort.  */
6867   emit_insn (gen_cmpsi (operands[0], operands[2]));
6868   emit_jump_insn (gen_bgtu (operands[4]));
6869
6870   if (TARGET_BIG_SWITCH)
6871     {
6872       if (TARGET_64BIT)
6873         {
6874           rtx tmp1 = gen_reg_rtx (DImode);
6875           rtx tmp2 = gen_reg_rtx (DImode);
6876
6877           emit_jump_insn (gen_casesi64p (operands[0], operands[3],
6878                                          tmp1, tmp2));
6879         }
6880       else
6881         {
6882           rtx tmp1 = gen_reg_rtx (SImode);
6883
6884           if (flag_pic)
6885             {
6886               rtx tmp2 = gen_reg_rtx (SImode);
6887
6888               emit_jump_insn (gen_casesi32p (operands[0], operands[3],
6889                                              tmp1, tmp2));
6890             }
6891           else
6892             emit_jump_insn (gen_casesi32 (operands[0], operands[3], tmp1));
6893         }
6894     }
6895   else
6896     emit_jump_insn (gen_casesi0 (operands[0], operands[3]));
6897   DONE;
6898 }")
6899
6900 ;;; The rtl for this pattern doesn't accurately describe what the insn
6901 ;;; actually does, particularly when case-vector elements are exploded
6902 ;;; in pa_reorg.  However, the initial SET in these patterns must show
6903 ;;; the connection of the insn to the following jump table.
6904 (define_insn "casesi0"
6905   [(set (pc) (mem:SI (plus:SI
6906                        (mult:SI (match_operand:SI 0 "register_operand" "r")
6907                                 (const_int 4))
6908                        (label_ref (match_operand 1 "" "")))))]
6909   ""
6910   "blr,n %0,%%r0\;nop"
6911   [(set_attr "type" "multi")
6912    (set_attr "length" "8")])
6913
6914 ;;; 32-bit code, absolute branch table.
6915 (define_insn "casesi32"
6916   [(set (pc) (mem:SI (plus:SI
6917                        (mult:SI (match_operand:SI 0 "register_operand" "r")
6918                                 (const_int 4))
6919                        (label_ref (match_operand 1 "" "")))))
6920    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
6921   "!TARGET_64BIT && TARGET_BIG_SWITCH"
6922   "ldil L'%l1,%2\;ldo R'%l1(%2),%2\;{ldwx|ldw},s %0(%2),%2\;bv,n %%r0(%2)"
6923   [(set_attr "type" "multi")
6924    (set_attr "length" "16")])
6925
6926 ;;; 32-bit code, relative branch table.
6927 (define_insn "casesi32p"
6928   [(set (pc) (mem:SI (plus:SI
6929                        (mult:SI (match_operand:SI 0 "register_operand" "r")
6930                                 (const_int 4))
6931                        (label_ref (match_operand 1 "" "")))))
6932    (clobber (match_operand:SI 2 "register_operand" "=&a"))
6933    (clobber (match_operand:SI 3 "register_operand" "=&r"))]
6934   "!TARGET_64BIT && TARGET_BIG_SWITCH"
6935   "{bl .+8,%2\;depi 0,31,2,%2|mfia %2}\;ldo {16|20}(%2),%2\;\
6936 {ldwx|ldw},s %0(%2),%3\;{addl|add,l} %2,%3,%3\;bv,n %%r0(%3)"
6937   [(set_attr "type" "multi")
6938    (set (attr "length")
6939      (if_then_else (ne (symbol_ref "TARGET_PA_20") (const_int 0))
6940         (const_int 20)
6941         (const_int 24)))])
6942
6943 ;;; 64-bit code, 32-bit relative branch table.
6944 (define_insn "casesi64p"
6945   [(set (pc) (mem:DI (plus:DI
6946                        (mult:DI (sign_extend:DI
6947                                   (match_operand:SI 0 "register_operand" "r"))
6948                                 (const_int 8))
6949                        (label_ref (match_operand 1 "" "")))))
6950    (clobber (match_operand:DI 2 "register_operand" "=&r"))
6951    (clobber (match_operand:DI 3 "register_operand" "=&r"))]
6952   "TARGET_64BIT && TARGET_BIG_SWITCH"
6953   "mfia %2\;ldo 24(%2),%2\;ldw,s %0(%2),%3\;extrd,s %3,63,32,%3\;\
6954 add,l %2,%3,%3\;bv,n %%r0(%3)"
6955   [(set_attr "type" "multi")
6956    (set_attr "length" "24")])
6957
6958
6959 ;; Call patterns.
6960 ;;- jump to subroutine
6961
6962 (define_expand "call"
6963   [(parallel [(call (match_operand:SI 0 "" "")
6964                     (match_operand 1 "" ""))
6965               (clobber (reg:SI 2))])]
6966   ""
6967   "
6968 {
6969   rtx op, call_insn;
6970   rtx nb = operands[1];
6971
6972   if (TARGET_PORTABLE_RUNTIME)
6973     op = force_reg (SImode, XEXP (operands[0], 0));
6974   else
6975     op = XEXP (operands[0], 0);
6976
6977   if (TARGET_64BIT)
6978     {
6979       if (!virtuals_instantiated)
6980         emit_move_insn (arg_pointer_rtx,
6981                         gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
6982                                       GEN_INT (64)));
6983       else
6984         {
6985           /* The loop pass can generate new libcalls after the virtual
6986              registers are instantiated when fpregs are disabled because
6987              the only method that we have for doing DImode multiplication
6988              is with a libcall.  This could be trouble if we haven't
6989              allocated enough space for the outgoing arguments.  */
6990           if (INTVAL (nb) > current_function_outgoing_args_size)
6991             abort ();
6992
6993           emit_move_insn (arg_pointer_rtx,
6994                           gen_rtx_PLUS (word_mode, stack_pointer_rtx,
6995                                         GEN_INT (STACK_POINTER_OFFSET + 64)));
6996         }
6997     }
6998
6999   /* Use two different patterns for calls to explicitly named functions
7000      and calls through function pointers.  This is necessary as these two
7001      types of calls use different calling conventions, and CSE might try
7002      to change the named call into an indirect call in some cases (using
7003      two patterns keeps CSE from performing this optimization).
7004      
7005      We now use even more call patterns as there was a subtle bug in
7006      attempting to restore the pic register after a call using a simple
7007      move insn.  During reload, a instruction involving a pseudo register
7008      with no explicit dependence on the PIC register can be converted
7009      to an equivalent load from memory using the PIC register.  If we
7010      emit a simple move to restore the PIC register in the initial rtl
7011      generation, then it can potentially be repositioned during scheduling.
7012      and an instruction that eventually uses the PIC register may end up
7013      between the call and the PIC register restore.
7014      
7015      This only worked because there is a post call group of instructions
7016      that are scheduled with the call.  These instructions are included
7017      in the same basic block as the call.  However, calls can throw in
7018      C++ code and a basic block has to terminate at the call if the call
7019      can throw.  This results in the PIC register restore being scheduled
7020      independently from the call.  So, we now hide the save and restore
7021      of the PIC register in the call pattern until after reload.  Then,
7022      we split the moves out.  A small side benefit is that we now don't
7023      need to have a use of the PIC register in the return pattern and
7024      the final save/restore operation is not needed.
7025      
7026      I elected to just clobber %r4 in the PIC patterns and use it instead
7027      of trying to force hppa_pic_save_rtx () to a callee saved register.
7028      This might have required a new register class and constraint.  It
7029      was also simpler to just handle the restore from a register than a
7030      generic pseudo.  */
7031   if (TARGET_64BIT)
7032     {
7033       if (GET_CODE (op) == SYMBOL_REF)
7034         call_insn = emit_call_insn (gen_call_symref_64bit (op, nb));
7035       else
7036         {
7037           op = force_reg (word_mode, op);
7038           call_insn = emit_call_insn (gen_call_reg_64bit (op, nb));
7039         }
7040     }
7041   else
7042     {
7043       if (GET_CODE (op) == SYMBOL_REF)
7044         {
7045           if (flag_pic)
7046             call_insn = emit_call_insn (gen_call_symref_pic (op, nb));
7047           else
7048             call_insn = emit_call_insn (gen_call_symref (op, nb));
7049         }
7050       else
7051         {
7052           rtx tmpreg = gen_rtx_REG (word_mode, 22);
7053
7054           emit_move_insn (tmpreg, force_reg (word_mode, op));
7055           if (flag_pic)
7056             call_insn = emit_call_insn (gen_call_reg_pic (nb));
7057           else
7058             call_insn = emit_call_insn (gen_call_reg (nb));
7059         }
7060     }
7061
7062   DONE;
7063 }")
7064
7065 ;; We use function calls to set the attribute length of calls and millicode
7066 ;; calls.  This is necessary because of the large variety of call sequences.
7067 ;; Implementing the calculation in rtl is difficult as well as ugly.  As
7068 ;; we need the same calculation in several places, maintenance becomes a
7069 ;; nightmare.
7070 ;;
7071 ;; However, this has a subtle impact on branch shortening.  When the
7072 ;; expression used to set the length attribute of an instruction depends
7073 ;; on a relative address (e.g., pc or a branch address), genattrtab
7074 ;; notes that the insn's length is variable, and attempts to determine a
7075 ;; worst-case default length and code to compute an insn's current length.
7076
7077 ;; The use of a function call hides the variable dependence of our calls
7078 ;; and millicode calls.  The result is genattrtab doesn't treat the operation
7079 ;; as variable and it only generates code for the default case using our
7080 ;; function call.  Because of this, calls and millicode calls have a fixed
7081 ;; length in the branch shortening pass, and some branches will use a longer
7082 ;; code sequence than necessary.  However, the length of any given call
7083 ;; will still reflect its final code location and it may be shorter than
7084 ;; the initial length estimate.
7085
7086 ;; It's possible to trick genattrtab by adding an expression involving `pc'
7087 ;; in the set.  However, when genattrtab hits a function call in its attempt
7088 ;; to compute the default length, it marks the result as unknown and sets
7089 ;; the default result to MAX_INT ;-(  One possible fix that would allow
7090 ;; calls to participate in branch shortening would be to make the call to
7091 ;; insn_default_length a target option.  Then, we could massage unknown
7092 ;; results.  Another fix might be to change genattrtab so that it just does
7093 ;; the call in the variable case as it already does for the fixed case.
7094
7095 (define_insn "call_symref"
7096   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7097          (match_operand 1 "" "i"))
7098    (clobber (reg:SI 1))
7099    (clobber (reg:SI 2))
7100    (use (const_int 0))]
7101   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7102   "*
7103 {
7104   output_arg_descriptor (insn);
7105   return output_call (insn, operands[0], 0);
7106 }"
7107   [(set_attr "type" "call")
7108    (set (attr "length") (symbol_ref "attr_length_call (insn, 0)"))])
7109
7110 (define_insn "call_symref_pic"
7111   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7112          (match_operand 1 "" "i"))
7113    (clobber (reg:SI 1))
7114    (clobber (reg:SI 2))
7115    (clobber (reg:SI 4))
7116    (use (reg:SI 19))
7117    (use (const_int 0))]
7118   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7119   "*
7120 {
7121   output_arg_descriptor (insn);
7122   return output_call (insn, operands[0], 0);
7123 }"
7124   [(set_attr "type" "call")
7125    (set (attr "length")
7126         (plus (symbol_ref "attr_length_call (insn, 0)")
7127               (symbol_ref "attr_length_save_restore_dltp (insn)")))])
7128
7129 ;; Split out the PIC register save and restore after reload.  This is
7130 ;; done only if the function returns.  As the split is done after reload,
7131 ;; there are some situations in which we unnecessarily save and restore
7132 ;; %r4.  This happens when there is a single call and the PIC register
7133 ;; is "dead" after the call.  This isn't easy to fix as the usage of
7134 ;; the PIC register isn't completely determined until the reload pass.
7135 (define_split
7136   [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7137                     (match_operand 1 "" ""))
7138               (clobber (reg:SI 1))
7139               (clobber (reg:SI 2))
7140               (clobber (reg:SI 4))
7141               (use (reg:SI 19))
7142               (use (const_int 0))])]
7143   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT
7144    && reload_completed
7145    && !find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7146   [(set (reg:SI 4) (reg:SI 19))
7147    (parallel [(call (mem:SI (match_dup 0))
7148                     (match_dup 1))
7149               (clobber (reg:SI 1))
7150               (clobber (reg:SI 2))
7151               (use (reg:SI 19))
7152               (use (const_int 0))])
7153    (set (reg:SI 19) (reg:SI 4))]
7154   "")
7155
7156 ;; Remove the clobber of register 4 when optimizing.  This has to be
7157 ;; done with a peephole optimization rather than a split because the
7158 ;; split sequence for a call must be longer than one instruction.
7159 (define_peephole2
7160   [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7161                     (match_operand 1 "" ""))
7162               (clobber (reg:SI 1))
7163               (clobber (reg:SI 2))
7164               (clobber (reg:SI 4))
7165               (use (reg:SI 19))
7166               (use (const_int 0))])]
7167   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
7168   [(parallel [(call (mem:SI (match_dup 0))
7169                     (match_dup 1))
7170               (clobber (reg:SI 1))
7171               (clobber (reg:SI 2))
7172               (use (reg:SI 19))
7173               (use (const_int 0))])]
7174   "")
7175
7176 (define_insn "*call_symref_pic_post_reload"
7177   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7178          (match_operand 1 "" "i"))
7179    (clobber (reg:SI 1))
7180    (clobber (reg:SI 2))
7181    (use (reg:SI 19))
7182    (use (const_int 0))]
7183   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7184   "*
7185 {
7186   output_arg_descriptor (insn);
7187   return output_call (insn, operands[0], 0);
7188 }"
7189   [(set_attr "type" "call")
7190    (set (attr "length") (symbol_ref "attr_length_call (insn, 0)"))])
7191
7192 ;; This pattern is split if it is necessary to save and restore the
7193 ;; PIC register.
7194 (define_insn "call_symref_64bit"
7195   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7196          (match_operand 1 "" "i"))
7197    (clobber (reg:DI 1))
7198    (clobber (reg:DI 2))
7199    (clobber (reg:DI 4))
7200    (use (reg:DI 27))
7201    (use (reg:DI 29))
7202    (use (const_int 0))]
7203   "TARGET_64BIT"
7204   "*
7205 {
7206   output_arg_descriptor (insn);
7207   return output_call (insn, operands[0], 0);
7208 }"
7209   [(set_attr "type" "call")
7210    (set (attr "length")
7211         (plus (symbol_ref "attr_length_call (insn, 0)")
7212               (symbol_ref "attr_length_save_restore_dltp (insn)")))])
7213
7214 ;; Split out the PIC register save and restore after reload.  This is
7215 ;; done only if the function returns.  As the split is done after reload,
7216 ;; there are some situations in which we unnecessarily save and restore
7217 ;; %r4.  This happens when there is a single call and the PIC register
7218 ;; is "dead" after the call.  This isn't easy to fix as the usage of
7219 ;; the PIC register isn't completely determined until the reload pass.
7220 (define_split
7221   [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7222                     (match_operand 1 "" ""))
7223               (clobber (reg:DI 1))
7224               (clobber (reg:DI 2))
7225               (clobber (reg:DI 4))
7226               (use (reg:DI 27))
7227               (use (reg:DI 29))
7228               (use (const_int 0))])]
7229   "TARGET_64BIT
7230    && reload_completed
7231    && !find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7232   [(set (reg:DI 4) (reg:DI 27))
7233    (parallel [(call (mem:SI (match_dup 0))
7234                     (match_dup 1))
7235               (clobber (reg:DI 1))
7236               (clobber (reg:DI 2))
7237               (use (reg:DI 27))
7238               (use (reg:DI 29))
7239               (use (const_int 0))])
7240    (set (reg:DI 27) (reg:DI 4))]
7241   "")
7242
7243 ;; Remove the clobber of register 4 when optimizing.  This has to be
7244 ;; done with a peephole optimization rather than a split because the
7245 ;; split sequence for a call must be longer than one instruction.
7246 (define_peephole2
7247   [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7248                     (match_operand 1 "" ""))
7249               (clobber (reg:DI 1))
7250               (clobber (reg:DI 2))
7251               (clobber (reg:DI 4))
7252               (use (reg:DI 27))
7253               (use (reg:DI 29))
7254               (use (const_int 0))])]
7255   "TARGET_64BIT && reload_completed"
7256   [(parallel [(call (mem:SI (match_dup 0))
7257                     (match_dup 1))
7258               (clobber (reg:DI 1))
7259               (clobber (reg:DI 2))
7260               (use (reg:DI 27))
7261               (use (reg:DI 29))
7262               (use (const_int 0))])]
7263   "")
7264
7265 (define_insn "*call_symref_64bit_post_reload"
7266   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7267          (match_operand 1 "" "i"))
7268    (clobber (reg:DI 1))
7269    (clobber (reg:DI 2))
7270    (use (reg:DI 27))
7271    (use (reg:DI 29))
7272    (use (const_int 0))]
7273   "TARGET_64BIT"
7274   "*
7275 {
7276   output_arg_descriptor (insn);
7277   return output_call (insn, operands[0], 0);
7278 }"
7279   [(set_attr "type" "call")
7280    (set (attr "length") (symbol_ref "attr_length_call (insn, 0)"))])
7281
7282 (define_insn "call_reg"
7283   [(call (mem:SI (reg:SI 22))
7284          (match_operand 0 "" "i"))
7285    (clobber (reg:SI 1))
7286    (clobber (reg:SI 2))
7287    (use (const_int 1))]
7288   "!TARGET_64BIT"
7289   "*
7290 {
7291   return output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
7292 }"
7293   [(set_attr "type" "dyncall")
7294    (set (attr "length") (symbol_ref "attr_length_indirect_call (insn)"))])
7295
7296 ;; This pattern is split if it is necessary to save and restore the
7297 ;; PIC register.
7298 (define_insn "call_reg_pic"
7299   [(call (mem:SI (reg:SI 22))
7300          (match_operand 0 "" "i"))
7301    (clobber (reg:SI 1))
7302    (clobber (reg:SI 2))
7303    (clobber (reg:SI 4))
7304    (use (reg:SI 19))
7305    (use (const_int 1))]
7306   "!TARGET_64BIT"
7307   "*
7308 {
7309   return output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
7310 }"
7311   [(set_attr "type" "dyncall")
7312    (set (attr "length")
7313         (plus (symbol_ref "attr_length_indirect_call (insn)")
7314               (symbol_ref "attr_length_save_restore_dltp (insn)")))])
7315
7316 ;; Split out the PIC register save and restore after reload.  This is
7317 ;; done only if the function returns.  As the split is done after reload,
7318 ;; there are some situations in which we unnecessarily save and restore
7319 ;; %r4.  This happens when there is a single call and the PIC register
7320 ;; is "dead" after the call.  This isn't easy to fix as the usage of
7321 ;; the PIC register isn't completely determined until the reload pass.
7322 (define_split
7323   [(parallel [(call (mem:SI (reg:SI 22))
7324                     (match_operand 0 "" ""))
7325               (clobber (reg:SI 1))
7326               (clobber (reg:SI 2))
7327               (clobber (reg:SI 4))
7328               (use (reg:SI 19))
7329               (use (const_int 1))])]
7330   "!TARGET_64BIT
7331    && reload_completed
7332    && !find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7333   [(set (reg:SI 4) (reg:SI 19))
7334    (parallel [(call (mem:SI (reg:SI 22))
7335                     (match_dup 0))
7336               (clobber (reg:SI 1))
7337               (clobber (reg:SI 2))
7338               (use (reg:SI 19))
7339               (use (const_int 1))])
7340    (set (reg:SI 19) (reg:SI 4))]
7341   "")
7342
7343 ;; Remove the clobber of register 4 when optimizing.  This has to be
7344 ;; done with a peephole optimization rather than a split because the
7345 ;; split sequence for a call must be longer than one instruction.
7346 (define_peephole2
7347   [(parallel [(call (mem:SI (reg:SI 22))
7348                     (match_operand 0 "" ""))
7349               (clobber (reg:SI 1))
7350               (clobber (reg:SI 2))
7351               (clobber (reg:SI 4))
7352               (use (reg:SI 19))
7353               (use (const_int 1))])]
7354   "!TARGET_64BIT && reload_completed"
7355   [(parallel [(call (mem:SI (reg:SI 22))
7356                     (match_dup 0))
7357               (clobber (reg:SI 1))
7358               (clobber (reg:SI 2))
7359               (use (reg:SI 19))
7360               (use (const_int 1))])]
7361   "")
7362
7363 (define_insn "*call_reg_pic_post_reload"
7364   [(call (mem:SI (reg:SI 22))
7365          (match_operand 0 "" "i"))
7366    (clobber (reg:SI 1))
7367    (clobber (reg:SI 2))
7368    (use (reg:SI 19))
7369    (use (const_int 1))]
7370   "!TARGET_64BIT"
7371   "*
7372 {
7373   return output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
7374 }"
7375   [(set_attr "type" "dyncall")
7376    (set (attr "length") (symbol_ref "attr_length_indirect_call (insn)"))])
7377
7378 ;; This pattern is split if it is necessary to save and restore the
7379 ;; PIC register.
7380 (define_insn "call_reg_64bit"
7381   [(call (mem:SI (match_operand:DI 0 "register_operand" "r"))
7382          (match_operand 1 "" "i"))
7383    (clobber (reg:DI 2))
7384    (clobber (reg:DI 4))
7385    (use (reg:DI 27))
7386    (use (reg:DI 29))
7387    (use (const_int 1))]
7388   "TARGET_64BIT"
7389   "*
7390 {
7391   return output_indirect_call (insn, operands[0]);
7392 }"
7393   [(set_attr "type" "dyncall")
7394    (set (attr "length")
7395         (plus (symbol_ref "attr_length_indirect_call (insn)")
7396               (symbol_ref "attr_length_save_restore_dltp (insn)")))])
7397
7398 ;; Split out the PIC register save and restore after reload.  This is
7399 ;; done only if the function returns.  As the split is done after reload,
7400 ;; there are some situations in which we unnecessarily save and restore
7401 ;; %r4.  This happens when there is a single call and the PIC register
7402 ;; is "dead" after the call.  This isn't easy to fix as the usage of
7403 ;; the PIC register isn't completely determined until the reload pass.
7404 (define_split
7405   [(parallel [(call (mem:SI (match_operand 0 "register_operand" ""))
7406                     (match_operand 1 "" ""))
7407               (clobber (reg:DI 2))
7408               (clobber (reg:DI 4))
7409               (use (reg:DI 27))
7410               (use (reg:DI 29))
7411               (use (const_int 1))])]
7412   "TARGET_64BIT
7413    && reload_completed
7414    && !find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7415   [(set (reg:DI 4) (reg:DI 27))
7416    (parallel [(call (mem:SI (match_dup 0))
7417                     (match_dup 1))
7418               (clobber (reg:DI 2))
7419               (use (reg:DI 27))
7420               (use (reg:DI 29))
7421               (use (const_int 1))])
7422    (set (reg:DI 27) (reg:DI 4))]
7423   "")
7424
7425 ;; Remove the clobber of register 4 when optimizing.  This has to be
7426 ;; done with a peephole optimization rather than a split because the
7427 ;; split sequence for a call must be longer than one instruction.
7428 (define_peephole2
7429   [(parallel [(call (mem:SI (match_operand 0 "register_operand" ""))
7430                     (match_operand 1 "" ""))
7431               (clobber (reg:DI 2))
7432               (clobber (reg:DI 4))
7433               (use (reg:DI 27))
7434               (use (reg:DI 29))
7435               (use (const_int 1))])]
7436   "TARGET_64BIT && reload_completed"
7437   [(parallel [(call (mem:SI (match_dup 0))
7438                     (match_dup 1))
7439               (clobber (reg:DI 2))
7440               (use (reg:DI 27))
7441               (use (reg:DI 29))
7442               (use (const_int 1))])]
7443   "")
7444
7445 (define_insn "*call_reg_64bit_post_reload"
7446   [(call (mem:SI (match_operand:DI 0 "register_operand" "r"))
7447          (match_operand 1 "" "i"))
7448    (clobber (reg:DI 2))
7449    (use (reg:DI 27))
7450    (use (reg:DI 29))
7451    (use (const_int 1))]
7452   "TARGET_64BIT"
7453   "*
7454 {
7455   return output_indirect_call (insn, operands[0]);
7456 }"
7457   [(set_attr "type" "dyncall")
7458    (set (attr "length") (symbol_ref "attr_length_indirect_call (insn)"))])
7459
7460 (define_expand "call_value"
7461   [(parallel [(set (match_operand 0 "" "")
7462                    (call (match_operand:SI 1 "" "")
7463                          (match_operand 2 "" "")))
7464               (clobber (reg:SI 2))])]
7465   ""
7466   "
7467 {
7468   rtx op, call_insn;
7469   rtx dst = operands[0];
7470   rtx nb = operands[2];
7471
7472   if (TARGET_PORTABLE_RUNTIME)
7473     op = force_reg (SImode, XEXP (operands[1], 0));
7474   else
7475     op = XEXP (operands[1], 0);
7476
7477   if (TARGET_64BIT)
7478     {
7479       if (!virtuals_instantiated)
7480         emit_move_insn (arg_pointer_rtx,
7481                         gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
7482                                       GEN_INT (64)));
7483       else
7484         {
7485           /* The loop pass can generate new libcalls after the virtual
7486              registers are instantiated when fpregs are disabled because
7487              the only method that we have for doing DImode multiplication
7488              is with a libcall.  This could be trouble if we haven't
7489              allocated enough space for the outgoing arguments.  */
7490           if (INTVAL (nb) > current_function_outgoing_args_size)
7491             abort ();
7492
7493           emit_move_insn (arg_pointer_rtx,
7494                           gen_rtx_PLUS (word_mode, stack_pointer_rtx,
7495                                         GEN_INT (STACK_POINTER_OFFSET + 64)));
7496         }
7497     }
7498
7499   /* Use two different patterns for calls to explicitly named functions
7500      and calls through function pointers.  This is necessary as these two
7501      types of calls use different calling conventions, and CSE might try
7502      to change the named call into an indirect call in some cases (using
7503      two patterns keeps CSE from performing this optimization).
7504
7505      We now use even more call patterns as there was a subtle bug in
7506      attempting to restore the pic register after a call using a simple
7507      move insn.  During reload, a instruction involving a pseudo register
7508      with no explicit dependence on the PIC register can be converted
7509      to an equivalent load from memory using the PIC register.  If we
7510      emit a simple move to restore the PIC register in the initial rtl
7511      generation, then it can potentially be repositioned during scheduling.
7512      and an instruction that eventually uses the PIC register may end up
7513      between the call and the PIC register restore.
7514      
7515      This only worked because there is a post call group of instructions
7516      that are scheduled with the call.  These instructions are included
7517      in the same basic block as the call.  However, calls can throw in
7518      C++ code and a basic block has to terminate at the call if the call
7519      can throw.  This results in the PIC register restore being scheduled
7520      independently from the call.  So, we now hide the save and restore
7521      of the PIC register in the call pattern until after reload.  Then,
7522      we split the moves out.  A small side benefit is that we now don't
7523      need to have a use of the PIC register in the return pattern and
7524      the final save/restore operation is not needed.
7525      
7526      I elected to just clobber %r4 in the PIC patterns and use it instead
7527      of trying to force hppa_pic_save_rtx () to a callee saved register.
7528      This might have required a new register class and constraint.  It
7529      was also simpler to just handle the restore from a register than a
7530      generic pseudo.  */
7531   if (TARGET_64BIT)
7532     {
7533       if (GET_CODE (op) == SYMBOL_REF)
7534         call_insn = emit_call_insn (gen_call_val_symref_64bit (dst, op, nb));
7535       else
7536         {
7537           op = force_reg (word_mode, op);
7538           call_insn = emit_call_insn (gen_call_val_reg_64bit (dst, op, nb));
7539         }
7540     }
7541   else
7542     {
7543       if (GET_CODE (op) == SYMBOL_REF)
7544         {
7545           if (flag_pic)
7546             call_insn = emit_call_insn (gen_call_val_symref_pic (dst, op, nb));
7547           else
7548             call_insn = emit_call_insn (gen_call_val_symref (dst, op, nb));
7549         }
7550       else
7551         {
7552           rtx tmpreg = gen_rtx_REG (word_mode, 22);
7553
7554           emit_move_insn (tmpreg, force_reg (word_mode, op));
7555           if (flag_pic)
7556             call_insn = emit_call_insn (gen_call_val_reg_pic (dst, nb));
7557           else
7558             call_insn = emit_call_insn (gen_call_val_reg (dst, nb));
7559         }
7560     }
7561
7562   DONE;
7563 }")
7564
7565 (define_insn "call_val_symref"
7566   [(set (match_operand 0 "" "")
7567         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7568               (match_operand 2 "" "i")))
7569    (clobber (reg:SI 1))
7570    (clobber (reg:SI 2))
7571    (use (const_int 0))]
7572   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7573   "*
7574 {
7575   output_arg_descriptor (insn);
7576   return output_call (insn, operands[1], 0);
7577 }"
7578   [(set_attr "type" "call")
7579    (set (attr "length") (symbol_ref "attr_length_call (insn, 0)"))])
7580
7581 (define_insn "call_val_symref_pic"
7582   [(set (match_operand 0 "" "")
7583         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7584               (match_operand 2 "" "i")))
7585    (clobber (reg:SI 1))
7586    (clobber (reg:SI 2))
7587    (clobber (reg:SI 4))
7588    (use (reg:SI 19))
7589    (use (const_int 0))]
7590   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7591   "*
7592 {
7593   output_arg_descriptor (insn);
7594   return output_call (insn, operands[1], 0);
7595 }"
7596   [(set_attr "type" "call")
7597    (set (attr "length")
7598         (plus (symbol_ref "attr_length_call (insn, 0)")
7599               (symbol_ref "attr_length_save_restore_dltp (insn)")))])
7600
7601 ;; Split out the PIC register save and restore after reload.  This is
7602 ;; done only if the function returns.  As the split is done after reload,
7603 ;; there are some situations in which we unnecessarily save and restore
7604 ;; %r4.  This happens when there is a single call and the PIC register
7605 ;; is "dead" after the call.  This isn't easy to fix as the usage of
7606 ;; the PIC register isn't completely determined until the reload pass.
7607 (define_split
7608   [(parallel [(set (match_operand 0 "" "")
7609               (call (mem:SI (match_operand 1 "call_operand_address" ""))
7610                     (match_operand 2 "" "")))
7611               (clobber (reg:SI 1))
7612               (clobber (reg:SI 2))
7613               (clobber (reg:SI 4))
7614               (use (reg:SI 19))
7615               (use (const_int 0))])]
7616   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT
7617    && reload_completed
7618    && !find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7619   [(set (reg:SI 4) (reg:SI 19))
7620    (parallel [(set (match_dup 0)
7621               (call (mem:SI (match_dup 1))
7622                     (match_dup 2)))
7623               (clobber (reg:SI 1))
7624               (clobber (reg:SI 2))
7625               (use (reg:SI 19))
7626               (use (const_int 0))])
7627    (set (reg:SI 19) (reg:SI 4))]
7628   "")
7629
7630 ;; Remove the clobber of register 4 when optimizing.  This has to be
7631 ;; done with a peephole optimization rather than a split because the
7632 ;; split sequence for a call must be longer than one instruction.
7633 (define_peephole2
7634   [(parallel [(set (match_operand 0 "" "")
7635               (call (mem:SI (match_operand 1 "call_operand_address" ""))
7636                     (match_operand 2 "" "")))
7637               (clobber (reg:SI 1))
7638               (clobber (reg:SI 2))
7639               (clobber (reg:SI 4))
7640               (use (reg:SI 19))
7641               (use (const_int 0))])]
7642   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
7643   [(parallel [(set (match_dup 0)
7644               (call (mem:SI (match_dup 1))
7645                     (match_dup 2)))
7646               (clobber (reg:SI 1))
7647               (clobber (reg:SI 2))
7648               (use (reg:SI 19))
7649               (use (const_int 0))])]
7650   "")
7651
7652 (define_insn "*call_val_symref_pic_post_reload"
7653   [(set (match_operand 0 "" "")
7654         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7655               (match_operand 2 "" "i")))
7656    (clobber (reg:SI 1))
7657    (clobber (reg:SI 2))
7658    (use (reg:SI 19))
7659    (use (const_int 0))]
7660   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7661   "*
7662 {
7663   output_arg_descriptor (insn);
7664   return output_call (insn, operands[1], 0);
7665 }"
7666   [(set_attr "type" "call")
7667    (set (attr "length") (symbol_ref "attr_length_call (insn, 0)"))])
7668
7669 ;; This pattern is split if it is necessary to save and restore the
7670 ;; PIC register.
7671 (define_insn "call_val_symref_64bit"
7672   [(set (match_operand 0 "" "")
7673         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7674               (match_operand 2 "" "i")))
7675    (clobber (reg:DI 1))
7676    (clobber (reg:DI 2))
7677    (clobber (reg:DI 4))
7678    (use (reg:DI 27))
7679    (use (reg:DI 29))
7680    (use (const_int 0))]
7681   "TARGET_64BIT"
7682   "*
7683 {
7684   output_arg_descriptor (insn);
7685   return output_call (insn, operands[1], 0);
7686 }"
7687   [(set_attr "type" "call")
7688    (set (attr "length")
7689         (plus (symbol_ref "attr_length_call (insn, 0)")
7690               (symbol_ref "attr_length_save_restore_dltp (insn)")))])
7691
7692 ;; Split out the PIC register save and restore after reload.  This is
7693 ;; done only if the function returns.  As the split is done after reload,
7694 ;; there are some situations in which we unnecessarily save and restore
7695 ;; %r4.  This happens when there is a single call and the PIC register
7696 ;; is "dead" after the call.  This isn't easy to fix as the usage of
7697 ;; the PIC register isn't completely determined until the reload pass.
7698 (define_split
7699   [(parallel [(set (match_operand 0 "" "")
7700               (call (mem:SI (match_operand 1 "call_operand_address" ""))
7701                     (match_operand 2 "" "")))
7702               (clobber (reg:DI 1))
7703               (clobber (reg:DI 2))
7704               (clobber (reg:DI 4))
7705               (use (reg:DI 27))
7706               (use (reg:DI 29))
7707               (use (const_int 0))])]
7708   "TARGET_64BIT
7709    && reload_completed
7710    && !find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7711   [(set (reg:DI 4) (reg:DI 27))
7712    (parallel [(set (match_dup 0)
7713               (call (mem:SI (match_dup 1))
7714                     (match_dup 2)))
7715               (clobber (reg:DI 1))
7716               (clobber (reg:DI 2))
7717               (use (reg:DI 27))
7718               (use (reg:DI 29))
7719               (use (const_int 0))])
7720    (set (reg:DI 27) (reg:DI 4))]
7721   "")
7722
7723 ;; Remove the clobber of register 4 when optimizing.  This has to be
7724 ;; done with a peephole optimization rather than a split because the
7725 ;; split sequence for a call must be longer than one instruction.
7726 (define_peephole2
7727   [(parallel [(set (match_operand 0 "" "")
7728               (call (mem:SI (match_operand 1 "call_operand_address" ""))
7729                     (match_operand 2 "" "")))
7730               (clobber (reg:DI 1))
7731               (clobber (reg:DI 2))
7732               (clobber (reg:DI 4))
7733               (use (reg:DI 27))
7734               (use (reg:DI 29))
7735               (use (const_int 0))])]
7736   "TARGET_64BIT && reload_completed"
7737   [(parallel [(set (match_dup 0)
7738               (call (mem:SI (match_dup 1))
7739                     (match_dup 2)))
7740               (clobber (reg:DI 1))
7741               (clobber (reg:DI 2))
7742               (use (reg:DI 27))
7743               (use (reg:DI 29))
7744               (use (const_int 0))])]
7745   "")
7746
7747 (define_insn "*call_val_symref_64bit_post_reload"
7748   [(set (match_operand 0 "" "")
7749         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7750               (match_operand 2 "" "i")))
7751    (clobber (reg:DI 1))
7752    (clobber (reg:DI 2))
7753    (use (reg:DI 27))
7754    (use (reg:DI 29))
7755    (use (const_int 0))]
7756   "TARGET_64BIT"
7757   "*
7758 {
7759   output_arg_descriptor (insn);
7760   return output_call (insn, operands[1], 0);
7761 }"
7762   [(set_attr "type" "call")
7763    (set (attr "length") (symbol_ref "attr_length_call (insn, 0)"))])
7764
7765 (define_insn "call_val_reg"
7766   [(set (match_operand 0 "" "")
7767         (call (mem:SI (reg:SI 22))
7768               (match_operand 1 "" "i")))
7769    (clobber (reg:SI 1))
7770    (clobber (reg:SI 2))
7771    (use (const_int 1))]
7772   "!TARGET_64BIT"
7773   "*
7774 {
7775   return output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
7776 }"
7777   [(set_attr "type" "dyncall")
7778    (set (attr "length") (symbol_ref "attr_length_indirect_call (insn)"))])
7779
7780 ;; This pattern is split if it is necessary to save and restore the
7781 ;; PIC register.
7782 (define_insn "call_val_reg_pic"
7783   [(set (match_operand 0 "" "")
7784         (call (mem:SI (reg:SI 22))
7785               (match_operand 1 "" "i")))
7786    (clobber (reg:SI 1))
7787    (clobber (reg:SI 2))
7788    (clobber (reg:SI 4))
7789    (use (reg:SI 19))
7790    (use (const_int 1))]
7791   "!TARGET_64BIT"
7792   "*
7793 {
7794   return output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
7795 }"
7796   [(set_attr "type" "dyncall")
7797    (set (attr "length")
7798         (plus (symbol_ref "attr_length_indirect_call (insn)")
7799               (symbol_ref "attr_length_save_restore_dltp (insn)")))])
7800
7801 ;; Split out the PIC register save and restore after reload.  This is
7802 ;; done only if the function returns.  As the split is done after reload,
7803 ;; there are some situations in which we unnecessarily save and restore
7804 ;; %r4.  This happens when there is a single call and the PIC register
7805 ;; is "dead" after the call.  This isn't easy to fix as the usage of
7806 ;; the PIC register isn't completely determined until the reload pass.
7807 (define_split
7808   [(parallel [(set (match_operand 0 "" "")
7809                    (call (mem:SI (reg:SI 22))
7810                          (match_operand 1 "" "")))
7811               (clobber (reg:SI 1))
7812               (clobber (reg:SI 2))
7813               (clobber (reg:SI 4))
7814               (use (reg:SI 19))
7815               (use (const_int 1))])]
7816   "!TARGET_64BIT
7817    && reload_completed
7818    && !find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7819   [(set (reg:SI 4) (reg:SI 19))
7820    (parallel [(set (match_dup 0)
7821                    (call (mem:SI (reg:SI 22))
7822                          (match_dup 1)))
7823               (clobber (reg:SI 1))
7824               (clobber (reg:SI 2))
7825               (use (reg:SI 19))
7826               (use (const_int 1))])
7827    (set (reg:SI 19) (reg:SI 4))]
7828   "")
7829
7830 ;; Remove the clobber of register 4 when optimizing.  This has to be
7831 ;; done with a peephole optimization rather than a split because the
7832 ;; split sequence for a call must be longer than one instruction.
7833 (define_peephole2
7834   [(parallel [(set (match_operand 0 "" "")
7835                    (call (mem:SI (reg:SI 22))
7836                          (match_operand 1 "" "")))
7837               (clobber (reg:SI 1))
7838               (clobber (reg:SI 2))
7839               (clobber (reg:SI 4))
7840               (use (reg:SI 19))
7841               (use (const_int 1))])]
7842   "!TARGET_64BIT && reload_completed"
7843   [(parallel [(set (match_dup 0)
7844                    (call (mem:SI (reg:SI 22))
7845                          (match_dup 1)))
7846               (clobber (reg:SI 1))
7847               (clobber (reg:SI 2))
7848               (use (reg:SI 19))
7849               (use (const_int 1))])]
7850   "")
7851
7852 (define_insn "*call_val_reg_pic_post_reload"
7853   [(set (match_operand 0 "" "")
7854         (call (mem:SI (reg:SI 22))
7855               (match_operand 1 "" "i")))
7856    (clobber (reg:SI 1))
7857    (clobber (reg:SI 2))
7858    (use (reg:SI 19))
7859    (use (const_int 1))]
7860   "!TARGET_64BIT"
7861   "*
7862 {
7863   return output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
7864 }"
7865   [(set_attr "type" "dyncall")
7866    (set (attr "length") (symbol_ref "attr_length_indirect_call (insn)"))])
7867
7868 ;; This pattern is split if it is necessary to save and restore the
7869 ;; PIC register.
7870 (define_insn "call_val_reg_64bit"
7871   [(set (match_operand 0 "" "")
7872         (call (mem:SI (match_operand:DI 1 "register_operand" "r"))
7873               (match_operand 2 "" "i")))
7874    (clobber (reg:DI 2))
7875    (clobber (reg:DI 4))
7876    (use (reg:DI 27))
7877    (use (reg:DI 29))
7878    (use (const_int 1))]
7879   "TARGET_64BIT"
7880   "*
7881 {
7882   return output_indirect_call (insn, operands[1]);
7883 }"
7884   [(set_attr "type" "dyncall")
7885    (set (attr "length")
7886         (plus (symbol_ref "attr_length_indirect_call (insn)")
7887               (symbol_ref "attr_length_save_restore_dltp (insn)")))])
7888
7889 ;; Split out the PIC register save and restore after reload.  This is
7890 ;; done only if the function returns.  As the split is done after reload,
7891 ;; there are some situations in which we unnecessarily save and restore
7892 ;; %r4.  This happens when there is a single call and the PIC register
7893 ;; is "dead" after the call.  This isn't easy to fix as the usage of
7894 ;; the PIC register isn't completely determined until the reload pass.
7895 (define_split
7896   [(parallel [(set (match_operand 0 "" "")
7897                    (call (mem:SI (match_operand:DI 1 "register_operand" ""))
7898                          (match_operand 2 "" "")))
7899               (clobber (reg:DI 2))
7900               (clobber (reg:DI 4))
7901               (use (reg:DI 27))
7902               (use (reg:DI 29))
7903               (use (const_int 1))])]
7904   "TARGET_64BIT
7905    && reload_completed
7906    && !find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7907   [(set (reg:DI 4) (reg:DI 27))
7908    (parallel [(set (match_dup 0)
7909                    (call (mem:SI (match_dup 1))
7910                          (match_dup 2)))
7911               (clobber (reg:DI 2))
7912               (use (reg:DI 27))
7913               (use (reg:DI 29))
7914               (use (const_int 1))])
7915    (set (reg:DI 27) (reg:DI 4))]
7916   "")
7917
7918 ;; Remove the clobber of register 4 when optimizing.  This has to be
7919 ;; done with a peephole optimization rather than a split because the
7920 ;; split sequence for a call must be longer than one instruction.
7921 (define_peephole2
7922   [(parallel [(set (match_operand 0 "" "")
7923                    (call (mem:SI (match_operand:DI 1 "register_operand" ""))
7924                          (match_operand 2 "" "")))
7925               (clobber (reg:DI 2))
7926               (clobber (reg:DI 4))
7927               (use (reg:DI 27))
7928               (use (reg:DI 29))
7929               (use (const_int 1))])]
7930   "TARGET_64BIT && reload_completed"
7931   [(parallel [(set (match_dup 0)
7932                    (call (mem:SI (match_dup 1))
7933                          (match_dup 2)))
7934               (clobber (reg:DI 2))
7935               (use (reg:DI 27))
7936               (use (reg:DI 29))
7937               (use (const_int 1))])]
7938   "")
7939
7940 (define_insn "*call_val_reg_64bit_post_reload"
7941   [(set (match_operand 0 "" "")
7942         (call (mem:SI (match_operand:DI 1 "register_operand" "r"))
7943               (match_operand 2 "" "i")))
7944    (clobber (reg:DI 2))
7945    (use (reg:DI 27))
7946    (use (reg:DI 29))
7947    (use (const_int 1))]
7948   "TARGET_64BIT"
7949   "*
7950 {
7951   return output_indirect_call (insn, operands[1]);
7952 }"
7953   [(set_attr "type" "dyncall")
7954    (set (attr "length") (symbol_ref "attr_length_indirect_call (insn)"))])
7955
7956 ;; Call subroutine returning any type.
7957
7958 (define_expand "untyped_call"
7959   [(parallel [(call (match_operand 0 "" "")
7960                     (const_int 0))
7961               (match_operand 1 "" "")
7962               (match_operand 2 "" "")])]
7963   ""
7964   "
7965 {
7966   int i;
7967
7968   emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
7969
7970   for (i = 0; i < XVECLEN (operands[2], 0); i++)
7971     {
7972       rtx set = XVECEXP (operands[2], 0, i);
7973       emit_move_insn (SET_DEST (set), SET_SRC (set));
7974     }
7975
7976   /* The optimizer does not know that the call sets the function value
7977      registers we stored in the result block.  We avoid problems by
7978      claiming that all hard registers are used and clobbered at this
7979      point.  */
7980   emit_insn (gen_blockage ());
7981
7982   DONE;
7983 }")
7984
7985 (define_expand "sibcall"
7986   [(call (match_operand:SI 0 "" "")
7987          (match_operand 1 "" ""))]
7988   "!TARGET_PORTABLE_RUNTIME"
7989   "
7990 {
7991   rtx op, call_insn;
7992   rtx nb = operands[1];
7993
7994   op = XEXP (operands[0], 0);
7995
7996   if (TARGET_64BIT)
7997     {
7998       if (!virtuals_instantiated)
7999         emit_move_insn (arg_pointer_rtx,
8000                         gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
8001                                       GEN_INT (64)));
8002       else
8003         {
8004           /* The loop pass can generate new libcalls after the virtual
8005              registers are instantiated when fpregs are disabled because
8006              the only method that we have for doing DImode multiplication
8007              is with a libcall.  This could be trouble if we haven't
8008              allocated enough space for the outgoing arguments.  */
8009           if (INTVAL (nb) > current_function_outgoing_args_size)
8010             abort ();
8011
8012           emit_move_insn (arg_pointer_rtx,
8013                           gen_rtx_PLUS (word_mode, stack_pointer_rtx,
8014                                         GEN_INT (STACK_POINTER_OFFSET + 64)));
8015         }
8016     }
8017
8018   /* Indirect sibling calls are not allowed.  */
8019   if (TARGET_64BIT)
8020     call_insn = gen_sibcall_internal_symref_64bit (op, operands[1]);
8021   else
8022     call_insn = gen_sibcall_internal_symref (op, operands[1]);
8023
8024   call_insn = emit_call_insn (call_insn);
8025
8026   if (TARGET_64BIT)
8027     use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), arg_pointer_rtx);
8028
8029   /* We don't have to restore the PIC register.  */
8030   if (flag_pic)
8031     use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
8032
8033   DONE;
8034 }")
8035
8036 (define_insn "sibcall_internal_symref"
8037   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8038          (match_operand 1 "" "i"))
8039    (clobber (reg:SI 1))
8040    (use (reg:SI 2))
8041    (use (const_int 0))]
8042   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8043   "*
8044 {
8045   output_arg_descriptor (insn);
8046   return output_call (insn, operands[0], 1);
8047 }"
8048   [(set_attr "type" "call")
8049    (set (attr "length") (symbol_ref "attr_length_call (insn, 1)"))])
8050
8051 (define_insn "sibcall_internal_symref_64bit"
8052   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8053          (match_operand 1 "" "i"))
8054    (clobber (reg:DI 1))
8055    (use (reg:DI 2))
8056    (use (const_int 0))]
8057   "TARGET_64BIT"
8058   "*
8059 {
8060   output_arg_descriptor (insn);
8061   return output_call (insn, operands[0], 1);
8062 }"
8063   [(set_attr "type" "call")
8064    (set (attr "length") (symbol_ref "attr_length_call (insn, 1)"))])
8065
8066 (define_expand "sibcall_value"
8067   [(set (match_operand 0 "" "")
8068                    (call (match_operand:SI 1 "" "")
8069                          (match_operand 2 "" "")))]
8070   "!TARGET_PORTABLE_RUNTIME"
8071   "
8072 {
8073   rtx op, call_insn;
8074   rtx nb = operands[1];
8075
8076   op = XEXP (operands[1], 0);
8077
8078   if (TARGET_64BIT)
8079     {
8080       if (!virtuals_instantiated)
8081         emit_move_insn (arg_pointer_rtx,
8082                         gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
8083                                       GEN_INT (64)));
8084       else
8085         {
8086           /* The loop pass can generate new libcalls after the virtual
8087              registers are instantiated when fpregs are disabled because
8088              the only method that we have for doing DImode multiplication
8089              is with a libcall.  This could be trouble if we haven't
8090              allocated enough space for the outgoing arguments.  */
8091           if (INTVAL (nb) > current_function_outgoing_args_size)
8092             abort ();
8093
8094           emit_move_insn (arg_pointer_rtx,
8095                           gen_rtx_PLUS (word_mode, stack_pointer_rtx,
8096                                         GEN_INT (STACK_POINTER_OFFSET + 64)));
8097         }
8098     }
8099
8100   /* Indirect sibling calls are not allowed.  */
8101   if (TARGET_64BIT)
8102     call_insn
8103       = gen_sibcall_value_internal_symref_64bit (operands[0], op, operands[2]);
8104   else
8105     call_insn
8106       = gen_sibcall_value_internal_symref (operands[0], op, operands[2]);
8107
8108   call_insn = emit_call_insn (call_insn);
8109
8110   if (TARGET_64BIT)
8111     use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), arg_pointer_rtx);
8112
8113   /* We don't have to restore the PIC register.  */
8114   if (flag_pic)
8115     use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
8116
8117   DONE;
8118 }")
8119
8120 (define_insn "sibcall_value_internal_symref"
8121   [(set (match_operand 0 "" "")
8122         (call (mem:SI (match_operand 1 "call_operand_address" ""))
8123               (match_operand 2 "" "i")))
8124    (clobber (reg:SI 1))
8125    (use (reg:SI 2))
8126    (use (const_int 0))]
8127   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8128   "*
8129 {
8130   output_arg_descriptor (insn);
8131   return output_call (insn, operands[1], 1);
8132 }"
8133   [(set_attr "type" "call")
8134    (set (attr "length") (symbol_ref "attr_length_call (insn, 1)"))])
8135
8136 (define_insn "sibcall_value_internal_symref_64bit"
8137   [(set (match_operand 0 "" "")
8138         (call (mem:SI (match_operand 1 "call_operand_address" ""))
8139               (match_operand 2 "" "i")))
8140    (clobber (reg:DI 1))
8141    (use (reg:DI 2))
8142    (use (const_int 0))]
8143   "TARGET_64BIT"
8144   "*
8145 {
8146   output_arg_descriptor (insn);
8147   return output_call (insn, operands[1], 1);
8148 }"
8149   [(set_attr "type" "call")
8150    (set (attr "length") (symbol_ref "attr_length_call (insn, 1)"))])
8151
8152 (define_insn "nop"
8153   [(const_int 0)]
8154   ""
8155   "nop"
8156   [(set_attr "type" "move")
8157    (set_attr "length" "4")])
8158
8159 ;; These are just placeholders so we know where branch tables
8160 ;; begin and end.
8161 (define_insn "begin_brtab"
8162   [(const_int 1)]
8163   ""
8164   "*
8165 {
8166   /* Only GAS actually supports this pseudo-op.  */
8167   if (TARGET_GAS)
8168     return \".begin_brtab\";
8169   else
8170     return \"\";
8171 }"
8172   [(set_attr "type" "move")
8173    (set_attr "length" "0")])
8174
8175 (define_insn "end_brtab"
8176   [(const_int 2)]
8177   ""
8178   "*
8179 {
8180   /* Only GAS actually supports this pseudo-op.  */
8181   if (TARGET_GAS)
8182     return \".end_brtab\";
8183   else
8184     return \"\";
8185 }"
8186   [(set_attr "type" "move")
8187    (set_attr "length" "0")])
8188
8189 ;;; EH does longjmp's from and within the data section.  Thus,
8190 ;;; an interspace branch is required for the longjmp implementation.
8191 ;;; Registers r1 and r2 are used as scratch registers for the jump
8192 ;;; when necessary.
8193 (define_expand "interspace_jump"
8194   [(parallel
8195      [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8196       (clobber (match_dup 1))])]
8197   ""
8198   "
8199 {
8200   operands[1] = gen_rtx_REG (word_mode, 2);
8201 }")
8202
8203 (define_insn ""
8204   [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8205   (clobber (reg:SI 2))]
8206   "TARGET_PA_20 && !TARGET_64BIT"
8207   "bve%* (%0)"
8208    [(set_attr "type" "branch")
8209     (set_attr "length" "4")])
8210
8211 (define_insn ""
8212   [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8213   (clobber (reg:SI 2))]
8214   "TARGET_NO_SPACE_REGS && !TARGET_64BIT"
8215   "be%* 0(%%sr4,%0)"
8216    [(set_attr "type" "branch")
8217     (set_attr "length" "4")])
8218
8219 (define_insn ""
8220   [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8221   (clobber (reg:SI 2))]
8222   "!TARGET_64BIT"
8223   "ldsid (%%sr0,%0),%%r2\; mtsp %%r2,%%sr0\; be%* 0(%%sr0,%0)"
8224    [(set_attr "type" "branch")
8225     (set_attr "length" "12")])
8226
8227 (define_insn ""
8228   [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8229   (clobber (reg:DI 2))]
8230   "TARGET_64BIT"
8231   "bve%* (%0)"
8232    [(set_attr "type" "branch")
8233     (set_attr "length" "4")])
8234
8235 (define_expand "builtin_longjmp"
8236   [(unspec_volatile [(match_operand 0 "register_operand" "r")] 3)]
8237   ""
8238   "
8239 {
8240   /* The elements of the buffer are, in order:  */
8241   rtx fp = gen_rtx_MEM (Pmode, operands[0]);
8242   rtx lab = gen_rtx_MEM (Pmode, plus_constant (operands[0],
8243                          POINTER_SIZE / BITS_PER_UNIT));
8244   rtx stack = gen_rtx_MEM (Pmode, plus_constant (operands[0],
8245                            (POINTER_SIZE * 2) / BITS_PER_UNIT));
8246   rtx pv = gen_rtx_REG (Pmode, 1);
8247
8248   /* This bit is the same as expand_builtin_longjmp.  */
8249   emit_move_insn (hard_frame_pointer_rtx, fp);
8250   emit_stack_restore (SAVE_NONLOCAL, stack, NULL_RTX);
8251   emit_insn (gen_rtx_USE (VOIDmode, hard_frame_pointer_rtx));
8252   emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
8253
8254   /* Load the label we are jumping through into r1 so that we know
8255      where to look for it when we get back to setjmp's function for
8256      restoring the gp.  */
8257   emit_move_insn (pv, lab);
8258
8259   /* Prevent the insns above from being scheduled into the delay slot
8260      of the interspace jump because the space register could change.  */
8261   emit_insn (gen_blockage ());
8262
8263   emit_jump_insn (gen_interspace_jump (pv));
8264   emit_barrier ();
8265   DONE;
8266 }")
8267
8268 ;;; Operands 2 and 3 are assumed to be CONST_INTs.
8269 (define_expand "extzv"
8270   [(set (match_operand 0 "register_operand" "")
8271         (zero_extract (match_operand 1 "register_operand" "")
8272                       (match_operand 2 "uint32_operand" "")
8273                       (match_operand 3 "uint32_operand" "")))]
8274   ""
8275   "
8276 {
8277   HOST_WIDE_INT len = INTVAL (operands[2]);
8278   HOST_WIDE_INT pos = INTVAL (operands[3]);
8279
8280   /* PA extraction insns don't support zero length bitfields or fields
8281      extending beyond the left or right-most bits.  Also, we reject lengths
8282      equal to a word as they are better handled by the move patterns.  */
8283   if (len <= 0 || len >= BITS_PER_WORD || pos < 0 || pos + len > BITS_PER_WORD)
8284     FAIL;
8285
8286   /* From mips.md: extract_bit_field doesn't verify that our source
8287      matches the predicate, so check it again here.  */
8288   if (!register_operand (operands[1], VOIDmode))
8289     FAIL;
8290
8291   if (TARGET_64BIT)
8292     emit_insn (gen_extzv_64 (operands[0], operands[1],
8293                              operands[2], operands[3]));
8294   else
8295     emit_insn (gen_extzv_32 (operands[0], operands[1],
8296                              operands[2], operands[3]));
8297   DONE;
8298 }")
8299
8300 (define_insn "extzv_32"
8301   [(set (match_operand:SI 0 "register_operand" "=r")
8302         (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
8303                          (match_operand:SI 2 "uint5_operand" "")
8304                          (match_operand:SI 3 "uint5_operand" "")))]
8305   ""
8306   "{extru|extrw,u} %1,%3+%2-1,%2,%0"
8307   [(set_attr "type" "shift")
8308    (set_attr "length" "4")])
8309
8310 (define_insn ""
8311   [(set (match_operand:SI 0 "register_operand" "=r")
8312         (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
8313                          (const_int 1)
8314                          (match_operand:SI 2 "register_operand" "q")))]
8315   ""
8316   "{vextru %1,1,%0|extrw,u %1,%%sar,1,%0}"
8317   [(set_attr "type" "shift")
8318    (set_attr "length" "4")])
8319
8320 (define_insn "extzv_64"
8321   [(set (match_operand:DI 0 "register_operand" "=r")
8322         (zero_extract:DI (match_operand:DI 1 "register_operand" "r")
8323                          (match_operand:DI 2 "uint32_operand" "")
8324                          (match_operand:DI 3 "uint32_operand" "")))]
8325   "TARGET_64BIT"
8326   "extrd,u %1,%3+%2-1,%2,%0"
8327   [(set_attr "type" "shift")
8328    (set_attr "length" "4")])
8329
8330 (define_insn ""
8331   [(set (match_operand:DI 0 "register_operand" "=r")
8332         (zero_extract:DI (match_operand:DI 1 "register_operand" "r")
8333                          (const_int 1)
8334                          (match_operand:DI 2 "register_operand" "q")))]
8335   "TARGET_64BIT"
8336   "extrd,u %1,%%sar,1,%0"
8337   [(set_attr "type" "shift")
8338    (set_attr "length" "4")])
8339
8340 ;;; Operands 2 and 3 are assumed to be CONST_INTs.
8341 (define_expand "extv"
8342   [(set (match_operand 0 "register_operand" "")
8343         (sign_extract (match_operand 1 "register_operand" "")
8344                       (match_operand 2 "uint32_operand" "")
8345                       (match_operand 3 "uint32_operand" "")))]
8346   ""
8347   "
8348 {
8349   HOST_WIDE_INT len = INTVAL (operands[2]);
8350   HOST_WIDE_INT pos = INTVAL (operands[3]);
8351
8352   /* PA extraction insns don't support zero length bitfields or fields
8353      extending beyond the left or right-most bits.  Also, we reject lengths
8354      equal to a word as they are better handled by the move patterns.  */
8355   if (len <= 0 || len >= BITS_PER_WORD || pos < 0 || pos + len > BITS_PER_WORD)
8356     FAIL;
8357
8358   /* From mips.md: extract_bit_field doesn't verify that our source
8359      matches the predicate, so check it again here.  */
8360   if (!register_operand (operands[1], VOIDmode))
8361     FAIL;
8362
8363   if (TARGET_64BIT)
8364     emit_insn (gen_extv_64 (operands[0], operands[1],
8365                             operands[2], operands[3]));
8366   else
8367     emit_insn (gen_extv_32 (operands[0], operands[1],
8368                             operands[2], operands[3]));
8369   DONE;
8370 }")
8371
8372 (define_insn "extv_32"
8373   [(set (match_operand:SI 0 "register_operand" "=r")
8374         (sign_extract:SI (match_operand:SI 1 "register_operand" "r")
8375                          (match_operand:SI 2 "uint5_operand" "")
8376                          (match_operand:SI 3 "uint5_operand" "")))]
8377   ""
8378   "{extrs|extrw,s} %1,%3+%2-1,%2,%0"
8379   [(set_attr "type" "shift")
8380    (set_attr "length" "4")])
8381
8382 (define_insn ""
8383   [(set (match_operand:SI 0 "register_operand" "=r")
8384         (sign_extract:SI (match_operand:SI 1 "register_operand" "r")
8385                          (const_int 1)
8386                          (match_operand:SI 2 "register_operand" "q")))]
8387   "!TARGET_64BIT"
8388   "{vextrs %1,1,%0|extrw,s %1,%%sar,1,%0}"
8389   [(set_attr "type" "shift")
8390    (set_attr "length" "4")])
8391
8392 (define_insn "extv_64"
8393   [(set (match_operand:DI 0 "register_operand" "=r")
8394         (sign_extract:DI (match_operand:DI 1 "register_operand" "r")
8395                          (match_operand:DI 2 "uint32_operand" "")
8396                          (match_operand:DI 3 "uint32_operand" "")))]
8397   "TARGET_64BIT"
8398   "extrd,s %1,%3+%2-1,%2,%0"
8399   [(set_attr "type" "shift")
8400    (set_attr "length" "4")])
8401
8402 (define_insn ""
8403   [(set (match_operand:DI 0 "register_operand" "=r")
8404         (sign_extract:DI (match_operand:DI 1 "register_operand" "r")
8405                          (const_int 1)
8406                          (match_operand:DI 2 "register_operand" "q")))]
8407   "TARGET_64BIT"
8408   "extrd,s %1,%%sar,1,%0"
8409   [(set_attr "type" "shift")
8410    (set_attr "length" "4")])
8411
8412 ;;; Operands 1 and 2 are assumed to be CONST_INTs.
8413 (define_expand "insv"
8414   [(set (zero_extract (match_operand 0 "register_operand" "")
8415                       (match_operand 1 "uint32_operand" "")
8416                       (match_operand 2 "uint32_operand" ""))
8417         (match_operand 3 "arith5_operand" ""))]
8418   ""
8419   "
8420 {
8421   HOST_WIDE_INT len = INTVAL (operands[1]);
8422   HOST_WIDE_INT pos = INTVAL (operands[2]);
8423
8424   /* PA insertion insns don't support zero length bitfields or fields
8425      extending beyond the left or right-most bits.  Also, we reject lengths
8426      equal to a word as they are better handled by the move patterns.  */
8427   if (len <= 0 || len >= BITS_PER_WORD || pos < 0 || pos + len > BITS_PER_WORD)
8428     FAIL;
8429
8430   /* From mips.md: insert_bit_field doesn't verify that our destination
8431      matches the predicate, so check it again here.  */
8432   if (!register_operand (operands[0], VOIDmode))
8433     FAIL;
8434
8435   if (TARGET_64BIT)
8436     emit_insn (gen_insv_64 (operands[0], operands[1],
8437                             operands[2], operands[3]));
8438   else
8439     emit_insn (gen_insv_32 (operands[0], operands[1],
8440                             operands[2], operands[3]));
8441   DONE;
8442 }")
8443
8444 (define_insn "insv_32"
8445   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r,r")
8446                          (match_operand:SI 1 "uint5_operand" "")
8447                          (match_operand:SI 2 "uint5_operand" ""))
8448         (match_operand:SI 3 "arith5_operand" "r,L"))]
8449   ""
8450   "@
8451    {dep|depw} %3,%2+%1-1,%1,%0
8452    {depi|depwi} %3,%2+%1-1,%1,%0"
8453   [(set_attr "type" "shift,shift")
8454    (set_attr "length" "4,4")])
8455
8456 ;; Optimize insertion of const_int values of type 1...1xxxx.
8457 (define_insn ""
8458   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
8459                          (match_operand:SI 1 "uint5_operand" "")
8460                          (match_operand:SI 2 "uint5_operand" ""))
8461         (match_operand:SI 3 "const_int_operand" ""))]
8462   "(INTVAL (operands[3]) & 0x10) != 0 &&
8463    (~INTVAL (operands[3]) & ((1L << INTVAL (operands[1])) - 1) & ~0xf) == 0"
8464   "*
8465 {
8466   operands[3] = GEN_INT ((INTVAL (operands[3]) & 0xf) - 0x10);
8467   return \"{depi|depwi} %3,%2+%1-1,%1,%0\";
8468 }"
8469   [(set_attr "type" "shift")
8470    (set_attr "length" "4")])
8471
8472 (define_insn "insv_64"
8473   [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+r,r")
8474                          (match_operand:DI 1 "uint32_operand" "")
8475                          (match_operand:DI 2 "uint32_operand" ""))
8476         (match_operand:DI 3 "arith32_operand" "r,L"))]
8477   "TARGET_64BIT"
8478   "@
8479    depd %3,%2+%1-1,%1,%0
8480    depdi %3,%2+%1-1,%1,%0"
8481   [(set_attr "type" "shift,shift")
8482    (set_attr "length" "4,4")])
8483
8484 ;; Optimize insertion of const_int values of type 1...1xxxx.
8485 (define_insn ""
8486   [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+r")
8487                          (match_operand:DI 1 "uint32_operand" "")
8488                          (match_operand:DI 2 "uint32_operand" ""))
8489         (match_operand:DI 3 "const_int_operand" ""))]
8490   "(INTVAL (operands[3]) & 0x10) != 0
8491    && TARGET_64BIT
8492    && (~INTVAL (operands[3]) & ((1L << INTVAL (operands[1])) - 1) & ~0xf) == 0"
8493   "*
8494 {
8495   operands[3] = GEN_INT ((INTVAL (operands[3]) & 0xf) - 0x10);
8496   return \"depdi %3,%2+%1-1,%1,%0\";
8497 }"
8498   [(set_attr "type" "shift")
8499    (set_attr "length" "4")])
8500
8501 (define_insn ""
8502   [(set (match_operand:DI 0 "register_operand" "=r")
8503         (ashift:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
8504                    (const_int 32)))]
8505   "TARGET_64BIT"
8506   "depd,z %1,31,32,%0"
8507   [(set_attr "type" "shift")
8508    (set_attr "length" "4")])
8509
8510 ;; This insn is used for some loop tests, typically loops reversed when
8511 ;; strength reduction is used.  It is actually created when the instruction
8512 ;; combination phase combines the special loop test.  Since this insn
8513 ;; is both a jump insn and has an output, it must deal with its own
8514 ;; reloads, hence the `m' constraints.  The `!' constraints direct reload
8515 ;; to not choose the register alternatives in the event a reload is needed.
8516 (define_insn "decrement_and_branch_until_zero"
8517   [(set (pc)
8518         (if_then_else
8519           (match_operator 2 "comparison_operator"
8520            [(plus:SI
8521               (match_operand:SI 0 "reg_before_reload_operand" "+!r,!*f,*m")
8522               (match_operand:SI 1 "int5_operand" "L,L,L"))
8523             (const_int 0)])
8524           (label_ref (match_operand 3 "" ""))
8525           (pc)))
8526    (set (match_dup 0)
8527         (plus:SI (match_dup 0) (match_dup 1)))
8528    (clobber (match_scratch:SI 4 "=X,r,r"))]
8529   ""
8530   "* return output_dbra (operands, insn, which_alternative); "
8531 ;; Do not expect to understand this the first time through.
8532 [(set_attr "type" "cbranch,multi,multi")
8533  (set (attr "length")
8534       (if_then_else (eq_attr "alternative" "0")
8535 ;; Loop counter in register case
8536 ;; Short branch has length of 4
8537 ;; Long branch has length of 8
8538         (if_then_else (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
8539                       (const_int 8184))
8540            (const_int 4)
8541            (const_int 8))
8542
8543 ;; Loop counter in FP reg case.
8544 ;; Extra goo to deal with additional reload insns.
8545         (if_then_else (eq_attr "alternative" "1")
8546           (if_then_else (lt (match_dup 3) (pc))
8547             (if_then_else
8548               (lt (abs (minus (match_dup 3) (plus (pc) (const_int 24))))
8549                   (const_int 8184))
8550               (const_int 24)
8551               (const_int 28))
8552             (if_then_else
8553               (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
8554                   (const_int 8184))
8555               (const_int 24)
8556               (const_int 28)))
8557 ;; Loop counter in memory case.
8558 ;; Extra goo to deal with additional reload insns.
8559         (if_then_else (lt (match_dup 3) (pc))
8560           (if_then_else
8561             (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
8562                 (const_int 8184))
8563             (const_int 12)
8564             (const_int 16))
8565           (if_then_else
8566             (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
8567                 (const_int 8184))
8568             (const_int 12)
8569             (const_int 16))))))])
8570
8571 (define_insn ""
8572   [(set (pc)
8573         (if_then_else
8574           (match_operator 2 "movb_comparison_operator"
8575            [(match_operand:SI 1 "register_operand" "r,r,r,r") (const_int 0)])
8576           (label_ref (match_operand 3 "" ""))
8577           (pc)))
8578    (set (match_operand:SI 0 "reg_before_reload_operand" "=!r,!*f,*m,!*q")
8579         (match_dup 1))]
8580   ""
8581 "* return output_movb (operands, insn, which_alternative, 0); "
8582 ;; Do not expect to understand this the first time through.
8583 [(set_attr "type" "cbranch,multi,multi,multi")
8584  (set (attr "length")
8585       (if_then_else (eq_attr "alternative" "0")
8586 ;; Loop counter in register case
8587 ;; Short branch has length of 4
8588 ;; Long branch has length of 8
8589         (if_then_else (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
8590                       (const_int 8184))
8591            (const_int 4)
8592            (const_int 8))
8593
8594 ;; Loop counter in FP reg case.
8595 ;; Extra goo to deal with additional reload insns.
8596         (if_then_else (eq_attr "alternative" "1")
8597           (if_then_else (lt (match_dup 3) (pc))
8598             (if_then_else
8599               (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
8600                   (const_int 8184))
8601               (const_int 12)
8602               (const_int 16))
8603             (if_then_else
8604               (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
8605                   (const_int 8184))
8606               (const_int 12)
8607               (const_int 16)))
8608 ;; Loop counter in memory or sar case.
8609 ;; Extra goo to deal with additional reload insns.
8610         (if_then_else
8611           (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
8612               (const_int 8184))
8613           (const_int 8)
8614           (const_int 12)))))])
8615
8616 ;; Handle negated branch.
8617 (define_insn ""
8618   [(set (pc)
8619         (if_then_else
8620           (match_operator 2 "movb_comparison_operator"
8621            [(match_operand:SI 1 "register_operand" "r,r,r,r") (const_int 0)])
8622           (pc)
8623           (label_ref (match_operand 3 "" ""))))
8624    (set (match_operand:SI 0 "reg_before_reload_operand" "=!r,!*f,*m,!*q")
8625         (match_dup 1))]
8626   ""
8627 "* return output_movb (operands, insn, which_alternative, 1); "
8628 ;; Do not expect to understand this the first time through.
8629 [(set_attr "type" "cbranch,multi,multi,multi")
8630  (set (attr "length")
8631       (if_then_else (eq_attr "alternative" "0")
8632 ;; Loop counter in register case
8633 ;; Short branch has length of 4
8634 ;; Long branch has length of 8
8635         (if_then_else (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
8636                       (const_int 8184))
8637            (const_int 4)
8638            (const_int 8))
8639
8640 ;; Loop counter in FP reg case.
8641 ;; Extra goo to deal with additional reload insns.
8642         (if_then_else (eq_attr "alternative" "1")
8643           (if_then_else (lt (match_dup 3) (pc))
8644             (if_then_else
8645               (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
8646                   (const_int 8184))
8647               (const_int 12)
8648               (const_int 16))
8649             (if_then_else
8650               (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
8651                   (const_int 8184))
8652               (const_int 12)
8653               (const_int 16)))
8654 ;; Loop counter in memory or SAR case.
8655 ;; Extra goo to deal with additional reload insns.
8656         (if_then_else
8657           (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
8658               (const_int 8184))
8659           (const_int 8)
8660           (const_int 12)))))])
8661
8662 (define_insn ""
8663   [(set (pc) (label_ref (match_operand 3 "" "" )))
8664    (set (match_operand:SI 0 "ireg_operand" "=r")
8665         (plus:SI (match_operand:SI 1 "ireg_operand" "r")
8666                  (match_operand:SI 2 "ireg_or_int5_operand" "rL")))]
8667   "(reload_completed && operands[0] == operands[1]) || operands[0] == operands[2]"
8668   "*
8669 {
8670   return output_parallel_addb (operands, get_attr_length (insn));
8671 }"
8672   [(set_attr "type" "parallel_branch")
8673    (set (attr "length")
8674     (if_then_else (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
8675                       (const_int 8184))
8676            (const_int 4)
8677            (const_int 8)))])
8678
8679 (define_insn ""
8680   [(set (pc) (label_ref (match_operand 2 "" "" )))
8681    (set (match_operand:SF 0 "ireg_operand" "=r")
8682         (match_operand:SF 1 "ireg_or_int5_operand" "rL"))]
8683   "reload_completed"
8684   "*
8685 {
8686   return output_parallel_movb (operands, get_attr_length (insn));
8687 }"
8688   [(set_attr "type" "parallel_branch")
8689    (set (attr "length")
8690     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
8691                       (const_int 8184))
8692            (const_int 4)
8693            (const_int 8)))])
8694
8695 (define_insn ""
8696   [(set (pc) (label_ref (match_operand 2 "" "" )))
8697    (set (match_operand:SI 0 "ireg_operand" "=r")
8698         (match_operand:SI 1 "ireg_or_int5_operand" "rL"))]
8699   "reload_completed"
8700   "*
8701 {
8702   return output_parallel_movb (operands, get_attr_length (insn));
8703 }"
8704   [(set_attr "type" "parallel_branch")
8705    (set (attr "length")
8706     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
8707                       (const_int 8184))
8708            (const_int 4)
8709            (const_int 8)))])
8710
8711 (define_insn ""
8712   [(set (pc) (label_ref (match_operand 2 "" "" )))
8713    (set (match_operand:HI 0 "ireg_operand" "=r")
8714         (match_operand:HI 1 "ireg_or_int5_operand" "rL"))]
8715   "reload_completed"
8716   "*
8717 {
8718   return output_parallel_movb (operands, get_attr_length (insn));
8719 }"
8720   [(set_attr "type" "parallel_branch")
8721    (set (attr "length")
8722     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
8723                       (const_int 8184))
8724            (const_int 4)
8725            (const_int 8)))])
8726
8727 (define_insn ""
8728   [(set (pc) (label_ref (match_operand 2 "" "" )))
8729    (set (match_operand:QI 0 "ireg_operand" "=r")
8730         (match_operand:QI 1 "ireg_or_int5_operand" "rL"))]
8731   "reload_completed"
8732   "*
8733 {
8734   return output_parallel_movb (operands, get_attr_length (insn));
8735 }"
8736   [(set_attr "type" "parallel_branch")
8737    (set (attr "length")
8738     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
8739                       (const_int 8184))
8740            (const_int 4)
8741            (const_int 8)))])
8742
8743 (define_insn ""
8744   [(set (match_operand 0 "register_operand" "=f")
8745         (mult (match_operand 1 "register_operand" "f")
8746               (match_operand 2 "register_operand" "f")))
8747    (set (match_operand 3 "register_operand" "+f")
8748         (plus (match_operand 4 "register_operand" "f")
8749               (match_operand 5 "register_operand" "f")))]
8750   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
8751    && reload_completed && fmpyaddoperands (operands)"
8752   "*
8753 {
8754   if (GET_MODE (operands[0]) == DFmode)
8755     {
8756       if (rtx_equal_p (operands[3], operands[5]))
8757         return \"fmpyadd,dbl %1,%2,%0,%4,%3\";
8758       else
8759         return \"fmpyadd,dbl %1,%2,%0,%5,%3\";
8760     }
8761   else
8762     {
8763       if (rtx_equal_p (operands[3], operands[5]))
8764         return \"fmpyadd,sgl %1,%2,%0,%4,%3\";
8765       else
8766         return \"fmpyadd,sgl %1,%2,%0,%5,%3\";
8767     }
8768 }"
8769   [(set_attr "type" "fpalu")
8770    (set_attr "length" "4")])
8771
8772 (define_insn ""
8773   [(set (match_operand 3 "register_operand" "+f")
8774         (plus (match_operand 4 "register_operand" "f")
8775               (match_operand 5 "register_operand" "f")))
8776    (set (match_operand 0 "register_operand" "=f")
8777         (mult (match_operand 1 "register_operand" "f")
8778               (match_operand 2 "register_operand" "f")))]
8779   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
8780    && reload_completed && fmpyaddoperands (operands)"
8781   "*
8782 {
8783   if (GET_MODE (operands[0]) == DFmode)
8784     {
8785       if (rtx_equal_p (operands[3], operands[5]))
8786         return \"fmpyadd,dbl %1,%2,%0,%4,%3\";
8787       else
8788         return \"fmpyadd,dbl %1,%2,%0,%5,%3\";
8789     }
8790   else
8791     {
8792       if (rtx_equal_p (operands[3], operands[5]))
8793         return \"fmpyadd,sgl %1,%2,%0,%4,%3\";
8794       else
8795         return \"fmpyadd,sgl %1,%2,%0,%5,%3\";
8796     }
8797 }"
8798   [(set_attr "type" "fpalu")
8799    (set_attr "length" "4")])
8800
8801 (define_insn ""
8802   [(set (match_operand 0 "register_operand" "=f")
8803         (mult (match_operand 1 "register_operand" "f")
8804               (match_operand 2 "register_operand" "f")))
8805    (set (match_operand 3 "register_operand" "+f")
8806         (minus (match_operand 4 "register_operand" "f")
8807                (match_operand 5 "register_operand" "f")))]
8808   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
8809    && reload_completed && fmpysuboperands (operands)"
8810   "*
8811 {
8812   if (GET_MODE (operands[0]) == DFmode)
8813     return \"fmpysub,dbl %1,%2,%0,%5,%3\";
8814   else
8815     return \"fmpysub,sgl %1,%2,%0,%5,%3\";
8816 }"
8817   [(set_attr "type" "fpalu")
8818    (set_attr "length" "4")])
8819
8820 (define_insn ""
8821   [(set (match_operand 3 "register_operand" "+f")
8822         (minus (match_operand 4 "register_operand" "f")
8823                (match_operand 5 "register_operand" "f")))
8824    (set (match_operand 0 "register_operand" "=f")
8825         (mult (match_operand 1 "register_operand" "f")
8826               (match_operand 2 "register_operand" "f")))]
8827   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
8828    && reload_completed && fmpysuboperands (operands)"
8829   "*
8830 {
8831   if (GET_MODE (operands[0]) == DFmode)
8832     return \"fmpysub,dbl %1,%2,%0,%5,%3\";
8833   else
8834     return \"fmpysub,sgl %1,%2,%0,%5,%3\";
8835 }"
8836   [(set_attr "type" "fpalu")
8837    (set_attr "length" "4")])
8838
8839 ;; Clean up turds left by reload.
8840 (define_peephole
8841   [(set (match_operand 0 "move_dest_operand" "")
8842         (match_operand 1 "register_operand" "fr"))
8843    (set (match_operand 2 "register_operand" "fr")
8844         (match_dup 0))]
8845   "!TARGET_SOFT_FLOAT
8846    && GET_CODE (operands[0]) == MEM
8847    && ! MEM_VOLATILE_P (operands[0])
8848    && GET_MODE (operands[0]) == GET_MODE (operands[1])
8849    && GET_MODE (operands[0]) == GET_MODE (operands[2])
8850    && GET_MODE (operands[0]) == DFmode
8851    && GET_CODE (operands[1]) == REG
8852    && GET_CODE (operands[2]) == REG
8853    && ! side_effects_p (XEXP (operands[0], 0))
8854    && REGNO_REG_CLASS (REGNO (operands[1]))
8855       == REGNO_REG_CLASS (REGNO (operands[2]))"
8856   "*
8857 {
8858   rtx xoperands[2];
8859
8860   if (FP_REG_P (operands[1]))
8861     output_asm_insn (output_fp_move_double (operands), operands);
8862   else
8863     output_asm_insn (output_move_double (operands), operands);
8864
8865   if (rtx_equal_p (operands[1], operands[2]))
8866     return \"\";
8867
8868   xoperands[0] = operands[2];
8869   xoperands[1] = operands[1];
8870       
8871   if (FP_REG_P (xoperands[1]))
8872     output_asm_insn (output_fp_move_double (xoperands), xoperands);
8873   else
8874     output_asm_insn (output_move_double (xoperands), xoperands);
8875
8876   return \"\";
8877 }")
8878
8879 (define_peephole
8880   [(set (match_operand 0 "register_operand" "fr")
8881         (match_operand 1 "move_src_operand" ""))
8882    (set (match_operand 2 "register_operand" "fr")
8883         (match_dup 1))]
8884   "!TARGET_SOFT_FLOAT
8885    && GET_CODE (operands[1]) == MEM
8886    && ! MEM_VOLATILE_P (operands[1])
8887    && GET_MODE (operands[0]) == GET_MODE (operands[1])
8888    && GET_MODE (operands[0]) == GET_MODE (operands[2])
8889    && GET_MODE (operands[0]) == DFmode
8890    && GET_CODE (operands[0]) == REG
8891    && GET_CODE (operands[2]) == REG
8892    && ! side_effects_p (XEXP (operands[1], 0))
8893    && REGNO_REG_CLASS (REGNO (operands[0]))
8894       == REGNO_REG_CLASS (REGNO (operands[2]))"
8895   "*
8896 {
8897   rtx xoperands[2];
8898
8899   if (FP_REG_P (operands[0]))
8900     output_asm_insn (output_fp_move_double (operands), operands);
8901   else
8902     output_asm_insn (output_move_double (operands), operands);
8903
8904   xoperands[0] = operands[2];
8905   xoperands[1] = operands[0];
8906       
8907   if (FP_REG_P (xoperands[1]))
8908     output_asm_insn (output_fp_move_double (xoperands), xoperands);
8909   else
8910     output_asm_insn (output_move_double (xoperands), xoperands);
8911
8912   return \"\";
8913 }")
8914
8915 ;; Flush the I and D cache lines from the start address (operand0)
8916 ;; to the end address (operand1).  No lines are flushed if the end
8917 ;; address is less than the start address (unsigned).
8918 ;;
8919 ;; Because the range of memory flushed is variable and the size of
8920 ;; a MEM can only be a CONST_INT, the patterns specify that they
8921 ;; perform an unspecified volatile operation on all memory.
8922 ;;
8923 ;; The address range for an icache flush must lie within a single
8924 ;; space on targets with non-equivalent space registers.
8925 ;;
8926 ;; This is used by the trampoline code for nested functions.
8927 ;;
8928 ;; Operand 0 contains the start address.
8929 ;; Operand 1 contains the end address.
8930 ;; Operand 2 contains the line length to use.
8931 ;; Operands 3 and 4 (icacheflush) are clobbered scratch registers.
8932 (define_insn "dcacheflush"
8933   [(const_int 1)
8934    (unspec_volatile [(mem:BLK (scratch))] 0)
8935    (use (match_operand 0 "pmode_register_operand" "r"))
8936    (use (match_operand 1 "pmode_register_operand" "r"))
8937    (use (match_operand 2 "pmode_register_operand" "r"))
8938    (clobber (match_scratch 3 "=&0"))]
8939   ""
8940   "*
8941 {
8942   if (TARGET_64BIT)
8943     return \"cmpb,*<<=,n %3,%1,.\;fdc,m %2(%3)\;sync\";
8944   else
8945     return \"cmpb,<<=,n %3,%1,.\;fdc,m %2(%3)\;sync\";
8946 }"
8947   [(set_attr "type" "multi")
8948    (set_attr "length" "12")])
8949
8950 (define_insn "icacheflush"
8951   [(const_int 2)
8952    (unspec_volatile [(mem:BLK (scratch))] 0)
8953    (use (match_operand 0 "pmode_register_operand" "r"))
8954    (use (match_operand 1 "pmode_register_operand" "r"))
8955    (use (match_operand 2 "pmode_register_operand" "r"))
8956    (clobber (match_operand 3 "pmode_register_operand" "=&r"))
8957    (clobber (match_operand 4 "pmode_register_operand" "=&r"))
8958    (clobber (match_scratch 5 "=&0"))]
8959   ""
8960   "*
8961 {
8962   if (TARGET_64BIT)
8963     return \"mfsp %%sr0,%4\;ldsid (%5),%3\;mtsp %3,%%sr0\;cmpb,*<<=,n %5,%1,.\;fic,m %2(%%sr0,%5)\;sync\;mtsp %4,%%sr0\;nop\;nop\;nop\;nop\;nop\;nop\";
8964   else
8965     return \"mfsp %%sr0,%4\;ldsid (%5),%3\;mtsp %3,%%sr0\;cmpb,<<=,n %5,%1,.\;fic,m %2(%%sr0,%5)\;sync\;mtsp %4,%%sr0\;nop\;nop\;nop\;nop\;nop\;nop\";
8966 }"
8967   [(set_attr "type" "multi")
8968    (set_attr "length" "52")])
8969
8970 ;; An out-of-line prologue.
8971 (define_insn "outline_prologue_call"
8972   [(unspec_volatile [(const_int 0)] 0)
8973    (clobber (reg:SI 31))
8974    (clobber (reg:SI 22))
8975    (clobber (reg:SI 21))
8976    (clobber (reg:SI 20))
8977    (clobber (reg:SI 19))
8978    (clobber (reg:SI 1))]
8979   ""
8980   "*
8981 {
8982   extern int frame_pointer_needed;
8983
8984   /* We need two different versions depending on whether or not we
8985      need a frame pointer.   Also note that we return to the instruction
8986      immediately after the branch rather than two instructions after the
8987      break as normally is the case.  */
8988   if (frame_pointer_needed)
8989     {
8990       /* Must import the magic millicode routine(s).  */
8991       output_asm_insn (\".IMPORT __outline_prologue_fp,MILLICODE\", NULL);
8992
8993       if (TARGET_PORTABLE_RUNTIME)
8994         {
8995           output_asm_insn (\"ldil L'__outline_prologue_fp,%%r31\", NULL);
8996           output_asm_insn (\"ble,n R'__outline_prologue_fp(%%sr0,%%r31)\",
8997                            NULL);
8998         }
8999       else
9000         output_asm_insn (\"{bl|b,l},n __outline_prologue_fp,%%r31\", NULL);
9001     }
9002   else
9003     {
9004       /* Must import the magic millicode routine(s).  */
9005       output_asm_insn (\".IMPORT __outline_prologue,MILLICODE\", NULL);
9006
9007       if (TARGET_PORTABLE_RUNTIME)
9008         {
9009           output_asm_insn (\"ldil L'__outline_prologue,%%r31\", NULL);
9010           output_asm_insn (\"ble,n R'__outline_prologue(%%sr0,%%r31)\", NULL);
9011         }
9012       else
9013         output_asm_insn (\"{bl|b,l},n __outline_prologue,%%r31\", NULL);
9014     }
9015   return \"\";
9016 }"
9017   [(set_attr "type" "multi")
9018    (set_attr "length" "8")])
9019
9020 ;; An out-of-line epilogue.
9021 (define_insn "outline_epilogue_call"
9022   [(unspec_volatile [(const_int 1)] 0)
9023    (use (reg:SI 29))
9024    (use (reg:SI 28))
9025    (clobber (reg:SI 31))
9026    (clobber (reg:SI 22))
9027    (clobber (reg:SI 21))
9028    (clobber (reg:SI 20))
9029    (clobber (reg:SI 19))
9030    (clobber (reg:SI 2))
9031    (clobber (reg:SI 1))]
9032   ""
9033   "*
9034 {
9035   extern int frame_pointer_needed;
9036
9037   /* We need two different versions depending on whether or not we
9038      need a frame pointer.   Also note that we return to the instruction
9039      immediately after the branch rather than two instructions after the
9040      break as normally is the case.  */
9041   if (frame_pointer_needed)
9042     {
9043       /* Must import the magic millicode routine.  */
9044       output_asm_insn (\".IMPORT __outline_epilogue_fp,MILLICODE\", NULL);
9045
9046       /* The out-of-line prologue will make sure we return to the right
9047          instruction.  */
9048       if (TARGET_PORTABLE_RUNTIME)
9049         {
9050           output_asm_insn (\"ldil L'__outline_epilogue_fp,%%r31\", NULL);
9051           output_asm_insn (\"ble,n R'__outline_epilogue_fp(%%sr0,%%r31)\",
9052                            NULL);
9053         }
9054       else
9055         output_asm_insn (\"{bl|b,l},n __outline_epilogue_fp,%%r31\", NULL);
9056     }
9057   else
9058     {
9059       /* Must import the magic millicode routine.  */
9060       output_asm_insn (\".IMPORT __outline_epilogue,MILLICODE\", NULL);
9061
9062       /* The out-of-line prologue will make sure we return to the right
9063          instruction.  */
9064       if (TARGET_PORTABLE_RUNTIME)
9065         {
9066           output_asm_insn (\"ldil L'__outline_epilogue,%%r31\", NULL);
9067           output_asm_insn (\"ble,n R'__outline_epilogue(%%sr0,%%r31)\", NULL);
9068         }
9069       else
9070         output_asm_insn (\"{bl|b,l},n __outline_epilogue,%%r31\", NULL);
9071     }
9072   return \"\";
9073 }"
9074   [(set_attr "type" "multi")
9075    (set_attr "length" "8")])
9076
9077 ;; Given a function pointer, canonicalize it so it can be 
9078 ;; reliably compared to another function pointer.  */
9079 (define_expand "canonicalize_funcptr_for_compare"
9080   [(set (reg:SI 26) (match_operand:SI 1 "register_operand" ""))
9081    (parallel [(set (reg:SI 29) (unspec:SI [(reg:SI 26)] 0))
9082               (clobber (match_dup 2))
9083               (clobber (reg:SI 26))
9084               (clobber (reg:SI 22))
9085               (clobber (reg:SI 31))])
9086    (set (match_operand:SI 0 "register_operand" "")
9087         (reg:SI 29))]
9088   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
9089   "
9090 {
9091   if (TARGET_ELF32)
9092     {
9093       rtx canonicalize_funcptr_for_compare_libfunc
9094         = init_one_libfunc (CANONICALIZE_FUNCPTR_FOR_COMPARE_LIBCALL);
9095
9096       emit_library_call_value (canonicalize_funcptr_for_compare_libfunc,
9097                                operands[0], LCT_NORMAL, Pmode,
9098                                1, operands[1], Pmode);
9099       DONE;
9100     }
9101
9102   operands[2] = gen_reg_rtx (SImode);
9103   if (GET_CODE (operands[1]) != REG)
9104     {
9105       rtx tmp = gen_reg_rtx (Pmode);
9106       emit_move_insn (tmp, operands[1]);
9107       operands[1] = tmp;
9108     }
9109 }")
9110
9111 (define_insn ""
9112   [(set (reg:SI 29) (unspec:SI [(reg:SI 26)] 0))
9113    (clobber (match_operand:SI 0 "register_operand" "=a"))
9114    (clobber (reg:SI 26))
9115    (clobber (reg:SI 22))
9116    (clobber (reg:SI 31))]
9117   "!TARGET_64BIT"
9118   "*
9119 {
9120   int length = get_attr_length (insn);
9121   rtx xoperands[2];
9122
9123   xoperands[0] = GEN_INT (length - 8);
9124   xoperands[1] = GEN_INT (length - 16);
9125
9126   /* Must import the magic millicode routine.  */
9127   output_asm_insn (\".IMPORT $$sh_func_adrs,MILLICODE\", NULL);
9128
9129   /* This is absolutely amazing.
9130
9131      First, copy our input parameter into %r29 just in case we don't
9132      need to call $$sh_func_adrs.  */
9133   output_asm_insn (\"copy %%r26,%%r29\", NULL);
9134   output_asm_insn (\"{extru|extrw,u} %%r26,31,2,%%r31\", NULL);
9135
9136   /* Next, examine the low two bits in %r26, if they aren't 0x2, then
9137      we use %r26 unchanged.  */
9138   output_asm_insn (\"{comib|cmpib},<>,n 2,%%r31,.+%0\", xoperands);
9139   output_asm_insn (\"ldi 4096,%%r31\", NULL);
9140
9141   /* Next, compare %r26 with 4096, if %r26 is less than or equal to
9142      4096, then again we use %r26 unchanged.  */
9143   output_asm_insn (\"{comb|cmpb},<<,n %%r26,%%r31,.+%1\", xoperands);
9144
9145   /* Finally, call $$sh_func_adrs to extract the function's real add24.  */
9146   return output_millicode_call (insn,
9147                                 gen_rtx_SYMBOL_REF (SImode,
9148                                                     \"$$sh_func_adrs\"));
9149 }"
9150   [(set_attr "type" "multi")
9151    (set (attr "length")
9152         (plus (symbol_ref "attr_length_millicode_call (insn)")
9153               (const_int 20)))])
9154
9155 ;; On the PA, the PIC register is call clobbered, so it must
9156 ;; be saved & restored around calls by the caller.  If the call
9157 ;; doesn't return normally (nonlocal goto, or an exception is
9158 ;; thrown), then the code at the exception handler label must
9159 ;; restore the PIC register.
9160 (define_expand "exception_receiver"
9161   [(const_int 4)]
9162   "flag_pic"
9163   "
9164 {
9165   /* On the 64-bit port, we need a blockage because there is
9166      confusion regarding the dependence of the restore on the
9167      frame pointer.  As a result, the frame pointer and pic
9168      register restores sometimes are interchanged erroneously.  */
9169   if (TARGET_64BIT)
9170     emit_insn (gen_blockage ());
9171   /* Restore the PIC register using hppa_pic_save_rtx ().  The
9172      PIC register is not saved in the frame in 64-bit ABI.  */
9173   emit_move_insn (pic_offset_table_rtx, hppa_pic_save_rtx ());
9174   emit_insn (gen_blockage ());
9175   DONE;
9176 }")
9177
9178 (define_expand "builtin_setjmp_receiver"
9179   [(label_ref (match_operand 0 "" ""))]
9180   "flag_pic"
9181   "
9182 {
9183   if (TARGET_64BIT)
9184     emit_insn (gen_blockage ());
9185   /* Restore the PIC register.  Hopefully, this will always be from
9186      a stack slot.  The only registers that are valid after a
9187      builtin_longjmp are the stack and frame pointers.  */
9188   emit_move_insn (pic_offset_table_rtx, hppa_pic_save_rtx ());
9189   emit_insn (gen_blockage ());
9190   DONE;
9191 }")
9192
9193 ;; Allocate new stack space and update the saved stack pointer in the
9194 ;; frame marker.  The HP C compilers also copy additional words in the
9195 ;; frame marker.  The 64-bit compiler copies words at -48, -32 and -24.
9196 ;; The 32-bit compiler copies the word at -16 (Static Link).  We
9197 ;; currently don't copy these values.
9198 ;;
9199 ;; Since the copy of the frame marker can't be done atomically, I
9200 ;; suspect that using it for unwind purposes may be somewhat unreliable.
9201 ;; The HP compilers appear to raise the stack and copy the frame
9202 ;; marker in a strict instruction sequence.  This suggests that the
9203 ;; unwind library may check for an alloca sequence when ALLOCA_FRAME
9204 ;; is set in the callinfo data.  We currently don't set ALLOCA_FRAME
9205 ;; as GAS doesn't support it, or try to keep the instructions emitted
9206 ;; here in strict sequence.
9207 (define_expand "allocate_stack"
9208   [(match_operand 0 "" "")
9209    (match_operand 1 "" "")]
9210   ""
9211   "
9212 {
9213   rtx addr;
9214
9215   /* Since the stack grows upward, we need to store virtual_stack_dynamic_rtx
9216      in operand 0 before adjusting the stack.  */
9217   emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
9218   anti_adjust_stack (operands[1]);
9219   if (TARGET_HPUX_UNWIND_LIBRARY)
9220     {
9221       addr = gen_rtx_PLUS (word_mode, stack_pointer_rtx,
9222                            GEN_INT (TARGET_64BIT ? -8 : -4));
9223       emit_move_insn (gen_rtx_MEM (word_mode, addr), frame_pointer_rtx);
9224     }
9225   if (!TARGET_64BIT && flag_pic)
9226     {
9227       rtx addr = gen_rtx_PLUS (word_mode, stack_pointer_rtx, GEN_INT (-32));
9228       emit_move_insn (gen_rtx_MEM (word_mode, addr), pic_offset_table_rtx);
9229     }
9230   DONE;
9231 }")