OSDN Git Service

* pa/constraints.md: New file.
[pf3gnuchains/gcc-fork.git] / gcc / config / pa / pa.md
1 ;;- Machine description for HP PA-RISC architecture for GCC compiler
2 ;;   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
3 ;;   2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
4 ;;   Contributed by the Center for Software Science at the University
5 ;;   of Utah.
6
7 ;; This file is part of GCC.
8
9 ;; GCC is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; any later version.
13
14 ;; GCC is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 ;; GNU General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GCC; see the file COPYING.  If not, write to
21 ;; the Free Software Foundation, 51 Franklin Street, Fifth Floor,
22 ;; Boston, MA 02110-1301, 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 ;; Uses of UNSPEC in this file:
30
31 (define_constants
32   [(UNSPEC_CFFC         0)      ; canonicalize_funcptr_for_compare
33    (UNSPEC_GOTO         1)      ; indirect_goto
34    (UNSPEC_DLTIND14R    2)      ; 
35    (UNSPEC_TP           3)
36    (UNSPEC_TLSGD        4)
37    (UNSPEC_TLSLDM       5)
38    (UNSPEC_TLSLDO       6)
39    (UNSPEC_TLSLDBASE    7)
40    (UNSPEC_TLSIE        8)
41    (UNSPEC_TLSLE        9)
42    (UNSPEC_TLSGD_PIC   10)
43    (UNSPEC_TLSLDM_PIC  11)
44    (UNSPEC_TLSIE_PIC   12)
45   ])
46
47 ;; UNSPEC_VOLATILE:
48
49 (define_constants
50   [(UNSPECV_BLOCKAGE    0)      ; blockage
51    (UNSPECV_DCACHE      1)      ; dcacheflush
52    (UNSPECV_ICACHE      2)      ; icacheflush
53    (UNSPECV_OPC         3)      ; outline_prologue_call
54    (UNSPECV_OEC         4)      ; outline_epilogue_call
55    (UNSPECV_LONGJMP     5)      ; builtin_longjmp
56   ])
57
58 ;; Maximum pc-relative branch offsets.
59
60 ;; These numbers are a bit smaller than the maximum allowable offsets
61 ;; so that a few instructions may be inserted before the actual branch.
62
63 (define_constants
64   [(MAX_12BIT_OFFSET     8184)  ; 12-bit branch
65    (MAX_17BIT_OFFSET   262100)  ; 17-bit branch
66   ])
67
68 ;; Insn type.  Used to default other attribute values.
69
70 ;; type "unary" insns have one input operand (1) and one output operand (0)
71 ;; type "binary" insns have two input operands (1,2) and one output (0)
72
73 (define_attr "type"
74   "move,unary,binary,shift,nullshift,compare,load,store,uncond_branch,btable_branch,branch,cbranch,fbranch,call,dyncall,fpload,fpstore,fpalu,fpcc,fpmulsgl,fpmuldbl,fpdivsgl,fpdivdbl,fpsqrtsgl,fpsqrtdbl,multi,milli,parallel_branch,fpstore_load,store_fpload"
75   (const_string "binary"))
76
77 (define_attr "pa_combine_type"
78   "fmpy,faddsub,uncond_branch,addmove,none"
79   (const_string "none"))
80
81 ;; Processor type (for scheduling, not code generation) -- this attribute
82 ;; must exactly match the processor_type enumeration in pa.h.
83 ;;
84 ;; FIXME: Add 800 scheduling for completeness?
85
86 (define_attr "cpu" "700,7100,7100LC,7200,7300,8000" (const (symbol_ref "pa_cpu_attr")))
87
88 ;; Length (in # of bytes).
89 (define_attr "length" ""
90   (cond [(eq_attr "type" "load,fpload")
91          (if_then_else (match_operand 1 "symbolic_memory_operand" "")
92                        (const_int 8) (const_int 4))
93
94          (eq_attr "type" "store,fpstore")
95          (if_then_else (match_operand 0 "symbolic_memory_operand" "")
96                        (const_int 8) (const_int 4))
97
98          (eq_attr "type" "binary,shift,nullshift")
99          (if_then_else (match_operand 2 "arith_operand" "")
100                        (const_int 4) (const_int 12))
101
102          (eq_attr "type" "move,unary,shift,nullshift")
103          (if_then_else (match_operand 1 "arith_operand" "")
104                        (const_int 4) (const_int 8))]
105
106         (const_int 4)))
107
108 (define_asm_attributes
109   [(set_attr "length" "4")
110    (set_attr "type" "multi")])
111
112 ;; Attributes for instruction and branch scheduling
113
114 ;; For conditional branches.
115 (define_attr "in_branch_delay" "false,true"
116   (if_then_else (and (eq_attr "type" "!uncond_branch,btable_branch,branch,cbranch,fbranch,call,dyncall,multi,milli,parallel_branch")
117                      (eq_attr "length" "4"))
118                 (const_string "true")
119                 (const_string "false")))
120
121 ;; Disallow instructions which use the FPU since they will tie up the FPU
122 ;; even if the instruction is nullified.
123 (define_attr "in_nullified_branch_delay" "false,true"
124   (if_then_else (and (eq_attr "type" "!uncond_branch,btable_branch,branch,cbranch,fbranch,call,dyncall,multi,milli,fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpdivdbl,fpsqrtsgl,fpsqrtdbl,parallel_branch")
125                      (eq_attr "length" "4"))
126                 (const_string "true")
127                 (const_string "false")))
128
129 ;; For calls and millicode calls.  Allow unconditional branches in the
130 ;; delay slot.
131 (define_attr "in_call_delay" "false,true"
132   (cond [(and (eq_attr "type" "!uncond_branch,btable_branch,branch,cbranch,fbranch,call,dyncall,multi,milli,parallel_branch")
133               (eq_attr "length" "4"))
134            (const_string "true")
135          (eq_attr "type" "uncond_branch")
136            (if_then_else (ne (symbol_ref "TARGET_JUMP_IN_DELAY")
137                              (const_int 0))
138                          (const_string "true")
139                          (const_string "false"))]
140         (const_string "false")))
141
142
143 ;; Call delay slot description.
144 (define_delay (eq_attr "type" "call")
145   [(eq_attr "in_call_delay" "true") (nil) (nil)])
146
147 ;; Millicode call delay slot description.
148 (define_delay (eq_attr "type" "milli")
149   [(eq_attr "in_call_delay" "true") (nil) (nil)])
150
151 ;; Return and other similar instructions.
152 (define_delay (eq_attr "type" "btable_branch,branch,parallel_branch")
153   [(eq_attr "in_branch_delay" "true") (nil) (nil)])
154
155 ;; Floating point conditional branch delay slot description.
156 (define_delay (eq_attr "type" "fbranch")
157   [(eq_attr "in_branch_delay" "true")
158    (eq_attr "in_nullified_branch_delay" "true")
159    (nil)])
160
161 ;; Integer conditional branch delay slot description.
162 ;; Nullification of conditional branches on the PA is dependent on the
163 ;; direction of the branch.  Forward branches nullify true and
164 ;; backward branches nullify false.  If the direction is unknown
165 ;; then nullification is not allowed.
166 (define_delay (eq_attr "type" "cbranch")
167   [(eq_attr "in_branch_delay" "true")
168    (and (eq_attr "in_nullified_branch_delay" "true")
169         (attr_flag "forward"))
170    (and (eq_attr "in_nullified_branch_delay" "true")
171         (attr_flag "backward"))])
172
173 (define_delay (and (eq_attr "type" "uncond_branch")
174                    (eq (symbol_ref "following_call (insn)")
175                        (const_int 0)))
176   [(eq_attr "in_branch_delay" "true") (nil) (nil)])
177
178 ;; Memory. Disregarding Cache misses, the Mustang memory times are:
179 ;; load: 2, fpload: 3
180 ;; store, fpstore: 3, no D-cache operations should be scheduled.
181
182 ;; The Timex (aka 700) has two floating-point units: ALU, and MUL/DIV/SQRT.
183 ;; Timings:
184 ;; Instruction  Time    Unit    Minimum Distance (unit contention)
185 ;; fcpy         3       ALU     2
186 ;; fabs         3       ALU     2
187 ;; fadd         3       ALU     2
188 ;; fsub         3       ALU     2
189 ;; fcmp         3       ALU     2
190 ;; fcnv         3       ALU     2
191 ;; fmpyadd      3       ALU,MPY 2
192 ;; fmpysub      3       ALU,MPY 2
193 ;; fmpycfxt     3       ALU,MPY 2
194 ;; fmpy         3       MPY     2
195 ;; fmpyi        3       MPY     2
196 ;; fdiv,sgl     10      MPY     10
197 ;; fdiv,dbl     12      MPY     12
198 ;; fsqrt,sgl    14      MPY     14
199 ;; fsqrt,dbl    18      MPY     18
200 ;;
201 ;; We don't model fmpyadd/fmpysub properly as those instructions
202 ;; keep both the FP ALU and MPY units busy.  Given that these
203 ;; processors are obsolete, I'm not going to spend the time to
204 ;; model those instructions correctly.
205
206 (define_automaton "pa700")
207 (define_cpu_unit "dummy_700,mem_700,fpalu_700,fpmpy_700" "pa700")
208
209 (define_insn_reservation "W0" 4
210   (and (eq_attr "type" "fpcc")
211        (eq_attr "cpu" "700"))
212   "fpalu_700*2")
213
214 (define_insn_reservation "W1" 3
215   (and (eq_attr "type" "fpalu")
216        (eq_attr "cpu" "700"))
217   "fpalu_700*2")
218
219 (define_insn_reservation "W2" 3
220   (and (eq_attr "type" "fpmulsgl,fpmuldbl")
221        (eq_attr "cpu" "700"))
222   "fpmpy_700*2")
223
224 (define_insn_reservation "W3" 10
225   (and (eq_attr "type" "fpdivsgl")
226        (eq_attr "cpu" "700"))
227   "fpmpy_700*10")
228
229 (define_insn_reservation "W4" 12
230   (and (eq_attr "type" "fpdivdbl")
231        (eq_attr "cpu" "700"))
232   "fpmpy_700*12")
233
234 (define_insn_reservation "W5" 14
235   (and (eq_attr "type" "fpsqrtsgl")
236        (eq_attr "cpu" "700"))
237   "fpmpy_700*14")
238
239 (define_insn_reservation "W6" 18
240   (and (eq_attr "type" "fpsqrtdbl")
241        (eq_attr "cpu" "700"))
242   "fpmpy_700*18")
243
244 (define_insn_reservation "W7" 2
245   (and (eq_attr "type" "load")
246        (eq_attr "cpu" "700"))
247   "mem_700")
248
249 (define_insn_reservation "W8" 2
250   (and (eq_attr "type" "fpload")
251        (eq_attr "cpu" "700"))
252   "mem_700")
253
254 (define_insn_reservation "W9" 3
255   (and (eq_attr "type" "store")
256        (eq_attr "cpu" "700"))
257   "mem_700*3")
258
259 (define_insn_reservation "W10" 3
260   (and (eq_attr "type" "fpstore")
261        (eq_attr "cpu" "700"))
262   "mem_700*3")
263
264 (define_insn_reservation "W11" 5
265   (and (eq_attr "type" "fpstore_load")
266        (eq_attr "cpu" "700"))
267   "mem_700*5")
268
269 (define_insn_reservation "W12" 6
270   (and (eq_attr "type" "store_fpload")
271        (eq_attr "cpu" "700"))
272   "mem_700*6")
273
274 (define_insn_reservation "W13" 1
275   (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpdivdbl,fpsqrtsgl,fpsqrtdbl,load,fpload,store,fpstore,fpstore_load,store_fpload")
276        (eq_attr "cpu" "700"))
277   "dummy_700")
278
279 ;; We have a bypass for all computations in the FP unit which feed an
280 ;; FP store as long as the sizes are the same.
281 (define_bypass 2 "W1,W2" "W10,W11" "hppa_fpstore_bypass_p")
282 (define_bypass 9 "W3" "W10,W11" "hppa_fpstore_bypass_p")
283 (define_bypass 11 "W4" "W10,W11" "hppa_fpstore_bypass_p")
284 (define_bypass 13 "W5" "W10,W11" "hppa_fpstore_bypass_p")
285 (define_bypass 17 "W6" "W10,W11" "hppa_fpstore_bypass_p")
286
287 ;; We have an "anti-bypass" for FP loads which feed an FP store.
288 (define_bypass 4 "W8,W12" "W10,W11" "hppa_fpstore_bypass_p")
289
290 ;; Function units for the 7100 and 7150.  The 7100/7150 can dual-issue
291 ;; floating point computations with non-floating point computations (fp loads
292 ;; and stores are not fp computations).
293 ;;
294 ;; Memory. Disregarding Cache misses, memory loads take two cycles; stores also
295 ;; take two cycles, during which no Dcache operations should be scheduled.
296 ;; Any special cases are handled in pa_adjust_cost.  The 7100, 7150 and 7100LC
297 ;; all have the same memory characteristics if one disregards cache misses.
298 ;;
299 ;; The 7100/7150 has three floating-point units: ALU, MUL, and DIV.
300 ;; There's no value in modeling the ALU and MUL separately though
301 ;; since there can never be a functional unit conflict given the
302 ;; latency and issue rates for those units.
303 ;;
304 ;; Timings:
305 ;; Instruction  Time    Unit    Minimum Distance (unit contention)
306 ;; fcpy         2       ALU     1
307 ;; fabs         2       ALU     1
308 ;; fadd         2       ALU     1
309 ;; fsub         2       ALU     1
310 ;; fcmp         2       ALU     1
311 ;; fcnv         2       ALU     1
312 ;; fmpyadd      2       ALU,MPY 1
313 ;; fmpysub      2       ALU,MPY 1
314 ;; fmpycfxt     2       ALU,MPY 1
315 ;; fmpy         2       MPY     1
316 ;; fmpyi        2       MPY     1
317 ;; fdiv,sgl     8       DIV     8
318 ;; fdiv,dbl     15      DIV     15
319 ;; fsqrt,sgl    8       DIV     8
320 ;; fsqrt,dbl    15      DIV     15
321
322 (define_automaton "pa7100")
323 (define_cpu_unit "i_7100, f_7100,fpmac_7100,fpdivsqrt_7100,mem_7100" "pa7100")
324
325 (define_insn_reservation "X0" 2
326   (and (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
327        (eq_attr "cpu" "7100"))
328   "f_7100,fpmac_7100")
329
330 (define_insn_reservation "X1" 8
331   (and (eq_attr "type" "fpdivsgl,fpsqrtsgl")
332        (eq_attr "cpu" "7100"))
333   "f_7100+fpdivsqrt_7100,fpdivsqrt_7100*7")
334
335 (define_insn_reservation "X2" 15
336   (and (eq_attr "type" "fpdivdbl,fpsqrtdbl")
337        (eq_attr "cpu" "7100"))
338   "f_7100+fpdivsqrt_7100,fpdivsqrt_7100*14")
339
340 (define_insn_reservation "X3" 2
341   (and (eq_attr "type" "load")
342        (eq_attr "cpu" "7100"))
343   "i_7100+mem_7100")
344
345 (define_insn_reservation "X4" 2
346   (and (eq_attr "type" "fpload")
347        (eq_attr "cpu" "7100"))
348   "i_7100+mem_7100")
349
350 (define_insn_reservation "X5" 2
351   (and (eq_attr "type" "store")
352        (eq_attr "cpu" "7100"))
353   "i_7100+mem_7100,mem_7100")
354
355 (define_insn_reservation "X6" 2
356   (and (eq_attr "type" "fpstore")
357        (eq_attr "cpu" "7100"))
358   "i_7100+mem_7100,mem_7100")
359
360 (define_insn_reservation "X7" 4
361   (and (eq_attr "type" "fpstore_load")
362        (eq_attr "cpu" "7100"))
363   "i_7100+mem_7100,mem_7100*3")
364
365 (define_insn_reservation "X8" 4
366   (and (eq_attr "type" "store_fpload")
367        (eq_attr "cpu" "7100"))
368   "i_7100+mem_7100,mem_7100*3")
369
370 (define_insn_reservation "X9" 1
371   (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl,load,fpload,store,fpstore,fpstore_load,store_fpload")
372        (eq_attr "cpu" "7100"))
373   "i_7100")
374
375 ;; We have a bypass for all computations in the FP unit which feed an
376 ;; FP store as long as the sizes are the same.
377 (define_bypass 1 "X0" "X6,X7" "hppa_fpstore_bypass_p")
378 (define_bypass 7 "X1" "X6,X7" "hppa_fpstore_bypass_p")
379 (define_bypass 14 "X2" "X6,X7" "hppa_fpstore_bypass_p")
380
381 ;; We have an "anti-bypass" for FP loads which feed an FP store.
382 (define_bypass 3 "X4,X8" "X6,X7" "hppa_fpstore_bypass_p")
383
384 ;; The 7100LC has three floating-point units: ALU, MUL, and DIV.
385 ;; There's no value in modeling the ALU and MUL separately though
386 ;; since there can never be a functional unit conflict that
387 ;; can be avoided given the latency, issue rates and mandatory
388 ;; one cycle cpu-wide lock for a double precision fp multiply.
389 ;;
390 ;; Timings:
391 ;; Instruction  Time    Unit    Minimum Distance (unit contention)
392 ;; fcpy         2       ALU     1
393 ;; fabs         2       ALU     1
394 ;; fadd         2       ALU     1
395 ;; fsub         2       ALU     1
396 ;; fcmp         2       ALU     1
397 ;; fcnv         2       ALU     1
398 ;; fmpyadd,sgl  2       ALU,MPY 1
399 ;; fmpyadd,dbl  3       ALU,MPY 2
400 ;; fmpysub,sgl  2       ALU,MPY 1
401 ;; fmpysub,dbl  3       ALU,MPY 2
402 ;; fmpycfxt,sgl 2       ALU,MPY 1
403 ;; fmpycfxt,dbl 3       ALU,MPY 2
404 ;; fmpy,sgl     2       MPY     1
405 ;; fmpy,dbl     3       MPY     2
406 ;; fmpyi        3       MPY     2
407 ;; fdiv,sgl     8       DIV     8
408 ;; fdiv,dbl     15      DIV     15
409 ;; fsqrt,sgl    8       DIV     8
410 ;; fsqrt,dbl    15      DIV     15
411 ;;
412 ;; The PA7200 is just like the PA7100LC except that there is
413 ;; no store-store penalty.
414 ;;
415 ;; The PA7300 is just like the PA7200 except that there is
416 ;; no store-load penalty.
417 ;;
418 ;; Note there are some aspects of the 7100LC we are not modeling
419 ;; at the moment.  I'll be reviewing the 7100LC scheduling info
420 ;; shortly and updating this description.
421 ;;
422 ;;   load-load pairs
423 ;;   store-store pairs
424 ;;   other issue modeling
425
426 (define_automaton "pa7100lc")
427 (define_cpu_unit "i0_7100lc, i1_7100lc, f_7100lc" "pa7100lc")
428 (define_cpu_unit "fpmac_7100lc" "pa7100lc")
429 (define_cpu_unit "mem_7100lc" "pa7100lc")
430
431 ;; Double precision multiplies lock the entire CPU for one
432 ;; cycle.  There is no way to avoid this lock and trying to
433 ;; schedule around the lock is pointless and thus there is no
434 ;; value in trying to model this lock.
435 ;;
436 ;; Not modeling the lock allows us to treat fp multiplies just
437 ;; like any other FP alu instruction.  It allows for a smaller
438 ;; DFA and may reduce register pressure.
439 (define_insn_reservation "Y0" 2
440   (and (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
441        (eq_attr "cpu" "7100LC,7200,7300"))
442   "f_7100lc,fpmac_7100lc")
443
444 ;; fp division and sqrt instructions lock the entire CPU for
445 ;; 7 cycles (single precision) or 14 cycles (double precision).
446 ;; There is no way to avoid this lock and trying to schedule
447 ;; around the lock is pointless and thus there is no value in
448 ;; trying to model this lock.  Not modeling the lock allows
449 ;; for a smaller DFA and may reduce register pressure.
450 (define_insn_reservation "Y1" 1
451   (and (eq_attr "type" "fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl")
452        (eq_attr "cpu" "7100LC,7200,7300"))
453   "f_7100lc")
454
455 (define_insn_reservation "Y2" 2
456   (and (eq_attr "type" "load")
457        (eq_attr "cpu" "7100LC,7200,7300"))
458   "i1_7100lc+mem_7100lc")
459
460 (define_insn_reservation "Y3" 2
461   (and (eq_attr "type" "fpload")
462        (eq_attr "cpu" "7100LC,7200,7300"))
463   "i1_7100lc+mem_7100lc")
464
465 (define_insn_reservation "Y4" 2
466   (and (eq_attr "type" "store")
467        (eq_attr "cpu" "7100LC"))
468   "i1_7100lc+mem_7100lc,mem_7100lc")
469
470 (define_insn_reservation "Y5" 2
471   (and (eq_attr "type" "fpstore")
472        (eq_attr "cpu" "7100LC"))
473   "i1_7100lc+mem_7100lc,mem_7100lc")
474
475 (define_insn_reservation "Y6" 4
476   (and (eq_attr "type" "fpstore_load")
477        (eq_attr "cpu" "7100LC"))
478   "i1_7100lc+mem_7100lc,mem_7100lc*3")
479
480 (define_insn_reservation "Y7" 4
481   (and (eq_attr "type" "store_fpload")
482        (eq_attr "cpu" "7100LC"))
483   "i1_7100lc+mem_7100lc,mem_7100lc*3")
484
485 (define_insn_reservation "Y8" 1
486   (and (eq_attr "type" "shift,nullshift")
487        (eq_attr "cpu" "7100LC,7200,7300"))
488   "i1_7100lc")
489
490 (define_insn_reservation "Y9" 1
491   (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl,load,fpload,store,fpstore,shift,nullshift")
492        (eq_attr "cpu" "7100LC,7200,7300"))
493   "(i0_7100lc|i1_7100lc)")
494
495 ;; The 7200 has a store-load penalty
496 (define_insn_reservation "Y10" 2
497   (and (eq_attr "type" "store")
498        (eq_attr "cpu" "7200"))
499   "i1_7100lc,mem_7100lc")
500
501 (define_insn_reservation "Y11" 2
502   (and (eq_attr "type" "fpstore")
503        (eq_attr "cpu" "7200"))
504   "i1_7100lc,mem_7100lc")
505
506 (define_insn_reservation "Y12" 4
507   (and (eq_attr "type" "fpstore_load")
508        (eq_attr "cpu" "7200"))
509   "i1_7100lc,mem_7100lc,i1_7100lc+mem_7100lc")
510
511 (define_insn_reservation "Y13" 4
512   (and (eq_attr "type" "store_fpload")
513        (eq_attr "cpu" "7200"))
514   "i1_7100lc,mem_7100lc,i1_7100lc+mem_7100lc")
515
516 ;; The 7300 has no penalty for store-store or store-load
517 (define_insn_reservation "Y14" 2
518   (and (eq_attr "type" "store")
519        (eq_attr "cpu" "7300"))
520   "i1_7100lc")
521
522 (define_insn_reservation "Y15" 2
523   (and (eq_attr "type" "fpstore")
524        (eq_attr "cpu" "7300"))
525   "i1_7100lc")
526
527 (define_insn_reservation "Y16" 4
528   (and (eq_attr "type" "fpstore_load")
529        (eq_attr "cpu" "7300"))
530   "i1_7100lc,i1_7100lc+mem_7100lc")
531
532 (define_insn_reservation "Y17" 4
533   (and (eq_attr "type" "store_fpload")
534        (eq_attr "cpu" "7300"))
535   "i1_7100lc,i1_7100lc+mem_7100lc")
536
537 ;; We have an "anti-bypass" for FP loads which feed an FP store.
538 (define_bypass 3 "Y3,Y7,Y13,Y17" "Y5,Y6,Y11,Y12,Y15,Y16" "hppa_fpstore_bypass_p")
539
540 ;; Scheduling for the PA8000 is somewhat different than scheduling for a
541 ;; traditional architecture.
542 ;;
543 ;; The PA8000 has a large (56) entry reorder buffer that is split between
544 ;; memory and non-memory operations.
545 ;;
546 ;; The PA8000 can issue two memory and two non-memory operations per cycle to
547 ;; the function units, with the exception of branches and multi-output
548 ;; instructions.  The PA8000 can retire two non-memory operations per cycle
549 ;; and two memory operations per cycle, only one of which may be a store.
550 ;;
551 ;; Given the large reorder buffer, the processor can hide most latencies.
552 ;; According to HP, they've got the best results by scheduling for retirement
553 ;; bandwidth with limited latency scheduling for floating point operations.
554 ;; Latency for integer operations and memory references is ignored.
555 ;;
556 ;;
557 ;; We claim floating point operations have a 2 cycle latency and are
558 ;; fully pipelined, except for div and sqrt which are not pipelined and
559 ;; take from 17 to 31 cycles to complete.
560 ;;
561 ;; It's worth noting that there is no way to saturate all the functional
562 ;; units on the PA8000 as there is not enough issue bandwidth.
563
564 (define_automaton "pa8000")
565 (define_cpu_unit "inm0_8000, inm1_8000, im0_8000, im1_8000" "pa8000")
566 (define_cpu_unit "rnm0_8000, rnm1_8000, rm0_8000, rm1_8000" "pa8000")
567 (define_cpu_unit "store_8000" "pa8000")
568 (define_cpu_unit "f0_8000, f1_8000" "pa8000")
569 (define_cpu_unit "fdivsqrt0_8000, fdivsqrt1_8000" "pa8000")
570 (define_reservation "inm_8000" "inm0_8000 | inm1_8000")
571 (define_reservation "im_8000" "im0_8000 | im1_8000")
572 (define_reservation "rnm_8000" "rnm0_8000 | rnm1_8000")
573 (define_reservation "rm_8000" "rm0_8000 | rm1_8000")
574 (define_reservation "f_8000" "f0_8000 | f1_8000")
575 (define_reservation "fdivsqrt_8000" "fdivsqrt0_8000 | fdivsqrt1_8000")
576
577 ;; We can issue any two memops per cycle, but we can only retire
578 ;; one memory store per cycle.  We assume that the reorder buffer
579 ;; will hide any memory latencies per HP's recommendation.
580 (define_insn_reservation "Z0" 0
581   (and
582     (eq_attr "type" "load,fpload")
583     (eq_attr "cpu" "8000"))
584   "im_8000,rm_8000")
585
586 (define_insn_reservation "Z1" 0
587   (and
588     (eq_attr "type" "store,fpstore")
589     (eq_attr "cpu" "8000"))
590   "im_8000,rm_8000+store_8000")
591
592 (define_insn_reservation "Z2" 0
593   (and (eq_attr "type" "fpstore_load,store_fpload")
594        (eq_attr "cpu" "8000"))
595   "im_8000,rm_8000+store_8000,im_8000,rm_8000")
596
597 ;; We can issue and retire two non-memory operations per cycle with
598 ;; a few exceptions (branches).  This group catches those we want
599 ;; to assume have zero latency.
600 (define_insn_reservation "Z3" 0
601   (and
602     (eq_attr "type" "!load,fpload,store,fpstore,uncond_branch,btable_branch,branch,cbranch,fbranch,call,dyncall,multi,milli,parallel_branch,fpcc,fpalu,fpmulsgl,fpmuldbl,fpsqrtsgl,fpsqrtdbl,fpdivsgl,fpdivdbl,fpstore_load,store_fpload")
603     (eq_attr "cpu" "8000"))
604   "inm_8000,rnm_8000")
605
606 ;; Branches use both slots in the non-memory issue and
607 ;; retirement unit.
608 (define_insn_reservation "Z4" 0
609   (and
610     (eq_attr "type" "uncond_branch,btable_branch,branch,cbranch,fbranch,call,dyncall,multi,milli,parallel_branch")
611     (eq_attr "cpu" "8000"))
612   "inm0_8000+inm1_8000,rnm0_8000+rnm1_8000")
613
614 ;; We partial latency schedule the floating point units.
615 ;; They can issue/retire two at a time in the non-memory
616 ;; units.  We fix their latency at 2 cycles and they
617 ;; are fully pipelined.
618 (define_insn_reservation "Z5" 1
619  (and
620    (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
621    (eq_attr "cpu" "8000"))
622  "inm_8000,f_8000,rnm_8000")
623
624 ;; The fdivsqrt units are not pipelined and have a very long latency.  
625 ;; To keep the DFA from exploding, we do not show all the
626 ;; reservations for the divsqrt unit.
627 (define_insn_reservation "Z6" 17
628  (and
629    (eq_attr "type" "fpdivsgl,fpsqrtsgl")
630    (eq_attr "cpu" "8000"))
631  "inm_8000,fdivsqrt_8000*6,rnm_8000")
632
633 (define_insn_reservation "Z7" 31
634  (and
635    (eq_attr "type" "fpdivdbl,fpsqrtdbl")
636    (eq_attr "cpu" "8000"))
637  "inm_8000,fdivsqrt_8000*6,rnm_8000")
638
639 ;; Operand and operator predicates and constraints
640
641 (include "predicates.md")
642 (include "constraints.md")
643 \f
644 ;; Compare instructions.
645 ;; This controls RTL generation and register allocation.
646
647 ;; We generate RTL for comparisons and branches by having the cmpxx
648 ;; patterns store away the operands.  Then, the scc and bcc patterns
649 ;; emit RTL for both the compare and the branch.
650 ;;
651
652 (define_expand "cmpdi"
653   [(set (reg:CC 0)
654         (compare:CC (match_operand:DI 0 "reg_or_0_operand" "")
655                     (match_operand:DI 1 "register_operand" "")))]
656   "TARGET_64BIT"
657
658   "
659 {
660  hppa_compare_op0 = operands[0];
661  hppa_compare_op1 = operands[1];
662  hppa_branch_type = CMP_SI;
663  DONE;
664 }")
665
666 (define_expand "cmpsi"
667   [(set (reg:CC 0)
668         (compare:CC (match_operand:SI 0 "reg_or_0_operand" "")
669                     (match_operand:SI 1 "arith5_operand" "")))]
670   ""
671   "
672 {
673  hppa_compare_op0 = operands[0];
674  hppa_compare_op1 = operands[1];
675  hppa_branch_type = CMP_SI;
676  DONE;
677 }")
678
679 (define_expand "cmpsf"
680   [(set (reg:CCFP 0)
681         (compare:CCFP (match_operand:SF 0 "reg_or_0_operand" "")
682                       (match_operand:SF 1 "reg_or_0_operand" "")))]
683   "! TARGET_SOFT_FLOAT"
684   "
685 {
686   hppa_compare_op0 = operands[0];
687   hppa_compare_op1 = operands[1];
688   hppa_branch_type = CMP_SF;
689   DONE;
690 }")
691
692 (define_expand "cmpdf"
693   [(set (reg:CCFP 0)
694       (compare:CCFP (match_operand:DF 0 "reg_or_0_operand" "")
695                     (match_operand:DF 1 "reg_or_0_operand" "")))]
696   "! TARGET_SOFT_FLOAT"
697   "
698 {
699   hppa_compare_op0 = operands[0];
700   hppa_compare_op1 = operands[1];
701   hppa_branch_type = CMP_DF;
702   DONE;
703 }")
704
705 (define_insn ""
706   [(set (reg:CCFP 0)
707         (match_operator:CCFP 2 "comparison_operator"
708                              [(match_operand:SF 0 "reg_or_0_operand" "fG")
709                               (match_operand:SF 1 "reg_or_0_operand" "fG")]))]
710   "! TARGET_SOFT_FLOAT"
711   "fcmp,sgl,%Y2 %f0,%f1"
712   [(set_attr "length" "4")
713    (set_attr "type" "fpcc")])
714
715 (define_insn ""
716   [(set (reg:CCFP 0)
717         (match_operator:CCFP 2 "comparison_operator"
718                              [(match_operand:DF 0 "reg_or_0_operand" "fG")
719                               (match_operand:DF 1 "reg_or_0_operand" "fG")]))]
720   "! TARGET_SOFT_FLOAT"
721   "fcmp,dbl,%Y2 %f0,%f1"
722   [(set_attr "length" "4")
723    (set_attr "type" "fpcc")])
724
725 ;; Provide a means to emit the movccfp0 and movccfp1 optimization
726 ;; placeholders.  This is necessary in rare situations when a
727 ;; placeholder is re-emitted (see PR 8705).
728
729 (define_expand "movccfp"
730   [(set (reg:CCFP 0)
731         (match_operand 0 "const_int_operand" ""))]
732   "! TARGET_SOFT_FLOAT"
733   "
734 {
735   if ((unsigned HOST_WIDE_INT) INTVAL (operands[0]) > 1)
736     FAIL;
737 }")
738
739 ;; The following patterns are optimization placeholders.  In almost
740 ;; all cases, the user of the condition code will be simplified and the
741 ;; original condition code setting insn should be eliminated.
742
743 (define_insn "*movccfp0"
744   [(set (reg:CCFP 0)
745         (const_int 0))]
746   "! TARGET_SOFT_FLOAT"
747   "fcmp,dbl,= %%fr0,%%fr0"
748   [(set_attr "length" "4")
749    (set_attr "type" "fpcc")])
750
751 (define_insn "*movccfp1"
752   [(set (reg:CCFP 0)
753         (const_int 1))]
754   "! TARGET_SOFT_FLOAT"
755   "fcmp,dbl,!= %%fr0,%%fr0"
756   [(set_attr "length" "4")
757    (set_attr "type" "fpcc")])
758
759 ;; scc insns.
760
761 (define_expand "seq"
762   [(set (match_operand:SI 0 "register_operand" "")
763         (eq:SI (match_dup 1)
764                (match_dup 2)))]
765   "!TARGET_64BIT"
766   "
767 {
768   /* fp scc patterns rarely match, and are not a win on the PA.  */
769   if (hppa_branch_type != CMP_SI)
770     FAIL;
771   /* set up operands from compare.  */
772   operands[1] = hppa_compare_op0;
773   operands[2] = hppa_compare_op1;
774   /* fall through and generate default code */
775 }")
776
777 (define_expand "sne"
778   [(set (match_operand:SI 0 "register_operand" "")
779         (ne:SI (match_dup 1)
780                (match_dup 2)))]
781   "!TARGET_64BIT"
782   "
783 {
784   /* fp scc patterns rarely match, and are not a win on the PA.  */
785   if (hppa_branch_type != CMP_SI)
786     FAIL;
787   operands[1] = hppa_compare_op0;
788   operands[2] = hppa_compare_op1;
789 }")
790
791 (define_expand "slt"
792   [(set (match_operand:SI 0 "register_operand" "")
793         (lt:SI (match_dup 1)
794                (match_dup 2)))]
795   "!TARGET_64BIT"
796   "
797 {
798   /* fp scc patterns rarely match, and are not a win on the PA.  */
799   if (hppa_branch_type != CMP_SI)
800     FAIL;
801   operands[1] = hppa_compare_op0;
802   operands[2] = hppa_compare_op1;
803 }")
804
805 (define_expand "sgt"
806   [(set (match_operand:SI 0 "register_operand" "")
807         (gt:SI (match_dup 1)
808                (match_dup 2)))]
809   "!TARGET_64BIT"
810   "
811 {
812   /* fp scc patterns rarely match, and are not a win on the PA.  */
813   if (hppa_branch_type != CMP_SI)
814     FAIL;
815   operands[1] = hppa_compare_op0;
816   operands[2] = hppa_compare_op1;
817 }")
818
819 (define_expand "sle"
820   [(set (match_operand:SI 0 "register_operand" "")
821         (le:SI (match_dup 1)
822                (match_dup 2)))]
823   "!TARGET_64BIT"
824   "
825 {
826   /* fp scc patterns rarely match, and are not a win on the PA.  */
827   if (hppa_branch_type != CMP_SI)
828     FAIL;
829   operands[1] = hppa_compare_op0;
830   operands[2] = hppa_compare_op1;
831 }")
832
833 (define_expand "sge"
834   [(set (match_operand:SI 0 "register_operand" "")
835         (ge:SI (match_dup 1)
836                (match_dup 2)))]
837   "!TARGET_64BIT"
838   "
839 {
840   /* fp scc patterns rarely match, and are not a win on the PA.  */
841   if (hppa_branch_type != CMP_SI)
842     FAIL;
843   operands[1] = hppa_compare_op0;
844   operands[2] = hppa_compare_op1;
845 }")
846
847 (define_expand "sltu"
848   [(set (match_operand:SI 0 "register_operand" "")
849         (ltu:SI (match_dup 1)
850                 (match_dup 2)))]
851   "!TARGET_64BIT"
852   "
853 {
854   if (hppa_branch_type != CMP_SI)
855     FAIL;
856   operands[1] = hppa_compare_op0;
857   operands[2] = hppa_compare_op1;
858 }")
859
860 (define_expand "sgtu"
861   [(set (match_operand:SI 0 "register_operand" "")
862         (gtu:SI (match_dup 1)
863                 (match_dup 2)))]
864   "!TARGET_64BIT"
865   "
866 {
867   if (hppa_branch_type != CMP_SI)
868     FAIL;
869   operands[1] = hppa_compare_op0;
870   operands[2] = hppa_compare_op1;
871 }")
872
873 (define_expand "sleu"
874   [(set (match_operand:SI 0 "register_operand" "")
875         (leu:SI (match_dup 1)
876                 (match_dup 2)))]
877   "!TARGET_64BIT"
878   "
879 {
880   if (hppa_branch_type != CMP_SI)
881     FAIL;
882   operands[1] = hppa_compare_op0;
883   operands[2] = hppa_compare_op1;
884 }")
885
886 (define_expand "sgeu"
887   [(set (match_operand:SI 0 "register_operand" "")
888         (geu:SI (match_dup 1)
889                 (match_dup 2)))]
890   "!TARGET_64BIT"
891   "
892 {
893   if (hppa_branch_type != CMP_SI)
894     FAIL;
895   operands[1] = hppa_compare_op0;
896   operands[2] = hppa_compare_op1;
897 }")
898
899 ;; Instruction canonicalization puts immediate operands second, which
900 ;; is the reverse of what we want.
901
902 (define_insn "scc"
903   [(set (match_operand:SI 0 "register_operand" "=r")
904         (match_operator:SI 3 "comparison_operator"
905                            [(match_operand:SI 1 "register_operand" "r")
906                             (match_operand:SI 2 "arith11_operand" "rI")]))]
907   ""
908   "{com%I2clr|cmp%I2clr},%B3 %2,%1,%0\;ldi 1,%0"
909   [(set_attr "type" "binary")
910    (set_attr "length" "8")])
911
912 (define_insn ""
913   [(set (match_operand:DI 0 "register_operand" "=r")
914         (match_operator:DI 3 "comparison_operator"
915                            [(match_operand:DI 1 "register_operand" "r")
916                             (match_operand:DI 2 "arith11_operand" "rI")]))]
917   "TARGET_64BIT"
918   "cmp%I2clr,*%B3 %2,%1,%0\;ldi 1,%0"
919   [(set_attr "type" "binary")
920    (set_attr "length" "8")])
921
922 (define_insn "iorscc"
923   [(set (match_operand:SI 0 "register_operand" "=r")
924         (ior:SI (match_operator:SI 3 "comparison_operator"
925                                    [(match_operand:SI 1 "register_operand" "r")
926                                     (match_operand:SI 2 "arith11_operand" "rI")])
927                 (match_operator:SI 6 "comparison_operator"
928                                    [(match_operand:SI 4 "register_operand" "r")
929                                     (match_operand:SI 5 "arith11_operand" "rI")])))]
930   ""
931   "{com%I2clr|cmp%I2clr},%S3 %2,%1,%%r0\;{com%I5clr|cmp%I5clr},%B6 %5,%4,%0\;ldi 1,%0"
932   [(set_attr "type" "binary")
933    (set_attr "length" "12")])
934
935 (define_insn ""
936   [(set (match_operand:DI 0 "register_operand" "=r")
937         (ior:DI (match_operator:DI 3 "comparison_operator"
938                                    [(match_operand:DI 1 "register_operand" "r")
939                                     (match_operand:DI 2 "arith11_operand" "rI")])
940                 (match_operator:DI 6 "comparison_operator"
941                                    [(match_operand:DI 4 "register_operand" "r")
942                                     (match_operand:DI 5 "arith11_operand" "rI")])))]
943   "TARGET_64BIT"
944   "cmp%I2clr,*%S3 %2,%1,%%r0\;cmp%I5clr,*%B6 %5,%4,%0\;ldi 1,%0"
945   [(set_attr "type" "binary")
946    (set_attr "length" "12")])
947
948 ;; Combiner patterns for common operations performed with the output
949 ;; from an scc insn (negscc and incscc).
950 (define_insn "negscc"
951   [(set (match_operand:SI 0 "register_operand" "=r")
952         (neg:SI (match_operator:SI 3 "comparison_operator"
953                [(match_operand:SI 1 "register_operand" "r")
954                 (match_operand:SI 2 "arith11_operand" "rI")])))]
955   ""
956   "{com%I2clr|cmp%I2clr},%B3 %2,%1,%0\;ldi -1,%0"
957   [(set_attr "type" "binary")
958    (set_attr "length" "8")])
959
960 (define_insn ""
961   [(set (match_operand:DI 0 "register_operand" "=r")
962         (neg:DI (match_operator:DI 3 "comparison_operator"
963                [(match_operand:DI 1 "register_operand" "r")
964                 (match_operand:DI 2 "arith11_operand" "rI")])))]
965   "TARGET_64BIT"
966   "cmp%I2clr,*%B3 %2,%1,%0\;ldi -1,%0"
967   [(set_attr "type" "binary")
968    (set_attr "length" "8")])
969
970 ;; Patterns for adding/subtracting the result of a boolean expression from
971 ;; a register.  First we have special patterns that make use of the carry
972 ;; bit, and output only two instructions.  For the cases we can't in
973 ;; general do in two instructions, the incscc pattern at the end outputs
974 ;; two or three instructions.
975
976 (define_insn ""
977   [(set (match_operand:SI 0 "register_operand" "=r")
978         (plus:SI (leu:SI (match_operand:SI 2 "register_operand" "r")
979                          (match_operand:SI 3 "arith11_operand" "rI"))
980                  (match_operand:SI 1 "register_operand" "r")))]
981   ""
982   "sub%I3 %3,%2,%%r0\;{addc|add,c} %%r0,%1,%0"
983   [(set_attr "type" "binary")
984    (set_attr "length" "8")])
985
986 (define_insn ""
987   [(set (match_operand:DI 0 "register_operand" "=r")
988         (plus:DI (leu:DI (match_operand:DI 2 "register_operand" "r")
989                          (match_operand:DI 3 "arith11_operand" "rI"))
990                  (match_operand:DI 1 "register_operand" "r")))]
991   "TARGET_64BIT"
992   "sub%I3 %3,%2,%%r0\;add,dc %%r0,%1,%0"
993   [(set_attr "type" "binary")
994    (set_attr "length" "8")])
995
996 ; This need only accept registers for op3, since canonicalization
997 ; replaces geu with gtu when op3 is an integer.
998 (define_insn ""
999   [(set (match_operand:SI 0 "register_operand" "=r")
1000         (plus:SI (geu:SI (match_operand:SI 2 "register_operand" "r")
1001                          (match_operand:SI 3 "register_operand" "r"))
1002                  (match_operand:SI 1 "register_operand" "r")))]
1003   ""
1004   "sub %2,%3,%%r0\;{addc|add,c} %%r0,%1,%0"
1005   [(set_attr "type" "binary")
1006    (set_attr "length" "8")])
1007
1008 (define_insn ""
1009   [(set (match_operand:DI 0 "register_operand" "=r")
1010         (plus:DI (geu:DI (match_operand:DI 2 "register_operand" "r")
1011                          (match_operand:DI 3 "register_operand" "r"))
1012                  (match_operand:DI 1 "register_operand" "r")))]
1013   "TARGET_64BIT"
1014   "sub %2,%3,%%r0\;add,dc %%r0,%1,%0"
1015   [(set_attr "type" "binary")
1016    (set_attr "length" "8")])
1017
1018 ; Match only integers for op3 here.  This is used as canonical form of the
1019 ; geu pattern when op3 is an integer.  Don't match registers since we can't
1020 ; make better code than the general incscc pattern.
1021 (define_insn ""
1022   [(set (match_operand:SI 0 "register_operand" "=r")
1023         (plus:SI (gtu:SI (match_operand:SI 2 "register_operand" "r")
1024                          (match_operand:SI 3 "int11_operand" "I"))
1025                  (match_operand:SI 1 "register_operand" "r")))]
1026   ""
1027   "addi %k3,%2,%%r0\;{addc|add,c} %%r0,%1,%0"
1028   [(set_attr "type" "binary")
1029    (set_attr "length" "8")])
1030
1031 (define_insn ""
1032   [(set (match_operand:DI 0 "register_operand" "=r")
1033         (plus:DI (gtu:DI (match_operand:DI 2 "register_operand" "r")
1034                          (match_operand:DI 3 "int11_operand" "I"))
1035                  (match_operand:DI 1 "register_operand" "r")))]
1036   "TARGET_64BIT"
1037   "addi %k3,%2,%%r0\;add,dc %%r0,%1,%0"
1038   [(set_attr "type" "binary")
1039    (set_attr "length" "8")])
1040
1041 (define_insn "incscc"
1042   [(set (match_operand:SI 0 "register_operand" "=r,r")
1043         (plus:SI (match_operator:SI 4 "comparison_operator"
1044                     [(match_operand:SI 2 "register_operand" "r,r")
1045                      (match_operand:SI 3 "arith11_operand" "rI,rI")])
1046                  (match_operand:SI 1 "register_operand" "0,?r")))]
1047   ""
1048   "@
1049    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi 1,%0,%0
1050    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi,tr 1,%1,%0\;copy %1,%0"
1051   [(set_attr "type" "binary,binary")
1052    (set_attr "length" "8,12")])
1053
1054 (define_insn ""
1055   [(set (match_operand:DI 0 "register_operand" "=r,r")
1056         (plus:DI (match_operator:DI 4 "comparison_operator"
1057                     [(match_operand:DI 2 "register_operand" "r,r")
1058                      (match_operand:DI 3 "arith11_operand" "rI,rI")])
1059                  (match_operand:DI 1 "register_operand" "0,?r")))]
1060   "TARGET_64BIT"
1061   "@
1062    cmp%I3clr,*%B4 %3,%2,%%r0\;addi 1,%0,%0
1063    cmp%I3clr,*%B4 %3,%2,%%r0\;addi,tr 1,%1,%0\;copy %1,%0"
1064   [(set_attr "type" "binary,binary")
1065    (set_attr "length" "8,12")])
1066
1067 (define_insn ""
1068   [(set (match_operand:SI 0 "register_operand" "=r")
1069         (minus:SI (match_operand:SI 1 "register_operand" "r")
1070                   (gtu:SI (match_operand:SI 2 "register_operand" "r")
1071                           (match_operand:SI 3 "arith11_operand" "rI"))))]
1072   ""
1073   "sub%I3 %3,%2,%%r0\;{subb|sub,b} %1,%%r0,%0"
1074   [(set_attr "type" "binary")
1075    (set_attr "length" "8")])
1076
1077 (define_insn ""
1078   [(set (match_operand:DI 0 "register_operand" "=r")
1079         (minus:DI (match_operand:DI 1 "register_operand" "r")
1080                   (gtu:DI (match_operand:DI 2 "register_operand" "r")
1081                           (match_operand:DI 3 "arith11_operand" "rI"))))]
1082   "TARGET_64BIT"
1083   "sub%I3 %3,%2,%%r0\;sub,db %1,%%r0,%0"
1084   [(set_attr "type" "binary")
1085    (set_attr "length" "8")])
1086
1087 (define_insn ""
1088   [(set (match_operand:SI 0 "register_operand" "=r")
1089         (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
1090                             (gtu:SI (match_operand:SI 2 "register_operand" "r")
1091                                     (match_operand:SI 3 "arith11_operand" "rI")))
1092                   (match_operand:SI 4 "register_operand" "r")))]
1093   ""
1094   "sub%I3 %3,%2,%%r0\;{subb|sub,b} %1,%4,%0"
1095   [(set_attr "type" "binary")
1096    (set_attr "length" "8")])
1097
1098 (define_insn ""
1099   [(set (match_operand:DI 0 "register_operand" "=r")
1100         (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
1101                             (gtu:DI (match_operand:DI 2 "register_operand" "r")
1102                                     (match_operand:DI 3 "arith11_operand" "rI")))
1103                   (match_operand:DI 4 "register_operand" "r")))]
1104   "TARGET_64BIT"
1105   "sub%I3 %3,%2,%%r0\;sub,db %1,%4,%0"
1106   [(set_attr "type" "binary")
1107    (set_attr "length" "8")])
1108
1109 ; This need only accept registers for op3, since canonicalization
1110 ; replaces ltu with leu when op3 is an integer.
1111 (define_insn ""
1112   [(set (match_operand:SI 0 "register_operand" "=r")
1113         (minus:SI (match_operand:SI 1 "register_operand" "r")
1114                   (ltu:SI (match_operand:SI 2 "register_operand" "r")
1115                           (match_operand:SI 3 "register_operand" "r"))))]
1116   ""
1117   "sub %2,%3,%%r0\;{subb|sub,b} %1,%%r0,%0"
1118   [(set_attr "type" "binary")
1119    (set_attr "length" "8")])
1120
1121 (define_insn ""
1122   [(set (match_operand:DI 0 "register_operand" "=r")
1123         (minus:DI (match_operand:DI 1 "register_operand" "r")
1124                   (ltu:DI (match_operand:DI 2 "register_operand" "r")
1125                           (match_operand:DI 3 "register_operand" "r"))))]
1126   "TARGET_64BIT"
1127   "sub %2,%3,%%r0\;sub,db %1,%%r0,%0"
1128   [(set_attr "type" "binary")
1129    (set_attr "length" "8")])
1130
1131 (define_insn ""
1132   [(set (match_operand:SI 0 "register_operand" "=r")
1133         (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
1134                             (ltu:SI (match_operand:SI 2 "register_operand" "r")
1135                                     (match_operand:SI 3 "register_operand" "r")))
1136                   (match_operand:SI 4 "register_operand" "r")))]
1137   ""
1138   "sub %2,%3,%%r0\;{subb|sub,b} %1,%4,%0"
1139   [(set_attr "type" "binary")
1140    (set_attr "length" "8")])
1141
1142 (define_insn ""
1143   [(set (match_operand:DI 0 "register_operand" "=r")
1144         (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
1145                             (ltu:DI (match_operand:DI 2 "register_operand" "r")
1146                                     (match_operand:DI 3 "register_operand" "r")))
1147                   (match_operand:DI 4 "register_operand" "r")))]
1148   "TARGET_64BIT"
1149   "sub %2,%3,%%r0\;sub,db %1,%4,%0"
1150   [(set_attr "type" "binary")
1151    (set_attr "length" "8")])
1152
1153 ; Match only integers for op3 here.  This is used as canonical form of the
1154 ; ltu pattern when op3 is an integer.  Don't match registers since we can't
1155 ; make better code than the general incscc pattern.
1156 (define_insn ""
1157   [(set (match_operand:SI 0 "register_operand" "=r")
1158         (minus:SI (match_operand:SI 1 "register_operand" "r")
1159                   (leu:SI (match_operand:SI 2 "register_operand" "r")
1160                           (match_operand:SI 3 "int11_operand" "I"))))]
1161   ""
1162   "addi %k3,%2,%%r0\;{subb|sub,b} %1,%%r0,%0"
1163   [(set_attr "type" "binary")
1164    (set_attr "length" "8")])
1165
1166 (define_insn ""
1167   [(set (match_operand:DI 0 "register_operand" "=r")
1168         (minus:DI (match_operand:DI 1 "register_operand" "r")
1169                   (leu:DI (match_operand:DI 2 "register_operand" "r")
1170                           (match_operand:DI 3 "int11_operand" "I"))))]
1171   "TARGET_64BIT"
1172   "addi %k3,%2,%%r0\;sub,db %1,%%r0,%0"
1173   [(set_attr "type" "binary")
1174    (set_attr "length" "8")])
1175
1176 (define_insn ""
1177   [(set (match_operand:SI 0 "register_operand" "=r")
1178         (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
1179                             (leu:SI (match_operand:SI 2 "register_operand" "r")
1180                                     (match_operand:SI 3 "int11_operand" "I")))
1181                   (match_operand:SI 4 "register_operand" "r")))]
1182   ""
1183   "addi %k3,%2,%%r0\;{subb|sub,b} %1,%4,%0"
1184   [(set_attr "type" "binary")
1185    (set_attr "length" "8")])
1186
1187 (define_insn ""
1188   [(set (match_operand:DI 0 "register_operand" "=r")
1189         (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
1190                             (leu:DI (match_operand:DI 2 "register_operand" "r")
1191                                     (match_operand:DI 3 "int11_operand" "I")))
1192                   (match_operand:DI 4 "register_operand" "r")))]
1193   "TARGET_64BIT"
1194   "addi %k3,%2,%%r0\;sub,db %1,%4,%0"
1195   [(set_attr "type" "binary")
1196    (set_attr "length" "8")])
1197
1198 (define_insn "decscc"
1199   [(set (match_operand:SI 0 "register_operand" "=r,r")
1200         (minus:SI (match_operand:SI 1 "register_operand" "0,?r")
1201                   (match_operator:SI 4 "comparison_operator"
1202                      [(match_operand:SI 2 "register_operand" "r,r")
1203                       (match_operand:SI 3 "arith11_operand" "rI,rI")])))]
1204   ""
1205   "@
1206    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi -1,%0,%0
1207    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi,tr -1,%1,%0\;copy %1,%0"
1208   [(set_attr "type" "binary,binary")
1209    (set_attr "length" "8,12")])
1210
1211 (define_insn ""
1212   [(set (match_operand:DI 0 "register_operand" "=r,r")
1213         (minus:DI (match_operand:DI 1 "register_operand" "0,?r")
1214                   (match_operator:DI 4 "comparison_operator"
1215                      [(match_operand:DI 2 "register_operand" "r,r")
1216                       (match_operand:DI 3 "arith11_operand" "rI,rI")])))]
1217   "TARGET_64BIT"
1218   "@
1219    cmp%I3clr,*%B4 %3,%2,%%r0\;addi -1,%0,%0
1220    cmp%I3clr,*%B4 %3,%2,%%r0\;addi,tr -1,%1,%0\;copy %1,%0"
1221   [(set_attr "type" "binary,binary")
1222    (set_attr "length" "8,12")])
1223
1224 ; Patterns for max and min.  (There is no need for an earlyclobber in the
1225 ; last alternative since the middle alternative will match if op0 == op1.)
1226
1227 (define_insn "sminsi3"
1228   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1229         (smin:SI (match_operand:SI 1 "register_operand" "%0,0,r")
1230                  (match_operand:SI 2 "arith11_operand" "r,I,M")))]
1231   ""
1232   "@
1233   {comclr|cmpclr},> %2,%0,%%r0\;copy %2,%0
1234   {comiclr|cmpiclr},> %2,%0,%%r0\;ldi %2,%0
1235   {comclr|cmpclr},> %1,%r2,%0\;copy %1,%0"
1236 [(set_attr "type" "multi,multi,multi")
1237  (set_attr "length" "8,8,8")])
1238
1239 (define_insn "smindi3"
1240   [(set (match_operand:DI 0 "register_operand" "=r,r,r")
1241         (smin:DI (match_operand:DI 1 "register_operand" "%0,0,r")
1242                  (match_operand:DI 2 "arith11_operand" "r,I,M")))]
1243   "TARGET_64BIT"
1244   "@
1245   cmpclr,*> %2,%0,%%r0\;copy %2,%0
1246   cmpiclr,*> %2,%0,%%r0\;ldi %2,%0
1247   cmpclr,*> %1,%r2,%0\;copy %1,%0"
1248 [(set_attr "type" "multi,multi,multi")
1249  (set_attr "length" "8,8,8")])
1250
1251 (define_insn "uminsi3"
1252   [(set (match_operand:SI 0 "register_operand" "=r,r")
1253         (umin:SI (match_operand:SI 1 "register_operand" "%0,0")
1254                  (match_operand:SI 2 "arith11_operand" "r,I")))]
1255   ""
1256   "@
1257   {comclr|cmpclr},>> %2,%0,%%r0\;copy %2,%0
1258   {comiclr|cmpiclr},>> %2,%0,%%r0\;ldi %2,%0"
1259 [(set_attr "type" "multi,multi")
1260  (set_attr "length" "8,8")])
1261
1262 (define_insn "umindi3"
1263   [(set (match_operand:DI 0 "register_operand" "=r,r")
1264         (umin:DI (match_operand:DI 1 "register_operand" "%0,0")
1265                  (match_operand:DI 2 "arith11_operand" "r,I")))]
1266   "TARGET_64BIT"
1267   "@
1268   cmpclr,*>> %2,%0,%%r0\;copy %2,%0
1269   cmpiclr,*>> %2,%0,%%r0\;ldi %2,%0"
1270 [(set_attr "type" "multi,multi")
1271  (set_attr "length" "8,8")])
1272
1273 (define_insn "smaxsi3"
1274   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1275         (smax:SI (match_operand:SI 1 "register_operand" "%0,0,r")
1276                  (match_operand:SI 2 "arith11_operand" "r,I,M")))]
1277   ""
1278   "@
1279   {comclr|cmpclr},< %2,%0,%%r0\;copy %2,%0
1280   {comiclr|cmpiclr},< %2,%0,%%r0\;ldi %2,%0
1281   {comclr|cmpclr},< %1,%r2,%0\;copy %1,%0"
1282 [(set_attr "type" "multi,multi,multi")
1283  (set_attr "length" "8,8,8")])
1284
1285 (define_insn "smaxdi3"
1286   [(set (match_operand:DI 0 "register_operand" "=r,r,r")
1287         (smax:DI (match_operand:DI 1 "register_operand" "%0,0,r")
1288                  (match_operand:DI 2 "arith11_operand" "r,I,M")))]
1289   "TARGET_64BIT"
1290   "@
1291   cmpclr,*< %2,%0,%%r0\;copy %2,%0
1292   cmpiclr,*< %2,%0,%%r0\;ldi %2,%0
1293   cmpclr,*< %1,%r2,%0\;copy %1,%0"
1294 [(set_attr "type" "multi,multi,multi")
1295  (set_attr "length" "8,8,8")])
1296
1297 (define_insn "umaxsi3"
1298   [(set (match_operand:SI 0 "register_operand" "=r,r")
1299         (umax:SI (match_operand:SI 1 "register_operand" "%0,0")
1300                  (match_operand:SI 2 "arith11_operand" "r,I")))]
1301   ""
1302   "@
1303   {comclr|cmpclr},<< %2,%0,%%r0\;copy %2,%0
1304   {comiclr|cmpiclr},<< %2,%0,%%r0\;ldi %2,%0"
1305 [(set_attr "type" "multi,multi")
1306  (set_attr "length" "8,8")])
1307
1308 (define_insn "umaxdi3"
1309   [(set (match_operand:DI 0 "register_operand" "=r,r")
1310         (umax:DI (match_operand:DI 1 "register_operand" "%0,0")
1311                  (match_operand:DI 2 "arith11_operand" "r,I")))]
1312   "TARGET_64BIT"
1313   "@
1314   cmpclr,*<< %2,%0,%%r0\;copy %2,%0
1315   cmpiclr,*<< %2,%0,%%r0\;ldi %2,%0"
1316 [(set_attr "type" "multi,multi")
1317  (set_attr "length" "8,8")])
1318
1319 (define_insn "abssi2"
1320   [(set (match_operand:SI 0 "register_operand" "=r")
1321         (abs:SI (match_operand:SI 1 "register_operand" "r")))]
1322   ""
1323   "or,>= %%r0,%1,%0\;subi 0,%0,%0"
1324   [(set_attr "type" "multi")
1325    (set_attr "length" "8")])
1326
1327 (define_insn "absdi2"
1328   [(set (match_operand:DI 0 "register_operand" "=r")
1329         (abs:DI (match_operand:DI 1 "register_operand" "r")))]
1330   "TARGET_64BIT"
1331   "or,*>= %%r0,%1,%0\;subi 0,%0,%0"
1332   [(set_attr "type" "multi")
1333    (set_attr "length" "8")])
1334
1335 ;;; Experimental conditional move patterns
1336
1337 (define_expand "movsicc"
1338   [(set (match_operand:SI 0 "register_operand" "")
1339         (if_then_else:SI
1340          (match_operator 1 "comparison_operator"
1341             [(match_dup 4)
1342              (match_dup 5)])
1343          (match_operand:SI 2 "reg_or_cint_move_operand" "")
1344          (match_operand:SI 3 "reg_or_cint_move_operand" "")))]
1345   ""
1346   "
1347 {
1348   enum rtx_code code = GET_CODE (operands[1]);
1349
1350   if (hppa_branch_type != CMP_SI)
1351     FAIL;
1352
1353   if (GET_MODE (hppa_compare_op0) != GET_MODE (hppa_compare_op1)
1354       || GET_MODE (hppa_compare_op0) != GET_MODE (operands[0]))
1355     FAIL;
1356
1357   /* operands[1] is currently the result of compare_from_rtx.  We want to
1358      emit a compare of the original operands.  */
1359   operands[1] = gen_rtx_fmt_ee (code, SImode, hppa_compare_op0, hppa_compare_op1);
1360   operands[4] = hppa_compare_op0;
1361   operands[5] = hppa_compare_op1;
1362 }")
1363
1364 ;; We used to accept any register for op1.
1365 ;;
1366 ;; However, it loses sometimes because the compiler will end up using
1367 ;; different registers for op0 and op1 in some critical cases.  local-alloc
1368 ;; will  not tie op0 and op1 because op0 is used in multiple basic blocks.
1369 ;;
1370 ;; If/when global register allocation supports tying we should allow any
1371 ;; register for op1 again.
1372 (define_insn ""
1373   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
1374         (if_then_else:SI
1375          (match_operator 2 "comparison_operator"
1376             [(match_operand:SI 3 "register_operand" "r,r,r,r")
1377              (match_operand:SI 4 "arith11_operand" "rI,rI,rI,rI")])
1378          (match_operand:SI 1 "reg_or_cint_move_operand" "0,J,N,K")
1379          (const_int 0)))]
1380   ""
1381   "@
1382    {com%I4clr|cmp%I4clr},%S2 %4,%3,%%r0\;ldi 0,%0
1383    {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;ldi %1,%0
1384    {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;ldil L'%1,%0
1385    {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;{zdepi|depwi,z} %Z1,%0"
1386   [(set_attr "type" "multi,multi,multi,nullshift")
1387    (set_attr "length" "8,8,8,8")])
1388
1389 (define_insn ""
1390   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r,r,r")
1391         (if_then_else:SI
1392          (match_operator 5 "comparison_operator"
1393             [(match_operand:SI 3 "register_operand" "r,r,r,r,r,r,r,r")
1394              (match_operand:SI 4 "arith11_operand" "rI,rI,rI,rI,rI,rI,rI,rI")])
1395          (match_operand:SI 1 "reg_or_cint_move_operand" "0,0,0,0,r,J,N,K")
1396          (match_operand:SI 2 "reg_or_cint_move_operand" "r,J,N,K,0,0,0,0")))]
1397   ""
1398   "@
1399    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;copy %2,%0
1400    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;ldi %2,%0
1401    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;ldil L'%2,%0
1402    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;{zdepi|depwi,z} %Z2,%0
1403    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;copy %1,%0
1404    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;ldi %1,%0
1405    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;ldil L'%1,%0
1406    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;{zdepi|depwi,z} %Z1,%0"
1407   [(set_attr "type" "multi,multi,multi,nullshift,multi,multi,multi,nullshift")
1408    (set_attr "length" "8,8,8,8,8,8,8,8")])
1409
1410 (define_expand "movdicc"
1411   [(set (match_operand:DI 0 "register_operand" "")
1412         (if_then_else:DI
1413          (match_operator 1 "comparison_operator"
1414             [(match_dup 4)
1415              (match_dup 5)])
1416          (match_operand:DI 2 "reg_or_cint_move_operand" "")
1417          (match_operand:DI 3 "reg_or_cint_move_operand" "")))]
1418   "TARGET_64BIT"
1419   "
1420 {
1421   enum rtx_code code = GET_CODE (operands[1]);
1422
1423   if (hppa_branch_type != CMP_SI)
1424     FAIL;
1425
1426   if (GET_MODE (hppa_compare_op0) != GET_MODE (hppa_compare_op1)
1427       || GET_MODE (hppa_compare_op0) != GET_MODE (operands[0]))
1428     FAIL;
1429
1430   /* operands[1] is currently the result of compare_from_rtx.  We want to
1431      emit a compare of the original operands.  */
1432   operands[1] = gen_rtx_fmt_ee (code, DImode, hppa_compare_op0, hppa_compare_op1);
1433   operands[4] = hppa_compare_op0;
1434   operands[5] = hppa_compare_op1;
1435 }")
1436
1437 ; We need the first constraint alternative in order to avoid
1438 ; earlyclobbers on all other alternatives.
1439 (define_insn ""
1440   [(set (match_operand:DI 0 "register_operand" "=r,r,r,r,r")
1441         (if_then_else:DI
1442          (match_operator 2 "comparison_operator"
1443             [(match_operand:DI 3 "register_operand" "r,r,r,r,r")
1444              (match_operand:DI 4 "arith11_operand" "rI,rI,rI,rI,rI")])
1445          (match_operand:DI 1 "reg_or_cint_move_operand" "0,r,J,N,K")
1446          (const_int 0)))]
1447   "TARGET_64BIT"
1448   "@
1449    cmp%I4clr,*%S2 %4,%3,%%r0\;ldi 0,%0
1450    cmp%I4clr,*%B2 %4,%3,%0\;copy %1,%0
1451    cmp%I4clr,*%B2 %4,%3,%0\;ldi %1,%0
1452    cmp%I4clr,*%B2 %4,%3,%0\;ldil L'%1,%0
1453    cmp%I4clr,*%B2 %4,%3,%0\;depdi,z %z1,%0"
1454   [(set_attr "type" "multi,multi,multi,multi,nullshift")
1455    (set_attr "length" "8,8,8,8,8")])
1456
1457 (define_insn ""
1458   [(set (match_operand:DI 0 "register_operand" "=r,r,r,r,r,r,r,r")
1459         (if_then_else:DI
1460          (match_operator 5 "comparison_operator"
1461             [(match_operand:DI 3 "register_operand" "r,r,r,r,r,r,r,r")
1462              (match_operand:DI 4 "arith11_operand" "rI,rI,rI,rI,rI,rI,rI,rI")])
1463          (match_operand:DI 1 "reg_or_cint_move_operand" "0,0,0,0,r,J,N,K")
1464          (match_operand:DI 2 "reg_or_cint_move_operand" "r,J,N,K,0,0,0,0")))]
1465   "TARGET_64BIT"
1466   "@
1467    cmp%I4clr,*%S5 %4,%3,%%r0\;copy %2,%0
1468    cmp%I4clr,*%S5 %4,%3,%%r0\;ldi %2,%0
1469    cmp%I4clr,*%S5 %4,%3,%%r0\;ldil L'%2,%0
1470    cmp%I4clr,*%S5 %4,%3,%%r0\;depdi,z %z2,%0
1471    cmp%I4clr,*%B5 %4,%3,%%r0\;copy %1,%0
1472    cmp%I4clr,*%B5 %4,%3,%%r0\;ldi %1,%0
1473    cmp%I4clr,*%B5 %4,%3,%%r0\;ldil L'%1,%0
1474    cmp%I4clr,*%B5 %4,%3,%%r0\;depdi,z %z1,%0"
1475   [(set_attr "type" "multi,multi,multi,nullshift,multi,multi,multi,nullshift")
1476    (set_attr "length" "8,8,8,8,8,8,8,8")])
1477
1478 ;; Conditional Branches
1479
1480 (define_expand "beq"
1481   [(set (pc)
1482         (if_then_else (eq (match_dup 1) (match_dup 2))
1483                       (label_ref (match_operand 0 "" ""))
1484                       (pc)))]
1485   ""
1486   "
1487 {
1488   if (hppa_branch_type != CMP_SI)
1489     {
1490       emit_insn (gen_cmp_fp (EQ, hppa_compare_op0, hppa_compare_op1));
1491       emit_bcond_fp (NE, operands[0]);
1492       DONE;
1493     }
1494   /* set up operands from compare.  */
1495   operands[1] = hppa_compare_op0;
1496   operands[2] = hppa_compare_op1;
1497   /* fall through and generate default code */
1498 }")
1499
1500 (define_expand "bne"
1501   [(set (pc)
1502         (if_then_else (ne (match_dup 1) (match_dup 2))
1503                       (label_ref (match_operand 0 "" ""))
1504                       (pc)))]
1505   ""
1506   "
1507 {
1508   if (hppa_branch_type != CMP_SI)
1509     {
1510       emit_insn (gen_cmp_fp (NE, hppa_compare_op0, hppa_compare_op1));
1511       emit_bcond_fp (NE, operands[0]);
1512       DONE;
1513     }
1514   operands[1] = hppa_compare_op0;
1515   operands[2] = hppa_compare_op1;
1516 }")
1517
1518 (define_expand "bgt"
1519   [(set (pc)
1520         (if_then_else (gt (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     {
1528       emit_insn (gen_cmp_fp (GT, hppa_compare_op0, hppa_compare_op1));
1529       emit_bcond_fp (NE, operands[0]);
1530       DONE;
1531     }
1532   operands[1] = hppa_compare_op0;
1533   operands[2] = hppa_compare_op1;
1534 }")
1535
1536 (define_expand "blt"
1537   [(set (pc)
1538         (if_then_else (lt (match_dup 1) (match_dup 2))
1539                       (label_ref (match_operand 0 "" ""))
1540                       (pc)))]
1541   ""
1542   "
1543 {
1544   if (hppa_branch_type != CMP_SI)
1545     {
1546       emit_insn (gen_cmp_fp (LT, hppa_compare_op0, hppa_compare_op1));
1547       emit_bcond_fp (NE, operands[0]);
1548       DONE;
1549     }
1550   operands[1] = hppa_compare_op0;
1551   operands[2] = hppa_compare_op1;
1552 }")
1553
1554 (define_expand "bge"
1555   [(set (pc)
1556         (if_then_else (ge (match_dup 1) (match_dup 2))
1557                       (label_ref (match_operand 0 "" ""))
1558                       (pc)))]
1559   ""
1560   "
1561 {
1562   if (hppa_branch_type != CMP_SI)
1563     {
1564       emit_insn (gen_cmp_fp (GE, hppa_compare_op0, hppa_compare_op1));
1565       emit_bcond_fp (NE, operands[0]);
1566       DONE;
1567     }
1568   operands[1] = hppa_compare_op0;
1569   operands[2] = hppa_compare_op1;
1570 }")
1571
1572 (define_expand "ble"
1573   [(set (pc)
1574         (if_then_else (le (match_dup 1) (match_dup 2))
1575                       (label_ref (match_operand 0 "" ""))
1576                       (pc)))]
1577   ""
1578   "
1579 {
1580   if (hppa_branch_type != CMP_SI)
1581     {
1582       emit_insn (gen_cmp_fp (LE, hppa_compare_op0, hppa_compare_op1));
1583       emit_bcond_fp (NE, operands[0]);
1584       DONE;
1585     }
1586   operands[1] = hppa_compare_op0;
1587   operands[2] = hppa_compare_op1;
1588 }")
1589
1590 (define_expand "bgtu"
1591   [(set (pc)
1592         (if_then_else (gtu (match_dup 1) (match_dup 2))
1593                       (label_ref (match_operand 0 "" ""))
1594                       (pc)))]
1595   ""
1596   "
1597 {
1598   if (hppa_branch_type != CMP_SI)
1599     FAIL;
1600   operands[1] = hppa_compare_op0;
1601   operands[2] = hppa_compare_op1;
1602 }")
1603
1604 (define_expand "bltu"
1605   [(set (pc)
1606         (if_then_else (ltu (match_dup 1) (match_dup 2))
1607                       (label_ref (match_operand 0 "" ""))
1608                       (pc)))]
1609   ""
1610   "
1611 {
1612   if (hppa_branch_type != CMP_SI)
1613     FAIL;
1614   operands[1] = hppa_compare_op0;
1615   operands[2] = hppa_compare_op1;
1616 }")
1617
1618 (define_expand "bgeu"
1619   [(set (pc)
1620         (if_then_else (geu (match_dup 1) (match_dup 2))
1621                       (label_ref (match_operand 0 "" ""))
1622                       (pc)))]
1623   ""
1624   "
1625 {
1626   if (hppa_branch_type != CMP_SI)
1627     FAIL;
1628   operands[1] = hppa_compare_op0;
1629   operands[2] = hppa_compare_op1;
1630 }")
1631
1632 (define_expand "bleu"
1633   [(set (pc)
1634         (if_then_else (leu (match_dup 1) (match_dup 2))
1635                       (label_ref (match_operand 0 "" ""))
1636                       (pc)))]
1637   ""
1638   "
1639 {
1640   if (hppa_branch_type != CMP_SI)
1641     FAIL;
1642   operands[1] = hppa_compare_op0;
1643   operands[2] = hppa_compare_op1;
1644 }")
1645
1646 (define_expand "bltgt"
1647   [(set (pc)
1648         (if_then_else (ltgt (match_dup 1) (match_dup 2))
1649                       (label_ref (match_operand 0 "" ""))
1650                       (pc)))]
1651   ""
1652   "
1653 {
1654   if (hppa_branch_type == CMP_SI)
1655     FAIL;
1656   emit_insn (gen_cmp_fp (LTGT, hppa_compare_op0, hppa_compare_op1));
1657   emit_bcond_fp (NE, operands[0]);
1658   DONE;
1659 }")
1660
1661 (define_expand "bunle"
1662   [(set (pc)
1663         (if_then_else (unle (match_dup 1) (match_dup 2))
1664                       (label_ref (match_operand 0 "" ""))
1665                       (pc)))]
1666   ""
1667   "
1668 {
1669   if (hppa_branch_type == CMP_SI)
1670     FAIL;
1671   emit_insn (gen_cmp_fp (UNLE, hppa_compare_op0, hppa_compare_op1));
1672   emit_bcond_fp (NE, operands[0]);
1673   DONE;
1674 }")
1675
1676 (define_expand "bunlt"
1677   [(set (pc)
1678         (if_then_else (unlt (match_dup 1) (match_dup 2))
1679                       (label_ref (match_operand 0 "" ""))
1680                       (pc)))]
1681   ""
1682   "
1683 {
1684   if (hppa_branch_type == CMP_SI)
1685     FAIL;
1686   emit_insn (gen_cmp_fp (UNLT, hppa_compare_op0, hppa_compare_op1));
1687   emit_bcond_fp (NE, operands[0]);
1688   DONE;
1689 }")
1690
1691 (define_expand "bunge"
1692   [(set (pc)
1693         (if_then_else (unge (match_dup 1) (match_dup 2))
1694                       (label_ref (match_operand 0 "" ""))
1695                       (pc)))]
1696   ""
1697   "
1698 {
1699   if (hppa_branch_type == CMP_SI)
1700     FAIL;
1701   emit_insn (gen_cmp_fp (UNGE, hppa_compare_op0, hppa_compare_op1));
1702   emit_bcond_fp (NE, operands[0]);
1703   DONE;
1704 }")
1705
1706 (define_expand "bungt"
1707   [(set (pc)
1708         (if_then_else (ungt (match_dup 1) (match_dup 2))
1709                       (label_ref (match_operand 0 "" ""))
1710                       (pc)))]
1711   ""
1712   "
1713 {
1714   if (hppa_branch_type == CMP_SI)
1715     FAIL;
1716   emit_insn (gen_cmp_fp (UNGT, hppa_compare_op0, hppa_compare_op1));
1717   emit_bcond_fp (NE, operands[0]);
1718   DONE;
1719 }")
1720
1721 (define_expand "buneq"
1722   [(set (pc)
1723         (if_then_else (uneq (match_dup 1) (match_dup 2))
1724                       (label_ref (match_operand 0 "" ""))
1725                       (pc)))]
1726   ""
1727   "
1728 {
1729   if (hppa_branch_type == CMP_SI)
1730     FAIL;
1731   emit_insn (gen_cmp_fp (UNEQ, hppa_compare_op0, hppa_compare_op1));
1732   emit_bcond_fp (NE, operands[0]);
1733   DONE;
1734 }")
1735
1736 (define_expand "bunordered"
1737   [(set (pc)
1738         (if_then_else (unordered (match_dup 1) (match_dup 2))
1739                       (label_ref (match_operand 0 "" ""))
1740                       (pc)))]
1741   ""
1742   "
1743 {
1744   if (hppa_branch_type == CMP_SI)
1745     FAIL;
1746   emit_insn (gen_cmp_fp (UNORDERED, hppa_compare_op0, hppa_compare_op1));
1747   emit_bcond_fp (NE, operands[0]);
1748   DONE;
1749 }")
1750
1751 (define_expand "bordered"
1752   [(set (pc)
1753         (if_then_else (ordered (match_dup 1) (match_dup 2))
1754                       (label_ref (match_operand 0 "" ""))
1755                       (pc)))]
1756   ""
1757   "
1758 {
1759   if (hppa_branch_type == CMP_SI)
1760     FAIL;
1761   emit_insn (gen_cmp_fp (ORDERED, hppa_compare_op0, hppa_compare_op1));
1762   emit_bcond_fp (NE, operands[0]);
1763   DONE;
1764 }")
1765
1766 ;; Match the branch patterns.
1767
1768
1769 ;; Note a long backward conditional branch with an annulled delay slot
1770 ;; has a length of 12.
1771 (define_insn ""
1772   [(set (pc)
1773         (if_then_else
1774          (match_operator 3 "comparison_operator"
1775                          [(match_operand:SI 1 "reg_or_0_operand" "rM")
1776                           (match_operand:SI 2 "arith5_operand" "rL")])
1777          (label_ref (match_operand 0 "" ""))
1778          (pc)))]
1779   ""
1780   "*
1781 {
1782   return output_cbranch (operands, 0, insn);
1783 }"
1784 [(set_attr "type" "cbranch")
1785  (set (attr "length")
1786     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1787                (const_int MAX_12BIT_OFFSET))
1788            (const_int 4)
1789            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1790                (const_int MAX_17BIT_OFFSET))
1791            (const_int 8)
1792            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
1793            (const_int 24)
1794            (eq (symbol_ref "flag_pic") (const_int 0))
1795            (const_int 20)]
1796           (const_int 28)))])
1797
1798 ;; Match the negated branch.
1799
1800 (define_insn ""
1801   [(set (pc)
1802         (if_then_else
1803          (match_operator 3 "comparison_operator"
1804                          [(match_operand:SI 1 "reg_or_0_operand" "rM")
1805                           (match_operand:SI 2 "arith5_operand" "rL")])
1806          (pc)
1807          (label_ref (match_operand 0 "" ""))))]
1808   ""
1809   "*
1810 {
1811   return output_cbranch (operands, 1, insn);
1812 }"
1813 [(set_attr "type" "cbranch")
1814  (set (attr "length")
1815     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1816                (const_int MAX_12BIT_OFFSET))
1817            (const_int 4)
1818            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1819                (const_int MAX_17BIT_OFFSET))
1820            (const_int 8)
1821            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
1822            (const_int 24)
1823            (eq (symbol_ref "flag_pic") (const_int 0))
1824            (const_int 20)]
1825           (const_int 28)))])
1826
1827 (define_insn ""
1828   [(set (pc)
1829         (if_then_else
1830          (match_operator 3 "comparison_operator"
1831                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1832                           (match_operand:DI 2 "reg_or_0_operand" "rM")])
1833          (label_ref (match_operand 0 "" ""))
1834          (pc)))]
1835   "TARGET_64BIT"
1836   "*
1837 {
1838   return output_cbranch (operands, 0, insn);
1839 }"
1840 [(set_attr "type" "cbranch")
1841  (set (attr "length")
1842     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1843                (const_int MAX_12BIT_OFFSET))
1844            (const_int 4)
1845            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1846                (const_int MAX_17BIT_OFFSET))
1847            (const_int 8)
1848            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
1849            (const_int 24)
1850            (eq (symbol_ref "flag_pic") (const_int 0))
1851            (const_int 20)]
1852           (const_int 28)))])
1853
1854 ;; Match the negated branch.
1855
1856 (define_insn ""
1857   [(set (pc)
1858         (if_then_else
1859          (match_operator 3 "comparison_operator"
1860                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1861                           (match_operand:DI 2 "reg_or_0_operand" "rM")])
1862          (pc)
1863          (label_ref (match_operand 0 "" ""))))]
1864   "TARGET_64BIT"
1865   "*
1866 {
1867   return output_cbranch (operands, 1, insn);
1868 }"
1869 [(set_attr "type" "cbranch")
1870  (set (attr "length")
1871     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1872                (const_int MAX_12BIT_OFFSET))
1873            (const_int 4)
1874            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1875                (const_int MAX_17BIT_OFFSET))
1876            (const_int 8)
1877            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
1878            (const_int 24)
1879            (eq (symbol_ref "flag_pic") (const_int 0))
1880            (const_int 20)]
1881           (const_int 28)))])
1882 (define_insn ""
1883   [(set (pc)
1884         (if_then_else
1885          (match_operator 3 "cmpib_comparison_operator"
1886                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1887                           (match_operand:DI 2 "arith5_operand" "rL")])
1888          (label_ref (match_operand 0 "" ""))
1889          (pc)))]
1890   "TARGET_64BIT"
1891   "*
1892 {
1893   return output_cbranch (operands, 0, insn);
1894 }"
1895 [(set_attr "type" "cbranch")
1896  (set (attr "length")
1897     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1898                (const_int MAX_12BIT_OFFSET))
1899            (const_int 4)
1900            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1901                (const_int MAX_17BIT_OFFSET))
1902            (const_int 8)
1903            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
1904            (const_int 24)
1905            (eq (symbol_ref "flag_pic") (const_int 0))
1906            (const_int 20)]
1907           (const_int 28)))])
1908
1909 ;; Match the negated branch.
1910
1911 (define_insn ""
1912   [(set (pc)
1913         (if_then_else
1914          (match_operator 3 "cmpib_comparison_operator"
1915                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1916                           (match_operand:DI 2 "arith5_operand" "rL")])
1917          (pc)
1918          (label_ref (match_operand 0 "" ""))))]
1919   "TARGET_64BIT"
1920   "*
1921 {
1922   return output_cbranch (operands, 1, insn);
1923 }"
1924 [(set_attr "type" "cbranch")
1925  (set (attr "length")
1926     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1927                (const_int MAX_12BIT_OFFSET))
1928            (const_int 4)
1929            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1930                (const_int MAX_17BIT_OFFSET))
1931            (const_int 8)
1932            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
1933            (const_int 24)
1934            (eq (symbol_ref "flag_pic") (const_int 0))
1935            (const_int 20)]
1936           (const_int 28)))])
1937
1938 ;; Branch on Bit patterns.
1939 (define_insn ""
1940   [(set (pc)
1941         (if_then_else
1942          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1943                               (const_int 1)
1944                               (match_operand:SI 1 "uint5_operand" ""))
1945              (const_int 0))
1946          (label_ref (match_operand 2 "" ""))
1947          (pc)))]
1948   ""
1949   "*
1950 {
1951   return output_bb (operands, 0, insn, 0);
1952 }"
1953 [(set_attr "type" "cbranch")
1954  (set (attr "length")
1955     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1956                (const_int MAX_12BIT_OFFSET))
1957            (const_int 4)
1958            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1959                (const_int MAX_17BIT_OFFSET))
1960            (const_int 8)
1961            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
1962            (const_int 24)
1963            (eq (symbol_ref "flag_pic") (const_int 0))
1964            (const_int 20)]
1965           (const_int 28)))])
1966
1967 (define_insn ""
1968   [(set (pc)
1969         (if_then_else
1970          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1971                               (const_int 1)
1972                               (match_operand:DI 1 "uint32_operand" ""))
1973              (const_int 0))
1974          (label_ref (match_operand 2 "" ""))
1975          (pc)))]
1976   "TARGET_64BIT"
1977   "*
1978 {
1979   return output_bb (operands, 0, insn, 0);
1980 }"
1981 [(set_attr "type" "cbranch")
1982  (set (attr "length")
1983     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1984                (const_int MAX_12BIT_OFFSET))
1985            (const_int 4)
1986            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1987                (const_int MAX_17BIT_OFFSET))
1988            (const_int 8)
1989            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
1990            (const_int 24)
1991            (eq (symbol_ref "flag_pic") (const_int 0))
1992            (const_int 20)]
1993           (const_int 28)))])
1994
1995 (define_insn ""
1996   [(set (pc)
1997         (if_then_else
1998          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1999                               (const_int 1)
2000                               (match_operand:SI 1 "uint5_operand" ""))
2001              (const_int 0))
2002          (pc)
2003          (label_ref (match_operand 2 "" ""))))]
2004   ""
2005   "*
2006 {
2007   return output_bb (operands, 1, insn, 0);
2008 }"
2009 [(set_attr "type" "cbranch")
2010  (set (attr "length")
2011     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2012                (const_int MAX_12BIT_OFFSET))
2013            (const_int 4)
2014            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2015                (const_int MAX_17BIT_OFFSET))
2016            (const_int 8)
2017            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
2018            (const_int 24)
2019            (eq (symbol_ref "flag_pic") (const_int 0))
2020            (const_int 20)]
2021           (const_int 28)))])
2022
2023 (define_insn ""
2024   [(set (pc)
2025         (if_then_else
2026          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2027                               (const_int 1)
2028                               (match_operand:DI 1 "uint32_operand" ""))
2029              (const_int 0))
2030          (pc)
2031          (label_ref (match_operand 2 "" ""))))]
2032   "TARGET_64BIT"
2033   "*
2034 {
2035   return output_bb (operands, 1, insn, 0);
2036 }"
2037 [(set_attr "type" "cbranch")
2038  (set (attr "length")
2039     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2040                (const_int MAX_12BIT_OFFSET))
2041            (const_int 4)
2042            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2043                (const_int MAX_17BIT_OFFSET))
2044            (const_int 8)
2045            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
2046            (const_int 24)
2047            (eq (symbol_ref "flag_pic") (const_int 0))
2048            (const_int 20)]
2049           (const_int 28)))])
2050
2051 (define_insn ""
2052   [(set (pc)
2053         (if_then_else
2054          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
2055                               (const_int 1)
2056                               (match_operand:SI 1 "uint5_operand" ""))
2057              (const_int 0))
2058          (label_ref (match_operand 2 "" ""))
2059          (pc)))]
2060   ""
2061   "*
2062 {
2063   return output_bb (operands, 0, insn, 1);
2064 }"
2065 [(set_attr "type" "cbranch")
2066  (set (attr "length")
2067     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2068                (const_int MAX_12BIT_OFFSET))
2069            (const_int 4)
2070            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2071                (const_int MAX_17BIT_OFFSET))
2072            (const_int 8)
2073            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
2074            (const_int 24)
2075            (eq (symbol_ref "flag_pic") (const_int 0))
2076            (const_int 20)]
2077           (const_int 28)))])
2078
2079 (define_insn ""
2080   [(set (pc)
2081         (if_then_else
2082          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2083                               (const_int 1)
2084                               (match_operand:DI 1 "uint32_operand" ""))
2085              (const_int 0))
2086          (label_ref (match_operand 2 "" ""))
2087          (pc)))]
2088   "TARGET_64BIT"
2089   "*
2090 {
2091   return output_bb (operands, 0, insn, 1);
2092 }"
2093 [(set_attr "type" "cbranch")
2094  (set (attr "length")
2095     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2096                (const_int MAX_12BIT_OFFSET))
2097            (const_int 4)
2098            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2099                (const_int MAX_17BIT_OFFSET))
2100            (const_int 8)
2101            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
2102            (const_int 24)
2103            (eq (symbol_ref "flag_pic") (const_int 0))
2104            (const_int 20)]
2105           (const_int 28)))])
2106
2107 (define_insn ""
2108   [(set (pc)
2109         (if_then_else
2110          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
2111                               (const_int 1)
2112                               (match_operand:SI 1 "uint5_operand" ""))
2113              (const_int 0))
2114          (pc)
2115          (label_ref (match_operand 2 "" ""))))]
2116   ""
2117   "*
2118 {
2119   return output_bb (operands, 1, insn, 1);
2120 }"
2121 [(set_attr "type" "cbranch")
2122  (set (attr "length")
2123     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2124                (const_int MAX_12BIT_OFFSET))
2125            (const_int 4)
2126            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2127                (const_int MAX_17BIT_OFFSET))
2128            (const_int 8)
2129            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
2130            (const_int 24)
2131            (eq (symbol_ref "flag_pic") (const_int 0))
2132            (const_int 20)]
2133           (const_int 28)))])
2134
2135 (define_insn ""
2136   [(set (pc)
2137         (if_then_else
2138          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2139                               (const_int 1)
2140                               (match_operand:DI 1 "uint32_operand" ""))
2141              (const_int 0))
2142          (pc)
2143          (label_ref (match_operand 2 "" ""))))]
2144   "TARGET_64BIT"
2145   "*
2146 {
2147   return output_bb (operands, 1, insn, 1);
2148 }"
2149 [(set_attr "type" "cbranch")
2150  (set (attr "length")
2151     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2152                (const_int MAX_12BIT_OFFSET))
2153            (const_int 4)
2154            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2155                (const_int MAX_17BIT_OFFSET))
2156            (const_int 8)
2157            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
2158            (const_int 24)
2159            (eq (symbol_ref "flag_pic") (const_int 0))
2160            (const_int 20)]
2161           (const_int 28)))])
2162
2163 ;; Branch on Variable Bit patterns.
2164 (define_insn ""
2165   [(set (pc)
2166         (if_then_else
2167          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
2168                               (const_int 1)
2169                               (match_operand:SI 1 "register_operand" "q"))
2170              (const_int 0))
2171          (label_ref (match_operand 2 "" ""))
2172          (pc)))]
2173   ""
2174   "*
2175 {
2176   return output_bvb (operands, 0, insn, 0);
2177 }"
2178 [(set_attr "type" "cbranch")
2179  (set (attr "length")
2180     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2181                (const_int MAX_12BIT_OFFSET))
2182            (const_int 4)
2183            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2184                (const_int MAX_17BIT_OFFSET))
2185            (const_int 8)
2186            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
2187            (const_int 24)
2188            (eq (symbol_ref "flag_pic") (const_int 0))
2189            (const_int 20)]
2190           (const_int 28)))])
2191
2192 (define_insn ""
2193   [(set (pc)
2194         (if_then_else
2195          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2196                               (const_int 1)
2197                               (match_operand:DI 1 "register_operand" "q"))
2198              (const_int 0))
2199          (label_ref (match_operand 2 "" ""))
2200          (pc)))]
2201   "TARGET_64BIT"
2202   "*
2203 {
2204   return output_bvb (operands, 0, insn, 0);
2205 }"
2206 [(set_attr "type" "cbranch")
2207  (set (attr "length")
2208     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2209                (const_int MAX_12BIT_OFFSET))
2210            (const_int 4)
2211            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2212                (const_int MAX_17BIT_OFFSET))
2213            (const_int 8)
2214            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
2215            (const_int 24)
2216            (eq (symbol_ref "flag_pic") (const_int 0))
2217            (const_int 20)]
2218           (const_int 28)))])
2219
2220 (define_insn ""
2221   [(set (pc)
2222         (if_then_else
2223          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
2224                               (const_int 1)
2225                               (match_operand:SI 1 "register_operand" "q"))
2226              (const_int 0))
2227          (pc)
2228          (label_ref (match_operand 2 "" ""))))]
2229   ""
2230   "*
2231 {
2232   return output_bvb (operands, 1, insn, 0);
2233 }"
2234 [(set_attr "type" "cbranch")
2235  (set (attr "length")
2236     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2237                (const_int MAX_12BIT_OFFSET))
2238            (const_int 4)
2239            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2240                (const_int MAX_17BIT_OFFSET))
2241            (const_int 8)
2242            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
2243            (const_int 24)
2244            (eq (symbol_ref "flag_pic") (const_int 0))
2245            (const_int 20)]
2246           (const_int 28)))])
2247
2248 (define_insn ""
2249   [(set (pc)
2250         (if_then_else
2251          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2252                               (const_int 1)
2253                               (match_operand:DI 1 "register_operand" "q"))
2254              (const_int 0))
2255          (pc)
2256          (label_ref (match_operand 2 "" ""))))]
2257   "TARGET_64BIT"
2258   "*
2259 {
2260   return output_bvb (operands, 1, insn, 0);
2261 }"
2262 [(set_attr "type" "cbranch")
2263  (set (attr "length")
2264     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2265                (const_int MAX_12BIT_OFFSET))
2266            (const_int 4)
2267            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2268                (const_int MAX_17BIT_OFFSET))
2269            (const_int 8)
2270            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
2271            (const_int 24)
2272            (eq (symbol_ref "flag_pic") (const_int 0))
2273            (const_int 20)]
2274           (const_int 28)))])
2275
2276 (define_insn ""
2277   [(set (pc)
2278         (if_then_else
2279          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
2280                               (const_int 1)
2281                               (match_operand:SI 1 "register_operand" "q"))
2282              (const_int 0))
2283          (label_ref (match_operand 2 "" ""))
2284          (pc)))]
2285   ""
2286   "*
2287 {
2288   return output_bvb (operands, 0, insn, 1);
2289 }"
2290 [(set_attr "type" "cbranch")
2291  (set (attr "length")
2292     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2293                (const_int MAX_12BIT_OFFSET))
2294            (const_int 4)
2295            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2296                (const_int MAX_17BIT_OFFSET))
2297            (const_int 8)
2298            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
2299            (const_int 24)
2300            (eq (symbol_ref "flag_pic") (const_int 0))
2301            (const_int 20)]
2302           (const_int 28)))])
2303
2304 (define_insn ""
2305   [(set (pc)
2306         (if_then_else
2307          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2308                               (const_int 1)
2309                               (match_operand:DI 1 "register_operand" "q"))
2310              (const_int 0))
2311          (label_ref (match_operand 2 "" ""))
2312          (pc)))]
2313   "TARGET_64BIT"
2314   "*
2315 {
2316   return output_bvb (operands, 0, insn, 1);
2317 }"
2318 [(set_attr "type" "cbranch")
2319  (set (attr "length")
2320     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2321                (const_int MAX_12BIT_OFFSET))
2322            (const_int 4)
2323            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2324                (const_int MAX_17BIT_OFFSET))
2325            (const_int 8)
2326            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
2327            (const_int 24)
2328            (eq (symbol_ref "flag_pic") (const_int 0))
2329            (const_int 20)]
2330           (const_int 28)))])
2331
2332 (define_insn ""
2333   [(set (pc)
2334         (if_then_else
2335          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
2336                               (const_int 1)
2337                               (match_operand:SI 1 "register_operand" "q"))
2338              (const_int 0))
2339          (pc)
2340          (label_ref (match_operand 2 "" ""))))]
2341   ""
2342   "*
2343 {
2344   return output_bvb (operands, 1, insn, 1);
2345 }"
2346 [(set_attr "type" "cbranch")
2347  (set (attr "length")
2348     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2349                (const_int MAX_12BIT_OFFSET))
2350            (const_int 4)
2351            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2352                (const_int MAX_17BIT_OFFSET))
2353            (const_int 8)
2354            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
2355            (const_int 24)
2356            (eq (symbol_ref "flag_pic") (const_int 0))
2357            (const_int 20)]
2358           (const_int 28)))])
2359
2360 (define_insn ""
2361   [(set (pc)
2362         (if_then_else
2363          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2364                               (const_int 1)
2365                               (match_operand:DI 1 "register_operand" "q"))
2366              (const_int 0))
2367          (pc)
2368          (label_ref (match_operand 2 "" ""))))]
2369   "TARGET_64BIT"
2370   "*
2371 {
2372   return output_bvb (operands, 1, insn, 1);
2373 }"
2374 [(set_attr "type" "cbranch")
2375  (set (attr "length")
2376     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2377                (const_int MAX_12BIT_OFFSET))
2378            (const_int 4)
2379            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2380                (const_int MAX_17BIT_OFFSET))
2381            (const_int 8)
2382            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
2383            (const_int 24)
2384            (eq (symbol_ref "flag_pic") (const_int 0))
2385            (const_int 20)]
2386           (const_int 28)))])
2387
2388 ;; Floating point branches
2389
2390 ;; ??? Nullification is handled differently from other branches.
2391 ;; If nullification is specified, the delay slot is nullified on any
2392 ;; taken branch regardless of branch direction.
2393 (define_insn ""
2394   [(set (pc) (if_then_else (ne (reg:CCFP 0) (const_int 0))
2395                            (label_ref (match_operand 0 "" ""))
2396                            (pc)))]
2397   "!TARGET_SOFT_FLOAT"
2398   "*
2399 {
2400   int length = get_attr_length (insn);
2401   rtx xoperands[1];
2402   int nullify, xdelay;
2403
2404   if (length < 16)
2405     return \"ftest\;b%* %l0\";
2406
2407   if (dbr_sequence_length () == 0 || INSN_ANNULLED_BRANCH_P (insn))
2408     {
2409       nullify = 1;
2410       xdelay = 0;
2411       xoperands[0] = GEN_INT (length - 8);
2412     }
2413   else
2414     {
2415       nullify = 0;
2416       xdelay = 1;
2417       xoperands[0] = GEN_INT (length - 4);
2418     }
2419
2420   if (nullify)
2421     output_asm_insn (\"ftest\;add,tr %%r0,%%r0,%%r0\;b,n .+%0\", xoperands);
2422   else
2423     output_asm_insn (\"ftest\;add,tr %%r0,%%r0,%%r0\;b .+%0\", xoperands);
2424   return output_lbranch (operands[0], insn, xdelay);
2425 }"
2426 [(set_attr "type" "fbranch")
2427  (set (attr "length")
2428     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
2429                (const_int MAX_17BIT_OFFSET))
2430            (const_int 8)
2431            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
2432            (const_int 32)
2433            (eq (symbol_ref "flag_pic") (const_int 0))
2434            (const_int 28)]
2435           (const_int 36)))])
2436
2437 (define_insn ""
2438   [(set (pc) (if_then_else (ne (reg:CCFP 0) (const_int 0))
2439                            (pc)
2440                            (label_ref (match_operand 0 "" ""))))]
2441   "!TARGET_SOFT_FLOAT"
2442   "*
2443 {
2444   int length = get_attr_length (insn);
2445   rtx xoperands[1];
2446   int nullify, xdelay;
2447
2448   if (length < 16)
2449     return \"ftest\;add,tr %%r0,%%r0,%%r0\;b%* %0\";
2450
2451   if (dbr_sequence_length () == 0 || INSN_ANNULLED_BRANCH_P (insn))
2452     {
2453       nullify = 1;
2454       xdelay = 0;
2455       xoperands[0] = GEN_INT (length - 4);
2456     }
2457   else
2458     {
2459       nullify = 0;
2460       xdelay = 1;
2461       xoperands[0] = GEN_INT (length);
2462     }
2463
2464   if (nullify)
2465     output_asm_insn (\"ftest\;b,n .+%0\", xoperands);
2466   else
2467     output_asm_insn (\"ftest\;b .+%0\", xoperands);
2468   return output_lbranch (operands[0], insn, xdelay);
2469 }"
2470 [(set_attr "type" "fbranch")
2471  (set (attr "length")
2472     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
2473                (const_int MAX_17BIT_OFFSET))
2474            (const_int 12)
2475            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
2476            (const_int 28)
2477            (eq (symbol_ref "flag_pic") (const_int 0))
2478            (const_int 24)]
2479           (const_int 32)))])
2480
2481 ;; Move instructions
2482
2483 (define_expand "movsi"
2484   [(set (match_operand:SI 0 "general_operand" "")
2485         (match_operand:SI 1 "general_operand" ""))]
2486   ""
2487   "
2488 {
2489   if (emit_move_sequence (operands, SImode, 0))
2490     DONE;
2491 }")
2492
2493 ;; Handle SImode input reloads requiring %r1 as a scratch register.
2494 (define_expand "reload_insi_r1"
2495   [(set (match_operand:SI 0 "register_operand" "=Z")
2496         (match_operand:SI 1 "non_hard_reg_operand" ""))
2497    (clobber (match_operand:SI 2 "register_operand" "=&a"))]
2498   ""
2499   "
2500 {
2501   if (emit_move_sequence (operands, SImode, operands[2]))
2502     DONE;
2503
2504   /* We don't want the clobber emitted, so handle this ourselves.  */
2505   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
2506   DONE;
2507 }")
2508
2509 ;; Handle SImode input reloads requiring a general register as a
2510 ;; scratch register.
2511 (define_expand "reload_insi"
2512   [(set (match_operand:SI 0 "register_operand" "=Z")
2513         (match_operand:SI 1 "non_hard_reg_operand" ""))
2514    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
2515   ""
2516   "
2517 {
2518   if (emit_move_sequence (operands, SImode, operands[2]))
2519     DONE;
2520
2521   /* We don't want the clobber emitted, so handle this ourselves.  */
2522   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
2523   DONE;
2524 }")
2525
2526 ;; Handle SImode output reloads requiring a general register as a
2527 ;; scratch register.
2528 (define_expand "reload_outsi"
2529   [(set (match_operand:SI 0 "non_hard_reg_operand" "")
2530         (match_operand:SI 1  "register_operand" "Z"))
2531    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
2532   ""
2533   "
2534 {
2535   if (emit_move_sequence (operands, SImode, operands[2]))
2536     DONE;
2537
2538   /* We don't want the clobber emitted, so handle this ourselves.  */
2539   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
2540   DONE;
2541 }")
2542
2543 (define_insn ""
2544   [(set (match_operand:SI 0 "move_dest_operand"
2545                           "=r,r,r,r,r,r,Q,!*q,!r,!*f,*f,T,?r,?*f")
2546         (match_operand:SI 1 "move_src_operand"
2547                           "A,r,J,N,K,RQ,rM,!rM,!*q,!*fM,RT,*f,*f,r"))]
2548   "(register_operand (operands[0], SImode)
2549     || reg_or_0_operand (operands[1], SImode))
2550    && !TARGET_SOFT_FLOAT
2551    && !TARGET_64BIT"
2552   "@
2553    ldw RT'%A1,%0
2554    copy %1,%0
2555    ldi %1,%0
2556    ldil L'%1,%0
2557    {zdepi|depwi,z} %Z1,%0
2558    ldw%M1 %1,%0
2559    stw%M0 %r1,%0
2560    mtsar %r1
2561    {mfctl|mfctl,w} %%sar,%0
2562    fcpy,sgl %f1,%0
2563    fldw%F1 %1,%0
2564    fstw%F0 %1,%0
2565    {fstws|fstw} %1,-16(%%sp)\n\t{ldws|ldw} -16(%%sp),%0
2566    {stws|stw} %1,-16(%%sp)\n\t{fldws|fldw} -16(%%sp),%0"
2567   [(set_attr "type" "load,move,move,move,shift,load,store,move,move,fpalu,fpload,fpstore,fpstore_load,store_fpload")
2568    (set_attr "pa_combine_type" "addmove")
2569    (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4,8,8")])
2570
2571 (define_insn ""
2572   [(set (match_operand:SI 0 "move_dest_operand"
2573                           "=r,r,r,r,r,r,Q,!*q,!r,!*f,*f,T")
2574         (match_operand:SI 1 "move_src_operand"
2575                           "A,r,J,N,K,RQ,rM,!rM,!*q,!*fM,RT,*f"))]
2576   "(register_operand (operands[0], SImode)
2577     || reg_or_0_operand (operands[1], SImode))
2578    && !TARGET_SOFT_FLOAT
2579    && TARGET_64BIT"
2580   "@
2581    ldw RT'%A1,%0
2582    copy %1,%0
2583    ldi %1,%0
2584    ldil L'%1,%0
2585    {zdepi|depwi,z} %Z1,%0
2586    ldw%M1 %1,%0
2587    stw%M0 %r1,%0
2588    mtsar %r1
2589    {mfctl|mfctl,w} %%sar,%0
2590    fcpy,sgl %f1,%0
2591    fldw%F1 %1,%0
2592    fstw%F0 %1,%0"
2593   [(set_attr "type" "load,move,move,move,shift,load,store,move,move,fpalu,fpload,fpstore")
2594    (set_attr "pa_combine_type" "addmove")
2595    (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4")])
2596
2597 (define_insn ""
2598   [(set (match_operand:SI 0 "indexed_memory_operand" "=R")
2599         (match_operand:SI 1 "register_operand" "f"))]
2600   "!TARGET_SOFT_FLOAT
2601    && !TARGET_DISABLE_INDEXING
2602    && reload_completed"
2603   "fstw%F0 %1,%0"
2604   [(set_attr "type" "fpstore")
2605    (set_attr "pa_combine_type" "addmove")
2606    (set_attr "length" "4")])
2607
2608 ; Rewrite RTL using an indexed store.  This will allow the insn that
2609 ; computes the address to be deleted if the register it sets is dead.
2610 (define_peephole2
2611   [(set (match_operand:SI 0 "register_operand" "")
2612         (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "")
2613                           (const_int 4))
2614                  (match_operand:SI 2 "register_operand" "")))
2615    (set (mem:SI (match_dup 0))
2616         (match_operand:SI 3 "register_operand" ""))]
2617   "!TARGET_SOFT_FLOAT
2618    && !TARGET_DISABLE_INDEXING
2619    && REG_OK_FOR_BASE_P (operands[2])
2620    && FP_REGNO_P (REGNO (operands[3]))"
2621   [(set (mem:SI (plus:SI (mult:SI (match_dup 1) (const_int 4)) (match_dup 2)))
2622         (match_dup 3))
2623    (set (match_dup 0) (plus:SI (mult:SI (match_dup 1) (const_int 4))
2624                                (match_dup 2)))]
2625   "")
2626
2627 (define_peephole2
2628   [(set (match_operand:SI 0 "register_operand" "")
2629         (plus:SI (match_operand:SI 2 "register_operand" "")
2630                  (mult:SI (match_operand:SI 1 "register_operand" "")
2631                           (const_int 4))))
2632    (set (mem:SI (match_dup 0))
2633         (match_operand:SI 3 "register_operand" ""))]
2634   "!TARGET_SOFT_FLOAT
2635    && !TARGET_DISABLE_INDEXING
2636    && REG_OK_FOR_BASE_P (operands[2])
2637    && FP_REGNO_P (REGNO (operands[3]))"
2638   [(set (mem:SI (plus:SI (mult:SI (match_dup 1) (const_int 4)) (match_dup 2)))
2639         (match_dup 3))
2640    (set (match_dup 0) (plus:SI (mult:SI (match_dup 1) (const_int 4))
2641                                (match_dup 2)))]
2642   "")
2643
2644 (define_peephole2
2645   [(set (match_operand:DI 0 "register_operand" "")
2646         (plus:DI (mult:DI (match_operand:DI 1 "register_operand" "")
2647                           (const_int 4))
2648                  (match_operand:DI 2 "register_operand" "")))
2649    (set (mem:SI (match_dup 0))
2650         (match_operand:SI 3 "register_operand" ""))]
2651   "!TARGET_SOFT_FLOAT
2652    && !TARGET_DISABLE_INDEXING
2653    && TARGET_64BIT
2654    && REG_OK_FOR_BASE_P (operands[2])
2655    && FP_REGNO_P (REGNO (operands[3]))"
2656   [(set (mem:SI (plus:DI (mult:DI (match_dup 1) (const_int 4)) (match_dup 2)))
2657         (match_dup 3))
2658    (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 4))
2659                                (match_dup 2)))]
2660   "")
2661
2662 (define_peephole2
2663   [(set (match_operand:DI 0 "register_operand" "")
2664         (plus:DI (match_operand:DI 2 "register_operand" "")
2665                  (mult:DI (match_operand:DI 1 "register_operand" "")
2666                           (const_int 4))))
2667    (set (mem:SI (match_dup 0))
2668         (match_operand:SI 3 "register_operand" ""))]
2669   "!TARGET_SOFT_FLOAT
2670    && !TARGET_DISABLE_INDEXING
2671    && TARGET_64BIT
2672    && REG_OK_FOR_BASE_P (operands[2])
2673    && FP_REGNO_P (REGNO (operands[3]))"
2674   [(set (mem:SI (plus:DI (mult:DI (match_dup 1) (const_int 4)) (match_dup 2)))
2675         (match_dup 3))
2676    (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 4))
2677                                (match_dup 2)))]
2678   "")
2679
2680 (define_peephole2
2681   [(set (match_operand:SI 0 "register_operand" "")
2682         (plus:SI (match_operand:SI 1 "register_operand" "")
2683                  (match_operand:SI 2 "register_operand" "")))
2684    (set (mem:SI (match_dup 0))
2685         (match_operand:SI 3 "register_operand" ""))]
2686   "!TARGET_SOFT_FLOAT
2687    && !TARGET_DISABLE_INDEXING
2688    && TARGET_NO_SPACE_REGS
2689    && REG_OK_FOR_INDEX_P (operands[1])
2690    && REG_OK_FOR_BASE_P (operands[2])
2691    && FP_REGNO_P (REGNO (operands[3]))"
2692   [(set (mem:SI (plus:SI (match_dup 1) (match_dup 2)))
2693         (match_dup 3))
2694    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
2695   "")
2696
2697 (define_peephole2
2698   [(set (match_operand:SI 0 "register_operand" "")
2699         (plus:SI (match_operand:SI 1 "register_operand" "")
2700                  (match_operand:SI 2 "register_operand" "")))
2701    (set (mem:SI (match_dup 0))
2702         (match_operand:SI 3 "register_operand" ""))]
2703   "!TARGET_SOFT_FLOAT
2704    && !TARGET_DISABLE_INDEXING
2705    && TARGET_NO_SPACE_REGS
2706    && REG_OK_FOR_BASE_P (operands[1])
2707    && REG_OK_FOR_INDEX_P (operands[2])
2708    && FP_REGNO_P (REGNO (operands[3]))"
2709   [(set (mem:SI (plus:SI (match_dup 2) (match_dup 1)))
2710         (match_dup 3))
2711    (set (match_dup 0) (plus:SI (match_dup 2) (match_dup 1)))]
2712   "")
2713
2714 (define_peephole2
2715   [(set (match_operand:DI 0 "register_operand" "")
2716         (plus:DI (match_operand:DI 1 "register_operand" "")
2717                  (match_operand:DI 2 "register_operand" "")))
2718    (set (mem:SI (match_dup 0))
2719         (match_operand:SI 3 "register_operand" ""))]
2720   "!TARGET_SOFT_FLOAT
2721    && !TARGET_DISABLE_INDEXING
2722    && TARGET_64BIT
2723    && TARGET_NO_SPACE_REGS
2724    && REG_OK_FOR_INDEX_P (operands[1])
2725    && REG_OK_FOR_BASE_P (operands[2])
2726    && FP_REGNO_P (REGNO (operands[3]))"
2727   [(set (mem:SI (plus:DI (match_dup 1) (match_dup 2)))
2728         (match_dup 3))
2729    (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
2730   "")
2731
2732 (define_peephole2
2733   [(set (match_operand:DI 0 "register_operand" "")
2734         (plus:DI (match_operand:DI 1 "register_operand" "")
2735                  (match_operand:DI 2 "register_operand" "")))
2736    (set (mem:SI (match_dup 0))
2737         (match_operand:SI 3 "register_operand" ""))]
2738   "!TARGET_SOFT_FLOAT
2739    && !TARGET_DISABLE_INDEXING
2740    && TARGET_64BIT
2741    && TARGET_NO_SPACE_REGS
2742    && REG_OK_FOR_BASE_P (operands[1])
2743    && REG_OK_FOR_INDEX_P (operands[2])
2744    && FP_REGNO_P (REGNO (operands[3]))"
2745   [(set (mem:SI (plus:DI (match_dup 2) (match_dup 1)))
2746         (match_dup 3))
2747    (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
2748   "")
2749
2750 (define_insn ""
2751   [(set (match_operand:SI 0 "move_dest_operand"
2752                           "=r,r,r,r,r,r,Q,!*q,!r")
2753         (match_operand:SI 1 "move_src_operand"
2754                           "A,r,J,N,K,RQ,rM,!rM,!*q"))]
2755   "(register_operand (operands[0], SImode)
2756     || reg_or_0_operand (operands[1], SImode))
2757    && TARGET_SOFT_FLOAT"
2758   "@
2759    ldw RT'%A1,%0
2760    copy %1,%0
2761    ldi %1,%0
2762    ldil L'%1,%0
2763    {zdepi|depwi,z} %Z1,%0
2764    ldw%M1 %1,%0
2765    stw%M0 %r1,%0
2766    mtsar %r1
2767    {mfctl|mfctl,w} %%sar,%0"
2768   [(set_attr "type" "load,move,move,move,move,load,store,move,move")
2769    (set_attr "pa_combine_type" "addmove")
2770    (set_attr "length" "4,4,4,4,4,4,4,4,4")])
2771
2772 ;; Load or store with base-register modification.
2773 (define_insn ""
2774   [(set (match_operand:SI 0 "register_operand" "=r")
2775         (mem:SI (plus:DI (match_operand:DI 1 "register_operand" "+r")
2776                          (match_operand:DI 2 "int5_operand" "L"))))
2777    (set (match_dup 1)
2778         (plus:DI (match_dup 1) (match_dup 2)))]
2779   "TARGET_64BIT"
2780   "ldw,mb %2(%1),%0"
2781   [(set_attr "type" "load")
2782    (set_attr "length" "4")])
2783
2784 ; And a zero extended variant.
2785 (define_insn ""
2786   [(set (match_operand:DI 0 "register_operand" "=r")
2787         (zero_extend:DI (mem:SI
2788                           (plus:DI
2789                             (match_operand:DI 1 "register_operand" "+r")
2790                             (match_operand:DI 2 "int5_operand" "L")))))
2791    (set (match_dup 1)
2792         (plus:DI (match_dup 1) (match_dup 2)))]
2793   "TARGET_64BIT"
2794   "ldw,mb %2(%1),%0"
2795   [(set_attr "type" "load")
2796    (set_attr "length" "4")])
2797
2798 (define_expand "pre_load"
2799   [(parallel [(set (match_operand:SI 0 "register_operand" "")
2800               (mem (plus (match_operand 1 "register_operand" "")
2801                                (match_operand 2 "pre_cint_operand" ""))))
2802               (set (match_dup 1)
2803                    (plus (match_dup 1) (match_dup 2)))])]
2804   ""
2805   "
2806 {
2807   if (TARGET_64BIT)
2808     {
2809       emit_insn (gen_pre_ldd (operands[0], operands[1], operands[2]));
2810       DONE;
2811     }
2812   emit_insn (gen_pre_ldw (operands[0], operands[1], operands[2]));
2813   DONE;
2814 }")
2815
2816 (define_insn "pre_ldw"
2817   [(set (match_operand:SI 0 "register_operand" "=r")
2818         (mem:SI (plus:SI (match_operand:SI 1 "register_operand" "+r")
2819                          (match_operand:SI 2 "pre_cint_operand" ""))))
2820    (set (match_dup 1)
2821         (plus:SI (match_dup 1) (match_dup 2)))]
2822   ""
2823   "*
2824 {
2825   if (INTVAL (operands[2]) < 0)
2826     return \"{ldwm|ldw,mb} %2(%1),%0\";
2827   return \"{ldws|ldw},mb %2(%1),%0\";
2828 }"
2829   [(set_attr "type" "load")
2830    (set_attr "length" "4")])
2831
2832 (define_insn "pre_ldd"
2833   [(set (match_operand:DI 0 "register_operand" "=r")
2834         (mem:DI (plus:DI (match_operand:DI 1 "register_operand" "+r")
2835                          (match_operand:DI 2 "pre_cint_operand" ""))))
2836    (set (match_dup 1)
2837         (plus:DI (match_dup 1) (match_dup 2)))]
2838   "TARGET_64BIT"
2839   "ldd,mb %2(%1),%0"
2840   [(set_attr "type" "load")
2841    (set_attr "length" "4")])
2842
2843 (define_insn ""
2844   [(set (mem:SI (plus:SI (match_operand:SI 0 "register_operand" "+r")
2845                          (match_operand:SI 1 "pre_cint_operand" "")))
2846         (match_operand:SI 2 "reg_or_0_operand" "rM"))
2847    (set (match_dup 0)
2848         (plus:SI (match_dup 0) (match_dup 1)))]
2849   ""
2850   "*
2851 {
2852   if (INTVAL (operands[1]) < 0)
2853     return \"{stwm|stw,mb} %r2,%1(%0)\";
2854   return \"{stws|stw},mb %r2,%1(%0)\";
2855 }"
2856   [(set_attr "type" "store")
2857    (set_attr "length" "4")])
2858
2859 (define_insn ""
2860   [(set (match_operand:SI 0 "register_operand" "=r")
2861         (mem:SI (match_operand:SI 1 "register_operand" "+r")))
2862    (set (match_dup 1)
2863         (plus:SI (match_dup 1)
2864                  (match_operand:SI 2 "post_cint_operand" "")))]
2865   ""
2866   "*
2867 {
2868   if (INTVAL (operands[2]) > 0)
2869     return \"{ldwm|ldw,ma} %2(%1),%0\";
2870   return \"{ldws|ldw},ma %2(%1),%0\";
2871 }"
2872   [(set_attr "type" "load")
2873    (set_attr "length" "4")])
2874
2875 (define_expand "post_store"
2876   [(parallel [(set (mem (match_operand 0 "register_operand" ""))
2877                    (match_operand 1 "reg_or_0_operand" ""))
2878               (set (match_dup 0)
2879                    (plus (match_dup 0)
2880                          (match_operand 2 "post_cint_operand" "")))])]
2881   ""
2882   "
2883 {
2884   if (TARGET_64BIT)
2885     {
2886       emit_insn (gen_post_std (operands[0], operands[1], operands[2]));
2887       DONE;
2888     }
2889   emit_insn (gen_post_stw (operands[0], operands[1], operands[2]));
2890   DONE;
2891 }")
2892
2893 (define_insn "post_stw"
2894   [(set (mem:SI (match_operand:SI 0 "register_operand" "+r"))
2895         (match_operand:SI 1 "reg_or_0_operand" "rM"))
2896    (set (match_dup 0)
2897         (plus:SI (match_dup 0)
2898                  (match_operand:SI 2 "post_cint_operand" "")))]
2899   ""
2900   "*
2901 {
2902   if (INTVAL (operands[2]) > 0)
2903     return \"{stwm|stw,ma} %r1,%2(%0)\";
2904   return \"{stws|stw},ma %r1,%2(%0)\";
2905 }"
2906   [(set_attr "type" "store")
2907    (set_attr "length" "4")])
2908
2909 (define_insn "post_std"
2910   [(set (mem:DI (match_operand:DI 0 "register_operand" "+r"))
2911         (match_operand:DI 1 "reg_or_0_operand" "rM"))
2912    (set (match_dup 0)
2913         (plus:DI (match_dup 0)
2914                  (match_operand:DI 2 "post_cint_operand" "")))]
2915   "TARGET_64BIT"
2916   "std,ma %r1,%2(%0)"
2917   [(set_attr "type" "store")
2918    (set_attr "length" "4")])
2919
2920 ;; For loading the address of a label while generating PIC code.
2921 ;; Note since this pattern can be created at reload time (via movsi), all
2922 ;; the same rules for movsi apply here.  (no new pseudos, no temporaries).
2923 (define_insn ""
2924   [(set (match_operand 0 "pmode_register_operand" "=a")
2925         (match_operand 1 "pic_label_operand" ""))]
2926   "TARGET_PA_20"
2927   "*
2928 {
2929   rtx xoperands[3];
2930
2931   xoperands[0] = operands[0];
2932   xoperands[1] = operands[1];
2933   xoperands[2] = gen_label_rtx ();
2934
2935   (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
2936                                      CODE_LABEL_NUMBER (xoperands[2]));
2937   output_asm_insn (\"mfia %0\", xoperands);
2938
2939   /* If we're trying to load the address of a label that happens to be
2940      close, then we can use a shorter sequence.  */
2941   if (GET_CODE (operands[1]) == LABEL_REF
2942       && !LABEL_REF_NONLOCAL_P (operands[1])
2943       && INSN_ADDRESSES_SET_P ()
2944       && abs (INSN_ADDRESSES (INSN_UID (XEXP (operands[1], 0)))
2945                 - INSN_ADDRESSES (INSN_UID (insn))) < 8100)
2946     output_asm_insn (\"ldo %1-%2(%0),%0\", xoperands);
2947   else
2948     {
2949       output_asm_insn (\"addil L%%%1-%2,%0\", xoperands);
2950       output_asm_insn (\"ldo R%%%1-%2(%0),%0\", xoperands);
2951     }
2952   return \"\";
2953 }"
2954   [(set_attr "type" "multi")
2955    (set_attr "length" "12")])           ; 8 or 12
2956
2957 (define_insn ""
2958   [(set (match_operand 0 "pmode_register_operand" "=a")
2959         (match_operand 1 "pic_label_operand" ""))]
2960   "!TARGET_PA_20"
2961   "*
2962 {
2963   rtx xoperands[3];
2964
2965   xoperands[0] = operands[0];
2966   xoperands[1] = operands[1];
2967   xoperands[2] = gen_label_rtx ();
2968
2969   output_asm_insn (\"bl .+8,%0\", xoperands);
2970   output_asm_insn (\"depi 0,31,2,%0\", xoperands);
2971   (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
2972                                      CODE_LABEL_NUMBER (xoperands[2]));
2973
2974   /* If we're trying to load the address of a label that happens to be
2975      close, then we can use a shorter sequence.  */
2976   if (GET_CODE (operands[1]) == LABEL_REF
2977       && !LABEL_REF_NONLOCAL_P (operands[1])
2978       && INSN_ADDRESSES_SET_P ()
2979       && abs (INSN_ADDRESSES (INSN_UID (XEXP (operands[1], 0)))
2980                 - INSN_ADDRESSES (INSN_UID (insn))) < 8100)
2981     output_asm_insn (\"ldo %1-%2(%0),%0\", xoperands);
2982   else
2983     {
2984       output_asm_insn (\"addil L%%%1-%2,%0\", xoperands);
2985       output_asm_insn (\"ldo R%%%1-%2(%0),%0\", xoperands);
2986     }
2987   return \"\";
2988 }"
2989   [(set_attr "type" "multi")
2990    (set_attr "length" "16")])           ; 12 or 16
2991
2992 (define_insn ""
2993   [(set (match_operand:SI 0 "register_operand" "=a")
2994         (plus:SI (match_operand:SI 1 "register_operand" "r")
2995                  (high:SI (match_operand 2 "" ""))))]
2996   "symbolic_operand (operands[2], Pmode)
2997    && ! function_label_operand (operands[2], Pmode)
2998    && flag_pic"
2999   "addil LT'%G2,%1"
3000   [(set_attr "type" "binary")
3001    (set_attr "length" "4")])
3002
3003 (define_insn ""
3004   [(set (match_operand:DI 0 "register_operand" "=a")
3005         (plus:DI (match_operand:DI 1 "register_operand" "r")
3006                  (high:DI (match_operand 2 "" ""))))]
3007   "symbolic_operand (operands[2], Pmode)
3008    && ! function_label_operand (operands[2], Pmode)
3009    && TARGET_64BIT
3010    && flag_pic"
3011   "addil LT'%G2,%1"
3012   [(set_attr "type" "binary")
3013    (set_attr "length" "4")])
3014
3015 ;; Always use addil rather than ldil;add sequences.  This allows the
3016 ;; HP linker to eliminate the dp relocation if the symbolic operand
3017 ;; lives in the TEXT space.
3018 (define_insn ""
3019   [(set (match_operand:SI 0 "register_operand" "=a")
3020         (high:SI (match_operand 1 "" "")))]
3021   "symbolic_operand (operands[1], Pmode)
3022    && ! function_label_operand (operands[1], Pmode)
3023    && ! read_only_operand (operands[1], Pmode)
3024    && ! flag_pic"
3025   "*
3026 {
3027   if (TARGET_LONG_LOAD_STORE)
3028     return \"addil NLR'%H1,%%r27\;ldo N'%H1(%%r1),%%r1\";
3029   else
3030     return \"addil LR'%H1,%%r27\";
3031 }"
3032   [(set_attr "type" "binary")
3033    (set (attr "length")
3034       (if_then_else (eq (symbol_ref "TARGET_LONG_LOAD_STORE") (const_int 0))
3035                     (const_int 4)
3036                     (const_int 8)))])
3037
3038
3039 ;; This is for use in the prologue/epilogue code.  We need it
3040 ;; to add large constants to a stack pointer or frame pointer.
3041 ;; Because of the additional %r1 pressure, we probably do not
3042 ;; want to use this in general code, so make it available
3043 ;; only after reload.
3044 (define_insn ""
3045   [(set (match_operand:SI 0 "register_operand" "=!a,*r")
3046         (plus:SI (match_operand:SI 1 "register_operand" "r,r")
3047                  (high:SI (match_operand 2 "const_int_operand" ""))))]
3048   "reload_completed"
3049   "@
3050    addil L'%G2,%1
3051    ldil L'%G2,%0\;{addl|add,l} %0,%1,%0"
3052   [(set_attr "type" "binary,binary")
3053    (set_attr "length" "4,8")])
3054
3055 (define_insn ""
3056   [(set (match_operand:DI 0 "register_operand" "=!a,*r")
3057         (plus:DI (match_operand:DI 1 "register_operand" "r,r")
3058                  (high:DI (match_operand 2 "const_int_operand" ""))))]
3059   "reload_completed && TARGET_64BIT"
3060   "@
3061    addil L'%G2,%1
3062    ldil L'%G2,%0\;{addl|add,l} %0,%1,%0"
3063   [(set_attr "type" "binary,binary")
3064    (set_attr "length" "4,8")])
3065
3066 (define_insn ""
3067   [(set (match_operand:SI 0 "register_operand" "=r")
3068         (high:SI (match_operand 1 "" "")))]
3069   "(!flag_pic || !symbolic_operand (operands[1], Pmode))
3070     && !is_function_label_plus_const (operands[1])"
3071   "*
3072 {
3073   if (symbolic_operand (operands[1], Pmode))
3074     return \"ldil LR'%H1,%0\";
3075   else
3076     return \"ldil L'%G1,%0\";
3077 }"
3078   [(set_attr "type" "move")
3079    (set_attr "length" "4")])
3080
3081 (define_insn ""
3082   [(set (match_operand:DI 0 "register_operand" "=r")
3083         (high:DI (match_operand 1 "const_int_operand" "")))]
3084   "TARGET_64BIT"
3085   "ldil L'%G1,%0";
3086   [(set_attr "type" "move")
3087    (set_attr "length" "4")])
3088
3089 (define_insn ""
3090   [(set (match_operand:DI 0 "register_operand" "=r")
3091         (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
3092                    (match_operand:DI 2 "const_int_operand" "i")))]
3093   "TARGET_64BIT"
3094   "ldo R'%G2(%1),%0";
3095   [(set_attr "type" "move")
3096    (set_attr "length" "4")])
3097
3098 (define_insn ""
3099   [(set (match_operand:SI 0 "register_operand" "=r")
3100         (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
3101                    (match_operand:SI 2 "immediate_operand" "i")))]
3102   "!is_function_label_plus_const (operands[2])"
3103   "*
3104 {
3105   gcc_assert (!flag_pic || !symbolic_operand (operands[2], Pmode));
3106   
3107   if (symbolic_operand (operands[2], Pmode))
3108     return \"ldo RR'%G2(%1),%0\";
3109   else
3110     return \"ldo R'%G2(%1),%0\";
3111 }"
3112   [(set_attr "type" "move")
3113    (set_attr "length" "4")])
3114
3115 ;; Now that a symbolic_address plus a constant is broken up early
3116 ;; in the compilation phase (for better CSE) we need a special
3117 ;; combiner pattern to load the symbolic address plus the constant
3118 ;; in only 2 instructions. (For cases where the symbolic address
3119 ;; was not a common subexpression.)
3120 (define_split
3121   [(set (match_operand:SI 0 "register_operand" "")
3122         (match_operand:SI 1 "symbolic_operand" ""))
3123    (clobber (match_operand:SI 2 "register_operand" ""))]
3124   "! (flag_pic && pic_label_operand (operands[1], SImode))"
3125   [(set (match_dup 2) (high:SI (match_dup 1)))
3126    (set (match_dup 0) (lo_sum:SI (match_dup 2) (match_dup 1)))]
3127   "")
3128
3129 ;; hppa_legitimize_address goes to a great deal of trouble to
3130 ;; create addresses which use indexing.  In some cases, this
3131 ;; is a lose because there isn't any store instructions which
3132 ;; allow indexed addresses (with integer register source).
3133 ;;
3134 ;; These define_splits try to turn a 3 insn store into
3135 ;; a 2 insn store with some creative RTL rewriting.
3136 (define_split
3137   [(set (mem:SI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
3138                                (match_operand:SI 1 "shadd_operand" ""))
3139                    (plus:SI (match_operand:SI 2 "register_operand" "")
3140                             (match_operand:SI 3 "const_int_operand" ""))))
3141         (match_operand:SI 4 "register_operand" ""))
3142    (clobber (match_operand:SI 5 "register_operand" ""))]
3143   ""
3144   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
3145                                (match_dup 2)))
3146    (set (mem:SI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
3147   "")
3148
3149 (define_split
3150   [(set (mem:HI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
3151                                (match_operand:SI 1 "shadd_operand" ""))
3152                    (plus:SI (match_operand:SI 2 "register_operand" "")
3153                             (match_operand:SI 3 "const_int_operand" ""))))
3154         (match_operand:HI 4 "register_operand" ""))
3155    (clobber (match_operand:SI 5 "register_operand" ""))]
3156   ""
3157   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
3158                                (match_dup 2)))
3159    (set (mem:HI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
3160   "")
3161
3162 (define_split
3163   [(set (mem:QI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
3164                                (match_operand:SI 1 "shadd_operand" ""))
3165                    (plus:SI (match_operand:SI 2 "register_operand" "")
3166                             (match_operand:SI 3 "const_int_operand" ""))))
3167         (match_operand:QI 4 "register_operand" ""))
3168    (clobber (match_operand:SI 5 "register_operand" ""))]
3169   ""
3170   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
3171                                (match_dup 2)))
3172    (set (mem:QI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
3173   "")
3174
3175 (define_expand "movhi"
3176   [(set (match_operand:HI 0 "general_operand" "")
3177         (match_operand:HI 1 "general_operand" ""))]
3178   ""
3179   "
3180 {
3181   if (emit_move_sequence (operands, HImode, 0))
3182     DONE;
3183 }")
3184
3185 (define_insn ""
3186   [(set (match_operand:HI 0 "move_dest_operand"
3187                           "=r,r,r,r,r,Q,!*q,!r,!*f,?r,?*f")
3188         (match_operand:HI 1 "move_src_operand"
3189                           "r,J,N,K,RQ,rM,!rM,!*q,!*fM,*f,r"))]
3190   "(register_operand (operands[0], HImode)
3191     || reg_or_0_operand (operands[1], HImode))
3192    && !TARGET_SOFT_FLOAT
3193    && !TARGET_64BIT"
3194   "@
3195    copy %1,%0
3196    ldi %1,%0
3197    ldil L'%1,%0
3198    {zdepi|depwi,z} %Z1,%0
3199    ldh%M1 %1,%0
3200    sth%M0 %r1,%0
3201    mtsar %r1
3202    {mfctl|mfctl,w} %sar,%0
3203    fcpy,sgl %f1,%0
3204    {fstws|fstw} %1,-16(%%sp)\n\t{ldws|ldw} -16(%%sp),%0
3205    {stws|stw} %1,-16(%%sp)\n\t{fldws|fldw} -16(%%sp),%0"
3206   [(set_attr "type" "move,move,move,shift,load,store,move,move,move,fpstore_load,store_fpload")
3207    (set_attr "pa_combine_type" "addmove")
3208    (set_attr "length" "4,4,4,4,4,4,4,4,4,8,8")])
3209
3210 (define_insn ""
3211   [(set (match_operand:HI 0 "move_dest_operand"
3212                           "=r,r,r,r,r,Q,!*q,!r,!*f")
3213         (match_operand:HI 1 "move_src_operand"
3214                           "r,J,N,K,RQ,rM,!rM,!*q,!*fM"))]
3215   "(register_operand (operands[0], HImode)
3216     || reg_or_0_operand (operands[1], HImode))
3217    && !TARGET_SOFT_FLOAT
3218    && TARGET_64BIT"
3219   "@
3220    copy %1,%0
3221    ldi %1,%0
3222    ldil L'%1,%0
3223    {zdepi|depwi,z} %Z1,%0
3224    ldh%M1 %1,%0
3225    sth%M0 %r1,%0
3226    mtsar %r1
3227    {mfctl|mfctl,w} %sar,%0
3228    fcpy,sgl %f1,%0"
3229   [(set_attr "type" "move,move,move,shift,load,store,move,move,move")
3230    (set_attr "pa_combine_type" "addmove")
3231    (set_attr "length" "4,4,4,4,4,4,4,4,4")])
3232
3233 (define_insn ""
3234   [(set (match_operand:HI 0 "move_dest_operand"
3235                           "=r,r,r,r,r,Q,!*q,!r")
3236         (match_operand:HI 1 "move_src_operand"
3237                           "r,J,N,K,RQ,rM,!rM,!*q"))]
3238   "(register_operand (operands[0], HImode)
3239     || reg_or_0_operand (operands[1], HImode))
3240    && TARGET_SOFT_FLOAT"
3241   "@
3242    copy %1,%0
3243    ldi %1,%0
3244    ldil L'%1,%0
3245    {zdepi|depwi,z} %Z1,%0
3246    ldh%M1 %1,%0
3247    sth%M0 %r1,%0
3248    mtsar %r1
3249    {mfctl|mfctl,w} %sar,%0"
3250   [(set_attr "type" "move,move,move,shift,load,store,move,move")
3251    (set_attr "pa_combine_type" "addmove")
3252    (set_attr "length" "4,4,4,4,4,4,4,4")])
3253
3254 (define_insn ""
3255   [(set (match_operand:HI 0 "register_operand" "=r")
3256         (mem:HI (plus:SI (match_operand:SI 1 "register_operand" "+r")
3257                          (match_operand:SI 2 "int5_operand" "L"))))
3258    (set (match_dup 1)
3259         (plus:SI (match_dup 1) (match_dup 2)))]
3260   ""
3261   "{ldhs|ldh},mb %2(%1),%0"
3262   [(set_attr "type" "load")
3263    (set_attr "length" "4")])
3264
3265 (define_insn ""
3266   [(set (match_operand:HI 0 "register_operand" "=r")
3267         (mem:HI (plus:DI (match_operand:DI 1 "register_operand" "+r")
3268                          (match_operand:DI 2 "int5_operand" "L"))))
3269    (set (match_dup 1)
3270         (plus:DI (match_dup 1) (match_dup 2)))]
3271   "TARGET_64BIT"
3272   "ldh,mb %2(%1),%0"
3273   [(set_attr "type" "load")
3274    (set_attr "length" "4")])
3275
3276 ; And a zero extended variant.
3277 (define_insn ""
3278   [(set (match_operand:DI 0 "register_operand" "=r")
3279         (zero_extend:DI (mem:HI
3280                           (plus:DI
3281                             (match_operand:DI 1 "register_operand" "+r")
3282                             (match_operand:DI 2 "int5_operand" "L")))))
3283    (set (match_dup 1)
3284         (plus:DI (match_dup 1) (match_dup 2)))]
3285   "TARGET_64BIT"
3286   "ldh,mb %2(%1),%0"
3287   [(set_attr "type" "load")
3288    (set_attr "length" "4")])
3289
3290 (define_insn ""
3291   [(set (match_operand:SI 0 "register_operand" "=r")
3292         (zero_extend:SI (mem:HI
3293                           (plus:SI
3294                             (match_operand:SI 1 "register_operand" "+r")
3295                             (match_operand:SI 2 "int5_operand" "L")))))
3296    (set (match_dup 1)
3297         (plus:SI (match_dup 1) (match_dup 2)))]
3298   ""
3299   "{ldhs|ldh},mb %2(%1),%0"
3300   [(set_attr "type" "load")
3301    (set_attr "length" "4")])
3302
3303 (define_insn ""
3304   [(set (match_operand:SI 0 "register_operand" "=r")
3305         (zero_extend:SI (mem:HI
3306                           (plus:DI
3307                             (match_operand:DI 1 "register_operand" "+r")
3308                             (match_operand:DI 2 "int5_operand" "L")))))
3309    (set (match_dup 1)
3310         (plus:DI (match_dup 1) (match_dup 2)))]
3311   "TARGET_64BIT"
3312   "ldh,mb %2(%1),%0"
3313   [(set_attr "type" "load")
3314    (set_attr "length" "4")])
3315
3316 (define_insn ""
3317   [(set (mem:HI (plus:SI (match_operand:SI 0 "register_operand" "+r")
3318                          (match_operand:SI 1 "int5_operand" "L")))
3319         (match_operand:HI 2 "reg_or_0_operand" "rM"))
3320    (set (match_dup 0)
3321         (plus:SI (match_dup 0) (match_dup 1)))]
3322   ""
3323   "{sths|sth},mb %r2,%1(%0)"
3324   [(set_attr "type" "store")
3325    (set_attr "length" "4")])
3326
3327 (define_insn ""
3328   [(set (mem:HI (plus:DI (match_operand:DI 0 "register_operand" "+r")
3329                          (match_operand:DI 1 "int5_operand" "L")))
3330         (match_operand:HI 2 "reg_or_0_operand" "rM"))
3331    (set (match_dup 0)
3332         (plus:DI (match_dup 0) (match_dup 1)))]
3333   "TARGET_64BIT"
3334   "sth,mb %r2,%1(%0)"
3335   [(set_attr "type" "store")
3336    (set_attr "length" "4")])
3337
3338 (define_insn ""
3339   [(set (match_operand:HI 0 "register_operand" "=r")
3340         (plus:HI (match_operand:HI 1 "register_operand" "r")
3341                  (match_operand 2 "const_int_operand" "J")))]
3342   ""
3343   "ldo %2(%1),%0"
3344   [(set_attr "type" "binary")
3345    (set_attr "pa_combine_type" "addmove")
3346    (set_attr "length" "4")])
3347
3348 (define_expand "movqi"
3349   [(set (match_operand:QI 0 "general_operand" "")
3350         (match_operand:QI 1 "general_operand" ""))]
3351   ""
3352   "
3353 {
3354   if (emit_move_sequence (operands, QImode, 0))
3355     DONE;
3356 }")
3357
3358 (define_insn ""
3359   [(set (match_operand:QI 0 "move_dest_operand"
3360                           "=r,r,r,r,r,Q,!*q,!r,!*f,?r,?*f")
3361         (match_operand:QI 1 "move_src_operand"
3362                           "r,J,N,K,RQ,rM,!rM,!*q,!*fM,*f,r"))]
3363   "(register_operand (operands[0], QImode)
3364     || reg_or_0_operand (operands[1], QImode))
3365    && !TARGET_SOFT_FLOAT
3366    && !TARGET_64BIT"
3367   "@
3368    copy %1,%0
3369    ldi %1,%0
3370    ldil L'%1,%0
3371    {zdepi|depwi,z} %Z1,%0
3372    ldb%M1 %1,%0
3373    stb%M0 %r1,%0
3374    mtsar %r1
3375    {mfctl|mfctl,w} %%sar,%0
3376    fcpy,sgl %f1,%0
3377    {fstws|fstw} %1,-16(%%sp)\n\t{ldws|ldw} -16(%%sp),%0
3378    {stws|stw} %1,-16(%%sp)\n\t{fldws|fldw} -16(%%sp),%0"
3379   [(set_attr "type" "move,move,move,shift,load,store,move,move,move,fpstore_load,store_fpload")
3380    (set_attr "pa_combine_type" "addmove")
3381    (set_attr "length" "4,4,4,4,4,4,4,4,4,8,8")])
3382
3383 (define_insn ""
3384   [(set (match_operand:QI 0 "move_dest_operand"
3385                           "=r,r,r,r,r,Q,!*q,!r,!*f")
3386         (match_operand:QI 1 "move_src_operand"
3387                           "r,J,N,K,RQ,rM,!rM,!*q,!*fM"))]
3388   "(register_operand (operands[0], QImode)
3389     || reg_or_0_operand (operands[1], QImode))
3390    && !TARGET_SOFT_FLOAT
3391    && TARGET_64BIT"
3392   "@
3393    copy %1,%0
3394    ldi %1,%0
3395    ldil L'%1,%0
3396    {zdepi|depwi,z} %Z1,%0
3397    ldb%M1 %1,%0
3398    stb%M0 %r1,%0
3399    mtsar %r1
3400    {mfctl|mfctl,w} %%sar,%0
3401    fcpy,sgl %f1,%0"
3402   [(set_attr "type" "move,move,move,shift,load,store,move,move,move")
3403    (set_attr "pa_combine_type" "addmove")
3404    (set_attr "length" "4,4,4,4,4,4,4,4,4")])
3405
3406 (define_insn ""
3407   [(set (match_operand:QI 0 "move_dest_operand"
3408                           "=r,r,r,r,r,Q,!*q,!r")
3409         (match_operand:QI 1 "move_src_operand"
3410                           "r,J,N,K,RQ,rM,!rM,!*q"))]
3411   "(register_operand (operands[0], QImode)
3412     || reg_or_0_operand (operands[1], QImode))
3413    && TARGET_SOFT_FLOAT"
3414   "@
3415    copy %1,%0
3416    ldi %1,%0
3417    ldil L'%1,%0
3418    {zdepi|depwi,z} %Z1,%0
3419    ldb%M1 %1,%0
3420    stb%M0 %r1,%0
3421    mtsar %r1
3422    {mfctl|mfctl,w} %%sar,%0"
3423   [(set_attr "type" "move,move,move,shift,load,store,move,move")
3424    (set_attr "pa_combine_type" "addmove")
3425    (set_attr "length" "4,4,4,4,4,4,4,4")])
3426
3427 (define_insn ""
3428   [(set (match_operand:QI 0 "register_operand" "=r")
3429         (mem:QI (plus:SI (match_operand:SI 1 "register_operand" "+r")
3430                          (match_operand:SI 2 "int5_operand" "L"))))
3431    (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
3432   ""
3433   "{ldbs|ldb},mb %2(%1),%0"
3434   [(set_attr "type" "load")
3435    (set_attr "length" "4")])
3436
3437 (define_insn ""
3438   [(set (match_operand:QI 0 "register_operand" "=r")
3439         (mem:QI (plus:DI (match_operand:DI 1 "register_operand" "+r")
3440                          (match_operand:DI 2 "int5_operand" "L"))))
3441    (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3442   "TARGET_64BIT"
3443   "ldb,mb %2(%1),%0"
3444   [(set_attr "type" "load")
3445    (set_attr "length" "4")])
3446
3447 ; Now the same thing with zero extensions.
3448 (define_insn ""
3449   [(set (match_operand:DI 0 "register_operand" "=r")
3450         (zero_extend:DI (mem:QI (plus:DI
3451                                   (match_operand:DI 1 "register_operand" "+r")
3452                                   (match_operand:DI 2 "int5_operand" "L")))))
3453    (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3454   "TARGET_64BIT"
3455   "ldb,mb %2(%1),%0"
3456   [(set_attr "type" "load")
3457    (set_attr "length" "4")])
3458
3459 (define_insn ""
3460   [(set (match_operand:SI 0 "register_operand" "=r")
3461         (zero_extend:SI (mem:QI (plus:SI
3462                                   (match_operand:SI 1 "register_operand" "+r")
3463                                   (match_operand:SI 2 "int5_operand" "L")))))
3464    (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
3465   ""
3466   "{ldbs|ldb},mb %2(%1),%0"
3467   [(set_attr "type" "load")
3468    (set_attr "length" "4")])
3469
3470 (define_insn ""
3471   [(set (match_operand:SI 0 "register_operand" "=r")
3472         (zero_extend:SI (mem:QI (plus:DI
3473                                   (match_operand:DI 1 "register_operand" "+r")
3474                                   (match_operand:DI 2 "int5_operand" "L")))))
3475    (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3476   "TARGET_64BIT"
3477   "ldb,mb %2(%1),%0"
3478   [(set_attr "type" "load")
3479    (set_attr "length" "4")])
3480
3481 (define_insn ""
3482   [(set (match_operand:HI 0 "register_operand" "=r")
3483         (zero_extend:HI (mem:QI (plus:SI
3484                                   (match_operand:SI 1 "register_operand" "+r")
3485                                   (match_operand:SI 2 "int5_operand" "L")))))
3486    (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
3487   ""
3488   "{ldbs|ldb},mb %2(%1),%0"
3489   [(set_attr "type" "load")
3490    (set_attr "length" "4")])
3491
3492 (define_insn ""
3493   [(set (match_operand:HI 0 "register_operand" "=r")
3494         (zero_extend:HI (mem:QI (plus:DI
3495                                   (match_operand:DI 1 "register_operand" "+r")
3496                                   (match_operand:DI 2 "int5_operand" "L")))))
3497    (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3498   "TARGET_64BIT"
3499   "ldb,mb %2(%1),%0"
3500   [(set_attr "type" "load")
3501    (set_attr "length" "4")])
3502
3503 (define_insn ""
3504   [(set (mem:QI (plus:SI (match_operand:SI 0 "register_operand" "+r")
3505                          (match_operand:SI 1 "int5_operand" "L")))
3506         (match_operand:QI 2 "reg_or_0_operand" "rM"))
3507    (set (match_dup 0)
3508         (plus:SI (match_dup 0) (match_dup 1)))]
3509   ""
3510   "{stbs|stb},mb %r2,%1(%0)"
3511   [(set_attr "type" "store")
3512    (set_attr "length" "4")])
3513
3514 (define_insn ""
3515   [(set (mem:QI (plus:DI (match_operand:DI 0 "register_operand" "+r")
3516                          (match_operand:DI 1 "int5_operand" "L")))
3517         (match_operand:QI 2 "reg_or_0_operand" "rM"))
3518    (set (match_dup 0)
3519         (plus:DI (match_dup 0) (match_dup 1)))]
3520   "TARGET_64BIT"
3521   "stb,mb %r2,%1(%0)"
3522   [(set_attr "type" "store")
3523    (set_attr "length" "4")])
3524
3525 ;; The definition of this insn does not really explain what it does,
3526 ;; but it should suffice that anything generated as this insn will be
3527 ;; recognized as a movmemsi operation, and that it will not successfully
3528 ;; combine with anything.
3529 (define_expand "movmemsi"
3530   [(parallel [(set (match_operand:BLK 0 "" "")
3531                    (match_operand:BLK 1 "" ""))
3532               (clobber (match_dup 4))
3533               (clobber (match_dup 5))
3534               (clobber (match_dup 6))
3535               (clobber (match_dup 7))
3536               (clobber (match_dup 8))
3537               (use (match_operand:SI 2 "arith_operand" ""))
3538               (use (match_operand:SI 3 "const_int_operand" ""))])]
3539   "!TARGET_64BIT && optimize > 0"
3540   "
3541 {
3542   int size, align;
3543
3544   /* HP provides very fast block move library routine for the PA;
3545      this routine includes:
3546
3547         4x4 byte at a time block moves,
3548         1x4 byte at a time with alignment checked at runtime with
3549             attempts to align the source and destination as needed
3550         1x1 byte loop
3551
3552      With that in mind, here's the heuristics to try and guess when
3553      the inlined block move will be better than the library block
3554      move:
3555
3556         If the size isn't constant, then always use the library routines.
3557
3558         If the size is large in respect to the known alignment, then use
3559         the library routines.
3560
3561         If the size is small in respect to the known alignment, then open
3562         code the copy (since that will lead to better scheduling).
3563
3564         Else use the block move pattern.   */
3565
3566   /* Undetermined size, use the library routine.  */
3567   if (GET_CODE (operands[2]) != CONST_INT)
3568     FAIL;
3569
3570   size = INTVAL (operands[2]);
3571   align = INTVAL (operands[3]);
3572   align = align > 4 ? 4 : align;
3573
3574   /* If size/alignment is large, then use the library routines.  */
3575   if (size / align > 16)
3576     FAIL;
3577
3578   /* This does happen, but not often enough to worry much about.  */
3579   if (size / align < MOVE_RATIO)
3580     FAIL;
3581   
3582   /* Fall through means we're going to use our block move pattern.  */
3583   operands[0]
3584     = replace_equiv_address (operands[0],
3585                              copy_to_mode_reg (SImode, XEXP (operands[0], 0)));
3586   operands[1]
3587     = replace_equiv_address (operands[1],
3588                              copy_to_mode_reg (SImode, XEXP (operands[1], 0)));
3589   operands[4] = gen_reg_rtx (SImode);
3590   operands[5] = gen_reg_rtx (SImode);
3591   operands[6] = gen_reg_rtx (SImode);
3592   operands[7] = gen_reg_rtx (SImode);
3593   operands[8] = gen_reg_rtx (SImode);
3594 }")
3595
3596 ;; The operand constraints are written like this to support both compile-time
3597 ;; and run-time determined byte counts.  The expander and output_block_move
3598 ;; only support compile-time determined counts at this time.
3599 ;;
3600 ;; If the count is run-time determined, the register with the byte count
3601 ;; is clobbered by the copying code, and therefore it is forced to operand 2.
3602 ;;
3603 ;; We used to clobber operands 0 and 1.  However, a change to regrename.c
3604 ;; broke this semantic for pseudo registers.  We can't use match_scratch
3605 ;; as this requires two registers in the class R1_REGS when the MEMs for
3606 ;; operands 0 and 1 are both equivalent to symbolic MEMs.  Thus, we are
3607 ;; forced to internally copy operands 0 and 1 to operands 7 and 8,
3608 ;; respectively.  We then split or peephole optimize after reload.
3609 (define_insn "movmemsi_prereload"
3610   [(set (mem:BLK (match_operand:SI 0 "register_operand" "r,r"))
3611         (mem:BLK (match_operand:SI 1 "register_operand" "r,r")))
3612    (clobber (match_operand:SI 2 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3613    (clobber (match_operand:SI 3 "register_operand" "=&r,&r"))   ;item tmp1
3614    (clobber (match_operand:SI 6 "register_operand" "=&r,&r"))   ;item tmp2
3615    (clobber (match_operand:SI 7 "register_operand" "=&r,&r"))   ;item tmp3
3616    (clobber (match_operand:SI 8 "register_operand" "=&r,&r"))   ;item tmp4
3617    (use (match_operand:SI 4 "arith_operand" "J,2"))      ;byte count
3618    (use (match_operand:SI 5 "const_int_operand" "n,n"))] ;alignment
3619   "!TARGET_64BIT"
3620   "#"
3621   [(set_attr "type" "multi,multi")])
3622
3623 (define_split
3624   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3625                    (match_operand:BLK 1 "memory_operand" ""))
3626               (clobber (match_operand:SI 2 "register_operand" ""))
3627               (clobber (match_operand:SI 3 "register_operand" ""))
3628               (clobber (match_operand:SI 6 "register_operand" ""))
3629               (clobber (match_operand:SI 7 "register_operand" ""))
3630               (clobber (match_operand:SI 8 "register_operand" ""))
3631               (use (match_operand:SI 4 "arith_operand" ""))
3632               (use (match_operand:SI 5 "const_int_operand" ""))])]
3633   "!TARGET_64BIT && reload_completed && !flag_peephole2
3634    && GET_CODE (operands[0]) == MEM
3635    && register_operand (XEXP (operands[0], 0), SImode)
3636    && GET_CODE (operands[1]) == MEM
3637    && register_operand (XEXP (operands[1], 0), SImode)"
3638   [(set (match_dup 7) (match_dup 9))
3639    (set (match_dup 8) (match_dup 10))
3640    (parallel [(set (match_dup 0) (match_dup 1))
3641               (clobber (match_dup 2))
3642               (clobber (match_dup 3))
3643               (clobber (match_dup 6))
3644               (clobber (match_dup 7))
3645               (clobber (match_dup 8))
3646               (use (match_dup 4))
3647               (use (match_dup 5))
3648               (const_int 0)])]
3649   "
3650 {
3651   operands[9] = XEXP (operands[0], 0);
3652   operands[10] = XEXP (operands[1], 0);
3653   operands[0] = replace_equiv_address (operands[0], operands[7]);
3654   operands[1] = replace_equiv_address (operands[1], operands[8]);
3655 }")
3656
3657 (define_peephole2
3658   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3659                    (match_operand:BLK 1 "memory_operand" ""))
3660               (clobber (match_operand:SI 2 "register_operand" ""))
3661               (clobber (match_operand:SI 3 "register_operand" ""))
3662               (clobber (match_operand:SI 6 "register_operand" ""))
3663               (clobber (match_operand:SI 7 "register_operand" ""))
3664               (clobber (match_operand:SI 8 "register_operand" ""))
3665               (use (match_operand:SI 4 "arith_operand" ""))
3666               (use (match_operand:SI 5 "const_int_operand" ""))])]
3667   "!TARGET_64BIT
3668    && GET_CODE (operands[0]) == MEM
3669    && register_operand (XEXP (operands[0], 0), SImode)
3670    && GET_CODE (operands[1]) == MEM
3671    && register_operand (XEXP (operands[1], 0), SImode)"
3672   [(parallel [(set (match_dup 0) (match_dup 1))
3673               (clobber (match_dup 2))
3674               (clobber (match_dup 3))
3675               (clobber (match_dup 6))
3676               (clobber (match_dup 7))
3677               (clobber (match_dup 8))
3678               (use (match_dup 4))
3679               (use (match_dup 5))
3680               (const_int 0)])]
3681   "
3682 {
3683   rtx addr = XEXP (operands[0], 0);
3684   if (dead_or_set_p (curr_insn, addr))
3685     operands[7] = addr;
3686   else
3687     {
3688       emit_insn (gen_rtx_SET (VOIDmode, operands[7], addr));
3689       operands[0] = replace_equiv_address (operands[0], operands[7]);
3690     }
3691
3692   addr = XEXP (operands[1], 0);
3693   if (dead_or_set_p (curr_insn, addr))
3694     operands[8] = addr;
3695   else
3696     {
3697       emit_insn (gen_rtx_SET (VOIDmode, operands[8], addr));
3698       operands[1] = replace_equiv_address (operands[1], operands[8]);
3699     }
3700 }")
3701
3702 (define_insn "movmemsi_postreload"
3703   [(set (mem:BLK (match_operand:SI 0 "register_operand" "+r,r"))
3704         (mem:BLK (match_operand:SI 1 "register_operand" "+r,r")))
3705    (clobber (match_operand:SI 2 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3706    (clobber (match_operand:SI 3 "register_operand" "=&r,&r"))   ;item tmp1
3707    (clobber (match_operand:SI 6 "register_operand" "=&r,&r"))   ;item tmp2
3708    (clobber (match_dup 0))
3709    (clobber (match_dup 1))
3710    (use (match_operand:SI 4 "arith_operand" "J,2"))      ;byte count
3711    (use (match_operand:SI 5 "const_int_operand" "n,n"))  ;alignment
3712    (const_int 0)]
3713   "!TARGET_64BIT && reload_completed"
3714   "* return output_block_move (operands, !which_alternative);"
3715   [(set_attr "type" "multi,multi")])
3716
3717 (define_expand "movmemdi"
3718   [(parallel [(set (match_operand:BLK 0 "" "")
3719                    (match_operand:BLK 1 "" ""))
3720               (clobber (match_dup 4))
3721               (clobber (match_dup 5))
3722               (clobber (match_dup 6))
3723               (clobber (match_dup 7))
3724               (clobber (match_dup 8))
3725               (use (match_operand:DI 2 "arith_operand" ""))
3726               (use (match_operand:DI 3 "const_int_operand" ""))])]
3727   "TARGET_64BIT && optimize > 0"
3728   "
3729 {
3730   int size, align;
3731
3732   /* HP provides very fast block move library routine for the PA;
3733      this routine includes:
3734
3735         4x4 byte at a time block moves,
3736         1x4 byte at a time with alignment checked at runtime with
3737             attempts to align the source and destination as needed
3738         1x1 byte loop
3739
3740      With that in mind, here's the heuristics to try and guess when
3741      the inlined block move will be better than the library block
3742      move:
3743
3744         If the size isn't constant, then always use the library routines.
3745
3746         If the size is large in respect to the known alignment, then use
3747         the library routines.
3748
3749         If the size is small in respect to the known alignment, then open
3750         code the copy (since that will lead to better scheduling).
3751
3752         Else use the block move pattern.   */
3753
3754   /* Undetermined size, use the library routine.  */
3755   if (GET_CODE (operands[2]) != CONST_INT)
3756     FAIL;
3757
3758   size = INTVAL (operands[2]);
3759   align = INTVAL (operands[3]);
3760   align = align > 8 ? 8 : align;
3761
3762   /* If size/alignment is large, then use the library routines.  */
3763   if (size / align > 16)
3764     FAIL;
3765
3766   /* This does happen, but not often enough to worry much about.  */
3767   if (size / align < MOVE_RATIO)
3768     FAIL;
3769   
3770   /* Fall through means we're going to use our block move pattern.  */
3771   operands[0]
3772     = replace_equiv_address (operands[0],
3773                              copy_to_mode_reg (DImode, XEXP (operands[0], 0)));
3774   operands[1]
3775     = replace_equiv_address (operands[1],
3776                              copy_to_mode_reg (DImode, XEXP (operands[1], 0)));
3777   operands[4] = gen_reg_rtx (DImode);
3778   operands[5] = gen_reg_rtx (DImode);
3779   operands[6] = gen_reg_rtx (DImode);
3780   operands[7] = gen_reg_rtx (DImode);
3781   operands[8] = gen_reg_rtx (DImode);
3782 }")
3783
3784 ;; The operand constraints are written like this to support both compile-time
3785 ;; and run-time determined byte counts.  The expander and output_block_move
3786 ;; only support compile-time determined counts at this time.
3787 ;;
3788 ;; If the count is run-time determined, the register with the byte count
3789 ;; is clobbered by the copying code, and therefore it is forced to operand 2.
3790 ;;
3791 ;; We used to clobber operands 0 and 1.  However, a change to regrename.c
3792 ;; broke this semantic for pseudo registers.  We can't use match_scratch
3793 ;; as this requires two registers in the class R1_REGS when the MEMs for
3794 ;; operands 0 and 1 are both equivalent to symbolic MEMs.  Thus, we are
3795 ;; forced to internally copy operands 0 and 1 to operands 7 and 8,
3796 ;; respectively.  We then split or peephole optimize after reload.
3797 (define_insn "movmemdi_prereload"
3798   [(set (mem:BLK (match_operand:DI 0 "register_operand" "r,r"))
3799         (mem:BLK (match_operand:DI 1 "register_operand" "r,r")))
3800    (clobber (match_operand:DI 2 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3801    (clobber (match_operand:DI 3 "register_operand" "=&r,&r"))   ;item tmp1
3802    (clobber (match_operand:DI 6 "register_operand" "=&r,&r"))   ;item tmp2
3803    (clobber (match_operand:DI 7 "register_operand" "=&r,&r"))   ;item tmp3
3804    (clobber (match_operand:DI 8 "register_operand" "=&r,&r"))   ;item tmp4
3805    (use (match_operand:DI 4 "arith_operand" "J,2"))      ;byte count
3806    (use (match_operand:DI 5 "const_int_operand" "n,n"))] ;alignment
3807   "TARGET_64BIT"
3808   "#"
3809   [(set_attr "type" "multi,multi")])
3810
3811 (define_split
3812   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3813                    (match_operand:BLK 1 "memory_operand" ""))
3814               (clobber (match_operand:DI 2 "register_operand" ""))
3815               (clobber (match_operand:DI 3 "register_operand" ""))
3816               (clobber (match_operand:DI 6 "register_operand" ""))
3817               (clobber (match_operand:DI 7 "register_operand" ""))
3818               (clobber (match_operand:DI 8 "register_operand" ""))
3819               (use (match_operand:DI 4 "arith_operand" ""))
3820               (use (match_operand:DI 5 "const_int_operand" ""))])]
3821   "TARGET_64BIT && reload_completed && !flag_peephole2
3822    && GET_CODE (operands[0]) == MEM
3823    && register_operand (XEXP (operands[0], 0), DImode)
3824    && GET_CODE (operands[1]) == MEM
3825    && register_operand (XEXP (operands[1], 0), DImode)"
3826   [(set (match_dup 7) (match_dup 9))
3827    (set (match_dup 8) (match_dup 10))
3828    (parallel [(set (match_dup 0) (match_dup 1))
3829               (clobber (match_dup 2))
3830               (clobber (match_dup 3))
3831               (clobber (match_dup 6))
3832               (clobber (match_dup 7))
3833               (clobber (match_dup 8))
3834               (use (match_dup 4))
3835               (use (match_dup 5))
3836               (const_int 0)])]
3837   "
3838 {
3839   operands[9] = XEXP (operands[0], 0);
3840   operands[10] = XEXP (operands[1], 0);
3841   operands[0] = replace_equiv_address (operands[0], operands[7]);
3842   operands[1] = replace_equiv_address (operands[1], operands[8]);
3843 }")
3844
3845 (define_peephole2
3846   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3847                    (match_operand:BLK 1 "memory_operand" ""))
3848               (clobber (match_operand:DI 2 "register_operand" ""))
3849               (clobber (match_operand:DI 3 "register_operand" ""))
3850               (clobber (match_operand:DI 6 "register_operand" ""))
3851               (clobber (match_operand:DI 7 "register_operand" ""))
3852               (clobber (match_operand:DI 8 "register_operand" ""))
3853               (use (match_operand:DI 4 "arith_operand" ""))
3854               (use (match_operand:DI 5 "const_int_operand" ""))])]
3855   "TARGET_64BIT
3856    && GET_CODE (operands[0]) == MEM
3857    && register_operand (XEXP (operands[0], 0), DImode)
3858    && GET_CODE (operands[1]) == MEM
3859    && register_operand (XEXP (operands[1], 0), DImode)"
3860   [(parallel [(set (match_dup 0) (match_dup 1))
3861               (clobber (match_dup 2))
3862               (clobber (match_dup 3))
3863               (clobber (match_dup 6))
3864               (clobber (match_dup 7))
3865               (clobber (match_dup 8))
3866               (use (match_dup 4))
3867               (use (match_dup 5))
3868               (const_int 0)])]
3869   "
3870 {
3871   rtx addr = XEXP (operands[0], 0);
3872   if (dead_or_set_p (curr_insn, addr))
3873     operands[7] = addr;
3874   else
3875     {
3876       emit_insn (gen_rtx_SET (VOIDmode, operands[7], addr));
3877       operands[0] = replace_equiv_address (operands[0], operands[7]);
3878     }
3879
3880   addr = XEXP (operands[1], 0);
3881   if (dead_or_set_p (curr_insn, addr))
3882     operands[8] = addr;
3883   else
3884     {
3885       emit_insn (gen_rtx_SET (VOIDmode, operands[8], addr));
3886       operands[1] = replace_equiv_address (operands[1], operands[8]);
3887     }
3888 }")
3889
3890 (define_insn "movmemdi_postreload"
3891   [(set (mem:BLK (match_operand:DI 0 "register_operand" "+r,r"))
3892         (mem:BLK (match_operand:DI 1 "register_operand" "+r,r")))
3893    (clobber (match_operand:DI 2 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3894    (clobber (match_operand:DI 3 "register_operand" "=&r,&r"))   ;item tmp1
3895    (clobber (match_operand:DI 6 "register_operand" "=&r,&r"))   ;item tmp2
3896    (clobber (match_dup 0))
3897    (clobber (match_dup 1))
3898    (use (match_operand:DI 4 "arith_operand" "J,2"))      ;byte count
3899    (use (match_operand:DI 5 "const_int_operand" "n,n"))  ;alignment
3900    (const_int 0)]
3901   "TARGET_64BIT && reload_completed"
3902   "* return output_block_move (operands, !which_alternative);"
3903   [(set_attr "type" "multi,multi")])
3904
3905 (define_expand "setmemsi"
3906   [(parallel [(set (match_operand:BLK 0 "" "")
3907                    (match_operand 2 "const_int_operand" ""))
3908               (clobber (match_dup 4))
3909               (clobber (match_dup 5))
3910               (use (match_operand:SI 1 "arith_operand" ""))
3911               (use (match_operand:SI 3 "const_int_operand" ""))])]
3912   "!TARGET_64BIT && optimize > 0"
3913   "
3914 {
3915   int size, align;
3916
3917   /* If value to set is not zero, use the library routine.  */
3918   if (operands[2] != const0_rtx)
3919     FAIL;
3920
3921   /* Undetermined size, use the library routine.  */
3922   if (GET_CODE (operands[1]) != CONST_INT)
3923     FAIL;
3924
3925   size = INTVAL (operands[1]);
3926   align = INTVAL (operands[3]);
3927   align = align > 4 ? 4 : align;
3928
3929   /* If size/alignment is large, then use the library routines.  */
3930   if (size / align > 16)
3931     FAIL;
3932
3933   /* This does happen, but not often enough to worry much about.  */
3934   if (size / align < MOVE_RATIO)
3935     FAIL;
3936   
3937   /* Fall through means we're going to use our block clear pattern.  */
3938   operands[0]
3939     = replace_equiv_address (operands[0],
3940                              copy_to_mode_reg (SImode, XEXP (operands[0], 0)));
3941   operands[4] = gen_reg_rtx (SImode);
3942   operands[5] = gen_reg_rtx (SImode);
3943 }")
3944
3945 (define_insn "clrmemsi_prereload"
3946   [(set (mem:BLK (match_operand:SI 0 "register_operand" "r,r"))
3947         (const_int 0))
3948    (clobber (match_operand:SI 1 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3949    (clobber (match_operand:SI 4 "register_operand" "=&r,&r"))   ;tmp1
3950    (use (match_operand:SI 2 "arith_operand" "J,1"))      ;byte count
3951    (use (match_operand:SI 3 "const_int_operand" "n,n"))] ;alignment
3952   "!TARGET_64BIT"
3953   "#"
3954   [(set_attr "type" "multi,multi")])
3955
3956 (define_split
3957   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3958                    (const_int 0))
3959               (clobber (match_operand:SI 1 "register_operand" ""))
3960               (clobber (match_operand:SI 4 "register_operand" ""))
3961               (use (match_operand:SI 2 "arith_operand" ""))
3962               (use (match_operand:SI 3 "const_int_operand" ""))])]
3963   "!TARGET_64BIT && reload_completed && !flag_peephole2
3964    && GET_CODE (operands[0]) == MEM
3965    && register_operand (XEXP (operands[0], 0), SImode)"
3966   [(set (match_dup 4) (match_dup 5))
3967    (parallel [(set (match_dup 0) (const_int 0))
3968               (clobber (match_dup 1))
3969               (clobber (match_dup 4))
3970               (use (match_dup 2))
3971               (use (match_dup 3))
3972               (const_int 0)])]
3973   "
3974 {
3975   operands[5] = XEXP (operands[0], 0);
3976   operands[0] = replace_equiv_address (operands[0], operands[4]);
3977 }")
3978
3979 (define_peephole2
3980   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3981                    (const_int 0))
3982               (clobber (match_operand:SI 1 "register_operand" ""))
3983               (clobber (match_operand:SI 4 "register_operand" ""))
3984               (use (match_operand:SI 2 "arith_operand" ""))
3985               (use (match_operand:SI 3 "const_int_operand" ""))])]
3986   "!TARGET_64BIT
3987    && GET_CODE (operands[0]) == MEM
3988    && register_operand (XEXP (operands[0], 0), SImode)"
3989   [(parallel [(set (match_dup 0) (const_int 0))
3990               (clobber (match_dup 1))
3991               (clobber (match_dup 4))
3992               (use (match_dup 2))
3993               (use (match_dup 3))
3994               (const_int 0)])]
3995   "
3996 {
3997   rtx addr = XEXP (operands[0], 0);
3998   if (dead_or_set_p (curr_insn, addr))
3999     operands[4] = addr;
4000   else
4001     {
4002       emit_insn (gen_rtx_SET (VOIDmode, operands[4], addr));
4003       operands[0] = replace_equiv_address (operands[0], operands[4]);
4004     }
4005 }")
4006
4007 (define_insn "clrmemsi_postreload"
4008   [(set (mem:BLK (match_operand:SI 0 "register_operand" "+r,r"))
4009         (const_int 0))
4010    (clobber (match_operand:SI 1 "register_operand" "=&r,&r"))   ;loop cnt/tmp
4011    (clobber (match_dup 0))
4012    (use (match_operand:SI 2 "arith_operand" "J,1"))      ;byte count
4013    (use (match_operand:SI 3 "const_int_operand" "n,n"))  ;alignment
4014    (const_int 0)]
4015   "!TARGET_64BIT && reload_completed"
4016   "* return output_block_clear (operands, !which_alternative);"
4017   [(set_attr "type" "multi,multi")])
4018
4019 (define_expand "setmemdi"
4020   [(parallel [(set (match_operand:BLK 0 "" "")
4021                    (match_operand 2 "const_int_operand" ""))
4022               (clobber (match_dup 4))
4023               (clobber (match_dup 5))
4024               (use (match_operand:DI 1 "arith_operand" ""))
4025               (use (match_operand:DI 3 "const_int_operand" ""))])]
4026   "TARGET_64BIT && optimize > 0"
4027   "
4028 {
4029   int size, align;
4030
4031   /* If value to set is not zero, use the library routine.  */
4032   if (operands[2] != const0_rtx)
4033     FAIL;
4034
4035   /* Undetermined size, use the library routine.  */
4036   if (GET_CODE (operands[1]) != CONST_INT)
4037     FAIL;
4038
4039   size = INTVAL (operands[1]);
4040   align = INTVAL (operands[3]);
4041   align = align > 8 ? 8 : align;
4042
4043   /* If size/alignment is large, then use the library routines.  */
4044   if (size / align > 16)
4045     FAIL;
4046
4047   /* This does happen, but not often enough to worry much about.  */
4048   if (size / align < MOVE_RATIO)
4049     FAIL;
4050   
4051   /* Fall through means we're going to use our block clear pattern.  */
4052   operands[0]
4053     = replace_equiv_address (operands[0],
4054                              copy_to_mode_reg (DImode, XEXP (operands[0], 0)));
4055   operands[4] = gen_reg_rtx (DImode);
4056   operands[5] = gen_reg_rtx (DImode);
4057 }")
4058
4059 (define_insn "clrmemdi_prereload"
4060   [(set (mem:BLK (match_operand:DI 0 "register_operand" "r,r"))
4061         (const_int 0))
4062    (clobber (match_operand:DI 1 "register_operand" "=&r,&r"))   ;loop cnt/tmp
4063    (clobber (match_operand:DI 4 "register_operand" "=&r,&r"))   ;item tmp1
4064    (use (match_operand:DI 2 "arith_operand" "J,1"))      ;byte count
4065    (use (match_operand:DI 3 "const_int_operand" "n,n"))] ;alignment
4066   "TARGET_64BIT"
4067   "#"
4068   [(set_attr "type" "multi,multi")])
4069
4070 (define_split
4071   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
4072                    (const_int 0))
4073               (clobber (match_operand:DI 1 "register_operand" ""))
4074               (clobber (match_operand:DI 4 "register_operand" ""))
4075               (use (match_operand:DI 2 "arith_operand" ""))
4076               (use (match_operand:DI 3 "const_int_operand" ""))])]
4077   "TARGET_64BIT && reload_completed && !flag_peephole2
4078    && GET_CODE (operands[0]) == MEM
4079    && register_operand (XEXP (operands[0], 0), DImode)"
4080   [(set (match_dup 4) (match_dup 5))
4081    (parallel [(set (match_dup 0) (const_int 0))
4082               (clobber (match_dup 1))
4083               (clobber (match_dup 4))
4084               (use (match_dup 2))
4085               (use (match_dup 3))
4086               (const_int 0)])]
4087   "
4088 {
4089   operands[5] = XEXP (operands[0], 0);
4090   operands[0] = replace_equiv_address (operands[0], operands[4]);
4091 }")
4092
4093 (define_peephole2
4094   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
4095                    (const_int 0))
4096               (clobber (match_operand:DI 1 "register_operand" ""))
4097               (clobber (match_operand:DI 4 "register_operand" ""))
4098               (use (match_operand:DI 2 "arith_operand" ""))
4099               (use (match_operand:DI 3 "const_int_operand" ""))])]
4100   "TARGET_64BIT
4101    && GET_CODE (operands[0]) == MEM
4102    && register_operand (XEXP (operands[0], 0), DImode)"
4103   [(parallel [(set (match_dup 0) (const_int 0))
4104               (clobber (match_dup 1))
4105               (clobber (match_dup 4))
4106               (use (match_dup 2))
4107               (use (match_dup 3))
4108               (const_int 0)])]
4109   "
4110 {  
4111   rtx addr = XEXP (operands[0], 0);
4112   if (dead_or_set_p (curr_insn, addr))
4113     operands[4] = addr;
4114   else
4115     {
4116       emit_insn (gen_rtx_SET (VOIDmode, operands[4], addr));
4117       operands[0] = replace_equiv_address (operands[0], operands[4]);
4118     }
4119 }")
4120
4121 (define_insn "clrmemdi_postreload"
4122   [(set (mem:BLK (match_operand:DI 0 "register_operand" "+r,r"))
4123         (const_int 0))
4124    (clobber (match_operand:DI 1 "register_operand" "=&r,&r"))   ;loop cnt/tmp
4125    (clobber (match_dup 0))
4126    (use (match_operand:DI 2 "arith_operand" "J,1"))      ;byte count
4127    (use (match_operand:DI 3 "const_int_operand" "n,n"))  ;alignment
4128    (const_int 0)]
4129   "TARGET_64BIT && reload_completed"
4130   "* return output_block_clear (operands, !which_alternative);"
4131   [(set_attr "type" "multi,multi")])
4132 \f
4133 ;; Floating point move insns
4134
4135 ;; This pattern forces (set (reg:DF ...) (const_double ...))
4136 ;; to be reloaded by putting the constant into memory when
4137 ;; reg is a floating point register.
4138 ;;
4139 ;; For integer registers we use ldil;ldo to set the appropriate
4140 ;; value.
4141 ;;
4142 ;; This must come before the movdf pattern, and it must be present
4143 ;; to handle obscure reloading cases.
4144 (define_insn ""
4145   [(set (match_operand:DF 0 "register_operand" "=?r,f")
4146         (match_operand:DF 1 "" "?F,m"))]
4147   "GET_CODE (operands[1]) == CONST_DOUBLE
4148    && operands[1] != CONST0_RTX (DFmode)
4149    && !TARGET_64BIT
4150    && !TARGET_SOFT_FLOAT"
4151   "* return (which_alternative == 0 ? output_move_double (operands)
4152                                     : \"fldd%F1 %1,%0\");"
4153   [(set_attr "type" "move,fpload")
4154    (set_attr "length" "16,4")])
4155
4156 (define_expand "movdf"
4157   [(set (match_operand:DF 0 "general_operand" "")
4158         (match_operand:DF 1 "general_operand" ""))]
4159   ""
4160   "
4161 {
4162   if (GET_CODE (operands[1]) == CONST_DOUBLE
4163       && operands[1] != CONST0_RTX (DFmode))
4164     {
4165       /* Reject CONST_DOUBLE loads to all hard registers when
4166          generating 64-bit code and to floating point registers
4167          when generating 32-bit code.  */
4168       if (REG_P (operands[0])
4169           && HARD_REGISTER_P (operands[0])
4170           && (TARGET_64BIT || REGNO (operands[0]) >= 32))
4171         FAIL;
4172
4173       if (TARGET_64BIT)
4174         operands[1] = force_const_mem (DFmode, operands[1]);
4175     }
4176
4177   if (emit_move_sequence (operands, DFmode, 0))
4178     DONE;
4179 }")
4180
4181 ;; Handle DFmode input reloads requiring a general register as a
4182 ;; scratch register.
4183 (define_expand "reload_indf"
4184   [(set (match_operand:DF 0 "register_operand" "=Z")
4185         (match_operand:DF 1 "non_hard_reg_operand" ""))
4186    (clobber (match_operand:DF 2 "register_operand" "=&r"))]
4187   ""
4188   "
4189 {
4190   if (emit_move_sequence (operands, DFmode, operands[2]))
4191     DONE;
4192
4193   /* We don't want the clobber emitted, so handle this ourselves.  */
4194   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
4195   DONE;
4196 }")
4197
4198 ;; Handle DFmode output reloads requiring a general register as a
4199 ;; scratch register.
4200 (define_expand "reload_outdf" 
4201  [(set (match_operand:DF 0 "non_hard_reg_operand" "")
4202         (match_operand:DF 1  "register_operand" "Z"))
4203    (clobber (match_operand:DF 2 "register_operand" "=&r"))]
4204   ""
4205   "
4206 {
4207   if (emit_move_sequence (operands, DFmode, operands[2]))
4208     DONE;
4209
4210   /* We don't want the clobber emitted, so handle this ourselves.  */
4211   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
4212   DONE;
4213 }")
4214
4215 (define_insn ""
4216   [(set (match_operand:DF 0 "move_dest_operand"
4217                           "=f,*r,Q,?o,?Q,f,*r,*r,?*r,?f")
4218         (match_operand:DF 1 "reg_or_0_or_nonsymb_mem_operand"
4219                           "fG,*rG,f,*r,*r,RQ,o,RQ,f,*r"))]
4220   "(register_operand (operands[0], DFmode)
4221     || reg_or_0_operand (operands[1], DFmode))
4222    && !(GET_CODE (operands[1]) == CONST_DOUBLE
4223         && GET_CODE (operands[0]) == MEM)
4224    && !TARGET_64BIT
4225    && !TARGET_SOFT_FLOAT"
4226   "*
4227 {
4228   if ((FP_REG_P (operands[0]) || FP_REG_P (operands[1])
4229        || operands[1] == CONST0_RTX (DFmode))
4230       && !(REG_P (operands[0]) && REG_P (operands[1])
4231            && FP_REG_P (operands[0]) ^ FP_REG_P (operands[1])))
4232     return output_fp_move_double (operands);
4233   return output_move_double (operands);
4234 }"
4235   [(set_attr "type" "fpalu,move,fpstore,store,store,fpload,load,load,fpstore_load,store_fpload")
4236    (set_attr "length" "4,8,4,8,16,4,8,16,12,12")])
4237
4238 (define_insn ""
4239   [(set (match_operand:DF 0 "indexed_memory_operand" "=R")
4240         (match_operand:DF 1 "reg_or_0_operand" "f"))]
4241   "!TARGET_SOFT_FLOAT
4242    && !TARGET_DISABLE_INDEXING
4243    && reload_completed"
4244   "fstd%F0 %1,%0"
4245   [(set_attr "type" "fpstore")
4246    (set_attr "pa_combine_type" "addmove")
4247    (set_attr "length" "4")])
4248
4249 (define_peephole2
4250   [(set (match_operand:SI 0 "register_operand" "")
4251         (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "")
4252                           (const_int 8))
4253                  (match_operand:SI 2 "register_operand" "")))
4254    (set (mem:DF (match_dup 0))
4255         (match_operand:DF 3 "register_operand" ""))]
4256   "!TARGET_SOFT_FLOAT
4257    && !TARGET_DISABLE_INDEXING
4258    && REG_OK_FOR_BASE_P (operands[2])
4259    && FP_REGNO_P (REGNO (operands[3]))"
4260   [(set (mem:DF (plus:SI (mult:SI (match_dup 1) (const_int 8)) (match_dup 2)))
4261         (match_dup 3))
4262    (set (match_dup 0) (plus:SI (mult:SI (match_dup 1) (const_int 8))
4263                                (match_dup 2)))]
4264   "")
4265
4266 (define_peephole2
4267   [(set (match_operand:SI 0 "register_operand" "")
4268         (plus:SI (match_operand:SI 2 "register_operand" "")
4269                  (mult:SI (match_operand:SI 1 "register_operand" "")
4270                           (const_int 8))))
4271    (set (mem:DF (match_dup 0))
4272         (match_operand:DF 3 "register_operand" ""))]
4273   "!TARGET_SOFT_FLOAT
4274    && !TARGET_DISABLE_INDEXING
4275    && REG_OK_FOR_BASE_P (operands[2])
4276    && FP_REGNO_P (REGNO (operands[3]))"
4277   [(set (mem:DF (plus:SI (mult:SI (match_dup 1) (const_int 8)) (match_dup 2)))
4278         (match_dup 3))
4279    (set (match_dup 0) (plus:SI (mult:SI (match_dup 1) (const_int 8))
4280                                (match_dup 2)))]
4281   "")
4282
4283 (define_peephole2
4284   [(set (match_operand:DI 0 "register_operand" "")
4285         (plus:DI (mult:DI (match_operand:DI 1 "register_operand" "")
4286                           (const_int 8))
4287                  (match_operand:DI 2 "register_operand" "")))
4288    (set (mem:DF (match_dup 0))
4289         (match_operand:DF 3 "register_operand" ""))]
4290   "!TARGET_SOFT_FLOAT
4291    && !TARGET_DISABLE_INDEXING
4292    && TARGET_64BIT
4293    && REG_OK_FOR_BASE_P (operands[2])
4294    && FP_REGNO_P (REGNO (operands[3]))"
4295   [(set (mem:DF (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
4296         (match_dup 3))
4297    (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 8))
4298                                (match_dup 2)))]
4299   "")
4300
4301 (define_peephole2
4302   [(set (match_operand:DI 0 "register_operand" "")
4303         (plus:DI (match_operand:DI 2 "register_operand" "")
4304                  (mult:DI (match_operand:DI 1 "register_operand" "")
4305                           (const_int 8))))
4306    (set (mem:DF (match_dup 0))
4307         (match_operand:DF 3 "register_operand" ""))]
4308   "!TARGET_SOFT_FLOAT
4309    && !TARGET_DISABLE_INDEXING
4310    && TARGET_64BIT
4311    && REG_OK_FOR_BASE_P (operands[2])
4312    && FP_REGNO_P (REGNO (operands[3]))"
4313   [(set (mem:DF (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
4314         (match_dup 3))
4315    (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 8))
4316                                (match_dup 2)))]
4317   "")
4318
4319 (define_peephole2
4320   [(set (match_operand:SI 0 "register_operand" "")
4321         (plus:SI (match_operand:SI 1 "register_operand" "")
4322                  (match_operand:SI 2 "register_operand" "")))
4323    (set (mem:DF (match_dup 0))
4324         (match_operand:DF 3 "register_operand" ""))]
4325   "!TARGET_SOFT_FLOAT
4326    && !TARGET_DISABLE_INDEXING
4327    && TARGET_NO_SPACE_REGS
4328    && REG_OK_FOR_INDEX_P (operands[1])
4329    && REG_OK_FOR_BASE_P (operands[2])
4330    && FP_REGNO_P (REGNO (operands[3]))"
4331   [(set (mem:DF (plus:SI (match_dup 1) (match_dup 2)))
4332         (match_dup 3))
4333    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
4334   "")
4335
4336 (define_peephole2
4337   [(set (match_operand:SI 0 "register_operand" "")
4338         (plus:SI (match_operand:SI 1 "register_operand" "")
4339                  (match_operand:SI 2 "register_operand" "")))
4340    (set (mem:DF (match_dup 0))
4341         (match_operand:DF 3 "register_operand" ""))]
4342   "!TARGET_SOFT_FLOAT
4343    && !TARGET_DISABLE_INDEXING
4344    && TARGET_NO_SPACE_REGS
4345    && REG_OK_FOR_BASE_P (operands[1])
4346    && REG_OK_FOR_INDEX_P (operands[2])
4347    && FP_REGNO_P (REGNO (operands[3]))"
4348   [(set (mem:DF (plus:SI (match_dup 2) (match_dup 1)))
4349         (match_dup 3))
4350    (set (match_dup 0) (plus:SI (match_dup 2) (match_dup 1)))]
4351   "")
4352
4353 (define_peephole2
4354   [(set (match_operand:DI 0 "register_operand" "")
4355         (plus:DI (match_operand:DI 1 "register_operand" "")
4356                  (match_operand:DI 2 "register_operand" "")))
4357    (set (mem:DF (match_dup 0))
4358         (match_operand:DF 3 "register_operand" ""))]
4359   "!TARGET_SOFT_FLOAT
4360    && !TARGET_DISABLE_INDEXING
4361    && TARGET_64BIT
4362    && TARGET_NO_SPACE_REGS
4363    && REG_OK_FOR_INDEX_P (operands[1])
4364    && REG_OK_FOR_BASE_P (operands[2])
4365    && FP_REGNO_P (REGNO (operands[3]))"
4366   [(set (mem:DF (plus:DI (match_dup 1) (match_dup 2)))
4367         (match_dup 3))
4368    (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
4369   "")
4370
4371 (define_peephole2
4372   [(set (match_operand:DI 0 "register_operand" "")
4373         (plus:DI (match_operand:DI 1 "register_operand" "")
4374                  (match_operand:DI 2 "register_operand" "")))
4375    (set (mem:DF (match_dup 0))
4376         (match_operand:DF 3 "register_operand" ""))]
4377   "!TARGET_SOFT_FLOAT
4378    && !TARGET_DISABLE_INDEXING
4379    && TARGET_64BIT
4380    && TARGET_NO_SPACE_REGS
4381    && REG_OK_FOR_BASE_P (operands[1])
4382    && REG_OK_FOR_INDEX_P (operands[2])
4383    && FP_REGNO_P (REGNO (operands[3]))"
4384   [(set (mem:DF (plus:DI (match_dup 2) (match_dup 1)))
4385         (match_dup 3))
4386    (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
4387   "")
4388
4389 (define_insn ""
4390   [(set (match_operand:DF 0 "move_dest_operand"
4391                           "=r,?o,?Q,r,r")
4392         (match_operand:DF 1 "reg_or_0_or_nonsymb_mem_operand"
4393                           "rG,r,r,o,RQ"))]
4394   "(register_operand (operands[0], DFmode)
4395     || reg_or_0_operand (operands[1], DFmode))
4396    && !TARGET_64BIT
4397    && TARGET_SOFT_FLOAT"
4398   "*
4399 {
4400   return output_move_double (operands);
4401 }"
4402   [(set_attr "type" "move,store,store,load,load")
4403    (set_attr "length" "8,8,16,8,16")])
4404
4405 (define_insn ""
4406   [(set (match_operand:DF 0 "move_dest_operand"
4407                           "=!*r,*r,*r,*r,*r,Q,f,f,T")
4408         (match_operand:DF 1 "move_src_operand"
4409                           "!*r,J,N,K,RQ,*rG,fG,RT,f"))]
4410   "(register_operand (operands[0], DFmode)
4411     || reg_or_0_operand (operands[1], DFmode))
4412    && !TARGET_SOFT_FLOAT && TARGET_64BIT"
4413   "@
4414    copy %1,%0
4415    ldi %1,%0
4416    ldil L'%1,%0
4417    depdi,z %z1,%0
4418    ldd%M1 %1,%0
4419    std%M0 %r1,%0
4420    fcpy,dbl %f1,%0
4421    fldd%F1 %1,%0
4422    fstd%F0 %1,%0"
4423   [(set_attr "type" "move,move,move,shift,load,store,fpalu,fpload,fpstore")
4424    (set_attr "pa_combine_type" "addmove")
4425    (set_attr "length" "4,4,4,4,4,4,4,4,4")])
4426
4427 \f
4428 (define_expand "movdi"
4429   [(set (match_operand:DI 0 "general_operand" "")
4430         (match_operand:DI 1 "general_operand" ""))]
4431   ""
4432   "
4433 {
4434   /* Except for zero, we don't support loading a CONST_INT directly
4435      to a hard floating-point register since a scratch register is
4436      needed for the operation.  While the operation could be handled
4437      before no_new_pseudos is true, the simplest solution is to fail.  */
4438   if (TARGET_64BIT
4439       && GET_CODE (operands[1]) == CONST_INT
4440       && operands[1] != CONST0_RTX (DImode)
4441       && REG_P (operands[0])
4442       && HARD_REGISTER_P (operands[0])
4443       && REGNO (operands[0]) >= 32)
4444     FAIL;
4445
4446   if (emit_move_sequence (operands, DImode, 0))
4447     DONE;
4448 }")
4449
4450 ;; Handle DImode input reloads requiring %r1 as a scratch register.
4451 (define_expand "reload_indi_r1"
4452   [(set (match_operand:DI 0 "register_operand" "=Z")
4453         (match_operand:DI 1 "non_hard_reg_operand" ""))
4454    (clobber (match_operand:SI 2 "register_operand" "=&a"))]
4455   ""
4456   "
4457 {
4458   if (emit_move_sequence (operands, DImode, operands[2]))
4459     DONE;
4460
4461   /* We don't want the clobber emitted, so handle this ourselves.  */
4462   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
4463   DONE;
4464 }")
4465
4466 ;; Handle DImode input reloads requiring a general register as a
4467 ;; scratch register.
4468 (define_expand "reload_indi"
4469   [(set (match_operand:DI 0 "register_operand" "=Z")
4470         (match_operand:DI 1 "non_hard_reg_operand" ""))
4471    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
4472   ""
4473   "
4474 {
4475   if (emit_move_sequence (operands, DImode, operands[2]))
4476     DONE;
4477
4478   /* We don't want the clobber emitted, so handle this ourselves.  */
4479   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
4480   DONE;
4481 }")
4482
4483 ;; Handle DImode output reloads requiring a general register as a
4484 ;; scratch register.
4485 (define_expand "reload_outdi"
4486   [(set (match_operand:DI 0 "non_hard_reg_operand" "")
4487         (match_operand:DI 1 "register_operand" "Z"))
4488    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
4489   ""
4490   "
4491 {
4492   if (emit_move_sequence (operands, DImode, operands[2]))
4493     DONE;
4494
4495   /* We don't want the clobber emitted, so handle this ourselves.  */
4496   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
4497   DONE;
4498 }")
4499
4500 (define_insn ""
4501   [(set (match_operand:DI 0 "register_operand" "=r")
4502         (high:DI (match_operand 1 "" "")))]
4503   "!TARGET_64BIT"
4504   "*
4505 {
4506   rtx op0 = operands[0];
4507   rtx op1 = operands[1];
4508
4509   switch (GET_CODE (op1))
4510     {
4511     case CONST_INT:
4512 #if HOST_BITS_PER_WIDE_INT <= 32
4513       operands[0] = operand_subword (op0, 1, 0, DImode);
4514       output_asm_insn (\"ldil L'%1,%0\", operands);
4515
4516       operands[0] = operand_subword (op0, 0, 0, DImode);
4517       if (INTVAL (op1) < 0)
4518         output_asm_insn (\"ldi -1,%0\", operands);
4519       else
4520         output_asm_insn (\"ldi 0,%0\", operands);
4521 #else
4522       operands[0] = operand_subword (op0, 1, 0, DImode);
4523       operands[1] = GEN_INT (INTVAL (op1) & 0xffffffff);
4524       output_asm_insn (\"ldil L'%1,%0\", operands);
4525
4526       operands[0] = operand_subword (op0, 0, 0, DImode);
4527       operands[1] = GEN_INT (INTVAL (op1) >> 32);
4528       output_asm_insn (singlemove_string (operands), operands);
4529 #endif
4530       break;
4531
4532     case CONST_DOUBLE:
4533       operands[0] = operand_subword (op0, 1, 0, DImode);
4534       operands[1] = GEN_INT (CONST_DOUBLE_LOW (op1));
4535       output_asm_insn (\"ldil L'%1,%0\", operands);
4536
4537       operands[0] = operand_subword (op0, 0, 0, DImode);
4538       operands[1] = GEN_INT (CONST_DOUBLE_HIGH (op1));
4539       output_asm_insn (singlemove_string (operands), operands);
4540       break;
4541
4542     default:
4543       gcc_unreachable ();
4544     }
4545   return \"\";
4546 }"
4547   [(set_attr "type" "move")
4548    (set_attr "length" "12")])
4549
4550 (define_insn ""
4551   [(set (match_operand:DI 0 "move_dest_operand"
4552                           "=r,o,Q,r,r,r,*f,*f,T,?r,?*f")
4553         (match_operand:DI 1 "general_operand"
4554                           "rM,r,r,o*R,Q,i,*fM,RT,*f,*f,r"))]
4555   "(register_operand (operands[0], DImode)
4556     || reg_or_0_operand (operands[1], DImode))
4557    && !TARGET_64BIT
4558    && !TARGET_SOFT_FLOAT"
4559   "*
4560 {
4561   if ((FP_REG_P (operands[0]) || FP_REG_P (operands[1])
4562        || operands[1] == CONST0_RTX (DFmode))
4563       && !(REG_P (operands[0]) && REG_P (operands[1])
4564            && FP_REG_P (operands[0]) ^ FP_REG_P (operands[1])))
4565     return output_fp_move_double (operands);
4566   return output_move_double (operands);
4567 }"
4568   [(set_attr "type"
4569     "move,store,store,load,load,multi,fpalu,fpload,fpstore,fpstore_load,store_fpload")
4570    (set_attr "length" "8,8,16,8,16,16,4,4,4,12,12")])
4571
4572 (define_insn ""
4573   [(set (match_operand:DI 0 "move_dest_operand"
4574                           "=r,r,r,r,r,r,Q,!*q,!r,!*f,*f,T")
4575         (match_operand:DI 1 "move_src_operand"
4576                           "A,r,J,N,K,RQ,rM,!rM,!*q,!*fM,RT,*f"))]
4577   "(register_operand (operands[0], DImode)
4578     || reg_or_0_operand (operands[1], DImode))
4579    && !TARGET_SOFT_FLOAT && TARGET_64BIT"
4580   "@
4581    ldd RT'%A1,%0
4582    copy %1,%0
4583    ldi %1,%0
4584    ldil L'%1,%0
4585    depdi,z %z1,%0
4586    ldd%M1 %1,%0
4587    std%M0 %r1,%0
4588    mtsar %r1
4589    {mfctl|mfctl,w} %%sar,%0
4590    fcpy,dbl %f1,%0
4591    fldd%F1 %1,%0
4592    fstd%F0 %1,%0"
4593   [(set_attr "type" "load,move,move,move,shift,load,store,move,move,fpalu,fpload,fpstore")
4594    (set_attr "pa_combine_type" "addmove")
4595    (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4")])
4596
4597 (define_insn ""
4598   [(set (match_operand:DI 0 "indexed_memory_operand" "=R")
4599         (match_operand:DI 1 "register_operand" "f"))]
4600   "!TARGET_SOFT_FLOAT
4601    && TARGET_64BIT
4602    && !TARGET_DISABLE_INDEXING
4603    && reload_completed"
4604   "fstd%F0 %1,%0"
4605   [(set_attr "type" "fpstore")
4606    (set_attr "pa_combine_type" "addmove")
4607    (set_attr "length" "4")])
4608
4609 (define_peephole2
4610   [(set (match_operand:DI 0 "register_operand" "")
4611         (plus:DI (mult:DI (match_operand:DI 1 "register_operand" "")
4612                           (const_int 8))
4613                  (match_operand:DI 2 "register_operand" "")))
4614    (set (mem:DI (match_dup 0))
4615         (match_operand:DI 3 "register_operand" ""))]
4616   "!TARGET_SOFT_FLOAT
4617    && !TARGET_DISABLE_INDEXING
4618    && TARGET_64BIT
4619    && REG_OK_FOR_BASE_P (operands[2])
4620    && FP_REGNO_P (REGNO (operands[3]))"
4621   [(set (mem:DI (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
4622         (match_dup 3))
4623    (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 8))
4624                                (match_dup 2)))]
4625   "")
4626
4627 (define_peephole2
4628   [(set (match_operand:DI 0 "register_operand" "")
4629         (plus:DI (match_operand:DI 2 "register_operand" "")
4630                  (mult:DI (match_operand:DI 1 "register_operand" "")
4631                           (const_int 8))))
4632    (set (mem:DI (match_dup 0))
4633         (match_operand:DI 3 "register_operand" ""))]
4634   "!TARGET_SOFT_FLOAT
4635    && !TARGET_DISABLE_INDEXING
4636    && TARGET_64BIT
4637    && REG_OK_FOR_BASE_P (operands[2])
4638    && FP_REGNO_P (REGNO (operands[3]))"
4639   [(set (mem:DI (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
4640         (match_dup 3))
4641    (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 8))
4642                                (match_dup 2)))]
4643   "")
4644
4645 (define_peephole2
4646   [(set (match_operand:DI 0 "register_operand" "")
4647         (plus:DI (match_operand:DI 1 "register_operand" "")
4648                  (match_operand:DI 2 "register_operand" "")))
4649    (set (mem:DI (match_dup 0))
4650         (match_operand:DI 3 "register_operand" ""))]
4651   "!TARGET_SOFT_FLOAT
4652    && !TARGET_DISABLE_INDEXING
4653    && TARGET_64BIT
4654    && TARGET_NO_SPACE_REGS
4655    && REG_OK_FOR_INDEX_P (operands[1])
4656    && REG_OK_FOR_BASE_P (operands[2])
4657    && FP_REGNO_P (REGNO (operands[3]))"
4658   [(set (mem:DI (plus:DI (match_dup 1) (match_dup 2)))
4659         (match_dup 3))
4660    (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
4661   "")
4662
4663 (define_peephole2
4664   [(set (match_operand:DI 0 "register_operand" "")
4665         (plus:DI (match_operand:DI 1 "register_operand" "")
4666                  (match_operand:DI 2 "register_operand" "")))
4667    (set (mem:DI (match_dup 0))
4668         (match_operand:DI 3 "register_operand" ""))]
4669   "!TARGET_SOFT_FLOAT
4670    && !TARGET_DISABLE_INDEXING
4671    && TARGET_64BIT
4672    && TARGET_NO_SPACE_REGS
4673    && REG_OK_FOR_BASE_P (operands[1])
4674    && REG_OK_FOR_INDEX_P (operands[2])
4675    && FP_REGNO_P (REGNO (operands[3]))"
4676   [(set (mem:DI (plus:DI (match_dup 2) (match_dup 1)))
4677         (match_dup 3))
4678    (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
4679   "")
4680
4681 (define_insn ""
4682   [(set (match_operand:DI 0 "move_dest_operand"
4683                           "=r,o,Q,r,r,r")
4684         (match_operand:DI 1 "general_operand"
4685                           "rM,r,r,o,Q,i"))]
4686   "(register_operand (operands[0], DImode)
4687     || reg_or_0_operand (operands[1], DImode))
4688    && !TARGET_64BIT
4689    && TARGET_SOFT_FLOAT"
4690   "*
4691 {
4692   return output_move_double (operands);
4693 }"
4694   [(set_attr "type" "move,store,store,load,load,multi")
4695    (set_attr "length" "8,8,16,8,16,16")])
4696
4697 (define_insn ""
4698   [(set (match_operand:DI 0 "register_operand" "=r,&r")
4699         (lo_sum:DI (match_operand:DI 1 "register_operand" "0,r")
4700                    (match_operand:DI 2 "immediate_operand" "i,i")))]
4701   "!TARGET_64BIT"
4702   "*
4703 {
4704   /* Don't output a 64-bit constant, since we can't trust the assembler to
4705      handle it correctly.  */
4706   if (GET_CODE (operands[2]) == CONST_DOUBLE)
4707     operands[2] = GEN_INT (CONST_DOUBLE_LOW (operands[2]));
4708   else if (HOST_BITS_PER_WIDE_INT > 32
4709            && GET_CODE (operands[2]) == CONST_INT)
4710     operands[2] = GEN_INT (INTVAL (operands[2]) & 0xffffffff);
4711   if (which_alternative == 1)
4712     output_asm_insn (\"copy %1,%0\", operands);
4713   return \"ldo R'%G2(%R1),%R0\";
4714 }"
4715   [(set_attr "type" "move,move")
4716    (set_attr "length" "4,8")])
4717
4718 ;; This pattern forces (set (reg:SF ...) (const_double ...))
4719 ;; to be reloaded by putting the constant into memory when
4720 ;; reg is a floating point register.
4721 ;;
4722 ;; For integer registers we use ldil;ldo to set the appropriate
4723 ;; value.
4724 ;;
4725 ;; This must come before the movsf pattern, and it must be present
4726 ;; to handle obscure reloading cases.
4727 (define_insn ""
4728   [(set (match_operand:SF 0 "register_operand" "=?r,f")
4729         (match_operand:SF 1 "" "?F,m"))]
4730   "GET_CODE (operands[1]) == CONST_DOUBLE
4731    && operands[1] != CONST0_RTX (SFmode)
4732    && ! TARGET_SOFT_FLOAT"
4733   "* return (which_alternative == 0 ? singlemove_string (operands)
4734                                     : \" fldw%F1 %1,%0\");"
4735   [(set_attr "type" "move,fpload")
4736    (set_attr "length" "8,4")])
4737
4738 (define_expand "movsf"
4739   [(set (match_operand:SF 0 "general_operand" "")
4740         (match_operand:SF 1 "general_operand" ""))]
4741   ""
4742   "
4743 {
4744   /* Reject CONST_DOUBLE loads to floating point registers.  */
4745   if (GET_CODE (operands[1]) == CONST_DOUBLE
4746       && operands[1] != CONST0_RTX (SFmode)
4747       && REG_P (operands[0])
4748       && HARD_REGISTER_P (operands[0])
4749       && REGNO (operands[0]) >= 32)
4750     FAIL;
4751
4752   if (emit_move_sequence (operands, SFmode, 0))
4753     DONE;
4754 }")
4755
4756 ;; Handle SFmode input reloads requiring a general register as a
4757 ;; scratch register.
4758 (define_expand "reload_insf"
4759   [(set (match_operand:SF 0 "register_operand" "=Z")
4760         (match_operand:SF 1 "non_hard_reg_operand" ""))
4761    (clobber (match_operand:SF 2 "register_operand" "=&r"))]
4762   ""
4763   "
4764 {
4765   if (emit_move_sequence (operands, SFmode, operands[2]))
4766     DONE;
4767
4768   /* We don't want the clobber emitted, so handle this ourselves.  */
4769   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
4770   DONE;
4771 }")
4772
4773 ;; Handle SFmode output reloads requiring a general register as a
4774 ;; scratch register.
4775 (define_expand "reload_outsf"
4776   [(set (match_operand:SF 0 "non_hard_reg_operand" "")
4777         (match_operand:SF 1  "register_operand" "Z"))
4778    (clobber (match_operand:SF 2 "register_operand" "=&r"))]
4779   ""
4780   "
4781 {
4782   if (emit_move_sequence (operands, SFmode, operands[2]))
4783     DONE;
4784
4785   /* We don't want the clobber emitted, so handle this ourselves.  */
4786   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
4787   DONE;
4788 }")
4789
4790 (define_insn ""
4791   [(set (match_operand:SF 0 "move_dest_operand"
4792                           "=f,!*r,f,*r,Q,Q,?*r,?f")
4793         (match_operand:SF 1 "reg_or_0_or_nonsymb_mem_operand"
4794                           "fG,!*rG,RQ,RQ,f,*rG,f,*r"))]
4795   "(register_operand (operands[0], SFmode)
4796     || reg_or_0_operand (operands[1], SFmode))
4797    && !TARGET_SOFT_FLOAT
4798    && !TARGET_64BIT"
4799   "@
4800    fcpy,sgl %f1,%0
4801    copy %r1,%0
4802    fldw%F1 %1,%0
4803    ldw%M1 %1,%0
4804    fstw%F0 %1,%0
4805    stw%M0 %r1,%0
4806    {fstws|fstw} %1,-16(%%sp)\n\t{ldws|ldw} -16(%%sp),%0
4807    {stws|stw} %1,-16(%%sp)\n\t{fldws|fldw} -16(%%sp),%0"
4808   [(set_attr "type" "fpalu,move,fpload,load,fpstore,store,fpstore_load,store_fpload")
4809    (set_attr "pa_combine_type" "addmove")
4810    (set_attr "length" "4,4,4,4,4,4,8,8")])
4811
4812 (define_insn ""
4813   [(set (match_operand:SF 0 "move_dest_operand"
4814                           "=f,!*r,f,*r,Q,Q")
4815         (match_operand:SF 1 "reg_or_0_or_nonsymb_mem_operand"
4816                           "fG,!*rG,RQ,RQ,f,*rG"))]
4817   "(register_operand (operands[0], SFmode)
4818     || reg_or_0_operand (operands[1], SFmode))
4819    && !TARGET_SOFT_FLOAT
4820    && TARGET_64BIT"
4821   "@
4822    fcpy,sgl %f1,%0
4823    copy %r1,%0
4824    fldw%F1 %1,%0
4825    ldw%M1 %1,%0
4826    fstw%F0 %1,%0
4827    stw%M0 %r1,%0"
4828   [(set_attr "type" "fpalu,move,fpload,load,fpstore,store")
4829    (set_attr "pa_combine_type" "addmove")
4830    (set_attr "length" "4,4,4,4,4,4")])
4831
4832 (define_insn ""
4833   [(set (match_operand:SF 0 "indexed_memory_operand" "=R")
4834         (match_operand:SF 1 "register_operand" "f"))]
4835   "!TARGET_SOFT_FLOAT
4836    && !TARGET_DISABLE_INDEXING
4837    && reload_completed"
4838   "fstw%F0 %1,%0"
4839   [(set_attr "type" "fpstore")
4840    (set_attr "pa_combine_type" "addmove")
4841    (set_attr "length" "4")])
4842
4843 (define_peephole2
4844   [(set (match_operand:SI 0 "register_operand" "")
4845         (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "")
4846                           (const_int 4))
4847                  (match_operand:SI 2 "register_operand" "")))
4848    (set (mem:SF (match_dup 0))
4849         (match_operand:SF 3 "register_operand" ""))]
4850   "!TARGET_SOFT_FLOAT
4851    && !TARGET_DISABLE_INDEXING
4852    && REG_OK_FOR_BASE_P (operands[2])
4853    && FP_REGNO_P (REGNO (operands[3]))"
4854   [(set (mem:SF (plus:SI (mult:SI (match_dup 1) (const_int 4)) (match_dup 2)))
4855         (match_dup 3))
4856    (set (match_dup 0) (plus:SI (mult:SI (match_dup 1) (const_int 4))
4857                                (match_dup 2)))]
4858   "")
4859
4860 (define_peephole2
4861   [(set (match_operand:SI 0 "register_operand" "")
4862         (plus:SI (match_operand:SI 2 "register_operand" "")
4863                  (mult:SI (match_operand:SI 1 "register_operand" "")
4864                           (const_int 4))))
4865    (set (mem:SF (match_dup 0))
4866         (match_operand:SF 3 "register_operand" ""))]
4867   "!TARGET_SOFT_FLOAT
4868    && !TARGET_DISABLE_INDEXING
4869    && REG_OK_FOR_BASE_P (operands[2])
4870    && FP_REGNO_P (REGNO (operands[3]))"
4871   [(set (mem:SF (plus:SI (mult:SI (match_dup 1) (const_int 4)) (match_dup 2)))
4872         (match_dup 3))
4873    (set (match_dup 0) (plus:SI (mult:SI (match_dup 1) (const_int 4))
4874                                (match_dup 2)))]
4875   "")
4876
4877 (define_peephole2
4878   [(set (match_operand:DI 0 "register_operand" "")
4879         (plus:DI (mult:DI (match_operand:DI 1 "register_operand" "")
4880                           (const_int 4))
4881                  (match_operand:DI 2 "register_operand" "")))
4882    (set (mem:SF (match_dup 0))
4883         (match_operand:SF 3 "register_operand" ""))]
4884   "!TARGET_SOFT_FLOAT
4885    && !TARGET_DISABLE_INDEXING
4886    && TARGET_64BIT
4887    && REG_OK_FOR_BASE_P (operands[2])
4888    && FP_REGNO_P (REGNO (operands[3]))"
4889   [(set (mem:SF (plus:DI (mult:DI (match_dup 1) (const_int 4)) (match_dup 2)))
4890         (match_dup 3))
4891    (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 4))
4892                                (match_dup 2)))]
4893   "")
4894
4895 (define_peephole2
4896   [(set (match_operand:DI 0 "register_operand" "")
4897         (plus:DI (match_operand:DI 2 "register_operand" "")
4898                  (mult:DI (match_operand:DI 1 "register_operand" "")
4899                           (const_int 4))))
4900    (set (mem:SF (match_dup 0))
4901         (match_operand:SF 3 "register_operand" ""))]
4902   "!TARGET_SOFT_FLOAT
4903    && !TARGET_DISABLE_INDEXING
4904    && TARGET_64BIT
4905    && REG_OK_FOR_BASE_P (operands[2])
4906    && FP_REGNO_P (REGNO (operands[3]))"
4907   [(set (mem:SF (plus:DI (mult:DI (match_dup 1) (const_int 4)) (match_dup 2)))
4908         (match_dup 3))
4909    (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 4))
4910                                (match_dup 2)))]
4911   "")
4912
4913 (define_peephole2
4914   [(set (match_operand:SI 0 "register_operand" "")
4915         (plus:SI (match_operand:SI 1 "register_operand" "")
4916                  (match_operand:SI 2 "register_operand" "")))
4917    (set (mem:SF (match_dup 0))
4918         (match_operand:SF 3 "register_operand" ""))]
4919   "!TARGET_SOFT_FLOAT
4920    && !TARGET_DISABLE_INDEXING
4921    && TARGET_NO_SPACE_REGS
4922    && REG_OK_FOR_INDEX_P (operands[1])
4923    && REG_OK_FOR_BASE_P (operands[2])
4924    && FP_REGNO_P (REGNO (operands[3]))"
4925   [(set (mem:SF (plus:SI (match_dup 1) (match_dup 2)))
4926         (match_dup 3))
4927    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
4928   "")
4929
4930 (define_peephole2
4931   [(set (match_operand:SI 0 "register_operand" "")
4932         (plus:SI (match_operand:SI 1 "register_operand" "")
4933                  (match_operand:SI 2 "register_operand" "")))
4934    (set (mem:SF (match_dup 0))
4935         (match_operand:SF 3 "register_operand" ""))]
4936   "!TARGET_SOFT_FLOAT
4937    && !TARGET_DISABLE_INDEXING
4938    && TARGET_NO_SPACE_REGS
4939    && REG_OK_FOR_BASE_P (operands[1])
4940    && REG_OK_FOR_INDEX_P (operands[2])
4941    && FP_REGNO_P (REGNO (operands[3]))"
4942   [(set (mem:SF (plus:SI (match_dup 2) (match_dup 1)))
4943         (match_dup 3))
4944    (set (match_dup 0) (plus:SI (match_dup 2) (match_dup 1)))]
4945   "")
4946
4947 (define_peephole2
4948   [(set (match_operand:DI 0 "register_operand" "")
4949         (plus:DI (match_operand:DI 1 "register_operand" "")
4950                  (match_operand:DI 2 "register_operand" "")))
4951    (set (mem:SF (match_dup 0))
4952         (match_operand:SF 3 "register_operand" ""))]
4953   "!TARGET_SOFT_FLOAT
4954    && !TARGET_DISABLE_INDEXING
4955    && TARGET_64BIT
4956    && TARGET_NO_SPACE_REGS
4957    && REG_OK_FOR_INDEX_P (operands[1])
4958    && REG_OK_FOR_BASE_P (operands[2])
4959    && FP_REGNO_P (REGNO (operands[3]))"
4960   [(set (mem:SF (plus:DI (match_dup 1) (match_dup 2)))
4961         (match_dup 3))
4962    (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
4963   "")
4964
4965 (define_peephole2
4966   [(set (match_operand:DI 0 "register_operand" "")
4967         (plus:DI (match_operand:DI 1 "register_operand" "")
4968                  (match_operand:DI 2 "register_operand" "")))
4969    (set (mem:SF (match_dup 0))
4970         (match_operand:SF 3 "register_operand" ""))]
4971   "!TARGET_SOFT_FLOAT
4972    && !TARGET_DISABLE_INDEXING
4973    && TARGET_64BIT
4974    && TARGET_NO_SPACE_REGS
4975    && REG_OK_FOR_BASE_P (operands[1])
4976    && REG_OK_FOR_INDEX_P (operands[2])
4977    && FP_REGNO_P (REGNO (operands[3]))"
4978   [(set (mem:SF (plus:DI (match_dup 2) (match_dup 1)))
4979         (match_dup 3))
4980    (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
4981   "")
4982
4983 (define_insn ""
4984   [(set (match_operand:SF 0 "move_dest_operand"
4985                           "=r,r,Q")
4986         (match_operand:SF 1 "reg_or_0_or_nonsymb_mem_operand"
4987                           "rG,RQ,rG"))]
4988   "(register_operand (operands[0], SFmode)
4989     || reg_or_0_operand (operands[1], SFmode))
4990    && TARGET_SOFT_FLOAT"
4991   "@
4992    copy %r1,%0
4993    ldw%M1 %1,%0
4994    stw%M0 %r1,%0"
4995   [(set_attr "type" "move,load,store")
4996    (set_attr "pa_combine_type" "addmove")
4997    (set_attr "length" "4,4,4")])
4998
4999 \f
5000
5001 ;;- zero extension instructions
5002 ;; We have define_expand for zero extension patterns to make sure the
5003 ;; operands get loaded into registers.  The define_insns accept
5004 ;; memory operands.  This gives us better overall code than just
5005 ;; having a pattern that does or does not accept memory operands.
5006
5007 (define_expand "zero_extendqihi2"
5008   [(set (match_operand:HI 0 "register_operand" "")
5009         (zero_extend:HI
5010          (match_operand:QI 1 "register_operand" "")))]
5011   ""
5012   "")
5013
5014 (define_insn ""
5015   [(set (match_operand:HI 0 "register_operand" "=r,r")
5016         (zero_extend:HI
5017          (match_operand:QI 1 "move_src_operand" "r,RQ")))]
5018   "GET_CODE (operands[1]) != CONST_INT"
5019   "@
5020    {extru|extrw,u} %1,31,8,%0
5021    ldb%M1 %1,%0"
5022   [(set_attr "type" "shift,load")
5023    (set_attr "length" "4,4")])
5024
5025 (define_expand "zero_extendqisi2"
5026   [(set (match_operand:SI 0 "register_operand" "")
5027         (zero_extend:SI
5028          (match_operand:QI 1 "register_operand" "")))]
5029   ""
5030   "")
5031
5032 (define_insn ""
5033   [(set (match_operand:SI 0 "register_operand" "=r,r")
5034         (zero_extend:SI
5035          (match_operand:QI 1 "move_src_operand" "r,RQ")))]
5036   "GET_CODE (operands[1]) != CONST_INT"
5037   "@
5038    {extru|extrw,u} %1,31,8,%0
5039    ldb%M1 %1,%0"
5040   [(set_attr "type" "shift,load")
5041    (set_attr "length" "4,4")])
5042
5043 (define_expand "zero_extendhisi2"
5044   [(set (match_operand:SI 0 "register_operand" "")
5045         (zero_extend:SI
5046          (match_operand:HI 1 "register_operand" "")))]
5047   ""
5048   "")
5049
5050 (define_insn ""
5051   [(set (match_operand:SI 0 "register_operand" "=r,r")
5052         (zero_extend:SI
5053          (match_operand:HI 1 "move_src_operand" "r,RQ")))]
5054   "GET_CODE (operands[1]) != CONST_INT"
5055   "@
5056    {extru|extrw,u} %1,31,16,%0
5057    ldh%M1 %1,%0"
5058   [(set_attr "type" "shift,load")
5059    (set_attr "length" "4,4")])
5060
5061 (define_expand "zero_extendqidi2"
5062   [(set (match_operand:DI 0 "register_operand" "")
5063         (zero_extend:DI
5064          (match_operand:QI 1 "register_operand" "")))]
5065   "TARGET_64BIT"
5066   "")
5067
5068 (define_insn ""
5069   [(set (match_operand:DI 0 "register_operand" "=r,r")
5070         (zero_extend:DI
5071          (match_operand:QI 1 "move_src_operand" "r,RQ")))]
5072   "TARGET_64BIT && GET_CODE (operands[1]) != CONST_INT"
5073   "@
5074    extrd,u %1,63,8,%0
5075    ldb%M1 %1,%0"
5076   [(set_attr "type" "shift,load")
5077    (set_attr "length" "4,4")])
5078
5079 (define_expand "zero_extendhidi2"
5080   [(set (match_operand:DI 0 "register_operand" "")
5081         (zero_extend:DI
5082          (match_operand:HI 1 "register_operand" "")))]
5083   "TARGET_64BIT"
5084   "")
5085
5086 (define_insn ""
5087   [(set (match_operand:DI 0 "register_operand" "=r,r")
5088         (zero_extend:DI
5089          (match_operand:HI 1 "move_src_operand" "r,RQ")))]
5090   "TARGET_64BIT && GET_CODE (operands[1]) != CONST_INT"
5091   "@
5092    extrd,u %1,63,16,%0
5093    ldh%M1 %1,%0"
5094   [(set_attr "type" "shift,load")
5095    (set_attr "length" "4,4")])
5096
5097 (define_expand "zero_extendsidi2"
5098   [(set (match_operand:DI 0 "register_operand" "")
5099         (zero_extend:DI
5100          (match_operand:SI 1 "register_operand" "")))]
5101   "TARGET_64BIT"
5102   "")
5103
5104 (define_insn ""
5105   [(set (match_operand:DI 0 "register_operand" "=r,r")
5106         (zero_extend:DI
5107          (match_operand:SI 1 "move_src_operand" "r,RQ")))]
5108   "TARGET_64BIT && GET_CODE (operands[1]) != CONST_INT"
5109   "@
5110    extrd,u %1,63,32,%0
5111    ldw%M1 %1,%0"
5112   [(set_attr "type" "shift,load")
5113    (set_attr "length" "4,4")])
5114
5115 ;;- sign extension instructions
5116
5117 (define_insn "extendhisi2"
5118   [(set (match_operand:SI 0 "register_operand" "=r")
5119         (sign_extend:SI (match_operand:HI 1 "register_operand" "r")))]
5120   ""
5121   "{extrs|extrw,s} %1,31,16,%0"
5122   [(set_attr "type" "shift")
5123    (set_attr "length" "4")])
5124
5125 (define_insn "extendqihi2"
5126   [(set (match_operand:HI 0 "register_operand" "=r")
5127         (sign_extend:HI (match_operand:QI 1 "register_operand" "r")))]
5128   ""
5129   "{extrs|extrw,s} %1,31,8,%0"
5130   [(set_attr "type" "shift") 
5131   (set_attr "length" "4")])
5132
5133 (define_insn "extendqisi2"
5134   [(set (match_operand:SI 0 "register_operand" "=r")
5135         (sign_extend:SI (match_operand:QI 1 "register_operand" "r")))]
5136   ""
5137   "{extrs|extrw,s} %1,31,8,%0"
5138   [(set_attr "type" "shift")
5139    (set_attr "length" "4")])
5140
5141 (define_insn "extendqidi2"
5142   [(set (match_operand:DI 0 "register_operand" "=r")
5143         (sign_extend:DI (match_operand:QI 1 "register_operand" "r")))]
5144   "TARGET_64BIT"
5145   "extrd,s %1,63,8,%0"
5146   [(set_attr "type" "shift") 
5147   (set_attr "length" "4")])
5148
5149 (define_insn "extendhidi2"
5150   [(set (match_operand:DI 0 "register_operand" "=r")
5151         (sign_extend:DI (match_operand:HI 1 "register_operand" "r")))]
5152   "TARGET_64BIT"
5153   "extrd,s %1,63,16,%0"
5154   [(set_attr "type" "shift") 
5155   (set_attr "length" "4")])
5156
5157 (define_insn "extendsidi2"
5158   [(set (match_operand:DI 0 "register_operand" "=r")
5159         (sign_extend:DI (match_operand:SI 1 "register_operand" "r")))]
5160   "TARGET_64BIT"
5161   "extrd,s %1,63,32,%0"
5162   [(set_attr "type" "shift") 
5163   (set_attr "length" "4")])
5164
5165 \f
5166 ;; Conversions between float and double.
5167
5168 (define_insn "extendsfdf2"
5169   [(set (match_operand:DF 0 "register_operand" "=f")
5170         (float_extend:DF
5171          (match_operand:SF 1 "register_operand" "f")))]
5172   "! TARGET_SOFT_FLOAT"
5173   "{fcnvff|fcnv},sgl,dbl %1,%0"
5174   [(set_attr "type" "fpalu")
5175    (set_attr "length" "4")])
5176
5177 (define_insn "truncdfsf2"
5178   [(set (match_operand:SF 0 "register_operand" "=f")
5179         (float_truncate:SF
5180          (match_operand:DF 1 "register_operand" "f")))]
5181   "! TARGET_SOFT_FLOAT"
5182   "{fcnvff|fcnv},dbl,sgl %1,%0"
5183   [(set_attr "type" "fpalu")
5184    (set_attr "length" "4")])
5185
5186 ;; Conversion between fixed point and floating point.
5187 ;; Note that among the fix-to-float insns
5188 ;; the ones that start with SImode come first.
5189 ;; That is so that an operand that is a CONST_INT
5190 ;; (and therefore lacks a specific machine mode).
5191 ;; will be recognized as SImode (which is always valid)
5192 ;; rather than as QImode or HImode.
5193
5194 ;; This pattern forces (set (reg:SF ...) (float:SF (const_int ...)))
5195 ;; to be reloaded by putting the constant into memory.
5196 ;; It must come before the more general floatsisf2 pattern.
5197 (define_insn ""
5198   [(set (match_operand:SF 0 "register_operand" "=f")
5199         (float:SF (match_operand:SI 1 "const_int_operand" "m")))]
5200   "! TARGET_SOFT_FLOAT"
5201   "fldw%F1 %1,%0\;{fcnvxf,sgl,sgl|fcnv,w,sgl} %0,%0"
5202   [(set_attr "type" "fpalu")
5203    (set_attr "length" "8")])
5204
5205 (define_insn "floatsisf2"
5206   [(set (match_operand:SF 0 "register_operand" "=f")
5207         (float:SF (match_operand:SI 1 "register_operand" "f")))]
5208   "! TARGET_SOFT_FLOAT"
5209   "{fcnvxf,sgl,sgl|fcnv,w,sgl} %1,%0"
5210   [(set_attr "type" "fpalu")
5211    (set_attr "length" "4")])
5212
5213 ;; This pattern forces (set (reg:DF ...) (float:DF (const_int ...)))
5214 ;; to be reloaded by putting the constant into memory.
5215 ;; It must come before the more general floatsidf2 pattern.
5216 (define_insn ""
5217   [(set (match_operand:DF 0 "register_operand" "=f")
5218         (float:DF (match_operand:SI 1 "const_int_operand" "m")))]
5219   "! TARGET_SOFT_FLOAT"
5220   "fldw%F1 %1,%0\;{fcnvxf,sgl,dbl|fcnv,w,dbl} %0,%0"
5221   [(set_attr "type" "fpalu")
5222    (set_attr "length" "8")])
5223
5224 (define_insn "floatsidf2"
5225   [(set (match_operand:DF 0 "register_operand" "=f")
5226         (float:DF (match_operand:SI 1 "register_operand" "f")))]
5227   "! TARGET_SOFT_FLOAT"
5228   "{fcnvxf,sgl,dbl|fcnv,w,dbl} %1,%0"
5229   [(set_attr "type" "fpalu")
5230    (set_attr "length" "4")])
5231
5232 (define_expand "floatunssisf2"
5233   [(set (subreg:SI (match_dup 2) 4)
5234         (match_operand:SI 1 "register_operand" ""))
5235    (set (subreg:SI (match_dup 2) 0)
5236         (const_int 0))
5237    (set (match_operand:SF 0 "register_operand" "")
5238         (float:SF (match_dup 2)))]
5239   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
5240   "
5241 {
5242   if (TARGET_PA_20)
5243     {
5244       emit_insn (gen_floatunssisf2_pa20 (operands[0], operands[1]));
5245       DONE;
5246     }
5247   operands[2] = gen_reg_rtx (DImode);
5248 }")
5249
5250 (define_expand "floatunssidf2"
5251   [(set (subreg:SI (match_dup 2) 4)
5252         (match_operand:SI 1 "register_operand" ""))
5253    (set (subreg:SI (match_dup 2) 0)
5254         (const_int 0))
5255    (set (match_operand:DF 0 "register_operand" "")
5256         (float:DF (match_dup 2)))]
5257   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
5258   "
5259 {
5260   if (TARGET_PA_20)
5261     {
5262       emit_insn (gen_floatunssidf2_pa20 (operands[0], operands[1]));
5263       DONE;
5264     }
5265   operands[2] = gen_reg_rtx (DImode);
5266 }")
5267
5268 (define_insn "floatdisf2"
5269   [(set (match_operand:SF 0 "register_operand" "=f")
5270         (float:SF (match_operand:DI 1 "register_operand" "f")))]
5271   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
5272   "{fcnvxf,dbl,sgl|fcnv,dw,sgl} %1,%0"
5273   [(set_attr "type" "fpalu")
5274    (set_attr "length" "4")])
5275
5276 (define_insn "floatdidf2"
5277   [(set (match_operand:DF 0 "register_operand" "=f")
5278         (float:DF (match_operand:DI 1 "register_operand" "f")))]
5279   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
5280   "{fcnvxf,dbl,dbl|fcnv,dw,dbl} %1,%0"
5281   [(set_attr "type" "fpalu")
5282    (set_attr "length" "4")])
5283
5284 ;; Convert a float to an actual integer.
5285 ;; Truncation is performed as part of the conversion.
5286
5287 (define_insn "fix_truncsfsi2"
5288   [(set (match_operand:SI 0 "register_operand" "=f")
5289         (fix:SI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
5290   "! TARGET_SOFT_FLOAT"
5291   "{fcnvfxt,sgl,sgl|fcnv,t,sgl,w} %1,%0"
5292   [(set_attr "type" "fpalu")
5293    (set_attr "length" "4")])
5294
5295 (define_insn "fix_truncdfsi2"
5296   [(set (match_operand:SI 0 "register_operand" "=f")
5297         (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
5298   "! TARGET_SOFT_FLOAT"
5299   "{fcnvfxt,dbl,sgl|fcnv,t,dbl,w} %1,%0"
5300   [(set_attr "type" "fpalu")
5301    (set_attr "length" "4")])
5302
5303 (define_insn "fix_truncsfdi2"
5304   [(set (match_operand:DI 0 "register_operand" "=f")
5305         (fix:DI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
5306   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
5307   "{fcnvfxt,sgl,dbl|fcnv,t,sgl,dw} %1,%0"
5308   [(set_attr "type" "fpalu")
5309    (set_attr "length" "4")])
5310
5311 (define_insn "fix_truncdfdi2"
5312   [(set (match_operand:DI 0 "register_operand" "=f")
5313         (fix:DI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
5314   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
5315   "{fcnvfxt,dbl,dbl|fcnv,t,dbl,dw} %1,%0"
5316   [(set_attr "type" "fpalu")
5317    (set_attr "length" "4")])
5318
5319 (define_insn "floatunssidf2_pa20"
5320   [(set (match_operand:DF 0 "register_operand" "=f")
5321         (unsigned_float:DF (match_operand:SI 1 "register_operand" "f")))]
5322   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5323   "fcnv,uw,dbl %1,%0"
5324   [(set_attr "type" "fpalu")
5325    (set_attr "length" "4")])
5326
5327 (define_insn "floatunssisf2_pa20"
5328   [(set (match_operand:SF 0 "register_operand" "=f")
5329         (unsigned_float:SF (match_operand:SI 1 "register_operand" "f")))]
5330   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5331   "fcnv,uw,sgl %1,%0"
5332   [(set_attr "type" "fpalu")
5333    (set_attr "length" "4")])
5334
5335 (define_insn "floatunsdisf2"
5336   [(set (match_operand:SF 0 "register_operand" "=f")
5337         (unsigned_float:SF (match_operand:DI 1 "register_operand" "f")))]
5338   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5339   "fcnv,udw,sgl %1,%0"
5340   [(set_attr "type" "fpalu")
5341    (set_attr "length" "4")])
5342
5343 (define_insn "floatunsdidf2"
5344   [(set (match_operand:DF 0 "register_operand" "=f")
5345         (unsigned_float:DF (match_operand:DI 1 "register_operand" "f")))]
5346   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5347   "fcnv,udw,dbl %1,%0"
5348   [(set_attr "type" "fpalu")
5349    (set_attr "length" "4")])
5350
5351 (define_insn "fixuns_truncsfsi2"
5352   [(set (match_operand:SI 0 "register_operand" "=f")
5353         (unsigned_fix:SI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
5354   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5355   "fcnv,t,sgl,uw %1,%0"
5356   [(set_attr "type" "fpalu")
5357    (set_attr "length" "4")])
5358
5359 (define_insn "fixuns_truncdfsi2"
5360   [(set (match_operand:SI 0 "register_operand" "=f")
5361         (unsigned_fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
5362   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5363   "fcnv,t,dbl,uw %1,%0"
5364   [(set_attr "type" "fpalu")
5365    (set_attr "length" "4")])
5366
5367 (define_insn "fixuns_truncsfdi2"
5368   [(set (match_operand:DI 0 "register_operand" "=f")
5369         (unsigned_fix:DI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
5370   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5371   "fcnv,t,sgl,udw %1,%0"
5372   [(set_attr "type" "fpalu")
5373    (set_attr "length" "4")])
5374
5375 (define_insn "fixuns_truncdfdi2"
5376   [(set (match_operand:DI 0 "register_operand" "=f")
5377         (unsigned_fix:DI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
5378   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5379   "fcnv,t,dbl,udw %1,%0"
5380   [(set_attr "type" "fpalu")
5381    (set_attr "length" "4")])
5382 \f
5383 ;;- arithmetic instructions
5384
5385 (define_expand "adddi3"
5386   [(set (match_operand:DI 0 "register_operand" "")
5387         (plus:DI (match_operand:DI 1 "register_operand" "")
5388                  (match_operand:DI 2 "adddi3_operand" "")))]
5389   ""
5390   "")
5391
5392 (define_insn ""
5393   [(set (match_operand:DI 0 "register_operand" "=r")
5394         (plus:DI (match_operand:DI 1 "register_operand" "%r")
5395                  (match_operand:DI 2 "arith11_operand" "rI")))]
5396   "!TARGET_64BIT"
5397   "*
5398 {
5399   if (GET_CODE (operands[2]) == CONST_INT)
5400     {
5401       if (INTVAL (operands[2]) >= 0)
5402         return \"addi %2,%R1,%R0\;{addc|add,c} %1,%%r0,%0\";
5403       else
5404         return \"addi %2,%R1,%R0\;{subb|sub,b} %1,%%r0,%0\";
5405     }
5406   else
5407     return \"add %R2,%R1,%R0\;{addc|add,c} %2,%1,%0\";
5408 }"
5409   [(set_attr "type" "binary")
5410    (set_attr "length" "8")])
5411
5412 (define_insn ""
5413   [(set (match_operand:DI 0 "register_operand" "=r,r")
5414         (plus:DI (match_operand:DI 1 "register_operand" "%r,r")
5415                  (match_operand:DI 2 "arith_operand" "r,J")))]
5416   "TARGET_64BIT"
5417   "@
5418    add,l %1,%2,%0
5419    ldo %2(%1),%0"
5420   [(set_attr "type" "binary,binary")
5421    (set_attr "pa_combine_type" "addmove")
5422    (set_attr "length" "4,4")])
5423
5424 (define_insn ""
5425   [(set (match_operand:DI 0 "register_operand" "=r")
5426         (plus:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
5427                  (match_operand:DI 2 "register_operand" "r")))]
5428   "TARGET_64BIT"
5429   "uaddcm %2,%1,%0"
5430   [(set_attr "type" "binary")
5431    (set_attr "length" "4")])
5432
5433 (define_insn ""
5434   [(set (match_operand:SI 0 "register_operand" "=r")
5435         (plus:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
5436                  (match_operand:SI 2 "register_operand" "r")))]
5437   ""
5438   "uaddcm %2,%1,%0"
5439   [(set_attr "type" "binary")
5440    (set_attr "length" "4")])
5441
5442 (define_expand "addvdi3"
5443   [(parallel [(set (match_operand:DI 0 "register_operand" "")
5444                    (plus:DI (match_operand:DI 1 "reg_or_0_operand" "")
5445                             (match_operand:DI 2 "arith11_operand" "")))
5446               (trap_if (ne (plus:TI (sign_extend:TI (match_dup 1))
5447                                     (sign_extend:TI (match_dup 2)))
5448                            (sign_extend:TI (plus:DI (match_dup 1)
5449                                                     (match_dup 2))))
5450                        (const_int 0))])]
5451   ""
5452   "")
5453
5454 (define_insn ""
5455   [(set (match_operand:DI 0 "register_operand" "=r,r")
5456         (plus:DI (match_operand:DI 1 "reg_or_0_operand" "%rM,rM")
5457                  (match_operand:DI 2 "arith11_operand" "r,I")))
5458    (trap_if (ne (plus:TI (sign_extend:TI (match_dup 1))
5459                          (sign_extend:TI (match_dup 2)))
5460                 (sign_extend:TI (plus:DI (match_dup 1)
5461                                          (match_dup 2))))
5462             (const_int 0))]
5463   "TARGET_64BIT"
5464   "@
5465   add,tsv,* %2,%1,%0
5466   addi,tsv,* %2,%1,%0"
5467   [(set_attr "type" "binary,binary")
5468    (set_attr "length" "4,4")])
5469
5470 (define_insn ""
5471   [(set (match_operand:DI 0 "register_operand" "=r")
5472         (plus:DI (match_operand:DI 1 "reg_or_0_operand" "%rM")
5473                  (match_operand:DI 2 "arith11_operand" "rI")))
5474    (trap_if (ne (plus:TI (sign_extend:TI (match_dup 1))
5475                          (sign_extend:TI (match_dup 2)))
5476                 (sign_extend:TI (plus:DI (match_dup 1)
5477                                          (match_dup 2))))
5478             (const_int 0))]
5479   "!TARGET_64BIT"
5480   "*
5481 {
5482   if (GET_CODE (operands[2]) == CONST_INT)
5483     {
5484       if (INTVAL (operands[2]) >= 0)
5485         return \"addi %2,%R1,%R0\;{addco|add,c,tsv} %1,%%r0,%0\";
5486       else
5487         return \"addi %2,%R1,%R0\;{subbo|sub,b,tsv} %1,%%r0,%0\";
5488     }
5489   else
5490     return \"add %R2,%R1,%R0\;{addco|add,c,tsv} %2,%1,%0\";
5491 }"
5492   [(set_attr "type" "binary")
5493    (set_attr "length" "8")])
5494
5495 ;; define_splits to optimize cases of adding a constant integer
5496 ;; to a register when the constant does not fit in 14 bits.  */
5497 (define_split
5498   [(set (match_operand:SI 0 "register_operand" "")
5499         (plus:SI (match_operand:SI 1 "register_operand" "")
5500                  (match_operand:SI 2 "const_int_operand" "")))
5501    (clobber (match_operand:SI 4 "register_operand" ""))]
5502   "! cint_ok_for_move (INTVAL (operands[2]))
5503    && VAL_14_BITS_P (INTVAL (operands[2]) >> 1)"
5504   [(set (match_dup 4) (plus:SI (match_dup 1) (match_dup 2)))
5505    (set (match_dup 0) (plus:SI (match_dup 4) (match_dup 3)))]
5506   "
5507 {
5508   int val = INTVAL (operands[2]);
5509   int low = (val < 0) ? -0x2000 : 0x1fff;
5510   int rest = val - low;
5511
5512   operands[2] = GEN_INT (rest);
5513   operands[3] = GEN_INT (low);
5514 }")
5515
5516 (define_split
5517   [(set (match_operand:SI 0 "register_operand" "")
5518         (plus:SI (match_operand:SI 1 "register_operand" "")
5519                  (match_operand:SI 2 "const_int_operand" "")))
5520    (clobber (match_operand:SI 4 "register_operand" ""))]
5521   "! cint_ok_for_move (INTVAL (operands[2]))"
5522   [(set (match_dup 4) (match_dup 2))
5523    (set (match_dup 0) (plus:SI (mult:SI (match_dup 4) (match_dup 3))
5524                                (match_dup 1)))]
5525   "
5526 {
5527   HOST_WIDE_INT intval = INTVAL (operands[2]);
5528
5529   /* Try dividing the constant by 2, then 4, and finally 8 to see
5530      if we can get a constant which can be loaded into a register
5531      in a single instruction (cint_ok_for_move). 
5532
5533      If that fails, try to negate the constant and subtract it
5534      from our input operand.  */
5535   if (intval % 2 == 0 && cint_ok_for_move (intval / 2))
5536     {
5537       operands[2] = GEN_INT (intval / 2);
5538       operands[3] = const2_rtx;
5539     }
5540   else if (intval % 4 == 0 && cint_ok_for_move (intval / 4))
5541     {
5542       operands[2] = GEN_INT (intval / 4);
5543       operands[3] = GEN_INT (4);
5544     }
5545   else if (intval % 8 == 0 && cint_ok_for_move (intval / 8))
5546     {
5547       operands[2] = GEN_INT (intval / 8);
5548       operands[3] = GEN_INT (8);
5549     }
5550   else if (cint_ok_for_move (-intval))
5551     {
5552       emit_insn (gen_rtx_SET (VOIDmode, operands[4], GEN_INT (-intval)));
5553       emit_insn (gen_subsi3 (operands[0], operands[1], operands[4]));
5554       DONE;
5555     }
5556   else
5557     FAIL;
5558 }")
5559
5560 (define_insn "addsi3"
5561   [(set (match_operand:SI 0 "register_operand" "=r,r")
5562         (plus:SI (match_operand:SI 1 "register_operand" "%r,r")
5563                  (match_operand:SI 2 "arith_operand" "r,J")))]
5564   ""
5565   "@
5566    {addl|add,l} %1,%2,%0
5567    ldo %2(%1),%0"
5568   [(set_attr "type" "binary,binary")
5569    (set_attr "pa_combine_type" "addmove")
5570    (set_attr "length" "4,4")])
5571
5572 (define_insn "addvsi3"
5573   [(set (match_operand:SI 0 "register_operand" "=r,r")
5574         (plus:SI (match_operand:SI 1 "reg_or_0_operand" "%rM,rM")
5575                  (match_operand:SI 2 "arith11_operand" "r,I")))
5576    (trap_if (ne (plus:DI (sign_extend:DI (match_dup 1))
5577                          (sign_extend:DI (match_dup 2)))
5578                 (sign_extend:DI (plus:SI (match_dup 1)
5579                                          (match_dup 2))))
5580             (const_int 0))]
5581   ""
5582   "@
5583   {addo|add,tsv} %2,%1,%0
5584   {addio|addi,tsv} %2,%1,%0"
5585   [(set_attr "type" "binary,binary")
5586    (set_attr "length" "4,4")])
5587
5588 (define_expand "subdi3"
5589   [(set (match_operand:DI 0 "register_operand" "")
5590         (minus:DI (match_operand:DI 1 "arith11_operand" "")
5591                   (match_operand:DI 2 "reg_or_0_operand" "")))]
5592   ""
5593   "")
5594
5595 (define_insn ""
5596   [(set (match_operand:DI 0 "register_operand" "=r,r,!q")
5597         (minus:DI (match_operand:DI 1 "arith11_operand" "r,I,!U")
5598                   (match_operand:DI 2 "reg_or_0_operand" "rM,rM,!rM")))]
5599   "TARGET_64BIT"
5600   "@
5601    sub %1,%2,%0
5602    subi %1,%2,%0
5603    mtsarcm %2"
5604   [(set_attr "type" "binary,binary,move")
5605   (set_attr "length" "4,4,4")])
5606
5607 (define_insn ""
5608   [(set (match_operand:DI 0 "register_operand" "=r,&r")
5609         (minus:DI (match_operand:DI 1 "arith11_operand" "r,I")
5610                   (match_operand:DI 2 "reg_or_0_operand" "rM,rM")))]
5611   "!TARGET_64BIT"
5612   "*
5613 {
5614   if (GET_CODE (operands[1]) == CONST_INT)
5615     {
5616       if (INTVAL (operands[1]) >= 0)
5617         return \"subi %1,%R2,%R0\;{subb|sub,b} %%r0,%2,%0\";
5618       else
5619         return \"ldi -1,%0\;subi %1,%R2,%R0\;{subb|sub,b} %0,%2,%0\";
5620     }
5621   else
5622     return \"sub %R1,%R2,%R0\;{subb|sub,b} %1,%2,%0\";
5623 }"
5624   [(set_attr "type" "binary")
5625    (set (attr "length")
5626         (if_then_else (eq_attr "alternative" "0")
5627           (const_int 8)
5628           (if_then_else (ge (symbol_ref "INTVAL (operands[1])")
5629                             (const_int 0))
5630             (const_int 8)
5631             (const_int 12))))])
5632
5633 (define_expand "subvdi3"
5634   [(parallel [(set (match_operand:DI 0 "register_operand" "")
5635                    (minus:DI (match_operand:DI 1 "arith11_operand" "")
5636                              (match_operand:DI 2 "reg_or_0_operand" "")))
5637               (trap_if (ne (minus:TI (sign_extend:TI (match_dup 1))
5638                                      (sign_extend:TI (match_dup 2)))
5639                            (sign_extend:TI (minus:DI (match_dup 1)
5640                                                      (match_dup 2))))
5641                        (const_int 0))])]
5642   ""
5643   "")
5644
5645 (define_insn ""
5646   [(set (match_operand:DI 0 "register_operand" "=r,r")
5647         (minus:DI (match_operand:DI 1 "arith11_operand" "r,I")
5648                   (match_operand:DI 2 "reg_or_0_operand" "rM,rM")))
5649    (trap_if (ne (minus:TI (sign_extend:TI (match_dup 1))
5650                           (sign_extend:TI (match_dup 2)))
5651                 (sign_extend:TI (minus:DI (match_dup 1)
5652                                           (match_dup 2))))
5653             (const_int 0))]
5654   "TARGET_64BIT"
5655   "@
5656   {subo|sub,tsv} %1,%2,%0
5657   {subio|subi,tsv} %1,%2,%0"
5658   [(set_attr "type" "binary,binary")
5659    (set_attr "length" "4,4")])
5660
5661 (define_insn ""
5662   [(set (match_operand:DI 0 "register_operand" "=r,&r")
5663         (minus:DI (match_operand:DI 1 "arith11_operand" "r,I")
5664                   (match_operand:DI 2 "reg_or_0_operand" "rM,rM")))
5665    (trap_if (ne (minus:TI (sign_extend:TI (match_dup 1))
5666                           (sign_extend:TI (match_dup 2)))
5667                 (sign_extend:TI (minus:DI (match_dup 1)
5668                                           (match_dup 2))))
5669             (const_int 0))]
5670   "!TARGET_64BIT"
5671   "*
5672 {
5673   if (GET_CODE (operands[1]) == CONST_INT)
5674     {
5675       if (INTVAL (operands[1]) >= 0)
5676         return \"subi %1,%R2,%R0\;{subbo|sub,b,tsv} %%r0,%2,%0\";
5677       else
5678         return \"ldi -1,%0\;subi %1,%R2,%R0\;{subbo|sub,b,tsv} %0,%2,%0\";
5679     }
5680   else
5681     return \"sub %R1,%R2,%R0\;{subbo|sub,b,tsv} %1,%2,%0\";
5682 }"
5683   [(set_attr "type" "binary,binary")
5684    (set (attr "length")
5685         (if_then_else (eq_attr "alternative" "0")
5686           (const_int 8)
5687           (if_then_else (ge (symbol_ref "INTVAL (operands[1])")
5688                             (const_int 0))
5689             (const_int 8)
5690             (const_int 12))))])
5691
5692 (define_expand "subsi3"
5693   [(set (match_operand:SI 0 "register_operand" "")
5694         (minus:SI (match_operand:SI 1 "arith11_operand" "")
5695                   (match_operand:SI 2 "register_operand" "")))]
5696   ""
5697   "")
5698
5699 (define_insn ""
5700   [(set (match_operand:SI 0 "register_operand" "=r,r")
5701         (minus:SI (match_operand:SI 1 "arith11_operand" "r,I")
5702                   (match_operand:SI 2 "register_operand" "r,r")))]
5703   "!TARGET_PA_20"
5704   "@
5705    sub %1,%2,%0
5706    subi %1,%2,%0"
5707   [(set_attr "type" "binary,binary")
5708    (set_attr "length" "4,4")])
5709
5710 (define_insn ""
5711   [(set (match_operand:SI 0 "register_operand" "=r,r,!q")
5712         (minus:SI (match_operand:SI 1 "arith11_operand" "r,I,!S")
5713                   (match_operand:SI 2 "register_operand" "r,r,!r")))]
5714   "TARGET_PA_20"
5715   "@
5716    sub %1,%2,%0
5717    subi %1,%2,%0
5718    mtsarcm %2"
5719   [(set_attr "type" "binary,binary,move")
5720    (set_attr "length" "4,4,4")])
5721
5722 (define_insn "subvsi3"
5723   [(set (match_operand:SI 0 "register_operand" "=r,r")
5724         (minus:SI (match_operand:SI 1 "arith11_operand" "rM,I")
5725                   (match_operand:SI 2 "reg_or_0_operand" "rM,rM")))
5726    (trap_if (ne (minus:DI (sign_extend:DI (match_dup 1))
5727                           (sign_extend:DI (match_dup 2)))
5728                 (sign_extend:DI (minus:SI (match_dup 1)
5729                                           (match_dup 2))))
5730             (const_int 0))]
5731   ""
5732   "@
5733   {subo|sub,tsv} %1,%2,%0
5734   {subio|subi,tsv} %1,%2,%0"
5735   [(set_attr "type" "binary,binary")
5736    (set_attr "length" "4,4")])
5737
5738 ;; Clobbering a "register_operand" instead of a match_scratch
5739 ;; in operand3 of millicode calls avoids spilling %r1 and
5740 ;; produces better code.
5741
5742 ;; The mulsi3 insns set up registers for the millicode call.
5743 (define_expand "mulsi3"
5744   [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5745    (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5746    (parallel [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
5747               (clobber (match_dup 3))
5748               (clobber (reg:SI 26))
5749               (clobber (reg:SI 25))
5750               (clobber (match_dup 4))])
5751    (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5752   ""
5753   "
5754 {
5755   operands[4] = gen_rtx_REG (SImode, TARGET_64BIT ? 2 : 31);
5756   if (TARGET_PA_11 && !TARGET_DISABLE_FPREGS && !TARGET_SOFT_FLOAT)
5757     {
5758       rtx scratch = gen_reg_rtx (DImode);
5759       operands[1] = force_reg (SImode, operands[1]);
5760       operands[2] = force_reg (SImode, operands[2]);
5761       emit_insn (gen_umulsidi3 (scratch, operands[1], operands[2]));
5762       emit_insn (gen_movsi (operands[0],
5763                             gen_rtx_SUBREG (SImode, scratch,
5764                                             GET_MODE_SIZE (SImode))));
5765       DONE;
5766     }
5767   operands[3] = gen_reg_rtx (SImode);
5768 }")
5769
5770 (define_insn "umulsidi3"
5771   [(set (match_operand:DI 0 "nonimmediate_operand" "=f")
5772         (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "f"))
5773                  (zero_extend:DI (match_operand:SI 2 "nonimmediate_operand" "f"))))]
5774   "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT"
5775   "xmpyu %1,%2,%0"
5776   [(set_attr "type" "fpmuldbl")
5777    (set_attr "length" "4")])
5778
5779 (define_insn ""
5780   [(set (match_operand:DI 0 "nonimmediate_operand" "=f")
5781         (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "f"))
5782                  (match_operand:DI 2 "uint32_operand" "f")))]
5783   "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT && !TARGET_64BIT"
5784   "xmpyu %1,%R2,%0"
5785   [(set_attr "type" "fpmuldbl")
5786    (set_attr "length" "4")])
5787
5788 (define_insn ""
5789   [(set (match_operand:DI 0 "nonimmediate_operand" "=f")
5790         (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "f"))
5791                  (match_operand:DI 2 "uint32_operand" "f")))]
5792   "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT && TARGET_64BIT"
5793   "xmpyu %1,%2R,%0"
5794   [(set_attr "type" "fpmuldbl")
5795    (set_attr "length" "4")])
5796
5797 (define_insn ""
5798   [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
5799    (clobber (match_operand:SI 0 "register_operand" "=a"))
5800    (clobber (reg:SI 26))
5801    (clobber (reg:SI 25))
5802    (clobber (reg:SI 31))]
5803   "!TARGET_64BIT"
5804   "* return output_mul_insn (0, insn);"
5805   [(set_attr "type" "milli")
5806    (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5807
5808 (define_insn ""
5809   [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
5810    (clobber (match_operand:SI 0 "register_operand" "=a"))
5811    (clobber (reg:SI 26))
5812    (clobber (reg:SI 25))
5813    (clobber (reg:SI 2))]
5814   "TARGET_64BIT"
5815   "* return output_mul_insn (0, insn);"
5816   [(set_attr "type" "milli")
5817    (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5818
5819 (define_expand "muldi3"
5820   [(set (match_operand:DI 0 "register_operand" "")
5821         (mult:DI (match_operand:DI 1 "register_operand" "")
5822                  (match_operand:DI 2 "register_operand" "")))]
5823   "TARGET_64BIT && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT"
5824   "
5825 {
5826   rtx low_product = gen_reg_rtx (DImode);
5827   rtx cross_product1 = gen_reg_rtx (DImode);
5828   rtx cross_product2 = gen_reg_rtx (DImode);
5829   rtx cross_scratch = gen_reg_rtx (DImode);
5830   rtx cross_product = gen_reg_rtx (DImode);
5831   rtx op1l, op1r, op2l, op2r;
5832   rtx op1shifted, op2shifted;
5833
5834   op1shifted = gen_reg_rtx (DImode);
5835   op2shifted = gen_reg_rtx (DImode);
5836   op1l = gen_reg_rtx (SImode);
5837   op1r = gen_reg_rtx (SImode);
5838   op2l = gen_reg_rtx (SImode);
5839   op2r = gen_reg_rtx (SImode);
5840
5841   emit_move_insn (op1shifted, gen_rtx_LSHIFTRT (DImode, operands[1],
5842                                                 GEN_INT (32)));
5843   emit_move_insn (op2shifted, gen_rtx_LSHIFTRT (DImode, operands[2],
5844                                                 GEN_INT (32)));
5845   op1r = force_reg (SImode, gen_rtx_SUBREG (SImode, operands[1], 4));
5846   op2r = force_reg (SImode, gen_rtx_SUBREG (SImode, operands[2], 4));
5847   op1l = force_reg (SImode, gen_rtx_SUBREG (SImode, op1shifted, 4));
5848   op2l = force_reg (SImode, gen_rtx_SUBREG (SImode, op2shifted, 4));
5849
5850   /* Emit multiplies for the cross products.  */
5851   emit_insn (gen_umulsidi3 (cross_product1, op2r, op1l));
5852   emit_insn (gen_umulsidi3 (cross_product2, op2l, op1r));
5853
5854   /* Emit a multiply for the low sub-word.  */
5855   emit_insn (gen_umulsidi3 (low_product, copy_rtx (op2r), copy_rtx (op1r)));
5856
5857   /* Sum the cross products and shift them into proper position.  */
5858   emit_insn (gen_adddi3 (cross_scratch, cross_product1, cross_product2));
5859   emit_insn (gen_ashldi3 (cross_product, cross_scratch, GEN_INT (32)));
5860
5861   /* Add the cross product to the low product and store the result
5862      into the output operand .  */
5863   emit_insn (gen_adddi3 (operands[0], cross_product, low_product));
5864   DONE;
5865 }")
5866
5867 ;;; Division and mod.
5868 (define_expand "divsi3"
5869   [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5870    (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5871    (parallel [(set (reg:SI 29) (div:SI (reg:SI 26) (reg:SI 25)))
5872               (clobber (match_dup 3))
5873               (clobber (match_dup 4))
5874               (clobber (reg:SI 26))
5875               (clobber (reg:SI 25))
5876               (clobber (match_dup 5))])
5877    (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5878   ""
5879   "
5880 {
5881   operands[3] = gen_reg_rtx (SImode);
5882   if (TARGET_64BIT)
5883     {
5884       operands[5] = gen_rtx_REG (SImode, 2);
5885       operands[4] = operands[5];
5886     }
5887   else
5888     {
5889       operands[5] = gen_rtx_REG (SImode, 31);
5890       operands[4] = gen_reg_rtx (SImode);
5891     }
5892   if (GET_CODE (operands[2]) == CONST_INT && emit_hpdiv_const (operands, 0))
5893     DONE;
5894 }")
5895
5896 (define_insn ""
5897   [(set (reg:SI 29)
5898         (div:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5899    (clobber (match_operand:SI 1 "register_operand" "=a"))
5900    (clobber (match_operand:SI 2 "register_operand" "=&r"))
5901    (clobber (reg:SI 26))
5902    (clobber (reg:SI 25))
5903    (clobber (reg:SI 31))]
5904   "!TARGET_64BIT"
5905   "*
5906    return output_div_insn (operands, 0, insn);"
5907   [(set_attr "type" "milli")
5908    (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5909
5910 (define_insn ""
5911   [(set (reg:SI 29)
5912         (div:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5913    (clobber (match_operand:SI 1 "register_operand" "=a"))
5914    (clobber (match_operand:SI 2 "register_operand" "=&r"))
5915    (clobber (reg:SI 26))
5916    (clobber (reg:SI 25))
5917    (clobber (reg:SI 2))]
5918   "TARGET_64BIT"
5919   "*
5920    return output_div_insn (operands, 0, insn);"
5921   [(set_attr "type" "milli")
5922    (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5923
5924 (define_expand "udivsi3"
5925   [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5926    (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5927    (parallel [(set (reg:SI 29) (udiv:SI (reg:SI 26) (reg:SI 25)))
5928               (clobber (match_dup 3))
5929               (clobber (match_dup 4))
5930               (clobber (reg:SI 26))
5931               (clobber (reg:SI 25))
5932               (clobber (match_dup 5))])
5933    (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5934   ""
5935   "
5936 {
5937   operands[3] = gen_reg_rtx (SImode);
5938
5939   if (TARGET_64BIT)
5940     {
5941       operands[5] = gen_rtx_REG (SImode, 2);
5942       operands[4] = operands[5];
5943     }
5944   else
5945     {
5946       operands[5] = gen_rtx_REG (SImode, 31);
5947       operands[4] = gen_reg_rtx (SImode);
5948     }
5949   if (GET_CODE (operands[2]) == CONST_INT && emit_hpdiv_const (operands, 1))
5950     DONE;
5951 }")
5952
5953 (define_insn ""
5954   [(set (reg:SI 29)
5955         (udiv:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5956    (clobber (match_operand:SI 1 "register_operand" "=a"))
5957    (clobber (match_operand:SI 2 "register_operand" "=&r"))
5958    (clobber (reg:SI 26))
5959    (clobber (reg:SI 25))
5960    (clobber (reg:SI 31))]
5961   "!TARGET_64BIT"
5962   "*
5963    return output_div_insn (operands, 1, insn);"
5964   [(set_attr "type" "milli")
5965    (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5966
5967 (define_insn ""
5968   [(set (reg:SI 29)
5969         (udiv:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5970    (clobber (match_operand:SI 1 "register_operand" "=a"))
5971    (clobber (match_operand:SI 2 "register_operand" "=&r"))
5972    (clobber (reg:SI 26))
5973    (clobber (reg:SI 25))
5974    (clobber (reg:SI 2))]
5975   "TARGET_64BIT"
5976   "*
5977    return output_div_insn (operands, 1, insn);"
5978   [(set_attr "type" "milli")
5979    (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5980
5981 (define_expand "modsi3"
5982   [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5983    (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5984    (parallel [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
5985               (clobber (match_dup 3))
5986               (clobber (match_dup 4))
5987               (clobber (reg:SI 26))
5988               (clobber (reg:SI 25))
5989               (clobber (match_dup 5))])
5990    (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5991   ""
5992   "
5993 {
5994   if (TARGET_64BIT)
5995     {
5996       operands[5] = gen_rtx_REG (SImode, 2);
5997       operands[4] = operands[5];
5998     }
5999   else
6000     {
6001       operands[5] = gen_rtx_REG (SImode, 31);
6002       operands[4] = gen_reg_rtx (SImode);
6003     }
6004   operands[3] = gen_reg_rtx (SImode);
6005 }")
6006
6007 (define_insn ""
6008   [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
6009    (clobber (match_operand:SI 0 "register_operand" "=a"))
6010    (clobber (match_operand:SI 1 "register_operand" "=&r"))
6011    (clobber (reg:SI 26))
6012    (clobber (reg:SI 25))
6013    (clobber (reg:SI 31))]
6014   "!TARGET_64BIT"
6015   "*
6016   return output_mod_insn (0, insn);"
6017   [(set_attr "type" "milli")
6018    (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
6019
6020 (define_insn ""
6021   [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
6022    (clobber (match_operand:SI 0 "register_operand" "=a"))
6023    (clobber (match_operand:SI 1 "register_operand" "=&r"))
6024    (clobber (reg:SI 26))
6025    (clobber (reg:SI 25))
6026    (clobber (reg:SI 2))]
6027   "TARGET_64BIT"
6028   "*
6029   return output_mod_insn (0, insn);"
6030   [(set_attr "type" "milli")
6031    (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
6032
6033 (define_expand "umodsi3"
6034   [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
6035    (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
6036    (parallel [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
6037               (clobber (match_dup 3))
6038               (clobber (match_dup 4))
6039               (clobber (reg:SI 26))
6040               (clobber (reg:SI 25))
6041               (clobber (match_dup 5))])
6042    (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
6043   ""
6044   "
6045 {
6046   if (TARGET_64BIT)
6047     {
6048       operands[5] = gen_rtx_REG (SImode, 2);
6049       operands[4] = operands[5];
6050     }
6051   else
6052     {
6053       operands[5] = gen_rtx_REG (SImode, 31);
6054       operands[4] = gen_reg_rtx (SImode);
6055     }
6056   operands[3] = gen_reg_rtx (SImode);
6057 }")
6058
6059 (define_insn ""
6060   [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
6061    (clobber (match_operand:SI 0 "register_operand" "=a"))
6062    (clobber (match_operand:SI 1 "register_operand" "=&r"))
6063    (clobber (reg:SI 26))
6064    (clobber (reg:SI 25))
6065    (clobber (reg:SI 31))]
6066   "!TARGET_64BIT"
6067   "*
6068   return output_mod_insn (1, insn);"
6069   [(set_attr "type" "milli")
6070    (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
6071
6072 (define_insn ""
6073   [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
6074    (clobber (match_operand:SI 0 "register_operand" "=a"))
6075    (clobber (match_operand:SI 1 "register_operand" "=&r"))
6076    (clobber (reg:SI 26))
6077    (clobber (reg:SI 25))
6078    (clobber (reg:SI 2))]
6079   "TARGET_64BIT"
6080   "*
6081   return output_mod_insn (1, insn);"
6082   [(set_attr "type" "milli")
6083    (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
6084
6085 ;;- and instructions
6086 ;; We define DImode `and` so with DImode `not` we can get
6087 ;; DImode `andn`.  Other combinations are possible.
6088
6089 (define_expand "anddi3"
6090   [(set (match_operand:DI 0 "register_operand" "")
6091         (and:DI (match_operand:DI 1 "register_operand" "")
6092                 (match_operand:DI 2 "and_operand" "")))]
6093   ""
6094   "
6095 {
6096   /* Both operands must be register operands.  */
6097   if (!TARGET_64BIT && !register_operand (operands[2], DImode))
6098     FAIL;
6099 }")
6100
6101 (define_insn ""
6102   [(set (match_operand:DI 0 "register_operand" "=r")
6103         (and:DI (match_operand:DI 1 "register_operand" "%r")
6104                 (match_operand:DI 2 "register_operand" "r")))]
6105   "!TARGET_64BIT"
6106   "and %1,%2,%0\;and %R1,%R2,%R0"
6107   [(set_attr "type" "binary")
6108    (set_attr "length" "8")])
6109
6110 (define_insn ""
6111   [(set (match_operand:DI 0 "register_operand" "=r,r")
6112         (and:DI (match_operand:DI 1 "register_operand" "%?r,0")
6113                 (match_operand:DI 2 "and_operand" "rO,P")))]
6114   "TARGET_64BIT"
6115   "* return output_64bit_and (operands); "
6116   [(set_attr "type" "binary")
6117    (set_attr "length" "4")])
6118
6119 ; The ? for op1 makes reload prefer zdepi instead of loading a huge
6120 ; constant with ldil;ldo.
6121 (define_insn "andsi3"
6122   [(set (match_operand:SI 0 "register_operand" "=r,r")
6123         (and:SI (match_operand:SI 1 "register_operand" "%?r,0")
6124                 (match_operand:SI 2 "and_operand" "rO,P")))]
6125   ""
6126   "* return output_and (operands); "
6127   [(set_attr "type" "binary,shift")
6128    (set_attr "length" "4,4")])
6129
6130 (define_insn ""
6131   [(set (match_operand:DI 0 "register_operand" "=r")
6132         (and:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
6133                 (match_operand:DI 2 "register_operand" "r")))]
6134   "!TARGET_64BIT"
6135   "andcm %2,%1,%0\;andcm %R2,%R1,%R0"
6136   [(set_attr "type" "binary")
6137    (set_attr "length" "8")])
6138
6139 (define_insn ""
6140   [(set (match_operand:DI 0 "register_operand" "=r")
6141         (and:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
6142                 (match_operand:DI 2 "register_operand" "r")))]
6143   "TARGET_64BIT"
6144   "andcm %2,%1,%0"
6145   [(set_attr "type" "binary")
6146    (set_attr "length" "4")])
6147
6148 (define_insn ""
6149   [(set (match_operand:SI 0 "register_operand" "=r")
6150         (and:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
6151                 (match_operand:SI 2 "register_operand" "r")))]
6152   ""
6153   "andcm %2,%1,%0"
6154   [(set_attr "type" "binary")
6155   (set_attr "length" "4")])
6156
6157 (define_expand "iordi3"
6158   [(set (match_operand:DI 0 "register_operand" "")
6159         (ior:DI (match_operand:DI 1 "register_operand" "")
6160                 (match_operand:DI 2 "ior_operand" "")))]
6161   ""
6162   "
6163 {
6164   /* Both operands must be register operands.  */
6165   if (!TARGET_64BIT && !register_operand (operands[2], DImode))
6166     FAIL;
6167 }")
6168
6169 (define_insn ""
6170   [(set (match_operand:DI 0 "register_operand" "=r")
6171         (ior:DI (match_operand:DI 1 "register_operand" "%r")
6172                 (match_operand:DI 2 "register_operand" "r")))]
6173   "!TARGET_64BIT"
6174   "or %1,%2,%0\;or %R1,%R2,%R0"
6175   [(set_attr "type" "binary")
6176    (set_attr "length" "8")])
6177
6178 (define_insn ""
6179   [(set (match_operand:DI 0 "register_operand" "=r,r")
6180         (ior:DI (match_operand:DI 1 "register_operand" "0,0")
6181                 (match_operand:DI 2 "ior_operand" "M,i")))]
6182   "TARGET_64BIT"
6183   "* return output_64bit_ior (operands); "
6184   [(set_attr "type" "binary,shift")
6185    (set_attr "length" "4,4")])
6186
6187 (define_insn ""
6188   [(set (match_operand:DI 0 "register_operand" "=r")
6189         (ior:DI (match_operand:DI 1 "register_operand" "%r")
6190                 (match_operand:DI 2 "register_operand" "r")))]
6191   "TARGET_64BIT"
6192   "or %1,%2,%0"
6193   [(set_attr "type" "binary")
6194    (set_attr "length" "4")])
6195
6196 ;; Need a define_expand because we've run out of CONST_OK... characters.
6197 (define_expand "iorsi3"
6198   [(set (match_operand:SI 0 "register_operand" "")
6199         (ior:SI (match_operand:SI 1 "register_operand" "")
6200                 (match_operand:SI 2 "arith32_operand" "")))]
6201   ""
6202   "
6203 {
6204   if (! (ior_operand (operands[2], SImode)
6205          || register_operand (operands[2], SImode)))
6206     operands[2] = force_reg (SImode, operands[2]);
6207 }")
6208
6209 (define_insn ""
6210   [(set (match_operand:SI 0 "register_operand" "=r,r")
6211         (ior:SI (match_operand:SI 1 "register_operand" "0,0")
6212                 (match_operand:SI 2 "ior_operand" "M,i")))]
6213   ""
6214   "* return output_ior (operands); "
6215   [(set_attr "type" "binary,shift")
6216    (set_attr "length" "4,4")])
6217
6218 (define_insn ""
6219   [(set (match_operand:SI 0 "register_operand" "=r")
6220         (ior:SI (match_operand:SI 1 "register_operand" "%r")
6221                 (match_operand:SI 2 "register_operand" "r")))]
6222   ""
6223   "or %1,%2,%0"
6224   [(set_attr "type" "binary")
6225    (set_attr "length" "4")])
6226
6227 (define_expand "xordi3"
6228   [(set (match_operand:DI 0 "register_operand" "")
6229         (xor:DI (match_operand:DI 1 "register_operand" "")
6230                 (match_operand:DI 2 "register_operand" "")))]
6231   ""
6232   "
6233 {
6234 }")
6235
6236 (define_insn ""
6237   [(set (match_operand:DI 0 "register_operand" "=r")
6238         (xor:DI (match_operand:DI 1 "register_operand" "%r")
6239                 (match_operand:DI 2 "register_operand" "r")))]
6240   "!TARGET_64BIT"
6241   "xor %1,%2,%0\;xor %R1,%R2,%R0"
6242   [(set_attr "type" "binary")
6243    (set_attr "length" "8")])
6244
6245 (define_insn ""
6246   [(set (match_operand:DI 0 "register_operand" "=r")
6247         (xor:DI (match_operand:DI 1 "register_operand" "%r")
6248                 (match_operand:DI 2 "register_operand" "r")))]
6249   "TARGET_64BIT"
6250   "xor %1,%2,%0"
6251   [(set_attr "type" "binary")
6252    (set_attr "length" "4")])
6253
6254 (define_insn "xorsi3"
6255   [(set (match_operand:SI 0 "register_operand" "=r")
6256         (xor:SI (match_operand:SI 1 "register_operand" "%r")
6257                 (match_operand:SI 2 "register_operand" "r")))]
6258   ""
6259   "xor %1,%2,%0"
6260   [(set_attr "type" "binary")
6261    (set_attr "length" "4")])
6262
6263 (define_expand "negdi2"
6264   [(set (match_operand:DI 0 "register_operand" "")
6265         (neg:DI (match_operand:DI 1 "register_operand" "")))]
6266   ""
6267   "")
6268
6269 (define_insn ""
6270   [(set (match_operand:DI 0 "register_operand" "=r")
6271         (neg:DI (match_operand:DI 1 "register_operand" "r")))]
6272   "!TARGET_64BIT"
6273   "sub %%r0,%R1,%R0\;{subb|sub,b} %%r0,%1,%0"
6274   [(set_attr "type" "unary")
6275    (set_attr "length" "8")])
6276
6277 (define_insn ""
6278   [(set (match_operand:DI 0 "register_operand" "=r")
6279         (neg:DI (match_operand:DI 1 "register_operand" "r")))]
6280   "TARGET_64BIT"
6281   "sub %%r0,%1,%0"
6282   [(set_attr "type" "unary")
6283    (set_attr "length" "4")])
6284
6285 (define_expand "negvdi2"
6286   [(parallel [(set (match_operand:DI 0 "register_operand" "")
6287                    (neg:DI (match_operand:DI 1 "register_operand" "")))
6288               (trap_if (ne (neg:TI (sign_extend:TI (match_dup 1)))
6289                                    (sign_extend:TI (neg:DI (match_dup 1))))
6290                        (const_int 0))])]
6291   ""
6292   "")
6293
6294 (define_insn ""
6295   [(set (match_operand:DI 0 "register_operand" "=r")
6296         (neg:DI (match_operand:DI 1 "register_operand" "r")))
6297    (trap_if (ne (neg:TI (sign_extend:TI (match_dup 1)))
6298                 (sign_extend:TI (neg:DI (match_dup 1))))
6299             (const_int 0))]
6300   "!TARGET_64BIT"
6301   "sub %%r0,%R1,%R0\;{subbo|sub,b,tsv} %%r0,%1,%0"
6302   [(set_attr "type" "unary")
6303    (set_attr "length" "8")])
6304
6305 (define_insn ""
6306   [(set (match_operand:DI 0 "register_operand" "=r")
6307         (neg:DI (match_operand:DI 1 "register_operand" "r")))
6308    (trap_if (ne (neg:TI (sign_extend:TI (match_dup 1)))
6309                 (sign_extend:TI (neg:DI (match_dup 1))))
6310             (const_int 0))]
6311   "TARGET_64BIT"
6312   "sub,tsv %%r0,%1,%0"
6313   [(set_attr "type" "unary")
6314    (set_attr "length" "4")])
6315
6316 (define_insn "negsi2"
6317   [(set (match_operand:SI 0 "register_operand" "=r")
6318         (neg:SI (match_operand:SI 1 "register_operand" "r")))]
6319   ""
6320   "sub %%r0,%1,%0"
6321   [(set_attr "type" "unary")
6322    (set_attr "length" "4")])
6323
6324 (define_insn "negvsi2"
6325   [(set (match_operand:SI 0 "register_operand" "=r")
6326         (neg:SI (match_operand:SI 1 "register_operand" "r")))
6327    (trap_if (ne (neg:DI (sign_extend:DI (match_dup 1)))
6328                 (sign_extend:DI (neg:SI (match_dup 1))))
6329             (const_int 0))]
6330    ""
6331    "{subo|sub,tsv} %%r0,%1,%0"
6332   [(set_attr "type" "unary")
6333    (set_attr "length" "4")])
6334
6335 (define_expand "one_cmpldi2"
6336   [(set (match_operand:DI 0 "register_operand" "")
6337         (not:DI (match_operand:DI 1 "register_operand" "")))]
6338   ""
6339   "
6340 {
6341 }")
6342
6343 (define_insn ""
6344   [(set (match_operand:DI 0 "register_operand" "=r")
6345         (not:DI (match_operand:DI 1 "register_operand" "r")))]
6346   "!TARGET_64BIT"
6347   "uaddcm %%r0,%1,%0\;uaddcm %%r0,%R1,%R0"
6348   [(set_attr "type" "unary")
6349    (set_attr "length" "8")])
6350
6351 (define_insn ""
6352   [(set (match_operand:DI 0 "register_operand" "=r")
6353         (not:DI (match_operand:DI 1 "register_operand" "r")))]
6354   "TARGET_64BIT"
6355   "uaddcm %%r0,%1,%0"
6356   [(set_attr "type" "unary")
6357    (set_attr "length" "4")])
6358
6359 (define_insn "one_cmplsi2"
6360   [(set (match_operand:SI 0 "register_operand" "=r")
6361         (not:SI (match_operand:SI 1 "register_operand" "r")))]
6362   ""
6363   "uaddcm %%r0,%1,%0"
6364   [(set_attr "type" "unary")
6365    (set_attr "length" "4")])
6366 \f
6367 ;; Floating point arithmetic instructions.
6368
6369 (define_insn "adddf3"
6370   [(set (match_operand:DF 0 "register_operand" "=f")
6371         (plus:DF (match_operand:DF 1 "register_operand" "f")
6372                  (match_operand:DF 2 "register_operand" "f")))]
6373   "! TARGET_SOFT_FLOAT"
6374   "fadd,dbl %1,%2,%0"
6375   [(set_attr "type" "fpalu")
6376    (set_attr "pa_combine_type" "faddsub")
6377    (set_attr "length" "4")])
6378
6379 (define_insn "addsf3"
6380   [(set (match_operand:SF 0 "register_operand" "=f")
6381         (plus:SF (match_operand:SF 1 "register_operand" "f")
6382                  (match_operand:SF 2 "register_operand" "f")))]
6383   "! TARGET_SOFT_FLOAT"
6384   "fadd,sgl %1,%2,%0"
6385   [(set_attr "type" "fpalu")
6386    (set_attr "pa_combine_type" "faddsub")
6387    (set_attr "length" "4")])
6388
6389 (define_insn "subdf3"
6390   [(set (match_operand:DF 0 "register_operand" "=f")
6391         (minus:DF (match_operand:DF 1 "register_operand" "f")
6392                   (match_operand:DF 2 "register_operand" "f")))]
6393   "! TARGET_SOFT_FLOAT"
6394   "fsub,dbl %1,%2,%0"
6395   [(set_attr "type" "fpalu")
6396    (set_attr "pa_combine_type" "faddsub")
6397    (set_attr "length" "4")])
6398
6399 (define_insn "subsf3"
6400   [(set (match_operand:SF 0 "register_operand" "=f")
6401         (minus:SF (match_operand:SF 1 "register_operand" "f")
6402                   (match_operand:SF 2 "register_operand" "f")))]
6403   "! TARGET_SOFT_FLOAT"
6404   "fsub,sgl %1,%2,%0"
6405   [(set_attr "type" "fpalu")
6406    (set_attr "pa_combine_type" "faddsub")
6407    (set_attr "length" "4")])
6408
6409 (define_insn "muldf3"
6410   [(set (match_operand:DF 0 "register_operand" "=f")
6411         (mult:DF (match_operand:DF 1 "register_operand" "f")
6412                  (match_operand:DF 2 "register_operand" "f")))]
6413   "! TARGET_SOFT_FLOAT"
6414   "fmpy,dbl %1,%2,%0"
6415   [(set_attr "type" "fpmuldbl")
6416    (set_attr "pa_combine_type" "fmpy")
6417    (set_attr "length" "4")])
6418
6419 (define_insn "mulsf3"
6420   [(set (match_operand:SF 0 "register_operand" "=f")
6421         (mult:SF (match_operand:SF 1 "register_operand" "f")
6422                  (match_operand:SF 2 "register_operand" "f")))]
6423   "! TARGET_SOFT_FLOAT"
6424   "fmpy,sgl %1,%2,%0"
6425   [(set_attr "type" "fpmulsgl")
6426    (set_attr "pa_combine_type" "fmpy")
6427    (set_attr "length" "4")])
6428
6429 (define_insn "divdf3"
6430   [(set (match_operand:DF 0 "register_operand" "=f")
6431         (div:DF (match_operand:DF 1 "register_operand" "f")
6432                 (match_operand:DF 2 "register_operand" "f")))]
6433   "! TARGET_SOFT_FLOAT"
6434   "fdiv,dbl %1,%2,%0"
6435   [(set_attr "type" "fpdivdbl")
6436    (set_attr "length" "4")])
6437
6438 (define_insn "divsf3"
6439   [(set (match_operand:SF 0 "register_operand" "=f")
6440         (div:SF (match_operand:SF 1 "register_operand" "f")
6441                 (match_operand:SF 2 "register_operand" "f")))]
6442   "! TARGET_SOFT_FLOAT"
6443   "fdiv,sgl %1,%2,%0"
6444   [(set_attr "type" "fpdivsgl")
6445    (set_attr "length" "4")])
6446
6447 ;; Processors prior to PA 2.0 don't have a fneg instruction.  Fast
6448 ;; negation can be done by subtracting from plus zero.  However, this
6449 ;; violates the IEEE standard when negating plus and minus zero.
6450 (define_expand "negdf2"
6451   [(parallel [(set (match_operand:DF 0 "register_operand" "")
6452                    (neg:DF (match_operand:DF 1 "register_operand" "")))
6453               (use (match_dup 2))])]
6454   "! TARGET_SOFT_FLOAT"
6455 {
6456   if (TARGET_PA_20 || flag_unsafe_math_optimizations)
6457     emit_insn (gen_negdf2_fast (operands[0], operands[1]));
6458   else
6459     {
6460       operands[2] = force_reg (DFmode,
6461         CONST_DOUBLE_FROM_REAL_VALUE (dconstm1, DFmode));
6462       emit_insn (gen_muldf3 (operands[0], operands[1], operands[2]));
6463     }
6464   DONE;
6465 })
6466
6467 (define_insn "negdf2_fast"
6468   [(set (match_operand:DF 0 "register_operand" "=f")
6469         (neg:DF (match_operand:DF 1 "register_operand" "f")))]
6470   "! TARGET_SOFT_FLOAT && (TARGET_PA_20 || flag_unsafe_math_optimizations)"
6471   "*
6472 {
6473   if (TARGET_PA_20)
6474     return \"fneg,dbl %1,%0\";
6475   else
6476     return \"fsub,dbl %%fr0,%1,%0\";
6477 }"
6478   [(set_attr "type" "fpalu")
6479    (set_attr "length" "4")])
6480
6481 (define_expand "negsf2"
6482   [(parallel [(set (match_operand:SF 0 "register_operand" "")
6483                    (neg:SF (match_operand:SF 1 "register_operand" "")))
6484               (use (match_dup 2))])]
6485   "! TARGET_SOFT_FLOAT"
6486 {
6487   if (TARGET_PA_20 || flag_unsafe_math_optimizations)
6488     emit_insn (gen_negsf2_fast (operands[0], operands[1]));
6489   else
6490     {
6491       operands[2] = force_reg (SFmode,
6492         CONST_DOUBLE_FROM_REAL_VALUE (dconstm1, SFmode));
6493       emit_insn (gen_mulsf3 (operands[0], operands[1], operands[2]));
6494     }
6495   DONE;
6496 })
6497
6498 (define_insn "negsf2_fast"
6499   [(set (match_operand:SF 0 "register_operand" "=f")
6500         (neg:SF (match_operand:SF 1 "register_operand" "f")))]
6501   "! TARGET_SOFT_FLOAT && (TARGET_PA_20 || flag_unsafe_math_optimizations)"
6502   "*
6503 {
6504   if (TARGET_PA_20)
6505     return \"fneg,sgl %1,%0\";
6506   else
6507     return \"fsub,sgl %%fr0,%1,%0\";
6508 }"
6509   [(set_attr "type" "fpalu")
6510    (set_attr "length" "4")])
6511
6512 (define_insn "absdf2"
6513   [(set (match_operand:DF 0 "register_operand" "=f")
6514         (abs:DF (match_operand:DF 1 "register_operand" "f")))]
6515   "! TARGET_SOFT_FLOAT"
6516   "fabs,dbl %1,%0"
6517   [(set_attr "type" "fpalu")
6518    (set_attr "length" "4")])
6519
6520 (define_insn "abssf2"
6521   [(set (match_operand:SF 0 "register_operand" "=f")
6522         (abs:SF (match_operand:SF 1 "register_operand" "f")))]
6523   "! TARGET_SOFT_FLOAT"
6524   "fabs,sgl %1,%0"
6525   [(set_attr "type" "fpalu")
6526    (set_attr "length" "4")])
6527
6528 (define_insn "sqrtdf2"
6529   [(set (match_operand:DF 0 "register_operand" "=f")
6530         (sqrt:DF (match_operand:DF 1 "register_operand" "f")))]
6531   "! TARGET_SOFT_FLOAT"
6532   "fsqrt,dbl %1,%0"
6533   [(set_attr "type" "fpsqrtdbl")
6534    (set_attr "length" "4")])
6535
6536 (define_insn "sqrtsf2"
6537   [(set (match_operand:SF 0 "register_operand" "=f")
6538         (sqrt:SF (match_operand:SF 1 "register_operand" "f")))]
6539   "! TARGET_SOFT_FLOAT"
6540   "fsqrt,sgl %1,%0"
6541   [(set_attr "type" "fpsqrtsgl")
6542    (set_attr "length" "4")])
6543
6544 ;; PA 2.0 floating point instructions
6545
6546 ; fmpyfadd patterns
6547 (define_insn ""
6548   [(set (match_operand:DF 0 "register_operand" "=f")
6549         (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
6550                           (match_operand:DF 2 "register_operand" "f"))
6551                  (match_operand:DF 3 "register_operand" "f")))]
6552   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6553   "fmpyfadd,dbl %1,%2,%3,%0"
6554   [(set_attr "type" "fpmuldbl")
6555    (set_attr "length" "4")])
6556
6557 (define_insn ""
6558   [(set (match_operand:DF 0 "register_operand" "=f")
6559         (plus:DF (match_operand:DF 1 "register_operand" "f")
6560                  (mult:DF (match_operand:DF 2 "register_operand" "f")
6561                           (match_operand:DF 3 "register_operand" "f"))))]
6562   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6563   "fmpyfadd,dbl %2,%3,%1,%0"
6564   [(set_attr "type" "fpmuldbl")
6565    (set_attr "length" "4")])
6566
6567 (define_insn ""
6568   [(set (match_operand:SF 0 "register_operand" "=f")
6569         (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
6570                           (match_operand:SF 2 "register_operand" "f"))
6571                  (match_operand:SF 3 "register_operand" "f")))]
6572   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6573   "fmpyfadd,sgl %1,%2,%3,%0"
6574   [(set_attr "type" "fpmulsgl")
6575    (set_attr "length" "4")])
6576
6577 (define_insn ""
6578   [(set (match_operand:SF 0 "register_operand" "=f")
6579         (plus:SF (match_operand:SF 1 "register_operand" "f")
6580                  (mult:SF (match_operand:SF 2 "register_operand" "f")
6581                           (match_operand:SF 3 "register_operand" "f"))))]
6582   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6583   "fmpyfadd,sgl %2,%3,%1,%0"
6584   [(set_attr "type" "fpmulsgl")
6585    (set_attr "length" "4")])
6586
6587 ; fmpynfadd patterns
6588 (define_insn ""
6589   [(set (match_operand:DF 0 "register_operand" "=f")
6590         (minus:DF (match_operand:DF 1 "register_operand" "f")
6591                   (mult:DF (match_operand:DF 2 "register_operand" "f")
6592                            (match_operand:DF 3 "register_operand" "f"))))]
6593   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6594   "fmpynfadd,dbl %2,%3,%1,%0"
6595   [(set_attr "type" "fpmuldbl")
6596    (set_attr "length" "4")])
6597
6598 (define_insn ""
6599   [(set (match_operand:SF 0 "register_operand" "=f")
6600         (minus:SF (match_operand:SF 1 "register_operand" "f")
6601                   (mult:SF (match_operand:SF 2 "register_operand" "f")
6602                            (match_operand:SF 3 "register_operand" "f"))))]
6603   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6604   "fmpynfadd,sgl %2,%3,%1,%0"
6605   [(set_attr "type" "fpmulsgl")
6606    (set_attr "length" "4")])
6607
6608 ; fnegabs patterns
6609 (define_insn ""
6610   [(set (match_operand:DF 0 "register_operand" "=f")
6611         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))]
6612   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6613   "fnegabs,dbl %1,%0"
6614   [(set_attr "type" "fpalu")
6615    (set_attr "length" "4")])
6616
6617 (define_insn ""
6618   [(set (match_operand:SF 0 "register_operand" "=f")
6619         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))]
6620   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6621   "fnegabs,sgl %1,%0"
6622   [(set_attr "type" "fpalu")
6623    (set_attr "length" "4")])
6624
6625 ;; Generating a fused multiply sequence is a win for this case as it will
6626 ;; reduce the latency for the fused case without impacting the plain
6627 ;; multiply case.
6628 ;;
6629 ;; Similar possibilities exist for fnegabs, shadd and other insns which
6630 ;; perform two operations with the result of the first feeding the second.
6631 (define_insn ""
6632   [(set (match_operand:DF 0 "register_operand" "=f")
6633         (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
6634                           (match_operand:DF 2 "register_operand" "f"))
6635                  (match_operand:DF 3 "register_operand" "f")))
6636    (set (match_operand:DF 4 "register_operand" "=&f")
6637         (mult:DF (match_dup 1) (match_dup 2)))]
6638   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6639     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
6640           || reg_overlap_mentioned_p (operands[4], operands[2])))"
6641   "#"
6642   [(set_attr "type" "fpmuldbl")
6643    (set_attr "length" "8")])
6644
6645 ;; We want to split this up during scheduling since we want both insns
6646 ;; to schedule independently.
6647 (define_split
6648   [(set (match_operand:DF 0 "register_operand" "")
6649         (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "")
6650                           (match_operand:DF 2 "register_operand" ""))
6651                  (match_operand:DF 3 "register_operand" "")))
6652    (set (match_operand:DF 4 "register_operand" "")
6653         (mult:DF (match_dup 1) (match_dup 2)))]
6654   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6655   [(set (match_dup 4) (mult:DF (match_dup 1) (match_dup 2)))
6656    (set (match_dup 0) (plus:DF (mult:DF (match_dup 1) (match_dup 2))
6657                                (match_dup 3)))]
6658   "")
6659
6660 (define_insn ""
6661   [(set (match_operand:SF 0 "register_operand" "=f")
6662         (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
6663                           (match_operand:SF 2 "register_operand" "f"))
6664                  (match_operand:SF 3 "register_operand" "f")))
6665    (set (match_operand:SF 4 "register_operand" "=&f")
6666         (mult:SF (match_dup 1) (match_dup 2)))]
6667   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6668     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
6669           || reg_overlap_mentioned_p (operands[4], operands[2])))"
6670   "#"
6671   [(set_attr "type" "fpmuldbl")
6672    (set_attr "length" "8")])
6673
6674 ;; We want to split this up during scheduling since we want both insns
6675 ;; to schedule independently.
6676 (define_split
6677   [(set (match_operand:SF 0 "register_operand" "")
6678         (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "")
6679                           (match_operand:SF 2 "register_operand" ""))
6680                  (match_operand:SF 3 "register_operand" "")))
6681    (set (match_operand:SF 4 "register_operand" "")
6682         (mult:SF (match_dup 1) (match_dup 2)))]
6683   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6684   [(set (match_dup 4) (mult:SF (match_dup 1) (match_dup 2)))
6685    (set (match_dup 0) (plus:SF (mult:SF (match_dup 1) (match_dup 2))
6686                                (match_dup 3)))]
6687   "")
6688
6689 ;; Negating a multiply can be faked by adding zero in a fused multiply-add
6690 ;; instruction.
6691 (define_insn ""
6692   [(set (match_operand:DF 0 "register_operand" "=f")
6693         (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
6694                          (match_operand:DF 2 "register_operand" "f"))))]
6695   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6696   "fmpynfadd,dbl %1,%2,%%fr0,%0"
6697   [(set_attr "type" "fpmuldbl")
6698    (set_attr "length" "4")])
6699
6700 (define_insn ""
6701   [(set (match_operand:SF 0 "register_operand" "=f")
6702         (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
6703                          (match_operand:SF 2 "register_operand" "f"))))]
6704   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6705   "fmpynfadd,sgl %1,%2,%%fr0,%0"
6706   [(set_attr "type" "fpmuldbl")
6707    (set_attr "length" "4")])
6708
6709 (define_insn ""
6710   [(set (match_operand:DF 0 "register_operand" "=f")
6711         (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
6712                          (match_operand:DF 2 "register_operand" "f"))))
6713    (set (match_operand:DF 3 "register_operand" "=&f")
6714         (mult:DF (match_dup 1) (match_dup 2)))]
6715   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6716     && ! (reg_overlap_mentioned_p (operands[3], operands[1])
6717           || reg_overlap_mentioned_p (operands[3], operands[2])))"
6718   "#"
6719   [(set_attr "type" "fpmuldbl")
6720    (set_attr "length" "8")])
6721
6722 (define_split
6723   [(set (match_operand:DF 0 "register_operand" "")
6724         (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "")
6725                          (match_operand:DF 2 "register_operand" ""))))
6726    (set (match_operand:DF 3 "register_operand" "")
6727         (mult:DF (match_dup 1) (match_dup 2)))]
6728   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6729   [(set (match_dup 3) (mult:DF (match_dup 1) (match_dup 2)))
6730    (set (match_dup 0) (neg:DF (mult:DF (match_dup 1) (match_dup 2))))]
6731   "")
6732
6733 (define_insn ""
6734   [(set (match_operand:SF 0 "register_operand" "=f")
6735         (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
6736                          (match_operand:SF 2 "register_operand" "f"))))
6737    (set (match_operand:SF 3 "register_operand" "=&f")
6738         (mult:SF (match_dup 1) (match_dup 2)))]
6739   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6740     && ! (reg_overlap_mentioned_p (operands[3], operands[1])
6741           || reg_overlap_mentioned_p (operands[3], operands[2])))"
6742   "#"
6743   [(set_attr "type" "fpmuldbl")
6744    (set_attr "length" "8")])
6745
6746 (define_split
6747   [(set (match_operand:SF 0 "register_operand" "")
6748         (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "")
6749                          (match_operand:SF 2 "register_operand" ""))))
6750    (set (match_operand:SF 3 "register_operand" "")
6751         (mult:SF (match_dup 1) (match_dup 2)))]
6752   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6753   [(set (match_dup 3) (mult:SF (match_dup 1) (match_dup 2)))
6754    (set (match_dup 0) (neg:SF (mult:SF (match_dup 1) (match_dup 2))))]
6755   "")
6756
6757 ;; Now fused multiplies with the result of the multiply negated.
6758 (define_insn ""
6759   [(set (match_operand:DF 0 "register_operand" "=f")
6760         (plus:DF (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
6761                                   (match_operand:DF 2 "register_operand" "f")))
6762                  (match_operand:DF 3 "register_operand" "f")))]
6763   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6764   "fmpynfadd,dbl %1,%2,%3,%0"
6765   [(set_attr "type" "fpmuldbl")
6766    (set_attr "length" "4")])
6767
6768 (define_insn ""
6769   [(set (match_operand:SF 0 "register_operand" "=f")
6770         (plus:SF (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
6771                          (match_operand:SF 2 "register_operand" "f")))
6772                  (match_operand:SF 3 "register_operand" "f")))]
6773   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6774   "fmpynfadd,sgl %1,%2,%3,%0"
6775   [(set_attr "type" "fpmuldbl")
6776    (set_attr "length" "4")])
6777
6778 (define_insn ""
6779   [(set (match_operand:DF 0 "register_operand" "=f")
6780         (plus:DF (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
6781                                   (match_operand:DF 2 "register_operand" "f")))
6782                  (match_operand:DF 3 "register_operand" "f")))
6783    (set (match_operand:DF 4 "register_operand" "=&f")
6784         (mult:DF (match_dup 1) (match_dup 2)))]
6785   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6786     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
6787           || reg_overlap_mentioned_p (operands[4], operands[2])))"
6788   "#"
6789   [(set_attr "type" "fpmuldbl")
6790    (set_attr "length" "8")])
6791
6792 (define_split
6793   [(set (match_operand:DF 0 "register_operand" "")
6794         (plus:DF (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "")
6795                                   (match_operand:DF 2 "register_operand" "")))
6796                  (match_operand:DF 3 "register_operand" "")))
6797    (set (match_operand:DF 4 "register_operand" "")
6798         (mult:DF (match_dup 1) (match_dup 2)))]
6799   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6800   [(set (match_dup 4) (mult:DF (match_dup 1) (match_dup 2)))
6801    (set (match_dup 0) (plus:DF (neg:DF (mult:DF (match_dup 1) (match_dup 2)))
6802                                (match_dup 3)))]
6803   "")
6804
6805 (define_insn ""
6806   [(set (match_operand:SF 0 "register_operand" "=f")
6807         (plus:SF (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
6808                                   (match_operand:SF 2 "register_operand" "f")))
6809                  (match_operand:SF 3 "register_operand" "f")))
6810    (set (match_operand:SF 4 "register_operand" "=&f")
6811         (mult:SF (match_dup 1) (match_dup 2)))]
6812   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6813     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
6814           || reg_overlap_mentioned_p (operands[4], operands[2])))"
6815   "#"
6816   [(set_attr "type" "fpmuldbl")
6817    (set_attr "length" "8")])
6818
6819 (define_split
6820   [(set (match_operand:SF 0 "register_operand" "")
6821         (plus:SF (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "")
6822                                   (match_operand:SF 2 "register_operand" "")))
6823                  (match_operand:SF 3 "register_operand" "")))
6824    (set (match_operand:SF 4 "register_operand" "")
6825         (mult:SF (match_dup 1) (match_dup 2)))]
6826   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6827   [(set (match_dup 4) (mult:SF (match_dup 1) (match_dup 2)))
6828    (set (match_dup 0) (plus:SF (neg:SF (mult:SF (match_dup 1) (match_dup 2)))
6829                                (match_dup 3)))]
6830   "")
6831
6832 (define_insn ""
6833   [(set (match_operand:DF 0 "register_operand" "=f")
6834         (minus:DF (match_operand:DF 3 "register_operand" "f")
6835                   (mult:DF (match_operand:DF 1 "register_operand" "f")
6836                            (match_operand:DF 2 "register_operand" "f"))))
6837    (set (match_operand:DF 4 "register_operand" "=&f")
6838         (mult:DF (match_dup 1) (match_dup 2)))]
6839   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6840     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
6841           || reg_overlap_mentioned_p (operands[4], operands[2])))"
6842   "#"
6843   [(set_attr "type" "fpmuldbl")
6844    (set_attr "length" "8")])
6845
6846 (define_split
6847   [(set (match_operand:DF 0 "register_operand" "")
6848         (minus:DF (match_operand:DF 3 "register_operand" "")
6849                   (mult:DF (match_operand:DF 1 "register_operand" "")
6850                            (match_operand:DF 2 "register_operand" ""))))
6851    (set (match_operand:DF 4 "register_operand" "")
6852         (mult:DF (match_dup 1) (match_dup 2)))]
6853   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6854   [(set (match_dup 4) (mult:DF (match_dup 1) (match_dup 2)))
6855    (set (match_dup 0) (minus:DF (match_dup 3)
6856                                 (mult:DF (match_dup 1) (match_dup 2))))]
6857   "")
6858
6859 (define_insn ""
6860   [(set (match_operand:SF 0 "register_operand" "=f")
6861         (minus:SF (match_operand:SF 3 "register_operand" "f")
6862                   (mult:SF (match_operand:SF 1 "register_operand" "f")
6863                            (match_operand:SF 2 "register_operand" "f"))))
6864    (set (match_operand:SF 4 "register_operand" "=&f")
6865         (mult:SF (match_dup 1) (match_dup 2)))]
6866   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6867     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
6868           || reg_overlap_mentioned_p (operands[4], operands[2])))"
6869   "#"
6870   [(set_attr "type" "fpmuldbl")
6871    (set_attr "length" "8")])
6872
6873 (define_split
6874   [(set (match_operand:SF 0 "register_operand" "")
6875         (minus:SF (match_operand:SF 3 "register_operand" "")
6876                   (mult:SF (match_operand:SF 1 "register_operand" "")
6877                            (match_operand:SF 2 "register_operand" ""))))
6878    (set (match_operand:SF 4 "register_operand" "")
6879         (mult:SF (match_dup 1) (match_dup 2)))]
6880   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6881   [(set (match_dup 4) (mult:SF (match_dup 1) (match_dup 2)))
6882    (set (match_dup 0) (minus:SF (match_dup 3)
6883                                 (mult:SF (match_dup 1) (match_dup 2))))]
6884   "")
6885
6886 (define_insn ""
6887   [(set (match_operand:DF 0 "register_operand" "=f")
6888         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))
6889    (set (match_operand:DF 2 "register_operand" "=&f") (abs:DF (match_dup 1)))]
6890   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6891     && ! reg_overlap_mentioned_p (operands[2], operands[1]))"
6892   "#"
6893   [(set_attr "type" "fpalu")
6894    (set_attr "length" "8")])
6895
6896 (define_split
6897   [(set (match_operand:DF 0 "register_operand" "")
6898         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" ""))))
6899    (set (match_operand:DF 2 "register_operand" "") (abs:DF (match_dup 1)))]
6900   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6901   [(set (match_dup 2) (abs:DF (match_dup 1)))
6902    (set (match_dup 0) (neg:DF (abs:DF (match_dup 1))))]
6903   "")
6904
6905 (define_insn ""
6906   [(set (match_operand:SF 0 "register_operand" "=f")
6907         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))
6908    (set (match_operand:SF 2 "register_operand" "=&f") (abs:SF (match_dup 1)))]
6909   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6910     && ! reg_overlap_mentioned_p (operands[2], operands[1]))"
6911   "#"
6912   [(set_attr "type" "fpalu")
6913    (set_attr "length" "8")])
6914
6915 (define_split
6916   [(set (match_operand:SF 0 "register_operand" "")
6917         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" ""))))
6918    (set (match_operand:SF 2 "register_operand" "") (abs:SF (match_dup 1)))]
6919   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6920   [(set (match_dup 2) (abs:SF (match_dup 1)))
6921    (set (match_dup 0) (neg:SF (abs:SF (match_dup 1))))]
6922   "")
6923 \f
6924 ;;- Shift instructions
6925
6926 ;; Optimized special case of shifting.
6927
6928 (define_insn ""
6929   [(set (match_operand:SI 0 "register_operand" "=r")
6930         (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
6931                      (const_int 24)))]
6932   ""
6933   "ldb%M1 %1,%0"
6934   [(set_attr "type" "load")
6935    (set_attr "length" "4")])
6936
6937 (define_insn ""
6938   [(set (match_operand:SI 0 "register_operand" "=r")
6939         (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
6940                      (const_int 16)))]
6941   ""
6942   "ldh%M1 %1,%0"
6943   [(set_attr "type" "load")
6944    (set_attr "length" "4")])
6945
6946 (define_insn ""
6947   [(set (match_operand:SI 0 "register_operand" "=r")
6948         (plus:SI (mult:SI (match_operand:SI 2 "register_operand" "r")
6949                           (match_operand:SI 3 "shadd_operand" ""))
6950                  (match_operand:SI 1 "register_operand" "r")))]
6951   ""
6952   "{sh%O3addl %2,%1,%0|shladd,l %2,%O3,%1,%0} "
6953   [(set_attr "type" "binary")
6954    (set_attr "length" "4")])
6955
6956 (define_insn ""
6957   [(set (match_operand:DI 0 "register_operand" "=r")
6958         (plus:DI (mult:DI (match_operand:DI 2 "register_operand" "r")
6959                           (match_operand:DI 3 "shadd_operand" ""))
6960                  (match_operand:DI 1 "register_operand" "r")))]
6961   "TARGET_64BIT"
6962   "shladd,l %2,%O3,%1,%0"
6963   [(set_attr "type" "binary")
6964    (set_attr "length" "4")])
6965
6966 (define_expand "ashlsi3"
6967   [(set (match_operand:SI 0 "register_operand" "")
6968         (ashift:SI (match_operand:SI 1 "lhs_lshift_operand" "")
6969                    (match_operand:SI 2 "arith32_operand" "")))]
6970   ""
6971   "
6972 {
6973   if (GET_CODE (operands[2]) != CONST_INT)
6974     {
6975       rtx temp = gen_reg_rtx (SImode);
6976       emit_insn (gen_subsi3 (temp, GEN_INT (31), operands[2]));
6977       if (GET_CODE (operands[1]) == CONST_INT)
6978         emit_insn (gen_zvdep_imm32 (operands[0], operands[1], temp));
6979       else
6980         emit_insn (gen_zvdep32 (operands[0], operands[1], temp));
6981       DONE;
6982     }
6983   /* Make sure both inputs are not constants,
6984      there are no patterns for that.  */
6985   operands[1] = force_reg (SImode, operands[1]);
6986 }")
6987
6988 (define_insn ""
6989   [(set (match_operand:SI 0 "register_operand" "=r")
6990         (ashift:SI (match_operand:SI 1 "register_operand" "r")
6991                    (match_operand:SI 2 "const_int_operand" "n")))]
6992   ""
6993   "{zdep|depw,z} %1,%P2,%L2,%0"
6994   [(set_attr "type" "shift")
6995    (set_attr "length" "4")])
6996
6997 ; Match cases of op1 a CONST_INT here that zvdep_imm32 doesn't handle.
6998 ; Doing it like this makes slightly better code since reload can
6999 ; replace a register with a known value in range -16..15 with a
7000 ; constant.  Ideally, we would like to merge zvdep32 and zvdep_imm32,
7001 ; but since we have no more CONST_OK... characters, that is not
7002 ; possible.
7003 (define_insn "zvdep32"
7004   [(set (match_operand:SI 0 "register_operand" "=r,r")
7005         (ashift:SI (match_operand:SI 1 "arith5_operand" "r,L")
7006                    (minus:SI (const_int 31)
7007                              (match_operand:SI 2 "register_operand" "q,q"))))]
7008   ""
7009   "@
7010    {zvdep %1,32,%0|depw,z %1,%%sar,32,%0}
7011    {zvdepi %1,32,%0|depwi,z %1,%%sar,32,%0}"
7012   [(set_attr "type" "shift,shift")
7013    (set_attr "length" "4,4")])
7014
7015 (define_insn "zvdep_imm32"
7016   [(set (match_operand:SI 0 "register_operand" "=r")
7017         (ashift:SI (match_operand:SI 1 "lhs_lshift_cint_operand" "")
7018                    (minus:SI (const_int 31)
7019                              (match_operand:SI 2 "register_operand" "q"))))]
7020   ""
7021   "*
7022 {
7023   int x = INTVAL (operands[1]);
7024   operands[2] = GEN_INT (4 + exact_log2 ((x >> 4) + 1));
7025   operands[1] = GEN_INT ((x & 0xf) - 0x10);
7026   return \"{zvdepi %1,%2,%0|depwi,z %1,%%sar,%2,%0}\";
7027 }"
7028   [(set_attr "type" "shift")
7029    (set_attr "length" "4")])
7030
7031 (define_insn "vdepi_ior"
7032   [(set (match_operand:SI 0 "register_operand" "=r")
7033         (ior:SI (ashift:SI (match_operand:SI 1 "const_int_operand" "")
7034                            (minus:SI (const_int 31)
7035                                      (match_operand:SI 2 "register_operand" "q")))
7036                 (match_operand:SI 3 "register_operand" "0")))]
7037   ; accept ...0001...1, can this be generalized?
7038   "exact_log2 (INTVAL (operands[1]) + 1) > 0"
7039   "*
7040 {
7041   int x = INTVAL (operands[1]);
7042   operands[2] = GEN_INT (exact_log2 (x + 1));
7043   return \"{vdepi -1,%2,%0|depwi -1,%%sar,%2,%0}\";
7044 }"
7045   [(set_attr "type" "shift")
7046    (set_attr "length" "4")])
7047
7048 (define_insn "vdepi_and"
7049   [(set (match_operand:SI 0 "register_operand" "=r")
7050         (and:SI (rotate:SI (match_operand:SI 1 "const_int_operand" "")
7051                            (minus:SI (const_int 31)
7052                                      (match_operand:SI 2 "register_operand" "q")))
7053                 (match_operand:SI 3 "register_operand" "0")))]
7054   ; this can be generalized...!
7055   "INTVAL (operands[1]) == -2"
7056   "*
7057 {
7058   int x = INTVAL (operands[1]);
7059   operands[2] = GEN_INT (exact_log2 ((~x) + 1));
7060   return \"{vdepi 0,%2,%0|depwi 0,%%sar,%2,%0}\";
7061 }"
7062   [(set_attr "type" "shift")
7063    (set_attr "length" "4")])
7064
7065 (define_expand "ashldi3"
7066   [(set (match_operand:DI 0 "register_operand" "")
7067         (ashift:DI (match_operand:DI 1 "lhs_lshift_operand" "")
7068                    (match_operand:DI 2 "arith32_operand" "")))]
7069   "TARGET_64BIT"
7070   "
7071 {
7072   if (GET_CODE (operands[2]) != CONST_INT)
7073     {
7074       rtx temp = gen_reg_rtx (DImode);
7075       emit_insn (gen_subdi3 (temp, GEN_INT (63), operands[2]));
7076       if (GET_CODE (operands[1]) == CONST_INT)
7077         emit_insn (gen_zvdep_imm64 (operands[0], operands[1], temp));
7078       else
7079         emit_insn (gen_zvdep64 (operands[0], operands[1], temp));
7080       DONE;
7081     }
7082   /* Make sure both inputs are not constants,
7083      there are no patterns for that.  */
7084   operands[1] = force_reg (DImode, operands[1]);
7085 }")
7086
7087 (define_insn ""
7088   [(set (match_operand:DI 0 "register_operand" "=r")
7089         (ashift:DI (match_operand:DI 1 "register_operand" "r")
7090                    (match_operand:DI 2 "const_int_operand" "n")))]
7091   "TARGET_64BIT"
7092   "depd,z %1,%p2,%Q2,%0"
7093   [(set_attr "type" "shift")
7094    (set_attr "length" "4")])
7095
7096 ; Match cases of op1 a CONST_INT here that zvdep_imm64 doesn't handle.
7097 ; Doing it like this makes slightly better code since reload can
7098 ; replace a register with a known value in range -16..15 with a
7099 ; constant.  Ideally, we would like to merge zvdep64 and zvdep_imm64,
7100 ; but since we have no more CONST_OK... characters, that is not
7101 ; possible.
7102 (define_insn "zvdep64"
7103   [(set (match_operand:DI 0 "register_operand" "=r,r")
7104         (ashift:DI (match_operand:DI 1 "arith5_operand" "r,L")
7105                    (minus:DI (const_int 63)
7106                              (match_operand:DI 2 "register_operand" "q,q"))))]
7107   "TARGET_64BIT"
7108   "@
7109    depd,z %1,%%sar,64,%0
7110    depdi,z %1,%%sar,64,%0"
7111   [(set_attr "type" "shift,shift")
7112    (set_attr "length" "4,4")])
7113
7114 (define_insn "zvdep_imm64"
7115   [(set (match_operand:DI 0 "register_operand" "=r")
7116         (ashift:DI (match_operand:DI 1 "lhs_lshift_cint_operand" "")
7117                    (minus:DI (const_int 63)
7118                              (match_operand:DI 2 "register_operand" "q"))))]
7119   "TARGET_64BIT"
7120   "*
7121 {
7122   int x = INTVAL (operands[1]);
7123   operands[2] = GEN_INT (4 + exact_log2 ((x >> 4) + 1));
7124   operands[1] = GEN_INT ((x & 0x1f) - 0x20);
7125   return \"depdi,z %1,%%sar,%2,%0\";
7126 }"
7127   [(set_attr "type" "shift")
7128    (set_attr "length" "4")])
7129
7130 (define_insn ""
7131   [(set (match_operand:DI 0 "register_operand" "=r")
7132         (ior:DI (ashift:DI (match_operand:DI 1 "const_int_operand" "")
7133                            (minus:DI (const_int 63)
7134                                      (match_operand:DI 2 "register_operand" "q")))
7135                 (match_operand:DI 3 "register_operand" "0")))]
7136   ; accept ...0001...1, can this be generalized?
7137   "TARGET_64BIT && exact_log2 (INTVAL (operands[1]) + 1) > 0"
7138   "*
7139 {
7140   int x = INTVAL (operands[1]);
7141   operands[2] = GEN_INT (exact_log2 (x + 1));
7142   return \"depdi -1,%%sar,%2,%0\";
7143 }"
7144   [(set_attr "type" "shift")
7145    (set_attr "length" "4")])
7146
7147 (define_insn ""
7148   [(set (match_operand:DI 0 "register_operand" "=r")
7149         (and:DI (rotate:DI (match_operand:DI 1 "const_int_operand" "")
7150                            (minus:DI (const_int 63)
7151                                      (match_operand:DI 2 "register_operand" "q")))
7152                 (match_operand:DI 3 "register_operand" "0")))]
7153   ; this can be generalized...!
7154   "TARGET_64BIT && INTVAL (operands[1]) == -2"
7155   "*
7156 {
7157   int x = INTVAL (operands[1]);
7158   operands[2] = GEN_INT (exact_log2 ((~x) + 1));
7159   return \"depdi 0,%%sar,%2,%0\";
7160 }"
7161   [(set_attr "type" "shift")
7162    (set_attr "length" "4")])
7163
7164 (define_expand "ashrsi3"
7165   [(set (match_operand:SI 0 "register_operand" "")
7166         (ashiftrt:SI (match_operand:SI 1 "register_operand" "")
7167                      (match_operand:SI 2 "arith32_operand" "")))]
7168   ""
7169   "
7170 {
7171   if (GET_CODE (operands[2]) != CONST_INT)
7172     {
7173       rtx temp = gen_reg_rtx (SImode);
7174       emit_insn (gen_subsi3 (temp, GEN_INT (31), operands[2]));
7175       emit_insn (gen_vextrs32 (operands[0], operands[1], temp));
7176       DONE;
7177     }
7178 }")
7179
7180 (define_insn ""
7181   [(set (match_operand:SI 0 "register_operand" "=r")
7182         (ashiftrt:SI (match_operand:SI 1 "register_operand" "r")
7183                      (match_operand:SI 2 "const_int_operand" "n")))]
7184   ""
7185   "{extrs|extrw,s} %1,%P2,%L2,%0"
7186   [(set_attr "type" "shift")
7187    (set_attr "length" "4")])
7188
7189 (define_insn "vextrs32"
7190   [(set (match_operand:SI 0 "register_operand" "=r")
7191         (ashiftrt:SI (match_operand:SI 1 "register_operand" "r")
7192                      (minus:SI (const_int 31)
7193                                (match_operand:SI 2 "register_operand" "q"))))]
7194   ""
7195   "{vextrs %1,32,%0|extrw,s %1,%%sar,32,%0}"
7196   [(set_attr "type" "shift")
7197    (set_attr "length" "4")])
7198
7199 (define_expand "ashrdi3"
7200   [(set (match_operand:DI 0 "register_operand" "")
7201         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
7202                      (match_operand:DI 2 "arith32_operand" "")))]
7203   "TARGET_64BIT"
7204   "
7205 {
7206   if (GET_CODE (operands[2]) != CONST_INT)
7207     {
7208       rtx temp = gen_reg_rtx (DImode);
7209       emit_insn (gen_subdi3 (temp, GEN_INT (63), operands[2]));
7210       emit_insn (gen_vextrs64 (operands[0], operands[1], temp));
7211       DONE;
7212     }
7213 }")
7214
7215 (define_insn ""
7216   [(set (match_operand:DI 0 "register_operand" "=r")
7217         (ashiftrt:DI (match_operand:DI 1 "register_operand" "r")
7218                      (match_operand:DI 2 "const_int_operand" "n")))]
7219   "TARGET_64BIT"
7220   "extrd,s %1,%p2,%Q2,%0"
7221   [(set_attr "type" "shift")
7222    (set_attr "length" "4")])
7223
7224 (define_insn "vextrs64"
7225   [(set (match_operand:DI 0 "register_operand" "=r")
7226         (ashiftrt:DI (match_operand:DI 1 "register_operand" "r")
7227                      (minus:DI (const_int 63)
7228                                (match_operand:DI 2 "register_operand" "q"))))]
7229   "TARGET_64BIT"
7230   "extrd,s %1,%%sar,64,%0"
7231   [(set_attr "type" "shift")
7232    (set_attr "length" "4")])
7233
7234 (define_insn "lshrsi3"
7235   [(set (match_operand:SI 0 "register_operand" "=r,r")
7236         (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
7237                      (match_operand:SI 2 "arith32_operand" "q,n")))]
7238   ""
7239   "@
7240    {vshd %%r0,%1,%0|shrpw %%r0,%1,%%sar,%0}
7241    {extru|extrw,u} %1,%P2,%L2,%0"
7242   [(set_attr "type" "shift")
7243    (set_attr "length" "4")])
7244
7245 (define_insn "lshrdi3"
7246   [(set (match_operand:DI 0 "register_operand" "=r,r")
7247         (lshiftrt:DI (match_operand:DI 1 "register_operand" "r,r")
7248                      (match_operand:DI 2 "arith32_operand" "q,n")))]
7249   "TARGET_64BIT"
7250   "@
7251    shrpd %%r0,%1,%%sar,%0
7252    extrd,u %1,%p2,%Q2,%0"
7253   [(set_attr "type" "shift")
7254    (set_attr "length" "4")])
7255
7256 (define_insn "rotrsi3"
7257   [(set (match_operand:SI 0 "register_operand" "=r,r")
7258         (rotatert:SI (match_operand:SI 1 "register_operand" "r,r")
7259                      (match_operand:SI 2 "arith32_operand" "q,n")))]
7260   ""
7261   "*
7262 {
7263   if (GET_CODE (operands[2]) == CONST_INT)
7264     {
7265       operands[2] = GEN_INT (INTVAL (operands[2]) & 31);
7266       return \"{shd|shrpw} %1,%1,%2,%0\";
7267     }
7268   else
7269     return \"{vshd %1,%1,%0|shrpw %1,%1,%%sar,%0}\";
7270 }"
7271   [(set_attr "type" "shift")
7272    (set_attr "length" "4")])
7273
7274 (define_expand "rotlsi3"
7275   [(set (match_operand:SI 0 "register_operand" "")
7276         (rotate:SI (match_operand:SI 1 "register_operand" "")
7277                    (match_operand:SI 2 "arith32_operand" "")))]
7278   ""
7279   "
7280 {
7281   if (GET_CODE (operands[2]) != CONST_INT)
7282     {
7283       rtx temp = gen_reg_rtx (SImode);
7284       emit_insn (gen_subsi3 (temp, GEN_INT (32), operands[2]));
7285       emit_insn (gen_rotrsi3 (operands[0], operands[1], temp));
7286       DONE;
7287     }
7288   /* Else expand normally.  */
7289 }")
7290
7291 (define_insn ""
7292   [(set (match_operand:SI 0 "register_operand" "=r")
7293         (rotate:SI (match_operand:SI 1 "register_operand" "r")
7294                    (match_operand:SI 2 "const_int_operand" "n")))]
7295   ""
7296   "*
7297 {
7298   operands[2] = GEN_INT ((32 - INTVAL (operands[2])) & 31);
7299   return \"{shd|shrpw} %1,%1,%2,%0\";
7300 }"
7301   [(set_attr "type" "shift")
7302    (set_attr "length" "4")])
7303
7304 (define_insn ""
7305   [(set (match_operand:SI 0 "register_operand" "=r")
7306         (match_operator:SI 5 "plus_xor_ior_operator"
7307           [(ashift:SI (match_operand:SI 1 "register_operand" "r")
7308                       (match_operand:SI 3 "const_int_operand" "n"))
7309            (lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
7310                         (match_operand:SI 4 "const_int_operand" "n"))]))]
7311   "INTVAL (operands[3]) + INTVAL (operands[4]) == 32"
7312   "{shd|shrpw} %1,%2,%4,%0"
7313   [(set_attr "type" "shift")
7314    (set_attr "length" "4")])
7315
7316 (define_insn ""
7317   [(set (match_operand:SI 0 "register_operand" "=r")
7318         (match_operator:SI 5 "plus_xor_ior_operator"
7319           [(lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
7320                         (match_operand:SI 4 "const_int_operand" "n"))
7321            (ashift:SI (match_operand:SI 1 "register_operand" "r")
7322                       (match_operand:SI 3 "const_int_operand" "n"))]))]
7323   "INTVAL (operands[3]) + INTVAL (operands[4]) == 32"
7324   "{shd|shrpw} %1,%2,%4,%0"
7325   [(set_attr "type" "shift")
7326    (set_attr "length" "4")])
7327
7328 (define_insn ""
7329   [(set (match_operand:SI 0 "register_operand" "=r")
7330         (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
7331                            (match_operand:SI 2 "const_int_operand" ""))
7332                 (match_operand:SI 3 "const_int_operand" "")))]
7333   "exact_log2 (1 + (INTVAL (operands[3]) >> (INTVAL (operands[2]) & 31))) > 0"
7334   "*
7335 {
7336   int cnt = INTVAL (operands[2]) & 31;
7337   operands[3] = GEN_INT (exact_log2 (1 + (INTVAL (operands[3]) >> cnt)));
7338   operands[2] = GEN_INT (31 - cnt);
7339   return \"{zdep|depw,z} %1,%2,%3,%0\";
7340 }"
7341   [(set_attr "type" "shift")
7342    (set_attr "length" "4")])
7343 \f
7344 ;; Unconditional and other jump instructions.
7345
7346 ;; This can only be used in a leaf function, so we do
7347 ;; not need to use the PIC register when generating PIC code.
7348 (define_insn "return"
7349   [(return)
7350    (use (reg:SI 2))
7351    (const_int 0)]
7352   "hppa_can_use_return_insn_p ()"
7353   "*
7354 {
7355   if (TARGET_PA_20)
7356     return \"bve%* (%%r2)\";
7357   return \"bv%* %%r0(%%r2)\";
7358 }"
7359   [(set_attr "type" "branch")
7360    (set_attr "length" "4")])
7361
7362 ;; Emit a different pattern for functions which have non-trivial
7363 ;; epilogues so as not to confuse jump and reorg.
7364 (define_insn "return_internal"
7365   [(return)
7366    (use (reg:SI 2))
7367    (const_int 1)]
7368   ""
7369   "*
7370 {
7371   if (TARGET_PA_20)
7372     return \"bve%* (%%r2)\";
7373   return \"bv%* %%r0(%%r2)\";
7374 }"
7375   [(set_attr "type" "branch")
7376    (set_attr "length" "4")])
7377
7378 ;; This is used for eh returns which bypass the return stub.
7379 (define_insn "return_external_pic"
7380   [(return)
7381    (clobber (reg:SI 1))
7382    (use (reg:SI 2))]
7383   "!TARGET_NO_SPACE_REGS
7384    && !TARGET_PA_20
7385    && flag_pic && current_function_calls_eh_return"
7386   "ldsid (%%sr0,%%r2),%%r1\;mtsp %%r1,%%sr0\;be%* 0(%%sr0,%%r2)"
7387   [(set_attr "type" "branch")
7388    (set_attr "length" "12")])
7389
7390 (define_expand "prologue"
7391   [(const_int 0)]
7392   ""
7393   "hppa_expand_prologue ();DONE;")
7394
7395 (define_expand "sibcall_epilogue"
7396   [(return)]
7397   ""
7398   "
7399 {
7400   hppa_expand_epilogue ();
7401   DONE;
7402 }")
7403
7404 (define_expand "epilogue"
7405   [(return)]
7406   ""
7407   "
7408 {
7409   /* Try to use the trivial return first.  Else use the full
7410      epilogue.  */
7411   if (hppa_can_use_return_insn_p ())
7412     emit_jump_insn (gen_return ());
7413   else
7414     {
7415       rtx x;
7416
7417       hppa_expand_epilogue ();
7418
7419       /* EH returns bypass the normal return stub.  Thus, we must do an
7420          interspace branch to return from functions that call eh_return.
7421          This is only a problem for returns from shared code on ports
7422          using space registers.  */
7423       if (!TARGET_NO_SPACE_REGS
7424           && !TARGET_PA_20
7425           && flag_pic && current_function_calls_eh_return)
7426         x = gen_return_external_pic ();
7427       else
7428         x = gen_return_internal ();
7429
7430       emit_jump_insn (x);
7431     }
7432   DONE;
7433 }")
7434
7435 ; Used by hppa_profile_hook to load the starting address of the current
7436 ; function; operand 1 contains the address of the label in operand 3
7437 (define_insn "load_offset_label_address"
7438   [(set (match_operand:SI 0 "register_operand" "=r")
7439         (plus:SI (match_operand:SI 1 "register_operand" "r")
7440                  (minus:SI (match_operand:SI 2 "" "")
7441                            (label_ref:SI (match_operand 3 "" "")))))]
7442   ""
7443   "ldo %2-%l3(%1),%0"
7444   [(set_attr "type" "multi")
7445    (set_attr "length" "4")])
7446
7447 ; Output a code label and load its address.
7448 (define_insn "lcla1"
7449   [(set (match_operand:SI 0 "register_operand" "=r")
7450         (label_ref:SI (match_operand 1 "" "")))
7451    (const_int 0)]
7452   "!TARGET_PA_20"
7453   "*
7454 {
7455   output_asm_insn (\"bl .+8,%0\;depi 0,31,2,%0\", operands);
7456   (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
7457                                      CODE_LABEL_NUMBER (operands[1]));
7458   return \"\";
7459 }"
7460   [(set_attr "type" "multi")
7461    (set_attr "length" "8")])
7462
7463 (define_insn "lcla2"
7464   [(set (match_operand:SI 0 "register_operand" "=r")
7465         (label_ref:SI (match_operand 1 "" "")))
7466    (const_int 0)]
7467   "TARGET_PA_20"
7468   "*
7469 {
7470   (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
7471                                      CODE_LABEL_NUMBER (operands[1]));
7472   return \"mfia %0\";
7473 }"
7474   [(set_attr "type" "move")
7475    (set_attr "length" "4")])
7476
7477 (define_insn "blockage"
7478   [(unspec_volatile [(const_int 2)] UNSPECV_BLOCKAGE)]
7479   ""
7480   ""
7481   [(set_attr "length" "0")])
7482
7483 (define_insn "jump"
7484   [(set (pc) (label_ref (match_operand 0 "" "")))]
7485   ""
7486   "*
7487 {
7488   /* An unconditional branch which can reach its target.  */
7489   if (get_attr_length (insn) < 16)
7490     return \"b%* %l0\";
7491
7492   return output_lbranch (operands[0], insn, 1);
7493 }"
7494   [(set_attr "type" "uncond_branch")
7495    (set_attr "pa_combine_type" "uncond_branch")
7496    (set (attr "length")
7497     (cond [(eq (symbol_ref "jump_in_call_delay (insn)") (const_int 1))
7498            (if_then_else (lt (abs (minus (match_dup 0)
7499                                          (plus (pc) (const_int 8))))
7500                              (const_int MAX_12BIT_OFFSET))
7501            (const_int 4)
7502            (const_int 8))
7503            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
7504                (const_int MAX_17BIT_OFFSET))
7505            (const_int 4)
7506            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
7507            (const_int 20)
7508            (eq (symbol_ref "flag_pic") (const_int 0))
7509            (const_int 16)]
7510           (const_int 24)))])
7511
7512 ;;; Hope this is only within a function...
7513 (define_insn "indirect_jump"
7514   [(set (pc) (match_operand 0 "register_operand" "r"))]
7515   "GET_MODE (operands[0]) == word_mode"
7516   "bv%* %%r0(%0)"
7517   [(set_attr "type" "branch")
7518    (set_attr "length" "4")])
7519
7520 ;;; An indirect jump can be optimized to a direct jump.  GAS for the
7521 ;;; SOM target doesn't allow branching to a label inside a function.
7522 ;;; We also don't correctly compute branch distances for labels
7523 ;;; outside the current function.  Thus, we use an indirect jump can't
7524 ;;; be optimized to a direct jump for all targets.  We assume that
7525 ;;; the branch target is in the same space (i.e., nested function
7526 ;;; jumping to a label in an outer function in the same translation
7527 ;;; unit).
7528 (define_expand "nonlocal_goto"
7529   [(use (match_operand 0 "general_operand" ""))
7530    (use (match_operand 1 "general_operand" ""))
7531    (use (match_operand 2 "general_operand" ""))
7532    (use (match_operand 3 "general_operand" ""))]
7533   ""
7534 {
7535   rtx lab = operands[1];
7536   rtx stack = operands[2];
7537   rtx fp = operands[3];
7538
7539   lab = copy_to_reg (lab);
7540
7541   emit_insn (gen_rtx_CLOBBER (VOIDmode,
7542                               gen_rtx_MEM (BLKmode,
7543                                            gen_rtx_SCRATCH (VOIDmode))));
7544   emit_insn (gen_rtx_CLOBBER (VOIDmode,
7545                               gen_rtx_MEM (BLKmode,
7546                                            hard_frame_pointer_rtx)));
7547
7548   /* Restore the frame pointer.  The virtual_stack_vars_rtx is saved
7549      instead of the hard_frame_pointer_rtx in the save area.  As a
7550      result, an extra instruction is needed to adjust for the offset
7551      of the virtual stack variables and the frame pointer.  */
7552   if (GET_CODE (fp) != REG)
7553     fp = force_reg (Pmode, fp);
7554   emit_move_insn (virtual_stack_vars_rtx, fp);
7555
7556   emit_stack_restore (SAVE_NONLOCAL, stack, NULL_RTX);
7557
7558   emit_insn (gen_rtx_USE (VOIDmode, hard_frame_pointer_rtx));
7559   emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
7560
7561   /* Nonlocal goto jumps are only used between functions in the same
7562      translation unit.  Thus, we can avoid the extra overhead of an
7563      interspace jump.  */
7564   emit_jump_insn (gen_indirect_goto (lab));
7565   emit_barrier ();
7566   DONE;
7567 })
7568
7569 (define_insn "indirect_goto"
7570   [(unspec [(match_operand 0 "register_operand" "=r")] UNSPEC_GOTO)]
7571   "GET_MODE (operands[0]) == word_mode"
7572   "bv%* %%r0(%0)"
7573   [(set_attr "type" "branch")
7574    (set_attr "length" "4")])
7575
7576 ;;; This jump is used in branch tables where the insn length is fixed.
7577 ;;; The length of this insn is adjusted if the delay slot is not filled.
7578 (define_insn "short_jump"
7579   [(set (pc) (label_ref (match_operand 0 "" "")))
7580    (const_int 0)]
7581   ""
7582   "b%* %l0%#"
7583   [(set_attr "type" "btable_branch")
7584    (set_attr "length" "4")])
7585
7586 ;; Subroutines of "casesi".
7587 ;; operand 0 is index
7588 ;; operand 1 is the minimum bound
7589 ;; operand 2 is the maximum bound - minimum bound + 1
7590 ;; operand 3 is CODE_LABEL for the table;
7591 ;; operand 4 is the CODE_LABEL to go to if index out of range.
7592
7593 (define_expand "casesi"
7594   [(match_operand:SI 0 "general_operand" "")
7595    (match_operand:SI 1 "const_int_operand" "")
7596    (match_operand:SI 2 "const_int_operand" "")
7597    (match_operand 3 "" "")
7598    (match_operand 4 "" "")]
7599   ""
7600   "
7601 {
7602   if (GET_CODE (operands[0]) != REG)
7603     operands[0] = force_reg (SImode, operands[0]);
7604
7605   if (operands[1] != const0_rtx)
7606     {
7607       rtx index = gen_reg_rtx (SImode);
7608
7609       operands[1] = GEN_INT (-INTVAL (operands[1]));
7610       if (!INT_14_BITS (operands[1]))
7611         operands[1] = force_reg (SImode, operands[1]);
7612       emit_insn (gen_addsi3 (index, operands[0], operands[1]));
7613       operands[0] = index;
7614     }
7615
7616   /* In 64bit mode we must make sure to wipe the upper bits of the register
7617      just in case the addition overflowed or we had random bits in the
7618      high part of the register.  */
7619   if (TARGET_64BIT)
7620     {
7621       rtx index = gen_reg_rtx (DImode);
7622
7623       emit_insn (gen_extendsidi2 (index, operands[0]));
7624       operands[0] = gen_rtx_SUBREG (SImode, index, 4);
7625     }
7626
7627   if (!INT_5_BITS (operands[2]))
7628     operands[2] = force_reg (SImode, operands[2]);
7629
7630   /* This branch prevents us finding an insn for the delay slot of the
7631      following vectored branch.  It might be possible to use the delay
7632      slot if an index value of -1 was used to transfer to the out-of-range
7633      label.  In order to do this, we would have to output the -1 vector
7634      element after the delay insn.  The casesi output code would have to
7635      check if the casesi insn is in a delay branch sequence and output
7636      the delay insn if one is found.  If this was done, then it might
7637      then be worthwhile to split the casesi patterns to improve scheduling.
7638      However, it's not clear that all this extra complexity is worth
7639      the effort.  */
7640   emit_insn (gen_cmpsi (operands[0], operands[2]));
7641   emit_jump_insn (gen_bgtu (operands[4]));
7642
7643   if (TARGET_BIG_SWITCH)
7644     {
7645       if (TARGET_64BIT)
7646         {
7647           rtx tmp1 = gen_reg_rtx (DImode);
7648           rtx tmp2 = gen_reg_rtx (DImode);
7649
7650           emit_jump_insn (gen_casesi64p (operands[0], operands[3],
7651                                          tmp1, tmp2));
7652         }
7653       else
7654         {
7655           rtx tmp1 = gen_reg_rtx (SImode);
7656
7657           if (flag_pic)
7658             {
7659               rtx tmp2 = gen_reg_rtx (SImode);
7660
7661               emit_jump_insn (gen_casesi32p (operands[0], operands[3],
7662                                              tmp1, tmp2));
7663             }
7664           else
7665             emit_jump_insn (gen_casesi32 (operands[0], operands[3], tmp1));
7666         }
7667     }
7668   else
7669     emit_jump_insn (gen_casesi0 (operands[0], operands[3]));
7670   DONE;
7671 }")
7672
7673 ;;; The rtl for this pattern doesn't accurately describe what the insn
7674 ;;; actually does, particularly when case-vector elements are exploded
7675 ;;; in pa_reorg.  However, the initial SET in these patterns must show
7676 ;;; the connection of the insn to the following jump table.
7677 (define_insn "casesi0"
7678   [(set (pc) (mem:SI (plus:SI
7679                        (mult:SI (match_operand:SI 0 "register_operand" "r")
7680                                 (const_int 4))
7681                        (label_ref (match_operand 1 "" "")))))]
7682   ""
7683   "blr,n %0,%%r0\;nop"
7684   [(set_attr "type" "multi")
7685    (set_attr "length" "8")])
7686
7687 ;;; 32-bit code, absolute branch table.
7688 (define_insn "casesi32"
7689   [(set (pc) (mem:SI (plus:SI
7690                        (mult:SI (match_operand:SI 0 "register_operand" "r")
7691                                 (const_int 4))
7692                        (label_ref (match_operand 1 "" "")))))
7693    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
7694   "!TARGET_64BIT && TARGET_BIG_SWITCH"
7695   "ldil L'%l1,%2\;ldo R'%l1(%2),%2\;{ldwx|ldw},s %0(%2),%2\;bv,n %%r0(%2)"
7696   [(set_attr "type" "multi")
7697    (set_attr "length" "16")])
7698
7699 ;;; 32-bit code, relative branch table.
7700 (define_insn "casesi32p"
7701   [(set (pc) (mem:SI (plus:SI
7702                        (mult:SI (match_operand:SI 0 "register_operand" "r")
7703                                 (const_int 4))
7704                        (label_ref (match_operand 1 "" "")))))
7705    (clobber (match_operand:SI 2 "register_operand" "=&a"))
7706    (clobber (match_operand:SI 3 "register_operand" "=&r"))]
7707   "!TARGET_64BIT && TARGET_BIG_SWITCH"
7708   "{bl .+8,%2\;depi 0,31,2,%2|mfia %2}\;ldo {16|20}(%2),%2\;\
7709 {ldwx|ldw},s %0(%2),%3\;{addl|add,l} %2,%3,%3\;bv,n %%r0(%3)"
7710   [(set_attr "type" "multi")
7711    (set (attr "length")
7712      (if_then_else (ne (symbol_ref "TARGET_PA_20") (const_int 0))
7713         (const_int 20)
7714         (const_int 24)))])
7715
7716 ;;; 64-bit code, 32-bit relative branch table.
7717 (define_insn "casesi64p"
7718   [(set (pc) (mem:DI (plus:DI
7719                        (mult:DI (sign_extend:DI
7720                                   (match_operand:SI 0 "register_operand" "r"))
7721                                 (const_int 8))
7722                        (label_ref (match_operand 1 "" "")))))
7723    (clobber (match_operand:DI 2 "register_operand" "=&r"))
7724    (clobber (match_operand:DI 3 "register_operand" "=&r"))]
7725   "TARGET_64BIT && TARGET_BIG_SWITCH"
7726   "mfia %2\;ldo 24(%2),%2\;ldw,s %0(%2),%3\;extrd,s %3,63,32,%3\;\
7727 add,l %2,%3,%3\;bv,n %%r0(%3)"
7728   [(set_attr "type" "multi")
7729    (set_attr "length" "24")])
7730
7731
7732 ;; Call patterns.
7733 ;;- jump to subroutine
7734
7735 (define_expand "call"
7736   [(parallel [(call (match_operand:SI 0 "" "")
7737                     (match_operand 1 "" ""))
7738               (clobber (reg:SI 2))])]
7739   ""
7740   "
7741 {
7742   rtx op, call_insn;
7743   rtx nb = operands[1];
7744
7745   if (TARGET_PORTABLE_RUNTIME)
7746     op = force_reg (SImode, XEXP (operands[0], 0));
7747   else
7748     op = XEXP (operands[0], 0);
7749
7750   if (TARGET_64BIT)
7751     {
7752       if (!virtuals_instantiated)
7753         emit_move_insn (arg_pointer_rtx,
7754                         gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
7755                                       GEN_INT (64)));
7756       else
7757         {
7758           /* The loop pass can generate new libcalls after the virtual
7759              registers are instantiated when fpregs are disabled because
7760              the only method that we have for doing DImode multiplication
7761              is with a libcall.  This could be trouble if we haven't
7762              allocated enough space for the outgoing arguments.  */
7763           gcc_assert (INTVAL (nb) <= current_function_outgoing_args_size);
7764
7765           emit_move_insn (arg_pointer_rtx,
7766                           gen_rtx_PLUS (word_mode, stack_pointer_rtx,
7767                                         GEN_INT (STACK_POINTER_OFFSET + 64)));
7768         }
7769     }
7770
7771   /* Use two different patterns for calls to explicitly named functions
7772      and calls through function pointers.  This is necessary as these two
7773      types of calls use different calling conventions, and CSE might try
7774      to change the named call into an indirect call in some cases (using
7775      two patterns keeps CSE from performing this optimization).
7776      
7777      We now use even more call patterns as there was a subtle bug in
7778      attempting to restore the pic register after a call using a simple
7779      move insn.  During reload, a instruction involving a pseudo register
7780      with no explicit dependence on the PIC register can be converted
7781      to an equivalent load from memory using the PIC register.  If we
7782      emit a simple move to restore the PIC register in the initial rtl
7783      generation, then it can potentially be repositioned during scheduling.
7784      and an instruction that eventually uses the PIC register may end up
7785      between the call and the PIC register restore.
7786      
7787      This only worked because there is a post call group of instructions
7788      that are scheduled with the call.  These instructions are included
7789      in the same basic block as the call.  However, calls can throw in
7790      C++ code and a basic block has to terminate at the call if the call
7791      can throw.  This results in the PIC register restore being scheduled
7792      independently from the call.  So, we now hide the save and restore
7793      of the PIC register in the call pattern until after reload.  Then,
7794      we split the moves out.  A small side benefit is that we now don't
7795      need to have a use of the PIC register in the return pattern and
7796      the final save/restore operation is not needed.
7797      
7798      I elected to just clobber %r4 in the PIC patterns and use it instead
7799      of trying to force hppa_pic_save_rtx () to a callee saved register.
7800      This might have required a new register class and constraint.  It
7801      was also simpler to just handle the restore from a register than a
7802      generic pseudo.  */
7803   if (TARGET_64BIT)
7804     {
7805       if (GET_CODE (op) == SYMBOL_REF)
7806         call_insn = emit_call_insn (gen_call_symref_64bit (op, nb));
7807       else
7808         {
7809           op = force_reg (word_mode, op);
7810           call_insn = emit_call_insn (gen_call_reg_64bit (op, nb));
7811         }
7812     }
7813   else
7814     {
7815       if (GET_CODE (op) == SYMBOL_REF)
7816         {
7817           if (flag_pic)
7818             call_insn = emit_call_insn (gen_call_symref_pic (op, nb));
7819           else
7820             call_insn = emit_call_insn (gen_call_symref (op, nb));
7821         }
7822       else
7823         {
7824           rtx tmpreg = gen_rtx_REG (word_mode, 22);
7825
7826           emit_move_insn (tmpreg, force_reg (word_mode, op));
7827           if (flag_pic)
7828             call_insn = emit_call_insn (gen_call_reg_pic (nb));
7829           else
7830             call_insn = emit_call_insn (gen_call_reg (nb));
7831         }
7832     }
7833
7834   DONE;
7835 }")
7836
7837 ;; We use function calls to set the attribute length of calls and millicode
7838 ;; calls.  This is necessary because of the large variety of call sequences.
7839 ;; Implementing the calculation in rtl is difficult as well as ugly.  As
7840 ;; we need the same calculation in several places, maintenance becomes a
7841 ;; nightmare.
7842 ;;
7843 ;; However, this has a subtle impact on branch shortening.  When the
7844 ;; expression used to set the length attribute of an instruction depends
7845 ;; on a relative address (e.g., pc or a branch address), genattrtab
7846 ;; notes that the insn's length is variable, and attempts to determine a
7847 ;; worst-case default length and code to compute an insn's current length.
7848
7849 ;; The use of a function call hides the variable dependence of our calls
7850 ;; and millicode calls.  The result is genattrtab doesn't treat the operation
7851 ;; as variable and it only generates code for the default case using our
7852 ;; function call.  Because of this, calls and millicode calls have a fixed
7853 ;; length in the branch shortening pass, and some branches will use a longer
7854 ;; code sequence than necessary.  However, the length of any given call
7855 ;; will still reflect its final code location and it may be shorter than
7856 ;; the initial length estimate.
7857
7858 ;; It's possible to trick genattrtab by adding an expression involving `pc'
7859 ;; in the set.  However, when genattrtab hits a function call in its attempt
7860 ;; to compute the default length, it marks the result as unknown and sets
7861 ;; the default result to MAX_INT ;-(  One possible fix that would allow
7862 ;; calls to participate in branch shortening would be to make the call to
7863 ;; insn_default_length a target option.  Then, we could massage unknown
7864 ;; results.  Another fix might be to change genattrtab so that it just does
7865 ;; the call in the variable case as it already does for the fixed case.
7866
7867 (define_insn "call_symref"
7868   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7869          (match_operand 1 "" "i"))
7870    (clobber (reg:SI 1))
7871    (clobber (reg:SI 2))
7872    (use (const_int 0))]
7873   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7874   "*
7875 {
7876   output_arg_descriptor (insn);
7877   return output_call (insn, operands[0], 0);
7878 }"
7879   [(set_attr "type" "call")
7880    (set (attr "length") (symbol_ref "attr_length_call (insn, 0)"))])
7881
7882 (define_insn "call_symref_pic"
7883   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7884          (match_operand 1 "" "i"))
7885    (clobber (reg:SI 1))
7886    (clobber (reg:SI 2))
7887    (clobber (reg:SI 4))
7888    (use (reg:SI 19))
7889    (use (const_int 0))]
7890   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7891   "*
7892 {
7893   output_arg_descriptor (insn);
7894   return output_call (insn, operands[0], 0);
7895 }"
7896   [(set_attr "type" "call")
7897    (set (attr "length")
7898         (plus (symbol_ref "attr_length_call (insn, 0)")
7899               (symbol_ref "attr_length_save_restore_dltp (insn)")))])
7900
7901 ;; Split out the PIC register save and restore after reload.  This is
7902 ;; done only if the function returns.  As the split is done after reload,
7903 ;; there are some situations in which we unnecessarily save and restore
7904 ;; %r4.  This happens when there is a single call and the PIC register
7905 ;; is "dead" after the call.  This isn't easy to fix as the usage of
7906 ;; the PIC register isn't completely determined until the reload pass.
7907 (define_split
7908   [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7909                     (match_operand 1 "" ""))
7910               (clobber (reg:SI 1))
7911               (clobber (reg:SI 2))
7912               (clobber (reg:SI 4))
7913               (use (reg:SI 19))
7914               (use (const_int 0))])]
7915   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT
7916    && reload_completed
7917    && !find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7918   [(set (reg:SI 4) (reg:SI 19))
7919    (parallel [(call (mem:SI (match_dup 0))
7920                     (match_dup 1))
7921               (clobber (reg:SI 1))
7922               (clobber (reg:SI 2))
7923               (use (reg:SI 19))
7924               (use (const_int 0))])
7925    (set (reg:SI 19) (reg:SI 4))]
7926   "")
7927
7928 ;; Remove the clobber of register 4 when optimizing.  This has to be
7929 ;; done with a peephole optimization rather than a split because the
7930 ;; split sequence for a call must be longer than one instruction.
7931 (define_peephole2
7932   [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7933                     (match_operand 1 "" ""))
7934               (clobber (reg:SI 1))
7935               (clobber (reg:SI 2))
7936               (clobber (reg:SI 4))
7937               (use (reg:SI 19))
7938               (use (const_int 0))])]
7939   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
7940   [(parallel [(call (mem:SI (match_dup 0))
7941                     (match_dup 1))
7942               (clobber (reg:SI 1))
7943               (clobber (reg:SI 2))
7944               (use (reg:SI 19))
7945               (use (const_int 0))])]
7946   "")
7947
7948 (define_insn "*call_symref_pic_post_reload"
7949   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7950          (match_operand 1 "" "i"))
7951    (clobber (reg:SI 1))
7952    (clobber (reg:SI 2))
7953    (use (reg:SI 19))
7954    (use (const_int 0))]
7955   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7956   "*
7957 {
7958   output_arg_descriptor (insn);
7959   return output_call (insn, operands[0], 0);
7960 }"
7961   [(set_attr "type" "call")
7962    (set (attr "length") (symbol_ref "attr_length_call (insn, 0)"))])
7963
7964 ;; This pattern is split if it is necessary to save and restore the
7965 ;; PIC register.
7966 (define_insn "call_symref_64bit"
7967   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7968          (match_operand 1 "" "i"))
7969    (clobber (reg:DI 1))
7970    (clobber (reg:DI 2))
7971    (clobber (reg:DI 4))
7972    (use (reg:DI 27))
7973    (use (reg:DI 29))
7974    (use (const_int 0))]
7975   "TARGET_64BIT"
7976   "*
7977 {
7978   output_arg_descriptor (insn);
7979   return output_call (insn, operands[0], 0);
7980 }"
7981   [(set_attr "type" "call")
7982    (set (attr "length")
7983         (plus (symbol_ref "attr_length_call (insn, 0)")
7984               (symbol_ref "attr_length_save_restore_dltp (insn)")))])
7985
7986 ;; Split out the PIC register save and restore after reload.  This is
7987 ;; done only if the function returns.  As the split is done after reload,
7988 ;; there are some situations in which we unnecessarily save and restore
7989 ;; %r4.  This happens when there is a single call and the PIC register
7990 ;; is "dead" after the call.  This isn't easy to fix as the usage of
7991 ;; the PIC register isn't completely determined until the reload pass.
7992 (define_split
7993   [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7994                     (match_operand 1 "" ""))
7995               (clobber (reg:DI 1))
7996               (clobber (reg:DI 2))
7997               (clobber (reg:DI 4))
7998               (use (reg:DI 27))
7999               (use (reg:DI 29))
8000               (use (const_int 0))])]
8001   "TARGET_64BIT
8002    && reload_completed
8003    && !find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8004   [(set (reg:DI 4) (reg:DI 27))
8005    (parallel [(call (mem:SI (match_dup 0))
8006                     (match_dup 1))
8007               (clobber (reg:DI 1))
8008               (clobber (reg:DI 2))
8009               (use (reg:DI 27))
8010               (use (reg:DI 29))
8011               (use (const_int 0))])
8012    (set (reg:DI 27) (reg:DI 4))]
8013   "")
8014
8015 ;; Remove the clobber of register 4 when optimizing.  This has to be
8016 ;; done with a peephole optimization rather than a split because the
8017 ;; split sequence for a call must be longer than one instruction.
8018 (define_peephole2
8019   [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8020                     (match_operand 1 "" ""))
8021               (clobber (reg:DI 1))
8022               (clobber (reg:DI 2))
8023               (clobber (reg:DI 4))
8024               (use (reg:DI 27))
8025               (use (reg:DI 29))
8026               (use (const_int 0))])]
8027   "TARGET_64BIT && reload_completed"
8028   [(parallel [(call (mem:SI (match_dup 0))
8029                     (match_dup 1))
8030               (clobber (reg:DI 1))
8031               (clobber (reg:DI 2))
8032               (use (reg:DI 27))
8033               (use (reg:DI 29))
8034               (use (const_int 0))])]
8035   "")
8036
8037 (define_insn "*call_symref_64bit_post_reload"
8038   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8039          (match_operand 1 "" "i"))
8040    (clobber (reg:DI 1))
8041    (clobber (reg:DI 2))
8042    (use (reg:DI 27))
8043    (use (reg:DI 29))
8044    (use (const_int 0))]
8045   "TARGET_64BIT"
8046   "*
8047 {
8048   output_arg_descriptor (insn);
8049   return output_call (insn, operands[0], 0);
8050 }"
8051   [(set_attr "type" "call")
8052    (set (attr "length") (symbol_ref "attr_length_call (insn, 0)"))])
8053
8054 (define_insn "call_reg"
8055   [(call (mem:SI (reg:SI 22))
8056          (match_operand 0 "" "i"))
8057    (clobber (reg:SI 1))
8058    (clobber (reg:SI 2))
8059    (use (const_int 1))]
8060   "!TARGET_64BIT"
8061   "*
8062 {
8063   return output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
8064 }"
8065   [(set_attr "type" "dyncall")
8066    (set (attr "length") (symbol_ref "attr_length_indirect_call (insn)"))])
8067
8068 ;; This pattern is split if it is necessary to save and restore the
8069 ;; PIC register.
8070 (define_insn "call_reg_pic"
8071   [(call (mem:SI (reg:SI 22))
8072          (match_operand 0 "" "i"))
8073    (clobber (reg:SI 1))
8074    (clobber (reg:SI 2))
8075    (clobber (reg:SI 4))
8076    (use (reg:SI 19))
8077    (use (const_int 1))]
8078   "!TARGET_64BIT"
8079   "*
8080 {
8081   return output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
8082 }"
8083   [(set_attr "type" "dyncall")
8084    (set (attr "length")
8085         (plus (symbol_ref "attr_length_indirect_call (insn)")
8086               (symbol_ref "attr_length_save_restore_dltp (insn)")))])
8087
8088 ;; Split out the PIC register save and restore after reload.  This is
8089 ;; done only if the function returns.  As the split is done after reload,
8090 ;; there are some situations in which we unnecessarily save and restore
8091 ;; %r4.  This happens when there is a single call and the PIC register
8092 ;; is "dead" after the call.  This isn't easy to fix as the usage of
8093 ;; the PIC register isn't completely determined until the reload pass.
8094 (define_split
8095   [(parallel [(call (mem:SI (reg:SI 22))
8096                     (match_operand 0 "" ""))
8097               (clobber (reg:SI 1))
8098               (clobber (reg:SI 2))
8099               (clobber (reg:SI 4))
8100               (use (reg:SI 19))
8101               (use (const_int 1))])]
8102   "!TARGET_64BIT
8103    && reload_completed
8104    && !find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8105   [(set (reg:SI 4) (reg:SI 19))
8106    (parallel [(call (mem:SI (reg:SI 22))
8107                     (match_dup 0))
8108               (clobber (reg:SI 1))
8109               (clobber (reg:SI 2))
8110               (use (reg:SI 19))
8111               (use (const_int 1))])
8112    (set (reg:SI 19) (reg:SI 4))]
8113   "")
8114
8115 ;; Remove the clobber of register 4 when optimizing.  This has to be
8116 ;; done with a peephole optimization rather than a split because the
8117 ;; split sequence for a call must be longer than one instruction.
8118 (define_peephole2
8119   [(parallel [(call (mem:SI (reg:SI 22))
8120                     (match_operand 0 "" ""))
8121               (clobber (reg:SI 1))
8122               (clobber (reg:SI 2))
8123               (clobber (reg:SI 4))
8124               (use (reg:SI 19))
8125               (use (const_int 1))])]
8126   "!TARGET_64BIT && reload_completed"
8127   [(parallel [(call (mem:SI (reg:SI 22))
8128                     (match_dup 0))
8129               (clobber (reg:SI 1))
8130               (clobber (reg:SI 2))
8131               (use (reg:SI 19))
8132               (use (const_int 1))])]
8133   "")
8134
8135 (define_insn "*call_reg_pic_post_reload"
8136   [(call (mem:SI (reg:SI 22))
8137          (match_operand 0 "" "i"))
8138    (clobber (reg:SI 1))
8139    (clobber (reg:SI 2))
8140    (use (reg:SI 19))
8141    (use (const_int 1))]
8142   "!TARGET_64BIT"
8143   "*
8144 {
8145   return output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
8146 }"
8147   [(set_attr "type" "dyncall")
8148    (set (attr "length") (symbol_ref "attr_length_indirect_call (insn)"))])
8149
8150 ;; This pattern is split if it is necessary to save and restore the
8151 ;; PIC register.
8152 (define_insn "call_reg_64bit"
8153   [(call (mem:SI (match_operand:DI 0 "register_operand" "r"))
8154          (match_operand 1 "" "i"))
8155    (clobber (reg:DI 2))
8156    (clobber (reg:DI 4))
8157    (use (reg:DI 27))
8158    (use (reg:DI 29))
8159    (use (const_int 1))]
8160   "TARGET_64BIT"
8161   "*
8162 {
8163   return output_indirect_call (insn, operands[0]);
8164 }"
8165   [(set_attr "type" "dyncall")
8166    (set (attr "length")
8167         (plus (symbol_ref "attr_length_indirect_call (insn)")
8168               (symbol_ref "attr_length_save_restore_dltp (insn)")))])
8169
8170 ;; Split out the PIC register save and restore after reload.  This is
8171 ;; done only if the function returns.  As the split is done after reload,
8172 ;; there are some situations in which we unnecessarily save and restore
8173 ;; %r4.  This happens when there is a single call and the PIC register
8174 ;; is "dead" after the call.  This isn't easy to fix as the usage of
8175 ;; the PIC register isn't completely determined until the reload pass.
8176 (define_split
8177   [(parallel [(call (mem:SI (match_operand 0 "register_operand" ""))
8178                     (match_operand 1 "" ""))
8179               (clobber (reg:DI 2))
8180               (clobber (reg:DI 4))
8181               (use (reg:DI 27))
8182               (use (reg:DI 29))
8183               (use (const_int 1))])]
8184   "TARGET_64BIT
8185    && reload_completed
8186    && !find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8187   [(set (reg:DI 4) (reg:DI 27))
8188    (parallel [(call (mem:SI (match_dup 0))
8189                     (match_dup 1))
8190               (clobber (reg:DI 2))
8191               (use (reg:DI 27))
8192               (use (reg:DI 29))
8193               (use (const_int 1))])
8194    (set (reg:DI 27) (reg:DI 4))]
8195   "")
8196
8197 ;; Remove the clobber of register 4 when optimizing.  This has to be
8198 ;; done with a peephole optimization rather than a split because the
8199 ;; split sequence for a call must be longer than one instruction.
8200 (define_peephole2
8201   [(parallel [(call (mem:SI (match_operand 0 "register_operand" ""))
8202                     (match_operand 1 "" ""))
8203               (clobber (reg:DI 2))
8204               (clobber (reg:DI 4))
8205               (use (reg:DI 27))
8206               (use (reg:DI 29))
8207               (use (const_int 1))])]
8208   "TARGET_64BIT && reload_completed"
8209   [(parallel [(call (mem:SI (match_dup 0))
8210                     (match_dup 1))
8211               (clobber (reg:DI 2))
8212               (use (reg:DI 27))
8213               (use (reg:DI 29))
8214               (use (const_int 1))])]
8215   "")
8216
8217 (define_insn "*call_reg_64bit_post_reload"
8218   [(call (mem:SI (match_operand:DI 0 "register_operand" "r"))
8219          (match_operand 1 "" "i"))
8220    (clobber (reg:DI 2))
8221    (use (reg:DI 27))
8222    (use (reg:DI 29))
8223    (use (const_int 1))]
8224   "TARGET_64BIT"
8225   "*
8226 {
8227   return output_indirect_call (insn, operands[0]);
8228 }"
8229   [(set_attr "type" "dyncall")
8230    (set (attr "length") (symbol_ref "attr_length_indirect_call (insn)"))])
8231
8232 (define_expand "call_value"
8233   [(parallel [(set (match_operand 0 "" "")
8234                    (call (match_operand:SI 1 "" "")
8235                          (match_operand 2 "" "")))
8236               (clobber (reg:SI 2))])]
8237   ""
8238   "
8239 {
8240   rtx op, call_insn;
8241   rtx dst = operands[0];
8242   rtx nb = operands[2];
8243
8244   if (TARGET_PORTABLE_RUNTIME)
8245     op = force_reg (SImode, XEXP (operands[1], 0));
8246   else
8247     op = XEXP (operands[1], 0);
8248
8249   if (TARGET_64BIT)
8250     {
8251       if (!virtuals_instantiated)
8252         emit_move_insn (arg_pointer_rtx,
8253                         gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
8254                                       GEN_INT (64)));
8255       else
8256         {
8257           /* The loop pass can generate new libcalls after the virtual
8258              registers are instantiated when fpregs are disabled because
8259              the only method that we have for doing DImode multiplication
8260              is with a libcall.  This could be trouble if we haven't
8261              allocated enough space for the outgoing arguments.  */
8262           gcc_assert (INTVAL (nb) <= current_function_outgoing_args_size);
8263
8264           emit_move_insn (arg_pointer_rtx,
8265                           gen_rtx_PLUS (word_mode, stack_pointer_rtx,
8266                                         GEN_INT (STACK_POINTER_OFFSET + 64)));
8267         }
8268     }
8269
8270   /* Use two different patterns for calls to explicitly named functions
8271      and calls through function pointers.  This is necessary as these two
8272      types of calls use different calling conventions, and CSE might try
8273      to change the named call into an indirect call in some cases (using
8274      two patterns keeps CSE from performing this optimization).
8275
8276      We now use even more call patterns as there was a subtle bug in
8277      attempting to restore the pic register after a call using a simple
8278      move insn.  During reload, a instruction involving a pseudo register
8279      with no explicit dependence on the PIC register can be converted
8280      to an equivalent load from memory using the PIC register.  If we
8281      emit a simple move to restore the PIC register in the initial rtl
8282      generation, then it can potentially be repositioned during scheduling.
8283      and an instruction that eventually uses the PIC register may end up
8284      between the call and the PIC register restore.
8285      
8286      This only worked because there is a post call group of instructions
8287      that are scheduled with the call.  These instructions are included
8288      in the same basic block as the call.  However, calls can throw in
8289      C++ code and a basic block has to terminate at the call if the call
8290      can throw.  This results in the PIC register restore being scheduled
8291      independently from the call.  So, we now hide the save and restore
8292      of the PIC register in the call pattern until after reload.  Then,
8293      we split the moves out.  A small side benefit is that we now don't
8294      need to have a use of the PIC register in the return pattern and
8295      the final save/restore operation is not needed.
8296      
8297      I elected to just clobber %r4 in the PIC patterns and use it instead
8298      of trying to force hppa_pic_save_rtx () to a callee saved register.
8299      This might have required a new register class and constraint.  It
8300      was also simpler to just handle the restore from a register than a
8301      generic pseudo.  */
8302   if (TARGET_64BIT)
8303     {
8304       if (GET_CODE (op) == SYMBOL_REF)
8305         call_insn = emit_call_insn (gen_call_val_symref_64bit (dst, op, nb));
8306       else
8307         {
8308           op = force_reg (word_mode, op);
8309           call_insn = emit_call_insn (gen_call_val_reg_64bit (dst, op, nb));
8310         }
8311     }
8312   else
8313     {
8314       if (GET_CODE (op) == SYMBOL_REF)
8315         {
8316           if (flag_pic)
8317             call_insn = emit_call_insn (gen_call_val_symref_pic (dst, op, nb));
8318           else
8319             call_insn = emit_call_insn (gen_call_val_symref (dst, op, nb));
8320         }
8321       else
8322         {
8323           rtx tmpreg = gen_rtx_REG (word_mode, 22);
8324
8325           emit_move_insn (tmpreg, force_reg (word_mode, op));
8326           if (flag_pic)
8327             call_insn = emit_call_insn (gen_call_val_reg_pic (dst, nb));
8328           else
8329             call_insn = emit_call_insn (gen_call_val_reg (dst, nb));
8330         }
8331     }
8332
8333   DONE;
8334 }")
8335
8336 (define_insn "call_val_symref"
8337   [(set (match_operand 0 "" "")
8338         (call (mem:SI (match_operand 1 "call_operand_address" ""))
8339               (match_operand 2 "" "i")))
8340    (clobber (reg:SI 1))
8341    (clobber (reg:SI 2))
8342    (use (const_int 0))]
8343   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8344   "*
8345 {
8346   output_arg_descriptor (insn);
8347   return output_call (insn, operands[1], 0);
8348 }"
8349   [(set_attr "type" "call")
8350    (set (attr "length") (symbol_ref "attr_length_call (insn, 0)"))])
8351
8352 (define_insn "call_val_symref_pic"
8353   [(set (match_operand 0 "" "")
8354         (call (mem:SI (match_operand 1 "call_operand_address" ""))
8355               (match_operand 2 "" "i")))
8356    (clobber (reg:SI 1))
8357    (clobber (reg:SI 2))
8358    (clobber (reg:SI 4))
8359    (use (reg:SI 19))
8360    (use (const_int 0))]
8361   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8362   "*
8363 {
8364   output_arg_descriptor (insn);
8365   return output_call (insn, operands[1], 0);
8366 }"
8367   [(set_attr "type" "call")
8368    (set (attr "length")
8369         (plus (symbol_ref "attr_length_call (insn, 0)")
8370               (symbol_ref "attr_length_save_restore_dltp (insn)")))])
8371
8372 ;; Split out the PIC register save and restore after reload.  This is
8373 ;; done only if the function returns.  As the split is done after reload,
8374 ;; there are some situations in which we unnecessarily save and restore
8375 ;; %r4.  This happens when there is a single call and the PIC register
8376 ;; is "dead" after the call.  This isn't easy to fix as the usage of
8377 ;; the PIC register isn't completely determined until the reload pass.
8378 (define_split
8379   [(parallel [(set (match_operand 0 "" "")
8380               (call (mem:SI (match_operand 1 "call_operand_address" ""))
8381                     (match_operand 2 "" "")))
8382               (clobber (reg:SI 1))
8383               (clobber (reg:SI 2))
8384               (clobber (reg:SI 4))
8385               (use (reg:SI 19))
8386               (use (const_int 0))])]
8387   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT
8388    && reload_completed
8389    && !find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8390   [(set (reg:SI 4) (reg:SI 19))
8391    (parallel [(set (match_dup 0)
8392               (call (mem:SI (match_dup 1))
8393                     (match_dup 2)))
8394               (clobber (reg:SI 1))
8395               (clobber (reg:SI 2))
8396               (use (reg:SI 19))
8397               (use (const_int 0))])
8398    (set (reg:SI 19) (reg:SI 4))]
8399   "")
8400
8401 ;; Remove the clobber of register 4 when optimizing.  This has to be
8402 ;; done with a peephole optimization rather than a split because the
8403 ;; split sequence for a call must be longer than one instruction.
8404 (define_peephole2
8405   [(parallel [(set (match_operand 0 "" "")
8406               (call (mem:SI (match_operand 1 "call_operand_address" ""))
8407                     (match_operand 2 "" "")))
8408               (clobber (reg:SI 1))
8409               (clobber (reg:SI 2))
8410               (clobber (reg:SI 4))
8411               (use (reg:SI 19))
8412               (use (const_int 0))])]
8413   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
8414   [(parallel [(set (match_dup 0)
8415               (call (mem:SI (match_dup 1))
8416                     (match_dup 2)))
8417               (clobber (reg:SI 1))
8418               (clobber (reg:SI 2))
8419               (use (reg:SI 19))
8420               (use (const_int 0))])]
8421   "")
8422
8423 (define_insn "*call_val_symref_pic_post_reload"
8424   [(set (match_operand 0 "" "")
8425         (call (mem:SI (match_operand 1 "call_operand_address" ""))
8426               (match_operand 2 "" "i")))
8427    (clobber (reg:SI 1))
8428    (clobber (reg:SI 2))
8429    (use (reg:SI 19))
8430    (use (const_int 0))]
8431   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8432   "*
8433 {
8434   output_arg_descriptor (insn);
8435   return output_call (insn, operands[1], 0);
8436 }"
8437   [(set_attr "type" "call")
8438    (set (attr "length") (symbol_ref "attr_length_call (insn, 0)"))])
8439
8440 ;; This pattern is split if it is necessary to save and restore the
8441 ;; PIC register.
8442 (define_insn "call_val_symref_64bit"
8443   [(set (match_operand 0 "" "")
8444         (call (mem:SI (match_operand 1 "call_operand_address" ""))
8445               (match_operand 2 "" "i")))
8446    (clobber (reg:DI 1))
8447    (clobber (reg:DI 2))
8448    (clobber (reg:DI 4))
8449    (use (reg:DI 27))
8450    (use (reg:DI 29))
8451    (use (const_int 0))]
8452   "TARGET_64BIT"
8453   "*
8454 {
8455   output_arg_descriptor (insn);
8456   return output_call (insn, operands[1], 0);
8457 }"
8458   [(set_attr "type" "call")
8459    (set (attr "length")
8460         (plus (symbol_ref "attr_length_call (insn, 0)")
8461               (symbol_ref "attr_length_save_restore_dltp (insn)")))])
8462
8463 ;; Split out the PIC register save and restore after reload.  This is
8464 ;; done only if the function returns.  As the split is done after reload,
8465 ;; there are some situations in which we unnecessarily save and restore
8466 ;; %r4.  This happens when there is a single call and the PIC register
8467 ;; is "dead" after the call.  This isn't easy to fix as the usage of
8468 ;; the PIC register isn't completely determined until the reload pass.
8469 (define_split
8470   [(parallel [(set (match_operand 0 "" "")
8471               (call (mem:SI (match_operand 1 "call_operand_address" ""))
8472                     (match_operand 2 "" "")))
8473               (clobber (reg:DI 1))
8474               (clobber (reg:DI 2))
8475               (clobber (reg:DI 4))
8476               (use (reg:DI 27))
8477               (use (reg:DI 29))
8478               (use (const_int 0))])]
8479   "TARGET_64BIT
8480    && reload_completed
8481    && !find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8482   [(set (reg:DI 4) (reg:DI 27))
8483    (parallel [(set (match_dup 0)
8484               (call (mem:SI (match_dup 1))
8485                     (match_dup 2)))
8486               (clobber (reg:DI 1))
8487               (clobber (reg:DI 2))
8488               (use (reg:DI 27))
8489               (use (reg:DI 29))
8490               (use (const_int 0))])
8491    (set (reg:DI 27) (reg:DI 4))]
8492   "")
8493
8494 ;; Remove the clobber of register 4 when optimizing.  This has to be
8495 ;; done with a peephole optimization rather than a split because the
8496 ;; split sequence for a call must be longer than one instruction.
8497 (define_peephole2
8498   [(parallel [(set (match_operand 0 "" "")
8499               (call (mem:SI (match_operand 1 "call_operand_address" ""))
8500                     (match_operand 2 "" "")))
8501               (clobber (reg:DI 1))
8502               (clobber (reg:DI 2))
8503               (clobber (reg:DI 4))
8504               (use (reg:DI 27))
8505               (use (reg:DI 29))
8506               (use (const_int 0))])]
8507   "TARGET_64BIT && reload_completed"
8508   [(parallel [(set (match_dup 0)
8509               (call (mem:SI (match_dup 1))
8510                     (match_dup 2)))
8511               (clobber (reg:DI 1))
8512               (clobber (reg:DI 2))
8513               (use (reg:DI 27))
8514               (use (reg:DI 29))
8515               (use (const_int 0))])]
8516   "")
8517
8518 (define_insn "*call_val_symref_64bit_post_reload"
8519   [(set (match_operand 0 "" "")
8520         (call (mem:SI (match_operand 1 "call_operand_address" ""))
8521               (match_operand 2 "" "i")))
8522    (clobber (reg:DI 1))
8523    (clobber (reg:DI 2))
8524    (use (reg:DI 27))
8525    (use (reg:DI 29))
8526    (use (const_int 0))]
8527   "TARGET_64BIT"
8528   "*
8529 {
8530   output_arg_descriptor (insn);
8531   return output_call (insn, operands[1], 0);
8532 }"
8533   [(set_attr "type" "call")
8534    (set (attr "length") (symbol_ref "attr_length_call (insn, 0)"))])
8535
8536 (define_insn "call_val_reg"
8537   [(set (match_operand 0 "" "")
8538         (call (mem:SI (reg:SI 22))
8539               (match_operand 1 "" "i")))
8540    (clobber (reg:SI 1))
8541    (clobber (reg:SI 2))
8542    (use (const_int 1))]
8543   "!TARGET_64BIT"
8544   "*
8545 {
8546   return output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
8547 }"
8548   [(set_attr "type" "dyncall")
8549    (set (attr "length") (symbol_ref "attr_length_indirect_call (insn)"))])
8550
8551 ;; This pattern is split if it is necessary to save and restore the
8552 ;; PIC register.
8553 (define_insn "call_val_reg_pic"
8554   [(set (match_operand 0 "" "")
8555         (call (mem:SI (reg:SI 22))
8556               (match_operand 1 "" "i")))
8557    (clobber (reg:SI 1))
8558    (clobber (reg:SI 2))
8559    (clobber (reg:SI 4))
8560    (use (reg:SI 19))
8561    (use (const_int 1))]
8562   "!TARGET_64BIT"
8563   "*
8564 {
8565   return output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
8566 }"
8567   [(set_attr "type" "dyncall")
8568    (set (attr "length")
8569         (plus (symbol_ref "attr_length_indirect_call (insn)")
8570               (symbol_ref "attr_length_save_restore_dltp (insn)")))])
8571
8572 ;; Split out the PIC register save and restore after reload.  This is
8573 ;; done only if the function returns.  As the split is done after reload,
8574 ;; there are some situations in which we unnecessarily save and restore
8575 ;; %r4.  This happens when there is a single call and the PIC register
8576 ;; is "dead" after the call.  This isn't easy to fix as the usage of
8577 ;; the PIC register isn't completely determined until the reload pass.
8578 (define_split
8579   [(parallel [(set (match_operand 0 "" "")
8580                    (call (mem:SI (reg:SI 22))
8581                          (match_operand 1 "" "")))
8582               (clobber (reg:SI 1))
8583               (clobber (reg:SI 2))
8584               (clobber (reg:SI 4))
8585               (use (reg:SI 19))
8586               (use (const_int 1))])]
8587   "!TARGET_64BIT
8588    && reload_completed
8589    && !find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8590   [(set (reg:SI 4) (reg:SI 19))
8591    (parallel [(set (match_dup 0)
8592                    (call (mem:SI (reg:SI 22))
8593                          (match_dup 1)))
8594               (clobber (reg:SI 1))
8595               (clobber (reg:SI 2))
8596               (use (reg:SI 19))
8597               (use (const_int 1))])
8598    (set (reg:SI 19) (reg:SI 4))]
8599   "")
8600
8601 ;; Remove the clobber of register 4 when optimizing.  This has to be
8602 ;; done with a peephole optimization rather than a split because the
8603 ;; split sequence for a call must be longer than one instruction.
8604 (define_peephole2
8605   [(parallel [(set (match_operand 0 "" "")
8606                    (call (mem:SI (reg:SI 22))
8607                          (match_operand 1 "" "")))
8608               (clobber (reg:SI 1))
8609               (clobber (reg:SI 2))
8610               (clobber (reg:SI 4))
8611               (use (reg:SI 19))
8612               (use (const_int 1))])]
8613   "!TARGET_64BIT && reload_completed"
8614   [(parallel [(set (match_dup 0)
8615                    (call (mem:SI (reg:SI 22))
8616                          (match_dup 1)))
8617               (clobber (reg:SI 1))
8618               (clobber (reg:SI 2))
8619               (use (reg:SI 19))
8620               (use (const_int 1))])]
8621   "")
8622
8623 (define_insn "*call_val_reg_pic_post_reload"
8624   [(set (match_operand 0 "" "")
8625         (call (mem:SI (reg:SI 22))
8626               (match_operand 1 "" "i")))
8627    (clobber (reg:SI 1))
8628    (clobber (reg:SI 2))
8629    (use (reg:SI 19))
8630    (use (const_int 1))]
8631   "!TARGET_64BIT"
8632   "*
8633 {
8634   return output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
8635 }"
8636   [(set_attr "type" "dyncall")
8637    (set (attr "length") (symbol_ref "attr_length_indirect_call (insn)"))])
8638
8639 ;; This pattern is split if it is necessary to save and restore the
8640 ;; PIC register.
8641 (define_insn "call_val_reg_64bit"
8642   [(set (match_operand 0 "" "")
8643         (call (mem:SI (match_operand:DI 1 "register_operand" "r"))
8644               (match_operand 2 "" "i")))
8645    (clobber (reg:DI 2))
8646    (clobber (reg:DI 4))
8647    (use (reg:DI 27))
8648    (use (reg:DI 29))
8649    (use (const_int 1))]
8650   "TARGET_64BIT"
8651   "*
8652 {
8653   return output_indirect_call (insn, operands[1]);
8654 }"
8655   [(set_attr "type" "dyncall")
8656    (set (attr "length")
8657         (plus (symbol_ref "attr_length_indirect_call (insn)")
8658               (symbol_ref "attr_length_save_restore_dltp (insn)")))])
8659
8660 ;; Split out the PIC register save and restore after reload.  This is
8661 ;; done only if the function returns.  As the split is done after reload,
8662 ;; there are some situations in which we unnecessarily save and restore
8663 ;; %r4.  This happens when there is a single call and the PIC register
8664 ;; is "dead" after the call.  This isn't easy to fix as the usage of
8665 ;; the PIC register isn't completely determined until the reload pass.
8666 (define_split
8667   [(parallel [(set (match_operand 0 "" "")
8668                    (call (mem:SI (match_operand:DI 1 "register_operand" ""))
8669                          (match_operand 2 "" "")))
8670               (clobber (reg:DI 2))
8671               (clobber (reg:DI 4))
8672               (use (reg:DI 27))
8673               (use (reg:DI 29))
8674               (use (const_int 1))])]
8675   "TARGET_64BIT
8676    && reload_completed
8677    && !find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8678   [(set (reg:DI 4) (reg:DI 27))
8679    (parallel [(set (match_dup 0)
8680                    (call (mem:SI (match_dup 1))
8681                          (match_dup 2)))
8682               (clobber (reg:DI 2))
8683               (use (reg:DI 27))
8684               (use (reg:DI 29))
8685               (use (const_int 1))])
8686    (set (reg:DI 27) (reg:DI 4))]
8687   "")
8688
8689 ;; Remove the clobber of register 4 when optimizing.  This has to be
8690 ;; done with a peephole optimization rather than a split because the
8691 ;; split sequence for a call must be longer than one instruction.
8692 (define_peephole2
8693   [(parallel [(set (match_operand 0 "" "")
8694                    (call (mem:SI (match_operand:DI 1 "register_operand" ""))
8695                          (match_operand 2 "" "")))
8696               (clobber (reg:DI 2))
8697               (clobber (reg:DI 4))
8698               (use (reg:DI 27))
8699               (use (reg:DI 29))
8700               (use (const_int 1))])]
8701   "TARGET_64BIT && reload_completed"
8702   [(parallel [(set (match_dup 0)
8703                    (call (mem:SI (match_dup 1))
8704                          (match_dup 2)))
8705               (clobber (reg:DI 2))
8706               (use (reg:DI 27))
8707               (use (reg:DI 29))
8708               (use (const_int 1))])]
8709   "")
8710
8711 (define_insn "*call_val_reg_64bit_post_reload"
8712   [(set (match_operand 0 "" "")
8713         (call (mem:SI (match_operand:DI 1 "register_operand" "r"))
8714               (match_operand 2 "" "i")))
8715    (clobber (reg:DI 2))
8716    (use (reg:DI 27))
8717    (use (reg:DI 29))
8718    (use (const_int 1))]
8719   "TARGET_64BIT"
8720   "*
8721 {
8722   return output_indirect_call (insn, operands[1]);
8723 }"
8724   [(set_attr "type" "dyncall")
8725    (set (attr "length") (symbol_ref "attr_length_indirect_call (insn)"))])
8726
8727 ;; Call subroutine returning any type.
8728
8729 (define_expand "untyped_call"
8730   [(parallel [(call (match_operand 0 "" "")
8731                     (const_int 0))
8732               (match_operand 1 "" "")
8733               (match_operand 2 "" "")])]
8734   ""
8735   "
8736 {
8737   int i;
8738
8739   emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
8740
8741   for (i = 0; i < XVECLEN (operands[2], 0); i++)
8742     {
8743       rtx set = XVECEXP (operands[2], 0, i);
8744       emit_move_insn (SET_DEST (set), SET_SRC (set));
8745     }
8746
8747   /* The optimizer does not know that the call sets the function value
8748      registers we stored in the result block.  We avoid problems by
8749      claiming that all hard registers are used and clobbered at this
8750      point.  */
8751   emit_insn (gen_blockage ());
8752
8753   DONE;
8754 }")
8755
8756 (define_expand "sibcall"
8757   [(call (match_operand:SI 0 "" "")
8758          (match_operand 1 "" ""))]
8759   "!TARGET_PORTABLE_RUNTIME"
8760   "
8761 {
8762   rtx op, call_insn;
8763   rtx nb = operands[1];
8764
8765   op = XEXP (operands[0], 0);
8766
8767   if (TARGET_64BIT)
8768     {
8769       if (!virtuals_instantiated)
8770         emit_move_insn (arg_pointer_rtx,
8771                         gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
8772                                       GEN_INT (64)));
8773       else
8774         {
8775           /* The loop pass can generate new libcalls after the virtual
8776              registers are instantiated when fpregs are disabled because
8777              the only method that we have for doing DImode multiplication
8778              is with a libcall.  This could be trouble if we haven't
8779              allocated enough space for the outgoing arguments.  */
8780           gcc_assert (INTVAL (nb) <= current_function_outgoing_args_size);
8781
8782           emit_move_insn (arg_pointer_rtx,
8783                           gen_rtx_PLUS (word_mode, stack_pointer_rtx,
8784                                         GEN_INT (STACK_POINTER_OFFSET + 64)));
8785         }
8786     }
8787
8788   /* Indirect sibling calls are not allowed.  */
8789   if (TARGET_64BIT)
8790     call_insn = gen_sibcall_internal_symref_64bit (op, operands[1]);
8791   else
8792     call_insn = gen_sibcall_internal_symref (op, operands[1]);
8793
8794   call_insn = emit_call_insn (call_insn);
8795
8796   if (TARGET_64BIT)
8797     use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), arg_pointer_rtx);
8798
8799   /* We don't have to restore the PIC register.  */
8800   if (flag_pic)
8801     use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
8802
8803   DONE;
8804 }")
8805
8806 (define_insn "sibcall_internal_symref"
8807   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8808          (match_operand 1 "" "i"))
8809    (clobber (reg:SI 1))
8810    (use (reg:SI 2))
8811    (use (const_int 0))]
8812   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8813   "*
8814 {
8815   output_arg_descriptor (insn);
8816   return output_call (insn, operands[0], 1);
8817 }"
8818   [(set_attr "type" "call")
8819    (set (attr "length") (symbol_ref "attr_length_call (insn, 1)"))])
8820
8821 (define_insn "sibcall_internal_symref_64bit"
8822   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8823          (match_operand 1 "" "i"))
8824    (clobber (reg:DI 1))
8825    (use (reg:DI 2))
8826    (use (const_int 0))]
8827   "TARGET_64BIT"
8828   "*
8829 {
8830   output_arg_descriptor (insn);
8831   return output_call (insn, operands[0], 1);
8832 }"
8833   [(set_attr "type" "call")
8834    (set (attr "length") (symbol_ref "attr_length_call (insn, 1)"))])
8835
8836 (define_expand "sibcall_value"
8837   [(set (match_operand 0 "" "")
8838                    (call (match_operand:SI 1 "" "")
8839                          (match_operand 2 "" "")))]
8840   "!TARGET_PORTABLE_RUNTIME"
8841   "
8842 {
8843   rtx op, call_insn;
8844   rtx nb = operands[1];
8845
8846   op = XEXP (operands[1], 0);
8847
8848   if (TARGET_64BIT)
8849     {
8850       if (!virtuals_instantiated)
8851         emit_move_insn (arg_pointer_rtx,
8852                         gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
8853                                       GEN_INT (64)));
8854       else
8855         {
8856           /* The loop pass can generate new libcalls after the virtual
8857              registers are instantiated when fpregs are disabled because
8858              the only method that we have for doing DImode multiplication
8859              is with a libcall.  This could be trouble if we haven't
8860              allocated enough space for the outgoing arguments.  */
8861           gcc_assert (INTVAL (nb) <= current_function_outgoing_args_size);
8862
8863           emit_move_insn (arg_pointer_rtx,
8864                           gen_rtx_PLUS (word_mode, stack_pointer_rtx,
8865                                         GEN_INT (STACK_POINTER_OFFSET + 64)));
8866         }
8867     }
8868
8869   /* Indirect sibling calls are not allowed.  */
8870   if (TARGET_64BIT)
8871     call_insn
8872       = gen_sibcall_value_internal_symref_64bit (operands[0], op, operands[2]);
8873   else
8874     call_insn
8875       = gen_sibcall_value_internal_symref (operands[0], op, operands[2]);
8876
8877   call_insn = emit_call_insn (call_insn);
8878
8879   if (TARGET_64BIT)
8880     use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), arg_pointer_rtx);
8881
8882   /* We don't have to restore the PIC register.  */
8883   if (flag_pic)
8884     use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
8885
8886   DONE;
8887 }")
8888
8889 (define_insn "sibcall_value_internal_symref"
8890   [(set (match_operand 0 "" "")
8891         (call (mem:SI (match_operand 1 "call_operand_address" ""))
8892               (match_operand 2 "" "i")))
8893    (clobber (reg:SI 1))
8894    (use (reg:SI 2))
8895    (use (const_int 0))]
8896   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8897   "*
8898 {
8899   output_arg_descriptor (insn);
8900   return output_call (insn, operands[1], 1);
8901 }"
8902   [(set_attr "type" "call")
8903    (set (attr "length") (symbol_ref "attr_length_call (insn, 1)"))])
8904
8905 (define_insn "sibcall_value_internal_symref_64bit"
8906   [(set (match_operand 0 "" "")
8907         (call (mem:SI (match_operand 1 "call_operand_address" ""))
8908               (match_operand 2 "" "i")))
8909    (clobber (reg:DI 1))
8910    (use (reg:DI 2))
8911    (use (const_int 0))]
8912   "TARGET_64BIT"
8913   "*
8914 {
8915   output_arg_descriptor (insn);
8916   return output_call (insn, operands[1], 1);
8917 }"
8918   [(set_attr "type" "call")
8919    (set (attr "length") (symbol_ref "attr_length_call (insn, 1)"))])
8920
8921 (define_insn "nop"
8922   [(const_int 0)]
8923   ""
8924   "nop"
8925   [(set_attr "type" "move")
8926    (set_attr "length" "4")])
8927
8928 ;; These are just placeholders so we know where branch tables
8929 ;; begin and end.
8930 (define_insn "begin_brtab"
8931   [(const_int 1)]
8932   ""
8933   "*
8934 {
8935   /* Only GAS actually supports this pseudo-op.  */
8936   if (TARGET_GAS)
8937     return \".begin_brtab\";
8938   else
8939     return \"\";
8940 }"
8941   [(set_attr "type" "move")
8942    (set_attr "length" "0")])
8943
8944 (define_insn "end_brtab"
8945   [(const_int 2)]
8946   ""
8947   "*
8948 {
8949   /* Only GAS actually supports this pseudo-op.  */
8950   if (TARGET_GAS)
8951     return \".end_brtab\";
8952   else
8953     return \"\";
8954 }"
8955   [(set_attr "type" "move")
8956    (set_attr "length" "0")])
8957
8958 ;;; EH does longjmp's from and within the data section.  Thus,
8959 ;;; an interspace branch is required for the longjmp implementation.
8960 ;;; Registers r1 and r2 are used as scratch registers for the jump
8961 ;;; when necessary.
8962 (define_expand "interspace_jump"
8963   [(parallel
8964      [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8965       (clobber (match_dup 1))])]
8966   ""
8967   "
8968 {
8969   operands[1] = gen_rtx_REG (word_mode, 2);
8970 }")
8971
8972 (define_insn ""
8973   [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8974   (clobber (reg:SI 2))]
8975   "TARGET_PA_20 && !TARGET_64BIT"
8976   "bve%* (%0)"
8977    [(set_attr "type" "branch")
8978     (set_attr "length" "4")])
8979
8980 (define_insn ""
8981   [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8982   (clobber (reg:SI 2))]
8983   "TARGET_NO_SPACE_REGS && !TARGET_64BIT"
8984   "be%* 0(%%sr4,%0)"
8985    [(set_attr "type" "branch")
8986     (set_attr "length" "4")])
8987
8988 (define_insn ""
8989   [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8990   (clobber (reg:SI 2))]
8991   "!TARGET_64BIT"
8992   "ldsid (%%sr0,%0),%%r2\;mtsp %%r2,%%sr0\;be%* 0(%%sr0,%0)"
8993    [(set_attr "type" "branch")
8994     (set_attr "length" "12")])
8995
8996 (define_insn ""
8997   [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8998   (clobber (reg:DI 2))]
8999   "TARGET_64BIT"
9000   "bve%* (%0)"
9001    [(set_attr "type" "branch")
9002     (set_attr "length" "4")])
9003
9004 (define_expand "builtin_longjmp"
9005   [(unspec_volatile [(match_operand 0 "register_operand" "r")] UNSPECV_LONGJMP)]
9006   ""
9007   "
9008 {
9009   /* The elements of the buffer are, in order:  */
9010   rtx fp = gen_rtx_MEM (Pmode, operands[0]);
9011   rtx lab = gen_rtx_MEM (Pmode, plus_constant (operands[0],
9012                          POINTER_SIZE / BITS_PER_UNIT));
9013   rtx stack = gen_rtx_MEM (Pmode, plus_constant (operands[0],
9014                            (POINTER_SIZE * 2) / BITS_PER_UNIT));
9015   rtx pv = gen_rtx_REG (Pmode, 1);
9016
9017   emit_insn (gen_rtx_CLOBBER (VOIDmode,
9018                               gen_rtx_MEM (BLKmode,
9019                                            gen_rtx_SCRATCH (VOIDmode))));
9020   emit_insn (gen_rtx_CLOBBER (VOIDmode,
9021                               gen_rtx_MEM (BLKmode,
9022                                            hard_frame_pointer_rtx)));
9023
9024   /* Restore the frame pointer.  The virtual_stack_vars_rtx is saved
9025      instead of the hard_frame_pointer_rtx in the save area.  We need
9026      to adjust for the offset between these two values when we have
9027      a nonlocal_goto pattern.  When we don't have a nonlocal_goto
9028      pattern, the receiver performs the adjustment.  */
9029 #ifdef HAVE_nonlocal_goto
9030   if (HAVE_nonlocal_goto)
9031     emit_move_insn (virtual_stack_vars_rtx, force_reg (Pmode, fp));
9032   else
9033 #endif
9034     emit_move_insn (hard_frame_pointer_rtx, fp);
9035
9036   /* This bit is the same as expand_builtin_longjmp.  */
9037   emit_stack_restore (SAVE_NONLOCAL, stack, NULL_RTX);
9038   emit_insn (gen_rtx_USE (VOIDmode, hard_frame_pointer_rtx));
9039   emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
9040
9041   /* Load the label we are jumping through into r1 so that we know
9042      where to look for it when we get back to setjmp's function for
9043      restoring the gp.  */
9044   emit_move_insn (pv, lab);
9045
9046   /* Prevent the insns above from being scheduled into the delay slot
9047      of the interspace jump because the space register could change.  */
9048   emit_insn (gen_blockage ());
9049
9050   emit_jump_insn (gen_interspace_jump (pv));
9051   emit_barrier ();
9052   DONE;
9053 }")
9054
9055 ;;; Operands 2 and 3 are assumed to be CONST_INTs.
9056 (define_expand "extzv"
9057   [(set (match_operand 0 "register_operand" "")
9058         (zero_extract (match_operand 1 "register_operand" "")
9059                       (match_operand 2 "uint32_operand" "")
9060                       (match_operand 3 "uint32_operand" "")))]
9061   ""
9062   "
9063 {
9064   HOST_WIDE_INT len = INTVAL (operands[2]);
9065   HOST_WIDE_INT pos = INTVAL (operands[3]);
9066
9067   /* PA extraction insns don't support zero length bitfields or fields
9068      extending beyond the left or right-most bits.  Also, we reject lengths
9069      equal to a word as they are better handled by the move patterns.  */
9070   if (len <= 0 || len >= BITS_PER_WORD || pos < 0 || pos + len > BITS_PER_WORD)
9071     FAIL;
9072
9073   /* From mips.md: extract_bit_field doesn't verify that our source
9074      matches the predicate, so check it again here.  */
9075   if (!register_operand (operands[1], VOIDmode))
9076     FAIL;
9077
9078   if (TARGET_64BIT)
9079     emit_insn (gen_extzv_64 (operands[0], operands[1],
9080                              operands[2], operands[3]));
9081   else
9082     emit_insn (gen_extzv_32 (operands[0], operands[1],
9083                              operands[2], operands[3]));
9084   DONE;
9085 }")
9086
9087 (define_insn "extzv_32"
9088   [(set (match_operand:SI 0 "register_operand" "=r")
9089         (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
9090                          (match_operand:SI 2 "uint5_operand" "")
9091                          (match_operand:SI 3 "uint5_operand" "")))]
9092   ""
9093   "{extru|extrw,u} %1,%3+%2-1,%2,%0"
9094   [(set_attr "type" "shift")
9095    (set_attr "length" "4")])
9096
9097 (define_insn ""
9098   [(set (match_operand:SI 0 "register_operand" "=r")
9099         (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
9100                          (const_int 1)
9101                          (match_operand:SI 2 "register_operand" "q")))]
9102   ""
9103   "{vextru %1,1,%0|extrw,u %1,%%sar,1,%0}"
9104   [(set_attr "type" "shift")
9105    (set_attr "length" "4")])
9106
9107 (define_insn "extzv_64"
9108   [(set (match_operand:DI 0 "register_operand" "=r")
9109         (zero_extract:DI (match_operand:DI 1 "register_operand" "r")
9110                          (match_operand:DI 2 "uint32_operand" "")
9111                          (match_operand:DI 3 "uint32_operand" "")))]
9112   "TARGET_64BIT"
9113   "extrd,u %1,%3+%2-1,%2,%0"
9114   [(set_attr "type" "shift")
9115    (set_attr "length" "4")])
9116
9117 (define_insn ""
9118   [(set (match_operand:DI 0 "register_operand" "=r")
9119         (zero_extract:DI (match_operand:DI 1 "register_operand" "r")
9120                          (const_int 1)
9121                          (match_operand:DI 2 "register_operand" "q")))]
9122   "TARGET_64BIT"
9123   "extrd,u %1,%%sar,1,%0"
9124   [(set_attr "type" "shift")
9125    (set_attr "length" "4")])
9126
9127 ;;; Operands 2 and 3 are assumed to be CONST_INTs.
9128 (define_expand "extv"
9129   [(set (match_operand 0 "register_operand" "")
9130         (sign_extract (match_operand 1 "register_operand" "")
9131                       (match_operand 2 "uint32_operand" "")
9132                       (match_operand 3 "uint32_operand" "")))]
9133   ""
9134   "
9135 {
9136   HOST_WIDE_INT len = INTVAL (operands[2]);
9137   HOST_WIDE_INT pos = INTVAL (operands[3]);
9138
9139   /* PA extraction insns don't support zero length bitfields or fields
9140      extending beyond the left or right-most bits.  Also, we reject lengths
9141      equal to a word as they are better handled by the move patterns.  */
9142   if (len <= 0 || len >= BITS_PER_WORD || pos < 0 || pos + len > BITS_PER_WORD)
9143     FAIL;
9144
9145   /* From mips.md: extract_bit_field doesn't verify that our source
9146      matches the predicate, so check it again here.  */
9147   if (!register_operand (operands[1], VOIDmode))
9148     FAIL;
9149
9150   if (TARGET_64BIT)
9151     emit_insn (gen_extv_64 (operands[0], operands[1],
9152                             operands[2], operands[3]));
9153   else
9154     emit_insn (gen_extv_32 (operands[0], operands[1],
9155                             operands[2], operands[3]));
9156   DONE;
9157 }")
9158
9159 (define_insn "extv_32"
9160   [(set (match_operand:SI 0 "register_operand" "=r")
9161         (sign_extract:SI (match_operand:SI 1 "register_operand" "r")
9162                          (match_operand:SI 2 "uint5_operand" "")
9163                          (match_operand:SI 3 "uint5_operand" "")))]
9164   ""
9165   "{extrs|extrw,s} %1,%3+%2-1,%2,%0"
9166   [(set_attr "type" "shift")
9167    (set_attr "length" "4")])
9168
9169 (define_insn ""
9170   [(set (match_operand:SI 0 "register_operand" "=r")
9171         (sign_extract:SI (match_operand:SI 1 "register_operand" "r")
9172                          (const_int 1)
9173                          (match_operand:SI 2 "register_operand" "q")))]
9174   "!TARGET_64BIT"
9175   "{vextrs %1,1,%0|extrw,s %1,%%sar,1,%0}"
9176   [(set_attr "type" "shift")
9177    (set_attr "length" "4")])
9178
9179 (define_insn "extv_64"
9180   [(set (match_operand:DI 0 "register_operand" "=r")
9181         (sign_extract:DI (match_operand:DI 1 "register_operand" "r")
9182                          (match_operand:DI 2 "uint32_operand" "")
9183                          (match_operand:DI 3 "uint32_operand" "")))]
9184   "TARGET_64BIT"
9185   "extrd,s %1,%3+%2-1,%2,%0"
9186   [(set_attr "type" "shift")
9187    (set_attr "length" "4")])
9188
9189 (define_insn ""
9190   [(set (match_operand:DI 0 "register_operand" "=r")
9191         (sign_extract:DI (match_operand:DI 1 "register_operand" "r")
9192                          (const_int 1)
9193                          (match_operand:DI 2 "register_operand" "q")))]
9194   "TARGET_64BIT"
9195   "extrd,s %1,%%sar,1,%0"
9196   [(set_attr "type" "shift")
9197    (set_attr "length" "4")])
9198
9199 ;;; Operands 1 and 2 are assumed to be CONST_INTs.
9200 (define_expand "insv"
9201   [(set (zero_extract (match_operand 0 "register_operand" "")
9202                       (match_operand 1 "uint32_operand" "")
9203                       (match_operand 2 "uint32_operand" ""))
9204         (match_operand 3 "arith5_operand" ""))]
9205   ""
9206   "
9207 {
9208   HOST_WIDE_INT len = INTVAL (operands[1]);
9209   HOST_WIDE_INT pos = INTVAL (operands[2]);
9210
9211   /* PA insertion insns don't support zero length bitfields or fields
9212      extending beyond the left or right-most bits.  Also, we reject lengths
9213      equal to a word as they are better handled by the move patterns.  */
9214   if (len <= 0 || len >= BITS_PER_WORD || pos < 0 || pos + len > BITS_PER_WORD)
9215     FAIL;
9216
9217   /* From mips.md: insert_bit_field doesn't verify that our destination
9218      matches the predicate, so check it again here.  */
9219   if (!register_operand (operands[0], VOIDmode))
9220     FAIL;
9221
9222   if (TARGET_64BIT)
9223     emit_insn (gen_insv_64 (operands[0], operands[1],
9224                             operands[2], operands[3]));
9225   else
9226     emit_insn (gen_insv_32 (operands[0], operands[1],
9227                             operands[2], operands[3]));
9228   DONE;
9229 }")
9230
9231 (define_insn "insv_32"
9232   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r,r")
9233                          (match_operand:SI 1 "uint5_operand" "")
9234                          (match_operand:SI 2 "uint5_operand" ""))
9235         (match_operand:SI 3 "arith5_operand" "r,L"))]
9236   ""
9237   "@
9238    {dep|depw} %3,%2+%1-1,%1,%0
9239    {depi|depwi} %3,%2+%1-1,%1,%0"
9240   [(set_attr "type" "shift,shift")
9241    (set_attr "length" "4,4")])
9242
9243 ;; Optimize insertion of const_int values of type 1...1xxxx.
9244 (define_insn ""
9245   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
9246                          (match_operand:SI 1 "uint5_operand" "")
9247                          (match_operand:SI 2 "uint5_operand" ""))
9248         (match_operand:SI 3 "const_int_operand" ""))]
9249   "(INTVAL (operands[3]) & 0x10) != 0 &&
9250    (~INTVAL (operands[3]) & ((1L << INTVAL (operands[1])) - 1) & ~0xf) == 0"
9251   "*
9252 {
9253   operands[3] = GEN_INT ((INTVAL (operands[3]) & 0xf) - 0x10);
9254   return \"{depi|depwi} %3,%2+%1-1,%1,%0\";
9255 }"
9256   [(set_attr "type" "shift")
9257    (set_attr "length" "4")])
9258
9259 (define_insn "insv_64"
9260   [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+r,r")
9261                          (match_operand:DI 1 "uint32_operand" "")
9262                          (match_operand:DI 2 "uint32_operand" ""))
9263         (match_operand:DI 3 "arith32_operand" "r,L"))]
9264   "TARGET_64BIT"
9265   "@
9266    depd %3,%2+%1-1,%1,%0
9267    depdi %3,%2+%1-1,%1,%0"
9268   [(set_attr "type" "shift,shift")
9269    (set_attr "length" "4,4")])
9270
9271 ;; Optimize insertion of const_int values of type 1...1xxxx.
9272 (define_insn ""
9273   [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+r")
9274                          (match_operand:DI 1 "uint32_operand" "")
9275                          (match_operand:DI 2 "uint32_operand" ""))
9276         (match_operand:DI 3 "const_int_operand" ""))]
9277   "(INTVAL (operands[3]) & 0x10) != 0
9278    && TARGET_64BIT
9279    && (~INTVAL (operands[3]) & ((1L << INTVAL (operands[1])) - 1) & ~0xf) == 0"
9280   "*
9281 {
9282   operands[3] = GEN_INT ((INTVAL (operands[3]) & 0xf) - 0x10);
9283   return \"depdi %3,%2+%1-1,%1,%0\";
9284 }"
9285   [(set_attr "type" "shift")
9286    (set_attr "length" "4")])
9287
9288 (define_insn ""
9289   [(set (match_operand:DI 0 "register_operand" "=r")
9290         (ashift:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
9291                    (const_int 32)))]
9292   "TARGET_64BIT"
9293   "depd,z %1,31,32,%0"
9294   [(set_attr "type" "shift")
9295    (set_attr "length" "4")])
9296
9297 ;; This insn is used for some loop tests, typically loops reversed when
9298 ;; strength reduction is used.  It is actually created when the instruction
9299 ;; combination phase combines the special loop test.  Since this insn
9300 ;; is both a jump insn and has an output, it must deal with its own
9301 ;; reloads, hence the `m' constraints.  The `!' constraints direct reload
9302 ;; to not choose the register alternatives in the event a reload is needed.
9303 (define_insn "decrement_and_branch_until_zero"
9304   [(set (pc)
9305         (if_then_else
9306           (match_operator 2 "comparison_operator"
9307            [(plus:SI
9308               (match_operand:SI 0 "reg_before_reload_operand" "+!r,!*f,*m")
9309               (match_operand:SI 1 "int5_operand" "L,L,L"))
9310             (const_int 0)])
9311           (label_ref (match_operand 3 "" ""))
9312           (pc)))
9313    (set (match_dup 0)
9314         (plus:SI (match_dup 0) (match_dup 1)))
9315    (clobber (match_scratch:SI 4 "=X,r,r"))]
9316   ""
9317   "* return output_dbra (operands, insn, which_alternative); "
9318 ;; Do not expect to understand this the first time through.
9319 [(set_attr "type" "cbranch,multi,multi")
9320  (set (attr "length")
9321       (if_then_else (eq_attr "alternative" "0")
9322 ;; Loop counter in register case
9323 ;; Short branch has length of 4
9324 ;; Long branch has length of 8, 20, 24 or 28
9325         (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9326                (const_int MAX_12BIT_OFFSET))
9327            (const_int 4)
9328            (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9329                (const_int MAX_17BIT_OFFSET))
9330            (const_int 8)
9331            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9332            (const_int 24)
9333            (eq (symbol_ref "flag_pic") (const_int 0))
9334            (const_int 20)]
9335           (const_int 28))
9336
9337 ;; Loop counter in FP reg case.
9338 ;; Extra goo to deal with additional reload insns.
9339         (if_then_else (eq_attr "alternative" "1")
9340           (if_then_else (lt (match_dup 3) (pc))
9341              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 24))))
9342                       (const_int MAX_12BIT_OFFSET))
9343                     (const_int 24)
9344                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 24))))
9345                       (const_int MAX_17BIT_OFFSET))
9346                     (const_int 28)
9347                     (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9348                     (const_int 44)
9349                     (eq (symbol_ref "flag_pic") (const_int 0))
9350                     (const_int 40)]
9351                   (const_int 48))
9352              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9353                       (const_int MAX_12BIT_OFFSET))
9354                     (const_int 24)
9355                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9356                       (const_int MAX_17BIT_OFFSET))
9357                     (const_int 28)
9358                     (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9359                     (const_int 44)
9360                     (eq (symbol_ref "flag_pic") (const_int 0))
9361                     (const_int 40)]
9362                   (const_int 48)))
9363
9364 ;; Loop counter in memory case.
9365 ;; Extra goo to deal with additional reload insns.
9366         (if_then_else (lt (match_dup 3) (pc))
9367              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9368                       (const_int MAX_12BIT_OFFSET))
9369                     (const_int 12)
9370                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9371                       (const_int MAX_17BIT_OFFSET))
9372                     (const_int 16)
9373                     (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9374                     (const_int 32)
9375                     (eq (symbol_ref "flag_pic") (const_int 0))
9376                     (const_int 28)]
9377                   (const_int 36))
9378              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9379                       (const_int MAX_12BIT_OFFSET))
9380                     (const_int 12)
9381                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9382                       (const_int MAX_17BIT_OFFSET))
9383                     (const_int 16)
9384                     (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9385                     (const_int 32)
9386                     (eq (symbol_ref "flag_pic") (const_int 0))
9387                     (const_int 28)]
9388                   (const_int 36))))))])
9389
9390 (define_insn ""
9391   [(set (pc)
9392         (if_then_else
9393           (match_operator 2 "movb_comparison_operator"
9394            [(match_operand:SI 1 "register_operand" "r,r,r,r") (const_int 0)])
9395           (label_ref (match_operand 3 "" ""))
9396           (pc)))
9397    (set (match_operand:SI 0 "reg_before_reload_operand" "=!r,!*f,*m,!*q")
9398         (match_dup 1))]
9399   ""
9400 "* return output_movb (operands, insn, which_alternative, 0); "
9401 ;; Do not expect to understand this the first time through.
9402 [(set_attr "type" "cbranch,multi,multi,multi")
9403  (set (attr "length")
9404       (if_then_else (eq_attr "alternative" "0")
9405 ;; Loop counter in register case
9406 ;; Short branch has length of 4
9407 ;; Long branch has length of 8, 20, 24 or 28
9408         (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9409                (const_int MAX_12BIT_OFFSET))
9410            (const_int 4)
9411            (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9412                (const_int MAX_17BIT_OFFSET))
9413            (const_int 8)
9414            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9415            (const_int 24)
9416            (eq (symbol_ref "flag_pic") (const_int 0))
9417            (const_int 20)]
9418           (const_int 28))
9419
9420 ;; Loop counter in FP reg case.
9421 ;; Extra goo to deal with additional reload insns.
9422         (if_then_else (eq_attr "alternative" "1")
9423           (if_then_else (lt (match_dup 3) (pc))
9424              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9425                       (const_int MAX_12BIT_OFFSET))
9426                     (const_int 12)
9427                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9428                       (const_int MAX_17BIT_OFFSET))
9429                     (const_int 16)
9430                     (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9431                     (const_int 32)
9432                     (eq (symbol_ref "flag_pic") (const_int 0))
9433                     (const_int 28)]
9434                   (const_int 36))
9435              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9436                       (const_int MAX_12BIT_OFFSET))
9437                     (const_int 12)
9438                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9439                       (const_int MAX_17BIT_OFFSET))
9440                     (const_int 16)
9441                     (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9442                     (const_int 32)
9443                     (eq (symbol_ref "flag_pic") (const_int 0))
9444                     (const_int 28)]
9445                   (const_int 36)))
9446
9447 ;; Loop counter in memory or sar case.
9448 ;; Extra goo to deal with additional reload insns.
9449         (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9450                    (const_int MAX_12BIT_OFFSET))
9451                 (const_int 8)
9452                 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9453                   (const_int MAX_17BIT_OFFSET))
9454                 (const_int 12)
9455                 (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9456                 (const_int 28)
9457                 (eq (symbol_ref "flag_pic") (const_int 0))
9458                 (const_int 24)]
9459               (const_int 32)))))])
9460
9461 ;; Handle negated branch.
9462 (define_insn ""
9463   [(set (pc)
9464         (if_then_else
9465           (match_operator 2 "movb_comparison_operator"
9466            [(match_operand:SI 1 "register_operand" "r,r,r,r") (const_int 0)])
9467           (pc)
9468           (label_ref (match_operand 3 "" ""))))
9469    (set (match_operand:SI 0 "reg_before_reload_operand" "=!r,!*f,*m,!*q")
9470         (match_dup 1))]
9471   ""
9472 "* return output_movb (operands, insn, which_alternative, 1); "
9473 ;; Do not expect to understand this the first time through.
9474 [(set_attr "type" "cbranch,multi,multi,multi")
9475  (set (attr "length")
9476       (if_then_else (eq_attr "alternative" "0")
9477 ;; Loop counter in register case
9478 ;; Short branch has length of 4
9479 ;; Long branch has length of 8
9480         (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9481                (const_int MAX_12BIT_OFFSET))
9482            (const_int 4)
9483            (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9484                (const_int MAX_17BIT_OFFSET))
9485            (const_int 8)
9486            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9487            (const_int 24)
9488            (eq (symbol_ref "flag_pic") (const_int 0))
9489            (const_int 20)]
9490           (const_int 28))
9491
9492 ;; Loop counter in FP reg case.
9493 ;; Extra goo to deal with additional reload insns.
9494         (if_then_else (eq_attr "alternative" "1")
9495           (if_then_else (lt (match_dup 3) (pc))
9496              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9497                       (const_int MAX_12BIT_OFFSET))
9498                     (const_int 12)
9499                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9500                       (const_int MAX_17BIT_OFFSET))
9501                     (const_int 16)
9502                     (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9503                     (const_int 32)
9504                     (eq (symbol_ref "flag_pic") (const_int 0))
9505                     (const_int 28)]
9506                   (const_int 36))
9507              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9508                       (const_int MAX_12BIT_OFFSET))
9509                     (const_int 12)
9510                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9511                       (const_int MAX_17BIT_OFFSET))
9512                     (const_int 16)
9513                     (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9514                     (const_int 32)
9515                     (eq (symbol_ref "flag_pic") (const_int 0))
9516                     (const_int 28)]
9517                   (const_int 36)))
9518
9519 ;; Loop counter in memory or SAR case.
9520 ;; Extra goo to deal with additional reload insns.
9521         (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9522                    (const_int MAX_12BIT_OFFSET))
9523                 (const_int 8)
9524                 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9525                   (const_int MAX_17BIT_OFFSET))
9526                 (const_int 12)
9527                 (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9528                 (const_int 28)
9529                 (eq (symbol_ref "flag_pic") (const_int 0))
9530                 (const_int 24)]
9531               (const_int 32)))))])
9532
9533 (define_insn ""
9534   [(set (pc) (label_ref (match_operand 3 "" "" )))
9535    (set (match_operand:SI 0 "ireg_operand" "=r")
9536         (plus:SI (match_operand:SI 1 "ireg_operand" "r")
9537                  (match_operand:SI 2 "ireg_or_int5_operand" "rL")))]
9538   "(reload_completed && operands[0] == operands[1]) || operands[0] == operands[2]"
9539   "*
9540 {
9541   return output_parallel_addb (operands, insn);
9542 }"
9543 [(set_attr "type" "parallel_branch")
9544  (set (attr "length")
9545     (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9546                (const_int MAX_12BIT_OFFSET))
9547            (const_int 4)
9548            (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9549                (const_int MAX_17BIT_OFFSET))
9550            (const_int 8)
9551            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9552            (const_int 24)
9553            (eq (symbol_ref "flag_pic") (const_int 0))
9554            (const_int 20)]
9555           (const_int 28)))])
9556
9557 (define_insn ""
9558   [(set (pc) (label_ref (match_operand 2 "" "" )))
9559    (set (match_operand:SF 0 "ireg_operand" "=r")
9560         (match_operand:SF 1 "ireg_or_int5_operand" "rL"))]
9561   "reload_completed"
9562   "*
9563 {
9564   return output_parallel_movb (operands, insn);
9565 }"
9566 [(set_attr "type" "parallel_branch")
9567  (set (attr "length")
9568     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9569                (const_int MAX_12BIT_OFFSET))
9570            (const_int 4)
9571            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9572                (const_int MAX_17BIT_OFFSET))
9573            (const_int 8)
9574            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9575            (const_int 24)
9576            (eq (symbol_ref "flag_pic") (const_int 0))
9577            (const_int 20)]
9578           (const_int 28)))])
9579
9580 (define_insn ""
9581   [(set (pc) (label_ref (match_operand 2 "" "" )))
9582    (set (match_operand:SI 0 "ireg_operand" "=r")
9583         (match_operand:SI 1 "ireg_or_int5_operand" "rL"))]
9584   "reload_completed"
9585   "*
9586 {
9587   return output_parallel_movb (operands, insn);
9588 }"
9589 [(set_attr "type" "parallel_branch")
9590  (set (attr "length")
9591     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9592                (const_int MAX_12BIT_OFFSET))
9593            (const_int 4)
9594            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9595                (const_int MAX_17BIT_OFFSET))
9596            (const_int 8)
9597            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9598            (const_int 24)
9599            (eq (symbol_ref "flag_pic") (const_int 0))
9600            (const_int 20)]
9601           (const_int 28)))])
9602
9603 (define_insn ""
9604   [(set (pc) (label_ref (match_operand 2 "" "" )))
9605    (set (match_operand:HI 0 "ireg_operand" "=r")
9606         (match_operand:HI 1 "ireg_or_int5_operand" "rL"))]
9607   "reload_completed"
9608   "*
9609 {
9610   return output_parallel_movb (operands, insn);
9611 }"
9612 [(set_attr "type" "parallel_branch")
9613  (set (attr "length")
9614     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9615                (const_int MAX_12BIT_OFFSET))
9616            (const_int 4)
9617            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9618                (const_int MAX_17BIT_OFFSET))
9619            (const_int 8)
9620            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9621            (const_int 24)
9622            (eq (symbol_ref "flag_pic") (const_int 0))
9623            (const_int 20)]
9624           (const_int 28)))])
9625
9626 (define_insn ""
9627   [(set (pc) (label_ref (match_operand 2 "" "" )))
9628    (set (match_operand:QI 0 "ireg_operand" "=r")
9629         (match_operand:QI 1 "ireg_or_int5_operand" "rL"))]
9630   "reload_completed"
9631   "*
9632 {
9633   return output_parallel_movb (operands, insn);
9634 }"
9635 [(set_attr "type" "parallel_branch")
9636  (set (attr "length")
9637     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9638                (const_int MAX_12BIT_OFFSET))
9639            (const_int 4)
9640            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9641                (const_int MAX_17BIT_OFFSET))
9642            (const_int 8)
9643            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9644            (const_int 24)
9645            (eq (symbol_ref "flag_pic") (const_int 0))
9646            (const_int 20)]
9647           (const_int 28)))])
9648
9649 (define_insn ""
9650   [(set (match_operand 0 "register_operand" "=f")
9651         (mult (match_operand 1 "register_operand" "f")
9652               (match_operand 2 "register_operand" "f")))
9653    (set (match_operand 3 "register_operand" "+f")
9654         (plus (match_operand 4 "register_operand" "f")
9655               (match_operand 5 "register_operand" "f")))]
9656   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9657    && reload_completed && fmpyaddoperands (operands)"
9658   "*
9659 {
9660   if (GET_MODE (operands[0]) == DFmode)
9661     {
9662       if (rtx_equal_p (operands[3], operands[5]))
9663         return \"fmpyadd,dbl %1,%2,%0,%4,%3\";
9664       else
9665         return \"fmpyadd,dbl %1,%2,%0,%5,%3\";
9666     }
9667   else
9668     {
9669       if (rtx_equal_p (operands[3], operands[5]))
9670         return \"fmpyadd,sgl %1,%2,%0,%4,%3\";
9671       else
9672         return \"fmpyadd,sgl %1,%2,%0,%5,%3\";
9673     }
9674 }"
9675   [(set_attr "type" "fpalu")
9676    (set_attr "length" "4")])
9677
9678 (define_insn ""
9679   [(set (match_operand 3 "register_operand" "+f")
9680         (plus (match_operand 4 "register_operand" "f")
9681               (match_operand 5 "register_operand" "f")))
9682    (set (match_operand 0 "register_operand" "=f")
9683         (mult (match_operand 1 "register_operand" "f")
9684               (match_operand 2 "register_operand" "f")))]
9685   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9686    && reload_completed && fmpyaddoperands (operands)"
9687   "*
9688 {
9689   if (GET_MODE (operands[0]) == DFmode)
9690     {
9691       if (rtx_equal_p (operands[3], operands[5]))
9692         return \"fmpyadd,dbl %1,%2,%0,%4,%3\";
9693       else
9694         return \"fmpyadd,dbl %1,%2,%0,%5,%3\";
9695     }
9696   else
9697     {
9698       if (rtx_equal_p (operands[3], operands[5]))
9699         return \"fmpyadd,sgl %1,%2,%0,%4,%3\";
9700       else
9701         return \"fmpyadd,sgl %1,%2,%0,%5,%3\";
9702     }
9703 }"
9704   [(set_attr "type" "fpalu")
9705    (set_attr "length" "4")])
9706
9707 (define_insn ""
9708   [(set (match_operand 0 "register_operand" "=f")
9709         (mult (match_operand 1 "register_operand" "f")
9710               (match_operand 2 "register_operand" "f")))
9711    (set (match_operand 3 "register_operand" "+f")
9712         (minus (match_operand 4 "register_operand" "f")
9713                (match_operand 5 "register_operand" "f")))]
9714   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9715    && reload_completed && fmpysuboperands (operands)"
9716   "*
9717 {
9718   if (GET_MODE (operands[0]) == DFmode)
9719     return \"fmpysub,dbl %1,%2,%0,%5,%3\";
9720   else
9721     return \"fmpysub,sgl %1,%2,%0,%5,%3\";
9722 }"
9723   [(set_attr "type" "fpalu")
9724    (set_attr "length" "4")])
9725
9726 (define_insn ""
9727   [(set (match_operand 3 "register_operand" "+f")
9728         (minus (match_operand 4 "register_operand" "f")
9729                (match_operand 5 "register_operand" "f")))
9730    (set (match_operand 0 "register_operand" "=f")
9731         (mult (match_operand 1 "register_operand" "f")
9732               (match_operand 2 "register_operand" "f")))]
9733   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9734    && reload_completed && fmpysuboperands (operands)"
9735   "*
9736 {
9737   if (GET_MODE (operands[0]) == DFmode)
9738     return \"fmpysub,dbl %1,%2,%0,%5,%3\";
9739   else
9740     return \"fmpysub,sgl %1,%2,%0,%5,%3\";
9741 }"
9742   [(set_attr "type" "fpalu")
9743    (set_attr "length" "4")])
9744
9745 ;; Flush the I and D cache lines from the start address (operand0)
9746 ;; to the end address (operand1).  No lines are flushed if the end
9747 ;; address is less than the start address (unsigned).
9748 ;;
9749 ;; Because the range of memory flushed is variable and the size of
9750 ;; a MEM can only be a CONST_INT, the patterns specify that they
9751 ;; perform an unspecified volatile operation on all memory.
9752 ;;
9753 ;; The address range for an icache flush must lie within a single
9754 ;; space on targets with non-equivalent space registers.
9755 ;;
9756 ;; This is used by the trampoline code for nested functions.
9757 ;;
9758 ;; Operand 0 contains the start address.
9759 ;; Operand 1 contains the end address.
9760 ;; Operand 2 contains the line length to use.
9761 ;; Operands 3 and 4 (icacheflush) are clobbered scratch registers.
9762 (define_insn "dcacheflush"
9763   [(const_int 1)
9764    (unspec_volatile [(mem:BLK (scratch))] UNSPECV_DCACHE)
9765    (use (match_operand 0 "pmode_register_operand" "r"))
9766    (use (match_operand 1 "pmode_register_operand" "r"))
9767    (use (match_operand 2 "pmode_register_operand" "r"))
9768    (clobber (match_scratch 3 "=&0"))]
9769   ""
9770   "*
9771 {
9772   if (TARGET_64BIT)
9773     return \"cmpb,*<<=,n %3,%1,.\;fdc,m %2(%3)\;sync\";
9774   else
9775     return \"cmpb,<<=,n %3,%1,.\;fdc,m %2(%3)\;sync\";
9776 }"
9777   [(set_attr "type" "multi")
9778    (set_attr "length" "12")])
9779
9780 (define_insn "icacheflush"
9781   [(const_int 2)
9782    (unspec_volatile [(mem:BLK (scratch))] UNSPECV_ICACHE)
9783    (use (match_operand 0 "pmode_register_operand" "r"))
9784    (use (match_operand 1 "pmode_register_operand" "r"))
9785    (use (match_operand 2 "pmode_register_operand" "r"))
9786    (clobber (match_operand 3 "pmode_register_operand" "=&r"))
9787    (clobber (match_operand 4 "pmode_register_operand" "=&r"))
9788    (clobber (match_scratch 5 "=&0"))]
9789   ""
9790   "*
9791 {
9792   if (TARGET_64BIT)
9793     return \"mfsp %%sr0,%4\;ldsid (%5),%3\;mtsp %3,%%sr0\;cmpb,*<<=,n %5,%1,.\;fic,m %2(%%sr0,%5)\;sync\;mtsp %4,%%sr0\;nop\;nop\;nop\;nop\;nop\;nop\";
9794   else
9795     return \"mfsp %%sr0,%4\;ldsid (%5),%3\;mtsp %3,%%sr0\;cmpb,<<=,n %5,%1,.\;fic,m %2(%%sr0,%5)\;sync\;mtsp %4,%%sr0\;nop\;nop\;nop\;nop\;nop\;nop\";
9796 }"
9797   [(set_attr "type" "multi")
9798    (set_attr "length" "52")])
9799
9800 ;; An out-of-line prologue.
9801 (define_insn "outline_prologue_call"
9802   [(unspec_volatile [(const_int 0)] UNSPECV_OPC)
9803    (clobber (reg:SI 31))
9804    (clobber (reg:SI 22))
9805    (clobber (reg:SI 21))
9806    (clobber (reg:SI 20))
9807    (clobber (reg:SI 19))
9808    (clobber (reg:SI 1))]
9809   ""
9810   "*
9811 {
9812   extern int frame_pointer_needed;
9813
9814   /* We need two different versions depending on whether or not we
9815      need a frame pointer.   Also note that we return to the instruction
9816      immediately after the branch rather than two instructions after the
9817      break as normally is the case.  */
9818   if (frame_pointer_needed)
9819     {
9820       /* Must import the magic millicode routine(s).  */
9821       output_asm_insn (\".IMPORT __outline_prologue_fp,MILLICODE\", NULL);
9822
9823       if (TARGET_PORTABLE_RUNTIME)
9824         {
9825           output_asm_insn (\"ldil L'__outline_prologue_fp,%%r31\", NULL);
9826           output_asm_insn (\"ble,n R'__outline_prologue_fp(%%sr0,%%r31)\",
9827                            NULL);
9828         }
9829       else
9830         output_asm_insn (\"{bl|b,l},n __outline_prologue_fp,%%r31\", NULL);
9831     }
9832   else
9833     {
9834       /* Must import the magic millicode routine(s).  */
9835       output_asm_insn (\".IMPORT __outline_prologue,MILLICODE\", NULL);
9836
9837       if (TARGET_PORTABLE_RUNTIME)
9838         {
9839           output_asm_insn (\"ldil L'__outline_prologue,%%r31\", NULL);
9840           output_asm_insn (\"ble,n R'__outline_prologue(%%sr0,%%r31)\", NULL);
9841         }
9842       else
9843         output_asm_insn (\"{bl|b,l},n __outline_prologue,%%r31\", NULL);
9844     }
9845   return \"\";
9846 }"
9847   [(set_attr "type" "multi")
9848    (set_attr "length" "8")])
9849
9850 ;; An out-of-line epilogue.
9851 (define_insn "outline_epilogue_call"
9852   [(unspec_volatile [(const_int 1)] UNSPECV_OEC)
9853    (use (reg:SI 29))
9854    (use (reg:SI 28))
9855    (clobber (reg:SI 31))
9856    (clobber (reg:SI 22))
9857    (clobber (reg:SI 21))
9858    (clobber (reg:SI 20))
9859    (clobber (reg:SI 19))
9860    (clobber (reg:SI 2))
9861    (clobber (reg:SI 1))]
9862   ""
9863   "*
9864 {
9865   extern int frame_pointer_needed;
9866
9867   /* We need two different versions depending on whether or not we
9868      need a frame pointer.   Also note that we return to the instruction
9869      immediately after the branch rather than two instructions after the
9870      break as normally is the case.  */
9871   if (frame_pointer_needed)
9872     {
9873       /* Must import the magic millicode routine.  */
9874       output_asm_insn (\".IMPORT __outline_epilogue_fp,MILLICODE\", NULL);
9875
9876       /* The out-of-line prologue will make sure we return to the right
9877          instruction.  */
9878       if (TARGET_PORTABLE_RUNTIME)
9879         {
9880           output_asm_insn (\"ldil L'__outline_epilogue_fp,%%r31\", NULL);
9881           output_asm_insn (\"ble,n R'__outline_epilogue_fp(%%sr0,%%r31)\",
9882                            NULL);
9883         }
9884       else
9885         output_asm_insn (\"{bl|b,l},n __outline_epilogue_fp,%%r31\", NULL);
9886     }
9887   else
9888     {
9889       /* Must import the magic millicode routine.  */
9890       output_asm_insn (\".IMPORT __outline_epilogue,MILLICODE\", NULL);
9891
9892       /* The out-of-line prologue will make sure we return to the right
9893          instruction.  */
9894       if (TARGET_PORTABLE_RUNTIME)
9895         {
9896           output_asm_insn (\"ldil L'__outline_epilogue,%%r31\", NULL);
9897           output_asm_insn (\"ble,n R'__outline_epilogue(%%sr0,%%r31)\", NULL);
9898         }
9899       else
9900         output_asm_insn (\"{bl|b,l},n __outline_epilogue,%%r31\", NULL);
9901     }
9902   return \"\";
9903 }"
9904   [(set_attr "type" "multi")
9905    (set_attr "length" "8")])
9906
9907 ;; Given a function pointer, canonicalize it so it can be 
9908 ;; reliably compared to another function pointer.  */
9909 (define_expand "canonicalize_funcptr_for_compare"
9910   [(set (reg:SI 26) (match_operand:SI 1 "register_operand" ""))
9911    (parallel [(set (reg:SI 29) (unspec:SI [(reg:SI 26)] UNSPEC_CFFC))
9912               (clobber (match_dup 2))
9913               (clobber (reg:SI 26))
9914               (clobber (reg:SI 22))
9915               (clobber (reg:SI 31))])
9916    (set (match_operand:SI 0 "register_operand" "")
9917         (reg:SI 29))]
9918   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
9919   "
9920 {
9921   if (TARGET_ELF32)
9922     {
9923       rtx canonicalize_funcptr_for_compare_libfunc
9924         = init_one_libfunc (CANONICALIZE_FUNCPTR_FOR_COMPARE_LIBCALL);
9925
9926       emit_library_call_value (canonicalize_funcptr_for_compare_libfunc,
9927                                operands[0], LCT_NORMAL, Pmode,
9928                                1, operands[1], Pmode);
9929       DONE;
9930     }
9931
9932   operands[2] = gen_reg_rtx (SImode);
9933   if (GET_CODE (operands[1]) != REG)
9934     {
9935       rtx tmp = gen_reg_rtx (Pmode);
9936       emit_move_insn (tmp, operands[1]);
9937       operands[1] = tmp;
9938     }
9939 }")
9940
9941 (define_insn "*$$sh_func_adrs"
9942   [(set (reg:SI 29) (unspec:SI [(reg:SI 26)] UNSPEC_CFFC))
9943    (clobber (match_operand:SI 0 "register_operand" "=a"))
9944    (clobber (reg:SI 26))
9945    (clobber (reg:SI 22))
9946    (clobber (reg:SI 31))]
9947   "!TARGET_64BIT"
9948   "*
9949 {
9950   int length = get_attr_length (insn);
9951   rtx xoperands[2];
9952
9953   xoperands[0] = GEN_INT (length - 8);
9954   xoperands[1] = GEN_INT (length - 16);
9955
9956   /* Must import the magic millicode routine.  */
9957   output_asm_insn (\".IMPORT $$sh_func_adrs,MILLICODE\", NULL);
9958
9959   /* This is absolutely amazing.
9960
9961      First, copy our input parameter into %r29 just in case we don't
9962      need to call $$sh_func_adrs.  */
9963   output_asm_insn (\"copy %%r26,%%r29\", NULL);
9964   output_asm_insn (\"{extru|extrw,u} %%r26,31,2,%%r31\", NULL);
9965
9966   /* Next, examine the low two bits in %r26, if they aren't 0x2, then
9967      we use %r26 unchanged.  */
9968   output_asm_insn (\"{comib|cmpib},<>,n 2,%%r31,.+%0\", xoperands);
9969   output_asm_insn (\"ldi 4096,%%r31\", NULL);
9970
9971   /* Next, compare %r26 with 4096, if %r26 is less than or equal to
9972      4096, then again we use %r26 unchanged.  */
9973   output_asm_insn (\"{comb|cmpb},<<,n %%r26,%%r31,.+%1\", xoperands);
9974
9975   /* Finally, call $$sh_func_adrs to extract the function's real add24.  */
9976   return output_millicode_call (insn,
9977                                 gen_rtx_SYMBOL_REF (SImode,
9978                                                     \"$$sh_func_adrs\"));
9979 }"
9980   [(set_attr "type" "multi")
9981    (set (attr "length")
9982         (plus (symbol_ref "attr_length_millicode_call (insn)")
9983               (const_int 20)))])
9984
9985 ;; On the PA, the PIC register is call clobbered, so it must
9986 ;; be saved & restored around calls by the caller.  If the call
9987 ;; doesn't return normally (nonlocal goto, or an exception is
9988 ;; thrown), then the code at the exception handler label must
9989 ;; restore the PIC register.
9990 (define_expand "exception_receiver"
9991   [(const_int 4)]
9992   "flag_pic"
9993   "
9994 {
9995   /* On the 64-bit port, we need a blockage because there is
9996      confusion regarding the dependence of the restore on the
9997      frame pointer.  As a result, the frame pointer and pic
9998      register restores sometimes are interchanged erroneously.  */
9999   if (TARGET_64BIT)
10000     emit_insn (gen_blockage ());
10001   /* Restore the PIC register using hppa_pic_save_rtx ().  The
10002      PIC register is not saved in the frame in 64-bit ABI.  */
10003   emit_move_insn (pic_offset_table_rtx, hppa_pic_save_rtx ());
10004   emit_insn (gen_blockage ());
10005   DONE;
10006 }")
10007
10008 (define_expand "builtin_setjmp_receiver"
10009   [(label_ref (match_operand 0 "" ""))]
10010   "flag_pic"
10011   "
10012 {
10013   if (TARGET_64BIT)
10014     emit_insn (gen_blockage ());
10015   /* Restore the PIC register.  Hopefully, this will always be from
10016      a stack slot.  The only registers that are valid after a
10017      builtin_longjmp are the stack and frame pointers.  */
10018   emit_move_insn (pic_offset_table_rtx, hppa_pic_save_rtx ());
10019   emit_insn (gen_blockage ());
10020   DONE;
10021 }")
10022
10023 ;; Allocate new stack space and update the saved stack pointer in the
10024 ;; frame marker.  The HP C compilers also copy additional words in the
10025 ;; frame marker.  The 64-bit compiler copies words at -48, -32 and -24.
10026 ;; The 32-bit compiler copies the word at -16 (Static Link).  We
10027 ;; currently don't copy these values.
10028 ;;
10029 ;; Since the copy of the frame marker can't be done atomically, I
10030 ;; suspect that using it for unwind purposes may be somewhat unreliable.
10031 ;; The HP compilers appear to raise the stack and copy the frame
10032 ;; marker in a strict instruction sequence.  This suggests that the
10033 ;; unwind library may check for an alloca sequence when ALLOCA_FRAME
10034 ;; is set in the callinfo data.  We currently don't set ALLOCA_FRAME
10035 ;; as GAS doesn't support it, or try to keep the instructions emitted
10036 ;; here in strict sequence.
10037 (define_expand "allocate_stack"
10038   [(match_operand 0 "" "")
10039    (match_operand 1 "" "")]
10040   ""
10041   "
10042 {
10043   rtx addr;
10044
10045   /* Since the stack grows upward, we need to store virtual_stack_dynamic_rtx
10046      in operand 0 before adjusting the stack.  */
10047   emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
10048   anti_adjust_stack (operands[1]);
10049   if (TARGET_HPUX_UNWIND_LIBRARY)
10050     {
10051       addr = gen_rtx_PLUS (word_mode, stack_pointer_rtx,
10052                            GEN_INT (TARGET_64BIT ? -8 : -4));
10053       emit_move_insn (gen_rtx_MEM (word_mode, addr), frame_pointer_rtx);
10054     }
10055   if (!TARGET_64BIT && flag_pic)
10056     {
10057       rtx addr = gen_rtx_PLUS (word_mode, stack_pointer_rtx, GEN_INT (-32));
10058       emit_move_insn (gen_rtx_MEM (word_mode, addr), pic_offset_table_rtx);
10059     }
10060   DONE;
10061 }")
10062
10063 (define_expand "prefetch"
10064   [(match_operand 0 "address_operand" "")
10065    (match_operand 1 "const_int_operand" "")
10066    (match_operand 2 "const_int_operand" "")]
10067   "TARGET_PA_20"
10068 {
10069   int locality = INTVAL (operands[2]);
10070
10071   gcc_assert (locality >= 0 && locality <= 3);
10072
10073   /* Change operand[0] to a MEM as we don't have the infrastructure
10074      to output all the supported address modes for ldw/ldd when we use
10075      the address directly.  However, we do have it for MEMs.  */
10076   operands[0] = gen_rtx_MEM (QImode, operands[0]);
10077
10078   /* If the address isn't valid for the prefetch, replace it.  */
10079   if (locality)
10080     {
10081       if (!prefetch_nocc_operand (operands[0], QImode))
10082         operands[0]
10083           = replace_equiv_address (operands[0],
10084                                    copy_to_mode_reg (Pmode,
10085                                                      XEXP (operands[0], 0)));
10086       emit_insn (gen_prefetch_nocc (operands[0], operands[1], operands[2]));
10087     }
10088   else
10089     {
10090       if (!prefetch_cc_operand (operands[0], QImode))
10091         operands[0]
10092           = replace_equiv_address (operands[0],
10093                                    copy_to_mode_reg (Pmode,
10094                                                      XEXP (operands[0], 0)));
10095       emit_insn (gen_prefetch_cc (operands[0], operands[1], operands[2]));
10096     }
10097   DONE;
10098 })
10099
10100 (define_insn "prefetch_cc"
10101   [(prefetch (match_operand:QI 0 "prefetch_cc_operand" "RW")
10102              (match_operand:SI 1 "const_int_operand" "n")
10103              (match_operand:SI 2 "const_int_operand" "n"))]
10104   "TARGET_PA_20 && operands[2] == const0_rtx"
10105 {
10106   /* The SL cache-control completor indicates good spatial locality but
10107      poor temporal locality.  The ldw instruction with a target of general
10108      register 0 prefetches a cache line for a read.  The ldd instruction
10109      prefetches a cache line for a write.  */
10110   static const char * const instr[2] = {
10111     "ldw%M0,sl %0,%%r0",
10112     "ldd%M0,sl %0,%%r0"
10113   };
10114   int read_or_write = INTVAL (operands[1]);
10115
10116   gcc_assert (read_or_write >= 0 && read_or_write <= 1);
10117
10118   return instr [read_or_write];
10119 }
10120   [(set_attr "type" "load")
10121    (set_attr "length" "4")])
10122
10123 (define_insn "prefetch_nocc"
10124   [(prefetch (match_operand:QI 0 "prefetch_nocc_operand" "A,RQ")
10125              (match_operand:SI 1 "const_int_operand" "n,n")
10126              (match_operand:SI 2 "const_int_operand" "n,n"))]
10127   "TARGET_PA_20 && operands[2] != const0_rtx"
10128 {
10129   /* The ldw instruction with a target of general register 0 prefetches
10130      a cache line for a read.  The ldd instruction prefetches a cache line
10131      for a write.  */
10132   static const char * const instr[2][2] = {
10133     {
10134       "ldw RT'%A0,%%r0",
10135       "ldd RT'%A0,%%r0",
10136     },
10137     {
10138       "ldw%M0 %0,%%r0",
10139       "ldd%M0 %0,%%r0",
10140     }
10141   };
10142   int read_or_write = INTVAL (operands[1]);
10143
10144   gcc_assert (which_alternative == 0 || which_alternative == 1);
10145   gcc_assert (read_or_write >= 0 && read_or_write <= 1);
10146
10147   return instr [which_alternative][read_or_write];
10148 }
10149   [(set_attr "type" "load")
10150    (set_attr "length" "4")])
10151
10152
10153 ;; TLS Support
10154 (define_insn "tgd_load"
10155  [(set (match_operand:SI 0 "register_operand" "=r")
10156        (unspec:SI [(match_operand 1 "tgd_symbolic_operand" "")] UNSPEC_TLSGD))
10157   (clobber (reg:SI 1))
10158   (use (reg:SI 27))]
10159   ""
10160   "*
10161 {
10162   return \"addil LR'%1-$tls_gdidx$,%%r27\;ldo RR'%1-$tls_gdidx$(%%r1),%0\";
10163 }"
10164   [(set_attr "type" "multi")
10165    (set_attr "length" "8")])
10166
10167 (define_insn "tgd_load_pic"
10168  [(set (match_operand:SI 0 "register_operand" "=r")
10169        (unspec:SI [(match_operand 1 "tgd_symbolic_operand" "")] UNSPEC_TLSGD_PIC))
10170   (clobber (reg:SI 1))
10171   (use (reg:SI 19))]
10172   ""
10173   "*
10174 {
10175   return \"addil LT'%1-$tls_gdidx$,%%r19\;ldo RT'%1-$tls_gdidx$(%%r1),%0\";
10176 }"
10177   [(set_attr "type" "multi")
10178    (set_attr "length" "8")])
10179
10180 (define_insn "tld_load"
10181  [(set (match_operand:SI 0 "register_operand" "=r")
10182        (unspec:SI [(match_operand 1 "tld_symbolic_operand" "")] UNSPEC_TLSLDM))
10183   (clobber (reg:SI 1))
10184   (use (reg:SI 27))]
10185   ""
10186   "*
10187 {
10188   return \"addil LR'%1-$tls_ldidx$,%%r27\;ldo RR'%1-$tls_ldidx$(%%r1),%0\";
10189 }"
10190   [(set_attr "type" "multi")
10191    (set_attr "length" "8")])
10192
10193 (define_insn "tld_load_pic"
10194  [(set (match_operand:SI 0 "register_operand" "=r")
10195        (unspec:SI [(match_operand 1 "tld_symbolic_operand" "")] UNSPEC_TLSLDM_PIC))
10196   (clobber (reg:SI 1))
10197   (use (reg:SI 19))]
10198   ""
10199   "*
10200 {
10201   return \"addil LT'%1-$tls_ldidx$,%%r19\;ldo RT'%1-$tls_ldidx$(%%r1),%0\";
10202 }"
10203   [(set_attr "type" "multi")
10204    (set_attr "length" "8")])
10205
10206 (define_insn "tld_offset_load"
10207   [(set (match_operand:SI 0 "register_operand" "=r")
10208         (plus:SI (unspec:SI [(match_operand 1 "tld_symbolic_operand" "")] 
10209                             UNSPEC_TLSLDO)
10210                  (match_operand:SI 2 "register_operand" "r")))
10211    (clobber (reg:SI 1))]
10212   ""
10213   "*
10214 {
10215   return \"addil LR'%1-$tls_dtpoff$,%2\;ldo RR'%1-$tls_dtpoff$(%%r1),%0\"; 
10216 }"
10217   [(set_attr "type" "multi")
10218    (set_attr "length" "8")])
10219
10220 (define_insn "tp_load"
10221   [(set (match_operand:SI 0 "register_operand" "=r")
10222         (unspec:SI [(const_int 0)] UNSPEC_TP))]
10223   ""
10224   "mfctl %%cr27,%0"
10225   [(set_attr "type" "multi")
10226    (set_attr "length" "4")])
10227
10228 (define_insn "tie_load"
10229   [(set (match_operand:SI 0 "register_operand" "=r")
10230         (unspec:SI [(match_operand 1 "tie_symbolic_operand" "")] UNSPEC_TLSIE))
10231    (clobber (reg:SI 1))
10232    (use (reg:SI 27))]
10233   ""
10234   "*
10235 {
10236   return \"addil LR'%1-$tls_ieoff$,%%r27\;ldw RR'%1-$tls_ieoff$(%%r1),%0\";
10237 }"
10238   [(set_attr "type" "multi")
10239    (set_attr "length" "8")])
10240
10241 (define_insn "tie_load_pic"
10242   [(set (match_operand:SI 0 "register_operand" "=r")
10243         (unspec:SI [(match_operand 1 "tie_symbolic_operand" "")] UNSPEC_TLSIE_PIC))
10244    (clobber (reg:SI 1))
10245    (use (reg:SI 19))]
10246   ""
10247   "*
10248 {
10249   return \"addil LT'%1-$tls_ieoff$,%%r19\;ldw RT'%1-$tls_ieoff$(%%r1),%0\";
10250 }"
10251   [(set_attr "type" "multi")
10252    (set_attr "length" "8")])
10253
10254 (define_insn "tle_load"
10255   [(set (match_operand:SI 0 "register_operand" "=r")
10256         (plus:SI (unspec:SI [(match_operand 1 "tle_symbolic_operand" "")] 
10257                             UNSPEC_TLSLE)
10258                  (match_operand:SI 2 "register_operand" "r")))
10259    (clobber (reg:SI 1))]
10260   ""
10261   "addil LR'%1-$tls_leoff$,%2\;ldo RR'%1-$tls_leoff$(%%r1),%0"
10262   [(set_attr "type" "multi")
10263    (set_attr "length" "8")])