Fix PR target/63209.
[official-gcc.git] / gcc / config / pa / pa.md
bloba9421ac2e61d9f33fb8201890fe78d0408837a5b
1 ;;- Machine description for HP PA-RISC architecture for GCC compiler
2 ;;   Copyright (C) 1992-2014 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"
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")
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")
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.  Allow unconditional branches in the
185 ;; delay slot.
186 (define_attr "in_call_delay" "false,true"
187   (cond [(and (eq_attr "type" "!uncond_branch,branch,cbranch,fbranch,call,sibcall,dyncall,multi,milli,sh_func_adrs,parallel_branch")
188               (eq_attr "length" "4")
189               (not (match_test "RTX_FRAME_RELATED_P (insn)")))
190            (const_string "true")
191          (eq_attr "type" "uncond_branch")
192            (if_then_else (match_test "TARGET_JUMP_IN_DELAY")
193                          (const_string "true")
194                          (const_string "false"))]
195         (const_string "false")))
198 ;; Call delay slot description.
199 (define_delay (eq_attr "type" "call")
200   [(eq_attr "in_call_delay" "true") (nil) (nil)])
202 ;; Sibcall delay slot description.
203 (define_delay (eq_attr "type" "sibcall")
204   [(eq_attr "in_call_delay" "true") (nil) (nil)])
206 ;; Millicode call delay slot description.
207 (define_delay (eq_attr "type" "milli")
208   [(eq_attr "in_call_delay" "true") (nil) (nil)])
210 ;; Return and other similar instructions.
211 (define_delay (eq_attr "type" "branch,parallel_branch")
212   [(eq_attr "in_branch_delay" "true") (nil) (nil)])
214 ;; Floating point conditional branch delay slot description.
215 (define_delay (eq_attr "type" "fbranch")
216   [(eq_attr "in_branch_delay" "true")
217    (eq_attr "in_nullified_branch_delay" "true")
218    (nil)])
220 ;; Integer conditional branch delay slot description.
221 ;; Nullification of conditional branches on the PA is dependent on the
222 ;; direction of the branch.  Forward branches nullify true and
223 ;; backward branches nullify false.  If the direction is unknown
224 ;; then nullification is not allowed.
225 (define_delay (eq_attr "type" "cbranch")
226   [(eq_attr "in_branch_delay" "true")
227    (and (eq_attr "in_nullified_branch_delay" "true")
228         (attr_flag "forward"))
229    (and (eq_attr "in_nullified_branch_delay" "true")
230         (attr_flag "backward"))])
232 (define_delay (and (eq_attr "type" "uncond_branch")
233                    (not (match_test "pa_following_call (insn)")))
234   [(eq_attr "in_branch_delay" "true") (nil) (nil)])
236 ;; Memory. Disregarding Cache misses, the Mustang memory times are:
237 ;; load: 2, fpload: 3
238 ;; store, fpstore: 3, no D-cache operations should be scheduled.
240 ;; The Timex (aka 700) has two floating-point units: ALU, and MUL/DIV/SQRT.
241 ;; Timings:
242 ;; Instruction  Time    Unit    Minimum Distance (unit contention)
243 ;; fcpy         3       ALU     2
244 ;; fabs         3       ALU     2
245 ;; fadd         3       ALU     2
246 ;; fsub         3       ALU     2
247 ;; fcmp         3       ALU     2
248 ;; fcnv         3       ALU     2
249 ;; fmpyadd      3       ALU,MPY 2
250 ;; fmpysub      3       ALU,MPY 2
251 ;; fmpycfxt     3       ALU,MPY 2
252 ;; fmpy         3       MPY     2
253 ;; fmpyi        3       MPY     2
254 ;; fdiv,sgl     10      MPY     10
255 ;; fdiv,dbl     12      MPY     12
256 ;; fsqrt,sgl    14      MPY     14
257 ;; fsqrt,dbl    18      MPY     18
259 ;; We don't model fmpyadd/fmpysub properly as those instructions
260 ;; keep both the FP ALU and MPY units busy.  Given that these
261 ;; processors are obsolete, I'm not going to spend the time to
262 ;; model those instructions correctly.
264 (define_automaton "pa700")
265 (define_cpu_unit "dummy_700,mem_700,fpalu_700,fpmpy_700" "pa700")
267 (define_insn_reservation "W0" 4
268   (and (eq_attr "type" "fpcc")
269        (eq_attr "cpu" "700"))
270   "fpalu_700*2")
272 (define_insn_reservation "W1" 3
273   (and (eq_attr "type" "fpalu")
274        (eq_attr "cpu" "700"))
275   "fpalu_700*2")
277 (define_insn_reservation "W2" 3
278   (and (eq_attr "type" "fpmulsgl,fpmuldbl")
279        (eq_attr "cpu" "700"))
280   "fpmpy_700*2")
282 (define_insn_reservation "W3" 10
283   (and (eq_attr "type" "fpdivsgl")
284        (eq_attr "cpu" "700"))
285   "fpmpy_700*10")
287 (define_insn_reservation "W4" 12
288   (and (eq_attr "type" "fpdivdbl")
289        (eq_attr "cpu" "700"))
290   "fpmpy_700*12")
292 (define_insn_reservation "W5" 14
293   (and (eq_attr "type" "fpsqrtsgl")
294        (eq_attr "cpu" "700"))
295   "fpmpy_700*14")
297 (define_insn_reservation "W6" 18
298   (and (eq_attr "type" "fpsqrtdbl")
299        (eq_attr "cpu" "700"))
300   "fpmpy_700*18")
302 (define_insn_reservation "W7" 2
303   (and (eq_attr "type" "load")
304        (eq_attr "cpu" "700"))
305   "mem_700")
307 (define_insn_reservation "W8" 2
308   (and (eq_attr "type" "fpload")
309        (eq_attr "cpu" "700"))
310   "mem_700")
312 (define_insn_reservation "W9" 3
313   (and (eq_attr "type" "store")
314        (eq_attr "cpu" "700"))
315   "mem_700*3")
317 (define_insn_reservation "W10" 3
318   (and (eq_attr "type" "fpstore")
319        (eq_attr "cpu" "700"))
320   "mem_700*3")
322 (define_insn_reservation "W11" 5
323   (and (eq_attr "type" "fpstore_load")
324        (eq_attr "cpu" "700"))
325   "mem_700*5")
327 (define_insn_reservation "W12" 6
328   (and (eq_attr "type" "store_fpload")
329        (eq_attr "cpu" "700"))
330   "mem_700*6")
332 (define_insn_reservation "W13" 1
333   (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpdivdbl,fpsqrtsgl,fpsqrtdbl,load,fpload,store,fpstore,fpstore_load,store_fpload")
334        (eq_attr "cpu" "700"))
335   "dummy_700")
337 ;; We have a bypass for all computations in the FP unit which feed an
338 ;; FP store as long as the sizes are the same.
339 (define_bypass 2 "W1,W2" "W10,W11" "pa_fpstore_bypass_p")
340 (define_bypass 9 "W3" "W10,W11" "pa_fpstore_bypass_p")
341 (define_bypass 11 "W4" "W10,W11" "pa_fpstore_bypass_p")
342 (define_bypass 13 "W5" "W10,W11" "pa_fpstore_bypass_p")
343 (define_bypass 17 "W6" "W10,W11" "pa_fpstore_bypass_p")
345 ;; We have an "anti-bypass" for FP loads which feed an FP store.
346 (define_bypass 4 "W8,W12" "W10,W11" "pa_fpstore_bypass_p")
348 ;; Function units for the 7100 and 7150.  The 7100/7150 can dual-issue
349 ;; floating point computations with non-floating point computations (fp loads
350 ;; and stores are not fp computations).
352 ;; Memory. Disregarding Cache misses, memory loads take two cycles; stores also
353 ;; take two cycles, during which no Dcache operations should be scheduled.
354 ;; Any special cases are handled in pa_adjust_cost.  The 7100, 7150 and 7100LC
355 ;; all have the same memory characteristics if one disregards cache misses.
357 ;; The 7100/7150 has three floating-point units: ALU, MUL, and DIV.
358 ;; There's no value in modeling the ALU and MUL separately though
359 ;; since there can never be a functional unit conflict given the
360 ;; latency and issue rates for those units.
362 ;; Timings:
363 ;; Instruction  Time    Unit    Minimum Distance (unit contention)
364 ;; fcpy         2       ALU     1
365 ;; fabs         2       ALU     1
366 ;; fadd         2       ALU     1
367 ;; fsub         2       ALU     1
368 ;; fcmp         2       ALU     1
369 ;; fcnv         2       ALU     1
370 ;; fmpyadd      2       ALU,MPY 1
371 ;; fmpysub      2       ALU,MPY 1
372 ;; fmpycfxt     2       ALU,MPY 1
373 ;; fmpy         2       MPY     1
374 ;; fmpyi        2       MPY     1
375 ;; fdiv,sgl     8       DIV     8
376 ;; fdiv,dbl     15      DIV     15
377 ;; fsqrt,sgl    8       DIV     8
378 ;; fsqrt,dbl    15      DIV     15
380 (define_automaton "pa7100")
381 (define_cpu_unit "i_7100, f_7100,fpmac_7100,fpdivsqrt_7100,mem_7100" "pa7100")
383 (define_insn_reservation "X0" 2
384   (and (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
385        (eq_attr "cpu" "7100"))
386   "f_7100,fpmac_7100")
388 (define_insn_reservation "X1" 8
389   (and (eq_attr "type" "fpdivsgl,fpsqrtsgl")
390        (eq_attr "cpu" "7100"))
391   "f_7100+fpdivsqrt_7100,fpdivsqrt_7100*7")
393 (define_insn_reservation "X2" 15
394   (and (eq_attr "type" "fpdivdbl,fpsqrtdbl")
395        (eq_attr "cpu" "7100"))
396   "f_7100+fpdivsqrt_7100,fpdivsqrt_7100*14")
398 (define_insn_reservation "X3" 2
399   (and (eq_attr "type" "load")
400        (eq_attr "cpu" "7100"))
401   "i_7100+mem_7100")
403 (define_insn_reservation "X4" 2
404   (and (eq_attr "type" "fpload")
405        (eq_attr "cpu" "7100"))
406   "i_7100+mem_7100")
408 (define_insn_reservation "X5" 2
409   (and (eq_attr "type" "store")
410        (eq_attr "cpu" "7100"))
411   "i_7100+mem_7100,mem_7100")
413 (define_insn_reservation "X6" 2
414   (and (eq_attr "type" "fpstore")
415        (eq_attr "cpu" "7100"))
416   "i_7100+mem_7100,mem_7100")
418 (define_insn_reservation "X7" 4
419   (and (eq_attr "type" "fpstore_load")
420        (eq_attr "cpu" "7100"))
421   "i_7100+mem_7100,mem_7100*3")
423 (define_insn_reservation "X8" 4
424   (and (eq_attr "type" "store_fpload")
425        (eq_attr "cpu" "7100"))
426   "i_7100+mem_7100,mem_7100*3")
428 (define_insn_reservation "X9" 1
429   (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl,load,fpload,store,fpstore,fpstore_load,store_fpload")
430        (eq_attr "cpu" "7100"))
431   "i_7100")
433 ;; We have a bypass for all computations in the FP unit which feed an
434 ;; FP store as long as the sizes are the same.
435 (define_bypass 1 "X0" "X6,X7" "pa_fpstore_bypass_p")
436 (define_bypass 7 "X1" "X6,X7" "pa_fpstore_bypass_p")
437 (define_bypass 14 "X2" "X6,X7" "pa_fpstore_bypass_p")
439 ;; We have an "anti-bypass" for FP loads which feed an FP store.
440 (define_bypass 3 "X4,X8" "X6,X7" "pa_fpstore_bypass_p")
442 ;; The 7100LC has three floating-point units: ALU, MUL, and DIV.
443 ;; There's no value in modeling the ALU and MUL separately though
444 ;; since there can never be a functional unit conflict that
445 ;; can be avoided given the latency, issue rates and mandatory
446 ;; one cycle cpu-wide lock for a double precision fp multiply.
448 ;; Timings:
449 ;; Instruction  Time    Unit    Minimum Distance (unit contention)
450 ;; fcpy         2       ALU     1
451 ;; fabs         2       ALU     1
452 ;; fadd         2       ALU     1
453 ;; fsub         2       ALU     1
454 ;; fcmp         2       ALU     1
455 ;; fcnv         2       ALU     1
456 ;; fmpyadd,sgl  2       ALU,MPY 1
457 ;; fmpyadd,dbl  3       ALU,MPY 2
458 ;; fmpysub,sgl  2       ALU,MPY 1
459 ;; fmpysub,dbl  3       ALU,MPY 2
460 ;; fmpycfxt,sgl 2       ALU,MPY 1
461 ;; fmpycfxt,dbl 3       ALU,MPY 2
462 ;; fmpy,sgl     2       MPY     1
463 ;; fmpy,dbl     3       MPY     2
464 ;; fmpyi        3       MPY     2
465 ;; fdiv,sgl     8       DIV     8
466 ;; fdiv,dbl     15      DIV     15
467 ;; fsqrt,sgl    8       DIV     8
468 ;; fsqrt,dbl    15      DIV     15
470 ;; The PA7200 is just like the PA7100LC except that there is
471 ;; no store-store penalty.
473 ;; The PA7300 is just like the PA7200 except that there is
474 ;; no store-load penalty.
476 ;; Note there are some aspects of the 7100LC we are not modeling
477 ;; at the moment.  I'll be reviewing the 7100LC scheduling info
478 ;; shortly and updating this description.
480 ;;   load-load pairs
481 ;;   store-store pairs
482 ;;   other issue modeling
484 (define_automaton "pa7100lc")
485 (define_cpu_unit "i0_7100lc, i1_7100lc, f_7100lc" "pa7100lc")
486 (define_cpu_unit "fpmac_7100lc" "pa7100lc")
487 (define_cpu_unit "mem_7100lc" "pa7100lc")
489 ;; Double precision multiplies lock the entire CPU for one
490 ;; cycle.  There is no way to avoid this lock and trying to
491 ;; schedule around the lock is pointless and thus there is no
492 ;; value in trying to model this lock.
494 ;; Not modeling the lock allows us to treat fp multiplies just
495 ;; like any other FP alu instruction.  It allows for a smaller
496 ;; DFA and may reduce register pressure.
497 (define_insn_reservation "Y0" 2
498   (and (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
499        (eq_attr "cpu" "7100LC,7200,7300"))
500   "f_7100lc,fpmac_7100lc")
502 ;; fp division and sqrt instructions lock the entire CPU for
503 ;; 7 cycles (single precision) or 14 cycles (double precision).
504 ;; There is no way to avoid this lock and trying to schedule
505 ;; around the lock is pointless and thus there is no value in
506 ;; trying to model this lock.  Not modeling the lock allows
507 ;; for a smaller DFA and may reduce register pressure.
508 (define_insn_reservation "Y1" 1
509   (and (eq_attr "type" "fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl")
510        (eq_attr "cpu" "7100LC,7200,7300"))
511   "f_7100lc")
513 (define_insn_reservation "Y2" 2
514   (and (eq_attr "type" "load")
515        (eq_attr "cpu" "7100LC,7200,7300"))
516   "i1_7100lc+mem_7100lc")
518 (define_insn_reservation "Y3" 2
519   (and (eq_attr "type" "fpload")
520        (eq_attr "cpu" "7100LC,7200,7300"))
521   "i1_7100lc+mem_7100lc")
523 (define_insn_reservation "Y4" 2
524   (and (eq_attr "type" "store")
525        (eq_attr "cpu" "7100LC"))
526   "i1_7100lc+mem_7100lc,mem_7100lc")
528 (define_insn_reservation "Y5" 2
529   (and (eq_attr "type" "fpstore")
530        (eq_attr "cpu" "7100LC"))
531   "i1_7100lc+mem_7100lc,mem_7100lc")
533 (define_insn_reservation "Y6" 4
534   (and (eq_attr "type" "fpstore_load")
535        (eq_attr "cpu" "7100LC"))
536   "i1_7100lc+mem_7100lc,mem_7100lc*3")
538 (define_insn_reservation "Y7" 4
539   (and (eq_attr "type" "store_fpload")
540        (eq_attr "cpu" "7100LC"))
541   "i1_7100lc+mem_7100lc,mem_7100lc*3")
543 (define_insn_reservation "Y8" 1
544   (and (eq_attr "type" "shift,nullshift")
545        (eq_attr "cpu" "7100LC,7200,7300"))
546   "i1_7100lc")
548 (define_insn_reservation "Y9" 1
549   (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl,load,fpload,store,fpstore,shift,nullshift")
550        (eq_attr "cpu" "7100LC,7200,7300"))
551   "(i0_7100lc|i1_7100lc)")
553 ;; The 7200 has a store-load penalty
554 (define_insn_reservation "Y10" 2
555   (and (eq_attr "type" "store")
556        (eq_attr "cpu" "7200"))
557   "i1_7100lc,mem_7100lc")
559 (define_insn_reservation "Y11" 2
560   (and (eq_attr "type" "fpstore")
561        (eq_attr "cpu" "7200"))
562   "i1_7100lc,mem_7100lc")
564 (define_insn_reservation "Y12" 4
565   (and (eq_attr "type" "fpstore_load")
566        (eq_attr "cpu" "7200"))
567   "i1_7100lc,mem_7100lc,i1_7100lc+mem_7100lc")
569 (define_insn_reservation "Y13" 4
570   (and (eq_attr "type" "store_fpload")
571        (eq_attr "cpu" "7200"))
572   "i1_7100lc,mem_7100lc,i1_7100lc+mem_7100lc")
574 ;; The 7300 has no penalty for store-store or store-load
575 (define_insn_reservation "Y14" 2
576   (and (eq_attr "type" "store")
577        (eq_attr "cpu" "7300"))
578   "i1_7100lc")
580 (define_insn_reservation "Y15" 2
581   (and (eq_attr "type" "fpstore")
582        (eq_attr "cpu" "7300"))
583   "i1_7100lc")
585 (define_insn_reservation "Y16" 4
586   (and (eq_attr "type" "fpstore_load")
587        (eq_attr "cpu" "7300"))
588   "i1_7100lc,i1_7100lc+mem_7100lc")
590 (define_insn_reservation "Y17" 4
591   (and (eq_attr "type" "store_fpload")
592        (eq_attr "cpu" "7300"))
593   "i1_7100lc,i1_7100lc+mem_7100lc")
595 ;; We have an "anti-bypass" for FP loads which feed an FP store.
596 (define_bypass 3 "Y3,Y7,Y13,Y17" "Y5,Y6,Y11,Y12,Y15,Y16" "pa_fpstore_bypass_p")
598 ;; Scheduling for the PA8000 is somewhat different than scheduling for a
599 ;; traditional architecture.
601 ;; The PA8000 has a large (56) entry reorder buffer that is split between
602 ;; memory and non-memory operations.
604 ;; The PA8000 can issue two memory and two non-memory operations per cycle to
605 ;; the function units, with the exception of branches and multi-output
606 ;; instructions.  The PA8000 can retire two non-memory operations per cycle
607 ;; and two memory operations per cycle, only one of which may be a store.
609 ;; Given the large reorder buffer, the processor can hide most latencies.
610 ;; According to HP, they've got the best results by scheduling for retirement
611 ;; bandwidth with limited latency scheduling for floating point operations.
612 ;; Latency for integer operations and memory references is ignored.
615 ;; We claim floating point operations have a 2 cycle latency and are
616 ;; fully pipelined, except for div and sqrt which are not pipelined and
617 ;; take from 17 to 31 cycles to complete.
619 ;; It's worth noting that there is no way to saturate all the functional
620 ;; units on the PA8000 as there is not enough issue bandwidth.
622 (define_automaton "pa8000")
623 (define_cpu_unit "inm0_8000, inm1_8000, im0_8000, im1_8000" "pa8000")
624 (define_cpu_unit "rnm0_8000, rnm1_8000, rm0_8000, rm1_8000" "pa8000")
625 (define_cpu_unit "store_8000" "pa8000")
626 (define_cpu_unit "f0_8000, f1_8000" "pa8000")
627 (define_cpu_unit "fdivsqrt0_8000, fdivsqrt1_8000" "pa8000")
628 (define_reservation "inm_8000" "inm0_8000 | inm1_8000")
629 (define_reservation "im_8000" "im0_8000 | im1_8000")
630 (define_reservation "rnm_8000" "rnm0_8000 | rnm1_8000")
631 (define_reservation "rm_8000" "rm0_8000 | rm1_8000")
632 (define_reservation "f_8000" "f0_8000 | f1_8000")
633 (define_reservation "fdivsqrt_8000" "fdivsqrt0_8000 | fdivsqrt1_8000")
635 ;; We can issue any two memops per cycle, but we can only retire
636 ;; one memory store per cycle.  We assume that the reorder buffer
637 ;; will hide any memory latencies per HP's recommendation.
638 (define_insn_reservation "Z0" 0
639   (and
640     (eq_attr "type" "load,fpload")
641     (eq_attr "cpu" "8000"))
642   "im_8000,rm_8000")
644 (define_insn_reservation "Z1" 0
645   (and
646     (eq_attr "type" "store,fpstore")
647     (eq_attr "cpu" "8000"))
648   "im_8000,rm_8000+store_8000")
650 (define_insn_reservation "Z2" 0
651   (and (eq_attr "type" "fpstore_load,store_fpload")
652        (eq_attr "cpu" "8000"))
653   "im_8000,rm_8000+store_8000,im_8000,rm_8000")
655 ;; We can issue and retire two non-memory operations per cycle with
656 ;; a few exceptions (branches).  This group catches those we want
657 ;; to assume have zero latency.
658 (define_insn_reservation "Z3" 0
659   (and
660     (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")
661     (eq_attr "cpu" "8000"))
662   "inm_8000,rnm_8000")
664 ;; Branches use both slots in the non-memory issue and
665 ;; retirement unit.
666 (define_insn_reservation "Z4" 0
667   (and
668     (eq_attr "type" "uncond_branch,branch,cbranch,fbranch,call,sibcall,dyncall,multi,milli,sh_func_adrs,parallel_branch")
669     (eq_attr "cpu" "8000"))
670   "inm0_8000+inm1_8000,rnm0_8000+rnm1_8000")
672 ;; We partial latency schedule the floating point units.
673 ;; They can issue/retire two at a time in the non-memory
674 ;; units.  We fix their latency at 2 cycles and they
675 ;; are fully pipelined.
676 (define_insn_reservation "Z5" 1
677  (and
678    (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
679    (eq_attr "cpu" "8000"))
680  "inm_8000,f_8000,rnm_8000")
682 ;; The fdivsqrt units are not pipelined and have a very long latency.  
683 ;; To keep the DFA from exploding, we do not show all the
684 ;; reservations for the divsqrt unit.
685 (define_insn_reservation "Z6" 17
686  (and
687    (eq_attr "type" "fpdivsgl,fpsqrtsgl")
688    (eq_attr "cpu" "8000"))
689  "inm_8000,fdivsqrt_8000*6,rnm_8000")
691 (define_insn_reservation "Z7" 31
692  (and
693    (eq_attr "type" "fpdivdbl,fpsqrtdbl")
694    (eq_attr "cpu" "8000"))
695  "inm_8000,fdivsqrt_8000*6,rnm_8000")
697 ;; Operand and operator predicates and constraints
699 (include "predicates.md")
700 (include "constraints.md")
702 ;; Atomic instructions
704 ;; All memory loads and stores access storage atomically except
705 ;; for one exception.  The STORE BYTES, STORE DOUBLE BYTES, and
706 ;; doubleword loads and stores are not guaranteed to be atomic
707 ;; when referencing the I/O address space.
709 ;; Implement atomic DImode load using 64-bit floating point load and copy.
711 (define_expand "atomic_loaddi"
712   [(match_operand:DI 0 "register_operand")              ;; val out
713    (match_operand:DI 1 "memory_operand")                ;; memory
714    (match_operand:SI 2 "const_int_operand")]            ;; model
715   "!TARGET_64BIT && !TARGET_SOFT_FLOAT"
717   enum memmodel model = (enum memmodel) INTVAL (operands[2]);
718   operands[1] = force_reg (SImode, XEXP (operands[1], 0));
719   operands[2] = gen_reg_rtx (DImode);
720   expand_mem_thread_fence (model);
721   emit_insn (gen_atomic_loaddi_1 (operands[0], operands[1], operands[2]));
722   if ((model & MEMMODEL_MASK) == MEMMODEL_SEQ_CST)
723     expand_mem_thread_fence (model);
724   DONE;
727 (define_insn "atomic_loaddi_1"
728   [(set (match_operand:DI 0 "register_operand" "=r")
729         (mem:DI (match_operand:SI 1 "register_operand" "r")))
730    (clobber (match_operand:DI 2 "register_operand" "=&f"))]
731   "!TARGET_64BIT && !TARGET_SOFT_FLOAT"
732   "{fldds|fldd} 0(%1),%2\;{fstds|fstd} %2,-16(%%sp)\;{ldws|ldw} -16(%%sp),%0\;{ldws|ldw} -12(%%sp),%R0"
733   [(set_attr "type" "move")
734    (set_attr "length" "16")])
736 ;; Implement atomic DImode store using copy and 64-bit floating point store.
738 (define_expand "atomic_storedi"
739   [(match_operand:DI 0 "memory_operand")                ;; memory
740    (match_operand:DI 1 "register_operand")              ;; val out
741    (match_operand:SI 2 "const_int_operand")]            ;; model
742   "!TARGET_64BIT && !TARGET_SOFT_FLOAT"
744   enum memmodel model = (enum memmodel) INTVAL (operands[2]);
745   operands[0] = force_reg (SImode, XEXP (operands[0], 0));
746   operands[2] = gen_reg_rtx (DImode);
747   expand_mem_thread_fence (model);
748   emit_insn (gen_atomic_storedi_1 (operands[0], operands[1], operands[2]));
749   if ((model & MEMMODEL_MASK) == MEMMODEL_SEQ_CST)
750     expand_mem_thread_fence (model);
751   DONE;
754 (define_insn "atomic_storedi_1"
755   [(set (mem:DI (match_operand:SI 0 "register_operand" "r"))
756         (match_operand:DI 1 "register_operand" "r"))
757    (clobber (match_operand:DI 2 "register_operand" "=&f"))]
758   "!TARGET_64BIT && !TARGET_SOFT_FLOAT"
759   "{stws|stw} %1,-16(%%sp)\;{stws|stw} %R1,-12(%%sp)\;{fldds|fldd} -16(%%sp),%2\;{fstds|fstd} %2,0(%0)"
760   [(set_attr "type" "move")
761    (set_attr "length" "16")])
763 ;; Compare instructions.
764 ;; This controls RTL generation and register allocation.
766 (define_insn ""
767   [(set (reg:CCFP 0)
768         (match_operator:CCFP 2 "comparison_operator"
769                              [(match_operand:SF 0 "reg_or_0_operand" "fG")
770                               (match_operand:SF 1 "reg_or_0_operand" "fG")]))]
771   "! TARGET_SOFT_FLOAT"
772   "fcmp,sgl,%Y2 %f0,%f1"
773   [(set_attr "length" "4")
774    (set_attr "type" "fpcc")])
776 (define_insn ""
777   [(set (reg:CCFP 0)
778         (match_operator:CCFP 2 "comparison_operator"
779                              [(match_operand:DF 0 "reg_or_0_operand" "fG")
780                               (match_operand:DF 1 "reg_or_0_operand" "fG")]))]
781   "! TARGET_SOFT_FLOAT"
782   "fcmp,dbl,%Y2 %f0,%f1"
783   [(set_attr "length" "4")
784    (set_attr "type" "fpcc")])
786 ;; Provide a means to emit the movccfp0 and movccfp1 optimization
787 ;; placeholders.  This is necessary in rare situations when a
788 ;; placeholder is re-emitted (see PR 8705).
790 (define_expand "movccfp"
791   [(set (reg:CCFP 0)
792         (match_operand 0 "const_int_operand" ""))]
793   "! TARGET_SOFT_FLOAT"
794   "
796   if ((unsigned HOST_WIDE_INT) INTVAL (operands[0]) > 1)
797     FAIL;
800 ;; The following patterns are optimization placeholders.  In almost
801 ;; all cases, the user of the condition code will be simplified and the
802 ;; original condition code setting insn should be eliminated.
804 (define_insn "*movccfp0"
805   [(set (reg:CCFP 0)
806         (const_int 0))]
807   "! TARGET_SOFT_FLOAT"
808   "fcmp,dbl,= %%fr0,%%fr0"
809   [(set_attr "length" "4")
810    (set_attr "type" "fpcc")])
812 (define_insn "*movccfp1"
813   [(set (reg:CCFP 0)
814         (const_int 1))]
815   "! TARGET_SOFT_FLOAT"
816   "fcmp,dbl,!= %%fr0,%%fr0"
817   [(set_attr "length" "4")
818    (set_attr "type" "fpcc")])
820 ;; scc insns.
822 (define_expand "cstoresi4"
823   [(set (match_operand:SI 0 "register_operand")
824         (match_operator:SI 1 "ordered_comparison_operator"
825          [(match_operand:SI 2 "reg_or_0_operand" "")
826           (match_operand:SI 3 "arith5_operand" "")]))]
827   "!TARGET_64BIT"
828   "")
830 ;; Instruction canonicalization puts immediate operands second, which
831 ;; is the reverse of what we want.
833 (define_insn "scc"
834   [(set (match_operand:SI 0 "register_operand" "=r")
835         (match_operator:SI 3 "comparison_operator"
836                            [(match_operand:SI 1 "reg_or_0_operand" "rM")
837                             (match_operand:SI 2 "arith11_operand" "rI")]))]
838   ""
839   "{com%I2clr|cmp%I2clr},%B3 %2,%r1,%0\;ldi 1,%0"
840   [(set_attr "type" "binary")
841    (set_attr "length" "8")])
843 (define_insn ""
844   [(set (match_operand:DI 0 "register_operand" "=r")
845         (match_operator:DI 3 "comparison_operator"
846                            [(match_operand:DI 1 "reg_or_0_operand" "rM")
847                             (match_operand:DI 2 "arith11_operand" "rI")]))]
848   "TARGET_64BIT"
849   "cmp%I2clr,*%B3 %2,%r1,%0\;ldi 1,%0"
850   [(set_attr "type" "binary")
851    (set_attr "length" "8")])
853 (define_insn "iorscc"
854   [(set (match_operand:SI 0 "register_operand" "=r")
855         (ior:SI (match_operator:SI 3 "comparison_operator"
856                                    [(match_operand:SI 1 "reg_or_0_operand" "rM")
857                                     (match_operand:SI 2 "arith11_operand" "rI")])
858                 (match_operator:SI 6 "comparison_operator"
859                                    [(match_operand:SI 4 "reg_or_0_operand" "rM")
860                                     (match_operand:SI 5 "arith11_operand" "rI")])))]
861   ""
862   "{com%I2clr|cmp%I2clr},%S3 %2,%r1,%%r0\;{com%I5clr|cmp%I5clr},%B6 %5,%r4,%0\;ldi 1,%0"
863   [(set_attr "type" "binary")
864    (set_attr "length" "12")])
866 (define_insn ""
867   [(set (match_operand:DI 0 "register_operand" "=r")
868         (ior:DI (match_operator:DI 3 "comparison_operator"
869                                    [(match_operand:DI 1 "reg_or_0_operand" "rM")
870                                     (match_operand:DI 2 "arith11_operand" "rI")])
871                 (match_operator:DI 6 "comparison_operator"
872                                    [(match_operand:DI 4 "reg_or_0_operand" "rM")
873                                     (match_operand:DI 5 "arith11_operand" "rI")])))]
874   "TARGET_64BIT"
875   "cmp%I2clr,*%S3 %2,%r1,%%r0\;cmp%I5clr,*%B6 %5,%r4,%0\;ldi 1,%0"
876   [(set_attr "type" "binary")
877    (set_attr "length" "12")])
879 ;; Combiner patterns for common operations performed with the output
880 ;; from an scc insn (negscc and incscc).
881 (define_insn "negscc"
882   [(set (match_operand:SI 0 "register_operand" "=r")
883         (neg:SI (match_operator:SI 3 "comparison_operator"
884                [(match_operand:SI 1 "reg_or_0_operand" "rM")
885                 (match_operand:SI 2 "arith11_operand" "rI")])))]
886   ""
887   "{com%I2clr|cmp%I2clr},%B3 %2,%r1,%0\;ldi -1,%0"
888   [(set_attr "type" "binary")
889    (set_attr "length" "8")])
891 (define_insn ""
892   [(set (match_operand:DI 0 "register_operand" "=r")
893         (neg:DI (match_operator:DI 3 "comparison_operator"
894                [(match_operand:DI 1 "reg_or_0_operand" "rM")
895                 (match_operand:DI 2 "arith11_operand" "rI")])))]
896   "TARGET_64BIT"
897   "cmp%I2clr,*%B3 %2,%r1,%0\;ldi -1,%0"
898   [(set_attr "type" "binary")
899    (set_attr "length" "8")])
901 ;; Patterns for adding/subtracting the result of a boolean expression from
902 ;; a register.  First we have special patterns that make use of the carry
903 ;; bit, and output only two instructions.  For the cases we can't in
904 ;; general do in two instructions, the incscc pattern at the end outputs
905 ;; two or three instructions.
907 (define_insn ""
908   [(set (match_operand:SI 0 "register_operand" "=r")
909         (plus:SI (leu:SI (match_operand:SI 2 "register_operand" "r")
910                          (match_operand:SI 3 "arith11_operand" "rI"))
911                  (match_operand:SI 1 "register_operand" "r")))]
912   ""
913   "sub%I3 %3,%2,%%r0\;{addc|add,c} %%r0,%1,%0"
914   [(set_attr "type" "binary")
915    (set_attr "length" "8")])
917 (define_insn ""
918   [(set (match_operand:DI 0 "register_operand" "=r")
919         (plus:DI (leu:DI (match_operand:DI 2 "register_operand" "r")
920                          (match_operand:DI 3 "arith11_operand" "rI"))
921                  (match_operand:DI 1 "register_operand" "r")))]
922   "TARGET_64BIT"
923   "sub%I3 %3,%2,%%r0\;add,dc %%r0,%1,%0"
924   [(set_attr "type" "binary")
925    (set_attr "length" "8")])
927 ; This need only accept registers for op3, since canonicalization
928 ; replaces geu with gtu when op3 is an integer.
929 (define_insn ""
930   [(set (match_operand:SI 0 "register_operand" "=r")
931         (plus:SI (geu:SI (match_operand:SI 2 "register_operand" "r")
932                          (match_operand:SI 3 "register_operand" "r"))
933                  (match_operand:SI 1 "register_operand" "r")))]
934   ""
935   "sub %2,%3,%%r0\;{addc|add,c} %%r0,%1,%0"
936   [(set_attr "type" "binary")
937    (set_attr "length" "8")])
939 (define_insn ""
940   [(set (match_operand:DI 0 "register_operand" "=r")
941         (plus:DI (geu:DI (match_operand:DI 2 "register_operand" "r")
942                          (match_operand:DI 3 "register_operand" "r"))
943                  (match_operand:DI 1 "register_operand" "r")))]
944   "TARGET_64BIT"
945   "sub %2,%3,%%r0\;add,dc %%r0,%1,%0"
946   [(set_attr "type" "binary")
947    (set_attr "length" "8")])
949 ; Match only integers for op3 here.  This is used as canonical form of the
950 ; geu pattern when op3 is an integer.  Don't match registers since we can't
951 ; make better code than the general incscc pattern.
952 (define_insn ""
953   [(set (match_operand:SI 0 "register_operand" "=r")
954         (plus:SI (gtu:SI (match_operand:SI 2 "register_operand" "r")
955                          (match_operand:SI 3 "int11_operand" "I"))
956                  (match_operand:SI 1 "register_operand" "r")))]
957   ""
958   "addi %k3,%2,%%r0\;{addc|add,c} %%r0,%1,%0"
959   [(set_attr "type" "binary")
960    (set_attr "length" "8")])
962 (define_insn ""
963   [(set (match_operand:DI 0 "register_operand" "=r")
964         (plus:DI (gtu:DI (match_operand:DI 2 "register_operand" "r")
965                          (match_operand:DI 3 "int11_operand" "I"))
966                  (match_operand:DI 1 "register_operand" "r")))]
967   "TARGET_64BIT"
968   "addi %k3,%2,%%r0\;add,dc %%r0,%1,%0"
969   [(set_attr "type" "binary")
970    (set_attr "length" "8")])
972 (define_insn "incscc"
973   [(set (match_operand:SI 0 "register_operand" "=r,r")
974         (plus:SI (match_operator:SI 4 "comparison_operator"
975                     [(match_operand:SI 2 "register_operand" "r,r")
976                      (match_operand:SI 3 "arith11_operand" "rI,rI")])
977                  (match_operand:SI 1 "register_operand" "0,?r")))]
978   ""
979   "@
980    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi 1,%0,%0
981    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi,tr 1,%1,%0\;copy %1,%0"
982   [(set_attr "type" "binary,binary")
983    (set_attr "length" "8,12")])
985 (define_insn ""
986   [(set (match_operand:DI 0 "register_operand" "=r,r")
987         (plus:DI (match_operator:DI 4 "comparison_operator"
988                     [(match_operand:DI 2 "register_operand" "r,r")
989                      (match_operand:DI 3 "arith11_operand" "rI,rI")])
990                  (match_operand:DI 1 "register_operand" "0,?r")))]
991   "TARGET_64BIT"
992   "@
993    cmp%I3clr,*%B4 %3,%2,%%r0\;addi 1,%0,%0
994    cmp%I3clr,*%B4 %3,%2,%%r0\;addi,tr 1,%1,%0\;copy %1,%0"
995   [(set_attr "type" "binary,binary")
996    (set_attr "length" "8,12")])
998 (define_insn ""
999   [(set (match_operand:SI 0 "register_operand" "=r")
1000         (minus:SI (match_operand:SI 1 "register_operand" "r")
1001                   (gtu:SI (match_operand:SI 2 "register_operand" "r")
1002                           (match_operand:SI 3 "arith11_operand" "rI"))))]
1003   ""
1004   "sub%I3 %3,%2,%%r0\;{subb|sub,b} %1,%%r0,%0"
1005   [(set_attr "type" "binary")
1006    (set_attr "length" "8")])
1008 (define_insn ""
1009   [(set (match_operand:DI 0 "register_operand" "=r")
1010         (minus:DI (match_operand:DI 1 "register_operand" "r")
1011                   (gtu:DI (match_operand:DI 2 "register_operand" "r")
1012                           (match_operand:DI 3 "arith11_operand" "rI"))))]
1013   "TARGET_64BIT"
1014   "sub%I3 %3,%2,%%r0\;sub,db %1,%%r0,%0"
1015   [(set_attr "type" "binary")
1016    (set_attr "length" "8")])
1018 (define_insn ""
1019   [(set (match_operand:SI 0 "register_operand" "=r")
1020         (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
1021                             (gtu:SI (match_operand:SI 2 "register_operand" "r")
1022                                     (match_operand:SI 3 "arith11_operand" "rI")))
1023                   (match_operand:SI 4 "register_operand" "r")))]
1024   ""
1025   "sub%I3 %3,%2,%%r0\;{subb|sub,b} %1,%4,%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 (minus:DI (match_operand:DI 1 "register_operand" "r")
1032                             (gtu:DI (match_operand:DI 2 "register_operand" "r")
1033                                     (match_operand:DI 3 "arith11_operand" "rI")))
1034                   (match_operand:DI 4 "register_operand" "r")))]
1035   "TARGET_64BIT"
1036   "sub%I3 %3,%2,%%r0\;sub,db %1,%4,%0"
1037   [(set_attr "type" "binary")
1038    (set_attr "length" "8")])
1040 ; This need only accept registers for op3, since canonicalization
1041 ; replaces ltu with leu when op3 is an integer.
1042 (define_insn ""
1043   [(set (match_operand:SI 0 "register_operand" "=r")
1044         (minus:SI (match_operand:SI 1 "register_operand" "r")
1045                   (ltu:SI (match_operand:SI 2 "register_operand" "r")
1046                           (match_operand:SI 3 "register_operand" "r"))))]
1047   ""
1048   "sub %2,%3,%%r0\;{subb|sub,b} %1,%%r0,%0"
1049   [(set_attr "type" "binary")
1050    (set_attr "length" "8")])
1052 (define_insn ""
1053   [(set (match_operand:DI 0 "register_operand" "=r")
1054         (minus:DI (match_operand:DI 1 "register_operand" "r")
1055                   (ltu:DI (match_operand:DI 2 "register_operand" "r")
1056                           (match_operand:DI 3 "register_operand" "r"))))]
1057   "TARGET_64BIT"
1058   "sub %2,%3,%%r0\;sub,db %1,%%r0,%0"
1059   [(set_attr "type" "binary")
1060    (set_attr "length" "8")])
1062 (define_insn ""
1063   [(set (match_operand:SI 0 "register_operand" "=r")
1064         (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
1065                             (ltu:SI (match_operand:SI 2 "register_operand" "r")
1066                                     (match_operand:SI 3 "register_operand" "r")))
1067                   (match_operand:SI 4 "register_operand" "r")))]
1068   ""
1069   "sub %2,%3,%%r0\;{subb|sub,b} %1,%4,%0"
1070   [(set_attr "type" "binary")
1071    (set_attr "length" "8")])
1073 (define_insn ""
1074   [(set (match_operand:DI 0 "register_operand" "=r")
1075         (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
1076                             (ltu:DI (match_operand:DI 2 "register_operand" "r")
1077                                     (match_operand:DI 3 "register_operand" "r")))
1078                   (match_operand:DI 4 "register_operand" "r")))]
1079   "TARGET_64BIT"
1080   "sub %2,%3,%%r0\;sub,db %1,%4,%0"
1081   [(set_attr "type" "binary")
1082    (set_attr "length" "8")])
1084 ; Match only integers for op3 here.  This is used as canonical form of the
1085 ; ltu pattern when op3 is an integer.  Don't match registers since we can't
1086 ; make better code than the general incscc pattern.
1087 (define_insn ""
1088   [(set (match_operand:SI 0 "register_operand" "=r")
1089         (minus:SI (match_operand:SI 1 "register_operand" "r")
1090                   (leu:SI (match_operand:SI 2 "register_operand" "r")
1091                           (match_operand:SI 3 "int11_operand" "I"))))]
1092   ""
1093   "addi %k3,%2,%%r0\;{subb|sub,b} %1,%%r0,%0"
1094   [(set_attr "type" "binary")
1095    (set_attr "length" "8")])
1097 (define_insn ""
1098   [(set (match_operand:DI 0 "register_operand" "=r")
1099         (minus:DI (match_operand:DI 1 "register_operand" "r")
1100                   (leu:DI (match_operand:DI 2 "register_operand" "r")
1101                           (match_operand:DI 3 "int11_operand" "I"))))]
1102   "TARGET_64BIT"
1103   "addi %k3,%2,%%r0\;sub,db %1,%%r0,%0"
1104   [(set_attr "type" "binary")
1105    (set_attr "length" "8")])
1107 (define_insn ""
1108   [(set (match_operand:SI 0 "register_operand" "=r")
1109         (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
1110                             (leu:SI (match_operand:SI 2 "register_operand" "r")
1111                                     (match_operand:SI 3 "int11_operand" "I")))
1112                   (match_operand:SI 4 "register_operand" "r")))]
1113   ""
1114   "addi %k3,%2,%%r0\;{subb|sub,b} %1,%4,%0"
1115   [(set_attr "type" "binary")
1116    (set_attr "length" "8")])
1118 (define_insn ""
1119   [(set (match_operand:DI 0 "register_operand" "=r")
1120         (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
1121                             (leu:DI (match_operand:DI 2 "register_operand" "r")
1122                                     (match_operand:DI 3 "int11_operand" "I")))
1123                   (match_operand:DI 4 "register_operand" "r")))]
1124   "TARGET_64BIT"
1125   "addi %k3,%2,%%r0\;sub,db %1,%4,%0"
1126   [(set_attr "type" "binary")
1127    (set_attr "length" "8")])
1129 (define_insn "decscc"
1130   [(set (match_operand:SI 0 "register_operand" "=r,r")
1131         (minus:SI (match_operand:SI 1 "register_operand" "0,?r")
1132                   (match_operator:SI 4 "comparison_operator"
1133                      [(match_operand:SI 2 "register_operand" "r,r")
1134                       (match_operand:SI 3 "arith11_operand" "rI,rI")])))]
1135   ""
1136   "@
1137    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi -1,%0,%0
1138    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi,tr -1,%1,%0\;copy %1,%0"
1139   [(set_attr "type" "binary,binary")
1140    (set_attr "length" "8,12")])
1142 (define_insn ""
1143   [(set (match_operand:DI 0 "register_operand" "=r,r")
1144         (minus:DI (match_operand:DI 1 "register_operand" "0,?r")
1145                   (match_operator:DI 4 "comparison_operator"
1146                      [(match_operand:DI 2 "register_operand" "r,r")
1147                       (match_operand:DI 3 "arith11_operand" "rI,rI")])))]
1148   "TARGET_64BIT"
1149   "@
1150    cmp%I3clr,*%B4 %3,%2,%%r0\;addi -1,%0,%0
1151    cmp%I3clr,*%B4 %3,%2,%%r0\;addi,tr -1,%1,%0\;copy %1,%0"
1152   [(set_attr "type" "binary,binary")
1153    (set_attr "length" "8,12")])
1155 ; Patterns for max and min.  (There is no need for an earlyclobber in the
1156 ; last alternative since the middle alternative will match if op0 == op1.)
1158 (define_insn "sminsi3"
1159   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1160         (smin:SI (match_operand:SI 1 "register_operand" "%0,0,r")
1161                  (match_operand:SI 2 "arith11_operand" "r,I,M")))]
1162   ""
1163   "@
1164   {comclr|cmpclr},> %2,%0,%%r0\;copy %2,%0
1165   {comiclr|cmpiclr},> %2,%0,%%r0\;ldi %2,%0
1166   {comclr|cmpclr},> %1,%r2,%0\;copy %1,%0"
1167 [(set_attr "type" "multi,multi,multi")
1168  (set_attr "length" "8,8,8")])
1170 (define_insn "smindi3"
1171   [(set (match_operand:DI 0 "register_operand" "=r,r,r")
1172         (smin:DI (match_operand:DI 1 "register_operand" "%0,0,r")
1173                  (match_operand:DI 2 "arith11_operand" "r,I,M")))]
1174   "TARGET_64BIT"
1175   "@
1176   cmpclr,*> %2,%0,%%r0\;copy %2,%0
1177   cmpiclr,*> %2,%0,%%r0\;ldi %2,%0
1178   cmpclr,*> %1,%r2,%0\;copy %1,%0"
1179 [(set_attr "type" "multi,multi,multi")
1180  (set_attr "length" "8,8,8")])
1182 (define_insn "uminsi3"
1183   [(set (match_operand:SI 0 "register_operand" "=r,r")
1184         (umin:SI (match_operand:SI 1 "register_operand" "%0,0")
1185                  (match_operand:SI 2 "arith11_operand" "r,I")))]
1186   ""
1187   "@
1188   {comclr|cmpclr},>> %2,%0,%%r0\;copy %2,%0
1189   {comiclr|cmpiclr},>> %2,%0,%%r0\;ldi %2,%0"
1190 [(set_attr "type" "multi,multi")
1191  (set_attr "length" "8,8")])
1193 (define_insn "umindi3"
1194   [(set (match_operand:DI 0 "register_operand" "=r,r")
1195         (umin:DI (match_operand:DI 1 "register_operand" "%0,0")
1196                  (match_operand:DI 2 "arith11_operand" "r,I")))]
1197   "TARGET_64BIT"
1198   "@
1199   cmpclr,*>> %2,%0,%%r0\;copy %2,%0
1200   cmpiclr,*>> %2,%0,%%r0\;ldi %2,%0"
1201 [(set_attr "type" "multi,multi")
1202  (set_attr "length" "8,8")])
1204 (define_insn "smaxsi3"
1205   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1206         (smax:SI (match_operand:SI 1 "register_operand" "%0,0,r")
1207                  (match_operand:SI 2 "arith11_operand" "r,I,M")))]
1208   ""
1209   "@
1210   {comclr|cmpclr},< %2,%0,%%r0\;copy %2,%0
1211   {comiclr|cmpiclr},< %2,%0,%%r0\;ldi %2,%0
1212   {comclr|cmpclr},< %1,%r2,%0\;copy %1,%0"
1213 [(set_attr "type" "multi,multi,multi")
1214  (set_attr "length" "8,8,8")])
1216 (define_insn "smaxdi3"
1217   [(set (match_operand:DI 0 "register_operand" "=r,r,r")
1218         (smax:DI (match_operand:DI 1 "register_operand" "%0,0,r")
1219                  (match_operand:DI 2 "arith11_operand" "r,I,M")))]
1220   "TARGET_64BIT"
1221   "@
1222   cmpclr,*< %2,%0,%%r0\;copy %2,%0
1223   cmpiclr,*< %2,%0,%%r0\;ldi %2,%0
1224   cmpclr,*< %1,%r2,%0\;copy %1,%0"
1225 [(set_attr "type" "multi,multi,multi")
1226  (set_attr "length" "8,8,8")])
1228 (define_insn "umaxsi3"
1229   [(set (match_operand:SI 0 "register_operand" "=r,r")
1230         (umax:SI (match_operand:SI 1 "register_operand" "%0,0")
1231                  (match_operand:SI 2 "arith11_operand" "r,I")))]
1232   ""
1233   "@
1234   {comclr|cmpclr},<< %2,%0,%%r0\;copy %2,%0
1235   {comiclr|cmpiclr},<< %2,%0,%%r0\;ldi %2,%0"
1236 [(set_attr "type" "multi,multi")
1237  (set_attr "length" "8,8")])
1239 (define_insn "umaxdi3"
1240   [(set (match_operand:DI 0 "register_operand" "=r,r")
1241         (umax:DI (match_operand:DI 1 "register_operand" "%0,0")
1242                  (match_operand:DI 2 "arith11_operand" "r,I")))]
1243   "TARGET_64BIT"
1244   "@
1245   cmpclr,*<< %2,%0,%%r0\;copy %2,%0
1246   cmpiclr,*<< %2,%0,%%r0\;ldi %2,%0"
1247 [(set_attr "type" "multi,multi")
1248  (set_attr "length" "8,8")])
1250 (define_insn "abssi2"
1251   [(set (match_operand:SI 0 "register_operand" "=r")
1252         (abs:SI (match_operand:SI 1 "register_operand" "r")))]
1253   ""
1254   "or,>= %%r0,%1,%0\;subi 0,%0,%0"
1255   [(set_attr "type" "multi")
1256    (set_attr "length" "8")])
1258 (define_insn "absdi2"
1259   [(set (match_operand:DI 0 "register_operand" "=r")
1260         (abs:DI (match_operand:DI 1 "register_operand" "r")))]
1261   "TARGET_64BIT"
1262   "or,*>= %%r0,%1,%0\;subi 0,%0,%0"
1263   [(set_attr "type" "multi")
1264    (set_attr "length" "8")])
1266 ;;; Experimental conditional move patterns
1268 (define_expand "movsicc"
1269   [(set (match_operand:SI 0 "register_operand" "")
1270         (if_then_else:SI
1271          (match_operand 1 "comparison_operator" "")
1272          (match_operand:SI 2 "reg_or_cint_move_operand" "")
1273          (match_operand:SI 3 "reg_or_cint_move_operand" "")))]
1274   ""
1275   "
1277   if (GET_MODE (XEXP (operands[1], 0)) != SImode
1278       || GET_MODE (XEXP (operands[1], 0)) != GET_MODE (XEXP (operands[1], 1)))
1279     FAIL;
1282 ;; We used to accept any register for op1.
1284 ;; However, it loses sometimes because the compiler will end up using
1285 ;; different registers for op0 and op1 in some critical cases.  local-alloc
1286 ;; will  not tie op0 and op1 because op0 is used in multiple basic blocks.
1288 ;; If/when global register allocation supports tying we should allow any
1289 ;; register for op1 again.
1290 (define_insn ""
1291   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
1292         (if_then_else:SI
1293          (match_operator 2 "comparison_operator"
1294             [(match_operand:SI 3 "register_operand" "r,r,r,r")
1295              (match_operand:SI 4 "arith11_operand" "rI,rI,rI,rI")])
1296          (match_operand:SI 1 "reg_or_cint_move_operand" "0,J,N,K")
1297          (const_int 0)))]
1298   ""
1299   "@
1300    {com%I4clr|cmp%I4clr},%S2 %4,%3,%%r0\;ldi 0,%0
1301    {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;ldi %1,%0
1302    {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;ldil L'%1,%0
1303    {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;{zdepi|depwi,z} %Z1,%0"
1304   [(set_attr "type" "multi,multi,multi,nullshift")
1305    (set_attr "length" "8,8,8,8")])
1307 (define_insn ""
1308   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r,r,r")
1309         (if_then_else:SI
1310          (match_operator 5 "comparison_operator"
1311             [(match_operand:SI 3 "register_operand" "r,r,r,r,r,r,r,r")
1312              (match_operand:SI 4 "arith11_operand" "rI,rI,rI,rI,rI,rI,rI,rI")])
1313          (match_operand:SI 1 "reg_or_cint_move_operand" "0,0,0,0,r,J,N,K")
1314          (match_operand:SI 2 "reg_or_cint_move_operand" "r,J,N,K,0,0,0,0")))]
1315   ""
1316   "@
1317    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;copy %2,%0
1318    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;ldi %2,%0
1319    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;ldil L'%2,%0
1320    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;{zdepi|depwi,z} %Z2,%0
1321    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;copy %1,%0
1322    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;ldi %1,%0
1323    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;ldil L'%1,%0
1324    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;{zdepi|depwi,z} %Z1,%0"
1325   [(set_attr "type" "multi,multi,multi,nullshift,multi,multi,multi,nullshift")
1326    (set_attr "length" "8,8,8,8,8,8,8,8")])
1328 (define_expand "movdicc"
1329   [(set (match_operand:DI 0 "register_operand" "")
1330         (if_then_else:DI
1331          (match_operand 1 "comparison_operator" "")
1332          (match_operand:DI 2 "reg_or_cint_move_operand" "")
1333          (match_operand:DI 3 "reg_or_cint_move_operand" "")))]
1334   "TARGET_64BIT"
1335   "
1337   if (GET_MODE (XEXP (operands[1], 0)) != DImode
1338       || GET_MODE (XEXP (operands[1], 0)) != GET_MODE (XEXP (operands[1], 1)))
1339     FAIL;
1342 ; We need the first constraint alternative in order to avoid
1343 ; earlyclobbers on all other alternatives.
1344 (define_insn ""
1345   [(set (match_operand:DI 0 "register_operand" "=r,r,r,r,r")
1346         (if_then_else:DI
1347          (match_operator 2 "comparison_operator"
1348             [(match_operand:DI 3 "register_operand" "r,r,r,r,r")
1349              (match_operand:DI 4 "arith11_operand" "rI,rI,rI,rI,rI")])
1350          (match_operand:DI 1 "reg_or_cint_move_operand" "0,r,J,N,K")
1351          (const_int 0)))]
1352   "TARGET_64BIT"
1353   "@
1354    cmp%I4clr,*%S2 %4,%3,%%r0\;ldi 0,%0
1355    cmp%I4clr,*%B2 %4,%3,%0\;copy %1,%0
1356    cmp%I4clr,*%B2 %4,%3,%0\;ldi %1,%0
1357    cmp%I4clr,*%B2 %4,%3,%0\;ldil L'%1,%0
1358    cmp%I4clr,*%B2 %4,%3,%0\;depdi,z %z1,%0"
1359   [(set_attr "type" "multi,multi,multi,multi,nullshift")
1360    (set_attr "length" "8,8,8,8,8")])
1362 (define_insn ""
1363   [(set (match_operand:DI 0 "register_operand" "=r,r,r,r,r,r,r,r")
1364         (if_then_else:DI
1365          (match_operator 5 "comparison_operator"
1366             [(match_operand:DI 3 "register_operand" "r,r,r,r,r,r,r,r")
1367              (match_operand:DI 4 "arith11_operand" "rI,rI,rI,rI,rI,rI,rI,rI")])
1368          (match_operand:DI 1 "reg_or_cint_move_operand" "0,0,0,0,r,J,N,K")
1369          (match_operand:DI 2 "reg_or_cint_move_operand" "r,J,N,K,0,0,0,0")))]
1370   "TARGET_64BIT"
1371   "@
1372    cmp%I4clr,*%S5 %4,%3,%%r0\;copy %2,%0
1373    cmp%I4clr,*%S5 %4,%3,%%r0\;ldi %2,%0
1374    cmp%I4clr,*%S5 %4,%3,%%r0\;ldil L'%2,%0
1375    cmp%I4clr,*%S5 %4,%3,%%r0\;depdi,z %z2,%0
1376    cmp%I4clr,*%B5 %4,%3,%%r0\;copy %1,%0
1377    cmp%I4clr,*%B5 %4,%3,%%r0\;ldi %1,%0
1378    cmp%I4clr,*%B5 %4,%3,%%r0\;ldil L'%1,%0
1379    cmp%I4clr,*%B5 %4,%3,%%r0\;depdi,z %z1,%0"
1380   [(set_attr "type" "multi,multi,multi,nullshift,multi,multi,multi,nullshift")
1381    (set_attr "length" "8,8,8,8,8,8,8,8")])
1383 ;; Conditional Branches
1385 (define_expand "cbranchdi4"
1386   [(set (pc)
1387         (if_then_else (match_operator 0 "ordered_comparison_operator"
1388                        [(match_operand:DI 1 "reg_or_0_operand" "")
1389                         (match_operand:DI 2 "register_operand" "")])
1390                       (label_ref (match_operand 3 "" ""))
1391                       (pc)))]
1392   "TARGET_64BIT"
1393   "")
1395 (define_expand "cbranchsi4"
1396   [(set (pc)
1397         (if_then_else (match_operator 0 "ordered_comparison_operator"
1398                        [(match_operand:SI 1 "reg_or_0_operand" "")
1399                         (match_operand:SI 2 "arith5_operand" "")])
1400                       (label_ref (match_operand 3 "" ""))
1401                       (pc)))]
1402   ""
1403   "")
1405 (define_expand "cbranchsf4"
1406   [(set (pc)
1407         (if_then_else (match_operator 0 "comparison_operator"
1408                        [(match_operand:SF 1 "reg_or_0_operand" "")
1409                         (match_operand:SF 2 "reg_or_0_operand" "")])
1410                       (label_ref (match_operand 3 "" ""))
1411                       (pc)))]
1412   ""
1413   "
1415   pa_emit_bcond_fp (operands);
1416   DONE;
1420 (define_expand "cbranchdf4"
1421   [(set (pc)
1422         (if_then_else (match_operator 0 "comparison_operator"
1423                        [(match_operand:DF 1 "reg_or_0_operand" "")
1424                         (match_operand:DF 2 "reg_or_0_operand" "")])
1425                       (label_ref (match_operand 3 "" ""))
1426                       (pc)))]
1427   ""
1428   "
1430   pa_emit_bcond_fp (operands);
1431   DONE;
1434 ;; Match the branch patterns.
1437 ;; Note a long backward conditional branch with an annulled delay slot
1438 ;; has a length of 12.
1439 (define_insn ""
1440   [(set (pc)
1441         (if_then_else
1442          (match_operator 3 "comparison_operator"
1443                          [(match_operand:SI 1 "reg_or_0_operand" "rM")
1444                           (match_operand:SI 2 "arith5_operand" "rL")])
1445          (label_ref (match_operand 0 "" ""))
1446          (pc)))]
1447   ""
1448   "*
1450   return pa_output_cbranch (operands, 0, insn);
1452 [(set_attr "type" "cbranch")
1453  (set (attr "length")
1454     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1455                (const_int MAX_12BIT_OFFSET))
1456            (const_int 4)
1457            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1458                (const_int MAX_17BIT_OFFSET))
1459            (const_int 8)
1460            (match_test "TARGET_PORTABLE_RUNTIME")
1461            (const_int 24)
1462            (not (match_test "flag_pic"))
1463            (const_int 20)]
1464           (const_int 28)))])
1466 ;; Match the negated branch.
1468 (define_insn ""
1469   [(set (pc)
1470         (if_then_else
1471          (match_operator 3 "comparison_operator"
1472                          [(match_operand:SI 1 "reg_or_0_operand" "rM")
1473                           (match_operand:SI 2 "arith5_operand" "rL")])
1474          (pc)
1475          (label_ref (match_operand 0 "" ""))))]
1476   ""
1477   "*
1479   return pa_output_cbranch (operands, 1, 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 (define_insn ""
1496   [(set (pc)
1497         (if_then_else
1498          (match_operator 3 "comparison_operator"
1499                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1500                           (match_operand:DI 2 "reg_or_0_operand" "rM")])
1501          (label_ref (match_operand 0 "" ""))
1502          (pc)))]
1503   "TARGET_64BIT"
1504   "*
1506   return pa_output_cbranch (operands, 0, insn);
1508 [(set_attr "type" "cbranch")
1509  (set (attr "length")
1510     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1511                (const_int MAX_12BIT_OFFSET))
1512            (const_int 4)
1513            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1514                (const_int MAX_17BIT_OFFSET))
1515            (const_int 8)
1516            (match_test "TARGET_PORTABLE_RUNTIME")
1517            (const_int 24)
1518            (not (match_test "flag_pic"))
1519            (const_int 20)]
1520           (const_int 28)))])
1522 ;; Match the negated branch.
1524 (define_insn ""
1525   [(set (pc)
1526         (if_then_else
1527          (match_operator 3 "comparison_operator"
1528                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1529                           (match_operand:DI 2 "reg_or_0_operand" "rM")])
1530          (pc)
1531          (label_ref (match_operand 0 "" ""))))]
1532   "TARGET_64BIT"
1533   "*
1535   return pa_output_cbranch (operands, 1, insn);
1537 [(set_attr "type" "cbranch")
1538  (set (attr "length")
1539     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1540                (const_int MAX_12BIT_OFFSET))
1541            (const_int 4)
1542            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1543                (const_int MAX_17BIT_OFFSET))
1544            (const_int 8)
1545            (match_test "TARGET_PORTABLE_RUNTIME")
1546            (const_int 24)
1547            (not (match_test "flag_pic"))
1548            (const_int 20)]
1549           (const_int 28)))])
1550 (define_insn ""
1551   [(set (pc)
1552         (if_then_else
1553          (match_operator 3 "cmpib_comparison_operator"
1554                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1555                           (match_operand:DI 2 "arith5_operand" "rL")])
1556          (label_ref (match_operand 0 "" ""))
1557          (pc)))]
1558   "TARGET_64BIT"
1559   "*
1561   return pa_output_cbranch (operands, 0, insn);
1563 [(set_attr "type" "cbranch")
1564  (set (attr "length")
1565     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1566                (const_int MAX_12BIT_OFFSET))
1567            (const_int 4)
1568            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1569                (const_int MAX_17BIT_OFFSET))
1570            (const_int 8)
1571            (match_test "TARGET_PORTABLE_RUNTIME")
1572            (const_int 24)
1573            (not (match_test "flag_pic"))
1574            (const_int 20)]
1575           (const_int 28)))])
1577 ;; Match the negated branch.
1579 (define_insn ""
1580   [(set (pc)
1581         (if_then_else
1582          (match_operator 3 "cmpib_comparison_operator"
1583                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1584                           (match_operand:DI 2 "arith5_operand" "rL")])
1585          (pc)
1586          (label_ref (match_operand 0 "" ""))))]
1587   "TARGET_64BIT"
1588   "*
1590   return pa_output_cbranch (operands, 1, insn);
1592 [(set_attr "type" "cbranch")
1593  (set (attr "length")
1594     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1595                (const_int MAX_12BIT_OFFSET))
1596            (const_int 4)
1597            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1598                (const_int MAX_17BIT_OFFSET))
1599            (const_int 8)
1600            (match_test "TARGET_PORTABLE_RUNTIME")
1601            (const_int 24)
1602            (not (match_test "flag_pic"))
1603            (const_int 20)]
1604           (const_int 28)))])
1606 ;; Branch on Bit patterns.
1607 (define_insn ""
1608   [(set (pc)
1609         (if_then_else
1610          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1611                               (const_int 1)
1612                               (match_operand:SI 1 "uint5_operand" ""))
1613              (const_int 0))
1614          (label_ref (match_operand 2 "" ""))
1615          (pc)))]
1616   ""
1617   "*
1619   return pa_output_bb (operands, 0, insn, 0);
1621 [(set_attr "type" "cbranch")
1622  (set (attr "length")
1623     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1624                (const_int MAX_12BIT_OFFSET))
1625            (const_int 4)
1626            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1627                (const_int MAX_17BIT_OFFSET))
1628            (const_int 8)
1629            (match_test "TARGET_PORTABLE_RUNTIME")
1630            (const_int 24)
1631            (not (match_test "flag_pic"))
1632            (const_int 20)]
1633           (const_int 28)))])
1635 (define_insn ""
1636   [(set (pc)
1637         (if_then_else
1638          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1639                               (const_int 1)
1640                               (match_operand:DI 1 "uint32_operand" ""))
1641              (const_int 0))
1642          (label_ref (match_operand 2 "" ""))
1643          (pc)))]
1644   "TARGET_64BIT"
1645   "*
1647   return pa_output_bb (operands, 0, insn, 0);
1649 [(set_attr "type" "cbranch")
1650  (set (attr "length")
1651     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1652                (const_int MAX_12BIT_OFFSET))
1653            (const_int 4)
1654            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1655                (const_int MAX_17BIT_OFFSET))
1656            (const_int 8)
1657            (match_test "TARGET_PORTABLE_RUNTIME")
1658            (const_int 24)
1659            (not (match_test "flag_pic"))
1660            (const_int 20)]
1661           (const_int 28)))])
1663 (define_insn ""
1664   [(set (pc)
1665         (if_then_else
1666          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1667                               (const_int 1)
1668                               (match_operand:SI 1 "uint5_operand" ""))
1669              (const_int 0))
1670          (pc)
1671          (label_ref (match_operand 2 "" ""))))]
1672   ""
1673   "*
1675   return pa_output_bb (operands, 1, insn, 0);
1677 [(set_attr "type" "cbranch")
1678  (set (attr "length")
1679     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1680                (const_int MAX_12BIT_OFFSET))
1681            (const_int 4)
1682            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1683                (const_int MAX_17BIT_OFFSET))
1684            (const_int 8)
1685            (match_test "TARGET_PORTABLE_RUNTIME")
1686            (const_int 24)
1687            (not (match_test "flag_pic"))
1688            (const_int 20)]
1689           (const_int 28)))])
1691 (define_insn ""
1692   [(set (pc)
1693         (if_then_else
1694          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1695                               (const_int 1)
1696                               (match_operand:DI 1 "uint32_operand" ""))
1697              (const_int 0))
1698          (pc)
1699          (label_ref (match_operand 2 "" ""))))]
1700   "TARGET_64BIT"
1701   "*
1703   return pa_output_bb (operands, 1, insn, 0);
1705 [(set_attr "type" "cbranch")
1706  (set (attr "length")
1707     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1708                (const_int MAX_12BIT_OFFSET))
1709            (const_int 4)
1710            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1711                (const_int MAX_17BIT_OFFSET))
1712            (const_int 8)
1713            (match_test "TARGET_PORTABLE_RUNTIME")
1714            (const_int 24)
1715            (not (match_test "flag_pic"))
1716            (const_int 20)]
1717           (const_int 28)))])
1719 (define_insn ""
1720   [(set (pc)
1721         (if_then_else
1722          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1723                               (const_int 1)
1724                               (match_operand:SI 1 "uint5_operand" ""))
1725              (const_int 0))
1726          (label_ref (match_operand 2 "" ""))
1727          (pc)))]
1728   ""
1729   "*
1731   return pa_output_bb (operands, 0, insn, 1);
1733 [(set_attr "type" "cbranch")
1734  (set (attr "length")
1735     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1736                (const_int MAX_12BIT_OFFSET))
1737            (const_int 4)
1738            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1739                (const_int MAX_17BIT_OFFSET))
1740            (const_int 8)
1741            (match_test "TARGET_PORTABLE_RUNTIME")
1742            (const_int 24)
1743            (not (match_test "flag_pic"))
1744            (const_int 20)]
1745           (const_int 28)))])
1747 (define_insn ""
1748   [(set (pc)
1749         (if_then_else
1750          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1751                               (const_int 1)
1752                               (match_operand:DI 1 "uint32_operand" ""))
1753              (const_int 0))
1754          (label_ref (match_operand 2 "" ""))
1755          (pc)))]
1756   "TARGET_64BIT"
1757   "*
1759   return pa_output_bb (operands, 0, insn, 1);
1761 [(set_attr "type" "cbranch")
1762  (set (attr "length")
1763     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1764                (const_int MAX_12BIT_OFFSET))
1765            (const_int 4)
1766            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1767                (const_int MAX_17BIT_OFFSET))
1768            (const_int 8)
1769            (match_test "TARGET_PORTABLE_RUNTIME")
1770            (const_int 24)
1771            (not (match_test "flag_pic"))
1772            (const_int 20)]
1773           (const_int 28)))])
1775 (define_insn ""
1776   [(set (pc)
1777         (if_then_else
1778          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1779                               (const_int 1)
1780                               (match_operand:SI 1 "uint5_operand" ""))
1781              (const_int 0))
1782          (pc)
1783          (label_ref (match_operand 2 "" ""))))]
1784   ""
1785   "*
1787   return pa_output_bb (operands, 1, insn, 1);
1789 [(set_attr "type" "cbranch")
1790  (set (attr "length")
1791     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1792                (const_int MAX_12BIT_OFFSET))
1793            (const_int 4)
1794            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1795                (const_int MAX_17BIT_OFFSET))
1796            (const_int 8)
1797            (match_test "TARGET_PORTABLE_RUNTIME")
1798            (const_int 24)
1799            (not (match_test "flag_pic"))
1800            (const_int 20)]
1801           (const_int 28)))])
1803 (define_insn ""
1804   [(set (pc)
1805         (if_then_else
1806          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1807                               (const_int 1)
1808                               (match_operand:DI 1 "uint32_operand" ""))
1809              (const_int 0))
1810          (pc)
1811          (label_ref (match_operand 2 "" ""))))]
1812   "TARGET_64BIT"
1813   "*
1815   return pa_output_bb (operands, 1, insn, 1);
1817 [(set_attr "type" "cbranch")
1818  (set (attr "length")
1819     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1820                (const_int MAX_12BIT_OFFSET))
1821            (const_int 4)
1822            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1823                (const_int MAX_17BIT_OFFSET))
1824            (const_int 8)
1825            (match_test "TARGET_PORTABLE_RUNTIME")
1826            (const_int 24)
1827            (not (match_test "flag_pic"))
1828            (const_int 20)]
1829           (const_int 28)))])
1831 ;; Branch on Variable Bit patterns.
1832 (define_insn ""
1833   [(set (pc)
1834         (if_then_else
1835          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1836                               (const_int 1)
1837                               (match_operand:SI 1 "register_operand" "q"))
1838              (const_int 0))
1839          (label_ref (match_operand 2 "" ""))
1840          (pc)))]
1841   ""
1842   "*
1844   return pa_output_bvb (operands, 0, insn, 0);
1846 [(set_attr "type" "cbranch")
1847  (set (attr "length")
1848     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1849                (const_int MAX_12BIT_OFFSET))
1850            (const_int 4)
1851            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1852                (const_int MAX_17BIT_OFFSET))
1853            (const_int 8)
1854            (match_test "TARGET_PORTABLE_RUNTIME")
1855            (const_int 24)
1856            (not (match_test "flag_pic"))
1857            (const_int 20)]
1858           (const_int 28)))])
1860 (define_insn ""
1861   [(set (pc)
1862         (if_then_else
1863          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1864                               (const_int 1)
1865                               (match_operand:DI 1 "register_operand" "q"))
1866              (const_int 0))
1867          (label_ref (match_operand 2 "" ""))
1868          (pc)))]
1869   "TARGET_64BIT"
1870   "*
1872   return pa_output_bvb (operands, 0, insn, 0);
1874 [(set_attr "type" "cbranch")
1875  (set (attr "length")
1876     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1877                (const_int MAX_12BIT_OFFSET))
1878            (const_int 4)
1879            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1880                (const_int MAX_17BIT_OFFSET))
1881            (const_int 8)
1882            (match_test "TARGET_PORTABLE_RUNTIME")
1883            (const_int 24)
1884            (not (match_test "flag_pic"))
1885            (const_int 20)]
1886           (const_int 28)))])
1888 (define_insn ""
1889   [(set (pc)
1890         (if_then_else
1891          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1892                               (const_int 1)
1893                               (match_operand:SI 1 "register_operand" "q"))
1894              (const_int 0))
1895          (pc)
1896          (label_ref (match_operand 2 "" ""))))]
1897   ""
1898   "*
1900   return pa_output_bvb (operands, 1, insn, 0);
1902 [(set_attr "type" "cbranch")
1903  (set (attr "length")
1904     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1905                (const_int MAX_12BIT_OFFSET))
1906            (const_int 4)
1907            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1908                (const_int MAX_17BIT_OFFSET))
1909            (const_int 8)
1910            (match_test "TARGET_PORTABLE_RUNTIME")
1911            (const_int 24)
1912            (not (match_test "flag_pic"))
1913            (const_int 20)]
1914           (const_int 28)))])
1916 (define_insn ""
1917   [(set (pc)
1918         (if_then_else
1919          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1920                               (const_int 1)
1921                               (match_operand:DI 1 "register_operand" "q"))
1922              (const_int 0))
1923          (pc)
1924          (label_ref (match_operand 2 "" ""))))]
1925   "TARGET_64BIT"
1926   "*
1928   return pa_output_bvb (operands, 1, insn, 0);
1930 [(set_attr "type" "cbranch")
1931  (set (attr "length")
1932     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1933                (const_int MAX_12BIT_OFFSET))
1934            (const_int 4)
1935            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1936                (const_int MAX_17BIT_OFFSET))
1937            (const_int 8)
1938            (match_test "TARGET_PORTABLE_RUNTIME")
1939            (const_int 24)
1940            (not (match_test "flag_pic"))
1941            (const_int 20)]
1942           (const_int 28)))])
1944 (define_insn ""
1945   [(set (pc)
1946         (if_then_else
1947          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1948                               (const_int 1)
1949                               (match_operand:SI 1 "register_operand" "q"))
1950              (const_int 0))
1951          (label_ref (match_operand 2 "" ""))
1952          (pc)))]
1953   ""
1954   "*
1956   return pa_output_bvb (operands, 0, insn, 1);
1958 [(set_attr "type" "cbranch")
1959  (set (attr "length")
1960     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1961                (const_int MAX_12BIT_OFFSET))
1962            (const_int 4)
1963            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1964                (const_int MAX_17BIT_OFFSET))
1965            (const_int 8)
1966            (match_test "TARGET_PORTABLE_RUNTIME")
1967            (const_int 24)
1968            (not (match_test "flag_pic"))
1969            (const_int 20)]
1970           (const_int 28)))])
1972 (define_insn ""
1973   [(set (pc)
1974         (if_then_else
1975          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1976                               (const_int 1)
1977                               (match_operand:DI 1 "register_operand" "q"))
1978              (const_int 0))
1979          (label_ref (match_operand 2 "" ""))
1980          (pc)))]
1981   "TARGET_64BIT"
1982   "*
1984   return pa_output_bvb (operands, 0, insn, 1);
1986 [(set_attr "type" "cbranch")
1987  (set (attr "length")
1988     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1989                (const_int MAX_12BIT_OFFSET))
1990            (const_int 4)
1991            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1992                (const_int MAX_17BIT_OFFSET))
1993            (const_int 8)
1994            (match_test "TARGET_PORTABLE_RUNTIME")
1995            (const_int 24)
1996            (not (match_test "flag_pic"))
1997            (const_int 20)]
1998           (const_int 28)))])
2000 (define_insn ""
2001   [(set (pc)
2002         (if_then_else
2003          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
2004                               (const_int 1)
2005                               (match_operand:SI 1 "register_operand" "q"))
2006              (const_int 0))
2007          (pc)
2008          (label_ref (match_operand 2 "" ""))))]
2009   ""
2010   "*
2012   return pa_output_bvb (operands, 1, insn, 1);
2014 [(set_attr "type" "cbranch")
2015  (set (attr "length")
2016     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2017                (const_int MAX_12BIT_OFFSET))
2018            (const_int 4)
2019            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2020                (const_int MAX_17BIT_OFFSET))
2021            (const_int 8)
2022            (match_test "TARGET_PORTABLE_RUNTIME")
2023            (const_int 24)
2024            (not (match_test "flag_pic"))
2025            (const_int 20)]
2026           (const_int 28)))])
2028 (define_insn ""
2029   [(set (pc)
2030         (if_then_else
2031          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2032                               (const_int 1)
2033                               (match_operand:DI 1 "register_operand" "q"))
2034              (const_int 0))
2035          (pc)
2036          (label_ref (match_operand 2 "" ""))))]
2037   "TARGET_64BIT"
2038   "*
2040   return pa_output_bvb (operands, 1, insn, 1);
2042 [(set_attr "type" "cbranch")
2043  (set (attr "length")
2044     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2045                (const_int MAX_12BIT_OFFSET))
2046            (const_int 4)
2047            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2048                (const_int MAX_17BIT_OFFSET))
2049            (const_int 8)
2050            (match_test "TARGET_PORTABLE_RUNTIME")
2051            (const_int 24)
2052            (not (match_test "flag_pic"))
2053            (const_int 20)]
2054           (const_int 28)))])
2056 ;; Floating point branches
2058 ;; ??? Nullification is handled differently from other branches.
2059 ;; If nullification is specified, the delay slot is nullified on any
2060 ;; taken branch regardless of branch direction.
2061 (define_insn ""
2062   [(set (pc) (if_then_else (ne (reg:CCFP 0) (const_int 0))
2063                            (label_ref (match_operand 0 "" ""))
2064                            (pc)))]
2065   "!TARGET_SOFT_FLOAT"
2066   "*
2068   int length = get_attr_length (insn);
2069   rtx xoperands[1];
2070   int nullify, xdelay;
2072   if (length < 16)
2073     return \"ftest\;b%* %l0\";
2075   if (dbr_sequence_length () == 0 || INSN_ANNULLED_BRANCH_P (insn))
2076     {
2077       nullify = 1;
2078       xdelay = 0;
2079       xoperands[0] = GEN_INT (length - 8);
2080     }
2081   else
2082     {
2083       nullify = 0;
2084       xdelay = 1;
2085       xoperands[0] = GEN_INT (length - 4);
2086     }
2088   if (nullify)
2089     output_asm_insn (\"ftest\;add,tr %%r0,%%r0,%%r0\;b,n .+%0\", xoperands);
2090   else
2091     output_asm_insn (\"ftest\;add,tr %%r0,%%r0,%%r0\;b .+%0\", xoperands);
2092   return pa_output_lbranch (operands[0], insn, xdelay);
2094 [(set_attr "type" "fbranch")
2095  (set (attr "length")
2096     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
2097                (const_int MAX_17BIT_OFFSET))
2098            (const_int 8)
2099            (match_test "TARGET_PORTABLE_RUNTIME")
2100            (const_int 32)
2101            (not (match_test "flag_pic"))
2102            (const_int 28)]
2103           (const_int 36)))])
2105 (define_insn ""
2106   [(set (pc) (if_then_else (ne (reg:CCFP 0) (const_int 0))
2107                            (pc)
2108                            (label_ref (match_operand 0 "" ""))))]
2109   "!TARGET_SOFT_FLOAT"
2110   "*
2112   int length = get_attr_length (insn);
2113   rtx xoperands[1];
2114   int nullify, xdelay;
2116   if (length < 16)
2117     return \"ftest\;add,tr %%r0,%%r0,%%r0\;b%* %0\";
2119   if (dbr_sequence_length () == 0 || INSN_ANNULLED_BRANCH_P (insn))
2120     {
2121       nullify = 1;
2122       xdelay = 0;
2123       xoperands[0] = GEN_INT (length - 4);
2124     }
2125   else
2126     {
2127       nullify = 0;
2128       xdelay = 1;
2129       xoperands[0] = GEN_INT (length);
2130     }
2132   if (nullify)
2133     output_asm_insn (\"ftest\;b,n .+%0\", xoperands);
2134   else
2135     output_asm_insn (\"ftest\;b .+%0\", xoperands);
2136   return pa_output_lbranch (operands[0], insn, xdelay);
2138 [(set_attr "type" "fbranch")
2139  (set (attr "length")
2140     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
2141                (const_int MAX_17BIT_OFFSET))
2142            (const_int 12)
2143            (match_test "TARGET_PORTABLE_RUNTIME")
2144            (const_int 28)
2145            (not (match_test "flag_pic"))
2146            (const_int 24)]
2147           (const_int 32)))])
2149 ;; Move instructions
2151 (define_expand "movsi"
2152   [(set (match_operand:SI 0 "general_operand" "")
2153         (match_operand:SI 1 "general_operand" ""))]
2154   ""
2155   "
2157   if (pa_emit_move_sequence (operands, SImode, 0))
2158     DONE;
2161 ;; Handle SImode input reloads requiring %r1 as a scratch register.
2162 (define_expand "reload_insi_r1"
2163   [(set (match_operand:SI 0 "register_operand" "=Z")
2164         (match_operand:SI 1 "non_hard_reg_operand" ""))
2165    (clobber (match_operand:SI 2 "register_operand" "=&a"))]
2166   ""
2167   "
2169   if (pa_emit_move_sequence (operands, SImode, operands[2]))
2170     DONE;
2172   /* We don't want the clobber emitted, so handle this ourselves.  */
2173   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
2174   DONE;
2177 ;; Handle SImode input reloads requiring a general register as a
2178 ;; scratch register.
2179 (define_expand "reload_insi"
2180   [(set (match_operand:SI 0 "register_operand" "=Z")
2181         (match_operand:SI 1 "non_hard_reg_operand" ""))
2182    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
2183   ""
2184   "
2186   if (pa_emit_move_sequence (operands, SImode, operands[2]))
2187     DONE;
2189   /* We don't want the clobber emitted, so handle this ourselves.  */
2190   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
2191   DONE;
2194 ;; Handle SImode output reloads requiring a general register as a
2195 ;; scratch register.
2196 (define_expand "reload_outsi"
2197   [(set (match_operand:SI 0 "non_hard_reg_operand" "")
2198         (match_operand:SI 1  "register_operand" "Z"))
2199    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
2200   ""
2201   "
2203   if (pa_emit_move_sequence (operands, SImode, operands[2]))
2204     DONE;
2206   /* We don't want the clobber emitted, so handle this ourselves.  */
2207   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
2208   DONE;
2211 (define_insn ""
2212   [(set (match_operand:SI 0 "move_dest_operand"
2213                           "=r,r,r,r,r,r,Q,!*q,!r,!*f,*f,T,?r,?*f")
2214         (match_operand:SI 1 "move_src_operand"
2215                           "A,r,J,N,K,RQ,rM,!rM,!*q,!*fM,RT,*f,*f,r"))]
2216   "(register_operand (operands[0], SImode)
2217     || reg_or_0_operand (operands[1], SImode))
2218    && !TARGET_SOFT_FLOAT
2219    && !TARGET_64BIT"
2220   "@
2221    ldw RT'%A1,%0
2222    copy %1,%0
2223    ldi %1,%0
2224    ldil L'%1,%0
2225    {zdepi|depwi,z} %Z1,%0
2226    ldw%M1 %1,%0
2227    stw%M0 %r1,%0
2228    mtsar %r1
2229    {mfctl|mfctl,w} %%sar,%0
2230    fcpy,sgl %f1,%0
2231    fldw%F1 %1,%0
2232    fstw%F0 %1,%0
2233    {fstws|fstw} %1,-16(%%sp)\n\t{ldws|ldw} -16(%%sp),%0
2234    {stws|stw} %1,-16(%%sp)\n\t{fldws|fldw} -16(%%sp),%0"
2235   [(set_attr "type" "load,move,move,move,shift,load,store,move,move,fpalu,fpload,fpstore,fpstore_load,store_fpload")
2236    (set_attr "pa_combine_type" "addmove")
2237    (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4,8,8")])
2239 (define_insn ""
2240   [(set (match_operand:SI 0 "move_dest_operand"
2241                           "=r,r,r,r,r,r,Q,!*q,!r,!*f,*f,T")
2242         (match_operand:SI 1 "move_src_operand"
2243                           "A,r,J,N,K,RQ,rM,!rM,!*q,!*fM,RT,*f"))]
2244   "(register_operand (operands[0], SImode)
2245     || reg_or_0_operand (operands[1], SImode))
2246    && !TARGET_SOFT_FLOAT
2247    && TARGET_64BIT"
2248   "@
2249    ldw RT'%A1,%0
2250    copy %1,%0
2251    ldi %1,%0
2252    ldil L'%1,%0
2253    {zdepi|depwi,z} %Z1,%0
2254    ldw%M1 %1,%0
2255    stw%M0 %r1,%0
2256    mtsar %r1
2257    {mfctl|mfctl,w} %%sar,%0
2258    fcpy,sgl %f1,%0
2259    fldw%F1 %1,%0
2260    fstw%F0 %1,%0"
2261   [(set_attr "type" "load,move,move,move,shift,load,store,move,move,fpalu,fpload,fpstore")
2262    (set_attr "pa_combine_type" "addmove")
2263    (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4")])
2265 (define_insn ""
2266   [(set (match_operand:SI 0 "indexed_memory_operand" "=R")
2267         (match_operand:SI 1 "register_operand" "f"))]
2268   "!TARGET_SOFT_FLOAT
2269    && !TARGET_DISABLE_INDEXING
2270    && reload_completed"
2271   "fstw%F0 %1,%0"
2272   [(set_attr "type" "fpstore")
2273    (set_attr "pa_combine_type" "addmove")
2274    (set_attr "length" "4")])
2276 ; Rewrite RTL using an indexed store.  This will allow the insn that
2277 ; computes the address to be deleted if the register it sets is dead.
2278 (define_peephole2
2279   [(set (match_operand:SI 0 "register_operand" "")
2280         (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "")
2281                           (const_int 4))
2282                  (match_operand:SI 2 "register_operand" "")))
2283    (set (mem:SI (match_dup 0))
2284         (match_operand:SI 3 "register_operand" ""))]
2285   "!TARGET_SOFT_FLOAT
2286    && !TARGET_DISABLE_INDEXING
2287    && REG_OK_FOR_BASE_P (operands[2])
2288    && FP_REGNO_P (REGNO (operands[3]))"
2289   [(set (mem:SI (plus:SI (mult:SI (match_dup 1) (const_int 4)) (match_dup 2)))
2290         (match_dup 3))
2291    (set (match_dup 0) (plus:SI (mult:SI (match_dup 1) (const_int 4))
2292                                (match_dup 2)))]
2293   "")
2295 (define_peephole2
2296   [(set (match_operand:SI 0 "register_operand" "")
2297         (plus:SI (match_operand:SI 2 "register_operand" "")
2298                  (mult:SI (match_operand:SI 1 "register_operand" "")
2299                           (const_int 4))))
2300    (set (mem:SI (match_dup 0))
2301         (match_operand:SI 3 "register_operand" ""))]
2302   "!TARGET_SOFT_FLOAT
2303    && !TARGET_DISABLE_INDEXING
2304    && REG_OK_FOR_BASE_P (operands[2])
2305    && FP_REGNO_P (REGNO (operands[3]))"
2306   [(set (mem:SI (plus:SI (mult:SI (match_dup 1) (const_int 4)) (match_dup 2)))
2307         (match_dup 3))
2308    (set (match_dup 0) (plus:SI (mult:SI (match_dup 1) (const_int 4))
2309                                (match_dup 2)))]
2310   "")
2312 (define_peephole2
2313   [(set (match_operand:DI 0 "register_operand" "")
2314         (plus:DI (mult:DI (match_operand:DI 1 "register_operand" "")
2315                           (const_int 4))
2316                  (match_operand:DI 2 "register_operand" "")))
2317    (set (mem:SI (match_dup 0))
2318         (match_operand:SI 3 "register_operand" ""))]
2319   "!TARGET_SOFT_FLOAT
2320    && !TARGET_DISABLE_INDEXING
2321    && TARGET_64BIT
2322    && REG_OK_FOR_BASE_P (operands[2])
2323    && FP_REGNO_P (REGNO (operands[3]))"
2324   [(set (mem:SI (plus:DI (mult:DI (match_dup 1) (const_int 4)) (match_dup 2)))
2325         (match_dup 3))
2326    (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 4))
2327                                (match_dup 2)))]
2328   "")
2330 (define_peephole2
2331   [(set (match_operand:DI 0 "register_operand" "")
2332         (plus:DI (match_operand:DI 2 "register_operand" "")
2333                  (mult:DI (match_operand:DI 1 "register_operand" "")
2334                           (const_int 4))))
2335    (set (mem:SI (match_dup 0))
2336         (match_operand:SI 3 "register_operand" ""))]
2337   "!TARGET_SOFT_FLOAT
2338    && !TARGET_DISABLE_INDEXING
2339    && TARGET_64BIT
2340    && REG_OK_FOR_BASE_P (operands[2])
2341    && FP_REGNO_P (REGNO (operands[3]))"
2342   [(set (mem:SI (plus:DI (mult:DI (match_dup 1) (const_int 4)) (match_dup 2)))
2343         (match_dup 3))
2344    (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 4))
2345                                (match_dup 2)))]
2346   "")
2348 (define_peephole2
2349   [(set (match_operand:SI 0 "register_operand" "")
2350         (plus:SI (match_operand:SI 1 "register_operand" "")
2351                  (match_operand:SI 2 "register_operand" "")))
2352    (set (mem:SI (match_dup 0))
2353         (match_operand:SI 3 "register_operand" ""))]
2354   "!TARGET_SOFT_FLOAT
2355    && !TARGET_DISABLE_INDEXING
2356    && TARGET_NO_SPACE_REGS
2357    && REG_OK_FOR_INDEX_P (operands[1])
2358    && REG_OK_FOR_BASE_P (operands[2])
2359    && FP_REGNO_P (REGNO (operands[3]))"
2360   [(set (mem:SI (plus:SI (match_dup 1) (match_dup 2)))
2361         (match_dup 3))
2362    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
2363   "")
2365 (define_peephole2
2366   [(set (match_operand:SI 0 "register_operand" "")
2367         (plus:SI (match_operand:SI 1 "register_operand" "")
2368                  (match_operand:SI 2 "register_operand" "")))
2369    (set (mem:SI (match_dup 0))
2370         (match_operand:SI 3 "register_operand" ""))]
2371   "!TARGET_SOFT_FLOAT
2372    && !TARGET_DISABLE_INDEXING
2373    && TARGET_NO_SPACE_REGS
2374    && REG_OK_FOR_BASE_P (operands[1])
2375    && REG_OK_FOR_INDEX_P (operands[2])
2376    && FP_REGNO_P (REGNO (operands[3]))"
2377   [(set (mem:SI (plus:SI (match_dup 2) (match_dup 1)))
2378         (match_dup 3))
2379    (set (match_dup 0) (plus:SI (match_dup 2) (match_dup 1)))]
2380   "")
2382 (define_peephole2
2383   [(set (match_operand:DI 0 "register_operand" "")
2384         (plus:DI (match_operand:DI 1 "register_operand" "")
2385                  (match_operand:DI 2 "register_operand" "")))
2386    (set (mem:SI (match_dup 0))
2387         (match_operand:SI 3 "register_operand" ""))]
2388   "!TARGET_SOFT_FLOAT
2389    && !TARGET_DISABLE_INDEXING
2390    && TARGET_64BIT
2391    && TARGET_NO_SPACE_REGS
2392    && REG_OK_FOR_INDEX_P (operands[1])
2393    && REG_OK_FOR_BASE_P (operands[2])
2394    && FP_REGNO_P (REGNO (operands[3]))"
2395   [(set (mem:SI (plus:DI (match_dup 1) (match_dup 2)))
2396         (match_dup 3))
2397    (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
2398   "")
2400 (define_peephole2
2401   [(set (match_operand:DI 0 "register_operand" "")
2402         (plus:DI (match_operand:DI 1 "register_operand" "")
2403                  (match_operand:DI 2 "register_operand" "")))
2404    (set (mem:SI (match_dup 0))
2405         (match_operand:SI 3 "register_operand" ""))]
2406   "!TARGET_SOFT_FLOAT
2407    && !TARGET_DISABLE_INDEXING
2408    && TARGET_64BIT
2409    && TARGET_NO_SPACE_REGS
2410    && REG_OK_FOR_BASE_P (operands[1])
2411    && REG_OK_FOR_INDEX_P (operands[2])
2412    && FP_REGNO_P (REGNO (operands[3]))"
2413   [(set (mem:SI (plus:DI (match_dup 2) (match_dup 1)))
2414         (match_dup 3))
2415    (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
2416   "")
2418 (define_insn ""
2419   [(set (match_operand:SI 0 "move_dest_operand"
2420                           "=r,r,r,r,r,r,Q,!*q,!r")
2421         (match_operand:SI 1 "move_src_operand"
2422                           "A,r,J,N,K,RQ,rM,!rM,!*q"))]
2423   "(register_operand (operands[0], SImode)
2424     || reg_or_0_operand (operands[1], SImode))
2425    && TARGET_SOFT_FLOAT"
2426   "@
2427    ldw RT'%A1,%0
2428    copy %1,%0
2429    ldi %1,%0
2430    ldil L'%1,%0
2431    {zdepi|depwi,z} %Z1,%0
2432    ldw%M1 %1,%0
2433    stw%M0 %r1,%0
2434    mtsar %r1
2435    {mfctl|mfctl,w} %%sar,%0"
2436   [(set_attr "type" "load,move,move,move,move,load,store,move,move")
2437    (set_attr "pa_combine_type" "addmove")
2438    (set_attr "length" "4,4,4,4,4,4,4,4,4")])
2440 ;; Load or store with base-register modification.
2441 (define_insn ""
2442   [(set (match_operand:SI 0 "register_operand" "=r")
2443         (mem:SI (plus:DI (match_operand:DI 1 "register_operand" "+r")
2444                          (match_operand:DI 2 "int5_operand" "L"))))
2445    (set (match_dup 1)
2446         (plus:DI (match_dup 1) (match_dup 2)))]
2447   "TARGET_64BIT"
2448   "ldw,mb %2(%1),%0"
2449   [(set_attr "type" "load")
2450    (set_attr "length" "4")])
2452 ; And a zero extended variant.
2453 (define_insn ""
2454   [(set (match_operand:DI 0 "register_operand" "=r")
2455         (zero_extend:DI (mem:SI
2456                           (plus:DI
2457                             (match_operand:DI 1 "register_operand" "+r")
2458                             (match_operand:DI 2 "int5_operand" "L")))))
2459    (set (match_dup 1)
2460         (plus:DI (match_dup 1) (match_dup 2)))]
2461   "TARGET_64BIT"
2462   "ldw,mb %2(%1),%0"
2463   [(set_attr "type" "load")
2464    (set_attr "length" "4")])
2466 (define_expand "pre_load"
2467   [(parallel [(set (match_operand:SI 0 "register_operand" "")
2468               (mem (plus (match_operand 1 "register_operand" "")
2469                                (match_operand 2 "pre_cint_operand" ""))))
2470               (set (match_dup 1)
2471                    (plus (match_dup 1) (match_dup 2)))])]
2472   ""
2473   "
2475   if (TARGET_64BIT)
2476     {
2477       emit_insn (gen_pre_ldd (operands[0], operands[1], operands[2]));
2478       DONE;
2479     }
2480   emit_insn (gen_pre_ldw (operands[0], operands[1], operands[2]));
2481   DONE;
2484 (define_insn "pre_ldw"
2485   [(set (match_operand:SI 0 "register_operand" "=r")
2486         (mem:SI (plus:SI (match_operand:SI 1 "register_operand" "+r")
2487                          (match_operand:SI 2 "pre_cint_operand" ""))))
2488    (set (match_dup 1)
2489         (plus:SI (match_dup 1) (match_dup 2)))]
2490   ""
2491   "*
2493   if (INTVAL (operands[2]) < 0)
2494     return \"{ldwm|ldw,mb} %2(%1),%0\";
2495   return \"{ldws|ldw},mb %2(%1),%0\";
2497   [(set_attr "type" "load")
2498    (set_attr "length" "4")])
2500 (define_insn "pre_ldd"
2501   [(set (match_operand:DI 0 "register_operand" "=r")
2502         (mem:DI (plus:DI (match_operand:DI 1 "register_operand" "+r")
2503                          (match_operand:DI 2 "pre_cint_operand" ""))))
2504    (set (match_dup 1)
2505         (plus:DI (match_dup 1) (match_dup 2)))]
2506   "TARGET_64BIT"
2507   "ldd,mb %2(%1),%0"
2508   [(set_attr "type" "load")
2509    (set_attr "length" "4")])
2511 (define_insn ""
2512   [(set (mem:SI (plus:SI (match_operand:SI 0 "register_operand" "+r")
2513                          (match_operand:SI 1 "pre_cint_operand" "")))
2514         (match_operand:SI 2 "reg_or_0_operand" "rM"))
2515    (set (match_dup 0)
2516         (plus:SI (match_dup 0) (match_dup 1)))]
2517   ""
2518   "*
2520   if (INTVAL (operands[1]) < 0)
2521     return \"{stwm|stw,mb} %r2,%1(%0)\";
2522   return \"{stws|stw},mb %r2,%1(%0)\";
2524   [(set_attr "type" "store")
2525    (set_attr "length" "4")])
2527 (define_insn ""
2528   [(set (match_operand:SI 0 "register_operand" "=r")
2529         (mem:SI (match_operand:SI 1 "register_operand" "+r")))
2530    (set (match_dup 1)
2531         (plus:SI (match_dup 1)
2532                  (match_operand:SI 2 "post_cint_operand" "")))]
2533   ""
2534   "*
2536   if (INTVAL (operands[2]) > 0)
2537     return \"{ldwm|ldw,ma} %2(%1),%0\";
2538   return \"{ldws|ldw},ma %2(%1),%0\";
2540   [(set_attr "type" "load")
2541    (set_attr "length" "4")])
2543 (define_expand "post_store"
2544   [(parallel [(set (mem (match_operand 0 "register_operand" ""))
2545                    (match_operand 1 "reg_or_0_operand" ""))
2546               (set (match_dup 0)
2547                    (plus (match_dup 0)
2548                          (match_operand 2 "post_cint_operand" "")))])]
2549   ""
2550   "
2552   if (TARGET_64BIT)
2553     {
2554       emit_insn (gen_post_std (operands[0], operands[1], operands[2]));
2555       DONE;
2556     }
2557   emit_insn (gen_post_stw (operands[0], operands[1], operands[2]));
2558   DONE;
2561 (define_insn "post_stw"
2562   [(set (mem:SI (match_operand:SI 0 "register_operand" "+r"))
2563         (match_operand:SI 1 "reg_or_0_operand" "rM"))
2564    (set (match_dup 0)
2565         (plus:SI (match_dup 0)
2566                  (match_operand:SI 2 "post_cint_operand" "")))]
2567   ""
2568   "*
2570   if (INTVAL (operands[2]) > 0)
2571     return \"{stwm|stw,ma} %r1,%2(%0)\";
2572   return \"{stws|stw},ma %r1,%2(%0)\";
2574   [(set_attr "type" "store")
2575    (set_attr "length" "4")])
2577 (define_insn "post_std"
2578   [(set (mem:DI (match_operand:DI 0 "register_operand" "+r"))
2579         (match_operand:DI 1 "reg_or_0_operand" "rM"))
2580    (set (match_dup 0)
2581         (plus:DI (match_dup 0)
2582                  (match_operand:DI 2 "post_cint_operand" "")))]
2583   "TARGET_64BIT"
2584   "std,ma %r1,%2(%0)"
2585   [(set_attr "type" "store")
2586    (set_attr "length" "4")])
2588 ;; For loading the address of a label while generating PIC code.
2589 ;; Note since this pattern can be created at reload time (via movsi), all
2590 ;; the same rules for movsi apply here.  (no new pseudos, no temporaries).
2591 (define_insn ""
2592   [(set (match_operand 0 "pmode_register_operand" "=a")
2593         (match_operand 1 "pic_label_operand" ""))]
2594   "TARGET_PA_20"
2595   "*
2597   rtx xoperands[3];
2599   xoperands[0] = operands[0];
2600   xoperands[1] = operands[1];
2601   xoperands[2] = gen_label_rtx ();
2603   (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
2604                                      CODE_LABEL_NUMBER (xoperands[2]));
2605   output_asm_insn (\"mfia %0\", xoperands);
2607   /* If we're trying to load the address of a label that happens to be
2608      close, then we can use a shorter sequence.  */
2609   if (GET_CODE (operands[1]) == LABEL_REF
2610       && !LABEL_REF_NONLOCAL_P (operands[1])
2611       && INSN_ADDRESSES_SET_P ()
2612       && abs (INSN_ADDRESSES (INSN_UID (XEXP (operands[1], 0)))
2613                 - INSN_ADDRESSES (INSN_UID (insn))) < 8100)
2614     output_asm_insn (\"ldo %1-%2(%0),%0\", xoperands);
2615   else
2616     {
2617       output_asm_insn (\"addil L%%%1-%2,%0\", xoperands);
2618       output_asm_insn (\"ldo R%%%1-%2(%0),%0\", xoperands);
2619     }
2620   return \"\";
2622   [(set_attr "type" "multi")
2623    (set_attr "length" "12")])           ; 8 or 12
2625 (define_insn ""
2626   [(set (match_operand 0 "pmode_register_operand" "=a")
2627         (match_operand 1 "pic_label_operand" ""))]
2628   "!TARGET_PA_20"
2629   "*
2631   rtx xoperands[3];
2633   xoperands[0] = operands[0];
2634   xoperands[1] = operands[1];
2635   xoperands[2] = gen_label_rtx ();
2637   output_asm_insn (\"bl .+8,%0\", xoperands);
2638   output_asm_insn (\"depi 0,31,2,%0\", xoperands);
2639   (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
2640                                      CODE_LABEL_NUMBER (xoperands[2]));
2642   /* If we're trying to load the address of a label that happens to be
2643      close, then we can use a shorter sequence.  */
2644   if (GET_CODE (operands[1]) == LABEL_REF
2645       && !LABEL_REF_NONLOCAL_P (operands[1])
2646       && INSN_ADDRESSES_SET_P ()
2647       && abs (INSN_ADDRESSES (INSN_UID (XEXP (operands[1], 0)))
2648                 - INSN_ADDRESSES (INSN_UID (insn))) < 8100)
2649     output_asm_insn (\"ldo %1-%2(%0),%0\", xoperands);
2650   else
2651     {
2652       output_asm_insn (\"addil L%%%1-%2,%0\", xoperands);
2653       output_asm_insn (\"ldo R%%%1-%2(%0),%0\", xoperands);
2654     }
2655   return \"\";
2657   [(set_attr "type" "multi")
2658    (set_attr "length" "16")])           ; 12 or 16
2660 (define_insn ""
2661   [(set (match_operand:SI 0 "register_operand" "=a")
2662         (plus:SI (match_operand:SI 1 "register_operand" "r")
2663                  (high:SI (match_operand 2 "" ""))))]
2664   "symbolic_operand (operands[2], Pmode)
2665    && ! function_label_operand (operands[2], Pmode)
2666    && flag_pic"
2667   "addil LT'%G2,%1"
2668   [(set_attr "type" "binary")
2669    (set_attr "length" "4")])
2671 (define_insn ""
2672   [(set (match_operand:DI 0 "register_operand" "=a")
2673         (plus:DI (match_operand:DI 1 "register_operand" "r")
2674                  (high:DI (match_operand 2 "" ""))))]
2675   "symbolic_operand (operands[2], Pmode)
2676    && ! function_label_operand (operands[2], Pmode)
2677    && TARGET_64BIT
2678    && flag_pic"
2679   "addil LT'%G2,%1"
2680   [(set_attr "type" "binary")
2681    (set_attr "length" "4")])
2683 ;; Always use addil rather than ldil;add sequences.  This allows the
2684 ;; HP linker to eliminate the dp relocation if the symbolic operand
2685 ;; lives in the TEXT space.
2686 (define_insn ""
2687   [(set (match_operand:SI 0 "register_operand" "=a")
2688         (high:SI (match_operand 1 "" "")))]
2689   "symbolic_operand (operands[1], Pmode)
2690    && ! function_label_operand (operands[1], Pmode)
2691    && ! read_only_operand (operands[1], Pmode)
2692    && ! flag_pic"
2693   "*
2695   if (TARGET_LONG_LOAD_STORE)
2696     return \"addil NLR'%H1,%%r27\;ldo N'%H1(%%r1),%%r1\";
2697   else
2698     return \"addil LR'%H1,%%r27\";
2700   [(set_attr "type" "binary")
2701    (set (attr "length")
2702       (if_then_else (not (match_test "TARGET_LONG_LOAD_STORE"))
2703                     (const_int 4)
2704                     (const_int 8)))])
2707 ;; This is for use in the prologue/epilogue code.  We need it
2708 ;; to add large constants to a stack pointer or frame pointer.
2709 ;; Because of the additional %r1 pressure, we probably do not
2710 ;; want to use this in general code, so make it available
2711 ;; only after reload.
2712 (define_insn ""
2713   [(set (match_operand:SI 0 "register_operand" "=!a,*r")
2714         (plus:SI (match_operand:SI 1 "register_operand" "r,r")
2715                  (high:SI (match_operand 2 "const_int_operand" ""))))]
2716   "reload_completed"
2717   "@
2718    addil L'%G2,%1
2719    ldil L'%G2,%0\;{addl|add,l} %0,%1,%0"
2720   [(set_attr "type" "binary,binary")
2721    (set_attr "length" "4,8")])
2723 (define_insn ""
2724   [(set (match_operand:DI 0 "register_operand" "=!a,*r")
2725         (plus:DI (match_operand:DI 1 "register_operand" "r,r")
2726                  (high:DI (match_operand 2 "const_int_operand" ""))))]
2727   "reload_completed && TARGET_64BIT"
2728   "@
2729    addil L'%G2,%1
2730    ldil L'%G2,%0\;{addl|add,l} %0,%1,%0"
2731   [(set_attr "type" "binary,binary")
2732    (set_attr "length" "4,8")])
2734 (define_insn ""
2735   [(set (match_operand:SI 0 "register_operand" "=r")
2736         (high:SI (match_operand 1 "" "")))]
2737   "(!flag_pic || !symbolic_operand (operands[1], Pmode))
2738     && !pa_is_function_label_plus_const (operands[1])"
2739   "*
2741   if (symbolic_operand (operands[1], Pmode))
2742     return \"ldil LR'%H1,%0\";
2743   else
2744     return \"ldil L'%G1,%0\";
2746   [(set_attr "type" "move")
2747    (set_attr "length" "4")])
2749 (define_insn ""
2750   [(set (match_operand:DI 0 "register_operand" "=r")
2751         (high:DI (match_operand 1 "const_int_operand" "")))]
2752   "TARGET_64BIT"
2753   "ldil L'%G1,%0";
2754   [(set_attr "type" "move")
2755    (set_attr "length" "4")])
2757 (define_insn ""
2758   [(set (match_operand:DI 0 "register_operand" "=r")
2759         (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
2760                    (match_operand:DI 2 "const_int_operand" "i")))]
2761   "TARGET_64BIT"
2762   "ldo R'%G2(%1),%0";
2763   [(set_attr "type" "move")
2764    (set_attr "length" "4")])
2766 (define_insn ""
2767   [(set (match_operand:SI 0 "register_operand" "=r")
2768         (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
2769                    (match_operand:SI 2 "immediate_operand" "i")))]
2770   "!pa_is_function_label_plus_const (operands[2])"
2771   "*
2773   gcc_assert (!flag_pic || !symbolic_operand (operands[2], Pmode));
2774   
2775   if (symbolic_operand (operands[2], Pmode))
2776     return \"ldo RR'%G2(%1),%0\";
2777   else
2778     return \"ldo R'%G2(%1),%0\";
2780   [(set_attr "type" "move")
2781    (set_attr "length" "4")])
2783 ;; Now that a symbolic_address plus a constant is broken up early
2784 ;; in the compilation phase (for better CSE) we need a special
2785 ;; combiner pattern to load the symbolic address plus the constant
2786 ;; in only 2 instructions. (For cases where the symbolic address
2787 ;; was not a common subexpression.)
2788 (define_split
2789   [(set (match_operand:SI 0 "register_operand" "")
2790         (match_operand:SI 1 "symbolic_operand" ""))
2791    (clobber (match_operand:SI 2 "register_operand" ""))]
2792   "! (flag_pic && pic_label_operand (operands[1], SImode))"
2793   [(set (match_dup 2) (high:SI (match_dup 1)))
2794    (set (match_dup 0) (lo_sum:SI (match_dup 2) (match_dup 1)))]
2795   "")
2797 ;; hppa_legitimize_address goes to a great deal of trouble to
2798 ;; create addresses which use indexing.  In some cases, this
2799 ;; is a lose because there isn't any store instructions which
2800 ;; allow indexed addresses (with integer register source).
2802 ;; These define_splits try to turn a 3 insn store into
2803 ;; a 2 insn store with some creative RTL rewriting.
2804 (define_split
2805   [(set (mem:SI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2806                                (match_operand:SI 1 "shadd_operand" ""))
2807                    (plus:SI (match_operand:SI 2 "register_operand" "")
2808                             (match_operand:SI 3 "const_int_operand" ""))))
2809         (match_operand:SI 4 "register_operand" ""))
2810    (clobber (match_operand:SI 5 "register_operand" ""))]
2811   ""
2812   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
2813                                (match_dup 2)))
2814    (set (mem:SI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2815   "")
2817 (define_split
2818   [(set (mem:HI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2819                                (match_operand:SI 1 "shadd_operand" ""))
2820                    (plus:SI (match_operand:SI 2 "register_operand" "")
2821                             (match_operand:SI 3 "const_int_operand" ""))))
2822         (match_operand:HI 4 "register_operand" ""))
2823    (clobber (match_operand:SI 5 "register_operand" ""))]
2824   ""
2825   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
2826                                (match_dup 2)))
2827    (set (mem:HI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2828   "")
2830 (define_split
2831   [(set (mem:QI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2832                                (match_operand:SI 1 "shadd_operand" ""))
2833                    (plus:SI (match_operand:SI 2 "register_operand" "")
2834                             (match_operand:SI 3 "const_int_operand" ""))))
2835         (match_operand:QI 4 "register_operand" ""))
2836    (clobber (match_operand:SI 5 "register_operand" ""))]
2837   ""
2838   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
2839                                (match_dup 2)))
2840    (set (mem:QI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2841   "")
2843 (define_expand "movhi"
2844   [(set (match_operand:HI 0 "general_operand" "")
2845         (match_operand:HI 1 "general_operand" ""))]
2846   ""
2847   "
2849   if (pa_emit_move_sequence (operands, HImode, 0))
2850     DONE;
2853 ;; Handle HImode input reloads requiring a general register as a
2854 ;; scratch register.
2855 (define_expand "reload_inhi"
2856   [(set (match_operand:HI 0 "register_operand" "=Z")
2857         (match_operand:HI 1 "non_hard_reg_operand" ""))
2858    (clobber (match_operand:HI 2 "register_operand" "=&r"))]
2859   ""
2860   "
2862   if (pa_emit_move_sequence (operands, HImode, operands[2]))
2863     DONE;
2865   /* We don't want the clobber emitted, so handle this ourselves.  */
2866   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
2867   DONE;
2870 ;; Handle HImode output reloads requiring a general register as a
2871 ;; scratch register.
2872 (define_expand "reload_outhi"
2873   [(set (match_operand:HI 0 "non_hard_reg_operand" "")
2874         (match_operand:HI 1  "register_operand" "Z"))
2875    (clobber (match_operand:HI 2 "register_operand" "=&r"))]
2876   ""
2877   "
2879   if (pa_emit_move_sequence (operands, HImode, operands[2]))
2880     DONE;
2882   /* We don't want the clobber emitted, so handle this ourselves.  */
2883   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
2884   DONE;
2887 (define_insn ""
2888   [(set (match_operand:HI 0 "move_dest_operand"
2889                           "=r,r,r,r,r,Q,!*q,!r")
2890         (match_operand:HI 1 "move_src_operand"
2891                           "r,J,N,K,RQ,rM,!rM,!*q"))]
2892   "(register_operand (operands[0], HImode)
2893     || reg_or_0_operand (operands[1], HImode))"
2894   "@
2895    copy %1,%0
2896    ldi %1,%0
2897    ldil L'%1,%0
2898    {zdepi|depwi,z} %Z1,%0
2899    ldh%M1 %1,%0
2900    sth%M0 %r1,%0
2901    mtsar %r1
2902    {mfctl|mfctl,w} %sar,%0"
2903   [(set_attr "type" "move,move,move,shift,load,store,move,move")
2904    (set_attr "pa_combine_type" "addmove")
2905    (set_attr "length" "4,4,4,4,4,4,4,4")])
2907 (define_insn ""
2908   [(set (match_operand:HI 0 "register_operand" "=r")
2909         (mem:HI (plus:SI (match_operand:SI 1 "register_operand" "+r")
2910                          (match_operand:SI 2 "int5_operand" "L"))))
2911    (set (match_dup 1)
2912         (plus:SI (match_dup 1) (match_dup 2)))]
2913   ""
2914   "{ldhs|ldh},mb %2(%1),%0"
2915   [(set_attr "type" "load")
2916    (set_attr "length" "4")])
2918 (define_insn ""
2919   [(set (match_operand:HI 0 "register_operand" "=r")
2920         (mem:HI (plus:DI (match_operand:DI 1 "register_operand" "+r")
2921                          (match_operand:DI 2 "int5_operand" "L"))))
2922    (set (match_dup 1)
2923         (plus:DI (match_dup 1) (match_dup 2)))]
2924   "TARGET_64BIT"
2925   "ldh,mb %2(%1),%0"
2926   [(set_attr "type" "load")
2927    (set_attr "length" "4")])
2929 ; And a zero extended variant.
2930 (define_insn ""
2931   [(set (match_operand:DI 0 "register_operand" "=r")
2932         (zero_extend:DI (mem:HI
2933                           (plus:DI
2934                             (match_operand:DI 1 "register_operand" "+r")
2935                             (match_operand:DI 2 "int5_operand" "L")))))
2936    (set (match_dup 1)
2937         (plus:DI (match_dup 1) (match_dup 2)))]
2938   "TARGET_64BIT"
2939   "ldh,mb %2(%1),%0"
2940   [(set_attr "type" "load")
2941    (set_attr "length" "4")])
2943 (define_insn ""
2944   [(set (match_operand:SI 0 "register_operand" "=r")
2945         (zero_extend:SI (mem:HI
2946                           (plus:SI
2947                             (match_operand:SI 1 "register_operand" "+r")
2948                             (match_operand:SI 2 "int5_operand" "L")))))
2949    (set (match_dup 1)
2950         (plus:SI (match_dup 1) (match_dup 2)))]
2951   ""
2952   "{ldhs|ldh},mb %2(%1),%0"
2953   [(set_attr "type" "load")
2954    (set_attr "length" "4")])
2956 (define_insn ""
2957   [(set (match_operand:SI 0 "register_operand" "=r")
2958         (zero_extend:SI (mem:HI
2959                           (plus:DI
2960                             (match_operand:DI 1 "register_operand" "+r")
2961                             (match_operand:DI 2 "int5_operand" "L")))))
2962    (set (match_dup 1)
2963         (plus:DI (match_dup 1) (match_dup 2)))]
2964   "TARGET_64BIT"
2965   "ldh,mb %2(%1),%0"
2966   [(set_attr "type" "load")
2967    (set_attr "length" "4")])
2969 (define_insn ""
2970   [(set (mem:HI (plus:SI (match_operand:SI 0 "register_operand" "+r")
2971                          (match_operand:SI 1 "int5_operand" "L")))
2972         (match_operand:HI 2 "reg_or_0_operand" "rM"))
2973    (set (match_dup 0)
2974         (plus:SI (match_dup 0) (match_dup 1)))]
2975   ""
2976   "{sths|sth},mb %r2,%1(%0)"
2977   [(set_attr "type" "store")
2978    (set_attr "length" "4")])
2980 (define_insn ""
2981   [(set (mem:HI (plus:DI (match_operand:DI 0 "register_operand" "+r")
2982                          (match_operand:DI 1 "int5_operand" "L")))
2983         (match_operand:HI 2 "reg_or_0_operand" "rM"))
2984    (set (match_dup 0)
2985         (plus:DI (match_dup 0) (match_dup 1)))]
2986   "TARGET_64BIT"
2987   "sth,mb %r2,%1(%0)"
2988   [(set_attr "type" "store")
2989    (set_attr "length" "4")])
2991 (define_insn "addhi3"
2992   [(set (match_operand:HI 0 "register_operand" "=r,r")
2993         (plus:HI (match_operand:HI 1 "register_operand" "%r,r")
2994                  (match_operand:HI 2 "arith14_operand" "r,J")))]
2995   ""
2996   "@
2997    {addl|add,l} %1,%2,%0
2998    ldo %2(%1),%0"
2999   [(set_attr "type" "binary,binary")
3000    (set_attr "pa_combine_type" "addmove")
3001    (set_attr "length" "4,4")])
3003 (define_expand "movqi"
3004   [(set (match_operand:QI 0 "general_operand" "")
3005         (match_operand:QI 1 "general_operand" ""))]
3006   ""
3007   "
3009   if (pa_emit_move_sequence (operands, QImode, 0))
3010     DONE;
3013 ;; Handle QImode input reloads requiring a general register as a
3014 ;; scratch register.
3015 (define_expand "reload_inqi"
3016   [(set (match_operand:QI 0 "register_operand" "=Z")
3017         (match_operand:QI 1 "non_hard_reg_operand" ""))
3018    (clobber (match_operand:QI 2 "register_operand" "=&r"))]
3019   ""
3020   "
3022   if (pa_emit_move_sequence (operands, QImode, operands[2]))
3023     DONE;
3025   /* We don't want the clobber emitted, so handle this ourselves.  */
3026   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
3027   DONE;
3030 ;; Handle QImode output reloads requiring a general register as a
3031 ;; scratch register.
3032 (define_expand "reload_outqi"
3033   [(set (match_operand:QI 0 "non_hard_reg_operand" "")
3034         (match_operand:QI 1  "register_operand" "Z"))
3035    (clobber (match_operand:QI 2 "register_operand" "=&r"))]
3036   ""
3037   "
3039   if (pa_emit_move_sequence (operands, QImode, operands[2]))
3040     DONE;
3042   /* We don't want the clobber emitted, so handle this ourselves.  */
3043   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
3044   DONE;
3047 (define_insn ""
3048   [(set (match_operand:QI 0 "move_dest_operand"
3049                           "=r,r,r,r,r,Q,!*q,!r")
3050         (match_operand:QI 1 "move_src_operand"
3051                           "r,J,N,K,RQ,rM,!rM,!*q"))]
3052   "(register_operand (operands[0], QImode)
3053     || reg_or_0_operand (operands[1], QImode))"
3054   "@
3055    copy %1,%0
3056    ldi %1,%0
3057    ldil L'%1,%0
3058    {zdepi|depwi,z} %Z1,%0
3059    ldb%M1 %1,%0
3060    stb%M0 %r1,%0
3061    mtsar %r1
3062    {mfctl|mfctl,w} %%sar,%0"
3063   [(set_attr "type" "move,move,move,shift,load,store,move,move")
3064    (set_attr "pa_combine_type" "addmove")
3065    (set_attr "length" "4,4,4,4,4,4,4,4")])
3067 (define_insn ""
3068   [(set (match_operand:QI 0 "register_operand" "=r")
3069         (mem:QI (plus:SI (match_operand:SI 1 "register_operand" "+r")
3070                          (match_operand:SI 2 "int5_operand" "L"))))
3071    (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
3072   ""
3073   "{ldbs|ldb},mb %2(%1),%0"
3074   [(set_attr "type" "load")
3075    (set_attr "length" "4")])
3077 (define_insn ""
3078   [(set (match_operand:QI 0 "register_operand" "=r")
3079         (mem:QI (plus:DI (match_operand:DI 1 "register_operand" "+r")
3080                          (match_operand:DI 2 "int5_operand" "L"))))
3081    (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3082   "TARGET_64BIT"
3083   "ldb,mb %2(%1),%0"
3084   [(set_attr "type" "load")
3085    (set_attr "length" "4")])
3087 ; Now the same thing with zero extensions.
3088 (define_insn ""
3089   [(set (match_operand:DI 0 "register_operand" "=r")
3090         (zero_extend:DI (mem:QI (plus:DI
3091                                   (match_operand:DI 1 "register_operand" "+r")
3092                                   (match_operand:DI 2 "int5_operand" "L")))))
3093    (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3094   "TARGET_64BIT"
3095   "ldb,mb %2(%1),%0"
3096   [(set_attr "type" "load")
3097    (set_attr "length" "4")])
3099 (define_insn ""
3100   [(set (match_operand:SI 0 "register_operand" "=r")
3101         (zero_extend:SI (mem:QI (plus:SI
3102                                   (match_operand:SI 1 "register_operand" "+r")
3103                                   (match_operand:SI 2 "int5_operand" "L")))))
3104    (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
3105   ""
3106   "{ldbs|ldb},mb %2(%1),%0"
3107   [(set_attr "type" "load")
3108    (set_attr "length" "4")])
3110 (define_insn ""
3111   [(set (match_operand:SI 0 "register_operand" "=r")
3112         (zero_extend:SI (mem:QI (plus:DI
3113                                   (match_operand:DI 1 "register_operand" "+r")
3114                                   (match_operand:DI 2 "int5_operand" "L")))))
3115    (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3116   "TARGET_64BIT"
3117   "ldb,mb %2(%1),%0"
3118   [(set_attr "type" "load")
3119    (set_attr "length" "4")])
3121 (define_insn ""
3122   [(set (match_operand:HI 0 "register_operand" "=r")
3123         (zero_extend:HI (mem:QI (plus:SI
3124                                   (match_operand:SI 1 "register_operand" "+r")
3125                                   (match_operand:SI 2 "int5_operand" "L")))))
3126    (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
3127   ""
3128   "{ldbs|ldb},mb %2(%1),%0"
3129   [(set_attr "type" "load")
3130    (set_attr "length" "4")])
3132 (define_insn ""
3133   [(set (match_operand:HI 0 "register_operand" "=r")
3134         (zero_extend:HI (mem:QI (plus:DI
3135                                   (match_operand:DI 1 "register_operand" "+r")
3136                                   (match_operand:DI 2 "int5_operand" "L")))))
3137    (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3138   "TARGET_64BIT"
3139   "ldb,mb %2(%1),%0"
3140   [(set_attr "type" "load")
3141    (set_attr "length" "4")])
3143 (define_insn ""
3144   [(set (mem:QI (plus:SI (match_operand:SI 0 "register_operand" "+r")
3145                          (match_operand:SI 1 "int5_operand" "L")))
3146         (match_operand:QI 2 "reg_or_0_operand" "rM"))
3147    (set (match_dup 0)
3148         (plus:SI (match_dup 0) (match_dup 1)))]
3149   ""
3150   "{stbs|stb},mb %r2,%1(%0)"
3151   [(set_attr "type" "store")
3152    (set_attr "length" "4")])
3154 (define_insn ""
3155   [(set (mem:QI (plus:DI (match_operand:DI 0 "register_operand" "+r")
3156                          (match_operand:DI 1 "int5_operand" "L")))
3157         (match_operand:QI 2 "reg_or_0_operand" "rM"))
3158    (set (match_dup 0)
3159         (plus:DI (match_dup 0) (match_dup 1)))]
3160   "TARGET_64BIT"
3161   "stb,mb %r2,%1(%0)"
3162   [(set_attr "type" "store")
3163    (set_attr "length" "4")])
3165 ;; The definition of this insn does not really explain what it does,
3166 ;; but it should suffice that anything generated as this insn will be
3167 ;; recognized as a movmemsi operation, and that it will not successfully
3168 ;; combine with anything.
3169 (define_expand "movmemsi"
3170   [(parallel [(set (match_operand:BLK 0 "" "")
3171                    (match_operand:BLK 1 "" ""))
3172               (clobber (match_dup 4))
3173               (clobber (match_dup 5))
3174               (clobber (match_dup 6))
3175               (clobber (match_dup 7))
3176               (clobber (match_dup 8))
3177               (use (match_operand:SI 2 "arith14_operand" ""))
3178               (use (match_operand:SI 3 "const_int_operand" ""))])]
3179   "!TARGET_64BIT && optimize > 0"
3180   "
3182   int size, align;
3184   /* HP provides very fast block move library routine for the PA;
3185      this routine includes:
3187         4x4 byte at a time block moves,
3188         1x4 byte at a time with alignment checked at runtime with
3189             attempts to align the source and destination as needed
3190         1x1 byte loop
3192      With that in mind, here's the heuristics to try and guess when
3193      the inlined block move will be better than the library block
3194      move:
3196         If the size isn't constant, then always use the library routines.
3198         If the size is large in respect to the known alignment, then use
3199         the library routines.
3201         If the size is small in respect to the known alignment, then open
3202         code the copy (since that will lead to better scheduling).
3204         Else use the block move pattern.   */
3206   /* Undetermined size, use the library routine.  */
3207   if (GET_CODE (operands[2]) != CONST_INT)
3208     FAIL;
3210   size = INTVAL (operands[2]);
3211   align = INTVAL (operands[3]);
3212   align = align > 4 ? 4 : (align ? align : 1);
3214   /* If size/alignment is large, then use the library routines.  */
3215   if (size / align > 16)
3216     FAIL;
3218   /* This does happen, but not often enough to worry much about.  */
3219   if (size / align < MOVE_RATIO (optimize_insn_for_speed_p ()))
3220     FAIL;
3221   
3222   /* Fall through means we're going to use our block move pattern.  */
3223   operands[0]
3224     = replace_equiv_address (operands[0],
3225                              copy_to_mode_reg (SImode, XEXP (operands[0], 0)));
3226   operands[1]
3227     = replace_equiv_address (operands[1],
3228                              copy_to_mode_reg (SImode, XEXP (operands[1], 0)));
3229   operands[4] = gen_reg_rtx (SImode);
3230   operands[5] = gen_reg_rtx (SImode);
3231   operands[6] = gen_reg_rtx (SImode);
3232   operands[7] = gen_reg_rtx (SImode);
3233   operands[8] = gen_reg_rtx (SImode);
3236 ;; The operand constraints are written like this to support both compile-time
3237 ;; and run-time determined byte counts.  The expander and pa_output_block_move
3238 ;; only support compile-time determined counts at this time.
3240 ;; If the count is run-time determined, the register with the byte count
3241 ;; is clobbered by the copying code, and therefore it is forced to operand 2.
3243 ;; We used to clobber operands 0 and 1.  However, a change to regrename.c
3244 ;; broke this semantic for pseudo registers.  We can't use match_scratch
3245 ;; as this requires two registers in the class R1_REGS when the MEMs for
3246 ;; operands 0 and 1 are both equivalent to symbolic MEMs.  Thus, we are
3247 ;; forced to internally copy operands 0 and 1 to operands 7 and 8,
3248 ;; respectively.  We then split or peephole optimize after reload.
3249 (define_insn "movmemsi_prereload"
3250   [(set (mem:BLK (match_operand:SI 0 "register_operand" "r,r"))
3251         (mem:BLK (match_operand:SI 1 "register_operand" "r,r")))
3252    (clobber (match_operand:SI 2 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3253    (clobber (match_operand:SI 3 "register_operand" "=&r,&r"))   ;item tmp1
3254    (clobber (match_operand:SI 6 "register_operand" "=&r,&r"))   ;item tmp2
3255    (clobber (match_operand:SI 7 "register_operand" "=&r,&r"))   ;item tmp3
3256    (clobber (match_operand:SI 8 "register_operand" "=&r,&r"))   ;item tmp4
3257    (use (match_operand:SI 4 "arith14_operand" "J,2"))    ;byte count
3258    (use (match_operand:SI 5 "const_int_operand" "n,n"))] ;alignment
3259   "!TARGET_64BIT"
3260   "#"
3261   [(set_attr "type" "multi,multi")])
3263 (define_split
3264   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3265                    (match_operand:BLK 1 "memory_operand" ""))
3266               (clobber (match_operand:SI 2 "register_operand" ""))
3267               (clobber (match_operand:SI 3 "register_operand" ""))
3268               (clobber (match_operand:SI 6 "register_operand" ""))
3269               (clobber (match_operand:SI 7 "register_operand" ""))
3270               (clobber (match_operand:SI 8 "register_operand" ""))
3271               (use (match_operand:SI 4 "arith14_operand" ""))
3272               (use (match_operand:SI 5 "const_int_operand" ""))])]
3273   "!TARGET_64BIT && reload_completed && !flag_peephole2
3274    && GET_CODE (operands[0]) == MEM
3275    && register_operand (XEXP (operands[0], 0), SImode)
3276    && GET_CODE (operands[1]) == MEM
3277    && register_operand (XEXP (operands[1], 0), SImode)"
3278   [(set (match_dup 7) (match_dup 9))
3279    (set (match_dup 8) (match_dup 10))
3280    (parallel [(set (match_dup 0) (match_dup 1))
3281               (clobber (match_dup 2))
3282               (clobber (match_dup 3))
3283               (clobber (match_dup 6))
3284               (clobber (match_dup 7))
3285               (clobber (match_dup 8))
3286               (use (match_dup 4))
3287               (use (match_dup 5))
3288               (const_int 0)])]
3289   "
3291   operands[9] = XEXP (operands[0], 0);
3292   operands[10] = XEXP (operands[1], 0);
3293   operands[0] = replace_equiv_address (operands[0], operands[7]);
3294   operands[1] = replace_equiv_address (operands[1], operands[8]);
3297 (define_peephole2
3298   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3299                    (match_operand:BLK 1 "memory_operand" ""))
3300               (clobber (match_operand:SI 2 "register_operand" ""))
3301               (clobber (match_operand:SI 3 "register_operand" ""))
3302               (clobber (match_operand:SI 6 "register_operand" ""))
3303               (clobber (match_operand:SI 7 "register_operand" ""))
3304               (clobber (match_operand:SI 8 "register_operand" ""))
3305               (use (match_operand:SI 4 "arith14_operand" ""))
3306               (use (match_operand:SI 5 "const_int_operand" ""))])]
3307   "!TARGET_64BIT
3308    && GET_CODE (operands[0]) == MEM
3309    && register_operand (XEXP (operands[0], 0), SImode)
3310    && GET_CODE (operands[1]) == MEM
3311    && register_operand (XEXP (operands[1], 0), SImode)"
3312   [(parallel [(set (match_dup 0) (match_dup 1))
3313               (clobber (match_dup 2))
3314               (clobber (match_dup 3))
3315               (clobber (match_dup 6))
3316               (clobber (match_dup 7))
3317               (clobber (match_dup 8))
3318               (use (match_dup 4))
3319               (use (match_dup 5))
3320               (const_int 0)])]
3321   "
3323   rtx addr = XEXP (operands[0], 0);
3324   if (dead_or_set_p (curr_insn, addr))
3325     operands[7] = addr;
3326   else
3327     {
3328       emit_insn (gen_rtx_SET (VOIDmode, operands[7], addr));
3329       operands[0] = replace_equiv_address (operands[0], operands[7]);
3330     }
3332   addr = XEXP (operands[1], 0);
3333   if (dead_or_set_p (curr_insn, addr))
3334     operands[8] = addr;
3335   else
3336     {
3337       emit_insn (gen_rtx_SET (VOIDmode, operands[8], addr));
3338       operands[1] = replace_equiv_address (operands[1], operands[8]);
3339     }
3342 (define_insn "movmemsi_postreload"
3343   [(set (mem:BLK (match_operand:SI 0 "register_operand" "+r,r"))
3344         (mem:BLK (match_operand:SI 1 "register_operand" "+r,r")))
3345    (clobber (match_operand:SI 2 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3346    (clobber (match_operand:SI 3 "register_operand" "=&r,&r"))   ;item tmp1
3347    (clobber (match_operand:SI 6 "register_operand" "=&r,&r"))   ;item tmp2
3348    (clobber (match_dup 0))
3349    (clobber (match_dup 1))
3350    (use (match_operand:SI 4 "arith14_operand" "J,2"))    ;byte count
3351    (use (match_operand:SI 5 "const_int_operand" "n,n"))  ;alignment
3352    (const_int 0)]
3353   "!TARGET_64BIT && reload_completed"
3354   "* return pa_output_block_move (operands, !which_alternative);"
3355   [(set_attr "type" "multi,multi")])
3357 (define_expand "movmemdi"
3358   [(parallel [(set (match_operand:BLK 0 "" "")
3359                    (match_operand:BLK 1 "" ""))
3360               (clobber (match_dup 4))
3361               (clobber (match_dup 5))
3362               (clobber (match_dup 6))
3363               (clobber (match_dup 7))
3364               (clobber (match_dup 8))
3365               (use (match_operand:DI 2 "arith14_operand" ""))
3366               (use (match_operand:DI 3 "const_int_operand" ""))])]
3367   "TARGET_64BIT && optimize > 0"
3368   "
3370   int size, align;
3372   /* HP provides very fast block move library routine for the PA;
3373      this routine includes:
3375         4x4 byte at a time block moves,
3376         1x4 byte at a time with alignment checked at runtime with
3377             attempts to align the source and destination as needed
3378         1x1 byte loop
3380      With that in mind, here's the heuristics to try and guess when
3381      the inlined block move will be better than the library block
3382      move:
3384         If the size isn't constant, then always use the library routines.
3386         If the size is large in respect to the known alignment, then use
3387         the library routines.
3389         If the size is small in respect to the known alignment, then open
3390         code the copy (since that will lead to better scheduling).
3392         Else use the block move pattern.   */
3394   /* Undetermined size, use the library routine.  */
3395   if (GET_CODE (operands[2]) != CONST_INT)
3396     FAIL;
3398   size = INTVAL (operands[2]);
3399   align = INTVAL (operands[3]);
3400   align = align > 8 ? 8 : (align ? align : 1);
3402   /* If size/alignment is large, then use the library routines.  */
3403   if (size / align > 16)
3404     FAIL;
3406   /* This does happen, but not often enough to worry much about.  */
3407   if (size / align < MOVE_RATIO (optimize_insn_for_speed_p ()))
3408     FAIL;
3409   
3410   /* Fall through means we're going to use our block move pattern.  */
3411   operands[0]
3412     = replace_equiv_address (operands[0],
3413                              copy_to_mode_reg (DImode, XEXP (operands[0], 0)));
3414   operands[1]
3415     = replace_equiv_address (operands[1],
3416                              copy_to_mode_reg (DImode, XEXP (operands[1], 0)));
3417   operands[4] = gen_reg_rtx (DImode);
3418   operands[5] = gen_reg_rtx (DImode);
3419   operands[6] = gen_reg_rtx (DImode);
3420   operands[7] = gen_reg_rtx (DImode);
3421   operands[8] = gen_reg_rtx (DImode);
3424 ;; The operand constraints are written like this to support both compile-time
3425 ;; and run-time determined byte counts.  The expander and pa_output_block_move
3426 ;; only support compile-time determined counts at this time.
3428 ;; If the count is run-time determined, the register with the byte count
3429 ;; is clobbered by the copying code, and therefore it is forced to operand 2.
3431 ;; We used to clobber operands 0 and 1.  However, a change to regrename.c
3432 ;; broke this semantic for pseudo registers.  We can't use match_scratch
3433 ;; as this requires two registers in the class R1_REGS when the MEMs for
3434 ;; operands 0 and 1 are both equivalent to symbolic MEMs.  Thus, we are
3435 ;; forced to internally copy operands 0 and 1 to operands 7 and 8,
3436 ;; respectively.  We then split or peephole optimize after reload.
3437 (define_insn "movmemdi_prereload"
3438   [(set (mem:BLK (match_operand:DI 0 "register_operand" "r,r"))
3439         (mem:BLK (match_operand:DI 1 "register_operand" "r,r")))
3440    (clobber (match_operand:DI 2 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3441    (clobber (match_operand:DI 3 "register_operand" "=&r,&r"))   ;item tmp1
3442    (clobber (match_operand:DI 6 "register_operand" "=&r,&r"))   ;item tmp2
3443    (clobber (match_operand:DI 7 "register_operand" "=&r,&r"))   ;item tmp3
3444    (clobber (match_operand:DI 8 "register_operand" "=&r,&r"))   ;item tmp4
3445    (use (match_operand:DI 4 "arith14_operand" "J,2"))    ;byte count
3446    (use (match_operand:DI 5 "const_int_operand" "n,n"))] ;alignment
3447   "TARGET_64BIT"
3448   "#"
3449   [(set_attr "type" "multi,multi")])
3451 (define_split
3452   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3453                    (match_operand:BLK 1 "memory_operand" ""))
3454               (clobber (match_operand:DI 2 "register_operand" ""))
3455               (clobber (match_operand:DI 3 "register_operand" ""))
3456               (clobber (match_operand:DI 6 "register_operand" ""))
3457               (clobber (match_operand:DI 7 "register_operand" ""))
3458               (clobber (match_operand:DI 8 "register_operand" ""))
3459               (use (match_operand:DI 4 "arith14_operand" ""))
3460               (use (match_operand:DI 5 "const_int_operand" ""))])]
3461   "TARGET_64BIT && reload_completed && !flag_peephole2
3462    && GET_CODE (operands[0]) == MEM
3463    && register_operand (XEXP (operands[0], 0), DImode)
3464    && GET_CODE (operands[1]) == MEM
3465    && register_operand (XEXP (operands[1], 0), DImode)"
3466   [(set (match_dup 7) (match_dup 9))
3467    (set (match_dup 8) (match_dup 10))
3468    (parallel [(set (match_dup 0) (match_dup 1))
3469               (clobber (match_dup 2))
3470               (clobber (match_dup 3))
3471               (clobber (match_dup 6))
3472               (clobber (match_dup 7))
3473               (clobber (match_dup 8))
3474               (use (match_dup 4))
3475               (use (match_dup 5))
3476               (const_int 0)])]
3477   "
3479   operands[9] = XEXP (operands[0], 0);
3480   operands[10] = XEXP (operands[1], 0);
3481   operands[0] = replace_equiv_address (operands[0], operands[7]);
3482   operands[1] = replace_equiv_address (operands[1], operands[8]);
3485 (define_peephole2
3486   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3487                    (match_operand:BLK 1 "memory_operand" ""))
3488               (clobber (match_operand:DI 2 "register_operand" ""))
3489               (clobber (match_operand:DI 3 "register_operand" ""))
3490               (clobber (match_operand:DI 6 "register_operand" ""))
3491               (clobber (match_operand:DI 7 "register_operand" ""))
3492               (clobber (match_operand:DI 8 "register_operand" ""))
3493               (use (match_operand:DI 4 "arith14_operand" ""))
3494               (use (match_operand:DI 5 "const_int_operand" ""))])]
3495   "TARGET_64BIT
3496    && GET_CODE (operands[0]) == MEM
3497    && register_operand (XEXP (operands[0], 0), DImode)
3498    && GET_CODE (operands[1]) == MEM
3499    && register_operand (XEXP (operands[1], 0), DImode)"
3500   [(parallel [(set (match_dup 0) (match_dup 1))
3501               (clobber (match_dup 2))
3502               (clobber (match_dup 3))
3503               (clobber (match_dup 6))
3504               (clobber (match_dup 7))
3505               (clobber (match_dup 8))
3506               (use (match_dup 4))
3507               (use (match_dup 5))
3508               (const_int 0)])]
3509   "
3511   rtx addr = XEXP (operands[0], 0);
3512   if (dead_or_set_p (curr_insn, addr))
3513     operands[7] = addr;
3514   else
3515     {
3516       emit_insn (gen_rtx_SET (VOIDmode, operands[7], addr));
3517       operands[0] = replace_equiv_address (operands[0], operands[7]);
3518     }
3520   addr = XEXP (operands[1], 0);
3521   if (dead_or_set_p (curr_insn, addr))
3522     operands[8] = addr;
3523   else
3524     {
3525       emit_insn (gen_rtx_SET (VOIDmode, operands[8], addr));
3526       operands[1] = replace_equiv_address (operands[1], operands[8]);
3527     }
3530 (define_insn "movmemdi_postreload"
3531   [(set (mem:BLK (match_operand:DI 0 "register_operand" "+r,r"))
3532         (mem:BLK (match_operand:DI 1 "register_operand" "+r,r")))
3533    (clobber (match_operand:DI 2 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3534    (clobber (match_operand:DI 3 "register_operand" "=&r,&r"))   ;item tmp1
3535    (clobber (match_operand:DI 6 "register_operand" "=&r,&r"))   ;item tmp2
3536    (clobber (match_dup 0))
3537    (clobber (match_dup 1))
3538    (use (match_operand:DI 4 "arith14_operand" "J,2"))    ;byte count
3539    (use (match_operand:DI 5 "const_int_operand" "n,n"))  ;alignment
3540    (const_int 0)]
3541   "TARGET_64BIT && reload_completed"
3542   "* return pa_output_block_move (operands, !which_alternative);"
3543   [(set_attr "type" "multi,multi")])
3545 (define_expand "setmemsi"
3546   [(parallel [(set (match_operand:BLK 0 "" "")
3547                    (match_operand 2 "const_int_operand" ""))
3548               (clobber (match_dup 4))
3549               (clobber (match_dup 5))
3550               (use (match_operand:SI 1 "arith14_operand" ""))
3551               (use (match_operand:SI 3 "const_int_operand" ""))])]
3552   "!TARGET_64BIT && optimize > 0"
3553   "
3555   int size, align;
3557   /* If value to set is not zero, use the library routine.  */
3558   if (operands[2] != const0_rtx)
3559     FAIL;
3561   /* Undetermined size, use the library routine.  */
3562   if (GET_CODE (operands[1]) != CONST_INT)
3563     FAIL;
3565   size = INTVAL (operands[1]);
3566   align = INTVAL (operands[3]);
3567   align = align > 4 ? 4 : align;
3569   /* If size/alignment is large, then use the library routines.  */
3570   if (size / align > 16)
3571     FAIL;
3573   /* This does happen, but not often enough to worry much about.  */
3574   if (size / align < MOVE_RATIO (optimize_insn_for_speed_p ()))
3575     FAIL;
3576   
3577   /* Fall through means we're going to use our block clear pattern.  */
3578   operands[0]
3579     = replace_equiv_address (operands[0],
3580                              copy_to_mode_reg (SImode, XEXP (operands[0], 0)));
3581   operands[4] = gen_reg_rtx (SImode);
3582   operands[5] = gen_reg_rtx (SImode);
3585 (define_insn "clrmemsi_prereload"
3586   [(set (mem:BLK (match_operand:SI 0 "register_operand" "r,r"))
3587         (const_int 0))
3588    (clobber (match_operand:SI 1 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3589    (clobber (match_operand:SI 4 "register_operand" "=&r,&r"))   ;tmp1
3590    (use (match_operand:SI 2 "arith14_operand" "J,1"))    ;byte count
3591    (use (match_operand:SI 3 "const_int_operand" "n,n"))] ;alignment
3592   "!TARGET_64BIT"
3593   "#"
3594   [(set_attr "type" "multi,multi")])
3596 (define_split
3597   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3598                    (const_int 0))
3599               (clobber (match_operand:SI 1 "register_operand" ""))
3600               (clobber (match_operand:SI 4 "register_operand" ""))
3601               (use (match_operand:SI 2 "arith14_operand" ""))
3602               (use (match_operand:SI 3 "const_int_operand" ""))])]
3603   "!TARGET_64BIT && reload_completed && !flag_peephole2
3604    && GET_CODE (operands[0]) == MEM
3605    && register_operand (XEXP (operands[0], 0), SImode)"
3606   [(set (match_dup 4) (match_dup 5))
3607    (parallel [(set (match_dup 0) (const_int 0))
3608               (clobber (match_dup 1))
3609               (clobber (match_dup 4))
3610               (use (match_dup 2))
3611               (use (match_dup 3))
3612               (const_int 0)])]
3613   "
3615   operands[5] = XEXP (operands[0], 0);
3616   operands[0] = replace_equiv_address (operands[0], operands[4]);
3619 (define_peephole2
3620   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3621                    (const_int 0))
3622               (clobber (match_operand:SI 1 "register_operand" ""))
3623               (clobber (match_operand:SI 4 "register_operand" ""))
3624               (use (match_operand:SI 2 "arith14_operand" ""))
3625               (use (match_operand:SI 3 "const_int_operand" ""))])]
3626   "!TARGET_64BIT
3627    && GET_CODE (operands[0]) == MEM
3628    && register_operand (XEXP (operands[0], 0), SImode)"
3629   [(parallel [(set (match_dup 0) (const_int 0))
3630               (clobber (match_dup 1))
3631               (clobber (match_dup 4))
3632               (use (match_dup 2))
3633               (use (match_dup 3))
3634               (const_int 0)])]
3635   "
3637   rtx addr = XEXP (operands[0], 0);
3638   if (dead_or_set_p (curr_insn, addr))
3639     operands[4] = addr;
3640   else
3641     {
3642       emit_insn (gen_rtx_SET (VOIDmode, operands[4], addr));
3643       operands[0] = replace_equiv_address (operands[0], operands[4]);
3644     }
3647 (define_insn "clrmemsi_postreload"
3648   [(set (mem:BLK (match_operand:SI 0 "register_operand" "+r,r"))
3649         (const_int 0))
3650    (clobber (match_operand:SI 1 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3651    (clobber (match_dup 0))
3652    (use (match_operand:SI 2 "arith14_operand" "J,1"))    ;byte count
3653    (use (match_operand:SI 3 "const_int_operand" "n,n"))  ;alignment
3654    (const_int 0)]
3655   "!TARGET_64BIT && reload_completed"
3656   "* return pa_output_block_clear (operands, !which_alternative);"
3657   [(set_attr "type" "multi,multi")])
3659 (define_expand "setmemdi"
3660   [(parallel [(set (match_operand:BLK 0 "" "")
3661                    (match_operand 2 "const_int_operand" ""))
3662               (clobber (match_dup 4))
3663               (clobber (match_dup 5))
3664               (use (match_operand:DI 1 "arith14_operand" ""))
3665               (use (match_operand:DI 3 "const_int_operand" ""))])]
3666   "TARGET_64BIT && optimize > 0"
3667   "
3669   int size, align;
3671   /* If value to set is not zero, use the library routine.  */
3672   if (operands[2] != const0_rtx)
3673     FAIL;
3675   /* Undetermined size, use the library routine.  */
3676   if (GET_CODE (operands[1]) != CONST_INT)
3677     FAIL;
3679   size = INTVAL (operands[1]);
3680   align = INTVAL (operands[3]);
3681   align = align > 8 ? 8 : align;
3683   /* If size/alignment is large, then use the library routines.  */
3684   if (size / align > 16)
3685     FAIL;
3687   /* This does happen, but not often enough to worry much about.  */
3688   if (size / align < MOVE_RATIO (optimize_insn_for_speed_p ()))
3689     FAIL;
3690   
3691   /* Fall through means we're going to use our block clear pattern.  */
3692   operands[0]
3693     = replace_equiv_address (operands[0],
3694                              copy_to_mode_reg (DImode, XEXP (operands[0], 0)));
3695   operands[4] = gen_reg_rtx (DImode);
3696   operands[5] = gen_reg_rtx (DImode);
3699 (define_insn "clrmemdi_prereload"
3700   [(set (mem:BLK (match_operand:DI 0 "register_operand" "r,r"))
3701         (const_int 0))
3702    (clobber (match_operand:DI 1 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3703    (clobber (match_operand:DI 4 "register_operand" "=&r,&r"))   ;item tmp1
3704    (use (match_operand:DI 2 "arith14_operand" "J,1"))    ;byte count
3705    (use (match_operand:DI 3 "const_int_operand" "n,n"))] ;alignment
3706   "TARGET_64BIT"
3707   "#"
3708   [(set_attr "type" "multi,multi")])
3710 (define_split
3711   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3712                    (const_int 0))
3713               (clobber (match_operand:DI 1 "register_operand" ""))
3714               (clobber (match_operand:DI 4 "register_operand" ""))
3715               (use (match_operand:DI 2 "arith14_operand" ""))
3716               (use (match_operand:DI 3 "const_int_operand" ""))])]
3717   "TARGET_64BIT && reload_completed && !flag_peephole2
3718    && GET_CODE (operands[0]) == MEM
3719    && register_operand (XEXP (operands[0], 0), DImode)"
3720   [(set (match_dup 4) (match_dup 5))
3721    (parallel [(set (match_dup 0) (const_int 0))
3722               (clobber (match_dup 1))
3723               (clobber (match_dup 4))
3724               (use (match_dup 2))
3725               (use (match_dup 3))
3726               (const_int 0)])]
3727   "
3729   operands[5] = XEXP (operands[0], 0);
3730   operands[0] = replace_equiv_address (operands[0], operands[4]);
3733 (define_peephole2
3734   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3735                    (const_int 0))
3736               (clobber (match_operand:DI 1 "register_operand" ""))
3737               (clobber (match_operand:DI 4 "register_operand" ""))
3738               (use (match_operand:DI 2 "arith14_operand" ""))
3739               (use (match_operand:DI 3 "const_int_operand" ""))])]
3740   "TARGET_64BIT
3741    && GET_CODE (operands[0]) == MEM
3742    && register_operand (XEXP (operands[0], 0), DImode)"
3743   [(parallel [(set (match_dup 0) (const_int 0))
3744               (clobber (match_dup 1))
3745               (clobber (match_dup 4))
3746               (use (match_dup 2))
3747               (use (match_dup 3))
3748               (const_int 0)])]
3749   "
3750 {  
3751   rtx addr = XEXP (operands[0], 0);
3752   if (dead_or_set_p (curr_insn, addr))
3753     operands[4] = addr;
3754   else
3755     {
3756       emit_insn (gen_rtx_SET (VOIDmode, operands[4], addr));
3757       operands[0] = replace_equiv_address (operands[0], operands[4]);
3758     }
3761 (define_insn "clrmemdi_postreload"
3762   [(set (mem:BLK (match_operand:DI 0 "register_operand" "+r,r"))
3763         (const_int 0))
3764    (clobber (match_operand:DI 1 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3765    (clobber (match_dup 0))
3766    (use (match_operand:DI 2 "arith14_operand" "J,1"))    ;byte count
3767    (use (match_operand:DI 3 "const_int_operand" "n,n"))  ;alignment
3768    (const_int 0)]
3769   "TARGET_64BIT && reload_completed"
3770   "* return pa_output_block_clear (operands, !which_alternative);"
3771   [(set_attr "type" "multi,multi")])
3773 ;; Floating point move insns
3775 (define_expand "movdf"
3776   [(set (match_operand:DF 0 "general_operand" "")
3777         (match_operand:DF 1 "general_operand" ""))]
3778   ""
3779   "
3781   if (pa_emit_move_sequence (operands, DFmode, 0))
3782     DONE;
3785 ;; Handle DFmode input reloads requiring %r1 as a scratch register.
3786 (define_expand "reload_indf_r1"
3787   [(set (match_operand:DF 0 "register_operand" "=Z")
3788         (match_operand:DF 1 "non_hard_reg_operand" ""))
3789    (clobber (match_operand:SI 2 "register_operand" "=&a"))]
3790   ""
3791   "
3793   if (pa_emit_move_sequence (operands, DFmode, operands[2]))
3794     DONE;
3796   /* We don't want the clobber emitted, so handle this ourselves.  */
3797   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
3798   DONE;
3801 ;; Handle DFmode input reloads requiring a general register as a
3802 ;; scratch register.
3803 (define_expand "reload_indf"
3804   [(set (match_operand:DF 0 "register_operand" "=Z")
3805         (match_operand:DF 1 "non_hard_reg_operand" ""))
3806    (clobber (match_operand:DF 2 "register_operand" "=&r"))]
3807   ""
3808   "
3810   if (pa_emit_move_sequence (operands, DFmode, operands[2]))
3811     DONE;
3813   /* We don't want the clobber emitted, so handle this ourselves.  */
3814   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
3815   DONE;
3818 ;; Handle DFmode output reloads requiring a general register as a
3819 ;; scratch register.
3820 (define_expand "reload_outdf" 
3821  [(set (match_operand:DF 0 "non_hard_reg_operand" "")
3822         (match_operand:DF 1  "register_operand" "Z"))
3823    (clobber (match_operand:DF 2 "register_operand" "=&r"))]
3824   ""
3825   "
3827   if (pa_emit_move_sequence (operands, DFmode, operands[2]))
3828     DONE;
3830   /* We don't want the clobber emitted, so handle this ourselves.  */
3831   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
3832   DONE;
3835 (define_insn ""
3836   [(set (match_operand:DF 0 "move_dest_operand"
3837                           "=f,*r,T,?o,?Q,f,*r,*r,?*r,?f")
3838         (match_operand:DF 1 "reg_or_0_or_nonsymb_mem_operand"
3839                           "fG,*rG,f,*r,*r,RT,o,RQ,f,*r"))]
3840   "(register_operand (operands[0], DFmode)
3841     || reg_or_0_operand (operands[1], DFmode))
3842    && !(GET_CODE (operands[1]) == CONST_DOUBLE
3843         && GET_CODE (operands[0]) == MEM)
3844    && !TARGET_64BIT
3845    && !TARGET_SOFT_FLOAT"
3846   "*
3848   if ((FP_REG_P (operands[0]) || FP_REG_P (operands[1])
3849        || operands[1] == CONST0_RTX (DFmode))
3850       && !(REG_P (operands[0]) && REG_P (operands[1])
3851            && FP_REG_P (operands[0]) ^ FP_REG_P (operands[1])))
3852     return pa_output_fp_move_double (operands);
3853   return pa_output_move_double (operands);
3855   [(set_attr "type" "fpalu,move,fpstore,store,store,fpload,load,load,fpstore_load,store_fpload")
3856    (set_attr "length" "4,8,4,8,16,4,8,16,12,12")])
3858 (define_insn ""
3859   [(set (match_operand:DF 0 "indexed_memory_operand" "=R")
3860         (match_operand:DF 1 "reg_or_0_operand" "f"))]
3861   "!TARGET_SOFT_FLOAT
3862    && !TARGET_DISABLE_INDEXING
3863    && reload_completed"
3864   "fstd%F0 %1,%0"
3865   [(set_attr "type" "fpstore")
3866    (set_attr "pa_combine_type" "addmove")
3867    (set_attr "length" "4")])
3869 (define_peephole2
3870   [(set (match_operand:SI 0 "register_operand" "")
3871         (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "")
3872                           (const_int 8))
3873                  (match_operand:SI 2 "register_operand" "")))
3874    (set (mem:DF (match_dup 0))
3875         (match_operand:DF 3 "register_operand" ""))]
3876   "!TARGET_SOFT_FLOAT
3877    && !TARGET_DISABLE_INDEXING
3878    && REG_OK_FOR_BASE_P (operands[2])
3879    && FP_REGNO_P (REGNO (operands[3]))"
3880   [(set (mem:DF (plus:SI (mult:SI (match_dup 1) (const_int 8)) (match_dup 2)))
3881         (match_dup 3))
3882    (set (match_dup 0) (plus:SI (mult:SI (match_dup 1) (const_int 8))
3883                                (match_dup 2)))]
3884   "")
3886 (define_peephole2
3887   [(set (match_operand:SI 0 "register_operand" "")
3888         (plus:SI (match_operand:SI 2 "register_operand" "")
3889                  (mult:SI (match_operand:SI 1 "register_operand" "")
3890                           (const_int 8))))
3891    (set (mem:DF (match_dup 0))
3892         (match_operand:DF 3 "register_operand" ""))]
3893   "!TARGET_SOFT_FLOAT
3894    && !TARGET_DISABLE_INDEXING
3895    && REG_OK_FOR_BASE_P (operands[2])
3896    && FP_REGNO_P (REGNO (operands[3]))"
3897   [(set (mem:DF (plus:SI (mult:SI (match_dup 1) (const_int 8)) (match_dup 2)))
3898         (match_dup 3))
3899    (set (match_dup 0) (plus:SI (mult:SI (match_dup 1) (const_int 8))
3900                                (match_dup 2)))]
3901   "")
3903 (define_peephole2
3904   [(set (match_operand:DI 0 "register_operand" "")
3905         (plus:DI (mult:DI (match_operand:DI 1 "register_operand" "")
3906                           (const_int 8))
3907                  (match_operand:DI 2 "register_operand" "")))
3908    (set (mem:DF (match_dup 0))
3909         (match_operand:DF 3 "register_operand" ""))]
3910   "!TARGET_SOFT_FLOAT
3911    && !TARGET_DISABLE_INDEXING
3912    && TARGET_64BIT
3913    && REG_OK_FOR_BASE_P (operands[2])
3914    && FP_REGNO_P (REGNO (operands[3]))"
3915   [(set (mem:DF (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
3916         (match_dup 3))
3917    (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 8))
3918                                (match_dup 2)))]
3919   "")
3921 (define_peephole2
3922   [(set (match_operand:DI 0 "register_operand" "")
3923         (plus:DI (match_operand:DI 2 "register_operand" "")
3924                  (mult:DI (match_operand:DI 1 "register_operand" "")
3925                           (const_int 8))))
3926    (set (mem:DF (match_dup 0))
3927         (match_operand:DF 3 "register_operand" ""))]
3928   "!TARGET_SOFT_FLOAT
3929    && !TARGET_DISABLE_INDEXING
3930    && TARGET_64BIT
3931    && REG_OK_FOR_BASE_P (operands[2])
3932    && FP_REGNO_P (REGNO (operands[3]))"
3933   [(set (mem:DF (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
3934         (match_dup 3))
3935    (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 8))
3936                                (match_dup 2)))]
3937   "")
3939 (define_peephole2
3940   [(set (match_operand:SI 0 "register_operand" "")
3941         (plus:SI (match_operand:SI 1 "register_operand" "")
3942                  (match_operand:SI 2 "register_operand" "")))
3943    (set (mem:DF (match_dup 0))
3944         (match_operand:DF 3 "register_operand" ""))]
3945   "!TARGET_SOFT_FLOAT
3946    && !TARGET_DISABLE_INDEXING
3947    && TARGET_NO_SPACE_REGS
3948    && REG_OK_FOR_INDEX_P (operands[1])
3949    && REG_OK_FOR_BASE_P (operands[2])
3950    && FP_REGNO_P (REGNO (operands[3]))"
3951   [(set (mem:DF (plus:SI (match_dup 1) (match_dup 2)))
3952         (match_dup 3))
3953    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
3954   "")
3956 (define_peephole2
3957   [(set (match_operand:SI 0 "register_operand" "")
3958         (plus:SI (match_operand:SI 1 "register_operand" "")
3959                  (match_operand:SI 2 "register_operand" "")))
3960    (set (mem:DF (match_dup 0))
3961         (match_operand:DF 3 "register_operand" ""))]
3962   "!TARGET_SOFT_FLOAT
3963    && !TARGET_DISABLE_INDEXING
3964    && TARGET_NO_SPACE_REGS
3965    && REG_OK_FOR_BASE_P (operands[1])
3966    && REG_OK_FOR_INDEX_P (operands[2])
3967    && FP_REGNO_P (REGNO (operands[3]))"
3968   [(set (mem:DF (plus:SI (match_dup 2) (match_dup 1)))
3969         (match_dup 3))
3970    (set (match_dup 0) (plus:SI (match_dup 2) (match_dup 1)))]
3971   "")
3973 (define_peephole2
3974   [(set (match_operand:DI 0 "register_operand" "")
3975         (plus:DI (match_operand:DI 1 "register_operand" "")
3976                  (match_operand:DI 2 "register_operand" "")))
3977    (set (mem:DF (match_dup 0))
3978         (match_operand:DF 3 "register_operand" ""))]
3979   "!TARGET_SOFT_FLOAT
3980    && !TARGET_DISABLE_INDEXING
3981    && TARGET_64BIT
3982    && TARGET_NO_SPACE_REGS
3983    && REG_OK_FOR_INDEX_P (operands[1])
3984    && REG_OK_FOR_BASE_P (operands[2])
3985    && FP_REGNO_P (REGNO (operands[3]))"
3986   [(set (mem:DF (plus:DI (match_dup 1) (match_dup 2)))
3987         (match_dup 3))
3988    (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
3989   "")
3991 (define_peephole2
3992   [(set (match_operand:DI 0 "register_operand" "")
3993         (plus:DI (match_operand:DI 1 "register_operand" "")
3994                  (match_operand:DI 2 "register_operand" "")))
3995    (set (mem:DF (match_dup 0))
3996         (match_operand:DF 3 "register_operand" ""))]
3997   "!TARGET_SOFT_FLOAT
3998    && !TARGET_DISABLE_INDEXING
3999    && TARGET_64BIT
4000    && TARGET_NO_SPACE_REGS
4001    && REG_OK_FOR_BASE_P (operands[1])
4002    && REG_OK_FOR_INDEX_P (operands[2])
4003    && FP_REGNO_P (REGNO (operands[3]))"
4004   [(set (mem:DF (plus:DI (match_dup 2) (match_dup 1)))
4005         (match_dup 3))
4006    (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
4007   "")
4009 (define_insn ""
4010   [(set (match_operand:DF 0 "move_dest_operand"
4011                           "=r,?o,?Q,r,r")
4012         (match_operand:DF 1 "reg_or_0_or_nonsymb_mem_operand"
4013                           "rG,r,r,o,RQ"))]
4014   "(register_operand (operands[0], DFmode)
4015     || reg_or_0_operand (operands[1], DFmode))
4016    && !TARGET_64BIT
4017    && TARGET_SOFT_FLOAT"
4018   "*
4020   return pa_output_move_double (operands);
4022   [(set_attr "type" "move,store,store,load,load")
4023    (set_attr "length" "8,8,16,8,16")])
4025 (define_insn ""
4026   [(set (match_operand:DF 0 "move_dest_operand"
4027                           "=!*r,*r,*r,*r,*r,Q,f,f,T")
4028         (match_operand:DF 1 "move_src_operand"
4029                           "!*r,J,N,K,RQ,*rG,fG,RT,f"))]
4030   "(register_operand (operands[0], DFmode)
4031     || reg_or_0_operand (operands[1], DFmode))
4032    && !TARGET_SOFT_FLOAT && TARGET_64BIT"
4033   "@
4034    copy %1,%0
4035    ldi %1,%0
4036    ldil L'%1,%0
4037    depdi,z %z1,%0
4038    ldd%M1 %1,%0
4039    std%M0 %r1,%0
4040    fcpy,dbl %f1,%0
4041    fldd%F1 %1,%0
4042    fstd%F0 %1,%0"
4043   [(set_attr "type" "move,move,move,shift,load,store,fpalu,fpload,fpstore")
4044    (set_attr "pa_combine_type" "addmove")
4045    (set_attr "length" "4,4,4,4,4,4,4,4,4")])
4048 (define_expand "movdi"
4049   [(set (match_operand:DI 0 "general_operand" "")
4050         (match_operand:DI 1 "general_operand" ""))]
4051   ""
4052   "
4054   if (pa_emit_move_sequence (operands, DImode, 0))
4055     DONE;
4058 ;; Handle DImode input reloads requiring %r1 as a scratch register.
4059 (define_expand "reload_indi_r1"
4060   [(set (match_operand:DI 0 "register_operand" "=Z")
4061         (match_operand:DI 1 "non_hard_reg_operand" ""))
4062    (clobber (match_operand:SI 2 "register_operand" "=&a"))]
4063   ""
4064   "
4066   if (pa_emit_move_sequence (operands, DImode, operands[2]))
4067     DONE;
4069   /* We don't want the clobber emitted, so handle this ourselves.  */
4070   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
4071   DONE;
4074 ;; Handle DImode input reloads requiring a general register as a
4075 ;; scratch register.
4076 (define_expand "reload_indi"
4077   [(set (match_operand:DI 0 "register_operand" "=Z")
4078         (match_operand:DI 1 "non_hard_reg_operand" ""))
4079    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
4080   ""
4081   "
4083   if (pa_emit_move_sequence (operands, DImode, operands[2]))
4084     DONE;
4086   /* We don't want the clobber emitted, so handle this ourselves.  */
4087   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
4088   DONE;
4091 ;; Handle DImode output reloads requiring a general register as a
4092 ;; scratch register.
4093 (define_expand "reload_outdi"
4094   [(set (match_operand:DI 0 "non_hard_reg_operand" "")
4095         (match_operand:DI 1 "register_operand" "Z"))
4096    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
4097   ""
4098   "
4100   if (pa_emit_move_sequence (operands, DImode, operands[2]))
4101     DONE;
4103   /* We don't want the clobber emitted, so handle this ourselves.  */
4104   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
4105   DONE;
4108 (define_insn ""
4109   [(set (match_operand:DI 0 "register_operand" "=r")
4110         (high:DI (match_operand 1 "" "")))]
4111   "!TARGET_64BIT"
4112   "*
4114   rtx op0 = operands[0];
4115   rtx op1 = operands[1];
4117   switch (GET_CODE (op1))
4118     {
4119     case CONST_INT:
4120 #if HOST_BITS_PER_WIDE_INT <= 32
4121       operands[0] = operand_subword (op0, 1, 0, DImode);
4122       output_asm_insn (\"ldil L'%1,%0\", operands);
4124       operands[0] = operand_subword (op0, 0, 0, DImode);
4125       if (INTVAL (op1) < 0)
4126         output_asm_insn (\"ldi -1,%0\", operands);
4127       else
4128         output_asm_insn (\"ldi 0,%0\", operands);
4129 #else
4130       operands[0] = operand_subword (op0, 1, 0, DImode);
4131       operands[1] = GEN_INT (INTVAL (op1) & 0xffffffff);
4132       output_asm_insn (\"ldil L'%1,%0\", operands);
4134       operands[0] = operand_subword (op0, 0, 0, DImode);
4135       operands[1] = GEN_INT (INTVAL (op1) >> 32);
4136       output_asm_insn (pa_singlemove_string (operands), operands);
4137 #endif
4138       break;
4140     case CONST_DOUBLE:
4141       operands[0] = operand_subword (op0, 1, 0, DImode);
4142       operands[1] = GEN_INT (CONST_DOUBLE_LOW (op1));
4143       output_asm_insn (\"ldil L'%1,%0\", operands);
4145       operands[0] = operand_subword (op0, 0, 0, DImode);
4146       operands[1] = GEN_INT (CONST_DOUBLE_HIGH (op1));
4147       output_asm_insn (pa_singlemove_string (operands), operands);
4148       break;
4150     default:
4151       gcc_unreachable ();
4152     }
4153   return \"\";
4155   [(set_attr "type" "move")
4156    (set_attr "length" "12")])
4158 (define_insn ""
4159   [(set (match_operand:DI 0 "move_dest_operand"
4160                           "=r,o,Q,r,r,r,*f,*f,T,?r,?*f")
4161         (match_operand:DI 1 "move_src_operand"
4162                           "rM,r,r,o*R,Q,i,*fM,RT,*f,*f,r"))]
4163   "(register_operand (operands[0], DImode)
4164     || reg_or_0_operand (operands[1], DImode))
4165    && !TARGET_64BIT
4166    && !TARGET_SOFT_FLOAT"
4167   "*
4169   if ((FP_REG_P (operands[0]) || FP_REG_P (operands[1])
4170        || operands[1] == CONST0_RTX (DFmode))
4171       && !(REG_P (operands[0]) && REG_P (operands[1])
4172            && FP_REG_P (operands[0]) ^ FP_REG_P (operands[1])))
4173     return pa_output_fp_move_double (operands);
4174   return pa_output_move_double (operands);
4176   [(set_attr "type"
4177     "move,store,store,load,load,multi,fpalu,fpload,fpstore,fpstore_load,store_fpload")
4178    (set_attr "length" "8,8,16,8,16,16,4,4,4,12,12")])
4180 (define_insn ""
4181   [(set (match_operand:DI 0 "move_dest_operand"
4182                           "=r,r,r,r,r,r,Q,!*q,!r,!*f,*f,T")
4183         (match_operand:DI 1 "move_src_operand"
4184                           "A,r,J,N,K,RQ,rM,!rM,!*q,!*fM,RT,*f"))]
4185   "(register_operand (operands[0], DImode)
4186     || reg_or_0_operand (operands[1], DImode))
4187    && !TARGET_SOFT_FLOAT && TARGET_64BIT"
4188   "@
4189    ldd RT'%A1,%0
4190    copy %1,%0
4191    ldi %1,%0
4192    ldil L'%1,%0
4193    depdi,z %z1,%0
4194    ldd%M1 %1,%0
4195    std%M0 %r1,%0
4196    mtsar %r1
4197    {mfctl|mfctl,w} %%sar,%0
4198    fcpy,dbl %f1,%0
4199    fldd%F1 %1,%0
4200    fstd%F0 %1,%0"
4201   [(set_attr "type" "load,move,move,move,shift,load,store,move,move,fpalu,fpload,fpstore")
4202    (set_attr "pa_combine_type" "addmove")
4203    (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4")])
4205 (define_insn ""
4206   [(set (match_operand:DI 0 "indexed_memory_operand" "=R")
4207         (match_operand:DI 1 "register_operand" "f"))]
4208   "!TARGET_SOFT_FLOAT
4209    && TARGET_64BIT
4210    && !TARGET_DISABLE_INDEXING
4211    && reload_completed"
4212   "fstd%F0 %1,%0"
4213   [(set_attr "type" "fpstore")
4214    (set_attr "pa_combine_type" "addmove")
4215    (set_attr "length" "4")])
4217 (define_peephole2
4218   [(set (match_operand:DI 0 "register_operand" "")
4219         (plus:DI (mult:DI (match_operand:DI 1 "register_operand" "")
4220                           (const_int 8))
4221                  (match_operand:DI 2 "register_operand" "")))
4222    (set (mem:DI (match_dup 0))
4223         (match_operand:DI 3 "register_operand" ""))]
4224   "!TARGET_SOFT_FLOAT
4225    && !TARGET_DISABLE_INDEXING
4226    && TARGET_64BIT
4227    && REG_OK_FOR_BASE_P (operands[2])
4228    && FP_REGNO_P (REGNO (operands[3]))"
4229   [(set (mem:DI (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
4230         (match_dup 3))
4231    (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 8))
4232                                (match_dup 2)))]
4233   "")
4235 (define_peephole2
4236   [(set (match_operand:DI 0 "register_operand" "")
4237         (plus:DI (match_operand:DI 2 "register_operand" "")
4238                  (mult:DI (match_operand:DI 1 "register_operand" "")
4239                           (const_int 8))))
4240    (set (mem:DI (match_dup 0))
4241         (match_operand:DI 3 "register_operand" ""))]
4242   "!TARGET_SOFT_FLOAT
4243    && !TARGET_DISABLE_INDEXING
4244    && TARGET_64BIT
4245    && REG_OK_FOR_BASE_P (operands[2])
4246    && FP_REGNO_P (REGNO (operands[3]))"
4247   [(set (mem:DI (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
4248         (match_dup 3))
4249    (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 8))
4250                                (match_dup 2)))]
4251   "")
4253 (define_peephole2
4254   [(set (match_operand:DI 0 "register_operand" "")
4255         (plus:DI (match_operand:DI 1 "register_operand" "")
4256                  (match_operand:DI 2 "register_operand" "")))
4257    (set (mem:DI (match_dup 0))
4258         (match_operand:DI 3 "register_operand" ""))]
4259   "!TARGET_SOFT_FLOAT
4260    && !TARGET_DISABLE_INDEXING
4261    && TARGET_64BIT
4262    && TARGET_NO_SPACE_REGS
4263    && REG_OK_FOR_INDEX_P (operands[1])
4264    && REG_OK_FOR_BASE_P (operands[2])
4265    && FP_REGNO_P (REGNO (operands[3]))"
4266   [(set (mem:DI (plus:DI (match_dup 1) (match_dup 2)))
4267         (match_dup 3))
4268    (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
4269   "")
4271 (define_peephole2
4272   [(set (match_operand:DI 0 "register_operand" "")
4273         (plus:DI (match_operand:DI 1 "register_operand" "")
4274                  (match_operand:DI 2 "register_operand" "")))
4275    (set (mem:DI (match_dup 0))
4276         (match_operand:DI 3 "register_operand" ""))]
4277   "!TARGET_SOFT_FLOAT
4278    && !TARGET_DISABLE_INDEXING
4279    && TARGET_64BIT
4280    && TARGET_NO_SPACE_REGS
4281    && REG_OK_FOR_BASE_P (operands[1])
4282    && REG_OK_FOR_INDEX_P (operands[2])
4283    && FP_REGNO_P (REGNO (operands[3]))"
4284   [(set (mem:DI (plus:DI (match_dup 2) (match_dup 1)))
4285         (match_dup 3))
4286    (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
4287   "")
4289 (define_insn ""
4290   [(set (match_operand:DI 0 "move_dest_operand"
4291                           "=r,o,Q,r,r,r")
4292         (match_operand:DI 1 "general_operand"
4293                           "rM,r,r,o,Q,i"))]
4294   "(register_operand (operands[0], DImode)
4295     || reg_or_0_operand (operands[1], DImode))
4296    && !TARGET_64BIT
4297    && TARGET_SOFT_FLOAT"
4298   "*
4300   return pa_output_move_double (operands);
4302   [(set_attr "type" "move,store,store,load,load,multi")
4303    (set_attr "length" "8,8,16,8,16,16")])
4305 (define_insn ""
4306   [(set (match_operand:DI 0 "register_operand" "=r,&r")
4307         (lo_sum:DI (match_operand:DI 1 "register_operand" "0,r")
4308                    (match_operand:DI 2 "immediate_operand" "i,i")))]
4309   "!TARGET_64BIT"
4310   "*
4312   /* Don't output a 64-bit constant, since we can't trust the assembler to
4313      handle it correctly.  */
4314   if (GET_CODE (operands[2]) == CONST_DOUBLE)
4315     operands[2] = GEN_INT (CONST_DOUBLE_LOW (operands[2]));
4316   else if (HOST_BITS_PER_WIDE_INT > 32
4317            && GET_CODE (operands[2]) == CONST_INT)
4318     operands[2] = GEN_INT (INTVAL (operands[2]) & 0xffffffff);
4319   if (which_alternative == 1)
4320     output_asm_insn (\"copy %1,%0\", operands);
4321   return \"ldo R'%G2(%R1),%R0\";
4323   [(set_attr "type" "move,move")
4324    (set_attr "length" "4,8")])
4326 (define_expand "movsf"
4327   [(set (match_operand:SF 0 "general_operand" "")
4328         (match_operand:SF 1 "general_operand" ""))]
4329   ""
4330   "
4332   if (pa_emit_move_sequence (operands, SFmode, 0))
4333     DONE;
4336 ;; Handle SFmode input reloads requiring %r1 as a scratch register.
4337 (define_expand "reload_insf_r1"
4338   [(set (match_operand:SF 0 "register_operand" "=Z")
4339         (match_operand:SF 1 "non_hard_reg_operand" ""))
4340    (clobber (match_operand:SI 2 "register_operand" "=&a"))]
4341   ""
4342   "
4344   if (pa_emit_move_sequence (operands, SFmode, operands[2]))
4345     DONE;
4347   /* We don't want the clobber emitted, so handle this ourselves.  */
4348   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
4349   DONE;
4352 ;; Handle SFmode input reloads requiring a general register as a
4353 ;; scratch register.
4354 (define_expand "reload_insf"
4355   [(set (match_operand:SF 0 "register_operand" "=Z")
4356         (match_operand:SF 1 "non_hard_reg_operand" ""))
4357    (clobber (match_operand:SF 2 "register_operand" "=&r"))]
4358   ""
4359   "
4361   if (pa_emit_move_sequence (operands, SFmode, operands[2]))
4362     DONE;
4364   /* We don't want the clobber emitted, so handle this ourselves.  */
4365   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
4366   DONE;
4369 ;; Handle SFmode output reloads requiring a general register as a
4370 ;; scratch register.
4371 (define_expand "reload_outsf"
4372   [(set (match_operand:SF 0 "non_hard_reg_operand" "")
4373         (match_operand:SF 1  "register_operand" "Z"))
4374    (clobber (match_operand:SF 2 "register_operand" "=&r"))]
4375   ""
4376   "
4378   if (pa_emit_move_sequence (operands, SFmode, operands[2]))
4379     DONE;
4381   /* We don't want the clobber emitted, so handle this ourselves.  */
4382   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
4383   DONE;
4386 (define_insn ""
4387   [(set (match_operand:SF 0 "move_dest_operand"
4388                           "=f,!*r,f,*r,T,Q,?*r,?f")
4389         (match_operand:SF 1 "reg_or_0_or_nonsymb_mem_operand"
4390                           "fG,!*rG,RT,RQ,f,*rG,f,*r"))]
4391   "(register_operand (operands[0], SFmode)
4392     || reg_or_0_operand (operands[1], SFmode))
4393    && !TARGET_SOFT_FLOAT
4394    && !TARGET_64BIT"
4395   "@
4396    fcpy,sgl %f1,%0
4397    copy %r1,%0
4398    fldw%F1 %1,%0
4399    ldw%M1 %1,%0
4400    fstw%F0 %1,%0
4401    stw%M0 %r1,%0
4402    {fstws|fstw} %1,-16(%%sp)\n\t{ldws|ldw} -16(%%sp),%0
4403    {stws|stw} %1,-16(%%sp)\n\t{fldws|fldw} -16(%%sp),%0"
4404   [(set_attr "type" "fpalu,move,fpload,load,fpstore,store,fpstore_load,store_fpload")
4405    (set_attr "pa_combine_type" "addmove")
4406    (set_attr "length" "4,4,4,4,4,4,8,8")])
4408 (define_insn ""
4409   [(set (match_operand:SF 0 "move_dest_operand"
4410                           "=f,!*r,f,*r,T,Q")
4411         (match_operand:SF 1 "reg_or_0_or_nonsymb_mem_operand"
4412                           "fG,!*rG,RT,RQ,f,*rG"))]
4413   "(register_operand (operands[0], SFmode)
4414     || reg_or_0_operand (operands[1], SFmode))
4415    && !TARGET_SOFT_FLOAT
4416    && TARGET_64BIT"
4417   "@
4418    fcpy,sgl %f1,%0
4419    copy %r1,%0
4420    fldw%F1 %1,%0
4421    ldw%M1 %1,%0
4422    fstw%F0 %1,%0
4423    stw%M0 %r1,%0"
4424   [(set_attr "type" "fpalu,move,fpload,load,fpstore,store")
4425    (set_attr "pa_combine_type" "addmove")
4426    (set_attr "length" "4,4,4,4,4,4")])
4428 (define_insn ""
4429   [(set (match_operand:SF 0 "indexed_memory_operand" "=R")
4430         (match_operand:SF 1 "register_operand" "f"))]
4431   "!TARGET_SOFT_FLOAT
4432    && !TARGET_DISABLE_INDEXING
4433    && reload_completed"
4434   "fstw%F0 %1,%0"
4435   [(set_attr "type" "fpstore")
4436    (set_attr "pa_combine_type" "addmove")
4437    (set_attr "length" "4")])
4439 (define_peephole2
4440   [(set (match_operand:SI 0 "register_operand" "")
4441         (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "")
4442                           (const_int 4))
4443                  (match_operand:SI 2 "register_operand" "")))
4444    (set (mem:SF (match_dup 0))
4445         (match_operand:SF 3 "register_operand" ""))]
4446   "!TARGET_SOFT_FLOAT
4447    && !TARGET_DISABLE_INDEXING
4448    && REG_OK_FOR_BASE_P (operands[2])
4449    && FP_REGNO_P (REGNO (operands[3]))"
4450   [(set (mem:SF (plus:SI (mult:SI (match_dup 1) (const_int 4)) (match_dup 2)))
4451         (match_dup 3))
4452    (set (match_dup 0) (plus:SI (mult:SI (match_dup 1) (const_int 4))
4453                                (match_dup 2)))]
4454   "")
4456 (define_peephole2
4457   [(set (match_operand:SI 0 "register_operand" "")
4458         (plus:SI (match_operand:SI 2 "register_operand" "")
4459                  (mult:SI (match_operand:SI 1 "register_operand" "")
4460                           (const_int 4))))
4461    (set (mem:SF (match_dup 0))
4462         (match_operand:SF 3 "register_operand" ""))]
4463   "!TARGET_SOFT_FLOAT
4464    && !TARGET_DISABLE_INDEXING
4465    && REG_OK_FOR_BASE_P (operands[2])
4466    && FP_REGNO_P (REGNO (operands[3]))"
4467   [(set (mem:SF (plus:SI (mult:SI (match_dup 1) (const_int 4)) (match_dup 2)))
4468         (match_dup 3))
4469    (set (match_dup 0) (plus:SI (mult:SI (match_dup 1) (const_int 4))
4470                                (match_dup 2)))]
4471   "")
4473 (define_peephole2
4474   [(set (match_operand:DI 0 "register_operand" "")
4475         (plus:DI (mult:DI (match_operand:DI 1 "register_operand" "")
4476                           (const_int 4))
4477                  (match_operand:DI 2 "register_operand" "")))
4478    (set (mem:SF (match_dup 0))
4479         (match_operand:SF 3 "register_operand" ""))]
4480   "!TARGET_SOFT_FLOAT
4481    && !TARGET_DISABLE_INDEXING
4482    && TARGET_64BIT
4483    && REG_OK_FOR_BASE_P (operands[2])
4484    && FP_REGNO_P (REGNO (operands[3]))"
4485   [(set (mem:SF (plus:DI (mult:DI (match_dup 1) (const_int 4)) (match_dup 2)))
4486         (match_dup 3))
4487    (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 4))
4488                                (match_dup 2)))]
4489   "")
4491 (define_peephole2
4492   [(set (match_operand:DI 0 "register_operand" "")
4493         (plus:DI (match_operand:DI 2 "register_operand" "")
4494                  (mult:DI (match_operand:DI 1 "register_operand" "")
4495                           (const_int 4))))
4496    (set (mem:SF (match_dup 0))
4497         (match_operand:SF 3 "register_operand" ""))]
4498   "!TARGET_SOFT_FLOAT
4499    && !TARGET_DISABLE_INDEXING
4500    && TARGET_64BIT
4501    && REG_OK_FOR_BASE_P (operands[2])
4502    && FP_REGNO_P (REGNO (operands[3]))"
4503   [(set (mem:SF (plus:DI (mult:DI (match_dup 1) (const_int 4)) (match_dup 2)))
4504         (match_dup 3))
4505    (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 4))
4506                                (match_dup 2)))]
4507   "")
4509 (define_peephole2
4510   [(set (match_operand:SI 0 "register_operand" "")
4511         (plus:SI (match_operand:SI 1 "register_operand" "")
4512                  (match_operand:SI 2 "register_operand" "")))
4513    (set (mem:SF (match_dup 0))
4514         (match_operand:SF 3 "register_operand" ""))]
4515   "!TARGET_SOFT_FLOAT
4516    && !TARGET_DISABLE_INDEXING
4517    && TARGET_NO_SPACE_REGS
4518    && REG_OK_FOR_INDEX_P (operands[1])
4519    && REG_OK_FOR_BASE_P (operands[2])
4520    && FP_REGNO_P (REGNO (operands[3]))"
4521   [(set (mem:SF (plus:SI (match_dup 1) (match_dup 2)))
4522         (match_dup 3))
4523    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
4524   "")
4526 (define_peephole2
4527   [(set (match_operand:SI 0 "register_operand" "")
4528         (plus:SI (match_operand:SI 1 "register_operand" "")
4529                  (match_operand:SI 2 "register_operand" "")))
4530    (set (mem:SF (match_dup 0))
4531         (match_operand:SF 3 "register_operand" ""))]
4532   "!TARGET_SOFT_FLOAT
4533    && !TARGET_DISABLE_INDEXING
4534    && TARGET_NO_SPACE_REGS
4535    && REG_OK_FOR_BASE_P (operands[1])
4536    && REG_OK_FOR_INDEX_P (operands[2])
4537    && FP_REGNO_P (REGNO (operands[3]))"
4538   [(set (mem:SF (plus:SI (match_dup 2) (match_dup 1)))
4539         (match_dup 3))
4540    (set (match_dup 0) (plus:SI (match_dup 2) (match_dup 1)))]
4541   "")
4543 (define_peephole2
4544   [(set (match_operand:DI 0 "register_operand" "")
4545         (plus:DI (match_operand:DI 1 "register_operand" "")
4546                  (match_operand:DI 2 "register_operand" "")))
4547    (set (mem:SF (match_dup 0))
4548         (match_operand:SF 3 "register_operand" ""))]
4549   "!TARGET_SOFT_FLOAT
4550    && !TARGET_DISABLE_INDEXING
4551    && TARGET_64BIT
4552    && TARGET_NO_SPACE_REGS
4553    && REG_OK_FOR_INDEX_P (operands[1])
4554    && REG_OK_FOR_BASE_P (operands[2])
4555    && FP_REGNO_P (REGNO (operands[3]))"
4556   [(set (mem:SF (plus:DI (match_dup 1) (match_dup 2)))
4557         (match_dup 3))
4558    (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
4559   "")
4561 (define_peephole2
4562   [(set (match_operand:DI 0 "register_operand" "")
4563         (plus:DI (match_operand:DI 1 "register_operand" "")
4564                  (match_operand:DI 2 "register_operand" "")))
4565    (set (mem:SF (match_dup 0))
4566         (match_operand:SF 3 "register_operand" ""))]
4567   "!TARGET_SOFT_FLOAT
4568    && !TARGET_DISABLE_INDEXING
4569    && TARGET_64BIT
4570    && TARGET_NO_SPACE_REGS
4571    && REG_OK_FOR_BASE_P (operands[1])
4572    && REG_OK_FOR_INDEX_P (operands[2])
4573    && FP_REGNO_P (REGNO (operands[3]))"
4574   [(set (mem:SF (plus:DI (match_dup 2) (match_dup 1)))
4575         (match_dup 3))
4576    (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
4577   "")
4579 (define_insn ""
4580   [(set (match_operand:SF 0 "move_dest_operand"
4581                           "=r,r,Q")
4582         (match_operand:SF 1 "reg_or_0_or_nonsymb_mem_operand"
4583                           "rG,RQ,rG"))]
4584   "(register_operand (operands[0], SFmode)
4585     || reg_or_0_operand (operands[1], SFmode))
4586    && TARGET_SOFT_FLOAT"
4587   "@
4588    copy %r1,%0
4589    ldw%M1 %1,%0
4590    stw%M0 %r1,%0"
4591   [(set_attr "type" "move,load,store")
4592    (set_attr "pa_combine_type" "addmove")
4593    (set_attr "length" "4,4,4")])
4597 ;;- zero extension instructions
4598 ;; We have define_expand for zero extension patterns to make sure the
4599 ;; operands get loaded into registers.  The define_insns accept
4600 ;; memory operands.  This gives us better overall code than just
4601 ;; having a pattern that does or does not accept memory operands.
4603 (define_expand "zero_extendqihi2"
4604   [(set (match_operand:HI 0 "register_operand" "")
4605         (zero_extend:HI
4606          (match_operand:QI 1 "register_operand" "")))]
4607   ""
4608   "")
4610 (define_insn ""
4611   [(set (match_operand:HI 0 "register_operand" "=r,r")
4612         (zero_extend:HI
4613          (match_operand:QI 1 "move_src_operand" "r,RQ")))]
4614   "GET_CODE (operands[1]) != CONST_INT"
4615   "@
4616    {extru|extrw,u} %1,31,8,%0
4617    ldb%M1 %1,%0"
4618   [(set_attr "type" "shift,load")
4619    (set_attr "length" "4,4")])
4621 (define_expand "zero_extendqisi2"
4622   [(set (match_operand:SI 0 "register_operand" "")
4623         (zero_extend:SI
4624          (match_operand:QI 1 "register_operand" "")))]
4625   ""
4626   "")
4628 (define_insn ""
4629   [(set (match_operand:SI 0 "register_operand" "=r,r")
4630         (zero_extend:SI
4631          (match_operand:QI 1 "move_src_operand" "r,RQ")))]
4632   "GET_CODE (operands[1]) != CONST_INT"
4633   "@
4634    {extru|extrw,u} %1,31,8,%0
4635    ldb%M1 %1,%0"
4636   [(set_attr "type" "shift,load")
4637    (set_attr "length" "4,4")])
4639 (define_expand "zero_extendhisi2"
4640   [(set (match_operand:SI 0 "register_operand" "")
4641         (zero_extend:SI
4642          (match_operand:HI 1 "register_operand" "")))]
4643   ""
4644   "")
4646 (define_insn ""
4647   [(set (match_operand:SI 0 "register_operand" "=r,r")
4648         (zero_extend:SI
4649          (match_operand:HI 1 "move_src_operand" "r,RQ")))]
4650   "GET_CODE (operands[1]) != CONST_INT"
4651   "@
4652    {extru|extrw,u} %1,31,16,%0
4653    ldh%M1 %1,%0"
4654   [(set_attr "type" "shift,load")
4655    (set_attr "length" "4,4")])
4657 (define_expand "zero_extendqidi2"
4658   [(set (match_operand:DI 0 "register_operand" "")
4659         (zero_extend:DI
4660          (match_operand:QI 1 "register_operand" "")))]
4661   "TARGET_64BIT"
4662   "")
4664 (define_insn ""
4665   [(set (match_operand:DI 0 "register_operand" "=r,r")
4666         (zero_extend:DI
4667          (match_operand:QI 1 "move_src_operand" "r,RQ")))]
4668   "TARGET_64BIT && GET_CODE (operands[1]) != CONST_INT"
4669   "@
4670    extrd,u %1,63,8,%0
4671    ldb%M1 %1,%0"
4672   [(set_attr "type" "shift,load")
4673    (set_attr "length" "4,4")])
4675 (define_expand "zero_extendhidi2"
4676   [(set (match_operand:DI 0 "register_operand" "")
4677         (zero_extend:DI
4678          (match_operand:HI 1 "register_operand" "")))]
4679   "TARGET_64BIT"
4680   "")
4682 (define_insn ""
4683   [(set (match_operand:DI 0 "register_operand" "=r,r")
4684         (zero_extend:DI
4685          (match_operand:HI 1 "move_src_operand" "r,RQ")))]
4686   "TARGET_64BIT && GET_CODE (operands[1]) != CONST_INT"
4687   "@
4688    extrd,u %1,63,16,%0
4689    ldh%M1 %1,%0"
4690   [(set_attr "type" "shift,load")
4691    (set_attr "length" "4,4")])
4693 (define_expand "zero_extendsidi2"
4694   [(set (match_operand:DI 0 "register_operand" "")
4695         (zero_extend:DI
4696          (match_operand:SI 1 "register_operand" "")))]
4697   "TARGET_64BIT"
4698   "")
4700 (define_insn ""
4701   [(set (match_operand:DI 0 "register_operand" "=r,r")
4702         (zero_extend:DI
4703          (match_operand:SI 1 "move_src_operand" "r,RQ")))]
4704   "TARGET_64BIT && GET_CODE (operands[1]) != CONST_INT"
4705   "@
4706    extrd,u %1,63,32,%0
4707    ldw%M1 %1,%0"
4708   [(set_attr "type" "shift,load")
4709    (set_attr "length" "4,4")])
4711 ;;- sign extension instructions
4713 (define_insn "extendhisi2"
4714   [(set (match_operand:SI 0 "register_operand" "=r")
4715         (sign_extend:SI (match_operand:HI 1 "register_operand" "r")))]
4716   ""
4717   "{extrs|extrw,s} %1,31,16,%0"
4718   [(set_attr "type" "shift")
4719    (set_attr "length" "4")])
4721 (define_insn "extendqihi2"
4722   [(set (match_operand:HI 0 "register_operand" "=r")
4723         (sign_extend:HI (match_operand:QI 1 "register_operand" "r")))]
4724   ""
4725   "{extrs|extrw,s} %1,31,8,%0"
4726   [(set_attr "type" "shift") 
4727   (set_attr "length" "4")])
4729 (define_insn "extendqisi2"
4730   [(set (match_operand:SI 0 "register_operand" "=r")
4731         (sign_extend:SI (match_operand:QI 1 "register_operand" "r")))]
4732   ""
4733   "{extrs|extrw,s} %1,31,8,%0"
4734   [(set_attr "type" "shift")
4735    (set_attr "length" "4")])
4737 (define_insn "extendqidi2"
4738   [(set (match_operand:DI 0 "register_operand" "=r")
4739         (sign_extend:DI (match_operand:QI 1 "register_operand" "r")))]
4740   "TARGET_64BIT"
4741   "extrd,s %1,63,8,%0"
4742   [(set_attr "type" "shift") 
4743   (set_attr "length" "4")])
4745 (define_insn "extendhidi2"
4746   [(set (match_operand:DI 0 "register_operand" "=r")
4747         (sign_extend:DI (match_operand:HI 1 "register_operand" "r")))]
4748   "TARGET_64BIT"
4749   "extrd,s %1,63,16,%0"
4750   [(set_attr "type" "shift") 
4751   (set_attr "length" "4")])
4753 (define_insn "extendsidi2"
4754   [(set (match_operand:DI 0 "register_operand" "=r")
4755         (sign_extend:DI (match_operand:SI 1 "register_operand" "r")))]
4756   "TARGET_64BIT"
4757   "extrd,s %1,63,32,%0"
4758   [(set_attr "type" "shift") 
4759   (set_attr "length" "4")])
4762 ;; Conversions between float and double.
4764 (define_insn "extendsfdf2"
4765   [(set (match_operand:DF 0 "register_operand" "=f")
4766         (float_extend:DF
4767          (match_operand:SF 1 "register_operand" "f")))]
4768   "! TARGET_SOFT_FLOAT"
4769   "{fcnvff|fcnv},sgl,dbl %1,%0"
4770   [(set_attr "type" "fpalu")
4771    (set_attr "length" "4")])
4773 (define_insn "truncdfsf2"
4774   [(set (match_operand:SF 0 "register_operand" "=f")
4775         (float_truncate:SF
4776          (match_operand:DF 1 "register_operand" "f")))]
4777   "! TARGET_SOFT_FLOAT"
4778   "{fcnvff|fcnv},dbl,sgl %1,%0"
4779   [(set_attr "type" "fpalu")
4780    (set_attr "length" "4")])
4782 ;; Conversion between fixed point and floating point.
4783 ;; Note that among the fix-to-float insns
4784 ;; the ones that start with SImode come first.
4785 ;; That is so that an operand that is a CONST_INT
4786 ;; (and therefore lacks a specific machine mode).
4787 ;; will be recognized as SImode (which is always valid)
4788 ;; rather than as QImode or HImode.
4790 ;; This pattern forces (set (reg:SF ...) (float:SF (const_int ...)))
4791 ;; to be reloaded by putting the constant into memory.
4792 ;; It must come before the more general floatsisf2 pattern.
4793 (define_insn ""
4794   [(set (match_operand:SF 0 "register_operand" "=f")
4795         (float:SF (match_operand:SI 1 "const_int_operand" "m")))]
4796   "! TARGET_SOFT_FLOAT"
4797   "fldw%F1 %1,%0\;{fcnvxf,sgl,sgl|fcnv,w,sgl} %0,%0"
4798   [(set_attr "type" "fpalu")
4799    (set_attr "length" "8")])
4801 (define_insn "floatsisf2"
4802   [(set (match_operand:SF 0 "register_operand" "=f")
4803         (float:SF (match_operand:SI 1 "register_operand" "f")))]
4804   "! TARGET_SOFT_FLOAT"
4805   "{fcnvxf,sgl,sgl|fcnv,w,sgl} %1,%0"
4806   [(set_attr "type" "fpalu")
4807    (set_attr "length" "4")])
4809 ;; This pattern forces (set (reg:DF ...) (float:DF (const_int ...)))
4810 ;; to be reloaded by putting the constant into memory.
4811 ;; It must come before the more general floatsidf2 pattern.
4812 (define_insn ""
4813   [(set (match_operand:DF 0 "register_operand" "=f")
4814         (float:DF (match_operand:SI 1 "const_int_operand" "m")))]
4815   "! TARGET_SOFT_FLOAT"
4816   "fldw%F1 %1,%0\;{fcnvxf,sgl,dbl|fcnv,w,dbl} %0,%0"
4817   [(set_attr "type" "fpalu")
4818    (set_attr "length" "8")])
4820 (define_insn "floatsidf2"
4821   [(set (match_operand:DF 0 "register_operand" "=f")
4822         (float:DF (match_operand:SI 1 "register_operand" "f")))]
4823   "! TARGET_SOFT_FLOAT"
4824   "{fcnvxf,sgl,dbl|fcnv,w,dbl} %1,%0"
4825   [(set_attr "type" "fpalu")
4826    (set_attr "length" "4")])
4828 (define_expand "floatunssisf2"
4829   [(set (subreg:SI (match_dup 2) 4)
4830         (match_operand:SI 1 "register_operand" ""))
4831    (set (subreg:SI (match_dup 2) 0)
4832         (const_int 0))
4833    (set (match_operand:SF 0 "register_operand" "")
4834         (float:SF (match_dup 2)))]
4835   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4836   "
4838   if (TARGET_PA_20)
4839     {
4840       emit_insn (gen_floatunssisf2_pa20 (operands[0], operands[1]));
4841       DONE;
4842     }
4843   operands[2] = gen_reg_rtx (DImode);
4846 (define_expand "floatunssidf2"
4847   [(set (subreg:SI (match_dup 2) 4)
4848         (match_operand:SI 1 "register_operand" ""))
4849    (set (subreg:SI (match_dup 2) 0)
4850         (const_int 0))
4851    (set (match_operand:DF 0 "register_operand" "")
4852         (float:DF (match_dup 2)))]
4853   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4854   "
4856   if (TARGET_PA_20)
4857     {
4858       emit_insn (gen_floatunssidf2_pa20 (operands[0], operands[1]));
4859       DONE;
4860     }
4861   operands[2] = gen_reg_rtx (DImode);
4864 (define_insn "floatdisf2"
4865   [(set (match_operand:SF 0 "register_operand" "=f")
4866         (float:SF (match_operand:DI 1 "register_operand" "f")))]
4867   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4868   "{fcnvxf,dbl,sgl|fcnv,dw,sgl} %1,%0"
4869   [(set_attr "type" "fpalu")
4870    (set_attr "length" "4")])
4872 (define_insn "floatdidf2"
4873   [(set (match_operand:DF 0 "register_operand" "=f")
4874         (float:DF (match_operand:DI 1 "register_operand" "f")))]
4875   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4876   "{fcnvxf,dbl,dbl|fcnv,dw,dbl} %1,%0"
4877   [(set_attr "type" "fpalu")
4878    (set_attr "length" "4")])
4880 ;; Convert a float to an actual integer.
4881 ;; Truncation is performed as part of the conversion.
4883 (define_insn "fix_truncsfsi2"
4884   [(set (match_operand:SI 0 "register_operand" "=f")
4885         (fix:SI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
4886   "! TARGET_SOFT_FLOAT"
4887   "{fcnvfxt,sgl,sgl|fcnv,t,sgl,w} %1,%0"
4888   [(set_attr "type" "fpalu")
4889    (set_attr "length" "4")])
4891 (define_insn "fix_truncdfsi2"
4892   [(set (match_operand:SI 0 "register_operand" "=f")
4893         (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
4894   "! TARGET_SOFT_FLOAT"
4895   "{fcnvfxt,dbl,sgl|fcnv,t,dbl,w} %1,%0"
4896   [(set_attr "type" "fpalu")
4897    (set_attr "length" "4")])
4899 (define_insn "fix_truncsfdi2"
4900   [(set (match_operand:DI 0 "register_operand" "=f")
4901         (fix:DI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
4902   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4903   "{fcnvfxt,sgl,dbl|fcnv,t,sgl,dw} %1,%0"
4904   [(set_attr "type" "fpalu")
4905    (set_attr "length" "4")])
4907 (define_insn "fix_truncdfdi2"
4908   [(set (match_operand:DI 0 "register_operand" "=f")
4909         (fix:DI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
4910   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4911   "{fcnvfxt,dbl,dbl|fcnv,t,dbl,dw} %1,%0"
4912   [(set_attr "type" "fpalu")
4913    (set_attr "length" "4")])
4915 (define_insn "floatunssidf2_pa20"
4916   [(set (match_operand:DF 0 "register_operand" "=f")
4917         (unsigned_float:DF (match_operand:SI 1 "register_operand" "f")))]
4918   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4919   "fcnv,uw,dbl %1,%0"
4920   [(set_attr "type" "fpalu")
4921    (set_attr "length" "4")])
4923 (define_insn "floatunssisf2_pa20"
4924   [(set (match_operand:SF 0 "register_operand" "=f")
4925         (unsigned_float:SF (match_operand:SI 1 "register_operand" "f")))]
4926   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4927   "fcnv,uw,sgl %1,%0"
4928   [(set_attr "type" "fpalu")
4929    (set_attr "length" "4")])
4931 (define_insn "floatunsdisf2"
4932   [(set (match_operand:SF 0 "register_operand" "=f")
4933         (unsigned_float:SF (match_operand:DI 1 "register_operand" "f")))]
4934   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4935   "fcnv,udw,sgl %1,%0"
4936   [(set_attr "type" "fpalu")
4937    (set_attr "length" "4")])
4939 (define_insn "floatunsdidf2"
4940   [(set (match_operand:DF 0 "register_operand" "=f")
4941         (unsigned_float:DF (match_operand:DI 1 "register_operand" "f")))]
4942   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4943   "fcnv,udw,dbl %1,%0"
4944   [(set_attr "type" "fpalu")
4945    (set_attr "length" "4")])
4947 (define_insn "fixuns_truncsfsi2"
4948   [(set (match_operand:SI 0 "register_operand" "=f")
4949         (unsigned_fix:SI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
4950   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4951   "fcnv,t,sgl,uw %1,%0"
4952   [(set_attr "type" "fpalu")
4953    (set_attr "length" "4")])
4955 (define_insn "fixuns_truncdfsi2"
4956   [(set (match_operand:SI 0 "register_operand" "=f")
4957         (unsigned_fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
4958   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4959   "fcnv,t,dbl,uw %1,%0"
4960   [(set_attr "type" "fpalu")
4961    (set_attr "length" "4")])
4963 (define_insn "fixuns_truncsfdi2"
4964   [(set (match_operand:DI 0 "register_operand" "=f")
4965         (unsigned_fix:DI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
4966   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4967   "fcnv,t,sgl,udw %1,%0"
4968   [(set_attr "type" "fpalu")
4969    (set_attr "length" "4")])
4971 (define_insn "fixuns_truncdfdi2"
4972   [(set (match_operand:DI 0 "register_operand" "=f")
4973         (unsigned_fix:DI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
4974   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4975   "fcnv,t,dbl,udw %1,%0"
4976   [(set_attr "type" "fpalu")
4977    (set_attr "length" "4")])
4979 ;;- arithmetic instructions
4981 (define_expand "adddi3"
4982   [(set (match_operand:DI 0 "register_operand" "")
4983         (plus:DI (match_operand:DI 1 "register_operand" "")
4984                  (match_operand:DI 2 "adddi3_operand" "")))]
4985   ""
4986   "")
4988 (define_insn ""
4989   [(set (match_operand:DI 0 "register_operand" "=r")
4990         (plus:DI (match_operand:DI 1 "register_operand" "%r")
4991                  (match_operand:DI 2 "arith11_operand" "rI")))]
4992   "!TARGET_64BIT"
4993   "*
4995   if (GET_CODE (operands[2]) == CONST_INT)
4996     {
4997       if (INTVAL (operands[2]) >= 0)
4998         return \"addi %2,%R1,%R0\;{addc|add,c} %1,%%r0,%0\";
4999       else
5000         return \"addi %2,%R1,%R0\;{subb|sub,b} %1,%%r0,%0\";
5001     }
5002   else
5003     return \"add %R2,%R1,%R0\;{addc|add,c} %2,%1,%0\";
5005   [(set_attr "type" "binary")
5006    (set_attr "length" "8")])
5008 (define_insn ""
5009   [(set (match_operand:DI 0 "register_operand" "=r,r")
5010         (plus:DI (match_operand:DI 1 "register_operand" "%r,r")
5011                  (match_operand:DI 2 "arith14_operand" "r,J")))]
5012   "TARGET_64BIT"
5013   "@
5014    add,l %1,%2,%0
5015    ldo %2(%1),%0"
5016   [(set_attr "type" "binary,binary")
5017    (set_attr "pa_combine_type" "addmove")
5018    (set_attr "length" "4,4")])
5020 (define_insn ""
5021   [(set (match_operand:DI 0 "register_operand" "=r")
5022         (plus:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
5023                  (match_operand:DI 2 "register_operand" "r")))]
5024   "TARGET_64BIT"
5025   "uaddcm %2,%1,%0"
5026   [(set_attr "type" "binary")
5027    (set_attr "length" "4")])
5029 (define_insn ""
5030   [(set (match_operand:SI 0 "register_operand" "=r")
5031         (plus:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
5032                  (match_operand:SI 2 "register_operand" "r")))]
5033   ""
5034   "uaddcm %2,%1,%0"
5035   [(set_attr "type" "binary")
5036    (set_attr "length" "4")])
5038 (define_expand "addvdi3"
5039   [(parallel [(set (match_operand:DI 0 "register_operand" "")
5040                    (plus:DI (match_operand:DI 1 "reg_or_0_operand" "")
5041                             (match_operand:DI 2 "arith11_operand" "")))
5042               (trap_if (ne (plus:TI (sign_extend:TI (match_dup 1))
5043                                     (sign_extend:TI (match_dup 2)))
5044                            (sign_extend:TI (plus:DI (match_dup 1)
5045                                                     (match_dup 2))))
5046                        (const_int 0))])]
5047   ""
5048   "")
5050 (define_insn ""
5051   [(set (match_operand:DI 0 "register_operand" "=r,r")
5052         (plus:DI (match_operand:DI 1 "reg_or_0_operand" "%rM,rM")
5053                  (match_operand:DI 2 "arith11_operand" "r,I")))
5054    (trap_if (ne (plus:TI (sign_extend:TI (match_dup 1))
5055                          (sign_extend:TI (match_dup 2)))
5056                 (sign_extend:TI (plus:DI (match_dup 1)
5057                                          (match_dup 2))))
5058             (const_int 0))]
5059   "TARGET_64BIT"
5060   "@
5061   add,tsv,* %2,%1,%0
5062   addi,tsv,* %2,%1,%0"
5063   [(set_attr "type" "binary,binary")
5064    (set_attr "length" "4,4")])
5066 (define_insn ""
5067   [(set (match_operand:DI 0 "register_operand" "=r")
5068         (plus:DI (match_operand:DI 1 "reg_or_0_operand" "%rM")
5069                  (match_operand:DI 2 "arith11_operand" "rI")))
5070    (trap_if (ne (plus:TI (sign_extend:TI (match_dup 1))
5071                          (sign_extend:TI (match_dup 2)))
5072                 (sign_extend:TI (plus:DI (match_dup 1)
5073                                          (match_dup 2))))
5074             (const_int 0))]
5075   "!TARGET_64BIT"
5076   "*
5078   if (GET_CODE (operands[2]) == CONST_INT)
5079     {
5080       if (INTVAL (operands[2]) >= 0)
5081         return \"addi %2,%R1,%R0\;{addco|add,c,tsv} %1,%%r0,%0\";
5082       else
5083         return \"addi %2,%R1,%R0\;{subbo|sub,b,tsv} %1,%%r0,%0\";
5084     }
5085   else
5086     return \"add %R2,%R1,%R0\;{addco|add,c,tsv} %2,%1,%0\";
5088   [(set_attr "type" "binary")
5089    (set_attr "length" "8")])
5091 ;; define_splits to optimize cases of adding a constant integer
5092 ;; to a register when the constant does not fit in 14 bits.  */
5093 (define_split
5094   [(set (match_operand:SI 0 "register_operand" "")
5095         (plus:SI (match_operand:SI 1 "register_operand" "")
5096                  (match_operand:SI 2 "const_int_operand" "")))
5097    (clobber (match_operand:SI 4 "register_operand" ""))]
5098   "! pa_cint_ok_for_move (INTVAL (operands[2]))
5099    && VAL_14_BITS_P (INTVAL (operands[2]) >> 1)"
5100   [(set (match_dup 4) (plus:SI (match_dup 1) (match_dup 2)))
5101    (set (match_dup 0) (plus:SI (match_dup 4) (match_dup 3)))]
5102   "
5104   int val = INTVAL (operands[2]);
5105   int low = (val < 0) ? -0x2000 : 0x1fff;
5106   int rest = val - low;
5108   operands[2] = GEN_INT (rest);
5109   operands[3] = GEN_INT (low);
5112 (define_split
5113   [(set (match_operand:SI 0 "register_operand" "")
5114         (plus:SI (match_operand:SI 1 "register_operand" "")
5115                  (match_operand:SI 2 "const_int_operand" "")))
5116    (clobber (match_operand:SI 4 "register_operand" ""))]
5117   "! pa_cint_ok_for_move (INTVAL (operands[2]))"
5118   [(set (match_dup 4) (match_dup 2))
5119    (set (match_dup 0) (plus:SI (mult:SI (match_dup 4) (match_dup 3))
5120                                (match_dup 1)))]
5121   "
5123   HOST_WIDE_INT intval = INTVAL (operands[2]);
5125   /* Try dividing the constant by 2, then 4, and finally 8 to see
5126      if we can get a constant which can be loaded into a register
5127      in a single instruction (pa_cint_ok_for_move). 
5129      If that fails, try to negate the constant and subtract it
5130      from our input operand.  */
5131   if (intval % 2 == 0 && pa_cint_ok_for_move (intval / 2))
5132     {
5133       operands[2] = GEN_INT (intval / 2);
5134       operands[3] = const2_rtx;
5135     }
5136   else if (intval % 4 == 0 && pa_cint_ok_for_move (intval / 4))
5137     {
5138       operands[2] = GEN_INT (intval / 4);
5139       operands[3] = GEN_INT (4);
5140     }
5141   else if (intval % 8 == 0 && pa_cint_ok_for_move (intval / 8))
5142     {
5143       operands[2] = GEN_INT (intval / 8);
5144       operands[3] = GEN_INT (8);
5145     }
5146   else if (pa_cint_ok_for_move (-intval))
5147     {
5148       emit_insn (gen_rtx_SET (VOIDmode, operands[4], GEN_INT (-intval)));
5149       emit_insn (gen_subsi3 (operands[0], operands[1], operands[4]));
5150       DONE;
5151     }
5152   else
5153     FAIL;
5156 (define_insn "addsi3"
5157   [(set (match_operand:SI 0 "register_operand" "=r,r")
5158         (plus:SI (match_operand:SI 1 "register_operand" "%r,r")
5159                  (match_operand:SI 2 "arith14_operand" "r,J")))]
5160   ""
5161   "@
5162    {addl|add,l} %1,%2,%0
5163    ldo %2(%1),%0"
5164   [(set_attr "type" "binary,binary")
5165    (set_attr "pa_combine_type" "addmove")
5166    (set_attr "length" "4,4")])
5168 (define_insn "addvsi3"
5169   [(set (match_operand:SI 0 "register_operand" "=r,r")
5170         (plus:SI (match_operand:SI 1 "reg_or_0_operand" "%rM,rM")
5171                  (match_operand:SI 2 "arith11_operand" "r,I")))
5172    (trap_if (ne (plus:DI (sign_extend:DI (match_dup 1))
5173                          (sign_extend:DI (match_dup 2)))
5174                 (sign_extend:DI (plus:SI (match_dup 1)
5175                                          (match_dup 2))))
5176             (const_int 0))]
5177   ""
5178   "@
5179   {addo|add,tsv} %2,%1,%0
5180   {addio|addi,tsv} %2,%1,%0"
5181   [(set_attr "type" "binary,binary")
5182    (set_attr "length" "4,4")])
5184 (define_expand "subdi3"
5185   [(set (match_operand:DI 0 "register_operand" "")
5186         (minus:DI (match_operand:DI 1 "arith11_operand" "")
5187                   (match_operand:DI 2 "reg_or_0_operand" "")))]
5188   ""
5189   "")
5191 (define_insn ""
5192   [(set (match_operand:DI 0 "register_operand" "=r,r,!q")
5193         (minus:DI (match_operand:DI 1 "arith11_operand" "r,I,!U")
5194                   (match_operand:DI 2 "reg_or_0_operand" "rM,rM,!rM")))]
5195   "TARGET_64BIT"
5196   "@
5197    sub %1,%2,%0
5198    subi %1,%2,%0
5199    mtsarcm %2"
5200   [(set_attr "type" "binary,binary,move")
5201   (set_attr "length" "4,4,4")])
5203 (define_insn ""
5204   [(set (match_operand:DI 0 "register_operand" "=r,&r")
5205         (minus:DI (match_operand:DI 1 "arith11_operand" "r,I")
5206                   (match_operand:DI 2 "reg_or_0_operand" "rM,rM")))]
5207   "!TARGET_64BIT"
5208   "*
5210   if (GET_CODE (operands[1]) == CONST_INT)
5211     {
5212       if (INTVAL (operands[1]) >= 0)
5213         return \"subi %1,%R2,%R0\;{subb|sub,b} %%r0,%2,%0\";
5214       else
5215         return \"ldi -1,%0\;subi %1,%R2,%R0\;{subb|sub,b} %0,%2,%0\";
5216     }
5217   else
5218     return \"sub %R1,%R2,%R0\;{subb|sub,b} %1,%2,%0\";
5220   [(set_attr "type" "binary")
5221    (set (attr "length")
5222         (if_then_else (eq_attr "alternative" "0")
5223           (const_int 8)
5224           (if_then_else (ge (symbol_ref "INTVAL (operands[1])")
5225                             (const_int 0))
5226             (const_int 8)
5227             (const_int 12))))])
5229 (define_expand "subvdi3"
5230   [(parallel [(set (match_operand:DI 0 "register_operand" "")
5231                    (minus:DI (match_operand:DI 1 "arith11_operand" "")
5232                              (match_operand:DI 2 "reg_or_0_operand" "")))
5233               (trap_if (ne (minus:TI (sign_extend:TI (match_dup 1))
5234                                      (sign_extend:TI (match_dup 2)))
5235                            (sign_extend:TI (minus:DI (match_dup 1)
5236                                                      (match_dup 2))))
5237                        (const_int 0))])]
5238   ""
5239   "")
5241 (define_insn ""
5242   [(set (match_operand:DI 0 "register_operand" "=r,r")
5243         (minus:DI (match_operand:DI 1 "arith11_operand" "r,I")
5244                   (match_operand:DI 2 "reg_or_0_operand" "rM,rM")))
5245    (trap_if (ne (minus:TI (sign_extend:TI (match_dup 1))
5246                           (sign_extend:TI (match_dup 2)))
5247                 (sign_extend:TI (minus:DI (match_dup 1)
5248                                           (match_dup 2))))
5249             (const_int 0))]
5250   "TARGET_64BIT"
5251   "@
5252   {subo|sub,tsv} %1,%2,%0
5253   {subio|subi,tsv} %1,%2,%0"
5254   [(set_attr "type" "binary,binary")
5255    (set_attr "length" "4,4")])
5257 (define_insn ""
5258   [(set (match_operand:DI 0 "register_operand" "=r,&r")
5259         (minus:DI (match_operand:DI 1 "arith11_operand" "r,I")
5260                   (match_operand:DI 2 "reg_or_0_operand" "rM,rM")))
5261    (trap_if (ne (minus:TI (sign_extend:TI (match_dup 1))
5262                           (sign_extend:TI (match_dup 2)))
5263                 (sign_extend:TI (minus:DI (match_dup 1)
5264                                           (match_dup 2))))
5265             (const_int 0))]
5266   "!TARGET_64BIT"
5267   "*
5269   if (GET_CODE (operands[1]) == CONST_INT)
5270     {
5271       if (INTVAL (operands[1]) >= 0)
5272         return \"subi %1,%R2,%R0\;{subbo|sub,b,tsv} %%r0,%2,%0\";
5273       else
5274         return \"ldi -1,%0\;subi %1,%R2,%R0\;{subbo|sub,b,tsv} %0,%2,%0\";
5275     }
5276   else
5277     return \"sub %R1,%R2,%R0\;{subbo|sub,b,tsv} %1,%2,%0\";
5279   [(set_attr "type" "binary,binary")
5280    (set (attr "length")
5281         (if_then_else (eq_attr "alternative" "0")
5282           (const_int 8)
5283           (if_then_else (ge (symbol_ref "INTVAL (operands[1])")
5284                             (const_int 0))
5285             (const_int 8)
5286             (const_int 12))))])
5288 (define_expand "subsi3"
5289   [(set (match_operand:SI 0 "register_operand" "")
5290         (minus:SI (match_operand:SI 1 "arith11_operand" "")
5291                   (match_operand:SI 2 "register_operand" "")))]
5292   ""
5293   "")
5295 (define_insn ""
5296   [(set (match_operand:SI 0 "register_operand" "=r,r")
5297         (minus:SI (match_operand:SI 1 "arith11_operand" "r,I")
5298                   (match_operand:SI 2 "register_operand" "r,r")))]
5299   "!TARGET_PA_20"
5300   "@
5301    sub %1,%2,%0
5302    subi %1,%2,%0"
5303   [(set_attr "type" "binary,binary")
5304    (set_attr "length" "4,4")])
5306 (define_insn ""
5307   [(set (match_operand:SI 0 "register_operand" "=r,r,!q")
5308         (minus:SI (match_operand:SI 1 "arith11_operand" "r,I,!S")
5309                   (match_operand:SI 2 "register_operand" "r,r,!r")))]
5310   "TARGET_PA_20"
5311   "@
5312    sub %1,%2,%0
5313    subi %1,%2,%0
5314    mtsarcm %2"
5315   [(set_attr "type" "binary,binary,move")
5316    (set_attr "length" "4,4,4")])
5318 (define_insn "subvsi3"
5319   [(set (match_operand:SI 0 "register_operand" "=r,r")
5320         (minus:SI (match_operand:SI 1 "arith11_operand" "rM,I")
5321                   (match_operand:SI 2 "reg_or_0_operand" "rM,rM")))
5322    (trap_if (ne (minus:DI (sign_extend:DI (match_dup 1))
5323                           (sign_extend:DI (match_dup 2)))
5324                 (sign_extend:DI (minus:SI (match_dup 1)
5325                                           (match_dup 2))))
5326             (const_int 0))]
5327   ""
5328   "@
5329   {subo|sub,tsv} %1,%2,%0
5330   {subio|subi,tsv} %1,%2,%0"
5331   [(set_attr "type" "binary,binary")
5332    (set_attr "length" "4,4")])
5334 ;; Clobbering a "register_operand" instead of a match_scratch
5335 ;; in operand3 of millicode calls avoids spilling %r1 and
5336 ;; produces better code.
5338 ;; The mulsi3 insns set up registers for the millicode call.
5339 (define_expand "mulsi3"
5340   [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5341    (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5342    (parallel [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
5343               (clobber (match_dup 3))
5344               (clobber (reg:SI 26))
5345               (clobber (reg:SI 25))
5346               (clobber (match_dup 4))])
5347    (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5348   ""
5349   "
5351   operands[4] = gen_rtx_REG (SImode, TARGET_64BIT ? 2 : 31);
5352   if (TARGET_PA_11 && !TARGET_DISABLE_FPREGS && !TARGET_SOFT_FLOAT)
5353     {
5354       rtx scratch = gen_reg_rtx (DImode);
5355       operands[1] = force_reg (SImode, operands[1]);
5356       operands[2] = force_reg (SImode, operands[2]);
5357       emit_insn (gen_umulsidi3 (scratch, operands[1], operands[2]));
5358       emit_insn (gen_movsi (operands[0],
5359                             gen_rtx_SUBREG (SImode, scratch,
5360                                             GET_MODE_SIZE (SImode))));
5361       DONE;
5362     }
5363   operands[3] = gen_reg_rtx (SImode);
5366 (define_insn "umulsidi3"
5367   [(set (match_operand:DI 0 "register_operand" "=f")
5368         (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "f"))
5369                  (zero_extend:DI (match_operand:SI 2 "nonimmediate_operand" "f"))))]
5370   "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT"
5371   "xmpyu %1,%2,%0"
5372   [(set_attr "type" "fpmuldbl")
5373    (set_attr "length" "4")])
5375 (define_insn ""
5376   [(set (match_operand:DI 0 "register_operand" "=f")
5377         (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "f"))
5378                  (match_operand:DI 2 "uint32_operand" "f")))]
5379   "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT && !TARGET_64BIT"
5380   "xmpyu %1,%R2,%0"
5381   [(set_attr "type" "fpmuldbl")
5382    (set_attr "length" "4")])
5384 (define_insn ""
5385   [(set (match_operand:DI 0 "register_operand" "=f")
5386         (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "f"))
5387                  (match_operand:DI 2 "uint32_operand" "f")))]
5388   "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT && TARGET_64BIT"
5389   "xmpyu %1,%2R,%0"
5390   [(set_attr "type" "fpmuldbl")
5391    (set_attr "length" "4")])
5393 (define_insn ""
5394   [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
5395    (clobber (match_operand:SI 0 "register_operand" "=a"))
5396    (clobber (reg:SI 26))
5397    (clobber (reg:SI 25))
5398    (clobber (reg:SI 31))]
5399   "!TARGET_64BIT"
5400   "* return pa_output_mul_insn (0, insn);"
5401   [(set_attr "type" "milli")
5402    (set (attr "length")
5403         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5404               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5406 (define_insn ""
5407   [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
5408    (clobber (match_operand:SI 0 "register_operand" "=a"))
5409    (clobber (reg:SI 26))
5410    (clobber (reg:SI 25))
5411    (clobber (reg:SI 2))]
5412   "TARGET_64BIT"
5413   "* return pa_output_mul_insn (0, insn);"
5414   [(set_attr "type" "milli")
5415    (set (attr "length")
5416         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5417               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5419 (define_expand "muldi3"
5420   [(set (match_operand:DI 0 "register_operand" "")
5421         (mult:DI (match_operand:DI 1 "register_operand" "")
5422                  (match_operand:DI 2 "register_operand" "")))]
5423   "TARGET_64BIT && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT"
5424   "
5426   rtx low_product = gen_reg_rtx (DImode);
5427   rtx cross_product1 = gen_reg_rtx (DImode);
5428   rtx cross_product2 = gen_reg_rtx (DImode);
5429   rtx cross_scratch = gen_reg_rtx (DImode);
5430   rtx cross_product = gen_reg_rtx (DImode);
5431   rtx op1l, op1r, op2l, op2r;
5432   rtx op1shifted, op2shifted;
5434   op1shifted = gen_reg_rtx (DImode);
5435   op2shifted = gen_reg_rtx (DImode);
5436   op1l = gen_reg_rtx (SImode);
5437   op1r = gen_reg_rtx (SImode);
5438   op2l = gen_reg_rtx (SImode);
5439   op2r = gen_reg_rtx (SImode);
5441   emit_move_insn (op1shifted, gen_rtx_LSHIFTRT (DImode, operands[1],
5442                                                 GEN_INT (32)));
5443   emit_move_insn (op2shifted, gen_rtx_LSHIFTRT (DImode, operands[2],
5444                                                 GEN_INT (32)));
5445   op1r = force_reg (SImode, gen_rtx_SUBREG (SImode, operands[1], 4));
5446   op2r = force_reg (SImode, gen_rtx_SUBREG (SImode, operands[2], 4));
5447   op1l = force_reg (SImode, gen_rtx_SUBREG (SImode, op1shifted, 4));
5448   op2l = force_reg (SImode, gen_rtx_SUBREG (SImode, op2shifted, 4));
5450   /* Emit multiplies for the cross products.  */
5451   emit_insn (gen_umulsidi3 (cross_product1, op2r, op1l));
5452   emit_insn (gen_umulsidi3 (cross_product2, op2l, op1r));
5454   /* Emit a multiply for the low sub-word.  */
5455   emit_insn (gen_umulsidi3 (low_product, copy_rtx (op2r), copy_rtx (op1r)));
5457   /* Sum the cross products and shift them into proper position.  */
5458   emit_insn (gen_adddi3 (cross_scratch, cross_product1, cross_product2));
5459   emit_insn (gen_ashldi3 (cross_product, cross_scratch, GEN_INT (32)));
5461   /* Add the cross product to the low product and store the result
5462      into the output operand .  */
5463   emit_insn (gen_adddi3 (operands[0], cross_product, low_product));
5464   DONE;
5467 ;;; Division and mod.
5468 (define_expand "divsi3"
5469   [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5470    (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5471    (parallel [(set (reg:SI 29) (div:SI (reg:SI 26) (reg:SI 25)))
5472               (clobber (match_dup 3))
5473               (clobber (match_dup 4))
5474               (clobber (reg:SI 26))
5475               (clobber (reg:SI 25))
5476               (clobber (match_dup 5))])
5477    (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5478   ""
5479   "
5481   operands[3] = gen_reg_rtx (SImode);
5482   if (TARGET_64BIT)
5483     {
5484       operands[5] = gen_rtx_REG (SImode, 2);
5485       operands[4] = operands[5];
5486     }
5487   else
5488     {
5489       operands[5] = gen_rtx_REG (SImode, 31);
5490       operands[4] = gen_reg_rtx (SImode);
5491     }
5492   if (GET_CODE (operands[2]) == CONST_INT && pa_emit_hpdiv_const (operands, 0))
5493     DONE;
5496 (define_insn ""
5497   [(set (reg:SI 29)
5498         (div:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5499    (clobber (match_operand:SI 1 "register_operand" "=a"))
5500    (clobber (match_operand:SI 2 "register_operand" "=&r"))
5501    (clobber (reg:SI 26))
5502    (clobber (reg:SI 25))
5503    (clobber (reg:SI 31))]
5504   "!TARGET_64BIT"
5505   "*
5506    return pa_output_div_insn (operands, 0, insn);"
5507   [(set_attr "type" "milli")
5508    (set (attr "length")
5509         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5510               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5512 (define_insn ""
5513   [(set (reg:SI 29)
5514         (div:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5515    (clobber (match_operand:SI 1 "register_operand" "=a"))
5516    (clobber (match_operand:SI 2 "register_operand" "=&r"))
5517    (clobber (reg:SI 26))
5518    (clobber (reg:SI 25))
5519    (clobber (reg:SI 2))]
5520   "TARGET_64BIT"
5521   "*
5522    return pa_output_div_insn (operands, 0, insn);"
5523   [(set_attr "type" "milli")
5524    (set (attr "length")
5525         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5526               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5528 (define_expand "udivsi3"
5529   [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5530    (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5531    (parallel [(set (reg:SI 29) (udiv:SI (reg:SI 26) (reg:SI 25)))
5532               (clobber (match_dup 3))
5533               (clobber (match_dup 4))
5534               (clobber (reg:SI 26))
5535               (clobber (reg:SI 25))
5536               (clobber (match_dup 5))])
5537    (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5538   ""
5539   "
5541   operands[3] = gen_reg_rtx (SImode);
5543   if (TARGET_64BIT)
5544     {
5545       operands[5] = gen_rtx_REG (SImode, 2);
5546       operands[4] = operands[5];
5547     }
5548   else
5549     {
5550       operands[5] = gen_rtx_REG (SImode, 31);
5551       operands[4] = gen_reg_rtx (SImode);
5552     }
5553   if (GET_CODE (operands[2]) == CONST_INT && pa_emit_hpdiv_const (operands, 1))
5554     DONE;
5557 (define_insn ""
5558   [(set (reg:SI 29)
5559         (udiv:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5560    (clobber (match_operand:SI 1 "register_operand" "=a"))
5561    (clobber (match_operand:SI 2 "register_operand" "=&r"))
5562    (clobber (reg:SI 26))
5563    (clobber (reg:SI 25))
5564    (clobber (reg:SI 31))]
5565   "!TARGET_64BIT"
5566   "*
5567    return pa_output_div_insn (operands, 1, insn);"
5568   [(set_attr "type" "milli")
5569    (set (attr "length")
5570         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5571               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5573 (define_insn ""
5574   [(set (reg:SI 29)
5575         (udiv:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5576    (clobber (match_operand:SI 1 "register_operand" "=a"))
5577    (clobber (match_operand:SI 2 "register_operand" "=&r"))
5578    (clobber (reg:SI 26))
5579    (clobber (reg:SI 25))
5580    (clobber (reg:SI 2))]
5581   "TARGET_64BIT"
5582   "*
5583    return pa_output_div_insn (operands, 1, insn);"
5584   [(set_attr "type" "milli")
5585    (set (attr "length")
5586         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5587               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5589 (define_expand "modsi3"
5590   [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5591    (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5592    (parallel [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
5593               (clobber (match_dup 3))
5594               (clobber (match_dup 4))
5595               (clobber (reg:SI 26))
5596               (clobber (reg:SI 25))
5597               (clobber (match_dup 5))])
5598    (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5599   ""
5600   "
5602   if (TARGET_64BIT)
5603     {
5604       operands[5] = gen_rtx_REG (SImode, 2);
5605       operands[4] = operands[5];
5606     }
5607   else
5608     {
5609       operands[5] = gen_rtx_REG (SImode, 31);
5610       operands[4] = gen_reg_rtx (SImode);
5611     }
5612   operands[3] = gen_reg_rtx (SImode);
5615 (define_insn ""
5616   [(set (reg:SI 29) (mod: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 31))]
5622   "!TARGET_64BIT"
5623   "*
5624   return pa_output_mod_insn (0, 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 (define_insn ""
5631   [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
5632    (clobber (match_operand:SI 0 "register_operand" "=a"))
5633    (clobber (match_operand:SI 1 "register_operand" "=&r"))
5634    (clobber (reg:SI 26))
5635    (clobber (reg:SI 25))
5636    (clobber (reg:SI 2))]
5637   "TARGET_64BIT"
5638   "*
5639   return pa_output_mod_insn (0, insn);"
5640   [(set_attr "type" "milli")
5641    (set (attr "length")
5642         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5643               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5645 (define_expand "umodsi3"
5646   [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5647    (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5648    (parallel [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
5649               (clobber (match_dup 3))
5650               (clobber (match_dup 4))
5651               (clobber (reg:SI 26))
5652               (clobber (reg:SI 25))
5653               (clobber (match_dup 5))])
5654    (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5655   ""
5656   "
5658   if (TARGET_64BIT)
5659     {
5660       operands[5] = gen_rtx_REG (SImode, 2);
5661       operands[4] = operands[5];
5662     }
5663   else
5664     {
5665       operands[5] = gen_rtx_REG (SImode, 31);
5666       operands[4] = gen_reg_rtx (SImode);
5667     }
5668   operands[3] = gen_reg_rtx (SImode);
5671 (define_insn ""
5672   [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
5673    (clobber (match_operand:SI 0 "register_operand" "=a"))
5674    (clobber (match_operand:SI 1 "register_operand" "=&r"))
5675    (clobber (reg:SI 26))
5676    (clobber (reg:SI 25))
5677    (clobber (reg:SI 31))]
5678   "!TARGET_64BIT"
5679   "*
5680   return pa_output_mod_insn (1, insn);"
5681   [(set_attr "type" "milli")
5682    (set (attr "length")
5683         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5684               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5686 (define_insn ""
5687   [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
5688    (clobber (match_operand:SI 0 "register_operand" "=a"))
5689    (clobber (match_operand:SI 1 "register_operand" "=&r"))
5690    (clobber (reg:SI 26))
5691    (clobber (reg:SI 25))
5692    (clobber (reg:SI 2))]
5693   "TARGET_64BIT"
5694   "*
5695   return pa_output_mod_insn (1, insn);"
5696   [(set_attr "type" "milli")
5697    (set (attr "length")
5698         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5699               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5701 ;;- and instructions
5702 ;; We define DImode `and` so with DImode `not` we can get
5703 ;; DImode `andn`.  Other combinations are possible.
5705 (define_expand "anddi3"
5706   [(set (match_operand:DI 0 "register_operand" "")
5707         (and:DI (match_operand:DI 1 "register_operand" "")
5708                 (match_operand:DI 2 "and_operand" "")))]
5709   "TARGET_64BIT"
5710   "")
5712 (define_insn ""
5713   [(set (match_operand:DI 0 "register_operand" "=r,r")
5714         (and:DI (match_operand:DI 1 "register_operand" "%?r,0")
5715                 (match_operand:DI 2 "and_operand" "rO,P")))]
5716   "TARGET_64BIT"
5717   "* return pa_output_64bit_and (operands); "
5718   [(set_attr "type" "binary")
5719    (set_attr "length" "4")])
5721 ; The ? for op1 makes reload prefer zdepi instead of loading a huge
5722 ; constant with ldil;ldo.
5723 (define_insn "andsi3"
5724   [(set (match_operand:SI 0 "register_operand" "=r,r")
5725         (and:SI (match_operand:SI 1 "register_operand" "%?r,0")
5726                 (match_operand:SI 2 "and_operand" "rO,P")))]
5727   ""
5728   "* return pa_output_and (operands); "
5729   [(set_attr "type" "binary,shift")
5730    (set_attr "length" "4,4")])
5732 (define_insn ""
5733   [(set (match_operand:DI 0 "register_operand" "=r")
5734         (and:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
5735                 (match_operand:DI 2 "register_operand" "r")))]
5736   "TARGET_64BIT"
5737   "andcm %2,%1,%0"
5738   [(set_attr "type" "binary")
5739    (set_attr "length" "4")])
5741 (define_insn ""
5742   [(set (match_operand:SI 0 "register_operand" "=r")
5743         (and:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
5744                 (match_operand:SI 2 "register_operand" "r")))]
5745   ""
5746   "andcm %2,%1,%0"
5747   [(set_attr "type" "binary")
5748   (set_attr "length" "4")])
5750 (define_expand "iordi3"
5751   [(set (match_operand:DI 0 "register_operand" "")
5752         (ior:DI (match_operand:DI 1 "register_operand" "")
5753                 (match_operand:DI 2 "reg_or_cint_ior_operand" "")))]
5754   "TARGET_64BIT"
5755   "")
5757 (define_insn ""
5758   [(set (match_operand:DI 0 "register_operand" "=r,r")
5759         (ior:DI (match_operand:DI 1 "register_operand" "0,0")
5760                 (match_operand:DI 2 "cint_ior_operand" "M,i")))]
5761   "TARGET_64BIT"
5762   "* return pa_output_64bit_ior (operands); "
5763   [(set_attr "type" "binary,shift")
5764    (set_attr "length" "4,4")])
5766 (define_insn ""
5767   [(set (match_operand:DI 0 "register_operand" "=r")
5768         (ior:DI (match_operand:DI 1 "register_operand" "%r")
5769                 (match_operand:DI 2 "register_operand" "r")))]
5770   "TARGET_64BIT"
5771   "or %1,%2,%0"
5772   [(set_attr "type" "binary")
5773    (set_attr "length" "4")])
5775 ;; Need a define_expand because we've run out of CONST_OK... characters.
5776 (define_expand "iorsi3"
5777   [(set (match_operand:SI 0 "register_operand" "")
5778         (ior:SI (match_operand:SI 1 "register_operand" "")
5779                 (match_operand:SI 2 "reg_or_cint_ior_operand" "")))]
5780   ""
5781   "")
5783 (define_insn ""
5784   [(set (match_operand:SI 0 "register_operand" "=r,r")
5785         (ior:SI (match_operand:SI 1 "register_operand" "0,0")
5786                 (match_operand:SI 2 "cint_ior_operand" "M,i")))]
5787   ""
5788   "* return pa_output_ior (operands); "
5789   [(set_attr "type" "binary,shift")
5790    (set_attr "length" "4,4")])
5792 (define_insn ""
5793   [(set (match_operand:SI 0 "register_operand" "=r")
5794         (ior:SI (match_operand:SI 1 "register_operand" "%r")
5795                 (match_operand:SI 2 "register_operand" "r")))]
5796   ""
5797   "or %1,%2,%0"
5798   [(set_attr "type" "binary")
5799    (set_attr "length" "4")])
5801 (define_expand "xordi3"
5802   [(set (match_operand:DI 0 "register_operand" "")
5803         (xor:DI (match_operand:DI 1 "register_operand" "")
5804                 (match_operand:DI 2 "register_operand" "")))]
5805   "TARGET_64BIT"
5806   "")
5808 (define_insn ""
5809   [(set (match_operand:DI 0 "register_operand" "=r")
5810         (xor:DI (match_operand:DI 1 "register_operand" "%r")
5811                 (match_operand:DI 2 "register_operand" "r")))]
5812   "TARGET_64BIT"
5813   "xor %1,%2,%0"
5814   [(set_attr "type" "binary")
5815    (set_attr "length" "4")])
5817 (define_insn "xorsi3"
5818   [(set (match_operand:SI 0 "register_operand" "=r")
5819         (xor:SI (match_operand:SI 1 "register_operand" "%r")
5820                 (match_operand:SI 2 "register_operand" "r")))]
5821   ""
5822   "xor %1,%2,%0"
5823   [(set_attr "type" "binary")
5824    (set_attr "length" "4")])
5826 (define_expand "negdi2"
5827   [(set (match_operand:DI 0 "register_operand" "")
5828         (neg:DI (match_operand:DI 1 "register_operand" "")))]
5829   ""
5830   "")
5832 (define_insn ""
5833   [(set (match_operand:DI 0 "register_operand" "=r")
5834         (neg:DI (match_operand:DI 1 "register_operand" "r")))]
5835   "!TARGET_64BIT"
5836   "sub %%r0,%R1,%R0\;{subb|sub,b} %%r0,%1,%0"
5837   [(set_attr "type" "unary")
5838    (set_attr "length" "8")])
5840 (define_insn ""
5841   [(set (match_operand:DI 0 "register_operand" "=r")
5842         (neg:DI (match_operand:DI 1 "register_operand" "r")))]
5843   "TARGET_64BIT"
5844   "sub %%r0,%1,%0"
5845   [(set_attr "type" "unary")
5846    (set_attr "length" "4")])
5848 (define_expand "negvdi2"
5849   [(parallel [(set (match_operand:DI 0 "register_operand" "")
5850                    (neg:DI (match_operand:DI 1 "register_operand" "")))
5851               (trap_if (ne (neg:TI (sign_extend:TI (match_dup 1)))
5852                                    (sign_extend:TI (neg:DI (match_dup 1))))
5853                        (const_int 0))])]
5854   ""
5855   "")
5857 (define_insn ""
5858   [(set (match_operand:DI 0 "register_operand" "=r")
5859         (neg:DI (match_operand:DI 1 "register_operand" "r")))
5860    (trap_if (ne (neg:TI (sign_extend:TI (match_dup 1)))
5861                 (sign_extend:TI (neg:DI (match_dup 1))))
5862             (const_int 0))]
5863   "!TARGET_64BIT"
5864   "sub %%r0,%R1,%R0\;{subbo|sub,b,tsv} %%r0,%1,%0"
5865   [(set_attr "type" "unary")
5866    (set_attr "length" "8")])
5868 (define_insn ""
5869   [(set (match_operand:DI 0 "register_operand" "=r")
5870         (neg:DI (match_operand:DI 1 "register_operand" "r")))
5871    (trap_if (ne (neg:TI (sign_extend:TI (match_dup 1)))
5872                 (sign_extend:TI (neg:DI (match_dup 1))))
5873             (const_int 0))]
5874   "TARGET_64BIT"
5875   "sub,tsv %%r0,%1,%0"
5876   [(set_attr "type" "unary")
5877    (set_attr "length" "4")])
5879 (define_insn "negsi2"
5880   [(set (match_operand:SI 0 "register_operand" "=r")
5881         (neg:SI (match_operand:SI 1 "register_operand" "r")))]
5882   ""
5883   "sub %%r0,%1,%0"
5884   [(set_attr "type" "unary")
5885    (set_attr "length" "4")])
5887 (define_insn "negvsi2"
5888   [(set (match_operand:SI 0 "register_operand" "=r")
5889         (neg:SI (match_operand:SI 1 "register_operand" "r")))
5890    (trap_if (ne (neg:DI (sign_extend:DI (match_dup 1)))
5891                 (sign_extend:DI (neg:SI (match_dup 1))))
5892             (const_int 0))]
5893    ""
5894    "{subo|sub,tsv} %%r0,%1,%0"
5895   [(set_attr "type" "unary")
5896    (set_attr "length" "4")])
5898 (define_expand "one_cmpldi2"
5899   [(set (match_operand:DI 0 "register_operand" "")
5900         (not:DI (match_operand:DI 1 "register_operand" "")))]
5901   ""
5902   "
5906 (define_insn ""
5907   [(set (match_operand:DI 0 "register_operand" "=r")
5908         (not:DI (match_operand:DI 1 "register_operand" "r")))]
5909   "!TARGET_64BIT"
5910   "uaddcm %%r0,%1,%0\;uaddcm %%r0,%R1,%R0"
5911   [(set_attr "type" "unary")
5912    (set_attr "length" "8")])
5914 (define_insn ""
5915   [(set (match_operand:DI 0 "register_operand" "=r")
5916         (not:DI (match_operand:DI 1 "register_operand" "r")))]
5917   "TARGET_64BIT"
5918   "uaddcm %%r0,%1,%0"
5919   [(set_attr "type" "unary")
5920    (set_attr "length" "4")])
5922 (define_insn "one_cmplsi2"
5923   [(set (match_operand:SI 0 "register_operand" "=r")
5924         (not:SI (match_operand:SI 1 "register_operand" "r")))]
5925   ""
5926   "uaddcm %%r0,%1,%0"
5927   [(set_attr "type" "unary")
5928    (set_attr "length" "4")])
5930 ;; Floating point arithmetic instructions.
5932 (define_insn "adddf3"
5933   [(set (match_operand:DF 0 "register_operand" "=f")
5934         (plus:DF (match_operand:DF 1 "register_operand" "f")
5935                  (match_operand:DF 2 "register_operand" "f")))]
5936   "! TARGET_SOFT_FLOAT"
5937   "fadd,dbl %1,%2,%0"
5938   [(set_attr "type" "fpalu")
5939    (set_attr "pa_combine_type" "faddsub")
5940    (set_attr "length" "4")])
5942 (define_insn "addsf3"
5943   [(set (match_operand:SF 0 "register_operand" "=f")
5944         (plus:SF (match_operand:SF 1 "register_operand" "f")
5945                  (match_operand:SF 2 "register_operand" "f")))]
5946   "! TARGET_SOFT_FLOAT"
5947   "fadd,sgl %1,%2,%0"
5948   [(set_attr "type" "fpalu")
5949    (set_attr "pa_combine_type" "faddsub")
5950    (set_attr "length" "4")])
5952 (define_insn "subdf3"
5953   [(set (match_operand:DF 0 "register_operand" "=f")
5954         (minus:DF (match_operand:DF 1 "register_operand" "f")
5955                   (match_operand:DF 2 "register_operand" "f")))]
5956   "! TARGET_SOFT_FLOAT"
5957   "fsub,dbl %1,%2,%0"
5958   [(set_attr "type" "fpalu")
5959    (set_attr "pa_combine_type" "faddsub")
5960    (set_attr "length" "4")])
5962 (define_insn "subsf3"
5963   [(set (match_operand:SF 0 "register_operand" "=f")
5964         (minus:SF (match_operand:SF 1 "register_operand" "f")
5965                   (match_operand:SF 2 "register_operand" "f")))]
5966   "! TARGET_SOFT_FLOAT"
5967   "fsub,sgl %1,%2,%0"
5968   [(set_attr "type" "fpalu")
5969    (set_attr "pa_combine_type" "faddsub")
5970    (set_attr "length" "4")])
5972 (define_insn "muldf3"
5973   [(set (match_operand:DF 0 "register_operand" "=f")
5974         (mult:DF (match_operand:DF 1 "register_operand" "f")
5975                  (match_operand:DF 2 "register_operand" "f")))]
5976   "! TARGET_SOFT_FLOAT"
5977   "fmpy,dbl %1,%2,%0"
5978   [(set_attr "type" "fpmuldbl")
5979    (set_attr "pa_combine_type" "fmpy")
5980    (set_attr "length" "4")])
5982 (define_insn "mulsf3"
5983   [(set (match_operand:SF 0 "register_operand" "=f")
5984         (mult:SF (match_operand:SF 1 "register_operand" "f")
5985                  (match_operand:SF 2 "register_operand" "f")))]
5986   "! TARGET_SOFT_FLOAT"
5987   "fmpy,sgl %1,%2,%0"
5988   [(set_attr "type" "fpmulsgl")
5989    (set_attr "pa_combine_type" "fmpy")
5990    (set_attr "length" "4")])
5992 (define_insn "divdf3"
5993   [(set (match_operand:DF 0 "register_operand" "=f")
5994         (div:DF (match_operand:DF 1 "register_operand" "f")
5995                 (match_operand:DF 2 "register_operand" "f")))]
5996   "! TARGET_SOFT_FLOAT"
5997   "fdiv,dbl %1,%2,%0"
5998   [(set_attr "type" "fpdivdbl")
5999    (set_attr "length" "4")])
6001 (define_insn "divsf3"
6002   [(set (match_operand:SF 0 "register_operand" "=f")
6003         (div:SF (match_operand:SF 1 "register_operand" "f")
6004                 (match_operand:SF 2 "register_operand" "f")))]
6005   "! TARGET_SOFT_FLOAT"
6006   "fdiv,sgl %1,%2,%0"
6007   [(set_attr "type" "fpdivsgl")
6008    (set_attr "length" "4")])
6010 ;; Processors prior to PA 2.0 don't have a fneg instruction.  Fast
6011 ;; negation can be done by subtracting from plus zero.  However, this
6012 ;; violates the IEEE standard when negating plus and minus zero.
6013 ;; The slow path toggles the sign bit in the general registers.
6014 (define_expand "negdf2"
6015   [(set (match_operand:DF 0 "register_operand" "")
6016         (neg:DF (match_operand:DF 1 "register_operand" "")))]
6017   "!TARGET_SOFT_FLOAT"
6019   if (TARGET_PA_20 || !flag_signed_zeros)
6020     emit_insn (gen_negdf2_fast (operands[0], operands[1]));
6021   else
6022     emit_insn (gen_negdf2_slow (operands[0], operands[1]));
6023   DONE;
6026 (define_insn "negdf2_slow"
6027   [(set (match_operand:DF 0 "register_operand" "=r")
6028         (neg:DF (match_operand:DF 1 "register_operand" "r")))]
6029   "!TARGET_SOFT_FLOAT && !TARGET_PA_20"
6030   "*
6032   if (rtx_equal_p (operands[0], operands[1]))
6033     return \"and,< %1,%1,%0\;depi,tr 1,0,1,%0\;depi 0,0,1,%0\";
6034   else
6035     return \"and,< %1,%1,%0\;depi,tr 1,0,1,%0\;depi 0,0,1,%0\;copy %R1,%R0\";
6037   [(set_attr "type" "multi")
6038    (set (attr "length")
6039         (if_then_else (match_test "rtx_equal_p (operands[0], operands[1])")
6040             (const_int 12)
6041             (const_int 16)))])
6043 (define_insn "negdf2_fast"
6044   [(set (match_operand:DF 0 "register_operand" "=f")
6045         (neg:DF (match_operand:DF 1 "register_operand" "f")))]
6046   "!TARGET_SOFT_FLOAT"
6047   "*
6049   if (TARGET_PA_20)
6050     return \"fneg,dbl %1,%0\";
6051   else
6052     return \"fsub,dbl %%fr0,%1,%0\";
6054   [(set_attr "type" "fpalu")
6055    (set_attr "length" "4")])
6057 (define_expand "negsf2"
6058   [(set (match_operand:SF 0 "register_operand" "")
6059         (neg:SF (match_operand:SF 1 "register_operand" "")))]
6060   "!TARGET_SOFT_FLOAT"
6062   if (TARGET_PA_20 || !flag_signed_zeros)
6063     emit_insn (gen_negsf2_fast (operands[0], operands[1]));
6064   else
6065     emit_insn (gen_negsf2_slow (operands[0], operands[1]));
6066   DONE;
6069 (define_insn "negsf2_slow"
6070   [(set (match_operand:SF 0 "register_operand" "=r")
6071         (neg:SF (match_operand:SF 1 "register_operand" "r")))]
6072   "!TARGET_SOFT_FLOAT && !TARGET_PA_20"
6073   "and,< %1,%1,%0\;depi,tr 1,0,1,%0\;depi 0,0,1,%0"
6074   [(set_attr "type" "multi")
6075    (set_attr "length" "12")])
6077 (define_insn "negsf2_fast"
6078   [(set (match_operand:SF 0 "register_operand" "=f")
6079         (neg:SF (match_operand:SF 1 "register_operand" "f")))]
6080   "!TARGET_SOFT_FLOAT"
6081   "*
6083   if (TARGET_PA_20)
6084     return \"fneg,sgl %1,%0\";
6085   else
6086     return \"fsub,sgl %%fr0,%1,%0\";
6088   [(set_attr "type" "fpalu")
6089    (set_attr "length" "4")])
6091 (define_insn "absdf2"
6092   [(set (match_operand:DF 0 "register_operand" "=f")
6093         (abs:DF (match_operand:DF 1 "register_operand" "f")))]
6094   "! TARGET_SOFT_FLOAT"
6095   "fabs,dbl %1,%0"
6096   [(set_attr "type" "fpalu")
6097    (set_attr "length" "4")])
6099 (define_insn "abssf2"
6100   [(set (match_operand:SF 0 "register_operand" "=f")
6101         (abs:SF (match_operand:SF 1 "register_operand" "f")))]
6102   "! TARGET_SOFT_FLOAT"
6103   "fabs,sgl %1,%0"
6104   [(set_attr "type" "fpalu")
6105    (set_attr "length" "4")])
6107 (define_insn "sqrtdf2"
6108   [(set (match_operand:DF 0 "register_operand" "=f")
6109         (sqrt:DF (match_operand:DF 1 "register_operand" "f")))]
6110   "! TARGET_SOFT_FLOAT"
6111   "fsqrt,dbl %1,%0"
6112   [(set_attr "type" "fpsqrtdbl")
6113    (set_attr "length" "4")])
6115 (define_insn "sqrtsf2"
6116   [(set (match_operand:SF 0 "register_operand" "=f")
6117         (sqrt:SF (match_operand:SF 1 "register_operand" "f")))]
6118   "! TARGET_SOFT_FLOAT"
6119   "fsqrt,sgl %1,%0"
6120   [(set_attr "type" "fpsqrtsgl")
6121    (set_attr "length" "4")])
6123 ;; PA 2.0 floating point instructions
6125 ; fmpyfadd patterns
6126 (define_insn "fmadf4"
6127   [(set (match_operand:DF 0 "register_operand" "=f")
6128         (fma:DF (match_operand:DF 1 "register_operand" "f")
6129                 (match_operand:DF 2 "register_operand" "f")
6130                 (match_operand:DF 3 "register_operand" "f")))]
6131   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6132   "fmpyfadd,dbl %1,%2,%3,%0"
6133   [(set_attr "type" "fpmuldbl")
6134    (set_attr "length" "4")])
6136 (define_insn "fmasf4"
6137   [(set (match_operand:SF 0 "register_operand" "=f")
6138         (fma:SF (match_operand:SF 1 "register_operand" "f")
6139                 (match_operand:SF 2 "register_operand" "f")
6140                 (match_operand:SF 3 "register_operand" "f")))]
6141   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6142   "fmpyfadd,sgl %1,%2,%3,%0"
6143   [(set_attr "type" "fpmulsgl")
6144    (set_attr "length" "4")])
6146 ; fmpynfadd patterns
6147 (define_insn "fnmadf4"
6148   [(set (match_operand:DF 0 "register_operand" "=f")
6149         (fma:DF (neg:DF (match_operand:DF 1 "register_operand" "f"))
6150                 (match_operand:DF 2 "register_operand" "f")
6151                 (match_operand:DF 3 "register_operand" "f")))]
6152   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6153   "fmpynfadd,dbl %1,%2,%3,%0"
6154   [(set_attr "type" "fpmuldbl")
6155    (set_attr "length" "4")])
6157 (define_insn "fnmasf4"
6158   [(set (match_operand:SF 0 "register_operand" "=f")
6159         (fma:SF (neg:SF (match_operand:SF 1 "register_operand" "f"))
6160                 (match_operand:SF 2 "register_operand" "f")
6161                 (match_operand:SF 3 "register_operand" "f")))]
6162   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6163   "fmpynfadd,sgl %1,%2,%3,%0"
6164   [(set_attr "type" "fpmulsgl")
6165    (set_attr "length" "4")])
6167 ; fnegabs patterns
6168 (define_insn ""
6169   [(set (match_operand:DF 0 "register_operand" "=f")
6170         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))]
6171   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6172   "fnegabs,dbl %1,%0"
6173   [(set_attr "type" "fpalu")
6174    (set_attr "length" "4")])
6176 (define_insn ""
6177   [(set (match_operand:SF 0 "register_operand" "=f")
6178         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))]
6179   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6180   "fnegabs,sgl %1,%0"
6181   [(set_attr "type" "fpalu")
6182    (set_attr "length" "4")])
6184 (define_insn ""
6185   [(set (match_operand:DF 0 "register_operand" "=f")
6186         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))
6187    (set (match_operand:DF 2 "register_operand" "=&f") (abs:DF (match_dup 1)))]
6188   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6189     && ! reg_overlap_mentioned_p (operands[2], operands[1]))"
6190   "#"
6191   [(set_attr "type" "fpalu")
6192    (set_attr "length" "8")])
6194 (define_split
6195   [(set (match_operand:DF 0 "register_operand" "")
6196         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" ""))))
6197    (set (match_operand:DF 2 "register_operand" "") (abs:DF (match_dup 1)))]
6198   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6199   [(set (match_dup 2) (abs:DF (match_dup 1)))
6200    (set (match_dup 0) (neg:DF (abs:DF (match_dup 1))))]
6201   "")
6203 (define_insn ""
6204   [(set (match_operand:SF 0 "register_operand" "=f")
6205         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))
6206    (set (match_operand:SF 2 "register_operand" "=&f") (abs:SF (match_dup 1)))]
6207   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6208     && ! reg_overlap_mentioned_p (operands[2], operands[1]))"
6209   "#"
6210   [(set_attr "type" "fpalu")
6211    (set_attr "length" "8")])
6213 (define_split
6214   [(set (match_operand:SF 0 "register_operand" "")
6215         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" ""))))
6216    (set (match_operand:SF 2 "register_operand" "") (abs:SF (match_dup 1)))]
6217   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6218   [(set (match_dup 2) (abs:SF (match_dup 1)))
6219    (set (match_dup 0) (neg:SF (abs:SF (match_dup 1))))]
6220   "")
6222 ;; Negating a multiply can be faked by adding zero in a fused multiply-add
6223 ;; instruction if we can ignore the sign of zero.
6224 (define_insn ""
6225   [(set (match_operand:DF 0 "register_operand" "=f")
6226         (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
6227                          (match_operand:DF 2 "register_operand" "f"))))]
6228   "!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros"
6229   "fmpynfadd,dbl %1,%2,%%fr0,%0"
6230   [(set_attr "type" "fpmuldbl")
6231    (set_attr "length" "4")])
6233 (define_insn ""
6234   [(set (match_operand:SF 0 "register_operand" "=f")
6235         (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
6236                          (match_operand:SF 2 "register_operand" "f"))))]
6237   "!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros"
6238   "fmpynfadd,sgl %1,%2,%%fr0,%0"
6239   [(set_attr "type" "fpmuldbl")
6240    (set_attr "length" "4")])
6242 (define_insn ""
6243   [(set (match_operand:DF 0 "register_operand" "=f")
6244         (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
6245                          (match_operand:DF 2 "register_operand" "f"))))
6246    (set (match_operand:DF 3 "register_operand" "=&f")
6247         (mult:DF (match_dup 1) (match_dup 2)))]
6248   "(!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros
6249     && ! (reg_overlap_mentioned_p (operands[3], operands[1])
6250           || reg_overlap_mentioned_p (operands[3], operands[2])))"
6251   "#"
6252   [(set_attr "type" "fpmuldbl")
6253    (set_attr "length" "8")])
6255 (define_split
6256   [(set (match_operand:DF 0 "register_operand" "")
6257         (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "")
6258                          (match_operand:DF 2 "register_operand" ""))))
6259    (set (match_operand:DF 3 "register_operand" "")
6260         (mult:DF (match_dup 1) (match_dup 2)))]
6261   "!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros"
6262   [(set (match_dup 3) (mult:DF (match_dup 1) (match_dup 2)))
6263    (set (match_dup 0) (neg:DF (mult:DF (match_dup 1) (match_dup 2))))]
6264   "")
6266 (define_insn ""
6267   [(set (match_operand:SF 0 "register_operand" "=f")
6268         (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
6269                          (match_operand:SF 2 "register_operand" "f"))))
6270    (set (match_operand:SF 3 "register_operand" "=&f")
6271         (mult:SF (match_dup 1) (match_dup 2)))]
6272   "(!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros
6273     && ! (reg_overlap_mentioned_p (operands[3], operands[1])
6274           || reg_overlap_mentioned_p (operands[3], operands[2])))"
6275   "#"
6276   [(set_attr "type" "fpmuldbl")
6277    (set_attr "length" "8")])
6279 (define_split
6280   [(set (match_operand:SF 0 "register_operand" "")
6281         (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "")
6282                          (match_operand:SF 2 "register_operand" ""))))
6283    (set (match_operand:SF 3 "register_operand" "")
6284         (mult:SF (match_dup 1) (match_dup 2)))]
6285   "!TARGET_SOFT_FLOAT && TARGET_PA_20&& !flag_signed_zeros"
6286   [(set (match_dup 3) (mult:SF (match_dup 1) (match_dup 2)))
6287    (set (match_dup 0) (neg:SF (mult:SF (match_dup 1) (match_dup 2))))]
6288   "")
6290 ;;- Shift instructions
6292 ;; Optimized special case of shifting.
6294 (define_insn ""
6295   [(set (match_operand:SI 0 "register_operand" "=r")
6296         (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
6297                      (const_int 24)))]
6298   ""
6299   "ldb%M1 %1,%0"
6300   [(set_attr "type" "load")
6301    (set_attr "length" "4")])
6303 (define_insn ""
6304   [(set (match_operand:SI 0 "register_operand" "=r")
6305         (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
6306                      (const_int 16)))]
6307   ""
6308   "ldh%M1 %1,%0"
6309   [(set_attr "type" "load")
6310    (set_attr "length" "4")])
6312 (define_insn ""
6313   [(set (match_operand:SI 0 "register_operand" "=r")
6314         (plus:SI (mult:SI (match_operand:SI 2 "register_operand" "r")
6315                           (match_operand:SI 3 "shadd_operand" ""))
6316                  (match_operand:SI 1 "register_operand" "r")))]
6317   ""
6318   "{sh%O3addl %2,%1,%0|shladd,l %2,%O3,%1,%0} "
6319   [(set_attr "type" "binary")
6320    (set_attr "length" "4")])
6322 (define_insn ""
6323   [(set (match_operand:DI 0 "register_operand" "=r")
6324         (plus:DI (mult:DI (match_operand:DI 2 "register_operand" "r")
6325                           (match_operand:DI 3 "shadd_operand" ""))
6326                  (match_operand:DI 1 "register_operand" "r")))]
6327   "TARGET_64BIT"
6328   "shladd,l %2,%O3,%1,%0"
6329   [(set_attr "type" "binary")
6330    (set_attr "length" "4")])
6332 (define_expand "ashlsi3"
6333   [(set (match_operand:SI 0 "register_operand" "")
6334         (ashift:SI (match_operand:SI 1 "lhs_lshift_operand" "")
6335                    (match_operand:SI 2 "arith32_operand" "")))]
6336   ""
6337   "
6339   if (GET_CODE (operands[2]) != CONST_INT)
6340     {
6341       rtx temp = gen_reg_rtx (SImode);
6342       emit_insn (gen_subsi3 (temp, GEN_INT (31), operands[2]));
6343       if (GET_CODE (operands[1]) == CONST_INT)
6344         emit_insn (gen_zvdep_imm32 (operands[0], operands[1], temp));
6345       else
6346         emit_insn (gen_zvdep32 (operands[0], operands[1], temp));
6347       DONE;
6348     }
6349   /* Make sure both inputs are not constants,
6350      there are no patterns for that.  */
6351   operands[1] = force_reg (SImode, operands[1]);
6354 (define_insn ""
6355   [(set (match_operand:SI 0 "register_operand" "=r")
6356         (ashift:SI (match_operand:SI 1 "register_operand" "r")
6357                    (match_operand:SI 2 "const_int_operand" "n")))]
6358   ""
6359   "{zdep|depw,z} %1,%P2,%L2,%0"
6360   [(set_attr "type" "shift")
6361    (set_attr "length" "4")])
6363 ; Match cases of op1 a CONST_INT here that zvdep_imm32 doesn't handle.
6364 ; Doing it like this makes slightly better code since reload can
6365 ; replace a register with a known value in range -16..15 with a
6366 ; constant.  Ideally, we would like to merge zvdep32 and zvdep_imm32,
6367 ; but since we have no more CONST_OK... characters, that is not
6368 ; possible.
6369 (define_insn "zvdep32"
6370   [(set (match_operand:SI 0 "register_operand" "=r,r")
6371         (ashift:SI (match_operand:SI 1 "arith5_operand" "r,L")
6372                    (minus:SI (const_int 31)
6373                              (match_operand:SI 2 "register_operand" "q,q"))))]
6374   ""
6375   "@
6376    {zvdep %1,32,%0|depw,z %1,%%sar,32,%0}
6377    {zvdepi %1,32,%0|depwi,z %1,%%sar,32,%0}"
6378   [(set_attr "type" "shift,shift")
6379    (set_attr "length" "4,4")])
6381 (define_insn "zvdep_imm32"
6382   [(set (match_operand:SI 0 "register_operand" "=r")
6383         (ashift:SI (match_operand:SI 1 "lhs_lshift_cint_operand" "")
6384                    (minus:SI (const_int 31)
6385                              (match_operand:SI 2 "register_operand" "q"))))]
6386   ""
6387   "*
6389   unsigned HOST_WIDE_INT x = UINTVAL (operands[1]);
6390   operands[2] = GEN_INT (4 + exact_log2 ((x >> 4) + 1));
6391   operands[1] = GEN_INT ((x & 0xf) - 0x10);
6392   return \"{zvdepi %1,%2,%0|depwi,z %1,%%sar,%2,%0}\";
6394   [(set_attr "type" "shift")
6395    (set_attr "length" "4")])
6397 (define_insn "vdepi_ior"
6398   [(set (match_operand:SI 0 "register_operand" "=r")
6399         (ior:SI (ashift:SI (match_operand:SI 1 "const_int_operand" "")
6400                            (minus:SI (const_int 31)
6401                                      (match_operand:SI 2 "register_operand" "q")))
6402                 (match_operand:SI 3 "register_operand" "0")))]
6403   ; accept ...0001...1, can this be generalized?
6404   "exact_log2 (INTVAL (operands[1]) + 1) > 0"
6405   "*
6407   HOST_WIDE_INT x = INTVAL (operands[1]);
6408   operands[2] = GEN_INT (exact_log2 (x + 1));
6409   return \"{vdepi -1,%2,%0|depwi -1,%%sar,%2,%0}\";
6411   [(set_attr "type" "shift")
6412    (set_attr "length" "4")])
6414 (define_insn "vdepi_and"
6415   [(set (match_operand:SI 0 "register_operand" "=r")
6416         (and:SI (rotate:SI (match_operand:SI 1 "const_int_operand" "")
6417                            (minus:SI (const_int 31)
6418                                      (match_operand:SI 2 "register_operand" "q")))
6419                 (match_operand:SI 3 "register_operand" "0")))]
6420   ; this can be generalized...!
6421   "INTVAL (operands[1]) == -2"
6422   "*
6424   HOST_WIDE_INT x = INTVAL (operands[1]);
6425   operands[2] = GEN_INT (exact_log2 ((~x) + 1));
6426   return \"{vdepi 0,%2,%0|depwi 0,%%sar,%2,%0}\";
6428   [(set_attr "type" "shift")
6429    (set_attr "length" "4")])
6431 (define_expand "ashldi3"
6432   [(set (match_operand:DI 0 "register_operand" "")
6433         (ashift:DI (match_operand:DI 1 "lhs_lshift_operand" "")
6434                    (match_operand:DI 2 "arith32_operand" "")))]
6435   "TARGET_64BIT"
6436   "
6438   if (GET_CODE (operands[2]) != CONST_INT)
6439     {
6440       rtx temp = gen_reg_rtx (DImode);
6441       emit_insn (gen_subdi3 (temp, GEN_INT (63), operands[2]));
6442       if (GET_CODE (operands[1]) == CONST_INT)
6443         emit_insn (gen_zvdep_imm64 (operands[0], operands[1], temp));
6444       else
6445         emit_insn (gen_zvdep64 (operands[0], operands[1], temp));
6446       DONE;
6447     }
6448   /* Make sure both inputs are not constants,
6449      there are no patterns for that.  */
6450   operands[1] = force_reg (DImode, operands[1]);
6453 (define_insn ""
6454   [(set (match_operand:DI 0 "register_operand" "=r")
6455         (ashift:DI (match_operand:DI 1 "register_operand" "r")
6456                    (match_operand:DI 2 "const_int_operand" "n")))]
6457   "TARGET_64BIT"
6458   "depd,z %1,%p2,%Q2,%0"
6459   [(set_attr "type" "shift")
6460    (set_attr "length" "4")])
6462 ; Match cases of op1 a CONST_INT here that zvdep_imm64 doesn't handle.
6463 ; Doing it like this makes slightly better code since reload can
6464 ; replace a register with a known value in range -16..15 with a
6465 ; constant.  Ideally, we would like to merge zvdep64 and zvdep_imm64,
6466 ; but since we have no more CONST_OK... characters, that is not
6467 ; possible.
6468 (define_insn "zvdep64"
6469   [(set (match_operand:DI 0 "register_operand" "=r,r")
6470         (ashift:DI (match_operand:DI 1 "arith5_operand" "r,L")
6471                    (minus:DI (const_int 63)
6472                              (match_operand:DI 2 "register_operand" "q,q"))))]
6473   "TARGET_64BIT"
6474   "@
6475    depd,z %1,%%sar,64,%0
6476    depdi,z %1,%%sar,64,%0"
6477   [(set_attr "type" "shift,shift")
6478    (set_attr "length" "4,4")])
6480 (define_insn "zvdep_imm64"
6481   [(set (match_operand:DI 0 "register_operand" "=r")
6482         (ashift:DI (match_operand:DI 1 "lhs_lshift_cint_operand" "")
6483                    (minus:DI (const_int 63)
6484                              (match_operand:DI 2 "register_operand" "q"))))]
6485   "TARGET_64BIT"
6486   "*
6488   unsigned HOST_WIDE_INT x = UINTVAL (operands[1]);
6489   operands[2] = GEN_INT (4 + exact_log2 ((x >> 4) + 1));
6490   operands[1] = GEN_INT ((x & 0x1f) - 0x20);
6491   return \"depdi,z %1,%%sar,%2,%0\";
6493   [(set_attr "type" "shift")
6494    (set_attr "length" "4")])
6496 (define_insn ""
6497   [(set (match_operand:DI 0 "register_operand" "=r")
6498         (ior:DI (ashift:DI (match_operand:DI 1 "const_int_operand" "")
6499                            (minus:DI (const_int 63)
6500                                      (match_operand:DI 2 "register_operand" "q")))
6501                 (match_operand:DI 3 "register_operand" "0")))]
6502   ; accept ...0001...1, can this be generalized?
6503   "TARGET_64BIT && exact_log2 (INTVAL (operands[1]) + 1) > 0"
6504   "*
6506   HOST_WIDE_INT x = INTVAL (operands[1]);
6507   operands[2] = GEN_INT (exact_log2 (x + 1));
6508   return \"depdi -1,%%sar,%2,%0\";
6510   [(set_attr "type" "shift")
6511    (set_attr "length" "4")])
6513 (define_insn ""
6514   [(set (match_operand:DI 0 "register_operand" "=r")
6515         (and:DI (rotate:DI (match_operand:DI 1 "const_int_operand" "")
6516                            (minus:DI (const_int 63)
6517                                      (match_operand:DI 2 "register_operand" "q")))
6518                 (match_operand:DI 3 "register_operand" "0")))]
6519   ; this can be generalized...!
6520   "TARGET_64BIT && INTVAL (operands[1]) == -2"
6521   "*
6523   HOST_WIDE_INT x = INTVAL (operands[1]);
6524   operands[2] = GEN_INT (exact_log2 ((~x) + 1));
6525   return \"depdi 0,%%sar,%2,%0\";
6527   [(set_attr "type" "shift")
6528    (set_attr "length" "4")])
6530 (define_expand "ashrsi3"
6531   [(set (match_operand:SI 0 "register_operand" "")
6532         (ashiftrt:SI (match_operand:SI 1 "register_operand" "")
6533                      (match_operand:SI 2 "arith32_operand" "")))]
6534   ""
6535   "
6537   if (GET_CODE (operands[2]) != CONST_INT)
6538     {
6539       rtx temp = gen_reg_rtx (SImode);
6540       emit_insn (gen_subsi3 (temp, GEN_INT (31), operands[2]));
6541       emit_insn (gen_vextrs32 (operands[0], operands[1], temp));
6542       DONE;
6543     }
6546 (define_insn ""
6547   [(set (match_operand:SI 0 "register_operand" "=r")
6548         (ashiftrt:SI (match_operand:SI 1 "register_operand" "r")
6549                      (match_operand:SI 2 "const_int_operand" "n")))]
6550   ""
6551   "{extrs|extrw,s} %1,%P2,%L2,%0"
6552   [(set_attr "type" "shift")
6553    (set_attr "length" "4")])
6555 (define_insn "vextrs32"
6556   [(set (match_operand:SI 0 "register_operand" "=r")
6557         (ashiftrt:SI (match_operand:SI 1 "register_operand" "r")
6558                      (minus:SI (const_int 31)
6559                                (match_operand:SI 2 "register_operand" "q"))))]
6560   ""
6561   "{vextrs %1,32,%0|extrw,s %1,%%sar,32,%0}"
6562   [(set_attr "type" "shift")
6563    (set_attr "length" "4")])
6565 (define_expand "ashrdi3"
6566   [(set (match_operand:DI 0 "register_operand" "")
6567         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
6568                      (match_operand:DI 2 "arith32_operand" "")))]
6569   "TARGET_64BIT"
6570   "
6572   if (GET_CODE (operands[2]) != CONST_INT)
6573     {
6574       rtx temp = gen_reg_rtx (DImode);
6575       emit_insn (gen_subdi3 (temp, GEN_INT (63), operands[2]));
6576       emit_insn (gen_vextrs64 (operands[0], operands[1], temp));
6577       DONE;
6578     }
6581 (define_insn ""
6582   [(set (match_operand:DI 0 "register_operand" "=r")
6583         (ashiftrt:DI (match_operand:DI 1 "register_operand" "r")
6584                      (match_operand:DI 2 "const_int_operand" "n")))]
6585   "TARGET_64BIT"
6586   "extrd,s %1,%p2,%Q2,%0"
6587   [(set_attr "type" "shift")
6588    (set_attr "length" "4")])
6590 (define_insn "vextrs64"
6591   [(set (match_operand:DI 0 "register_operand" "=r")
6592         (ashiftrt:DI (match_operand:DI 1 "register_operand" "r")
6593                      (minus:DI (const_int 63)
6594                                (match_operand:DI 2 "register_operand" "q"))))]
6595   "TARGET_64BIT"
6596   "extrd,s %1,%%sar,64,%0"
6597   [(set_attr "type" "shift")
6598    (set_attr "length" "4")])
6600 (define_insn "lshrsi3"
6601   [(set (match_operand:SI 0 "register_operand" "=r,r")
6602         (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
6603                      (match_operand:SI 2 "shift5_operand" "q,n")))]
6604   ""
6605   "@
6606    {vshd %%r0,%1,%0|shrpw %%r0,%1,%%sar,%0}
6607    {extru|extrw,u} %1,%P2,%L2,%0"
6608   [(set_attr "type" "shift")
6609    (set_attr "length" "4")])
6611 (define_insn "lshrdi3"
6612   [(set (match_operand:DI 0 "register_operand" "=r,r")
6613         (lshiftrt:DI (match_operand:DI 1 "register_operand" "r,r")
6614                      (match_operand:DI 2 "shift6_operand" "q,n")))]
6615   "TARGET_64BIT"
6616   "@
6617    shrpd %%r0,%1,%%sar,%0
6618    extrd,u %1,%p2,%Q2,%0"
6619   [(set_attr "type" "shift")
6620    (set_attr "length" "4")])
6622 ; Shift right pair word 0 to 31 bits.
6623 (define_insn "shrpsi4"
6624   [(set (match_operand:SI 0 "register_operand" "=r,r")
6625         (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "r,r")
6626                            (minus:SI (const_int 32)
6627                              (match_operand:SI 3 "shift5_operand" "q,n")))
6628                 (lshiftrt:SI (match_operand:SI 2 "register_operand" "r,r")
6629                              (match_dup 3))))]
6630   ""
6631   "@
6632    {vshd %1,%2,%0|shrpw %1,%2,%%sar,%0}
6633    {shd|shrpw} %1,%2,%3,%0"
6634   [(set_attr "type" "shift")
6635    (set_attr "length" "4")])
6637 ; Shift right pair doubleword 0 to 63 bits.
6638 (define_insn "shrpdi4"
6639   [(set (match_operand:DI 0 "register_operand" "=r,r")
6640         (ior:DI (ashift:DI (match_operand:SI 1 "register_operand" "r,r")
6641                            (minus:DI (const_int 64)
6642                              (match_operand:DI 3 "shift6_operand" "q,n")))
6643                 (lshiftrt:DI (match_operand:DI 2 "register_operand" "r,r")
6644                              (match_dup 3))))]
6645   "TARGET_64BIT"
6646   "@
6647    shrpd %1,%2,%%sar,%0
6648    shrpd %1,%2,%3,%0"
6649   [(set_attr "type" "shift")
6650    (set_attr "length" "4")])
6652 (define_insn "rotrsi3"
6653   [(set (match_operand:SI 0 "register_operand" "=r,r")
6654         (rotatert:SI (match_operand:SI 1 "register_operand" "r,r")
6655                      (match_operand:SI 2 "shift5_operand" "q,n")))]
6656   ""
6657   "*
6659   if (GET_CODE (operands[2]) == CONST_INT)
6660     {
6661       operands[2] = GEN_INT (INTVAL (operands[2]) & 31);
6662       return \"{shd|shrpw} %1,%1,%2,%0\";
6663     }
6664   else
6665     return \"{vshd %1,%1,%0|shrpw %1,%1,%%sar,%0}\";
6667   [(set_attr "type" "shift")
6668    (set_attr "length" "4")])
6670 (define_expand "rotlsi3"
6671   [(set (match_operand:SI 0 "register_operand" "")
6672         (rotate:SI (match_operand:SI 1 "register_operand" "")
6673                    (match_operand:SI 2 "arith32_operand" "")))]
6674   ""
6675   "
6677   if (GET_CODE (operands[2]) != CONST_INT)
6678     {
6679       rtx temp = gen_reg_rtx (SImode);
6680       emit_insn (gen_subsi3 (temp, GEN_INT (32), operands[2]));
6681       emit_insn (gen_rotrsi3 (operands[0], operands[1], temp));
6682       DONE;
6683     }
6684   /* Else expand normally.  */
6687 (define_insn ""
6688   [(set (match_operand:SI 0 "register_operand" "=r")
6689         (rotate:SI (match_operand:SI 1 "register_operand" "r")
6690                    (match_operand:SI 2 "const_int_operand" "n")))]
6691   ""
6692   "*
6694   operands[2] = GEN_INT ((32 - INTVAL (operands[2])) & 31);
6695   return \"{shd|shrpw} %1,%1,%2,%0\";
6697   [(set_attr "type" "shift")
6698    (set_attr "length" "4")])
6700 (define_insn ""
6701   [(set (match_operand:SI 0 "register_operand" "=r")
6702         (match_operator:SI 5 "plus_xor_ior_operator"
6703           [(ashift:SI (match_operand:SI 1 "register_operand" "r")
6704                       (match_operand:SI 3 "const_int_operand" "n"))
6705            (lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
6706                         (match_operand:SI 4 "const_int_operand" "n"))]))]
6707   "INTVAL (operands[3]) + INTVAL (operands[4]) == 32"
6708   "{shd|shrpw} %1,%2,%4,%0"
6709   [(set_attr "type" "shift")
6710    (set_attr "length" "4")])
6712 (define_insn ""
6713   [(set (match_operand:SI 0 "register_operand" "=r")
6714         (match_operator:SI 5 "plus_xor_ior_operator"
6715           [(lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
6716                         (match_operand:SI 4 "const_int_operand" "n"))
6717            (ashift:SI (match_operand:SI 1 "register_operand" "r")
6718                       (match_operand:SI 3 "const_int_operand" "n"))]))]
6719   "INTVAL (operands[3]) + INTVAL (operands[4]) == 32"
6720   "{shd|shrpw} %1,%2,%4,%0"
6721   [(set_attr "type" "shift")
6722    (set_attr "length" "4")])
6724 (define_insn ""
6725   [(set (match_operand:SI 0 "register_operand" "=r")
6726         (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
6727                            (match_operand:SI 2 "const_int_operand" ""))
6728                 (match_operand:SI 3 "const_int_operand" "")))]
6729   "exact_log2 (1 + (INTVAL (operands[3]) >> (INTVAL (operands[2]) & 31))) > 0"
6730   "*
6732   int cnt = INTVAL (operands[2]) & 31;
6733   operands[3] = GEN_INT (exact_log2 (1 + (INTVAL (operands[3]) >> cnt)));
6734   operands[2] = GEN_INT (31 - cnt);
6735   return \"{zdep|depw,z} %1,%2,%3,%0\";
6737   [(set_attr "type" "shift")
6738    (set_attr "length" "4")])
6740 ;; Unconditional and other jump instructions.
6742 ;; Trivial return used when no epilogue is needed.
6743 (define_insn "return"
6744   [(return)
6745    (use (reg:SI 2))]
6746   "pa_can_use_return_insn ()"
6747   "*
6749   if (TARGET_PA_20)
6750     return \"bve%* (%%r2)\";
6751   return \"bv%* %%r0(%%r2)\";
6753   [(set_attr "type" "branch")
6754    (set_attr "length" "4")])
6756 ;; This is used for most returns.
6757 (define_insn "return_internal"
6758   [(return)
6759    (use (reg:SI 2))]
6760   ""
6761   "*
6763   if (TARGET_PA_20)
6764     return \"bve%* (%%r2)\";
6765   return \"bv%* %%r0(%%r2)\";
6767   [(set_attr "type" "branch")
6768    (set_attr "length" "4")])
6770 ;; This is used for eh returns which bypass the return stub.
6771 (define_insn "return_external_pic"
6772   [(return)
6773    (clobber (reg:SI 1))
6774    (use (reg:SI 2))]
6775   "!TARGET_NO_SPACE_REGS
6776    && !TARGET_PA_20
6777    && flag_pic && crtl->calls_eh_return"
6778   "ldsid (%%sr0,%%r2),%%r1\;mtsp %%r1,%%sr0\;be%* 0(%%sr0,%%r2)"
6779   [(set_attr "type" "branch")
6780    (set_attr "length" "12")])
6782 (define_expand "prologue"
6783   [(const_int 0)]
6784   ""
6785   "pa_expand_prologue ();DONE;")
6787 (define_expand "sibcall_epilogue"
6788   [(return)]
6789   ""
6790   "
6792   pa_expand_epilogue ();
6793   DONE;
6796 (define_expand "epilogue"
6797   [(return)]
6798   ""
6799   "
6801   rtx x;
6803   /* Try to use the trivial return first.  Else use the full epilogue.  */
6804   if (pa_can_use_return_insn ())
6805     x = gen_return ();
6806   else
6807     {
6808       pa_expand_epilogue ();
6810       /* EH returns bypass the normal return stub.  Thus, we must do an
6811          interspace branch to return from functions that call eh_return.
6812          This is only a problem for returns from shared code on ports
6813          using space registers.  */
6814       if (!TARGET_NO_SPACE_REGS
6815           && !TARGET_PA_20
6816           && flag_pic && crtl->calls_eh_return)
6817         x = gen_return_external_pic ();
6818       else
6819         x = gen_return_internal ();
6820     }
6821   emit_jump_insn (x);
6822   DONE;
6825 ; Used by hppa_profile_hook to load the starting address of the current
6826 ; function; operand 1 contains the address of the label in operand 3
6827 (define_insn "load_offset_label_address"
6828   [(set (match_operand:SI 0 "register_operand" "=r")
6829         (plus:SI (match_operand:SI 1 "register_operand" "r")
6830                  (minus:SI (match_operand:SI 2 "" "")
6831                            (label_ref:SI (match_operand 3 "" "")))))]
6832   ""
6833   "ldo %2-%l3(%1),%0"
6834   [(set_attr "type" "multi")
6835    (set_attr "length" "4")])
6837 ; Output a code label and load its address.
6838 (define_insn "lcla1"
6839   [(set (match_operand:SI 0 "register_operand" "=r")
6840         (label_ref:SI (match_operand 1 "" "")))
6841    (const_int 0)]
6842   "!TARGET_PA_20"
6843   "*
6845   output_asm_insn (\"bl .+8,%0\;depi 0,31,2,%0\", operands);
6846   (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
6847                                      CODE_LABEL_NUMBER (operands[1]));
6848   return \"\";
6850   [(set_attr "type" "multi")
6851    (set_attr "length" "8")])
6853 (define_insn "lcla2"
6854   [(set (match_operand:SI 0 "register_operand" "=r")
6855         (label_ref:SI (match_operand 1 "" "")))
6856    (const_int 0)]
6857   "TARGET_PA_20"
6858   "*
6860   (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
6861                                      CODE_LABEL_NUMBER (operands[1]));
6862   return \"mfia %0\";
6864   [(set_attr "type" "move")
6865    (set_attr "length" "4")])
6867 (define_insn "blockage"
6868   [(unspec_volatile [(const_int 2)] UNSPECV_BLOCKAGE)]
6869   ""
6870   ""
6871   [(set_attr "length" "0")])
6873 (define_insn "jump"
6874   [(set (pc) (label_ref (match_operand 0 "" "")))]
6875   ""
6876   "*
6878   /* An unconditional branch which can reach its target.  */
6879   if (get_attr_length (insn) < 16)
6880     return \"b%* %l0\";
6882   return pa_output_lbranch (operands[0], insn, 1);
6884   [(set_attr "type" "uncond_branch")
6885    (set_attr "pa_combine_type" "uncond_branch")
6886    (set (attr "length")
6887     (cond [(match_test "pa_jump_in_call_delay (insn)")
6888            (if_then_else (lt (abs (minus (match_dup 0)
6889                                          (plus (pc) (const_int 8))))
6890                              (const_int MAX_12BIT_OFFSET))
6891            (const_int 4)
6892            (const_int 8))
6893            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
6894                (const_int MAX_17BIT_OFFSET))
6895            (const_int 4)
6896            (match_test "TARGET_PORTABLE_RUNTIME")
6897            (const_int 20)
6898            (not (match_test "flag_pic"))
6899            (const_int 16)]
6900           (const_int 24)))])
6902 ;;; Hope this is only within a function...
6903 (define_insn "indirect_jump"
6904   [(set (pc) (match_operand 0 "register_operand" "r"))]
6905   "GET_MODE (operands[0]) == word_mode"
6906   "bv%* %%r0(%0)"
6907   [(set_attr "type" "branch")
6908    (set_attr "length" "4")])
6910 ;;; An indirect jump can be optimized to a direct jump.  GAS for the
6911 ;;; SOM target doesn't allow branching to a label inside a function.
6912 ;;; We also don't correctly compute branch distances for labels
6913 ;;; outside the current function.  Thus, we use an indirect jump can't
6914 ;;; be optimized to a direct jump for all targets.  We assume that
6915 ;;; the branch target is in the same space (i.e., nested function
6916 ;;; jumping to a label in an outer function in the same translation
6917 ;;; unit).
6918 (define_expand "nonlocal_goto"
6919   [(use (match_operand 0 "general_operand" ""))
6920    (use (match_operand 1 "general_operand" ""))
6921    (use (match_operand 2 "general_operand" ""))
6922    (use (match_operand 3 "general_operand" ""))]
6923   ""
6925   rtx lab = operands[1];
6926   rtx stack = operands[2];
6927   rtx fp = operands[3];
6929   lab = copy_to_reg (lab);
6931   emit_clobber (gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (VOIDmode)));
6932   emit_clobber (gen_rtx_MEM (BLKmode, hard_frame_pointer_rtx));
6934   /* Restore the frame pointer.  The virtual_stack_vars_rtx is saved
6935      instead of the hard_frame_pointer_rtx in the save area.  As a
6936      result, an extra instruction is needed to adjust for the offset
6937      of the virtual stack variables and the hard frame pointer.  */
6938   if (GET_CODE (fp) != REG)
6939     fp = force_reg (Pmode, fp);
6940   emit_move_insn (hard_frame_pointer_rtx, plus_constant (Pmode, fp, -8));
6942   emit_stack_restore (SAVE_NONLOCAL, stack);
6944   emit_use (hard_frame_pointer_rtx);
6945   emit_use (stack_pointer_rtx);
6947   /* Nonlocal goto jumps are only used between functions in the same
6948      translation unit.  Thus, we can avoid the extra overhead of an
6949      interspace jump.  */
6950   emit_jump_insn (gen_indirect_goto (lab));
6951   emit_barrier ();
6952   DONE;
6955 (define_insn "indirect_goto"
6956   [(unspec [(match_operand 0 "register_operand" "=r")] UNSPEC_GOTO)]
6957   "GET_MODE (operands[0]) == word_mode"
6958   "bv%* %%r0(%0)"
6959   [(set_attr "type" "branch")
6960    (set_attr "length" "4")])
6962 ;; Subroutines of "casesi".
6963 ;; operand 0 is index
6964 ;; operand 1 is the minimum bound
6965 ;; operand 2 is the maximum bound - minimum bound + 1
6966 ;; operand 3 is CODE_LABEL for the table;
6967 ;; operand 4 is the CODE_LABEL to go to if index out of range.
6969 (define_expand "casesi"
6970   [(match_operand:SI 0 "general_operand" "")
6971    (match_operand:SI 1 "const_int_operand" "")
6972    (match_operand:SI 2 "const_int_operand" "")
6973    (match_operand 3 "" "")
6974    (match_operand 4 "" "")]
6975   ""
6976   "
6978   if (GET_CODE (operands[0]) != REG)
6979     operands[0] = force_reg (SImode, operands[0]);
6981   if (operands[1] != const0_rtx)
6982     {
6983       rtx index = gen_reg_rtx (SImode);
6985       operands[1] = gen_int_mode (-INTVAL (operands[1]), SImode);
6986       if (!INT_14_BITS (operands[1]))
6987         operands[1] = force_reg (SImode, operands[1]);
6988       emit_insn (gen_addsi3 (index, operands[0], operands[1]));
6989       operands[0] = index;
6990     }
6992   if (!INT_5_BITS (operands[2]))
6993     operands[2] = force_reg (SImode, operands[2]);
6995   /* This branch prevents us finding an insn for the delay slot of the
6996      following vectored branch.  It might be possible to use the delay
6997      slot if an index value of -1 was used to transfer to the out-of-range
6998      label.  In order to do this, we would have to output the -1 vector
6999      element after the delay insn.  The casesi output code would have to
7000      check if the casesi insn is in a delay branch sequence and output
7001      the delay insn if one is found.  If this was done, then it might
7002      then be worthwhile to split the casesi patterns to improve scheduling.
7003      However, it's not clear that all this extra complexity is worth
7004      the effort.  */
7005   {
7006     rtx test = gen_rtx_GTU (VOIDmode, operands[0], operands[2]);
7007     emit_jump_insn (gen_cbranchsi4 (test, operands[0], operands[2], operands[4]));
7008   }
7010   /* In 64bit mode we must make sure to wipe the upper bits of the register
7011      just in case the addition overflowed or we had random bits in the
7012      high part of the register.  */
7013   if (TARGET_64BIT)
7014     {
7015       rtx index = gen_reg_rtx (DImode);
7017       emit_insn (gen_extendsidi2 (index, operands[0]));
7018       operands[0] = index;
7019     }
7021   if (TARGET_64BIT)
7022     emit_jump_insn (gen_casesi64p (operands[0], operands[3]));
7023   else if (flag_pic)
7024     emit_jump_insn (gen_casesi32p (operands[0], operands[3]));
7025   else
7026     emit_jump_insn (gen_casesi32 (operands[0], operands[3]));
7027   DONE;
7030 ;;; 32-bit code, absolute branch table.
7031 (define_insn "casesi32"
7032   [(set (pc) (mem:SI (plus:SI
7033                        (mult:SI (match_operand:SI 0 "register_operand" "r")
7034                                 (const_int 4))
7035                        (label_ref (match_operand 1 "" "")))))
7036    (clobber (match_scratch:SI 2 "=&r"))]
7037   "!flag_pic"
7038   "ldil L'%l1,%2\;ldo R'%l1(%2),%2\;{ldwx|ldw},s %0(%2),%2\;bv,n %%r0(%2)"
7039   [(set_attr "type" "multi")
7040    (set_attr "length" "16")])
7042 ;;; 32-bit code, relative branch table.
7043 (define_insn "casesi32p"
7044   [(set (pc) (mem:SI (plus:SI
7045                        (mult:SI (match_operand:SI 0 "register_operand" "r")
7046                                 (const_int 4))
7047                        (label_ref (match_operand 1 "" "")))))
7048    (clobber (match_scratch:SI 2 "=&r"))
7049    (clobber (match_scratch:SI 3 "=&r"))]
7050   "flag_pic"
7051   "{bl .+8,%2\;depi 0,31,2,%2|mfia %2}\;ldo {%l1-.|%l1+4-.}(%2),%2\;\
7052 {ldwx|ldw},s %0(%2),%3\;{addl|add,l} %2,%3,%3\;bv,n %%r0(%3)"
7053   [(set_attr "type" "multi")
7054    (set (attr "length")
7055      (if_then_else (match_test "TARGET_PA_20")
7056         (const_int 20)
7057         (const_int 24)))])
7059 ;;; 64-bit code, 32-bit relative branch table.
7060 (define_insn "casesi64p"
7061   [(set (pc) (mem:DI (plus:DI
7062                        (mult:DI (match_operand:DI 0 "register_operand" "r")
7063                                 (const_int 8))
7064                        (label_ref (match_operand 1 "" "")))))
7065    (clobber (match_scratch:DI 2 "=&r"))
7066    (clobber (match_scratch:DI 3 "=&r"))]
7067   ""
7068   "mfia %2\;ldo %l1+4-.(%2),%2\;ldw,s %0(%2),%3\;extrd,s %3,63,32,%3\;\
7069 add,l %2,%3,%3\;bv,n %%r0(%3)"
7070   [(set_attr "type" "multi")
7071    (set_attr "length" "24")])
7074 ;; Call patterns.
7075 ;;- jump to subroutine
7077 (define_expand "call"
7078   [(parallel [(call (match_operand:SI 0 "" "")
7079                     (match_operand 1 "" ""))
7080               (clobber (reg:SI 2))])]
7081   ""
7082   "
7084   rtx op;
7085   rtx nb = operands[1];
7087   if (TARGET_PORTABLE_RUNTIME)
7088     op = force_reg (SImode, XEXP (operands[0], 0));
7089   else
7090     {
7091       op = XEXP (operands[0], 0);
7093       /* Generate indirect long calls to non-local functions. */
7094       if (!TARGET_64BIT && TARGET_LONG_CALLS && GET_CODE (op) == SYMBOL_REF)
7095         {
7096           tree call_decl = SYMBOL_REF_DECL (op);
7097           if (!(call_decl && targetm.binds_local_p (call_decl)))
7098             op = force_reg (word_mode, op);
7099         }
7100     }
7102   if (TARGET_64BIT)
7103     {
7104       if (!virtuals_instantiated)
7105         emit_move_insn (arg_pointer_rtx,
7106                         gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
7107                                       GEN_INT (64)));
7108       else
7109         {
7110           /* The loop pass can generate new libcalls after the virtual
7111              registers are instantiated when fpregs are disabled because
7112              the only method that we have for doing DImode multiplication
7113              is with a libcall.  This could be trouble if we haven't
7114              allocated enough space for the outgoing arguments.  */
7115           gcc_assert (INTVAL (nb) <= crtl->outgoing_args_size);
7117           emit_move_insn (arg_pointer_rtx,
7118                           gen_rtx_PLUS (word_mode, stack_pointer_rtx,
7119                                         GEN_INT (STACK_POINTER_OFFSET + 64)));
7120         }
7121     }
7123   /* Use two different patterns for calls to explicitly named functions
7124      and calls through function pointers.  This is necessary as these two
7125      types of calls use different calling conventions, and CSE might try
7126      to change the named call into an indirect call in some cases (using
7127      two patterns keeps CSE from performing this optimization).
7128      
7129      We now use even more call patterns as there was a subtle bug in
7130      attempting to restore the pic register after a call using a simple
7131      move insn.  During reload, a instruction involving a pseudo register
7132      with no explicit dependence on the PIC register can be converted
7133      to an equivalent load from memory using the PIC register.  If we
7134      emit a simple move to restore the PIC register in the initial rtl
7135      generation, then it can potentially be repositioned during scheduling.
7136      and an instruction that eventually uses the PIC register may end up
7137      between the call and the PIC register restore.
7138      
7139      This only worked because there is a post call group of instructions
7140      that are scheduled with the call.  These instructions are included
7141      in the same basic block as the call.  However, calls can throw in
7142      C++ code and a basic block has to terminate at the call if the call
7143      can throw.  This results in the PIC register restore being scheduled
7144      independently from the call.  So, we now hide the save and restore
7145      of the PIC register in the call pattern until after reload.  Then,
7146      we split the moves out.  A small side benefit is that we now don't
7147      need to have a use of the PIC register in the return pattern and
7148      the final save/restore operation is not needed.
7149      
7150      I elected to just use register %r4 in the PIC patterns instead
7151      of trying to force hppa_pic_save_rtx () to a callee saved register.
7152      This might have required a new register class and constraint.  It
7153      was also simpler to just handle the restore from a register than a
7154      generic pseudo.  */
7155   if (TARGET_64BIT)
7156     {
7157       rtx r4 = gen_rtx_REG (word_mode, 4);
7158       if (GET_CODE (op) == SYMBOL_REF)
7159         emit_call_insn (gen_call_symref_64bit (op, nb, r4));
7160       else
7161         {
7162           op = force_reg (word_mode, op);
7163           emit_call_insn (gen_call_reg_64bit (op, nb, r4));
7164         }
7165     }
7166   else
7167     {
7168       if (GET_CODE (op) == SYMBOL_REF)
7169         {
7170           if (flag_pic)
7171             {
7172               rtx r4 = gen_rtx_REG (word_mode, 4);
7173               emit_call_insn (gen_call_symref_pic (op, nb, r4));
7174             }
7175           else
7176             emit_call_insn (gen_call_symref (op, nb));
7177         }
7178       else
7179         {
7180           rtx tmpreg = gen_rtx_REG (word_mode, 22);
7181           emit_move_insn (tmpreg, force_reg (word_mode, op));
7182           if (flag_pic)
7183             {
7184               rtx r4 = gen_rtx_REG (word_mode, 4);
7185               emit_call_insn (gen_call_reg_pic (nb, r4));
7186             }
7187           else
7188             emit_call_insn (gen_call_reg (nb));
7189         }
7190     }
7192   DONE;
7195 ;; We use function calls to set the attribute length of calls and millicode
7196 ;; calls.  This is necessary because of the large variety of call sequences.
7197 ;; Implementing the calculation in rtl is difficult as well as ugly.  As
7198 ;; we need the same calculation in several places, maintenance becomes a
7199 ;; nightmare.
7201 ;; However, this has a subtle impact on branch shortening.  When the
7202 ;; expression used to set the length attribute of an instruction depends
7203 ;; on a relative address (e.g., pc or a branch address), genattrtab
7204 ;; notes that the insn's length is variable, and attempts to determine a
7205 ;; worst-case default length and code to compute an insn's current length.
7207 ;; The use of a function call hides the variable dependence of our calls
7208 ;; and millicode calls.  The result is genattrtab doesn't treat the operation
7209 ;; as variable and it only generates code for the default case using our
7210 ;; function call.  Because of this, calls and millicode calls have a fixed
7211 ;; length in the branch shortening pass, and some branches will use a longer
7212 ;; code sequence than necessary.  However, the length of any given call
7213 ;; will still reflect its final code location and it may be shorter than
7214 ;; the initial length estimate.
7216 ;; It's possible to trick genattrtab by adding an expression involving `pc'
7217 ;; in the set.  However, when genattrtab hits a function call in its attempt
7218 ;; to compute the default length, it marks the result as unknown and sets
7219 ;; the default result to MAX_INT ;-(  One possible fix that would allow
7220 ;; calls to participate in branch shortening would be to make the call to
7221 ;; insn_default_length a target option.  Then, we could massage unknown
7222 ;; results.  Another fix might be to change genattrtab so that it just does
7223 ;; the call in the variable case as it already does for the fixed case.
7225 (define_insn "call_symref"
7226   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7227          (match_operand 1 "" "i"))
7228    (clobber (reg:SI 1))
7229    (clobber (reg:SI 2))
7230    (use (const_int 0))]
7231   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7232   "*
7234   pa_output_arg_descriptor (insn);
7235   return pa_output_call (insn, operands[0], 0);
7237   [(set_attr "type" "call")
7238    (set (attr "length")
7239         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7240               (symbol_ref "pa_attr_length_call (insn, 0)")))])
7242 (define_insn "call_symref_pic"
7243   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7244          (match_operand 1 "" "i"))
7245    (clobber (reg:SI 1))
7246    (clobber (reg:SI 2))
7247    (clobber (match_operand 2))
7248    (use (reg:SI 19))
7249    (use (const_int 0))]
7250   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7251   "#")
7253 ;; Split out the PIC register save and restore after reload.  As the
7254 ;; split is done after reload, there are some situations in which we
7255 ;; unnecessarily save and restore %r4.  This happens when there is a
7256 ;; single call and the PIC register is not used after the call.
7258 ;; The split has to be done since call_from_call_insn () can't handle
7259 ;; the pattern as is.  Noreturn calls are special because they have to
7260 ;; terminate the basic block.  The split has to contain more than one
7261 ;; insn.
7262 (define_split
7263   [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7264                     (match_operand 1 "" ""))
7265               (clobber (reg:SI 1))
7266               (clobber (reg:SI 2))
7267               (clobber (match_operand 2))
7268               (use (reg:SI 19))
7269               (use (const_int 0))])]
7270   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed
7271    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7272   [(set (match_dup 2) (reg:SI 19))
7273    (parallel [(call (mem:SI (match_dup 0))
7274                     (match_dup 1))
7275               (clobber (reg:SI 1))
7276               (clobber (reg:SI 2))
7277               (use (reg:SI 19))
7278               (use (const_int 0))])]
7279   "")
7281 (define_split
7282   [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7283                     (match_operand 1 "" ""))
7284               (clobber (reg:SI 1))
7285               (clobber (reg:SI 2))
7286               (clobber (match_operand 2))
7287               (use (reg:SI 19))
7288               (use (const_int 0))])]
7289   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
7290   [(set (match_dup 2) (reg:SI 19))
7291    (parallel [(call (mem:SI (match_dup 0))
7292                     (match_dup 1))
7293               (clobber (reg:SI 1))
7294               (clobber (reg:SI 2))
7295               (use (reg:SI 19))
7296               (use (const_int 0))])
7297    (set (reg:SI 19) (match_dup 2))]
7298   "")
7300 (define_insn "*call_symref_pic_post_reload"
7301   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7302          (match_operand 1 "" "i"))
7303    (clobber (reg:SI 1))
7304    (clobber (reg:SI 2))
7305    (use (reg:SI 19))
7306    (use (const_int 0))]
7307   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7308   "*
7310   pa_output_arg_descriptor (insn);
7311   return pa_output_call (insn, operands[0], 0);
7313   [(set_attr "type" "call")
7314    (set (attr "length")
7315         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7316               (symbol_ref "pa_attr_length_call (insn, 0)")))])
7318 ;; This pattern is split if it is necessary to save and restore the
7319 ;; PIC register.
7320 (define_insn "call_symref_64bit"
7321   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7322          (match_operand 1 "" "i"))
7323    (clobber (reg:DI 1))
7324    (clobber (reg:DI 2))
7325    (clobber (match_operand 2))
7326    (use (reg:DI 27))
7327    (use (reg:DI 29))
7328    (use (const_int 0))]
7329   "TARGET_64BIT"
7330   "#")
7332 ;; Split out the PIC register save and restore after reload.  As the
7333 ;; split is done after reload, there are some situations in which we
7334 ;; unnecessarily save and restore %r4.  This happens when there is a
7335 ;; single call and the PIC register is not used after the call.
7337 ;; The split has to be done since call_from_call_insn () can't handle
7338 ;; the pattern as is.  Noreturn calls are special because they have to
7339 ;; terminate the basic block.  The split has to contain more than one
7340 ;; insn.
7341 (define_split
7342   [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7343                     (match_operand 1 "" ""))
7344               (clobber (reg:DI 1))
7345               (clobber (reg:DI 2))
7346               (clobber (match_operand 2))
7347               (use (reg:DI 27))
7348               (use (reg:DI 29))
7349               (use (const_int 0))])]
7350   "TARGET_64BIT && reload_completed
7351    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7352   [(set (match_dup 2) (reg:DI 27))
7353    (parallel [(call (mem:SI (match_dup 0))
7354                     (match_dup 1))
7355               (clobber (reg:DI 1))
7356               (clobber (reg:DI 2))
7357               (use (reg:DI 27))
7358               (use (reg:DI 29))
7359               (use (const_int 0))])]
7360   "")
7362 (define_split
7363   [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7364                     (match_operand 1 "" ""))
7365               (clobber (reg:DI 1))
7366               (clobber (reg:DI 2))
7367               (clobber (match_operand 2))
7368               (use (reg:DI 27))
7369               (use (reg:DI 29))
7370               (use (const_int 0))])]
7371   "TARGET_64BIT && reload_completed"
7372   [(set (match_dup 2) (reg:DI 27))
7373    (parallel [(call (mem:SI (match_dup 0))
7374                     (match_dup 1))
7375               (clobber (reg:DI 1))
7376               (clobber (reg:DI 2))
7377               (use (reg:DI 27))
7378               (use (reg:DI 29))
7379               (use (const_int 0))])
7380    (set (reg:DI 27) (match_dup 2))]
7381   "")
7383 (define_insn "*call_symref_64bit_post_reload"
7384   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7385          (match_operand 1 "" "i"))
7386    (clobber (reg:DI 1))
7387    (clobber (reg:DI 2))
7388    (use (reg:DI 27))
7389    (use (reg:DI 29))
7390    (use (const_int 0))]
7391   "TARGET_64BIT"
7392   "*
7394   pa_output_arg_descriptor (insn);
7395   return pa_output_call (insn, operands[0], 0);
7397   [(set_attr "type" "call")
7398    (set (attr "length")
7399         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7400               (symbol_ref "pa_attr_length_call (insn, 0)")))])
7402 (define_insn "call_reg"
7403   [(call (mem:SI (reg:SI 22))
7404          (match_operand 0 "" "i"))
7405    (clobber (reg:SI 1))
7406    (clobber (reg:SI 2))
7407    (use (const_int 1))]
7408   "!TARGET_64BIT"
7409   "*
7411   return pa_output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
7413   [(set_attr "type" "dyncall")
7414    (set (attr "length")
7415         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7416               (symbol_ref "pa_attr_length_indirect_call (insn)")))])
7418 ;; This pattern is split if it is necessary to save and restore the
7419 ;; PIC register.
7420 (define_insn "call_reg_pic"
7421   [(call (mem:SI (reg:SI 22))
7422          (match_operand 0 "" "i"))
7423    (clobber (reg:SI 1))
7424    (clobber (reg:SI 2))
7425    (clobber (match_operand 1))
7426    (use (reg:SI 19))
7427    (use (const_int 1))]
7428   "!TARGET_64BIT"
7429   "#")
7431 ;; Split out the PIC register save and restore after reload.  As the
7432 ;; split is done after reload, there are some situations in which we
7433 ;; unnecessarily save and restore %r4.  This happens when there is a
7434 ;; single call and the PIC register is not used after the call.
7436 ;; The split has to be done since call_from_call_insn () can't handle
7437 ;; the pattern as is.  Noreturn calls are special because they have to
7438 ;; terminate the basic block.  The split has to contain more than one
7439 ;; insn.
7440 (define_split
7441   [(parallel [(call (mem:SI (reg:SI 22))
7442                     (match_operand 0 "" ""))
7443               (clobber (reg:SI 1))
7444               (clobber (reg:SI 2))
7445               (clobber (match_operand 1))
7446               (use (reg:SI 19))
7447               (use (const_int 1))])]
7448   "!TARGET_64BIT && reload_completed
7449    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7450   [(set (match_dup 1) (reg:SI 19))
7451    (parallel [(call (mem:SI (reg:SI 22))
7452                     (match_dup 0))
7453               (clobber (reg:SI 1))
7454               (clobber (reg:SI 2))
7455               (use (reg:SI 19))
7456               (use (const_int 1))])]
7457   "")
7459 (define_split
7460   [(parallel [(call (mem:SI (reg:SI 22))
7461                     (match_operand 0 "" ""))
7462               (clobber (reg:SI 1))
7463               (clobber (reg:SI 2))
7464               (clobber (match_operand 1))
7465               (use (reg:SI 19))
7466               (use (const_int 1))])]
7467   "!TARGET_64BIT && reload_completed"
7468   [(set (match_dup 1) (reg:SI 19))
7469    (parallel [(call (mem:SI (reg:SI 22))
7470                     (match_dup 0))
7471               (clobber (reg:SI 1))
7472               (clobber (reg:SI 2))
7473               (use (reg:SI 19))
7474               (use (const_int 1))])
7475    (set (reg:SI 19) (match_dup 1))]
7476   "")
7478 (define_insn "*call_reg_pic_post_reload"
7479   [(call (mem:SI (reg:SI 22))
7480          (match_operand 0 "" "i"))
7481    (clobber (reg:SI 1))
7482    (clobber (reg:SI 2))
7483    (use (reg:SI 19))
7484    (use (const_int 1))]
7485   "!TARGET_64BIT"
7486   "*
7488   return pa_output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
7490   [(set_attr "type" "dyncall")
7491    (set (attr "length")
7492         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7493               (symbol_ref "pa_attr_length_indirect_call (insn)")))])
7495 ;; This pattern is split if it is necessary to save and restore the
7496 ;; PIC register.
7497 (define_insn "call_reg_64bit"
7498   [(call (mem:SI (match_operand:DI 0 "register_operand" "r"))
7499          (match_operand 1 "" "i"))
7500    (clobber (reg:DI 1))
7501    (clobber (reg:DI 2))
7502    (clobber (match_operand 2))
7503    (use (reg:DI 27))
7504    (use (reg:DI 29))
7505    (use (const_int 1))]
7506   "TARGET_64BIT"
7507   "#")
7509 ;; Split out the PIC register save and restore after reload.  As the
7510 ;; split is done after reload, there are some situations in which we
7511 ;; unnecessarily save and restore %r4.  This happens when there is a
7512 ;; single call and the PIC register is not used after the call.
7514 ;; The split has to be done since call_from_call_insn () can't handle
7515 ;; the pattern as is.  Noreturn calls are special because they have to
7516 ;; terminate the basic block.  The split has to contain more than one
7517 ;; insn.
7518 (define_split
7519   [(parallel [(call (mem:SI (match_operand 0 "register_operand" ""))
7520                     (match_operand 1 "" ""))
7521               (clobber (reg:DI 1))
7522               (clobber (reg:DI 2))
7523               (clobber (match_operand 2))
7524               (use (reg:DI 27))
7525               (use (reg:DI 29))
7526               (use (const_int 1))])]
7527   "TARGET_64BIT && reload_completed
7528    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7529   [(set (match_dup 2) (reg:DI 27))
7530    (parallel [(call (mem:SI (match_dup 0))
7531                     (match_dup 1))
7532               (clobber (reg:DI 1))
7533               (clobber (reg:DI 2))
7534               (use (reg:DI 27))
7535               (use (reg:DI 29))
7536               (use (const_int 1))])]
7537   "")
7539 (define_split
7540   [(parallel [(call (mem:SI (match_operand 0 "register_operand" ""))
7541                     (match_operand 1 "" ""))
7542               (clobber (reg:DI 1))
7543               (clobber (reg:DI 2))
7544               (clobber (match_operand 2))
7545               (use (reg:DI 27))
7546               (use (reg:DI 29))
7547               (use (const_int 1))])]
7548   "TARGET_64BIT && reload_completed"
7549   [(set (match_dup 2) (reg:DI 27))
7550    (parallel [(call (mem:SI (match_dup 0))
7551                     (match_dup 1))
7552               (clobber (reg:DI 1))
7553               (clobber (reg:DI 2))
7554               (use (reg:DI 27))
7555               (use (reg:DI 29))
7556               (use (const_int 1))])
7557    (set (reg:DI 27) (match_dup 2))]
7558   "")
7560 (define_insn "*call_reg_64bit_post_reload"
7561   [(call (mem:SI (match_operand:DI 0 "register_operand" "r"))
7562          (match_operand 1 "" "i"))
7563    (clobber (reg:DI 1))
7564    (clobber (reg:DI 2))
7565    (use (reg:DI 27))
7566    (use (reg:DI 29))
7567    (use (const_int 1))]
7568   "TARGET_64BIT"
7569   "*
7571   return pa_output_indirect_call (insn, operands[0]);
7573   [(set_attr "type" "dyncall")
7574    (set (attr "length")
7575         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 12)]
7576               (symbol_ref "pa_attr_length_indirect_call (insn)")))])
7578 (define_expand "call_value"
7579   [(parallel [(set (match_operand 0 "" "")
7580                    (call (match_operand:SI 1 "" "")
7581                          (match_operand 2 "" "")))
7582               (clobber (reg:SI 2))])]
7583   ""
7585   rtx op;
7586   rtx dst = operands[0];
7587   rtx nb = operands[2];
7588   bool call_powf = false;
7590   if (TARGET_PORTABLE_RUNTIME)
7591     op = force_reg (SImode, XEXP (operands[1], 0));
7592   else
7593     {
7594       op = XEXP (operands[1], 0);
7595       if (GET_CODE (op) == SYMBOL_REF)
7596         {
7597           /* Handle special call to buggy powf function.  */
7598           if (TARGET_HPUX && !TARGET_DISABLE_FPREGS && !TARGET_SOFT_FLOAT
7599               && !strcmp (targetm.strip_name_encoding (XSTR (op, 0)), "powf"))
7600             call_powf = true;
7602           /* Generate indirect long calls to non-local functions. */
7603           else if (!TARGET_64BIT && TARGET_LONG_CALLS)
7604             {
7605               tree call_decl = SYMBOL_REF_DECL (op);
7606               if (!(call_decl && targetm.binds_local_p (call_decl)))
7607                 op = force_reg (word_mode, op);
7608             }
7609         }
7610     }
7612   if (TARGET_64BIT)
7613     {
7614       if (!virtuals_instantiated)
7615         emit_move_insn (arg_pointer_rtx,
7616                         gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
7617                                       GEN_INT (64)));
7618       else
7619         {
7620           /* The loop pass can generate new libcalls after the virtual
7621              registers are instantiated when fpregs are disabled because
7622              the only method that we have for doing DImode multiplication
7623              is with a libcall.  This could be trouble if we haven't
7624              allocated enough space for the outgoing arguments.  */
7625           gcc_assert (INTVAL (nb) <= crtl->outgoing_args_size);
7627           emit_move_insn (arg_pointer_rtx,
7628                           gen_rtx_PLUS (word_mode, stack_pointer_rtx,
7629                                         GEN_INT (STACK_POINTER_OFFSET + 64)));
7630         }
7631     }
7633   /* Use two different patterns for calls to explicitly named functions
7634      and calls through function pointers.  This is necessary as these two
7635      types of calls use different calling conventions, and CSE might try
7636      to change the named call into an indirect call in some cases (using
7637      two patterns keeps CSE from performing this optimization).
7639      We now use even more call patterns as there was a subtle bug in
7640      attempting to restore the pic register after a call using a simple
7641      move insn.  During reload, a instruction involving a pseudo register
7642      with no explicit dependence on the PIC register can be converted
7643      to an equivalent load from memory using the PIC register.  If we
7644      emit a simple move to restore the PIC register in the initial rtl
7645      generation, then it can potentially be repositioned during scheduling.
7646      and an instruction that eventually uses the PIC register may end up
7647      between the call and the PIC register restore.
7648      
7649      This only worked because there is a post call group of instructions
7650      that are scheduled with the call.  These instructions are included
7651      in the same basic block as the call.  However, calls can throw in
7652      C++ code and a basic block has to terminate at the call if the call
7653      can throw.  This results in the PIC register restore being scheduled
7654      independently from the call.  So, we now hide the save and restore
7655      of the PIC register in the call pattern until after reload.  Then,
7656      we split the moves out.  A small side benefit is that we now don't
7657      need to have a use of the PIC register in the return pattern and
7658      the final save/restore operation is not needed.
7659      
7660      I elected to just use register %r4 in the PIC patterns instead
7661      of trying to force hppa_pic_save_rtx () to a callee saved register.
7662      This might have required a new register class and constraint.  It
7663      was also simpler to just handle the restore from a register than a
7664      generic pseudo.  */
7665   if (TARGET_64BIT)
7666     {
7667       rtx r4 = gen_rtx_REG (word_mode, 4);
7668       if (GET_CODE (op) == SYMBOL_REF)
7669         {
7670           if (call_powf)
7671             emit_call_insn (gen_call_val_powf_64bit (dst, op, nb, r4));
7672           else
7673             emit_call_insn (gen_call_val_symref_64bit (dst, op, nb, r4));
7674         }
7675       else
7676         {
7677           op = force_reg (word_mode, op);
7678           emit_call_insn (gen_call_val_reg_64bit (dst, op, nb, r4));
7679         }
7680     }
7681   else
7682     {
7683       if (GET_CODE (op) == SYMBOL_REF)
7684         {
7685           if (flag_pic)
7686             {
7687               rtx r4 = gen_rtx_REG (word_mode, 4);
7689               if (call_powf)
7690                 emit_call_insn (gen_call_val_powf_pic (dst, op, nb, r4));
7691               else
7692                 emit_call_insn (gen_call_val_symref_pic (dst, op, nb, r4));
7693             }
7694           else
7695             {
7696               if (call_powf)
7697                 emit_call_insn (gen_call_val_powf (dst, op, nb));
7698               else
7699                 emit_call_insn (gen_call_val_symref (dst, op, nb));
7700             }
7701         }
7702       else
7703         {
7704           rtx tmpreg = gen_rtx_REG (word_mode, 22);
7705           emit_move_insn (tmpreg, force_reg (word_mode, op));
7706           if (flag_pic)
7707             {
7708               rtx r4 = gen_rtx_REG (word_mode, 4);
7709               emit_call_insn (gen_call_val_reg_pic (dst, nb, r4));
7710             }
7711           else
7712             emit_call_insn (gen_call_val_reg (dst, nb));
7713         }
7714     }
7716   DONE;
7719 (define_insn "call_val_symref"
7720   [(set (match_operand 0 "" "")
7721         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7722               (match_operand 2 "" "i")))
7723    (clobber (reg:SI 1))
7724    (clobber (reg:SI 2))
7725    (use (const_int 0))]
7726   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7727   "*
7729   pa_output_arg_descriptor (insn);
7730   return pa_output_call (insn, operands[1], 0);
7732   [(set_attr "type" "call")
7733    (set (attr "length")
7734         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7735               (symbol_ref "pa_attr_length_call (insn, 0)")))])
7737 ;; powf function clobbers %fr12
7738 (define_insn "call_val_powf"
7739   [(set (match_operand 0 "" "")
7740         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7741               (match_operand 2 "" "i")))
7742    (clobber (reg:SI 1))
7743    (clobber (reg:SI 2))
7744    (clobber (reg:DF 48))
7745    (use (const_int 1))]
7746   "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7747   "*
7749   pa_output_arg_descriptor (insn);
7750   return pa_output_call (insn, operands[1], 0);
7752   [(set_attr "type" "call")
7753    (set (attr "length")
7754         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7755               (symbol_ref "pa_attr_length_call (insn, 0)")))])
7757 (define_insn "call_val_symref_pic"
7758   [(set (match_operand 0 "" "")
7759         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7760               (match_operand 2 "" "i")))
7761    (clobber (reg:SI 1))
7762    (clobber (reg:SI 2))
7763    (clobber (match_operand 3))
7764    (use (reg:SI 19))
7765    (use (const_int 0))]
7766   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7767   "#")
7769 ;; Split out the PIC register save and restore after reload.  As the
7770 ;; split is done after reload, there are some situations in which we
7771 ;; unnecessarily save and restore %r4.  This happens when there is a
7772 ;; single call and the PIC register is not used after the call.
7774 ;; The split has to be done since call_from_call_insn () can't handle
7775 ;; the pattern as is.  Noreturn calls are special because they have to
7776 ;; terminate the basic block.  The split has to contain more than one
7777 ;; insn.
7778 (define_split
7779   [(parallel [(set (match_operand 0 "" "")
7780               (call (mem:SI (match_operand 1 "call_operand_address" ""))
7781                     (match_operand 2 "" "")))
7782               (clobber (reg:SI 1))
7783               (clobber (reg:SI 2))
7784               (clobber (match_operand 3))
7785               (use (reg:SI 19))
7786               (use (const_int 0))])]
7787   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed
7788    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7789   [(set (match_dup 3) (reg:SI 19))
7790    (parallel [(set (match_dup 0)
7791               (call (mem:SI (match_dup 1))
7792                     (match_dup 2)))
7793               (clobber (reg:SI 1))
7794               (clobber (reg:SI 2))
7795               (use (reg:SI 19))
7796               (use (const_int 0))])]
7797   "")
7799 (define_split
7800   [(parallel [(set (match_operand 0 "" "")
7801               (call (mem:SI (match_operand 1 "call_operand_address" ""))
7802                     (match_operand 2 "" "")))
7803               (clobber (reg:SI 1))
7804               (clobber (reg:SI 2))
7805               (clobber (match_operand 3))
7806               (use (reg:SI 19))
7807               (use (const_int 0))])]
7808   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
7809   [(set (match_dup 3) (reg:SI 19))
7810    (parallel [(set (match_dup 0)
7811               (call (mem:SI (match_dup 1))
7812                     (match_dup 2)))
7813               (clobber (reg:SI 1))
7814               (clobber (reg:SI 2))
7815               (use (reg:SI 19))
7816               (use (const_int 0))])
7817    (set (reg:SI 19) (match_dup 3))]
7818   "")
7820 (define_insn "*call_val_symref_pic_post_reload"
7821   [(set (match_operand 0 "" "")
7822         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7823               (match_operand 2 "" "i")))
7824    (clobber (reg:SI 1))
7825    (clobber (reg:SI 2))
7826    (use (reg:SI 19))
7827    (use (const_int 0))]
7828   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7829   "*
7831   pa_output_arg_descriptor (insn);
7832   return pa_output_call (insn, operands[1], 0);
7834   [(set_attr "type" "call")
7835    (set (attr "length")
7836         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7837               (symbol_ref "pa_attr_length_call (insn, 0)")))])
7839 ;; powf function clobbers %fr12
7840 (define_insn "call_val_powf_pic"
7841   [(set (match_operand 0 "" "")
7842         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7843               (match_operand 2 "" "i")))
7844    (clobber (reg:SI 1))
7845    (clobber (reg:SI 2))
7846    (clobber (reg:DF 48))
7847    (clobber (match_operand 3))
7848    (use (reg:SI 19))
7849    (use (const_int 1))]
7850   "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7851   "#")
7853 ;; Split out the PIC register save and restore after reload.  As the
7854 ;; split is done after reload, there are some situations in which we
7855 ;; unnecessarily save and restore %r4.  This happens when there is a
7856 ;; single call and the PIC register is not used after the call.
7858 ;; The split has to be done since call_from_call_insn () can't handle
7859 ;; the pattern as is.  Noreturn calls are special because they have to
7860 ;; terminate the basic block.  The split has to contain more than one
7861 ;; insn.
7862 (define_split
7863   [(parallel [(set (match_operand 0 "" "")
7864               (call (mem:SI (match_operand 1 "call_operand_address" ""))
7865                     (match_operand 2 "" "")))
7866               (clobber (reg:SI 1))
7867               (clobber (reg:SI 2))
7868               (clobber (reg:DF 48))
7869               (clobber (match_operand 3))
7870               (use (reg:SI 19))
7871               (use (const_int 1))])]
7872   "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed
7873    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7874   [(set (match_dup 3) (reg:SI 19))
7875    (parallel [(set (match_dup 0)
7876               (call (mem:SI (match_dup 1))
7877                     (match_dup 2)))
7878               (clobber (reg:SI 1))
7879               (clobber (reg:SI 2))
7880               (clobber (reg:DF 48))
7881               (use (reg:SI 19))
7882               (use (const_int 1))])]
7883   "")
7885 (define_split
7886   [(parallel [(set (match_operand 0 "" "")
7887               (call (mem:SI (match_operand 1 "call_operand_address" ""))
7888                     (match_operand 2 "" "")))
7889               (clobber (reg:SI 1))
7890               (clobber (reg:SI 2))
7891               (clobber (reg:DF 48))
7892               (clobber (match_operand 3))
7893               (use (reg:SI 19))
7894               (use (const_int 1))])]
7895   "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
7896   [(set (match_dup 3) (reg:SI 19))
7897    (parallel [(set (match_dup 0)
7898               (call (mem:SI (match_dup 1))
7899                     (match_dup 2)))
7900               (clobber (reg:SI 1))
7901               (clobber (reg:SI 2))
7902               (clobber (reg:DF 48))
7903               (use (reg:SI 19))
7904               (use (const_int 1))])
7905    (set (reg:SI 19) (match_dup 3))]
7906   "")
7908 (define_insn "*call_val_powf_pic_post_reload"
7909   [(set (match_operand 0 "" "")
7910         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7911               (match_operand 2 "" "i")))
7912    (clobber (reg:SI 1))
7913    (clobber (reg:SI 2))
7914    (clobber (reg:DF 48))
7915    (use (reg:SI 19))
7916    (use (const_int 1))]
7917   "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7918   "*
7920   pa_output_arg_descriptor (insn);
7921   return pa_output_call (insn, operands[1], 0);
7923   [(set_attr "type" "call")
7924    (set (attr "length")
7925         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7926               (symbol_ref "pa_attr_length_call (insn, 0)")))])
7928 ;; This pattern is split if it is necessary to save and restore the
7929 ;; PIC register.
7930 (define_insn "call_val_symref_64bit"
7931   [(set (match_operand 0 "" "")
7932         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7933               (match_operand 2 "" "i")))
7934    (clobber (reg:DI 1))
7935    (clobber (reg:DI 2))
7936    (clobber (match_operand 3))
7937    (use (reg:DI 27))
7938    (use (reg:DI 29))
7939    (use (const_int 0))]
7940   "TARGET_64BIT"
7941   "#")
7943 ;; Split out the PIC register save and restore after reload.  As the
7944 ;; split is done after reload, there are some situations in which we
7945 ;; unnecessarily save and restore %r4.  This happens when there is a
7946 ;; single call and the PIC register is not used after the call.
7948 ;; The split has to be done since call_from_call_insn () can't handle
7949 ;; the pattern as is.  Noreturn calls are special because they have to
7950 ;; terminate the basic block.  The split has to contain more than one
7951 ;; insn.
7952 (define_split
7953   [(parallel [(set (match_operand 0 "" "")
7954               (call (mem:SI (match_operand 1 "call_operand_address" ""))
7955                     (match_operand 2 "" "")))
7956               (clobber (reg:DI 1))
7957               (clobber (reg:DI 2))
7958               (clobber (match_operand 3))
7959               (use (reg:DI 27))
7960               (use (reg:DI 29))
7961               (use (const_int 0))])]
7962   "TARGET_64BIT && reload_completed
7963    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7964   [(set (match_dup 3) (reg:DI 27))
7965    (parallel [(set (match_dup 0)
7966               (call (mem:SI (match_dup 1))
7967                     (match_dup 2)))
7968               (clobber (reg:DI 1))
7969               (clobber (reg:DI 2))
7970               (use (reg:DI 27))
7971               (use (reg:DI 29))
7972               (use (const_int 0))])]
7973   "")
7975 (define_split
7976   [(parallel [(set (match_operand 0 "" "")
7977               (call (mem:SI (match_operand 1 "call_operand_address" ""))
7978                     (match_operand 2 "" "")))
7979               (clobber (reg:DI 1))
7980               (clobber (reg:DI 2))
7981               (clobber (match_operand 3))
7982               (use (reg:DI 27))
7983               (use (reg:DI 29))
7984               (use (const_int 0))])]
7985   "TARGET_64BIT && reload_completed"
7986   [(set (match_dup 3) (reg:DI 27))
7987    (parallel [(set (match_dup 0)
7988               (call (mem:SI (match_dup 1))
7989                     (match_dup 2)))
7990               (clobber (reg:DI 1))
7991               (clobber (reg:DI 2))
7992               (use (reg:DI 27))
7993               (use (reg:DI 29))
7994               (use (const_int 0))])
7995    (set (reg:DI 27) (match_dup 3))]
7996   "")
7998 (define_insn "*call_val_symref_64bit_post_reload"
7999   [(set (match_operand 0 "" "")
8000         (call (mem:SI (match_operand 1 "call_operand_address" ""))
8001               (match_operand 2 "" "i")))
8002    (clobber (reg:DI 1))
8003    (clobber (reg:DI 2))
8004    (use (reg:DI 27))
8005    (use (reg:DI 29))
8006    (use (const_int 0))]
8007   "TARGET_64BIT"
8008   "*
8010   pa_output_arg_descriptor (insn);
8011   return pa_output_call (insn, operands[1], 0);
8013   [(set_attr "type" "call")
8014    (set (attr "length")
8015         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8016               (symbol_ref "pa_attr_length_call (insn, 0)")))])
8018 ;; powf function clobbers %fr12
8019 (define_insn "call_val_powf_64bit"
8020   [(set (match_operand 0 "" "")
8021         (call (mem:SI (match_operand 1 "call_operand_address" ""))
8022               (match_operand 2 "" "i")))
8023    (clobber (reg:DI 1))
8024    (clobber (reg:DI 2))
8025    (clobber (reg:DF 40))
8026    (clobber (match_operand 3))
8027    (use (reg:DI 27))
8028    (use (reg:DI 29))
8029    (use (const_int 1))]
8030   "TARGET_64BIT && TARGET_HPUX"
8031   "#")
8033 ;; Split out the PIC register save and restore after reload.  As the
8034 ;; split is done after reload, there are some situations in which we
8035 ;; unnecessarily save and restore %r4.  This happens when there is a
8036 ;; single call and the PIC register is not used after the call.
8038 ;; The split has to be done since call_from_call_insn () can't handle
8039 ;; the pattern as is.  Noreturn calls are special because they have to
8040 ;; terminate the basic block.  The split has to contain more than one
8041 ;; insn.
8042 (define_split
8043   [(parallel [(set (match_operand 0 "" "")
8044               (call (mem:SI (match_operand 1 "call_operand_address" ""))
8045                     (match_operand 2 "" "")))
8046               (clobber (reg:DI 1))
8047               (clobber (reg:DI 2))
8048               (clobber (reg:DF 40))
8049               (clobber (match_operand 3))
8050               (use (reg:DI 27))
8051               (use (reg:DI 29))
8052               (use (const_int 1))])]
8053   "TARGET_64BIT && TARGET_HPUX && reload_completed
8054    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8055   [(set (match_dup 3) (reg:DI 27))
8056    (parallel [(set (match_dup 0)
8057               (call (mem:SI (match_dup 1))
8058                     (match_dup 2)))
8059               (clobber (reg:DI 1))
8060               (clobber (reg:DI 2))
8061               (clobber (reg:DF 40))
8062               (use (reg:DI 27))
8063               (use (reg:DI 29))
8064               (use (const_int 1))])]
8065   "")
8067 (define_split
8068   [(parallel [(set (match_operand 0 "" "")
8069               (call (mem:SI (match_operand 1 "call_operand_address" ""))
8070                     (match_operand 2 "" "")))
8071               (clobber (reg:DI 1))
8072               (clobber (reg:DI 2))
8073               (clobber (reg:DF 40))
8074               (clobber (match_operand 3))
8075               (use (reg:DI 27))
8076               (use (reg:DI 29))
8077               (use (const_int 1))])]
8078   "TARGET_64BIT && TARGET_HPUX && reload_completed"
8079   [(set (match_dup 3) (reg:DI 27))
8080    (parallel [(set (match_dup 0)
8081               (call (mem:SI (match_dup 1))
8082                     (match_dup 2)))
8083               (clobber (reg:DI 1))
8084               (clobber (reg:DI 2))
8085               (clobber (reg:DF 40))
8086               (use (reg:DI 27))
8087               (use (reg:DI 29))
8088               (use (const_int 1))])
8089    (set (reg:DI 27) (match_dup 3))]
8090   "")
8092 (define_insn "*call_val_powf_64bit_post_reload"
8093   [(set (match_operand 0 "" "")
8094         (call (mem:SI (match_operand 1 "call_operand_address" ""))
8095               (match_operand 2 "" "i")))
8096    (clobber (reg:DI 1))
8097    (clobber (reg:DI 2))
8098    (clobber (reg:DF 40))
8099    (use (reg:DI 27))
8100    (use (reg:DI 29))
8101    (use (const_int 1))]
8102   "TARGET_64BIT && TARGET_HPUX"
8103   "*
8105   pa_output_arg_descriptor (insn);
8106   return pa_output_call (insn, operands[1], 0);
8108   [(set_attr "type" "call")
8109    (set (attr "length")
8110         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8111               (symbol_ref "pa_attr_length_call (insn, 0)")))])
8113 (define_insn "call_val_reg"
8114   [(set (match_operand 0 "" "")
8115         (call (mem:SI (reg:SI 22))
8116               (match_operand 1 "" "i")))
8117    (clobber (reg:SI 1))
8118    (clobber (reg:SI 2))
8119    (use (const_int 1))]
8120   "!TARGET_64BIT"
8121   "*
8123   return pa_output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
8125   [(set_attr "type" "dyncall")
8126    (set (attr "length")
8127         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8128               (symbol_ref "pa_attr_length_indirect_call (insn)")))])
8130 ;; This pattern is split if it is necessary to save and restore the
8131 ;; PIC register.
8132 (define_insn "call_val_reg_pic"
8133   [(set (match_operand 0 "" "")
8134         (call (mem:SI (reg:SI 22))
8135               (match_operand 1 "" "i")))
8136    (clobber (reg:SI 1))
8137    (clobber (reg:SI 2))
8138    (clobber (match_operand 2))
8139    (use (reg:SI 19))
8140    (use (const_int 1))]
8141   "!TARGET_64BIT"
8142   "#")
8144 ;; Split out the PIC register save and restore after reload.  As the
8145 ;; split is done after reload, there are some situations in which we
8146 ;; unnecessarily save and restore %r4.  This happens when there is a
8147 ;; single call and the PIC register is not used after the call.
8149 ;; The split has to be done since call_from_call_insn () can't handle
8150 ;; the pattern as is.  Noreturn calls are special because they have to
8151 ;; terminate the basic block.  The split has to contain more than one
8152 ;; insn.
8153 (define_split
8154   [(parallel [(set (match_operand 0 "" "")
8155                    (call (mem:SI (reg:SI 22))
8156                          (match_operand 1 "" "")))
8157               (clobber (reg:SI 1))
8158               (clobber (reg:SI 2))
8159               (clobber (match_operand 2))
8160               (use (reg:SI 19))
8161               (use (const_int 1))])]
8162   "!TARGET_64BIT && reload_completed
8163    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8164   [(set (match_dup 2) (reg:SI 19))
8165    (parallel [(set (match_dup 0)
8166                    (call (mem:SI (reg:SI 22))
8167                          (match_dup 1)))
8168               (clobber (reg:SI 1))
8169               (clobber (reg:SI 2))
8170               (use (reg:SI 19))
8171               (use (const_int 1))])]
8172   "")
8174 (define_split
8175   [(parallel [(set (match_operand 0 "" "")
8176                    (call (mem:SI (reg:SI 22))
8177                          (match_operand 1 "" "")))
8178               (clobber (reg:SI 1))
8179               (clobber (reg:SI 2))
8180               (clobber (match_operand 2))
8181               (use (reg:SI 19))
8182               (use (const_int 1))])]
8183   "!TARGET_64BIT && reload_completed"
8184   [(set (match_dup 2) (reg:SI 19))
8185    (parallel [(set (match_dup 0)
8186                    (call (mem:SI (reg:SI 22))
8187                          (match_dup 1)))
8188               (clobber (reg:SI 1))
8189               (clobber (reg:SI 2))
8190               (use (reg:SI 19))
8191               (use (const_int 1))])
8192    (set (reg:SI 19) (match_dup 2))]
8193   "")
8195 (define_insn "*call_val_reg_pic_post_reload"
8196   [(set (match_operand 0 "" "")
8197         (call (mem:SI (reg:SI 22))
8198               (match_operand 1 "" "i")))
8199    (clobber (reg:SI 1))
8200    (clobber (reg:SI 2))
8201    (use (reg:SI 19))
8202    (use (const_int 1))]
8203   "!TARGET_64BIT"
8204   "*
8206   return pa_output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
8208   [(set_attr "type" "dyncall")
8209    (set (attr "length")
8210         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8211               (symbol_ref "pa_attr_length_indirect_call (insn)")))])
8213 ;; This pattern is split if it is necessary to save and restore the
8214 ;; PIC register.
8215 (define_insn "call_val_reg_64bit"
8216   [(set (match_operand 0 "" "")
8217         (call (mem:SI (match_operand:DI 1 "register_operand" "r"))
8218               (match_operand 2 "" "i")))
8219    (clobber (reg:DI 1))
8220    (clobber (reg:DI 2))
8221    (clobber (match_operand 3))
8222    (use (reg:DI 27))
8223    (use (reg:DI 29))
8224    (use (const_int 1))]
8225   "TARGET_64BIT"
8226   "#")
8228 ;; Split out the PIC register save and restore after reload.  As the
8229 ;; split is done after reload, there are some situations in which we
8230 ;; unnecessarily save and restore %r4.  This happens when there is a
8231 ;; single call and the PIC register is not used after the call.
8233 ;; The split has to be done since call_from_call_insn () can't handle
8234 ;; the pattern as is.  Noreturn calls are special because they have to
8235 ;; terminate the basic block.  The split has to contain more than one
8236 ;; insn.
8237 (define_split
8238   [(parallel [(set (match_operand 0 "" "")
8239                    (call (mem:SI (match_operand:DI 1 "register_operand" ""))
8240                          (match_operand 2 "" "")))
8241               (clobber (reg:DI 1))
8242               (clobber (reg:DI 2))
8243               (clobber (match_operand 3))
8244               (use (reg:DI 27))
8245               (use (reg:DI 29))
8246               (use (const_int 1))])]
8247   "TARGET_64BIT && reload_completed
8248    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8249   [(set (match_dup 3) (reg:DI 27))
8250    (parallel [(set (match_dup 0)
8251                    (call (mem:SI (match_dup 1))
8252                          (match_dup 2)))
8253               (clobber (reg:DI 1))
8254               (clobber (reg:DI 2))
8255               (use (reg:DI 27))
8256               (use (reg:DI 29))
8257               (use (const_int 1))])]
8258   "")
8260 (define_split
8261   [(parallel [(set (match_operand 0 "" "")
8262                    (call (mem:SI (match_operand:DI 1 "register_operand" ""))
8263                          (match_operand 2 "" "")))
8264               (clobber (reg:DI 1))
8265               (clobber (reg:DI 2))
8266               (clobber (match_operand 3))
8267               (use (reg:DI 27))
8268               (use (reg:DI 29))
8269               (use (const_int 1))])]
8270   "TARGET_64BIT && reload_completed"
8271   [(set (match_dup 3) (reg:DI 27))
8272    (parallel [(set (match_dup 0)
8273                    (call (mem:SI (match_dup 1))
8274                          (match_dup 2)))
8275               (clobber (reg:DI 1))
8276               (clobber (reg:DI 2))
8277               (use (reg:DI 27))
8278               (use (reg:DI 29))
8279               (use (const_int 1))])
8280    (set (reg:DI 27) (match_dup 3))]
8281   "")
8283 (define_insn "*call_val_reg_64bit_post_reload"
8284   [(set (match_operand 0 "" "")
8285         (call (mem:SI (match_operand:DI 1 "register_operand" "r"))
8286               (match_operand 2 "" "i")))
8287    (clobber (reg:DI 1))
8288    (clobber (reg:DI 2))
8289    (use (reg:DI 27))
8290    (use (reg:DI 29))
8291    (use (const_int 1))]
8292   "TARGET_64BIT"
8293   "*
8295   return pa_output_indirect_call (insn, operands[1]);
8297   [(set_attr "type" "dyncall")
8298    (set (attr "length")
8299         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 12)]
8300               (symbol_ref "pa_attr_length_indirect_call (insn)")))])
8302 ;; Call subroutine returning any type.
8304 (define_expand "untyped_call"
8305   [(parallel [(call (match_operand 0 "" "")
8306                     (const_int 0))
8307               (match_operand 1 "" "")
8308               (match_operand 2 "" "")])]
8309   ""
8310   "
8312   int i;
8314   emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
8316   for (i = 0; i < XVECLEN (operands[2], 0); i++)
8317     {
8318       rtx set = XVECEXP (operands[2], 0, i);
8319       emit_move_insn (SET_DEST (set), SET_SRC (set));
8320     }
8322   /* The optimizer does not know that the call sets the function value
8323      registers we stored in the result block.  We avoid problems by
8324      claiming that all hard registers are used and clobbered at this
8325      point.  */
8326   emit_insn (gen_blockage ());
8328   DONE;
8331 (define_expand "sibcall"
8332   [(call (match_operand:SI 0 "" "")
8333          (match_operand 1 "" ""))]
8334   "!TARGET_PORTABLE_RUNTIME"
8335   "
8337   rtx op, call_insn;
8338   rtx nb = operands[1];
8340   op = XEXP (operands[0], 0);
8342   if (TARGET_64BIT)
8343     {
8344       if (!virtuals_instantiated)
8345         emit_move_insn (arg_pointer_rtx,
8346                         gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
8347                                       GEN_INT (64)));
8348       else
8349         {
8350           /* The loop pass can generate new libcalls after the virtual
8351              registers are instantiated when fpregs are disabled because
8352              the only method that we have for doing DImode multiplication
8353              is with a libcall.  This could be trouble if we haven't
8354              allocated enough space for the outgoing arguments.  */
8355           gcc_assert (INTVAL (nb) <= crtl->outgoing_args_size);
8357           emit_move_insn (arg_pointer_rtx,
8358                           gen_rtx_PLUS (word_mode, stack_pointer_rtx,
8359                                         GEN_INT (STACK_POINTER_OFFSET + 64)));
8360         }
8361     }
8363   /* Indirect sibling calls are not allowed.  */
8364   if (TARGET_64BIT)
8365     call_insn = gen_sibcall_internal_symref_64bit (op, operands[1]);
8366   else
8367     call_insn = gen_sibcall_internal_symref (op, operands[1]);
8369   call_insn = emit_call_insn (call_insn);
8371   if (TARGET_64BIT)
8372     use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), arg_pointer_rtx);
8374   /* We don't have to restore the PIC register.  */
8375   if (flag_pic)
8376     use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
8378   DONE;
8381 (define_insn "sibcall_internal_symref"
8382   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8383          (match_operand 1 "" "i"))
8384    (clobber (reg:SI 1))
8385    (use (reg:SI 2))
8386    (use (const_int 0))]
8387   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8388   "*
8390   pa_output_arg_descriptor (insn);
8391   return pa_output_call (insn, operands[0], 1);
8393   [(set_attr "type" "sibcall")
8394    (set (attr "length")
8395         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8396               (symbol_ref "pa_attr_length_call (insn, 1)")))])
8398 (define_insn "sibcall_internal_symref_64bit"
8399   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8400          (match_operand 1 "" "i"))
8401    (clobber (reg:DI 1))
8402    (use (reg:DI 2))
8403    (use (const_int 0))]
8404   "TARGET_64BIT"
8405   "*
8407   pa_output_arg_descriptor (insn);
8408   return pa_output_call (insn, operands[0], 1);
8410   [(set_attr "type" "sibcall")
8411    (set (attr "length")
8412         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8413               (symbol_ref "pa_attr_length_call (insn, 1)")))])
8415 (define_expand "sibcall_value"
8416   [(set (match_operand 0 "" "")
8417                    (call (match_operand:SI 1 "" "")
8418                          (match_operand 2 "" "")))]
8419   "!TARGET_PORTABLE_RUNTIME"
8420   "
8422   rtx op, call_insn;
8423   rtx nb = operands[1];
8425   op = XEXP (operands[1], 0);
8427   if (TARGET_64BIT)
8428     {
8429       if (!virtuals_instantiated)
8430         emit_move_insn (arg_pointer_rtx,
8431                         gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
8432                                       GEN_INT (64)));
8433       else
8434         {
8435           /* The loop pass can generate new libcalls after the virtual
8436              registers are instantiated when fpregs are disabled because
8437              the only method that we have for doing DImode multiplication
8438              is with a libcall.  This could be trouble if we haven't
8439              allocated enough space for the outgoing arguments.  */
8440           gcc_assert (INTVAL (nb) <= crtl->outgoing_args_size);
8442           emit_move_insn (arg_pointer_rtx,
8443                           gen_rtx_PLUS (word_mode, stack_pointer_rtx,
8444                                         GEN_INT (STACK_POINTER_OFFSET + 64)));
8445         }
8446     }
8448   /* Indirect sibling calls are not allowed.  */
8449   if (TARGET_64BIT)
8450     call_insn
8451       = gen_sibcall_value_internal_symref_64bit (operands[0], op, operands[2]);
8452   else
8453     call_insn
8454       = gen_sibcall_value_internal_symref (operands[0], op, operands[2]);
8456   call_insn = emit_call_insn (call_insn);
8458   if (TARGET_64BIT)
8459     use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), arg_pointer_rtx);
8461   /* We don't have to restore the PIC register.  */
8462   if (flag_pic)
8463     use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
8465   DONE;
8468 (define_insn "sibcall_value_internal_symref"
8469   [(set (match_operand 0 "" "")
8470         (call (mem:SI (match_operand 1 "call_operand_address" ""))
8471               (match_operand 2 "" "i")))
8472    (clobber (reg:SI 1))
8473    (use (reg:SI 2))
8474    (use (const_int 0))]
8475   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8476   "*
8478   pa_output_arg_descriptor (insn);
8479   return pa_output_call (insn, operands[1], 1);
8481   [(set_attr "type" "sibcall")
8482    (set (attr "length")
8483         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8484               (symbol_ref "pa_attr_length_call (insn, 1)")))])
8486 (define_insn "sibcall_value_internal_symref_64bit"
8487   [(set (match_operand 0 "" "")
8488         (call (mem:SI (match_operand 1 "call_operand_address" ""))
8489               (match_operand 2 "" "i")))
8490    (clobber (reg:DI 1))
8491    (use (reg:DI 2))
8492    (use (const_int 0))]
8493   "TARGET_64BIT"
8494   "*
8496   pa_output_arg_descriptor (insn);
8497   return pa_output_call (insn, operands[1], 1);
8499   [(set_attr "type" "sibcall")
8500    (set (attr "length")
8501         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8502               (symbol_ref "pa_attr_length_call (insn, 1)")))])
8504 (define_insn "nop"
8505   [(const_int 0)]
8506   ""
8507   "nop"
8508   [(set_attr "type" "move")
8509    (set_attr "length" "4")])
8511 ;;; EH does longjmp's from and within the data section.  Thus,
8512 ;;; an interspace branch is required for the longjmp implementation.
8513 ;;; Registers r1 and r2 are used as scratch registers for the jump
8514 ;;; when necessary.
8515 (define_expand "interspace_jump"
8516   [(parallel
8517      [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8518       (clobber (match_dup 1))])]
8519   ""
8520   "
8522   operands[1] = gen_rtx_REG (word_mode, 2);
8525 (define_insn ""
8526   [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8527   (clobber (reg:SI 2))]
8528   "TARGET_PA_20 && !TARGET_64BIT"
8529   "bve%* (%0)"
8530    [(set_attr "type" "branch")
8531     (set_attr "length" "4")])
8533 (define_insn ""
8534   [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8535   (clobber (reg:SI 2))]
8536   "TARGET_NO_SPACE_REGS && !TARGET_64BIT"
8537   "be%* 0(%%sr4,%0)"
8538    [(set_attr "type" "branch")
8539     (set_attr "length" "4")])
8541 (define_insn ""
8542   [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8543   (clobber (reg:SI 2))]
8544   "!TARGET_64BIT"
8545   "ldsid (%%sr0,%0),%%r2\;mtsp %%r2,%%sr0\;be%* 0(%%sr0,%0)"
8546    [(set_attr "type" "branch")
8547     (set_attr "length" "12")])
8549 (define_insn ""
8550   [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8551   (clobber (reg:DI 2))]
8552   "TARGET_64BIT"
8553   "bve%* (%0)"
8554    [(set_attr "type" "branch")
8555     (set_attr "length" "4")])
8557 (define_expand "builtin_longjmp"
8558   [(unspec_volatile [(match_operand 0 "register_operand" "r")] UNSPECV_LONGJMP)]
8559   ""
8560   "
8562   /* The elements of the buffer are, in order:  */
8563   rtx fp = gen_rtx_MEM (Pmode, operands[0]);
8564   rtx lab = gen_rtx_MEM (Pmode, plus_constant (Pmode, operands[0],
8565                          POINTER_SIZE / BITS_PER_UNIT));
8566   rtx stack = gen_rtx_MEM (Pmode, plus_constant (Pmode, operands[0],
8567                            (POINTER_SIZE * 2) / BITS_PER_UNIT));
8568   rtx pv = gen_rtx_REG (Pmode, 1);
8570   emit_clobber (gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (VOIDmode)));
8571   emit_clobber (gen_rtx_MEM (BLKmode, hard_frame_pointer_rtx));
8573   /* Restore the frame pointer.  The virtual_stack_vars_rtx is saved
8574      instead of the hard_frame_pointer_rtx in the save area.  We need
8575      to adjust for the offset between these two values.  */
8576   if (GET_CODE (fp) != REG)
8577     fp = force_reg (Pmode, fp);
8578   emit_move_insn (hard_frame_pointer_rtx, plus_constant (Pmode, fp, -8));
8580   /* This bit is the same as expand_builtin_longjmp.  */
8581   emit_stack_restore (SAVE_NONLOCAL, stack);
8582   emit_use (hard_frame_pointer_rtx);
8583   emit_use (stack_pointer_rtx);
8585   /* Load the label we are jumping through into r1 so that we know
8586      where to look for it when we get back to setjmp's function for
8587      restoring the gp.  */
8588   emit_move_insn (pv, lab);
8590   /* Prevent the insns above from being scheduled into the delay slot
8591      of the interspace jump because the space register could change.  */
8592   emit_insn (gen_blockage ());
8594   emit_jump_insn (gen_interspace_jump (pv));
8595   emit_barrier ();
8596   DONE;
8599 ;;; Operands 2 and 3 are assumed to be CONST_INTs.
8600 (define_expand "extzvsi"
8601   [(set (match_operand:SI 0 "register_operand" "")
8602         (zero_extract:SI (match_operand:SI 1 "register_operand" "")
8603                          (match_operand:SI 2 "uint5_operand" "")
8604                          (match_operand:SI 3 "uint5_operand" "")))]
8605   ""
8606   "
8608   unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
8609   unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
8611   /* PA extraction insns don't support zero length bitfields or fields
8612      extending beyond the left or right-most bits.  Also, the predicate
8613      rejects lengths equal to a word as they are better handled by
8614      the move patterns.  */
8615   if (len == 0 || pos + len > 32)
8616     FAIL;
8618   /* From mips.md: extract_bit_field doesn't verify that our source
8619      matches the predicate, so check it again here.  */
8620   if (!register_operand (operands[1], VOIDmode))
8621     FAIL;
8623   emit_insn (gen_extzv_32 (operands[0], operands[1],
8624                            operands[2], operands[3]));
8625   DONE;
8628 (define_insn "extzv_32"
8629   [(set (match_operand:SI 0 "register_operand" "=r")
8630         (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
8631                          (match_operand:SI 2 "uint5_operand" "")
8632                          (match_operand:SI 3 "uint5_operand" "")))]
8633   "UINTVAL (operands[2]) > 0
8634    && UINTVAL (operands[2]) + UINTVAL (operands[3]) <= 32"
8635   "{extru|extrw,u} %1,%3+%2-1,%2,%0"
8636   [(set_attr "type" "shift")
8637    (set_attr "length" "4")])
8639 (define_insn ""
8640   [(set (match_operand:SI 0 "register_operand" "=r")
8641         (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
8642                          (const_int 1)
8643                          (match_operand:SI 2 "register_operand" "q")))]
8644   ""
8645   "{vextru %1,1,%0|extrw,u %1,%%sar,1,%0}"
8646   [(set_attr "type" "shift")
8647    (set_attr "length" "4")])
8649 (define_expand "extzvdi"
8650   [(set (match_operand:DI 0 "register_operand" "")
8651         (zero_extract:DI (match_operand:DI 1 "register_operand" "")
8652                          (match_operand:DI 2 "uint6_operand" "")
8653                          (match_operand:DI 3 "uint6_operand" "")))]
8654   "TARGET_64BIT"
8655   "
8657   unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
8658   unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
8660   /* PA extraction insns don't support zero length bitfields or fields
8661      extending beyond the left or right-most bits.  Also, the predicate
8662      rejects lengths equal to a doubleword as they are better handled by
8663      the move patterns.  */
8664   if (len == 0 || pos + len > 64)
8665     FAIL;
8667   /* From mips.md: extract_bit_field doesn't verify that our source
8668      matches the predicate, so check it again here.  */
8669   if (!register_operand (operands[1], VOIDmode))
8670     FAIL;
8672   emit_insn (gen_extzv_64 (operands[0], operands[1],
8673                            operands[2], operands[3]));
8674   DONE;
8677 (define_insn "extzv_64"
8678   [(set (match_operand:DI 0 "register_operand" "=r")
8679         (zero_extract:DI (match_operand:DI 1 "register_operand" "r")
8680                          (match_operand:DI 2 "uint6_operand" "")
8681                          (match_operand:DI 3 "uint6_operand" "")))]
8682   "TARGET_64BIT
8683    && UINTVAL (operands[2]) > 0
8684    && UINTVAL (operands[2]) + UINTVAL (operands[3]) <= 64"
8685   "extrd,u %1,%3+%2-1,%2,%0"
8686   [(set_attr "type" "shift")
8687    (set_attr "length" "4")])
8689 (define_insn ""
8690   [(set (match_operand:DI 0 "register_operand" "=r")
8691         (zero_extract:DI (match_operand:DI 1 "register_operand" "r")
8692                          (const_int 1)
8693                          (match_operand:DI 2 "register_operand" "q")))]
8694   "TARGET_64BIT"
8695   "extrd,u %1,%%sar,1,%0"
8696   [(set_attr "type" "shift")
8697    (set_attr "length" "4")])
8699 ;;; Operands 2 and 3 are assumed to be CONST_INTs.
8700 (define_expand "extvsi"
8701   [(set (match_operand:SI 0 "register_operand" "")
8702         (sign_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_extv_32 (operands[0], operands[1],
8724                           operands[2], operands[3]));
8725   DONE;
8728 (define_insn "extv_32"
8729   [(set (match_operand:SI 0 "register_operand" "=r")
8730         (sign_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   "{extrs|extrw,s} %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         (sign_extract:SI (match_operand:SI 1 "register_operand" "r")
8742                          (const_int 1)
8743                          (match_operand:SI 2 "register_operand" "q")))]
8744   "!TARGET_64BIT"
8745   "{vextrs %1,1,%0|extrw,s %1,%%sar,1,%0}"
8746   [(set_attr "type" "shift")
8747    (set_attr "length" "4")])
8749 (define_expand "extvdi"
8750   [(set (match_operand:DI 0 "register_operand" "")
8751         (sign_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_extv_64 (operands[0], operands[1],
8773                           operands[2], operands[3]));
8774   DONE;
8777 (define_insn "extv_64"
8778   [(set (match_operand:DI 0 "register_operand" "=r")
8779         (sign_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,s %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         (sign_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,s %1,%%sar,1,%0"
8796   [(set_attr "type" "shift")
8797    (set_attr "length" "4")])
8799 ;;; Operands 1 and 2 are assumed to be CONST_INTs.
8800 (define_expand "insvsi"
8801   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "")
8802                          (match_operand:SI 1 "uint5_operand" "")
8803                          (match_operand:SI 2 "uint5_operand" ""))
8804         (match_operand:SI 3 "arith5_operand" ""))]
8805   ""
8806   "
8808   unsigned HOST_WIDE_INT len = UINTVAL (operands[1]);
8809   unsigned HOST_WIDE_INT pos = UINTVAL (operands[2]);
8811   /* PA insertion 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: insert_bit_field doesn't verify that our destination
8819      matches the predicate, so check it again here.  */
8820   if (!register_operand (operands[0], VOIDmode))
8821     FAIL;
8823   emit_insn (gen_insv_32 (operands[0], operands[1],
8824                           operands[2], operands[3]));
8825   DONE;
8828 (define_insn "insv_32"
8829   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r,r")
8830                          (match_operand:SI 1 "uint5_operand" "")
8831                          (match_operand:SI 2 "uint5_operand" ""))
8832         (match_operand:SI 3 "arith5_operand" "r,L"))]
8833   "UINTVAL (operands[1]) > 0
8834    && UINTVAL (operands[1]) + UINTVAL (operands[2]) <= 32"
8835   "@
8836    {dep|depw} %3,%2+%1-1,%1,%0
8837    {depi|depwi} %3,%2+%1-1,%1,%0"
8838   [(set_attr "type" "shift,shift")
8839    (set_attr "length" "4,4")])
8841 ;; Optimize insertion of const_int values of type 1...1xxxx.
8842 (define_insn ""
8843   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
8844                          (match_operand:SI 1 "uint5_operand" "")
8845                          (match_operand:SI 2 "uint5_operand" ""))
8846         (match_operand:SI 3 "const_int_operand" ""))]
8847   "(INTVAL (operands[3]) & 0x10) != 0 &&
8848    (~INTVAL (operands[3]) & ((1L << INTVAL (operands[1])) - 1) & ~0xf) == 0"
8849   "*
8851   operands[3] = GEN_INT ((INTVAL (operands[3]) & 0xf) - 0x10);
8852   return \"{depi|depwi} %3,%2+%1-1,%1,%0\";
8854   [(set_attr "type" "shift")
8855    (set_attr "length" "4")])
8857 (define_expand "insvdi"
8858   [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "")
8859                          (match_operand:DI 1 "uint6_operand" "")
8860                          (match_operand:DI 2 "uint6_operand" ""))
8861         (match_operand:DI 3 "arith5_operand" ""))]
8862   "TARGET_64BIT"
8863   "
8865   unsigned HOST_WIDE_INT len = UINTVAL (operands[1]);
8866   unsigned HOST_WIDE_INT pos = UINTVAL (operands[2]);
8868   /* PA insertion insns don't support zero length bitfields or fields
8869      extending beyond the left or right-most bits.  Also, the predicate
8870      rejects lengths equal to a doubleword as they are better handled by
8871      the move patterns.  */
8872   if (len <= 0 || pos + len > 64)
8873     FAIL;
8875   /* From mips.md: insert_bit_field doesn't verify that our destination
8876      matches the predicate, so check it again here.  */
8877   if (!register_operand (operands[0], VOIDmode))
8878     FAIL;
8880   emit_insn (gen_insv_64 (operands[0], operands[1],
8881                           operands[2], operands[3]));
8882   DONE;
8885 (define_insn "insv_64"
8886   [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+r,r")
8887                          (match_operand:DI 1 "uint6_operand" "")
8888                          (match_operand:DI 2 "uint6_operand" ""))
8889         (match_operand:DI 3 "arith5_operand" "r,L"))]
8890   "TARGET_64BIT
8891    && UINTVAL (operands[1]) > 0
8892    && UINTVAL (operands[1]) + UINTVAL (operands[2]) <= 64"
8893   "@
8894    depd %3,%2+%1-1,%1,%0
8895    depdi %3,%2+%1-1,%1,%0"
8896   [(set_attr "type" "shift,shift")
8897    (set_attr "length" "4,4")])
8899 ;; Optimize insertion of const_int values of type 1...1xxxx.
8900 (define_insn ""
8901   [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+r")
8902                          (match_operand:DI 1 "uint6_operand" "")
8903                          (match_operand:DI 2 "uint6_operand" ""))
8904         (match_operand:DI 3 "const_int_operand" ""))]
8905   "(INTVAL (operands[3]) & 0x10) != 0
8906    && TARGET_64BIT
8907    && (~INTVAL (operands[3]) & ((1L << INTVAL (operands[1])) - 1) & ~0xf) == 0"
8908   "*
8910   operands[3] = GEN_INT ((INTVAL (operands[3]) & 0xf) - 0x10);
8911   return \"depdi %3,%2+%1-1,%1,%0\";
8913   [(set_attr "type" "shift")
8914    (set_attr "length" "4")])
8916 (define_insn ""
8917   [(set (match_operand:DI 0 "register_operand" "=r")
8918         (ashift:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
8919                    (const_int 32)))]
8920   "TARGET_64BIT"
8921   "depd,z %1,31,32,%0"
8922   [(set_attr "type" "shift")
8923    (set_attr "length" "4")])
8925 ;; This insn is used for some loop tests, typically loops reversed when
8926 ;; strength reduction is used.  It is actually created when the instruction
8927 ;; combination phase combines the special loop test.  Since this insn
8928 ;; is both a jump insn and has an output, it must deal with its own
8929 ;; reloads, hence the `m' constraints.  The `!' constraints direct reload
8930 ;; to not choose the register alternatives in the event a reload is needed.
8931 (define_insn "decrement_and_branch_until_zero"
8932   [(set (pc)
8933         (if_then_else
8934           (match_operator 2 "comparison_operator"
8935            [(plus:SI
8936               (match_operand:SI 0 "reg_before_reload_operand" "+!r,!*f,*m")
8937               (match_operand:SI 1 "int5_operand" "L,L,L"))
8938             (const_int 0)])
8939           (label_ref (match_operand 3 "" ""))
8940           (pc)))
8941    (set (match_dup 0)
8942         (plus:SI (match_dup 0) (match_dup 1)))
8943    (clobber (match_scratch:SI 4 "=X,r,r"))]
8944   ""
8945   "* return pa_output_dbra (operands, insn, which_alternative); "
8946 ;; Do not expect to understand this the first time through.
8947 [(set_attr "type" "cbranch,multi,multi")
8948  (set (attr "length")
8949       (if_then_else (eq_attr "alternative" "0")
8950 ;; Loop counter in register case
8951 ;; Short branch has length of 4
8952 ;; Long branch has length of 8, 20, 24 or 28
8953         (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
8954                (const_int MAX_12BIT_OFFSET))
8955            (const_int 4)
8956            (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
8957                (const_int MAX_17BIT_OFFSET))
8958            (const_int 8)
8959            (match_test "TARGET_PORTABLE_RUNTIME")
8960            (const_int 24)
8961            (not (match_test "flag_pic"))
8962            (const_int 20)]
8963           (const_int 28))
8965 ;; Loop counter in FP reg case.
8966 ;; Extra goo to deal with additional reload insns.
8967         (if_then_else (eq_attr "alternative" "1")
8968           (if_then_else (lt (match_dup 3) (pc))
8969              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 24))))
8970                       (const_int MAX_12BIT_OFFSET))
8971                     (const_int 24)
8972                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 24))))
8973                       (const_int MAX_17BIT_OFFSET))
8974                     (const_int 28)
8975                     (match_test "TARGET_PORTABLE_RUNTIME")
8976                     (const_int 44)
8977                     (not (match_test "flag_pic"))
8978                     (const_int 40)]
8979                   (const_int 48))
8980              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
8981                       (const_int MAX_12BIT_OFFSET))
8982                     (const_int 24)
8983                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
8984                       (const_int MAX_17BIT_OFFSET))
8985                     (const_int 28)
8986                     (match_test "TARGET_PORTABLE_RUNTIME")
8987                     (const_int 44)
8988                     (not (match_test "flag_pic"))
8989                     (const_int 40)]
8990                   (const_int 48)))
8992 ;; Loop counter in memory case.
8993 ;; Extra goo to deal with additional reload insns.
8994         (if_then_else (lt (match_dup 3) (pc))
8995              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
8996                       (const_int MAX_12BIT_OFFSET))
8997                     (const_int 12)
8998                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
8999                       (const_int MAX_17BIT_OFFSET))
9000                     (const_int 16)
9001                     (match_test "TARGET_PORTABLE_RUNTIME")
9002                     (const_int 32)
9003                     (not (match_test "flag_pic"))
9004                     (const_int 28)]
9005                   (const_int 36))
9006              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9007                       (const_int MAX_12BIT_OFFSET))
9008                     (const_int 12)
9009                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9010                       (const_int MAX_17BIT_OFFSET))
9011                     (const_int 16)
9012                     (match_test "TARGET_PORTABLE_RUNTIME")
9013                     (const_int 32)
9014                     (not (match_test "flag_pic"))
9015                     (const_int 28)]
9016                   (const_int 36))))))])
9018 (define_insn ""
9019   [(set (pc)
9020         (if_then_else
9021           (match_operator 2 "movb_comparison_operator"
9022            [(match_operand:SI 1 "register_operand" "r,r,r,r") (const_int 0)])
9023           (label_ref (match_operand 3 "" ""))
9024           (pc)))
9025    (set (match_operand:SI 0 "reg_before_reload_operand" "=!r,!*f,*m,!*q")
9026         (match_dup 1))]
9027   ""
9028 "* return pa_output_movb (operands, insn, which_alternative, 0); "
9029 ;; Do not expect to understand this the first time through.
9030 [(set_attr "type" "cbranch,multi,multi,multi")
9031  (set (attr "length")
9032       (if_then_else (eq_attr "alternative" "0")
9033 ;; Loop counter in register case
9034 ;; Short branch has length of 4
9035 ;; Long branch has length of 8, 20, 24 or 28
9036         (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9037                (const_int MAX_12BIT_OFFSET))
9038            (const_int 4)
9039            (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9040                (const_int MAX_17BIT_OFFSET))
9041            (const_int 8)
9042            (match_test "TARGET_PORTABLE_RUNTIME")
9043            (const_int 24)
9044            (not (match_test "flag_pic"))
9045            (const_int 20)]
9046           (const_int 28))
9048 ;; Loop counter in FP reg case.
9049 ;; Extra goo to deal with additional reload insns.
9050         (if_then_else (eq_attr "alternative" "1")
9051           (if_then_else (lt (match_dup 3) (pc))
9052              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9053                       (const_int MAX_12BIT_OFFSET))
9054                     (const_int 12)
9055                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9056                       (const_int MAX_17BIT_OFFSET))
9057                     (const_int 16)
9058                     (match_test "TARGET_PORTABLE_RUNTIME")
9059                     (const_int 32)
9060                     (not (match_test "flag_pic"))
9061                     (const_int 28)]
9062                   (const_int 36))
9063              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9064                       (const_int MAX_12BIT_OFFSET))
9065                     (const_int 12)
9066                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9067                       (const_int MAX_17BIT_OFFSET))
9068                     (const_int 16)
9069                     (match_test "TARGET_PORTABLE_RUNTIME")
9070                     (const_int 32)
9071                     (not (match_test "flag_pic"))
9072                     (const_int 28)]
9073                   (const_int 36)))
9075 ;; Loop counter in memory or sar case.
9076 ;; Extra goo to deal with additional reload insns.
9077         (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9078                    (const_int MAX_12BIT_OFFSET))
9079                 (const_int 8)
9080                 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9081                   (const_int MAX_17BIT_OFFSET))
9082                 (const_int 12)
9083                 (match_test "TARGET_PORTABLE_RUNTIME")
9084                 (const_int 28)
9085                 (not (match_test "flag_pic"))
9086                 (const_int 24)]
9087               (const_int 32)))))])
9089 ;; Handle negated branch.
9090 (define_insn ""
9091   [(set (pc)
9092         (if_then_else
9093           (match_operator 2 "movb_comparison_operator"
9094            [(match_operand:SI 1 "register_operand" "r,r,r,r") (const_int 0)])
9095           (pc)
9096           (label_ref (match_operand 3 "" ""))))
9097    (set (match_operand:SI 0 "reg_before_reload_operand" "=!r,!*f,*m,!*q")
9098         (match_dup 1))]
9099   ""
9100 "* return pa_output_movb (operands, insn, which_alternative, 1); "
9101 ;; Do not expect to understand this the first time through.
9102 [(set_attr "type" "cbranch,multi,multi,multi")
9103  (set (attr "length")
9104       (if_then_else (eq_attr "alternative" "0")
9105 ;; Loop counter in register case
9106 ;; Short branch has length of 4
9107 ;; Long branch has length of 8
9108         (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9109                (const_int MAX_12BIT_OFFSET))
9110            (const_int 4)
9111            (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9112                (const_int MAX_17BIT_OFFSET))
9113            (const_int 8)
9114            (match_test "TARGET_PORTABLE_RUNTIME")
9115            (const_int 24)
9116            (not (match_test "flag_pic"))
9117            (const_int 20)]
9118           (const_int 28))
9120 ;; Loop counter in FP reg case.
9121 ;; Extra goo to deal with additional reload insns.
9122         (if_then_else (eq_attr "alternative" "1")
9123           (if_then_else (lt (match_dup 3) (pc))
9124              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9125                       (const_int MAX_12BIT_OFFSET))
9126                     (const_int 12)
9127                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9128                       (const_int MAX_17BIT_OFFSET))
9129                     (const_int 16)
9130                     (match_test "TARGET_PORTABLE_RUNTIME")
9131                     (const_int 32)
9132                     (not (match_test "flag_pic"))
9133                     (const_int 28)]
9134                   (const_int 36))
9135              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9136                       (const_int MAX_12BIT_OFFSET))
9137                     (const_int 12)
9138                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9139                       (const_int MAX_17BIT_OFFSET))
9140                     (const_int 16)
9141                     (match_test "TARGET_PORTABLE_RUNTIME")
9142                     (const_int 32)
9143                     (not (match_test "flag_pic"))
9144                     (const_int 28)]
9145                   (const_int 36)))
9147 ;; Loop counter in memory or SAR case.
9148 ;; Extra goo to deal with additional reload insns.
9149         (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9150                    (const_int MAX_12BIT_OFFSET))
9151                 (const_int 8)
9152                 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9153                   (const_int MAX_17BIT_OFFSET))
9154                 (const_int 12)
9155                 (match_test "TARGET_PORTABLE_RUNTIME")
9156                 (const_int 28)
9157                 (not (match_test "flag_pic"))
9158                 (const_int 24)]
9159               (const_int 32)))))])
9161 (define_insn ""
9162   [(set (pc) (label_ref (match_operand 3 "" "" )))
9163    (set (match_operand:SI 0 "ireg_operand" "=r")
9164         (plus:SI (match_operand:SI 1 "ireg_operand" "r")
9165                  (match_operand:SI 2 "ireg_or_int5_operand" "rL")))]
9166   "(reload_completed && operands[0] == operands[1]) || operands[0] == operands[2]"
9167   "*
9169   return pa_output_parallel_addb (operands, insn);
9171 [(set_attr "type" "parallel_branch")
9172  (set (attr "length")
9173     (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9174                (const_int MAX_12BIT_OFFSET))
9175            (const_int 4)
9176            (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9177                (const_int MAX_17BIT_OFFSET))
9178            (const_int 8)
9179            (match_test "TARGET_PORTABLE_RUNTIME")
9180            (const_int 24)
9181            (not (match_test "flag_pic"))
9182            (const_int 20)]
9183           (const_int 28)))])
9185 (define_insn ""
9186   [(set (pc) (label_ref (match_operand 2 "" "" )))
9187    (set (match_operand:SF 0 "ireg_operand" "=r")
9188         (match_operand:SF 1 "ireg_or_int5_operand" "rL"))]
9189   "reload_completed"
9190   "*
9192   return pa_output_parallel_movb (operands, insn);
9194 [(set_attr "type" "parallel_branch")
9195  (set (attr "length")
9196     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9197                (const_int MAX_12BIT_OFFSET))
9198            (const_int 4)
9199            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9200                (const_int MAX_17BIT_OFFSET))
9201            (const_int 8)
9202            (match_test "TARGET_PORTABLE_RUNTIME")
9203            (const_int 24)
9204            (not (match_test "flag_pic"))
9205            (const_int 20)]
9206           (const_int 28)))])
9208 (define_insn ""
9209   [(set (pc) (label_ref (match_operand 2 "" "" )))
9210    (set (match_operand:SI 0 "ireg_operand" "=r")
9211         (match_operand:SI 1 "ireg_or_int5_operand" "rL"))]
9212   "reload_completed"
9213   "*
9215   return pa_output_parallel_movb (operands, insn);
9217 [(set_attr "type" "parallel_branch")
9218  (set (attr "length")
9219     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9220                (const_int MAX_12BIT_OFFSET))
9221            (const_int 4)
9222            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9223                (const_int MAX_17BIT_OFFSET))
9224            (const_int 8)
9225            (match_test "TARGET_PORTABLE_RUNTIME")
9226            (const_int 24)
9227            (not (match_test "flag_pic"))
9228            (const_int 20)]
9229           (const_int 28)))])
9231 (define_insn ""
9232   [(set (pc) (label_ref (match_operand 2 "" "" )))
9233    (set (match_operand:HI 0 "ireg_operand" "=r")
9234         (match_operand:HI 1 "ireg_or_int5_operand" "rL"))]
9235   "reload_completed"
9236   "*
9238   return pa_output_parallel_movb (operands, insn);
9240 [(set_attr "type" "parallel_branch")
9241  (set (attr "length")
9242     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9243                (const_int MAX_12BIT_OFFSET))
9244            (const_int 4)
9245            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9246                (const_int MAX_17BIT_OFFSET))
9247            (const_int 8)
9248            (match_test "TARGET_PORTABLE_RUNTIME")
9249            (const_int 24)
9250            (not (match_test "flag_pic"))
9251            (const_int 20)]
9252           (const_int 28)))])
9254 (define_insn ""
9255   [(set (pc) (label_ref (match_operand 2 "" "" )))
9256    (set (match_operand:QI 0 "ireg_operand" "=r")
9257         (match_operand:QI 1 "ireg_or_int5_operand" "rL"))]
9258   "reload_completed"
9259   "*
9261   return pa_output_parallel_movb (operands, insn);
9263 [(set_attr "type" "parallel_branch")
9264  (set (attr "length")
9265     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9266                (const_int MAX_12BIT_OFFSET))
9267            (const_int 4)
9268            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9269                (const_int MAX_17BIT_OFFSET))
9270            (const_int 8)
9271            (match_test "TARGET_PORTABLE_RUNTIME")
9272            (const_int 24)
9273            (not (match_test "flag_pic"))
9274            (const_int 20)]
9275           (const_int 28)))])
9277 (define_insn ""
9278   [(set (match_operand 0 "register_operand" "=f")
9279         (mult (match_operand 1 "register_operand" "f")
9280               (match_operand 2 "register_operand" "f")))
9281    (set (match_operand 3 "register_operand" "+f")
9282         (plus (match_operand 4 "register_operand" "f")
9283               (match_operand 5 "register_operand" "f")))]
9284   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9285    && reload_completed && pa_fmpyaddoperands (operands)"
9286   "*
9288   if (GET_MODE (operands[0]) == DFmode)
9289     {
9290       if (rtx_equal_p (operands[3], operands[5]))
9291         return \"fmpyadd,dbl %1,%2,%0,%4,%3\";
9292       else
9293         return \"fmpyadd,dbl %1,%2,%0,%5,%3\";
9294     }
9295   else
9296     {
9297       if (rtx_equal_p (operands[3], operands[5]))
9298         return \"fmpyadd,sgl %1,%2,%0,%4,%3\";
9299       else
9300         return \"fmpyadd,sgl %1,%2,%0,%5,%3\";
9301     }
9303   [(set_attr "type" "fpalu")
9304    (set_attr "length" "4")])
9306 (define_insn ""
9307   [(set (match_operand 3 "register_operand" "+f")
9308         (plus (match_operand 4 "register_operand" "f")
9309               (match_operand 5 "register_operand" "f")))
9310    (set (match_operand 0 "register_operand" "=f")
9311         (mult (match_operand 1 "register_operand" "f")
9312               (match_operand 2 "register_operand" "f")))]
9313   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9314    && reload_completed && pa_fmpyaddoperands (operands)"
9315   "*
9317   if (GET_MODE (operands[0]) == DFmode)
9318     {
9319       if (rtx_equal_p (operands[3], operands[5]))
9320         return \"fmpyadd,dbl %1,%2,%0,%4,%3\";
9321       else
9322         return \"fmpyadd,dbl %1,%2,%0,%5,%3\";
9323     }
9324   else
9325     {
9326       if (rtx_equal_p (operands[3], operands[5]))
9327         return \"fmpyadd,sgl %1,%2,%0,%4,%3\";
9328       else
9329         return \"fmpyadd,sgl %1,%2,%0,%5,%3\";
9330     }
9332   [(set_attr "type" "fpalu")
9333    (set_attr "length" "4")])
9335 (define_insn ""
9336   [(set (match_operand 0 "register_operand" "=f")
9337         (mult (match_operand 1 "register_operand" "f")
9338               (match_operand 2 "register_operand" "f")))
9339    (set (match_operand 3 "register_operand" "+f")
9340         (minus (match_operand 4 "register_operand" "f")
9341                (match_operand 5 "register_operand" "f")))]
9342   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9343    && reload_completed && pa_fmpysuboperands (operands)"
9344   "*
9346   if (GET_MODE (operands[0]) == DFmode)
9347     return \"fmpysub,dbl %1,%2,%0,%5,%3\";
9348   else
9349     return \"fmpysub,sgl %1,%2,%0,%5,%3\";
9351   [(set_attr "type" "fpalu")
9352    (set_attr "length" "4")])
9354 (define_insn ""
9355   [(set (match_operand 3 "register_operand" "+f")
9356         (minus (match_operand 4 "register_operand" "f")
9357                (match_operand 5 "register_operand" "f")))
9358    (set (match_operand 0 "register_operand" "=f")
9359         (mult (match_operand 1 "register_operand" "f")
9360               (match_operand 2 "register_operand" "f")))]
9361   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9362    && reload_completed && pa_fmpysuboperands (operands)"
9363   "*
9365   if (GET_MODE (operands[0]) == DFmode)
9366     return \"fmpysub,dbl %1,%2,%0,%5,%3\";
9367   else
9368     return \"fmpysub,sgl %1,%2,%0,%5,%3\";
9370   [(set_attr "type" "fpalu")
9371    (set_attr "length" "4")])
9373 ;; The following two patterns are used by the trampoline code for nested
9374 ;; functions.  They flush the I and D cache lines from the start address
9375 ;; (operand0) to the end address (operand1).  No lines are flushed if the
9376 ;; end address is less than the start address (unsigned).
9378 ;; Because the range of memory flushed is variable and the size of a MEM
9379 ;; can only be a CONST_INT, the patterns specify that they perform an
9380 ;; unspecified volatile operation on all memory.
9382 ;; The address range for an icache flush must lie within a single
9383 ;; space on targets with non-equivalent space registers.
9385 ;; Operand 0 contains the start address.
9386 ;; Operand 1 contains the end address.
9387 ;; Operand 2 contains the line length to use.
9388 (define_insn "dcacheflush<P:mode>"
9389   [(const_int 1)
9390    (unspec_volatile [(mem:BLK (scratch))] UNSPECV_DCACHE)
9391    (use (match_operand 0 "pmode_register_operand" "r"))
9392    (use (match_operand 1 "pmode_register_operand" "r"))
9393    (use (match_operand 2 "pmode_register_operand" "r"))
9394    (clobber (match_scratch:P 3 "=&0"))]
9395   ""
9396   "cmpb,<dwc><<=,n %3,%1,.\;fdc,m %2(%3)\;sync"
9397   [(set_attr "type" "multi")
9398    (set_attr "length" "12")])
9400 (define_insn "icacheflush<P:mode>"
9401   [(const_int 2)
9402    (unspec_volatile [(mem:BLK (scratch))] UNSPECV_ICACHE)
9403    (use (match_operand 0 "pmode_register_operand" "r"))
9404    (use (match_operand 1 "pmode_register_operand" "r"))
9405    (use (match_operand 2 "pmode_register_operand" "r"))
9406    (clobber (match_operand 3 "pmode_register_operand" "=&r"))
9407    (clobber (match_operand 4 "pmode_register_operand" "=&r"))
9408    (clobber (match_scratch:P 5 "=&0"))]
9409   ""
9410   "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"
9411   [(set_attr "type" "multi")
9412    (set_attr "length" "52")])
9414 ;; An out-of-line prologue.
9415 (define_insn "outline_prologue_call"
9416   [(unspec_volatile [(const_int 0)] UNSPECV_OPC)
9417    (clobber (reg:SI 31))
9418    (clobber (reg:SI 22))
9419    (clobber (reg:SI 21))
9420    (clobber (reg:SI 20))
9421    (clobber (reg:SI 19))
9422    (clobber (reg:SI 1))]
9423   ""
9424   "*
9427   /* We need two different versions depending on whether or not we
9428      need a frame pointer.   Also note that we return to the instruction
9429      immediately after the branch rather than two instructions after the
9430      break as normally is the case.  */
9431   if (frame_pointer_needed)
9432     {
9433       /* Must import the magic millicode routine(s).  */
9434       output_asm_insn (\".IMPORT __outline_prologue_fp,MILLICODE\", NULL);
9436       if (TARGET_PORTABLE_RUNTIME)
9437         {
9438           output_asm_insn (\"ldil L'__outline_prologue_fp,%%r31\", NULL);
9439           output_asm_insn (\"ble,n R'__outline_prologue_fp(%%sr0,%%r31)\",
9440                            NULL);
9441         }
9442       else
9443         output_asm_insn (\"{bl|b,l},n __outline_prologue_fp,%%r31\", NULL);
9444     }
9445   else
9446     {
9447       /* Must import the magic millicode routine(s).  */
9448       output_asm_insn (\".IMPORT __outline_prologue,MILLICODE\", NULL);
9450       if (TARGET_PORTABLE_RUNTIME)
9451         {
9452           output_asm_insn (\"ldil L'__outline_prologue,%%r31\", NULL);
9453           output_asm_insn (\"ble,n R'__outline_prologue(%%sr0,%%r31)\", NULL);
9454         }
9455       else
9456         output_asm_insn (\"{bl|b,l},n __outline_prologue,%%r31\", NULL);
9457     }
9458   return \"\";
9460   [(set_attr "type" "multi")
9461    (set_attr "length" "8")])
9463 ;; An out-of-line epilogue.
9464 (define_insn "outline_epilogue_call"
9465   [(unspec_volatile [(const_int 1)] UNSPECV_OEC)
9466    (use (reg:SI 29))
9467    (use (reg:SI 28))
9468    (clobber (reg:SI 31))
9469    (clobber (reg:SI 22))
9470    (clobber (reg:SI 21))
9471    (clobber (reg:SI 20))
9472    (clobber (reg:SI 19))
9473    (clobber (reg:SI 2))
9474    (clobber (reg:SI 1))]
9475   ""
9476   "*
9479   /* We need two different versions depending on whether or not we
9480      need a frame pointer.   Also note that we return to the instruction
9481      immediately after the branch rather than two instructions after the
9482      break as normally is the case.  */
9483   if (frame_pointer_needed)
9484     {
9485       /* Must import the magic millicode routine.  */
9486       output_asm_insn (\".IMPORT __outline_epilogue_fp,MILLICODE\", NULL);
9488       /* The out-of-line prologue will make sure we return to the right
9489          instruction.  */
9490       if (TARGET_PORTABLE_RUNTIME)
9491         {
9492           output_asm_insn (\"ldil L'__outline_epilogue_fp,%%r31\", NULL);
9493           output_asm_insn (\"ble,n R'__outline_epilogue_fp(%%sr0,%%r31)\",
9494                            NULL);
9495         }
9496       else
9497         output_asm_insn (\"{bl|b,l},n __outline_epilogue_fp,%%r31\", NULL);
9498     }
9499   else
9500     {
9501       /* Must import the magic millicode routine.  */
9502       output_asm_insn (\".IMPORT __outline_epilogue,MILLICODE\", NULL);
9504       /* The out-of-line prologue will make sure we return to the right
9505          instruction.  */
9506       if (TARGET_PORTABLE_RUNTIME)
9507         {
9508           output_asm_insn (\"ldil L'__outline_epilogue,%%r31\", NULL);
9509           output_asm_insn (\"ble,n R'__outline_epilogue(%%sr0,%%r31)\", NULL);
9510         }
9511       else
9512         output_asm_insn (\"{bl|b,l},n __outline_epilogue,%%r31\", NULL);
9513     }
9514   return \"\";
9516   [(set_attr "type" "multi")
9517    (set_attr "length" "8")])
9519 ;; Given a function pointer, canonicalize it so it can be 
9520 ;; reliably compared to another function pointer.  */
9521 (define_expand "canonicalize_funcptr_for_compare"
9522   [(set (reg:SI 26) (match_operand:SI 1 "register_operand" ""))
9523    (parallel [(set (reg:SI 29) (unspec:SI [(reg:SI 26)] UNSPEC_CFFC))
9524               (clobber (match_dup 2))
9525               (clobber (reg:SI 26))
9526               (clobber (reg:SI 22))
9527               (clobber (reg:SI 31))])
9528    (set (match_operand:SI 0 "register_operand" "")
9529         (reg:SI 29))]
9530   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
9531   "
9533   if (TARGET_ELF32)
9534     {
9535       rtx canonicalize_funcptr_for_compare_libfunc
9536         = init_one_libfunc (CANONICALIZE_FUNCPTR_FOR_COMPARE_LIBCALL);
9538       emit_library_call_value (canonicalize_funcptr_for_compare_libfunc,
9539                                operands[0], LCT_NORMAL, Pmode,
9540                                1, operands[1], Pmode);
9541       DONE;
9542     }
9544   operands[2] = gen_reg_rtx (SImode);
9545   if (GET_CODE (operands[1]) != REG)
9546     {
9547       rtx tmp = gen_reg_rtx (Pmode);
9548       emit_move_insn (tmp, operands[1]);
9549       operands[1] = tmp;
9550     }
9553 (define_insn "*$$sh_func_adrs"
9554   [(set (reg:SI 29) (unspec:SI [(reg:SI 26)] UNSPEC_CFFC))
9555    (clobber (match_operand:SI 0 "register_operand" "=a"))
9556    (clobber (reg:SI 26))
9557    (clobber (reg:SI 22))
9558    (clobber (reg:SI 31))]
9559   "!TARGET_64BIT"
9560   "*
9562   int length = get_attr_length (insn);
9563   rtx xoperands[2];
9565   xoperands[0] = GEN_INT (length - 8);
9566   xoperands[1] = GEN_INT (length - 16);
9568   /* Must import the magic millicode routine.  */
9569   output_asm_insn (\".IMPORT $$sh_func_adrs,MILLICODE\", NULL);
9571   /* This is absolutely amazing.
9573      First, copy our input parameter into %r29 just in case we don't
9574      need to call $$sh_func_adrs.  */
9575   output_asm_insn (\"copy %%r26,%%r29\", NULL);
9576   output_asm_insn (\"{extru|extrw,u} %%r26,31,2,%%r31\", NULL);
9578   /* Next, examine the low two bits in %r26, if they aren't 0x2, then
9579      we use %r26 unchanged.  */
9580   output_asm_insn (\"{comib|cmpib},<>,n 2,%%r31,.+%0\", xoperands);
9581   output_asm_insn (\"ldi 4096,%%r31\", NULL);
9583   /* Next, compare %r26 with 4096, if %r26 is less than or equal to
9584      4096, then again we use %r26 unchanged.  */
9585   output_asm_insn (\"{comb|cmpb},<<,n %%r26,%%r31,.+%1\", xoperands);
9587   /* Finally, call $$sh_func_adrs to extract the function's real add24.  */
9588   return pa_output_millicode_call (insn,
9589                                    gen_rtx_SYMBOL_REF (SImode,
9590                                                        \"$$sh_func_adrs\"));
9592   [(set_attr "type" "sh_func_adrs")
9593    (set (attr "length")
9594         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 28)]
9595               (plus (symbol_ref "pa_attr_length_millicode_call (insn)")
9596                     (const_int 20))))])
9598 ;; On the PA, the PIC register is call clobbered, so it must
9599 ;; be saved & restored around calls by the caller.  If the call
9600 ;; doesn't return normally (nonlocal goto, or an exception is
9601 ;; thrown), then the code at the exception handler label must
9602 ;; restore the PIC register.
9603 (define_expand "exception_receiver"
9604   [(const_int 4)]
9605   "flag_pic"
9606   "
9608   /* On the 64-bit port, we need a blockage because there is
9609      confusion regarding the dependence of the restore on the
9610      frame pointer.  As a result, the frame pointer and pic
9611      register restores sometimes are interchanged erroneously.  */
9612   if (TARGET_64BIT)
9613     emit_insn (gen_blockage ());
9614   /* Restore the PIC register using hppa_pic_save_rtx ().  The
9615      PIC register is not saved in the frame in 64-bit ABI.  */
9616   emit_move_insn (pic_offset_table_rtx, hppa_pic_save_rtx ());
9617   emit_insn (gen_blockage ());
9618   DONE;
9621 (define_expand "builtin_setjmp_receiver"
9622   [(label_ref (match_operand 0 "" ""))]
9623   "flag_pic"
9624   "
9626   if (TARGET_64BIT)
9627     emit_insn (gen_blockage ());
9628   /* Restore the PIC register.  Hopefully, this will always be from
9629      a stack slot.  The only registers that are valid after a
9630      builtin_longjmp are the stack and frame pointers.  */
9631   emit_move_insn (pic_offset_table_rtx, hppa_pic_save_rtx ());
9632   emit_insn (gen_blockage ());
9633   DONE;
9636 ;; Allocate new stack space and update the saved stack pointer in the
9637 ;; frame marker.  The HP C compilers also copy additional words in the
9638 ;; frame marker.  The 64-bit compiler copies words at -48, -32 and -24.
9639 ;; The 32-bit compiler copies the word at -16 (Static Link).  We
9640 ;; currently don't copy these values.
9642 ;; Since the copy of the frame marker can't be done atomically, I
9643 ;; suspect that using it for unwind purposes may be somewhat unreliable.
9644 ;; The HP compilers appear to raise the stack and copy the frame
9645 ;; marker in a strict instruction sequence.  This suggests that the
9646 ;; unwind library may check for an alloca sequence when ALLOCA_FRAME
9647 ;; is set in the callinfo data.  We currently don't set ALLOCA_FRAME
9648 ;; as GAS doesn't support it, or try to keep the instructions emitted
9649 ;; here in strict sequence.
9650 (define_expand "allocate_stack"
9651   [(match_operand 0 "" "")
9652    (match_operand 1 "" "")]
9653   ""
9654   "
9656   rtx addr;
9658   /* Since the stack grows upward, we need to store virtual_stack_dynamic_rtx
9659      in operand 0 before adjusting the stack.  */
9660   emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
9661   anti_adjust_stack (operands[1]);
9662   if (TARGET_HPUX_UNWIND_LIBRARY)
9663     {
9664       addr = gen_rtx_PLUS (word_mode, stack_pointer_rtx,
9665                            GEN_INT (TARGET_64BIT ? -8 : -4));
9666       emit_move_insn (gen_rtx_MEM (word_mode, addr), hard_frame_pointer_rtx);
9667     }
9668   if (!TARGET_64BIT && flag_pic)
9669     {
9670       rtx addr = gen_rtx_PLUS (word_mode, stack_pointer_rtx, GEN_INT (-32));
9671       emit_move_insn (gen_rtx_MEM (word_mode, addr), pic_offset_table_rtx);
9672     }
9673   DONE;
9676 (define_expand "prefetch"
9677   [(match_operand 0 "address_operand" "")
9678    (match_operand 1 "const_int_operand" "")
9679    (match_operand 2 "const_int_operand" "")]
9680   "TARGET_PA_20"
9682   operands[0] = copy_addr_to_reg (operands[0]);
9683   emit_insn (gen_prefetch_20 (operands[0], operands[1], operands[2]));
9684   DONE;
9687 (define_insn "prefetch_20"
9688   [(prefetch (match_operand 0 "pmode_register_operand" "r")
9689              (match_operand:SI 1 "const_int_operand" "n")
9690              (match_operand:SI 2 "const_int_operand" "n"))]
9691   "TARGET_PA_20"
9693   /* The SL cache-control completer indicates good spatial locality but
9694      poor temporal locality.  The ldw instruction with a target of general
9695      register 0 prefetches a cache line for a read.  The ldd instruction
9696      prefetches a cache line for a write.  */
9697   static const char * const instr[2][2] = {
9698     {
9699       "ldw,sl 0(%0),%%r0",
9700       "ldd,sl 0(%0),%%r0"
9701     },
9702     {
9703       "ldw 0(%0),%%r0",
9704       "ldd 0(%0),%%r0"
9705     }
9706   };
9707   int read_or_write = INTVAL (operands[1]) == 0 ? 0 : 1;
9708   int locality = INTVAL (operands[2]) == 0 ? 0 : 1;
9710   return instr [locality][read_or_write];
9712   [(set_attr "type" "load")
9713    (set_attr "length" "4")])
9715 ;; TLS Support
9716 (define_insn "tgd_load"
9717  [(set (match_operand:SI 0 "register_operand" "=r")
9718        (unspec:SI [(match_operand 1 "tgd_symbolic_operand" "")] UNSPEC_TLSGD))
9719   (clobber (reg:SI 1))
9720   (use (reg:SI 27))]
9721   ""
9722   "*
9724   return \"addil LR'%1-$tls_gdidx$,%%r27\;ldo RR'%1-$tls_gdidx$(%%r1),%0\";
9726   [(set_attr "type" "multi")
9727    (set_attr "length" "8")])
9729 (define_insn "tgd_load_pic"
9730  [(set (match_operand:SI 0 "register_operand" "=r")
9731        (unspec:SI [(match_operand 1 "tgd_symbolic_operand" "")] UNSPEC_TLSGD_PIC))
9732   (clobber (reg:SI 1))
9733   (use (reg:SI 19))]
9734   ""
9735   "*
9737   return \"addil LT'%1-$tls_gdidx$,%%r19\;ldo RT'%1-$tls_gdidx$(%%r1),%0\";
9739   [(set_attr "type" "multi")
9740    (set_attr "length" "8")])
9742 (define_insn "tld_load"
9743  [(set (match_operand:SI 0 "register_operand" "=r")
9744        (unspec:SI [(match_operand 1 "tld_symbolic_operand" "")] UNSPEC_TLSLDM))
9745   (clobber (reg:SI 1))
9746   (use (reg:SI 27))]
9747   ""
9748   "*
9750   return \"addil LR'%1-$tls_ldidx$,%%r27\;ldo RR'%1-$tls_ldidx$(%%r1),%0\";
9752   [(set_attr "type" "multi")
9753    (set_attr "length" "8")])
9755 (define_insn "tld_load_pic"
9756  [(set (match_operand:SI 0 "register_operand" "=r")
9757        (unspec:SI [(match_operand 1 "tld_symbolic_operand" "")] UNSPEC_TLSLDM_PIC))
9758   (clobber (reg:SI 1))
9759   (use (reg:SI 19))]
9760   ""
9761   "*
9763   return \"addil LT'%1-$tls_ldidx$,%%r19\;ldo RT'%1-$tls_ldidx$(%%r1),%0\";
9765   [(set_attr "type" "multi")
9766    (set_attr "length" "8")])
9768 (define_insn "tld_offset_load"
9769   [(set (match_operand:SI 0 "register_operand" "=r")
9770         (plus:SI (unspec:SI [(match_operand 1 "tld_symbolic_operand" "")] 
9771                             UNSPEC_TLSLDO)
9772                  (match_operand:SI 2 "register_operand" "r")))
9773    (clobber (reg:SI 1))]
9774   ""
9775   "*
9777   return \"addil LR'%1-$tls_dtpoff$,%2\;ldo RR'%1-$tls_dtpoff$(%%r1),%0\"; 
9779   [(set_attr "type" "multi")
9780    (set_attr "length" "8")])
9782 (define_insn "tp_load"
9783   [(set (match_operand:SI 0 "register_operand" "=r")
9784         (unspec:SI [(const_int 0)] UNSPEC_TP))]
9785   ""
9786   "mfctl %%cr27,%0"
9787   [(set_attr "type" "multi")
9788    (set_attr "length" "4")])
9790 (define_insn "tie_load"
9791   [(set (match_operand:SI 0 "register_operand" "=r")
9792         (unspec:SI [(match_operand 1 "tie_symbolic_operand" "")] UNSPEC_TLSIE))
9793    (clobber (reg:SI 1))
9794    (use (reg:SI 27))]
9795   ""
9796   "*
9798   return \"addil LR'%1-$tls_ieoff$,%%r27\;ldw RR'%1-$tls_ieoff$(%%r1),%0\";
9800   [(set_attr "type" "multi")
9801    (set_attr "length" "8")])
9803 (define_insn "tie_load_pic"
9804   [(set (match_operand:SI 0 "register_operand" "=r")
9805         (unspec:SI [(match_operand 1 "tie_symbolic_operand" "")] UNSPEC_TLSIE_PIC))
9806    (clobber (reg:SI 1))
9807    (use (reg:SI 19))]
9808   ""
9809   "*
9811   return \"addil LT'%1-$tls_ieoff$,%%r19\;ldw RT'%1-$tls_ieoff$(%%r1),%0\";
9813   [(set_attr "type" "multi")
9814    (set_attr "length" "8")])
9816 (define_insn "tle_load"
9817   [(set (match_operand:SI 0 "register_operand" "=r")
9818         (plus:SI (unspec:SI [(match_operand 1 "tle_symbolic_operand" "")] 
9819                             UNSPEC_TLSLE)
9820                  (match_operand:SI 2 "register_operand" "r")))
9821    (clobber (reg:SI 1))]
9822   ""
9823   "addil LR'%1-$tls_leoff$,%2\;ldo RR'%1-$tls_leoff$(%%r1),%0"
9824   [(set_attr "type" "multi")
9825    (set_attr "length" "8")])