OSDN Git Service

* emit-rtl.c (global_rtl): Update comment.
[pf3gnuchains/gcc-fork.git] / gcc / config / pa / pa.md
1 ;;- Machine description for HP PA-RISC architecture for GNU C compiler
2 ;;   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
3 ;;   2002 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 GNU CC.
8
9 ;; GNU CC 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 ;; GNU CC 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 GNU CC; 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,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,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,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,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.  Note it disallows delay slot
109 ;; when TARGET_PORTABLE_RUNTIME is true.
110 (define_delay (eq_attr "type" "milli")
111   [(and (eq_attr "in_call_delay" "true")
112         (eq (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0)))
113    (nil) (nil)])
114
115 ;; Return and other similar instructions.
116 (define_delay (eq_attr "type" "branch,parallel_branch")
117   [(eq_attr "in_branch_delay" "true") (nil) (nil)])
118
119 ;; Floating point conditional branch delay slot description and
120 (define_delay (eq_attr "type" "fbranch")
121   [(eq_attr "in_branch_delay" "true")
122    (eq_attr "in_nullified_branch_delay" "true")
123    (nil)])
124
125 ;; Integer conditional branch delay slot description.
126 ;; Nullification of conditional branches on the PA is dependent on the
127 ;; direction of the branch.  Forward branches nullify true and
128 ;; backward branches nullify false.  If the direction is unknown
129 ;; then nullification is not allowed.
130 (define_delay (eq_attr "type" "cbranch")
131   [(eq_attr "in_branch_delay" "true")
132    (and (eq_attr "in_nullified_branch_delay" "true")
133         (attr_flag "forward"))
134    (and (eq_attr "in_nullified_branch_delay" "true")
135         (attr_flag "backward"))])
136
137 (define_delay (and (eq_attr "type" "uncond_branch")
138                    (eq (symbol_ref "following_call (insn)")
139                        (const_int 0)))
140   [(eq_attr "in_branch_delay" "true") (nil) (nil)])
141
142 ;; Memory. Disregarding Cache misses, the Mustang memory times are:
143 ;; load: 2, fpload: 3
144 ;; store, fpstore: 3, no D-cache operations should be scheduled.
145
146 ;; The Timex (aka 700) has two floating-point units: ALU, and MUL/DIV/SQRT.
147 ;; Timings:
148 ;; Instruction  Time    Unit    Minimum Distance (unit contention)
149 ;; fcpy         3       ALU     2
150 ;; fabs         3       ALU     2
151 ;; fadd         3       ALU     2
152 ;; fsub         3       ALU     2
153 ;; fcmp         3       ALU     2
154 ;; fcnv         3       ALU     2
155 ;; fmpyadd      3       ALU,MPY 2
156 ;; fmpysub      3       ALU,MPY 2
157 ;; fmpycfxt     3       ALU,MPY 2
158 ;; fmpy         3       MPY     2
159 ;; fmpyi        3       MPY     2
160 ;; fdiv,sgl     10      MPY     10
161 ;; fdiv,dbl     12      MPY     12
162 ;; fsqrt,sgl    14      MPY     14
163 ;; fsqrt,dbl    18      MPY     18
164 ;;
165 ;; We don't model fmpyadd/fmpysub properly as those instructions
166 ;; keep both the FP ALU and MPY units busy.  Given that these
167 ;; processors are obsolete, I'm not going to spend the time to
168 ;; model those instructions correctly.
169
170 (define_automaton "pa700")
171 (define_cpu_unit "dummy_700,mem_700,fpalu_700,fpmpy_700" "pa700")
172
173 (define_insn_reservation "W0" 4
174   (and (eq_attr "type" "fpcc")
175        (eq_attr "cpu" "700"))
176   "fpalu_700*2")
177
178 (define_insn_reservation "W1" 3
179   (and (eq_attr "type" "fpalu")
180        (eq_attr "cpu" "700"))
181   "fpalu_700*2")
182
183 (define_insn_reservation "W2" 3
184   (and (eq_attr "type" "fpmulsgl,fpmuldbl")
185        (eq_attr "cpu" "700"))
186   "fpmpy_700*2")
187
188 (define_insn_reservation "W3" 10
189   (and (eq_attr "type" "fpdivsgl")
190        (eq_attr "cpu" "700"))
191   "fpmpy_700*10")
192
193 (define_insn_reservation "W4" 12
194   (and (eq_attr "type" "fpdivdbl")
195        (eq_attr "cpu" "700"))
196   "fpmpy_700*12")
197
198 (define_insn_reservation "W5" 14
199   (and (eq_attr "type" "fpsqrtsgl")
200        (eq_attr "cpu" "700"))
201   "fpmpy_700*14")
202
203 (define_insn_reservation "W6" 18
204   (and (eq_attr "type" "fpsqrtdbl")
205        (eq_attr "cpu" "700"))
206   "fpmpy_700*18")
207
208 (define_insn_reservation "W7" 2
209   (and (eq_attr "type" "load")
210        (eq_attr "cpu" "700"))
211   "mem_700")
212
213 (define_insn_reservation "W8" 2
214   (and (eq_attr "type" "fpload")
215        (eq_attr "cpu" "700"))
216   "mem_700")
217
218 (define_insn_reservation "W9" 3
219   (and (eq_attr "type" "store")
220        (eq_attr "cpu" "700"))
221   "mem_700*3")
222
223 (define_insn_reservation "W10" 3
224   (and (eq_attr "type" "fpstore")
225        (eq_attr "cpu" "700"))
226   "mem_700*3")
227
228 (define_insn_reservation "W11" 1
229   (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpdivdbl,fpsqrtsgl,fpsqrtdbl,load,fpload,store,fpstore")
230        (eq_attr "cpu" "700"))
231   "dummy_700")
232
233 ;; We have a bypass for all computations in the FP unit which feed an
234 ;; FP store as long as the sizes are the same.
235 (define_bypass 2 "W1,W2" "W10" "hppa_fpstore_bypass_p")
236 (define_bypass 9 "W3" "W10" "hppa_fpstore_bypass_p")
237 (define_bypass 11 "W4" "W10" "hppa_fpstore_bypass_p")
238 (define_bypass 13 "W5" "W10" "hppa_fpstore_bypass_p")
239 (define_bypass 17 "W6" "W10" "hppa_fpstore_bypass_p")
240
241 ;; We have an "anti-bypass" for FP loads which feed an FP store.
242 (define_bypass 4 "W8" "W10" "hppa_fpstore_bypass_p")
243
244 ;; Function units for the 7100 and 7150.  The 7100/7150 can dual-issue
245 ;; floating point computations with non-floating point computations (fp loads
246 ;; and stores are not fp computations).
247 ;;
248 ;; Memory. Disregarding Cache misses, memory loads take two cycles; stores also
249 ;; take two cycles, during which no Dcache operations should be scheduled.
250 ;; Any special cases are handled in pa_adjust_cost.  The 7100, 7150 and 7100LC
251 ;; all have the same memory characteristics if one disregards cache misses.
252 ;;
253 ;; The 7100/7150 has three floating-point units: ALU, MUL, and DIV.
254 ;; There's no value in modeling the ALU and MUL separately though
255 ;; since there can never be a functional unit conflict given the
256 ;; latency and issue rates for those units.
257 ;;
258 ;; Timings:
259 ;; Instruction  Time    Unit    Minimum Distance (unit contention)
260 ;; fcpy         2       ALU     1
261 ;; fabs         2       ALU     1
262 ;; fadd         2       ALU     1
263 ;; fsub         2       ALU     1
264 ;; fcmp         2       ALU     1
265 ;; fcnv         2       ALU     1
266 ;; fmpyadd      2       ALU,MPY 1
267 ;; fmpysub      2       ALU,MPY 1
268 ;; fmpycfxt     2       ALU,MPY 1
269 ;; fmpy         2       MPY     1
270 ;; fmpyi        2       MPY     1
271 ;; fdiv,sgl     8       DIV     8
272 ;; fdiv,dbl     15      DIV     15
273 ;; fsqrt,sgl    8       DIV     8
274 ;; fsqrt,dbl    15      DIV     15
275
276 (define_automaton "pa7100")
277 (define_cpu_unit "i_7100, f_7100,fpmac_7100,fpdivsqrt_7100,mem_7100" "pa7100")
278
279 (define_insn_reservation "X0" 2
280   (and (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
281        (eq_attr "cpu" "7100"))
282   "f_7100,fpmac_7100")
283
284 (define_insn_reservation "X1" 8
285   (and (eq_attr "type" "fpdivsgl,fpsqrtsgl")
286        (eq_attr "cpu" "7100"))
287   "f_7100+fpdivsqrt_7100,fpdivsqrt_7100*7")
288
289 (define_insn_reservation "X2" 15
290   (and (eq_attr "type" "fpdivdbl,fpsqrtdbl")
291        (eq_attr "cpu" "7100"))
292   "f_7100+fpdivsqrt_7100,fpdivsqrt_7100*14")
293
294 (define_insn_reservation "X3" 2
295   (and (eq_attr "type" "load")
296        (eq_attr "cpu" "7100"))
297   "i_7100+mem_7100")
298
299 (define_insn_reservation "X4" 2
300   (and (eq_attr "type" "fpload")
301        (eq_attr "cpu" "7100"))
302   "i_7100+mem_7100")
303
304 (define_insn_reservation "X5" 2
305   (and (eq_attr "type" "store")
306        (eq_attr "cpu" "7100"))
307   "i_7100+mem_7100,mem_7100")
308
309 (define_insn_reservation "X6" 2
310   (and (eq_attr "type" "fpstore")
311        (eq_attr "cpu" "7100"))
312   "i_7100+mem_7100,mem_7100")
313
314 (define_insn_reservation "X7" 1
315   (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl,load,fpload,store,fpstore")
316        (eq_attr "cpu" "7100"))
317   "i_7100")
318
319 ;; We have a bypass for all computations in the FP unit which feed an
320 ;; FP store as long as the sizes are the same.
321 (define_bypass 1 "X0" "X6" "hppa_fpstore_bypass_p")
322 (define_bypass 7 "X1" "X6" "hppa_fpstore_bypass_p")
323 (define_bypass 14 "X2" "X6" "hppa_fpstore_bypass_p")
324
325 ;; We have an "anti-bypass" for FP loads which feed an FP store.
326 (define_bypass 3 "X4" "X6" "hppa_fpstore_bypass_p")
327
328 ;; The 7100LC has three floating-point units: ALU, MUL, and DIV.
329 ;; There's no value in modeling the ALU and MUL separately though
330 ;; since there can never be a functional unit conflict that
331 ;; can be avoided given the latency, issue rates and mandatory
332 ;; one cycle cpu-wide lock for a double precision fp multiply.
333 ;;
334 ;; Timings:
335 ;; Instruction  Time    Unit    Minimum Distance (unit contention)
336 ;; fcpy         2       ALU     1
337 ;; fabs         2       ALU     1
338 ;; fadd         2       ALU     1
339 ;; fsub         2       ALU     1
340 ;; fcmp         2       ALU     1
341 ;; fcnv         2       ALU     1
342 ;; fmpyadd,sgl  2       ALU,MPY 1
343 ;; fmpyadd,dbl  3       ALU,MPY 2
344 ;; fmpysub,sgl  2       ALU,MPY 1
345 ;; fmpysub,dbl  3       ALU,MPY 2
346 ;; fmpycfxt,sgl 2       ALU,MPY 1
347 ;; fmpycfxt,dbl 3       ALU,MPY 2
348 ;; fmpy,sgl     2       MPY     1
349 ;; fmpy,dbl     3       MPY     2
350 ;; fmpyi        3       MPY     2
351 ;; fdiv,sgl     8       DIV     8
352 ;; fdiv,dbl     15      DIV     15
353 ;; fsqrt,sgl    8       DIV     8
354 ;; fsqrt,dbl    15      DIV     15
355 ;;
356 ;; The PA7200 is just like the PA7100LC except that there is
357 ;; no store-store penalty.
358 ;;
359 ;; The PA7300 is just like the PA7200 except that there is
360 ;; no store-load penalty.
361 ;;
362 ;; Note there are some aspects of the 7100LC we are not modeling
363 ;; at the moment.  I'll be reviewing the 7100LC scheduling info
364 ;; shortly and updating this description.
365 ;;
366 ;;   load-load pairs
367 ;;   store-store pairs
368 ;;   other issue modeling
369
370 (define_automaton "pa7100lc")
371 (define_cpu_unit "i0_7100lc, i1_7100lc, f_7100lc" "pa7100lc")
372 (define_cpu_unit "fpmac_7100lc" "pa7100lc")
373 (define_cpu_unit "mem_7100lc" "pa7100lc")
374
375 ;; Double precision multiplies lock the entire CPU for one
376 ;; cycle.  There is no way to avoid this lock and trying to
377 ;; schedule around the lock is pointless and thus there is no
378 ;; value in trying to model this lock.
379 ;;
380 ;; Not modeling the lock allows us to treat fp multiplies just
381 ;; like any other FP alu instruction.  It allows for a smaller
382 ;; DFA and may reduce register pressure.
383 (define_insn_reservation "Y0" 2
384   (and (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
385        (eq_attr "cpu" "7100LC,7200,7300"))
386   "f_7100lc,fpmac_7100lc")
387
388 ;; fp division and sqrt instructions lock the entire CPU for
389 ;; 7 cycles (single precision) or 14 cycles (double precision).
390 ;; There is no way to avoid this lock and trying to schedule
391 ;; around the lock is pointless and thus there is no value in
392 ;; trying to model this lock.  Not modeling the lock allows
393 ;; for a smaller DFA and may reduce register pressure.
394 (define_insn_reservation "Y1" 1
395   (and (eq_attr "type" "fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl")
396        (eq_attr "cpu" "7100LC,7200,7300"))
397   "f_7100lc")
398
399 (define_insn_reservation "Y2" 2
400   (and (eq_attr "type" "load")
401        (eq_attr "cpu" "7100LC,7200,7300"))
402   "i1_7100lc+mem_7100lc")
403
404 (define_insn_reservation "Y3" 2
405   (and (eq_attr "type" "fpload")
406        (eq_attr "cpu" "7100LC,7200,7300"))
407   "i1_7100lc+mem_7100lc")
408
409 (define_insn_reservation "Y4" 2
410   (and (eq_attr "type" "store")
411        (eq_attr "cpu" "7100LC"))
412   "i1_7100lc+mem_7100lc,mem_7100lc")
413
414 (define_insn_reservation "Y5" 2
415   (and (eq_attr "type" "fpstore")
416        (eq_attr "cpu" "7100LC"))
417   "i1_7100lc+mem_7100lc,mem_7100lc")
418
419 (define_insn_reservation "Y6" 1
420   (and (eq_attr "type" "shift,nullshift")
421        (eq_attr "cpu" "7100LC,7200,7300"))
422   "i1_7100lc")
423
424 (define_insn_reservation "Y7" 1
425   (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl,load,fpload,store,fpstore,shift,nullshift")
426        (eq_attr "cpu" "7100LC,7200,7300"))
427   "(i0_7100lc|i1_7100lc)")
428
429 ;; The 7200 has a store-load penalty
430 (define_insn_reservation "Y8" 2
431   (and (eq_attr "type" "store")
432        (eq_attr "cpu" "7200"))
433   "i1_7100lc,mem_7100lc")
434
435 (define_insn_reservation "Y9" 2
436   (and (eq_attr "type" "fpstore")
437        (eq_attr "cpu" "7200"))
438   "i1_7100lc,mem_7100lc")
439
440 ;; The 7300 has no penalty for store-store or store-load
441 (define_insn_reservation "Y10" 2
442   (and (eq_attr "type" "store")
443        (eq_attr "cpu" "7300"))
444   "i1_7100lc")
445
446 (define_insn_reservation "Y11" 2
447   (and (eq_attr "type" "fpstore")
448        (eq_attr "cpu" "7300"))
449   "i1_7100lc")
450
451 ;; We have an "anti-bypass" for FP loads which feed an FP store.
452 (define_bypass 3 "Y3" "Y5,Y9,Y11" "hppa_fpstore_bypass_p")
453
454 ;; Scheduling for the PA8000 is somewhat different than scheduling for a
455 ;; traditional architecture.
456 ;;
457 ;; The PA8000 has a large (56) entry reorder buffer that is split between
458 ;; memory and non-memory operations.
459 ;;
460 ;; The PA8000 can issue two memory and two non-memory operations per cycle to
461 ;; the function units, with the exception of branches and multi-output
462 ;; instructions.  The PA8000 can retire two non-memory operations per cycle
463 ;; and two memory operations per cycle, only one of which may be a store.
464 ;;
465 ;; Given the large reorder buffer, the processor can hide most latencies.
466 ;; According to HP, they've got the best results by scheduling for retirement
467 ;; bandwidth with limited latency scheduling for floating point operations.
468 ;; Latency for integer operations and memory references is ignored.
469 ;;
470 ;;
471 ;; We claim floating point operations have a 2 cycle latency and are
472 ;; fully pipelined, except for div and sqrt which are not pipelined and
473 ;; take from 17 to 31 cycles to complete.
474 ;;
475 ;; It's worth noting that there is no way to saturate all the functional
476 ;; units on the PA8000 as there is not enough issue bandwidth.
477
478 (define_automaton "pa8000")
479 (define_cpu_unit "inm0_8000, inm1_8000, im0_8000, im1_8000" "pa8000")
480 (define_cpu_unit "rnm0_8000, rnm1_8000, rm0_8000, rm1_8000" "pa8000")
481 (define_cpu_unit "store_8000" "pa8000")
482 (define_cpu_unit "f0_8000, f1_8000" "pa8000")
483 (define_cpu_unit "fdivsqrt0_8000, fdivsqrt1_8000" "pa8000")
484 (define_reservation "inm_8000" "inm0_8000 | inm1_8000")
485 (define_reservation "im_8000" "im0_8000 | im1_8000")
486 (define_reservation "rnm_8000" "rnm0_8000 | rnm1_8000")
487 (define_reservation "rm_8000" "rm0_8000 | rm1_8000")
488 (define_reservation "f_8000" "f0_8000 | f1_8000")
489 (define_reservation "fdivsqrt_8000" "fdivsqrt0_8000 | fdivsqrt1_8000")
490
491 ;; We can issue any two memops per cycle, but we can only retire
492 ;; one memory store per cycle.  We assume that the reorder buffer
493 ;; will hide any memory latencies per HP's recommendation.
494 (define_insn_reservation "Z0" 0
495   (and
496     (eq_attr "type" "load,fpload")
497     (eq_attr "cpu" "8000"))
498   "im_8000,rm_8000")
499
500 (define_insn_reservation "Z1" 0
501   (and
502     (eq_attr "type" "store,fpstore")
503     (eq_attr "cpu" "8000"))
504   "im_8000,rm_8000+store_8000")
505
506 ;; We can issue and retire two non-memory operations per cycle with
507 ;; a few exceptions (branches).  This group catches those we want
508 ;; to assume have zero latency.
509 (define_insn_reservation "Z2" 0
510   (and
511     (eq_attr "type" "!load,fpload,store,fpstore,uncond_branch,branch,cbranch,fbranch,call,dyncall,multi,milli,parallel_branch,fpcc,fpalu,fpmulsgl,fpmuldbl,fpsqrtsgl,fpsqrtdbl,fpdivsgl,fpdivdbl")
512     (eq_attr "cpu" "8000"))
513   "inm_8000,rnm_8000")
514
515 ;; Branches use both slots in the non-memory issue and
516 ;; retirement unit.
517 (define_insn_reservation "Z3" 0
518   (and
519     (eq_attr "type" "uncond_branch,branch,cbranch,fbranch,call,dyncall,multi,milli,parallel_branch")
520     (eq_attr "cpu" "8000"))
521   "inm0_8000+inm1_8000,rnm0_8000+rnm1_8000")
522
523 ;; We partial latency schedule the floating point units.
524 ;; They can issue/retire two at a time in the non-memory
525 ;; units.  We fix their latency at 2 cycles and they
526 ;; are fully pipelined.
527 (define_insn_reservation "Z4" 1
528  (and
529    (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
530    (eq_attr "cpu" "8000"))
531  "inm_8000,f_8000,rnm_8000")
532
533 ;; The fdivsqrt units are not pipelined and have a very long latency.  
534 ;; To keep the DFA from exploding, we do not show all the
535 ;; reservations for the divsqrt unit.
536 (define_insn_reservation "Z5" 17
537  (and
538    (eq_attr "type" "fpdivsgl,fpsqrtsgl")
539    (eq_attr "cpu" "8000"))
540  "inm_8000,fdivsqrt_8000*6,rnm_8000")
541
542 (define_insn_reservation "Z6" 31
543  (and
544    (eq_attr "type" "fpdivdbl,fpsqrtdbl")
545    (eq_attr "cpu" "8000"))
546  "inm_8000,fdivsqrt_8000*6,rnm_8000")
547
548
549 \f
550 ;; Compare instructions.
551 ;; This controls RTL generation and register allocation.
552
553 ;; We generate RTL for comparisons and branches by having the cmpxx
554 ;; patterns store away the operands.  Then, the scc and bcc patterns
555 ;; emit RTL for both the compare and the branch.
556 ;;
557
558 (define_expand "cmpdi"
559   [(set (reg:CC 0)
560         (compare:CC (match_operand:DI 0 "reg_or_0_operand" "")
561                     (match_operand:DI 1 "register_operand" "")))]
562   "TARGET_64BIT"
563
564   "
565 {
566  hppa_compare_op0 = operands[0];
567  hppa_compare_op1 = operands[1];
568  hppa_branch_type = CMP_SI;
569  DONE;
570 }")
571
572 (define_expand "cmpsi"
573   [(set (reg:CC 0)
574         (compare:CC (match_operand:SI 0 "reg_or_0_operand" "")
575                     (match_operand:SI 1 "arith5_operand" "")))]
576   ""
577   "
578 {
579  hppa_compare_op0 = operands[0];
580  hppa_compare_op1 = operands[1];
581  hppa_branch_type = CMP_SI;
582  DONE;
583 }")
584
585 (define_expand "cmpsf"
586   [(set (reg:CCFP 0)
587         (compare:CCFP (match_operand:SF 0 "reg_or_0_operand" "")
588                       (match_operand:SF 1 "reg_or_0_operand" "")))]
589   "! TARGET_SOFT_FLOAT"
590   "
591 {
592   hppa_compare_op0 = operands[0];
593   hppa_compare_op1 = operands[1];
594   hppa_branch_type = CMP_SF;
595   DONE;
596 }")
597
598 (define_expand "cmpdf"
599   [(set (reg:CCFP 0)
600       (compare:CCFP (match_operand:DF 0 "reg_or_0_operand" "")
601                     (match_operand:DF 1 "reg_or_0_operand" "")))]
602   "! TARGET_SOFT_FLOAT"
603   "
604 {
605   hppa_compare_op0 = operands[0];
606   hppa_compare_op1 = operands[1];
607   hppa_branch_type = CMP_DF;
608   DONE;
609 }")
610
611 (define_insn ""
612   [(set (reg:CCFP 0)
613         (match_operator:CCFP 2 "comparison_operator"
614                              [(match_operand:SF 0 "reg_or_0_operand" "fG")
615                               (match_operand:SF 1 "reg_or_0_operand" "fG")]))]
616   "! TARGET_SOFT_FLOAT"
617   "fcmp,sgl,%Y2 %f0,%f1"
618   [(set_attr "length" "4")
619    (set_attr "type" "fpcc")])
620
621 (define_insn ""
622   [(set (reg:CCFP 0)
623         (match_operator:CCFP 2 "comparison_operator"
624                              [(match_operand:DF 0 "reg_or_0_operand" "fG")
625                               (match_operand:DF 1 "reg_or_0_operand" "fG")]))]
626   "! TARGET_SOFT_FLOAT"
627   "fcmp,dbl,%Y2 %f0,%f1"
628   [(set_attr "length" "4")
629    (set_attr "type" "fpcc")])
630
631 ;; scc insns.
632
633 (define_expand "seq"
634   [(set (match_operand:SI 0 "register_operand" "")
635         (eq:SI (match_dup 1)
636                (match_dup 2)))]
637   "!TARGET_64BIT"
638   "
639 {
640   /* fp scc patterns rarely match, and are not a win on the PA.  */
641   if (hppa_branch_type != CMP_SI)
642     FAIL;
643   /* set up operands from compare.  */
644   operands[1] = hppa_compare_op0;
645   operands[2] = hppa_compare_op1;
646   /* fall through and generate default code */
647 }")
648
649 (define_expand "sne"
650   [(set (match_operand:SI 0 "register_operand" "")
651         (ne:SI (match_dup 1)
652                (match_dup 2)))]
653   "!TARGET_64BIT"
654   "
655 {
656   /* fp scc patterns rarely match, and are not a win on the PA.  */
657   if (hppa_branch_type != CMP_SI)
658     FAIL;
659   operands[1] = hppa_compare_op0;
660   operands[2] = hppa_compare_op1;
661 }")
662
663 (define_expand "slt"
664   [(set (match_operand:SI 0 "register_operand" "")
665         (lt:SI (match_dup 1)
666                (match_dup 2)))]
667   "!TARGET_64BIT"
668   "
669 {
670   /* fp scc patterns rarely match, and are not a win on the PA.  */
671   if (hppa_branch_type != CMP_SI)
672     FAIL;
673   operands[1] = hppa_compare_op0;
674   operands[2] = hppa_compare_op1;
675 }")
676
677 (define_expand "sgt"
678   [(set (match_operand:SI 0 "register_operand" "")
679         (gt:SI (match_dup 1)
680                (match_dup 2)))]
681   "!TARGET_64BIT"
682   "
683 {
684   /* fp scc patterns rarely match, and are not a win on the PA.  */
685   if (hppa_branch_type != CMP_SI)
686     FAIL;
687   operands[1] = hppa_compare_op0;
688   operands[2] = hppa_compare_op1;
689 }")
690
691 (define_expand "sle"
692   [(set (match_operand:SI 0 "register_operand" "")
693         (le:SI (match_dup 1)
694                (match_dup 2)))]
695   "!TARGET_64BIT"
696   "
697 {
698   /* fp scc patterns rarely match, and are not a win on the PA.  */
699   if (hppa_branch_type != CMP_SI)
700     FAIL;
701   operands[1] = hppa_compare_op0;
702   operands[2] = hppa_compare_op1;
703 }")
704
705 (define_expand "sge"
706   [(set (match_operand:SI 0 "register_operand" "")
707         (ge:SI (match_dup 1)
708                (match_dup 2)))]
709   "!TARGET_64BIT"
710   "
711 {
712   /* fp scc patterns rarely match, and are not a win on the PA.  */
713   if (hppa_branch_type != CMP_SI)
714     FAIL;
715   operands[1] = hppa_compare_op0;
716   operands[2] = hppa_compare_op1;
717 }")
718
719 (define_expand "sltu"
720   [(set (match_operand:SI 0 "register_operand" "")
721         (ltu:SI (match_dup 1)
722                 (match_dup 2)))]
723   "!TARGET_64BIT"
724   "
725 {
726   if (hppa_branch_type != CMP_SI)
727     FAIL;
728   operands[1] = hppa_compare_op0;
729   operands[2] = hppa_compare_op1;
730 }")
731
732 (define_expand "sgtu"
733   [(set (match_operand:SI 0 "register_operand" "")
734         (gtu:SI (match_dup 1)
735                 (match_dup 2)))]
736   "!TARGET_64BIT"
737   "
738 {
739   if (hppa_branch_type != CMP_SI)
740     FAIL;
741   operands[1] = hppa_compare_op0;
742   operands[2] = hppa_compare_op1;
743 }")
744
745 (define_expand "sleu"
746   [(set (match_operand:SI 0 "register_operand" "")
747         (leu:SI (match_dup 1)
748                 (match_dup 2)))]
749   "!TARGET_64BIT"
750   "
751 {
752   if (hppa_branch_type != CMP_SI)
753     FAIL;
754   operands[1] = hppa_compare_op0;
755   operands[2] = hppa_compare_op1;
756 }")
757
758 (define_expand "sgeu"
759   [(set (match_operand:SI 0 "register_operand" "")
760         (geu:SI (match_dup 1)
761                 (match_dup 2)))]
762   "!TARGET_64BIT"
763   "
764 {
765   if (hppa_branch_type != CMP_SI)
766     FAIL;
767   operands[1] = hppa_compare_op0;
768   operands[2] = hppa_compare_op1;
769 }")
770
771 ;; Instruction canonicalization puts immediate operands second, which
772 ;; is the reverse of what we want.
773
774 (define_insn "scc"
775   [(set (match_operand:SI 0 "register_operand" "=r")
776         (match_operator:SI 3 "comparison_operator"
777                            [(match_operand:SI 1 "register_operand" "r")
778                             (match_operand:SI 2 "arith11_operand" "rI")]))]
779   ""
780   "{com%I2clr|cmp%I2clr},%B3 %2,%1,%0\;ldi 1,%0"
781   [(set_attr "type" "binary")
782    (set_attr "length" "8")])
783
784 (define_insn ""
785   [(set (match_operand:DI 0 "register_operand" "=r")
786         (match_operator:DI 3 "comparison_operator"
787                            [(match_operand:DI 1 "register_operand" "r")
788                             (match_operand:DI 2 "arith11_operand" "rI")]))]
789   "TARGET_64BIT"
790   "cmp%I2clr,*%B3 %2,%1,%0\;ldi 1,%0"
791   [(set_attr "type" "binary")
792    (set_attr "length" "8")])
793
794 (define_insn "iorscc"
795   [(set (match_operand:SI 0 "register_operand" "=r")
796         (ior:SI (match_operator:SI 3 "comparison_operator"
797                                    [(match_operand:SI 1 "register_operand" "r")
798                                     (match_operand:SI 2 "arith11_operand" "rI")])
799                 (match_operator:SI 6 "comparison_operator"
800                                    [(match_operand:SI 4 "register_operand" "r")
801                                     (match_operand:SI 5 "arith11_operand" "rI")])))]
802   ""
803   "{com%I2clr|cmp%I2clr},%S3 %2,%1,%%r0\;{com%I5clr|cmp%I5clr},%B6 %5,%4,%0\;ldi 1,%0"
804   [(set_attr "type" "binary")
805    (set_attr "length" "12")])
806
807 (define_insn ""
808   [(set (match_operand:DI 0 "register_operand" "=r")
809         (ior:DI (match_operator:DI 3 "comparison_operator"
810                                    [(match_operand:DI 1 "register_operand" "r")
811                                     (match_operand:DI 2 "arith11_operand" "rI")])
812                 (match_operator:DI 6 "comparison_operator"
813                                    [(match_operand:DI 4 "register_operand" "r")
814                                     (match_operand:DI 5 "arith11_operand" "rI")])))]
815   "TARGET_64BIT"
816   "cmp%I2clr,*%S3 %2,%1,%%r0\;cmp%I5clr,*%B6 %5,%4,%0\;ldi 1,%0"
817   [(set_attr "type" "binary")
818    (set_attr "length" "12")])
819
820 ;; Combiner patterns for common operations performed with the output
821 ;; from an scc insn (negscc and incscc).
822 (define_insn "negscc"
823   [(set (match_operand:SI 0 "register_operand" "=r")
824         (neg:SI (match_operator:SI 3 "comparison_operator"
825                [(match_operand:SI 1 "register_operand" "r")
826                 (match_operand:SI 2 "arith11_operand" "rI")])))]
827   ""
828   "{com%I2clr|cmp%I2clr},%B3 %2,%1,%0\;ldi -1,%0"
829   [(set_attr "type" "binary")
830    (set_attr "length" "8")])
831
832 (define_insn ""
833   [(set (match_operand:DI 0 "register_operand" "=r")
834         (neg:DI (match_operator:DI 3 "comparison_operator"
835                [(match_operand:DI 1 "register_operand" "r")
836                 (match_operand:DI 2 "arith11_operand" "rI")])))]
837   "TARGET_64BIT"
838   "cmp%I2clr,*%B3 %2,%1,%0\;ldi -1,%0"
839   [(set_attr "type" "binary")
840    (set_attr "length" "8")])
841
842 ;; Patterns for adding/subtracting the result of a boolean expression from
843 ;; a register.  First we have special patterns that make use of the carry
844 ;; bit, and output only two instructions.  For the cases we can't in
845 ;; general do in two instructions, the incscc pattern at the end outputs
846 ;; two or three instructions.
847
848 (define_insn ""
849   [(set (match_operand:SI 0 "register_operand" "=r")
850         (plus:SI (leu:SI (match_operand:SI 2 "register_operand" "r")
851                          (match_operand:SI 3 "arith11_operand" "rI"))
852                  (match_operand:SI 1 "register_operand" "r")))]
853   ""
854   "sub%I3 %3,%2,%%r0\;{addc|add,c} %%r0,%1,%0"
855   [(set_attr "type" "binary")
856    (set_attr "length" "8")])
857
858 (define_insn ""
859   [(set (match_operand:DI 0 "register_operand" "=r")
860         (plus:DI (leu:DI (match_operand:DI 2 "register_operand" "r")
861                          (match_operand:DI 3 "arith11_operand" "rI"))
862                  (match_operand:DI 1 "register_operand" "r")))]
863   "TARGET_64BIT"
864   "sub%I3 %3,%2,%%r0\;add,dc %%r0,%1,%0"
865   [(set_attr "type" "binary")
866    (set_attr "length" "8")])
867
868 ; This need only accept registers for op3, since canonicalization
869 ; replaces geu with gtu when op3 is an integer.
870 (define_insn ""
871   [(set (match_operand:SI 0 "register_operand" "=r")
872         (plus:SI (geu:SI (match_operand:SI 2 "register_operand" "r")
873                          (match_operand:SI 3 "register_operand" "r"))
874                  (match_operand:SI 1 "register_operand" "r")))]
875   ""
876   "sub %2,%3,%%r0\;{addc|add,c} %%r0,%1,%0"
877   [(set_attr "type" "binary")
878    (set_attr "length" "8")])
879
880 (define_insn ""
881   [(set (match_operand:DI 0 "register_operand" "=r")
882         (plus:DI (geu:DI (match_operand:DI 2 "register_operand" "r")
883                          (match_operand:DI 3 "register_operand" "r"))
884                  (match_operand:DI 1 "register_operand" "r")))]
885   "TARGET_64BIT"
886   "sub %2,%3,%%r0\;add,dc %%r0,%1,%0"
887   [(set_attr "type" "binary")
888    (set_attr "length" "8")])
889
890 ; Match only integers for op3 here.  This is used as canonical form of the
891 ; geu pattern when op3 is an integer.  Don't match registers since we can't
892 ; make better code than the general incscc pattern.
893 (define_insn ""
894   [(set (match_operand:SI 0 "register_operand" "=r")
895         (plus:SI (gtu:SI (match_operand:SI 2 "register_operand" "r")
896                          (match_operand:SI 3 "int11_operand" "I"))
897                  (match_operand:SI 1 "register_operand" "r")))]
898   ""
899   "addi %k3,%2,%%r0\;{addc|add,c} %%r0,%1,%0"
900   [(set_attr "type" "binary")
901    (set_attr "length" "8")])
902
903 (define_insn ""
904   [(set (match_operand:DI 0 "register_operand" "=r")
905         (plus:DI (gtu:DI (match_operand:DI 2 "register_operand" "r")
906                          (match_operand:DI 3 "int11_operand" "I"))
907                  (match_operand:DI 1 "register_operand" "r")))]
908   "TARGET_64BIT"
909   "addi %k3,%2,%%r0\;add,dc %%r0,%1,%0"
910   [(set_attr "type" "binary")
911    (set_attr "length" "8")])
912
913 (define_insn "incscc"
914   [(set (match_operand:SI 0 "register_operand" "=r,r")
915         (plus:SI (match_operator:SI 4 "comparison_operator"
916                     [(match_operand:SI 2 "register_operand" "r,r")
917                      (match_operand:SI 3 "arith11_operand" "rI,rI")])
918                  (match_operand:SI 1 "register_operand" "0,?r")))]
919   ""
920   "@
921    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi 1,%0,%0
922    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi,tr 1,%1,%0\;copy %1,%0"
923   [(set_attr "type" "binary,binary")
924    (set_attr "length" "8,12")])
925
926 (define_insn ""
927   [(set (match_operand:DI 0 "register_operand" "=r,r")
928         (plus:DI (match_operator:DI 4 "comparison_operator"
929                     [(match_operand:DI 2 "register_operand" "r,r")
930                      (match_operand:DI 3 "arith11_operand" "rI,rI")])
931                  (match_operand:DI 1 "register_operand" "0,?r")))]
932   "TARGET_64BIT"
933   "@
934    cmp%I3clr,*%B4 %3,%2,%%r0\;addi 1,%0,%0
935    cmp%I3clr,*%B4 %3,%2,%%r0\;addi,tr 1,%1,%0\;copy %1,%0"
936   [(set_attr "type" "binary,binary")
937    (set_attr "length" "8,12")])
938
939 (define_insn ""
940   [(set (match_operand:SI 0 "register_operand" "=r")
941         (minus:SI (match_operand:SI 1 "register_operand" "r")
942                   (gtu:SI (match_operand:SI 2 "register_operand" "r")
943                           (match_operand:SI 3 "arith11_operand" "rI"))))]
944   ""
945   "sub%I3 %3,%2,%%r0\;{subb|sub,b} %1,%%r0,%0"
946   [(set_attr "type" "binary")
947    (set_attr "length" "8")])
948
949 (define_insn ""
950   [(set (match_operand:DI 0 "register_operand" "=r")
951         (minus:DI (match_operand:DI 1 "register_operand" "r")
952                   (gtu:DI (match_operand:DI 2 "register_operand" "r")
953                           (match_operand:DI 3 "arith11_operand" "rI"))))]
954   "TARGET_64BIT"
955   "sub%I3 %3,%2,%%r0\;sub,db %1,%%r0,%0"
956   [(set_attr "type" "binary")
957    (set_attr "length" "8")])
958
959 (define_insn ""
960   [(set (match_operand:SI 0 "register_operand" "=r")
961         (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
962                             (gtu:SI (match_operand:SI 2 "register_operand" "r")
963                                     (match_operand:SI 3 "arith11_operand" "rI")))
964                   (match_operand:SI 4 "register_operand" "r")))]
965   ""
966   "sub%I3 %3,%2,%%r0\;{subb|sub,b} %1,%4,%0"
967   [(set_attr "type" "binary")
968    (set_attr "length" "8")])
969
970 (define_insn ""
971   [(set (match_operand:DI 0 "register_operand" "=r")
972         (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
973                             (gtu:DI (match_operand:DI 2 "register_operand" "r")
974                                     (match_operand:DI 3 "arith11_operand" "rI")))
975                   (match_operand:DI 4 "register_operand" "r")))]
976   "TARGET_64BIT"
977   "sub%I3 %3,%2,%%r0\;sub,db %1,%4,%0"
978   [(set_attr "type" "binary")
979    (set_attr "length" "8")])
980
981 ; This need only accept registers for op3, since canonicalization
982 ; replaces ltu with leu when op3 is an integer.
983 (define_insn ""
984   [(set (match_operand:SI 0 "register_operand" "=r")
985         (minus:SI (match_operand:SI 1 "register_operand" "r")
986                   (ltu:SI (match_operand:SI 2 "register_operand" "r")
987                           (match_operand:SI 3 "register_operand" "r"))))]
988   ""
989   "sub %2,%3,%%r0\;{subb|sub,b} %1,%%r0,%0"
990   [(set_attr "type" "binary")
991    (set_attr "length" "8")])
992
993 (define_insn ""
994   [(set (match_operand:DI 0 "register_operand" "=r")
995         (minus:DI (match_operand:DI 1 "register_operand" "r")
996                   (ltu:DI (match_operand:DI 2 "register_operand" "r")
997                           (match_operand:DI 3 "register_operand" "r"))))]
998   "TARGET_64BIT"
999   "sub %2,%3,%%r0\;sub,db %1,%%r0,%0"
1000   [(set_attr "type" "binary")
1001    (set_attr "length" "8")])
1002
1003 (define_insn ""
1004   [(set (match_operand:SI 0 "register_operand" "=r")
1005         (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
1006                             (ltu:SI (match_operand:SI 2 "register_operand" "r")
1007                                     (match_operand:SI 3 "register_operand" "r")))
1008                   (match_operand:SI 4 "register_operand" "r")))]
1009   ""
1010   "sub %2,%3,%%r0\;{subb|sub,b} %1,%4,%0"
1011   [(set_attr "type" "binary")
1012    (set_attr "length" "8")])
1013
1014 (define_insn ""
1015   [(set (match_operand:DI 0 "register_operand" "=r")
1016         (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
1017                             (ltu:DI (match_operand:DI 2 "register_operand" "r")
1018                                     (match_operand:DI 3 "register_operand" "r")))
1019                   (match_operand:DI 4 "register_operand" "r")))]
1020   "TARGET_64BIT"
1021   "sub %2,%3,%%r0\;sub,db %1,%4,%0"
1022   [(set_attr "type" "binary")
1023    (set_attr "length" "8")])
1024
1025 ; Match only integers for op3 here.  This is used as canonical form of the
1026 ; ltu pattern when op3 is an integer.  Don't match registers since we can't
1027 ; make better code than the general incscc pattern.
1028 (define_insn ""
1029   [(set (match_operand:SI 0 "register_operand" "=r")
1030         (minus:SI (match_operand:SI 1 "register_operand" "r")
1031                   (leu:SI (match_operand:SI 2 "register_operand" "r")
1032                           (match_operand:SI 3 "int11_operand" "I"))))]
1033   ""
1034   "addi %k3,%2,%%r0\;{subb|sub,b} %1,%%r0,%0"
1035   [(set_attr "type" "binary")
1036    (set_attr "length" "8")])
1037
1038 (define_insn ""
1039   [(set (match_operand:DI 0 "register_operand" "=r")
1040         (minus:DI (match_operand:DI 1 "register_operand" "r")
1041                   (leu:DI (match_operand:DI 2 "register_operand" "r")
1042                           (match_operand:DI 3 "int11_operand" "I"))))]
1043   "TARGET_64BIT"
1044   "addi %k3,%2,%%r0\;sub,db %1,%%r0,%0"
1045   [(set_attr "type" "binary")
1046    (set_attr "length" "8")])
1047
1048 (define_insn ""
1049   [(set (match_operand:SI 0 "register_operand" "=r")
1050         (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
1051                             (leu:SI (match_operand:SI 2 "register_operand" "r")
1052                                     (match_operand:SI 3 "int11_operand" "I")))
1053                   (match_operand:SI 4 "register_operand" "r")))]
1054   ""
1055   "addi %k3,%2,%%r0\;{subb|sub,b} %1,%4,%0"
1056   [(set_attr "type" "binary")
1057    (set_attr "length" "8")])
1058
1059 (define_insn ""
1060   [(set (match_operand:DI 0 "register_operand" "=r")
1061         (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
1062                             (leu:DI (match_operand:DI 2 "register_operand" "r")
1063                                     (match_operand:DI 3 "int11_operand" "I")))
1064                   (match_operand:DI 4 "register_operand" "r")))]
1065   "TARGET_64BIT"
1066   "addi %k3,%2,%%r0\;sub,db %1,%4,%0"
1067   [(set_attr "type" "binary")
1068    (set_attr "length" "8")])
1069
1070 (define_insn "decscc"
1071   [(set (match_operand:SI 0 "register_operand" "=r,r")
1072         (minus:SI (match_operand:SI 1 "register_operand" "0,?r")
1073                   (match_operator:SI 4 "comparison_operator"
1074                      [(match_operand:SI 2 "register_operand" "r,r")
1075                       (match_operand:SI 3 "arith11_operand" "rI,rI")])))]
1076   ""
1077   "@
1078    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi -1,%0,%0
1079    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi,tr -1,%1,%0\;copy %1,%0"
1080   [(set_attr "type" "binary,binary")
1081    (set_attr "length" "8,12")])
1082
1083 (define_insn ""
1084   [(set (match_operand:DI 0 "register_operand" "=r,r")
1085         (minus:DI (match_operand:DI 1 "register_operand" "0,?r")
1086                   (match_operator:DI 4 "comparison_operator"
1087                      [(match_operand:DI 2 "register_operand" "r,r")
1088                       (match_operand:DI 3 "arith11_operand" "rI,rI")])))]
1089   "TARGET_64BIT"
1090   "@
1091    cmp%I3clr,*%B4 %3,%2,%%r0\;addi -1,%0,%0
1092    cmp%I3clr,*%B4 %3,%2,%%r0\;addi,tr -1,%1,%0\;copy %1,%0"
1093   [(set_attr "type" "binary,binary")
1094    (set_attr "length" "8,12")])
1095
1096 ; Patterns for max and min.  (There is no need for an earlyclobber in the
1097 ; last alternative since the middle alternative will match if op0 == op1.)
1098
1099 (define_insn "sminsi3"
1100   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1101         (smin:SI (match_operand:SI 1 "register_operand" "%0,0,r")
1102                  (match_operand:SI 2 "arith11_operand" "r,I,M")))]
1103   ""
1104   "@
1105   {comclr|cmpclr},> %2,%0,%%r0\;copy %2,%0
1106   {comiclr|cmpiclr},> %2,%0,%%r0\;ldi %2,%0
1107   {comclr|cmpclr},> %1,%r2,%0\;copy %1,%0"
1108 [(set_attr "type" "multi,multi,multi")
1109  (set_attr "length" "8,8,8")])
1110
1111 (define_insn "smindi3"
1112   [(set (match_operand:DI 0 "register_operand" "=r,r,r")
1113         (smin:DI (match_operand:DI 1 "register_operand" "%0,0,r")
1114                  (match_operand:DI 2 "arith11_operand" "r,I,M")))]
1115   "TARGET_64BIT"
1116   "@
1117   cmpclr,*> %2,%0,%%r0\;copy %2,%0
1118   cmpiclr,*> %2,%0,%%r0\;ldi %2,%0
1119   cmpclr,*> %1,%r2,%0\;copy %1,%0"
1120 [(set_attr "type" "multi,multi,multi")
1121  (set_attr "length" "8,8,8")])
1122
1123 (define_insn "uminsi3"
1124   [(set (match_operand:SI 0 "register_operand" "=r,r")
1125         (umin:SI (match_operand:SI 1 "register_operand" "%0,0")
1126                  (match_operand:SI 2 "arith11_operand" "r,I")))]
1127   ""
1128   "@
1129   {comclr|cmpclr},>> %2,%0,%%r0\;copy %2,%0
1130   {comiclr|cmpiclr},>> %2,%0,%%r0\;ldi %2,%0"
1131 [(set_attr "type" "multi,multi")
1132  (set_attr "length" "8,8")])
1133
1134 (define_insn "umindi3"
1135   [(set (match_operand:DI 0 "register_operand" "=r,r")
1136         (umin:DI (match_operand:DI 1 "register_operand" "%0,0")
1137                  (match_operand:DI 2 "arith11_operand" "r,I")))]
1138   "TARGET_64BIT"
1139   "@
1140   cmpclr,*>> %2,%0,%%r0\;copy %2,%0
1141   cmpiclr,*>> %2,%0,%%r0\;ldi %2,%0"
1142 [(set_attr "type" "multi,multi")
1143  (set_attr "length" "8,8")])
1144
1145 (define_insn "smaxsi3"
1146   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1147         (smax:SI (match_operand:SI 1 "register_operand" "%0,0,r")
1148                  (match_operand:SI 2 "arith11_operand" "r,I,M")))]
1149   ""
1150   "@
1151   {comclr|cmpclr},< %2,%0,%%r0\;copy %2,%0
1152   {comiclr|cmpiclr},< %2,%0,%%r0\;ldi %2,%0
1153   {comclr|cmpclr},< %1,%r2,%0\;copy %1,%0"
1154 [(set_attr "type" "multi,multi,multi")
1155  (set_attr "length" "8,8,8")])
1156
1157 (define_insn "smaxdi3"
1158   [(set (match_operand:DI 0 "register_operand" "=r,r,r")
1159         (smax:DI (match_operand:DI 1 "register_operand" "%0,0,r")
1160                  (match_operand:DI 2 "arith11_operand" "r,I,M")))]
1161   "TARGET_64BIT"
1162   "@
1163   cmpclr,*< %2,%0,%%r0\;copy %2,%0
1164   cmpiclr,*< %2,%0,%%r0\;ldi %2,%0
1165   cmpclr,*< %1,%r2,%0\;copy %1,%0"
1166 [(set_attr "type" "multi,multi,multi")
1167  (set_attr "length" "8,8,8")])
1168
1169 (define_insn "umaxsi3"
1170   [(set (match_operand:SI 0 "register_operand" "=r,r")
1171         (umax:SI (match_operand:SI 1 "register_operand" "%0,0")
1172                  (match_operand:SI 2 "arith11_operand" "r,I")))]
1173   ""
1174   "@
1175   {comclr|cmpclr},<< %2,%0,%%r0\;copy %2,%0
1176   {comiclr|cmpiclr},<< %2,%0,%%r0\;ldi %2,%0"
1177 [(set_attr "type" "multi,multi")
1178  (set_attr "length" "8,8")])
1179
1180 (define_insn "umaxdi3"
1181   [(set (match_operand:DI 0 "register_operand" "=r,r")
1182         (umax:DI (match_operand:DI 1 "register_operand" "%0,0")
1183                  (match_operand:DI 2 "arith11_operand" "r,I")))]
1184   "TARGET_64BIT"
1185   "@
1186   cmpclr,*<< %2,%0,%%r0\;copy %2,%0
1187   cmpiclr,*<< %2,%0,%%r0\;ldi %2,%0"
1188 [(set_attr "type" "multi,multi")
1189  (set_attr "length" "8,8")])
1190
1191 (define_insn "abssi2"
1192   [(set (match_operand:SI 0 "register_operand" "=r")
1193         (abs:SI (match_operand:SI 1 "register_operand" "r")))]
1194   ""
1195   "or,>= %%r0,%1,%0\;subi 0,%0,%0"
1196   [(set_attr "type" "multi")
1197    (set_attr "length" "8")])
1198
1199 (define_insn "absdi2"
1200   [(set (match_operand:DI 0 "register_operand" "=r")
1201         (abs:DI (match_operand:DI 1 "register_operand" "r")))]
1202   "TARGET_64BIT"
1203   "or,*>= %%r0,%1,%0\;subi 0,%0,%0"
1204   [(set_attr "type" "multi")
1205    (set_attr "length" "8")])
1206
1207 ;;; Experimental conditional move patterns
1208
1209 (define_expand "movsicc"
1210   [(set (match_operand:SI 0 "register_operand" "")
1211         (if_then_else:SI
1212          (match_operator 1 "comparison_operator"
1213             [(match_dup 4)
1214              (match_dup 5)])
1215          (match_operand:SI 2 "reg_or_cint_move_operand" "")
1216          (match_operand:SI 3 "reg_or_cint_move_operand" "")))]
1217   ""
1218   "
1219 {
1220   enum rtx_code code = GET_CODE (operands[1]);
1221
1222   if (hppa_branch_type != CMP_SI)
1223     FAIL;
1224
1225   if (GET_MODE (hppa_compare_op0) != GET_MODE (hppa_compare_op1)
1226       || GET_MODE (hppa_compare_op0) != GET_MODE (operands[0]))
1227     FAIL;
1228
1229   /* operands[1] is currently the result of compare_from_rtx.  We want to
1230      emit a compare of the original operands.  */
1231   operands[1] = gen_rtx_fmt_ee (code, SImode, hppa_compare_op0, hppa_compare_op1);
1232   operands[4] = hppa_compare_op0;
1233   operands[5] = hppa_compare_op1;
1234 }")
1235
1236 ;; We used to accept any register for op1.
1237 ;;
1238 ;; However, it loses sometimes because the compiler will end up using
1239 ;; different registers for op0 and op1 in some critical cases.  local-alloc
1240 ;; will  not tie op0 and op1 because op0 is used in multiple basic blocks.
1241 ;;
1242 ;; If/when global register allocation supports tying we should allow any
1243 ;; register for op1 again.
1244 (define_insn ""
1245   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
1246         (if_then_else:SI
1247          (match_operator 2 "comparison_operator"
1248             [(match_operand:SI 3 "register_operand" "r,r,r,r")
1249              (match_operand:SI 4 "arith11_operand" "rI,rI,rI,rI")])
1250          (match_operand:SI 1 "reg_or_cint_move_operand" "0,J,N,K")
1251          (const_int 0)))]
1252   ""
1253   "@
1254    {com%I4clr|cmp%I4clr},%S2 %4,%3,%%r0\;ldi 0,%0
1255    {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;ldi %1,%0
1256    {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;ldil L'%1,%0
1257    {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;{zdepi|depwi,z} %Z1,%0"
1258   [(set_attr "type" "multi,multi,multi,nullshift")
1259    (set_attr "length" "8,8,8,8")])
1260
1261 (define_insn ""
1262   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r,r,r")
1263         (if_then_else:SI
1264          (match_operator 5 "comparison_operator"
1265             [(match_operand:SI 3 "register_operand" "r,r,r,r,r,r,r,r")
1266              (match_operand:SI 4 "arith11_operand" "rI,rI,rI,rI,rI,rI,rI,rI")])
1267          (match_operand:SI 1 "reg_or_cint_move_operand" "0,0,0,0,r,J,N,K")
1268          (match_operand:SI 2 "reg_or_cint_move_operand" "r,J,N,K,0,0,0,0")))]
1269   ""
1270   "@
1271    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;copy %2,%0
1272    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;ldi %2,%0
1273    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;ldil L'%2,%0
1274    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;{zdepi|depwi,z} %Z2,%0
1275    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;copy %1,%0
1276    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;ldi %1,%0
1277    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;ldil L'%1,%0
1278    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;{zdepi|depwi,z} %Z1,%0"
1279   [(set_attr "type" "multi,multi,multi,nullshift,multi,multi,multi,nullshift")
1280    (set_attr "length" "8,8,8,8,8,8,8,8")])
1281
1282 (define_expand "movdicc"
1283   [(set (match_operand:DI 0 "register_operand" "")
1284         (if_then_else:DI
1285          (match_operator 1 "comparison_operator"
1286             [(match_dup 4)
1287              (match_dup 5)])
1288          (match_operand:DI 2 "reg_or_cint_move_operand" "")
1289          (match_operand:DI 3 "reg_or_cint_move_operand" "")))]
1290   "TARGET_64BIT"
1291   "
1292 {
1293   enum rtx_code code = GET_CODE (operands[1]);
1294
1295   if (hppa_branch_type != CMP_SI)
1296     FAIL;
1297
1298   if (GET_MODE (hppa_compare_op0) != GET_MODE (hppa_compare_op1)
1299       || GET_MODE (hppa_compare_op0) != GET_MODE (operands[0]))
1300     FAIL;
1301
1302   /* operands[1] is currently the result of compare_from_rtx.  We want to
1303      emit a compare of the original operands.  */
1304   operands[1] = gen_rtx_fmt_ee (code, DImode, hppa_compare_op0, hppa_compare_op1);
1305   operands[4] = hppa_compare_op0;
1306   operands[5] = hppa_compare_op1;
1307 }")
1308
1309 ; We need the first constraint alternative in order to avoid
1310 ; earlyclobbers on all other alternatives.
1311 (define_insn ""
1312   [(set (match_operand:DI 0 "register_operand" "=r,r,r,r,r")
1313         (if_then_else:DI
1314          (match_operator 2 "comparison_operator"
1315             [(match_operand:DI 3 "register_operand" "r,r,r,r,r")
1316              (match_operand:DI 4 "arith11_operand" "rI,rI,rI,rI,rI")])
1317          (match_operand:DI 1 "reg_or_cint_move_operand" "0,r,J,N,K")
1318          (const_int 0)))]
1319   "TARGET_64BIT"
1320   "@
1321    cmp%I4clr,*%S2 %4,%3,%%r0\;ldi 0,%0
1322    cmp%I4clr,*%B2 %4,%3,%0\;copy %1,%0
1323    cmp%I4clr,*%B2 %4,%3,%0\;ldi %1,%0
1324    cmp%I4clr,*%B2 %4,%3,%0\;ldil L'%1,%0
1325    cmp%I4clr,*%B2 %4,%3,%0\;depdi,z %z1,%0"
1326   [(set_attr "type" "multi,multi,multi,multi,nullshift")
1327    (set_attr "length" "8,8,8,8,8")])
1328
1329 (define_insn ""
1330   [(set (match_operand:DI 0 "register_operand" "=r,r,r,r,r,r,r,r")
1331         (if_then_else:DI
1332          (match_operator 5 "comparison_operator"
1333             [(match_operand:DI 3 "register_operand" "r,r,r,r,r,r,r,r")
1334              (match_operand:DI 4 "arith11_operand" "rI,rI,rI,rI,rI,rI,rI,rI")])
1335          (match_operand:DI 1 "reg_or_cint_move_operand" "0,0,0,0,r,J,N,K")
1336          (match_operand:DI 2 "reg_or_cint_move_operand" "r,J,N,K,0,0,0,0")))]
1337   "TARGET_64BIT"
1338   "@
1339    cmp%I4clr,*%S5 %4,%3,%%r0\;copy %2,%0
1340    cmp%I4clr,*%S5 %4,%3,%%r0\;ldi %2,%0
1341    cmp%I4clr,*%S5 %4,%3,%%r0\;ldil L'%2,%0
1342    cmp%I4clr,*%S5 %4,%3,%%r0\;depdi,z %z2,%0
1343    cmp%I4clr,*%B5 %4,%3,%%r0\;copy %1,%0
1344    cmp%I4clr,*%B5 %4,%3,%%r0\;ldi %1,%0
1345    cmp%I4clr,*%B5 %4,%3,%%r0\;ldil L'%1,%0
1346    cmp%I4clr,*%B5 %4,%3,%%r0\;depdi,z %z1,%0"
1347   [(set_attr "type" "multi,multi,multi,nullshift,multi,multi,multi,nullshift")
1348    (set_attr "length" "8,8,8,8,8,8,8,8")])
1349
1350 ;; Conditional Branches
1351
1352 (define_expand "beq"
1353   [(set (pc)
1354         (if_then_else (eq (match_dup 1) (match_dup 2))
1355                       (label_ref (match_operand 0 "" ""))
1356                       (pc)))]
1357   ""
1358   "
1359 {
1360   if (hppa_branch_type != CMP_SI)
1361     {
1362       emit_insn (gen_cmp_fp (EQ, hppa_compare_op0, hppa_compare_op1));
1363       emit_bcond_fp (NE, operands[0]);
1364       DONE;
1365     }
1366   /* set up operands from compare.  */
1367   operands[1] = hppa_compare_op0;
1368   operands[2] = hppa_compare_op1;
1369   /* fall through and generate default code */
1370 }")
1371
1372 (define_expand "bne"
1373   [(set (pc)
1374         (if_then_else (ne (match_dup 1) (match_dup 2))
1375                       (label_ref (match_operand 0 "" ""))
1376                       (pc)))]
1377   ""
1378   "
1379 {
1380   if (hppa_branch_type != CMP_SI)
1381     {
1382       emit_insn (gen_cmp_fp (NE, hppa_compare_op0, hppa_compare_op1));
1383       emit_bcond_fp (NE, operands[0]);
1384       DONE;
1385     }
1386   operands[1] = hppa_compare_op0;
1387   operands[2] = hppa_compare_op1;
1388 }")
1389
1390 (define_expand "bgt"
1391   [(set (pc)
1392         (if_then_else (gt (match_dup 1) (match_dup 2))
1393                       (label_ref (match_operand 0 "" ""))
1394                       (pc)))]
1395   ""
1396   "
1397 {
1398   if (hppa_branch_type != CMP_SI)
1399     {
1400       emit_insn (gen_cmp_fp (GT, hppa_compare_op0, hppa_compare_op1));
1401       emit_bcond_fp (NE, operands[0]);
1402       DONE;
1403     }
1404   operands[1] = hppa_compare_op0;
1405   operands[2] = hppa_compare_op1;
1406 }")
1407
1408 (define_expand "blt"
1409   [(set (pc)
1410         (if_then_else (lt (match_dup 1) (match_dup 2))
1411                       (label_ref (match_operand 0 "" ""))
1412                       (pc)))]
1413   ""
1414   "
1415 {
1416   if (hppa_branch_type != CMP_SI)
1417     {
1418       emit_insn (gen_cmp_fp (LT, hppa_compare_op0, hppa_compare_op1));
1419       emit_bcond_fp (NE, operands[0]);
1420       DONE;
1421     }
1422   operands[1] = hppa_compare_op0;
1423   operands[2] = hppa_compare_op1;
1424 }")
1425
1426 (define_expand "bge"
1427   [(set (pc)
1428         (if_then_else (ge (match_dup 1) (match_dup 2))
1429                       (label_ref (match_operand 0 "" ""))
1430                       (pc)))]
1431   ""
1432   "
1433 {
1434   if (hppa_branch_type != CMP_SI)
1435     {
1436       emit_insn (gen_cmp_fp (GE, hppa_compare_op0, hppa_compare_op1));
1437       emit_bcond_fp (NE, operands[0]);
1438       DONE;
1439     }
1440   operands[1] = hppa_compare_op0;
1441   operands[2] = hppa_compare_op1;
1442 }")
1443
1444 (define_expand "ble"
1445   [(set (pc)
1446         (if_then_else (le (match_dup 1) (match_dup 2))
1447                       (label_ref (match_operand 0 "" ""))
1448                       (pc)))]
1449   ""
1450   "
1451 {
1452   if (hppa_branch_type != CMP_SI)
1453     {
1454       emit_insn (gen_cmp_fp (LE, hppa_compare_op0, hppa_compare_op1));
1455       emit_bcond_fp (NE, operands[0]);
1456       DONE;
1457     }
1458   operands[1] = hppa_compare_op0;
1459   operands[2] = hppa_compare_op1;
1460 }")
1461
1462 (define_expand "bgtu"
1463   [(set (pc)
1464         (if_then_else (gtu (match_dup 1) (match_dup 2))
1465                       (label_ref (match_operand 0 "" ""))
1466                       (pc)))]
1467   ""
1468   "
1469 {
1470   if (hppa_branch_type != CMP_SI)
1471     FAIL;
1472   operands[1] = hppa_compare_op0;
1473   operands[2] = hppa_compare_op1;
1474 }")
1475
1476 (define_expand "bltu"
1477   [(set (pc)
1478         (if_then_else (ltu (match_dup 1) (match_dup 2))
1479                       (label_ref (match_operand 0 "" ""))
1480                       (pc)))]
1481   ""
1482   "
1483 {
1484   if (hppa_branch_type != CMP_SI)
1485     FAIL;
1486   operands[1] = hppa_compare_op0;
1487   operands[2] = hppa_compare_op1;
1488 }")
1489
1490 (define_expand "bgeu"
1491   [(set (pc)
1492         (if_then_else (geu (match_dup 1) (match_dup 2))
1493                       (label_ref (match_operand 0 "" ""))
1494                       (pc)))]
1495   ""
1496   "
1497 {
1498   if (hppa_branch_type != CMP_SI)
1499     FAIL;
1500   operands[1] = hppa_compare_op0;
1501   operands[2] = hppa_compare_op1;
1502 }")
1503
1504 (define_expand "bleu"
1505   [(set (pc)
1506         (if_then_else (leu (match_dup 1) (match_dup 2))
1507                       (label_ref (match_operand 0 "" ""))
1508                       (pc)))]
1509   ""
1510   "
1511 {
1512   if (hppa_branch_type != CMP_SI)
1513     FAIL;
1514   operands[1] = hppa_compare_op0;
1515   operands[2] = hppa_compare_op1;
1516 }")
1517
1518 (define_expand "bltgt"
1519   [(set (pc)
1520         (if_then_else (ltgt (match_dup 1) (match_dup 2))
1521                       (label_ref (match_operand 0 "" ""))
1522                       (pc)))]
1523   ""
1524   "
1525 {
1526   if (hppa_branch_type == CMP_SI)
1527     FAIL;
1528   emit_insn (gen_cmp_fp (LTGT, hppa_compare_op0, hppa_compare_op1));
1529   emit_bcond_fp (NE, operands[0]);
1530   DONE;
1531 }")
1532
1533 (define_expand "bunle"
1534   [(set (pc)
1535         (if_then_else (unle (match_dup 1) (match_dup 2))
1536                       (label_ref (match_operand 0 "" ""))
1537                       (pc)))]
1538   ""
1539   "
1540 {
1541   if (hppa_branch_type == CMP_SI)
1542     FAIL;
1543   emit_insn (gen_cmp_fp (UNLE, hppa_compare_op0, hppa_compare_op1));
1544   emit_bcond_fp (NE, operands[0]);
1545   DONE;
1546 }")
1547
1548 (define_expand "bunlt"
1549   [(set (pc)
1550         (if_then_else (unlt (match_dup 1) (match_dup 2))
1551                       (label_ref (match_operand 0 "" ""))
1552                       (pc)))]
1553   ""
1554   "
1555 {
1556   if (hppa_branch_type == CMP_SI)
1557     FAIL;
1558   emit_insn (gen_cmp_fp (UNLT, hppa_compare_op0, hppa_compare_op1));
1559   emit_bcond_fp (NE, operands[0]);
1560   DONE;
1561 }")
1562
1563 (define_expand "bunge"
1564   [(set (pc)
1565         (if_then_else (unge (match_dup 1) (match_dup 2))
1566                       (label_ref (match_operand 0 "" ""))
1567                       (pc)))]
1568   ""
1569   "
1570 {
1571   if (hppa_branch_type == CMP_SI)
1572     FAIL;
1573   emit_insn (gen_cmp_fp (UNGE, hppa_compare_op0, hppa_compare_op1));
1574   emit_bcond_fp (NE, operands[0]);
1575   DONE;
1576 }")
1577
1578 (define_expand "bungt"
1579   [(set (pc)
1580         (if_then_else (ungt (match_dup 1) (match_dup 2))
1581                       (label_ref (match_operand 0 "" ""))
1582                       (pc)))]
1583   ""
1584   "
1585 {
1586   if (hppa_branch_type == CMP_SI)
1587     FAIL;
1588   emit_insn (gen_cmp_fp (UNGT, hppa_compare_op0, hppa_compare_op1));
1589   emit_bcond_fp (NE, operands[0]);
1590   DONE;
1591 }")
1592
1593 (define_expand "buneq"
1594   [(set (pc)
1595         (if_then_else (uneq (match_dup 1) (match_dup 2))
1596                       (label_ref (match_operand 0 "" ""))
1597                       (pc)))]
1598   ""
1599   "
1600 {
1601   if (hppa_branch_type == CMP_SI)
1602     FAIL;
1603   emit_insn (gen_cmp_fp (UNEQ, hppa_compare_op0, hppa_compare_op1));
1604   emit_bcond_fp (NE, operands[0]);
1605   DONE;
1606 }")
1607
1608 (define_expand "bunordered"
1609   [(set (pc)
1610         (if_then_else (unordered (match_dup 1) (match_dup 2))
1611                       (label_ref (match_operand 0 "" ""))
1612                       (pc)))]
1613   ""
1614   "
1615 {
1616   if (hppa_branch_type == CMP_SI)
1617     FAIL;
1618   emit_insn (gen_cmp_fp (UNORDERED, hppa_compare_op0, hppa_compare_op1));
1619   emit_bcond_fp (NE, operands[0]);
1620   DONE;
1621 }")
1622
1623 (define_expand "bordered"
1624   [(set (pc)
1625         (if_then_else (ordered (match_dup 1) (match_dup 2))
1626                       (label_ref (match_operand 0 "" ""))
1627                       (pc)))]
1628   ""
1629   "
1630 {
1631   if (hppa_branch_type == CMP_SI)
1632     FAIL;
1633   emit_insn (gen_cmp_fp (ORDERED, hppa_compare_op0, hppa_compare_op1));
1634   emit_bcond_fp (NE, operands[0]);
1635   DONE;
1636 }")
1637
1638 ;; Match the branch patterns.
1639
1640
1641 ;; Note a long backward conditional branch with an annulled delay slot
1642 ;; has a length of 12.
1643 (define_insn ""
1644   [(set (pc)
1645         (if_then_else
1646          (match_operator 3 "comparison_operator"
1647                          [(match_operand:SI 1 "reg_or_0_operand" "rM")
1648                           (match_operand:SI 2 "arith5_operand" "rL")])
1649          (label_ref (match_operand 0 "" ""))
1650          (pc)))]
1651   ""
1652   "*
1653 {
1654   return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1655                          get_attr_length (insn), 0, insn);
1656 }"
1657 [(set_attr "type" "cbranch")
1658  (set (attr "length")
1659     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1660                (const_int 8184))
1661            (const_int 4)
1662            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1663                (const_int 262100))
1664            (const_int 8)
1665            (eq (symbol_ref "flag_pic") (const_int 0))
1666            (const_int 20)]
1667           (const_int 28)))])
1668
1669 ;; Match the negated branch.
1670
1671 (define_insn ""
1672   [(set (pc)
1673         (if_then_else
1674          (match_operator 3 "comparison_operator"
1675                          [(match_operand:SI 1 "reg_or_0_operand" "rM")
1676                           (match_operand:SI 2 "arith5_operand" "rL")])
1677          (pc)
1678          (label_ref (match_operand 0 "" ""))))]
1679   ""
1680   "*
1681 {
1682   return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1683                          get_attr_length (insn), 1, insn);
1684 }"
1685 [(set_attr "type" "cbranch")
1686  (set (attr "length")
1687     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1688                (const_int 8184))
1689            (const_int 4)
1690            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1691                (const_int 262100))
1692            (const_int 8)
1693            (eq (symbol_ref "flag_pic") (const_int 0))
1694            (const_int 20)]
1695           (const_int 28)))])
1696
1697 (define_insn ""
1698   [(set (pc)
1699         (if_then_else
1700          (match_operator 3 "comparison_operator"
1701                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1702                           (match_operand:DI 2 "reg_or_0_operand" "rM")])
1703          (label_ref (match_operand 0 "" ""))
1704          (pc)))]
1705   "TARGET_64BIT"
1706   "*
1707 {
1708   return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1709                          get_attr_length (insn), 0, insn);
1710 }"
1711 [(set_attr "type" "cbranch")
1712  (set (attr "length")
1713     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1714                (const_int 8184))
1715            (const_int 4)
1716            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1717                (const_int 262100))
1718            (const_int 8)
1719            (eq (symbol_ref "flag_pic") (const_int 0))
1720            (const_int 20)]
1721           (const_int 28)))])
1722
1723 ;; Match the negated branch.
1724
1725 (define_insn ""
1726   [(set (pc)
1727         (if_then_else
1728          (match_operator 3 "comparison_operator"
1729                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1730                           (match_operand:DI 2 "reg_or_0_operand" "rM")])
1731          (pc)
1732          (label_ref (match_operand 0 "" ""))))]
1733   "TARGET_64BIT"
1734   "*
1735 {
1736   return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1737                          get_attr_length (insn), 1, insn);
1738 }"
1739 [(set_attr "type" "cbranch")
1740  (set (attr "length")
1741     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1742                (const_int 8184))
1743            (const_int 4)
1744            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1745                (const_int 262100))
1746            (const_int 8)
1747            (eq (symbol_ref "flag_pic") (const_int 0))
1748            (const_int 20)]
1749           (const_int 28)))])
1750 (define_insn ""
1751   [(set (pc)
1752         (if_then_else
1753          (match_operator 3 "cmpib_comparison_operator"
1754                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1755                           (match_operand:DI 2 "arith5_operand" "rL")])
1756          (label_ref (match_operand 0 "" ""))
1757          (pc)))]
1758   "TARGET_64BIT"
1759   "*
1760 {
1761   return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1762                          get_attr_length (insn), 0, insn);
1763 }"
1764 [(set_attr "type" "cbranch")
1765  (set (attr "length")
1766     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1767                (const_int 8184))
1768            (const_int 4)
1769            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1770                (const_int 262100))
1771            (const_int 8)
1772            (eq (symbol_ref "flag_pic") (const_int 0))
1773            (const_int 20)]
1774           (const_int 28)))])
1775
1776 ;; Match the negated branch.
1777
1778 (define_insn ""
1779   [(set (pc)
1780         (if_then_else
1781          (match_operator 3 "cmpib_comparison_operator"
1782                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1783                           (match_operand:DI 2 "arith5_operand" "rL")])
1784          (pc)
1785          (label_ref (match_operand 0 "" ""))))]
1786   "TARGET_64BIT"
1787   "*
1788 {
1789   return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1790                          get_attr_length (insn), 1, insn);
1791 }"
1792 [(set_attr "type" "cbranch")
1793  (set (attr "length")
1794     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1795                (const_int 8184))
1796            (const_int 4)
1797            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1798                (const_int 262100))
1799            (const_int 8)
1800            (eq (symbol_ref "flag_pic") (const_int 0))
1801            (const_int 20)]
1802           (const_int 28)))])
1803
1804 ;; Branch on Bit patterns.
1805 (define_insn ""
1806   [(set (pc)
1807         (if_then_else
1808          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1809                               (const_int 1)
1810                               (match_operand:SI 1 "uint5_operand" ""))
1811              (const_int 0))
1812          (label_ref (match_operand 2 "" ""))
1813          (pc)))]
1814   ""
1815   "*
1816 {
1817   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1818                          get_attr_length (insn), 0, insn, 0);
1819 }"
1820 [(set_attr "type" "cbranch")
1821  (set (attr "length")
1822     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1823                       (const_int 8184))
1824            (const_int 4)
1825            (const_int 8)))])
1826
1827 (define_insn ""
1828   [(set (pc)
1829         (if_then_else
1830          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1831                               (const_int 1)
1832                               (match_operand:DI 1 "uint32_operand" ""))
1833              (const_int 0))
1834          (label_ref (match_operand 2 "" ""))
1835          (pc)))]
1836   "TARGET_64BIT"
1837   "*
1838 {
1839   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1840                          get_attr_length (insn), 0, insn, 0);
1841 }"
1842 [(set_attr "type" "cbranch")
1843  (set (attr "length")
1844     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1845                       (const_int 8184))
1846            (const_int 4)
1847            (const_int 8)))])
1848
1849 (define_insn ""
1850   [(set (pc)
1851         (if_then_else
1852          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1853                               (const_int 1)
1854                               (match_operand:SI 1 "uint5_operand" ""))
1855              (const_int 0))
1856          (pc)
1857          (label_ref (match_operand 2 "" ""))))]
1858   ""
1859   "*
1860 {
1861   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1862                          get_attr_length (insn), 1, insn, 0);
1863 }"
1864 [(set_attr "type" "cbranch")
1865  (set (attr "length")
1866     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1867                       (const_int 8184))
1868            (const_int 4)
1869            (const_int 8)))])
1870
1871 (define_insn ""
1872   [(set (pc)
1873         (if_then_else
1874          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1875                               (const_int 1)
1876                               (match_operand:DI 1 "uint32_operand" ""))
1877              (const_int 0))
1878          (pc)
1879          (label_ref (match_operand 2 "" ""))))]
1880   "TARGET_64BIT"
1881   "*
1882 {
1883   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1884                          get_attr_length (insn), 1, insn, 0);
1885 }"
1886 [(set_attr "type" "cbranch")
1887  (set (attr "length")
1888     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1889                       (const_int 8184))
1890            (const_int 4)
1891            (const_int 8)))])
1892
1893 (define_insn ""
1894   [(set (pc)
1895         (if_then_else
1896          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1897                               (const_int 1)
1898                               (match_operand:SI 1 "uint5_operand" ""))
1899              (const_int 0))
1900          (label_ref (match_operand 2 "" ""))
1901          (pc)))]
1902   ""
1903   "*
1904 {
1905   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1906                          get_attr_length (insn), 0, insn, 1);
1907 }"
1908 [(set_attr "type" "cbranch")
1909  (set (attr "length")
1910     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1911                       (const_int 8184))
1912            (const_int 4)
1913            (const_int 8)))])
1914
1915 (define_insn ""
1916   [(set (pc)
1917         (if_then_else
1918          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1919                               (const_int 1)
1920                               (match_operand:DI 1 "uint32_operand" ""))
1921              (const_int 0))
1922          (label_ref (match_operand 2 "" ""))
1923          (pc)))]
1924   "TARGET_64BIT"
1925   "*
1926 {
1927   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1928                          get_attr_length (insn), 0, insn, 1);
1929 }"
1930 [(set_attr "type" "cbranch")
1931  (set (attr "length")
1932     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1933                       (const_int 8184))
1934            (const_int 4)
1935            (const_int 8)))])
1936
1937 (define_insn ""
1938   [(set (pc)
1939         (if_then_else
1940          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1941                               (const_int 1)
1942                               (match_operand:SI 1 "uint5_operand" ""))
1943              (const_int 0))
1944          (pc)
1945          (label_ref (match_operand 2 "" ""))))]
1946   ""
1947   "*
1948 {
1949   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1950                          get_attr_length (insn), 1, insn, 1);
1951 }"
1952 [(set_attr "type" "cbranch")
1953  (set (attr "length")
1954     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1955                       (const_int 8184))
1956            (const_int 4)
1957            (const_int 8)))])
1958
1959 (define_insn ""
1960   [(set (pc)
1961         (if_then_else
1962          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1963                               (const_int 1)
1964                               (match_operand:DI 1 "uint32_operand" ""))
1965              (const_int 0))
1966          (pc)
1967          (label_ref (match_operand 2 "" ""))))]
1968   "TARGET_64BIT"
1969   "*
1970 {
1971   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1972                          get_attr_length (insn), 1, insn, 1);
1973 }"
1974 [(set_attr "type" "cbranch")
1975  (set (attr "length")
1976     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1977                       (const_int 8184))
1978            (const_int 4)
1979            (const_int 8)))])
1980
1981 ;; Branch on Variable Bit patterns.
1982 (define_insn ""
1983   [(set (pc)
1984         (if_then_else
1985          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1986                               (const_int 1)
1987                               (match_operand:SI 1 "register_operand" "q"))
1988              (const_int 0))
1989          (label_ref (match_operand 2 "" ""))
1990          (pc)))]
1991   ""
1992   "*
1993 {
1994   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
1995                      get_attr_length (insn), 0, insn, 0);
1996 }"
1997 [(set_attr "type" "cbranch")
1998  (set (attr "length")
1999     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2000                       (const_int 8184))
2001            (const_int 4)
2002            (const_int 8)))])
2003
2004 (define_insn ""
2005   [(set (pc)
2006         (if_then_else
2007          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2008                               (const_int 1)
2009                               (match_operand:DI 1 "register_operand" "q"))
2010              (const_int 0))
2011          (label_ref (match_operand 2 "" ""))
2012          (pc)))]
2013   "TARGET_64BIT"
2014   "*
2015 {
2016   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
2017                      get_attr_length (insn), 0, insn, 0);
2018 }"
2019 [(set_attr "type" "cbranch")
2020  (set (attr "length")
2021     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2022                       (const_int 8184))
2023            (const_int 4)
2024            (const_int 8)))])
2025
2026 (define_insn ""
2027   [(set (pc)
2028         (if_then_else
2029          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
2030                               (const_int 1)
2031                               (match_operand:SI 1 "register_operand" "q"))
2032              (const_int 0))
2033          (pc)
2034          (label_ref (match_operand 2 "" ""))))]
2035   ""
2036   "*
2037 {
2038   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
2039                      get_attr_length (insn), 1, insn, 0);
2040 }"
2041 [(set_attr "type" "cbranch")
2042  (set (attr "length")
2043     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2044                       (const_int 8184))
2045            (const_int 4)
2046            (const_int 8)))])
2047
2048 (define_insn ""
2049   [(set (pc)
2050         (if_then_else
2051          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2052                               (const_int 1)
2053                               (match_operand:DI 1 "register_operand" "q"))
2054              (const_int 0))
2055          (pc)
2056          (label_ref (match_operand 2 "" ""))))]
2057   "TARGET_64BIT"
2058   "*
2059 {
2060   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
2061                      get_attr_length (insn), 1, insn, 0);
2062 }"
2063 [(set_attr "type" "cbranch")
2064  (set (attr "length")
2065     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2066                       (const_int 8184))
2067            (const_int 4)
2068            (const_int 8)))])
2069
2070 (define_insn ""
2071   [(set (pc)
2072         (if_then_else
2073          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
2074                               (const_int 1)
2075                               (match_operand:SI 1 "register_operand" "q"))
2076              (const_int 0))
2077          (label_ref (match_operand 2 "" ""))
2078          (pc)))]
2079   ""
2080   "*
2081 {
2082   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
2083                      get_attr_length (insn), 0, insn, 1);
2084 }"
2085 [(set_attr "type" "cbranch")
2086  (set (attr "length")
2087     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2088                       (const_int 8184))
2089            (const_int 4)
2090            (const_int 8)))])
2091
2092 (define_insn ""
2093   [(set (pc)
2094         (if_then_else
2095          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2096                               (const_int 1)
2097                               (match_operand:DI 1 "register_operand" "q"))
2098              (const_int 0))
2099          (label_ref (match_operand 2 "" ""))
2100          (pc)))]
2101   "TARGET_64BIT"
2102   "*
2103 {
2104   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
2105                      get_attr_length (insn), 0, insn, 1);
2106 }"
2107 [(set_attr "type" "cbranch")
2108  (set (attr "length")
2109     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2110                       (const_int 8184))
2111            (const_int 4)
2112            (const_int 8)))])
2113
2114 (define_insn ""
2115   [(set (pc)
2116         (if_then_else
2117          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
2118                               (const_int 1)
2119                               (match_operand:SI 1 "register_operand" "q"))
2120              (const_int 0))
2121          (pc)
2122          (label_ref (match_operand 2 "" ""))))]
2123   ""
2124   "*
2125 {
2126   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
2127                      get_attr_length (insn), 1, insn, 1);
2128 }"
2129 [(set_attr "type" "cbranch")
2130  (set (attr "length")
2131     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2132                       (const_int 8184))
2133            (const_int 4)
2134            (const_int 8)))])
2135
2136 (define_insn ""
2137   [(set (pc)
2138         (if_then_else
2139          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2140                               (const_int 1)
2141                               (match_operand:DI 1 "register_operand" "q"))
2142              (const_int 0))
2143          (pc)
2144          (label_ref (match_operand 2 "" ""))))]
2145   "TARGET_64BIT"
2146   "*
2147 {
2148   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
2149                      get_attr_length (insn), 1, insn, 1);
2150 }"
2151 [(set_attr "type" "cbranch")
2152  (set (attr "length")
2153     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2154                       (const_int 8184))
2155            (const_int 4)
2156            (const_int 8)))])
2157
2158 ;; Floating point branches
2159 (define_insn ""
2160   [(set (pc) (if_then_else (ne (reg:CCFP 0) (const_int 0))
2161                            (label_ref (match_operand 0 "" ""))
2162                            (pc)))]
2163   "! TARGET_SOFT_FLOAT"
2164   "*
2165 {
2166   if (INSN_ANNULLED_BRANCH_P (insn))
2167     return \"ftest\;b,n %0\";
2168   else
2169     return \"ftest\;b%* %0\";
2170 }"
2171   [(set_attr "type" "fbranch")
2172    (set_attr "length" "8")])
2173
2174 (define_insn ""
2175   [(set (pc) (if_then_else (ne (reg:CCFP 0) (const_int 0))
2176                            (pc)
2177                            (label_ref (match_operand 0 "" ""))))]
2178   "! TARGET_SOFT_FLOAT"
2179   "*
2180 {
2181   if (INSN_ANNULLED_BRANCH_P (insn))
2182     return \"ftest\;add,tr %%r0,%%r0,%%r0\;b,n %0\";
2183   else
2184     return \"ftest\;add,tr %%r0,%%r0,%%r0\;b%* %0\";
2185 }"
2186   [(set_attr "type" "fbranch")
2187    (set_attr "length" "12")])
2188
2189 ;; Move instructions
2190
2191 (define_expand "movsi"
2192   [(set (match_operand:SI 0 "general_operand" "")
2193         (match_operand:SI 1 "general_operand" ""))]
2194   ""
2195   "
2196 {
2197   if (emit_move_sequence (operands, SImode, 0))
2198     DONE;
2199 }")
2200
2201 ;; Reloading an SImode or DImode value requires a scratch register if
2202 ;; going in to or out of float point registers.
2203
2204 (define_expand "reload_insi"
2205   [(set (match_operand:SI 0 "register_operand" "=Z")
2206         (match_operand:SI 1 "non_hard_reg_operand" ""))
2207    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
2208   ""
2209   "
2210 {
2211   if (emit_move_sequence (operands, SImode, operands[2]))
2212     DONE;
2213
2214   /* We don't want the clobber emitted, so handle this ourselves.  */
2215   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
2216   DONE;
2217 }")
2218
2219 (define_expand "reload_outsi"
2220   [(set (match_operand:SI 0 "non_hard_reg_operand" "")
2221         (match_operand:SI 1  "register_operand" "Z"))
2222    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
2223   ""
2224   "
2225 {
2226   if (emit_move_sequence (operands, SImode, operands[2]))
2227     DONE;
2228
2229   /* We don't want the clobber emitted, so handle this ourselves.  */
2230   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
2231   DONE;
2232 }")
2233
2234 (define_insn ""
2235   [(set (match_operand:SI 0 "reg_or_nonsymb_mem_operand"
2236                                 "=r,r,r,r,r,r,Q,*q,!f,f,*TR")
2237         (match_operand:SI 1 "move_operand"
2238                                 "A,r,J,N,K,RQ,rM,rM,!fM,*RT,f"))]
2239   "(register_operand (operands[0], SImode)
2240     || reg_or_0_operand (operands[1], SImode))
2241    && ! TARGET_SOFT_FLOAT"
2242   "@
2243    ldw RT'%A1,%0
2244    copy %1,%0
2245    ldi %1,%0
2246    ldil L'%1,%0
2247    {zdepi|depwi,z} %Z1,%0
2248    ldw%M1 %1,%0
2249    stw%M0 %r1,%0
2250    mtsar %r1
2251    fcpy,sgl %f1,%0
2252    fldw%F1 %1,%0
2253    fstw%F0 %1,%0"
2254   [(set_attr "type" "load,move,move,move,shift,load,store,move,fpalu,fpload,fpstore")
2255    (set_attr "pa_combine_type" "addmove")
2256    (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4")])
2257
2258 (define_insn ""
2259   [(set (match_operand:SI 0 "reg_or_nonsymb_mem_operand"
2260                                 "=r,r,r,r,r,r,Q,*q")
2261         (match_operand:SI 1 "move_operand"
2262                                 "A,r,J,N,K,RQ,rM,rM"))]
2263   "(register_operand (operands[0], SImode)
2264     || reg_or_0_operand (operands[1], SImode))
2265    && TARGET_SOFT_FLOAT"
2266   "@
2267    ldw RT'%A1,%0
2268    copy %1,%0
2269    ldi %1,%0
2270    ldil L'%1,%0
2271    {zdepi|depwi,z} %Z1,%0
2272    ldw%M1 %1,%0
2273    stw%M0 %r1,%0
2274    mtsar %r1"
2275   [(set_attr "type" "load,move,move,move,move,load,store,move")
2276    (set_attr "pa_combine_type" "addmove")
2277    (set_attr "length" "4,4,4,4,4,4,4,4")])
2278
2279 (define_insn ""
2280   [(set (match_operand:SI 0 "register_operand" "=r")
2281         (mem:SI (plus:SI (match_operand:SI 1 "basereg_operand" "r")
2282                          (match_operand:SI 2 "register_operand" "r"))))]
2283   "! TARGET_DISABLE_INDEXING"
2284   "{ldwx|ldw} %2(%1),%0"
2285   [(set_attr "type" "load")
2286    (set_attr "length" "4")])
2287
2288 (define_insn ""
2289   [(set (match_operand:SI 0 "register_operand" "=r")
2290         (mem:SI (plus:SI (match_operand:SI 1 "register_operand" "r")
2291                          (match_operand:SI 2 "basereg_operand" "r"))))]
2292   "! TARGET_DISABLE_INDEXING"
2293   "{ldwx|ldw} %1(%2),%0"
2294   [(set_attr "type" "load")
2295    (set_attr "length" "4")])
2296
2297 ;; Load or store with base-register modification.
2298
2299 (define_expand "pre_load"
2300   [(parallel [(set (match_operand:SI 0 "register_operand" "")
2301               (mem (plus (match_operand 1 "register_operand" "")
2302                                (match_operand 2 "pre_cint_operand" ""))))
2303               (set (match_dup 1)
2304                    (plus (match_dup 1) (match_dup 2)))])]
2305   ""
2306   "
2307 {
2308   if (TARGET_64BIT)
2309     {
2310       emit_insn (gen_pre_ldd (operands[0], operands[1], operands[2]));
2311       DONE;
2312     }
2313   emit_insn (gen_pre_ldw (operands[0], operands[1], operands[2]));
2314   DONE;
2315 }")
2316
2317 (define_insn "pre_ldw"
2318   [(set (match_operand:SI 0 "register_operand" "=r")
2319         (mem:SI (plus:SI (match_operand:SI 1 "register_operand" "+r")
2320                          (match_operand:SI 2 "pre_cint_operand" ""))))
2321    (set (match_dup 1)
2322         (plus:SI (match_dup 1) (match_dup 2)))]
2323   ""
2324   "*
2325 {
2326   if (INTVAL (operands[2]) < 0)
2327     return \"{ldwm|ldw,mb} %2(%1),%0\";
2328   return \"{ldws|ldw},mb %2(%1),%0\";
2329 }"
2330   [(set_attr "type" "load")
2331    (set_attr "length" "4")])
2332
2333 (define_insn "pre_ldd"
2334   [(set (match_operand:DI 0 "register_operand" "=r")
2335         (mem:DI (plus:DI (match_operand:DI 1 "register_operand" "+r")
2336                          (match_operand:DI 2 "pre_cint_operand" ""))))
2337    (set (match_dup 1)
2338         (plus:DI (match_dup 1) (match_dup 2)))]
2339   "TARGET_64BIT"
2340   "ldd,mb %2(%1),%0"
2341   [(set_attr "type" "load")
2342    (set_attr "length" "4")])
2343
2344 (define_insn ""
2345   [(set (mem:SI (plus:SI (match_operand:SI 0 "register_operand" "+r")
2346                          (match_operand:SI 1 "pre_cint_operand" "")))
2347         (match_operand:SI 2 "reg_or_0_operand" "rM"))
2348    (set (match_dup 0)
2349         (plus:SI (match_dup 0) (match_dup 1)))]
2350   ""
2351   "*
2352 {
2353   if (INTVAL (operands[1]) < 0)
2354     return \"{stwm|stw,mb} %r2,%1(%0)\";
2355   return \"{stws|stw},mb %r2,%1(%0)\";
2356 }"
2357   [(set_attr "type" "store")
2358    (set_attr "length" "4")])
2359
2360 (define_insn ""
2361   [(set (match_operand:SI 0 "register_operand" "=r")
2362         (mem:SI (match_operand:SI 1 "register_operand" "+r")))
2363    (set (match_dup 1)
2364         (plus:SI (match_dup 1)
2365                  (match_operand:SI 2 "post_cint_operand" "")))]
2366   ""
2367   "*
2368 {
2369   if (INTVAL (operands[2]) > 0)
2370     return \"{ldwm|ldw,ma} %2(%1),%0\";
2371   return \"{ldws|ldw},ma %2(%1),%0\";
2372 }"
2373   [(set_attr "type" "load")
2374    (set_attr "length" "4")])
2375
2376 (define_expand "post_store"
2377   [(parallel [(set (mem (match_operand 0 "register_operand" ""))
2378                    (match_operand 1 "reg_or_0_operand" ""))
2379               (set (match_dup 0)
2380                    (plus (match_dup 0)
2381                          (match_operand 2 "post_cint_operand" "")))])]
2382   ""
2383   "
2384 {
2385   if (TARGET_64BIT)
2386     {
2387       emit_insn (gen_post_std (operands[0], operands[1], operands[2]));
2388       DONE;
2389     }
2390   emit_insn (gen_post_stw (operands[0], operands[1], operands[2]));
2391   DONE;
2392 }")
2393
2394 (define_insn "post_stw"
2395   [(set (mem:SI (match_operand:SI 0 "register_operand" "+r"))
2396         (match_operand:SI 1 "reg_or_0_operand" "rM"))
2397    (set (match_dup 0)
2398         (plus:SI (match_dup 0)
2399                  (match_operand:SI 2 "post_cint_operand" "")))]
2400   ""
2401   "*
2402 {
2403   if (INTVAL (operands[2]) > 0)
2404     return \"{stwm|stw,ma} %r1,%2(%0)\";
2405   return \"{stws|stw},ma %r1,%2(%0)\";
2406 }"
2407   [(set_attr "type" "store")
2408    (set_attr "length" "4")])
2409
2410 (define_insn "post_std"
2411   [(set (mem:DI (match_operand:DI 0 "register_operand" "+r"))
2412         (match_operand:DI 1 "reg_or_0_operand" "rM"))
2413    (set (match_dup 0)
2414         (plus:DI (match_dup 0)
2415                  (match_operand:DI 2 "post_cint_operand" "")))]
2416   "TARGET_64BIT"
2417   "std,ma %r1,%2(%0)"
2418   [(set_attr "type" "store")
2419    (set_attr "length" "4")])
2420
2421 ;; For loading the address of a label while generating PIC code.
2422 ;; Note since this pattern can be created at reload time (via movsi), all
2423 ;; the same rules for movsi apply here.  (no new pseudos, no temporaries).
2424 (define_insn ""
2425   [(set (match_operand 0 "pmode_register_operand" "=a")
2426         (match_operand 1 "pic_label_operand" ""))]
2427   ""
2428   "*
2429 {
2430   rtx xoperands[3];
2431   extern FILE *asm_out_file;
2432
2433   xoperands[0] = operands[0];
2434   xoperands[1] = operands[1];
2435   if (TARGET_SOM || ! TARGET_GAS)
2436     xoperands[2] = gen_label_rtx ();
2437
2438   output_asm_insn (\"{bl|b,l} .+8,%0\", xoperands);
2439   output_asm_insn (\"{depi|depwi} 0,31,2,%0\", xoperands);
2440   if (TARGET_SOM || ! TARGET_GAS)
2441     ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\",
2442                                CODE_LABEL_NUMBER (xoperands[2]));
2443
2444   /* If we're trying to load the address of a label that happens to be
2445      close, then we can use a shorter sequence.  */
2446   if (GET_CODE (operands[1]) == LABEL_REF
2447       && INSN_ADDRESSES_SET_P ()
2448       && abs (INSN_ADDRESSES (INSN_UID (XEXP (operands[1], 0)))
2449                 - INSN_ADDRESSES (INSN_UID (insn))) < 8100)
2450     {
2451       /* Prefixing with R% here is wrong, it extracts just 11 bits and is
2452          always non-negative.  */
2453       if (TARGET_SOM || ! TARGET_GAS)
2454         output_asm_insn (\"ldo %1-%2(%0),%0\", xoperands);
2455       else
2456         output_asm_insn (\"ldo %1-$PIC_pcrel$0+8(%0),%0\", xoperands);
2457     }
2458   else
2459     {
2460       if (TARGET_SOM || ! TARGET_GAS)
2461         {
2462           output_asm_insn (\"addil L%%%1-%2,%0\", xoperands);
2463           output_asm_insn (\"ldo R%%%1-%2(%0),%0\", xoperands);
2464         }
2465       else
2466         {
2467           output_asm_insn (\"addil L%%%1-$PIC_pcrel$0+8,%0\", xoperands);
2468           output_asm_insn (\"ldo R%%%1-$PIC_pcrel$0+12(%0),%0\",
2469                            xoperands);
2470         }
2471     }
2472   return \"\";
2473 }"
2474   [(set_attr "type" "multi")
2475    (set_attr "length" "16")])           ; 12 or 16
2476
2477 (define_insn ""
2478   [(set (match_operand:SI 0 "register_operand" "=a")
2479         (plus:SI (match_operand:SI 1 "register_operand" "r")
2480                  (high:SI (match_operand 2 "" ""))))]
2481   "symbolic_operand (operands[2], Pmode)
2482    && ! function_label_operand (operands[2], Pmode)
2483    && flag_pic"
2484   "addil LT'%G2,%1"
2485   [(set_attr "type" "binary")
2486    (set_attr "length" "4")])
2487
2488 (define_insn ""
2489   [(set (match_operand:DI 0 "register_operand" "=a")
2490         (plus:DI (match_operand:DI 1 "register_operand" "r")
2491                  (high:DI (match_operand 2 "" ""))))]
2492   "symbolic_operand (operands[2], Pmode)
2493    && ! function_label_operand (operands[2], Pmode)
2494    && TARGET_64BIT
2495    && flag_pic"
2496   "addil LT'%G2,%1"
2497   [(set_attr "type" "binary")
2498    (set_attr "length" "4")])
2499
2500 ;; Always use addil rather than ldil;add sequences.  This allows the
2501 ;; HP linker to eliminate the dp relocation if the symbolic operand
2502 ;; lives in the TEXT space.
2503 (define_insn ""
2504   [(set (match_operand:SI 0 "register_operand" "=a")
2505         (high:SI (match_operand 1 "" "")))]
2506   "symbolic_operand (operands[1], Pmode)
2507    && ! function_label_operand (operands[1], Pmode)
2508    && ! read_only_operand (operands[1], Pmode)
2509    && ! flag_pic"
2510   "*
2511 {
2512   if (TARGET_LONG_LOAD_STORE)
2513     return \"addil NLR'%H1,%%r27\;ldo N'%H1(%%r1),%%r1\";
2514   else
2515     return \"addil LR'%H1,%%r27\";
2516 }"
2517   [(set_attr "type" "binary")
2518    (set (attr "length")
2519       (if_then_else (eq (symbol_ref "TARGET_LONG_LOAD_STORE") (const_int 0))
2520                     (const_int 4)
2521                     (const_int 8)))])
2522
2523
2524 ;; This is for use in the prologue/epilogue code.  We need it
2525 ;; to add large constants to a stack pointer or frame pointer.
2526 ;; Because of the additional %r1 pressure, we probably do not
2527 ;; want to use this in general code, so make it available
2528 ;; only after reload.
2529 (define_insn ""
2530   [(set (match_operand:SI 0 "register_operand" "=!a,*r")
2531         (plus:SI (match_operand:SI 1 "register_operand" "r,r")
2532                  (high:SI (match_operand 2 "const_int_operand" ""))))]
2533   "reload_completed"
2534   "@
2535    addil L'%G2,%1
2536    ldil L'%G2,%0\;{addl|add,l} %0,%1,%0"
2537   [(set_attr "type" "binary,binary")
2538    (set_attr "length" "4,8")])
2539
2540 (define_insn ""
2541   [(set (match_operand:DI 0 "register_operand" "=!a,*r")
2542         (plus:DI (match_operand:DI 1 "register_operand" "r,r")
2543                  (high:DI (match_operand 2 "const_int_operand" ""))))]
2544   "reload_completed && TARGET_64BIT"
2545   "@
2546    addil L'%G2,%1
2547    ldil L'%G2,%0\;{addl|add,l} %0,%1,%0"
2548   [(set_attr "type" "binary,binary")
2549    (set_attr "length" "4,8")])
2550
2551 (define_insn ""
2552   [(set (match_operand:SI 0 "register_operand" "=r")
2553         (high:SI (match_operand 1 "" "")))]
2554   "(!flag_pic || !symbolic_operand (operands[1], Pmode))
2555     && !is_function_label_plus_const (operands[1])"
2556   "*
2557 {
2558   if (symbolic_operand (operands[1], Pmode))
2559     return \"ldil LR'%H1,%0\";
2560   else
2561     return \"ldil L'%G1,%0\";
2562 }"
2563   [(set_attr "type" "move")
2564    (set_attr "length" "4")])
2565
2566 (define_insn ""
2567   [(set (match_operand:DI 0 "register_operand" "=r")
2568         (high:DI (match_operand 1 "const_int_operand" "")))]
2569   "TARGET_64BIT"
2570   "ldil L'%G1,%0";
2571   [(set_attr "type" "move")
2572    (set_attr "length" "4")])
2573
2574 (define_insn ""
2575   [(set (match_operand:DI 0 "register_operand" "=r")
2576         (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
2577                    (match_operand:DI 2 "const_int_operand" "i")))]
2578   "TARGET_64BIT"
2579   "ldo R'%G2(%1),%0";
2580   [(set_attr "type" "move")
2581    (set_attr "length" "4")])
2582
2583 (define_insn ""
2584   [(set (match_operand:SI 0 "register_operand" "=r")
2585         (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
2586                    (match_operand:SI 2 "immediate_operand" "i")))]
2587   "!is_function_label_plus_const (operands[2])"
2588   "*
2589 {
2590   if (flag_pic && symbolic_operand (operands[2], Pmode))
2591     abort ();
2592   else if (symbolic_operand (operands[2], Pmode))
2593     return \"ldo RR'%G2(%1),%0\";
2594   else
2595     return \"ldo R'%G2(%1),%0\";
2596 }"
2597   [(set_attr "type" "move")
2598    (set_attr "length" "4")])
2599
2600 ;; Now that a symbolic_address plus a constant is broken up early
2601 ;; in the compilation phase (for better CSE) we need a special
2602 ;; combiner pattern to load the symbolic address plus the constant
2603 ;; in only 2 instructions. (For cases where the symbolic address
2604 ;; was not a common subexpression.)
2605 (define_split
2606   [(set (match_operand:SI 0 "register_operand" "")
2607         (match_operand:SI 1 "symbolic_operand" ""))
2608    (clobber (match_operand:SI 2 "register_operand" ""))]
2609   "! (flag_pic && pic_label_operand (operands[1], SImode))"
2610   [(set (match_dup 2) (high:SI (match_dup 1)))
2611    (set (match_dup 0) (lo_sum:SI (match_dup 2) (match_dup 1)))]
2612   "")
2613
2614 ;; hppa_legitimize_address goes to a great deal of trouble to
2615 ;; create addresses which use indexing.  In some cases, this
2616 ;; is a lose because there isn't any store instructions which
2617 ;; allow indexed addresses (with integer register source).
2618 ;;
2619 ;; These define_splits try to turn a 3 insn store into
2620 ;; a 2 insn store with some creative RTL rewriting.
2621 (define_split
2622   [(set (mem:SI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2623                                (match_operand:SI 1 "shadd_operand" ""))
2624                    (plus:SI (match_operand:SI 2 "register_operand" "")
2625                             (match_operand:SI 3 "const_int_operand" ""))))
2626         (match_operand:SI 4 "register_operand" ""))
2627    (clobber (match_operand:SI 5 "register_operand" ""))]
2628   ""
2629   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
2630                                (match_dup 2)))
2631    (set (mem:SI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2632   "")
2633
2634 (define_split
2635   [(set (mem:HI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2636                                (match_operand:SI 1 "shadd_operand" ""))
2637                    (plus:SI (match_operand:SI 2 "register_operand" "")
2638                             (match_operand:SI 3 "const_int_operand" ""))))
2639         (match_operand:HI 4 "register_operand" ""))
2640    (clobber (match_operand:SI 5 "register_operand" ""))]
2641   ""
2642   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
2643                                (match_dup 2)))
2644    (set (mem:HI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2645   "")
2646
2647 (define_split
2648   [(set (mem:QI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2649                                (match_operand:SI 1 "shadd_operand" ""))
2650                    (plus:SI (match_operand:SI 2 "register_operand" "")
2651                             (match_operand:SI 3 "const_int_operand" ""))))
2652         (match_operand:QI 4 "register_operand" ""))
2653    (clobber (match_operand:SI 5 "register_operand" ""))]
2654   ""
2655   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
2656                                (match_dup 2)))
2657    (set (mem:QI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2658   "")
2659
2660 (define_expand "movhi"
2661   [(set (match_operand:HI 0 "general_operand" "")
2662         (match_operand:HI 1 "general_operand" ""))]
2663   ""
2664   "
2665 {
2666   if (emit_move_sequence (operands, HImode, 0))
2667     DONE;
2668 }")
2669
2670 (define_insn ""
2671   [(set (match_operand:HI 0 "reg_or_nonsymb_mem_operand" "=r,r,r,r,r,Q,*q,!*f")
2672         (match_operand:HI 1 "move_operand" "r,J,N,K,RQ,rM,rM,!*fM"))]
2673   "register_operand (operands[0], HImode)
2674    || reg_or_0_operand (operands[1], HImode)"
2675   "@
2676    copy %1,%0
2677    ldi %1,%0
2678    ldil L'%1,%0
2679    {zdepi|depwi,z} %Z1,%0
2680    ldh%M1 %1,%0
2681    sth%M0 %r1,%0
2682    mtsar %r1
2683    fcpy,sgl %f1,%0"
2684   [(set_attr "type" "move,move,move,shift,load,store,move,fpalu")
2685    (set_attr "pa_combine_type" "addmove")
2686    (set_attr "length" "4,4,4,4,4,4,4,4")])
2687
2688 (define_insn ""
2689   [(set (match_operand:HI 0 "register_operand" "=r")
2690         (mem:HI (plus:SI (match_operand:SI 1 "basereg_operand" "r")
2691                          (match_operand:SI 2 "register_operand" "r"))))]
2692   "! TARGET_DISABLE_INDEXING"
2693   "{ldhx|ldh} %2(%1),%0"
2694   [(set_attr "type" "load")
2695    (set_attr "length" "4")])
2696
2697 (define_insn ""
2698   [(set (match_operand:HI 0 "register_operand" "=r")
2699         (mem:HI (plus:SI (match_operand:SI 1 "register_operand" "r")
2700                          (match_operand:SI 2 "basereg_operand" "r"))))]
2701   "! TARGET_DISABLE_INDEXING"
2702   "{ldhx|ldh} %1(%2),%0"
2703   [(set_attr "type" "load")
2704    (set_attr "length" "4")])
2705
2706 ; Now zero extended variants.
2707 (define_insn ""
2708   [(set (match_operand:SI 0 "register_operand" "=r")
2709         (zero_extend:SI (mem:HI
2710                           (plus:SI
2711                             (match_operand:SI 1 "basereg_operand" "r")
2712                             (match_operand:SI 2 "register_operand" "r")))))]
2713   "! TARGET_DISABLE_INDEXING"
2714   "{ldhx|ldh} %2(%1),%0"
2715   [(set_attr "type" "load")
2716    (set_attr "length" "4")])
2717
2718 (define_insn ""
2719   [(set (match_operand:SI 0 "register_operand" "=r")
2720         (zero_extend:SI (mem:HI
2721                           (plus:SI
2722                              (match_operand:SI 1 "register_operand" "r")
2723                              (match_operand:SI 2 "basereg_operand" "r")))))]
2724   "! TARGET_DISABLE_INDEXING"
2725   "{ldhx|ldh} %1(%2),%0"
2726   [(set_attr "type" "load")
2727    (set_attr "length" "4")])
2728
2729 (define_insn ""
2730   [(set (match_operand:HI 0 "register_operand" "=r")
2731         (mem:HI (plus:SI (match_operand:SI 1 "register_operand" "+r")
2732                          (match_operand:SI 2 "int5_operand" "L"))))
2733    (set (match_dup 1)
2734         (plus:SI (match_dup 1) (match_dup 2)))]
2735   ""
2736   "{ldhs|ldh},mb %2(%1),%0"
2737   [(set_attr "type" "load")
2738    (set_attr "length" "4")])
2739
2740 ; And a zero extended variant.
2741 (define_insn ""
2742   [(set (match_operand:SI 0 "register_operand" "=r")
2743         (zero_extend:SI (mem:HI
2744                           (plus:SI
2745                             (match_operand:SI 1 "register_operand" "+r")
2746                             (match_operand:SI 2 "int5_operand" "L")))))
2747    (set (match_dup 1)
2748         (plus:SI (match_dup 1) (match_dup 2)))]
2749   ""
2750   "{ldhs|ldh},mb %2(%1),%0"
2751   [(set_attr "type" "load")
2752    (set_attr "length" "4")])
2753
2754 (define_insn ""
2755   [(set (mem:HI (plus:SI (match_operand:SI 0 "register_operand" "+r")
2756                          (match_operand:SI 1 "int5_operand" "L")))
2757         (match_operand:HI 2 "reg_or_0_operand" "rM"))
2758    (set (match_dup 0)
2759         (plus:SI (match_dup 0) (match_dup 1)))]
2760   ""
2761   "{sths|sth},mb %r2,%1(%0)"
2762   [(set_attr "type" "store")
2763    (set_attr "length" "4")])
2764
2765 (define_insn ""
2766   [(set (match_operand:HI 0 "register_operand" "=r")
2767         (plus:HI (match_operand:HI 1 "register_operand" "r")
2768                  (match_operand 2 "const_int_operand" "J")))]
2769   ""
2770   "ldo %2(%1),%0"
2771   [(set_attr "type" "binary")
2772    (set_attr "pa_combine_type" "addmove")
2773    (set_attr "length" "4")])
2774
2775 (define_expand "movqi"
2776   [(set (match_operand:QI 0 "general_operand" "")
2777         (match_operand:QI 1 "general_operand" ""))]
2778   ""
2779   "
2780 {
2781   if (emit_move_sequence (operands, QImode, 0))
2782     DONE;
2783 }")
2784
2785 (define_insn ""
2786   [(set (match_operand:QI 0 "reg_or_nonsymb_mem_operand" "=r,r,r,r,r,Q,*q,!*f")
2787         (match_operand:QI 1 "move_operand" "r,J,N,K,RQ,rM,rM,!*fM"))]
2788   "register_operand (operands[0], QImode)
2789    || reg_or_0_operand (operands[1], QImode)"
2790   "@
2791    copy %1,%0
2792    ldi %1,%0
2793    ldil L'%1,%0
2794    {zdepi|depwi,z} %Z1,%0
2795    ldb%M1 %1,%0
2796    stb%M0 %r1,%0
2797    mtsar %r1
2798    fcpy,sgl %f1,%0"
2799   [(set_attr "type" "move,move,move,shift,load,store,move,fpalu")
2800    (set_attr "pa_combine_type" "addmove")
2801    (set_attr "length" "4,4,4,4,4,4,4,4")])
2802
2803 (define_insn ""
2804   [(set (match_operand:QI 0 "register_operand" "=r")
2805         (mem:QI (plus:SI (match_operand:SI 1 "basereg_operand" "r")
2806                          (match_operand:SI 2 "register_operand" "r"))))]
2807   "! TARGET_DISABLE_INDEXING"
2808   "{ldbx|ldb} %2(%1),%0"
2809   [(set_attr "type" "load")
2810    (set_attr "length" "4")])
2811
2812 (define_insn ""
2813   [(set (match_operand:QI 0 "register_operand" "=r")
2814         (mem:QI (plus:SI (match_operand:SI 1 "register_operand" "r")
2815                          (match_operand:SI 2 "basereg_operand" "r"))))]
2816   "! TARGET_DISABLE_INDEXING"
2817   "{ldbx|ldb} %1(%2),%0"
2818   [(set_attr "type" "load")
2819    (set_attr "length" "4")])
2820
2821 ; Indexed byte load with zero extension to SImode or HImode.
2822 (define_insn ""
2823   [(set (match_operand:SI 0 "register_operand" "=r")
2824         (zero_extend:SI (mem:QI
2825                           (plus:SI
2826                             (match_operand:SI 1 "basereg_operand" "r")
2827                             (match_operand:SI 2 "register_operand" "r")))))]
2828   "! TARGET_DISABLE_INDEXING"
2829   "{ldbx|ldb} %2(%1),%0"
2830   [(set_attr "type" "load")
2831    (set_attr "length" "4")])
2832
2833 (define_insn ""
2834   [(set (match_operand:SI 0 "register_operand" "=r")
2835         (zero_extend:SI (mem:QI
2836                           (plus:SI
2837                             (match_operand:SI 1 "register_operand" "r")
2838                             (match_operand:SI 2 "basereg_operand" "r")))))]
2839   "! TARGET_DISABLE_INDEXING"
2840   "{ldbx|ldb} %1(%2),%0"
2841   [(set_attr "type" "load")
2842    (set_attr "length" "4")])
2843
2844 (define_insn ""
2845   [(set (match_operand:HI 0 "register_operand" "=r")
2846         (zero_extend:HI (mem:QI
2847                           (plus:SI
2848                             (match_operand:SI 1 "basereg_operand" "r")
2849                             (match_operand:SI 2 "register_operand" "r")))))]
2850   "! TARGET_DISABLE_INDEXING"
2851   "{ldbx|ldb} %2(%1),%0"
2852   [(set_attr "type" "load")
2853    (set_attr "length" "4")])
2854
2855 (define_insn ""
2856   [(set (match_operand:HI 0 "register_operand" "=r")
2857         (zero_extend:HI (mem:QI
2858                           (plus:SI
2859                             (match_operand:SI 1 "register_operand" "r")
2860                             (match_operand:SI 2 "basereg_operand" "r")))))]
2861   "! TARGET_DISABLE_INDEXING"
2862   "{ldbx|ldb} %1(%2),%0"
2863   [(set_attr "type" "load")
2864    (set_attr "length" "4")])
2865
2866 (define_insn ""
2867   [(set (match_operand:QI 0 "register_operand" "=r")
2868         (mem:QI (plus:SI (match_operand:SI 1 "register_operand" "+r")
2869                          (match_operand:SI 2 "int5_operand" "L"))))
2870    (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
2871   ""
2872   "{ldbs|ldb},mb %2(%1),%0"
2873   [(set_attr "type" "load")
2874    (set_attr "length" "4")])
2875
2876 ; Now the same thing with zero extensions.
2877 (define_insn ""
2878   [(set (match_operand:SI 0 "register_operand" "=r")
2879         (zero_extend:SI (mem:QI (plus:SI
2880                                   (match_operand:SI 1 "register_operand" "+r")
2881                                   (match_operand:SI 2 "int5_operand" "L")))))
2882    (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
2883   ""
2884   "{ldbs|ldb},mb %2(%1),%0"
2885   [(set_attr "type" "load")
2886    (set_attr "length" "4")])
2887
2888 (define_insn ""
2889   [(set (match_operand:HI 0 "register_operand" "=r")
2890         (zero_extend:HI (mem:QI (plus:SI
2891                                   (match_operand:SI 1 "register_operand" "+r")
2892                                   (match_operand:SI 2 "int5_operand" "L")))))
2893    (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
2894   ""
2895   "{ldbs|ldb},mb %2(%1),%0"
2896   [(set_attr "type" "load")
2897    (set_attr "length" "4")])
2898
2899 (define_insn ""
2900   [(set (mem:QI (plus:SI (match_operand:SI 0 "register_operand" "+r")
2901                          (match_operand:SI 1 "int5_operand" "L")))
2902         (match_operand:QI 2 "reg_or_0_operand" "rM"))
2903    (set (match_dup 0)
2904         (plus:SI (match_dup 0) (match_dup 1)))]
2905   ""
2906   "{stbs|stb},mb %r2,%1(%0)"
2907   [(set_attr "type" "store")
2908    (set_attr "length" "4")])
2909
2910 ;; The definition of this insn does not really explain what it does,
2911 ;; but it should suffice
2912 ;; that anything generated as this insn will be recognized as one
2913 ;; and that it will not successfully combine with anything.
2914 (define_expand "movstrsi"
2915   [(parallel [(set (match_operand:BLK 0 "" "")
2916                    (match_operand:BLK 1 "" ""))
2917               (clobber (match_dup 7))
2918               (clobber (match_dup 8))
2919               (clobber (match_dup 4))
2920               (clobber (match_dup 5))
2921               (clobber (match_dup 6))
2922               (use (match_operand:SI 2 "arith_operand" ""))
2923               (use (match_operand:SI 3 "const_int_operand" ""))])]
2924   "!TARGET_64BIT"
2925   "
2926 {
2927   int size, align;
2928
2929   /* HP provides very fast block move library routine for the PA;
2930      this routine includes:
2931
2932         4x4 byte at a time block moves,
2933         1x4 byte at a time with alignment checked at runtime with
2934             attempts to align the source and destination as needed
2935         1x1 byte loop
2936
2937      With that in mind, here's the heuristics to try and guess when
2938      the inlined block move will be better than the library block
2939      move:
2940
2941         If the size isn't constant, then always use the library routines.
2942
2943         If the size is large in respect to the known alignment, then use
2944         the library routines.
2945
2946         If the size is small in repsect to the known alignment, then open
2947         code the copy (since that will lead to better scheduling).
2948
2949         Else use the block move pattern.   */
2950
2951   /* Undetermined size, use the library routine.  */
2952   if (GET_CODE (operands[2]) != CONST_INT)
2953     FAIL;
2954
2955   size = INTVAL (operands[2]);
2956   align = INTVAL (operands[3]);
2957   align = align > 4 ? 4 : align;
2958
2959   /* If size/alignment > 8 (eg size is large in respect to alignment),
2960      then use the library routines.  */
2961   if (size / align > 16)
2962     FAIL;
2963
2964   /* This does happen, but not often enough to worry much about.  */
2965   if (size / align < MOVE_RATIO)
2966     FAIL;
2967   
2968   /* Fall through means we're going to use our block move pattern.  */
2969   operands[0]
2970     = replace_equiv_address (operands[0],
2971                              copy_to_mode_reg (SImode, XEXP (operands[0], 0)));
2972   operands[1]
2973     = replace_equiv_address (operands[1],
2974                              copy_to_mode_reg (SImode, XEXP (operands[1], 0)));
2975   operands[4] = gen_reg_rtx (SImode);
2976   operands[5] = gen_reg_rtx (SImode);
2977   operands[6] = gen_reg_rtx (SImode);
2978   operands[7] = XEXP (operands[0], 0);
2979   operands[8] = XEXP (operands[1], 0);
2980 }")
2981
2982 ;; The operand constraints are written like this to support both compile-time
2983 ;; and run-time determined byte count.  If the count is run-time determined,
2984 ;; the register with the byte count is clobbered by the copying code, and
2985 ;; therefore it is forced to operand 2.  If the count is compile-time
2986 ;; determined, we need two scratch registers for the unrolled code.
2987 (define_insn "movstrsi_internal"
2988   [(set (mem:BLK (match_operand:SI 0 "register_operand" "+r,r"))
2989         (mem:BLK (match_operand:SI 1 "register_operand" "+r,r")))
2990    (clobber (match_dup 0))
2991    (clobber (match_dup 1))
2992    (clobber (match_operand:SI 2 "register_operand" "=r,r"))     ;loop cnt/tmp
2993    (clobber (match_operand:SI 3 "register_operand" "=&r,&r"))   ;item tmp
2994    (clobber (match_operand:SI 6 "register_operand" "=&r,&r"))   ;item tmp2
2995    (use (match_operand:SI 4 "arith_operand" "J,2"))      ;byte count
2996    (use (match_operand:SI 5 "const_int_operand" "n,n"))] ;alignment
2997   "!TARGET_64BIT"
2998   "* return output_block_move (operands, !which_alternative);"
2999   [(set_attr "type" "multi,multi")])
3000 \f
3001 ;; Floating point move insns
3002
3003 ;; This pattern forces (set (reg:DF ...) (const_double ...))
3004 ;; to be reloaded by putting the constant into memory when
3005 ;; reg is a floating point register.
3006 ;;
3007 ;; For integer registers we use ldil;ldo to set the appropriate
3008 ;; value.
3009 ;;
3010 ;; This must come before the movdf pattern, and it must be present
3011 ;; to handle obscure reloading cases.
3012 (define_insn ""
3013   [(set (match_operand:DF 0 "register_operand" "=?r,f")
3014         (match_operand:DF 1 "" "?F,m"))]
3015   "GET_CODE (operands[1]) == CONST_DOUBLE
3016    && operands[1] != CONST0_RTX (DFmode)
3017    && !TARGET_64BIT
3018    && ! TARGET_SOFT_FLOAT"
3019   "* return (which_alternative == 0 ? output_move_double (operands)
3020                                     : \"fldd%F1 %1,%0\");"
3021   [(set_attr "type" "move,fpload")
3022    (set_attr "length" "16,4")])
3023
3024 (define_expand "movdf"
3025   [(set (match_operand:DF 0 "general_operand" "")
3026         (match_operand:DF 1 "general_operand" ""))]
3027   ""
3028   "
3029 {
3030   if (GET_CODE (operands[1]) == CONST_DOUBLE && TARGET_64BIT)
3031       operands[1] = force_const_mem (DFmode, operands[1]);
3032
3033   if (emit_move_sequence (operands, DFmode, 0))
3034     DONE;
3035 }")
3036
3037 ;; Reloading an SImode or DImode value requires a scratch register if
3038 ;; going in to or out of float point registers.
3039
3040 (define_expand "reload_indf"
3041   [(set (match_operand:DF 0 "register_operand" "=Z")
3042         (match_operand:DF 1 "non_hard_reg_operand" ""))
3043    (clobber (match_operand:DF 2 "register_operand" "=&r"))]
3044   ""
3045   "
3046 {
3047   if (emit_move_sequence (operands, DFmode, operands[2]))
3048     DONE;
3049
3050   /* We don't want the clobber emitted, so handle this ourselves.  */
3051   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
3052   DONE;
3053 }")
3054
3055 (define_expand "reload_outdf" 
3056  [(set (match_operand:DF 0 "non_hard_reg_operand" "")
3057         (match_operand:DF 1  "register_operand" "Z"))
3058    (clobber (match_operand:DF 2 "register_operand" "=&r"))]
3059   ""
3060   "
3061 {
3062   if (emit_move_sequence (operands, DFmode, operands[2]))
3063     DONE;
3064
3065   /* We don't want the clobber emitted, so handle this ourselves.  */
3066   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
3067   DONE;
3068 }")
3069
3070 (define_insn ""
3071   [(set (match_operand:DF 0 "reg_or_nonsymb_mem_operand"
3072                           "=f,*r,RQ,?o,?Q,f,*r,*r")
3073         (match_operand:DF 1 "reg_or_0_or_nonsymb_mem_operand"
3074                           "fG,*rG,f,*r,*r,RQ,o,RQ"))]
3075   "(register_operand (operands[0], DFmode)
3076     || reg_or_0_operand (operands[1], DFmode))
3077    && ! (GET_CODE (operands[1]) == CONST_DOUBLE
3078          && GET_CODE (operands[0]) == MEM)
3079    && ! TARGET_64BIT
3080    && ! TARGET_SOFT_FLOAT"
3081   "*
3082 {
3083   if (FP_REG_P (operands[0]) || FP_REG_P (operands[1])
3084       || operands[1] == CONST0_RTX (DFmode))
3085     return output_fp_move_double (operands);
3086   return output_move_double (operands);
3087 }"
3088   [(set_attr "type" "fpalu,move,fpstore,store,store,fpload,load,load")
3089    (set_attr "length" "4,8,4,8,16,4,8,16")])
3090
3091 (define_insn ""
3092   [(set (match_operand:DF 0 "reg_or_nonsymb_mem_operand"
3093                           "=r,?o,?Q,r,r")
3094         (match_operand:DF 1 "reg_or_0_or_nonsymb_mem_operand"
3095                           "rG,r,r,o,Q"))]
3096   "(register_operand (operands[0], DFmode)
3097     || reg_or_0_operand (operands[1], DFmode))
3098    && ! TARGET_64BIT
3099    && TARGET_SOFT_FLOAT"
3100   "*
3101 {
3102   return output_move_double (operands);
3103 }"
3104   [(set_attr "type" "move,store,store,load,load")
3105    (set_attr "length" "8,8,16,8,16")])
3106
3107 (define_insn ""
3108   [(set (match_operand:DF 0 "reg_or_nonsymb_mem_operand"
3109                                 "=r,r,r,r,r,Q,*q,!f,f,*TR")
3110         (match_operand:DF 1 "move_operand"
3111                                 "r,J,N,K,RQ,rM,rM,!fM,*RT,f"))]
3112   "(register_operand (operands[0], DFmode)
3113     || reg_or_0_operand (operands[1], DFmode))
3114    && ! TARGET_SOFT_FLOAT && TARGET_64BIT"
3115   "@
3116    copy %1,%0
3117    ldi %1,%0
3118    ldil L'%1,%0
3119    depdi,z %z1,%0
3120    ldd%M1 %1,%0
3121    std%M0 %r1,%0
3122    mtsar %r1
3123    fcpy,dbl %f1,%0
3124    fldd%F1 %1,%0
3125    fstd%F0 %1,%0"
3126   [(set_attr "type" "move,move,move,shift,load,store,move,fpalu,fpload,fpstore")
3127    (set_attr "pa_combine_type" "addmove")
3128    (set_attr "length" "4,4,4,4,4,4,4,4,4,4")])
3129
3130 (define_insn ""
3131   [(set (match_operand:DF 0 "register_operand" "=fx")
3132         (mem:DF (plus:SI (match_operand:SI 1 "basereg_operand" "r")
3133                          (match_operand:SI 2 "register_operand" "r"))))]
3134   "! TARGET_DISABLE_INDEXING && ! TARGET_SOFT_FLOAT"
3135   "{flddx|fldd} %2(%1),%0"
3136   [(set_attr "type" "fpload")
3137    (set_attr "length" "4")])
3138
3139 (define_insn ""
3140   [(set (match_operand:DF 0 "register_operand" "=fx")
3141         (mem:DF (plus:SI (match_operand:SI 1 "register_operand" "r")
3142                          (match_operand:SI 2 "basereg_operand" "r"))))]
3143   "! TARGET_DISABLE_INDEXING && ! TARGET_SOFT_FLOAT"
3144   "{flddx|fldd} %1(%2),%0"
3145   [(set_attr "type" "fpload")
3146    (set_attr "length" "4")])
3147
3148 (define_insn ""
3149   [(set (mem:DF (plus:SI (match_operand:SI 1 "basereg_operand" "r")
3150                          (match_operand:SI 2 "register_operand" "r")))
3151         (match_operand:DF 0 "register_operand" "fx"))]
3152   "! TARGET_DISABLE_INDEXING && ! TARGET_SOFT_FLOAT"
3153   "{fstdx|fstd} %0,%2(%1)"
3154   [(set_attr "type" "fpstore")
3155    (set_attr "length" "4")])
3156
3157 (define_insn ""
3158   [(set (mem:DF (plus:SI (match_operand:SI 1 "register_operand" "r")
3159                          (match_operand:SI 2 "basereg_operand" "r")))
3160         (match_operand:DF 0 "register_operand" "fx"))]
3161   "! TARGET_DISABLE_INDEXING && ! TARGET_SOFT_FLOAT"
3162   "{fstdx|fstd} %0,%1(%2)"
3163   [(set_attr "type" "fpstore")
3164    (set_attr "length" "4")])
3165
3166 (define_expand "movdi"
3167   [(set (match_operand:DI 0 "reg_or_nonsymb_mem_operand" "")
3168         (match_operand:DI 1 "general_operand" ""))]
3169   ""
3170   "
3171 {
3172   if (GET_CODE (operands[1]) == CONST_DOUBLE && TARGET_64BIT)
3173       operands[1] = force_const_mem (DImode, operands[1]);
3174
3175   if (emit_move_sequence (operands, DImode, 0))
3176     DONE;
3177 }")
3178
3179 (define_expand "reload_indi"
3180   [(set (match_operand:DI 0 "register_operand" "=Z")
3181         (match_operand:DI 1 "non_hard_reg_operand" ""))
3182    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
3183   ""
3184   "
3185 {
3186   if (emit_move_sequence (operands, DImode, operands[2]))
3187     DONE;
3188
3189   /* We don't want the clobber emitted, so handle this ourselves.  */
3190   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
3191   DONE;
3192 }")
3193
3194 (define_expand "reload_outdi"
3195   [(set (match_operand:DI 0 "non_hard_reg_operand" "")
3196         (match_operand:DI 1 "register_operand" "Z"))
3197    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
3198   ""
3199   "
3200 {
3201   if (emit_move_sequence (operands, DImode, operands[2]))
3202     DONE;
3203
3204   /* We don't want the clobber emitted, so handle this ourselves.  */
3205   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
3206   DONE;
3207 }")
3208
3209 (define_insn ""
3210   [(set (match_operand:DI 0 "register_operand" "=r")
3211         (high:DI (match_operand 1 "" "")))]
3212   "!TARGET_64BIT"
3213   "*
3214 {
3215   rtx op0 = operands[0];
3216   rtx op1 = operands[1];
3217
3218   if (GET_CODE (op1) == CONST_INT)
3219     {
3220       operands[0] = operand_subword (op0, 1, 0, DImode);
3221       output_asm_insn (\"ldil L'%1,%0\", operands);
3222
3223       operands[0] = operand_subword (op0, 0, 0, DImode);
3224       if (INTVAL (op1) < 0)
3225         output_asm_insn (\"ldi -1,%0\", operands);
3226       else
3227         output_asm_insn (\"ldi 0,%0\", operands);
3228       return \"\";
3229     }
3230   else if (GET_CODE (op1) == CONST_DOUBLE)
3231     {
3232       operands[0] = operand_subword (op0, 1, 0, DImode);
3233       operands[1] = GEN_INT (CONST_DOUBLE_LOW (op1));
3234       output_asm_insn (\"ldil L'%1,%0\", operands);
3235
3236       operands[0] = operand_subword (op0, 0, 0, DImode);
3237       operands[1] = GEN_INT (CONST_DOUBLE_HIGH (op1));
3238       output_asm_insn (singlemove_string (operands), operands);
3239       return \"\";
3240     }
3241   else
3242     abort ();
3243 }"
3244   [(set_attr "type" "move")
3245    (set_attr "length" "8")])
3246
3247 (define_insn ""
3248   [(set (match_operand:DI 0 "reg_or_nonsymb_mem_operand"
3249                           "=r,o,Q,r,r,r,f,f,*TR")
3250         (match_operand:DI 1 "general_operand"
3251                           "rM,r,r,o*R,Q,i,fM,*TR,f"))]
3252   "(register_operand (operands[0], DImode)
3253     || reg_or_0_operand (operands[1], DImode))
3254    && ! TARGET_64BIT
3255    && ! TARGET_SOFT_FLOAT"
3256   "*
3257 {
3258   if (FP_REG_P (operands[0]) || FP_REG_P (operands[1])
3259       || (operands[1] == CONST0_RTX (DImode)))
3260     return output_fp_move_double (operands);
3261   return output_move_double (operands);
3262 }"
3263   [(set_attr "type" "move,store,store,load,load,multi,fpalu,fpload,fpstore")
3264    (set_attr "length" "8,8,16,8,16,16,4,4,4")])
3265
3266 (define_insn ""
3267   [(set (match_operand:DI 0 "reg_or_nonsymb_mem_operand"
3268                                 "=r,r,r,r,r,r,Q,*q,!f,f,*TR")
3269         (match_operand:DI 1 "move_operand"
3270                                 "A,r,J,N,K,RQ,rM,rM,!fM,*RT,f"))]
3271   "(register_operand (operands[0], DImode)
3272     || reg_or_0_operand (operands[1], DImode))
3273    && ! TARGET_SOFT_FLOAT && TARGET_64BIT"
3274   "@
3275    ldd RT'%A1,%0
3276    copy %1,%0
3277    ldi %1,%0
3278    ldil L'%1,%0
3279    depdi,z %z1,%0
3280    ldd%M1 %1,%0
3281    std%M0 %r1,%0
3282    mtsar %r1
3283    fcpy,dbl %f1,%0
3284    fldd%F1 %1,%0
3285    fstd%F0 %1,%0"
3286   [(set_attr "type" "load,move,move,move,shift,load,store,move,fpalu,fpload,fpstore")
3287    (set_attr "pa_combine_type" "addmove")
3288    (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4")])
3289
3290 (define_insn ""
3291   [(set (match_operand:DI 0 "reg_or_nonsymb_mem_operand"
3292                           "=r,o,Q,r,r,r")
3293         (match_operand:DI 1 "general_operand"
3294                           "rM,r,r,o,Q,i"))]
3295   "(register_operand (operands[0], DImode)
3296     || reg_or_0_operand (operands[1], DImode))
3297    && ! TARGET_64BIT
3298    && TARGET_SOFT_FLOAT"
3299   "*
3300 {
3301   return output_move_double (operands);
3302 }"
3303   [(set_attr "type" "move,store,store,load,load,multi")
3304    (set_attr "length" "8,8,16,8,16,16")])
3305
3306 (define_insn ""
3307   [(set (match_operand:DI 0 "register_operand" "=r,&r")
3308         (lo_sum:DI (match_operand:DI 1 "register_operand" "0,r")
3309                    (match_operand:DI 2 "immediate_operand" "i,i")))]
3310   "!TARGET_64BIT"
3311   "*
3312 {
3313   /* Don't output a 64 bit constant, since we can't trust the assembler to
3314      handle it correctly.  */
3315   if (GET_CODE (operands[2]) == CONST_DOUBLE)
3316     operands[2] = GEN_INT (CONST_DOUBLE_LOW (operands[2]));
3317   if (which_alternative == 1)
3318     output_asm_insn (\"copy %1,%0\", operands);
3319   return \"ldo R'%G2(%R1),%R0\";
3320 }"
3321   [(set_attr "type" "move,move")
3322    (set_attr "length" "4,8")])
3323
3324 ;; This pattern forces (set (reg:SF ...) (const_double ...))
3325 ;; to be reloaded by putting the constant into memory when
3326 ;; reg is a floating point register.
3327 ;;
3328 ;; For integer registers we use ldil;ldo to set the appropriate
3329 ;; value.
3330 ;;
3331 ;; This must come before the movsf pattern, and it must be present
3332 ;; to handle obscure reloading cases.
3333 (define_insn ""
3334   [(set (match_operand:SF 0 "register_operand" "=?r,f")
3335         (match_operand:SF 1 "" "?F,m"))]
3336   "GET_CODE (operands[1]) == CONST_DOUBLE
3337    && operands[1] != CONST0_RTX (SFmode)
3338    && ! TARGET_SOFT_FLOAT"
3339   "* return (which_alternative == 0 ? singlemove_string (operands)
3340                                     : \" fldw%F1 %1,%0\");"
3341   [(set_attr "type" "move,fpload")
3342    (set_attr "length" "8,4")])
3343
3344 (define_expand "movsf"
3345   [(set (match_operand:SF 0 "general_operand" "")
3346         (match_operand:SF 1 "general_operand" ""))]
3347   ""
3348   "
3349 {
3350   if (emit_move_sequence (operands, SFmode, 0))
3351     DONE;
3352 }")
3353
3354 ;; Reloading an SImode or DImode value requires a scratch register if
3355 ;; going in to or out of float point registers.
3356
3357 (define_expand "reload_insf"
3358   [(set (match_operand:SF 0 "register_operand" "=Z")
3359         (match_operand:SF 1 "non_hard_reg_operand" ""))
3360    (clobber (match_operand:SF 2 "register_operand" "=&r"))]
3361   ""
3362   "
3363 {
3364   if (emit_move_sequence (operands, SFmode, operands[2]))
3365     DONE;
3366
3367   /* We don't want the clobber emitted, so handle this ourselves.  */
3368   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
3369   DONE;
3370 }")
3371
3372 (define_expand "reload_outsf"
3373   [(set (match_operand:SF 0 "non_hard_reg_operand" "")
3374         (match_operand:SF 1  "register_operand" "Z"))
3375    (clobber (match_operand:SF 2 "register_operand" "=&r"))]
3376   ""
3377   "
3378 {
3379   if (emit_move_sequence (operands, SFmode, operands[2]))
3380     DONE;
3381
3382   /* We don't want the clobber emitted, so handle this ourselves.  */
3383   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
3384   DONE;
3385 }")
3386
3387 (define_insn ""
3388   [(set (match_operand:SF 0 "reg_or_nonsymb_mem_operand"
3389                           "=f,r,f,r,RQ,Q")
3390         (match_operand:SF 1 "reg_or_0_or_nonsymb_mem_operand"
3391                           "fG,rG,RQ,RQ,f,rG"))]
3392   "(register_operand (operands[0], SFmode)
3393     || reg_or_0_operand (operands[1], SFmode))
3394    && ! TARGET_SOFT_FLOAT"
3395   "@
3396    fcpy,sgl %f1,%0
3397    copy %r1,%0
3398    fldw%F1 %1,%0
3399    ldw%M1 %1,%0
3400    fstw%F0 %r1,%0
3401    stw%M0 %r1,%0"
3402   [(set_attr "type" "fpalu,move,fpload,load,fpstore,store")
3403    (set_attr "pa_combine_type" "addmove")
3404    (set_attr "length" "4,4,4,4,4,4")])
3405
3406 (define_insn ""
3407   [(set (match_operand:SF 0 "reg_or_nonsymb_mem_operand"
3408                           "=r,r,Q")
3409         (match_operand:SF 1 "reg_or_0_or_nonsymb_mem_operand"
3410                           "rG,RQ,rG"))]
3411   "(register_operand (operands[0], SFmode)
3412     || reg_or_0_operand (operands[1], SFmode))
3413    && TARGET_SOFT_FLOAT"
3414   "@
3415    copy %r1,%0
3416    ldw%M1 %1,%0
3417    stw%M0 %r1,%0"
3418   [(set_attr "type" "move,load,store")
3419    (set_attr "pa_combine_type" "addmove")
3420    (set_attr "length" "4,4,4")])
3421
3422 (define_insn ""
3423   [(set (match_operand:SF 0 "register_operand" "=fx")
3424         (mem:SF (plus:SI (match_operand:SI 1 "basereg_operand" "r")
3425                          (match_operand:SI 2 "register_operand" "r"))))]
3426   "! TARGET_DISABLE_INDEXING && ! TARGET_SOFT_FLOAT"
3427   "{fldwx|fldw} %2(%1),%0"
3428   [(set_attr "type" "fpload")
3429    (set_attr "length" "4")])
3430
3431 (define_insn ""
3432   [(set (match_operand:SF 0 "register_operand" "=fx")
3433         (mem:SF (plus:SI (match_operand:SI 1 "register_operand" "r")
3434                          (match_operand:SI 2 "basereg_operand" "r"))))]
3435   "! TARGET_DISABLE_INDEXING && ! TARGET_SOFT_FLOAT"
3436   "{fldwx|fldw} %1(%2),%0"
3437   [(set_attr "type" "fpload")
3438    (set_attr "length" "4")])
3439
3440 (define_insn ""
3441   [(set (mem:SF (plus:SI (match_operand:SI 1 "basereg_operand" "r")
3442                          (match_operand:SI 2 "register_operand" "r")))
3443       (match_operand:SF 0 "register_operand" "fx"))]
3444   "! TARGET_DISABLE_INDEXING && ! TARGET_SOFT_FLOAT"
3445   "{fstwx|fstw} %0,%2(%1)"
3446   [(set_attr "type" "fpstore")
3447    (set_attr "length" "4")])
3448 \f
3449 (define_insn ""
3450   [(set (mem:SF (plus:SI (match_operand:SI 1 "register_operand" "r")
3451                          (match_operand:SI 2 "basereg_operand" "r")))
3452       (match_operand:SF 0 "register_operand" "fx"))]
3453   "! TARGET_DISABLE_INDEXING && ! TARGET_SOFT_FLOAT"
3454   "{fstwx|fstw} %0,%1(%2)"
3455   [(set_attr "type" "fpstore")
3456    (set_attr "length" "4")])
3457 \f
3458
3459 ;;- zero extension instructions
3460 ;; We have define_expand for zero extension patterns to make sure the
3461 ;; operands get loaded into registers.  The define_insns accept
3462 ;; memory operands.  This gives us better overall code than just
3463 ;; having a pattern that does or does not accept memory operands.
3464
3465 (define_expand "zero_extendhisi2"
3466   [(set (match_operand:SI 0 "register_operand" "")
3467         (zero_extend:SI
3468          (match_operand:HI 1 "register_operand" "")))]
3469   ""
3470   "")
3471
3472 (define_insn ""
3473   [(set (match_operand:SI 0 "register_operand" "=r,r")
3474         (zero_extend:SI
3475          (match_operand:HI 1 "move_operand" "r,RQ")))]
3476   "GET_CODE (operands[1]) != CONST_INT"
3477   "@
3478    {extru|extrw,u} %1,31,16,%0
3479    ldh%M1 %1,%0"
3480   [(set_attr "type" "shift,load")
3481    (set_attr "length" "4,4")])
3482
3483 (define_expand "zero_extendqihi2"
3484   [(set (match_operand:HI 0 "register_operand" "")
3485         (zero_extend:HI
3486          (match_operand:QI 1 "register_operand" "")))]
3487   ""
3488   "")
3489
3490 (define_insn ""
3491   [(set (match_operand:HI 0 "register_operand" "=r,r")
3492         (zero_extend:HI
3493          (match_operand:QI 1 "move_operand" "r,RQ")))]
3494   "GET_CODE (operands[1]) != CONST_INT"
3495   "@
3496    {extru|extrw,u} %1,31,8,%0
3497    ldb%M1 %1,%0"
3498   [(set_attr "type" "shift,load")
3499    (set_attr "length" "4,4")])
3500
3501 (define_expand "zero_extendqisi2"
3502   [(set (match_operand:SI 0 "register_operand" "")
3503         (zero_extend:SI
3504          (match_operand:QI 1 "register_operand" "")))]
3505   ""
3506   "")
3507
3508 (define_insn ""
3509   [(set (match_operand:SI 0 "register_operand" "=r,r")
3510         (zero_extend:SI
3511          (match_operand:QI 1 "move_operand" "r,RQ")))]
3512   "GET_CODE (operands[1]) != CONST_INT"
3513   "@
3514    {extru|extrw,u} %1,31,8,%0
3515    ldb%M1 %1,%0"
3516   [(set_attr "type" "shift,load")
3517    (set_attr "length" "4,4")])
3518
3519 (define_insn "zero_extendqidi2"
3520   [(set (match_operand:DI 0 "register_operand" "=r")
3521         (zero_extend:DI (match_operand:QI 1 "register_operand" "r")))]
3522   "TARGET_64BIT"
3523   "extrd,u %1,63,8,%0"
3524   [(set_attr "type" "shift") 
3525   (set_attr "length" "4")])
3526
3527 (define_insn "zero_extendhidi2"
3528   [(set (match_operand:DI 0 "register_operand" "=r")
3529         (zero_extend:DI (match_operand:HI 1 "register_operand" "r")))]
3530   "TARGET_64BIT"
3531   "extrd,u %1,63,16,%0"
3532   [(set_attr "type" "shift") 
3533   (set_attr "length" "4")])
3534
3535 (define_insn "zero_extendsidi2"
3536   [(set (match_operand:DI 0 "register_operand" "=r")
3537         (zero_extend:DI (match_operand:SI 1 "register_operand" "r")))]
3538   "TARGET_64BIT"
3539   "extrd,u %1,63,32,%0"
3540   [(set_attr "type" "shift") 
3541   (set_attr "length" "4")])
3542
3543 ;;- sign extension instructions
3544
3545 (define_insn "extendhisi2"
3546   [(set (match_operand:SI 0 "register_operand" "=r")
3547         (sign_extend:SI (match_operand:HI 1 "register_operand" "r")))]
3548   ""
3549   "{extrs|extrw,s} %1,31,16,%0"
3550   [(set_attr "type" "shift")
3551    (set_attr "length" "4")])
3552
3553 (define_insn "extendqihi2"
3554   [(set (match_operand:HI 0 "register_operand" "=r")
3555         (sign_extend:HI (match_operand:QI 1 "register_operand" "r")))]
3556   ""
3557   "{extrs|extrw,s} %1,31,8,%0"
3558   [(set_attr "type" "shift") 
3559   (set_attr "length" "4")])
3560
3561 (define_insn "extendqisi2"
3562   [(set (match_operand:SI 0 "register_operand" "=r")
3563         (sign_extend:SI (match_operand:QI 1 "register_operand" "r")))]
3564   ""
3565   "{extrs|extrw,s} %1,31,8,%0"
3566   [(set_attr "type" "shift")
3567    (set_attr "length" "4")])
3568
3569 (define_insn "extendqidi2"
3570   [(set (match_operand:DI 0 "register_operand" "=r")
3571         (sign_extend:DI (match_operand:QI 1 "register_operand" "r")))]
3572   "TARGET_64BIT"
3573   "extrd,s %1,63,8,%0"
3574   [(set_attr "type" "shift") 
3575   (set_attr "length" "4")])
3576
3577 (define_insn "extendhidi2"
3578   [(set (match_operand:DI 0 "register_operand" "=r")
3579         (sign_extend:DI (match_operand:HI 1 "register_operand" "r")))]
3580   "TARGET_64BIT"
3581   "extrd,s %1,63,16,%0"
3582   [(set_attr "type" "shift") 
3583   (set_attr "length" "4")])
3584
3585 (define_insn "extendsidi2"
3586   [(set (match_operand:DI 0 "register_operand" "=r")
3587         (sign_extend:DI (match_operand:SI 1 "register_operand" "r")))]
3588   "TARGET_64BIT"
3589   "extrd,s %1,63,32,%0"
3590   [(set_attr "type" "shift") 
3591   (set_attr "length" "4")])
3592
3593 \f
3594 ;; Conversions between float and double.
3595
3596 (define_insn "extendsfdf2"
3597   [(set (match_operand:DF 0 "register_operand" "=f")
3598         (float_extend:DF
3599          (match_operand:SF 1 "register_operand" "f")))]
3600   "! TARGET_SOFT_FLOAT"
3601   "{fcnvff|fcnv},sgl,dbl %1,%0"
3602   [(set_attr "type" "fpalu")
3603    (set_attr "length" "4")])
3604
3605 (define_insn "truncdfsf2"
3606   [(set (match_operand:SF 0 "register_operand" "=f")
3607         (float_truncate:SF
3608          (match_operand:DF 1 "register_operand" "f")))]
3609   "! TARGET_SOFT_FLOAT"
3610   "{fcnvff|fcnv},dbl,sgl %1,%0"
3611   [(set_attr "type" "fpalu")
3612    (set_attr "length" "4")])
3613
3614 ;; Conversion between fixed point and floating point.
3615 ;; Note that among the fix-to-float insns
3616 ;; the ones that start with SImode come first.
3617 ;; That is so that an operand that is a CONST_INT
3618 ;; (and therefore lacks a specific machine mode).
3619 ;; will be recognized as SImode (which is always valid)
3620 ;; rather than as QImode or HImode.
3621
3622 ;; This pattern forces (set (reg:SF ...) (float:SF (const_int ...)))
3623 ;; to be reloaded by putting the constant into memory.
3624 ;; It must come before the more general floatsisf2 pattern.
3625 (define_insn ""
3626   [(set (match_operand:SF 0 "register_operand" "=f")
3627         (float:SF (match_operand:SI 1 "const_int_operand" "m")))]
3628   "! TARGET_SOFT_FLOAT"
3629   "fldw%F1 %1,%0\;{fcnvxf,sgl,sgl|fcnv,w,sgl} %0,%0"
3630   [(set_attr "type" "fpalu")
3631    (set_attr "length" "8")])
3632
3633 (define_insn "floatsisf2"
3634   [(set (match_operand:SF 0 "register_operand" "=f")
3635         (float:SF (match_operand:SI 1 "register_operand" "f")))]
3636   "! TARGET_SOFT_FLOAT"
3637   "{fcnvxf,sgl,sgl|fcnv,w,sgl} %1,%0"
3638   [(set_attr "type" "fpalu")
3639    (set_attr "length" "4")])
3640
3641 ;; This pattern forces (set (reg:DF ...) (float:DF (const_int ...)))
3642 ;; to be reloaded by putting the constant into memory.
3643 ;; It must come before the more general floatsidf2 pattern.
3644 (define_insn ""
3645   [(set (match_operand:DF 0 "register_operand" "=f")
3646         (float:DF (match_operand:SI 1 "const_int_operand" "m")))]
3647   "! TARGET_SOFT_FLOAT"
3648   "fldw%F1 %1,%0\;{fcnvxf,sgl,dbl|fcnv,w,dbl} %0,%0"
3649   [(set_attr "type" "fpalu")
3650    (set_attr "length" "8")])
3651
3652 (define_insn "floatsidf2"
3653   [(set (match_operand:DF 0 "register_operand" "=f")
3654         (float:DF (match_operand:SI 1 "register_operand" "f")))]
3655   "! TARGET_SOFT_FLOAT"
3656   "{fcnvxf,sgl,dbl|fcnv,w,dbl} %1,%0"
3657   [(set_attr "type" "fpalu")
3658    (set_attr "length" "4")])
3659
3660 (define_expand "floatunssisf2"
3661   [(set (subreg:SI (match_dup 2) 4)
3662         (match_operand:SI 1 "register_operand" ""))
3663    (set (subreg:SI (match_dup 2) 0)
3664         (const_int 0))
3665    (set (match_operand:SF 0 "register_operand" "")
3666         (float:SF (match_dup 2)))]
3667   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
3668   "
3669 {
3670   if (TARGET_PA_20)
3671     {
3672       emit_insn (gen_floatunssisf2_pa20 (operands[0], operands[1]));
3673       DONE;
3674     }
3675   operands[2] = gen_reg_rtx (DImode);
3676 }")
3677
3678 (define_expand "floatunssidf2"
3679   [(set (subreg:SI (match_dup 2) 4)
3680         (match_operand:SI 1 "register_operand" ""))
3681    (set (subreg:SI (match_dup 2) 0)
3682         (const_int 0))
3683    (set (match_operand:DF 0 "register_operand" "")
3684         (float:DF (match_dup 2)))]
3685   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
3686   "
3687 {
3688   if (TARGET_PA_20)
3689     {
3690       emit_insn (gen_floatunssidf2_pa20 (operands[0], operands[1]));
3691       DONE;
3692     }
3693   operands[2] = gen_reg_rtx (DImode);
3694 }")
3695
3696 (define_insn "floatdisf2"
3697   [(set (match_operand:SF 0 "register_operand" "=f")
3698         (float:SF (match_operand:DI 1 "register_operand" "f")))]
3699   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
3700   "{fcnvxf,dbl,sgl|fcnv,dw,sgl} %1,%0"
3701   [(set_attr "type" "fpalu")
3702    (set_attr "length" "4")])
3703
3704 (define_insn "floatdidf2"
3705   [(set (match_operand:DF 0 "register_operand" "=f")
3706         (float:DF (match_operand:DI 1 "register_operand" "f")))]
3707   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
3708   "{fcnvxf,dbl,dbl|fcnv,dw,dbl} %1,%0"
3709   [(set_attr "type" "fpalu")
3710    (set_attr "length" "4")])
3711
3712 ;; Convert a float to an actual integer.
3713 ;; Truncation is performed as part of the conversion.
3714
3715 (define_insn "fix_truncsfsi2"
3716   [(set (match_operand:SI 0 "register_operand" "=f")
3717         (fix:SI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
3718   "! TARGET_SOFT_FLOAT"
3719   "{fcnvfxt,sgl,sgl|fcnv,t,sgl,w} %1,%0"
3720   [(set_attr "type" "fpalu")
3721    (set_attr "length" "4")])
3722
3723 (define_insn "fix_truncdfsi2"
3724   [(set (match_operand:SI 0 "register_operand" "=f")
3725         (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
3726   "! TARGET_SOFT_FLOAT"
3727   "{fcnvfxt,dbl,sgl|fcnv,t,dbl,w} %1,%0"
3728   [(set_attr "type" "fpalu")
3729    (set_attr "length" "4")])
3730
3731 (define_insn "fix_truncsfdi2"
3732   [(set (match_operand:DI 0 "register_operand" "=f")
3733         (fix:DI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
3734   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
3735   "{fcnvfxt,sgl,dbl|fcnv,t,sgl,dw} %1,%0"
3736   [(set_attr "type" "fpalu")
3737    (set_attr "length" "4")])
3738
3739 (define_insn "fix_truncdfdi2"
3740   [(set (match_operand:DI 0 "register_operand" "=f")
3741         (fix:DI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
3742   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
3743   "{fcnvfxt,dbl,dbl|fcnv,t,dbl,dw} %1,%0"
3744   [(set_attr "type" "fpalu")
3745    (set_attr "length" "4")])
3746
3747 (define_insn "floatunssidf2_pa20"
3748   [(set (match_operand:DF 0 "register_operand" "=f")
3749         (unsigned_float:DF (match_operand:SI 1 "register_operand" "f")))]
3750   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
3751   "fcnv,uw,dbl %1,%0"
3752   [(set_attr "type" "fpalu")
3753    (set_attr "length" "4")])
3754
3755 (define_insn "floatunssisf2_pa20"
3756   [(set (match_operand:SF 0 "register_operand" "=f")
3757         (unsigned_float:SF (match_operand:SI 1 "register_operand" "f")))]
3758   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
3759   "fcnv,uw,sgl %1,%0"
3760   [(set_attr "type" "fpalu")
3761    (set_attr "length" "4")])
3762
3763 (define_insn "floatunsdisf2"
3764   [(set (match_operand:SF 0 "register_operand" "=f")
3765         (unsigned_float:SF (match_operand:DI 1 "register_operand" "f")))]
3766   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
3767   "fcnv,udw,sgl %1,%0"
3768   [(set_attr "type" "fpalu")
3769    (set_attr "length" "4")])
3770
3771 (define_insn "floatunsdidf2"
3772   [(set (match_operand:DF 0 "register_operand" "=f")
3773         (unsigned_float:DF (match_operand:DI 1 "register_operand" "f")))]
3774   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
3775   "fcnv,udw,dbl %1,%0"
3776   [(set_attr "type" "fpalu")
3777    (set_attr "length" "4")])
3778
3779 (define_insn "fixuns_truncsfsi2"
3780   [(set (match_operand:SI 0 "register_operand" "=f")
3781         (unsigned_fix:SI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
3782   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
3783   "fcnv,t,sgl,uw %1,%0"
3784   [(set_attr "type" "fpalu")
3785    (set_attr "length" "4")])
3786
3787 (define_insn "fixuns_truncdfsi2"
3788   [(set (match_operand:SI 0 "register_operand" "=f")
3789         (unsigned_fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
3790   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
3791   "fcnv,t,dbl,uw %1,%0"
3792   [(set_attr "type" "fpalu")
3793    (set_attr "length" "4")])
3794
3795 (define_insn "fixuns_truncsfdi2"
3796   [(set (match_operand:DI 0 "register_operand" "=f")
3797         (unsigned_fix:DI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
3798   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
3799   "fcnv,t,sgl,udw %1,%0"
3800   [(set_attr "type" "fpalu")
3801    (set_attr "length" "4")])
3802
3803 (define_insn "fixuns_truncdfdi2"
3804   [(set (match_operand:DI 0 "register_operand" "=f")
3805         (unsigned_fix:DI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
3806   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
3807   "fcnv,t,dbl,udw %1,%0"
3808   [(set_attr "type" "fpalu")
3809    (set_attr "length" "4")])
3810 \f
3811 ;;- arithmetic instructions
3812
3813 (define_expand "adddi3"
3814   [(set (match_operand:DI 0 "register_operand" "")
3815         (plus:DI (match_operand:DI 1 "register_operand" "")
3816                  (match_operand:DI 2 "arith_operand" "")))]
3817   ""
3818   "")
3819
3820 ;; We allow arith_operand for operands2, even though strictly speaking it
3821 ;; we would prefer to us arith11_operand since that's what the hardware
3822 ;; can actually support.
3823 ;;
3824 ;; But the price of the extra reload in that case is worth the simplicity
3825 ;; we get by allowing a trivial adddi3 expander to be used for both
3826 ;; PA64 and PA32.
3827
3828 (define_insn ""
3829   [(set (match_operand:DI 0 "register_operand" "=r")
3830         (plus:DI (match_operand:DI 1 "register_operand" "%r")
3831                  (match_operand:DI 2 "arith_operand" "rI")))]
3832   "!TARGET_64BIT"
3833   "*
3834 {
3835   if (GET_CODE (operands[2]) == CONST_INT)
3836     {
3837       if (INTVAL (operands[2]) >= 0)
3838         return \"addi %2,%R1,%R0\;{addc|add,c} %1,%%r0,%0\";
3839       else
3840         return \"addi %2,%R1,%R0\;{subb|sub,b} %1,%%r0,%0\";
3841     }
3842   else
3843     return \"add %R2,%R1,%R0\;{addc|add,c} %2,%1,%0\";
3844 }"
3845   [(set_attr "type" "binary")
3846    (set_attr "length" "8")])
3847
3848 (define_insn ""
3849   [(set (match_operand:DI 0 "register_operand" "=r,r")
3850         (plus:DI (match_operand:DI 1 "register_operand" "%r,r")
3851                  (match_operand:DI 2 "arith_operand" "r,J")))]
3852   "TARGET_64BIT"
3853   "@
3854    {addl|add,l} %1,%2,%0
3855    ldo %2(%1),%0"
3856   [(set_attr "type" "binary,binary")
3857    (set_attr "pa_combine_type" "addmove")
3858    (set_attr "length" "4,4")])
3859
3860 (define_insn ""
3861   [(set (match_operand:DI 0 "register_operand" "=r")
3862         (plus:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
3863                  (match_operand:DI 2 "register_operand" "r")))]
3864   "TARGET_64BIT"
3865   "uaddcm %2,%1,%0"
3866   [(set_attr "type" "binary")
3867    (set_attr "length" "4")])
3868
3869 (define_insn ""
3870   [(set (match_operand:SI 0 "register_operand" "=r")
3871         (plus:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
3872                  (match_operand:SI 2 "register_operand" "r")))]
3873   ""
3874   "uaddcm %2,%1,%0"
3875   [(set_attr "type" "binary")
3876    (set_attr "length" "4")])
3877
3878 ;; define_splits to optimize cases of adding a constant integer
3879 ;; to a register when the constant does not fit in 14 bits.  */
3880 (define_split
3881   [(set (match_operand:SI 0 "register_operand" "")
3882         (plus:SI (match_operand:SI 1 "register_operand" "")
3883                  (match_operand:SI 2 "const_int_operand" "")))
3884    (clobber (match_operand:SI 4 "register_operand" ""))]
3885   "! cint_ok_for_move (INTVAL (operands[2]))
3886    && VAL_14_BITS_P (INTVAL (operands[2]) >> 1)"
3887   [(set (match_dup 4) (plus:SI (match_dup 1) (match_dup 2)))
3888    (set (match_dup 0) (plus:SI (match_dup 4) (match_dup 3)))]
3889   "
3890 {
3891   int val = INTVAL (operands[2]);
3892   int low = (val < 0) ? -0x2000 : 0x1fff;
3893   int rest = val - low;
3894
3895   operands[2] = GEN_INT (rest);
3896   operands[3] = GEN_INT (low);
3897 }")
3898
3899 (define_split
3900   [(set (match_operand:SI 0 "register_operand" "")
3901         (plus:SI (match_operand:SI 1 "register_operand" "")
3902                  (match_operand:SI 2 "const_int_operand" "")))
3903    (clobber (match_operand:SI 4 "register_operand" ""))]
3904   "! cint_ok_for_move (INTVAL (operands[2]))"
3905   [(set (match_dup 4) (match_dup 2))
3906    (set (match_dup 0) (plus:SI (mult:SI (match_dup 4) (match_dup 3))
3907                                (match_dup 1)))]
3908   "
3909 {
3910   HOST_WIDE_INT intval = INTVAL (operands[2]);
3911
3912   /* Try dividing the constant by 2, then 4, and finally 8 to see
3913      if we can get a constant which can be loaded into a register
3914      in a single instruction (cint_ok_for_move). 
3915
3916      If that fails, try to negate the constant and subtract it
3917      from our input operand.  */
3918   if (intval % 2 == 0 && cint_ok_for_move (intval / 2))
3919     {
3920       operands[2] = GEN_INT (intval / 2);
3921       operands[3] = GEN_INT (2);
3922     }
3923   else if (intval % 4 == 0 && cint_ok_for_move (intval / 4))
3924     {
3925       operands[2] = GEN_INT (intval / 4);
3926       operands[3] = GEN_INT (4);
3927     }
3928   else if (intval % 8 == 0 && cint_ok_for_move (intval / 8))
3929     {
3930       operands[2] = GEN_INT (intval / 8);
3931       operands[3] = GEN_INT (8);
3932     }
3933   else if (cint_ok_for_move (-intval))
3934     {
3935       emit_insn (gen_rtx_SET (VOIDmode, operands[4], GEN_INT (-intval)));
3936       emit_insn (gen_subsi3 (operands[0], operands[1], operands[4]));
3937       DONE;
3938     }
3939   else
3940     FAIL;
3941 }")
3942
3943 (define_insn "addsi3"
3944   [(set (match_operand:SI 0 "register_operand" "=r,r")
3945         (plus:SI (match_operand:SI 1 "register_operand" "%r,r")
3946                  (match_operand:SI 2 "arith_operand" "r,J")))]
3947   ""
3948   "@
3949    {addl|add,l} %1,%2,%0
3950    ldo %2(%1),%0"
3951   [(set_attr "type" "binary,binary")
3952    (set_attr "pa_combine_type" "addmove")
3953    (set_attr "length" "4,4")])
3954
3955 (define_expand "subdi3"
3956   [(set (match_operand:DI 0 "register_operand" "")
3957         (minus:DI (match_operand:DI 1 "register_operand" "")
3958                   (match_operand:DI 2 "register_operand" "")))]
3959   ""
3960   "")
3961
3962 (define_insn ""
3963   [(set (match_operand:DI 0 "register_operand" "=r")
3964         (minus:DI (match_operand:DI 1 "register_operand" "r")
3965                   (match_operand:DI 2 "register_operand" "r")))]
3966   "!TARGET_64BIT"
3967   "sub %R1,%R2,%R0\;{subb|sub,b} %1,%2,%0"
3968   [(set_attr "type" "binary")
3969   (set_attr "length" "8")])
3970
3971 (define_insn ""
3972   [(set (match_operand:DI 0 "register_operand" "=r,r,q")
3973         (minus:DI (match_operand:DI 1 "arith11_operand" "r,I,U")
3974                   (match_operand:DI 2 "register_operand" "r,r,r")))]
3975   "TARGET_64BIT"
3976   "@
3977    sub %1,%2,%0
3978    subi %1,%2,%0
3979    mtsarcm %2"
3980   [(set_attr "type" "binary,binary,move")
3981   (set_attr "length" "4,4,4")])
3982
3983 (define_expand "subsi3"
3984   [(set (match_operand:SI 0 "register_operand" "")
3985         (minus:SI (match_operand:SI 1 "arith11_operand" "")
3986                   (match_operand:SI 2 "register_operand" "")))]
3987   ""
3988   "")
3989
3990 (define_insn ""
3991   [(set (match_operand:SI 0 "register_operand" "=r,r")
3992         (minus:SI (match_operand:SI 1 "arith11_operand" "r,I")
3993                   (match_operand:SI 2 "register_operand" "r,r")))]
3994   "!TARGET_PA_20"
3995   "@
3996    sub %1,%2,%0
3997    subi %1,%2,%0"
3998   [(set_attr "type" "binary,binary")
3999    (set_attr "length" "4,4")])
4000
4001 (define_insn ""
4002   [(set (match_operand:SI 0 "register_operand" "=r,r,q")
4003         (minus:SI (match_operand:SI 1 "arith11_operand" "r,I,S")
4004                   (match_operand:SI 2 "register_operand" "r,r,r")))]
4005   "TARGET_PA_20"
4006   "@
4007    sub %1,%2,%0
4008    subi %1,%2,%0
4009    mtsarcm %2"
4010   [(set_attr "type" "binary,binary,move")
4011    (set_attr "length" "4,4,4")])
4012
4013 ;; Clobbering a "register_operand" instead of a match_scratch
4014 ;; in operand3 of millicode calls avoids spilling %r1 and
4015 ;; produces better code.
4016
4017 ;; The mulsi3 insns set up registers for the millicode call.
4018 (define_expand "mulsi3"
4019   [(set (reg:SI 26) (match_operand:SI 1 "move_operand" ""))
4020    (set (reg:SI 25) (match_operand:SI 2 "move_operand" ""))
4021    (parallel [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
4022               (clobber (match_dup 3))
4023               (clobber (reg:SI 26))
4024               (clobber (reg:SI 25))
4025               (clobber (match_dup 4))])
4026    (set (match_operand:SI 0 "general_operand" "") (reg:SI 29))]
4027   ""
4028   "
4029 {
4030   operands[4] = gen_rtx_REG (SImode, TARGET_64BIT ? 2 : 31);
4031   if (TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT)
4032     {
4033       rtx scratch = gen_reg_rtx (DImode);
4034       operands[1] = force_reg (SImode, operands[1]);
4035       operands[2] = force_reg (SImode, operands[2]);
4036       emit_insn (gen_umulsidi3 (scratch, operands[1], operands[2]));
4037       emit_insn (gen_rtx_SET (VOIDmode, operands[0],
4038                               gen_rtx_SUBREG (SImode, scratch, GET_MODE_SIZE (SImode))));
4039       DONE;
4040     }
4041   operands[3] = gen_reg_rtx (SImode);
4042 }")
4043
4044 (define_insn "umulsidi3"
4045   [(set (match_operand:DI 0 "nonimmediate_operand" "=f")
4046         (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "f"))
4047                  (zero_extend:DI (match_operand:SI 2 "nonimmediate_operand" "f"))))]
4048   "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT"
4049   "xmpyu %1,%2,%0"
4050   [(set_attr "type" "fpmuldbl")
4051    (set_attr "length" "4")])
4052
4053 (define_insn ""
4054   [(set (match_operand:DI 0 "nonimmediate_operand" "=f")
4055         (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "f"))
4056                  (match_operand:DI 2 "uint32_operand" "f")))]
4057   "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT && !TARGET_64BIT"
4058   "xmpyu %1,%R2,%0"
4059   [(set_attr "type" "fpmuldbl")
4060    (set_attr "length" "4")])
4061
4062 (define_insn ""
4063   [(set (match_operand:DI 0 "nonimmediate_operand" "=f")
4064         (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "f"))
4065                  (match_operand:DI 2 "uint32_operand" "f")))]
4066   "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT && TARGET_64BIT"
4067   "xmpyu %1,%2R,%0"
4068   [(set_attr "type" "fpmuldbl")
4069    (set_attr "length" "4")])
4070
4071 (define_insn ""
4072   [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
4073    (clobber (match_operand:SI 0 "register_operand" "=a"))
4074    (clobber (reg:SI 26))
4075    (clobber (reg:SI 25))
4076    (clobber (reg:SI 31))]
4077   "!TARGET_64BIT"
4078   "* return output_mul_insn (0, insn);"
4079   [(set_attr "type" "milli")
4080    (set (attr "length")
4081      (cond [
4082 ;; Target (or stub) within reach
4083             (and (lt (plus (symbol_ref "total_code_bytes") (pc))
4084                      (const_int 240000))
4085                  (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
4086                      (const_int 0)))
4087             (const_int 4)
4088
4089 ;; Out of reach PIC
4090             (ne (symbol_ref "flag_pic")
4091                 (const_int 0))
4092             (const_int 24)
4093
4094 ;; Out of reach PORTABLE_RUNTIME
4095             (ne (symbol_ref "TARGET_PORTABLE_RUNTIME")
4096                 (const_int 0))
4097             (const_int 20)]
4098
4099 ;; Out of reach, can use ble
4100           (const_int 12)))])
4101
4102 (define_insn ""
4103   [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
4104    (clobber (match_operand:SI 0 "register_operand" "=a"))
4105    (clobber (reg:SI 26))
4106    (clobber (reg:SI 25))
4107    (clobber (reg:SI 2))]
4108   "TARGET_64BIT"
4109   "* return output_mul_insn (0, insn);"
4110   [(set_attr "type" "milli")
4111    (set (attr "length") (const_int 4))])
4112
4113 (define_expand "muldi3"
4114   [(set (match_operand:DI 0 "register_operand" "")
4115         (mult:DI (match_operand:DI 1 "register_operand" "")
4116                  (match_operand:DI 2 "register_operand" "")))]
4117   "TARGET_64BIT && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT"
4118   "
4119 {
4120   rtx low_product = gen_reg_rtx (DImode);
4121   rtx cross_product1 = gen_reg_rtx (DImode);
4122   rtx cross_product2 = gen_reg_rtx (DImode);
4123   rtx cross_scratch = gen_reg_rtx (DImode);
4124   rtx cross_product = gen_reg_rtx (DImode);
4125   rtx op1l, op1r, op2l, op2r;
4126   rtx op1shifted, op2shifted;
4127
4128   op1shifted = gen_reg_rtx (DImode);
4129   op2shifted = gen_reg_rtx (DImode);
4130   op1l = gen_reg_rtx (SImode);
4131   op1r = gen_reg_rtx (SImode);
4132   op2l = gen_reg_rtx (SImode);
4133   op2r = gen_reg_rtx (SImode);
4134
4135   emit_move_insn (op1shifted, gen_rtx_LSHIFTRT (DImode, operands[1],
4136                                                 GEN_INT (32)));
4137   emit_move_insn (op2shifted, gen_rtx_LSHIFTRT (DImode, operands[2],
4138                                                 GEN_INT (32)));
4139   op1r = gen_rtx_SUBREG (SImode, operands[1], 4);
4140   op2r = gen_rtx_SUBREG (SImode, operands[2], 4);
4141   op1l = gen_rtx_SUBREG (SImode, op1shifted, 4);
4142   op2l = gen_rtx_SUBREG (SImode, op2shifted, 4);
4143
4144   /* Emit multiplies for the cross products.  */
4145   emit_insn (gen_umulsidi3 (cross_product1, op2r, op1l));
4146   emit_insn (gen_umulsidi3 (cross_product2, op2l, op1r));
4147
4148   /* Emit a multiply for the low sub-word.  */
4149   emit_insn (gen_umulsidi3 (low_product, op2r, op1r));
4150
4151   /* Sum the cross products and shift them into proper position.  */
4152   emit_insn (gen_adddi3 (cross_scratch, cross_product1, cross_product2));
4153   emit_insn (gen_ashldi3 (cross_product, cross_scratch, GEN_INT (32)));
4154
4155   /* Add the cross product to the low product and store the result
4156      into the output operand .  */
4157   emit_insn (gen_adddi3 (operands[0], cross_product, low_product));
4158   DONE;
4159 }")
4160
4161 ;;; Division and mod.
4162 (define_expand "divsi3"
4163   [(set (reg:SI 26) (match_operand:SI 1 "move_operand" ""))
4164    (set (reg:SI 25) (match_operand:SI 2 "move_operand" ""))
4165    (parallel [(set (reg:SI 29) (div:SI (reg:SI 26) (reg:SI 25)))
4166               (clobber (match_dup 3))
4167               (clobber (match_dup 4))
4168               (clobber (reg:SI 26))
4169               (clobber (reg:SI 25))
4170               (clobber (match_dup 5))])
4171    (set (match_operand:SI 0 "general_operand" "") (reg:SI 29))]
4172   ""
4173   "
4174 {
4175   operands[3] = gen_reg_rtx (SImode);
4176   if (TARGET_64BIT)
4177     {
4178       operands[5] = gen_rtx_REG (SImode, 2);
4179       operands[4] = operands[5];
4180     }
4181   else
4182     {
4183       operands[5] = gen_rtx_REG (SImode, 31);
4184       operands[4] = gen_reg_rtx (SImode);
4185     }
4186   if (GET_CODE (operands[2]) == CONST_INT && emit_hpdiv_const (operands, 0))
4187     DONE;
4188 }")
4189
4190 (define_insn ""
4191   [(set (reg:SI 29)
4192         (div:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
4193    (clobber (match_operand:SI 1 "register_operand" "=a"))
4194    (clobber (match_operand:SI 2 "register_operand" "=&r"))
4195    (clobber (reg:SI 26))
4196    (clobber (reg:SI 25))
4197    (clobber (reg:SI 31))]
4198   "!TARGET_64BIT"
4199   "*
4200    return output_div_insn (operands, 0, insn);"
4201   [(set_attr "type" "milli")
4202    (set (attr "length")
4203      (cond [
4204 ;; Target (or stub) within reach
4205             (and (lt (plus (symbol_ref "total_code_bytes") (pc))
4206                      (const_int 240000))
4207                  (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
4208                      (const_int 0)))
4209             (const_int 4)
4210
4211 ;; Out of reach PIC
4212             (ne (symbol_ref "flag_pic")
4213                 (const_int 0))
4214             (const_int 24)
4215
4216 ;; Out of reach PORTABLE_RUNTIME
4217             (ne (symbol_ref "TARGET_PORTABLE_RUNTIME")
4218                 (const_int 0))
4219             (const_int 20)]
4220
4221 ;; Out of reach, can use ble
4222           (const_int 12)))])
4223
4224 (define_insn ""
4225   [(set (reg:SI 29)
4226         (div:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
4227    (clobber (match_operand:SI 1 "register_operand" "=a"))
4228    (clobber (match_operand:SI 2 "register_operand" "=&r"))
4229    (clobber (reg:SI 26))
4230    (clobber (reg:SI 25))
4231    (clobber (reg:SI 2))]
4232   "TARGET_64BIT"
4233   "*
4234    return output_div_insn (operands, 0, insn);"
4235   [(set_attr "type" "milli")
4236    (set (attr "length") (const_int 4))])
4237
4238 (define_expand "udivsi3"
4239   [(set (reg:SI 26) (match_operand:SI 1 "move_operand" ""))
4240    (set (reg:SI 25) (match_operand:SI 2 "move_operand" ""))
4241    (parallel [(set (reg:SI 29) (udiv:SI (reg:SI 26) (reg:SI 25)))
4242               (clobber (match_dup 3))
4243               (clobber (match_dup 4))
4244               (clobber (reg:SI 26))
4245               (clobber (reg:SI 25))
4246               (clobber (match_dup 5))])
4247    (set (match_operand:SI 0 "general_operand" "") (reg:SI 29))]
4248   ""
4249   "
4250 {
4251   operands[3] = gen_reg_rtx (SImode);
4252   if (TARGET_64BIT)
4253     {
4254       operands[5] = gen_rtx_REG (SImode, 2);
4255       operands[4] = operands[5];
4256     }
4257   else
4258     {
4259       operands[5] = gen_rtx_REG (SImode, 31);
4260       operands[4] = gen_reg_rtx (SImode);
4261     }
4262   if (GET_CODE (operands[2]) == CONST_INT && emit_hpdiv_const (operands, 1))
4263     DONE;
4264 }")
4265
4266 (define_insn ""
4267   [(set (reg:SI 29)
4268         (udiv:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
4269    (clobber (match_operand:SI 1 "register_operand" "=a"))
4270    (clobber (match_operand:SI 2 "register_operand" "=&r"))
4271    (clobber (reg:SI 26))
4272    (clobber (reg:SI 25))
4273    (clobber (reg:SI 31))]
4274   "!TARGET_64BIT"
4275   "*
4276    return output_div_insn (operands, 1, insn);"
4277   [(set_attr "type" "milli")
4278    (set (attr "length")
4279      (cond [
4280 ;; Target (or stub) within reach
4281             (and (lt (plus (symbol_ref "total_code_bytes") (pc))
4282                      (const_int 240000))
4283                  (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
4284                      (const_int 0)))
4285             (const_int 4)
4286
4287 ;; Out of reach PIC
4288             (ne (symbol_ref "flag_pic")
4289                 (const_int 0))
4290             (const_int 24)
4291
4292 ;; Out of reach PORTABLE_RUNTIME
4293             (ne (symbol_ref "TARGET_PORTABLE_RUNTIME")
4294                 (const_int 0))
4295             (const_int 20)]
4296
4297 ;; Out of reach, can use ble
4298           (const_int 12)))])
4299
4300 (define_insn ""
4301   [(set (reg:SI 29)
4302         (udiv:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
4303    (clobber (match_operand:SI 1 "register_operand" "=a"))
4304    (clobber (match_operand:SI 2 "register_operand" "=&r"))
4305    (clobber (reg:SI 26))
4306    (clobber (reg:SI 25))
4307    (clobber (reg:SI 2))]
4308   "TARGET_64BIT"
4309   "*
4310    return output_div_insn (operands, 1, insn);"
4311   [(set_attr "type" "milli")
4312    (set (attr "length") (const_int 4))])
4313
4314 (define_expand "modsi3"
4315   [(set (reg:SI 26) (match_operand:SI 1 "move_operand" ""))
4316    (set (reg:SI 25) (match_operand:SI 2 "move_operand" ""))
4317    (parallel [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
4318               (clobber (match_dup 3))
4319               (clobber (match_dup 4))
4320               (clobber (reg:SI 26))
4321               (clobber (reg:SI 25))
4322               (clobber (match_dup 5))])
4323    (set (match_operand:SI 0 "general_operand" "") (reg:SI 29))]
4324   ""
4325   "
4326 {
4327   if (TARGET_64BIT)
4328     {
4329       operands[5] = gen_rtx_REG (SImode, 2);
4330       operands[4] = operands[5];
4331     }
4332   else
4333     {
4334       operands[5] = gen_rtx_REG (SImode, 31);
4335       operands[4] = gen_reg_rtx (SImode);
4336     }
4337   operands[3] = gen_reg_rtx (SImode);
4338 }")
4339
4340 (define_insn ""
4341   [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
4342    (clobber (match_operand:SI 0 "register_operand" "=a"))
4343    (clobber (match_operand:SI 1 "register_operand" "=&r"))
4344    (clobber (reg:SI 26))
4345    (clobber (reg:SI 25))
4346    (clobber (reg:SI 31))]
4347   "!TARGET_64BIT"
4348   "*
4349   return output_mod_insn (0, insn);"
4350   [(set_attr "type" "milli")
4351    (set (attr "length")
4352      (cond [
4353 ;; Target (or stub) within reach
4354             (and (lt (plus (symbol_ref "total_code_bytes") (pc))
4355                      (const_int 240000))
4356                  (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
4357                      (const_int 0)))
4358             (const_int 4)
4359
4360 ;; Out of reach PIC
4361             (ne (symbol_ref "flag_pic")
4362                 (const_int 0))
4363             (const_int 24)
4364
4365 ;; Out of reach PORTABLE_RUNTIME
4366             (ne (symbol_ref "TARGET_PORTABLE_RUNTIME")
4367                 (const_int 0))
4368             (const_int 20)]
4369
4370 ;; Out of reach, can use ble
4371           (const_int 12)))])
4372
4373 (define_insn ""
4374   [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
4375    (clobber (match_operand:SI 0 "register_operand" "=a"))
4376    (clobber (match_operand:SI 1 "register_operand" "=&r"))
4377    (clobber (reg:SI 26))
4378    (clobber (reg:SI 25))
4379    (clobber (reg:SI 2))]
4380   "TARGET_64BIT"
4381   "*
4382   return output_mod_insn (0, insn);"
4383   [(set_attr "type" "milli")
4384    (set (attr "length") (const_int 4))])
4385
4386 (define_expand "umodsi3"
4387   [(set (reg:SI 26) (match_operand:SI 1 "move_operand" ""))
4388    (set (reg:SI 25) (match_operand:SI 2 "move_operand" ""))
4389    (parallel [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
4390               (clobber (match_dup 3))
4391               (clobber (match_dup 4))
4392               (clobber (reg:SI 26))
4393               (clobber (reg:SI 25))
4394               (clobber (match_dup 5))])
4395    (set (match_operand:SI 0 "general_operand" "") (reg:SI 29))]
4396   ""
4397   "
4398 {
4399   if (TARGET_64BIT)
4400     {
4401       operands[5] = gen_rtx_REG (SImode, 2);
4402       operands[4] = operands[5];
4403     }
4404   else
4405     {
4406       operands[5] = gen_rtx_REG (SImode, 31);
4407       operands[4] = gen_reg_rtx (SImode);
4408     }
4409   operands[3] = gen_reg_rtx (SImode);
4410 }")
4411
4412 (define_insn ""
4413   [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
4414    (clobber (match_operand:SI 0 "register_operand" "=a"))
4415    (clobber (match_operand:SI 1 "register_operand" "=&r"))
4416    (clobber (reg:SI 26))
4417    (clobber (reg:SI 25))
4418    (clobber (reg:SI 31))]
4419   "!TARGET_64BIT"
4420   "*
4421   return output_mod_insn (1, insn);"
4422   [(set_attr "type" "milli")
4423    (set (attr "length")
4424      (cond [
4425 ;; Target (or stub) within reach
4426             (and (lt (plus (symbol_ref "total_code_bytes") (pc))
4427                      (const_int 240000))
4428                  (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
4429                      (const_int 0)))
4430             (const_int 4)
4431
4432 ;; Out of reach PIC
4433             (ne (symbol_ref "flag_pic")
4434                 (const_int 0))
4435             (const_int 24)
4436
4437 ;; Out of reach PORTABLE_RUNTIME
4438             (ne (symbol_ref "TARGET_PORTABLE_RUNTIME")
4439                 (const_int 0))
4440             (const_int 20)]
4441
4442 ;; Out of reach, can use ble
4443           (const_int 12)))])
4444
4445 (define_insn ""
4446   [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
4447    (clobber (match_operand:SI 0 "register_operand" "=a"))
4448    (clobber (match_operand:SI 1 "register_operand" "=&r"))
4449    (clobber (reg:SI 26))
4450    (clobber (reg:SI 25))
4451    (clobber (reg:SI 2))]
4452   "TARGET_64BIT"
4453   "*
4454   return output_mod_insn (1, insn);"
4455   [(set_attr "type" "milli")
4456    (set (attr "length") (const_int 4))])
4457
4458 ;;- and instructions
4459 ;; We define DImode `and` so with DImode `not` we can get
4460 ;; DImode `andn`.  Other combinations are possible.
4461
4462 (define_expand "anddi3"
4463   [(set (match_operand:DI 0 "register_operand" "")
4464         (and:DI (match_operand:DI 1 "arith_double_operand" "")
4465                 (match_operand:DI 2 "arith_double_operand" "")))]
4466   ""
4467   "
4468 {
4469   if (! register_operand (operands[1], DImode)
4470       || ! register_operand (operands[2], DImode))
4471     /* Let GCC break this into word-at-a-time operations.  */
4472     FAIL;
4473 }")
4474
4475 (define_insn ""
4476   [(set (match_operand:DI 0 "register_operand" "=r")
4477         (and:DI (match_operand:DI 1 "register_operand" "%r")
4478                 (match_operand:DI 2 "register_operand" "r")))]
4479   "!TARGET_64BIT"
4480   "and %1,%2,%0\;and %R1,%R2,%R0"
4481   [(set_attr "type" "binary")
4482    (set_attr "length" "8")])
4483
4484 (define_insn ""
4485   [(set (match_operand:DI 0 "register_operand" "=r,r")
4486         (and:DI (match_operand:DI 1 "register_operand" "%?r,0")
4487                 (match_operand:DI 2 "and_operand" "rO,P")))]
4488   "TARGET_64BIT"
4489   "* return output_64bit_and (operands); "
4490   [(set_attr "type" "binary")
4491    (set_attr "length" "4")])
4492
4493 ; The ? for op1 makes reload prefer zdepi instead of loading a huge
4494 ; constant with ldil;ldo.
4495 (define_insn "andsi3"
4496   [(set (match_operand:SI 0 "register_operand" "=r,r")
4497         (and:SI (match_operand:SI 1 "register_operand" "%?r,0")
4498                 (match_operand:SI 2 "and_operand" "rO,P")))]
4499   ""
4500   "* return output_and (operands); "
4501   [(set_attr "type" "binary,shift")
4502    (set_attr "length" "4,4")])
4503
4504 (define_insn ""
4505   [(set (match_operand:DI 0 "register_operand" "=r")
4506         (and:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
4507                 (match_operand:DI 2 "register_operand" "r")))]
4508   "!TARGET_64BIT"
4509   "andcm %2,%1,%0\;andcm %R2,%R1,%R0"
4510   [(set_attr "type" "binary")
4511    (set_attr "length" "8")])
4512
4513 (define_insn ""
4514   [(set (match_operand:DI 0 "register_operand" "=r")
4515         (and:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
4516                 (match_operand:DI 2 "register_operand" "r")))]
4517   "TARGET_64BIT"
4518   "andcm %2,%1,%0"
4519   [(set_attr "type" "binary")
4520    (set_attr "length" "4")])
4521
4522 (define_insn ""
4523   [(set (match_operand:SI 0 "register_operand" "=r")
4524         (and:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
4525                 (match_operand:SI 2 "register_operand" "r")))]
4526   ""
4527   "andcm %2,%1,%0"
4528   [(set_attr "type" "binary")
4529   (set_attr "length" "4")])
4530
4531 (define_expand "iordi3"
4532   [(set (match_operand:DI 0 "register_operand" "")
4533         (ior:DI (match_operand:DI 1 "arith_double_operand" "")
4534                 (match_operand:DI 2 "arith_double_operand" "")))]
4535   ""
4536   "
4537 {
4538   if (! register_operand (operands[1], DImode)
4539       || ! register_operand (operands[2], DImode))
4540     /* Let GCC break this into word-at-a-time operations.  */
4541     FAIL;
4542 }")
4543
4544 (define_insn ""
4545   [(set (match_operand:DI 0 "register_operand" "=r")
4546         (ior:DI (match_operand:DI 1 "register_operand" "%r")
4547                 (match_operand:DI 2 "register_operand" "r")))]
4548   "!TARGET_64BIT"
4549   "or %1,%2,%0\;or %R1,%R2,%R0"
4550   [(set_attr "type" "binary")
4551    (set_attr "length" "8")])
4552
4553 (define_insn ""
4554   [(set (match_operand:DI 0 "register_operand" "=r,r")
4555         (ior:DI (match_operand:DI 1 "register_operand" "0,0")
4556                 (match_operand:DI 2 "ior_operand" "M,i")))]
4557   "TARGET_64BIT"
4558   "* return output_64bit_ior (operands); "
4559   [(set_attr "type" "binary,shift")
4560    (set_attr "length" "4,4")])
4561
4562 (define_insn ""
4563   [(set (match_operand:DI 0 "register_operand" "=r")
4564         (ior:DI (match_operand:DI 1 "register_operand" "%r")
4565                 (match_operand:DI 2 "register_operand" "r")))]
4566   "TARGET_64BIT"
4567   "or %1,%2,%0"
4568   [(set_attr "type" "binary")
4569    (set_attr "length" "4")])
4570
4571 ;; Need a define_expand because we've run out of CONST_OK... characters.
4572 (define_expand "iorsi3"
4573   [(set (match_operand:SI 0 "register_operand" "")
4574         (ior:SI (match_operand:SI 1 "register_operand" "")
4575                 (match_operand:SI 2 "arith32_operand" "")))]
4576   ""
4577   "
4578 {
4579   if (! (ior_operand (operands[2], SImode)
4580          || register_operand (operands[2], SImode)))
4581     operands[2] = force_reg (SImode, operands[2]);
4582 }")
4583
4584 (define_insn ""
4585   [(set (match_operand:SI 0 "register_operand" "=r,r")
4586         (ior:SI (match_operand:SI 1 "register_operand" "0,0")
4587                 (match_operand:SI 2 "ior_operand" "M,i")))]
4588   ""
4589   "* return output_ior (operands); "
4590   [(set_attr "type" "binary,shift")
4591    (set_attr "length" "4,4")])
4592
4593 (define_insn ""
4594   [(set (match_operand:SI 0 "register_operand" "=r")
4595         (ior:SI (match_operand:SI 1 "register_operand" "%r")
4596                 (match_operand:SI 2 "register_operand" "r")))]
4597   ""
4598   "or %1,%2,%0"
4599   [(set_attr "type" "binary")
4600    (set_attr "length" "4")])
4601
4602 (define_expand "xordi3"
4603   [(set (match_operand:DI 0 "register_operand" "")
4604         (xor:DI (match_operand:DI 1 "arith_double_operand" "")
4605                 (match_operand:DI 2 "arith_double_operand" "")))]
4606   ""
4607   "
4608 {
4609   if (! register_operand (operands[1], DImode)
4610       || ! register_operand (operands[2], DImode))
4611     /* Let GCC break this into word-at-a-time operations.  */
4612     FAIL;
4613 }")
4614
4615 (define_insn ""
4616   [(set (match_operand:DI 0 "register_operand" "=r")
4617         (xor:DI (match_operand:DI 1 "register_operand" "%r")
4618                 (match_operand:DI 2 "register_operand" "r")))]
4619   "!TARGET_64BIT"
4620   "xor %1,%2,%0\;xor %R1,%R2,%R0"
4621   [(set_attr "type" "binary")
4622    (set_attr "length" "8")])
4623
4624 (define_insn ""
4625   [(set (match_operand:DI 0 "register_operand" "=r")
4626         (xor:DI (match_operand:DI 1 "register_operand" "%r")
4627                 (match_operand:DI 2 "register_operand" "r")))]
4628   "TARGET_64BIT"
4629   "xor %1,%2,%0"
4630   [(set_attr "type" "binary")
4631    (set_attr "length" "4")])
4632
4633 (define_insn "xorsi3"
4634   [(set (match_operand:SI 0 "register_operand" "=r")
4635         (xor:SI (match_operand:SI 1 "register_operand" "%r")
4636                 (match_operand:SI 2 "register_operand" "r")))]
4637   ""
4638   "xor %1,%2,%0"
4639   [(set_attr "type" "binary")
4640    (set_attr "length" "4")])
4641
4642 (define_expand "negdi2"
4643   [(set (match_operand:DI 0 "register_operand" "")
4644         (neg:DI (match_operand:DI 1 "register_operand" "")))]
4645   ""
4646   "")
4647
4648 (define_insn ""
4649   [(set (match_operand:DI 0 "register_operand" "=r")
4650         (neg:DI (match_operand:DI 1 "register_operand" "r")))]
4651   "!TARGET_64BIT"
4652   "sub %%r0,%R1,%R0\;{subb|sub,b} %%r0,%1,%0"
4653   [(set_attr "type" "unary")
4654    (set_attr "length" "8")])
4655
4656 (define_insn ""
4657   [(set (match_operand:DI 0 "register_operand" "=r")
4658         (neg:DI (match_operand:DI 1 "register_operand" "r")))]
4659   "TARGET_64BIT"
4660   "sub %%r0,%1,%0"
4661   [(set_attr "type" "unary")
4662    (set_attr "length" "4")])
4663
4664 (define_insn "negsi2"
4665   [(set (match_operand:SI 0 "register_operand" "=r")
4666         (neg:SI (match_operand:SI 1 "register_operand" "r")))]
4667   ""
4668   "sub %%r0,%1,%0"
4669   [(set_attr "type" "unary")
4670    (set_attr "length" "4")])
4671
4672 (define_expand "one_cmpldi2"
4673   [(set (match_operand:DI 0 "register_operand" "")
4674         (not:DI (match_operand:DI 1 "arith_double_operand" "")))]
4675   ""
4676   "
4677 {
4678   if (! register_operand (operands[1], DImode))
4679     FAIL;
4680 }")
4681
4682 (define_insn ""
4683   [(set (match_operand:DI 0 "register_operand" "=r")
4684         (not:DI (match_operand:DI 1 "register_operand" "r")))]
4685   "!TARGET_64BIT"
4686   "uaddcm %%r0,%1,%0\;uaddcm %%r0,%R1,%R0"
4687   [(set_attr "type" "unary")
4688    (set_attr "length" "8")])
4689
4690 (define_insn ""
4691   [(set (match_operand:DI 0 "register_operand" "=r")
4692         (not:DI (match_operand:DI 1 "register_operand" "r")))]
4693   "TARGET_64BIT"
4694   "uaddcm %%r0,%1,%0"
4695   [(set_attr "type" "unary")
4696    (set_attr "length" "4")])
4697
4698 (define_insn "one_cmplsi2"
4699   [(set (match_operand:SI 0 "register_operand" "=r")
4700         (not:SI (match_operand:SI 1 "register_operand" "r")))]
4701   ""
4702   "uaddcm %%r0,%1,%0"
4703   [(set_attr "type" "unary")
4704    (set_attr "length" "4")])
4705 \f
4706 ;; Floating point arithmetic instructions.
4707
4708 (define_insn "adddf3"
4709   [(set (match_operand:DF 0 "register_operand" "=f")
4710         (plus:DF (match_operand:DF 1 "register_operand" "f")
4711                  (match_operand:DF 2 "register_operand" "f")))]
4712   "! TARGET_SOFT_FLOAT"
4713   "fadd,dbl %1,%2,%0"
4714   [(set_attr "type" "fpalu")
4715    (set_attr "pa_combine_type" "faddsub")
4716    (set_attr "length" "4")])
4717
4718 (define_insn "addsf3"
4719   [(set (match_operand:SF 0 "register_operand" "=f")
4720         (plus:SF (match_operand:SF 1 "register_operand" "f")
4721                  (match_operand:SF 2 "register_operand" "f")))]
4722   "! TARGET_SOFT_FLOAT"
4723   "fadd,sgl %1,%2,%0"
4724   [(set_attr "type" "fpalu")
4725    (set_attr "pa_combine_type" "faddsub")
4726    (set_attr "length" "4")])
4727
4728 (define_insn "subdf3"
4729   [(set (match_operand:DF 0 "register_operand" "=f")
4730         (minus:DF (match_operand:DF 1 "register_operand" "f")
4731                   (match_operand:DF 2 "register_operand" "f")))]
4732   "! TARGET_SOFT_FLOAT"
4733   "fsub,dbl %1,%2,%0"
4734   [(set_attr "type" "fpalu")
4735    (set_attr "pa_combine_type" "faddsub")
4736    (set_attr "length" "4")])
4737
4738 (define_insn "subsf3"
4739   [(set (match_operand:SF 0 "register_operand" "=f")
4740         (minus:SF (match_operand:SF 1 "register_operand" "f")
4741                   (match_operand:SF 2 "register_operand" "f")))]
4742   "! TARGET_SOFT_FLOAT"
4743   "fsub,sgl %1,%2,%0"
4744   [(set_attr "type" "fpalu")
4745    (set_attr "pa_combine_type" "faddsub")
4746    (set_attr "length" "4")])
4747
4748 (define_insn "muldf3"
4749   [(set (match_operand:DF 0 "register_operand" "=f")
4750         (mult:DF (match_operand:DF 1 "register_operand" "f")
4751                  (match_operand:DF 2 "register_operand" "f")))]
4752   "! TARGET_SOFT_FLOAT"
4753   "fmpy,dbl %1,%2,%0"
4754   [(set_attr "type" "fpmuldbl")
4755    (set_attr "pa_combine_type" "fmpy")
4756    (set_attr "length" "4")])
4757
4758 (define_insn "mulsf3"
4759   [(set (match_operand:SF 0 "register_operand" "=f")
4760         (mult:SF (match_operand:SF 1 "register_operand" "f")
4761                  (match_operand:SF 2 "register_operand" "f")))]
4762   "! TARGET_SOFT_FLOAT"
4763   "fmpy,sgl %1,%2,%0"
4764   [(set_attr "type" "fpmulsgl")
4765    (set_attr "pa_combine_type" "fmpy")
4766    (set_attr "length" "4")])
4767
4768 (define_insn "divdf3"
4769   [(set (match_operand:DF 0 "register_operand" "=f")
4770         (div:DF (match_operand:DF 1 "register_operand" "f")
4771                 (match_operand:DF 2 "register_operand" "f")))]
4772   "! TARGET_SOFT_FLOAT"
4773   "fdiv,dbl %1,%2,%0"
4774   [(set_attr "type" "fpdivdbl")
4775    (set_attr "length" "4")])
4776
4777 (define_insn "divsf3"
4778   [(set (match_operand:SF 0 "register_operand" "=f")
4779         (div:SF (match_operand:SF 1 "register_operand" "f")
4780                 (match_operand:SF 2 "register_operand" "f")))]
4781   "! TARGET_SOFT_FLOAT"
4782   "fdiv,sgl %1,%2,%0"
4783   [(set_attr "type" "fpdivsgl")
4784    (set_attr "length" "4")])
4785
4786 ;; Processors prior to PA 2.0 don't have a fneg instruction.  Fast
4787 ;; negation can be done by subtracting from plus zero.  However, this
4788 ;; violates the IEEE standard when negating plus and minus zero.
4789 (define_expand "negdf2"
4790   [(parallel [(set (match_operand:DF 0 "register_operand" "")
4791                    (neg:DF (match_operand:DF 1 "register_operand" "")))
4792               (use (match_dup 2))])]
4793   "! TARGET_SOFT_FLOAT"
4794 {
4795   if (TARGET_PA_20 || flag_unsafe_math_optimizations)
4796     emit_insn (gen_negdf2_fast (operands[0], operands[1]));
4797   else
4798     {
4799       operands[2] = force_reg (DFmode,
4800         CONST_DOUBLE_FROM_REAL_VALUE (dconstm1, DFmode));
4801       emit_insn (gen_muldf3 (operands[0], operands[1], operands[2]));
4802     }
4803   DONE;
4804 })
4805
4806 (define_insn "negdf2_fast"
4807   [(set (match_operand:DF 0 "register_operand" "=f")
4808         (neg:DF (match_operand:DF 1 "register_operand" "f")))]
4809   "! TARGET_SOFT_FLOAT && (TARGET_PA_20 || flag_unsafe_math_optimizations)"
4810   "*
4811 {
4812   if (TARGET_PA_20)
4813     return \"fneg,dbl %1,%0\";
4814   else
4815     return \"fsub,dbl %%fr0,%1,%0\";
4816 }"
4817   [(set_attr "type" "fpalu")
4818    (set_attr "length" "4")])
4819
4820 (define_expand "negsf2"
4821   [(parallel [(set (match_operand:SF 0 "register_operand" "")
4822                    (neg:SF (match_operand:SF 1 "register_operand" "")))
4823               (use (match_dup 2))])]
4824   "! TARGET_SOFT_FLOAT"
4825 {
4826   if (TARGET_PA_20 || flag_unsafe_math_optimizations)
4827     emit_insn (gen_negsf2_fast (operands[0], operands[1]));
4828   else
4829     {
4830       operands[2] = force_reg (SFmode,
4831         CONST_DOUBLE_FROM_REAL_VALUE (dconstm1, SFmode));
4832       emit_insn (gen_mulsf3 (operands[0], operands[1], operands[2]));
4833     }
4834   DONE;
4835 })
4836
4837 (define_insn "negsf2_fast"
4838   [(set (match_operand:SF 0 "register_operand" "=f")
4839         (neg:SF (match_operand:SF 1 "register_operand" "f")))]
4840   "! TARGET_SOFT_FLOAT && (TARGET_PA_20 || flag_unsafe_math_optimizations)"
4841   "*
4842 {
4843   if (TARGET_PA_20)
4844     return \"fneg,sgl %1,%0\";
4845   else
4846     return \"fsub,sgl %%fr0,%1,%0\";
4847 }"
4848   [(set_attr "type" "fpalu")
4849    (set_attr "length" "4")])
4850
4851 (define_insn "absdf2"
4852   [(set (match_operand:DF 0 "register_operand" "=f")
4853         (abs:DF (match_operand:DF 1 "register_operand" "f")))]
4854   "! TARGET_SOFT_FLOAT"
4855   "fabs,dbl %1,%0"
4856   [(set_attr "type" "fpalu")
4857    (set_attr "length" "4")])
4858
4859 (define_insn "abssf2"
4860   [(set (match_operand:SF 0 "register_operand" "=f")
4861         (abs:SF (match_operand:SF 1 "register_operand" "f")))]
4862   "! TARGET_SOFT_FLOAT"
4863   "fabs,sgl %1,%0"
4864   [(set_attr "type" "fpalu")
4865    (set_attr "length" "4")])
4866
4867 (define_insn "sqrtdf2"
4868   [(set (match_operand:DF 0 "register_operand" "=f")
4869         (sqrt:DF (match_operand:DF 1 "register_operand" "f")))]
4870   "! TARGET_SOFT_FLOAT"
4871   "fsqrt,dbl %1,%0"
4872   [(set_attr "type" "fpsqrtdbl")
4873    (set_attr "length" "4")])
4874
4875 (define_insn "sqrtsf2"
4876   [(set (match_operand:SF 0 "register_operand" "=f")
4877         (sqrt:SF (match_operand:SF 1 "register_operand" "f")))]
4878   "! TARGET_SOFT_FLOAT"
4879   "fsqrt,sgl %1,%0"
4880   [(set_attr "type" "fpsqrtsgl")
4881    (set_attr "length" "4")])
4882
4883 ;; PA 2.0 floating point instructions
4884
4885 ; fmpyfadd patterns
4886 (define_insn ""
4887   [(set (match_operand:DF 0 "register_operand" "=f")
4888         (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
4889                           (match_operand:DF 2 "register_operand" "f"))
4890                  (match_operand:DF 3 "register_operand" "f")))]
4891   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
4892   "fmpyfadd,dbl %1,%2,%3,%0"
4893   [(set_attr "type" "fpmuldbl")
4894    (set_attr "length" "4")])
4895
4896 (define_insn ""
4897   [(set (match_operand:DF 0 "register_operand" "=f")
4898         (plus:DF (match_operand:DF 1 "register_operand" "f")
4899                  (mult:DF (match_operand:DF 2 "register_operand" "f")
4900                           (match_operand:DF 3 "register_operand" "f"))))]
4901   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
4902   "fmpyfadd,dbl %2,%3,%1,%0"
4903   [(set_attr "type" "fpmuldbl")
4904    (set_attr "length" "4")])
4905
4906 (define_insn ""
4907   [(set (match_operand:SF 0 "register_operand" "=f")
4908         (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
4909                           (match_operand:SF 2 "register_operand" "f"))
4910                  (match_operand:SF 3 "register_operand" "f")))]
4911   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
4912   "fmpyfadd,sgl %1,%2,%3,%0"
4913   [(set_attr "type" "fpmulsgl")
4914    (set_attr "length" "4")])
4915
4916 (define_insn ""
4917   [(set (match_operand:SF 0 "register_operand" "=f")
4918         (plus:SF (match_operand:SF 1 "register_operand" "f")
4919                  (mult:SF (match_operand:SF 2 "register_operand" "f")
4920                           (match_operand:SF 3 "register_operand" "f"))))]
4921   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
4922   "fmpyfadd,sgl %2,%3,%1,%0"
4923   [(set_attr "type" "fpmulsgl")
4924    (set_attr "length" "4")])
4925
4926 ; fmpynfadd patterns
4927 (define_insn ""
4928   [(set (match_operand:DF 0 "register_operand" "=f")
4929         (minus:DF (match_operand:DF 1 "register_operand" "f")
4930                   (mult:DF (match_operand:DF 2 "register_operand" "f")
4931                            (match_operand:DF 3 "register_operand" "f"))))]
4932   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
4933   "fmpynfadd,dbl %2,%3,%1,%0"
4934   [(set_attr "type" "fpmuldbl")
4935    (set_attr "length" "4")])
4936
4937 (define_insn ""
4938   [(set (match_operand:SF 0 "register_operand" "=f")
4939         (minus:SF (match_operand:SF 1 "register_operand" "f")
4940                   (mult:SF (match_operand:SF 2 "register_operand" "f")
4941                            (match_operand:SF 3 "register_operand" "f"))))]
4942   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
4943   "fmpynfadd,sgl %2,%3,%1,%0"
4944   [(set_attr "type" "fpmulsgl")
4945    (set_attr "length" "4")])
4946
4947 ; fnegabs patterns
4948 (define_insn ""
4949   [(set (match_operand:DF 0 "register_operand" "=f")
4950         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))]
4951   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
4952   "fnegabs,dbl %1,%0"
4953   [(set_attr "type" "fpalu")
4954    (set_attr "length" "4")])
4955
4956 (define_insn ""
4957   [(set (match_operand:SF 0 "register_operand" "=f")
4958         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))]
4959   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
4960   "fnegabs,sgl %1,%0"
4961   [(set_attr "type" "fpalu")
4962    (set_attr "length" "4")])
4963
4964 ;; Generating a fused multiply sequence is a win for this case as it will
4965 ;; reduce the latency for the fused case without impacting the plain
4966 ;; multiply case.
4967 ;;
4968 ;; Similar possibilities exist for fnegabs, shadd and other insns which
4969 ;; perform two operations with the result of the first feeding the second.
4970 (define_insn ""
4971   [(set (match_operand:DF 0 "register_operand" "=f")
4972         (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
4973                           (match_operand:DF 2 "register_operand" "f"))
4974                  (match_operand:DF 3 "register_operand" "f")))
4975    (set (match_operand:DF 4 "register_operand" "=&f")
4976         (mult:DF (match_dup 1) (match_dup 2)))]
4977   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
4978     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
4979           || reg_overlap_mentioned_p (operands[4], operands[2])))"
4980   "#"
4981   [(set_attr "type" "fpmuldbl")
4982    (set_attr "length" "8")])
4983
4984 ;; We want to split this up during scheduling since we want both insns
4985 ;; to schedule independently.
4986 (define_split
4987   [(set (match_operand:DF 0 "register_operand" "")
4988         (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "")
4989                           (match_operand:DF 2 "register_operand" ""))
4990                  (match_operand:DF 3 "register_operand" "")))
4991    (set (match_operand:DF 4 "register_operand" "")
4992         (mult:DF (match_dup 1) (match_dup 2)))]
4993   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4994   [(set (match_dup 4) (mult:DF (match_dup 1) (match_dup 2)))
4995    (set (match_dup 0) (plus:DF (mult:DF (match_dup 1) (match_dup 2))
4996                                (match_dup 3)))]
4997   "")
4998
4999 (define_insn ""
5000   [(set (match_operand:SF 0 "register_operand" "=f")
5001         (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
5002                           (match_operand:SF 2 "register_operand" "f"))
5003                  (match_operand:SF 3 "register_operand" "f")))
5004    (set (match_operand:SF 4 "register_operand" "=&f")
5005         (mult:SF (match_dup 1) (match_dup 2)))]
5006   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
5007     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
5008           || reg_overlap_mentioned_p (operands[4], operands[2])))"
5009   "#"
5010   [(set_attr "type" "fpmuldbl")
5011    (set_attr "length" "8")])
5012
5013 ;; We want to split this up during scheduling since we want both insns
5014 ;; to schedule independently.
5015 (define_split
5016   [(set (match_operand:SF 0 "register_operand" "")
5017         (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "")
5018                           (match_operand:SF 2 "register_operand" ""))
5019                  (match_operand:SF 3 "register_operand" "")))
5020    (set (match_operand:SF 4 "register_operand" "")
5021         (mult:SF (match_dup 1) (match_dup 2)))]
5022   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5023   [(set (match_dup 4) (mult:SF (match_dup 1) (match_dup 2)))
5024    (set (match_dup 0) (plus:SF (mult:SF (match_dup 1) (match_dup 2))
5025                                (match_dup 3)))]
5026   "")
5027
5028 ;; Negating a multiply can be faked by adding zero in a fused multiply-add
5029 ;; instruction.
5030 (define_insn ""
5031   [(set (match_operand:DF 0 "register_operand" "=f")
5032         (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
5033                          (match_operand:DF 2 "register_operand" "f"))))]
5034   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5035   "fmpynfadd,dbl %1,%2,%%fr0,%0"
5036   [(set_attr "type" "fpmuldbl")
5037    (set_attr "length" "4")])
5038
5039 (define_insn ""
5040   [(set (match_operand:SF 0 "register_operand" "=f")
5041         (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
5042                          (match_operand:SF 2 "register_operand" "f"))))]
5043   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5044   "fmpynfadd,sgl %1,%2,%%fr0,%0"
5045   [(set_attr "type" "fpmuldbl")
5046    (set_attr "length" "4")])
5047
5048 (define_insn ""
5049   [(set (match_operand:DF 0 "register_operand" "=f")
5050         (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
5051                          (match_operand:DF 2 "register_operand" "f"))))
5052    (set (match_operand:DF 3 "register_operand" "=&f")
5053         (mult:DF (match_dup 1) (match_dup 2)))]
5054   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
5055     && ! (reg_overlap_mentioned_p (operands[3], operands[1])
5056           || reg_overlap_mentioned_p (operands[3], operands[2])))"
5057   "#"
5058   [(set_attr "type" "fpmuldbl")
5059    (set_attr "length" "8")])
5060
5061 (define_split
5062   [(set (match_operand:DF 0 "register_operand" "")
5063         (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "")
5064                          (match_operand:DF 2 "register_operand" ""))))
5065    (set (match_operand:DF 3 "register_operand" "")
5066         (mult:DF (match_dup 1) (match_dup 2)))]
5067   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5068   [(set (match_dup 3) (mult:DF (match_dup 1) (match_dup 2)))
5069    (set (match_dup 0) (neg:DF (mult:DF (match_dup 1) (match_dup 2))))]
5070   "")
5071
5072 (define_insn ""
5073   [(set (match_operand:SF 0 "register_operand" "=f")
5074         (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
5075                          (match_operand:SF 2 "register_operand" "f"))))
5076    (set (match_operand:SF 3 "register_operand" "=&f")
5077         (mult:SF (match_dup 1) (match_dup 2)))]
5078   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
5079     && ! (reg_overlap_mentioned_p (operands[3], operands[1])
5080           || reg_overlap_mentioned_p (operands[3], operands[2])))"
5081   "#"
5082   [(set_attr "type" "fpmuldbl")
5083    (set_attr "length" "8")])
5084
5085 (define_split
5086   [(set (match_operand:SF 0 "register_operand" "")
5087         (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "")
5088                          (match_operand:SF 2 "register_operand" ""))))
5089    (set (match_operand:SF 3 "register_operand" "")
5090         (mult:SF (match_dup 1) (match_dup 2)))]
5091   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5092   [(set (match_dup 3) (mult:SF (match_dup 1) (match_dup 2)))
5093    (set (match_dup 0) (neg:SF (mult:SF (match_dup 1) (match_dup 2))))]
5094   "")
5095
5096 ;; Now fused multiplies with the result of the multiply negated.
5097 (define_insn ""
5098   [(set (match_operand:DF 0 "register_operand" "=f")
5099         (plus:DF (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
5100                                   (match_operand:DF 2 "register_operand" "f")))
5101                  (match_operand:DF 3 "register_operand" "f")))]
5102   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5103   "fmpynfadd,dbl %1,%2,%3,%0"
5104   [(set_attr "type" "fpmuldbl")
5105    (set_attr "length" "4")])
5106
5107 (define_insn ""
5108   [(set (match_operand:SF 0 "register_operand" "=f")
5109         (plus:SF (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
5110                          (match_operand:SF 2 "register_operand" "f")))
5111                  (match_operand:SF 3 "register_operand" "f")))]
5112   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5113   "fmpynfadd,sgl %1,%2,%3,%0"
5114   [(set_attr "type" "fpmuldbl")
5115    (set_attr "length" "4")])
5116
5117 (define_insn ""
5118   [(set (match_operand:DF 0 "register_operand" "=f")
5119         (plus:DF (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
5120                                   (match_operand:DF 2 "register_operand" "f")))
5121                  (match_operand:DF 3 "register_operand" "f")))
5122    (set (match_operand:DF 4 "register_operand" "=&f")
5123         (mult:DF (match_dup 1) (match_dup 2)))]
5124   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
5125     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
5126           || reg_overlap_mentioned_p (operands[4], operands[2])))"
5127   "#"
5128   [(set_attr "type" "fpmuldbl")
5129    (set_attr "length" "8")])
5130
5131 (define_split
5132   [(set (match_operand:DF 0 "register_operand" "")
5133         (plus:DF (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "")
5134                                   (match_operand:DF 2 "register_operand" "")))
5135                  (match_operand:DF 3 "register_operand" "")))
5136    (set (match_operand:DF 4 "register_operand" "")
5137         (mult:DF (match_dup 1) (match_dup 2)))]
5138   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5139   [(set (match_dup 4) (mult:DF (match_dup 1) (match_dup 2)))
5140    (set (match_dup 0) (plus:DF (neg:DF (mult:DF (match_dup 1) (match_dup 2)))
5141                                (match_dup 3)))]
5142   "")
5143
5144 (define_insn ""
5145   [(set (match_operand:SF 0 "register_operand" "=f")
5146         (plus:SF (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
5147                                   (match_operand:SF 2 "register_operand" "f")))
5148                  (match_operand:SF 3 "register_operand" "f")))
5149    (set (match_operand:SF 4 "register_operand" "=&f")
5150         (mult:SF (match_dup 1) (match_dup 2)))]
5151   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
5152     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
5153           || reg_overlap_mentioned_p (operands[4], operands[2])))"
5154   "#"
5155   [(set_attr "type" "fpmuldbl")
5156    (set_attr "length" "8")])
5157
5158 (define_split
5159   [(set (match_operand:SF 0 "register_operand" "")
5160         (plus:SF (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "")
5161                                   (match_operand:SF 2 "register_operand" "")))
5162                  (match_operand:SF 3 "register_operand" "")))
5163    (set (match_operand:SF 4 "register_operand" "")
5164         (mult:SF (match_dup 1) (match_dup 2)))]
5165   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5166   [(set (match_dup 4) (mult:SF (match_dup 1) (match_dup 2)))
5167    (set (match_dup 0) (plus:SF (neg:SF (mult:SF (match_dup 1) (match_dup 2)))
5168                                (match_dup 3)))]
5169   "")
5170
5171 (define_insn ""
5172   [(set (match_operand:DF 0 "register_operand" "=f")
5173         (minus:DF (match_operand:DF 3 "register_operand" "f")
5174                   (mult:DF (match_operand:DF 1 "register_operand" "f")
5175                            (match_operand:DF 2 "register_operand" "f"))))
5176    (set (match_operand:DF 4 "register_operand" "=&f")
5177         (mult:DF (match_dup 1) (match_dup 2)))]
5178   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
5179     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
5180           || reg_overlap_mentioned_p (operands[4], operands[2])))"
5181   "#"
5182   [(set_attr "type" "fpmuldbl")
5183    (set_attr "length" "8")])
5184
5185 (define_split
5186   [(set (match_operand:DF 0 "register_operand" "")
5187         (minus:DF (match_operand:DF 3 "register_operand" "")
5188                   (mult:DF (match_operand:DF 1 "register_operand" "")
5189                            (match_operand:DF 2 "register_operand" ""))))
5190    (set (match_operand:DF 4 "register_operand" "")
5191         (mult:DF (match_dup 1) (match_dup 2)))]
5192   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5193   [(set (match_dup 4) (mult:DF (match_dup 1) (match_dup 2)))
5194    (set (match_dup 0) (minus:DF (match_dup 3)
5195                                 (mult:DF (match_dup 1) (match_dup 2))))]
5196   "")
5197
5198 (define_insn ""
5199   [(set (match_operand:SF 0 "register_operand" "=f")
5200         (minus:SF (match_operand:SF 3 "register_operand" "f")
5201                   (mult:SF (match_operand:SF 1 "register_operand" "f")
5202                            (match_operand:SF 2 "register_operand" "f"))))
5203    (set (match_operand:SF 4 "register_operand" "=&f")
5204         (mult:SF (match_dup 1) (match_dup 2)))]
5205   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
5206     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
5207           || reg_overlap_mentioned_p (operands[4], operands[2])))"
5208   "#"
5209   [(set_attr "type" "fpmuldbl")
5210    (set_attr "length" "8")])
5211
5212 (define_split
5213   [(set (match_operand:SF 0 "register_operand" "")
5214         (minus:SF (match_operand:SF 3 "register_operand" "")
5215                   (mult:SF (match_operand:SF 1 "register_operand" "")
5216                            (match_operand:SF 2 "register_operand" ""))))
5217    (set (match_operand:SF 4 "register_operand" "")
5218         (mult:SF (match_dup 1) (match_dup 2)))]
5219   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5220   [(set (match_dup 4) (mult:SF (match_dup 1) (match_dup 2)))
5221    (set (match_dup 0) (minus:SF (match_dup 3)
5222                                 (mult:SF (match_dup 1) (match_dup 2))))]
5223   "")
5224
5225 (define_insn ""
5226   [(set (match_operand:DF 0 "register_operand" "=f")
5227         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))
5228    (set (match_operand:DF 2 "register_operand" "=&f") (abs:DF (match_dup 1)))]
5229   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
5230     && ! reg_overlap_mentioned_p (operands[2], operands[1]))"
5231   "#"
5232   [(set_attr "type" "fpalu")
5233    (set_attr "length" "8")])
5234
5235 (define_split
5236   [(set (match_operand:DF 0 "register_operand" "")
5237         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" ""))))
5238    (set (match_operand:DF 2 "register_operand" "") (abs:DF (match_dup 1)))]
5239   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5240   [(set (match_dup 2) (abs:DF (match_dup 1)))
5241    (set (match_dup 0) (neg:DF (abs:DF (match_dup 1))))]
5242   "")
5243
5244 (define_insn ""
5245   [(set (match_operand:SF 0 "register_operand" "=f")
5246         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))
5247    (set (match_operand:SF 2 "register_operand" "=&f") (abs:SF (match_dup 1)))]
5248   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
5249     && ! reg_overlap_mentioned_p (operands[2], operands[1]))"
5250   "#"
5251   [(set_attr "type" "fpalu")
5252    (set_attr "length" "8")])
5253
5254 (define_split
5255   [(set (match_operand:SF 0 "register_operand" "")
5256         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" ""))))
5257    (set (match_operand:SF 2 "register_operand" "") (abs:SF (match_dup 1)))]
5258   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5259   [(set (match_dup 2) (abs:SF (match_dup 1)))
5260    (set (match_dup 0) (neg:SF (abs:SF (match_dup 1))))]
5261   "")
5262 \f
5263 ;;- Shift instructions
5264
5265 ;; Optimized special case of shifting.
5266
5267 (define_insn ""
5268   [(set (match_operand:SI 0 "register_operand" "=r")
5269         (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
5270                      (const_int 24)))]
5271   ""
5272   "ldb%M1 %1,%0"
5273   [(set_attr "type" "load")
5274    (set_attr "length" "4")])
5275
5276 (define_insn ""
5277   [(set (match_operand:SI 0 "register_operand" "=r")
5278         (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
5279                      (const_int 16)))]
5280   ""
5281   "ldh%M1 %1,%0"
5282   [(set_attr "type" "load")
5283    (set_attr "length" "4")])
5284
5285 (define_insn ""
5286   [(set (match_operand:SI 0 "register_operand" "=r")
5287         (plus:SI (mult:SI (match_operand:SI 2 "register_operand" "r")
5288                           (match_operand:SI 3 "shadd_operand" ""))
5289                  (match_operand:SI 1 "register_operand" "r")))]
5290   ""
5291   "{sh%O3addl %2,%1,%0|shladd,l %2,%O3,%1,%0} "
5292   [(set_attr "type" "binary")
5293    (set_attr "length" "4")])
5294
5295 (define_insn ""
5296   [(set (match_operand:DI 0 "register_operand" "=r")
5297         (plus:DI (mult:DI (match_operand:DI 2 "register_operand" "r")
5298                           (match_operand:DI 3 "shadd_operand" ""))
5299                  (match_operand:DI 1 "register_operand" "r")))]
5300   "TARGET_64BIT"
5301   "shladd,l %2,%O3,%1,%0"
5302   [(set_attr "type" "binary")
5303    (set_attr "length" "4")])
5304
5305 (define_expand "ashlsi3"
5306   [(set (match_operand:SI 0 "register_operand" "")
5307         (ashift:SI (match_operand:SI 1 "lhs_lshift_operand" "")
5308                    (match_operand:SI 2 "arith32_operand" "")))]
5309   ""
5310   "
5311 {
5312   if (GET_CODE (operands[2]) != CONST_INT)
5313     {
5314       rtx temp = gen_reg_rtx (SImode);
5315       emit_insn (gen_subsi3 (temp, GEN_INT (31), operands[2]));
5316       if (GET_CODE (operands[1]) == CONST_INT)
5317         emit_insn (gen_zvdep_imm32 (operands[0], operands[1], temp));
5318       else
5319         emit_insn (gen_zvdep32 (operands[0], operands[1], temp));
5320       DONE;
5321     }
5322   /* Make sure both inputs are not constants,
5323      there are no patterns for that.  */
5324   operands[1] = force_reg (SImode, operands[1]);
5325 }")
5326
5327 (define_insn ""
5328   [(set (match_operand:SI 0 "register_operand" "=r")
5329         (ashift:SI (match_operand:SI 1 "register_operand" "r")
5330                    (match_operand:SI 2 "const_int_operand" "n")))]
5331   ""
5332   "{zdep|depw,z} %1,%P2,%L2,%0"
5333   [(set_attr "type" "shift")
5334    (set_attr "length" "4")])
5335
5336 ; Match cases of op1 a CONST_INT here that zvdep_imm32 doesn't handle.
5337 ; Doing it like this makes slightly better code since reload can
5338 ; replace a register with a known value in range -16..15 with a
5339 ; constant.  Ideally, we would like to merge zvdep32 and zvdep_imm32,
5340 ; but since we have no more CONST_OK... characters, that is not
5341 ; possible.
5342 (define_insn "zvdep32"
5343   [(set (match_operand:SI 0 "register_operand" "=r,r")
5344         (ashift:SI (match_operand:SI 1 "arith5_operand" "r,L")
5345                    (minus:SI (const_int 31)
5346                              (match_operand:SI 2 "register_operand" "q,q"))))]
5347   ""
5348   "@
5349    {zvdep %1,32,%0|depw,z %1,%%sar,32,%0}
5350    {zvdepi %1,32,%0|depwi,z %1,%%sar,32,%0}"
5351   [(set_attr "type" "shift,shift")
5352    (set_attr "length" "4,4")])
5353
5354 (define_insn "zvdep_imm32"
5355   [(set (match_operand:SI 0 "register_operand" "=r")
5356         (ashift:SI (match_operand:SI 1 "lhs_lshift_cint_operand" "")
5357                    (minus:SI (const_int 31)
5358                              (match_operand:SI 2 "register_operand" "q"))))]
5359   ""
5360   "*
5361 {
5362   int x = INTVAL (operands[1]);
5363   operands[2] = GEN_INT (4 + exact_log2 ((x >> 4) + 1));
5364   operands[1] = GEN_INT ((x & 0xf) - 0x10);
5365   return \"{zvdepi %1,%2,%0|depwi,z %1,%%sar,%2,%0}\";
5366 }"
5367   [(set_attr "type" "shift")
5368    (set_attr "length" "4")])
5369
5370 (define_insn "vdepi_ior"
5371   [(set (match_operand:SI 0 "register_operand" "=r")
5372         (ior:SI (ashift:SI (match_operand:SI 1 "const_int_operand" "")
5373                            (minus:SI (const_int 31)
5374                                      (match_operand:SI 2 "register_operand" "q")))
5375                 (match_operand:SI 3 "register_operand" "0")))]
5376   ; accept ...0001...1, can this be generalized?
5377   "exact_log2 (INTVAL (operands[1]) + 1) >= 0"
5378   "*
5379 {
5380   int x = INTVAL (operands[1]);
5381   operands[2] = GEN_INT (exact_log2 (x + 1));
5382   return \"{vdepi -1,%2,%0|depwi -1,%%sar,%2,%0}\";
5383 }"
5384   [(set_attr "type" "shift")
5385    (set_attr "length" "4")])
5386
5387 (define_insn "vdepi_and"
5388   [(set (match_operand:SI 0 "register_operand" "=r")
5389         (and:SI (rotate:SI (match_operand:SI 1 "const_int_operand" "")
5390                            (minus:SI (const_int 31)
5391                                      (match_operand:SI 2 "register_operand" "q")))
5392                 (match_operand:SI 3 "register_operand" "0")))]
5393   ; this can be generalized...!
5394   "INTVAL (operands[1]) == -2"
5395   "*
5396 {
5397   int x = INTVAL (operands[1]);
5398   operands[2] = GEN_INT (exact_log2 ((~x) + 1));
5399   return \"{vdepi 0,%2,%0|depwi 0,%%sar,%2,%0}\";
5400 }"
5401   [(set_attr "type" "shift")
5402    (set_attr "length" "4")])
5403
5404 (define_expand "ashldi3"
5405   [(set (match_operand:DI 0 "register_operand" "")
5406         (ashift:DI (match_operand:DI 1 "lhs_lshift_operand" "")
5407                    (match_operand:DI 2 "arith32_operand" "")))]
5408   "TARGET_64BIT"
5409   "
5410 {
5411   if (GET_CODE (operands[2]) != CONST_INT)
5412     {
5413       rtx temp = gen_reg_rtx (DImode);
5414       emit_insn (gen_subdi3 (temp, GEN_INT (63), operands[2]));
5415       if (GET_CODE (operands[1]) == CONST_INT)
5416         emit_insn (gen_zvdep_imm64 (operands[0], operands[1], temp));
5417       else
5418         emit_insn (gen_zvdep64 (operands[0], operands[1], temp));
5419       DONE;
5420     }
5421   /* Make sure both inputs are not constants,
5422      there are no patterns for that.  */
5423   operands[1] = force_reg (DImode, operands[1]);
5424 }")
5425
5426 (define_insn ""
5427   [(set (match_operand:DI 0 "register_operand" "=r")
5428         (ashift:DI (match_operand:DI 1 "register_operand" "r")
5429                    (match_operand:DI 2 "const_int_operand" "n")))]
5430   "TARGET_64BIT"
5431   "depd,z %1,%p2,%Q2,%0"
5432   [(set_attr "type" "shift")
5433    (set_attr "length" "4")])
5434
5435 ; Match cases of op1 a CONST_INT here that zvdep_imm64 doesn't handle.
5436 ; Doing it like this makes slightly better code since reload can
5437 ; replace a register with a known value in range -16..15 with a
5438 ; constant.  Ideally, we would like to merge zvdep64 and zvdep_imm64,
5439 ; but since we have no more CONST_OK... characters, that is not
5440 ; possible.
5441 (define_insn "zvdep64"
5442   [(set (match_operand:DI 0 "register_operand" "=r,r")
5443         (ashift:DI (match_operand:DI 1 "arith5_operand" "r,L")
5444                    (minus:DI (const_int 63)
5445                              (match_operand:DI 2 "register_operand" "q,q"))))]
5446   "TARGET_64BIT"
5447   "@
5448    depd,z %1,%%sar,64,%0
5449    depdi,z %1,%%sar,64,%0"
5450   [(set_attr "type" "shift,shift")
5451    (set_attr "length" "4,4")])
5452
5453 (define_insn "zvdep_imm64"
5454   [(set (match_operand:DI 0 "register_operand" "=r")
5455         (ashift:DI (match_operand:DI 1 "lhs_lshift_cint_operand" "")
5456                    (minus:DI (const_int 63)
5457                              (match_operand:DI 2 "register_operand" "q"))))]
5458   "TARGET_64BIT"
5459   "*
5460 {
5461   int x = INTVAL (operands[1]);
5462   operands[2] = GEN_INT (4 + exact_log2 ((x >> 4) + 1));
5463   operands[1] = GEN_INT ((x & 0x1f) - 0x20);
5464   return \"depdi,z %1,%%sar,%2,%0\";
5465 }"
5466   [(set_attr "type" "shift")
5467    (set_attr "length" "4")])
5468
5469 (define_insn ""
5470   [(set (match_operand:DI 0 "register_operand" "=r")
5471         (ior:DI (ashift:DI (match_operand:DI 1 "const_int_operand" "")
5472                            (minus:DI (const_int 63)
5473                                      (match_operand:DI 2 "register_operand" "q")))
5474                 (match_operand:DI 3 "register_operand" "0")))]
5475   ; accept ...0001...1, can this be generalized?
5476   "TARGET_64BIT && exact_log2 (INTVAL (operands[1]) + 1) >= 0"
5477   "*
5478 {
5479   int x = INTVAL (operands[1]);
5480   operands[2] = GEN_INT (exact_log2 (x + 1));
5481   return \"depdi -1,%%sar,%2,%0\";
5482 }"
5483   [(set_attr "type" "shift")
5484    (set_attr "length" "4")])
5485
5486 (define_insn ""
5487   [(set (match_operand:DI 0 "register_operand" "=r")
5488         (and:DI (rotate:DI (match_operand:DI 1 "const_int_operand" "")
5489                            (minus:DI (const_int 63)
5490                                      (match_operand:DI 2 "register_operand" "q")))
5491                 (match_operand:DI 3 "register_operand" "0")))]
5492   ; this can be generalized...!
5493   "TARGET_64BIT && INTVAL (operands[1]) == -2"
5494   "*
5495 {
5496   int x = INTVAL (operands[1]);
5497   operands[2] = GEN_INT (exact_log2 ((~x) + 1));
5498   return \"depdi 0,%%sar,%2,%0\";
5499 }"
5500   [(set_attr "type" "shift")
5501    (set_attr "length" "4")])
5502
5503 (define_expand "ashrsi3"
5504   [(set (match_operand:SI 0 "register_operand" "")
5505         (ashiftrt:SI (match_operand:SI 1 "register_operand" "")
5506                      (match_operand:SI 2 "arith32_operand" "")))]
5507   ""
5508   "
5509 {
5510   if (GET_CODE (operands[2]) != CONST_INT)
5511     {
5512       rtx temp = gen_reg_rtx (SImode);
5513       emit_insn (gen_subsi3 (temp, GEN_INT (31), operands[2]));
5514       emit_insn (gen_vextrs32 (operands[0], operands[1], temp));
5515       DONE;
5516     }
5517 }")
5518
5519 (define_insn ""
5520   [(set (match_operand:SI 0 "register_operand" "=r")
5521         (ashiftrt:SI (match_operand:SI 1 "register_operand" "r")
5522                      (match_operand:SI 2 "const_int_operand" "n")))]
5523   ""
5524   "{extrs|extrw,s} %1,%P2,%L2,%0"
5525   [(set_attr "type" "shift")
5526    (set_attr "length" "4")])
5527
5528 (define_insn "vextrs32"
5529   [(set (match_operand:SI 0 "register_operand" "=r")
5530         (ashiftrt:SI (match_operand:SI 1 "register_operand" "r")
5531                      (minus:SI (const_int 31)
5532                                (match_operand:SI 2 "register_operand" "q"))))]
5533   ""
5534   "{vextrs %1,32,%0|extrw,s %1,%%sar,32,%0}"
5535   [(set_attr "type" "shift")
5536    (set_attr "length" "4")])
5537
5538 (define_expand "ashrdi3"
5539   [(set (match_operand:DI 0 "register_operand" "")
5540         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
5541                      (match_operand:DI 2 "arith32_operand" "")))]
5542   "TARGET_64BIT"
5543   "
5544 {
5545   if (GET_CODE (operands[2]) != CONST_INT)
5546     {
5547       rtx temp = gen_reg_rtx (DImode);
5548       emit_insn (gen_subdi3 (temp, GEN_INT (63), operands[2]));
5549       emit_insn (gen_vextrs64 (operands[0], operands[1], temp));
5550       DONE;
5551     }
5552 }")
5553
5554 (define_insn ""
5555   [(set (match_operand:DI 0 "register_operand" "=r")
5556         (ashiftrt:DI (match_operand:DI 1 "register_operand" "r")
5557                      (match_operand:DI 2 "const_int_operand" "n")))]
5558   "TARGET_64BIT"
5559   "extrd,s %1,%p2,%Q2,%0"
5560   [(set_attr "type" "shift")
5561    (set_attr "length" "4")])
5562
5563 (define_insn "vextrs64"
5564   [(set (match_operand:DI 0 "register_operand" "=r")
5565         (ashiftrt:DI (match_operand:DI 1 "register_operand" "r")
5566                      (minus:DI (const_int 63)
5567                                (match_operand:DI 2 "register_operand" "q"))))]
5568   "TARGET_64BIT"
5569   "extrd,s %1,%%sar,64,%0"
5570   [(set_attr "type" "shift")
5571    (set_attr "length" "4")])
5572
5573 (define_insn "lshrsi3"
5574   [(set (match_operand:SI 0 "register_operand" "=r,r")
5575         (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
5576                      (match_operand:SI 2 "arith32_operand" "q,n")))]
5577   ""
5578   "@
5579    {vshd %%r0,%1,%0|shrpw %%r0,%1,%%sar,%0}
5580    {extru|extrw,u} %1,%P2,%L2,%0"
5581   [(set_attr "type" "shift")
5582    (set_attr "length" "4")])
5583
5584 (define_insn "lshrdi3"
5585   [(set (match_operand:DI 0 "register_operand" "=r,r")
5586         (lshiftrt:DI (match_operand:DI 1 "register_operand" "r,r")
5587                      (match_operand:DI 2 "arith32_operand" "q,n")))]
5588   "TARGET_64BIT"
5589   "@
5590    shrpd %%r0,%1,%%sar,%0
5591    extrd,u %1,%p2,%Q2,%0"
5592   [(set_attr "type" "shift")
5593    (set_attr "length" "4")])
5594
5595 (define_insn "rotrsi3"
5596   [(set (match_operand:SI 0 "register_operand" "=r,r")
5597         (rotatert:SI (match_operand:SI 1 "register_operand" "r,r")
5598                      (match_operand:SI 2 "arith32_operand" "q,n")))]
5599   ""
5600   "*
5601 {
5602   if (GET_CODE (operands[2]) == CONST_INT)
5603     {
5604       operands[2] = GEN_INT (INTVAL (operands[2]) & 31);
5605       return \"{shd|shrpw} %1,%1,%2,%0\";
5606     }
5607   else
5608     return \"{vshd %1,%1,%0|shrpw %1,%1,%%sar,%0}\";
5609 }"
5610   [(set_attr "type" "shift")
5611    (set_attr "length" "4")])
5612
5613 (define_expand "rotlsi3"
5614   [(set (match_operand:SI 0 "register_operand" "")
5615         (rotate:SI (match_operand:SI 1 "register_operand" "")
5616                    (match_operand:SI 2 "arith32_operand" "")))]
5617   ""
5618   "
5619 {
5620   if (GET_CODE (operands[2]) != CONST_INT)
5621     {
5622       rtx temp = gen_reg_rtx (SImode);
5623       emit_insn (gen_subsi3 (temp, GEN_INT (32), operands[2]));
5624       emit_insn (gen_rotrsi3 (operands[0], operands[1], temp));
5625       DONE;
5626     }
5627   /* Else expand normally.  */
5628 }")
5629
5630 (define_insn ""
5631   [(set (match_operand:SI 0 "register_operand" "=r")
5632         (rotate:SI (match_operand:SI 1 "register_operand" "r")
5633                    (match_operand:SI 2 "const_int_operand" "n")))]
5634   ""
5635   "*
5636 {
5637   operands[2] = GEN_INT ((32 - INTVAL (operands[2])) & 31);
5638   return \"{shd|shrpw} %1,%1,%2,%0\";
5639 }"
5640   [(set_attr "type" "shift")
5641    (set_attr "length" "4")])
5642
5643 (define_insn ""
5644   [(set (match_operand:SI 0 "register_operand" "=r")
5645         (match_operator:SI 5 "plus_xor_ior_operator"
5646           [(ashift:SI (match_operand:SI 1 "register_operand" "r")
5647                       (match_operand:SI 3 "const_int_operand" "n"))
5648            (lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
5649                         (match_operand:SI 4 "const_int_operand" "n"))]))]
5650   "INTVAL (operands[3]) + INTVAL (operands[4]) == 32"
5651   "{shd|shrpw} %1,%2,%4,%0"
5652   [(set_attr "type" "shift")
5653    (set_attr "length" "4")])
5654
5655 (define_insn ""
5656   [(set (match_operand:SI 0 "register_operand" "=r")
5657         (match_operator:SI 5 "plus_xor_ior_operator"
5658           [(lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
5659                         (match_operand:SI 4 "const_int_operand" "n"))
5660            (ashift:SI (match_operand:SI 1 "register_operand" "r")
5661                       (match_operand:SI 3 "const_int_operand" "n"))]))]
5662   "INTVAL (operands[3]) + INTVAL (operands[4]) == 32"
5663   "{shd|shrpw} %1,%2,%4,%0"
5664   [(set_attr "type" "shift")
5665    (set_attr "length" "4")])
5666
5667 (define_insn ""
5668   [(set (match_operand:SI 0 "register_operand" "=r")
5669         (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
5670                            (match_operand:SI 2 "const_int_operand" ""))
5671                 (match_operand:SI 3 "const_int_operand" "")))]
5672   "exact_log2 (1 + (INTVAL (operands[3]) >> (INTVAL (operands[2]) & 31))) >= 0"
5673   "*
5674 {
5675   int cnt = INTVAL (operands[2]) & 31;
5676   operands[3] = GEN_INT (exact_log2 (1 + (INTVAL (operands[3]) >> cnt)));
5677   operands[2] = GEN_INT (31 - cnt);
5678   return \"{zdep|depw,z} %1,%2,%3,%0\";
5679 }"
5680   [(set_attr "type" "shift")
5681    (set_attr "length" "4")])
5682 \f
5683 ;; Unconditional and other jump instructions.
5684
5685 ;; This can only be used in a leaf function, so we do
5686 ;; not need to use the PIC register when generating PIC code.
5687 (define_insn "return"
5688   [(return)
5689    (use (reg:SI 2))
5690    (const_int 0)]
5691   "hppa_can_use_return_insn_p ()"
5692   "*
5693 {
5694   if (TARGET_PA_20)
5695     return \"bve%* (%%r2)\";
5696   return \"bv%* %%r0(%%r2)\";
5697 }"
5698   [(set_attr "type" "branch")
5699    (set_attr "length" "4")])
5700
5701 ;; Emit a different pattern for functions which have non-trivial
5702 ;; epilogues so as not to confuse jump and reorg.
5703 (define_insn "return_internal"
5704   [(return)
5705    (use (reg:SI 2))
5706    (const_int 1)]
5707   "! flag_pic"
5708   "*
5709 {
5710   if (TARGET_PA_20)
5711     return \"bve%* (%%r2)\";
5712   return \"bv%* %%r0(%%r2)\";
5713 }"
5714   [(set_attr "type" "branch")
5715    (set_attr "length" "4")])
5716
5717 ;; Use the PIC register to ensure it's restored after a
5718 ;; call in PIC mode.
5719 (define_insn "return_internal_pic"
5720   [(return)
5721    (use (match_operand 0 "register_operand" "r"))
5722    (use (reg:SI 2))]
5723   "flag_pic && true_regnum (operands[0]) == PIC_OFFSET_TABLE_REGNUM"
5724   "*
5725 {
5726   if (TARGET_PA_20)
5727     return \"bve%* (%%r2)\";
5728   return \"bv%* %%r0(%%r2)\";
5729 }"
5730   [(set_attr "type" "branch")
5731    (set_attr "length" "4")])
5732
5733 ;; Use the PIC register to ensure it's restored after a
5734 ;; call in PIC mode.  This is used for eh returns which
5735 ;; bypass the return stub.
5736 (define_insn "return_external_pic"
5737   [(return)
5738    (use (match_operand 0 "register_operand" "r"))
5739    (use (reg:SI 2))
5740    (clobber (reg:SI 1))]
5741   "flag_pic
5742    && current_function_calls_eh_return
5743    && true_regnum (operands[0]) == PIC_OFFSET_TABLE_REGNUM"
5744   "ldsid (%%sr0,%%r2),%%r1\;mtsp %%r1,%%sr0\;be%* 0(%%sr0,%%r2)"
5745   [(set_attr "type" "branch")
5746    (set_attr "length" "12")])
5747
5748 (define_expand "prologue"
5749   [(const_int 0)]
5750   ""
5751   "hppa_expand_prologue ();DONE;")
5752
5753 (define_expand "sibcall_epilogue"
5754   [(return)]
5755   ""
5756   "
5757 {
5758   hppa_expand_epilogue ();
5759   DONE;
5760 }")
5761
5762 (define_expand "epilogue"
5763   [(return)]
5764   ""
5765   "
5766 {
5767   /* Try to use the trivial return first.  Else use the full
5768      epilogue.  */
5769   if (hppa_can_use_return_insn_p ())
5770     emit_jump_insn (gen_return ());
5771   else
5772     {
5773       rtx x;
5774
5775       hppa_expand_epilogue ();
5776       if (flag_pic)
5777         {
5778           rtx pic = gen_rtx_REG (word_mode, PIC_OFFSET_TABLE_REGNUM);
5779
5780           /* EH returns bypass the normal return stub.  Thus, we must do an
5781              interspace branch to return from functions that call eh_return.
5782              This is only a problem for returns from shared code.  */
5783           if (current_function_calls_eh_return)
5784             x = gen_return_external_pic (pic);
5785           else
5786             x = gen_return_internal_pic (pic);
5787         }
5788       else
5789         x = gen_return_internal ();
5790       emit_jump_insn (x);
5791     }
5792   DONE;
5793 }")
5794
5795 ;; Special because we use the value placed in %r2 by the bl instruction
5796 ;; from within its delay slot to set the value for the 2nd parameter to
5797 ;; the call.
5798 (define_insn "call_profiler"
5799   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
5800          (match_operand 1 "" ""))
5801    (use (match_operand 2 "" ""))
5802    (use (reg:SI 25))
5803    (use (reg:SI 26))
5804    (clobber (reg:SI 2))]
5805   ""
5806   "*
5807 {
5808   rtx xoperands[3];
5809
5810   output_arg_descriptor (insn);
5811
5812   xoperands[0] = operands[0];
5813   xoperands[1] = operands[2];
5814   xoperands[2] = gen_label_rtx ();
5815   output_asm_insn (\"{bl|b,l} %0,%%r2\;ldo %1-%2(%%r2),%%r25\", xoperands);
5816
5817   ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\",
5818                              CODE_LABEL_NUMBER (xoperands[2]));
5819   return \"\";
5820 }"
5821   [(set_attr "type" "multi")
5822    (set_attr "length" "8")])
5823
5824 (define_insn "blockage"
5825   [(unspec_volatile [(const_int 2)] 0)]
5826   ""
5827   ""
5828   [(set_attr "length" "0")])
5829
5830 (define_insn "jump"
5831   [(set (pc) (label_ref (match_operand 0 "" "")))]
5832   ""
5833   "*
5834 {
5835   extern int optimize;
5836
5837   if (GET_MODE (insn) == SImode)
5838     return \"b %l0%#\";
5839
5840   /* An unconditional branch which can reach its target.  */
5841   if (get_attr_length (insn) != 24
5842       && get_attr_length (insn) != 16)
5843     return \"b%* %l0\";
5844
5845   /* An unconditional branch which can not reach its target.
5846
5847      We need to be able to use %r1 as a scratch register; however,
5848      we can never be sure whether or not it's got a live value in
5849      it.  Therefore, we must restore its original value after the
5850      jump.
5851
5852      To make matters worse, we don't have a stack slot which we
5853      can always clobber.  sp-12/sp-16 shouldn't ever have a live
5854      value during a non-optimizing compilation, so we use those
5855      slots for now.  We don't support very long branches when
5856      optimizing -- they should be quite rare when optimizing.
5857
5858      Really the way to go long term is a register scavenger; goto
5859      the target of the jump and find a register which we can use
5860      as a scratch to hold the value in %r1.  */
5861
5862   /* We don't know how to register scavenge yet.  */
5863   if (optimize)
5864     abort ();
5865
5866   /* First store %r1 into the stack.  */
5867   output_asm_insn (\"stw %%r1,-16(%%r30)\", operands);
5868
5869   /* Now load the target address into %r1 and do an indirect jump
5870      to the value specified in %r1.  Be careful to generate PIC
5871      code as needed.  */
5872   if (flag_pic)
5873     {
5874       rtx xoperands[2];
5875       xoperands[0] = operands[0];
5876       if (TARGET_SOM || ! TARGET_GAS)
5877         {
5878           xoperands[1] = gen_label_rtx ();
5879
5880           output_asm_insn (\"{bl|b,l} .+8,%%r1\\n\\taddil L'%l0-%l1,%%r1\",
5881                            xoperands);
5882           ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\",
5883                                      CODE_LABEL_NUMBER (xoperands[1]));
5884           output_asm_insn (\"ldo R'%l0-%l1(%%r1),%%r1\", xoperands);
5885         }
5886       else
5887         {
5888           output_asm_insn (\"{bl|b,l} .+8,%%r1\", xoperands);
5889           output_asm_insn (\"addil L'%l0-$PIC_pcrel$0+4,%%r1\", xoperands);
5890           output_asm_insn (\"ldo R'%l0-$PIC_pcrel$0+8(%%r1),%%r1\", xoperands);
5891         }
5892       output_asm_insn (\"bv %%r0(%%r1)\", xoperands);
5893     }
5894   else
5895     output_asm_insn (\"ldil L'%l0,%%r1\\n\\tbe R'%l0(%%sr4,%%r1)\", operands);;
5896
5897   /* And restore the value of %r1 in the delay slot.  We're not optimizing,
5898      so we know nothing else can be in the delay slot.  */
5899   return \"ldw -16(%%r30),%%r1\";
5900 }"
5901   [(set_attr "type" "uncond_branch")
5902    (set_attr "pa_combine_type" "uncond_branch")
5903    (set (attr "length")
5904     (cond [(eq (symbol_ref "jump_in_call_delay (insn)") (const_int 1))
5905            (if_then_else (lt (abs (minus (match_dup 0)
5906                                          (plus (pc) (const_int 8))))
5907                              (const_int 8184))
5908                          (const_int 4)
5909                          (const_int 8))
5910            (ge (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
5911                (const_int 262100))
5912            (if_then_else (eq (symbol_ref "flag_pic") (const_int 0))
5913                          (const_int 16)
5914                          (const_int 24))]
5915           (const_int 4)))])
5916
5917 ;; Subroutines of "casesi".
5918 ;; operand 0 is index
5919 ;; operand 1 is the minimum bound
5920 ;; operand 2 is the maximum bound - minimum bound + 1
5921 ;; operand 3 is CODE_LABEL for the table;
5922 ;; operand 4 is the CODE_LABEL to go to if index out of range.
5923
5924 (define_expand "casesi"
5925   [(match_operand:SI 0 "general_operand" "")
5926    (match_operand:SI 1 "const_int_operand" "")
5927    (match_operand:SI 2 "const_int_operand" "")
5928    (match_operand 3 "" "")
5929    (match_operand 4 "" "")]
5930   ""
5931   "
5932 {
5933   if (GET_CODE (operands[0]) != REG)
5934     operands[0] = force_reg (SImode, operands[0]);
5935
5936   if (operands[1] != const0_rtx)
5937     {
5938       rtx reg = gen_reg_rtx (SImode);
5939
5940       operands[1] = GEN_INT (-INTVAL (operands[1]));
5941       if (!INT_14_BITS (operands[1]))
5942         operands[1] = force_reg (SImode, operands[1]);
5943       emit_insn (gen_addsi3 (reg, operands[0], operands[1]));
5944
5945       operands[0] = reg;
5946     }
5947
5948   /* In 64bit mode we must make sure to wipe the upper bits of the register
5949      just in case the addition overflowed or we had random bits in the
5950      high part of the register.  */
5951   if (TARGET_64BIT)
5952     {
5953       rtx reg = gen_reg_rtx (DImode);
5954       emit_insn (gen_extendsidi2 (reg, operands[0]));
5955       operands[0] = gen_rtx_SUBREG (SImode, reg, 4);
5956     }
5957
5958   if (!INT_5_BITS (operands[2]))
5959     operands[2] = force_reg (SImode, operands[2]);
5960
5961   emit_insn (gen_cmpsi (operands[0], operands[2]));
5962   emit_jump_insn (gen_bgtu (operands[4]));
5963   if (TARGET_BIG_SWITCH)
5964     {
5965       rtx temp = gen_reg_rtx (SImode);
5966       emit_move_insn (temp, gen_rtx_PLUS (SImode, operands[0], operands[0]));
5967       operands[0] = temp;
5968     }
5969   emit_jump_insn (gen_casesi0 (operands[0], operands[3]));
5970   DONE;
5971 }")
5972
5973 (define_insn "casesi0"
5974   [(set (pc) (plus:SI
5975                (mem:SI (plus:SI (pc)
5976                                 (match_operand:SI 0 "register_operand" "r")))
5977                (label_ref (match_operand 1 "" ""))))]
5978   ""
5979   "blr %0,%%r0\;nop"
5980   [(set_attr "type" "multi")
5981    (set_attr "length" "8")])
5982
5983 ;; Need nops for the calls because execution is supposed to continue
5984 ;; past; we don't want to nullify an instruction that we need.
5985 ;;- jump to subroutine
5986
5987 (define_expand "call"
5988   [(parallel [(call (match_operand:SI 0 "" "")
5989                     (match_operand 1 "" ""))
5990               (clobber (reg:SI 2))])]
5991   ""
5992   "
5993 {
5994   rtx op;
5995   rtx call_insn;
5996
5997   if (TARGET_PORTABLE_RUNTIME)
5998     op = force_reg (SImode, XEXP (operands[0], 0));
5999   else
6000     op = XEXP (operands[0], 0);
6001
6002   if (TARGET_64BIT)
6003     emit_move_insn (arg_pointer_rtx,
6004                     gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
6005                                   GEN_INT (64)));
6006
6007   /* Use two different patterns for calls to explicitly named functions
6008      and calls through function pointers.  This is necessary as these two
6009      types of calls use different calling conventions, and CSE might try
6010      to change the named call into an indirect call in some cases (using
6011      two patterns keeps CSE from performing this optimization).  */
6012   if (GET_CODE (op) == SYMBOL_REF)
6013     call_insn = emit_call_insn (gen_call_internal_symref (op, operands[1]));
6014   else if (TARGET_64BIT)
6015     {
6016       rtx tmpreg = force_reg (word_mode, op);
6017       call_insn = emit_call_insn (gen_call_internal_reg_64bit (tmpreg,
6018                                                                operands[1]));
6019     }
6020   else
6021     {
6022       rtx tmpreg = gen_rtx_REG (word_mode, 22);
6023       emit_move_insn (tmpreg, force_reg (word_mode, op));
6024       call_insn = emit_call_insn (gen_call_internal_reg (operands[1]));
6025     }
6026
6027   if (flag_pic)
6028     {
6029       use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
6030       if (TARGET_64BIT)
6031         use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), arg_pointer_rtx);
6032
6033       /* After each call we must restore the PIC register, even if it
6034          doesn't appear to be used.  */
6035       emit_move_insn (pic_offset_table_rtx, hppa_pic_save_rtx ());
6036     }
6037   DONE;
6038 }")
6039
6040 (define_insn "call_internal_symref"
6041   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
6042          (match_operand 1 "" "i"))
6043    (clobber (reg:SI 2))
6044    (use (const_int 0))]
6045   "! TARGET_PORTABLE_RUNTIME"
6046   "*
6047 {
6048   output_arg_descriptor (insn);
6049   return output_call (insn, operands[0], 0);
6050 }"
6051   [(set_attr "type" "call")
6052    (set (attr "length")
6053 ;;       If we're sure that we can either reach the target or that the
6054 ;;       linker can use a long-branch stub, then the length is at most
6055 ;;       8 bytes.
6056 ;;
6057 ;;       For long-calls the length will be at most 68 bytes (non-pic)
6058 ;;       or 84 bytes (pic).  */
6059 ;;       Else we have to use a long-call;
6060       (if_then_else (lt (plus (symbol_ref "total_code_bytes") (pc))
6061                         (const_int 240000))
6062                     (const_int 8)
6063                     (if_then_else (eq (symbol_ref "flag_pic")
6064                                       (const_int 0))
6065                                   (const_int 68)
6066                                   (const_int 84))))])
6067
6068 (define_insn "call_internal_reg_64bit"
6069   [(call (mem:SI (match_operand:DI 0 "register_operand" "r"))
6070          (match_operand 1 "" "i"))
6071    (clobber (reg:SI 2))
6072    (use (const_int 1))]
6073   "TARGET_64BIT"
6074   "*
6075 {
6076   /* ??? Needs more work.  Length computation, split into multiple insns,
6077      do not use %r22 directly, expose delay slot.  */
6078   return \"ldd 16(%0),%%r2\;ldd 24(%0),%%r27\;bve,l (%%r2),%%r2\;nop\";
6079 }"
6080   [(set_attr "type" "dyncall")
6081    (set (attr "length") (const_int 16))])
6082
6083 (define_insn "call_internal_reg"
6084   [(call (mem:SI (reg:SI 22))
6085          (match_operand 0 "" "i"))
6086    (clobber (reg:SI 2))
6087    (use (const_int 1))]
6088   ""
6089   "*
6090 {
6091   rtx xoperands[2];
6092
6093   /* First the special case for kernels, level 0 systems, etc.  */
6094   if (TARGET_FAST_INDIRECT_CALLS)
6095     return \"ble 0(%%sr4,%%r22)\;copy %%r31,%%r2\";
6096
6097   /* Now the normal case -- we can reach $$dyncall directly or
6098      we're sure that we can get there via a long-branch stub. 
6099
6100      No need to check target flags as the length uniquely identifies
6101      the remaining cases.  */
6102   if (get_attr_length (insn) == 8)
6103     return \".CALL\\tARGW0=GR\;{bl|b,l} $$dyncall,%%r31\;copy %%r31,%%r2\";
6104
6105   /* Long millicode call, but we are not generating PIC or portable runtime
6106      code.  */
6107   if (get_attr_length (insn) == 12)
6108     return \".CALL\\tARGW0=GR\;ldil L%%$$dyncall,%%r2\;ble R%%$$dyncall(%%sr4,%%r2)\;copy %%r31,%%r2\";
6109
6110   /* Long millicode call for portable runtime.  */
6111   if (get_attr_length (insn) == 20)
6112     return \"ldil L%%$$dyncall,%%r31\;ldo R%%$$dyncall(%%r31),%%r31\;blr %%r0,%%r2\;bv,n %%r0(%%r31)\;nop\";
6113
6114   /* If we're generating PIC code.  */
6115   xoperands[0] = operands[0];
6116   if (TARGET_SOM || ! TARGET_GAS)
6117     xoperands[1] = gen_label_rtx ();
6118   output_asm_insn (\"{bl|b,l} .+8,%%r1\", xoperands);
6119   if (TARGET_SOM || ! TARGET_GAS)
6120     {
6121       output_asm_insn (\"addil L%%$$dyncall-%1,%%r1\", xoperands);
6122       ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\",
6123                                  CODE_LABEL_NUMBER (xoperands[1]));
6124       output_asm_insn (\"ldo R%%$$dyncall-%1(%%r1),%%r1\", xoperands);
6125     }
6126   else
6127     {
6128       output_asm_insn (\"addil L%%$$dyncall-$PIC_pcrel$0+4,%%r1\", xoperands);
6129       output_asm_insn (\"ldo R%%$$dyncall-$PIC_pcrel$0+8(%%r1),%%r1\",
6130                        xoperands);
6131     }
6132   output_asm_insn (\"blr %%r0,%%r2\", xoperands);
6133   output_asm_insn (\"bv,n %%r0(%%r1)\\n\\tnop\", xoperands);
6134   return \"\";
6135 }"
6136   [(set_attr "type" "dyncall")
6137    (set (attr "length")
6138      (cond [
6139 ;; First FAST_INDIRECT_CALLS
6140             (ne (symbol_ref "TARGET_FAST_INDIRECT_CALLS")
6141                 (const_int 0))
6142             (const_int 8)
6143
6144 ;; Target (or stub) within reach
6145             (and (lt (plus (symbol_ref "total_code_bytes") (pc))
6146                      (const_int 240000))
6147                  (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
6148                      (const_int 0)))
6149             (const_int 8)
6150
6151 ;; Out of reach PIC
6152             (ne (symbol_ref "flag_pic")
6153                 (const_int 0))
6154             (const_int 24)
6155
6156 ;; Out of reach PORTABLE_RUNTIME
6157             (ne (symbol_ref "TARGET_PORTABLE_RUNTIME")
6158                 (const_int 0))
6159             (const_int 20)]
6160
6161 ;; Out of reach, can use ble
6162           (const_int 12)))])
6163
6164 (define_expand "call_value"
6165   [(parallel [(set (match_operand 0 "" "")
6166                    (call (match_operand:SI 1 "" "")
6167                          (match_operand 2 "" "")))
6168               (clobber (reg:SI 2))])]
6169   ""
6170   "
6171 {
6172   rtx op;
6173   rtx call_insn;
6174
6175   if (TARGET_PORTABLE_RUNTIME)
6176     op = force_reg (word_mode, XEXP (operands[1], 0));
6177   else
6178     op = XEXP (operands[1], 0);
6179
6180   if (TARGET_64BIT)
6181     emit_move_insn (arg_pointer_rtx,
6182                     gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
6183                                   GEN_INT (64)));
6184
6185   /* Use two different patterns for calls to explicitly named functions
6186      and calls through function pointers.  This is necessary as these two
6187      types of calls use different calling conventions, and CSE might try
6188      to change the named call into an indirect call in some cases (using
6189      two patterns keeps CSE from performing this optimization).  */
6190   if (GET_CODE (op) == SYMBOL_REF)
6191     call_insn = emit_call_insn (gen_call_value_internal_symref (operands[0],
6192                                                                 op,
6193                                                                 operands[2]));
6194   else if (TARGET_64BIT)
6195     {
6196       rtx tmpreg = force_reg (word_mode, op);
6197       call_insn
6198         = emit_call_insn (gen_call_value_internal_reg_64bit (operands[0],
6199                                                              tmpreg,
6200                                                              operands[2]));
6201     }
6202   else
6203     {
6204       rtx tmpreg = gen_rtx_REG (word_mode, 22);
6205       emit_move_insn (tmpreg, force_reg (word_mode, op));
6206       call_insn = emit_call_insn (gen_call_value_internal_reg (operands[0],
6207                                                                operands[2]));
6208     }
6209   if (flag_pic)
6210     {
6211       use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
6212       if (TARGET_64BIT)
6213         use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), arg_pointer_rtx);
6214
6215       /* After each call we must restore the PIC register, even if it
6216          doesn't appear to be used.  */
6217       emit_move_insn (pic_offset_table_rtx, hppa_pic_save_rtx ());
6218     }
6219   DONE;
6220 }")
6221
6222 (define_insn "call_value_internal_symref"
6223   [(set (match_operand 0 "" "=rf")
6224         (call (mem:SI (match_operand 1 "call_operand_address" ""))
6225               (match_operand 2 "" "i")))
6226    (clobber (reg:SI 2))
6227    (use (const_int 0))]
6228   ;;- Don't use operand 1 for most machines.
6229   "! TARGET_PORTABLE_RUNTIME"
6230   "*
6231 {
6232   output_arg_descriptor (insn);
6233   return output_call (insn, operands[1], 0);
6234 }"
6235   [(set_attr "type" "call")
6236    (set (attr "length")
6237 ;;       If we're sure that we can either reach the target or that the
6238 ;;       linker can use a long-branch stub, then the length is at most
6239 ;;       8 bytes.
6240 ;;
6241 ;;       For long-calls the length will be at most 68 bytes (non-pic)
6242 ;;       or 84 bytes (pic).  */
6243 ;;       Else we have to use a long-call;
6244       (if_then_else (lt (plus (symbol_ref "total_code_bytes") (pc))
6245                         (const_int 240000))
6246                     (const_int 8)
6247                     (if_then_else (eq (symbol_ref "flag_pic")
6248                                       (const_int 0))
6249                                   (const_int 68)
6250                                   (const_int 84))))])
6251
6252 (define_insn "call_value_internal_reg_64bit"
6253   [(set (match_operand 0 "" "=rf")
6254          (call (mem:SI (match_operand:DI 1 "register_operand" "r"))
6255                (match_operand 2 "" "i")))
6256    (clobber (reg:SI 2))
6257    (use (const_int 1))]
6258   "TARGET_64BIT"
6259   "*
6260 {
6261   /* ??? Needs more work.  Length computation, split into multiple insns,
6262      do not use %r22 directly, expose delay slot.  */
6263   return \"ldd 16(%1),%%r2\;ldd 24(%1),%%r27\;bve,l (%%r2),%%r2\;nop\";
6264 }"
6265   [(set_attr "type" "dyncall")
6266    (set (attr "length") (const_int 16))])
6267
6268 (define_insn "call_value_internal_reg"
6269   [(set (match_operand 0 "" "=rf")
6270         (call (mem:SI (reg:SI 22))
6271               (match_operand 1 "" "i")))
6272    (clobber (reg:SI 2))
6273    (use (const_int 1))]
6274   ""
6275   "*
6276 {
6277   rtx xoperands[2];
6278
6279   /* First the special case for kernels, level 0 systems, etc.  */
6280   if (TARGET_FAST_INDIRECT_CALLS)
6281     return \"ble 0(%%sr4,%%r22)\;copy %%r31,%%r2\";
6282
6283   /* Now the normal case -- we can reach $$dyncall directly or
6284      we're sure that we can get there via a long-branch stub. 
6285
6286      No need to check target flags as the length uniquely identifies
6287      the remaining cases.  */
6288   if (get_attr_length (insn) == 8)
6289     return \".CALL\\tARGW0=GR\;{bl|b,l} $$dyncall,%%r31\;copy %%r31,%%r2\";
6290
6291   /* Long millicode call, but we are not generating PIC or portable runtime
6292      code.  */
6293   if (get_attr_length (insn) == 12)
6294     return \".CALL\\tARGW0=GR\;ldil L%%$$dyncall,%%r2\;ble R%%$$dyncall(%%sr4,%%r2)\;copy %%r31,%%r2\";
6295
6296   /* Long millicode call for portable runtime.  */
6297   if (get_attr_length (insn) == 20)
6298     return \"ldil L%%$$dyncall,%%r31\;ldo R%%$$dyncall(%%r31),%%r31\;blr %%r0,%%r2\;bv,n %%r0(%%r31)\;nop\";
6299
6300   /* If we're generating PIC code.  */
6301   xoperands[0] = operands[1];
6302   if (TARGET_SOM || ! TARGET_GAS)
6303     xoperands[1] = gen_label_rtx ();
6304   output_asm_insn (\"{bl|b,l} .+8,%%r1\", xoperands);
6305   if (TARGET_SOM || ! TARGET_GAS)
6306     {
6307       output_asm_insn (\"addil L%%$$dyncall-%1,%%r1\", xoperands);
6308       ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\",
6309                                  CODE_LABEL_NUMBER (xoperands[1]));
6310       output_asm_insn (\"ldo R%%$$dyncall-%1(%%r1),%%r1\", xoperands);
6311     }
6312   else
6313     {
6314       output_asm_insn (\"addil L%%$$dyncall-$PIC_pcrel$0+4,%%r1\", xoperands);
6315       output_asm_insn (\"ldo R%%$$dyncall-$PIC_pcrel$0+8(%%r1),%%r1\",
6316                        xoperands);
6317     }
6318   output_asm_insn (\"blr %%r0,%%r2\", xoperands);
6319   output_asm_insn (\"bv,n %%r0(%%r1)\\n\\tnop\", xoperands);
6320   return \"\";
6321 }"
6322   [(set_attr "type" "dyncall")
6323    (set (attr "length")
6324      (cond [
6325 ;; First FAST_INDIRECT_CALLS
6326             (ne (symbol_ref "TARGET_FAST_INDIRECT_CALLS")
6327                 (const_int 0))
6328             (const_int 8)
6329
6330 ;; Target (or stub) within reach
6331             (and (lt (plus (symbol_ref "total_code_bytes") (pc))
6332                      (const_int 240000))
6333                  (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
6334                      (const_int 0)))
6335             (const_int 8)
6336
6337 ;; Out of reach PIC
6338             (ne (symbol_ref "flag_pic")
6339                 (const_int 0))
6340             (const_int 24)
6341
6342 ;; Out of reach PORTABLE_RUNTIME
6343             (ne (symbol_ref "TARGET_PORTABLE_RUNTIME")
6344                 (const_int 0))
6345             (const_int 20)]
6346
6347 ;; Out of reach, can use ble
6348           (const_int 12)))])
6349
6350 ;; Call subroutine returning any type.
6351
6352 (define_expand "untyped_call"
6353   [(parallel [(call (match_operand 0 "" "")
6354                     (const_int 0))
6355               (match_operand 1 "" "")
6356               (match_operand 2 "" "")])]
6357   ""
6358   "
6359 {
6360   int i;
6361
6362   emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
6363
6364   for (i = 0; i < XVECLEN (operands[2], 0); i++)
6365     {
6366       rtx set = XVECEXP (operands[2], 0, i);
6367       emit_move_insn (SET_DEST (set), SET_SRC (set));
6368     }
6369
6370   /* The optimizer does not know that the call sets the function value
6371      registers we stored in the result block.  We avoid problems by
6372      claiming that all hard registers are used and clobbered at this
6373      point.  */
6374   emit_insn (gen_blockage ());
6375
6376   DONE;
6377 }")
6378
6379 (define_expand "sibcall"
6380   [(parallel [(call (match_operand:SI 0 "" "")
6381                     (match_operand 1 "" ""))
6382               (clobber (reg:SI 0))])]
6383   "! TARGET_PORTABLE_RUNTIME"
6384   "
6385 {
6386   rtx op;
6387   rtx call_insn;
6388
6389   op = XEXP (operands[0], 0);
6390
6391   /* We do not allow indirect sibling calls.  */
6392   call_insn = emit_call_insn (gen_sibcall_internal_symref (op, operands[1]));
6393
6394   if (flag_pic)
6395     {
6396       use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
6397
6398       /* After each call we must restore the PIC register, even if it
6399          doesn't appear to be used.  */
6400       emit_move_insn (pic_offset_table_rtx, hppa_pic_save_rtx ());
6401     }
6402   DONE;
6403 }")
6404
6405 (define_insn "sibcall_internal_symref"
6406   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
6407          (match_operand 1 "" "i"))
6408    (clobber (reg:SI 0))
6409    (use (reg:SI 2))
6410    (use (const_int 0))]
6411   "! TARGET_PORTABLE_RUNTIME"
6412   "*
6413 {
6414   output_arg_descriptor (insn);
6415   return output_call (insn, operands[0], 1);
6416 }"
6417   [(set_attr "type" "call")
6418    (set (attr "length")
6419 ;;       If we're sure that we can either reach the target or that the
6420 ;;       linker can use a long-branch stub, then the length is at most
6421 ;;       8 bytes.
6422 ;;
6423 ;;       For long-calls the length will be at most 68 bytes (non-pic)
6424 ;;       or 84 bytes (pic).  */
6425 ;;       Else we have to use a long-call;
6426       (if_then_else (lt (plus (symbol_ref "total_code_bytes") (pc))
6427                         (const_int 240000))
6428                     (const_int 8)
6429                     (if_then_else (eq (symbol_ref "flag_pic")
6430                                       (const_int 0))
6431                                   (const_int 68)
6432                                   (const_int 84))))])
6433
6434 (define_expand "sibcall_value"
6435   [(parallel [(set (match_operand 0 "" "")
6436                    (call (match_operand:SI 1 "" "")
6437                          (match_operand 2 "" "")))
6438               (clobber (reg:SI 0))])]
6439   "! TARGET_PORTABLE_RUNTIME"
6440   "
6441 {
6442   rtx op;
6443   rtx call_insn;
6444
6445   op = XEXP (operands[1], 0);
6446
6447   /* We do not allow indirect sibling calls.  */
6448   call_insn = emit_call_insn (gen_sibcall_value_internal_symref (operands[0],
6449                                                                  op,
6450                                                                  operands[2]));
6451   if (flag_pic)
6452     {
6453       use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
6454
6455       /* After each call we must restore the PIC register, even if it
6456          doesn't appear to be used.  */
6457       emit_move_insn (pic_offset_table_rtx, hppa_pic_save_rtx ());
6458     }
6459   DONE;
6460 }")
6461
6462 (define_insn "sibcall_value_internal_symref"
6463   [(set (match_operand 0 "" "=rf")
6464         (call (mem:SI (match_operand 1 "call_operand_address" ""))
6465               (match_operand 2 "" "i")))
6466    (clobber (reg:SI 0))
6467    (use (reg:SI 2))
6468    (use (const_int 0))]
6469   ;;- Don't use operand 1 for most machines.
6470   "! TARGET_PORTABLE_RUNTIME"
6471   "*
6472 {
6473   output_arg_descriptor (insn);
6474   return output_call (insn, operands[1], 1);
6475 }"
6476   [(set_attr "type" "call")
6477    (set (attr "length")
6478 ;;       If we're sure that we can either reach the target or that the
6479 ;;       linker can use a long-branch stub, then the length is at most
6480 ;;       8 bytes.
6481 ;;
6482 ;;       For long-calls the length will be at most 68 bytes (non-pic)
6483 ;;       or 84 bytes (pic).  */
6484 ;;       Else we have to use a long-call;
6485       (if_then_else (lt (plus (symbol_ref "total_code_bytes") (pc))
6486                         (const_int 240000))
6487                     (const_int 8)
6488                     (if_then_else (eq (symbol_ref "flag_pic")
6489                                       (const_int 0))
6490                                   (const_int 68)
6491                                   (const_int 84))))])
6492
6493 (define_insn "nop"
6494   [(const_int 0)]
6495   ""
6496   "nop"
6497   [(set_attr "type" "move")
6498    (set_attr "length" "4")])
6499
6500 ;; These are just placeholders so we know where branch tables
6501 ;; begin and end.
6502 (define_insn "begin_brtab"
6503   [(const_int 1)]
6504   ""
6505   "*
6506 {
6507   /* Only GAS actually supports this pseudo-op.  */
6508   if (TARGET_GAS)
6509     return \".begin_brtab\";
6510   else
6511     return \"\";
6512 }"
6513   [(set_attr "type" "move")
6514    (set_attr "length" "0")])
6515
6516 (define_insn "end_brtab"
6517   [(const_int 2)]
6518   ""
6519   "*
6520 {
6521   /* Only GAS actually supports this pseudo-op.  */
6522   if (TARGET_GAS)
6523     return \".end_brtab\";
6524   else
6525     return \"\";
6526 }"
6527   [(set_attr "type" "move")
6528    (set_attr "length" "0")])
6529
6530 ;;; EH does longjmp's from and within the data section.  Thus,
6531 ;;; an interspace branch is required for the longjmp implementation.
6532 ;;; Registers r1 and r2 are used as scratch registers for the jump.
6533 (define_expand "interspace_jump"
6534   [(parallel
6535      [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
6536       (clobber (match_dup 1))])]
6537   ""
6538   "
6539 {
6540   operands[1] = gen_rtx_REG (word_mode, 2);
6541 }")
6542
6543 (define_insn ""
6544   [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
6545   (clobber (reg:SI 2))]
6546   "!TARGET_64BIT"
6547   "ldsid (%%sr0,%0),%%r2\; mtsp %%r2,%%sr0\; be%* 0(%%sr0,%0)"
6548    [(set_attr "type" "branch")
6549     (set_attr "length" "12")])
6550
6551 (define_insn ""
6552   [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
6553   (clobber (reg:DI 2))]
6554   "TARGET_64BIT"
6555   "ldsid (%%sr0,%0),%%r2\; mtsp %%r2,%%sr0\; be%* 0(%%sr0,%0)"
6556    [(set_attr "type" "branch")
6557     (set_attr "length" "12")])
6558
6559 (define_expand "builtin_longjmp"
6560   [(unspec_volatile [(match_operand 0 "register_operand" "r")] 3)]
6561   ""
6562   "
6563 {
6564   /* The elements of the buffer are, in order:  */
6565   rtx fp = gen_rtx_MEM (Pmode, operands[0]);
6566   rtx lab = gen_rtx_MEM (Pmode, plus_constant (operands[0],
6567                          POINTER_SIZE / BITS_PER_UNIT));
6568   rtx stack = gen_rtx_MEM (Pmode, plus_constant (operands[0],
6569                            (POINTER_SIZE * 2) / BITS_PER_UNIT));
6570   rtx pv = gen_rtx_REG (Pmode, 1);
6571
6572   /* This bit is the same as expand_builtin_longjmp.  */
6573   emit_move_insn (hard_frame_pointer_rtx, fp);
6574   emit_stack_restore (SAVE_NONLOCAL, stack, NULL_RTX);
6575   emit_insn (gen_rtx_USE (VOIDmode, hard_frame_pointer_rtx));
6576   emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
6577
6578   /* Load the label we are jumping through into r1 so that we know
6579      where to look for it when we get back to setjmp's function for
6580      restoring the gp.  */
6581   emit_move_insn (pv, lab);
6582
6583   /* Prevent the insns above from being scheduled into the delay slot
6584      of the interspace jump because the space register could change.  */
6585   emit_insn (gen_blockage ());
6586
6587   emit_jump_insn (gen_interspace_jump (pv));
6588   emit_barrier ();
6589   DONE;
6590 }")
6591
6592 ;;; Hope this is only within a function...
6593 (define_insn "indirect_jump"
6594   [(set (pc) (match_operand 0 "register_operand" "r"))]
6595   "GET_MODE (operands[0]) == word_mode"
6596   "bv%* %%r0(%0)"
6597   [(set_attr "type" "branch")
6598    (set_attr "length" "4")])
6599
6600 (define_expand "extzv"
6601   [(set (match_operand 0 "register_operand" "")
6602         (zero_extract (match_operand 1 "register_operand" "")
6603                       (match_operand 2 "uint32_operand" "")
6604                       (match_operand 3 "uint32_operand" "")))]
6605   ""
6606   "
6607 {
6608   if (TARGET_64BIT)
6609     emit_insn (gen_extzv_64 (operands[0], operands[1],
6610                              operands[2], operands[3]));
6611   else
6612     emit_insn (gen_extzv_32 (operands[0], operands[1],
6613                              operands[2], operands[3]));
6614   DONE;
6615 }")
6616
6617 (define_insn "extzv_32"
6618   [(set (match_operand:SI 0 "register_operand" "=r")
6619         (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
6620                          (match_operand:SI 2 "uint5_operand" "")
6621                          (match_operand:SI 3 "uint5_operand" "")))]
6622   ""
6623   "{extru|extrw,u} %1,%3+%2-1,%2,%0"
6624   [(set_attr "type" "shift")
6625    (set_attr "length" "4")])
6626
6627 (define_insn ""
6628   [(set (match_operand:SI 0 "register_operand" "=r")
6629         (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
6630                          (const_int 1)
6631                          (match_operand:SI 2 "register_operand" "q")))]
6632   ""
6633   "{vextru %1,1,%0|extrw,u %1,%%sar,1,%0}"
6634   [(set_attr "type" "shift")
6635    (set_attr "length" "4")])
6636
6637 (define_insn "extzv_64"
6638   [(set (match_operand:DI 0 "register_operand" "=r")
6639         (zero_extract:DI (match_operand:DI 1 "register_operand" "r")
6640                          (match_operand:DI 2 "uint32_operand" "")
6641                          (match_operand:DI 3 "uint32_operand" "")))]
6642   "TARGET_64BIT"
6643   "extrd,u %1,%3+%2-1,%2,%0"
6644   [(set_attr "type" "shift")
6645    (set_attr "length" "4")])
6646
6647 (define_insn ""
6648   [(set (match_operand:DI 0 "register_operand" "=r")
6649         (zero_extract:DI (match_operand:DI 1 "register_operand" "r")
6650                          (const_int 1)
6651                          (match_operand:DI 2 "register_operand" "q")))]
6652   "TARGET_64BIT"
6653   "extrd,u %1,%%sar,1,%0"
6654   [(set_attr "type" "shift")
6655    (set_attr "length" "4")])
6656
6657 (define_expand "extv"
6658   [(set (match_operand 0 "register_operand" "")
6659         (sign_extract (match_operand 1 "register_operand" "")
6660                       (match_operand 2 "uint32_operand" "")
6661                       (match_operand 3 "uint32_operand" "")))]
6662   ""
6663   "
6664 {
6665   if (TARGET_64BIT)
6666     emit_insn (gen_extv_64 (operands[0], operands[1],
6667                             operands[2], operands[3]));
6668   else
6669     emit_insn (gen_extv_32 (operands[0], operands[1],
6670                             operands[2], operands[3]));
6671   DONE;
6672 }")
6673
6674 (define_insn "extv_32"
6675   [(set (match_operand:SI 0 "register_operand" "=r")
6676         (sign_extract:SI (match_operand:SI 1 "register_operand" "r")
6677                          (match_operand:SI 2 "uint5_operand" "")
6678                          (match_operand:SI 3 "uint5_operand" "")))]
6679   ""
6680   "{extrs|extrw,s} %1,%3+%2-1,%2,%0"
6681   [(set_attr "type" "shift")
6682    (set_attr "length" "4")])
6683
6684 (define_insn ""
6685   [(set (match_operand:SI 0 "register_operand" "=r")
6686         (sign_extract:SI (match_operand:SI 1 "register_operand" "r")
6687                          (const_int 1)
6688                          (match_operand:SI 2 "register_operand" "q")))]
6689   "!TARGET_64BIT"
6690   "{vextrs %1,1,%0|extrw,s %1,%%sar,1,%0}"
6691   [(set_attr "type" "shift")
6692    (set_attr "length" "4")])
6693
6694 (define_insn "extv_64"
6695   [(set (match_operand:DI 0 "register_operand" "=r")
6696         (sign_extract:DI (match_operand:DI 1 "register_operand" "r")
6697                          (match_operand:DI 2 "uint32_operand" "")
6698                          (match_operand:DI 3 "uint32_operand" "")))]
6699   "TARGET_64BIT"
6700   "extrd,s %1,%3+%2-1,%2,%0"
6701   [(set_attr "type" "shift")
6702    (set_attr "length" "4")])
6703
6704 (define_insn ""
6705   [(set (match_operand:DI 0 "register_operand" "=r")
6706         (sign_extract:DI (match_operand:DI 1 "register_operand" "r")
6707                          (const_int 1)
6708                          (match_operand:DI 2 "register_operand" "q")))]
6709   "TARGET_64BIT"
6710   "extrd,s %1,%%sar,1,%0"
6711   [(set_attr "type" "shift")
6712    (set_attr "length" "4")])
6713
6714 ;; Only specify the mode operands 0, the rest are assumed to be word_mode.
6715 (define_expand "insv"
6716   [(set (zero_extract (match_operand 0 "register_operand" "")
6717                       (match_operand 1 "uint32_operand" "")
6718                       (match_operand 2 "uint32_operand" ""))
6719         (match_operand 3 "arith5_operand" ""))]
6720   ""
6721   "
6722 {
6723   if (TARGET_64BIT)
6724     emit_insn (gen_insv_64 (operands[0], operands[1],
6725                             operands[2], operands[3]));
6726   else
6727     emit_insn (gen_insv_32 (operands[0], operands[1],
6728                             operands[2], operands[3]));
6729   DONE;
6730 }")
6731
6732 (define_insn "insv_32"
6733   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r,r")
6734                          (match_operand:SI 1 "uint5_operand" "")
6735                          (match_operand:SI 2 "uint5_operand" ""))
6736         (match_operand:SI 3 "arith5_operand" "r,L"))]
6737   ""
6738   "@
6739    {dep|depw} %3,%2+%1-1,%1,%0
6740    {depi|depwi} %3,%2+%1-1,%1,%0"
6741   [(set_attr "type" "shift,shift")
6742    (set_attr "length" "4,4")])
6743
6744 ;; Optimize insertion of const_int values of type 1...1xxxx.
6745 (define_insn ""
6746   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
6747                          (match_operand:SI 1 "uint5_operand" "")
6748                          (match_operand:SI 2 "uint5_operand" ""))
6749         (match_operand:SI 3 "const_int_operand" ""))]
6750   "(INTVAL (operands[3]) & 0x10) != 0 &&
6751    (~INTVAL (operands[3]) & ((1L << INTVAL (operands[1])) - 1) & ~0xf) == 0"
6752   "*
6753 {
6754   operands[3] = GEN_INT ((INTVAL (operands[3]) & 0xf) - 0x10);
6755   return \"{depi|depwi} %3,%2+%1-1,%1,%0\";
6756 }"
6757   [(set_attr "type" "shift")
6758    (set_attr "length" "4")])
6759
6760 (define_insn "insv_64"
6761   [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+r,r")
6762                          (match_operand:DI 1 "uint32_operand" "")
6763                          (match_operand:DI 2 "uint32_operand" ""))
6764         (match_operand:DI 3 "arith32_operand" "r,L"))]
6765   "TARGET_64BIT"
6766   "@
6767    depd %3,%2+%1-1,%1,%0
6768    depdi %3,%2+%1-1,%1,%0"
6769   [(set_attr "type" "shift,shift")
6770    (set_attr "length" "4,4")])
6771
6772 ;; Optimize insertion of const_int values of type 1...1xxxx.
6773 (define_insn ""
6774   [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+r")
6775                          (match_operand:DI 1 "uint32_operand" "")
6776                          (match_operand:DI 2 "uint32_operand" ""))
6777         (match_operand:DI 3 "const_int_operand" ""))]
6778   "(INTVAL (operands[3]) & 0x10) != 0
6779    && TARGET_64BIT
6780    && (~INTVAL (operands[3]) & ((1L << INTVAL (operands[1])) - 1) & ~0xf) == 0"
6781   "*
6782 {
6783   operands[3] = GEN_INT ((INTVAL (operands[3]) & 0xf) - 0x10);
6784   return \"depdi %3,%2+%1-1,%1,%0\";
6785 }"
6786   [(set_attr "type" "shift")
6787    (set_attr "length" "4")])
6788
6789 (define_insn ""
6790   [(set (match_operand:DI 0 "register_operand" "=r")
6791         (ashift:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
6792                    (const_int 32)))]
6793   "TARGET_64BIT"
6794   "depd,z %1,31,32,%0"
6795   [(set_attr "type" "shift")
6796    (set_attr "length" "4")])
6797
6798 ;; This insn is used for some loop tests, typically loops reversed when
6799 ;; strength reduction is used.  It is actually created when the instruction
6800 ;; combination phase combines the special loop test.  Since this insn
6801 ;; is both a jump insn and has an output, it must deal with its own
6802 ;; reloads, hence the `m' constraints.  The `!' constraints direct reload
6803 ;; to not choose the register alternatives in the event a reload is needed.
6804 (define_insn "decrement_and_branch_until_zero"
6805   [(set (pc)
6806         (if_then_else
6807           (match_operator 2 "comparison_operator"
6808            [(plus:SI
6809               (match_operand:SI 0 "reg_before_reload_operand" "+!r,!*f,*m")
6810               (match_operand:SI 1 "int5_operand" "L,L,L"))
6811             (const_int 0)])
6812           (label_ref (match_operand 3 "" ""))
6813           (pc)))
6814    (set (match_dup 0)
6815         (plus:SI (match_dup 0) (match_dup 1)))
6816    (clobber (match_scratch:SI 4 "=X,r,r"))]
6817   ""
6818   "* return output_dbra (operands, insn, which_alternative); "
6819 ;; Do not expect to understand this the first time through.
6820 [(set_attr "type" "cbranch,multi,multi")
6821  (set (attr "length")
6822       (if_then_else (eq_attr "alternative" "0")
6823 ;; Loop counter in register case
6824 ;; Short branch has length of 4
6825 ;; Long branch has length of 8
6826         (if_then_else (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
6827                       (const_int 8184))
6828            (const_int 4)
6829            (const_int 8))
6830
6831 ;; Loop counter in FP reg case.
6832 ;; Extra goo to deal with additional reload insns.
6833         (if_then_else (eq_attr "alternative" "1")
6834           (if_then_else (lt (match_dup 3) (pc))
6835             (if_then_else
6836               (lt (abs (minus (match_dup 3) (plus (pc) (const_int 24))))
6837                   (const_int 8184))
6838               (const_int 24)
6839               (const_int 28))
6840             (if_then_else
6841               (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
6842                   (const_int 8184))
6843               (const_int 24)
6844               (const_int 28)))
6845 ;; Loop counter in memory case.
6846 ;; Extra goo to deal with additional reload insns.
6847         (if_then_else (lt (match_dup 3) (pc))
6848           (if_then_else
6849             (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
6850                 (const_int 8184))
6851             (const_int 12)
6852             (const_int 16))
6853           (if_then_else
6854             (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
6855                 (const_int 8184))
6856             (const_int 12)
6857             (const_int 16))))))])
6858
6859 (define_insn ""
6860   [(set (pc)
6861         (if_then_else
6862           (match_operator 2 "movb_comparison_operator"
6863            [(match_operand:SI 1 "register_operand" "r,r,r,r") (const_int 0)])
6864           (label_ref (match_operand 3 "" ""))
6865           (pc)))
6866    (set (match_operand:SI 0 "reg_before_reload_operand" "=!r,!*f,*m,!*q")
6867         (match_dup 1))]
6868   ""
6869 "* return output_movb (operands, insn, which_alternative, 0); "
6870 ;; Do not expect to understand this the first time through.
6871 [(set_attr "type" "cbranch,multi,multi,multi")
6872  (set (attr "length")
6873       (if_then_else (eq_attr "alternative" "0")
6874 ;; Loop counter in register case
6875 ;; Short branch has length of 4
6876 ;; Long branch has length of 8
6877         (if_then_else (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
6878                       (const_int 8184))
6879            (const_int 4)
6880            (const_int 8))
6881
6882 ;; Loop counter in FP reg case.
6883 ;; Extra goo to deal with additional reload insns.
6884         (if_then_else (eq_attr "alternative" "1")
6885           (if_then_else (lt (match_dup 3) (pc))
6886             (if_then_else
6887               (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
6888                   (const_int 8184))
6889               (const_int 12)
6890               (const_int 16))
6891             (if_then_else
6892               (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
6893                   (const_int 8184))
6894               (const_int 12)
6895               (const_int 16)))
6896 ;; Loop counter in memory or sar case.
6897 ;; Extra goo to deal with additional reload insns.
6898         (if_then_else
6899           (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
6900               (const_int 8184))
6901           (const_int 8)
6902           (const_int 12)))))])
6903
6904 ;; Handle negated branch.
6905 (define_insn ""
6906   [(set (pc)
6907         (if_then_else
6908           (match_operator 2 "movb_comparison_operator"
6909            [(match_operand:SI 1 "register_operand" "r,r,r,r") (const_int 0)])
6910           (pc)
6911           (label_ref (match_operand 3 "" ""))))
6912    (set (match_operand:SI 0 "reg_before_reload_operand" "=!r,!*f,*m,!*q")
6913         (match_dup 1))]
6914   ""
6915 "* return output_movb (operands, insn, which_alternative, 1); "
6916 ;; Do not expect to understand this the first time through.
6917 [(set_attr "type" "cbranch,multi,multi,multi")
6918  (set (attr "length")
6919       (if_then_else (eq_attr "alternative" "0")
6920 ;; Loop counter in register case
6921 ;; Short branch has length of 4
6922 ;; Long branch has length of 8
6923         (if_then_else (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
6924                       (const_int 8184))
6925            (const_int 4)
6926            (const_int 8))
6927
6928 ;; Loop counter in FP reg case.
6929 ;; Extra goo to deal with additional reload insns.
6930         (if_then_else (eq_attr "alternative" "1")
6931           (if_then_else (lt (match_dup 3) (pc))
6932             (if_then_else
6933               (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
6934                   (const_int 8184))
6935               (const_int 12)
6936               (const_int 16))
6937             (if_then_else
6938               (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
6939                   (const_int 8184))
6940               (const_int 12)
6941               (const_int 16)))
6942 ;; Loop counter in memory or SAR case.
6943 ;; Extra goo to deal with additional reload insns.
6944         (if_then_else
6945           (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
6946               (const_int 8184))
6947           (const_int 8)
6948           (const_int 12)))))])
6949
6950 (define_insn ""
6951   [(set (pc) (label_ref (match_operand 3 "" "" )))
6952    (set (match_operand:SI 0 "ireg_operand" "=r")
6953         (plus:SI (match_operand:SI 1 "ireg_operand" "r")
6954                  (match_operand:SI 2 "ireg_or_int5_operand" "rL")))]
6955   "(reload_completed && operands[0] == operands[1]) || operands[0] == operands[2]"
6956   "*
6957 {
6958   return output_parallel_addb (operands, get_attr_length (insn));
6959 }"
6960   [(set_attr "type" "parallel_branch")
6961    (set (attr "length")
6962     (if_then_else (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
6963                       (const_int 8184))
6964            (const_int 4)
6965            (const_int 8)))])
6966
6967 (define_insn ""
6968   [(set (pc) (label_ref (match_operand 2 "" "" )))
6969    (set (match_operand:SF 0 "ireg_operand" "=r")
6970         (match_operand:SF 1 "ireg_or_int5_operand" "rL"))]
6971   "reload_completed"
6972   "*
6973 {
6974   return output_parallel_movb (operands, get_attr_length (insn));
6975 }"
6976   [(set_attr "type" "parallel_branch")
6977    (set (attr "length")
6978     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
6979                       (const_int 8184))
6980            (const_int 4)
6981            (const_int 8)))])
6982
6983 (define_insn ""
6984   [(set (pc) (label_ref (match_operand 2 "" "" )))
6985    (set (match_operand:SI 0 "ireg_operand" "=r")
6986         (match_operand:SI 1 "ireg_or_int5_operand" "rL"))]
6987   "reload_completed"
6988   "*
6989 {
6990   return output_parallel_movb (operands, get_attr_length (insn));
6991 }"
6992   [(set_attr "type" "parallel_branch")
6993    (set (attr "length")
6994     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
6995                       (const_int 8184))
6996            (const_int 4)
6997            (const_int 8)))])
6998
6999 (define_insn ""
7000   [(set (pc) (label_ref (match_operand 2 "" "" )))
7001    (set (match_operand:HI 0 "ireg_operand" "=r")
7002         (match_operand:HI 1 "ireg_or_int5_operand" "rL"))]
7003   "reload_completed"
7004   "*
7005 {
7006   return output_parallel_movb (operands, get_attr_length (insn));
7007 }"
7008   [(set_attr "type" "parallel_branch")
7009    (set (attr "length")
7010     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
7011                       (const_int 8184))
7012            (const_int 4)
7013            (const_int 8)))])
7014
7015 (define_insn ""
7016   [(set (pc) (label_ref (match_operand 2 "" "" )))
7017    (set (match_operand:QI 0 "ireg_operand" "=r")
7018         (match_operand:QI 1 "ireg_or_int5_operand" "rL"))]
7019   "reload_completed"
7020   "*
7021 {
7022   return output_parallel_movb (operands, get_attr_length (insn));
7023 }"
7024   [(set_attr "type" "parallel_branch")
7025    (set (attr "length")
7026     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
7027                       (const_int 8184))
7028            (const_int 4)
7029            (const_int 8)))])
7030
7031 (define_insn ""
7032   [(set (match_operand 0 "register_operand" "=f")
7033         (mult (match_operand 1 "register_operand" "f")
7034               (match_operand 2 "register_operand" "f")))
7035    (set (match_operand 3 "register_operand" "+f")
7036         (plus (match_operand 4 "register_operand" "f")
7037               (match_operand 5 "register_operand" "f")))]
7038   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
7039    && reload_completed && fmpyaddoperands (operands)"
7040   "*
7041 {
7042   if (GET_MODE (operands[0]) == DFmode)
7043     {
7044       if (rtx_equal_p (operands[3], operands[5]))
7045         return \"fmpyadd,dbl %1,%2,%0,%4,%3\";
7046       else
7047         return \"fmpyadd,dbl %1,%2,%0,%5,%3\";
7048     }
7049   else
7050     {
7051       if (rtx_equal_p (operands[3], operands[5]))
7052         return \"fmpyadd,sgl %1,%2,%0,%4,%3\";
7053       else
7054         return \"fmpyadd,sgl %1,%2,%0,%5,%3\";
7055     }
7056 }"
7057   [(set_attr "type" "fpalu")
7058    (set_attr "length" "4")])
7059
7060 (define_insn ""
7061   [(set (match_operand 3 "register_operand" "+f")
7062         (plus (match_operand 4 "register_operand" "f")
7063               (match_operand 5 "register_operand" "f")))
7064    (set (match_operand 0 "register_operand" "=f")
7065         (mult (match_operand 1 "register_operand" "f")
7066               (match_operand 2 "register_operand" "f")))]
7067   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
7068    && reload_completed && fmpyaddoperands (operands)"
7069   "*
7070 {
7071   if (GET_MODE (operands[0]) == DFmode)
7072     {
7073       if (rtx_equal_p (operands[3], operands[5]))
7074         return \"fmpyadd,dbl %1,%2,%0,%4,%3\";
7075       else
7076         return \"fmpyadd,dbl %1,%2,%0,%5,%3\";
7077     }
7078   else
7079     {
7080       if (rtx_equal_p (operands[3], operands[5]))
7081         return \"fmpyadd,sgl %1,%2,%0,%4,%3\";
7082       else
7083         return \"fmpyadd,sgl %1,%2,%0,%5,%3\";
7084     }
7085 }"
7086   [(set_attr "type" "fpalu")
7087    (set_attr "length" "4")])
7088
7089 (define_insn ""
7090   [(set (match_operand 0 "register_operand" "=f")
7091         (mult (match_operand 1 "register_operand" "f")
7092               (match_operand 2 "register_operand" "f")))
7093    (set (match_operand 3 "register_operand" "+f")
7094         (minus (match_operand 4 "register_operand" "f")
7095                (match_operand 5 "register_operand" "f")))]
7096   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
7097    && reload_completed && fmpysuboperands (operands)"
7098   "*
7099 {
7100   if (GET_MODE (operands[0]) == DFmode)
7101     return \"fmpysub,dbl %1,%2,%0,%5,%3\";
7102   else
7103     return \"fmpysub,sgl %1,%2,%0,%5,%3\";
7104 }"
7105   [(set_attr "type" "fpalu")
7106    (set_attr "length" "4")])
7107
7108 (define_insn ""
7109   [(set (match_operand 3 "register_operand" "+f")
7110         (minus (match_operand 4 "register_operand" "f")
7111                (match_operand 5 "register_operand" "f")))
7112    (set (match_operand 0 "register_operand" "=f")
7113         (mult (match_operand 1 "register_operand" "f")
7114               (match_operand 2 "register_operand" "f")))]
7115   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
7116    && reload_completed && fmpysuboperands (operands)"
7117   "*
7118 {
7119   if (GET_MODE (operands[0]) == DFmode)
7120     return \"fmpysub,dbl %1,%2,%0,%5,%3\";
7121   else
7122     return \"fmpysub,sgl %1,%2,%0,%5,%3\";
7123 }"
7124   [(set_attr "type" "fpalu")
7125    (set_attr "length" "4")])
7126
7127 ;; Clean up turds left by reload.
7128 (define_peephole
7129   [(set (match_operand 0 "reg_or_nonsymb_mem_operand" "")
7130         (match_operand 1 "register_operand" "fr"))
7131    (set (match_operand 2 "register_operand" "fr")
7132         (match_dup 0))]
7133   "! TARGET_SOFT_FLOAT
7134    && GET_CODE (operands[0]) == MEM
7135    && ! MEM_VOLATILE_P (operands[0])
7136    && GET_MODE (operands[0]) == GET_MODE (operands[1])
7137    && GET_MODE (operands[0]) == GET_MODE (operands[2])
7138    && GET_MODE (operands[0]) == DFmode
7139    && GET_CODE (operands[1]) == REG
7140    && GET_CODE (operands[2]) == REG
7141    && ! side_effects_p (XEXP (operands[0], 0))
7142    && REGNO_REG_CLASS (REGNO (operands[1]))
7143       == REGNO_REG_CLASS (REGNO (operands[2]))"
7144   "*
7145 {
7146   rtx xoperands[2];
7147
7148   if (FP_REG_P (operands[1]))
7149     output_asm_insn (output_fp_move_double (operands), operands);
7150   else
7151     output_asm_insn (output_move_double (operands), operands);
7152
7153   if (rtx_equal_p (operands[1], operands[2]))
7154     return \"\";
7155
7156   xoperands[0] = operands[2];
7157   xoperands[1] = operands[1];
7158       
7159   if (FP_REG_P (xoperands[1]))
7160     output_asm_insn (output_fp_move_double (xoperands), xoperands);
7161   else
7162     output_asm_insn (output_move_double (xoperands), xoperands);
7163
7164   return \"\";
7165 }")
7166
7167 (define_peephole
7168   [(set (match_operand 0 "register_operand" "fr")
7169         (match_operand 1 "reg_or_nonsymb_mem_operand" ""))
7170    (set (match_operand 2 "register_operand" "fr")
7171         (match_dup 1))]
7172   "! TARGET_SOFT_FLOAT
7173    && GET_CODE (operands[1]) == MEM
7174    && ! MEM_VOLATILE_P (operands[1])
7175    && GET_MODE (operands[0]) == GET_MODE (operands[1])
7176    && GET_MODE (operands[0]) == GET_MODE (operands[2])
7177    && GET_MODE (operands[0]) == DFmode
7178    && GET_CODE (operands[0]) == REG
7179    && GET_CODE (operands[2]) == REG
7180    && ! side_effects_p (XEXP (operands[1], 0))
7181    && REGNO_REG_CLASS (REGNO (operands[0]))
7182       == REGNO_REG_CLASS (REGNO (operands[2]))"
7183   "*
7184 {
7185   rtx xoperands[2];
7186
7187   if (FP_REG_P (operands[0]))
7188     output_asm_insn (output_fp_move_double (operands), operands);
7189   else
7190     output_asm_insn (output_move_double (operands), operands);
7191
7192   xoperands[0] = operands[2];
7193   xoperands[1] = operands[0];
7194       
7195   if (FP_REG_P (xoperands[1]))
7196     output_asm_insn (output_fp_move_double (xoperands), xoperands);
7197   else
7198     output_asm_insn (output_move_double (xoperands), xoperands);
7199
7200   return \"\";
7201 }")
7202
7203 ;; Flush the I and D cache line found at the address in operand 0.
7204 ;; This is used by the trampoline code for nested functions.
7205 ;; So long as the trampoline itself is less than 32 bytes this
7206 ;; is sufficient.
7207
7208 (define_insn "dcacheflush"
7209   [(unspec_volatile [(const_int 1)] 0)
7210    (use (mem:SI (match_operand 0 "pmode_register_operand" "r")))
7211    (use (mem:SI (match_operand 1 "pmode_register_operand" "r")))]
7212   ""
7213   "fdc 0(%0)\;fdc 0(%1)\;sync"
7214   [(set_attr "type" "multi")
7215    (set_attr "length" "12")])
7216
7217 (define_insn "icacheflush"
7218   [(unspec_volatile [(const_int 2)] 0)
7219    (use (mem:SI (match_operand 0 "pmode_register_operand" "r")))
7220    (use (mem:SI (match_operand 1 "pmode_register_operand" "r")))
7221    (use (match_operand 2 "pmode_register_operand" "r"))
7222    (clobber (match_operand 3 "pmode_register_operand" "=&r"))
7223    (clobber (match_operand 4 "pmode_register_operand" "=&r"))]
7224   ""
7225   "mfsp %%sr0,%4\;ldsid (%2),%3\;mtsp %3,%%sr0\;fic 0(%%sr0,%0)\;fic 0(%%sr0,%1)\;sync\;mtsp %4,%%sr0\;nop\;nop\;nop\;nop\;nop\;nop"
7226   [(set_attr "type" "multi")
7227    (set_attr "length" "52")])
7228
7229 ;; An out-of-line prologue.
7230 (define_insn "outline_prologue_call"
7231   [(unspec_volatile [(const_int 0)] 0)
7232    (clobber (reg:SI 31))
7233    (clobber (reg:SI 22))
7234    (clobber (reg:SI 21))
7235    (clobber (reg:SI 20))
7236    (clobber (reg:SI 19))
7237    (clobber (reg:SI 1))]
7238   ""
7239   "*
7240 {
7241   extern int frame_pointer_needed;
7242
7243   /* We need two different versions depending on whether or not we
7244      need a frame pointer.   Also note that we return to the instruction
7245      immediately after the branch rather than two instructions after the
7246      break as normally is the case.  */
7247   if (frame_pointer_needed)
7248     {
7249       /* Must import the magic millicode routine(s).  */
7250       output_asm_insn (\".IMPORT __outline_prologue_fp,MILLICODE\", NULL);
7251
7252       if (TARGET_PORTABLE_RUNTIME)
7253         {
7254           output_asm_insn (\"ldil L'__outline_prologue_fp,%%r31\", NULL);
7255           output_asm_insn (\"ble,n R'__outline_prologue_fp(%%sr0,%%r31)\",
7256                            NULL);
7257         }
7258       else
7259         output_asm_insn (\"{bl|b,l},n __outline_prologue_fp,%%r31\", NULL);
7260     }
7261   else
7262     {
7263       /* Must import the magic millicode routine(s).  */
7264       output_asm_insn (\".IMPORT __outline_prologue,MILLICODE\", NULL);
7265
7266       if (TARGET_PORTABLE_RUNTIME)
7267         {
7268           output_asm_insn (\"ldil L'__outline_prologue,%%r31\", NULL);
7269           output_asm_insn (\"ble,n R'__outline_prologue(%%sr0,%%r31)\", NULL);
7270         }
7271       else
7272         output_asm_insn (\"{bl|b,l},n __outline_prologue,%%r31\", NULL);
7273     }
7274   return \"\";
7275 }"
7276   [(set_attr "type" "multi")
7277    (set_attr "length" "8")])
7278
7279 ;; An out-of-line epilogue.
7280 (define_insn "outline_epilogue_call"
7281   [(unspec_volatile [(const_int 1)] 0)
7282    (use (reg:SI 29))
7283    (use (reg:SI 28))
7284    (clobber (reg:SI 31))
7285    (clobber (reg:SI 22))
7286    (clobber (reg:SI 21))
7287    (clobber (reg:SI 20))
7288    (clobber (reg:SI 19))
7289    (clobber (reg:SI 2))
7290    (clobber (reg:SI 1))]
7291   ""
7292   "*
7293 {
7294   extern int frame_pointer_needed;
7295
7296   /* We need two different versions depending on whether or not we
7297      need a frame pointer.   Also note that we return to the instruction
7298      immediately after the branch rather than two instructions after the
7299      break as normally is the case.  */
7300   if (frame_pointer_needed)
7301     {
7302       /* Must import the magic millicode routine.  */
7303       output_asm_insn (\".IMPORT __outline_epilogue_fp,MILLICODE\", NULL);
7304
7305       /* The out-of-line prologue will make sure we return to the right
7306          instruction.  */
7307       if (TARGET_PORTABLE_RUNTIME)
7308         {
7309           output_asm_insn (\"ldil L'__outline_epilogue_fp,%%r31\", NULL);
7310           output_asm_insn (\"ble,n R'__outline_epilogue_fp(%%sr0,%%r31)\",
7311                            NULL);
7312         }
7313       else
7314         output_asm_insn (\"{bl|b,l},n __outline_epilogue_fp,%%r31\", NULL);
7315     }
7316   else
7317     {
7318       /* Must import the magic millicode routine.  */
7319       output_asm_insn (\".IMPORT __outline_epilogue,MILLICODE\", NULL);
7320
7321       /* The out-of-line prologue will make sure we return to the right
7322          instruction.  */
7323       if (TARGET_PORTABLE_RUNTIME)
7324         {
7325           output_asm_insn (\"ldil L'__outline_epilogue,%%r31\", NULL);
7326           output_asm_insn (\"ble,n R'__outline_epilogue(%%sr0,%%r31)\", NULL);
7327         }
7328       else
7329         output_asm_insn (\"{bl|b,l},n __outline_epilogue,%%r31\", NULL);
7330     }
7331   return \"\";
7332 }"
7333   [(set_attr "type" "multi")
7334    (set_attr "length" "8")])
7335
7336 ;; Given a function pointer, canonicalize it so it can be 
7337 ;; reliably compared to another function pointer.  */
7338 (define_expand "canonicalize_funcptr_for_compare"
7339   [(set (reg:SI 26) (match_operand:SI 1 "register_operand" ""))
7340    (parallel [(set (reg:SI 29) (unspec:SI [(reg:SI 26)] 0))
7341               (clobber (match_dup 2))
7342               (clobber (reg:SI 26))
7343               (clobber (reg:SI 22))
7344               (clobber (reg:SI 31))])
7345    (set (match_operand:SI 0 "register_operand" "")
7346         (reg:SI 29))]
7347   "! TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && !TARGET_ELF32"
7348   "
7349 {
7350   operands[2] = gen_reg_rtx (SImode);
7351   if (GET_CODE (operands[1]) != REG)
7352     {
7353       rtx tmp = gen_reg_rtx (Pmode);
7354       emit_move_insn (tmp, operands[1]);
7355       operands[1] = tmp;
7356     }
7357 }")
7358
7359 (define_insn ""
7360   [(set (reg:SI 29) (unspec:SI [(reg:SI 26)] 0))
7361    (clobber (match_operand:SI 0 "register_operand" "=a"))
7362    (clobber (reg:SI 26))
7363    (clobber (reg:SI 22))
7364    (clobber (reg:SI 31))]
7365   "!TARGET_64BIT"
7366   "*
7367 {
7368   /* Must import the magic millicode routine.  */
7369   output_asm_insn (\".IMPORT $$sh_func_adrs,MILLICODE\", NULL);
7370
7371   /* This is absolutely amazing.
7372
7373      First, copy our input parameter into %r29 just in case we don't
7374      need to call $$sh_func_adrs.  */
7375   output_asm_insn (\"copy %%r26,%%r29\", NULL);
7376
7377   /* Next, examine the low two bits in %r26, if they aren't 0x2, then
7378      we use %r26 unchanged.  */
7379   if (get_attr_length (insn) == 32)
7380     output_asm_insn (\"{extru|extrw,u} %%r26,31,2,%%r31\;{comib|cmpib},<>,n 2,%%r31,.+24\", NULL);
7381   else if (get_attr_length (insn) == 40)
7382     output_asm_insn (\"{extru|extrw,u} %%r26,31,2,%%r31\;{comib|cmpib},<>,n 2,%%r31,.+32\", NULL);
7383   else if (get_attr_length (insn) == 44)
7384     output_asm_insn (\"{extru|extrw,u} %%r26,31,2,%%r31\;{comib|cmpib},<>,n 2,%%r31,.+36\", NULL);
7385   else
7386     output_asm_insn (\"{extru|extrw,u} %%r26,31,2,%%r31\;{comib|cmpib},<>,n 2,%%r31,.+20\", NULL);
7387
7388   /* Next, compare %r26 with 4096, if %r26 is less than or equal to
7389      4096, then we use %r26 unchanged.  */
7390   if (get_attr_length (insn) == 32)
7391     output_asm_insn (\"ldi 4096,%%r31\;{comb|cmpb},<<,n %%r26,%%r31,.+16\",
7392                      NULL);
7393   else if (get_attr_length (insn) == 40)
7394     output_asm_insn (\"ldi 4096,%%r31\;{comb|cmpb},<<,n %%r26,%%r31,.+24\",
7395                      NULL);
7396   else if (get_attr_length (insn) == 44)
7397     output_asm_insn (\"ldi 4096,%%r31\;{comb|cmpb},<<,n %%r26,%%r31,.+28\",
7398                      NULL);
7399   else
7400     output_asm_insn (\"ldi 4096,%%r31\;{comb|cmpb},<<,n %%r26,%%r31,.+12\",
7401                      NULL);
7402
7403   /* Else call $$sh_func_adrs to extract the function's real add24.  */
7404   return output_millicode_call (insn,
7405                                 gen_rtx_SYMBOL_REF (SImode,
7406                                          \"$$sh_func_adrs\"));
7407 }"
7408   [(set_attr "type" "multi")
7409    (set (attr "length")
7410      (cond [
7411 ;; Target (or stub) within reach
7412             (and (lt (plus (symbol_ref "total_code_bytes") (pc))
7413                      (const_int 240000))
7414                  (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
7415                      (const_int 0)))
7416             (const_int 28)
7417
7418 ;; Out of reach PIC
7419             (ne (symbol_ref "flag_pic")
7420                 (const_int 0))
7421             (const_int 44)
7422
7423 ;; Out of reach PORTABLE_RUNTIME
7424             (ne (symbol_ref "TARGET_PORTABLE_RUNTIME")
7425                 (const_int 0))
7426             (const_int 40)]
7427
7428 ;; Out of reach, can use ble
7429           (const_int 32)))])
7430
7431 ;; On the PA, the PIC register is call clobbered, so it must
7432 ;; be saved & restored around calls by the caller.  If the call
7433 ;; doesn't return normally (nonlocal goto, or an exception is
7434 ;; thrown), then the code at the exception handler label must
7435 ;; restore the PIC register.
7436 (define_expand "exception_receiver"
7437   [(const_int 4)]
7438   "flag_pic"
7439   "
7440 {
7441   /* Restore the PIC register using hppa_pic_save_rtx ().  The
7442      PIC register is not saved in the frame in 64-bit ABI.  */
7443   emit_move_insn (pic_offset_table_rtx, hppa_pic_save_rtx ());
7444   DONE;
7445 }")
7446
7447 (define_expand "builtin_setjmp_receiver"
7448   [(label_ref (match_operand 0 "" ""))]
7449   "flag_pic"
7450   "
7451 {
7452   /* Restore the PIC register.  Hopefully, this will always be from
7453      a stack slot.  The only registers that are valid after a
7454      builtin_longjmp are the stack and frame pointers.  */
7455   emit_move_insn (pic_offset_table_rtx, hppa_pic_save_rtx ());
7456   DONE;
7457 }")