Merge with trank @ 137446
[official-gcc.git] / gcc / config / pa / pa.md
blobc3d686db5c420c33caf68d78e695dad43973e802
1 ;;- Machine description for HP PA-RISC architecture for GCC compiler
2 ;;   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
3 ;;   2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
4 ;;   Contributed by the Center for Software Science at the University
5 ;;   of Utah.
7 ;; This file is part of GCC.
9 ;; GCC is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 3, or (at your option)
12 ;; any later version.
14 ;; GCC is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GCC; see the file COPYING3.  If not see
21 ;; <http://www.gnu.org/licenses/>.
23 ;; This gcc Version 2 machine description is inspired by sparc.md and
24 ;; mips.md.
26 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
28 ;; Uses of UNSPEC in this file:
30 (define_constants
31   [(UNSPEC_CFFC         0)      ; canonicalize_funcptr_for_compare
32    (UNSPEC_GOTO         1)      ; indirect_goto
33    (UNSPEC_DLTIND14R    2)      ; 
34    (UNSPEC_TP           3)
35    (UNSPEC_TLSGD        4)
36    (UNSPEC_TLSLDM       5)
37    (UNSPEC_TLSLDO       6)
38    (UNSPEC_TLSLDBASE    7)
39    (UNSPEC_TLSIE        8)
40    (UNSPEC_TLSLE        9)
41    (UNSPEC_TLSGD_PIC   10)
42    (UNSPEC_TLSLDM_PIC  11)
43    (UNSPEC_TLSIE_PIC   12)
44   ])
46 ;; UNSPEC_VOLATILE:
48 (define_constants
49   [(UNSPECV_BLOCKAGE    0)      ; blockage
50    (UNSPECV_DCACHE      1)      ; dcacheflush
51    (UNSPECV_ICACHE      2)      ; icacheflush
52    (UNSPECV_OPC         3)      ; outline_prologue_call
53    (UNSPECV_OEC         4)      ; outline_epilogue_call
54    (UNSPECV_LONGJMP     5)      ; builtin_longjmp
55   ])
57 ;; Maximum pc-relative branch offsets.
59 ;; These numbers are a bit smaller than the maximum allowable offsets
60 ;; so that a few instructions may be inserted before the actual branch.
62 (define_constants
63   [(MAX_12BIT_OFFSET     8184)  ; 12-bit branch
64    (MAX_17BIT_OFFSET   262100)  ; 17-bit branch
65   ])
67 ;; Mode and code iterators
69 ;; This mode iterator allows :P to be used for patterns that operate on
70 ;; pointer-sized quantities.  Exactly one of the two alternatives will match.
71 (define_mode_iterator P [(SI "Pmode == SImode") (DI "Pmode == DImode")])
73 ;; This attribute defines the condition prefix for word and double word
74 ;; add, compare, subtract and logical instructions.
75 (define_mode_attr dwc [(SI "") (DI "*")])
77 ;; Insn type.  Used to default other attribute values.
79 ;; type "unary" insns have one input operand (1) and one output operand (0)
80 ;; type "binary" insns have two input operands (1,2) and one output (0)
82 (define_attr "type"
83   "move,unary,binary,shift,nullshift,compare,load,store,uncond_branch,btable_branch,branch,cbranch,fbranch,call,dyncall,fpload,fpstore,fpalu,fpcc,fpmulsgl,fpmuldbl,fpdivsgl,fpdivdbl,fpsqrtsgl,fpsqrtdbl,multi,milli,parallel_branch,fpstore_load,store_fpload"
84   (const_string "binary"))
86 (define_attr "pa_combine_type"
87   "fmpy,faddsub,uncond_branch,addmove,none"
88   (const_string "none"))
90 ;; Processor type (for scheduling, not code generation) -- this attribute
91 ;; must exactly match the processor_type enumeration in pa.h.
93 ;; FIXME: Add 800 scheduling for completeness?
95 (define_attr "cpu" "700,7100,7100LC,7200,7300,8000" (const (symbol_ref "pa_cpu_attr")))
97 ;; Length (in # of bytes).
98 (define_attr "length" ""
99   (cond [(eq_attr "type" "load,fpload")
100          (if_then_else (match_operand 1 "symbolic_memory_operand" "")
101                        (const_int 8) (const_int 4))
103          (eq_attr "type" "store,fpstore")
104          (if_then_else (match_operand 0 "symbolic_memory_operand" "")
105                        (const_int 8) (const_int 4))
107          (eq_attr "type" "binary,shift,nullshift")
108          (if_then_else (match_operand 2 "arith_operand" "")
109                        (const_int 4) (const_int 12))
111          (eq_attr "type" "move,unary,shift,nullshift")
112          (if_then_else (match_operand 1 "arith_operand" "")
113                        (const_int 4) (const_int 8))]
115         (const_int 4)))
117 (define_asm_attributes
118   [(set_attr "length" "4")
119    (set_attr "type" "multi")])
121 ;; Attributes for instruction and branch scheduling
123 ;; For conditional branches.
124 (define_attr "in_branch_delay" "false,true"
125   (if_then_else (and (eq_attr "type" "!uncond_branch,btable_branch,branch,cbranch,fbranch,call,dyncall,multi,milli,parallel_branch")
126                      (eq_attr "length" "4"))
127                 (const_string "true")
128                 (const_string "false")))
130 ;; Disallow instructions which use the FPU since they will tie up the FPU
131 ;; even if the instruction is nullified.
132 (define_attr "in_nullified_branch_delay" "false,true"
133   (if_then_else (and (eq_attr "type" "!uncond_branch,btable_branch,branch,cbranch,fbranch,call,dyncall,multi,milli,fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpdivdbl,fpsqrtsgl,fpsqrtdbl,parallel_branch")
134                      (eq_attr "length" "4"))
135                 (const_string "true")
136                 (const_string "false")))
138 ;; For calls and millicode calls.  Allow unconditional branches in the
139 ;; delay slot.
140 (define_attr "in_call_delay" "false,true"
141   (cond [(and (eq_attr "type" "!uncond_branch,btable_branch,branch,cbranch,fbranch,call,dyncall,multi,milli,parallel_branch")
142               (eq_attr "length" "4"))
143            (const_string "true")
144          (eq_attr "type" "uncond_branch")
145            (if_then_else (ne (symbol_ref "TARGET_JUMP_IN_DELAY")
146                              (const_int 0))
147                          (const_string "true")
148                          (const_string "false"))]
149         (const_string "false")))
152 ;; Call delay slot description.
153 (define_delay (eq_attr "type" "call")
154   [(eq_attr "in_call_delay" "true") (nil) (nil)])
156 ;; Millicode call delay slot description.
157 (define_delay (eq_attr "type" "milli")
158   [(eq_attr "in_call_delay" "true") (nil) (nil)])
160 ;; Return and other similar instructions.
161 (define_delay (eq_attr "type" "btable_branch,branch,parallel_branch")
162   [(eq_attr "in_branch_delay" "true") (nil) (nil)])
164 ;; Floating point conditional branch delay slot description.
165 (define_delay (eq_attr "type" "fbranch")
166   [(eq_attr "in_branch_delay" "true")
167    (eq_attr "in_nullified_branch_delay" "true")
168    (nil)])
170 ;; Integer conditional branch delay slot description.
171 ;; Nullification of conditional branches on the PA is dependent on the
172 ;; direction of the branch.  Forward branches nullify true and
173 ;; backward branches nullify false.  If the direction is unknown
174 ;; then nullification is not allowed.
175 (define_delay (eq_attr "type" "cbranch")
176   [(eq_attr "in_branch_delay" "true")
177    (and (eq_attr "in_nullified_branch_delay" "true")
178         (attr_flag "forward"))
179    (and (eq_attr "in_nullified_branch_delay" "true")
180         (attr_flag "backward"))])
182 (define_delay (and (eq_attr "type" "uncond_branch")
183                    (eq (symbol_ref "following_call (insn)")
184                        (const_int 0)))
185   [(eq_attr "in_branch_delay" "true") (nil) (nil)])
187 ;; Memory. Disregarding Cache misses, the Mustang memory times are:
188 ;; load: 2, fpload: 3
189 ;; store, fpstore: 3, no D-cache operations should be scheduled.
191 ;; The Timex (aka 700) has two floating-point units: ALU, and MUL/DIV/SQRT.
192 ;; Timings:
193 ;; Instruction  Time    Unit    Minimum Distance (unit contention)
194 ;; fcpy         3       ALU     2
195 ;; fabs         3       ALU     2
196 ;; fadd         3       ALU     2
197 ;; fsub         3       ALU     2
198 ;; fcmp         3       ALU     2
199 ;; fcnv         3       ALU     2
200 ;; fmpyadd      3       ALU,MPY 2
201 ;; fmpysub      3       ALU,MPY 2
202 ;; fmpycfxt     3       ALU,MPY 2
203 ;; fmpy         3       MPY     2
204 ;; fmpyi        3       MPY     2
205 ;; fdiv,sgl     10      MPY     10
206 ;; fdiv,dbl     12      MPY     12
207 ;; fsqrt,sgl    14      MPY     14
208 ;; fsqrt,dbl    18      MPY     18
210 ;; We don't model fmpyadd/fmpysub properly as those instructions
211 ;; keep both the FP ALU and MPY units busy.  Given that these
212 ;; processors are obsolete, I'm not going to spend the time to
213 ;; model those instructions correctly.
215 (define_automaton "pa700")
216 (define_cpu_unit "dummy_700,mem_700,fpalu_700,fpmpy_700" "pa700")
218 (define_insn_reservation "W0" 4
219   (and (eq_attr "type" "fpcc")
220        (eq_attr "cpu" "700"))
221   "fpalu_700*2")
223 (define_insn_reservation "W1" 3
224   (and (eq_attr "type" "fpalu")
225        (eq_attr "cpu" "700"))
226   "fpalu_700*2")
228 (define_insn_reservation "W2" 3
229   (and (eq_attr "type" "fpmulsgl,fpmuldbl")
230        (eq_attr "cpu" "700"))
231   "fpmpy_700*2")
233 (define_insn_reservation "W3" 10
234   (and (eq_attr "type" "fpdivsgl")
235        (eq_attr "cpu" "700"))
236   "fpmpy_700*10")
238 (define_insn_reservation "W4" 12
239   (and (eq_attr "type" "fpdivdbl")
240        (eq_attr "cpu" "700"))
241   "fpmpy_700*12")
243 (define_insn_reservation "W5" 14
244   (and (eq_attr "type" "fpsqrtsgl")
245        (eq_attr "cpu" "700"))
246   "fpmpy_700*14")
248 (define_insn_reservation "W6" 18
249   (and (eq_attr "type" "fpsqrtdbl")
250        (eq_attr "cpu" "700"))
251   "fpmpy_700*18")
253 (define_insn_reservation "W7" 2
254   (and (eq_attr "type" "load")
255        (eq_attr "cpu" "700"))
256   "mem_700")
258 (define_insn_reservation "W8" 2
259   (and (eq_attr "type" "fpload")
260        (eq_attr "cpu" "700"))
261   "mem_700")
263 (define_insn_reservation "W9" 3
264   (and (eq_attr "type" "store")
265        (eq_attr "cpu" "700"))
266   "mem_700*3")
268 (define_insn_reservation "W10" 3
269   (and (eq_attr "type" "fpstore")
270        (eq_attr "cpu" "700"))
271   "mem_700*3")
273 (define_insn_reservation "W11" 5
274   (and (eq_attr "type" "fpstore_load")
275        (eq_attr "cpu" "700"))
276   "mem_700*5")
278 (define_insn_reservation "W12" 6
279   (and (eq_attr "type" "store_fpload")
280        (eq_attr "cpu" "700"))
281   "mem_700*6")
283 (define_insn_reservation "W13" 1
284   (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpdivdbl,fpsqrtsgl,fpsqrtdbl,load,fpload,store,fpstore,fpstore_load,store_fpload")
285        (eq_attr "cpu" "700"))
286   "dummy_700")
288 ;; We have a bypass for all computations in the FP unit which feed an
289 ;; FP store as long as the sizes are the same.
290 (define_bypass 2 "W1,W2" "W10,W11" "hppa_fpstore_bypass_p")
291 (define_bypass 9 "W3" "W10,W11" "hppa_fpstore_bypass_p")
292 (define_bypass 11 "W4" "W10,W11" "hppa_fpstore_bypass_p")
293 (define_bypass 13 "W5" "W10,W11" "hppa_fpstore_bypass_p")
294 (define_bypass 17 "W6" "W10,W11" "hppa_fpstore_bypass_p")
296 ;; We have an "anti-bypass" for FP loads which feed an FP store.
297 (define_bypass 4 "W8,W12" "W10,W11" "hppa_fpstore_bypass_p")
299 ;; Function units for the 7100 and 7150.  The 7100/7150 can dual-issue
300 ;; floating point computations with non-floating point computations (fp loads
301 ;; and stores are not fp computations).
303 ;; Memory. Disregarding Cache misses, memory loads take two cycles; stores also
304 ;; take two cycles, during which no Dcache operations should be scheduled.
305 ;; Any special cases are handled in pa_adjust_cost.  The 7100, 7150 and 7100LC
306 ;; all have the same memory characteristics if one disregards cache misses.
308 ;; The 7100/7150 has three floating-point units: ALU, MUL, and DIV.
309 ;; There's no value in modeling the ALU and MUL separately though
310 ;; since there can never be a functional unit conflict given the
311 ;; latency and issue rates for those units.
313 ;; Timings:
314 ;; Instruction  Time    Unit    Minimum Distance (unit contention)
315 ;; fcpy         2       ALU     1
316 ;; fabs         2       ALU     1
317 ;; fadd         2       ALU     1
318 ;; fsub         2       ALU     1
319 ;; fcmp         2       ALU     1
320 ;; fcnv         2       ALU     1
321 ;; fmpyadd      2       ALU,MPY 1
322 ;; fmpysub      2       ALU,MPY 1
323 ;; fmpycfxt     2       ALU,MPY 1
324 ;; fmpy         2       MPY     1
325 ;; fmpyi        2       MPY     1
326 ;; fdiv,sgl     8       DIV     8
327 ;; fdiv,dbl     15      DIV     15
328 ;; fsqrt,sgl    8       DIV     8
329 ;; fsqrt,dbl    15      DIV     15
331 (define_automaton "pa7100")
332 (define_cpu_unit "i_7100, f_7100,fpmac_7100,fpdivsqrt_7100,mem_7100" "pa7100")
334 (define_insn_reservation "X0" 2
335   (and (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
336        (eq_attr "cpu" "7100"))
337   "f_7100,fpmac_7100")
339 (define_insn_reservation "X1" 8
340   (and (eq_attr "type" "fpdivsgl,fpsqrtsgl")
341        (eq_attr "cpu" "7100"))
342   "f_7100+fpdivsqrt_7100,fpdivsqrt_7100*7")
344 (define_insn_reservation "X2" 15
345   (and (eq_attr "type" "fpdivdbl,fpsqrtdbl")
346        (eq_attr "cpu" "7100"))
347   "f_7100+fpdivsqrt_7100,fpdivsqrt_7100*14")
349 (define_insn_reservation "X3" 2
350   (and (eq_attr "type" "load")
351        (eq_attr "cpu" "7100"))
352   "i_7100+mem_7100")
354 (define_insn_reservation "X4" 2
355   (and (eq_attr "type" "fpload")
356        (eq_attr "cpu" "7100"))
357   "i_7100+mem_7100")
359 (define_insn_reservation "X5" 2
360   (and (eq_attr "type" "store")
361        (eq_attr "cpu" "7100"))
362   "i_7100+mem_7100,mem_7100")
364 (define_insn_reservation "X6" 2
365   (and (eq_attr "type" "fpstore")
366        (eq_attr "cpu" "7100"))
367   "i_7100+mem_7100,mem_7100")
369 (define_insn_reservation "X7" 4
370   (and (eq_attr "type" "fpstore_load")
371        (eq_attr "cpu" "7100"))
372   "i_7100+mem_7100,mem_7100*3")
374 (define_insn_reservation "X8" 4
375   (and (eq_attr "type" "store_fpload")
376        (eq_attr "cpu" "7100"))
377   "i_7100+mem_7100,mem_7100*3")
379 (define_insn_reservation "X9" 1
380   (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl,load,fpload,store,fpstore,fpstore_load,store_fpload")
381        (eq_attr "cpu" "7100"))
382   "i_7100")
384 ;; We have a bypass for all computations in the FP unit which feed an
385 ;; FP store as long as the sizes are the same.
386 (define_bypass 1 "X0" "X6,X7" "hppa_fpstore_bypass_p")
387 (define_bypass 7 "X1" "X6,X7" "hppa_fpstore_bypass_p")
388 (define_bypass 14 "X2" "X6,X7" "hppa_fpstore_bypass_p")
390 ;; We have an "anti-bypass" for FP loads which feed an FP store.
391 (define_bypass 3 "X4,X8" "X6,X7" "hppa_fpstore_bypass_p")
393 ;; The 7100LC has three floating-point units: ALU, MUL, and DIV.
394 ;; There's no value in modeling the ALU and MUL separately though
395 ;; since there can never be a functional unit conflict that
396 ;; can be avoided given the latency, issue rates and mandatory
397 ;; one cycle cpu-wide lock for a double precision fp multiply.
399 ;; Timings:
400 ;; Instruction  Time    Unit    Minimum Distance (unit contention)
401 ;; fcpy         2       ALU     1
402 ;; fabs         2       ALU     1
403 ;; fadd         2       ALU     1
404 ;; fsub         2       ALU     1
405 ;; fcmp         2       ALU     1
406 ;; fcnv         2       ALU     1
407 ;; fmpyadd,sgl  2       ALU,MPY 1
408 ;; fmpyadd,dbl  3       ALU,MPY 2
409 ;; fmpysub,sgl  2       ALU,MPY 1
410 ;; fmpysub,dbl  3       ALU,MPY 2
411 ;; fmpycfxt,sgl 2       ALU,MPY 1
412 ;; fmpycfxt,dbl 3       ALU,MPY 2
413 ;; fmpy,sgl     2       MPY     1
414 ;; fmpy,dbl     3       MPY     2
415 ;; fmpyi        3       MPY     2
416 ;; fdiv,sgl     8       DIV     8
417 ;; fdiv,dbl     15      DIV     15
418 ;; fsqrt,sgl    8       DIV     8
419 ;; fsqrt,dbl    15      DIV     15
421 ;; The PA7200 is just like the PA7100LC except that there is
422 ;; no store-store penalty.
424 ;; The PA7300 is just like the PA7200 except that there is
425 ;; no store-load penalty.
427 ;; Note there are some aspects of the 7100LC we are not modeling
428 ;; at the moment.  I'll be reviewing the 7100LC scheduling info
429 ;; shortly and updating this description.
431 ;;   load-load pairs
432 ;;   store-store pairs
433 ;;   other issue modeling
435 (define_automaton "pa7100lc")
436 (define_cpu_unit "i0_7100lc, i1_7100lc, f_7100lc" "pa7100lc")
437 (define_cpu_unit "fpmac_7100lc" "pa7100lc")
438 (define_cpu_unit "mem_7100lc" "pa7100lc")
440 ;; Double precision multiplies lock the entire CPU for one
441 ;; cycle.  There is no way to avoid this lock and trying to
442 ;; schedule around the lock is pointless and thus there is no
443 ;; value in trying to model this lock.
445 ;; Not modeling the lock allows us to treat fp multiplies just
446 ;; like any other FP alu instruction.  It allows for a smaller
447 ;; DFA and may reduce register pressure.
448 (define_insn_reservation "Y0" 2
449   (and (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
450        (eq_attr "cpu" "7100LC,7200,7300"))
451   "f_7100lc,fpmac_7100lc")
453 ;; fp division and sqrt instructions lock the entire CPU for
454 ;; 7 cycles (single precision) or 14 cycles (double precision).
455 ;; There is no way to avoid this lock and trying to schedule
456 ;; around the lock is pointless and thus there is no value in
457 ;; trying to model this lock.  Not modeling the lock allows
458 ;; for a smaller DFA and may reduce register pressure.
459 (define_insn_reservation "Y1" 1
460   (and (eq_attr "type" "fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl")
461        (eq_attr "cpu" "7100LC,7200,7300"))
462   "f_7100lc")
464 (define_insn_reservation "Y2" 2
465   (and (eq_attr "type" "load")
466        (eq_attr "cpu" "7100LC,7200,7300"))
467   "i1_7100lc+mem_7100lc")
469 (define_insn_reservation "Y3" 2
470   (and (eq_attr "type" "fpload")
471        (eq_attr "cpu" "7100LC,7200,7300"))
472   "i1_7100lc+mem_7100lc")
474 (define_insn_reservation "Y4" 2
475   (and (eq_attr "type" "store")
476        (eq_attr "cpu" "7100LC"))
477   "i1_7100lc+mem_7100lc,mem_7100lc")
479 (define_insn_reservation "Y5" 2
480   (and (eq_attr "type" "fpstore")
481        (eq_attr "cpu" "7100LC"))
482   "i1_7100lc+mem_7100lc,mem_7100lc")
484 (define_insn_reservation "Y6" 4
485   (and (eq_attr "type" "fpstore_load")
486        (eq_attr "cpu" "7100LC"))
487   "i1_7100lc+mem_7100lc,mem_7100lc*3")
489 (define_insn_reservation "Y7" 4
490   (and (eq_attr "type" "store_fpload")
491        (eq_attr "cpu" "7100LC"))
492   "i1_7100lc+mem_7100lc,mem_7100lc*3")
494 (define_insn_reservation "Y8" 1
495   (and (eq_attr "type" "shift,nullshift")
496        (eq_attr "cpu" "7100LC,7200,7300"))
497   "i1_7100lc")
499 (define_insn_reservation "Y9" 1
500   (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl,load,fpload,store,fpstore,shift,nullshift")
501        (eq_attr "cpu" "7100LC,7200,7300"))
502   "(i0_7100lc|i1_7100lc)")
504 ;; The 7200 has a store-load penalty
505 (define_insn_reservation "Y10" 2
506   (and (eq_attr "type" "store")
507        (eq_attr "cpu" "7200"))
508   "i1_7100lc,mem_7100lc")
510 (define_insn_reservation "Y11" 2
511   (and (eq_attr "type" "fpstore")
512        (eq_attr "cpu" "7200"))
513   "i1_7100lc,mem_7100lc")
515 (define_insn_reservation "Y12" 4
516   (and (eq_attr "type" "fpstore_load")
517        (eq_attr "cpu" "7200"))
518   "i1_7100lc,mem_7100lc,i1_7100lc+mem_7100lc")
520 (define_insn_reservation "Y13" 4
521   (and (eq_attr "type" "store_fpload")
522        (eq_attr "cpu" "7200"))
523   "i1_7100lc,mem_7100lc,i1_7100lc+mem_7100lc")
525 ;; The 7300 has no penalty for store-store or store-load
526 (define_insn_reservation "Y14" 2
527   (and (eq_attr "type" "store")
528        (eq_attr "cpu" "7300"))
529   "i1_7100lc")
531 (define_insn_reservation "Y15" 2
532   (and (eq_attr "type" "fpstore")
533        (eq_attr "cpu" "7300"))
534   "i1_7100lc")
536 (define_insn_reservation "Y16" 4
537   (and (eq_attr "type" "fpstore_load")
538        (eq_attr "cpu" "7300"))
539   "i1_7100lc,i1_7100lc+mem_7100lc")
541 (define_insn_reservation "Y17" 4
542   (and (eq_attr "type" "store_fpload")
543        (eq_attr "cpu" "7300"))
544   "i1_7100lc,i1_7100lc+mem_7100lc")
546 ;; We have an "anti-bypass" for FP loads which feed an FP store.
547 (define_bypass 3 "Y3,Y7,Y13,Y17" "Y5,Y6,Y11,Y12,Y15,Y16" "hppa_fpstore_bypass_p")
549 ;; Scheduling for the PA8000 is somewhat different than scheduling for a
550 ;; traditional architecture.
552 ;; The PA8000 has a large (56) entry reorder buffer that is split between
553 ;; memory and non-memory operations.
555 ;; The PA8000 can issue two memory and two non-memory operations per cycle to
556 ;; the function units, with the exception of branches and multi-output
557 ;; instructions.  The PA8000 can retire two non-memory operations per cycle
558 ;; and two memory operations per cycle, only one of which may be a store.
560 ;; Given the large reorder buffer, the processor can hide most latencies.
561 ;; According to HP, they've got the best results by scheduling for retirement
562 ;; bandwidth with limited latency scheduling for floating point operations.
563 ;; Latency for integer operations and memory references is ignored.
566 ;; We claim floating point operations have a 2 cycle latency and are
567 ;; fully pipelined, except for div and sqrt which are not pipelined and
568 ;; take from 17 to 31 cycles to complete.
570 ;; It's worth noting that there is no way to saturate all the functional
571 ;; units on the PA8000 as there is not enough issue bandwidth.
573 (define_automaton "pa8000")
574 (define_cpu_unit "inm0_8000, inm1_8000, im0_8000, im1_8000" "pa8000")
575 (define_cpu_unit "rnm0_8000, rnm1_8000, rm0_8000, rm1_8000" "pa8000")
576 (define_cpu_unit "store_8000" "pa8000")
577 (define_cpu_unit "f0_8000, f1_8000" "pa8000")
578 (define_cpu_unit "fdivsqrt0_8000, fdivsqrt1_8000" "pa8000")
579 (define_reservation "inm_8000" "inm0_8000 | inm1_8000")
580 (define_reservation "im_8000" "im0_8000 | im1_8000")
581 (define_reservation "rnm_8000" "rnm0_8000 | rnm1_8000")
582 (define_reservation "rm_8000" "rm0_8000 | rm1_8000")
583 (define_reservation "f_8000" "f0_8000 | f1_8000")
584 (define_reservation "fdivsqrt_8000" "fdivsqrt0_8000 | fdivsqrt1_8000")
586 ;; We can issue any two memops per cycle, but we can only retire
587 ;; one memory store per cycle.  We assume that the reorder buffer
588 ;; will hide any memory latencies per HP's recommendation.
589 (define_insn_reservation "Z0" 0
590   (and
591     (eq_attr "type" "load,fpload")
592     (eq_attr "cpu" "8000"))
593   "im_8000,rm_8000")
595 (define_insn_reservation "Z1" 0
596   (and
597     (eq_attr "type" "store,fpstore")
598     (eq_attr "cpu" "8000"))
599   "im_8000,rm_8000+store_8000")
601 (define_insn_reservation "Z2" 0
602   (and (eq_attr "type" "fpstore_load,store_fpload")
603        (eq_attr "cpu" "8000"))
604   "im_8000,rm_8000+store_8000,im_8000,rm_8000")
606 ;; We can issue and retire two non-memory operations per cycle with
607 ;; a few exceptions (branches).  This group catches those we want
608 ;; to assume have zero latency.
609 (define_insn_reservation "Z3" 0
610   (and
611     (eq_attr "type" "!load,fpload,store,fpstore,uncond_branch,btable_branch,branch,cbranch,fbranch,call,dyncall,multi,milli,parallel_branch,fpcc,fpalu,fpmulsgl,fpmuldbl,fpsqrtsgl,fpsqrtdbl,fpdivsgl,fpdivdbl,fpstore_load,store_fpload")
612     (eq_attr "cpu" "8000"))
613   "inm_8000,rnm_8000")
615 ;; Branches use both slots in the non-memory issue and
616 ;; retirement unit.
617 (define_insn_reservation "Z4" 0
618   (and
619     (eq_attr "type" "uncond_branch,btable_branch,branch,cbranch,fbranch,call,dyncall,multi,milli,parallel_branch")
620     (eq_attr "cpu" "8000"))
621   "inm0_8000+inm1_8000,rnm0_8000+rnm1_8000")
623 ;; We partial latency schedule the floating point units.
624 ;; They can issue/retire two at a time in the non-memory
625 ;; units.  We fix their latency at 2 cycles and they
626 ;; are fully pipelined.
627 (define_insn_reservation "Z5" 1
628  (and
629    (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
630    (eq_attr "cpu" "8000"))
631  "inm_8000,f_8000,rnm_8000")
633 ;; The fdivsqrt units are not pipelined and have a very long latency.  
634 ;; To keep the DFA from exploding, we do not show all the
635 ;; reservations for the divsqrt unit.
636 (define_insn_reservation "Z6" 17
637  (and
638    (eq_attr "type" "fpdivsgl,fpsqrtsgl")
639    (eq_attr "cpu" "8000"))
640  "inm_8000,fdivsqrt_8000*6,rnm_8000")
642 (define_insn_reservation "Z7" 31
643  (and
644    (eq_attr "type" "fpdivdbl,fpsqrtdbl")
645    (eq_attr "cpu" "8000"))
646  "inm_8000,fdivsqrt_8000*6,rnm_8000")
648 ;; Operand and operator predicates and constraints
650 (include "predicates.md")
651 (include "constraints.md")
653 ;; Compare instructions.
654 ;; This controls RTL generation and register allocation.
656 ;; We generate RTL for comparisons and branches by having the cmpxx
657 ;; patterns store away the operands.  Then, the scc and bcc patterns
658 ;; emit RTL for both the compare and the branch.
661 (define_expand "cmpdi"
662   [(set (reg:CC 0)
663         (compare:CC (match_operand:DI 0 "reg_or_0_operand" "")
664                     (match_operand:DI 1 "register_operand" "")))]
665   "TARGET_64BIT"
667   "
669  hppa_compare_op0 = operands[0];
670  hppa_compare_op1 = operands[1];
671  hppa_branch_type = CMP_SI;
672  DONE;
675 (define_expand "cmpsi"
676   [(set (reg:CC 0)
677         (compare:CC (match_operand:SI 0 "reg_or_0_operand" "")
678                     (match_operand:SI 1 "arith5_operand" "")))]
679   ""
680   "
682  hppa_compare_op0 = operands[0];
683  hppa_compare_op1 = operands[1];
684  hppa_branch_type = CMP_SI;
685  DONE;
688 (define_expand "cmpsf"
689   [(set (reg:CCFP 0)
690         (compare:CCFP (match_operand:SF 0 "reg_or_0_operand" "")
691                       (match_operand:SF 1 "reg_or_0_operand" "")))]
692   "! TARGET_SOFT_FLOAT"
693   "
695   hppa_compare_op0 = operands[0];
696   hppa_compare_op1 = operands[1];
697   hppa_branch_type = CMP_SF;
698   DONE;
701 (define_expand "cmpdf"
702   [(set (reg:CCFP 0)
703       (compare:CCFP (match_operand:DF 0 "reg_or_0_operand" "")
704                     (match_operand:DF 1 "reg_or_0_operand" "")))]
705   "! TARGET_SOFT_FLOAT"
706   "
708   hppa_compare_op0 = operands[0];
709   hppa_compare_op1 = operands[1];
710   hppa_branch_type = CMP_DF;
711   DONE;
714 (define_insn ""
715   [(set (reg:CCFP 0)
716         (match_operator:CCFP 2 "comparison_operator"
717                              [(match_operand:SF 0 "reg_or_0_operand" "fG")
718                               (match_operand:SF 1 "reg_or_0_operand" "fG")]))]
719   "! TARGET_SOFT_FLOAT"
720   "fcmp,sgl,%Y2 %f0,%f1"
721   [(set_attr "length" "4")
722    (set_attr "type" "fpcc")])
724 (define_insn ""
725   [(set (reg:CCFP 0)
726         (match_operator:CCFP 2 "comparison_operator"
727                              [(match_operand:DF 0 "reg_or_0_operand" "fG")
728                               (match_operand:DF 1 "reg_or_0_operand" "fG")]))]
729   "! TARGET_SOFT_FLOAT"
730   "fcmp,dbl,%Y2 %f0,%f1"
731   [(set_attr "length" "4")
732    (set_attr "type" "fpcc")])
734 ;; Provide a means to emit the movccfp0 and movccfp1 optimization
735 ;; placeholders.  This is necessary in rare situations when a
736 ;; placeholder is re-emitted (see PR 8705).
738 (define_expand "movccfp"
739   [(set (reg:CCFP 0)
740         (match_operand 0 "const_int_operand" ""))]
741   "! TARGET_SOFT_FLOAT"
742   "
744   if ((unsigned HOST_WIDE_INT) INTVAL (operands[0]) > 1)
745     FAIL;
748 ;; The following patterns are optimization placeholders.  In almost
749 ;; all cases, the user of the condition code will be simplified and the
750 ;; original condition code setting insn should be eliminated.
752 (define_insn "*movccfp0"
753   [(set (reg:CCFP 0)
754         (const_int 0))]
755   "! TARGET_SOFT_FLOAT"
756   "fcmp,dbl,= %%fr0,%%fr0"
757   [(set_attr "length" "4")
758    (set_attr "type" "fpcc")])
760 (define_insn "*movccfp1"
761   [(set (reg:CCFP 0)
762         (const_int 1))]
763   "! TARGET_SOFT_FLOAT"
764   "fcmp,dbl,!= %%fr0,%%fr0"
765   [(set_attr "length" "4")
766    (set_attr "type" "fpcc")])
768 ;; scc insns.
770 (define_expand "seq"
771   [(set (match_operand:SI 0 "register_operand" "")
772         (eq:SI (match_dup 1)
773                (match_dup 2)))]
774   "!TARGET_64BIT"
775   "
777   /* fp scc patterns rarely match, and are not a win on the PA.  */
778   if (hppa_branch_type != CMP_SI)
779     FAIL;
780   /* set up operands from compare.  */
781   operands[1] = hppa_compare_op0;
782   operands[2] = hppa_compare_op1;
783   /* fall through and generate default code */
786 (define_expand "sne"
787   [(set (match_operand:SI 0 "register_operand" "")
788         (ne:SI (match_dup 1)
789                (match_dup 2)))]
790   "!TARGET_64BIT"
791   "
793   /* fp scc patterns rarely match, and are not a win on the PA.  */
794   if (hppa_branch_type != CMP_SI)
795     FAIL;
796   operands[1] = hppa_compare_op0;
797   operands[2] = hppa_compare_op1;
800 (define_expand "slt"
801   [(set (match_operand:SI 0 "register_operand" "")
802         (lt:SI (match_dup 1)
803                (match_dup 2)))]
804   "!TARGET_64BIT"
805   "
807   /* fp scc patterns rarely match, and are not a win on the PA.  */
808   if (hppa_branch_type != CMP_SI)
809     FAIL;
810   operands[1] = hppa_compare_op0;
811   operands[2] = hppa_compare_op1;
814 (define_expand "sgt"
815   [(set (match_operand:SI 0 "register_operand" "")
816         (gt:SI (match_dup 1)
817                (match_dup 2)))]
818   "!TARGET_64BIT"
819   "
821   /* fp scc patterns rarely match, and are not a win on the PA.  */
822   if (hppa_branch_type != CMP_SI)
823     FAIL;
824   operands[1] = hppa_compare_op0;
825   operands[2] = hppa_compare_op1;
828 (define_expand "sle"
829   [(set (match_operand:SI 0 "register_operand" "")
830         (le:SI (match_dup 1)
831                (match_dup 2)))]
832   "!TARGET_64BIT"
833   "
835   /* fp scc patterns rarely match, and are not a win on the PA.  */
836   if (hppa_branch_type != CMP_SI)
837     FAIL;
838   operands[1] = hppa_compare_op0;
839   operands[2] = hppa_compare_op1;
842 (define_expand "sge"
843   [(set (match_operand:SI 0 "register_operand" "")
844         (ge:SI (match_dup 1)
845                (match_dup 2)))]
846   "!TARGET_64BIT"
847   "
849   /* fp scc patterns rarely match, and are not a win on the PA.  */
850   if (hppa_branch_type != CMP_SI)
851     FAIL;
852   operands[1] = hppa_compare_op0;
853   operands[2] = hppa_compare_op1;
856 (define_expand "sltu"
857   [(set (match_operand:SI 0 "register_operand" "")
858         (ltu:SI (match_dup 1)
859                 (match_dup 2)))]
860   "!TARGET_64BIT"
861   "
863   if (hppa_branch_type != CMP_SI)
864     FAIL;
865   operands[1] = hppa_compare_op0;
866   operands[2] = hppa_compare_op1;
869 (define_expand "sgtu"
870   [(set (match_operand:SI 0 "register_operand" "")
871         (gtu:SI (match_dup 1)
872                 (match_dup 2)))]
873   "!TARGET_64BIT"
874   "
876   if (hppa_branch_type != CMP_SI)
877     FAIL;
878   operands[1] = hppa_compare_op0;
879   operands[2] = hppa_compare_op1;
882 (define_expand "sleu"
883   [(set (match_operand:SI 0 "register_operand" "")
884         (leu:SI (match_dup 1)
885                 (match_dup 2)))]
886   "!TARGET_64BIT"
887   "
889   if (hppa_branch_type != CMP_SI)
890     FAIL;
891   operands[1] = hppa_compare_op0;
892   operands[2] = hppa_compare_op1;
895 (define_expand "sgeu"
896   [(set (match_operand:SI 0 "register_operand" "")
897         (geu:SI (match_dup 1)
898                 (match_dup 2)))]
899   "!TARGET_64BIT"
900   "
902   if (hppa_branch_type != CMP_SI)
903     FAIL;
904   operands[1] = hppa_compare_op0;
905   operands[2] = hppa_compare_op1;
908 ;; Instruction canonicalization puts immediate operands second, which
909 ;; is the reverse of what we want.
911 (define_insn "scc"
912   [(set (match_operand:SI 0 "register_operand" "=r")
913         (match_operator:SI 3 "comparison_operator"
914                            [(match_operand:SI 1 "register_operand" "r")
915                             (match_operand:SI 2 "arith11_operand" "rI")]))]
916   ""
917   "{com%I2clr|cmp%I2clr},%B3 %2,%1,%0\;ldi 1,%0"
918   [(set_attr "type" "binary")
919    (set_attr "length" "8")])
921 (define_insn ""
922   [(set (match_operand:DI 0 "register_operand" "=r")
923         (match_operator:DI 3 "comparison_operator"
924                            [(match_operand:DI 1 "register_operand" "r")
925                             (match_operand:DI 2 "arith11_operand" "rI")]))]
926   "TARGET_64BIT"
927   "cmp%I2clr,*%B3 %2,%1,%0\;ldi 1,%0"
928   [(set_attr "type" "binary")
929    (set_attr "length" "8")])
931 (define_insn "iorscc"
932   [(set (match_operand:SI 0 "register_operand" "=r")
933         (ior:SI (match_operator:SI 3 "comparison_operator"
934                                    [(match_operand:SI 1 "register_operand" "r")
935                                     (match_operand:SI 2 "arith11_operand" "rI")])
936                 (match_operator:SI 6 "comparison_operator"
937                                    [(match_operand:SI 4 "register_operand" "r")
938                                     (match_operand:SI 5 "arith11_operand" "rI")])))]
939   ""
940   "{com%I2clr|cmp%I2clr},%S3 %2,%1,%%r0\;{com%I5clr|cmp%I5clr},%B6 %5,%4,%0\;ldi 1,%0"
941   [(set_attr "type" "binary")
942    (set_attr "length" "12")])
944 (define_insn ""
945   [(set (match_operand:DI 0 "register_operand" "=r")
946         (ior:DI (match_operator:DI 3 "comparison_operator"
947                                    [(match_operand:DI 1 "register_operand" "r")
948                                     (match_operand:DI 2 "arith11_operand" "rI")])
949                 (match_operator:DI 6 "comparison_operator"
950                                    [(match_operand:DI 4 "register_operand" "r")
951                                     (match_operand:DI 5 "arith11_operand" "rI")])))]
952   "TARGET_64BIT"
953   "cmp%I2clr,*%S3 %2,%1,%%r0\;cmp%I5clr,*%B6 %5,%4,%0\;ldi 1,%0"
954   [(set_attr "type" "binary")
955    (set_attr "length" "12")])
957 ;; Combiner patterns for common operations performed with the output
958 ;; from an scc insn (negscc and incscc).
959 (define_insn "negscc"
960   [(set (match_operand:SI 0 "register_operand" "=r")
961         (neg:SI (match_operator:SI 3 "comparison_operator"
962                [(match_operand:SI 1 "register_operand" "r")
963                 (match_operand:SI 2 "arith11_operand" "rI")])))]
964   ""
965   "{com%I2clr|cmp%I2clr},%B3 %2,%1,%0\;ldi -1,%0"
966   [(set_attr "type" "binary")
967    (set_attr "length" "8")])
969 (define_insn ""
970   [(set (match_operand:DI 0 "register_operand" "=r")
971         (neg:DI (match_operator:DI 3 "comparison_operator"
972                [(match_operand:DI 1 "register_operand" "r")
973                 (match_operand:DI 2 "arith11_operand" "rI")])))]
974   "TARGET_64BIT"
975   "cmp%I2clr,*%B3 %2,%1,%0\;ldi -1,%0"
976   [(set_attr "type" "binary")
977    (set_attr "length" "8")])
979 ;; Patterns for adding/subtracting the result of a boolean expression from
980 ;; a register.  First we have special patterns that make use of the carry
981 ;; bit, and output only two instructions.  For the cases we can't in
982 ;; general do in two instructions, the incscc pattern at the end outputs
983 ;; two or three instructions.
985 (define_insn ""
986   [(set (match_operand:SI 0 "register_operand" "=r")
987         (plus:SI (leu:SI (match_operand:SI 2 "register_operand" "r")
988                          (match_operand:SI 3 "arith11_operand" "rI"))
989                  (match_operand:SI 1 "register_operand" "r")))]
990   ""
991   "sub%I3 %3,%2,%%r0\;{addc|add,c} %%r0,%1,%0"
992   [(set_attr "type" "binary")
993    (set_attr "length" "8")])
995 (define_insn ""
996   [(set (match_operand:DI 0 "register_operand" "=r")
997         (plus:DI (leu:DI (match_operand:DI 2 "register_operand" "r")
998                          (match_operand:DI 3 "arith11_operand" "rI"))
999                  (match_operand:DI 1 "register_operand" "r")))]
1000   "TARGET_64BIT"
1001   "sub%I3 %3,%2,%%r0\;add,dc %%r0,%1,%0"
1002   [(set_attr "type" "binary")
1003    (set_attr "length" "8")])
1005 ; This need only accept registers for op3, since canonicalization
1006 ; replaces geu with gtu when op3 is an integer.
1007 (define_insn ""
1008   [(set (match_operand:SI 0 "register_operand" "=r")
1009         (plus:SI (geu:SI (match_operand:SI 2 "register_operand" "r")
1010                          (match_operand:SI 3 "register_operand" "r"))
1011                  (match_operand:SI 1 "register_operand" "r")))]
1012   ""
1013   "sub %2,%3,%%r0\;{addc|add,c} %%r0,%1,%0"
1014   [(set_attr "type" "binary")
1015    (set_attr "length" "8")])
1017 (define_insn ""
1018   [(set (match_operand:DI 0 "register_operand" "=r")
1019         (plus:DI (geu:DI (match_operand:DI 2 "register_operand" "r")
1020                          (match_operand:DI 3 "register_operand" "r"))
1021                  (match_operand:DI 1 "register_operand" "r")))]
1022   "TARGET_64BIT"
1023   "sub %2,%3,%%r0\;add,dc %%r0,%1,%0"
1024   [(set_attr "type" "binary")
1025    (set_attr "length" "8")])
1027 ; Match only integers for op3 here.  This is used as canonical form of the
1028 ; geu pattern when op3 is an integer.  Don't match registers since we can't
1029 ; make better code than the general incscc pattern.
1030 (define_insn ""
1031   [(set (match_operand:SI 0 "register_operand" "=r")
1032         (plus:SI (gtu:SI (match_operand:SI 2 "register_operand" "r")
1033                          (match_operand:SI 3 "int11_operand" "I"))
1034                  (match_operand:SI 1 "register_operand" "r")))]
1035   ""
1036   "addi %k3,%2,%%r0\;{addc|add,c} %%r0,%1,%0"
1037   [(set_attr "type" "binary")
1038    (set_attr "length" "8")])
1040 (define_insn ""
1041   [(set (match_operand:DI 0 "register_operand" "=r")
1042         (plus:DI (gtu:DI (match_operand:DI 2 "register_operand" "r")
1043                          (match_operand:DI 3 "int11_operand" "I"))
1044                  (match_operand:DI 1 "register_operand" "r")))]
1045   "TARGET_64BIT"
1046   "addi %k3,%2,%%r0\;add,dc %%r0,%1,%0"
1047   [(set_attr "type" "binary")
1048    (set_attr "length" "8")])
1050 (define_insn "incscc"
1051   [(set (match_operand:SI 0 "register_operand" "=r,r")
1052         (plus:SI (match_operator:SI 4 "comparison_operator"
1053                     [(match_operand:SI 2 "register_operand" "r,r")
1054                      (match_operand:SI 3 "arith11_operand" "rI,rI")])
1055                  (match_operand:SI 1 "register_operand" "0,?r")))]
1056   ""
1057   "@
1058    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi 1,%0,%0
1059    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi,tr 1,%1,%0\;copy %1,%0"
1060   [(set_attr "type" "binary,binary")
1061    (set_attr "length" "8,12")])
1063 (define_insn ""
1064   [(set (match_operand:DI 0 "register_operand" "=r,r")
1065         (plus:DI (match_operator:DI 4 "comparison_operator"
1066                     [(match_operand:DI 2 "register_operand" "r,r")
1067                      (match_operand:DI 3 "arith11_operand" "rI,rI")])
1068                  (match_operand:DI 1 "register_operand" "0,?r")))]
1069   "TARGET_64BIT"
1070   "@
1071    cmp%I3clr,*%B4 %3,%2,%%r0\;addi 1,%0,%0
1072    cmp%I3clr,*%B4 %3,%2,%%r0\;addi,tr 1,%1,%0\;copy %1,%0"
1073   [(set_attr "type" "binary,binary")
1074    (set_attr "length" "8,12")])
1076 (define_insn ""
1077   [(set (match_operand:SI 0 "register_operand" "=r")
1078         (minus:SI (match_operand:SI 1 "register_operand" "r")
1079                   (gtu:SI (match_operand:SI 2 "register_operand" "r")
1080                           (match_operand:SI 3 "arith11_operand" "rI"))))]
1081   ""
1082   "sub%I3 %3,%2,%%r0\;{subb|sub,b} %1,%%r0,%0"
1083   [(set_attr "type" "binary")
1084    (set_attr "length" "8")])
1086 (define_insn ""
1087   [(set (match_operand:DI 0 "register_operand" "=r")
1088         (minus:DI (match_operand:DI 1 "register_operand" "r")
1089                   (gtu:DI (match_operand:DI 2 "register_operand" "r")
1090                           (match_operand:DI 3 "arith11_operand" "rI"))))]
1091   "TARGET_64BIT"
1092   "sub%I3 %3,%2,%%r0\;sub,db %1,%%r0,%0"
1093   [(set_attr "type" "binary")
1094    (set_attr "length" "8")])
1096 (define_insn ""
1097   [(set (match_operand:SI 0 "register_operand" "=r")
1098         (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
1099                             (gtu:SI (match_operand:SI 2 "register_operand" "r")
1100                                     (match_operand:SI 3 "arith11_operand" "rI")))
1101                   (match_operand:SI 4 "register_operand" "r")))]
1102   ""
1103   "sub%I3 %3,%2,%%r0\;{subb|sub,b} %1,%4,%0"
1104   [(set_attr "type" "binary")
1105    (set_attr "length" "8")])
1107 (define_insn ""
1108   [(set (match_operand:DI 0 "register_operand" "=r")
1109         (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
1110                             (gtu:DI (match_operand:DI 2 "register_operand" "r")
1111                                     (match_operand:DI 3 "arith11_operand" "rI")))
1112                   (match_operand:DI 4 "register_operand" "r")))]
1113   "TARGET_64BIT"
1114   "sub%I3 %3,%2,%%r0\;sub,db %1,%4,%0"
1115   [(set_attr "type" "binary")
1116    (set_attr "length" "8")])
1118 ; This need only accept registers for op3, since canonicalization
1119 ; replaces ltu with leu when op3 is an integer.
1120 (define_insn ""
1121   [(set (match_operand:SI 0 "register_operand" "=r")
1122         (minus:SI (match_operand:SI 1 "register_operand" "r")
1123                   (ltu:SI (match_operand:SI 2 "register_operand" "r")
1124                           (match_operand:SI 3 "register_operand" "r"))))]
1125   ""
1126   "sub %2,%3,%%r0\;{subb|sub,b} %1,%%r0,%0"
1127   [(set_attr "type" "binary")
1128    (set_attr "length" "8")])
1130 (define_insn ""
1131   [(set (match_operand:DI 0 "register_operand" "=r")
1132         (minus:DI (match_operand:DI 1 "register_operand" "r")
1133                   (ltu:DI (match_operand:DI 2 "register_operand" "r")
1134                           (match_operand:DI 3 "register_operand" "r"))))]
1135   "TARGET_64BIT"
1136   "sub %2,%3,%%r0\;sub,db %1,%%r0,%0"
1137   [(set_attr "type" "binary")
1138    (set_attr "length" "8")])
1140 (define_insn ""
1141   [(set (match_operand:SI 0 "register_operand" "=r")
1142         (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
1143                             (ltu:SI (match_operand:SI 2 "register_operand" "r")
1144                                     (match_operand:SI 3 "register_operand" "r")))
1145                   (match_operand:SI 4 "register_operand" "r")))]
1146   ""
1147   "sub %2,%3,%%r0\;{subb|sub,b} %1,%4,%0"
1148   [(set_attr "type" "binary")
1149    (set_attr "length" "8")])
1151 (define_insn ""
1152   [(set (match_operand:DI 0 "register_operand" "=r")
1153         (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
1154                             (ltu:DI (match_operand:DI 2 "register_operand" "r")
1155                                     (match_operand:DI 3 "register_operand" "r")))
1156                   (match_operand:DI 4 "register_operand" "r")))]
1157   "TARGET_64BIT"
1158   "sub %2,%3,%%r0\;sub,db %1,%4,%0"
1159   [(set_attr "type" "binary")
1160    (set_attr "length" "8")])
1162 ; Match only integers for op3 here.  This is used as canonical form of the
1163 ; ltu pattern when op3 is an integer.  Don't match registers since we can't
1164 ; make better code than the general incscc pattern.
1165 (define_insn ""
1166   [(set (match_operand:SI 0 "register_operand" "=r")
1167         (minus:SI (match_operand:SI 1 "register_operand" "r")
1168                   (leu:SI (match_operand:SI 2 "register_operand" "r")
1169                           (match_operand:SI 3 "int11_operand" "I"))))]
1170   ""
1171   "addi %k3,%2,%%r0\;{subb|sub,b} %1,%%r0,%0"
1172   [(set_attr "type" "binary")
1173    (set_attr "length" "8")])
1175 (define_insn ""
1176   [(set (match_operand:DI 0 "register_operand" "=r")
1177         (minus:DI (match_operand:DI 1 "register_operand" "r")
1178                   (leu:DI (match_operand:DI 2 "register_operand" "r")
1179                           (match_operand:DI 3 "int11_operand" "I"))))]
1180   "TARGET_64BIT"
1181   "addi %k3,%2,%%r0\;sub,db %1,%%r0,%0"
1182   [(set_attr "type" "binary")
1183    (set_attr "length" "8")])
1185 (define_insn ""
1186   [(set (match_operand:SI 0 "register_operand" "=r")
1187         (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
1188                             (leu:SI (match_operand:SI 2 "register_operand" "r")
1189                                     (match_operand:SI 3 "int11_operand" "I")))
1190                   (match_operand:SI 4 "register_operand" "r")))]
1191   ""
1192   "addi %k3,%2,%%r0\;{subb|sub,b} %1,%4,%0"
1193   [(set_attr "type" "binary")
1194    (set_attr "length" "8")])
1196 (define_insn ""
1197   [(set (match_operand:DI 0 "register_operand" "=r")
1198         (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
1199                             (leu:DI (match_operand:DI 2 "register_operand" "r")
1200                                     (match_operand:DI 3 "int11_operand" "I")))
1201                   (match_operand:DI 4 "register_operand" "r")))]
1202   "TARGET_64BIT"
1203   "addi %k3,%2,%%r0\;sub,db %1,%4,%0"
1204   [(set_attr "type" "binary")
1205    (set_attr "length" "8")])
1207 (define_insn "decscc"
1208   [(set (match_operand:SI 0 "register_operand" "=r,r")
1209         (minus:SI (match_operand:SI 1 "register_operand" "0,?r")
1210                   (match_operator:SI 4 "comparison_operator"
1211                      [(match_operand:SI 2 "register_operand" "r,r")
1212                       (match_operand:SI 3 "arith11_operand" "rI,rI")])))]
1213   ""
1214   "@
1215    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi -1,%0,%0
1216    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi,tr -1,%1,%0\;copy %1,%0"
1217   [(set_attr "type" "binary,binary")
1218    (set_attr "length" "8,12")])
1220 (define_insn ""
1221   [(set (match_operand:DI 0 "register_operand" "=r,r")
1222         (minus:DI (match_operand:DI 1 "register_operand" "0,?r")
1223                   (match_operator:DI 4 "comparison_operator"
1224                      [(match_operand:DI 2 "register_operand" "r,r")
1225                       (match_operand:DI 3 "arith11_operand" "rI,rI")])))]
1226   "TARGET_64BIT"
1227   "@
1228    cmp%I3clr,*%B4 %3,%2,%%r0\;addi -1,%0,%0
1229    cmp%I3clr,*%B4 %3,%2,%%r0\;addi,tr -1,%1,%0\;copy %1,%0"
1230   [(set_attr "type" "binary,binary")
1231    (set_attr "length" "8,12")])
1233 ; Patterns for max and min.  (There is no need for an earlyclobber in the
1234 ; last alternative since the middle alternative will match if op0 == op1.)
1236 (define_insn "sminsi3"
1237   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1238         (smin:SI (match_operand:SI 1 "register_operand" "%0,0,r")
1239                  (match_operand:SI 2 "arith11_operand" "r,I,M")))]
1240   ""
1241   "@
1242   {comclr|cmpclr},> %2,%0,%%r0\;copy %2,%0
1243   {comiclr|cmpiclr},> %2,%0,%%r0\;ldi %2,%0
1244   {comclr|cmpclr},> %1,%r2,%0\;copy %1,%0"
1245 [(set_attr "type" "multi,multi,multi")
1246  (set_attr "length" "8,8,8")])
1248 (define_insn "smindi3"
1249   [(set (match_operand:DI 0 "register_operand" "=r,r,r")
1250         (smin:DI (match_operand:DI 1 "register_operand" "%0,0,r")
1251                  (match_operand:DI 2 "arith11_operand" "r,I,M")))]
1252   "TARGET_64BIT"
1253   "@
1254   cmpclr,*> %2,%0,%%r0\;copy %2,%0
1255   cmpiclr,*> %2,%0,%%r0\;ldi %2,%0
1256   cmpclr,*> %1,%r2,%0\;copy %1,%0"
1257 [(set_attr "type" "multi,multi,multi")
1258  (set_attr "length" "8,8,8")])
1260 (define_insn "uminsi3"
1261   [(set (match_operand:SI 0 "register_operand" "=r,r")
1262         (umin:SI (match_operand:SI 1 "register_operand" "%0,0")
1263                  (match_operand:SI 2 "arith11_operand" "r,I")))]
1264   ""
1265   "@
1266   {comclr|cmpclr},>> %2,%0,%%r0\;copy %2,%0
1267   {comiclr|cmpiclr},>> %2,%0,%%r0\;ldi %2,%0"
1268 [(set_attr "type" "multi,multi")
1269  (set_attr "length" "8,8")])
1271 (define_insn "umindi3"
1272   [(set (match_operand:DI 0 "register_operand" "=r,r")
1273         (umin:DI (match_operand:DI 1 "register_operand" "%0,0")
1274                  (match_operand:DI 2 "arith11_operand" "r,I")))]
1275   "TARGET_64BIT"
1276   "@
1277   cmpclr,*>> %2,%0,%%r0\;copy %2,%0
1278   cmpiclr,*>> %2,%0,%%r0\;ldi %2,%0"
1279 [(set_attr "type" "multi,multi")
1280  (set_attr "length" "8,8")])
1282 (define_insn "smaxsi3"
1283   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1284         (smax:SI (match_operand:SI 1 "register_operand" "%0,0,r")
1285                  (match_operand:SI 2 "arith11_operand" "r,I,M")))]
1286   ""
1287   "@
1288   {comclr|cmpclr},< %2,%0,%%r0\;copy %2,%0
1289   {comiclr|cmpiclr},< %2,%0,%%r0\;ldi %2,%0
1290   {comclr|cmpclr},< %1,%r2,%0\;copy %1,%0"
1291 [(set_attr "type" "multi,multi,multi")
1292  (set_attr "length" "8,8,8")])
1294 (define_insn "smaxdi3"
1295   [(set (match_operand:DI 0 "register_operand" "=r,r,r")
1296         (smax:DI (match_operand:DI 1 "register_operand" "%0,0,r")
1297                  (match_operand:DI 2 "arith11_operand" "r,I,M")))]
1298   "TARGET_64BIT"
1299   "@
1300   cmpclr,*< %2,%0,%%r0\;copy %2,%0
1301   cmpiclr,*< %2,%0,%%r0\;ldi %2,%0
1302   cmpclr,*< %1,%r2,%0\;copy %1,%0"
1303 [(set_attr "type" "multi,multi,multi")
1304  (set_attr "length" "8,8,8")])
1306 (define_insn "umaxsi3"
1307   [(set (match_operand:SI 0 "register_operand" "=r,r")
1308         (umax:SI (match_operand:SI 1 "register_operand" "%0,0")
1309                  (match_operand:SI 2 "arith11_operand" "r,I")))]
1310   ""
1311   "@
1312   {comclr|cmpclr},<< %2,%0,%%r0\;copy %2,%0
1313   {comiclr|cmpiclr},<< %2,%0,%%r0\;ldi %2,%0"
1314 [(set_attr "type" "multi,multi")
1315  (set_attr "length" "8,8")])
1317 (define_insn "umaxdi3"
1318   [(set (match_operand:DI 0 "register_operand" "=r,r")
1319         (umax:DI (match_operand:DI 1 "register_operand" "%0,0")
1320                  (match_operand:DI 2 "arith11_operand" "r,I")))]
1321   "TARGET_64BIT"
1322   "@
1323   cmpclr,*<< %2,%0,%%r0\;copy %2,%0
1324   cmpiclr,*<< %2,%0,%%r0\;ldi %2,%0"
1325 [(set_attr "type" "multi,multi")
1326  (set_attr "length" "8,8")])
1328 (define_insn "abssi2"
1329   [(set (match_operand:SI 0 "register_operand" "=r")
1330         (abs:SI (match_operand:SI 1 "register_operand" "r")))]
1331   ""
1332   "or,>= %%r0,%1,%0\;subi 0,%0,%0"
1333   [(set_attr "type" "multi")
1334    (set_attr "length" "8")])
1336 (define_insn "absdi2"
1337   [(set (match_operand:DI 0 "register_operand" "=r")
1338         (abs:DI (match_operand:DI 1 "register_operand" "r")))]
1339   "TARGET_64BIT"
1340   "or,*>= %%r0,%1,%0\;subi 0,%0,%0"
1341   [(set_attr "type" "multi")
1342    (set_attr "length" "8")])
1344 ;;; Experimental conditional move patterns
1346 (define_expand "movsicc"
1347   [(set (match_operand:SI 0 "register_operand" "")
1348         (if_then_else:SI
1349          (match_operator 1 "comparison_operator"
1350             [(match_dup 4)
1351              (match_dup 5)])
1352          (match_operand:SI 2 "reg_or_cint_move_operand" "")
1353          (match_operand:SI 3 "reg_or_cint_move_operand" "")))]
1354   ""
1355   "
1357   enum rtx_code code = GET_CODE (operands[1]);
1359   if (hppa_branch_type != CMP_SI)
1360     FAIL;
1362   if (GET_MODE (hppa_compare_op0) != GET_MODE (hppa_compare_op1)
1363       || GET_MODE (hppa_compare_op0) != GET_MODE (operands[0]))
1364     FAIL;
1366   /* operands[1] is currently the result of compare_from_rtx.  We want to
1367      emit a compare of the original operands.  */
1368   operands[1] = gen_rtx_fmt_ee (code, SImode, hppa_compare_op0, hppa_compare_op1);
1369   operands[4] = hppa_compare_op0;
1370   operands[5] = hppa_compare_op1;
1373 ;; We used to accept any register for op1.
1375 ;; However, it loses sometimes because the compiler will end up using
1376 ;; different registers for op0 and op1 in some critical cases.  local-alloc
1377 ;; will  not tie op0 and op1 because op0 is used in multiple basic blocks.
1379 ;; If/when global register allocation supports tying we should allow any
1380 ;; register for op1 again.
1381 (define_insn ""
1382   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
1383         (if_then_else:SI
1384          (match_operator 2 "comparison_operator"
1385             [(match_operand:SI 3 "register_operand" "r,r,r,r")
1386              (match_operand:SI 4 "arith11_operand" "rI,rI,rI,rI")])
1387          (match_operand:SI 1 "reg_or_cint_move_operand" "0,J,N,K")
1388          (const_int 0)))]
1389   ""
1390   "@
1391    {com%I4clr|cmp%I4clr},%S2 %4,%3,%%r0\;ldi 0,%0
1392    {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;ldi %1,%0
1393    {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;ldil L'%1,%0
1394    {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;{zdepi|depwi,z} %Z1,%0"
1395   [(set_attr "type" "multi,multi,multi,nullshift")
1396    (set_attr "length" "8,8,8,8")])
1398 (define_insn ""
1399   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r,r,r")
1400         (if_then_else:SI
1401          (match_operator 5 "comparison_operator"
1402             [(match_operand:SI 3 "register_operand" "r,r,r,r,r,r,r,r")
1403              (match_operand:SI 4 "arith11_operand" "rI,rI,rI,rI,rI,rI,rI,rI")])
1404          (match_operand:SI 1 "reg_or_cint_move_operand" "0,0,0,0,r,J,N,K")
1405          (match_operand:SI 2 "reg_or_cint_move_operand" "r,J,N,K,0,0,0,0")))]
1406   ""
1407   "@
1408    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;copy %2,%0
1409    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;ldi %2,%0
1410    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;ldil L'%2,%0
1411    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;{zdepi|depwi,z} %Z2,%0
1412    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;copy %1,%0
1413    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;ldi %1,%0
1414    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;ldil L'%1,%0
1415    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;{zdepi|depwi,z} %Z1,%0"
1416   [(set_attr "type" "multi,multi,multi,nullshift,multi,multi,multi,nullshift")
1417    (set_attr "length" "8,8,8,8,8,8,8,8")])
1419 (define_expand "movdicc"
1420   [(set (match_operand:DI 0 "register_operand" "")
1421         (if_then_else:DI
1422          (match_operator 1 "comparison_operator"
1423             [(match_dup 4)
1424              (match_dup 5)])
1425          (match_operand:DI 2 "reg_or_cint_move_operand" "")
1426          (match_operand:DI 3 "reg_or_cint_move_operand" "")))]
1427   "TARGET_64BIT"
1428   "
1430   enum rtx_code code = GET_CODE (operands[1]);
1432   if (hppa_branch_type != CMP_SI)
1433     FAIL;
1435   if (GET_MODE (hppa_compare_op0) != GET_MODE (hppa_compare_op1)
1436       || GET_MODE (hppa_compare_op0) != GET_MODE (operands[0]))
1437     FAIL;
1439   /* operands[1] is currently the result of compare_from_rtx.  We want to
1440      emit a compare of the original operands.  */
1441   operands[1] = gen_rtx_fmt_ee (code, DImode, hppa_compare_op0, hppa_compare_op1);
1442   operands[4] = hppa_compare_op0;
1443   operands[5] = hppa_compare_op1;
1446 ; We need the first constraint alternative in order to avoid
1447 ; earlyclobbers on all other alternatives.
1448 (define_insn ""
1449   [(set (match_operand:DI 0 "register_operand" "=r,r,r,r,r")
1450         (if_then_else:DI
1451          (match_operator 2 "comparison_operator"
1452             [(match_operand:DI 3 "register_operand" "r,r,r,r,r")
1453              (match_operand:DI 4 "arith11_operand" "rI,rI,rI,rI,rI")])
1454          (match_operand:DI 1 "reg_or_cint_move_operand" "0,r,J,N,K")
1455          (const_int 0)))]
1456   "TARGET_64BIT"
1457   "@
1458    cmp%I4clr,*%S2 %4,%3,%%r0\;ldi 0,%0
1459    cmp%I4clr,*%B2 %4,%3,%0\;copy %1,%0
1460    cmp%I4clr,*%B2 %4,%3,%0\;ldi %1,%0
1461    cmp%I4clr,*%B2 %4,%3,%0\;ldil L'%1,%0
1462    cmp%I4clr,*%B2 %4,%3,%0\;depdi,z %z1,%0"
1463   [(set_attr "type" "multi,multi,multi,multi,nullshift")
1464    (set_attr "length" "8,8,8,8,8")])
1466 (define_insn ""
1467   [(set (match_operand:DI 0 "register_operand" "=r,r,r,r,r,r,r,r")
1468         (if_then_else:DI
1469          (match_operator 5 "comparison_operator"
1470             [(match_operand:DI 3 "register_operand" "r,r,r,r,r,r,r,r")
1471              (match_operand:DI 4 "arith11_operand" "rI,rI,rI,rI,rI,rI,rI,rI")])
1472          (match_operand:DI 1 "reg_or_cint_move_operand" "0,0,0,0,r,J,N,K")
1473          (match_operand:DI 2 "reg_or_cint_move_operand" "r,J,N,K,0,0,0,0")))]
1474   "TARGET_64BIT"
1475   "@
1476    cmp%I4clr,*%S5 %4,%3,%%r0\;copy %2,%0
1477    cmp%I4clr,*%S5 %4,%3,%%r0\;ldi %2,%0
1478    cmp%I4clr,*%S5 %4,%3,%%r0\;ldil L'%2,%0
1479    cmp%I4clr,*%S5 %4,%3,%%r0\;depdi,z %z2,%0
1480    cmp%I4clr,*%B5 %4,%3,%%r0\;copy %1,%0
1481    cmp%I4clr,*%B5 %4,%3,%%r0\;ldi %1,%0
1482    cmp%I4clr,*%B5 %4,%3,%%r0\;ldil L'%1,%0
1483    cmp%I4clr,*%B5 %4,%3,%%r0\;depdi,z %z1,%0"
1484   [(set_attr "type" "multi,multi,multi,nullshift,multi,multi,multi,nullshift")
1485    (set_attr "length" "8,8,8,8,8,8,8,8")])
1487 ;; Conditional Branches
1489 (define_expand "beq"
1490   [(set (pc)
1491         (if_then_else (eq (match_dup 1) (match_dup 2))
1492                       (label_ref (match_operand 0 "" ""))
1493                       (pc)))]
1494   ""
1495   "
1497   if (hppa_branch_type != CMP_SI)
1498     {
1499       emit_insn (gen_cmp_fp (EQ, hppa_compare_op0, hppa_compare_op1));
1500       emit_bcond_fp (NE, operands[0]);
1501       DONE;
1502     }
1503   /* set up operands from compare.  */
1504   operands[1] = hppa_compare_op0;
1505   operands[2] = hppa_compare_op1;
1506   /* fall through and generate default code */
1509 (define_expand "bne"
1510   [(set (pc)
1511         (if_then_else (ne (match_dup 1) (match_dup 2))
1512                       (label_ref (match_operand 0 "" ""))
1513                       (pc)))]
1514   ""
1515   "
1517   if (hppa_branch_type != CMP_SI)
1518     {
1519       emit_insn (gen_cmp_fp (NE, hppa_compare_op0, hppa_compare_op1));
1520       emit_bcond_fp (NE, operands[0]);
1521       DONE;
1522     }
1523   operands[1] = hppa_compare_op0;
1524   operands[2] = hppa_compare_op1;
1527 (define_expand "bgt"
1528   [(set (pc)
1529         (if_then_else (gt (match_dup 1) (match_dup 2))
1530                       (label_ref (match_operand 0 "" ""))
1531                       (pc)))]
1532   ""
1533   "
1535   if (hppa_branch_type != CMP_SI)
1536     {
1537       emit_insn (gen_cmp_fp (GT, hppa_compare_op0, hppa_compare_op1));
1538       emit_bcond_fp (NE, operands[0]);
1539       DONE;
1540     }
1541   operands[1] = hppa_compare_op0;
1542   operands[2] = hppa_compare_op1;
1545 (define_expand "blt"
1546   [(set (pc)
1547         (if_then_else (lt (match_dup 1) (match_dup 2))
1548                       (label_ref (match_operand 0 "" ""))
1549                       (pc)))]
1550   ""
1551   "
1553   if (hppa_branch_type != CMP_SI)
1554     {
1555       emit_insn (gen_cmp_fp (LT, hppa_compare_op0, hppa_compare_op1));
1556       emit_bcond_fp (NE, operands[0]);
1557       DONE;
1558     }
1559   operands[1] = hppa_compare_op0;
1560   operands[2] = hppa_compare_op1;
1563 (define_expand "bge"
1564   [(set (pc)
1565         (if_then_else (ge (match_dup 1) (match_dup 2))
1566                       (label_ref (match_operand 0 "" ""))
1567                       (pc)))]
1568   ""
1569   "
1571   if (hppa_branch_type != CMP_SI)
1572     {
1573       emit_insn (gen_cmp_fp (GE, hppa_compare_op0, hppa_compare_op1));
1574       emit_bcond_fp (NE, operands[0]);
1575       DONE;
1576     }
1577   operands[1] = hppa_compare_op0;
1578   operands[2] = hppa_compare_op1;
1581 (define_expand "ble"
1582   [(set (pc)
1583         (if_then_else (le (match_dup 1) (match_dup 2))
1584                       (label_ref (match_operand 0 "" ""))
1585                       (pc)))]
1586   ""
1587   "
1589   if (hppa_branch_type != CMP_SI)
1590     {
1591       emit_insn (gen_cmp_fp (LE, hppa_compare_op0, hppa_compare_op1));
1592       emit_bcond_fp (NE, operands[0]);
1593       DONE;
1594     }
1595   operands[1] = hppa_compare_op0;
1596   operands[2] = hppa_compare_op1;
1599 (define_expand "bgtu"
1600   [(set (pc)
1601         (if_then_else (gtu (match_dup 1) (match_dup 2))
1602                       (label_ref (match_operand 0 "" ""))
1603                       (pc)))]
1604   ""
1605   "
1607   if (hppa_branch_type != CMP_SI)
1608     FAIL;
1609   operands[1] = hppa_compare_op0;
1610   operands[2] = hppa_compare_op1;
1613 (define_expand "bltu"
1614   [(set (pc)
1615         (if_then_else (ltu (match_dup 1) (match_dup 2))
1616                       (label_ref (match_operand 0 "" ""))
1617                       (pc)))]
1618   ""
1619   "
1621   if (hppa_branch_type != CMP_SI)
1622     FAIL;
1623   operands[1] = hppa_compare_op0;
1624   operands[2] = hppa_compare_op1;
1627 (define_expand "bgeu"
1628   [(set (pc)
1629         (if_then_else (geu (match_dup 1) (match_dup 2))
1630                       (label_ref (match_operand 0 "" ""))
1631                       (pc)))]
1632   ""
1633   "
1635   if (hppa_branch_type != CMP_SI)
1636     FAIL;
1637   operands[1] = hppa_compare_op0;
1638   operands[2] = hppa_compare_op1;
1641 (define_expand "bleu"
1642   [(set (pc)
1643         (if_then_else (leu (match_dup 1) (match_dup 2))
1644                       (label_ref (match_operand 0 "" ""))
1645                       (pc)))]
1646   ""
1647   "
1649   if (hppa_branch_type != CMP_SI)
1650     FAIL;
1651   operands[1] = hppa_compare_op0;
1652   operands[2] = hppa_compare_op1;
1655 (define_expand "bltgt"
1656   [(set (pc)
1657         (if_then_else (ltgt (match_dup 1) (match_dup 2))
1658                       (label_ref (match_operand 0 "" ""))
1659                       (pc)))]
1660   ""
1661   "
1663   if (hppa_branch_type == CMP_SI)
1664     FAIL;
1665   emit_insn (gen_cmp_fp (LTGT, hppa_compare_op0, hppa_compare_op1));
1666   emit_bcond_fp (NE, operands[0]);
1667   DONE;
1670 (define_expand "bunle"
1671   [(set (pc)
1672         (if_then_else (unle (match_dup 1) (match_dup 2))
1673                       (label_ref (match_operand 0 "" ""))
1674                       (pc)))]
1675   ""
1676   "
1678   if (hppa_branch_type == CMP_SI)
1679     FAIL;
1680   emit_insn (gen_cmp_fp (UNLE, hppa_compare_op0, hppa_compare_op1));
1681   emit_bcond_fp (NE, operands[0]);
1682   DONE;
1685 (define_expand "bunlt"
1686   [(set (pc)
1687         (if_then_else (unlt (match_dup 1) (match_dup 2))
1688                       (label_ref (match_operand 0 "" ""))
1689                       (pc)))]
1690   ""
1691   "
1693   if (hppa_branch_type == CMP_SI)
1694     FAIL;
1695   emit_insn (gen_cmp_fp (UNLT, hppa_compare_op0, hppa_compare_op1));
1696   emit_bcond_fp (NE, operands[0]);
1697   DONE;
1700 (define_expand "bunge"
1701   [(set (pc)
1702         (if_then_else (unge (match_dup 1) (match_dup 2))
1703                       (label_ref (match_operand 0 "" ""))
1704                       (pc)))]
1705   ""
1706   "
1708   if (hppa_branch_type == CMP_SI)
1709     FAIL;
1710   emit_insn (gen_cmp_fp (UNGE, hppa_compare_op0, hppa_compare_op1));
1711   emit_bcond_fp (NE, operands[0]);
1712   DONE;
1715 (define_expand "bungt"
1716   [(set (pc)
1717         (if_then_else (ungt (match_dup 1) (match_dup 2))
1718                       (label_ref (match_operand 0 "" ""))
1719                       (pc)))]
1720   ""
1721   "
1723   if (hppa_branch_type == CMP_SI)
1724     FAIL;
1725   emit_insn (gen_cmp_fp (UNGT, hppa_compare_op0, hppa_compare_op1));
1726   emit_bcond_fp (NE, operands[0]);
1727   DONE;
1730 (define_expand "buneq"
1731   [(set (pc)
1732         (if_then_else (uneq (match_dup 1) (match_dup 2))
1733                       (label_ref (match_operand 0 "" ""))
1734                       (pc)))]
1735   ""
1736   "
1738   if (hppa_branch_type == CMP_SI)
1739     FAIL;
1740   emit_insn (gen_cmp_fp (UNEQ, hppa_compare_op0, hppa_compare_op1));
1741   emit_bcond_fp (NE, operands[0]);
1742   DONE;
1745 (define_expand "bunordered"
1746   [(set (pc)
1747         (if_then_else (unordered (match_dup 1) (match_dup 2))
1748                       (label_ref (match_operand 0 "" ""))
1749                       (pc)))]
1750   ""
1751   "
1753   if (hppa_branch_type == CMP_SI)
1754     FAIL;
1755   emit_insn (gen_cmp_fp (UNORDERED, hppa_compare_op0, hppa_compare_op1));
1756   emit_bcond_fp (NE, operands[0]);
1757   DONE;
1760 (define_expand "bordered"
1761   [(set (pc)
1762         (if_then_else (ordered (match_dup 1) (match_dup 2))
1763                       (label_ref (match_operand 0 "" ""))
1764                       (pc)))]
1765   ""
1766   "
1768   if (hppa_branch_type == CMP_SI)
1769     FAIL;
1770   emit_insn (gen_cmp_fp (ORDERED, hppa_compare_op0, hppa_compare_op1));
1771   emit_bcond_fp (NE, operands[0]);
1772   DONE;
1775 ;; Match the branch patterns.
1778 ;; Note a long backward conditional branch with an annulled delay slot
1779 ;; has a length of 12.
1780 (define_insn ""
1781   [(set (pc)
1782         (if_then_else
1783          (match_operator 3 "comparison_operator"
1784                          [(match_operand:SI 1 "reg_or_0_operand" "rM")
1785                           (match_operand:SI 2 "arith5_operand" "rL")])
1786          (label_ref (match_operand 0 "" ""))
1787          (pc)))]
1788   ""
1789   "*
1791   return output_cbranch (operands, 0, insn);
1793 [(set_attr "type" "cbranch")
1794  (set (attr "length")
1795     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1796                (const_int MAX_12BIT_OFFSET))
1797            (const_int 4)
1798            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1799                (const_int MAX_17BIT_OFFSET))
1800            (const_int 8)
1801            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
1802            (const_int 24)
1803            (eq (symbol_ref "flag_pic") (const_int 0))
1804            (const_int 20)]
1805           (const_int 28)))])
1807 ;; Match the negated branch.
1809 (define_insn ""
1810   [(set (pc)
1811         (if_then_else
1812          (match_operator 3 "comparison_operator"
1813                          [(match_operand:SI 1 "reg_or_0_operand" "rM")
1814                           (match_operand:SI 2 "arith5_operand" "rL")])
1815          (pc)
1816          (label_ref (match_operand 0 "" ""))))]
1817   ""
1818   "*
1820   return output_cbranch (operands, 1, insn);
1822 [(set_attr "type" "cbranch")
1823  (set (attr "length")
1824     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1825                (const_int MAX_12BIT_OFFSET))
1826            (const_int 4)
1827            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1828                (const_int MAX_17BIT_OFFSET))
1829            (const_int 8)
1830            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
1831            (const_int 24)
1832            (eq (symbol_ref "flag_pic") (const_int 0))
1833            (const_int 20)]
1834           (const_int 28)))])
1836 (define_insn ""
1837   [(set (pc)
1838         (if_then_else
1839          (match_operator 3 "comparison_operator"
1840                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1841                           (match_operand:DI 2 "reg_or_0_operand" "rM")])
1842          (label_ref (match_operand 0 "" ""))
1843          (pc)))]
1844   "TARGET_64BIT"
1845   "*
1847   return output_cbranch (operands, 0, insn);
1849 [(set_attr "type" "cbranch")
1850  (set (attr "length")
1851     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1852                (const_int MAX_12BIT_OFFSET))
1853            (const_int 4)
1854            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1855                (const_int MAX_17BIT_OFFSET))
1856            (const_int 8)
1857            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
1858            (const_int 24)
1859            (eq (symbol_ref "flag_pic") (const_int 0))
1860            (const_int 20)]
1861           (const_int 28)))])
1863 ;; Match the negated branch.
1865 (define_insn ""
1866   [(set (pc)
1867         (if_then_else
1868          (match_operator 3 "comparison_operator"
1869                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1870                           (match_operand:DI 2 "reg_or_0_operand" "rM")])
1871          (pc)
1872          (label_ref (match_operand 0 "" ""))))]
1873   "TARGET_64BIT"
1874   "*
1876   return output_cbranch (operands, 1, insn);
1878 [(set_attr "type" "cbranch")
1879  (set (attr "length")
1880     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1881                (const_int MAX_12BIT_OFFSET))
1882            (const_int 4)
1883            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1884                (const_int MAX_17BIT_OFFSET))
1885            (const_int 8)
1886            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
1887            (const_int 24)
1888            (eq (symbol_ref "flag_pic") (const_int 0))
1889            (const_int 20)]
1890           (const_int 28)))])
1891 (define_insn ""
1892   [(set (pc)
1893         (if_then_else
1894          (match_operator 3 "cmpib_comparison_operator"
1895                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1896                           (match_operand:DI 2 "arith5_operand" "rL")])
1897          (label_ref (match_operand 0 "" ""))
1898          (pc)))]
1899   "TARGET_64BIT"
1900   "*
1902   return output_cbranch (operands, 0, insn);
1904 [(set_attr "type" "cbranch")
1905  (set (attr "length")
1906     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1907                (const_int MAX_12BIT_OFFSET))
1908            (const_int 4)
1909            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1910                (const_int MAX_17BIT_OFFSET))
1911            (const_int 8)
1912            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
1913            (const_int 24)
1914            (eq (symbol_ref "flag_pic") (const_int 0))
1915            (const_int 20)]
1916           (const_int 28)))])
1918 ;; Match the negated branch.
1920 (define_insn ""
1921   [(set (pc)
1922         (if_then_else
1923          (match_operator 3 "cmpib_comparison_operator"
1924                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1925                           (match_operand:DI 2 "arith5_operand" "rL")])
1926          (pc)
1927          (label_ref (match_operand 0 "" ""))))]
1928   "TARGET_64BIT"
1929   "*
1931   return output_cbranch (operands, 1, insn);
1933 [(set_attr "type" "cbranch")
1934  (set (attr "length")
1935     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1936                (const_int MAX_12BIT_OFFSET))
1937            (const_int 4)
1938            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1939                (const_int MAX_17BIT_OFFSET))
1940            (const_int 8)
1941            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
1942            (const_int 24)
1943            (eq (symbol_ref "flag_pic") (const_int 0))
1944            (const_int 20)]
1945           (const_int 28)))])
1947 ;; Branch on Bit patterns.
1948 (define_insn ""
1949   [(set (pc)
1950         (if_then_else
1951          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1952                               (const_int 1)
1953                               (match_operand:SI 1 "uint5_operand" ""))
1954              (const_int 0))
1955          (label_ref (match_operand 2 "" ""))
1956          (pc)))]
1957   ""
1958   "*
1960   return output_bb (operands, 0, insn, 0);
1962 [(set_attr "type" "cbranch")
1963  (set (attr "length")
1964     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1965                (const_int MAX_12BIT_OFFSET))
1966            (const_int 4)
1967            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1968                (const_int MAX_17BIT_OFFSET))
1969            (const_int 8)
1970            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
1971            (const_int 24)
1972            (eq (symbol_ref "flag_pic") (const_int 0))
1973            (const_int 20)]
1974           (const_int 28)))])
1976 (define_insn ""
1977   [(set (pc)
1978         (if_then_else
1979          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1980                               (const_int 1)
1981                               (match_operand:DI 1 "uint32_operand" ""))
1982              (const_int 0))
1983          (label_ref (match_operand 2 "" ""))
1984          (pc)))]
1985   "TARGET_64BIT"
1986   "*
1988   return output_bb (operands, 0, insn, 0);
1990 [(set_attr "type" "cbranch")
1991  (set (attr "length")
1992     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1993                (const_int MAX_12BIT_OFFSET))
1994            (const_int 4)
1995            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1996                (const_int MAX_17BIT_OFFSET))
1997            (const_int 8)
1998            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
1999            (const_int 24)
2000            (eq (symbol_ref "flag_pic") (const_int 0))
2001            (const_int 20)]
2002           (const_int 28)))])
2004 (define_insn ""
2005   [(set (pc)
2006         (if_then_else
2007          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
2008                               (const_int 1)
2009                               (match_operand:SI 1 "uint5_operand" ""))
2010              (const_int 0))
2011          (pc)
2012          (label_ref (match_operand 2 "" ""))))]
2013   ""
2014   "*
2016   return output_bb (operands, 1, insn, 0);
2018 [(set_attr "type" "cbranch")
2019  (set (attr "length")
2020     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2021                (const_int MAX_12BIT_OFFSET))
2022            (const_int 4)
2023            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2024                (const_int MAX_17BIT_OFFSET))
2025            (const_int 8)
2026            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
2027            (const_int 24)
2028            (eq (symbol_ref "flag_pic") (const_int 0))
2029            (const_int 20)]
2030           (const_int 28)))])
2032 (define_insn ""
2033   [(set (pc)
2034         (if_then_else
2035          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2036                               (const_int 1)
2037                               (match_operand:DI 1 "uint32_operand" ""))
2038              (const_int 0))
2039          (pc)
2040          (label_ref (match_operand 2 "" ""))))]
2041   "TARGET_64BIT"
2042   "*
2044   return output_bb (operands, 1, insn, 0);
2046 [(set_attr "type" "cbranch")
2047  (set (attr "length")
2048     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2049                (const_int MAX_12BIT_OFFSET))
2050            (const_int 4)
2051            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2052                (const_int MAX_17BIT_OFFSET))
2053            (const_int 8)
2054            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
2055            (const_int 24)
2056            (eq (symbol_ref "flag_pic") (const_int 0))
2057            (const_int 20)]
2058           (const_int 28)))])
2060 (define_insn ""
2061   [(set (pc)
2062         (if_then_else
2063          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
2064                               (const_int 1)
2065                               (match_operand:SI 1 "uint5_operand" ""))
2066              (const_int 0))
2067          (label_ref (match_operand 2 "" ""))
2068          (pc)))]
2069   ""
2070   "*
2072   return output_bb (operands, 0, insn, 1);
2074 [(set_attr "type" "cbranch")
2075  (set (attr "length")
2076     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2077                (const_int MAX_12BIT_OFFSET))
2078            (const_int 4)
2079            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2080                (const_int MAX_17BIT_OFFSET))
2081            (const_int 8)
2082            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
2083            (const_int 24)
2084            (eq (symbol_ref "flag_pic") (const_int 0))
2085            (const_int 20)]
2086           (const_int 28)))])
2088 (define_insn ""
2089   [(set (pc)
2090         (if_then_else
2091          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2092                               (const_int 1)
2093                               (match_operand:DI 1 "uint32_operand" ""))
2094              (const_int 0))
2095          (label_ref (match_operand 2 "" ""))
2096          (pc)))]
2097   "TARGET_64BIT"
2098   "*
2100   return output_bb (operands, 0, insn, 1);
2102 [(set_attr "type" "cbranch")
2103  (set (attr "length")
2104     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2105                (const_int MAX_12BIT_OFFSET))
2106            (const_int 4)
2107            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2108                (const_int MAX_17BIT_OFFSET))
2109            (const_int 8)
2110            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
2111            (const_int 24)
2112            (eq (symbol_ref "flag_pic") (const_int 0))
2113            (const_int 20)]
2114           (const_int 28)))])
2116 (define_insn ""
2117   [(set (pc)
2118         (if_then_else
2119          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
2120                               (const_int 1)
2121                               (match_operand:SI 1 "uint5_operand" ""))
2122              (const_int 0))
2123          (pc)
2124          (label_ref (match_operand 2 "" ""))))]
2125   ""
2126   "*
2128   return output_bb (operands, 1, insn, 1);
2130 [(set_attr "type" "cbranch")
2131  (set (attr "length")
2132     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2133                (const_int MAX_12BIT_OFFSET))
2134            (const_int 4)
2135            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2136                (const_int MAX_17BIT_OFFSET))
2137            (const_int 8)
2138            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
2139            (const_int 24)
2140            (eq (symbol_ref "flag_pic") (const_int 0))
2141            (const_int 20)]
2142           (const_int 28)))])
2144 (define_insn ""
2145   [(set (pc)
2146         (if_then_else
2147          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2148                               (const_int 1)
2149                               (match_operand:DI 1 "uint32_operand" ""))
2150              (const_int 0))
2151          (pc)
2152          (label_ref (match_operand 2 "" ""))))]
2153   "TARGET_64BIT"
2154   "*
2156   return output_bb (operands, 1, insn, 1);
2158 [(set_attr "type" "cbranch")
2159  (set (attr "length")
2160     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2161                (const_int MAX_12BIT_OFFSET))
2162            (const_int 4)
2163            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2164                (const_int MAX_17BIT_OFFSET))
2165            (const_int 8)
2166            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
2167            (const_int 24)
2168            (eq (symbol_ref "flag_pic") (const_int 0))
2169            (const_int 20)]
2170           (const_int 28)))])
2172 ;; Branch on Variable Bit patterns.
2173 (define_insn ""
2174   [(set (pc)
2175         (if_then_else
2176          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
2177                               (const_int 1)
2178                               (match_operand:SI 1 "register_operand" "q"))
2179              (const_int 0))
2180          (label_ref (match_operand 2 "" ""))
2181          (pc)))]
2182   ""
2183   "*
2185   return output_bvb (operands, 0, insn, 0);
2187 [(set_attr "type" "cbranch")
2188  (set (attr "length")
2189     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2190                (const_int MAX_12BIT_OFFSET))
2191            (const_int 4)
2192            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2193                (const_int MAX_17BIT_OFFSET))
2194            (const_int 8)
2195            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
2196            (const_int 24)
2197            (eq (symbol_ref "flag_pic") (const_int 0))
2198            (const_int 20)]
2199           (const_int 28)))])
2201 (define_insn ""
2202   [(set (pc)
2203         (if_then_else
2204          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2205                               (const_int 1)
2206                               (match_operand:DI 1 "register_operand" "q"))
2207              (const_int 0))
2208          (label_ref (match_operand 2 "" ""))
2209          (pc)))]
2210   "TARGET_64BIT"
2211   "*
2213   return output_bvb (operands, 0, insn, 0);
2215 [(set_attr "type" "cbranch")
2216  (set (attr "length")
2217     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2218                (const_int MAX_12BIT_OFFSET))
2219            (const_int 4)
2220            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2221                (const_int MAX_17BIT_OFFSET))
2222            (const_int 8)
2223            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
2224            (const_int 24)
2225            (eq (symbol_ref "flag_pic") (const_int 0))
2226            (const_int 20)]
2227           (const_int 28)))])
2229 (define_insn ""
2230   [(set (pc)
2231         (if_then_else
2232          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
2233                               (const_int 1)
2234                               (match_operand:SI 1 "register_operand" "q"))
2235              (const_int 0))
2236          (pc)
2237          (label_ref (match_operand 2 "" ""))))]
2238   ""
2239   "*
2241   return output_bvb (operands, 1, insn, 0);
2243 [(set_attr "type" "cbranch")
2244  (set (attr "length")
2245     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2246                (const_int MAX_12BIT_OFFSET))
2247            (const_int 4)
2248            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2249                (const_int MAX_17BIT_OFFSET))
2250            (const_int 8)
2251            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
2252            (const_int 24)
2253            (eq (symbol_ref "flag_pic") (const_int 0))
2254            (const_int 20)]
2255           (const_int 28)))])
2257 (define_insn ""
2258   [(set (pc)
2259         (if_then_else
2260          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2261                               (const_int 1)
2262                               (match_operand:DI 1 "register_operand" "q"))
2263              (const_int 0))
2264          (pc)
2265          (label_ref (match_operand 2 "" ""))))]
2266   "TARGET_64BIT"
2267   "*
2269   return output_bvb (operands, 1, insn, 0);
2271 [(set_attr "type" "cbranch")
2272  (set (attr "length")
2273     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2274                (const_int MAX_12BIT_OFFSET))
2275            (const_int 4)
2276            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2277                (const_int MAX_17BIT_OFFSET))
2278            (const_int 8)
2279            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
2280            (const_int 24)
2281            (eq (symbol_ref "flag_pic") (const_int 0))
2282            (const_int 20)]
2283           (const_int 28)))])
2285 (define_insn ""
2286   [(set (pc)
2287         (if_then_else
2288          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
2289                               (const_int 1)
2290                               (match_operand:SI 1 "register_operand" "q"))
2291              (const_int 0))
2292          (label_ref (match_operand 2 "" ""))
2293          (pc)))]
2294   ""
2295   "*
2297   return output_bvb (operands, 0, insn, 1);
2299 [(set_attr "type" "cbranch")
2300  (set (attr "length")
2301     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2302                (const_int MAX_12BIT_OFFSET))
2303            (const_int 4)
2304            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2305                (const_int MAX_17BIT_OFFSET))
2306            (const_int 8)
2307            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
2308            (const_int 24)
2309            (eq (symbol_ref "flag_pic") (const_int 0))
2310            (const_int 20)]
2311           (const_int 28)))])
2313 (define_insn ""
2314   [(set (pc)
2315         (if_then_else
2316          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2317                               (const_int 1)
2318                               (match_operand:DI 1 "register_operand" "q"))
2319              (const_int 0))
2320          (label_ref (match_operand 2 "" ""))
2321          (pc)))]
2322   "TARGET_64BIT"
2323   "*
2325   return output_bvb (operands, 0, insn, 1);
2327 [(set_attr "type" "cbranch")
2328  (set (attr "length")
2329     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2330                (const_int MAX_12BIT_OFFSET))
2331            (const_int 4)
2332            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2333                (const_int MAX_17BIT_OFFSET))
2334            (const_int 8)
2335            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
2336            (const_int 24)
2337            (eq (symbol_ref "flag_pic") (const_int 0))
2338            (const_int 20)]
2339           (const_int 28)))])
2341 (define_insn ""
2342   [(set (pc)
2343         (if_then_else
2344          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
2345                               (const_int 1)
2346                               (match_operand:SI 1 "register_operand" "q"))
2347              (const_int 0))
2348          (pc)
2349          (label_ref (match_operand 2 "" ""))))]
2350   ""
2351   "*
2353   return output_bvb (operands, 1, insn, 1);
2355 [(set_attr "type" "cbranch")
2356  (set (attr "length")
2357     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2358                (const_int MAX_12BIT_OFFSET))
2359            (const_int 4)
2360            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2361                (const_int MAX_17BIT_OFFSET))
2362            (const_int 8)
2363            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
2364            (const_int 24)
2365            (eq (symbol_ref "flag_pic") (const_int 0))
2366            (const_int 20)]
2367           (const_int 28)))])
2369 (define_insn ""
2370   [(set (pc)
2371         (if_then_else
2372          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2373                               (const_int 1)
2374                               (match_operand:DI 1 "register_operand" "q"))
2375              (const_int 0))
2376          (pc)
2377          (label_ref (match_operand 2 "" ""))))]
2378   "TARGET_64BIT"
2379   "*
2381   return output_bvb (operands, 1, insn, 1);
2383 [(set_attr "type" "cbranch")
2384  (set (attr "length")
2385     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2386                (const_int MAX_12BIT_OFFSET))
2387            (const_int 4)
2388            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2389                (const_int MAX_17BIT_OFFSET))
2390            (const_int 8)
2391            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
2392            (const_int 24)
2393            (eq (symbol_ref "flag_pic") (const_int 0))
2394            (const_int 20)]
2395           (const_int 28)))])
2397 ;; Floating point branches
2399 ;; ??? Nullification is handled differently from other branches.
2400 ;; If nullification is specified, the delay slot is nullified on any
2401 ;; taken branch regardless of branch direction.
2402 (define_insn ""
2403   [(set (pc) (if_then_else (ne (reg:CCFP 0) (const_int 0))
2404                            (label_ref (match_operand 0 "" ""))
2405                            (pc)))]
2406   "!TARGET_SOFT_FLOAT"
2407   "*
2409   int length = get_attr_length (insn);
2410   rtx xoperands[1];
2411   int nullify, xdelay;
2413   if (length < 16)
2414     return \"ftest\;b%* %l0\";
2416   if (dbr_sequence_length () == 0 || INSN_ANNULLED_BRANCH_P (insn))
2417     {
2418       nullify = 1;
2419       xdelay = 0;
2420       xoperands[0] = GEN_INT (length - 8);
2421     }
2422   else
2423     {
2424       nullify = 0;
2425       xdelay = 1;
2426       xoperands[0] = GEN_INT (length - 4);
2427     }
2429   if (nullify)
2430     output_asm_insn (\"ftest\;add,tr %%r0,%%r0,%%r0\;b,n .+%0\", xoperands);
2431   else
2432     output_asm_insn (\"ftest\;add,tr %%r0,%%r0,%%r0\;b .+%0\", xoperands);
2433   return output_lbranch (operands[0], insn, xdelay);
2435 [(set_attr "type" "fbranch")
2436  (set (attr "length")
2437     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
2438                (const_int MAX_17BIT_OFFSET))
2439            (const_int 8)
2440            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
2441            (const_int 32)
2442            (eq (symbol_ref "flag_pic") (const_int 0))
2443            (const_int 28)]
2444           (const_int 36)))])
2446 (define_insn ""
2447   [(set (pc) (if_then_else (ne (reg:CCFP 0) (const_int 0))
2448                            (pc)
2449                            (label_ref (match_operand 0 "" ""))))]
2450   "!TARGET_SOFT_FLOAT"
2451   "*
2453   int length = get_attr_length (insn);
2454   rtx xoperands[1];
2455   int nullify, xdelay;
2457   if (length < 16)
2458     return \"ftest\;add,tr %%r0,%%r0,%%r0\;b%* %0\";
2460   if (dbr_sequence_length () == 0 || INSN_ANNULLED_BRANCH_P (insn))
2461     {
2462       nullify = 1;
2463       xdelay = 0;
2464       xoperands[0] = GEN_INT (length - 4);
2465     }
2466   else
2467     {
2468       nullify = 0;
2469       xdelay = 1;
2470       xoperands[0] = GEN_INT (length);
2471     }
2473   if (nullify)
2474     output_asm_insn (\"ftest\;b,n .+%0\", xoperands);
2475   else
2476     output_asm_insn (\"ftest\;b .+%0\", xoperands);
2477   return output_lbranch (operands[0], insn, xdelay);
2479 [(set_attr "type" "fbranch")
2480  (set (attr "length")
2481     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
2482                (const_int MAX_17BIT_OFFSET))
2483            (const_int 12)
2484            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
2485            (const_int 28)
2486            (eq (symbol_ref "flag_pic") (const_int 0))
2487            (const_int 24)]
2488           (const_int 32)))])
2490 ;; Move instructions
2492 (define_expand "movsi"
2493   [(set (match_operand:SI 0 "general_operand" "")
2494         (match_operand:SI 1 "general_operand" ""))]
2495   ""
2496   "
2498   if (emit_move_sequence (operands, SImode, 0))
2499     DONE;
2502 ;; Handle SImode input reloads requiring %r1 as a scratch register.
2503 (define_expand "reload_insi_r1"
2504   [(set (match_operand:SI 0 "register_operand" "=Z")
2505         (match_operand:SI 1 "non_hard_reg_operand" ""))
2506    (clobber (match_operand:SI 2 "register_operand" "=&a"))]
2507   ""
2508   "
2510   if (emit_move_sequence (operands, SImode, operands[2]))
2511     DONE;
2513   /* We don't want the clobber emitted, so handle this ourselves.  */
2514   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
2515   DONE;
2518 ;; Handle SImode input reloads requiring a general register as a
2519 ;; scratch register.
2520 (define_expand "reload_insi"
2521   [(set (match_operand:SI 0 "register_operand" "=Z")
2522         (match_operand:SI 1 "non_hard_reg_operand" ""))
2523    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
2524   ""
2525   "
2527   if (emit_move_sequence (operands, SImode, operands[2]))
2528     DONE;
2530   /* We don't want the clobber emitted, so handle this ourselves.  */
2531   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
2532   DONE;
2535 ;; Handle SImode output reloads requiring a general register as a
2536 ;; scratch register.
2537 (define_expand "reload_outsi"
2538   [(set (match_operand:SI 0 "non_hard_reg_operand" "")
2539         (match_operand:SI 1  "register_operand" "Z"))
2540    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
2541   ""
2542   "
2544   if (emit_move_sequence (operands, SImode, operands[2]))
2545     DONE;
2547   /* We don't want the clobber emitted, so handle this ourselves.  */
2548   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
2549   DONE;
2552 (define_insn ""
2553   [(set (match_operand:SI 0 "move_dest_operand"
2554                           "=r,r,r,r,r,r,Q,!*q,!r,!*f,*f,T,?r,?*f")
2555         (match_operand:SI 1 "move_src_operand"
2556                           "A,r,J,N,K,RQ,rM,!rM,!*q,!*fM,RT,*f,*f,r"))]
2557   "(register_operand (operands[0], SImode)
2558     || reg_or_0_operand (operands[1], SImode))
2559    && !TARGET_SOFT_FLOAT
2560    && !TARGET_64BIT"
2561   "@
2562    ldw RT'%A1,%0
2563    copy %1,%0
2564    ldi %1,%0
2565    ldil L'%1,%0
2566    {zdepi|depwi,z} %Z1,%0
2567    ldw%M1 %1,%0
2568    stw%M0 %r1,%0
2569    mtsar %r1
2570    {mfctl|mfctl,w} %%sar,%0
2571    fcpy,sgl %f1,%0
2572    fldw%F1 %1,%0
2573    fstw%F0 %1,%0
2574    {fstws|fstw} %1,-16(%%sp)\n\t{ldws|ldw} -16(%%sp),%0
2575    {stws|stw} %1,-16(%%sp)\n\t{fldws|fldw} -16(%%sp),%0"
2576   [(set_attr "type" "load,move,move,move,shift,load,store,move,move,fpalu,fpload,fpstore,fpstore_load,store_fpload")
2577    (set_attr "pa_combine_type" "addmove")
2578    (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4,8,8")])
2580 (define_insn ""
2581   [(set (match_operand:SI 0 "move_dest_operand"
2582                           "=r,r,r,r,r,r,Q,!*q,!r,!*f,*f,T")
2583         (match_operand:SI 1 "move_src_operand"
2584                           "A,r,J,N,K,RQ,rM,!rM,!*q,!*fM,RT,*f"))]
2585   "(register_operand (operands[0], SImode)
2586     || reg_or_0_operand (operands[1], SImode))
2587    && !TARGET_SOFT_FLOAT
2588    && TARGET_64BIT"
2589   "@
2590    ldw RT'%A1,%0
2591    copy %1,%0
2592    ldi %1,%0
2593    ldil L'%1,%0
2594    {zdepi|depwi,z} %Z1,%0
2595    ldw%M1 %1,%0
2596    stw%M0 %r1,%0
2597    mtsar %r1
2598    {mfctl|mfctl,w} %%sar,%0
2599    fcpy,sgl %f1,%0
2600    fldw%F1 %1,%0
2601    fstw%F0 %1,%0"
2602   [(set_attr "type" "load,move,move,move,shift,load,store,move,move,fpalu,fpload,fpstore")
2603    (set_attr "pa_combine_type" "addmove")
2604    (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4")])
2606 (define_insn ""
2607   [(set (match_operand:SI 0 "indexed_memory_operand" "=R")
2608         (match_operand:SI 1 "register_operand" "f"))]
2609   "!TARGET_SOFT_FLOAT
2610    && !TARGET_DISABLE_INDEXING
2611    && reload_completed"
2612   "fstw%F0 %1,%0"
2613   [(set_attr "type" "fpstore")
2614    (set_attr "pa_combine_type" "addmove")
2615    (set_attr "length" "4")])
2617 ; Rewrite RTL using an indexed store.  This will allow the insn that
2618 ; computes the address to be deleted if the register it sets is dead.
2619 (define_peephole2
2620   [(set (match_operand:SI 0 "register_operand" "")
2621         (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "")
2622                           (const_int 4))
2623                  (match_operand:SI 2 "register_operand" "")))
2624    (set (mem:SI (match_dup 0))
2625         (match_operand:SI 3 "register_operand" ""))]
2626   "!TARGET_SOFT_FLOAT
2627    && !TARGET_DISABLE_INDEXING
2628    && REG_OK_FOR_BASE_P (operands[2])
2629    && FP_REGNO_P (REGNO (operands[3]))"
2630   [(set (mem:SI (plus:SI (mult:SI (match_dup 1) (const_int 4)) (match_dup 2)))
2631         (match_dup 3))
2632    (set (match_dup 0) (plus:SI (mult:SI (match_dup 1) (const_int 4))
2633                                (match_dup 2)))]
2634   "")
2636 (define_peephole2
2637   [(set (match_operand:SI 0 "register_operand" "")
2638         (plus:SI (match_operand:SI 2 "register_operand" "")
2639                  (mult:SI (match_operand:SI 1 "register_operand" "")
2640                           (const_int 4))))
2641    (set (mem:SI (match_dup 0))
2642         (match_operand:SI 3 "register_operand" ""))]
2643   "!TARGET_SOFT_FLOAT
2644    && !TARGET_DISABLE_INDEXING
2645    && REG_OK_FOR_BASE_P (operands[2])
2646    && FP_REGNO_P (REGNO (operands[3]))"
2647   [(set (mem:SI (plus:SI (mult:SI (match_dup 1) (const_int 4)) (match_dup 2)))
2648         (match_dup 3))
2649    (set (match_dup 0) (plus:SI (mult:SI (match_dup 1) (const_int 4))
2650                                (match_dup 2)))]
2651   "")
2653 (define_peephole2
2654   [(set (match_operand:DI 0 "register_operand" "")
2655         (plus:DI (mult:DI (match_operand:DI 1 "register_operand" "")
2656                           (const_int 4))
2657                  (match_operand:DI 2 "register_operand" "")))
2658    (set (mem:SI (match_dup 0))
2659         (match_operand:SI 3 "register_operand" ""))]
2660   "!TARGET_SOFT_FLOAT
2661    && !TARGET_DISABLE_INDEXING
2662    && TARGET_64BIT
2663    && REG_OK_FOR_BASE_P (operands[2])
2664    && FP_REGNO_P (REGNO (operands[3]))"
2665   [(set (mem:SI (plus:DI (mult:DI (match_dup 1) (const_int 4)) (match_dup 2)))
2666         (match_dup 3))
2667    (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 4))
2668                                (match_dup 2)))]
2669   "")
2671 (define_peephole2
2672   [(set (match_operand:DI 0 "register_operand" "")
2673         (plus:DI (match_operand:DI 2 "register_operand" "")
2674                  (mult:DI (match_operand:DI 1 "register_operand" "")
2675                           (const_int 4))))
2676    (set (mem:SI (match_dup 0))
2677         (match_operand:SI 3 "register_operand" ""))]
2678   "!TARGET_SOFT_FLOAT
2679    && !TARGET_DISABLE_INDEXING
2680    && TARGET_64BIT
2681    && REG_OK_FOR_BASE_P (operands[2])
2682    && FP_REGNO_P (REGNO (operands[3]))"
2683   [(set (mem:SI (plus:DI (mult:DI (match_dup 1) (const_int 4)) (match_dup 2)))
2684         (match_dup 3))
2685    (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 4))
2686                                (match_dup 2)))]
2687   "")
2689 (define_peephole2
2690   [(set (match_operand:SI 0 "register_operand" "")
2691         (plus:SI (match_operand:SI 1 "register_operand" "")
2692                  (match_operand:SI 2 "register_operand" "")))
2693    (set (mem:SI (match_dup 0))
2694         (match_operand:SI 3 "register_operand" ""))]
2695   "!TARGET_SOFT_FLOAT
2696    && !TARGET_DISABLE_INDEXING
2697    && TARGET_NO_SPACE_REGS
2698    && REG_OK_FOR_INDEX_P (operands[1])
2699    && REG_OK_FOR_BASE_P (operands[2])
2700    && FP_REGNO_P (REGNO (operands[3]))"
2701   [(set (mem:SI (plus:SI (match_dup 1) (match_dup 2)))
2702         (match_dup 3))
2703    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
2704   "")
2706 (define_peephole2
2707   [(set (match_operand:SI 0 "register_operand" "")
2708         (plus:SI (match_operand:SI 1 "register_operand" "")
2709                  (match_operand:SI 2 "register_operand" "")))
2710    (set (mem:SI (match_dup 0))
2711         (match_operand:SI 3 "register_operand" ""))]
2712   "!TARGET_SOFT_FLOAT
2713    && !TARGET_DISABLE_INDEXING
2714    && TARGET_NO_SPACE_REGS
2715    && REG_OK_FOR_BASE_P (operands[1])
2716    && REG_OK_FOR_INDEX_P (operands[2])
2717    && FP_REGNO_P (REGNO (operands[3]))"
2718   [(set (mem:SI (plus:SI (match_dup 2) (match_dup 1)))
2719         (match_dup 3))
2720    (set (match_dup 0) (plus:SI (match_dup 2) (match_dup 1)))]
2721   "")
2723 (define_peephole2
2724   [(set (match_operand:DI 0 "register_operand" "")
2725         (plus:DI (match_operand:DI 1 "register_operand" "")
2726                  (match_operand:DI 2 "register_operand" "")))
2727    (set (mem:SI (match_dup 0))
2728         (match_operand:SI 3 "register_operand" ""))]
2729   "!TARGET_SOFT_FLOAT
2730    && !TARGET_DISABLE_INDEXING
2731    && TARGET_64BIT
2732    && TARGET_NO_SPACE_REGS
2733    && REG_OK_FOR_INDEX_P (operands[1])
2734    && REG_OK_FOR_BASE_P (operands[2])
2735    && FP_REGNO_P (REGNO (operands[3]))"
2736   [(set (mem:SI (plus:DI (match_dup 1) (match_dup 2)))
2737         (match_dup 3))
2738    (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
2739   "")
2741 (define_peephole2
2742   [(set (match_operand:DI 0 "register_operand" "")
2743         (plus:DI (match_operand:DI 1 "register_operand" "")
2744                  (match_operand:DI 2 "register_operand" "")))
2745    (set (mem:SI (match_dup 0))
2746         (match_operand:SI 3 "register_operand" ""))]
2747   "!TARGET_SOFT_FLOAT
2748    && !TARGET_DISABLE_INDEXING
2749    && TARGET_64BIT
2750    && TARGET_NO_SPACE_REGS
2751    && REG_OK_FOR_BASE_P (operands[1])
2752    && REG_OK_FOR_INDEX_P (operands[2])
2753    && FP_REGNO_P (REGNO (operands[3]))"
2754   [(set (mem:SI (plus:DI (match_dup 2) (match_dup 1)))
2755         (match_dup 3))
2756    (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
2757   "")
2759 (define_insn ""
2760   [(set (match_operand:SI 0 "move_dest_operand"
2761                           "=r,r,r,r,r,r,Q,!*q,!r")
2762         (match_operand:SI 1 "move_src_operand"
2763                           "A,r,J,N,K,RQ,rM,!rM,!*q"))]
2764   "(register_operand (operands[0], SImode)
2765     || reg_or_0_operand (operands[1], SImode))
2766    && TARGET_SOFT_FLOAT"
2767   "@
2768    ldw RT'%A1,%0
2769    copy %1,%0
2770    ldi %1,%0
2771    ldil L'%1,%0
2772    {zdepi|depwi,z} %Z1,%0
2773    ldw%M1 %1,%0
2774    stw%M0 %r1,%0
2775    mtsar %r1
2776    {mfctl|mfctl,w} %%sar,%0"
2777   [(set_attr "type" "load,move,move,move,move,load,store,move,move")
2778    (set_attr "pa_combine_type" "addmove")
2779    (set_attr "length" "4,4,4,4,4,4,4,4,4")])
2781 ;; Load or store with base-register modification.
2782 (define_insn ""
2783   [(set (match_operand:SI 0 "register_operand" "=r")
2784         (mem:SI (plus:DI (match_operand:DI 1 "register_operand" "+r")
2785                          (match_operand:DI 2 "int5_operand" "L"))))
2786    (set (match_dup 1)
2787         (plus:DI (match_dup 1) (match_dup 2)))]
2788   "TARGET_64BIT"
2789   "ldw,mb %2(%1),%0"
2790   [(set_attr "type" "load")
2791    (set_attr "length" "4")])
2793 ; And a zero extended variant.
2794 (define_insn ""
2795   [(set (match_operand:DI 0 "register_operand" "=r")
2796         (zero_extend:DI (mem:SI
2797                           (plus:DI
2798                             (match_operand:DI 1 "register_operand" "+r")
2799                             (match_operand:DI 2 "int5_operand" "L")))))
2800    (set (match_dup 1)
2801         (plus:DI (match_dup 1) (match_dup 2)))]
2802   "TARGET_64BIT"
2803   "ldw,mb %2(%1),%0"
2804   [(set_attr "type" "load")
2805    (set_attr "length" "4")])
2807 (define_expand "pre_load"
2808   [(parallel [(set (match_operand:SI 0 "register_operand" "")
2809               (mem (plus (match_operand 1 "register_operand" "")
2810                                (match_operand 2 "pre_cint_operand" ""))))
2811               (set (match_dup 1)
2812                    (plus (match_dup 1) (match_dup 2)))])]
2813   ""
2814   "
2816   if (TARGET_64BIT)
2817     {
2818       emit_insn (gen_pre_ldd (operands[0], operands[1], operands[2]));
2819       DONE;
2820     }
2821   emit_insn (gen_pre_ldw (operands[0], operands[1], operands[2]));
2822   DONE;
2825 (define_insn "pre_ldw"
2826   [(set (match_operand:SI 0 "register_operand" "=r")
2827         (mem:SI (plus:SI (match_operand:SI 1 "register_operand" "+r")
2828                          (match_operand:SI 2 "pre_cint_operand" ""))))
2829    (set (match_dup 1)
2830         (plus:SI (match_dup 1) (match_dup 2)))]
2831   ""
2832   "*
2834   if (INTVAL (operands[2]) < 0)
2835     return \"{ldwm|ldw,mb} %2(%1),%0\";
2836   return \"{ldws|ldw},mb %2(%1),%0\";
2838   [(set_attr "type" "load")
2839    (set_attr "length" "4")])
2841 (define_insn "pre_ldd"
2842   [(set (match_operand:DI 0 "register_operand" "=r")
2843         (mem:DI (plus:DI (match_operand:DI 1 "register_operand" "+r")
2844                          (match_operand:DI 2 "pre_cint_operand" ""))))
2845    (set (match_dup 1)
2846         (plus:DI (match_dup 1) (match_dup 2)))]
2847   "TARGET_64BIT"
2848   "ldd,mb %2(%1),%0"
2849   [(set_attr "type" "load")
2850    (set_attr "length" "4")])
2852 (define_insn ""
2853   [(set (mem:SI (plus:SI (match_operand:SI 0 "register_operand" "+r")
2854                          (match_operand:SI 1 "pre_cint_operand" "")))
2855         (match_operand:SI 2 "reg_or_0_operand" "rM"))
2856    (set (match_dup 0)
2857         (plus:SI (match_dup 0) (match_dup 1)))]
2858   ""
2859   "*
2861   if (INTVAL (operands[1]) < 0)
2862     return \"{stwm|stw,mb} %r2,%1(%0)\";
2863   return \"{stws|stw},mb %r2,%1(%0)\";
2865   [(set_attr "type" "store")
2866    (set_attr "length" "4")])
2868 (define_insn ""
2869   [(set (match_operand:SI 0 "register_operand" "=r")
2870         (mem:SI (match_operand:SI 1 "register_operand" "+r")))
2871    (set (match_dup 1)
2872         (plus:SI (match_dup 1)
2873                  (match_operand:SI 2 "post_cint_operand" "")))]
2874   ""
2875   "*
2877   if (INTVAL (operands[2]) > 0)
2878     return \"{ldwm|ldw,ma} %2(%1),%0\";
2879   return \"{ldws|ldw},ma %2(%1),%0\";
2881   [(set_attr "type" "load")
2882    (set_attr "length" "4")])
2884 (define_expand "post_store"
2885   [(parallel [(set (mem (match_operand 0 "register_operand" ""))
2886                    (match_operand 1 "reg_or_0_operand" ""))
2887               (set (match_dup 0)
2888                    (plus (match_dup 0)
2889                          (match_operand 2 "post_cint_operand" "")))])]
2890   ""
2891   "
2893   if (TARGET_64BIT)
2894     {
2895       emit_insn (gen_post_std (operands[0], operands[1], operands[2]));
2896       DONE;
2897     }
2898   emit_insn (gen_post_stw (operands[0], operands[1], operands[2]));
2899   DONE;
2902 (define_insn "post_stw"
2903   [(set (mem:SI (match_operand:SI 0 "register_operand" "+r"))
2904         (match_operand:SI 1 "reg_or_0_operand" "rM"))
2905    (set (match_dup 0)
2906         (plus:SI (match_dup 0)
2907                  (match_operand:SI 2 "post_cint_operand" "")))]
2908   ""
2909   "*
2911   if (INTVAL (operands[2]) > 0)
2912     return \"{stwm|stw,ma} %r1,%2(%0)\";
2913   return \"{stws|stw},ma %r1,%2(%0)\";
2915   [(set_attr "type" "store")
2916    (set_attr "length" "4")])
2918 (define_insn "post_std"
2919   [(set (mem:DI (match_operand:DI 0 "register_operand" "+r"))
2920         (match_operand:DI 1 "reg_or_0_operand" "rM"))
2921    (set (match_dup 0)
2922         (plus:DI (match_dup 0)
2923                  (match_operand:DI 2 "post_cint_operand" "")))]
2924   "TARGET_64BIT"
2925   "std,ma %r1,%2(%0)"
2926   [(set_attr "type" "store")
2927    (set_attr "length" "4")])
2929 ;; For loading the address of a label while generating PIC code.
2930 ;; Note since this pattern can be created at reload time (via movsi), all
2931 ;; the same rules for movsi apply here.  (no new pseudos, no temporaries).
2932 (define_insn ""
2933   [(set (match_operand 0 "pmode_register_operand" "=a")
2934         (match_operand 1 "pic_label_operand" ""))]
2935   "TARGET_PA_20"
2936   "*
2938   rtx xoperands[3];
2940   xoperands[0] = operands[0];
2941   xoperands[1] = operands[1];
2942   xoperands[2] = gen_label_rtx ();
2944   (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
2945                                      CODE_LABEL_NUMBER (xoperands[2]));
2946   output_asm_insn (\"mfia %0\", xoperands);
2948   /* If we're trying to load the address of a label that happens to be
2949      close, then we can use a shorter sequence.  */
2950   if (GET_CODE (operands[1]) == LABEL_REF
2951       && !LABEL_REF_NONLOCAL_P (operands[1])
2952       && INSN_ADDRESSES_SET_P ()
2953       && abs (INSN_ADDRESSES (INSN_UID (XEXP (operands[1], 0)))
2954                 - INSN_ADDRESSES (INSN_UID (insn))) < 8100)
2955     output_asm_insn (\"ldo %1-%2(%0),%0\", xoperands);
2956   else
2957     {
2958       output_asm_insn (\"addil L%%%1-%2,%0\", xoperands);
2959       output_asm_insn (\"ldo R%%%1-%2(%0),%0\", xoperands);
2960     }
2961   return \"\";
2963   [(set_attr "type" "multi")
2964    (set_attr "length" "12")])           ; 8 or 12
2966 (define_insn ""
2967   [(set (match_operand 0 "pmode_register_operand" "=a")
2968         (match_operand 1 "pic_label_operand" ""))]
2969   "!TARGET_PA_20"
2970   "*
2972   rtx xoperands[3];
2974   xoperands[0] = operands[0];
2975   xoperands[1] = operands[1];
2976   xoperands[2] = gen_label_rtx ();
2978   output_asm_insn (\"bl .+8,%0\", xoperands);
2979   output_asm_insn (\"depi 0,31,2,%0\", xoperands);
2980   (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
2981                                      CODE_LABEL_NUMBER (xoperands[2]));
2983   /* If we're trying to load the address of a label that happens to be
2984      close, then we can use a shorter sequence.  */
2985   if (GET_CODE (operands[1]) == LABEL_REF
2986       && !LABEL_REF_NONLOCAL_P (operands[1])
2987       && INSN_ADDRESSES_SET_P ()
2988       && abs (INSN_ADDRESSES (INSN_UID (XEXP (operands[1], 0)))
2989                 - INSN_ADDRESSES (INSN_UID (insn))) < 8100)
2990     output_asm_insn (\"ldo %1-%2(%0),%0\", xoperands);
2991   else
2992     {
2993       output_asm_insn (\"addil L%%%1-%2,%0\", xoperands);
2994       output_asm_insn (\"ldo R%%%1-%2(%0),%0\", xoperands);
2995     }
2996   return \"\";
2998   [(set_attr "type" "multi")
2999    (set_attr "length" "16")])           ; 12 or 16
3001 (define_insn ""
3002   [(set (match_operand:SI 0 "register_operand" "=a")
3003         (plus:SI (match_operand:SI 1 "register_operand" "r")
3004                  (high:SI (match_operand 2 "" ""))))]
3005   "symbolic_operand (operands[2], Pmode)
3006    && ! function_label_operand (operands[2], Pmode)
3007    && flag_pic"
3008   "addil LT'%G2,%1"
3009   [(set_attr "type" "binary")
3010    (set_attr "length" "4")])
3012 (define_insn ""
3013   [(set (match_operand:DI 0 "register_operand" "=a")
3014         (plus:DI (match_operand:DI 1 "register_operand" "r")
3015                  (high:DI (match_operand 2 "" ""))))]
3016   "symbolic_operand (operands[2], Pmode)
3017    && ! function_label_operand (operands[2], Pmode)
3018    && TARGET_64BIT
3019    && flag_pic"
3020   "addil LT'%G2,%1"
3021   [(set_attr "type" "binary")
3022    (set_attr "length" "4")])
3024 ;; Always use addil rather than ldil;add sequences.  This allows the
3025 ;; HP linker to eliminate the dp relocation if the symbolic operand
3026 ;; lives in the TEXT space.
3027 (define_insn ""
3028   [(set (match_operand:SI 0 "register_operand" "=a")
3029         (high:SI (match_operand 1 "" "")))]
3030   "symbolic_operand (operands[1], Pmode)
3031    && ! function_label_operand (operands[1], Pmode)
3032    && ! read_only_operand (operands[1], Pmode)
3033    && ! flag_pic"
3034   "*
3036   if (TARGET_LONG_LOAD_STORE)
3037     return \"addil NLR'%H1,%%r27\;ldo N'%H1(%%r1),%%r1\";
3038   else
3039     return \"addil LR'%H1,%%r27\";
3041   [(set_attr "type" "binary")
3042    (set (attr "length")
3043       (if_then_else (eq (symbol_ref "TARGET_LONG_LOAD_STORE") (const_int 0))
3044                     (const_int 4)
3045                     (const_int 8)))])
3048 ;; This is for use in the prologue/epilogue code.  We need it
3049 ;; to add large constants to a stack pointer or frame pointer.
3050 ;; Because of the additional %r1 pressure, we probably do not
3051 ;; want to use this in general code, so make it available
3052 ;; only after reload.
3053 (define_insn ""
3054   [(set (match_operand:SI 0 "register_operand" "=!a,*r")
3055         (plus:SI (match_operand:SI 1 "register_operand" "r,r")
3056                  (high:SI (match_operand 2 "const_int_operand" ""))))]
3057   "reload_completed"
3058   "@
3059    addil L'%G2,%1
3060    ldil L'%G2,%0\;{addl|add,l} %0,%1,%0"
3061   [(set_attr "type" "binary,binary")
3062    (set_attr "length" "4,8")])
3064 (define_insn ""
3065   [(set (match_operand:DI 0 "register_operand" "=!a,*r")
3066         (plus:DI (match_operand:DI 1 "register_operand" "r,r")
3067                  (high:DI (match_operand 2 "const_int_operand" ""))))]
3068   "reload_completed && TARGET_64BIT"
3069   "@
3070    addil L'%G2,%1
3071    ldil L'%G2,%0\;{addl|add,l} %0,%1,%0"
3072   [(set_attr "type" "binary,binary")
3073    (set_attr "length" "4,8")])
3075 (define_insn ""
3076   [(set (match_operand:SI 0 "register_operand" "=r")
3077         (high:SI (match_operand 1 "" "")))]
3078   "(!flag_pic || !symbolic_operand (operands[1], Pmode))
3079     && !is_function_label_plus_const (operands[1])"
3080   "*
3082   if (symbolic_operand (operands[1], Pmode))
3083     return \"ldil LR'%H1,%0\";
3084   else
3085     return \"ldil L'%G1,%0\";
3087   [(set_attr "type" "move")
3088    (set_attr "length" "4")])
3090 (define_insn ""
3091   [(set (match_operand:DI 0 "register_operand" "=r")
3092         (high:DI (match_operand 1 "const_int_operand" "")))]
3093   "TARGET_64BIT"
3094   "ldil L'%G1,%0";
3095   [(set_attr "type" "move")
3096    (set_attr "length" "4")])
3098 (define_insn ""
3099   [(set (match_operand:DI 0 "register_operand" "=r")
3100         (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
3101                    (match_operand:DI 2 "const_int_operand" "i")))]
3102   "TARGET_64BIT"
3103   "ldo R'%G2(%1),%0";
3104   [(set_attr "type" "move")
3105    (set_attr "length" "4")])
3107 (define_insn ""
3108   [(set (match_operand:SI 0 "register_operand" "=r")
3109         (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
3110                    (match_operand:SI 2 "immediate_operand" "i")))]
3111   "!is_function_label_plus_const (operands[2])"
3112   "*
3114   gcc_assert (!flag_pic || !symbolic_operand (operands[2], Pmode));
3115   
3116   if (symbolic_operand (operands[2], Pmode))
3117     return \"ldo RR'%G2(%1),%0\";
3118   else
3119     return \"ldo R'%G2(%1),%0\";
3121   [(set_attr "type" "move")
3122    (set_attr "length" "4")])
3124 ;; Now that a symbolic_address plus a constant is broken up early
3125 ;; in the compilation phase (for better CSE) we need a special
3126 ;; combiner pattern to load the symbolic address plus the constant
3127 ;; in only 2 instructions. (For cases where the symbolic address
3128 ;; was not a common subexpression.)
3129 (define_split
3130   [(set (match_operand:SI 0 "register_operand" "")
3131         (match_operand:SI 1 "symbolic_operand" ""))
3132    (clobber (match_operand:SI 2 "register_operand" ""))]
3133   "! (flag_pic && pic_label_operand (operands[1], SImode))"
3134   [(set (match_dup 2) (high:SI (match_dup 1)))
3135    (set (match_dup 0) (lo_sum:SI (match_dup 2) (match_dup 1)))]
3136   "")
3138 ;; hppa_legitimize_address goes to a great deal of trouble to
3139 ;; create addresses which use indexing.  In some cases, this
3140 ;; is a lose because there isn't any store instructions which
3141 ;; allow indexed addresses (with integer register source).
3143 ;; These define_splits try to turn a 3 insn store into
3144 ;; a 2 insn store with some creative RTL rewriting.
3145 (define_split
3146   [(set (mem:SI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
3147                                (match_operand:SI 1 "shadd_operand" ""))
3148                    (plus:SI (match_operand:SI 2 "register_operand" "")
3149                             (match_operand:SI 3 "const_int_operand" ""))))
3150         (match_operand:SI 4 "register_operand" ""))
3151    (clobber (match_operand:SI 5 "register_operand" ""))]
3152   ""
3153   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
3154                                (match_dup 2)))
3155    (set (mem:SI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
3156   "")
3158 (define_split
3159   [(set (mem:HI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
3160                                (match_operand:SI 1 "shadd_operand" ""))
3161                    (plus:SI (match_operand:SI 2 "register_operand" "")
3162                             (match_operand:SI 3 "const_int_operand" ""))))
3163         (match_operand:HI 4 "register_operand" ""))
3164    (clobber (match_operand:SI 5 "register_operand" ""))]
3165   ""
3166   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
3167                                (match_dup 2)))
3168    (set (mem:HI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
3169   "")
3171 (define_split
3172   [(set (mem:QI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
3173                                (match_operand:SI 1 "shadd_operand" ""))
3174                    (plus:SI (match_operand:SI 2 "register_operand" "")
3175                             (match_operand:SI 3 "const_int_operand" ""))))
3176         (match_operand:QI 4 "register_operand" ""))
3177    (clobber (match_operand:SI 5 "register_operand" ""))]
3178   ""
3179   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
3180                                (match_dup 2)))
3181    (set (mem:QI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
3182   "")
3184 (define_expand "movhi"
3185   [(set (match_operand:HI 0 "general_operand" "")
3186         (match_operand:HI 1 "general_operand" ""))]
3187   ""
3188   "
3190   if (emit_move_sequence (operands, HImode, 0))
3191     DONE;
3194 (define_insn ""
3195   [(set (match_operand:HI 0 "move_dest_operand"
3196                           "=r,r,r,r,r,Q,!*q,!r")
3197         (match_operand:HI 1 "move_src_operand"
3198                           "r,J,N,K,RQ,rM,!rM,!*q"))]
3199   "(register_operand (operands[0], HImode)
3200     || reg_or_0_operand (operands[1], HImode))"
3201   "@
3202    copy %1,%0
3203    ldi %1,%0
3204    ldil L'%1,%0
3205    {zdepi|depwi,z} %Z1,%0
3206    ldh%M1 %1,%0
3207    sth%M0 %r1,%0
3208    mtsar %r1
3209    {mfctl|mfctl,w} %sar,%0"
3210   [(set_attr "type" "move,move,move,shift,load,store,move,move")
3211    (set_attr "pa_combine_type" "addmove")
3212    (set_attr "length" "4,4,4,4,4,4,4,4")])
3214 (define_insn ""
3215   [(set (match_operand:HI 0 "register_operand" "=r")
3216         (mem:HI (plus:SI (match_operand:SI 1 "register_operand" "+r")
3217                          (match_operand:SI 2 "int5_operand" "L"))))
3218    (set (match_dup 1)
3219         (plus:SI (match_dup 1) (match_dup 2)))]
3220   ""
3221   "{ldhs|ldh},mb %2(%1),%0"
3222   [(set_attr "type" "load")
3223    (set_attr "length" "4")])
3225 (define_insn ""
3226   [(set (match_operand:HI 0 "register_operand" "=r")
3227         (mem:HI (plus:DI (match_operand:DI 1 "register_operand" "+r")
3228                          (match_operand:DI 2 "int5_operand" "L"))))
3229    (set (match_dup 1)
3230         (plus:DI (match_dup 1) (match_dup 2)))]
3231   "TARGET_64BIT"
3232   "ldh,mb %2(%1),%0"
3233   [(set_attr "type" "load")
3234    (set_attr "length" "4")])
3236 ; And a zero extended variant.
3237 (define_insn ""
3238   [(set (match_operand:DI 0 "register_operand" "=r")
3239         (zero_extend:DI (mem:HI
3240                           (plus:DI
3241                             (match_operand:DI 1 "register_operand" "+r")
3242                             (match_operand:DI 2 "int5_operand" "L")))))
3243    (set (match_dup 1)
3244         (plus:DI (match_dup 1) (match_dup 2)))]
3245   "TARGET_64BIT"
3246   "ldh,mb %2(%1),%0"
3247   [(set_attr "type" "load")
3248    (set_attr "length" "4")])
3250 (define_insn ""
3251   [(set (match_operand:SI 0 "register_operand" "=r")
3252         (zero_extend:SI (mem:HI
3253                           (plus:SI
3254                             (match_operand:SI 1 "register_operand" "+r")
3255                             (match_operand:SI 2 "int5_operand" "L")))))
3256    (set (match_dup 1)
3257         (plus:SI (match_dup 1) (match_dup 2)))]
3258   ""
3259   "{ldhs|ldh},mb %2(%1),%0"
3260   [(set_attr "type" "load")
3261    (set_attr "length" "4")])
3263 (define_insn ""
3264   [(set (match_operand:SI 0 "register_operand" "=r")
3265         (zero_extend:SI (mem:HI
3266                           (plus:DI
3267                             (match_operand:DI 1 "register_operand" "+r")
3268                             (match_operand:DI 2 "int5_operand" "L")))))
3269    (set (match_dup 1)
3270         (plus:DI (match_dup 1) (match_dup 2)))]
3271   "TARGET_64BIT"
3272   "ldh,mb %2(%1),%0"
3273   [(set_attr "type" "load")
3274    (set_attr "length" "4")])
3276 (define_insn ""
3277   [(set (mem:HI (plus:SI (match_operand:SI 0 "register_operand" "+r")
3278                          (match_operand:SI 1 "int5_operand" "L")))
3279         (match_operand:HI 2 "reg_or_0_operand" "rM"))
3280    (set (match_dup 0)
3281         (plus:SI (match_dup 0) (match_dup 1)))]
3282   ""
3283   "{sths|sth},mb %r2,%1(%0)"
3284   [(set_attr "type" "store")
3285    (set_attr "length" "4")])
3287 (define_insn ""
3288   [(set (mem:HI (plus:DI (match_operand:DI 0 "register_operand" "+r")
3289                          (match_operand:DI 1 "int5_operand" "L")))
3290         (match_operand:HI 2 "reg_or_0_operand" "rM"))
3291    (set (match_dup 0)
3292         (plus:DI (match_dup 0) (match_dup 1)))]
3293   "TARGET_64BIT"
3294   "sth,mb %r2,%1(%0)"
3295   [(set_attr "type" "store")
3296    (set_attr "length" "4")])
3298 (define_insn ""
3299   [(set (match_operand:HI 0 "register_operand" "=r")
3300         (plus:HI (match_operand:HI 1 "register_operand" "r")
3301                  (match_operand 2 "const_int_operand" "J")))]
3302   ""
3303   "ldo %2(%1),%0"
3304   [(set_attr "type" "binary")
3305    (set_attr "pa_combine_type" "addmove")
3306    (set_attr "length" "4")])
3308 (define_expand "movqi"
3309   [(set (match_operand:QI 0 "general_operand" "")
3310         (match_operand:QI 1 "general_operand" ""))]
3311   ""
3312   "
3314   if (emit_move_sequence (operands, QImode, 0))
3315     DONE;
3318 (define_insn ""
3319   [(set (match_operand:QI 0 "move_dest_operand"
3320                           "=r,r,r,r,r,Q,!*q,!r")
3321         (match_operand:QI 1 "move_src_operand"
3322                           "r,J,N,K,RQ,rM,!rM,!*q"))]
3323   "(register_operand (operands[0], QImode)
3324     || reg_or_0_operand (operands[1], QImode))"
3325   "@
3326    copy %1,%0
3327    ldi %1,%0
3328    ldil L'%1,%0
3329    {zdepi|depwi,z} %Z1,%0
3330    ldb%M1 %1,%0
3331    stb%M0 %r1,%0
3332    mtsar %r1
3333    {mfctl|mfctl,w} %%sar,%0"
3334   [(set_attr "type" "move,move,move,shift,load,store,move,move")
3335    (set_attr "pa_combine_type" "addmove")
3336    (set_attr "length" "4,4,4,4,4,4,4,4")])
3338 (define_insn ""
3339   [(set (match_operand:QI 0 "register_operand" "=r")
3340         (mem:QI (plus:SI (match_operand:SI 1 "register_operand" "+r")
3341                          (match_operand:SI 2 "int5_operand" "L"))))
3342    (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
3343   ""
3344   "{ldbs|ldb},mb %2(%1),%0"
3345   [(set_attr "type" "load")
3346    (set_attr "length" "4")])
3348 (define_insn ""
3349   [(set (match_operand:QI 0 "register_operand" "=r")
3350         (mem:QI (plus:DI (match_operand:DI 1 "register_operand" "+r")
3351                          (match_operand:DI 2 "int5_operand" "L"))))
3352    (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3353   "TARGET_64BIT"
3354   "ldb,mb %2(%1),%0"
3355   [(set_attr "type" "load")
3356    (set_attr "length" "4")])
3358 ; Now the same thing with zero extensions.
3359 (define_insn ""
3360   [(set (match_operand:DI 0 "register_operand" "=r")
3361         (zero_extend:DI (mem:QI (plus:DI
3362                                   (match_operand:DI 1 "register_operand" "+r")
3363                                   (match_operand:DI 2 "int5_operand" "L")))))
3364    (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3365   "TARGET_64BIT"
3366   "ldb,mb %2(%1),%0"
3367   [(set_attr "type" "load")
3368    (set_attr "length" "4")])
3370 (define_insn ""
3371   [(set (match_operand:SI 0 "register_operand" "=r")
3372         (zero_extend:SI (mem:QI (plus:SI
3373                                   (match_operand:SI 1 "register_operand" "+r")
3374                                   (match_operand:SI 2 "int5_operand" "L")))))
3375    (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
3376   ""
3377   "{ldbs|ldb},mb %2(%1),%0"
3378   [(set_attr "type" "load")
3379    (set_attr "length" "4")])
3381 (define_insn ""
3382   [(set (match_operand:SI 0 "register_operand" "=r")
3383         (zero_extend:SI (mem:QI (plus:DI
3384                                   (match_operand:DI 1 "register_operand" "+r")
3385                                   (match_operand:DI 2 "int5_operand" "L")))))
3386    (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3387   "TARGET_64BIT"
3388   "ldb,mb %2(%1),%0"
3389   [(set_attr "type" "load")
3390    (set_attr "length" "4")])
3392 (define_insn ""
3393   [(set (match_operand:HI 0 "register_operand" "=r")
3394         (zero_extend:HI (mem:QI (plus:SI
3395                                   (match_operand:SI 1 "register_operand" "+r")
3396                                   (match_operand:SI 2 "int5_operand" "L")))))
3397    (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
3398   ""
3399   "{ldbs|ldb},mb %2(%1),%0"
3400   [(set_attr "type" "load")
3401    (set_attr "length" "4")])
3403 (define_insn ""
3404   [(set (match_operand:HI 0 "register_operand" "=r")
3405         (zero_extend:HI (mem:QI (plus:DI
3406                                   (match_operand:DI 1 "register_operand" "+r")
3407                                   (match_operand:DI 2 "int5_operand" "L")))))
3408    (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3409   "TARGET_64BIT"
3410   "ldb,mb %2(%1),%0"
3411   [(set_attr "type" "load")
3412    (set_attr "length" "4")])
3414 (define_insn ""
3415   [(set (mem:QI (plus:SI (match_operand:SI 0 "register_operand" "+r")
3416                          (match_operand:SI 1 "int5_operand" "L")))
3417         (match_operand:QI 2 "reg_or_0_operand" "rM"))
3418    (set (match_dup 0)
3419         (plus:SI (match_dup 0) (match_dup 1)))]
3420   ""
3421   "{stbs|stb},mb %r2,%1(%0)"
3422   [(set_attr "type" "store")
3423    (set_attr "length" "4")])
3425 (define_insn ""
3426   [(set (mem:QI (plus:DI (match_operand:DI 0 "register_operand" "+r")
3427                          (match_operand:DI 1 "int5_operand" "L")))
3428         (match_operand:QI 2 "reg_or_0_operand" "rM"))
3429    (set (match_dup 0)
3430         (plus:DI (match_dup 0) (match_dup 1)))]
3431   "TARGET_64BIT"
3432   "stb,mb %r2,%1(%0)"
3433   [(set_attr "type" "store")
3434    (set_attr "length" "4")])
3436 ;; The definition of this insn does not really explain what it does,
3437 ;; but it should suffice that anything generated as this insn will be
3438 ;; recognized as a movmemsi operation, and that it will not successfully
3439 ;; combine with anything.
3440 (define_expand "movmemsi"
3441   [(parallel [(set (match_operand:BLK 0 "" "")
3442                    (match_operand:BLK 1 "" ""))
3443               (clobber (match_dup 4))
3444               (clobber (match_dup 5))
3445               (clobber (match_dup 6))
3446               (clobber (match_dup 7))
3447               (clobber (match_dup 8))
3448               (use (match_operand:SI 2 "arith_operand" ""))
3449               (use (match_operand:SI 3 "const_int_operand" ""))])]
3450   "!TARGET_64BIT && optimize > 0"
3451   "
3453   int size, align;
3455   /* HP provides very fast block move library routine for the PA;
3456      this routine includes:
3458         4x4 byte at a time block moves,
3459         1x4 byte at a time with alignment checked at runtime with
3460             attempts to align the source and destination as needed
3461         1x1 byte loop
3463      With that in mind, here's the heuristics to try and guess when
3464      the inlined block move will be better than the library block
3465      move:
3467         If the size isn't constant, then always use the library routines.
3469         If the size is large in respect to the known alignment, then use
3470         the library routines.
3472         If the size is small in respect to the known alignment, then open
3473         code the copy (since that will lead to better scheduling).
3475         Else use the block move pattern.   */
3477   /* Undetermined size, use the library routine.  */
3478   if (GET_CODE (operands[2]) != CONST_INT)
3479     FAIL;
3481   size = INTVAL (operands[2]);
3482   align = INTVAL (operands[3]);
3483   align = align > 4 ? 4 : align;
3485   /* If size/alignment is large, then use the library routines.  */
3486   if (size / align > 16)
3487     FAIL;
3489   /* This does happen, but not often enough to worry much about.  */
3490   if (size / align < MOVE_RATIO)
3491     FAIL;
3492   
3493   /* Fall through means we're going to use our block move pattern.  */
3494   operands[0]
3495     = replace_equiv_address (operands[0],
3496                              copy_to_mode_reg (SImode, XEXP (operands[0], 0)));
3497   operands[1]
3498     = replace_equiv_address (operands[1],
3499                              copy_to_mode_reg (SImode, XEXP (operands[1], 0)));
3500   operands[4] = gen_reg_rtx (SImode);
3501   operands[5] = gen_reg_rtx (SImode);
3502   operands[6] = gen_reg_rtx (SImode);
3503   operands[7] = gen_reg_rtx (SImode);
3504   operands[8] = gen_reg_rtx (SImode);
3507 ;; The operand constraints are written like this to support both compile-time
3508 ;; and run-time determined byte counts.  The expander and output_block_move
3509 ;; only support compile-time determined counts at this time.
3511 ;; If the count is run-time determined, the register with the byte count
3512 ;; is clobbered by the copying code, and therefore it is forced to operand 2.
3514 ;; We used to clobber operands 0 and 1.  However, a change to regrename.c
3515 ;; broke this semantic for pseudo registers.  We can't use match_scratch
3516 ;; as this requires two registers in the class R1_REGS when the MEMs for
3517 ;; operands 0 and 1 are both equivalent to symbolic MEMs.  Thus, we are
3518 ;; forced to internally copy operands 0 and 1 to operands 7 and 8,
3519 ;; respectively.  We then split or peephole optimize after reload.
3520 (define_insn "movmemsi_prereload"
3521   [(set (mem:BLK (match_operand:SI 0 "register_operand" "r,r"))
3522         (mem:BLK (match_operand:SI 1 "register_operand" "r,r")))
3523    (clobber (match_operand:SI 2 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3524    (clobber (match_operand:SI 3 "register_operand" "=&r,&r"))   ;item tmp1
3525    (clobber (match_operand:SI 6 "register_operand" "=&r,&r"))   ;item tmp2
3526    (clobber (match_operand:SI 7 "register_operand" "=&r,&r"))   ;item tmp3
3527    (clobber (match_operand:SI 8 "register_operand" "=&r,&r"))   ;item tmp4
3528    (use (match_operand:SI 4 "arith_operand" "J,2"))      ;byte count
3529    (use (match_operand:SI 5 "const_int_operand" "n,n"))] ;alignment
3530   "!TARGET_64BIT"
3531   "#"
3532   [(set_attr "type" "multi,multi")])
3534 (define_split
3535   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3536                    (match_operand:BLK 1 "memory_operand" ""))
3537               (clobber (match_operand:SI 2 "register_operand" ""))
3538               (clobber (match_operand:SI 3 "register_operand" ""))
3539               (clobber (match_operand:SI 6 "register_operand" ""))
3540               (clobber (match_operand:SI 7 "register_operand" ""))
3541               (clobber (match_operand:SI 8 "register_operand" ""))
3542               (use (match_operand:SI 4 "arith_operand" ""))
3543               (use (match_operand:SI 5 "const_int_operand" ""))])]
3544   "!TARGET_64BIT && reload_completed && !flag_peephole2
3545    && GET_CODE (operands[0]) == MEM
3546    && register_operand (XEXP (operands[0], 0), SImode)
3547    && GET_CODE (operands[1]) == MEM
3548    && register_operand (XEXP (operands[1], 0), SImode)"
3549   [(set (match_dup 7) (match_dup 9))
3550    (set (match_dup 8) (match_dup 10))
3551    (parallel [(set (match_dup 0) (match_dup 1))
3552               (clobber (match_dup 2))
3553               (clobber (match_dup 3))
3554               (clobber (match_dup 6))
3555               (clobber (match_dup 7))
3556               (clobber (match_dup 8))
3557               (use (match_dup 4))
3558               (use (match_dup 5))
3559               (const_int 0)])]
3560   "
3562   operands[9] = XEXP (operands[0], 0);
3563   operands[10] = XEXP (operands[1], 0);
3564   operands[0] = replace_equiv_address (operands[0], operands[7]);
3565   operands[1] = replace_equiv_address (operands[1], operands[8]);
3568 (define_peephole2
3569   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3570                    (match_operand:BLK 1 "memory_operand" ""))
3571               (clobber (match_operand:SI 2 "register_operand" ""))
3572               (clobber (match_operand:SI 3 "register_operand" ""))
3573               (clobber (match_operand:SI 6 "register_operand" ""))
3574               (clobber (match_operand:SI 7 "register_operand" ""))
3575               (clobber (match_operand:SI 8 "register_operand" ""))
3576               (use (match_operand:SI 4 "arith_operand" ""))
3577               (use (match_operand:SI 5 "const_int_operand" ""))])]
3578   "!TARGET_64BIT
3579    && GET_CODE (operands[0]) == MEM
3580    && register_operand (XEXP (operands[0], 0), SImode)
3581    && GET_CODE (operands[1]) == MEM
3582    && register_operand (XEXP (operands[1], 0), SImode)"
3583   [(parallel [(set (match_dup 0) (match_dup 1))
3584               (clobber (match_dup 2))
3585               (clobber (match_dup 3))
3586               (clobber (match_dup 6))
3587               (clobber (match_dup 7))
3588               (clobber (match_dup 8))
3589               (use (match_dup 4))
3590               (use (match_dup 5))
3591               (const_int 0)])]
3592   "
3594   rtx addr = XEXP (operands[0], 0);
3595   if (dead_or_set_p (curr_insn, addr))
3596     operands[7] = addr;
3597   else
3598     {
3599       emit_insn (gen_rtx_SET (VOIDmode, operands[7], addr));
3600       operands[0] = replace_equiv_address (operands[0], operands[7]);
3601     }
3603   addr = XEXP (operands[1], 0);
3604   if (dead_or_set_p (curr_insn, addr))
3605     operands[8] = addr;
3606   else
3607     {
3608       emit_insn (gen_rtx_SET (VOIDmode, operands[8], addr));
3609       operands[1] = replace_equiv_address (operands[1], operands[8]);
3610     }
3613 (define_insn "movmemsi_postreload"
3614   [(set (mem:BLK (match_operand:SI 0 "register_operand" "+r,r"))
3615         (mem:BLK (match_operand:SI 1 "register_operand" "+r,r")))
3616    (clobber (match_operand:SI 2 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3617    (clobber (match_operand:SI 3 "register_operand" "=&r,&r"))   ;item tmp1
3618    (clobber (match_operand:SI 6 "register_operand" "=&r,&r"))   ;item tmp2
3619    (clobber (match_dup 0))
3620    (clobber (match_dup 1))
3621    (use (match_operand:SI 4 "arith_operand" "J,2"))      ;byte count
3622    (use (match_operand:SI 5 "const_int_operand" "n,n"))  ;alignment
3623    (const_int 0)]
3624   "!TARGET_64BIT && reload_completed"
3625   "* return output_block_move (operands, !which_alternative);"
3626   [(set_attr "type" "multi,multi")])
3628 (define_expand "movmemdi"
3629   [(parallel [(set (match_operand:BLK 0 "" "")
3630                    (match_operand:BLK 1 "" ""))
3631               (clobber (match_dup 4))
3632               (clobber (match_dup 5))
3633               (clobber (match_dup 6))
3634               (clobber (match_dup 7))
3635               (clobber (match_dup 8))
3636               (use (match_operand:DI 2 "arith_operand" ""))
3637               (use (match_operand:DI 3 "const_int_operand" ""))])]
3638   "TARGET_64BIT && optimize > 0"
3639   "
3641   int size, align;
3643   /* HP provides very fast block move library routine for the PA;
3644      this routine includes:
3646         4x4 byte at a time block moves,
3647         1x4 byte at a time with alignment checked at runtime with
3648             attempts to align the source and destination as needed
3649         1x1 byte loop
3651      With that in mind, here's the heuristics to try and guess when
3652      the inlined block move will be better than the library block
3653      move:
3655         If the size isn't constant, then always use the library routines.
3657         If the size is large in respect to the known alignment, then use
3658         the library routines.
3660         If the size is small in respect to the known alignment, then open
3661         code the copy (since that will lead to better scheduling).
3663         Else use the block move pattern.   */
3665   /* Undetermined size, use the library routine.  */
3666   if (GET_CODE (operands[2]) != CONST_INT)
3667     FAIL;
3669   size = INTVAL (operands[2]);
3670   align = INTVAL (operands[3]);
3671   align = align > 8 ? 8 : align;
3673   /* If size/alignment is large, then use the library routines.  */
3674   if (size / align > 16)
3675     FAIL;
3677   /* This does happen, but not often enough to worry much about.  */
3678   if (size / align < MOVE_RATIO)
3679     FAIL;
3680   
3681   /* Fall through means we're going to use our block move pattern.  */
3682   operands[0]
3683     = replace_equiv_address (operands[0],
3684                              copy_to_mode_reg (DImode, XEXP (operands[0], 0)));
3685   operands[1]
3686     = replace_equiv_address (operands[1],
3687                              copy_to_mode_reg (DImode, XEXP (operands[1], 0)));
3688   operands[4] = gen_reg_rtx (DImode);
3689   operands[5] = gen_reg_rtx (DImode);
3690   operands[6] = gen_reg_rtx (DImode);
3691   operands[7] = gen_reg_rtx (DImode);
3692   operands[8] = gen_reg_rtx (DImode);
3695 ;; The operand constraints are written like this to support both compile-time
3696 ;; and run-time determined byte counts.  The expander and output_block_move
3697 ;; only support compile-time determined counts at this time.
3699 ;; If the count is run-time determined, the register with the byte count
3700 ;; is clobbered by the copying code, and therefore it is forced to operand 2.
3702 ;; We used to clobber operands 0 and 1.  However, a change to regrename.c
3703 ;; broke this semantic for pseudo registers.  We can't use match_scratch
3704 ;; as this requires two registers in the class R1_REGS when the MEMs for
3705 ;; operands 0 and 1 are both equivalent to symbolic MEMs.  Thus, we are
3706 ;; forced to internally copy operands 0 and 1 to operands 7 and 8,
3707 ;; respectively.  We then split or peephole optimize after reload.
3708 (define_insn "movmemdi_prereload"
3709   [(set (mem:BLK (match_operand:DI 0 "register_operand" "r,r"))
3710         (mem:BLK (match_operand:DI 1 "register_operand" "r,r")))
3711    (clobber (match_operand:DI 2 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3712    (clobber (match_operand:DI 3 "register_operand" "=&r,&r"))   ;item tmp1
3713    (clobber (match_operand:DI 6 "register_operand" "=&r,&r"))   ;item tmp2
3714    (clobber (match_operand:DI 7 "register_operand" "=&r,&r"))   ;item tmp3
3715    (clobber (match_operand:DI 8 "register_operand" "=&r,&r"))   ;item tmp4
3716    (use (match_operand:DI 4 "arith_operand" "J,2"))      ;byte count
3717    (use (match_operand:DI 5 "const_int_operand" "n,n"))] ;alignment
3718   "TARGET_64BIT"
3719   "#"
3720   [(set_attr "type" "multi,multi")])
3722 (define_split
3723   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3724                    (match_operand:BLK 1 "memory_operand" ""))
3725               (clobber (match_operand:DI 2 "register_operand" ""))
3726               (clobber (match_operand:DI 3 "register_operand" ""))
3727               (clobber (match_operand:DI 6 "register_operand" ""))
3728               (clobber (match_operand:DI 7 "register_operand" ""))
3729               (clobber (match_operand:DI 8 "register_operand" ""))
3730               (use (match_operand:DI 4 "arith_operand" ""))
3731               (use (match_operand:DI 5 "const_int_operand" ""))])]
3732   "TARGET_64BIT && reload_completed && !flag_peephole2
3733    && GET_CODE (operands[0]) == MEM
3734    && register_operand (XEXP (operands[0], 0), DImode)
3735    && GET_CODE (operands[1]) == MEM
3736    && register_operand (XEXP (operands[1], 0), DImode)"
3737   [(set (match_dup 7) (match_dup 9))
3738    (set (match_dup 8) (match_dup 10))
3739    (parallel [(set (match_dup 0) (match_dup 1))
3740               (clobber (match_dup 2))
3741               (clobber (match_dup 3))
3742               (clobber (match_dup 6))
3743               (clobber (match_dup 7))
3744               (clobber (match_dup 8))
3745               (use (match_dup 4))
3746               (use (match_dup 5))
3747               (const_int 0)])]
3748   "
3750   operands[9] = XEXP (operands[0], 0);
3751   operands[10] = XEXP (operands[1], 0);
3752   operands[0] = replace_equiv_address (operands[0], operands[7]);
3753   operands[1] = replace_equiv_address (operands[1], operands[8]);
3756 (define_peephole2
3757   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3758                    (match_operand:BLK 1 "memory_operand" ""))
3759               (clobber (match_operand:DI 2 "register_operand" ""))
3760               (clobber (match_operand:DI 3 "register_operand" ""))
3761               (clobber (match_operand:DI 6 "register_operand" ""))
3762               (clobber (match_operand:DI 7 "register_operand" ""))
3763               (clobber (match_operand:DI 8 "register_operand" ""))
3764               (use (match_operand:DI 4 "arith_operand" ""))
3765               (use (match_operand:DI 5 "const_int_operand" ""))])]
3766   "TARGET_64BIT
3767    && GET_CODE (operands[0]) == MEM
3768    && register_operand (XEXP (operands[0], 0), DImode)
3769    && GET_CODE (operands[1]) == MEM
3770    && register_operand (XEXP (operands[1], 0), DImode)"
3771   [(parallel [(set (match_dup 0) (match_dup 1))
3772               (clobber (match_dup 2))
3773               (clobber (match_dup 3))
3774               (clobber (match_dup 6))
3775               (clobber (match_dup 7))
3776               (clobber (match_dup 8))
3777               (use (match_dup 4))
3778               (use (match_dup 5))
3779               (const_int 0)])]
3780   "
3782   rtx addr = XEXP (operands[0], 0);
3783   if (dead_or_set_p (curr_insn, addr))
3784     operands[7] = addr;
3785   else
3786     {
3787       emit_insn (gen_rtx_SET (VOIDmode, operands[7], addr));
3788       operands[0] = replace_equiv_address (operands[0], operands[7]);
3789     }
3791   addr = XEXP (operands[1], 0);
3792   if (dead_or_set_p (curr_insn, addr))
3793     operands[8] = addr;
3794   else
3795     {
3796       emit_insn (gen_rtx_SET (VOIDmode, operands[8], addr));
3797       operands[1] = replace_equiv_address (operands[1], operands[8]);
3798     }
3801 (define_insn "movmemdi_postreload"
3802   [(set (mem:BLK (match_operand:DI 0 "register_operand" "+r,r"))
3803         (mem:BLK (match_operand:DI 1 "register_operand" "+r,r")))
3804    (clobber (match_operand:DI 2 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3805    (clobber (match_operand:DI 3 "register_operand" "=&r,&r"))   ;item tmp1
3806    (clobber (match_operand:DI 6 "register_operand" "=&r,&r"))   ;item tmp2
3807    (clobber (match_dup 0))
3808    (clobber (match_dup 1))
3809    (use (match_operand:DI 4 "arith_operand" "J,2"))      ;byte count
3810    (use (match_operand:DI 5 "const_int_operand" "n,n"))  ;alignment
3811    (const_int 0)]
3812   "TARGET_64BIT && reload_completed"
3813   "* return output_block_move (operands, !which_alternative);"
3814   [(set_attr "type" "multi,multi")])
3816 (define_expand "setmemsi"
3817   [(parallel [(set (match_operand:BLK 0 "" "")
3818                    (match_operand 2 "const_int_operand" ""))
3819               (clobber (match_dup 4))
3820               (clobber (match_dup 5))
3821               (use (match_operand:SI 1 "arith_operand" ""))
3822               (use (match_operand:SI 3 "const_int_operand" ""))])]
3823   "!TARGET_64BIT && optimize > 0"
3824   "
3826   int size, align;
3828   /* If value to set is not zero, use the library routine.  */
3829   if (operands[2] != const0_rtx)
3830     FAIL;
3832   /* Undetermined size, use the library routine.  */
3833   if (GET_CODE (operands[1]) != CONST_INT)
3834     FAIL;
3836   size = INTVAL (operands[1]);
3837   align = INTVAL (operands[3]);
3838   align = align > 4 ? 4 : align;
3840   /* If size/alignment is large, then use the library routines.  */
3841   if (size / align > 16)
3842     FAIL;
3844   /* This does happen, but not often enough to worry much about.  */
3845   if (size / align < MOVE_RATIO)
3846     FAIL;
3847   
3848   /* Fall through means we're going to use our block clear pattern.  */
3849   operands[0]
3850     = replace_equiv_address (operands[0],
3851                              copy_to_mode_reg (SImode, XEXP (operands[0], 0)));
3852   operands[4] = gen_reg_rtx (SImode);
3853   operands[5] = gen_reg_rtx (SImode);
3856 (define_insn "clrmemsi_prereload"
3857   [(set (mem:BLK (match_operand:SI 0 "register_operand" "r,r"))
3858         (const_int 0))
3859    (clobber (match_operand:SI 1 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3860    (clobber (match_operand:SI 4 "register_operand" "=&r,&r"))   ;tmp1
3861    (use (match_operand:SI 2 "arith_operand" "J,1"))      ;byte count
3862    (use (match_operand:SI 3 "const_int_operand" "n,n"))] ;alignment
3863   "!TARGET_64BIT"
3864   "#"
3865   [(set_attr "type" "multi,multi")])
3867 (define_split
3868   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3869                    (const_int 0))
3870               (clobber (match_operand:SI 1 "register_operand" ""))
3871               (clobber (match_operand:SI 4 "register_operand" ""))
3872               (use (match_operand:SI 2 "arith_operand" ""))
3873               (use (match_operand:SI 3 "const_int_operand" ""))])]
3874   "!TARGET_64BIT && reload_completed && !flag_peephole2
3875    && GET_CODE (operands[0]) == MEM
3876    && register_operand (XEXP (operands[0], 0), SImode)"
3877   [(set (match_dup 4) (match_dup 5))
3878    (parallel [(set (match_dup 0) (const_int 0))
3879               (clobber (match_dup 1))
3880               (clobber (match_dup 4))
3881               (use (match_dup 2))
3882               (use (match_dup 3))
3883               (const_int 0)])]
3884   "
3886   operands[5] = XEXP (operands[0], 0);
3887   operands[0] = replace_equiv_address (operands[0], operands[4]);
3890 (define_peephole2
3891   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3892                    (const_int 0))
3893               (clobber (match_operand:SI 1 "register_operand" ""))
3894               (clobber (match_operand:SI 4 "register_operand" ""))
3895               (use (match_operand:SI 2 "arith_operand" ""))
3896               (use (match_operand:SI 3 "const_int_operand" ""))])]
3897   "!TARGET_64BIT
3898    && GET_CODE (operands[0]) == MEM
3899    && register_operand (XEXP (operands[0], 0), SImode)"
3900   [(parallel [(set (match_dup 0) (const_int 0))
3901               (clobber (match_dup 1))
3902               (clobber (match_dup 4))
3903               (use (match_dup 2))
3904               (use (match_dup 3))
3905               (const_int 0)])]
3906   "
3908   rtx addr = XEXP (operands[0], 0);
3909   if (dead_or_set_p (curr_insn, addr))
3910     operands[4] = addr;
3911   else
3912     {
3913       emit_insn (gen_rtx_SET (VOIDmode, operands[4], addr));
3914       operands[0] = replace_equiv_address (operands[0], operands[4]);
3915     }
3918 (define_insn "clrmemsi_postreload"
3919   [(set (mem:BLK (match_operand:SI 0 "register_operand" "+r,r"))
3920         (const_int 0))
3921    (clobber (match_operand:SI 1 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3922    (clobber (match_dup 0))
3923    (use (match_operand:SI 2 "arith_operand" "J,1"))      ;byte count
3924    (use (match_operand:SI 3 "const_int_operand" "n,n"))  ;alignment
3925    (const_int 0)]
3926   "!TARGET_64BIT && reload_completed"
3927   "* return output_block_clear (operands, !which_alternative);"
3928   [(set_attr "type" "multi,multi")])
3930 (define_expand "setmemdi"
3931   [(parallel [(set (match_operand:BLK 0 "" "")
3932                    (match_operand 2 "const_int_operand" ""))
3933               (clobber (match_dup 4))
3934               (clobber (match_dup 5))
3935               (use (match_operand:DI 1 "arith_operand" ""))
3936               (use (match_operand:DI 3 "const_int_operand" ""))])]
3937   "TARGET_64BIT && optimize > 0"
3938   "
3940   int size, align;
3942   /* If value to set is not zero, use the library routine.  */
3943   if (operands[2] != const0_rtx)
3944     FAIL;
3946   /* Undetermined size, use the library routine.  */
3947   if (GET_CODE (operands[1]) != CONST_INT)
3948     FAIL;
3950   size = INTVAL (operands[1]);
3951   align = INTVAL (operands[3]);
3952   align = align > 8 ? 8 : align;
3954   /* If size/alignment is large, then use the library routines.  */
3955   if (size / align > 16)
3956     FAIL;
3958   /* This does happen, but not often enough to worry much about.  */
3959   if (size / align < MOVE_RATIO)
3960     FAIL;
3961   
3962   /* Fall through means we're going to use our block clear pattern.  */
3963   operands[0]
3964     = replace_equiv_address (operands[0],
3965                              copy_to_mode_reg (DImode, XEXP (operands[0], 0)));
3966   operands[4] = gen_reg_rtx (DImode);
3967   operands[5] = gen_reg_rtx (DImode);
3970 (define_insn "clrmemdi_prereload"
3971   [(set (mem:BLK (match_operand:DI 0 "register_operand" "r,r"))
3972         (const_int 0))
3973    (clobber (match_operand:DI 1 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3974    (clobber (match_operand:DI 4 "register_operand" "=&r,&r"))   ;item tmp1
3975    (use (match_operand:DI 2 "arith_operand" "J,1"))      ;byte count
3976    (use (match_operand:DI 3 "const_int_operand" "n,n"))] ;alignment
3977   "TARGET_64BIT"
3978   "#"
3979   [(set_attr "type" "multi,multi")])
3981 (define_split
3982   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3983                    (const_int 0))
3984               (clobber (match_operand:DI 1 "register_operand" ""))
3985               (clobber (match_operand:DI 4 "register_operand" ""))
3986               (use (match_operand:DI 2 "arith_operand" ""))
3987               (use (match_operand:DI 3 "const_int_operand" ""))])]
3988   "TARGET_64BIT && reload_completed && !flag_peephole2
3989    && GET_CODE (operands[0]) == MEM
3990    && register_operand (XEXP (operands[0], 0), DImode)"
3991   [(set (match_dup 4) (match_dup 5))
3992    (parallel [(set (match_dup 0) (const_int 0))
3993               (clobber (match_dup 1))
3994               (clobber (match_dup 4))
3995               (use (match_dup 2))
3996               (use (match_dup 3))
3997               (const_int 0)])]
3998   "
4000   operands[5] = XEXP (operands[0], 0);
4001   operands[0] = replace_equiv_address (operands[0], operands[4]);
4004 (define_peephole2
4005   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
4006                    (const_int 0))
4007               (clobber (match_operand:DI 1 "register_operand" ""))
4008               (clobber (match_operand:DI 4 "register_operand" ""))
4009               (use (match_operand:DI 2 "arith_operand" ""))
4010               (use (match_operand:DI 3 "const_int_operand" ""))])]
4011   "TARGET_64BIT
4012    && GET_CODE (operands[0]) == MEM
4013    && register_operand (XEXP (operands[0], 0), DImode)"
4014   [(parallel [(set (match_dup 0) (const_int 0))
4015               (clobber (match_dup 1))
4016               (clobber (match_dup 4))
4017               (use (match_dup 2))
4018               (use (match_dup 3))
4019               (const_int 0)])]
4020   "
4021 {  
4022   rtx addr = XEXP (operands[0], 0);
4023   if (dead_or_set_p (curr_insn, addr))
4024     operands[4] = addr;
4025   else
4026     {
4027       emit_insn (gen_rtx_SET (VOIDmode, operands[4], addr));
4028       operands[0] = replace_equiv_address (operands[0], operands[4]);
4029     }
4032 (define_insn "clrmemdi_postreload"
4033   [(set (mem:BLK (match_operand:DI 0 "register_operand" "+r,r"))
4034         (const_int 0))
4035    (clobber (match_operand:DI 1 "register_operand" "=&r,&r"))   ;loop cnt/tmp
4036    (clobber (match_dup 0))
4037    (use (match_operand:DI 2 "arith_operand" "J,1"))      ;byte count
4038    (use (match_operand:DI 3 "const_int_operand" "n,n"))  ;alignment
4039    (const_int 0)]
4040   "TARGET_64BIT && reload_completed"
4041   "* return output_block_clear (operands, !which_alternative);"
4042   [(set_attr "type" "multi,multi")])
4044 ;; Floating point move insns
4046 ;; This pattern forces (set (reg:DF ...) (const_double ...))
4047 ;; to be reloaded by putting the constant into memory when
4048 ;; reg is a floating point register.
4050 ;; For integer registers we use ldil;ldo to set the appropriate
4051 ;; value.
4053 ;; This must come before the movdf pattern, and it must be present
4054 ;; to handle obscure reloading cases.
4055 (define_insn ""
4056   [(set (match_operand:DF 0 "register_operand" "=?r,f")
4057         (match_operand:DF 1 "" "?F,m"))]
4058   "GET_CODE (operands[1]) == CONST_DOUBLE
4059    && operands[1] != CONST0_RTX (DFmode)
4060    && !TARGET_64BIT
4061    && !TARGET_SOFT_FLOAT"
4062   "* return (which_alternative == 0 ? output_move_double (operands)
4063                                     : \"fldd%F1 %1,%0\");"
4064   [(set_attr "type" "move,fpload")
4065    (set_attr "length" "16,4")])
4067 (define_expand "movdf"
4068   [(set (match_operand:DF 0 "general_operand" "")
4069         (match_operand:DF 1 "general_operand" ""))]
4070   ""
4071   "
4073   if (GET_CODE (operands[1]) == CONST_DOUBLE
4074       && operands[1] != CONST0_RTX (DFmode))
4075     {
4076       /* Reject CONST_DOUBLE loads to all hard registers when
4077          generating 64-bit code and to floating point registers
4078          when generating 32-bit code.  */
4079       if (REG_P (operands[0])
4080           && HARD_REGISTER_P (operands[0])
4081           && (TARGET_64BIT || REGNO (operands[0]) >= 32))
4082         FAIL;
4084       if (TARGET_64BIT)
4085         operands[1] = force_const_mem (DFmode, operands[1]);
4086     }
4088   if (emit_move_sequence (operands, DFmode, 0))
4089     DONE;
4092 ;; Handle DFmode input reloads requiring a general register as a
4093 ;; scratch register.
4094 (define_expand "reload_indf"
4095   [(set (match_operand:DF 0 "register_operand" "=Z")
4096         (match_operand:DF 1 "non_hard_reg_operand" ""))
4097    (clobber (match_operand:DF 2 "register_operand" "=&r"))]
4098   ""
4099   "
4101   if (emit_move_sequence (operands, DFmode, operands[2]))
4102     DONE;
4104   /* We don't want the clobber emitted, so handle this ourselves.  */
4105   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
4106   DONE;
4109 ;; Handle DFmode output reloads requiring a general register as a
4110 ;; scratch register.
4111 (define_expand "reload_outdf" 
4112  [(set (match_operand:DF 0 "non_hard_reg_operand" "")
4113         (match_operand:DF 1  "register_operand" "Z"))
4114    (clobber (match_operand:DF 2 "register_operand" "=&r"))]
4115   ""
4116   "
4118   if (emit_move_sequence (operands, DFmode, operands[2]))
4119     DONE;
4121   /* We don't want the clobber emitted, so handle this ourselves.  */
4122   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
4123   DONE;
4126 (define_insn ""
4127   [(set (match_operand:DF 0 "move_dest_operand"
4128                           "=f,*r,Q,?o,?Q,f,*r,*r,?*r,?f")
4129         (match_operand:DF 1 "reg_or_0_or_nonsymb_mem_operand"
4130                           "fG,*rG,f,*r,*r,RQ,o,RQ,f,*r"))]
4131   "(register_operand (operands[0], DFmode)
4132     || reg_or_0_operand (operands[1], DFmode))
4133    && !(GET_CODE (operands[1]) == CONST_DOUBLE
4134         && GET_CODE (operands[0]) == MEM)
4135    && !TARGET_64BIT
4136    && !TARGET_SOFT_FLOAT"
4137   "*
4139   if ((FP_REG_P (operands[0]) || FP_REG_P (operands[1])
4140        || operands[1] == CONST0_RTX (DFmode))
4141       && !(REG_P (operands[0]) && REG_P (operands[1])
4142            && FP_REG_P (operands[0]) ^ FP_REG_P (operands[1])))
4143     return output_fp_move_double (operands);
4144   return output_move_double (operands);
4146   [(set_attr "type" "fpalu,move,fpstore,store,store,fpload,load,load,fpstore_load,store_fpload")
4147    (set_attr "length" "4,8,4,8,16,4,8,16,12,12")])
4149 (define_insn ""
4150   [(set (match_operand:DF 0 "indexed_memory_operand" "=R")
4151         (match_operand:DF 1 "reg_or_0_operand" "f"))]
4152   "!TARGET_SOFT_FLOAT
4153    && !TARGET_DISABLE_INDEXING
4154    && reload_completed"
4155   "fstd%F0 %1,%0"
4156   [(set_attr "type" "fpstore")
4157    (set_attr "pa_combine_type" "addmove")
4158    (set_attr "length" "4")])
4160 (define_peephole2
4161   [(set (match_operand:SI 0 "register_operand" "")
4162         (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "")
4163                           (const_int 8))
4164                  (match_operand:SI 2 "register_operand" "")))
4165    (set (mem:DF (match_dup 0))
4166         (match_operand:DF 3 "register_operand" ""))]
4167   "!TARGET_SOFT_FLOAT
4168    && !TARGET_DISABLE_INDEXING
4169    && REG_OK_FOR_BASE_P (operands[2])
4170    && FP_REGNO_P (REGNO (operands[3]))"
4171   [(set (mem:DF (plus:SI (mult:SI (match_dup 1) (const_int 8)) (match_dup 2)))
4172         (match_dup 3))
4173    (set (match_dup 0) (plus:SI (mult:SI (match_dup 1) (const_int 8))
4174                                (match_dup 2)))]
4175   "")
4177 (define_peephole2
4178   [(set (match_operand:SI 0 "register_operand" "")
4179         (plus:SI (match_operand:SI 2 "register_operand" "")
4180                  (mult:SI (match_operand:SI 1 "register_operand" "")
4181                           (const_int 8))))
4182    (set (mem:DF (match_dup 0))
4183         (match_operand:DF 3 "register_operand" ""))]
4184   "!TARGET_SOFT_FLOAT
4185    && !TARGET_DISABLE_INDEXING
4186    && REG_OK_FOR_BASE_P (operands[2])
4187    && FP_REGNO_P (REGNO (operands[3]))"
4188   [(set (mem:DF (plus:SI (mult:SI (match_dup 1) (const_int 8)) (match_dup 2)))
4189         (match_dup 3))
4190    (set (match_dup 0) (plus:SI (mult:SI (match_dup 1) (const_int 8))
4191                                (match_dup 2)))]
4192   "")
4194 (define_peephole2
4195   [(set (match_operand:DI 0 "register_operand" "")
4196         (plus:DI (mult:DI (match_operand:DI 1 "register_operand" "")
4197                           (const_int 8))
4198                  (match_operand:DI 2 "register_operand" "")))
4199    (set (mem:DF (match_dup 0))
4200         (match_operand:DF 3 "register_operand" ""))]
4201   "!TARGET_SOFT_FLOAT
4202    && !TARGET_DISABLE_INDEXING
4203    && TARGET_64BIT
4204    && REG_OK_FOR_BASE_P (operands[2])
4205    && FP_REGNO_P (REGNO (operands[3]))"
4206   [(set (mem:DF (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
4207         (match_dup 3))
4208    (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 8))
4209                                (match_dup 2)))]
4210   "")
4212 (define_peephole2
4213   [(set (match_operand:DI 0 "register_operand" "")
4214         (plus:DI (match_operand:DI 2 "register_operand" "")
4215                  (mult:DI (match_operand:DI 1 "register_operand" "")
4216                           (const_int 8))))
4217    (set (mem:DF (match_dup 0))
4218         (match_operand:DF 3 "register_operand" ""))]
4219   "!TARGET_SOFT_FLOAT
4220    && !TARGET_DISABLE_INDEXING
4221    && TARGET_64BIT
4222    && REG_OK_FOR_BASE_P (operands[2])
4223    && FP_REGNO_P (REGNO (operands[3]))"
4224   [(set (mem:DF (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
4225         (match_dup 3))
4226    (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 8))
4227                                (match_dup 2)))]
4228   "")
4230 (define_peephole2
4231   [(set (match_operand:SI 0 "register_operand" "")
4232         (plus:SI (match_operand:SI 1 "register_operand" "")
4233                  (match_operand:SI 2 "register_operand" "")))
4234    (set (mem:DF (match_dup 0))
4235         (match_operand:DF 3 "register_operand" ""))]
4236   "!TARGET_SOFT_FLOAT
4237    && !TARGET_DISABLE_INDEXING
4238    && TARGET_NO_SPACE_REGS
4239    && REG_OK_FOR_INDEX_P (operands[1])
4240    && REG_OK_FOR_BASE_P (operands[2])
4241    && FP_REGNO_P (REGNO (operands[3]))"
4242   [(set (mem:DF (plus:SI (match_dup 1) (match_dup 2)))
4243         (match_dup 3))
4244    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
4245   "")
4247 (define_peephole2
4248   [(set (match_operand:SI 0 "register_operand" "")
4249         (plus:SI (match_operand:SI 1 "register_operand" "")
4250                  (match_operand:SI 2 "register_operand" "")))
4251    (set (mem:DF (match_dup 0))
4252         (match_operand:DF 3 "register_operand" ""))]
4253   "!TARGET_SOFT_FLOAT
4254    && !TARGET_DISABLE_INDEXING
4255    && TARGET_NO_SPACE_REGS
4256    && REG_OK_FOR_BASE_P (operands[1])
4257    && REG_OK_FOR_INDEX_P (operands[2])
4258    && FP_REGNO_P (REGNO (operands[3]))"
4259   [(set (mem:DF (plus:SI (match_dup 2) (match_dup 1)))
4260         (match_dup 3))
4261    (set (match_dup 0) (plus:SI (match_dup 2) (match_dup 1)))]
4262   "")
4264 (define_peephole2
4265   [(set (match_operand:DI 0 "register_operand" "")
4266         (plus:DI (match_operand:DI 1 "register_operand" "")
4267                  (match_operand:DI 2 "register_operand" "")))
4268    (set (mem:DF (match_dup 0))
4269         (match_operand:DF 3 "register_operand" ""))]
4270   "!TARGET_SOFT_FLOAT
4271    && !TARGET_DISABLE_INDEXING
4272    && TARGET_64BIT
4273    && TARGET_NO_SPACE_REGS
4274    && REG_OK_FOR_INDEX_P (operands[1])
4275    && REG_OK_FOR_BASE_P (operands[2])
4276    && FP_REGNO_P (REGNO (operands[3]))"
4277   [(set (mem:DF (plus:DI (match_dup 1) (match_dup 2)))
4278         (match_dup 3))
4279    (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
4280   "")
4282 (define_peephole2
4283   [(set (match_operand:DI 0 "register_operand" "")
4284         (plus:DI (match_operand:DI 1 "register_operand" "")
4285                  (match_operand:DI 2 "register_operand" "")))
4286    (set (mem:DF (match_dup 0))
4287         (match_operand:DF 3 "register_operand" ""))]
4288   "!TARGET_SOFT_FLOAT
4289    && !TARGET_DISABLE_INDEXING
4290    && TARGET_64BIT
4291    && TARGET_NO_SPACE_REGS
4292    && REG_OK_FOR_BASE_P (operands[1])
4293    && REG_OK_FOR_INDEX_P (operands[2])
4294    && FP_REGNO_P (REGNO (operands[3]))"
4295   [(set (mem:DF (plus:DI (match_dup 2) (match_dup 1)))
4296         (match_dup 3))
4297    (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
4298   "")
4300 (define_insn ""
4301   [(set (match_operand:DF 0 "move_dest_operand"
4302                           "=r,?o,?Q,r,r")
4303         (match_operand:DF 1 "reg_or_0_or_nonsymb_mem_operand"
4304                           "rG,r,r,o,RQ"))]
4305   "(register_operand (operands[0], DFmode)
4306     || reg_or_0_operand (operands[1], DFmode))
4307    && !TARGET_64BIT
4308    && TARGET_SOFT_FLOAT"
4309   "*
4311   return output_move_double (operands);
4313   [(set_attr "type" "move,store,store,load,load")
4314    (set_attr "length" "8,8,16,8,16")])
4316 (define_insn ""
4317   [(set (match_operand:DF 0 "move_dest_operand"
4318                           "=!*r,*r,*r,*r,*r,Q,f,f,T")
4319         (match_operand:DF 1 "move_src_operand"
4320                           "!*r,J,N,K,RQ,*rG,fG,RT,f"))]
4321   "(register_operand (operands[0], DFmode)
4322     || reg_or_0_operand (operands[1], DFmode))
4323    && !TARGET_SOFT_FLOAT && TARGET_64BIT"
4324   "@
4325    copy %1,%0
4326    ldi %1,%0
4327    ldil L'%1,%0
4328    depdi,z %z1,%0
4329    ldd%M1 %1,%0
4330    std%M0 %r1,%0
4331    fcpy,dbl %f1,%0
4332    fldd%F1 %1,%0
4333    fstd%F0 %1,%0"
4334   [(set_attr "type" "move,move,move,shift,load,store,fpalu,fpload,fpstore")
4335    (set_attr "pa_combine_type" "addmove")
4336    (set_attr "length" "4,4,4,4,4,4,4,4,4")])
4339 (define_expand "movdi"
4340   [(set (match_operand:DI 0 "general_operand" "")
4341         (match_operand:DI 1 "general_operand" ""))]
4342   ""
4343   "
4345   /* Except for zero, we don't support loading a CONST_INT directly
4346      to a hard floating-point register since a scratch register is
4347      needed for the operation.  While the operation could be handled
4348      before register allocation, the simplest solution is to fail.  */
4349   if (TARGET_64BIT
4350       && GET_CODE (operands[1]) == CONST_INT
4351       && operands[1] != CONST0_RTX (DImode)
4352       && REG_P (operands[0])
4353       && HARD_REGISTER_P (operands[0])
4354       && REGNO (operands[0]) >= 32)
4355     FAIL;
4357   if (emit_move_sequence (operands, DImode, 0))
4358     DONE;
4361 ;; Handle DImode input reloads requiring %r1 as a scratch register.
4362 (define_expand "reload_indi_r1"
4363   [(set (match_operand:DI 0 "register_operand" "=Z")
4364         (match_operand:DI 1 "non_hard_reg_operand" ""))
4365    (clobber (match_operand:SI 2 "register_operand" "=&a"))]
4366   ""
4367   "
4369   if (emit_move_sequence (operands, DImode, operands[2]))
4370     DONE;
4372   /* We don't want the clobber emitted, so handle this ourselves.  */
4373   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
4374   DONE;
4377 ;; Handle DImode input reloads requiring a general register as a
4378 ;; scratch register.
4379 (define_expand "reload_indi"
4380   [(set (match_operand:DI 0 "register_operand" "=Z")
4381         (match_operand:DI 1 "non_hard_reg_operand" ""))
4382    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
4383   ""
4384   "
4386   if (emit_move_sequence (operands, DImode, operands[2]))
4387     DONE;
4389   /* We don't want the clobber emitted, so handle this ourselves.  */
4390   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
4391   DONE;
4394 ;; Handle DImode output reloads requiring a general register as a
4395 ;; scratch register.
4396 (define_expand "reload_outdi"
4397   [(set (match_operand:DI 0 "non_hard_reg_operand" "")
4398         (match_operand:DI 1 "register_operand" "Z"))
4399    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
4400   ""
4401   "
4403   if (emit_move_sequence (operands, DImode, operands[2]))
4404     DONE;
4406   /* We don't want the clobber emitted, so handle this ourselves.  */
4407   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
4408   DONE;
4411 (define_insn ""
4412   [(set (match_operand:DI 0 "register_operand" "=r")
4413         (high:DI (match_operand 1 "" "")))]
4414   "!TARGET_64BIT"
4415   "*
4417   rtx op0 = operands[0];
4418   rtx op1 = operands[1];
4420   switch (GET_CODE (op1))
4421     {
4422     case CONST_INT:
4423 #if HOST_BITS_PER_WIDE_INT <= 32
4424       operands[0] = operand_subword (op0, 1, 0, DImode);
4425       output_asm_insn (\"ldil L'%1,%0\", operands);
4427       operands[0] = operand_subword (op0, 0, 0, DImode);
4428       if (INTVAL (op1) < 0)
4429         output_asm_insn (\"ldi -1,%0\", operands);
4430       else
4431         output_asm_insn (\"ldi 0,%0\", operands);
4432 #else
4433       operands[0] = operand_subword (op0, 1, 0, DImode);
4434       operands[1] = GEN_INT (INTVAL (op1) & 0xffffffff);
4435       output_asm_insn (\"ldil L'%1,%0\", operands);
4437       operands[0] = operand_subword (op0, 0, 0, DImode);
4438       operands[1] = GEN_INT (INTVAL (op1) >> 32);
4439       output_asm_insn (singlemove_string (operands), operands);
4440 #endif
4441       break;
4443     case CONST_DOUBLE:
4444       operands[0] = operand_subword (op0, 1, 0, DImode);
4445       operands[1] = GEN_INT (CONST_DOUBLE_LOW (op1));
4446       output_asm_insn (\"ldil L'%1,%0\", operands);
4448       operands[0] = operand_subword (op0, 0, 0, DImode);
4449       operands[1] = GEN_INT (CONST_DOUBLE_HIGH (op1));
4450       output_asm_insn (singlemove_string (operands), operands);
4451       break;
4453     default:
4454       gcc_unreachable ();
4455     }
4456   return \"\";
4458   [(set_attr "type" "move")
4459    (set_attr "length" "12")])
4461 (define_insn ""
4462   [(set (match_operand:DI 0 "move_dest_operand"
4463                           "=r,o,Q,r,r,r,*f,*f,T,?r,?*f")
4464         (match_operand:DI 1 "general_operand"
4465                           "rM,r,r,o*R,Q,i,*fM,RT,*f,*f,r"))]
4466   "(register_operand (operands[0], DImode)
4467     || reg_or_0_operand (operands[1], DImode))
4468    && !TARGET_64BIT
4469    && !TARGET_SOFT_FLOAT"
4470   "*
4472   if ((FP_REG_P (operands[0]) || FP_REG_P (operands[1])
4473        || operands[1] == CONST0_RTX (DFmode))
4474       && !(REG_P (operands[0]) && REG_P (operands[1])
4475            && FP_REG_P (operands[0]) ^ FP_REG_P (operands[1])))
4476     return output_fp_move_double (operands);
4477   return output_move_double (operands);
4479   [(set_attr "type"
4480     "move,store,store,load,load,multi,fpalu,fpload,fpstore,fpstore_load,store_fpload")
4481    (set_attr "length" "8,8,16,8,16,16,4,4,4,12,12")])
4483 (define_insn ""
4484   [(set (match_operand:DI 0 "move_dest_operand"
4485                           "=r,r,r,r,r,r,Q,!*q,!r,!*f,*f,T")
4486         (match_operand:DI 1 "move_src_operand"
4487                           "A,r,J,N,K,RQ,rM,!rM,!*q,!*fM,RT,*f"))]
4488   "(register_operand (operands[0], DImode)
4489     || reg_or_0_operand (operands[1], DImode))
4490    && !TARGET_SOFT_FLOAT && TARGET_64BIT"
4491   "@
4492    ldd RT'%A1,%0
4493    copy %1,%0
4494    ldi %1,%0
4495    ldil L'%1,%0
4496    depdi,z %z1,%0
4497    ldd%M1 %1,%0
4498    std%M0 %r1,%0
4499    mtsar %r1
4500    {mfctl|mfctl,w} %%sar,%0
4501    fcpy,dbl %f1,%0
4502    fldd%F1 %1,%0
4503    fstd%F0 %1,%0"
4504   [(set_attr "type" "load,move,move,move,shift,load,store,move,move,fpalu,fpload,fpstore")
4505    (set_attr "pa_combine_type" "addmove")
4506    (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4")])
4508 (define_insn ""
4509   [(set (match_operand:DI 0 "indexed_memory_operand" "=R")
4510         (match_operand:DI 1 "register_operand" "f"))]
4511   "!TARGET_SOFT_FLOAT
4512    && TARGET_64BIT
4513    && !TARGET_DISABLE_INDEXING
4514    && reload_completed"
4515   "fstd%F0 %1,%0"
4516   [(set_attr "type" "fpstore")
4517    (set_attr "pa_combine_type" "addmove")
4518    (set_attr "length" "4")])
4520 (define_peephole2
4521   [(set (match_operand:DI 0 "register_operand" "")
4522         (plus:DI (mult:DI (match_operand:DI 1 "register_operand" "")
4523                           (const_int 8))
4524                  (match_operand:DI 2 "register_operand" "")))
4525    (set (mem:DI (match_dup 0))
4526         (match_operand:DI 3 "register_operand" ""))]
4527   "!TARGET_SOFT_FLOAT
4528    && !TARGET_DISABLE_INDEXING
4529    && TARGET_64BIT
4530    && REG_OK_FOR_BASE_P (operands[2])
4531    && FP_REGNO_P (REGNO (operands[3]))"
4532   [(set (mem:DI (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
4533         (match_dup 3))
4534    (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 8))
4535                                (match_dup 2)))]
4536   "")
4538 (define_peephole2
4539   [(set (match_operand:DI 0 "register_operand" "")
4540         (plus:DI (match_operand:DI 2 "register_operand" "")
4541                  (mult:DI (match_operand:DI 1 "register_operand" "")
4542                           (const_int 8))))
4543    (set (mem:DI (match_dup 0))
4544         (match_operand:DI 3 "register_operand" ""))]
4545   "!TARGET_SOFT_FLOAT
4546    && !TARGET_DISABLE_INDEXING
4547    && TARGET_64BIT
4548    && REG_OK_FOR_BASE_P (operands[2])
4549    && FP_REGNO_P (REGNO (operands[3]))"
4550   [(set (mem:DI (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
4551         (match_dup 3))
4552    (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 8))
4553                                (match_dup 2)))]
4554   "")
4556 (define_peephole2
4557   [(set (match_operand:DI 0 "register_operand" "")
4558         (plus:DI (match_operand:DI 1 "register_operand" "")
4559                  (match_operand:DI 2 "register_operand" "")))
4560    (set (mem:DI (match_dup 0))
4561         (match_operand:DI 3 "register_operand" ""))]
4562   "!TARGET_SOFT_FLOAT
4563    && !TARGET_DISABLE_INDEXING
4564    && TARGET_64BIT
4565    && TARGET_NO_SPACE_REGS
4566    && REG_OK_FOR_INDEX_P (operands[1])
4567    && REG_OK_FOR_BASE_P (operands[2])
4568    && FP_REGNO_P (REGNO (operands[3]))"
4569   [(set (mem:DI (plus:DI (match_dup 1) (match_dup 2)))
4570         (match_dup 3))
4571    (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
4572   "")
4574 (define_peephole2
4575   [(set (match_operand:DI 0 "register_operand" "")
4576         (plus:DI (match_operand:DI 1 "register_operand" "")
4577                  (match_operand:DI 2 "register_operand" "")))
4578    (set (mem:DI (match_dup 0))
4579         (match_operand:DI 3 "register_operand" ""))]
4580   "!TARGET_SOFT_FLOAT
4581    && !TARGET_DISABLE_INDEXING
4582    && TARGET_64BIT
4583    && TARGET_NO_SPACE_REGS
4584    && REG_OK_FOR_BASE_P (operands[1])
4585    && REG_OK_FOR_INDEX_P (operands[2])
4586    && FP_REGNO_P (REGNO (operands[3]))"
4587   [(set (mem:DI (plus:DI (match_dup 2) (match_dup 1)))
4588         (match_dup 3))
4589    (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
4590   "")
4592 (define_insn ""
4593   [(set (match_operand:DI 0 "move_dest_operand"
4594                           "=r,o,Q,r,r,r")
4595         (match_operand:DI 1 "general_operand"
4596                           "rM,r,r,o,Q,i"))]
4597   "(register_operand (operands[0], DImode)
4598     || reg_or_0_operand (operands[1], DImode))
4599    && !TARGET_64BIT
4600    && TARGET_SOFT_FLOAT"
4601   "*
4603   return output_move_double (operands);
4605   [(set_attr "type" "move,store,store,load,load,multi")
4606    (set_attr "length" "8,8,16,8,16,16")])
4608 (define_insn ""
4609   [(set (match_operand:DI 0 "register_operand" "=r,&r")
4610         (lo_sum:DI (match_operand:DI 1 "register_operand" "0,r")
4611                    (match_operand:DI 2 "immediate_operand" "i,i")))]
4612   "!TARGET_64BIT"
4613   "*
4615   /* Don't output a 64-bit constant, since we can't trust the assembler to
4616      handle it correctly.  */
4617   if (GET_CODE (operands[2]) == CONST_DOUBLE)
4618     operands[2] = GEN_INT (CONST_DOUBLE_LOW (operands[2]));
4619   else if (HOST_BITS_PER_WIDE_INT > 32
4620            && GET_CODE (operands[2]) == CONST_INT)
4621     operands[2] = GEN_INT (INTVAL (operands[2]) & 0xffffffff);
4622   if (which_alternative == 1)
4623     output_asm_insn (\"copy %1,%0\", operands);
4624   return \"ldo R'%G2(%R1),%R0\";
4626   [(set_attr "type" "move,move")
4627    (set_attr "length" "4,8")])
4629 ;; This pattern forces (set (reg:SF ...) (const_double ...))
4630 ;; to be reloaded by putting the constant into memory when
4631 ;; reg is a floating point register.
4633 ;; For integer registers we use ldil;ldo to set the appropriate
4634 ;; value.
4636 ;; This must come before the movsf pattern, and it must be present
4637 ;; to handle obscure reloading cases.
4638 (define_insn ""
4639   [(set (match_operand:SF 0 "register_operand" "=?r,f")
4640         (match_operand:SF 1 "" "?F,m"))]
4641   "GET_CODE (operands[1]) == CONST_DOUBLE
4642    && operands[1] != CONST0_RTX (SFmode)
4643    && ! TARGET_SOFT_FLOAT"
4644   "* return (which_alternative == 0 ? singlemove_string (operands)
4645                                     : \" fldw%F1 %1,%0\");"
4646   [(set_attr "type" "move,fpload")
4647    (set_attr "length" "8,4")])
4649 (define_expand "movsf"
4650   [(set (match_operand:SF 0 "general_operand" "")
4651         (match_operand:SF 1 "general_operand" ""))]
4652   ""
4653   "
4655   /* Reject CONST_DOUBLE loads to floating point registers.  */
4656   if (GET_CODE (operands[1]) == CONST_DOUBLE
4657       && operands[1] != CONST0_RTX (SFmode)
4658       && REG_P (operands[0])
4659       && HARD_REGISTER_P (operands[0])
4660       && REGNO (operands[0]) >= 32)
4661     FAIL;
4663   if (emit_move_sequence (operands, SFmode, 0))
4664     DONE;
4667 ;; Handle SFmode input reloads requiring a general register as a
4668 ;; scratch register.
4669 (define_expand "reload_insf"
4670   [(set (match_operand:SF 0 "register_operand" "=Z")
4671         (match_operand:SF 1 "non_hard_reg_operand" ""))
4672    (clobber (match_operand:SF 2 "register_operand" "=&r"))]
4673   ""
4674   "
4676   if (emit_move_sequence (operands, SFmode, operands[2]))
4677     DONE;
4679   /* We don't want the clobber emitted, so handle this ourselves.  */
4680   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
4681   DONE;
4684 ;; Handle SFmode output reloads requiring a general register as a
4685 ;; scratch register.
4686 (define_expand "reload_outsf"
4687   [(set (match_operand:SF 0 "non_hard_reg_operand" "")
4688         (match_operand:SF 1  "register_operand" "Z"))
4689    (clobber (match_operand:SF 2 "register_operand" "=&r"))]
4690   ""
4691   "
4693   if (emit_move_sequence (operands, SFmode, operands[2]))
4694     DONE;
4696   /* We don't want the clobber emitted, so handle this ourselves.  */
4697   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
4698   DONE;
4701 (define_insn ""
4702   [(set (match_operand:SF 0 "move_dest_operand"
4703                           "=f,!*r,f,*r,Q,Q,?*r,?f")
4704         (match_operand:SF 1 "reg_or_0_or_nonsymb_mem_operand"
4705                           "fG,!*rG,RQ,RQ,f,*rG,f,*r"))]
4706   "(register_operand (operands[0], SFmode)
4707     || reg_or_0_operand (operands[1], SFmode))
4708    && !TARGET_SOFT_FLOAT
4709    && !TARGET_64BIT"
4710   "@
4711    fcpy,sgl %f1,%0
4712    copy %r1,%0
4713    fldw%F1 %1,%0
4714    ldw%M1 %1,%0
4715    fstw%F0 %1,%0
4716    stw%M0 %r1,%0
4717    {fstws|fstw} %1,-16(%%sp)\n\t{ldws|ldw} -16(%%sp),%0
4718    {stws|stw} %1,-16(%%sp)\n\t{fldws|fldw} -16(%%sp),%0"
4719   [(set_attr "type" "fpalu,move,fpload,load,fpstore,store,fpstore_load,store_fpload")
4720    (set_attr "pa_combine_type" "addmove")
4721    (set_attr "length" "4,4,4,4,4,4,8,8")])
4723 (define_insn ""
4724   [(set (match_operand:SF 0 "move_dest_operand"
4725                           "=f,!*r,f,*r,Q,Q")
4726         (match_operand:SF 1 "reg_or_0_or_nonsymb_mem_operand"
4727                           "fG,!*rG,RQ,RQ,f,*rG"))]
4728   "(register_operand (operands[0], SFmode)
4729     || reg_or_0_operand (operands[1], SFmode))
4730    && !TARGET_SOFT_FLOAT
4731    && TARGET_64BIT"
4732   "@
4733    fcpy,sgl %f1,%0
4734    copy %r1,%0
4735    fldw%F1 %1,%0
4736    ldw%M1 %1,%0
4737    fstw%F0 %1,%0
4738    stw%M0 %r1,%0"
4739   [(set_attr "type" "fpalu,move,fpload,load,fpstore,store")
4740    (set_attr "pa_combine_type" "addmove")
4741    (set_attr "length" "4,4,4,4,4,4")])
4743 (define_insn ""
4744   [(set (match_operand:SF 0 "indexed_memory_operand" "=R")
4745         (match_operand:SF 1 "register_operand" "f"))]
4746   "!TARGET_SOFT_FLOAT
4747    && !TARGET_DISABLE_INDEXING
4748    && reload_completed"
4749   "fstw%F0 %1,%0"
4750   [(set_attr "type" "fpstore")
4751    (set_attr "pa_combine_type" "addmove")
4752    (set_attr "length" "4")])
4754 (define_peephole2
4755   [(set (match_operand:SI 0 "register_operand" "")
4756         (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "")
4757                           (const_int 4))
4758                  (match_operand:SI 2 "register_operand" "")))
4759    (set (mem:SF (match_dup 0))
4760         (match_operand:SF 3 "register_operand" ""))]
4761   "!TARGET_SOFT_FLOAT
4762    && !TARGET_DISABLE_INDEXING
4763    && REG_OK_FOR_BASE_P (operands[2])
4764    && FP_REGNO_P (REGNO (operands[3]))"
4765   [(set (mem:SF (plus:SI (mult:SI (match_dup 1) (const_int 4)) (match_dup 2)))
4766         (match_dup 3))
4767    (set (match_dup 0) (plus:SI (mult:SI (match_dup 1) (const_int 4))
4768                                (match_dup 2)))]
4769   "")
4771 (define_peephole2
4772   [(set (match_operand:SI 0 "register_operand" "")
4773         (plus:SI (match_operand:SI 2 "register_operand" "")
4774                  (mult:SI (match_operand:SI 1 "register_operand" "")
4775                           (const_int 4))))
4776    (set (mem:SF (match_dup 0))
4777         (match_operand:SF 3 "register_operand" ""))]
4778   "!TARGET_SOFT_FLOAT
4779    && !TARGET_DISABLE_INDEXING
4780    && REG_OK_FOR_BASE_P (operands[2])
4781    && FP_REGNO_P (REGNO (operands[3]))"
4782   [(set (mem:SF (plus:SI (mult:SI (match_dup 1) (const_int 4)) (match_dup 2)))
4783         (match_dup 3))
4784    (set (match_dup 0) (plus:SI (mult:SI (match_dup 1) (const_int 4))
4785                                (match_dup 2)))]
4786   "")
4788 (define_peephole2
4789   [(set (match_operand:DI 0 "register_operand" "")
4790         (plus:DI (mult:DI (match_operand:DI 1 "register_operand" "")
4791                           (const_int 4))
4792                  (match_operand:DI 2 "register_operand" "")))
4793    (set (mem:SF (match_dup 0))
4794         (match_operand:SF 3 "register_operand" ""))]
4795   "!TARGET_SOFT_FLOAT
4796    && !TARGET_DISABLE_INDEXING
4797    && TARGET_64BIT
4798    && REG_OK_FOR_BASE_P (operands[2])
4799    && FP_REGNO_P (REGNO (operands[3]))"
4800   [(set (mem:SF (plus:DI (mult:DI (match_dup 1) (const_int 4)) (match_dup 2)))
4801         (match_dup 3))
4802    (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 4))
4803                                (match_dup 2)))]
4804   "")
4806 (define_peephole2
4807   [(set (match_operand:DI 0 "register_operand" "")
4808         (plus:DI (match_operand:DI 2 "register_operand" "")
4809                  (mult:DI (match_operand:DI 1 "register_operand" "")
4810                           (const_int 4))))
4811    (set (mem:SF (match_dup 0))
4812         (match_operand:SF 3 "register_operand" ""))]
4813   "!TARGET_SOFT_FLOAT
4814    && !TARGET_DISABLE_INDEXING
4815    && TARGET_64BIT
4816    && REG_OK_FOR_BASE_P (operands[2])
4817    && FP_REGNO_P (REGNO (operands[3]))"
4818   [(set (mem:SF (plus:DI (mult:DI (match_dup 1) (const_int 4)) (match_dup 2)))
4819         (match_dup 3))
4820    (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 4))
4821                                (match_dup 2)))]
4822   "")
4824 (define_peephole2
4825   [(set (match_operand:SI 0 "register_operand" "")
4826         (plus:SI (match_operand:SI 1 "register_operand" "")
4827                  (match_operand:SI 2 "register_operand" "")))
4828    (set (mem:SF (match_dup 0))
4829         (match_operand:SF 3 "register_operand" ""))]
4830   "!TARGET_SOFT_FLOAT
4831    && !TARGET_DISABLE_INDEXING
4832    && TARGET_NO_SPACE_REGS
4833    && REG_OK_FOR_INDEX_P (operands[1])
4834    && REG_OK_FOR_BASE_P (operands[2])
4835    && FP_REGNO_P (REGNO (operands[3]))"
4836   [(set (mem:SF (plus:SI (match_dup 1) (match_dup 2)))
4837         (match_dup 3))
4838    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
4839   "")
4841 (define_peephole2
4842   [(set (match_operand:SI 0 "register_operand" "")
4843         (plus:SI (match_operand:SI 1 "register_operand" "")
4844                  (match_operand:SI 2 "register_operand" "")))
4845    (set (mem:SF (match_dup 0))
4846         (match_operand:SF 3 "register_operand" ""))]
4847   "!TARGET_SOFT_FLOAT
4848    && !TARGET_DISABLE_INDEXING
4849    && TARGET_NO_SPACE_REGS
4850    && REG_OK_FOR_BASE_P (operands[1])
4851    && REG_OK_FOR_INDEX_P (operands[2])
4852    && FP_REGNO_P (REGNO (operands[3]))"
4853   [(set (mem:SF (plus:SI (match_dup 2) (match_dup 1)))
4854         (match_dup 3))
4855    (set (match_dup 0) (plus:SI (match_dup 2) (match_dup 1)))]
4856   "")
4858 (define_peephole2
4859   [(set (match_operand:DI 0 "register_operand" "")
4860         (plus:DI (match_operand:DI 1 "register_operand" "")
4861                  (match_operand:DI 2 "register_operand" "")))
4862    (set (mem:SF (match_dup 0))
4863         (match_operand:SF 3 "register_operand" ""))]
4864   "!TARGET_SOFT_FLOAT
4865    && !TARGET_DISABLE_INDEXING
4866    && TARGET_64BIT
4867    && TARGET_NO_SPACE_REGS
4868    && REG_OK_FOR_INDEX_P (operands[1])
4869    && REG_OK_FOR_BASE_P (operands[2])
4870    && FP_REGNO_P (REGNO (operands[3]))"
4871   [(set (mem:SF (plus:DI (match_dup 1) (match_dup 2)))
4872         (match_dup 3))
4873    (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
4874   "")
4876 (define_peephole2
4877   [(set (match_operand:DI 0 "register_operand" "")
4878         (plus:DI (match_operand:DI 1 "register_operand" "")
4879                  (match_operand:DI 2 "register_operand" "")))
4880    (set (mem:SF (match_dup 0))
4881         (match_operand:SF 3 "register_operand" ""))]
4882   "!TARGET_SOFT_FLOAT
4883    && !TARGET_DISABLE_INDEXING
4884    && TARGET_64BIT
4885    && TARGET_NO_SPACE_REGS
4886    && REG_OK_FOR_BASE_P (operands[1])
4887    && REG_OK_FOR_INDEX_P (operands[2])
4888    && FP_REGNO_P (REGNO (operands[3]))"
4889   [(set (mem:SF (plus:DI (match_dup 2) (match_dup 1)))
4890         (match_dup 3))
4891    (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
4892   "")
4894 (define_insn ""
4895   [(set (match_operand:SF 0 "move_dest_operand"
4896                           "=r,r,Q")
4897         (match_operand:SF 1 "reg_or_0_or_nonsymb_mem_operand"
4898                           "rG,RQ,rG"))]
4899   "(register_operand (operands[0], SFmode)
4900     || reg_or_0_operand (operands[1], SFmode))
4901    && TARGET_SOFT_FLOAT"
4902   "@
4903    copy %r1,%0
4904    ldw%M1 %1,%0
4905    stw%M0 %r1,%0"
4906   [(set_attr "type" "move,load,store")
4907    (set_attr "pa_combine_type" "addmove")
4908    (set_attr "length" "4,4,4")])
4912 ;;- zero extension instructions
4913 ;; We have define_expand for zero extension patterns to make sure the
4914 ;; operands get loaded into registers.  The define_insns accept
4915 ;; memory operands.  This gives us better overall code than just
4916 ;; having a pattern that does or does not accept memory operands.
4918 (define_expand "zero_extendqihi2"
4919   [(set (match_operand:HI 0 "register_operand" "")
4920         (zero_extend:HI
4921          (match_operand:QI 1 "register_operand" "")))]
4922   ""
4923   "")
4925 (define_insn ""
4926   [(set (match_operand:HI 0 "register_operand" "=r,r")
4927         (zero_extend:HI
4928          (match_operand:QI 1 "move_src_operand" "r,RQ")))]
4929   "GET_CODE (operands[1]) != CONST_INT"
4930   "@
4931    {extru|extrw,u} %1,31,8,%0
4932    ldb%M1 %1,%0"
4933   [(set_attr "type" "shift,load")
4934    (set_attr "length" "4,4")])
4936 (define_expand "zero_extendqisi2"
4937   [(set (match_operand:SI 0 "register_operand" "")
4938         (zero_extend:SI
4939          (match_operand:QI 1 "register_operand" "")))]
4940   ""
4941   "")
4943 (define_insn ""
4944   [(set (match_operand:SI 0 "register_operand" "=r,r")
4945         (zero_extend:SI
4946          (match_operand:QI 1 "move_src_operand" "r,RQ")))]
4947   "GET_CODE (operands[1]) != CONST_INT"
4948   "@
4949    {extru|extrw,u} %1,31,8,%0
4950    ldb%M1 %1,%0"
4951   [(set_attr "type" "shift,load")
4952    (set_attr "length" "4,4")])
4954 (define_expand "zero_extendhisi2"
4955   [(set (match_operand:SI 0 "register_operand" "")
4956         (zero_extend:SI
4957          (match_operand:HI 1 "register_operand" "")))]
4958   ""
4959   "")
4961 (define_insn ""
4962   [(set (match_operand:SI 0 "register_operand" "=r,r")
4963         (zero_extend:SI
4964          (match_operand:HI 1 "move_src_operand" "r,RQ")))]
4965   "GET_CODE (operands[1]) != CONST_INT"
4966   "@
4967    {extru|extrw,u} %1,31,16,%0
4968    ldh%M1 %1,%0"
4969   [(set_attr "type" "shift,load")
4970    (set_attr "length" "4,4")])
4972 (define_expand "zero_extendqidi2"
4973   [(set (match_operand:DI 0 "register_operand" "")
4974         (zero_extend:DI
4975          (match_operand:QI 1 "register_operand" "")))]
4976   "TARGET_64BIT"
4977   "")
4979 (define_insn ""
4980   [(set (match_operand:DI 0 "register_operand" "=r,r")
4981         (zero_extend:DI
4982          (match_operand:QI 1 "move_src_operand" "r,RQ")))]
4983   "TARGET_64BIT && GET_CODE (operands[1]) != CONST_INT"
4984   "@
4985    extrd,u %1,63,8,%0
4986    ldb%M1 %1,%0"
4987   [(set_attr "type" "shift,load")
4988    (set_attr "length" "4,4")])
4990 (define_expand "zero_extendhidi2"
4991   [(set (match_operand:DI 0 "register_operand" "")
4992         (zero_extend:DI
4993          (match_operand:HI 1 "register_operand" "")))]
4994   "TARGET_64BIT"
4995   "")
4997 (define_insn ""
4998   [(set (match_operand:DI 0 "register_operand" "=r,r")
4999         (zero_extend:DI
5000          (match_operand:HI 1 "move_src_operand" "r,RQ")))]
5001   "TARGET_64BIT && GET_CODE (operands[1]) != CONST_INT"
5002   "@
5003    extrd,u %1,63,16,%0
5004    ldh%M1 %1,%0"
5005   [(set_attr "type" "shift,load")
5006    (set_attr "length" "4,4")])
5008 (define_expand "zero_extendsidi2"
5009   [(set (match_operand:DI 0 "register_operand" "")
5010         (zero_extend:DI
5011          (match_operand:SI 1 "register_operand" "")))]
5012   "TARGET_64BIT"
5013   "")
5015 (define_insn ""
5016   [(set (match_operand:DI 0 "register_operand" "=r,r")
5017         (zero_extend:DI
5018          (match_operand:SI 1 "move_src_operand" "r,RQ")))]
5019   "TARGET_64BIT && GET_CODE (operands[1]) != CONST_INT"
5020   "@
5021    extrd,u %1,63,32,%0
5022    ldw%M1 %1,%0"
5023   [(set_attr "type" "shift,load")
5024    (set_attr "length" "4,4")])
5026 ;;- sign extension instructions
5028 (define_insn "extendhisi2"
5029   [(set (match_operand:SI 0 "register_operand" "=r")
5030         (sign_extend:SI (match_operand:HI 1 "register_operand" "r")))]
5031   ""
5032   "{extrs|extrw,s} %1,31,16,%0"
5033   [(set_attr "type" "shift")
5034    (set_attr "length" "4")])
5036 (define_insn "extendqihi2"
5037   [(set (match_operand:HI 0 "register_operand" "=r")
5038         (sign_extend:HI (match_operand:QI 1 "register_operand" "r")))]
5039   ""
5040   "{extrs|extrw,s} %1,31,8,%0"
5041   [(set_attr "type" "shift") 
5042   (set_attr "length" "4")])
5044 (define_insn "extendqisi2"
5045   [(set (match_operand:SI 0 "register_operand" "=r")
5046         (sign_extend:SI (match_operand:QI 1 "register_operand" "r")))]
5047   ""
5048   "{extrs|extrw,s} %1,31,8,%0"
5049   [(set_attr "type" "shift")
5050    (set_attr "length" "4")])
5052 (define_insn "extendqidi2"
5053   [(set (match_operand:DI 0 "register_operand" "=r")
5054         (sign_extend:DI (match_operand:QI 1 "register_operand" "r")))]
5055   "TARGET_64BIT"
5056   "extrd,s %1,63,8,%0"
5057   [(set_attr "type" "shift") 
5058   (set_attr "length" "4")])
5060 (define_insn "extendhidi2"
5061   [(set (match_operand:DI 0 "register_operand" "=r")
5062         (sign_extend:DI (match_operand:HI 1 "register_operand" "r")))]
5063   "TARGET_64BIT"
5064   "extrd,s %1,63,16,%0"
5065   [(set_attr "type" "shift") 
5066   (set_attr "length" "4")])
5068 (define_insn "extendsidi2"
5069   [(set (match_operand:DI 0 "register_operand" "=r")
5070         (sign_extend:DI (match_operand:SI 1 "register_operand" "r")))]
5071   "TARGET_64BIT"
5072   "extrd,s %1,63,32,%0"
5073   [(set_attr "type" "shift") 
5074   (set_attr "length" "4")])
5077 ;; Conversions between float and double.
5079 (define_insn "extendsfdf2"
5080   [(set (match_operand:DF 0 "register_operand" "=f")
5081         (float_extend:DF
5082          (match_operand:SF 1 "register_operand" "f")))]
5083   "! TARGET_SOFT_FLOAT"
5084   "{fcnvff|fcnv},sgl,dbl %1,%0"
5085   [(set_attr "type" "fpalu")
5086    (set_attr "length" "4")])
5088 (define_insn "truncdfsf2"
5089   [(set (match_operand:SF 0 "register_operand" "=f")
5090         (float_truncate:SF
5091          (match_operand:DF 1 "register_operand" "f")))]
5092   "! TARGET_SOFT_FLOAT"
5093   "{fcnvff|fcnv},dbl,sgl %1,%0"
5094   [(set_attr "type" "fpalu")
5095    (set_attr "length" "4")])
5097 ;; Conversion between fixed point and floating point.
5098 ;; Note that among the fix-to-float insns
5099 ;; the ones that start with SImode come first.
5100 ;; That is so that an operand that is a CONST_INT
5101 ;; (and therefore lacks a specific machine mode).
5102 ;; will be recognized as SImode (which is always valid)
5103 ;; rather than as QImode or HImode.
5105 ;; This pattern forces (set (reg:SF ...) (float:SF (const_int ...)))
5106 ;; to be reloaded by putting the constant into memory.
5107 ;; It must come before the more general floatsisf2 pattern.
5108 (define_insn ""
5109   [(set (match_operand:SF 0 "register_operand" "=f")
5110         (float:SF (match_operand:SI 1 "const_int_operand" "m")))]
5111   "! TARGET_SOFT_FLOAT"
5112   "fldw%F1 %1,%0\;{fcnvxf,sgl,sgl|fcnv,w,sgl} %0,%0"
5113   [(set_attr "type" "fpalu")
5114    (set_attr "length" "8")])
5116 (define_insn "floatsisf2"
5117   [(set (match_operand:SF 0 "register_operand" "=f")
5118         (float:SF (match_operand:SI 1 "register_operand" "f")))]
5119   "! TARGET_SOFT_FLOAT"
5120   "{fcnvxf,sgl,sgl|fcnv,w,sgl} %1,%0"
5121   [(set_attr "type" "fpalu")
5122    (set_attr "length" "4")])
5124 ;; This pattern forces (set (reg:DF ...) (float:DF (const_int ...)))
5125 ;; to be reloaded by putting the constant into memory.
5126 ;; It must come before the more general floatsidf2 pattern.
5127 (define_insn ""
5128   [(set (match_operand:DF 0 "register_operand" "=f")
5129         (float:DF (match_operand:SI 1 "const_int_operand" "m")))]
5130   "! TARGET_SOFT_FLOAT"
5131   "fldw%F1 %1,%0\;{fcnvxf,sgl,dbl|fcnv,w,dbl} %0,%0"
5132   [(set_attr "type" "fpalu")
5133    (set_attr "length" "8")])
5135 (define_insn "floatsidf2"
5136   [(set (match_operand:DF 0 "register_operand" "=f")
5137         (float:DF (match_operand:SI 1 "register_operand" "f")))]
5138   "! TARGET_SOFT_FLOAT"
5139   "{fcnvxf,sgl,dbl|fcnv,w,dbl} %1,%0"
5140   [(set_attr "type" "fpalu")
5141    (set_attr "length" "4")])
5143 (define_expand "floatunssisf2"
5144   [(set (subreg:SI (match_dup 2) 4)
5145         (match_operand:SI 1 "register_operand" ""))
5146    (set (subreg:SI (match_dup 2) 0)
5147         (const_int 0))
5148    (set (match_operand:SF 0 "register_operand" "")
5149         (float:SF (match_dup 2)))]
5150   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
5151   "
5153   if (TARGET_PA_20)
5154     {
5155       emit_insn (gen_floatunssisf2_pa20 (operands[0], operands[1]));
5156       DONE;
5157     }
5158   operands[2] = gen_reg_rtx (DImode);
5161 (define_expand "floatunssidf2"
5162   [(set (subreg:SI (match_dup 2) 4)
5163         (match_operand:SI 1 "register_operand" ""))
5164    (set (subreg:SI (match_dup 2) 0)
5165         (const_int 0))
5166    (set (match_operand:DF 0 "register_operand" "")
5167         (float:DF (match_dup 2)))]
5168   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
5169   "
5171   if (TARGET_PA_20)
5172     {
5173       emit_insn (gen_floatunssidf2_pa20 (operands[0], operands[1]));
5174       DONE;
5175     }
5176   operands[2] = gen_reg_rtx (DImode);
5179 (define_insn "floatdisf2"
5180   [(set (match_operand:SF 0 "register_operand" "=f")
5181         (float:SF (match_operand:DI 1 "register_operand" "f")))]
5182   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
5183   "{fcnvxf,dbl,sgl|fcnv,dw,sgl} %1,%0"
5184   [(set_attr "type" "fpalu")
5185    (set_attr "length" "4")])
5187 (define_insn "floatdidf2"
5188   [(set (match_operand:DF 0 "register_operand" "=f")
5189         (float:DF (match_operand:DI 1 "register_operand" "f")))]
5190   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
5191   "{fcnvxf,dbl,dbl|fcnv,dw,dbl} %1,%0"
5192   [(set_attr "type" "fpalu")
5193    (set_attr "length" "4")])
5195 ;; Convert a float to an actual integer.
5196 ;; Truncation is performed as part of the conversion.
5198 (define_insn "fix_truncsfsi2"
5199   [(set (match_operand:SI 0 "register_operand" "=f")
5200         (fix:SI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
5201   "! TARGET_SOFT_FLOAT"
5202   "{fcnvfxt,sgl,sgl|fcnv,t,sgl,w} %1,%0"
5203   [(set_attr "type" "fpalu")
5204    (set_attr "length" "4")])
5206 (define_insn "fix_truncdfsi2"
5207   [(set (match_operand:SI 0 "register_operand" "=f")
5208         (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
5209   "! TARGET_SOFT_FLOAT"
5210   "{fcnvfxt,dbl,sgl|fcnv,t,dbl,w} %1,%0"
5211   [(set_attr "type" "fpalu")
5212    (set_attr "length" "4")])
5214 (define_insn "fix_truncsfdi2"
5215   [(set (match_operand:DI 0 "register_operand" "=f")
5216         (fix:DI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
5217   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
5218   "{fcnvfxt,sgl,dbl|fcnv,t,sgl,dw} %1,%0"
5219   [(set_attr "type" "fpalu")
5220    (set_attr "length" "4")])
5222 (define_insn "fix_truncdfdi2"
5223   [(set (match_operand:DI 0 "register_operand" "=f")
5224         (fix:DI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
5225   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
5226   "{fcnvfxt,dbl,dbl|fcnv,t,dbl,dw} %1,%0"
5227   [(set_attr "type" "fpalu")
5228    (set_attr "length" "4")])
5230 (define_insn "floatunssidf2_pa20"
5231   [(set (match_operand:DF 0 "register_operand" "=f")
5232         (unsigned_float:DF (match_operand:SI 1 "register_operand" "f")))]
5233   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5234   "fcnv,uw,dbl %1,%0"
5235   [(set_attr "type" "fpalu")
5236    (set_attr "length" "4")])
5238 (define_insn "floatunssisf2_pa20"
5239   [(set (match_operand:SF 0 "register_operand" "=f")
5240         (unsigned_float:SF (match_operand:SI 1 "register_operand" "f")))]
5241   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5242   "fcnv,uw,sgl %1,%0"
5243   [(set_attr "type" "fpalu")
5244    (set_attr "length" "4")])
5246 (define_insn "floatunsdisf2"
5247   [(set (match_operand:SF 0 "register_operand" "=f")
5248         (unsigned_float:SF (match_operand:DI 1 "register_operand" "f")))]
5249   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5250   "fcnv,udw,sgl %1,%0"
5251   [(set_attr "type" "fpalu")
5252    (set_attr "length" "4")])
5254 (define_insn "floatunsdidf2"
5255   [(set (match_operand:DF 0 "register_operand" "=f")
5256         (unsigned_float:DF (match_operand:DI 1 "register_operand" "f")))]
5257   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5258   "fcnv,udw,dbl %1,%0"
5259   [(set_attr "type" "fpalu")
5260    (set_attr "length" "4")])
5262 (define_insn "fixuns_truncsfsi2"
5263   [(set (match_operand:SI 0 "register_operand" "=f")
5264         (unsigned_fix:SI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
5265   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5266   "fcnv,t,sgl,uw %1,%0"
5267   [(set_attr "type" "fpalu")
5268    (set_attr "length" "4")])
5270 (define_insn "fixuns_truncdfsi2"
5271   [(set (match_operand:SI 0 "register_operand" "=f")
5272         (unsigned_fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
5273   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5274   "fcnv,t,dbl,uw %1,%0"
5275   [(set_attr "type" "fpalu")
5276    (set_attr "length" "4")])
5278 (define_insn "fixuns_truncsfdi2"
5279   [(set (match_operand:DI 0 "register_operand" "=f")
5280         (unsigned_fix:DI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
5281   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5282   "fcnv,t,sgl,udw %1,%0"
5283   [(set_attr "type" "fpalu")
5284    (set_attr "length" "4")])
5286 (define_insn "fixuns_truncdfdi2"
5287   [(set (match_operand:DI 0 "register_operand" "=f")
5288         (unsigned_fix:DI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
5289   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5290   "fcnv,t,dbl,udw %1,%0"
5291   [(set_attr "type" "fpalu")
5292    (set_attr "length" "4")])
5294 ;;- arithmetic instructions
5296 (define_expand "adddi3"
5297   [(set (match_operand:DI 0 "register_operand" "")
5298         (plus:DI (match_operand:DI 1 "register_operand" "")
5299                  (match_operand:DI 2 "adddi3_operand" "")))]
5300   ""
5301   "")
5303 (define_insn ""
5304   [(set (match_operand:DI 0 "register_operand" "=r")
5305         (plus:DI (match_operand:DI 1 "register_operand" "%r")
5306                  (match_operand:DI 2 "arith11_operand" "rI")))]
5307   "!TARGET_64BIT"
5308   "*
5310   if (GET_CODE (operands[2]) == CONST_INT)
5311     {
5312       if (INTVAL (operands[2]) >= 0)
5313         return \"addi %2,%R1,%R0\;{addc|add,c} %1,%%r0,%0\";
5314       else
5315         return \"addi %2,%R1,%R0\;{subb|sub,b} %1,%%r0,%0\";
5316     }
5317   else
5318     return \"add %R2,%R1,%R0\;{addc|add,c} %2,%1,%0\";
5320   [(set_attr "type" "binary")
5321    (set_attr "length" "8")])
5323 (define_insn ""
5324   [(set (match_operand:DI 0 "register_operand" "=r,r")
5325         (plus:DI (match_operand:DI 1 "register_operand" "%r,r")
5326                  (match_operand:DI 2 "arith_operand" "r,J")))]
5327   "TARGET_64BIT"
5328   "@
5329    add,l %1,%2,%0
5330    ldo %2(%1),%0"
5331   [(set_attr "type" "binary,binary")
5332    (set_attr "pa_combine_type" "addmove")
5333    (set_attr "length" "4,4")])
5335 (define_insn ""
5336   [(set (match_operand:DI 0 "register_operand" "=r")
5337         (plus:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
5338                  (match_operand:DI 2 "register_operand" "r")))]
5339   "TARGET_64BIT"
5340   "uaddcm %2,%1,%0"
5341   [(set_attr "type" "binary")
5342    (set_attr "length" "4")])
5344 (define_insn ""
5345   [(set (match_operand:SI 0 "register_operand" "=r")
5346         (plus:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
5347                  (match_operand:SI 2 "register_operand" "r")))]
5348   ""
5349   "uaddcm %2,%1,%0"
5350   [(set_attr "type" "binary")
5351    (set_attr "length" "4")])
5353 (define_expand "addvdi3"
5354   [(parallel [(set (match_operand:DI 0 "register_operand" "")
5355                    (plus:DI (match_operand:DI 1 "reg_or_0_operand" "")
5356                             (match_operand:DI 2 "arith11_operand" "")))
5357               (trap_if (ne (plus:TI (sign_extend:TI (match_dup 1))
5358                                     (sign_extend:TI (match_dup 2)))
5359                            (sign_extend:TI (plus:DI (match_dup 1)
5360                                                     (match_dup 2))))
5361                        (const_int 0))])]
5362   ""
5363   "")
5365 (define_insn ""
5366   [(set (match_operand:DI 0 "register_operand" "=r,r")
5367         (plus:DI (match_operand:DI 1 "reg_or_0_operand" "%rM,rM")
5368                  (match_operand:DI 2 "arith11_operand" "r,I")))
5369    (trap_if (ne (plus:TI (sign_extend:TI (match_dup 1))
5370                          (sign_extend:TI (match_dup 2)))
5371                 (sign_extend:TI (plus:DI (match_dup 1)
5372                                          (match_dup 2))))
5373             (const_int 0))]
5374   "TARGET_64BIT"
5375   "@
5376   add,tsv,* %2,%1,%0
5377   addi,tsv,* %2,%1,%0"
5378   [(set_attr "type" "binary,binary")
5379    (set_attr "length" "4,4")])
5381 (define_insn ""
5382   [(set (match_operand:DI 0 "register_operand" "=r")
5383         (plus:DI (match_operand:DI 1 "reg_or_0_operand" "%rM")
5384                  (match_operand:DI 2 "arith11_operand" "rI")))
5385    (trap_if (ne (plus:TI (sign_extend:TI (match_dup 1))
5386                          (sign_extend:TI (match_dup 2)))
5387                 (sign_extend:TI (plus:DI (match_dup 1)
5388                                          (match_dup 2))))
5389             (const_int 0))]
5390   "!TARGET_64BIT"
5391   "*
5393   if (GET_CODE (operands[2]) == CONST_INT)
5394     {
5395       if (INTVAL (operands[2]) >= 0)
5396         return \"addi %2,%R1,%R0\;{addco|add,c,tsv} %1,%%r0,%0\";
5397       else
5398         return \"addi %2,%R1,%R0\;{subbo|sub,b,tsv} %1,%%r0,%0\";
5399     }
5400   else
5401     return \"add %R2,%R1,%R0\;{addco|add,c,tsv} %2,%1,%0\";
5403   [(set_attr "type" "binary")
5404    (set_attr "length" "8")])
5406 ;; define_splits to optimize cases of adding a constant integer
5407 ;; to a register when the constant does not fit in 14 bits.  */
5408 (define_split
5409   [(set (match_operand:SI 0 "register_operand" "")
5410         (plus:SI (match_operand:SI 1 "register_operand" "")
5411                  (match_operand:SI 2 "const_int_operand" "")))
5412    (clobber (match_operand:SI 4 "register_operand" ""))]
5413   "! cint_ok_for_move (INTVAL (operands[2]))
5414    && VAL_14_BITS_P (INTVAL (operands[2]) >> 1)"
5415   [(set (match_dup 4) (plus:SI (match_dup 1) (match_dup 2)))
5416    (set (match_dup 0) (plus:SI (match_dup 4) (match_dup 3)))]
5417   "
5419   int val = INTVAL (operands[2]);
5420   int low = (val < 0) ? -0x2000 : 0x1fff;
5421   int rest = val - low;
5423   operands[2] = GEN_INT (rest);
5424   operands[3] = GEN_INT (low);
5427 (define_split
5428   [(set (match_operand:SI 0 "register_operand" "")
5429         (plus:SI (match_operand:SI 1 "register_operand" "")
5430                  (match_operand:SI 2 "const_int_operand" "")))
5431    (clobber (match_operand:SI 4 "register_operand" ""))]
5432   "! cint_ok_for_move (INTVAL (operands[2]))"
5433   [(set (match_dup 4) (match_dup 2))
5434    (set (match_dup 0) (plus:SI (mult:SI (match_dup 4) (match_dup 3))
5435                                (match_dup 1)))]
5436   "
5438   HOST_WIDE_INT intval = INTVAL (operands[2]);
5440   /* Try dividing the constant by 2, then 4, and finally 8 to see
5441      if we can get a constant which can be loaded into a register
5442      in a single instruction (cint_ok_for_move). 
5444      If that fails, try to negate the constant and subtract it
5445      from our input operand.  */
5446   if (intval % 2 == 0 && cint_ok_for_move (intval / 2))
5447     {
5448       operands[2] = GEN_INT (intval / 2);
5449       operands[3] = const2_rtx;
5450     }
5451   else if (intval % 4 == 0 && cint_ok_for_move (intval / 4))
5452     {
5453       operands[2] = GEN_INT (intval / 4);
5454       operands[3] = GEN_INT (4);
5455     }
5456   else if (intval % 8 == 0 && cint_ok_for_move (intval / 8))
5457     {
5458       operands[2] = GEN_INT (intval / 8);
5459       operands[3] = GEN_INT (8);
5460     }
5461   else if (cint_ok_for_move (-intval))
5462     {
5463       emit_insn (gen_rtx_SET (VOIDmode, operands[4], GEN_INT (-intval)));
5464       emit_insn (gen_subsi3 (operands[0], operands[1], operands[4]));
5465       DONE;
5466     }
5467   else
5468     FAIL;
5471 (define_insn "addsi3"
5472   [(set (match_operand:SI 0 "register_operand" "=r,r")
5473         (plus:SI (match_operand:SI 1 "register_operand" "%r,r")
5474                  (match_operand:SI 2 "arith_operand" "r,J")))]
5475   ""
5476   "@
5477    {addl|add,l} %1,%2,%0
5478    ldo %2(%1),%0"
5479   [(set_attr "type" "binary,binary")
5480    (set_attr "pa_combine_type" "addmove")
5481    (set_attr "length" "4,4")])
5483 (define_insn "addvsi3"
5484   [(set (match_operand:SI 0 "register_operand" "=r,r")
5485         (plus:SI (match_operand:SI 1 "reg_or_0_operand" "%rM,rM")
5486                  (match_operand:SI 2 "arith11_operand" "r,I")))
5487    (trap_if (ne (plus:DI (sign_extend:DI (match_dup 1))
5488                          (sign_extend:DI (match_dup 2)))
5489                 (sign_extend:DI (plus:SI (match_dup 1)
5490                                          (match_dup 2))))
5491             (const_int 0))]
5492   ""
5493   "@
5494   {addo|add,tsv} %2,%1,%0
5495   {addio|addi,tsv} %2,%1,%0"
5496   [(set_attr "type" "binary,binary")
5497    (set_attr "length" "4,4")])
5499 (define_expand "subdi3"
5500   [(set (match_operand:DI 0 "register_operand" "")
5501         (minus:DI (match_operand:DI 1 "arith11_operand" "")
5502                   (match_operand:DI 2 "reg_or_0_operand" "")))]
5503   ""
5504   "")
5506 (define_insn ""
5507   [(set (match_operand:DI 0 "register_operand" "=r,r,!q")
5508         (minus:DI (match_operand:DI 1 "arith11_operand" "r,I,!U")
5509                   (match_operand:DI 2 "reg_or_0_operand" "rM,rM,!rM")))]
5510   "TARGET_64BIT"
5511   "@
5512    sub %1,%2,%0
5513    subi %1,%2,%0
5514    mtsarcm %2"
5515   [(set_attr "type" "binary,binary,move")
5516   (set_attr "length" "4,4,4")])
5518 (define_insn ""
5519   [(set (match_operand:DI 0 "register_operand" "=r,&r")
5520         (minus:DI (match_operand:DI 1 "arith11_operand" "r,I")
5521                   (match_operand:DI 2 "reg_or_0_operand" "rM,rM")))]
5522   "!TARGET_64BIT"
5523   "*
5525   if (GET_CODE (operands[1]) == CONST_INT)
5526     {
5527       if (INTVAL (operands[1]) >= 0)
5528         return \"subi %1,%R2,%R0\;{subb|sub,b} %%r0,%2,%0\";
5529       else
5530         return \"ldi -1,%0\;subi %1,%R2,%R0\;{subb|sub,b} %0,%2,%0\";
5531     }
5532   else
5533     return \"sub %R1,%R2,%R0\;{subb|sub,b} %1,%2,%0\";
5535   [(set_attr "type" "binary")
5536    (set (attr "length")
5537         (if_then_else (eq_attr "alternative" "0")
5538           (const_int 8)
5539           (if_then_else (ge (symbol_ref "INTVAL (operands[1])")
5540                             (const_int 0))
5541             (const_int 8)
5542             (const_int 12))))])
5544 (define_expand "subvdi3"
5545   [(parallel [(set (match_operand:DI 0 "register_operand" "")
5546                    (minus:DI (match_operand:DI 1 "arith11_operand" "")
5547                              (match_operand:DI 2 "reg_or_0_operand" "")))
5548               (trap_if (ne (minus:TI (sign_extend:TI (match_dup 1))
5549                                      (sign_extend:TI (match_dup 2)))
5550                            (sign_extend:TI (minus:DI (match_dup 1)
5551                                                      (match_dup 2))))
5552                        (const_int 0))])]
5553   ""
5554   "")
5556 (define_insn ""
5557   [(set (match_operand:DI 0 "register_operand" "=r,r")
5558         (minus:DI (match_operand:DI 1 "arith11_operand" "r,I")
5559                   (match_operand:DI 2 "reg_or_0_operand" "rM,rM")))
5560    (trap_if (ne (minus:TI (sign_extend:TI (match_dup 1))
5561                           (sign_extend:TI (match_dup 2)))
5562                 (sign_extend:TI (minus:DI (match_dup 1)
5563                                           (match_dup 2))))
5564             (const_int 0))]
5565   "TARGET_64BIT"
5566   "@
5567   {subo|sub,tsv} %1,%2,%0
5568   {subio|subi,tsv} %1,%2,%0"
5569   [(set_attr "type" "binary,binary")
5570    (set_attr "length" "4,4")])
5572 (define_insn ""
5573   [(set (match_operand:DI 0 "register_operand" "=r,&r")
5574         (minus:DI (match_operand:DI 1 "arith11_operand" "r,I")
5575                   (match_operand:DI 2 "reg_or_0_operand" "rM,rM")))
5576    (trap_if (ne (minus:TI (sign_extend:TI (match_dup 1))
5577                           (sign_extend:TI (match_dup 2)))
5578                 (sign_extend:TI (minus:DI (match_dup 1)
5579                                           (match_dup 2))))
5580             (const_int 0))]
5581   "!TARGET_64BIT"
5582   "*
5584   if (GET_CODE (operands[1]) == CONST_INT)
5585     {
5586       if (INTVAL (operands[1]) >= 0)
5587         return \"subi %1,%R2,%R0\;{subbo|sub,b,tsv} %%r0,%2,%0\";
5588       else
5589         return \"ldi -1,%0\;subi %1,%R2,%R0\;{subbo|sub,b,tsv} %0,%2,%0\";
5590     }
5591   else
5592     return \"sub %R1,%R2,%R0\;{subbo|sub,b,tsv} %1,%2,%0\";
5594   [(set_attr "type" "binary,binary")
5595    (set (attr "length")
5596         (if_then_else (eq_attr "alternative" "0")
5597           (const_int 8)
5598           (if_then_else (ge (symbol_ref "INTVAL (operands[1])")
5599                             (const_int 0))
5600             (const_int 8)
5601             (const_int 12))))])
5603 (define_expand "subsi3"
5604   [(set (match_operand:SI 0 "register_operand" "")
5605         (minus:SI (match_operand:SI 1 "arith11_operand" "")
5606                   (match_operand:SI 2 "register_operand" "")))]
5607   ""
5608   "")
5610 (define_insn ""
5611   [(set (match_operand:SI 0 "register_operand" "=r,r")
5612         (minus:SI (match_operand:SI 1 "arith11_operand" "r,I")
5613                   (match_operand:SI 2 "register_operand" "r,r")))]
5614   "!TARGET_PA_20"
5615   "@
5616    sub %1,%2,%0
5617    subi %1,%2,%0"
5618   [(set_attr "type" "binary,binary")
5619    (set_attr "length" "4,4")])
5621 (define_insn ""
5622   [(set (match_operand:SI 0 "register_operand" "=r,r,!q")
5623         (minus:SI (match_operand:SI 1 "arith11_operand" "r,I,!S")
5624                   (match_operand:SI 2 "register_operand" "r,r,!r")))]
5625   "TARGET_PA_20"
5626   "@
5627    sub %1,%2,%0
5628    subi %1,%2,%0
5629    mtsarcm %2"
5630   [(set_attr "type" "binary,binary,move")
5631    (set_attr "length" "4,4,4")])
5633 (define_insn "subvsi3"
5634   [(set (match_operand:SI 0 "register_operand" "=r,r")
5635         (minus:SI (match_operand:SI 1 "arith11_operand" "rM,I")
5636                   (match_operand:SI 2 "reg_or_0_operand" "rM,rM")))
5637    (trap_if (ne (minus:DI (sign_extend:DI (match_dup 1))
5638                           (sign_extend:DI (match_dup 2)))
5639                 (sign_extend:DI (minus:SI (match_dup 1)
5640                                           (match_dup 2))))
5641             (const_int 0))]
5642   ""
5643   "@
5644   {subo|sub,tsv} %1,%2,%0
5645   {subio|subi,tsv} %1,%2,%0"
5646   [(set_attr "type" "binary,binary")
5647    (set_attr "length" "4,4")])
5649 ;; Clobbering a "register_operand" instead of a match_scratch
5650 ;; in operand3 of millicode calls avoids spilling %r1 and
5651 ;; produces better code.
5653 ;; The mulsi3 insns set up registers for the millicode call.
5654 (define_expand "mulsi3"
5655   [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5656    (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5657    (parallel [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
5658               (clobber (match_dup 3))
5659               (clobber (reg:SI 26))
5660               (clobber (reg:SI 25))
5661               (clobber (match_dup 4))])
5662    (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5663   ""
5664   "
5666   operands[4] = gen_rtx_REG (SImode, TARGET_64BIT ? 2 : 31);
5667   if (TARGET_PA_11 && !TARGET_DISABLE_FPREGS && !TARGET_SOFT_FLOAT)
5668     {
5669       rtx scratch = gen_reg_rtx (DImode);
5670       operands[1] = force_reg (SImode, operands[1]);
5671       operands[2] = force_reg (SImode, operands[2]);
5672       emit_insn (gen_umulsidi3 (scratch, operands[1], operands[2]));
5673       emit_insn (gen_movsi (operands[0],
5674                             gen_rtx_SUBREG (SImode, scratch,
5675                                             GET_MODE_SIZE (SImode))));
5676       DONE;
5677     }
5678   operands[3] = gen_reg_rtx (SImode);
5681 (define_insn "umulsidi3"
5682   [(set (match_operand:DI 0 "nonimmediate_operand" "=f")
5683         (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "f"))
5684                  (zero_extend:DI (match_operand:SI 2 "nonimmediate_operand" "f"))))]
5685   "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT"
5686   "xmpyu %1,%2,%0"
5687   [(set_attr "type" "fpmuldbl")
5688    (set_attr "length" "4")])
5690 (define_insn ""
5691   [(set (match_operand:DI 0 "nonimmediate_operand" "=f")
5692         (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "f"))
5693                  (match_operand:DI 2 "uint32_operand" "f")))]
5694   "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT && !TARGET_64BIT"
5695   "xmpyu %1,%R2,%0"
5696   [(set_attr "type" "fpmuldbl")
5697    (set_attr "length" "4")])
5699 (define_insn ""
5700   [(set (match_operand:DI 0 "nonimmediate_operand" "=f")
5701         (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "f"))
5702                  (match_operand:DI 2 "uint32_operand" "f")))]
5703   "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT && TARGET_64BIT"
5704   "xmpyu %1,%2R,%0"
5705   [(set_attr "type" "fpmuldbl")
5706    (set_attr "length" "4")])
5708 (define_insn ""
5709   [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
5710    (clobber (match_operand:SI 0 "register_operand" "=a"))
5711    (clobber (reg:SI 26))
5712    (clobber (reg:SI 25))
5713    (clobber (reg:SI 31))]
5714   "!TARGET_64BIT"
5715   "* return output_mul_insn (0, insn);"
5716   [(set_attr "type" "milli")
5717    (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5719 (define_insn ""
5720   [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
5721    (clobber (match_operand:SI 0 "register_operand" "=a"))
5722    (clobber (reg:SI 26))
5723    (clobber (reg:SI 25))
5724    (clobber (reg:SI 2))]
5725   "TARGET_64BIT"
5726   "* return output_mul_insn (0, insn);"
5727   [(set_attr "type" "milli")
5728    (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5730 (define_expand "muldi3"
5731   [(set (match_operand:DI 0 "register_operand" "")
5732         (mult:DI (match_operand:DI 1 "register_operand" "")
5733                  (match_operand:DI 2 "register_operand" "")))]
5734   "TARGET_64BIT && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT"
5735   "
5737   rtx low_product = gen_reg_rtx (DImode);
5738   rtx cross_product1 = gen_reg_rtx (DImode);
5739   rtx cross_product2 = gen_reg_rtx (DImode);
5740   rtx cross_scratch = gen_reg_rtx (DImode);
5741   rtx cross_product = gen_reg_rtx (DImode);
5742   rtx op1l, op1r, op2l, op2r;
5743   rtx op1shifted, op2shifted;
5745   op1shifted = gen_reg_rtx (DImode);
5746   op2shifted = gen_reg_rtx (DImode);
5747   op1l = gen_reg_rtx (SImode);
5748   op1r = gen_reg_rtx (SImode);
5749   op2l = gen_reg_rtx (SImode);
5750   op2r = gen_reg_rtx (SImode);
5752   emit_move_insn (op1shifted, gen_rtx_LSHIFTRT (DImode, operands[1],
5753                                                 GEN_INT (32)));
5754   emit_move_insn (op2shifted, gen_rtx_LSHIFTRT (DImode, operands[2],
5755                                                 GEN_INT (32)));
5756   op1r = force_reg (SImode, gen_rtx_SUBREG (SImode, operands[1], 4));
5757   op2r = force_reg (SImode, gen_rtx_SUBREG (SImode, operands[2], 4));
5758   op1l = force_reg (SImode, gen_rtx_SUBREG (SImode, op1shifted, 4));
5759   op2l = force_reg (SImode, gen_rtx_SUBREG (SImode, op2shifted, 4));
5761   /* Emit multiplies for the cross products.  */
5762   emit_insn (gen_umulsidi3 (cross_product1, op2r, op1l));
5763   emit_insn (gen_umulsidi3 (cross_product2, op2l, op1r));
5765   /* Emit a multiply for the low sub-word.  */
5766   emit_insn (gen_umulsidi3 (low_product, copy_rtx (op2r), copy_rtx (op1r)));
5768   /* Sum the cross products and shift them into proper position.  */
5769   emit_insn (gen_adddi3 (cross_scratch, cross_product1, cross_product2));
5770   emit_insn (gen_ashldi3 (cross_product, cross_scratch, GEN_INT (32)));
5772   /* Add the cross product to the low product and store the result
5773      into the output operand .  */
5774   emit_insn (gen_adddi3 (operands[0], cross_product, low_product));
5775   DONE;
5778 ;;; Division and mod.
5779 (define_expand "divsi3"
5780   [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5781    (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5782    (parallel [(set (reg:SI 29) (div:SI (reg:SI 26) (reg:SI 25)))
5783               (clobber (match_dup 3))
5784               (clobber (match_dup 4))
5785               (clobber (reg:SI 26))
5786               (clobber (reg:SI 25))
5787               (clobber (match_dup 5))])
5788    (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5789   ""
5790   "
5792   operands[3] = gen_reg_rtx (SImode);
5793   if (TARGET_64BIT)
5794     {
5795       operands[5] = gen_rtx_REG (SImode, 2);
5796       operands[4] = operands[5];
5797     }
5798   else
5799     {
5800       operands[5] = gen_rtx_REG (SImode, 31);
5801       operands[4] = gen_reg_rtx (SImode);
5802     }
5803   if (GET_CODE (operands[2]) == CONST_INT && emit_hpdiv_const (operands, 0))
5804     DONE;
5807 (define_insn ""
5808   [(set (reg:SI 29)
5809         (div:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5810    (clobber (match_operand:SI 1 "register_operand" "=a"))
5811    (clobber (match_operand:SI 2 "register_operand" "=&r"))
5812    (clobber (reg:SI 26))
5813    (clobber (reg:SI 25))
5814    (clobber (reg:SI 31))]
5815   "!TARGET_64BIT"
5816   "*
5817    return output_div_insn (operands, 0, insn);"
5818   [(set_attr "type" "milli")
5819    (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5821 (define_insn ""
5822   [(set (reg:SI 29)
5823         (div:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5824    (clobber (match_operand:SI 1 "register_operand" "=a"))
5825    (clobber (match_operand:SI 2 "register_operand" "=&r"))
5826    (clobber (reg:SI 26))
5827    (clobber (reg:SI 25))
5828    (clobber (reg:SI 2))]
5829   "TARGET_64BIT"
5830   "*
5831    return output_div_insn (operands, 0, insn);"
5832   [(set_attr "type" "milli")
5833    (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5835 (define_expand "udivsi3"
5836   [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5837    (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5838    (parallel [(set (reg:SI 29) (udiv:SI (reg:SI 26) (reg:SI 25)))
5839               (clobber (match_dup 3))
5840               (clobber (match_dup 4))
5841               (clobber (reg:SI 26))
5842               (clobber (reg:SI 25))
5843               (clobber (match_dup 5))])
5844    (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5845   ""
5846   "
5848   operands[3] = gen_reg_rtx (SImode);
5850   if (TARGET_64BIT)
5851     {
5852       operands[5] = gen_rtx_REG (SImode, 2);
5853       operands[4] = operands[5];
5854     }
5855   else
5856     {
5857       operands[5] = gen_rtx_REG (SImode, 31);
5858       operands[4] = gen_reg_rtx (SImode);
5859     }
5860   if (GET_CODE (operands[2]) == CONST_INT && emit_hpdiv_const (operands, 1))
5861     DONE;
5864 (define_insn ""
5865   [(set (reg:SI 29)
5866         (udiv:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5867    (clobber (match_operand:SI 1 "register_operand" "=a"))
5868    (clobber (match_operand:SI 2 "register_operand" "=&r"))
5869    (clobber (reg:SI 26))
5870    (clobber (reg:SI 25))
5871    (clobber (reg:SI 31))]
5872   "!TARGET_64BIT"
5873   "*
5874    return output_div_insn (operands, 1, insn);"
5875   [(set_attr "type" "milli")
5876    (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5878 (define_insn ""
5879   [(set (reg:SI 29)
5880         (udiv:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5881    (clobber (match_operand:SI 1 "register_operand" "=a"))
5882    (clobber (match_operand:SI 2 "register_operand" "=&r"))
5883    (clobber (reg:SI 26))
5884    (clobber (reg:SI 25))
5885    (clobber (reg:SI 2))]
5886   "TARGET_64BIT"
5887   "*
5888    return output_div_insn (operands, 1, insn);"
5889   [(set_attr "type" "milli")
5890    (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5892 (define_expand "modsi3"
5893   [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5894    (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5895    (parallel [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
5896               (clobber (match_dup 3))
5897               (clobber (match_dup 4))
5898               (clobber (reg:SI 26))
5899               (clobber (reg:SI 25))
5900               (clobber (match_dup 5))])
5901    (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5902   ""
5903   "
5905   if (TARGET_64BIT)
5906     {
5907       operands[5] = gen_rtx_REG (SImode, 2);
5908       operands[4] = operands[5];
5909     }
5910   else
5911     {
5912       operands[5] = gen_rtx_REG (SImode, 31);
5913       operands[4] = gen_reg_rtx (SImode);
5914     }
5915   operands[3] = gen_reg_rtx (SImode);
5918 (define_insn ""
5919   [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
5920    (clobber (match_operand:SI 0 "register_operand" "=a"))
5921    (clobber (match_operand:SI 1 "register_operand" "=&r"))
5922    (clobber (reg:SI 26))
5923    (clobber (reg:SI 25))
5924    (clobber (reg:SI 31))]
5925   "!TARGET_64BIT"
5926   "*
5927   return output_mod_insn (0, insn);"
5928   [(set_attr "type" "milli")
5929    (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5931 (define_insn ""
5932   [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
5933    (clobber (match_operand:SI 0 "register_operand" "=a"))
5934    (clobber (match_operand:SI 1 "register_operand" "=&r"))
5935    (clobber (reg:SI 26))
5936    (clobber (reg:SI 25))
5937    (clobber (reg:SI 2))]
5938   "TARGET_64BIT"
5939   "*
5940   return output_mod_insn (0, insn);"
5941   [(set_attr "type" "milli")
5942    (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5944 (define_expand "umodsi3"
5945   [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5946    (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5947    (parallel [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
5948               (clobber (match_dup 3))
5949               (clobber (match_dup 4))
5950               (clobber (reg:SI 26))
5951               (clobber (reg:SI 25))
5952               (clobber (match_dup 5))])
5953    (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5954   ""
5955   "
5957   if (TARGET_64BIT)
5958     {
5959       operands[5] = gen_rtx_REG (SImode, 2);
5960       operands[4] = operands[5];
5961     }
5962   else
5963     {
5964       operands[5] = gen_rtx_REG (SImode, 31);
5965       operands[4] = gen_reg_rtx (SImode);
5966     }
5967   operands[3] = gen_reg_rtx (SImode);
5970 (define_insn ""
5971   [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
5972    (clobber (match_operand:SI 0 "register_operand" "=a"))
5973    (clobber (match_operand:SI 1 "register_operand" "=&r"))
5974    (clobber (reg:SI 26))
5975    (clobber (reg:SI 25))
5976    (clobber (reg:SI 31))]
5977   "!TARGET_64BIT"
5978   "*
5979   return output_mod_insn (1, insn);"
5980   [(set_attr "type" "milli")
5981    (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5983 (define_insn ""
5984   [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
5985    (clobber (match_operand:SI 0 "register_operand" "=a"))
5986    (clobber (match_operand:SI 1 "register_operand" "=&r"))
5987    (clobber (reg:SI 26))
5988    (clobber (reg:SI 25))
5989    (clobber (reg:SI 2))]
5990   "TARGET_64BIT"
5991   "*
5992   return output_mod_insn (1, insn);"
5993   [(set_attr "type" "milli")
5994    (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5996 ;;- and instructions
5997 ;; We define DImode `and` so with DImode `not` we can get
5998 ;; DImode `andn`.  Other combinations are possible.
6000 (define_expand "anddi3"
6001   [(set (match_operand:DI 0 "register_operand" "")
6002         (and:DI (match_operand:DI 1 "register_operand" "")
6003                 (match_operand:DI 2 "and_operand" "")))]
6004   ""
6005   "
6007   /* Both operands must be register operands.  */
6008   if (!TARGET_64BIT && !register_operand (operands[2], DImode))
6009     FAIL;
6012 (define_insn ""
6013   [(set (match_operand:DI 0 "register_operand" "=r")
6014         (and:DI (match_operand:DI 1 "register_operand" "%r")
6015                 (match_operand:DI 2 "register_operand" "r")))]
6016   "!TARGET_64BIT"
6017   "and %1,%2,%0\;and %R1,%R2,%R0"
6018   [(set_attr "type" "binary")
6019    (set_attr "length" "8")])
6021 (define_insn ""
6022   [(set (match_operand:DI 0 "register_operand" "=r,r")
6023         (and:DI (match_operand:DI 1 "register_operand" "%?r,0")
6024                 (match_operand:DI 2 "and_operand" "rO,P")))]
6025   "TARGET_64BIT"
6026   "* return output_64bit_and (operands); "
6027   [(set_attr "type" "binary")
6028    (set_attr "length" "4")])
6030 ; The ? for op1 makes reload prefer zdepi instead of loading a huge
6031 ; constant with ldil;ldo.
6032 (define_insn "andsi3"
6033   [(set (match_operand:SI 0 "register_operand" "=r,r")
6034         (and:SI (match_operand:SI 1 "register_operand" "%?r,0")
6035                 (match_operand:SI 2 "and_operand" "rO,P")))]
6036   ""
6037   "* return output_and (operands); "
6038   [(set_attr "type" "binary,shift")
6039    (set_attr "length" "4,4")])
6041 (define_insn ""
6042   [(set (match_operand:DI 0 "register_operand" "=r")
6043         (and:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
6044                 (match_operand:DI 2 "register_operand" "r")))]
6045   "!TARGET_64BIT"
6046   "andcm %2,%1,%0\;andcm %R2,%R1,%R0"
6047   [(set_attr "type" "binary")
6048    (set_attr "length" "8")])
6050 (define_insn ""
6051   [(set (match_operand:DI 0 "register_operand" "=r")
6052         (and:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
6053                 (match_operand:DI 2 "register_operand" "r")))]
6054   "TARGET_64BIT"
6055   "andcm %2,%1,%0"
6056   [(set_attr "type" "binary")
6057    (set_attr "length" "4")])
6059 (define_insn ""
6060   [(set (match_operand:SI 0 "register_operand" "=r")
6061         (and:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
6062                 (match_operand:SI 2 "register_operand" "r")))]
6063   ""
6064   "andcm %2,%1,%0"
6065   [(set_attr "type" "binary")
6066   (set_attr "length" "4")])
6068 (define_expand "iordi3"
6069   [(set (match_operand:DI 0 "register_operand" "")
6070         (ior:DI (match_operand:DI 1 "register_operand" "")
6071                 (match_operand:DI 2 "ior_operand" "")))]
6072   ""
6073   "
6075   /* Both operands must be register operands.  */
6076   if (!TARGET_64BIT && !register_operand (operands[2], DImode))
6077     FAIL;
6080 (define_insn ""
6081   [(set (match_operand:DI 0 "register_operand" "=r")
6082         (ior:DI (match_operand:DI 1 "register_operand" "%r")
6083                 (match_operand:DI 2 "register_operand" "r")))]
6084   "!TARGET_64BIT"
6085   "or %1,%2,%0\;or %R1,%R2,%R0"
6086   [(set_attr "type" "binary")
6087    (set_attr "length" "8")])
6089 (define_insn ""
6090   [(set (match_operand:DI 0 "register_operand" "=r,r")
6091         (ior:DI (match_operand:DI 1 "register_operand" "0,0")
6092                 (match_operand:DI 2 "ior_operand" "M,i")))]
6093   "TARGET_64BIT"
6094   "* return output_64bit_ior (operands); "
6095   [(set_attr "type" "binary,shift")
6096    (set_attr "length" "4,4")])
6098 (define_insn ""
6099   [(set (match_operand:DI 0 "register_operand" "=r")
6100         (ior:DI (match_operand:DI 1 "register_operand" "%r")
6101                 (match_operand:DI 2 "register_operand" "r")))]
6102   "TARGET_64BIT"
6103   "or %1,%2,%0"
6104   [(set_attr "type" "binary")
6105    (set_attr "length" "4")])
6107 ;; Need a define_expand because we've run out of CONST_OK... characters.
6108 (define_expand "iorsi3"
6109   [(set (match_operand:SI 0 "register_operand" "")
6110         (ior:SI (match_operand:SI 1 "register_operand" "")
6111                 (match_operand:SI 2 "arith32_operand" "")))]
6112   ""
6113   "
6115   if (! (ior_operand (operands[2], SImode)
6116          || register_operand (operands[2], SImode)))
6117     operands[2] = force_reg (SImode, operands[2]);
6120 (define_insn ""
6121   [(set (match_operand:SI 0 "register_operand" "=r,r")
6122         (ior:SI (match_operand:SI 1 "register_operand" "0,0")
6123                 (match_operand:SI 2 "ior_operand" "M,i")))]
6124   ""
6125   "* return output_ior (operands); "
6126   [(set_attr "type" "binary,shift")
6127    (set_attr "length" "4,4")])
6129 (define_insn ""
6130   [(set (match_operand:SI 0 "register_operand" "=r")
6131         (ior:SI (match_operand:SI 1 "register_operand" "%r")
6132                 (match_operand:SI 2 "register_operand" "r")))]
6133   ""
6134   "or %1,%2,%0"
6135   [(set_attr "type" "binary")
6136    (set_attr "length" "4")])
6138 (define_expand "xordi3"
6139   [(set (match_operand:DI 0 "register_operand" "")
6140         (xor:DI (match_operand:DI 1 "register_operand" "")
6141                 (match_operand:DI 2 "register_operand" "")))]
6142   ""
6143   "
6147 (define_insn ""
6148   [(set (match_operand:DI 0 "register_operand" "=r")
6149         (xor:DI (match_operand:DI 1 "register_operand" "%r")
6150                 (match_operand:DI 2 "register_operand" "r")))]
6151   "!TARGET_64BIT"
6152   "xor %1,%2,%0\;xor %R1,%R2,%R0"
6153   [(set_attr "type" "binary")
6154    (set_attr "length" "8")])
6156 (define_insn ""
6157   [(set (match_operand:DI 0 "register_operand" "=r")
6158         (xor:DI (match_operand:DI 1 "register_operand" "%r")
6159                 (match_operand:DI 2 "register_operand" "r")))]
6160   "TARGET_64BIT"
6161   "xor %1,%2,%0"
6162   [(set_attr "type" "binary")
6163    (set_attr "length" "4")])
6165 (define_insn "xorsi3"
6166   [(set (match_operand:SI 0 "register_operand" "=r")
6167         (xor:SI (match_operand:SI 1 "register_operand" "%r")
6168                 (match_operand:SI 2 "register_operand" "r")))]
6169   ""
6170   "xor %1,%2,%0"
6171   [(set_attr "type" "binary")
6172    (set_attr "length" "4")])
6174 (define_expand "negdi2"
6175   [(set (match_operand:DI 0 "register_operand" "")
6176         (neg:DI (match_operand:DI 1 "register_operand" "")))]
6177   ""
6178   "")
6180 (define_insn ""
6181   [(set (match_operand:DI 0 "register_operand" "=r")
6182         (neg:DI (match_operand:DI 1 "register_operand" "r")))]
6183   "!TARGET_64BIT"
6184   "sub %%r0,%R1,%R0\;{subb|sub,b} %%r0,%1,%0"
6185   [(set_attr "type" "unary")
6186    (set_attr "length" "8")])
6188 (define_insn ""
6189   [(set (match_operand:DI 0 "register_operand" "=r")
6190         (neg:DI (match_operand:DI 1 "register_operand" "r")))]
6191   "TARGET_64BIT"
6192   "sub %%r0,%1,%0"
6193   [(set_attr "type" "unary")
6194    (set_attr "length" "4")])
6196 (define_expand "negvdi2"
6197   [(parallel [(set (match_operand:DI 0 "register_operand" "")
6198                    (neg:DI (match_operand:DI 1 "register_operand" "")))
6199               (trap_if (ne (neg:TI (sign_extend:TI (match_dup 1)))
6200                                    (sign_extend:TI (neg:DI (match_dup 1))))
6201                        (const_int 0))])]
6202   ""
6203   "")
6205 (define_insn ""
6206   [(set (match_operand:DI 0 "register_operand" "=r")
6207         (neg:DI (match_operand:DI 1 "register_operand" "r")))
6208    (trap_if (ne (neg:TI (sign_extend:TI (match_dup 1)))
6209                 (sign_extend:TI (neg:DI (match_dup 1))))
6210             (const_int 0))]
6211   "!TARGET_64BIT"
6212   "sub %%r0,%R1,%R0\;{subbo|sub,b,tsv} %%r0,%1,%0"
6213   [(set_attr "type" "unary")
6214    (set_attr "length" "8")])
6216 (define_insn ""
6217   [(set (match_operand:DI 0 "register_operand" "=r")
6218         (neg:DI (match_operand:DI 1 "register_operand" "r")))
6219    (trap_if (ne (neg:TI (sign_extend:TI (match_dup 1)))
6220                 (sign_extend:TI (neg:DI (match_dup 1))))
6221             (const_int 0))]
6222   "TARGET_64BIT"
6223   "sub,tsv %%r0,%1,%0"
6224   [(set_attr "type" "unary")
6225    (set_attr "length" "4")])
6227 (define_insn "negsi2"
6228   [(set (match_operand:SI 0 "register_operand" "=r")
6229         (neg:SI (match_operand:SI 1 "register_operand" "r")))]
6230   ""
6231   "sub %%r0,%1,%0"
6232   [(set_attr "type" "unary")
6233    (set_attr "length" "4")])
6235 (define_insn "negvsi2"
6236   [(set (match_operand:SI 0 "register_operand" "=r")
6237         (neg:SI (match_operand:SI 1 "register_operand" "r")))
6238    (trap_if (ne (neg:DI (sign_extend:DI (match_dup 1)))
6239                 (sign_extend:DI (neg:SI (match_dup 1))))
6240             (const_int 0))]
6241    ""
6242    "{subo|sub,tsv} %%r0,%1,%0"
6243   [(set_attr "type" "unary")
6244    (set_attr "length" "4")])
6246 (define_expand "one_cmpldi2"
6247   [(set (match_operand:DI 0 "register_operand" "")
6248         (not:DI (match_operand:DI 1 "register_operand" "")))]
6249   ""
6250   "
6254 (define_insn ""
6255   [(set (match_operand:DI 0 "register_operand" "=r")
6256         (not:DI (match_operand:DI 1 "register_operand" "r")))]
6257   "!TARGET_64BIT"
6258   "uaddcm %%r0,%1,%0\;uaddcm %%r0,%R1,%R0"
6259   [(set_attr "type" "unary")
6260    (set_attr "length" "8")])
6262 (define_insn ""
6263   [(set (match_operand:DI 0 "register_operand" "=r")
6264         (not:DI (match_operand:DI 1 "register_operand" "r")))]
6265   "TARGET_64BIT"
6266   "uaddcm %%r0,%1,%0"
6267   [(set_attr "type" "unary")
6268    (set_attr "length" "4")])
6270 (define_insn "one_cmplsi2"
6271   [(set (match_operand:SI 0 "register_operand" "=r")
6272         (not:SI (match_operand:SI 1 "register_operand" "r")))]
6273   ""
6274   "uaddcm %%r0,%1,%0"
6275   [(set_attr "type" "unary")
6276    (set_attr "length" "4")])
6278 ;; Floating point arithmetic instructions.
6280 (define_insn "adddf3"
6281   [(set (match_operand:DF 0 "register_operand" "=f")
6282         (plus:DF (match_operand:DF 1 "register_operand" "f")
6283                  (match_operand:DF 2 "register_operand" "f")))]
6284   "! TARGET_SOFT_FLOAT"
6285   "fadd,dbl %1,%2,%0"
6286   [(set_attr "type" "fpalu")
6287    (set_attr "pa_combine_type" "faddsub")
6288    (set_attr "length" "4")])
6290 (define_insn "addsf3"
6291   [(set (match_operand:SF 0 "register_operand" "=f")
6292         (plus:SF (match_operand:SF 1 "register_operand" "f")
6293                  (match_operand:SF 2 "register_operand" "f")))]
6294   "! TARGET_SOFT_FLOAT"
6295   "fadd,sgl %1,%2,%0"
6296   [(set_attr "type" "fpalu")
6297    (set_attr "pa_combine_type" "faddsub")
6298    (set_attr "length" "4")])
6300 (define_insn "subdf3"
6301   [(set (match_operand:DF 0 "register_operand" "=f")
6302         (minus:DF (match_operand:DF 1 "register_operand" "f")
6303                   (match_operand:DF 2 "register_operand" "f")))]
6304   "! TARGET_SOFT_FLOAT"
6305   "fsub,dbl %1,%2,%0"
6306   [(set_attr "type" "fpalu")
6307    (set_attr "pa_combine_type" "faddsub")
6308    (set_attr "length" "4")])
6310 (define_insn "subsf3"
6311   [(set (match_operand:SF 0 "register_operand" "=f")
6312         (minus:SF (match_operand:SF 1 "register_operand" "f")
6313                   (match_operand:SF 2 "register_operand" "f")))]
6314   "! TARGET_SOFT_FLOAT"
6315   "fsub,sgl %1,%2,%0"
6316   [(set_attr "type" "fpalu")
6317    (set_attr "pa_combine_type" "faddsub")
6318    (set_attr "length" "4")])
6320 (define_insn "muldf3"
6321   [(set (match_operand:DF 0 "register_operand" "=f")
6322         (mult:DF (match_operand:DF 1 "register_operand" "f")
6323                  (match_operand:DF 2 "register_operand" "f")))]
6324   "! TARGET_SOFT_FLOAT"
6325   "fmpy,dbl %1,%2,%0"
6326   [(set_attr "type" "fpmuldbl")
6327    (set_attr "pa_combine_type" "fmpy")
6328    (set_attr "length" "4")])
6330 (define_insn "mulsf3"
6331   [(set (match_operand:SF 0 "register_operand" "=f")
6332         (mult:SF (match_operand:SF 1 "register_operand" "f")
6333                  (match_operand:SF 2 "register_operand" "f")))]
6334   "! TARGET_SOFT_FLOAT"
6335   "fmpy,sgl %1,%2,%0"
6336   [(set_attr "type" "fpmulsgl")
6337    (set_attr "pa_combine_type" "fmpy")
6338    (set_attr "length" "4")])
6340 (define_insn "divdf3"
6341   [(set (match_operand:DF 0 "register_operand" "=f")
6342         (div:DF (match_operand:DF 1 "register_operand" "f")
6343                 (match_operand:DF 2 "register_operand" "f")))]
6344   "! TARGET_SOFT_FLOAT"
6345   "fdiv,dbl %1,%2,%0"
6346   [(set_attr "type" "fpdivdbl")
6347    (set_attr "length" "4")])
6349 (define_insn "divsf3"
6350   [(set (match_operand:SF 0 "register_operand" "=f")
6351         (div:SF (match_operand:SF 1 "register_operand" "f")
6352                 (match_operand:SF 2 "register_operand" "f")))]
6353   "! TARGET_SOFT_FLOAT"
6354   "fdiv,sgl %1,%2,%0"
6355   [(set_attr "type" "fpdivsgl")
6356    (set_attr "length" "4")])
6358 ;; Processors prior to PA 2.0 don't have a fneg instruction.  Fast
6359 ;; negation can be done by subtracting from plus zero.  However, this
6360 ;; violates the IEEE standard when negating plus and minus zero.
6361 (define_expand "negdf2"
6362   [(parallel [(set (match_operand:DF 0 "register_operand" "")
6363                    (neg:DF (match_operand:DF 1 "register_operand" "")))
6364               (use (match_dup 2))])]
6365   "! TARGET_SOFT_FLOAT"
6367   if (TARGET_PA_20 || flag_unsafe_math_optimizations)
6368     emit_insn (gen_negdf2_fast (operands[0], operands[1]));
6369   else
6370     {
6371       operands[2] = force_reg (DFmode,
6372         CONST_DOUBLE_FROM_REAL_VALUE (dconstm1, DFmode));
6373       emit_insn (gen_muldf3 (operands[0], operands[1], operands[2]));
6374     }
6375   DONE;
6378 (define_insn "negdf2_fast"
6379   [(set (match_operand:DF 0 "register_operand" "=f")
6380         (neg:DF (match_operand:DF 1 "register_operand" "f")))]
6381   "! TARGET_SOFT_FLOAT && (TARGET_PA_20 || flag_unsafe_math_optimizations)"
6382   "*
6384   if (TARGET_PA_20)
6385     return \"fneg,dbl %1,%0\";
6386   else
6387     return \"fsub,dbl %%fr0,%1,%0\";
6389   [(set_attr "type" "fpalu")
6390    (set_attr "length" "4")])
6392 (define_expand "negsf2"
6393   [(parallel [(set (match_operand:SF 0 "register_operand" "")
6394                    (neg:SF (match_operand:SF 1 "register_operand" "")))
6395               (use (match_dup 2))])]
6396   "! TARGET_SOFT_FLOAT"
6398   if (TARGET_PA_20 || flag_unsafe_math_optimizations)
6399     emit_insn (gen_negsf2_fast (operands[0], operands[1]));
6400   else
6401     {
6402       operands[2] = force_reg (SFmode,
6403         CONST_DOUBLE_FROM_REAL_VALUE (dconstm1, SFmode));
6404       emit_insn (gen_mulsf3 (operands[0], operands[1], operands[2]));
6405     }
6406   DONE;
6409 (define_insn "negsf2_fast"
6410   [(set (match_operand:SF 0 "register_operand" "=f")
6411         (neg:SF (match_operand:SF 1 "register_operand" "f")))]
6412   "! TARGET_SOFT_FLOAT && (TARGET_PA_20 || flag_unsafe_math_optimizations)"
6413   "*
6415   if (TARGET_PA_20)
6416     return \"fneg,sgl %1,%0\";
6417   else
6418     return \"fsub,sgl %%fr0,%1,%0\";
6420   [(set_attr "type" "fpalu")
6421    (set_attr "length" "4")])
6423 (define_insn "absdf2"
6424   [(set (match_operand:DF 0 "register_operand" "=f")
6425         (abs:DF (match_operand:DF 1 "register_operand" "f")))]
6426   "! TARGET_SOFT_FLOAT"
6427   "fabs,dbl %1,%0"
6428   [(set_attr "type" "fpalu")
6429    (set_attr "length" "4")])
6431 (define_insn "abssf2"
6432   [(set (match_operand:SF 0 "register_operand" "=f")
6433         (abs:SF (match_operand:SF 1 "register_operand" "f")))]
6434   "! TARGET_SOFT_FLOAT"
6435   "fabs,sgl %1,%0"
6436   [(set_attr "type" "fpalu")
6437    (set_attr "length" "4")])
6439 (define_insn "sqrtdf2"
6440   [(set (match_operand:DF 0 "register_operand" "=f")
6441         (sqrt:DF (match_operand:DF 1 "register_operand" "f")))]
6442   "! TARGET_SOFT_FLOAT"
6443   "fsqrt,dbl %1,%0"
6444   [(set_attr "type" "fpsqrtdbl")
6445    (set_attr "length" "4")])
6447 (define_insn "sqrtsf2"
6448   [(set (match_operand:SF 0 "register_operand" "=f")
6449         (sqrt:SF (match_operand:SF 1 "register_operand" "f")))]
6450   "! TARGET_SOFT_FLOAT"
6451   "fsqrt,sgl %1,%0"
6452   [(set_attr "type" "fpsqrtsgl")
6453    (set_attr "length" "4")])
6455 ;; PA 2.0 floating point instructions
6457 ; fmpyfadd patterns
6458 (define_insn ""
6459   [(set (match_operand:DF 0 "register_operand" "=f")
6460         (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
6461                           (match_operand:DF 2 "register_operand" "f"))
6462                  (match_operand:DF 3 "register_operand" "f")))]
6463   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6464   "fmpyfadd,dbl %1,%2,%3,%0"
6465   [(set_attr "type" "fpmuldbl")
6466    (set_attr "length" "4")])
6468 (define_insn ""
6469   [(set (match_operand:DF 0 "register_operand" "=f")
6470         (plus:DF (match_operand:DF 1 "register_operand" "f")
6471                  (mult:DF (match_operand:DF 2 "register_operand" "f")
6472                           (match_operand:DF 3 "register_operand" "f"))))]
6473   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6474   "fmpyfadd,dbl %2,%3,%1,%0"
6475   [(set_attr "type" "fpmuldbl")
6476    (set_attr "length" "4")])
6478 (define_insn ""
6479   [(set (match_operand:SF 0 "register_operand" "=f")
6480         (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
6481                           (match_operand:SF 2 "register_operand" "f"))
6482                  (match_operand:SF 3 "register_operand" "f")))]
6483   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6484   "fmpyfadd,sgl %1,%2,%3,%0"
6485   [(set_attr "type" "fpmulsgl")
6486    (set_attr "length" "4")])
6488 (define_insn ""
6489   [(set (match_operand:SF 0 "register_operand" "=f")
6490         (plus:SF (match_operand:SF 1 "register_operand" "f")
6491                  (mult:SF (match_operand:SF 2 "register_operand" "f")
6492                           (match_operand:SF 3 "register_operand" "f"))))]
6493   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6494   "fmpyfadd,sgl %2,%3,%1,%0"
6495   [(set_attr "type" "fpmulsgl")
6496    (set_attr "length" "4")])
6498 ; fmpynfadd patterns
6499 (define_insn ""
6500   [(set (match_operand:DF 0 "register_operand" "=f")
6501         (minus:DF (match_operand:DF 1 "register_operand" "f")
6502                   (mult:DF (match_operand:DF 2 "register_operand" "f")
6503                            (match_operand:DF 3 "register_operand" "f"))))]
6504   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6505   "fmpynfadd,dbl %2,%3,%1,%0"
6506   [(set_attr "type" "fpmuldbl")
6507    (set_attr "length" "4")])
6509 (define_insn ""
6510   [(set (match_operand:SF 0 "register_operand" "=f")
6511         (minus:SF (match_operand:SF 1 "register_operand" "f")
6512                   (mult:SF (match_operand:SF 2 "register_operand" "f")
6513                            (match_operand:SF 3 "register_operand" "f"))))]
6514   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6515   "fmpynfadd,sgl %2,%3,%1,%0"
6516   [(set_attr "type" "fpmulsgl")
6517    (set_attr "length" "4")])
6519 ; fnegabs patterns
6520 (define_insn ""
6521   [(set (match_operand:DF 0 "register_operand" "=f")
6522         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))]
6523   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6524   "fnegabs,dbl %1,%0"
6525   [(set_attr "type" "fpalu")
6526    (set_attr "length" "4")])
6528 (define_insn ""
6529   [(set (match_operand:SF 0 "register_operand" "=f")
6530         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))]
6531   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6532   "fnegabs,sgl %1,%0"
6533   [(set_attr "type" "fpalu")
6534    (set_attr "length" "4")])
6536 ;; Generating a fused multiply sequence is a win for this case as it will
6537 ;; reduce the latency for the fused case without impacting the plain
6538 ;; multiply case.
6540 ;; Similar possibilities exist for fnegabs, shadd and other insns which
6541 ;; perform two operations with the result of the first feeding the second.
6542 (define_insn ""
6543   [(set (match_operand:DF 0 "register_operand" "=f")
6544         (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
6545                           (match_operand:DF 2 "register_operand" "f"))
6546                  (match_operand:DF 3 "register_operand" "f")))
6547    (set (match_operand:DF 4 "register_operand" "=&f")
6548         (mult:DF (match_dup 1) (match_dup 2)))]
6549   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6550     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
6551           || reg_overlap_mentioned_p (operands[4], operands[2])))"
6552   "#"
6553   [(set_attr "type" "fpmuldbl")
6554    (set_attr "length" "8")])
6556 ;; We want to split this up during scheduling since we want both insns
6557 ;; to schedule independently.
6558 (define_split
6559   [(set (match_operand:DF 0 "register_operand" "")
6560         (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "")
6561                           (match_operand:DF 2 "register_operand" ""))
6562                  (match_operand:DF 3 "register_operand" "")))
6563    (set (match_operand:DF 4 "register_operand" "")
6564         (mult:DF (match_dup 1) (match_dup 2)))]
6565   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6566   [(set (match_dup 4) (mult:DF (match_dup 1) (match_dup 2)))
6567    (set (match_dup 0) (plus:DF (mult:DF (match_dup 1) (match_dup 2))
6568                                (match_dup 3)))]
6569   "")
6571 (define_insn ""
6572   [(set (match_operand:SF 0 "register_operand" "=f")
6573         (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
6574                           (match_operand:SF 2 "register_operand" "f"))
6575                  (match_operand:SF 3 "register_operand" "f")))
6576    (set (match_operand:SF 4 "register_operand" "=&f")
6577         (mult:SF (match_dup 1) (match_dup 2)))]
6578   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6579     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
6580           || reg_overlap_mentioned_p (operands[4], operands[2])))"
6581   "#"
6582   [(set_attr "type" "fpmuldbl")
6583    (set_attr "length" "8")])
6585 ;; We want to split this up during scheduling since we want both insns
6586 ;; to schedule independently.
6587 (define_split
6588   [(set (match_operand:SF 0 "register_operand" "")
6589         (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "")
6590                           (match_operand:SF 2 "register_operand" ""))
6591                  (match_operand:SF 3 "register_operand" "")))
6592    (set (match_operand:SF 4 "register_operand" "")
6593         (mult:SF (match_dup 1) (match_dup 2)))]
6594   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6595   [(set (match_dup 4) (mult:SF (match_dup 1) (match_dup 2)))
6596    (set (match_dup 0) (plus:SF (mult:SF (match_dup 1) (match_dup 2))
6597                                (match_dup 3)))]
6598   "")
6600 ;; Negating a multiply can be faked by adding zero in a fused multiply-add
6601 ;; instruction.
6602 (define_insn ""
6603   [(set (match_operand:DF 0 "register_operand" "=f")
6604         (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
6605                          (match_operand:DF 2 "register_operand" "f"))))]
6606   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6607   "fmpynfadd,dbl %1,%2,%%fr0,%0"
6608   [(set_attr "type" "fpmuldbl")
6609    (set_attr "length" "4")])
6611 (define_insn ""
6612   [(set (match_operand:SF 0 "register_operand" "=f")
6613         (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
6614                          (match_operand:SF 2 "register_operand" "f"))))]
6615   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6616   "fmpynfadd,sgl %1,%2,%%fr0,%0"
6617   [(set_attr "type" "fpmuldbl")
6618    (set_attr "length" "4")])
6620 (define_insn ""
6621   [(set (match_operand:DF 0 "register_operand" "=f")
6622         (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
6623                          (match_operand:DF 2 "register_operand" "f"))))
6624    (set (match_operand:DF 3 "register_operand" "=&f")
6625         (mult:DF (match_dup 1) (match_dup 2)))]
6626   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6627     && ! (reg_overlap_mentioned_p (operands[3], operands[1])
6628           || reg_overlap_mentioned_p (operands[3], operands[2])))"
6629   "#"
6630   [(set_attr "type" "fpmuldbl")
6631    (set_attr "length" "8")])
6633 (define_split
6634   [(set (match_operand:DF 0 "register_operand" "")
6635         (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "")
6636                          (match_operand:DF 2 "register_operand" ""))))
6637    (set (match_operand:DF 3 "register_operand" "")
6638         (mult:DF (match_dup 1) (match_dup 2)))]
6639   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6640   [(set (match_dup 3) (mult:DF (match_dup 1) (match_dup 2)))
6641    (set (match_dup 0) (neg:DF (mult:DF (match_dup 1) (match_dup 2))))]
6642   "")
6644 (define_insn ""
6645   [(set (match_operand:SF 0 "register_operand" "=f")
6646         (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
6647                          (match_operand:SF 2 "register_operand" "f"))))
6648    (set (match_operand:SF 3 "register_operand" "=&f")
6649         (mult:SF (match_dup 1) (match_dup 2)))]
6650   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6651     && ! (reg_overlap_mentioned_p (operands[3], operands[1])
6652           || reg_overlap_mentioned_p (operands[3], operands[2])))"
6653   "#"
6654   [(set_attr "type" "fpmuldbl")
6655    (set_attr "length" "8")])
6657 (define_split
6658   [(set (match_operand:SF 0 "register_operand" "")
6659         (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "")
6660                          (match_operand:SF 2 "register_operand" ""))))
6661    (set (match_operand:SF 3 "register_operand" "")
6662         (mult:SF (match_dup 1) (match_dup 2)))]
6663   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6664   [(set (match_dup 3) (mult:SF (match_dup 1) (match_dup 2)))
6665    (set (match_dup 0) (neg:SF (mult:SF (match_dup 1) (match_dup 2))))]
6666   "")
6668 ;; Now fused multiplies with the result of the multiply negated.
6669 (define_insn ""
6670   [(set (match_operand:DF 0 "register_operand" "=f")
6671         (plus:DF (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
6672                                   (match_operand:DF 2 "register_operand" "f")))
6673                  (match_operand:DF 3 "register_operand" "f")))]
6674   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6675   "fmpynfadd,dbl %1,%2,%3,%0"
6676   [(set_attr "type" "fpmuldbl")
6677    (set_attr "length" "4")])
6679 (define_insn ""
6680   [(set (match_operand:SF 0 "register_operand" "=f")
6681         (plus:SF (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
6682                          (match_operand:SF 2 "register_operand" "f")))
6683                  (match_operand:SF 3 "register_operand" "f")))]
6684   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6685   "fmpynfadd,sgl %1,%2,%3,%0"
6686   [(set_attr "type" "fpmuldbl")
6687    (set_attr "length" "4")])
6689 (define_insn ""
6690   [(set (match_operand:DF 0 "register_operand" "=f")
6691         (plus:DF (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
6692                                   (match_operand:DF 2 "register_operand" "f")))
6693                  (match_operand:DF 3 "register_operand" "f")))
6694    (set (match_operand:DF 4 "register_operand" "=&f")
6695         (mult:DF (match_dup 1) (match_dup 2)))]
6696   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6697     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
6698           || reg_overlap_mentioned_p (operands[4], operands[2])))"
6699   "#"
6700   [(set_attr "type" "fpmuldbl")
6701    (set_attr "length" "8")])
6703 (define_split
6704   [(set (match_operand:DF 0 "register_operand" "")
6705         (plus:DF (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "")
6706                                   (match_operand:DF 2 "register_operand" "")))
6707                  (match_operand:DF 3 "register_operand" "")))
6708    (set (match_operand:DF 4 "register_operand" "")
6709         (mult:DF (match_dup 1) (match_dup 2)))]
6710   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6711   [(set (match_dup 4) (mult:DF (match_dup 1) (match_dup 2)))
6712    (set (match_dup 0) (plus:DF (neg:DF (mult:DF (match_dup 1) (match_dup 2)))
6713                                (match_dup 3)))]
6714   "")
6716 (define_insn ""
6717   [(set (match_operand:SF 0 "register_operand" "=f")
6718         (plus:SF (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
6719                                   (match_operand:SF 2 "register_operand" "f")))
6720                  (match_operand:SF 3 "register_operand" "f")))
6721    (set (match_operand:SF 4 "register_operand" "=&f")
6722         (mult:SF (match_dup 1) (match_dup 2)))]
6723   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6724     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
6725           || reg_overlap_mentioned_p (operands[4], operands[2])))"
6726   "#"
6727   [(set_attr "type" "fpmuldbl")
6728    (set_attr "length" "8")])
6730 (define_split
6731   [(set (match_operand:SF 0 "register_operand" "")
6732         (plus:SF (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "")
6733                                   (match_operand:SF 2 "register_operand" "")))
6734                  (match_operand:SF 3 "register_operand" "")))
6735    (set (match_operand:SF 4 "register_operand" "")
6736         (mult:SF (match_dup 1) (match_dup 2)))]
6737   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6738   [(set (match_dup 4) (mult:SF (match_dup 1) (match_dup 2)))
6739    (set (match_dup 0) (plus:SF (neg:SF (mult:SF (match_dup 1) (match_dup 2)))
6740                                (match_dup 3)))]
6741   "")
6743 (define_insn ""
6744   [(set (match_operand:DF 0 "register_operand" "=f")
6745         (minus:DF (match_operand:DF 3 "register_operand" "f")
6746                   (mult:DF (match_operand:DF 1 "register_operand" "f")
6747                            (match_operand:DF 2 "register_operand" "f"))))
6748    (set (match_operand:DF 4 "register_operand" "=&f")
6749         (mult:DF (match_dup 1) (match_dup 2)))]
6750   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6751     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
6752           || reg_overlap_mentioned_p (operands[4], operands[2])))"
6753   "#"
6754   [(set_attr "type" "fpmuldbl")
6755    (set_attr "length" "8")])
6757 (define_split
6758   [(set (match_operand:DF 0 "register_operand" "")
6759         (minus:DF (match_operand:DF 3 "register_operand" "")
6760                   (mult:DF (match_operand:DF 1 "register_operand" "")
6761                            (match_operand:DF 2 "register_operand" ""))))
6762    (set (match_operand:DF 4 "register_operand" "")
6763         (mult:DF (match_dup 1) (match_dup 2)))]
6764   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6765   [(set (match_dup 4) (mult:DF (match_dup 1) (match_dup 2)))
6766    (set (match_dup 0) (minus:DF (match_dup 3)
6767                                 (mult:DF (match_dup 1) (match_dup 2))))]
6768   "")
6770 (define_insn ""
6771   [(set (match_operand:SF 0 "register_operand" "=f")
6772         (minus:SF (match_operand:SF 3 "register_operand" "f")
6773                   (mult:SF (match_operand:SF 1 "register_operand" "f")
6774                            (match_operand:SF 2 "register_operand" "f"))))
6775    (set (match_operand:SF 4 "register_operand" "=&f")
6776         (mult:SF (match_dup 1) (match_dup 2)))]
6777   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6778     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
6779           || reg_overlap_mentioned_p (operands[4], operands[2])))"
6780   "#"
6781   [(set_attr "type" "fpmuldbl")
6782    (set_attr "length" "8")])
6784 (define_split
6785   [(set (match_operand:SF 0 "register_operand" "")
6786         (minus:SF (match_operand:SF 3 "register_operand" "")
6787                   (mult:SF (match_operand:SF 1 "register_operand" "")
6788                            (match_operand:SF 2 "register_operand" ""))))
6789    (set (match_operand:SF 4 "register_operand" "")
6790         (mult:SF (match_dup 1) (match_dup 2)))]
6791   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6792   [(set (match_dup 4) (mult:SF (match_dup 1) (match_dup 2)))
6793    (set (match_dup 0) (minus:SF (match_dup 3)
6794                                 (mult:SF (match_dup 1) (match_dup 2))))]
6795   "")
6797 (define_insn ""
6798   [(set (match_operand:DF 0 "register_operand" "=f")
6799         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))
6800    (set (match_operand:DF 2 "register_operand" "=&f") (abs:DF (match_dup 1)))]
6801   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6802     && ! reg_overlap_mentioned_p (operands[2], operands[1]))"
6803   "#"
6804   [(set_attr "type" "fpalu")
6805    (set_attr "length" "8")])
6807 (define_split
6808   [(set (match_operand:DF 0 "register_operand" "")
6809         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" ""))))
6810    (set (match_operand:DF 2 "register_operand" "") (abs:DF (match_dup 1)))]
6811   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6812   [(set (match_dup 2) (abs:DF (match_dup 1)))
6813    (set (match_dup 0) (neg:DF (abs:DF (match_dup 1))))]
6814   "")
6816 (define_insn ""
6817   [(set (match_operand:SF 0 "register_operand" "=f")
6818         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))
6819    (set (match_operand:SF 2 "register_operand" "=&f") (abs:SF (match_dup 1)))]
6820   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6821     && ! reg_overlap_mentioned_p (operands[2], operands[1]))"
6822   "#"
6823   [(set_attr "type" "fpalu")
6824    (set_attr "length" "8")])
6826 (define_split
6827   [(set (match_operand:SF 0 "register_operand" "")
6828         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" ""))))
6829    (set (match_operand:SF 2 "register_operand" "") (abs:SF (match_dup 1)))]
6830   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6831   [(set (match_dup 2) (abs:SF (match_dup 1)))
6832    (set (match_dup 0) (neg:SF (abs:SF (match_dup 1))))]
6833   "")
6835 ;;- Shift instructions
6837 ;; Optimized special case of shifting.
6839 (define_insn ""
6840   [(set (match_operand:SI 0 "register_operand" "=r")
6841         (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
6842                      (const_int 24)))]
6843   ""
6844   "ldb%M1 %1,%0"
6845   [(set_attr "type" "load")
6846    (set_attr "length" "4")])
6848 (define_insn ""
6849   [(set (match_operand:SI 0 "register_operand" "=r")
6850         (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
6851                      (const_int 16)))]
6852   ""
6853   "ldh%M1 %1,%0"
6854   [(set_attr "type" "load")
6855    (set_attr "length" "4")])
6857 (define_insn ""
6858   [(set (match_operand:SI 0 "register_operand" "=r")
6859         (plus:SI (mult:SI (match_operand:SI 2 "register_operand" "r")
6860                           (match_operand:SI 3 "shadd_operand" ""))
6861                  (match_operand:SI 1 "register_operand" "r")))]
6862   ""
6863   "{sh%O3addl %2,%1,%0|shladd,l %2,%O3,%1,%0} "
6864   [(set_attr "type" "binary")
6865    (set_attr "length" "4")])
6867 (define_insn ""
6868   [(set (match_operand:DI 0 "register_operand" "=r")
6869         (plus:DI (mult:DI (match_operand:DI 2 "register_operand" "r")
6870                           (match_operand:DI 3 "shadd_operand" ""))
6871                  (match_operand:DI 1 "register_operand" "r")))]
6872   "TARGET_64BIT"
6873   "shladd,l %2,%O3,%1,%0"
6874   [(set_attr "type" "binary")
6875    (set_attr "length" "4")])
6877 (define_expand "ashlsi3"
6878   [(set (match_operand:SI 0 "register_operand" "")
6879         (ashift:SI (match_operand:SI 1 "lhs_lshift_operand" "")
6880                    (match_operand:SI 2 "arith32_operand" "")))]
6881   ""
6882   "
6884   if (GET_CODE (operands[2]) != CONST_INT)
6885     {
6886       rtx temp = gen_reg_rtx (SImode);
6887       emit_insn (gen_subsi3 (temp, GEN_INT (31), operands[2]));
6888       if (GET_CODE (operands[1]) == CONST_INT)
6889         emit_insn (gen_zvdep_imm32 (operands[0], operands[1], temp));
6890       else
6891         emit_insn (gen_zvdep32 (operands[0], operands[1], temp));
6892       DONE;
6893     }
6894   /* Make sure both inputs are not constants,
6895      there are no patterns for that.  */
6896   operands[1] = force_reg (SImode, operands[1]);
6899 (define_insn ""
6900   [(set (match_operand:SI 0 "register_operand" "=r")
6901         (ashift:SI (match_operand:SI 1 "register_operand" "r")
6902                    (match_operand:SI 2 "const_int_operand" "n")))]
6903   ""
6904   "{zdep|depw,z} %1,%P2,%L2,%0"
6905   [(set_attr "type" "shift")
6906    (set_attr "length" "4")])
6908 ; Match cases of op1 a CONST_INT here that zvdep_imm32 doesn't handle.
6909 ; Doing it like this makes slightly better code since reload can
6910 ; replace a register with a known value in range -16..15 with a
6911 ; constant.  Ideally, we would like to merge zvdep32 and zvdep_imm32,
6912 ; but since we have no more CONST_OK... characters, that is not
6913 ; possible.
6914 (define_insn "zvdep32"
6915   [(set (match_operand:SI 0 "register_operand" "=r,r")
6916         (ashift:SI (match_operand:SI 1 "arith5_operand" "r,L")
6917                    (minus:SI (const_int 31)
6918                              (match_operand:SI 2 "register_operand" "q,q"))))]
6919   ""
6920   "@
6921    {zvdep %1,32,%0|depw,z %1,%%sar,32,%0}
6922    {zvdepi %1,32,%0|depwi,z %1,%%sar,32,%0}"
6923   [(set_attr "type" "shift,shift")
6924    (set_attr "length" "4,4")])
6926 (define_insn "zvdep_imm32"
6927   [(set (match_operand:SI 0 "register_operand" "=r")
6928         (ashift:SI (match_operand:SI 1 "lhs_lshift_cint_operand" "")
6929                    (minus:SI (const_int 31)
6930                              (match_operand:SI 2 "register_operand" "q"))))]
6931   ""
6932   "*
6934   int x = INTVAL (operands[1]);
6935   operands[2] = GEN_INT (4 + exact_log2 ((x >> 4) + 1));
6936   operands[1] = GEN_INT ((x & 0xf) - 0x10);
6937   return \"{zvdepi %1,%2,%0|depwi,z %1,%%sar,%2,%0}\";
6939   [(set_attr "type" "shift")
6940    (set_attr "length" "4")])
6942 (define_insn "vdepi_ior"
6943   [(set (match_operand:SI 0 "register_operand" "=r")
6944         (ior:SI (ashift:SI (match_operand:SI 1 "const_int_operand" "")
6945                            (minus:SI (const_int 31)
6946                                      (match_operand:SI 2 "register_operand" "q")))
6947                 (match_operand:SI 3 "register_operand" "0")))]
6948   ; accept ...0001...1, can this be generalized?
6949   "exact_log2 (INTVAL (operands[1]) + 1) > 0"
6950   "*
6952   int x = INTVAL (operands[1]);
6953   operands[2] = GEN_INT (exact_log2 (x + 1));
6954   return \"{vdepi -1,%2,%0|depwi -1,%%sar,%2,%0}\";
6956   [(set_attr "type" "shift")
6957    (set_attr "length" "4")])
6959 (define_insn "vdepi_and"
6960   [(set (match_operand:SI 0 "register_operand" "=r")
6961         (and:SI (rotate:SI (match_operand:SI 1 "const_int_operand" "")
6962                            (minus:SI (const_int 31)
6963                                      (match_operand:SI 2 "register_operand" "q")))
6964                 (match_operand:SI 3 "register_operand" "0")))]
6965   ; this can be generalized...!
6966   "INTVAL (operands[1]) == -2"
6967   "*
6969   int x = INTVAL (operands[1]);
6970   operands[2] = GEN_INT (exact_log2 ((~x) + 1));
6971   return \"{vdepi 0,%2,%0|depwi 0,%%sar,%2,%0}\";
6973   [(set_attr "type" "shift")
6974    (set_attr "length" "4")])
6976 (define_expand "ashldi3"
6977   [(set (match_operand:DI 0 "register_operand" "")
6978         (ashift:DI (match_operand:DI 1 "lhs_lshift_operand" "")
6979                    (match_operand:DI 2 "arith32_operand" "")))]
6980   "TARGET_64BIT"
6981   "
6983   if (GET_CODE (operands[2]) != CONST_INT)
6984     {
6985       rtx temp = gen_reg_rtx (DImode);
6986       emit_insn (gen_subdi3 (temp, GEN_INT (63), operands[2]));
6987       if (GET_CODE (operands[1]) == CONST_INT)
6988         emit_insn (gen_zvdep_imm64 (operands[0], operands[1], temp));
6989       else
6990         emit_insn (gen_zvdep64 (operands[0], operands[1], temp));
6991       DONE;
6992     }
6993   /* Make sure both inputs are not constants,
6994      there are no patterns for that.  */
6995   operands[1] = force_reg (DImode, operands[1]);
6998 (define_insn ""
6999   [(set (match_operand:DI 0 "register_operand" "=r")
7000         (ashift:DI (match_operand:DI 1 "register_operand" "r")
7001                    (match_operand:DI 2 "const_int_operand" "n")))]
7002   "TARGET_64BIT"
7003   "depd,z %1,%p2,%Q2,%0"
7004   [(set_attr "type" "shift")
7005    (set_attr "length" "4")])
7007 ; Match cases of op1 a CONST_INT here that zvdep_imm64 doesn't handle.
7008 ; Doing it like this makes slightly better code since reload can
7009 ; replace a register with a known value in range -16..15 with a
7010 ; constant.  Ideally, we would like to merge zvdep64 and zvdep_imm64,
7011 ; but since we have no more CONST_OK... characters, that is not
7012 ; possible.
7013 (define_insn "zvdep64"
7014   [(set (match_operand:DI 0 "register_operand" "=r,r")
7015         (ashift:DI (match_operand:DI 1 "arith5_operand" "r,L")
7016                    (minus:DI (const_int 63)
7017                              (match_operand:DI 2 "register_operand" "q,q"))))]
7018   "TARGET_64BIT"
7019   "@
7020    depd,z %1,%%sar,64,%0
7021    depdi,z %1,%%sar,64,%0"
7022   [(set_attr "type" "shift,shift")
7023    (set_attr "length" "4,4")])
7025 (define_insn "zvdep_imm64"
7026   [(set (match_operand:DI 0 "register_operand" "=r")
7027         (ashift:DI (match_operand:DI 1 "lhs_lshift_cint_operand" "")
7028                    (minus:DI (const_int 63)
7029                              (match_operand:DI 2 "register_operand" "q"))))]
7030   "TARGET_64BIT"
7031   "*
7033   int x = INTVAL (operands[1]);
7034   operands[2] = GEN_INT (4 + exact_log2 ((x >> 4) + 1));
7035   operands[1] = GEN_INT ((x & 0x1f) - 0x20);
7036   return \"depdi,z %1,%%sar,%2,%0\";
7038   [(set_attr "type" "shift")
7039    (set_attr "length" "4")])
7041 (define_insn ""
7042   [(set (match_operand:DI 0 "register_operand" "=r")
7043         (ior:DI (ashift:DI (match_operand:DI 1 "const_int_operand" "")
7044                            (minus:DI (const_int 63)
7045                                      (match_operand:DI 2 "register_operand" "q")))
7046                 (match_operand:DI 3 "register_operand" "0")))]
7047   ; accept ...0001...1, can this be generalized?
7048   "TARGET_64BIT && exact_log2 (INTVAL (operands[1]) + 1) > 0"
7049   "*
7051   int x = INTVAL (operands[1]);
7052   operands[2] = GEN_INT (exact_log2 (x + 1));
7053   return \"depdi -1,%%sar,%2,%0\";
7055   [(set_attr "type" "shift")
7056    (set_attr "length" "4")])
7058 (define_insn ""
7059   [(set (match_operand:DI 0 "register_operand" "=r")
7060         (and:DI (rotate:DI (match_operand:DI 1 "const_int_operand" "")
7061                            (minus:DI (const_int 63)
7062                                      (match_operand:DI 2 "register_operand" "q")))
7063                 (match_operand:DI 3 "register_operand" "0")))]
7064   ; this can be generalized...!
7065   "TARGET_64BIT && INTVAL (operands[1]) == -2"
7066   "*
7068   int x = INTVAL (operands[1]);
7069   operands[2] = GEN_INT (exact_log2 ((~x) + 1));
7070   return \"depdi 0,%%sar,%2,%0\";
7072   [(set_attr "type" "shift")
7073    (set_attr "length" "4")])
7075 (define_expand "ashrsi3"
7076   [(set (match_operand:SI 0 "register_operand" "")
7077         (ashiftrt:SI (match_operand:SI 1 "register_operand" "")
7078                      (match_operand:SI 2 "arith32_operand" "")))]
7079   ""
7080   "
7082   if (GET_CODE (operands[2]) != CONST_INT)
7083     {
7084       rtx temp = gen_reg_rtx (SImode);
7085       emit_insn (gen_subsi3 (temp, GEN_INT (31), operands[2]));
7086       emit_insn (gen_vextrs32 (operands[0], operands[1], temp));
7087       DONE;
7088     }
7091 (define_insn ""
7092   [(set (match_operand:SI 0 "register_operand" "=r")
7093         (ashiftrt:SI (match_operand:SI 1 "register_operand" "r")
7094                      (match_operand:SI 2 "const_int_operand" "n")))]
7095   ""
7096   "{extrs|extrw,s} %1,%P2,%L2,%0"
7097   [(set_attr "type" "shift")
7098    (set_attr "length" "4")])
7100 (define_insn "vextrs32"
7101   [(set (match_operand:SI 0 "register_operand" "=r")
7102         (ashiftrt:SI (match_operand:SI 1 "register_operand" "r")
7103                      (minus:SI (const_int 31)
7104                                (match_operand:SI 2 "register_operand" "q"))))]
7105   ""
7106   "{vextrs %1,32,%0|extrw,s %1,%%sar,32,%0}"
7107   [(set_attr "type" "shift")
7108    (set_attr "length" "4")])
7110 (define_expand "ashrdi3"
7111   [(set (match_operand:DI 0 "register_operand" "")
7112         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
7113                      (match_operand:DI 2 "arith32_operand" "")))]
7114   "TARGET_64BIT"
7115   "
7117   if (GET_CODE (operands[2]) != CONST_INT)
7118     {
7119       rtx temp = gen_reg_rtx (DImode);
7120       emit_insn (gen_subdi3 (temp, GEN_INT (63), operands[2]));
7121       emit_insn (gen_vextrs64 (operands[0], operands[1], temp));
7122       DONE;
7123     }
7126 (define_insn ""
7127   [(set (match_operand:DI 0 "register_operand" "=r")
7128         (ashiftrt:DI (match_operand:DI 1 "register_operand" "r")
7129                      (match_operand:DI 2 "const_int_operand" "n")))]
7130   "TARGET_64BIT"
7131   "extrd,s %1,%p2,%Q2,%0"
7132   [(set_attr "type" "shift")
7133    (set_attr "length" "4")])
7135 (define_insn "vextrs64"
7136   [(set (match_operand:DI 0 "register_operand" "=r")
7137         (ashiftrt:DI (match_operand:DI 1 "register_operand" "r")
7138                      (minus:DI (const_int 63)
7139                                (match_operand:DI 2 "register_operand" "q"))))]
7140   "TARGET_64BIT"
7141   "extrd,s %1,%%sar,64,%0"
7142   [(set_attr "type" "shift")
7143    (set_attr "length" "4")])
7145 (define_insn "lshrsi3"
7146   [(set (match_operand:SI 0 "register_operand" "=r,r")
7147         (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
7148                      (match_operand:SI 2 "arith32_operand" "q,n")))]
7149   ""
7150   "@
7151    {vshd %%r0,%1,%0|shrpw %%r0,%1,%%sar,%0}
7152    {extru|extrw,u} %1,%P2,%L2,%0"
7153   [(set_attr "type" "shift")
7154    (set_attr "length" "4")])
7156 (define_insn "lshrdi3"
7157   [(set (match_operand:DI 0 "register_operand" "=r,r")
7158         (lshiftrt:DI (match_operand:DI 1 "register_operand" "r,r")
7159                      (match_operand:DI 2 "arith32_operand" "q,n")))]
7160   "TARGET_64BIT"
7161   "@
7162    shrpd %%r0,%1,%%sar,%0
7163    extrd,u %1,%p2,%Q2,%0"
7164   [(set_attr "type" "shift")
7165    (set_attr "length" "4")])
7167 (define_insn "rotrsi3"
7168   [(set (match_operand:SI 0 "register_operand" "=r,r")
7169         (rotatert:SI (match_operand:SI 1 "register_operand" "r,r")
7170                      (match_operand:SI 2 "arith32_operand" "q,n")))]
7171   ""
7172   "*
7174   if (GET_CODE (operands[2]) == CONST_INT)
7175     {
7176       operands[2] = GEN_INT (INTVAL (operands[2]) & 31);
7177       return \"{shd|shrpw} %1,%1,%2,%0\";
7178     }
7179   else
7180     return \"{vshd %1,%1,%0|shrpw %1,%1,%%sar,%0}\";
7182   [(set_attr "type" "shift")
7183    (set_attr "length" "4")])
7185 (define_expand "rotlsi3"
7186   [(set (match_operand:SI 0 "register_operand" "")
7187         (rotate:SI (match_operand:SI 1 "register_operand" "")
7188                    (match_operand:SI 2 "arith32_operand" "")))]
7189   ""
7190   "
7192   if (GET_CODE (operands[2]) != CONST_INT)
7193     {
7194       rtx temp = gen_reg_rtx (SImode);
7195       emit_insn (gen_subsi3 (temp, GEN_INT (32), operands[2]));
7196       emit_insn (gen_rotrsi3 (operands[0], operands[1], temp));
7197       DONE;
7198     }
7199   /* Else expand normally.  */
7202 (define_insn ""
7203   [(set (match_operand:SI 0 "register_operand" "=r")
7204         (rotate:SI (match_operand:SI 1 "register_operand" "r")
7205                    (match_operand:SI 2 "const_int_operand" "n")))]
7206   ""
7207   "*
7209   operands[2] = GEN_INT ((32 - INTVAL (operands[2])) & 31);
7210   return \"{shd|shrpw} %1,%1,%2,%0\";
7212   [(set_attr "type" "shift")
7213    (set_attr "length" "4")])
7215 (define_insn ""
7216   [(set (match_operand:SI 0 "register_operand" "=r")
7217         (match_operator:SI 5 "plus_xor_ior_operator"
7218           [(ashift:SI (match_operand:SI 1 "register_operand" "r")
7219                       (match_operand:SI 3 "const_int_operand" "n"))
7220            (lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
7221                         (match_operand:SI 4 "const_int_operand" "n"))]))]
7222   "INTVAL (operands[3]) + INTVAL (operands[4]) == 32"
7223   "{shd|shrpw} %1,%2,%4,%0"
7224   [(set_attr "type" "shift")
7225    (set_attr "length" "4")])
7227 (define_insn ""
7228   [(set (match_operand:SI 0 "register_operand" "=r")
7229         (match_operator:SI 5 "plus_xor_ior_operator"
7230           [(lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
7231                         (match_operand:SI 4 "const_int_operand" "n"))
7232            (ashift:SI (match_operand:SI 1 "register_operand" "r")
7233                       (match_operand:SI 3 "const_int_operand" "n"))]))]
7234   "INTVAL (operands[3]) + INTVAL (operands[4]) == 32"
7235   "{shd|shrpw} %1,%2,%4,%0"
7236   [(set_attr "type" "shift")
7237    (set_attr "length" "4")])
7239 (define_insn ""
7240   [(set (match_operand:SI 0 "register_operand" "=r")
7241         (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
7242                            (match_operand:SI 2 "const_int_operand" ""))
7243                 (match_operand:SI 3 "const_int_operand" "")))]
7244   "exact_log2 (1 + (INTVAL (operands[3]) >> (INTVAL (operands[2]) & 31))) > 0"
7245   "*
7247   int cnt = INTVAL (operands[2]) & 31;
7248   operands[3] = GEN_INT (exact_log2 (1 + (INTVAL (operands[3]) >> cnt)));
7249   operands[2] = GEN_INT (31 - cnt);
7250   return \"{zdep|depw,z} %1,%2,%3,%0\";
7252   [(set_attr "type" "shift")
7253    (set_attr "length" "4")])
7255 ;; Unconditional and other jump instructions.
7257 ;; This is used for most returns.
7258 (define_insn "return_internal"
7259   [(return)
7260    (use (reg:SI 2))]
7261   ""
7262   "*
7264   if (TARGET_PA_20)
7265     return \"bve%* (%%r2)\";
7266   return \"bv%* %%r0(%%r2)\";
7268   [(set_attr "type" "branch")
7269    (set_attr "length" "4")])
7271 ;; This is used for eh returns which bypass the return stub.
7272 (define_insn "return_external_pic"
7273   [(return)
7274    (clobber (reg:SI 1))
7275    (use (reg:SI 2))]
7276   "!TARGET_NO_SPACE_REGS
7277    && !TARGET_PA_20
7278    && flag_pic && crtl->calls_eh_return"
7279   "ldsid (%%sr0,%%r2),%%r1\;mtsp %%r1,%%sr0\;be%* 0(%%sr0,%%r2)"
7280   [(set_attr "type" "branch")
7281    (set_attr "length" "12")])
7283 (define_expand "prologue"
7284   [(const_int 0)]
7285   ""
7286   "hppa_expand_prologue ();DONE;")
7288 (define_expand "sibcall_epilogue"
7289   [(return)]
7290   ""
7291   "
7293   hppa_expand_epilogue ();
7294   DONE;
7297 (define_expand "epilogue"
7298   [(return)]
7299   ""
7300   "
7302   rtx x;
7304   /* Try to use the trivial return first.  Else use the full epilogue.  */
7305   if (reload_completed
7306       && !frame_pointer_needed
7307       && !df_regs_ever_live_p (2)
7308       && (compute_frame_size (get_frame_size (), 0) ? 0 : 1))
7309     x = gen_return_internal ();
7310   else
7311     {
7312       hppa_expand_epilogue ();
7314       /* EH returns bypass the normal return stub.  Thus, we must do an
7315          interspace branch to return from functions that call eh_return.
7316          This is only a problem for returns from shared code on ports
7317          using space registers.  */
7318       if (!TARGET_NO_SPACE_REGS
7319           && !TARGET_PA_20
7320           && flag_pic && crtl->calls_eh_return)
7321         x = gen_return_external_pic ();
7322       else
7323         x = gen_return_internal ();
7324     }
7325   emit_jump_insn (x);
7326   DONE;
7329 ; Used by hppa_profile_hook to load the starting address of the current
7330 ; function; operand 1 contains the address of the label in operand 3
7331 (define_insn "load_offset_label_address"
7332   [(set (match_operand:SI 0 "register_operand" "=r")
7333         (plus:SI (match_operand:SI 1 "register_operand" "r")
7334                  (minus:SI (match_operand:SI 2 "" "")
7335                            (label_ref:SI (match_operand 3 "" "")))))]
7336   ""
7337   "ldo %2-%l3(%1),%0"
7338   [(set_attr "type" "multi")
7339    (set_attr "length" "4")])
7341 ; Output a code label and load its address.
7342 (define_insn "lcla1"
7343   [(set (match_operand:SI 0 "register_operand" "=r")
7344         (label_ref:SI (match_operand 1 "" "")))
7345    (const_int 0)]
7346   "!TARGET_PA_20"
7347   "*
7349   output_asm_insn (\"bl .+8,%0\;depi 0,31,2,%0\", operands);
7350   (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
7351                                      CODE_LABEL_NUMBER (operands[1]));
7352   return \"\";
7354   [(set_attr "type" "multi")
7355    (set_attr "length" "8")])
7357 (define_insn "lcla2"
7358   [(set (match_operand:SI 0 "register_operand" "=r")
7359         (label_ref:SI (match_operand 1 "" "")))
7360    (const_int 0)]
7361   "TARGET_PA_20"
7362   "*
7364   (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
7365                                      CODE_LABEL_NUMBER (operands[1]));
7366   return \"mfia %0\";
7368   [(set_attr "type" "move")
7369    (set_attr "length" "4")])
7371 (define_insn "blockage"
7372   [(unspec_volatile [(const_int 2)] UNSPECV_BLOCKAGE)]
7373   ""
7374   ""
7375   [(set_attr "length" "0")])
7377 (define_insn "jump"
7378   [(set (pc) (label_ref (match_operand 0 "" "")))]
7379   ""
7380   "*
7382   /* An unconditional branch which can reach its target.  */
7383   if (get_attr_length (insn) < 16)
7384     return \"b%* %l0\";
7386   return output_lbranch (operands[0], insn, 1);
7388   [(set_attr "type" "uncond_branch")
7389    (set_attr "pa_combine_type" "uncond_branch")
7390    (set (attr "length")
7391     (cond [(eq (symbol_ref "jump_in_call_delay (insn)") (const_int 1))
7392            (if_then_else (lt (abs (minus (match_dup 0)
7393                                          (plus (pc) (const_int 8))))
7394                              (const_int MAX_12BIT_OFFSET))
7395            (const_int 4)
7396            (const_int 8))
7397            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
7398                (const_int MAX_17BIT_OFFSET))
7399            (const_int 4)
7400            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
7401            (const_int 20)
7402            (eq (symbol_ref "flag_pic") (const_int 0))
7403            (const_int 16)]
7404           (const_int 24)))])
7406 ;;; Hope this is only within a function...
7407 (define_insn "indirect_jump"
7408   [(set (pc) (match_operand 0 "register_operand" "r"))]
7409   "GET_MODE (operands[0]) == word_mode"
7410   "bv%* %%r0(%0)"
7411   [(set_attr "type" "branch")
7412    (set_attr "length" "4")])
7414 ;;; An indirect jump can be optimized to a direct jump.  GAS for the
7415 ;;; SOM target doesn't allow branching to a label inside a function.
7416 ;;; We also don't correctly compute branch distances for labels
7417 ;;; outside the current function.  Thus, we use an indirect jump can't
7418 ;;; be optimized to a direct jump for all targets.  We assume that
7419 ;;; the branch target is in the same space (i.e., nested function
7420 ;;; jumping to a label in an outer function in the same translation
7421 ;;; unit).
7422 (define_expand "nonlocal_goto"
7423   [(use (match_operand 0 "general_operand" ""))
7424    (use (match_operand 1 "general_operand" ""))
7425    (use (match_operand 2 "general_operand" ""))
7426    (use (match_operand 3 "general_operand" ""))]
7427   ""
7429   rtx lab = operands[1];
7430   rtx stack = operands[2];
7431   rtx fp = operands[3];
7433   lab = copy_to_reg (lab);
7435   emit_clobber (gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (VOIDmode)));
7436   emit_clobber (gen_rtx_MEM (BLKmode, hard_frame_pointer_rtx));
7438   /* Restore the frame pointer.  The virtual_stack_vars_rtx is saved
7439      instead of the hard_frame_pointer_rtx in the save area.  As a
7440      result, an extra instruction is needed to adjust for the offset
7441      of the virtual stack variables and the frame pointer.  */
7442   if (GET_CODE (fp) != REG)
7443     fp = force_reg (Pmode, fp);
7444   emit_move_insn (virtual_stack_vars_rtx, fp);
7446   emit_stack_restore (SAVE_NONLOCAL, stack, NULL_RTX);
7448   emit_use (hard_frame_pointer_rtx);
7449   emit_use (stack_pointer_rtx);
7451   /* Nonlocal goto jumps are only used between functions in the same
7452      translation unit.  Thus, we can avoid the extra overhead of an
7453      interspace jump.  */
7454   emit_jump_insn (gen_indirect_goto (lab));
7455   emit_barrier ();
7456   DONE;
7459 (define_insn "indirect_goto"
7460   [(unspec [(match_operand 0 "register_operand" "=r")] UNSPEC_GOTO)]
7461   "GET_MODE (operands[0]) == word_mode"
7462   "bv%* %%r0(%0)"
7463   [(set_attr "type" "branch")
7464    (set_attr "length" "4")])
7466 ;;; This jump is used in branch tables where the insn length is fixed.
7467 ;;; The length of this insn is adjusted if the delay slot is not filled.
7468 (define_insn "short_jump"
7469   [(set (pc) (label_ref (match_operand 0 "" "")))
7470    (const_int 0)]
7471   ""
7472   "b%* %l0%#"
7473   [(set_attr "type" "btable_branch")
7474    (set_attr "length" "4")])
7476 ;; Subroutines of "casesi".
7477 ;; operand 0 is index
7478 ;; operand 1 is the minimum bound
7479 ;; operand 2 is the maximum bound - minimum bound + 1
7480 ;; operand 3 is CODE_LABEL for the table;
7481 ;; operand 4 is the CODE_LABEL to go to if index out of range.
7483 (define_expand "casesi"
7484   [(match_operand:SI 0 "general_operand" "")
7485    (match_operand:SI 1 "const_int_operand" "")
7486    (match_operand:SI 2 "const_int_operand" "")
7487    (match_operand 3 "" "")
7488    (match_operand 4 "" "")]
7489   ""
7490   "
7492   if (GET_CODE (operands[0]) != REG)
7493     operands[0] = force_reg (SImode, operands[0]);
7495   if (operands[1] != const0_rtx)
7496     {
7497       rtx index = gen_reg_rtx (SImode);
7499       operands[1] = GEN_INT (-INTVAL (operands[1]));
7500       if (!INT_14_BITS (operands[1]))
7501         operands[1] = force_reg (SImode, operands[1]);
7502       emit_insn (gen_addsi3 (index, operands[0], operands[1]));
7503       operands[0] = index;
7504     }
7506   /* In 64bit mode we must make sure to wipe the upper bits of the register
7507      just in case the addition overflowed or we had random bits in the
7508      high part of the register.  */
7509   if (TARGET_64BIT)
7510     {
7511       rtx index = gen_reg_rtx (DImode);
7513       emit_insn (gen_extendsidi2 (index, operands[0]));
7514       operands[0] = gen_rtx_SUBREG (SImode, index, 4);
7515     }
7517   if (!INT_5_BITS (operands[2]))
7518     operands[2] = force_reg (SImode, operands[2]);
7520   /* This branch prevents us finding an insn for the delay slot of the
7521      following vectored branch.  It might be possible to use the delay
7522      slot if an index value of -1 was used to transfer to the out-of-range
7523      label.  In order to do this, we would have to output the -1 vector
7524      element after the delay insn.  The casesi output code would have to
7525      check if the casesi insn is in a delay branch sequence and output
7526      the delay insn if one is found.  If this was done, then it might
7527      then be worthwhile to split the casesi patterns to improve scheduling.
7528      However, it's not clear that all this extra complexity is worth
7529      the effort.  */
7530   emit_insn (gen_cmpsi (operands[0], operands[2]));
7531   emit_jump_insn (gen_bgtu (operands[4]));
7533   if (TARGET_BIG_SWITCH)
7534     {
7535       if (TARGET_64BIT)
7536         emit_jump_insn (gen_casesi64p (operands[0], operands[3]));
7537       else if (flag_pic)
7538         emit_jump_insn (gen_casesi32p (operands[0], operands[3]));
7539       else
7540         emit_jump_insn (gen_casesi32 (operands[0], operands[3]));
7541     }
7542   else
7543     emit_jump_insn (gen_casesi0 (operands[0], operands[3]));
7544   DONE;
7547 ;;; The rtl for this pattern doesn't accurately describe what the insn
7548 ;;; actually does, particularly when case-vector elements are exploded
7549 ;;; in pa_reorg.  However, the initial SET in these patterns must show
7550 ;;; the connection of the insn to the following jump table.
7551 (define_insn "casesi0"
7552   [(set (pc) (mem:SI (plus:SI
7553                        (mult:SI (match_operand:SI 0 "register_operand" "r")
7554                                 (const_int 4))
7555                        (label_ref (match_operand 1 "" "")))))]
7556   ""
7557   "blr,n %0,%%r0\;nop"
7558   [(set_attr "type" "multi")
7559    (set_attr "length" "8")])
7561 ;;; 32-bit code, absolute branch table.
7562 (define_insn "casesi32"
7563   [(set (pc) (mem:SI (plus:SI
7564                        (mult:SI (match_operand:SI 0 "register_operand" "r")
7565                                 (const_int 4))
7566                        (label_ref (match_operand 1 "" "")))))
7567    (clobber (match_scratch:SI 2 "=&r"))]
7568   "!flag_pic"
7569   "ldil L'%l1,%2\;ldo R'%l1(%2),%2\;{ldwx|ldw},s %0(%2),%2\;bv,n %%r0(%2)"
7570   [(set_attr "type" "multi")
7571    (set_attr "length" "16")])
7573 ;;; 32-bit code, relative branch table.
7574 (define_insn "casesi32p"
7575   [(set (pc) (mem:SI (plus:SI
7576                        (mult:SI (match_operand:SI 0 "register_operand" "r")
7577                                 (const_int 4))
7578                        (label_ref (match_operand 1 "" "")))))
7579    (clobber (match_scratch:SI 2 "=&r"))
7580    (clobber (match_scratch:SI 3 "=&r"))]
7581   "flag_pic"
7582   "{bl .+8,%2\;depi 0,31,2,%2|mfia %2}\;ldo {16|20}(%2),%2\;\
7583 {ldwx|ldw},s %0(%2),%3\;{addl|add,l} %2,%3,%3\;bv,n %%r0(%3)"
7584   [(set_attr "type" "multi")
7585    (set (attr "length")
7586      (if_then_else (ne (symbol_ref "TARGET_PA_20") (const_int 0))
7587         (const_int 20)
7588         (const_int 24)))])
7590 ;;; 64-bit code, 32-bit relative branch table.
7591 (define_insn "casesi64p"
7592   [(set (pc) (mem:DI (plus:DI
7593                        (mult:DI (sign_extend:DI
7594                                   (match_operand:SI 0 "register_operand" "r"))
7595                                 (const_int 8))
7596                        (label_ref (match_operand 1 "" "")))))
7597    (clobber (match_scratch:DI 2 "=&r"))
7598    (clobber (match_scratch:DI 3 "=&r"))]
7599   ""
7600   "mfia %2\;ldo 24(%2),%2\;ldw,s %0(%2),%3\;extrd,s %3,63,32,%3\;\
7601 add,l %2,%3,%3\;bv,n %%r0(%3)"
7602   [(set_attr "type" "multi")
7603    (set_attr "length" "24")])
7606 ;; Call patterns.
7607 ;;- jump to subroutine
7609 (define_expand "call"
7610   [(parallel [(call (match_operand:SI 0 "" "")
7611                     (match_operand 1 "" ""))
7612               (clobber (reg:SI 2))])]
7613   ""
7614   "
7616   rtx op, call_insn;
7617   rtx nb = operands[1];
7619   if (TARGET_PORTABLE_RUNTIME)
7620     op = force_reg (SImode, XEXP (operands[0], 0));
7621   else
7622     op = XEXP (operands[0], 0);
7624   if (TARGET_64BIT)
7625     {
7626       if (!virtuals_instantiated)
7627         emit_move_insn (arg_pointer_rtx,
7628                         gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
7629                                       GEN_INT (64)));
7630       else
7631         {
7632           /* The loop pass can generate new libcalls after the virtual
7633              registers are instantiated when fpregs are disabled because
7634              the only method that we have for doing DImode multiplication
7635              is with a libcall.  This could be trouble if we haven't
7636              allocated enough space for the outgoing arguments.  */
7637           gcc_assert (INTVAL (nb) <= crtl->outgoing_args_size);
7639           emit_move_insn (arg_pointer_rtx,
7640                           gen_rtx_PLUS (word_mode, stack_pointer_rtx,
7641                                         GEN_INT (STACK_POINTER_OFFSET + 64)));
7642         }
7643     }
7645   /* Use two different patterns for calls to explicitly named functions
7646      and calls through function pointers.  This is necessary as these two
7647      types of calls use different calling conventions, and CSE might try
7648      to change the named call into an indirect call in some cases (using
7649      two patterns keeps CSE from performing this optimization).
7650      
7651      We now use even more call patterns as there was a subtle bug in
7652      attempting to restore the pic register after a call using a simple
7653      move insn.  During reload, a instruction involving a pseudo register
7654      with no explicit dependence on the PIC register can be converted
7655      to an equivalent load from memory using the PIC register.  If we
7656      emit a simple move to restore the PIC register in the initial rtl
7657      generation, then it can potentially be repositioned during scheduling.
7658      and an instruction that eventually uses the PIC register may end up
7659      between the call and the PIC register restore.
7660      
7661      This only worked because there is a post call group of instructions
7662      that are scheduled with the call.  These instructions are included
7663      in the same basic block as the call.  However, calls can throw in
7664      C++ code and a basic block has to terminate at the call if the call
7665      can throw.  This results in the PIC register restore being scheduled
7666      independently from the call.  So, we now hide the save and restore
7667      of the PIC register in the call pattern until after reload.  Then,
7668      we split the moves out.  A small side benefit is that we now don't
7669      need to have a use of the PIC register in the return pattern and
7670      the final save/restore operation is not needed.
7671      
7672      I elected to just clobber %r4 in the PIC patterns and use it instead
7673      of trying to force hppa_pic_save_rtx () to a callee saved register.
7674      This might have required a new register class and constraint.  It
7675      was also simpler to just handle the restore from a register than a
7676      generic pseudo.  */
7677   if (TARGET_64BIT)
7678     {
7679       if (GET_CODE (op) == SYMBOL_REF)
7680         call_insn = emit_call_insn (gen_call_symref_64bit (op, nb));
7681       else
7682         {
7683           op = force_reg (word_mode, op);
7684           call_insn = emit_call_insn (gen_call_reg_64bit (op, nb));
7685         }
7686     }
7687   else
7688     {
7689       if (GET_CODE (op) == SYMBOL_REF)
7690         {
7691           if (flag_pic)
7692             call_insn = emit_call_insn (gen_call_symref_pic (op, nb));
7693           else
7694             call_insn = emit_call_insn (gen_call_symref (op, nb));
7695         }
7696       else
7697         {
7698           rtx tmpreg = gen_rtx_REG (word_mode, 22);
7700           emit_move_insn (tmpreg, force_reg (word_mode, op));
7701           if (flag_pic)
7702             call_insn = emit_call_insn (gen_call_reg_pic (nb));
7703           else
7704             call_insn = emit_call_insn (gen_call_reg (nb));
7705         }
7706     }
7708   DONE;
7711 ;; We use function calls to set the attribute length of calls and millicode
7712 ;; calls.  This is necessary because of the large variety of call sequences.
7713 ;; Implementing the calculation in rtl is difficult as well as ugly.  As
7714 ;; we need the same calculation in several places, maintenance becomes a
7715 ;; nightmare.
7717 ;; However, this has a subtle impact on branch shortening.  When the
7718 ;; expression used to set the length attribute of an instruction depends
7719 ;; on a relative address (e.g., pc or a branch address), genattrtab
7720 ;; notes that the insn's length is variable, and attempts to determine a
7721 ;; worst-case default length and code to compute an insn's current length.
7723 ;; The use of a function call hides the variable dependence of our calls
7724 ;; and millicode calls.  The result is genattrtab doesn't treat the operation
7725 ;; as variable and it only generates code for the default case using our
7726 ;; function call.  Because of this, calls and millicode calls have a fixed
7727 ;; length in the branch shortening pass, and some branches will use a longer
7728 ;; code sequence than necessary.  However, the length of any given call
7729 ;; will still reflect its final code location and it may be shorter than
7730 ;; the initial length estimate.
7732 ;; It's possible to trick genattrtab by adding an expression involving `pc'
7733 ;; in the set.  However, when genattrtab hits a function call in its attempt
7734 ;; to compute the default length, it marks the result as unknown and sets
7735 ;; the default result to MAX_INT ;-(  One possible fix that would allow
7736 ;; calls to participate in branch shortening would be to make the call to
7737 ;; insn_default_length a target option.  Then, we could massage unknown
7738 ;; results.  Another fix might be to change genattrtab so that it just does
7739 ;; the call in the variable case as it already does for the fixed case.
7741 (define_insn "call_symref"
7742   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7743          (match_operand 1 "" "i"))
7744    (clobber (reg:SI 1))
7745    (clobber (reg:SI 2))
7746    (use (const_int 0))]
7747   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7748   "*
7750   output_arg_descriptor (insn);
7751   return output_call (insn, operands[0], 0);
7753   [(set_attr "type" "call")
7754    (set (attr "length") (symbol_ref "attr_length_call (insn, 0)"))])
7756 (define_insn "call_symref_pic"
7757   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7758          (match_operand 1 "" "i"))
7759    (clobber (reg:SI 1))
7760    (clobber (reg:SI 2))
7761    (clobber (reg:SI 4))
7762    (use (reg:SI 19))
7763    (use (const_int 0))]
7764   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7765   "*
7767   output_arg_descriptor (insn);
7768   return output_call (insn, operands[0], 0);
7770   [(set_attr "type" "call")
7771    (set (attr "length")
7772         (plus (symbol_ref "attr_length_call (insn, 0)")
7773               (symbol_ref "attr_length_save_restore_dltp (insn)")))])
7775 ;; Split out the PIC register save and restore after reload.  This is
7776 ;; done only if the function returns.  As the split is done after reload,
7777 ;; there are some situations in which we unnecessarily save and restore
7778 ;; %r4.  This happens when there is a single call and the PIC register
7779 ;; is "dead" after the call.  This isn't easy to fix as the usage of
7780 ;; the PIC register isn't completely determined until the reload pass.
7781 (define_split
7782   [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7783                     (match_operand 1 "" ""))
7784               (clobber (reg:SI 1))
7785               (clobber (reg:SI 2))
7786               (clobber (reg:SI 4))
7787               (use (reg:SI 19))
7788               (use (const_int 0))])]
7789   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT
7790    && reload_completed
7791    && !find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7792   [(set (reg:SI 4) (reg:SI 19))
7793    (parallel [(call (mem:SI (match_dup 0))
7794                     (match_dup 1))
7795               (clobber (reg:SI 1))
7796               (clobber (reg:SI 2))
7797               (use (reg:SI 19))
7798               (use (const_int 0))])
7799    (set (reg:SI 19) (reg:SI 4))]
7800   "")
7802 ;; Remove the clobber of register 4 when optimizing.  This has to be
7803 ;; done with a peephole optimization rather than a split because the
7804 ;; split sequence for a call must be longer than one instruction.
7805 (define_peephole2
7806   [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7807                     (match_operand 1 "" ""))
7808               (clobber (reg:SI 1))
7809               (clobber (reg:SI 2))
7810               (clobber (reg:SI 4))
7811               (use (reg:SI 19))
7812               (use (const_int 0))])]
7813   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
7814   [(parallel [(call (mem:SI (match_dup 0))
7815                     (match_dup 1))
7816               (clobber (reg:SI 1))
7817               (clobber (reg:SI 2))
7818               (use (reg:SI 19))
7819               (use (const_int 0))])]
7820   "")
7822 (define_insn "*call_symref_pic_post_reload"
7823   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7824          (match_operand 1 "" "i"))
7825    (clobber (reg:SI 1))
7826    (clobber (reg:SI 2))
7827    (use (reg:SI 19))
7828    (use (const_int 0))]
7829   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7830   "*
7832   output_arg_descriptor (insn);
7833   return output_call (insn, operands[0], 0);
7835   [(set_attr "type" "call")
7836    (set (attr "length") (symbol_ref "attr_length_call (insn, 0)"))])
7838 ;; This pattern is split if it is necessary to save and restore the
7839 ;; PIC register.
7840 (define_insn "call_symref_64bit"
7841   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7842          (match_operand 1 "" "i"))
7843    (clobber (reg:DI 1))
7844    (clobber (reg:DI 2))
7845    (clobber (reg:DI 4))
7846    (use (reg:DI 27))
7847    (use (reg:DI 29))
7848    (use (const_int 0))]
7849   "TARGET_64BIT"
7850   "*
7852   output_arg_descriptor (insn);
7853   return output_call (insn, operands[0], 0);
7855   [(set_attr "type" "call")
7856    (set (attr "length")
7857         (plus (symbol_ref "attr_length_call (insn, 0)")
7858               (symbol_ref "attr_length_save_restore_dltp (insn)")))])
7860 ;; Split out the PIC register save and restore after reload.  This is
7861 ;; done only if the function returns.  As the split is done after reload,
7862 ;; there are some situations in which we unnecessarily save and restore
7863 ;; %r4.  This happens when there is a single call and the PIC register
7864 ;; is "dead" after the call.  This isn't easy to fix as the usage of
7865 ;; the PIC register isn't completely determined until the reload pass.
7866 (define_split
7867   [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7868                     (match_operand 1 "" ""))
7869               (clobber (reg:DI 1))
7870               (clobber (reg:DI 2))
7871               (clobber (reg:DI 4))
7872               (use (reg:DI 27))
7873               (use (reg:DI 29))
7874               (use (const_int 0))])]
7875   "TARGET_64BIT
7876    && reload_completed
7877    && !find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7878   [(set (reg:DI 4) (reg:DI 27))
7879    (parallel [(call (mem:SI (match_dup 0))
7880                     (match_dup 1))
7881               (clobber (reg:DI 1))
7882               (clobber (reg:DI 2))
7883               (use (reg:DI 27))
7884               (use (reg:DI 29))
7885               (use (const_int 0))])
7886    (set (reg:DI 27) (reg:DI 4))]
7887   "")
7889 ;; Remove the clobber of register 4 when optimizing.  This has to be
7890 ;; done with a peephole optimization rather than a split because the
7891 ;; split sequence for a call must be longer than one instruction.
7892 (define_peephole2
7893   [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7894                     (match_operand 1 "" ""))
7895               (clobber (reg:DI 1))
7896               (clobber (reg:DI 2))
7897               (clobber (reg:DI 4))
7898               (use (reg:DI 27))
7899               (use (reg:DI 29))
7900               (use (const_int 0))])]
7901   "TARGET_64BIT && reload_completed"
7902   [(parallel [(call (mem:SI (match_dup 0))
7903                     (match_dup 1))
7904               (clobber (reg:DI 1))
7905               (clobber (reg:DI 2))
7906               (use (reg:DI 27))
7907               (use (reg:DI 29))
7908               (use (const_int 0))])]
7909   "")
7911 (define_insn "*call_symref_64bit_post_reload"
7912   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7913          (match_operand 1 "" "i"))
7914    (clobber (reg:DI 1))
7915    (clobber (reg:DI 2))
7916    (use (reg:DI 27))
7917    (use (reg:DI 29))
7918    (use (const_int 0))]
7919   "TARGET_64BIT"
7920   "*
7922   output_arg_descriptor (insn);
7923   return output_call (insn, operands[0], 0);
7925   [(set_attr "type" "call")
7926    (set (attr "length") (symbol_ref "attr_length_call (insn, 0)"))])
7928 (define_insn "call_reg"
7929   [(call (mem:SI (reg:SI 22))
7930          (match_operand 0 "" "i"))
7931    (clobber (reg:SI 1))
7932    (clobber (reg:SI 2))
7933    (use (const_int 1))]
7934   "!TARGET_64BIT"
7935   "*
7937   return output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
7939   [(set_attr "type" "dyncall")
7940    (set (attr "length") (symbol_ref "attr_length_indirect_call (insn)"))])
7942 ;; This pattern is split if it is necessary to save and restore the
7943 ;; PIC register.
7944 (define_insn "call_reg_pic"
7945   [(call (mem:SI (reg:SI 22))
7946          (match_operand 0 "" "i"))
7947    (clobber (reg:SI 1))
7948    (clobber (reg:SI 2))
7949    (clobber (reg:SI 4))
7950    (use (reg:SI 19))
7951    (use (const_int 1))]
7952   "!TARGET_64BIT"
7953   "*
7955   return output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
7957   [(set_attr "type" "dyncall")
7958    (set (attr "length")
7959         (plus (symbol_ref "attr_length_indirect_call (insn)")
7960               (symbol_ref "attr_length_save_restore_dltp (insn)")))])
7962 ;; Split out the PIC register save and restore after reload.  This is
7963 ;; done only if the function returns.  As the split is done after reload,
7964 ;; there are some situations in which we unnecessarily save and restore
7965 ;; %r4.  This happens when there is a single call and the PIC register
7966 ;; is "dead" after the call.  This isn't easy to fix as the usage of
7967 ;; the PIC register isn't completely determined until the reload pass.
7968 (define_split
7969   [(parallel [(call (mem:SI (reg:SI 22))
7970                     (match_operand 0 "" ""))
7971               (clobber (reg:SI 1))
7972               (clobber (reg:SI 2))
7973               (clobber (reg:SI 4))
7974               (use (reg:SI 19))
7975               (use (const_int 1))])]
7976   "!TARGET_64BIT
7977    && reload_completed
7978    && !find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7979   [(set (reg:SI 4) (reg:SI 19))
7980    (parallel [(call (mem:SI (reg:SI 22))
7981                     (match_dup 0))
7982               (clobber (reg:SI 1))
7983               (clobber (reg:SI 2))
7984               (use (reg:SI 19))
7985               (use (const_int 1))])
7986    (set (reg:SI 19) (reg:SI 4))]
7987   "")
7989 ;; Remove the clobber of register 4 when optimizing.  This has to be
7990 ;; done with a peephole optimization rather than a split because the
7991 ;; split sequence for a call must be longer than one instruction.
7992 (define_peephole2
7993   [(parallel [(call (mem:SI (reg:SI 22))
7994                     (match_operand 0 "" ""))
7995               (clobber (reg:SI 1))
7996               (clobber (reg:SI 2))
7997               (clobber (reg:SI 4))
7998               (use (reg:SI 19))
7999               (use (const_int 1))])]
8000   "!TARGET_64BIT && reload_completed"
8001   [(parallel [(call (mem:SI (reg:SI 22))
8002                     (match_dup 0))
8003               (clobber (reg:SI 1))
8004               (clobber (reg:SI 2))
8005               (use (reg:SI 19))
8006               (use (const_int 1))])]
8007   "")
8009 (define_insn "*call_reg_pic_post_reload"
8010   [(call (mem:SI (reg:SI 22))
8011          (match_operand 0 "" "i"))
8012    (clobber (reg:SI 1))
8013    (clobber (reg:SI 2))
8014    (use (reg:SI 19))
8015    (use (const_int 1))]
8016   "!TARGET_64BIT"
8017   "*
8019   return output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
8021   [(set_attr "type" "dyncall")
8022    (set (attr "length") (symbol_ref "attr_length_indirect_call (insn)"))])
8024 ;; This pattern is split if it is necessary to save and restore the
8025 ;; PIC register.
8026 (define_insn "call_reg_64bit"
8027   [(call (mem:SI (match_operand:DI 0 "register_operand" "r"))
8028          (match_operand 1 "" "i"))
8029    (clobber (reg:DI 2))
8030    (clobber (reg:DI 4))
8031    (use (reg:DI 27))
8032    (use (reg:DI 29))
8033    (use (const_int 1))]
8034   "TARGET_64BIT"
8035   "*
8037   return output_indirect_call (insn, operands[0]);
8039   [(set_attr "type" "dyncall")
8040    (set (attr "length")
8041         (plus (symbol_ref "attr_length_indirect_call (insn)")
8042               (symbol_ref "attr_length_save_restore_dltp (insn)")))])
8044 ;; Split out the PIC register save and restore after reload.  This is
8045 ;; done only if the function returns.  As the split is done after reload,
8046 ;; there are some situations in which we unnecessarily save and restore
8047 ;; %r4.  This happens when there is a single call and the PIC register
8048 ;; is "dead" after the call.  This isn't easy to fix as the usage of
8049 ;; the PIC register isn't completely determined until the reload pass.
8050 (define_split
8051   [(parallel [(call (mem:SI (match_operand 0 "register_operand" ""))
8052                     (match_operand 1 "" ""))
8053               (clobber (reg:DI 2))
8054               (clobber (reg:DI 4))
8055               (use (reg:DI 27))
8056               (use (reg:DI 29))
8057               (use (const_int 1))])]
8058   "TARGET_64BIT
8059    && reload_completed
8060    && !find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8061   [(set (reg:DI 4) (reg:DI 27))
8062    (parallel [(call (mem:SI (match_dup 0))
8063                     (match_dup 1))
8064               (clobber (reg:DI 2))
8065               (use (reg:DI 27))
8066               (use (reg:DI 29))
8067               (use (const_int 1))])
8068    (set (reg:DI 27) (reg:DI 4))]
8069   "")
8071 ;; Remove the clobber of register 4 when optimizing.  This has to be
8072 ;; done with a peephole optimization rather than a split because the
8073 ;; split sequence for a call must be longer than one instruction.
8074 (define_peephole2
8075   [(parallel [(call (mem:SI (match_operand 0 "register_operand" ""))
8076                     (match_operand 1 "" ""))
8077               (clobber (reg:DI 2))
8078               (clobber (reg:DI 4))
8079               (use (reg:DI 27))
8080               (use (reg:DI 29))
8081               (use (const_int 1))])]
8082   "TARGET_64BIT && reload_completed"
8083   [(parallel [(call (mem:SI (match_dup 0))
8084                     (match_dup 1))
8085               (clobber (reg:DI 2))
8086               (use (reg:DI 27))
8087               (use (reg:DI 29))
8088               (use (const_int 1))])]
8089   "")
8091 (define_insn "*call_reg_64bit_post_reload"
8092   [(call (mem:SI (match_operand:DI 0 "register_operand" "r"))
8093          (match_operand 1 "" "i"))
8094    (clobber (reg:DI 2))
8095    (use (reg:DI 27))
8096    (use (reg:DI 29))
8097    (use (const_int 1))]
8098   "TARGET_64BIT"
8099   "*
8101   return output_indirect_call (insn, operands[0]);
8103   [(set_attr "type" "dyncall")
8104    (set (attr "length") (symbol_ref "attr_length_indirect_call (insn)"))])
8106 (define_expand "call_value"
8107   [(parallel [(set (match_operand 0 "" "")
8108                    (call (match_operand:SI 1 "" "")
8109                          (match_operand 2 "" "")))
8110               (clobber (reg:SI 2))])]
8111   ""
8112   "
8114   rtx op, call_insn;
8115   rtx dst = operands[0];
8116   rtx nb = operands[2];
8118   if (TARGET_PORTABLE_RUNTIME)
8119     op = force_reg (SImode, XEXP (operands[1], 0));
8120   else
8121     op = XEXP (operands[1], 0);
8123   if (TARGET_64BIT)
8124     {
8125       if (!virtuals_instantiated)
8126         emit_move_insn (arg_pointer_rtx,
8127                         gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
8128                                       GEN_INT (64)));
8129       else
8130         {
8131           /* The loop pass can generate new libcalls after the virtual
8132              registers are instantiated when fpregs are disabled because
8133              the only method that we have for doing DImode multiplication
8134              is with a libcall.  This could be trouble if we haven't
8135              allocated enough space for the outgoing arguments.  */
8136           gcc_assert (INTVAL (nb) <= crtl->outgoing_args_size);
8138           emit_move_insn (arg_pointer_rtx,
8139                           gen_rtx_PLUS (word_mode, stack_pointer_rtx,
8140                                         GEN_INT (STACK_POINTER_OFFSET + 64)));
8141         }
8142     }
8144   /* Use two different patterns for calls to explicitly named functions
8145      and calls through function pointers.  This is necessary as these two
8146      types of calls use different calling conventions, and CSE might try
8147      to change the named call into an indirect call in some cases (using
8148      two patterns keeps CSE from performing this optimization).
8150      We now use even more call patterns as there was a subtle bug in
8151      attempting to restore the pic register after a call using a simple
8152      move insn.  During reload, a instruction involving a pseudo register
8153      with no explicit dependence on the PIC register can be converted
8154      to an equivalent load from memory using the PIC register.  If we
8155      emit a simple move to restore the PIC register in the initial rtl
8156      generation, then it can potentially be repositioned during scheduling.
8157      and an instruction that eventually uses the PIC register may end up
8158      between the call and the PIC register restore.
8159      
8160      This only worked because there is a post call group of instructions
8161      that are scheduled with the call.  These instructions are included
8162      in the same basic block as the call.  However, calls can throw in
8163      C++ code and a basic block has to terminate at the call if the call
8164      can throw.  This results in the PIC register restore being scheduled
8165      independently from the call.  So, we now hide the save and restore
8166      of the PIC register in the call pattern until after reload.  Then,
8167      we split the moves out.  A small side benefit is that we now don't
8168      need to have a use of the PIC register in the return pattern and
8169      the final save/restore operation is not needed.
8170      
8171      I elected to just clobber %r4 in the PIC patterns and use it instead
8172      of trying to force hppa_pic_save_rtx () to a callee saved register.
8173      This might have required a new register class and constraint.  It
8174      was also simpler to just handle the restore from a register than a
8175      generic pseudo.  */
8176   if (TARGET_64BIT)
8177     {
8178       if (GET_CODE (op) == SYMBOL_REF)
8179         call_insn = emit_call_insn (gen_call_val_symref_64bit (dst, op, nb));
8180       else
8181         {
8182           op = force_reg (word_mode, op);
8183           call_insn = emit_call_insn (gen_call_val_reg_64bit (dst, op, nb));
8184         }
8185     }
8186   else
8187     {
8188       if (GET_CODE (op) == SYMBOL_REF)
8189         {
8190           if (flag_pic)
8191             call_insn = emit_call_insn (gen_call_val_symref_pic (dst, op, nb));
8192           else
8193             call_insn = emit_call_insn (gen_call_val_symref (dst, op, nb));
8194         }
8195       else
8196         {
8197           rtx tmpreg = gen_rtx_REG (word_mode, 22);
8199           emit_move_insn (tmpreg, force_reg (word_mode, op));
8200           if (flag_pic)
8201             call_insn = emit_call_insn (gen_call_val_reg_pic (dst, nb));
8202           else
8203             call_insn = emit_call_insn (gen_call_val_reg (dst, nb));
8204         }
8205     }
8207   DONE;
8210 (define_insn "call_val_symref"
8211   [(set (match_operand 0 "" "")
8212         (call (mem:SI (match_operand 1 "call_operand_address" ""))
8213               (match_operand 2 "" "i")))
8214    (clobber (reg:SI 1))
8215    (clobber (reg:SI 2))
8216    (use (const_int 0))]
8217   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8218   "*
8220   output_arg_descriptor (insn);
8221   return output_call (insn, operands[1], 0);
8223   [(set_attr "type" "call")
8224    (set (attr "length") (symbol_ref "attr_length_call (insn, 0)"))])
8226 (define_insn "call_val_symref_pic"
8227   [(set (match_operand 0 "" "")
8228         (call (mem:SI (match_operand 1 "call_operand_address" ""))
8229               (match_operand 2 "" "i")))
8230    (clobber (reg:SI 1))
8231    (clobber (reg:SI 2))
8232    (clobber (reg:SI 4))
8233    (use (reg:SI 19))
8234    (use (const_int 0))]
8235   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8236   "*
8238   output_arg_descriptor (insn);
8239   return output_call (insn, operands[1], 0);
8241   [(set_attr "type" "call")
8242    (set (attr "length")
8243         (plus (symbol_ref "attr_length_call (insn, 0)")
8244               (symbol_ref "attr_length_save_restore_dltp (insn)")))])
8246 ;; Split out the PIC register save and restore after reload.  This is
8247 ;; done only if the function returns.  As the split is done after reload,
8248 ;; there are some situations in which we unnecessarily save and restore
8249 ;; %r4.  This happens when there is a single call and the PIC register
8250 ;; is "dead" after the call.  This isn't easy to fix as the usage of
8251 ;; the PIC register isn't completely determined until the reload pass.
8252 (define_split
8253   [(parallel [(set (match_operand 0 "" "")
8254               (call (mem:SI (match_operand 1 "call_operand_address" ""))
8255                     (match_operand 2 "" "")))
8256               (clobber (reg:SI 1))
8257               (clobber (reg:SI 2))
8258               (clobber (reg:SI 4))
8259               (use (reg:SI 19))
8260               (use (const_int 0))])]
8261   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT
8262    && reload_completed
8263    && !find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8264   [(set (reg:SI 4) (reg:SI 19))
8265    (parallel [(set (match_dup 0)
8266               (call (mem:SI (match_dup 1))
8267                     (match_dup 2)))
8268               (clobber (reg:SI 1))
8269               (clobber (reg:SI 2))
8270               (use (reg:SI 19))
8271               (use (const_int 0))])
8272    (set (reg:SI 19) (reg:SI 4))]
8273   "")
8275 ;; Remove the clobber of register 4 when optimizing.  This has to be
8276 ;; done with a peephole optimization rather than a split because the
8277 ;; split sequence for a call must be longer than one instruction.
8278 (define_peephole2
8279   [(parallel [(set (match_operand 0 "" "")
8280               (call (mem:SI (match_operand 1 "call_operand_address" ""))
8281                     (match_operand 2 "" "")))
8282               (clobber (reg:SI 1))
8283               (clobber (reg:SI 2))
8284               (clobber (reg:SI 4))
8285               (use (reg:SI 19))
8286               (use (const_int 0))])]
8287   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
8288   [(parallel [(set (match_dup 0)
8289               (call (mem:SI (match_dup 1))
8290                     (match_dup 2)))
8291               (clobber (reg:SI 1))
8292               (clobber (reg:SI 2))
8293               (use (reg:SI 19))
8294               (use (const_int 0))])]
8295   "")
8297 (define_insn "*call_val_symref_pic_post_reload"
8298   [(set (match_operand 0 "" "")
8299         (call (mem:SI (match_operand 1 "call_operand_address" ""))
8300               (match_operand 2 "" "i")))
8301    (clobber (reg:SI 1))
8302    (clobber (reg:SI 2))
8303    (use (reg:SI 19))
8304    (use (const_int 0))]
8305   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8306   "*
8308   output_arg_descriptor (insn);
8309   return output_call (insn, operands[1], 0);
8311   [(set_attr "type" "call")
8312    (set (attr "length") (symbol_ref "attr_length_call (insn, 0)"))])
8314 ;; This pattern is split if it is necessary to save and restore the
8315 ;; PIC register.
8316 (define_insn "call_val_symref_64bit"
8317   [(set (match_operand 0 "" "")
8318         (call (mem:SI (match_operand 1 "call_operand_address" ""))
8319               (match_operand 2 "" "i")))
8320    (clobber (reg:DI 1))
8321    (clobber (reg:DI 2))
8322    (clobber (reg:DI 4))
8323    (use (reg:DI 27))
8324    (use (reg:DI 29))
8325    (use (const_int 0))]
8326   "TARGET_64BIT"
8327   "*
8329   output_arg_descriptor (insn);
8330   return output_call (insn, operands[1], 0);
8332   [(set_attr "type" "call")
8333    (set (attr "length")
8334         (plus (symbol_ref "attr_length_call (insn, 0)")
8335               (symbol_ref "attr_length_save_restore_dltp (insn)")))])
8337 ;; Split out the PIC register save and restore after reload.  This is
8338 ;; done only if the function returns.  As the split is done after reload,
8339 ;; there are some situations in which we unnecessarily save and restore
8340 ;; %r4.  This happens when there is a single call and the PIC register
8341 ;; is "dead" after the call.  This isn't easy to fix as the usage of
8342 ;; the PIC register isn't completely determined until the reload pass.
8343 (define_split
8344   [(parallel [(set (match_operand 0 "" "")
8345               (call (mem:SI (match_operand 1 "call_operand_address" ""))
8346                     (match_operand 2 "" "")))
8347               (clobber (reg:DI 1))
8348               (clobber (reg:DI 2))
8349               (clobber (reg:DI 4))
8350               (use (reg:DI 27))
8351               (use (reg:DI 29))
8352               (use (const_int 0))])]
8353   "TARGET_64BIT
8354    && reload_completed
8355    && !find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8356   [(set (reg:DI 4) (reg:DI 27))
8357    (parallel [(set (match_dup 0)
8358               (call (mem:SI (match_dup 1))
8359                     (match_dup 2)))
8360               (clobber (reg:DI 1))
8361               (clobber (reg:DI 2))
8362               (use (reg:DI 27))
8363               (use (reg:DI 29))
8364               (use (const_int 0))])
8365    (set (reg:DI 27) (reg:DI 4))]
8366   "")
8368 ;; Remove the clobber of register 4 when optimizing.  This has to be
8369 ;; done with a peephole optimization rather than a split because the
8370 ;; split sequence for a call must be longer than one instruction.
8371 (define_peephole2
8372   [(parallel [(set (match_operand 0 "" "")
8373               (call (mem:SI (match_operand 1 "call_operand_address" ""))
8374                     (match_operand 2 "" "")))
8375               (clobber (reg:DI 1))
8376               (clobber (reg:DI 2))
8377               (clobber (reg:DI 4))
8378               (use (reg:DI 27))
8379               (use (reg:DI 29))
8380               (use (const_int 0))])]
8381   "TARGET_64BIT && reload_completed"
8382   [(parallel [(set (match_dup 0)
8383               (call (mem:SI (match_dup 1))
8384                     (match_dup 2)))
8385               (clobber (reg:DI 1))
8386               (clobber (reg:DI 2))
8387               (use (reg:DI 27))
8388               (use (reg:DI 29))
8389               (use (const_int 0))])]
8390   "")
8392 (define_insn "*call_val_symref_64bit_post_reload"
8393   [(set (match_operand 0 "" "")
8394         (call (mem:SI (match_operand 1 "call_operand_address" ""))
8395               (match_operand 2 "" "i")))
8396    (clobber (reg:DI 1))
8397    (clobber (reg:DI 2))
8398    (use (reg:DI 27))
8399    (use (reg:DI 29))
8400    (use (const_int 0))]
8401   "TARGET_64BIT"
8402   "*
8404   output_arg_descriptor (insn);
8405   return output_call (insn, operands[1], 0);
8407   [(set_attr "type" "call")
8408    (set (attr "length") (symbol_ref "attr_length_call (insn, 0)"))])
8410 (define_insn "call_val_reg"
8411   [(set (match_operand 0 "" "")
8412         (call (mem:SI (reg:SI 22))
8413               (match_operand 1 "" "i")))
8414    (clobber (reg:SI 1))
8415    (clobber (reg:SI 2))
8416    (use (const_int 1))]
8417   "!TARGET_64BIT"
8418   "*
8420   return output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
8422   [(set_attr "type" "dyncall")
8423    (set (attr "length") (symbol_ref "attr_length_indirect_call (insn)"))])
8425 ;; This pattern is split if it is necessary to save and restore the
8426 ;; PIC register.
8427 (define_insn "call_val_reg_pic"
8428   [(set (match_operand 0 "" "")
8429         (call (mem:SI (reg:SI 22))
8430               (match_operand 1 "" "i")))
8431    (clobber (reg:SI 1))
8432    (clobber (reg:SI 2))
8433    (clobber (reg:SI 4))
8434    (use (reg:SI 19))
8435    (use (const_int 1))]
8436   "!TARGET_64BIT"
8437   "*
8439   return output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
8441   [(set_attr "type" "dyncall")
8442    (set (attr "length")
8443         (plus (symbol_ref "attr_length_indirect_call (insn)")
8444               (symbol_ref "attr_length_save_restore_dltp (insn)")))])
8446 ;; Split out the PIC register save and restore after reload.  This is
8447 ;; done only if the function returns.  As the split is done after reload,
8448 ;; there are some situations in which we unnecessarily save and restore
8449 ;; %r4.  This happens when there is a single call and the PIC register
8450 ;; is "dead" after the call.  This isn't easy to fix as the usage of
8451 ;; the PIC register isn't completely determined until the reload pass.
8452 (define_split
8453   [(parallel [(set (match_operand 0 "" "")
8454                    (call (mem:SI (reg:SI 22))
8455                          (match_operand 1 "" "")))
8456               (clobber (reg:SI 1))
8457               (clobber (reg:SI 2))
8458               (clobber (reg:SI 4))
8459               (use (reg:SI 19))
8460               (use (const_int 1))])]
8461   "!TARGET_64BIT
8462    && reload_completed
8463    && !find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8464   [(set (reg:SI 4) (reg:SI 19))
8465    (parallel [(set (match_dup 0)
8466                    (call (mem:SI (reg:SI 22))
8467                          (match_dup 1)))
8468               (clobber (reg:SI 1))
8469               (clobber (reg:SI 2))
8470               (use (reg:SI 19))
8471               (use (const_int 1))])
8472    (set (reg:SI 19) (reg:SI 4))]
8473   "")
8475 ;; Remove the clobber of register 4 when optimizing.  This has to be
8476 ;; done with a peephole optimization rather than a split because the
8477 ;; split sequence for a call must be longer than one instruction.
8478 (define_peephole2
8479   [(parallel [(set (match_operand 0 "" "")
8480                    (call (mem:SI (reg:SI 22))
8481                          (match_operand 1 "" "")))
8482               (clobber (reg:SI 1))
8483               (clobber (reg:SI 2))
8484               (clobber (reg:SI 4))
8485               (use (reg:SI 19))
8486               (use (const_int 1))])]
8487   "!TARGET_64BIT && reload_completed"
8488   [(parallel [(set (match_dup 0)
8489                    (call (mem:SI (reg:SI 22))
8490                          (match_dup 1)))
8491               (clobber (reg:SI 1))
8492               (clobber (reg:SI 2))
8493               (use (reg:SI 19))
8494               (use (const_int 1))])]
8495   "")
8497 (define_insn "*call_val_reg_pic_post_reload"
8498   [(set (match_operand 0 "" "")
8499         (call (mem:SI (reg:SI 22))
8500               (match_operand 1 "" "i")))
8501    (clobber (reg:SI 1))
8502    (clobber (reg:SI 2))
8503    (use (reg:SI 19))
8504    (use (const_int 1))]
8505   "!TARGET_64BIT"
8506   "*
8508   return output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
8510   [(set_attr "type" "dyncall")
8511    (set (attr "length") (symbol_ref "attr_length_indirect_call (insn)"))])
8513 ;; This pattern is split if it is necessary to save and restore the
8514 ;; PIC register.
8515 (define_insn "call_val_reg_64bit"
8516   [(set (match_operand 0 "" "")
8517         (call (mem:SI (match_operand:DI 1 "register_operand" "r"))
8518               (match_operand 2 "" "i")))
8519    (clobber (reg:DI 2))
8520    (clobber (reg:DI 4))
8521    (use (reg:DI 27))
8522    (use (reg:DI 29))
8523    (use (const_int 1))]
8524   "TARGET_64BIT"
8525   "*
8527   return output_indirect_call (insn, operands[1]);
8529   [(set_attr "type" "dyncall")
8530    (set (attr "length")
8531         (plus (symbol_ref "attr_length_indirect_call (insn)")
8532               (symbol_ref "attr_length_save_restore_dltp (insn)")))])
8534 ;; Split out the PIC register save and restore after reload.  This is
8535 ;; done only if the function returns.  As the split is done after reload,
8536 ;; there are some situations in which we unnecessarily save and restore
8537 ;; %r4.  This happens when there is a single call and the PIC register
8538 ;; is "dead" after the call.  This isn't easy to fix as the usage of
8539 ;; the PIC register isn't completely determined until the reload pass.
8540 (define_split
8541   [(parallel [(set (match_operand 0 "" "")
8542                    (call (mem:SI (match_operand:DI 1 "register_operand" ""))
8543                          (match_operand 2 "" "")))
8544               (clobber (reg:DI 2))
8545               (clobber (reg:DI 4))
8546               (use (reg:DI 27))
8547               (use (reg:DI 29))
8548               (use (const_int 1))])]
8549   "TARGET_64BIT
8550    && reload_completed
8551    && !find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8552   [(set (reg:DI 4) (reg:DI 27))
8553    (parallel [(set (match_dup 0)
8554                    (call (mem:SI (match_dup 1))
8555                          (match_dup 2)))
8556               (clobber (reg:DI 2))
8557               (use (reg:DI 27))
8558               (use (reg:DI 29))
8559               (use (const_int 1))])
8560    (set (reg:DI 27) (reg:DI 4))]
8561   "")
8563 ;; Remove the clobber of register 4 when optimizing.  This has to be
8564 ;; done with a peephole optimization rather than a split because the
8565 ;; split sequence for a call must be longer than one instruction.
8566 (define_peephole2
8567   [(parallel [(set (match_operand 0 "" "")
8568                    (call (mem:SI (match_operand:DI 1 "register_operand" ""))
8569                          (match_operand 2 "" "")))
8570               (clobber (reg:DI 2))
8571               (clobber (reg:DI 4))
8572               (use (reg:DI 27))
8573               (use (reg:DI 29))
8574               (use (const_int 1))])]
8575   "TARGET_64BIT && reload_completed"
8576   [(parallel [(set (match_dup 0)
8577                    (call (mem:SI (match_dup 1))
8578                          (match_dup 2)))
8579               (clobber (reg:DI 2))
8580               (use (reg:DI 27))
8581               (use (reg:DI 29))
8582               (use (const_int 1))])]
8583   "")
8585 (define_insn "*call_val_reg_64bit_post_reload"
8586   [(set (match_operand 0 "" "")
8587         (call (mem:SI (match_operand:DI 1 "register_operand" "r"))
8588               (match_operand 2 "" "i")))
8589    (clobber (reg:DI 2))
8590    (use (reg:DI 27))
8591    (use (reg:DI 29))
8592    (use (const_int 1))]
8593   "TARGET_64BIT"
8594   "*
8596   return output_indirect_call (insn, operands[1]);
8598   [(set_attr "type" "dyncall")
8599    (set (attr "length") (symbol_ref "attr_length_indirect_call (insn)"))])
8601 ;; Call subroutine returning any type.
8603 (define_expand "untyped_call"
8604   [(parallel [(call (match_operand 0 "" "")
8605                     (const_int 0))
8606               (match_operand 1 "" "")
8607               (match_operand 2 "" "")])]
8608   ""
8609   "
8611   int i;
8613   emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
8615   for (i = 0; i < XVECLEN (operands[2], 0); i++)
8616     {
8617       rtx set = XVECEXP (operands[2], 0, i);
8618       emit_move_insn (SET_DEST (set), SET_SRC (set));
8619     }
8621   /* The optimizer does not know that the call sets the function value
8622      registers we stored in the result block.  We avoid problems by
8623      claiming that all hard registers are used and clobbered at this
8624      point.  */
8625   emit_insn (gen_blockage ());
8627   DONE;
8630 (define_expand "sibcall"
8631   [(call (match_operand:SI 0 "" "")
8632          (match_operand 1 "" ""))]
8633   "!TARGET_PORTABLE_RUNTIME"
8634   "
8636   rtx op, call_insn;
8637   rtx nb = operands[1];
8639   op = XEXP (operands[0], 0);
8641   if (TARGET_64BIT)
8642     {
8643       if (!virtuals_instantiated)
8644         emit_move_insn (arg_pointer_rtx,
8645                         gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
8646                                       GEN_INT (64)));
8647       else
8648         {
8649           /* The loop pass can generate new libcalls after the virtual
8650              registers are instantiated when fpregs are disabled because
8651              the only method that we have for doing DImode multiplication
8652              is with a libcall.  This could be trouble if we haven't
8653              allocated enough space for the outgoing arguments.  */
8654           gcc_assert (INTVAL (nb) <= crtl->outgoing_args_size);
8656           emit_move_insn (arg_pointer_rtx,
8657                           gen_rtx_PLUS (word_mode, stack_pointer_rtx,
8658                                         GEN_INT (STACK_POINTER_OFFSET + 64)));
8659         }
8660     }
8662   /* Indirect sibling calls are not allowed.  */
8663   if (TARGET_64BIT)
8664     call_insn = gen_sibcall_internal_symref_64bit (op, operands[1]);
8665   else
8666     call_insn = gen_sibcall_internal_symref (op, operands[1]);
8668   call_insn = emit_call_insn (call_insn);
8670   if (TARGET_64BIT)
8671     use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), arg_pointer_rtx);
8673   /* We don't have to restore the PIC register.  */
8674   if (flag_pic)
8675     use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
8677   DONE;
8680 (define_insn "sibcall_internal_symref"
8681   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8682          (match_operand 1 "" "i"))
8683    (clobber (reg:SI 1))
8684    (use (reg:SI 2))
8685    (use (const_int 0))]
8686   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8687   "*
8689   output_arg_descriptor (insn);
8690   return output_call (insn, operands[0], 1);
8692   [(set_attr "type" "call")
8693    (set (attr "length") (symbol_ref "attr_length_call (insn, 1)"))])
8695 (define_insn "sibcall_internal_symref_64bit"
8696   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8697          (match_operand 1 "" "i"))
8698    (clobber (reg:DI 1))
8699    (use (reg:DI 2))
8700    (use (const_int 0))]
8701   "TARGET_64BIT"
8702   "*
8704   output_arg_descriptor (insn);
8705   return output_call (insn, operands[0], 1);
8707   [(set_attr "type" "call")
8708    (set (attr "length") (symbol_ref "attr_length_call (insn, 1)"))])
8710 (define_expand "sibcall_value"
8711   [(set (match_operand 0 "" "")
8712                    (call (match_operand:SI 1 "" "")
8713                          (match_operand 2 "" "")))]
8714   "!TARGET_PORTABLE_RUNTIME"
8715   "
8717   rtx op, call_insn;
8718   rtx nb = operands[1];
8720   op = XEXP (operands[1], 0);
8722   if (TARGET_64BIT)
8723     {
8724       if (!virtuals_instantiated)
8725         emit_move_insn (arg_pointer_rtx,
8726                         gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
8727                                       GEN_INT (64)));
8728       else
8729         {
8730           /* The loop pass can generate new libcalls after the virtual
8731              registers are instantiated when fpregs are disabled because
8732              the only method that we have for doing DImode multiplication
8733              is with a libcall.  This could be trouble if we haven't
8734              allocated enough space for the outgoing arguments.  */
8735           gcc_assert (INTVAL (nb) <= crtl->outgoing_args_size);
8737           emit_move_insn (arg_pointer_rtx,
8738                           gen_rtx_PLUS (word_mode, stack_pointer_rtx,
8739                                         GEN_INT (STACK_POINTER_OFFSET + 64)));
8740         }
8741     }
8743   /* Indirect sibling calls are not allowed.  */
8744   if (TARGET_64BIT)
8745     call_insn
8746       = gen_sibcall_value_internal_symref_64bit (operands[0], op, operands[2]);
8747   else
8748     call_insn
8749       = gen_sibcall_value_internal_symref (operands[0], op, operands[2]);
8751   call_insn = emit_call_insn (call_insn);
8753   if (TARGET_64BIT)
8754     use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), arg_pointer_rtx);
8756   /* We don't have to restore the PIC register.  */
8757   if (flag_pic)
8758     use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
8760   DONE;
8763 (define_insn "sibcall_value_internal_symref"
8764   [(set (match_operand 0 "" "")
8765         (call (mem:SI (match_operand 1 "call_operand_address" ""))
8766               (match_operand 2 "" "i")))
8767    (clobber (reg:SI 1))
8768    (use (reg:SI 2))
8769    (use (const_int 0))]
8770   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8771   "*
8773   output_arg_descriptor (insn);
8774   return output_call (insn, operands[1], 1);
8776   [(set_attr "type" "call")
8777    (set (attr "length") (symbol_ref "attr_length_call (insn, 1)"))])
8779 (define_insn "sibcall_value_internal_symref_64bit"
8780   [(set (match_operand 0 "" "")
8781         (call (mem:SI (match_operand 1 "call_operand_address" ""))
8782               (match_operand 2 "" "i")))
8783    (clobber (reg:DI 1))
8784    (use (reg:DI 2))
8785    (use (const_int 0))]
8786   "TARGET_64BIT"
8787   "*
8789   output_arg_descriptor (insn);
8790   return output_call (insn, operands[1], 1);
8792   [(set_attr "type" "call")
8793    (set (attr "length") (symbol_ref "attr_length_call (insn, 1)"))])
8795 (define_insn "nop"
8796   [(const_int 0)]
8797   ""
8798   "nop"
8799   [(set_attr "type" "move")
8800    (set_attr "length" "4")])
8802 ;; These are just placeholders so we know where branch tables
8803 ;; begin and end.
8804 (define_insn "begin_brtab"
8805   [(const_int 1)]
8806   ""
8807   "*
8809   /* Only GAS actually supports this pseudo-op.  */
8810   if (TARGET_GAS)
8811     return \".begin_brtab\";
8812   else
8813     return \"\";
8815   [(set_attr "type" "move")
8816    (set_attr "length" "0")])
8818 (define_insn "end_brtab"
8819   [(const_int 2)]
8820   ""
8821   "*
8823   /* Only GAS actually supports this pseudo-op.  */
8824   if (TARGET_GAS)
8825     return \".end_brtab\";
8826   else
8827     return \"\";
8829   [(set_attr "type" "move")
8830    (set_attr "length" "0")])
8832 ;;; EH does longjmp's from and within the data section.  Thus,
8833 ;;; an interspace branch is required for the longjmp implementation.
8834 ;;; Registers r1 and r2 are used as scratch registers for the jump
8835 ;;; when necessary.
8836 (define_expand "interspace_jump"
8837   [(parallel
8838      [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8839       (clobber (match_dup 1))])]
8840   ""
8841   "
8843   operands[1] = gen_rtx_REG (word_mode, 2);
8846 (define_insn ""
8847   [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8848   (clobber (reg:SI 2))]
8849   "TARGET_PA_20 && !TARGET_64BIT"
8850   "bve%* (%0)"
8851    [(set_attr "type" "branch")
8852     (set_attr "length" "4")])
8854 (define_insn ""
8855   [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8856   (clobber (reg:SI 2))]
8857   "TARGET_NO_SPACE_REGS && !TARGET_64BIT"
8858   "be%* 0(%%sr4,%0)"
8859    [(set_attr "type" "branch")
8860     (set_attr "length" "4")])
8862 (define_insn ""
8863   [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8864   (clobber (reg:SI 2))]
8865   "!TARGET_64BIT"
8866   "ldsid (%%sr0,%0),%%r2\;mtsp %%r2,%%sr0\;be%* 0(%%sr0,%0)"
8867    [(set_attr "type" "branch")
8868     (set_attr "length" "12")])
8870 (define_insn ""
8871   [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8872   (clobber (reg:DI 2))]
8873   "TARGET_64BIT"
8874   "bve%* (%0)"
8875    [(set_attr "type" "branch")
8876     (set_attr "length" "4")])
8878 (define_expand "builtin_longjmp"
8879   [(unspec_volatile [(match_operand 0 "register_operand" "r")] UNSPECV_LONGJMP)]
8880   ""
8881   "
8883   /* The elements of the buffer are, in order:  */
8884   rtx fp = gen_rtx_MEM (Pmode, operands[0]);
8885   rtx lab = gen_rtx_MEM (Pmode, plus_constant (operands[0],
8886                          POINTER_SIZE / BITS_PER_UNIT));
8887   rtx stack = gen_rtx_MEM (Pmode, plus_constant (operands[0],
8888                            (POINTER_SIZE * 2) / BITS_PER_UNIT));
8889   rtx pv = gen_rtx_REG (Pmode, 1);
8891   emit_clobber (gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (VOIDmode)));
8892   emit_clobber (gen_rtx_MEM (BLKmode, hard_frame_pointer_rtx));
8894   /* Restore the frame pointer.  The virtual_stack_vars_rtx is saved
8895      instead of the hard_frame_pointer_rtx in the save area.  We need
8896      to adjust for the offset between these two values when we have
8897      a nonlocal_goto pattern.  When we don't have a nonlocal_goto
8898      pattern, the receiver performs the adjustment.  */
8899 #ifdef HAVE_nonlocal_goto
8900   if (HAVE_nonlocal_goto)
8901     emit_move_insn (virtual_stack_vars_rtx, force_reg (Pmode, fp));
8902   else
8903 #endif
8904     emit_move_insn (hard_frame_pointer_rtx, fp);
8906   /* This bit is the same as expand_builtin_longjmp.  */
8907   emit_stack_restore (SAVE_NONLOCAL, stack, NULL_RTX);
8908   emit_use (hard_frame_pointer_rtx);
8909   emit_use (stack_pointer_rtx);
8911   /* Load the label we are jumping through into r1 so that we know
8912      where to look for it when we get back to setjmp's function for
8913      restoring the gp.  */
8914   emit_move_insn (pv, lab);
8916   /* Prevent the insns above from being scheduled into the delay slot
8917      of the interspace jump because the space register could change.  */
8918   emit_insn (gen_blockage ());
8920   emit_jump_insn (gen_interspace_jump (pv));
8921   emit_barrier ();
8922   DONE;
8925 ;;; Operands 2 and 3 are assumed to be CONST_INTs.
8926 (define_expand "extzv"
8927   [(set (match_operand 0 "register_operand" "")
8928         (zero_extract (match_operand 1 "register_operand" "")
8929                       (match_operand 2 "uint32_operand" "")
8930                       (match_operand 3 "uint32_operand" "")))]
8931   ""
8932   "
8934   HOST_WIDE_INT len = INTVAL (operands[2]);
8935   HOST_WIDE_INT pos = INTVAL (operands[3]);
8937   /* PA extraction insns don't support zero length bitfields or fields
8938      extending beyond the left or right-most bits.  Also, we reject lengths
8939      equal to a word as they are better handled by the move patterns.  */
8940   if (len <= 0 || len >= BITS_PER_WORD || pos < 0 || pos + len > BITS_PER_WORD)
8941     FAIL;
8943   /* From mips.md: extract_bit_field doesn't verify that our source
8944      matches the predicate, so check it again here.  */
8945   if (!register_operand (operands[1], VOIDmode))
8946     FAIL;
8948   if (TARGET_64BIT)
8949     emit_insn (gen_extzv_64 (operands[0], operands[1],
8950                              operands[2], operands[3]));
8951   else
8952     emit_insn (gen_extzv_32 (operands[0], operands[1],
8953                              operands[2], operands[3]));
8954   DONE;
8957 (define_insn "extzv_32"
8958   [(set (match_operand:SI 0 "register_operand" "=r")
8959         (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
8960                          (match_operand:SI 2 "uint5_operand" "")
8961                          (match_operand:SI 3 "uint5_operand" "")))]
8962   ""
8963   "{extru|extrw,u} %1,%3+%2-1,%2,%0"
8964   [(set_attr "type" "shift")
8965    (set_attr "length" "4")])
8967 (define_insn ""
8968   [(set (match_operand:SI 0 "register_operand" "=r")
8969         (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
8970                          (const_int 1)
8971                          (match_operand:SI 2 "register_operand" "q")))]
8972   ""
8973   "{vextru %1,1,%0|extrw,u %1,%%sar,1,%0}"
8974   [(set_attr "type" "shift")
8975    (set_attr "length" "4")])
8977 (define_insn "extzv_64"
8978   [(set (match_operand:DI 0 "register_operand" "=r")
8979         (zero_extract:DI (match_operand:DI 1 "register_operand" "r")
8980                          (match_operand:DI 2 "uint32_operand" "")
8981                          (match_operand:DI 3 "uint32_operand" "")))]
8982   "TARGET_64BIT"
8983   "extrd,u %1,%3+%2-1,%2,%0"
8984   [(set_attr "type" "shift")
8985    (set_attr "length" "4")])
8987 (define_insn ""
8988   [(set (match_operand:DI 0 "register_operand" "=r")
8989         (zero_extract:DI (match_operand:DI 1 "register_operand" "r")
8990                          (const_int 1)
8991                          (match_operand:DI 2 "register_operand" "q")))]
8992   "TARGET_64BIT"
8993   "extrd,u %1,%%sar,1,%0"
8994   [(set_attr "type" "shift")
8995    (set_attr "length" "4")])
8997 ;;; Operands 2 and 3 are assumed to be CONST_INTs.
8998 (define_expand "extv"
8999   [(set (match_operand 0 "register_operand" "")
9000         (sign_extract (match_operand 1 "register_operand" "")
9001                       (match_operand 2 "uint32_operand" "")
9002                       (match_operand 3 "uint32_operand" "")))]
9003   ""
9004   "
9006   HOST_WIDE_INT len = INTVAL (operands[2]);
9007   HOST_WIDE_INT pos = INTVAL (operands[3]);
9009   /* PA extraction insns don't support zero length bitfields or fields
9010      extending beyond the left or right-most bits.  Also, we reject lengths
9011      equal to a word as they are better handled by the move patterns.  */
9012   if (len <= 0 || len >= BITS_PER_WORD || pos < 0 || pos + len > BITS_PER_WORD)
9013     FAIL;
9015   /* From mips.md: extract_bit_field doesn't verify that our source
9016      matches the predicate, so check it again here.  */
9017   if (!register_operand (operands[1], VOIDmode))
9018     FAIL;
9020   if (TARGET_64BIT)
9021     emit_insn (gen_extv_64 (operands[0], operands[1],
9022                             operands[2], operands[3]));
9023   else
9024     emit_insn (gen_extv_32 (operands[0], operands[1],
9025                             operands[2], operands[3]));
9026   DONE;
9029 (define_insn "extv_32"
9030   [(set (match_operand:SI 0 "register_operand" "=r")
9031         (sign_extract:SI (match_operand:SI 1 "register_operand" "r")
9032                          (match_operand:SI 2 "uint5_operand" "")
9033                          (match_operand:SI 3 "uint5_operand" "")))]
9034   ""
9035   "{extrs|extrw,s} %1,%3+%2-1,%2,%0"
9036   [(set_attr "type" "shift")
9037    (set_attr "length" "4")])
9039 (define_insn ""
9040   [(set (match_operand:SI 0 "register_operand" "=r")
9041         (sign_extract:SI (match_operand:SI 1 "register_operand" "r")
9042                          (const_int 1)
9043                          (match_operand:SI 2 "register_operand" "q")))]
9044   "!TARGET_64BIT"
9045   "{vextrs %1,1,%0|extrw,s %1,%%sar,1,%0}"
9046   [(set_attr "type" "shift")
9047    (set_attr "length" "4")])
9049 (define_insn "extv_64"
9050   [(set (match_operand:DI 0 "register_operand" "=r")
9051         (sign_extract:DI (match_operand:DI 1 "register_operand" "r")
9052                          (match_operand:DI 2 "uint32_operand" "")
9053                          (match_operand:DI 3 "uint32_operand" "")))]
9054   "TARGET_64BIT"
9055   "extrd,s %1,%3+%2-1,%2,%0"
9056   [(set_attr "type" "shift")
9057    (set_attr "length" "4")])
9059 (define_insn ""
9060   [(set (match_operand:DI 0 "register_operand" "=r")
9061         (sign_extract:DI (match_operand:DI 1 "register_operand" "r")
9062                          (const_int 1)
9063                          (match_operand:DI 2 "register_operand" "q")))]
9064   "TARGET_64BIT"
9065   "extrd,s %1,%%sar,1,%0"
9066   [(set_attr "type" "shift")
9067    (set_attr "length" "4")])
9069 ;;; Operands 1 and 2 are assumed to be CONST_INTs.
9070 (define_expand "insv"
9071   [(set (zero_extract (match_operand 0 "register_operand" "")
9072                       (match_operand 1 "uint32_operand" "")
9073                       (match_operand 2 "uint32_operand" ""))
9074         (match_operand 3 "arith5_operand" ""))]
9075   ""
9076   "
9078   HOST_WIDE_INT len = INTVAL (operands[1]);
9079   HOST_WIDE_INT pos = INTVAL (operands[2]);
9081   /* PA insertion insns don't support zero length bitfields or fields
9082      extending beyond the left or right-most bits.  Also, we reject lengths
9083      equal to a word as they are better handled by the move patterns.  */
9084   if (len <= 0 || len >= BITS_PER_WORD || pos < 0 || pos + len > BITS_PER_WORD)
9085     FAIL;
9087   /* From mips.md: insert_bit_field doesn't verify that our destination
9088      matches the predicate, so check it again here.  */
9089   if (!register_operand (operands[0], VOIDmode))
9090     FAIL;
9092   if (TARGET_64BIT)
9093     emit_insn (gen_insv_64 (operands[0], operands[1],
9094                             operands[2], operands[3]));
9095   else
9096     emit_insn (gen_insv_32 (operands[0], operands[1],
9097                             operands[2], operands[3]));
9098   DONE;
9101 (define_insn "insv_32"
9102   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r,r")
9103                          (match_operand:SI 1 "uint5_operand" "")
9104                          (match_operand:SI 2 "uint5_operand" ""))
9105         (match_operand:SI 3 "arith5_operand" "r,L"))]
9106   ""
9107   "@
9108    {dep|depw} %3,%2+%1-1,%1,%0
9109    {depi|depwi} %3,%2+%1-1,%1,%0"
9110   [(set_attr "type" "shift,shift")
9111    (set_attr "length" "4,4")])
9113 ;; Optimize insertion of const_int values of type 1...1xxxx.
9114 (define_insn ""
9115   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
9116                          (match_operand:SI 1 "uint5_operand" "")
9117                          (match_operand:SI 2 "uint5_operand" ""))
9118         (match_operand:SI 3 "const_int_operand" ""))]
9119   "(INTVAL (operands[3]) & 0x10) != 0 &&
9120    (~INTVAL (operands[3]) & ((1L << INTVAL (operands[1])) - 1) & ~0xf) == 0"
9121   "*
9123   operands[3] = GEN_INT ((INTVAL (operands[3]) & 0xf) - 0x10);
9124   return \"{depi|depwi} %3,%2+%1-1,%1,%0\";
9126   [(set_attr "type" "shift")
9127    (set_attr "length" "4")])
9129 (define_insn "insv_64"
9130   [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+r,r")
9131                          (match_operand:DI 1 "uint32_operand" "")
9132                          (match_operand:DI 2 "uint32_operand" ""))
9133         (match_operand:DI 3 "arith32_operand" "r,L"))]
9134   "TARGET_64BIT"
9135   "@
9136    depd %3,%2+%1-1,%1,%0
9137    depdi %3,%2+%1-1,%1,%0"
9138   [(set_attr "type" "shift,shift")
9139    (set_attr "length" "4,4")])
9141 ;; Optimize insertion of const_int values of type 1...1xxxx.
9142 (define_insn ""
9143   [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+r")
9144                          (match_operand:DI 1 "uint32_operand" "")
9145                          (match_operand:DI 2 "uint32_operand" ""))
9146         (match_operand:DI 3 "const_int_operand" ""))]
9147   "(INTVAL (operands[3]) & 0x10) != 0
9148    && TARGET_64BIT
9149    && (~INTVAL (operands[3]) & ((1L << INTVAL (operands[1])) - 1) & ~0xf) == 0"
9150   "*
9152   operands[3] = GEN_INT ((INTVAL (operands[3]) & 0xf) - 0x10);
9153   return \"depdi %3,%2+%1-1,%1,%0\";
9155   [(set_attr "type" "shift")
9156    (set_attr "length" "4")])
9158 (define_insn ""
9159   [(set (match_operand:DI 0 "register_operand" "=r")
9160         (ashift:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
9161                    (const_int 32)))]
9162   "TARGET_64BIT"
9163   "depd,z %1,31,32,%0"
9164   [(set_attr "type" "shift")
9165    (set_attr "length" "4")])
9167 ;; This insn is used for some loop tests, typically loops reversed when
9168 ;; strength reduction is used.  It is actually created when the instruction
9169 ;; combination phase combines the special loop test.  Since this insn
9170 ;; is both a jump insn and has an output, it must deal with its own
9171 ;; reloads, hence the `m' constraints.  The `!' constraints direct reload
9172 ;; to not choose the register alternatives in the event a reload is needed.
9173 (define_insn "decrement_and_branch_until_zero"
9174   [(set (pc)
9175         (if_then_else
9176           (match_operator 2 "comparison_operator"
9177            [(plus:SI
9178               (match_operand:SI 0 "reg_before_reload_operand" "+!r,!*f,*m")
9179               (match_operand:SI 1 "int5_operand" "L,L,L"))
9180             (const_int 0)])
9181           (label_ref (match_operand 3 "" ""))
9182           (pc)))
9183    (set (match_dup 0)
9184         (plus:SI (match_dup 0) (match_dup 1)))
9185    (clobber (match_scratch:SI 4 "=X,r,r"))]
9186   ""
9187   "* return output_dbra (operands, insn, which_alternative); "
9188 ;; Do not expect to understand this the first time through.
9189 [(set_attr "type" "cbranch,multi,multi")
9190  (set (attr "length")
9191       (if_then_else (eq_attr "alternative" "0")
9192 ;; Loop counter in register case
9193 ;; Short branch has length of 4
9194 ;; Long branch has length of 8, 20, 24 or 28
9195         (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9196                (const_int MAX_12BIT_OFFSET))
9197            (const_int 4)
9198            (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9199                (const_int MAX_17BIT_OFFSET))
9200            (const_int 8)
9201            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9202            (const_int 24)
9203            (eq (symbol_ref "flag_pic") (const_int 0))
9204            (const_int 20)]
9205           (const_int 28))
9207 ;; Loop counter in FP reg case.
9208 ;; Extra goo to deal with additional reload insns.
9209         (if_then_else (eq_attr "alternative" "1")
9210           (if_then_else (lt (match_dup 3) (pc))
9211              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 24))))
9212                       (const_int MAX_12BIT_OFFSET))
9213                     (const_int 24)
9214                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 24))))
9215                       (const_int MAX_17BIT_OFFSET))
9216                     (const_int 28)
9217                     (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9218                     (const_int 44)
9219                     (eq (symbol_ref "flag_pic") (const_int 0))
9220                     (const_int 40)]
9221                   (const_int 48))
9222              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9223                       (const_int MAX_12BIT_OFFSET))
9224                     (const_int 24)
9225                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9226                       (const_int MAX_17BIT_OFFSET))
9227                     (const_int 28)
9228                     (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9229                     (const_int 44)
9230                     (eq (symbol_ref "flag_pic") (const_int 0))
9231                     (const_int 40)]
9232                   (const_int 48)))
9234 ;; Loop counter in memory case.
9235 ;; Extra goo to deal with additional reload insns.
9236         (if_then_else (lt (match_dup 3) (pc))
9237              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9238                       (const_int MAX_12BIT_OFFSET))
9239                     (const_int 12)
9240                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9241                       (const_int MAX_17BIT_OFFSET))
9242                     (const_int 16)
9243                     (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9244                     (const_int 32)
9245                     (eq (symbol_ref "flag_pic") (const_int 0))
9246                     (const_int 28)]
9247                   (const_int 36))
9248              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9249                       (const_int MAX_12BIT_OFFSET))
9250                     (const_int 12)
9251                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9252                       (const_int MAX_17BIT_OFFSET))
9253                     (const_int 16)
9254                     (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9255                     (const_int 32)
9256                     (eq (symbol_ref "flag_pic") (const_int 0))
9257                     (const_int 28)]
9258                   (const_int 36))))))])
9260 (define_insn ""
9261   [(set (pc)
9262         (if_then_else
9263           (match_operator 2 "movb_comparison_operator"
9264            [(match_operand:SI 1 "register_operand" "r,r,r,r") (const_int 0)])
9265           (label_ref (match_operand 3 "" ""))
9266           (pc)))
9267    (set (match_operand:SI 0 "reg_before_reload_operand" "=!r,!*f,*m,!*q")
9268         (match_dup 1))]
9269   ""
9270 "* return output_movb (operands, insn, which_alternative, 0); "
9271 ;; Do not expect to understand this the first time through.
9272 [(set_attr "type" "cbranch,multi,multi,multi")
9273  (set (attr "length")
9274       (if_then_else (eq_attr "alternative" "0")
9275 ;; Loop counter in register case
9276 ;; Short branch has length of 4
9277 ;; Long branch has length of 8, 20, 24 or 28
9278         (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9279                (const_int MAX_12BIT_OFFSET))
9280            (const_int 4)
9281            (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9282                (const_int MAX_17BIT_OFFSET))
9283            (const_int 8)
9284            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9285            (const_int 24)
9286            (eq (symbol_ref "flag_pic") (const_int 0))
9287            (const_int 20)]
9288           (const_int 28))
9290 ;; Loop counter in FP reg case.
9291 ;; Extra goo to deal with additional reload insns.
9292         (if_then_else (eq_attr "alternative" "1")
9293           (if_then_else (lt (match_dup 3) (pc))
9294              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9295                       (const_int MAX_12BIT_OFFSET))
9296                     (const_int 12)
9297                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9298                       (const_int MAX_17BIT_OFFSET))
9299                     (const_int 16)
9300                     (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9301                     (const_int 32)
9302                     (eq (symbol_ref "flag_pic") (const_int 0))
9303                     (const_int 28)]
9304                   (const_int 36))
9305              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9306                       (const_int MAX_12BIT_OFFSET))
9307                     (const_int 12)
9308                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9309                       (const_int MAX_17BIT_OFFSET))
9310                     (const_int 16)
9311                     (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9312                     (const_int 32)
9313                     (eq (symbol_ref "flag_pic") (const_int 0))
9314                     (const_int 28)]
9315                   (const_int 36)))
9317 ;; Loop counter in memory or sar case.
9318 ;; Extra goo to deal with additional reload insns.
9319         (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9320                    (const_int MAX_12BIT_OFFSET))
9321                 (const_int 8)
9322                 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9323                   (const_int MAX_17BIT_OFFSET))
9324                 (const_int 12)
9325                 (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9326                 (const_int 28)
9327                 (eq (symbol_ref "flag_pic") (const_int 0))
9328                 (const_int 24)]
9329               (const_int 32)))))])
9331 ;; Handle negated branch.
9332 (define_insn ""
9333   [(set (pc)
9334         (if_then_else
9335           (match_operator 2 "movb_comparison_operator"
9336            [(match_operand:SI 1 "register_operand" "r,r,r,r") (const_int 0)])
9337           (pc)
9338           (label_ref (match_operand 3 "" ""))))
9339    (set (match_operand:SI 0 "reg_before_reload_operand" "=!r,!*f,*m,!*q")
9340         (match_dup 1))]
9341   ""
9342 "* return output_movb (operands, insn, which_alternative, 1); "
9343 ;; Do not expect to understand this the first time through.
9344 [(set_attr "type" "cbranch,multi,multi,multi")
9345  (set (attr "length")
9346       (if_then_else (eq_attr "alternative" "0")
9347 ;; Loop counter in register case
9348 ;; Short branch has length of 4
9349 ;; Long branch has length of 8
9350         (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9351                (const_int MAX_12BIT_OFFSET))
9352            (const_int 4)
9353            (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9354                (const_int MAX_17BIT_OFFSET))
9355            (const_int 8)
9356            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9357            (const_int 24)
9358            (eq (symbol_ref "flag_pic") (const_int 0))
9359            (const_int 20)]
9360           (const_int 28))
9362 ;; Loop counter in FP reg case.
9363 ;; Extra goo to deal with additional reload insns.
9364         (if_then_else (eq_attr "alternative" "1")
9365           (if_then_else (lt (match_dup 3) (pc))
9366              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9367                       (const_int MAX_12BIT_OFFSET))
9368                     (const_int 12)
9369                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9370                       (const_int MAX_17BIT_OFFSET))
9371                     (const_int 16)
9372                     (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9373                     (const_int 32)
9374                     (eq (symbol_ref "flag_pic") (const_int 0))
9375                     (const_int 28)]
9376                   (const_int 36))
9377              (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9378                       (const_int MAX_12BIT_OFFSET))
9379                     (const_int 12)
9380                     (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9381                       (const_int MAX_17BIT_OFFSET))
9382                     (const_int 16)
9383                     (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9384                     (const_int 32)
9385                     (eq (symbol_ref "flag_pic") (const_int 0))
9386                     (const_int 28)]
9387                   (const_int 36)))
9389 ;; Loop counter in memory or SAR case.
9390 ;; Extra goo to deal with additional reload insns.
9391         (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9392                    (const_int MAX_12BIT_OFFSET))
9393                 (const_int 8)
9394                 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9395                   (const_int MAX_17BIT_OFFSET))
9396                 (const_int 12)
9397                 (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9398                 (const_int 28)
9399                 (eq (symbol_ref "flag_pic") (const_int 0))
9400                 (const_int 24)]
9401               (const_int 32)))))])
9403 (define_insn ""
9404   [(set (pc) (label_ref (match_operand 3 "" "" )))
9405    (set (match_operand:SI 0 "ireg_operand" "=r")
9406         (plus:SI (match_operand:SI 1 "ireg_operand" "r")
9407                  (match_operand:SI 2 "ireg_or_int5_operand" "rL")))]
9408   "(reload_completed && operands[0] == operands[1]) || operands[0] == operands[2]"
9409   "*
9411   return output_parallel_addb (operands, insn);
9413 [(set_attr "type" "parallel_branch")
9414  (set (attr "length")
9415     (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9416                (const_int MAX_12BIT_OFFSET))
9417            (const_int 4)
9418            (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9419                (const_int MAX_17BIT_OFFSET))
9420            (const_int 8)
9421            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9422            (const_int 24)
9423            (eq (symbol_ref "flag_pic") (const_int 0))
9424            (const_int 20)]
9425           (const_int 28)))])
9427 (define_insn ""
9428   [(set (pc) (label_ref (match_operand 2 "" "" )))
9429    (set (match_operand:SF 0 "ireg_operand" "=r")
9430         (match_operand:SF 1 "ireg_or_int5_operand" "rL"))]
9431   "reload_completed"
9432   "*
9434   return output_parallel_movb (operands, insn);
9436 [(set_attr "type" "parallel_branch")
9437  (set (attr "length")
9438     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9439                (const_int MAX_12BIT_OFFSET))
9440            (const_int 4)
9441            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9442                (const_int MAX_17BIT_OFFSET))
9443            (const_int 8)
9444            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9445            (const_int 24)
9446            (eq (symbol_ref "flag_pic") (const_int 0))
9447            (const_int 20)]
9448           (const_int 28)))])
9450 (define_insn ""
9451   [(set (pc) (label_ref (match_operand 2 "" "" )))
9452    (set (match_operand:SI 0 "ireg_operand" "=r")
9453         (match_operand:SI 1 "ireg_or_int5_operand" "rL"))]
9454   "reload_completed"
9455   "*
9457   return output_parallel_movb (operands, insn);
9459 [(set_attr "type" "parallel_branch")
9460  (set (attr "length")
9461     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9462                (const_int MAX_12BIT_OFFSET))
9463            (const_int 4)
9464            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9465                (const_int MAX_17BIT_OFFSET))
9466            (const_int 8)
9467            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9468            (const_int 24)
9469            (eq (symbol_ref "flag_pic") (const_int 0))
9470            (const_int 20)]
9471           (const_int 28)))])
9473 (define_insn ""
9474   [(set (pc) (label_ref (match_operand 2 "" "" )))
9475    (set (match_operand:HI 0 "ireg_operand" "=r")
9476         (match_operand:HI 1 "ireg_or_int5_operand" "rL"))]
9477   "reload_completed"
9478   "*
9480   return output_parallel_movb (operands, insn);
9482 [(set_attr "type" "parallel_branch")
9483  (set (attr "length")
9484     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9485                (const_int MAX_12BIT_OFFSET))
9486            (const_int 4)
9487            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9488                (const_int MAX_17BIT_OFFSET))
9489            (const_int 8)
9490            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9491            (const_int 24)
9492            (eq (symbol_ref "flag_pic") (const_int 0))
9493            (const_int 20)]
9494           (const_int 28)))])
9496 (define_insn ""
9497   [(set (pc) (label_ref (match_operand 2 "" "" )))
9498    (set (match_operand:QI 0 "ireg_operand" "=r")
9499         (match_operand:QI 1 "ireg_or_int5_operand" "rL"))]
9500   "reload_completed"
9501   "*
9503   return output_parallel_movb (operands, insn);
9505 [(set_attr "type" "parallel_branch")
9506  (set (attr "length")
9507     (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9508                (const_int MAX_12BIT_OFFSET))
9509            (const_int 4)
9510            (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9511                (const_int MAX_17BIT_OFFSET))
9512            (const_int 8)
9513            (ne (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0))
9514            (const_int 24)
9515            (eq (symbol_ref "flag_pic") (const_int 0))
9516            (const_int 20)]
9517           (const_int 28)))])
9519 (define_insn ""
9520   [(set (match_operand 0 "register_operand" "=f")
9521         (mult (match_operand 1 "register_operand" "f")
9522               (match_operand 2 "register_operand" "f")))
9523    (set (match_operand 3 "register_operand" "+f")
9524         (plus (match_operand 4 "register_operand" "f")
9525               (match_operand 5 "register_operand" "f")))]
9526   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9527    && reload_completed && fmpyaddoperands (operands)"
9528   "*
9530   if (GET_MODE (operands[0]) == DFmode)
9531     {
9532       if (rtx_equal_p (operands[3], operands[5]))
9533         return \"fmpyadd,dbl %1,%2,%0,%4,%3\";
9534       else
9535         return \"fmpyadd,dbl %1,%2,%0,%5,%3\";
9536     }
9537   else
9538     {
9539       if (rtx_equal_p (operands[3], operands[5]))
9540         return \"fmpyadd,sgl %1,%2,%0,%4,%3\";
9541       else
9542         return \"fmpyadd,sgl %1,%2,%0,%5,%3\";
9543     }
9545   [(set_attr "type" "fpalu")
9546    (set_attr "length" "4")])
9548 (define_insn ""
9549   [(set (match_operand 3 "register_operand" "+f")
9550         (plus (match_operand 4 "register_operand" "f")
9551               (match_operand 5 "register_operand" "f")))
9552    (set (match_operand 0 "register_operand" "=f")
9553         (mult (match_operand 1 "register_operand" "f")
9554               (match_operand 2 "register_operand" "f")))]
9555   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9556    && reload_completed && fmpyaddoperands (operands)"
9557   "*
9559   if (GET_MODE (operands[0]) == DFmode)
9560     {
9561       if (rtx_equal_p (operands[3], operands[5]))
9562         return \"fmpyadd,dbl %1,%2,%0,%4,%3\";
9563       else
9564         return \"fmpyadd,dbl %1,%2,%0,%5,%3\";
9565     }
9566   else
9567     {
9568       if (rtx_equal_p (operands[3], operands[5]))
9569         return \"fmpyadd,sgl %1,%2,%0,%4,%3\";
9570       else
9571         return \"fmpyadd,sgl %1,%2,%0,%5,%3\";
9572     }
9574   [(set_attr "type" "fpalu")
9575    (set_attr "length" "4")])
9577 (define_insn ""
9578   [(set (match_operand 0 "register_operand" "=f")
9579         (mult (match_operand 1 "register_operand" "f")
9580               (match_operand 2 "register_operand" "f")))
9581    (set (match_operand 3 "register_operand" "+f")
9582         (minus (match_operand 4 "register_operand" "f")
9583                (match_operand 5 "register_operand" "f")))]
9584   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9585    && reload_completed && fmpysuboperands (operands)"
9586   "*
9588   if (GET_MODE (operands[0]) == DFmode)
9589     return \"fmpysub,dbl %1,%2,%0,%5,%3\";
9590   else
9591     return \"fmpysub,sgl %1,%2,%0,%5,%3\";
9593   [(set_attr "type" "fpalu")
9594    (set_attr "length" "4")])
9596 (define_insn ""
9597   [(set (match_operand 3 "register_operand" "+f")
9598         (minus (match_operand 4 "register_operand" "f")
9599                (match_operand 5 "register_operand" "f")))
9600    (set (match_operand 0 "register_operand" "=f")
9601         (mult (match_operand 1 "register_operand" "f")
9602               (match_operand 2 "register_operand" "f")))]
9603   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9604    && reload_completed && fmpysuboperands (operands)"
9605   "*
9607   if (GET_MODE (operands[0]) == DFmode)
9608     return \"fmpysub,dbl %1,%2,%0,%5,%3\";
9609   else
9610     return \"fmpysub,sgl %1,%2,%0,%5,%3\";
9612   [(set_attr "type" "fpalu")
9613    (set_attr "length" "4")])
9615 ;; The following two patterns are used by the trampoline code for nested
9616 ;; functions.  They flush the I and D cache lines from the start address
9617 ;; (operand0) to the end address (operand1).  No lines are flushed if the
9618 ;; end address is less than the start address (unsigned).
9620 ;; Because the range of memory flushed is variable and the size of a MEM
9621 ;; can only be a CONST_INT, the patterns specify that they perform an
9622 ;; unspecified volatile operation on all memory.
9624 ;; The address range for an icache flush must lie within a single
9625 ;; space on targets with non-equivalent space registers.
9627 ;; Operand 0 contains the start address.
9628 ;; Operand 1 contains the end address.
9629 ;; Operand 2 contains the line length to use.
9630 (define_insn "dcacheflush<P:mode>"
9631   [(const_int 1)
9632    (unspec_volatile [(mem:BLK (scratch))] UNSPECV_DCACHE)
9633    (use (match_operand 0 "pmode_register_operand" "r"))
9634    (use (match_operand 1 "pmode_register_operand" "r"))
9635    (use (match_operand 2 "pmode_register_operand" "r"))
9636    (clobber (match_scratch:P 3 "=&0"))]
9637   ""
9638   "cmpb,<dwc><<=,n %3,%1,.\;fdc,m %2(%3)\;sync"
9639   [(set_attr "type" "multi")
9640    (set_attr "length" "12")])
9642 (define_insn "icacheflush<P:mode>"
9643   [(const_int 2)
9644    (unspec_volatile [(mem:BLK (scratch))] UNSPECV_ICACHE)
9645    (use (match_operand 0 "pmode_register_operand" "r"))
9646    (use (match_operand 1 "pmode_register_operand" "r"))
9647    (use (match_operand 2 "pmode_register_operand" "r"))
9648    (clobber (match_operand 3 "pmode_register_operand" "=&r"))
9649    (clobber (match_operand 4 "pmode_register_operand" "=&r"))
9650    (clobber (match_scratch:P 5 "=&0"))]
9651   ""
9652   "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"
9653   [(set_attr "type" "multi")
9654    (set_attr "length" "52")])
9656 ;; An out-of-line prologue.
9657 (define_insn "outline_prologue_call"
9658   [(unspec_volatile [(const_int 0)] UNSPECV_OPC)
9659    (clobber (reg:SI 31))
9660    (clobber (reg:SI 22))
9661    (clobber (reg:SI 21))
9662    (clobber (reg:SI 20))
9663    (clobber (reg:SI 19))
9664    (clobber (reg:SI 1))]
9665   ""
9666   "*
9669   /* We need two different versions depending on whether or not we
9670      need a frame pointer.   Also note that we return to the instruction
9671      immediately after the branch rather than two instructions after the
9672      break as normally is the case.  */
9673   if (frame_pointer_needed)
9674     {
9675       /* Must import the magic millicode routine(s).  */
9676       output_asm_insn (\".IMPORT __outline_prologue_fp,MILLICODE\", NULL);
9678       if (TARGET_PORTABLE_RUNTIME)
9679         {
9680           output_asm_insn (\"ldil L'__outline_prologue_fp,%%r31\", NULL);
9681           output_asm_insn (\"ble,n R'__outline_prologue_fp(%%sr0,%%r31)\",
9682                            NULL);
9683         }
9684       else
9685         output_asm_insn (\"{bl|b,l},n __outline_prologue_fp,%%r31\", NULL);
9686     }
9687   else
9688     {
9689       /* Must import the magic millicode routine(s).  */
9690       output_asm_insn (\".IMPORT __outline_prologue,MILLICODE\", NULL);
9692       if (TARGET_PORTABLE_RUNTIME)
9693         {
9694           output_asm_insn (\"ldil L'__outline_prologue,%%r31\", NULL);
9695           output_asm_insn (\"ble,n R'__outline_prologue(%%sr0,%%r31)\", NULL);
9696         }
9697       else
9698         output_asm_insn (\"{bl|b,l},n __outline_prologue,%%r31\", NULL);
9699     }
9700   return \"\";
9702   [(set_attr "type" "multi")
9703    (set_attr "length" "8")])
9705 ;; An out-of-line epilogue.
9706 (define_insn "outline_epilogue_call"
9707   [(unspec_volatile [(const_int 1)] UNSPECV_OEC)
9708    (use (reg:SI 29))
9709    (use (reg:SI 28))
9710    (clobber (reg:SI 31))
9711    (clobber (reg:SI 22))
9712    (clobber (reg:SI 21))
9713    (clobber (reg:SI 20))
9714    (clobber (reg:SI 19))
9715    (clobber (reg:SI 2))
9716    (clobber (reg:SI 1))]
9717   ""
9718   "*
9721   /* We need two different versions depending on whether or not we
9722      need a frame pointer.   Also note that we return to the instruction
9723      immediately after the branch rather than two instructions after the
9724      break as normally is the case.  */
9725   if (frame_pointer_needed)
9726     {
9727       /* Must import the magic millicode routine.  */
9728       output_asm_insn (\".IMPORT __outline_epilogue_fp,MILLICODE\", NULL);
9730       /* The out-of-line prologue will make sure we return to the right
9731          instruction.  */
9732       if (TARGET_PORTABLE_RUNTIME)
9733         {
9734           output_asm_insn (\"ldil L'__outline_epilogue_fp,%%r31\", NULL);
9735           output_asm_insn (\"ble,n R'__outline_epilogue_fp(%%sr0,%%r31)\",
9736                            NULL);
9737         }
9738       else
9739         output_asm_insn (\"{bl|b,l},n __outline_epilogue_fp,%%r31\", NULL);
9740     }
9741   else
9742     {
9743       /* Must import the magic millicode routine.  */
9744       output_asm_insn (\".IMPORT __outline_epilogue,MILLICODE\", NULL);
9746       /* The out-of-line prologue will make sure we return to the right
9747          instruction.  */
9748       if (TARGET_PORTABLE_RUNTIME)
9749         {
9750           output_asm_insn (\"ldil L'__outline_epilogue,%%r31\", NULL);
9751           output_asm_insn (\"ble,n R'__outline_epilogue(%%sr0,%%r31)\", NULL);
9752         }
9753       else
9754         output_asm_insn (\"{bl|b,l},n __outline_epilogue,%%r31\", NULL);
9755     }
9756   return \"\";
9758   [(set_attr "type" "multi")
9759    (set_attr "length" "8")])
9761 ;; Given a function pointer, canonicalize it so it can be 
9762 ;; reliably compared to another function pointer.  */
9763 (define_expand "canonicalize_funcptr_for_compare"
9764   [(set (reg:SI 26) (match_operand:SI 1 "register_operand" ""))
9765    (parallel [(set (reg:SI 29) (unspec:SI [(reg:SI 26)] UNSPEC_CFFC))
9766               (clobber (match_dup 2))
9767               (clobber (reg:SI 26))
9768               (clobber (reg:SI 22))
9769               (clobber (reg:SI 31))])
9770    (set (match_operand:SI 0 "register_operand" "")
9771         (reg:SI 29))]
9772   "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
9773   "
9775   if (TARGET_ELF32)
9776     {
9777       rtx canonicalize_funcptr_for_compare_libfunc
9778         = init_one_libfunc (CANONICALIZE_FUNCPTR_FOR_COMPARE_LIBCALL);
9780       emit_library_call_value (canonicalize_funcptr_for_compare_libfunc,
9781                                operands[0], LCT_NORMAL, Pmode,
9782                                1, operands[1], Pmode);
9783       DONE;
9784     }
9786   operands[2] = gen_reg_rtx (SImode);
9787   if (GET_CODE (operands[1]) != REG)
9788     {
9789       rtx tmp = gen_reg_rtx (Pmode);
9790       emit_move_insn (tmp, operands[1]);
9791       operands[1] = tmp;
9792     }
9795 (define_insn "*$$sh_func_adrs"
9796   [(set (reg:SI 29) (unspec:SI [(reg:SI 26)] UNSPEC_CFFC))
9797    (clobber (match_operand:SI 0 "register_operand" "=a"))
9798    (clobber (reg:SI 26))
9799    (clobber (reg:SI 22))
9800    (clobber (reg:SI 31))]
9801   "!TARGET_64BIT"
9802   "*
9804   int length = get_attr_length (insn);
9805   rtx xoperands[2];
9807   xoperands[0] = GEN_INT (length - 8);
9808   xoperands[1] = GEN_INT (length - 16);
9810   /* Must import the magic millicode routine.  */
9811   output_asm_insn (\".IMPORT $$sh_func_adrs,MILLICODE\", NULL);
9813   /* This is absolutely amazing.
9815      First, copy our input parameter into %r29 just in case we don't
9816      need to call $$sh_func_adrs.  */
9817   output_asm_insn (\"copy %%r26,%%r29\", NULL);
9818   output_asm_insn (\"{extru|extrw,u} %%r26,31,2,%%r31\", NULL);
9820   /* Next, examine the low two bits in %r26, if they aren't 0x2, then
9821      we use %r26 unchanged.  */
9822   output_asm_insn (\"{comib|cmpib},<>,n 2,%%r31,.+%0\", xoperands);
9823   output_asm_insn (\"ldi 4096,%%r31\", NULL);
9825   /* Next, compare %r26 with 4096, if %r26 is less than or equal to
9826      4096, then again we use %r26 unchanged.  */
9827   output_asm_insn (\"{comb|cmpb},<<,n %%r26,%%r31,.+%1\", xoperands);
9829   /* Finally, call $$sh_func_adrs to extract the function's real add24.  */
9830   return output_millicode_call (insn,
9831                                 gen_rtx_SYMBOL_REF (SImode,
9832                                                     \"$$sh_func_adrs\"));
9834   [(set_attr "type" "multi")
9835    (set (attr "length")
9836         (plus (symbol_ref "attr_length_millicode_call (insn)")
9837               (const_int 20)))])
9839 ;; On the PA, the PIC register is call clobbered, so it must
9840 ;; be saved & restored around calls by the caller.  If the call
9841 ;; doesn't return normally (nonlocal goto, or an exception is
9842 ;; thrown), then the code at the exception handler label must
9843 ;; restore the PIC register.
9844 (define_expand "exception_receiver"
9845   [(const_int 4)]
9846   "flag_pic"
9847   "
9849   /* On the 64-bit port, we need a blockage because there is
9850      confusion regarding the dependence of the restore on the
9851      frame pointer.  As a result, the frame pointer and pic
9852      register restores sometimes are interchanged erroneously.  */
9853   if (TARGET_64BIT)
9854     emit_insn (gen_blockage ());
9855   /* Restore the PIC register using hppa_pic_save_rtx ().  The
9856      PIC register is not saved in the frame in 64-bit ABI.  */
9857   emit_move_insn (pic_offset_table_rtx, hppa_pic_save_rtx ());
9858   emit_insn (gen_blockage ());
9859   DONE;
9862 (define_expand "builtin_setjmp_receiver"
9863   [(label_ref (match_operand 0 "" ""))]
9864   "flag_pic"
9865   "
9867   if (TARGET_64BIT)
9868     emit_insn (gen_blockage ());
9869   /* Restore the PIC register.  Hopefully, this will always be from
9870      a stack slot.  The only registers that are valid after a
9871      builtin_longjmp are the stack and frame pointers.  */
9872   emit_move_insn (pic_offset_table_rtx, hppa_pic_save_rtx ());
9873   emit_insn (gen_blockage ());
9874   DONE;
9877 ;; Allocate new stack space and update the saved stack pointer in the
9878 ;; frame marker.  The HP C compilers also copy additional words in the
9879 ;; frame marker.  The 64-bit compiler copies words at -48, -32 and -24.
9880 ;; The 32-bit compiler copies the word at -16 (Static Link).  We
9881 ;; currently don't copy these values.
9883 ;; Since the copy of the frame marker can't be done atomically, I
9884 ;; suspect that using it for unwind purposes may be somewhat unreliable.
9885 ;; The HP compilers appear to raise the stack and copy the frame
9886 ;; marker in a strict instruction sequence.  This suggests that the
9887 ;; unwind library may check for an alloca sequence when ALLOCA_FRAME
9888 ;; is set in the callinfo data.  We currently don't set ALLOCA_FRAME
9889 ;; as GAS doesn't support it, or try to keep the instructions emitted
9890 ;; here in strict sequence.
9891 (define_expand "allocate_stack"
9892   [(match_operand 0 "" "")
9893    (match_operand 1 "" "")]
9894   ""
9895   "
9897   rtx addr;
9899   /* Since the stack grows upward, we need to store virtual_stack_dynamic_rtx
9900      in operand 0 before adjusting the stack.  */
9901   emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
9902   anti_adjust_stack (operands[1]);
9903   if (TARGET_HPUX_UNWIND_LIBRARY)
9904     {
9905       addr = gen_rtx_PLUS (word_mode, stack_pointer_rtx,
9906                            GEN_INT (TARGET_64BIT ? -8 : -4));
9907       emit_move_insn (gen_rtx_MEM (word_mode, addr), frame_pointer_rtx);
9908     }
9909   if (!TARGET_64BIT && flag_pic)
9910     {
9911       rtx addr = gen_rtx_PLUS (word_mode, stack_pointer_rtx, GEN_INT (-32));
9912       emit_move_insn (gen_rtx_MEM (word_mode, addr), pic_offset_table_rtx);
9913     }
9914   DONE;
9917 (define_expand "prefetch"
9918   [(match_operand 0 "address_operand" "")
9919    (match_operand 1 "const_int_operand" "")
9920    (match_operand 2 "const_int_operand" "")]
9921   "TARGET_PA_20"
9923   int locality = INTVAL (operands[2]);
9925   gcc_assert (locality >= 0 && locality <= 3);
9927   /* Change operand[0] to a MEM as we don't have the infrastructure
9928      to output all the supported address modes for ldw/ldd when we use
9929      the address directly.  However, we do have it for MEMs.  */
9930   operands[0] = gen_rtx_MEM (QImode, operands[0]);
9932   /* If the address isn't valid for the prefetch, replace it.  */
9933   if (locality)
9934     {
9935       if (!prefetch_nocc_operand (operands[0], QImode))
9936         operands[0]
9937           = replace_equiv_address (operands[0],
9938                                    copy_to_mode_reg (Pmode,
9939                                                      XEXP (operands[0], 0)));
9940       emit_insn (gen_prefetch_nocc (operands[0], operands[1], operands[2]));
9941     }
9942   else
9943     {
9944       if (!prefetch_cc_operand (operands[0], QImode))
9945         operands[0]
9946           = replace_equiv_address (operands[0],
9947                                    copy_to_mode_reg (Pmode,
9948                                                      XEXP (operands[0], 0)));
9949       emit_insn (gen_prefetch_cc (operands[0], operands[1], operands[2]));
9950     }
9951   DONE;
9954 (define_insn "prefetch_cc"
9955   [(prefetch (match_operand:QI 0 "prefetch_cc_operand" "RW")
9956              (match_operand:SI 1 "const_int_operand" "n")
9957              (match_operand:SI 2 "const_int_operand" "n"))]
9958   "TARGET_PA_20 && operands[2] == const0_rtx"
9960   /* The SL cache-control completor indicates good spatial locality but
9961      poor temporal locality.  The ldw instruction with a target of general
9962      register 0 prefetches a cache line for a read.  The ldd instruction
9963      prefetches a cache line for a write.  */
9964   static const char * const instr[2] = {
9965     "ldw%M0,sl %0,%%r0",
9966     "ldd%M0,sl %0,%%r0"
9967   };
9968   int read_or_write = INTVAL (operands[1]);
9970   gcc_assert (read_or_write >= 0 && read_or_write <= 1);
9972   return instr [read_or_write];
9974   [(set_attr "type" "load")
9975    (set_attr "length" "4")])
9977 (define_insn "prefetch_nocc"
9978   [(prefetch (match_operand:QI 0 "prefetch_nocc_operand" "A,RQ")
9979              (match_operand:SI 1 "const_int_operand" "n,n")
9980              (match_operand:SI 2 "const_int_operand" "n,n"))]
9981   "TARGET_PA_20 && operands[2] != const0_rtx"
9983   /* The ldw instruction with a target of general register 0 prefetches
9984      a cache line for a read.  The ldd instruction prefetches a cache line
9985      for a write.  */
9986   static const char * const instr[2][2] = {
9987     {
9988       "ldw RT'%A0,%%r0",
9989       "ldd RT'%A0,%%r0",
9990     },
9991     {
9992       "ldw%M0 %0,%%r0",
9993       "ldd%M0 %0,%%r0",
9994     }
9995   };
9996   int read_or_write = INTVAL (operands[1]);
9998   gcc_assert (which_alternative == 0 || which_alternative == 1);
9999   gcc_assert (read_or_write >= 0 && read_or_write <= 1);
10001   return instr [which_alternative][read_or_write];
10003   [(set_attr "type" "load")
10004    (set_attr "length" "4")])
10007 ;; TLS Support
10008 (define_insn "tgd_load"
10009  [(set (match_operand:SI 0 "register_operand" "=r")
10010        (unspec:SI [(match_operand 1 "tgd_symbolic_operand" "")] UNSPEC_TLSGD))
10011   (clobber (reg:SI 1))
10012   (use (reg:SI 27))]
10013   ""
10014   "*
10016   return \"addil LR'%1-$tls_gdidx$,%%r27\;ldo RR'%1-$tls_gdidx$(%%r1),%0\";
10018   [(set_attr "type" "multi")
10019    (set_attr "length" "8")])
10021 (define_insn "tgd_load_pic"
10022  [(set (match_operand:SI 0 "register_operand" "=r")
10023        (unspec:SI [(match_operand 1 "tgd_symbolic_operand" "")] UNSPEC_TLSGD_PIC))
10024   (clobber (reg:SI 1))
10025   (use (reg:SI 19))]
10026   ""
10027   "*
10029   return \"addil LT'%1-$tls_gdidx$,%%r19\;ldo RT'%1-$tls_gdidx$(%%r1),%0\";
10031   [(set_attr "type" "multi")
10032    (set_attr "length" "8")])
10034 (define_insn "tld_load"
10035  [(set (match_operand:SI 0 "register_operand" "=r")
10036        (unspec:SI [(match_operand 1 "tld_symbolic_operand" "")] UNSPEC_TLSLDM))
10037   (clobber (reg:SI 1))
10038   (use (reg:SI 27))]
10039   ""
10040   "*
10042   return \"addil LR'%1-$tls_ldidx$,%%r27\;ldo RR'%1-$tls_ldidx$(%%r1),%0\";
10044   [(set_attr "type" "multi")
10045    (set_attr "length" "8")])
10047 (define_insn "tld_load_pic"
10048  [(set (match_operand:SI 0 "register_operand" "=r")
10049        (unspec:SI [(match_operand 1 "tld_symbolic_operand" "")] UNSPEC_TLSLDM_PIC))
10050   (clobber (reg:SI 1))
10051   (use (reg:SI 19))]
10052   ""
10053   "*
10055   return \"addil LT'%1-$tls_ldidx$,%%r19\;ldo RT'%1-$tls_ldidx$(%%r1),%0\";
10057   [(set_attr "type" "multi")
10058    (set_attr "length" "8")])
10060 (define_insn "tld_offset_load"
10061   [(set (match_operand:SI 0 "register_operand" "=r")
10062         (plus:SI (unspec:SI [(match_operand 1 "tld_symbolic_operand" "")] 
10063                             UNSPEC_TLSLDO)
10064                  (match_operand:SI 2 "register_operand" "r")))
10065    (clobber (reg:SI 1))]
10066   ""
10067   "*
10069   return \"addil LR'%1-$tls_dtpoff$,%2\;ldo RR'%1-$tls_dtpoff$(%%r1),%0\"; 
10071   [(set_attr "type" "multi")
10072    (set_attr "length" "8")])
10074 (define_insn "tp_load"
10075   [(set (match_operand:SI 0 "register_operand" "=r")
10076         (unspec:SI [(const_int 0)] UNSPEC_TP))]
10077   ""
10078   "mfctl %%cr27,%0"
10079   [(set_attr "type" "multi")
10080    (set_attr "length" "4")])
10082 (define_insn "tie_load"
10083   [(set (match_operand:SI 0 "register_operand" "=r")
10084         (unspec:SI [(match_operand 1 "tie_symbolic_operand" "")] UNSPEC_TLSIE))
10085    (clobber (reg:SI 1))
10086    (use (reg:SI 27))]
10087   ""
10088   "*
10090   return \"addil LR'%1-$tls_ieoff$,%%r27\;ldw RR'%1-$tls_ieoff$(%%r1),%0\";
10092   [(set_attr "type" "multi")
10093    (set_attr "length" "8")])
10095 (define_insn "tie_load_pic"
10096   [(set (match_operand:SI 0 "register_operand" "=r")
10097         (unspec:SI [(match_operand 1 "tie_symbolic_operand" "")] UNSPEC_TLSIE_PIC))
10098    (clobber (reg:SI 1))
10099    (use (reg:SI 19))]
10100   ""
10101   "*
10103   return \"addil LT'%1-$tls_ieoff$,%%r19\;ldw RT'%1-$tls_ieoff$(%%r1),%0\";
10105   [(set_attr "type" "multi")
10106    (set_attr "length" "8")])
10108 (define_insn "tle_load"
10109   [(set (match_operand:SI 0 "register_operand" "=r")
10110         (plus:SI (unspec:SI [(match_operand 1 "tle_symbolic_operand" "")] 
10111                             UNSPEC_TLSLE)
10112                  (match_operand:SI 2 "register_operand" "r")))
10113    (clobber (reg:SI 1))]
10114   ""
10115   "addil LR'%1-$tls_leoff$,%2\;ldo RR'%1-$tls_leoff$(%%r1),%0"
10116   [(set_attr "type" "multi")
10117    (set_attr "length" "8")])