pa.md: Revert change to use ordered_comparison_operator instead of...
[official-gcc.git] / gcc / config / pa / pa.md
blob6350c685a59b71dbc83b0527169e5e18bdb578b5
1 ;;- Machine description for HP PA-RISC architecture for GCC compiler
2 ;;   Copyright (C) 1992-2020 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    UNSPEC_MEMORY_BARRIER
88   ])
90 ;; UNSPEC_VOLATILE:
92 (define_c_enum "unspecv"
93   [UNSPECV_BLOCKAGE     ; blockage
94    UNSPECV_DCACHE       ; dcacheflush
95    UNSPECV_ICACHE       ; icacheflush
96    UNSPECV_OPC          ; outline_prologue_call
97    UNSPECV_OEC          ; outline_epilogue_call
98    UNSPECV_LONGJMP      ; builtin_longjmp
99   ])
101 ;; Maximum pc-relative branch offsets.
103 ;; These numbers are a bit smaller than the maximum allowable offsets
104 ;; so that a few instructions may be inserted before the actual branch.
106 (define_constants
107   [(MAX_12BIT_OFFSET     8184)  ; 12-bit branch
108    (MAX_17BIT_OFFSET   262100)  ; 17-bit branch
109   ])
111 ;; Mode and code iterators
113 ;; This mode iterator allows :P to be used for patterns that operate on
114 ;; pointer-sized quantities.  Exactly one of the two alternatives will match.
115 (define_mode_iterator P [(SI "Pmode == SImode") (DI "Pmode == DImode")])
117 ;; This attribute defines the condition prefix for word and double word
118 ;; add, compare, subtract and logical instructions.
119 (define_mode_attr dwc [(SI "") (DI "*")])
121 ;; Insn type.  Used to default other attribute values.
123 ;; type "unary" insns have one input operand (1) and one output operand (0)
124 ;; type "binary" insns have two input operands (1,2) and one output (0)
126 (define_attr "type"
127   "move,unary,binary,shift,nullshift,compare,load,store,uncond_branch,branch,cbranch,fbranch,call,sibcall,dyncall,fpload,fpstore,fpalu,fpcc,fpmulsgl,fpmuldbl,fpdivsgl,fpdivdbl,fpsqrtsgl,fpsqrtdbl,multi,milli,sh_func_adrs,parallel_branch,fpstore_load,store_fpload,trap"
128   (const_string "binary"))
130 (define_attr "pa_combine_type"
131   "fmpy,faddsub,uncond_branch,addmove,none"
132   (const_string "none"))
134 ;; Processor type (for scheduling, not code generation) -- this attribute
135 ;; must exactly match the processor_type enumeration in pa.h.
137 ;; FIXME: Add 800 scheduling for completeness?
139 (define_attr "cpu" "700,7100,7100LC,7200,7300,8000" (const (symbol_ref "pa_cpu_attr")))
141 ;; Length (in # of bytes).
142 (define_attr "length" ""
143   (cond [(eq_attr "type" "load,fpload")
144          (if_then_else (match_operand 1 "symbolic_memory_operand" "")
145                        (const_int 8) (const_int 4))
147          (eq_attr "type" "store,fpstore")
148          (if_then_else (match_operand 0 "symbolic_memory_operand" "")
149                        (const_int 8) (const_int 4))
151          (eq_attr "type" "binary,shift,nullshift")
152          (if_then_else (match_operand 2 "arith14_operand" "")
153                        (const_int 4) (const_int 12))
155          (eq_attr "type" "move,unary,shift,nullshift")
156          (if_then_else (match_operand 1 "arith14_operand" "")
157                        (const_int 4) (const_int 8))]
159         (const_int 4)))
161 (define_asm_attributes
162   [(set_attr "length" "4")
163    (set_attr "type" "multi")])
165 ;; Attributes for instruction and branch scheduling
167 ;; For conditional branches. Frame related instructions are not allowed
168 ;; because they confuse the unwind support.
169 (define_attr "in_branch_delay" "false,true"
170   (if_then_else (and (eq_attr "type" "!uncond_branch,branch,cbranch,fbranch,call,sibcall,dyncall,multi,milli,sh_func_adrs,parallel_branch,trap")
171                      (eq_attr "length" "4")
172                      (not (match_test "RTX_FRAME_RELATED_P (insn)")))
173                 (const_string "true")
174                 (const_string "false")))
176 ;; Disallow instructions which use the FPU since they will tie up the FPU
177 ;; even if the instruction is nullified.
178 (define_attr "in_nullified_branch_delay" "false,true"
179   (if_then_else (and (eq_attr "type" "!uncond_branch,branch,cbranch,fbranch,call,sibcall,dyncall,multi,milli,sh_func_adrs,fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpdivdbl,fpsqrtsgl,fpsqrtdbl,parallel_branch,trap")
180                      (eq_attr "length" "4")
181                      (not (match_test "RTX_FRAME_RELATED_P (insn)")))
182                 (const_string "true")
183                 (const_string "false")))
185 ;; For calls and millicode calls.
186 (define_attr "in_call_delay" "false,true"
187   (if_then_else (and (eq_attr "type" "!uncond_branch,branch,cbranch,fbranch,call,sibcall,dyncall,multi,milli,sh_func_adrs,parallel_branch,trap")
188                      (eq_attr "length" "4")
189                      (not (match_test "RTX_FRAME_RELATED_P (insn)")))
190                 (const_string "true")
191                 (const_string "false")))
193 ;; Call delay slot description.
194 (define_delay (eq_attr "type" "call")
195   [(eq_attr "in_call_delay" "true") (nil) (nil)])
197 ;; Sibcall delay slot description.
198 (define_delay (eq_attr "type" "sibcall")
199   [(eq_attr "in_call_delay" "true") (nil) (nil)])
201 ;; Millicode call delay slot description.
202 (define_delay (eq_attr "type" "milli")
203   [(eq_attr "in_call_delay" "true") (nil) (nil)])
205 ;; Return and other similar instructions.
206 (define_delay (eq_attr "type" "branch,parallel_branch")
207   [(eq_attr "in_branch_delay" "true") (nil) (nil)])
209 ;; Floating point conditional branch delay slot description.
210 (define_delay (eq_attr "type" "fbranch")
211   [(eq_attr "in_branch_delay" "true")
212    (eq_attr "in_nullified_branch_delay" "true")
213    (nil)])
215 ;; Integer conditional branch delay slot description.
216 ;; Nullification of conditional branches on the PA is dependent on the
217 ;; direction of the branch.  Forward branches nullify true and
218 ;; backward branches nullify false.  If the direction is unknown
219 ;; then nullification is not allowed.
220 (define_delay (eq_attr "type" "cbranch")
221   [(eq_attr "in_branch_delay" "true")
222    (and (eq_attr "in_nullified_branch_delay" "true")
223         (attr_flag "forward"))
224    (and (eq_attr "in_nullified_branch_delay" "true")
225         (attr_flag "backward"))])
227 (define_delay (eq_attr "type" "uncond_branch")
228   [(eq_attr "in_branch_delay" "true") (nil) (nil)])
230 ;; Memory. Disregarding Cache misses, the Mustang memory times are:
231 ;; load: 2, fpload: 3
232 ;; store, fpstore: 3, no D-cache operations should be scheduled.
234 ;; The Timex (aka 700) has two floating-point units: ALU, and MUL/DIV/SQRT.
235 ;; Timings:
236 ;; Instruction  Time    Unit    Minimum Distance (unit contention)
237 ;; fcpy         3       ALU     2
238 ;; fabs         3       ALU     2
239 ;; fadd         3       ALU     2
240 ;; fsub         3       ALU     2
241 ;; fcmp         3       ALU     2
242 ;; fcnv         3       ALU     2
243 ;; fmpyadd      3       ALU,MPY 2
244 ;; fmpysub      3       ALU,MPY 2
245 ;; fmpycfxt     3       ALU,MPY 2
246 ;; fmpy         3       MPY     2
247 ;; fmpyi        3       MPY     2
248 ;; fdiv,sgl     10      MPY     10
249 ;; fdiv,dbl     12      MPY     12
250 ;; fsqrt,sgl    14      MPY     14
251 ;; fsqrt,dbl    18      MPY     18
253 ;; We don't model fmpyadd/fmpysub properly as those instructions
254 ;; keep both the FP ALU and MPY units busy.  Given that these
255 ;; processors are obsolete, I'm not going to spend the time to
256 ;; model those instructions correctly.
258 (define_automaton "pa700")
259 (define_cpu_unit "dummy_700,mem_700,fpalu_700,fpmpy_700" "pa700")
261 (define_insn_reservation "W0" 4
262   (and (eq_attr "type" "fpcc")
263        (eq_attr "cpu" "700"))
264   "fpalu_700*2")
266 (define_insn_reservation "W1" 3
267   (and (eq_attr "type" "fpalu")
268        (eq_attr "cpu" "700"))
269   "fpalu_700*2")
271 (define_insn_reservation "W2" 3
272   (and (eq_attr "type" "fpmulsgl,fpmuldbl")
273        (eq_attr "cpu" "700"))
274   "fpmpy_700*2")
276 (define_insn_reservation "W3" 10
277   (and (eq_attr "type" "fpdivsgl")
278        (eq_attr "cpu" "700"))
279   "fpmpy_700*10")
281 (define_insn_reservation "W4" 12
282   (and (eq_attr "type" "fpdivdbl")
283        (eq_attr "cpu" "700"))
284   "fpmpy_700*12")
286 (define_insn_reservation "W5" 14
287   (and (eq_attr "type" "fpsqrtsgl")
288        (eq_attr "cpu" "700"))
289   "fpmpy_700*14")
291 (define_insn_reservation "W6" 18
292   (and (eq_attr "type" "fpsqrtdbl")
293        (eq_attr "cpu" "700"))
294   "fpmpy_700*18")
296 (define_insn_reservation "W7" 2
297   (and (eq_attr "type" "load")
298        (eq_attr "cpu" "700"))
299   "mem_700")
301 (define_insn_reservation "W8" 2
302   (and (eq_attr "type" "fpload")
303        (eq_attr "cpu" "700"))
304   "mem_700")
306 (define_insn_reservation "W9" 3
307   (and (eq_attr "type" "store")
308        (eq_attr "cpu" "700"))
309   "mem_700*3")
311 (define_insn_reservation "W10" 3
312   (and (eq_attr "type" "fpstore")
313        (eq_attr "cpu" "700"))
314   "mem_700*3")
316 (define_insn_reservation "W11" 5
317   (and (eq_attr "type" "fpstore_load")
318        (eq_attr "cpu" "700"))
319   "mem_700*5")
321 (define_insn_reservation "W12" 6
322   (and (eq_attr "type" "store_fpload")
323        (eq_attr "cpu" "700"))
324   "mem_700*6")
326 (define_insn_reservation "W13" 1
327   (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpdivdbl,fpsqrtsgl,fpsqrtdbl,load,fpload,store,fpstore,fpstore_load,store_fpload")
328        (eq_attr "cpu" "700"))
329   "dummy_700")
331 ;; We have a bypass for all computations in the FP unit which feed an
332 ;; FP store as long as the sizes are the same.
333 (define_bypass 2 "W1,W2" "W10,W11" "pa_fpstore_bypass_p")
334 (define_bypass 9 "W3" "W10,W11" "pa_fpstore_bypass_p")
335 (define_bypass 11 "W4" "W10,W11" "pa_fpstore_bypass_p")
336 (define_bypass 13 "W5" "W10,W11" "pa_fpstore_bypass_p")
337 (define_bypass 17 "W6" "W10,W11" "pa_fpstore_bypass_p")
339 ;; We have an "anti-bypass" for FP loads which feed an FP store.
340 (define_bypass 4 "W8,W12" "W10,W11" "pa_fpstore_bypass_p")
342 ;; Function units for the 7100 and 7150.  The 7100/7150 can dual-issue
343 ;; floating point computations with non-floating point computations (fp loads
344 ;; and stores are not fp computations).
346 ;; Memory. Disregarding Cache misses, memory loads take two cycles; stores also
347 ;; take two cycles, during which no Dcache operations should be scheduled.
348 ;; Any special cases are handled in pa_adjust_cost.  The 7100, 7150 and 7100LC
349 ;; all have the same memory characteristics if one disregards cache misses.
351 ;; The 7100/7150 has three floating-point units: ALU, MUL, and DIV.
352 ;; There's no value in modeling the ALU and MUL separately though
353 ;; since there can never be a functional unit conflict given the
354 ;; latency and issue rates for those units.
356 ;; Timings:
357 ;; Instruction  Time    Unit    Minimum Distance (unit contention)
358 ;; fcpy         2       ALU     1
359 ;; fabs         2       ALU     1
360 ;; fadd         2       ALU     1
361 ;; fsub         2       ALU     1
362 ;; fcmp         2       ALU     1
363 ;; fcnv         2       ALU     1
364 ;; fmpyadd      2       ALU,MPY 1
365 ;; fmpysub      2       ALU,MPY 1
366 ;; fmpycfxt     2       ALU,MPY 1
367 ;; fmpy         2       MPY     1
368 ;; fmpyi        2       MPY     1
369 ;; fdiv,sgl     8       DIV     8
370 ;; fdiv,dbl     15      DIV     15
371 ;; fsqrt,sgl    8       DIV     8
372 ;; fsqrt,dbl    15      DIV     15
374 (define_automaton "pa7100")
375 (define_cpu_unit "i_7100, f_7100,fpmac_7100,fpdivsqrt_7100,mem_7100" "pa7100")
377 (define_insn_reservation "X0" 2
378   (and (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
379        (eq_attr "cpu" "7100"))
380   "f_7100,fpmac_7100")
382 (define_insn_reservation "X1" 8
383   (and (eq_attr "type" "fpdivsgl,fpsqrtsgl")
384        (eq_attr "cpu" "7100"))
385   "f_7100+fpdivsqrt_7100,fpdivsqrt_7100*7")
387 (define_insn_reservation "X2" 15
388   (and (eq_attr "type" "fpdivdbl,fpsqrtdbl")
389        (eq_attr "cpu" "7100"))
390   "f_7100+fpdivsqrt_7100,fpdivsqrt_7100*14")
392 (define_insn_reservation "X3" 2
393   (and (eq_attr "type" "load")
394        (eq_attr "cpu" "7100"))
395   "i_7100+mem_7100")
397 (define_insn_reservation "X4" 2
398   (and (eq_attr "type" "fpload")
399        (eq_attr "cpu" "7100"))
400   "i_7100+mem_7100")
402 (define_insn_reservation "X5" 2
403   (and (eq_attr "type" "store")
404        (eq_attr "cpu" "7100"))
405   "i_7100+mem_7100,mem_7100")
407 (define_insn_reservation "X6" 2
408   (and (eq_attr "type" "fpstore")
409        (eq_attr "cpu" "7100"))
410   "i_7100+mem_7100,mem_7100")
412 (define_insn_reservation "X7" 4
413   (and (eq_attr "type" "fpstore_load")
414        (eq_attr "cpu" "7100"))
415   "i_7100+mem_7100,mem_7100*3")
417 (define_insn_reservation "X8" 4
418   (and (eq_attr "type" "store_fpload")
419        (eq_attr "cpu" "7100"))
420   "i_7100+mem_7100,mem_7100*3")
422 (define_insn_reservation "X9" 1
423   (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl,load,fpload,store,fpstore,fpstore_load,store_fpload")
424        (eq_attr "cpu" "7100"))
425   "i_7100")
427 ;; We have a bypass for all computations in the FP unit which feed an
428 ;; FP store as long as the sizes are the same.
429 (define_bypass 1 "X0" "X6,X7" "pa_fpstore_bypass_p")
430 (define_bypass 7 "X1" "X6,X7" "pa_fpstore_bypass_p")
431 (define_bypass 14 "X2" "X6,X7" "pa_fpstore_bypass_p")
433 ;; We have an "anti-bypass" for FP loads which feed an FP store.
434 (define_bypass 3 "X4,X8" "X6,X7" "pa_fpstore_bypass_p")
436 ;; The 7100LC has three floating-point units: ALU, MUL, and DIV.
437 ;; There's no value in modeling the ALU and MUL separately though
438 ;; since there can never be a functional unit conflict that
439 ;; can be avoided given the latency, issue rates and mandatory
440 ;; one cycle cpu-wide lock for a double precision fp multiply.
442 ;; Timings:
443 ;; Instruction  Time    Unit    Minimum Distance (unit contention)
444 ;; fcpy         2       ALU     1
445 ;; fabs         2       ALU     1
446 ;; fadd         2       ALU     1
447 ;; fsub         2       ALU     1
448 ;; fcmp         2       ALU     1
449 ;; fcnv         2       ALU     1
450 ;; fmpyadd,sgl  2       ALU,MPY 1
451 ;; fmpyadd,dbl  3       ALU,MPY 2
452 ;; fmpysub,sgl  2       ALU,MPY 1
453 ;; fmpysub,dbl  3       ALU,MPY 2
454 ;; fmpycfxt,sgl 2       ALU,MPY 1
455 ;; fmpycfxt,dbl 3       ALU,MPY 2
456 ;; fmpy,sgl     2       MPY     1
457 ;; fmpy,dbl     3       MPY     2
458 ;; fmpyi        3       MPY     2
459 ;; fdiv,sgl     8       DIV     8
460 ;; fdiv,dbl     15      DIV     15
461 ;; fsqrt,sgl    8       DIV     8
462 ;; fsqrt,dbl    15      DIV     15
464 ;; The PA7200 is just like the PA7100LC except that there is
465 ;; no store-store penalty.
467 ;; The PA7300 is just like the PA7200 except that there is
468 ;; no store-load penalty.
470 ;; Note there are some aspects of the 7100LC we are not modeling
471 ;; at the moment.  I'll be reviewing the 7100LC scheduling info
472 ;; shortly and updating this description.
474 ;;   load-load pairs
475 ;;   store-store pairs
476 ;;   other issue modeling
478 (define_automaton "pa7100lc")
479 (define_cpu_unit "i0_7100lc, i1_7100lc, f_7100lc" "pa7100lc")
480 (define_cpu_unit "fpmac_7100lc" "pa7100lc")
481 (define_cpu_unit "mem_7100lc" "pa7100lc")
483 ;; Double precision multiplies lock the entire CPU for one
484 ;; cycle.  There is no way to avoid this lock and trying to
485 ;; schedule around the lock is pointless and thus there is no
486 ;; value in trying to model this lock.
488 ;; Not modeling the lock allows us to treat fp multiplies just
489 ;; like any other FP alu instruction.  It allows for a smaller
490 ;; DFA and may reduce register pressure.
491 (define_insn_reservation "Y0" 2
492   (and (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
493        (eq_attr "cpu" "7100LC,7200,7300"))
494   "f_7100lc,fpmac_7100lc")
496 ;; fp division and sqrt instructions lock the entire CPU for
497 ;; 7 cycles (single precision) or 14 cycles (double precision).
498 ;; There is no way to avoid this lock and trying to schedule
499 ;; around the lock is pointless and thus there is no value in
500 ;; trying to model this lock.  Not modeling the lock allows
501 ;; for a smaller DFA and may reduce register pressure.
502 (define_insn_reservation "Y1" 1
503   (and (eq_attr "type" "fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl")
504        (eq_attr "cpu" "7100LC,7200,7300"))
505   "f_7100lc")
507 (define_insn_reservation "Y2" 2
508   (and (eq_attr "type" "load")
509        (eq_attr "cpu" "7100LC,7200,7300"))
510   "i1_7100lc+mem_7100lc")
512 (define_insn_reservation "Y3" 2
513   (and (eq_attr "type" "fpload")
514        (eq_attr "cpu" "7100LC,7200,7300"))
515   "i1_7100lc+mem_7100lc")
517 (define_insn_reservation "Y4" 2
518   (and (eq_attr "type" "store")
519        (eq_attr "cpu" "7100LC"))
520   "i1_7100lc+mem_7100lc,mem_7100lc")
522 (define_insn_reservation "Y5" 2
523   (and (eq_attr "type" "fpstore")
524        (eq_attr "cpu" "7100LC"))
525   "i1_7100lc+mem_7100lc,mem_7100lc")
527 (define_insn_reservation "Y6" 4
528   (and (eq_attr "type" "fpstore_load")
529        (eq_attr "cpu" "7100LC"))
530   "i1_7100lc+mem_7100lc,mem_7100lc*3")
532 (define_insn_reservation "Y7" 4
533   (and (eq_attr "type" "store_fpload")
534        (eq_attr "cpu" "7100LC"))
535   "i1_7100lc+mem_7100lc,mem_7100lc*3")
537 (define_insn_reservation "Y8" 1
538   (and (eq_attr "type" "shift,nullshift")
539        (eq_attr "cpu" "7100LC,7200,7300"))
540   "i1_7100lc")
542 (define_insn_reservation "Y9" 1
543   (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl,load,fpload,store,fpstore,shift,nullshift")
544        (eq_attr "cpu" "7100LC,7200,7300"))
545   "(i0_7100lc|i1_7100lc)")
547 ;; The 7200 has a store-load penalty
548 (define_insn_reservation "Y10" 2
549   (and (eq_attr "type" "store")
550        (eq_attr "cpu" "7200"))
551   "i1_7100lc,mem_7100lc")
553 (define_insn_reservation "Y11" 2
554   (and (eq_attr "type" "fpstore")
555        (eq_attr "cpu" "7200"))
556   "i1_7100lc,mem_7100lc")
558 (define_insn_reservation "Y12" 4
559   (and (eq_attr "type" "fpstore_load")
560        (eq_attr "cpu" "7200"))
561   "i1_7100lc,mem_7100lc,i1_7100lc+mem_7100lc")
563 (define_insn_reservation "Y13" 4
564   (and (eq_attr "type" "store_fpload")
565        (eq_attr "cpu" "7200"))
566   "i1_7100lc,mem_7100lc,i1_7100lc+mem_7100lc")
568 ;; The 7300 has no penalty for store-store or store-load
569 (define_insn_reservation "Y14" 2
570   (and (eq_attr "type" "store")
571        (eq_attr "cpu" "7300"))
572   "i1_7100lc")
574 (define_insn_reservation "Y15" 2
575   (and (eq_attr "type" "fpstore")
576        (eq_attr "cpu" "7300"))
577   "i1_7100lc")
579 (define_insn_reservation "Y16" 4
580   (and (eq_attr "type" "fpstore_load")
581        (eq_attr "cpu" "7300"))
582   "i1_7100lc,i1_7100lc+mem_7100lc")
584 (define_insn_reservation "Y17" 4
585   (and (eq_attr "type" "store_fpload")
586        (eq_attr "cpu" "7300"))
587   "i1_7100lc,i1_7100lc+mem_7100lc")
589 ;; We have an "anti-bypass" for FP loads which feed an FP store.
590 (define_bypass 3 "Y3,Y7,Y13,Y17" "Y5,Y6,Y11,Y12,Y15,Y16" "pa_fpstore_bypass_p")
592 ;; Scheduling for the PA8000 is somewhat different than scheduling for a
593 ;; traditional architecture.
595 ;; The PA8000 has a large (56) entry reorder buffer that is split between
596 ;; memory and non-memory operations.
598 ;; The PA8000 can issue two memory and two non-memory operations per cycle to
599 ;; the function units, with the exception of branches and multi-output
600 ;; instructions.  The PA8000 can retire two non-memory operations per cycle
601 ;; and two memory operations per cycle, only one of which may be a store.
603 ;; Given the large reorder buffer, the processor can hide most latencies.
604 ;; According to HP, they've got the best results by scheduling for retirement
605 ;; bandwidth with limited latency scheduling for floating point operations.
606 ;; Latency for integer operations and memory references is ignored.
609 ;; We claim floating point operations have a 2 cycle latency and are
610 ;; fully pipelined, except for div and sqrt which are not pipelined and
611 ;; take from 17 to 31 cycles to complete.
613 ;; It's worth noting that there is no way to saturate all the functional
614 ;; units on the PA8000 as there is not enough issue bandwidth.
616 (define_automaton "pa8000")
617 (define_cpu_unit "inm0_8000, inm1_8000, im0_8000, im1_8000" "pa8000")
618 (define_cpu_unit "rnm0_8000, rnm1_8000, rm0_8000, rm1_8000" "pa8000")
619 (define_cpu_unit "store_8000" "pa8000")
620 (define_cpu_unit "f0_8000, f1_8000" "pa8000")
621 (define_cpu_unit "fdivsqrt0_8000, fdivsqrt1_8000" "pa8000")
622 (define_reservation "inm_8000" "inm0_8000 | inm1_8000")
623 (define_reservation "im_8000" "im0_8000 | im1_8000")
624 (define_reservation "rnm_8000" "rnm0_8000 | rnm1_8000")
625 (define_reservation "rm_8000" "rm0_8000 | rm1_8000")
626 (define_reservation "f_8000" "f0_8000 | f1_8000")
627 (define_reservation "fdivsqrt_8000" "fdivsqrt0_8000 | fdivsqrt1_8000")
629 ;; We can issue any two memops per cycle, but we can only retire
630 ;; one memory store per cycle.  We assume that the reorder buffer
631 ;; will hide any memory latencies per HP's recommendation.
632 (define_insn_reservation "Z0" 0
633   (and
634     (eq_attr "type" "load,fpload")
635     (eq_attr "cpu" "8000"))
636   "im_8000,rm_8000")
638 (define_insn_reservation "Z1" 0
639   (and
640     (eq_attr "type" "store,fpstore")
641     (eq_attr "cpu" "8000"))
642   "im_8000,rm_8000+store_8000")
644 (define_insn_reservation "Z2" 0
645   (and (eq_attr "type" "fpstore_load,store_fpload")
646        (eq_attr "cpu" "8000"))
647   "im_8000,rm_8000+store_8000,im_8000,rm_8000")
649 ;; We can issue and retire two non-memory operations per cycle with
650 ;; a few exceptions (branches).  This group catches those we want
651 ;; to assume have zero latency.
652 (define_insn_reservation "Z3" 0
653   (and
654     (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")
655     (eq_attr "cpu" "8000"))
656   "inm_8000,rnm_8000")
658 ;; Branches use both slots in the non-memory issue and
659 ;; retirement unit.
660 (define_insn_reservation "Z4" 0
661   (and
662     (eq_attr "type" "uncond_branch,branch,cbranch,fbranch,call,sibcall,dyncall,multi,milli,sh_func_adrs,parallel_branch")
663     (eq_attr "cpu" "8000"))
664   "inm0_8000+inm1_8000,rnm0_8000+rnm1_8000")
666 ;; We partial latency schedule the floating point units.
667 ;; They can issue/retire two at a time in the non-memory
668 ;; units.  We fix their latency at 2 cycles and they
669 ;; are fully pipelined.
670 (define_insn_reservation "Z5" 1
671  (and
672    (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
673    (eq_attr "cpu" "8000"))
674  "inm_8000,f_8000,rnm_8000")
676 ;; The fdivsqrt units are not pipelined and have a very long latency.  
677 ;; To keep the DFA from exploding, we do not show all the
678 ;; reservations for the divsqrt unit.
679 (define_insn_reservation "Z6" 17
680  (and
681    (eq_attr "type" "fpdivsgl,fpsqrtsgl")
682    (eq_attr "cpu" "8000"))
683  "inm_8000,fdivsqrt_8000*6,rnm_8000")
685 (define_insn_reservation "Z7" 31
686  (and
687    (eq_attr "type" "fpdivdbl,fpsqrtdbl")
688    (eq_attr "cpu" "8000"))
689  "inm_8000,fdivsqrt_8000*6,rnm_8000")
691 ;; Operand and operator predicates and constraints
693 (include "predicates.md")
694 (include "constraints.md")
696 ;; Compare instructions.
697 ;; This controls RTL generation and register allocation.
699 (define_insn ""
700   [(set (reg:CCFP 0)
701         (match_operator:CCFP 2 "comparison_operator"
702                              [(match_operand:SF 0 "reg_or_0_operand" "fG")
703                               (match_operand:SF 1 "reg_or_0_operand" "fG")]))]
704   "! TARGET_SOFT_FLOAT"
705   "fcmp,sgl,%Y2 %f0,%f1"
706   [(set_attr "length" "4")
707    (set_attr "type" "fpcc")])
709 (define_insn ""
710   [(set (reg:CCFP 0)
711         (match_operator:CCFP 2 "comparison_operator"
712                              [(match_operand:DF 0 "reg_or_0_operand" "fG")
713                               (match_operand:DF 1 "reg_or_0_operand" "fG")]))]
714   "! TARGET_SOFT_FLOAT"
715   "fcmp,dbl,%Y2 %f0,%f1"
716   [(set_attr "length" "4")
717    (set_attr "type" "fpcc")])
719 ;; Provide a means to emit the movccfp0 and movccfp1 optimization
720 ;; placeholders.  This is necessary in rare situations when a
721 ;; placeholder is re-emitted (see PR 8705).
723 (define_expand "movccfp"
724   [(set (reg:CCFP 0)
725         (match_operand 0 "const_int_operand" ""))]
726   "! TARGET_SOFT_FLOAT"
727   "
729   if ((unsigned HOST_WIDE_INT) INTVAL (operands[0]) > 1)
730     FAIL;
733 ;; The following patterns are optimization placeholders.  In almost
734 ;; all cases, the user of the condition code will be simplified and the
735 ;; original condition code setting insn should be eliminated.
737 (define_insn "*movccfp0"
738   [(set (reg:CCFP 0)
739         (const_int 0))]
740   "! TARGET_SOFT_FLOAT"
741   "fcmp,dbl,= %%fr0,%%fr0"
742   [(set_attr "length" "4")
743    (set_attr "type" "fpcc")])
745 (define_insn "*movccfp1"
746   [(set (reg:CCFP 0)
747         (const_int 1))]
748   "! TARGET_SOFT_FLOAT"
749   "fcmp,dbl,!= %%fr0,%%fr0"
750   [(set_attr "length" "4")
751    (set_attr "type" "fpcc")])
753 ;; scc insns.
755 (define_expand "cstoresi4"
756   [(set (match_operand:SI 0 "register_operand")
757         (match_operator:SI 1 "ordered_comparison_operator"
758          [(match_operand:SI 2 "reg_or_0_operand" "")
759           (match_operand:SI 3 "arith5_operand" "")]))]
760   "!TARGET_64BIT"
761   "")
763 ;; Instruction canonicalization puts immediate operands second, which
764 ;; is the reverse of what we want.
766 (define_insn "scc"
767   [(set (match_operand:SI 0 "register_operand" "=r")
768         (match_operator:SI 3 "ordered_comparison_operator"
769                            [(match_operand:SI 1 "reg_or_0_operand" "rM")
770                             (match_operand:SI 2 "arith11_operand" "rI")]))]
771   ""
772   "{com%I2clr|cmp%I2clr},%B3 %2,%r1,%0\;ldi 1,%0"
773   [(set_attr "type" "binary")
774    (set_attr "length" "8")])
776 (define_insn ""
777   [(set (match_operand:DI 0 "register_operand" "=r")
778         (match_operator:DI 3 "ordered_comparison_operator"
779                            [(match_operand:DI 1 "reg_or_0_operand" "rM")
780                             (match_operand:DI 2 "arith11_operand" "rI")]))]
781   "TARGET_64BIT"
782   "cmp%I2clr,*%B3 %2,%r1,%0\;ldi 1,%0"
783   [(set_attr "type" "binary")
784    (set_attr "length" "8")])
786 (define_insn "iorscc"
787   [(set (match_operand:SI 0 "register_operand" "=r")
788         (ior:SI (match_operator:SI 3 "ordered_comparison_operator"
789                                    [(match_operand:SI 1 "reg_or_0_operand" "rM")
790                                     (match_operand:SI 2 "arith11_operand" "rI")])
791                 (match_operator:SI 6 "ordered_comparison_operator"
792                                    [(match_operand:SI 4 "reg_or_0_operand" "rM")
793                                     (match_operand:SI 5 "arith11_operand" "rI")])))]
794   ""
795   "{com%I2clr|cmp%I2clr},%S3 %2,%r1,%%r0\;{com%I5clr|cmp%I5clr},%B6 %5,%r4,%0\;ldi 1,%0"
796   [(set_attr "type" "binary")
797    (set_attr "length" "12")])
799 (define_insn ""
800   [(set (match_operand:DI 0 "register_operand" "=r")
801         (ior:DI (match_operator:DI 3 "ordered_comparison_operator"
802                                    [(match_operand:DI 1 "reg_or_0_operand" "rM")
803                                     (match_operand:DI 2 "arith11_operand" "rI")])
804                 (match_operator:DI 6 "ordered_comparison_operator"
805                                    [(match_operand:DI 4 "reg_or_0_operand" "rM")
806                                     (match_operand:DI 5 "arith11_operand" "rI")])))]
807   "TARGET_64BIT"
808   "cmp%I2clr,*%S3 %2,%r1,%%r0\;cmp%I5clr,*%B6 %5,%r4,%0\;ldi 1,%0"
809   [(set_attr "type" "binary")
810    (set_attr "length" "12")])
812 ;; Combiner patterns for common operations performed with the output
813 ;; from an scc insn (negscc and incscc).
814 (define_insn "negscc"
815   [(set (match_operand:SI 0 "register_operand" "=r")
816         (neg:SI (match_operator:SI 3 "ordered_comparison_operator"
817                [(match_operand:SI 1 "reg_or_0_operand" "rM")
818                 (match_operand:SI 2 "arith11_operand" "rI")])))]
819   ""
820   "{com%I2clr|cmp%I2clr},%B3 %2,%r1,%0\;ldi -1,%0"
821   [(set_attr "type" "binary")
822    (set_attr "length" "8")])
824 (define_insn ""
825   [(set (match_operand:DI 0 "register_operand" "=r")
826         (neg:DI (match_operator:DI 3 "ordered_comparison_operator"
827                [(match_operand:DI 1 "reg_or_0_operand" "rM")
828                 (match_operand:DI 2 "arith11_operand" "rI")])))]
829   "TARGET_64BIT"
830   "cmp%I2clr,*%B3 %2,%r1,%0\;ldi -1,%0"
831   [(set_attr "type" "binary")
832    (set_attr "length" "8")])
834 ;; Patterns for adding/subtracting the result of a boolean expression from
835 ;; a register.  First we have special patterns that make use of the carry
836 ;; bit, and output only two instructions.  For the cases we can't in
837 ;; general do in two instructions, the incscc pattern at the end outputs
838 ;; two or three instructions.
840 (define_insn ""
841   [(set (match_operand:SI 0 "register_operand" "=r")
842         (plus:SI (leu:SI (match_operand:SI 2 "register_operand" "r")
843                          (match_operand:SI 3 "arith11_operand" "rI"))
844                  (match_operand:SI 1 "register_operand" "r")))]
845   ""
846   "sub%I3 %3,%2,%%r0\;{addc|add,c} %%r0,%1,%0"
847   [(set_attr "type" "binary")
848    (set_attr "length" "8")])
850 (define_insn ""
851   [(set (match_operand:DI 0 "register_operand" "=r")
852         (plus:DI (leu:DI (match_operand:DI 2 "register_operand" "r")
853                          (match_operand:DI 3 "arith11_operand" "rI"))
854                  (match_operand:DI 1 "register_operand" "r")))]
855   "TARGET_64BIT"
856   "sub%I3 %3,%2,%%r0\;add,dc %%r0,%1,%0"
857   [(set_attr "type" "binary")
858    (set_attr "length" "8")])
860 ; This need only accept registers for op3, since canonicalization
861 ; replaces geu with gtu when op3 is an integer.
862 (define_insn ""
863   [(set (match_operand:SI 0 "register_operand" "=r")
864         (plus:SI (geu:SI (match_operand:SI 2 "register_operand" "r")
865                          (match_operand:SI 3 "register_operand" "r"))
866                  (match_operand:SI 1 "register_operand" "r")))]
867   ""
868   "sub %2,%3,%%r0\;{addc|add,c} %%r0,%1,%0"
869   [(set_attr "type" "binary")
870    (set_attr "length" "8")])
872 (define_insn ""
873   [(set (match_operand:DI 0 "register_operand" "=r")
874         (plus:DI (geu:DI (match_operand:DI 2 "register_operand" "r")
875                          (match_operand:DI 3 "register_operand" "r"))
876                  (match_operand:DI 1 "register_operand" "r")))]
877   "TARGET_64BIT"
878   "sub %2,%3,%%r0\;add,dc %%r0,%1,%0"
879   [(set_attr "type" "binary")
880    (set_attr "length" "8")])
882 ; Match only integers for op3 here.  This is used as canonical form of the
883 ; geu pattern when op3 is an integer.  Don't match registers since we can't
884 ; make better code than the general incscc pattern.
885 (define_insn ""
886   [(set (match_operand:SI 0 "register_operand" "=r")
887         (plus:SI (gtu:SI (match_operand:SI 2 "register_operand" "r")
888                          (match_operand:SI 3 "int11_operand" "I"))
889                  (match_operand:SI 1 "register_operand" "r")))]
890   ""
891   "addi %k3,%2,%%r0\;{addc|add,c} %%r0,%1,%0"
892   [(set_attr "type" "binary")
893    (set_attr "length" "8")])
895 (define_insn ""
896   [(set (match_operand:DI 0 "register_operand" "=r")
897         (plus:DI (gtu:DI (match_operand:DI 2 "register_operand" "r")
898                          (match_operand:DI 3 "int11_operand" "I"))
899                  (match_operand:DI 1 "register_operand" "r")))]
900   "TARGET_64BIT"
901   "addi %k3,%2,%%r0\;add,dc %%r0,%1,%0"
902   [(set_attr "type" "binary")
903    (set_attr "length" "8")])
905 (define_insn "incscc"
906   [(set (match_operand:SI 0 "register_operand" "=r,r")
907         (plus:SI (match_operator:SI 4 "ordered_comparison_operator"
908                     [(match_operand:SI 2 "register_operand" "r,r")
909                      (match_operand:SI 3 "arith11_operand" "rI,rI")])
910                  (match_operand:SI 1 "register_operand" "0,?r")))]
911   ""
912   "@
913    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi 1,%0,%0
914    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi,tr 1,%1,%0\;copy %1,%0"
915   [(set_attr "type" "binary,binary")
916    (set_attr "length" "8,12")])
918 (define_insn ""
919   [(set (match_operand:DI 0 "register_operand" "=r,r")
920         (plus:DI (match_operator:DI 4 "ordered_comparison_operator"
921                     [(match_operand:DI 2 "register_operand" "r,r")
922                      (match_operand:DI 3 "arith11_operand" "rI,rI")])
923                  (match_operand:DI 1 "register_operand" "0,?r")))]
924   "TARGET_64BIT"
925   "@
926    cmp%I3clr,*%B4 %3,%2,%%r0\;addi 1,%0,%0
927    cmp%I3clr,*%B4 %3,%2,%%r0\;addi,tr 1,%1,%0\;copy %1,%0"
928   [(set_attr "type" "binary,binary")
929    (set_attr "length" "8,12")])
931 (define_insn ""
932   [(set (match_operand:SI 0 "register_operand" "=r")
933         (minus:SI (match_operand:SI 1 "register_operand" "r")
934                   (gtu:SI (match_operand:SI 2 "register_operand" "r")
935                           (match_operand:SI 3 "arith11_operand" "rI"))))]
936   ""
937   "sub%I3 %3,%2,%%r0\;{subb|sub,b} %1,%%r0,%0"
938   [(set_attr "type" "binary")
939    (set_attr "length" "8")])
941 (define_insn ""
942   [(set (match_operand:DI 0 "register_operand" "=r")
943         (minus:DI (match_operand:DI 1 "register_operand" "r")
944                   (gtu:DI (match_operand:DI 2 "register_operand" "r")
945                           (match_operand:DI 3 "arith11_operand" "rI"))))]
946   "TARGET_64BIT"
947   "sub%I3 %3,%2,%%r0\;sub,db %1,%%r0,%0"
948   [(set_attr "type" "binary")
949    (set_attr "length" "8")])
951 (define_insn ""
952   [(set (match_operand:SI 0 "register_operand" "=r")
953         (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
954                             (gtu:SI (match_operand:SI 2 "register_operand" "r")
955                                     (match_operand:SI 3 "arith11_operand" "rI")))
956                   (match_operand:SI 4 "register_operand" "r")))]
957   ""
958   "sub%I3 %3,%2,%%r0\;{subb|sub,b} %1,%4,%0"
959   [(set_attr "type" "binary")
960    (set_attr "length" "8")])
962 (define_insn ""
963   [(set (match_operand:DI 0 "register_operand" "=r")
964         (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
965                             (gtu:DI (match_operand:DI 2 "register_operand" "r")
966                                     (match_operand:DI 3 "arith11_operand" "rI")))
967                   (match_operand:DI 4 "register_operand" "r")))]
968   "TARGET_64BIT"
969   "sub%I3 %3,%2,%%r0\;sub,db %1,%4,%0"
970   [(set_attr "type" "binary")
971    (set_attr "length" "8")])
973 ; This need only accept registers for op3, since canonicalization
974 ; replaces ltu with leu when op3 is an integer.
975 (define_insn ""
976   [(set (match_operand:SI 0 "register_operand" "=r")
977         (minus:SI (match_operand:SI 1 "register_operand" "r")
978                   (ltu:SI (match_operand:SI 2 "register_operand" "r")
979                           (match_operand:SI 3 "register_operand" "r"))))]
980   ""
981   "sub %2,%3,%%r0\;{subb|sub,b} %1,%%r0,%0"
982   [(set_attr "type" "binary")
983    (set_attr "length" "8")])
985 (define_insn ""
986   [(set (match_operand:DI 0 "register_operand" "=r")
987         (minus:DI (match_operand:DI 1 "register_operand" "r")
988                   (ltu:DI (match_operand:DI 2 "register_operand" "r")
989                           (match_operand:DI 3 "register_operand" "r"))))]
990   "TARGET_64BIT"
991   "sub %2,%3,%%r0\;sub,db %1,%%r0,%0"
992   [(set_attr "type" "binary")
993    (set_attr "length" "8")])
995 (define_insn ""
996   [(set (match_operand:SI 0 "register_operand" "=r")
997         (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
998                             (ltu:SI (match_operand:SI 2 "register_operand" "r")
999                                     (match_operand:SI 3 "register_operand" "r")))
1000                   (match_operand:SI 4 "register_operand" "r")))]
1001   ""
1002   "sub %2,%3,%%r0\;{subb|sub,b} %1,%4,%0"
1003   [(set_attr "type" "binary")
1004    (set_attr "length" "8")])
1006 (define_insn ""
1007   [(set (match_operand:DI 0 "register_operand" "=r")
1008         (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
1009                             (ltu:DI (match_operand:DI 2 "register_operand" "r")
1010                                     (match_operand:DI 3 "register_operand" "r")))
1011                   (match_operand:DI 4 "register_operand" "r")))]
1012   "TARGET_64BIT"
1013   "sub %2,%3,%%r0\;sub,db %1,%4,%0"
1014   [(set_attr "type" "binary")
1015    (set_attr "length" "8")])
1017 ; Match only integers for op3 here.  This is used as canonical form of the
1018 ; ltu pattern when op3 is an integer.  Don't match registers since we can't
1019 ; make better code than the general incscc pattern.
1020 (define_insn ""
1021   [(set (match_operand:SI 0 "register_operand" "=r")
1022         (minus:SI (match_operand:SI 1 "register_operand" "r")
1023                   (leu:SI (match_operand:SI 2 "register_operand" "r")
1024                           (match_operand:SI 3 "int11_operand" "I"))))]
1025   ""
1026   "addi %k3,%2,%%r0\;{subb|sub,b} %1,%%r0,%0"
1027   [(set_attr "type" "binary")
1028    (set_attr "length" "8")])
1030 (define_insn ""
1031   [(set (match_operand:DI 0 "register_operand" "=r")
1032         (minus:DI (match_operand:DI 1 "register_operand" "r")
1033                   (leu:DI (match_operand:DI 2 "register_operand" "r")
1034                           (match_operand:DI 3 "int11_operand" "I"))))]
1035   "TARGET_64BIT"
1036   "addi %k3,%2,%%r0\;sub,db %1,%%r0,%0"
1037   [(set_attr "type" "binary")
1038    (set_attr "length" "8")])
1040 (define_insn ""
1041   [(set (match_operand:SI 0 "register_operand" "=r")
1042         (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
1043                             (leu:SI (match_operand:SI 2 "register_operand" "r")
1044                                     (match_operand:SI 3 "int11_operand" "I")))
1045                   (match_operand:SI 4 "register_operand" "r")))]
1046   ""
1047   "addi %k3,%2,%%r0\;{subb|sub,b} %1,%4,%0"
1048   [(set_attr "type" "binary")
1049    (set_attr "length" "8")])
1051 (define_insn ""
1052   [(set (match_operand:DI 0 "register_operand" "=r")
1053         (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
1054                             (leu:DI (match_operand:DI 2 "register_operand" "r")
1055                                     (match_operand:DI 3 "int11_operand" "I")))
1056                   (match_operand:DI 4 "register_operand" "r")))]
1057   "TARGET_64BIT"
1058   "addi %k3,%2,%%r0\;sub,db %1,%4,%0"
1059   [(set_attr "type" "binary")
1060    (set_attr "length" "8")])
1062 (define_insn "decscc"
1063   [(set (match_operand:SI 0 "register_operand" "=r,r")
1064         (minus:SI (match_operand:SI 1 "register_operand" "0,?r")
1065                   (match_operator:SI 4 "ordered_comparison_operator"
1066                      [(match_operand:SI 2 "register_operand" "r,r")
1067                       (match_operand:SI 3 "arith11_operand" "rI,rI")])))]
1068   ""
1069   "@
1070    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi -1,%0,%0
1071    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi,tr -1,%1,%0\;copy %1,%0"
1072   [(set_attr "type" "binary,binary")
1073    (set_attr "length" "8,12")])
1075 (define_insn ""
1076   [(set (match_operand:DI 0 "register_operand" "=r,r")
1077         (minus:DI (match_operand:DI 1 "register_operand" "0,?r")
1078                   (match_operator:DI 4 "ordered_comparison_operator"
1079                      [(match_operand:DI 2 "register_operand" "r,r")
1080                       (match_operand:DI 3 "arith11_operand" "rI,rI")])))]
1081   "TARGET_64BIT"
1082   "@
1083    cmp%I3clr,*%B4 %3,%2,%%r0\;addi -1,%0,%0
1084    cmp%I3clr,*%B4 %3,%2,%%r0\;addi,tr -1,%1,%0\;copy %1,%0"
1085   [(set_attr "type" "binary,binary")
1086    (set_attr "length" "8,12")])
1088 ; Patterns for max and min.  (There is no need for an earlyclobber in the
1089 ; last alternative since the middle alternative will match if op0 == op1.)
1091 (define_insn "sminsi3"
1092   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1093         (smin:SI (match_operand:SI 1 "register_operand" "%0,0,r")
1094                  (match_operand:SI 2 "arith11_operand" "r,I,M")))]
1095   ""
1096   "@
1097   {comclr|cmpclr},> %2,%0,%%r0\;copy %2,%0
1098   {comiclr|cmpiclr},> %2,%0,%%r0\;ldi %2,%0
1099   {comclr|cmpclr},> %1,%r2,%0\;copy %1,%0"
1100 [(set_attr "type" "multi,multi,multi")
1101  (set_attr "length" "8,8,8")])
1103 (define_insn "smindi3"
1104   [(set (match_operand:DI 0 "register_operand" "=r,r,r")
1105         (smin:DI (match_operand:DI 1 "register_operand" "%0,0,r")
1106                  (match_operand:DI 2 "arith11_operand" "r,I,M")))]
1107   "TARGET_64BIT"
1108   "@
1109   cmpclr,*> %2,%0,%%r0\;copy %2,%0
1110   cmpiclr,*> %2,%0,%%r0\;ldi %2,%0
1111   cmpclr,*> %1,%r2,%0\;copy %1,%0"
1112 [(set_attr "type" "multi,multi,multi")
1113  (set_attr "length" "8,8,8")])
1115 (define_insn "uminsi3"
1116   [(set (match_operand:SI 0 "register_operand" "=r,r")
1117         (umin:SI (match_operand:SI 1 "register_operand" "%0,0")
1118                  (match_operand:SI 2 "arith11_operand" "r,I")))]
1119   ""
1120   "@
1121   {comclr|cmpclr},>> %2,%0,%%r0\;copy %2,%0
1122   {comiclr|cmpiclr},>> %2,%0,%%r0\;ldi %2,%0"
1123 [(set_attr "type" "multi,multi")
1124  (set_attr "length" "8,8")])
1126 (define_insn "umindi3"
1127   [(set (match_operand:DI 0 "register_operand" "=r,r")
1128         (umin:DI (match_operand:DI 1 "register_operand" "%0,0")
1129                  (match_operand:DI 2 "arith11_operand" "r,I")))]
1130   "TARGET_64BIT"
1131   "@
1132   cmpclr,*>> %2,%0,%%r0\;copy %2,%0
1133   cmpiclr,*>> %2,%0,%%r0\;ldi %2,%0"
1134 [(set_attr "type" "multi,multi")
1135  (set_attr "length" "8,8")])
1137 (define_insn "smaxsi3"
1138   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1139         (smax:SI (match_operand:SI 1 "register_operand" "%0,0,r")
1140                  (match_operand:SI 2 "arith11_operand" "r,I,M")))]
1141   ""
1142   "@
1143   {comclr|cmpclr},< %2,%0,%%r0\;copy %2,%0
1144   {comiclr|cmpiclr},< %2,%0,%%r0\;ldi %2,%0
1145   {comclr|cmpclr},< %1,%r2,%0\;copy %1,%0"
1146 [(set_attr "type" "multi,multi,multi")
1147  (set_attr "length" "8,8,8")])
1149 (define_insn "smaxdi3"
1150   [(set (match_operand:DI 0 "register_operand" "=r,r,r")
1151         (smax:DI (match_operand:DI 1 "register_operand" "%0,0,r")
1152                  (match_operand:DI 2 "arith11_operand" "r,I,M")))]
1153   "TARGET_64BIT"
1154   "@
1155   cmpclr,*< %2,%0,%%r0\;copy %2,%0
1156   cmpiclr,*< %2,%0,%%r0\;ldi %2,%0
1157   cmpclr,*< %1,%r2,%0\;copy %1,%0"
1158 [(set_attr "type" "multi,multi,multi")
1159  (set_attr "length" "8,8,8")])
1161 (define_insn "umaxsi3"
1162   [(set (match_operand:SI 0 "register_operand" "=r,r")
1163         (umax:SI (match_operand:SI 1 "register_operand" "%0,0")
1164                  (match_operand:SI 2 "arith11_operand" "r,I")))]
1165   ""
1166   "@
1167   {comclr|cmpclr},<< %2,%0,%%r0\;copy %2,%0
1168   {comiclr|cmpiclr},<< %2,%0,%%r0\;ldi %2,%0"
1169 [(set_attr "type" "multi,multi")
1170  (set_attr "length" "8,8")])
1172 (define_insn "umaxdi3"
1173   [(set (match_operand:DI 0 "register_operand" "=r,r")
1174         (umax:DI (match_operand:DI 1 "register_operand" "%0,0")
1175                  (match_operand:DI 2 "arith11_operand" "r,I")))]
1176   "TARGET_64BIT"
1177   "@
1178   cmpclr,*<< %2,%0,%%r0\;copy %2,%0
1179   cmpiclr,*<< %2,%0,%%r0\;ldi %2,%0"
1180 [(set_attr "type" "multi,multi")
1181  (set_attr "length" "8,8")])
1183 (define_insn "absqi2"
1184   [(set (match_operand:QI 0 "register_operand" "=r")
1185         (abs:QI (match_operand:QI 1 "register_operand" "r")))]
1186   ""
1187   "{extrs|extrw,s},>= %1,31,8,%0\;subi 0,%0,%0"
1188   [(set_attr "type" "multi")
1189    (set_attr "length" "8")])
1191 (define_insn "abshi2"
1192   [(set (match_operand:HI 0 "register_operand" "=r")
1193         (abs:HI (match_operand:HI 1 "register_operand" "r")))]
1194   ""
1195   "{extrs|extrw,s},>= %1,31,16,%0\;subi 0,%0,%0"
1196   [(set_attr "type" "multi")
1197    (set_attr "length" "8")])
1199 (define_insn "abssi2"
1200   [(set (match_operand:SI 0 "register_operand" "=r")
1201         (abs:SI (match_operand:SI 1 "register_operand" "r")))]
1202   ""
1203   "or,>= %%r0,%1,%0\;subi 0,%0,%0"
1204   [(set_attr "type" "multi")
1205    (set_attr "length" "8")])
1207 (define_insn "absdi2"
1208   [(set (match_operand:DI 0 "register_operand" "=r")
1209         (abs:DI (match_operand:DI 1 "register_operand" "r")))]
1210   "TARGET_64BIT"
1211   "or,*>= %%r0,%1,%0\;subi 0,%0,%0"
1212   [(set_attr "type" "multi")
1213    (set_attr "length" "8")])
1215 (define_insn "bswaphi2"
1216   [(set (match_operand:HI 0 "register_operand" "=&r")
1217         (bswap:HI (match_operand:HI 1 "register_operand" "r")))]
1218   ""
1219   "{extru|extrw,u} %1,23,8,%0\;{dep|depw} %1,23,8,%0"
1220   [(set_attr "type" "multi")
1221    (set_attr "length" "8")])
1223 (define_insn "bswapsi2"
1224   [(set (match_operand:SI 0 "register_operand" "=&r")
1225         (bswap:SI (match_operand:SI 1 "register_operand" "r")))]
1226   ""
1227   "{shd|shrpw} %1,%1,16,%0\;{dep|depw} %0,15,8,%0\;{shd|shrpw} %1,%0,8,%0"
1228   [(set_attr "type" "multi")
1229    (set_attr "length" "12")])
1231 (define_insn "bswapdi2"
1232   [(set (match_operand:DI 0 "register_operand" "=&r")
1233         (bswap:DI (match_operand:DI 1 "register_operand" "r")))
1234    (clobber (match_scratch:DI 2 "=r"))]
1235   "TARGET_64BIT"
1236   "permh,3210 %1,%2\;hshl %2,8,%0\;hshr,u %2,8,%2\;or %0,%2,%0"
1237   [(set_attr "type" "multi")
1238    (set_attr "length" "16")])
1240 ;;; Experimental conditional move patterns
1242 (define_expand "movsicc"
1243   [(set (match_operand:SI 0 "register_operand" "")
1244         (if_then_else:SI
1245          (match_operand 1 "ordered_comparison_operator" "")
1246          (match_operand:SI 2 "reg_or_cint_move_operand" "")
1247          (match_operand:SI 3 "reg_or_cint_move_operand" "")))]
1248   ""
1249   "
1251   if (GET_MODE (XEXP (operands[1], 0)) != SImode
1252       || GET_MODE (XEXP (operands[1], 0)) != GET_MODE (XEXP (operands[1], 1)))
1253     FAIL;
1256 ;; We used to accept any register for op1.
1258 ;; However, it loses sometimes because the compiler will end up using
1259 ;; different registers for op0 and op1 in some critical cases.  local-alloc
1260 ;; will  not tie op0 and op1 because op0 is used in multiple basic blocks.
1262 ;; If/when global register allocation supports tying we should allow any
1263 ;; register for op1 again.
1264 (define_insn ""
1265   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
1266         (if_then_else:SI
1267          (match_operator 2 "ordered_comparison_operator"
1268             [(match_operand:SI 3 "register_operand" "r,r,r,r")
1269              (match_operand:SI 4 "arith11_operand" "rI,rI,rI,rI")])
1270          (match_operand:SI 1 "reg_or_cint_move_operand" "0,J,N,K")
1271          (const_int 0)))]
1272   ""
1273   "@
1274    {com%I4clr|cmp%I4clr},%S2 %4,%3,%%r0\;ldi 0,%0
1275    {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;ldi %1,%0
1276    {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;ldil L'%1,%0
1277    {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;{zdepi|depwi,z} %Z1,%0"
1278   [(set_attr "type" "multi,multi,multi,nullshift")
1279    (set_attr "length" "8,8,8,8")])
1281 (define_insn ""
1282   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r,r,r")
1283         (if_then_else:SI
1284          (match_operator 5 "ordered_comparison_operator"
1285             [(match_operand:SI 3 "register_operand" "r,r,r,r,r,r,r,r")
1286              (match_operand:SI 4 "arith11_operand" "rI,rI,rI,rI,rI,rI,rI,rI")])
1287          (match_operand:SI 1 "reg_or_cint_move_operand" "0,0,0,0,r,J,N,K")
1288          (match_operand:SI 2 "reg_or_cint_move_operand" "r,J,N,K,0,0,0,0")))]
1289   ""
1290   "@
1291    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;copy %2,%0
1292    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;ldi %2,%0
1293    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;ldil L'%2,%0
1294    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;{zdepi|depwi,z} %Z2,%0
1295    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;copy %1,%0
1296    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;ldi %1,%0
1297    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;ldil L'%1,%0
1298    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;{zdepi|depwi,z} %Z1,%0"
1299   [(set_attr "type" "multi,multi,multi,nullshift,multi,multi,multi,nullshift")
1300    (set_attr "length" "8,8,8,8,8,8,8,8")])
1302 (define_expand "movdicc"
1303   [(set (match_operand:DI 0 "register_operand" "")
1304         (if_then_else:DI
1305          (match_operand 1 "ordered_comparison_operator" "")
1306          (match_operand:DI 2 "reg_or_cint_move_operand" "")
1307          (match_operand:DI 3 "reg_or_cint_move_operand" "")))]
1308   "TARGET_64BIT"
1309   "
1311   if (GET_MODE (XEXP (operands[1], 0)) != DImode
1312       || GET_MODE (XEXP (operands[1], 0)) != GET_MODE (XEXP (operands[1], 1)))
1313     FAIL;
1316 ; We need the first constraint alternative in order to avoid
1317 ; earlyclobbers on all other alternatives.
1318 (define_insn ""
1319   [(set (match_operand:DI 0 "register_operand" "=r,r,r,r,r")
1320         (if_then_else:DI
1321          (match_operator 2 "ordered_comparison_operator"
1322             [(match_operand:DI 3 "register_operand" "r,r,r,r,r")
1323              (match_operand:DI 4 "arith11_operand" "rI,rI,rI,rI,rI")])
1324          (match_operand:DI 1 "reg_or_cint_move_operand" "0,r,J,N,K")
1325          (const_int 0)))]
1326   "TARGET_64BIT"
1327   "@
1328    cmp%I4clr,*%S2 %4,%3,%%r0\;ldi 0,%0
1329    cmp%I4clr,*%B2 %4,%3,%0\;copy %1,%0
1330    cmp%I4clr,*%B2 %4,%3,%0\;ldi %1,%0
1331    cmp%I4clr,*%B2 %4,%3,%0\;ldil L'%1,%0
1332    cmp%I4clr,*%B2 %4,%3,%0\;depdi,z %z1,%0"
1333   [(set_attr "type" "multi,multi,multi,multi,nullshift")
1334    (set_attr "length" "8,8,8,8,8")])
1336 (define_insn ""
1337   [(set (match_operand:DI 0 "register_operand" "=r,r,r,r,r,r,r,r")
1338         (if_then_else:DI
1339          (match_operator 5 "ordered_comparison_operator"
1340             [(match_operand:DI 3 "register_operand" "r,r,r,r,r,r,r,r")
1341              (match_operand:DI 4 "arith11_operand" "rI,rI,rI,rI,rI,rI,rI,rI")])
1342          (match_operand:DI 1 "reg_or_cint_move_operand" "0,0,0,0,r,J,N,K")
1343          (match_operand:DI 2 "reg_or_cint_move_operand" "r,J,N,K,0,0,0,0")))]
1344   "TARGET_64BIT"
1345   "@
1346    cmp%I4clr,*%S5 %4,%3,%%r0\;copy %2,%0
1347    cmp%I4clr,*%S5 %4,%3,%%r0\;ldi %2,%0
1348    cmp%I4clr,*%S5 %4,%3,%%r0\;ldil L'%2,%0
1349    cmp%I4clr,*%S5 %4,%3,%%r0\;depdi,z %z2,%0
1350    cmp%I4clr,*%B5 %4,%3,%%r0\;copy %1,%0
1351    cmp%I4clr,*%B5 %4,%3,%%r0\;ldi %1,%0
1352    cmp%I4clr,*%B5 %4,%3,%%r0\;ldil L'%1,%0
1353    cmp%I4clr,*%B5 %4,%3,%%r0\;depdi,z %z1,%0"
1354   [(set_attr "type" "multi,multi,multi,nullshift,multi,multi,multi,nullshift")
1355    (set_attr "length" "8,8,8,8,8,8,8,8")])
1357 ;; Conditional Branches
1359 (define_expand "cbranchdi4"
1360   [(set (pc)
1361         (if_then_else (match_operator 0 "ordered_comparison_operator"
1362                        [(match_operand:DI 1 "reg_or_0_operand" "")
1363                         (match_operand:DI 2 "register_operand" "")])
1364                       (label_ref (match_operand 3 "" ""))
1365                       (pc)))]
1366   "TARGET_64BIT"
1367   "")
1369 (define_expand "cbranchsi4"
1370   [(set (pc)
1371         (if_then_else (match_operator 0 "ordered_comparison_operator"
1372                        [(match_operand:SI 1 "reg_or_0_operand" "")
1373                         (match_operand:SI 2 "arith5_operand" "")])
1374                       (label_ref (match_operand 3 "" ""))
1375                       (pc)))]
1376   ""
1377   "")
1379 (define_expand "cbranchsf4"
1380   [(set (pc)
1381         (if_then_else (match_operator 0 "comparison_operator"
1382                        [(match_operand:SF 1 "reg_or_0_operand" "")
1383                         (match_operand:SF 2 "reg_or_0_operand" "")])
1384                       (label_ref (match_operand 3 "" ""))
1385                       (pc)))]
1386   ""
1387   "
1389   pa_emit_bcond_fp (operands);
1390   DONE;
1394 (define_expand "cbranchdf4"
1395   [(set (pc)
1396         (if_then_else (match_operator 0 "comparison_operator"
1397                        [(match_operand:DF 1 "reg_or_0_operand" "")
1398                         (match_operand:DF 2 "reg_or_0_operand" "")])
1399                       (label_ref (match_operand 3 "" ""))
1400                       (pc)))]
1401   ""
1402   "
1404   pa_emit_bcond_fp (operands);
1405   DONE;
1408 ;; Match the branch patterns.
1411 ;; Note a long backward conditional branch with an annulled delay slot
1412 ;; has a length of 12.
1413 (define_insn ""
1414   [(set (pc)
1415         (if_then_else
1416          (match_operator 3 "ordered_comparison_operator"
1417                          [(match_operand:SI 1 "reg_or_0_operand" "rM")
1418                           (match_operand:SI 2 "arith5_operand" "rL")])
1419          (label_ref (match_operand 0 "" ""))
1420          (pc)))]
1421   ""
1422   "*
1424   return pa_output_cbranch (operands, 0, insn);
1426 [(set_attr "type" "cbranch")
1427  (set (attr "length")
1428     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1429                (const_int MAX_12BIT_OFFSET))
1430            (const_int 4)
1431            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1432                (const_int MAX_17BIT_OFFSET))
1433            (const_int 8)
1434            (match_test "TARGET_PORTABLE_RUNTIME")
1435            (const_int 24)
1436            (not (match_test "flag_pic"))
1437            (const_int 20)]
1438           (const_int 28)))])
1440 ;; Match the negated branch.
1442 (define_insn ""
1443   [(set (pc)
1444         (if_then_else
1445          (match_operator 3 "ordered_comparison_operator"
1446                          [(match_operand:SI 1 "reg_or_0_operand" "rM")
1447                           (match_operand:SI 2 "arith5_operand" "rL")])
1448          (pc)
1449          (label_ref (match_operand 0 "" ""))))]
1450   ""
1451   "*
1453   return pa_output_cbranch (operands, 1, insn);
1455 [(set_attr "type" "cbranch")
1456  (set (attr "length")
1457     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1458                (const_int MAX_12BIT_OFFSET))
1459            (const_int 4)
1460            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1461                (const_int MAX_17BIT_OFFSET))
1462            (const_int 8)
1463            (match_test "TARGET_PORTABLE_RUNTIME")
1464            (const_int 24)
1465            (not (match_test "flag_pic"))
1466            (const_int 20)]
1467           (const_int 28)))])
1469 (define_insn ""
1470   [(set (pc)
1471         (if_then_else
1472          (match_operator 3 "ordered_comparison_operator"
1473                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1474                           (match_operand:DI 2 "reg_or_0_operand" "rM")])
1475          (label_ref (match_operand 0 "" ""))
1476          (pc)))]
1477   "TARGET_64BIT"
1478   "*
1480   return pa_output_cbranch (operands, 0, insn);
1482 [(set_attr "type" "cbranch")
1483  (set (attr "length")
1484     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1485                (const_int MAX_12BIT_OFFSET))
1486            (const_int 4)
1487            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1488                (const_int MAX_17BIT_OFFSET))
1489            (const_int 8)
1490            (match_test "TARGET_PORTABLE_RUNTIME")
1491            (const_int 24)
1492            (not (match_test "flag_pic"))
1493            (const_int 20)]
1494           (const_int 28)))])
1496 ;; Match the negated branch.
1498 (define_insn ""
1499   [(set (pc)
1500         (if_then_else
1501          (match_operator 3 "ordered_comparison_operator"
1502                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1503                           (match_operand:DI 2 "reg_or_0_operand" "rM")])
1504          (pc)
1505          (label_ref (match_operand 0 "" ""))))]
1506   "TARGET_64BIT"
1507   "*
1509   return pa_output_cbranch (operands, 1, insn);
1511 [(set_attr "type" "cbranch")
1512  (set (attr "length")
1513     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1514                (const_int MAX_12BIT_OFFSET))
1515            (const_int 4)
1516            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1517                (const_int MAX_17BIT_OFFSET))
1518            (const_int 8)
1519            (match_test "TARGET_PORTABLE_RUNTIME")
1520            (const_int 24)
1521            (not (match_test "flag_pic"))
1522            (const_int 20)]
1523           (const_int 28)))])
1524 (define_insn ""
1525   [(set (pc)
1526         (if_then_else
1527          (match_operator 3 "cmpib_comparison_operator"
1528                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1529                           (match_operand:DI 2 "arith5_operand" "rL")])
1530          (label_ref (match_operand 0 "" ""))
1531          (pc)))]
1532   "TARGET_64BIT"
1533   "*
1535   return pa_output_cbranch (operands, 0, 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)))])
1551 ;; Match the negated branch.
1553 (define_insn ""
1554   [(set (pc)
1555         (if_then_else
1556          (match_operator 3 "cmpib_comparison_operator"
1557                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1558                           (match_operand:DI 2 "arith5_operand" "rL")])
1559          (pc)
1560          (label_ref (match_operand 0 "" ""))))]
1561   "TARGET_64BIT"
1562   "*
1564   return pa_output_cbranch (operands, 1, insn);
1566 [(set_attr "type" "cbranch")
1567  (set (attr "length")
1568     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1569                (const_int MAX_12BIT_OFFSET))
1570            (const_int 4)
1571            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1572                (const_int MAX_17BIT_OFFSET))
1573            (const_int 8)
1574            (match_test "TARGET_PORTABLE_RUNTIME")
1575            (const_int 24)
1576            (not (match_test "flag_pic"))
1577            (const_int 20)]
1578           (const_int 28)))])
1580 ;; Branch on Bit patterns.
1581 (define_insn ""
1582   [(set (pc)
1583         (if_then_else
1584          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1585                               (const_int 1)
1586                               (match_operand:SI 1 "uint5_operand" ""))
1587              (const_int 0))
1588          (label_ref (match_operand 2 "" ""))
1589          (pc)))]
1590   ""
1591   "*
1593   return pa_output_bb (operands, 0, insn, 0);
1595 [(set_attr "type" "cbranch")
1596  (set (attr "length")
1597     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1598                (const_int MAX_12BIT_OFFSET))
1599            (const_int 4)
1600            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1601                (const_int MAX_17BIT_OFFSET))
1602            (const_int 8)
1603            (match_test "TARGET_PORTABLE_RUNTIME")
1604            (const_int 24)
1605            (not (match_test "flag_pic"))
1606            (const_int 20)]
1607           (const_int 28)))])
1609 (define_insn ""
1610   [(set (pc)
1611         (if_then_else
1612          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1613                               (const_int 1)
1614                               (match_operand:DI 1 "uint32_operand" ""))
1615              (const_int 0))
1616          (label_ref (match_operand 2 "" ""))
1617          (pc)))]
1618   "TARGET_64BIT"
1619   "*
1621   return pa_output_bb (operands, 0, insn, 0);
1623 [(set_attr "type" "cbranch")
1624  (set (attr "length")
1625     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1626                (const_int MAX_12BIT_OFFSET))
1627            (const_int 4)
1628            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1629                (const_int MAX_17BIT_OFFSET))
1630            (const_int 8)
1631            (match_test "TARGET_PORTABLE_RUNTIME")
1632            (const_int 24)
1633            (not (match_test "flag_pic"))
1634            (const_int 20)]
1635           (const_int 28)))])
1637 (define_insn ""
1638   [(set (pc)
1639         (if_then_else
1640          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1641                               (const_int 1)
1642                               (match_operand:SI 1 "uint5_operand" ""))
1643              (const_int 0))
1644          (pc)
1645          (label_ref (match_operand 2 "" ""))))]
1646   ""
1647   "*
1649   return pa_output_bb (operands, 1, insn, 0);
1651 [(set_attr "type" "cbranch")
1652  (set (attr "length")
1653     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1654                (const_int MAX_12BIT_OFFSET))
1655            (const_int 4)
1656            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1657                (const_int MAX_17BIT_OFFSET))
1658            (const_int 8)
1659            (match_test "TARGET_PORTABLE_RUNTIME")
1660            (const_int 24)
1661            (not (match_test "flag_pic"))
1662            (const_int 20)]
1663           (const_int 28)))])
1665 (define_insn ""
1666   [(set (pc)
1667         (if_then_else
1668          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1669                               (const_int 1)
1670                               (match_operand:DI 1 "uint32_operand" ""))
1671              (const_int 0))
1672          (pc)
1673          (label_ref (match_operand 2 "" ""))))]
1674   "TARGET_64BIT"
1675   "*
1677   return pa_output_bb (operands, 1, insn, 0);
1679 [(set_attr "type" "cbranch")
1680  (set (attr "length")
1681     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1682                (const_int MAX_12BIT_OFFSET))
1683            (const_int 4)
1684            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1685                (const_int MAX_17BIT_OFFSET))
1686            (const_int 8)
1687            (match_test "TARGET_PORTABLE_RUNTIME")
1688            (const_int 24)
1689            (not (match_test "flag_pic"))
1690            (const_int 20)]
1691           (const_int 28)))])
1693 (define_insn ""
1694   [(set (pc)
1695         (if_then_else
1696          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1697                               (const_int 1)
1698                               (match_operand:SI 1 "uint5_operand" ""))
1699              (const_int 0))
1700          (label_ref (match_operand 2 "" ""))
1701          (pc)))]
1702   ""
1703   "*
1705   return pa_output_bb (operands, 0, insn, 1);
1707 [(set_attr "type" "cbranch")
1708  (set (attr "length")
1709     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1710                (const_int MAX_12BIT_OFFSET))
1711            (const_int 4)
1712            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1713                (const_int MAX_17BIT_OFFSET))
1714            (const_int 8)
1715            (match_test "TARGET_PORTABLE_RUNTIME")
1716            (const_int 24)
1717            (not (match_test "flag_pic"))
1718            (const_int 20)]
1719           (const_int 28)))])
1721 (define_insn ""
1722   [(set (pc)
1723         (if_then_else
1724          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1725                               (const_int 1)
1726                               (match_operand:DI 1 "uint32_operand" ""))
1727              (const_int 0))
1728          (label_ref (match_operand 2 "" ""))
1729          (pc)))]
1730   "TARGET_64BIT"
1731   "*
1733   return pa_output_bb (operands, 0, insn, 1);
1735 [(set_attr "type" "cbranch")
1736  (set (attr "length")
1737     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1738                (const_int MAX_12BIT_OFFSET))
1739            (const_int 4)
1740            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1741                (const_int MAX_17BIT_OFFSET))
1742            (const_int 8)
1743            (match_test "TARGET_PORTABLE_RUNTIME")
1744            (const_int 24)
1745            (not (match_test "flag_pic"))
1746            (const_int 20)]
1747           (const_int 28)))])
1749 (define_insn ""
1750   [(set (pc)
1751         (if_then_else
1752          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1753                               (const_int 1)
1754                               (match_operand:SI 1 "uint5_operand" ""))
1755              (const_int 0))
1756          (pc)
1757          (label_ref (match_operand 2 "" ""))))]
1758   ""
1759   "*
1761   return pa_output_bb (operands, 1, insn, 1);
1763 [(set_attr "type" "cbranch")
1764  (set (attr "length")
1765     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1766                (const_int MAX_12BIT_OFFSET))
1767            (const_int 4)
1768            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1769                (const_int MAX_17BIT_OFFSET))
1770            (const_int 8)
1771            (match_test "TARGET_PORTABLE_RUNTIME")
1772            (const_int 24)
1773            (not (match_test "flag_pic"))
1774            (const_int 20)]
1775           (const_int 28)))])
1777 (define_insn ""
1778   [(set (pc)
1779         (if_then_else
1780          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1781                               (const_int 1)
1782                               (match_operand:DI 1 "uint32_operand" ""))
1783              (const_int 0))
1784          (pc)
1785          (label_ref (match_operand 2 "" ""))))]
1786   "TARGET_64BIT"
1787   "*
1789   return pa_output_bb (operands, 1, insn, 1);
1791 [(set_attr "type" "cbranch")
1792  (set (attr "length")
1793     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1794                (const_int MAX_12BIT_OFFSET))
1795            (const_int 4)
1796            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1797                (const_int MAX_17BIT_OFFSET))
1798            (const_int 8)
1799            (match_test "TARGET_PORTABLE_RUNTIME")
1800            (const_int 24)
1801            (not (match_test "flag_pic"))
1802            (const_int 20)]
1803           (const_int 28)))])
1805 ;; Branch on Variable Bit patterns.
1806 (define_insn ""
1807   [(set (pc)
1808         (if_then_else
1809          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1810                               (const_int 1)
1811                               (match_operand:SI 1 "register_operand" "q"))
1812              (const_int 0))
1813          (label_ref (match_operand 2 "" ""))
1814          (pc)))]
1815   ""
1816   "*
1818   return pa_output_bvb (operands, 0, insn, 0);
1820 [(set_attr "type" "cbranch")
1821  (set (attr "length")
1822     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1823                (const_int MAX_12BIT_OFFSET))
1824            (const_int 4)
1825            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1826                (const_int MAX_17BIT_OFFSET))
1827            (const_int 8)
1828            (match_test "TARGET_PORTABLE_RUNTIME")
1829            (const_int 24)
1830            (not (match_test "flag_pic"))
1831            (const_int 20)]
1832           (const_int 28)))])
1834 (define_insn ""
1835   [(set (pc)
1836         (if_then_else
1837          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1838                               (const_int 1)
1839                               (match_operand:DI 1 "register_operand" "q"))
1840              (const_int 0))
1841          (label_ref (match_operand 2 "" ""))
1842          (pc)))]
1843   "TARGET_64BIT"
1844   "*
1846   return pa_output_bvb (operands, 0, insn, 0);
1848 [(set_attr "type" "cbranch")
1849  (set (attr "length")
1850     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1851                (const_int MAX_12BIT_OFFSET))
1852            (const_int 4)
1853            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1854                (const_int MAX_17BIT_OFFSET))
1855            (const_int 8)
1856            (match_test "TARGET_PORTABLE_RUNTIME")
1857            (const_int 24)
1858            (not (match_test "flag_pic"))
1859            (const_int 20)]
1860           (const_int 28)))])
1862 (define_insn ""
1863   [(set (pc)
1864         (if_then_else
1865          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1866                               (const_int 1)
1867                               (match_operand:SI 1 "register_operand" "q"))
1868              (const_int 0))
1869          (pc)
1870          (label_ref (match_operand 2 "" ""))))]
1871   ""
1872   "*
1874   return pa_output_bvb (operands, 1, insn, 0);
1876 [(set_attr "type" "cbranch")
1877  (set (attr "length")
1878     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1879                (const_int MAX_12BIT_OFFSET))
1880            (const_int 4)
1881            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1882                (const_int MAX_17BIT_OFFSET))
1883            (const_int 8)
1884            (match_test "TARGET_PORTABLE_RUNTIME")
1885            (const_int 24)
1886            (not (match_test "flag_pic"))
1887            (const_int 20)]
1888           (const_int 28)))])
1890 (define_insn ""
1891   [(set (pc)
1892         (if_then_else
1893          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1894                               (const_int 1)
1895                               (match_operand:DI 1 "register_operand" "q"))
1896              (const_int 0))
1897          (pc)
1898          (label_ref (match_operand 2 "" ""))))]
1899   "TARGET_64BIT"
1900   "*
1902   return pa_output_bvb (operands, 1, insn, 0);
1904 [(set_attr "type" "cbranch")
1905  (set (attr "length")
1906     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1907                (const_int MAX_12BIT_OFFSET))
1908            (const_int 4)
1909            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1910                (const_int MAX_17BIT_OFFSET))
1911            (const_int 8)
1912            (match_test "TARGET_PORTABLE_RUNTIME")
1913            (const_int 24)
1914            (not (match_test "flag_pic"))
1915            (const_int 20)]
1916           (const_int 28)))])
1918 (define_insn ""
1919   [(set (pc)
1920         (if_then_else
1921          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1922                               (const_int 1)
1923                               (match_operand:SI 1 "register_operand" "q"))
1924              (const_int 0))
1925          (label_ref (match_operand 2 "" ""))
1926          (pc)))]
1927   ""
1928   "*
1930   return pa_output_bvb (operands, 0, insn, 1);
1932 [(set_attr "type" "cbranch")
1933  (set (attr "length")
1934     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1935                (const_int MAX_12BIT_OFFSET))
1936            (const_int 4)
1937            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1938                (const_int MAX_17BIT_OFFSET))
1939            (const_int 8)
1940            (match_test "TARGET_PORTABLE_RUNTIME")
1941            (const_int 24)
1942            (not (match_test "flag_pic"))
1943            (const_int 20)]
1944           (const_int 28)))])
1946 (define_insn ""
1947   [(set (pc)
1948         (if_then_else
1949          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1950                               (const_int 1)
1951                               (match_operand:DI 1 "register_operand" "q"))
1952              (const_int 0))
1953          (label_ref (match_operand 2 "" ""))
1954          (pc)))]
1955   "TARGET_64BIT"
1956   "*
1958   return pa_output_bvb (operands, 0, insn, 1);
1960 [(set_attr "type" "cbranch")
1961  (set (attr "length")
1962     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1963                (const_int MAX_12BIT_OFFSET))
1964            (const_int 4)
1965            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1966                (const_int MAX_17BIT_OFFSET))
1967            (const_int 8)
1968            (match_test "TARGET_PORTABLE_RUNTIME")
1969            (const_int 24)
1970            (not (match_test "flag_pic"))
1971            (const_int 20)]
1972           (const_int 28)))])
1974 (define_insn ""
1975   [(set (pc)
1976         (if_then_else
1977          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1978                               (const_int 1)
1979                               (match_operand:SI 1 "register_operand" "q"))
1980              (const_int 0))
1981          (pc)
1982          (label_ref (match_operand 2 "" ""))))]
1983   ""
1984   "*
1986   return pa_output_bvb (operands, 1, insn, 1);
1988 [(set_attr "type" "cbranch")
1989  (set (attr "length")
1990     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1991                (const_int MAX_12BIT_OFFSET))
1992            (const_int 4)
1993            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1994                (const_int MAX_17BIT_OFFSET))
1995            (const_int 8)
1996            (match_test "TARGET_PORTABLE_RUNTIME")
1997            (const_int 24)
1998            (not (match_test "flag_pic"))
1999            (const_int 20)]
2000           (const_int 28)))])
2002 (define_insn ""
2003   [(set (pc)
2004         (if_then_else
2005          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2006                               (const_int 1)
2007                               (match_operand:DI 1 "register_operand" "q"))
2008              (const_int 0))
2009          (pc)
2010          (label_ref (match_operand 2 "" ""))))]
2011   "TARGET_64BIT"
2012   "*
2014   return pa_output_bvb (operands, 1, insn, 1);
2016 [(set_attr "type" "cbranch")
2017  (set (attr "length")
2018     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2019                (const_int MAX_12BIT_OFFSET))
2020            (const_int 4)
2021            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2022                (const_int MAX_17BIT_OFFSET))
2023            (const_int 8)
2024            (match_test "TARGET_PORTABLE_RUNTIME")
2025            (const_int 24)
2026            (not (match_test "flag_pic"))
2027            (const_int 20)]
2028           (const_int 28)))])
2030 ;; Floating point branches
2032 ;; ??? Nullification is handled differently from other branches.
2033 ;; If nullification is specified, the delay slot is nullified on any
2034 ;; taken branch regardless of branch direction.
2035 (define_insn ""
2036   [(set (pc) (if_then_else (ne (reg:CCFP 0) (const_int 0))
2037                            (label_ref (match_operand 0 "" ""))
2038                            (pc)))]
2039   "!TARGET_SOFT_FLOAT"
2040   "*
2042   int length = get_attr_length (insn);
2043   rtx xoperands[1];
2044   int nullify, xdelay;
2046   if (length < 16)
2047     return \"ftest\;b%* %l0\";
2049   if (dbr_sequence_length () == 0 || INSN_ANNULLED_BRANCH_P (insn))
2050     {
2051       nullify = 1;
2052       xdelay = 0;
2053       xoperands[0] = GEN_INT (length - 8);
2054     }
2055   else
2056     {
2057       nullify = 0;
2058       xdelay = 1;
2059       xoperands[0] = GEN_INT (length - 4);
2060     }
2062   if (nullify)
2063     output_asm_insn (\"ftest\;add,tr %%r0,%%r0,%%r0\;b,n .+%0\", xoperands);
2064   else
2065     output_asm_insn (\"ftest\;add,tr %%r0,%%r0,%%r0\;b .+%0\", xoperands);
2066   return pa_output_lbranch (operands[0], insn, xdelay);
2068 [(set_attr "type" "fbranch")
2069  (set (attr "length")
2070     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
2071                (const_int MAX_17BIT_OFFSET))
2072            (const_int 8)
2073            (match_test "TARGET_PORTABLE_RUNTIME")
2074            (const_int 32)
2075            (not (match_test "flag_pic"))
2076            (const_int 28)]
2077           (const_int 36)))])
2079 (define_insn ""
2080   [(set (pc) (if_then_else (ne (reg:CCFP 0) (const_int 0))
2081                            (pc)
2082                            (label_ref (match_operand 0 "" ""))))]
2083   "!TARGET_SOFT_FLOAT"
2084   "*
2086   int length = get_attr_length (insn);
2087   rtx xoperands[1];
2088   int nullify, xdelay;
2090   if (length < 16)
2091     return \"ftest\;add,tr %%r0,%%r0,%%r0\;b%* %0\";
2093   if (dbr_sequence_length () == 0 || INSN_ANNULLED_BRANCH_P (insn))
2094     {
2095       nullify = 1;
2096       xdelay = 0;
2097       xoperands[0] = GEN_INT (length - 4);
2098     }
2099   else
2100     {
2101       nullify = 0;
2102       xdelay = 1;
2103       xoperands[0] = GEN_INT (length);
2104     }
2106   if (nullify)
2107     output_asm_insn (\"ftest\;b,n .+%0\", xoperands);
2108   else
2109     output_asm_insn (\"ftest\;b .+%0\", xoperands);
2110   return pa_output_lbranch (operands[0], insn, xdelay);
2112 [(set_attr "type" "fbranch")
2113  (set (attr "length")
2114     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
2115                (const_int MAX_17BIT_OFFSET))
2116            (const_int 12)
2117            (match_test "TARGET_PORTABLE_RUNTIME")
2118            (const_int 28)
2119            (not (match_test "flag_pic"))
2120            (const_int 24)]
2121           (const_int 32)))])
2123 ;; Move instructions
2125 (define_expand "movsi"
2126   [(set (match_operand:SI 0 "general_operand" "")
2127         (match_operand:SI 1 "general_operand" ""))]
2128   ""
2129   "
2131   if (pa_emit_move_sequence (operands, SImode, 0))
2132     DONE;
2135 ;; Handle SImode input reloads requiring %r1 as a scratch register.
2136 (define_expand "reload_insi_r1"
2137   [(set (match_operand:SI 0 "register_operand" "=Z")
2138         (match_operand:SI 1 "non_hard_reg_operand" ""))
2139    (clobber (match_operand:SI 2 "register_operand" "=&a"))]
2140   ""
2141   "
2143   if (pa_emit_move_sequence (operands, SImode, operands[2]))
2144     DONE;
2146   /* We don't want the clobber emitted, so handle this ourselves.  */
2147   emit_insn (gen_rtx_SET (operands[0], operands[1]));
2148   DONE;
2151 ;; Handle SImode input reloads requiring a general register as a
2152 ;; scratch register.
2153 (define_expand "reload_insi"
2154   [(set (match_operand:SI 0 "register_operand" "=Z")
2155         (match_operand:SI 1 "non_hard_reg_operand" ""))
2156    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
2157   ""
2158   "
2160   if (pa_emit_move_sequence (operands, SImode, operands[2]))
2161     DONE;
2163   /* We don't want the clobber emitted, so handle this ourselves.  */
2164   emit_insn (gen_rtx_SET (operands[0], operands[1]));
2165   DONE;
2168 ;; Handle SImode output reloads requiring a general register as a
2169 ;; scratch register.
2170 (define_expand "reload_outsi"
2171   [(set (match_operand:SI 0 "non_hard_reg_operand" "")
2172         (match_operand:SI 1  "register_operand" "Z"))
2173    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
2174   ""
2175   "
2177   if (pa_emit_move_sequence (operands, SImode, operands[2]))
2178     DONE;
2180   /* We don't want the clobber emitted, so handle this ourselves.  */
2181   emit_insn (gen_rtx_SET (operands[0], operands[1]));
2182   DONE;
2185 (define_insn ""
2186   [(set (match_operand:SI 0 "move_dest_operand"
2187                           "=r,r,r,r,r,r,Q,!*q,!r,!*f,*f,T,?r,?*f")
2188         (match_operand:SI 1 "move_src_operand"
2189                           "A,r,J,N,K,RQ,rM,!rM,!*q,!*fM,RT,*f,*f,r"))]
2190   "(register_operand (operands[0], SImode)
2191     || reg_or_0_operand (operands[1], SImode))
2192    && !TARGET_SOFT_FLOAT
2193    && !TARGET_64BIT"
2194   "@
2195    ldw RT'%A1,%0
2196    copy %1,%0
2197    ldi %1,%0
2198    ldil L'%1,%0
2199    {zdepi|depwi,z} %Z1,%0
2200    ldw%M1 %1,%0
2201    stw%M0 %r1,%0
2202    mtsar %r1
2203    {mfctl|mfctl,w} %%sar,%0
2204    fcpy,sgl %f1,%0
2205    fldw%F1 %1,%0
2206    fstw%F0 %1,%0
2207    {fstws|fstw} %1,-16(%%sp)\n\t{ldws|ldw} -16(%%sp),%0
2208    {stws|stw} %1,-16(%%sp)\n\t{fldws|fldw} -16(%%sp),%0"
2209   [(set_attr "type" "load,move,move,move,shift,load,store,move,move,fpalu,fpload,fpstore,fpstore_load,store_fpload")
2210    (set_attr "pa_combine_type" "addmove")
2211    (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4,8,8")])
2213 (define_insn ""
2214   [(set (match_operand:SI 0 "move_dest_operand"
2215                           "=r,r,r,r,r,r,Q,!*q,!r,!*f,*f,T")
2216         (match_operand:SI 1 "move_src_operand"
2217                           "A,r,J,N,K,RQ,rM,!rM,!*q,!*fM,RT,*f"))]
2218   "(register_operand (operands[0], SImode)
2219     || reg_or_0_operand (operands[1], SImode))
2220    && !TARGET_SOFT_FLOAT
2221    && TARGET_64BIT"
2222   "@
2223    ldw RT'%A1,%0
2224    copy %1,%0
2225    ldi %1,%0
2226    ldil L'%1,%0
2227    {zdepi|depwi,z} %Z1,%0
2228    ldw%M1 %1,%0
2229    stw%M0 %r1,%0
2230    mtsar %r1
2231    {mfctl|mfctl,w} %%sar,%0
2232    fcpy,sgl %f1,%0
2233    fldw%F1 %1,%0
2234    fstw%F0 %1,%0"
2235   [(set_attr "type" "load,move,move,move,shift,load,store,move,move,fpalu,fpload,fpstore")
2236    (set_attr "pa_combine_type" "addmove")
2237    (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4")])
2239 (define_insn ""
2240   [(set (match_operand:SI 0 "indexed_memory_operand" "=R")
2241         (match_operand:SI 1 "register_operand" "f"))]
2242   "!TARGET_SOFT_FLOAT
2243    && !TARGET_DISABLE_INDEXING
2244    && reload_completed"
2245   "fstw%F0 %1,%0"
2246   [(set_attr "type" "fpstore")
2247    (set_attr "pa_combine_type" "addmove")
2248    (set_attr "length" "4")])
2250 ; Rewrite RTL using an indexed store.  This will allow the insn that
2251 ; computes the address to be deleted if the register it sets is dead.
2252 (define_peephole2
2253   [(set (match_operand:SI 0 "register_operand" "")
2254         (plus:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
2255                             (const_int 2))
2256                  (match_operand:SI 2 "register_operand" "")))
2257    (set (mem:SI (match_dup 0))
2258         (match_operand:SI 3 "register_operand" ""))]
2259   "!TARGET_SOFT_FLOAT
2260    && !TARGET_DISABLE_INDEXING
2261    && REG_OK_FOR_BASE_P (operands[2])
2262    && FP_REGNO_P (REGNO (operands[3]))"
2263   [(set (mem:SI (plus:SI (mult:SI (match_dup 1) (const_int 4)) (match_dup 2)))
2264         (match_dup 3))
2265    (set (match_dup 0) (plus:SI (ashift:SI (match_dup 1) (const_int 2))
2266                                (match_dup 2)))]
2267   "")
2269 (define_peephole2
2270   [(set (match_operand:DI 0 "register_operand" "")
2271         (plus:DI (ashift:DI (match_operand:DI 1 "register_operand" "")
2272                             (const_int 2))
2273                  (match_operand:DI 2 "register_operand" "")))
2274    (set (mem:SI (match_dup 0))
2275         (match_operand:SI 3 "register_operand" ""))]
2276   "!TARGET_SOFT_FLOAT
2277    && !TARGET_DISABLE_INDEXING
2278    && TARGET_64BIT
2279    && REG_OK_FOR_BASE_P (operands[2])
2280    && FP_REGNO_P (REGNO (operands[3]))"
2281   [(set (mem:SI (plus:DI (mult:DI (match_dup 1) (const_int 4)) (match_dup 2)))
2282         (match_dup 3))
2283    (set (match_dup 0) (plus:DI (ashift:DI (match_dup 1) (const_int 2))
2284                                (match_dup 2)))]
2285   "")
2287 (define_peephole2
2288   [(set (match_operand:SI 0 "register_operand" "")
2289         (plus:SI (match_operand:SI 1 "register_operand" "")
2290                  (match_operand:SI 2 "register_operand" "")))
2291    (set (mem:SI (match_dup 0))
2292         (match_operand:SI 3 "register_operand" ""))]
2293   "!TARGET_SOFT_FLOAT
2294    && !TARGET_DISABLE_INDEXING
2295    && TARGET_NO_SPACE_REGS
2296    && REG_OK_FOR_INDEX_P (operands[1])
2297    && REG_OK_FOR_BASE_P (operands[2])
2298    && FP_REGNO_P (REGNO (operands[3]))"
2299   [(set (mem:SI (plus:SI (match_dup 1) (match_dup 2)))
2300         (match_dup 3))
2301    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
2302   "")
2304 (define_peephole2
2305   [(set (match_operand:SI 0 "register_operand" "")
2306         (plus:SI (match_operand:SI 1 "register_operand" "")
2307                  (match_operand:SI 2 "register_operand" "")))
2308    (set (mem:SI (match_dup 0))
2309         (match_operand:SI 3 "register_operand" ""))]
2310   "!TARGET_SOFT_FLOAT
2311    && !TARGET_DISABLE_INDEXING
2312    && TARGET_NO_SPACE_REGS
2313    && REG_OK_FOR_BASE_P (operands[1])
2314    && REG_OK_FOR_INDEX_P (operands[2])
2315    && FP_REGNO_P (REGNO (operands[3]))"
2316   [(set (mem:SI (plus:SI (match_dup 2) (match_dup 1)))
2317         (match_dup 3))
2318    (set (match_dup 0) (plus:SI (match_dup 2) (match_dup 1)))]
2319   "")
2321 (define_peephole2
2322   [(set (match_operand:DI 0 "register_operand" "")
2323         (plus:DI (match_operand:DI 1 "register_operand" "")
2324                  (match_operand:DI 2 "register_operand" "")))
2325    (set (mem:SI (match_dup 0))
2326         (match_operand:SI 3 "register_operand" ""))]
2327   "!TARGET_SOFT_FLOAT
2328    && !TARGET_DISABLE_INDEXING
2329    && TARGET_64BIT
2330    && TARGET_NO_SPACE_REGS
2331    && REG_OK_FOR_INDEX_P (operands[1])
2332    && REG_OK_FOR_BASE_P (operands[2])
2333    && FP_REGNO_P (REGNO (operands[3]))"
2334   [(set (mem:SI (plus:DI (match_dup 1) (match_dup 2)))
2335         (match_dup 3))
2336    (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
2337   "")
2339 (define_peephole2
2340   [(set (match_operand:DI 0 "register_operand" "")
2341         (plus:DI (match_operand:DI 1 "register_operand" "")
2342                  (match_operand:DI 2 "register_operand" "")))
2343    (set (mem:SI (match_dup 0))
2344         (match_operand:SI 3 "register_operand" ""))]
2345   "!TARGET_SOFT_FLOAT
2346    && !TARGET_DISABLE_INDEXING
2347    && TARGET_64BIT
2348    && TARGET_NO_SPACE_REGS
2349    && REG_OK_FOR_BASE_P (operands[1])
2350    && REG_OK_FOR_INDEX_P (operands[2])
2351    && FP_REGNO_P (REGNO (operands[3]))"
2352   [(set (mem:SI (plus:DI (match_dup 2) (match_dup 1)))
2353         (match_dup 3))
2354    (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
2355   "")
2357 (define_insn ""
2358   [(set (match_operand:SI 0 "move_dest_operand"
2359                           "=r,r,r,r,r,r,Q,!*q,!r")
2360         (match_operand:SI 1 "move_src_operand"
2361                           "A,r,J,N,K,RQ,rM,!rM,!*q"))]
2362   "(register_operand (operands[0], SImode)
2363     || reg_or_0_operand (operands[1], SImode))
2364    && TARGET_SOFT_FLOAT"
2365   "@
2366    ldw RT'%A1,%0
2367    copy %1,%0
2368    ldi %1,%0
2369    ldil L'%1,%0
2370    {zdepi|depwi,z} %Z1,%0
2371    ldw%M1 %1,%0
2372    stw%M0 %r1,%0
2373    mtsar %r1
2374    {mfctl|mfctl,w} %%sar,%0"
2375   [(set_attr "type" "load,move,move,move,move,load,store,move,move")
2376    (set_attr "pa_combine_type" "addmove")
2377    (set_attr "length" "4,4,4,4,4,4,4,4,4")])
2379 ;; Load or store with base-register modification.
2380 (define_insn ""
2381   [(set (match_operand:SI 0 "register_operand" "=r")
2382         (mem:SI (plus:DI (match_operand:DI 1 "register_operand" "+r")
2383                          (match_operand:DI 2 "int5_operand" "L"))))
2384    (set (match_dup 1)
2385         (plus:DI (match_dup 1) (match_dup 2)))]
2386   "TARGET_64BIT"
2387   "ldw,mb %2(%1),%0"
2388   [(set_attr "type" "load")
2389    (set_attr "length" "4")])
2391 ; And a zero extended variant.
2392 (define_insn ""
2393   [(set (match_operand:DI 0 "register_operand" "=r")
2394         (zero_extend:DI (mem:SI
2395                           (plus:DI
2396                             (match_operand:DI 1 "register_operand" "+r")
2397                             (match_operand:DI 2 "int5_operand" "L")))))
2398    (set (match_dup 1)
2399         (plus:DI (match_dup 1) (match_dup 2)))]
2400   "TARGET_64BIT"
2401   "ldw,mb %2(%1),%0"
2402   [(set_attr "type" "load")
2403    (set_attr "length" "4")])
2405 (define_expand "pre_load"
2406   [(parallel [(set (match_operand:SI 0 "register_operand" "")
2407               (mem (plus (match_operand 1 "register_operand" "")
2408                                (match_operand 2 "pre_cint_operand" ""))))
2409               (set (match_dup 1)
2410                    (plus (match_dup 1) (match_dup 2)))])]
2411   ""
2412   "
2414   if (TARGET_64BIT)
2415     {
2416       emit_insn (gen_pre_ldd (operands[0], operands[1], operands[2]));
2417       DONE;
2418     }
2419   emit_insn (gen_pre_ldw (operands[0], operands[1], operands[2]));
2420   DONE;
2423 (define_insn "pre_ldw"
2424   [(set (match_operand:SI 0 "register_operand" "=r")
2425         (mem:SI (plus:SI (match_operand:SI 1 "register_operand" "+r")
2426                          (match_operand:SI 2 "pre_cint_operand" ""))))
2427    (set (match_dup 1)
2428         (plus:SI (match_dup 1) (match_dup 2)))]
2429   ""
2430   "*
2432   if (INTVAL (operands[2]) < 0)
2433     return \"{ldwm|ldw,mb} %2(%1),%0\";
2434   return \"{ldws|ldw},mb %2(%1),%0\";
2436   [(set_attr "type" "load")
2437    (set_attr "length" "4")])
2439 (define_insn "pre_ldd"
2440   [(set (match_operand:DI 0 "register_operand" "=r")
2441         (mem:DI (plus:DI (match_operand:DI 1 "register_operand" "+r")
2442                          (match_operand:DI 2 "pre_cint_operand" ""))))
2443    (set (match_dup 1)
2444         (plus:DI (match_dup 1) (match_dup 2)))]
2445   "TARGET_64BIT"
2446   "ldd,mb %2(%1),%0"
2447   [(set_attr "type" "load")
2448    (set_attr "length" "4")])
2450 (define_insn ""
2451   [(set (mem:SI (plus:SI (match_operand:SI 0 "register_operand" "+r")
2452                          (match_operand:SI 1 "pre_cint_operand" "")))
2453         (match_operand:SI 2 "reg_or_0_operand" "rM"))
2454    (set (match_dup 0)
2455         (plus:SI (match_dup 0) (match_dup 1)))]
2456   ""
2457   "*
2459   if (INTVAL (operands[1]) < 0)
2460     return \"{stwm|stw,mb} %r2,%1(%0)\";
2461   return \"{stws|stw},mb %r2,%1(%0)\";
2463   [(set_attr "type" "store")
2464    (set_attr "length" "4")])
2466 (define_insn ""
2467   [(set (match_operand:SI 0 "register_operand" "=r")
2468         (mem:SI (match_operand:SI 1 "register_operand" "+r")))
2469    (set (match_dup 1)
2470         (plus:SI (match_dup 1)
2471                  (match_operand:SI 2 "post_cint_operand" "")))]
2472   ""
2473   "*
2475   if (INTVAL (operands[2]) > 0)
2476     return \"{ldwm|ldw,ma} %2(%1),%0\";
2477   return \"{ldws|ldw},ma %2(%1),%0\";
2479   [(set_attr "type" "load")
2480    (set_attr "length" "4")])
2482 (define_expand "post_store"
2483   [(parallel [(set (mem (match_operand 0 "register_operand" ""))
2484                    (match_operand 1 "reg_or_0_operand" ""))
2485               (set (match_dup 0)
2486                    (plus (match_dup 0)
2487                          (match_operand 2 "post_cint_operand" "")))])]
2488   ""
2489   "
2491   if (TARGET_64BIT)
2492     {
2493       emit_insn (gen_post_std (operands[0], operands[1], operands[2]));
2494       DONE;
2495     }
2496   emit_insn (gen_post_stw (operands[0], operands[1], operands[2]));
2497   DONE;
2500 (define_insn "post_stw"
2501   [(set (mem:SI (match_operand:SI 0 "register_operand" "+r"))
2502         (match_operand:SI 1 "reg_or_0_operand" "rM"))
2503    (set (match_dup 0)
2504         (plus:SI (match_dup 0)
2505                  (match_operand:SI 2 "post_cint_operand" "")))]
2506   ""
2507   "*
2509   if (INTVAL (operands[2]) > 0)
2510     return \"{stwm|stw,ma} %r1,%2(%0)\";
2511   return \"{stws|stw},ma %r1,%2(%0)\";
2513   [(set_attr "type" "store")
2514    (set_attr "length" "4")])
2516 (define_insn "post_std"
2517   [(set (mem:DI (match_operand:DI 0 "register_operand" "+r"))
2518         (match_operand:DI 1 "reg_or_0_operand" "rM"))
2519    (set (match_dup 0)
2520         (plus:DI (match_dup 0)
2521                  (match_operand:DI 2 "post_cint_operand" "")))]
2522   "TARGET_64BIT"
2523   "std,ma %r1,%2(%0)"
2524   [(set_attr "type" "store")
2525    (set_attr "length" "4")])
2527 ;; For loading the address of a label while generating PIC code.
2528 ;; Note since this pattern can be created at reload time (via movsi), all
2529 ;; the same rules for movsi apply here.  (no new pseudos, no temporaries).
2530 (define_insn ""
2531   [(set (match_operand 0 "pmode_register_operand" "=a")
2532         (match_operand 1 "pic_label_operand" ""))]
2533   "TARGET_PA_20"
2534   "*
2536   rtx xoperands[3];
2538   xoperands[0] = operands[0];
2539   xoperands[1] = operands[1];
2541   if (GET_CODE (operands[1]) == LABEL_REF
2542       && !LABEL_REF_NONLOCAL_P (operands[1]))
2543     {
2544       xoperands[2] = gen_label_rtx ();
2545       (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
2546                                          CODE_LABEL_NUMBER (xoperands[2]));
2547       output_asm_insn (\"mfia %0\", xoperands);
2549       /* If we're trying to load the address of a label that happens to be
2550          close, then we can use a shorter sequence.  */
2551       if (INSN_ADDRESSES_SET_P ()
2552           && abs (INSN_ADDRESSES (INSN_UID (XEXP (operands[1], 0)))
2553                   - INSN_ADDRESSES (INSN_UID (insn))) < 8100)
2554         output_asm_insn (\"ldo %1-%2(%0),%0\", xoperands);
2555       else
2556         {
2557           output_asm_insn (\"addil L%%%1-%2,%0\", xoperands);
2558           output_asm_insn (\"ldo R%%%1-%2(%0),%0\", xoperands);
2559         }
2560     }
2561   else
2562     {
2563       /* Load using linkage table.  */
2564       if (TARGET_64BIT)
2565         {
2566           output_asm_insn (\"addil LT%%%1,%%r27\", xoperands);
2567           output_asm_insn (\"ldd RT%%%1(%0),%0\", xoperands);
2568         }
2569       else
2570         {
2571           output_asm_insn (\"addil LT%%%1,%%r19\", xoperands);
2572           output_asm_insn (\"ldw RT%%%1(%0),%0\", xoperands);
2573         }
2574     }
2575   return \"\";
2577   [(set_attr "type" "multi")
2578    (set_attr "length" "12")])           ; 8 or 12
2580 (define_insn ""
2581   [(set (match_operand 0 "pmode_register_operand" "=a")
2582         (match_operand 1 "pic_label_operand" ""))]
2583   "!TARGET_PA_20"
2584   "*
2586   rtx xoperands[3];
2588   xoperands[0] = operands[0];
2589   xoperands[1] = operands[1];
2591   if (GET_CODE (operands[1]) == LABEL_REF
2592       && !LABEL_REF_NONLOCAL_P (operands[1]))
2593     {
2594       xoperands[2] = gen_label_rtx ();
2595       output_asm_insn (\"bl .+8,%0\", xoperands);
2596       output_asm_insn (\"depi 0,31,2,%0\", xoperands);
2597       (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
2598                                          CODE_LABEL_NUMBER (xoperands[2]));
2600       /* If we're trying to load the address of a label that happens to be
2601          close, then we can use a shorter sequence.  */
2602       if (INSN_ADDRESSES_SET_P ()
2603           && abs (INSN_ADDRESSES (INSN_UID (XEXP (operands[1], 0)))
2604                   - INSN_ADDRESSES (INSN_UID (insn))) < 8100)
2605         output_asm_insn (\"ldo %1-%2(%0),%0\", xoperands);
2606       else
2607         {
2608           output_asm_insn (\"addil L%%%1-%2,%0\", xoperands);
2609           output_asm_insn (\"ldo R%%%1-%2(%0),%0\", xoperands);
2610         }
2611     }
2612   else
2613     {
2614       /* Load using linkage table.  */
2615       output_asm_insn (\"addil LT%%%1,%%r19\", xoperands);
2616       output_asm_insn (\"ldw RT%%%1(%0),%0\", xoperands);
2617     }
2618   return \"\";
2620   [(set_attr "type" "multi")
2621    (set_attr "length" "16")])           ; 12 or 16
2623 (define_insn ""
2624   [(set (match_operand:SI 0 "register_operand" "=a")
2625         (plus:SI (match_operand:SI 1 "register_operand" "r")
2626                  (high:SI (match_operand 2 "" ""))))]
2627   "symbolic_operand (operands[2], Pmode)
2628    && ! function_label_operand (operands[2], Pmode)
2629    && flag_pic"
2630   "addil LT'%G2,%1"
2631   [(set_attr "type" "binary")
2632    (set_attr "length" "4")])
2634 (define_insn ""
2635   [(set (match_operand:DI 0 "register_operand" "=a")
2636         (plus:DI (match_operand:DI 1 "register_operand" "r")
2637                  (high:DI (match_operand 2 "" ""))))]
2638   "symbolic_operand (operands[2], Pmode)
2639    && ! function_label_operand (operands[2], Pmode)
2640    && TARGET_64BIT
2641    && flag_pic"
2642   "addil LT'%G2,%1"
2643   [(set_attr "type" "binary")
2644    (set_attr "length" "4")])
2646 (define_insn ""
2647  [(set (match_operand:SI 0 "register_operand" "=r")
2648        (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
2649                   (unspec:SI [(match_operand 2 "" "")] UNSPEC_DLTIND14R)))]
2650   "symbolic_operand (operands[2], Pmode)
2651    && ! function_label_operand (operands[2], Pmode)
2652    && flag_pic"
2653   "ldo RT'%G2(%1),%0"
2654   [(set_attr "type" "binary")
2655    (set_attr "length" "4")])
2657 (define_insn ""
2658  [(set (match_operand:DI 0 "register_operand" "=r")
2659        (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
2660                   (unspec:DI [(match_operand 2 "" "")] UNSPEC_DLTIND14R)))]
2661   "symbolic_operand (operands[2], Pmode)
2662    && ! function_label_operand (operands[2], Pmode)
2663    && TARGET_64BIT
2664    && flag_pic"
2665   "ldo RT'%G2(%1),%0"
2666   [(set_attr "type" "binary")
2667    (set_attr "length" "4")])
2669 ;; Always use addil rather than ldil;add sequences.  This allows the
2670 ;; HP linker to eliminate the dp relocation if the symbolic operand
2671 ;; lives in the TEXT space.
2672 (define_insn ""
2673   [(set (match_operand:SI 0 "register_operand" "=a")
2674         (high:SI (match_operand 1 "" "")))]
2675   "symbolic_operand (operands[1], Pmode)
2676    && ! function_label_operand (operands[1], Pmode)
2677    && ! read_only_operand (operands[1], Pmode)
2678    && ! flag_pic"
2679   "*
2681   if (TARGET_LONG_LOAD_STORE)
2682     return \"addil NLR'%H1,%%r27\;ldo N'%H1(%%r1),%%r1\";
2683   else
2684     return \"addil LR'%H1,%%r27\";
2686   [(set_attr "type" "binary")
2687    (set (attr "length")
2688       (if_then_else (not (match_test "TARGET_LONG_LOAD_STORE"))
2689                     (const_int 4)
2690                     (const_int 8)))])
2693 ;; This is for use in the prologue/epilogue code.  We need it
2694 ;; to add large constants to a stack pointer or frame pointer.
2695 ;; Because of the additional %r1 pressure, we probably do not
2696 ;; want to use this in general code, so make it available
2697 ;; only after reload.
2698 (define_insn ""
2699   [(set (match_operand:SI 0 "register_operand" "=!a,*r")
2700         (plus:SI (match_operand:SI 1 "register_operand" "r,r")
2701                  (high:SI (match_operand 2 "const_int_operand" ""))))]
2702   "reload_completed"
2703   "@
2704    addil L'%G2,%1
2705    ldil L'%G2,%0\;{addl|add,l} %0,%1,%0"
2706   [(set_attr "type" "binary,binary")
2707    (set_attr "length" "4,8")])
2709 (define_insn ""
2710   [(set (match_operand:DI 0 "register_operand" "=!a,*r")
2711         (plus:DI (match_operand:DI 1 "register_operand" "r,r")
2712                  (high:DI (match_operand 2 "const_int_operand" ""))))]
2713   "reload_completed && TARGET_64BIT"
2714   "@
2715    addil L'%G2,%1
2716    ldil L'%G2,%0\;{addl|add,l} %0,%1,%0"
2717   [(set_attr "type" "binary,binary")
2718    (set_attr "length" "4,8")])
2720 (define_insn ""
2721   [(set (match_operand:SI 0 "register_operand" "=r")
2722         (high:SI (match_operand 1 "" "")))]
2723   "(!flag_pic || !symbolic_operand (operands[1], Pmode))
2724     && !pa_is_function_label_plus_const (operands[1])"
2725   "*
2727   if (symbolic_operand (operands[1], Pmode))
2728     return \"ldil LR'%H1,%0\";
2729   else
2730     return \"ldil L'%G1,%0\";
2732   [(set_attr "type" "move")
2733    (set_attr "length" "4")])
2735 (define_insn ""
2736   [(set (match_operand:DI 0 "register_operand" "=r")
2737         (high:DI (match_operand 1 "const_int_operand" "")))]
2738   "TARGET_64BIT"
2739   "ldil L'%G1,%0";
2740   [(set_attr "type" "move")
2741    (set_attr "length" "4")])
2743 (define_insn ""
2744   [(set (match_operand:DI 0 "register_operand" "=r")
2745         (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
2746                    (match_operand:DI 2 "const_int_operand" "i")))]
2747   "TARGET_64BIT"
2748   "ldo R'%G2(%1),%0";
2749   [(set_attr "type" "move")
2750    (set_attr "length" "4")])
2752 (define_insn ""
2753   [(set (match_operand:SI 0 "register_operand" "=r")
2754         (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
2755                    (match_operand:SI 2 "immediate_operand" "i")))]
2756   "!pa_is_function_label_plus_const (operands[2])"
2757   "*
2759   gcc_assert (!flag_pic || !symbolic_operand (operands[2], Pmode));
2760   
2761   if (symbolic_operand (operands[2], Pmode))
2762     return \"ldo RR'%G2(%1),%0\";
2763   else
2764     return \"ldo R'%G2(%1),%0\";
2766   [(set_attr "type" "move")
2767    (set_attr "length" "4")])
2769 ;; Now that a symbolic_address plus a constant is broken up early
2770 ;; in the compilation phase (for better CSE) we need a special
2771 ;; combiner pattern to load the symbolic address plus the constant
2772 ;; in only 2 instructions. (For cases where the symbolic address
2773 ;; was not a common subexpression.)
2774 (define_split
2775   [(set (match_operand:SI 0 "register_operand" "")
2776         (match_operand:SI 1 "symbolic_operand" ""))
2777    (clobber (match_operand:SI 2 "register_operand" ""))]
2778   "! (flag_pic && pic_label_operand (operands[1], SImode))"
2779   [(set (match_dup 2) (high:SI (match_dup 1)))
2780    (set (match_dup 0) (lo_sum:SI (match_dup 2) (match_dup 1)))]
2781   "")
2783 ;; hppa_legitimize_address goes to a great deal of trouble to
2784 ;; create addresses which use indexing.  In some cases, this
2785 ;; is a lose because there isn't any store instructions which
2786 ;; allow indexed addresses (with integer register source).
2788 ;; These define_splits try to turn a 3 insn store into
2789 ;; a 2 insn store with some creative RTL rewriting.
2790 (define_split
2791   [(set (mem:SI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2792                                (match_operand:SI 1 "mem_shadd_operand" ""))
2793                    (plus:SI (match_operand:SI 2 "register_operand" "")
2794                             (match_operand:SI 3 "const_int_operand" ""))))
2795         (match_operand:SI 4 "register_operand" ""))
2796    (clobber (match_operand:SI 5 "register_operand" ""))]
2797   ""
2798   [(set (match_dup 5) (plus:SI (ashift:SI (match_dup 0) (match_dup 1))
2799                                (match_dup 2)))
2800    (set (mem:SI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2801   "
2803   operands[1] = GEN_INT (exact_log2 (INTVAL (operands[1])));
2807 (define_split
2808   [(set (mem:HI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2809                                (match_operand:SI 1 "mem_shadd_operand" ""))
2810                    (plus:SI (match_operand:SI 2 "register_operand" "")
2811                             (match_operand:SI 3 "const_int_operand" ""))))
2812         (match_operand:HI 4 "register_operand" ""))
2813    (clobber (match_operand:SI 5 "register_operand" ""))]
2814   ""
2815   [(set (match_dup 5) (plus:SI (ashift:SI (match_dup 0) (match_dup 1))
2816                                (match_dup 2)))
2817    (set (mem:HI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2818   "
2820   operands[1] = GEN_INT (exact_log2 (INTVAL (operands[1])));
2824 (define_split
2825   [(set (mem:QI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2826                                (match_operand:SI 1 "mem_shadd_operand" ""))
2827                    (plus:SI (match_operand:SI 2 "register_operand" "")
2828                             (match_operand:SI 3 "const_int_operand" ""))))
2829         (match_operand:QI 4 "register_operand" ""))
2830    (clobber (match_operand:SI 5 "register_operand" ""))]
2831   ""
2832   [(set (match_dup 5) (plus:SI (ashift:SI (match_dup 0) (match_dup 1))
2833                                (match_dup 2)))
2834    (set (mem:QI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2835   "
2837   operands[1] = GEN_INT (exact_log2 (INTVAL (operands[1])));
2841 (define_expand "movhi"
2842   [(set (match_operand:HI 0 "general_operand" "")
2843         (match_operand:HI 1 "general_operand" ""))]
2844   ""
2845   "
2847   if (pa_emit_move_sequence (operands, HImode, 0))
2848     DONE;
2851 ;; Handle HImode input reloads requiring a general register as a
2852 ;; scratch register.
2853 (define_expand "reload_inhi"
2854   [(set (match_operand:HI 0 "register_operand" "=Z")
2855         (match_operand:HI 1 "non_hard_reg_operand" ""))
2856    (clobber (match_operand:HI 2 "register_operand" "=&r"))]
2857   ""
2858   "
2860   if (pa_emit_move_sequence (operands, HImode, operands[2]))
2861     DONE;
2863   /* We don't want the clobber emitted, so handle this ourselves.  */
2864   emit_insn (gen_rtx_SET (operands[0], operands[1]));
2865   DONE;
2868 ;; Handle HImode output reloads requiring a general register as a
2869 ;; scratch register.
2870 (define_expand "reload_outhi"
2871   [(set (match_operand:HI 0 "non_hard_reg_operand" "")
2872         (match_operand:HI 1  "register_operand" "Z"))
2873    (clobber (match_operand:HI 2 "register_operand" "=&r"))]
2874   ""
2875   "
2877   if (pa_emit_move_sequence (operands, HImode, operands[2]))
2878     DONE;
2880   /* We don't want the clobber emitted, so handle this ourselves.  */
2881   emit_insn (gen_rtx_SET (operands[0], operands[1]));
2882   DONE;
2885 (define_insn ""
2886   [(set (match_operand:HI 0 "move_dest_operand"
2887                           "=r,r,r,r,r,Q,!*q,!r")
2888         (match_operand:HI 1 "move_src_operand"
2889                           "r,J,N,K,RQ,rM,!rM,!*q"))]
2890   "(register_operand (operands[0], HImode)
2891     || reg_or_0_operand (operands[1], HImode))"
2892   "@
2893    copy %1,%0
2894    ldi %1,%0
2895    ldil L'%1,%0
2896    {zdepi|depwi,z} %Z1,%0
2897    ldh%M1 %1,%0
2898    sth%M0 %r1,%0
2899    mtsar %r1
2900    {mfctl|mfctl,w} %sar,%0"
2901   [(set_attr "type" "move,move,move,shift,load,store,move,move")
2902    (set_attr "pa_combine_type" "addmove")
2903    (set_attr "length" "4,4,4,4,4,4,4,4")])
2905 (define_insn ""
2906   [(set (match_operand:HI 0 "register_operand" "=r")
2907         (mem:HI (plus:SI (match_operand:SI 1 "register_operand" "+r")
2908                          (match_operand:SI 2 "int5_operand" "L"))))
2909    (set (match_dup 1)
2910         (plus:SI (match_dup 1) (match_dup 2)))]
2911   ""
2912   "{ldhs|ldh},mb %2(%1),%0"
2913   [(set_attr "type" "load")
2914    (set_attr "length" "4")])
2916 (define_insn ""
2917   [(set (match_operand:HI 0 "register_operand" "=r")
2918         (mem:HI (plus:DI (match_operand:DI 1 "register_operand" "+r")
2919                          (match_operand:DI 2 "int5_operand" "L"))))
2920    (set (match_dup 1)
2921         (plus:DI (match_dup 1) (match_dup 2)))]
2922   "TARGET_64BIT"
2923   "ldh,mb %2(%1),%0"
2924   [(set_attr "type" "load")
2925    (set_attr "length" "4")])
2927 ; And a zero extended variant.
2928 (define_insn ""
2929   [(set (match_operand:DI 0 "register_operand" "=r")
2930         (zero_extend:DI (mem:HI
2931                           (plus:DI
2932                             (match_operand:DI 1 "register_operand" "+r")
2933                             (match_operand:DI 2 "int5_operand" "L")))))
2934    (set (match_dup 1)
2935         (plus:DI (match_dup 1) (match_dup 2)))]
2936   "TARGET_64BIT"
2937   "ldh,mb %2(%1),%0"
2938   [(set_attr "type" "load")
2939    (set_attr "length" "4")])
2941 (define_insn ""
2942   [(set (match_operand:SI 0 "register_operand" "=r")
2943         (zero_extend:SI (mem:HI
2944                           (plus:SI
2945                             (match_operand:SI 1 "register_operand" "+r")
2946                             (match_operand:SI 2 "int5_operand" "L")))))
2947    (set (match_dup 1)
2948         (plus:SI (match_dup 1) (match_dup 2)))]
2949   ""
2950   "{ldhs|ldh},mb %2(%1),%0"
2951   [(set_attr "type" "load")
2952    (set_attr "length" "4")])
2954 (define_insn ""
2955   [(set (match_operand:SI 0 "register_operand" "=r")
2956         (zero_extend:SI (mem:HI
2957                           (plus:DI
2958                             (match_operand:DI 1 "register_operand" "+r")
2959                             (match_operand:DI 2 "int5_operand" "L")))))
2960    (set (match_dup 1)
2961         (plus:DI (match_dup 1) (match_dup 2)))]
2962   "TARGET_64BIT"
2963   "ldh,mb %2(%1),%0"
2964   [(set_attr "type" "load")
2965    (set_attr "length" "4")])
2967 (define_insn ""
2968   [(set (mem:HI (plus:SI (match_operand:SI 0 "register_operand" "+r")
2969                          (match_operand:SI 1 "int5_operand" "L")))
2970         (match_operand:HI 2 "reg_or_0_operand" "rM"))
2971    (set (match_dup 0)
2972         (plus:SI (match_dup 0) (match_dup 1)))]
2973   ""
2974   "{sths|sth},mb %r2,%1(%0)"
2975   [(set_attr "type" "store")
2976    (set_attr "length" "4")])
2978 (define_insn ""
2979   [(set (mem:HI (plus:DI (match_operand:DI 0 "register_operand" "+r")
2980                          (match_operand:DI 1 "int5_operand" "L")))
2981         (match_operand:HI 2 "reg_or_0_operand" "rM"))
2982    (set (match_dup 0)
2983         (plus:DI (match_dup 0) (match_dup 1)))]
2984   "TARGET_64BIT"
2985   "sth,mb %r2,%1(%0)"
2986   [(set_attr "type" "store")
2987    (set_attr "length" "4")])
2989 (define_insn "addhi3"
2990   [(set (match_operand:HI 0 "register_operand" "=r,r")
2991         (plus:HI (match_operand:HI 1 "register_operand" "%r,r")
2992                  (match_operand:HI 2 "arith14_operand" "r,J")))]
2993   ""
2994   "@
2995    {addl|add,l} %1,%2,%0
2996    ldo %2(%1),%0"
2997   [(set_attr "type" "binary,binary")
2998    (set_attr "pa_combine_type" "addmove")
2999    (set_attr "length" "4,4")])
3001 (define_expand "movqi"
3002   [(set (match_operand:QI 0 "general_operand" "")
3003         (match_operand:QI 1 "general_operand" ""))]
3004   ""
3005   "
3007   if (pa_emit_move_sequence (operands, QImode, 0))
3008     DONE;
3011 ;; Handle QImode input reloads requiring a general register as a
3012 ;; scratch register.
3013 (define_expand "reload_inqi"
3014   [(set (match_operand:QI 0 "register_operand" "=Z")
3015         (match_operand:QI 1 "non_hard_reg_operand" ""))
3016    (clobber (match_operand:QI 2 "register_operand" "=&r"))]
3017   ""
3018   "
3020   if (pa_emit_move_sequence (operands, QImode, operands[2]))
3021     DONE;
3023   /* We don't want the clobber emitted, so handle this ourselves.  */
3024   emit_insn (gen_rtx_SET (operands[0], operands[1]));
3025   DONE;
3028 ;; Handle QImode output reloads requiring a general register as a
3029 ;; scratch register.
3030 (define_expand "reload_outqi"
3031   [(set (match_operand:QI 0 "non_hard_reg_operand" "")
3032         (match_operand:QI 1  "register_operand" "Z"))
3033    (clobber (match_operand:QI 2 "register_operand" "=&r"))]
3034   ""
3035   "
3037   if (pa_emit_move_sequence (operands, QImode, operands[2]))
3038     DONE;
3040   /* We don't want the clobber emitted, so handle this ourselves.  */
3041   emit_insn (gen_rtx_SET (operands[0], operands[1]));
3042   DONE;
3045 (define_insn ""
3046   [(set (match_operand:QI 0 "move_dest_operand"
3047                           "=r,r,r,r,r,Q,!*q,!r")
3048         (match_operand:QI 1 "move_src_operand"
3049                           "r,J,N,K,RQ,rM,!rM,!*q"))]
3050   "(register_operand (operands[0], QImode)
3051     || reg_or_0_operand (operands[1], QImode))"
3052   "@
3053    copy %1,%0
3054    ldi %1,%0
3055    ldil L'%1,%0
3056    {zdepi|depwi,z} %Z1,%0
3057    ldb%M1 %1,%0
3058    stb%M0 %r1,%0
3059    mtsar %r1
3060    {mfctl|mfctl,w} %%sar,%0"
3061   [(set_attr "type" "move,move,move,shift,load,store,move,move")
3062    (set_attr "pa_combine_type" "addmove")
3063    (set_attr "length" "4,4,4,4,4,4,4,4")])
3065 (define_insn ""
3066   [(set (match_operand:QI 0 "register_operand" "=r")
3067         (mem:QI (plus:SI (match_operand:SI 1 "register_operand" "+r")
3068                          (match_operand:SI 2 "int5_operand" "L"))))
3069    (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
3070   ""
3071   "{ldbs|ldb},mb %2(%1),%0"
3072   [(set_attr "type" "load")
3073    (set_attr "length" "4")])
3075 (define_insn ""
3076   [(set (match_operand:QI 0 "register_operand" "=r")
3077         (mem:QI (plus:DI (match_operand:DI 1 "register_operand" "+r")
3078                          (match_operand:DI 2 "int5_operand" "L"))))
3079    (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3080   "TARGET_64BIT"
3081   "ldb,mb %2(%1),%0"
3082   [(set_attr "type" "load")
3083    (set_attr "length" "4")])
3085 ; Now the same thing with zero extensions.
3086 (define_insn ""
3087   [(set (match_operand:DI 0 "register_operand" "=r")
3088         (zero_extend:DI (mem:QI (plus:DI
3089                                   (match_operand:DI 1 "register_operand" "+r")
3090                                   (match_operand:DI 2 "int5_operand" "L")))))
3091    (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3092   "TARGET_64BIT"
3093   "ldb,mb %2(%1),%0"
3094   [(set_attr "type" "load")
3095    (set_attr "length" "4")])
3097 (define_insn ""
3098   [(set (match_operand:SI 0 "register_operand" "=r")
3099         (zero_extend:SI (mem:QI (plus:SI
3100                                   (match_operand:SI 1 "register_operand" "+r")
3101                                   (match_operand:SI 2 "int5_operand" "L")))))
3102    (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
3103   ""
3104   "{ldbs|ldb},mb %2(%1),%0"
3105   [(set_attr "type" "load")
3106    (set_attr "length" "4")])
3108 (define_insn ""
3109   [(set (match_operand:SI 0 "register_operand" "=r")
3110         (zero_extend:SI (mem:QI (plus:DI
3111                                   (match_operand:DI 1 "register_operand" "+r")
3112                                   (match_operand:DI 2 "int5_operand" "L")))))
3113    (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3114   "TARGET_64BIT"
3115   "ldb,mb %2(%1),%0"
3116   [(set_attr "type" "load")
3117    (set_attr "length" "4")])
3119 (define_insn ""
3120   [(set (match_operand:HI 0 "register_operand" "=r")
3121         (zero_extend:HI (mem:QI (plus:SI
3122                                   (match_operand:SI 1 "register_operand" "+r")
3123                                   (match_operand:SI 2 "int5_operand" "L")))))
3124    (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
3125   ""
3126   "{ldbs|ldb},mb %2(%1),%0"
3127   [(set_attr "type" "load")
3128    (set_attr "length" "4")])
3130 (define_insn ""
3131   [(set (match_operand:HI 0 "register_operand" "=r")
3132         (zero_extend:HI (mem:QI (plus:DI
3133                                   (match_operand:DI 1 "register_operand" "+r")
3134                                   (match_operand:DI 2 "int5_operand" "L")))))
3135    (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3136   "TARGET_64BIT"
3137   "ldb,mb %2(%1),%0"
3138   [(set_attr "type" "load")
3139    (set_attr "length" "4")])
3141 (define_insn ""
3142   [(set (mem:QI (plus:SI (match_operand:SI 0 "register_operand" "+r")
3143                          (match_operand:SI 1 "int5_operand" "L")))
3144         (match_operand:QI 2 "reg_or_0_operand" "rM"))
3145    (set (match_dup 0)
3146         (plus:SI (match_dup 0) (match_dup 1)))]
3147   ""
3148   "{stbs|stb},mb %r2,%1(%0)"
3149   [(set_attr "type" "store")
3150    (set_attr "length" "4")])
3152 (define_insn ""
3153   [(set (mem:QI (plus:DI (match_operand:DI 0 "register_operand" "+r")
3154                          (match_operand:DI 1 "int5_operand" "L")))
3155         (match_operand:QI 2 "reg_or_0_operand" "rM"))
3156    (set (match_dup 0)
3157         (plus:DI (match_dup 0) (match_dup 1)))]
3158   "TARGET_64BIT"
3159   "stb,mb %r2,%1(%0)"
3160   [(set_attr "type" "store")
3161    (set_attr "length" "4")])
3163 ;; The definition of this insn does not really explain what it does,
3164 ;; but it should suffice that anything generated as this insn will be
3165 ;; recognized as a cpymemsi operation, and that it will not successfully
3166 ;; combine with anything.
3167 (define_expand "cpymemsi"
3168   [(parallel [(set (match_operand:BLK 0 "" "")
3169                    (match_operand:BLK 1 "" ""))
3170               (clobber (match_dup 4))
3171               (clobber (match_dup 5))
3172               (clobber (match_dup 6))
3173               (clobber (match_dup 7))
3174               (clobber (match_dup 8))
3175               (use (match_operand:SI 2 "arith14_operand" ""))
3176               (use (match_operand:SI 3 "const_int_operand" ""))])]
3177   "!TARGET_64BIT && optimize > 0"
3178   "
3180   int size, align;
3182   /* HP provides very fast block move library routine for the PA;
3183      this routine includes:
3185         4x4 byte at a time block moves,
3186         1x4 byte at a time with alignment checked at runtime with
3187             attempts to align the source and destination as needed
3188         1x1 byte loop
3190      With that in mind, here's the heuristics to try and guess when
3191      the inlined block move will be better than the library block
3192      move:
3194         If the size isn't constant, then always use the library routines.
3196         If the size is large in respect to the known alignment, then use
3197         the library routines.
3199         If the size is small in respect to the known alignment, then open
3200         code the copy (since that will lead to better scheduling).
3202         Else use the block move pattern.   */
3204   /* Undetermined size, use the library routine.  */
3205   if (GET_CODE (operands[2]) != CONST_INT)
3206     FAIL;
3208   size = INTVAL (operands[2]);
3209   align = INTVAL (operands[3]);
3210   align = align > 4 ? 4 : (align ? align : 1);
3212   /* If size/alignment is large, then use the library routines.  */
3213   if (size / align > 16)
3214     FAIL;
3216   /* This does happen, but not often enough to worry much about.  */
3217   if (size / align < MOVE_RATIO (optimize_insn_for_speed_p ()))
3218     FAIL;
3219   
3220   /* Fall through means we're going to use our block move pattern.  */
3221   operands[0]
3222     = replace_equiv_address (operands[0],
3223                              copy_to_mode_reg (SImode, XEXP (operands[0], 0)));
3224   operands[1]
3225     = replace_equiv_address (operands[1],
3226                              copy_to_mode_reg (SImode, XEXP (operands[1], 0)));
3227   operands[4] = gen_reg_rtx (SImode);
3228   operands[5] = gen_reg_rtx (SImode);
3229   operands[6] = gen_reg_rtx (SImode);
3230   operands[7] = gen_reg_rtx (SImode);
3231   operands[8] = gen_reg_rtx (SImode);
3234 ;; The operand constraints are written like this to support both compile-time
3235 ;; and run-time determined byte counts.  The expander and pa_output_block_move
3236 ;; only support compile-time determined counts at this time.
3238 ;; If the count is run-time determined, the register with the byte count
3239 ;; is clobbered by the copying code, and therefore it is forced to operand 2.
3241 ;; We used to clobber operands 0 and 1.  However, a change to regrename.c
3242 ;; broke this semantic for pseudo registers.  We can't use match_scratch
3243 ;; as this requires two registers in the class R1_REGS when the MEMs for
3244 ;; operands 0 and 1 are both equivalent to symbolic MEMs.  Thus, we are
3245 ;; forced to internally copy operands 0 and 1 to operands 7 and 8,
3246 ;; respectively.  We then split or peephole optimize after reload.
3247 (define_insn "cpymemsi_prereload"
3248   [(set (mem:BLK (match_operand:SI 0 "register_operand" "r,r"))
3249         (mem:BLK (match_operand:SI 1 "register_operand" "r,r")))
3250    (clobber (match_operand:SI 2 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3251    (clobber (match_operand:SI 3 "register_operand" "=&r,&r"))   ;item tmp1
3252    (clobber (match_operand:SI 6 "register_operand" "=&r,&r"))   ;item tmp2
3253    (clobber (match_operand:SI 7 "register_operand" "=&r,&r"))   ;item tmp3
3254    (clobber (match_operand:SI 8 "register_operand" "=&r,&r"))   ;item tmp4
3255    (use (match_operand:SI 4 "arith14_operand" "J,2"))    ;byte count
3256    (use (match_operand:SI 5 "const_int_operand" "n,n"))] ;alignment
3257   "!TARGET_64BIT"
3258   "#"
3259   [(set_attr "type" "multi,multi")])
3261 (define_split
3262   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3263                    (match_operand:BLK 1 "memory_operand" ""))
3264               (clobber (match_operand:SI 2 "register_operand" ""))
3265               (clobber (match_operand:SI 3 "register_operand" ""))
3266               (clobber (match_operand:SI 6 "register_operand" ""))
3267               (clobber (match_operand:SI 7 "register_operand" ""))
3268               (clobber (match_operand:SI 8 "register_operand" ""))
3269               (use (match_operand:SI 4 "arith14_operand" ""))
3270               (use (match_operand:SI 5 "const_int_operand" ""))])]
3271   "!TARGET_64BIT && reload_completed && !flag_peephole2
3272    && GET_CODE (operands[0]) == MEM
3273    && register_operand (XEXP (operands[0], 0), SImode)
3274    && GET_CODE (operands[1]) == MEM
3275    && register_operand (XEXP (operands[1], 0), SImode)"
3276   [(set (match_dup 7) (match_dup 9))
3277    (set (match_dup 8) (match_dup 10))
3278    (parallel [(set (match_dup 0) (match_dup 1))
3279               (clobber (match_dup 2))
3280               (clobber (match_dup 3))
3281               (clobber (match_dup 6))
3282               (clobber (match_dup 7))
3283               (clobber (match_dup 8))
3284               (use (match_dup 4))
3285               (use (match_dup 5))
3286               (const_int 0)])]
3287   "
3289   operands[9] = XEXP (operands[0], 0);
3290   operands[10] = XEXP (operands[1], 0);
3291   operands[0] = replace_equiv_address (operands[0], operands[7]);
3292   operands[1] = replace_equiv_address (operands[1], operands[8]);
3295 (define_peephole2
3296   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3297                    (match_operand:BLK 1 "memory_operand" ""))
3298               (clobber (match_operand:SI 2 "register_operand" ""))
3299               (clobber (match_operand:SI 3 "register_operand" ""))
3300               (clobber (match_operand:SI 6 "register_operand" ""))
3301               (clobber (match_operand:SI 7 "register_operand" ""))
3302               (clobber (match_operand:SI 8 "register_operand" ""))
3303               (use (match_operand:SI 4 "arith14_operand" ""))
3304               (use (match_operand:SI 5 "const_int_operand" ""))])]
3305   "!TARGET_64BIT
3306    && GET_CODE (operands[0]) == MEM
3307    && register_operand (XEXP (operands[0], 0), SImode)
3308    && GET_CODE (operands[1]) == MEM
3309    && register_operand (XEXP (operands[1], 0), SImode)"
3310   [(parallel [(set (match_dup 0) (match_dup 1))
3311               (clobber (match_dup 2))
3312               (clobber (match_dup 3))
3313               (clobber (match_dup 6))
3314               (clobber (match_dup 7))
3315               (clobber (match_dup 8))
3316               (use (match_dup 4))
3317               (use (match_dup 5))
3318               (const_int 0)])]
3319   "
3321   rtx addr = XEXP (operands[0], 0);
3322   if (dead_or_set_p (curr_insn, addr))
3323     operands[7] = addr;
3324   else
3325     {
3326       emit_insn (gen_rtx_SET (operands[7], addr));
3327       operands[0] = replace_equiv_address (operands[0], operands[7]);
3328     }
3330   addr = XEXP (operands[1], 0);
3331   if (dead_or_set_p (curr_insn, addr))
3332     operands[8] = addr;
3333   else
3334     {
3335       emit_insn (gen_rtx_SET (operands[8], addr));
3336       operands[1] = replace_equiv_address (operands[1], operands[8]);
3337     }
3340 (define_insn "cpymemsi_postreload"
3341   [(set (mem:BLK (match_operand:SI 0 "register_operand" "+r,r"))
3342         (mem:BLK (match_operand:SI 1 "register_operand" "+r,r")))
3343    (clobber (match_operand:SI 2 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3344    (clobber (match_operand:SI 3 "register_operand" "=&r,&r"))   ;item tmp1
3345    (clobber (match_operand:SI 6 "register_operand" "=&r,&r"))   ;item tmp2
3346    (clobber (match_dup 0))
3347    (clobber (match_dup 1))
3348    (use (match_operand:SI 4 "arith14_operand" "J,2"))    ;byte count
3349    (use (match_operand:SI 5 "const_int_operand" "n,n"))  ;alignment
3350    (const_int 0)]
3351   "!TARGET_64BIT && reload_completed"
3352   "* return pa_output_block_move (operands, !which_alternative);"
3353   [(set_attr "type" "multi,multi")])
3355 (define_expand "cpymemdi"
3356   [(parallel [(set (match_operand:BLK 0 "" "")
3357                    (match_operand:BLK 1 "" ""))
3358               (clobber (match_dup 4))
3359               (clobber (match_dup 5))
3360               (clobber (match_dup 6))
3361               (clobber (match_dup 7))
3362               (clobber (match_dup 8))
3363               (use (match_operand:DI 2 "arith14_operand" ""))
3364               (use (match_operand:DI 3 "const_int_operand" ""))])]
3365   "TARGET_64BIT && optimize > 0"
3366   "
3368   int size, align;
3370   /* HP provides very fast block move library routine for the PA;
3371      this routine includes:
3373         4x4 byte at a time block moves,
3374         1x4 byte at a time with alignment checked at runtime with
3375             attempts to align the source and destination as needed
3376         1x1 byte loop
3378      With that in mind, here's the heuristics to try and guess when
3379      the inlined block move will be better than the library block
3380      move:
3382         If the size isn't constant, then always use the library routines.
3384         If the size is large in respect to the known alignment, then use
3385         the library routines.
3387         If the size is small in respect to the known alignment, then open
3388         code the copy (since that will lead to better scheduling).
3390         Else use the block move pattern.   */
3392   /* Undetermined size, use the library routine.  */
3393   if (GET_CODE (operands[2]) != CONST_INT)
3394     FAIL;
3396   size = INTVAL (operands[2]);
3397   align = INTVAL (operands[3]);
3398   align = align > 8 ? 8 : (align ? align : 1);
3400   /* If size/alignment is large, then use the library routines.  */
3401   if (size / align > 16)
3402     FAIL;
3404   /* This does happen, but not often enough to worry much about.  */
3405   if (size / align < MOVE_RATIO (optimize_insn_for_speed_p ()))
3406     FAIL;
3407   
3408   /* Fall through means we're going to use our block move pattern.  */
3409   operands[0]
3410     = replace_equiv_address (operands[0],
3411                              copy_to_mode_reg (DImode, XEXP (operands[0], 0)));
3412   operands[1]
3413     = replace_equiv_address (operands[1],
3414                              copy_to_mode_reg (DImode, XEXP (operands[1], 0)));
3415   operands[4] = gen_reg_rtx (DImode);
3416   operands[5] = gen_reg_rtx (DImode);
3417   operands[6] = gen_reg_rtx (DImode);
3418   operands[7] = gen_reg_rtx (DImode);
3419   operands[8] = gen_reg_rtx (DImode);
3422 ;; The operand constraints are written like this to support both compile-time
3423 ;; and run-time determined byte counts.  The expander and pa_output_block_move
3424 ;; only support compile-time determined counts at this time.
3426 ;; If the count is run-time determined, the register with the byte count
3427 ;; is clobbered by the copying code, and therefore it is forced to operand 2.
3429 ;; We used to clobber operands 0 and 1.  However, a change to regrename.c
3430 ;; broke this semantic for pseudo registers.  We can't use match_scratch
3431 ;; as this requires two registers in the class R1_REGS when the MEMs for
3432 ;; operands 0 and 1 are both equivalent to symbolic MEMs.  Thus, we are
3433 ;; forced to internally copy operands 0 and 1 to operands 7 and 8,
3434 ;; respectively.  We then split or peephole optimize after reload.
3435 (define_insn "cpymemdi_prereload"
3436   [(set (mem:BLK (match_operand:DI 0 "register_operand" "r,r"))
3437         (mem:BLK (match_operand:DI 1 "register_operand" "r,r")))
3438    (clobber (match_operand:DI 2 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3439    (clobber (match_operand:DI 3 "register_operand" "=&r,&r"))   ;item tmp1
3440    (clobber (match_operand:DI 6 "register_operand" "=&r,&r"))   ;item tmp2
3441    (clobber (match_operand:DI 7 "register_operand" "=&r,&r"))   ;item tmp3
3442    (clobber (match_operand:DI 8 "register_operand" "=&r,&r"))   ;item tmp4
3443    (use (match_operand:DI 4 "arith14_operand" "J,2"))    ;byte count
3444    (use (match_operand:DI 5 "const_int_operand" "n,n"))] ;alignment
3445   "TARGET_64BIT"
3446   "#"
3447   [(set_attr "type" "multi,multi")])
3449 (define_split
3450   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3451                    (match_operand:BLK 1 "memory_operand" ""))
3452               (clobber (match_operand:DI 2 "register_operand" ""))
3453               (clobber (match_operand:DI 3 "register_operand" ""))
3454               (clobber (match_operand:DI 6 "register_operand" ""))
3455               (clobber (match_operand:DI 7 "register_operand" ""))
3456               (clobber (match_operand:DI 8 "register_operand" ""))
3457               (use (match_operand:DI 4 "arith14_operand" ""))
3458               (use (match_operand:DI 5 "const_int_operand" ""))])]
3459   "TARGET_64BIT && reload_completed && !flag_peephole2
3460    && GET_CODE (operands[0]) == MEM
3461    && register_operand (XEXP (operands[0], 0), DImode)
3462    && GET_CODE (operands[1]) == MEM
3463    && register_operand (XEXP (operands[1], 0), DImode)"
3464   [(set (match_dup 7) (match_dup 9))
3465    (set (match_dup 8) (match_dup 10))
3466    (parallel [(set (match_dup 0) (match_dup 1))
3467               (clobber (match_dup 2))
3468               (clobber (match_dup 3))
3469               (clobber (match_dup 6))
3470               (clobber (match_dup 7))
3471               (clobber (match_dup 8))
3472               (use (match_dup 4))
3473               (use (match_dup 5))
3474               (const_int 0)])]
3475   "
3477   operands[9] = XEXP (operands[0], 0);
3478   operands[10] = XEXP (operands[1], 0);
3479   operands[0] = replace_equiv_address (operands[0], operands[7]);
3480   operands[1] = replace_equiv_address (operands[1], operands[8]);
3483 (define_peephole2
3484   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3485                    (match_operand:BLK 1 "memory_operand" ""))
3486               (clobber (match_operand:DI 2 "register_operand" ""))
3487               (clobber (match_operand:DI 3 "register_operand" ""))
3488               (clobber (match_operand:DI 6 "register_operand" ""))
3489               (clobber (match_operand:DI 7 "register_operand" ""))
3490               (clobber (match_operand:DI 8 "register_operand" ""))
3491               (use (match_operand:DI 4 "arith14_operand" ""))
3492               (use (match_operand:DI 5 "const_int_operand" ""))])]
3493   "TARGET_64BIT
3494    && GET_CODE (operands[0]) == MEM
3495    && register_operand (XEXP (operands[0], 0), DImode)
3496    && GET_CODE (operands[1]) == MEM
3497    && register_operand (XEXP (operands[1], 0), DImode)"
3498   [(parallel [(set (match_dup 0) (match_dup 1))
3499               (clobber (match_dup 2))
3500               (clobber (match_dup 3))
3501               (clobber (match_dup 6))
3502               (clobber (match_dup 7))
3503               (clobber (match_dup 8))
3504               (use (match_dup 4))
3505               (use (match_dup 5))
3506               (const_int 0)])]
3507   "
3509   rtx addr = XEXP (operands[0], 0);
3510   if (dead_or_set_p (curr_insn, addr))
3511     operands[7] = addr;
3512   else
3513     {
3514       emit_insn (gen_rtx_SET (operands[7], addr));
3515       operands[0] = replace_equiv_address (operands[0], operands[7]);
3516     }
3518   addr = XEXP (operands[1], 0);
3519   if (dead_or_set_p (curr_insn, addr))
3520     operands[8] = addr;
3521   else
3522     {
3523       emit_insn (gen_rtx_SET (operands[8], addr));
3524       operands[1] = replace_equiv_address (operands[1], operands[8]);
3525     }
3528 (define_insn "cpymemdi_postreload"
3529   [(set (mem:BLK (match_operand:DI 0 "register_operand" "+r,r"))
3530         (mem:BLK (match_operand:DI 1 "register_operand" "+r,r")))
3531    (clobber (match_operand:DI 2 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3532    (clobber (match_operand:DI 3 "register_operand" "=&r,&r"))   ;item tmp1
3533    (clobber (match_operand:DI 6 "register_operand" "=&r,&r"))   ;item tmp2
3534    (clobber (match_dup 0))
3535    (clobber (match_dup 1))
3536    (use (match_operand:DI 4 "arith14_operand" "J,2"))    ;byte count
3537    (use (match_operand:DI 5 "const_int_operand" "n,n"))  ;alignment
3538    (const_int 0)]
3539   "TARGET_64BIT && reload_completed"
3540   "* return pa_output_block_move (operands, !which_alternative);"
3541   [(set_attr "type" "multi,multi")])
3543 (define_expand "setmemsi"
3544   [(parallel [(set (match_operand:BLK 0 "" "")
3545                    (match_operand 2 "const_int_operand" ""))
3546               (clobber (match_dup 4))
3547               (clobber (match_dup 5))
3548               (use (match_operand:SI 1 "arith14_operand" ""))
3549               (use (match_operand:SI 3 "const_int_operand" ""))])]
3550   "!TARGET_64BIT && optimize > 0"
3551   "
3553   int size, align;
3555   /* If value to set is not zero, use the library routine.  */
3556   if (operands[2] != const0_rtx)
3557     FAIL;
3559   /* Undetermined size, use the library routine.  */
3560   if (GET_CODE (operands[1]) != CONST_INT)
3561     FAIL;
3563   size = INTVAL (operands[1]);
3564   align = INTVAL (operands[3]);
3565   align = align > 4 ? 4 : align;
3567   /* If size/alignment is large, then use the library routines.  */
3568   if (size / align > 16)
3569     FAIL;
3571   /* This does happen, but not often enough to worry much about.  */
3572   if (size / align < MOVE_RATIO (optimize_insn_for_speed_p ()))
3573     FAIL;
3574   
3575   /* Fall through means we're going to use our block clear pattern.  */
3576   operands[0]
3577     = replace_equiv_address (operands[0],
3578                              copy_to_mode_reg (SImode, XEXP (operands[0], 0)));
3579   operands[4] = gen_reg_rtx (SImode);
3580   operands[5] = gen_reg_rtx (SImode);
3583 (define_insn "clrmemsi_prereload"
3584   [(set (mem:BLK (match_operand:SI 0 "register_operand" "r,r"))
3585         (const_int 0))
3586    (clobber (match_operand:SI 1 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3587    (clobber (match_operand:SI 4 "register_operand" "=&r,&r"))   ;tmp1
3588    (use (match_operand:SI 2 "arith14_operand" "J,1"))    ;byte count
3589    (use (match_operand:SI 3 "const_int_operand" "n,n"))] ;alignment
3590   "!TARGET_64BIT"
3591   "#"
3592   [(set_attr "type" "multi,multi")])
3594 (define_split
3595   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3596                    (const_int 0))
3597               (clobber (match_operand:SI 1 "register_operand" ""))
3598               (clobber (match_operand:SI 4 "register_operand" ""))
3599               (use (match_operand:SI 2 "arith14_operand" ""))
3600               (use (match_operand:SI 3 "const_int_operand" ""))])]
3601   "!TARGET_64BIT && reload_completed && !flag_peephole2
3602    && GET_CODE (operands[0]) == MEM
3603    && register_operand (XEXP (operands[0], 0), SImode)"
3604   [(set (match_dup 4) (match_dup 5))
3605    (parallel [(set (match_dup 0) (const_int 0))
3606               (clobber (match_dup 1))
3607               (clobber (match_dup 4))
3608               (use (match_dup 2))
3609               (use (match_dup 3))
3610               (const_int 0)])]
3611   "
3613   operands[5] = XEXP (operands[0], 0);
3614   operands[0] = replace_equiv_address (operands[0], operands[4]);
3617 (define_peephole2
3618   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3619                    (const_int 0))
3620               (clobber (match_operand:SI 1 "register_operand" ""))
3621               (clobber (match_operand:SI 4 "register_operand" ""))
3622               (use (match_operand:SI 2 "arith14_operand" ""))
3623               (use (match_operand:SI 3 "const_int_operand" ""))])]
3624   "!TARGET_64BIT
3625    && GET_CODE (operands[0]) == MEM
3626    && register_operand (XEXP (operands[0], 0), SImode)"
3627   [(parallel [(set (match_dup 0) (const_int 0))
3628               (clobber (match_dup 1))
3629               (clobber (match_dup 4))
3630               (use (match_dup 2))
3631               (use (match_dup 3))
3632               (const_int 0)])]
3633   "
3635   rtx addr = XEXP (operands[0], 0);
3636   if (dead_or_set_p (curr_insn, addr))
3637     operands[4] = addr;
3638   else
3639     {
3640       emit_insn (gen_rtx_SET (operands[4], addr));
3641       operands[0] = replace_equiv_address (operands[0], operands[4]);
3642     }
3645 (define_insn "clrmemsi_postreload"
3646   [(set (mem:BLK (match_operand:SI 0 "register_operand" "+r,r"))
3647         (const_int 0))
3648    (clobber (match_operand:SI 1 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3649    (clobber (match_dup 0))
3650    (use (match_operand:SI 2 "arith14_operand" "J,1"))    ;byte count
3651    (use (match_operand:SI 3 "const_int_operand" "n,n"))  ;alignment
3652    (const_int 0)]
3653   "!TARGET_64BIT && reload_completed"
3654   "* return pa_output_block_clear (operands, !which_alternative);"
3655   [(set_attr "type" "multi,multi")])
3657 (define_expand "setmemdi"
3658   [(parallel [(set (match_operand:BLK 0 "" "")
3659                    (match_operand 2 "const_int_operand" ""))
3660               (clobber (match_dup 4))
3661               (clobber (match_dup 5))
3662               (use (match_operand:DI 1 "arith14_operand" ""))
3663               (use (match_operand:DI 3 "const_int_operand" ""))])]
3664   "TARGET_64BIT && optimize > 0"
3665   "
3667   int size, align;
3669   /* If value to set is not zero, use the library routine.  */
3670   if (operands[2] != const0_rtx)
3671     FAIL;
3673   /* Undetermined size, use the library routine.  */
3674   if (GET_CODE (operands[1]) != CONST_INT)
3675     FAIL;
3677   size = INTVAL (operands[1]);
3678   align = INTVAL (operands[3]);
3679   align = align > 8 ? 8 : align;
3681   /* If size/alignment is large, then use the library routines.  */
3682   if (size / align > 16)
3683     FAIL;
3685   /* This does happen, but not often enough to worry much about.  */
3686   if (size / align < MOVE_RATIO (optimize_insn_for_speed_p ()))
3687     FAIL;
3688   
3689   /* Fall through means we're going to use our block clear pattern.  */
3690   operands[0]
3691     = replace_equiv_address (operands[0],
3692                              copy_to_mode_reg (DImode, XEXP (operands[0], 0)));
3693   operands[4] = gen_reg_rtx (DImode);
3694   operands[5] = gen_reg_rtx (DImode);
3697 (define_insn "clrmemdi_prereload"
3698   [(set (mem:BLK (match_operand:DI 0 "register_operand" "r,r"))
3699         (const_int 0))
3700    (clobber (match_operand:DI 1 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3701    (clobber (match_operand:DI 4 "register_operand" "=&r,&r"))   ;item tmp1
3702    (use (match_operand:DI 2 "arith14_operand" "J,1"))    ;byte count
3703    (use (match_operand:DI 3 "const_int_operand" "n,n"))] ;alignment
3704   "TARGET_64BIT"
3705   "#"
3706   [(set_attr "type" "multi,multi")])
3708 (define_split
3709   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3710                    (const_int 0))
3711               (clobber (match_operand:DI 1 "register_operand" ""))
3712               (clobber (match_operand:DI 4 "register_operand" ""))
3713               (use (match_operand:DI 2 "arith14_operand" ""))
3714               (use (match_operand:DI 3 "const_int_operand" ""))])]
3715   "TARGET_64BIT && reload_completed && !flag_peephole2
3716    && GET_CODE (operands[0]) == MEM
3717    && register_operand (XEXP (operands[0], 0), DImode)"
3718   [(set (match_dup 4) (match_dup 5))
3719    (parallel [(set (match_dup 0) (const_int 0))
3720               (clobber (match_dup 1))
3721               (clobber (match_dup 4))
3722               (use (match_dup 2))
3723               (use (match_dup 3))
3724               (const_int 0)])]
3725   "
3727   operands[5] = XEXP (operands[0], 0);
3728   operands[0] = replace_equiv_address (operands[0], operands[4]);
3731 (define_peephole2
3732   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3733                    (const_int 0))
3734               (clobber (match_operand:DI 1 "register_operand" ""))
3735               (clobber (match_operand:DI 4 "register_operand" ""))
3736               (use (match_operand:DI 2 "arith14_operand" ""))
3737               (use (match_operand:DI 3 "const_int_operand" ""))])]
3738   "TARGET_64BIT
3739    && GET_CODE (operands[0]) == MEM
3740    && register_operand (XEXP (operands[0], 0), DImode)"
3741   [(parallel [(set (match_dup 0) (const_int 0))
3742               (clobber (match_dup 1))
3743               (clobber (match_dup 4))
3744               (use (match_dup 2))
3745               (use (match_dup 3))
3746               (const_int 0)])]
3747   "
3748 {  
3749   rtx addr = XEXP (operands[0], 0);
3750   if (dead_or_set_p (curr_insn, addr))
3751     operands[4] = addr;
3752   else
3753     {
3754       emit_insn (gen_rtx_SET (operands[4], addr));
3755       operands[0] = replace_equiv_address (operands[0], operands[4]);
3756     }
3759 (define_insn "clrmemdi_postreload"
3760   [(set (mem:BLK (match_operand:DI 0 "register_operand" "+r,r"))
3761         (const_int 0))
3762    (clobber (match_operand:DI 1 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3763    (clobber (match_dup 0))
3764    (use (match_operand:DI 2 "arith14_operand" "J,1"))    ;byte count
3765    (use (match_operand:DI 3 "const_int_operand" "n,n"))  ;alignment
3766    (const_int 0)]
3767   "TARGET_64BIT && reload_completed"
3768   "* return pa_output_block_clear (operands, !which_alternative);"
3769   [(set_attr "type" "multi,multi")])
3771 ;; Floating point move insns
3773 (define_expand "movdf"
3774   [(set (match_operand:DF 0 "general_operand" "")
3775         (match_operand:DF 1 "general_operand" ""))]
3776   ""
3777   "
3779   if (pa_emit_move_sequence (operands, DFmode, 0))
3780     DONE;
3783 ;; Handle DFmode input reloads requiring %r1 as a scratch register.
3784 (define_expand "reload_indf_r1"
3785   [(set (match_operand:DF 0 "register_operand" "=Z")
3786         (match_operand:DF 1 "non_hard_reg_operand" ""))
3787    (clobber (match_operand:SI 2 "register_operand" "=&a"))]
3788   ""
3789   "
3791   if (pa_emit_move_sequence (operands, DFmode, operands[2]))
3792     DONE;
3794   /* We don't want the clobber emitted, so handle this ourselves.  */
3795   emit_insn (gen_rtx_SET (operands[0], operands[1]));
3796   DONE;
3799 ;; Handle DFmode input reloads requiring a general register as a
3800 ;; scratch register.
3801 (define_expand "reload_indf"
3802   [(set (match_operand:DF 0 "register_operand" "=Z")
3803         (match_operand:DF 1 "non_hard_reg_operand" ""))
3804    (clobber (match_operand:DF 2 "register_operand" "=&r"))]
3805   ""
3806   "
3808   if (pa_emit_move_sequence (operands, DFmode, operands[2]))
3809     DONE;
3811   /* We don't want the clobber emitted, so handle this ourselves.  */
3812   emit_insn (gen_rtx_SET (operands[0], operands[1]));
3813   DONE;
3816 ;; Handle DFmode output reloads requiring a general register as a
3817 ;; scratch register.
3818 (define_expand "reload_outdf" 
3819  [(set (match_operand:DF 0 "non_hard_reg_operand" "")
3820         (match_operand:DF 1  "register_operand" "Z"))
3821    (clobber (match_operand:DF 2 "register_operand" "=&r"))]
3822   ""
3823   "
3825   if (pa_emit_move_sequence (operands, DFmode, operands[2]))
3826     DONE;
3828   /* We don't want the clobber emitted, so handle this ourselves.  */
3829   emit_insn (gen_rtx_SET (operands[0], operands[1]));
3830   DONE;
3833 (define_insn ""
3834   [(set (match_operand:DF 0 "move_dest_operand"
3835                           "=f,*r,T,?o,?Q,f,*r,*r,?*r,?f")
3836         (match_operand:DF 1 "reg_or_0_or_nonsymb_mem_operand"
3837                           "fG,*rG,f,*r,*r,RT,o,RQ,f,*r"))]
3838   "(register_operand (operands[0], DFmode)
3839     || reg_or_0_operand (operands[1], DFmode))
3840    && !(GET_CODE (operands[1]) == CONST_DOUBLE
3841         && GET_CODE (operands[0]) == MEM)
3842    && !TARGET_64BIT
3843    && !TARGET_SOFT_FLOAT"
3844   "*
3846   if ((FP_REG_P (operands[0]) || FP_REG_P (operands[1])
3847        || operands[1] == CONST0_RTX (DFmode))
3848       && !(REG_P (operands[0]) && REG_P (operands[1])
3849            && FP_REG_P (operands[0]) ^ FP_REG_P (operands[1])))
3850     return pa_output_fp_move_double (operands);
3851   return pa_output_move_double (operands);
3853   [(set_attr "type" "fpalu,move,fpstore,store,store,fpload,load,load,fpstore_load,store_fpload")
3854    (set_attr "length" "4,8,4,8,16,4,8,16,12,12")])
3856 (define_insn ""
3857   [(set (match_operand:DF 0 "indexed_memory_operand" "=R")
3858         (match_operand:DF 1 "reg_or_0_operand" "f"))]
3859   "!TARGET_SOFT_FLOAT
3860    && !TARGET_DISABLE_INDEXING
3861    && reload_completed"
3862   "fstd%F0 %1,%0"
3863   [(set_attr "type" "fpstore")
3864    (set_attr "pa_combine_type" "addmove")
3865    (set_attr "length" "4")])
3867 (define_peephole2
3868   [(set (match_operand:SI 0 "register_operand" "")
3869         (plus:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
3870                             (const_int 3))
3871                  (match_operand:SI 2 "register_operand" "")))
3872    (set (mem:DF (match_dup 0))
3873         (match_operand:DF 3 "register_operand" ""))]
3874   "!TARGET_SOFT_FLOAT
3875    && !TARGET_DISABLE_INDEXING
3876    && REG_OK_FOR_BASE_P (operands[2])
3877    && FP_REGNO_P (REGNO (operands[3]))"
3878   [(set (mem:DF (plus:SI (mult:SI (match_dup 1) (const_int 8)) (match_dup 2)))
3879         (match_dup 3))
3880    (set (match_dup 0) (plus:SI (ashift:SI (match_dup 1) (const_int 3))
3881                                (match_dup 2)))]
3882   "")
3884 (define_peephole2
3885   [(set (match_operand:SI 0 "register_operand" "")
3886         (plus:SI (match_operand:SI 2 "register_operand" "")
3887                  (ashift:SI (match_operand:SI 1 "register_operand" "")
3888                             (const_int 3))))
3889    (set (mem:DF (match_dup 0))
3890         (match_operand:DF 3 "register_operand" ""))]
3891   "!TARGET_SOFT_FLOAT
3892    && !TARGET_DISABLE_INDEXING
3893    && REG_OK_FOR_BASE_P (operands[2])
3894    && FP_REGNO_P (REGNO (operands[3]))"
3895   [(set (mem:DF (plus:SI (mult:SI (match_dup 1) (const_int 8)) (match_dup 2)))
3896         (match_dup 3))
3897    (set (match_dup 0) (plus:SI (ashift:SI (match_dup 1) (const_int 3))
3898                                (match_dup 2)))]
3899   "")
3901 (define_peephole2
3902   [(set (match_operand:DI 0 "register_operand" "")
3903         (plus:DI (ashift:DI (match_operand:DI 1 "register_operand" "")
3904                             (const_int 3))
3905                  (match_operand:DI 2 "register_operand" "")))
3906    (set (mem:DF (match_dup 0))
3907         (match_operand:DF 3 "register_operand" ""))]
3908   "!TARGET_SOFT_FLOAT
3909    && !TARGET_DISABLE_INDEXING
3910    && TARGET_64BIT
3911    && REG_OK_FOR_BASE_P (operands[2])
3912    && FP_REGNO_P (REGNO (operands[3]))"
3913   [(set (mem:DF (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
3914         (match_dup 3))
3915    (set (match_dup 0) (plus:DI (ashift:DI (match_dup 1) (const_int 3))
3916                                (match_dup 2)))]
3917   "")
3919 (define_peephole2
3920   [(set (match_operand:DI 0 "register_operand" "")
3921         (plus:DI (match_operand:DI 2 "register_operand" "")
3922                  (ashift:DI (match_operand:DI 1 "register_operand" "")
3923                             (const_int 3))))
3924    (set (mem:DF (match_dup 0))
3925         (match_operand:DF 3 "register_operand" ""))]
3926   "!TARGET_SOFT_FLOAT
3927    && !TARGET_DISABLE_INDEXING
3928    && TARGET_64BIT
3929    && REG_OK_FOR_BASE_P (operands[2])
3930    && FP_REGNO_P (REGNO (operands[3]))"
3931   [(set (mem:DF (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
3932         (match_dup 3))
3933    (set (match_dup 0) (plus:DI (ashift:DI (match_dup 1) (const_int 3))
3934                                (match_dup 2)))]
3935   "")
3937 (define_peephole2
3938   [(set (match_operand:SI 0 "register_operand" "")
3939         (plus:SI (match_operand:SI 1 "register_operand" "")
3940                  (match_operand:SI 2 "register_operand" "")))
3941    (set (mem:DF (match_dup 0))
3942         (match_operand:DF 3 "register_operand" ""))]
3943   "!TARGET_SOFT_FLOAT
3944    && !TARGET_DISABLE_INDEXING
3945    && TARGET_NO_SPACE_REGS
3946    && REG_OK_FOR_INDEX_P (operands[1])
3947    && REG_OK_FOR_BASE_P (operands[2])
3948    && FP_REGNO_P (REGNO (operands[3]))"
3949   [(set (mem:DF (plus:SI (match_dup 1) (match_dup 2)))
3950         (match_dup 3))
3951    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
3952   "")
3954 (define_peephole2
3955   [(set (match_operand:SI 0 "register_operand" "")
3956         (plus:SI (match_operand:SI 1 "register_operand" "")
3957                  (match_operand:SI 2 "register_operand" "")))
3958    (set (mem:DF (match_dup 0))
3959         (match_operand:DF 3 "register_operand" ""))]
3960   "!TARGET_SOFT_FLOAT
3961    && !TARGET_DISABLE_INDEXING
3962    && TARGET_NO_SPACE_REGS
3963    && REG_OK_FOR_BASE_P (operands[1])
3964    && REG_OK_FOR_INDEX_P (operands[2])
3965    && FP_REGNO_P (REGNO (operands[3]))"
3966   [(set (mem:DF (plus:SI (match_dup 2) (match_dup 1)))
3967         (match_dup 3))
3968    (set (match_dup 0) (plus:SI (match_dup 2) (match_dup 1)))]
3969   "")
3971 (define_peephole2
3972   [(set (match_operand:DI 0 "register_operand" "")
3973         (plus:DI (match_operand:DI 1 "register_operand" "")
3974                  (match_operand:DI 2 "register_operand" "")))
3975    (set (mem:DF (match_dup 0))
3976         (match_operand:DF 3 "register_operand" ""))]
3977   "!TARGET_SOFT_FLOAT
3978    && !TARGET_DISABLE_INDEXING
3979    && TARGET_64BIT
3980    && TARGET_NO_SPACE_REGS
3981    && REG_OK_FOR_INDEX_P (operands[1])
3982    && REG_OK_FOR_BASE_P (operands[2])
3983    && FP_REGNO_P (REGNO (operands[3]))"
3984   [(set (mem:DF (plus:DI (match_dup 1) (match_dup 2)))
3985         (match_dup 3))
3986    (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
3987   "")
3989 (define_peephole2
3990   [(set (match_operand:DI 0 "register_operand" "")
3991         (plus:DI (match_operand:DI 1 "register_operand" "")
3992                  (match_operand:DI 2 "register_operand" "")))
3993    (set (mem:DF (match_dup 0))
3994         (match_operand:DF 3 "register_operand" ""))]
3995   "!TARGET_SOFT_FLOAT
3996    && !TARGET_DISABLE_INDEXING
3997    && TARGET_64BIT
3998    && TARGET_NO_SPACE_REGS
3999    && REG_OK_FOR_BASE_P (operands[1])
4000    && REG_OK_FOR_INDEX_P (operands[2])
4001    && FP_REGNO_P (REGNO (operands[3]))"
4002   [(set (mem:DF (plus:DI (match_dup 2) (match_dup 1)))
4003         (match_dup 3))
4004    (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
4005   "")
4007 (define_insn ""
4008   [(set (match_operand:DF 0 "move_dest_operand"
4009                           "=r,?o,?Q,r,r")
4010         (match_operand:DF 1 "reg_or_0_or_nonsymb_mem_operand"
4011                           "rG,r,r,o,RQ"))]
4012   "(register_operand (operands[0], DFmode)
4013     || reg_or_0_operand (operands[1], DFmode))
4014    && !TARGET_64BIT
4015    && TARGET_SOFT_FLOAT"
4016   "*
4018   return pa_output_move_double (operands);
4020   [(set_attr "type" "move,store,store,load,load")
4021    (set_attr "length" "8,8,16,8,16")])
4023 (define_insn ""
4024   [(set (match_operand:DF 0 "move_dest_operand"
4025                           "=!*r,*r,*r,*r,*r,Q,f,f,T")
4026         (match_operand:DF 1 "move_src_operand"
4027                           "!*r,J,N,K,RQ,*rG,fG,RT,f"))]
4028   "(register_operand (operands[0], DFmode)
4029     || reg_or_0_operand (operands[1], DFmode))
4030    && !TARGET_SOFT_FLOAT && TARGET_64BIT"
4031   "@
4032    copy %1,%0
4033    ldi %1,%0
4034    ldil L'%1,%0
4035    depdi,z %z1,%0
4036    ldd%M1 %1,%0
4037    std%M0 %r1,%0
4038    fcpy,dbl %f1,%0
4039    fldd%F1 %1,%0
4040    fstd%F0 %1,%0"
4041   [(set_attr "type" "move,move,move,shift,load,store,fpalu,fpload,fpstore")
4042    (set_attr "pa_combine_type" "addmove")
4043    (set_attr "length" "4,4,4,4,4,4,4,4,4")])
4046 (define_expand "movdi"
4047   [(set (match_operand:DI 0 "general_operand" "")
4048         (match_operand:DI 1 "general_operand" ""))]
4049   ""
4050   "
4052   if (pa_emit_move_sequence (operands, DImode, 0))
4053     DONE;
4056 ;; Handle DImode input reloads requiring %r1 as a scratch register.
4057 (define_expand "reload_indi_r1"
4058   [(set (match_operand:DI 0 "register_operand" "=Z")
4059         (match_operand:DI 1 "non_hard_reg_operand" ""))
4060    (clobber (match_operand:SI 2 "register_operand" "=&a"))]
4061   ""
4062   "
4064   if (pa_emit_move_sequence (operands, DImode, operands[2]))
4065     DONE;
4067   /* We don't want the clobber emitted, so handle this ourselves.  */
4068   emit_insn (gen_rtx_SET (operands[0], operands[1]));
4069   DONE;
4072 ;; Handle DImode input reloads requiring a general register as a
4073 ;; scratch register.
4074 (define_expand "reload_indi"
4075   [(set (match_operand:DI 0 "register_operand" "=Z")
4076         (match_operand:DI 1 "non_hard_reg_operand" ""))
4077    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
4078   ""
4079   "
4081   if (pa_emit_move_sequence (operands, DImode, operands[2]))
4082     DONE;
4084   /* We don't want the clobber emitted, so handle this ourselves.  */
4085   emit_insn (gen_rtx_SET (operands[0], operands[1]));
4086   DONE;
4089 ;; Handle DImode output reloads requiring a general register as a
4090 ;; scratch register.
4091 (define_expand "reload_outdi"
4092   [(set (match_operand:DI 0 "non_hard_reg_operand" "")
4093         (match_operand:DI 1 "register_operand" "Z"))
4094    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
4095   ""
4096   "
4098   if (pa_emit_move_sequence (operands, DImode, operands[2]))
4099     DONE;
4101   /* We don't want the clobber emitted, so handle this ourselves.  */
4102   emit_insn (gen_rtx_SET (operands[0], operands[1]));
4103   DONE;
4106 (define_insn ""
4107   [(set (match_operand:DI 0 "register_operand" "=r")
4108         (high:DI (match_operand 1 "" "")))]
4109   "!TARGET_64BIT"
4110   "*
4112   rtx op0 = operands[0];
4113   rtx op1 = operands[1];
4115   switch (GET_CODE (op1))
4116     {
4117     case CONST_INT:
4118 #if HOST_BITS_PER_WIDE_INT <= 32
4119       operands[0] = operand_subword (op0, 1, 0, DImode);
4120       output_asm_insn (\"ldil L'%1,%0\", operands);
4122       operands[0] = operand_subword (op0, 0, 0, DImode);
4123       if (INTVAL (op1) < 0)
4124         output_asm_insn (\"ldi -1,%0\", operands);
4125       else
4126         output_asm_insn (\"ldi 0,%0\", operands);
4127 #else
4128       operands[0] = operand_subword (op0, 1, 0, DImode);
4129       operands[1] = GEN_INT (INTVAL (op1) & 0xffffffff);
4130       output_asm_insn (\"ldil L'%1,%0\", operands);
4132       operands[0] = operand_subword (op0, 0, 0, DImode);
4133       operands[1] = GEN_INT (INTVAL (op1) >> 32);
4134       output_asm_insn (pa_singlemove_string (operands), operands);
4135 #endif
4136       break;
4138     case CONST_DOUBLE:
4139       operands[0] = operand_subword (op0, 1, 0, DImode);
4140       operands[1] = GEN_INT (CONST_DOUBLE_LOW (op1));
4141       output_asm_insn (\"ldil L'%1,%0\", operands);
4143       operands[0] = operand_subword (op0, 0, 0, DImode);
4144       operands[1] = GEN_INT (CONST_DOUBLE_HIGH (op1));
4145       output_asm_insn (pa_singlemove_string (operands), operands);
4146       break;
4148     default:
4149       gcc_unreachable ();
4150     }
4151   return \"\";
4153   [(set_attr "type" "move")
4154    (set_attr "length" "12")])
4156 (define_insn ""
4157   [(set (match_operand:DI 0 "move_dest_operand"
4158                           "=r,o,Q,r,r,r,*f,*f,T,?r,?*f")
4159         (match_operand:DI 1 "move_src_operand"
4160                           "rM,r,r,o*R,Q,i,*fM,RT,*f,*f,r"))]
4161   "(register_operand (operands[0], DImode)
4162     || reg_or_0_operand (operands[1], DImode))
4163    && !TARGET_64BIT
4164    && !TARGET_SOFT_FLOAT"
4165   "*
4167   if ((FP_REG_P (operands[0]) || FP_REG_P (operands[1])
4168        || operands[1] == CONST0_RTX (DFmode))
4169       && !(REG_P (operands[0]) && REG_P (operands[1])
4170            && FP_REG_P (operands[0]) ^ FP_REG_P (operands[1])))
4171     return pa_output_fp_move_double (operands);
4172   return pa_output_move_double (operands);
4174   [(set_attr "type"
4175     "move,store,store,load,load,multi,fpalu,fpload,fpstore,fpstore_load,store_fpload")
4176    (set_attr "length" "8,8,16,8,16,16,4,4,4,12,12")])
4178 (define_insn ""
4179   [(set (match_operand:DI 0 "move_dest_operand"
4180                           "=r,r,r,r,r,r,Q,!*q,!r,!*f,*f,T")
4181         (match_operand:DI 1 "move_src_operand"
4182                           "A,r,J,N,K,RQ,rM,!rM,!*q,!*fM,RT,*f"))]
4183   "(register_operand (operands[0], DImode)
4184     || reg_or_0_operand (operands[1], DImode))
4185    && !TARGET_SOFT_FLOAT && TARGET_64BIT"
4186   "@
4187    ldd RT'%A1,%0
4188    copy %1,%0
4189    ldi %1,%0
4190    ldil L'%1,%0
4191    depdi,z %z1,%0
4192    ldd%M1 %1,%0
4193    std%M0 %r1,%0
4194    mtsar %r1
4195    {mfctl|mfctl,w} %%sar,%0
4196    fcpy,dbl %f1,%0
4197    fldd%F1 %1,%0
4198    fstd%F0 %1,%0"
4199   [(set_attr "type" "load,move,move,move,shift,load,store,move,move,fpalu,fpload,fpstore")
4200    (set_attr "pa_combine_type" "addmove")
4201    (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4")])
4203 (define_insn ""
4204   [(set (match_operand:DI 0 "indexed_memory_operand" "=R")
4205         (match_operand:DI 1 "register_operand" "f"))]
4206   "!TARGET_SOFT_FLOAT
4207    && TARGET_64BIT
4208    && !TARGET_DISABLE_INDEXING
4209    && reload_completed"
4210   "fstd%F0 %1,%0"
4211   [(set_attr "type" "fpstore")
4212    (set_attr "pa_combine_type" "addmove")
4213    (set_attr "length" "4")])
4215 (define_peephole2
4216   [(set (match_operand:DI 0 "register_operand" "")
4217         (plus:DI (ashift:DI (match_operand:DI 1 "register_operand" "")
4218                             (const_int 3))
4219                  (match_operand:DI 2 "register_operand" "")))
4220    (set (mem:DI (match_dup 0))
4221         (match_operand:DI 3 "register_operand" ""))]
4222   "!TARGET_SOFT_FLOAT
4223    && !TARGET_DISABLE_INDEXING
4224    && TARGET_64BIT
4225    && REG_OK_FOR_BASE_P (operands[2])
4226    && FP_REGNO_P (REGNO (operands[3]))"
4227   [(set (mem:DI (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
4228         (match_dup 3))
4229    (set (match_dup 0) (plus:DI (ashift:DI (match_dup 1) (const_int 3))
4230                                (match_dup 2)))]
4231   "")
4233 (define_peephole2
4234   [(set (match_operand:DI 0 "register_operand" "")
4235         (plus:DI (match_operand:DI 1 "register_operand" "")
4236                  (match_operand:DI 2 "register_operand" "")))
4237    (set (mem:DI (match_dup 0))
4238         (match_operand:DI 3 "register_operand" ""))]
4239   "!TARGET_SOFT_FLOAT
4240    && !TARGET_DISABLE_INDEXING
4241    && TARGET_64BIT
4242    && TARGET_NO_SPACE_REGS
4243    && REG_OK_FOR_INDEX_P (operands[1])
4244    && REG_OK_FOR_BASE_P (operands[2])
4245    && FP_REGNO_P (REGNO (operands[3]))"
4246   [(set (mem:DI (plus:DI (match_dup 1) (match_dup 2)))
4247         (match_dup 3))
4248    (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
4249   "")
4251 (define_peephole2
4252   [(set (match_operand:DI 0 "register_operand" "")
4253         (plus:DI (match_operand:DI 1 "register_operand" "")
4254                  (match_operand:DI 2 "register_operand" "")))
4255    (set (mem:DI (match_dup 0))
4256         (match_operand:DI 3 "register_operand" ""))]
4257   "!TARGET_SOFT_FLOAT
4258    && !TARGET_DISABLE_INDEXING
4259    && TARGET_64BIT
4260    && TARGET_NO_SPACE_REGS
4261    && REG_OK_FOR_BASE_P (operands[1])
4262    && REG_OK_FOR_INDEX_P (operands[2])
4263    && FP_REGNO_P (REGNO (operands[3]))"
4264   [(set (mem:DI (plus:DI (match_dup 2) (match_dup 1)))
4265         (match_dup 3))
4266    (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
4267   "")
4269 (define_insn ""
4270   [(set (match_operand:DI 0 "move_dest_operand"
4271                           "=r,o,Q,r,r,r")
4272         (match_operand:DI 1 "general_operand"
4273                           "rM,r,r,o,Q,i"))]
4274   "(register_operand (operands[0], DImode)
4275     || reg_or_0_operand (operands[1], DImode))
4276    && !TARGET_64BIT
4277    && TARGET_SOFT_FLOAT"
4278   "*
4280   return pa_output_move_double (operands);
4282   [(set_attr "type" "move,store,store,load,load,multi")
4283    (set_attr "length" "8,8,16,8,16,16")])
4285 (define_insn ""
4286   [(set (match_operand:DI 0 "register_operand" "=r,&r")
4287         (lo_sum:DI (match_operand:DI 1 "register_operand" "0,r")
4288                    (match_operand:DI 2 "immediate_operand" "i,i")))]
4289   "!TARGET_64BIT"
4290   "*
4292   /* Don't output a 64-bit constant, since we can't trust the assembler to
4293      handle it correctly.  */
4294   if (GET_CODE (operands[2]) == CONST_DOUBLE)
4295     operands[2] = GEN_INT (CONST_DOUBLE_LOW (operands[2]));
4296   else if (HOST_BITS_PER_WIDE_INT > 32
4297            && GET_CODE (operands[2]) == CONST_INT)
4298     operands[2] = GEN_INT (INTVAL (operands[2]) & 0xffffffff);
4299   if (which_alternative == 1)
4300     output_asm_insn (\"copy %1,%0\", operands);
4301   return \"ldo R'%G2(%R1),%R0\";
4303   [(set_attr "type" "move,move")
4304    (set_attr "length" "4,8")])
4306 (define_expand "movsf"
4307   [(set (match_operand:SF 0 "general_operand" "")
4308         (match_operand:SF 1 "general_operand" ""))]
4309   ""
4310   "
4312   if (pa_emit_move_sequence (operands, SFmode, 0))
4313     DONE;
4316 ;; Handle SFmode input reloads requiring %r1 as a scratch register.
4317 (define_expand "reload_insf_r1"
4318   [(set (match_operand:SF 0 "register_operand" "=Z")
4319         (match_operand:SF 1 "non_hard_reg_operand" ""))
4320    (clobber (match_operand:SI 2 "register_operand" "=&a"))]
4321   ""
4322   "
4324   if (pa_emit_move_sequence (operands, SFmode, operands[2]))
4325     DONE;
4327   /* We don't want the clobber emitted, so handle this ourselves.  */
4328   emit_insn (gen_rtx_SET (operands[0], operands[1]));
4329   DONE;
4332 ;; Handle SFmode input reloads requiring a general register as a
4333 ;; scratch register.
4334 (define_expand "reload_insf"
4335   [(set (match_operand:SF 0 "register_operand" "=Z")
4336         (match_operand:SF 1 "non_hard_reg_operand" ""))
4337    (clobber (match_operand:SF 2 "register_operand" "=&r"))]
4338   ""
4339   "
4341   if (pa_emit_move_sequence (operands, SFmode, operands[2]))
4342     DONE;
4344   /* We don't want the clobber emitted, so handle this ourselves.  */
4345   emit_insn (gen_rtx_SET (operands[0], operands[1]));
4346   DONE;
4349 ;; Handle SFmode output reloads requiring a general register as a
4350 ;; scratch register.
4351 (define_expand "reload_outsf"
4352   [(set (match_operand:SF 0 "non_hard_reg_operand" "")
4353         (match_operand:SF 1  "register_operand" "Z"))
4354    (clobber (match_operand:SF 2 "register_operand" "=&r"))]
4355   ""
4356   "
4358   if (pa_emit_move_sequence (operands, SFmode, operands[2]))
4359     DONE;
4361   /* We don't want the clobber emitted, so handle this ourselves.  */
4362   emit_insn (gen_rtx_SET (operands[0], operands[1]));
4363   DONE;
4366 (define_insn ""
4367   [(set (match_operand:SF 0 "move_dest_operand"
4368                           "=f,!*r,f,*r,T,Q,?*r,?f")
4369         (match_operand:SF 1 "reg_or_0_or_nonsymb_mem_operand"
4370                           "fG,!*rG,RT,RQ,f,*rG,f,*r"))]
4371   "(register_operand (operands[0], SFmode)
4372     || reg_or_0_operand (operands[1], SFmode))
4373    && !TARGET_SOFT_FLOAT
4374    && !TARGET_64BIT"
4375   "@
4376    fcpy,sgl %f1,%0
4377    copy %r1,%0
4378    fldw%F1 %1,%0
4379    ldw%M1 %1,%0
4380    fstw%F0 %1,%0
4381    stw%M0 %r1,%0
4382    {fstws|fstw} %1,-16(%%sp)\n\t{ldws|ldw} -16(%%sp),%0
4383    {stws|stw} %1,-16(%%sp)\n\t{fldws|fldw} -16(%%sp),%0"
4384   [(set_attr "type" "fpalu,move,fpload,load,fpstore,store,fpstore_load,store_fpload")
4385    (set_attr "pa_combine_type" "addmove")
4386    (set_attr "length" "4,4,4,4,4,4,8,8")])
4388 (define_insn ""
4389   [(set (match_operand:SF 0 "move_dest_operand"
4390                           "=f,!*r,f,*r,T,Q")
4391         (match_operand:SF 1 "reg_or_0_or_nonsymb_mem_operand"
4392                           "fG,!*rG,RT,RQ,f,*rG"))]
4393   "(register_operand (operands[0], SFmode)
4394     || reg_or_0_operand (operands[1], SFmode))
4395    && !TARGET_SOFT_FLOAT
4396    && TARGET_64BIT"
4397   "@
4398    fcpy,sgl %f1,%0
4399    copy %r1,%0
4400    fldw%F1 %1,%0
4401    ldw%M1 %1,%0
4402    fstw%F0 %1,%0
4403    stw%M0 %r1,%0"
4404   [(set_attr "type" "fpalu,move,fpload,load,fpstore,store")
4405    (set_attr "pa_combine_type" "addmove")
4406    (set_attr "length" "4,4,4,4,4,4")])
4408 (define_insn ""
4409   [(set (match_operand:SF 0 "indexed_memory_operand" "=R")
4410         (match_operand:SF 1 "register_operand" "f"))]
4411   "!TARGET_SOFT_FLOAT
4412    && !TARGET_DISABLE_INDEXING
4413    && reload_completed"
4414   "fstw%F0 %1,%0"
4415   [(set_attr "type" "fpstore")
4416    (set_attr "pa_combine_type" "addmove")
4417    (set_attr "length" "4")])
4419 (define_peephole2
4420   [(set (match_operand:SI 0 "register_operand" "")
4421         (plus:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
4422                             (const_int 2))
4423                  (match_operand:SI 2 "register_operand" "")))
4424    (set (mem:SF (match_dup 0))
4425         (match_operand:SF 3 "register_operand" ""))]
4426   "!TARGET_SOFT_FLOAT
4427    && !TARGET_DISABLE_INDEXING
4428    && REG_OK_FOR_BASE_P (operands[2])
4429    && FP_REGNO_P (REGNO (operands[3]))"
4430   [(set (mem:SF (plus:SI (mult:SI (match_dup 1) (const_int 4)) (match_dup 2)))
4431         (match_dup 3))
4432    (set (match_dup 0) (plus:SI (ashift:SI (match_dup 1) (const_int 2))
4433                                (match_dup 2)))]
4434   "")
4436 (define_peephole2
4437   [(set (match_operand:DI 0 "register_operand" "")
4438         (plus:DI (ashift:DI (match_operand:DI 1 "register_operand" "")
4439                             (const_int 2))
4440                  (match_operand:DI 2 "register_operand" "")))
4441    (set (mem:SF (match_dup 0))
4442         (match_operand:SF 3 "register_operand" ""))]
4443   "!TARGET_SOFT_FLOAT
4444    && !TARGET_DISABLE_INDEXING
4445    && TARGET_64BIT
4446    && REG_OK_FOR_BASE_P (operands[2])
4447    && FP_REGNO_P (REGNO (operands[3]))"
4448   [(set (mem:SF (plus:DI (mult:DI (match_dup 1) (const_int 4)) (match_dup 2)))
4449         (match_dup 3))
4450    (set (match_dup 0) (plus:DI (ashift:DI (match_dup 1) (const_int 2))
4451                                (match_dup 2)))]
4452   "")
4454 (define_peephole2
4455   [(set (match_operand:SI 0 "register_operand" "")
4456         (plus:SI (match_operand:SI 1 "register_operand" "")
4457                  (match_operand:SI 2 "register_operand" "")))
4458    (set (mem:SF (match_dup 0))
4459         (match_operand:SF 3 "register_operand" ""))]
4460   "!TARGET_SOFT_FLOAT
4461    && !TARGET_DISABLE_INDEXING
4462    && TARGET_NO_SPACE_REGS
4463    && REG_OK_FOR_INDEX_P (operands[1])
4464    && REG_OK_FOR_BASE_P (operands[2])
4465    && FP_REGNO_P (REGNO (operands[3]))"
4466   [(set (mem:SF (plus:SI (match_dup 1) (match_dup 2)))
4467         (match_dup 3))
4468    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
4469   "")
4471 (define_peephole2
4472   [(set (match_operand:SI 0 "register_operand" "")
4473         (plus:SI (match_operand:SI 1 "register_operand" "")
4474                  (match_operand:SI 2 "register_operand" "")))
4475    (set (mem:SF (match_dup 0))
4476         (match_operand:SF 3 "register_operand" ""))]
4477   "!TARGET_SOFT_FLOAT
4478    && !TARGET_DISABLE_INDEXING
4479    && TARGET_NO_SPACE_REGS
4480    && REG_OK_FOR_BASE_P (operands[1])
4481    && REG_OK_FOR_INDEX_P (operands[2])
4482    && FP_REGNO_P (REGNO (operands[3]))"
4483   [(set (mem:SF (plus:SI (match_dup 2) (match_dup 1)))
4484         (match_dup 3))
4485    (set (match_dup 0) (plus:SI (match_dup 2) (match_dup 1)))]
4486   "")
4488 (define_peephole2
4489   [(set (match_operand:DI 0 "register_operand" "")
4490         (plus:DI (match_operand:DI 1 "register_operand" "")
4491                  (match_operand:DI 2 "register_operand" "")))
4492    (set (mem:SF (match_dup 0))
4493         (match_operand:SF 3 "register_operand" ""))]
4494   "!TARGET_SOFT_FLOAT
4495    && !TARGET_DISABLE_INDEXING
4496    && TARGET_64BIT
4497    && TARGET_NO_SPACE_REGS
4498    && REG_OK_FOR_INDEX_P (operands[1])
4499    && REG_OK_FOR_BASE_P (operands[2])
4500    && FP_REGNO_P (REGNO (operands[3]))"
4501   [(set (mem:SF (plus:DI (match_dup 1) (match_dup 2)))
4502         (match_dup 3))
4503    (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
4504   "")
4506 (define_peephole2
4507   [(set (match_operand:DI 0 "register_operand" "")
4508         (plus:DI (match_operand:DI 1 "register_operand" "")
4509                  (match_operand:DI 2 "register_operand" "")))
4510    (set (mem:SF (match_dup 0))
4511         (match_operand:SF 3 "register_operand" ""))]
4512   "!TARGET_SOFT_FLOAT
4513    && !TARGET_DISABLE_INDEXING
4514    && TARGET_64BIT
4515    && TARGET_NO_SPACE_REGS
4516    && REG_OK_FOR_BASE_P (operands[1])
4517    && REG_OK_FOR_INDEX_P (operands[2])
4518    && FP_REGNO_P (REGNO (operands[3]))"
4519   [(set (mem:SF (plus:DI (match_dup 2) (match_dup 1)))
4520         (match_dup 3))
4521    (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
4522   "")
4524 (define_insn ""
4525   [(set (match_operand:SF 0 "move_dest_operand"
4526                           "=r,r,Q")
4527         (match_operand:SF 1 "reg_or_0_or_nonsymb_mem_operand"
4528                           "rG,RQ,rG"))]
4529   "(register_operand (operands[0], SFmode)
4530     || reg_or_0_operand (operands[1], SFmode))
4531    && TARGET_SOFT_FLOAT"
4532   "@
4533    copy %r1,%0
4534    ldw%M1 %1,%0
4535    stw%M0 %r1,%0"
4536   [(set_attr "type" "move,load,store")
4537    (set_attr "pa_combine_type" "addmove")
4538    (set_attr "length" "4,4,4")])
4542 ;;- zero extension instructions
4543 ;; We have define_expand for zero extension patterns to make sure the
4544 ;; operands get loaded into registers.  The define_insns accept
4545 ;; memory operands.  This gives us better overall code than just
4546 ;; having a pattern that does or does not accept memory operands.
4548 (define_expand "zero_extendqihi2"
4549   [(set (match_operand:HI 0 "register_operand" "")
4550         (zero_extend:HI
4551          (match_operand:QI 1 "register_operand" "")))]
4552   ""
4553   "")
4555 (define_insn ""
4556   [(set (match_operand:HI 0 "register_operand" "=r,r")
4557         (zero_extend:HI
4558          (match_operand:QI 1 "move_src_operand" "r,RQ")))]
4559   "GET_CODE (operands[1]) != CONST_INT"
4560   "@
4561    {extru|extrw,u} %1,31,8,%0
4562    ldb%M1 %1,%0"
4563   [(set_attr "type" "shift,load")
4564    (set_attr "length" "4,4")])
4566 (define_expand "zero_extendqisi2"
4567   [(set (match_operand:SI 0 "register_operand" "")
4568         (zero_extend:SI
4569          (match_operand:QI 1 "register_operand" "")))]
4570   ""
4571   "")
4573 (define_insn ""
4574   [(set (match_operand:SI 0 "register_operand" "=r,r")
4575         (zero_extend:SI
4576          (match_operand:QI 1 "move_src_operand" "r,RQ")))]
4577   "GET_CODE (operands[1]) != CONST_INT"
4578   "@
4579    {extru|extrw,u} %1,31,8,%0
4580    ldb%M1 %1,%0"
4581   [(set_attr "type" "shift,load")
4582    (set_attr "length" "4,4")])
4584 (define_expand "zero_extendhisi2"
4585   [(set (match_operand:SI 0 "register_operand" "")
4586         (zero_extend:SI
4587          (match_operand:HI 1 "register_operand" "")))]
4588   ""
4589   "")
4591 (define_insn ""
4592   [(set (match_operand:SI 0 "register_operand" "=r,r")
4593         (zero_extend:SI
4594          (match_operand:HI 1 "move_src_operand" "r,RQ")))]
4595   "GET_CODE (operands[1]) != CONST_INT"
4596   "@
4597    {extru|extrw,u} %1,31,16,%0
4598    ldh%M1 %1,%0"
4599   [(set_attr "type" "shift,load")
4600    (set_attr "length" "4,4")])
4602 (define_expand "zero_extendqidi2"
4603   [(set (match_operand:DI 0 "register_operand" "")
4604         (zero_extend:DI
4605          (match_operand:QI 1 "register_operand" "")))]
4606   "TARGET_64BIT"
4607   "")
4609 (define_insn ""
4610   [(set (match_operand:DI 0 "register_operand" "=r,r")
4611         (zero_extend:DI
4612          (match_operand:QI 1 "move_src_operand" "r,RQ")))]
4613   "TARGET_64BIT && GET_CODE (operands[1]) != CONST_INT"
4614   "@
4615    extrd,u %1,63,8,%0
4616    ldb%M1 %1,%0"
4617   [(set_attr "type" "shift,load")
4618    (set_attr "length" "4,4")])
4620 (define_expand "zero_extendhidi2"
4621   [(set (match_operand:DI 0 "register_operand" "")
4622         (zero_extend:DI
4623          (match_operand:HI 1 "register_operand" "")))]
4624   "TARGET_64BIT"
4625   "")
4627 (define_insn ""
4628   [(set (match_operand:DI 0 "register_operand" "=r,r")
4629         (zero_extend:DI
4630          (match_operand:HI 1 "move_src_operand" "r,RQ")))]
4631   "TARGET_64BIT && GET_CODE (operands[1]) != CONST_INT"
4632   "@
4633    extrd,u %1,63,16,%0
4634    ldh%M1 %1,%0"
4635   [(set_attr "type" "shift,load")
4636    (set_attr "length" "4,4")])
4638 (define_expand "zero_extendsidi2"
4639   [(set (match_operand:DI 0 "register_operand" "")
4640         (zero_extend:DI
4641          (match_operand:SI 1 "register_operand" "")))]
4642   "TARGET_64BIT"
4643   "")
4645 (define_insn ""
4646   [(set (match_operand:DI 0 "register_operand" "=r,r")
4647         (zero_extend:DI
4648          (match_operand:SI 1 "move_src_operand" "r,RQ")))]
4649   "TARGET_64BIT && GET_CODE (operands[1]) != CONST_INT"
4650   "@
4651    extrd,u %1,63,32,%0
4652    ldw%M1 %1,%0"
4653   [(set_attr "type" "shift,load")
4654    (set_attr "length" "4,4")])
4656 ;;- sign extension instructions
4658 (define_insn "extendhisi2"
4659   [(set (match_operand:SI 0 "register_operand" "=r")
4660         (sign_extend:SI (match_operand:HI 1 "register_operand" "r")))]
4661   ""
4662   "{extrs|extrw,s} %1,31,16,%0"
4663   [(set_attr "type" "shift")
4664    (set_attr "length" "4")])
4666 (define_insn "extendqihi2"
4667   [(set (match_operand:HI 0 "register_operand" "=r")
4668         (sign_extend:HI (match_operand:QI 1 "register_operand" "r")))]
4669   ""
4670   "{extrs|extrw,s} %1,31,8,%0"
4671   [(set_attr "type" "shift") 
4672   (set_attr "length" "4")])
4674 (define_insn "extendqisi2"
4675   [(set (match_operand:SI 0 "register_operand" "=r")
4676         (sign_extend:SI (match_operand:QI 1 "register_operand" "r")))]
4677   ""
4678   "{extrs|extrw,s} %1,31,8,%0"
4679   [(set_attr "type" "shift")
4680    (set_attr "length" "4")])
4682 (define_insn "extendqidi2"
4683   [(set (match_operand:DI 0 "register_operand" "=r")
4684         (sign_extend:DI (match_operand:QI 1 "register_operand" "r")))]
4685   "TARGET_64BIT"
4686   "extrd,s %1,63,8,%0"
4687   [(set_attr "type" "shift") 
4688   (set_attr "length" "4")])
4690 (define_insn "extendhidi2"
4691   [(set (match_operand:DI 0 "register_operand" "=r")
4692         (sign_extend:DI (match_operand:HI 1 "register_operand" "r")))]
4693   "TARGET_64BIT"
4694   "extrd,s %1,63,16,%0"
4695   [(set_attr "type" "shift") 
4696   (set_attr "length" "4")])
4698 (define_insn "extendsidi2"
4699   [(set (match_operand:DI 0 "register_operand" "=r")
4700         (sign_extend:DI (match_operand:SI 1 "register_operand" "r")))]
4701   "TARGET_64BIT"
4702   "extrd,s %1,63,32,%0"
4703   [(set_attr "type" "shift") 
4704   (set_attr "length" "4")])
4707 ;; Conversions between float and double.
4709 (define_insn "extendsfdf2"
4710   [(set (match_operand:DF 0 "register_operand" "=f")
4711         (float_extend:DF
4712          (match_operand:SF 1 "register_operand" "f")))]
4713   "! TARGET_SOFT_FLOAT"
4714   "{fcnvff|fcnv},sgl,dbl %1,%0"
4715   [(set_attr "type" "fpalu")
4716    (set_attr "length" "4")])
4718 (define_insn "truncdfsf2"
4719   [(set (match_operand:SF 0 "register_operand" "=f")
4720         (float_truncate:SF
4721          (match_operand:DF 1 "register_operand" "f")))]
4722   "! TARGET_SOFT_FLOAT"
4723   "{fcnvff|fcnv},dbl,sgl %1,%0"
4724   [(set_attr "type" "fpalu")
4725    (set_attr "length" "4")])
4727 ;; Conversion between fixed point and floating point.
4728 ;; Note that among the fix-to-float insns
4729 ;; the ones that start with SImode come first.
4730 ;; That is so that an operand that is a CONST_INT
4731 ;; (and therefore lacks a specific machine mode).
4732 ;; will be recognized as SImode (which is always valid)
4733 ;; rather than as QImode or HImode.
4735 ;; This pattern forces (set (reg:SF ...) (float:SF (const_int ...)))
4736 ;; to be reloaded by putting the constant into memory.
4737 ;; It must come before the more general floatsisf2 pattern.
4738 (define_insn ""
4739   [(set (match_operand:SF 0 "register_operand" "=f")
4740         (float:SF (match_operand:SI 1 "const_int_operand" "m")))]
4741   "! TARGET_SOFT_FLOAT"
4742   "fldw%F1 %1,%0\;{fcnvxf,sgl,sgl|fcnv,w,sgl} %0,%0"
4743   [(set_attr "type" "fpalu")
4744    (set_attr "length" "8")])
4746 (define_insn "floatsisf2"
4747   [(set (match_operand:SF 0 "register_operand" "=f")
4748         (float:SF (match_operand:SI 1 "register_operand" "f")))]
4749   "! TARGET_SOFT_FLOAT"
4750   "{fcnvxf,sgl,sgl|fcnv,w,sgl} %1,%0"
4751   [(set_attr "type" "fpalu")
4752    (set_attr "length" "4")])
4754 ;; This pattern forces (set (reg:DF ...) (float:DF (const_int ...)))
4755 ;; to be reloaded by putting the constant into memory.
4756 ;; It must come before the more general floatsidf2 pattern.
4757 (define_insn ""
4758   [(set (match_operand:DF 0 "register_operand" "=f")
4759         (float:DF (match_operand:SI 1 "const_int_operand" "m")))]
4760   "! TARGET_SOFT_FLOAT"
4761   "fldw%F1 %1,%0\;{fcnvxf,sgl,dbl|fcnv,w,dbl} %0,%0"
4762   [(set_attr "type" "fpalu")
4763    (set_attr "length" "8")])
4765 (define_insn "floatsidf2"
4766   [(set (match_operand:DF 0 "register_operand" "=f")
4767         (float:DF (match_operand:SI 1 "register_operand" "f")))]
4768   "! TARGET_SOFT_FLOAT"
4769   "{fcnvxf,sgl,dbl|fcnv,w,dbl} %1,%0"
4770   [(set_attr "type" "fpalu")
4771    (set_attr "length" "4")])
4773 (define_expand "floatunssisf2"
4774   [(set (subreg:SI (match_dup 2) 4)
4775         (match_operand:SI 1 "register_operand" ""))
4776    (set (subreg:SI (match_dup 2) 0)
4777         (const_int 0))
4778    (set (match_operand:SF 0 "register_operand" "")
4779         (float:SF (match_dup 2)))]
4780   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4781   "
4783   if (TARGET_PA_20)
4784     {
4785       emit_insn (gen_floatunssisf2_pa20 (operands[0], operands[1]));
4786       DONE;
4787     }
4788   operands[2] = gen_reg_rtx (DImode);
4791 (define_expand "floatunssidf2"
4792   [(set (subreg:SI (match_dup 2) 4)
4793         (match_operand:SI 1 "register_operand" ""))
4794    (set (subreg:SI (match_dup 2) 0)
4795         (const_int 0))
4796    (set (match_operand:DF 0 "register_operand" "")
4797         (float:DF (match_dup 2)))]
4798   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4799   "
4801   if (TARGET_PA_20)
4802     {
4803       emit_insn (gen_floatunssidf2_pa20 (operands[0], operands[1]));
4804       DONE;
4805     }
4806   operands[2] = gen_reg_rtx (DImode);
4809 (define_insn "floatdisf2"
4810   [(set (match_operand:SF 0 "register_operand" "=f")
4811         (float:SF (match_operand:DI 1 "register_operand" "f")))]
4812   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4813   "{fcnvxf,dbl,sgl|fcnv,dw,sgl} %1,%0"
4814   [(set_attr "type" "fpalu")
4815    (set_attr "length" "4")])
4817 (define_insn "floatdidf2"
4818   [(set (match_operand:DF 0 "register_operand" "=f")
4819         (float:DF (match_operand:DI 1 "register_operand" "f")))]
4820   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4821   "{fcnvxf,dbl,dbl|fcnv,dw,dbl} %1,%0"
4822   [(set_attr "type" "fpalu")
4823    (set_attr "length" "4")])
4825 ;; Convert a float to an actual integer.
4826 ;; Truncation is performed as part of the conversion.
4828 (define_insn "fix_truncsfsi2"
4829   [(set (match_operand:SI 0 "register_operand" "=f")
4830         (fix:SI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
4831   "! TARGET_SOFT_FLOAT"
4832   "{fcnvfxt,sgl,sgl|fcnv,t,sgl,w} %1,%0"
4833   [(set_attr "type" "fpalu")
4834    (set_attr "length" "4")])
4836 (define_insn "fix_truncdfsi2"
4837   [(set (match_operand:SI 0 "register_operand" "=f")
4838         (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
4839   "! TARGET_SOFT_FLOAT"
4840   "{fcnvfxt,dbl,sgl|fcnv,t,dbl,w} %1,%0"
4841   [(set_attr "type" "fpalu")
4842    (set_attr "length" "4")])
4844 (define_insn "fix_truncsfdi2"
4845   [(set (match_operand:DI 0 "register_operand" "=f")
4846         (fix:DI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
4847   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4848   "{fcnvfxt,sgl,dbl|fcnv,t,sgl,dw} %1,%0"
4849   [(set_attr "type" "fpalu")
4850    (set_attr "length" "4")])
4852 (define_insn "fix_truncdfdi2"
4853   [(set (match_operand:DI 0 "register_operand" "=f")
4854         (fix:DI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
4855   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4856   "{fcnvfxt,dbl,dbl|fcnv,t,dbl,dw} %1,%0"
4857   [(set_attr "type" "fpalu")
4858    (set_attr "length" "4")])
4860 (define_insn "floatunssidf2_pa20"
4861   [(set (match_operand:DF 0 "register_operand" "=f")
4862         (unsigned_float:DF (match_operand:SI 1 "register_operand" "f")))]
4863   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4864   "fcnv,uw,dbl %1,%0"
4865   [(set_attr "type" "fpalu")
4866    (set_attr "length" "4")])
4868 (define_insn "floatunssisf2_pa20"
4869   [(set (match_operand:SF 0 "register_operand" "=f")
4870         (unsigned_float:SF (match_operand:SI 1 "register_operand" "f")))]
4871   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4872   "fcnv,uw,sgl %1,%0"
4873   [(set_attr "type" "fpalu")
4874    (set_attr "length" "4")])
4876 (define_insn "floatunsdisf2"
4877   [(set (match_operand:SF 0 "register_operand" "=f")
4878         (unsigned_float:SF (match_operand:DI 1 "register_operand" "f")))]
4879   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4880   "fcnv,udw,sgl %1,%0"
4881   [(set_attr "type" "fpalu")
4882    (set_attr "length" "4")])
4884 (define_insn "floatunsdidf2"
4885   [(set (match_operand:DF 0 "register_operand" "=f")
4886         (unsigned_float:DF (match_operand:DI 1 "register_operand" "f")))]
4887   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4888   "fcnv,udw,dbl %1,%0"
4889   [(set_attr "type" "fpalu")
4890    (set_attr "length" "4")])
4892 (define_insn "fixuns_truncsfsi2"
4893   [(set (match_operand:SI 0 "register_operand" "=f")
4894         (unsigned_fix:SI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
4895   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4896   "fcnv,t,sgl,uw %1,%0"
4897   [(set_attr "type" "fpalu")
4898    (set_attr "length" "4")])
4900 (define_insn "fixuns_truncdfsi2"
4901   [(set (match_operand:SI 0 "register_operand" "=f")
4902         (unsigned_fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
4903   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4904   "fcnv,t,dbl,uw %1,%0"
4905   [(set_attr "type" "fpalu")
4906    (set_attr "length" "4")])
4908 (define_insn "fixuns_truncsfdi2"
4909   [(set (match_operand:DI 0 "register_operand" "=f")
4910         (unsigned_fix:DI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
4911   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4912   "fcnv,t,sgl,udw %1,%0"
4913   [(set_attr "type" "fpalu")
4914    (set_attr "length" "4")])
4916 (define_insn "fixuns_truncdfdi2"
4917   [(set (match_operand:DI 0 "register_operand" "=f")
4918         (unsigned_fix:DI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
4919   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4920   "fcnv,t,dbl,udw %1,%0"
4921   [(set_attr "type" "fpalu")
4922    (set_attr "length" "4")])
4924 ;;- arithmetic instructions
4926 (define_expand "adddi3"
4927   [(set (match_operand:DI 0 "register_operand" "")
4928         (plus:DI (match_operand:DI 1 "register_operand" "")
4929                  (match_operand:DI 2 "adddi3_operand" "")))]
4930   ""
4931   "")
4933 (define_insn ""
4934   [(set (match_operand:DI 0 "register_operand" "=r")
4935         (plus:DI (match_operand:DI 1 "register_operand" "%r")
4936                  (match_operand:DI 2 "arith11_operand" "rI")))]
4937   "!TARGET_64BIT"
4938   "*
4940   if (GET_CODE (operands[2]) == CONST_INT)
4941     {
4942       if (INTVAL (operands[2]) >= 0)
4943         return \"addi %2,%R1,%R0\;{addc|add,c} %1,%%r0,%0\";
4944       else
4945         return \"addi %2,%R1,%R0\;{subb|sub,b} %1,%%r0,%0\";
4946     }
4947   else
4948     return \"add %R2,%R1,%R0\;{addc|add,c} %2,%1,%0\";
4950   [(set_attr "type" "binary")
4951    (set_attr "length" "8")])
4953 (define_insn ""
4954   [(set (match_operand:DI 0 "register_operand" "=r,r")
4955         (plus:DI (match_operand:DI 1 "register_operand" "%r,r")
4956                  (match_operand:DI 2 "arith14_operand" "r,J")))]
4957   "TARGET_64BIT"
4958   "@
4959    add,l %1,%2,%0
4960    ldo %2(%1),%0"
4961   [(set_attr "type" "binary,binary")
4962    (set_attr "pa_combine_type" "addmove")
4963    (set_attr "length" "4,4")])
4965 (define_insn ""
4966   [(set (match_operand:DI 0 "register_operand" "=r")
4967         (plus:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
4968                  (match_operand:DI 2 "register_operand" "r")))]
4969   "TARGET_64BIT"
4970   "uaddcm %2,%1,%0"
4971   [(set_attr "type" "binary")
4972    (set_attr "length" "4")])
4974 (define_insn ""
4975   [(set (match_operand:SI 0 "register_operand" "=r")
4976         (plus:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
4977                  (match_operand:SI 2 "register_operand" "r")))]
4978   ""
4979   "uaddcm %2,%1,%0"
4980   [(set_attr "type" "binary")
4981    (set_attr "length" "4")])
4983 (define_expand "addvdi3"
4984   [(parallel [(set (match_operand:DI 0 "register_operand" "")
4985                    (plus:DI (match_operand:DI 1 "reg_or_0_operand" "")
4986                             (match_operand:DI 2 "arith11_operand" "")))
4987               (trap_if (ne (plus:TI (sign_extend:TI (match_dup 1))
4988                                     (sign_extend:TI (match_dup 2)))
4989                            (sign_extend:TI (plus:DI (match_dup 1)
4990                                                     (match_dup 2))))
4991                        (const_int 0))])]
4992   ""
4993   "")
4995 (define_insn ""
4996   [(set (match_operand:DI 0 "register_operand" "=r,r")
4997         (plus:DI (match_operand:DI 1 "reg_or_0_operand" "%rM,rM")
4998                  (match_operand:DI 2 "arith11_operand" "r,I")))
4999    (trap_if (ne (plus:TI (sign_extend:TI (match_dup 1))
5000                          (sign_extend:TI (match_dup 2)))
5001                 (sign_extend:TI (plus:DI (match_dup 1)
5002                                          (match_dup 2))))
5003             (const_int 0))]
5004   "TARGET_64BIT"
5005   "@
5006   add,tsv,* %2,%1,%0
5007   addi,tsv,* %2,%1,%0"
5008   [(set_attr "type" "binary,binary")
5009    (set_attr "length" "4,4")])
5011 (define_insn ""
5012   [(set (match_operand:DI 0 "register_operand" "=r")
5013         (plus:DI (match_operand:DI 1 "reg_or_0_operand" "%rM")
5014                  (match_operand:DI 2 "arith11_operand" "rI")))
5015    (trap_if (ne (plus:TI (sign_extend:TI (match_dup 1))
5016                          (sign_extend:TI (match_dup 2)))
5017                 (sign_extend:TI (plus:DI (match_dup 1)
5018                                          (match_dup 2))))
5019             (const_int 0))]
5020   "!TARGET_64BIT"
5021   "*
5023   if (GET_CODE (operands[2]) == CONST_INT)
5024     {
5025       if (INTVAL (operands[2]) >= 0)
5026         return \"addi %2,%R1,%R0\;{addco|add,c,tsv} %1,%%r0,%0\";
5027       else
5028         return \"addi %2,%R1,%R0\;{subbo|sub,b,tsv} %1,%%r0,%0\";
5029     }
5030   else
5031     return \"add %R2,%R1,%R0\;{addco|add,c,tsv} %2,%1,%0\";
5033   [(set_attr "type" "binary")
5034    (set_attr "length" "8")])
5036 ;; define_splits to optimize cases of adding a constant integer
5037 ;; to a register when the constant does not fit in 14 bits.  */
5038 (define_split
5039   [(set (match_operand:SI 0 "register_operand" "")
5040         (plus:SI (match_operand:SI 1 "register_operand" "")
5041                  (match_operand:SI 2 "const_int_operand" "")))
5042    (clobber (match_operand:SI 4 "register_operand" ""))]
5043   "! pa_cint_ok_for_move (UINTVAL (operands[2]))
5044    && VAL_14_BITS_P (INTVAL (operands[2]) >> 1)"
5045   [(set (match_dup 4) (plus:SI (match_dup 1) (match_dup 2)))
5046    (set (match_dup 0) (plus:SI (match_dup 4) (match_dup 3)))]
5047   "
5049   int val = INTVAL (operands[2]);
5050   int low = (val < 0) ? -0x2000 : 0x1fff;
5051   int rest = val - low;
5053   operands[2] = GEN_INT (rest);
5054   operands[3] = GEN_INT (low);
5057 (define_split
5058   [(set (match_operand:SI 0 "register_operand" "")
5059         (plus:SI (match_operand:SI 1 "register_operand" "")
5060                  (match_operand:SI 2 "const_int_operand" "")))
5061    (clobber (match_operand:SI 4 "register_operand" ""))]
5062   "! pa_cint_ok_for_move (UINTVAL (operands[2]))"
5063   [(set (match_dup 4) (match_dup 2))
5064    (set (match_dup 0) (plus:SI (ashift:SI (match_dup 4) (match_dup 3))
5065                                (match_dup 1)))]
5066   "
5068   unsigned HOST_WIDE_INT intval = UINTVAL (operands[2]);
5070   /* Try dividing the constant by 2, then 4, and finally 8 to see
5071      if we can get a constant which can be loaded into a register
5072      in a single instruction (pa_cint_ok_for_move). 
5074      If that fails, try to negate the constant and subtract it
5075      from our input operand.  */
5076   if (intval % 2 == 0 && pa_cint_ok_for_move (intval / 2))
5077     {
5078       operands[2] = GEN_INT (intval / 2);
5079       operands[3] = const1_rtx;
5080     }
5081   else if (intval % 4 == 0 && pa_cint_ok_for_move (intval / 4))
5082     {
5083       operands[2] = GEN_INT (intval / 4);
5084       operands[3] = const2_rtx;
5085     }
5086   else if (intval % 8 == 0 && pa_cint_ok_for_move (intval / 8))
5087     {
5088       operands[2] = GEN_INT (intval / 8);
5089       operands[3] = GEN_INT (3);
5090     }
5091   else if (pa_cint_ok_for_move (-intval))
5092     {
5093       emit_insn (gen_rtx_SET (operands[4], GEN_INT (-intval)));
5094       emit_insn (gen_subsi3 (operands[0], operands[1], operands[4]));
5095       DONE;
5096     }
5097   else
5098     FAIL;
5101 (define_insn "addsi3"
5102   [(set (match_operand:SI 0 "register_operand" "=r,r")
5103         (plus:SI (match_operand:SI 1 "register_operand" "%r,r")
5104                  (match_operand:SI 2 "arith14_operand" "r,J")))]
5105   ""
5106   "@
5107    {addl|add,l} %1,%2,%0
5108    ldo %2(%1),%0"
5109   [(set_attr "type" "binary,binary")
5110    (set_attr "pa_combine_type" "addmove")
5111    (set_attr "length" "4,4")])
5113 (define_insn "addvsi3"
5114   [(set (match_operand:SI 0 "register_operand" "=r,r")
5115         (plus:SI (match_operand:SI 1 "reg_or_0_operand" "%rM,rM")
5116                  (match_operand:SI 2 "arith11_operand" "r,I")))
5117    (trap_if (ne (plus:DI (sign_extend:DI (match_dup 1))
5118                          (sign_extend:DI (match_dup 2)))
5119                 (sign_extend:DI (plus:SI (match_dup 1)
5120                                          (match_dup 2))))
5121             (const_int 0))]
5122   ""
5123   "@
5124   {addo|add,tsv} %2,%1,%0
5125   {addio|addi,tsv} %2,%1,%0"
5126   [(set_attr "type" "binary,binary")
5127    (set_attr "length" "4,4")])
5129 (define_expand "subdi3"
5130   [(set (match_operand:DI 0 "register_operand" "")
5131         (minus:DI (match_operand:DI 1 "arith11_operand" "")
5132                   (match_operand:DI 2 "reg_or_0_operand" "")))]
5133   ""
5134   "")
5136 (define_insn ""
5137   [(set (match_operand:DI 0 "register_operand" "=r,r,!q")
5138         (minus:DI (match_operand:DI 1 "arith11_operand" "r,I,!U")
5139                   (match_operand:DI 2 "reg_or_0_operand" "rM,rM,!rM")))]
5140   "TARGET_64BIT"
5141   "@
5142    sub %1,%2,%0
5143    subi %1,%2,%0
5144    mtsarcm %2"
5145   [(set_attr "type" "binary,binary,move")
5146   (set_attr "length" "4,4,4")])
5148 (define_insn ""
5149   [(set (match_operand:DI 0 "register_operand" "=r,&r")
5150         (minus:DI (match_operand:DI 1 "arith11_operand" "r,I")
5151                   (match_operand:DI 2 "reg_or_0_operand" "rM,rM")))]
5152   "!TARGET_64BIT"
5153   "*
5155   if (GET_CODE (operands[1]) == CONST_INT)
5156     {
5157       if (INTVAL (operands[1]) >= 0)
5158         return \"subi %1,%R2,%R0\;{subb|sub,b} %%r0,%2,%0\";
5159       else
5160         return \"ldi -1,%0\;subi %1,%R2,%R0\;{subb|sub,b} %0,%2,%0\";
5161     }
5162   else
5163     return \"sub %R1,%R2,%R0\;{subb|sub,b} %1,%2,%0\";
5165   [(set_attr "type" "binary")
5166    (set (attr "length")
5167         (if_then_else (eq_attr "alternative" "0")
5168           (const_int 8)
5169           (if_then_else (ge (symbol_ref "INTVAL (operands[1])")
5170                             (const_int 0))
5171             (const_int 8)
5172             (const_int 12))))])
5174 (define_expand "subvdi3"
5175   [(parallel [(set (match_operand:DI 0 "register_operand" "")
5176                    (minus:DI (match_operand:DI 1 "arith11_operand" "")
5177                              (match_operand:DI 2 "reg_or_0_operand" "")))
5178               (trap_if (ne (minus:TI (sign_extend:TI (match_dup 1))
5179                                      (sign_extend:TI (match_dup 2)))
5180                            (sign_extend:TI (minus:DI (match_dup 1)
5181                                                      (match_dup 2))))
5182                        (const_int 0))])]
5183   ""
5184   "")
5186 (define_insn ""
5187   [(set (match_operand:DI 0 "register_operand" "=r,r")
5188         (minus:DI (match_operand:DI 1 "arith11_operand" "r,I")
5189                   (match_operand:DI 2 "reg_or_0_operand" "rM,rM")))
5190    (trap_if (ne (minus:TI (sign_extend:TI (match_dup 1))
5191                           (sign_extend:TI (match_dup 2)))
5192                 (sign_extend:TI (minus:DI (match_dup 1)
5193                                           (match_dup 2))))
5194             (const_int 0))]
5195   "TARGET_64BIT"
5196   "@
5197   {subo|sub,tsv} %1,%2,%0
5198   {subio|subi,tsv} %1,%2,%0"
5199   [(set_attr "type" "binary,binary")
5200    (set_attr "length" "4,4")])
5202 (define_insn ""
5203   [(set (match_operand:DI 0 "register_operand" "=r,&r")
5204         (minus:DI (match_operand:DI 1 "arith11_operand" "r,I")
5205                   (match_operand:DI 2 "reg_or_0_operand" "rM,rM")))
5206    (trap_if (ne (minus:TI (sign_extend:TI (match_dup 1))
5207                           (sign_extend:TI (match_dup 2)))
5208                 (sign_extend:TI (minus:DI (match_dup 1)
5209                                           (match_dup 2))))
5210             (const_int 0))]
5211   "!TARGET_64BIT"
5212   "*
5214   if (GET_CODE (operands[1]) == CONST_INT)
5215     {
5216       if (INTVAL (operands[1]) >= 0)
5217         return \"subi %1,%R2,%R0\;{subbo|sub,b,tsv} %%r0,%2,%0\";
5218       else
5219         return \"ldi -1,%0\;subi %1,%R2,%R0\;{subbo|sub,b,tsv} %0,%2,%0\";
5220     }
5221   else
5222     return \"sub %R1,%R2,%R0\;{subbo|sub,b,tsv} %1,%2,%0\";
5224   [(set_attr "type" "binary,binary")
5225    (set (attr "length")
5226         (if_then_else (eq_attr "alternative" "0")
5227           (const_int 8)
5228           (if_then_else (ge (symbol_ref "INTVAL (operands[1])")
5229                             (const_int 0))
5230             (const_int 8)
5231             (const_int 12))))])
5233 (define_expand "subsi3"
5234   [(set (match_operand:SI 0 "register_operand" "")
5235         (minus:SI (match_operand:SI 1 "arith11_operand" "")
5236                   (match_operand:SI 2 "register_operand" "")))]
5237   ""
5238   "")
5240 (define_insn ""
5241   [(set (match_operand:SI 0 "register_operand" "=r,r")
5242         (minus:SI (match_operand:SI 1 "arith11_operand" "r,I")
5243                   (match_operand:SI 2 "register_operand" "r,r")))]
5244   "!TARGET_PA_20"
5245   "@
5246    sub %1,%2,%0
5247    subi %1,%2,%0"
5248   [(set_attr "type" "binary,binary")
5249    (set_attr "length" "4,4")])
5251 (define_insn ""
5252   [(set (match_operand:SI 0 "register_operand" "=r,r,!q")
5253         (minus:SI (match_operand:SI 1 "arith11_operand" "r,I,!S")
5254                   (match_operand:SI 2 "register_operand" "r,r,!r")))]
5255   "TARGET_PA_20"
5256   "@
5257    sub %1,%2,%0
5258    subi %1,%2,%0
5259    mtsarcm %2"
5260   [(set_attr "type" "binary,binary,move")
5261    (set_attr "length" "4,4,4")])
5263 (define_insn "subvsi3"
5264   [(set (match_operand:SI 0 "register_operand" "=r,r")
5265         (minus:SI (match_operand:SI 1 "arith11_operand" "rM,I")
5266                   (match_operand:SI 2 "reg_or_0_operand" "rM,rM")))
5267    (trap_if (ne (minus:DI (sign_extend:DI (match_dup 1))
5268                           (sign_extend:DI (match_dup 2)))
5269                 (sign_extend:DI (minus:SI (match_dup 1)
5270                                           (match_dup 2))))
5271             (const_int 0))]
5272   ""
5273   "@
5274   {subo|sub,tsv} %1,%2,%0
5275   {subio|subi,tsv} %1,%2,%0"
5276   [(set_attr "type" "binary,binary")
5277    (set_attr "length" "4,4")])
5279 ;; Trap instructions.
5281 (define_insn "trap"
5282   [(trap_if (const_int 1) (const_int 0))]
5283   ""
5284   "{addit|addi,tc},<> 1,%%r0,%%r0"
5285   [(set_attr "type" "trap")
5286    (set_attr "length" "4")])
5288 ;; Clobbering a "register_operand" instead of a match_scratch
5289 ;; in operand3 of millicode calls avoids spilling %r1 and
5290 ;; produces better code.
5292 ;; The mulsi3 insns set up registers for the millicode call.
5293 (define_expand "mulsi3"
5294   [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5295    (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5296    (parallel [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
5297               (clobber (match_dup 3))
5298               (clobber (reg:SI 26))
5299               (clobber (reg:SI 25))
5300               (clobber (match_dup 4))])
5301    (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5302   ""
5303   "
5305   operands[4] = gen_rtx_REG (SImode, TARGET_64BIT ? 2 : 31);
5306   if (TARGET_PA_11 && !TARGET_DISABLE_FPREGS && !TARGET_SOFT_FLOAT)
5307     {
5308       rtx scratch = gen_reg_rtx (DImode);
5309       operands[1] = force_reg (SImode, operands[1]);
5310       operands[2] = force_reg (SImode, operands[2]);
5311       emit_insn (gen_umulsidi3 (scratch, operands[1], operands[2]));
5312       emit_insn (gen_movsi (operands[0],
5313                             gen_rtx_SUBREG (SImode, scratch,
5314                                             GET_MODE_SIZE (SImode))));
5315       DONE;
5316     }
5317   operands[3] = gen_reg_rtx (SImode);
5320 (define_insn "umulsidi3"
5321   [(set (match_operand:DI 0 "register_operand" "=f")
5322         (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "f"))
5323                  (zero_extend:DI (match_operand:SI 2 "register_operand" "f"))))]
5324   "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT"
5325   "xmpyu %1,%2,%0"
5326   [(set_attr "type" "fpmuldbl")
5327    (set_attr "length" "4")])
5329 (define_insn ""
5330   [(set (match_operand:DI 0 "register_operand" "=f")
5331         (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "f"))
5332                  (match_operand:DI 2 "uint32_operand" "f")))]
5333   "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT && !TARGET_64BIT"
5334   "xmpyu %1,%R2,%0"
5335   [(set_attr "type" "fpmuldbl")
5336    (set_attr "length" "4")])
5338 (define_insn ""
5339   [(set (match_operand:DI 0 "register_operand" "=f")
5340         (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "f"))
5341                  (match_operand:DI 2 "uint32_operand" "f")))]
5342   "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT && TARGET_64BIT"
5343   "xmpyu %1,%2R,%0"
5344   [(set_attr "type" "fpmuldbl")
5345    (set_attr "length" "4")])
5347 (define_insn ""
5348   [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
5349    (clobber (match_operand:SI 0 "register_operand" "=a"))
5350    (clobber (reg:SI 26))
5351    (clobber (reg:SI 25))
5352    (clobber (reg:SI 31))]
5353   "!TARGET_64BIT"
5354   "* return pa_output_mul_insn (0, insn);"
5355   [(set_attr "type" "milli")
5356    (set (attr "length")
5357         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5358               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5360 (define_insn ""
5361   [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
5362    (clobber (match_operand:SI 0 "register_operand" "=a"))
5363    (clobber (reg:SI 26))
5364    (clobber (reg:SI 25))
5365    (clobber (reg:SI 2))]
5366   "TARGET_64BIT"
5367   "* return pa_output_mul_insn (0, insn);"
5368   [(set_attr "type" "milli")
5369    (set (attr "length")
5370         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5371               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5373 (define_expand "muldi3"
5374   [(set (match_operand:DI 0 "register_operand" "")
5375         (mult:DI (match_operand:DI 1 "register_operand" "")
5376                  (match_operand:DI 2 "register_operand" "")))]
5377   "TARGET_64BIT && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT"
5378   "
5380   rtx low_product = gen_reg_rtx (DImode);
5381   rtx cross_product1 = gen_reg_rtx (DImode);
5382   rtx cross_product2 = gen_reg_rtx (DImode);
5383   rtx cross_scratch = gen_reg_rtx (DImode);
5384   rtx cross_product = gen_reg_rtx (DImode);
5385   rtx op1l, op1r, op2l, op2r;
5386   rtx op1shifted, op2shifted;
5388   op1shifted = gen_reg_rtx (DImode);
5389   op2shifted = gen_reg_rtx (DImode);
5390   op1l = gen_reg_rtx (SImode);
5391   op1r = gen_reg_rtx (SImode);
5392   op2l = gen_reg_rtx (SImode);
5393   op2r = gen_reg_rtx (SImode);
5395   emit_move_insn (op1shifted, gen_rtx_LSHIFTRT (DImode, operands[1],
5396                                                 GEN_INT (32)));
5397   emit_move_insn (op2shifted, gen_rtx_LSHIFTRT (DImode, operands[2],
5398                                                 GEN_INT (32)));
5399   op1r = force_reg (SImode, gen_rtx_SUBREG (SImode, operands[1], 4));
5400   op2r = force_reg (SImode, gen_rtx_SUBREG (SImode, operands[2], 4));
5401   op1l = force_reg (SImode, gen_rtx_SUBREG (SImode, op1shifted, 4));
5402   op2l = force_reg (SImode, gen_rtx_SUBREG (SImode, op2shifted, 4));
5404   /* Emit multiplies for the cross products.  */
5405   emit_insn (gen_umulsidi3 (cross_product1, op2r, op1l));
5406   emit_insn (gen_umulsidi3 (cross_product2, op2l, op1r));
5408   /* Emit a multiply for the low sub-word.  */
5409   emit_insn (gen_umulsidi3 (low_product, copy_rtx (op2r), copy_rtx (op1r)));
5411   /* Sum the cross products and shift them into proper position.  */
5412   emit_insn (gen_adddi3 (cross_scratch, cross_product1, cross_product2));
5413   emit_insn (gen_ashldi3 (cross_product, cross_scratch, GEN_INT (32)));
5415   /* Add the cross product to the low product and store the result
5416      into the output operand .  */
5417   emit_insn (gen_adddi3 (operands[0], cross_product, low_product));
5418   DONE;
5421 ;;; Division and mod.
5422 (define_expand "divsi3"
5423   [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5424    (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5425    (parallel [(set (reg:SI 29) (div:SI (reg:SI 26) (reg:SI 25)))
5426               (clobber (match_dup 3))
5427               (clobber (match_dup 4))
5428               (clobber (reg:SI 26))
5429               (clobber (reg:SI 25))
5430               (clobber (match_dup 5))])
5431    (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5432   ""
5433   "
5435   operands[3] = gen_reg_rtx (SImode);
5436   if (TARGET_64BIT)
5437     {
5438       operands[5] = gen_rtx_REG (SImode, 2);
5439       operands[4] = operands[5];
5440     }
5441   else
5442     {
5443       operands[5] = gen_rtx_REG (SImode, 31);
5444       operands[4] = gen_reg_rtx (SImode);
5445     }
5446   if (GET_CODE (operands[2]) == CONST_INT && pa_emit_hpdiv_const (operands, 0))
5447     DONE;
5450 (define_insn ""
5451   [(set (reg:SI 29)
5452         (div:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5453    (clobber (match_operand:SI 1 "register_operand" "=a"))
5454    (clobber (match_operand:SI 2 "register_operand" "=&r"))
5455    (clobber (reg:SI 26))
5456    (clobber (reg:SI 25))
5457    (clobber (reg:SI 31))]
5458   "!TARGET_64BIT"
5459   "*
5460    return pa_output_div_insn (operands, 0, insn);"
5461   [(set_attr "type" "milli")
5462    (set (attr "length")
5463         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5464               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5466 (define_insn ""
5467   [(set (reg:SI 29)
5468         (div:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5469    (clobber (match_operand:SI 1 "register_operand" "=a"))
5470    (clobber (match_operand:SI 2 "register_operand" "=&r"))
5471    (clobber (reg:SI 26))
5472    (clobber (reg:SI 25))
5473    (clobber (reg:SI 2))]
5474   "TARGET_64BIT"
5475   "*
5476    return pa_output_div_insn (operands, 0, insn);"
5477   [(set_attr "type" "milli")
5478    (set (attr "length")
5479         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5480               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5482 (define_expand "udivsi3"
5483   [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5484    (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5485    (parallel [(set (reg:SI 29) (udiv:SI (reg:SI 26) (reg:SI 25)))
5486               (clobber (match_dup 3))
5487               (clobber (match_dup 4))
5488               (clobber (reg:SI 26))
5489               (clobber (reg:SI 25))
5490               (clobber (match_dup 5))])
5491    (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5492   ""
5493   "
5495   operands[3] = gen_reg_rtx (SImode);
5497   if (TARGET_64BIT)
5498     {
5499       operands[5] = gen_rtx_REG (SImode, 2);
5500       operands[4] = operands[5];
5501     }
5502   else
5503     {
5504       operands[5] = gen_rtx_REG (SImode, 31);
5505       operands[4] = gen_reg_rtx (SImode);
5506     }
5507   if (GET_CODE (operands[2]) == CONST_INT && pa_emit_hpdiv_const (operands, 1))
5508     DONE;
5511 (define_insn ""
5512   [(set (reg:SI 29)
5513         (udiv:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5514    (clobber (match_operand:SI 1 "register_operand" "=a"))
5515    (clobber (match_operand:SI 2 "register_operand" "=&r"))
5516    (clobber (reg:SI 26))
5517    (clobber (reg:SI 25))
5518    (clobber (reg:SI 31))]
5519   "!TARGET_64BIT"
5520   "*
5521    return pa_output_div_insn (operands, 1, insn);"
5522   [(set_attr "type" "milli")
5523    (set (attr "length")
5524         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5525               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5527 (define_insn ""
5528   [(set (reg:SI 29)
5529         (udiv:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5530    (clobber (match_operand:SI 1 "register_operand" "=a"))
5531    (clobber (match_operand:SI 2 "register_operand" "=&r"))
5532    (clobber (reg:SI 26))
5533    (clobber (reg:SI 25))
5534    (clobber (reg:SI 2))]
5535   "TARGET_64BIT"
5536   "*
5537    return pa_output_div_insn (operands, 1, insn);"
5538   [(set_attr "type" "milli")
5539    (set (attr "length")
5540         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5541               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5543 (define_expand "modsi3"
5544   [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5545    (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5546    (parallel [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
5547               (clobber (match_dup 3))
5548               (clobber (match_dup 4))
5549               (clobber (reg:SI 26))
5550               (clobber (reg:SI 25))
5551               (clobber (match_dup 5))])
5552    (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5553   ""
5554   "
5556   if (TARGET_64BIT)
5557     {
5558       operands[5] = gen_rtx_REG (SImode, 2);
5559       operands[4] = operands[5];
5560     }
5561   else
5562     {
5563       operands[5] = gen_rtx_REG (SImode, 31);
5564       operands[4] = gen_reg_rtx (SImode);
5565     }
5566   operands[3] = gen_reg_rtx (SImode);
5569 (define_insn ""
5570   [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
5571    (clobber (match_operand:SI 0 "register_operand" "=a"))
5572    (clobber (match_operand:SI 1 "register_operand" "=&r"))
5573    (clobber (reg:SI 26))
5574    (clobber (reg:SI 25))
5575    (clobber (reg:SI 31))]
5576   "!TARGET_64BIT"
5577   "*
5578   return pa_output_mod_insn (0, insn);"
5579   [(set_attr "type" "milli")
5580    (set (attr "length")
5581         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5582               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5584 (define_insn ""
5585   [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
5586    (clobber (match_operand:SI 0 "register_operand" "=a"))
5587    (clobber (match_operand:SI 1 "register_operand" "=&r"))
5588    (clobber (reg:SI 26))
5589    (clobber (reg:SI 25))
5590    (clobber (reg:SI 2))]
5591   "TARGET_64BIT"
5592   "*
5593   return pa_output_mod_insn (0, insn);"
5594   [(set_attr "type" "milli")
5595    (set (attr "length")
5596         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5597               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5599 (define_expand "umodsi3"
5600   [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5601    (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5602    (parallel [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
5603               (clobber (match_dup 3))
5604               (clobber (match_dup 4))
5605               (clobber (reg:SI 26))
5606               (clobber (reg:SI 25))
5607               (clobber (match_dup 5))])
5608    (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5609   ""
5610   "
5612   if (TARGET_64BIT)
5613     {
5614       operands[5] = gen_rtx_REG (SImode, 2);
5615       operands[4] = operands[5];
5616     }
5617   else
5618     {
5619       operands[5] = gen_rtx_REG (SImode, 31);
5620       operands[4] = gen_reg_rtx (SImode);
5621     }
5622   operands[3] = gen_reg_rtx (SImode);
5625 (define_insn ""
5626   [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
5627    (clobber (match_operand:SI 0 "register_operand" "=a"))
5628    (clobber (match_operand:SI 1 "register_operand" "=&r"))
5629    (clobber (reg:SI 26))
5630    (clobber (reg:SI 25))
5631    (clobber (reg:SI 31))]
5632   "!TARGET_64BIT"
5633   "*
5634   return pa_output_mod_insn (1, insn);"
5635   [(set_attr "type" "milli")
5636    (set (attr "length")
5637         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5638               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5640 (define_insn ""
5641   [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
5642    (clobber (match_operand:SI 0 "register_operand" "=a"))
5643    (clobber (match_operand:SI 1 "register_operand" "=&r"))
5644    (clobber (reg:SI 26))
5645    (clobber (reg:SI 25))
5646    (clobber (reg:SI 2))]
5647   "TARGET_64BIT"
5648   "*
5649   return pa_output_mod_insn (1, insn);"
5650   [(set_attr "type" "milli")
5651    (set (attr "length")
5652         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5653               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5655 ;;- and instructions
5656 ;; We define DImode `and` so with DImode `not` we can get
5657 ;; DImode `andn`.  Other combinations are possible.
5659 (define_expand "anddi3"
5660   [(set (match_operand:DI 0 "register_operand" "")
5661         (and:DI (match_operand:DI 1 "register_operand" "")
5662                 (match_operand:DI 2 "and_operand" "")))]
5663   "TARGET_64BIT"
5664   "")
5666 (define_insn ""
5667   [(set (match_operand:DI 0 "register_operand" "=r,r")
5668         (and:DI (match_operand:DI 1 "register_operand" "%?r,0")
5669                 (match_operand:DI 2 "and_operand" "rO,P")))]
5670   "TARGET_64BIT"
5671   "* return pa_output_64bit_and (operands); "
5672   [(set_attr "type" "binary")
5673    (set_attr "length" "4")])
5675 ; The ? for op1 makes reload prefer zdepi instead of loading a huge
5676 ; constant with ldil;ldo.
5677 (define_insn "andsi3"
5678   [(set (match_operand:SI 0 "register_operand" "=r,r")
5679         (and:SI (match_operand:SI 1 "register_operand" "%?r,0")
5680                 (match_operand:SI 2 "and_operand" "rO,P")))]
5681   ""
5682   "* return pa_output_and (operands); "
5683   [(set_attr "type" "binary,shift")
5684    (set_attr "length" "4,4")])
5686 (define_insn ""
5687   [(set (match_operand:DI 0 "register_operand" "=r")
5688         (and:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
5689                 (match_operand:DI 2 "register_operand" "r")))]
5690   "TARGET_64BIT"
5691   "andcm %2,%1,%0"
5692   [(set_attr "type" "binary")
5693    (set_attr "length" "4")])
5695 (define_insn ""
5696   [(set (match_operand:SI 0 "register_operand" "=r")
5697         (and:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
5698                 (match_operand:SI 2 "register_operand" "r")))]
5699   ""
5700   "andcm %2,%1,%0"
5701   [(set_attr "type" "binary")
5702   (set_attr "length" "4")])
5704 (define_expand "iordi3"
5705   [(set (match_operand:DI 0 "register_operand" "")
5706         (ior:DI (match_operand:DI 1 "register_operand" "")
5707                 (match_operand:DI 2 "reg_or_cint_ior_operand" "")))]
5708   "TARGET_64BIT"
5709   "")
5711 (define_insn ""
5712   [(set (match_operand:DI 0 "register_operand" "=r,r")
5713         (ior:DI (match_operand:DI 1 "register_operand" "0,0")
5714                 (match_operand:DI 2 "cint_ior_operand" "M,i")))]
5715   "TARGET_64BIT"
5716   "* return pa_output_64bit_ior (operands); "
5717   [(set_attr "type" "binary,shift")
5718    (set_attr "length" "4,4")])
5720 (define_insn ""
5721   [(set (match_operand:DI 0 "register_operand" "=r")
5722         (ior:DI (match_operand:DI 1 "register_operand" "%r")
5723                 (match_operand:DI 2 "register_operand" "r")))]
5724   "TARGET_64BIT"
5725   "or %1,%2,%0"
5726   [(set_attr "type" "binary")
5727    (set_attr "length" "4")])
5729 ;; Need a define_expand because we've run out of CONST_OK... characters.
5730 (define_expand "iorsi3"
5731   [(set (match_operand:SI 0 "register_operand" "")
5732         (ior:SI (match_operand:SI 1 "register_operand" "")
5733                 (match_operand:SI 2 "reg_or_cint_ior_operand" "")))]
5734   ""
5735   "")
5737 (define_insn ""
5738   [(set (match_operand:SI 0 "register_operand" "=r,r")
5739         (ior:SI (match_operand:SI 1 "register_operand" "0,0")
5740                 (match_operand:SI 2 "cint_ior_operand" "M,i")))]
5741   ""
5742   "* return pa_output_ior (operands); "
5743   [(set_attr "type" "binary,shift")
5744    (set_attr "length" "4,4")])
5746 (define_insn ""
5747   [(set (match_operand:SI 0 "register_operand" "=r")
5748         (ior:SI (match_operand:SI 1 "register_operand" "%r")
5749                 (match_operand:SI 2 "register_operand" "r")))]
5750   ""
5751   "or %1,%2,%0"
5752   [(set_attr "type" "binary")
5753    (set_attr "length" "4")])
5755 (define_expand "xordi3"
5756   [(set (match_operand:DI 0 "register_operand" "")
5757         (xor:DI (match_operand:DI 1 "register_operand" "")
5758                 (match_operand:DI 2 "register_operand" "")))]
5759   "TARGET_64BIT"
5760   "")
5762 (define_insn ""
5763   [(set (match_operand:DI 0 "register_operand" "=r")
5764         (xor:DI (match_operand:DI 1 "register_operand" "%r")
5765                 (match_operand:DI 2 "register_operand" "r")))]
5766   "TARGET_64BIT"
5767   "xor %1,%2,%0"
5768   [(set_attr "type" "binary")
5769    (set_attr "length" "4")])
5771 (define_insn "xorsi3"
5772   [(set (match_operand:SI 0 "register_operand" "=r")
5773         (xor:SI (match_operand:SI 1 "register_operand" "%r")
5774                 (match_operand:SI 2 "register_operand" "r")))]
5775   ""
5776   "xor %1,%2,%0"
5777   [(set_attr "type" "binary")
5778    (set_attr "length" "4")])
5780 (define_expand "negdi2"
5781   [(set (match_operand:DI 0 "register_operand" "")
5782         (neg:DI (match_operand:DI 1 "register_operand" "")))]
5783   ""
5784   "")
5786 (define_insn ""
5787   [(set (match_operand:DI 0 "register_operand" "=r")
5788         (neg:DI (match_operand:DI 1 "register_operand" "r")))]
5789   "!TARGET_64BIT"
5790   "sub %%r0,%R1,%R0\;{subb|sub,b} %%r0,%1,%0"
5791   [(set_attr "type" "unary")
5792    (set_attr "length" "8")])
5794 (define_insn ""
5795   [(set (match_operand:DI 0 "register_operand" "=r")
5796         (neg:DI (match_operand:DI 1 "register_operand" "r")))]
5797   "TARGET_64BIT"
5798   "sub %%r0,%1,%0"
5799   [(set_attr "type" "unary")
5800    (set_attr "length" "4")])
5802 (define_expand "negvdi2"
5803   [(parallel [(set (match_operand:DI 0 "register_operand" "")
5804                    (neg:DI (match_operand:DI 1 "register_operand" "")))
5805               (trap_if (ne (neg:TI (sign_extend:TI (match_dup 1)))
5806                                    (sign_extend:TI (neg:DI (match_dup 1))))
5807                        (const_int 0))])]
5808   ""
5809   "")
5811 (define_insn ""
5812   [(set (match_operand:DI 0 "register_operand" "=r")
5813         (neg:DI (match_operand:DI 1 "register_operand" "r")))
5814    (trap_if (ne (neg:TI (sign_extend:TI (match_dup 1)))
5815                 (sign_extend:TI (neg:DI (match_dup 1))))
5816             (const_int 0))]
5817   "!TARGET_64BIT"
5818   "sub %%r0,%R1,%R0\;{subbo|sub,b,tsv} %%r0,%1,%0"
5819   [(set_attr "type" "unary")
5820    (set_attr "length" "8")])
5822 (define_insn ""
5823   [(set (match_operand:DI 0 "register_operand" "=r")
5824         (neg:DI (match_operand:DI 1 "register_operand" "r")))
5825    (trap_if (ne (neg:TI (sign_extend:TI (match_dup 1)))
5826                 (sign_extend:TI (neg:DI (match_dup 1))))
5827             (const_int 0))]
5828   "TARGET_64BIT"
5829   "sub,tsv %%r0,%1,%0"
5830   [(set_attr "type" "unary")
5831    (set_attr "length" "4")])
5833 (define_insn "negsi2"
5834   [(set (match_operand:SI 0 "register_operand" "=r")
5835         (neg:SI (match_operand:SI 1 "register_operand" "r")))]
5836   ""
5837   "sub %%r0,%1,%0"
5838   [(set_attr "type" "unary")
5839    (set_attr "length" "4")])
5841 (define_insn "negvsi2"
5842   [(set (match_operand:SI 0 "register_operand" "=r")
5843         (neg:SI (match_operand:SI 1 "register_operand" "r")))
5844    (trap_if (ne (neg:DI (sign_extend:DI (match_dup 1)))
5845                 (sign_extend:DI (neg:SI (match_dup 1))))
5846             (const_int 0))]
5847    ""
5848    "{subo|sub,tsv} %%r0,%1,%0"
5849   [(set_attr "type" "unary")
5850    (set_attr "length" "4")])
5852 (define_expand "one_cmpldi2"
5853   [(set (match_operand:DI 0 "register_operand" "")
5854         (not:DI (match_operand:DI 1 "register_operand" "")))]
5855   ""
5856   "
5860 (define_insn ""
5861   [(set (match_operand:DI 0 "register_operand" "=r")
5862         (not:DI (match_operand:DI 1 "register_operand" "r")))]
5863   "!TARGET_64BIT"
5864   "uaddcm %%r0,%1,%0\;uaddcm %%r0,%R1,%R0"
5865   [(set_attr "type" "unary")
5866    (set_attr "length" "8")])
5868 (define_insn ""
5869   [(set (match_operand:DI 0 "register_operand" "=r")
5870         (not:DI (match_operand:DI 1 "register_operand" "r")))]
5871   "TARGET_64BIT"
5872   "uaddcm %%r0,%1,%0"
5873   [(set_attr "type" "unary")
5874    (set_attr "length" "4")])
5876 (define_insn "one_cmplsi2"
5877   [(set (match_operand:SI 0 "register_operand" "=r")
5878         (not:SI (match_operand:SI 1 "register_operand" "r")))]
5879   ""
5880   "uaddcm %%r0,%1,%0"
5881   [(set_attr "type" "unary")
5882    (set_attr "length" "4")])
5884 ;; Floating point arithmetic instructions.
5886 (define_insn "adddf3"
5887   [(set (match_operand:DF 0 "register_operand" "=f")
5888         (plus:DF (match_operand:DF 1 "register_operand" "f")
5889                  (match_operand:DF 2 "register_operand" "f")))]
5890   "! TARGET_SOFT_FLOAT"
5891   "fadd,dbl %1,%2,%0"
5892   [(set_attr "type" "fpalu")
5893    (set_attr "pa_combine_type" "faddsub")
5894    (set_attr "length" "4")])
5896 (define_insn "addsf3"
5897   [(set (match_operand:SF 0 "register_operand" "=f")
5898         (plus:SF (match_operand:SF 1 "register_operand" "f")
5899                  (match_operand:SF 2 "register_operand" "f")))]
5900   "! TARGET_SOFT_FLOAT"
5901   "fadd,sgl %1,%2,%0"
5902   [(set_attr "type" "fpalu")
5903    (set_attr "pa_combine_type" "faddsub")
5904    (set_attr "length" "4")])
5906 (define_insn "subdf3"
5907   [(set (match_operand:DF 0 "register_operand" "=f")
5908         (minus:DF (match_operand:DF 1 "register_operand" "f")
5909                   (match_operand:DF 2 "register_operand" "f")))]
5910   "! TARGET_SOFT_FLOAT"
5911   "fsub,dbl %1,%2,%0"
5912   [(set_attr "type" "fpalu")
5913    (set_attr "pa_combine_type" "faddsub")
5914    (set_attr "length" "4")])
5916 (define_insn "subsf3"
5917   [(set (match_operand:SF 0 "register_operand" "=f")
5918         (minus:SF (match_operand:SF 1 "register_operand" "f")
5919                   (match_operand:SF 2 "register_operand" "f")))]
5920   "! TARGET_SOFT_FLOAT"
5921   "fsub,sgl %1,%2,%0"
5922   [(set_attr "type" "fpalu")
5923    (set_attr "pa_combine_type" "faddsub")
5924    (set_attr "length" "4")])
5926 (define_insn "muldf3"
5927   [(set (match_operand:DF 0 "register_operand" "=f")
5928         (mult:DF (match_operand:DF 1 "register_operand" "f")
5929                  (match_operand:DF 2 "register_operand" "f")))]
5930   "! TARGET_SOFT_FLOAT"
5931   "fmpy,dbl %1,%2,%0"
5932   [(set_attr "type" "fpmuldbl")
5933    (set_attr "pa_combine_type" "fmpy")
5934    (set_attr "length" "4")])
5936 (define_insn "mulsf3"
5937   [(set (match_operand:SF 0 "register_operand" "=f")
5938         (mult:SF (match_operand:SF 1 "register_operand" "f")
5939                  (match_operand:SF 2 "register_operand" "f")))]
5940   "! TARGET_SOFT_FLOAT"
5941   "fmpy,sgl %1,%2,%0"
5942   [(set_attr "type" "fpmulsgl")
5943    (set_attr "pa_combine_type" "fmpy")
5944    (set_attr "length" "4")])
5946 (define_insn "divdf3"
5947   [(set (match_operand:DF 0 "register_operand" "=f")
5948         (div:DF (match_operand:DF 1 "register_operand" "f")
5949                 (match_operand:DF 2 "register_operand" "f")))]
5950   "! TARGET_SOFT_FLOAT"
5951   "fdiv,dbl %1,%2,%0"
5952   [(set_attr "type" "fpdivdbl")
5953    (set_attr "length" "4")])
5955 (define_insn "divsf3"
5956   [(set (match_operand:SF 0 "register_operand" "=f")
5957         (div:SF (match_operand:SF 1 "register_operand" "f")
5958                 (match_operand:SF 2 "register_operand" "f")))]
5959   "! TARGET_SOFT_FLOAT"
5960   "fdiv,sgl %1,%2,%0"
5961   [(set_attr "type" "fpdivsgl")
5962    (set_attr "length" "4")])
5964 ;; Processors prior to PA 2.0 don't have a fneg instruction.  Fast
5965 ;; negation can be done by subtracting from plus zero.  However, this
5966 ;; violates the IEEE standard when negating plus and minus zero.
5967 ;; The slow path toggles the sign bit in the general registers.
5968 (define_expand "negdf2"
5969   [(set (match_operand:DF 0 "register_operand" "")
5970         (neg:DF (match_operand:DF 1 "register_operand" "")))]
5971   "!TARGET_SOFT_FLOAT"
5973   if (TARGET_PA_20 || !flag_signed_zeros)
5974     emit_insn (gen_negdf2_fast (operands[0], operands[1]));
5975   else
5976     emit_insn (gen_negdf2_slow (operands[0], operands[1]));
5977   DONE;
5980 (define_insn "negdf2_slow"
5981   [(set (match_operand:DF 0 "register_operand" "=r")
5982         (neg:DF (match_operand:DF 1 "register_operand" "r")))]
5983   "!TARGET_SOFT_FLOAT && !TARGET_PA_20"
5984   "*
5986   if (rtx_equal_p (operands[0], operands[1]))
5987     return \"and,< %1,%1,%0\;depi,tr 1,0,1,%0\;depi 0,0,1,%0\";
5988   else
5989     return \"and,< %1,%1,%0\;depi,tr 1,0,1,%0\;depi 0,0,1,%0\;copy %R1,%R0\";
5991   [(set_attr "type" "multi")
5992    (set (attr "length")
5993         (if_then_else (match_test "rtx_equal_p (operands[0], operands[1])")
5994             (const_int 12)
5995             (const_int 16)))])
5997 (define_insn "negdf2_fast"
5998   [(set (match_operand:DF 0 "register_operand" "=f")
5999         (neg:DF (match_operand:DF 1 "register_operand" "f")))]
6000   "!TARGET_SOFT_FLOAT"
6001   "*
6003   if (TARGET_PA_20)
6004     return \"fneg,dbl %1,%0\";
6005   else
6006     return \"fsub,dbl %%fr0,%1,%0\";
6008   [(set_attr "type" "fpalu")
6009    (set_attr "length" "4")])
6011 (define_expand "negsf2"
6012   [(set (match_operand:SF 0 "register_operand" "")
6013         (neg:SF (match_operand:SF 1 "register_operand" "")))]
6014   "!TARGET_SOFT_FLOAT"
6016   if (TARGET_PA_20 || !flag_signed_zeros)
6017     emit_insn (gen_negsf2_fast (operands[0], operands[1]));
6018   else
6019     emit_insn (gen_negsf2_slow (operands[0], operands[1]));
6020   DONE;
6023 (define_insn "negsf2_slow"
6024   [(set (match_operand:SF 0 "register_operand" "=r")
6025         (neg:SF (match_operand:SF 1 "register_operand" "r")))]
6026   "!TARGET_SOFT_FLOAT && !TARGET_PA_20"
6027   "and,< %1,%1,%0\;depi,tr 1,0,1,%0\;depi 0,0,1,%0"
6028   [(set_attr "type" "multi")
6029    (set_attr "length" "12")])
6031 (define_insn "negsf2_fast"
6032   [(set (match_operand:SF 0 "register_operand" "=f")
6033         (neg:SF (match_operand:SF 1 "register_operand" "f")))]
6034   "!TARGET_SOFT_FLOAT"
6035   "*
6037   if (TARGET_PA_20)
6038     return \"fneg,sgl %1,%0\";
6039   else
6040     return \"fsub,sgl %%fr0,%1,%0\";
6042   [(set_attr "type" "fpalu")
6043    (set_attr "length" "4")])
6045 (define_insn "absdf2"
6046   [(set (match_operand:DF 0 "register_operand" "=f")
6047         (abs:DF (match_operand:DF 1 "register_operand" "f")))]
6048   "! TARGET_SOFT_FLOAT"
6049   "fabs,dbl %1,%0"
6050   [(set_attr "type" "fpalu")
6051    (set_attr "length" "4")])
6053 (define_insn "abssf2"
6054   [(set (match_operand:SF 0 "register_operand" "=f")
6055         (abs:SF (match_operand:SF 1 "register_operand" "f")))]
6056   "! TARGET_SOFT_FLOAT"
6057   "fabs,sgl %1,%0"
6058   [(set_attr "type" "fpalu")
6059    (set_attr "length" "4")])
6061 (define_insn "sqrtdf2"
6062   [(set (match_operand:DF 0 "register_operand" "=f")
6063         (sqrt:DF (match_operand:DF 1 "register_operand" "f")))]
6064   "! TARGET_SOFT_FLOAT"
6065   "fsqrt,dbl %1,%0"
6066   [(set_attr "type" "fpsqrtdbl")
6067    (set_attr "length" "4")])
6069 (define_insn "sqrtsf2"
6070   [(set (match_operand:SF 0 "register_operand" "=f")
6071         (sqrt:SF (match_operand:SF 1 "register_operand" "f")))]
6072   "! TARGET_SOFT_FLOAT"
6073   "fsqrt,sgl %1,%0"
6074   [(set_attr "type" "fpsqrtsgl")
6075    (set_attr "length" "4")])
6077 ;; PA 2.0 floating point instructions
6079 ; fmpyfadd patterns
6080 (define_insn "fmadf4"
6081   [(set (match_operand:DF 0 "register_operand" "=f")
6082         (fma:DF (match_operand:DF 1 "register_operand" "f")
6083                 (match_operand:DF 2 "register_operand" "f")
6084                 (match_operand:DF 3 "register_operand" "f")))]
6085   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6086   "fmpyfadd,dbl %1,%2,%3,%0"
6087   [(set_attr "type" "fpmuldbl")
6088    (set_attr "length" "4")])
6090 (define_insn "fmasf4"
6091   [(set (match_operand:SF 0 "register_operand" "=f")
6092         (fma:SF (match_operand:SF 1 "register_operand" "f")
6093                 (match_operand:SF 2 "register_operand" "f")
6094                 (match_operand:SF 3 "register_operand" "f")))]
6095   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6096   "fmpyfadd,sgl %1,%2,%3,%0"
6097   [(set_attr "type" "fpmulsgl")
6098    (set_attr "length" "4")])
6100 ; fmpynfadd patterns
6101 (define_insn "fnmadf4"
6102   [(set (match_operand:DF 0 "register_operand" "=f")
6103         (fma:DF (neg:DF (match_operand:DF 1 "register_operand" "f"))
6104                 (match_operand:DF 2 "register_operand" "f")
6105                 (match_operand:DF 3 "register_operand" "f")))]
6106   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6107   "fmpynfadd,dbl %1,%2,%3,%0"
6108   [(set_attr "type" "fpmuldbl")
6109    (set_attr "length" "4")])
6111 (define_insn "fnmasf4"
6112   [(set (match_operand:SF 0 "register_operand" "=f")
6113         (fma:SF (neg:SF (match_operand:SF 1 "register_operand" "f"))
6114                 (match_operand:SF 2 "register_operand" "f")
6115                 (match_operand:SF 3 "register_operand" "f")))]
6116   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6117   "fmpynfadd,sgl %1,%2,%3,%0"
6118   [(set_attr "type" "fpmulsgl")
6119    (set_attr "length" "4")])
6121 ; fnegabs patterns
6122 (define_insn ""
6123   [(set (match_operand:DF 0 "register_operand" "=f")
6124         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))]
6125   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6126   "fnegabs,dbl %1,%0"
6127   [(set_attr "type" "fpalu")
6128    (set_attr "length" "4")])
6130 (define_insn ""
6131   [(set (match_operand:SF 0 "register_operand" "=f")
6132         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))]
6133   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6134   "fnegabs,sgl %1,%0"
6135   [(set_attr "type" "fpalu")
6136    (set_attr "length" "4")])
6138 (define_insn ""
6139   [(set (match_operand:DF 0 "register_operand" "=f")
6140         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))
6141    (set (match_operand:DF 2 "register_operand" "=&f") (abs:DF (match_dup 1)))]
6142   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6143     && ! reg_overlap_mentioned_p (operands[2], operands[1]))"
6144   "#"
6145   [(set_attr "type" "fpalu")
6146    (set_attr "length" "8")])
6148 (define_split
6149   [(set (match_operand:DF 0 "register_operand" "")
6150         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" ""))))
6151    (set (match_operand:DF 2 "register_operand" "") (abs:DF (match_dup 1)))]
6152   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6153   [(set (match_dup 2) (abs:DF (match_dup 1)))
6154    (set (match_dup 0) (neg:DF (abs:DF (match_dup 1))))]
6155   "")
6157 (define_insn ""
6158   [(set (match_operand:SF 0 "register_operand" "=f")
6159         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))
6160    (set (match_operand:SF 2 "register_operand" "=&f") (abs:SF (match_dup 1)))]
6161   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6162     && ! reg_overlap_mentioned_p (operands[2], operands[1]))"
6163   "#"
6164   [(set_attr "type" "fpalu")
6165    (set_attr "length" "8")])
6167 (define_split
6168   [(set (match_operand:SF 0 "register_operand" "")
6169         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" ""))))
6170    (set (match_operand:SF 2 "register_operand" "") (abs:SF (match_dup 1)))]
6171   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6172   [(set (match_dup 2) (abs:SF (match_dup 1)))
6173    (set (match_dup 0) (neg:SF (abs:SF (match_dup 1))))]
6174   "")
6176 ;; Negating a multiply can be faked by adding zero in a fused multiply-add
6177 ;; instruction if we can ignore the sign of zero.
6178 (define_insn ""
6179   [(set (match_operand:DF 0 "register_operand" "=f")
6180         (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
6181                          (match_operand:DF 2 "register_operand" "f"))))]
6182   "!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros"
6183   "fmpynfadd,dbl %1,%2,%%fr0,%0"
6184   [(set_attr "type" "fpmuldbl")
6185    (set_attr "length" "4")])
6187 (define_insn ""
6188   [(set (match_operand:SF 0 "register_operand" "=f")
6189         (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
6190                          (match_operand:SF 2 "register_operand" "f"))))]
6191   "!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros"
6192   "fmpynfadd,sgl %1,%2,%%fr0,%0"
6193   [(set_attr "type" "fpmuldbl")
6194    (set_attr "length" "4")])
6196 (define_insn ""
6197   [(set (match_operand:DF 0 "register_operand" "=f")
6198         (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
6199                          (match_operand:DF 2 "register_operand" "f"))))
6200    (set (match_operand:DF 3 "register_operand" "=&f")
6201         (mult:DF (match_dup 1) (match_dup 2)))]
6202   "(!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros
6203     && ! (reg_overlap_mentioned_p (operands[3], operands[1])
6204           || reg_overlap_mentioned_p (operands[3], operands[2])))"
6205   "#"
6206   [(set_attr "type" "fpmuldbl")
6207    (set_attr "length" "8")])
6209 (define_split
6210   [(set (match_operand:DF 0 "register_operand" "")
6211         (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "")
6212                          (match_operand:DF 2 "register_operand" ""))))
6213    (set (match_operand:DF 3 "register_operand" "")
6214         (mult:DF (match_dup 1) (match_dup 2)))]
6215   "!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros"
6216   [(set (match_dup 3) (mult:DF (match_dup 1) (match_dup 2)))
6217    (set (match_dup 0) (neg:DF (mult:DF (match_dup 1) (match_dup 2))))]
6218   "")
6220 (define_insn ""
6221   [(set (match_operand:SF 0 "register_operand" "=f")
6222         (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
6223                          (match_operand:SF 2 "register_operand" "f"))))
6224    (set (match_operand:SF 3 "register_operand" "=&f")
6225         (mult:SF (match_dup 1) (match_dup 2)))]
6226   "(!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros
6227     && ! (reg_overlap_mentioned_p (operands[3], operands[1])
6228           || reg_overlap_mentioned_p (operands[3], operands[2])))"
6229   "#"
6230   [(set_attr "type" "fpmuldbl")
6231    (set_attr "length" "8")])
6233 (define_split
6234   [(set (match_operand:SF 0 "register_operand" "")
6235         (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "")
6236                          (match_operand:SF 2 "register_operand" ""))))
6237    (set (match_operand:SF 3 "register_operand" "")
6238         (mult:SF (match_dup 1) (match_dup 2)))]
6239   "!TARGET_SOFT_FLOAT && TARGET_PA_20&& !flag_signed_zeros"
6240   [(set (match_dup 3) (mult:SF (match_dup 1) (match_dup 2)))
6241    (set (match_dup 0) (neg:SF (mult:SF (match_dup 1) (match_dup 2))))]
6242   "")
6244 ;;- Shift instructions
6246 ;; Optimized special case of shifting.
6248 (define_insn ""
6249   [(set (match_operand:SI 0 "register_operand" "=r")
6250         (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
6251                      (const_int 24)))]
6252   ""
6253   "ldb%M1 %1,%0"
6254   [(set_attr "type" "load")
6255    (set_attr "length" "4")])
6257 (define_insn ""
6258   [(set (match_operand:SI 0 "register_operand" "=r")
6259         (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
6260                      (const_int 16)))]
6261   ""
6262   "ldh%M1 %1,%0"
6263   [(set_attr "type" "load")
6264    (set_attr "length" "4")])
6266 (define_insn ""
6267   [(set (match_operand:SI 0 "register_operand" "=r")
6268         (plus:SI (ashift:SI (match_operand:SI 2 "register_operand" "r")
6269                             (match_operand:SI 3 "shadd_operand" ""))
6270                  (match_operand:SI 1 "register_operand" "r")))]
6271   ""
6272   "{sh%o3addl %2,%1,%0|shladd,l %2,%o3,%1,%0} "
6273   [(set_attr "type" "binary")
6274    (set_attr "length" "4")])
6276 (define_insn ""
6277   [(set (match_operand:SI 0 "register_operand" "=r")
6278         (plus:SI (mult:SI (match_operand:SI 2 "register_operand" "r")
6279                           (match_operand:SI 3 "mem_shadd_operand" ""))
6280                  (match_operand:SI 1 "register_operand" "r")))]
6281   ""
6282   "*
6284   int shift_val = exact_log2 (INTVAL (operands[3]));
6285   operands[3] = GEN_INT (shift_val);
6286   return \"{sh%o3addl %2,%1,%0|shladd,l %2,%o3,%1,%0}\";
6288   [(set_attr "type" "binary")
6289    (set_attr "length" "4")])
6291 (define_insn ""
6292   [(set (match_operand:DI 0 "register_operand" "=r")
6293         (plus:DI (ashift:DI (match_operand:DI 2 "register_operand" "r")
6294                             (match_operand:DI 3 "shadd_operand" ""))
6295                  (match_operand:DI 1 "register_operand" "r")))]
6296   "TARGET_64BIT"
6297   "shladd,l %2,%o3,%1,%0"
6298   [(set_attr "type" "binary")
6299    (set_attr "length" "4")])
6301 (define_insn ""
6302   [(set (match_operand:DI 0 "register_operand" "=r")
6303         (plus:DI (mult:DI (match_operand:DI 2 "register_operand" "r")
6304                           (match_operand:DI 3 "mem_shadd_operand" ""))
6305                  (match_operand:DI 1 "register_operand" "r")))]
6306   "TARGET_64BIT"
6307   "*
6309   int shift_val = exact_log2 (INTVAL (operands[3]));
6310   operands[3] = GEN_INT (shift_val);
6311   return \"shladd,l %2,%o3,%1,%0\";
6313   [(set_attr "type" "binary")
6314    (set_attr "length" "4")])
6316 (define_expand "ashlsi3"
6317   [(set (match_operand:SI 0 "register_operand" "")
6318         (ashift:SI (match_operand:SI 1 "lhs_lshift_operand" "")
6319                    (match_operand:SI 2 "arith32_operand" "")))]
6320   ""
6321   "
6323   if (GET_CODE (operands[2]) != CONST_INT)
6324     {
6325       rtx temp = gen_reg_rtx (SImode);
6326       emit_insn (gen_subsi3 (temp, GEN_INT (31), operands[2]));
6327       if (GET_CODE (operands[1]) == CONST_INT)
6328         emit_insn (gen_zvdep_imm32 (operands[0], operands[1], temp));
6329       else
6330         emit_insn (gen_zvdep32 (operands[0], operands[1], temp));
6331       DONE;
6332     }
6333   /* Make sure both inputs are not constants,
6334      there are no patterns for that.  */
6335   operands[1] = force_reg (SImode, operands[1]);
6338 (define_insn ""
6339   [(set (match_operand:SI 0 "register_operand" "=r")
6340         (ashift:SI (match_operand:SI 1 "register_operand" "r")
6341                    (match_operand:SI 2 "const_int_operand" "n")))]
6342   ""
6343   "{zdep|depw,z} %1,%P2,%L2,%0"
6344   [(set_attr "type" "shift")
6345    (set_attr "length" "4")])
6347 ; Match cases of op1 a CONST_INT here that zvdep_imm32 doesn't handle.
6348 ; Doing it like this makes slightly better code since reload can
6349 ; replace a register with a known value in range -16..15 with a
6350 ; constant.  Ideally, we would like to merge zvdep32 and zvdep_imm32,
6351 ; but since we have no more CONST_OK... characters, that is not
6352 ; possible.
6353 (define_insn "zvdep32"
6354   [(set (match_operand:SI 0 "register_operand" "=r,r")
6355         (ashift:SI (match_operand:SI 1 "arith5_operand" "r,L")
6356                    (minus:SI (const_int 31)
6357                              (match_operand:SI 2 "register_operand" "q,q"))))]
6358   ""
6359   "@
6360    {zvdep %1,32,%0|depw,z %1,%%sar,32,%0}
6361    {zvdepi %1,32,%0|depwi,z %1,%%sar,32,%0}"
6362   [(set_attr "type" "shift,shift")
6363    (set_attr "length" "4,4")])
6365 (define_insn "zvdep_imm32"
6366   [(set (match_operand:SI 0 "register_operand" "=r")
6367         (ashift:SI (match_operand:SI 1 "lhs_lshift_cint_operand" "")
6368                    (minus:SI (const_int 31)
6369                              (match_operand:SI 2 "register_operand" "q"))))]
6370   ""
6371   "*
6373   unsigned HOST_WIDE_INT x = UINTVAL (operands[1]);
6374   operands[2] = GEN_INT (4 + exact_log2 ((x >> 4) + 1));
6375   operands[1] = GEN_INT ((x & 0xf) - 0x10);
6376   return \"{zvdepi %1,%2,%0|depwi,z %1,%%sar,%2,%0}\";
6378   [(set_attr "type" "shift")
6379    (set_attr "length" "4")])
6381 (define_insn "vdepi_ior"
6382   [(set (match_operand:SI 0 "register_operand" "=r")
6383         (ior:SI (ashift:SI (match_operand:SI 1 "const_int_operand" "")
6384                            (minus:SI (const_int 31)
6385                                      (match_operand:SI 2 "register_operand" "q")))
6386                 (match_operand:SI 3 "register_operand" "0")))]
6387   ; accept ...0001...1, can this be generalized?
6388   "exact_log2 (INTVAL (operands[1]) + 1) > 0"
6389   "*
6391   HOST_WIDE_INT x = INTVAL (operands[1]);
6392   operands[2] = GEN_INT (exact_log2 (x + 1));
6393   return \"{vdepi -1,%2,%0|depwi -1,%%sar,%2,%0}\";
6395   [(set_attr "type" "shift")
6396    (set_attr "length" "4")])
6398 (define_insn "vdepi_and"
6399   [(set (match_operand:SI 0 "register_operand" "=r")
6400         (and:SI (rotate:SI (match_operand:SI 1 "const_int_operand" "")
6401                            (minus:SI (const_int 31)
6402                                      (match_operand:SI 2 "register_operand" "q")))
6403                 (match_operand:SI 3 "register_operand" "0")))]
6404   ; this can be generalized...!
6405   "INTVAL (operands[1]) == -2"
6406   "*
6408   HOST_WIDE_INT x = INTVAL (operands[1]);
6409   operands[2] = GEN_INT (exact_log2 ((~x) + 1));
6410   return \"{vdepi 0,%2,%0|depwi 0,%%sar,%2,%0}\";
6412   [(set_attr "type" "shift")
6413    (set_attr "length" "4")])
6415 (define_expand "ashldi3"
6416   [(set (match_operand:DI 0 "register_operand" "")
6417         (ashift:DI (match_operand:DI 1 "lhs_lshift_operand" "")
6418                    (match_operand:DI 2 "arith32_operand" "")))]
6419   "TARGET_64BIT"
6420   "
6422   if (GET_CODE (operands[2]) != CONST_INT)
6423     {
6424       rtx temp = gen_reg_rtx (DImode);
6425       emit_insn (gen_subdi3 (temp, GEN_INT (63), operands[2]));
6426       if (GET_CODE (operands[1]) == CONST_INT)
6427         emit_insn (gen_zvdep_imm64 (operands[0], operands[1], temp));
6428       else
6429         emit_insn (gen_zvdep64 (operands[0], operands[1], temp));
6430       DONE;
6431     }
6432   /* Make sure both inputs are not constants,
6433      there are no patterns for that.  */
6434   operands[1] = force_reg (DImode, operands[1]);
6437 (define_insn ""
6438   [(set (match_operand:DI 0 "register_operand" "=r")
6439         (ashift:DI (match_operand:DI 1 "register_operand" "r")
6440                    (match_operand:DI 2 "const_int_operand" "n")))]
6441   "TARGET_64BIT"
6442   "depd,z %1,%p2,%Q2,%0"
6443   [(set_attr "type" "shift")
6444    (set_attr "length" "4")])
6446 ; Match cases of op1 a CONST_INT here that zvdep_imm64 doesn't handle.
6447 ; Doing it like this makes slightly better code since reload can
6448 ; replace a register with a known value in range -16..15 with a
6449 ; constant.  Ideally, we would like to merge zvdep64 and zvdep_imm64,
6450 ; but since we have no more CONST_OK... characters, that is not
6451 ; possible.
6452 (define_insn "zvdep64"
6453   [(set (match_operand:DI 0 "register_operand" "=r,r")
6454         (ashift:DI (match_operand:DI 1 "arith5_operand" "r,L")
6455                    (minus:DI (const_int 63)
6456                              (match_operand:DI 2 "register_operand" "q,q"))))]
6457   "TARGET_64BIT"
6458   "@
6459    depd,z %1,%%sar,64,%0
6460    depdi,z %1,%%sar,64,%0"
6461   [(set_attr "type" "shift,shift")
6462    (set_attr "length" "4,4")])
6464 (define_insn "zvdep_imm64"
6465   [(set (match_operand:DI 0 "register_operand" "=r")
6466         (ashift:DI (match_operand:DI 1 "lhs_lshift_cint_operand" "")
6467                    (minus:DI (const_int 63)
6468                              (match_operand:DI 2 "register_operand" "q"))))]
6469   "TARGET_64BIT"
6470   "*
6472   unsigned HOST_WIDE_INT x = UINTVAL (operands[1]);
6473   operands[2] = GEN_INT (4 + exact_log2 ((x >> 4) + 1));
6474   operands[1] = GEN_INT ((x & 0x1f) - 0x20);
6475   return \"depdi,z %1,%%sar,%2,%0\";
6477   [(set_attr "type" "shift")
6478    (set_attr "length" "4")])
6480 (define_insn ""
6481   [(set (match_operand:DI 0 "register_operand" "=r")
6482         (ior:DI (ashift:DI (match_operand:DI 1 "const_int_operand" "")
6483                            (minus:DI (const_int 63)
6484                                      (match_operand:DI 2 "register_operand" "q")))
6485                 (match_operand:DI 3 "register_operand" "0")))]
6486   ; accept ...0001...1, can this be generalized?
6487   "TARGET_64BIT && exact_log2 (INTVAL (operands[1]) + 1) > 0"
6488   "*
6490   HOST_WIDE_INT x = INTVAL (operands[1]);
6491   operands[2] = GEN_INT (exact_log2 (x + 1));
6492   return \"depdi -1,%%sar,%2,%0\";
6494   [(set_attr "type" "shift")
6495    (set_attr "length" "4")])
6497 (define_insn ""
6498   [(set (match_operand:DI 0 "register_operand" "=r")
6499         (and:DI (rotate:DI (match_operand:DI 1 "const_int_operand" "")
6500                            (minus:DI (const_int 63)
6501                                      (match_operand:DI 2 "register_operand" "q")))
6502                 (match_operand:DI 3 "register_operand" "0")))]
6503   ; this can be generalized...!
6504   "TARGET_64BIT && INTVAL (operands[1]) == -2"
6505   "*
6507   HOST_WIDE_INT x = INTVAL (operands[1]);
6508   operands[2] = GEN_INT (exact_log2 ((~x) + 1));
6509   return \"depdi 0,%%sar,%2,%0\";
6511   [(set_attr "type" "shift")
6512    (set_attr "length" "4")])
6514 (define_expand "ashrsi3"
6515   [(set (match_operand:SI 0 "register_operand" "")
6516         (ashiftrt:SI (match_operand:SI 1 "register_operand" "")
6517                      (match_operand:SI 2 "arith32_operand" "")))]
6518   ""
6519   "
6521   if (GET_CODE (operands[2]) != CONST_INT)
6522     {
6523       rtx temp = gen_reg_rtx (SImode);
6524       emit_insn (gen_subsi3 (temp, GEN_INT (31), operands[2]));
6525       emit_insn (gen_vextrs32 (operands[0], operands[1], temp));
6526       DONE;
6527     }
6530 (define_insn ""
6531   [(set (match_operand:SI 0 "register_operand" "=r")
6532         (ashiftrt:SI (match_operand:SI 1 "register_operand" "r")
6533                      (match_operand:SI 2 "const_int_operand" "n")))]
6534   ""
6535   "{extrs|extrw,s} %1,%P2,%L2,%0"
6536   [(set_attr "type" "shift")
6537    (set_attr "length" "4")])
6539 (define_insn "vextrs32"
6540   [(set (match_operand:SI 0 "register_operand" "=r")
6541         (ashiftrt:SI (match_operand:SI 1 "register_operand" "r")
6542                      (minus:SI (const_int 31)
6543                                (match_operand:SI 2 "register_operand" "q"))))]
6544   ""
6545   "{vextrs %1,32,%0|extrw,s %1,%%sar,32,%0}"
6546   [(set_attr "type" "shift")
6547    (set_attr "length" "4")])
6549 (define_expand "ashrdi3"
6550   [(set (match_operand:DI 0 "register_operand" "")
6551         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
6552                      (match_operand:DI 2 "arith32_operand" "")))]
6553   "TARGET_64BIT"
6554   "
6556   if (GET_CODE (operands[2]) != CONST_INT)
6557     {
6558       rtx temp = gen_reg_rtx (DImode);
6559       emit_insn (gen_subdi3 (temp, GEN_INT (63), operands[2]));
6560       emit_insn (gen_vextrs64 (operands[0], operands[1], temp));
6561       DONE;
6562     }
6565 (define_insn ""
6566   [(set (match_operand:DI 0 "register_operand" "=r")
6567         (ashiftrt:DI (match_operand:DI 1 "register_operand" "r")
6568                      (match_operand:DI 2 "const_int_operand" "n")))]
6569   "TARGET_64BIT"
6570   "extrd,s %1,%p2,%Q2,%0"
6571   [(set_attr "type" "shift")
6572    (set_attr "length" "4")])
6574 (define_insn "vextrs64"
6575   [(set (match_operand:DI 0 "register_operand" "=r")
6576         (ashiftrt:DI (match_operand:DI 1 "register_operand" "r")
6577                      (minus:DI (const_int 63)
6578                                (match_operand:DI 2 "register_operand" "q"))))]
6579   "TARGET_64BIT"
6580   "extrd,s %1,%%sar,64,%0"
6581   [(set_attr "type" "shift")
6582    (set_attr "length" "4")])
6584 (define_insn "lshrsi3"
6585   [(set (match_operand:SI 0 "register_operand" "=r,r")
6586         (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
6587                      (match_operand:SI 2 "shift5_operand" "q,n")))]
6588   ""
6589   "@
6590    {vshd %%r0,%1,%0|shrpw %%r0,%1,%%sar,%0}
6591    {extru|extrw,u} %1,%P2,%L2,%0"
6592   [(set_attr "type" "shift")
6593    (set_attr "length" "4")])
6595 (define_insn "lshrdi3"
6596   [(set (match_operand:DI 0 "register_operand" "=r,r")
6597         (lshiftrt:DI (match_operand:DI 1 "register_operand" "r,r")
6598                      (match_operand:DI 2 "shift6_operand" "q,n")))]
6599   "TARGET_64BIT"
6600   "@
6601    shrpd %%r0,%1,%%sar,%0
6602    extrd,u %1,%p2,%Q2,%0"
6603   [(set_attr "type" "shift")
6604    (set_attr "length" "4")])
6606 ; Shift right pair word 0 to 31 bits.
6607 (define_insn "shrpsi4"
6608   [(set (match_operand:SI 0 "register_operand" "=r,r")
6609         (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "r,r")
6610                            (minus:SI (const_int 32)
6611                              (match_operand:SI 3 "shift5_operand" "q,n")))
6612                 (lshiftrt:SI (match_operand:SI 2 "register_operand" "r,r")
6613                              (match_dup 3))))]
6614   ""
6615   "@
6616    {vshd %1,%2,%0|shrpw %1,%2,%%sar,%0}
6617    {shd|shrpw} %1,%2,%3,%0"
6618   [(set_attr "type" "shift")
6619    (set_attr "length" "4")])
6621 ; Shift right pair doubleword 0 to 63 bits.
6622 (define_insn "shrpdi4"
6623   [(set (match_operand:DI 0 "register_operand" "=r,r")
6624         (ior:DI (ashift:DI (match_operand:SI 1 "register_operand" "r,r")
6625                            (minus:DI (const_int 64)
6626                              (match_operand:DI 3 "shift6_operand" "q,n")))
6627                 (lshiftrt:DI (match_operand:DI 2 "register_operand" "r,r")
6628                              (match_dup 3))))]
6629   "TARGET_64BIT"
6630   "@
6631    shrpd %1,%2,%%sar,%0
6632    shrpd %1,%2,%3,%0"
6633   [(set_attr "type" "shift")
6634    (set_attr "length" "4")])
6636 (define_insn "rotrsi3"
6637   [(set (match_operand:SI 0 "register_operand" "=r,r")
6638         (rotatert:SI (match_operand:SI 1 "register_operand" "r,r")
6639                      (match_operand:SI 2 "shift5_operand" "q,n")))]
6640   ""
6641   "*
6643   if (GET_CODE (operands[2]) == CONST_INT)
6644     {
6645       operands[2] = GEN_INT (INTVAL (operands[2]) & 31);
6646       return \"{shd|shrpw} %1,%1,%2,%0\";
6647     }
6648   else
6649     return \"{vshd %1,%1,%0|shrpw %1,%1,%%sar,%0}\";
6651   [(set_attr "type" "shift")
6652    (set_attr "length" "4")])
6654 (define_expand "rotlsi3"
6655   [(set (match_operand:SI 0 "register_operand" "")
6656         (rotate:SI (match_operand:SI 1 "register_operand" "")
6657                    (match_operand:SI 2 "arith32_operand" "")))]
6658   ""
6659   "
6661   if (GET_CODE (operands[2]) != CONST_INT)
6662     {
6663       rtx temp = gen_reg_rtx (SImode);
6664       emit_insn (gen_subsi3 (temp, GEN_INT (32), operands[2]));
6665       emit_insn (gen_rotrsi3 (operands[0], operands[1], temp));
6666       DONE;
6667     }
6668   /* Else expand normally.  */
6671 (define_insn ""
6672   [(set (match_operand:SI 0 "register_operand" "=r")
6673         (rotate:SI (match_operand:SI 1 "register_operand" "r")
6674                    (match_operand:SI 2 "const_int_operand" "n")))]
6675   ""
6676   "*
6678   operands[2] = GEN_INT ((32 - INTVAL (operands[2])) & 31);
6679   return \"{shd|shrpw} %1,%1,%2,%0\";
6681   [(set_attr "type" "shift")
6682    (set_attr "length" "4")])
6684 (define_insn ""
6685   [(set (match_operand:SI 0 "register_operand" "=r")
6686         (match_operator:SI 5 "plus_xor_ior_operator"
6687           [(ashift:SI (match_operand:SI 1 "register_operand" "r")
6688                       (match_operand:SI 3 "const_int_operand" "n"))
6689            (lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
6690                         (match_operand:SI 4 "const_int_operand" "n"))]))]
6691   "INTVAL (operands[3]) + INTVAL (operands[4]) == 32"
6692   "{shd|shrpw} %1,%2,%4,%0"
6693   [(set_attr "type" "shift")
6694    (set_attr "length" "4")])
6696 (define_insn ""
6697   [(set (match_operand:SI 0 "register_operand" "=r")
6698         (match_operator:SI 5 "plus_xor_ior_operator"
6699           [(lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
6700                         (match_operand:SI 4 "const_int_operand" "n"))
6701            (ashift:SI (match_operand:SI 1 "register_operand" "r")
6702                       (match_operand:SI 3 "const_int_operand" "n"))]))]
6703   "INTVAL (operands[3]) + INTVAL (operands[4]) == 32"
6704   "{shd|shrpw} %1,%2,%4,%0"
6705   [(set_attr "type" "shift")
6706    (set_attr "length" "4")])
6708 (define_insn ""
6709   [(set (match_operand:SI 0 "register_operand" "=r")
6710         (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
6711                            (match_operand:SI 2 "const_int_operand" ""))
6712                 (match_operand:SI 3 "const_int_operand" "")))]
6713   "exact_log2 (1 + (INTVAL (operands[3]) >> (INTVAL (operands[2]) & 31))) > 0"
6714   "*
6716   int cnt = INTVAL (operands[2]) & 31;
6717   operands[3] = GEN_INT (exact_log2 (1 + (INTVAL (operands[3]) >> cnt)));
6718   operands[2] = GEN_INT (31 - cnt);
6719   return \"{zdep|depw,z} %1,%2,%3,%0\";
6721   [(set_attr "type" "shift")
6722    (set_attr "length" "4")])
6724 ;; Unconditional and other jump instructions.
6726 ;; Trivial return used when no epilogue is needed.
6727 (define_insn "return"
6728   [(return)
6729    (use (reg:SI 2))]
6730   "pa_can_use_return_insn ()"
6731   "*
6733   if (TARGET_PA_20)
6734     return \"bve%* (%%r2)\";
6735   return \"bv%* %%r0(%%r2)\";
6737   [(set_attr "type" "branch")
6738    (set_attr "length" "4")])
6740 ;; This is used for most returns.
6741 (define_insn "return_internal"
6742   [(return)
6743    (use (reg:SI 2))]
6744   ""
6745   "*
6747   if (TARGET_PA_20)
6748     return \"bve%* (%%r2)\";
6749   return \"bv%* %%r0(%%r2)\";
6751   [(set_attr "type" "branch")
6752    (set_attr "length" "4")])
6754 ;; This is used for eh returns which bypass the return stub.
6755 (define_insn "return_external_pic"
6756   [(return)
6757    (clobber (reg:SI 1))
6758    (use (reg:SI 2))]
6759   "!TARGET_NO_SPACE_REGS
6760    && !TARGET_PA_20
6761    && flag_pic && crtl->calls_eh_return"
6762   "ldsid (%%sr0,%%r2),%%r1\;mtsp %%r1,%%sr0\;be%* 0(%%sr0,%%r2)"
6763   [(set_attr "type" "branch")
6764    (set_attr "length" "12")])
6766 (define_expand "prologue"
6767   [(const_int 0)]
6768   ""
6769   "pa_expand_prologue ();DONE;")
6771 (define_expand "sibcall_epilogue"
6772   [(return)]
6773   ""
6774   "
6776   pa_expand_epilogue ();
6777   DONE;
6780 (define_expand "epilogue"
6781   [(return)]
6782   ""
6783   "
6785   rtx x;
6787   /* Try to use the trivial return first.  Else use the full epilogue.  */
6788   if (pa_can_use_return_insn ())
6789     x = gen_return ();
6790   else
6791     {
6792       pa_expand_epilogue ();
6794       /* EH returns bypass the normal return stub.  Thus, we must do an
6795          interspace branch to return from functions that call eh_return.
6796          This is only a problem for returns from shared code on ports
6797          using space registers.  */
6798       if (!TARGET_NO_SPACE_REGS
6799           && !TARGET_PA_20
6800           && flag_pic && crtl->calls_eh_return)
6801         x = gen_return_external_pic ();
6802       else
6803         x = gen_return_internal ();
6804     }
6805   emit_jump_insn (x);
6806   DONE;
6809 ; Used by hppa_profile_hook to load the starting address of the current
6810 ; function; operand 1 contains the address of the label in operand 3
6811 (define_insn "load_offset_label_address"
6812   [(set (match_operand:SI 0 "register_operand" "=r")
6813         (plus:SI (match_operand:SI 1 "register_operand" "r")
6814                  (minus:SI (match_operand:SI 2 "" "")
6815                            (label_ref:SI (match_operand 3 "" "")))))]
6816   ""
6817   "ldo %2-%l3(%1),%0"
6818   [(set_attr "type" "multi")
6819    (set_attr "length" "4")])
6821 ; Output a code label and load its address.
6822 (define_insn "lcla1"
6823   [(set (match_operand:SI 0 "register_operand" "=r")
6824         (label_ref:SI (match_operand 1 "" "")))
6825    (const_int 0)]
6826   "!TARGET_PA_20"
6827   "*
6829   output_asm_insn (\"bl .+8,%0\;depi 0,31,2,%0\", operands);
6830   (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
6831                                      CODE_LABEL_NUMBER (operands[1]));
6832   return \"\";
6834   [(set_attr "type" "multi")
6835    (set_attr "length" "8")])
6837 (define_insn "lcla2"
6838   [(set (match_operand:SI 0 "register_operand" "=r")
6839         (label_ref:SI (match_operand 1 "" "")))
6840    (const_int 0)]
6841   "TARGET_PA_20"
6842   "*
6844   (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
6845                                      CODE_LABEL_NUMBER (operands[1]));
6846   return \"mfia %0\";
6848   [(set_attr "type" "move")
6849    (set_attr "length" "4")])
6851 (define_insn "blockage"
6852   [(unspec_volatile [(const_int 2)] UNSPECV_BLOCKAGE)]
6853   ""
6854   ""
6855   [(set_attr "length" "0")])
6857 (define_insn "jump"
6858   [(set (pc) (label_ref (match_operand 0 "" "")))]
6859   ""
6860   "*
6862   /* An unconditional branch which can reach its target.  */
6863   if (get_attr_length (insn) < 16)
6864     return \"b%* %l0\";
6866   return pa_output_lbranch (operands[0], insn, 1);
6868   [(set_attr "type" "uncond_branch")
6869    (set_attr "pa_combine_type" "uncond_branch")
6870    (set (attr "length")
6871     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
6872                (const_int MAX_17BIT_OFFSET))
6873            (const_int 4)
6874            (match_test "TARGET_PORTABLE_RUNTIME")
6875            (const_int 20)
6876            (not (match_test "flag_pic"))
6877            (const_int 16)]
6878           (const_int 24)))])
6880 ;;; Hope this is only within a function...
6881 (define_insn "indirect_jump"
6882   [(set (pc) (match_operand 0 "pmode_register_operand" "r"))]
6883   ""
6884   "bv%* %%r0(%0)"
6885   [(set_attr "type" "branch")
6886    (set_attr "length" "4")])
6888 ;;; An indirect jump can be optimized to a direct jump.  GAS for the
6889 ;;; SOM target doesn't allow branching to a label inside a function.
6890 ;;; We also don't correctly compute branch distances for labels
6891 ;;; outside the current function.  Thus, we use an indirect jump can't
6892 ;;; be optimized to a direct jump for all targets.  We assume that
6893 ;;; the branch target is in the same space (i.e., nested function
6894 ;;; jumping to a label in an outer function in the same translation
6895 ;;; unit).
6896 (define_expand "nonlocal_goto"
6897   [(use (match_operand 0 "general_operand" ""))
6898    (use (match_operand 1 "general_operand" ""))
6899    (use (match_operand 2 "general_operand" ""))
6900    (use (match_operand 3 "general_operand" ""))]
6901   ""
6903   rtx lab = operands[1];
6904   rtx stack = operands[2];
6905   rtx fp = operands[3];
6907   emit_clobber (gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (VOIDmode)));
6908   emit_clobber (gen_rtx_MEM (BLKmode, hard_frame_pointer_rtx));
6910   lab = copy_to_reg (lab);
6912   /* Restore the stack and frame pointers.  */
6913   fp = copy_to_reg (fp);
6914   emit_stack_restore (SAVE_NONLOCAL, stack);
6916   /* Ensure the frame pointer move is not optimized.  */
6917   emit_insn (gen_blockage ());
6918   emit_clobber (hard_frame_pointer_rtx);
6919   emit_clobber (frame_pointer_rtx);
6920   emit_move_insn (hard_frame_pointer_rtx, fp);
6922   emit_use (hard_frame_pointer_rtx);
6923   emit_use (stack_pointer_rtx);
6925   /* Nonlocal goto jumps are only used between functions in the same
6926      translation unit.  Thus, we can avoid the extra overhead of an
6927      interspace jump.  */
6928   emit_jump_insn (gen_indirect_goto (lab));
6929   emit_barrier ();
6930   DONE;
6933 (define_insn "indirect_goto"
6934   [(unspec [(match_operand 0 "register_operand" "=r")] UNSPEC_GOTO)]
6935   "GET_MODE (operands[0]) == word_mode"
6936   "bv%* %%r0(%0)"
6937   [(set_attr "type" "branch")
6938    (set_attr "length" "4")])
6940 ;; Subroutines of "casesi".
6941 ;; operand 0 is index
6942 ;; operand 1 is the minimum bound
6943 ;; operand 2 is the maximum bound - minimum bound + 1
6944 ;; operand 3 is CODE_LABEL for the table;
6945 ;; operand 4 is the CODE_LABEL to go to if index out of range.
6947 (define_expand "casesi"
6948   [(match_operand:SI 0 "general_operand" "")
6949    (match_operand:SI 1 "const_int_operand" "")
6950    (match_operand:SI 2 "const_int_operand" "")
6951    (match_operand 3 "" "")
6952    (match_operand 4 "" "")]
6953   ""
6954   "
6956   if (GET_CODE (operands[0]) != REG)
6957     operands[0] = force_reg (SImode, operands[0]);
6959   if (operands[1] != const0_rtx)
6960     {
6961       rtx index = gen_reg_rtx (SImode);
6963       operands[1] = gen_int_mode (-INTVAL (operands[1]), SImode);
6964       if (!INT_14_BITS (operands[1]))
6965         operands[1] = force_reg (SImode, operands[1]);
6966       emit_insn (gen_addsi3 (index, operands[0], operands[1]));
6967       operands[0] = index;
6968     }
6970   if (!INT_5_BITS (operands[2]))
6971     operands[2] = force_reg (SImode, operands[2]);
6973   /* This branch prevents us finding an insn for the delay slot of the
6974      following vectored branch.  It might be possible to use the delay
6975      slot if an index value of -1 was used to transfer to the out-of-range
6976      label.  In order to do this, we would have to output the -1 vector
6977      element after the delay insn.  The casesi output code would have to
6978      check if the casesi insn is in a delay branch sequence and output
6979      the delay insn if one is found.  If this was done, then it might
6980      then be worthwhile to split the casesi patterns to improve scheduling.
6981      However, it's not clear that all this extra complexity is worth
6982      the effort.  */
6983   {
6984     rtx test = gen_rtx_GTU (VOIDmode, operands[0], operands[2]);
6985     emit_jump_insn (gen_cbranchsi4 (test, operands[0], operands[2], operands[4]));
6986   }
6988   /* In 64bit mode we must make sure to wipe the upper bits of the register
6989      just in case the addition overflowed or we had random bits in the
6990      high part of the register.  */
6991   if (TARGET_64BIT)
6992     {
6993       rtx index = gen_reg_rtx (DImode);
6995       emit_insn (gen_extendsidi2 (index, operands[0]));
6996       operands[0] = index;
6997     }
6999   if (TARGET_64BIT)
7000     emit_jump_insn (gen_casesi64p (operands[0], operands[3]));
7001   else if (flag_pic)
7002     emit_jump_insn (gen_casesi32p (operands[0], operands[3]));
7003   else
7004     emit_jump_insn (gen_casesi32 (operands[0], operands[3]));
7005   DONE;
7008 ;;; 32-bit code, absolute branch table.
7009 (define_insn "casesi32"
7010   [(set (pc) (mem:SI (plus:SI
7011                        (mult:SI (match_operand:SI 0 "register_operand" "r")
7012                                 (const_int 4))
7013                        (label_ref (match_operand 1 "" "")))))
7014    (clobber (match_scratch:SI 2 "=&r"))]
7015   "!flag_pic"
7016   "ldil L'%l1,%2\;ldo R'%l1(%2),%2\;{ldwx|ldw},s %0(%2),%2\;bv,n %%r0(%2)"
7017   [(set_attr "type" "multi")
7018    (set_attr "length" "16")])
7020 ;;; 32-bit code, relative branch table.
7021 (define_insn "casesi32p"
7022   [(set (pc) (mem:SI (plus:SI
7023                        (mult:SI (match_operand:SI 0 "register_operand" "r")
7024                                 (const_int 4))
7025                        (label_ref (match_operand 1 "" "")))))
7026    (clobber (match_scratch:SI 2 "=&r"))
7027    (clobber (match_scratch:SI 3 "=&r"))]
7028   "flag_pic"
7029   "{bl .+8,%2\;depi 0,31,2,%2|mfia %2}\;ldo {%l1-.|%l1+4-.}(%2),%2\;\
7030 {ldwx|ldw},s %0(%2),%3\;{addl|add,l} %2,%3,%3\;bv,n %%r0(%3)"
7031   [(set_attr "type" "multi")
7032    (set (attr "length")
7033      (if_then_else (match_test "TARGET_PA_20")
7034         (const_int 20)
7035         (const_int 24)))])
7037 ;;; 64-bit code, 32-bit relative branch table.
7038 (define_insn "casesi64p"
7039   [(set (pc) (mem:DI (plus:DI
7040                        (mult:DI (match_operand:DI 0 "register_operand" "r")
7041                                 (const_int 8))
7042                        (label_ref (match_operand 1 "" "")))))
7043    (clobber (match_scratch:DI 2 "=&r"))
7044    (clobber (match_scratch:DI 3 "=&r"))]
7045   ""
7046   "mfia %2\;ldo %l1+4-.(%2),%2\;ldw,s %0(%2),%3\;extrd,s %3,63,32,%3\;\
7047 add,l %2,%3,%3\;bv,n %%r0(%3)"
7048   [(set_attr "type" "multi")
7049    (set_attr "length" "24")])
7052 ;; Call patterns.
7053 ;;- jump to subroutine
7055 (define_expand "call"
7056   [(parallel [(call (match_operand:SI 0 "" "")
7057                     (match_operand 1 "" ""))
7058               (clobber (reg:SI 2))])]
7059   ""
7060   "
7062   rtx op;
7063   rtx nb = operands[1];
7065   if (TARGET_PORTABLE_RUNTIME)
7066     op = force_reg (SImode, XEXP (operands[0], 0));
7067   else
7068     {
7069       op = XEXP (operands[0], 0);
7071       /* Generate indirect long calls to non-local functions. */
7072       if (TARGET_LONG_CALLS && GET_CODE (op) == SYMBOL_REF)
7073         {
7074           tree call_decl = SYMBOL_REF_DECL (op);
7075           if (!(call_decl && targetm.binds_local_p (call_decl)))
7076             op = force_reg (word_mode, op);
7077         }
7078     }
7080   if (TARGET_64BIT)
7081     {
7082       if (!virtuals_instantiated)
7083         emit_move_insn (arg_pointer_rtx,
7084                         gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
7085                                       GEN_INT (64)));
7086       else
7087         {
7088           /* The loop pass can generate new libcalls after the virtual
7089              registers are instantiated when fpregs are disabled because
7090              the only method that we have for doing DImode multiplication
7091              is with a libcall.  This could be trouble if we haven't
7092              allocated enough space for the outgoing arguments.  */
7093           gcc_assert (INTVAL (nb) <= crtl->outgoing_args_size);
7095           emit_move_insn (arg_pointer_rtx,
7096                           gen_rtx_PLUS (word_mode, stack_pointer_rtx,
7097                                         GEN_INT (STACK_POINTER_OFFSET + 64)));
7098         }
7099     }
7101   /* Use two different patterns for calls to explicitly named functions
7102      and calls through function pointers.  This is necessary as these two
7103      types of calls use different calling conventions, and CSE might try
7104      to change the named call into an indirect call in some cases (using
7105      two patterns keeps CSE from performing this optimization).
7106      
7107      We now use even more call patterns as there was a subtle bug in
7108      attempting to restore the pic register after a call using a simple
7109      move insn.  During reload, a instruction involving a pseudo register
7110      with no explicit dependence on the PIC register can be converted
7111      to an equivalent load from memory using the PIC register.  If we
7112      emit a simple move to restore the PIC register in the initial rtl
7113      generation, then it can potentially be repositioned during scheduling.
7114      and an instruction that eventually uses the PIC register may end up
7115      between the call and the PIC register restore.
7116      
7117      This only worked because there is a post call group of instructions
7118      that are scheduled with the call.  These instructions are included
7119      in the same basic block as the call.  However, calls can throw in
7120      C++ code and a basic block has to terminate at the call if the call
7121      can throw.  This results in the PIC register restore being scheduled
7122      independently from the call.  So, we now hide the save and restore
7123      of the PIC register in the call pattern until after reload.  Then,
7124      we split the moves out.  A small side benefit is that we now don't
7125      need to have a use of the PIC register in the return pattern and
7126      the final save/restore operation is not needed.
7127      
7128      I elected to just use register %r4 in the PIC patterns instead
7129      of trying to force hppa_pic_save_rtx () to a callee saved register.
7130      This might have required a new register class and constraint.  It
7131      was also simpler to just handle the restore from a register than a
7132      generic pseudo.  */
7133   if (TARGET_64BIT)
7134     {
7135       rtx r4 = gen_rtx_REG (word_mode, 4);
7136       if (GET_CODE (op) == SYMBOL_REF)
7137         emit_call_insn (gen_call_symref_64bit (op, nb, r4));
7138       else
7139         {
7140           op = force_reg (word_mode, op);
7141           emit_call_insn (gen_call_reg_64bit (op, nb, r4));
7142         }
7143     }
7144   else
7145     {
7146       if (GET_CODE (op) == SYMBOL_REF)
7147         {
7148           if (flag_pic)
7149             {
7150               rtx r4 = gen_rtx_REG (word_mode, 4);
7151               emit_call_insn (gen_call_symref_pic (op, nb, r4));
7152             }
7153           else
7154             emit_call_insn (gen_call_symref (op, nb));
7155         }
7156       else
7157         {
7158           rtx tmpreg = gen_rtx_REG (word_mode, 22);
7159           emit_move_insn (tmpreg, force_reg (word_mode, op));
7160           if (flag_pic)
7161             {
7162               rtx r4 = gen_rtx_REG (word_mode, 4);
7163               emit_call_insn (gen_call_reg_pic (nb, r4));
7164             }
7165           else
7166             emit_call_insn (gen_call_reg (nb));
7167         }
7168     }
7170   DONE;
7173 ;; We use function calls to set the attribute length of calls and millicode
7174 ;; calls.  This is necessary because of the large variety of call sequences.
7175 ;; Implementing the calculation in rtl is difficult as well as ugly.  As
7176 ;; we need the same calculation in several places, maintenance becomes a
7177 ;; nightmare.
7179 ;; However, this has a subtle impact on branch shortening.  When the
7180 ;; expression used to set the length attribute of an instruction depends
7181 ;; on a relative address (e.g., pc or a branch address), genattrtab
7182 ;; notes that the insn's length is variable, and attempts to determine a
7183 ;; worst-case default length and code to compute an insn's current length.
7185 ;; The use of a function call hides the variable dependence of our calls
7186 ;; and millicode calls.  The result is genattrtab doesn't treat the operation
7187 ;; as variable and it only generates code for the default case using our
7188 ;; function call.  Because of this, calls and millicode calls have a fixed
7189 ;; length in the branch shortening pass, and some branches will use a longer
7190 ;; code sequence than necessary.  However, the length of any given call
7191 ;; will still reflect its final code location and it may be shorter than
7192 ;; the initial length estimate.
7194 ;; It's possible to trick genattrtab by adding an expression involving `pc'
7195 ;; in the set.  However, when genattrtab hits a function call in its attempt
7196 ;; to compute the default length, it marks the result as unknown and sets
7197 ;; the default result to MAX_INT ;-(  One possible fix that would allow
7198 ;; calls to participate in branch shortening would be to make the call to
7199 ;; insn_default_length a target option.  Then, we could massage unknown
7200 ;; results.  Another fix might be to change genattrtab so that it just does
7201 ;; the call in the variable case as it already does for the fixed case.
7203 (define_insn "call_symref"
7204   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7205          (match_operand 1 "" "i"))
7206    (clobber (reg:SI 1))
7207    (clobber (reg:SI 2))
7208    (use (const_int 0))]
7209   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7210   "*
7212   pa_output_arg_descriptor (insn);
7213   return pa_output_call (insn, operands[0], 0);
7215   [(set_attr "type" "call")
7216    (set (attr "length")
7217         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7218               (symbol_ref "pa_attr_length_call (insn, 0)")))])
7220 (define_insn "call_symref_pic"
7221   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7222          (match_operand 1 "" "i"))
7223    (clobber (reg:SI 1))
7224    (clobber (reg:SI 2))
7225    (clobber (match_operand 2))
7226    (use (reg:SI 19))
7227    (use (const_int 0))]
7228   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7229   "#")
7231 ;; Split out the PIC register save and restore after reload.  As the
7232 ;; split is done after reload, there are some situations in which we
7233 ;; unnecessarily save and restore %r4.  This happens when there is a
7234 ;; single call and the PIC register is not used after the call.
7236 ;; The split has to be done since call_from_call_insn () can't handle
7237 ;; the pattern as is.  Noreturn calls are special because they have to
7238 ;; terminate the basic block.  The split has to contain more than one
7239 ;; insn.
7240 (define_split
7241   [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7242                     (match_operand 1 "" ""))
7243               (clobber (reg:SI 1))
7244               (clobber (reg:SI 2))
7245               (clobber (match_operand 2))
7246               (use (reg:SI 19))
7247               (use (const_int 0))])]
7248   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed
7249    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7250   [(set (match_dup 2) (reg:SI 19))
7251    (parallel [(call (mem:SI (match_dup 0))
7252                     (match_dup 1))
7253               (clobber (reg:SI 1))
7254               (clobber (reg:SI 2))
7255               (use (reg:SI 19))
7256               (use (const_int 0))])]
7257   "")
7259 (define_split
7260   [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7261                     (match_operand 1 "" ""))
7262               (clobber (reg:SI 1))
7263               (clobber (reg:SI 2))
7264               (clobber (match_operand 2))
7265               (use (reg:SI 19))
7266               (use (const_int 0))])]
7267   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
7268   [(set (match_dup 2) (reg:SI 19))
7269    (parallel [(call (mem:SI (match_dup 0))
7270                     (match_dup 1))
7271               (clobber (reg:SI 1))
7272               (clobber (reg:SI 2))
7273               (use (reg:SI 19))
7274               (use (const_int 0))])
7275    (set (reg:SI 19) (match_dup 2))]
7276   "")
7278 (define_insn "*call_symref_pic_post_reload"
7279   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7280          (match_operand 1 "" "i"))
7281    (clobber (reg:SI 1))
7282    (clobber (reg:SI 2))
7283    (use (reg:SI 19))
7284    (use (const_int 0))]
7285   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7286   "*
7288   pa_output_arg_descriptor (insn);
7289   return pa_output_call (insn, operands[0], 0);
7291   [(set_attr "type" "call")
7292    (set (attr "length")
7293         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7294               (symbol_ref "pa_attr_length_call (insn, 0)")))])
7296 ;; This pattern is split if it is necessary to save and restore the
7297 ;; PIC register.
7298 (define_insn "call_symref_64bit"
7299   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7300          (match_operand 1 "" "i"))
7301    (clobber (reg:DI 1))
7302    (clobber (reg:DI 2))
7303    (clobber (match_operand 2))
7304    (use (reg:DI 27))
7305    (use (reg:DI 29))
7306    (use (const_int 0))]
7307   "TARGET_64BIT"
7308   "#")
7310 ;; Split out the PIC register save and restore after reload.  As the
7311 ;; split is done after reload, there are some situations in which we
7312 ;; unnecessarily save and restore %r4.  This happens when there is a
7313 ;; single call and the PIC register is not used after the call.
7315 ;; The split has to be done since call_from_call_insn () can't handle
7316 ;; the pattern as is.  Noreturn calls are special because they have to
7317 ;; terminate the basic block.  The split has to contain more than one
7318 ;; insn.
7319 (define_split
7320   [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7321                     (match_operand 1 "" ""))
7322               (clobber (reg:DI 1))
7323               (clobber (reg:DI 2))
7324               (clobber (match_operand 2))
7325               (use (reg:DI 27))
7326               (use (reg:DI 29))
7327               (use (const_int 0))])]
7328   "TARGET_64BIT && reload_completed
7329    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7330   [(set (match_dup 2) (reg:DI 27))
7331    (parallel [(call (mem:SI (match_dup 0))
7332                     (match_dup 1))
7333               (clobber (reg:DI 1))
7334               (clobber (reg:DI 2))
7335               (use (reg:DI 27))
7336               (use (reg:DI 29))
7337               (use (const_int 0))])]
7338   "")
7340 (define_split
7341   [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7342                     (match_operand 1 "" ""))
7343               (clobber (reg:DI 1))
7344               (clobber (reg:DI 2))
7345               (clobber (match_operand 2))
7346               (use (reg:DI 27))
7347               (use (reg:DI 29))
7348               (use (const_int 0))])]
7349   "TARGET_64BIT && reload_completed"
7350   [(set (match_dup 2) (reg:DI 27))
7351    (parallel [(call (mem:SI (match_dup 0))
7352                     (match_dup 1))
7353               (clobber (reg:DI 1))
7354               (clobber (reg:DI 2))
7355               (use (reg:DI 27))
7356               (use (reg:DI 29))
7357               (use (const_int 0))])
7358    (set (reg:DI 27) (match_dup 2))]
7359   "")
7361 (define_insn "*call_symref_64bit_post_reload"
7362   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7363          (match_operand 1 "" "i"))
7364    (clobber (reg:DI 1))
7365    (clobber (reg:DI 2))
7366    (use (reg:DI 27))
7367    (use (reg:DI 29))
7368    (use (const_int 0))]
7369   "TARGET_64BIT"
7370   "*
7372   return pa_output_call (insn, operands[0], 0);
7374   [(set_attr "type" "call")
7375    (set (attr "length")
7376         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7377               (symbol_ref "pa_attr_length_call (insn, 0)")))])
7379 (define_insn "call_reg"
7380   [(call (mem:SI (reg:SI 22))
7381          (match_operand 0 "" "i"))
7382    (clobber (reg:SI 1))
7383    (clobber (reg:SI 2))
7384    (use (const_int 1))]
7385   "!TARGET_64BIT"
7386   "*
7388   return pa_output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
7390   [(set_attr "type" "dyncall")
7391    (set (attr "length")
7392         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7393               (symbol_ref "pa_attr_length_indirect_call (insn)")))])
7395 ;; This pattern is split if it is necessary to save and restore the
7396 ;; PIC register.
7397 (define_insn "call_reg_pic"
7398   [(call (mem:SI (reg:SI 22))
7399          (match_operand 0 "" "i"))
7400    (clobber (reg:SI 1))
7401    (clobber (reg:SI 2))
7402    (clobber (match_operand 1))
7403    (use (reg:SI 19))
7404    (use (const_int 1))]
7405   "!TARGET_64BIT"
7406   "#")
7408 ;; Split out the PIC register save and restore after reload.  As the
7409 ;; split is done after reload, there are some situations in which we
7410 ;; unnecessarily save and restore %r4.  This happens when there is a
7411 ;; single call and the PIC register is not used after the call.
7413 ;; The split has to be done since call_from_call_insn () can't handle
7414 ;; the pattern as is.  Noreturn calls are special because they have to
7415 ;; terminate the basic block.  The split has to contain more than one
7416 ;; insn.
7417 (define_split
7418   [(parallel [(call (mem:SI (reg:SI 22))
7419                     (match_operand 0 "" ""))
7420               (clobber (reg:SI 1))
7421               (clobber (reg:SI 2))
7422               (clobber (match_operand 1))
7423               (use (reg:SI 19))
7424               (use (const_int 1))])]
7425   "!TARGET_64BIT && reload_completed
7426    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7427   [(set (match_dup 1) (reg:SI 19))
7428    (parallel [(call (mem:SI (reg:SI 22))
7429                     (match_dup 0))
7430               (clobber (reg:SI 1))
7431               (clobber (reg:SI 2))
7432               (use (reg:SI 19))
7433               (use (const_int 1))])]
7434   "")
7436 (define_split
7437   [(parallel [(call (mem:SI (reg:SI 22))
7438                     (match_operand 0 "" ""))
7439               (clobber (reg:SI 1))
7440               (clobber (reg:SI 2))
7441               (clobber (match_operand 1))
7442               (use (reg:SI 19))
7443               (use (const_int 1))])]
7444   "!TARGET_64BIT && reload_completed"
7445   [(set (match_dup 1) (reg:SI 19))
7446    (parallel [(call (mem:SI (reg:SI 22))
7447                     (match_dup 0))
7448               (clobber (reg:SI 1))
7449               (clobber (reg:SI 2))
7450               (use (reg:SI 19))
7451               (use (const_int 1))])
7452    (set (reg:SI 19) (match_dup 1))]
7453   "")
7455 (define_insn "*call_reg_pic_post_reload"
7456   [(call (mem:SI (reg:SI 22))
7457          (match_operand 0 "" "i"))
7458    (clobber (reg:SI 1))
7459    (clobber (reg:SI 2))
7460    (use (reg:SI 19))
7461    (use (const_int 1))]
7462   "!TARGET_64BIT"
7463   "*
7465   return pa_output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
7467   [(set_attr "type" "dyncall")
7468    (set (attr "length")
7469         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7470               (symbol_ref "pa_attr_length_indirect_call (insn)")))])
7472 ;; This pattern is split if it is necessary to save and restore the
7473 ;; PIC register.
7474 (define_insn "call_reg_64bit"
7475   [(call (mem:SI (match_operand:DI 0 "register_operand" "r"))
7476          (match_operand 1 "" "i"))
7477    (clobber (reg:DI 2))
7478    (clobber (match_operand 2))
7479    (use (reg:DI 27))
7480    (use (reg:DI 29))
7481    (use (const_int 1))]
7482   "TARGET_64BIT"
7483   "#")
7485 ;; Split out the PIC register save and restore after reload.  As the
7486 ;; split is done after reload, there are some situations in which we
7487 ;; unnecessarily save and restore %r4.  This happens when there is a
7488 ;; single call and the PIC register is not used after the call.
7490 ;; The split has to be done since call_from_call_insn () can't handle
7491 ;; the pattern as is.  Noreturn calls are special because they have to
7492 ;; terminate the basic block.  The split has to contain more than one
7493 ;; insn.
7494 (define_split
7495   [(parallel [(call (mem:SI (match_operand 0 "register_operand" ""))
7496                     (match_operand 1 "" ""))
7497               (clobber (reg:DI 2))
7498               (clobber (match_operand 2))
7499               (use (reg:DI 27))
7500               (use (reg:DI 29))
7501               (use (const_int 1))])]
7502   "TARGET_64BIT && reload_completed
7503    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7504   [(set (match_dup 2) (reg:DI 27))
7505    (parallel [(call (mem:SI (match_dup 0))
7506                     (match_dup 1))
7507               (clobber (reg:DI 2))
7508               (use (reg:DI 27))
7509               (use (reg:DI 29))
7510               (use (const_int 1))])]
7511   "")
7513 (define_split
7514   [(parallel [(call (mem:SI (match_operand 0 "register_operand" ""))
7515                     (match_operand 1 "" ""))
7516               (clobber (reg:DI 2))
7517               (clobber (match_operand 2))
7518               (use (reg:DI 27))
7519               (use (reg:DI 29))
7520               (use (const_int 1))])]
7521   "TARGET_64BIT && reload_completed"
7522   [(set (match_dup 2) (reg:DI 27))
7523    (parallel [(call (mem:SI (match_dup 0))
7524                     (match_dup 1))
7525               (clobber (reg:DI 2))
7526               (use (reg:DI 27))
7527               (use (reg:DI 29))
7528               (use (const_int 1))])
7529    (set (reg:DI 27) (match_dup 2))]
7530   "")
7532 (define_insn "*call_reg_64bit_post_reload"
7533   [(call (mem:SI (match_operand:DI 0 "register_operand" "r"))
7534          (match_operand 1 "" "i"))
7535    (clobber (reg:DI 2))
7536    (use (reg:DI 27))
7537    (use (reg:DI 29))
7538    (use (const_int 1))]
7539   "TARGET_64BIT"
7540   "*
7542   return pa_output_indirect_call (insn, operands[0]);
7544   [(set_attr "type" "dyncall")
7545    (set (attr "length")
7546         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 12)]
7547               (symbol_ref "pa_attr_length_indirect_call (insn)")))])
7549 (define_expand "call_value"
7550   [(parallel [(set (match_operand 0 "" "")
7551                    (call (match_operand:SI 1 "" "")
7552                          (match_operand 2 "" "")))
7553               (clobber (reg:SI 2))])]
7554   ""
7556   rtx op;
7557   rtx dst = operands[0];
7558   rtx nb = operands[2];
7559   bool call_powf = false;
7561   if (TARGET_PORTABLE_RUNTIME)
7562     op = force_reg (SImode, XEXP (operands[1], 0));
7563   else
7564     {
7565       op = XEXP (operands[1], 0);
7566       if (GET_CODE (op) == SYMBOL_REF)
7567         {
7568           /* Handle special call to buggy powf function.  */
7569           if (TARGET_HPUX && !TARGET_DISABLE_FPREGS && !TARGET_SOFT_FLOAT
7570               && !strcmp (targetm.strip_name_encoding (XSTR (op, 0)), "powf"))
7571             call_powf = true;
7573           /* Generate indirect long calls to non-local functions. */
7574           else if (TARGET_LONG_CALLS)
7575             {
7576               tree call_decl = SYMBOL_REF_DECL (op);
7577               if (!(call_decl && targetm.binds_local_p (call_decl)))
7578                 op = force_reg (word_mode, op);
7579             }
7580         }
7581     }
7583   if (TARGET_64BIT)
7584     {
7585       if (!virtuals_instantiated)
7586         emit_move_insn (arg_pointer_rtx,
7587                         gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
7588                                       GEN_INT (64)));
7589       else
7590         {
7591           /* The loop pass can generate new libcalls after the virtual
7592              registers are instantiated when fpregs are disabled because
7593              the only method that we have for doing DImode multiplication
7594              is with a libcall.  This could be trouble if we haven't
7595              allocated enough space for the outgoing arguments.  */
7596           gcc_assert (INTVAL (nb) <= crtl->outgoing_args_size);
7598           emit_move_insn (arg_pointer_rtx,
7599                           gen_rtx_PLUS (word_mode, stack_pointer_rtx,
7600                                         GEN_INT (STACK_POINTER_OFFSET + 64)));
7601         }
7602     }
7604   /* Use two different patterns for calls to explicitly named functions
7605      and calls through function pointers.  This is necessary as these two
7606      types of calls use different calling conventions, and CSE might try
7607      to change the named call into an indirect call in some cases (using
7608      two patterns keeps CSE from performing this optimization).
7610      We now use even more call patterns as there was a subtle bug in
7611      attempting to restore the pic register after a call using a simple
7612      move insn.  During reload, a instruction involving a pseudo register
7613      with no explicit dependence on the PIC register can be converted
7614      to an equivalent load from memory using the PIC register.  If we
7615      emit a simple move to restore the PIC register in the initial rtl
7616      generation, then it can potentially be repositioned during scheduling.
7617      and an instruction that eventually uses the PIC register may end up
7618      between the call and the PIC register restore.
7619      
7620      This only worked because there is a post call group of instructions
7621      that are scheduled with the call.  These instructions are included
7622      in the same basic block as the call.  However, calls can throw in
7623      C++ code and a basic block has to terminate at the call if the call
7624      can throw.  This results in the PIC register restore being scheduled
7625      independently from the call.  So, we now hide the save and restore
7626      of the PIC register in the call pattern until after reload.  Then,
7627      we split the moves out.  A small side benefit is that we now don't
7628      need to have a use of the PIC register in the return pattern and
7629      the final save/restore operation is not needed.
7630      
7631      I elected to just use register %r4 in the PIC patterns instead
7632      of trying to force hppa_pic_save_rtx () to a callee saved register.
7633      This might have required a new register class and constraint.  It
7634      was also simpler to just handle the restore from a register than a
7635      generic pseudo.  */
7636   if (TARGET_64BIT)
7637     {
7638       rtx r4 = gen_rtx_REG (word_mode, 4);
7639       if (GET_CODE (op) == SYMBOL_REF)
7640         {
7641           if (call_powf)
7642             emit_call_insn (gen_call_val_powf_64bit (dst, op, nb, r4));
7643           else
7644             emit_call_insn (gen_call_val_symref_64bit (dst, op, nb, r4));
7645         }
7646       else
7647         {
7648           op = force_reg (word_mode, op);
7649           emit_call_insn (gen_call_val_reg_64bit (dst, op, nb, r4));
7650         }
7651     }
7652   else
7653     {
7654       if (GET_CODE (op) == SYMBOL_REF)
7655         {
7656           if (flag_pic)
7657             {
7658               rtx r4 = gen_rtx_REG (word_mode, 4);
7660               if (call_powf)
7661                 emit_call_insn (gen_call_val_powf_pic (dst, op, nb, r4));
7662               else
7663                 emit_call_insn (gen_call_val_symref_pic (dst, op, nb, r4));
7664             }
7665           else
7666             {
7667               if (call_powf)
7668                 emit_call_insn (gen_call_val_powf (dst, op, nb));
7669               else
7670                 emit_call_insn (gen_call_val_symref (dst, op, nb));
7671             }
7672         }
7673       else
7674         {
7675           rtx tmpreg = gen_rtx_REG (word_mode, 22);
7676           emit_move_insn (tmpreg, force_reg (word_mode, op));
7677           if (flag_pic)
7678             {
7679               rtx r4 = gen_rtx_REG (word_mode, 4);
7680               emit_call_insn (gen_call_val_reg_pic (dst, nb, r4));
7681             }
7682           else
7683             emit_call_insn (gen_call_val_reg (dst, nb));
7684         }
7685     }
7687   DONE;
7690 (define_insn "call_val_symref"
7691   [(set (match_operand 0 "" "")
7692         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7693               (match_operand 2 "" "i")))
7694    (clobber (reg:SI 1))
7695    (clobber (reg:SI 2))
7696    (use (const_int 0))]
7697   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7698   "*
7700   pa_output_arg_descriptor (insn);
7701   return pa_output_call (insn, operands[1], 0);
7703   [(set_attr "type" "call")
7704    (set (attr "length")
7705         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7706               (symbol_ref "pa_attr_length_call (insn, 0)")))])
7708 ;; powf function clobbers %fr12
7709 (define_insn "call_val_powf"
7710   [(set (match_operand 0 "" "")
7711         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7712               (match_operand 2 "" "i")))
7713    (clobber (reg:SI 1))
7714    (clobber (reg:SI 2))
7715    (clobber (reg:DF 48))
7716    (use (const_int 1))]
7717   "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7718   "*
7720   pa_output_arg_descriptor (insn);
7721   return pa_output_call (insn, operands[1], 0);
7723   [(set_attr "type" "call")
7724    (set (attr "length")
7725         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7726               (symbol_ref "pa_attr_length_call (insn, 0)")))])
7728 (define_insn "call_val_symref_pic"
7729   [(set (match_operand 0 "" "")
7730         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7731               (match_operand 2 "" "i")))
7732    (clobber (reg:SI 1))
7733    (clobber (reg:SI 2))
7734    (clobber (match_operand 3))
7735    (use (reg:SI 19))
7736    (use (const_int 0))]
7737   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7738   "#")
7740 ;; Split out the PIC register save and restore after reload.  As the
7741 ;; split is done after reload, there are some situations in which we
7742 ;; unnecessarily save and restore %r4.  This happens when there is a
7743 ;; single call and the PIC register is not used after the call.
7745 ;; The split has to be done since call_from_call_insn () can't handle
7746 ;; the pattern as is.  Noreturn calls are special because they have to
7747 ;; terminate the basic block.  The split has to contain more than one
7748 ;; insn.
7749 (define_split
7750   [(parallel [(set (match_operand 0 "" "")
7751               (call (mem:SI (match_operand 1 "call_operand_address" ""))
7752                     (match_operand 2 "" "")))
7753               (clobber (reg:SI 1))
7754               (clobber (reg:SI 2))
7755               (clobber (match_operand 3))
7756               (use (reg:SI 19))
7757               (use (const_int 0))])]
7758   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed
7759    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7760   [(set (match_dup 3) (reg:SI 19))
7761    (parallel [(set (match_dup 0)
7762               (call (mem:SI (match_dup 1))
7763                     (match_dup 2)))
7764               (clobber (reg:SI 1))
7765               (clobber (reg:SI 2))
7766               (use (reg:SI 19))
7767               (use (const_int 0))])]
7768   "")
7770 (define_split
7771   [(parallel [(set (match_operand 0 "" "")
7772               (call (mem:SI (match_operand 1 "call_operand_address" ""))
7773                     (match_operand 2 "" "")))
7774               (clobber (reg:SI 1))
7775               (clobber (reg:SI 2))
7776               (clobber (match_operand 3))
7777               (use (reg:SI 19))
7778               (use (const_int 0))])]
7779   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
7780   [(set (match_dup 3) (reg:SI 19))
7781    (parallel [(set (match_dup 0)
7782               (call (mem:SI (match_dup 1))
7783                     (match_dup 2)))
7784               (clobber (reg:SI 1))
7785               (clobber (reg:SI 2))
7786               (use (reg:SI 19))
7787               (use (const_int 0))])
7788    (set (reg:SI 19) (match_dup 3))]
7789   "")
7791 (define_insn "*call_val_symref_pic_post_reload"
7792   [(set (match_operand 0 "" "")
7793         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7794               (match_operand 2 "" "i")))
7795    (clobber (reg:SI 1))
7796    (clobber (reg:SI 2))
7797    (use (reg:SI 19))
7798    (use (const_int 0))]
7799   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7800   "*
7802   pa_output_arg_descriptor (insn);
7803   return pa_output_call (insn, operands[1], 0);
7805   [(set_attr "type" "call")
7806    (set (attr "length")
7807         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7808               (symbol_ref "pa_attr_length_call (insn, 0)")))])
7810 ;; powf function clobbers %fr12
7811 (define_insn "call_val_powf_pic"
7812   [(set (match_operand 0 "" "")
7813         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7814               (match_operand 2 "" "i")))
7815    (clobber (reg:SI 1))
7816    (clobber (reg:SI 2))
7817    (clobber (reg:DF 48))
7818    (clobber (match_operand 3))
7819    (use (reg:SI 19))
7820    (use (const_int 1))]
7821   "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7822   "#")
7824 ;; Split out the PIC register save and restore after reload.  As the
7825 ;; split is done after reload, there are some situations in which we
7826 ;; unnecessarily save and restore %r4.  This happens when there is a
7827 ;; single call and the PIC register is not used after the call.
7829 ;; The split has to be done since call_from_call_insn () can't handle
7830 ;; the pattern as is.  Noreturn calls are special because they have to
7831 ;; terminate the basic block.  The split has to contain more than one
7832 ;; insn.
7833 (define_split
7834   [(parallel [(set (match_operand 0 "" "")
7835               (call (mem:SI (match_operand 1 "call_operand_address" ""))
7836                     (match_operand 2 "" "")))
7837               (clobber (reg:SI 1))
7838               (clobber (reg:SI 2))
7839               (clobber (reg:DF 48))
7840               (clobber (match_operand 3))
7841               (use (reg:SI 19))
7842               (use (const_int 1))])]
7843   "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed
7844    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7845   [(set (match_dup 3) (reg:SI 19))
7846    (parallel [(set (match_dup 0)
7847               (call (mem:SI (match_dup 1))
7848                     (match_dup 2)))
7849               (clobber (reg:SI 1))
7850               (clobber (reg:SI 2))
7851               (clobber (reg:DF 48))
7852               (use (reg:SI 19))
7853               (use (const_int 1))])]
7854   "")
7856 (define_split
7857   [(parallel [(set (match_operand 0 "" "")
7858               (call (mem:SI (match_operand 1 "call_operand_address" ""))
7859                     (match_operand 2 "" "")))
7860               (clobber (reg:SI 1))
7861               (clobber (reg:SI 2))
7862               (clobber (reg:DF 48))
7863               (clobber (match_operand 3))
7864               (use (reg:SI 19))
7865               (use (const_int 1))])]
7866   "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
7867   [(set (match_dup 3) (reg:SI 19))
7868    (parallel [(set (match_dup 0)
7869               (call (mem:SI (match_dup 1))
7870                     (match_dup 2)))
7871               (clobber (reg:SI 1))
7872               (clobber (reg:SI 2))
7873               (clobber (reg:DF 48))
7874               (use (reg:SI 19))
7875               (use (const_int 1))])
7876    (set (reg:SI 19) (match_dup 3))]
7877   "")
7879 (define_insn "*call_val_powf_pic_post_reload"
7880   [(set (match_operand 0 "" "")
7881         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7882               (match_operand 2 "" "i")))
7883    (clobber (reg:SI 1))
7884    (clobber (reg:SI 2))
7885    (clobber (reg:DF 48))
7886    (use (reg:SI 19))
7887    (use (const_int 1))]
7888   "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7889   "*
7891   pa_output_arg_descriptor (insn);
7892   return pa_output_call (insn, operands[1], 0);
7894   [(set_attr "type" "call")
7895    (set (attr "length")
7896         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7897               (symbol_ref "pa_attr_length_call (insn, 0)")))])
7899 ;; This pattern is split if it is necessary to save and restore the
7900 ;; PIC register.
7901 (define_insn "call_val_symref_64bit"
7902   [(set (match_operand 0 "" "")
7903         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7904               (match_operand 2 "" "i")))
7905    (clobber (reg:DI 1))
7906    (clobber (reg:DI 2))
7907    (clobber (match_operand 3))
7908    (use (reg:DI 27))
7909    (use (reg:DI 29))
7910    (use (const_int 0))]
7911   "TARGET_64BIT"
7912   "#")
7914 ;; Split out the PIC register save and restore after reload.  As the
7915 ;; split is done after reload, there are some situations in which we
7916 ;; unnecessarily save and restore %r4.  This happens when there is a
7917 ;; single call and the PIC register is not used after the call.
7919 ;; The split has to be done since call_from_call_insn () can't handle
7920 ;; the pattern as is.  Noreturn calls are special because they have to
7921 ;; terminate the basic block.  The split has to contain more than one
7922 ;; insn.
7923 (define_split
7924   [(parallel [(set (match_operand 0 "" "")
7925               (call (mem:SI (match_operand 1 "call_operand_address" ""))
7926                     (match_operand 2 "" "")))
7927               (clobber (reg:DI 1))
7928               (clobber (reg:DI 2))
7929               (clobber (match_operand 3))
7930               (use (reg:DI 27))
7931               (use (reg:DI 29))
7932               (use (const_int 0))])]
7933   "TARGET_64BIT && reload_completed
7934    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7935   [(set (match_dup 3) (reg:DI 27))
7936    (parallel [(set (match_dup 0)
7937               (call (mem:SI (match_dup 1))
7938                     (match_dup 2)))
7939               (clobber (reg:DI 1))
7940               (clobber (reg:DI 2))
7941               (use (reg:DI 27))
7942               (use (reg:DI 29))
7943               (use (const_int 0))])]
7944   "")
7946 (define_split
7947   [(parallel [(set (match_operand 0 "" "")
7948               (call (mem:SI (match_operand 1 "call_operand_address" ""))
7949                     (match_operand 2 "" "")))
7950               (clobber (reg:DI 1))
7951               (clobber (reg:DI 2))
7952               (clobber (match_operand 3))
7953               (use (reg:DI 27))
7954               (use (reg:DI 29))
7955               (use (const_int 0))])]
7956   "TARGET_64BIT && reload_completed"
7957   [(set (match_dup 3) (reg:DI 27))
7958    (parallel [(set (match_dup 0)
7959               (call (mem:SI (match_dup 1))
7960                     (match_dup 2)))
7961               (clobber (reg:DI 1))
7962               (clobber (reg:DI 2))
7963               (use (reg:DI 27))
7964               (use (reg:DI 29))
7965               (use (const_int 0))])
7966    (set (reg:DI 27) (match_dup 3))]
7967   "")
7969 (define_insn "*call_val_symref_64bit_post_reload"
7970   [(set (match_operand 0 "" "")
7971         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7972               (match_operand 2 "" "i")))
7973    (clobber (reg:DI 1))
7974    (clobber (reg:DI 2))
7975    (use (reg:DI 27))
7976    (use (reg:DI 29))
7977    (use (const_int 0))]
7978   "TARGET_64BIT"
7979   "*
7981   return pa_output_call (insn, operands[1], 0);
7983   [(set_attr "type" "call")
7984    (set (attr "length")
7985         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7986               (symbol_ref "pa_attr_length_call (insn, 0)")))])
7988 ;; powf function clobbers %fr12
7989 (define_insn "call_val_powf_64bit"
7990   [(set (match_operand 0 "" "")
7991         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7992               (match_operand 2 "" "i")))
7993    (clobber (reg:DI 1))
7994    (clobber (reg:DI 2))
7995    (clobber (reg:DF 40))
7996    (clobber (match_operand 3))
7997    (use (reg:DI 27))
7998    (use (reg:DI 29))
7999    (use (const_int 1))]
8000   "TARGET_64BIT && TARGET_HPUX"
8001   "#")
8003 ;; Split out the PIC register save and restore after reload.  As the
8004 ;; split is done after reload, there are some situations in which we
8005 ;; unnecessarily save and restore %r4.  This happens when there is a
8006 ;; single call and the PIC register is not used after the call.
8008 ;; The split has to be done since call_from_call_insn () can't handle
8009 ;; the pattern as is.  Noreturn calls are special because they have to
8010 ;; terminate the basic block.  The split has to contain more than one
8011 ;; insn.
8012 (define_split
8013   [(parallel [(set (match_operand 0 "" "")
8014               (call (mem:SI (match_operand 1 "call_operand_address" ""))
8015                     (match_operand 2 "" "")))
8016               (clobber (reg:DI 1))
8017               (clobber (reg:DI 2))
8018               (clobber (reg:DF 40))
8019               (clobber (match_operand 3))
8020               (use (reg:DI 27))
8021               (use (reg:DI 29))
8022               (use (const_int 1))])]
8023   "TARGET_64BIT && TARGET_HPUX && reload_completed
8024    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8025   [(set (match_dup 3) (reg:DI 27))
8026    (parallel [(set (match_dup 0)
8027               (call (mem:SI (match_dup 1))
8028                     (match_dup 2)))
8029               (clobber (reg:DI 1))
8030               (clobber (reg:DI 2))
8031               (clobber (reg:DF 40))
8032               (use (reg:DI 27))
8033               (use (reg:DI 29))
8034               (use (const_int 1))])]
8035   "")
8037 (define_split
8038   [(parallel [(set (match_operand 0 "" "")
8039               (call (mem:SI (match_operand 1 "call_operand_address" ""))
8040                     (match_operand 2 "" "")))
8041               (clobber (reg:DI 1))
8042               (clobber (reg:DI 2))
8043               (clobber (reg:DF 40))
8044               (clobber (match_operand 3))
8045               (use (reg:DI 27))
8046               (use (reg:DI 29))
8047               (use (const_int 1))])]
8048   "TARGET_64BIT && TARGET_HPUX && reload_completed"
8049   [(set (match_dup 3) (reg:DI 27))
8050    (parallel [(set (match_dup 0)
8051               (call (mem:SI (match_dup 1))
8052                     (match_dup 2)))
8053               (clobber (reg:DI 1))
8054               (clobber (reg:DI 2))
8055               (clobber (reg:DF 40))
8056               (use (reg:DI 27))
8057               (use (reg:DI 29))
8058               (use (const_int 1))])
8059    (set (reg:DI 27) (match_dup 3))]
8060   "")
8062 (define_insn "*call_val_powf_64bit_post_reload"
8063   [(set (match_operand 0 "" "")
8064         (call (mem:SI (match_operand 1 "call_operand_address" ""))
8065               (match_operand 2 "" "i")))
8066    (clobber (reg:DI 1))
8067    (clobber (reg:DI 2))
8068    (clobber (reg:DF 40))
8069    (use (reg:DI 27))
8070    (use (reg:DI 29))
8071    (use (const_int 1))]
8072   "TARGET_64BIT && TARGET_HPUX"
8073   "*
8075   return pa_output_call (insn, operands[1], 0);
8077   [(set_attr "type" "call")
8078    (set (attr "length")
8079         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8080               (symbol_ref "pa_attr_length_call (insn, 0)")))])
8082 (define_insn "call_val_reg"
8083   [(set (match_operand 0 "" "")
8084         (call (mem:SI (reg:SI 22))
8085               (match_operand 1 "" "i")))
8086    (clobber (reg:SI 1))
8087    (clobber (reg:SI 2))
8088    (use (const_int 1))]
8089   "!TARGET_64BIT"
8090   "*
8092   return pa_output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
8094   [(set_attr "type" "dyncall")
8095    (set (attr "length")
8096         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8097               (symbol_ref "pa_attr_length_indirect_call (insn)")))])
8099 ;; This pattern is split if it is necessary to save and restore the
8100 ;; PIC register.
8101 (define_insn "call_val_reg_pic"
8102   [(set (match_operand 0 "" "")
8103         (call (mem:SI (reg:SI 22))
8104               (match_operand 1 "" "i")))
8105    (clobber (reg:SI 1))
8106    (clobber (reg:SI 2))
8107    (clobber (match_operand 2))
8108    (use (reg:SI 19))
8109    (use (const_int 1))]
8110   "!TARGET_64BIT"
8111   "#")
8113 ;; Split out the PIC register save and restore after reload.  As the
8114 ;; split is done after reload, there are some situations in which we
8115 ;; unnecessarily save and restore %r4.  This happens when there is a
8116 ;; single call and the PIC register is not used after the call.
8118 ;; The split has to be done since call_from_call_insn () can't handle
8119 ;; the pattern as is.  Noreturn calls are special because they have to
8120 ;; terminate the basic block.  The split has to contain more than one
8121 ;; insn.
8122 (define_split
8123   [(parallel [(set (match_operand 0 "" "")
8124                    (call (mem:SI (reg:SI 22))
8125                          (match_operand 1 "" "")))
8126               (clobber (reg:SI 1))
8127               (clobber (reg:SI 2))
8128               (clobber (match_operand 2))
8129               (use (reg:SI 19))
8130               (use (const_int 1))])]
8131   "!TARGET_64BIT && reload_completed
8132    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8133   [(set (match_dup 2) (reg:SI 19))
8134    (parallel [(set (match_dup 0)
8135                    (call (mem:SI (reg:SI 22))
8136                          (match_dup 1)))
8137               (clobber (reg:SI 1))
8138               (clobber (reg:SI 2))
8139               (use (reg:SI 19))
8140               (use (const_int 1))])]
8141   "")
8143 (define_split
8144   [(parallel [(set (match_operand 0 "" "")
8145                    (call (mem:SI (reg:SI 22))
8146                          (match_operand 1 "" "")))
8147               (clobber (reg:SI 1))
8148               (clobber (reg:SI 2))
8149               (clobber (match_operand 2))
8150               (use (reg:SI 19))
8151               (use (const_int 1))])]
8152   "!TARGET_64BIT && reload_completed"
8153   [(set (match_dup 2) (reg:SI 19))
8154    (parallel [(set (match_dup 0)
8155                    (call (mem:SI (reg:SI 22))
8156                          (match_dup 1)))
8157               (clobber (reg:SI 1))
8158               (clobber (reg:SI 2))
8159               (use (reg:SI 19))
8160               (use (const_int 1))])
8161    (set (reg:SI 19) (match_dup 2))]
8162   "")
8164 (define_insn "*call_val_reg_pic_post_reload"
8165   [(set (match_operand 0 "" "")
8166         (call (mem:SI (reg:SI 22))
8167               (match_operand 1 "" "i")))
8168    (clobber (reg:SI 1))
8169    (clobber (reg:SI 2))
8170    (use (reg:SI 19))
8171    (use (const_int 1))]
8172   "!TARGET_64BIT"
8173   "*
8175   return pa_output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
8177   [(set_attr "type" "dyncall")
8178    (set (attr "length")
8179         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8180               (symbol_ref "pa_attr_length_indirect_call (insn)")))])
8182 ;; This pattern is split if it is necessary to save and restore the
8183 ;; PIC register.
8184 (define_insn "call_val_reg_64bit"
8185   [(set (match_operand 0 "" "")
8186         (call (mem:SI (match_operand:DI 1 "register_operand" "r"))
8187               (match_operand 2 "" "i")))
8188    (clobber (reg:DI 2))
8189    (clobber (match_operand 3))
8190    (use (reg:DI 27))
8191    (use (reg:DI 29))
8192    (use (const_int 1))]
8193   "TARGET_64BIT"
8194   "#")
8196 ;; Split out the PIC register save and restore after reload.  As the
8197 ;; split is done after reload, there are some situations in which we
8198 ;; unnecessarily save and restore %r4.  This happens when there is a
8199 ;; single call and the PIC register is not used after the call.
8201 ;; The split has to be done since call_from_call_insn () can't handle
8202 ;; the pattern as is.  Noreturn calls are special because they have to
8203 ;; terminate the basic block.  The split has to contain more than one
8204 ;; insn.
8205 (define_split
8206   [(parallel [(set (match_operand 0 "" "")
8207                    (call (mem:SI (match_operand:DI 1 "register_operand" ""))
8208                          (match_operand 2 "" "")))
8209               (clobber (reg:DI 2))
8210               (clobber (match_operand 3))
8211               (use (reg:DI 27))
8212               (use (reg:DI 29))
8213               (use (const_int 1))])]
8214   "TARGET_64BIT && reload_completed
8215    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8216   [(set (match_dup 3) (reg:DI 27))
8217    (parallel [(set (match_dup 0)
8218                    (call (mem:SI (match_dup 1))
8219                          (match_dup 2)))
8220               (clobber (reg:DI 2))
8221               (use (reg:DI 27))
8222               (use (reg:DI 29))
8223               (use (const_int 1))])]
8224   "")
8226 (define_split
8227   [(parallel [(set (match_operand 0 "" "")
8228                    (call (mem:SI (match_operand:DI 1 "register_operand" ""))
8229                          (match_operand 2 "" "")))
8230               (clobber (reg:DI 2))
8231               (clobber (match_operand 3))
8232               (use (reg:DI 27))
8233               (use (reg:DI 29))
8234               (use (const_int 1))])]
8235   "TARGET_64BIT && reload_completed"
8236   [(set (match_dup 3) (reg:DI 27))
8237    (parallel [(set (match_dup 0)
8238                    (call (mem:SI (match_dup 1))
8239                          (match_dup 2)))
8240               (clobber (reg:DI 2))
8241               (use (reg:DI 27))
8242               (use (reg:DI 29))
8243               (use (const_int 1))])
8244    (set (reg:DI 27) (match_dup 3))]
8245   "")
8247 (define_insn "*call_val_reg_64bit_post_reload"
8248   [(set (match_operand 0 "" "")
8249         (call (mem:SI (match_operand:DI 1 "register_operand" "r"))
8250               (match_operand 2 "" "i")))
8251    (clobber (reg:DI 2))
8252    (use (reg:DI 27))
8253    (use (reg:DI 29))
8254    (use (const_int 1))]
8255   "TARGET_64BIT"
8256   "*
8258   return pa_output_indirect_call (insn, operands[1]);
8260   [(set_attr "type" "dyncall")
8261    (set (attr "length")
8262         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 12)]
8263               (symbol_ref "pa_attr_length_indirect_call (insn)")))])
8265 /* Expand special pc-relative call to _mcount.  */
8267 (define_expand "call_mcount"
8268   [(parallel [(call (match_operand:SI 0 "" "")
8269                     (match_operand 1 "" ""))
8270               (set (reg:SI 25)
8271                    (plus:SI (reg:SI 2)
8272                             (minus:SI (match_operand 2 "" "")
8273                                       (plus:SI (pc) (const_int 4)))))
8274               (clobber (reg:SI 2))])]
8275   "!TARGET_PORTABLE_RUNTIME"
8276   "
8278   rtx op = XEXP (operands[0], 0);
8279   rtx nb = operands[1];
8280   rtx lab = operands[2];
8282   if (TARGET_64BIT)
8283     {
8284       rtx r4 = gen_rtx_REG (word_mode, 4);
8285       emit_move_insn (arg_pointer_rtx,
8286                       gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
8287                                     GEN_INT (64)));
8288       emit_call_insn (gen_call_mcount_64bit (op, nb, lab, r4));
8289     }
8290   else
8291     {
8292       if (flag_pic)
8293         {
8294           rtx r4 = gen_rtx_REG (word_mode, 4);
8295           emit_call_insn (gen_call_mcount_pic (op, nb, lab, r4));
8296         }
8297       else
8298         emit_call_insn (gen_call_mcount_nonpic (op, nb, lab));
8299     }
8301   DONE;
8304 (define_insn "call_mcount_nonpic"
8305   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8306          (match_operand 1 "" "i"))
8307    (set (reg:SI 25)
8308         (plus:SI (reg:SI 2)
8309                  (minus:SI (match_operand 2 "" "")
8310                            (plus:SI (pc) (const_int 4)))))
8311    (clobber (reg:SI 2))]
8312   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8313   "*
8315   pa_output_arg_descriptor (insn);
8316   return \"{bl|b,l} %0,%%r2\;ldo %2-.-4(%%r2),%%r25\";
8318   [(set_attr "type" "multi")
8319    (set_attr "length" "8")])
8321 (define_insn "call_mcount_pic"
8322   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8323          (match_operand 1 "" "i"))
8324    (set (reg:SI 25)
8325         (plus:SI (reg:SI 2)
8326                  (minus:SI (match_operand 2 "" "")
8327                            (plus:SI (pc) (const_int 4)))))
8328    (clobber (reg:SI 2))
8329    (clobber (match_operand 3))
8330    (use (reg:SI 19))]
8331   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8332   "#")
8334 (define_split
8335   [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8336                     (match_operand 1 "" ""))
8337               (set (reg:SI 25)
8338                    (plus:SI (reg:SI 2)
8339                             (minus:SI (match_operand 2 "" "")
8340                                       (plus:SI (pc) (const_int 4)))))
8341               (clobber (reg:SI 2))
8342               (clobber (match_operand 3))
8343               (use (reg:SI 19))])]
8344   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
8345   [(set (match_dup 3) (reg:SI 19))
8346    (parallel [(call (mem:SI (match_dup 0))
8347                     (match_dup 1))
8348               (set (reg:SI 25)
8349                    (plus:SI (reg:SI 2)
8350                             (minus:SI (match_dup 2)
8351                                       (plus:SI (pc) (const_int 4)))))
8352               (clobber (reg:SI 2))
8353               (use (reg:SI 19))])
8354    (set (reg:SI 19) (match_dup 3))]
8355   "")
8357 (define_insn "*call_mcount_pic_post_reload"
8358   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8359          (match_operand 1 "" "i"))
8360    (set (reg:SI 25)
8361         (plus:SI (reg:SI 2)
8362                  (minus:SI (match_operand 2 "" "")
8363                            (plus:SI (pc) (const_int 4)))))
8364    (clobber (reg:SI 2))
8365    (use (reg:SI 19))]
8366   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8367   "*
8369   pa_output_arg_descriptor (insn);
8370   return \"{bl|b,l} %0,%%r2\;ldo %2-.-4(%%r2),%%r25\";
8372   [(set_attr "type" "multi")
8373    (set_attr "length" "8")])
8375 (define_insn "call_mcount_64bit"
8376   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8377          (match_operand 1 "" "i"))
8378    (set (reg:SI 25)
8379         (plus:SI (reg:SI 2)
8380                  (minus:SI (match_operand 2 "" "")
8381                            (plus:SI (pc) (const_int 4)))))
8382    (clobber (reg:DI 2))
8383    (clobber (match_operand 3))
8384    (use (reg:DI 27))
8385    (use (reg:DI 29))]
8386   "TARGET_64BIT"
8387   "#")
8389 (define_split
8390   [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8391                     (match_operand 1 "" ""))
8392               (set (reg:SI 25)
8393                    (plus:SI (reg:SI 2)
8394                             (minus:SI (match_operand 2 "" "")
8395                                       (plus:SI (pc) (const_int 4)))))
8396               (clobber (reg:DI 2))
8397               (clobber (match_operand 3))
8398               (use (reg:DI 27))
8399               (use (reg:DI 29))])]
8400   "TARGET_64BIT && reload_completed"
8401   [(set (match_dup 3) (reg:DI 27))
8402    (parallel [(call (mem:SI (match_dup 0))
8403                     (match_dup 1))
8404               (set (reg:SI 25)
8405                    (plus:SI (reg:SI 2)
8406                             (minus:SI (match_dup 2)
8407                                       (plus:SI (pc) (const_int 4)))))
8408               (clobber (reg:DI 2))
8409               (use (reg:DI 27))
8410               (use (reg:DI 29))])
8411    (set (reg:DI 27) (match_dup 3))]
8412   "")
8414 (define_insn "*call_mcount_64bit_post_reload"
8415   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8416          (match_operand 1 "" "i"))
8417    (set (reg:SI 25)
8418         (plus:SI (reg:SI 2)
8419                  (minus:SI (match_operand 2 "" "")
8420                            (plus:SI (pc) (const_int 4)))))
8421    (clobber (reg:DI 2))
8422    (use (reg:DI 27))
8423    (use (reg:DI 29))]
8424   "TARGET_64BIT"
8425   "{bl|b,l} %0,%%r2\;ldo %2-.-4(%%r2),%%r25"
8426   [(set_attr "type" "multi")
8427    (set_attr "length" "8")])
8429 ;; Call subroutine returning any type.
8431 (define_expand "untyped_call"
8432   [(parallel [(call (match_operand 0 "" "")
8433                     (const_int 0))
8434               (match_operand 1 "" "")
8435               (match_operand 2 "" "")])]
8436   ""
8437   "
8439   int i;
8441   emit_call_insn (gen_call (operands[0], const0_rtx));
8443   for (i = 0; i < XVECLEN (operands[2], 0); i++)
8444     {
8445       rtx set = XVECEXP (operands[2], 0, i);
8446       emit_move_insn (SET_DEST (set), SET_SRC (set));
8447     }
8449   /* The optimizer does not know that the call sets the function value
8450      registers we stored in the result block.  We avoid problems by
8451      claiming that all hard registers are used and clobbered at this
8452      point.  */
8453   emit_insn (gen_blockage ());
8455   DONE;
8458 (define_expand "sibcall"
8459   [(call (match_operand:SI 0 "" "")
8460          (match_operand 1 "" ""))]
8461   "!TARGET_PORTABLE_RUNTIME"
8462   "
8464   rtx op, call_insn;
8465   rtx nb = operands[1];
8467   op = XEXP (operands[0], 0);
8469   if (TARGET_64BIT)
8470     {
8471       if (!virtuals_instantiated)
8472         emit_move_insn (arg_pointer_rtx,
8473                         gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
8474                                       GEN_INT (64)));
8475       else
8476         {
8477           /* The loop pass can generate new libcalls after the virtual
8478              registers are instantiated when fpregs are disabled because
8479              the only method that we have for doing DImode multiplication
8480              is with a libcall.  This could be trouble if we haven't
8481              allocated enough space for the outgoing arguments.  */
8482           gcc_assert (INTVAL (nb) <= crtl->outgoing_args_size);
8484           emit_move_insn (arg_pointer_rtx,
8485                           gen_rtx_PLUS (word_mode, stack_pointer_rtx,
8486                                         GEN_INT (STACK_POINTER_OFFSET + 64)));
8487         }
8488     }
8490   /* Indirect sibling calls are not allowed.  */
8491   if (TARGET_64BIT)
8492     call_insn = gen_sibcall_internal_symref_64bit (op, operands[1]);
8493   else
8494     call_insn = gen_sibcall_internal_symref (op, operands[1]);
8496   call_insn = emit_call_insn (call_insn);
8498   if (TARGET_64BIT)
8499     use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), arg_pointer_rtx);
8501   /* We don't have to restore the PIC register.  */
8502   if (flag_pic)
8503     use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
8505   DONE;
8508 (define_insn "sibcall_internal_symref"
8509   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8510          (match_operand 1 "" "i"))
8511    (clobber (reg:SI 1))
8512    (use (reg:SI 2))
8513    (use (const_int 0))]
8514   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8515   "*
8517   pa_output_arg_descriptor (insn);
8518   return pa_output_call (insn, operands[0], 1);
8520   [(set_attr "type" "sibcall")
8521    (set (attr "length")
8522         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8523               (symbol_ref "pa_attr_length_call (insn, 1)")))])
8525 (define_insn "sibcall_internal_symref_64bit"
8526   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8527          (match_operand 1 "" "i"))
8528    (clobber (reg:DI 1))
8529    (use (reg:DI 2))
8530    (use (const_int 0))]
8531   "TARGET_64BIT"
8532   "*
8534   return pa_output_call (insn, operands[0], 1);
8536   [(set_attr "type" "sibcall")
8537    (set (attr "length")
8538         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8539               (symbol_ref "pa_attr_length_call (insn, 1)")))])
8541 (define_expand "sibcall_value"
8542   [(set (match_operand 0 "" "")
8543                    (call (match_operand:SI 1 "" "")
8544                          (match_operand 2 "" "")))]
8545   "!TARGET_PORTABLE_RUNTIME"
8546   "
8548   rtx op, call_insn;
8549   rtx nb = operands[1];
8551   op = XEXP (operands[1], 0);
8553   if (TARGET_64BIT)
8554     {
8555       if (!virtuals_instantiated)
8556         emit_move_insn (arg_pointer_rtx,
8557                         gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
8558                                       GEN_INT (64)));
8559       else
8560         {
8561           /* The loop pass can generate new libcalls after the virtual
8562              registers are instantiated when fpregs are disabled because
8563              the only method that we have for doing DImode multiplication
8564              is with a libcall.  This could be trouble if we haven't
8565              allocated enough space for the outgoing arguments.  */
8566           gcc_assert (INTVAL (nb) <= crtl->outgoing_args_size);
8568           emit_move_insn (arg_pointer_rtx,
8569                           gen_rtx_PLUS (word_mode, stack_pointer_rtx,
8570                                         GEN_INT (STACK_POINTER_OFFSET + 64)));
8571         }
8572     }
8574   /* Indirect sibling calls are not allowed.  */
8575   if (TARGET_64BIT)
8576     call_insn
8577       = gen_sibcall_value_internal_symref_64bit (operands[0], op, operands[2]);
8578   else
8579     call_insn
8580       = gen_sibcall_value_internal_symref (operands[0], op, operands[2]);
8582   call_insn = emit_call_insn (call_insn);
8584   if (TARGET_64BIT)
8585     use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), arg_pointer_rtx);
8587   /* We don't have to restore the PIC register.  */
8588   if (flag_pic)
8589     use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
8591   DONE;
8594 (define_insn "sibcall_value_internal_symref"
8595   [(set (match_operand 0 "" "")
8596         (call (mem:SI (match_operand 1 "call_operand_address" ""))
8597               (match_operand 2 "" "i")))
8598    (clobber (reg:SI 1))
8599    (use (reg:SI 2))
8600    (use (const_int 0))]
8601   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8602   "*
8604   pa_output_arg_descriptor (insn);
8605   return pa_output_call (insn, operands[1], 1);
8607   [(set_attr "type" "sibcall")
8608    (set (attr "length")
8609         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8610               (symbol_ref "pa_attr_length_call (insn, 1)")))])
8612 (define_insn "sibcall_value_internal_symref_64bit"
8613   [(set (match_operand 0 "" "")
8614         (call (mem:SI (match_operand 1 "call_operand_address" ""))
8615               (match_operand 2 "" "i")))
8616    (clobber (reg:DI 1))
8617    (use (reg:DI 2))
8618    (use (const_int 0))]
8619   "TARGET_64BIT"
8620   "*
8622   return pa_output_call (insn, operands[1], 1);
8624   [(set_attr "type" "sibcall")
8625    (set (attr "length")
8626         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8627               (symbol_ref "pa_attr_length_call (insn, 1)")))])
8629 (define_insn "nop"
8630   [(const_int 0)]
8631   ""
8632   "nop"
8633   [(set_attr "type" "move")
8634    (set_attr "length" "4")])
8636 ;;; EH does longjmp's from and within the data section.  Thus,
8637 ;;; an interspace branch is required for the longjmp implementation.
8638 ;;; Registers r1 and r2 are used as scratch registers for the jump
8639 ;;; when necessary.
8640 (define_expand "interspace_jump"
8641   [(parallel
8642      [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8643       (clobber (match_dup 1))])]
8644   ""
8645   "
8647   operands[1] = gen_rtx_REG (word_mode, 2);
8650 (define_insn ""
8651   [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8652   (clobber (reg:SI 2))]
8653   "TARGET_PA_20 && !TARGET_64BIT"
8654   "bve%* (%0)"
8655    [(set_attr "type" "branch")
8656     (set_attr "length" "4")])
8658 (define_insn ""
8659   [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8660   (clobber (reg:SI 2))]
8661   "TARGET_NO_SPACE_REGS && !TARGET_64BIT"
8662   "be%* 0(%%sr4,%0)"
8663    [(set_attr "type" "branch")
8664     (set_attr "length" "4")])
8666 (define_insn ""
8667   [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8668   (clobber (reg:SI 2))]
8669   "!TARGET_64BIT"
8670   "ldsid (%%sr0,%0),%%r2\;mtsp %%r2,%%sr0\;be%* 0(%%sr0,%0)"
8671    [(set_attr "type" "branch")
8672     (set_attr "length" "12")])
8674 (define_insn ""
8675   [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8676   (clobber (reg:DI 2))]
8677   "TARGET_64BIT"
8678   "bve%* (%0)"
8679    [(set_attr "type" "branch")
8680     (set_attr "length" "4")])
8682 (define_expand "builtin_longjmp"
8683   [(unspec_volatile [(match_operand 0 "register_operand" "r")] UNSPECV_LONGJMP)]
8684   ""
8685   "
8687   /* The elements of the buffer are, in order:  */
8688   rtx fp = gen_rtx_MEM (Pmode, operands[0]);
8689   rtx lab = gen_rtx_MEM (Pmode, plus_constant (Pmode, operands[0],
8690                          POINTER_SIZE / BITS_PER_UNIT));
8691   rtx stack = gen_rtx_MEM (Pmode, plus_constant (Pmode, operands[0],
8692                            (POINTER_SIZE * 2) / BITS_PER_UNIT));
8693   rtx pv = gen_rtx_REG (Pmode, 1);
8695   emit_clobber (gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (VOIDmode)));
8696   emit_clobber (gen_rtx_MEM (BLKmode, hard_frame_pointer_rtx));
8698   /* Load the label we are jumping through into r1 so that we know
8699      where to look for it when we get back to setjmp's function for
8700      restoring the gp.  */
8701   emit_move_insn (pv, lab);
8703   /* Restore the stack and frame pointers.  */
8704   fp = copy_to_reg (fp);
8705   emit_stack_restore (SAVE_NONLOCAL, stack);
8707   /* Ensure the frame pointer move is not optimized.  */
8708   emit_insn (gen_blockage ());
8709   emit_clobber (hard_frame_pointer_rtx);
8710   emit_clobber (frame_pointer_rtx);
8711   emit_move_insn (hard_frame_pointer_rtx, fp);
8713   emit_use (hard_frame_pointer_rtx);
8714   emit_use (stack_pointer_rtx);
8716   /* Prevent the insns above from being scheduled into the delay slot
8717      of the interspace jump because the space register could change.  */
8718   emit_insn (gen_blockage ());
8720   emit_jump_insn (gen_interspace_jump (pv));
8721   emit_barrier ();
8722   DONE;
8725 ;;; Operands 2 and 3 are assumed to be CONST_INTs.
8726 (define_expand "extzvsi"
8727   [(set (match_operand:SI 0 "register_operand" "")
8728         (zero_extract:SI (match_operand:SI 1 "register_operand" "")
8729                          (match_operand:SI 2 "uint5_operand" "")
8730                          (match_operand:SI 3 "uint5_operand" "")))]
8731   ""
8732   "
8734   unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
8735   unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
8737   /* PA extraction insns don't support zero length bitfields or fields
8738      extending beyond the left or right-most bits.  Also, the predicate
8739      rejects lengths equal to a word as they are better handled by
8740      the move patterns.  */
8741   if (len == 0 || pos + len > 32)
8742     FAIL;
8744   /* From mips.md: extract_bit_field doesn't verify that our source
8745      matches the predicate, so check it again here.  */
8746   if (!register_operand (operands[1], VOIDmode))
8747     FAIL;
8749   emit_insn (gen_extzv_32 (operands[0], operands[1],
8750                            operands[2], operands[3]));
8751   DONE;
8754 (define_insn "extzv_32"
8755   [(set (match_operand:SI 0 "register_operand" "=r")
8756         (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
8757                          (match_operand:SI 2 "uint5_operand" "")
8758                          (match_operand:SI 3 "uint5_operand" "")))]
8759   "UINTVAL (operands[2]) > 0
8760    && UINTVAL (operands[2]) + UINTVAL (operands[3]) <= 32"
8761   "{extru|extrw,u} %1,%3+%2-1,%2,%0"
8762   [(set_attr "type" "shift")
8763    (set_attr "length" "4")])
8765 (define_insn ""
8766   [(set (match_operand:SI 0 "register_operand" "=r")
8767         (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
8768                          (const_int 1)
8769                          (match_operand:SI 2 "register_operand" "q")))]
8770   ""
8771   "{vextru %1,1,%0|extrw,u %1,%%sar,1,%0}"
8772   [(set_attr "type" "shift")
8773    (set_attr "length" "4")])
8775 (define_expand "extzvdi"
8776   [(set (match_operand:DI 0 "register_operand" "")
8777         (zero_extract:DI (match_operand:DI 1 "register_operand" "")
8778                          (match_operand:DI 2 "uint6_operand" "")
8779                          (match_operand:DI 3 "uint6_operand" "")))]
8780   "TARGET_64BIT"
8781   "
8783   unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
8784   unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
8786   /* PA extraction insns don't support zero length bitfields or fields
8787      extending beyond the left or right-most bits.  Also, the predicate
8788      rejects lengths equal to a doubleword as they are better handled by
8789      the move patterns.  */
8790   if (len == 0 || pos + len > 64)
8791     FAIL;
8793   /* From mips.md: extract_bit_field doesn't verify that our source
8794      matches the predicate, so check it again here.  */
8795   if (!register_operand (operands[1], VOIDmode))
8796     FAIL;
8798   emit_insn (gen_extzv_64 (operands[0], operands[1],
8799                            operands[2], operands[3]));
8800   DONE;
8803 (define_insn "extzv_64"
8804   [(set (match_operand:DI 0 "register_operand" "=r")
8805         (zero_extract:DI (match_operand:DI 1 "register_operand" "r")
8806                          (match_operand:DI 2 "uint6_operand" "")
8807                          (match_operand:DI 3 "uint6_operand" "")))]
8808   "TARGET_64BIT
8809    && UINTVAL (operands[2]) > 0
8810    && UINTVAL (operands[2]) + UINTVAL (operands[3]) <= 64"
8811   "extrd,u %1,%3+%2-1,%2,%0"
8812   [(set_attr "type" "shift")
8813    (set_attr "length" "4")])
8815 (define_insn ""
8816   [(set (match_operand:DI 0 "register_operand" "=r")
8817         (zero_extract:DI (match_operand:DI 1 "register_operand" "r")
8818                          (const_int 1)
8819                          (match_operand:DI 2 "register_operand" "q")))]
8820   "TARGET_64BIT"
8821   "extrd,u %1,%%sar,1,%0"
8822   [(set_attr "type" "shift")
8823    (set_attr "length" "4")])
8825 ;;; Operands 2 and 3 are assumed to be CONST_INTs.
8826 (define_expand "extvsi"
8827   [(set (match_operand:SI 0 "register_operand" "")
8828         (sign_extract:SI (match_operand:SI 1 "register_operand" "")
8829                          (match_operand:SI 2 "uint5_operand" "")
8830                          (match_operand:SI 3 "uint5_operand" "")))]
8831   ""
8832   "
8834   unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
8835   unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
8837   /* PA extraction insns don't support zero length bitfields or fields
8838      extending beyond the left or right-most bits.  Also, the predicate
8839      rejects lengths equal to a word as they are better handled by
8840      the move patterns.  */
8841   if (len == 0 || pos + len > 32)
8842     FAIL;
8844   /* From mips.md: extract_bit_field doesn't verify that our source
8845      matches the predicate, so check it again here.  */
8846   if (!register_operand (operands[1], VOIDmode))
8847     FAIL;
8849   emit_insn (gen_extv_32 (operands[0], operands[1],
8850                           operands[2], operands[3]));
8851   DONE;
8854 (define_insn "extv_32"
8855   [(set (match_operand:SI 0 "register_operand" "=r")
8856         (sign_extract:SI (match_operand:SI 1 "register_operand" "r")
8857                          (match_operand:SI 2 "uint5_operand" "")
8858                          (match_operand:SI 3 "uint5_operand" "")))]
8859   "UINTVAL (operands[2]) > 0
8860    && UINTVAL (operands[2]) + UINTVAL (operands[3]) <= 32"
8861   "{extrs|extrw,s} %1,%3+%2-1,%2,%0"
8862   [(set_attr "type" "shift")
8863    (set_attr "length" "4")])
8865 (define_insn ""
8866   [(set (match_operand:SI 0 "register_operand" "=r")
8867         (sign_extract:SI (match_operand:SI 1 "register_operand" "r")
8868                          (const_int 1)
8869                          (match_operand:SI 2 "register_operand" "q")))]
8870   "!TARGET_64BIT"
8871   "{vextrs %1,1,%0|extrw,s %1,%%sar,1,%0}"
8872   [(set_attr "type" "shift")
8873    (set_attr "length" "4")])
8875 (define_expand "extvdi"
8876   [(set (match_operand:DI 0 "register_operand" "")
8877         (sign_extract:DI (match_operand:DI 1 "register_operand" "")
8878                          (match_operand:DI 2 "uint6_operand" "")
8879                          (match_operand:DI 3 "uint6_operand" "")))]
8880   "TARGET_64BIT"
8881   "
8883   unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
8884   unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
8886   /* PA extraction insns don't support zero length bitfields or fields
8887      extending beyond the left or right-most bits.  Also, the predicate
8888      rejects lengths equal to a doubleword as they are better handled by
8889      the move patterns.  */
8890   if (len == 0 || pos + len > 64)
8891     FAIL;
8893   /* From mips.md: extract_bit_field doesn't verify that our source
8894      matches the predicate, so check it again here.  */
8895   if (!register_operand (operands[1], VOIDmode))
8896     FAIL;
8898   emit_insn (gen_extv_64 (operands[0], operands[1],
8899                           operands[2], operands[3]));
8900   DONE;
8903 (define_insn "extv_64"
8904   [(set (match_operand:DI 0 "register_operand" "=r")
8905         (sign_extract:DI (match_operand:DI 1 "register_operand" "r")
8906                          (match_operand:DI 2 "uint6_operand" "")
8907                          (match_operand:DI 3 "uint6_operand" "")))]
8908   "TARGET_64BIT
8909    && UINTVAL (operands[2]) > 0
8910    && UINTVAL (operands[2]) + UINTVAL (operands[3]) <= 64"
8911   "extrd,s %1,%3+%2-1,%2,%0"
8912   [(set_attr "type" "shift")
8913    (set_attr "length" "4")])
8915 (define_insn ""
8916   [(set (match_operand:DI 0 "register_operand" "=r")
8917         (sign_extract:DI (match_operand:DI 1 "register_operand" "r")
8918                          (const_int 1)
8919                          (match_operand:DI 2 "register_operand" "q")))]
8920   "TARGET_64BIT"
8921   "extrd,s %1,%%sar,1,%0"
8922   [(set_attr "type" "shift")
8923    (set_attr "length" "4")])
8925 ;;; Operands 1 and 2 are assumed to be CONST_INTs.
8926 (define_expand "insvsi"
8927   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "")
8928                          (match_operand:SI 1 "uint5_operand" "")
8929                          (match_operand:SI 2 "uint5_operand" ""))
8930         (match_operand:SI 3 "arith5_operand" ""))]
8931   ""
8932   "
8934   unsigned HOST_WIDE_INT len = UINTVAL (operands[1]);
8935   unsigned HOST_WIDE_INT pos = UINTVAL (operands[2]);
8937   /* PA insertion insns don't support zero length bitfields or fields
8938      extending beyond the left or right-most bits.  Also, the predicate
8939      rejects lengths equal to a word as they are better handled by
8940      the move patterns.  */
8941   if (len <= 0 || pos + len > 32)
8942     FAIL;
8944   /* From mips.md: insert_bit_field doesn't verify that our destination
8945      matches the predicate, so check it again here.  */
8946   if (!register_operand (operands[0], VOIDmode))
8947     FAIL;
8949   emit_insn (gen_insv_32 (operands[0], operands[1],
8950                           operands[2], operands[3]));
8951   DONE;
8954 (define_insn "insv_32"
8955   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r,r")
8956                          (match_operand:SI 1 "uint5_operand" "")
8957                          (match_operand:SI 2 "uint5_operand" ""))
8958         (match_operand:SI 3 "arith5_operand" "r,L"))]
8959   "UINTVAL (operands[1]) > 0
8960    && UINTVAL (operands[1]) + UINTVAL (operands[2]) <= 32"
8961   "@
8962    {dep|depw} %3,%2+%1-1,%1,%0
8963    {depi|depwi} %3,%2+%1-1,%1,%0"
8964   [(set_attr "type" "shift,shift")
8965    (set_attr "length" "4,4")])
8967 ;; Optimize insertion of const_int values of type 1...1xxxx.
8968 (define_insn ""
8969   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
8970                          (match_operand:SI 1 "uint5_operand" "")
8971                          (match_operand:SI 2 "uint5_operand" ""))
8972         (match_operand:SI 3 "const_int_operand" ""))]
8973   "(INTVAL (operands[3]) & 0x10) != 0 &&
8974    (~INTVAL (operands[3]) & ((1L << INTVAL (operands[1])) - 1) & ~0xf) == 0"
8975   "*
8977   operands[3] = GEN_INT ((INTVAL (operands[3]) & 0xf) - 0x10);
8978   return \"{depi|depwi} %3,%2+%1-1,%1,%0\";
8980   [(set_attr "type" "shift")
8981    (set_attr "length" "4")])
8983 (define_expand "insvdi"
8984   [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "")
8985                          (match_operand:DI 1 "uint6_operand" "")
8986                          (match_operand:DI 2 "uint6_operand" ""))
8987         (match_operand:DI 3 "arith5_operand" ""))]
8988   "TARGET_64BIT"
8989   "
8991   unsigned HOST_WIDE_INT len = UINTVAL (operands[1]);
8992   unsigned HOST_WIDE_INT pos = UINTVAL (operands[2]);
8994   /* PA insertion insns don't support zero length bitfields or fields
8995      extending beyond the left or right-most bits.  Also, the predicate
8996      rejects lengths equal to a doubleword as they are better handled by
8997      the move patterns.  */
8998   if (len <= 0 || pos + len > 64)
8999     FAIL;
9001   /* From mips.md: insert_bit_field doesn't verify that our destination
9002      matches the predicate, so check it again here.  */
9003   if (!register_operand (operands[0], VOIDmode))
9004     FAIL;
9006   emit_insn (gen_insv_64 (operands[0], operands[1],
9007                           operands[2], operands[3]));
9008   DONE;
9011 (define_insn "insv_64"
9012   [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+r,r")
9013                          (match_operand:DI 1 "uint6_operand" "")
9014                          (match_operand:DI 2 "uint6_operand" ""))
9015         (match_operand:DI 3 "arith5_operand" "r,L"))]
9016   "TARGET_64BIT
9017    && UINTVAL (operands[1]) > 0
9018    && UINTVAL (operands[1]) + UINTVAL (operands[2]) <= 64"
9019   "@
9020    depd %3,%2+%1-1,%1,%0
9021    depdi %3,%2+%1-1,%1,%0"
9022   [(set_attr "type" "shift,shift")
9023    (set_attr "length" "4,4")])
9025 ;; Optimize insertion of const_int values of type 1...1xxxx.
9026 (define_insn ""
9027   [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+r")
9028                          (match_operand:DI 1 "uint6_operand" "")
9029                          (match_operand:DI 2 "uint6_operand" ""))
9030         (match_operand:DI 3 "const_int_operand" ""))]
9031   "(INTVAL (operands[3]) & 0x10) != 0
9032    && TARGET_64BIT
9033    && (~INTVAL (operands[3]) & ((1L << INTVAL (operands[1])) - 1) & ~0xf) == 0"
9034   "*
9036   operands[3] = GEN_INT ((INTVAL (operands[3]) & 0xf) - 0x10);
9037   return \"depdi %3,%2+%1-1,%1,%0\";
9039   [(set_attr "type" "shift")
9040    (set_attr "length" "4")])
9042 (define_insn ""
9043   [(set (match_operand:DI 0 "register_operand" "=r")
9044         (ashift:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
9045                    (const_int 32)))]
9046   "TARGET_64BIT"
9047   "depd,z %1,31,32,%0"
9048   [(set_attr "type" "shift")
9049    (set_attr "length" "4")])
9051 ;; This insn is used for some loop tests, typically loops reversed when
9052 ;; strength reduction is used.  It is actually created when the instruction
9053 ;; combination phase combines the special loop test.  Since this insn
9054 ;; is both a jump insn and has an output, it must deal with its own
9055 ;; reloads, hence the `Q' constraints.  The `!' constraints direct reload
9056 ;; to not choose the register alternatives in the event a reload is needed.
9057 (define_insn "decrement_and_branch_until_zero"
9058   [(set (pc)
9059         (if_then_else
9060           (match_operator 2 "ordered_comparison_operator"
9061            [(plus:SI
9062               (match_operand:SI 0 "reg_before_reload_operand" "+!r,!*f,*Q")
9063               (match_operand:SI 1 "int5_operand" "L,L,L"))
9064             (const_int 0)])
9065           (label_ref (match_operand 3 "" ""))
9066           (pc)))
9067    (set (match_dup 0)
9068         (plus:SI (match_dup 0) (match_dup 1)))
9069    (clobber (match_scratch:SI 4 "=X,r,r"))]
9070   ""
9071   "* return pa_output_dbra (operands, insn, which_alternative); "
9072 ;; Do not expect to understand this the first time through.
9073 [(set_attr "type" "cbranch,multi,multi")
9074  (set (attr "length")
9075       (if_then_else (eq_attr "alternative" "0")
9076 ;; Loop counter in register case
9077 ;; Short branch has length of 4
9078 ;; Long branch has length of 8, 20, 24 or 28
9079         (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9080                (const_int MAX_12BIT_OFFSET))
9081            (const_int 4)
9082            (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9083                (const_int MAX_17BIT_OFFSET))
9084            (const_int 8)
9085            (match_test "TARGET_PORTABLE_RUNTIME")
9086            (const_int 24)
9087            (not (match_test "flag_pic"))
9088            (const_int 20)]
9089           (const_int 28))
9091 ;; Loop counter in FP reg case.
9092 ;; Extra goo to deal with additional reload insns.
9093         (if_then_else (eq_attr "alternative" "1")
9094           (if_then_else (lt (match_dup 3) (pc))
9095              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 24))))
9096                       (const_int MAX_12BIT_OFFSET))
9097                     (const_int 24)
9098                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 24))))
9099                       (const_int MAX_17BIT_OFFSET))
9100                     (const_int 28)
9101                     (match_test "TARGET_PORTABLE_RUNTIME")
9102                     (const_int 44)
9103                     (not (match_test "flag_pic"))
9104                     (const_int 40)]
9105                   (const_int 48))
9106              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9107                       (const_int MAX_12BIT_OFFSET))
9108                     (const_int 24)
9109                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9110                       (const_int MAX_17BIT_OFFSET))
9111                     (const_int 28)
9112                     (match_test "TARGET_PORTABLE_RUNTIME")
9113                     (const_int 44)
9114                     (not (match_test "flag_pic"))
9115                     (const_int 40)]
9116                   (const_int 48)))
9118 ;; Loop counter in memory case.
9119 ;; Extra goo to deal with additional reload insns.
9120         (if_then_else (lt (match_dup 3) (pc))
9121              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9122                       (const_int MAX_12BIT_OFFSET))
9123                     (const_int 12)
9124                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9125                       (const_int MAX_17BIT_OFFSET))
9126                     (const_int 16)
9127                     (match_test "TARGET_PORTABLE_RUNTIME")
9128                     (const_int 32)
9129                     (not (match_test "flag_pic"))
9130                     (const_int 28)]
9131                   (const_int 36))
9132              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9133                       (const_int MAX_12BIT_OFFSET))
9134                     (const_int 12)
9135                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9136                       (const_int MAX_17BIT_OFFSET))
9137                     (const_int 16)
9138                     (match_test "TARGET_PORTABLE_RUNTIME")
9139                     (const_int 32)
9140                     (not (match_test "flag_pic"))
9141                     (const_int 28)]
9142                   (const_int 36))))))])
9144 (define_insn ""
9145   [(set (pc)
9146         (if_then_else
9147           (match_operator 2 "movb_comparison_operator"
9148            [(match_operand:SI 1 "register_operand" "r,r,r,r") (const_int 0)])
9149           (label_ref (match_operand 3 "" ""))
9150           (pc)))
9151    (set (match_operand:SI 0 "reg_before_reload_operand" "=!r,!*f,*Q,!*q")
9152         (match_dup 1))]
9153   ""
9154 "* return pa_output_movb (operands, insn, which_alternative, 0); "
9155 ;; Do not expect to understand this the first time through.
9156 [(set_attr "type" "cbranch,multi,multi,multi")
9157  (set (attr "length")
9158       (if_then_else (eq_attr "alternative" "0")
9159 ;; Loop counter in register case
9160 ;; Short branch has length of 4
9161 ;; Long branch has length of 8, 20, 24 or 28
9162         (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9163                (const_int MAX_12BIT_OFFSET))
9164            (const_int 4)
9165            (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9166                (const_int MAX_17BIT_OFFSET))
9167            (const_int 8)
9168            (match_test "TARGET_PORTABLE_RUNTIME")
9169            (const_int 24)
9170            (not (match_test "flag_pic"))
9171            (const_int 20)]
9172           (const_int 28))
9174 ;; Loop counter in FP reg case.
9175 ;; Extra goo to deal with additional reload insns.
9176         (if_then_else (eq_attr "alternative" "1")
9177           (if_then_else (lt (match_dup 3) (pc))
9178              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9179                       (const_int MAX_12BIT_OFFSET))
9180                     (const_int 12)
9181                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9182                       (const_int MAX_17BIT_OFFSET))
9183                     (const_int 16)
9184                     (match_test "TARGET_PORTABLE_RUNTIME")
9185                     (const_int 32)
9186                     (not (match_test "flag_pic"))
9187                     (const_int 28)]
9188                   (const_int 36))
9189              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9190                       (const_int MAX_12BIT_OFFSET))
9191                     (const_int 12)
9192                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9193                       (const_int MAX_17BIT_OFFSET))
9194                     (const_int 16)
9195                     (match_test "TARGET_PORTABLE_RUNTIME")
9196                     (const_int 32)
9197                     (not (match_test "flag_pic"))
9198                     (const_int 28)]
9199                   (const_int 36)))
9201 ;; Loop counter in memory or sar case.
9202 ;; Extra goo to deal with additional reload insns.
9203         (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9204                    (const_int MAX_12BIT_OFFSET))
9205                 (const_int 8)
9206                 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9207                   (const_int MAX_17BIT_OFFSET))
9208                 (const_int 12)
9209                 (match_test "TARGET_PORTABLE_RUNTIME")
9210                 (const_int 28)
9211                 (not (match_test "flag_pic"))
9212                 (const_int 24)]
9213               (const_int 32)))))])
9215 ;; Handle negated branch.
9216 (define_insn ""
9217   [(set (pc)
9218         (if_then_else
9219           (match_operator 2 "movb_comparison_operator"
9220            [(match_operand:SI 1 "register_operand" "r,r,r,r") (const_int 0)])
9221           (pc)
9222           (label_ref (match_operand 3 "" ""))))
9223    (set (match_operand:SI 0 "reg_before_reload_operand" "=!r,!*f,*Q,!*q")
9224         (match_dup 1))]
9225   ""
9226 "* return pa_output_movb (operands, insn, which_alternative, 1); "
9227 ;; Do not expect to understand this the first time through.
9228 [(set_attr "type" "cbranch,multi,multi,multi")
9229  (set (attr "length")
9230       (if_then_else (eq_attr "alternative" "0")
9231 ;; Loop counter in register case
9232 ;; Short branch has length of 4
9233 ;; Long branch has length of 8
9234         (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9235                (const_int MAX_12BIT_OFFSET))
9236            (const_int 4)
9237            (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9238                (const_int MAX_17BIT_OFFSET))
9239            (const_int 8)
9240            (match_test "TARGET_PORTABLE_RUNTIME")
9241            (const_int 24)
9242            (not (match_test "flag_pic"))
9243            (const_int 20)]
9244           (const_int 28))
9246 ;; Loop counter in FP reg case.
9247 ;; Extra goo to deal with additional reload insns.
9248         (if_then_else (eq_attr "alternative" "1")
9249           (if_then_else (lt (match_dup 3) (pc))
9250              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9251                       (const_int MAX_12BIT_OFFSET))
9252                     (const_int 12)
9253                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9254                       (const_int MAX_17BIT_OFFSET))
9255                     (const_int 16)
9256                     (match_test "TARGET_PORTABLE_RUNTIME")
9257                     (const_int 32)
9258                     (not (match_test "flag_pic"))
9259                     (const_int 28)]
9260                   (const_int 36))
9261              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9262                       (const_int MAX_12BIT_OFFSET))
9263                     (const_int 12)
9264                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9265                       (const_int MAX_17BIT_OFFSET))
9266                     (const_int 16)
9267                     (match_test "TARGET_PORTABLE_RUNTIME")
9268                     (const_int 32)
9269                     (not (match_test "flag_pic"))
9270                     (const_int 28)]
9271                   (const_int 36)))
9273 ;; Loop counter in memory or SAR case.
9274 ;; Extra goo to deal with additional reload insns.
9275         (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9276                    (const_int MAX_12BIT_OFFSET))
9277                 (const_int 8)
9278                 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9279                   (const_int MAX_17BIT_OFFSET))
9280                 (const_int 12)
9281                 (match_test "TARGET_PORTABLE_RUNTIME")
9282                 (const_int 28)
9283                 (not (match_test "flag_pic"))
9284                 (const_int 24)]
9285               (const_int 32)))))])
9287 (define_insn ""
9288   [(set (pc) (label_ref (match_operand 3 "" "" )))
9289    (set (match_operand:SI 0 "ireg_operand" "=r")
9290         (plus:SI (match_operand:SI 1 "ireg_operand" "r")
9291                  (match_operand:SI 2 "ireg_or_int5_operand" "rL")))]
9292   "(reload_completed && operands[0] == operands[1]) || operands[0] == operands[2]"
9293   "*
9295   return pa_output_parallel_addb (operands, insn);
9297 [(set_attr "type" "parallel_branch")
9298  (set (attr "length")
9299     (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9300                (const_int MAX_12BIT_OFFSET))
9301            (const_int 4)
9302            (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9303                (const_int MAX_17BIT_OFFSET))
9304            (const_int 8)
9305            (match_test "TARGET_PORTABLE_RUNTIME")
9306            (const_int 24)
9307            (not (match_test "flag_pic"))
9308            (const_int 20)]
9309           (const_int 28)))])
9311 (define_insn ""
9312   [(set (pc) (label_ref (match_operand 2 "" "" )))
9313    (set (match_operand:SF 0 "ireg_operand" "=r")
9314         (match_operand:SF 1 "ireg_or_int5_operand" "rL"))]
9315   "reload_completed"
9316   "*
9318   return pa_output_parallel_movb (operands, insn);
9320 [(set_attr "type" "parallel_branch")
9321  (set (attr "length")
9322     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9323                (const_int MAX_12BIT_OFFSET))
9324            (const_int 4)
9325            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9326                (const_int MAX_17BIT_OFFSET))
9327            (const_int 8)
9328            (match_test "TARGET_PORTABLE_RUNTIME")
9329            (const_int 24)
9330            (not (match_test "flag_pic"))
9331            (const_int 20)]
9332           (const_int 28)))])
9334 (define_insn ""
9335   [(set (pc) (label_ref (match_operand 2 "" "" )))
9336    (set (match_operand:SI 0 "ireg_operand" "=r")
9337         (match_operand:SI 1 "ireg_or_int5_operand" "rL"))]
9338   "reload_completed"
9339   "*
9341   return pa_output_parallel_movb (operands, insn);
9343 [(set_attr "type" "parallel_branch")
9344  (set (attr "length")
9345     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9346                (const_int MAX_12BIT_OFFSET))
9347            (const_int 4)
9348            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9349                (const_int MAX_17BIT_OFFSET))
9350            (const_int 8)
9351            (match_test "TARGET_PORTABLE_RUNTIME")
9352            (const_int 24)
9353            (not (match_test "flag_pic"))
9354            (const_int 20)]
9355           (const_int 28)))])
9357 (define_insn ""
9358   [(set (pc) (label_ref (match_operand 2 "" "" )))
9359    (set (match_operand:HI 0 "ireg_operand" "=r")
9360         (match_operand:HI 1 "ireg_or_int5_operand" "rL"))]
9361   "reload_completed"
9362   "*
9364   return pa_output_parallel_movb (operands, insn);
9366 [(set_attr "type" "parallel_branch")
9367  (set (attr "length")
9368     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9369                (const_int MAX_12BIT_OFFSET))
9370            (const_int 4)
9371            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9372                (const_int MAX_17BIT_OFFSET))
9373            (const_int 8)
9374            (match_test "TARGET_PORTABLE_RUNTIME")
9375            (const_int 24)
9376            (not (match_test "flag_pic"))
9377            (const_int 20)]
9378           (const_int 28)))])
9380 (define_insn ""
9381   [(set (pc) (label_ref (match_operand 2 "" "" )))
9382    (set (match_operand:QI 0 "ireg_operand" "=r")
9383         (match_operand:QI 1 "ireg_or_int5_operand" "rL"))]
9384   "reload_completed"
9385   "*
9387   return pa_output_parallel_movb (operands, insn);
9389 [(set_attr "type" "parallel_branch")
9390  (set (attr "length")
9391     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9392                (const_int MAX_12BIT_OFFSET))
9393            (const_int 4)
9394            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9395                (const_int MAX_17BIT_OFFSET))
9396            (const_int 8)
9397            (match_test "TARGET_PORTABLE_RUNTIME")
9398            (const_int 24)
9399            (not (match_test "flag_pic"))
9400            (const_int 20)]
9401           (const_int 28)))])
9403 (define_insn ""
9404   [(set (match_operand 0 "register_operand" "=f")
9405         (mult (match_operand 1 "register_operand" "f")
9406               (match_operand 2 "register_operand" "f")))
9407    (set (match_operand 3 "register_operand" "+f")
9408         (plus (match_operand 4 "register_operand" "f")
9409               (match_operand 5 "register_operand" "f")))]
9410   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9411    && reload_completed && pa_fmpyaddoperands (operands)"
9412   "*
9414   if (GET_MODE (operands[0]) == DFmode)
9415     {
9416       if (rtx_equal_p (operands[3], operands[5]))
9417         return \"fmpyadd,dbl %1,%2,%0,%4,%3\";
9418       else
9419         return \"fmpyadd,dbl %1,%2,%0,%5,%3\";
9420     }
9421   else
9422     {
9423       if (rtx_equal_p (operands[3], operands[5]))
9424         return \"fmpyadd,sgl %1,%2,%0,%4,%3\";
9425       else
9426         return \"fmpyadd,sgl %1,%2,%0,%5,%3\";
9427     }
9429   [(set_attr "type" "fpalu")
9430    (set_attr "length" "4")])
9432 (define_insn ""
9433   [(set (match_operand 3 "register_operand" "+f")
9434         (plus (match_operand 4 "register_operand" "f")
9435               (match_operand 5 "register_operand" "f")))
9436    (set (match_operand 0 "register_operand" "=f")
9437         (mult (match_operand 1 "register_operand" "f")
9438               (match_operand 2 "register_operand" "f")))]
9439   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9440    && reload_completed && pa_fmpyaddoperands (operands)"
9441   "*
9443   if (GET_MODE (operands[0]) == DFmode)
9444     {
9445       if (rtx_equal_p (operands[3], operands[5]))
9446         return \"fmpyadd,dbl %1,%2,%0,%4,%3\";
9447       else
9448         return \"fmpyadd,dbl %1,%2,%0,%5,%3\";
9449     }
9450   else
9451     {
9452       if (rtx_equal_p (operands[3], operands[5]))
9453         return \"fmpyadd,sgl %1,%2,%0,%4,%3\";
9454       else
9455         return \"fmpyadd,sgl %1,%2,%0,%5,%3\";
9456     }
9458   [(set_attr "type" "fpalu")
9459    (set_attr "length" "4")])
9461 (define_insn ""
9462   [(set (match_operand 0 "register_operand" "=f")
9463         (mult (match_operand 1 "register_operand" "f")
9464               (match_operand 2 "register_operand" "f")))
9465    (set (match_operand 3 "register_operand" "+f")
9466         (minus (match_operand 4 "register_operand" "f")
9467                (match_operand 5 "register_operand" "f")))]
9468   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9469    && reload_completed && pa_fmpysuboperands (operands)"
9470   "*
9472   if (GET_MODE (operands[0]) == DFmode)
9473     return \"fmpysub,dbl %1,%2,%0,%5,%3\";
9474   else
9475     return \"fmpysub,sgl %1,%2,%0,%5,%3\";
9477   [(set_attr "type" "fpalu")
9478    (set_attr "length" "4")])
9480 (define_insn ""
9481   [(set (match_operand 3 "register_operand" "+f")
9482         (minus (match_operand 4 "register_operand" "f")
9483                (match_operand 5 "register_operand" "f")))
9484    (set (match_operand 0 "register_operand" "=f")
9485         (mult (match_operand 1 "register_operand" "f")
9486               (match_operand 2 "register_operand" "f")))]
9487   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9488    && reload_completed && pa_fmpysuboperands (operands)"
9489   "*
9491   if (GET_MODE (operands[0]) == DFmode)
9492     return \"fmpysub,dbl %1,%2,%0,%5,%3\";
9493   else
9494     return \"fmpysub,sgl %1,%2,%0,%5,%3\";
9496   [(set_attr "type" "fpalu")
9497    (set_attr "length" "4")])
9499 ;; The following two patterns are used by the trampoline code for nested
9500 ;; functions.  They flush the I and D cache lines from the start address
9501 ;; (operand0) to the end address (operand1).  No lines are flushed if the
9502 ;; end address is less than the start address (unsigned).
9504 ;; Because the range of memory flushed is variable and the size of a MEM
9505 ;; can only be a CONST_INT, the patterns specify that they perform an
9506 ;; unspecified volatile operation on all memory.
9508 ;; The address range for an icache flush must lie within a single
9509 ;; space on targets with non-equivalent space registers.
9511 ;; Operand 0 contains the start address.
9512 ;; Operand 1 contains the end address.
9513 ;; Operand 2 contains the line length to use.
9514 (define_insn "dcacheflush<P:mode>"
9515   [(const_int 1)
9516    (unspec_volatile [(mem:BLK (scratch))] UNSPECV_DCACHE)
9517    (use (match_operand 0 "pmode_register_operand" "r"))
9518    (use (match_operand 1 "pmode_register_operand" "r"))
9519    (use (match_operand 2 "pmode_register_operand" "r"))
9520    (clobber (match_scratch:P 3 "=&0"))]
9521   ""
9522   "cmpb,<dwc><<=,n %3,%1,.\;fdc,m %2(%3)\;sync"
9523   [(set_attr "type" "multi")
9524    (set_attr "length" "12")])
9526 (define_insn "icacheflush<P:mode>"
9527   [(const_int 2)
9528    (unspec_volatile [(mem:BLK (scratch))] UNSPECV_ICACHE)
9529    (use (match_operand 0 "pmode_register_operand" "r"))
9530    (use (match_operand 1 "pmode_register_operand" "r"))
9531    (use (match_operand 2 "pmode_register_operand" "r"))
9532    (clobber (match_operand 3 "pmode_register_operand" "=&r"))
9533    (clobber (match_operand 4 "pmode_register_operand" "=&r"))
9534    (clobber (match_scratch:P 5 "=&0"))]
9535   ""
9536   "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"
9537   [(set_attr "type" "multi")
9538    (set_attr "length" "52")])
9540 ;; An out-of-line prologue.
9541 (define_insn "outline_prologue_call"
9542   [(unspec_volatile [(const_int 0)] UNSPECV_OPC)
9543    (clobber (reg:SI 31))
9544    (clobber (reg:SI 22))
9545    (clobber (reg:SI 21))
9546    (clobber (reg:SI 20))
9547    (clobber (reg:SI 19))
9548    (clobber (reg:SI 1))]
9549   ""
9550   "*
9553   /* We need two different versions depending on whether or not we
9554      need a frame pointer.   Also note that we return to the instruction
9555      immediately after the branch rather than two instructions after the
9556      break as normally is the case.  */
9557   if (frame_pointer_needed)
9558     {
9559       /* Must import the magic millicode routine(s).  */
9560       output_asm_insn (\".IMPORT __outline_prologue_fp,MILLICODE\", NULL);
9562       if (TARGET_PORTABLE_RUNTIME)
9563         {
9564           output_asm_insn (\"ldil L'__outline_prologue_fp,%%r31\", NULL);
9565           output_asm_insn (\"ble,n R'__outline_prologue_fp(%%sr0,%%r31)\",
9566                            NULL);
9567         }
9568       else
9569         output_asm_insn (\"{bl|b,l},n __outline_prologue_fp,%%r31\", NULL);
9570     }
9571   else
9572     {
9573       /* Must import the magic millicode routine(s).  */
9574       output_asm_insn (\".IMPORT __outline_prologue,MILLICODE\", NULL);
9576       if (TARGET_PORTABLE_RUNTIME)
9577         {
9578           output_asm_insn (\"ldil L'__outline_prologue,%%r31\", NULL);
9579           output_asm_insn (\"ble,n R'__outline_prologue(%%sr0,%%r31)\", NULL);
9580         }
9581       else
9582         output_asm_insn (\"{bl|b,l},n __outline_prologue,%%r31\", NULL);
9583     }
9584   return \"\";
9586   [(set_attr "type" "multi")
9587    (set_attr "length" "8")])
9589 ;; An out-of-line epilogue.
9590 (define_insn "outline_epilogue_call"
9591   [(unspec_volatile [(const_int 1)] UNSPECV_OEC)
9592    (use (reg:SI 29))
9593    (use (reg:SI 28))
9594    (clobber (reg:SI 31))
9595    (clobber (reg:SI 22))
9596    (clobber (reg:SI 21))
9597    (clobber (reg:SI 20))
9598    (clobber (reg:SI 19))
9599    (clobber (reg:SI 2))
9600    (clobber (reg:SI 1))]
9601   ""
9602   "*
9605   /* We need two different versions depending on whether or not we
9606      need a frame pointer.   Also note that we return to the instruction
9607      immediately after the branch rather than two instructions after the
9608      break as normally is the case.  */
9609   if (frame_pointer_needed)
9610     {
9611       /* Must import the magic millicode routine.  */
9612       output_asm_insn (\".IMPORT __outline_epilogue_fp,MILLICODE\", NULL);
9614       /* The out-of-line prologue will make sure we return to the right
9615          instruction.  */
9616       if (TARGET_PORTABLE_RUNTIME)
9617         {
9618           output_asm_insn (\"ldil L'__outline_epilogue_fp,%%r31\", NULL);
9619           output_asm_insn (\"ble,n R'__outline_epilogue_fp(%%sr0,%%r31)\",
9620                            NULL);
9621         }
9622       else
9623         output_asm_insn (\"{bl|b,l},n __outline_epilogue_fp,%%r31\", NULL);
9624     }
9625   else
9626     {
9627       /* Must import the magic millicode routine.  */
9628       output_asm_insn (\".IMPORT __outline_epilogue,MILLICODE\", NULL);
9630       /* The out-of-line prologue will make sure we return to the right
9631          instruction.  */
9632       if (TARGET_PORTABLE_RUNTIME)
9633         {
9634           output_asm_insn (\"ldil L'__outline_epilogue,%%r31\", NULL);
9635           output_asm_insn (\"ble,n R'__outline_epilogue(%%sr0,%%r31)\", NULL);
9636         }
9637       else
9638         output_asm_insn (\"{bl|b,l},n __outline_epilogue,%%r31\", NULL);
9639     }
9640   return \"\";
9642   [(set_attr "type" "multi")
9643    (set_attr "length" "8")])
9645 ;; Given a function pointer, canonicalize it so it can be 
9646 ;; reliably compared to another function pointer.  */
9647 (define_expand "canonicalize_funcptr_for_compare"
9648   [(set (reg:SI 26) (match_operand:SI 1 "register_operand" ""))
9649    (parallel [(set (reg:SI 29) (unspec:SI [(reg:SI 26)] UNSPEC_CFFC))
9650               (clobber (match_dup 2))
9651               (clobber (reg:SI 26))
9652               (clobber (reg:SI 22))
9653               (clobber (reg:SI 31))])
9654    (set (match_operand:SI 0 "register_operand" "")
9655         (reg:SI 29))]
9656   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
9657   "
9659   if (TARGET_ELF32)
9660     {
9661       rtx canonicalize_funcptr_for_compare_libfunc
9662         = init_one_libfunc (CANONICALIZE_FUNCPTR_FOR_COMPARE_LIBCALL);
9664       emit_library_call_value (canonicalize_funcptr_for_compare_libfunc,
9665                                operands[0], LCT_NORMAL, Pmode,
9666                                operands[1], Pmode);
9667       DONE;
9668     }
9670   operands[2] = gen_reg_rtx (SImode);
9671   if (GET_CODE (operands[1]) != REG)
9672     {
9673       rtx tmp = gen_reg_rtx (Pmode);
9674       emit_move_insn (tmp, operands[1]);
9675       operands[1] = tmp;
9676     }
9679 (define_insn "*$$sh_func_adrs"
9680   [(set (reg:SI 29) (unspec:SI [(reg:SI 26)] UNSPEC_CFFC))
9681    (clobber (match_operand:SI 0 "register_operand" "=a"))
9682    (clobber (reg:SI 26))
9683    (clobber (reg:SI 22))
9684    (clobber (reg:SI 31))]
9685   "!TARGET_64BIT"
9686   "*
9688   int length = get_attr_length (insn);
9689   rtx xoperands[2];
9691   xoperands[0] = GEN_INT (length - 8);
9692   xoperands[1] = GEN_INT (length - 16);
9694   /* Must import the magic millicode routine.  */
9695   output_asm_insn (\".IMPORT $$sh_func_adrs,MILLICODE\", NULL);
9697   /* This is absolutely amazing.
9699      First, copy our input parameter into %r29 just in case we don't
9700      need to call $$sh_func_adrs.  */
9701   output_asm_insn (\"copy %%r26,%%r29\", NULL);
9702   output_asm_insn (\"{extru|extrw,u} %%r26,31,2,%%r31\", NULL);
9704   /* Next, examine the low two bits in %r26, if they aren't 0x2, then
9705      we use %r26 unchanged.  */
9706   output_asm_insn (\"{comib|cmpib},<>,n 2,%%r31,.+%0\", xoperands);
9707   output_asm_insn (\"ldi 4096,%%r31\", NULL);
9709   /* Next, compare %r26 with 4096, if %r26 is less than or equal to
9710      4096, then again we use %r26 unchanged.  */
9711   output_asm_insn (\"{comb|cmpb},<<,n %%r26,%%r31,.+%1\", xoperands);
9713   /* Finally, call $$sh_func_adrs to extract the function's real add24.  */
9714   return pa_output_millicode_call (insn,
9715                                    gen_rtx_SYMBOL_REF (SImode,
9716                                                        \"$$sh_func_adrs\"));
9718   [(set_attr "type" "sh_func_adrs")
9719    (set (attr "length")
9720         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 28)]
9721               (plus (symbol_ref "pa_attr_length_millicode_call (insn)")
9722                     (const_int 20))))])
9724 ;; On the PA, the PIC register is call clobbered, so it must
9725 ;; be saved & restored around calls by the caller.  If the call
9726 ;; doesn't return normally (nonlocal goto, or an exception is
9727 ;; thrown), then the code at the exception handler label must
9728 ;; restore the PIC register.
9729 (define_expand "exception_receiver"
9730   [(const_int 4)]
9731   "flag_pic"
9732   "
9734   /* On the 64-bit port, we need a blockage because there is
9735      confusion regarding the dependence of the restore on the
9736      frame pointer.  As a result, the frame pointer and pic
9737      register restores sometimes are interchanged erroneously.  */
9738   if (TARGET_64BIT)
9739     emit_insn (gen_blockage ());
9740   /* Restore the PIC register using hppa_pic_save_rtx ().  The
9741      PIC register is not saved in the frame in 64-bit ABI.  */
9742   emit_move_insn (pic_offset_table_rtx, hppa_pic_save_rtx ());
9743   emit_insn (gen_blockage ());
9744   DONE;
9747 (define_expand "builtin_setjmp_receiver"
9748   [(label_ref (match_operand 0 "" ""))]
9749   "flag_pic"
9750   "
9752   if (TARGET_64BIT)
9753     emit_insn (gen_blockage ());
9754   /* Restore the PIC register.  Hopefully, this will always be from
9755      a stack slot.  The only registers that are valid after a
9756      builtin_longjmp are the stack and frame pointers.  */
9757   emit_move_insn (pic_offset_table_rtx, hppa_pic_save_rtx ());
9758   emit_insn (gen_blockage ());
9759   DONE;
9762 ;; Allocate new stack space and update the saved stack pointer in the
9763 ;; frame marker.  The HP C compilers also copy additional words in the
9764 ;; frame marker.  The 64-bit compiler copies words at -48, -32 and -24.
9765 ;; The 32-bit compiler copies the word at -16 (Static Link).  We
9766 ;; currently don't copy these values.
9768 ;; Since the copy of the frame marker can't be done atomically, I
9769 ;; suspect that using it for unwind purposes may be somewhat unreliable.
9770 ;; The HP compilers appear to raise the stack and copy the frame
9771 ;; marker in a strict instruction sequence.  This suggests that the
9772 ;; unwind library may check for an alloca sequence when ALLOCA_FRAME
9773 ;; is set in the callinfo data.  We currently don't set ALLOCA_FRAME
9774 ;; as GAS doesn't support it, or try to keep the instructions emitted
9775 ;; here in strict sequence.
9776 (define_expand "allocate_stack"
9777   [(match_operand 0 "" "")
9778    (match_operand 1 "" "")]
9779   ""
9780   "
9782   rtx addr;
9784   /* Since the stack grows upward, we need to store virtual_stack_dynamic_rtx
9785      in operand 0 before adjusting the stack.  */
9786   emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
9787   anti_adjust_stack (operands[1]);
9788   if (TARGET_HPUX_UNWIND_LIBRARY)
9789     {
9790       addr = gen_rtx_PLUS (word_mode, stack_pointer_rtx,
9791                            GEN_INT (TARGET_64BIT ? -8 : -4));
9792       emit_move_insn (gen_rtx_MEM (word_mode, addr), hard_frame_pointer_rtx);
9793     }
9794   if (!TARGET_64BIT && flag_pic)
9795     {
9796       rtx addr = gen_rtx_PLUS (word_mode, stack_pointer_rtx, GEN_INT (-32));
9797       emit_move_insn (gen_rtx_MEM (word_mode, addr), pic_offset_table_rtx);
9798     }
9799   DONE;
9802 (define_expand "prefetch"
9803   [(match_operand 0 "address_operand" "")
9804    (match_operand 1 "const_int_operand" "")
9805    (match_operand 2 "const_int_operand" "")]
9806   "TARGET_PA_20"
9808   operands[0] = copy_addr_to_reg (operands[0]);
9809   emit_insn (gen_prefetch_20 (operands[0], operands[1], operands[2]));
9810   DONE;
9813 (define_insn "prefetch_20"
9814   [(prefetch (match_operand 0 "pmode_register_operand" "r")
9815              (match_operand:SI 1 "const_int_operand" "n")
9816              (match_operand:SI 2 "const_int_operand" "n"))]
9817   "TARGET_PA_20"
9819   /* The SL cache-control completer indicates good spatial locality but
9820      poor temporal locality.  The ldw instruction with a target of general
9821      register 0 prefetches a cache line for a read.  The ldd instruction
9822      prefetches a cache line for a write.  */
9823   static const char * const instr[2][2] = {
9824     {
9825       "ldw,sl 0(%0),%%r0",
9826       "ldd,sl 0(%0),%%r0"
9827     },
9828     {
9829       "ldw 0(%0),%%r0",
9830       "ldd 0(%0),%%r0"
9831     }
9832   };
9833   int read_or_write = INTVAL (operands[1]) == 0 ? 0 : 1;
9834   int locality = INTVAL (operands[2]) == 0 ? 0 : 1;
9836   return instr [locality][read_or_write];
9838   [(set_attr "type" "load")
9839    (set_attr "length" "4")])
9841 ;; TLS Support
9842 (define_insn "tgd_load"
9843  [(set (match_operand:SI 0 "register_operand" "=r")
9844        (unspec:SI [(match_operand 1 "tgd_symbolic_operand" "")] UNSPEC_TLSGD))
9845   (clobber (reg:SI 1))
9846   (use (reg:SI 27))]
9847   ""
9848   "*
9850   return \"addil LR'%1-$tls_gdidx$,%%r27\;ldo RR'%1-$tls_gdidx$(%%r1),%0\";
9852   [(set_attr "type" "multi")
9853    (set_attr "length" "8")])
9855 (define_insn "tgd_load_pic"
9856  [(set (match_operand:SI 0 "register_operand" "=r")
9857        (unspec:SI [(match_operand 1 "tgd_symbolic_operand" "")] UNSPEC_TLSGD_PIC))
9858   (clobber (reg:SI 1))
9859   (use (reg:SI 19))]
9860   ""
9861   "*
9863   return \"addil LT'%1-$tls_gdidx$,%%r19\;ldo RT'%1-$tls_gdidx$(%%r1),%0\";
9865   [(set_attr "type" "multi")
9866    (set_attr "length" "8")])
9868 (define_insn "tld_load"
9869  [(set (match_operand:SI 0 "register_operand" "=r")
9870        (unspec:SI [(match_operand 1 "tld_symbolic_operand" "")] UNSPEC_TLSLDM))
9871   (clobber (reg:SI 1))
9872   (use (reg:SI 27))]
9873   ""
9874   "*
9876   return \"addil LR'%1-$tls_ldidx$,%%r27\;ldo RR'%1-$tls_ldidx$(%%r1),%0\";
9878   [(set_attr "type" "multi")
9879    (set_attr "length" "8")])
9881 (define_insn "tld_load_pic"
9882  [(set (match_operand:SI 0 "register_operand" "=r")
9883        (unspec:SI [(match_operand 1 "tld_symbolic_operand" "")] UNSPEC_TLSLDM_PIC))
9884   (clobber (reg:SI 1))
9885   (use (reg:SI 19))]
9886   ""
9887   "*
9889   return \"addil LT'%1-$tls_ldidx$,%%r19\;ldo RT'%1-$tls_ldidx$(%%r1),%0\";
9891   [(set_attr "type" "multi")
9892    (set_attr "length" "8")])
9894 (define_insn "tld_offset_load"
9895   [(set (match_operand:SI 0 "register_operand" "=r")
9896         (plus:SI (unspec:SI [(match_operand 1 "tld_symbolic_operand" "")] 
9897                             UNSPEC_TLSLDO)
9898                  (match_operand:SI 2 "register_operand" "r")))
9899    (clobber (reg:SI 1))]
9900   ""
9901   "*
9903   return \"addil LR'%1-$tls_dtpoff$,%2\;ldo RR'%1-$tls_dtpoff$(%%r1),%0\"; 
9905   [(set_attr "type" "multi")
9906    (set_attr "length" "8")])
9908 (define_insn "tp_load"
9909   [(set (match_operand:SI 0 "register_operand" "=r")
9910         (unspec:SI [(const_int 0)] UNSPEC_TP))]
9911   ""
9912   "mfctl %%cr27,%0"
9913   [(set_attr "type" "multi")
9914    (set_attr "length" "4")])
9916 (define_insn "tie_load"
9917   [(set (match_operand:SI 0 "register_operand" "=r")
9918         (unspec:SI [(match_operand 1 "tie_symbolic_operand" "")] UNSPEC_TLSIE))
9919    (clobber (reg:SI 1))
9920    (use (reg:SI 27))]
9921   ""
9922   "*
9924   return \"addil LR'%1-$tls_ieoff$,%%r27\;ldw RR'%1-$tls_ieoff$(%%r1),%0\";
9926   [(set_attr "type" "multi")
9927    (set_attr "length" "8")])
9929 (define_insn "tie_load_pic"
9930   [(set (match_operand:SI 0 "register_operand" "=r")
9931         (unspec:SI [(match_operand 1 "tie_symbolic_operand" "")] UNSPEC_TLSIE_PIC))
9932    (clobber (reg:SI 1))
9933    (use (reg:SI 19))]
9934   ""
9935   "*
9937   return \"addil LT'%1-$tls_ieoff$,%%r19\;ldw RT'%1-$tls_ieoff$(%%r1),%0\";
9939   [(set_attr "type" "multi")
9940    (set_attr "length" "8")])
9942 (define_insn "tle_load"
9943   [(set (match_operand:SI 0 "register_operand" "=r")
9944         (plus:SI (unspec:SI [(match_operand 1 "tle_symbolic_operand" "")] 
9945                             UNSPEC_TLSLE)
9946                  (match_operand:SI 2 "register_operand" "r")))
9947    (clobber (reg:SI 1))]
9948   ""
9949   "addil LR'%1-$tls_leoff$,%2\;ldo RR'%1-$tls_leoff$(%%r1),%0"
9950   [(set_attr "type" "multi")
9951    (set_attr "length" "8")])
9953 ;; Atomic instructions
9955 ;; All memory loads and stores access storage atomically except
9956 ;; for one exception.  The STORE BYTES, STORE DOUBLE BYTES, and
9957 ;; doubleword loads and stores are not guaranteed to be atomic
9958 ;; when referencing the I/O address space.
9960 ;; These patterns are at the bottom so the non atomic versions are preferred.
9962 (define_expand "atomic_storeqi"
9963   [(match_operand:QI 0 "memory_operand")                ;; memory
9964    (match_operand:QI 1 "register_operand")              ;; val out
9965    (match_operand:SI 2 "const_int_operand")]            ;; model
9966   ""
9968   if (TARGET_SYNC_LIBCALL)
9969     {
9970       rtx mem = operands[0];
9971       rtx val = operands[1];
9972       if (pa_maybe_emit_compare_and_swap_exchange_loop (NULL_RTX, mem, val))
9973         DONE;
9974     }
9975   FAIL;
9978 ;; Implement atomic HImode stores using exchange.
9980 (define_expand "atomic_storehi"
9981   [(match_operand:HI 0 "memory_operand")                ;; memory
9982    (match_operand:HI 1 "register_operand")              ;; val out
9983    (match_operand:SI 2 "const_int_operand")]            ;; model
9984   ""
9986   if (TARGET_SYNC_LIBCALL)
9987     {
9988       rtx mem = operands[0];
9989       rtx val = operands[1];
9990       if (pa_maybe_emit_compare_and_swap_exchange_loop (NULL_RTX, mem, val))
9991         DONE;
9992     }
9993   FAIL;
9996 ;; Implement atomic SImode store using exchange.
9998 (define_expand "atomic_storesi"
9999   [(match_operand:SI 0 "memory_operand")                ;; memory
10000    (match_operand:SI 1 "register_operand")              ;; val out
10001    (match_operand:SI 2 "const_int_operand")]            ;; model
10002   ""
10004   if (TARGET_SYNC_LIBCALL)
10005     {
10006       rtx mem = operands[0];
10007       rtx val = operands[1];
10008       if (pa_maybe_emit_compare_and_swap_exchange_loop (NULL_RTX, mem, val))
10009         DONE;
10010     }
10011   FAIL;
10014 ;; Implement atomic DImode load.
10016 (define_expand "atomic_loaddi"
10017   [(match_operand:DI 0 "register_operand")              ;; val out
10018    (match_operand:DI 1 "memory_operand")                ;; memory
10019    (match_operand:SI 2 "const_int_operand")]            ;; model
10020   ""
10022   enum memmodel model;
10024   if (TARGET_64BIT || TARGET_DISABLE_FPREGS || TARGET_SOFT_FLOAT)
10025     FAIL;
10027   model = memmodel_from_int (INTVAL (operands[2]));
10028   operands[1] = force_reg (SImode, XEXP (operands[1], 0));
10029   if (is_mm_seq_cst (model))
10030     expand_mem_thread_fence (model);
10031   emit_insn (gen_atomic_loaddi_1 (operands[0], operands[1]));
10032   expand_mem_thread_fence (model);
10033   DONE;
10036 (define_insn "atomic_loaddi_1"
10037   [(set (match_operand:DI 0 "register_operand" "=r")
10038         (mem:DI (match_operand:SI 1 "register_operand" "r")))
10039    (clobber (match_scratch:DI 2 "=f"))]
10040   "!TARGET_64BIT && !TARGET_DISABLE_FPREGS && !TARGET_SOFT_FLOAT"
10041   "{fldds|fldd} 0(%1),%2\n\t{fstds|fstd} %2,-16(%%sp)\n\t{ldws|ldw} -16(%%sp),%0\n\t{ldws|ldw} -12(%%sp),%R0"
10042   [(set_attr "type" "move")
10043    (set_attr "length" "16")])
10045 ;; Implement atomic DImode store.
10047 (define_expand "atomic_storedi"
10048   [(match_operand:DI 0 "memory_operand")                ;; memory
10049    (match_operand:DI 1 "reg_or_cint_move_operand")      ;; val out
10050    (match_operand:SI 2 "const_int_operand")]            ;; model
10051   ""
10053   enum memmodel model;
10055   if (TARGET_SYNC_LIBCALL)
10056     {
10057       rtx mem = operands[0];
10058       rtx val = operands[1];
10059       if (pa_maybe_emit_compare_and_swap_exchange_loop (NULL_RTX, mem, val))
10060         DONE;
10061     }
10063   if (TARGET_64BIT || TARGET_DISABLE_FPREGS || TARGET_SOFT_FLOAT)
10064     FAIL;
10066   model = memmodel_from_int (INTVAL (operands[2]));
10067   operands[0] = force_reg (SImode, XEXP (operands[0], 0));
10068   if (operands[1] != CONST0_RTX (DImode))
10069     operands[1] = force_reg (DImode, operands[1]);
10070   expand_mem_thread_fence (model);
10071   emit_insn (gen_atomic_storedi_1 (operands[0], operands[1]));
10072   if (is_mm_seq_cst (model))
10073     expand_mem_thread_fence (model);
10074   DONE;
10077 (define_insn "atomic_storedi_1"
10078   [(set (mem:DI (match_operand:SI 0 "register_operand" "r,r"))
10079         (match_operand:DI 1 "reg_or_0_operand" "M,r"))
10080    (clobber (match_scratch:DI 2 "=X,f"))]
10081   "!TARGET_64BIT && !TARGET_DISABLE_FPREGS && !TARGET_SOFT_FLOAT"
10082   "@
10083    {fstds|fstd} %%fr0,0(%0)
10084    {stws|stw} %1,-16(%%sp)\n\t{stws|stw} %R1,-12(%%sp)\n\t{fldds|fldd} -16(%%sp),%2\n\t{fstds|fstd} %2,0(%0)"
10085   [(set_attr "type" "move,move")
10086    (set_attr "length" "4,16")])
10088 ;; PA 2.0 hardware supports out-of-order execution of loads and stores, so
10089 ;; we need memory barriers to enforce program order for memory references
10090 ;; when the TLB and PSW O bits are not set.  We assume all PA 2.0 systems
10091 ;; are weakly ordered since neither HP-UX or Linux set the PSW O bit.  Since
10092 ;; we want PA 1.x code to be PA 2.0 compatible, we also need barriers when
10093 ;; generating PA 1.x code even though all PA 1.x systems are strongly ordered.
10095 ;; When barriers are needed, we use a strongly ordered ldcw instruction as
10096 ;; the barrier.  Most PA 2.0 targets are cache coherent.  In that case, we
10097 ;; can use the coherent cache control hint and avoid aligning the ldcw
10098 ;; address.  In spite of its description, it is not clear that the sync
10099 ;; instruction works as a barrier.
10101 (define_expand "memory_barrier"
10102   [(parallel
10103      [(set (match_dup 0) (unspec:BLK [(match_dup 0)] UNSPEC_MEMORY_BARRIER))
10104       (clobber (match_dup 1))])]
10105   ""
10107   /* We don't need a barrier if the target uses ordered memory references.  */
10108   if (TARGET_ORDERED)
10109     FAIL;
10110   operands[1] = gen_reg_rtx (Pmode);
10111   operands[0] = gen_rtx_MEM (BLKmode, operands[1]);
10112   MEM_VOLATILE_P (operands[0]) = 1;
10115 (define_insn "*memory_barrier_coherent"
10116   [(set (match_operand:BLK 0 "" "")
10117         (unspec:BLK [(match_dup 0)] UNSPEC_MEMORY_BARRIER))
10118    (clobber (match_operand 1 "pmode_register_operand" "=r"))]
10119   "TARGET_PA_20 && TARGET_COHERENT_LDCW"
10120   "ldcw,co 0(%%sp),%1"
10121   [(set_attr "type" "binary")
10122    (set_attr "length" "4")])
10124 (define_insn "*memory_barrier_64"
10125   [(set (match_operand:BLK 0 "" "")
10126         (unspec:BLK [(match_dup 0)] UNSPEC_MEMORY_BARRIER))
10127     (clobber (match_operand 1 "pmode_register_operand" "=&r"))]
10128   "TARGET_64BIT"
10129   "ldo 15(%%sp),%1\n\tdepd %%r0,63,3,%1\n\tldcw 0(%1),%1"
10130   [(set_attr "type" "binary")
10131    (set_attr "length" "12")])
10133 (define_insn "*memory_barrier_32"
10134   [(set (match_operand:BLK 0 "" "")
10135         (unspec:BLK [(match_dup 0)] UNSPEC_MEMORY_BARRIER))
10136     (clobber (match_operand 1 "pmode_register_operand" "=&r"))]
10137   ""
10138   "ldo 15(%%sp),%1\n\t{dep|depw} %%r0,31,3,%1\n\tldcw 0(%1),%1"
10139   [(set_attr "type" "binary")
10140    (set_attr "length" "12")])