Add support for 32-bit hppa targets in muldi3 expander
[official-gcc.git] / gcc / config / pa / pa.md
blob10623dd6fdbf5da5bd267ac380936f12ac6ea9e1
1 ;;- Machine description for HP PA-RISC architecture for GCC compiler
2 ;;   Copyright (C) 1992-2021 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   "! optimize_size
5378    && TARGET_PA_11
5379    && ! TARGET_DISABLE_FPREGS
5380    && ! TARGET_SOFT_FLOAT"
5381   "
5383   rtx low_product = gen_reg_rtx (DImode);
5384   rtx cross_product1 = gen_reg_rtx (DImode);
5385   rtx cross_product2 = gen_reg_rtx (DImode);
5386   rtx op1l, op1r, op2l, op2r;
5388   if (TARGET_64BIT)
5389     {
5390       rtx op1shifted = gen_reg_rtx (DImode);
5391       rtx op2shifted = gen_reg_rtx (DImode);
5393       emit_move_insn (op1shifted, gen_rtx_LSHIFTRT (DImode, operands[1],
5394                                                     GEN_INT (32)));
5395       emit_move_insn (op2shifted, gen_rtx_LSHIFTRT (DImode, operands[2],
5396                                                     GEN_INT (32)));
5397       op1r = force_reg (SImode, gen_rtx_SUBREG (SImode, operands[1], 4));
5398       op2r = force_reg (SImode, gen_rtx_SUBREG (SImode, operands[2], 4));
5399       op1l = force_reg (SImode, gen_rtx_SUBREG (SImode, op1shifted, 4));
5400       op2l = force_reg (SImode, gen_rtx_SUBREG (SImode, op2shifted, 4));
5401     }
5402   else
5403     {
5404       op1r = force_reg (SImode, gen_lowpart (SImode, operands[1]));
5405       op2r = force_reg (SImode, gen_lowpart (SImode, operands[2]));
5406       op1l = force_reg (SImode, gen_highpart (SImode, operands[1]));
5407       op2l = force_reg (SImode, gen_highpart (SImode, operands[2]));
5408     }
5410   /* Emit multiplies for the cross products.  */
5411   emit_insn (gen_umulsidi3 (cross_product1, op2r, op1l));
5412   emit_insn (gen_umulsidi3 (cross_product2, op2l, op1r));
5414   /* Emit a multiply for the low sub-word.  */
5415   emit_insn (gen_umulsidi3 (low_product, copy_rtx (op2r), copy_rtx (op1r)));
5417   if (TARGET_64BIT)
5418     {
5419       rtx cross_scratch = gen_reg_rtx (DImode);
5420       rtx cross_product = gen_reg_rtx (DImode);
5422       /* Sum the cross products and shift them into proper position.  */
5423       emit_insn (gen_adddi3 (cross_scratch, cross_product1, cross_product2));
5424       emit_insn (gen_ashldi3 (cross_product, cross_scratch, GEN_INT (32)));
5426       /* Add the cross product to the low product and store the result
5427          into the output operand .  */
5428       emit_insn (gen_adddi3 (operands[0], cross_product, low_product));
5429     }
5430   else
5431     {
5432       rtx cross_scratch = gen_reg_rtx (SImode);
5434       /* Sum cross products.  */
5435       emit_move_insn (cross_scratch,
5436                       gen_rtx_PLUS (SImode,
5437                                     gen_lowpart (SImode, cross_product1),
5438                                     gen_lowpart (SImode, cross_product2)));
5439       emit_move_insn (gen_lowpart (SImode, operands[0]),
5440                       gen_lowpart (SImode, low_product));
5441       emit_move_insn (gen_highpart (SImode, operands[0]),
5442                       gen_rtx_PLUS (SImode,
5443                                     gen_highpart (SImode, low_product),
5444                                     cross_scratch));
5445     }
5446   DONE;
5449 ;;; Division and mod.
5450 (define_expand "divsi3"
5451   [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5452    (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5453    (parallel [(set (reg:SI 29) (div:SI (reg:SI 26) (reg:SI 25)))
5454               (clobber (match_dup 3))
5455               (clobber (match_dup 4))
5456               (clobber (reg:SI 26))
5457               (clobber (reg:SI 25))
5458               (clobber (match_dup 5))])
5459    (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5460   ""
5461   "
5463   operands[3] = gen_reg_rtx (SImode);
5464   if (TARGET_64BIT)
5465     {
5466       operands[5] = gen_rtx_REG (SImode, 2);
5467       operands[4] = operands[5];
5468     }
5469   else
5470     {
5471       operands[5] = gen_rtx_REG (SImode, 31);
5472       operands[4] = gen_reg_rtx (SImode);
5473     }
5474   if (GET_CODE (operands[2]) == CONST_INT && pa_emit_hpdiv_const (operands, 0))
5475     DONE;
5478 (define_insn ""
5479   [(set (reg:SI 29)
5480         (div:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5481    (clobber (match_operand:SI 1 "register_operand" "=a"))
5482    (clobber (match_operand:SI 2 "register_operand" "=&r"))
5483    (clobber (reg:SI 26))
5484    (clobber (reg:SI 25))
5485    (clobber (reg:SI 31))]
5486   "!TARGET_64BIT"
5487   "*
5488    return pa_output_div_insn (operands, 0, insn);"
5489   [(set_attr "type" "milli")
5490    (set (attr "length")
5491         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5492               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5494 (define_insn ""
5495   [(set (reg:SI 29)
5496         (div:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5497    (clobber (match_operand:SI 1 "register_operand" "=a"))
5498    (clobber (match_operand:SI 2 "register_operand" "=&r"))
5499    (clobber (reg:SI 26))
5500    (clobber (reg:SI 25))
5501    (clobber (reg:SI 2))]
5502   "TARGET_64BIT"
5503   "*
5504    return pa_output_div_insn (operands, 0, insn);"
5505   [(set_attr "type" "milli")
5506    (set (attr "length")
5507         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5508               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5510 (define_expand "udivsi3"
5511   [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5512    (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5513    (parallel [(set (reg:SI 29) (udiv:SI (reg:SI 26) (reg:SI 25)))
5514               (clobber (match_dup 3))
5515               (clobber (match_dup 4))
5516               (clobber (reg:SI 26))
5517               (clobber (reg:SI 25))
5518               (clobber (match_dup 5))])
5519    (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5520   ""
5521   "
5523   operands[3] = gen_reg_rtx (SImode);
5525   if (TARGET_64BIT)
5526     {
5527       operands[5] = gen_rtx_REG (SImode, 2);
5528       operands[4] = operands[5];
5529     }
5530   else
5531     {
5532       operands[5] = gen_rtx_REG (SImode, 31);
5533       operands[4] = gen_reg_rtx (SImode);
5534     }
5535   if (GET_CODE (operands[2]) == CONST_INT && pa_emit_hpdiv_const (operands, 1))
5536     DONE;
5539 (define_insn ""
5540   [(set (reg:SI 29)
5541         (udiv:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5542    (clobber (match_operand:SI 1 "register_operand" "=a"))
5543    (clobber (match_operand:SI 2 "register_operand" "=&r"))
5544    (clobber (reg:SI 26))
5545    (clobber (reg:SI 25))
5546    (clobber (reg:SI 31))]
5547   "!TARGET_64BIT"
5548   "*
5549    return pa_output_div_insn (operands, 1, insn);"
5550   [(set_attr "type" "milli")
5551    (set (attr "length")
5552         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5553               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5555 (define_insn ""
5556   [(set (reg:SI 29)
5557         (udiv:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5558    (clobber (match_operand:SI 1 "register_operand" "=a"))
5559    (clobber (match_operand:SI 2 "register_operand" "=&r"))
5560    (clobber (reg:SI 26))
5561    (clobber (reg:SI 25))
5562    (clobber (reg:SI 2))]
5563   "TARGET_64BIT"
5564   "*
5565    return pa_output_div_insn (operands, 1, insn);"
5566   [(set_attr "type" "milli")
5567    (set (attr "length")
5568         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5569               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5571 (define_expand "modsi3"
5572   [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5573    (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5574    (parallel [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
5575               (clobber (match_dup 3))
5576               (clobber (match_dup 4))
5577               (clobber (reg:SI 26))
5578               (clobber (reg:SI 25))
5579               (clobber (match_dup 5))])
5580    (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5581   ""
5582   "
5584   if (TARGET_64BIT)
5585     {
5586       operands[5] = gen_rtx_REG (SImode, 2);
5587       operands[4] = operands[5];
5588     }
5589   else
5590     {
5591       operands[5] = gen_rtx_REG (SImode, 31);
5592       operands[4] = gen_reg_rtx (SImode);
5593     }
5594   operands[3] = gen_reg_rtx (SImode);
5597 (define_insn ""
5598   [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
5599    (clobber (match_operand:SI 0 "register_operand" "=a"))
5600    (clobber (match_operand:SI 1 "register_operand" "=&r"))
5601    (clobber (reg:SI 26))
5602    (clobber (reg:SI 25))
5603    (clobber (reg:SI 31))]
5604   "!TARGET_64BIT"
5605   "*
5606   return pa_output_mod_insn (0, insn);"
5607   [(set_attr "type" "milli")
5608    (set (attr "length")
5609         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5610               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5612 (define_insn ""
5613   [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
5614    (clobber (match_operand:SI 0 "register_operand" "=a"))
5615    (clobber (match_operand:SI 1 "register_operand" "=&r"))
5616    (clobber (reg:SI 26))
5617    (clobber (reg:SI 25))
5618    (clobber (reg:SI 2))]
5619   "TARGET_64BIT"
5620   "*
5621   return pa_output_mod_insn (0, insn);"
5622   [(set_attr "type" "milli")
5623    (set (attr "length")
5624         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5625               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5627 (define_expand "umodsi3"
5628   [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5629    (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5630    (parallel [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
5631               (clobber (match_dup 3))
5632               (clobber (match_dup 4))
5633               (clobber (reg:SI 26))
5634               (clobber (reg:SI 25))
5635               (clobber (match_dup 5))])
5636    (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5637   ""
5638   "
5640   if (TARGET_64BIT)
5641     {
5642       operands[5] = gen_rtx_REG (SImode, 2);
5643       operands[4] = operands[5];
5644     }
5645   else
5646     {
5647       operands[5] = gen_rtx_REG (SImode, 31);
5648       operands[4] = gen_reg_rtx (SImode);
5649     }
5650   operands[3] = gen_reg_rtx (SImode);
5653 (define_insn ""
5654   [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
5655    (clobber (match_operand:SI 0 "register_operand" "=a"))
5656    (clobber (match_operand:SI 1 "register_operand" "=&r"))
5657    (clobber (reg:SI 26))
5658    (clobber (reg:SI 25))
5659    (clobber (reg:SI 31))]
5660   "!TARGET_64BIT"
5661   "*
5662   return pa_output_mod_insn (1, insn);"
5663   [(set_attr "type" "milli")
5664    (set (attr "length")
5665         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5666               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5668 (define_insn ""
5669   [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
5670    (clobber (match_operand:SI 0 "register_operand" "=a"))
5671    (clobber (match_operand:SI 1 "register_operand" "=&r"))
5672    (clobber (reg:SI 26))
5673    (clobber (reg:SI 25))
5674    (clobber (reg:SI 2))]
5675   "TARGET_64BIT"
5676   "*
5677   return pa_output_mod_insn (1, insn);"
5678   [(set_attr "type" "milli")
5679    (set (attr "length")
5680         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5681               (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5683 ;;- and instructions
5684 ;; We define DImode `and` so with DImode `not` we can get
5685 ;; DImode `andn`.  Other combinations are possible.
5687 (define_expand "anddi3"
5688   [(set (match_operand:DI 0 "register_operand" "")
5689         (and:DI (match_operand:DI 1 "register_operand" "")
5690                 (match_operand:DI 2 "and_operand" "")))]
5691   "TARGET_64BIT"
5692   "")
5694 (define_insn ""
5695   [(set (match_operand:DI 0 "register_operand" "=r,r")
5696         (and:DI (match_operand:DI 1 "register_operand" "%?r,0")
5697                 (match_operand:DI 2 "and_operand" "rO,P")))]
5698   "TARGET_64BIT"
5699   "* return pa_output_64bit_and (operands); "
5700   [(set_attr "type" "binary")
5701    (set_attr "length" "4")])
5703 ; The ? for op1 makes reload prefer zdepi instead of loading a huge
5704 ; constant with ldil;ldo.
5705 (define_insn "andsi3"
5706   [(set (match_operand:SI 0 "register_operand" "=r,r")
5707         (and:SI (match_operand:SI 1 "register_operand" "%?r,0")
5708                 (match_operand:SI 2 "and_operand" "rO,P")))]
5709   ""
5710   "* return pa_output_and (operands); "
5711   [(set_attr "type" "binary,shift")
5712    (set_attr "length" "4,4")])
5714 (define_insn ""
5715   [(set (match_operand:DI 0 "register_operand" "=r")
5716         (and:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
5717                 (match_operand:DI 2 "register_operand" "r")))]
5718   "TARGET_64BIT"
5719   "andcm %2,%1,%0"
5720   [(set_attr "type" "binary")
5721    (set_attr "length" "4")])
5723 (define_insn ""
5724   [(set (match_operand:SI 0 "register_operand" "=r")
5725         (and:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
5726                 (match_operand:SI 2 "register_operand" "r")))]
5727   ""
5728   "andcm %2,%1,%0"
5729   [(set_attr "type" "binary")
5730   (set_attr "length" "4")])
5732 (define_expand "iordi3"
5733   [(set (match_operand:DI 0 "register_operand" "")
5734         (ior:DI (match_operand:DI 1 "register_operand" "")
5735                 (match_operand:DI 2 "reg_or_cint_ior_operand" "")))]
5736   "TARGET_64BIT"
5737   "")
5739 (define_insn ""
5740   [(set (match_operand:DI 0 "register_operand" "=r,r")
5741         (ior:DI (match_operand:DI 1 "register_operand" "0,0")
5742                 (match_operand:DI 2 "cint_ior_operand" "M,i")))]
5743   "TARGET_64BIT"
5744   "* return pa_output_64bit_ior (operands); "
5745   [(set_attr "type" "binary,shift")
5746    (set_attr "length" "4,4")])
5748 (define_insn ""
5749   [(set (match_operand:DI 0 "register_operand" "=r")
5750         (ior:DI (match_operand:DI 1 "register_operand" "%r")
5751                 (match_operand:DI 2 "register_operand" "r")))]
5752   "TARGET_64BIT"
5753   "or %1,%2,%0"
5754   [(set_attr "type" "binary")
5755    (set_attr "length" "4")])
5757 ;; Need a define_expand because we've run out of CONST_OK... characters.
5758 (define_expand "iorsi3"
5759   [(set (match_operand:SI 0 "register_operand" "")
5760         (ior:SI (match_operand:SI 1 "register_operand" "")
5761                 (match_operand:SI 2 "reg_or_cint_ior_operand" "")))]
5762   ""
5763   "")
5765 (define_insn ""
5766   [(set (match_operand:SI 0 "register_operand" "=r,r")
5767         (ior:SI (match_operand:SI 1 "register_operand" "0,0")
5768                 (match_operand:SI 2 "cint_ior_operand" "M,i")))]
5769   ""
5770   "* return pa_output_ior (operands); "
5771   [(set_attr "type" "binary,shift")
5772    (set_attr "length" "4,4")])
5774 (define_insn ""
5775   [(set (match_operand:SI 0 "register_operand" "=r")
5776         (ior:SI (match_operand:SI 1 "register_operand" "%r")
5777                 (match_operand:SI 2 "register_operand" "r")))]
5778   ""
5779   "or %1,%2,%0"
5780   [(set_attr "type" "binary")
5781    (set_attr "length" "4")])
5783 (define_expand "xordi3"
5784   [(set (match_operand:DI 0 "register_operand" "")
5785         (xor:DI (match_operand:DI 1 "register_operand" "")
5786                 (match_operand:DI 2 "register_operand" "")))]
5787   "TARGET_64BIT"
5788   "")
5790 (define_insn ""
5791   [(set (match_operand:DI 0 "register_operand" "=r")
5792         (xor:DI (match_operand:DI 1 "register_operand" "%r")
5793                 (match_operand:DI 2 "register_operand" "r")))]
5794   "TARGET_64BIT"
5795   "xor %1,%2,%0"
5796   [(set_attr "type" "binary")
5797    (set_attr "length" "4")])
5799 (define_insn "xorsi3"
5800   [(set (match_operand:SI 0 "register_operand" "=r")
5801         (xor:SI (match_operand:SI 1 "register_operand" "%r")
5802                 (match_operand:SI 2 "register_operand" "r")))]
5803   ""
5804   "xor %1,%2,%0"
5805   [(set_attr "type" "binary")
5806    (set_attr "length" "4")])
5808 (define_expand "negdi2"
5809   [(set (match_operand:DI 0 "register_operand" "")
5810         (neg:DI (match_operand:DI 1 "register_operand" "")))]
5811   ""
5812   "")
5814 (define_insn ""
5815   [(set (match_operand:DI 0 "register_operand" "=r")
5816         (neg:DI (match_operand:DI 1 "register_operand" "r")))]
5817   "!TARGET_64BIT"
5818   "sub %%r0,%R1,%R0\;{subb|sub,b} %%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   "TARGET_64BIT"
5826   "sub %%r0,%1,%0"
5827   [(set_attr "type" "unary")
5828    (set_attr "length" "4")])
5830 (define_expand "negvdi2"
5831   [(parallel [(set (match_operand:DI 0 "register_operand" "")
5832                    (neg:DI (match_operand:DI 1 "register_operand" "")))
5833               (trap_if (ne (neg:TI (sign_extend:TI (match_dup 1)))
5834                                    (sign_extend:TI (neg:DI (match_dup 1))))
5835                        (const_int 0))])]
5836   ""
5837   "")
5839 (define_insn ""
5840   [(set (match_operand:DI 0 "register_operand" "=r")
5841         (neg:DI (match_operand:DI 1 "register_operand" "r")))
5842    (trap_if (ne (neg:TI (sign_extend:TI (match_dup 1)))
5843                 (sign_extend:TI (neg:DI (match_dup 1))))
5844             (const_int 0))]
5845   "!TARGET_64BIT"
5846   "sub %%r0,%R1,%R0\;{subbo|sub,b,tsv} %%r0,%1,%0"
5847   [(set_attr "type" "unary")
5848    (set_attr "length" "8")])
5850 (define_insn ""
5851   [(set (match_operand:DI 0 "register_operand" "=r")
5852         (neg:DI (match_operand:DI 1 "register_operand" "r")))
5853    (trap_if (ne (neg:TI (sign_extend:TI (match_dup 1)))
5854                 (sign_extend:TI (neg:DI (match_dup 1))))
5855             (const_int 0))]
5856   "TARGET_64BIT"
5857   "sub,tsv %%r0,%1,%0"
5858   [(set_attr "type" "unary")
5859    (set_attr "length" "4")])
5861 (define_insn "negsi2"
5862   [(set (match_operand:SI 0 "register_operand" "=r")
5863         (neg:SI (match_operand:SI 1 "register_operand" "r")))]
5864   ""
5865   "sub %%r0,%1,%0"
5866   [(set_attr "type" "unary")
5867    (set_attr "length" "4")])
5869 (define_insn "negvsi2"
5870   [(set (match_operand:SI 0 "register_operand" "=r")
5871         (neg:SI (match_operand:SI 1 "register_operand" "r")))
5872    (trap_if (ne (neg:DI (sign_extend:DI (match_dup 1)))
5873                 (sign_extend:DI (neg:SI (match_dup 1))))
5874             (const_int 0))]
5875    ""
5876    "{subo|sub,tsv} %%r0,%1,%0"
5877   [(set_attr "type" "unary")
5878    (set_attr "length" "4")])
5880 (define_expand "one_cmpldi2"
5881   [(set (match_operand:DI 0 "register_operand" "")
5882         (not:DI (match_operand:DI 1 "register_operand" "")))]
5883   ""
5884   "
5888 (define_insn ""
5889   [(set (match_operand:DI 0 "register_operand" "=r")
5890         (not:DI (match_operand:DI 1 "register_operand" "r")))]
5891   "!TARGET_64BIT"
5892   "uaddcm %%r0,%1,%0\;uaddcm %%r0,%R1,%R0"
5893   [(set_attr "type" "unary")
5894    (set_attr "length" "8")])
5896 (define_insn ""
5897   [(set (match_operand:DI 0 "register_operand" "=r")
5898         (not:DI (match_operand:DI 1 "register_operand" "r")))]
5899   "TARGET_64BIT"
5900   "uaddcm %%r0,%1,%0"
5901   [(set_attr "type" "unary")
5902    (set_attr "length" "4")])
5904 (define_insn "one_cmplsi2"
5905   [(set (match_operand:SI 0 "register_operand" "=r")
5906         (not:SI (match_operand:SI 1 "register_operand" "r")))]
5907   ""
5908   "uaddcm %%r0,%1,%0"
5909   [(set_attr "type" "unary")
5910    (set_attr "length" "4")])
5912 ;; Floating point arithmetic instructions.
5914 (define_insn "adddf3"
5915   [(set (match_operand:DF 0 "register_operand" "=f")
5916         (plus:DF (match_operand:DF 1 "register_operand" "f")
5917                  (match_operand:DF 2 "register_operand" "f")))]
5918   "! TARGET_SOFT_FLOAT"
5919   "fadd,dbl %1,%2,%0"
5920   [(set_attr "type" "fpalu")
5921    (set_attr "pa_combine_type" "faddsub")
5922    (set_attr "length" "4")])
5924 (define_insn "addsf3"
5925   [(set (match_operand:SF 0 "register_operand" "=f")
5926         (plus:SF (match_operand:SF 1 "register_operand" "f")
5927                  (match_operand:SF 2 "register_operand" "f")))]
5928   "! TARGET_SOFT_FLOAT"
5929   "fadd,sgl %1,%2,%0"
5930   [(set_attr "type" "fpalu")
5931    (set_attr "pa_combine_type" "faddsub")
5932    (set_attr "length" "4")])
5934 (define_insn "subdf3"
5935   [(set (match_operand:DF 0 "register_operand" "=f")
5936         (minus:DF (match_operand:DF 1 "register_operand" "f")
5937                   (match_operand:DF 2 "register_operand" "f")))]
5938   "! TARGET_SOFT_FLOAT"
5939   "fsub,dbl %1,%2,%0"
5940   [(set_attr "type" "fpalu")
5941    (set_attr "pa_combine_type" "faddsub")
5942    (set_attr "length" "4")])
5944 (define_insn "subsf3"
5945   [(set (match_operand:SF 0 "register_operand" "=f")
5946         (minus:SF (match_operand:SF 1 "register_operand" "f")
5947                   (match_operand:SF 2 "register_operand" "f")))]
5948   "! TARGET_SOFT_FLOAT"
5949   "fsub,sgl %1,%2,%0"
5950   [(set_attr "type" "fpalu")
5951    (set_attr "pa_combine_type" "faddsub")
5952    (set_attr "length" "4")])
5954 (define_insn "muldf3"
5955   [(set (match_operand:DF 0 "register_operand" "=f")
5956         (mult:DF (match_operand:DF 1 "register_operand" "f")
5957                  (match_operand:DF 2 "register_operand" "f")))]
5958   "! TARGET_SOFT_FLOAT"
5959   "fmpy,dbl %1,%2,%0"
5960   [(set_attr "type" "fpmuldbl")
5961    (set_attr "pa_combine_type" "fmpy")
5962    (set_attr "length" "4")])
5964 (define_insn "mulsf3"
5965   [(set (match_operand:SF 0 "register_operand" "=f")
5966         (mult:SF (match_operand:SF 1 "register_operand" "f")
5967                  (match_operand:SF 2 "register_operand" "f")))]
5968   "! TARGET_SOFT_FLOAT"
5969   "fmpy,sgl %1,%2,%0"
5970   [(set_attr "type" "fpmulsgl")
5971    (set_attr "pa_combine_type" "fmpy")
5972    (set_attr "length" "4")])
5974 (define_insn "divdf3"
5975   [(set (match_operand:DF 0 "register_operand" "=f")
5976         (div:DF (match_operand:DF 1 "register_operand" "f")
5977                 (match_operand:DF 2 "register_operand" "f")))]
5978   "! TARGET_SOFT_FLOAT"
5979   "fdiv,dbl %1,%2,%0"
5980   [(set_attr "type" "fpdivdbl")
5981    (set_attr "length" "4")])
5983 (define_insn "divsf3"
5984   [(set (match_operand:SF 0 "register_operand" "=f")
5985         (div:SF (match_operand:SF 1 "register_operand" "f")
5986                 (match_operand:SF 2 "register_operand" "f")))]
5987   "! TARGET_SOFT_FLOAT"
5988   "fdiv,sgl %1,%2,%0"
5989   [(set_attr "type" "fpdivsgl")
5990    (set_attr "length" "4")])
5992 ;; Processors prior to PA 2.0 don't have a fneg instruction.  Fast
5993 ;; negation can be done by subtracting from plus zero.  However, this
5994 ;; violates the IEEE standard when negating plus and minus zero.
5995 ;; The slow path toggles the sign bit in the general registers.
5996 (define_expand "negdf2"
5997   [(set (match_operand:DF 0 "register_operand" "")
5998         (neg:DF (match_operand:DF 1 "register_operand" "")))]
5999   "!TARGET_SOFT_FLOAT"
6001   if (TARGET_PA_20 || !flag_signed_zeros)
6002     emit_insn (gen_negdf2_fast (operands[0], operands[1]));
6003   else
6004     emit_insn (gen_negdf2_slow (operands[0], operands[1]));
6005   DONE;
6008 (define_insn "negdf2_slow"
6009   [(set (match_operand:DF 0 "register_operand" "=r")
6010         (neg:DF (match_operand:DF 1 "register_operand" "r")))]
6011   "!TARGET_SOFT_FLOAT && !TARGET_PA_20"
6012   "*
6014   if (rtx_equal_p (operands[0], operands[1]))
6015     return \"and,< %1,%1,%0\;depi,tr 1,0,1,%0\;depi 0,0,1,%0\";
6016   else
6017     return \"and,< %1,%1,%0\;depi,tr 1,0,1,%0\;depi 0,0,1,%0\;copy %R1,%R0\";
6019   [(set_attr "type" "multi")
6020    (set (attr "length")
6021         (if_then_else (match_test "rtx_equal_p (operands[0], operands[1])")
6022             (const_int 12)
6023             (const_int 16)))])
6025 (define_insn "negdf2_fast"
6026   [(set (match_operand:DF 0 "register_operand" "=f")
6027         (neg:DF (match_operand:DF 1 "register_operand" "f")))]
6028   "!TARGET_SOFT_FLOAT"
6029   "*
6031   if (TARGET_PA_20)
6032     return \"fneg,dbl %1,%0\";
6033   else
6034     return \"fsub,dbl %%fr0,%1,%0\";
6036   [(set_attr "type" "fpalu")
6037    (set_attr "length" "4")])
6039 (define_expand "negsf2"
6040   [(set (match_operand:SF 0 "register_operand" "")
6041         (neg:SF (match_operand:SF 1 "register_operand" "")))]
6042   "!TARGET_SOFT_FLOAT"
6044   if (TARGET_PA_20 || !flag_signed_zeros)
6045     emit_insn (gen_negsf2_fast (operands[0], operands[1]));
6046   else
6047     emit_insn (gen_negsf2_slow (operands[0], operands[1]));
6048   DONE;
6051 (define_insn "negsf2_slow"
6052   [(set (match_operand:SF 0 "register_operand" "=r")
6053         (neg:SF (match_operand:SF 1 "register_operand" "r")))]
6054   "!TARGET_SOFT_FLOAT && !TARGET_PA_20"
6055   "and,< %1,%1,%0\;depi,tr 1,0,1,%0\;depi 0,0,1,%0"
6056   [(set_attr "type" "multi")
6057    (set_attr "length" "12")])
6059 (define_insn "negsf2_fast"
6060   [(set (match_operand:SF 0 "register_operand" "=f")
6061         (neg:SF (match_operand:SF 1 "register_operand" "f")))]
6062   "!TARGET_SOFT_FLOAT"
6063   "*
6065   if (TARGET_PA_20)
6066     return \"fneg,sgl %1,%0\";
6067   else
6068     return \"fsub,sgl %%fr0,%1,%0\";
6070   [(set_attr "type" "fpalu")
6071    (set_attr "length" "4")])
6073 (define_insn "absdf2"
6074   [(set (match_operand:DF 0 "register_operand" "=f")
6075         (abs:DF (match_operand:DF 1 "register_operand" "f")))]
6076   "! TARGET_SOFT_FLOAT"
6077   "fabs,dbl %1,%0"
6078   [(set_attr "type" "fpalu")
6079    (set_attr "length" "4")])
6081 (define_insn "abssf2"
6082   [(set (match_operand:SF 0 "register_operand" "=f")
6083         (abs:SF (match_operand:SF 1 "register_operand" "f")))]
6084   "! TARGET_SOFT_FLOAT"
6085   "fabs,sgl %1,%0"
6086   [(set_attr "type" "fpalu")
6087    (set_attr "length" "4")])
6089 (define_insn "sqrtdf2"
6090   [(set (match_operand:DF 0 "register_operand" "=f")
6091         (sqrt:DF (match_operand:DF 1 "register_operand" "f")))]
6092   "! TARGET_SOFT_FLOAT"
6093   "fsqrt,dbl %1,%0"
6094   [(set_attr "type" "fpsqrtdbl")
6095    (set_attr "length" "4")])
6097 (define_insn "sqrtsf2"
6098   [(set (match_operand:SF 0 "register_operand" "=f")
6099         (sqrt:SF (match_operand:SF 1 "register_operand" "f")))]
6100   "! TARGET_SOFT_FLOAT"
6101   "fsqrt,sgl %1,%0"
6102   [(set_attr "type" "fpsqrtsgl")
6103    (set_attr "length" "4")])
6105 ;; PA 2.0 floating point instructions
6107 ; fmpyfadd patterns
6108 (define_insn "fmadf4"
6109   [(set (match_operand:DF 0 "register_operand" "=f")
6110         (fma:DF (match_operand:DF 1 "register_operand" "f")
6111                 (match_operand:DF 2 "register_operand" "f")
6112                 (match_operand:DF 3 "register_operand" "f")))]
6113   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6114   "fmpyfadd,dbl %1,%2,%3,%0"
6115   [(set_attr "type" "fpmuldbl")
6116    (set_attr "length" "4")])
6118 (define_insn "fmasf4"
6119   [(set (match_operand:SF 0 "register_operand" "=f")
6120         (fma:SF (match_operand:SF 1 "register_operand" "f")
6121                 (match_operand:SF 2 "register_operand" "f")
6122                 (match_operand:SF 3 "register_operand" "f")))]
6123   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6124   "fmpyfadd,sgl %1,%2,%3,%0"
6125   [(set_attr "type" "fpmulsgl")
6126    (set_attr "length" "4")])
6128 ; fmpynfadd patterns
6129 (define_insn "fnmadf4"
6130   [(set (match_operand:DF 0 "register_operand" "=f")
6131         (fma:DF (neg:DF (match_operand:DF 1 "register_operand" "f"))
6132                 (match_operand:DF 2 "register_operand" "f")
6133                 (match_operand:DF 3 "register_operand" "f")))]
6134   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6135   "fmpynfadd,dbl %1,%2,%3,%0"
6136   [(set_attr "type" "fpmuldbl")
6137    (set_attr "length" "4")])
6139 (define_insn "fnmasf4"
6140   [(set (match_operand:SF 0 "register_operand" "=f")
6141         (fma:SF (neg:SF (match_operand:SF 1 "register_operand" "f"))
6142                 (match_operand:SF 2 "register_operand" "f")
6143                 (match_operand:SF 3 "register_operand" "f")))]
6144   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6145   "fmpynfadd,sgl %1,%2,%3,%0"
6146   [(set_attr "type" "fpmulsgl")
6147    (set_attr "length" "4")])
6149 ; fnegabs patterns
6150 (define_insn ""
6151   [(set (match_operand:DF 0 "register_operand" "=f")
6152         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))]
6153   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6154   "fnegabs,dbl %1,%0"
6155   [(set_attr "type" "fpalu")
6156    (set_attr "length" "4")])
6158 (define_insn ""
6159   [(set (match_operand:SF 0 "register_operand" "=f")
6160         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))]
6161   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6162   "fnegabs,sgl %1,%0"
6163   [(set_attr "type" "fpalu")
6164    (set_attr "length" "4")])
6166 (define_insn ""
6167   [(set (match_operand:DF 0 "register_operand" "=f")
6168         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))
6169    (set (match_operand:DF 2 "register_operand" "=&f") (abs:DF (match_dup 1)))]
6170   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6171     && ! reg_overlap_mentioned_p (operands[2], operands[1]))"
6172   "#"
6173   [(set_attr "type" "fpalu")
6174    (set_attr "length" "8")])
6176 (define_split
6177   [(set (match_operand:DF 0 "register_operand" "")
6178         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" ""))))
6179    (set (match_operand:DF 2 "register_operand" "") (abs:DF (match_dup 1)))]
6180   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6181   [(set (match_dup 2) (abs:DF (match_dup 1)))
6182    (set (match_dup 0) (neg:DF (abs:DF (match_dup 1))))]
6183   "")
6185 (define_insn ""
6186   [(set (match_operand:SF 0 "register_operand" "=f")
6187         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))
6188    (set (match_operand:SF 2 "register_operand" "=&f") (abs:SF (match_dup 1)))]
6189   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6190     && ! reg_overlap_mentioned_p (operands[2], operands[1]))"
6191   "#"
6192   [(set_attr "type" "fpalu")
6193    (set_attr "length" "8")])
6195 (define_split
6196   [(set (match_operand:SF 0 "register_operand" "")
6197         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" ""))))
6198    (set (match_operand:SF 2 "register_operand" "") (abs:SF (match_dup 1)))]
6199   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6200   [(set (match_dup 2) (abs:SF (match_dup 1)))
6201    (set (match_dup 0) (neg:SF (abs:SF (match_dup 1))))]
6202   "")
6204 ;; Negating a multiply can be faked by adding zero in a fused multiply-add
6205 ;; instruction if we can ignore the sign of zero.
6206 (define_insn ""
6207   [(set (match_operand:DF 0 "register_operand" "=f")
6208         (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
6209                          (match_operand:DF 2 "register_operand" "f"))))]
6210   "!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros"
6211   "fmpynfadd,dbl %1,%2,%%fr0,%0"
6212   [(set_attr "type" "fpmuldbl")
6213    (set_attr "length" "4")])
6215 (define_insn ""
6216   [(set (match_operand:SF 0 "register_operand" "=f")
6217         (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
6218                          (match_operand:SF 2 "register_operand" "f"))))]
6219   "!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros"
6220   "fmpynfadd,sgl %1,%2,%%fr0,%0"
6221   [(set_attr "type" "fpmuldbl")
6222    (set_attr "length" "4")])
6224 (define_insn ""
6225   [(set (match_operand:DF 0 "register_operand" "=f")
6226         (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
6227                          (match_operand:DF 2 "register_operand" "f"))))
6228    (set (match_operand:DF 3 "register_operand" "=&f")
6229         (mult:DF (match_dup 1) (match_dup 2)))]
6230   "(!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros
6231     && ! (reg_overlap_mentioned_p (operands[3], operands[1])
6232           || reg_overlap_mentioned_p (operands[3], operands[2])))"
6233   "#"
6234   [(set_attr "type" "fpmuldbl")
6235    (set_attr "length" "8")])
6237 (define_split
6238   [(set (match_operand:DF 0 "register_operand" "")
6239         (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "")
6240                          (match_operand:DF 2 "register_operand" ""))))
6241    (set (match_operand:DF 3 "register_operand" "")
6242         (mult:DF (match_dup 1) (match_dup 2)))]
6243   "!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros"
6244   [(set (match_dup 3) (mult:DF (match_dup 1) (match_dup 2)))
6245    (set (match_dup 0) (neg:DF (mult:DF (match_dup 1) (match_dup 2))))]
6246   "")
6248 (define_insn ""
6249   [(set (match_operand:SF 0 "register_operand" "=f")
6250         (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
6251                          (match_operand:SF 2 "register_operand" "f"))))
6252    (set (match_operand:SF 3 "register_operand" "=&f")
6253         (mult:SF (match_dup 1) (match_dup 2)))]
6254   "(!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros
6255     && ! (reg_overlap_mentioned_p (operands[3], operands[1])
6256           || reg_overlap_mentioned_p (operands[3], operands[2])))"
6257   "#"
6258   [(set_attr "type" "fpmuldbl")
6259    (set_attr "length" "8")])
6261 (define_split
6262   [(set (match_operand:SF 0 "register_operand" "")
6263         (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "")
6264                          (match_operand:SF 2 "register_operand" ""))))
6265    (set (match_operand:SF 3 "register_operand" "")
6266         (mult:SF (match_dup 1) (match_dup 2)))]
6267   "!TARGET_SOFT_FLOAT && TARGET_PA_20&& !flag_signed_zeros"
6268   [(set (match_dup 3) (mult:SF (match_dup 1) (match_dup 2)))
6269    (set (match_dup 0) (neg:SF (mult:SF (match_dup 1) (match_dup 2))))]
6270   "")
6272 ;;- Shift instructions
6274 ;; Optimized special case of shifting.
6276 (define_insn ""
6277   [(set (match_operand:SI 0 "register_operand" "=r")
6278         (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
6279                      (const_int 24)))]
6280   ""
6281   "ldb%M1 %1,%0"
6282   [(set_attr "type" "load")
6283    (set_attr "length" "4")])
6285 (define_insn ""
6286   [(set (match_operand:SI 0 "register_operand" "=r")
6287         (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
6288                      (const_int 16)))]
6289   ""
6290   "ldh%M1 %1,%0"
6291   [(set_attr "type" "load")
6292    (set_attr "length" "4")])
6294 (define_insn ""
6295   [(set (match_operand:SI 0 "register_operand" "=r")
6296         (plus:SI (ashift:SI (match_operand:SI 2 "register_operand" "r")
6297                             (match_operand:SI 3 "shadd_operand" ""))
6298                  (match_operand:SI 1 "register_operand" "r")))]
6299   ""
6300   "{sh%o3addl %2,%1,%0|shladd,l %2,%o3,%1,%0} "
6301   [(set_attr "type" "binary")
6302    (set_attr "length" "4")])
6304 (define_insn ""
6305   [(set (match_operand:SI 0 "register_operand" "=r")
6306         (plus:SI (mult:SI (match_operand:SI 2 "register_operand" "r")
6307                           (match_operand:SI 3 "mem_shadd_operand" ""))
6308                  (match_operand:SI 1 "register_operand" "r")))]
6309   ""
6310   "*
6312   int shift_val = exact_log2 (INTVAL (operands[3]));
6313   operands[3] = GEN_INT (shift_val);
6314   return \"{sh%o3addl %2,%1,%0|shladd,l %2,%o3,%1,%0}\";
6316   [(set_attr "type" "binary")
6317    (set_attr "length" "4")])
6319 (define_insn ""
6320   [(set (match_operand:DI 0 "register_operand" "=r")
6321         (plus:DI (ashift:DI (match_operand:DI 2 "register_operand" "r")
6322                             (match_operand:DI 3 "shadd_operand" ""))
6323                  (match_operand:DI 1 "register_operand" "r")))]
6324   "TARGET_64BIT"
6325   "shladd,l %2,%o3,%1,%0"
6326   [(set_attr "type" "binary")
6327    (set_attr "length" "4")])
6329 (define_insn ""
6330   [(set (match_operand:DI 0 "register_operand" "=r")
6331         (plus:DI (mult:DI (match_operand:DI 2 "register_operand" "r")
6332                           (match_operand:DI 3 "mem_shadd_operand" ""))
6333                  (match_operand:DI 1 "register_operand" "r")))]
6334   "TARGET_64BIT"
6335   "*
6337   int shift_val = exact_log2 (INTVAL (operands[3]));
6338   operands[3] = GEN_INT (shift_val);
6339   return \"shladd,l %2,%o3,%1,%0\";
6341   [(set_attr "type" "binary")
6342    (set_attr "length" "4")])
6344 (define_expand "ashlsi3"
6345   [(set (match_operand:SI 0 "register_operand" "")
6346         (ashift:SI (match_operand:SI 1 "lhs_lshift_operand" "")
6347                    (match_operand:SI 2 "arith32_operand" "")))]
6348   ""
6349   "
6351   if (GET_CODE (operands[2]) != CONST_INT)
6352     {
6353       rtx temp = gen_reg_rtx (SImode);
6354       emit_insn (gen_subsi3 (temp, GEN_INT (31), operands[2]));
6355       if (GET_CODE (operands[1]) == CONST_INT)
6356         emit_insn (gen_zvdep_imm32 (operands[0], operands[1], temp));
6357       else
6358         emit_insn (gen_zvdep32 (operands[0], operands[1], temp));
6359       DONE;
6360     }
6361   /* Make sure both inputs are not constants,
6362      there are no patterns for that.  */
6363   operands[1] = force_reg (SImode, operands[1]);
6366 (define_insn ""
6367   [(set (match_operand:SI 0 "register_operand" "=r")
6368         (ashift:SI (match_operand:SI 1 "register_operand" "r")
6369                    (match_operand:SI 2 "const_int_operand" "n")))]
6370   ""
6371   "{zdep|depw,z} %1,%P2,%L2,%0"
6372   [(set_attr "type" "shift")
6373    (set_attr "length" "4")])
6375 ; Match cases of op1 a CONST_INT here that zvdep_imm32 doesn't handle.
6376 ; Doing it like this makes slightly better code since reload can
6377 ; replace a register with a known value in range -16..15 with a
6378 ; constant.  Ideally, we would like to merge zvdep32 and zvdep_imm32,
6379 ; but since we have no more CONST_OK... characters, that is not
6380 ; possible.
6381 (define_insn "zvdep32"
6382   [(set (match_operand:SI 0 "register_operand" "=r,r")
6383         (ashift:SI (match_operand:SI 1 "arith5_operand" "r,L")
6384                    (minus:SI (const_int 31)
6385                              (match_operand:SI 2 "register_operand" "q,q"))))]
6386   ""
6387   "@
6388    {zvdep %1,32,%0|depw,z %1,%%sar,32,%0}
6389    {zvdepi %1,32,%0|depwi,z %1,%%sar,32,%0}"
6390   [(set_attr "type" "shift,shift")
6391    (set_attr "length" "4,4")])
6393 (define_insn "zvdep_imm32"
6394   [(set (match_operand:SI 0 "register_operand" "=r")
6395         (ashift:SI (match_operand:SI 1 "lhs_lshift_cint_operand" "")
6396                    (minus:SI (const_int 31)
6397                              (match_operand:SI 2 "register_operand" "q"))))]
6398   ""
6399   "*
6401   unsigned HOST_WIDE_INT x = UINTVAL (operands[1]);
6402   operands[2] = GEN_INT (4 + exact_log2 ((x >> 4) + 1));
6403   operands[1] = GEN_INT ((x & 0xf) - 0x10);
6404   return \"{zvdepi %1,%2,%0|depwi,z %1,%%sar,%2,%0}\";
6406   [(set_attr "type" "shift")
6407    (set_attr "length" "4")])
6409 (define_insn "vdepi_ior"
6410   [(set (match_operand:SI 0 "register_operand" "=r")
6411         (ior:SI (ashift:SI (match_operand:SI 1 "const_int_operand" "")
6412                            (minus:SI (const_int 31)
6413                                      (match_operand:SI 2 "register_operand" "q")))
6414                 (match_operand:SI 3 "register_operand" "0")))]
6415   ; accept ...0001...1, can this be generalized?
6416   "exact_log2 (INTVAL (operands[1]) + 1) > 0"
6417   "*
6419   HOST_WIDE_INT x = INTVAL (operands[1]);
6420   operands[2] = GEN_INT (exact_log2 (x + 1));
6421   return \"{vdepi -1,%2,%0|depwi -1,%%sar,%2,%0}\";
6423   [(set_attr "type" "shift")
6424    (set_attr "length" "4")])
6426 (define_insn "vdepi_and"
6427   [(set (match_operand:SI 0 "register_operand" "=r")
6428         (and:SI (rotate:SI (match_operand:SI 1 "const_int_operand" "")
6429                            (minus:SI (const_int 31)
6430                                      (match_operand:SI 2 "register_operand" "q")))
6431                 (match_operand:SI 3 "register_operand" "0")))]
6432   ; this can be generalized...!
6433   "INTVAL (operands[1]) == -2"
6434   "*
6436   HOST_WIDE_INT x = INTVAL (operands[1]);
6437   operands[2] = GEN_INT (exact_log2 ((~x) + 1));
6438   return \"{vdepi 0,%2,%0|depwi 0,%%sar,%2,%0}\";
6440   [(set_attr "type" "shift")
6441    (set_attr "length" "4")])
6443 (define_expand "ashldi3"
6444   [(set (match_operand:DI 0 "register_operand" "")
6445         (ashift:DI (match_operand:DI 1 "lhs_lshift_operand" "")
6446                    (match_operand:DI 2 "arith32_operand" "")))]
6447   ""
6448   "
6450   if (!TARGET_64BIT)
6451     {
6452       if (REG_P (operands[0]) && GET_CODE (operands[2]) == CONST_INT)
6453         {
6454           unsigned HOST_WIDE_INT shift = UINTVAL (operands[2]);
6455           if (shift >= 1 && shift <= 31)
6456             {
6457               rtx dst = operands[0];
6458               rtx src = force_reg (DImode, operands[1]);
6459               emit_insn (gen_shd_internal (gen_highpart (SImode, dst),
6460                                            gen_lowpart (SImode, src),
6461                                            GEN_INT (32-shift),
6462                                            gen_highpart (SImode, src),
6463                                            GEN_INT (shift)));
6464               emit_insn (gen_ashlsi3 (gen_lowpart (SImode, dst),
6465                                       gen_lowpart (SImode, src),
6466                                       GEN_INT (shift)));
6467               DONE;
6468             }
6469         }
6470       /* Fallback to using optabs.c's expand_doubleword_shift.  */
6471       FAIL;
6472     }
6473   if (GET_CODE (operands[2]) != CONST_INT)
6474     {
6475       rtx temp = gen_reg_rtx (DImode);
6476       emit_insn (gen_subdi3 (temp, GEN_INT (63), operands[2]));
6477       if (GET_CODE (operands[1]) == CONST_INT)
6478         emit_insn (gen_zvdep_imm64 (operands[0], operands[1], temp));
6479       else
6480         emit_insn (gen_zvdep64 (operands[0], operands[1], temp));
6481       DONE;
6482     }
6483   /* Make sure both inputs are not constants,
6484      there are no patterns for that.  */
6485   operands[1] = force_reg (DImode, operands[1]);
6488 (define_insn ""
6489   [(set (match_operand:DI 0 "register_operand" "=r")
6490         (ashift:DI (match_operand:DI 1 "register_operand" "r")
6491                    (match_operand:DI 2 "const_int_operand" "n")))]
6492   "TARGET_64BIT"
6493   "depd,z %1,%p2,%Q2,%0"
6494   [(set_attr "type" "shift")
6495    (set_attr "length" "4")])
6497 ; Match cases of op1 a CONST_INT here that zvdep_imm64 doesn't handle.
6498 ; Doing it like this makes slightly better code since reload can
6499 ; replace a register with a known value in range -16..15 with a
6500 ; constant.  Ideally, we would like to merge zvdep64 and zvdep_imm64,
6501 ; but since we have no more CONST_OK... characters, that is not
6502 ; possible.
6503 (define_insn "zvdep64"
6504   [(set (match_operand:DI 0 "register_operand" "=r,r")
6505         (ashift:DI (match_operand:DI 1 "arith5_operand" "r,L")
6506                    (minus:DI (const_int 63)
6507                              (match_operand:DI 2 "register_operand" "q,q"))))]
6508   "TARGET_64BIT"
6509   "@
6510    depd,z %1,%%sar,64,%0
6511    depdi,z %1,%%sar,64,%0"
6512   [(set_attr "type" "shift,shift")
6513    (set_attr "length" "4,4")])
6515 (define_insn "zvdep_imm64"
6516   [(set (match_operand:DI 0 "register_operand" "=r")
6517         (ashift:DI (match_operand:DI 1 "lhs_lshift_cint_operand" "")
6518                    (minus:DI (const_int 63)
6519                              (match_operand:DI 2 "register_operand" "q"))))]
6520   "TARGET_64BIT"
6521   "*
6523   unsigned HOST_WIDE_INT x = UINTVAL (operands[1]);
6524   operands[2] = GEN_INT (4 + exact_log2 ((x >> 4) + 1));
6525   operands[1] = GEN_INT ((x & 0x1f) - 0x20);
6526   return \"depdi,z %1,%%sar,%2,%0\";
6528   [(set_attr "type" "shift")
6529    (set_attr "length" "4")])
6531 (define_insn ""
6532   [(set (match_operand:DI 0 "register_operand" "=r")
6533         (ior:DI (ashift:DI (match_operand:DI 1 "const_int_operand" "")
6534                            (minus:DI (const_int 63)
6535                                      (match_operand:DI 2 "register_operand" "q")))
6536                 (match_operand:DI 3 "register_operand" "0")))]
6537   ; accept ...0001...1, can this be generalized?
6538   "TARGET_64BIT && exact_log2 (INTVAL (operands[1]) + 1) > 0"
6539   "*
6541   HOST_WIDE_INT x = INTVAL (operands[1]);
6542   operands[2] = GEN_INT (exact_log2 (x + 1));
6543   return \"depdi -1,%%sar,%2,%0\";
6545   [(set_attr "type" "shift")
6546    (set_attr "length" "4")])
6548 (define_insn ""
6549   [(set (match_operand:DI 0 "register_operand" "=r")
6550         (and:DI (rotate:DI (match_operand:DI 1 "const_int_operand" "")
6551                            (minus:DI (const_int 63)
6552                                      (match_operand:DI 2 "register_operand" "q")))
6553                 (match_operand:DI 3 "register_operand" "0")))]
6554   ; this can be generalized...!
6555   "TARGET_64BIT && INTVAL (operands[1]) == -2"
6556   "*
6558   HOST_WIDE_INT x = INTVAL (operands[1]);
6559   operands[2] = GEN_INT (exact_log2 ((~x) + 1));
6560   return \"depdi 0,%%sar,%2,%0\";
6562   [(set_attr "type" "shift")
6563    (set_attr "length" "4")])
6565 (define_expand "ashrsi3"
6566   [(set (match_operand:SI 0 "register_operand" "")
6567         (ashiftrt:SI (match_operand:SI 1 "register_operand" "")
6568                      (match_operand:SI 2 "arith32_operand" "")))]
6569   ""
6570   "
6572   if (GET_CODE (operands[2]) != CONST_INT)
6573     {
6574       rtx temp = gen_reg_rtx (SImode);
6575       emit_insn (gen_subsi3 (temp, GEN_INT (31), operands[2]));
6576       emit_insn (gen_vextrs32 (operands[0], operands[1], temp));
6577       DONE;
6578     }
6581 (define_insn ""
6582   [(set (match_operand:SI 0 "register_operand" "=r")
6583         (ashiftrt:SI (match_operand:SI 1 "register_operand" "r")
6584                      (match_operand:SI 2 "const_int_operand" "n")))]
6585   ""
6586   "{extrs|extrw,s} %1,%P2,%L2,%0"
6587   [(set_attr "type" "shift")
6588    (set_attr "length" "4")])
6590 (define_insn "vextrs32"
6591   [(set (match_operand:SI 0 "register_operand" "=r")
6592         (ashiftrt:SI (match_operand:SI 1 "register_operand" "r")
6593                      (minus:SI (const_int 31)
6594                                (match_operand:SI 2 "register_operand" "q"))))]
6595   ""
6596   "{vextrs %1,32,%0|extrw,s %1,%%sar,32,%0}"
6597   [(set_attr "type" "shift")
6598    (set_attr "length" "4")])
6600 (define_expand "ashrdi3"
6601   [(set (match_operand:DI 0 "register_operand" "")
6602         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
6603                      (match_operand:DI 2 "arith32_operand" "")))]
6604   "TARGET_64BIT"
6605   "
6607   if (GET_CODE (operands[2]) != CONST_INT)
6608     {
6609       rtx temp = gen_reg_rtx (DImode);
6610       emit_insn (gen_subdi3 (temp, GEN_INT (63), operands[2]));
6611       emit_insn (gen_vextrs64 (operands[0], operands[1], temp));
6612       DONE;
6613     }
6616 (define_insn ""
6617   [(set (match_operand:DI 0 "register_operand" "=r")
6618         (ashiftrt:DI (match_operand:DI 1 "register_operand" "r")
6619                      (match_operand:DI 2 "const_int_operand" "n")))]
6620   "TARGET_64BIT"
6621   "extrd,s %1,%p2,%Q2,%0"
6622   [(set_attr "type" "shift")
6623    (set_attr "length" "4")])
6625 (define_insn "vextrs64"
6626   [(set (match_operand:DI 0 "register_operand" "=r")
6627         (ashiftrt:DI (match_operand:DI 1 "register_operand" "r")
6628                      (minus:DI (const_int 63)
6629                                (match_operand:DI 2 "register_operand" "q"))))]
6630   "TARGET_64BIT"
6631   "extrd,s %1,%%sar,64,%0"
6632   [(set_attr "type" "shift")
6633    (set_attr "length" "4")])
6635 (define_insn "lshrsi3"
6636   [(set (match_operand:SI 0 "register_operand" "=r,r")
6637         (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
6638                      (match_operand:SI 2 "shift5_operand" "q,n")))]
6639   ""
6640   "@
6641    {vshd %%r0,%1,%0|shrpw %%r0,%1,%%sar,%0}
6642    {extru|extrw,u} %1,%P2,%L2,%0"
6643   [(set_attr "type" "shift")
6644    (set_attr "length" "4")])
6646 (define_insn "lshrdi3"
6647   [(set (match_operand:DI 0 "register_operand" "=r,r")
6648         (lshiftrt:DI (match_operand:DI 1 "register_operand" "r,r")
6649                      (match_operand:DI 2 "shift6_operand" "q,n")))]
6650   "TARGET_64BIT"
6651   "@
6652    shrpd %%r0,%1,%%sar,%0
6653    extrd,u %1,%p2,%Q2,%0"
6654   [(set_attr "type" "shift")
6655    (set_attr "length" "4")])
6657 ; Shift right pair word 0 to 31 bits.
6658 (define_insn "*shrpsi4_1"
6659   [(set (match_operand:SI 0 "register_operand" "=r")
6660         (match_operator:SI 4 "plus_xor_ior_operator"
6661           [(ashift:SI (match_operand:SI 1 "register_operand" "r")
6662                       (minus:SI (const_int 32)
6663                                 (match_operand:SI 3 "register_operand" "q")))
6664            (lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
6665                         (match_dup 3))]))]
6666   ""
6667   "{vshd %1,%2,%0|shrpw %1,%2,%%sar,%0}"
6668   [(set_attr "type" "shift")
6669    (set_attr "length" "4")])
6671 (define_insn "*shrpsi4_2"
6672   [(set (match_operand:SI 0 "register_operand" "=r")
6673         (match_operator:SI 4 "plus_xor_ior_operator"
6674           [(lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
6675                         (match_operand:SI 3 "register_operand" "q"))
6676            (ashift:SI (match_operand:SI 1 "register_operand" "r")
6677                       (minus:SI (const_int 32)
6678                                 (match_dup 3)))]))]
6679   ""
6680   "{vshd %1,%2,%0|shrpw %1,%2,%%sar,%0}"
6681   [(set_attr "type" "shift")
6682    (set_attr "length" "4")])
6684 ; Shift right pair doubleword 0 to 63 bits.
6685 (define_insn "*shrpdi4_1"
6686   [(set (match_operand:DI 0 "register_operand" "=r")
6687         (match_operator:DI 4 "plus_xor_ior_operator"
6688           [(ashift:DI (match_operand:DI 1 "register_operand" "r")
6689                       (minus:DI (const_int 64)
6690                                 (match_operand:DI 3 "register_operand" "q")))
6691            (lshiftrt:DI (match_operand:DI 2 "register_operand" "r")
6692                         (match_dup 3))]))]
6693   "TARGET_64BIT"
6694   "shrpd %1,%2,%%sar,%0"
6695   [(set_attr "type" "shift")
6696    (set_attr "length" "4")])
6698 (define_insn "*shrpdi4_2"
6699   [(set (match_operand:DI 0 "register_operand" "=r")
6700         (match_operator:DI 4 "plus_xor_ior_operator"
6701           [(lshiftrt:DI (match_operand:DI 2 "register_operand" "r")
6702                         (match_operand:DI 3 "shift6_operand" "q"))
6703            (ashift:DI (match_operand:SI 1 "register_operand" "r")
6704                       (minus:DI (const_int 64)
6705                                 (match_dup 3)))]))]
6706   "TARGET_64BIT"
6707   "shrpd %1,%2,%%sar,%0"
6708   [(set_attr "type" "shift")
6709    (set_attr "length" "4")])
6711 (define_insn "*shrpdi4_3"
6712   [(set (match_operand:DI 0 "register_operand" "=r")
6713         (match_operator:DI 5 "plus_xor_ior_operator"
6714           [(ashift:DI (match_operand:DI 1 "register_operand" "r")
6715                       (match_operand:DI 3 "const_int_operand" "n"))
6716            (lshiftrt:DI (match_operand:DI 2 "register_operand" "r")
6717                         (match_operand:DI 4 "const_int_operand" "n"))]))]
6718   "TARGET_64BIT
6719    && INTVAL (operands[3]) + INTVAL (operands[4]) == 64"
6720   "shrpd %1,%2,%4,%0"
6721   [(set_attr "type" "shift")
6722    (set_attr "length" "4")])
6724 (define_insn "*shrpdi4_4"
6725   [(set (match_operand:DI 0 "register_operand" "=r")
6726         (match_operator:DI 5 "plus_xor_ior_operator"
6727           [(lshiftrt:DI (match_operand:DI 2 "register_operand" "r")
6728                         (match_operand:DI 4 "const_int_operand" "n"))
6729            (ashift:DI (match_operand:DI 1 "register_operand" "r")
6730                       (match_operand:DI 3 "const_int_operand" "n"))]))]
6731   "TARGET_64BIT
6732    && INTVAL (operands[3]) + INTVAL (operands[4]) == 64"
6733   "shrpd %1,%2,%4,%0"
6734   [(set_attr "type" "shift")
6735    (set_attr "length" "4")])
6737 (define_insn "rotrsi3"
6738   [(set (match_operand:SI 0 "register_operand" "=r,r")
6739         (rotatert:SI (match_operand:SI 1 "register_operand" "r,r")
6740                      (match_operand:SI 2 "shift5_operand" "q,n")))]
6741   ""
6742   "*
6744   if (GET_CODE (operands[2]) == CONST_INT)
6745     {
6746       operands[2] = GEN_INT (INTVAL (operands[2]) & 31);
6747       return \"{shd|shrpw} %1,%1,%2,%0\";
6748     }
6749   else
6750     return \"{vshd %1,%1,%0|shrpw %1,%1,%%sar,%0}\";
6752   [(set_attr "type" "shift")
6753    (set_attr "length" "4")])
6755 (define_expand "rotlsi3"
6756   [(set (match_operand:SI 0 "register_operand" "")
6757         (rotate:SI (match_operand:SI 1 "register_operand" "")
6758                    (match_operand:SI 2 "arith32_operand" "")))]
6759   ""
6760   "
6762   if (GET_CODE (operands[2]) != CONST_INT)
6763     {
6764       rtx temp = gen_reg_rtx (SImode);
6765       emit_insn (gen_subsi3 (temp, GEN_INT (32), operands[2]));
6766       emit_insn (gen_rotrsi3 (operands[0], operands[1], temp));
6767       DONE;
6768     }
6769   /* Else expand normally.  */
6772 (define_insn "*rotlsi3_internal"
6773   [(set (match_operand:SI 0 "register_operand" "=r")
6774         (rotate:SI (match_operand:SI 1 "register_operand" "r")
6775                    (match_operand:SI 2 "const_int_operand" "n")))]
6776   ""
6777   "*
6779   operands[2] = GEN_INT ((32 - INTVAL (operands[2])) & 31);
6780   return \"{shd|shrpw} %1,%1,%2,%0\";
6782   [(set_attr "type" "shift")
6783    (set_attr "length" "4")])
6785 (define_insn "rotrdi3"
6786   [(set (match_operand:DI 0 "register_operand" "=r,r")
6787         (rotatert:DI (match_operand:DI 1 "register_operand" "r,r")
6788                      (match_operand:DI 2 "shift6_operand" "q,n")))]
6789   "TARGET_64BIT"
6790   "*
6792   if (GET_CODE (operands[2]) == CONST_INT)
6793     {
6794       operands[2] = GEN_INT (INTVAL (operands[2]) & 63);
6795       return \"shrpd %1,%1,%2,%0\";
6796     }
6797   else
6798     return \"shrpd %1,%1,%%sar,%0\";
6800   [(set_attr "type" "shift")
6801    (set_attr "length" "4")])
6803 (define_expand "rotldi3"
6804   [(set (match_operand:DI 0 "register_operand" "")
6805         (rotate:DI (match_operand:DI 1 "register_operand" "")
6806                    (match_operand:DI 2 "arith32_operand" "")))]
6807   "TARGET_64BIT"
6808   "
6810   if (GET_CODE (operands[2]) != CONST_INT)
6811     {
6812       rtx temp = gen_reg_rtx (DImode);
6813       emit_insn (gen_subdi3 (temp, GEN_INT (64), operands[2]));
6814       emit_insn (gen_rotrdi3 (operands[0], operands[1], temp));
6815       DONE;
6816     }
6817   /* Else expand normally.  */
6820 (define_insn "*rotldi3_internal"
6821   [(set (match_operand:DI 0 "register_operand" "=r")
6822         (rotate:DI (match_operand:DI 1 "register_operand" "r")
6823                    (match_operand:DI 2 "const_int_operand" "n")))]
6824   "TARGET_64BIT"
6825   "*
6827   operands[2] = GEN_INT ((64 - INTVAL (operands[2])) & 63);
6828   return \"shrpd %1,%1,%2,%0\";
6830   [(set_attr "type" "shift")
6831    (set_attr "length" "4")])
6833 (define_insn ""
6834   [(set (match_operand:SI 0 "register_operand" "=r")
6835         (match_operator:SI 5 "plus_xor_ior_operator"
6836           [(ashift:SI (match_operand:SI 1 "register_operand" "r")
6837                       (match_operand:SI 3 "const_int_operand" "n"))
6838            (lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
6839                         (match_operand:SI 4 "const_int_operand" "n"))]))]
6840   "INTVAL (operands[3]) + INTVAL (operands[4]) == 32"
6841   "{shd|shrpw} %1,%2,%4,%0"
6842   [(set_attr "type" "shift")
6843    (set_attr "length" "4")])
6845 (define_insn ""
6846   [(set (match_operand:SI 0 "register_operand" "=r")
6847         (match_operator:SI 5 "plus_xor_ior_operator"
6848           [(lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
6849                         (match_operand:SI 4 "const_int_operand" "n"))
6850            (ashift:SI (match_operand:SI 1 "register_operand" "r")
6851                       (match_operand:SI 3 "const_int_operand" "n"))]))]
6852   "INTVAL (operands[3]) + INTVAL (operands[4]) == 32"
6853   "{shd|shrpw} %1,%2,%4,%0"
6854   [(set_attr "type" "shift")
6855    (set_attr "length" "4")])
6857 (define_expand "shd_internal"
6858   [(set (match_operand:SI 0 "register_operand")
6859         (ior:SI
6860           (lshiftrt:SI (match_operand:SI 1 "register_operand")
6861                        (match_operand:SI 2 "const_int_operand"))
6862           (ashift:SI (match_operand:SI 3 "register_operand")
6863                      (match_operand:SI 4 "const_int_operand"))))]
6864   "")
6866 (define_insn ""
6867   [(set (match_operand:SI 0 "register_operand" "=r")
6868         (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
6869                            (match_operand:SI 2 "const_int_operand" ""))
6870                 (match_operand:SI 3 "const_int_operand" "")))]
6871   "exact_log2 (1 + (INTVAL (operands[3]) >> (INTVAL (operands[2]) & 31))) > 0"
6872   "*
6874   int cnt = INTVAL (operands[2]) & 31;
6875   operands[3] = GEN_INT (exact_log2 (1 + (INTVAL (operands[3]) >> cnt)));
6876   operands[2] = GEN_INT (31 - cnt);
6877   return \"{zdep|depw,z} %1,%2,%3,%0\";
6879   [(set_attr "type" "shift")
6880    (set_attr "length" "4")])
6882 ;; Unconditional and other jump instructions.
6884 ;; Trivial return used when no epilogue is needed.
6885 (define_insn "return"
6886   [(return)
6887    (use (reg:SI 2))]
6888   "pa_can_use_return_insn ()"
6889   "*
6891   if (TARGET_PA_20)
6892     return \"bve%* (%%r2)\";
6893   return \"bv%* %%r0(%%r2)\";
6895   [(set_attr "type" "branch")
6896    (set_attr "length" "4")])
6898 ;; This is used for most returns.
6899 (define_insn "return_internal"
6900   [(return)
6901    (use (reg:SI 2))]
6902   ""
6903   "*
6905   if (TARGET_PA_20)
6906     return \"bve%* (%%r2)\";
6907   return \"bv%* %%r0(%%r2)\";
6909   [(set_attr "type" "branch")
6910    (set_attr "length" "4")])
6912 ;; This is used for eh returns which bypass the return stub.
6913 (define_insn "return_external_pic"
6914   [(return)
6915    (clobber (reg:SI 1))
6916    (use (reg:SI 2))]
6917   "!TARGET_NO_SPACE_REGS
6918    && !TARGET_PA_20
6919    && flag_pic && crtl->calls_eh_return"
6920   "ldsid (%%sr0,%%r2),%%r1\;mtsp %%r1,%%sr0\;be%* 0(%%sr0,%%r2)"
6921   [(set_attr "type" "branch")
6922    (set_attr "length" "12")])
6924 (define_expand "prologue"
6925   [(const_int 0)]
6926   ""
6927   "pa_expand_prologue ();DONE;")
6929 (define_expand "sibcall_epilogue"
6930   [(return)]
6931   ""
6932   "
6934   pa_expand_epilogue ();
6935   DONE;
6938 (define_expand "epilogue"
6939   [(return)]
6940   ""
6941   "
6943   rtx x;
6945   /* Try to use the trivial return first.  Else use the full epilogue.  */
6946   if (pa_can_use_return_insn ())
6947     x = gen_return ();
6948   else
6949     {
6950       pa_expand_epilogue ();
6952       /* EH returns bypass the normal return stub.  Thus, we must do an
6953          interspace branch to return from functions that call eh_return.
6954          This is only a problem for returns from shared code on ports
6955          using space registers.  */
6956       if (!TARGET_NO_SPACE_REGS
6957           && !TARGET_PA_20
6958           && flag_pic && crtl->calls_eh_return)
6959         x = gen_return_external_pic ();
6960       else
6961         x = gen_return_internal ();
6962     }
6963   emit_jump_insn (x);
6964   DONE;
6967 ; Used by hppa_profile_hook to load the starting address of the current
6968 ; function; operand 1 contains the address of the label in operand 3
6969 (define_insn "load_offset_label_address"
6970   [(set (match_operand:SI 0 "register_operand" "=r")
6971         (plus:SI (match_operand:SI 1 "register_operand" "r")
6972                  (minus:SI (match_operand:SI 2 "" "")
6973                            (label_ref:SI (match_operand 3 "" "")))))]
6974   ""
6975   "ldo %2-%l3(%1),%0"
6976   [(set_attr "type" "multi")
6977    (set_attr "length" "4")])
6979 ; Output a code label and load its address.
6980 (define_insn "lcla1"
6981   [(set (match_operand:SI 0 "register_operand" "=r")
6982         (label_ref:SI (match_operand 1 "" "")))
6983    (const_int 0)]
6984   "!TARGET_PA_20"
6985   "*
6987   output_asm_insn (\"bl .+8,%0\;depi 0,31,2,%0\", operands);
6988   (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
6989                                      CODE_LABEL_NUMBER (operands[1]));
6990   return \"\";
6992   [(set_attr "type" "multi")
6993    (set_attr "length" "8")])
6995 (define_insn "lcla2"
6996   [(set (match_operand:SI 0 "register_operand" "=r")
6997         (label_ref:SI (match_operand 1 "" "")))
6998    (const_int 0)]
6999   "TARGET_PA_20"
7000   "*
7002   (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
7003                                      CODE_LABEL_NUMBER (operands[1]));
7004   return \"mfia %0\";
7006   [(set_attr "type" "move")
7007    (set_attr "length" "4")])
7009 (define_insn "blockage"
7010   [(unspec_volatile [(const_int 2)] UNSPECV_BLOCKAGE)]
7011   ""
7012   ""
7013   [(set_attr "length" "0")])
7015 (define_insn "jump"
7016   [(set (pc) (label_ref (match_operand 0 "" "")))]
7017   ""
7018   "*
7020   /* An unconditional branch which can reach its target.  */
7021   if (get_attr_length (insn) < 16)
7022     return \"b%* %l0\";
7024   return pa_output_lbranch (operands[0], insn, 1);
7026   [(set_attr "type" "uncond_branch")
7027    (set_attr "pa_combine_type" "uncond_branch")
7028    (set (attr "length")
7029     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
7030                (const_int MAX_17BIT_OFFSET))
7031            (const_int 4)
7032            (match_test "TARGET_PORTABLE_RUNTIME")
7033            (const_int 20)
7034            (not (match_test "flag_pic"))
7035            (const_int 16)]
7036           (const_int 24)))])
7038 ;;; Hope this is only within a function...
7039 (define_insn "indirect_jump"
7040   [(set (pc) (match_operand 0 "pmode_register_operand" "r"))]
7041   ""
7042   "bv%* %%r0(%0)"
7043   [(set_attr "type" "branch")
7044    (set_attr "length" "4")])
7046 ;;; An indirect jump can be optimized to a direct jump.  GAS for the
7047 ;;; SOM target doesn't allow branching to a label inside a function.
7048 ;;; We also don't correctly compute branch distances for labels
7049 ;;; outside the current function.  Thus, we use an indirect jump can't
7050 ;;; be optimized to a direct jump for all targets.  We assume that
7051 ;;; the branch target is in the same space (i.e., nested function
7052 ;;; jumping to a label in an outer function in the same translation
7053 ;;; unit).
7054 (define_expand "nonlocal_goto"
7055   [(use (match_operand 0 "general_operand" ""))
7056    (use (match_operand 1 "general_operand" ""))
7057    (use (match_operand 2 "general_operand" ""))
7058    (use (match_operand 3 "general_operand" ""))]
7059   ""
7061   rtx lab = operands[1];
7062   rtx stack = operands[2];
7063   rtx fp = operands[3];
7065   emit_clobber (gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (VOIDmode)));
7066   emit_clobber (gen_rtx_MEM (BLKmode, hard_frame_pointer_rtx));
7068   lab = copy_to_reg (lab);
7070   /* Restore the stack and frame pointers.  */
7071   fp = copy_to_reg (fp);
7072   emit_stack_restore (SAVE_NONLOCAL, stack);
7074   /* Ensure the frame pointer move is not optimized.  */
7075   emit_insn (gen_blockage ());
7076   emit_clobber (hard_frame_pointer_rtx);
7077   emit_clobber (frame_pointer_rtx);
7078   emit_move_insn (hard_frame_pointer_rtx, fp);
7080   emit_use (hard_frame_pointer_rtx);
7081   emit_use (stack_pointer_rtx);
7083   /* Nonlocal goto jumps are only used between functions in the same
7084      translation unit.  Thus, we can avoid the extra overhead of an
7085      interspace jump.  */
7086   emit_jump_insn (gen_indirect_goto (lab));
7087   emit_barrier ();
7088   DONE;
7091 (define_insn "indirect_goto"
7092   [(unspec [(match_operand 0 "register_operand" "=r")] UNSPEC_GOTO)]
7093   "GET_MODE (operands[0]) == word_mode"
7094   "bv%* %%r0(%0)"
7095   [(set_attr "type" "branch")
7096    (set_attr "length" "4")])
7098 ;; Subroutines of "casesi".
7099 ;; operand 0 is index
7100 ;; operand 1 is the minimum bound
7101 ;; operand 2 is the maximum bound - minimum bound + 1
7102 ;; operand 3 is CODE_LABEL for the table;
7103 ;; operand 4 is the CODE_LABEL to go to if index out of range.
7105 (define_expand "casesi"
7106   [(match_operand:SI 0 "general_operand" "")
7107    (match_operand:SI 1 "const_int_operand" "")
7108    (match_operand:SI 2 "const_int_operand" "")
7109    (match_operand 3 "" "")
7110    (match_operand 4 "" "")]
7111   ""
7112   "
7114   if (GET_CODE (operands[0]) != REG)
7115     operands[0] = force_reg (SImode, operands[0]);
7117   if (operands[1] != const0_rtx)
7118     {
7119       rtx index = gen_reg_rtx (SImode);
7121       operands[1] = gen_int_mode (-INTVAL (operands[1]), SImode);
7122       if (!INT_14_BITS (operands[1]))
7123         operands[1] = force_reg (SImode, operands[1]);
7124       emit_insn (gen_addsi3 (index, operands[0], operands[1]));
7125       operands[0] = index;
7126     }
7128   if (!INT_5_BITS (operands[2]))
7129     operands[2] = force_reg (SImode, operands[2]);
7131   /* This branch prevents us finding an insn for the delay slot of the
7132      following vectored branch.  It might be possible to use the delay
7133      slot if an index value of -1 was used to transfer to the out-of-range
7134      label.  In order to do this, we would have to output the -1 vector
7135      element after the delay insn.  The casesi output code would have to
7136      check if the casesi insn is in a delay branch sequence and output
7137      the delay insn if one is found.  If this was done, then it might
7138      then be worthwhile to split the casesi patterns to improve scheduling.
7139      However, it's not clear that all this extra complexity is worth
7140      the effort.  */
7141   {
7142     rtx test = gen_rtx_GTU (VOIDmode, operands[0], operands[2]);
7143     emit_jump_insn (gen_cbranchsi4 (test, operands[0], operands[2], operands[4]));
7144   }
7146   /* In 64bit mode we must make sure to wipe the upper bits of the register
7147      just in case the addition overflowed or we had random bits in the
7148      high part of the register.  */
7149   if (TARGET_64BIT)
7150     {
7151       rtx index = gen_reg_rtx (DImode);
7153       emit_insn (gen_extendsidi2 (index, operands[0]));
7154       operands[0] = index;
7155     }
7157   if (TARGET_64BIT)
7158     emit_jump_insn (gen_casesi64p (operands[0], operands[3]));
7159   else if (flag_pic)
7160     emit_jump_insn (gen_casesi32p (operands[0], operands[3]));
7161   else
7162     emit_jump_insn (gen_casesi32 (operands[0], operands[3]));
7163   DONE;
7166 ;;; 32-bit code, absolute branch table.
7167 (define_insn "casesi32"
7168   [(set (pc) (mem:SI (plus:SI
7169                        (mult:SI (match_operand:SI 0 "register_operand" "r")
7170                                 (const_int 4))
7171                        (label_ref (match_operand 1 "" "")))))
7172    (clobber (match_scratch:SI 2 "=&r"))]
7173   "!flag_pic"
7174   "ldil L'%l1,%2\;ldo R'%l1(%2),%2\;{ldwx|ldw},s %0(%2),%2\;bv,n %%r0(%2)"
7175   [(set_attr "type" "multi")
7176    (set_attr "length" "16")])
7178 ;;; 32-bit code, relative branch table.
7179 (define_insn "casesi32p"
7180   [(set (pc) (mem:SI (plus:SI
7181                        (mult:SI (match_operand:SI 0 "register_operand" "r")
7182                                 (const_int 4))
7183                        (label_ref (match_operand 1 "" "")))))
7184    (clobber (match_scratch:SI 2 "=&r"))
7185    (clobber (match_scratch:SI 3 "=&r"))]
7186   "flag_pic"
7187   "{bl .+8,%2\;depi 0,31,2,%2|mfia %2}\;ldo {%l1-.|%l1+4-.}(%2),%2\;\
7188 {ldwx|ldw},s %0(%2),%3\;{addl|add,l} %2,%3,%3\;bv,n %%r0(%3)"
7189   [(set_attr "type" "multi")
7190    (set (attr "length")
7191      (if_then_else (match_test "TARGET_PA_20")
7192         (const_int 20)
7193         (const_int 24)))])
7195 ;;; 64-bit code, 32-bit relative branch table.
7196 (define_insn "casesi64p"
7197   [(set (pc) (mem:DI (plus:DI
7198                        (mult:DI (match_operand:DI 0 "register_operand" "r")
7199                                 (const_int 8))
7200                        (label_ref (match_operand 1 "" "")))))
7201    (clobber (match_scratch:DI 2 "=&r"))
7202    (clobber (match_scratch:DI 3 "=&r"))]
7203   ""
7204   "mfia %2\;ldo %l1+4-.(%2),%2\;ldw,s %0(%2),%3\;extrd,s %3,63,32,%3\;\
7205 add,l %2,%3,%3\;bv,n %%r0(%3)"
7206   [(set_attr "type" "multi")
7207    (set_attr "length" "24")])
7210 ;; Call patterns.
7211 ;;- jump to subroutine
7213 (define_expand "call"
7214   [(parallel [(call (match_operand:SI 0 "" "")
7215                     (match_operand 1 "" ""))
7216               (clobber (reg:SI 2))])]
7217   ""
7218   "
7220   rtx op;
7221   rtx nb = operands[1];
7223   if (TARGET_PORTABLE_RUNTIME)
7224     op = force_reg (SImode, XEXP (operands[0], 0));
7225   else
7226     {
7227       op = XEXP (operands[0], 0);
7229       /* Generate indirect long calls to non-local functions. */
7230       if (TARGET_LONG_CALLS && GET_CODE (op) == SYMBOL_REF)
7231         {
7232           tree call_decl = SYMBOL_REF_DECL (op);
7233           if (!(call_decl && targetm.binds_local_p (call_decl)))
7234             op = force_reg (word_mode, op);
7235         }
7236     }
7238   if (TARGET_64BIT)
7239     {
7240       if (!virtuals_instantiated)
7241         emit_move_insn (arg_pointer_rtx,
7242                         gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
7243                                       GEN_INT (64)));
7244       else
7245         {
7246           /* The loop pass can generate new libcalls after the virtual
7247              registers are instantiated when fpregs are disabled because
7248              the only method that we have for doing DImode multiplication
7249              is with a libcall.  This could be trouble if we haven't
7250              allocated enough space for the outgoing arguments.  */
7251           gcc_assert (INTVAL (nb) <= crtl->outgoing_args_size);
7253           emit_move_insn (arg_pointer_rtx,
7254                           gen_rtx_PLUS (word_mode, stack_pointer_rtx,
7255                                         GEN_INT (STACK_POINTER_OFFSET + 64)));
7256         }
7257     }
7259   /* Use two different patterns for calls to explicitly named functions
7260      and calls through function pointers.  This is necessary as these two
7261      types of calls use different calling conventions, and CSE might try
7262      to change the named call into an indirect call in some cases (using
7263      two patterns keeps CSE from performing this optimization).
7264      
7265      We now use even more call patterns as there was a subtle bug in
7266      attempting to restore the pic register after a call using a simple
7267      move insn.  During reload, a instruction involving a pseudo register
7268      with no explicit dependence on the PIC register can be converted
7269      to an equivalent load from memory using the PIC register.  If we
7270      emit a simple move to restore the PIC register in the initial rtl
7271      generation, then it can potentially be repositioned during scheduling.
7272      and an instruction that eventually uses the PIC register may end up
7273      between the call and the PIC register restore.
7274      
7275      This only worked because there is a post call group of instructions
7276      that are scheduled with the call.  These instructions are included
7277      in the same basic block as the call.  However, calls can throw in
7278      C++ code and a basic block has to terminate at the call if the call
7279      can throw.  This results in the PIC register restore being scheduled
7280      independently from the call.  So, we now hide the save and restore
7281      of the PIC register in the call pattern until after reload.  Then,
7282      we split the moves out.  A small side benefit is that we now don't
7283      need to have a use of the PIC register in the return pattern and
7284      the final save/restore operation is not needed.
7285      
7286      I elected to just use register %r4 in the PIC patterns instead
7287      of trying to force hppa_pic_save_rtx () to a callee saved register.
7288      This might have required a new register class and constraint.  It
7289      was also simpler to just handle the restore from a register than a
7290      generic pseudo.  */
7291   if (TARGET_64BIT)
7292     {
7293       rtx r4 = gen_rtx_REG (word_mode, 4);
7294       if (GET_CODE (op) == SYMBOL_REF)
7295         emit_call_insn (gen_call_symref_64bit (op, nb, r4));
7296       else
7297         {
7298           op = force_reg (word_mode, op);
7299           emit_call_insn (gen_call_reg_64bit (op, nb, r4));
7300         }
7301     }
7302   else
7303     {
7304       if (GET_CODE (op) == SYMBOL_REF)
7305         {
7306           if (flag_pic)
7307             {
7308               rtx r4 = gen_rtx_REG (word_mode, 4);
7309               emit_call_insn (gen_call_symref_pic (op, nb, r4));
7310             }
7311           else
7312             emit_call_insn (gen_call_symref (op, nb));
7313         }
7314       else
7315         {
7316           rtx tmpreg = gen_rtx_REG (word_mode, 22);
7317           emit_move_insn (tmpreg, force_reg (word_mode, op));
7318           if (flag_pic)
7319             {
7320               rtx r4 = gen_rtx_REG (word_mode, 4);
7321               emit_call_insn (gen_call_reg_pic (nb, r4));
7322             }
7323           else
7324             emit_call_insn (gen_call_reg (nb));
7325         }
7326     }
7328   DONE;
7331 ;; We use function calls to set the attribute length of calls and millicode
7332 ;; calls.  This is necessary because of the large variety of call sequences.
7333 ;; Implementing the calculation in rtl is difficult as well as ugly.  As
7334 ;; we need the same calculation in several places, maintenance becomes a
7335 ;; nightmare.
7337 ;; However, this has a subtle impact on branch shortening.  When the
7338 ;; expression used to set the length attribute of an instruction depends
7339 ;; on a relative address (e.g., pc or a branch address), genattrtab
7340 ;; notes that the insn's length is variable, and attempts to determine a
7341 ;; worst-case default length and code to compute an insn's current length.
7343 ;; The use of a function call hides the variable dependence of our calls
7344 ;; and millicode calls.  The result is genattrtab doesn't treat the operation
7345 ;; as variable and it only generates code for the default case using our
7346 ;; function call.  Because of this, calls and millicode calls have a fixed
7347 ;; length in the branch shortening pass, and some branches will use a longer
7348 ;; code sequence than necessary.  However, the length of any given call
7349 ;; will still reflect its final code location and it may be shorter than
7350 ;; the initial length estimate.
7352 ;; It's possible to trick genattrtab by adding an expression involving `pc'
7353 ;; in the set.  However, when genattrtab hits a function call in its attempt
7354 ;; to compute the default length, it marks the result as unknown and sets
7355 ;; the default result to MAX_INT ;-(  One possible fix that would allow
7356 ;; calls to participate in branch shortening would be to make the call to
7357 ;; insn_default_length a target option.  Then, we could massage unknown
7358 ;; results.  Another fix might be to change genattrtab so that it just does
7359 ;; the call in the variable case as it already does for the fixed case.
7361 (define_insn "call_symref"
7362   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7363          (match_operand 1 "" "i"))
7364    (clobber (reg:SI 1))
7365    (clobber (reg:SI 2))
7366    (use (const_int 0))]
7367   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7368   "*
7370   pa_output_arg_descriptor (insn);
7371   return pa_output_call (insn, operands[0], 0);
7373   [(set_attr "type" "call")
7374    (set (attr "length")
7375         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7376               (symbol_ref "pa_attr_length_call (insn, 0)")))])
7378 (define_insn "call_symref_pic"
7379   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7380          (match_operand 1 "" "i"))
7381    (clobber (reg:SI 1))
7382    (clobber (reg:SI 2))
7383    (clobber (match_operand 2))
7384    (use (reg:SI 19))
7385    (use (const_int 0))]
7386   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7387   "#")
7389 ;; Split out the PIC register save and restore after reload.  As the
7390 ;; split is done after reload, there are some situations in which we
7391 ;; unnecessarily save and restore %r4.  This happens when there is a
7392 ;; single call and the PIC register is not used after the call.
7394 ;; The split has to be done since call_from_call_insn () can't handle
7395 ;; the pattern as is.  Noreturn calls are special because they have to
7396 ;; terminate the basic block.  The split has to contain more than one
7397 ;; insn.
7398 (define_split
7399   [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7400                     (match_operand 1 "" ""))
7401               (clobber (reg:SI 1))
7402               (clobber (reg:SI 2))
7403               (clobber (match_operand 2))
7404               (use (reg:SI 19))
7405               (use (const_int 0))])]
7406   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed
7407    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7408   [(set (match_dup 2) (reg:SI 19))
7409    (parallel [(call (mem:SI (match_dup 0))
7410                     (match_dup 1))
7411               (clobber (reg:SI 1))
7412               (clobber (reg:SI 2))
7413               (use (reg:SI 19))
7414               (use (const_int 0))])]
7415   "")
7417 (define_split
7418   [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7419                     (match_operand 1 "" ""))
7420               (clobber (reg:SI 1))
7421               (clobber (reg:SI 2))
7422               (clobber (match_operand 2))
7423               (use (reg:SI 19))
7424               (use (const_int 0))])]
7425   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
7426   [(set (match_dup 2) (reg:SI 19))
7427    (parallel [(call (mem:SI (match_dup 0))
7428                     (match_dup 1))
7429               (clobber (reg:SI 1))
7430               (clobber (reg:SI 2))
7431               (use (reg:SI 19))
7432               (use (const_int 0))])
7433    (set (reg:SI 19) (match_dup 2))]
7434   "")
7436 (define_insn "*call_symref_pic_post_reload"
7437   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7438          (match_operand 1 "" "i"))
7439    (clobber (reg:SI 1))
7440    (clobber (reg:SI 2))
7441    (use (reg:SI 19))
7442    (use (const_int 0))]
7443   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7444   "*
7446   pa_output_arg_descriptor (insn);
7447   return pa_output_call (insn, operands[0], 0);
7449   [(set_attr "type" "call")
7450    (set (attr "length")
7451         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7452               (symbol_ref "pa_attr_length_call (insn, 0)")))])
7454 ;; This pattern is split if it is necessary to save and restore the
7455 ;; PIC register.
7456 (define_insn "call_symref_64bit"
7457   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7458          (match_operand 1 "" "i"))
7459    (clobber (reg:DI 1))
7460    (clobber (reg:DI 2))
7461    (clobber (match_operand 2))
7462    (use (reg:DI 27))
7463    (use (reg:DI 29))
7464    (use (const_int 0))]
7465   "TARGET_64BIT"
7466   "#")
7468 ;; Split out the PIC register save and restore after reload.  As the
7469 ;; split is done after reload, there are some situations in which we
7470 ;; unnecessarily save and restore %r4.  This happens when there is a
7471 ;; single call and the PIC register is not used after the call.
7473 ;; The split has to be done since call_from_call_insn () can't handle
7474 ;; the pattern as is.  Noreturn calls are special because they have to
7475 ;; terminate the basic block.  The split has to contain more than one
7476 ;; insn.
7477 (define_split
7478   [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7479                     (match_operand 1 "" ""))
7480               (clobber (reg:DI 1))
7481               (clobber (reg:DI 2))
7482               (clobber (match_operand 2))
7483               (use (reg:DI 27))
7484               (use (reg:DI 29))
7485               (use (const_int 0))])]
7486   "TARGET_64BIT && reload_completed
7487    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7488   [(set (match_dup 2) (reg:DI 27))
7489    (parallel [(call (mem:SI (match_dup 0))
7490                     (match_dup 1))
7491               (clobber (reg:DI 1))
7492               (clobber (reg:DI 2))
7493               (use (reg:DI 27))
7494               (use (reg:DI 29))
7495               (use (const_int 0))])]
7496   "")
7498 (define_split
7499   [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7500                     (match_operand 1 "" ""))
7501               (clobber (reg:DI 1))
7502               (clobber (reg:DI 2))
7503               (clobber (match_operand 2))
7504               (use (reg:DI 27))
7505               (use (reg:DI 29))
7506               (use (const_int 0))])]
7507   "TARGET_64BIT && reload_completed"
7508   [(set (match_dup 2) (reg:DI 27))
7509    (parallel [(call (mem:SI (match_dup 0))
7510                     (match_dup 1))
7511               (clobber (reg:DI 1))
7512               (clobber (reg:DI 2))
7513               (use (reg:DI 27))
7514               (use (reg:DI 29))
7515               (use (const_int 0))])
7516    (set (reg:DI 27) (match_dup 2))]
7517   "")
7519 (define_insn "*call_symref_64bit_post_reload"
7520   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7521          (match_operand 1 "" "i"))
7522    (clobber (reg:DI 1))
7523    (clobber (reg:DI 2))
7524    (use (reg:DI 27))
7525    (use (reg:DI 29))
7526    (use (const_int 0))]
7527   "TARGET_64BIT"
7528   "*
7530   return pa_output_call (insn, operands[0], 0);
7532   [(set_attr "type" "call")
7533    (set (attr "length")
7534         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7535               (symbol_ref "pa_attr_length_call (insn, 0)")))])
7537 (define_insn "call_reg"
7538   [(call (mem:SI (reg:SI 22))
7539          (match_operand 0 "" "i"))
7540    (clobber (reg:SI 1))
7541    (clobber (reg:SI 2))
7542    (use (const_int 1))]
7543   "!TARGET_64BIT"
7544   "*
7546   return pa_output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
7548   [(set_attr "type" "dyncall")
7549    (set (attr "length")
7550         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7551               (symbol_ref "pa_attr_length_indirect_call (insn)")))])
7553 ;; This pattern is split if it is necessary to save and restore the
7554 ;; PIC register.
7555 (define_insn "call_reg_pic"
7556   [(call (mem:SI (reg:SI 22))
7557          (match_operand 0 "" "i"))
7558    (clobber (reg:SI 1))
7559    (clobber (reg:SI 2))
7560    (clobber (match_operand 1))
7561    (use (reg:SI 19))
7562    (use (const_int 1))]
7563   "!TARGET_64BIT"
7564   "#")
7566 ;; Split out the PIC register save and restore after reload.  As the
7567 ;; split is done after reload, there are some situations in which we
7568 ;; unnecessarily save and restore %r4.  This happens when there is a
7569 ;; single call and the PIC register is not used after the call.
7571 ;; The split has to be done since call_from_call_insn () can't handle
7572 ;; the pattern as is.  Noreturn calls are special because they have to
7573 ;; terminate the basic block.  The split has to contain more than one
7574 ;; insn.
7575 (define_split
7576   [(parallel [(call (mem:SI (reg:SI 22))
7577                     (match_operand 0 "" ""))
7578               (clobber (reg:SI 1))
7579               (clobber (reg:SI 2))
7580               (clobber (match_operand 1))
7581               (use (reg:SI 19))
7582               (use (const_int 1))])]
7583   "!TARGET_64BIT && reload_completed
7584    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7585   [(set (match_dup 1) (reg:SI 19))
7586    (parallel [(call (mem:SI (reg:SI 22))
7587                     (match_dup 0))
7588               (clobber (reg:SI 1))
7589               (clobber (reg:SI 2))
7590               (use (reg:SI 19))
7591               (use (const_int 1))])]
7592   "")
7594 (define_split
7595   [(parallel [(call (mem:SI (reg:SI 22))
7596                     (match_operand 0 "" ""))
7597               (clobber (reg:SI 1))
7598               (clobber (reg:SI 2))
7599               (clobber (match_operand 1))
7600               (use (reg:SI 19))
7601               (use (const_int 1))])]
7602   "!TARGET_64BIT && reload_completed"
7603   [(set (match_dup 1) (reg:SI 19))
7604    (parallel [(call (mem:SI (reg:SI 22))
7605                     (match_dup 0))
7606               (clobber (reg:SI 1))
7607               (clobber (reg:SI 2))
7608               (use (reg:SI 19))
7609               (use (const_int 1))])
7610    (set (reg:SI 19) (match_dup 1))]
7611   "")
7613 (define_insn "*call_reg_pic_post_reload"
7614   [(call (mem:SI (reg:SI 22))
7615          (match_operand 0 "" "i"))
7616    (clobber (reg:SI 1))
7617    (clobber (reg:SI 2))
7618    (use (reg:SI 19))
7619    (use (const_int 1))]
7620   "!TARGET_64BIT"
7621   "*
7623   return pa_output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
7625   [(set_attr "type" "dyncall")
7626    (set (attr "length")
7627         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7628               (symbol_ref "pa_attr_length_indirect_call (insn)")))])
7630 ;; This pattern is split if it is necessary to save and restore the
7631 ;; PIC register.
7632 (define_insn "call_reg_64bit"
7633   [(call (mem:SI (match_operand:DI 0 "register_operand" "r"))
7634          (match_operand 1 "" "i"))
7635    (clobber (reg:DI 2))
7636    (clobber (match_operand 2))
7637    (use (reg:DI 27))
7638    (use (reg:DI 29))
7639    (use (const_int 1))]
7640   "TARGET_64BIT"
7641   "#")
7643 ;; Split out the PIC register save and restore after reload.  As the
7644 ;; split is done after reload, there are some situations in which we
7645 ;; unnecessarily save and restore %r4.  This happens when there is a
7646 ;; single call and the PIC register is not used after the call.
7648 ;; The split has to be done since call_from_call_insn () can't handle
7649 ;; the pattern as is.  Noreturn calls are special because they have to
7650 ;; terminate the basic block.  The split has to contain more than one
7651 ;; insn.
7652 (define_split
7653   [(parallel [(call (mem:SI (match_operand 0 "register_operand" ""))
7654                     (match_operand 1 "" ""))
7655               (clobber (reg:DI 2))
7656               (clobber (match_operand 2))
7657               (use (reg:DI 27))
7658               (use (reg:DI 29))
7659               (use (const_int 1))])]
7660   "TARGET_64BIT && reload_completed
7661    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7662   [(set (match_dup 2) (reg:DI 27))
7663    (parallel [(call (mem:SI (match_dup 0))
7664                     (match_dup 1))
7665               (clobber (reg:DI 2))
7666               (use (reg:DI 27))
7667               (use (reg:DI 29))
7668               (use (const_int 1))])]
7669   "")
7671 (define_split
7672   [(parallel [(call (mem:SI (match_operand 0 "register_operand" ""))
7673                     (match_operand 1 "" ""))
7674               (clobber (reg:DI 2))
7675               (clobber (match_operand 2))
7676               (use (reg:DI 27))
7677               (use (reg:DI 29))
7678               (use (const_int 1))])]
7679   "TARGET_64BIT && reload_completed"
7680   [(set (match_dup 2) (reg:DI 27))
7681    (parallel [(call (mem:SI (match_dup 0))
7682                     (match_dup 1))
7683               (clobber (reg:DI 2))
7684               (use (reg:DI 27))
7685               (use (reg:DI 29))
7686               (use (const_int 1))])
7687    (set (reg:DI 27) (match_dup 2))]
7688   "")
7690 (define_insn "*call_reg_64bit_post_reload"
7691   [(call (mem:SI (match_operand:DI 0 "register_operand" "r"))
7692          (match_operand 1 "" "i"))
7693    (clobber (reg:DI 2))
7694    (use (reg:DI 27))
7695    (use (reg:DI 29))
7696    (use (const_int 1))]
7697   "TARGET_64BIT"
7698   "*
7700   return pa_output_indirect_call (insn, operands[0]);
7702   [(set_attr "type" "dyncall")
7703    (set (attr "length")
7704         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 12)]
7705               (symbol_ref "pa_attr_length_indirect_call (insn)")))])
7707 (define_expand "call_value"
7708   [(parallel [(set (match_operand 0 "" "")
7709                    (call (match_operand:SI 1 "" "")
7710                          (match_operand 2 "" "")))
7711               (clobber (reg:SI 2))])]
7712   ""
7714   rtx op;
7715   rtx dst = operands[0];
7716   rtx nb = operands[2];
7717   bool call_powf = false;
7719   if (TARGET_PORTABLE_RUNTIME)
7720     op = force_reg (SImode, XEXP (operands[1], 0));
7721   else
7722     {
7723       op = XEXP (operands[1], 0);
7724       if (GET_CODE (op) == SYMBOL_REF)
7725         {
7726           /* Handle special call to buggy powf function.  */
7727           if (TARGET_HPUX && !TARGET_DISABLE_FPREGS && !TARGET_SOFT_FLOAT
7728               && !strcmp (targetm.strip_name_encoding (XSTR (op, 0)), "powf"))
7729             call_powf = true;
7731           /* Generate indirect long calls to non-local functions. */
7732           else if (TARGET_LONG_CALLS)
7733             {
7734               tree call_decl = SYMBOL_REF_DECL (op);
7735               if (!(call_decl && targetm.binds_local_p (call_decl)))
7736                 op = force_reg (word_mode, op);
7737             }
7738         }
7739     }
7741   if (TARGET_64BIT)
7742     {
7743       if (!virtuals_instantiated)
7744         emit_move_insn (arg_pointer_rtx,
7745                         gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
7746                                       GEN_INT (64)));
7747       else
7748         {
7749           /* The loop pass can generate new libcalls after the virtual
7750              registers are instantiated when fpregs are disabled because
7751              the only method that we have for doing DImode multiplication
7752              is with a libcall.  This could be trouble if we haven't
7753              allocated enough space for the outgoing arguments.  */
7754           gcc_assert (INTVAL (nb) <= crtl->outgoing_args_size);
7756           emit_move_insn (arg_pointer_rtx,
7757                           gen_rtx_PLUS (word_mode, stack_pointer_rtx,
7758                                         GEN_INT (STACK_POINTER_OFFSET + 64)));
7759         }
7760     }
7762   /* Use two different patterns for calls to explicitly named functions
7763      and calls through function pointers.  This is necessary as these two
7764      types of calls use different calling conventions, and CSE might try
7765      to change the named call into an indirect call in some cases (using
7766      two patterns keeps CSE from performing this optimization).
7768      We now use even more call patterns as there was a subtle bug in
7769      attempting to restore the pic register after a call using a simple
7770      move insn.  During reload, a instruction involving a pseudo register
7771      with no explicit dependence on the PIC register can be converted
7772      to an equivalent load from memory using the PIC register.  If we
7773      emit a simple move to restore the PIC register in the initial rtl
7774      generation, then it can potentially be repositioned during scheduling.
7775      and an instruction that eventually uses the PIC register may end up
7776      between the call and the PIC register restore.
7777      
7778      This only worked because there is a post call group of instructions
7779      that are scheduled with the call.  These instructions are included
7780      in the same basic block as the call.  However, calls can throw in
7781      C++ code and a basic block has to terminate at the call if the call
7782      can throw.  This results in the PIC register restore being scheduled
7783      independently from the call.  So, we now hide the save and restore
7784      of the PIC register in the call pattern until after reload.  Then,
7785      we split the moves out.  A small side benefit is that we now don't
7786      need to have a use of the PIC register in the return pattern and
7787      the final save/restore operation is not needed.
7788      
7789      I elected to just use register %r4 in the PIC patterns instead
7790      of trying to force hppa_pic_save_rtx () to a callee saved register.
7791      This might have required a new register class and constraint.  It
7792      was also simpler to just handle the restore from a register than a
7793      generic pseudo.  */
7794   if (TARGET_64BIT)
7795     {
7796       rtx r4 = gen_rtx_REG (word_mode, 4);
7797       if (GET_CODE (op) == SYMBOL_REF)
7798         {
7799           if (call_powf)
7800             emit_call_insn (gen_call_val_powf_64bit (dst, op, nb, r4));
7801           else
7802             emit_call_insn (gen_call_val_symref_64bit (dst, op, nb, r4));
7803         }
7804       else
7805         {
7806           op = force_reg (word_mode, op);
7807           emit_call_insn (gen_call_val_reg_64bit (dst, op, nb, r4));
7808         }
7809     }
7810   else
7811     {
7812       if (GET_CODE (op) == SYMBOL_REF)
7813         {
7814           if (flag_pic)
7815             {
7816               rtx r4 = gen_rtx_REG (word_mode, 4);
7818               if (call_powf)
7819                 emit_call_insn (gen_call_val_powf_pic (dst, op, nb, r4));
7820               else
7821                 emit_call_insn (gen_call_val_symref_pic (dst, op, nb, r4));
7822             }
7823           else
7824             {
7825               if (call_powf)
7826                 emit_call_insn (gen_call_val_powf (dst, op, nb));
7827               else
7828                 emit_call_insn (gen_call_val_symref (dst, op, nb));
7829             }
7830         }
7831       else
7832         {
7833           rtx tmpreg = gen_rtx_REG (word_mode, 22);
7834           emit_move_insn (tmpreg, force_reg (word_mode, op));
7835           if (flag_pic)
7836             {
7837               rtx r4 = gen_rtx_REG (word_mode, 4);
7838               emit_call_insn (gen_call_val_reg_pic (dst, nb, r4));
7839             }
7840           else
7841             emit_call_insn (gen_call_val_reg (dst, nb));
7842         }
7843     }
7845   DONE;
7848 (define_insn "call_val_symref"
7849   [(set (match_operand 0 "" "")
7850         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7851               (match_operand 2 "" "i")))
7852    (clobber (reg:SI 1))
7853    (clobber (reg:SI 2))
7854    (use (const_int 0))]
7855   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7856   "*
7858   pa_output_arg_descriptor (insn);
7859   return pa_output_call (insn, operands[1], 0);
7861   [(set_attr "type" "call")
7862    (set (attr "length")
7863         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7864               (symbol_ref "pa_attr_length_call (insn, 0)")))])
7866 ;; powf function clobbers %fr12
7867 (define_insn "call_val_powf"
7868   [(set (match_operand 0 "" "")
7869         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7870               (match_operand 2 "" "i")))
7871    (clobber (reg:SI 1))
7872    (clobber (reg:SI 2))
7873    (clobber (reg:DF 48))
7874    (use (const_int 1))]
7875   "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7876   "*
7878   pa_output_arg_descriptor (insn);
7879   return pa_output_call (insn, operands[1], 0);
7881   [(set_attr "type" "call")
7882    (set (attr "length")
7883         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7884               (symbol_ref "pa_attr_length_call (insn, 0)")))])
7886 (define_insn "call_val_symref_pic"
7887   [(set (match_operand 0 "" "")
7888         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7889               (match_operand 2 "" "i")))
7890    (clobber (reg:SI 1))
7891    (clobber (reg:SI 2))
7892    (clobber (match_operand 3))
7893    (use (reg:SI 19))
7894    (use (const_int 0))]
7895   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7896   "#")
7898 ;; Split out the PIC register save and restore after reload.  As the
7899 ;; split is done after reload, there are some situations in which we
7900 ;; unnecessarily save and restore %r4.  This happens when there is a
7901 ;; single call and the PIC register is not used after the call.
7903 ;; The split has to be done since call_from_call_insn () can't handle
7904 ;; the pattern as is.  Noreturn calls are special because they have to
7905 ;; terminate the basic block.  The split has to contain more than one
7906 ;; insn.
7907 (define_split
7908   [(parallel [(set (match_operand 0 "" "")
7909               (call (mem:SI (match_operand 1 "call_operand_address" ""))
7910                     (match_operand 2 "" "")))
7911               (clobber (reg:SI 1))
7912               (clobber (reg:SI 2))
7913               (clobber (match_operand 3))
7914               (use (reg:SI 19))
7915               (use (const_int 0))])]
7916   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed
7917    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7918   [(set (match_dup 3) (reg:SI 19))
7919    (parallel [(set (match_dup 0)
7920               (call (mem:SI (match_dup 1))
7921                     (match_dup 2)))
7922               (clobber (reg:SI 1))
7923               (clobber (reg:SI 2))
7924               (use (reg:SI 19))
7925               (use (const_int 0))])]
7926   "")
7928 (define_split
7929   [(parallel [(set (match_operand 0 "" "")
7930               (call (mem:SI (match_operand 1 "call_operand_address" ""))
7931                     (match_operand 2 "" "")))
7932               (clobber (reg:SI 1))
7933               (clobber (reg:SI 2))
7934               (clobber (match_operand 3))
7935               (use (reg:SI 19))
7936               (use (const_int 0))])]
7937   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
7938   [(set (match_dup 3) (reg:SI 19))
7939    (parallel [(set (match_dup 0)
7940               (call (mem:SI (match_dup 1))
7941                     (match_dup 2)))
7942               (clobber (reg:SI 1))
7943               (clobber (reg:SI 2))
7944               (use (reg:SI 19))
7945               (use (const_int 0))])
7946    (set (reg:SI 19) (match_dup 3))]
7947   "")
7949 (define_insn "*call_val_symref_pic_post_reload"
7950   [(set (match_operand 0 "" "")
7951         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7952               (match_operand 2 "" "i")))
7953    (clobber (reg:SI 1))
7954    (clobber (reg:SI 2))
7955    (use (reg:SI 19))
7956    (use (const_int 0))]
7957   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7958   "*
7960   pa_output_arg_descriptor (insn);
7961   return pa_output_call (insn, operands[1], 0);
7963   [(set_attr "type" "call")
7964    (set (attr "length")
7965         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7966               (symbol_ref "pa_attr_length_call (insn, 0)")))])
7968 ;; powf function clobbers %fr12
7969 (define_insn "call_val_powf_pic"
7970   [(set (match_operand 0 "" "")
7971         (call (mem:SI (match_operand 1 "call_operand_address" ""))
7972               (match_operand 2 "" "i")))
7973    (clobber (reg:SI 1))
7974    (clobber (reg:SI 2))
7975    (clobber (reg:DF 48))
7976    (clobber (match_operand 3))
7977    (use (reg:SI 19))
7978    (use (const_int 1))]
7979   "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7980   "#")
7982 ;; Split out the PIC register save and restore after reload.  As the
7983 ;; split is done after reload, there are some situations in which we
7984 ;; unnecessarily save and restore %r4.  This happens when there is a
7985 ;; single call and the PIC register is not used after the call.
7987 ;; The split has to be done since call_from_call_insn () can't handle
7988 ;; the pattern as is.  Noreturn calls are special because they have to
7989 ;; terminate the basic block.  The split has to contain more than one
7990 ;; insn.
7991 (define_split
7992   [(parallel [(set (match_operand 0 "" "")
7993               (call (mem:SI (match_operand 1 "call_operand_address" ""))
7994                     (match_operand 2 "" "")))
7995               (clobber (reg:SI 1))
7996               (clobber (reg:SI 2))
7997               (clobber (reg:DF 48))
7998               (clobber (match_operand 3))
7999               (use (reg:SI 19))
8000               (use (const_int 1))])]
8001   "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed
8002    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8003   [(set (match_dup 3) (reg:SI 19))
8004    (parallel [(set (match_dup 0)
8005               (call (mem:SI (match_dup 1))
8006                     (match_dup 2)))
8007               (clobber (reg:SI 1))
8008               (clobber (reg:SI 2))
8009               (clobber (reg:DF 48))
8010               (use (reg:SI 19))
8011               (use (const_int 1))])]
8012   "")
8014 (define_split
8015   [(parallel [(set (match_operand 0 "" "")
8016               (call (mem:SI (match_operand 1 "call_operand_address" ""))
8017                     (match_operand 2 "" "")))
8018               (clobber (reg:SI 1))
8019               (clobber (reg:SI 2))
8020               (clobber (reg:DF 48))
8021               (clobber (match_operand 3))
8022               (use (reg:SI 19))
8023               (use (const_int 1))])]
8024   "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
8025   [(set (match_dup 3) (reg:SI 19))
8026    (parallel [(set (match_dup 0)
8027               (call (mem:SI (match_dup 1))
8028                     (match_dup 2)))
8029               (clobber (reg:SI 1))
8030               (clobber (reg:SI 2))
8031               (clobber (reg:DF 48))
8032               (use (reg:SI 19))
8033               (use (const_int 1))])
8034    (set (reg:SI 19) (match_dup 3))]
8035   "")
8037 (define_insn "*call_val_powf_pic_post_reload"
8038   [(set (match_operand 0 "" "")
8039         (call (mem:SI (match_operand 1 "call_operand_address" ""))
8040               (match_operand 2 "" "i")))
8041    (clobber (reg:SI 1))
8042    (clobber (reg:SI 2))
8043    (clobber (reg:DF 48))
8044    (use (reg:SI 19))
8045    (use (const_int 1))]
8046   "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8047   "*
8049   pa_output_arg_descriptor (insn);
8050   return pa_output_call (insn, operands[1], 0);
8052   [(set_attr "type" "call")
8053    (set (attr "length")
8054         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8055               (symbol_ref "pa_attr_length_call (insn, 0)")))])
8057 ;; This pattern is split if it is necessary to save and restore the
8058 ;; PIC register.
8059 (define_insn "call_val_symref_64bit"
8060   [(set (match_operand 0 "" "")
8061         (call (mem:SI (match_operand 1 "call_operand_address" ""))
8062               (match_operand 2 "" "i")))
8063    (clobber (reg:DI 1))
8064    (clobber (reg:DI 2))
8065    (clobber (match_operand 3))
8066    (use (reg:DI 27))
8067    (use (reg:DI 29))
8068    (use (const_int 0))]
8069   "TARGET_64BIT"
8070   "#")
8072 ;; Split out the PIC register save and restore after reload.  As the
8073 ;; split is done after reload, there are some situations in which we
8074 ;; unnecessarily save and restore %r4.  This happens when there is a
8075 ;; single call and the PIC register is not used after the call.
8077 ;; The split has to be done since call_from_call_insn () can't handle
8078 ;; the pattern as is.  Noreturn calls are special because they have to
8079 ;; terminate the basic block.  The split has to contain more than one
8080 ;; insn.
8081 (define_split
8082   [(parallel [(set (match_operand 0 "" "")
8083               (call (mem:SI (match_operand 1 "call_operand_address" ""))
8084                     (match_operand 2 "" "")))
8085               (clobber (reg:DI 1))
8086               (clobber (reg:DI 2))
8087               (clobber (match_operand 3))
8088               (use (reg:DI 27))
8089               (use (reg:DI 29))
8090               (use (const_int 0))])]
8091   "TARGET_64BIT && reload_completed
8092    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8093   [(set (match_dup 3) (reg:DI 27))
8094    (parallel [(set (match_dup 0)
8095               (call (mem:SI (match_dup 1))
8096                     (match_dup 2)))
8097               (clobber (reg:DI 1))
8098               (clobber (reg:DI 2))
8099               (use (reg:DI 27))
8100               (use (reg:DI 29))
8101               (use (const_int 0))])]
8102   "")
8104 (define_split
8105   [(parallel [(set (match_operand 0 "" "")
8106               (call (mem:SI (match_operand 1 "call_operand_address" ""))
8107                     (match_operand 2 "" "")))
8108               (clobber (reg:DI 1))
8109               (clobber (reg:DI 2))
8110               (clobber (match_operand 3))
8111               (use (reg:DI 27))
8112               (use (reg:DI 29))
8113               (use (const_int 0))])]
8114   "TARGET_64BIT && reload_completed"
8115   [(set (match_dup 3) (reg:DI 27))
8116    (parallel [(set (match_dup 0)
8117               (call (mem:SI (match_dup 1))
8118                     (match_dup 2)))
8119               (clobber (reg:DI 1))
8120               (clobber (reg:DI 2))
8121               (use (reg:DI 27))
8122               (use (reg:DI 29))
8123               (use (const_int 0))])
8124    (set (reg:DI 27) (match_dup 3))]
8125   "")
8127 (define_insn "*call_val_symref_64bit_post_reload"
8128   [(set (match_operand 0 "" "")
8129         (call (mem:SI (match_operand 1 "call_operand_address" ""))
8130               (match_operand 2 "" "i")))
8131    (clobber (reg:DI 1))
8132    (clobber (reg:DI 2))
8133    (use (reg:DI 27))
8134    (use (reg:DI 29))
8135    (use (const_int 0))]
8136   "TARGET_64BIT"
8137   "*
8139   return pa_output_call (insn, operands[1], 0);
8141   [(set_attr "type" "call")
8142    (set (attr "length")
8143         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8144               (symbol_ref "pa_attr_length_call (insn, 0)")))])
8146 ;; powf function clobbers %fr12
8147 (define_insn "call_val_powf_64bit"
8148   [(set (match_operand 0 "" "")
8149         (call (mem:SI (match_operand 1 "call_operand_address" ""))
8150               (match_operand 2 "" "i")))
8151    (clobber (reg:DI 1))
8152    (clobber (reg:DI 2))
8153    (clobber (reg:DF 40))
8154    (clobber (match_operand 3))
8155    (use (reg:DI 27))
8156    (use (reg:DI 29))
8157    (use (const_int 1))]
8158   "TARGET_64BIT && TARGET_HPUX"
8159   "#")
8161 ;; Split out the PIC register save and restore after reload.  As the
8162 ;; split is done after reload, there are some situations in which we
8163 ;; unnecessarily save and restore %r4.  This happens when there is a
8164 ;; single call and the PIC register is not used after the call.
8166 ;; The split has to be done since call_from_call_insn () can't handle
8167 ;; the pattern as is.  Noreturn calls are special because they have to
8168 ;; terminate the basic block.  The split has to contain more than one
8169 ;; insn.
8170 (define_split
8171   [(parallel [(set (match_operand 0 "" "")
8172               (call (mem:SI (match_operand 1 "call_operand_address" ""))
8173                     (match_operand 2 "" "")))
8174               (clobber (reg:DI 1))
8175               (clobber (reg:DI 2))
8176               (clobber (reg:DF 40))
8177               (clobber (match_operand 3))
8178               (use (reg:DI 27))
8179               (use (reg:DI 29))
8180               (use (const_int 1))])]
8181   "TARGET_64BIT && TARGET_HPUX && reload_completed
8182    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8183   [(set (match_dup 3) (reg:DI 27))
8184    (parallel [(set (match_dup 0)
8185               (call (mem:SI (match_dup 1))
8186                     (match_dup 2)))
8187               (clobber (reg:DI 1))
8188               (clobber (reg:DI 2))
8189               (clobber (reg:DF 40))
8190               (use (reg:DI 27))
8191               (use (reg:DI 29))
8192               (use (const_int 1))])]
8193   "")
8195 (define_split
8196   [(parallel [(set (match_operand 0 "" "")
8197               (call (mem:SI (match_operand 1 "call_operand_address" ""))
8198                     (match_operand 2 "" "")))
8199               (clobber (reg:DI 1))
8200               (clobber (reg:DI 2))
8201               (clobber (reg:DF 40))
8202               (clobber (match_operand 3))
8203               (use (reg:DI 27))
8204               (use (reg:DI 29))
8205               (use (const_int 1))])]
8206   "TARGET_64BIT && TARGET_HPUX && reload_completed"
8207   [(set (match_dup 3) (reg:DI 27))
8208    (parallel [(set (match_dup 0)
8209               (call (mem:SI (match_dup 1))
8210                     (match_dup 2)))
8211               (clobber (reg:DI 1))
8212               (clobber (reg:DI 2))
8213               (clobber (reg:DF 40))
8214               (use (reg:DI 27))
8215               (use (reg:DI 29))
8216               (use (const_int 1))])
8217    (set (reg:DI 27) (match_dup 3))]
8218   "")
8220 (define_insn "*call_val_powf_64bit_post_reload"
8221   [(set (match_operand 0 "" "")
8222         (call (mem:SI (match_operand 1 "call_operand_address" ""))
8223               (match_operand 2 "" "i")))
8224    (clobber (reg:DI 1))
8225    (clobber (reg:DI 2))
8226    (clobber (reg:DF 40))
8227    (use (reg:DI 27))
8228    (use (reg:DI 29))
8229    (use (const_int 1))]
8230   "TARGET_64BIT && TARGET_HPUX"
8231   "*
8233   return pa_output_call (insn, operands[1], 0);
8235   [(set_attr "type" "call")
8236    (set (attr "length")
8237         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8238               (symbol_ref "pa_attr_length_call (insn, 0)")))])
8240 (define_insn "call_val_reg"
8241   [(set (match_operand 0 "" "")
8242         (call (mem:SI (reg:SI 22))
8243               (match_operand 1 "" "i")))
8244    (clobber (reg:SI 1))
8245    (clobber (reg:SI 2))
8246    (use (const_int 1))]
8247   "!TARGET_64BIT"
8248   "*
8250   return pa_output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
8252   [(set_attr "type" "dyncall")
8253    (set (attr "length")
8254         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8255               (symbol_ref "pa_attr_length_indirect_call (insn)")))])
8257 ;; This pattern is split if it is necessary to save and restore the
8258 ;; PIC register.
8259 (define_insn "call_val_reg_pic"
8260   [(set (match_operand 0 "" "")
8261         (call (mem:SI (reg:SI 22))
8262               (match_operand 1 "" "i")))
8263    (clobber (reg:SI 1))
8264    (clobber (reg:SI 2))
8265    (clobber (match_operand 2))
8266    (use (reg:SI 19))
8267    (use (const_int 1))]
8268   "!TARGET_64BIT"
8269   "#")
8271 ;; Split out the PIC register save and restore after reload.  As the
8272 ;; split is done after reload, there are some situations in which we
8273 ;; unnecessarily save and restore %r4.  This happens when there is a
8274 ;; single call and the PIC register is not used after the call.
8276 ;; The split has to be done since call_from_call_insn () can't handle
8277 ;; the pattern as is.  Noreturn calls are special because they have to
8278 ;; terminate the basic block.  The split has to contain more than one
8279 ;; insn.
8280 (define_split
8281   [(parallel [(set (match_operand 0 "" "")
8282                    (call (mem:SI (reg:SI 22))
8283                          (match_operand 1 "" "")))
8284               (clobber (reg:SI 1))
8285               (clobber (reg:SI 2))
8286               (clobber (match_operand 2))
8287               (use (reg:SI 19))
8288               (use (const_int 1))])]
8289   "!TARGET_64BIT && reload_completed
8290    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8291   [(set (match_dup 2) (reg:SI 19))
8292    (parallel [(set (match_dup 0)
8293                    (call (mem:SI (reg:SI 22))
8294                          (match_dup 1)))
8295               (clobber (reg:SI 1))
8296               (clobber (reg:SI 2))
8297               (use (reg:SI 19))
8298               (use (const_int 1))])]
8299   "")
8301 (define_split
8302   [(parallel [(set (match_operand 0 "" "")
8303                    (call (mem:SI (reg:SI 22))
8304                          (match_operand 1 "" "")))
8305               (clobber (reg:SI 1))
8306               (clobber (reg:SI 2))
8307               (clobber (match_operand 2))
8308               (use (reg:SI 19))
8309               (use (const_int 1))])]
8310   "!TARGET_64BIT && reload_completed"
8311   [(set (match_dup 2) (reg:SI 19))
8312    (parallel [(set (match_dup 0)
8313                    (call (mem:SI (reg:SI 22))
8314                          (match_dup 1)))
8315               (clobber (reg:SI 1))
8316               (clobber (reg:SI 2))
8317               (use (reg:SI 19))
8318               (use (const_int 1))])
8319    (set (reg:SI 19) (match_dup 2))]
8320   "")
8322 (define_insn "*call_val_reg_pic_post_reload"
8323   [(set (match_operand 0 "" "")
8324         (call (mem:SI (reg:SI 22))
8325               (match_operand 1 "" "i")))
8326    (clobber (reg:SI 1))
8327    (clobber (reg:SI 2))
8328    (use (reg:SI 19))
8329    (use (const_int 1))]
8330   "!TARGET_64BIT"
8331   "*
8333   return pa_output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
8335   [(set_attr "type" "dyncall")
8336    (set (attr "length")
8337         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8338               (symbol_ref "pa_attr_length_indirect_call (insn)")))])
8340 ;; This pattern is split if it is necessary to save and restore the
8341 ;; PIC register.
8342 (define_insn "call_val_reg_64bit"
8343   [(set (match_operand 0 "" "")
8344         (call (mem:SI (match_operand:DI 1 "register_operand" "r"))
8345               (match_operand 2 "" "i")))
8346    (clobber (reg:DI 2))
8347    (clobber (match_operand 3))
8348    (use (reg:DI 27))
8349    (use (reg:DI 29))
8350    (use (const_int 1))]
8351   "TARGET_64BIT"
8352   "#")
8354 ;; Split out the PIC register save and restore after reload.  As the
8355 ;; split is done after reload, there are some situations in which we
8356 ;; unnecessarily save and restore %r4.  This happens when there is a
8357 ;; single call and the PIC register is not used after the call.
8359 ;; The split has to be done since call_from_call_insn () can't handle
8360 ;; the pattern as is.  Noreturn calls are special because they have to
8361 ;; terminate the basic block.  The split has to contain more than one
8362 ;; insn.
8363 (define_split
8364   [(parallel [(set (match_operand 0 "" "")
8365                    (call (mem:SI (match_operand:DI 1 "register_operand" ""))
8366                          (match_operand 2 "" "")))
8367               (clobber (reg:DI 2))
8368               (clobber (match_operand 3))
8369               (use (reg:DI 27))
8370               (use (reg:DI 29))
8371               (use (const_int 1))])]
8372   "TARGET_64BIT && reload_completed
8373    && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8374   [(set (match_dup 3) (reg:DI 27))
8375    (parallel [(set (match_dup 0)
8376                    (call (mem:SI (match_dup 1))
8377                          (match_dup 2)))
8378               (clobber (reg:DI 2))
8379               (use (reg:DI 27))
8380               (use (reg:DI 29))
8381               (use (const_int 1))])]
8382   "")
8384 (define_split
8385   [(parallel [(set (match_operand 0 "" "")
8386                    (call (mem:SI (match_operand:DI 1 "register_operand" ""))
8387                          (match_operand 2 "" "")))
8388               (clobber (reg:DI 2))
8389               (clobber (match_operand 3))
8390               (use (reg:DI 27))
8391               (use (reg:DI 29))
8392               (use (const_int 1))])]
8393   "TARGET_64BIT && reload_completed"
8394   [(set (match_dup 3) (reg:DI 27))
8395    (parallel [(set (match_dup 0)
8396                    (call (mem:SI (match_dup 1))
8397                          (match_dup 2)))
8398               (clobber (reg:DI 2))
8399               (use (reg:DI 27))
8400               (use (reg:DI 29))
8401               (use (const_int 1))])
8402    (set (reg:DI 27) (match_dup 3))]
8403   "")
8405 (define_insn "*call_val_reg_64bit_post_reload"
8406   [(set (match_operand 0 "" "")
8407         (call (mem:SI (match_operand:DI 1 "register_operand" "r"))
8408               (match_operand 2 "" "i")))
8409    (clobber (reg:DI 2))
8410    (use (reg:DI 27))
8411    (use (reg:DI 29))
8412    (use (const_int 1))]
8413   "TARGET_64BIT"
8414   "*
8416   return pa_output_indirect_call (insn, operands[1]);
8418   [(set_attr "type" "dyncall")
8419    (set (attr "length")
8420         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 12)]
8421               (symbol_ref "pa_attr_length_indirect_call (insn)")))])
8423 /* Expand special pc-relative call to _mcount.  */
8425 (define_expand "call_mcount"
8426   [(parallel [(call (match_operand:SI 0 "" "")
8427                     (match_operand 1 "" ""))
8428               (set (reg:SI 25)
8429                    (plus:SI (reg:SI 2)
8430                             (minus:SI (match_operand 2 "" "")
8431                                       (plus:SI (pc) (const_int 4)))))
8432               (clobber (reg:SI 2))])]
8433   "!TARGET_PORTABLE_RUNTIME"
8434   "
8436   rtx op = XEXP (operands[0], 0);
8437   rtx nb = operands[1];
8438   rtx lab = operands[2];
8440   if (TARGET_64BIT)
8441     {
8442       rtx r4 = gen_rtx_REG (word_mode, 4);
8443       emit_move_insn (arg_pointer_rtx,
8444                       gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
8445                                     GEN_INT (64)));
8446       emit_call_insn (gen_call_mcount_64bit (op, nb, lab, r4));
8447     }
8448   else
8449     {
8450       if (flag_pic)
8451         {
8452           rtx r4 = gen_rtx_REG (word_mode, 4);
8453           emit_call_insn (gen_call_mcount_pic (op, nb, lab, r4));
8454         }
8455       else
8456         emit_call_insn (gen_call_mcount_nonpic (op, nb, lab));
8457     }
8459   DONE;
8462 (define_insn "call_mcount_nonpic"
8463   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8464          (match_operand 1 "" "i"))
8465    (set (reg:SI 25)
8466         (plus:SI (reg:SI 2)
8467                  (minus:SI (match_operand 2 "" "")
8468                            (plus:SI (pc) (const_int 4)))))
8469    (clobber (reg:SI 2))]
8470   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8471   "*
8473   pa_output_arg_descriptor (insn);
8474   return \"{bl|b,l} %0,%%r2\;ldo %2-.-4(%%r2),%%r25\";
8476   [(set_attr "type" "multi")
8477    (set_attr "length" "8")])
8479 (define_insn "call_mcount_pic"
8480   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8481          (match_operand 1 "" "i"))
8482    (set (reg:SI 25)
8483         (plus:SI (reg:SI 2)
8484                  (minus:SI (match_operand 2 "" "")
8485                            (plus:SI (pc) (const_int 4)))))
8486    (clobber (reg:SI 2))
8487    (clobber (match_operand 3))
8488    (use (reg:SI 19))]
8489   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8490   "#")
8492 (define_split
8493   [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8494                     (match_operand 1 "" ""))
8495               (set (reg:SI 25)
8496                    (plus:SI (reg:SI 2)
8497                             (minus:SI (match_operand 2 "" "")
8498                                       (plus:SI (pc) (const_int 4)))))
8499               (clobber (reg:SI 2))
8500               (clobber (match_operand 3))
8501               (use (reg:SI 19))])]
8502   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
8503   [(set (match_dup 3) (reg:SI 19))
8504    (parallel [(call (mem:SI (match_dup 0))
8505                     (match_dup 1))
8506               (set (reg:SI 25)
8507                    (plus:SI (reg:SI 2)
8508                             (minus:SI (match_dup 2)
8509                                       (plus:SI (pc) (const_int 4)))))
8510               (clobber (reg:SI 2))
8511               (use (reg:SI 19))])
8512    (set (reg:SI 19) (match_dup 3))]
8513   "")
8515 (define_insn "*call_mcount_pic_post_reload"
8516   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8517          (match_operand 1 "" "i"))
8518    (set (reg:SI 25)
8519         (plus:SI (reg:SI 2)
8520                  (minus:SI (match_operand 2 "" "")
8521                            (plus:SI (pc) (const_int 4)))))
8522    (clobber (reg:SI 2))
8523    (use (reg:SI 19))]
8524   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8525   "*
8527   pa_output_arg_descriptor (insn);
8528   return \"{bl|b,l} %0,%%r2\;ldo %2-.-4(%%r2),%%r25\";
8530   [(set_attr "type" "multi")
8531    (set_attr "length" "8")])
8533 (define_insn "call_mcount_64bit"
8534   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8535          (match_operand 1 "" "i"))
8536    (set (reg:SI 25)
8537         (plus:SI (reg:SI 2)
8538                  (minus:SI (match_operand 2 "" "")
8539                            (plus:SI (pc) (const_int 4)))))
8540    (clobber (reg:DI 2))
8541    (clobber (match_operand 3))
8542    (use (reg:DI 27))
8543    (use (reg:DI 29))]
8544   "TARGET_64BIT"
8545   "#")
8547 (define_split
8548   [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8549                     (match_operand 1 "" ""))
8550               (set (reg:SI 25)
8551                    (plus:SI (reg:SI 2)
8552                             (minus:SI (match_operand 2 "" "")
8553                                       (plus:SI (pc) (const_int 4)))))
8554               (clobber (reg:DI 2))
8555               (clobber (match_operand 3))
8556               (use (reg:DI 27))
8557               (use (reg:DI 29))])]
8558   "TARGET_64BIT && reload_completed"
8559   [(set (match_dup 3) (reg:DI 27))
8560    (parallel [(call (mem:SI (match_dup 0))
8561                     (match_dup 1))
8562               (set (reg:SI 25)
8563                    (plus:SI (reg:SI 2)
8564                             (minus:SI (match_dup 2)
8565                                       (plus:SI (pc) (const_int 4)))))
8566               (clobber (reg:DI 2))
8567               (use (reg:DI 27))
8568               (use (reg:DI 29))])
8569    (set (reg:DI 27) (match_dup 3))]
8570   "")
8572 (define_insn "*call_mcount_64bit_post_reload"
8573   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8574          (match_operand 1 "" "i"))
8575    (set (reg:SI 25)
8576         (plus:SI (reg:SI 2)
8577                  (minus:SI (match_operand 2 "" "")
8578                            (plus:SI (pc) (const_int 4)))))
8579    (clobber (reg:DI 2))
8580    (use (reg:DI 27))
8581    (use (reg:DI 29))]
8582   "TARGET_64BIT"
8583   "{bl|b,l} %0,%%r2\;ldo %2-.-4(%%r2),%%r25"
8584   [(set_attr "type" "multi")
8585    (set_attr "length" "8")])
8587 ;; Call subroutine returning any type.
8589 (define_expand "untyped_call"
8590   [(parallel [(call (match_operand 0 "" "")
8591                     (const_int 0))
8592               (match_operand 1 "" "")
8593               (match_operand 2 "" "")])]
8594   ""
8595   "
8597   int i;
8599   emit_call_insn (gen_call (operands[0], const0_rtx));
8601   for (i = 0; i < XVECLEN (operands[2], 0); i++)
8602     {
8603       rtx set = XVECEXP (operands[2], 0, i);
8604       emit_move_insn (SET_DEST (set), SET_SRC (set));
8605     }
8607   /* The optimizer does not know that the call sets the function value
8608      registers we stored in the result block.  We avoid problems by
8609      claiming that all hard registers are used and clobbered at this
8610      point.  */
8611   emit_insn (gen_blockage ());
8613   DONE;
8616 (define_expand "sibcall"
8617   [(call (match_operand:SI 0 "" "")
8618          (match_operand 1 "" ""))]
8619   "!TARGET_PORTABLE_RUNTIME"
8620   "
8622   rtx op, call_insn;
8623   rtx nb = operands[1];
8625   op = XEXP (operands[0], 0);
8627   if (TARGET_64BIT)
8628     {
8629       if (!virtuals_instantiated)
8630         emit_move_insn (arg_pointer_rtx,
8631                         gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
8632                                       GEN_INT (64)));
8633       else
8634         {
8635           /* The loop pass can generate new libcalls after the virtual
8636              registers are instantiated when fpregs are disabled because
8637              the only method that we have for doing DImode multiplication
8638              is with a libcall.  This could be trouble if we haven't
8639              allocated enough space for the outgoing arguments.  */
8640           gcc_assert (INTVAL (nb) <= crtl->outgoing_args_size);
8642           emit_move_insn (arg_pointer_rtx,
8643                           gen_rtx_PLUS (word_mode, stack_pointer_rtx,
8644                                         GEN_INT (STACK_POINTER_OFFSET + 64)));
8645         }
8646     }
8648   /* Indirect sibling calls are not allowed.  */
8649   if (TARGET_64BIT)
8650     call_insn = gen_sibcall_internal_symref_64bit (op, operands[1]);
8651   else
8652     call_insn = gen_sibcall_internal_symref (op, operands[1]);
8654   call_insn = emit_call_insn (call_insn);
8656   if (TARGET_64BIT)
8657     use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), arg_pointer_rtx);
8659   /* We don't have to restore the PIC register.  */
8660   if (flag_pic)
8661     use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
8663   DONE;
8666 (define_insn "sibcall_internal_symref"
8667   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8668          (match_operand 1 "" "i"))
8669    (clobber (reg:SI 1))
8670    (use (reg:SI 2))
8671    (use (const_int 0))]
8672   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8673   "*
8675   pa_output_arg_descriptor (insn);
8676   return pa_output_call (insn, operands[0], 1);
8678   [(set_attr "type" "sibcall")
8679    (set (attr "length")
8680         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8681               (symbol_ref "pa_attr_length_call (insn, 1)")))])
8683 (define_insn "sibcall_internal_symref_64bit"
8684   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8685          (match_operand 1 "" "i"))
8686    (clobber (reg:DI 1))
8687    (use (reg:DI 2))
8688    (use (const_int 0))]
8689   "TARGET_64BIT"
8690   "*
8692   return pa_output_call (insn, operands[0], 1);
8694   [(set_attr "type" "sibcall")
8695    (set (attr "length")
8696         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8697               (symbol_ref "pa_attr_length_call (insn, 1)")))])
8699 (define_expand "sibcall_value"
8700   [(set (match_operand 0 "" "")
8701                    (call (match_operand:SI 1 "" "")
8702                          (match_operand 2 "" "")))]
8703   "!TARGET_PORTABLE_RUNTIME"
8704   "
8706   rtx op, call_insn;
8707   rtx nb = operands[1];
8709   op = XEXP (operands[1], 0);
8711   if (TARGET_64BIT)
8712     {
8713       if (!virtuals_instantiated)
8714         emit_move_insn (arg_pointer_rtx,
8715                         gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
8716                                       GEN_INT (64)));
8717       else
8718         {
8719           /* The loop pass can generate new libcalls after the virtual
8720              registers are instantiated when fpregs are disabled because
8721              the only method that we have for doing DImode multiplication
8722              is with a libcall.  This could be trouble if we haven't
8723              allocated enough space for the outgoing arguments.  */
8724           gcc_assert (INTVAL (nb) <= crtl->outgoing_args_size);
8726           emit_move_insn (arg_pointer_rtx,
8727                           gen_rtx_PLUS (word_mode, stack_pointer_rtx,
8728                                         GEN_INT (STACK_POINTER_OFFSET + 64)));
8729         }
8730     }
8732   /* Indirect sibling calls are not allowed.  */
8733   if (TARGET_64BIT)
8734     call_insn
8735       = gen_sibcall_value_internal_symref_64bit (operands[0], op, operands[2]);
8736   else
8737     call_insn
8738       = gen_sibcall_value_internal_symref (operands[0], op, operands[2]);
8740   call_insn = emit_call_insn (call_insn);
8742   if (TARGET_64BIT)
8743     use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), arg_pointer_rtx);
8745   /* We don't have to restore the PIC register.  */
8746   if (flag_pic)
8747     use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
8749   DONE;
8752 (define_insn "sibcall_value_internal_symref"
8753   [(set (match_operand 0 "" "")
8754         (call (mem:SI (match_operand 1 "call_operand_address" ""))
8755               (match_operand 2 "" "i")))
8756    (clobber (reg:SI 1))
8757    (use (reg:SI 2))
8758    (use (const_int 0))]
8759   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8760   "*
8762   pa_output_arg_descriptor (insn);
8763   return pa_output_call (insn, operands[1], 1);
8765   [(set_attr "type" "sibcall")
8766    (set (attr "length")
8767         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8768               (symbol_ref "pa_attr_length_call (insn, 1)")))])
8770 (define_insn "sibcall_value_internal_symref_64bit"
8771   [(set (match_operand 0 "" "")
8772         (call (mem:SI (match_operand 1 "call_operand_address" ""))
8773               (match_operand 2 "" "i")))
8774    (clobber (reg:DI 1))
8775    (use (reg:DI 2))
8776    (use (const_int 0))]
8777   "TARGET_64BIT"
8778   "*
8780   return pa_output_call (insn, operands[1], 1);
8782   [(set_attr "type" "sibcall")
8783    (set (attr "length")
8784         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8785               (symbol_ref "pa_attr_length_call (insn, 1)")))])
8787 (define_insn "nop"
8788   [(const_int 0)]
8789   ""
8790   "nop"
8791   [(set_attr "type" "move")
8792    (set_attr "length" "4")])
8794 ;;; EH does longjmp's from and within the data section.  Thus,
8795 ;;; an interspace branch is required for the longjmp implementation.
8796 ;;; Registers r1 and r2 are used as scratch registers for the jump
8797 ;;; when necessary.
8798 (define_expand "interspace_jump"
8799   [(parallel
8800      [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8801       (clobber (match_dup 1))])]
8802   ""
8803   "
8805   operands[1] = gen_rtx_REG (word_mode, 2);
8808 (define_insn ""
8809   [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8810   (clobber (reg:SI 2))]
8811   "TARGET_PA_20 && !TARGET_64BIT"
8812   "bve%* (%0)"
8813    [(set_attr "type" "branch")
8814     (set_attr "length" "4")])
8816 (define_insn ""
8817   [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8818   (clobber (reg:SI 2))]
8819   "TARGET_NO_SPACE_REGS && !TARGET_64BIT"
8820   "be%* 0(%%sr4,%0)"
8821    [(set_attr "type" "branch")
8822     (set_attr "length" "4")])
8824 (define_insn ""
8825   [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8826   (clobber (reg:SI 2))]
8827   "!TARGET_64BIT"
8828   "ldsid (%%sr0,%0),%%r2\;mtsp %%r2,%%sr0\;be%* 0(%%sr0,%0)"
8829    [(set_attr "type" "branch")
8830     (set_attr "length" "12")])
8832 (define_insn ""
8833   [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8834   (clobber (reg:DI 2))]
8835   "TARGET_64BIT"
8836   "bve%* (%0)"
8837    [(set_attr "type" "branch")
8838     (set_attr "length" "4")])
8840 (define_expand "builtin_longjmp"
8841   [(unspec_volatile [(match_operand 0 "register_operand" "r")] UNSPECV_LONGJMP)]
8842   ""
8843   "
8845   /* The elements of the buffer are, in order:  */
8846   rtx fp = gen_rtx_MEM (Pmode, operands[0]);
8847   rtx lab = gen_rtx_MEM (Pmode, plus_constant (Pmode, operands[0],
8848                          POINTER_SIZE / BITS_PER_UNIT));
8849   rtx stack = gen_rtx_MEM (Pmode, plus_constant (Pmode, operands[0],
8850                            (POINTER_SIZE * 2) / BITS_PER_UNIT));
8851   rtx pv = gen_rtx_REG (Pmode, 1);
8853   emit_clobber (gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (VOIDmode)));
8854   emit_clobber (gen_rtx_MEM (BLKmode, hard_frame_pointer_rtx));
8856   /* Load the label we are jumping through into r1 so that we know
8857      where to look for it when we get back to setjmp's function for
8858      restoring the gp.  */
8859   emit_move_insn (pv, lab);
8861   /* Restore the stack and frame pointers.  */
8862   fp = copy_to_reg (fp);
8863   emit_stack_restore (SAVE_NONLOCAL, stack);
8865   /* Ensure the frame pointer move is not optimized.  */
8866   emit_insn (gen_blockage ());
8867   emit_clobber (hard_frame_pointer_rtx);
8868   emit_clobber (frame_pointer_rtx);
8869   emit_move_insn (hard_frame_pointer_rtx, fp);
8871   emit_use (hard_frame_pointer_rtx);
8872   emit_use (stack_pointer_rtx);
8874   /* Prevent the insns above from being scheduled into the delay slot
8875      of the interspace jump because the space register could change.  */
8876   emit_insn (gen_blockage ());
8878   emit_jump_insn (gen_interspace_jump (pv));
8879   emit_barrier ();
8880   DONE;
8883 ;;; Operands 2 and 3 are assumed to be CONST_INTs.
8884 (define_expand "extzvsi"
8885   [(set (match_operand:SI 0 "register_operand" "")
8886         (zero_extract:SI (match_operand:SI 1 "register_operand" "")
8887                          (match_operand:SI 2 "uint5_operand" "")
8888                          (match_operand:SI 3 "uint5_operand" "")))]
8889   ""
8890   "
8892   unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
8893   unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
8895   /* PA extraction insns don't support zero length bitfields or fields
8896      extending beyond the left or right-most bits.  Also, the predicate
8897      rejects lengths equal to a word as they are better handled by
8898      the move patterns.  */
8899   if (len == 0 || pos + len > 32)
8900     FAIL;
8902   /* From mips.md: extract_bit_field doesn't verify that our source
8903      matches the predicate, so check it again here.  */
8904   if (!register_operand (operands[1], VOIDmode))
8905     FAIL;
8907   emit_insn (gen_extzv_32 (operands[0], operands[1],
8908                            operands[2], operands[3]));
8909   DONE;
8912 (define_insn "extzv_32"
8913   [(set (match_operand:SI 0 "register_operand" "=r")
8914         (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
8915                          (match_operand:SI 2 "uint5_operand" "")
8916                          (match_operand:SI 3 "uint5_operand" "")))]
8917   "UINTVAL (operands[2]) > 0
8918    && UINTVAL (operands[2]) + UINTVAL (operands[3]) <= 32"
8919   "{extru|extrw,u} %1,%3+%2-1,%2,%0"
8920   [(set_attr "type" "shift")
8921    (set_attr "length" "4")])
8923 (define_insn ""
8924   [(set (match_operand:SI 0 "register_operand" "=r")
8925         (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
8926                          (const_int 1)
8927                          (match_operand:SI 2 "register_operand" "q")))]
8928   ""
8929   "{vextru %1,1,%0|extrw,u %1,%%sar,1,%0}"
8930   [(set_attr "type" "shift")
8931    (set_attr "length" "4")])
8933 (define_expand "extzvdi"
8934   [(set (match_operand:DI 0 "register_operand" "")
8935         (zero_extract:DI (match_operand:DI 1 "register_operand" "")
8936                          (match_operand:DI 2 "uint6_operand" "")
8937                          (match_operand:DI 3 "uint6_operand" "")))]
8938   "TARGET_64BIT"
8939   "
8941   unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
8942   unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
8944   /* PA extraction insns don't support zero length bitfields or fields
8945      extending beyond the left or right-most bits.  Also, the predicate
8946      rejects lengths equal to a doubleword as they are better handled by
8947      the move patterns.  */
8948   if (len == 0 || pos + len > 64)
8949     FAIL;
8951   /* From mips.md: extract_bit_field doesn't verify that our source
8952      matches the predicate, so check it again here.  */
8953   if (!register_operand (operands[1], VOIDmode))
8954     FAIL;
8956   emit_insn (gen_extzv_64 (operands[0], operands[1],
8957                            operands[2], operands[3]));
8958   DONE;
8961 (define_insn "extzv_64"
8962   [(set (match_operand:DI 0 "register_operand" "=r")
8963         (zero_extract:DI (match_operand:DI 1 "register_operand" "r")
8964                          (match_operand:DI 2 "uint6_operand" "")
8965                          (match_operand:DI 3 "uint6_operand" "")))]
8966   "TARGET_64BIT
8967    && UINTVAL (operands[2]) > 0
8968    && UINTVAL (operands[2]) + UINTVAL (operands[3]) <= 64"
8969   "extrd,u %1,%3+%2-1,%2,%0"
8970   [(set_attr "type" "shift")
8971    (set_attr "length" "4")])
8973 (define_insn ""
8974   [(set (match_operand:DI 0 "register_operand" "=r")
8975         (zero_extract:DI (match_operand:DI 1 "register_operand" "r")
8976                          (const_int 1)
8977                          (match_operand:DI 2 "register_operand" "q")))]
8978   "TARGET_64BIT"
8979   "extrd,u %1,%%sar,1,%0"
8980   [(set_attr "type" "shift")
8981    (set_attr "length" "4")])
8983 ;;; Operands 2 and 3 are assumed to be CONST_INTs.
8984 (define_expand "extvsi"
8985   [(set (match_operand:SI 0 "register_operand" "")
8986         (sign_extract:SI (match_operand:SI 1 "register_operand" "")
8987                          (match_operand:SI 2 "uint5_operand" "")
8988                          (match_operand:SI 3 "uint5_operand" "")))]
8989   ""
8990   "
8992   unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
8993   unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
8995   /* PA extraction insns don't support zero length bitfields or fields
8996      extending beyond the left or right-most bits.  Also, the predicate
8997      rejects lengths equal to a word as they are better handled by
8998      the move patterns.  */
8999   if (len == 0 || pos + len > 32)
9000     FAIL;
9002   /* From mips.md: extract_bit_field doesn't verify that our source
9003      matches the predicate, so check it again here.  */
9004   if (!register_operand (operands[1], VOIDmode))
9005     FAIL;
9007   emit_insn (gen_extv_32 (operands[0], operands[1],
9008                           operands[2], operands[3]));
9009   DONE;
9012 (define_insn "extv_32"
9013   [(set (match_operand:SI 0 "register_operand" "=r")
9014         (sign_extract:SI (match_operand:SI 1 "register_operand" "r")
9015                          (match_operand:SI 2 "uint5_operand" "")
9016                          (match_operand:SI 3 "uint5_operand" "")))]
9017   "UINTVAL (operands[2]) > 0
9018    && UINTVAL (operands[2]) + UINTVAL (operands[3]) <= 32"
9019   "{extrs|extrw,s} %1,%3+%2-1,%2,%0"
9020   [(set_attr "type" "shift")
9021    (set_attr "length" "4")])
9023 (define_insn ""
9024   [(set (match_operand:SI 0 "register_operand" "=r")
9025         (sign_extract:SI (match_operand:SI 1 "register_operand" "r")
9026                          (const_int 1)
9027                          (match_operand:SI 2 "register_operand" "q")))]
9028   "!TARGET_64BIT"
9029   "{vextrs %1,1,%0|extrw,s %1,%%sar,1,%0}"
9030   [(set_attr "type" "shift")
9031    (set_attr "length" "4")])
9033 (define_expand "extvdi"
9034   [(set (match_operand:DI 0 "register_operand" "")
9035         (sign_extract:DI (match_operand:DI 1 "register_operand" "")
9036                          (match_operand:DI 2 "uint6_operand" "")
9037                          (match_operand:DI 3 "uint6_operand" "")))]
9038   "TARGET_64BIT"
9039   "
9041   unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
9042   unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
9044   /* PA extraction insns don't support zero length bitfields or fields
9045      extending beyond the left or right-most bits.  Also, the predicate
9046      rejects lengths equal to a doubleword as they are better handled by
9047      the move patterns.  */
9048   if (len == 0 || pos + len > 64)
9049     FAIL;
9051   /* From mips.md: extract_bit_field doesn't verify that our source
9052      matches the predicate, so check it again here.  */
9053   if (!register_operand (operands[1], VOIDmode))
9054     FAIL;
9056   emit_insn (gen_extv_64 (operands[0], operands[1],
9057                           operands[2], operands[3]));
9058   DONE;
9061 (define_insn "extv_64"
9062   [(set (match_operand:DI 0 "register_operand" "=r")
9063         (sign_extract:DI (match_operand:DI 1 "register_operand" "r")
9064                          (match_operand:DI 2 "uint6_operand" "")
9065                          (match_operand:DI 3 "uint6_operand" "")))]
9066   "TARGET_64BIT
9067    && UINTVAL (operands[2]) > 0
9068    && UINTVAL (operands[2]) + UINTVAL (operands[3]) <= 64"
9069   "extrd,s %1,%3+%2-1,%2,%0"
9070   [(set_attr "type" "shift")
9071    (set_attr "length" "4")])
9073 (define_insn ""
9074   [(set (match_operand:DI 0 "register_operand" "=r")
9075         (sign_extract:DI (match_operand:DI 1 "register_operand" "r")
9076                          (const_int 1)
9077                          (match_operand:DI 2 "register_operand" "q")))]
9078   "TARGET_64BIT"
9079   "extrd,s %1,%%sar,1,%0"
9080   [(set_attr "type" "shift")
9081    (set_attr "length" "4")])
9083 ;;; Operands 1 and 2 are assumed to be CONST_INTs.
9084 (define_expand "insvsi"
9085   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "")
9086                          (match_operand:SI 1 "uint5_operand" "")
9087                          (match_operand:SI 2 "uint5_operand" ""))
9088         (match_operand:SI 3 "arith5_operand" ""))]
9089   ""
9090   "
9092   unsigned HOST_WIDE_INT len = UINTVAL (operands[1]);
9093   unsigned HOST_WIDE_INT pos = UINTVAL (operands[2]);
9095   /* PA insertion insns don't support zero length bitfields or fields
9096      extending beyond the left or right-most bits.  Also, the predicate
9097      rejects lengths equal to a word as they are better handled by
9098      the move patterns.  */
9099   if (len <= 0 || pos + len > 32)
9100     FAIL;
9102   /* From mips.md: insert_bit_field doesn't verify that our destination
9103      matches the predicate, so check it again here.  */
9104   if (!register_operand (operands[0], VOIDmode))
9105     FAIL;
9107   emit_insn (gen_insv_32 (operands[0], operands[1],
9108                           operands[2], operands[3]));
9109   DONE;
9112 (define_insn "insv_32"
9113   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r,r")
9114                          (match_operand:SI 1 "uint5_operand" "")
9115                          (match_operand:SI 2 "uint5_operand" ""))
9116         (match_operand:SI 3 "arith5_operand" "r,L"))]
9117   "UINTVAL (operands[1]) > 0
9118    && UINTVAL (operands[1]) + UINTVAL (operands[2]) <= 32"
9119   "@
9120    {dep|depw} %3,%2+%1-1,%1,%0
9121    {depi|depwi} %3,%2+%1-1,%1,%0"
9122   [(set_attr "type" "shift,shift")
9123    (set_attr "length" "4,4")])
9125 ;; Optimize insertion of const_int values of type 1...1xxxx.
9126 (define_insn ""
9127   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
9128                          (match_operand:SI 1 "uint5_operand" "")
9129                          (match_operand:SI 2 "uint5_operand" ""))
9130         (match_operand:SI 3 "const_int_operand" ""))]
9131   "(INTVAL (operands[3]) & 0x10) != 0 &&
9132    (~INTVAL (operands[3]) & ((1L << INTVAL (operands[1])) - 1) & ~0xf) == 0"
9133   "*
9135   operands[3] = GEN_INT ((INTVAL (operands[3]) & 0xf) - 0x10);
9136   return \"{depi|depwi} %3,%2+%1-1,%1,%0\";
9138   [(set_attr "type" "shift")
9139    (set_attr "length" "4")])
9141 (define_expand "insvdi"
9142   [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "")
9143                          (match_operand:DI 1 "uint6_operand" "")
9144                          (match_operand:DI 2 "uint6_operand" ""))
9145         (match_operand:DI 3 "arith5_operand" ""))]
9146   "TARGET_64BIT"
9147   "
9149   unsigned HOST_WIDE_INT len = UINTVAL (operands[1]);
9150   unsigned HOST_WIDE_INT pos = UINTVAL (operands[2]);
9152   /* PA insertion insns don't support zero length bitfields or fields
9153      extending beyond the left or right-most bits.  Also, the predicate
9154      rejects lengths equal to a doubleword as they are better handled by
9155      the move patterns.  */
9156   if (len <= 0 || pos + len > 64)
9157     FAIL;
9159   /* From mips.md: insert_bit_field doesn't verify that our destination
9160      matches the predicate, so check it again here.  */
9161   if (!register_operand (operands[0], VOIDmode))
9162     FAIL;
9164   emit_insn (gen_insv_64 (operands[0], operands[1],
9165                           operands[2], operands[3]));
9166   DONE;
9169 (define_insn "insv_64"
9170   [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+r,r")
9171                          (match_operand:DI 1 "uint6_operand" "")
9172                          (match_operand:DI 2 "uint6_operand" ""))
9173         (match_operand:DI 3 "arith5_operand" "r,L"))]
9174   "TARGET_64BIT
9175    && UINTVAL (operands[1]) > 0
9176    && UINTVAL (operands[1]) + UINTVAL (operands[2]) <= 64"
9177   "@
9178    depd %3,%2+%1-1,%1,%0
9179    depdi %3,%2+%1-1,%1,%0"
9180   [(set_attr "type" "shift,shift")
9181    (set_attr "length" "4,4")])
9183 ;; Optimize insertion of const_int values of type 1...1xxxx.
9184 (define_insn ""
9185   [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+r")
9186                          (match_operand:DI 1 "uint6_operand" "")
9187                          (match_operand:DI 2 "uint6_operand" ""))
9188         (match_operand:DI 3 "const_int_operand" ""))]
9189   "(INTVAL (operands[3]) & 0x10) != 0
9190    && TARGET_64BIT
9191    && (~INTVAL (operands[3]) & ((1L << INTVAL (operands[1])) - 1) & ~0xf) == 0"
9192   "*
9194   operands[3] = GEN_INT ((INTVAL (operands[3]) & 0xf) - 0x10);
9195   return \"depdi %3,%2+%1-1,%1,%0\";
9197   [(set_attr "type" "shift")
9198    (set_attr "length" "4")])
9200 (define_insn ""
9201   [(set (match_operand:DI 0 "register_operand" "=r")
9202         (ashift:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
9203                    (const_int 32)))]
9204   "TARGET_64BIT"
9205   "depd,z %1,31,32,%0"
9206   [(set_attr "type" "shift")
9207    (set_attr "length" "4")])
9209 ;; This insn is used for some loop tests, typically loops reversed when
9210 ;; strength reduction is used.  It is actually created when the instruction
9211 ;; combination phase combines the special loop test.  Since this insn
9212 ;; is both a jump insn and has an output, it must deal with its own
9213 ;; reloads, hence the `Q' constraints.  The `!' constraints direct reload
9214 ;; to not choose the register alternatives in the event a reload is needed.
9215 (define_insn "decrement_and_branch_until_zero"
9216   [(set (pc)
9217         (if_then_else
9218           (match_operator 2 "ordered_comparison_operator"
9219            [(plus:SI
9220               (match_operand:SI 0 "reg_before_reload_operand" "+!r,!*f,*Q")
9221               (match_operand:SI 1 "int5_operand" "L,L,L"))
9222             (const_int 0)])
9223           (label_ref (match_operand 3 "" ""))
9224           (pc)))
9225    (set (match_dup 0)
9226         (plus:SI (match_dup 0) (match_dup 1)))
9227    (clobber (match_scratch:SI 4 "=X,r,r"))]
9228   ""
9229   "* return pa_output_dbra (operands, insn, which_alternative); "
9230 ;; Do not expect to understand this the first time through.
9231 [(set_attr "type" "cbranch,multi,multi")
9232  (set (attr "length")
9233       (if_then_else (eq_attr "alternative" "0")
9234 ;; Loop counter in register case
9235 ;; Short branch has length of 4
9236 ;; Long branch has length of 8, 20, 24 or 28
9237         (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9238                (const_int MAX_12BIT_OFFSET))
9239            (const_int 4)
9240            (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9241                (const_int MAX_17BIT_OFFSET))
9242            (const_int 8)
9243            (match_test "TARGET_PORTABLE_RUNTIME")
9244            (const_int 24)
9245            (not (match_test "flag_pic"))
9246            (const_int 20)]
9247           (const_int 28))
9249 ;; Loop counter in FP reg case.
9250 ;; Extra goo to deal with additional reload insns.
9251         (if_then_else (eq_attr "alternative" "1")
9252           (if_then_else (lt (match_dup 3) (pc))
9253              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 24))))
9254                       (const_int MAX_12BIT_OFFSET))
9255                     (const_int 24)
9256                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 24))))
9257                       (const_int MAX_17BIT_OFFSET))
9258                     (const_int 28)
9259                     (match_test "TARGET_PORTABLE_RUNTIME")
9260                     (const_int 44)
9261                     (not (match_test "flag_pic"))
9262                     (const_int 40)]
9263                   (const_int 48))
9264              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9265                       (const_int MAX_12BIT_OFFSET))
9266                     (const_int 24)
9267                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9268                       (const_int MAX_17BIT_OFFSET))
9269                     (const_int 28)
9270                     (match_test "TARGET_PORTABLE_RUNTIME")
9271                     (const_int 44)
9272                     (not (match_test "flag_pic"))
9273                     (const_int 40)]
9274                   (const_int 48)))
9276 ;; Loop counter in memory case.
9277 ;; Extra goo to deal with additional reload insns.
9278         (if_then_else (lt (match_dup 3) (pc))
9279              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9280                       (const_int MAX_12BIT_OFFSET))
9281                     (const_int 12)
9282                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9283                       (const_int MAX_17BIT_OFFSET))
9284                     (const_int 16)
9285                     (match_test "TARGET_PORTABLE_RUNTIME")
9286                     (const_int 32)
9287                     (not (match_test "flag_pic"))
9288                     (const_int 28)]
9289                   (const_int 36))
9290              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9291                       (const_int MAX_12BIT_OFFSET))
9292                     (const_int 12)
9293                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9294                       (const_int MAX_17BIT_OFFSET))
9295                     (const_int 16)
9296                     (match_test "TARGET_PORTABLE_RUNTIME")
9297                     (const_int 32)
9298                     (not (match_test "flag_pic"))
9299                     (const_int 28)]
9300                   (const_int 36))))))])
9302 (define_insn ""
9303   [(set (pc)
9304         (if_then_else
9305           (match_operator 2 "movb_comparison_operator"
9306            [(match_operand:SI 1 "register_operand" "r,r,r,r") (const_int 0)])
9307           (label_ref (match_operand 3 "" ""))
9308           (pc)))
9309    (set (match_operand:SI 0 "reg_before_reload_operand" "=!r,!*f,*Q,!*q")
9310         (match_dup 1))]
9311   ""
9312 "* return pa_output_movb (operands, insn, which_alternative, 0); "
9313 ;; Do not expect to understand this the first time through.
9314 [(set_attr "type" "cbranch,multi,multi,multi")
9315  (set (attr "length")
9316       (if_then_else (eq_attr "alternative" "0")
9317 ;; Loop counter in register case
9318 ;; Short branch has length of 4
9319 ;; Long branch has length of 8, 20, 24 or 28
9320         (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9321                (const_int MAX_12BIT_OFFSET))
9322            (const_int 4)
9323            (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9324                (const_int MAX_17BIT_OFFSET))
9325            (const_int 8)
9326            (match_test "TARGET_PORTABLE_RUNTIME")
9327            (const_int 24)
9328            (not (match_test "flag_pic"))
9329            (const_int 20)]
9330           (const_int 28))
9332 ;; Loop counter in FP reg case.
9333 ;; Extra goo to deal with additional reload insns.
9334         (if_then_else (eq_attr "alternative" "1")
9335           (if_then_else (lt (match_dup 3) (pc))
9336              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9337                       (const_int MAX_12BIT_OFFSET))
9338                     (const_int 12)
9339                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9340                       (const_int MAX_17BIT_OFFSET))
9341                     (const_int 16)
9342                     (match_test "TARGET_PORTABLE_RUNTIME")
9343                     (const_int 32)
9344                     (not (match_test "flag_pic"))
9345                     (const_int 28)]
9346                   (const_int 36))
9347              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9348                       (const_int MAX_12BIT_OFFSET))
9349                     (const_int 12)
9350                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9351                       (const_int MAX_17BIT_OFFSET))
9352                     (const_int 16)
9353                     (match_test "TARGET_PORTABLE_RUNTIME")
9354                     (const_int 32)
9355                     (not (match_test "flag_pic"))
9356                     (const_int 28)]
9357                   (const_int 36)))
9359 ;; Loop counter in memory or sar case.
9360 ;; Extra goo to deal with additional reload insns.
9361         (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9362                    (const_int MAX_12BIT_OFFSET))
9363                 (const_int 8)
9364                 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9365                   (const_int MAX_17BIT_OFFSET))
9366                 (const_int 12)
9367                 (match_test "TARGET_PORTABLE_RUNTIME")
9368                 (const_int 28)
9369                 (not (match_test "flag_pic"))
9370                 (const_int 24)]
9371               (const_int 32)))))])
9373 ;; Handle negated branch.
9374 (define_insn ""
9375   [(set (pc)
9376         (if_then_else
9377           (match_operator 2 "movb_comparison_operator"
9378            [(match_operand:SI 1 "register_operand" "r,r,r,r") (const_int 0)])
9379           (pc)
9380           (label_ref (match_operand 3 "" ""))))
9381    (set (match_operand:SI 0 "reg_before_reload_operand" "=!r,!*f,*Q,!*q")
9382         (match_dup 1))]
9383   ""
9384 "* return pa_output_movb (operands, insn, which_alternative, 1); "
9385 ;; Do not expect to understand this the first time through.
9386 [(set_attr "type" "cbranch,multi,multi,multi")
9387  (set (attr "length")
9388       (if_then_else (eq_attr "alternative" "0")
9389 ;; Loop counter in register case
9390 ;; Short branch has length of 4
9391 ;; Long branch has length of 8
9392         (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9393                (const_int MAX_12BIT_OFFSET))
9394            (const_int 4)
9395            (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9396                (const_int MAX_17BIT_OFFSET))
9397            (const_int 8)
9398            (match_test "TARGET_PORTABLE_RUNTIME")
9399            (const_int 24)
9400            (not (match_test "flag_pic"))
9401            (const_int 20)]
9402           (const_int 28))
9404 ;; Loop counter in FP reg case.
9405 ;; Extra goo to deal with additional reload insns.
9406         (if_then_else (eq_attr "alternative" "1")
9407           (if_then_else (lt (match_dup 3) (pc))
9408              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9409                       (const_int MAX_12BIT_OFFSET))
9410                     (const_int 12)
9411                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9412                       (const_int MAX_17BIT_OFFSET))
9413                     (const_int 16)
9414                     (match_test "TARGET_PORTABLE_RUNTIME")
9415                     (const_int 32)
9416                     (not (match_test "flag_pic"))
9417                     (const_int 28)]
9418                   (const_int 36))
9419              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9420                       (const_int MAX_12BIT_OFFSET))
9421                     (const_int 12)
9422                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9423                       (const_int MAX_17BIT_OFFSET))
9424                     (const_int 16)
9425                     (match_test "TARGET_PORTABLE_RUNTIME")
9426                     (const_int 32)
9427                     (not (match_test "flag_pic"))
9428                     (const_int 28)]
9429                   (const_int 36)))
9431 ;; Loop counter in memory or SAR case.
9432 ;; Extra goo to deal with additional reload insns.
9433         (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9434                    (const_int MAX_12BIT_OFFSET))
9435                 (const_int 8)
9436                 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9437                   (const_int MAX_17BIT_OFFSET))
9438                 (const_int 12)
9439                 (match_test "TARGET_PORTABLE_RUNTIME")
9440                 (const_int 28)
9441                 (not (match_test "flag_pic"))
9442                 (const_int 24)]
9443               (const_int 32)))))])
9445 (define_insn ""
9446   [(set (pc) (label_ref (match_operand 3 "" "" )))
9447    (set (match_operand:SI 0 "ireg_operand" "=r")
9448         (plus:SI (match_operand:SI 1 "ireg_operand" "r")
9449                  (match_operand:SI 2 "ireg_or_int5_operand" "rL")))]
9450   "(reload_completed && operands[0] == operands[1]) || operands[0] == operands[2]"
9451   "*
9453   return pa_output_parallel_addb (operands, insn);
9455 [(set_attr "type" "parallel_branch")
9456  (set (attr "length")
9457     (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9458                (const_int MAX_12BIT_OFFSET))
9459            (const_int 4)
9460            (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9461                (const_int MAX_17BIT_OFFSET))
9462            (const_int 8)
9463            (match_test "TARGET_PORTABLE_RUNTIME")
9464            (const_int 24)
9465            (not (match_test "flag_pic"))
9466            (const_int 20)]
9467           (const_int 28)))])
9469 (define_insn ""
9470   [(set (pc) (label_ref (match_operand 2 "" "" )))
9471    (set (match_operand:SF 0 "ireg_operand" "=r")
9472         (match_operand:SF 1 "ireg_or_int5_operand" "rL"))]
9473   "reload_completed"
9474   "*
9476   return pa_output_parallel_movb (operands, insn);
9478 [(set_attr "type" "parallel_branch")
9479  (set (attr "length")
9480     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9481                (const_int MAX_12BIT_OFFSET))
9482            (const_int 4)
9483            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9484                (const_int MAX_17BIT_OFFSET))
9485            (const_int 8)
9486            (match_test "TARGET_PORTABLE_RUNTIME")
9487            (const_int 24)
9488            (not (match_test "flag_pic"))
9489            (const_int 20)]
9490           (const_int 28)))])
9492 (define_insn ""
9493   [(set (pc) (label_ref (match_operand 2 "" "" )))
9494    (set (match_operand:SI 0 "ireg_operand" "=r")
9495         (match_operand:SI 1 "ireg_or_int5_operand" "rL"))]
9496   "reload_completed"
9497   "*
9499   return pa_output_parallel_movb (operands, insn);
9501 [(set_attr "type" "parallel_branch")
9502  (set (attr "length")
9503     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9504                (const_int MAX_12BIT_OFFSET))
9505            (const_int 4)
9506            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9507                (const_int MAX_17BIT_OFFSET))
9508            (const_int 8)
9509            (match_test "TARGET_PORTABLE_RUNTIME")
9510            (const_int 24)
9511            (not (match_test "flag_pic"))
9512            (const_int 20)]
9513           (const_int 28)))])
9515 (define_insn ""
9516   [(set (pc) (label_ref (match_operand 2 "" "" )))
9517    (set (match_operand:HI 0 "ireg_operand" "=r")
9518         (match_operand:HI 1 "ireg_or_int5_operand" "rL"))]
9519   "reload_completed"
9520   "*
9522   return pa_output_parallel_movb (operands, insn);
9524 [(set_attr "type" "parallel_branch")
9525  (set (attr "length")
9526     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9527                (const_int MAX_12BIT_OFFSET))
9528            (const_int 4)
9529            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9530                (const_int MAX_17BIT_OFFSET))
9531            (const_int 8)
9532            (match_test "TARGET_PORTABLE_RUNTIME")
9533            (const_int 24)
9534            (not (match_test "flag_pic"))
9535            (const_int 20)]
9536           (const_int 28)))])
9538 (define_insn ""
9539   [(set (pc) (label_ref (match_operand 2 "" "" )))
9540    (set (match_operand:QI 0 "ireg_operand" "=r")
9541         (match_operand:QI 1 "ireg_or_int5_operand" "rL"))]
9542   "reload_completed"
9543   "*
9545   return pa_output_parallel_movb (operands, insn);
9547 [(set_attr "type" "parallel_branch")
9548  (set (attr "length")
9549     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9550                (const_int MAX_12BIT_OFFSET))
9551            (const_int 4)
9552            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9553                (const_int MAX_17BIT_OFFSET))
9554            (const_int 8)
9555            (match_test "TARGET_PORTABLE_RUNTIME")
9556            (const_int 24)
9557            (not (match_test "flag_pic"))
9558            (const_int 20)]
9559           (const_int 28)))])
9561 (define_insn ""
9562   [(set (match_operand 0 "register_operand" "=f")
9563         (mult (match_operand 1 "register_operand" "f")
9564               (match_operand 2 "register_operand" "f")))
9565    (set (match_operand 3 "register_operand" "+f")
9566         (plus (match_operand 4 "register_operand" "f")
9567               (match_operand 5 "register_operand" "f")))]
9568   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9569    && reload_completed && pa_fmpyaddoperands (operands)"
9570   "*
9572   if (GET_MODE (operands[0]) == DFmode)
9573     {
9574       if (rtx_equal_p (operands[3], operands[5]))
9575         return \"fmpyadd,dbl %1,%2,%0,%4,%3\";
9576       else
9577         return \"fmpyadd,dbl %1,%2,%0,%5,%3\";
9578     }
9579   else
9580     {
9581       if (rtx_equal_p (operands[3], operands[5]))
9582         return \"fmpyadd,sgl %1,%2,%0,%4,%3\";
9583       else
9584         return \"fmpyadd,sgl %1,%2,%0,%5,%3\";
9585     }
9587   [(set_attr "type" "fpalu")
9588    (set_attr "length" "4")])
9590 (define_insn ""
9591   [(set (match_operand 3 "register_operand" "+f")
9592         (plus (match_operand 4 "register_operand" "f")
9593               (match_operand 5 "register_operand" "f")))
9594    (set (match_operand 0 "register_operand" "=f")
9595         (mult (match_operand 1 "register_operand" "f")
9596               (match_operand 2 "register_operand" "f")))]
9597   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9598    && reload_completed && pa_fmpyaddoperands (operands)"
9599   "*
9601   if (GET_MODE (operands[0]) == DFmode)
9602     {
9603       if (rtx_equal_p (operands[3], operands[5]))
9604         return \"fmpyadd,dbl %1,%2,%0,%4,%3\";
9605       else
9606         return \"fmpyadd,dbl %1,%2,%0,%5,%3\";
9607     }
9608   else
9609     {
9610       if (rtx_equal_p (operands[3], operands[5]))
9611         return \"fmpyadd,sgl %1,%2,%0,%4,%3\";
9612       else
9613         return \"fmpyadd,sgl %1,%2,%0,%5,%3\";
9614     }
9616   [(set_attr "type" "fpalu")
9617    (set_attr "length" "4")])
9619 (define_insn ""
9620   [(set (match_operand 0 "register_operand" "=f")
9621         (mult (match_operand 1 "register_operand" "f")
9622               (match_operand 2 "register_operand" "f")))
9623    (set (match_operand 3 "register_operand" "+f")
9624         (minus (match_operand 4 "register_operand" "f")
9625                (match_operand 5 "register_operand" "f")))]
9626   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9627    && reload_completed && pa_fmpysuboperands (operands)"
9628   "*
9630   if (GET_MODE (operands[0]) == DFmode)
9631     return \"fmpysub,dbl %1,%2,%0,%5,%3\";
9632   else
9633     return \"fmpysub,sgl %1,%2,%0,%5,%3\";
9635   [(set_attr "type" "fpalu")
9636    (set_attr "length" "4")])
9638 (define_insn ""
9639   [(set (match_operand 3 "register_operand" "+f")
9640         (minus (match_operand 4 "register_operand" "f")
9641                (match_operand 5 "register_operand" "f")))
9642    (set (match_operand 0 "register_operand" "=f")
9643         (mult (match_operand 1 "register_operand" "f")
9644               (match_operand 2 "register_operand" "f")))]
9645   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9646    && reload_completed && pa_fmpysuboperands (operands)"
9647   "*
9649   if (GET_MODE (operands[0]) == DFmode)
9650     return \"fmpysub,dbl %1,%2,%0,%5,%3\";
9651   else
9652     return \"fmpysub,sgl %1,%2,%0,%5,%3\";
9654   [(set_attr "type" "fpalu")
9655    (set_attr "length" "4")])
9657 ;; The following two patterns are used by the trampoline code for nested
9658 ;; functions.  They flush the I and D cache lines from the start address
9659 ;; (operand0) to the end address (operand1).  No lines are flushed if the
9660 ;; end address is less than the start address (unsigned).
9662 ;; Because the range of memory flushed is variable and the size of a MEM
9663 ;; can only be a CONST_INT, the patterns specify that they perform an
9664 ;; unspecified volatile operation on all memory.
9666 ;; The address range for an icache flush must lie within a single
9667 ;; space on targets with non-equivalent space registers.
9669 ;; Operand 0 contains the start address.
9670 ;; Operand 1 contains the end address.
9671 ;; Operand 2 contains the line length to use.
9672 (define_insn "dcacheflush<P:mode>"
9673   [(const_int 1)
9674    (unspec_volatile [(mem:BLK (scratch))] UNSPECV_DCACHE)
9675    (use (match_operand 0 "pmode_register_operand" "r"))
9676    (use (match_operand 1 "pmode_register_operand" "r"))
9677    (use (match_operand 2 "pmode_register_operand" "r"))
9678    (clobber (match_scratch:P 3 "=&0"))]
9679   ""
9680   "cmpb,<dwc><<=,n %3,%1,.\;fdc,m %2(%3)\;sync"
9681   [(set_attr "type" "multi")
9682    (set_attr "length" "12")])
9684 (define_insn "icacheflush<P:mode>"
9685   [(const_int 2)
9686    (unspec_volatile [(mem:BLK (scratch))] UNSPECV_ICACHE)
9687    (use (match_operand 0 "pmode_register_operand" "r"))
9688    (use (match_operand 1 "pmode_register_operand" "r"))
9689    (use (match_operand 2 "pmode_register_operand" "r"))
9690    (clobber (match_operand 3 "pmode_register_operand" "=&r"))
9691    (clobber (match_operand 4 "pmode_register_operand" "=&r"))
9692    (clobber (match_scratch:P 5 "=&0"))]
9693   ""
9694   "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"
9695   [(set_attr "type" "multi")
9696    (set_attr "length" "52")])
9698 ;; An out-of-line prologue.
9699 (define_insn "outline_prologue_call"
9700   [(unspec_volatile [(const_int 0)] UNSPECV_OPC)
9701    (clobber (reg:SI 31))
9702    (clobber (reg:SI 22))
9703    (clobber (reg:SI 21))
9704    (clobber (reg:SI 20))
9705    (clobber (reg:SI 19))
9706    (clobber (reg:SI 1))]
9707   ""
9708   "*
9711   /* We need two different versions depending on whether or not we
9712      need a frame pointer.   Also note that we return to the instruction
9713      immediately after the branch rather than two instructions after the
9714      break as normally is the case.  */
9715   if (frame_pointer_needed)
9716     {
9717       /* Must import the magic millicode routine(s).  */
9718       output_asm_insn (\".IMPORT __outline_prologue_fp,MILLICODE\", NULL);
9720       if (TARGET_PORTABLE_RUNTIME)
9721         {
9722           output_asm_insn (\"ldil L'__outline_prologue_fp,%%r31\", NULL);
9723           output_asm_insn (\"ble,n R'__outline_prologue_fp(%%sr0,%%r31)\",
9724                            NULL);
9725         }
9726       else
9727         output_asm_insn (\"{bl|b,l},n __outline_prologue_fp,%%r31\", NULL);
9728     }
9729   else
9730     {
9731       /* Must import the magic millicode routine(s).  */
9732       output_asm_insn (\".IMPORT __outline_prologue,MILLICODE\", NULL);
9734       if (TARGET_PORTABLE_RUNTIME)
9735         {
9736           output_asm_insn (\"ldil L'__outline_prologue,%%r31\", NULL);
9737           output_asm_insn (\"ble,n R'__outline_prologue(%%sr0,%%r31)\", NULL);
9738         }
9739       else
9740         output_asm_insn (\"{bl|b,l},n __outline_prologue,%%r31\", NULL);
9741     }
9742   return \"\";
9744   [(set_attr "type" "multi")
9745    (set_attr "length" "8")])
9747 ;; An out-of-line epilogue.
9748 (define_insn "outline_epilogue_call"
9749   [(unspec_volatile [(const_int 1)] UNSPECV_OEC)
9750    (use (reg:SI 29))
9751    (use (reg:SI 28))
9752    (clobber (reg:SI 31))
9753    (clobber (reg:SI 22))
9754    (clobber (reg:SI 21))
9755    (clobber (reg:SI 20))
9756    (clobber (reg:SI 19))
9757    (clobber (reg:SI 2))
9758    (clobber (reg:SI 1))]
9759   ""
9760   "*
9763   /* We need two different versions depending on whether or not we
9764      need a frame pointer.   Also note that we return to the instruction
9765      immediately after the branch rather than two instructions after the
9766      break as normally is the case.  */
9767   if (frame_pointer_needed)
9768     {
9769       /* Must import the magic millicode routine.  */
9770       output_asm_insn (\".IMPORT __outline_epilogue_fp,MILLICODE\", NULL);
9772       /* The out-of-line prologue will make sure we return to the right
9773          instruction.  */
9774       if (TARGET_PORTABLE_RUNTIME)
9775         {
9776           output_asm_insn (\"ldil L'__outline_epilogue_fp,%%r31\", NULL);
9777           output_asm_insn (\"ble,n R'__outline_epilogue_fp(%%sr0,%%r31)\",
9778                            NULL);
9779         }
9780       else
9781         output_asm_insn (\"{bl|b,l},n __outline_epilogue_fp,%%r31\", NULL);
9782     }
9783   else
9784     {
9785       /* Must import the magic millicode routine.  */
9786       output_asm_insn (\".IMPORT __outline_epilogue,MILLICODE\", NULL);
9788       /* The out-of-line prologue will make sure we return to the right
9789          instruction.  */
9790       if (TARGET_PORTABLE_RUNTIME)
9791         {
9792           output_asm_insn (\"ldil L'__outline_epilogue,%%r31\", NULL);
9793           output_asm_insn (\"ble,n R'__outline_epilogue(%%sr0,%%r31)\", NULL);
9794         }
9795       else
9796         output_asm_insn (\"{bl|b,l},n __outline_epilogue,%%r31\", NULL);
9797     }
9798   return \"\";
9800   [(set_attr "type" "multi")
9801    (set_attr "length" "8")])
9803 ;; Given a function pointer, canonicalize it so it can be 
9804 ;; reliably compared to another function pointer.  */
9805 (define_expand "canonicalize_funcptr_for_compare"
9806   [(set (reg:SI 26) (match_operand:SI 1 "register_operand" ""))
9807    (parallel [(set (reg:SI 29) (unspec:SI [(reg:SI 26)] UNSPEC_CFFC))
9808               (clobber (match_dup 2))
9809               (clobber (reg:SI 26))
9810               (clobber (reg:SI 22))
9811               (clobber (reg:SI 31))])
9812    (set (match_operand:SI 0 "register_operand" "")
9813         (reg:SI 29))]
9814   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
9815   "
9817   if (TARGET_ELF32)
9818     {
9819       rtx canonicalize_funcptr_for_compare_libfunc
9820         = init_one_libfunc (CANONICALIZE_FUNCPTR_FOR_COMPARE_LIBCALL);
9822       emit_library_call_value (canonicalize_funcptr_for_compare_libfunc,
9823                                operands[0], LCT_NORMAL, Pmode,
9824                                operands[1], Pmode);
9825       DONE;
9826     }
9828   operands[2] = gen_reg_rtx (SImode);
9829   if (GET_CODE (operands[1]) != REG)
9830     {
9831       rtx tmp = gen_reg_rtx (Pmode);
9832       emit_move_insn (tmp, operands[1]);
9833       operands[1] = tmp;
9834     }
9837 (define_insn "*$$sh_func_adrs"
9838   [(set (reg:SI 29) (unspec:SI [(reg:SI 26)] UNSPEC_CFFC))
9839    (clobber (match_operand:SI 0 "register_operand" "=a"))
9840    (clobber (reg:SI 26))
9841    (clobber (reg:SI 22))
9842    (clobber (reg:SI 31))]
9843   "!TARGET_64BIT"
9844   "*
9846   int length = get_attr_length (insn);
9847   rtx xoperands[2];
9849   xoperands[0] = GEN_INT (length - 8);
9850   xoperands[1] = GEN_INT (length - 16);
9852   /* Must import the magic millicode routine.  */
9853   output_asm_insn (\".IMPORT $$sh_func_adrs,MILLICODE\", NULL);
9855   /* This is absolutely amazing.
9857      First, copy our input parameter into %r29 just in case we don't
9858      need to call $$sh_func_adrs.  */
9859   output_asm_insn (\"copy %%r26,%%r29\", NULL);
9860   output_asm_insn (\"{extru|extrw,u} %%r26,31,2,%%r31\", NULL);
9862   /* Next, examine the low two bits in %r26, if they aren't 0x2, then
9863      we use %r26 unchanged.  */
9864   output_asm_insn (\"{comib|cmpib},<>,n 2,%%r31,.+%0\", xoperands);
9865   output_asm_insn (\"ldi 4096,%%r31\", NULL);
9867   /* Next, compare %r26 with 4096, if %r26 is less than or equal to
9868      4096, then again we use %r26 unchanged.  */
9869   output_asm_insn (\"{comb|cmpb},<<,n %%r26,%%r31,.+%1\", xoperands);
9871   /* Finally, call $$sh_func_adrs to extract the function's real add24.  */
9872   return pa_output_millicode_call (insn,
9873                                    gen_rtx_SYMBOL_REF (SImode,
9874                                                        \"$$sh_func_adrs\"));
9876   [(set_attr "type" "sh_func_adrs")
9877    (set (attr "length")
9878         (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 28)]
9879               (plus (symbol_ref "pa_attr_length_millicode_call (insn)")
9880                     (const_int 20))))])
9882 ;; On the PA, the PIC register is call clobbered, so it must
9883 ;; be saved & restored around calls by the caller.  If the call
9884 ;; doesn't return normally (nonlocal goto, or an exception is
9885 ;; thrown), then the code at the exception handler label must
9886 ;; restore the PIC register.
9887 (define_expand "exception_receiver"
9888   [(const_int 4)]
9889   "flag_pic"
9890   "
9892   /* On the 64-bit port, we need a blockage because there is
9893      confusion regarding the dependence of the restore on the
9894      frame pointer.  As a result, the frame pointer and pic
9895      register restores sometimes are interchanged erroneously.  */
9896   if (TARGET_64BIT)
9897     emit_insn (gen_blockage ());
9898   /* Restore the PIC register using hppa_pic_save_rtx ().  The
9899      PIC register is not saved in the frame in 64-bit ABI.  */
9900   emit_move_insn (pic_offset_table_rtx, hppa_pic_save_rtx ());
9901   emit_insn (gen_blockage ());
9902   DONE;
9905 (define_expand "builtin_setjmp_receiver"
9906   [(label_ref (match_operand 0 "" ""))]
9907   "flag_pic"
9908   "
9910   if (TARGET_64BIT)
9911     emit_insn (gen_blockage ());
9912   /* Restore the PIC register.  Hopefully, this will always be from
9913      a stack slot.  The only registers that are valid after a
9914      builtin_longjmp are the stack and frame pointers.  */
9915   emit_move_insn (pic_offset_table_rtx, hppa_pic_save_rtx ());
9916   emit_insn (gen_blockage ());
9917   DONE;
9920 ;; Allocate new stack space and update the saved stack pointer in the
9921 ;; frame marker.  The HP C compilers also copy additional words in the
9922 ;; frame marker.  The 64-bit compiler copies words at -48, -32 and -24.
9923 ;; The 32-bit compiler copies the word at -16 (Static Link).  We
9924 ;; currently don't copy these values.
9926 ;; Since the copy of the frame marker can't be done atomically, I
9927 ;; suspect that using it for unwind purposes may be somewhat unreliable.
9928 ;; The HP compilers appear to raise the stack and copy the frame
9929 ;; marker in a strict instruction sequence.  This suggests that the
9930 ;; unwind library may check for an alloca sequence when ALLOCA_FRAME
9931 ;; is set in the callinfo data.  We currently don't set ALLOCA_FRAME
9932 ;; as GAS doesn't support it, or try to keep the instructions emitted
9933 ;; here in strict sequence.
9934 (define_expand "allocate_stack"
9935   [(match_operand 0 "" "")
9936    (match_operand 1 "" "")]
9937   ""
9938   "
9940   rtx addr;
9942   /* Since the stack grows upward, we need to store virtual_stack_dynamic_rtx
9943      in operand 0 before adjusting the stack.  */
9944   emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
9945   anti_adjust_stack (operands[1]);
9946   if (TARGET_HPUX_UNWIND_LIBRARY)
9947     {
9948       addr = gen_rtx_PLUS (word_mode, stack_pointer_rtx,
9949                            GEN_INT (TARGET_64BIT ? -8 : -4));
9950       emit_move_insn (gen_rtx_MEM (word_mode, addr), hard_frame_pointer_rtx);
9951     }
9952   if (!TARGET_64BIT && flag_pic)
9953     {
9954       rtx addr = gen_rtx_PLUS (word_mode, stack_pointer_rtx, GEN_INT (-32));
9955       emit_move_insn (gen_rtx_MEM (word_mode, addr), pic_offset_table_rtx);
9956     }
9957   DONE;
9960 (define_expand "prefetch"
9961   [(match_operand 0 "address_operand" "")
9962    (match_operand 1 "const_int_operand" "")
9963    (match_operand 2 "const_int_operand" "")]
9964   "TARGET_PA_20"
9966   operands[0] = copy_addr_to_reg (operands[0]);
9967   emit_insn (gen_prefetch_20 (operands[0], operands[1], operands[2]));
9968   DONE;
9971 (define_insn "prefetch_20"
9972   [(prefetch (match_operand 0 "pmode_register_operand" "r")
9973              (match_operand:SI 1 "const_int_operand" "n")
9974              (match_operand:SI 2 "const_int_operand" "n"))]
9975   "TARGET_PA_20"
9977   /* The SL cache-control completer indicates good spatial locality but
9978      poor temporal locality.  The ldw instruction with a target of general
9979      register 0 prefetches a cache line for a read.  The ldd instruction
9980      prefetches a cache line for a write.  */
9981   static const char * const instr[2][2] = {
9982     {
9983       "ldw,sl 0(%0),%%r0",
9984       "ldd,sl 0(%0),%%r0"
9985     },
9986     {
9987       "ldw 0(%0),%%r0",
9988       "ldd 0(%0),%%r0"
9989     }
9990   };
9991   int read_or_write = INTVAL (operands[1]) == 0 ? 0 : 1;
9992   int locality = INTVAL (operands[2]) == 0 ? 0 : 1;
9994   return instr [locality][read_or_write];
9996   [(set_attr "type" "load")
9997    (set_attr "length" "4")])
9999 ;; TLS Support
10000 (define_insn "tgd_load"
10001  [(set (match_operand:SI 0 "register_operand" "=r")
10002        (unspec:SI [(match_operand 1 "tgd_symbolic_operand" "")] UNSPEC_TLSGD))
10003   (clobber (reg:SI 1))
10004   (use (reg:SI 27))]
10005   ""
10006   "*
10008   return \"addil LR'%1-$tls_gdidx$,%%r27\;ldo RR'%1-$tls_gdidx$(%%r1),%0\";
10010   [(set_attr "type" "multi")
10011    (set_attr "length" "8")])
10013 (define_insn "tgd_load_pic"
10014  [(set (match_operand:SI 0 "register_operand" "=r")
10015        (unspec:SI [(match_operand 1 "tgd_symbolic_operand" "")] UNSPEC_TLSGD_PIC))
10016   (clobber (reg:SI 1))
10017   (use (reg:SI 19))]
10018   ""
10019   "*
10021   return \"addil LT'%1-$tls_gdidx$,%%r19\;ldo RT'%1-$tls_gdidx$(%%r1),%0\";
10023   [(set_attr "type" "multi")
10024    (set_attr "length" "8")])
10026 (define_insn "tld_load"
10027  [(set (match_operand:SI 0 "register_operand" "=r")
10028        (unspec:SI [(match_operand 1 "tld_symbolic_operand" "")] UNSPEC_TLSLDM))
10029   (clobber (reg:SI 1))
10030   (use (reg:SI 27))]
10031   ""
10032   "*
10034   return \"addil LR'%1-$tls_ldidx$,%%r27\;ldo RR'%1-$tls_ldidx$(%%r1),%0\";
10036   [(set_attr "type" "multi")
10037    (set_attr "length" "8")])
10039 (define_insn "tld_load_pic"
10040  [(set (match_operand:SI 0 "register_operand" "=r")
10041        (unspec:SI [(match_operand 1 "tld_symbolic_operand" "")] UNSPEC_TLSLDM_PIC))
10042   (clobber (reg:SI 1))
10043   (use (reg:SI 19))]
10044   ""
10045   "*
10047   return \"addil LT'%1-$tls_ldidx$,%%r19\;ldo RT'%1-$tls_ldidx$(%%r1),%0\";
10049   [(set_attr "type" "multi")
10050    (set_attr "length" "8")])
10052 (define_insn "tld_offset_load"
10053   [(set (match_operand:SI 0 "register_operand" "=r")
10054         (plus:SI (unspec:SI [(match_operand 1 "tld_symbolic_operand" "")] 
10055                             UNSPEC_TLSLDO)
10056                  (match_operand:SI 2 "register_operand" "r")))
10057    (clobber (reg:SI 1))]
10058   ""
10059   "*
10061   return \"addil LR'%1-$tls_dtpoff$,%2\;ldo RR'%1-$tls_dtpoff$(%%r1),%0\"; 
10063   [(set_attr "type" "multi")
10064    (set_attr "length" "8")])
10066 (define_insn "tp_load"
10067   [(set (match_operand:SI 0 "register_operand" "=r")
10068         (unspec:SI [(const_int 0)] UNSPEC_TP))]
10069   ""
10070   "mfctl %%cr27,%0"
10071   [(set_attr "type" "multi")
10072    (set_attr "length" "4")])
10074 (define_insn "tie_load"
10075   [(set (match_operand:SI 0 "register_operand" "=r")
10076         (unspec:SI [(match_operand 1 "tie_symbolic_operand" "")] UNSPEC_TLSIE))
10077    (clobber (reg:SI 1))
10078    (use (reg:SI 27))]
10079   ""
10080   "*
10082   return \"addil LR'%1-$tls_ieoff$,%%r27\;ldw RR'%1-$tls_ieoff$(%%r1),%0\";
10084   [(set_attr "type" "multi")
10085    (set_attr "length" "8")])
10087 (define_insn "tie_load_pic"
10088   [(set (match_operand:SI 0 "register_operand" "=r")
10089         (unspec:SI [(match_operand 1 "tie_symbolic_operand" "")] UNSPEC_TLSIE_PIC))
10090    (clobber (reg:SI 1))
10091    (use (reg:SI 19))]
10092   ""
10093   "*
10095   return \"addil LT'%1-$tls_ieoff$,%%r19\;ldw RT'%1-$tls_ieoff$(%%r1),%0\";
10097   [(set_attr "type" "multi")
10098    (set_attr "length" "8")])
10100 (define_insn "tle_load"
10101   [(set (match_operand:SI 0 "register_operand" "=r")
10102         (plus:SI (unspec:SI [(match_operand 1 "tle_symbolic_operand" "")] 
10103                             UNSPEC_TLSLE)
10104                  (match_operand:SI 2 "register_operand" "r")))
10105    (clobber (reg:SI 1))]
10106   ""
10107   "addil LR'%1-$tls_leoff$,%2\;ldo RR'%1-$tls_leoff$(%%r1),%0"
10108   [(set_attr "type" "multi")
10109    (set_attr "length" "8")])
10111 ;; Atomic instructions
10113 ;; All memory loads and stores access storage atomically except
10114 ;; for one exception.  The STORE BYTES, STORE DOUBLE BYTES, and
10115 ;; doubleword loads and stores are not guaranteed to be atomic
10116 ;; when referencing the I/O address space.
10118 ;; These patterns are at the bottom so the non atomic versions are preferred.
10120 (define_expand "atomic_storeqi"
10121   [(match_operand:QI 0 "memory_operand")                ;; memory
10122    (match_operand:QI 1 "register_operand")              ;; val out
10123    (match_operand:SI 2 "const_int_operand")]            ;; model
10124   ""
10126   if (TARGET_SYNC_LIBCALL)
10127     {
10128       rtx mem = operands[0];
10129       rtx val = operands[1];
10130       if (pa_maybe_emit_compare_and_swap_exchange_loop (NULL_RTX, mem, val))
10131         DONE;
10132     }
10133   FAIL;
10136 ;; Implement atomic HImode stores using exchange.
10138 (define_expand "atomic_storehi"
10139   [(match_operand:HI 0 "memory_operand")                ;; memory
10140    (match_operand:HI 1 "register_operand")              ;; val out
10141    (match_operand:SI 2 "const_int_operand")]            ;; model
10142   ""
10144   if (TARGET_SYNC_LIBCALL)
10145     {
10146       rtx mem = operands[0];
10147       rtx val = operands[1];
10148       if (pa_maybe_emit_compare_and_swap_exchange_loop (NULL_RTX, mem, val))
10149         DONE;
10150     }
10151   FAIL;
10154 ;; Implement atomic SImode store using exchange.
10156 (define_expand "atomic_storesi"
10157   [(match_operand:SI 0 "memory_operand")                ;; memory
10158    (match_operand:SI 1 "register_operand")              ;; val out
10159    (match_operand:SI 2 "const_int_operand")]            ;; model
10160   ""
10162   if (TARGET_SYNC_LIBCALL)
10163     {
10164       rtx mem = operands[0];
10165       rtx val = operands[1];
10166       if (pa_maybe_emit_compare_and_swap_exchange_loop (NULL_RTX, mem, val))
10167         DONE;
10168     }
10169   FAIL;
10172 ;; Implement atomic DImode load.
10174 (define_expand "atomic_loaddi"
10175   [(match_operand:DI 0 "register_operand")              ;; val out
10176    (match_operand:DI 1 "memory_operand")                ;; memory
10177    (match_operand:SI 2 "const_int_operand")]            ;; model
10178   ""
10180   enum memmodel model;
10182   if (TARGET_64BIT || TARGET_DISABLE_FPREGS || TARGET_SOFT_FLOAT)
10183     FAIL;
10185   model = memmodel_from_int (INTVAL (operands[2]));
10186   operands[1] = force_reg (SImode, XEXP (operands[1], 0));
10187   if (is_mm_seq_cst (model))
10188     expand_mem_thread_fence (model);
10189   emit_insn (gen_atomic_loaddi_1 (operands[0], operands[1]));
10190   expand_mem_thread_fence (model);
10191   DONE;
10194 (define_insn "atomic_loaddi_1"
10195   [(set (match_operand:DI 0 "register_operand" "=r")
10196         (mem:DI (match_operand:SI 1 "register_operand" "r")))
10197    (clobber (match_scratch:DI 2 "=f"))]
10198   "!TARGET_64BIT && !TARGET_DISABLE_FPREGS && !TARGET_SOFT_FLOAT"
10199   "{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"
10200   [(set_attr "type" "move")
10201    (set_attr "length" "16")])
10203 ;; Implement atomic DImode store.
10205 (define_expand "atomic_storedi"
10206   [(match_operand:DI 0 "memory_operand")                ;; memory
10207    (match_operand:DI 1 "reg_or_cint_move_operand")      ;; val out
10208    (match_operand:SI 2 "const_int_operand")]            ;; model
10209   ""
10211   enum memmodel model;
10213   if (TARGET_SYNC_LIBCALL)
10214     {
10215       rtx mem = operands[0];
10216       rtx val = operands[1];
10217       if (pa_maybe_emit_compare_and_swap_exchange_loop (NULL_RTX, mem, val))
10218         DONE;
10219     }
10221   if (TARGET_64BIT || TARGET_DISABLE_FPREGS || TARGET_SOFT_FLOAT)
10222     FAIL;
10224   model = memmodel_from_int (INTVAL (operands[2]));
10225   operands[0] = force_reg (SImode, XEXP (operands[0], 0));
10226   if (operands[1] != CONST0_RTX (DImode))
10227     operands[1] = force_reg (DImode, operands[1]);
10228   expand_mem_thread_fence (model);
10229   emit_insn (gen_atomic_storedi_1 (operands[0], operands[1]));
10230   if (is_mm_seq_cst (model))
10231     expand_mem_thread_fence (model);
10232   DONE;
10235 (define_insn "atomic_storedi_1"
10236   [(set (mem:DI (match_operand:SI 0 "register_operand" "r,r"))
10237         (match_operand:DI 1 "reg_or_0_operand" "M,r"))
10238    (clobber (match_scratch:DI 2 "=X,f"))]
10239   "!TARGET_64BIT && !TARGET_DISABLE_FPREGS && !TARGET_SOFT_FLOAT"
10240   "@
10241    {fstds|fstd} %%fr0,0(%0)
10242    {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)"
10243   [(set_attr "type" "move,move")
10244    (set_attr "length" "4,16")])
10246 ;; PA 2.0 hardware supports out-of-order execution of loads and stores, so
10247 ;; we need memory barriers to enforce program order for memory references
10248 ;; when the TLB and PSW O bits are not set.  We assume all PA 2.0 systems
10249 ;; are weakly ordered since neither HP-UX or Linux set the PSW O bit.  Since
10250 ;; we want PA 1.x code to be PA 2.0 compatible, we also need barriers when
10251 ;; generating PA 1.x code even though all PA 1.x systems are strongly ordered.
10253 ;; When barriers are needed, we use a strongly ordered ldcw instruction as
10254 ;; the barrier.  Most PA 2.0 targets are cache coherent.  In that case, we
10255 ;; can use the coherent cache control hint and avoid aligning the ldcw
10256 ;; address.  In spite of its description, it is not clear that the sync
10257 ;; instruction works as a barrier.
10259 (define_expand "memory_barrier"
10260   [(parallel
10261      [(set (match_dup 0) (unspec:BLK [(match_dup 0)] UNSPEC_MEMORY_BARRIER))
10262       (clobber (match_dup 1))])]
10263   ""
10265   /* We don't need a barrier if the target uses ordered memory references.  */
10266   if (TARGET_ORDERED)
10267     FAIL;
10268   operands[1] = gen_reg_rtx (Pmode);
10269   operands[0] = gen_rtx_MEM (BLKmode, operands[1]);
10270   MEM_VOLATILE_P (operands[0]) = 1;
10273 (define_insn "*memory_barrier_coherent"
10274   [(set (match_operand:BLK 0 "" "")
10275         (unspec:BLK [(match_dup 0)] UNSPEC_MEMORY_BARRIER))
10276    (clobber (match_operand 1 "pmode_register_operand" "=r"))]
10277   "TARGET_PA_20 && TARGET_COHERENT_LDCW"
10278   "ldcw,co 0(%%sp),%1"
10279   [(set_attr "type" "binary")
10280    (set_attr "length" "4")])
10282 (define_insn "*memory_barrier_64"
10283   [(set (match_operand:BLK 0 "" "")
10284         (unspec:BLK [(match_dup 0)] UNSPEC_MEMORY_BARRIER))
10285     (clobber (match_operand 1 "pmode_register_operand" "=&r"))]
10286   "TARGET_64BIT"
10287   "ldo 15(%%sp),%1\n\tdepd %%r0,63,3,%1\n\tldcw 0(%1),%1"
10288   [(set_attr "type" "binary")
10289    (set_attr "length" "12")])
10291 (define_insn "*memory_barrier_32"
10292   [(set (match_operand:BLK 0 "" "")
10293         (unspec:BLK [(match_dup 0)] UNSPEC_MEMORY_BARRIER))
10294     (clobber (match_operand 1 "pmode_register_operand" "=&r"))]
10295   ""
10296   "ldo 15(%%sp),%1\n\t{dep|depw} %%r0,31,3,%1\n\tldcw 0(%1),%1"
10297   [(set_attr "type" "binary")
10298    (set_attr "length" "12")])