PR c/81544 - attribute noreturn and warn_unused_result on the same function accepted
[official-gcc.git] / gcc / config / pa / pa.md
blob1d979e0328d566c04412a74fa0bd54a402e6bfef
1 ;;- Machine description for HP PA-RISC architecture for GCC compiler
2 ;;   Copyright (C) 1992-2017 Free Software Foundation, Inc.
3 ;;   Contributed by the Center for Software Science at the University
4 ;;   of Utah.
6 ;; This file is part of GCC.
8 ;; GCC is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 3, or (at your option)
11 ;; any later version.
13 ;; GCC is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GCC; see the file COPYING3.  If not see
20 ;; <http://www.gnu.org/licenses/>.
22 ;; This machine description is inspired by sparc.md and to a lesser
23 ;; extent mips.md.
25 ;; Possible improvements:
27 ;; * With PA1.1, most computational instructions can conditionally nullify
28 ;;   the execution of the following instruction.  A nullified instruction
29 ;;   does not cause the instruction pipeline to stall, making it a very
30 ;;   efficient alternative to e.g. branching or conditional moves.
32 ;;   Nullification is performed conditionally based on the outcome of a
33 ;;   test specified in the opcode.  The test result is stored in PSW[N]
34 ;;   and can only be used to nullify the instruction following immediately
35 ;;   after the test.  For example:
37 ;;      ldi 10,%r26
38 ;;      ldi 5,%r25
39 ;;      sub,< %r26,%r25,%r28
40 ;;      sub   %r28,%r25,%r28    ; %r28 == 0
41 ;;      sub,> %r26,%r25,%r29
42 ;;      sub   %r29,%r25,%r29    ; %r29 == 5
44 ;;   This could be tricky to implement because the result of the test has
45 ;;   to be propagated one instruction forward, which, in the worst case,
46 ;;   would involve (1) adding a fake register for PSW[N]; (2) adding the
47 ;;   variants of the computational instructions that set or consume this
48 ;;   fake register.  The cond_exec infrastructure is probably not helpful
49 ;;   for this.
51 ;; * PA-RISC includes a set of conventions for branch instruction usage
52 ;;   to indicate whether a particular branch is more likely to be taken
53 ;;   or not taken.  For example, the prediction for CMPB instructions
54 ;;   (CMPB,cond,n r1,r2,target) depends on the direction of the branch
55 ;;   (forward or backward) and on the order of the operands:
57 ;;     | branch    | operand  | branch     |
58 ;;     | direction | compare  | prediction |
59 ;;     +-----------+----------+------------+
60 ;;     | backward  | r1 < r2  | taken      |
61 ;;     | backward  | r1 >= r2 | not taken  |
62 ;;     | forward   | r1 < r2  | not taken  |
63 ;;     | forward   | r1 >= r2 | taken      |
64 ;;    
65 ;;   By choosing instructions and operand order carefully, the compiler
66 ;;   could give the CPU branch predictor some help.
67 ;;   
69 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
71 ;; Uses of UNSPEC in this file:
73 (define_c_enum "unspec"
74   [UNSPEC_CFFC          ; canonicalize_funcptr_for_compare
75    UNSPEC_GOTO          ; indirect_goto
76    UNSPEC_DLTIND14R
77    UNSPEC_TP
78    UNSPEC_TLSGD
79    UNSPEC_TLSLDM
80    UNSPEC_TLSLDO
81    UNSPEC_TLSLDBASE
82    UNSPEC_TLSIE
83    UNSPEC_TLSLE 
84    UNSPEC_TLSGD_PIC
85    UNSPEC_TLSLDM_PIC
86    UNSPEC_TLSIE_PIC
87   ])
89 ;; UNSPEC_VOLATILE:
91 (define_c_enum "unspecv"
92   [UNSPECV_BLOCKAGE     ; blockage
93    UNSPECV_DCACHE       ; dcacheflush
94    UNSPECV_ICACHE       ; icacheflush
95    UNSPECV_OPC          ; outline_prologue_call
96    UNSPECV_OEC          ; outline_epilogue_call
97    UNSPECV_LONGJMP      ; builtin_longjmp
98   ])
100 ;; Maximum pc-relative branch offsets.
102 ;; These numbers are a bit smaller than the maximum allowable offsets
103 ;; so that a few instructions may be inserted before the actual branch.
105 (define_constants
106   [(MAX_12BIT_OFFSET     8184)  ; 12-bit branch
107    (MAX_17BIT_OFFSET   262100)  ; 17-bit branch
108   ])
110 ;; Mode and code iterators
112 ;; This mode iterator allows :P to be used for patterns that operate on
113 ;; pointer-sized quantities.  Exactly one of the two alternatives will match.
114 (define_mode_iterator P [(SI "Pmode == SImode") (DI "Pmode == DImode")])
116 ;; This attribute defines the condition prefix for word and double word
117 ;; add, compare, subtract and logical instructions.
118 (define_mode_attr dwc [(SI "") (DI "*")])
120 ;; Insn type.  Used to default other attribute values.
122 ;; type "unary" insns have one input operand (1) and one output operand (0)
123 ;; type "binary" insns have two input operands (1,2) and one output (0)
125 (define_attr "type"
126   "move,unary,binary,shift,nullshift,compare,load,store,uncond_branch,branch,cbranch,fbranch,call,sibcall,dyncall,fpload,fpstore,fpalu,fpcc,fpmulsgl,fpmuldbl,fpdivsgl,fpdivdbl,fpsqrtsgl,fpsqrtdbl,multi,milli,sh_func_adrs,parallel_branch,fpstore_load,store_fpload,trap"
127   (const_string "binary"))
129 (define_attr "pa_combine_type"
130   "fmpy,faddsub,uncond_branch,addmove,none"
131   (const_string "none"))
133 ;; Processor type (for scheduling, not code generation) -- this attribute
134 ;; must exactly match the processor_type enumeration in pa.h.
136 ;; FIXME: Add 800 scheduling for completeness?
138 (define_attr "cpu" "700,7100,7100LC,7200,7300,8000" (const (symbol_ref "pa_cpu_attr")))
140 ;; Length (in # of bytes).
141 (define_attr "length" ""
142   (cond [(eq_attr "type" "load,fpload")
143          (if_then_else (match_operand 1 "symbolic_memory_operand" "")
144                        (const_int 8) (const_int 4))
146          (eq_attr "type" "store,fpstore")
147          (if_then_else (match_operand 0 "symbolic_memory_operand" "")
148                        (const_int 8) (const_int 4))
150          (eq_attr "type" "binary,shift,nullshift")
151          (if_then_else (match_operand 2 "arith14_operand" "")
152                        (const_int 4) (const_int 12))
154          (eq_attr "type" "move,unary,shift,nullshift")
155          (if_then_else (match_operand 1 "arith14_operand" "")
156                        (const_int 4) (const_int 8))]
158         (const_int 4)))
160 (define_asm_attributes
161   [(set_attr "length" "4")
162    (set_attr "type" "multi")])
164 ;; Attributes for instruction and branch scheduling
166 ;; For conditional branches. Frame related instructions are not allowed
167 ;; because they confuse the unwind support.
168 (define_attr "in_branch_delay" "false,true"
169   (if_then_else (and (eq_attr "type" "!uncond_branch,branch,cbranch,fbranch,call,sibcall,dyncall,multi,milli,sh_func_adrs,parallel_branch,trap")
170                      (eq_attr "length" "4")
171                      (not (match_test "RTX_FRAME_RELATED_P (insn)")))
172                 (const_string "true")
173                 (const_string "false")))
175 ;; Disallow instructions which use the FPU since they will tie up the FPU
176 ;; even if the instruction is nullified.
177 (define_attr "in_nullified_branch_delay" "false,true"
178   (if_then_else (and (eq_attr "type" "!uncond_branch,branch,cbranch,fbranch,call,sibcall,dyncall,multi,milli,sh_func_adrs,fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpdivdbl,fpsqrtsgl,fpsqrtdbl,parallel_branch,trap")
179                      (eq_attr "length" "4")
180                      (not (match_test "RTX_FRAME_RELATED_P (insn)")))
181                 (const_string "true")
182                 (const_string "false")))
184 ;; For calls and millicode calls.
185 (define_attr "in_call_delay" "false,true"
186   (if_then_else (and (eq_attr "type" "!uncond_branch,branch,cbranch,fbranch,call,sibcall,dyncall,multi,milli,sh_func_adrs,parallel_branch,trap")
187                      (eq_attr "length" "4")
188                      (not (match_test "RTX_FRAME_RELATED_P (insn)")))
189                 (const_string "true")
190                 (const_string "false")))
192 ;; Call delay slot description.
193 (define_delay (eq_attr "type" "call")
194   [(eq_attr "in_call_delay" "true") (nil) (nil)])
196 ;; Sibcall delay slot description.
197 (define_delay (eq_attr "type" "sibcall")
198   [(eq_attr "in_call_delay" "true") (nil) (nil)])
200 ;; Millicode call delay slot description.
201 (define_delay (eq_attr "type" "milli")
202   [(eq_attr "in_call_delay" "true") (nil) (nil)])
204 ;; Return and other similar instructions.
205 (define_delay (eq_attr "type" "branch,parallel_branch")
206   [(eq_attr "in_branch_delay" "true") (nil) (nil)])
208 ;; Floating point conditional branch delay slot description.
209 (define_delay (eq_attr "type" "fbranch")
210   [(eq_attr "in_branch_delay" "true")
211    (eq_attr "in_nullified_branch_delay" "true")
212    (nil)])
214 ;; Integer conditional branch delay slot description.
215 ;; Nullification of conditional branches on the PA is dependent on the
216 ;; direction of the branch.  Forward branches nullify true and
217 ;; backward branches nullify false.  If the direction is unknown
218 ;; then nullification is not allowed.
219 (define_delay (eq_attr "type" "cbranch")
220   [(eq_attr "in_branch_delay" "true")
221    (and (eq_attr "in_nullified_branch_delay" "true")
222         (attr_flag "forward"))
223    (and (eq_attr "in_nullified_branch_delay" "true")
224         (attr_flag "backward"))])
226 (define_delay (eq_attr "type" "uncond_branch")
227   [(eq_attr "in_branch_delay" "true") (nil) (nil)])
229 ;; Memory. Disregarding Cache misses, the Mustang memory times are:
230 ;; load: 2, fpload: 3
231 ;; store, fpstore: 3, no D-cache operations should be scheduled.
233 ;; The Timex (aka 700) has two floating-point units: ALU, and MUL/DIV/SQRT.
234 ;; Timings:
235 ;; Instruction  Time    Unit    Minimum Distance (unit contention)
236 ;; fcpy         3       ALU     2
237 ;; fabs         3       ALU     2
238 ;; fadd         3       ALU     2
239 ;; fsub         3       ALU     2
240 ;; fcmp         3       ALU     2
241 ;; fcnv         3       ALU     2
242 ;; fmpyadd      3       ALU,MPY 2
243 ;; fmpysub      3       ALU,MPY 2
244 ;; fmpycfxt     3       ALU,MPY 2
245 ;; fmpy         3       MPY     2
246 ;; fmpyi        3       MPY     2
247 ;; fdiv,sgl     10      MPY     10
248 ;; fdiv,dbl     12      MPY     12
249 ;; fsqrt,sgl    14      MPY     14
250 ;; fsqrt,dbl    18      MPY     18
252 ;; We don't model fmpyadd/fmpysub properly as those instructions
253 ;; keep both the FP ALU and MPY units busy.  Given that these
254 ;; processors are obsolete, I'm not going to spend the time to
255 ;; model those instructions correctly.
257 (define_automaton "pa700")
258 (define_cpu_unit "dummy_700,mem_700,fpalu_700,fpmpy_700" "pa700")
260 (define_insn_reservation "W0" 4
261   (and (eq_attr "type" "fpcc")
262        (eq_attr "cpu" "700"))
263   "fpalu_700*2")
265 (define_insn_reservation "W1" 3
266   (and (eq_attr "type" "fpalu")
267        (eq_attr "cpu" "700"))
268   "fpalu_700*2")
270 (define_insn_reservation "W2" 3
271   (and (eq_attr "type" "fpmulsgl,fpmuldbl")
272        (eq_attr "cpu" "700"))
273   "fpmpy_700*2")
275 (define_insn_reservation "W3" 10
276   (and (eq_attr "type" "fpdivsgl")
277        (eq_attr "cpu" "700"))
278   "fpmpy_700*10")
280 (define_insn_reservation "W4" 12
281   (and (eq_attr "type" "fpdivdbl")
282        (eq_attr "cpu" "700"))
283   "fpmpy_700*12")
285 (define_insn_reservation "W5" 14
286   (and (eq_attr "type" "fpsqrtsgl")
287        (eq_attr "cpu" "700"))
288   "fpmpy_700*14")
290 (define_insn_reservation "W6" 18
291   (and (eq_attr "type" "fpsqrtdbl")
292        (eq_attr "cpu" "700"))
293   "fpmpy_700*18")
295 (define_insn_reservation "W7" 2
296   (and (eq_attr "type" "load")
297        (eq_attr "cpu" "700"))
298   "mem_700")
300 (define_insn_reservation "W8" 2
301   (and (eq_attr "type" "fpload")
302        (eq_attr "cpu" "700"))
303   "mem_700")
305 (define_insn_reservation "W9" 3
306   (and (eq_attr "type" "store")
307        (eq_attr "cpu" "700"))
308   "mem_700*3")
310 (define_insn_reservation "W10" 3
311   (and (eq_attr "type" "fpstore")
312        (eq_attr "cpu" "700"))
313   "mem_700*3")
315 (define_insn_reservation "W11" 5
316   (and (eq_attr "type" "fpstore_load")
317        (eq_attr "cpu" "700"))
318   "mem_700*5")
320 (define_insn_reservation "W12" 6
321   (and (eq_attr "type" "store_fpload")
322        (eq_attr "cpu" "700"))
323   "mem_700*6")
325 (define_insn_reservation "W13" 1
326   (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpdivdbl,fpsqrtsgl,fpsqrtdbl,load,fpload,store,fpstore,fpstore_load,store_fpload")
327        (eq_attr "cpu" "700"))
328   "dummy_700")
330 ;; We have a bypass for all computations in the FP unit which feed an
331 ;; FP store as long as the sizes are the same.
332 (define_bypass 2 "W1,W2" "W10,W11" "pa_fpstore_bypass_p")
333 (define_bypass 9 "W3" "W10,W11" "pa_fpstore_bypass_p")
334 (define_bypass 11 "W4" "W10,W11" "pa_fpstore_bypass_p")
335 (define_bypass 13 "W5" "W10,W11" "pa_fpstore_bypass_p")
336 (define_bypass 17 "W6" "W10,W11" "pa_fpstore_bypass_p")
338 ;; We have an "anti-bypass" for FP loads which feed an FP store.
339 (define_bypass 4 "W8,W12" "W10,W11" "pa_fpstore_bypass_p")
341 ;; Function units for the 7100 and 7150.  The 7100/7150 can dual-issue
342 ;; floating point computations with non-floating point computations (fp loads
343 ;; and stores are not fp computations).
345 ;; Memory. Disregarding Cache misses, memory loads take two cycles; stores also
346 ;; take two cycles, during which no Dcache operations should be scheduled.
347 ;; Any special cases are handled in pa_adjust_cost.  The 7100, 7150 and 7100LC
348 ;; all have the same memory characteristics if one disregards cache misses.
350 ;; The 7100/7150 has three floating-point units: ALU, MUL, and DIV.
351 ;; There's no value in modeling the ALU and MUL separately though
352 ;; since there can never be a functional unit conflict given the
353 ;; latency and issue rates for those units.
355 ;; Timings:
356 ;; Instruction  Time    Unit    Minimum Distance (unit contention)
357 ;; fcpy         2       ALU     1
358 ;; fabs         2       ALU     1
359 ;; fadd         2       ALU     1
360 ;; fsub         2       ALU     1
361 ;; fcmp         2       ALU     1
362 ;; fcnv         2       ALU     1
363 ;; fmpyadd      2       ALU,MPY 1
364 ;; fmpysub      2       ALU,MPY 1
365 ;; fmpycfxt     2       ALU,MPY 1
366 ;; fmpy         2       MPY     1
367 ;; fmpyi        2       MPY     1
368 ;; fdiv,sgl     8       DIV     8
369 ;; fdiv,dbl     15      DIV     15
370 ;; fsqrt,sgl    8       DIV     8
371 ;; fsqrt,dbl    15      DIV     15
373 (define_automaton "pa7100")
374 (define_cpu_unit "i_7100, f_7100,fpmac_7100,fpdivsqrt_7100,mem_7100" "pa7100")
376 (define_insn_reservation "X0" 2
377   (and (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
378        (eq_attr "cpu" "7100"))
379   "f_7100,fpmac_7100")
381 (define_insn_reservation "X1" 8
382   (and (eq_attr "type" "fpdivsgl,fpsqrtsgl")
383        (eq_attr "cpu" "7100"))
384   "f_7100+fpdivsqrt_7100,fpdivsqrt_7100*7")
386 (define_insn_reservation "X2" 15
387   (and (eq_attr "type" "fpdivdbl,fpsqrtdbl")
388        (eq_attr "cpu" "7100"))
389   "f_7100+fpdivsqrt_7100,fpdivsqrt_7100*14")
391 (define_insn_reservation "X3" 2
392   (and (eq_attr "type" "load")
393        (eq_attr "cpu" "7100"))
394   "i_7100+mem_7100")
396 (define_insn_reservation "X4" 2
397   (and (eq_attr "type" "fpload")
398        (eq_attr "cpu" "7100"))
399   "i_7100+mem_7100")
401 (define_insn_reservation "X5" 2
402   (and (eq_attr "type" "store")
403        (eq_attr "cpu" "7100"))
404   "i_7100+mem_7100,mem_7100")
406 (define_insn_reservation "X6" 2
407   (and (eq_attr "type" "fpstore")
408        (eq_attr "cpu" "7100"))
409   "i_7100+mem_7100,mem_7100")
411 (define_insn_reservation "X7" 4
412   (and (eq_attr "type" "fpstore_load")
413        (eq_attr "cpu" "7100"))
414   "i_7100+mem_7100,mem_7100*3")
416 (define_insn_reservation "X8" 4
417   (and (eq_attr "type" "store_fpload")
418        (eq_attr "cpu" "7100"))
419   "i_7100+mem_7100,mem_7100*3")
421 (define_insn_reservation "X9" 1
422   (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl,load,fpload,store,fpstore,fpstore_load,store_fpload")
423        (eq_attr "cpu" "7100"))
424   "i_7100")
426 ;; We have a bypass for all computations in the FP unit which feed an
427 ;; FP store as long as the sizes are the same.
428 (define_bypass 1 "X0" "X6,X7" "pa_fpstore_bypass_p")
429 (define_bypass 7 "X1" "X6,X7" "pa_fpstore_bypass_p")
430 (define_bypass 14 "X2" "X6,X7" "pa_fpstore_bypass_p")
432 ;; We have an "anti-bypass" for FP loads which feed an FP store.
433 (define_bypass 3 "X4,X8" "X6,X7" "pa_fpstore_bypass_p")
435 ;; The 7100LC has three floating-point units: ALU, MUL, and DIV.
436 ;; There's no value in modeling the ALU and MUL separately though
437 ;; since there can never be a functional unit conflict that
438 ;; can be avoided given the latency, issue rates and mandatory
439 ;; one cycle cpu-wide lock for a double precision fp multiply.
441 ;; Timings:
442 ;; Instruction  Time    Unit    Minimum Distance (unit contention)
443 ;; fcpy         2       ALU     1
444 ;; fabs         2       ALU     1
445 ;; fadd         2       ALU     1
446 ;; fsub         2       ALU     1
447 ;; fcmp         2       ALU     1
448 ;; fcnv         2       ALU     1
449 ;; fmpyadd,sgl  2       ALU,MPY 1
450 ;; fmpyadd,dbl  3       ALU,MPY 2
451 ;; fmpysub,sgl  2       ALU,MPY 1
452 ;; fmpysub,dbl  3       ALU,MPY 2
453 ;; fmpycfxt,sgl 2       ALU,MPY 1
454 ;; fmpycfxt,dbl 3       ALU,MPY 2
455 ;; fmpy,sgl     2       MPY     1
456 ;; fmpy,dbl     3       MPY     2
457 ;; fmpyi        3       MPY     2
458 ;; fdiv,sgl     8       DIV     8
459 ;; fdiv,dbl     15      DIV     15
460 ;; fsqrt,sgl    8       DIV     8
461 ;; fsqrt,dbl    15      DIV     15
463 ;; The PA7200 is just like the PA7100LC except that there is
464 ;; no store-store penalty.
466 ;; The PA7300 is just like the PA7200 except that there is
467 ;; no store-load penalty.
469 ;; Note there are some aspects of the 7100LC we are not modeling
470 ;; at the moment.  I'll be reviewing the 7100LC scheduling info
471 ;; shortly and updating this description.
473 ;;   load-load pairs
474 ;;   store-store pairs
475 ;;   other issue modeling
477 (define_automaton "pa7100lc")
478 (define_cpu_unit "i0_7100lc, i1_7100lc, f_7100lc" "pa7100lc")
479 (define_cpu_unit "fpmac_7100lc" "pa7100lc")
480 (define_cpu_unit "mem_7100lc" "pa7100lc")
482 ;; Double precision multiplies lock the entire CPU for one
483 ;; cycle.  There is no way to avoid this lock and trying to
484 ;; schedule around the lock is pointless and thus there is no
485 ;; value in trying to model this lock.
487 ;; Not modeling the lock allows us to treat fp multiplies just
488 ;; like any other FP alu instruction.  It allows for a smaller
489 ;; DFA and may reduce register pressure.
490 (define_insn_reservation "Y0" 2
491   (and (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
492        (eq_attr "cpu" "7100LC,7200,7300"))
493   "f_7100lc,fpmac_7100lc")
495 ;; fp division and sqrt instructions lock the entire CPU for
496 ;; 7 cycles (single precision) or 14 cycles (double precision).
497 ;; There is no way to avoid this lock and trying to schedule
498 ;; around the lock is pointless and thus there is no value in
499 ;; trying to model this lock.  Not modeling the lock allows
500 ;; for a smaller DFA and may reduce register pressure.
501 (define_insn_reservation "Y1" 1
502   (and (eq_attr "type" "fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl")
503        (eq_attr "cpu" "7100LC,7200,7300"))
504   "f_7100lc")
506 (define_insn_reservation "Y2" 2
507   (and (eq_attr "type" "load")
508        (eq_attr "cpu" "7100LC,7200,7300"))
509   "i1_7100lc+mem_7100lc")
511 (define_insn_reservation "Y3" 2
512   (and (eq_attr "type" "fpload")
513        (eq_attr "cpu" "7100LC,7200,7300"))
514   "i1_7100lc+mem_7100lc")
516 (define_insn_reservation "Y4" 2
517   (and (eq_attr "type" "store")
518        (eq_attr "cpu" "7100LC"))
519   "i1_7100lc+mem_7100lc,mem_7100lc")
521 (define_insn_reservation "Y5" 2
522   (and (eq_attr "type" "fpstore")
523        (eq_attr "cpu" "7100LC"))
524   "i1_7100lc+mem_7100lc,mem_7100lc")
526 (define_insn_reservation "Y6" 4
527   (and (eq_attr "type" "fpstore_load")
528        (eq_attr "cpu" "7100LC"))
529   "i1_7100lc+mem_7100lc,mem_7100lc*3")
531 (define_insn_reservation "Y7" 4
532   (and (eq_attr "type" "store_fpload")
533        (eq_attr "cpu" "7100LC"))
534   "i1_7100lc+mem_7100lc,mem_7100lc*3")
536 (define_insn_reservation "Y8" 1
537   (and (eq_attr "type" "shift,nullshift")
538        (eq_attr "cpu" "7100LC,7200,7300"))
539   "i1_7100lc")
541 (define_insn_reservation "Y9" 1
542   (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl,load,fpload,store,fpstore,shift,nullshift")
543        (eq_attr "cpu" "7100LC,7200,7300"))
544   "(i0_7100lc|i1_7100lc)")
546 ;; The 7200 has a store-load penalty
547 (define_insn_reservation "Y10" 2
548   (and (eq_attr "type" "store")
549        (eq_attr "cpu" "7200"))
550   "i1_7100lc,mem_7100lc")
552 (define_insn_reservation "Y11" 2
553   (and (eq_attr "type" "fpstore")
554        (eq_attr "cpu" "7200"))
555   "i1_7100lc,mem_7100lc")
557 (define_insn_reservation "Y12" 4
558   (and (eq_attr "type" "fpstore_load")
559        (eq_attr "cpu" "7200"))
560   "i1_7100lc,mem_7100lc,i1_7100lc+mem_7100lc")
562 (define_insn_reservation "Y13" 4
563   (and (eq_attr "type" "store_fpload")
564        (eq_attr "cpu" "7200"))
565   "i1_7100lc,mem_7100lc,i1_7100lc+mem_7100lc")
567 ;; The 7300 has no penalty for store-store or store-load
568 (define_insn_reservation "Y14" 2
569   (and (eq_attr "type" "store")
570        (eq_attr "cpu" "7300"))
571   "i1_7100lc")
573 (define_insn_reservation "Y15" 2
574   (and (eq_attr "type" "fpstore")
575        (eq_attr "cpu" "7300"))
576   "i1_7100lc")
578 (define_insn_reservation "Y16" 4
579   (and (eq_attr "type" "fpstore_load")
580        (eq_attr "cpu" "7300"))
581   "i1_7100lc,i1_7100lc+mem_7100lc")
583 (define_insn_reservation "Y17" 4
584   (and (eq_attr "type" "store_fpload")
585        (eq_attr "cpu" "7300"))
586   "i1_7100lc,i1_7100lc+mem_7100lc")
588 ;; We have an "anti-bypass" for FP loads which feed an FP store.
589 (define_bypass 3 "Y3,Y7,Y13,Y17" "Y5,Y6,Y11,Y12,Y15,Y16" "pa_fpstore_bypass_p")
591 ;; Scheduling for the PA8000 is somewhat different than scheduling for a
592 ;; traditional architecture.
594 ;; The PA8000 has a large (56) entry reorder buffer that is split between
595 ;; memory and non-memory operations.
597 ;; The PA8000 can issue two memory and two non-memory operations per cycle to
598 ;; the function units, with the exception of branches and multi-output
599 ;; instructions.  The PA8000 can retire two non-memory operations per cycle
600 ;; and two memory operations per cycle, only one of which may be a store.
602 ;; Given the large reorder buffer, the processor can hide most latencies.
603 ;; According to HP, they've got the best results by scheduling for retirement
604 ;; bandwidth with limited latency scheduling for floating point operations.
605 ;; Latency for integer operations and memory references is ignored.
608 ;; We claim floating point operations have a 2 cycle latency and are
609 ;; fully pipelined, except for div and sqrt which are not pipelined and
610 ;; take from 17 to 31 cycles to complete.
612 ;; It's worth noting that there is no way to saturate all the functional
613 ;; units on the PA8000 as there is not enough issue bandwidth.
615 (define_automaton "pa8000")
616 (define_cpu_unit "inm0_8000, inm1_8000, im0_8000, im1_8000" "pa8000")
617 (define_cpu_unit "rnm0_8000, rnm1_8000, rm0_8000, rm1_8000" "pa8000")
618 (define_cpu_unit "store_8000" "pa8000")
619 (define_cpu_unit "f0_8000, f1_8000" "pa8000")
620 (define_cpu_unit "fdivsqrt0_8000, fdivsqrt1_8000" "pa8000")
621 (define_reservation "inm_8000" "inm0_8000 | inm1_8000")
622 (define_reservation "im_8000" "im0_8000 | im1_8000")
623 (define_reservation "rnm_8000" "rnm0_8000 | rnm1_8000")
624 (define_reservation "rm_8000" "rm0_8000 | rm1_8000")
625 (define_reservation "f_8000" "f0_8000 | f1_8000")
626 (define_reservation "fdivsqrt_8000" "fdivsqrt0_8000 | fdivsqrt1_8000")
628 ;; We can issue any two memops per cycle, but we can only retire
629 ;; one memory store per cycle.  We assume that the reorder buffer
630 ;; will hide any memory latencies per HP's recommendation.
631 (define_insn_reservation "Z0" 0
632   (and
633     (eq_attr "type" "load,fpload")
634     (eq_attr "cpu" "8000"))
635   "im_8000,rm_8000")
637 (define_insn_reservation "Z1" 0
638   (and
639     (eq_attr "type" "store,fpstore")
640     (eq_attr "cpu" "8000"))
641   "im_8000,rm_8000+store_8000")
643 (define_insn_reservation "Z2" 0
644   (and (eq_attr "type" "fpstore_load,store_fpload")
645        (eq_attr "cpu" "8000"))
646   "im_8000,rm_8000+store_8000,im_8000,rm_8000")
648 ;; We can issue and retire two non-memory operations per cycle with
649 ;; a few exceptions (branches).  This group catches those we want
650 ;; to assume have zero latency.
651 (define_insn_reservation "Z3" 0
652   (and
653     (eq_attr "type" "!load,fpload,store,fpstore,uncond_branch,branch,cbranch,fbranch,call,sibcall,dyncall,multi,milli,sh_func_adrs,parallel_branch,fpcc,fpalu,fpmulsgl,fpmuldbl,fpsqrtsgl,fpsqrtdbl,fpdivsgl,fpdivdbl,fpstore_load,store_fpload")
654     (eq_attr "cpu" "8000"))
655   "inm_8000,rnm_8000")
657 ;; Branches use both slots in the non-memory issue and
658 ;; retirement unit.
659 (define_insn_reservation "Z4" 0
660   (and
661     (eq_attr "type" "uncond_branch,branch,cbranch,fbranch,call,sibcall,dyncall,multi,milli,sh_func_adrs,parallel_branch")
662     (eq_attr "cpu" "8000"))
663   "inm0_8000+inm1_8000,rnm0_8000+rnm1_8000")
665 ;; We partial latency schedule the floating point units.
666 ;; They can issue/retire two at a time in the non-memory
667 ;; units.  We fix their latency at 2 cycles and they
668 ;; are fully pipelined.
669 (define_insn_reservation "Z5" 1
670  (and
671    (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
672    (eq_attr "cpu" "8000"))
673  "inm_8000,f_8000,rnm_8000")
675 ;; The fdivsqrt units are not pipelined and have a very long latency.  
676 ;; To keep the DFA from exploding, we do not show all the
677 ;; reservations for the divsqrt unit.
678 (define_insn_reservation "Z6" 17
679  (and
680    (eq_attr "type" "fpdivsgl,fpsqrtsgl")
681    (eq_attr "cpu" "8000"))
682  "inm_8000,fdivsqrt_8000*6,rnm_8000")
684 (define_insn_reservation "Z7" 31
685  (and
686    (eq_attr "type" "fpdivdbl,fpsqrtdbl")
687    (eq_attr "cpu" "8000"))
688  "inm_8000,fdivsqrt_8000*6,rnm_8000")
690 ;; Operand and operator predicates and constraints
692 (include "predicates.md")
693 (include "constraints.md")
695 ;; Compare instructions.
696 ;; This controls RTL generation and register allocation.
698 (define_insn ""
699   [(set (reg:CCFP 0)
700         (match_operator:CCFP 2 "comparison_operator"
701                              [(match_operand:SF 0 "reg_or_0_operand" "fG")
702                               (match_operand:SF 1 "reg_or_0_operand" "fG")]))]
703   "! TARGET_SOFT_FLOAT"
704   "fcmp,sgl,%Y2 %f0,%f1"
705   [(set_attr "length" "4")
706    (set_attr "type" "fpcc")])
708 (define_insn ""
709   [(set (reg:CCFP 0)
710         (match_operator:CCFP 2 "comparison_operator"
711                              [(match_operand:DF 0 "reg_or_0_operand" "fG")
712                               (match_operand:DF 1 "reg_or_0_operand" "fG")]))]
713   "! TARGET_SOFT_FLOAT"
714   "fcmp,dbl,%Y2 %f0,%f1"
715   [(set_attr "length" "4")
716    (set_attr "type" "fpcc")])
718 ;; Provide a means to emit the movccfp0 and movccfp1 optimization
719 ;; placeholders.  This is necessary in rare situations when a
720 ;; placeholder is re-emitted (see PR 8705).
722 (define_expand "movccfp"
723   [(set (reg:CCFP 0)
724         (match_operand 0 "const_int_operand" ""))]
725   "! TARGET_SOFT_FLOAT"
726   "
728   if ((unsigned HOST_WIDE_INT) INTVAL (operands[0]) > 1)
729     FAIL;
732 ;; The following patterns are optimization placeholders.  In almost
733 ;; all cases, the user of the condition code will be simplified and the
734 ;; original condition code setting insn should be eliminated.
736 (define_insn "*movccfp0"
737   [(set (reg:CCFP 0)
738         (const_int 0))]
739   "! TARGET_SOFT_FLOAT"
740   "fcmp,dbl,= %%fr0,%%fr0"
741   [(set_attr "length" "4")
742    (set_attr "type" "fpcc")])
744 (define_insn "*movccfp1"
745   [(set (reg:CCFP 0)
746         (const_int 1))]
747   "! TARGET_SOFT_FLOAT"
748   "fcmp,dbl,!= %%fr0,%%fr0"
749   [(set_attr "length" "4")
750    (set_attr "type" "fpcc")])
752 ;; scc insns.
754 (define_expand "cstoresi4"
755   [(set (match_operand:SI 0 "register_operand")
756         (match_operator:SI 1 "ordered_comparison_operator"
757          [(match_operand:SI 2 "reg_or_0_operand" "")
758           (match_operand:SI 3 "arith5_operand" "")]))]
759   "!TARGET_64BIT"
760   "")
762 ;; Instruction canonicalization puts immediate operands second, which
763 ;; is the reverse of what we want.
765 (define_insn "scc"
766   [(set (match_operand:SI 0 "register_operand" "=r")
767         (match_operator:SI 3 "comparison_operator"
768                            [(match_operand:SI 1 "reg_or_0_operand" "rM")
769                             (match_operand:SI 2 "arith11_operand" "rI")]))]
770   ""
771   "{com%I2clr|cmp%I2clr},%B3 %2,%r1,%0\;ldi 1,%0"
772   [(set_attr "type" "binary")
773    (set_attr "length" "8")])
775 (define_insn ""
776   [(set (match_operand:DI 0 "register_operand" "=r")
777         (match_operator:DI 3 "comparison_operator"
778                            [(match_operand:DI 1 "reg_or_0_operand" "rM")
779                             (match_operand:DI 2 "arith11_operand" "rI")]))]
780   "TARGET_64BIT"
781   "cmp%I2clr,*%B3 %2,%r1,%0\;ldi 1,%0"
782   [(set_attr "type" "binary")
783    (set_attr "length" "8")])
785 (define_insn "iorscc"
786   [(set (match_operand:SI 0 "register_operand" "=r")
787         (ior:SI (match_operator:SI 3 "comparison_operator"
788                                    [(match_operand:SI 1 "reg_or_0_operand" "rM")
789                                     (match_operand:SI 2 "arith11_operand" "rI")])
790                 (match_operator:SI 6 "comparison_operator"
791                                    [(match_operand:SI 4 "reg_or_0_operand" "rM")
792                                     (match_operand:SI 5 "arith11_operand" "rI")])))]
793   ""
794   "{com%I2clr|cmp%I2clr},%S3 %2,%r1,%%r0\;{com%I5clr|cmp%I5clr},%B6 %5,%r4,%0\;ldi 1,%0"
795   [(set_attr "type" "binary")
796    (set_attr "length" "12")])
798 (define_insn ""
799   [(set (match_operand:DI 0 "register_operand" "=r")
800         (ior:DI (match_operator:DI 3 "comparison_operator"
801                                    [(match_operand:DI 1 "reg_or_0_operand" "rM")
802                                     (match_operand:DI 2 "arith11_operand" "rI")])
803                 (match_operator:DI 6 "comparison_operator"
804                                    [(match_operand:DI 4 "reg_or_0_operand" "rM")
805                                     (match_operand:DI 5 "arith11_operand" "rI")])))]
806   "TARGET_64BIT"
807   "cmp%I2clr,*%S3 %2,%r1,%%r0\;cmp%I5clr,*%B6 %5,%r4,%0\;ldi 1,%0"
808   [(set_attr "type" "binary")
809    (set_attr "length" "12")])
811 ;; Combiner patterns for common operations performed with the output
812 ;; from an scc insn (negscc and incscc).
813 (define_insn "negscc"
814   [(set (match_operand:SI 0 "register_operand" "=r")
815         (neg:SI (match_operator:SI 3 "comparison_operator"
816                [(match_operand:SI 1 "reg_or_0_operand" "rM")
817                 (match_operand:SI 2 "arith11_operand" "rI")])))]
818   ""
819   "{com%I2clr|cmp%I2clr},%B3 %2,%r1,%0\;ldi -1,%0"
820   [(set_attr "type" "binary")
821    (set_attr "length" "8")])
823 (define_insn ""
824   [(set (match_operand:DI 0 "register_operand" "=r")
825         (neg:DI (match_operator:DI 3 "comparison_operator"
826                [(match_operand:DI 1 "reg_or_0_operand" "rM")
827                 (match_operand:DI 2 "arith11_operand" "rI")])))]
828   "TARGET_64BIT"
829   "cmp%I2clr,*%B3 %2,%r1,%0\;ldi -1,%0"
830   [(set_attr "type" "binary")
831    (set_attr "length" "8")])
833 ;; Patterns for adding/subtracting the result of a boolean expression from
834 ;; a register.  First we have special patterns that make use of the carry
835 ;; bit, and output only two instructions.  For the cases we can't in
836 ;; general do in two instructions, the incscc pattern at the end outputs
837 ;; two or three instructions.
839 (define_insn ""
840   [(set (match_operand:SI 0 "register_operand" "=r")
841         (plus:SI (leu:SI (match_operand:SI 2 "register_operand" "r")
842                          (match_operand:SI 3 "arith11_operand" "rI"))
843                  (match_operand:SI 1 "register_operand" "r")))]
844   ""
845   "sub%I3 %3,%2,%%r0\;{addc|add,c} %%r0,%1,%0"
846   [(set_attr "type" "binary")
847    (set_attr "length" "8")])
849 (define_insn ""
850   [(set (match_operand:DI 0 "register_operand" "=r")
851         (plus:DI (leu:DI (match_operand:DI 2 "register_operand" "r")
852                          (match_operand:DI 3 "arith11_operand" "rI"))
853                  (match_operand:DI 1 "register_operand" "r")))]
854   "TARGET_64BIT"
855   "sub%I3 %3,%2,%%r0\;add,dc %%r0,%1,%0"
856   [(set_attr "type" "binary")
857    (set_attr "length" "8")])
859 ; This need only accept registers for op3, since canonicalization
860 ; replaces geu with gtu when op3 is an integer.
861 (define_insn ""
862   [(set (match_operand:SI 0 "register_operand" "=r")
863         (plus:SI (geu:SI (match_operand:SI 2 "register_operand" "r")
864                          (match_operand:SI 3 "register_operand" "r"))
865                  (match_operand:SI 1 "register_operand" "r")))]
866   ""
867   "sub %2,%3,%%r0\;{addc|add,c} %%r0,%1,%0"
868   [(set_attr "type" "binary")
869    (set_attr "length" "8")])
871 (define_insn ""
872   [(set (match_operand:DI 0 "register_operand" "=r")
873         (plus:DI (geu:DI (match_operand:DI 2 "register_operand" "r")
874                          (match_operand:DI 3 "register_operand" "r"))
875                  (match_operand:DI 1 "register_operand" "r")))]
876   "TARGET_64BIT"
877   "sub %2,%3,%%r0\;add,dc %%r0,%1,%0"
878   [(set_attr "type" "binary")
879    (set_attr "length" "8")])
881 ; Match only integers for op3 here.  This is used as canonical form of the
882 ; geu pattern when op3 is an integer.  Don't match registers since we can't
883 ; make better code than the general incscc pattern.
884 (define_insn ""
885   [(set (match_operand:SI 0 "register_operand" "=r")
886         (plus:SI (gtu:SI (match_operand:SI 2 "register_operand" "r")
887                          (match_operand:SI 3 "int11_operand" "I"))
888                  (match_operand:SI 1 "register_operand" "r")))]
889   ""
890   "addi %k3,%2,%%r0\;{addc|add,c} %%r0,%1,%0"
891   [(set_attr "type" "binary")
892    (set_attr "length" "8")])
894 (define_insn ""
895   [(set (match_operand:DI 0 "register_operand" "=r")
896         (plus:DI (gtu:DI (match_operand:DI 2 "register_operand" "r")
897                          (match_operand:DI 3 "int11_operand" "I"))
898                  (match_operand:DI 1 "register_operand" "r")))]
899   "TARGET_64BIT"
900   "addi %k3,%2,%%r0\;add,dc %%r0,%1,%0"
901   [(set_attr "type" "binary")
902    (set_attr "length" "8")])
904 (define_insn "incscc"
905   [(set (match_operand:SI 0 "register_operand" "=r,r")
906         (plus:SI (match_operator:SI 4 "comparison_operator"
907                     [(match_operand:SI 2 "register_operand" "r,r")
908                      (match_operand:SI 3 "arith11_operand" "rI,rI")])
909                  (match_operand:SI 1 "register_operand" "0,?r")))]
910   ""
911   "@
912    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi 1,%0,%0
913    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi,tr 1,%1,%0\;copy %1,%0"
914   [(set_attr "type" "binary,binary")
915    (set_attr "length" "8,12")])
917 (define_insn ""
918   [(set (match_operand:DI 0 "register_operand" "=r,r")
919         (plus:DI (match_operator:DI 4 "comparison_operator"
920                     [(match_operand:DI 2 "register_operand" "r,r")
921                      (match_operand:DI 3 "arith11_operand" "rI,rI")])
922                  (match_operand:DI 1 "register_operand" "0,?r")))]
923   "TARGET_64BIT"
924   "@
925    cmp%I3clr,*%B4 %3,%2,%%r0\;addi 1,%0,%0
926    cmp%I3clr,*%B4 %3,%2,%%r0\;addi,tr 1,%1,%0\;copy %1,%0"
927   [(set_attr "type" "binary,binary")
928    (set_attr "length" "8,12")])
930 (define_insn ""
931   [(set (match_operand:SI 0 "register_operand" "=r")
932         (minus:SI (match_operand:SI 1 "register_operand" "r")
933                   (gtu:SI (match_operand:SI 2 "register_operand" "r")
934                           (match_operand:SI 3 "arith11_operand" "rI"))))]
935   ""
936   "sub%I3 %3,%2,%%r0\;{subb|sub,b} %1,%%r0,%0"
937   [(set_attr "type" "binary")
938    (set_attr "length" "8")])
940 (define_insn ""
941   [(set (match_operand:DI 0 "register_operand" "=r")
942         (minus:DI (match_operand:DI 1 "register_operand" "r")
943                   (gtu:DI (match_operand:DI 2 "register_operand" "r")
944                           (match_operand:DI 3 "arith11_operand" "rI"))))]
945   "TARGET_64BIT"
946   "sub%I3 %3,%2,%%r0\;sub,db %1,%%r0,%0"
947   [(set_attr "type" "binary")
948    (set_attr "length" "8")])
950 (define_insn ""
951   [(set (match_operand:SI 0 "register_operand" "=r")
952         (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
953                             (gtu:SI (match_operand:SI 2 "register_operand" "r")
954                                     (match_operand:SI 3 "arith11_operand" "rI")))
955                   (match_operand:SI 4 "register_operand" "r")))]
956   ""
957   "sub%I3 %3,%2,%%r0\;{subb|sub,b} %1,%4,%0"
958   [(set_attr "type" "binary")
959    (set_attr "length" "8")])
961 (define_insn ""
962   [(set (match_operand:DI 0 "register_operand" "=r")
963         (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
964                             (gtu:DI (match_operand:DI 2 "register_operand" "r")
965                                     (match_operand:DI 3 "arith11_operand" "rI")))
966                   (match_operand:DI 4 "register_operand" "r")))]
967   "TARGET_64BIT"
968   "sub%I3 %3,%2,%%r0\;sub,db %1,%4,%0"
969   [(set_attr "type" "binary")
970    (set_attr "length" "8")])
972 ; This need only accept registers for op3, since canonicalization
973 ; replaces ltu with leu when op3 is an integer.
974 (define_insn ""
975   [(set (match_operand:SI 0 "register_operand" "=r")
976         (minus:SI (match_operand:SI 1 "register_operand" "r")
977                   (ltu:SI (match_operand:SI 2 "register_operand" "r")
978                           (match_operand:SI 3 "register_operand" "r"))))]
979   ""
980   "sub %2,%3,%%r0\;{subb|sub,b} %1,%%r0,%0"
981   [(set_attr "type" "binary")
982    (set_attr "length" "8")])
984 (define_insn ""
985   [(set (match_operand:DI 0 "register_operand" "=r")
986         (minus:DI (match_operand:DI 1 "register_operand" "r")
987                   (ltu:DI (match_operand:DI 2 "register_operand" "r")
988                           (match_operand:DI 3 "register_operand" "r"))))]
989   "TARGET_64BIT"
990   "sub %2,%3,%%r0\;sub,db %1,%%r0,%0"
991   [(set_attr "type" "binary")
992    (set_attr "length" "8")])
994 (define_insn ""
995   [(set (match_operand:SI 0 "register_operand" "=r")
996         (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
997                             (ltu:SI (match_operand:SI 2 "register_operand" "r")
998                                     (match_operand:SI 3 "register_operand" "r")))
999                   (match_operand:SI 4 "register_operand" "r")))]
1000   ""
1001   "sub %2,%3,%%r0\;{subb|sub,b} %1,%4,%0"
1002   [(set_attr "type" "binary")
1003    (set_attr "length" "8")])
1005 (define_insn ""
1006   [(set (match_operand:DI 0 "register_operand" "=r")
1007         (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
1008                             (ltu:DI (match_operand:DI 2 "register_operand" "r")
1009                                     (match_operand:DI 3 "register_operand" "r")))
1010                   (match_operand:DI 4 "register_operand" "r")))]
1011   "TARGET_64BIT"
1012   "sub %2,%3,%%r0\;sub,db %1,%4,%0"
1013   [(set_attr "type" "binary")
1014    (set_attr "length" "8")])
1016 ; Match only integers for op3 here.  This is used as canonical form of the
1017 ; ltu pattern when op3 is an integer.  Don't match registers since we can't
1018 ; make better code than the general incscc pattern.
1019 (define_insn ""
1020   [(set (match_operand:SI 0 "register_operand" "=r")
1021         (minus:SI (match_operand:SI 1 "register_operand" "r")
1022                   (leu:SI (match_operand:SI 2 "register_operand" "r")
1023                           (match_operand:SI 3 "int11_operand" "I"))))]
1024   ""
1025   "addi %k3,%2,%%r0\;{subb|sub,b} %1,%%r0,%0"
1026   [(set_attr "type" "binary")
1027    (set_attr "length" "8")])
1029 (define_insn ""
1030   [(set (match_operand:DI 0 "register_operand" "=r")
1031         (minus:DI (match_operand:DI 1 "register_operand" "r")
1032                   (leu:DI (match_operand:DI 2 "register_operand" "r")
1033                           (match_operand:DI 3 "int11_operand" "I"))))]
1034   "TARGET_64BIT"
1035   "addi %k3,%2,%%r0\;sub,db %1,%%r0,%0"
1036   [(set_attr "type" "binary")
1037    (set_attr "length" "8")])
1039 (define_insn ""
1040   [(set (match_operand:SI 0 "register_operand" "=r")
1041         (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
1042                             (leu:SI (match_operand:SI 2 "register_operand" "r")
1043                                     (match_operand:SI 3 "int11_operand" "I")))
1044                   (match_operand:SI 4 "register_operand" "r")))]
1045   ""
1046   "addi %k3,%2,%%r0\;{subb|sub,b} %1,%4,%0"
1047   [(set_attr "type" "binary")
1048    (set_attr "length" "8")])
1050 (define_insn ""
1051   [(set (match_operand:DI 0 "register_operand" "=r")
1052         (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
1053                             (leu:DI (match_operand:DI 2 "register_operand" "r")
1054                                     (match_operand:DI 3 "int11_operand" "I")))
1055                   (match_operand:DI 4 "register_operand" "r")))]
1056   "TARGET_64BIT"
1057   "addi %k3,%2,%%r0\;sub,db %1,%4,%0"
1058   [(set_attr "type" "binary")
1059    (set_attr "length" "8")])
1061 (define_insn "decscc"
1062   [(set (match_operand:SI 0 "register_operand" "=r,r")
1063         (minus:SI (match_operand:SI 1 "register_operand" "0,?r")
1064                   (match_operator:SI 4 "comparison_operator"
1065                      [(match_operand:SI 2 "register_operand" "r,r")
1066                       (match_operand:SI 3 "arith11_operand" "rI,rI")])))]
1067   ""
1068   "@
1069    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi -1,%0,%0
1070    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi,tr -1,%1,%0\;copy %1,%0"
1071   [(set_attr "type" "binary,binary")
1072    (set_attr "length" "8,12")])
1074 (define_insn ""
1075   [(set (match_operand:DI 0 "register_operand" "=r,r")
1076         (minus:DI (match_operand:DI 1 "register_operand" "0,?r")
1077                   (match_operator:DI 4 "comparison_operator"
1078                      [(match_operand:DI 2 "register_operand" "r,r")
1079                       (match_operand:DI 3 "arith11_operand" "rI,rI")])))]
1080   "TARGET_64BIT"
1081   "@
1082    cmp%I3clr,*%B4 %3,%2,%%r0\;addi -1,%0,%0
1083    cmp%I3clr,*%B4 %3,%2,%%r0\;addi,tr -1,%1,%0\;copy %1,%0"
1084   [(set_attr "type" "binary,binary")
1085    (set_attr "length" "8,12")])
1087 ; Patterns for max and min.  (There is no need for an earlyclobber in the
1088 ; last alternative since the middle alternative will match if op0 == op1.)
1090 (define_insn "sminsi3"
1091   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1092         (smin:SI (match_operand:SI 1 "register_operand" "%0,0,r")
1093                  (match_operand:SI 2 "arith11_operand" "r,I,M")))]
1094   ""
1095   "@
1096   {comclr|cmpclr},> %2,%0,%%r0\;copy %2,%0
1097   {comiclr|cmpiclr},> %2,%0,%%r0\;ldi %2,%0
1098   {comclr|cmpclr},> %1,%r2,%0\;copy %1,%0"
1099 [(set_attr "type" "multi,multi,multi")
1100  (set_attr "length" "8,8,8")])
1102 (define_insn "smindi3"
1103   [(set (match_operand:DI 0 "register_operand" "=r,r,r")
1104         (smin:DI (match_operand:DI 1 "register_operand" "%0,0,r")
1105                  (match_operand:DI 2 "arith11_operand" "r,I,M")))]
1106   "TARGET_64BIT"
1107   "@
1108   cmpclr,*> %2,%0,%%r0\;copy %2,%0
1109   cmpiclr,*> %2,%0,%%r0\;ldi %2,%0
1110   cmpclr,*> %1,%r2,%0\;copy %1,%0"
1111 [(set_attr "type" "multi,multi,multi")
1112  (set_attr "length" "8,8,8")])
1114 (define_insn "uminsi3"
1115   [(set (match_operand:SI 0 "register_operand" "=r,r")
1116         (umin:SI (match_operand:SI 1 "register_operand" "%0,0")
1117                  (match_operand:SI 2 "arith11_operand" "r,I")))]
1118   ""
1119   "@
1120   {comclr|cmpclr},>> %2,%0,%%r0\;copy %2,%0
1121   {comiclr|cmpiclr},>> %2,%0,%%r0\;ldi %2,%0"
1122 [(set_attr "type" "multi,multi")
1123  (set_attr "length" "8,8")])
1125 (define_insn "umindi3"
1126   [(set (match_operand:DI 0 "register_operand" "=r,r")
1127         (umin:DI (match_operand:DI 1 "register_operand" "%0,0")
1128                  (match_operand:DI 2 "arith11_operand" "r,I")))]
1129   "TARGET_64BIT"
1130   "@
1131   cmpclr,*>> %2,%0,%%r0\;copy %2,%0
1132   cmpiclr,*>> %2,%0,%%r0\;ldi %2,%0"
1133 [(set_attr "type" "multi,multi")
1134  (set_attr "length" "8,8")])
1136 (define_insn "smaxsi3"
1137   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1138         (smax:SI (match_operand:SI 1 "register_operand" "%0,0,r")
1139                  (match_operand:SI 2 "arith11_operand" "r,I,M")))]
1140   ""
1141   "@
1142   {comclr|cmpclr},< %2,%0,%%r0\;copy %2,%0
1143   {comiclr|cmpiclr},< %2,%0,%%r0\;ldi %2,%0
1144   {comclr|cmpclr},< %1,%r2,%0\;copy %1,%0"
1145 [(set_attr "type" "multi,multi,multi")
1146  (set_attr "length" "8,8,8")])
1148 (define_insn "smaxdi3"
1149   [(set (match_operand:DI 0 "register_operand" "=r,r,r")
1150         (smax:DI (match_operand:DI 1 "register_operand" "%0,0,r")
1151                  (match_operand:DI 2 "arith11_operand" "r,I,M")))]
1152   "TARGET_64BIT"
1153   "@
1154   cmpclr,*< %2,%0,%%r0\;copy %2,%0
1155   cmpiclr,*< %2,%0,%%r0\;ldi %2,%0
1156   cmpclr,*< %1,%r2,%0\;copy %1,%0"
1157 [(set_attr "type" "multi,multi,multi")
1158  (set_attr "length" "8,8,8")])
1160 (define_insn "umaxsi3"
1161   [(set (match_operand:SI 0 "register_operand" "=r,r")
1162         (umax:SI (match_operand:SI 1 "register_operand" "%0,0")
1163                  (match_operand:SI 2 "arith11_operand" "r,I")))]
1164   ""
1165   "@
1166   {comclr|cmpclr},<< %2,%0,%%r0\;copy %2,%0
1167   {comiclr|cmpiclr},<< %2,%0,%%r0\;ldi %2,%0"
1168 [(set_attr "type" "multi,multi")
1169  (set_attr "length" "8,8")])
1171 (define_insn "umaxdi3"
1172   [(set (match_operand:DI 0 "register_operand" "=r,r")
1173         (umax:DI (match_operand:DI 1 "register_operand" "%0,0")
1174                  (match_operand:DI 2 "arith11_operand" "r,I")))]
1175   "TARGET_64BIT"
1176   "@
1177   cmpclr,*<< %2,%0,%%r0\;copy %2,%0
1178   cmpiclr,*<< %2,%0,%%r0\;ldi %2,%0"
1179 [(set_attr "type" "multi,multi")
1180  (set_attr "length" "8,8")])
1182 (define_insn "absqi2"
1183   [(set (match_operand:QI 0 "register_operand" "=r")
1184         (abs:QI (match_operand:QI 1 "register_operand" "r")))]
1185   ""
1186   "{extrs|extrw,s},>= %1,31,8,%0\;subi 0,%0,%0"
1187   [(set_attr "type" "multi")
1188    (set_attr "length" "8")])
1190 (define_insn "abshi2"
1191   [(set (match_operand:HI 0 "register_operand" "=r")
1192         (abs:HI (match_operand:HI 1 "register_operand" "r")))]
1193   ""
1194   "{extrs|extrw,s},>= %1,31,16,%0\;subi 0,%0,%0"
1195   [(set_attr "type" "multi")
1196    (set_attr "length" "8")])
1198 (define_insn "abssi2"
1199   [(set (match_operand:SI 0 "register_operand" "=r")
1200         (abs:SI (match_operand:SI 1 "register_operand" "r")))]
1201   ""
1202   "or,>= %%r0,%1,%0\;subi 0,%0,%0"
1203   [(set_attr "type" "multi")
1204    (set_attr "length" "8")])
1206 (define_insn "absdi2"
1207   [(set (match_operand:DI 0 "register_operand" "=r")
1208         (abs:DI (match_operand:DI 1 "register_operand" "r")))]
1209   "TARGET_64BIT"
1210   "or,*>= %%r0,%1,%0\;subi 0,%0,%0"
1211   [(set_attr "type" "multi")
1212    (set_attr "length" "8")])
1214 (define_insn "bswaphi2"
1215   [(set (match_operand:HI 0 "register_operand" "=&r")
1216         (bswap:HI (match_operand:HI 1 "register_operand" "r")))]
1217   ""
1218   "{extru|extrw,u} %1,23,8,%0\;{dep|depw} %1,23,8,%0"
1219   [(set_attr "type" "multi")
1220    (set_attr "length" "8")])
1222 (define_insn "bswapsi2"
1223   [(set (match_operand:SI 0 "register_operand" "=&r")
1224         (bswap:SI (match_operand:SI 1 "register_operand" "r")))]
1225   ""
1226   "{shd|shrpw} %1,%1,16,%0\;{dep|depw} %0,15,8,%0\;{shd|shrpw} %1,%0,8,%0"
1227   [(set_attr "type" "multi")
1228    (set_attr "length" "12")])
1230 (define_insn "bswapdi2"
1231   [(set (match_operand:DI 0 "register_operand" "=&r")
1232         (bswap:DI (match_operand:DI 1 "register_operand" "r")))
1233    (clobber (match_scratch:DI 2 "=r"))]
1234   "TARGET_64BIT"
1235   "permh,3210 %1,%2\;hshl %2,8,%0\;hshr,u %2,8,%2\;or %0,%2,%0"
1236   [(set_attr "type" "multi")
1237    (set_attr "length" "16")])
1239 ;;; Experimental conditional move patterns
1241 (define_expand "movsicc"
1242   [(set (match_operand:SI 0 "register_operand" "")
1243         (if_then_else:SI
1244          (match_operand 1 "comparison_operator" "")
1245          (match_operand:SI 2 "reg_or_cint_move_operand" "")
1246          (match_operand:SI 3 "reg_or_cint_move_operand" "")))]
1247   ""
1248   "
1250   if (GET_MODE (XEXP (operands[1], 0)) != SImode
1251       || GET_MODE (XEXP (operands[1], 0)) != GET_MODE (XEXP (operands[1], 1)))
1252     FAIL;
1255 ;; We used to accept any register for op1.
1257 ;; However, it loses sometimes because the compiler will end up using
1258 ;; different registers for op0 and op1 in some critical cases.  local-alloc
1259 ;; will  not tie op0 and op1 because op0 is used in multiple basic blocks.
1261 ;; If/when global register allocation supports tying we should allow any
1262 ;; register for op1 again.
1263 (define_insn ""
1264   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
1265         (if_then_else:SI
1266          (match_operator 2 "comparison_operator"
1267             [(match_operand:SI 3 "register_operand" "r,r,r,r")
1268              (match_operand:SI 4 "arith11_operand" "rI,rI,rI,rI")])
1269          (match_operand:SI 1 "reg_or_cint_move_operand" "0,J,N,K")
1270          (const_int 0)))]
1271   ""
1272   "@
1273    {com%I4clr|cmp%I4clr},%S2 %4,%3,%%r0\;ldi 0,%0
1274    {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;ldi %1,%0
1275    {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;ldil L'%1,%0
1276    {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;{zdepi|depwi,z} %Z1,%0"
1277   [(set_attr "type" "multi,multi,multi,nullshift")
1278    (set_attr "length" "8,8,8,8")])
1280 (define_insn ""
1281   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r,r,r")
1282         (if_then_else:SI
1283          (match_operator 5 "comparison_operator"
1284             [(match_operand:SI 3 "register_operand" "r,r,r,r,r,r,r,r")
1285              (match_operand:SI 4 "arith11_operand" "rI,rI,rI,rI,rI,rI,rI,rI")])
1286          (match_operand:SI 1 "reg_or_cint_move_operand" "0,0,0,0,r,J,N,K")
1287          (match_operand:SI 2 "reg_or_cint_move_operand" "r,J,N,K,0,0,0,0")))]
1288   ""
1289   "@
1290    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;copy %2,%0
1291    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;ldi %2,%0
1292    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;ldil L'%2,%0
1293    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;{zdepi|depwi,z} %Z2,%0
1294    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;copy %1,%0
1295    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;ldi %1,%0
1296    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;ldil L'%1,%0
1297    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;{zdepi|depwi,z} %Z1,%0"
1298   [(set_attr "type" "multi,multi,multi,nullshift,multi,multi,multi,nullshift")
1299    (set_attr "length" "8,8,8,8,8,8,8,8")])
1301 (define_expand "movdicc"
1302   [(set (match_operand:DI 0 "register_operand" "")
1303         (if_then_else:DI
1304          (match_operand 1 "comparison_operator" "")
1305          (match_operand:DI 2 "reg_or_cint_move_operand" "")
1306          (match_operand:DI 3 "reg_or_cint_move_operand" "")))]
1307   "TARGET_64BIT"
1308   "
1310   if (GET_MODE (XEXP (operands[1], 0)) != DImode
1311       || GET_MODE (XEXP (operands[1], 0)) != GET_MODE (XEXP (operands[1], 1)))
1312     FAIL;
1315 ; We need the first constraint alternative in order to avoid
1316 ; earlyclobbers on all other alternatives.
1317 (define_insn ""
1318   [(set (match_operand:DI 0 "register_operand" "=r,r,r,r,r")
1319         (if_then_else:DI
1320          (match_operator 2 "comparison_operator"
1321             [(match_operand:DI 3 "register_operand" "r,r,r,r,r")
1322              (match_operand:DI 4 "arith11_operand" "rI,rI,rI,rI,rI")])
1323          (match_operand:DI 1 "reg_or_cint_move_operand" "0,r,J,N,K")
1324          (const_int 0)))]
1325   "TARGET_64BIT"
1326   "@
1327    cmp%I4clr,*%S2 %4,%3,%%r0\;ldi 0,%0
1328    cmp%I4clr,*%B2 %4,%3,%0\;copy %1,%0
1329    cmp%I4clr,*%B2 %4,%3,%0\;ldi %1,%0
1330    cmp%I4clr,*%B2 %4,%3,%0\;ldil L'%1,%0
1331    cmp%I4clr,*%B2 %4,%3,%0\;depdi,z %z1,%0"
1332   [(set_attr "type" "multi,multi,multi,multi,nullshift")
1333    (set_attr "length" "8,8,8,8,8")])
1335 (define_insn ""
1336   [(set (match_operand:DI 0 "register_operand" "=r,r,r,r,r,r,r,r")
1337         (if_then_else:DI
1338          (match_operator 5 "comparison_operator"
1339             [(match_operand:DI 3 "register_operand" "r,r,r,r,r,r,r,r")
1340              (match_operand:DI 4 "arith11_operand" "rI,rI,rI,rI,rI,rI,rI,rI")])
1341          (match_operand:DI 1 "reg_or_cint_move_operand" "0,0,0,0,r,J,N,K")
1342          (match_operand:DI 2 "reg_or_cint_move_operand" "r,J,N,K,0,0,0,0")))]
1343   "TARGET_64BIT"
1344   "@
1345    cmp%I4clr,*%S5 %4,%3,%%r0\;copy %2,%0
1346    cmp%I4clr,*%S5 %4,%3,%%r0\;ldi %2,%0
1347    cmp%I4clr,*%S5 %4,%3,%%r0\;ldil L'%2,%0
1348    cmp%I4clr,*%S5 %4,%3,%%r0\;depdi,z %z2,%0
1349    cmp%I4clr,*%B5 %4,%3,%%r0\;copy %1,%0
1350    cmp%I4clr,*%B5 %4,%3,%%r0\;ldi %1,%0
1351    cmp%I4clr,*%B5 %4,%3,%%r0\;ldil L'%1,%0
1352    cmp%I4clr,*%B5 %4,%3,%%r0\;depdi,z %z1,%0"
1353   [(set_attr "type" "multi,multi,multi,nullshift,multi,multi,multi,nullshift")
1354    (set_attr "length" "8,8,8,8,8,8,8,8")])
1356 ;; Conditional Branches
1358 (define_expand "cbranchdi4"
1359   [(set (pc)
1360         (if_then_else (match_operator 0 "ordered_comparison_operator"
1361                        [(match_operand:DI 1 "reg_or_0_operand" "")
1362                         (match_operand:DI 2 "register_operand" "")])
1363                       (label_ref (match_operand 3 "" ""))
1364                       (pc)))]
1365   "TARGET_64BIT"
1366   "")
1368 (define_expand "cbranchsi4"
1369   [(set (pc)
1370         (if_then_else (match_operator 0 "ordered_comparison_operator"
1371                        [(match_operand:SI 1 "reg_or_0_operand" "")
1372                         (match_operand:SI 2 "arith5_operand" "")])
1373                       (label_ref (match_operand 3 "" ""))
1374                       (pc)))]
1375   ""
1376   "")
1378 (define_expand "cbranchsf4"
1379   [(set (pc)
1380         (if_then_else (match_operator 0 "comparison_operator"
1381                        [(match_operand:SF 1 "reg_or_0_operand" "")
1382                         (match_operand:SF 2 "reg_or_0_operand" "")])
1383                       (label_ref (match_operand 3 "" ""))
1384                       (pc)))]
1385   ""
1386   "
1388   pa_emit_bcond_fp (operands);
1389   DONE;
1393 (define_expand "cbranchdf4"
1394   [(set (pc)
1395         (if_then_else (match_operator 0 "comparison_operator"
1396                        [(match_operand:DF 1 "reg_or_0_operand" "")
1397                         (match_operand:DF 2 "reg_or_0_operand" "")])
1398                       (label_ref (match_operand 3 "" ""))
1399                       (pc)))]
1400   ""
1401   "
1403   pa_emit_bcond_fp (operands);
1404   DONE;
1407 ;; Match the branch patterns.
1410 ;; Note a long backward conditional branch with an annulled delay slot
1411 ;; has a length of 12.
1412 (define_insn ""
1413   [(set (pc)
1414         (if_then_else
1415          (match_operator 3 "comparison_operator"
1416                          [(match_operand:SI 1 "reg_or_0_operand" "rM")
1417                           (match_operand:SI 2 "arith5_operand" "rL")])
1418          (label_ref (match_operand 0 "" ""))
1419          (pc)))]
1420   ""
1421   "*
1423   return pa_output_cbranch (operands, 0, insn);
1425 [(set_attr "type" "cbranch")
1426  (set (attr "length")
1427     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1428                (const_int MAX_12BIT_OFFSET))
1429            (const_int 4)
1430            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1431                (const_int MAX_17BIT_OFFSET))
1432            (const_int 8)
1433            (match_test "TARGET_PORTABLE_RUNTIME")
1434            (const_int 24)
1435            (not (match_test "flag_pic"))
1436            (const_int 20)]
1437           (const_int 28)))])
1439 ;; Match the negated branch.
1441 (define_insn ""
1442   [(set (pc)
1443         (if_then_else
1444          (match_operator 3 "comparison_operator"
1445                          [(match_operand:SI 1 "reg_or_0_operand" "rM")
1446                           (match_operand:SI 2 "arith5_operand" "rL")])
1447          (pc)
1448          (label_ref (match_operand 0 "" ""))))]
1449   ""
1450   "*
1452   return pa_output_cbranch (operands, 1, insn);
1454 [(set_attr "type" "cbranch")
1455  (set (attr "length")
1456     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1457                (const_int MAX_12BIT_OFFSET))
1458            (const_int 4)
1459            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1460                (const_int MAX_17BIT_OFFSET))
1461            (const_int 8)
1462            (match_test "TARGET_PORTABLE_RUNTIME")
1463            (const_int 24)
1464            (not (match_test "flag_pic"))
1465            (const_int 20)]
1466           (const_int 28)))])
1468 (define_insn ""
1469   [(set (pc)
1470         (if_then_else
1471          (match_operator 3 "comparison_operator"
1472                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1473                           (match_operand:DI 2 "reg_or_0_operand" "rM")])
1474          (label_ref (match_operand 0 "" ""))
1475          (pc)))]
1476   "TARGET_64BIT"
1477   "*
1479   return pa_output_cbranch (operands, 0, insn);
1481 [(set_attr "type" "cbranch")
1482  (set (attr "length")
1483     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1484                (const_int MAX_12BIT_OFFSET))
1485            (const_int 4)
1486            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1487                (const_int MAX_17BIT_OFFSET))
1488            (const_int 8)
1489            (match_test "TARGET_PORTABLE_RUNTIME")
1490            (const_int 24)
1491            (not (match_test "flag_pic"))
1492            (const_int 20)]
1493           (const_int 28)))])
1495 ;; Match the negated branch.
1497 (define_insn ""
1498   [(set (pc)
1499         (if_then_else
1500          (match_operator 3 "comparison_operator"
1501                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1502                           (match_operand:DI 2 "reg_or_0_operand" "rM")])
1503          (pc)
1504          (label_ref (match_operand 0 "" ""))))]
1505   "TARGET_64BIT"
1506   "*
1508   return pa_output_cbranch (operands, 1, insn);
1510 [(set_attr "type" "cbranch")
1511  (set (attr "length")
1512     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1513                (const_int MAX_12BIT_OFFSET))
1514            (const_int 4)
1515            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1516                (const_int MAX_17BIT_OFFSET))
1517            (const_int 8)
1518            (match_test "TARGET_PORTABLE_RUNTIME")
1519            (const_int 24)
1520            (not (match_test "flag_pic"))
1521            (const_int 20)]
1522           (const_int 28)))])
1523 (define_insn ""
1524   [(set (pc)
1525         (if_then_else
1526          (match_operator 3 "cmpib_comparison_operator"
1527                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1528                           (match_operand:DI 2 "arith5_operand" "rL")])
1529          (label_ref (match_operand 0 "" ""))
1530          (pc)))]
1531   "TARGET_64BIT"
1532   "*
1534   return pa_output_cbranch (operands, 0, insn);
1536 [(set_attr "type" "cbranch")
1537  (set (attr "length")
1538     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1539                (const_int MAX_12BIT_OFFSET))
1540            (const_int 4)
1541            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1542                (const_int MAX_17BIT_OFFSET))
1543            (const_int 8)
1544            (match_test "TARGET_PORTABLE_RUNTIME")
1545            (const_int 24)
1546            (not (match_test "flag_pic"))
1547            (const_int 20)]
1548           (const_int 28)))])
1550 ;; Match the negated branch.
1552 (define_insn ""
1553   [(set (pc)
1554         (if_then_else
1555          (match_operator 3 "cmpib_comparison_operator"
1556                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1557                           (match_operand:DI 2 "arith5_operand" "rL")])
1558          (pc)
1559          (label_ref (match_operand 0 "" ""))))]
1560   "TARGET_64BIT"
1561   "*
1563   return pa_output_cbranch (operands, 1, insn);
1565 [(set_attr "type" "cbranch")
1566  (set (attr "length")
1567     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1568                (const_int MAX_12BIT_OFFSET))
1569            (const_int 4)
1570            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1571                (const_int MAX_17BIT_OFFSET))
1572            (const_int 8)
1573            (match_test "TARGET_PORTABLE_RUNTIME")
1574            (const_int 24)
1575            (not (match_test "flag_pic"))
1576            (const_int 20)]
1577           (const_int 28)))])
1579 ;; Branch on Bit patterns.
1580 (define_insn ""
1581   [(set (pc)
1582         (if_then_else
1583          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1584                               (const_int 1)
1585                               (match_operand:SI 1 "uint5_operand" ""))
1586              (const_int 0))
1587          (label_ref (match_operand 2 "" ""))
1588          (pc)))]
1589   ""
1590   "*
1592   return pa_output_bb (operands, 0, insn, 0);
1594 [(set_attr "type" "cbranch")
1595  (set (attr "length")
1596     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1597                (const_int MAX_12BIT_OFFSET))
1598            (const_int 4)
1599            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1600                (const_int MAX_17BIT_OFFSET))
1601            (const_int 8)
1602            (match_test "TARGET_PORTABLE_RUNTIME")
1603            (const_int 24)
1604            (not (match_test "flag_pic"))
1605            (const_int 20)]
1606           (const_int 28)))])
1608 (define_insn ""
1609   [(set (pc)
1610         (if_then_else
1611          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1612                               (const_int 1)
1613                               (match_operand:DI 1 "uint32_operand" ""))
1614              (const_int 0))
1615          (label_ref (match_operand 2 "" ""))
1616          (pc)))]
1617   "TARGET_64BIT"
1618   "*
1620   return pa_output_bb (operands, 0, insn, 0);
1622 [(set_attr "type" "cbranch")
1623  (set (attr "length")
1624     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1625                (const_int MAX_12BIT_OFFSET))
1626            (const_int 4)
1627            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1628                (const_int MAX_17BIT_OFFSET))
1629            (const_int 8)
1630            (match_test "TARGET_PORTABLE_RUNTIME")
1631            (const_int 24)
1632            (not (match_test "flag_pic"))
1633            (const_int 20)]
1634           (const_int 28)))])
1636 (define_insn ""
1637   [(set (pc)
1638         (if_then_else
1639          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1640                               (const_int 1)
1641                               (match_operand:SI 1 "uint5_operand" ""))
1642              (const_int 0))
1643          (pc)
1644          (label_ref (match_operand 2 "" ""))))]
1645   ""
1646   "*
1648   return pa_output_bb (operands, 1, insn, 0);
1650 [(set_attr "type" "cbranch")
1651  (set (attr "length")
1652     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1653                (const_int MAX_12BIT_OFFSET))
1654            (const_int 4)
1655            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1656                (const_int MAX_17BIT_OFFSET))
1657            (const_int 8)
1658            (match_test "TARGET_PORTABLE_RUNTIME")
1659            (const_int 24)
1660            (not (match_test "flag_pic"))
1661            (const_int 20)]
1662           (const_int 28)))])
1664 (define_insn ""
1665   [(set (pc)
1666         (if_then_else
1667          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1668                               (const_int 1)
1669                               (match_operand:DI 1 "uint32_operand" ""))
1670              (const_int 0))
1671          (pc)
1672          (label_ref (match_operand 2 "" ""))))]
1673   "TARGET_64BIT"
1674   "*
1676   return pa_output_bb (operands, 1, insn, 0);
1678 [(set_attr "type" "cbranch")
1679  (set (attr "length")
1680     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1681                (const_int MAX_12BIT_OFFSET))
1682            (const_int 4)
1683            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1684                (const_int MAX_17BIT_OFFSET))
1685            (const_int 8)
1686            (match_test "TARGET_PORTABLE_RUNTIME")
1687            (const_int 24)
1688            (not (match_test "flag_pic"))
1689            (const_int 20)]
1690           (const_int 28)))])
1692 (define_insn ""
1693   [(set (pc)
1694         (if_then_else
1695          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1696                               (const_int 1)
1697                               (match_operand:SI 1 "uint5_operand" ""))
1698              (const_int 0))
1699          (label_ref (match_operand 2 "" ""))
1700          (pc)))]
1701   ""
1702   "*
1704   return pa_output_bb (operands, 0, insn, 1);
1706 [(set_attr "type" "cbranch")
1707  (set (attr "length")
1708     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1709                (const_int MAX_12BIT_OFFSET))
1710            (const_int 4)
1711            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1712                (const_int MAX_17BIT_OFFSET))
1713            (const_int 8)
1714            (match_test "TARGET_PORTABLE_RUNTIME")
1715            (const_int 24)
1716            (not (match_test "flag_pic"))
1717            (const_int 20)]
1718           (const_int 28)))])
1720 (define_insn ""
1721   [(set (pc)
1722         (if_then_else
1723          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1724                               (const_int 1)
1725                               (match_operand:DI 1 "uint32_operand" ""))
1726              (const_int 0))
1727          (label_ref (match_operand 2 "" ""))
1728          (pc)))]
1729   "TARGET_64BIT"
1730   "*
1732   return pa_output_bb (operands, 0, insn, 1);
1734 [(set_attr "type" "cbranch")
1735  (set (attr "length")
1736     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1737                (const_int MAX_12BIT_OFFSET))
1738            (const_int 4)
1739            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1740                (const_int MAX_17BIT_OFFSET))
1741            (const_int 8)
1742            (match_test "TARGET_PORTABLE_RUNTIME")
1743            (const_int 24)
1744            (not (match_test "flag_pic"))
1745            (const_int 20)]
1746           (const_int 28)))])
1748 (define_insn ""
1749   [(set (pc)
1750         (if_then_else
1751          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1752                               (const_int 1)
1753                               (match_operand:SI 1 "uint5_operand" ""))
1754              (const_int 0))
1755          (pc)
1756          (label_ref (match_operand 2 "" ""))))]
1757   ""
1758   "*
1760   return pa_output_bb (operands, 1, insn, 1);
1762 [(set_attr "type" "cbranch")
1763  (set (attr "length")
1764     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1765                (const_int MAX_12BIT_OFFSET))
1766            (const_int 4)
1767            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1768                (const_int MAX_17BIT_OFFSET))
1769            (const_int 8)
1770            (match_test "TARGET_PORTABLE_RUNTIME")
1771            (const_int 24)
1772            (not (match_test "flag_pic"))
1773            (const_int 20)]
1774           (const_int 28)))])
1776 (define_insn ""
1777   [(set (pc)
1778         (if_then_else
1779          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1780                               (const_int 1)
1781                               (match_operand:DI 1 "uint32_operand" ""))
1782              (const_int 0))
1783          (pc)
1784          (label_ref (match_operand 2 "" ""))))]
1785   "TARGET_64BIT"
1786   "*
1788   return pa_output_bb (operands, 1, insn, 1);
1790 [(set_attr "type" "cbranch")
1791  (set (attr "length")
1792     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1793                (const_int MAX_12BIT_OFFSET))
1794            (const_int 4)
1795            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1796                (const_int MAX_17BIT_OFFSET))
1797            (const_int 8)
1798            (match_test "TARGET_PORTABLE_RUNTIME")
1799            (const_int 24)
1800            (not (match_test "flag_pic"))
1801            (const_int 20)]
1802           (const_int 28)))])
1804 ;; Branch on Variable Bit patterns.
1805 (define_insn ""
1806   [(set (pc)
1807         (if_then_else
1808          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1809                               (const_int 1)
1810                               (match_operand:SI 1 "register_operand" "q"))
1811              (const_int 0))
1812          (label_ref (match_operand 2 "" ""))
1813          (pc)))]
1814   ""
1815   "*
1817   return pa_output_bvb (operands, 0, insn, 0);
1819 [(set_attr "type" "cbranch")
1820  (set (attr "length")
1821     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1822                (const_int MAX_12BIT_OFFSET))
1823            (const_int 4)
1824            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1825                (const_int MAX_17BIT_OFFSET))
1826            (const_int 8)
1827            (match_test "TARGET_PORTABLE_RUNTIME")
1828            (const_int 24)
1829            (not (match_test "flag_pic"))
1830            (const_int 20)]
1831           (const_int 28)))])
1833 (define_insn ""
1834   [(set (pc)
1835         (if_then_else
1836          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1837                               (const_int 1)
1838                               (match_operand:DI 1 "register_operand" "q"))
1839              (const_int 0))
1840          (label_ref (match_operand 2 "" ""))
1841          (pc)))]
1842   "TARGET_64BIT"
1843   "*
1845   return pa_output_bvb (operands, 0, insn, 0);
1847 [(set_attr "type" "cbranch")
1848  (set (attr "length")
1849     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1850                (const_int MAX_12BIT_OFFSET))
1851            (const_int 4)
1852            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1853                (const_int MAX_17BIT_OFFSET))
1854            (const_int 8)
1855            (match_test "TARGET_PORTABLE_RUNTIME")
1856            (const_int 24)
1857            (not (match_test "flag_pic"))
1858            (const_int 20)]
1859           (const_int 28)))])
1861 (define_insn ""
1862   [(set (pc)
1863         (if_then_else
1864          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1865                               (const_int 1)
1866                               (match_operand:SI 1 "register_operand" "q"))
1867              (const_int 0))
1868          (pc)
1869          (label_ref (match_operand 2 "" ""))))]
1870   ""
1871   "*
1873   return pa_output_bvb (operands, 1, insn, 0);
1875 [(set_attr "type" "cbranch")
1876  (set (attr "length")
1877     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1878                (const_int MAX_12BIT_OFFSET))
1879            (const_int 4)
1880            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1881                (const_int MAX_17BIT_OFFSET))
1882            (const_int 8)
1883            (match_test "TARGET_PORTABLE_RUNTIME")
1884            (const_int 24)
1885            (not (match_test "flag_pic"))
1886            (const_int 20)]
1887           (const_int 28)))])
1889 (define_insn ""
1890   [(set (pc)
1891         (if_then_else
1892          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1893                               (const_int 1)
1894                               (match_operand:DI 1 "register_operand" "q"))
1895              (const_int 0))
1896          (pc)
1897          (label_ref (match_operand 2 "" ""))))]
1898   "TARGET_64BIT"
1899   "*
1901   return pa_output_bvb (operands, 1, insn, 0);
1903 [(set_attr "type" "cbranch")
1904  (set (attr "length")
1905     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1906                (const_int MAX_12BIT_OFFSET))
1907            (const_int 4)
1908            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1909                (const_int MAX_17BIT_OFFSET))
1910            (const_int 8)
1911            (match_test "TARGET_PORTABLE_RUNTIME")
1912            (const_int 24)
1913            (not (match_test "flag_pic"))
1914            (const_int 20)]
1915           (const_int 28)))])
1917 (define_insn ""
1918   [(set (pc)
1919         (if_then_else
1920          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1921                               (const_int 1)
1922                               (match_operand:SI 1 "register_operand" "q"))
1923              (const_int 0))
1924          (label_ref (match_operand 2 "" ""))
1925          (pc)))]
1926   ""
1927   "*
1929   return pa_output_bvb (operands, 0, insn, 1);
1931 [(set_attr "type" "cbranch")
1932  (set (attr "length")
1933     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1934                (const_int MAX_12BIT_OFFSET))
1935            (const_int 4)
1936            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1937                (const_int MAX_17BIT_OFFSET))
1938            (const_int 8)
1939            (match_test "TARGET_PORTABLE_RUNTIME")
1940            (const_int 24)
1941            (not (match_test "flag_pic"))
1942            (const_int 20)]
1943           (const_int 28)))])
1945 (define_insn ""
1946   [(set (pc)
1947         (if_then_else
1948          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1949                               (const_int 1)
1950                               (match_operand:DI 1 "register_operand" "q"))
1951              (const_int 0))
1952          (label_ref (match_operand 2 "" ""))
1953          (pc)))]
1954   "TARGET_64BIT"
1955   "*
1957   return pa_output_bvb (operands, 0, insn, 1);
1959 [(set_attr "type" "cbranch")
1960  (set (attr "length")
1961     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1962                (const_int MAX_12BIT_OFFSET))
1963            (const_int 4)
1964            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1965                (const_int MAX_17BIT_OFFSET))
1966            (const_int 8)
1967            (match_test "TARGET_PORTABLE_RUNTIME")
1968            (const_int 24)
1969            (not (match_test "flag_pic"))
1970            (const_int 20)]
1971           (const_int 28)))])
1973 (define_insn ""
1974   [(set (pc)
1975         (if_then_else
1976          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1977                               (const_int 1)
1978                               (match_operand:SI 1 "register_operand" "q"))
1979              (const_int 0))
1980          (pc)
1981          (label_ref (match_operand 2 "" ""))))]
1982   ""
1983   "*
1985   return pa_output_bvb (operands, 1, insn, 1);
1987 [(set_attr "type" "cbranch")
1988  (set (attr "length")
1989     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1990                (const_int MAX_12BIT_OFFSET))
1991            (const_int 4)
1992            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1993                (const_int MAX_17BIT_OFFSET))
1994            (const_int 8)
1995            (match_test "TARGET_PORTABLE_RUNTIME")
1996            (const_int 24)
1997            (not (match_test "flag_pic"))
1998            (const_int 20)]
1999           (const_int 28)))])
2001 (define_insn ""
2002   [(set (pc)
2003         (if_then_else
2004          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2005                               (const_int 1)
2006                               (match_operand:DI 1 "register_operand" "q"))
2007              (const_int 0))
2008          (pc)
2009          (label_ref (match_operand 2 "" ""))))]
2010   "TARGET_64BIT"
2011   "*
2013   return pa_output_bvb (operands, 1, insn, 1);
2015 [(set_attr "type" "cbranch")
2016  (set (attr "length")
2017     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2018                (const_int MAX_12BIT_OFFSET))
2019            (const_int 4)
2020            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2021                (const_int MAX_17BIT_OFFSET))
2022            (const_int 8)
2023            (match_test "TARGET_PORTABLE_RUNTIME")
2024            (const_int 24)
2025            (not (match_test "flag_pic"))
2026            (const_int 20)]
2027           (const_int 28)))])
2029 ;; Floating point branches
2031 ;; ??? Nullification is handled differently from other branches.
2032 ;; If nullification is specified, the delay slot is nullified on any
2033 ;; taken branch regardless of branch direction.
2034 (define_insn ""
2035   [(set (pc) (if_then_else (ne (reg:CCFP 0) (const_int 0))
2036                            (label_ref (match_operand 0 "" ""))
2037                            (pc)))]
2038   "!TARGET_SOFT_FLOAT"
2039   "*
2041   int length = get_attr_length (insn);
2042   rtx xoperands[1];
2043   int nullify, xdelay;
2045   if (length < 16)
2046     return \"ftest\;b%* %l0\";
2048   if (dbr_sequence_length () == 0 || INSN_ANNULLED_BRANCH_P (insn))
2049     {
2050       nullify = 1;
2051       xdelay = 0;
2052       xoperands[0] = GEN_INT (length - 8);
2053     }
2054   else
2055     {
2056       nullify = 0;
2057       xdelay = 1;
2058       xoperands[0] = GEN_INT (length - 4);
2059     }
2061   if (nullify)
2062     output_asm_insn (\"ftest\;add,tr %%r0,%%r0,%%r0\;b,n .+%0\", xoperands);
2063   else
2064     output_asm_insn (\"ftest\;add,tr %%r0,%%r0,%%r0\;b .+%0\", xoperands);
2065   return pa_output_lbranch (operands[0], insn, xdelay);
2067 [(set_attr "type" "fbranch")
2068  (set (attr "length")
2069     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
2070                (const_int MAX_17BIT_OFFSET))
2071            (const_int 8)
2072            (match_test "TARGET_PORTABLE_RUNTIME")
2073            (const_int 32)
2074            (not (match_test "flag_pic"))
2075            (const_int 28)]
2076           (const_int 36)))])
2078 (define_insn ""
2079   [(set (pc) (if_then_else (ne (reg:CCFP 0) (const_int 0))
2080                            (pc)
2081                            (label_ref (match_operand 0 "" ""))))]
2082   "!TARGET_SOFT_FLOAT"
2083   "*
2085   int length = get_attr_length (insn);
2086   rtx xoperands[1];
2087   int nullify, xdelay;
2089   if (length < 16)
2090     return \"ftest\;add,tr %%r0,%%r0,%%r0\;b%* %0\";
2092   if (dbr_sequence_length () == 0 || INSN_ANNULLED_BRANCH_P (insn))
2093     {
2094       nullify = 1;
2095       xdelay = 0;
2096       xoperands[0] = GEN_INT (length - 4);
2097     }
2098   else
2099     {
2100       nullify = 0;
2101       xdelay = 1;
2102       xoperands[0] = GEN_INT (length);
2103     }
2105   if (nullify)
2106     output_asm_insn (\"ftest\;b,n .+%0\", xoperands);
2107   else
2108     output_asm_insn (\"ftest\;b .+%0\", xoperands);
2109   return pa_output_lbranch (operands[0], insn, xdelay);
2111 [(set_attr "type" "fbranch")
2112  (set (attr "length")
2113     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
2114                (const_int MAX_17BIT_OFFSET))
2115            (const_int 12)
2116            (match_test "TARGET_PORTABLE_RUNTIME")
2117            (const_int 28)
2118            (not (match_test "flag_pic"))
2119            (const_int 24)]
2120           (const_int 32)))])
2122 ;; Move instructions
2124 (define_expand "movsi"
2125   [(set (match_operand:SI 0 "general_operand" "")
2126         (match_operand:SI 1 "general_operand" ""))]
2127   ""
2128   "
2130   if (pa_emit_move_sequence (operands, SImode, 0))
2131     DONE;
2134 ;; Handle SImode input reloads requiring %r1 as a scratch register.
2135 (define_expand "reload_insi_r1"
2136   [(set (match_operand:SI 0 "register_operand" "=Z")
2137         (match_operand:SI 1 "non_hard_reg_operand" ""))
2138    (clobber (match_operand:SI 2 "register_operand" "=&a"))]
2139   ""
2140   "
2142   if (pa_emit_move_sequence (operands, SImode, operands[2]))
2143     DONE;
2145   /* We don't want the clobber emitted, so handle this ourselves.  */
2146   emit_insn (gen_rtx_SET (operands[0], operands[1]));
2147   DONE;
2150 ;; Handle SImode input reloads requiring a general register as a
2151 ;; scratch register.
2152 (define_expand "reload_insi"
2153   [(set (match_operand:SI 0 "register_operand" "=Z")
2154         (match_operand:SI 1 "non_hard_reg_operand" ""))
2155    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
2156   ""
2157   "
2159   if (pa_emit_move_sequence (operands, SImode, operands[2]))
2160     DONE;
2162   /* We don't want the clobber emitted, so handle this ourselves.  */
2163   emit_insn (gen_rtx_SET (operands[0], operands[1]));
2164   DONE;
2167 ;; Handle SImode output reloads requiring a general register as a
2168 ;; scratch register.
2169 (define_expand "reload_outsi"
2170   [(set (match_operand:SI 0 "non_hard_reg_operand" "")
2171         (match_operand:SI 1  "register_operand" "Z"))
2172    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
2173   ""
2174   "
2176   if (pa_emit_move_sequence (operands, SImode, operands[2]))
2177     DONE;
2179   /* We don't want the clobber emitted, so handle this ourselves.  */
2180   emit_insn (gen_rtx_SET (operands[0], operands[1]));
2181   DONE;
2184 (define_insn ""
2185   [(set (match_operand:SI 0 "move_dest_operand"
2186                           "=r,r,r,r,r,r,Q,!*q,!r,!*f,*f,T,?r,?*f")
2187         (match_operand:SI 1 "move_src_operand"
2188                           "A,r,J,N,K,RQ,rM,!rM,!*q,!*fM,RT,*f,*f,r"))]
2189   "(register_operand (operands[0], SImode)
2190     || reg_or_0_operand (operands[1], SImode))
2191    && !TARGET_SOFT_FLOAT
2192    && !TARGET_64BIT"
2193   "@
2194    ldw RT'%A1,%0
2195    copy %1,%0
2196    ldi %1,%0
2197    ldil L'%1,%0
2198    {zdepi|depwi,z} %Z1,%0
2199    ldw%M1 %1,%0
2200    stw%M0 %r1,%0
2201    mtsar %r1
2202    {mfctl|mfctl,w} %%sar,%0
2203    fcpy,sgl %f1,%0
2204    fldw%F1 %1,%0
2205    fstw%F0 %1,%0
2206    {fstws|fstw} %1,-16(%%sp)\n\t{ldws|ldw} -16(%%sp),%0
2207    {stws|stw} %1,-16(%%sp)\n\t{fldws|fldw} -16(%%sp),%0"
2208   [(set_attr "type" "load,move,move,move,shift,load,store,move,move,fpalu,fpload,fpstore,fpstore_load,store_fpload")
2209    (set_attr "pa_combine_type" "addmove")
2210    (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4,8,8")])
2212 (define_insn ""
2213   [(set (match_operand:SI 0 "move_dest_operand"
2214                           "=r,r,r,r,r,r,Q,!*q,!r,!*f,*f,T")
2215         (match_operand:SI 1 "move_src_operand"
2216                           "A,r,J,N,K,RQ,rM,!rM,!*q,!*fM,RT,*f"))]
2217   "(register_operand (operands[0], SImode)
2218     || reg_or_0_operand (operands[1], SImode))
2219    && !TARGET_SOFT_FLOAT
2220    && TARGET_64BIT"
2221   "@
2222    ldw RT'%A1,%0
2223    copy %1,%0
2224    ldi %1,%0
2225    ldil L'%1,%0
2226    {zdepi|depwi,z} %Z1,%0
2227    ldw%M1 %1,%0
2228    stw%M0 %r1,%0
2229    mtsar %r1
2230    {mfctl|mfctl,w} %%sar,%0
2231    fcpy,sgl %f1,%0
2232    fldw%F1 %1,%0
2233    fstw%F0 %1,%0"
2234   [(set_attr "type" "load,move,move,move,shift,load,store,move,move,fpalu,fpload,fpstore")
2235    (set_attr "pa_combine_type" "addmove")
2236    (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4")])
2238 (define_insn ""
2239   [(set (match_operand:SI 0 "indexed_memory_operand" "=R")
2240         (match_operand:SI 1 "register_operand" "f"))]
2241   "!TARGET_SOFT_FLOAT
2242    && !TARGET_DISABLE_INDEXING
2243    && reload_completed"
2244   "fstw%F0 %1,%0"
2245   [(set_attr "type" "fpstore")
2246    (set_attr "pa_combine_type" "addmove")
2247    (set_attr "length" "4")])
2249 ; Rewrite RTL using an indexed store.  This will allow the insn that
2250 ; computes the address to be deleted if the register it sets is dead.
2251 (define_peephole2
2252   [(set (match_operand:SI 0 "register_operand" "")
2253         (plus:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
2254                             (const_int 2))
2255                  (match_operand:SI 2 "register_operand" "")))
2256    (set (mem:SI (match_dup 0))
2257         (match_operand:SI 3 "register_operand" ""))]
2258   "!TARGET_SOFT_FLOAT
2259    && !TARGET_DISABLE_INDEXING
2260    && REG_OK_FOR_BASE_P (operands[2])
2261    && FP_REGNO_P (REGNO (operands[3]))"
2262   [(set (mem:SI (plus:SI (mult:SI (match_dup 1) (const_int 4)) (match_dup 2)))
2263         (match_dup 3))
2264    (set (match_dup 0) (plus:SI (ashift:SI (match_dup 1) (const_int 2))
2265                                (match_dup 2)))]
2266   "")
2268 (define_peephole2
2269   [(set (match_operand:DI 0 "register_operand" "")
2270         (plus:DI (ashift:DI (match_operand:DI 1 "register_operand" "")
2271                             (const_int 2))
2272                  (match_operand:DI 2 "register_operand" "")))
2273    (set (mem:SI (match_dup 0))
2274         (match_operand:SI 3 "register_operand" ""))]
2275   "!TARGET_SOFT_FLOAT
2276    && !TARGET_DISABLE_INDEXING
2277    && TARGET_64BIT
2278    && REG_OK_FOR_BASE_P (operands[2])
2279    && FP_REGNO_P (REGNO (operands[3]))"
2280   [(set (mem:SI (plus:DI (mult:DI (match_dup 1) (const_int 4)) (match_dup 2)))
2281         (match_dup 3))
2282    (set (match_dup 0) (plus:DI (ashift:DI (match_dup 1) (const_int 2))
2283                                (match_dup 2)))]
2284   "")
2286 (define_peephole2
2287   [(set (match_operand:SI 0 "register_operand" "")
2288         (plus:SI (match_operand:SI 1 "register_operand" "")
2289                  (match_operand:SI 2 "register_operand" "")))
2290    (set (mem:SI (match_dup 0))
2291         (match_operand:SI 3 "register_operand" ""))]
2292   "!TARGET_SOFT_FLOAT
2293    && !TARGET_DISABLE_INDEXING
2294    && TARGET_NO_SPACE_REGS
2295    && REG_OK_FOR_INDEX_P (operands[1])
2296    && REG_OK_FOR_BASE_P (operands[2])
2297    && FP_REGNO_P (REGNO (operands[3]))"
2298   [(set (mem:SI (plus:SI (match_dup 1) (match_dup 2)))
2299         (match_dup 3))
2300    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
2301   "")
2303 (define_peephole2
2304   [(set (match_operand:SI 0 "register_operand" "")
2305         (plus:SI (match_operand:SI 1 "register_operand" "")
2306                  (match_operand:SI 2 "register_operand" "")))
2307    (set (mem:SI (match_dup 0))
2308         (match_operand:SI 3 "register_operand" ""))]
2309   "!TARGET_SOFT_FLOAT
2310    && !TARGET_DISABLE_INDEXING
2311    && TARGET_NO_SPACE_REGS
2312    && REG_OK_FOR_BASE_P (operands[1])
2313    && REG_OK_FOR_INDEX_P (operands[2])
2314    && FP_REGNO_P (REGNO (operands[3]))"
2315   [(set (mem:SI (plus:SI (match_dup 2) (match_dup 1)))
2316         (match_dup 3))
2317    (set (match_dup 0) (plus:SI (match_dup 2) (match_dup 1)))]
2318   "")
2320 (define_peephole2
2321   [(set (match_operand:DI 0 "register_operand" "")
2322         (plus:DI (match_operand:DI 1 "register_operand" "")
2323                  (match_operand:DI 2 "register_operand" "")))
2324    (set (mem:SI (match_dup 0))
2325         (match_operand:SI 3 "register_operand" ""))]
2326   "!TARGET_SOFT_FLOAT
2327    && !TARGET_DISABLE_INDEXING
2328    && TARGET_64BIT
2329    && TARGET_NO_SPACE_REGS
2330    && REG_OK_FOR_INDEX_P (operands[1])
2331    && REG_OK_FOR_BASE_P (operands[2])
2332    && FP_REGNO_P (REGNO (operands[3]))"
2333   [(set (mem:SI (plus:DI (match_dup 1) (match_dup 2)))
2334         (match_dup 3))
2335    (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
2336   "")
2338 (define_peephole2
2339   [(set (match_operand:DI 0 "register_operand" "")
2340         (plus:DI (match_operand:DI 1 "register_operand" "")
2341                  (match_operand:DI 2 "register_operand" "")))
2342    (set (mem:SI (match_dup 0))
2343         (match_operand:SI 3 "register_operand" ""))]
2344   "!TARGET_SOFT_FLOAT
2345    && !TARGET_DISABLE_INDEXING
2346    && TARGET_64BIT
2347    && TARGET_NO_SPACE_REGS
2348    && REG_OK_FOR_BASE_P (operands[1])
2349    && REG_OK_FOR_INDEX_P (operands[2])
2350    && FP_REGNO_P (REGNO (operands[3]))"
2351   [(set (mem:SI (plus:DI (match_dup 2) (match_dup 1)))
2352         (match_dup 3))
2353    (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
2354   "")
2356 (define_insn ""
2357   [(set (match_operand:SI 0 "move_dest_operand"
2358                           "=r,r,r,r,r,r,Q,!*q,!r")
2359         (match_operand:SI 1 "move_src_operand"
2360                           "A,r,J,N,K,RQ,rM,!rM,!*q"))]
2361   "(register_operand (operands[0], SImode)
2362     || reg_or_0_operand (operands[1], SImode))
2363    && TARGET_SOFT_FLOAT"
2364   "@
2365    ldw RT'%A1,%0
2366    copy %1,%0
2367    ldi %1,%0
2368    ldil L'%1,%0
2369    {zdepi|depwi,z} %Z1,%0
2370    ldw%M1 %1,%0
2371    stw%M0 %r1,%0
2372    mtsar %r1
2373    {mfctl|mfctl,w} %%sar,%0"
2374   [(set_attr "type" "load,move,move,move,move,load,store,move,move")
2375    (set_attr "pa_combine_type" "addmove")
2376    (set_attr "length" "4,4,4,4,4,4,4,4,4")])
2378 ;; Load or store with base-register modification.
2379 (define_insn ""
2380   [(set (match_operand:SI 0 "register_operand" "=r")
2381         (mem:SI (plus:DI (match_operand:DI 1 "register_operand" "+r")
2382                          (match_operand:DI 2 "int5_operand" "L"))))
2383    (set (match_dup 1)
2384         (plus:DI (match_dup 1) (match_dup 2)))]
2385   "TARGET_64BIT"
2386   "ldw,mb %2(%1),%0"
2387   [(set_attr "type" "load")
2388    (set_attr "length" "4")])
2390 ; And a zero extended variant.
2391 (define_insn ""
2392   [(set (match_operand:DI 0 "register_operand" "=r")
2393         (zero_extend:DI (mem:SI
2394                           (plus:DI
2395                             (match_operand:DI 1 "register_operand" "+r")
2396                             (match_operand:DI 2 "int5_operand" "L")))))
2397    (set (match_dup 1)
2398         (plus:DI (match_dup 1) (match_dup 2)))]
2399   "TARGET_64BIT"
2400   "ldw,mb %2(%1),%0"
2401   [(set_attr "type" "load")
2402    (set_attr "length" "4")])
2404 (define_expand "pre_load"
2405   [(parallel [(set (match_operand:SI 0 "register_operand" "")
2406               (mem (plus (match_operand 1 "register_operand" "")
2407                                (match_operand 2 "pre_cint_operand" ""))))
2408               (set (match_dup 1)
2409                    (plus (match_dup 1) (match_dup 2)))])]
2410   ""
2411   "
2413   if (TARGET_64BIT)
2414     {
2415       emit_insn (gen_pre_ldd (operands[0], operands[1], operands[2]));
2416       DONE;
2417     }
2418   emit_insn (gen_pre_ldw (operands[0], operands[1], operands[2]));
2419   DONE;
2422 (define_insn "pre_ldw"
2423   [(set (match_operand:SI 0 "register_operand" "=r")
2424         (mem:SI (plus:SI (match_operand:SI 1 "register_operand" "+r")
2425                          (match_operand:SI 2 "pre_cint_operand" ""))))
2426    (set (match_dup 1)
2427         (plus:SI (match_dup 1) (match_dup 2)))]
2428   ""
2429   "*
2431   if (INTVAL (operands[2]) < 0)
2432     return \"{ldwm|ldw,mb} %2(%1),%0\";
2433   return \"{ldws|ldw},mb %2(%1),%0\";
2435   [(set_attr "type" "load")
2436    (set_attr "length" "4")])
2438 (define_insn "pre_ldd"
2439   [(set (match_operand:DI 0 "register_operand" "=r")
2440         (mem:DI (plus:DI (match_operand:DI 1 "register_operand" "+r")
2441                          (match_operand:DI 2 "pre_cint_operand" ""))))
2442    (set (match_dup 1)
2443         (plus:DI (match_dup 1) (match_dup 2)))]
2444   "TARGET_64BIT"
2445   "ldd,mb %2(%1),%0"
2446   [(set_attr "type" "load")
2447    (set_attr "length" "4")])
2449 (define_insn ""
2450   [(set (mem:SI (plus:SI (match_operand:SI 0 "register_operand" "+r")
2451                          (match_operand:SI 1 "pre_cint_operand" "")))
2452         (match_operand:SI 2 "reg_or_0_operand" "rM"))
2453    (set (match_dup 0)
2454         (plus:SI (match_dup 0) (match_dup 1)))]
2455   ""
2456   "*
2458   if (INTVAL (operands[1]) < 0)
2459     return \"{stwm|stw,mb} %r2,%1(%0)\";
2460   return \"{stws|stw},mb %r2,%1(%0)\";
2462   [(set_attr "type" "store")
2463    (set_attr "length" "4")])
2465 (define_insn ""
2466   [(set (match_operand:SI 0 "register_operand" "=r")
2467         (mem:SI (match_operand:SI 1 "register_operand" "+r")))
2468    (set (match_dup 1)
2469         (plus:SI (match_dup 1)
2470                  (match_operand:SI 2 "post_cint_operand" "")))]
2471   ""
2472   "*
2474   if (INTVAL (operands[2]) > 0)
2475     return \"{ldwm|ldw,ma} %2(%1),%0\";
2476   return \"{ldws|ldw},ma %2(%1),%0\";
2478   [(set_attr "type" "load")
2479    (set_attr "length" "4")])
2481 (define_expand "post_store"
2482   [(parallel [(set (mem (match_operand 0 "register_operand" ""))
2483                    (match_operand 1 "reg_or_0_operand" ""))
2484               (set (match_dup 0)
2485                    (plus (match_dup 0)
2486                          (match_operand 2 "post_cint_operand" "")))])]
2487   ""
2488   "
2490   if (TARGET_64BIT)
2491     {
2492       emit_insn (gen_post_std (operands[0], operands[1], operands[2]));
2493       DONE;
2494     }
2495   emit_insn (gen_post_stw (operands[0], operands[1], operands[2]));
2496   DONE;
2499 (define_insn "post_stw"
2500   [(set (mem:SI (match_operand:SI 0 "register_operand" "+r"))
2501         (match_operand:SI 1 "reg_or_0_operand" "rM"))
2502    (set (match_dup 0)
2503         (plus:SI (match_dup 0)
2504                  (match_operand:SI 2 "post_cint_operand" "")))]
2505   ""
2506   "*
2508   if (INTVAL (operands[2]) > 0)
2509     return \"{stwm|stw,ma} %r1,%2(%0)\";
2510   return \"{stws|stw},ma %r1,%2(%0)\";
2512   [(set_attr "type" "store")
2513    (set_attr "length" "4")])
2515 (define_insn "post_std"
2516   [(set (mem:DI (match_operand:DI 0 "register_operand" "+r"))
2517         (match_operand:DI 1 "reg_or_0_operand" "rM"))
2518    (set (match_dup 0)
2519         (plus:DI (match_dup 0)
2520                  (match_operand:DI 2 "post_cint_operand" "")))]
2521   "TARGET_64BIT"
2522   "std,ma %r1,%2(%0)"
2523   [(set_attr "type" "store")
2524    (set_attr "length" "4")])
2526 ;; For loading the address of a label while generating PIC code.
2527 ;; Note since this pattern can be created at reload time (via movsi), all
2528 ;; the same rules for movsi apply here.  (no new pseudos, no temporaries).
2529 (define_insn ""
2530   [(set (match_operand 0 "pmode_register_operand" "=a")
2531         (match_operand 1 "pic_label_operand" ""))]
2532   "TARGET_PA_20"
2533   "*
2535   rtx xoperands[3];
2537   xoperands[0] = operands[0];
2538   xoperands[1] = operands[1];
2539   xoperands[2] = gen_label_rtx ();
2541   (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
2542                                      CODE_LABEL_NUMBER (xoperands[2]));
2543   output_asm_insn (\"mfia %0\", xoperands);
2545   /* If we're trying to load the address of a label that happens to be
2546      close, then we can use a shorter sequence.  */
2547   if (GET_CODE (operands[1]) == LABEL_REF
2548       && !LABEL_REF_NONLOCAL_P (operands[1])
2549       && INSN_ADDRESSES_SET_P ()
2550       && abs (INSN_ADDRESSES (INSN_UID (XEXP (operands[1], 0)))
2551                 - INSN_ADDRESSES (INSN_UID (insn))) < 8100)
2552     output_asm_insn (\"ldo %1-%2(%0),%0\", xoperands);
2553   else
2554     {
2555       output_asm_insn (\"addil L%%%1-%2,%0\", xoperands);
2556       output_asm_insn (\"ldo R%%%1-%2(%0),%0\", xoperands);
2557     }
2558   return \"\";
2560   [(set_attr "type" "multi")
2561    (set_attr "length" "12")])           ; 8 or 12
2563 (define_insn ""
2564   [(set (match_operand 0 "pmode_register_operand" "=a")
2565         (match_operand 1 "pic_label_operand" ""))]
2566   "!TARGET_PA_20"
2567   "*
2569   rtx xoperands[3];
2571   xoperands[0] = operands[0];
2572   xoperands[1] = operands[1];
2573   xoperands[2] = gen_label_rtx ();
2575   output_asm_insn (\"bl .+8,%0\", xoperands);
2576   output_asm_insn (\"depi 0,31,2,%0\", xoperands);
2577   (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
2578                                      CODE_LABEL_NUMBER (xoperands[2]));
2580   /* If we're trying to load the address of a label that happens to be
2581      close, then we can use a shorter sequence.  */
2582   if (GET_CODE (operands[1]) == LABEL_REF
2583       && !LABEL_REF_NONLOCAL_P (operands[1])
2584       && INSN_ADDRESSES_SET_P ()
2585       && abs (INSN_ADDRESSES (INSN_UID (XEXP (operands[1], 0)))
2586                 - INSN_ADDRESSES (INSN_UID (insn))) < 8100)
2587     output_asm_insn (\"ldo %1-%2(%0),%0\", xoperands);
2588   else
2589     {
2590       output_asm_insn (\"addil L%%%1-%2,%0\", xoperands);
2591       output_asm_insn (\"ldo R%%%1-%2(%0),%0\", xoperands);
2592     }
2593   return \"\";
2595   [(set_attr "type" "multi")
2596    (set_attr "length" "16")])           ; 12 or 16
2598 (define_insn ""
2599   [(set (match_operand:SI 0 "register_operand" "=a")
2600         (plus:SI (match_operand:SI 1 "register_operand" "r")
2601                  (high:SI (match_operand 2 "" ""))))]
2602   "symbolic_operand (operands[2], Pmode)
2603    && ! function_label_operand (operands[2], Pmode)
2604    && flag_pic"
2605   "addil LT'%G2,%1"
2606   [(set_attr "type" "binary")
2607    (set_attr "length" "4")])
2609 (define_insn ""
2610   [(set (match_operand:DI 0 "register_operand" "=a")
2611         (plus:DI (match_operand:DI 1 "register_operand" "r")
2612                  (high:DI (match_operand 2 "" ""))))]
2613   "symbolic_operand (operands[2], Pmode)
2614    && ! function_label_operand (operands[2], Pmode)
2615    && TARGET_64BIT
2616    && flag_pic"
2617   "addil LT'%G2,%1"
2618   [(set_attr "type" "binary")
2619    (set_attr "length" "4")])
2621 (define_insn ""
2622  [(set (match_operand:SI 0 "register_operand" "=r")
2623        (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
2624                   (unspec:SI [(match_operand 2 "" "")] UNSPEC_DLTIND14R)))]
2625   "symbolic_operand (operands[2], Pmode)
2626    && ! function_label_operand (operands[2], Pmode)
2627    && flag_pic"
2628   "ldo RT'%G2(%1),%0"
2629   [(set_attr "type" "binary")
2630    (set_attr "length" "4")])
2632 (define_insn ""
2633  [(set (match_operand:DI 0 "register_operand" "=r")
2634        (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
2635                   (unspec:DI [(match_operand 2 "" "")] UNSPEC_DLTIND14R)))]
2636   "symbolic_operand (operands[2], Pmode)
2637    && ! function_label_operand (operands[2], Pmode)
2638    && TARGET_64BIT
2639    && flag_pic"
2640   "ldo RT'%G2(%1),%0"
2641   [(set_attr "type" "binary")
2642    (set_attr "length" "4")])
2644 ;; Always use addil rather than ldil;add sequences.  This allows the
2645 ;; HP linker to eliminate the dp relocation if the symbolic operand
2646 ;; lives in the TEXT space.
2647 (define_insn ""
2648   [(set (match_operand:SI 0 "register_operand" "=a")
2649         (high:SI (match_operand 1 "" "")))]
2650   "symbolic_operand (operands[1], Pmode)
2651    && ! function_label_operand (operands[1], Pmode)
2652    && ! read_only_operand (operands[1], Pmode)
2653    && ! flag_pic"
2654   "*
2656   if (TARGET_LONG_LOAD_STORE)
2657     return \"addil NLR'%H1,%%r27\;ldo N'%H1(%%r1),%%r1\";
2658   else
2659     return \"addil LR'%H1,%%r27\";
2661   [(set_attr "type" "binary")
2662    (set (attr "length")
2663       (if_then_else (not (match_test "TARGET_LONG_LOAD_STORE"))
2664                     (const_int 4)
2665                     (const_int 8)))])
2668 ;; This is for use in the prologue/epilogue code.  We need it
2669 ;; to add large constants to a stack pointer or frame pointer.
2670 ;; Because of the additional %r1 pressure, we probably do not
2671 ;; want to use this in general code, so make it available
2672 ;; only after reload.
2673 (define_insn ""
2674   [(set (match_operand:SI 0 "register_operand" "=!a,*r")
2675         (plus:SI (match_operand:SI 1 "register_operand" "r,r")
2676                  (high:SI (match_operand 2 "const_int_operand" ""))))]
2677   "reload_completed"
2678   "@
2679    addil L'%G2,%1
2680    ldil L'%G2,%0\;{addl|add,l} %0,%1,%0"
2681   [(set_attr "type" "binary,binary")
2682    (set_attr "length" "4,8")])
2684 (define_insn ""
2685   [(set (match_operand:DI 0 "register_operand" "=!a,*r")
2686         (plus:DI (match_operand:DI 1 "register_operand" "r,r")
2687                  (high:DI (match_operand 2 "const_int_operand" ""))))]
2688   "reload_completed && TARGET_64BIT"
2689   "@
2690    addil L'%G2,%1
2691    ldil L'%G2,%0\;{addl|add,l} %0,%1,%0"
2692   [(set_attr "type" "binary,binary")
2693    (set_attr "length" "4,8")])
2695 (define_insn ""
2696   [(set (match_operand:SI 0 "register_operand" "=r")
2697         (high:SI (match_operand 1 "" "")))]
2698   "(!flag_pic || !symbolic_operand (operands[1], Pmode))
2699     && !pa_is_function_label_plus_const (operands[1])"
2700   "*
2702   if (symbolic_operand (operands[1], Pmode))
2703     return \"ldil LR'%H1,%0\";
2704   else
2705     return \"ldil L'%G1,%0\";
2707   [(set_attr "type" "move")
2708    (set_attr "length" "4")])
2710 (define_insn ""
2711   [(set (match_operand:DI 0 "register_operand" "=r")
2712         (high:DI (match_operand 1 "const_int_operand" "")))]
2713   "TARGET_64BIT"
2714   "ldil L'%G1,%0";
2715   [(set_attr "type" "move")
2716    (set_attr "length" "4")])
2718 (define_insn ""
2719   [(set (match_operand:DI 0 "register_operand" "=r")
2720         (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
2721                    (match_operand:DI 2 "const_int_operand" "i")))]
2722   "TARGET_64BIT"
2723   "ldo R'%G2(%1),%0";
2724   [(set_attr "type" "move")
2725    (set_attr "length" "4")])
2727 (define_insn ""
2728   [(set (match_operand:SI 0 "register_operand" "=r")
2729         (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
2730                    (match_operand:SI 2 "immediate_operand" "i")))]
2731   "!pa_is_function_label_plus_const (operands[2])"
2732   "*
2734   gcc_assert (!flag_pic || !symbolic_operand (operands[2], Pmode));
2735   
2736   if (symbolic_operand (operands[2], Pmode))
2737     return \"ldo RR'%G2(%1),%0\";
2738   else
2739     return \"ldo R'%G2(%1),%0\";
2741   [(set_attr "type" "move")
2742    (set_attr "length" "4")])
2744 ;; Now that a symbolic_address plus a constant is broken up early
2745 ;; in the compilation phase (for better CSE) we need a special
2746 ;; combiner pattern to load the symbolic address plus the constant
2747 ;; in only 2 instructions. (For cases where the symbolic address
2748 ;; was not a common subexpression.)
2749 (define_split
2750   [(set (match_operand:SI 0 "register_operand" "")
2751         (match_operand:SI 1 "symbolic_operand" ""))
2752    (clobber (match_operand:SI 2 "register_operand" ""))]
2753   "! (flag_pic && pic_label_operand (operands[1], SImode))"
2754   [(set (match_dup 2) (high:SI (match_dup 1)))
2755    (set (match_dup 0) (lo_sum:SI (match_dup 2) (match_dup 1)))]
2756   "")
2758 ;; hppa_legitimize_address goes to a great deal of trouble to
2759 ;; create addresses which use indexing.  In some cases, this
2760 ;; is a lose because there isn't any store instructions which
2761 ;; allow indexed addresses (with integer register source).
2763 ;; These define_splits try to turn a 3 insn store into
2764 ;; a 2 insn store with some creative RTL rewriting.
2765 (define_split
2766   [(set (mem:SI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2767                                (match_operand:SI 1 "mem_shadd_operand" ""))
2768                    (plus:SI (match_operand:SI 2 "register_operand" "")
2769                             (match_operand:SI 3 "const_int_operand" ""))))
2770         (match_operand:SI 4 "register_operand" ""))
2771    (clobber (match_operand:SI 5 "register_operand" ""))]
2772   ""
2773   [(set (match_dup 5) (plus:SI (ashift:SI (match_dup 0) (match_dup 1))
2774                                (match_dup 2)))
2775    (set (mem:SI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2776   "
2778   operands[1] = GEN_INT (exact_log2 (INTVAL (operands[1])));
2782 (define_split
2783   [(set (mem:HI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2784                                (match_operand:SI 1 "mem_shadd_operand" ""))
2785                    (plus:SI (match_operand:SI 2 "register_operand" "")
2786                             (match_operand:SI 3 "const_int_operand" ""))))
2787         (match_operand:HI 4 "register_operand" ""))
2788    (clobber (match_operand:SI 5 "register_operand" ""))]
2789   ""
2790   [(set (match_dup 5) (plus:SI (ashift:SI (match_dup 0) (match_dup 1))
2791                                (match_dup 2)))
2792    (set (mem:HI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2793   "
2795   operands[1] = GEN_INT (exact_log2 (INTVAL (operands[1])));
2799 (define_split
2800   [(set (mem:QI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2801                                (match_operand:SI 1 "mem_shadd_operand" ""))
2802                    (plus:SI (match_operand:SI 2 "register_operand" "")
2803                             (match_operand:SI 3 "const_int_operand" ""))))
2804         (match_operand:QI 4 "register_operand" ""))
2805    (clobber (match_operand:SI 5 "register_operand" ""))]
2806   ""
2807   [(set (match_dup 5) (plus:SI (ashift:SI (match_dup 0) (match_dup 1))
2808                                (match_dup 2)))
2809    (set (mem:QI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2810   "
2812   operands[1] = GEN_INT (exact_log2 (INTVAL (operands[1])));
2816 (define_expand "movhi"
2817   [(set (match_operand:HI 0 "general_operand" "")
2818         (match_operand:HI 1 "general_operand" ""))]
2819   ""
2820   "
2822   if (pa_emit_move_sequence (operands, HImode, 0))
2823     DONE;
2826 ;; Handle HImode input reloads requiring a general register as a
2827 ;; scratch register.
2828 (define_expand "reload_inhi"
2829   [(set (match_operand:HI 0 "register_operand" "=Z")
2830         (match_operand:HI 1 "non_hard_reg_operand" ""))
2831    (clobber (match_operand:HI 2 "register_operand" "=&r"))]
2832   ""
2833   "
2835   if (pa_emit_move_sequence (operands, HImode, operands[2]))
2836     DONE;
2838   /* We don't want the clobber emitted, so handle this ourselves.  */
2839   emit_insn (gen_rtx_SET (operands[0], operands[1]));
2840   DONE;
2843 ;; Handle HImode output reloads requiring a general register as a
2844 ;; scratch register.
2845 (define_expand "reload_outhi"
2846   [(set (match_operand:HI 0 "non_hard_reg_operand" "")
2847         (match_operand:HI 1  "register_operand" "Z"))
2848    (clobber (match_operand:HI 2 "register_operand" "=&r"))]
2849   ""
2850   "
2852   if (pa_emit_move_sequence (operands, HImode, operands[2]))
2853     DONE;
2855   /* We don't want the clobber emitted, so handle this ourselves.  */
2856   emit_insn (gen_rtx_SET (operands[0], operands[1]));
2857   DONE;
2860 (define_insn ""
2861   [(set (match_operand:HI 0 "move_dest_operand"
2862                           "=r,r,r,r,r,Q,!*q,!r")
2863         (match_operand:HI 1 "move_src_operand"
2864                           "r,J,N,K,RQ,rM,!rM,!*q"))]
2865   "(register_operand (operands[0], HImode)
2866     || reg_or_0_operand (operands[1], HImode))"
2867   "@
2868    copy %1,%0
2869    ldi %1,%0
2870    ldil L'%1,%0
2871    {zdepi|depwi,z} %Z1,%0
2872    ldh%M1 %1,%0
2873    sth%M0 %r1,%0
2874    mtsar %r1
2875    {mfctl|mfctl,w} %sar,%0"
2876   [(set_attr "type" "move,move,move,shift,load,store,move,move")
2877    (set_attr "pa_combine_type" "addmove")
2878    (set_attr "length" "4,4,4,4,4,4,4,4")])
2880 (define_insn ""
2881   [(set (match_operand:HI 0 "register_operand" "=r")
2882         (mem:HI (plus:SI (match_operand:SI 1 "register_operand" "+r")
2883                          (match_operand:SI 2 "int5_operand" "L"))))
2884    (set (match_dup 1)
2885         (plus:SI (match_dup 1) (match_dup 2)))]
2886   ""
2887   "{ldhs|ldh},mb %2(%1),%0"
2888   [(set_attr "type" "load")
2889    (set_attr "length" "4")])
2891 (define_insn ""
2892   [(set (match_operand:HI 0 "register_operand" "=r")
2893         (mem:HI (plus:DI (match_operand:DI 1 "register_operand" "+r")
2894                          (match_operand:DI 2 "int5_operand" "L"))))
2895    (set (match_dup 1)
2896         (plus:DI (match_dup 1) (match_dup 2)))]
2897   "TARGET_64BIT"
2898   "ldh,mb %2(%1),%0"
2899   [(set_attr "type" "load")
2900    (set_attr "length" "4")])
2902 ; And a zero extended variant.
2903 (define_insn ""
2904   [(set (match_operand:DI 0 "register_operand" "=r")
2905         (zero_extend:DI (mem:HI
2906                           (plus:DI
2907                             (match_operand:DI 1 "register_operand" "+r")
2908                             (match_operand:DI 2 "int5_operand" "L")))))
2909    (set (match_dup 1)
2910         (plus:DI (match_dup 1) (match_dup 2)))]
2911   "TARGET_64BIT"
2912   "ldh,mb %2(%1),%0"
2913   [(set_attr "type" "load")
2914    (set_attr "length" "4")])
2916 (define_insn ""
2917   [(set (match_operand:SI 0 "register_operand" "=r")
2918         (zero_extend:SI (mem:HI
2919                           (plus:SI
2920                             (match_operand:SI 1 "register_operand" "+r")
2921                             (match_operand:SI 2 "int5_operand" "L")))))
2922    (set (match_dup 1)
2923         (plus:SI (match_dup 1) (match_dup 2)))]
2924   ""
2925   "{ldhs|ldh},mb %2(%1),%0"
2926   [(set_attr "type" "load")
2927    (set_attr "length" "4")])
2929 (define_insn ""
2930   [(set (match_operand:SI 0 "register_operand" "=r")
2931         (zero_extend:SI (mem:HI
2932                           (plus:DI
2933                             (match_operand:DI 1 "register_operand" "+r")
2934                             (match_operand:DI 2 "int5_operand" "L")))))
2935    (set (match_dup 1)
2936         (plus:DI (match_dup 1) (match_dup 2)))]
2937   "TARGET_64BIT"
2938   "ldh,mb %2(%1),%0"
2939   [(set_attr "type" "load")
2940    (set_attr "length" "4")])
2942 (define_insn ""
2943   [(set (mem:HI (plus:SI (match_operand:SI 0 "register_operand" "+r")
2944                          (match_operand:SI 1 "int5_operand" "L")))
2945         (match_operand:HI 2 "reg_or_0_operand" "rM"))
2946    (set (match_dup 0)
2947         (plus:SI (match_dup 0) (match_dup 1)))]
2948   ""
2949   "{sths|sth},mb %r2,%1(%0)"
2950   [(set_attr "type" "store")
2951    (set_attr "length" "4")])
2953 (define_insn ""
2954   [(set (mem:HI (plus:DI (match_operand:DI 0 "register_operand" "+r")
2955                          (match_operand:DI 1 "int5_operand" "L")))
2956         (match_operand:HI 2 "reg_or_0_operand" "rM"))
2957    (set (match_dup 0)
2958         (plus:DI (match_dup 0) (match_dup 1)))]
2959   "TARGET_64BIT"
2960   "sth,mb %r2,%1(%0)"
2961   [(set_attr "type" "store")
2962    (set_attr "length" "4")])
2964 (define_insn "addhi3"
2965   [(set (match_operand:HI 0 "register_operand" "=r,r")
2966         (plus:HI (match_operand:HI 1 "register_operand" "%r,r")
2967                  (match_operand:HI 2 "arith14_operand" "r,J")))]
2968   ""
2969   "@
2970    {addl|add,l} %1,%2,%0
2971    ldo %2(%1),%0"
2972   [(set_attr "type" "binary,binary")
2973    (set_attr "pa_combine_type" "addmove")
2974    (set_attr "length" "4,4")])
2976 (define_expand "movqi"
2977   [(set (match_operand:QI 0 "general_operand" "")
2978         (match_operand:QI 1 "general_operand" ""))]
2979   ""
2980   "
2982   if (pa_emit_move_sequence (operands, QImode, 0))
2983     DONE;
2986 ;; Handle QImode input reloads requiring a general register as a
2987 ;; scratch register.
2988 (define_expand "reload_inqi"
2989   [(set (match_operand:QI 0 "register_operand" "=Z")
2990         (match_operand:QI 1 "non_hard_reg_operand" ""))
2991    (clobber (match_operand:QI 2 "register_operand" "=&r"))]
2992   ""
2993   "
2995   if (pa_emit_move_sequence (operands, QImode, operands[2]))
2996     DONE;
2998   /* We don't want the clobber emitted, so handle this ourselves.  */
2999   emit_insn (gen_rtx_SET (operands[0], operands[1]));
3000   DONE;
3003 ;; Handle QImode output reloads requiring a general register as a
3004 ;; scratch register.
3005 (define_expand "reload_outqi"
3006   [(set (match_operand:QI 0 "non_hard_reg_operand" "")
3007         (match_operand:QI 1  "register_operand" "Z"))
3008    (clobber (match_operand:QI 2 "register_operand" "=&r"))]
3009   ""
3010   "
3012   if (pa_emit_move_sequence (operands, QImode, operands[2]))
3013     DONE;
3015   /* We don't want the clobber emitted, so handle this ourselves.  */
3016   emit_insn (gen_rtx_SET (operands[0], operands[1]));
3017   DONE;
3020 (define_insn ""
3021   [(set (match_operand:QI 0 "move_dest_operand"
3022                           "=r,r,r,r,r,Q,!*q,!r")
3023         (match_operand:QI 1 "move_src_operand"
3024                           "r,J,N,K,RQ,rM,!rM,!*q"))]
3025   "(register_operand (operands[0], QImode)
3026     || reg_or_0_operand (operands[1], QImode))"
3027   "@
3028    copy %1,%0
3029    ldi %1,%0
3030    ldil L'%1,%0
3031    {zdepi|depwi,z} %Z1,%0
3032    ldb%M1 %1,%0
3033    stb%M0 %r1,%0
3034    mtsar %r1
3035    {mfctl|mfctl,w} %%sar,%0"
3036   [(set_attr "type" "move,move,move,shift,load,store,move,move")
3037    (set_attr "pa_combine_type" "addmove")
3038    (set_attr "length" "4,4,4,4,4,4,4,4")])
3040 (define_insn ""
3041   [(set (match_operand:QI 0 "register_operand" "=r")
3042         (mem:QI (plus:SI (match_operand:SI 1 "register_operand" "+r")
3043                          (match_operand:SI 2 "int5_operand" "L"))))
3044    (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
3045   ""
3046   "{ldbs|ldb},mb %2(%1),%0"
3047   [(set_attr "type" "load")
3048    (set_attr "length" "4")])
3050 (define_insn ""
3051   [(set (match_operand:QI 0 "register_operand" "=r")
3052         (mem:QI (plus:DI (match_operand:DI 1 "register_operand" "+r")
3053                          (match_operand:DI 2 "int5_operand" "L"))))
3054    (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3055   "TARGET_64BIT"
3056   "ldb,mb %2(%1),%0"
3057   [(set_attr "type" "load")
3058    (set_attr "length" "4")])
3060 ; Now the same thing with zero extensions.
3061 (define_insn ""
3062   [(set (match_operand:DI 0 "register_operand" "=r")
3063         (zero_extend:DI (mem:QI (plus:DI
3064                                   (match_operand:DI 1 "register_operand" "+r")
3065                                   (match_operand:DI 2 "int5_operand" "L")))))
3066    (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3067   "TARGET_64BIT"
3068   "ldb,mb %2(%1),%0"
3069   [(set_attr "type" "load")
3070    (set_attr "length" "4")])
3072 (define_insn ""
3073   [(set (match_operand:SI 0 "register_operand" "=r")
3074         (zero_extend:SI (mem:QI (plus:SI
3075                                   (match_operand:SI 1 "register_operand" "+r")
3076                                   (match_operand:SI 2 "int5_operand" "L")))))
3077    (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
3078   ""
3079   "{ldbs|ldb},mb %2(%1),%0"
3080   [(set_attr "type" "load")
3081    (set_attr "length" "4")])
3083 (define_insn ""
3084   [(set (match_operand:SI 0 "register_operand" "=r")
3085         (zero_extend:SI (mem:QI (plus:DI
3086                                   (match_operand:DI 1 "register_operand" "+r")
3087                                   (match_operand:DI 2 "int5_operand" "L")))))
3088    (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3089   "TARGET_64BIT"
3090   "ldb,mb %2(%1),%0"
3091   [(set_attr "type" "load")
3092    (set_attr "length" "4")])
3094 (define_insn ""
3095   [(set (match_operand:HI 0 "register_operand" "=r")
3096         (zero_extend:HI (mem:QI (plus:SI
3097                                   (match_operand:SI 1 "register_operand" "+r")
3098                                   (match_operand:SI 2 "int5_operand" "L")))))
3099    (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
3100   ""
3101   "{ldbs|ldb},mb %2(%1),%0"
3102   [(set_attr "type" "load")
3103    (set_attr "length" "4")])
3105 (define_insn ""
3106   [(set (match_operand:HI 0 "register_operand" "=r")
3107         (zero_extend:HI (mem:QI (plus:DI
3108                                   (match_operand:DI 1 "register_operand" "+r")
3109                                   (match_operand:DI 2 "int5_operand" "L")))))
3110    (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3111   "TARGET_64BIT"
3112   "ldb,mb %2(%1),%0"
3113   [(set_attr "type" "load")
3114    (set_attr "length" "4")])
3116 (define_insn ""
3117   [(set (mem:QI (plus:SI (match_operand:SI 0 "register_operand" "+r")
3118                          (match_operand:SI 1 "int5_operand" "L")))
3119         (match_operand:QI 2 "reg_or_0_operand" "rM"))
3120    (set (match_dup 0)
3121         (plus:SI (match_dup 0) (match_dup 1)))]
3122   ""
3123   "{stbs|stb},mb %r2,%1(%0)"
3124   [(set_attr "type" "store")
3125    (set_attr "length" "4")])
3127 (define_insn ""
3128   [(set (mem:QI (plus:DI (match_operand:DI 0 "register_operand" "+r")
3129                          (match_operand:DI 1 "int5_operand" "L")))
3130         (match_operand:QI 2 "reg_or_0_operand" "rM"))
3131    (set (match_dup 0)
3132         (plus:DI (match_dup 0) (match_dup 1)))]
3133   "TARGET_64BIT"
3134   "stb,mb %r2,%1(%0)"
3135   [(set_attr "type" "store")
3136    (set_attr "length" "4")])
3138 ;; The definition of this insn does not really explain what it does,
3139 ;; but it should suffice that anything generated as this insn will be
3140 ;; recognized as a movmemsi operation, and that it will not successfully
3141 ;; combine with anything.
3142 (define_expand "movmemsi"
3143   [(parallel [(set (match_operand:BLK 0 "" "")
3144                    (match_operand:BLK 1 "" ""))
3145               (clobber (match_dup 4))
3146               (clobber (match_dup 5))
3147               (clobber (match_dup 6))
3148               (clobber (match_dup 7))
3149               (clobber (match_dup 8))
3150               (use (match_operand:SI 2 "arith14_operand" ""))
3151               (use (match_operand:SI 3 "const_int_operand" ""))])]
3152   "!TARGET_64BIT && optimize > 0"
3153   "
3155   int size, align;
3157   /* HP provides very fast block move library routine for the PA;
3158      this routine includes:
3160         4x4 byte at a time block moves,
3161         1x4 byte at a time with alignment checked at runtime with
3162             attempts to align the source and destination as needed
3163         1x1 byte loop
3165      With that in mind, here's the heuristics to try and guess when
3166      the inlined block move will be better than the library block
3167      move:
3169         If the size isn't constant, then always use the library routines.
3171         If the size is large in respect to the known alignment, then use
3172         the library routines.
3174         If the size is small in respect to the known alignment, then open
3175         code the copy (since that will lead to better scheduling).
3177         Else use the block move pattern.   */
3179   /* Undetermined size, use the library routine.  */
3180   if (GET_CODE (operands[2]) != CONST_INT)
3181     FAIL;
3183   size = INTVAL (operands[2]);
3184   align = INTVAL (operands[3]);
3185   align = align > 4 ? 4 : (align ? align : 1);
3187   /* If size/alignment is large, then use the library routines.  */
3188   if (size / align > 16)
3189     FAIL;
3191   /* This does happen, but not often enough to worry much about.  */
3192   if (size / align < MOVE_RATIO (optimize_insn_for_speed_p ()))
3193     FAIL;
3194   
3195   /* Fall through means we're going to use our block move pattern.  */
3196   operands[0]
3197     = replace_equiv_address (operands[0],
3198                              copy_to_mode_reg (SImode, XEXP (operands[0], 0)));
3199   operands[1]
3200     = replace_equiv_address (operands[1],
3201                              copy_to_mode_reg (SImode, XEXP (operands[1], 0)));
3202   operands[4] = gen_reg_rtx (SImode);
3203   operands[5] = gen_reg_rtx (SImode);
3204   operands[6] = gen_reg_rtx (SImode);
3205   operands[7] = gen_reg_rtx (SImode);
3206   operands[8] = gen_reg_rtx (SImode);
3209 ;; The operand constraints are written like this to support both compile-time
3210 ;; and run-time determined byte counts.  The expander and pa_output_block_move
3211 ;; only support compile-time determined counts at this time.
3213 ;; If the count is run-time determined, the register with the byte count
3214 ;; is clobbered by the copying code, and therefore it is forced to operand 2.
3216 ;; We used to clobber operands 0 and 1.  However, a change to regrename.c
3217 ;; broke this semantic for pseudo registers.  We can't use match_scratch
3218 ;; as this requires two registers in the class R1_REGS when the MEMs for
3219 ;; operands 0 and 1 are both equivalent to symbolic MEMs.  Thus, we are
3220 ;; forced to internally copy operands 0 and 1 to operands 7 and 8,
3221 ;; respectively.  We then split or peephole optimize after reload.
3222 (define_insn "movmemsi_prereload"
3223   [(set (mem:BLK (match_operand:SI 0 "register_operand" "r,r"))
3224         (mem:BLK (match_operand:SI 1 "register_operand" "r,r")))
3225    (clobber (match_operand:SI 2 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3226    (clobber (match_operand:SI 3 "register_operand" "=&r,&r"))   ;item tmp1
3227    (clobber (match_operand:SI 6 "register_operand" "=&r,&r"))   ;item tmp2
3228    (clobber (match_operand:SI 7 "register_operand" "=&r,&r"))   ;item tmp3
3229    (clobber (match_operand:SI 8 "register_operand" "=&r,&r"))   ;item tmp4
3230    (use (match_operand:SI 4 "arith14_operand" "J,2"))    ;byte count
3231    (use (match_operand:SI 5 "const_int_operand" "n,n"))] ;alignment
3232   "!TARGET_64BIT"
3233   "#"
3234   [(set_attr "type" "multi,multi")])
3236 (define_split
3237   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3238                    (match_operand:BLK 1 "memory_operand" ""))
3239               (clobber (match_operand:SI 2 "register_operand" ""))
3240               (clobber (match_operand:SI 3 "register_operand" ""))
3241               (clobber (match_operand:SI 6 "register_operand" ""))
3242               (clobber (match_operand:SI 7 "register_operand" ""))
3243               (clobber (match_operand:SI 8 "register_operand" ""))
3244               (use (match_operand:SI 4 "arith14_operand" ""))
3245               (use (match_operand:SI 5 "const_int_operand" ""))])]
3246   "!TARGET_64BIT && reload_completed && !flag_peephole2
3247    && GET_CODE (operands[0]) == MEM
3248    && register_operand (XEXP (operands[0], 0), SImode)
3249    && GET_CODE (operands[1]) == MEM
3250    && register_operand (XEXP (operands[1], 0), SImode)"
3251   [(set (match_dup 7) (match_dup 9))
3252    (set (match_dup 8) (match_dup 10))
3253    (parallel [(set (match_dup 0) (match_dup 1))
3254               (clobber (match_dup 2))
3255               (clobber (match_dup 3))
3256               (clobber (match_dup 6))
3257               (clobber (match_dup 7))
3258               (clobber (match_dup 8))
3259               (use (match_dup 4))
3260               (use (match_dup 5))
3261               (const_int 0)])]
3262   "
3264   operands[9] = XEXP (operands[0], 0);
3265   operands[10] = XEXP (operands[1], 0);
3266   operands[0] = replace_equiv_address (operands[0], operands[7]);
3267   operands[1] = replace_equiv_address (operands[1], operands[8]);
3270 (define_peephole2
3271   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3272                    (match_operand:BLK 1 "memory_operand" ""))
3273               (clobber (match_operand:SI 2 "register_operand" ""))
3274               (clobber (match_operand:SI 3 "register_operand" ""))
3275               (clobber (match_operand:SI 6 "register_operand" ""))
3276               (clobber (match_operand:SI 7 "register_operand" ""))
3277               (clobber (match_operand:SI 8 "register_operand" ""))
3278               (use (match_operand:SI 4 "arith14_operand" ""))
3279               (use (match_operand:SI 5 "const_int_operand" ""))])]
3280   "!TARGET_64BIT
3281    && GET_CODE (operands[0]) == MEM
3282    && register_operand (XEXP (operands[0], 0), SImode)
3283    && GET_CODE (operands[1]) == MEM
3284    && register_operand (XEXP (operands[1], 0), SImode)"
3285   [(parallel [(set (match_dup 0) (match_dup 1))
3286               (clobber (match_dup 2))
3287               (clobber (match_dup 3))
3288               (clobber (match_dup 6))
3289               (clobber (match_dup 7))
3290               (clobber (match_dup 8))
3291               (use (match_dup 4))
3292               (use (match_dup 5))
3293               (const_int 0)])]
3294   "
3296   rtx addr = XEXP (operands[0], 0);
3297   if (dead_or_set_p (curr_insn, addr))
3298     operands[7] = addr;
3299   else
3300     {
3301       emit_insn (gen_rtx_SET (operands[7], addr));
3302       operands[0] = replace_equiv_address (operands[0], operands[7]);
3303     }
3305   addr = XEXP (operands[1], 0);
3306   if (dead_or_set_p (curr_insn, addr))
3307     operands[8] = addr;
3308   else
3309     {
3310       emit_insn (gen_rtx_SET (operands[8], addr));
3311       operands[1] = replace_equiv_address (operands[1], operands[8]);
3312     }
3315 (define_insn "movmemsi_postreload"
3316   [(set (mem:BLK (match_operand:SI 0 "register_operand" "+r,r"))
3317         (mem:BLK (match_operand:SI 1 "register_operand" "+r,r")))
3318    (clobber (match_operand:SI 2 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3319    (clobber (match_operand:SI 3 "register_operand" "=&r,&r"))   ;item tmp1
3320    (clobber (match_operand:SI 6 "register_operand" "=&r,&r"))   ;item tmp2
3321    (clobber (match_dup 0))
3322    (clobber (match_dup 1))
3323    (use (match_operand:SI 4 "arith14_operand" "J,2"))    ;byte count
3324    (use (match_operand:SI 5 "const_int_operand" "n,n"))  ;alignment
3325    (const_int 0)]
3326   "!TARGET_64BIT && reload_completed"
3327   "* return pa_output_block_move (operands, !which_alternative);"
3328   [(set_attr "type" "multi,multi")])
3330 (define_expand "movmemdi"
3331   [(parallel [(set (match_operand:BLK 0 "" "")
3332                    (match_operand:BLK 1 "" ""))
3333               (clobber (match_dup 4))
3334               (clobber (match_dup 5))
3335               (clobber (match_dup 6))
3336               (clobber (match_dup 7))
3337               (clobber (match_dup 8))
3338               (use (match_operand:DI 2 "arith14_operand" ""))
3339               (use (match_operand:DI 3 "const_int_operand" ""))])]
3340   "TARGET_64BIT && optimize > 0"
3341   "
3343   int size, align;
3345   /* HP provides very fast block move library routine for the PA;
3346      this routine includes:
3348         4x4 byte at a time block moves,
3349         1x4 byte at a time with alignment checked at runtime with
3350             attempts to align the source and destination as needed
3351         1x1 byte loop
3353      With that in mind, here's the heuristics to try and guess when
3354      the inlined block move will be better than the library block
3355      move:
3357         If the size isn't constant, then always use the library routines.
3359         If the size is large in respect to the known alignment, then use
3360         the library routines.
3362         If the size is small in respect to the known alignment, then open
3363         code the copy (since that will lead to better scheduling).
3365         Else use the block move pattern.   */
3367   /* Undetermined size, use the library routine.  */
3368   if (GET_CODE (operands[2]) != CONST_INT)
3369     FAIL;
3371   size = INTVAL (operands[2]);
3372   align = INTVAL (operands[3]);
3373   align = align > 8 ? 8 : (align ? align : 1);
3375   /* If size/alignment is large, then use the library routines.  */
3376   if (size / align > 16)
3377     FAIL;
3379   /* This does happen, but not often enough to worry much about.  */
3380   if (size / align < MOVE_RATIO (optimize_insn_for_speed_p ()))
3381     FAIL;
3382   
3383   /* Fall through means we're going to use our block move pattern.  */
3384   operands[0]
3385     = replace_equiv_address (operands[0],
3386                              copy_to_mode_reg (DImode, XEXP (operands[0], 0)));
3387   operands[1]
3388     = replace_equiv_address (operands[1],
3389                              copy_to_mode_reg (DImode, XEXP (operands[1], 0)));
3390   operands[4] = gen_reg_rtx (DImode);
3391   operands[5] = gen_reg_rtx (DImode);
3392   operands[6] = gen_reg_rtx (DImode);
3393   operands[7] = gen_reg_rtx (DImode);
3394   operands[8] = gen_reg_rtx (DImode);
3397 ;; The operand constraints are written like this to support both compile-time
3398 ;; and run-time determined byte counts.  The expander and pa_output_block_move
3399 ;; only support compile-time determined counts at this time.
3401 ;; If the count is run-time determined, the register with the byte count
3402 ;; is clobbered by the copying code, and therefore it is forced to operand 2.
3404 ;; We used to clobber operands 0 and 1.  However, a change to regrename.c
3405 ;; broke this semantic for pseudo registers.  We can't use match_scratch
3406 ;; as this requires two registers in the class R1_REGS when the MEMs for
3407 ;; operands 0 and 1 are both equivalent to symbolic MEMs.  Thus, we are
3408 ;; forced to internally copy operands 0 and 1 to operands 7 and 8,
3409 ;; respectively.  We then split or peephole optimize after reload.
3410 (define_insn "movmemdi_prereload"
3411   [(set (mem:BLK (match_operand:DI 0 "register_operand" "r,r"))
3412         (mem:BLK (match_operand:DI 1 "register_operand" "r,r")))
3413    (clobber (match_operand:DI 2 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3414    (clobber (match_operand:DI 3 "register_operand" "=&r,&r"))   ;item tmp1
3415    (clobber (match_operand:DI 6 "register_operand" "=&r,&r"))   ;item tmp2
3416    (clobber (match_operand:DI 7 "register_operand" "=&r,&r"))   ;item tmp3
3417    (clobber (match_operand:DI 8 "register_operand" "=&r,&r"))   ;item tmp4
3418    (use (match_operand:DI 4 "arith14_operand" "J,2"))    ;byte count
3419    (use (match_operand:DI 5 "const_int_operand" "n,n"))] ;alignment
3420   "TARGET_64BIT"
3421   "#"
3422   [(set_attr "type" "multi,multi")])
3424 (define_split
3425   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3426                    (match_operand:BLK 1 "memory_operand" ""))
3427               (clobber (match_operand:DI 2 "register_operand" ""))
3428               (clobber (match_operand:DI 3 "register_operand" ""))
3429               (clobber (match_operand:DI 6 "register_operand" ""))
3430               (clobber (match_operand:DI 7 "register_operand" ""))
3431               (clobber (match_operand:DI 8 "register_operand" ""))
3432               (use (match_operand:DI 4 "arith14_operand" ""))
3433               (use (match_operand:DI 5 "const_int_operand" ""))])]
3434   "TARGET_64BIT && reload_completed && !flag_peephole2
3435    && GET_CODE (operands[0]) == MEM
3436    && register_operand (XEXP (operands[0], 0), DImode)
3437    && GET_CODE (operands[1]) == MEM
3438    && register_operand (XEXP (operands[1], 0), DImode)"
3439   [(set (match_dup 7) (match_dup 9))
3440    (set (match_dup 8) (match_dup 10))
3441    (parallel [(set (match_dup 0) (match_dup 1))
3442               (clobber (match_dup 2))
3443               (clobber (match_dup 3))
3444               (clobber (match_dup 6))
3445               (clobber (match_dup 7))
3446               (clobber (match_dup 8))
3447               (use (match_dup 4))
3448               (use (match_dup 5))
3449               (const_int 0)])]
3450   "
3452   operands[9] = XEXP (operands[0], 0);
3453   operands[10] = XEXP (operands[1], 0);
3454   operands[0] = replace_equiv_address (operands[0], operands[7]);
3455   operands[1] = replace_equiv_address (operands[1], operands[8]);
3458 (define_peephole2
3459   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3460                    (match_operand:BLK 1 "memory_operand" ""))
3461               (clobber (match_operand:DI 2 "register_operand" ""))
3462               (clobber (match_operand:DI 3 "register_operand" ""))
3463               (clobber (match_operand:DI 6 "register_operand" ""))
3464               (clobber (match_operand:DI 7 "register_operand" ""))
3465               (clobber (match_operand:DI 8 "register_operand" ""))
3466               (use (match_operand:DI 4 "arith14_operand" ""))
3467               (use (match_operand:DI 5 "const_int_operand" ""))])]
3468   "TARGET_64BIT
3469    && GET_CODE (operands[0]) == MEM
3470    && register_operand (XEXP (operands[0], 0), DImode)
3471    && GET_CODE (operands[1]) == MEM
3472    && register_operand (XEXP (operands[1], 0), DImode)"
3473   [(parallel [(set (match_dup 0) (match_dup 1))
3474               (clobber (match_dup 2))
3475               (clobber (match_dup 3))
3476               (clobber (match_dup 6))
3477               (clobber (match_dup 7))
3478               (clobber (match_dup 8))
3479               (use (match_dup 4))
3480               (use (match_dup 5))
3481               (const_int 0)])]
3482   "
3484   rtx addr = XEXP (operands[0], 0);
3485   if (dead_or_set_p (curr_insn, addr))
3486     operands[7] = addr;
3487   else
3488     {
3489       emit_insn (gen_rtx_SET (operands[7], addr));
3490       operands[0] = replace_equiv_address (operands[0], operands[7]);
3491     }
3493   addr = XEXP (operands[1], 0);
3494   if (dead_or_set_p (curr_insn, addr))
3495     operands[8] = addr;
3496   else
3497     {
3498       emit_insn (gen_rtx_SET (operands[8], addr));
3499       operands[1] = replace_equiv_address (operands[1], operands[8]);
3500     }
3503 (define_insn "movmemdi_postreload"
3504   [(set (mem:BLK (match_operand:DI 0 "register_operand" "+r,r"))
3505         (mem:BLK (match_operand:DI 1 "register_operand" "+r,r")))
3506    (clobber (match_operand:DI 2 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3507    (clobber (match_operand:DI 3 "register_operand" "=&r,&r"))   ;item tmp1
3508    (clobber (match_operand:DI 6 "register_operand" "=&r,&r"))   ;item tmp2
3509    (clobber (match_dup 0))
3510    (clobber (match_dup 1))
3511    (use (match_operand:DI 4 "arith14_operand" "J,2"))    ;byte count
3512    (use (match_operand:DI 5 "const_int_operand" "n,n"))  ;alignment
3513    (const_int 0)]
3514   "TARGET_64BIT && reload_completed"
3515   "* return pa_output_block_move (operands, !which_alternative);"
3516   [(set_attr "type" "multi,multi")])
3518 (define_expand "setmemsi"
3519   [(parallel [(set (match_operand:BLK 0 "" "")
3520                    (match_operand 2 "const_int_operand" ""))
3521               (clobber (match_dup 4))
3522               (clobber (match_dup 5))
3523               (use (match_operand:SI 1 "arith14_operand" ""))
3524               (use (match_operand:SI 3 "const_int_operand" ""))])]
3525   "!TARGET_64BIT && optimize > 0"
3526   "
3528   int size, align;
3530   /* If value to set is not zero, use the library routine.  */
3531   if (operands[2] != const0_rtx)
3532     FAIL;
3534   /* Undetermined size, use the library routine.  */
3535   if (GET_CODE (operands[1]) != CONST_INT)
3536     FAIL;
3538   size = INTVAL (operands[1]);
3539   align = INTVAL (operands[3]);
3540   align = align > 4 ? 4 : align;
3542   /* If size/alignment is large, then use the library routines.  */
3543   if (size / align > 16)
3544     FAIL;
3546   /* This does happen, but not often enough to worry much about.  */
3547   if (size / align < MOVE_RATIO (optimize_insn_for_speed_p ()))
3548     FAIL;
3549   
3550   /* Fall through means we're going to use our block clear pattern.  */
3551   operands[0]
3552     = replace_equiv_address (operands[0],
3553                              copy_to_mode_reg (SImode, XEXP (operands[0], 0)));
3554   operands[4] = gen_reg_rtx (SImode);
3555   operands[5] = gen_reg_rtx (SImode);
3558 (define_insn "clrmemsi_prereload"
3559   [(set (mem:BLK (match_operand:SI 0 "register_operand" "r,r"))
3560         (const_int 0))
3561    (clobber (match_operand:SI 1 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3562    (clobber (match_operand:SI 4 "register_operand" "=&r,&r"))   ;tmp1
3563    (use (match_operand:SI 2 "arith14_operand" "J,1"))    ;byte count
3564    (use (match_operand:SI 3 "const_int_operand" "n,n"))] ;alignment
3565   "!TARGET_64BIT"
3566   "#"
3567   [(set_attr "type" "multi,multi")])
3569 (define_split
3570   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3571                    (const_int 0))
3572               (clobber (match_operand:SI 1 "register_operand" ""))
3573               (clobber (match_operand:SI 4 "register_operand" ""))
3574               (use (match_operand:SI 2 "arith14_operand" ""))
3575               (use (match_operand:SI 3 "const_int_operand" ""))])]
3576   "!TARGET_64BIT && reload_completed && !flag_peephole2
3577    && GET_CODE (operands[0]) == MEM
3578    && register_operand (XEXP (operands[0], 0), SImode)"
3579   [(set (match_dup 4) (match_dup 5))
3580    (parallel [(set (match_dup 0) (const_int 0))
3581               (clobber (match_dup 1))
3582               (clobber (match_dup 4))
3583               (use (match_dup 2))
3584               (use (match_dup 3))
3585               (const_int 0)])]
3586   "
3588   operands[5] = XEXP (operands[0], 0);
3589   operands[0] = replace_equiv_address (operands[0], operands[4]);
3592 (define_peephole2
3593   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3594                    (const_int 0))
3595               (clobber (match_operand:SI 1 "register_operand" ""))
3596               (clobber (match_operand:SI 4 "register_operand" ""))
3597               (use (match_operand:SI 2 "arith14_operand" ""))
3598               (use (match_operand:SI 3 "const_int_operand" ""))])]
3599   "!TARGET_64BIT
3600    && GET_CODE (operands[0]) == MEM
3601    && register_operand (XEXP (operands[0], 0), SImode)"
3602   [(parallel [(set (match_dup 0) (const_int 0))
3603               (clobber (match_dup 1))
3604               (clobber (match_dup 4))
3605               (use (match_dup 2))
3606               (use (match_dup 3))
3607               (const_int 0)])]
3608   "
3610   rtx addr = XEXP (operands[0], 0);
3611   if (dead_or_set_p (curr_insn, addr))
3612     operands[4] = addr;
3613   else
3614     {
3615       emit_insn (gen_rtx_SET (operands[4], addr));
3616       operands[0] = replace_equiv_address (operands[0], operands[4]);
3617     }
3620 (define_insn "clrmemsi_postreload"
3621   [(set (mem:BLK (match_operand:SI 0 "register_operand" "+r,r"))
3622         (const_int 0))
3623    (clobber (match_operand:SI 1 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3624    (clobber (match_dup 0))
3625    (use (match_operand:SI 2 "arith14_operand" "J,1"))    ;byte count
3626    (use (match_operand:SI 3 "const_int_operand" "n,n"))  ;alignment
3627    (const_int 0)]
3628   "!TARGET_64BIT && reload_completed"
3629   "* return pa_output_block_clear (operands, !which_alternative);"
3630   [(set_attr "type" "multi,multi")])
3632 (define_expand "setmemdi"
3633   [(parallel [(set (match_operand:BLK 0 "" "")
3634                    (match_operand 2 "const_int_operand" ""))
3635               (clobber (match_dup 4))
3636               (clobber (match_dup 5))
3637               (use (match_operand:DI 1 "arith14_operand" ""))
3638               (use (match_operand:DI 3 "const_int_operand" ""))])]
3639   "TARGET_64BIT && optimize > 0"
3640   "
3642   int size, align;
3644   /* If value to set is not zero, use the library routine.  */
3645   if (operands[2] != const0_rtx)
3646     FAIL;
3648   /* Undetermined size, use the library routine.  */
3649   if (GET_CODE (operands[1]) != CONST_INT)
3650     FAIL;
3652   size = INTVAL (operands[1]);
3653   align = INTVAL (operands[3]);
3654   align = align > 8 ? 8 : align;
3656   /* If size/alignment is large, then use the library routines.  */
3657   if (size / align > 16)
3658     FAIL;
3660   /* This does happen, but not often enough to worry much about.  */
3661   if (size / align < MOVE_RATIO (optimize_insn_for_speed_p ()))
3662     FAIL;
3663   
3664   /* Fall through means we're going to use our block clear pattern.  */
3665   operands[0]
3666     = replace_equiv_address (operands[0],
3667                              copy_to_mode_reg (DImode, XEXP (operands[0], 0)));
3668   operands[4] = gen_reg_rtx (DImode);
3669   operands[5] = gen_reg_rtx (DImode);
3672 (define_insn "clrmemdi_prereload"
3673   [(set (mem:BLK (match_operand:DI 0 "register_operand" "r,r"))
3674         (const_int 0))
3675    (clobber (match_operand:DI 1 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3676    (clobber (match_operand:DI 4 "register_operand" "=&r,&r"))   ;item tmp1
3677    (use (match_operand:DI 2 "arith14_operand" "J,1"))    ;byte count
3678    (use (match_operand:DI 3 "const_int_operand" "n,n"))] ;alignment
3679   "TARGET_64BIT"
3680   "#"
3681   [(set_attr "type" "multi,multi")])
3683 (define_split
3684   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3685                    (const_int 0))
3686               (clobber (match_operand:DI 1 "register_operand" ""))
3687               (clobber (match_operand:DI 4 "register_operand" ""))
3688               (use (match_operand:DI 2 "arith14_operand" ""))
3689               (use (match_operand:DI 3 "const_int_operand" ""))])]
3690   "TARGET_64BIT && reload_completed && !flag_peephole2
3691    && GET_CODE (operands[0]) == MEM
3692    && register_operand (XEXP (operands[0], 0), DImode)"
3693   [(set (match_dup 4) (match_dup 5))
3694    (parallel [(set (match_dup 0) (const_int 0))
3695               (clobber (match_dup 1))
3696               (clobber (match_dup 4))
3697               (use (match_dup 2))
3698               (use (match_dup 3))
3699               (const_int 0)])]
3700   "
3702   operands[5] = XEXP (operands[0], 0);
3703   operands[0] = replace_equiv_address (operands[0], operands[4]);
3706 (define_peephole2
3707   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3708                    (const_int 0))
3709               (clobber (match_operand:DI 1 "register_operand" ""))
3710               (clobber (match_operand:DI 4 "register_operand" ""))
3711               (use (match_operand:DI 2 "arith14_operand" ""))
3712               (use (match_operand:DI 3 "const_int_operand" ""))])]
3713   "TARGET_64BIT
3714    && GET_CODE (operands[0]) == MEM
3715    && register_operand (XEXP (operands[0], 0), DImode)"
3716   [(parallel [(set (match_dup 0) (const_int 0))
3717               (clobber (match_dup 1))
3718               (clobber (match_dup 4))
3719               (use (match_dup 2))
3720               (use (match_dup 3))
3721               (const_int 0)])]
3722   "
3723 {  
3724   rtx addr = XEXP (operands[0], 0);
3725   if (dead_or_set_p (curr_insn, addr))
3726     operands[4] = addr;
3727   else
3728     {
3729       emit_insn (gen_rtx_SET (operands[4], addr));
3730       operands[0] = replace_equiv_address (operands[0], operands[4]);
3731     }
3734 (define_insn "clrmemdi_postreload"
3735   [(set (mem:BLK (match_operand:DI 0 "register_operand" "+r,r"))
3736         (const_int 0))
3737    (clobber (match_operand:DI 1 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3738    (clobber (match_dup 0))
3739    (use (match_operand:DI 2 "arith14_operand" "J,1"))    ;byte count
3740    (use (match_operand:DI 3 "const_int_operand" "n,n"))  ;alignment
3741    (const_int 0)]
3742   "TARGET_64BIT && reload_completed"
3743   "* return pa_output_block_clear (operands, !which_alternative);"
3744   [(set_attr "type" "multi,multi")])
3746 ;; Floating point move insns
3748 (define_expand "movdf"
3749   [(set (match_operand:DF 0 "general_operand" "")
3750         (match_operand:DF 1 "general_operand" ""))]
3751   ""
3752   "
3754   if (pa_emit_move_sequence (operands, DFmode, 0))
3755     DONE;
3758 ;; Handle DFmode input reloads requiring %r1 as a scratch register.
3759 (define_expand "reload_indf_r1"
3760   [(set (match_operand:DF 0 "register_operand" "=Z")
3761         (match_operand:DF 1 "non_hard_reg_operand" ""))
3762    (clobber (match_operand:SI 2 "register_operand" "=&a"))]
3763   ""
3764   "
3766   if (pa_emit_move_sequence (operands, DFmode, operands[2]))
3767     DONE;
3769   /* We don't want the clobber emitted, so handle this ourselves.  */
3770   emit_insn (gen_rtx_SET (operands[0], operands[1]));
3771   DONE;
3774 ;; Handle DFmode input reloads requiring a general register as a
3775 ;; scratch register.
3776 (define_expand "reload_indf"
3777   [(set (match_operand:DF 0 "register_operand" "=Z")
3778         (match_operand:DF 1 "non_hard_reg_operand" ""))
3779    (clobber (match_operand:DF 2 "register_operand" "=&r"))]
3780   ""
3781   "
3783   if (pa_emit_move_sequence (operands, DFmode, operands[2]))
3784     DONE;
3786   /* We don't want the clobber emitted, so handle this ourselves.  */
3787   emit_insn (gen_rtx_SET (operands[0], operands[1]));
3788   DONE;
3791 ;; Handle DFmode output reloads requiring a general register as a
3792 ;; scratch register.
3793 (define_expand "reload_outdf" 
3794  [(set (match_operand:DF 0 "non_hard_reg_operand" "")
3795         (match_operand:DF 1  "register_operand" "Z"))
3796    (clobber (match_operand:DF 2 "register_operand" "=&r"))]
3797   ""
3798   "
3800   if (pa_emit_move_sequence (operands, DFmode, operands[2]))
3801     DONE;
3803   /* We don't want the clobber emitted, so handle this ourselves.  */
3804   emit_insn (gen_rtx_SET (operands[0], operands[1]));
3805   DONE;
3808 (define_insn ""
3809   [(set (match_operand:DF 0 "move_dest_operand"
3810                           "=f,*r,T,?o,?Q,f,*r,*r,?*r,?f")
3811         (match_operand:DF 1 "reg_or_0_or_nonsymb_mem_operand"
3812                           "fG,*rG,f,*r,*r,RT,o,RQ,f,*r"))]
3813   "(register_operand (operands[0], DFmode)
3814     || reg_or_0_operand (operands[1], DFmode))
3815    && !(GET_CODE (operands[1]) == CONST_DOUBLE
3816         && GET_CODE (operands[0]) == MEM)
3817    && !TARGET_64BIT
3818    && !TARGET_SOFT_FLOAT"
3819   "*
3821   if ((FP_REG_P (operands[0]) || FP_REG_P (operands[1])
3822        || operands[1] == CONST0_RTX (DFmode))
3823       && !(REG_P (operands[0]) && REG_P (operands[1])
3824            && FP_REG_P (operands[0]) ^ FP_REG_P (operands[1])))
3825     return pa_output_fp_move_double (operands);
3826   return pa_output_move_double (operands);
3828   [(set_attr "type" "fpalu,move,fpstore,store,store,fpload,load,load,fpstore_load,store_fpload")
3829    (set_attr "length" "4,8,4,8,16,4,8,16,12,12")])
3831 (define_insn ""
3832   [(set (match_operand:DF 0 "indexed_memory_operand" "=R")
3833         (match_operand:DF 1 "reg_or_0_operand" "f"))]
3834   "!TARGET_SOFT_FLOAT
3835    && !TARGET_DISABLE_INDEXING
3836    && reload_completed"
3837   "fstd%F0 %1,%0"
3838   [(set_attr "type" "fpstore")
3839    (set_attr "pa_combine_type" "addmove")
3840    (set_attr "length" "4")])
3842 (define_peephole2
3843   [(set (match_operand:SI 0 "register_operand" "")
3844         (plus:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
3845                             (const_int 3))
3846                  (match_operand:SI 2 "register_operand" "")))
3847    (set (mem:DF (match_dup 0))
3848         (match_operand:DF 3 "register_operand" ""))]
3849   "!TARGET_SOFT_FLOAT
3850    && !TARGET_DISABLE_INDEXING
3851    && REG_OK_FOR_BASE_P (operands[2])
3852    && FP_REGNO_P (REGNO (operands[3]))"
3853   [(set (mem:DF (plus:SI (mult:SI (match_dup 1) (const_int 8)) (match_dup 2)))
3854         (match_dup 3))
3855    (set (match_dup 0) (plus:SI (ashift:SI (match_dup 1) (const_int 3))
3856                                (match_dup 2)))]
3857   "")
3859 (define_peephole2
3860   [(set (match_operand:SI 0 "register_operand" "")
3861         (plus:SI (match_operand:SI 2 "register_operand" "")
3862                  (ashift:SI (match_operand:SI 1 "register_operand" "")
3863                             (const_int 3))))
3864    (set (mem:DF (match_dup 0))
3865         (match_operand:DF 3 "register_operand" ""))]
3866   "!TARGET_SOFT_FLOAT
3867    && !TARGET_DISABLE_INDEXING
3868    && REG_OK_FOR_BASE_P (operands[2])
3869    && FP_REGNO_P (REGNO (operands[3]))"
3870   [(set (mem:DF (plus:SI (mult:SI (match_dup 1) (const_int 8)) (match_dup 2)))
3871         (match_dup 3))
3872    (set (match_dup 0) (plus:SI (ashift:SI (match_dup 1) (const_int 3))
3873                                (match_dup 2)))]
3874   "")
3876 (define_peephole2
3877   [(set (match_operand:DI 0 "register_operand" "")
3878         (plus:DI (ashift:DI (match_operand:DI 1 "register_operand" "")
3879                             (const_int 3))
3880                  (match_operand:DI 2 "register_operand" "")))
3881    (set (mem:DF (match_dup 0))
3882         (match_operand:DF 3 "register_operand" ""))]
3883   "!TARGET_SOFT_FLOAT
3884    && !TARGET_DISABLE_INDEXING
3885    && TARGET_64BIT
3886    && REG_OK_FOR_BASE_P (operands[2])
3887    && FP_REGNO_P (REGNO (operands[3]))"
3888   [(set (mem:DF (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
3889         (match_dup 3))
3890    (set (match_dup 0) (plus:DI (ashift:DI (match_dup 1) (const_int 3))
3891                                (match_dup 2)))]
3892   "")
3894 (define_peephole2
3895   [(set (match_operand:DI 0 "register_operand" "")
3896         (plus:DI (match_operand:DI 2 "register_operand" "")
3897                  (ashift:DI (match_operand:DI 1 "register_operand" "")
3898                             (const_int 3))))
3899    (set (mem:DF (match_dup 0))
3900         (match_operand:DF 3 "register_operand" ""))]
3901   "!TARGET_SOFT_FLOAT
3902    && !TARGET_DISABLE_INDEXING
3903    && TARGET_64BIT
3904    && REG_OK_FOR_BASE_P (operands[2])
3905    && FP_REGNO_P (REGNO (operands[3]))"
3906   [(set (mem:DF (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
3907         (match_dup 3))
3908    (set (match_dup 0) (plus:DI (ashift:DI (match_dup 1) (const_int 3))
3909                                (match_dup 2)))]
3910   "")
3912 (define_peephole2
3913   [(set (match_operand:SI 0 "register_operand" "")
3914         (plus:SI (match_operand:SI 1 "register_operand" "")
3915                  (match_operand:SI 2 "register_operand" "")))
3916    (set (mem:DF (match_dup 0))
3917         (match_operand:DF 3 "register_operand" ""))]
3918   "!TARGET_SOFT_FLOAT
3919    && !TARGET_DISABLE_INDEXING
3920    && TARGET_NO_SPACE_REGS
3921    && REG_OK_FOR_INDEX_P (operands[1])
3922    && REG_OK_FOR_BASE_P (operands[2])
3923    && FP_REGNO_P (REGNO (operands[3]))"
3924   [(set (mem:DF (plus:SI (match_dup 1) (match_dup 2)))
3925         (match_dup 3))
3926    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
3927   "")
3929 (define_peephole2
3930   [(set (match_operand:SI 0 "register_operand" "")
3931         (plus:SI (match_operand:SI 1 "register_operand" "")
3932                  (match_operand:SI 2 "register_operand" "")))
3933    (set (mem:DF (match_dup 0))
3934         (match_operand:DF 3 "register_operand" ""))]
3935   "!TARGET_SOFT_FLOAT
3936    && !TARGET_DISABLE_INDEXING
3937    && TARGET_NO_SPACE_REGS
3938    && REG_OK_FOR_BASE_P (operands[1])
3939    && REG_OK_FOR_INDEX_P (operands[2])
3940    && FP_REGNO_P (REGNO (operands[3]))"
3941   [(set (mem:DF (plus:SI (match_dup 2) (match_dup 1)))
3942         (match_dup 3))
3943    (set (match_dup 0) (plus:SI (match_dup 2) (match_dup 1)))]
3944   "")
3946 (define_peephole2
3947   [(set (match_operand:DI 0 "register_operand" "")
3948         (plus:DI (match_operand:DI 1 "register_operand" "")
3949                  (match_operand:DI 2 "register_operand" "")))
3950    (set (mem:DF (match_dup 0))
3951         (match_operand:DF 3 "register_operand" ""))]
3952   "!TARGET_SOFT_FLOAT
3953    && !TARGET_DISABLE_INDEXING
3954    && TARGET_64BIT
3955    && TARGET_NO_SPACE_REGS
3956    && REG_OK_FOR_INDEX_P (operands[1])
3957    && REG_OK_FOR_BASE_P (operands[2])
3958    && FP_REGNO_P (REGNO (operands[3]))"
3959   [(set (mem:DF (plus:DI (match_dup 1) (match_dup 2)))
3960         (match_dup 3))
3961    (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
3962   "")
3964 (define_peephole2
3965   [(set (match_operand:DI 0 "register_operand" "")
3966         (plus:DI (match_operand:DI 1 "register_operand" "")
3967                  (match_operand:DI 2 "register_operand" "")))
3968    (set (mem:DF (match_dup 0))
3969         (match_operand:DF 3 "register_operand" ""))]
3970   "!TARGET_SOFT_FLOAT
3971    && !TARGET_DISABLE_INDEXING
3972    && TARGET_64BIT
3973    && TARGET_NO_SPACE_REGS
3974    && REG_OK_FOR_BASE_P (operands[1])
3975    && REG_OK_FOR_INDEX_P (operands[2])
3976    && FP_REGNO_P (REGNO (operands[3]))"
3977   [(set (mem:DF (plus:DI (match_dup 2) (match_dup 1)))
3978         (match_dup 3))
3979    (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
3980   "")
3982 (define_insn ""
3983   [(set (match_operand:DF 0 "move_dest_operand"
3984                           "=r,?o,?Q,r,r")
3985         (match_operand:DF 1 "reg_or_0_or_nonsymb_mem_operand"
3986                           "rG,r,r,o,RQ"))]
3987   "(register_operand (operands[0], DFmode)
3988     || reg_or_0_operand (operands[1], DFmode))
3989    && !TARGET_64BIT
3990    && TARGET_SOFT_FLOAT"
3991   "*
3993   return pa_output_move_double (operands);
3995   [(set_attr "type" "move,store,store,load,load")
3996    (set_attr "length" "8,8,16,8,16")])
3998 (define_insn ""
3999   [(set (match_operand:DF 0 "move_dest_operand"
4000                           "=!*r,*r,*r,*r,*r,Q,f,f,T")
4001         (match_operand:DF 1 "move_src_operand"
4002                           "!*r,J,N,K,RQ,*rG,fG,RT,f"))]
4003   "(register_operand (operands[0], DFmode)
4004     || reg_or_0_operand (operands[1], DFmode))
4005    && !TARGET_SOFT_FLOAT && TARGET_64BIT"
4006   "@
4007    copy %1,%0
4008    ldi %1,%0
4009    ldil L'%1,%0
4010    depdi,z %z1,%0
4011    ldd%M1 %1,%0
4012    std%M0 %r1,%0
4013    fcpy,dbl %f1,%0
4014    fldd%F1 %1,%0
4015    fstd%F0 %1,%0"
4016   [(set_attr "type" "move,move,move,shift,load,store,fpalu,fpload,fpstore")
4017    (set_attr "pa_combine_type" "addmove")
4018    (set_attr "length" "4,4,4,4,4,4,4,4,4")])
4021 (define_expand "movdi"
4022   [(set (match_operand:DI 0 "general_operand" "")
4023         (match_operand:DI 1 "general_operand" ""))]
4024   ""
4025   "
4027   if (pa_emit_move_sequence (operands, DImode, 0))
4028     DONE;
4031 ;; Handle DImode input reloads requiring %r1 as a scratch register.
4032 (define_expand "reload_indi_r1"
4033   [(set (match_operand:DI 0 "register_operand" "=Z")
4034         (match_operand:DI 1 "non_hard_reg_operand" ""))
4035    (clobber (match_operand:SI 2 "register_operand" "=&a"))]
4036   ""
4037   "
4039   if (pa_emit_move_sequence (operands, DImode, operands[2]))
4040     DONE;
4042   /* We don't want the clobber emitted, so handle this ourselves.  */
4043   emit_insn (gen_rtx_SET (operands[0], operands[1]));
4044   DONE;
4047 ;; Handle DImode input reloads requiring a general register as a
4048 ;; scratch register.
4049 (define_expand "reload_indi"
4050   [(set (match_operand:DI 0 "register_operand" "=Z")
4051         (match_operand:DI 1 "non_hard_reg_operand" ""))
4052    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
4053   ""
4054   "
4056   if (pa_emit_move_sequence (operands, DImode, operands[2]))
4057     DONE;
4059   /* We don't want the clobber emitted, so handle this ourselves.  */
4060   emit_insn (gen_rtx_SET (operands[0], operands[1]));
4061   DONE;
4064 ;; Handle DImode output reloads requiring a general register as a
4065 ;; scratch register.
4066 (define_expand "reload_outdi"
4067   [(set (match_operand:DI 0 "non_hard_reg_operand" "")
4068         (match_operand:DI 1 "register_operand" "Z"))
4069    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
4070   ""
4071   "
4073   if (pa_emit_move_sequence (operands, DImode, operands[2]))
4074     DONE;
4076   /* We don't want the clobber emitted, so handle this ourselves.  */
4077   emit_insn (gen_rtx_SET (operands[0], operands[1]));
4078   DONE;
4081 (define_insn ""
4082   [(set (match_operand:DI 0 "register_operand" "=r")
4083         (high:DI (match_operand 1 "" "")))]
4084   "!TARGET_64BIT"
4085   "*
4087   rtx op0 = operands[0];
4088   rtx op1 = operands[1];
4090   switch (GET_CODE (op1))
4091     {
4092     case CONST_INT:
4093 #if HOST_BITS_PER_WIDE_INT <= 32
4094       operands[0] = operand_subword (op0, 1, 0, DImode);
4095       output_asm_insn (\"ldil L'%1,%0\", operands);
4097       operands[0] = operand_subword (op0, 0, 0, DImode);
4098       if (INTVAL (op1) < 0)
4099         output_asm_insn (\"ldi -1,%0\", operands);
4100       else
4101         output_asm_insn (\"ldi 0,%0\", operands);
4102 #else
4103       operands[0] = operand_subword (op0, 1, 0, DImode);
4104       operands[1] = GEN_INT (INTVAL (op1) & 0xffffffff);
4105       output_asm_insn (\"ldil L'%1,%0\", operands);
4107       operands[0] = operand_subword (op0, 0, 0, DImode);
4108       operands[1] = GEN_INT (INTVAL (op1) >> 32);
4109       output_asm_insn (pa_singlemove_string (operands), operands);
4110 #endif
4111       break;
4113     case CONST_DOUBLE:
4114       operands[0] = operand_subword (op0, 1, 0, DImode);
4115       operands[1] = GEN_INT (CONST_DOUBLE_LOW (op1));
4116       output_asm_insn (\"ldil L'%1,%0\", operands);
4118       operands[0] = operand_subword (op0, 0, 0, DImode);
4119       operands[1] = GEN_INT (CONST_DOUBLE_HIGH (op1));
4120       output_asm_insn (pa_singlemove_string (operands), operands);
4121       break;
4123     default:
4124       gcc_unreachable ();
4125     }
4126   return \"\";
4128   [(set_attr "type" "move")
4129    (set_attr "length" "12")])
4131 (define_insn ""
4132   [(set (match_operand:DI 0 "move_dest_operand"
4133                           "=r,o,Q,r,r,r,*f,*f,T,?r,?*f")
4134         (match_operand:DI 1 "move_src_operand"
4135                           "rM,r,r,o*R,Q,i,*fM,RT,*f,*f,r"))]
4136   "(register_operand (operands[0], DImode)
4137     || reg_or_0_operand (operands[1], DImode))
4138    && !TARGET_64BIT
4139    && !TARGET_SOFT_FLOAT"
4140   "*
4142   if ((FP_REG_P (operands[0]) || FP_REG_P (operands[1])
4143        || operands[1] == CONST0_RTX (DFmode))
4144       && !(REG_P (operands[0]) && REG_P (operands[1])
4145            && FP_REG_P (operands[0]) ^ FP_REG_P (operands[1])))
4146     return pa_output_fp_move_double (operands);
4147   return pa_output_move_double (operands);
4149   [(set_attr "type"
4150     "move,store,store,load,load,multi,fpalu,fpload,fpstore,fpstore_load,store_fpload")
4151    (set_attr "length" "8,8,16,8,16,16,4,4,4,12,12")])
4153 (define_insn ""
4154   [(set (match_operand:DI 0 "move_dest_operand"
4155                           "=r,r,r,r,r,r,Q,!*q,!r,!*f,*f,T")
4156         (match_operand:DI 1 "move_src_operand"
4157                           "A,r,J,N,K,RQ,rM,!rM,!*q,!*fM,RT,*f"))]
4158   "(register_operand (operands[0], DImode)
4159     || reg_or_0_operand (operands[1], DImode))
4160    && !TARGET_SOFT_FLOAT && TARGET_64BIT"
4161   "@
4162    ldd RT'%A1,%0
4163    copy %1,%0
4164    ldi %1,%0
4165    ldil L'%1,%0
4166    depdi,z %z1,%0
4167    ldd%M1 %1,%0
4168    std%M0 %r1,%0
4169    mtsar %r1
4170    {mfctl|mfctl,w} %%sar,%0
4171    fcpy,dbl %f1,%0
4172    fldd%F1 %1,%0
4173    fstd%F0 %1,%0"
4174   [(set_attr "type" "load,move,move,move,shift,load,store,move,move,fpalu,fpload,fpstore")
4175    (set_attr "pa_combine_type" "addmove")
4176    (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4")])
4178 (define_insn ""
4179   [(set (match_operand:DI 0 "indexed_memory_operand" "=R")
4180         (match_operand:DI 1 "register_operand" "f"))]
4181   "!TARGET_SOFT_FLOAT
4182    && TARGET_64BIT
4183    && !TARGET_DISABLE_INDEXING
4184    && reload_completed"
4185   "fstd%F0 %1,%0"
4186   [(set_attr "type" "fpstore")
4187    (set_attr "pa_combine_type" "addmove")
4188    (set_attr "length" "4")])
4190 (define_peephole2
4191   [(set (match_operand:DI 0 "register_operand" "")
4192         (plus:DI (ashift:DI (match_operand:DI 1 "register_operand" "")
4193                             (const_int 3))
4194                  (match_operand:DI 2 "register_operand" "")))
4195    (set (mem:DI (match_dup 0))
4196         (match_operand:DI 3 "register_operand" ""))]
4197   "!TARGET_SOFT_FLOAT
4198    && !TARGET_DISABLE_INDEXING
4199    && TARGET_64BIT
4200    && REG_OK_FOR_BASE_P (operands[2])
4201    && FP_REGNO_P (REGNO (operands[3]))"
4202   [(set (mem:DI (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
4203         (match_dup 3))
4204    (set (match_dup 0) (plus:DI (ashift:DI (match_dup 1) (const_int 3))
4205                                (match_dup 2)))]
4206   "")
4208 (define_peephole2
4209   [(set (match_operand:DI 0 "register_operand" "")
4210         (plus:DI (match_operand:DI 1 "register_operand" "")
4211                  (match_operand:DI 2 "register_operand" "")))
4212    (set (mem:DI (match_dup 0))
4213         (match_operand:DI 3 "register_operand" ""))]
4214   "!TARGET_SOFT_FLOAT
4215    && !TARGET_DISABLE_INDEXING
4216    && TARGET_64BIT
4217    && TARGET_NO_SPACE_REGS
4218    && REG_OK_FOR_INDEX_P (operands[1])
4219    && REG_OK_FOR_BASE_P (operands[2])
4220    && FP_REGNO_P (REGNO (operands[3]))"
4221   [(set (mem:DI (plus:DI (match_dup 1) (match_dup 2)))
4222         (match_dup 3))
4223    (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
4224   "")
4226 (define_peephole2
4227   [(set (match_operand:DI 0 "register_operand" "")
4228         (plus:DI (match_operand:DI 1 "register_operand" "")
4229                  (match_operand:DI 2 "register_operand" "")))
4230    (set (mem:DI (match_dup 0))
4231         (match_operand:DI 3 "register_operand" ""))]
4232   "!TARGET_SOFT_FLOAT
4233    && !TARGET_DISABLE_INDEXING
4234    && TARGET_64BIT
4235    && TARGET_NO_SPACE_REGS
4236    && REG_OK_FOR_BASE_P (operands[1])
4237    && REG_OK_FOR_INDEX_P (operands[2])
4238    && FP_REGNO_P (REGNO (operands[3]))"
4239   [(set (mem:DI (plus:DI (match_dup 2) (match_dup 1)))
4240         (match_dup 3))
4241    (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
4242   "")
4244 (define_insn ""
4245   [(set (match_operand:DI 0 "move_dest_operand"
4246                           "=r,o,Q,r,r,r")
4247         (match_operand:DI 1 "general_operand"
4248                           "rM,r,r,o,Q,i"))]
4249   "(register_operand (operands[0], DImode)
4250     || reg_or_0_operand (operands[1], DImode))
4251    && !TARGET_64BIT
4252    && TARGET_SOFT_FLOAT"
4253   "*
4255   return pa_output_move_double (operands);
4257   [(set_attr "type" "move,store,store,load,load,multi")
4258    (set_attr "length" "8,8,16,8,16,16")])
4260 (define_insn ""
4261   [(set (match_operand:DI 0 "register_operand" "=r,&r")
4262         (lo_sum:DI (match_operand:DI 1 "register_operand" "0,r")
4263                    (match_operand:DI 2 "immediate_operand" "i,i")))]
4264   "!TARGET_64BIT"
4265   "*
4267   /* Don't output a 64-bit constant, since we can't trust the assembler to
4268      handle it correctly.  */
4269   if (GET_CODE (operands[2]) == CONST_DOUBLE)
4270     operands[2] = GEN_INT (CONST_DOUBLE_LOW (operands[2]));
4271   else if (HOST_BITS_PER_WIDE_INT > 32
4272            && GET_CODE (operands[2]) == CONST_INT)
4273     operands[2] = GEN_INT (INTVAL (operands[2]) & 0xffffffff);
4274   if (which_alternative == 1)
4275     output_asm_insn (\"copy %1,%0\", operands);
4276   return \"ldo R'%G2(%R1),%R0\";
4278   [(set_attr "type" "move,move")
4279    (set_attr "length" "4,8")])
4281 (define_expand "movsf"
4282   [(set (match_operand:SF 0 "general_operand" "")
4283         (match_operand:SF 1 "general_operand" ""))]
4284   ""
4285   "
4287   if (pa_emit_move_sequence (operands, SFmode, 0))
4288     DONE;
4291 ;; Handle SFmode input reloads requiring %r1 as a scratch register.
4292 (define_expand "reload_insf_r1"
4293   [(set (match_operand:SF 0 "register_operand" "=Z")
4294         (match_operand:SF 1 "non_hard_reg_operand" ""))
4295    (clobber (match_operand:SI 2 "register_operand" "=&a"))]
4296   ""
4297   "
4299   if (pa_emit_move_sequence (operands, SFmode, operands[2]))
4300     DONE;
4302   /* We don't want the clobber emitted, so handle this ourselves.  */
4303   emit_insn (gen_rtx_SET (operands[0], operands[1]));
4304   DONE;
4307 ;; Handle SFmode input reloads requiring a general register as a
4308 ;; scratch register.
4309 (define_expand "reload_insf"
4310   [(set (match_operand:SF 0 "register_operand" "=Z")
4311         (match_operand:SF 1 "non_hard_reg_operand" ""))
4312    (clobber (match_operand:SF 2 "register_operand" "=&r"))]
4313   ""
4314   "
4316   if (pa_emit_move_sequence (operands, SFmode, operands[2]))
4317     DONE;
4319   /* We don't want the clobber emitted, so handle this ourselves.  */
4320   emit_insn (gen_rtx_SET (operands[0], operands[1]));
4321   DONE;
4324 ;; Handle SFmode output reloads requiring a general register as a
4325 ;; scratch register.
4326 (define_expand "reload_outsf"
4327   [(set (match_operand:SF 0 "non_hard_reg_operand" "")
4328         (match_operand:SF 1  "register_operand" "Z"))
4329    (clobber (match_operand:SF 2 "register_operand" "=&r"))]
4330   ""
4331   "
4333   if (pa_emit_move_sequence (operands, SFmode, operands[2]))
4334     DONE;
4336   /* We don't want the clobber emitted, so handle this ourselves.  */
4337   emit_insn (gen_rtx_SET (operands[0], operands[1]));
4338   DONE;
4341 (define_insn ""
4342   [(set (match_operand:SF 0 "move_dest_operand"
4343                           "=f,!*r,f,*r,T,Q,?*r,?f")
4344         (match_operand:SF 1 "reg_or_0_or_nonsymb_mem_operand"
4345                           "fG,!*rG,RT,RQ,f,*rG,f,*r"))]
4346   "(register_operand (operands[0], SFmode)
4347     || reg_or_0_operand (operands[1], SFmode))
4348    && !TARGET_SOFT_FLOAT
4349    && !TARGET_64BIT"
4350   "@
4351    fcpy,sgl %f1,%0
4352    copy %r1,%0
4353    fldw%F1 %1,%0
4354    ldw%M1 %1,%0
4355    fstw%F0 %1,%0
4356    stw%M0 %r1,%0
4357    {fstws|fstw} %1,-16(%%sp)\n\t{ldws|ldw} -16(%%sp),%0
4358    {stws|stw} %1,-16(%%sp)\n\t{fldws|fldw} -16(%%sp),%0"
4359   [(set_attr "type" "fpalu,move,fpload,load,fpstore,store,fpstore_load,store_fpload")
4360    (set_attr "pa_combine_type" "addmove")
4361    (set_attr "length" "4,4,4,4,4,4,8,8")])
4363 (define_insn ""
4364   [(set (match_operand:SF 0 "move_dest_operand"
4365                           "=f,!*r,f,*r,T,Q")
4366         (match_operand:SF 1 "reg_or_0_or_nonsymb_mem_operand"
4367                           "fG,!*rG,RT,RQ,f,*rG"))]
4368   "(register_operand (operands[0], SFmode)
4369     || reg_or_0_operand (operands[1], SFmode))
4370    && !TARGET_SOFT_FLOAT
4371    && TARGET_64BIT"
4372   "@
4373    fcpy,sgl %f1,%0
4374    copy %r1,%0
4375    fldw%F1 %1,%0
4376    ldw%M1 %1,%0
4377    fstw%F0 %1,%0
4378    stw%M0 %r1,%0"
4379   [(set_attr "type" "fpalu,move,fpload,load,fpstore,store")
4380    (set_attr "pa_combine_type" "addmove")
4381    (set_attr "length" "4,4,4,4,4,4")])
4383 (define_insn ""
4384   [(set (match_operand:SF 0 "indexed_memory_operand" "=R")
4385         (match_operand:SF 1 "register_operand" "f"))]
4386   "!TARGET_SOFT_FLOAT
4387    && !TARGET_DISABLE_INDEXING
4388    && reload_completed"
4389   "fstw%F0 %1,%0"
4390   [(set_attr "type" "fpstore")
4391    (set_attr "pa_combine_type" "addmove")
4392    (set_attr "length" "4")])
4394 (define_peephole2
4395   [(set (match_operand:SI 0 "register_operand" "")
4396         (plus:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
4397                             (const_int 2))
4398                  (match_operand:SI 2 "register_operand" "")))
4399    (set (mem:SF (match_dup 0))
4400         (match_operand:SF 3 "register_operand" ""))]
4401   "!TARGET_SOFT_FLOAT
4402    && !TARGET_DISABLE_INDEXING
4403    && REG_OK_FOR_BASE_P (operands[2])
4404    && FP_REGNO_P (REGNO (operands[3]))"
4405   [(set (mem:SF (plus:SI (mult:SI (match_dup 1) (const_int 4)) (match_dup 2)))
4406         (match_dup 3))
4407    (set (match_dup 0) (plus:SI (ashift:SI (match_dup 1) (const_int 2))
4408                                (match_dup 2)))]
4409   "")
4411 (define_peephole2
4412   [(set (match_operand:DI 0 "register_operand" "")
4413         (plus:DI (ashift:DI (match_operand:DI 1 "register_operand" "")
4414                             (const_int 2))
4415                  (match_operand:DI 2 "register_operand" "")))
4416    (set (mem:SF (match_dup 0))
4417         (match_operand:SF 3 "register_operand" ""))]
4418   "!TARGET_SOFT_FLOAT
4419    && !TARGET_DISABLE_INDEXING
4420    && TARGET_64BIT
4421    && REG_OK_FOR_BASE_P (operands[2])
4422    && FP_REGNO_P (REGNO (operands[3]))"
4423   [(set (mem:SF (plus:DI (mult:DI (match_dup 1) (const_int 4)) (match_dup 2)))
4424         (match_dup 3))
4425    (set (match_dup 0) (plus:DI (ashift:DI (match_dup 1) (const_int 2))
4426                                (match_dup 2)))]
4427   "")
4429 (define_peephole2
4430   [(set (match_operand:SI 0 "register_operand" "")
4431         (plus:SI (match_operand:SI 1 "register_operand" "")
4432                  (match_operand:SI 2 "register_operand" "")))
4433    (set (mem:SF (match_dup 0))
4434         (match_operand:SF 3 "register_operand" ""))]
4435   "!TARGET_SOFT_FLOAT
4436    && !TARGET_DISABLE_INDEXING
4437    && TARGET_NO_SPACE_REGS
4438    && REG_OK_FOR_INDEX_P (operands[1])
4439    && REG_OK_FOR_BASE_P (operands[2])
4440    && FP_REGNO_P (REGNO (operands[3]))"
4441   [(set (mem:SF (plus:SI (match_dup 1) (match_dup 2)))
4442         (match_dup 3))
4443    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
4444   "")
4446 (define_peephole2
4447   [(set (match_operand:SI 0 "register_operand" "")
4448         (plus:SI (match_operand:SI 1 "register_operand" "")
4449                  (match_operand:SI 2 "register_operand" "")))
4450    (set (mem:SF (match_dup 0))
4451         (match_operand:SF 3 "register_operand" ""))]
4452   "!TARGET_SOFT_FLOAT
4453    && !TARGET_DISABLE_INDEXING
4454    && TARGET_NO_SPACE_REGS
4455    && REG_OK_FOR_BASE_P (operands[1])
4456    && REG_OK_FOR_INDEX_P (operands[2])
4457    && FP_REGNO_P (REGNO (operands[3]))"
4458   [(set (mem:SF (plus:SI (match_dup 2) (match_dup 1)))
4459         (match_dup 3))
4460    (set (match_dup 0) (plus:SI (match_dup 2) (match_dup 1)))]
4461   "")
4463 (define_peephole2
4464   [(set (match_operand:DI 0 "register_operand" "")
4465         (plus:DI (match_operand:DI 1 "register_operand" "")
4466                  (match_operand:DI 2 "register_operand" "")))
4467    (set (mem:SF (match_dup 0))
4468         (match_operand:SF 3 "register_operand" ""))]
4469   "!TARGET_SOFT_FLOAT
4470    && !TARGET_DISABLE_INDEXING
4471    && TARGET_64BIT
4472    && TARGET_NO_SPACE_REGS
4473    && REG_OK_FOR_INDEX_P (operands[1])
4474    && REG_OK_FOR_BASE_P (operands[2])
4475    && FP_REGNO_P (REGNO (operands[3]))"
4476   [(set (mem:SF (plus:DI (match_dup 1) (match_dup 2)))
4477         (match_dup 3))
4478    (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
4479   "")
4481 (define_peephole2
4482   [(set (match_operand:DI 0 "register_operand" "")
4483         (plus:DI (match_operand:DI 1 "register_operand" "")
4484                  (match_operand:DI 2 "register_operand" "")))
4485    (set (mem:SF (match_dup 0))
4486         (match_operand:SF 3 "register_operand" ""))]
4487   "!TARGET_SOFT_FLOAT
4488    && !TARGET_DISABLE_INDEXING
4489    && TARGET_64BIT
4490    && TARGET_NO_SPACE_REGS
4491    && REG_OK_FOR_BASE_P (operands[1])
4492    && REG_OK_FOR_INDEX_P (operands[2])
4493    && FP_REGNO_P (REGNO (operands[3]))"
4494   [(set (mem:SF (plus:DI (match_dup 2) (match_dup 1)))
4495         (match_dup 3))
4496    (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
4497   "")
4499 (define_insn ""
4500   [(set (match_operand:SF 0 "move_dest_operand"
4501                           "=r,r,Q")
4502         (match_operand:SF 1 "reg_or_0_or_nonsymb_mem_operand"
4503                           "rG,RQ,rG"))]
4504   "(register_operand (operands[0], SFmode)
4505     || reg_or_0_operand (operands[1], SFmode))
4506    && TARGET_SOFT_FLOAT"
4507   "@
4508    copy %r1,%0
4509    ldw%M1 %1,%0
4510    stw%M0 %r1,%0"
4511   [(set_attr "type" "move,load,store")
4512    (set_attr "pa_combine_type" "addmove")
4513    (set_attr "length" "4,4,4")])
4517 ;;- zero extension instructions
4518 ;; We have define_expand for zero extension patterns to make sure the
4519 ;; operands get loaded into registers.  The define_insns accept
4520 ;; memory operands.  This gives us better overall code than just
4521 ;; having a pattern that does or does not accept memory operands.
4523 (define_expand "zero_extendqihi2"
4524   [(set (match_operand:HI 0 "register_operand" "")
4525         (zero_extend:HI
4526          (match_operand:QI 1 "register_operand" "")))]
4527   ""
4528   "")
4530 (define_insn ""
4531   [(set (match_operand:HI 0 "register_operand" "=r,r")
4532         (zero_extend:HI
4533          (match_operand:QI 1 "move_src_operand" "r,RQ")))]
4534   "GET_CODE (operands[1]) != CONST_INT"
4535   "@
4536    {extru|extrw,u} %1,31,8,%0
4537    ldb%M1 %1,%0"
4538   [(set_attr "type" "shift,load")
4539    (set_attr "length" "4,4")])
4541 (define_expand "zero_extendqisi2"
4542   [(set (match_operand:SI 0 "register_operand" "")
4543         (zero_extend:SI
4544          (match_operand:QI 1 "register_operand" "")))]
4545   ""
4546   "")
4548 (define_insn ""
4549   [(set (match_operand:SI 0 "register_operand" "=r,r")
4550         (zero_extend:SI
4551          (match_operand:QI 1 "move_src_operand" "r,RQ")))]
4552   "GET_CODE (operands[1]) != CONST_INT"
4553   "@
4554    {extru|extrw,u} %1,31,8,%0
4555    ldb%M1 %1,%0"
4556   [(set_attr "type" "shift,load")
4557    (set_attr "length" "4,4")])
4559 (define_expand "zero_extendhisi2"
4560   [(set (match_operand:SI 0 "register_operand" "")
4561         (zero_extend:SI
4562          (match_operand:HI 1 "register_operand" "")))]
4563   ""
4564   "")
4566 (define_insn ""
4567   [(set (match_operand:SI 0 "register_operand" "=r,r")
4568         (zero_extend:SI
4569          (match_operand:HI 1 "move_src_operand" "r,RQ")))]
4570   "GET_CODE (operands[1]) != CONST_INT"
4571   "@
4572    {extru|extrw,u} %1,31,16,%0
4573    ldh%M1 %1,%0"
4574   [(set_attr "type" "shift,load")
4575    (set_attr "length" "4,4")])
4577 (define_expand "zero_extendqidi2"
4578   [(set (match_operand:DI 0 "register_operand" "")
4579         (zero_extend:DI
4580          (match_operand:QI 1 "register_operand" "")))]
4581   "TARGET_64BIT"
4582   "")
4584 (define_insn ""
4585   [(set (match_operand:DI 0 "register_operand" "=r,r")
4586         (zero_extend:DI
4587          (match_operand:QI 1 "move_src_operand" "r,RQ")))]
4588   "TARGET_64BIT && GET_CODE (operands[1]) != CONST_INT"
4589   "@
4590    extrd,u %1,63,8,%0
4591    ldb%M1 %1,%0"
4592   [(set_attr "type" "shift,load")
4593    (set_attr "length" "4,4")])
4595 (define_expand "zero_extendhidi2"
4596   [(set (match_operand:DI 0 "register_operand" "")
4597         (zero_extend:DI
4598          (match_operand:HI 1 "register_operand" "")))]
4599   "TARGET_64BIT"
4600   "")
4602 (define_insn ""
4603   [(set (match_operand:DI 0 "register_operand" "=r,r")
4604         (zero_extend:DI
4605          (match_operand:HI 1 "move_src_operand" "r,RQ")))]
4606   "TARGET_64BIT && GET_CODE (operands[1]) != CONST_INT"
4607   "@
4608    extrd,u %1,63,16,%0
4609    ldh%M1 %1,%0"
4610   [(set_attr "type" "shift,load")
4611    (set_attr "length" "4,4")])
4613 (define_expand "zero_extendsidi2"
4614   [(set (match_operand:DI 0 "register_operand" "")
4615         (zero_extend:DI
4616          (match_operand:SI 1 "register_operand" "")))]
4617   "TARGET_64BIT"
4618   "")
4620 (define_insn ""
4621   [(set (match_operand:DI 0 "register_operand" "=r,r")
4622         (zero_extend:DI
4623          (match_operand:SI 1 "move_src_operand" "r,RQ")))]
4624   "TARGET_64BIT && GET_CODE (operands[1]) != CONST_INT"
4625   "@
4626    extrd,u %1,63,32,%0
4627    ldw%M1 %1,%0"
4628   [(set_attr "type" "shift,load")
4629    (set_attr "length" "4,4")])
4631 ;;- sign extension instructions
4633 (define_insn "extendhisi2"
4634   [(set (match_operand:SI 0 "register_operand" "=r")
4635         (sign_extend:SI (match_operand:HI 1 "register_operand" "r")))]
4636   ""
4637   "{extrs|extrw,s} %1,31,16,%0"
4638   [(set_attr "type" "shift")
4639    (set_attr "length" "4")])
4641 (define_insn "extendqihi2"
4642   [(set (match_operand:HI 0 "register_operand" "=r")
4643         (sign_extend:HI (match_operand:QI 1 "register_operand" "r")))]
4644   ""
4645   "{extrs|extrw,s} %1,31,8,%0"
4646   [(set_attr "type" "shift") 
4647   (set_attr "length" "4")])
4649 (define_insn "extendqisi2"
4650   [(set (match_operand:SI 0 "register_operand" "=r")
4651         (sign_extend:SI (match_operand:QI 1 "register_operand" "r")))]
4652   ""
4653   "{extrs|extrw,s} %1,31,8,%0"
4654   [(set_attr "type" "shift")
4655    (set_attr "length" "4")])
4657 (define_insn "extendqidi2"
4658   [(set (match_operand:DI 0 "register_operand" "=r")
4659         (sign_extend:DI (match_operand:QI 1 "register_operand" "r")))]
4660   "TARGET_64BIT"
4661   "extrd,s %1,63,8,%0"
4662   [(set_attr "type" "shift") 
4663   (set_attr "length" "4")])
4665 (define_insn "extendhidi2"
4666   [(set (match_operand:DI 0 "register_operand" "=r")
4667         (sign_extend:DI (match_operand:HI 1 "register_operand" "r")))]
4668   "TARGET_64BIT"
4669   "extrd,s %1,63,16,%0"
4670   [(set_attr "type" "shift") 
4671   (set_attr "length" "4")])
4673 (define_insn "extendsidi2"
4674   [(set (match_operand:DI 0 "register_operand" "=r")
4675         (sign_extend:DI (match_operand:SI 1 "register_operand" "r")))]
4676   "TARGET_64BIT"
4677   "extrd,s %1,63,32,%0"
4678   [(set_attr "type" "shift") 
4679   (set_attr "length" "4")])
4682 ;; Conversions between float and double.
4684 (define_insn "extendsfdf2"
4685   [(set (match_operand:DF 0 "register_operand" "=f")
4686         (float_extend:DF
4687          (match_operand:SF 1 "register_operand" "f")))]
4688   "! TARGET_SOFT_FLOAT"
4689   "{fcnvff|fcnv},sgl,dbl %1,%0"
4690   [(set_attr "type" "fpalu")
4691    (set_attr "length" "4")])
4693 (define_insn "truncdfsf2"
4694   [(set (match_operand:SF 0 "register_operand" "=f")
4695         (float_truncate:SF
4696          (match_operand:DF 1 "register_operand" "f")))]
4697   "! TARGET_SOFT_FLOAT"
4698   "{fcnvff|fcnv},dbl,sgl %1,%0"
4699   [(set_attr "type" "fpalu")
4700    (set_attr "length" "4")])
4702 ;; Conversion between fixed point and floating point.
4703 ;; Note that among the fix-to-float insns
4704 ;; the ones that start with SImode come first.
4705 ;; That is so that an operand that is a CONST_INT
4706 ;; (and therefore lacks a specific machine mode).
4707 ;; will be recognized as SImode (which is always valid)
4708 ;; rather than as QImode or HImode.
4710 ;; This pattern forces (set (reg:SF ...) (float:SF (const_int ...)))
4711 ;; to be reloaded by putting the constant into memory.
4712 ;; It must come before the more general floatsisf2 pattern.
4713 (define_insn ""
4714   [(set (match_operand:SF 0 "register_operand" "=f")
4715         (float:SF (match_operand:SI 1 "const_int_operand" "m")))]
4716   "! TARGET_SOFT_FLOAT"
4717   "fldw%F1 %1,%0\;{fcnvxf,sgl,sgl|fcnv,w,sgl} %0,%0"
4718   [(set_attr "type" "fpalu")
4719    (set_attr "length" "8")])
4721 (define_insn "floatsisf2"
4722   [(set (match_operand:SF 0 "register_operand" "=f")
4723         (float:SF (match_operand:SI 1 "register_operand" "f")))]
4724   "! TARGET_SOFT_FLOAT"
4725   "{fcnvxf,sgl,sgl|fcnv,w,sgl} %1,%0"
4726   [(set_attr "type" "fpalu")
4727    (set_attr "length" "4")])
4729 ;; This pattern forces (set (reg:DF ...) (float:DF (const_int ...)))
4730 ;; to be reloaded by putting the constant into memory.
4731 ;; It must come before the more general floatsidf2 pattern.
4732 (define_insn ""
4733   [(set (match_operand:DF 0 "register_operand" "=f")
4734         (float:DF (match_operand:SI 1 "const_int_operand" "m")))]
4735   "! TARGET_SOFT_FLOAT"
4736   "fldw%F1 %1,%0\;{fcnvxf,sgl,dbl|fcnv,w,dbl} %0,%0"
4737   [(set_attr "type" "fpalu")
4738    (set_attr "length" "8")])
4740 (define_insn "floatsidf2"
4741   [(set (match_operand:DF 0 "register_operand" "=f")
4742         (float:DF (match_operand:SI 1 "register_operand" "f")))]
4743   "! TARGET_SOFT_FLOAT"
4744   "{fcnvxf,sgl,dbl|fcnv,w,dbl} %1,%0"
4745   [(set_attr "type" "fpalu")
4746    (set_attr "length" "4")])
4748 (define_expand "floatunssisf2"
4749   [(set (subreg:SI (match_dup 2) 4)
4750         (match_operand:SI 1 "register_operand" ""))
4751    (set (subreg:SI (match_dup 2) 0)
4752         (const_int 0))
4753    (set (match_operand:SF 0 "register_operand" "")
4754         (float:SF (match_dup 2)))]
4755   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4756   "
4758   if (TARGET_PA_20)
4759     {
4760       emit_insn (gen_floatunssisf2_pa20 (operands[0], operands[1]));
4761       DONE;
4762     }
4763   operands[2] = gen_reg_rtx (DImode);
4766 (define_expand "floatunssidf2"
4767   [(set (subreg:SI (match_dup 2) 4)
4768         (match_operand:SI 1 "register_operand" ""))
4769    (set (subreg:SI (match_dup 2) 0)
4770         (const_int 0))
4771    (set (match_operand:DF 0 "register_operand" "")
4772         (float:DF (match_dup 2)))]
4773   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4774   "
4776   if (TARGET_PA_20)
4777     {
4778       emit_insn (gen_floatunssidf2_pa20 (operands[0], operands[1]));
4779       DONE;
4780     }
4781   operands[2] = gen_reg_rtx (DImode);
4784 (define_insn "floatdisf2"
4785   [(set (match_operand:SF 0 "register_operand" "=f")
4786         (float:SF (match_operand:DI 1 "register_operand" "f")))]
4787   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4788   "{fcnvxf,dbl,sgl|fcnv,dw,sgl} %1,%0"
4789   [(set_attr "type" "fpalu")
4790    (set_attr "length" "4")])
4792 (define_insn "floatdidf2"
4793   [(set (match_operand:DF 0 "register_operand" "=f")
4794         (float:DF (match_operand:DI 1 "register_operand" "f")))]
4795   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4796   "{fcnvxf,dbl,dbl|fcnv,dw,dbl} %1,%0"
4797   [(set_attr "type" "fpalu")
4798    (set_attr "length" "4")])
4800 ;; Convert a float to an actual integer.
4801 ;; Truncation is performed as part of the conversion.
4803 (define_insn "fix_truncsfsi2"
4804   [(set (match_operand:SI 0 "register_operand" "=f")
4805         (fix:SI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
4806   "! TARGET_SOFT_FLOAT"
4807   "{fcnvfxt,sgl,sgl|fcnv,t,sgl,w} %1,%0"
4808   [(set_attr "type" "fpalu")
4809    (set_attr "length" "4")])
4811 (define_insn "fix_truncdfsi2"
4812   [(set (match_operand:SI 0 "register_operand" "=f")
4813         (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
4814   "! TARGET_SOFT_FLOAT"
4815   "{fcnvfxt,dbl,sgl|fcnv,t,dbl,w} %1,%0"
4816   [(set_attr "type" "fpalu")
4817    (set_attr "length" "4")])
4819 (define_insn "fix_truncsfdi2"
4820   [(set (match_operand:DI 0 "register_operand" "=f")
4821         (fix:DI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
4822   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4823   "{fcnvfxt,sgl,dbl|fcnv,t,sgl,dw} %1,%0"
4824   [(set_attr "type" "fpalu")
4825    (set_attr "length" "4")])
4827 (define_insn "fix_truncdfdi2"
4828   [(set (match_operand:DI 0 "register_operand" "=f")
4829         (fix:DI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
4830   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4831   "{fcnvfxt,dbl,dbl|fcnv,t,dbl,dw} %1,%0"
4832   [(set_attr "type" "fpalu")
4833    (set_attr "length" "4")])
4835 (define_insn "floatunssidf2_pa20"
4836   [(set (match_operand:DF 0 "register_operand" "=f")
4837         (unsigned_float:DF (match_operand:SI 1 "register_operand" "f")))]
4838   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4839   "fcnv,uw,dbl %1,%0"
4840   [(set_attr "type" "fpalu")
4841    (set_attr "length" "4")])
4843 (define_insn "floatunssisf2_pa20"
4844   [(set (match_operand:SF 0 "register_operand" "=f")
4845         (unsigned_float:SF (match_operand:SI 1 "register_operand" "f")))]
4846   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4847   "fcnv,uw,sgl %1,%0"
4848   [(set_attr "type" "fpalu")
4849    (set_attr "length" "4")])
4851 (define_insn "floatunsdisf2"
4852   [(set (match_operand:SF 0 "register_operand" "=f")
4853         (unsigned_float:SF (match_operand:DI 1 "register_operand" "f")))]
4854   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4855   "fcnv,udw,sgl %1,%0"
4856   [(set_attr "type" "fpalu")
4857    (set_attr "length" "4")])
4859 (define_insn "floatunsdidf2"
4860   [(set (match_operand:DF 0 "register_operand" "=f")
4861         (unsigned_float:DF (match_operand:DI 1 "register_operand" "f")))]
4862   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4863   "fcnv,udw,dbl %1,%0"
4864   [(set_attr "type" "fpalu")
4865    (set_attr "length" "4")])
4867 (define_insn "fixuns_truncsfsi2"
4868   [(set (match_operand:SI 0 "register_operand" "=f")
4869         (unsigned_fix:SI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
4870   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4871   "fcnv,t,sgl,uw %1,%0"
4872   [(set_attr "type" "fpalu")
4873    (set_attr "length" "4")])
4875 (define_insn "fixuns_truncdfsi2"
4876   [(set (match_operand:SI 0 "register_operand" "=f")
4877         (unsigned_fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
4878   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4879   "fcnv,t,dbl,uw %1,%0"
4880   [(set_attr "type" "fpalu")
4881    (set_attr "length" "4")])
4883 (define_insn "fixuns_truncsfdi2"
4884   [(set (match_operand:DI 0 "register_operand" "=f")
4885         (unsigned_fix:DI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
4886   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4887   "fcnv,t,sgl,udw %1,%0"
4888   [(set_attr "type" "fpalu")
4889    (set_attr "length" "4")])
4891 (define_insn "fixuns_truncdfdi2"
4892   [(set (match_operand:DI 0 "register_operand" "=f")
4893         (unsigned_fix:DI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
4894   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4895   "fcnv,t,dbl,udw %1,%0"
4896   [(set_attr "type" "fpalu")
4897    (set_attr "length" "4")])
4899 ;;- arithmetic instructions
4901 (define_expand "adddi3"
4902   [(set (match_operand:DI 0 "register_operand" "")
4903         (plus:DI (match_operand:DI 1 "register_operand" "")
4904                  (match_operand:DI 2 "adddi3_operand" "")))]
4905   ""
4906   "")
4908 (define_insn ""
4909   [(set (match_operand:DI 0 "register_operand" "=r")
4910         (plus:DI (match_operand:DI 1 "register_operand" "%r")
4911                  (match_operand:DI 2 "arith11_operand" "rI")))]
4912   "!TARGET_64BIT"
4913   "*
4915   if (GET_CODE (operands[2]) == CONST_INT)
4916     {
4917       if (INTVAL (operands[2]) >= 0)
4918         return \"addi %2,%R1,%R0\;{addc|add,c} %1,%%r0,%0\";
4919       else
4920         return \"addi %2,%R1,%R0\;{subb|sub,b} %1,%%r0,%0\";
4921     }
4922   else
4923     return \"add %R2,%R1,%R0\;{addc|add,c} %2,%1,%0\";
4925   [(set_attr "type" "binary")
4926    (set_attr "length" "8")])
4928 (define_insn ""
4929   [(set (match_operand:DI 0 "register_operand" "=r,r")
4930         (plus:DI (match_operand:DI 1 "register_operand" "%r,r")
4931                  (match_operand:DI 2 "arith14_operand" "r,J")))]
4932   "TARGET_64BIT"
4933   "@
4934    add,l %1,%2,%0
4935    ldo %2(%1),%0"
4936   [(set_attr "type" "binary,binary")
4937    (set_attr "pa_combine_type" "addmove")
4938    (set_attr "length" "4,4")])
4940 (define_insn ""
4941   [(set (match_operand:DI 0 "register_operand" "=r")
4942         (plus:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
4943                  (match_operand:DI 2 "register_operand" "r")))]
4944   "TARGET_64BIT"
4945   "uaddcm %2,%1,%0"
4946   [(set_attr "type" "binary")
4947    (set_attr "length" "4")])
4949 (define_insn ""
4950   [(set (match_operand:SI 0 "register_operand" "=r")
4951         (plus:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
4952                  (match_operand:SI 2 "register_operand" "r")))]
4953   ""
4954   "uaddcm %2,%1,%0"
4955   [(set_attr "type" "binary")
4956    (set_attr "length" "4")])
4958 (define_expand "addvdi3"
4959   [(parallel [(set (match_operand:DI 0 "register_operand" "")
4960                    (plus:DI (match_operand:DI 1 "reg_or_0_operand" "")
4961                             (match_operand:DI 2 "arith11_operand" "")))
4962               (trap_if (ne (plus:TI (sign_extend:TI (match_dup 1))
4963                                     (sign_extend:TI (match_dup 2)))
4964                            (sign_extend:TI (plus:DI (match_dup 1)
4965                                                     (match_dup 2))))
4966                        (const_int 0))])]
4967   ""
4968   "")
4970 (define_insn ""
4971   [(set (match_operand:DI 0 "register_operand" "=r,r")
4972         (plus:DI (match_operand:DI 1 "reg_or_0_operand" "%rM,rM")
4973                  (match_operand:DI 2 "arith11_operand" "r,I")))
4974    (trap_if (ne (plus:TI (sign_extend:TI (match_dup 1))
4975                          (sign_extend:TI (match_dup 2)))
4976                 (sign_extend:TI (plus:DI (match_dup 1)
4977                                          (match_dup 2))))
4978             (const_int 0))]
4979   "TARGET_64BIT"
4980   "@
4981   add,tsv,* %2,%1,%0
4982   addi,tsv,* %2,%1,%0"
4983   [(set_attr "type" "binary,binary")
4984    (set_attr "length" "4,4")])
4986 (define_insn ""
4987   [(set (match_operand:DI 0 "register_operand" "=r")
4988         (plus:DI (match_operand:DI 1 "reg_or_0_operand" "%rM")
4989                  (match_operand:DI 2 "arith11_operand" "rI")))
4990    (trap_if (ne (plus:TI (sign_extend:TI (match_dup 1))
4991                          (sign_extend:TI (match_dup 2)))
4992                 (sign_extend:TI (plus:DI (match_dup 1)
4993                                          (match_dup 2))))
4994             (const_int 0))]
4995   "!TARGET_64BIT"
4996   "*
4998   if (GET_CODE (operands[2]) == CONST_INT)
4999     {
5000       if (INTVAL (operands[2]) >= 0)
5001         return \"addi %2,%R1,%R0\;{addco|add,c,tsv} %1,%%r0,%0\";
5002       else
5003         return \"addi %2,%R1,%R0\;{subbo|sub,b,tsv} %1,%%r0,%0\";
5004     }
5005   else
5006     return \"add %R2,%R1,%R0\;{addco|add,c,tsv} %2,%1,%0\";
5008   [(set_attr "type" "binary")
5009    (set_attr "length" "8")])
5011 ;; define_splits to optimize cases of adding a constant integer
5012 ;; to a register when the constant does not fit in 14 bits.  */
5013 (define_split
5014   [(set (match_operand:SI 0 "register_operand" "")
5015         (plus:SI (match_operand:SI 1 "register_operand" "")
5016                  (match_operand:SI 2 "const_int_operand" "")))
5017    (clobber (match_operand:SI 4 "register_operand" ""))]
5018   "! pa_cint_ok_for_move (UINTVAL (operands[2]))
5019    && VAL_14_BITS_P (INTVAL (operands[2]) >> 1)"
5020   [(set (match_dup 4) (plus:SI (match_dup 1) (match_dup 2)))
5021    (set (match_dup 0) (plus:SI (match_dup 4) (match_dup 3)))]
5022   "
5024   int val = INTVAL (operands[2]);
5025   int low = (val < 0) ? -0x2000 : 0x1fff;
5026   int rest = val - low;
5028   operands[2] = GEN_INT (rest);
5029   operands[3] = GEN_INT (low);
5032 (define_split
5033   [(set (match_operand:SI 0 "register_operand" "")
5034         (plus:SI (match_operand:SI 1 "register_operand" "")
5035                  (match_operand:SI 2 "const_int_operand" "")))
5036    (clobber (match_operand:SI 4 "register_operand" ""))]
5037   "! pa_cint_ok_for_move (UINTVAL (operands[2]))"
5038   [(set (match_dup 4) (match_dup 2))
5039    (set (match_dup 0) (plus:SI (ashift:SI (match_dup 4) (match_dup 3))
5040                                (match_dup 1)))]
5041   "
5043   unsigned HOST_WIDE_INT intval = UINTVAL (operands[2]);
5045   /* Try dividing the constant by 2, then 4, and finally 8 to see
5046      if we can get a constant which can be loaded into a register
5047      in a single instruction (pa_cint_ok_for_move). 
5049      If that fails, try to negate the constant and subtract it
5050      from our input operand.  */
5051   if (intval % 2 == 0 && pa_cint_ok_for_move (intval / 2))
5052     {
5053       operands[2] = GEN_INT (intval / 2);
5054       operands[3] = const1_rtx;
5055     }
5056   else if (intval % 4 == 0 && pa_cint_ok_for_move (intval / 4))
5057     {
5058       operands[2] = GEN_INT (intval / 4);
5059       operands[3] = const2_rtx;
5060     }
5061   else if (intval % 8 == 0 && pa_cint_ok_for_move (intval / 8))
5062     {
5063       operands[2] = GEN_INT (intval / 8);
5064       operands[3] = GEN_INT (3);
5065     }
5066   else if (pa_cint_ok_for_move (-intval))
5067     {
5068       emit_insn (gen_rtx_SET (operands[4], GEN_INT (-intval)));
5069       emit_insn (gen_subsi3 (operands[0], operands[1], operands[4]));
5070       DONE;
5071     }
5072   else
5073     FAIL;
5076 (define_insn "addsi3"
5077   [(set (match_operand:SI 0 "register_operand" "=r,r")
5078         (plus:SI (match_operand:SI 1 "register_operand" "%r,r")
5079                  (match_operand:SI 2 "arith14_operand" "r,J")))]
5080   ""
5081   "@
5082    {addl|add,l} %1,%2,%0
5083    ldo %2(%1),%0"
5084   [(set_attr "type" "binary,binary")
5085    (set_attr "pa_combine_type" "addmove")
5086    (set_attr "length" "4,4")])
5088 (define_insn "addvsi3"
5089   [(set (match_operand:SI 0 "register_operand" "=r,r")
5090         (plus:SI (match_operand:SI 1 "reg_or_0_operand" "%rM,rM")
5091                  (match_operand:SI 2 "arith11_operand" "r,I")))
5092    (trap_if (ne (plus:DI (sign_extend:DI (match_dup 1))
5093                          (sign_extend:DI (match_dup 2)))
5094                 (sign_extend:DI (plus:SI (match_dup 1)
5095                                          (match_dup 2))))
5096             (const_int 0))]
5097   ""
5098   "@
5099   {addo|add,tsv} %2,%1,%0
5100   {addio|addi,tsv} %2,%1,%0"
5101   [(set_attr "type" "binary,binary")
5102    (set_attr "length" "4,4")])
5104 (define_expand "subdi3"
5105   [(set (match_operand:DI 0 "register_operand" "")
5106         (minus:DI (match_operand:DI 1 "arith11_operand" "")
5107                   (match_operand:DI 2 "reg_or_0_operand" "")))]
5108   ""
5109   "")
5111 (define_insn ""
5112   [(set (match_operand:DI 0 "register_operand" "=r,r,!q")
5113         (minus:DI (match_operand:DI 1 "arith11_operand" "r,I,!U")
5114                   (match_operand:DI 2 "reg_or_0_operand" "rM,rM,!rM")))]
5115   "TARGET_64BIT"
5116   "@
5117    sub %1,%2,%0
5118    subi %1,%2,%0
5119    mtsarcm %2"
5120   [(set_attr "type" "binary,binary,move")
5121   (set_attr "length" "4,4,4")])
5123 (define_insn ""
5124   [(set (match_operand:DI 0 "register_operand" "=r,&r")
5125         (minus:DI (match_operand:DI 1 "arith11_operand" "r,I")
5126                   (match_operand:DI 2 "reg_or_0_operand" "rM,rM")))]
5127   "!TARGET_64BIT"
5128   "*
5130   if (GET_CODE (operands[1]) == CONST_INT)
5131     {
5132       if (INTVAL (operands[1]) >= 0)
5133         return \"subi %1,%R2,%R0\;{subb|sub,b} %%r0,%2,%0\";
5134       else
5135         return \"ldi -1,%0\;subi %1,%R2,%R0\;{subb|sub,b} %0,%2,%0\";
5136     }
5137   else
5138     return \"sub %R1,%R2,%R0\;{subb|sub,b} %1,%2,%0\";
5140   [(set_attr "type" "binary")
5141    (set (attr "length")
5142         (if_then_else (eq_attr "alternative" "0")
5143           (const_int 8)
5144           (if_then_else (ge (symbol_ref "INTVAL (operands[1])")
5145                             (const_int 0))
5146             (const_int 8)
5147             (const_int 12))))])
5149 (define_expand "subvdi3"
5150   [(parallel [(set (match_operand:DI 0 "register_operand" "")
5151                    (minus:DI (match_operand:DI 1 "arith11_operand" "")
5152                              (match_operand:DI 2 "reg_or_0_operand" "")))
5153               (trap_if (ne (minus:TI (sign_extend:TI (match_dup 1))
5154                                      (sign_extend:TI (match_dup 2)))
5155                            (sign_extend:TI (minus:DI (match_dup 1)
5156                                                      (match_dup 2))))
5157                        (const_int 0))])]
5158   ""
5159   "")
5161 (define_insn ""
5162   [(set (match_operand:DI 0 "register_operand" "=r,r")
5163         (minus:DI (match_operand:DI 1 "arith11_operand" "r,I")
5164                   (match_operand:DI 2 "reg_or_0_operand" "rM,rM")))
5165    (trap_if (ne (minus:TI (sign_extend:TI (match_dup 1))
5166                           (sign_extend:TI (match_dup 2)))
5167                 (sign_extend:TI (minus:DI (match_dup 1)
5168                                           (match_dup 2))))
5169             (const_int 0))]
5170   "TARGET_64BIT"
5171   "@
5172   {subo|sub,tsv} %1,%2,%0
5173   {subio|subi,tsv} %1,%2,%0"
5174   [(set_attr "type" "binary,binary")
5175    (set_attr "length" "4,4")])
5177 (define_insn ""
5178   [(set (match_operand:DI 0 "register_operand" "=r,&r")
5179         (minus:DI (match_operand:DI 1 "arith11_operand" "r,I")
5180                   (match_operand:DI 2 "reg_or_0_operand" "rM,rM")))
5181    (trap_if (ne (minus:TI (sign_extend:TI (match_dup 1))
5182                           (sign_extend:TI (match_dup 2)))
5183                 (sign_extend:TI (minus:DI (match_dup 1)
5184                                           (match_dup 2))))
5185             (const_int 0))]
5186   "!TARGET_64BIT"
5187   "*
5189   if (GET_CODE (operands[1]) == CONST_INT)
5190     {
5191       if (INTVAL (operands[1]) >= 0)
5192         return \"subi %1,%R2,%R0\;{subbo|sub,b,tsv} %%r0,%2,%0\";
5193       else
5194         return \"ldi -1,%0\;subi %1,%R2,%R0\;{subbo|sub,b,tsv} %0,%2,%0\";
5195     }
5196   else
5197     return \"sub %R1,%R2,%R0\;{subbo|sub,b,tsv} %1,%2,%0\";
5199   [(set_attr "type" "binary,binary")
5200    (set (attr "length")
5201         (if_then_else (eq_attr "alternative" "0")
5202           (const_int 8)
5203           (if_then_else (ge (symbol_ref "INTVAL (operands[1])")
5204                             (const_int 0))
5205             (const_int 8)
5206             (const_int 12))))])
5208 (define_expand "subsi3"
5209   [(set (match_operand:SI 0 "register_operand" "")
5210         (minus:SI (match_operand:SI 1 "arith11_operand" "")
5211                   (match_operand:SI 2 "register_operand" "")))]
5212   ""
5213   "")
5215 (define_insn ""
5216   [(set (match_operand:SI 0 "register_operand" "=r,r")
5217         (minus:SI (match_operand:SI 1 "arith11_operand" "r,I")
5218                   (match_operand:SI 2 "register_operand" "r,r")))]
5219   "!TARGET_PA_20"
5220   "@
5221    sub %1,%2,%0
5222    subi %1,%2,%0"
5223   [(set_attr "type" "binary,binary")
5224    (set_attr "length" "4,4")])
5226 (define_insn ""
5227   [(set (match_operand:SI 0 "register_operand" "=r,r,!q")
5228         (minus:SI (match_operand:SI 1 "arith11_operand" "r,I,!S")
5229                   (match_operand:SI 2 "register_operand" "r,r,!r")))]
5230   "TARGET_PA_20"
5231   "@
5232    sub %1,%2,%0
5233    subi %1,%2,%0
5234    mtsarcm %2"
5235   [(set_attr "type" "binary,binary,move")
5236    (set_attr "length" "4,4,4")])
5238 (define_insn "subvsi3"
5239   [(set (match_operand:SI 0 "register_operand" "=r,r")
5240         (minus:SI (match_operand:SI 1 "arith11_operand" "rM,I")
5241                   (match_operand:SI 2 "reg_or_0_operand" "rM,rM")))
5242    (trap_if (ne (minus:DI (sign_extend:DI (match_dup 1))
5243                           (sign_extend:DI (match_dup 2)))
5244                 (sign_extend:DI (minus:SI (match_dup 1)
5245                                           (match_dup 2))))
5246             (const_int 0))]
5247   ""
5248   "@
5249   {subo|sub,tsv} %1,%2,%0
5250   {subio|subi,tsv} %1,%2,%0"
5251   [(set_attr "type" "binary,binary")
5252    (set_attr "length" "4,4")])
5254 ;; Trap instructions.
5256 (define_insn "trap"
5257   [(trap_if (const_int 1) (const_int 0))]
5258   ""
5259   "{addit|addi,tc},<> 1,%%r0,%%r0"
5260   [(set_attr "type" "trap")
5261    (set_attr "length" "4")])
5263 ;; Clobbering a "register_operand" instead of a match_scratch
5264 ;; in operand3 of millicode calls avoids spilling %r1 and
5265 ;; produces better code.
5267 ;; The mulsi3 insns set up registers for the millicode call.
5268 (define_expand "mulsi3"
5269   [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5270    (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5271    (parallel [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
5272               (clobber (match_dup 3))
5273               (clobber (reg:SI 26))
5274               (clobber (reg:SI 25))
5275               (clobber (match_dup 4))])
5276    (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5277   ""
5278   "
5280   operands[4] = gen_rtx_REG (SImode, TARGET_64BIT ? 2 : 31);
5281   if (TARGET_PA_11 && !TARGET_DISABLE_FPREGS && !TARGET_SOFT_FLOAT)
5282     {
5283       rtx scratch = gen_reg_rtx (DImode);
5284       operands[1] = force_reg (SImode, operands[1]);
5285       operands[2] = force_reg (SImode, operands[2]);
5286       emit_insn (gen_umulsidi3 (scratch, operands[1], operands[2]));
5287       emit_insn (gen_movsi (operands[0],
5288                             gen_rtx_SUBREG (SImode, scratch,
5289                                             GET_MODE_SIZE (SImode))));
5290       DONE;
5291     }
5292   operands[3] = gen_reg_rtx (SImode);
5295 (define_insn "umulsidi3"
5296   [(set (match_operand:DI 0 "register_operand" "=f")
5297         (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "f"))
5298                  (zero_extend:DI (match_operand:SI 2 "nonimmediate_operand" "f"))))]
5299   "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT"
5300   "xmpyu %1,%2,%0"
5301   [(set_attr "type" "fpmuldbl")
5302    (set_attr "length" "4")])
5304 (define_insn ""
5305   [(set (match_operand:DI 0 "register_operand" "=f")
5306         (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "f"))
5307                  (match_operand:DI 2 "uint32_operand" "f")))]
5308   "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT && !TARGET_64BIT"
5309   "xmpyu %1,%R2,%0"
5310   [(set_attr "type" "fpmuldbl")
5311    (set_attr "length" "4")])
5313 (define_insn ""
5314   [(set (match_operand:DI 0 "register_operand" "=f")
5315         (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "f"))
5316                  (match_operand:DI 2 "uint32_operand" "f")))]
5317   "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT && TARGET_64BIT"
5318   "xmpyu %1,%2R,%0"
5319   [(set_attr "type" "fpmuldbl")
5320    (set_attr "length" "4")])
5322 (define_insn ""
5323   [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
5324    (clobber (match_operand:SI 0 "register_operand" "=a"))
5325    (clobber (reg:SI 26))
5326    (clobber (reg:SI 25))
5327    (clobber (reg:SI 31))]
5328   "!TARGET_64BIT"
5329   "* return pa_output_mul_insn (0, insn);"
5330   [(set_attr "type" "milli")
5331    (set (attr "length")
5332         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5333               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5335 (define_insn ""
5336   [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
5337    (clobber (match_operand:SI 0 "register_operand" "=a"))
5338    (clobber (reg:SI 26))
5339    (clobber (reg:SI 25))
5340    (clobber (reg:SI 2))]
5341   "TARGET_64BIT"
5342   "* return pa_output_mul_insn (0, insn);"
5343   [(set_attr "type" "milli")
5344    (set (attr "length")
5345         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5346               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5348 (define_expand "muldi3"
5349   [(set (match_operand:DI 0 "register_operand" "")
5350         (mult:DI (match_operand:DI 1 "register_operand" "")
5351                  (match_operand:DI 2 "register_operand" "")))]
5352   "TARGET_64BIT && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT"
5353   "
5355   rtx low_product = gen_reg_rtx (DImode);
5356   rtx cross_product1 = gen_reg_rtx (DImode);
5357   rtx cross_product2 = gen_reg_rtx (DImode);
5358   rtx cross_scratch = gen_reg_rtx (DImode);
5359   rtx cross_product = gen_reg_rtx (DImode);
5360   rtx op1l, op1r, op2l, op2r;
5361   rtx op1shifted, op2shifted;
5363   op1shifted = gen_reg_rtx (DImode);
5364   op2shifted = gen_reg_rtx (DImode);
5365   op1l = gen_reg_rtx (SImode);
5366   op1r = gen_reg_rtx (SImode);
5367   op2l = gen_reg_rtx (SImode);
5368   op2r = gen_reg_rtx (SImode);
5370   emit_move_insn (op1shifted, gen_rtx_LSHIFTRT (DImode, operands[1],
5371                                                 GEN_INT (32)));
5372   emit_move_insn (op2shifted, gen_rtx_LSHIFTRT (DImode, operands[2],
5373                                                 GEN_INT (32)));
5374   op1r = force_reg (SImode, gen_rtx_SUBREG (SImode, operands[1], 4));
5375   op2r = force_reg (SImode, gen_rtx_SUBREG (SImode, operands[2], 4));
5376   op1l = force_reg (SImode, gen_rtx_SUBREG (SImode, op1shifted, 4));
5377   op2l = force_reg (SImode, gen_rtx_SUBREG (SImode, op2shifted, 4));
5379   /* Emit multiplies for the cross products.  */
5380   emit_insn (gen_umulsidi3 (cross_product1, op2r, op1l));
5381   emit_insn (gen_umulsidi3 (cross_product2, op2l, op1r));
5383   /* Emit a multiply for the low sub-word.  */
5384   emit_insn (gen_umulsidi3 (low_product, copy_rtx (op2r), copy_rtx (op1r)));
5386   /* Sum the cross products and shift them into proper position.  */
5387   emit_insn (gen_adddi3 (cross_scratch, cross_product1, cross_product2));
5388   emit_insn (gen_ashldi3 (cross_product, cross_scratch, GEN_INT (32)));
5390   /* Add the cross product to the low product and store the result
5391      into the output operand .  */
5392   emit_insn (gen_adddi3 (operands[0], cross_product, low_product));
5393   DONE;
5396 ;;; Division and mod.
5397 (define_expand "divsi3"
5398   [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5399    (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5400    (parallel [(set (reg:SI 29) (div:SI (reg:SI 26) (reg:SI 25)))
5401               (clobber (match_dup 3))
5402               (clobber (match_dup 4))
5403               (clobber (reg:SI 26))
5404               (clobber (reg:SI 25))
5405               (clobber (match_dup 5))])
5406    (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5407   ""
5408   "
5410   operands[3] = gen_reg_rtx (SImode);
5411   if (TARGET_64BIT)
5412     {
5413       operands[5] = gen_rtx_REG (SImode, 2);
5414       operands[4] = operands[5];
5415     }
5416   else
5417     {
5418       operands[5] = gen_rtx_REG (SImode, 31);
5419       operands[4] = gen_reg_rtx (SImode);
5420     }
5421   if (GET_CODE (operands[2]) == CONST_INT && pa_emit_hpdiv_const (operands, 0))
5422     DONE;
5425 (define_insn ""
5426   [(set (reg:SI 29)
5427         (div:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5428    (clobber (match_operand:SI 1 "register_operand" "=a"))
5429    (clobber (match_operand:SI 2 "register_operand" "=&r"))
5430    (clobber (reg:SI 26))
5431    (clobber (reg:SI 25))
5432    (clobber (reg:SI 31))]
5433   "!TARGET_64BIT"
5434   "*
5435    return pa_output_div_insn (operands, 0, insn);"
5436   [(set_attr "type" "milli")
5437    (set (attr "length")
5438         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5439               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5441 (define_insn ""
5442   [(set (reg:SI 29)
5443         (div:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5444    (clobber (match_operand:SI 1 "register_operand" "=a"))
5445    (clobber (match_operand:SI 2 "register_operand" "=&r"))
5446    (clobber (reg:SI 26))
5447    (clobber (reg:SI 25))
5448    (clobber (reg:SI 2))]
5449   "TARGET_64BIT"
5450   "*
5451    return pa_output_div_insn (operands, 0, insn);"
5452   [(set_attr "type" "milli")
5453    (set (attr "length")
5454         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5455               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5457 (define_expand "udivsi3"
5458   [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5459    (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5460    (parallel [(set (reg:SI 29) (udiv:SI (reg:SI 26) (reg:SI 25)))
5461               (clobber (match_dup 3))
5462               (clobber (match_dup 4))
5463               (clobber (reg:SI 26))
5464               (clobber (reg:SI 25))
5465               (clobber (match_dup 5))])
5466    (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5467   ""
5468   "
5470   operands[3] = gen_reg_rtx (SImode);
5472   if (TARGET_64BIT)
5473     {
5474       operands[5] = gen_rtx_REG (SImode, 2);
5475       operands[4] = operands[5];
5476     }
5477   else
5478     {
5479       operands[5] = gen_rtx_REG (SImode, 31);
5480       operands[4] = gen_reg_rtx (SImode);
5481     }
5482   if (GET_CODE (operands[2]) == CONST_INT && pa_emit_hpdiv_const (operands, 1))
5483     DONE;
5486 (define_insn ""
5487   [(set (reg:SI 29)
5488         (udiv:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5489    (clobber (match_operand:SI 1 "register_operand" "=a"))
5490    (clobber (match_operand:SI 2 "register_operand" "=&r"))
5491    (clobber (reg:SI 26))
5492    (clobber (reg:SI 25))
5493    (clobber (reg:SI 31))]
5494   "!TARGET_64BIT"
5495   "*
5496    return pa_output_div_insn (operands, 1, insn);"
5497   [(set_attr "type" "milli")
5498    (set (attr "length")
5499         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5500               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5502 (define_insn ""
5503   [(set (reg:SI 29)
5504         (udiv:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5505    (clobber (match_operand:SI 1 "register_operand" "=a"))
5506    (clobber (match_operand:SI 2 "register_operand" "=&r"))
5507    (clobber (reg:SI 26))
5508    (clobber (reg:SI 25))
5509    (clobber (reg:SI 2))]
5510   "TARGET_64BIT"
5511   "*
5512    return pa_output_div_insn (operands, 1, insn);"
5513   [(set_attr "type" "milli")
5514    (set (attr "length")
5515         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5516               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5518 (define_expand "modsi3"
5519   [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5520    (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5521    (parallel [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
5522               (clobber (match_dup 3))
5523               (clobber (match_dup 4))
5524               (clobber (reg:SI 26))
5525               (clobber (reg:SI 25))
5526               (clobber (match_dup 5))])
5527    (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5528   ""
5529   "
5531   if (TARGET_64BIT)
5532     {
5533       operands[5] = gen_rtx_REG (SImode, 2);
5534       operands[4] = operands[5];
5535     }
5536   else
5537     {
5538       operands[5] = gen_rtx_REG (SImode, 31);
5539       operands[4] = gen_reg_rtx (SImode);
5540     }
5541   operands[3] = gen_reg_rtx (SImode);
5544 (define_insn ""
5545   [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
5546    (clobber (match_operand:SI 0 "register_operand" "=a"))
5547    (clobber (match_operand:SI 1 "register_operand" "=&r"))
5548    (clobber (reg:SI 26))
5549    (clobber (reg:SI 25))
5550    (clobber (reg:SI 31))]
5551   "!TARGET_64BIT"
5552   "*
5553   return pa_output_mod_insn (0, insn);"
5554   [(set_attr "type" "milli")
5555    (set (attr "length")
5556         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5557               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5559 (define_insn ""
5560   [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
5561    (clobber (match_operand:SI 0 "register_operand" "=a"))
5562    (clobber (match_operand:SI 1 "register_operand" "=&r"))
5563    (clobber (reg:SI 26))
5564    (clobber (reg:SI 25))
5565    (clobber (reg:SI 2))]
5566   "TARGET_64BIT"
5567   "*
5568   return pa_output_mod_insn (0, insn);"
5569   [(set_attr "type" "milli")
5570    (set (attr "length")
5571         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5572               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5574 (define_expand "umodsi3"
5575   [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5576    (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5577    (parallel [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
5578               (clobber (match_dup 3))
5579               (clobber (match_dup 4))
5580               (clobber (reg:SI 26))
5581               (clobber (reg:SI 25))
5582               (clobber (match_dup 5))])
5583    (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5584   ""
5585   "
5587   if (TARGET_64BIT)
5588     {
5589       operands[5] = gen_rtx_REG (SImode, 2);
5590       operands[4] = operands[5];
5591     }
5592   else
5593     {
5594       operands[5] = gen_rtx_REG (SImode, 31);
5595       operands[4] = gen_reg_rtx (SImode);
5596     }
5597   operands[3] = gen_reg_rtx (SImode);
5600 (define_insn ""
5601   [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
5602    (clobber (match_operand:SI 0 "register_operand" "=a"))
5603    (clobber (match_operand:SI 1 "register_operand" "=&r"))
5604    (clobber (reg:SI 26))
5605    (clobber (reg:SI 25))
5606    (clobber (reg:SI 31))]
5607   "!TARGET_64BIT"
5608   "*
5609   return pa_output_mod_insn (1, insn);"
5610   [(set_attr "type" "milli")
5611    (set (attr "length")
5612         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5613               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5615 (define_insn ""
5616   [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
5617    (clobber (match_operand:SI 0 "register_operand" "=a"))
5618    (clobber (match_operand:SI 1 "register_operand" "=&r"))
5619    (clobber (reg:SI 26))
5620    (clobber (reg:SI 25))
5621    (clobber (reg:SI 2))]
5622   "TARGET_64BIT"
5623   "*
5624   return pa_output_mod_insn (1, insn);"
5625   [(set_attr "type" "milli")
5626    (set (attr "length")
5627         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5628               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5630 ;;- and instructions
5631 ;; We define DImode `and` so with DImode `not` we can get
5632 ;; DImode `andn`.  Other combinations are possible.
5634 (define_expand "anddi3"
5635   [(set (match_operand:DI 0 "register_operand" "")
5636         (and:DI (match_operand:DI 1 "register_operand" "")
5637                 (match_operand:DI 2 "and_operand" "")))]
5638   "TARGET_64BIT"
5639   "")
5641 (define_insn ""
5642   [(set (match_operand:DI 0 "register_operand" "=r,r")
5643         (and:DI (match_operand:DI 1 "register_operand" "%?r,0")
5644                 (match_operand:DI 2 "and_operand" "rO,P")))]
5645   "TARGET_64BIT"
5646   "* return pa_output_64bit_and (operands); "
5647   [(set_attr "type" "binary")
5648    (set_attr "length" "4")])
5650 ; The ? for op1 makes reload prefer zdepi instead of loading a huge
5651 ; constant with ldil;ldo.
5652 (define_insn "andsi3"
5653   [(set (match_operand:SI 0 "register_operand" "=r,r")
5654         (and:SI (match_operand:SI 1 "register_operand" "%?r,0")
5655                 (match_operand:SI 2 "and_operand" "rO,P")))]
5656   ""
5657   "* return pa_output_and (operands); "
5658   [(set_attr "type" "binary,shift")
5659    (set_attr "length" "4,4")])
5661 (define_insn ""
5662   [(set (match_operand:DI 0 "register_operand" "=r")
5663         (and:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
5664                 (match_operand:DI 2 "register_operand" "r")))]
5665   "TARGET_64BIT"
5666   "andcm %2,%1,%0"
5667   [(set_attr "type" "binary")
5668    (set_attr "length" "4")])
5670 (define_insn ""
5671   [(set (match_operand:SI 0 "register_operand" "=r")
5672         (and:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
5673                 (match_operand:SI 2 "register_operand" "r")))]
5674   ""
5675   "andcm %2,%1,%0"
5676   [(set_attr "type" "binary")
5677   (set_attr "length" "4")])
5679 (define_expand "iordi3"
5680   [(set (match_operand:DI 0 "register_operand" "")
5681         (ior:DI (match_operand:DI 1 "register_operand" "")
5682                 (match_operand:DI 2 "reg_or_cint_ior_operand" "")))]
5683   "TARGET_64BIT"
5684   "")
5686 (define_insn ""
5687   [(set (match_operand:DI 0 "register_operand" "=r,r")
5688         (ior:DI (match_operand:DI 1 "register_operand" "0,0")
5689                 (match_operand:DI 2 "cint_ior_operand" "M,i")))]
5690   "TARGET_64BIT"
5691   "* return pa_output_64bit_ior (operands); "
5692   [(set_attr "type" "binary,shift")
5693    (set_attr "length" "4,4")])
5695 (define_insn ""
5696   [(set (match_operand:DI 0 "register_operand" "=r")
5697         (ior:DI (match_operand:DI 1 "register_operand" "%r")
5698                 (match_operand:DI 2 "register_operand" "r")))]
5699   "TARGET_64BIT"
5700   "or %1,%2,%0"
5701   [(set_attr "type" "binary")
5702    (set_attr "length" "4")])
5704 ;; Need a define_expand because we've run out of CONST_OK... characters.
5705 (define_expand "iorsi3"
5706   [(set (match_operand:SI 0 "register_operand" "")
5707         (ior:SI (match_operand:SI 1 "register_operand" "")
5708                 (match_operand:SI 2 "reg_or_cint_ior_operand" "")))]
5709   ""
5710   "")
5712 (define_insn ""
5713   [(set (match_operand:SI 0 "register_operand" "=r,r")
5714         (ior:SI (match_operand:SI 1 "register_operand" "0,0")
5715                 (match_operand:SI 2 "cint_ior_operand" "M,i")))]
5716   ""
5717   "* return pa_output_ior (operands); "
5718   [(set_attr "type" "binary,shift")
5719    (set_attr "length" "4,4")])
5721 (define_insn ""
5722   [(set (match_operand:SI 0 "register_operand" "=r")
5723         (ior:SI (match_operand:SI 1 "register_operand" "%r")
5724                 (match_operand:SI 2 "register_operand" "r")))]
5725   ""
5726   "or %1,%2,%0"
5727   [(set_attr "type" "binary")
5728    (set_attr "length" "4")])
5730 (define_expand "xordi3"
5731   [(set (match_operand:DI 0 "register_operand" "")
5732         (xor:DI (match_operand:DI 1 "register_operand" "")
5733                 (match_operand:DI 2 "register_operand" "")))]
5734   "TARGET_64BIT"
5735   "")
5737 (define_insn ""
5738   [(set (match_operand:DI 0 "register_operand" "=r")
5739         (xor:DI (match_operand:DI 1 "register_operand" "%r")
5740                 (match_operand:DI 2 "register_operand" "r")))]
5741   "TARGET_64BIT"
5742   "xor %1,%2,%0"
5743   [(set_attr "type" "binary")
5744    (set_attr "length" "4")])
5746 (define_insn "xorsi3"
5747   [(set (match_operand:SI 0 "register_operand" "=r")
5748         (xor:SI (match_operand:SI 1 "register_operand" "%r")
5749                 (match_operand:SI 2 "register_operand" "r")))]
5750   ""
5751   "xor %1,%2,%0"
5752   [(set_attr "type" "binary")
5753    (set_attr "length" "4")])
5755 (define_expand "negdi2"
5756   [(set (match_operand:DI 0 "register_operand" "")
5757         (neg:DI (match_operand:DI 1 "register_operand" "")))]
5758   ""
5759   "")
5761 (define_insn ""
5762   [(set (match_operand:DI 0 "register_operand" "=r")
5763         (neg:DI (match_operand:DI 1 "register_operand" "r")))]
5764   "!TARGET_64BIT"
5765   "sub %%r0,%R1,%R0\;{subb|sub,b} %%r0,%1,%0"
5766   [(set_attr "type" "unary")
5767    (set_attr "length" "8")])
5769 (define_insn ""
5770   [(set (match_operand:DI 0 "register_operand" "=r")
5771         (neg:DI (match_operand:DI 1 "register_operand" "r")))]
5772   "TARGET_64BIT"
5773   "sub %%r0,%1,%0"
5774   [(set_attr "type" "unary")
5775    (set_attr "length" "4")])
5777 (define_expand "negvdi2"
5778   [(parallel [(set (match_operand:DI 0 "register_operand" "")
5779                    (neg:DI (match_operand:DI 1 "register_operand" "")))
5780               (trap_if (ne (neg:TI (sign_extend:TI (match_dup 1)))
5781                                    (sign_extend:TI (neg:DI (match_dup 1))))
5782                        (const_int 0))])]
5783   ""
5784   "")
5786 (define_insn ""
5787   [(set (match_operand:DI 0 "register_operand" "=r")
5788         (neg:DI (match_operand:DI 1 "register_operand" "r")))
5789    (trap_if (ne (neg:TI (sign_extend:TI (match_dup 1)))
5790                 (sign_extend:TI (neg:DI (match_dup 1))))
5791             (const_int 0))]
5792   "!TARGET_64BIT"
5793   "sub %%r0,%R1,%R0\;{subbo|sub,b,tsv} %%r0,%1,%0"
5794   [(set_attr "type" "unary")
5795    (set_attr "length" "8")])
5797 (define_insn ""
5798   [(set (match_operand:DI 0 "register_operand" "=r")
5799         (neg:DI (match_operand:DI 1 "register_operand" "r")))
5800    (trap_if (ne (neg:TI (sign_extend:TI (match_dup 1)))
5801                 (sign_extend:TI (neg:DI (match_dup 1))))
5802             (const_int 0))]
5803   "TARGET_64BIT"
5804   "sub,tsv %%r0,%1,%0"
5805   [(set_attr "type" "unary")
5806    (set_attr "length" "4")])
5808 (define_insn "negsi2"
5809   [(set (match_operand:SI 0 "register_operand" "=r")
5810         (neg:SI (match_operand:SI 1 "register_operand" "r")))]
5811   ""
5812   "sub %%r0,%1,%0"
5813   [(set_attr "type" "unary")
5814    (set_attr "length" "4")])
5816 (define_insn "negvsi2"
5817   [(set (match_operand:SI 0 "register_operand" "=r")
5818         (neg:SI (match_operand:SI 1 "register_operand" "r")))
5819    (trap_if (ne (neg:DI (sign_extend:DI (match_dup 1)))
5820                 (sign_extend:DI (neg:SI (match_dup 1))))
5821             (const_int 0))]
5822    ""
5823    "{subo|sub,tsv} %%r0,%1,%0"
5824   [(set_attr "type" "unary")
5825    (set_attr "length" "4")])
5827 (define_expand "one_cmpldi2"
5828   [(set (match_operand:DI 0 "register_operand" "")
5829         (not:DI (match_operand:DI 1 "register_operand" "")))]
5830   ""
5831   "
5835 (define_insn ""
5836   [(set (match_operand:DI 0 "register_operand" "=r")
5837         (not:DI (match_operand:DI 1 "register_operand" "r")))]
5838   "!TARGET_64BIT"
5839   "uaddcm %%r0,%1,%0\;uaddcm %%r0,%R1,%R0"
5840   [(set_attr "type" "unary")
5841    (set_attr "length" "8")])
5843 (define_insn ""
5844   [(set (match_operand:DI 0 "register_operand" "=r")
5845         (not:DI (match_operand:DI 1 "register_operand" "r")))]
5846   "TARGET_64BIT"
5847   "uaddcm %%r0,%1,%0"
5848   [(set_attr "type" "unary")
5849    (set_attr "length" "4")])
5851 (define_insn "one_cmplsi2"
5852   [(set (match_operand:SI 0 "register_operand" "=r")
5853         (not:SI (match_operand:SI 1 "register_operand" "r")))]
5854   ""
5855   "uaddcm %%r0,%1,%0"
5856   [(set_attr "type" "unary")
5857    (set_attr "length" "4")])
5859 ;; Floating point arithmetic instructions.
5861 (define_insn "adddf3"
5862   [(set (match_operand:DF 0 "register_operand" "=f")
5863         (plus:DF (match_operand:DF 1 "register_operand" "f")
5864                  (match_operand:DF 2 "register_operand" "f")))]
5865   "! TARGET_SOFT_FLOAT"
5866   "fadd,dbl %1,%2,%0"
5867   [(set_attr "type" "fpalu")
5868    (set_attr "pa_combine_type" "faddsub")
5869    (set_attr "length" "4")])
5871 (define_insn "addsf3"
5872   [(set (match_operand:SF 0 "register_operand" "=f")
5873         (plus:SF (match_operand:SF 1 "register_operand" "f")
5874                  (match_operand:SF 2 "register_operand" "f")))]
5875   "! TARGET_SOFT_FLOAT"
5876   "fadd,sgl %1,%2,%0"
5877   [(set_attr "type" "fpalu")
5878    (set_attr "pa_combine_type" "faddsub")
5879    (set_attr "length" "4")])
5881 (define_insn "subdf3"
5882   [(set (match_operand:DF 0 "register_operand" "=f")
5883         (minus:DF (match_operand:DF 1 "register_operand" "f")
5884                   (match_operand:DF 2 "register_operand" "f")))]
5885   "! TARGET_SOFT_FLOAT"
5886   "fsub,dbl %1,%2,%0"
5887   [(set_attr "type" "fpalu")
5888    (set_attr "pa_combine_type" "faddsub")
5889    (set_attr "length" "4")])
5891 (define_insn "subsf3"
5892   [(set (match_operand:SF 0 "register_operand" "=f")
5893         (minus:SF (match_operand:SF 1 "register_operand" "f")
5894                   (match_operand:SF 2 "register_operand" "f")))]
5895   "! TARGET_SOFT_FLOAT"
5896   "fsub,sgl %1,%2,%0"
5897   [(set_attr "type" "fpalu")
5898    (set_attr "pa_combine_type" "faddsub")
5899    (set_attr "length" "4")])
5901 (define_insn "muldf3"
5902   [(set (match_operand:DF 0 "register_operand" "=f")
5903         (mult:DF (match_operand:DF 1 "register_operand" "f")
5904                  (match_operand:DF 2 "register_operand" "f")))]
5905   "! TARGET_SOFT_FLOAT"
5906   "fmpy,dbl %1,%2,%0"
5907   [(set_attr "type" "fpmuldbl")
5908    (set_attr "pa_combine_type" "fmpy")
5909    (set_attr "length" "4")])
5911 (define_insn "mulsf3"
5912   [(set (match_operand:SF 0 "register_operand" "=f")
5913         (mult:SF (match_operand:SF 1 "register_operand" "f")
5914                  (match_operand:SF 2 "register_operand" "f")))]
5915   "! TARGET_SOFT_FLOAT"
5916   "fmpy,sgl %1,%2,%0"
5917   [(set_attr "type" "fpmulsgl")
5918    (set_attr "pa_combine_type" "fmpy")
5919    (set_attr "length" "4")])
5921 (define_insn "divdf3"
5922   [(set (match_operand:DF 0 "register_operand" "=f")
5923         (div:DF (match_operand:DF 1 "register_operand" "f")
5924                 (match_operand:DF 2 "register_operand" "f")))]
5925   "! TARGET_SOFT_FLOAT"
5926   "fdiv,dbl %1,%2,%0"
5927   [(set_attr "type" "fpdivdbl")
5928    (set_attr "length" "4")])
5930 (define_insn "divsf3"
5931   [(set (match_operand:SF 0 "register_operand" "=f")
5932         (div:SF (match_operand:SF 1 "register_operand" "f")
5933                 (match_operand:SF 2 "register_operand" "f")))]
5934   "! TARGET_SOFT_FLOAT"
5935   "fdiv,sgl %1,%2,%0"
5936   [(set_attr "type" "fpdivsgl")
5937    (set_attr "length" "4")])
5939 ;; Processors prior to PA 2.0 don't have a fneg instruction.  Fast
5940 ;; negation can be done by subtracting from plus zero.  However, this
5941 ;; violates the IEEE standard when negating plus and minus zero.
5942 ;; The slow path toggles the sign bit in the general registers.
5943 (define_expand "negdf2"
5944   [(set (match_operand:DF 0 "register_operand" "")
5945         (neg:DF (match_operand:DF 1 "register_operand" "")))]
5946   "!TARGET_SOFT_FLOAT"
5948   if (TARGET_PA_20 || !flag_signed_zeros)
5949     emit_insn (gen_negdf2_fast (operands[0], operands[1]));
5950   else
5951     emit_insn (gen_negdf2_slow (operands[0], operands[1]));
5952   DONE;
5955 (define_insn "negdf2_slow"
5956   [(set (match_operand:DF 0 "register_operand" "=r")
5957         (neg:DF (match_operand:DF 1 "register_operand" "r")))]
5958   "!TARGET_SOFT_FLOAT && !TARGET_PA_20"
5959   "*
5961   if (rtx_equal_p (operands[0], operands[1]))
5962     return \"and,< %1,%1,%0\;depi,tr 1,0,1,%0\;depi 0,0,1,%0\";
5963   else
5964     return \"and,< %1,%1,%0\;depi,tr 1,0,1,%0\;depi 0,0,1,%0\;copy %R1,%R0\";
5966   [(set_attr "type" "multi")
5967    (set (attr "length")
5968         (if_then_else (match_test "rtx_equal_p (operands[0], operands[1])")
5969             (const_int 12)
5970             (const_int 16)))])
5972 (define_insn "negdf2_fast"
5973   [(set (match_operand:DF 0 "register_operand" "=f")
5974         (neg:DF (match_operand:DF 1 "register_operand" "f")))]
5975   "!TARGET_SOFT_FLOAT"
5976   "*
5978   if (TARGET_PA_20)
5979     return \"fneg,dbl %1,%0\";
5980   else
5981     return \"fsub,dbl %%fr0,%1,%0\";
5983   [(set_attr "type" "fpalu")
5984    (set_attr "length" "4")])
5986 (define_expand "negsf2"
5987   [(set (match_operand:SF 0 "register_operand" "")
5988         (neg:SF (match_operand:SF 1 "register_operand" "")))]
5989   "!TARGET_SOFT_FLOAT"
5991   if (TARGET_PA_20 || !flag_signed_zeros)
5992     emit_insn (gen_negsf2_fast (operands[0], operands[1]));
5993   else
5994     emit_insn (gen_negsf2_slow (operands[0], operands[1]));
5995   DONE;
5998 (define_insn "negsf2_slow"
5999   [(set (match_operand:SF 0 "register_operand" "=r")
6000         (neg:SF (match_operand:SF 1 "register_operand" "r")))]
6001   "!TARGET_SOFT_FLOAT && !TARGET_PA_20"
6002   "and,< %1,%1,%0\;depi,tr 1,0,1,%0\;depi 0,0,1,%0"
6003   [(set_attr "type" "multi")
6004    (set_attr "length" "12")])
6006 (define_insn "negsf2_fast"
6007   [(set (match_operand:SF 0 "register_operand" "=f")
6008         (neg:SF (match_operand:SF 1 "register_operand" "f")))]
6009   "!TARGET_SOFT_FLOAT"
6010   "*
6012   if (TARGET_PA_20)
6013     return \"fneg,sgl %1,%0\";
6014   else
6015     return \"fsub,sgl %%fr0,%1,%0\";
6017   [(set_attr "type" "fpalu")
6018    (set_attr "length" "4")])
6020 (define_insn "absdf2"
6021   [(set (match_operand:DF 0 "register_operand" "=f")
6022         (abs:DF (match_operand:DF 1 "register_operand" "f")))]
6023   "! TARGET_SOFT_FLOAT"
6024   "fabs,dbl %1,%0"
6025   [(set_attr "type" "fpalu")
6026    (set_attr "length" "4")])
6028 (define_insn "abssf2"
6029   [(set (match_operand:SF 0 "register_operand" "=f")
6030         (abs:SF (match_operand:SF 1 "register_operand" "f")))]
6031   "! TARGET_SOFT_FLOAT"
6032   "fabs,sgl %1,%0"
6033   [(set_attr "type" "fpalu")
6034    (set_attr "length" "4")])
6036 (define_insn "sqrtdf2"
6037   [(set (match_operand:DF 0 "register_operand" "=f")
6038         (sqrt:DF (match_operand:DF 1 "register_operand" "f")))]
6039   "! TARGET_SOFT_FLOAT"
6040   "fsqrt,dbl %1,%0"
6041   [(set_attr "type" "fpsqrtdbl")
6042    (set_attr "length" "4")])
6044 (define_insn "sqrtsf2"
6045   [(set (match_operand:SF 0 "register_operand" "=f")
6046         (sqrt:SF (match_operand:SF 1 "register_operand" "f")))]
6047   "! TARGET_SOFT_FLOAT"
6048   "fsqrt,sgl %1,%0"
6049   [(set_attr "type" "fpsqrtsgl")
6050    (set_attr "length" "4")])
6052 ;; PA 2.0 floating point instructions
6054 ; fmpyfadd patterns
6055 (define_insn "fmadf4"
6056   [(set (match_operand:DF 0 "register_operand" "=f")
6057         (fma:DF (match_operand:DF 1 "register_operand" "f")
6058                 (match_operand:DF 2 "register_operand" "f")
6059                 (match_operand:DF 3 "register_operand" "f")))]
6060   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6061   "fmpyfadd,dbl %1,%2,%3,%0"
6062   [(set_attr "type" "fpmuldbl")
6063    (set_attr "length" "4")])
6065 (define_insn "fmasf4"
6066   [(set (match_operand:SF 0 "register_operand" "=f")
6067         (fma:SF (match_operand:SF 1 "register_operand" "f")
6068                 (match_operand:SF 2 "register_operand" "f")
6069                 (match_operand:SF 3 "register_operand" "f")))]
6070   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6071   "fmpyfadd,sgl %1,%2,%3,%0"
6072   [(set_attr "type" "fpmulsgl")
6073    (set_attr "length" "4")])
6075 ; fmpynfadd patterns
6076 (define_insn "fnmadf4"
6077   [(set (match_operand:DF 0 "register_operand" "=f")
6078         (fma:DF (neg:DF (match_operand:DF 1 "register_operand" "f"))
6079                 (match_operand:DF 2 "register_operand" "f")
6080                 (match_operand:DF 3 "register_operand" "f")))]
6081   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6082   "fmpynfadd,dbl %1,%2,%3,%0"
6083   [(set_attr "type" "fpmuldbl")
6084    (set_attr "length" "4")])
6086 (define_insn "fnmasf4"
6087   [(set (match_operand:SF 0 "register_operand" "=f")
6088         (fma:SF (neg:SF (match_operand:SF 1 "register_operand" "f"))
6089                 (match_operand:SF 2 "register_operand" "f")
6090                 (match_operand:SF 3 "register_operand" "f")))]
6091   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6092   "fmpynfadd,sgl %1,%2,%3,%0"
6093   [(set_attr "type" "fpmulsgl")
6094    (set_attr "length" "4")])
6096 ; fnegabs patterns
6097 (define_insn ""
6098   [(set (match_operand:DF 0 "register_operand" "=f")
6099         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))]
6100   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6101   "fnegabs,dbl %1,%0"
6102   [(set_attr "type" "fpalu")
6103    (set_attr "length" "4")])
6105 (define_insn ""
6106   [(set (match_operand:SF 0 "register_operand" "=f")
6107         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))]
6108   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6109   "fnegabs,sgl %1,%0"
6110   [(set_attr "type" "fpalu")
6111    (set_attr "length" "4")])
6113 (define_insn ""
6114   [(set (match_operand:DF 0 "register_operand" "=f")
6115         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))
6116    (set (match_operand:DF 2 "register_operand" "=&f") (abs:DF (match_dup 1)))]
6117   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6118     && ! reg_overlap_mentioned_p (operands[2], operands[1]))"
6119   "#"
6120   [(set_attr "type" "fpalu")
6121    (set_attr "length" "8")])
6123 (define_split
6124   [(set (match_operand:DF 0 "register_operand" "")
6125         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" ""))))
6126    (set (match_operand:DF 2 "register_operand" "") (abs:DF (match_dup 1)))]
6127   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6128   [(set (match_dup 2) (abs:DF (match_dup 1)))
6129    (set (match_dup 0) (neg:DF (abs:DF (match_dup 1))))]
6130   "")
6132 (define_insn ""
6133   [(set (match_operand:SF 0 "register_operand" "=f")
6134         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))
6135    (set (match_operand:SF 2 "register_operand" "=&f") (abs:SF (match_dup 1)))]
6136   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6137     && ! reg_overlap_mentioned_p (operands[2], operands[1]))"
6138   "#"
6139   [(set_attr "type" "fpalu")
6140    (set_attr "length" "8")])
6142 (define_split
6143   [(set (match_operand:SF 0 "register_operand" "")
6144         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" ""))))
6145    (set (match_operand:SF 2 "register_operand" "") (abs:SF (match_dup 1)))]
6146   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6147   [(set (match_dup 2) (abs:SF (match_dup 1)))
6148    (set (match_dup 0) (neg:SF (abs:SF (match_dup 1))))]
6149   "")
6151 ;; Negating a multiply can be faked by adding zero in a fused multiply-add
6152 ;; instruction if we can ignore the sign of zero.
6153 (define_insn ""
6154   [(set (match_operand:DF 0 "register_operand" "=f")
6155         (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
6156                          (match_operand:DF 2 "register_operand" "f"))))]
6157   "!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros"
6158   "fmpynfadd,dbl %1,%2,%%fr0,%0"
6159   [(set_attr "type" "fpmuldbl")
6160    (set_attr "length" "4")])
6162 (define_insn ""
6163   [(set (match_operand:SF 0 "register_operand" "=f")
6164         (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
6165                          (match_operand:SF 2 "register_operand" "f"))))]
6166   "!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros"
6167   "fmpynfadd,sgl %1,%2,%%fr0,%0"
6168   [(set_attr "type" "fpmuldbl")
6169    (set_attr "length" "4")])
6171 (define_insn ""
6172   [(set (match_operand:DF 0 "register_operand" "=f")
6173         (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
6174                          (match_operand:DF 2 "register_operand" "f"))))
6175    (set (match_operand:DF 3 "register_operand" "=&f")
6176         (mult:DF (match_dup 1) (match_dup 2)))]
6177   "(!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros
6178     && ! (reg_overlap_mentioned_p (operands[3], operands[1])
6179           || reg_overlap_mentioned_p (operands[3], operands[2])))"
6180   "#"
6181   [(set_attr "type" "fpmuldbl")
6182    (set_attr "length" "8")])
6184 (define_split
6185   [(set (match_operand:DF 0 "register_operand" "")
6186         (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "")
6187                          (match_operand:DF 2 "register_operand" ""))))
6188    (set (match_operand:DF 3 "register_operand" "")
6189         (mult:DF (match_dup 1) (match_dup 2)))]
6190   "!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros"
6191   [(set (match_dup 3) (mult:DF (match_dup 1) (match_dup 2)))
6192    (set (match_dup 0) (neg:DF (mult:DF (match_dup 1) (match_dup 2))))]
6193   "")
6195 (define_insn ""
6196   [(set (match_operand:SF 0 "register_operand" "=f")
6197         (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
6198                          (match_operand:SF 2 "register_operand" "f"))))
6199    (set (match_operand:SF 3 "register_operand" "=&f")
6200         (mult:SF (match_dup 1) (match_dup 2)))]
6201   "(!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros
6202     && ! (reg_overlap_mentioned_p (operands[3], operands[1])
6203           || reg_overlap_mentioned_p (operands[3], operands[2])))"
6204   "#"
6205   [(set_attr "type" "fpmuldbl")
6206    (set_attr "length" "8")])
6208 (define_split
6209   [(set (match_operand:SF 0 "register_operand" "")
6210         (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "")
6211                          (match_operand:SF 2 "register_operand" ""))))
6212    (set (match_operand:SF 3 "register_operand" "")
6213         (mult:SF (match_dup 1) (match_dup 2)))]
6214   "!TARGET_SOFT_FLOAT && TARGET_PA_20&& !flag_signed_zeros"
6215   [(set (match_dup 3) (mult:SF (match_dup 1) (match_dup 2)))
6216    (set (match_dup 0) (neg:SF (mult:SF (match_dup 1) (match_dup 2))))]
6217   "")
6219 ;;- Shift instructions
6221 ;; Optimized special case of shifting.
6223 (define_insn ""
6224   [(set (match_operand:SI 0 "register_operand" "=r")
6225         (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
6226                      (const_int 24)))]
6227   ""
6228   "ldb%M1 %1,%0"
6229   [(set_attr "type" "load")
6230    (set_attr "length" "4")])
6232 (define_insn ""
6233   [(set (match_operand:SI 0 "register_operand" "=r")
6234         (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
6235                      (const_int 16)))]
6236   ""
6237   "ldh%M1 %1,%0"
6238   [(set_attr "type" "load")
6239    (set_attr "length" "4")])
6241 (define_insn ""
6242   [(set (match_operand:SI 0 "register_operand" "=r")
6243         (plus:SI (ashift:SI (match_operand:SI 2 "register_operand" "r")
6244                             (match_operand:SI 3 "shadd_operand" ""))
6245                  (match_operand:SI 1 "register_operand" "r")))]
6246   ""
6247   "{sh%o3addl %2,%1,%0|shladd,l %2,%o3,%1,%0} "
6248   [(set_attr "type" "binary")
6249    (set_attr "length" "4")])
6251 (define_insn ""
6252   [(set (match_operand:SI 0 "register_operand" "=r")
6253         (plus:SI (mult:SI (match_operand:SI 2 "register_operand" "r")
6254                           (match_operand:SI 3 "mem_shadd_operand" ""))
6255                  (match_operand:SI 1 "register_operand" "r")))]
6256   ""
6257   "*
6259   int shift_val = exact_log2 (INTVAL (operands[3]));
6260   operands[3] = GEN_INT (shift_val);
6261   return \"{sh%o3addl %2,%1,%0|shladd,l %2,%o3,%1,%0}\";
6263   [(set_attr "type" "binary")
6264    (set_attr "length" "4")])
6266 (define_insn ""
6267   [(set (match_operand:DI 0 "register_operand" "=r")
6268         (plus:DI (ashift:DI (match_operand:DI 2 "register_operand" "r")
6269                             (match_operand:DI 3 "shadd_operand" ""))
6270                  (match_operand:DI 1 "register_operand" "r")))]
6271   "TARGET_64BIT"
6272   "shladd,l %2,%o3,%1,%0"
6273   [(set_attr "type" "binary")
6274    (set_attr "length" "4")])
6276 (define_insn ""
6277   [(set (match_operand:DI 0 "register_operand" "=r")
6278         (plus:DI (mult:DI (match_operand:DI 2 "register_operand" "r")
6279                           (match_operand:DI 3 "mem_shadd_operand" ""))
6280                  (match_operand:DI 1 "register_operand" "r")))]
6281   "TARGET_64BIT"
6282   "*
6284   int shift_val = exact_log2 (INTVAL (operands[3]));
6285   operands[3] = GEN_INT (shift_val);
6286   return \"shladd,l %2,%o3,%1,%0\";
6288   [(set_attr "type" "binary")
6289    (set_attr "length" "4")])
6291 (define_expand "ashlsi3"
6292   [(set (match_operand:SI 0 "register_operand" "")
6293         (ashift:SI (match_operand:SI 1 "lhs_lshift_operand" "")
6294                    (match_operand:SI 2 "arith32_operand" "")))]
6295   ""
6296   "
6298   if (GET_CODE (operands[2]) != CONST_INT)
6299     {
6300       rtx temp = gen_reg_rtx (SImode);
6301       emit_insn (gen_subsi3 (temp, GEN_INT (31), operands[2]));
6302       if (GET_CODE (operands[1]) == CONST_INT)
6303         emit_insn (gen_zvdep_imm32 (operands[0], operands[1], temp));
6304       else
6305         emit_insn (gen_zvdep32 (operands[0], operands[1], temp));
6306       DONE;
6307     }
6308   /* Make sure both inputs are not constants,
6309      there are no patterns for that.  */
6310   operands[1] = force_reg (SImode, operands[1]);
6313 (define_insn ""
6314   [(set (match_operand:SI 0 "register_operand" "=r")
6315         (ashift:SI (match_operand:SI 1 "register_operand" "r")
6316                    (match_operand:SI 2 "const_int_operand" "n")))]
6317   ""
6318   "{zdep|depw,z} %1,%P2,%L2,%0"
6319   [(set_attr "type" "shift")
6320    (set_attr "length" "4")])
6322 ; Match cases of op1 a CONST_INT here that zvdep_imm32 doesn't handle.
6323 ; Doing it like this makes slightly better code since reload can
6324 ; replace a register with a known value in range -16..15 with a
6325 ; constant.  Ideally, we would like to merge zvdep32 and zvdep_imm32,
6326 ; but since we have no more CONST_OK... characters, that is not
6327 ; possible.
6328 (define_insn "zvdep32"
6329   [(set (match_operand:SI 0 "register_operand" "=r,r")
6330         (ashift:SI (match_operand:SI 1 "arith5_operand" "r,L")
6331                    (minus:SI (const_int 31)
6332                              (match_operand:SI 2 "register_operand" "q,q"))))]
6333   ""
6334   "@
6335    {zvdep %1,32,%0|depw,z %1,%%sar,32,%0}
6336    {zvdepi %1,32,%0|depwi,z %1,%%sar,32,%0}"
6337   [(set_attr "type" "shift,shift")
6338    (set_attr "length" "4,4")])
6340 (define_insn "zvdep_imm32"
6341   [(set (match_operand:SI 0 "register_operand" "=r")
6342         (ashift:SI (match_operand:SI 1 "lhs_lshift_cint_operand" "")
6343                    (minus:SI (const_int 31)
6344                              (match_operand:SI 2 "register_operand" "q"))))]
6345   ""
6346   "*
6348   unsigned HOST_WIDE_INT x = UINTVAL (operands[1]);
6349   operands[2] = GEN_INT (4 + exact_log2 ((x >> 4) + 1));
6350   operands[1] = GEN_INT ((x & 0xf) - 0x10);
6351   return \"{zvdepi %1,%2,%0|depwi,z %1,%%sar,%2,%0}\";
6353   [(set_attr "type" "shift")
6354    (set_attr "length" "4")])
6356 (define_insn "vdepi_ior"
6357   [(set (match_operand:SI 0 "register_operand" "=r")
6358         (ior:SI (ashift:SI (match_operand:SI 1 "const_int_operand" "")
6359                            (minus:SI (const_int 31)
6360                                      (match_operand:SI 2 "register_operand" "q")))
6361                 (match_operand:SI 3 "register_operand" "0")))]
6362   ; accept ...0001...1, can this be generalized?
6363   "exact_log2 (INTVAL (operands[1]) + 1) > 0"
6364   "*
6366   HOST_WIDE_INT x = INTVAL (operands[1]);
6367   operands[2] = GEN_INT (exact_log2 (x + 1));
6368   return \"{vdepi -1,%2,%0|depwi -1,%%sar,%2,%0}\";
6370   [(set_attr "type" "shift")
6371    (set_attr "length" "4")])
6373 (define_insn "vdepi_and"
6374   [(set (match_operand:SI 0 "register_operand" "=r")
6375         (and:SI (rotate:SI (match_operand:SI 1 "const_int_operand" "")
6376                            (minus:SI (const_int 31)
6377                                      (match_operand:SI 2 "register_operand" "q")))
6378                 (match_operand:SI 3 "register_operand" "0")))]
6379   ; this can be generalized...!
6380   "INTVAL (operands[1]) == -2"
6381   "*
6383   HOST_WIDE_INT x = INTVAL (operands[1]);
6384   operands[2] = GEN_INT (exact_log2 ((~x) + 1));
6385   return \"{vdepi 0,%2,%0|depwi 0,%%sar,%2,%0}\";
6387   [(set_attr "type" "shift")
6388    (set_attr "length" "4")])
6390 (define_expand "ashldi3"
6391   [(set (match_operand:DI 0 "register_operand" "")
6392         (ashift:DI (match_operand:DI 1 "lhs_lshift_operand" "")
6393                    (match_operand:DI 2 "arith32_operand" "")))]
6394   "TARGET_64BIT"
6395   "
6397   if (GET_CODE (operands[2]) != CONST_INT)
6398     {
6399       rtx temp = gen_reg_rtx (DImode);
6400       emit_insn (gen_subdi3 (temp, GEN_INT (63), operands[2]));
6401       if (GET_CODE (operands[1]) == CONST_INT)
6402         emit_insn (gen_zvdep_imm64 (operands[0], operands[1], temp));
6403       else
6404         emit_insn (gen_zvdep64 (operands[0], operands[1], temp));
6405       DONE;
6406     }
6407   /* Make sure both inputs are not constants,
6408      there are no patterns for that.  */
6409   operands[1] = force_reg (DImode, operands[1]);
6412 (define_insn ""
6413   [(set (match_operand:DI 0 "register_operand" "=r")
6414         (ashift:DI (match_operand:DI 1 "register_operand" "r")
6415                    (match_operand:DI 2 "const_int_operand" "n")))]
6416   "TARGET_64BIT"
6417   "depd,z %1,%p2,%Q2,%0"
6418   [(set_attr "type" "shift")
6419    (set_attr "length" "4")])
6421 ; Match cases of op1 a CONST_INT here that zvdep_imm64 doesn't handle.
6422 ; Doing it like this makes slightly better code since reload can
6423 ; replace a register with a known value in range -16..15 with a
6424 ; constant.  Ideally, we would like to merge zvdep64 and zvdep_imm64,
6425 ; but since we have no more CONST_OK... characters, that is not
6426 ; possible.
6427 (define_insn "zvdep64"
6428   [(set (match_operand:DI 0 "register_operand" "=r,r")
6429         (ashift:DI (match_operand:DI 1 "arith5_operand" "r,L")
6430                    (minus:DI (const_int 63)
6431                              (match_operand:DI 2 "register_operand" "q,q"))))]
6432   "TARGET_64BIT"
6433   "@
6434    depd,z %1,%%sar,64,%0
6435    depdi,z %1,%%sar,64,%0"
6436   [(set_attr "type" "shift,shift")
6437    (set_attr "length" "4,4")])
6439 (define_insn "zvdep_imm64"
6440   [(set (match_operand:DI 0 "register_operand" "=r")
6441         (ashift:DI (match_operand:DI 1 "lhs_lshift_cint_operand" "")
6442                    (minus:DI (const_int 63)
6443                              (match_operand:DI 2 "register_operand" "q"))))]
6444   "TARGET_64BIT"
6445   "*
6447   unsigned HOST_WIDE_INT x = UINTVAL (operands[1]);
6448   operands[2] = GEN_INT (4 + exact_log2 ((x >> 4) + 1));
6449   operands[1] = GEN_INT ((x & 0x1f) - 0x20);
6450   return \"depdi,z %1,%%sar,%2,%0\";
6452   [(set_attr "type" "shift")
6453    (set_attr "length" "4")])
6455 (define_insn ""
6456   [(set (match_operand:DI 0 "register_operand" "=r")
6457         (ior:DI (ashift:DI (match_operand:DI 1 "const_int_operand" "")
6458                            (minus:DI (const_int 63)
6459                                      (match_operand:DI 2 "register_operand" "q")))
6460                 (match_operand:DI 3 "register_operand" "0")))]
6461   ; accept ...0001...1, can this be generalized?
6462   "TARGET_64BIT && exact_log2 (INTVAL (operands[1]) + 1) > 0"
6463   "*
6465   HOST_WIDE_INT x = INTVAL (operands[1]);
6466   operands[2] = GEN_INT (exact_log2 (x + 1));
6467   return \"depdi -1,%%sar,%2,%0\";
6469   [(set_attr "type" "shift")
6470    (set_attr "length" "4")])
6472 (define_insn ""
6473   [(set (match_operand:DI 0 "register_operand" "=r")
6474         (and:DI (rotate:DI (match_operand:DI 1 "const_int_operand" "")
6475                            (minus:DI (const_int 63)
6476                                      (match_operand:DI 2 "register_operand" "q")))
6477                 (match_operand:DI 3 "register_operand" "0")))]
6478   ; this can be generalized...!
6479   "TARGET_64BIT && INTVAL (operands[1]) == -2"
6480   "*
6482   HOST_WIDE_INT x = INTVAL (operands[1]);
6483   operands[2] = GEN_INT (exact_log2 ((~x) + 1));
6484   return \"depdi 0,%%sar,%2,%0\";
6486   [(set_attr "type" "shift")
6487    (set_attr "length" "4")])
6489 (define_expand "ashrsi3"
6490   [(set (match_operand:SI 0 "register_operand" "")
6491         (ashiftrt:SI (match_operand:SI 1 "register_operand" "")
6492                      (match_operand:SI 2 "arith32_operand" "")))]
6493   ""
6494   "
6496   if (GET_CODE (operands[2]) != CONST_INT)
6497     {
6498       rtx temp = gen_reg_rtx (SImode);
6499       emit_insn (gen_subsi3 (temp, GEN_INT (31), operands[2]));
6500       emit_insn (gen_vextrs32 (operands[0], operands[1], temp));
6501       DONE;
6502     }
6505 (define_insn ""
6506   [(set (match_operand:SI 0 "register_operand" "=r")
6507         (ashiftrt:SI (match_operand:SI 1 "register_operand" "r")
6508                      (match_operand:SI 2 "const_int_operand" "n")))]
6509   ""
6510   "{extrs|extrw,s} %1,%P2,%L2,%0"
6511   [(set_attr "type" "shift")
6512    (set_attr "length" "4")])
6514 (define_insn "vextrs32"
6515   [(set (match_operand:SI 0 "register_operand" "=r")
6516         (ashiftrt:SI (match_operand:SI 1 "register_operand" "r")
6517                      (minus:SI (const_int 31)
6518                                (match_operand:SI 2 "register_operand" "q"))))]
6519   ""
6520   "{vextrs %1,32,%0|extrw,s %1,%%sar,32,%0}"
6521   [(set_attr "type" "shift")
6522    (set_attr "length" "4")])
6524 (define_expand "ashrdi3"
6525   [(set (match_operand:DI 0 "register_operand" "")
6526         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
6527                      (match_operand:DI 2 "arith32_operand" "")))]
6528   "TARGET_64BIT"
6529   "
6531   if (GET_CODE (operands[2]) != CONST_INT)
6532     {
6533       rtx temp = gen_reg_rtx (DImode);
6534       emit_insn (gen_subdi3 (temp, GEN_INT (63), operands[2]));
6535       emit_insn (gen_vextrs64 (operands[0], operands[1], temp));
6536       DONE;
6537     }
6540 (define_insn ""
6541   [(set (match_operand:DI 0 "register_operand" "=r")
6542         (ashiftrt:DI (match_operand:DI 1 "register_operand" "r")
6543                      (match_operand:DI 2 "const_int_operand" "n")))]
6544   "TARGET_64BIT"
6545   "extrd,s %1,%p2,%Q2,%0"
6546   [(set_attr "type" "shift")
6547    (set_attr "length" "4")])
6549 (define_insn "vextrs64"
6550   [(set (match_operand:DI 0 "register_operand" "=r")
6551         (ashiftrt:DI (match_operand:DI 1 "register_operand" "r")
6552                      (minus:DI (const_int 63)
6553                                (match_operand:DI 2 "register_operand" "q"))))]
6554   "TARGET_64BIT"
6555   "extrd,s %1,%%sar,64,%0"
6556   [(set_attr "type" "shift")
6557    (set_attr "length" "4")])
6559 (define_insn "lshrsi3"
6560   [(set (match_operand:SI 0 "register_operand" "=r,r")
6561         (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
6562                      (match_operand:SI 2 "shift5_operand" "q,n")))]
6563   ""
6564   "@
6565    {vshd %%r0,%1,%0|shrpw %%r0,%1,%%sar,%0}
6566    {extru|extrw,u} %1,%P2,%L2,%0"
6567   [(set_attr "type" "shift")
6568    (set_attr "length" "4")])
6570 (define_insn "lshrdi3"
6571   [(set (match_operand:DI 0 "register_operand" "=r,r")
6572         (lshiftrt:DI (match_operand:DI 1 "register_operand" "r,r")
6573                      (match_operand:DI 2 "shift6_operand" "q,n")))]
6574   "TARGET_64BIT"
6575   "@
6576    shrpd %%r0,%1,%%sar,%0
6577    extrd,u %1,%p2,%Q2,%0"
6578   [(set_attr "type" "shift")
6579    (set_attr "length" "4")])
6581 ; Shift right pair word 0 to 31 bits.
6582 (define_insn "shrpsi4"
6583   [(set (match_operand:SI 0 "register_operand" "=r,r")
6584         (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "r,r")
6585                            (minus:SI (const_int 32)
6586                              (match_operand:SI 3 "shift5_operand" "q,n")))
6587                 (lshiftrt:SI (match_operand:SI 2 "register_operand" "r,r")
6588                              (match_dup 3))))]
6589   ""
6590   "@
6591    {vshd %1,%2,%0|shrpw %1,%2,%%sar,%0}
6592    {shd|shrpw} %1,%2,%3,%0"
6593   [(set_attr "type" "shift")
6594    (set_attr "length" "4")])
6596 ; Shift right pair doubleword 0 to 63 bits.
6597 (define_insn "shrpdi4"
6598   [(set (match_operand:DI 0 "register_operand" "=r,r")
6599         (ior:DI (ashift:DI (match_operand:SI 1 "register_operand" "r,r")
6600                            (minus:DI (const_int 64)
6601                              (match_operand:DI 3 "shift6_operand" "q,n")))
6602                 (lshiftrt:DI (match_operand:DI 2 "register_operand" "r,r")
6603                              (match_dup 3))))]
6604   "TARGET_64BIT"
6605   "@
6606    shrpd %1,%2,%%sar,%0
6607    shrpd %1,%2,%3,%0"
6608   [(set_attr "type" "shift")
6609    (set_attr "length" "4")])
6611 (define_insn "rotrsi3"
6612   [(set (match_operand:SI 0 "register_operand" "=r,r")
6613         (rotatert:SI (match_operand:SI 1 "register_operand" "r,r")
6614                      (match_operand:SI 2 "shift5_operand" "q,n")))]
6615   ""
6616   "*
6618   if (GET_CODE (operands[2]) == CONST_INT)
6619     {
6620       operands[2] = GEN_INT (INTVAL (operands[2]) & 31);
6621       return \"{shd|shrpw} %1,%1,%2,%0\";
6622     }
6623   else
6624     return \"{vshd %1,%1,%0|shrpw %1,%1,%%sar,%0}\";
6626   [(set_attr "type" "shift")
6627    (set_attr "length" "4")])
6629 (define_expand "rotlsi3"
6630   [(set (match_operand:SI 0 "register_operand" "")
6631         (rotate:SI (match_operand:SI 1 "register_operand" "")
6632                    (match_operand:SI 2 "arith32_operand" "")))]
6633   ""
6634   "
6636   if (GET_CODE (operands[2]) != CONST_INT)
6637     {
6638       rtx temp = gen_reg_rtx (SImode);
6639       emit_insn (gen_subsi3 (temp, GEN_INT (32), operands[2]));
6640       emit_insn (gen_rotrsi3 (operands[0], operands[1], temp));
6641       DONE;
6642     }
6643   /* Else expand normally.  */
6646 (define_insn ""
6647   [(set (match_operand:SI 0 "register_operand" "=r")
6648         (rotate:SI (match_operand:SI 1 "register_operand" "r")
6649                    (match_operand:SI 2 "const_int_operand" "n")))]
6650   ""
6651   "*
6653   operands[2] = GEN_INT ((32 - INTVAL (operands[2])) & 31);
6654   return \"{shd|shrpw} %1,%1,%2,%0\";
6656   [(set_attr "type" "shift")
6657    (set_attr "length" "4")])
6659 (define_insn ""
6660   [(set (match_operand:SI 0 "register_operand" "=r")
6661         (match_operator:SI 5 "plus_xor_ior_operator"
6662           [(ashift:SI (match_operand:SI 1 "register_operand" "r")
6663                       (match_operand:SI 3 "const_int_operand" "n"))
6664            (lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
6665                         (match_operand:SI 4 "const_int_operand" "n"))]))]
6666   "INTVAL (operands[3]) + INTVAL (operands[4]) == 32"
6667   "{shd|shrpw} %1,%2,%4,%0"
6668   [(set_attr "type" "shift")
6669    (set_attr "length" "4")])
6671 (define_insn ""
6672   [(set (match_operand:SI 0 "register_operand" "=r")
6673         (match_operator:SI 5 "plus_xor_ior_operator"
6674           [(lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
6675                         (match_operand:SI 4 "const_int_operand" "n"))
6676            (ashift:SI (match_operand:SI 1 "register_operand" "r")
6677                       (match_operand:SI 3 "const_int_operand" "n"))]))]
6678   "INTVAL (operands[3]) + INTVAL (operands[4]) == 32"
6679   "{shd|shrpw} %1,%2,%4,%0"
6680   [(set_attr "type" "shift")
6681    (set_attr "length" "4")])
6683 (define_insn ""
6684   [(set (match_operand:SI 0 "register_operand" "=r")
6685         (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
6686                            (match_operand:SI 2 "const_int_operand" ""))
6687                 (match_operand:SI 3 "const_int_operand" "")))]
6688   "exact_log2 (1 + (INTVAL (operands[3]) >> (INTVAL (operands[2]) & 31))) > 0"
6689   "*
6691   int cnt = INTVAL (operands[2]) & 31;
6692   operands[3] = GEN_INT (exact_log2 (1 + (INTVAL (operands[3]) >> cnt)));
6693   operands[2] = GEN_INT (31 - cnt);
6694   return \"{zdep|depw,z} %1,%2,%3,%0\";
6696   [(set_attr "type" "shift")
6697    (set_attr "length" "4")])
6699 ;; Unconditional and other jump instructions.
6701 ;; Trivial return used when no epilogue is needed.
6702 (define_insn "return"
6703   [(return)
6704    (use (reg:SI 2))]
6705   "pa_can_use_return_insn ()"
6706   "*
6708   if (TARGET_PA_20)
6709     return \"bve%* (%%r2)\";
6710   return \"bv%* %%r0(%%r2)\";
6712   [(set_attr "type" "branch")
6713    (set_attr "length" "4")])
6715 ;; This is used for most returns.
6716 (define_insn "return_internal"
6717   [(return)
6718    (use (reg:SI 2))]
6719   ""
6720   "*
6722   if (TARGET_PA_20)
6723     return \"bve%* (%%r2)\";
6724   return \"bv%* %%r0(%%r2)\";
6726   [(set_attr "type" "branch")
6727    (set_attr "length" "4")])
6729 ;; This is used for eh returns which bypass the return stub.
6730 (define_insn "return_external_pic"
6731   [(return)
6732    (clobber (reg:SI 1))
6733    (use (reg:SI 2))]
6734   "!TARGET_NO_SPACE_REGS
6735    && !TARGET_PA_20
6736    && flag_pic && crtl->calls_eh_return"
6737   "ldsid (%%sr0,%%r2),%%r1\;mtsp %%r1,%%sr0\;be%* 0(%%sr0,%%r2)"
6738   [(set_attr "type" "branch")
6739    (set_attr "length" "12")])
6741 (define_expand "prologue"
6742   [(const_int 0)]
6743   ""
6744   "pa_expand_prologue ();DONE;")
6746 (define_expand "sibcall_epilogue"
6747   [(return)]
6748   ""
6749   "
6751   pa_expand_epilogue ();
6752   DONE;
6755 (define_expand "epilogue"
6756   [(return)]
6757   ""
6758   "
6760   rtx x;
6762   /* Try to use the trivial return first.  Else use the full epilogue.  */
6763   if (pa_can_use_return_insn ())
6764     x = gen_return ();
6765   else
6766     {
6767       pa_expand_epilogue ();
6769       /* EH returns bypass the normal return stub.  Thus, we must do an
6770          interspace branch to return from functions that call eh_return.
6771          This is only a problem for returns from shared code on ports
6772          using space registers.  */
6773       if (!TARGET_NO_SPACE_REGS
6774           && !TARGET_PA_20
6775           && flag_pic && crtl->calls_eh_return)
6776         x = gen_return_external_pic ();
6777       else
6778         x = gen_return_internal ();
6779     }
6780   emit_jump_insn (x);
6781   DONE;
6784 ; Used by hppa_profile_hook to load the starting address of the current
6785 ; function; operand 1 contains the address of the label in operand 3
6786 (define_insn "load_offset_label_address"
6787   [(set (match_operand:SI 0 "register_operand" "=r")
6788         (plus:SI (match_operand:SI 1 "register_operand" "r")
6789                  (minus:SI (match_operand:SI 2 "" "")
6790                            (label_ref:SI (match_operand 3 "" "")))))]
6791   ""
6792   "ldo %2-%l3(%1),%0"
6793   [(set_attr "type" "multi")
6794    (set_attr "length" "4")])
6796 ; Output a code label and load its address.
6797 (define_insn "lcla1"
6798   [(set (match_operand:SI 0 "register_operand" "=r")
6799         (label_ref:SI (match_operand 1 "" "")))
6800    (const_int 0)]
6801   "!TARGET_PA_20"
6802   "*
6804   output_asm_insn (\"bl .+8,%0\;depi 0,31,2,%0\", operands);
6805   (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
6806                                      CODE_LABEL_NUMBER (operands[1]));
6807   return \"\";
6809   [(set_attr "type" "multi")
6810    (set_attr "length" "8")])
6812 (define_insn "lcla2"
6813   [(set (match_operand:SI 0 "register_operand" "=r")
6814         (label_ref:SI (match_operand 1 "" "")))
6815    (const_int 0)]
6816   "TARGET_PA_20"
6817   "*
6819   (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
6820                                      CODE_LABEL_NUMBER (operands[1]));
6821   return \"mfia %0\";
6823   [(set_attr "type" "move")
6824    (set_attr "length" "4")])
6826 (define_insn "blockage"
6827   [(unspec_volatile [(const_int 2)] UNSPECV_BLOCKAGE)]
6828   ""
6829   ""
6830   [(set_attr "length" "0")])
6832 (define_insn "jump"
6833   [(set (pc) (label_ref (match_operand 0 "" "")))]
6834   ""
6835   "*
6837   /* An unconditional branch which can reach its target.  */
6838   if (get_attr_length (insn) < 16)
6839     return \"b%* %l0\";
6841   return pa_output_lbranch (operands[0], insn, 1);
6843   [(set_attr "type" "uncond_branch")
6844    (set_attr "pa_combine_type" "uncond_branch")
6845    (set (attr "length")
6846     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
6847                (const_int MAX_17BIT_OFFSET))
6848            (const_int 4)
6849            (match_test "TARGET_PORTABLE_RUNTIME")
6850            (const_int 20)
6851            (not (match_test "flag_pic"))
6852            (const_int 16)]
6853           (const_int 24)))])
6855 ;;; Hope this is only within a function...
6856 (define_insn "indirect_jump"
6857   [(set (pc) (match_operand 0 "pmode_register_operand" "r"))]
6858   ""
6859   "bv%* %%r0(%0)"
6860   [(set_attr "type" "branch")
6861    (set_attr "length" "4")])
6863 ;;; An indirect jump can be optimized to a direct jump.  GAS for the
6864 ;;; SOM target doesn't allow branching to a label inside a function.
6865 ;;; We also don't correctly compute branch distances for labels
6866 ;;; outside the current function.  Thus, we use an indirect jump can't
6867 ;;; be optimized to a direct jump for all targets.  We assume that
6868 ;;; the branch target is in the same space (i.e., nested function
6869 ;;; jumping to a label in an outer function in the same translation
6870 ;;; unit).
6871 (define_expand "nonlocal_goto"
6872   [(use (match_operand 0 "general_operand" ""))
6873    (use (match_operand 1 "general_operand" ""))
6874    (use (match_operand 2 "general_operand" ""))
6875    (use (match_operand 3 "general_operand" ""))]
6876   ""
6878   rtx lab = operands[1];
6879   rtx stack = operands[2];
6880   rtx fp = operands[3];
6882   lab = copy_to_reg (lab);
6884   emit_clobber (gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (VOIDmode)));
6885   emit_clobber (gen_rtx_MEM (BLKmode, hard_frame_pointer_rtx));
6887   /* Restore the frame pointer.  The virtual_stack_vars_rtx is saved
6888      instead of the hard_frame_pointer_rtx in the save area.  As a
6889      result, an extra instruction is needed to adjust for the offset
6890      of the virtual stack variables and the hard frame pointer.  */
6891   if (GET_CODE (fp) != REG)
6892     fp = force_reg (Pmode, fp);
6893   emit_move_insn (hard_frame_pointer_rtx, plus_constant (Pmode, fp, -8));
6895   emit_stack_restore (SAVE_NONLOCAL, stack);
6897   emit_use (hard_frame_pointer_rtx);
6898   emit_use (stack_pointer_rtx);
6900   /* Nonlocal goto jumps are only used between functions in the same
6901      translation unit.  Thus, we can avoid the extra overhead of an
6902      interspace jump.  */
6903   emit_jump_insn (gen_indirect_goto (lab));
6904   emit_barrier ();
6905   DONE;
6908 (define_insn "indirect_goto"
6909   [(unspec [(match_operand 0 "register_operand" "=r")] UNSPEC_GOTO)]
6910   "GET_MODE (operands[0]) == word_mode"
6911   "bv%* %%r0(%0)"
6912   [(set_attr "type" "branch")
6913    (set_attr "length" "4")])
6915 ;; Subroutines of "casesi".
6916 ;; operand 0 is index
6917 ;; operand 1 is the minimum bound
6918 ;; operand 2 is the maximum bound - minimum bound + 1
6919 ;; operand 3 is CODE_LABEL for the table;
6920 ;; operand 4 is the CODE_LABEL to go to if index out of range.
6922 (define_expand "casesi"
6923   [(match_operand:SI 0 "general_operand" "")
6924    (match_operand:SI 1 "const_int_operand" "")
6925    (match_operand:SI 2 "const_int_operand" "")
6926    (match_operand 3 "" "")
6927    (match_operand 4 "" "")]
6928   ""
6929   "
6931   if (GET_CODE (operands[0]) != REG)
6932     operands[0] = force_reg (SImode, operands[0]);
6934   if (operands[1] != const0_rtx)
6935     {
6936       rtx index = gen_reg_rtx (SImode);
6938       operands[1] = gen_int_mode (-INTVAL (operands[1]), SImode);
6939       if (!INT_14_BITS (operands[1]))
6940         operands[1] = force_reg (SImode, operands[1]);
6941       emit_insn (gen_addsi3 (index, operands[0], operands[1]));
6942       operands[0] = index;
6943     }
6945   if (!INT_5_BITS (operands[2]))
6946     operands[2] = force_reg (SImode, operands[2]);
6948   /* This branch prevents us finding an insn for the delay slot of the
6949      following vectored branch.  It might be possible to use the delay
6950      slot if an index value of -1 was used to transfer to the out-of-range
6951      label.  In order to do this, we would have to output the -1 vector
6952      element after the delay insn.  The casesi output code would have to
6953      check if the casesi insn is in a delay branch sequence and output
6954      the delay insn if one is found.  If this was done, then it might
6955      then be worthwhile to split the casesi patterns to improve scheduling.
6956      However, it's not clear that all this extra complexity is worth
6957      the effort.  */
6958   {
6959     rtx test = gen_rtx_GTU (VOIDmode, operands[0], operands[2]);
6960     emit_jump_insn (gen_cbranchsi4 (test, operands[0], operands[2], operands[4]));
6961   }
6963   /* In 64bit mode we must make sure to wipe the upper bits of the register
6964      just in case the addition overflowed or we had random bits in the
6965      high part of the register.  */
6966   if (TARGET_64BIT)
6967     {
6968       rtx index = gen_reg_rtx (DImode);
6970       emit_insn (gen_extendsidi2 (index, operands[0]));
6971       operands[0] = index;
6972     }
6974   if (TARGET_64BIT)
6975     emit_jump_insn (gen_casesi64p (operands[0], operands[3]));
6976   else if (flag_pic)
6977     emit_jump_insn (gen_casesi32p (operands[0], operands[3]));
6978   else
6979     emit_jump_insn (gen_casesi32 (operands[0], operands[3]));
6980   DONE;
6983 ;;; 32-bit code, absolute branch table.
6984 (define_insn "casesi32"
6985   [(set (pc) (mem:SI (plus:SI
6986                        (mult:SI (match_operand:SI 0 "register_operand" "r")
6987                                 (const_int 4))
6988                        (label_ref (match_operand 1 "" "")))))
6989    (clobber (match_scratch:SI 2 "=&r"))]
6990   "!flag_pic"
6991   "ldil L'%l1,%2\;ldo R'%l1(%2),%2\;{ldwx|ldw},s %0(%2),%2\;bv,n %%r0(%2)"
6992   [(set_attr "type" "multi")
6993    (set_attr "length" "16")])
6995 ;;; 32-bit code, relative branch table.
6996 (define_insn "casesi32p"
6997   [(set (pc) (mem:SI (plus:SI
6998                        (mult:SI (match_operand:SI 0 "register_operand" "r")
6999                                 (const_int 4))
7000                        (label_ref (match_operand 1 "" "")))))
7001    (clobber (match_scratch:SI 2 "=&r"))
7002    (clobber (match_scratch:SI 3 "=&r"))]
7003   "flag_pic"
7004   "{bl .+8,%2\;depi 0,31,2,%2|mfia %2}\;ldo {%l1-.|%l1+4-.}(%2),%2\;\
7005 {ldwx|ldw},s %0(%2),%3\;{addl|add,l} %2,%3,%3\;bv,n %%r0(%3)"
7006   [(set_attr "type" "multi")
7007    (set (attr "length")
7008      (if_then_else (match_test "TARGET_PA_20")
7009         (const_int 20)
7010         (const_int 24)))])
7012 ;;; 64-bit code, 32-bit relative branch table.
7013 (define_insn "casesi64p"
7014   [(set (pc) (mem:DI (plus:DI
7015                        (mult:DI (match_operand:DI 0 "register_operand" "r")
7016                                 (const_int 8))
7017                        (label_ref (match_operand 1 "" "")))))
7018    (clobber (match_scratch:DI 2 "=&r"))
7019    (clobber (match_scratch:DI 3 "=&r"))]
7020   ""
7021   "mfia %2\;ldo %l1+4-.(%2),%2\;ldw,s %0(%2),%3\;extrd,s %3,63,32,%3\;\
7022 add,l %2,%3,%3\;bv,n %%r0(%3)"
7023   [(set_attr "type" "multi")
7024    (set_attr "length" "24")])
7027 ;; Call patterns.
7028 ;;- jump to subroutine
7030 (define_expand "call"
7031   [(parallel [(call (match_operand:SI 0 "" "")
7032                     (match_operand 1 "" ""))
7033               (clobber (reg:SI 2))])]
7034   ""
7035   "
7037   rtx op;
7038   rtx nb = operands[1];
7040   if (TARGET_PORTABLE_RUNTIME)
7041     op = force_reg (SImode, XEXP (operands[0], 0));
7042   else
7043     {
7044       op = XEXP (operands[0], 0);
7046       /* Generate indirect long calls to non-local functions. */
7047       if (TARGET_LONG_CALLS && GET_CODE (op) == SYMBOL_REF)
7048         {
7049           tree call_decl = SYMBOL_REF_DECL (op);
7050           if (!(call_decl && targetm.binds_local_p (call_decl)))
7051             op = force_reg (word_mode, op);
7052         }
7053     }
7055   if (TARGET_64BIT)
7056     {
7057       if (!virtuals_instantiated)
7058         emit_move_insn (arg_pointer_rtx,
7059                         gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
7060                                       GEN_INT (64)));
7061       else
7062         {
7063           /* The loop pass can generate new libcalls after the virtual
7064              registers are instantiated when fpregs are disabled because
7065              the only method that we have for doing DImode multiplication
7066              is with a libcall.  This could be trouble if we haven't
7067              allocated enough space for the outgoing arguments.  */
7068           gcc_assert (INTVAL (nb) <= crtl->outgoing_args_size);
7070           emit_move_insn (arg_pointer_rtx,
7071                           gen_rtx_PLUS (word_mode, stack_pointer_rtx,
7072                                         GEN_INT (STACK_POINTER_OFFSET + 64)));
7073         }
7074     }
7076   /* Use two different patterns for calls to explicitly named functions
7077      and calls through function pointers.  This is necessary as these two
7078      types of calls use different calling conventions, and CSE might try
7079      to change the named call into an indirect call in some cases (using
7080      two patterns keeps CSE from performing this optimization).
7081      
7082      We now use even more call patterns as there was a subtle bug in
7083      attempting to restore the pic register after a call using a simple
7084      move insn.  During reload, a instruction involving a pseudo register
7085      with no explicit dependence on the PIC register can be converted
7086      to an equivalent load from memory using the PIC register.  If we
7087      emit a simple move to restore the PIC register in the initial rtl
7088      generation, then it can potentially be repositioned during scheduling.
7089      and an instruction that eventually uses the PIC register may end up
7090      between the call and the PIC register restore.
7091      
7092      This only worked because there is a post call group of instructions
7093      that are scheduled with the call.  These instructions are included
7094      in the same basic block as the call.  However, calls can throw in
7095      C++ code and a basic block has to terminate at the call if the call
7096      can throw.  This results in the PIC register restore being scheduled
7097      independently from the call.  So, we now hide the save and restore
7098      of the PIC register in the call pattern until after reload.  Then,
7099      we split the moves out.  A small side benefit is that we now don't
7100      need to have a use of the PIC register in the return pattern and
7101      the final save/restore operation is not needed.
7102      
7103      I elected to just use register %r4 in the PIC patterns instead
7104      of trying to force hppa_pic_save_rtx () to a callee saved register.
7105      This might have required a new register class and constraint.  It
7106      was also simpler to just handle the restore from a register than a
7107      generic pseudo.  */
7108   if (TARGET_64BIT)
7109     {
7110       rtx r4 = gen_rtx_REG (word_mode, 4);
7111       if (GET_CODE (op) == SYMBOL_REF)
7112         emit_call_insn (gen_call_symref_64bit (op, nb, r4));
7113       else
7114         {
7115           op = force_reg (word_mode, op);
7116           emit_call_insn (gen_call_reg_64bit (op, nb, r4));
7117         }
7118     }
7119   else
7120     {
7121       if (GET_CODE (op) == SYMBOL_REF)
7122         {
7123           if (flag_pic)
7124             {
7125               rtx r4 = gen_rtx_REG (word_mode, 4);
7126               emit_call_insn (gen_call_symref_pic (op, nb, r4));
7127             }
7128           else
7129             emit_call_insn (gen_call_symref (op, nb));
7130         }
7131       else
7132         {
7133           rtx tmpreg = gen_rtx_REG (word_mode, 22);
7134           emit_move_insn (tmpreg, force_reg (word_mode, op));
7135           if (flag_pic)
7136             {
7137               rtx r4 = gen_rtx_REG (word_mode, 4);
7138               emit_call_insn (gen_call_reg_pic (nb, r4));
7139             }
7140           else
7141             emit_call_insn (gen_call_reg (nb));
7142         }
7143     }
7145   DONE;
7148 ;; We use function calls to set the attribute length of calls and millicode
7149 ;; calls.  This is necessary because of the large variety of call sequences.
7150 ;; Implementing the calculation in rtl is difficult as well as ugly.  As
7151 ;; we need the same calculation in several places, maintenance becomes a
7152 ;; nightmare.
7154 ;; However, this has a subtle impact on branch shortening.  When the
7155 ;; expression used to set the length attribute of an instruction depends
7156 ;; on a relative address (e.g., pc or a branch address), genattrtab
7157 ;; notes that the insn's length is variable, and attempts to determine a
7158 ;; worst-case default length and code to compute an insn's current length.
7160 ;; The use of a function call hides the variable dependence of our calls
7161 ;; and millicode calls.  The result is genattrtab doesn't treat the operation
7162 ;; as variable and it only generates code for the default case using our
7163 ;; function call.  Because of this, calls and millicode calls have a fixed
7164 ;; length in the branch shortening pass, and some branches will use a longer
7165 ;; code sequence than necessary.  However, the length of any given call
7166 ;; will still reflect its final code location and it may be shorter than
7167 ;; the initial length estimate.
7169 ;; It's possible to trick genattrtab by adding an expression involving `pc'
7170 ;; in the set.  However, when genattrtab hits a function call in its attempt
7171 ;; to compute the default length, it marks the result as unknown and sets
7172 ;; the default result to MAX_INT ;-(  One possible fix that would allow
7173 ;; calls to participate in branch shortening would be to make the call to
7174 ;; insn_default_length a target option.  Then, we could massage unknown
7175 ;; results.  Another fix might be to change genattrtab so that it just does
7176 ;; the call in the variable case as it already does for the fixed case.
7178 (define_insn "call_symref"
7179   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7180          (match_operand 1 "" "i"))
7181    (clobber (reg:SI 1))
7182    (clobber (reg:SI 2))
7183    (use (const_int 0))]
7184   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7185   "*
7187   pa_output_arg_descriptor (insn);
7188   return pa_output_call (insn, operands[0], 0);
7190   [(set_attr "type" "call")
7191    (set (attr "length")
7192         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7193               (symbol_ref "pa_attr_length_call (insn, 0)")))])
7195 (define_insn "call_symref_pic"
7196   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7197          (match_operand 1 "" "i"))
7198    (clobber (reg:SI 1))
7199    (clobber (reg:SI 2))
7200    (clobber (match_operand 2))
7201    (use (reg:SI 19))
7202    (use (const_int 0))]
7203   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7204   "#")
7206 ;; Split out the PIC register save and restore after reload.  As the
7207 ;; split is done after reload, there are some situations in which we
7208 ;; unnecessarily save and restore %r4.  This happens when there is a
7209 ;; single call and the PIC register is not used after the call.
7211 ;; The split has to be done since call_from_call_insn () can't handle
7212 ;; the pattern as is.  Noreturn calls are special because they have to
7213 ;; terminate the basic block.  The split has to contain more than one
7214 ;; insn.
7215 (define_split
7216   [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7217                     (match_operand 1 "" ""))
7218               (clobber (reg:SI 1))
7219               (clobber (reg:SI 2))
7220               (clobber (match_operand 2))
7221               (use (reg:SI 19))
7222               (use (const_int 0))])]
7223   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed
7224    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7225   [(set (match_dup 2) (reg:SI 19))
7226    (parallel [(call (mem:SI (match_dup 0))
7227                     (match_dup 1))
7228               (clobber (reg:SI 1))
7229               (clobber (reg:SI 2))
7230               (use (reg:SI 19))
7231               (use (const_int 0))])]
7232   "")
7234 (define_split
7235   [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7236                     (match_operand 1 "" ""))
7237               (clobber (reg:SI 1))
7238               (clobber (reg:SI 2))
7239               (clobber (match_operand 2))
7240               (use (reg:SI 19))
7241               (use (const_int 0))])]
7242   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
7243   [(set (match_dup 2) (reg:SI 19))
7244    (parallel [(call (mem:SI (match_dup 0))
7245                     (match_dup 1))
7246               (clobber (reg:SI 1))
7247               (clobber (reg:SI 2))
7248               (use (reg:SI 19))
7249               (use (const_int 0))])
7250    (set (reg:SI 19) (match_dup 2))]
7251   "")
7253 (define_insn "*call_symref_pic_post_reload"
7254   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7255          (match_operand 1 "" "i"))
7256    (clobber (reg:SI 1))
7257    (clobber (reg:SI 2))
7258    (use (reg:SI 19))
7259    (use (const_int 0))]
7260   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7261   "*
7263   pa_output_arg_descriptor (insn);
7264   return pa_output_call (insn, operands[0], 0);
7266   [(set_attr "type" "call")
7267    (set (attr "length")
7268         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7269               (symbol_ref "pa_attr_length_call (insn, 0)")))])
7271 ;; This pattern is split if it is necessary to save and restore the
7272 ;; PIC register.
7273 (define_insn "call_symref_64bit"
7274   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7275          (match_operand 1 "" "i"))
7276    (clobber (reg:DI 1))
7277    (clobber (reg:DI 2))
7278    (clobber (match_operand 2))
7279    (use (reg:DI 27))
7280    (use (reg:DI 29))
7281    (use (const_int 0))]
7282   "TARGET_64BIT"
7283   "#")
7285 ;; Split out the PIC register save and restore after reload.  As the
7286 ;; split is done after reload, there are some situations in which we
7287 ;; unnecessarily save and restore %r4.  This happens when there is a
7288 ;; single call and the PIC register is not used after the call.
7290 ;; The split has to be done since call_from_call_insn () can't handle
7291 ;; the pattern as is.  Noreturn calls are special because they have to
7292 ;; terminate the basic block.  The split has to contain more than one
7293 ;; insn.
7294 (define_split
7295   [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7296                     (match_operand 1 "" ""))
7297               (clobber (reg:DI 1))
7298               (clobber (reg:DI 2))
7299               (clobber (match_operand 2))
7300               (use (reg:DI 27))
7301               (use (reg:DI 29))
7302               (use (const_int 0))])]
7303   "TARGET_64BIT && reload_completed
7304    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7305   [(set (match_dup 2) (reg:DI 27))
7306    (parallel [(call (mem:SI (match_dup 0))
7307                     (match_dup 1))
7308               (clobber (reg:DI 1))
7309               (clobber (reg:DI 2))
7310               (use (reg:DI 27))
7311               (use (reg:DI 29))
7312               (use (const_int 0))])]
7313   "")
7315 (define_split
7316   [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7317                     (match_operand 1 "" ""))
7318               (clobber (reg:DI 1))
7319               (clobber (reg:DI 2))
7320               (clobber (match_operand 2))
7321               (use (reg:DI 27))
7322               (use (reg:DI 29))
7323               (use (const_int 0))])]
7324   "TARGET_64BIT && reload_completed"
7325   [(set (match_dup 2) (reg:DI 27))
7326    (parallel [(call (mem:SI (match_dup 0))
7327                     (match_dup 1))
7328               (clobber (reg:DI 1))
7329               (clobber (reg:DI 2))
7330               (use (reg:DI 27))
7331               (use (reg:DI 29))
7332               (use (const_int 0))])
7333    (set (reg:DI 27) (match_dup 2))]
7334   "")
7336 (define_insn "*call_symref_64bit_post_reload"
7337   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7338          (match_operand 1 "" "i"))
7339    (clobber (reg:DI 1))
7340    (clobber (reg:DI 2))
7341    (use (reg:DI 27))
7342    (use (reg:DI 29))
7343    (use (const_int 0))]
7344   "TARGET_64BIT"
7345   "*
7347   return pa_output_call (insn, operands[0], 0);
7349   [(set_attr "type" "call")
7350    (set (attr "length")
7351         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7352               (symbol_ref "pa_attr_length_call (insn, 0)")))])
7354 (define_insn "call_reg"
7355   [(call (mem:SI (reg:SI 22))
7356          (match_operand 0 "" "i"))
7357    (clobber (reg:SI 1))
7358    (clobber (reg:SI 2))
7359    (use (const_int 1))]
7360   "!TARGET_64BIT"
7361   "*
7363   return pa_output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
7365   [(set_attr "type" "dyncall")
7366    (set (attr "length")
7367         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7368               (symbol_ref "pa_attr_length_indirect_call (insn)")))])
7370 ;; This pattern is split if it is necessary to save and restore the
7371 ;; PIC register.
7372 (define_insn "call_reg_pic"
7373   [(call (mem:SI (reg:SI 22))
7374          (match_operand 0 "" "i"))
7375    (clobber (reg:SI 1))
7376    (clobber (reg:SI 2))
7377    (clobber (match_operand 1))
7378    (use (reg:SI 19))
7379    (use (const_int 1))]
7380   "!TARGET_64BIT"
7381   "#")
7383 ;; Split out the PIC register save and restore after reload.  As the
7384 ;; split is done after reload, there are some situations in which we
7385 ;; unnecessarily save and restore %r4.  This happens when there is a
7386 ;; single call and the PIC register is not used after the call.
7388 ;; The split has to be done since call_from_call_insn () can't handle
7389 ;; the pattern as is.  Noreturn calls are special because they have to
7390 ;; terminate the basic block.  The split has to contain more than one
7391 ;; insn.
7392 (define_split
7393   [(parallel [(call (mem:SI (reg:SI 22))
7394                     (match_operand 0 "" ""))
7395               (clobber (reg:SI 1))
7396               (clobber (reg:SI 2))
7397               (clobber (match_operand 1))
7398               (use (reg:SI 19))
7399               (use (const_int 1))])]
7400   "!TARGET_64BIT && reload_completed
7401    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7402   [(set (match_dup 1) (reg:SI 19))
7403    (parallel [(call (mem:SI (reg:SI 22))
7404                     (match_dup 0))
7405               (clobber (reg:SI 1))
7406               (clobber (reg:SI 2))
7407               (use (reg:SI 19))
7408               (use (const_int 1))])]
7409   "")
7411 (define_split
7412   [(parallel [(call (mem:SI (reg:SI 22))
7413                     (match_operand 0 "" ""))
7414               (clobber (reg:SI 1))
7415               (clobber (reg:SI 2))
7416               (clobber (match_operand 1))
7417               (use (reg:SI 19))
7418               (use (const_int 1))])]
7419   "!TARGET_64BIT && reload_completed"
7420   [(set (match_dup 1) (reg:SI 19))
7421    (parallel [(call (mem:SI (reg:SI 22))
7422                     (match_dup 0))
7423               (clobber (reg:SI 1))
7424               (clobber (reg:SI 2))
7425               (use (reg:SI 19))
7426               (use (const_int 1))])
7427    (set (reg:SI 19) (match_dup 1))]
7428   "")
7430 (define_insn "*call_reg_pic_post_reload"
7431   [(call (mem:SI (reg:SI 22))
7432          (match_operand 0 "" "i"))
7433    (clobber (reg:SI 1))
7434    (clobber (reg:SI 2))
7435    (use (reg:SI 19))
7436    (use (const_int 1))]
7437   "!TARGET_64BIT"
7438   "*
7440   return pa_output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
7442   [(set_attr "type" "dyncall")
7443    (set (attr "length")
7444         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7445               (symbol_ref "pa_attr_length_indirect_call (insn)")))])
7447 ;; This pattern is split if it is necessary to save and restore the
7448 ;; PIC register.
7449 (define_insn "call_reg_64bit"
7450   [(call (mem:SI (match_operand:DI 0 "register_operand" "r"))
7451          (match_operand 1 "" "i"))
7452    (clobber (reg:DI 2))
7453    (clobber (match_operand 2))
7454    (use (reg:DI 27))
7455    (use (reg:DI 29))
7456    (use (const_int 1))]
7457   "TARGET_64BIT"
7458   "#")
7460 ;; Split out the PIC register save and restore after reload.  As the
7461 ;; split is done after reload, there are some situations in which we
7462 ;; unnecessarily save and restore %r4.  This happens when there is a
7463 ;; single call and the PIC register is not used after the call.
7465 ;; The split has to be done since call_from_call_insn () can't handle
7466 ;; the pattern as is.  Noreturn calls are special because they have to
7467 ;; terminate the basic block.  The split has to contain more than one
7468 ;; insn.
7469 (define_split
7470   [(parallel [(call (mem:SI (match_operand 0 "register_operand" ""))
7471                     (match_operand 1 "" ""))
7472               (clobber (reg:DI 2))
7473               (clobber (match_operand 2))
7474               (use (reg:DI 27))
7475               (use (reg:DI 29))
7476               (use (const_int 1))])]
7477   "TARGET_64BIT && reload_completed
7478    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7479   [(set (match_dup 2) (reg:DI 27))
7480    (parallel [(call (mem:SI (match_dup 0))
7481                     (match_dup 1))
7482               (clobber (reg:DI 2))
7483               (use (reg:DI 27))
7484               (use (reg:DI 29))
7485               (use (const_int 1))])]
7486   "")
7488 (define_split
7489   [(parallel [(call (mem:SI (match_operand 0 "register_operand" ""))
7490                     (match_operand 1 "" ""))
7491               (clobber (reg:DI 2))
7492               (clobber (match_operand 2))
7493               (use (reg:DI 27))
7494               (use (reg:DI 29))
7495               (use (const_int 1))])]
7496   "TARGET_64BIT && reload_completed"
7497   [(set (match_dup 2) (reg:DI 27))
7498    (parallel [(call (mem:SI (match_dup 0))
7499                     (match_dup 1))
7500               (clobber (reg:DI 2))
7501               (use (reg:DI 27))
7502               (use (reg:DI 29))
7503               (use (const_int 1))])
7504    (set (reg:DI 27) (match_dup 2))]
7505   "")
7507 (define_insn "*call_reg_64bit_post_reload"
7508   [(call (mem:SI (match_operand:DI 0 "register_operand" "r"))
7509          (match_operand 1 "" "i"))
7510    (clobber (reg:DI 2))
7511    (use (reg:DI 27))
7512    (use (reg:DI 29))
7513    (use (const_int 1))]
7514   "TARGET_64BIT"
7515   "*
7517   return pa_output_indirect_call (insn, operands[0]);
7519   [(set_attr "type" "dyncall")
7520    (set (attr "length")
7521         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 12)]
7522               (symbol_ref "pa_attr_length_indirect_call (insn)")))])
7524 (define_expand "call_value"
7525   [(parallel [(set (match_operand 0 "" "")
7526                    (call (match_operand:SI 1 "" "")
7527                          (match_operand 2 "" "")))
7528               (clobber (reg:SI 2))])]
7529   ""
7531   rtx op;
7532   rtx dst = operands[0];
7533   rtx nb = operands[2];
7534   bool call_powf = false;
7536   if (TARGET_PORTABLE_RUNTIME)
7537     op = force_reg (SImode, XEXP (operands[1], 0));
7538   else
7539     {
7540       op = XEXP (operands[1], 0);
7541       if (GET_CODE (op) == SYMBOL_REF)
7542         {
7543           /* Handle special call to buggy powf function.  */
7544           if (TARGET_HPUX && !TARGET_DISABLE_FPREGS && !TARGET_SOFT_FLOAT
7545               && !strcmp (targetm.strip_name_encoding (XSTR (op, 0)), "powf"))
7546             call_powf = true;
7548           /* Generate indirect long calls to non-local functions. */
7549           else if (TARGET_LONG_CALLS)
7550             {
7551               tree call_decl = SYMBOL_REF_DECL (op);
7552               if (!(call_decl && targetm.binds_local_p (call_decl)))
7553                 op = force_reg (word_mode, op);
7554             }
7555         }
7556     }
7558   if (TARGET_64BIT)
7559     {
7560       if (!virtuals_instantiated)
7561         emit_move_insn (arg_pointer_rtx,
7562                         gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
7563                                       GEN_INT (64)));
7564       else
7565         {
7566           /* The loop pass can generate new libcalls after the virtual
7567              registers are instantiated when fpregs are disabled because
7568              the only method that we have for doing DImode multiplication
7569              is with a libcall.  This could be trouble if we haven't
7570              allocated enough space for the outgoing arguments.  */
7571           gcc_assert (INTVAL (nb) <= crtl->outgoing_args_size);
7573           emit_move_insn (arg_pointer_rtx,
7574                           gen_rtx_PLUS (word_mode, stack_pointer_rtx,
7575                                         GEN_INT (STACK_POINTER_OFFSET + 64)));
7576         }
7577     }
7579   /* Use two different patterns for calls to explicitly named functions
7580      and calls through function pointers.  This is necessary as these two
7581      types of calls use different calling conventions, and CSE might try
7582      to change the named call into an indirect call in some cases (using
7583      two patterns keeps CSE from performing this optimization).
7585      We now use even more call patterns as there was a subtle bug in
7586      attempting to restore the pic register after a call using a simple
7587      move insn.  During reload, a instruction involving a pseudo register
7588      with no explicit dependence on the PIC register can be converted
7589      to an equivalent load from memory using the PIC register.  If we
7590      emit a simple move to restore the PIC register in the initial rtl
7591      generation, then it can potentially be repositioned during scheduling.
7592      and an instruction that eventually uses the PIC register may end up
7593      between the call and the PIC register restore.
7594      
7595      This only worked because there is a post call group of instructions
7596      that are scheduled with the call.  These instructions are included
7597      in the same basic block as the call.  However, calls can throw in
7598      C++ code and a basic block has to terminate at the call if the call
7599      can throw.  This results in the PIC register restore being scheduled
7600      independently from the call.  So, we now hide the save and restore
7601      of the PIC register in the call pattern until after reload.  Then,
7602      we split the moves out.  A small side benefit is that we now don't
7603      need to have a use of the PIC register in the return pattern and
7604      the final save/restore operation is not needed.
7605      
7606      I elected to just use register %r4 in the PIC patterns instead
7607      of trying to force hppa_pic_save_rtx () to a callee saved register.
7608      This might have required a new register class and constraint.  It
7609      was also simpler to just handle the restore from a register than a
7610      generic pseudo.  */
7611   if (TARGET_64BIT)
7612     {
7613       rtx r4 = gen_rtx_REG (word_mode, 4);
7614       if (GET_CODE (op) == SYMBOL_REF)
7615         {
7616           if (call_powf)
7617             emit_call_insn (gen_call_val_powf_64bit (dst, op, nb, r4));
7618           else
7619             emit_call_insn (gen_call_val_symref_64bit (dst, op, nb, r4));
7620         }
7621       else
7622         {
7623           op = force_reg (word_mode, op);
7624           emit_call_insn (gen_call_val_reg_64bit (dst, op, nb, r4));
7625         }
7626     }
7627   else
7628     {
7629       if (GET_CODE (op) == SYMBOL_REF)
7630         {
7631           if (flag_pic)
7632             {
7633               rtx r4 = gen_rtx_REG (word_mode, 4);
7635               if (call_powf)
7636                 emit_call_insn (gen_call_val_powf_pic (dst, op, nb, r4));
7637               else
7638                 emit_call_insn (gen_call_val_symref_pic (dst, op, nb, r4));
7639             }
7640           else
7641             {
7642               if (call_powf)
7643                 emit_call_insn (gen_call_val_powf (dst, op, nb));
7644               else
7645                 emit_call_insn (gen_call_val_symref (dst, op, nb));
7646             }
7647         }
7648       else
7649         {
7650           rtx tmpreg = gen_rtx_REG (word_mode, 22);
7651           emit_move_insn (tmpreg, force_reg (word_mode, op));
7652           if (flag_pic)
7653             {
7654               rtx r4 = gen_rtx_REG (word_mode, 4);
7655               emit_call_insn (gen_call_val_reg_pic (dst, nb, r4));
7656             }
7657           else
7658             emit_call_insn (gen_call_val_reg (dst, nb));
7659         }
7660     }
7662   DONE;
7665 (define_insn "call_val_symref"
7666   [(set (match_operand 0 "" "")
7667         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7668               (match_operand 2 "" "i")))
7669    (clobber (reg:SI 1))
7670    (clobber (reg:SI 2))
7671    (use (const_int 0))]
7672   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7673   "*
7675   pa_output_arg_descriptor (insn);
7676   return pa_output_call (insn, operands[1], 0);
7678   [(set_attr "type" "call")
7679    (set (attr "length")
7680         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7681               (symbol_ref "pa_attr_length_call (insn, 0)")))])
7683 ;; powf function clobbers %fr12
7684 (define_insn "call_val_powf"
7685   [(set (match_operand 0 "" "")
7686         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7687               (match_operand 2 "" "i")))
7688    (clobber (reg:SI 1))
7689    (clobber (reg:SI 2))
7690    (clobber (reg:DF 48))
7691    (use (const_int 1))]
7692   "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7693   "*
7695   pa_output_arg_descriptor (insn);
7696   return pa_output_call (insn, operands[1], 0);
7698   [(set_attr "type" "call")
7699    (set (attr "length")
7700         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7701               (symbol_ref "pa_attr_length_call (insn, 0)")))])
7703 (define_insn "call_val_symref_pic"
7704   [(set (match_operand 0 "" "")
7705         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7706               (match_operand 2 "" "i")))
7707    (clobber (reg:SI 1))
7708    (clobber (reg:SI 2))
7709    (clobber (match_operand 3))
7710    (use (reg:SI 19))
7711    (use (const_int 0))]
7712   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7713   "#")
7715 ;; Split out the PIC register save and restore after reload.  As the
7716 ;; split is done after reload, there are some situations in which we
7717 ;; unnecessarily save and restore %r4.  This happens when there is a
7718 ;; single call and the PIC register is not used after the call.
7720 ;; The split has to be done since call_from_call_insn () can't handle
7721 ;; the pattern as is.  Noreturn calls are special because they have to
7722 ;; terminate the basic block.  The split has to contain more than one
7723 ;; insn.
7724 (define_split
7725   [(parallel [(set (match_operand 0 "" "")
7726               (call (mem:SI (match_operand 1 "call_operand_address" ""))
7727                     (match_operand 2 "" "")))
7728               (clobber (reg:SI 1))
7729               (clobber (reg:SI 2))
7730               (clobber (match_operand 3))
7731               (use (reg:SI 19))
7732               (use (const_int 0))])]
7733   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed
7734    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7735   [(set (match_dup 3) (reg:SI 19))
7736    (parallel [(set (match_dup 0)
7737               (call (mem:SI (match_dup 1))
7738                     (match_dup 2)))
7739               (clobber (reg:SI 1))
7740               (clobber (reg:SI 2))
7741               (use (reg:SI 19))
7742               (use (const_int 0))])]
7743   "")
7745 (define_split
7746   [(parallel [(set (match_operand 0 "" "")
7747               (call (mem:SI (match_operand 1 "call_operand_address" ""))
7748                     (match_operand 2 "" "")))
7749               (clobber (reg:SI 1))
7750               (clobber (reg:SI 2))
7751               (clobber (match_operand 3))
7752               (use (reg:SI 19))
7753               (use (const_int 0))])]
7754   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
7755   [(set (match_dup 3) (reg:SI 19))
7756    (parallel [(set (match_dup 0)
7757               (call (mem:SI (match_dup 1))
7758                     (match_dup 2)))
7759               (clobber (reg:SI 1))
7760               (clobber (reg:SI 2))
7761               (use (reg:SI 19))
7762               (use (const_int 0))])
7763    (set (reg:SI 19) (match_dup 3))]
7764   "")
7766 (define_insn "*call_val_symref_pic_post_reload"
7767   [(set (match_operand 0 "" "")
7768         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7769               (match_operand 2 "" "i")))
7770    (clobber (reg:SI 1))
7771    (clobber (reg:SI 2))
7772    (use (reg:SI 19))
7773    (use (const_int 0))]
7774   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7775   "*
7777   pa_output_arg_descriptor (insn);
7778   return pa_output_call (insn, operands[1], 0);
7780   [(set_attr "type" "call")
7781    (set (attr "length")
7782         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7783               (symbol_ref "pa_attr_length_call (insn, 0)")))])
7785 ;; powf function clobbers %fr12
7786 (define_insn "call_val_powf_pic"
7787   [(set (match_operand 0 "" "")
7788         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7789               (match_operand 2 "" "i")))
7790    (clobber (reg:SI 1))
7791    (clobber (reg:SI 2))
7792    (clobber (reg:DF 48))
7793    (clobber (match_operand 3))
7794    (use (reg:SI 19))
7795    (use (const_int 1))]
7796   "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7797   "#")
7799 ;; Split out the PIC register save and restore after reload.  As the
7800 ;; split is done after reload, there are some situations in which we
7801 ;; unnecessarily save and restore %r4.  This happens when there is a
7802 ;; single call and the PIC register is not used after the call.
7804 ;; The split has to be done since call_from_call_insn () can't handle
7805 ;; the pattern as is.  Noreturn calls are special because they have to
7806 ;; terminate the basic block.  The split has to contain more than one
7807 ;; insn.
7808 (define_split
7809   [(parallel [(set (match_operand 0 "" "")
7810               (call (mem:SI (match_operand 1 "call_operand_address" ""))
7811                     (match_operand 2 "" "")))
7812               (clobber (reg:SI 1))
7813               (clobber (reg:SI 2))
7814               (clobber (reg:DF 48))
7815               (clobber (match_operand 3))
7816               (use (reg:SI 19))
7817               (use (const_int 1))])]
7818   "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed
7819    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7820   [(set (match_dup 3) (reg:SI 19))
7821    (parallel [(set (match_dup 0)
7822               (call (mem:SI (match_dup 1))
7823                     (match_dup 2)))
7824               (clobber (reg:SI 1))
7825               (clobber (reg:SI 2))
7826               (clobber (reg:DF 48))
7827               (use (reg:SI 19))
7828               (use (const_int 1))])]
7829   "")
7831 (define_split
7832   [(parallel [(set (match_operand 0 "" "")
7833               (call (mem:SI (match_operand 1 "call_operand_address" ""))
7834                     (match_operand 2 "" "")))
7835               (clobber (reg:SI 1))
7836               (clobber (reg:SI 2))
7837               (clobber (reg:DF 48))
7838               (clobber (match_operand 3))
7839               (use (reg:SI 19))
7840               (use (const_int 1))])]
7841   "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
7842   [(set (match_dup 3) (reg:SI 19))
7843    (parallel [(set (match_dup 0)
7844               (call (mem:SI (match_dup 1))
7845                     (match_dup 2)))
7846               (clobber (reg:SI 1))
7847               (clobber (reg:SI 2))
7848               (clobber (reg:DF 48))
7849               (use (reg:SI 19))
7850               (use (const_int 1))])
7851    (set (reg:SI 19) (match_dup 3))]
7852   "")
7854 (define_insn "*call_val_powf_pic_post_reload"
7855   [(set (match_operand 0 "" "")
7856         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7857               (match_operand 2 "" "i")))
7858    (clobber (reg:SI 1))
7859    (clobber (reg:SI 2))
7860    (clobber (reg:DF 48))
7861    (use (reg:SI 19))
7862    (use (const_int 1))]
7863   "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7864   "*
7866   pa_output_arg_descriptor (insn);
7867   return pa_output_call (insn, operands[1], 0);
7869   [(set_attr "type" "call")
7870    (set (attr "length")
7871         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7872               (symbol_ref "pa_attr_length_call (insn, 0)")))])
7874 ;; This pattern is split if it is necessary to save and restore the
7875 ;; PIC register.
7876 (define_insn "call_val_symref_64bit"
7877   [(set (match_operand 0 "" "")
7878         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7879               (match_operand 2 "" "i")))
7880    (clobber (reg:DI 1))
7881    (clobber (reg:DI 2))
7882    (clobber (match_operand 3))
7883    (use (reg:DI 27))
7884    (use (reg:DI 29))
7885    (use (const_int 0))]
7886   "TARGET_64BIT"
7887   "#")
7889 ;; Split out the PIC register save and restore after reload.  As the
7890 ;; split is done after reload, there are some situations in which we
7891 ;; unnecessarily save and restore %r4.  This happens when there is a
7892 ;; single call and the PIC register is not used after the call.
7894 ;; The split has to be done since call_from_call_insn () can't handle
7895 ;; the pattern as is.  Noreturn calls are special because they have to
7896 ;; terminate the basic block.  The split has to contain more than one
7897 ;; insn.
7898 (define_split
7899   [(parallel [(set (match_operand 0 "" "")
7900               (call (mem:SI (match_operand 1 "call_operand_address" ""))
7901                     (match_operand 2 "" "")))
7902               (clobber (reg:DI 1))
7903               (clobber (reg:DI 2))
7904               (clobber (match_operand 3))
7905               (use (reg:DI 27))
7906               (use (reg:DI 29))
7907               (use (const_int 0))])]
7908   "TARGET_64BIT && reload_completed
7909    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7910   [(set (match_dup 3) (reg:DI 27))
7911    (parallel [(set (match_dup 0)
7912               (call (mem:SI (match_dup 1))
7913                     (match_dup 2)))
7914               (clobber (reg:DI 1))
7915               (clobber (reg:DI 2))
7916               (use (reg:DI 27))
7917               (use (reg:DI 29))
7918               (use (const_int 0))])]
7919   "")
7921 (define_split
7922   [(parallel [(set (match_operand 0 "" "")
7923               (call (mem:SI (match_operand 1 "call_operand_address" ""))
7924                     (match_operand 2 "" "")))
7925               (clobber (reg:DI 1))
7926               (clobber (reg:DI 2))
7927               (clobber (match_operand 3))
7928               (use (reg:DI 27))
7929               (use (reg:DI 29))
7930               (use (const_int 0))])]
7931   "TARGET_64BIT && reload_completed"
7932   [(set (match_dup 3) (reg:DI 27))
7933    (parallel [(set (match_dup 0)
7934               (call (mem:SI (match_dup 1))
7935                     (match_dup 2)))
7936               (clobber (reg:DI 1))
7937               (clobber (reg:DI 2))
7938               (use (reg:DI 27))
7939               (use (reg:DI 29))
7940               (use (const_int 0))])
7941    (set (reg:DI 27) (match_dup 3))]
7942   "")
7944 (define_insn "*call_val_symref_64bit_post_reload"
7945   [(set (match_operand 0 "" "")
7946         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7947               (match_operand 2 "" "i")))
7948    (clobber (reg:DI 1))
7949    (clobber (reg:DI 2))
7950    (use (reg:DI 27))
7951    (use (reg:DI 29))
7952    (use (const_int 0))]
7953   "TARGET_64BIT"
7954   "*
7956   return pa_output_call (insn, operands[1], 0);
7958   [(set_attr "type" "call")
7959    (set (attr "length")
7960         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7961               (symbol_ref "pa_attr_length_call (insn, 0)")))])
7963 ;; powf function clobbers %fr12
7964 (define_insn "call_val_powf_64bit"
7965   [(set (match_operand 0 "" "")
7966         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7967               (match_operand 2 "" "i")))
7968    (clobber (reg:DI 1))
7969    (clobber (reg:DI 2))
7970    (clobber (reg:DF 40))
7971    (clobber (match_operand 3))
7972    (use (reg:DI 27))
7973    (use (reg:DI 29))
7974    (use (const_int 1))]
7975   "TARGET_64BIT && TARGET_HPUX"
7976   "#")
7978 ;; Split out the PIC register save and restore after reload.  As the
7979 ;; split is done after reload, there are some situations in which we
7980 ;; unnecessarily save and restore %r4.  This happens when there is a
7981 ;; single call and the PIC register is not used after the call.
7983 ;; The split has to be done since call_from_call_insn () can't handle
7984 ;; the pattern as is.  Noreturn calls are special because they have to
7985 ;; terminate the basic block.  The split has to contain more than one
7986 ;; insn.
7987 (define_split
7988   [(parallel [(set (match_operand 0 "" "")
7989               (call (mem:SI (match_operand 1 "call_operand_address" ""))
7990                     (match_operand 2 "" "")))
7991               (clobber (reg:DI 1))
7992               (clobber (reg:DI 2))
7993               (clobber (reg:DF 40))
7994               (clobber (match_operand 3))
7995               (use (reg:DI 27))
7996               (use (reg:DI 29))
7997               (use (const_int 1))])]
7998   "TARGET_64BIT && TARGET_HPUX && reload_completed
7999    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8000   [(set (match_dup 3) (reg:DI 27))
8001    (parallel [(set (match_dup 0)
8002               (call (mem:SI (match_dup 1))
8003                     (match_dup 2)))
8004               (clobber (reg:DI 1))
8005               (clobber (reg:DI 2))
8006               (clobber (reg:DF 40))
8007               (use (reg:DI 27))
8008               (use (reg:DI 29))
8009               (use (const_int 1))])]
8010   "")
8012 (define_split
8013   [(parallel [(set (match_operand 0 "" "")
8014               (call (mem:SI (match_operand 1 "call_operand_address" ""))
8015                     (match_operand 2 "" "")))
8016               (clobber (reg:DI 1))
8017               (clobber (reg:DI 2))
8018               (clobber (reg:DF 40))
8019               (clobber (match_operand 3))
8020               (use (reg:DI 27))
8021               (use (reg:DI 29))
8022               (use (const_int 1))])]
8023   "TARGET_64BIT && TARGET_HPUX && reload_completed"
8024   [(set (match_dup 3) (reg:DI 27))
8025    (parallel [(set (match_dup 0)
8026               (call (mem:SI (match_dup 1))
8027                     (match_dup 2)))
8028               (clobber (reg:DI 1))
8029               (clobber (reg:DI 2))
8030               (clobber (reg:DF 40))
8031               (use (reg:DI 27))
8032               (use (reg:DI 29))
8033               (use (const_int 1))])
8034    (set (reg:DI 27) (match_dup 3))]
8035   "")
8037 (define_insn "*call_val_powf_64bit_post_reload"
8038   [(set (match_operand 0 "" "")
8039         (call (mem:SI (match_operand 1 "call_operand_address" ""))
8040               (match_operand 2 "" "i")))
8041    (clobber (reg:DI 1))
8042    (clobber (reg:DI 2))
8043    (clobber (reg:DF 40))
8044    (use (reg:DI 27))
8045    (use (reg:DI 29))
8046    (use (const_int 1))]
8047   "TARGET_64BIT && TARGET_HPUX"
8048   "*
8050   return pa_output_call (insn, operands[1], 0);
8052   [(set_attr "type" "call")
8053    (set (attr "length")
8054         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8055               (symbol_ref "pa_attr_length_call (insn, 0)")))])
8057 (define_insn "call_val_reg"
8058   [(set (match_operand 0 "" "")
8059         (call (mem:SI (reg:SI 22))
8060               (match_operand 1 "" "i")))
8061    (clobber (reg:SI 1))
8062    (clobber (reg:SI 2))
8063    (use (const_int 1))]
8064   "!TARGET_64BIT"
8065   "*
8067   return pa_output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
8069   [(set_attr "type" "dyncall")
8070    (set (attr "length")
8071         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8072               (symbol_ref "pa_attr_length_indirect_call (insn)")))])
8074 ;; This pattern is split if it is necessary to save and restore the
8075 ;; PIC register.
8076 (define_insn "call_val_reg_pic"
8077   [(set (match_operand 0 "" "")
8078         (call (mem:SI (reg:SI 22))
8079               (match_operand 1 "" "i")))
8080    (clobber (reg:SI 1))
8081    (clobber (reg:SI 2))
8082    (clobber (match_operand 2))
8083    (use (reg:SI 19))
8084    (use (const_int 1))]
8085   "!TARGET_64BIT"
8086   "#")
8088 ;; Split out the PIC register save and restore after reload.  As the
8089 ;; split is done after reload, there are some situations in which we
8090 ;; unnecessarily save and restore %r4.  This happens when there is a
8091 ;; single call and the PIC register is not used after the call.
8093 ;; The split has to be done since call_from_call_insn () can't handle
8094 ;; the pattern as is.  Noreturn calls are special because they have to
8095 ;; terminate the basic block.  The split has to contain more than one
8096 ;; insn.
8097 (define_split
8098   [(parallel [(set (match_operand 0 "" "")
8099                    (call (mem:SI (reg:SI 22))
8100                          (match_operand 1 "" "")))
8101               (clobber (reg:SI 1))
8102               (clobber (reg:SI 2))
8103               (clobber (match_operand 2))
8104               (use (reg:SI 19))
8105               (use (const_int 1))])]
8106   "!TARGET_64BIT && reload_completed
8107    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8108   [(set (match_dup 2) (reg:SI 19))
8109    (parallel [(set (match_dup 0)
8110                    (call (mem:SI (reg:SI 22))
8111                          (match_dup 1)))
8112               (clobber (reg:SI 1))
8113               (clobber (reg:SI 2))
8114               (use (reg:SI 19))
8115               (use (const_int 1))])]
8116   "")
8118 (define_split
8119   [(parallel [(set (match_operand 0 "" "")
8120                    (call (mem:SI (reg:SI 22))
8121                          (match_operand 1 "" "")))
8122               (clobber (reg:SI 1))
8123               (clobber (reg:SI 2))
8124               (clobber (match_operand 2))
8125               (use (reg:SI 19))
8126               (use (const_int 1))])]
8127   "!TARGET_64BIT && reload_completed"
8128   [(set (match_dup 2) (reg:SI 19))
8129    (parallel [(set (match_dup 0)
8130                    (call (mem:SI (reg:SI 22))
8131                          (match_dup 1)))
8132               (clobber (reg:SI 1))
8133               (clobber (reg:SI 2))
8134               (use (reg:SI 19))
8135               (use (const_int 1))])
8136    (set (reg:SI 19) (match_dup 2))]
8137   "")
8139 (define_insn "*call_val_reg_pic_post_reload"
8140   [(set (match_operand 0 "" "")
8141         (call (mem:SI (reg:SI 22))
8142               (match_operand 1 "" "i")))
8143    (clobber (reg:SI 1))
8144    (clobber (reg:SI 2))
8145    (use (reg:SI 19))
8146    (use (const_int 1))]
8147   "!TARGET_64BIT"
8148   "*
8150   return pa_output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
8152   [(set_attr "type" "dyncall")
8153    (set (attr "length")
8154         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8155               (symbol_ref "pa_attr_length_indirect_call (insn)")))])
8157 ;; This pattern is split if it is necessary to save and restore the
8158 ;; PIC register.
8159 (define_insn "call_val_reg_64bit"
8160   [(set (match_operand 0 "" "")
8161         (call (mem:SI (match_operand:DI 1 "register_operand" "r"))
8162               (match_operand 2 "" "i")))
8163    (clobber (reg:DI 2))
8164    (clobber (match_operand 3))
8165    (use (reg:DI 27))
8166    (use (reg:DI 29))
8167    (use (const_int 1))]
8168   "TARGET_64BIT"
8169   "#")
8171 ;; Split out the PIC register save and restore after reload.  As the
8172 ;; split is done after reload, there are some situations in which we
8173 ;; unnecessarily save and restore %r4.  This happens when there is a
8174 ;; single call and the PIC register is not used after the call.
8176 ;; The split has to be done since call_from_call_insn () can't handle
8177 ;; the pattern as is.  Noreturn calls are special because they have to
8178 ;; terminate the basic block.  The split has to contain more than one
8179 ;; insn.
8180 (define_split
8181   [(parallel [(set (match_operand 0 "" "")
8182                    (call (mem:SI (match_operand:DI 1 "register_operand" ""))
8183                          (match_operand 2 "" "")))
8184               (clobber (reg:DI 2))
8185               (clobber (match_operand 3))
8186               (use (reg:DI 27))
8187               (use (reg:DI 29))
8188               (use (const_int 1))])]
8189   "TARGET_64BIT && reload_completed
8190    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8191   [(set (match_dup 3) (reg:DI 27))
8192    (parallel [(set (match_dup 0)
8193                    (call (mem:SI (match_dup 1))
8194                          (match_dup 2)))
8195               (clobber (reg:DI 2))
8196               (use (reg:DI 27))
8197               (use (reg:DI 29))
8198               (use (const_int 1))])]
8199   "")
8201 (define_split
8202   [(parallel [(set (match_operand 0 "" "")
8203                    (call (mem:SI (match_operand:DI 1 "register_operand" ""))
8204                          (match_operand 2 "" "")))
8205               (clobber (reg:DI 2))
8206               (clobber (match_operand 3))
8207               (use (reg:DI 27))
8208               (use (reg:DI 29))
8209               (use (const_int 1))])]
8210   "TARGET_64BIT && reload_completed"
8211   [(set (match_dup 3) (reg:DI 27))
8212    (parallel [(set (match_dup 0)
8213                    (call (mem:SI (match_dup 1))
8214                          (match_dup 2)))
8215               (clobber (reg:DI 2))
8216               (use (reg:DI 27))
8217               (use (reg:DI 29))
8218               (use (const_int 1))])
8219    (set (reg:DI 27) (match_dup 3))]
8220   "")
8222 (define_insn "*call_val_reg_64bit_post_reload"
8223   [(set (match_operand 0 "" "")
8224         (call (mem:SI (match_operand:DI 1 "register_operand" "r"))
8225               (match_operand 2 "" "i")))
8226    (clobber (reg:DI 2))
8227    (use (reg:DI 27))
8228    (use (reg:DI 29))
8229    (use (const_int 1))]
8230   "TARGET_64BIT"
8231   "*
8233   return pa_output_indirect_call (insn, operands[1]);
8235   [(set_attr "type" "dyncall")
8236    (set (attr "length")
8237         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 12)]
8238               (symbol_ref "pa_attr_length_indirect_call (insn)")))])
8240 /* Expand special pc-relative call to _mcount.  */
8242 (define_expand "call_mcount"
8243   [(parallel [(call (match_operand:SI 0 "" "")
8244                     (match_operand 1 "" ""))
8245               (set (reg:SI 25)
8246                    (plus:SI (reg:SI 2)
8247                             (minus:SI (match_operand 2 "" "")
8248                                       (plus:SI (pc) (const_int 4)))))
8249               (clobber (reg:SI 2))])]
8250   "!TARGET_PORTABLE_RUNTIME"
8251   "
8253   rtx op = XEXP (operands[0], 0);
8254   rtx nb = operands[1];
8255   rtx lab = operands[2];
8257   if (TARGET_64BIT)
8258     {
8259       rtx r4 = gen_rtx_REG (word_mode, 4);
8260       emit_move_insn (arg_pointer_rtx,
8261                       gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
8262                                     GEN_INT (64)));
8263       emit_call_insn (gen_call_mcount_64bit (op, nb, lab, r4));
8264     }
8265   else
8266     {
8267       if (flag_pic)
8268         {
8269           rtx r4 = gen_rtx_REG (word_mode, 4);
8270           emit_call_insn (gen_call_mcount_pic (op, nb, lab, r4));
8271         }
8272       else
8273         emit_call_insn (gen_call_mcount_nonpic (op, nb, lab));
8274     }
8276   DONE;
8279 (define_insn "call_mcount_nonpic"
8280   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8281          (match_operand 1 "" "i"))
8282    (set (reg:SI 25)
8283         (plus:SI (reg:SI 2)
8284                  (minus:SI (match_operand 2 "" "")
8285                            (plus:SI (pc) (const_int 4)))))
8286    (clobber (reg:SI 2))]
8287   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8288   "*
8290   pa_output_arg_descriptor (insn);
8291   return \"{bl|b,l} %0,%%r2\;ldo %2-.-4(%%r2),%%r25\";
8293   [(set_attr "type" "multi")
8294    (set_attr "length" "8")])
8296 (define_insn "call_mcount_pic"
8297   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8298          (match_operand 1 "" "i"))
8299    (set (reg:SI 25)
8300         (plus:SI (reg:SI 2)
8301                  (minus:SI (match_operand 2 "" "")
8302                            (plus:SI (pc) (const_int 4)))))
8303    (clobber (reg:SI 2))
8304    (clobber (match_operand 3))
8305    (use (reg:SI 19))]
8306   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8307   "#")
8309 (define_split
8310   [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8311                     (match_operand 1 "" ""))
8312               (set (reg:SI 25)
8313                    (plus:SI (reg:SI 2)
8314                             (minus:SI (match_operand 2 "" "")
8315                                       (plus:SI (pc) (const_int 4)))))
8316               (clobber (reg:SI 2))
8317               (clobber (match_operand 3))
8318               (use (reg:SI 19))])]
8319   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
8320   [(set (match_dup 3) (reg:SI 19))
8321    (parallel [(call (mem:SI (match_dup 0))
8322                     (match_dup 1))
8323               (set (reg:SI 25)
8324                    (plus:SI (reg:SI 2)
8325                             (minus:SI (match_dup 2)
8326                                       (plus:SI (pc) (const_int 4)))))
8327               (clobber (reg:SI 2))
8328               (use (reg:SI 19))])
8329    (set (reg:SI 19) (match_dup 3))]
8330   "")
8332 (define_insn "*call_mcount_pic_post_reload"
8333   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8334          (match_operand 1 "" "i"))
8335    (set (reg:SI 25)
8336         (plus:SI (reg:SI 2)
8337                  (minus:SI (match_operand 2 "" "")
8338                            (plus:SI (pc) (const_int 4)))))
8339    (clobber (reg:SI 2))
8340    (use (reg:SI 19))]
8341   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8342   "*
8344   pa_output_arg_descriptor (insn);
8345   return \"{bl|b,l} %0,%%r2\;ldo %2-.-4(%%r2),%%r25\";
8347   [(set_attr "type" "multi")
8348    (set_attr "length" "8")])
8350 (define_insn "call_mcount_64bit"
8351   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8352          (match_operand 1 "" "i"))
8353    (set (reg:SI 25)
8354         (plus:SI (reg:SI 2)
8355                  (minus:SI (match_operand 2 "" "")
8356                            (plus:SI (pc) (const_int 4)))))
8357    (clobber (reg:DI 2))
8358    (clobber (match_operand 3))
8359    (use (reg:DI 27))
8360    (use (reg:DI 29))]
8361   "TARGET_64BIT"
8362   "#")
8364 (define_split
8365   [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8366                     (match_operand 1 "" ""))
8367               (set (reg:SI 25)
8368                    (plus:SI (reg:SI 2)
8369                             (minus:SI (match_operand 2 "" "")
8370                                       (plus:SI (pc) (const_int 4)))))
8371               (clobber (reg:DI 2))
8372               (clobber (match_operand 3))
8373               (use (reg:DI 27))
8374               (use (reg:DI 29))])]
8375   "TARGET_64BIT && reload_completed"
8376   [(set (match_dup 3) (reg:DI 27))
8377    (parallel [(call (mem:SI (match_dup 0))
8378                     (match_dup 1))
8379               (set (reg:SI 25)
8380                    (plus:SI (reg:SI 2)
8381                             (minus:SI (match_dup 2)
8382                                       (plus:SI (pc) (const_int 4)))))
8383               (clobber (reg:DI 2))
8384               (use (reg:DI 27))
8385               (use (reg:DI 29))])
8386    (set (reg:DI 27) (match_dup 3))]
8387   "")
8389 (define_insn "*call_mcount_64bit_post_reload"
8390   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8391          (match_operand 1 "" "i"))
8392    (set (reg:SI 25)
8393         (plus:SI (reg:SI 2)
8394                  (minus:SI (match_operand 2 "" "")
8395                            (plus:SI (pc) (const_int 4)))))
8396    (clobber (reg:DI 2))
8397    (use (reg:DI 27))
8398    (use (reg:DI 29))]
8399   "TARGET_64BIT"
8400   "{bl|b,l} %0,%%r2\;ldo %2-.-4(%%r2),%%r25"
8401   [(set_attr "type" "multi")
8402    (set_attr "length" "8")])
8404 ;; Call subroutine returning any type.
8406 (define_expand "untyped_call"
8407   [(parallel [(call (match_operand 0 "" "")
8408                     (const_int 0))
8409               (match_operand 1 "" "")
8410               (match_operand 2 "" "")])]
8411   ""
8412   "
8414   int i;
8416   emit_call_insn (gen_call (operands[0], const0_rtx));
8418   for (i = 0; i < XVECLEN (operands[2], 0); i++)
8419     {
8420       rtx set = XVECEXP (operands[2], 0, i);
8421       emit_move_insn (SET_DEST (set), SET_SRC (set));
8422     }
8424   /* The optimizer does not know that the call sets the function value
8425      registers we stored in the result block.  We avoid problems by
8426      claiming that all hard registers are used and clobbered at this
8427      point.  */
8428   emit_insn (gen_blockage ());
8430   DONE;
8433 (define_expand "sibcall"
8434   [(call (match_operand:SI 0 "" "")
8435          (match_operand 1 "" ""))]
8436   "!TARGET_PORTABLE_RUNTIME"
8437   "
8439   rtx op, call_insn;
8440   rtx nb = operands[1];
8442   op = XEXP (operands[0], 0);
8444   if (TARGET_64BIT)
8445     {
8446       if (!virtuals_instantiated)
8447         emit_move_insn (arg_pointer_rtx,
8448                         gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
8449                                       GEN_INT (64)));
8450       else
8451         {
8452           /* The loop pass can generate new libcalls after the virtual
8453              registers are instantiated when fpregs are disabled because
8454              the only method that we have for doing DImode multiplication
8455              is with a libcall.  This could be trouble if we haven't
8456              allocated enough space for the outgoing arguments.  */
8457           gcc_assert (INTVAL (nb) <= crtl->outgoing_args_size);
8459           emit_move_insn (arg_pointer_rtx,
8460                           gen_rtx_PLUS (word_mode, stack_pointer_rtx,
8461                                         GEN_INT (STACK_POINTER_OFFSET + 64)));
8462         }
8463     }
8465   /* Indirect sibling calls are not allowed.  */
8466   if (TARGET_64BIT)
8467     call_insn = gen_sibcall_internal_symref_64bit (op, operands[1]);
8468   else
8469     call_insn = gen_sibcall_internal_symref (op, operands[1]);
8471   call_insn = emit_call_insn (call_insn);
8473   if (TARGET_64BIT)
8474     use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), arg_pointer_rtx);
8476   /* We don't have to restore the PIC register.  */
8477   if (flag_pic)
8478     use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
8480   DONE;
8483 (define_insn "sibcall_internal_symref"
8484   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8485          (match_operand 1 "" "i"))
8486    (clobber (reg:SI 1))
8487    (use (reg:SI 2))
8488    (use (const_int 0))]
8489   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8490   "*
8492   pa_output_arg_descriptor (insn);
8493   return pa_output_call (insn, operands[0], 1);
8495   [(set_attr "type" "sibcall")
8496    (set (attr "length")
8497         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8498               (symbol_ref "pa_attr_length_call (insn, 1)")))])
8500 (define_insn "sibcall_internal_symref_64bit"
8501   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8502          (match_operand 1 "" "i"))
8503    (clobber (reg:DI 1))
8504    (use (reg:DI 2))
8505    (use (const_int 0))]
8506   "TARGET_64BIT"
8507   "*
8509   return pa_output_call (insn, operands[0], 1);
8511   [(set_attr "type" "sibcall")
8512    (set (attr "length")
8513         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8514               (symbol_ref "pa_attr_length_call (insn, 1)")))])
8516 (define_expand "sibcall_value"
8517   [(set (match_operand 0 "" "")
8518                    (call (match_operand:SI 1 "" "")
8519                          (match_operand 2 "" "")))]
8520   "!TARGET_PORTABLE_RUNTIME"
8521   "
8523   rtx op, call_insn;
8524   rtx nb = operands[1];
8526   op = XEXP (operands[1], 0);
8528   if (TARGET_64BIT)
8529     {
8530       if (!virtuals_instantiated)
8531         emit_move_insn (arg_pointer_rtx,
8532                         gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
8533                                       GEN_INT (64)));
8534       else
8535         {
8536           /* The loop pass can generate new libcalls after the virtual
8537              registers are instantiated when fpregs are disabled because
8538              the only method that we have for doing DImode multiplication
8539              is with a libcall.  This could be trouble if we haven't
8540              allocated enough space for the outgoing arguments.  */
8541           gcc_assert (INTVAL (nb) <= crtl->outgoing_args_size);
8543           emit_move_insn (arg_pointer_rtx,
8544                           gen_rtx_PLUS (word_mode, stack_pointer_rtx,
8545                                         GEN_INT (STACK_POINTER_OFFSET + 64)));
8546         }
8547     }
8549   /* Indirect sibling calls are not allowed.  */
8550   if (TARGET_64BIT)
8551     call_insn
8552       = gen_sibcall_value_internal_symref_64bit (operands[0], op, operands[2]);
8553   else
8554     call_insn
8555       = gen_sibcall_value_internal_symref (operands[0], op, operands[2]);
8557   call_insn = emit_call_insn (call_insn);
8559   if (TARGET_64BIT)
8560     use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), arg_pointer_rtx);
8562   /* We don't have to restore the PIC register.  */
8563   if (flag_pic)
8564     use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
8566   DONE;
8569 (define_insn "sibcall_value_internal_symref"
8570   [(set (match_operand 0 "" "")
8571         (call (mem:SI (match_operand 1 "call_operand_address" ""))
8572               (match_operand 2 "" "i")))
8573    (clobber (reg:SI 1))
8574    (use (reg:SI 2))
8575    (use (const_int 0))]
8576   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8577   "*
8579   pa_output_arg_descriptor (insn);
8580   return pa_output_call (insn, operands[1], 1);
8582   [(set_attr "type" "sibcall")
8583    (set (attr "length")
8584         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8585               (symbol_ref "pa_attr_length_call (insn, 1)")))])
8587 (define_insn "sibcall_value_internal_symref_64bit"
8588   [(set (match_operand 0 "" "")
8589         (call (mem:SI (match_operand 1 "call_operand_address" ""))
8590               (match_operand 2 "" "i")))
8591    (clobber (reg:DI 1))
8592    (use (reg:DI 2))
8593    (use (const_int 0))]
8594   "TARGET_64BIT"
8595   "*
8597   return pa_output_call (insn, operands[1], 1);
8599   [(set_attr "type" "sibcall")
8600    (set (attr "length")
8601         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8602               (symbol_ref "pa_attr_length_call (insn, 1)")))])
8604 (define_insn "nop"
8605   [(const_int 0)]
8606   ""
8607   "nop"
8608   [(set_attr "type" "move")
8609    (set_attr "length" "4")])
8611 ;;; EH does longjmp's from and within the data section.  Thus,
8612 ;;; an interspace branch is required for the longjmp implementation.
8613 ;;; Registers r1 and r2 are used as scratch registers for the jump
8614 ;;; when necessary.
8615 (define_expand "interspace_jump"
8616   [(parallel
8617      [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8618       (clobber (match_dup 1))])]
8619   ""
8620   "
8622   operands[1] = gen_rtx_REG (word_mode, 2);
8625 (define_insn ""
8626   [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8627   (clobber (reg:SI 2))]
8628   "TARGET_PA_20 && !TARGET_64BIT"
8629   "bve%* (%0)"
8630    [(set_attr "type" "branch")
8631     (set_attr "length" "4")])
8633 (define_insn ""
8634   [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8635   (clobber (reg:SI 2))]
8636   "TARGET_NO_SPACE_REGS && !TARGET_64BIT"
8637   "be%* 0(%%sr4,%0)"
8638    [(set_attr "type" "branch")
8639     (set_attr "length" "4")])
8641 (define_insn ""
8642   [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8643   (clobber (reg:SI 2))]
8644   "!TARGET_64BIT"
8645   "ldsid (%%sr0,%0),%%r2\;mtsp %%r2,%%sr0\;be%* 0(%%sr0,%0)"
8646    [(set_attr "type" "branch")
8647     (set_attr "length" "12")])
8649 (define_insn ""
8650   [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8651   (clobber (reg:DI 2))]
8652   "TARGET_64BIT"
8653   "bve%* (%0)"
8654    [(set_attr "type" "branch")
8655     (set_attr "length" "4")])
8657 (define_expand "builtin_longjmp"
8658   [(unspec_volatile [(match_operand 0 "register_operand" "r")] UNSPECV_LONGJMP)]
8659   ""
8660   "
8662   /* The elements of the buffer are, in order:  */
8663   rtx fp = gen_rtx_MEM (Pmode, operands[0]);
8664   rtx lab = gen_rtx_MEM (Pmode, plus_constant (Pmode, operands[0],
8665                          POINTER_SIZE / BITS_PER_UNIT));
8666   rtx stack = gen_rtx_MEM (Pmode, plus_constant (Pmode, operands[0],
8667                            (POINTER_SIZE * 2) / BITS_PER_UNIT));
8668   rtx pv = gen_rtx_REG (Pmode, 1);
8670   emit_clobber (gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (VOIDmode)));
8671   emit_clobber (gen_rtx_MEM (BLKmode, hard_frame_pointer_rtx));
8673   /* Restore the frame pointer.  The virtual_stack_vars_rtx is saved
8674      instead of the hard_frame_pointer_rtx in the save area.  We need
8675      to adjust for the offset between these two values.  */
8676   if (GET_CODE (fp) != REG)
8677     fp = force_reg (Pmode, fp);
8678   emit_move_insn (hard_frame_pointer_rtx, plus_constant (Pmode, fp, -8));
8680   /* This bit is the same as expand_builtin_longjmp.  */
8681   emit_stack_restore (SAVE_NONLOCAL, stack);
8682   emit_use (hard_frame_pointer_rtx);
8683   emit_use (stack_pointer_rtx);
8685   /* Load the label we are jumping through into r1 so that we know
8686      where to look for it when we get back to setjmp's function for
8687      restoring the gp.  */
8688   emit_move_insn (pv, lab);
8690   /* Prevent the insns above from being scheduled into the delay slot
8691      of the interspace jump because the space register could change.  */
8692   emit_insn (gen_blockage ());
8694   emit_jump_insn (gen_interspace_jump (pv));
8695   emit_barrier ();
8696   DONE;
8699 ;;; Operands 2 and 3 are assumed to be CONST_INTs.
8700 (define_expand "extzvsi"
8701   [(set (match_operand:SI 0 "register_operand" "")
8702         (zero_extract:SI (match_operand:SI 1 "register_operand" "")
8703                          (match_operand:SI 2 "uint5_operand" "")
8704                          (match_operand:SI 3 "uint5_operand" "")))]
8705   ""
8706   "
8708   unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
8709   unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
8711   /* PA extraction insns don't support zero length bitfields or fields
8712      extending beyond the left or right-most bits.  Also, the predicate
8713      rejects lengths equal to a word as they are better handled by
8714      the move patterns.  */
8715   if (len == 0 || pos + len > 32)
8716     FAIL;
8718   /* From mips.md: extract_bit_field doesn't verify that our source
8719      matches the predicate, so check it again here.  */
8720   if (!register_operand (operands[1], VOIDmode))
8721     FAIL;
8723   emit_insn (gen_extzv_32 (operands[0], operands[1],
8724                            operands[2], operands[3]));
8725   DONE;
8728 (define_insn "extzv_32"
8729   [(set (match_operand:SI 0 "register_operand" "=r")
8730         (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
8731                          (match_operand:SI 2 "uint5_operand" "")
8732                          (match_operand:SI 3 "uint5_operand" "")))]
8733   "UINTVAL (operands[2]) > 0
8734    && UINTVAL (operands[2]) + UINTVAL (operands[3]) <= 32"
8735   "{extru|extrw,u} %1,%3+%2-1,%2,%0"
8736   [(set_attr "type" "shift")
8737    (set_attr "length" "4")])
8739 (define_insn ""
8740   [(set (match_operand:SI 0 "register_operand" "=r")
8741         (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
8742                          (const_int 1)
8743                          (match_operand:SI 2 "register_operand" "q")))]
8744   ""
8745   "{vextru %1,1,%0|extrw,u %1,%%sar,1,%0}"
8746   [(set_attr "type" "shift")
8747    (set_attr "length" "4")])
8749 (define_expand "extzvdi"
8750   [(set (match_operand:DI 0 "register_operand" "")
8751         (zero_extract:DI (match_operand:DI 1 "register_operand" "")
8752                          (match_operand:DI 2 "uint6_operand" "")
8753                          (match_operand:DI 3 "uint6_operand" "")))]
8754   "TARGET_64BIT"
8755   "
8757   unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
8758   unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
8760   /* PA extraction insns don't support zero length bitfields or fields
8761      extending beyond the left or right-most bits.  Also, the predicate
8762      rejects lengths equal to a doubleword as they are better handled by
8763      the move patterns.  */
8764   if (len == 0 || pos + len > 64)
8765     FAIL;
8767   /* From mips.md: extract_bit_field doesn't verify that our source
8768      matches the predicate, so check it again here.  */
8769   if (!register_operand (operands[1], VOIDmode))
8770     FAIL;
8772   emit_insn (gen_extzv_64 (operands[0], operands[1],
8773                            operands[2], operands[3]));
8774   DONE;
8777 (define_insn "extzv_64"
8778   [(set (match_operand:DI 0 "register_operand" "=r")
8779         (zero_extract:DI (match_operand:DI 1 "register_operand" "r")
8780                          (match_operand:DI 2 "uint6_operand" "")
8781                          (match_operand:DI 3 "uint6_operand" "")))]
8782   "TARGET_64BIT
8783    && UINTVAL (operands[2]) > 0
8784    && UINTVAL (operands[2]) + UINTVAL (operands[3]) <= 64"
8785   "extrd,u %1,%3+%2-1,%2,%0"
8786   [(set_attr "type" "shift")
8787    (set_attr "length" "4")])
8789 (define_insn ""
8790   [(set (match_operand:DI 0 "register_operand" "=r")
8791         (zero_extract:DI (match_operand:DI 1 "register_operand" "r")
8792                          (const_int 1)
8793                          (match_operand:DI 2 "register_operand" "q")))]
8794   "TARGET_64BIT"
8795   "extrd,u %1,%%sar,1,%0"
8796   [(set_attr "type" "shift")
8797    (set_attr "length" "4")])
8799 ;;; Operands 2 and 3 are assumed to be CONST_INTs.
8800 (define_expand "extvsi"
8801   [(set (match_operand:SI 0 "register_operand" "")
8802         (sign_extract:SI (match_operand:SI 1 "register_operand" "")
8803                          (match_operand:SI 2 "uint5_operand" "")
8804                          (match_operand:SI 3 "uint5_operand" "")))]
8805   ""
8806   "
8808   unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
8809   unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
8811   /* PA extraction insns don't support zero length bitfields or fields
8812      extending beyond the left or right-most bits.  Also, the predicate
8813      rejects lengths equal to a word as they are better handled by
8814      the move patterns.  */
8815   if (len == 0 || pos + len > 32)
8816     FAIL;
8818   /* From mips.md: extract_bit_field doesn't verify that our source
8819      matches the predicate, so check it again here.  */
8820   if (!register_operand (operands[1], VOIDmode))
8821     FAIL;
8823   emit_insn (gen_extv_32 (operands[0], operands[1],
8824                           operands[2], operands[3]));
8825   DONE;
8828 (define_insn "extv_32"
8829   [(set (match_operand:SI 0 "register_operand" "=r")
8830         (sign_extract:SI (match_operand:SI 1 "register_operand" "r")
8831                          (match_operand:SI 2 "uint5_operand" "")
8832                          (match_operand:SI 3 "uint5_operand" "")))]
8833   "UINTVAL (operands[2]) > 0
8834    && UINTVAL (operands[2]) + UINTVAL (operands[3]) <= 32"
8835   "{extrs|extrw,s} %1,%3+%2-1,%2,%0"
8836   [(set_attr "type" "shift")
8837    (set_attr "length" "4")])
8839 (define_insn ""
8840   [(set (match_operand:SI 0 "register_operand" "=r")
8841         (sign_extract:SI (match_operand:SI 1 "register_operand" "r")
8842                          (const_int 1)
8843                          (match_operand:SI 2 "register_operand" "q")))]
8844   "!TARGET_64BIT"
8845   "{vextrs %1,1,%0|extrw,s %1,%%sar,1,%0}"
8846   [(set_attr "type" "shift")
8847    (set_attr "length" "4")])
8849 (define_expand "extvdi"
8850   [(set (match_operand:DI 0 "register_operand" "")
8851         (sign_extract:DI (match_operand:DI 1 "register_operand" "")
8852                          (match_operand:DI 2 "uint6_operand" "")
8853                          (match_operand:DI 3 "uint6_operand" "")))]
8854   "TARGET_64BIT"
8855   "
8857   unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
8858   unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
8860   /* PA extraction insns don't support zero length bitfields or fields
8861      extending beyond the left or right-most bits.  Also, the predicate
8862      rejects lengths equal to a doubleword as they are better handled by
8863      the move patterns.  */
8864   if (len == 0 || pos + len > 64)
8865     FAIL;
8867   /* From mips.md: extract_bit_field doesn't verify that our source
8868      matches the predicate, so check it again here.  */
8869   if (!register_operand (operands[1], VOIDmode))
8870     FAIL;
8872   emit_insn (gen_extv_64 (operands[0], operands[1],
8873                           operands[2], operands[3]));
8874   DONE;
8877 (define_insn "extv_64"
8878   [(set (match_operand:DI 0 "register_operand" "=r")
8879         (sign_extract:DI (match_operand:DI 1 "register_operand" "r")
8880                          (match_operand:DI 2 "uint6_operand" "")
8881                          (match_operand:DI 3 "uint6_operand" "")))]
8882   "TARGET_64BIT
8883    && UINTVAL (operands[2]) > 0
8884    && UINTVAL (operands[2]) + UINTVAL (operands[3]) <= 64"
8885   "extrd,s %1,%3+%2-1,%2,%0"
8886   [(set_attr "type" "shift")
8887    (set_attr "length" "4")])
8889 (define_insn ""
8890   [(set (match_operand:DI 0 "register_operand" "=r")
8891         (sign_extract:DI (match_operand:DI 1 "register_operand" "r")
8892                          (const_int 1)
8893                          (match_operand:DI 2 "register_operand" "q")))]
8894   "TARGET_64BIT"
8895   "extrd,s %1,%%sar,1,%0"
8896   [(set_attr "type" "shift")
8897    (set_attr "length" "4")])
8899 ;;; Operands 1 and 2 are assumed to be CONST_INTs.
8900 (define_expand "insvsi"
8901   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "")
8902                          (match_operand:SI 1 "uint5_operand" "")
8903                          (match_operand:SI 2 "uint5_operand" ""))
8904         (match_operand:SI 3 "arith5_operand" ""))]
8905   ""
8906   "
8908   unsigned HOST_WIDE_INT len = UINTVAL (operands[1]);
8909   unsigned HOST_WIDE_INT pos = UINTVAL (operands[2]);
8911   /* PA insertion insns don't support zero length bitfields or fields
8912      extending beyond the left or right-most bits.  Also, the predicate
8913      rejects lengths equal to a word as they are better handled by
8914      the move patterns.  */
8915   if (len <= 0 || pos + len > 32)
8916     FAIL;
8918   /* From mips.md: insert_bit_field doesn't verify that our destination
8919      matches the predicate, so check it again here.  */
8920   if (!register_operand (operands[0], VOIDmode))
8921     FAIL;
8923   emit_insn (gen_insv_32 (operands[0], operands[1],
8924                           operands[2], operands[3]));
8925   DONE;
8928 (define_insn "insv_32"
8929   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r,r")
8930                          (match_operand:SI 1 "uint5_operand" "")
8931                          (match_operand:SI 2 "uint5_operand" ""))
8932         (match_operand:SI 3 "arith5_operand" "r,L"))]
8933   "UINTVAL (operands[1]) > 0
8934    && UINTVAL (operands[1]) + UINTVAL (operands[2]) <= 32"
8935   "@
8936    {dep|depw} %3,%2+%1-1,%1,%0
8937    {depi|depwi} %3,%2+%1-1,%1,%0"
8938   [(set_attr "type" "shift,shift")
8939    (set_attr "length" "4,4")])
8941 ;; Optimize insertion of const_int values of type 1...1xxxx.
8942 (define_insn ""
8943   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
8944                          (match_operand:SI 1 "uint5_operand" "")
8945                          (match_operand:SI 2 "uint5_operand" ""))
8946         (match_operand:SI 3 "const_int_operand" ""))]
8947   "(INTVAL (operands[3]) & 0x10) != 0 &&
8948    (~INTVAL (operands[3]) & ((1L << INTVAL (operands[1])) - 1) & ~0xf) == 0"
8949   "*
8951   operands[3] = GEN_INT ((INTVAL (operands[3]) & 0xf) - 0x10);
8952   return \"{depi|depwi} %3,%2+%1-1,%1,%0\";
8954   [(set_attr "type" "shift")
8955    (set_attr "length" "4")])
8957 (define_expand "insvdi"
8958   [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "")
8959                          (match_operand:DI 1 "uint6_operand" "")
8960                          (match_operand:DI 2 "uint6_operand" ""))
8961         (match_operand:DI 3 "arith5_operand" ""))]
8962   "TARGET_64BIT"
8963   "
8965   unsigned HOST_WIDE_INT len = UINTVAL (operands[1]);
8966   unsigned HOST_WIDE_INT pos = UINTVAL (operands[2]);
8968   /* PA insertion insns don't support zero length bitfields or fields
8969      extending beyond the left or right-most bits.  Also, the predicate
8970      rejects lengths equal to a doubleword as they are better handled by
8971      the move patterns.  */
8972   if (len <= 0 || pos + len > 64)
8973     FAIL;
8975   /* From mips.md: insert_bit_field doesn't verify that our destination
8976      matches the predicate, so check it again here.  */
8977   if (!register_operand (operands[0], VOIDmode))
8978     FAIL;
8980   emit_insn (gen_insv_64 (operands[0], operands[1],
8981                           operands[2], operands[3]));
8982   DONE;
8985 (define_insn "insv_64"
8986   [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+r,r")
8987                          (match_operand:DI 1 "uint6_operand" "")
8988                          (match_operand:DI 2 "uint6_operand" ""))
8989         (match_operand:DI 3 "arith5_operand" "r,L"))]
8990   "TARGET_64BIT
8991    && UINTVAL (operands[1]) > 0
8992    && UINTVAL (operands[1]) + UINTVAL (operands[2]) <= 64"
8993   "@
8994    depd %3,%2+%1-1,%1,%0
8995    depdi %3,%2+%1-1,%1,%0"
8996   [(set_attr "type" "shift,shift")
8997    (set_attr "length" "4,4")])
8999 ;; Optimize insertion of const_int values of type 1...1xxxx.
9000 (define_insn ""
9001   [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+r")
9002                          (match_operand:DI 1 "uint6_operand" "")
9003                          (match_operand:DI 2 "uint6_operand" ""))
9004         (match_operand:DI 3 "const_int_operand" ""))]
9005   "(INTVAL (operands[3]) & 0x10) != 0
9006    && TARGET_64BIT
9007    && (~INTVAL (operands[3]) & ((1L << INTVAL (operands[1])) - 1) & ~0xf) == 0"
9008   "*
9010   operands[3] = GEN_INT ((INTVAL (operands[3]) & 0xf) - 0x10);
9011   return \"depdi %3,%2+%1-1,%1,%0\";
9013   [(set_attr "type" "shift")
9014    (set_attr "length" "4")])
9016 (define_insn ""
9017   [(set (match_operand:DI 0 "register_operand" "=r")
9018         (ashift:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
9019                    (const_int 32)))]
9020   "TARGET_64BIT"
9021   "depd,z %1,31,32,%0"
9022   [(set_attr "type" "shift")
9023    (set_attr "length" "4")])
9025 ;; This insn is used for some loop tests, typically loops reversed when
9026 ;; strength reduction is used.  It is actually created when the instruction
9027 ;; combination phase combines the special loop test.  Since this insn
9028 ;; is both a jump insn and has an output, it must deal with its own
9029 ;; reloads, hence the `Q' constraints.  The `!' constraints direct reload
9030 ;; to not choose the register alternatives in the event a reload is needed.
9031 (define_insn "decrement_and_branch_until_zero"
9032   [(set (pc)
9033         (if_then_else
9034           (match_operator 2 "comparison_operator"
9035            [(plus:SI
9036               (match_operand:SI 0 "reg_before_reload_operand" "+!r,!*f,*Q")
9037               (match_operand:SI 1 "int5_operand" "L,L,L"))
9038             (const_int 0)])
9039           (label_ref (match_operand 3 "" ""))
9040           (pc)))
9041    (set (match_dup 0)
9042         (plus:SI (match_dup 0) (match_dup 1)))
9043    (clobber (match_scratch:SI 4 "=X,r,r"))]
9044   ""
9045   "* return pa_output_dbra (operands, insn, which_alternative); "
9046 ;; Do not expect to understand this the first time through.
9047 [(set_attr "type" "cbranch,multi,multi")
9048  (set (attr "length")
9049       (if_then_else (eq_attr "alternative" "0")
9050 ;; Loop counter in register case
9051 ;; Short branch has length of 4
9052 ;; Long branch has length of 8, 20, 24 or 28
9053         (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9054                (const_int MAX_12BIT_OFFSET))
9055            (const_int 4)
9056            (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9057                (const_int MAX_17BIT_OFFSET))
9058            (const_int 8)
9059            (match_test "TARGET_PORTABLE_RUNTIME")
9060            (const_int 24)
9061            (not (match_test "flag_pic"))
9062            (const_int 20)]
9063           (const_int 28))
9065 ;; Loop counter in FP reg case.
9066 ;; Extra goo to deal with additional reload insns.
9067         (if_then_else (eq_attr "alternative" "1")
9068           (if_then_else (lt (match_dup 3) (pc))
9069              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 24))))
9070                       (const_int MAX_12BIT_OFFSET))
9071                     (const_int 24)
9072                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 24))))
9073                       (const_int MAX_17BIT_OFFSET))
9074                     (const_int 28)
9075                     (match_test "TARGET_PORTABLE_RUNTIME")
9076                     (const_int 44)
9077                     (not (match_test "flag_pic"))
9078                     (const_int 40)]
9079                   (const_int 48))
9080              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9081                       (const_int MAX_12BIT_OFFSET))
9082                     (const_int 24)
9083                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9084                       (const_int MAX_17BIT_OFFSET))
9085                     (const_int 28)
9086                     (match_test "TARGET_PORTABLE_RUNTIME")
9087                     (const_int 44)
9088                     (not (match_test "flag_pic"))
9089                     (const_int 40)]
9090                   (const_int 48)))
9092 ;; Loop counter in memory case.
9093 ;; Extra goo to deal with additional reload insns.
9094         (if_then_else (lt (match_dup 3) (pc))
9095              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9096                       (const_int MAX_12BIT_OFFSET))
9097                     (const_int 12)
9098                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9099                       (const_int MAX_17BIT_OFFSET))
9100                     (const_int 16)
9101                     (match_test "TARGET_PORTABLE_RUNTIME")
9102                     (const_int 32)
9103                     (not (match_test "flag_pic"))
9104                     (const_int 28)]
9105                   (const_int 36))
9106              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9107                       (const_int MAX_12BIT_OFFSET))
9108                     (const_int 12)
9109                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9110                       (const_int MAX_17BIT_OFFSET))
9111                     (const_int 16)
9112                     (match_test "TARGET_PORTABLE_RUNTIME")
9113                     (const_int 32)
9114                     (not (match_test "flag_pic"))
9115                     (const_int 28)]
9116                   (const_int 36))))))])
9118 (define_insn ""
9119   [(set (pc)
9120         (if_then_else
9121           (match_operator 2 "movb_comparison_operator"
9122            [(match_operand:SI 1 "register_operand" "r,r,r,r") (const_int 0)])
9123           (label_ref (match_operand 3 "" ""))
9124           (pc)))
9125    (set (match_operand:SI 0 "reg_before_reload_operand" "=!r,!*f,*Q,!*q")
9126         (match_dup 1))]
9127   ""
9128 "* return pa_output_movb (operands, insn, which_alternative, 0); "
9129 ;; Do not expect to understand this the first time through.
9130 [(set_attr "type" "cbranch,multi,multi,multi")
9131  (set (attr "length")
9132       (if_then_else (eq_attr "alternative" "0")
9133 ;; Loop counter in register case
9134 ;; Short branch has length of 4
9135 ;; Long branch has length of 8, 20, 24 or 28
9136         (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9137                (const_int MAX_12BIT_OFFSET))
9138            (const_int 4)
9139            (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9140                (const_int MAX_17BIT_OFFSET))
9141            (const_int 8)
9142            (match_test "TARGET_PORTABLE_RUNTIME")
9143            (const_int 24)
9144            (not (match_test "flag_pic"))
9145            (const_int 20)]
9146           (const_int 28))
9148 ;; Loop counter in FP reg case.
9149 ;; Extra goo to deal with additional reload insns.
9150         (if_then_else (eq_attr "alternative" "1")
9151           (if_then_else (lt (match_dup 3) (pc))
9152              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9153                       (const_int MAX_12BIT_OFFSET))
9154                     (const_int 12)
9155                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9156                       (const_int MAX_17BIT_OFFSET))
9157                     (const_int 16)
9158                     (match_test "TARGET_PORTABLE_RUNTIME")
9159                     (const_int 32)
9160                     (not (match_test "flag_pic"))
9161                     (const_int 28)]
9162                   (const_int 36))
9163              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9164                       (const_int MAX_12BIT_OFFSET))
9165                     (const_int 12)
9166                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9167                       (const_int MAX_17BIT_OFFSET))
9168                     (const_int 16)
9169                     (match_test "TARGET_PORTABLE_RUNTIME")
9170                     (const_int 32)
9171                     (not (match_test "flag_pic"))
9172                     (const_int 28)]
9173                   (const_int 36)))
9175 ;; Loop counter in memory or sar case.
9176 ;; Extra goo to deal with additional reload insns.
9177         (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9178                    (const_int MAX_12BIT_OFFSET))
9179                 (const_int 8)
9180                 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9181                   (const_int MAX_17BIT_OFFSET))
9182                 (const_int 12)
9183                 (match_test "TARGET_PORTABLE_RUNTIME")
9184                 (const_int 28)
9185                 (not (match_test "flag_pic"))
9186                 (const_int 24)]
9187               (const_int 32)))))])
9189 ;; Handle negated branch.
9190 (define_insn ""
9191   [(set (pc)
9192         (if_then_else
9193           (match_operator 2 "movb_comparison_operator"
9194            [(match_operand:SI 1 "register_operand" "r,r,r,r") (const_int 0)])
9195           (pc)
9196           (label_ref (match_operand 3 "" ""))))
9197    (set (match_operand:SI 0 "reg_before_reload_operand" "=!r,!*f,*Q,!*q")
9198         (match_dup 1))]
9199   ""
9200 "* return pa_output_movb (operands, insn, which_alternative, 1); "
9201 ;; Do not expect to understand this the first time through.
9202 [(set_attr "type" "cbranch,multi,multi,multi")
9203  (set (attr "length")
9204       (if_then_else (eq_attr "alternative" "0")
9205 ;; Loop counter in register case
9206 ;; Short branch has length of 4
9207 ;; Long branch has length of 8
9208         (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9209                (const_int MAX_12BIT_OFFSET))
9210            (const_int 4)
9211            (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9212                (const_int MAX_17BIT_OFFSET))
9213            (const_int 8)
9214            (match_test "TARGET_PORTABLE_RUNTIME")
9215            (const_int 24)
9216            (not (match_test "flag_pic"))
9217            (const_int 20)]
9218           (const_int 28))
9220 ;; Loop counter in FP reg case.
9221 ;; Extra goo to deal with additional reload insns.
9222         (if_then_else (eq_attr "alternative" "1")
9223           (if_then_else (lt (match_dup 3) (pc))
9224              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9225                       (const_int MAX_12BIT_OFFSET))
9226                     (const_int 12)
9227                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9228                       (const_int MAX_17BIT_OFFSET))
9229                     (const_int 16)
9230                     (match_test "TARGET_PORTABLE_RUNTIME")
9231                     (const_int 32)
9232                     (not (match_test "flag_pic"))
9233                     (const_int 28)]
9234                   (const_int 36))
9235              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9236                       (const_int MAX_12BIT_OFFSET))
9237                     (const_int 12)
9238                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9239                       (const_int MAX_17BIT_OFFSET))
9240                     (const_int 16)
9241                     (match_test "TARGET_PORTABLE_RUNTIME")
9242                     (const_int 32)
9243                     (not (match_test "flag_pic"))
9244                     (const_int 28)]
9245                   (const_int 36)))
9247 ;; Loop counter in memory or SAR case.
9248 ;; Extra goo to deal with additional reload insns.
9249         (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9250                    (const_int MAX_12BIT_OFFSET))
9251                 (const_int 8)
9252                 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9253                   (const_int MAX_17BIT_OFFSET))
9254                 (const_int 12)
9255                 (match_test "TARGET_PORTABLE_RUNTIME")
9256                 (const_int 28)
9257                 (not (match_test "flag_pic"))
9258                 (const_int 24)]
9259               (const_int 32)))))])
9261 (define_insn ""
9262   [(set (pc) (label_ref (match_operand 3 "" "" )))
9263    (set (match_operand:SI 0 "ireg_operand" "=r")
9264         (plus:SI (match_operand:SI 1 "ireg_operand" "r")
9265                  (match_operand:SI 2 "ireg_or_int5_operand" "rL")))]
9266   "(reload_completed && operands[0] == operands[1]) || operands[0] == operands[2]"
9267   "*
9269   return pa_output_parallel_addb (operands, insn);
9271 [(set_attr "type" "parallel_branch")
9272  (set (attr "length")
9273     (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9274                (const_int MAX_12BIT_OFFSET))
9275            (const_int 4)
9276            (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9277                (const_int MAX_17BIT_OFFSET))
9278            (const_int 8)
9279            (match_test "TARGET_PORTABLE_RUNTIME")
9280            (const_int 24)
9281            (not (match_test "flag_pic"))
9282            (const_int 20)]
9283           (const_int 28)))])
9285 (define_insn ""
9286   [(set (pc) (label_ref (match_operand 2 "" "" )))
9287    (set (match_operand:SF 0 "ireg_operand" "=r")
9288         (match_operand:SF 1 "ireg_or_int5_operand" "rL"))]
9289   "reload_completed"
9290   "*
9292   return pa_output_parallel_movb (operands, insn);
9294 [(set_attr "type" "parallel_branch")
9295  (set (attr "length")
9296     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9297                (const_int MAX_12BIT_OFFSET))
9298            (const_int 4)
9299            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9300                (const_int MAX_17BIT_OFFSET))
9301            (const_int 8)
9302            (match_test "TARGET_PORTABLE_RUNTIME")
9303            (const_int 24)
9304            (not (match_test "flag_pic"))
9305            (const_int 20)]
9306           (const_int 28)))])
9308 (define_insn ""
9309   [(set (pc) (label_ref (match_operand 2 "" "" )))
9310    (set (match_operand:SI 0 "ireg_operand" "=r")
9311         (match_operand:SI 1 "ireg_or_int5_operand" "rL"))]
9312   "reload_completed"
9313   "*
9315   return pa_output_parallel_movb (operands, insn);
9317 [(set_attr "type" "parallel_branch")
9318  (set (attr "length")
9319     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9320                (const_int MAX_12BIT_OFFSET))
9321            (const_int 4)
9322            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9323                (const_int MAX_17BIT_OFFSET))
9324            (const_int 8)
9325            (match_test "TARGET_PORTABLE_RUNTIME")
9326            (const_int 24)
9327            (not (match_test "flag_pic"))
9328            (const_int 20)]
9329           (const_int 28)))])
9331 (define_insn ""
9332   [(set (pc) (label_ref (match_operand 2 "" "" )))
9333    (set (match_operand:HI 0 "ireg_operand" "=r")
9334         (match_operand:HI 1 "ireg_or_int5_operand" "rL"))]
9335   "reload_completed"
9336   "*
9338   return pa_output_parallel_movb (operands, insn);
9340 [(set_attr "type" "parallel_branch")
9341  (set (attr "length")
9342     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9343                (const_int MAX_12BIT_OFFSET))
9344            (const_int 4)
9345            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9346                (const_int MAX_17BIT_OFFSET))
9347            (const_int 8)
9348            (match_test "TARGET_PORTABLE_RUNTIME")
9349            (const_int 24)
9350            (not (match_test "flag_pic"))
9351            (const_int 20)]
9352           (const_int 28)))])
9354 (define_insn ""
9355   [(set (pc) (label_ref (match_operand 2 "" "" )))
9356    (set (match_operand:QI 0 "ireg_operand" "=r")
9357         (match_operand:QI 1 "ireg_or_int5_operand" "rL"))]
9358   "reload_completed"
9359   "*
9361   return pa_output_parallel_movb (operands, insn);
9363 [(set_attr "type" "parallel_branch")
9364  (set (attr "length")
9365     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9366                (const_int MAX_12BIT_OFFSET))
9367            (const_int 4)
9368            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9369                (const_int MAX_17BIT_OFFSET))
9370            (const_int 8)
9371            (match_test "TARGET_PORTABLE_RUNTIME")
9372            (const_int 24)
9373            (not (match_test "flag_pic"))
9374            (const_int 20)]
9375           (const_int 28)))])
9377 (define_insn ""
9378   [(set (match_operand 0 "register_operand" "=f")
9379         (mult (match_operand 1 "register_operand" "f")
9380               (match_operand 2 "register_operand" "f")))
9381    (set (match_operand 3 "register_operand" "+f")
9382         (plus (match_operand 4 "register_operand" "f")
9383               (match_operand 5 "register_operand" "f")))]
9384   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9385    && reload_completed && pa_fmpyaddoperands (operands)"
9386   "*
9388   if (GET_MODE (operands[0]) == DFmode)
9389     {
9390       if (rtx_equal_p (operands[3], operands[5]))
9391         return \"fmpyadd,dbl %1,%2,%0,%4,%3\";
9392       else
9393         return \"fmpyadd,dbl %1,%2,%0,%5,%3\";
9394     }
9395   else
9396     {
9397       if (rtx_equal_p (operands[3], operands[5]))
9398         return \"fmpyadd,sgl %1,%2,%0,%4,%3\";
9399       else
9400         return \"fmpyadd,sgl %1,%2,%0,%5,%3\";
9401     }
9403   [(set_attr "type" "fpalu")
9404    (set_attr "length" "4")])
9406 (define_insn ""
9407   [(set (match_operand 3 "register_operand" "+f")
9408         (plus (match_operand 4 "register_operand" "f")
9409               (match_operand 5 "register_operand" "f")))
9410    (set (match_operand 0 "register_operand" "=f")
9411         (mult (match_operand 1 "register_operand" "f")
9412               (match_operand 2 "register_operand" "f")))]
9413   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9414    && reload_completed && pa_fmpyaddoperands (operands)"
9415   "*
9417   if (GET_MODE (operands[0]) == DFmode)
9418     {
9419       if (rtx_equal_p (operands[3], operands[5]))
9420         return \"fmpyadd,dbl %1,%2,%0,%4,%3\";
9421       else
9422         return \"fmpyadd,dbl %1,%2,%0,%5,%3\";
9423     }
9424   else
9425     {
9426       if (rtx_equal_p (operands[3], operands[5]))
9427         return \"fmpyadd,sgl %1,%2,%0,%4,%3\";
9428       else
9429         return \"fmpyadd,sgl %1,%2,%0,%5,%3\";
9430     }
9432   [(set_attr "type" "fpalu")
9433    (set_attr "length" "4")])
9435 (define_insn ""
9436   [(set (match_operand 0 "register_operand" "=f")
9437         (mult (match_operand 1 "register_operand" "f")
9438               (match_operand 2 "register_operand" "f")))
9439    (set (match_operand 3 "register_operand" "+f")
9440         (minus (match_operand 4 "register_operand" "f")
9441                (match_operand 5 "register_operand" "f")))]
9442   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9443    && reload_completed && pa_fmpysuboperands (operands)"
9444   "*
9446   if (GET_MODE (operands[0]) == DFmode)
9447     return \"fmpysub,dbl %1,%2,%0,%5,%3\";
9448   else
9449     return \"fmpysub,sgl %1,%2,%0,%5,%3\";
9451   [(set_attr "type" "fpalu")
9452    (set_attr "length" "4")])
9454 (define_insn ""
9455   [(set (match_operand 3 "register_operand" "+f")
9456         (minus (match_operand 4 "register_operand" "f")
9457                (match_operand 5 "register_operand" "f")))
9458    (set (match_operand 0 "register_operand" "=f")
9459         (mult (match_operand 1 "register_operand" "f")
9460               (match_operand 2 "register_operand" "f")))]
9461   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9462    && reload_completed && pa_fmpysuboperands (operands)"
9463   "*
9465   if (GET_MODE (operands[0]) == DFmode)
9466     return \"fmpysub,dbl %1,%2,%0,%5,%3\";
9467   else
9468     return \"fmpysub,sgl %1,%2,%0,%5,%3\";
9470   [(set_attr "type" "fpalu")
9471    (set_attr "length" "4")])
9473 ;; The following two patterns are used by the trampoline code for nested
9474 ;; functions.  They flush the I and D cache lines from the start address
9475 ;; (operand0) to the end address (operand1).  No lines are flushed if the
9476 ;; end address is less than the start address (unsigned).
9478 ;; Because the range of memory flushed is variable and the size of a MEM
9479 ;; can only be a CONST_INT, the patterns specify that they perform an
9480 ;; unspecified volatile operation on all memory.
9482 ;; The address range for an icache flush must lie within a single
9483 ;; space on targets with non-equivalent space registers.
9485 ;; Operand 0 contains the start address.
9486 ;; Operand 1 contains the end address.
9487 ;; Operand 2 contains the line length to use.
9488 (define_insn "dcacheflush<P:mode>"
9489   [(const_int 1)
9490    (unspec_volatile [(mem:BLK (scratch))] UNSPECV_DCACHE)
9491    (use (match_operand 0 "pmode_register_operand" "r"))
9492    (use (match_operand 1 "pmode_register_operand" "r"))
9493    (use (match_operand 2 "pmode_register_operand" "r"))
9494    (clobber (match_scratch:P 3 "=&0"))]
9495   ""
9496   "cmpb,<dwc><<=,n %3,%1,.\;fdc,m %2(%3)\;sync"
9497   [(set_attr "type" "multi")
9498    (set_attr "length" "12")])
9500 (define_insn "icacheflush<P:mode>"
9501   [(const_int 2)
9502    (unspec_volatile [(mem:BLK (scratch))] UNSPECV_ICACHE)
9503    (use (match_operand 0 "pmode_register_operand" "r"))
9504    (use (match_operand 1 "pmode_register_operand" "r"))
9505    (use (match_operand 2 "pmode_register_operand" "r"))
9506    (clobber (match_operand 3 "pmode_register_operand" "=&r"))
9507    (clobber (match_operand 4 "pmode_register_operand" "=&r"))
9508    (clobber (match_scratch:P 5 "=&0"))]
9509   ""
9510   "mfsp %%sr0,%4\;ldsid (%5),%3\;mtsp %3,%%sr0\;cmpb,<dwc><<=,n %5,%1,.\;fic,m %2(%%sr0,%5)\;sync\;mtsp %4,%%sr0\;nop\;nop\;nop\;nop\;nop\;nop"
9511   [(set_attr "type" "multi")
9512    (set_attr "length" "52")])
9514 ;; An out-of-line prologue.
9515 (define_insn "outline_prologue_call"
9516   [(unspec_volatile [(const_int 0)] UNSPECV_OPC)
9517    (clobber (reg:SI 31))
9518    (clobber (reg:SI 22))
9519    (clobber (reg:SI 21))
9520    (clobber (reg:SI 20))
9521    (clobber (reg:SI 19))
9522    (clobber (reg:SI 1))]
9523   ""
9524   "*
9527   /* We need two different versions depending on whether or not we
9528      need a frame pointer.   Also note that we return to the instruction
9529      immediately after the branch rather than two instructions after the
9530      break as normally is the case.  */
9531   if (frame_pointer_needed)
9532     {
9533       /* Must import the magic millicode routine(s).  */
9534       output_asm_insn (\".IMPORT __outline_prologue_fp,MILLICODE\", NULL);
9536       if (TARGET_PORTABLE_RUNTIME)
9537         {
9538           output_asm_insn (\"ldil L'__outline_prologue_fp,%%r31\", NULL);
9539           output_asm_insn (\"ble,n R'__outline_prologue_fp(%%sr0,%%r31)\",
9540                            NULL);
9541         }
9542       else
9543         output_asm_insn (\"{bl|b,l},n __outline_prologue_fp,%%r31\", NULL);
9544     }
9545   else
9546     {
9547       /* Must import the magic millicode routine(s).  */
9548       output_asm_insn (\".IMPORT __outline_prologue,MILLICODE\", NULL);
9550       if (TARGET_PORTABLE_RUNTIME)
9551         {
9552           output_asm_insn (\"ldil L'__outline_prologue,%%r31\", NULL);
9553           output_asm_insn (\"ble,n R'__outline_prologue(%%sr0,%%r31)\", NULL);
9554         }
9555       else
9556         output_asm_insn (\"{bl|b,l},n __outline_prologue,%%r31\", NULL);
9557     }
9558   return \"\";
9560   [(set_attr "type" "multi")
9561    (set_attr "length" "8")])
9563 ;; An out-of-line epilogue.
9564 (define_insn "outline_epilogue_call"
9565   [(unspec_volatile [(const_int 1)] UNSPECV_OEC)
9566    (use (reg:SI 29))
9567    (use (reg:SI 28))
9568    (clobber (reg:SI 31))
9569    (clobber (reg:SI 22))
9570    (clobber (reg:SI 21))
9571    (clobber (reg:SI 20))
9572    (clobber (reg:SI 19))
9573    (clobber (reg:SI 2))
9574    (clobber (reg:SI 1))]
9575   ""
9576   "*
9579   /* We need two different versions depending on whether or not we
9580      need a frame pointer.   Also note that we return to the instruction
9581      immediately after the branch rather than two instructions after the
9582      break as normally is the case.  */
9583   if (frame_pointer_needed)
9584     {
9585       /* Must import the magic millicode routine.  */
9586       output_asm_insn (\".IMPORT __outline_epilogue_fp,MILLICODE\", NULL);
9588       /* The out-of-line prologue will make sure we return to the right
9589          instruction.  */
9590       if (TARGET_PORTABLE_RUNTIME)
9591         {
9592           output_asm_insn (\"ldil L'__outline_epilogue_fp,%%r31\", NULL);
9593           output_asm_insn (\"ble,n R'__outline_epilogue_fp(%%sr0,%%r31)\",
9594                            NULL);
9595         }
9596       else
9597         output_asm_insn (\"{bl|b,l},n __outline_epilogue_fp,%%r31\", NULL);
9598     }
9599   else
9600     {
9601       /* Must import the magic millicode routine.  */
9602       output_asm_insn (\".IMPORT __outline_epilogue,MILLICODE\", NULL);
9604       /* The out-of-line prologue will make sure we return to the right
9605          instruction.  */
9606       if (TARGET_PORTABLE_RUNTIME)
9607         {
9608           output_asm_insn (\"ldil L'__outline_epilogue,%%r31\", NULL);
9609           output_asm_insn (\"ble,n R'__outline_epilogue(%%sr0,%%r31)\", NULL);
9610         }
9611       else
9612         output_asm_insn (\"{bl|b,l},n __outline_epilogue,%%r31\", NULL);
9613     }
9614   return \"\";
9616   [(set_attr "type" "multi")
9617    (set_attr "length" "8")])
9619 ;; Given a function pointer, canonicalize it so it can be 
9620 ;; reliably compared to another function pointer.  */
9621 (define_expand "canonicalize_funcptr_for_compare"
9622   [(set (reg:SI 26) (match_operand:SI 1 "register_operand" ""))
9623    (parallel [(set (reg:SI 29) (unspec:SI [(reg:SI 26)] UNSPEC_CFFC))
9624               (clobber (match_dup 2))
9625               (clobber (reg:SI 26))
9626               (clobber (reg:SI 22))
9627               (clobber (reg:SI 31))])
9628    (set (match_operand:SI 0 "register_operand" "")
9629         (reg:SI 29))]
9630   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
9631   "
9633   if (TARGET_ELF32)
9634     {
9635       rtx canonicalize_funcptr_for_compare_libfunc
9636         = init_one_libfunc (CANONICALIZE_FUNCPTR_FOR_COMPARE_LIBCALL);
9638       emit_library_call_value (canonicalize_funcptr_for_compare_libfunc,
9639                                operands[0], LCT_NORMAL, Pmode,
9640                                operands[1], Pmode);
9641       DONE;
9642     }
9644   operands[2] = gen_reg_rtx (SImode);
9645   if (GET_CODE (operands[1]) != REG)
9646     {
9647       rtx tmp = gen_reg_rtx (Pmode);
9648       emit_move_insn (tmp, operands[1]);
9649       operands[1] = tmp;
9650     }
9653 (define_insn "*$$sh_func_adrs"
9654   [(set (reg:SI 29) (unspec:SI [(reg:SI 26)] UNSPEC_CFFC))
9655    (clobber (match_operand:SI 0 "register_operand" "=a"))
9656    (clobber (reg:SI 26))
9657    (clobber (reg:SI 22))
9658    (clobber (reg:SI 31))]
9659   "!TARGET_64BIT"
9660   "*
9662   int length = get_attr_length (insn);
9663   rtx xoperands[2];
9665   xoperands[0] = GEN_INT (length - 8);
9666   xoperands[1] = GEN_INT (length - 16);
9668   /* Must import the magic millicode routine.  */
9669   output_asm_insn (\".IMPORT $$sh_func_adrs,MILLICODE\", NULL);
9671   /* This is absolutely amazing.
9673      First, copy our input parameter into %r29 just in case we don't
9674      need to call $$sh_func_adrs.  */
9675   output_asm_insn (\"copy %%r26,%%r29\", NULL);
9676   output_asm_insn (\"{extru|extrw,u} %%r26,31,2,%%r31\", NULL);
9678   /* Next, examine the low two bits in %r26, if they aren't 0x2, then
9679      we use %r26 unchanged.  */
9680   output_asm_insn (\"{comib|cmpib},<>,n 2,%%r31,.+%0\", xoperands);
9681   output_asm_insn (\"ldi 4096,%%r31\", NULL);
9683   /* Next, compare %r26 with 4096, if %r26 is less than or equal to
9684      4096, then again we use %r26 unchanged.  */
9685   output_asm_insn (\"{comb|cmpb},<<,n %%r26,%%r31,.+%1\", xoperands);
9687   /* Finally, call $$sh_func_adrs to extract the function's real add24.  */
9688   return pa_output_millicode_call (insn,
9689                                    gen_rtx_SYMBOL_REF (SImode,
9690                                                        \"$$sh_func_adrs\"));
9692   [(set_attr "type" "sh_func_adrs")
9693    (set (attr "length")
9694         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 28)]
9695               (plus (symbol_ref "pa_attr_length_millicode_call (insn)")
9696                     (const_int 20))))])
9698 ;; On the PA, the PIC register is call clobbered, so it must
9699 ;; be saved & restored around calls by the caller.  If the call
9700 ;; doesn't return normally (nonlocal goto, or an exception is
9701 ;; thrown), then the code at the exception handler label must
9702 ;; restore the PIC register.
9703 (define_expand "exception_receiver"
9704   [(const_int 4)]
9705   "flag_pic"
9706   "
9708   /* On the 64-bit port, we need a blockage because there is
9709      confusion regarding the dependence of the restore on the
9710      frame pointer.  As a result, the frame pointer and pic
9711      register restores sometimes are interchanged erroneously.  */
9712   if (TARGET_64BIT)
9713     emit_insn (gen_blockage ());
9714   /* Restore the PIC register using hppa_pic_save_rtx ().  The
9715      PIC register is not saved in the frame in 64-bit ABI.  */
9716   emit_move_insn (pic_offset_table_rtx, hppa_pic_save_rtx ());
9717   emit_insn (gen_blockage ());
9718   DONE;
9721 (define_expand "builtin_setjmp_receiver"
9722   [(label_ref (match_operand 0 "" ""))]
9723   "flag_pic"
9724   "
9726   if (TARGET_64BIT)
9727     emit_insn (gen_blockage ());
9728   /* Restore the PIC register.  Hopefully, this will always be from
9729      a stack slot.  The only registers that are valid after a
9730      builtin_longjmp are the stack and frame pointers.  */
9731   emit_move_insn (pic_offset_table_rtx, hppa_pic_save_rtx ());
9732   emit_insn (gen_blockage ());
9733   DONE;
9736 ;; Allocate new stack space and update the saved stack pointer in the
9737 ;; frame marker.  The HP C compilers also copy additional words in the
9738 ;; frame marker.  The 64-bit compiler copies words at -48, -32 and -24.
9739 ;; The 32-bit compiler copies the word at -16 (Static Link).  We
9740 ;; currently don't copy these values.
9742 ;; Since the copy of the frame marker can't be done atomically, I
9743 ;; suspect that using it for unwind purposes may be somewhat unreliable.
9744 ;; The HP compilers appear to raise the stack and copy the frame
9745 ;; marker in a strict instruction sequence.  This suggests that the
9746 ;; unwind library may check for an alloca sequence when ALLOCA_FRAME
9747 ;; is set in the callinfo data.  We currently don't set ALLOCA_FRAME
9748 ;; as GAS doesn't support it, or try to keep the instructions emitted
9749 ;; here in strict sequence.
9750 (define_expand "allocate_stack"
9751   [(match_operand 0 "" "")
9752    (match_operand 1 "" "")]
9753   ""
9754   "
9756   rtx addr;
9758   /* Since the stack grows upward, we need to store virtual_stack_dynamic_rtx
9759      in operand 0 before adjusting the stack.  */
9760   emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
9761   anti_adjust_stack (operands[1]);
9762   if (TARGET_HPUX_UNWIND_LIBRARY)
9763     {
9764       addr = gen_rtx_PLUS (word_mode, stack_pointer_rtx,
9765                            GEN_INT (TARGET_64BIT ? -8 : -4));
9766       emit_move_insn (gen_rtx_MEM (word_mode, addr), hard_frame_pointer_rtx);
9767     }
9768   if (!TARGET_64BIT && flag_pic)
9769     {
9770       rtx addr = gen_rtx_PLUS (word_mode, stack_pointer_rtx, GEN_INT (-32));
9771       emit_move_insn (gen_rtx_MEM (word_mode, addr), pic_offset_table_rtx);
9772     }
9773   DONE;
9776 (define_expand "prefetch"
9777   [(match_operand 0 "address_operand" "")
9778    (match_operand 1 "const_int_operand" "")
9779    (match_operand 2 "const_int_operand" "")]
9780   "TARGET_PA_20"
9782   operands[0] = copy_addr_to_reg (operands[0]);
9783   emit_insn (gen_prefetch_20 (operands[0], operands[1], operands[2]));
9784   DONE;
9787 (define_insn "prefetch_20"
9788   [(prefetch (match_operand 0 "pmode_register_operand" "r")
9789              (match_operand:SI 1 "const_int_operand" "n")
9790              (match_operand:SI 2 "const_int_operand" "n"))]
9791   "TARGET_PA_20"
9793   /* The SL cache-control completer indicates good spatial locality but
9794      poor temporal locality.  The ldw instruction with a target of general
9795      register 0 prefetches a cache line for a read.  The ldd instruction
9796      prefetches a cache line for a write.  */
9797   static const char * const instr[2][2] = {
9798     {
9799       "ldw,sl 0(%0),%%r0",
9800       "ldd,sl 0(%0),%%r0"
9801     },
9802     {
9803       "ldw 0(%0),%%r0",
9804       "ldd 0(%0),%%r0"
9805     }
9806   };
9807   int read_or_write = INTVAL (operands[1]) == 0 ? 0 : 1;
9808   int locality = INTVAL (operands[2]) == 0 ? 0 : 1;
9810   return instr [locality][read_or_write];
9812   [(set_attr "type" "load")
9813    (set_attr "length" "4")])
9815 ;; TLS Support
9816 (define_insn "tgd_load"
9817  [(set (match_operand:SI 0 "register_operand" "=r")
9818        (unspec:SI [(match_operand 1 "tgd_symbolic_operand" "")] UNSPEC_TLSGD))
9819   (clobber (reg:SI 1))
9820   (use (reg:SI 27))]
9821   ""
9822   "*
9824   return \"addil LR'%1-$tls_gdidx$,%%r27\;ldo RR'%1-$tls_gdidx$(%%r1),%0\";
9826   [(set_attr "type" "multi")
9827    (set_attr "length" "8")])
9829 (define_insn "tgd_load_pic"
9830  [(set (match_operand:SI 0 "register_operand" "=r")
9831        (unspec:SI [(match_operand 1 "tgd_symbolic_operand" "")] UNSPEC_TLSGD_PIC))
9832   (clobber (reg:SI 1))
9833   (use (reg:SI 19))]
9834   ""
9835   "*
9837   return \"addil LT'%1-$tls_gdidx$,%%r19\;ldo RT'%1-$tls_gdidx$(%%r1),%0\";
9839   [(set_attr "type" "multi")
9840    (set_attr "length" "8")])
9842 (define_insn "tld_load"
9843  [(set (match_operand:SI 0 "register_operand" "=r")
9844        (unspec:SI [(match_operand 1 "tld_symbolic_operand" "")] UNSPEC_TLSLDM))
9845   (clobber (reg:SI 1))
9846   (use (reg:SI 27))]
9847   ""
9848   "*
9850   return \"addil LR'%1-$tls_ldidx$,%%r27\;ldo RR'%1-$tls_ldidx$(%%r1),%0\";
9852   [(set_attr "type" "multi")
9853    (set_attr "length" "8")])
9855 (define_insn "tld_load_pic"
9856  [(set (match_operand:SI 0 "register_operand" "=r")
9857        (unspec:SI [(match_operand 1 "tld_symbolic_operand" "")] UNSPEC_TLSLDM_PIC))
9858   (clobber (reg:SI 1))
9859   (use (reg:SI 19))]
9860   ""
9861   "*
9863   return \"addil LT'%1-$tls_ldidx$,%%r19\;ldo RT'%1-$tls_ldidx$(%%r1),%0\";
9865   [(set_attr "type" "multi")
9866    (set_attr "length" "8")])
9868 (define_insn "tld_offset_load"
9869   [(set (match_operand:SI 0 "register_operand" "=r")
9870         (plus:SI (unspec:SI [(match_operand 1 "tld_symbolic_operand" "")] 
9871                             UNSPEC_TLSLDO)
9872                  (match_operand:SI 2 "register_operand" "r")))
9873    (clobber (reg:SI 1))]
9874   ""
9875   "*
9877   return \"addil LR'%1-$tls_dtpoff$,%2\;ldo RR'%1-$tls_dtpoff$(%%r1),%0\"; 
9879   [(set_attr "type" "multi")
9880    (set_attr "length" "8")])
9882 (define_insn "tp_load"
9883   [(set (match_operand:SI 0 "register_operand" "=r")
9884         (unspec:SI [(const_int 0)] UNSPEC_TP))]
9885   ""
9886   "mfctl %%cr27,%0"
9887   [(set_attr "type" "multi")
9888    (set_attr "length" "4")])
9890 (define_insn "tie_load"
9891   [(set (match_operand:SI 0 "register_operand" "=r")
9892         (unspec:SI [(match_operand 1 "tie_symbolic_operand" "")] UNSPEC_TLSIE))
9893    (clobber (reg:SI 1))
9894    (use (reg:SI 27))]
9895   ""
9896   "*
9898   return \"addil LR'%1-$tls_ieoff$,%%r27\;ldw RR'%1-$tls_ieoff$(%%r1),%0\";
9900   [(set_attr "type" "multi")
9901    (set_attr "length" "8")])
9903 (define_insn "tie_load_pic"
9904   [(set (match_operand:SI 0 "register_operand" "=r")
9905         (unspec:SI [(match_operand 1 "tie_symbolic_operand" "")] UNSPEC_TLSIE_PIC))
9906    (clobber (reg:SI 1))
9907    (use (reg:SI 19))]
9908   ""
9909   "*
9911   return \"addil LT'%1-$tls_ieoff$,%%r19\;ldw RT'%1-$tls_ieoff$(%%r1),%0\";
9913   [(set_attr "type" "multi")
9914    (set_attr "length" "8")])
9916 (define_insn "tle_load"
9917   [(set (match_operand:SI 0 "register_operand" "=r")
9918         (plus:SI (unspec:SI [(match_operand 1 "tle_symbolic_operand" "")] 
9919                             UNSPEC_TLSLE)
9920                  (match_operand:SI 2 "register_operand" "r")))
9921    (clobber (reg:SI 1))]
9922   ""
9923   "addil LR'%1-$tls_leoff$,%2\;ldo RR'%1-$tls_leoff$(%%r1),%0"
9924   [(set_attr "type" "multi")
9925    (set_attr "length" "8")])
9927 ;; Atomic instructions
9929 ;; All memory loads and stores access storage atomically except
9930 ;; for one exception.  The STORE BYTES, STORE DOUBLE BYTES, and
9931 ;; doubleword loads and stores are not guaranteed to be atomic
9932 ;; when referencing the I/O address space.
9934 ;; The kernel cmpxchg operation on linux is not atomic with respect to
9935 ;; memory stores on SMP machines, so we must do stores using a cmpxchg
9936 ;; operation.
9938 ;; These patterns are at the bottom so the non atomic versions are preferred.
9940 ;; Implement atomic QImode store using exchange.
9942 (define_expand "atomic_storeqi"
9943   [(match_operand:QI 0 "memory_operand")                ;; memory
9944    (match_operand:QI 1 "register_operand")              ;; val out
9945    (match_operand:SI 2 "const_int_operand")]            ;; model
9946   ""
9948   if (TARGET_SYNC_LIBCALL)
9949     {
9950       rtx mem = operands[0];
9951       rtx val = operands[1];
9952       if (pa_maybe_emit_compare_and_swap_exchange_loop (NULL_RTX, mem, val))
9953         DONE;
9954     }
9955   FAIL;
9958 ;; Implement atomic HImode stores using exchange.
9960 (define_expand "atomic_storehi"
9961   [(match_operand:HI 0 "memory_operand")                ;; memory
9962    (match_operand:HI 1 "register_operand")              ;; val out
9963    (match_operand:SI 2 "const_int_operand")]            ;; model
9964   ""
9966   if (TARGET_SYNC_LIBCALL)
9967     {
9968       rtx mem = operands[0];
9969       rtx val = operands[1];
9970       if (pa_maybe_emit_compare_and_swap_exchange_loop (NULL_RTX, mem, val))
9971         DONE;
9972     }
9973   FAIL;
9976 ;; Implement atomic SImode store using exchange.
9978 (define_expand "atomic_storesi"
9979   [(match_operand:SI 0 "memory_operand")                ;; memory
9980    (match_operand:SI 1 "register_operand")              ;; val out
9981    (match_operand:SI 2 "const_int_operand")]            ;; model
9982   ""
9984   if (TARGET_SYNC_LIBCALL)
9985     {
9986       rtx mem = operands[0];
9987       rtx val = operands[1];
9988       if (pa_maybe_emit_compare_and_swap_exchange_loop (NULL_RTX, mem, val))
9989         DONE;
9990     }
9991   FAIL;
9994 ;; Implement atomic SFmode store using exchange.
9996 (define_expand "atomic_storesf"
9997   [(match_operand:SF 0 "memory_operand")                ;; memory
9998    (match_operand:SF 1 "register_operand")              ;; val out
9999    (match_operand:SI 2 "const_int_operand")]            ;; model
10000   ""
10002   if (TARGET_SYNC_LIBCALL)
10003     {
10004       rtx mem = operands[0];
10005       rtx val = operands[1];
10006       if (pa_maybe_emit_compare_and_swap_exchange_loop (NULL_RTX, mem, val))
10007         DONE;
10008     }
10009   FAIL;
10012 ;; Implement atomic DImode load using 64-bit floating point load.
10014 (define_expand "atomic_loaddi"
10015   [(match_operand:DI 0 "register_operand")              ;; val out
10016    (match_operand:DI 1 "memory_operand")                ;; memory
10017    (match_operand:SI 2 "const_int_operand")]            ;; model
10018   ""
10020   enum memmodel model;
10022   if (TARGET_64BIT || TARGET_DISABLE_FPREGS || TARGET_SOFT_FLOAT)
10023     FAIL;
10025   model = memmodel_from_int (INTVAL (operands[2]));
10026   operands[1] = force_reg (SImode, XEXP (operands[1], 0));
10027   expand_mem_thread_fence (model);
10028   emit_insn (gen_atomic_loaddi_1 (operands[0], operands[1]));
10029   if (is_mm_seq_cst (model))
10030     expand_mem_thread_fence (model);
10031   DONE;
10034 (define_insn "atomic_loaddi_1"
10035   [(set (match_operand:DI 0 "register_operand" "=f,r")
10036         (mem:DI (match_operand:SI 1 "register_operand" "r,r")))
10037    (clobber (match_scratch:DI 2 "=X,f"))]
10038   "!TARGET_64BIT && !TARGET_DISABLE_FPREGS && !TARGET_SOFT_FLOAT"
10039   "@
10040    {fldds|fldd} 0(%1),%0
10041    {fldds|fldd} 0(%1),%2\n\t{fstds|fstd} %2,-16(%%sp)\n\t{ldws|ldw} -16(%%sp),%0\n\t{ldws|ldw} -12(%%sp),%R0"
10042   [(set_attr "type" "move,move")
10043    (set_attr "length" "4,16")])
10045 ;; Implement atomic DImode store.
10047 (define_expand "atomic_storedi"
10048   [(match_operand:DI 0 "memory_operand")                ;; memory
10049    (match_operand:DI 1 "register_operand")              ;; val out
10050    (match_operand:SI 2 "const_int_operand")]            ;; model
10051   ""
10053   enum memmodel model;
10055   if (TARGET_SYNC_LIBCALL)
10056     {
10057       rtx mem = operands[0];
10058       rtx val = operands[1];
10059       if (pa_maybe_emit_compare_and_swap_exchange_loop (NULL_RTX, mem, val))
10060         DONE;
10061     }
10063   if (TARGET_64BIT || TARGET_DISABLE_FPREGS || TARGET_SOFT_FLOAT)
10064     FAIL;
10066   model = memmodel_from_int (INTVAL (operands[2]));
10067   operands[0] = force_reg (SImode, XEXP (operands[0], 0));
10068   expand_mem_thread_fence (model);
10069   emit_insn (gen_atomic_storedi_1 (operands[0], operands[1]));
10070   if (is_mm_seq_cst (model))
10071     expand_mem_thread_fence (model);
10072   DONE;
10075 (define_insn "atomic_storedi_1"
10076   [(set (mem:DI (match_operand:SI 0 "register_operand" "r,r"))
10077         (match_operand:DI 1 "register_operand" "f,r"))
10078    (clobber (match_scratch:DI 2 "=X,f"))]
10079   "!TARGET_64BIT && !TARGET_DISABLE_FPREGS
10080    && !TARGET_SOFT_FLOAT && !TARGET_SYNC_LIBCALL"
10081   "@
10082    {fstds|fstd} %1,0(%0)
10083    {stws|stw} %1,-16(%%sp)\n\t{stws|stw} %R1,-12(%%sp)\n\t{fldds|fldd} -16(%%sp),%2\n\t{fstds|fstd} %2,0(%0)"
10084   [(set_attr "type" "move,move")
10085    (set_attr "length" "4,16")])
10087 ;; Implement atomic DFmode load using 64-bit floating point load.
10089 (define_expand "atomic_loaddf"
10090   [(match_operand:DF 0 "register_operand")              ;; val out
10091    (match_operand:DF 1 "memory_operand")                ;; memory
10092    (match_operand:SI 2 "const_int_operand")]            ;; model
10093   ""
10095   enum memmodel model;
10097   if (TARGET_64BIT || TARGET_DISABLE_FPREGS || TARGET_SOFT_FLOAT)
10098     FAIL;
10100   model = memmodel_from_int (INTVAL (operands[2]));
10101   operands[1] = force_reg (SImode, XEXP (operands[1], 0));
10102   expand_mem_thread_fence (model);
10103   emit_insn (gen_atomic_loaddf_1 (operands[0], operands[1]));
10104   if (is_mm_seq_cst (model))
10105     expand_mem_thread_fence (model);
10106   DONE;
10109 (define_insn "atomic_loaddf_1"
10110   [(set (match_operand:DF 0 "register_operand" "=f,r")
10111         (mem:DF (match_operand:SI 1 "register_operand" "r,r")))
10112    (clobber (match_scratch:DF 2 "=X,f"))]
10113   "!TARGET_64BIT && !TARGET_DISABLE_FPREGS && !TARGET_SOFT_FLOAT"
10114   "@
10115    {fldds|fldd} 0(%1),%0
10116    {fldds|fldd} 0(%1),%2\n\t{fstds|fstd} %2,-16(%%sp)\n\t{ldws|ldw} -16(%%sp),%0\n\t{ldws|ldw} -12(%%sp),%R0"
10117   [(set_attr "type" "move,move")
10118    (set_attr "length" "4,16")])
10120 ;; Implement atomic DFmode store using 64-bit floating point store.
10122 (define_expand "atomic_storedf"
10123   [(match_operand:DF 0 "memory_operand")                ;; memory
10124    (match_operand:DF 1 "register_operand")              ;; val out
10125    (match_operand:SI 2 "const_int_operand")]            ;; model
10126   ""
10128   enum memmodel model;
10130   if (TARGET_SYNC_LIBCALL)
10131     {
10132       rtx mem = operands[0];
10133       rtx val = operands[1];
10134       if (pa_maybe_emit_compare_and_swap_exchange_loop (NULL_RTX, mem, val))
10135         DONE;
10136     }
10138   if (TARGET_64BIT || TARGET_DISABLE_FPREGS || TARGET_SOFT_FLOAT)
10139     FAIL;
10141   model = memmodel_from_int (INTVAL (operands[2]));
10142   operands[0] = force_reg (SImode, XEXP (operands[0], 0));
10143   expand_mem_thread_fence (model);
10144   emit_insn (gen_atomic_storedf_1 (operands[0], operands[1]));
10145   if (is_mm_seq_cst (model))
10146     expand_mem_thread_fence (model);
10147   DONE;
10150 (define_insn "atomic_storedf_1"
10151   [(set (mem:DF (match_operand:SI 0 "register_operand" "r,r"))
10152         (match_operand:DF 1 "register_operand" "f,r"))
10153    (clobber (match_scratch:DF 2 "=X,f"))]
10154   "!TARGET_64BIT && !TARGET_DISABLE_FPREGS
10155    && !TARGET_SOFT_FLOAT && !TARGET_SYNC_LIBCALL"
10156   "@
10157    {fstds|fstd} %1,0(%0)
10158    {stws|stw} %1,-16(%%sp)\n\t{stws|stw} %R1,-12(%%sp)\n\t{fldds|fldd} -16(%%sp),%2\n\t{fstds|fstd} %2,0(%0)"
10159   [(set_attr "type" "move,move")
10160    (set_attr "length" "4,16")])