OSDN Git Service

* pa.c (override_options): Promote -fpic to -fPIC.
[pf3gnuchains/gcc-fork.git] / gcc / config / pa / pa.md
1 ;;- Machine description for HP PA-RISC architecture for GNU C compiler
2 ;;   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
3 ;;   Free Software Foundation, Inc.
4 ;;   Contributed by the Center for Software Science at the University
5 ;;   of Utah.
6
7 ;; This file is part of GNU CC.
8
9 ;; GNU CC 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 2, or (at your option)
12 ;; any later version.
13
14 ;; GNU CC 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.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU CC; see the file COPYING.  If not, write to
21 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
23
24 ;; This gcc Version 2 machine description is inspired by sparc.md and
25 ;; mips.md.
26
27 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
28
29 ;; Insn type.  Used to default other attribute values.
30
31 ;; type "unary" insns have one input operand (1) and one output operand (0)
32 ;; type "binary" insns have two input operands (1,2) and one output (0)
33
34 (define_attr "type"
35   "move,unary,binary,shift,nullshift,compare,load,store,uncond_branch,branch,cbranch,fbranch,call,dyncall,fpload,fpstore,fpalu,fpcc,fpmulsgl,fpmuldbl,fpdivsgl,fpdivdbl,fpsqrtsgl,fpsqrtdbl,multi,milli,parallel_branch"
36   (const_string "binary"))
37
38 (define_attr "pa_combine_type"
39   "fmpy,faddsub,uncond_branch,addmove,none"
40   (const_string "none"))
41
42 ;; Processor type (for scheduling, not code generation) -- this attribute
43 ;; must exactly match the processor_type enumeration in pa.h.
44 ;;
45 ;; FIXME: Add 800 scheduling for completeness?
46
47 (define_attr "cpu" "700,7100,7100LC,7200,8000" (const (symbol_ref "pa_cpu_attr")))
48
49 ;; Length (in # of bytes).
50 (define_attr "length" ""
51   (cond [(eq_attr "type" "load,fpload")
52          (if_then_else (match_operand 1 "symbolic_memory_operand" "")
53                        (const_int 8) (const_int 4))
54
55          (eq_attr "type" "store,fpstore")
56          (if_then_else (match_operand 0 "symbolic_memory_operand" "")
57                        (const_int 8) (const_int 4))
58
59          (eq_attr "type" "binary,shift,nullshift")
60          (if_then_else (match_operand 2 "arith_operand" "")
61                        (const_int 4) (const_int 12))
62
63          (eq_attr "type" "move,unary,shift,nullshift")
64          (if_then_else (match_operand 1 "arith_operand" "")
65                        (const_int 4) (const_int 8))]
66
67         (const_int 4)))
68
69 (define_asm_attributes
70   [(set_attr "length" "4")
71    (set_attr "type" "multi")])
72
73 ;; Attributes for instruction and branch scheduling
74
75 ;; For conditional branches.
76 (define_attr "in_branch_delay" "false,true"
77   (if_then_else (and (eq_attr "type" "!uncond_branch,branch,cbranch,fbranch,call,dyncall,multi,milli,parallel_branch")
78                      (eq_attr "length" "4"))
79                 (const_string "true")
80                 (const_string "false")))
81
82 ;; Disallow instructions which use the FPU since they will tie up the FPU
83 ;; even if the instruction is nullified.
84 (define_attr "in_nullified_branch_delay" "false,true"
85   (if_then_else (and (eq_attr "type" "!uncond_branch,branch,cbranch,fbranch,call,dyncall,multi,milli,fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpdivdbl,fpsqrtsgl,fpsqrtdbl,parallel_branch")
86                      (eq_attr "length" "4"))
87                 (const_string "true")
88                 (const_string "false")))
89
90 ;; For calls and millicode calls.  Allow unconditional branches in the
91 ;; delay slot.
92 (define_attr "in_call_delay" "false,true"
93   (cond [(and (eq_attr "type" "!uncond_branch,branch,cbranch,fbranch,call,dyncall,multi,milli,parallel_branch")
94               (eq_attr "length" "4"))
95            (const_string "true")
96          (eq_attr "type" "uncond_branch")
97            (if_then_else (ne (symbol_ref "TARGET_JUMP_IN_DELAY")
98                              (const_int 0))
99                          (const_string "true")
100                          (const_string "false"))]
101         (const_string "false")))
102
103
104 ;; Call delay slot description.
105 (define_delay (eq_attr "type" "call")
106   [(eq_attr "in_call_delay" "true") (nil) (nil)])
107
108 ;; millicode call delay slot description.  Note it disallows delay slot
109 ;; when TARGET_PORTABLE_RUNTIME is true.
110 (define_delay (eq_attr "type" "milli")
111   [(and (eq_attr "in_call_delay" "true")
112         (eq (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0)))
113    (nil) (nil)])
114
115 ;; Return and other similar instructions.
116 (define_delay (eq_attr "type" "branch,parallel_branch")
117   [(eq_attr "in_branch_delay" "true") (nil) (nil)])
118
119 ;; Floating point conditional branch delay slot description and
120 (define_delay (eq_attr "type" "fbranch")
121   [(eq_attr "in_branch_delay" "true")
122    (eq_attr "in_nullified_branch_delay" "true")
123    (nil)])
124
125 ;; Integer conditional branch delay slot description.
126 ;; Nullification of conditional branches on the PA is dependent on the
127 ;; direction of the branch.  Forward branches nullify true and
128 ;; backward branches nullify false.  If the direction is unknown
129 ;; then nullification is not allowed.
130 (define_delay (eq_attr "type" "cbranch")
131   [(eq_attr "in_branch_delay" "true")
132    (and (eq_attr "in_nullified_branch_delay" "true")
133         (attr_flag "forward"))
134    (and (eq_attr "in_nullified_branch_delay" "true")
135         (attr_flag "backward"))])
136
137 (define_delay (and (eq_attr "type" "uncond_branch")
138                    (eq (symbol_ref "following_call (insn)")
139                        (const_int 0)))
140   [(eq_attr "in_branch_delay" "true") (nil) (nil)])
141
142 ;; Function units of the HPPA. The following data is for the 700 CPUs
143 ;; (Mustang CPU + Timex FPU aka PA-89) because that's what I have the docs for.
144 ;; Scheduling instructions for PA-83 machines according to the Snake
145 ;; constraints shouldn't hurt.
146
147 ;; (define_function_unit {name} {num-units} {n-users} {test}
148 ;;                       {ready-delay} {issue-delay} [{conflict-list}])
149
150 ;; The integer ALU.
151 ;; (Noted only for documentation; units that take one cycle do not need to
152 ;; be specified.)
153
154 ;; (define_function_unit "alu" 1 0
155 ;;  (and (eq_attr "type" "unary,shift,nullshift,binary,move,address")
156 ;;       (eq_attr "cpu" "700"))
157 ;;  1 0)
158
159
160 ;; Memory. Disregarding Cache misses, the Mustang memory times are:
161 ;; load: 2, fpload: 3
162 ;; store, fpstore: 3, no D-cache operations should be scheduled.
163
164 (define_function_unit "pa700memory" 1 0
165   (and (eq_attr "type" "load,fpload")
166        (eq_attr "cpu" "700")) 2 0)
167 (define_function_unit "pa700memory" 1 0 
168   (and (eq_attr "type" "store,fpstore")
169        (eq_attr "cpu" "700")) 3 3)
170
171 ;; The Timex (aka 700) has two floating-point units: ALU, and MUL/DIV/SQRT.
172 ;; Timings:
173 ;; Instruction  Time    Unit    Minimum Distance (unit contention)
174 ;; fcpy         3       ALU     2
175 ;; fabs         3       ALU     2
176 ;; fadd         3       ALU     2
177 ;; fsub         3       ALU     2
178 ;; fcmp         3       ALU     2
179 ;; fcnv         3       ALU     2
180 ;; fmpyadd      3       ALU,MPY 2
181 ;; fmpysub      3       ALU,MPY 2
182 ;; fmpycfxt     3       ALU,MPY 2
183 ;; fmpy         3       MPY     2
184 ;; fmpyi        3       MPY     2
185 ;; fdiv,sgl     10      MPY     10
186 ;; fdiv,dbl     12      MPY     12
187 ;; fsqrt,sgl    14      MPY     14
188 ;; fsqrt,dbl    18      MPY     18
189
190 (define_function_unit "pa700fp_alu" 1 0
191   (and (eq_attr "type" "fpcc")
192        (eq_attr "cpu" "700")) 4 2)
193 (define_function_unit "pa700fp_alu" 1 0
194   (and (eq_attr "type" "fpalu")
195        (eq_attr "cpu" "700")) 3 2)
196 (define_function_unit "pa700fp_mpy" 1 0
197   (and (eq_attr "type" "fpmulsgl,fpmuldbl")
198        (eq_attr "cpu" "700")) 3 2)
199 (define_function_unit "pa700fp_mpy" 1 0
200   (and (eq_attr "type" "fpdivsgl")
201        (eq_attr "cpu" "700")) 10 10)
202 (define_function_unit "pa700fp_mpy" 1 0
203   (and (eq_attr "type" "fpdivdbl")
204        (eq_attr "cpu" "700")) 12 12)
205 (define_function_unit "pa700fp_mpy" 1 0
206   (and (eq_attr "type" "fpsqrtsgl")
207        (eq_attr "cpu" "700")) 14 14)
208 (define_function_unit "pa700fp_mpy" 1 0
209   (and (eq_attr "type" "fpsqrtdbl")
210        (eq_attr "cpu" "700")) 18 18)
211
212 ;; Function units for the 7100 and 7150.  The 7100/7150 can dual-issue
213 ;; floating point computations with non-floating point computations (fp loads
214 ;; and stores are not fp computations).
215 ;;
216
217 ;; Memory. Disregarding Cache misses, memory loads take two cycles; stores also
218 ;; take two cycles, during which no Dcache operations should be scheduled.
219 ;; Any special cases are handled in pa_adjust_cost.  The 7100, 7150 and 7100LC
220 ;; all have the same memory characteristics if one disregards cache misses.
221 (define_function_unit "pa7100memory" 1 0
222   (and (eq_attr "type" "load,fpload")
223        (eq_attr "cpu" "7100,7100LC")) 2 0)
224 (define_function_unit "pa7100memory" 1 0 
225   (and (eq_attr "type" "store,fpstore")
226        (eq_attr "cpu" "7100,7100LC")) 2 2)
227
228 ;; The 7100/7150 has three floating-point units: ALU, MUL, and DIV.
229 ;; Timings:
230 ;; Instruction  Time    Unit    Minimum Distance (unit contention)
231 ;; fcpy         2       ALU     1
232 ;; fabs         2       ALU     1
233 ;; fadd         2       ALU     1
234 ;; fsub         2       ALU     1
235 ;; fcmp         2       ALU     1
236 ;; fcnv         2       ALU     1
237 ;; fmpyadd      2       ALU,MPY 1
238 ;; fmpysub      2       ALU,MPY 1
239 ;; fmpycfxt     2       ALU,MPY 1
240 ;; fmpy         2       MPY     1
241 ;; fmpyi        2       MPY     1
242 ;; fdiv,sgl     8       DIV     8
243 ;; fdiv,dbl     15      DIV     15
244 ;; fsqrt,sgl    8       DIV     8
245 ;; fsqrt,dbl    15      DIV     15
246
247 (define_function_unit "pa7100fp_alu" 1 0
248   (and (eq_attr "type" "fpcc,fpalu")
249        (eq_attr "cpu" "7100")) 2 1)
250 (define_function_unit "pa7100fp_mpy" 1 0
251   (and (eq_attr "type" "fpmulsgl,fpmuldbl")
252        (eq_attr "cpu" "7100")) 2 1)
253 (define_function_unit "pa7100fp_div" 1 0
254   (and (eq_attr "type" "fpdivsgl,fpsqrtsgl")
255        (eq_attr "cpu" "7100")) 8 8)
256 (define_function_unit "pa7100fp_div" 1 0
257   (and (eq_attr "type" "fpdivdbl,fpsqrtdbl")
258        (eq_attr "cpu" "7100")) 15 15)
259
260 ;; To encourage dual issue we define function units corresponding to
261 ;; the instructions which can be dual issued.    This is a rather crude
262 ;; approximation, the "pa7100nonflop" test in particular could be refined.
263 (define_function_unit "pa7100flop" 1 1
264   (and
265     (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl")
266     (eq_attr "cpu" "7100")) 1 1)
267
268 (define_function_unit "pa7100nonflop" 1 1
269   (and
270     (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl")
271     (eq_attr "cpu" "7100")) 1 1)
272
273
274 ;; Memory subsystem works just like 7100/7150 (except for cache miss times which
275 ;; we don't model here).  
276
277 ;; The 7100LC has three floating-point units: ALU, MUL, and DIV.
278 ;; Note divides and sqrt flops lock the cpu until the flop is
279 ;; finished.  fmpy and xmpyu (fmpyi) lock the cpu for one cycle.
280 ;; There's no way to avoid the penalty.
281 ;; Timings:
282 ;; Instruction  Time    Unit    Minimum Distance (unit contention)
283 ;; fcpy         2       ALU     1
284 ;; fabs         2       ALU     1
285 ;; fadd         2       ALU     1
286 ;; fsub         2       ALU     1
287 ;; fcmp         2       ALU     1
288 ;; fcnv         2       ALU     1
289 ;; fmpyadd,sgl  2       ALU,MPY 1
290 ;; fmpyadd,dbl  3       ALU,MPY 2
291 ;; fmpysub,sgl  2       ALU,MPY 1
292 ;; fmpysub,dbl  3       ALU,MPY 2
293 ;; fmpycfxt,sgl 2       ALU,MPY 1
294 ;; fmpycfxt,dbl 3       ALU,MPY 2
295 ;; fmpy,sgl     2       MPY     1
296 ;; fmpy,dbl     3       MPY     2
297 ;; fmpyi        3       MPY     2
298 ;; fdiv,sgl     8       DIV     8
299 ;; fdiv,dbl     15      DIV     15
300 ;; fsqrt,sgl    8       DIV     8
301 ;; fsqrt,dbl    15      DIV     15
302
303 (define_function_unit "pa7100LCfp_alu" 1 0
304   (and (eq_attr "type" "fpcc,fpalu")
305        (eq_attr "cpu" "7100LC,7200")) 2 1)
306 (define_function_unit "pa7100LCfp_mpy" 1 0
307   (and (eq_attr "type" "fpmulsgl")
308        (eq_attr "cpu" "7100LC,7200")) 2 1)
309 (define_function_unit "pa7100LCfp_mpy" 1 0
310   (and (eq_attr "type" "fpmuldbl")
311        (eq_attr "cpu" "7100LC,7200")) 3 2)
312 (define_function_unit "pa7100LCfp_div" 1 0
313   (and (eq_attr "type" "fpdivsgl,fpsqrtsgl")
314        (eq_attr "cpu" "7100LC,7200")) 8 8)
315 (define_function_unit "pa7100LCfp_div" 1 0
316   (and (eq_attr "type" "fpdivdbl,fpsqrtdbl")
317        (eq_attr "cpu" "7100LC,7200")) 15 15)
318
319 ;; Define the various functional units for dual-issue.
320
321 ;; There's only one floating point unit.
322 (define_function_unit "pa7100LCflop" 1 1
323   (and
324     (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl")
325     (eq_attr "cpu" "7100LC,7200")) 1 1)
326
327 ;; Shifts and memory ops execute in only one of the integer ALUs
328 (define_function_unit "pa7100LCshiftmem" 1 1
329   (and
330     (eq_attr "type" "shift,nullshift,load,fpload,store,fpstore")
331     (eq_attr "cpu" "7100LC,7200")) 1 1)
332
333 ;; We have two basic ALUs.
334 (define_function_unit "pa7100LCalu" 2 1
335   (and
336     (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl")
337    (eq_attr "cpu" "7100LC,7200")) 1 1)
338
339 ;; I don't have complete information on the PA7200; however, most of
340 ;; what I've heard makes it look like a 7100LC without the store-store
341 ;; penalty.  So that's how we'll model it.
342
343 ;; Memory. Disregarding Cache misses, memory loads and stores take
344 ;; two cycles.  Any special cases are handled in pa_adjust_cost.
345 (define_function_unit "pa7200memory" 1 0
346   (and (eq_attr "type" "load,fpload,store,fpstore")
347        (eq_attr "cpu" "7200")) 2 0)
348
349 ;; I don't have detailed information on the PA7200 FP pipeline, so I
350 ;; treat it just like the 7100LC pipeline.
351 ;; Similarly for the multi-issue fake units.
352
353 ;; 
354 ;; Scheduling for the PA8000 is somewhat different than scheduling for a
355 ;; traditional architecture.
356 ;;
357 ;; The PA8000 has a large (56) entry reorder buffer that is split between
358 ;; memory and non-memory operations.
359 ;;
360 ;; The PA800 can issue two memory and two non-memory operations per cycle to
361 ;; the function units.  Similarly, the PA8000 can retire two memory and two
362 ;; non-memory operations per cycle.
363 ;;
364 ;; Given the large reorder buffer, the processor can hide most latencies.
365 ;; According to HP, they've got the best results by scheduling for retirement
366 ;; bandwidth with limited latency scheduling for floating point operations.
367 ;; Latency for integer operations and memory references is ignored.
368 ;;
369 ;; We claim floating point operations have a 2 cycle latency and are
370 ;; fully pipelined, except for div and sqrt which are not pipelined.
371 ;;
372 ;; It is not necessary to define the shifter and integer alu units.
373 ;;
374 ;; These first two define_unit_unit descriptions model retirement from
375 ;; the reorder buffer.
376 (define_function_unit "pa8000lsu" 2 1
377   (and
378     (eq_attr "type" "load,fpload,store,fpstore")
379     (eq_attr "cpu" "8000")) 1 1)
380
381 (define_function_unit "pa8000alu" 2 1
382   (and
383     (eq_attr "type" "!load,fpload,store,fpstore")
384     (eq_attr "cpu" "8000")) 1 1)
385
386 ;; Claim floating point ops have a 2 cycle latency, excluding div and
387 ;; sqrt, which are not pipelined and issue to different units.
388 (define_function_unit "pa8000fmac" 2 0
389   (and
390     (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
391     (eq_attr "cpu" "8000")) 2 1)
392
393 (define_function_unit "pa8000fdiv" 2 1
394   (and
395     (eq_attr "type" "fpdivsgl,fpsqrtsgl")
396     (eq_attr "cpu" "8000")) 17 17)
397
398 (define_function_unit "pa8000fdiv" 2 1
399   (and
400     (eq_attr "type" "fpdivdbl,fpsqrtdbl")
401     (eq_attr "cpu" "8000")) 31 31)
402
403 \f
404 ;; Compare instructions.
405 ;; This controls RTL generation and register allocation.
406
407 ;; We generate RTL for comparisons and branches by having the cmpxx
408 ;; patterns store away the operands.  Then, the scc and bcc patterns
409 ;; emit RTL for both the compare and the branch.
410 ;;
411
412 (define_expand "cmpdi"
413   [(set (reg:CC 0)
414         (compare:CC (match_operand:DI 0 "reg_or_0_operand" "")
415                     (match_operand:DI 1 "register_operand" "")))]
416   "TARGET_64BIT"
417
418   "
419 {
420  hppa_compare_op0 = operands[0];
421  hppa_compare_op1 = operands[1];
422  hppa_branch_type = CMP_SI;
423  DONE;
424 }")
425
426 (define_expand "cmpsi"
427   [(set (reg:CC 0)
428         (compare:CC (match_operand:SI 0 "reg_or_0_operand" "")
429                     (match_operand:SI 1 "arith5_operand" "")))]
430   ""
431   "
432 {
433  hppa_compare_op0 = operands[0];
434  hppa_compare_op1 = operands[1];
435  hppa_branch_type = CMP_SI;
436  DONE;
437 }")
438
439 (define_expand "cmpsf"
440   [(set (reg:CCFP 0)
441         (compare:CCFP (match_operand:SF 0 "reg_or_0_operand" "")
442                       (match_operand:SF 1 "reg_or_0_operand" "")))]
443   "! TARGET_SOFT_FLOAT"
444   "
445 {
446   hppa_compare_op0 = operands[0];
447   hppa_compare_op1 = operands[1];
448   hppa_branch_type = CMP_SF;
449   DONE;
450 }")
451
452 (define_expand "cmpdf"
453   [(set (reg:CCFP 0)
454       (compare:CCFP (match_operand:DF 0 "reg_or_0_operand" "")
455                     (match_operand:DF 1 "reg_or_0_operand" "")))]
456   "! TARGET_SOFT_FLOAT"
457   "
458 {
459   hppa_compare_op0 = operands[0];
460   hppa_compare_op1 = operands[1];
461   hppa_branch_type = CMP_DF;
462   DONE;
463 }")
464
465 (define_insn ""
466   [(set (reg:CCFP 0)
467         (match_operator:CCFP 2 "comparison_operator"
468                              [(match_operand:SF 0 "reg_or_0_operand" "fG")
469                               (match_operand:SF 1 "reg_or_0_operand" "fG")]))]
470   "! TARGET_SOFT_FLOAT"
471   "fcmp,sgl,%Y2 %f0,%f1"
472   [(set_attr "length" "4")
473    (set_attr "type" "fpcc")])
474
475 (define_insn ""
476   [(set (reg:CCFP 0)
477         (match_operator:CCFP 2 "comparison_operator"
478                              [(match_operand:DF 0 "reg_or_0_operand" "fG")
479                               (match_operand:DF 1 "reg_or_0_operand" "fG")]))]
480   "! TARGET_SOFT_FLOAT"
481   "fcmp,dbl,%Y2 %f0,%f1"
482   [(set_attr "length" "4")
483    (set_attr "type" "fpcc")])
484
485 ;; scc insns.
486
487 (define_expand "seq"
488   [(set (match_operand:SI 0 "register_operand" "")
489         (eq:SI (match_dup 1)
490                (match_dup 2)))]
491   "!TARGET_64BIT"
492   "
493 {
494   /* fp scc patterns rarely match, and are not a win on the PA.  */
495   if (hppa_branch_type != CMP_SI)
496     FAIL;
497   /* set up operands from compare.  */
498   operands[1] = hppa_compare_op0;
499   operands[2] = hppa_compare_op1;
500   /* fall through and generate default code */
501 }")
502
503 (define_expand "sne"
504   [(set (match_operand:SI 0 "register_operand" "")
505         (ne:SI (match_dup 1)
506                (match_dup 2)))]
507   "!TARGET_64BIT"
508   "
509 {
510   /* fp scc patterns rarely match, and are not a win on the PA.  */
511   if (hppa_branch_type != CMP_SI)
512     FAIL;
513   operands[1] = hppa_compare_op0;
514   operands[2] = hppa_compare_op1;
515 }")
516
517 (define_expand "slt"
518   [(set (match_operand:SI 0 "register_operand" "")
519         (lt:SI (match_dup 1)
520                (match_dup 2)))]
521   "!TARGET_64BIT"
522   "
523 {
524   /* fp scc patterns rarely match, and are not a win on the PA.  */
525   if (hppa_branch_type != CMP_SI)
526     FAIL;
527   operands[1] = hppa_compare_op0;
528   operands[2] = hppa_compare_op1;
529 }")
530
531 (define_expand "sgt"
532   [(set (match_operand:SI 0 "register_operand" "")
533         (gt:SI (match_dup 1)
534                (match_dup 2)))]
535   "!TARGET_64BIT"
536   "
537 {
538   /* fp scc patterns rarely match, and are not a win on the PA.  */
539   if (hppa_branch_type != CMP_SI)
540     FAIL;
541   operands[1] = hppa_compare_op0;
542   operands[2] = hppa_compare_op1;
543 }")
544
545 (define_expand "sle"
546   [(set (match_operand:SI 0 "register_operand" "")
547         (le:SI (match_dup 1)
548                (match_dup 2)))]
549   "!TARGET_64BIT"
550   "
551 {
552   /* fp scc patterns rarely match, and are not a win on the PA.  */
553   if (hppa_branch_type != CMP_SI)
554     FAIL;
555   operands[1] = hppa_compare_op0;
556   operands[2] = hppa_compare_op1;
557 }")
558
559 (define_expand "sge"
560   [(set (match_operand:SI 0 "register_operand" "")
561         (ge:SI (match_dup 1)
562                (match_dup 2)))]
563   "!TARGET_64BIT"
564   "
565 {
566   /* fp scc patterns rarely match, and are not a win on the PA.  */
567   if (hppa_branch_type != CMP_SI)
568     FAIL;
569   operands[1] = hppa_compare_op0;
570   operands[2] = hppa_compare_op1;
571 }")
572
573 (define_expand "sltu"
574   [(set (match_operand:SI 0 "register_operand" "")
575         (ltu:SI (match_dup 1)
576                 (match_dup 2)))]
577   "!TARGET_64BIT"
578   "
579 {
580   if (hppa_branch_type != CMP_SI)
581     FAIL;
582   operands[1] = hppa_compare_op0;
583   operands[2] = hppa_compare_op1;
584 }")
585
586 (define_expand "sgtu"
587   [(set (match_operand:SI 0 "register_operand" "")
588         (gtu:SI (match_dup 1)
589                 (match_dup 2)))]
590   "!TARGET_64BIT"
591   "
592 {
593   if (hppa_branch_type != CMP_SI)
594     FAIL;
595   operands[1] = hppa_compare_op0;
596   operands[2] = hppa_compare_op1;
597 }")
598
599 (define_expand "sleu"
600   [(set (match_operand:SI 0 "register_operand" "")
601         (leu:SI (match_dup 1)
602                 (match_dup 2)))]
603   "!TARGET_64BIT"
604   "
605 {
606   if (hppa_branch_type != CMP_SI)
607     FAIL;
608   operands[1] = hppa_compare_op0;
609   operands[2] = hppa_compare_op1;
610 }")
611
612 (define_expand "sgeu"
613   [(set (match_operand:SI 0 "register_operand" "")
614         (geu:SI (match_dup 1)
615                 (match_dup 2)))]
616   "!TARGET_64BIT"
617   "
618 {
619   if (hppa_branch_type != CMP_SI)
620     FAIL;
621   operands[1] = hppa_compare_op0;
622   operands[2] = hppa_compare_op1;
623 }")
624
625 ;; Instruction canonicalization puts immediate operands second, which
626 ;; is the reverse of what we want.
627
628 (define_insn "scc"
629   [(set (match_operand:SI 0 "register_operand" "=r")
630         (match_operator:SI 3 "comparison_operator"
631                            [(match_operand:SI 1 "register_operand" "r")
632                             (match_operand:SI 2 "arith11_operand" "rI")]))]
633   ""
634   "{com%I2clr|cmp%I2clr},%B3 %2,%1,%0\;ldi 1,%0"
635   [(set_attr "type" "binary")
636    (set_attr "length" "8")])
637
638 (define_insn ""
639   [(set (match_operand:DI 0 "register_operand" "=r")
640         (match_operator:DI 3 "comparison_operator"
641                            [(match_operand:DI 1 "register_operand" "r")
642                             (match_operand:DI 2 "arith11_operand" "rI")]))]
643   "TARGET_64BIT"
644   "cmp%I2clr,*%B3 %2,%1,%0\;ldi 1,%0"
645   [(set_attr "type" "binary")
646    (set_attr "length" "8")])
647
648 (define_insn "iorscc"
649   [(set (match_operand:SI 0 "register_operand" "=r")
650         (ior:SI (match_operator:SI 3 "comparison_operator"
651                                    [(match_operand:SI 1 "register_operand" "r")
652                                     (match_operand:SI 2 "arith11_operand" "rI")])
653                 (match_operator:SI 6 "comparison_operator"
654                                    [(match_operand:SI 4 "register_operand" "r")
655                                     (match_operand:SI 5 "arith11_operand" "rI")])))]
656   ""
657   "{com%I2clr|cmp%I2clr},%S3 %2,%1,%%r0\;{com%I5clr|cmp%I5clr},%B6 %5,%4,%0\;ldi 1,%0"
658   [(set_attr "type" "binary")
659    (set_attr "length" "12")])
660
661 (define_insn ""
662   [(set (match_operand:DI 0 "register_operand" "=r")
663         (ior:DI (match_operator:DI 3 "comparison_operator"
664                                    [(match_operand:DI 1 "register_operand" "r")
665                                     (match_operand:DI 2 "arith11_operand" "rI")])
666                 (match_operator:DI 6 "comparison_operator"
667                                    [(match_operand:DI 4 "register_operand" "r")
668                                     (match_operand:DI 5 "arith11_operand" "rI")])))]
669   "TARGET_64BIT"
670   "cmp%I2clr,*%S3 %2,%1,%%r0\;cmp%I5clr,*%B6 %5,%4,%0\;ldi 1,%0"
671   [(set_attr "type" "binary")
672    (set_attr "length" "12")])
673
674 ;; Combiner patterns for common operations performed with the output
675 ;; from an scc insn (negscc and incscc).
676 (define_insn "negscc"
677   [(set (match_operand:SI 0 "register_operand" "=r")
678         (neg:SI (match_operator:SI 3 "comparison_operator"
679                [(match_operand:SI 1 "register_operand" "r")
680                 (match_operand:SI 2 "arith11_operand" "rI")])))]
681   ""
682   "{com%I2clr|cmp%I2clr},%B3 %2,%1,%0\;ldi -1,%0"
683   [(set_attr "type" "binary")
684    (set_attr "length" "8")])
685
686 (define_insn ""
687   [(set (match_operand:DI 0 "register_operand" "=r")
688         (neg:DI (match_operator:DI 3 "comparison_operator"
689                [(match_operand:DI 1 "register_operand" "r")
690                 (match_operand:DI 2 "arith11_operand" "rI")])))]
691   "TARGET_64BIT"
692   "cmp%I2clr,*%B3 %2,%1,%0\;ldi -1,%0"
693   [(set_attr "type" "binary")
694    (set_attr "length" "8")])
695
696 ;; Patterns for adding/subtracting the result of a boolean expression from
697 ;; a register.  First we have special patterns that make use of the carry
698 ;; bit, and output only two instructions.  For the cases we can't in
699 ;; general do in two instructions, the incscc pattern at the end outputs
700 ;; two or three instructions.
701
702 (define_insn ""
703   [(set (match_operand:SI 0 "register_operand" "=r")
704         (plus:SI (leu:SI (match_operand:SI 2 "register_operand" "r")
705                          (match_operand:SI 3 "arith11_operand" "rI"))
706                  (match_operand:SI 1 "register_operand" "r")))]
707   ""
708   "sub%I3 %3,%2,%%r0\;{addc|add,c} %%r0,%1,%0"
709   [(set_attr "type" "binary")
710    (set_attr "length" "8")])
711
712 (define_insn ""
713   [(set (match_operand:DI 0 "register_operand" "=r")
714         (plus:DI (leu:DI (match_operand:DI 2 "register_operand" "r")
715                          (match_operand:DI 3 "arith11_operand" "rI"))
716                  (match_operand:DI 1 "register_operand" "r")))]
717   "TARGET_64BIT"
718   "sub%I3 %3,%2,%%r0\;add,dc %%r0,%1,%0"
719   [(set_attr "type" "binary")
720    (set_attr "length" "8")])
721
722 ; This need only accept registers for op3, since canonicalization
723 ; replaces geu with gtu when op3 is an integer.
724 (define_insn ""
725   [(set (match_operand:SI 0 "register_operand" "=r")
726         (plus:SI (geu:SI (match_operand:SI 2 "register_operand" "r")
727                          (match_operand:SI 3 "register_operand" "r"))
728                  (match_operand:SI 1 "register_operand" "r")))]
729   ""
730   "sub %2,%3,%%r0\;{addc|add,c} %%r0,%1,%0"
731   [(set_attr "type" "binary")
732    (set_attr "length" "8")])
733
734 (define_insn ""
735   [(set (match_operand:DI 0 "register_operand" "=r")
736         (plus:DI (geu:DI (match_operand:DI 2 "register_operand" "r")
737                          (match_operand:DI 3 "register_operand" "r"))
738                  (match_operand:DI 1 "register_operand" "r")))]
739   "TARGET_64BIT"
740   "sub %2,%3,%%r0\;add,dc %%r0,%1,%0"
741   [(set_attr "type" "binary")
742    (set_attr "length" "8")])
743
744 ; Match only integers for op3 here.  This is used as canonical form of the
745 ; geu pattern when op3 is an integer.  Don't match registers since we can't
746 ; make better code than the general incscc pattern.
747 (define_insn ""
748   [(set (match_operand:SI 0 "register_operand" "=r")
749         (plus:SI (gtu:SI (match_operand:SI 2 "register_operand" "r")
750                          (match_operand:SI 3 "int11_operand" "I"))
751                  (match_operand:SI 1 "register_operand" "r")))]
752   ""
753   "addi %k3,%2,%%r0\;{addc|add,c} %%r0,%1,%0"
754   [(set_attr "type" "binary")
755    (set_attr "length" "8")])
756
757 (define_insn ""
758   [(set (match_operand:DI 0 "register_operand" "=r")
759         (plus:DI (gtu:DI (match_operand:DI 2 "register_operand" "r")
760                          (match_operand:DI 3 "int11_operand" "I"))
761                  (match_operand:DI 1 "register_operand" "r")))]
762   "TARGET_64BIT"
763   "addi %k3,%2,%%r0\;add,dc %%r0,%1,%0"
764   [(set_attr "type" "binary")
765    (set_attr "length" "8")])
766
767 (define_insn "incscc"
768   [(set (match_operand:SI 0 "register_operand" "=r,r")
769         (plus:SI (match_operator:SI 4 "comparison_operator"
770                     [(match_operand:SI 2 "register_operand" "r,r")
771                      (match_operand:SI 3 "arith11_operand" "rI,rI")])
772                  (match_operand:SI 1 "register_operand" "0,?r")))]
773   ""
774   "@
775    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi 1,%0,%0
776    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi,tr 1,%1,%0\;copy %1,%0"
777   [(set_attr "type" "binary,binary")
778    (set_attr "length" "8,12")])
779
780 (define_insn ""
781   [(set (match_operand:DI 0 "register_operand" "=r,r")
782         (plus:DI (match_operator:DI 4 "comparison_operator"
783                     [(match_operand:DI 2 "register_operand" "r,r")
784                      (match_operand:DI 3 "arith11_operand" "rI,rI")])
785                  (match_operand:DI 1 "register_operand" "0,?r")))]
786   "TARGET_64BIT"
787   "@
788    cmp%I3clr,*%B4 %3,%2,%%r0\;addi 1,%0,%0
789    cmp%I3clr,*%B4 %3,%2,%%r0\;addi,tr 1,%1,%0\;copy %1,%0"
790   [(set_attr "type" "binary,binary")
791    (set_attr "length" "8,12")])
792
793 (define_insn ""
794   [(set (match_operand:SI 0 "register_operand" "=r")
795         (minus:SI (match_operand:SI 1 "register_operand" "r")
796                   (gtu:SI (match_operand:SI 2 "register_operand" "r")
797                           (match_operand:SI 3 "arith11_operand" "rI"))))]
798   ""
799   "sub%I3 %3,%2,%%r0\;{subb|sub,b} %1,%%r0,%0"
800   [(set_attr "type" "binary")
801    (set_attr "length" "8")])
802
803 (define_insn ""
804   [(set (match_operand:DI 0 "register_operand" "=r")
805         (minus:DI (match_operand:DI 1 "register_operand" "r")
806                   (gtu:DI (match_operand:DI 2 "register_operand" "r")
807                           (match_operand:DI 3 "arith11_operand" "rI"))))]
808   "TARGET_64BIT"
809   "sub%I3 %3,%2,%%r0\;sub,db %1,%%r0,%0"
810   [(set_attr "type" "binary")
811    (set_attr "length" "8")])
812
813 (define_insn ""
814   [(set (match_operand:SI 0 "register_operand" "=r")
815         (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
816                             (gtu:SI (match_operand:SI 2 "register_operand" "r")
817                                     (match_operand:SI 3 "arith11_operand" "rI")))
818                   (match_operand:SI 4 "register_operand" "r")))]
819   ""
820   "sub%I3 %3,%2,%%r0\;{subb|sub,b} %1,%4,%0"
821   [(set_attr "type" "binary")
822    (set_attr "length" "8")])
823
824 (define_insn ""
825   [(set (match_operand:DI 0 "register_operand" "=r")
826         (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
827                             (gtu:DI (match_operand:DI 2 "register_operand" "r")
828                                     (match_operand:DI 3 "arith11_operand" "rI")))
829                   (match_operand:DI 4 "register_operand" "r")))]
830   "TARGET_64BIT"
831   "sub%I3 %3,%2,%%r0\;sub,db %1,%4,%0"
832   [(set_attr "type" "binary")
833    (set_attr "length" "8")])
834
835 ; This need only accept registers for op3, since canonicalization
836 ; replaces ltu with leu when op3 is an integer.
837 (define_insn ""
838   [(set (match_operand:SI 0 "register_operand" "=r")
839         (minus:SI (match_operand:SI 1 "register_operand" "r")
840                   (ltu:SI (match_operand:SI 2 "register_operand" "r")
841                           (match_operand:SI 3 "register_operand" "r"))))]
842   ""
843   "sub %2,%3,%%r0\;{subb|sub,b} %1,%%r0,%0"
844   [(set_attr "type" "binary")
845    (set_attr "length" "8")])
846
847 (define_insn ""
848   [(set (match_operand:DI 0 "register_operand" "=r")
849         (minus:DI (match_operand:DI 1 "register_operand" "r")
850                   (ltu:DI (match_operand:DI 2 "register_operand" "r")
851                           (match_operand:DI 3 "register_operand" "r"))))]
852   "TARGET_64BIT"
853   "sub %2,%3,%%r0\;sub,db %1,%%r0,%0"
854   [(set_attr "type" "binary")
855    (set_attr "length" "8")])
856
857 (define_insn ""
858   [(set (match_operand:SI 0 "register_operand" "=r")
859         (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
860                             (ltu:SI (match_operand:SI 2 "register_operand" "r")
861                                     (match_operand:SI 3 "register_operand" "r")))
862                   (match_operand:SI 4 "register_operand" "r")))]
863   ""
864   "sub %2,%3,%%r0\;{subb|sub,b} %1,%4,%0"
865   [(set_attr "type" "binary")
866    (set_attr "length" "8")])
867
868 (define_insn ""
869   [(set (match_operand:DI 0 "register_operand" "=r")
870         (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
871                             (ltu:DI (match_operand:DI 2 "register_operand" "r")
872                                     (match_operand:DI 3 "register_operand" "r")))
873                   (match_operand:DI 4 "register_operand" "r")))]
874   "TARGET_64BIT"
875   "sub %2,%3,%%r0\;sub,db %1,%4,%0"
876   [(set_attr "type" "binary")
877    (set_attr "length" "8")])
878
879 ; Match only integers for op3 here.  This is used as canonical form of the
880 ; ltu pattern when op3 is an integer.  Don't match registers since we can't
881 ; make better code than the general incscc pattern.
882 (define_insn ""
883   [(set (match_operand:SI 0 "register_operand" "=r")
884         (minus:SI (match_operand:SI 1 "register_operand" "r")
885                   (leu:SI (match_operand:SI 2 "register_operand" "r")
886                           (match_operand:SI 3 "int11_operand" "I"))))]
887   ""
888   "addi %k3,%2,%%r0\;{subb|sub,b} %1,%%r0,%0"
889   [(set_attr "type" "binary")
890    (set_attr "length" "8")])
891
892 (define_insn ""
893   [(set (match_operand:DI 0 "register_operand" "=r")
894         (minus:DI (match_operand:DI 1 "register_operand" "r")
895                   (leu:DI (match_operand:DI 2 "register_operand" "r")
896                           (match_operand:DI 3 "int11_operand" "I"))))]
897   "TARGET_64BIT"
898   "addi %k3,%2,%%r0\;sub,db %1,%%r0,%0"
899   [(set_attr "type" "binary")
900    (set_attr "length" "8")])
901
902 (define_insn ""
903   [(set (match_operand:SI 0 "register_operand" "=r")
904         (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
905                             (leu:SI (match_operand:SI 2 "register_operand" "r")
906                                     (match_operand:SI 3 "int11_operand" "I")))
907                   (match_operand:SI 4 "register_operand" "r")))]
908   ""
909   "addi %k3,%2,%%r0\;{subb|sub,b} %1,%4,%0"
910   [(set_attr "type" "binary")
911    (set_attr "length" "8")])
912
913 (define_insn ""
914   [(set (match_operand:DI 0 "register_operand" "=r")
915         (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
916                             (leu:DI (match_operand:DI 2 "register_operand" "r")
917                                     (match_operand:DI 3 "int11_operand" "I")))
918                   (match_operand:DI 4 "register_operand" "r")))]
919   "TARGET_64BIT"
920   "addi %k3,%2,%%r0\;sub,db %1,%4,%0"
921   [(set_attr "type" "binary")
922    (set_attr "length" "8")])
923
924 (define_insn "decscc"
925   [(set (match_operand:SI 0 "register_operand" "=r,r")
926         (minus:SI (match_operand:SI 1 "register_operand" "0,?r")
927                   (match_operator:SI 4 "comparison_operator"
928                      [(match_operand:SI 2 "register_operand" "r,r")
929                       (match_operand:SI 3 "arith11_operand" "rI,rI")])))]
930   ""
931   "@
932    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi -1,%0,%0
933    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi,tr -1,%1,%0\;copy %1,%0"
934   [(set_attr "type" "binary,binary")
935    (set_attr "length" "8,12")])
936
937 (define_insn ""
938   [(set (match_operand:DI 0 "register_operand" "=r,r")
939         (minus:DI (match_operand:DI 1 "register_operand" "0,?r")
940                   (match_operator:DI 4 "comparison_operator"
941                      [(match_operand:DI 2 "register_operand" "r,r")
942                       (match_operand:DI 3 "arith11_operand" "rI,rI")])))]
943   "TARGET_64BIT"
944   "@
945    cmp%I3clr,*%B4 %3,%2,%%r0\;addi -1,%0,%0
946    cmp%I3clr,*%B4 %3,%2,%%r0\;addi,tr -1,%1,%0\;copy %1,%0"
947   [(set_attr "type" "binary,binary")
948    (set_attr "length" "8,12")])
949
950 ; Patterns for max and min.  (There is no need for an earlyclobber in the
951 ; last alternative since the middle alternative will match if op0 == op1.)
952
953 (define_insn "sminsi3"
954   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
955         (smin:SI (match_operand:SI 1 "register_operand" "%0,0,r")
956                  (match_operand:SI 2 "arith11_operand" "r,I,M")))]
957   ""
958   "@
959   {comclr|cmpclr},> %2,%0,%%r0\;copy %2,%0
960   {comiclr|cmpiclr},> %2,%0,%%r0\;ldi %2,%0
961   {comclr|cmpclr},> %1,%r2,%0\;copy %1,%0"
962 [(set_attr "type" "multi,multi,multi")
963  (set_attr "length" "8,8,8")])
964
965 (define_insn "smindi3"
966   [(set (match_operand:DI 0 "register_operand" "=r,r,r")
967         (smin:DI (match_operand:DI 1 "register_operand" "%0,0,r")
968                  (match_operand:DI 2 "arith11_operand" "r,I,M")))]
969   "TARGET_64BIT"
970   "@
971   cmpclr,*> %2,%0,%%r0\;copy %2,%0
972   cmpiclr,*> %2,%0,%%r0\;ldi %2,%0
973   cmpclr,*> %1,%r2,%0\;copy %1,%0"
974 [(set_attr "type" "multi,multi,multi")
975  (set_attr "length" "8,8,8")])
976
977 (define_insn "uminsi3"
978   [(set (match_operand:SI 0 "register_operand" "=r,r")
979         (umin:SI (match_operand:SI 1 "register_operand" "%0,0")
980                  (match_operand:SI 2 "arith11_operand" "r,I")))]
981   ""
982   "@
983   {comclr|cmpclr},>> %2,%0,%%r0\;copy %2,%0
984   {comiclr|cmpiclr},>> %2,%0,%%r0\;ldi %2,%0"
985 [(set_attr "type" "multi,multi")
986  (set_attr "length" "8,8")])
987
988 (define_insn "umindi3"
989   [(set (match_operand:DI 0 "register_operand" "=r,r")
990         (umin:DI (match_operand:DI 1 "register_operand" "%0,0")
991                  (match_operand:DI 2 "arith11_operand" "r,I")))]
992   "TARGET_64BIT"
993   "@
994   cmpclr,*>> %2,%0,%%r0\;copy %2,%0
995   cmpiclr,*>> %2,%0,%%r0\;ldi %2,%0"
996 [(set_attr "type" "multi,multi")
997  (set_attr "length" "8,8")])
998
999 (define_insn "smaxsi3"
1000   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1001         (smax:SI (match_operand:SI 1 "register_operand" "%0,0,r")
1002                  (match_operand:SI 2 "arith11_operand" "r,I,M")))]
1003   ""
1004   "@
1005   {comclr|cmpclr},< %2,%0,%%r0\;copy %2,%0
1006   {comiclr|cmpiclr},< %2,%0,%%r0\;ldi %2,%0
1007   {comclr|cmpclr},< %1,%r2,%0\;copy %1,%0"
1008 [(set_attr "type" "multi,multi,multi")
1009  (set_attr "length" "8,8,8")])
1010
1011 (define_insn "smaxdi3"
1012   [(set (match_operand:DI 0 "register_operand" "=r,r,r")
1013         (smax:DI (match_operand:DI 1 "register_operand" "%0,0,r")
1014                  (match_operand:DI 2 "arith11_operand" "r,I,M")))]
1015   "TARGET_64BIT"
1016   "@
1017   cmpclr,*< %2,%0,%%r0\;copy %2,%0
1018   cmpiclr,*< %2,%0,%%r0\;ldi %2,%0
1019   cmpclr,*< %1,%r2,%0\;copy %1,%0"
1020 [(set_attr "type" "multi,multi,multi")
1021  (set_attr "length" "8,8,8")])
1022
1023 (define_insn "umaxsi3"
1024   [(set (match_operand:SI 0 "register_operand" "=r,r")
1025         (umax:SI (match_operand:SI 1 "register_operand" "%0,0")
1026                  (match_operand:SI 2 "arith11_operand" "r,I")))]
1027   ""
1028   "@
1029   {comclr|cmpclr},<< %2,%0,%%r0\;copy %2,%0
1030   {comiclr|cmpiclr},<< %2,%0,%%r0\;ldi %2,%0"
1031 [(set_attr "type" "multi,multi")
1032  (set_attr "length" "8,8")])
1033
1034 (define_insn "umaxdi3"
1035   [(set (match_operand:DI 0 "register_operand" "=r,r")
1036         (umax:DI (match_operand:DI 1 "register_operand" "%0,0")
1037                  (match_operand:DI 2 "arith11_operand" "r,I")))]
1038   "TARGET_64BIT"
1039   "@
1040   cmpclr,*<< %2,%0,%%r0\;copy %2,%0
1041   cmpiclr,*<< %2,%0,%%r0\;ldi %2,%0"
1042 [(set_attr "type" "multi,multi")
1043  (set_attr "length" "8,8")])
1044
1045 (define_insn "abssi2"
1046   [(set (match_operand:SI 0 "register_operand" "=r")
1047         (abs:SI (match_operand:SI 1 "register_operand" "r")))]
1048   ""
1049   "or,>= %%r0,%1,%0\;subi 0,%0,%0"
1050   [(set_attr "type" "multi")
1051    (set_attr "length" "8")])
1052
1053 (define_insn "absdi2"
1054   [(set (match_operand:DI 0 "register_operand" "=r")
1055         (abs:DI (match_operand:DI 1 "register_operand" "r")))]
1056   "TARGET_64BIT"
1057   "or,*>= %%r0,%1,%0\;subi 0,%0,%0"
1058   [(set_attr "type" "multi")
1059    (set_attr "length" "8")])
1060
1061 ;;; Experimental conditional move patterns
1062
1063 (define_expand "movsicc"
1064   [(set (match_operand:SI 0 "register_operand" "")
1065         (if_then_else:SI
1066          (match_operator 1 "comparison_operator"
1067             [(match_dup 4)
1068              (match_dup 5)])
1069          (match_operand:SI 2 "reg_or_cint_move_operand" "")
1070          (match_operand:SI 3 "reg_or_cint_move_operand" "")))]
1071   ""
1072   "
1073 {
1074   enum rtx_code code = GET_CODE (operands[1]);
1075
1076   if (hppa_branch_type != CMP_SI)
1077     FAIL;
1078
1079   if (GET_MODE (hppa_compare_op0) != GET_MODE (hppa_compare_op1)
1080       || GET_MODE (hppa_compare_op0) != GET_MODE (operands[0]))
1081     FAIL;
1082
1083   /* operands[1] is currently the result of compare_from_rtx.  We want to
1084      emit a compare of the original operands.  */
1085   operands[1] = gen_rtx_fmt_ee (code, SImode, hppa_compare_op0, hppa_compare_op1);
1086   operands[4] = hppa_compare_op0;
1087   operands[5] = hppa_compare_op1;
1088 }")
1089
1090 ;; We used to accept any register for op1.
1091 ;;
1092 ;; However, it loses sometimes because the compiler will end up using
1093 ;; different registers for op0 and op1 in some critical cases.  local-alloc
1094 ;; will  not tie op0 and op1 because op0 is used in multiple basic blocks.
1095 ;;
1096 ;; If/when global register allocation supports tying we should allow any
1097 ;; register for op1 again.
1098 (define_insn ""
1099   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
1100         (if_then_else:SI
1101          (match_operator 2 "comparison_operator"
1102             [(match_operand:SI 3 "register_operand" "r,r,r,r")
1103              (match_operand:SI 4 "arith11_operand" "rI,rI,rI,rI")])
1104          (match_operand:SI 1 "reg_or_cint_move_operand" "0,J,N,K")
1105          (const_int 0)))]
1106   ""
1107   "@
1108    {com%I4clr|cmp%I4clr},%S2 %4,%3,%%r0\;ldi 0,%0
1109    {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;ldi %1,%0
1110    {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;ldil L'%1,%0
1111    {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;{zdepi|depwi,z} %Z1,%0"
1112   [(set_attr "type" "multi,multi,multi,nullshift")
1113    (set_attr "length" "8,8,8,8")])
1114
1115 (define_insn ""
1116   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r,r,r")
1117         (if_then_else:SI
1118          (match_operator 5 "comparison_operator"
1119             [(match_operand:SI 3 "register_operand" "r,r,r,r,r,r,r,r")
1120              (match_operand:SI 4 "arith11_operand" "rI,rI,rI,rI,rI,rI,rI,rI")])
1121          (match_operand:SI 1 "reg_or_cint_move_operand" "0,0,0,0,r,J,N,K")
1122          (match_operand:SI 2 "reg_or_cint_move_operand" "r,J,N,K,0,0,0,0")))]
1123   ""
1124   "@
1125    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;copy %2,%0
1126    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;ldi %2,%0
1127    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;ldil L'%2,%0
1128    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;{zdepi|depwi,z} %Z2,%0
1129    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;copy %1,%0
1130    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;ldi %1,%0
1131    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;ldil L'%1,%0
1132    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;{zdepi|depwi,z} %Z1,%0"
1133   [(set_attr "type" "multi,multi,multi,nullshift,multi,multi,multi,nullshift")
1134    (set_attr "length" "8,8,8,8,8,8,8,8")])
1135
1136 (define_expand "movdicc"
1137   [(set (match_operand:DI 0 "register_operand" "")
1138         (if_then_else:DI
1139          (match_operator 1 "comparison_operator"
1140             [(match_dup 4)
1141              (match_dup 5)])
1142          (match_operand:DI 2 "reg_or_cint_move_operand" "")
1143          (match_operand:DI 3 "reg_or_cint_move_operand" "")))]
1144   "TARGET_64BIT"
1145   "
1146 {
1147   enum rtx_code code = GET_CODE (operands[1]);
1148
1149   if (hppa_branch_type != CMP_SI)
1150     FAIL;
1151
1152   if (GET_MODE (hppa_compare_op0) != GET_MODE (hppa_compare_op1)
1153       || GET_MODE (hppa_compare_op0) != GET_MODE (operands[0]))
1154     FAIL;
1155
1156   /* operands[1] is currently the result of compare_from_rtx.  We want to
1157      emit a compare of the original operands.  */
1158   operands[1] = gen_rtx_fmt_ee (code, DImode, hppa_compare_op0, hppa_compare_op1);
1159   operands[4] = hppa_compare_op0;
1160   operands[5] = hppa_compare_op1;
1161 }")
1162
1163 ; We need the first constraint alternative in order to avoid
1164 ; earlyclobbers on all other alternatives.
1165 (define_insn ""
1166   [(set (match_operand:DI 0 "register_operand" "=r,r,r,r,r")
1167         (if_then_else:DI
1168          (match_operator 2 "comparison_operator"
1169             [(match_operand:DI 3 "register_operand" "r,r,r,r,r")
1170              (match_operand:DI 4 "arith11_operand" "rI,rI,rI,rI,rI")])
1171          (match_operand:DI 1 "reg_or_cint_move_operand" "0,r,J,N,K")
1172          (const_int 0)))]
1173   "TARGET_64BIT"
1174   "@
1175    cmp%I4clr,*%S2 %4,%3,%%r0\;ldi 0,%0
1176    cmp%I4clr,*%B2 %4,%3,%0\;copy %1,%0
1177    cmp%I4clr,*%B2 %4,%3,%0\;ldi %1,%0
1178    cmp%I4clr,*%B2 %4,%3,%0\;ldil L'%1,%0
1179    cmp%I4clr,*%B2 %4,%3,%0\;depdi,z %z1,%0"
1180   [(set_attr "type" "multi,multi,multi,multi,nullshift")
1181    (set_attr "length" "8,8,8,8,8")])
1182
1183 (define_insn ""
1184   [(set (match_operand:DI 0 "register_operand" "=r,r,r,r,r,r,r,r")
1185         (if_then_else:DI
1186          (match_operator 5 "comparison_operator"
1187             [(match_operand:DI 3 "register_operand" "r,r,r,r,r,r,r,r")
1188              (match_operand:DI 4 "arith11_operand" "rI,rI,rI,rI,rI,rI,rI,rI")])
1189          (match_operand:DI 1 "reg_or_cint_move_operand" "0,0,0,0,r,J,N,K")
1190          (match_operand:DI 2 "reg_or_cint_move_operand" "r,J,N,K,0,0,0,0")))]
1191   "TARGET_64BIT"
1192   "@
1193    cmp%I4clr,*%S5 %4,%3,%%r0\;copy %2,%0
1194    cmp%I4clr,*%S5 %4,%3,%%r0\;ldi %2,%0
1195    cmp%I4clr,*%S5 %4,%3,%%r0\;ldil L'%2,%0
1196    cmp%I4clr,*%S5 %4,%3,%%r0\;depdi,z %z2,%0
1197    cmp%I4clr,*%B5 %4,%3,%%r0\;copy %1,%0
1198    cmp%I4clr,*%B5 %4,%3,%%r0\;ldi %1,%0
1199    cmp%I4clr,*%B5 %4,%3,%%r0\;ldil L'%1,%0
1200    cmp%I4clr,*%B5 %4,%3,%%r0\;depdi,z %z1,%0"
1201   [(set_attr "type" "multi,multi,multi,nullshift,multi,multi,multi,nullshift")
1202    (set_attr "length" "8,8,8,8,8,8,8,8")])
1203
1204 ;; Conditional Branches
1205
1206 (define_expand "beq"
1207   [(set (pc)
1208         (if_then_else (eq (match_dup 1) (match_dup 2))
1209                       (label_ref (match_operand 0 "" ""))
1210                       (pc)))]
1211   ""
1212   "
1213 {
1214   if (hppa_branch_type != CMP_SI)
1215     {
1216       emit_insn (gen_cmp_fp (EQ, hppa_compare_op0, hppa_compare_op1));
1217       emit_bcond_fp (NE, operands[0]);
1218       DONE;
1219     }
1220   /* set up operands from compare.  */
1221   operands[1] = hppa_compare_op0;
1222   operands[2] = hppa_compare_op1;
1223   /* fall through and generate default code */
1224 }")
1225
1226 (define_expand "bne"
1227   [(set (pc)
1228         (if_then_else (ne (match_dup 1) (match_dup 2))
1229                       (label_ref (match_operand 0 "" ""))
1230                       (pc)))]
1231   ""
1232   "
1233 {
1234   if (hppa_branch_type != CMP_SI)
1235     {
1236       emit_insn (gen_cmp_fp (NE, hppa_compare_op0, hppa_compare_op1));
1237       emit_bcond_fp (NE, operands[0]);
1238       DONE;
1239     }
1240   operands[1] = hppa_compare_op0;
1241   operands[2] = hppa_compare_op1;
1242 }")
1243
1244 (define_expand "bgt"
1245   [(set (pc)
1246         (if_then_else (gt (match_dup 1) (match_dup 2))
1247                       (label_ref (match_operand 0 "" ""))
1248                       (pc)))]
1249   ""
1250   "
1251 {
1252   if (hppa_branch_type != CMP_SI)
1253     {
1254       emit_insn (gen_cmp_fp (GT, hppa_compare_op0, hppa_compare_op1));
1255       emit_bcond_fp (NE, operands[0]);
1256       DONE;
1257     }
1258   operands[1] = hppa_compare_op0;
1259   operands[2] = hppa_compare_op1;
1260 }")
1261
1262 (define_expand "blt"
1263   [(set (pc)
1264         (if_then_else (lt (match_dup 1) (match_dup 2))
1265                       (label_ref (match_operand 0 "" ""))
1266                       (pc)))]
1267   ""
1268   "
1269 {
1270   if (hppa_branch_type != CMP_SI)
1271     {
1272       emit_insn (gen_cmp_fp (LT, hppa_compare_op0, hppa_compare_op1));
1273       emit_bcond_fp (NE, operands[0]);
1274       DONE;
1275     }
1276   operands[1] = hppa_compare_op0;
1277   operands[2] = hppa_compare_op1;
1278 }")
1279
1280 (define_expand "bge"
1281   [(set (pc)
1282         (if_then_else (ge (match_dup 1) (match_dup 2))
1283                       (label_ref (match_operand 0 "" ""))
1284                       (pc)))]
1285   ""
1286   "
1287 {
1288   if (hppa_branch_type != CMP_SI)
1289     {
1290       emit_insn (gen_cmp_fp (GE, hppa_compare_op0, hppa_compare_op1));
1291       emit_bcond_fp (NE, operands[0]);
1292       DONE;
1293     }
1294   operands[1] = hppa_compare_op0;
1295   operands[2] = hppa_compare_op1;
1296 }")
1297
1298 (define_expand "ble"
1299   [(set (pc)
1300         (if_then_else (le (match_dup 1) (match_dup 2))
1301                       (label_ref (match_operand 0 "" ""))
1302                       (pc)))]
1303   ""
1304   "
1305 {
1306   if (hppa_branch_type != CMP_SI)
1307     {
1308       emit_insn (gen_cmp_fp (LE, hppa_compare_op0, hppa_compare_op1));
1309       emit_bcond_fp (NE, operands[0]);
1310       DONE;
1311     }
1312   operands[1] = hppa_compare_op0;
1313   operands[2] = hppa_compare_op1;
1314 }")
1315
1316 (define_expand "bgtu"
1317   [(set (pc)
1318         (if_then_else (gtu (match_dup 1) (match_dup 2))
1319                       (label_ref (match_operand 0 "" ""))
1320                       (pc)))]
1321   ""
1322   "
1323 {
1324   if (hppa_branch_type != CMP_SI)
1325     FAIL;
1326   operands[1] = hppa_compare_op0;
1327   operands[2] = hppa_compare_op1;
1328 }")
1329
1330 (define_expand "bltu"
1331   [(set (pc)
1332         (if_then_else (ltu (match_dup 1) (match_dup 2))
1333                       (label_ref (match_operand 0 "" ""))
1334                       (pc)))]
1335   ""
1336   "
1337 {
1338   if (hppa_branch_type != CMP_SI)
1339     FAIL;
1340   operands[1] = hppa_compare_op0;
1341   operands[2] = hppa_compare_op1;
1342 }")
1343
1344 (define_expand "bgeu"
1345   [(set (pc)
1346         (if_then_else (geu (match_dup 1) (match_dup 2))
1347                       (label_ref (match_operand 0 "" ""))
1348                       (pc)))]
1349   ""
1350   "
1351 {
1352   if (hppa_branch_type != CMP_SI)
1353     FAIL;
1354   operands[1] = hppa_compare_op0;
1355   operands[2] = hppa_compare_op1;
1356 }")
1357
1358 (define_expand "bleu"
1359   [(set (pc)
1360         (if_then_else (leu (match_dup 1) (match_dup 2))
1361                       (label_ref (match_operand 0 "" ""))
1362                       (pc)))]
1363   ""
1364   "
1365 {
1366   if (hppa_branch_type != CMP_SI)
1367     FAIL;
1368   operands[1] = hppa_compare_op0;
1369   operands[2] = hppa_compare_op1;
1370 }")
1371
1372 (define_expand "bltgt"
1373   [(set (pc)
1374         (if_then_else (ltgt (match_dup 1) (match_dup 2))
1375                       (label_ref (match_operand 0 "" ""))
1376                       (pc)))]
1377   ""
1378   "
1379 {
1380   if (hppa_branch_type == CMP_SI)
1381     FAIL;
1382   emit_insn (gen_cmp_fp (LTGT, hppa_compare_op0, hppa_compare_op1));
1383   emit_bcond_fp (NE, operands[0]);
1384   DONE;
1385 }")
1386
1387 (define_expand "bunle"
1388   [(set (pc)
1389         (if_then_else (unle (match_dup 1) (match_dup 2))
1390                       (label_ref (match_operand 0 "" ""))
1391                       (pc)))]
1392   ""
1393   "
1394 {
1395   if (hppa_branch_type == CMP_SI)
1396     FAIL;
1397   emit_insn (gen_cmp_fp (UNLE, hppa_compare_op0, hppa_compare_op1));
1398   emit_bcond_fp (NE, operands[0]);
1399   DONE;
1400 }")
1401
1402 (define_expand "bunlt"
1403   [(set (pc)
1404         (if_then_else (unlt (match_dup 1) (match_dup 2))
1405                       (label_ref (match_operand 0 "" ""))
1406                       (pc)))]
1407   ""
1408   "
1409 {
1410   if (hppa_branch_type == CMP_SI)
1411     FAIL;
1412   emit_insn (gen_cmp_fp (UNLT, hppa_compare_op0, hppa_compare_op1));
1413   emit_bcond_fp (NE, operands[0]);
1414   DONE;
1415 }")
1416
1417 (define_expand "bunge"
1418   [(set (pc)
1419         (if_then_else (unge (match_dup 1) (match_dup 2))
1420                       (label_ref (match_operand 0 "" ""))
1421                       (pc)))]
1422   ""
1423   "
1424 {
1425   if (hppa_branch_type == CMP_SI)
1426     FAIL;
1427   emit_insn (gen_cmp_fp (UNGE, hppa_compare_op0, hppa_compare_op1));
1428   emit_bcond_fp (NE, operands[0]);
1429   DONE;
1430 }")
1431
1432 (define_expand "bungt"
1433   [(set (pc)
1434         (if_then_else (ungt (match_dup 1) (match_dup 2))
1435                       (label_ref (match_operand 0 "" ""))
1436                       (pc)))]
1437   ""
1438   "
1439 {
1440   if (hppa_branch_type == CMP_SI)
1441     FAIL;
1442   emit_insn (gen_cmp_fp (UNGT, hppa_compare_op0, hppa_compare_op1));
1443   emit_bcond_fp (NE, operands[0]);
1444   DONE;
1445 }")
1446
1447 (define_expand "buneq"
1448   [(set (pc)
1449         (if_then_else (uneq (match_dup 1) (match_dup 2))
1450                       (label_ref (match_operand 0 "" ""))
1451                       (pc)))]
1452   ""
1453   "
1454 {
1455   if (hppa_branch_type == CMP_SI)
1456     FAIL;
1457   emit_insn (gen_cmp_fp (UNEQ, hppa_compare_op0, hppa_compare_op1));
1458   emit_bcond_fp (NE, operands[0]);
1459   DONE;
1460 }")
1461
1462 (define_expand "bunordered"
1463   [(set (pc)
1464         (if_then_else (unordered (match_dup 1) (match_dup 2))
1465                       (label_ref (match_operand 0 "" ""))
1466                       (pc)))]
1467   ""
1468   "
1469 {
1470   if (hppa_branch_type == CMP_SI)
1471     FAIL;
1472   emit_insn (gen_cmp_fp (UNORDERED, hppa_compare_op0, hppa_compare_op1));
1473   emit_bcond_fp (NE, operands[0]);
1474   DONE;
1475 }")
1476
1477 (define_expand "bordered"
1478   [(set (pc)
1479         (if_then_else (ordered (match_dup 1) (match_dup 2))
1480                       (label_ref (match_operand 0 "" ""))
1481                       (pc)))]
1482   ""
1483   "
1484 {
1485   if (hppa_branch_type == CMP_SI)
1486     FAIL;
1487   emit_insn (gen_cmp_fp (ORDERED, hppa_compare_op0, hppa_compare_op1));
1488   emit_bcond_fp (NE, operands[0]);
1489   DONE;
1490 }")
1491
1492 ;; Match the branch patterns.
1493
1494
1495 ;; Note a long backward conditional branch with an annulled delay slot
1496 ;; has a length of 12.
1497 (define_insn ""
1498   [(set (pc)
1499         (if_then_else
1500          (match_operator 3 "comparison_operator"
1501                          [(match_operand:SI 1 "reg_or_0_operand" "rM")
1502                           (match_operand:SI 2 "arith5_operand" "rL")])
1503          (label_ref (match_operand 0 "" ""))
1504          (pc)))]
1505   ""
1506   "*
1507 {
1508   return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1509                          get_attr_length (insn), 0, insn);
1510 }"
1511 [(set_attr "type" "cbranch")
1512  (set (attr "length")
1513     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1514                (const_int 8184))
1515            (const_int 4)
1516            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1517                (const_int 262100))
1518            (const_int 8)
1519            (eq (symbol_ref "flag_pic") (const_int 0))
1520            (const_int 20)]
1521           (const_int 28)))])
1522
1523 ;; Match the negated branch.
1524
1525 (define_insn ""
1526   [(set (pc)
1527         (if_then_else
1528          (match_operator 3 "comparison_operator"
1529                          [(match_operand:SI 1 "reg_or_0_operand" "rM")
1530                           (match_operand:SI 2 "arith5_operand" "rL")])
1531          (pc)
1532          (label_ref (match_operand 0 "" ""))))]
1533   ""
1534   "*
1535 {
1536   return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1537                          get_attr_length (insn), 1, insn);
1538 }"
1539 [(set_attr "type" "cbranch")
1540  (set (attr "length")
1541     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1542                (const_int 8184))
1543            (const_int 4)
1544            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1545                (const_int 262100))
1546            (const_int 8)
1547            (eq (symbol_ref "flag_pic") (const_int 0))
1548            (const_int 20)]
1549           (const_int 28)))])
1550
1551 (define_insn ""
1552   [(set (pc)
1553         (if_then_else
1554          (match_operator 3 "comparison_operator"
1555                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1556                           (match_operand:DI 2 "reg_or_0_operand" "rM")])
1557          (label_ref (match_operand 0 "" ""))
1558          (pc)))]
1559   "TARGET_64BIT"
1560   "*
1561 {
1562   return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1563                          get_attr_length (insn), 0, insn);
1564 }"
1565 [(set_attr "type" "cbranch")
1566  (set (attr "length")
1567     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1568                (const_int 8184))
1569            (const_int 4)
1570            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1571                (const_int 262100))
1572            (const_int 8)
1573            (eq (symbol_ref "flag_pic") (const_int 0))
1574            (const_int 20)]
1575           (const_int 28)))])
1576
1577 ;; Match the negated branch.
1578
1579 (define_insn ""
1580   [(set (pc)
1581         (if_then_else
1582          (match_operator 3 "comparison_operator"
1583                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1584                           (match_operand:DI 2 "reg_or_0_operand" "rM")])
1585          (pc)
1586          (label_ref (match_operand 0 "" ""))))]
1587   "TARGET_64BIT"
1588   "*
1589 {
1590   return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1591                          get_attr_length (insn), 1, insn);
1592 }"
1593 [(set_attr "type" "cbranch")
1594  (set (attr "length")
1595     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1596                (const_int 8184))
1597            (const_int 4)
1598            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1599                (const_int 262100))
1600            (const_int 8)
1601            (eq (symbol_ref "flag_pic") (const_int 0))
1602            (const_int 20)]
1603           (const_int 28)))])
1604 (define_insn ""
1605   [(set (pc)
1606         (if_then_else
1607          (match_operator 3 "cmpib_comparison_operator"
1608                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1609                           (match_operand:DI 2 "arith5_operand" "rL")])
1610          (label_ref (match_operand 0 "" ""))
1611          (pc)))]
1612   "TARGET_64BIT"
1613   "*
1614 {
1615   return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1616                          get_attr_length (insn), 0, insn);
1617 }"
1618 [(set_attr "type" "cbranch")
1619  (set (attr "length")
1620     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1621                (const_int 8184))
1622            (const_int 4)
1623            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1624                (const_int 262100))
1625            (const_int 8)
1626            (eq (symbol_ref "flag_pic") (const_int 0))
1627            (const_int 20)]
1628           (const_int 28)))])
1629
1630 ;; Match the negated branch.
1631
1632 (define_insn ""
1633   [(set (pc)
1634         (if_then_else
1635          (match_operator 3 "cmpib_comparison_operator"
1636                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1637                           (match_operand:DI 2 "arith5_operand" "rL")])
1638          (pc)
1639          (label_ref (match_operand 0 "" ""))))]
1640   "TARGET_64BIT"
1641   "*
1642 {
1643   return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1644                          get_attr_length (insn), 1, insn);
1645 }"
1646 [(set_attr "type" "cbranch")
1647  (set (attr "length")
1648     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1649                (const_int 8184))
1650            (const_int 4)
1651            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1652                (const_int 262100))
1653            (const_int 8)
1654            (eq (symbol_ref "flag_pic") (const_int 0))
1655            (const_int 20)]
1656           (const_int 28)))])
1657
1658 ;; Branch on Bit patterns.
1659 (define_insn ""
1660   [(set (pc)
1661         (if_then_else
1662          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1663                               (const_int 1)
1664                               (match_operand:SI 1 "uint5_operand" ""))
1665              (const_int 0))
1666          (label_ref (match_operand 2 "" ""))
1667          (pc)))]
1668   ""
1669   "*
1670 {
1671   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1672                          get_attr_length (insn), 0, insn, 0);
1673 }"
1674 [(set_attr "type" "cbranch")
1675  (set (attr "length")
1676     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1677                       (const_int 8184))
1678            (const_int 4)
1679            (const_int 8)))])
1680
1681 (define_insn ""
1682   [(set (pc)
1683         (if_then_else
1684          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1685                               (const_int 1)
1686                               (match_operand:DI 1 "uint32_operand" ""))
1687              (const_int 0))
1688          (label_ref (match_operand 2 "" ""))
1689          (pc)))]
1690   "TARGET_64BIT"
1691   "*
1692 {
1693   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1694                          get_attr_length (insn), 0, insn, 0);
1695 }"
1696 [(set_attr "type" "cbranch")
1697  (set (attr "length")
1698     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1699                       (const_int 8184))
1700            (const_int 4)
1701            (const_int 8)))])
1702
1703 (define_insn ""
1704   [(set (pc)
1705         (if_then_else
1706          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1707                               (const_int 1)
1708                               (match_operand:SI 1 "uint5_operand" ""))
1709              (const_int 0))
1710          (pc)
1711          (label_ref (match_operand 2 "" ""))))]
1712   ""
1713   "*
1714 {
1715   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1716                          get_attr_length (insn), 1, insn, 0);
1717 }"
1718 [(set_attr "type" "cbranch")
1719  (set (attr "length")
1720     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1721                       (const_int 8184))
1722            (const_int 4)
1723            (const_int 8)))])
1724
1725 (define_insn ""
1726   [(set (pc)
1727         (if_then_else
1728          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1729                               (const_int 1)
1730                               (match_operand:DI 1 "uint32_operand" ""))
1731              (const_int 0))
1732          (pc)
1733          (label_ref (match_operand 2 "" ""))))]
1734   "TARGET_64BIT"
1735   "*
1736 {
1737   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1738                          get_attr_length (insn), 1, insn, 0);
1739 }"
1740 [(set_attr "type" "cbranch")
1741  (set (attr "length")
1742     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1743                       (const_int 8184))
1744            (const_int 4)
1745            (const_int 8)))])
1746
1747 (define_insn ""
1748   [(set (pc)
1749         (if_then_else
1750          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1751                               (const_int 1)
1752                               (match_operand:SI 1 "uint5_operand" ""))
1753              (const_int 0))
1754          (label_ref (match_operand 2 "" ""))
1755          (pc)))]
1756   ""
1757   "*
1758 {
1759   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1760                          get_attr_length (insn), 0, insn, 1);
1761 }"
1762 [(set_attr "type" "cbranch")
1763  (set (attr "length")
1764     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1765                       (const_int 8184))
1766            (const_int 4)
1767            (const_int 8)))])
1768
1769 (define_insn ""
1770   [(set (pc)
1771         (if_then_else
1772          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1773                               (const_int 1)
1774                               (match_operand:DI 1 "uint32_operand" ""))
1775              (const_int 0))
1776          (label_ref (match_operand 2 "" ""))
1777          (pc)))]
1778   "TARGET_64BIT"
1779   "*
1780 {
1781   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1782                          get_attr_length (insn), 0, insn, 1);
1783 }"
1784 [(set_attr "type" "cbranch")
1785  (set (attr "length")
1786     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1787                       (const_int 8184))
1788            (const_int 4)
1789            (const_int 8)))])
1790
1791 (define_insn ""
1792   [(set (pc)
1793         (if_then_else
1794          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1795                               (const_int 1)
1796                               (match_operand:SI 1 "uint5_operand" ""))
1797              (const_int 0))
1798          (pc)
1799          (label_ref (match_operand 2 "" ""))))]
1800   ""
1801   "*
1802 {
1803   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1804                          get_attr_length (insn), 1, insn, 1);
1805 }"
1806 [(set_attr "type" "cbranch")
1807  (set (attr "length")
1808     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1809                       (const_int 8184))
1810            (const_int 4)
1811            (const_int 8)))])
1812
1813 (define_insn ""
1814   [(set (pc)
1815         (if_then_else
1816          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1817                               (const_int 1)
1818                               (match_operand:DI 1 "uint32_operand" ""))
1819              (const_int 0))
1820          (pc)
1821          (label_ref (match_operand 2 "" ""))))]
1822   "TARGET_64BIT"
1823   "*
1824 {
1825   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1826                          get_attr_length (insn), 1, insn, 1);
1827 }"
1828 [(set_attr "type" "cbranch")
1829  (set (attr "length")
1830     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1831                       (const_int 8184))
1832            (const_int 4)
1833            (const_int 8)))])
1834
1835 ;; Branch on Variable Bit patterns.
1836 (define_insn ""
1837   [(set (pc)
1838         (if_then_else
1839          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1840                               (const_int 1)
1841                               (match_operand:SI 1 "register_operand" "q"))
1842              (const_int 0))
1843          (label_ref (match_operand 2 "" ""))
1844          (pc)))]
1845   ""
1846   "*
1847 {
1848   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
1849                      get_attr_length (insn), 0, insn, 0);
1850 }"
1851 [(set_attr "type" "cbranch")
1852  (set (attr "length")
1853     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1854                       (const_int 8184))
1855            (const_int 4)
1856            (const_int 8)))])
1857
1858 (define_insn ""
1859   [(set (pc)
1860         (if_then_else
1861          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1862                               (const_int 1)
1863                               (match_operand:DI 1 "register_operand" "q"))
1864              (const_int 0))
1865          (label_ref (match_operand 2 "" ""))
1866          (pc)))]
1867   "TARGET_64BIT"
1868   "*
1869 {
1870   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
1871                      get_attr_length (insn), 0, insn, 0);
1872 }"
1873 [(set_attr "type" "cbranch")
1874  (set (attr "length")
1875     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1876                       (const_int 8184))
1877            (const_int 4)
1878            (const_int 8)))])
1879
1880 (define_insn ""
1881   [(set (pc)
1882         (if_then_else
1883          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1884                               (const_int 1)
1885                               (match_operand:SI 1 "register_operand" "q"))
1886              (const_int 0))
1887          (pc)
1888          (label_ref (match_operand 2 "" ""))))]
1889   ""
1890   "*
1891 {
1892   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
1893                      get_attr_length (insn), 1, insn, 0);
1894 }"
1895 [(set_attr "type" "cbranch")
1896  (set (attr "length")
1897     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1898                       (const_int 8184))
1899            (const_int 4)
1900            (const_int 8)))])
1901
1902 (define_insn ""
1903   [(set (pc)
1904         (if_then_else
1905          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1906                               (const_int 1)
1907                               (match_operand:DI 1 "register_operand" "q"))
1908              (const_int 0))
1909          (pc)
1910          (label_ref (match_operand 2 "" ""))))]
1911   "TARGET_64BIT"
1912   "*
1913 {
1914   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
1915                      get_attr_length (insn), 1, insn, 0);
1916 }"
1917 [(set_attr "type" "cbranch")
1918  (set (attr "length")
1919     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1920                       (const_int 8184))
1921            (const_int 4)
1922            (const_int 8)))])
1923
1924 (define_insn ""
1925   [(set (pc)
1926         (if_then_else
1927          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1928                               (const_int 1)
1929                               (match_operand:SI 1 "register_operand" "q"))
1930              (const_int 0))
1931          (label_ref (match_operand 2 "" ""))
1932          (pc)))]
1933   ""
1934   "*
1935 {
1936   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
1937                      get_attr_length (insn), 0, insn, 1);
1938 }"
1939 [(set_attr "type" "cbranch")
1940  (set (attr "length")
1941     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1942                       (const_int 8184))
1943            (const_int 4)
1944            (const_int 8)))])
1945
1946 (define_insn ""
1947   [(set (pc)
1948         (if_then_else
1949          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1950                               (const_int 1)
1951                               (match_operand:DI 1 "register_operand" "q"))
1952              (const_int 0))
1953          (label_ref (match_operand 2 "" ""))
1954          (pc)))]
1955   "TARGET_64BIT"
1956   "*
1957 {
1958   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
1959                      get_attr_length (insn), 0, insn, 1);
1960 }"
1961 [(set_attr "type" "cbranch")
1962  (set (attr "length")
1963     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1964                       (const_int 8184))
1965            (const_int 4)
1966            (const_int 8)))])
1967
1968 (define_insn ""
1969   [(set (pc)
1970         (if_then_else
1971          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1972                               (const_int 1)
1973                               (match_operand:SI 1 "register_operand" "q"))
1974              (const_int 0))
1975          (pc)
1976          (label_ref (match_operand 2 "" ""))))]
1977   ""
1978   "*
1979 {
1980   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
1981                      get_attr_length (insn), 1, insn, 1);
1982 }"
1983 [(set_attr "type" "cbranch")
1984  (set (attr "length")
1985     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1986                       (const_int 8184))
1987            (const_int 4)
1988            (const_int 8)))])
1989
1990 (define_insn ""
1991   [(set (pc)
1992         (if_then_else
1993          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1994                               (const_int 1)
1995                               (match_operand:DI 1 "register_operand" "q"))
1996              (const_int 0))
1997          (pc)
1998          (label_ref (match_operand 2 "" ""))))]
1999   "TARGET_64BIT"
2000   "*
2001 {
2002   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
2003                      get_attr_length (insn), 1, insn, 1);
2004 }"
2005 [(set_attr "type" "cbranch")
2006  (set (attr "length")
2007     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2008                       (const_int 8184))
2009            (const_int 4)
2010            (const_int 8)))])
2011
2012 ;; Floating point branches
2013 (define_insn ""
2014   [(set (pc) (if_then_else (ne (reg:CCFP 0) (const_int 0))
2015                            (label_ref (match_operand 0 "" ""))
2016                            (pc)))]
2017   "! TARGET_SOFT_FLOAT"
2018   "*
2019 {
2020   if (INSN_ANNULLED_BRANCH_P (insn))
2021     return \"ftest\;b,n %0\";
2022   else
2023     return \"ftest\;b%* %0\";
2024 }"
2025   [(set_attr "type" "fbranch")
2026    (set_attr "length" "8")])
2027
2028 (define_insn ""
2029   [(set (pc) (if_then_else (ne (reg:CCFP 0) (const_int 0))
2030                            (pc)
2031                            (label_ref (match_operand 0 "" ""))))]
2032   "! TARGET_SOFT_FLOAT"
2033   "*
2034 {
2035   if (INSN_ANNULLED_BRANCH_P (insn))
2036     return \"ftest\;add,tr %%r0,%%r0,%%r0\;b,n %0\";
2037   else
2038     return \"ftest\;add,tr %%r0,%%r0,%%r0\;b%* %0\";
2039 }"
2040   [(set_attr "type" "fbranch")
2041    (set_attr "length" "12")])
2042
2043 ;; Move instructions
2044
2045 (define_expand "movsi"
2046   [(set (match_operand:SI 0 "general_operand" "")
2047         (match_operand:SI 1 "general_operand" ""))]
2048   ""
2049   "
2050 {
2051   if (emit_move_sequence (operands, SImode, 0))
2052     DONE;
2053 }")
2054
2055 ;; Reloading an SImode or DImode value requires a scratch register if
2056 ;; going in to or out of float point registers.
2057
2058 (define_expand "reload_insi"
2059   [(set (match_operand:SI 0 "register_operand" "=Z")
2060         (match_operand:SI 1 "non_hard_reg_operand" ""))
2061    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
2062   ""
2063   "
2064 {
2065   if (emit_move_sequence (operands, SImode, operands[2]))
2066     DONE;
2067
2068   /* We don't want the clobber emitted, so handle this ourselves.  */
2069   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
2070   DONE;
2071 }")
2072
2073 (define_expand "reload_outsi"
2074   [(set (match_operand:SI 0 "non_hard_reg_operand" "")
2075         (match_operand:SI 1  "register_operand" "Z"))
2076    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
2077   ""
2078   "
2079 {
2080   if (emit_move_sequence (operands, SImode, operands[2]))
2081     DONE;
2082
2083   /* We don't want the clobber emitted, so handle this ourselves.  */
2084   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
2085   DONE;
2086 }")
2087
2088 (define_insn ""
2089   [(set (match_operand:SI 0 "reg_or_nonsymb_mem_operand"
2090                                 "=r,r,r,r,r,r,Q,*q,!f,f,*TR")
2091         (match_operand:SI 1 "move_operand"
2092                                 "A,r,J,N,K,RQ,rM,rM,!fM,*RT,f"))]
2093   "(register_operand (operands[0], SImode)
2094     || reg_or_0_operand (operands[1], SImode))
2095    && ! TARGET_SOFT_FLOAT"
2096   "@
2097    ldw RT'%A1,%0
2098    copy %1,%0
2099    ldi %1,%0
2100    ldil L'%1,%0
2101    {zdepi|depwi,z} %Z1,%0
2102    ldw%M1 %1,%0
2103    stw%M0 %r1,%0
2104    mtsar %r1
2105    fcpy,sgl %f1,%0
2106    fldw%F1 %1,%0
2107    fstw%F0 %1,%0"
2108   [(set_attr "type" "load,move,move,move,shift,load,store,move,fpalu,fpload,fpstore")
2109    (set_attr "pa_combine_type" "addmove")
2110    (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4")])
2111
2112 (define_insn ""
2113   [(set (match_operand:SI 0 "reg_or_nonsymb_mem_operand"
2114                                 "=r,r,r,r,r,r,Q,*q")
2115         (match_operand:SI 1 "move_operand"
2116                                 "A,r,J,N,K,RQ,rM,rM"))]
2117   "(register_operand (operands[0], SImode)
2118     || reg_or_0_operand (operands[1], SImode))
2119    && TARGET_SOFT_FLOAT"
2120   "@
2121    ldw RT'%A1,%0
2122    copy %1,%0
2123    ldi %1,%0
2124    ldil L'%1,%0
2125    {zdepi|depwi,z} %Z1,%0
2126    ldw%M1 %1,%0
2127    stw%M0 %r1,%0
2128    mtsar %r1"
2129   [(set_attr "type" "load,move,move,move,move,load,store,move")
2130    (set_attr "pa_combine_type" "addmove")
2131    (set_attr "length" "4,4,4,4,4,4,4,4")])
2132
2133 (define_insn ""
2134   [(set (match_operand:SI 0 "register_operand" "=r")
2135         (mem:SI (plus:SI (match_operand:SI 1 "basereg_operand" "r")
2136                          (match_operand:SI 2 "register_operand" "r"))))]
2137   "! TARGET_DISABLE_INDEXING"
2138   "{ldwx|ldw} %2(%1),%0"
2139   [(set_attr "type" "load")
2140    (set_attr "length" "4")])
2141
2142 (define_insn ""
2143   [(set (match_operand:SI 0 "register_operand" "=r")
2144         (mem:SI (plus:SI (match_operand:SI 1 "register_operand" "r")
2145                          (match_operand:SI 2 "basereg_operand" "r"))))]
2146   "! TARGET_DISABLE_INDEXING"
2147   "{ldwx|ldw} %1(%2),%0"
2148   [(set_attr "type" "load")
2149    (set_attr "length" "4")])
2150
2151 ;; Load or store with base-register modification.
2152
2153 (define_expand "pre_load"
2154   [(parallel [(set (match_operand:SI 0 "register_operand" "")
2155               (mem (plus (match_operand 1 "register_operand" "")
2156                                (match_operand 2 "pre_cint_operand" ""))))
2157               (set (match_dup 1)
2158                    (plus (match_dup 1) (match_dup 2)))])]
2159   ""
2160   "
2161 {
2162   if (TARGET_64BIT)
2163     {
2164       emit_insn (gen_pre_ldd (operands[0], operands[1], operands[2]));
2165       DONE;
2166     }
2167   emit_insn (gen_pre_ldw (operands[0], operands[1], operands[2]));
2168   DONE;
2169 }")
2170
2171 (define_insn "pre_ldw"
2172   [(set (match_operand:SI 0 "register_operand" "=r")
2173         (mem:SI (plus:SI (match_operand:SI 1 "register_operand" "+r")
2174                          (match_operand:SI 2 "pre_cint_operand" ""))))
2175    (set (match_dup 1)
2176         (plus:SI (match_dup 1) (match_dup 2)))]
2177   ""
2178   "*
2179 {
2180   if (INTVAL (operands[2]) < 0)
2181     return \"{ldwm|ldw,mb} %2(%1),%0\";
2182   return \"{ldws|ldw},mb %2(%1),%0\";
2183 }"
2184   [(set_attr "type" "load")
2185    (set_attr "length" "4")])
2186
2187 (define_insn "pre_ldd"
2188   [(set (match_operand:DI 0 "register_operand" "=r")
2189         (mem:DI (plus:DI (match_operand:DI 1 "register_operand" "+r")
2190                          (match_operand:DI 2 "pre_cint_operand" ""))))
2191    (set (match_dup 1)
2192         (plus:DI (match_dup 1) (match_dup 2)))]
2193   "TARGET_64BIT"
2194   "ldd,mb %2(%1),%0"
2195   [(set_attr "type" "load")
2196    (set_attr "length" "4")])
2197
2198 (define_insn ""
2199   [(set (mem:SI (plus:SI (match_operand:SI 0 "register_operand" "+r")
2200                          (match_operand:SI 1 "pre_cint_operand" "")))
2201         (match_operand:SI 2 "reg_or_0_operand" "rM"))
2202    (set (match_dup 0)
2203         (plus:SI (match_dup 0) (match_dup 1)))]
2204   ""
2205   "*
2206 {
2207   if (INTVAL (operands[1]) < 0)
2208     return \"{stwm|stw,mb} %r2,%1(%0)\";
2209   return \"{stws|stw},mb %r2,%1(%0)\";
2210 }"
2211   [(set_attr "type" "store")
2212    (set_attr "length" "4")])
2213
2214 (define_insn ""
2215   [(set (match_operand:SI 0 "register_operand" "=r")
2216         (mem:SI (match_operand:SI 1 "register_operand" "+r")))
2217    (set (match_dup 1)
2218         (plus:SI (match_dup 1)
2219                  (match_operand:SI 2 "post_cint_operand" "")))]
2220   ""
2221   "*
2222 {
2223   if (INTVAL (operands[2]) > 0)
2224     return \"{ldwm|ldw,ma} %2(%1),%0\";
2225   return \"{ldws|ldw},ma %2(%1),%0\";
2226 }"
2227   [(set_attr "type" "load")
2228    (set_attr "length" "4")])
2229
2230 (define_expand "post_store"
2231   [(parallel [(set (mem (match_operand 0 "register_operand" ""))
2232                    (match_operand 1 "reg_or_0_operand" ""))
2233               (set (match_dup 0)
2234                    (plus (match_dup 0)
2235                          (match_operand 2 "post_cint_operand" "")))])]
2236   ""
2237   "
2238 {
2239   if (TARGET_64BIT)
2240     {
2241       emit_insn (gen_post_std (operands[0], operands[1], operands[2]));
2242       DONE;
2243     }
2244   emit_insn (gen_post_stw (operands[0], operands[1], operands[2]));
2245   DONE;
2246 }")
2247
2248 (define_insn "post_stw"
2249   [(set (mem:SI (match_operand:SI 0 "register_operand" "+r"))
2250         (match_operand:SI 1 "reg_or_0_operand" "rM"))
2251    (set (match_dup 0)
2252         (plus:SI (match_dup 0)
2253                  (match_operand:SI 2 "post_cint_operand" "")))]
2254   ""
2255   "*
2256 {
2257   if (INTVAL (operands[2]) > 0)
2258     return \"{stwm|stw,ma} %r1,%2(%0)\";
2259   return \"{stws|stw},ma %r1,%2(%0)\";
2260 }"
2261   [(set_attr "type" "store")
2262    (set_attr "length" "4")])
2263
2264 (define_insn "post_std"
2265   [(set (mem:DI (match_operand:DI 0 "register_operand" "+r"))
2266         (match_operand:DI 1 "reg_or_0_operand" "rM"))
2267    (set (match_dup 0)
2268         (plus:DI (match_dup 0)
2269                  (match_operand:DI 2 "post_cint_operand" "")))]
2270   "TARGET_64BIT"
2271   "std,ma %r1,%2(%0)"
2272   [(set_attr "type" "store")
2273    (set_attr "length" "4")])
2274
2275 ;; For loading the address of a label while generating PIC code.
2276 ;; Note since this pattern can be created at reload time (via movsi), all
2277 ;; the same rules for movsi apply here.  (no new pseudos, no temporaries).
2278 (define_insn ""
2279   [(set (match_operand 0 "pmode_register_operand" "=a")
2280         (match_operand 1 "pic_label_operand" ""))]
2281   ""
2282   "*
2283 {
2284   rtx label_rtx = gen_label_rtx ();
2285   rtx xoperands[3];
2286   extern FILE *asm_out_file;
2287
2288   xoperands[0] = operands[0];
2289   xoperands[1] = operands[1];
2290   xoperands[2] = label_rtx;
2291   output_asm_insn (\"{bl|b,l} .+8,%0\", xoperands);
2292   output_asm_insn (\"{depi|depwi} 0,31,2,%0\", xoperands);
2293   ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\",
2294                              CODE_LABEL_NUMBER (label_rtx));
2295
2296   /* If we're trying to load the address of a label that happens to be
2297      close, then we can use a shorter sequence.  */
2298   if (GET_CODE (operands[1]) == LABEL_REF
2299       && INSN_ADDRESSES_SET_P ()
2300       && abs (INSN_ADDRESSES (INSN_UID (XEXP (operands[1], 0)))
2301                 - INSN_ADDRESSES (INSN_UID (insn))) < 8100)
2302     {
2303       /* Prefixing with R% here is wrong, it extracts just 11 bits and is
2304          always non-negative.  */
2305       output_asm_insn (\"ldo %1-%2(%0),%0\", xoperands);
2306     }
2307   else
2308     {
2309       output_asm_insn (\"addil L%%%1-%2,%0\", xoperands);
2310       output_asm_insn (\"ldo R%%%1-%2(%0),%0\", xoperands);
2311     }
2312   return \"\";
2313 }"
2314   [(set_attr "type" "multi")
2315    (set_attr "length" "16")])           ; 12 or 16
2316
2317 (define_insn ""
2318   [(set (match_operand:SI 0 "register_operand" "=a")
2319         (plus:SI (match_operand:SI 1 "register_operand" "r")
2320                  (high:SI (match_operand 2 "" ""))))]
2321   "symbolic_operand (operands[2], Pmode)
2322    && ! function_label_operand (operands[2], Pmode)
2323    && flag_pic"
2324   "addil LT'%G2,%1"
2325   [(set_attr "type" "binary")
2326    (set_attr "length" "4")])
2327
2328 (define_insn ""
2329   [(set (match_operand:DI 0 "register_operand" "=a")
2330         (plus:DI (match_operand:DI 1 "register_operand" "r")
2331                  (high:DI (match_operand 2 "" ""))))]
2332   "symbolic_operand (operands[2], Pmode)
2333    && ! function_label_operand (operands[2], Pmode)
2334    && TARGET_64BIT
2335    && flag_pic"
2336   "addil LT'%G2,%1"
2337   [(set_attr "type" "binary")
2338    (set_attr "length" "4")])
2339
2340 ;; Always use addil rather than ldil;add sequences.  This allows the
2341 ;; HP linker to eliminate the dp relocation if the symbolic operand
2342 ;; lives in the TEXT space.
2343 (define_insn ""
2344   [(set (match_operand:SI 0 "register_operand" "=a")
2345         (high:SI (match_operand 1 "" "")))]
2346   "symbolic_operand (operands[1], Pmode)
2347    && ! function_label_operand (operands[1], Pmode)
2348    && ! read_only_operand (operands[1], Pmode)
2349    && ! flag_pic"
2350   "*
2351 {
2352   if (TARGET_LONG_LOAD_STORE)
2353     return \"addil NLR'%H1,%%r27\;ldo N'%H1(%%r1),%%r1\";
2354   else
2355     return \"addil LR'%H1,%%r27\";
2356 }"
2357   [(set_attr "type" "binary")
2358    (set (attr "length")
2359       (if_then_else (eq (symbol_ref "TARGET_LONG_LOAD_STORE") (const_int 0))
2360                     (const_int 4)
2361                     (const_int 8)))])
2362
2363
2364 ;; This is for use in the prologue/epilogue code.  We need it
2365 ;; to add large constants to a stack pointer or frame pointer.
2366 ;; Because of the additional %r1 pressure, we probably do not
2367 ;; want to use this in general code, so make it available
2368 ;; only after reload.
2369 (define_insn ""
2370   [(set (match_operand:SI 0 "register_operand" "=!a,*r")
2371         (plus:SI (match_operand:SI 1 "register_operand" "r,r")
2372                  (high:SI (match_operand 2 "const_int_operand" ""))))]
2373   "reload_completed"
2374   "@
2375    addil L'%G2,%1
2376    ldil L'%G2,%0\;{addl|add,l} %0,%1,%0"
2377   [(set_attr "type" "binary,binary")
2378    (set_attr "length" "4,8")])
2379
2380 (define_insn ""
2381   [(set (match_operand:DI 0 "register_operand" "=!a,*r")
2382         (plus:DI (match_operand:DI 1 "register_operand" "r,r")
2383                  (high:DI (match_operand 2 "const_int_operand" ""))))]
2384   "reload_completed && TARGET_64BIT"
2385   "@
2386    addil L'%G2,%1
2387    ldil L'%G2,%0\;{addl|add,l} %0,%1,%0"
2388   [(set_attr "type" "binary,binary")
2389    (set_attr "length" "4,8")])
2390
2391 (define_insn ""
2392   [(set (match_operand:SI 0 "register_operand" "=r")
2393         (high:SI (match_operand 1 "" "")))]
2394   "(!flag_pic || !symbolic_operand (operands[1], Pmode))
2395     && !is_function_label_plus_const (operands[1])"
2396   "*
2397 {
2398   if (symbolic_operand (operands[1], Pmode))
2399     return \"ldil LR'%H1,%0\";
2400   else
2401     return \"ldil L'%G1,%0\";
2402 }"
2403   [(set_attr "type" "move")
2404    (set_attr "length" "4")])
2405
2406 (define_insn ""
2407   [(set (match_operand:DI 0 "register_operand" "=r")
2408         (high:DI (match_operand 1 "const_int_operand" "")))]
2409   "TARGET_64BIT"
2410   "ldil L'%G1,%0";
2411   [(set_attr "type" "move")
2412    (set_attr "length" "4")])
2413
2414 (define_insn ""
2415   [(set (match_operand:DI 0 "register_operand" "=r")
2416         (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
2417                    (match_operand:DI 2 "const_int_operand" "i")))]
2418   "TARGET_64BIT"
2419   "ldo R'%G2(%1),%0";
2420   [(set_attr "type" "move")
2421    (set_attr "length" "4")])
2422
2423 (define_insn ""
2424   [(set (match_operand:SI 0 "register_operand" "=r")
2425         (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
2426                    (match_operand:SI 2 "immediate_operand" "i")))]
2427   "!is_function_label_plus_const (operands[2])"
2428   "*
2429 {
2430   if (flag_pic && symbolic_operand (operands[2], Pmode))
2431     abort ();
2432   else if (symbolic_operand (operands[2], Pmode))
2433     return \"ldo RR'%G2(%1),%0\";
2434   else
2435     return \"ldo R'%G2(%1),%0\";
2436 }"
2437   [(set_attr "type" "move")
2438    (set_attr "length" "4")])
2439
2440 ;; Now that a symbolic_address plus a constant is broken up early
2441 ;; in the compilation phase (for better CSE) we need a special
2442 ;; combiner pattern to load the symbolic address plus the constant
2443 ;; in only 2 instructions. (For cases where the symbolic address
2444 ;; was not a common subexpression.)
2445 (define_split
2446   [(set (match_operand:SI 0 "register_operand" "")
2447         (match_operand:SI 1 "symbolic_operand" ""))
2448    (clobber (match_operand:SI 2 "register_operand" ""))]
2449   "! (flag_pic && pic_label_operand (operands[1], SImode))"
2450   [(set (match_dup 2) (high:SI (match_dup 1)))
2451    (set (match_dup 0) (lo_sum:SI (match_dup 2) (match_dup 1)))]
2452   "")
2453
2454 ;; hppa_legitimize_address goes to a great deal of trouble to
2455 ;; create addresses which use indexing.  In some cases, this
2456 ;; is a lose because there isn't any store instructions which
2457 ;; allow indexed addresses (with integer register source).
2458 ;;
2459 ;; These define_splits try to turn a 3 insn store into
2460 ;; a 2 insn store with some creative RTL rewriting.
2461 (define_split
2462   [(set (mem:SI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2463                                (match_operand:SI 1 "shadd_operand" ""))
2464                    (plus:SI (match_operand:SI 2 "register_operand" "")
2465                             (match_operand:SI 3 "const_int_operand" ""))))
2466         (match_operand:SI 4 "register_operand" ""))
2467    (clobber (match_operand:SI 5 "register_operand" ""))]
2468   ""
2469   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
2470                                (match_dup 2)))
2471    (set (mem:SI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2472   "")
2473
2474 (define_split
2475   [(set (mem:HI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2476                                (match_operand:SI 1 "shadd_operand" ""))
2477                    (plus:SI (match_operand:SI 2 "register_operand" "")
2478                             (match_operand:SI 3 "const_int_operand" ""))))
2479         (match_operand:HI 4 "register_operand" ""))
2480    (clobber (match_operand:SI 5 "register_operand" ""))]
2481   ""
2482   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
2483                                (match_dup 2)))
2484    (set (mem:HI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2485   "")
2486
2487 (define_split
2488   [(set (mem:QI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2489                                (match_operand:SI 1 "shadd_operand" ""))
2490                    (plus:SI (match_operand:SI 2 "register_operand" "")
2491                             (match_operand:SI 3 "const_int_operand" ""))))
2492         (match_operand:QI 4 "register_operand" ""))
2493    (clobber (match_operand:SI 5 "register_operand" ""))]
2494   ""
2495   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
2496                                (match_dup 2)))
2497    (set (mem:QI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2498   "")
2499
2500 (define_expand "movhi"
2501   [(set (match_operand:HI 0 "general_operand" "")
2502         (match_operand:HI 1 "general_operand" ""))]
2503   ""
2504   "
2505 {
2506   if (emit_move_sequence (operands, HImode, 0))
2507     DONE;
2508 }")
2509
2510 (define_insn ""
2511   [(set (match_operand:HI 0 "reg_or_nonsymb_mem_operand" "=r,r,r,r,r,Q,*q,!*f")
2512         (match_operand:HI 1 "move_operand" "r,J,N,K,RQ,rM,rM,!*fM"))]
2513   "register_operand (operands[0], HImode)
2514    || reg_or_0_operand (operands[1], HImode)"
2515   "@
2516    copy %1,%0
2517    ldi %1,%0
2518    ldil L'%1,%0
2519    {zdepi|depwi,z} %Z1,%0
2520    ldh%M1 %1,%0
2521    sth%M0 %r1,%0
2522    mtsar %r1
2523    fcpy,sgl %f1,%0"
2524   [(set_attr "type" "move,move,move,shift,load,store,move,fpalu")
2525    (set_attr "pa_combine_type" "addmove")
2526    (set_attr "length" "4,4,4,4,4,4,4,4")])
2527
2528 (define_insn ""
2529   [(set (match_operand:HI 0 "register_operand" "=r")
2530         (mem:HI (plus:SI (match_operand:SI 1 "basereg_operand" "r")
2531                          (match_operand:SI 2 "register_operand" "r"))))]
2532   "! TARGET_DISABLE_INDEXING"
2533   "{ldhx|ldh} %2(%1),%0"
2534   [(set_attr "type" "load")
2535    (set_attr "length" "4")])
2536
2537 (define_insn ""
2538   [(set (match_operand:HI 0 "register_operand" "=r")
2539         (mem:HI (plus:SI (match_operand:SI 1 "register_operand" "r")
2540                          (match_operand:SI 2 "basereg_operand" "r"))))]
2541   "! TARGET_DISABLE_INDEXING"
2542   "{ldhx|ldh} %1(%2),%0"
2543   [(set_attr "type" "load")
2544    (set_attr "length" "4")])
2545
2546 ; Now zero extended variants.
2547 (define_insn ""
2548   [(set (match_operand:SI 0 "register_operand" "=r")
2549         (zero_extend:SI (mem:HI
2550                           (plus:SI
2551                             (match_operand:SI 1 "basereg_operand" "r")
2552                             (match_operand:SI 2 "register_operand" "r")))))]
2553   "! TARGET_DISABLE_INDEXING"
2554   "{ldhx|ldh} %2(%1),%0"
2555   [(set_attr "type" "load")
2556    (set_attr "length" "4")])
2557
2558 (define_insn ""
2559   [(set (match_operand:SI 0 "register_operand" "=r")
2560         (zero_extend:SI (mem:HI
2561                           (plus:SI
2562                              (match_operand:SI 1 "register_operand" "r")
2563                              (match_operand:SI 2 "basereg_operand" "r")))))]
2564   "! TARGET_DISABLE_INDEXING"
2565   "{ldhx|ldh} %1(%2),%0"
2566   [(set_attr "type" "load")
2567    (set_attr "length" "4")])
2568
2569 (define_insn ""
2570   [(set (match_operand:HI 0 "register_operand" "=r")
2571         (mem:HI (plus:SI (match_operand:SI 1 "register_operand" "+r")
2572                          (match_operand:SI 2 "int5_operand" "L"))))
2573    (set (match_dup 1)
2574         (plus:SI (match_dup 1) (match_dup 2)))]
2575   ""
2576   "{ldhs|ldh},mb %2(%1),%0"
2577   [(set_attr "type" "load")
2578    (set_attr "length" "4")])
2579
2580 ; And a zero extended variant.
2581 (define_insn ""
2582   [(set (match_operand:SI 0 "register_operand" "=r")
2583         (zero_extend:SI (mem:HI
2584                           (plus:SI
2585                             (match_operand:SI 1 "register_operand" "+r")
2586                             (match_operand:SI 2 "int5_operand" "L")))))
2587    (set (match_dup 1)
2588         (plus:SI (match_dup 1) (match_dup 2)))]
2589   ""
2590   "{ldhs|ldh},mb %2(%1),%0"
2591   [(set_attr "type" "load")
2592    (set_attr "length" "4")])
2593
2594 (define_insn ""
2595   [(set (mem:HI (plus:SI (match_operand:SI 0 "register_operand" "+r")
2596                          (match_operand:SI 1 "int5_operand" "L")))
2597         (match_operand:HI 2 "reg_or_0_operand" "rM"))
2598    (set (match_dup 0)
2599         (plus:SI (match_dup 0) (match_dup 1)))]
2600   ""
2601   "{sths|sth},mb %r2,%1(%0)"
2602   [(set_attr "type" "store")
2603    (set_attr "length" "4")])
2604
2605 (define_insn ""
2606   [(set (match_operand:HI 0 "register_operand" "=r")
2607         (high:HI (match_operand 1 "const_int_operand" "")))]
2608   ""
2609   "ldil L'%G1,%0"
2610   [(set_attr "type" "move")
2611    (set_attr "length" "4")])
2612
2613 (define_insn ""
2614   [(set (match_operand:HI 0 "register_operand" "=r")
2615         (lo_sum:HI (match_operand:HI 1 "register_operand" "r")
2616                    (match_operand 2 "const_int_operand" "")))]
2617   ""
2618   "ldo R'%G2(%1),%0"
2619   [(set_attr "type" "move")
2620    (set_attr "length" "4")])
2621
2622 (define_expand "movqi"
2623   [(set (match_operand:QI 0 "general_operand" "")
2624         (match_operand:QI 1 "general_operand" ""))]
2625   ""
2626   "
2627 {
2628   if (emit_move_sequence (operands, QImode, 0))
2629     DONE;
2630 }")
2631
2632 (define_insn ""
2633   [(set (match_operand:QI 0 "reg_or_nonsymb_mem_operand" "=r,r,r,r,r,Q,*q,!*f")
2634         (match_operand:QI 1 "move_operand" "r,J,N,K,RQ,rM,rM,!*fM"))]
2635   "register_operand (operands[0], QImode)
2636    || reg_or_0_operand (operands[1], QImode)"
2637   "@
2638    copy %1,%0
2639    ldi %1,%0
2640    ldil L'%1,%0
2641    {zdepi|depwi,z} %Z1,%0
2642    ldb%M1 %1,%0
2643    stb%M0 %r1,%0
2644    mtsar %r1
2645    fcpy,sgl %f1,%0"
2646   [(set_attr "type" "move,move,move,shift,load,store,move,fpalu")
2647    (set_attr "pa_combine_type" "addmove")
2648    (set_attr "length" "4,4,4,4,4,4,4,4")])
2649
2650 (define_insn ""
2651   [(set (match_operand:QI 0 "register_operand" "=r")
2652         (mem:QI (plus:SI (match_operand:SI 1 "basereg_operand" "r")
2653                          (match_operand:SI 2 "register_operand" "r"))))]
2654   "! TARGET_DISABLE_INDEXING"
2655   "{ldbx|ldb} %2(%1),%0"
2656   [(set_attr "type" "load")
2657    (set_attr "length" "4")])
2658
2659 (define_insn ""
2660   [(set (match_operand:QI 0 "register_operand" "=r")
2661         (mem:QI (plus:SI (match_operand:SI 1 "register_operand" "r")
2662                          (match_operand:SI 2 "basereg_operand" "r"))))]
2663   "! TARGET_DISABLE_INDEXING"
2664   "{ldbx|ldb} %1(%2),%0"
2665   [(set_attr "type" "load")
2666    (set_attr "length" "4")])
2667
2668 ; Indexed byte load with zero extension to SImode or HImode.
2669 (define_insn ""
2670   [(set (match_operand:SI 0 "register_operand" "=r")
2671         (zero_extend:SI (mem:QI
2672                           (plus:SI
2673                             (match_operand:SI 1 "basereg_operand" "r")
2674                             (match_operand:SI 2 "register_operand" "r")))))]
2675   "! TARGET_DISABLE_INDEXING"
2676   "{ldbx|ldb} %2(%1),%0"
2677   [(set_attr "type" "load")
2678    (set_attr "length" "4")])
2679
2680 (define_insn ""
2681   [(set (match_operand:SI 0 "register_operand" "=r")
2682         (zero_extend:SI (mem:QI
2683                           (plus:SI
2684                             (match_operand:SI 1 "register_operand" "r")
2685                             (match_operand:SI 2 "basereg_operand" "r")))))]
2686   "! TARGET_DISABLE_INDEXING"
2687   "{ldbx|ldb} %1(%2),%0"
2688   [(set_attr "type" "load")
2689    (set_attr "length" "4")])
2690
2691 (define_insn ""
2692   [(set (match_operand:HI 0 "register_operand" "=r")
2693         (zero_extend:HI (mem:QI
2694                           (plus:SI
2695                             (match_operand:SI 1 "basereg_operand" "r")
2696                             (match_operand:SI 2 "register_operand" "r")))))]
2697   "! TARGET_DISABLE_INDEXING"
2698   "{ldbx|ldb} %2(%1),%0"
2699   [(set_attr "type" "load")
2700    (set_attr "length" "4")])
2701
2702 (define_insn ""
2703   [(set (match_operand:HI 0 "register_operand" "=r")
2704         (zero_extend:HI (mem:QI
2705                           (plus:SI
2706                             (match_operand:SI 1 "register_operand" "r")
2707                             (match_operand:SI 2 "basereg_operand" "r")))))]
2708   "! TARGET_DISABLE_INDEXING"
2709   "{ldbx|ldb} %1(%2),%0"
2710   [(set_attr "type" "load")
2711    (set_attr "length" "4")])
2712
2713 (define_insn ""
2714   [(set (match_operand:QI 0 "register_operand" "=r")
2715         (mem:QI (plus:SI (match_operand:SI 1 "register_operand" "+r")
2716                          (match_operand:SI 2 "int5_operand" "L"))))
2717    (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
2718   ""
2719   "{ldbs|ldb},mb %2(%1),%0"
2720   [(set_attr "type" "load")
2721    (set_attr "length" "4")])
2722
2723 ; Now the same thing with zero extensions.
2724 (define_insn ""
2725   [(set (match_operand:SI 0 "register_operand" "=r")
2726         (zero_extend:SI (mem:QI (plus:SI
2727                                   (match_operand:SI 1 "register_operand" "+r")
2728                                   (match_operand:SI 2 "int5_operand" "L")))))
2729    (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
2730   ""
2731   "{ldbs|ldb},mb %2(%1),%0"
2732   [(set_attr "type" "load")
2733    (set_attr "length" "4")])
2734
2735 (define_insn ""
2736   [(set (match_operand:HI 0 "register_operand" "=r")
2737         (zero_extend:HI (mem:QI (plus:SI
2738                                   (match_operand:SI 1 "register_operand" "+r")
2739                                   (match_operand:SI 2 "int5_operand" "L")))))
2740    (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
2741   ""
2742   "{ldbs|ldb},mb %2(%1),%0"
2743   [(set_attr "type" "load")
2744    (set_attr "length" "4")])
2745
2746 (define_insn ""
2747   [(set (mem:QI (plus:SI (match_operand:SI 0 "register_operand" "+r")
2748                          (match_operand:SI 1 "int5_operand" "L")))
2749         (match_operand:QI 2 "reg_or_0_operand" "rM"))
2750    (set (match_dup 0)
2751         (plus:SI (match_dup 0) (match_dup 1)))]
2752   ""
2753   "{stbs|stb},mb %r2,%1(%0)"
2754   [(set_attr "type" "store")
2755    (set_attr "length" "4")])
2756
2757 ;; The definition of this insn does not really explain what it does,
2758 ;; but it should suffice
2759 ;; that anything generated as this insn will be recognized as one
2760 ;; and that it will not successfully combine with anything.
2761 (define_expand "movstrsi"
2762   [(parallel [(set (match_operand:BLK 0 "" "")
2763                    (match_operand:BLK 1 "" ""))
2764               (clobber (match_dup 7))
2765               (clobber (match_dup 8))
2766               (clobber (match_dup 4))
2767               (clobber (match_dup 5))
2768               (clobber (match_dup 6))
2769               (use (match_operand:SI 2 "arith_operand" ""))
2770               (use (match_operand:SI 3 "const_int_operand" ""))])]
2771   "!TARGET_64BIT"
2772   "
2773 {
2774   int size, align;
2775
2776   /* HP provides very fast block move library routine for the PA;
2777      this routine includes:
2778
2779         4x4 byte at a time block moves,
2780         1x4 byte at a time with alignment checked at runtime with
2781             attempts to align the source and destination as needed
2782         1x1 byte loop
2783
2784      With that in mind, here's the heuristics to try and guess when
2785      the inlined block move will be better than the library block
2786      move:
2787
2788         If the size isn't constant, then always use the library routines.
2789
2790         If the size is large in respect to the known alignment, then use
2791         the library routines.
2792
2793         If the size is small in repsect to the known alignment, then open
2794         code the copy (since that will lead to better scheduling).
2795
2796         Else use the block move pattern.   */
2797
2798   /* Undetermined size, use the library routine.  */
2799   if (GET_CODE (operands[2]) != CONST_INT)
2800     FAIL;
2801
2802   size = INTVAL (operands[2]);
2803   align = INTVAL (operands[3]);
2804   align = align > 4 ? 4 : align;
2805
2806   /* If size/alignment > 8 (eg size is large in respect to alignment),
2807      then use the library routines.  */
2808   if (size / align > 16)
2809     FAIL;
2810
2811   /* This does happen, but not often enough to worry much about.  */
2812   if (size / align < MOVE_RATIO)
2813     FAIL;
2814   
2815   /* Fall through means we're going to use our block move pattern.  */
2816   operands[0]
2817     = change_address (operands[0], VOIDmode,
2818                       copy_to_mode_reg (SImode, XEXP (operands[0], 0)));
2819   operands[1]
2820     = change_address (operands[1], VOIDmode,
2821                       copy_to_mode_reg (SImode, XEXP (operands[1], 0)));
2822   operands[4] = gen_reg_rtx (SImode);
2823   operands[5] = gen_reg_rtx (SImode);
2824   operands[6] = gen_reg_rtx (SImode);
2825   operands[7] = XEXP (operands[0], 0);
2826   operands[8] = XEXP (operands[1], 0);
2827 }")
2828
2829 ;; The operand constraints are written like this to support both compile-time
2830 ;; and run-time determined byte count.  If the count is run-time determined,
2831 ;; the register with the byte count is clobbered by the copying code, and
2832 ;; therefore it is forced to operand 2.  If the count is compile-time
2833 ;; determined, we need two scratch registers for the unrolled code.
2834 (define_insn "movstrsi_internal"
2835   [(set (mem:BLK (match_operand:SI 0 "register_operand" "+r,r"))
2836         (mem:BLK (match_operand:SI 1 "register_operand" "+r,r")))
2837    (clobber (match_dup 0))
2838    (clobber (match_dup 1))
2839    (clobber (match_operand:SI 2 "register_operand" "=r,r"))     ;loop cnt/tmp
2840    (clobber (match_operand:SI 3 "register_operand" "=&r,&r"))   ;item tmp
2841    (clobber (match_operand:SI 6 "register_operand" "=&r,&r"))   ;item tmp2
2842    (use (match_operand:SI 4 "arith_operand" "J,2"))      ;byte count
2843    (use (match_operand:SI 5 "const_int_operand" "n,n"))] ;alignment
2844   "!TARGET_64BIT"
2845   "* return output_block_move (operands, !which_alternative);"
2846   [(set_attr "type" "multi,multi")])
2847 \f
2848 ;; Floating point move insns
2849
2850 ;; This pattern forces (set (reg:DF ...) (const_double ...))
2851 ;; to be reloaded by putting the constant into memory when
2852 ;; reg is a floating point register.
2853 ;;
2854 ;; For integer registers we use ldil;ldo to set the appropriate
2855 ;; value.
2856 ;;
2857 ;; This must come before the movdf pattern, and it must be present
2858 ;; to handle obscure reloading cases.
2859 (define_insn ""
2860   [(set (match_operand:DF 0 "register_operand" "=?r,f")
2861         (match_operand:DF 1 "" "?F,m"))]
2862   "GET_CODE (operands[1]) == CONST_DOUBLE
2863    && operands[1] != CONST0_RTX (DFmode)
2864    && !TARGET_64BIT
2865    && ! TARGET_SOFT_FLOAT"
2866   "* return (which_alternative == 0 ? output_move_double (operands)
2867                                     : \"fldd%F1 %1,%0\");"
2868   [(set_attr "type" "move,fpload")
2869    (set_attr "length" "16,4")])
2870
2871 (define_expand "movdf"
2872   [(set (match_operand:DF 0 "general_operand" "")
2873         (match_operand:DF 1 "general_operand" ""))]
2874   ""
2875   "
2876 {
2877   if (GET_CODE (operands[1]) == CONST_DOUBLE && TARGET_64BIT)
2878       operands[1] = force_const_mem (DFmode, operands[1]);
2879
2880   if (emit_move_sequence (operands, DFmode, 0))
2881     DONE;
2882 }")
2883
2884 ;; Reloading an SImode or DImode value requires a scratch register if
2885 ;; going in to or out of float point registers.
2886
2887 (define_expand "reload_indf"
2888   [(set (match_operand:DF 0 "register_operand" "=Z")
2889         (match_operand:DF 1 "non_hard_reg_operand" ""))
2890    (clobber (match_operand:DF 2 "register_operand" "=&r"))]
2891   ""
2892   "
2893 {
2894   if (emit_move_sequence (operands, DFmode, operands[2]))
2895     DONE;
2896
2897   /* We don't want the clobber emitted, so handle this ourselves.  */
2898   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
2899   DONE;
2900 }")
2901
2902 (define_expand "reload_outdf" 
2903  [(set (match_operand:DF 0 "non_hard_reg_operand" "")
2904         (match_operand:DF 1  "register_operand" "Z"))
2905    (clobber (match_operand:DF 2 "register_operand" "=&r"))]
2906   ""
2907   "
2908 {
2909   if (emit_move_sequence (operands, DFmode, operands[2]))
2910     DONE;
2911
2912   /* We don't want the clobber emitted, so handle this ourselves.  */
2913   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
2914   DONE;
2915 }")
2916
2917 (define_insn ""
2918   [(set (match_operand:DF 0 "reg_or_nonsymb_mem_operand"
2919                           "=f,*r,RQ,?o,?Q,f,*r,*r")
2920         (match_operand:DF 1 "reg_or_0_or_nonsymb_mem_operand"
2921                           "fG,*rG,f,*r,*r,RQ,o,RQ"))]
2922   "(register_operand (operands[0], DFmode)
2923     || reg_or_0_operand (operands[1], DFmode))
2924    && ! (GET_CODE (operands[1]) == CONST_DOUBLE
2925          && GET_CODE (operands[0]) == MEM)
2926    && ! TARGET_64BIT
2927    && ! TARGET_SOFT_FLOAT"
2928   "*
2929 {
2930   if (FP_REG_P (operands[0]) || FP_REG_P (operands[1])
2931       || operands[1] == CONST0_RTX (DFmode))
2932     return output_fp_move_double (operands);
2933   return output_move_double (operands);
2934 }"
2935   [(set_attr "type" "fpalu,move,fpstore,store,store,fpload,load,load")
2936    (set_attr "length" "4,8,4,8,16,4,8,16")])
2937
2938 (define_insn ""
2939   [(set (match_operand:DF 0 "reg_or_nonsymb_mem_operand"
2940                           "=r,?o,?Q,r,r")
2941         (match_operand:DF 1 "reg_or_0_or_nonsymb_mem_operand"
2942                           "rG,r,r,o,Q"))]
2943   "(register_operand (operands[0], DFmode)
2944     || reg_or_0_operand (operands[1], DFmode))
2945    && ! TARGET_64BIT
2946    && TARGET_SOFT_FLOAT"
2947   "*
2948 {
2949   return output_move_double (operands);
2950 }"
2951   [(set_attr "type" "move,store,store,load,load")
2952    (set_attr "length" "8,8,16,8,16")])
2953
2954 (define_insn ""
2955   [(set (match_operand:DF 0 "reg_or_nonsymb_mem_operand"
2956                                 "=r,r,r,r,r,Q,*q,!f,f,*TR")
2957         (match_operand:DF 1 "move_operand"
2958                                 "r,J,N,K,RQ,rM,rM,!fM,*RT,f"))]
2959   "(register_operand (operands[0], DFmode)
2960     || reg_or_0_operand (operands[1], DFmode))
2961    && ! TARGET_SOFT_FLOAT && TARGET_64BIT"
2962   "@
2963    copy %1,%0
2964    ldi %1,%0
2965    ldil L'%1,%0
2966    depdi,z %z1,%0
2967    ldd%M1 %1,%0
2968    std%M0 %r1,%0
2969    mtsar %r1
2970    fcpy,dbl %f1,%0
2971    fldd%F1 %1,%0
2972    fstd%F0 %1,%0"
2973   [(set_attr "type" "move,move,move,shift,load,store,move,fpalu,fpload,fpstore")
2974    (set_attr "pa_combine_type" "addmove")
2975    (set_attr "length" "4,4,4,4,4,4,4,4,4,4")])
2976
2977 (define_insn ""
2978   [(set (match_operand:DF 0 "register_operand" "=fx")
2979         (mem:DF (plus:SI (match_operand:SI 1 "basereg_operand" "r")
2980                          (match_operand:SI 2 "register_operand" "r"))))]
2981   "! TARGET_DISABLE_INDEXING && ! TARGET_SOFT_FLOAT"
2982   "{flddx|fldd} %2(%1),%0"
2983   [(set_attr "type" "fpload")
2984    (set_attr "length" "4")])
2985
2986 (define_insn ""
2987   [(set (match_operand:DF 0 "register_operand" "=fx")
2988         (mem:DF (plus:SI (match_operand:SI 1 "register_operand" "r")
2989                          (match_operand:SI 2 "basereg_operand" "r"))))]
2990   "! TARGET_DISABLE_INDEXING && ! TARGET_SOFT_FLOAT"
2991   "{flddx|fldd} %1(%2),%0"
2992   [(set_attr "type" "fpload")
2993    (set_attr "length" "4")])
2994
2995 (define_insn ""
2996   [(set (mem:DF (plus:SI (match_operand:SI 1 "basereg_operand" "r")
2997                          (match_operand:SI 2 "register_operand" "r")))
2998         (match_operand:DF 0 "register_operand" "fx"))]
2999   "! TARGET_DISABLE_INDEXING && ! TARGET_SOFT_FLOAT"
3000   "{fstdx|fstd} %0,%2(%1)"
3001   [(set_attr "type" "fpstore")
3002    (set_attr "length" "4")])
3003
3004 (define_insn ""
3005   [(set (mem:DF (plus:SI (match_operand:SI 1 "register_operand" "r")
3006                          (match_operand:SI 2 "basereg_operand" "r")))
3007         (match_operand:DF 0 "register_operand" "fx"))]
3008   "! TARGET_DISABLE_INDEXING && ! TARGET_SOFT_FLOAT"
3009   "{fstdx|fstd} %0,%1(%2)"
3010   [(set_attr "type" "fpstore")
3011    (set_attr "length" "4")])
3012
3013 (define_expand "movdi"
3014   [(set (match_operand:DI 0 "reg_or_nonsymb_mem_operand" "")
3015         (match_operand:DI 1 "general_operand" ""))]
3016   ""
3017   "
3018 {
3019   if (GET_CODE (operands[1]) == CONST_DOUBLE && TARGET_64BIT)
3020       operands[1] = force_const_mem (DImode, operands[1]);
3021
3022   if (emit_move_sequence (operands, DImode, 0))
3023     DONE;
3024 }")
3025
3026 (define_expand "reload_indi"
3027   [(set (match_operand:DI 0 "register_operand" "=Z")
3028         (match_operand:DI 1 "non_hard_reg_operand" ""))
3029    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
3030   ""
3031   "
3032 {
3033   if (emit_move_sequence (operands, DImode, operands[2]))
3034     DONE;
3035
3036   /* We don't want the clobber emitted, so handle this ourselves.  */
3037   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
3038   DONE;
3039 }")
3040
3041 (define_expand "reload_outdi"
3042   [(set (match_operand:DI 0 "general_operand" "")
3043         (match_operand:DI 1 "register_operand" "Z"))
3044    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
3045   ""
3046   "
3047 {
3048   if (emit_move_sequence (operands, DImode, operands[2]))
3049     DONE;
3050
3051   /* We don't want the clobber emitted, so handle this ourselves.  */
3052   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
3053   DONE;
3054 }")
3055
3056 (define_insn ""
3057   [(set (match_operand:DI 0 "register_operand" "=r")
3058         (high:DI (match_operand 1 "" "")))]
3059   "!TARGET_64BIT"
3060   "*
3061 {
3062   rtx op0 = operands[0];
3063   rtx op1 = operands[1];
3064
3065   if (GET_CODE (op1) == CONST_INT)
3066     {
3067       operands[0] = operand_subword (op0, 1, 0, DImode);
3068       output_asm_insn (\"ldil L'%1,%0\", operands);
3069
3070       operands[0] = operand_subword (op0, 0, 0, DImode);
3071       if (INTVAL (op1) < 0)
3072         output_asm_insn (\"ldi -1,%0\", operands);
3073       else
3074         output_asm_insn (\"ldi 0,%0\", operands);
3075       return \"\";
3076     }
3077   else if (GET_CODE (op1) == CONST_DOUBLE)
3078     {
3079       operands[0] = operand_subword (op0, 1, 0, DImode);
3080       operands[1] = GEN_INT (CONST_DOUBLE_LOW (op1));
3081       output_asm_insn (\"ldil L'%1,%0\", operands);
3082
3083       operands[0] = operand_subword (op0, 0, 0, DImode);
3084       operands[1] = GEN_INT (CONST_DOUBLE_HIGH (op1));
3085       output_asm_insn (singlemove_string (operands), operands);
3086       return \"\";
3087     }
3088   else
3089     abort ();
3090 }"
3091   [(set_attr "type" "move")
3092    (set_attr "length" "8")])
3093
3094 (define_insn ""
3095   [(set (match_operand:DI 0 "reg_or_nonsymb_mem_operand"
3096                           "=r,o,Q,r,r,r,f,f,*TR")
3097         (match_operand:DI 1 "general_operand"
3098                           "rM,r,r,o*R,Q,i,fM,*TR,f"))]
3099   "(register_operand (operands[0], DImode)
3100     || reg_or_0_operand (operands[1], DImode))
3101    && ! TARGET_64BIT
3102    && ! TARGET_SOFT_FLOAT"
3103   "*
3104 {
3105   if (FP_REG_P (operands[0]) || FP_REG_P (operands[1])
3106       || (operands[1] == CONST0_RTX (DImode)))
3107     return output_fp_move_double (operands);
3108   return output_move_double (operands);
3109 }"
3110   [(set_attr "type" "move,store,store,load,load,multi,fpalu,fpload,fpstore")
3111    (set_attr "length" "8,8,16,8,16,16,4,4,4")])
3112
3113 (define_insn ""
3114   [(set (match_operand:DI 0 "reg_or_nonsymb_mem_operand"
3115                                 "=r,r,r,r,r,r,Q,*q,!f,f,*TR")
3116         (match_operand:DI 1 "move_operand"
3117                                 "A,r,J,N,K,RQ,rM,rM,!fM,*RT,f"))]
3118   "(register_operand (operands[0], DImode)
3119     || reg_or_0_operand (operands[1], DImode))
3120    && ! TARGET_SOFT_FLOAT && TARGET_64BIT"
3121   "@
3122    ldd RT'%A1,%0
3123    copy %1,%0
3124    ldi %1,%0
3125    ldil L'%1,%0
3126    depdi,z %z1,%0
3127    ldd%M1 %1,%0
3128    std%M0 %r1,%0
3129    mtsar %r1
3130    fcpy,dbl %f1,%0
3131    fldd%F1 %1,%0
3132    fstd%F0 %1,%0"
3133   [(set_attr "type" "load,move,move,move,shift,load,store,move,fpalu,fpload,fpstore")
3134    (set_attr "pa_combine_type" "addmove")
3135    (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4")])
3136
3137 (define_insn ""
3138   [(set (match_operand:DI 0 "reg_or_nonsymb_mem_operand"
3139                           "=r,o,Q,r,r,r")
3140         (match_operand:DI 1 "general_operand"
3141                           "rM,r,r,o,Q,i"))]
3142   "(register_operand (operands[0], DImode)
3143     || reg_or_0_operand (operands[1], DImode))
3144    && ! TARGET_64BIT
3145    && TARGET_SOFT_FLOAT"
3146   "*
3147 {
3148   return output_move_double (operands);
3149 }"
3150   [(set_attr "type" "move,store,store,load,load,multi")
3151    (set_attr "length" "8,8,16,8,16,16")])
3152
3153 (define_insn ""
3154   [(set (match_operand:DI 0 "register_operand" "=r,&r")
3155         (lo_sum:DI (match_operand:DI 1 "register_operand" "0,r")
3156                    (match_operand:DI 2 "immediate_operand" "i,i")))]
3157   "!TARGET_64BIT"
3158   "*
3159 {
3160   /* Don't output a 64 bit constant, since we can't trust the assembler to
3161      handle it correctly.  */
3162   if (GET_CODE (operands[2]) == CONST_DOUBLE)
3163     operands[2] = GEN_INT (CONST_DOUBLE_LOW (operands[2]));
3164   if (which_alternative == 1)
3165     output_asm_insn (\"copy %1,%0\", operands);
3166   return \"ldo R'%G2(%R1),%R0\";
3167 }"
3168   [(set_attr "type" "move,move")
3169    (set_attr "length" "4,8")])
3170
3171 ;; This pattern forces (set (reg:SF ...) (const_double ...))
3172 ;; to be reloaded by putting the constant into memory when
3173 ;; reg is a floating point register.
3174 ;;
3175 ;; For integer registers we use ldil;ldo to set the appropriate
3176 ;; value.
3177 ;;
3178 ;; This must come before the movsf pattern, and it must be present
3179 ;; to handle obscure reloading cases.
3180 (define_insn ""
3181   [(set (match_operand:SF 0 "register_operand" "=?r,f")
3182         (match_operand:SF 1 "" "?F,m"))]
3183   "GET_CODE (operands[1]) == CONST_DOUBLE
3184    && operands[1] != CONST0_RTX (SFmode)
3185    && ! TARGET_SOFT_FLOAT"
3186   "* return (which_alternative == 0 ? singlemove_string (operands)
3187                                     : \" fldw%F1 %1,%0\");"
3188   [(set_attr "type" "move,fpload")
3189    (set_attr "length" "8,4")])
3190
3191 (define_expand "movsf"
3192   [(set (match_operand:SF 0 "general_operand" "")
3193         (match_operand:SF 1 "general_operand" ""))]
3194   ""
3195   "
3196 {
3197   if (emit_move_sequence (operands, SFmode, 0))
3198     DONE;
3199 }")
3200
3201 ;; Reloading an SImode or DImode value requires a scratch register if
3202 ;; going in to or out of float point registers.
3203
3204 (define_expand "reload_insf"
3205   [(set (match_operand:SF 0 "register_operand" "=Z")
3206         (match_operand:SF 1 "non_hard_reg_operand" ""))
3207    (clobber (match_operand:SF 2 "register_operand" "=&r"))]
3208   ""
3209   "
3210 {
3211   if (emit_move_sequence (operands, SFmode, operands[2]))
3212     DONE;
3213
3214   /* We don't want the clobber emitted, so handle this ourselves.  */
3215   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
3216   DONE;
3217 }")
3218
3219 (define_expand "reload_outsf"
3220   [(set (match_operand:SF 0 "non_hard_reg_operand" "")
3221         (match_operand:SF 1  "register_operand" "Z"))
3222    (clobber (match_operand:SF 2 "register_operand" "=&r"))]
3223   ""
3224   "
3225 {
3226   if (emit_move_sequence (operands, SFmode, operands[2]))
3227     DONE;
3228
3229   /* We don't want the clobber emitted, so handle this ourselves.  */
3230   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
3231   DONE;
3232 }")
3233
3234 (define_insn ""
3235   [(set (match_operand:SF 0 "reg_or_nonsymb_mem_operand"
3236                           "=f,r,f,r,RQ,Q")
3237         (match_operand:SF 1 "reg_or_0_or_nonsymb_mem_operand"
3238                           "fG,rG,RQ,RQ,f,rG"))]
3239   "(register_operand (operands[0], SFmode)
3240     || reg_or_0_operand (operands[1], SFmode))
3241    && ! TARGET_SOFT_FLOAT"
3242   "@
3243    fcpy,sgl %f1,%0
3244    copy %r1,%0
3245    fldw%F1 %1,%0
3246    ldw%M1 %1,%0
3247    fstw%F0 %r1,%0
3248    stw%M0 %r1,%0"
3249   [(set_attr "type" "fpalu,move,fpload,load,fpstore,store")
3250    (set_attr "pa_combine_type" "addmove")
3251    (set_attr "length" "4,4,4,4,4,4")])
3252
3253 (define_insn ""
3254   [(set (match_operand:SF 0 "reg_or_nonsymb_mem_operand"
3255                           "=r,r,Q")
3256         (match_operand:SF 1 "reg_or_0_or_nonsymb_mem_operand"
3257                           "rG,RQ,rG"))]
3258   "(register_operand (operands[0], SFmode)
3259     || reg_or_0_operand (operands[1], SFmode))
3260    && TARGET_SOFT_FLOAT"
3261   "@
3262    copy %r1,%0
3263    ldw%M1 %1,%0
3264    stw%M0 %r1,%0"
3265   [(set_attr "type" "move,load,store")
3266    (set_attr "pa_combine_type" "addmove")
3267    (set_attr "length" "4,4,4")])
3268
3269 (define_insn ""
3270   [(set (match_operand:SF 0 "register_operand" "=fx")
3271         (mem:SF (plus:SI (match_operand:SI 1 "basereg_operand" "r")
3272                          (match_operand:SI 2 "register_operand" "r"))))]
3273   "! TARGET_DISABLE_INDEXING && ! TARGET_SOFT_FLOAT"
3274   "{fldwx|fldw} %2(%1),%0"
3275   [(set_attr "type" "fpload")
3276    (set_attr "length" "4")])
3277
3278 (define_insn ""
3279   [(set (match_operand:SF 0 "register_operand" "=fx")
3280         (mem:SF (plus:SI (match_operand:SI 1 "register_operand" "r")
3281                          (match_operand:SI 2 "basereg_operand" "r"))))]
3282   "! TARGET_DISABLE_INDEXING && ! TARGET_SOFT_FLOAT"
3283   "{fldwx|fldw} %1(%2),%0"
3284   [(set_attr "type" "fpload")
3285    (set_attr "length" "4")])
3286
3287 (define_insn ""
3288   [(set (mem:SF (plus:SI (match_operand:SI 1 "basereg_operand" "r")
3289                          (match_operand:SI 2 "register_operand" "r")))
3290       (match_operand:SF 0 "register_operand" "fx"))]
3291   "! TARGET_DISABLE_INDEXING && ! TARGET_SOFT_FLOAT"
3292   "{fstwx|fstw} %0,%2(%1)"
3293   [(set_attr "type" "fpstore")
3294    (set_attr "length" "4")])
3295 \f
3296 (define_insn ""
3297   [(set (mem:SF (plus:SI (match_operand:SI 1 "register_operand" "r")
3298                          (match_operand:SI 2 "basereg_operand" "r")))
3299       (match_operand:SF 0 "register_operand" "fx"))]
3300   "! TARGET_DISABLE_INDEXING && ! TARGET_SOFT_FLOAT"
3301   "{fstwx|fstw} %0,%1(%2)"
3302   [(set_attr "type" "fpstore")
3303    (set_attr "length" "4")])
3304 \f
3305
3306 ;;- zero extension instructions
3307 ;; We have define_expand for zero extension patterns to make sure the
3308 ;; operands get loaded into registers.  The define_insns accept
3309 ;; memory operands.  This gives us better overall code than just
3310 ;; having a pattern that does or does not accept memory operands.
3311
3312 (define_expand "zero_extendhisi2"
3313   [(set (match_operand:SI 0 "register_operand" "")
3314         (zero_extend:SI
3315          (match_operand:HI 1 "register_operand" "")))]
3316   ""
3317   "")
3318
3319 (define_insn ""
3320   [(set (match_operand:SI 0 "register_operand" "=r,r")
3321         (zero_extend:SI
3322          (match_operand:HI 1 "move_operand" "r,RQ")))]
3323   "GET_CODE (operands[1]) != CONST_INT"
3324   "@
3325    {extru|extrw,u} %1,31,16,%0
3326    ldh%M1 %1,%0"
3327   [(set_attr "type" "shift,load")
3328    (set_attr "length" "4,4")])
3329
3330 (define_expand "zero_extendqihi2"
3331   [(set (match_operand:HI 0 "register_operand" "")
3332         (zero_extend:HI
3333          (match_operand:QI 1 "register_operand" "")))]
3334   ""
3335   "")
3336
3337 (define_insn ""
3338   [(set (match_operand:HI 0 "register_operand" "=r,r")
3339         (zero_extend:HI
3340          (match_operand:QI 1 "move_operand" "r,RQ")))]
3341   "GET_CODE (operands[1]) != CONST_INT"
3342   "@
3343    {extru|extrw,u} %1,31,8,%0
3344    ldb%M1 %1,%0"
3345   [(set_attr "type" "shift,load")
3346    (set_attr "length" "4,4")])
3347
3348 (define_expand "zero_extendqisi2"
3349   [(set (match_operand:SI 0 "register_operand" "")
3350         (zero_extend:SI
3351          (match_operand:QI 1 "register_operand" "")))]
3352   ""
3353   "")
3354
3355 (define_insn ""
3356   [(set (match_operand:SI 0 "register_operand" "=r,r")
3357         (zero_extend:SI
3358          (match_operand:QI 1 "move_operand" "r,RQ")))]
3359   "GET_CODE (operands[1]) != CONST_INT"
3360   "@
3361    {extru|extrw,u} %1,31,8,%0
3362    ldb%M1 %1,%0"
3363   [(set_attr "type" "shift,load")
3364    (set_attr "length" "4,4")])
3365
3366 (define_insn "zero_extendqidi2"
3367   [(set (match_operand:DI 0 "register_operand" "=r")
3368         (zero_extend:DI (match_operand:QI 1 "register_operand" "r")))]
3369   "TARGET_64BIT"
3370   "extrd,u %1,63,8,%0"
3371   [(set_attr "type" "shift") 
3372   (set_attr "length" "4")])
3373
3374 (define_insn "zero_extendhidi2"
3375   [(set (match_operand:DI 0 "register_operand" "=r")
3376         (zero_extend:DI (match_operand:HI 1 "register_operand" "r")))]
3377   "TARGET_64BIT"
3378   "extrd,u %1,63,16,%0"
3379   [(set_attr "type" "shift") 
3380   (set_attr "length" "4")])
3381
3382 (define_insn "zero_extendsidi2"
3383   [(set (match_operand:DI 0 "register_operand" "=r")
3384         (zero_extend:DI (match_operand:SI 1 "register_operand" "r")))]
3385   "TARGET_64BIT"
3386   "extrd,u %1,63,32,%0"
3387   [(set_attr "type" "shift") 
3388   (set_attr "length" "4")])
3389
3390 ;;- sign extension instructions
3391
3392 (define_insn "extendhisi2"
3393   [(set (match_operand:SI 0 "register_operand" "=r")
3394         (sign_extend:SI (match_operand:HI 1 "register_operand" "r")))]
3395   ""
3396   "{extrs|extrw,s} %1,31,16,%0"
3397   [(set_attr "type" "shift")
3398    (set_attr "length" "4")])
3399
3400 (define_insn "extendqihi2"
3401   [(set (match_operand:HI 0 "register_operand" "=r")
3402         (sign_extend:HI (match_operand:QI 1 "register_operand" "r")))]
3403   ""
3404   "{extrs|extrw,s} %1,31,8,%0"
3405   [(set_attr "type" "shift") 
3406   (set_attr "length" "4")])
3407
3408 (define_insn "extendqisi2"
3409   [(set (match_operand:SI 0 "register_operand" "=r")
3410         (sign_extend:SI (match_operand:QI 1 "register_operand" "r")))]
3411   ""
3412   "{extrs|extrw,s} %1,31,8,%0"
3413   [(set_attr "type" "shift")
3414    (set_attr "length" "4")])
3415
3416 (define_insn "extendqidi2"
3417   [(set (match_operand:DI 0 "register_operand" "=r")
3418         (sign_extend:DI (match_operand:QI 1 "register_operand" "r")))]
3419   "TARGET_64BIT"
3420   "extrd,s %1,63,8,%0"
3421   [(set_attr "type" "shift") 
3422   (set_attr "length" "4")])
3423
3424 (define_insn "extendhidi2"
3425   [(set (match_operand:DI 0 "register_operand" "=r")
3426         (sign_extend:DI (match_operand:HI 1 "register_operand" "r")))]
3427   "TARGET_64BIT"
3428   "extrd,s %1,63,16,%0"
3429   [(set_attr "type" "shift") 
3430   (set_attr "length" "4")])
3431
3432 (define_insn "extendsidi2"
3433   [(set (match_operand:DI 0 "register_operand" "=r")
3434         (sign_extend:DI (match_operand:SI 1 "register_operand" "r")))]
3435   "TARGET_64BIT"
3436   "extrd,s %1,63,32,%0"
3437   [(set_attr "type" "shift") 
3438   (set_attr "length" "4")])
3439
3440 \f
3441 ;; Conversions between float and double.
3442
3443 (define_insn "extendsfdf2"
3444   [(set (match_operand:DF 0 "register_operand" "=f")
3445         (float_extend:DF
3446          (match_operand:SF 1 "register_operand" "f")))]
3447   "! TARGET_SOFT_FLOAT"
3448   "{fcnvff|fcnv},sgl,dbl %1,%0"
3449   [(set_attr "type" "fpalu")
3450    (set_attr "length" "4")])
3451
3452 (define_insn "truncdfsf2"
3453   [(set (match_operand:SF 0 "register_operand" "=f")
3454         (float_truncate:SF
3455          (match_operand:DF 1 "register_operand" "f")))]
3456   "! TARGET_SOFT_FLOAT"
3457   "{fcnvff|fcnv},dbl,sgl %1,%0"
3458   [(set_attr "type" "fpalu")
3459    (set_attr "length" "4")])
3460
3461 ;; Conversion between fixed point and floating point.
3462 ;; Note that among the fix-to-float insns
3463 ;; the ones that start with SImode come first.
3464 ;; That is so that an operand that is a CONST_INT
3465 ;; (and therefore lacks a specific machine mode).
3466 ;; will be recognized as SImode (which is always valid)
3467 ;; rather than as QImode or HImode.
3468
3469 ;; This pattern forces (set (reg:SF ...) (float:SF (const_int ...)))
3470 ;; to be reloaded by putting the constant into memory.
3471 ;; It must come before the more general floatsisf2 pattern.
3472 (define_insn ""
3473   [(set (match_operand:SF 0 "register_operand" "=f")
3474         (float:SF (match_operand:SI 1 "const_int_operand" "m")))]
3475   "! TARGET_SOFT_FLOAT"
3476   "fldw%F1 %1,%0\;{fcnvxf,sgl,sgl|fcnv,w,sgl} %0,%0"
3477   [(set_attr "type" "fpalu")
3478    (set_attr "length" "8")])
3479
3480 (define_insn "floatsisf2"
3481   [(set (match_operand:SF 0 "register_operand" "=f")
3482         (float:SF (match_operand:SI 1 "register_operand" "f")))]
3483   "! TARGET_SOFT_FLOAT"
3484   "{fcnvxf,sgl,sgl|fcnv,w,sgl} %1,%0"
3485   [(set_attr "type" "fpalu")
3486    (set_attr "length" "4")])
3487
3488 ;; This pattern forces (set (reg:DF ...) (float:DF (const_int ...)))
3489 ;; to be reloaded by putting the constant into memory.
3490 ;; It must come before the more general floatsidf2 pattern.
3491 (define_insn ""
3492   [(set (match_operand:DF 0 "register_operand" "=f")
3493         (float:DF (match_operand:SI 1 "const_int_operand" "m")))]
3494   "! TARGET_SOFT_FLOAT"
3495   "fldw%F1 %1,%0\;{fcnvxf,sgl,dbl|fcnv,w,dbl} %0,%0"
3496   [(set_attr "type" "fpalu")
3497    (set_attr "length" "8")])
3498
3499 (define_insn "floatsidf2"
3500   [(set (match_operand:DF 0 "register_operand" "=f")
3501         (float:DF (match_operand:SI 1 "register_operand" "f")))]
3502   "! TARGET_SOFT_FLOAT"
3503   "{fcnvxf,sgl,dbl|fcnv,w,dbl} %1,%0"
3504   [(set_attr "type" "fpalu")
3505    (set_attr "length" "4")])
3506
3507 (define_expand "floatunssisf2"
3508   [(set (subreg:SI (match_dup 2) 1)
3509         (match_operand:SI 1 "register_operand" ""))
3510    (set (subreg:SI (match_dup 2) 0)
3511         (const_int 0))
3512    (set (match_operand:SF 0 "register_operand" "")
3513         (float:SF (match_dup 2)))]
3514   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
3515   "
3516 {
3517   if (TARGET_PA_20)
3518     {
3519       emit_insn (gen_floatunssisf2_pa20 (operands[0], operands[1]));
3520       DONE;
3521     }
3522   operands[2] = gen_reg_rtx (DImode);
3523 }")
3524
3525 (define_expand "floatunssidf2"
3526   [(set (subreg:SI (match_dup 2) 1)
3527         (match_operand:SI 1 "register_operand" ""))
3528    (set (subreg:SI (match_dup 2) 0)
3529         (const_int 0))
3530    (set (match_operand:DF 0 "register_operand" "")
3531         (float:DF (match_dup 2)))]
3532   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
3533   "
3534 {
3535   if (TARGET_PA_20)
3536     {
3537       emit_insn (gen_floatunssidf2_pa20 (operands[0], operands[1]));
3538       DONE;
3539     }
3540   operands[2] = gen_reg_rtx (DImode);
3541 }")
3542
3543 (define_insn "floatdisf2"
3544   [(set (match_operand:SF 0 "register_operand" "=f")
3545         (float:SF (match_operand:DI 1 "register_operand" "f")))]
3546   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
3547   "{fcnvxf,dbl,sgl|fcnv,dw,sgl} %1,%0"
3548   [(set_attr "type" "fpalu")
3549    (set_attr "length" "4")])
3550
3551 (define_insn "floatdidf2"
3552   [(set (match_operand:DF 0 "register_operand" "=f")
3553         (float:DF (match_operand:DI 1 "register_operand" "f")))]
3554   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
3555   "{fcnvxf,dbl,dbl|fcnv,dw,dbl} %1,%0"
3556   [(set_attr "type" "fpalu")
3557    (set_attr "length" "4")])
3558
3559 ;; Convert a float to an actual integer.
3560 ;; Truncation is performed as part of the conversion.
3561
3562 (define_insn "fix_truncsfsi2"
3563   [(set (match_operand:SI 0 "register_operand" "=f")
3564         (fix:SI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
3565   "! TARGET_SOFT_FLOAT"
3566   "{fcnvfxt,sgl,sgl|fcnv,t,sgl,w} %1,%0"
3567   [(set_attr "type" "fpalu")
3568    (set_attr "length" "4")])
3569
3570 (define_insn "fix_truncdfsi2"
3571   [(set (match_operand:SI 0 "register_operand" "=f")
3572         (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
3573   "! TARGET_SOFT_FLOAT"
3574   "{fcnvfxt,dbl,sgl|fcnv,t,dbl,w} %1,%0"
3575   [(set_attr "type" "fpalu")
3576    (set_attr "length" "4")])
3577
3578 (define_insn "fix_truncsfdi2"
3579   [(set (match_operand:DI 0 "register_operand" "=f")
3580         (fix:DI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
3581   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
3582   "{fcnvfxt,sgl,dbl|fcnv,t,sgl,dw} %1,%0"
3583   [(set_attr "type" "fpalu")
3584    (set_attr "length" "4")])
3585
3586 (define_insn "fix_truncdfdi2"
3587   [(set (match_operand:DI 0 "register_operand" "=f")
3588         (fix:DI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
3589   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
3590   "{fcnvfxt,dbl,dbl|fcnv,t,dbl,dw} %1,%0"
3591   [(set_attr "type" "fpalu")
3592    (set_attr "length" "4")])
3593
3594 (define_insn "floatunssidf2_pa20"
3595   [(set (match_operand:DF 0 "register_operand" "=f")
3596         (unsigned_float:DF (match_operand:SI 1 "register_operand" "f")))]
3597   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
3598   "fcnv,uw,dbl %1,%0"
3599   [(set_attr "type" "fpalu")
3600    (set_attr "length" "4")])
3601
3602 (define_insn "floatunssisf2_pa20"
3603   [(set (match_operand:SF 0 "register_operand" "=f")
3604         (unsigned_float:SF (match_operand:SI 1 "register_operand" "f")))]
3605   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
3606   "fcnv,uw,sgl %1,%0"
3607   [(set_attr "type" "fpalu")
3608    (set_attr "length" "4")])
3609
3610 (define_insn "floatunsdisf2"
3611   [(set (match_operand:SF 0 "register_operand" "=f")
3612         (unsigned_float:SF (match_operand:DI 1 "register_operand" "f")))]
3613   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
3614   "fcnv,udw,sgl %1,%0"
3615   [(set_attr "type" "fpalu")
3616    (set_attr "length" "4")])
3617
3618 (define_insn "floatunsdidf2"
3619   [(set (match_operand:DF 0 "register_operand" "=f")
3620         (unsigned_float:DF (match_operand:DI 1 "register_operand" "f")))]
3621   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
3622   "fcnv,udw,dbl %1,%0"
3623   [(set_attr "type" "fpalu")
3624    (set_attr "length" "4")])
3625
3626 (define_insn "fixuns_truncsfsi2"
3627   [(set (match_operand:SI 0 "register_operand" "=f")
3628         (unsigned_fix:SI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
3629   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
3630   "fcnv,t,sgl,uw %1,%0"
3631   [(set_attr "type" "fpalu")
3632    (set_attr "length" "4")])
3633
3634 (define_insn "fixuns_truncdfsi2"
3635   [(set (match_operand:SI 0 "register_operand" "=f")
3636         (unsigned_fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
3637   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
3638   "fcnv,t,dbl,uw %1,%0"
3639   [(set_attr "type" "fpalu")
3640    (set_attr "length" "4")])
3641
3642 (define_insn "fixuns_truncsfdi2"
3643   [(set (match_operand:DI 0 "register_operand" "=f")
3644         (unsigned_fix:DI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
3645   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
3646   "fcnv,t,sgl,udw %1,%0"
3647   [(set_attr "type" "fpalu")
3648    (set_attr "length" "4")])
3649
3650 (define_insn "fixuns_truncdfdi2"
3651   [(set (match_operand:DI 0 "register_operand" "=f")
3652         (unsigned_fix:DI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
3653   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
3654   "fcnv,t,dbl,udw %1,%0"
3655   [(set_attr "type" "fpalu")
3656    (set_attr "length" "4")])
3657 \f
3658 ;;- arithmetic instructions
3659
3660 (define_expand "adddi3"
3661   [(set (match_operand:DI 0 "register_operand" "")
3662         (plus:DI (match_operand:DI 1 "register_operand" "")
3663                  (match_operand:DI 2 "arith_operand" "")))]
3664   ""
3665   "")
3666
3667 ;; We allow arith_operand for operands2, even though strictly speaking it
3668 ;; we would prefer to us arith11_operand since that's what the hardware
3669 ;; can actually support.
3670 ;;
3671 ;; But the price of the extra reload in that case is worth the simplicity
3672 ;; we get by allowing a trivial adddi3 expander to be used for both
3673 ;; PA64 and PA32.
3674
3675 (define_insn ""
3676   [(set (match_operand:DI 0 "register_operand" "=r")
3677         (plus:DI (match_operand:DI 1 "register_operand" "%r")
3678                  (match_operand:DI 2 "arith_operand" "rI")))]
3679   "!TARGET_64BIT"
3680   "*
3681 {
3682   if (GET_CODE (operands[2]) == CONST_INT)
3683     {
3684       if (INTVAL (operands[2]) >= 0)
3685         return \"addi %2,%R1,%R0\;{addc|add,c} %1,%%r0,%0\";
3686       else
3687         return \"addi %2,%R1,%R0\;{subb|sub,b} %1,%%r0,%0\";
3688     }
3689   else
3690     return \"add %R2,%R1,%R0\;{addc|add,c} %2,%1,%0\";
3691 }"
3692   [(set_attr "type" "binary")
3693    (set_attr "length" "8")])
3694
3695 (define_insn ""
3696   [(set (match_operand:DI 0 "register_operand" "=r,r")
3697         (plus:DI (match_operand:DI 1 "register_operand" "%r,r")
3698                  (match_operand:DI 2 "arith_operand" "r,J")))]
3699   "TARGET_64BIT"
3700   "@
3701    {addl|add,l} %1,%2,%0
3702    ldo %2(%1),%0"
3703   [(set_attr "type" "binary,binary")
3704    (set_attr "pa_combine_type" "addmove")
3705    (set_attr "length" "4,4")])
3706
3707 (define_insn ""
3708   [(set (match_operand:DI 0 "register_operand" "=r")
3709         (plus:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
3710                  (match_operand:DI 2 "register_operand" "r")))]
3711   "TARGET_64BIT"
3712   "uaddcm %2,%1,%0"
3713   [(set_attr "type" "binary")
3714    (set_attr "length" "4")])
3715
3716 (define_insn ""
3717   [(set (match_operand:SI 0 "register_operand" "=r")
3718         (plus:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
3719                  (match_operand:SI 2 "register_operand" "r")))]
3720   ""
3721   "uaddcm %2,%1,%0"
3722   [(set_attr "type" "binary")
3723    (set_attr "length" "4")])
3724
3725 ;; define_splits to optimize cases of adding a constant integer
3726 ;; to a register when the constant does not fit in 14 bits.  */
3727 (define_split
3728   [(set (match_operand:SI 0 "register_operand" "")
3729         (plus:SI (match_operand:SI 1 "register_operand" "")
3730                  (match_operand:SI 2 "const_int_operand" "")))
3731    (clobber (match_operand:SI 4 "register_operand" ""))]
3732   "! cint_ok_for_move (INTVAL (operands[2]))
3733    && VAL_14_BITS_P (INTVAL (operands[2]) >> 1)"
3734   [(set (match_dup 4) (plus:SI (match_dup 1) (match_dup 2)))
3735    (set (match_dup 0) (plus:SI (match_dup 4) (match_dup 3)))]
3736   "
3737 {
3738   int val = INTVAL (operands[2]);
3739   int low = (val < 0) ? -0x2000 : 0x1fff;
3740   int rest = val - low;
3741
3742   operands[2] = GEN_INT (rest);
3743   operands[3] = GEN_INT (low);
3744 }")
3745
3746 (define_split
3747   [(set (match_operand:SI 0 "register_operand" "")
3748         (plus:SI (match_operand:SI 1 "register_operand" "")
3749                  (match_operand:SI 2 "const_int_operand" "")))
3750    (clobber (match_operand:SI 4 "register_operand" ""))]
3751   "! cint_ok_for_move (INTVAL (operands[2]))"
3752   [(set (match_dup 4) (match_dup 2))
3753    (set (match_dup 0) (plus:SI (mult:SI (match_dup 4) (match_dup 3))
3754                                (match_dup 1)))]
3755   "
3756 {
3757   HOST_WIDE_INT intval = INTVAL (operands[2]);
3758
3759   /* Try dividing the constant by 2, then 4, and finally 8 to see
3760      if we can get a constant which can be loaded into a register
3761      in a single instruction (cint_ok_for_move). 
3762
3763      If that fails, try to negate the constant and subtract it
3764      from our input operand.  */
3765   if (intval % 2 == 0 && cint_ok_for_move (intval / 2))
3766     {
3767       operands[2] = GEN_INT (intval / 2);
3768       operands[3] = GEN_INT (2);
3769     }
3770   else if (intval % 4 == 0 && cint_ok_for_move (intval / 4))
3771     {
3772       operands[2] = GEN_INT (intval / 4);
3773       operands[3] = GEN_INT (4);
3774     }
3775   else if (intval % 8 == 0 && cint_ok_for_move (intval / 8))
3776     {
3777       operands[2] = GEN_INT (intval / 8);
3778       operands[3] = GEN_INT (8);
3779     }
3780   else if (cint_ok_for_move (-intval))
3781     {
3782       emit_insn (gen_rtx_SET (VOIDmode, operands[4], GEN_INT (-intval)));
3783       emit_insn (gen_subsi3 (operands[0], operands[1], operands[4]));
3784       DONE;
3785     }
3786   else
3787     FAIL;
3788 }")
3789
3790 (define_insn "addsi3"
3791   [(set (match_operand:SI 0 "register_operand" "=r,r")
3792         (plus:SI (match_operand:SI 1 "register_operand" "%r,r")
3793                  (match_operand:SI 2 "arith_operand" "r,J")))]
3794   ""
3795   "@
3796    {addl|add,l} %1,%2,%0
3797    ldo %2(%1),%0"
3798   [(set_attr "type" "binary,binary")
3799    (set_attr "pa_combine_type" "addmove")
3800    (set_attr "length" "4,4")])
3801
3802 (define_expand "subdi3"
3803   [(set (match_operand:DI 0 "register_operand" "")
3804         (minus:DI (match_operand:DI 1 "register_operand" "")
3805                   (match_operand:DI 2 "register_operand" "")))]
3806   ""
3807   "")
3808
3809 (define_insn ""
3810   [(set (match_operand:DI 0 "register_operand" "=r")
3811         (minus:DI (match_operand:DI 1 "register_operand" "r")
3812                   (match_operand:DI 2 "register_operand" "r")))]
3813   "!TARGET_64BIT"
3814   "sub %R1,%R2,%R0\;{subb|sub,b} %1,%2,%0"
3815   [(set_attr "type" "binary")
3816   (set_attr "length" "8")])
3817
3818 (define_insn ""
3819   [(set (match_operand:DI 0 "register_operand" "=r,r,q")
3820         (minus:DI (match_operand:DI 1 "arith11_operand" "r,I,U")
3821                   (match_operand:DI 2 "register_operand" "r,r,r")))]
3822   "TARGET_64BIT"
3823   "@
3824    sub %1,%2,%0
3825    subi %1,%2,%0
3826    mtsarcm %2"
3827   [(set_attr "type" "binary,binary,move")
3828   (set_attr "length" "4,4,4")])
3829
3830 (define_expand "subsi3"
3831   [(set (match_operand:SI 0 "register_operand" "")
3832         (minus:SI (match_operand:SI 1 "arith11_operand" "")
3833                   (match_operand:SI 2 "register_operand" "")))]
3834   ""
3835   "")
3836
3837 (define_insn ""
3838   [(set (match_operand:SI 0 "register_operand" "=r,r")
3839         (minus:SI (match_operand:SI 1 "arith11_operand" "r,I")
3840                   (match_operand:SI 2 "register_operand" "r,r")))]
3841   "!TARGET_PA_20"
3842   "@
3843    sub %1,%2,%0
3844    subi %1,%2,%0"
3845   [(set_attr "type" "binary,binary")
3846    (set_attr "length" "4,4")])
3847
3848 (define_insn ""
3849   [(set (match_operand:SI 0 "register_operand" "=r,r,q")
3850         (minus:SI (match_operand:SI 1 "arith11_operand" "r,I,S")
3851                   (match_operand:SI 2 "register_operand" "r,r,r")))]
3852   "TARGET_PA_20"
3853   "@
3854    sub %1,%2,%0
3855    subi %1,%2,%0
3856    mtsarcm %2"
3857   [(set_attr "type" "binary,binary,move")
3858    (set_attr "length" "4,4,4")])
3859
3860 ;; Clobbering a "register_operand" instead of a match_scratch
3861 ;; in operand3 of millicode calls avoids spilling %r1 and
3862 ;; produces better code.
3863
3864 ;; The mulsi3 insns set up registers for the millicode call.
3865 (define_expand "mulsi3"
3866   [(set (reg:SI 26) (match_operand:SI 1 "move_operand" ""))
3867    (set (reg:SI 25) (match_operand:SI 2 "move_operand" ""))
3868    (parallel [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
3869               (clobber (match_dup 3))
3870               (clobber (reg:SI 26))
3871               (clobber (reg:SI 25))
3872               (clobber (reg:SI 31))])
3873    (set (match_operand:SI 0 "general_operand" "") (reg:SI 29))]
3874   ""
3875   "
3876 {
3877   if (TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT)
3878     {
3879       rtx scratch = gen_reg_rtx (DImode);
3880       operands[1] = force_reg (SImode, operands[1]);
3881       operands[2] = force_reg (SImode, operands[2]);
3882       emit_insn (gen_umulsidi3 (scratch, operands[1], operands[2]));
3883       /* We do not want (subreg:SI (XX:DI) 1)) for TARGET_64BIT since
3884          that has no real meaning.  */
3885       if (TARGET_64BIT)
3886         {
3887           emit_insn (gen_rtx_SET (VOIDmode,
3888                                   operands[0],
3889                                   gen_rtx_SUBREG (SImode, scratch, 0)));
3890           DONE;
3891           
3892         }
3893       emit_insn (gen_rtx_SET (VOIDmode, operands[0],
3894                               gen_rtx_SUBREG (SImode, scratch, 1)));
3895       DONE;
3896     }
3897   operands[3] = gen_reg_rtx (SImode);
3898 }")
3899
3900 (define_insn "umulsidi3"
3901   [(set (match_operand:DI 0 "nonimmediate_operand" "=f")
3902         (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "f"))
3903                  (zero_extend:DI (match_operand:SI 2 "nonimmediate_operand" "f"))))]
3904   "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT"
3905   "xmpyu %1,%2,%0"
3906   [(set_attr "type" "fpmuldbl")
3907    (set_attr "length" "4")])
3908
3909 (define_insn ""
3910   [(set (match_operand:DI 0 "nonimmediate_operand" "=f")
3911         (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "f"))
3912                  (match_operand:DI 2 "uint32_operand" "f")))]
3913   "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT && !TARGET_64BIT"
3914   "xmpyu %1,%R2,%0"
3915   [(set_attr "type" "fpmuldbl")
3916    (set_attr "length" "4")])
3917
3918 (define_insn ""
3919   [(set (match_operand:DI 0 "nonimmediate_operand" "=f")
3920         (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "f"))
3921                  (match_operand:DI 2 "uint32_operand" "f")))]
3922   "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT && TARGET_64BIT"
3923   "xmpyu %1,%2R,%0"
3924   [(set_attr "type" "fpmuldbl")
3925    (set_attr "length" "4")])
3926
3927 (define_insn ""
3928   [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
3929    (clobber (match_operand:SI 0 "register_operand" "=a"))
3930    (clobber (reg:SI 26))
3931    (clobber (reg:SI 25))
3932    (clobber (reg:SI 31))]
3933   ""
3934   "* return output_mul_insn (0, insn);"
3935   [(set_attr "type" "milli")
3936    (set (attr "length")
3937      (cond [
3938 ;; Target (or stub) within reach
3939             (and (lt (plus (symbol_ref "total_code_bytes") (pc))
3940                      (const_int 240000))
3941                  (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
3942                      (const_int 0)))
3943             (const_int 4)
3944
3945 ;; NO_SPACE_REGS
3946             (ne (symbol_ref "TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS")
3947                 (const_int 0))
3948             (const_int 8)
3949
3950 ;; Out of reach, but not PIC or PORTABLE_RUNTIME
3951 ;; same as NO_SPACE_REGS code
3952             (and (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
3953                      (const_int 0))
3954                  (eq (symbol_ref "flag_pic")
3955                      (const_int 0)))
3956             (const_int 8)]
3957
3958 ;; Out of range and either PIC or PORTABLE_RUNTIME
3959           (const_int 24)))])
3960
3961 (define_expand "muldi3"
3962   [(set (match_operand:DI 0 "register_operand" "")
3963         (mult:DI (match_operand:DI 1 "register_operand" "")
3964                  (match_operand:DI 2 "register_operand" "")))]
3965   "TARGET_64BIT && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT"
3966   "
3967 {
3968   rtx low_product = gen_reg_rtx (DImode);
3969   rtx cross_product1 = gen_reg_rtx (DImode);
3970   rtx cross_product2 = gen_reg_rtx (DImode);
3971   rtx cross_scratch = gen_reg_rtx (DImode);
3972   rtx cross_product = gen_reg_rtx (DImode);
3973   rtx op1l, op1r, op2l, op2r;
3974   rtx op1shifted, op2shifted;
3975
3976   op1shifted = gen_reg_rtx (DImode);
3977   op2shifted = gen_reg_rtx (DImode);
3978   op1l = gen_reg_rtx (SImode);
3979   op1r = gen_reg_rtx (SImode);
3980   op2l = gen_reg_rtx (SImode);
3981   op2r = gen_reg_rtx (SImode);
3982
3983   emit_move_insn (op1shifted, gen_rtx_LSHIFTRT (DImode, operands[1],
3984                                                 GEN_INT (32)));
3985   emit_move_insn (op2shifted, gen_rtx_LSHIFTRT (DImode, operands[2],
3986                                                 GEN_INT (32)));
3987   op1r = gen_rtx_SUBREG (SImode, operands[1], 0);
3988   op2r = gen_rtx_SUBREG (SImode, operands[2], 0);
3989   op1l = gen_rtx_SUBREG (SImode, op1shifted, 0);
3990   op2l = gen_rtx_SUBREG (SImode, op2shifted, 0);
3991
3992   /* Emit multiplies for the cross products.  */
3993   emit_insn (gen_umulsidi3 (cross_product1, op2r, op1l));
3994   emit_insn (gen_umulsidi3 (cross_product2, op2l, op1r));
3995
3996   /* Emit a multiply for the low sub-word.  */
3997   emit_insn (gen_umulsidi3 (low_product, op2r, op1r));
3998
3999   /* Sum the cross products and shift them into proper position.  */
4000   emit_insn (gen_adddi3 (cross_scratch, cross_product1, cross_product2));
4001   emit_insn (gen_ashldi3 (cross_product, cross_scratch, GEN_INT (32)));
4002
4003   /* Add the cross product to the low product and store the result
4004      into the output operand .  */
4005   emit_insn (gen_adddi3 (operands[0], cross_product, low_product));
4006   DONE;
4007 }")
4008
4009 ;;; Division and mod.
4010 (define_expand "divsi3"
4011   [(set (reg:SI 26) (match_operand:SI 1 "move_operand" ""))
4012    (set (reg:SI 25) (match_operand:SI 2 "move_operand" ""))
4013    (parallel [(set (reg:SI 29) (div:SI (reg:SI 26) (reg:SI 25)))
4014               (clobber (match_dup 3))
4015               (clobber (match_dup 4))
4016               (clobber (reg:SI 26))
4017               (clobber (reg:SI 25))
4018               (clobber (reg:SI 31))])
4019    (set (match_operand:SI 0 "general_operand" "") (reg:SI 29))]
4020   ""
4021   "
4022 {
4023   operands[3] = gen_reg_rtx (SImode);
4024   operands[4] = gen_reg_rtx (SImode);
4025   if (TARGET_64BIT)
4026     operands[4] = gen_rtx_REG (SImode, 2);
4027   if (GET_CODE (operands[2]) == CONST_INT && emit_hpdiv_const (operands, 0))
4028     DONE;
4029 }")
4030
4031 (define_insn ""
4032   [(set (reg:SI 29)
4033         (div:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
4034    (clobber (match_operand:SI 1 "register_operand" "=a"))
4035    (clobber (match_operand:SI 2 "register_operand" "=&r"))
4036    (clobber (reg:SI 26))
4037    (clobber (reg:SI 25))
4038    (clobber (reg:SI 31))]
4039   ""
4040   "*
4041    return output_div_insn (operands, 0, insn);"
4042   [(set_attr "type" "milli")
4043    (set (attr "length")
4044      (cond [
4045 ;; Target (or stub) within reach
4046             (and (lt (plus (symbol_ref "total_code_bytes") (pc))
4047                      (const_int 240000))
4048                  (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
4049                      (const_int 0)))
4050             (const_int 4)
4051
4052 ;; NO_SPACE_REGS
4053             (ne (symbol_ref "TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS")
4054                 (const_int 0))
4055             (const_int 8)
4056
4057 ;; Out of reach, but not PIC or PORTABLE_RUNTIME
4058 ;; same as NO_SPACE_REGS code
4059             (and (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
4060                      (const_int 0))
4061                  (eq (symbol_ref "flag_pic")
4062                      (const_int 0)))
4063             (const_int 8)]
4064
4065 ;; Out of range and either PIC or PORTABLE_RUNTIME
4066           (const_int 24)))])
4067
4068 (define_expand "udivsi3"
4069   [(set (reg:SI 26) (match_operand:SI 1 "move_operand" ""))
4070    (set (reg:SI 25) (match_operand:SI 2 "move_operand" ""))
4071    (parallel [(set (reg:SI 29) (udiv:SI (reg:SI 26) (reg:SI 25)))
4072               (clobber (match_dup 3))
4073               (clobber (match_dup 4))
4074               (clobber (reg:SI 26))
4075               (clobber (reg:SI 25))
4076               (clobber (reg:SI 31))])
4077    (set (match_operand:SI 0 "general_operand" "") (reg:SI 29))]
4078   ""
4079   "
4080 {
4081   operands[3] = gen_reg_rtx (SImode);
4082   operands[4] = gen_reg_rtx (SImode);
4083   if (TARGET_64BIT)
4084     operands[4] = gen_rtx_REG (SImode, 2);
4085   if (GET_CODE (operands[2]) == CONST_INT && emit_hpdiv_const (operands, 1))
4086     DONE;
4087 }")
4088
4089 (define_insn ""
4090   [(set (reg:SI 29)
4091         (udiv:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
4092    (clobber (match_operand:SI 1 "register_operand" "=a"))
4093    (clobber (match_operand:SI 2 "register_operand" "=&r"))
4094    (clobber (reg:SI 26))
4095    (clobber (reg:SI 25))
4096    (clobber (reg:SI 31))]
4097   ""
4098   "*
4099    return output_div_insn (operands, 1, insn);"
4100   [(set_attr "type" "milli")
4101    (set (attr "length")
4102      (cond [
4103 ;; Target (or stub) within reach
4104             (and (lt (plus (symbol_ref "total_code_bytes") (pc))
4105                      (const_int 240000))
4106                  (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
4107                      (const_int 0)))
4108             (const_int 4)
4109
4110 ;; NO_SPACE_REGS
4111             (ne (symbol_ref "TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS")
4112                 (const_int 0))
4113             (const_int 8)
4114
4115 ;; Out of reach, but not PIC or PORTABLE_RUNTIME
4116 ;; same as NO_SPACE_REGS code
4117             (and (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
4118                      (const_int 0))
4119                  (eq (symbol_ref "flag_pic")
4120                      (const_int 0)))
4121             (const_int 8)]
4122
4123 ;; Out of range and either PIC or PORTABLE_RUNTIME
4124           (const_int 24)))])
4125
4126 (define_expand "modsi3"
4127   [(set (reg:SI 26) (match_operand:SI 1 "move_operand" ""))
4128    (set (reg:SI 25) (match_operand:SI 2 "move_operand" ""))
4129    (parallel [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
4130               (clobber (match_dup 3))
4131               (clobber (match_dup 4))
4132               (clobber (reg:SI 26))
4133               (clobber (reg:SI 25))
4134               (clobber (reg:SI 31))])
4135    (set (match_operand:SI 0 "general_operand" "") (reg:SI 29))]
4136   ""
4137   "
4138 {
4139   operands[4] = gen_reg_rtx (SImode);
4140   if (TARGET_64BIT)
4141     operands[4] = gen_rtx_REG (SImode, 2);
4142   operands[3] = gen_reg_rtx (SImode);
4143 }")
4144
4145 (define_insn ""
4146   [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
4147    (clobber (match_operand:SI 0 "register_operand" "=a"))
4148    (clobber (match_operand:SI 1 "register_operand" "=&r"))
4149    (clobber (reg:SI 26))
4150    (clobber (reg:SI 25))
4151    (clobber (reg:SI 31))]
4152   ""
4153   "*
4154   return output_mod_insn (0, insn);"
4155   [(set_attr "type" "milli")
4156    (set (attr "length")
4157      (cond [
4158 ;; Target (or stub) within reach
4159             (and (lt (plus (symbol_ref "total_code_bytes") (pc))
4160                      (const_int 240000))
4161                  (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
4162                      (const_int 0)))
4163             (const_int 4)
4164
4165 ;; NO_SPACE_REGS
4166             (ne (symbol_ref "TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS")
4167                 (const_int 0))
4168             (const_int 8)
4169
4170 ;; Out of reach, but not PIC or PORTABLE_RUNTIME
4171 ;; same as NO_SPACE_REGS code
4172             (and (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
4173                      (const_int 0))
4174                  (eq (symbol_ref "flag_pic")
4175                      (const_int 0)))
4176             (const_int 8)]
4177
4178 ;; Out of range and either PIC or PORTABLE_RUNTIME
4179           (const_int 24)))])
4180
4181 (define_expand "umodsi3"
4182   [(set (reg:SI 26) (match_operand:SI 1 "move_operand" ""))
4183    (set (reg:SI 25) (match_operand:SI 2 "move_operand" ""))
4184    (parallel [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
4185               (clobber (match_dup 3))
4186               (clobber (match_dup 4))
4187               (clobber (reg:SI 26))
4188               (clobber (reg:SI 25))
4189               (clobber (reg:SI 31))])
4190    (set (match_operand:SI 0 "general_operand" "") (reg:SI 29))]
4191   ""
4192   "
4193 {
4194   operands[4] = gen_reg_rtx (SImode);
4195   if (TARGET_64BIT)
4196     operands[4] = gen_rtx_REG (SImode, 2);
4197   operands[3] = gen_reg_rtx (SImode);
4198 }")
4199
4200 (define_insn ""
4201   [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
4202    (clobber (match_operand:SI 0 "register_operand" "=a"))
4203    (clobber (match_operand:SI 1 "register_operand" "=&r"))
4204    (clobber (reg:SI 26))
4205    (clobber (reg:SI 25))
4206    (clobber (reg:SI 31))]
4207   ""
4208   "*
4209   return output_mod_insn (1, insn);"
4210   [(set_attr "type" "milli")
4211    (set (attr "length")
4212      (cond [
4213 ;; Target (or stub) within reach
4214             (and (lt (plus (symbol_ref "total_code_bytes") (pc))
4215                      (const_int 240000))
4216                  (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
4217                      (const_int 0)))
4218             (const_int 4)
4219
4220 ;; NO_SPACE_REGS
4221             (ne (symbol_ref "TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS")
4222                 (const_int 0))
4223             (const_int 8)
4224
4225 ;; Out of reach, but not PIC or PORTABLE_RUNTIME
4226 ;; same as NO_SPACE_REGS code
4227             (and (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
4228                      (const_int 0))
4229                  (eq (symbol_ref "flag_pic")
4230                      (const_int 0)))
4231             (const_int 8)]
4232
4233 ;; Out of range and either PIC or PORTABLE_RUNTIME
4234           (const_int 24)))])
4235
4236 ;;- and instructions
4237 ;; We define DImode `and` so with DImode `not` we can get
4238 ;; DImode `andn`.  Other combinations are possible.
4239
4240 (define_expand "anddi3"
4241   [(set (match_operand:DI 0 "register_operand" "")
4242         (and:DI (match_operand:DI 1 "arith_double_operand" "")
4243                 (match_operand:DI 2 "arith_double_operand" "")))]
4244   ""
4245   "
4246 {
4247   if (! register_operand (operands[1], DImode)
4248       || ! register_operand (operands[2], DImode))
4249     /* Let GCC break this into word-at-a-time operations.  */
4250     FAIL;
4251 }")
4252
4253 (define_insn ""
4254   [(set (match_operand:DI 0 "register_operand" "=r")
4255         (and:DI (match_operand:DI 1 "register_operand" "%r")
4256                 (match_operand:DI 2 "register_operand" "r")))]
4257   "!TARGET_64BIT"
4258   "and %1,%2,%0\;and %R1,%R2,%R0"
4259   [(set_attr "type" "binary")
4260    (set_attr "length" "8")])
4261
4262 (define_insn ""
4263   [(set (match_operand:DI 0 "register_operand" "=r,r")
4264         (and:DI (match_operand:DI 1 "register_operand" "%?r,0")
4265                 (match_operand:DI 2 "and_operand" "rO,P")))]
4266   "TARGET_64BIT"
4267   "* return output_64bit_and (operands); "
4268   [(set_attr "type" "binary")
4269    (set_attr "length" "4")])
4270
4271 ; The ? for op1 makes reload prefer zdepi instead of loading a huge
4272 ; constant with ldil;ldo.
4273 (define_insn "andsi3"
4274   [(set (match_operand:SI 0 "register_operand" "=r,r")
4275         (and:SI (match_operand:SI 1 "register_operand" "%?r,0")
4276                 (match_operand:SI 2 "and_operand" "rO,P")))]
4277   ""
4278   "* return output_and (operands); "
4279   [(set_attr "type" "binary,shift")
4280    (set_attr "length" "4,4")])
4281
4282 (define_insn ""
4283   [(set (match_operand:DI 0 "register_operand" "=r")
4284         (and:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
4285                 (match_operand:DI 2 "register_operand" "r")))]
4286   "!TARGET_64BIT"
4287   "andcm %2,%1,%0\;andcm %R2,%R1,%R0"
4288   [(set_attr "type" "binary")
4289    (set_attr "length" "8")])
4290
4291 (define_insn ""
4292   [(set (match_operand:DI 0 "register_operand" "=r")
4293         (and:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
4294                 (match_operand:DI 2 "register_operand" "r")))]
4295   "TARGET_64BIT"
4296   "andcm %2,%1,%0"
4297   [(set_attr "type" "binary")
4298    (set_attr "length" "4")])
4299
4300 (define_insn ""
4301   [(set (match_operand:SI 0 "register_operand" "=r")
4302         (and:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
4303                 (match_operand:SI 2 "register_operand" "r")))]
4304   ""
4305   "andcm %2,%1,%0"
4306   [(set_attr "type" "binary")
4307   (set_attr "length" "4")])
4308
4309 (define_expand "iordi3"
4310   [(set (match_operand:DI 0 "register_operand" "")
4311         (ior:DI (match_operand:DI 1 "arith_double_operand" "")
4312                 (match_operand:DI 2 "arith_double_operand" "")))]
4313   ""
4314   "
4315 {
4316   if (! register_operand (operands[1], DImode)
4317       || ! register_operand (operands[2], DImode))
4318     /* Let GCC break this into word-at-a-time operations.  */
4319     FAIL;
4320 }")
4321
4322 (define_insn ""
4323   [(set (match_operand:DI 0 "register_operand" "=r")
4324         (ior:DI (match_operand:DI 1 "register_operand" "%r")
4325                 (match_operand:DI 2 "register_operand" "r")))]
4326   "!TARGET_64BIT"
4327   "or %1,%2,%0\;or %R1,%R2,%R0"
4328   [(set_attr "type" "binary")
4329    (set_attr "length" "8")])
4330
4331 (define_insn ""
4332   [(set (match_operand:DI 0 "register_operand" "=r,r")
4333         (ior:DI (match_operand:DI 1 "register_operand" "0,0")
4334                 (match_operand:DI 2 "ior_operand" "M,i")))]
4335   "TARGET_64BIT"
4336   "* return output_64bit_ior (operands); "
4337   [(set_attr "type" "binary,shift")
4338    (set_attr "length" "4,4")])
4339
4340 (define_insn ""
4341   [(set (match_operand:DI 0 "register_operand" "=r")
4342         (ior:DI (match_operand:DI 1 "register_operand" "%r")
4343                 (match_operand:DI 2 "register_operand" "r")))]
4344   "TARGET_64BIT"
4345   "or %1,%2,%0"
4346   [(set_attr "type" "binary")
4347    (set_attr "length" "4")])
4348
4349 ;; Need a define_expand because we've run out of CONST_OK... characters.
4350 (define_expand "iorsi3"
4351   [(set (match_operand:SI 0 "register_operand" "")
4352         (ior:SI (match_operand:SI 1 "register_operand" "")
4353                 (match_operand:SI 2 "arith32_operand" "")))]
4354   ""
4355   "
4356 {
4357   if (! (ior_operand (operands[2], SImode)
4358          || register_operand (operands[2], SImode)))
4359     operands[2] = force_reg (SImode, operands[2]);
4360 }")
4361
4362 (define_insn ""
4363   [(set (match_operand:SI 0 "register_operand" "=r,r")
4364         (ior:SI (match_operand:SI 1 "register_operand" "0,0")
4365                 (match_operand:SI 2 "ior_operand" "M,i")))]
4366   ""
4367   "* return output_ior (operands); "
4368   [(set_attr "type" "binary,shift")
4369    (set_attr "length" "4,4")])
4370
4371 (define_insn ""
4372   [(set (match_operand:SI 0 "register_operand" "=r")
4373         (ior:SI (match_operand:SI 1 "register_operand" "%r")
4374                 (match_operand:SI 2 "register_operand" "r")))]
4375   ""
4376   "or %1,%2,%0"
4377   [(set_attr "type" "binary")
4378    (set_attr "length" "4")])
4379
4380 (define_expand "xordi3"
4381   [(set (match_operand:DI 0 "register_operand" "")
4382         (xor:DI (match_operand:DI 1 "arith_double_operand" "")
4383                 (match_operand:DI 2 "arith_double_operand" "")))]
4384   ""
4385   "
4386 {
4387   if (! register_operand (operands[1], DImode)
4388       || ! register_operand (operands[2], DImode))
4389     /* Let GCC break this into word-at-a-time operations.  */
4390     FAIL;
4391 }")
4392
4393 (define_insn ""
4394   [(set (match_operand:DI 0 "register_operand" "=r")
4395         (xor:DI (match_operand:DI 1 "register_operand" "%r")
4396                 (match_operand:DI 2 "register_operand" "r")))]
4397   "!TARGET_64BIT"
4398   "xor %1,%2,%0\;xor %R1,%R2,%R0"
4399   [(set_attr "type" "binary")
4400    (set_attr "length" "8")])
4401
4402 (define_insn ""
4403   [(set (match_operand:DI 0 "register_operand" "=r")
4404         (xor:DI (match_operand:DI 1 "register_operand" "%r")
4405                 (match_operand:DI 2 "register_operand" "r")))]
4406   "TARGET_64BIT"
4407   "xor %1,%2,%0"
4408   [(set_attr "type" "binary")
4409    (set_attr "length" "4")])
4410
4411 (define_insn "xorsi3"
4412   [(set (match_operand:SI 0 "register_operand" "=r")
4413         (xor:SI (match_operand:SI 1 "register_operand" "%r")
4414                 (match_operand:SI 2 "register_operand" "r")))]
4415   ""
4416   "xor %1,%2,%0"
4417   [(set_attr "type" "binary")
4418    (set_attr "length" "4")])
4419
4420 (define_expand "negdi2"
4421   [(set (match_operand:DI 0 "register_operand" "")
4422         (neg:DI (match_operand:DI 1 "register_operand" "")))]
4423   ""
4424   "")
4425
4426 (define_insn ""
4427   [(set (match_operand:DI 0 "register_operand" "=r")
4428         (neg:DI (match_operand:DI 1 "register_operand" "r")))]
4429   "!TARGET_64BIT"
4430   "sub %%r0,%R1,%R0\;{subb|sub,b} %%r0,%1,%0"
4431   [(set_attr "type" "unary")
4432    (set_attr "length" "8")])
4433
4434 (define_insn ""
4435   [(set (match_operand:DI 0 "register_operand" "=r")
4436         (neg:DI (match_operand:DI 1 "register_operand" "r")))]
4437   "TARGET_64BIT"
4438   "sub %%r0,%1,%0"
4439   [(set_attr "type" "unary")
4440    (set_attr "length" "4")])
4441
4442 (define_insn "negsi2"
4443   [(set (match_operand:SI 0 "register_operand" "=r")
4444         (neg:SI (match_operand:SI 1 "register_operand" "r")))]
4445   ""
4446   "sub %%r0,%1,%0"
4447   [(set_attr "type" "unary")
4448    (set_attr "length" "4")])
4449
4450 (define_expand "one_cmpldi2"
4451   [(set (match_operand:DI 0 "register_operand" "")
4452         (not:DI (match_operand:DI 1 "arith_double_operand" "")))]
4453   ""
4454   "
4455 {
4456   if (! register_operand (operands[1], DImode))
4457     FAIL;
4458 }")
4459
4460 (define_insn ""
4461   [(set (match_operand:DI 0 "register_operand" "=r")
4462         (not:DI (match_operand:DI 1 "register_operand" "r")))]
4463   "!TARGET_64BIT"
4464   "uaddcm %%r0,%1,%0\;uaddcm %%r0,%R1,%R0"
4465   [(set_attr "type" "unary")
4466    (set_attr "length" "8")])
4467
4468 (define_insn ""
4469   [(set (match_operand:DI 0 "register_operand" "=r")
4470         (not:DI (match_operand:DI 1 "register_operand" "r")))]
4471   "TARGET_64BIT"
4472   "uaddcm %%r0,%1,%0"
4473   [(set_attr "type" "unary")
4474    (set_attr "length" "4")])
4475
4476 (define_insn "one_cmplsi2"
4477   [(set (match_operand:SI 0 "register_operand" "=r")
4478         (not:SI (match_operand:SI 1 "register_operand" "r")))]
4479   ""
4480   "uaddcm %%r0,%1,%0"
4481   [(set_attr "type" "unary")
4482    (set_attr "length" "4")])
4483 \f
4484 ;; Floating point arithmetic instructions.
4485
4486 (define_insn "adddf3"
4487   [(set (match_operand:DF 0 "register_operand" "=f")
4488         (plus:DF (match_operand:DF 1 "register_operand" "f")
4489                  (match_operand:DF 2 "register_operand" "f")))]
4490   "! TARGET_SOFT_FLOAT"
4491   "fadd,dbl %1,%2,%0"
4492   [(set_attr "type" "fpalu")
4493    (set_attr "pa_combine_type" "faddsub")
4494    (set_attr "length" "4")])
4495
4496 (define_insn "addsf3"
4497   [(set (match_operand:SF 0 "register_operand" "=f")
4498         (plus:SF (match_operand:SF 1 "register_operand" "f")
4499                  (match_operand:SF 2 "register_operand" "f")))]
4500   "! TARGET_SOFT_FLOAT"
4501   "fadd,sgl %1,%2,%0"
4502   [(set_attr "type" "fpalu")
4503    (set_attr "pa_combine_type" "faddsub")
4504    (set_attr "length" "4")])
4505
4506 (define_insn "subdf3"
4507   [(set (match_operand:DF 0 "register_operand" "=f")
4508         (minus:DF (match_operand:DF 1 "register_operand" "f")
4509                   (match_operand:DF 2 "register_operand" "f")))]
4510   "! TARGET_SOFT_FLOAT"
4511   "fsub,dbl %1,%2,%0"
4512   [(set_attr "type" "fpalu")
4513    (set_attr "pa_combine_type" "faddsub")
4514    (set_attr "length" "4")])
4515
4516 (define_insn "subsf3"
4517   [(set (match_operand:SF 0 "register_operand" "=f")
4518         (minus:SF (match_operand:SF 1 "register_operand" "f")
4519                   (match_operand:SF 2 "register_operand" "f")))]
4520   "! TARGET_SOFT_FLOAT"
4521   "fsub,sgl %1,%2,%0"
4522   [(set_attr "type" "fpalu")
4523    (set_attr "pa_combine_type" "faddsub")
4524    (set_attr "length" "4")])
4525
4526 (define_insn "muldf3"
4527   [(set (match_operand:DF 0 "register_operand" "=f")
4528         (mult:DF (match_operand:DF 1 "register_operand" "f")
4529                  (match_operand:DF 2 "register_operand" "f")))]
4530   "! TARGET_SOFT_FLOAT"
4531   "fmpy,dbl %1,%2,%0"
4532   [(set_attr "type" "fpmuldbl")
4533    (set_attr "pa_combine_type" "fmpy")
4534    (set_attr "length" "4")])
4535
4536 (define_insn "mulsf3"
4537   [(set (match_operand:SF 0 "register_operand" "=f")
4538         (mult:SF (match_operand:SF 1 "register_operand" "f")
4539                  (match_operand:SF 2 "register_operand" "f")))]
4540   "! TARGET_SOFT_FLOAT"
4541   "fmpy,sgl %1,%2,%0"
4542   [(set_attr "type" "fpmulsgl")
4543    (set_attr "pa_combine_type" "fmpy")
4544    (set_attr "length" "4")])
4545
4546 (define_insn "divdf3"
4547   [(set (match_operand:DF 0 "register_operand" "=f")
4548         (div:DF (match_operand:DF 1 "register_operand" "f")
4549                 (match_operand:DF 2 "register_operand" "f")))]
4550   "! TARGET_SOFT_FLOAT"
4551   "fdiv,dbl %1,%2,%0"
4552   [(set_attr "type" "fpdivdbl")
4553    (set_attr "length" "4")])
4554
4555 (define_insn "divsf3"
4556   [(set (match_operand:SF 0 "register_operand" "=f")
4557         (div:SF (match_operand:SF 1 "register_operand" "f")
4558                 (match_operand:SF 2 "register_operand" "f")))]
4559   "! TARGET_SOFT_FLOAT"
4560   "fdiv,sgl %1,%2,%0"
4561   [(set_attr "type" "fpdivsgl")
4562    (set_attr "length" "4")])
4563
4564 (define_insn "negdf2"
4565   [(set (match_operand:DF 0 "register_operand" "=f")
4566         (neg:DF (match_operand:DF 1 "register_operand" "f")))]
4567   "! TARGET_SOFT_FLOAT"
4568   "*
4569 {
4570   if (TARGET_PA_20)
4571     return \"fneg,dbl %1,%0\";
4572   else
4573     return \"fsub,dbl %%fr0,%1,%0\";
4574 }"
4575   [(set_attr "type" "fpalu")
4576    (set_attr "length" "4")])
4577
4578 (define_insn "negsf2"
4579   [(set (match_operand:SF 0 "register_operand" "=f")
4580         (neg:SF (match_operand:SF 1 "register_operand" "f")))]
4581   "! TARGET_SOFT_FLOAT"
4582   "*
4583 {
4584   if (TARGET_PA_20)
4585     return \"fneg,sgl %1,%0\";
4586   else
4587     return \"fsub,sgl %%fr0,%1,%0\";
4588 }"
4589   [(set_attr "type" "fpalu")
4590    (set_attr "length" "4")])
4591
4592 (define_insn "absdf2"
4593   [(set (match_operand:DF 0 "register_operand" "=f")
4594         (abs:DF (match_operand:DF 1 "register_operand" "f")))]
4595   "! TARGET_SOFT_FLOAT"
4596   "fabs,dbl %1,%0"
4597   [(set_attr "type" "fpalu")
4598    (set_attr "length" "4")])
4599
4600 (define_insn "abssf2"
4601   [(set (match_operand:SF 0 "register_operand" "=f")
4602         (abs:SF (match_operand:SF 1 "register_operand" "f")))]
4603   "! TARGET_SOFT_FLOAT"
4604   "fabs,sgl %1,%0"
4605   [(set_attr "type" "fpalu")
4606    (set_attr "length" "4")])
4607
4608 (define_insn "sqrtdf2"
4609   [(set (match_operand:DF 0 "register_operand" "=f")
4610         (sqrt:DF (match_operand:DF 1 "register_operand" "f")))]
4611   "! TARGET_SOFT_FLOAT"
4612   "fsqrt,dbl %1,%0"
4613   [(set_attr "type" "fpsqrtdbl")
4614    (set_attr "length" "4")])
4615
4616 (define_insn "sqrtsf2"
4617   [(set (match_operand:SF 0 "register_operand" "=f")
4618         (sqrt:SF (match_operand:SF 1 "register_operand" "f")))]
4619   "! TARGET_SOFT_FLOAT"
4620   "fsqrt,sgl %1,%0"
4621   [(set_attr "type" "fpsqrtsgl")
4622    (set_attr "length" "4")])
4623
4624 ;; PA 2.0 floating point instructions
4625
4626 ; fmpyfadd patterns
4627 (define_insn ""
4628   [(set (match_operand:DF 0 "register_operand" "=f")
4629         (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
4630                           (match_operand:DF 2 "register_operand" "f"))
4631                  (match_operand:DF 3 "register_operand" "f")))]
4632   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
4633   "fmpyfadd,dbl %1,%2,%3,%0"
4634   [(set_attr "type" "fpmuldbl")
4635    (set_attr "length" "4")])
4636
4637 (define_insn ""
4638   [(set (match_operand:DF 0 "register_operand" "=f")
4639         (plus:DF (match_operand:DF 1 "register_operand" "f")
4640                  (mult:DF (match_operand:DF 2 "register_operand" "f")
4641                           (match_operand:DF 3 "register_operand" "f"))))]
4642   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
4643   "fmpyfadd,dbl %2,%3,%1,%0"
4644   [(set_attr "type" "fpmuldbl")
4645    (set_attr "length" "4")])
4646
4647 (define_insn ""
4648   [(set (match_operand:SF 0 "register_operand" "=f")
4649         (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
4650                           (match_operand:SF 2 "register_operand" "f"))
4651                  (match_operand:SF 3 "register_operand" "f")))]
4652   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
4653   "fmpyfadd,sgl %1,%2,%3,%0"
4654   [(set_attr "type" "fpmulsgl")
4655    (set_attr "length" "4")])
4656
4657 (define_insn ""
4658   [(set (match_operand:SF 0 "register_operand" "=f")
4659         (plus:SF (match_operand:SF 1 "register_operand" "f")
4660                  (mult:SF (match_operand:SF 2 "register_operand" "f")
4661                           (match_operand:SF 3 "register_operand" "f"))))]
4662   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
4663   "fmpyfadd,sgl %2,%3,%1,%0"
4664   [(set_attr "type" "fpmulsgl")
4665    (set_attr "length" "4")])
4666
4667 ; fmpynfadd patterns
4668 (define_insn ""
4669   [(set (match_operand:DF 0 "register_operand" "=f")
4670         (minus:DF (match_operand:DF 1 "register_operand" "f")
4671                   (mult:DF (match_operand:DF 2 "register_operand" "f")
4672                            (match_operand:DF 3 "register_operand" "f"))))]
4673   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
4674   "fmpynfadd,dbl %2,%3,%1,%0"
4675   [(set_attr "type" "fpmuldbl")
4676    (set_attr "length" "4")])
4677
4678 (define_insn ""
4679   [(set (match_operand:SF 0 "register_operand" "=f")
4680         (minus:SF (match_operand:SF 1 "register_operand" "f")
4681                   (mult:SF (match_operand:SF 2 "register_operand" "f")
4682                            (match_operand:SF 3 "register_operand" "f"))))]
4683   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
4684   "fmpynfadd,sgl %2,%3,%1,%0"
4685   [(set_attr "type" "fpmulsgl")
4686    (set_attr "length" "4")])
4687
4688 ; fnegabs patterns
4689 (define_insn ""
4690   [(set (match_operand:DF 0 "register_operand" "=f")
4691         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))]
4692   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
4693   "fnegabs,dbl %1,%0"
4694   [(set_attr "type" "fpalu")
4695    (set_attr "length" "4")])
4696
4697 (define_insn ""
4698   [(set (match_operand:SF 0 "register_operand" "=f")
4699         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))]
4700   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
4701   "fnegabs,sgl %1,%0"
4702   [(set_attr "type" "fpalu")
4703    (set_attr "length" "4")])
4704
4705 ;; Generating a fused multiply sequence is a win for this case as it will
4706 ;; reduce the latency for the fused case without impacting the plain
4707 ;; multiply case.
4708 ;;
4709 ;; Similar possibilities exist for fnegabs, shadd and other insns which
4710 ;; perform two operations with the result of the first feeding the second.
4711 (define_insn ""
4712   [(set (match_operand:DF 0 "register_operand" "=f")
4713         (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
4714                           (match_operand:DF 2 "register_operand" "f"))
4715                  (match_operand:DF 3 "register_operand" "f")))
4716    (set (match_operand:DF 4 "register_operand" "=&f")
4717         (mult:DF (match_dup 1) (match_dup 2)))]
4718   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
4719     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
4720           || reg_overlap_mentioned_p (operands[4], operands[2])))"
4721   "#"
4722   [(set_attr "type" "fpmuldbl")
4723    (set_attr "length" "8")])
4724
4725 ;; We want to split this up during scheduling since we want both insns
4726 ;; to schedule independently.
4727 (define_split
4728   [(set (match_operand:DF 0 "register_operand" "=f")
4729         (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
4730                           (match_operand:DF 2 "register_operand" "f"))
4731                  (match_operand:DF 3 "register_operand" "f")))
4732    (set (match_operand:DF 4 "register_operand" "=&f")
4733         (mult:DF (match_dup 1) (match_dup 2)))]
4734   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4735   [(set (match_dup 4) (mult:DF (match_dup 1) (match_dup 2)))
4736    (set (match_dup 0) (plus:DF (mult:DF (match_dup 1) (match_dup 2))
4737                                (match_dup 3)))]
4738   "")
4739
4740 (define_insn ""
4741   [(set (match_operand:SF 0 "register_operand" "=f")
4742         (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
4743                           (match_operand:SF 2 "register_operand" "f"))
4744                  (match_operand:SF 3 "register_operand" "f")))
4745    (set (match_operand:SF 4 "register_operand" "=&f")
4746         (mult:SF (match_dup 1) (match_dup 2)))]
4747   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
4748     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
4749           || reg_overlap_mentioned_p (operands[4], operands[2])))"
4750   "#"
4751   [(set_attr "type" "fpmuldbl")
4752    (set_attr "length" "8")])
4753
4754 ;; We want to split this up during scheduling since we want both insns
4755 ;; to schedule independently.
4756 (define_split
4757   [(set (match_operand:SF 0 "register_operand" "=f")
4758         (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
4759                           (match_operand:SF 2 "register_operand" "f"))
4760                  (match_operand:SF 3 "register_operand" "f")))
4761    (set (match_operand:SF 4 "register_operand" "=&f")
4762         (mult:SF (match_dup 1) (match_dup 2)))]
4763   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4764   [(set (match_dup 4) (mult:SF (match_dup 1) (match_dup 2)))
4765    (set (match_dup 0) (plus:SF (mult:SF (match_dup 1) (match_dup 2))
4766                                (match_dup 3)))]
4767   "")
4768
4769 ;; Negating a multiply can be faked by adding zero in a fused multiply-add
4770 ;; instruction.
4771 (define_insn ""
4772   [(set (match_operand:DF 0 "register_operand" "=f")
4773         (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
4774                          (match_operand:DF 2 "register_operand" "f"))))]
4775   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4776   "fmpynfadd,dbl %1,%2,%%fr0,%0"
4777   [(set_attr "type" "fpmuldbl")
4778    (set_attr "length" "4")])
4779
4780 (define_insn ""
4781   [(set (match_operand:SF 0 "register_operand" "=f")
4782         (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
4783                          (match_operand:SF 2 "register_operand" "f"))))]
4784   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4785   "fmpynfadd,sgl %1,%2,%%fr0,%0"
4786   [(set_attr "type" "fpmuldbl")
4787    (set_attr "length" "4")])
4788
4789 (define_insn ""
4790   [(set (match_operand:DF 0 "register_operand" "=f")
4791         (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
4792                          (match_operand:DF 2 "register_operand" "f"))))
4793    (set (match_operand:DF 3 "register_operand" "=&f")
4794         (mult:DF (match_dup 1) (match_dup 2)))]
4795   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
4796     && ! (reg_overlap_mentioned_p (operands[3], operands[1])
4797           || reg_overlap_mentioned_p (operands[3], operands[2])))"
4798   "#"
4799   [(set_attr "type" "fpmuldbl")
4800    (set_attr "length" "8")])
4801
4802 (define_split
4803   [(set (match_operand:DF 0 "register_operand" "=f")
4804         (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
4805                          (match_operand:DF 2 "register_operand" "f"))))
4806    (set (match_operand:DF 3 "register_operand" "=&f")
4807         (mult:DF (match_dup 1) (match_dup 2)))]
4808   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4809   [(set (match_dup 3) (mult:DF (match_dup 1) (match_dup 2)))
4810    (set (match_dup 0) (neg:DF (mult:DF (match_dup 1) (match_dup 2))))]
4811   "")
4812
4813 (define_insn ""
4814   [(set (match_operand:SF 0 "register_operand" "=f")
4815         (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
4816                          (match_operand:SF 2 "register_operand" "f"))))
4817    (set (match_operand:SF 3 "register_operand" "=&f")
4818         (mult:SF (match_dup 1) (match_dup 2)))]
4819   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
4820     && ! (reg_overlap_mentioned_p (operands[3], operands[1])
4821           || reg_overlap_mentioned_p (operands[3], operands[2])))"
4822   "#"
4823   [(set_attr "type" "fpmuldbl")
4824    (set_attr "length" "8")])
4825
4826 (define_split
4827   [(set (match_operand:SF 0 "register_operand" "=f")
4828         (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
4829                          (match_operand:SF 2 "register_operand" "f"))))
4830    (set (match_operand:SF 3 "register_operand" "=&f")
4831         (mult:SF (match_dup 1) (match_dup 2)))]
4832   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4833   [(set (match_dup 3) (mult:SF (match_dup 1) (match_dup 2)))
4834    (set (match_dup 0) (neg:SF (mult:SF (match_dup 1) (match_dup 2))))]
4835   "")
4836
4837 ;; Now fused multiplies with the result of the multiply negated.
4838 (define_insn ""
4839   [(set (match_operand:DF 0 "register_operand" "=f")
4840         (plus:DF (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
4841                                   (match_operand:DF 2 "register_operand" "f")))
4842                  (match_operand:DF 3 "register_operand" "f")))]
4843   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4844   "fmpynfadd,dbl %1,%2,%3,%0"
4845   [(set_attr "type" "fpmuldbl")
4846    (set_attr "length" "4")])
4847
4848 (define_insn ""
4849   [(set (match_operand:SF 0 "register_operand" "=f")
4850         (plus:SF (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
4851                          (match_operand:SF 2 "register_operand" "f")))
4852                  (match_operand:SF 3 "register_operand" "f")))]
4853   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4854   "fmpynfadd,sgl %1,%2,%3,%0"
4855   [(set_attr "type" "fpmuldbl")
4856    (set_attr "length" "4")])
4857
4858 (define_insn ""
4859   [(set (match_operand:DF 0 "register_operand" "=f")
4860         (plus:DF (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
4861                                   (match_operand:DF 2 "register_operand" "f")))
4862                  (match_operand:DF 3 "register_operand" "f")))
4863    (set (match_operand:DF 4 "register_operand" "=&f")
4864         (mult:DF (match_dup 1) (match_dup 2)))]
4865   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
4866     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
4867           || reg_overlap_mentioned_p (operands[4], operands[2])))"
4868   "#"
4869   [(set_attr "type" "fpmuldbl")
4870    (set_attr "length" "8")])
4871
4872 (define_split
4873   [(set (match_operand:DF 0 "register_operand" "=f")
4874         (plus:DF (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
4875                                   (match_operand:DF 2 "register_operand" "f")))
4876                  (match_operand:DF 3 "register_operand" "f")))
4877    (set (match_operand:DF 4 "register_operand" "=&f")
4878         (mult:DF (match_dup 1) (match_dup 2)))]
4879   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4880   [(set (match_dup 4) (mult:DF (match_dup 1) (match_dup 2)))
4881    (set (match_dup 0) (plus:DF (neg:DF (mult:DF (match_dup 1) (match_dup 2)))
4882                                (match_dup 3)))]
4883   "")
4884
4885 (define_insn ""
4886   [(set (match_operand:SF 0 "register_operand" "=f")
4887         (plus:SF (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
4888                                   (match_operand:SF 2 "register_operand" "f")))
4889                  (match_operand:SF 3 "register_operand" "f")))
4890    (set (match_operand:SF 4 "register_operand" "=&f")
4891         (mult:SF (match_dup 1) (match_dup 2)))]
4892   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
4893     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
4894           || reg_overlap_mentioned_p (operands[4], operands[2])))"
4895   "#"
4896   [(set_attr "type" "fpmuldbl")
4897    (set_attr "length" "8")])
4898
4899 (define_split
4900   [(set (match_operand:SF 0 "register_operand" "=f")
4901         (plus:SF (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
4902                                   (match_operand:SF 2 "register_operand" "f")))
4903                  (match_operand:SF 3 "register_operand" "f")))
4904    (set (match_operand:SF 4 "register_operand" "=&f")
4905         (mult:SF (match_dup 1) (match_dup 2)))]
4906   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4907   [(set (match_dup 4) (mult:SF (match_dup 1) (match_dup 2)))
4908    (set (match_dup 0) (plus:SF (neg:SF (mult:SF (match_dup 1) (match_dup 2)))
4909                                (match_dup 3)))]
4910   "")
4911
4912 (define_insn ""
4913   [(set (match_operand:DF 0 "register_operand" "=f")
4914         (minus:DF (match_operand:DF 3 "register_operand" "f")
4915                   (mult:DF (match_operand:DF 1 "register_operand" "f")
4916                            (match_operand:DF 2 "register_operand" "f"))))
4917    (set (match_operand:DF 4 "register_operand" "=&f")
4918         (mult:DF (match_dup 1) (match_dup 2)))]
4919   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
4920     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
4921           || reg_overlap_mentioned_p (operands[4], operands[2])))"
4922   "#"
4923   [(set_attr "type" "fpmuldbl")
4924    (set_attr "length" "8")])
4925
4926 (define_split
4927   [(set (match_operand:DF 0 "register_operand" "=f")
4928         (minus:DF (match_operand:DF 3 "register_operand" "f")
4929                   (mult:DF (match_operand:DF 1 "register_operand" "f")
4930                            (match_operand:DF 2 "register_operand" "f"))))
4931    (set (match_operand:DF 4 "register_operand" "=&f")
4932         (mult:DF (match_dup 1) (match_dup 2)))]
4933   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4934   [(set (match_dup 4) (mult:DF (match_dup 1) (match_dup 2)))
4935    (set (match_dup 0) (minus:DF (match_dup 3)
4936                                 (mult:DF (match_dup 1) (match_dup 2))))]
4937   "")
4938
4939 (define_insn ""
4940   [(set (match_operand:SF 0 "register_operand" "=f")
4941         (minus:SF (match_operand:SF 3 "register_operand" "f")
4942                   (mult:SF (match_operand:SF 1 "register_operand" "f")
4943                            (match_operand:SF 2 "register_operand" "f"))))
4944    (set (match_operand:SF 4 "register_operand" "=&f")
4945         (mult:SF (match_dup 1) (match_dup 2)))]
4946   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
4947     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
4948           || reg_overlap_mentioned_p (operands[4], operands[2])))"
4949   "#"
4950   [(set_attr "type" "fpmuldbl")
4951    (set_attr "length" "8")])
4952
4953 (define_split
4954   [(set (match_operand:SF 0 "register_operand" "=f")
4955         (minus:SF (match_operand:SF 3 "register_operand" "f")
4956                   (mult:SF (match_operand:SF 1 "register_operand" "f")
4957                            (match_operand:SF 2 "register_operand" "f"))))
4958    (set (match_operand:SF 4 "register_operand" "=&f")
4959         (mult:SF (match_dup 1) (match_dup 2)))]
4960   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4961   [(set (match_dup 4) (mult:SF (match_dup 1) (match_dup 2)))
4962    (set (match_dup 0) (minus:SF (match_dup 3)
4963                                 (mult:SF (match_dup 1) (match_dup 2))))]
4964   "")
4965
4966 (define_insn ""
4967   [(set (match_operand:DF 0 "register_operand" "=f")
4968         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))
4969    (set (match_operand:DF 2 "register_operand" "=&f") (abs:DF (match_dup 1)))]
4970   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
4971     && ! reg_overlap_mentioned_p (operands[2], operands[1]))"
4972   "#"
4973   [(set_attr "type" "fpalu")
4974    (set_attr "length" "8")])
4975
4976 (define_split
4977   [(set (match_operand:DF 0 "register_operand" "=f")
4978         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))
4979    (set (match_operand:DF 2 "register_operand" "=&f") (abs:DF (match_dup 1)))]
4980   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4981   [(set (match_dup 2) (abs:DF (match_dup 1)))
4982    (set (match_dup 0) (neg:DF (abs:DF (match_dup 1))))]
4983   "")
4984
4985 (define_insn ""
4986   [(set (match_operand:SF 0 "register_operand" "=f")
4987         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))
4988    (set (match_operand:SF 2 "register_operand" "=&f") (abs:SF (match_dup 1)))]
4989   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
4990     && ! reg_overlap_mentioned_p (operands[2], operands[1]))"
4991   "#"
4992   [(set_attr "type" "fpalu")
4993    (set_attr "length" "8")])
4994
4995 (define_split
4996   [(set (match_operand:SF 0 "register_operand" "=f")
4997         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))
4998    (set (match_operand:SF 2 "register_operand" "=&f") (abs:SF (match_dup 1)))]
4999   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5000   [(set (match_dup 2) (abs:SF (match_dup 1)))
5001    (set (match_dup 0) (neg:SF (abs:SF (match_dup 1))))]
5002   "")
5003 \f
5004 ;;- Shift instructions
5005
5006 ;; Optimized special case of shifting.
5007
5008 (define_insn ""
5009   [(set (match_operand:SI 0 "register_operand" "=r")
5010         (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
5011                      (const_int 24)))]
5012   ""
5013   "ldb%M1 %1,%0"
5014   [(set_attr "type" "load")
5015    (set_attr "length" "4")])
5016
5017 (define_insn ""
5018   [(set (match_operand:SI 0 "register_operand" "=r")
5019         (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
5020                      (const_int 16)))]
5021   ""
5022   "ldh%M1 %1,%0"
5023   [(set_attr "type" "load")
5024    (set_attr "length" "4")])
5025
5026 (define_insn ""
5027   [(set (match_operand:SI 0 "register_operand" "=r")
5028         (plus:SI (mult:SI (match_operand:SI 2 "register_operand" "r")
5029                           (match_operand:SI 3 "shadd_operand" ""))
5030                  (match_operand:SI 1 "register_operand" "r")))]
5031   ""
5032   "{sh%O3addl %2,%1,%0|shladd,l %2,%O3,%1,%0} "
5033   [(set_attr "type" "binary")
5034    (set_attr "length" "4")])
5035
5036 (define_insn ""
5037   [(set (match_operand:DI 0 "register_operand" "=r")
5038         (plus:DI (mult:DI (match_operand:DI 2 "register_operand" "r")
5039                           (match_operand:DI 3 "shadd_operand" ""))
5040                  (match_operand:DI 1 "register_operand" "r")))]
5041   "TARGET_64BIT"
5042   "shladd,l %2,%O3,%1,%0"
5043   [(set_attr "type" "binary")
5044    (set_attr "length" "4")])
5045
5046 (define_expand "ashlsi3"
5047   [(set (match_operand:SI 0 "register_operand" "")
5048         (ashift:SI (match_operand:SI 1 "lhs_lshift_operand" "")
5049                    (match_operand:SI 2 "arith32_operand" "")))]
5050   ""
5051   "
5052 {
5053   if (GET_CODE (operands[2]) != CONST_INT)
5054     {
5055       rtx temp = gen_reg_rtx (SImode);
5056       emit_insn (gen_subsi3 (temp, GEN_INT (31), operands[2]));
5057       if (GET_CODE (operands[1]) == CONST_INT)
5058         emit_insn (gen_zvdep_imm32 (operands[0], operands[1], temp));
5059       else
5060         emit_insn (gen_zvdep32 (operands[0], operands[1], temp));
5061       DONE;
5062     }
5063   /* Make sure both inputs are not constants,
5064      there are no patterns for that.  */
5065   operands[1] = force_reg (SImode, operands[1]);
5066 }")
5067
5068 (define_insn ""
5069   [(set (match_operand:SI 0 "register_operand" "=r")
5070         (ashift:SI (match_operand:SI 1 "register_operand" "r")
5071                    (match_operand:SI 2 "const_int_operand" "n")))]
5072   ""
5073   "{zdep|depw,z} %1,%P2,%L2,%0"
5074   [(set_attr "type" "shift")
5075    (set_attr "length" "4")])
5076
5077 ; Match cases of op1 a CONST_INT here that zvdep_imm32 doesn't handle.
5078 ; Doing it like this makes slightly better code since reload can
5079 ; replace a register with a known value in range -16..15 with a
5080 ; constant.  Ideally, we would like to merge zvdep32 and zvdep_imm32,
5081 ; but since we have no more CONST_OK... characters, that is not
5082 ; possible.
5083 (define_insn "zvdep32"
5084   [(set (match_operand:SI 0 "register_operand" "=r,r")
5085         (ashift:SI (match_operand:SI 1 "arith5_operand" "r,L")
5086                    (minus:SI (const_int 31)
5087                              (match_operand:SI 2 "register_operand" "q,q"))))]
5088   ""
5089   "@
5090    {zvdep %1,32,%0|depw,z %1,%%sar,32,%0}
5091    {zvdepi %1,32,%0|depwi,z %1,%%sar,32,%0}"
5092   [(set_attr "type" "shift,shift")
5093    (set_attr "length" "4,4")])
5094
5095 (define_insn "zvdep_imm32"
5096   [(set (match_operand:SI 0 "register_operand" "=r")
5097         (ashift:SI (match_operand:SI 1 "lhs_lshift_cint_operand" "")
5098                    (minus:SI (const_int 31)
5099                              (match_operand:SI 2 "register_operand" "q"))))]
5100   ""
5101   "*
5102 {
5103   int x = INTVAL (operands[1]);
5104   operands[2] = GEN_INT (4 + exact_log2 ((x >> 4) + 1));
5105   operands[1] = GEN_INT ((x & 0xf) - 0x10);
5106   return \"{zvdepi %1,%2,%0|depwi,z %1,%%sar,%2,%0}\";
5107 }"
5108   [(set_attr "type" "shift")
5109    (set_attr "length" "4")])
5110
5111 (define_insn "vdepi_ior"
5112   [(set (match_operand:SI 0 "register_operand" "=r")
5113         (ior:SI (ashift:SI (match_operand:SI 1 "const_int_operand" "")
5114                            (minus:SI (const_int 31)
5115                                      (match_operand:SI 2 "register_operand" "q")))
5116                 (match_operand:SI 3 "register_operand" "0")))]
5117   ; accept ...0001...1, can this be generalized?
5118   "exact_log2 (INTVAL (operands[1]) + 1) >= 0"
5119   "*
5120 {
5121   int x = INTVAL (operands[1]);
5122   operands[2] = GEN_INT (exact_log2 (x + 1));
5123   return \"{vdepi -1,%2,%0|depwi -1,%%sar,%2,%0}\";
5124 }"
5125   [(set_attr "type" "shift")
5126    (set_attr "length" "4")])
5127
5128 (define_insn "vdepi_and"
5129   [(set (match_operand:SI 0 "register_operand" "=r")
5130         (and:SI (rotate:SI (match_operand:SI 1 "const_int_operand" "")
5131                            (minus:SI (const_int 31)
5132                                      (match_operand:SI 2 "register_operand" "q")))
5133                 (match_operand:SI 3 "register_operand" "0")))]
5134   ; this can be generalized...!
5135   "INTVAL (operands[1]) == -2"
5136   "*
5137 {
5138   int x = INTVAL (operands[1]);
5139   operands[2] = GEN_INT (exact_log2 ((~x) + 1));
5140   return \"{vdepi 0,%2,%0|depwi 0,%%sar,%2,%0}\";
5141 }"
5142   [(set_attr "type" "shift")
5143    (set_attr "length" "4")])
5144
5145 (define_expand "ashldi3"
5146   [(set (match_operand:DI 0 "register_operand" "")
5147         (ashift:DI (match_operand:DI 1 "lhs_lshift_operand" "")
5148                    (match_operand:DI 2 "arith32_operand" "")))]
5149   "TARGET_64BIT"
5150   "
5151 {
5152   if (GET_CODE (operands[2]) != CONST_INT)
5153     {
5154       rtx temp = gen_reg_rtx (DImode);
5155       emit_insn (gen_subdi3 (temp, GEN_INT (63), operands[2]));
5156       if (GET_CODE (operands[1]) == CONST_INT)
5157         emit_insn (gen_zvdep_imm64 (operands[0], operands[1], temp));
5158       else
5159         emit_insn (gen_zvdep64 (operands[0], operands[1], temp));
5160       DONE;
5161     }
5162   /* Make sure both inputs are not constants,
5163      there are no patterns for that.  */
5164   operands[1] = force_reg (DImode, operands[1]);
5165 }")
5166
5167 (define_insn ""
5168   [(set (match_operand:DI 0 "register_operand" "=r")
5169         (ashift:DI (match_operand:DI 1 "register_operand" "r")
5170                    (match_operand:DI 2 "const_int_operand" "n")))]
5171   "TARGET_64BIT"
5172   "depd,z %1,%p2,%Q2,%0"
5173   [(set_attr "type" "shift")
5174    (set_attr "length" "4")])
5175
5176 ; Match cases of op1 a CONST_INT here that zvdep_imm64 doesn't handle.
5177 ; Doing it like this makes slightly better code since reload can
5178 ; replace a register with a known value in range -16..15 with a
5179 ; constant.  Ideally, we would like to merge zvdep64 and zvdep_imm64,
5180 ; but since we have no more CONST_OK... characters, that is not
5181 ; possible.
5182 (define_insn "zvdep64"
5183   [(set (match_operand:DI 0 "register_operand" "=r,r")
5184         (ashift:DI (match_operand:DI 1 "arith5_operand" "r,L")
5185                    (minus:DI (const_int 63)
5186                              (match_operand:DI 2 "register_operand" "q,q"))))]
5187   "TARGET_64BIT"
5188   "@
5189    depd,z %1,%%sar,64,%0
5190    depdi,z %1,%%sar,64,%0"
5191   [(set_attr "type" "shift,shift")
5192    (set_attr "length" "4,4")])
5193
5194 (define_insn "zvdep_imm64"
5195   [(set (match_operand:DI 0 "register_operand" "=r")
5196         (ashift:DI (match_operand:DI 1 "lhs_lshift_cint_operand" "")
5197                    (minus:DI (const_int 63)
5198                              (match_operand:DI 2 "register_operand" "q"))))]
5199   "TARGET_64BIT"
5200   "*
5201 {
5202   int x = INTVAL (operands[1]);
5203   operands[2] = GEN_INT (4 + exact_log2 ((x >> 4) + 1));
5204   operands[1] = GEN_INT ((x & 0x1f) - 0x20);
5205   return \"depdi,z %1,%%sar,%2,%0\";
5206 }"
5207   [(set_attr "type" "shift")
5208    (set_attr "length" "4")])
5209
5210 (define_insn ""
5211   [(set (match_operand:DI 0 "register_operand" "=r")
5212         (ior:DI (ashift:DI (match_operand:DI 1 "const_int_operand" "")
5213                            (minus:DI (const_int 63)
5214                                      (match_operand:DI 2 "register_operand" "q")))
5215                 (match_operand:DI 3 "register_operand" "0")))]
5216   ; accept ...0001...1, can this be generalized?
5217   "TARGET_64BIT && exact_log2 (INTVAL (operands[1]) + 1) >= 0"
5218   "*
5219 {
5220   int x = INTVAL (operands[1]);
5221   operands[2] = GEN_INT (exact_log2 (x + 1));
5222   return \"depdi -1,%%sar,%2,%0\";
5223 }"
5224   [(set_attr "type" "shift")
5225    (set_attr "length" "4")])
5226
5227 (define_insn ""
5228   [(set (match_operand:DI 0 "register_operand" "=r")
5229         (and:DI (rotate:DI (match_operand:DI 1 "const_int_operand" "")
5230                            (minus:DI (const_int 63)
5231                                      (match_operand:DI 2 "register_operand" "q")))
5232                 (match_operand:DI 3 "register_operand" "0")))]
5233   ; this can be generalized...!
5234   "TARGET_64BIT && INTVAL (operands[1]) == -2"
5235   "*
5236 {
5237   int x = INTVAL (operands[1]);
5238   operands[2] = GEN_INT (exact_log2 ((~x) + 1));
5239   return \"depdi 0,%%sar,%2,%0\";
5240 }"
5241   [(set_attr "type" "shift")
5242    (set_attr "length" "4")])
5243
5244 (define_expand "ashrsi3"
5245   [(set (match_operand:SI 0 "register_operand" "")
5246         (ashiftrt:SI (match_operand:SI 1 "register_operand" "")
5247                      (match_operand:SI 2 "arith32_operand" "")))]
5248   ""
5249   "
5250 {
5251   if (GET_CODE (operands[2]) != CONST_INT)
5252     {
5253       rtx temp = gen_reg_rtx (SImode);
5254       emit_insn (gen_subsi3 (temp, GEN_INT (31), operands[2]));
5255       emit_insn (gen_vextrs32 (operands[0], operands[1], temp));
5256       DONE;
5257     }
5258 }")
5259
5260 (define_insn ""
5261   [(set (match_operand:SI 0 "register_operand" "=r")
5262         (ashiftrt:SI (match_operand:SI 1 "register_operand" "r")
5263                      (match_operand:SI 2 "const_int_operand" "n")))]
5264   ""
5265   "{extrs|extrw,s} %1,%P2,%L2,%0"
5266   [(set_attr "type" "shift")
5267    (set_attr "length" "4")])
5268
5269 (define_insn "vextrs32"
5270   [(set (match_operand:SI 0 "register_operand" "=r")
5271         (ashiftrt:SI (match_operand:SI 1 "register_operand" "r")
5272                      (minus:SI (const_int 31)
5273                                (match_operand:SI 2 "register_operand" "q"))))]
5274   ""
5275   "{vextrs %1,32,%0|extrw,s %1,%%sar,32,%0}"
5276   [(set_attr "type" "shift")
5277    (set_attr "length" "4")])
5278
5279 (define_expand "ashrdi3"
5280   [(set (match_operand:DI 0 "register_operand" "")
5281         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
5282                      (match_operand:DI 2 "arith32_operand" "")))]
5283   "TARGET_64BIT"
5284   "
5285 {
5286   if (GET_CODE (operands[2]) != CONST_INT)
5287     {
5288       rtx temp = gen_reg_rtx (DImode);
5289       emit_insn (gen_subdi3 (temp, GEN_INT (63), operands[2]));
5290       emit_insn (gen_vextrs64 (operands[0], operands[1], temp));
5291       DONE;
5292     }
5293 }")
5294
5295 (define_insn ""
5296   [(set (match_operand:DI 0 "register_operand" "=r")
5297         (ashiftrt:DI (match_operand:DI 1 "register_operand" "r")
5298                      (match_operand:DI 2 "const_int_operand" "n")))]
5299   "TARGET_64BIT"
5300   "extrd,s %1,%p2,%Q2,%0"
5301   [(set_attr "type" "shift")
5302    (set_attr "length" "4")])
5303
5304 (define_insn "vextrs64"
5305   [(set (match_operand:DI 0 "register_operand" "=r")
5306         (ashiftrt:DI (match_operand:DI 1 "register_operand" "r")
5307                      (minus:DI (const_int 63)
5308                                (match_operand:DI 2 "register_operand" "q"))))]
5309   "TARGET_64BIT"
5310   "extrd,s %1,%%sar,64,%0"
5311   [(set_attr "type" "shift")
5312    (set_attr "length" "4")])
5313
5314 (define_insn "lshrsi3"
5315   [(set (match_operand:SI 0 "register_operand" "=r,r")
5316         (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
5317                      (match_operand:SI 2 "arith32_operand" "q,n")))]
5318   ""
5319   "@
5320    {vshd %%r0,%1,%0|shrpw %%r0,%1,%%sar,%0}
5321    {extru|extrw,u} %1,%P2,%L2,%0"
5322   [(set_attr "type" "shift")
5323    (set_attr "length" "4")])
5324
5325 (define_insn "lshrdi3"
5326   [(set (match_operand:DI 0 "register_operand" "=r,r")
5327         (lshiftrt:DI (match_operand:DI 1 "register_operand" "r,r")
5328                      (match_operand:DI 2 "arith32_operand" "q,n")))]
5329   "TARGET_64BIT"
5330   "@
5331    shrpd %%r0,%1,%%sar,%0
5332    extrd,u %1,%p2,%Q2,%0"
5333   [(set_attr "type" "shift")
5334    (set_attr "length" "4")])
5335
5336 (define_insn "rotrsi3"
5337   [(set (match_operand:SI 0 "register_operand" "=r,r")
5338         (rotatert:SI (match_operand:SI 1 "register_operand" "r,r")
5339                      (match_operand:SI 2 "arith32_operand" "q,n")))]
5340   ""
5341   "*
5342 {
5343   if (GET_CODE (operands[2]) == CONST_INT)
5344     {
5345       operands[2] = GEN_INT (INTVAL (operands[2]) & 31);
5346       return \"{shd|shrpw} %1,%1,%2,%0\";
5347     }
5348   else
5349     return \"{vshd %1,%1,%0|shrpw %1,%1,%%sar,%0}\";
5350 }"
5351   [(set_attr "type" "shift")
5352    (set_attr "length" "4")])
5353
5354 (define_expand "rotlsi3"
5355   [(set (match_operand:SI 0 "register_operand" "")
5356         (rotate:SI (match_operand:SI 1 "register_operand" "")
5357                    (match_operand:SI 2 "arith32_operand" "")))]
5358   ""
5359   "
5360 {
5361   if (GET_CODE (operands[2]) != CONST_INT)
5362     {
5363       rtx temp = gen_reg_rtx (SImode);
5364       emit_insn (gen_subsi3 (temp, GEN_INT (32), operands[2]));
5365       emit_insn (gen_rotrsi3 (operands[0], operands[1], temp));
5366       DONE;
5367     }
5368   /* Else expand normally.  */
5369 }")
5370
5371 (define_insn ""
5372   [(set (match_operand:SI 0 "register_operand" "=r")
5373         (rotate:SI (match_operand:SI 1 "register_operand" "r")
5374                    (match_operand:SI 2 "const_int_operand" "n")))]
5375   ""
5376   "*
5377 {
5378   operands[2] = GEN_INT ((32 - INTVAL (operands[2])) & 31);
5379   return \"{shd|shrpw} %1,%1,%2,%0\";
5380 }"
5381   [(set_attr "type" "shift")
5382    (set_attr "length" "4")])
5383
5384 (define_insn ""
5385   [(set (match_operand:SI 0 "register_operand" "=r")
5386         (match_operator:SI 5 "plus_xor_ior_operator"
5387           [(ashift:SI (match_operand:SI 1 "register_operand" "r")
5388                       (match_operand:SI 3 "const_int_operand" "n"))
5389            (lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
5390                         (match_operand:SI 4 "const_int_operand" "n"))]))]
5391   "INTVAL (operands[3]) + INTVAL (operands[4]) == 32"
5392   "{shd|shrpw} %1,%2,%4,%0"
5393   [(set_attr "type" "shift")
5394    (set_attr "length" "4")])
5395
5396 (define_insn ""
5397   [(set (match_operand:SI 0 "register_operand" "=r")
5398         (match_operator:SI 5 "plus_xor_ior_operator"
5399           [(lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
5400                         (match_operand:SI 4 "const_int_operand" "n"))
5401            (ashift:SI (match_operand:SI 1 "register_operand" "r")
5402                       (match_operand:SI 3 "const_int_operand" "n"))]))]
5403   "INTVAL (operands[3]) + INTVAL (operands[4]) == 32"
5404   "{shd|shrpw} %1,%2,%4,%0"
5405   [(set_attr "type" "shift")
5406    (set_attr "length" "4")])
5407
5408 (define_insn ""
5409   [(set (match_operand:SI 0 "register_operand" "=r")
5410         (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
5411                            (match_operand:SI 2 "const_int_operand" ""))
5412                 (match_operand:SI 3 "const_int_operand" "")))]
5413   "exact_log2 (1 + (INTVAL (operands[3]) >> (INTVAL (operands[2]) & 31))) >= 0"
5414   "*
5415 {
5416   int cnt = INTVAL (operands[2]) & 31;
5417   operands[3] = GEN_INT (exact_log2 (1 + (INTVAL (operands[3]) >> cnt)));
5418   operands[2] = GEN_INT (31 - cnt);
5419   return \"{zdep|depw,z} %1,%2,%3,%0\";
5420 }"
5421   [(set_attr "type" "shift")
5422    (set_attr "length" "4")])
5423 \f
5424 ;; Unconditional and other jump instructions.
5425
5426 ;; This can only be used in a leaf function, so we do
5427 ;; not need to use the PIC register when generating PIC code.
5428 (define_insn "return"
5429   [(return)
5430    (use (reg:SI 2))
5431    (const_int 0)]
5432   "hppa_can_use_return_insn_p ()"
5433   "*
5434 {
5435   if (TARGET_PA_20)
5436     return \"bve%* (%%r2)\";
5437   return \"bv%* %%r0(%%r2)\";
5438 }"
5439   [(set_attr "type" "branch")
5440    (set_attr "length" "4")])
5441
5442 ;; Emit a different pattern for functions which have non-trivial
5443 ;; epilogues so as not to confuse jump and reorg.
5444 (define_insn "return_internal"
5445   [(return)
5446    (use (reg:SI 2))
5447    (const_int 1)]
5448   "! flag_pic"
5449   "*
5450 {
5451   if (TARGET_PA_20)
5452     return \"bve%* (%%r2)\";
5453   return \"bv%* %%r0(%%r2)\";
5454 }"
5455   [(set_attr "type" "branch")
5456    (set_attr "length" "4")])
5457
5458 ;; Use the PIC register to ensure it's restored after a
5459 ;; call in PIC mode.
5460 (define_insn "return_internal_pic"
5461   [(return)
5462    (use (match_operand 0 "register_operand" "r"))
5463    (use (reg:SI 2))]
5464   "flag_pic && true_regnum (operands[0]) == PIC_OFFSET_TABLE_REGNUM"
5465   "*
5466 {
5467   if (TARGET_PA_20)
5468     return \"bve%* (%%r2)\";
5469   return \"bv%* %%r0(%%r2)\";
5470 }"
5471   [(set_attr "type" "branch")
5472    (set_attr "length" "4")])
5473
5474 (define_expand "prologue"
5475   [(const_int 0)]
5476   ""
5477   "hppa_expand_prologue ();DONE;")
5478
5479 (define_expand "sibcall_epilogue"
5480   [(return)]
5481   ""
5482   "
5483 {
5484   hppa_expand_epilogue ();
5485   DONE;
5486 }")
5487
5488 (define_expand "epilogue"
5489   [(return)]
5490   ""
5491   "
5492 {
5493   /* Try to use the trivial return first.  Else use the full
5494      epilogue.  */
5495   if (hppa_can_use_return_insn_p ())
5496    emit_jump_insn (gen_return ());
5497   else
5498     {
5499       rtx x;
5500
5501       hppa_expand_epilogue ();
5502       if (flag_pic)
5503         x = gen_return_internal_pic (gen_rtx_REG (word_mode,
5504                                                   PIC_OFFSET_TABLE_REGNUM));
5505       else
5506         x = gen_return_internal ();
5507       emit_jump_insn (x);
5508     }
5509   DONE;
5510 }")
5511
5512 ;; Special because we use the value placed in %r2 by the bl instruction
5513 ;; from within its delay slot to set the value for the 2nd parameter to
5514 ;; the call.
5515 (define_insn "call_profiler"
5516   [(unspec_volatile [(const_int 0)] 0)
5517    (use (match_operand:SI 0 "const_int_operand" ""))]
5518   ""
5519   "{bl|b,l} _mcount,%%r2\;ldo %0(%%r2),%%r25"
5520   [(set_attr "type" "multi")
5521    (set_attr "length" "8")])
5522
5523 (define_insn "blockage"
5524   [(unspec_volatile [(const_int 2)] 0)]
5525   ""
5526   ""
5527   [(set_attr "length" "0")])
5528
5529 (define_insn "jump"
5530   [(set (pc) (label_ref (match_operand 0 "" "")))]
5531   ""
5532   "*
5533 {
5534   extern int optimize;
5535
5536   if (GET_MODE (insn) == SImode)
5537     return \"b %l0%#\";
5538
5539   /* An unconditional branch which can reach its target.  */
5540   if (get_attr_length (insn) != 24
5541       && get_attr_length (insn) != 16)
5542     return \"b%* %l0\";
5543
5544   /* An unconditional branch which can not reach its target.
5545
5546      We need to be able to use %r1 as a scratch register; however,
5547      we can never be sure whether or not it's got a live value in
5548      it.  Therefore, we must restore its original value after the
5549      jump.
5550
5551      To make matters worse, we don't have a stack slot which we
5552      can always clobber.  sp-12/sp-16 shouldn't ever have a live
5553      value during a non-optimizing compilation, so we use those
5554      slots for now.  We don't support very long branches when
5555      optimizing -- they should be quite rare when optimizing.
5556
5557      Really the way to go long term is a register scavenger; goto
5558      the target of the jump and find a register which we can use
5559      as a scratch to hold the value in %r1.  */
5560
5561   /* We don't know how to register scavenge yet.  */
5562   if (optimize)
5563     abort ();
5564
5565   /* First store %r1 into the stack.  */
5566   output_asm_insn (\"stw %%r1,-16(%%r30)\", operands);
5567
5568   /* Now load the target address into %r1 and do an indirect jump
5569      to the value specified in %r1.  Be careful to generate PIC
5570      code as needed.  */
5571   if (flag_pic)
5572     {
5573       rtx xoperands[2];
5574       xoperands[0] = operands[0];
5575       xoperands[1] = gen_label_rtx ();
5576
5577       output_asm_insn (\"{bl|b,l} .+8,%%r1\\n\\taddil L'%l0-%l1,%%r1\",
5578                        xoperands);
5579       ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\",
5580                                  CODE_LABEL_NUMBER (xoperands[1]));
5581       output_asm_insn (\"ldo R'%l0-%l1(%%r1),%%r1\\n\\tbv %%r0(%%r1)\",
5582                        xoperands);
5583     }
5584   else
5585     output_asm_insn (\"ldil L'%l0,%%r1\\n\\tbe R'%l0(%%sr4,%%r1)\", operands);;
5586
5587   /* And restore the value of %r1 in the delay slot.  We're not optimizing,
5588      so we know nothing else can be in the delay slot.  */
5589   return \"ldw -16(%%r30),%%r1\";
5590 }"
5591   [(set_attr "type" "uncond_branch")
5592    (set_attr "pa_combine_type" "uncond_branch")
5593    (set (attr "length")
5594     (cond [(eq (symbol_ref "jump_in_call_delay (insn)") (const_int 1))
5595            (if_then_else (lt (abs (minus (match_dup 0)
5596                                          (plus (pc) (const_int 8))))
5597                              (const_int 8184))
5598                          (const_int 4)
5599                          (const_int 8))
5600            (ge (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
5601                (const_int 262100))
5602            (if_then_else (eq (symbol_ref "flag_pic") (const_int 0))
5603                          (const_int 16)
5604                          (const_int 24))]
5605           (const_int 4)))])
5606
5607 ;; Subroutines of "casesi".
5608 ;; operand 0 is index
5609 ;; operand 1 is the minimum bound
5610 ;; operand 2 is the maximum bound - minimum bound + 1
5611 ;; operand 3 is CODE_LABEL for the table;
5612 ;; operand 4 is the CODE_LABEL to go to if index out of range.
5613
5614 (define_expand "casesi"
5615   [(match_operand:SI 0 "general_operand" "")
5616    (match_operand:SI 1 "const_int_operand" "")
5617    (match_operand:SI 2 "const_int_operand" "")
5618    (match_operand 3 "" "")
5619    (match_operand 4 "" "")]
5620   ""
5621   "
5622 {
5623   if (GET_CODE (operands[0]) != REG)
5624     operands[0] = force_reg (SImode, operands[0]);
5625
5626   if (operands[1] != const0_rtx)
5627     {
5628       rtx reg = gen_reg_rtx (SImode);
5629
5630       operands[1] = GEN_INT (-INTVAL (operands[1]));
5631       if (!INT_14_BITS (operands[1]))
5632         operands[1] = force_reg (SImode, operands[1]);
5633       emit_insn (gen_addsi3 (reg, operands[0], operands[1]));
5634
5635       operands[0] = reg;
5636     }
5637
5638   /* In 64bit mode we must make sure to wipe the upper bits of the register
5639      just in case the addition overflowed or we had random bits in the
5640      high part of the register.  */
5641   if (TARGET_64BIT)
5642     {
5643       rtx reg = gen_reg_rtx (DImode);
5644       emit_insn (gen_extendsidi2 (reg, operands[0]));
5645       operands[0] = gen_rtx_SUBREG (SImode, reg, 0);
5646     }
5647
5648   if (!INT_5_BITS (operands[2]))
5649     operands[2] = force_reg (SImode, operands[2]);
5650
5651   emit_insn (gen_cmpsi (operands[0], operands[2]));
5652   emit_jump_insn (gen_bgtu (operands[4]));
5653   if (TARGET_BIG_SWITCH)
5654     {
5655       rtx temp = gen_reg_rtx (SImode);
5656       emit_move_insn (temp, gen_rtx_PLUS (SImode, operands[0], operands[0]));
5657       operands[0] = temp;
5658     }
5659   emit_jump_insn (gen_casesi0 (operands[0], operands[3]));
5660   DONE;
5661 }")
5662
5663 (define_insn "casesi0"
5664   [(set (pc) (plus:SI
5665                (mem:SI (plus:SI (pc)
5666                                 (match_operand:SI 0 "register_operand" "r")))
5667                (label_ref (match_operand 1 "" ""))))]
5668   ""
5669   "blr %0,%%r0\;nop"
5670   [(set_attr "type" "multi")
5671    (set_attr "length" "8")])
5672
5673 ;; Need nops for the calls because execution is supposed to continue
5674 ;; past; we don't want to nullify an instruction that we need.
5675 ;;- jump to subroutine
5676
5677 (define_expand "call"
5678   [(parallel [(call (match_operand:SI 0 "" "")
5679                     (match_operand 1 "" ""))
5680               (clobber (reg:SI 2))])]
5681   ""
5682   "
5683 {
5684   rtx op;
5685   rtx call_insn;
5686
5687   if (TARGET_PORTABLE_RUNTIME)
5688     op = force_reg (SImode, XEXP (operands[0], 0));
5689   else
5690     op = XEXP (operands[0], 0);
5691
5692   if (TARGET_64BIT)
5693     emit_move_insn (arg_pointer_rtx,
5694                     gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
5695                                   GEN_INT (64)));
5696
5697   if (flag_pic && PIC_OFFSET_TABLE_SAVE_RTX == NULL_RTX)
5698     hppa_init_pic_save ();
5699
5700   /* Use two different patterns for calls to explicitly named functions
5701      and calls through function pointers.  This is necessary as these two
5702      types of calls use different calling conventions, and CSE might try
5703      to change the named call into an indirect call in some cases (using
5704      two patterns keeps CSE from performing this optimization).  */
5705   if (GET_CODE (op) == SYMBOL_REF)
5706     call_insn = emit_call_insn (gen_call_internal_symref (op, operands[1]));
5707   else if (TARGET_64BIT)
5708     {
5709       rtx tmpreg = force_reg (word_mode, op);
5710       call_insn = emit_call_insn (gen_call_internal_reg_64bit (tmpreg,
5711                                                                operands[1]));
5712     }
5713   else
5714     {
5715       rtx tmpreg = gen_rtx_REG (word_mode, 22);
5716       emit_move_insn (tmpreg, force_reg (word_mode, op));
5717       call_insn = emit_call_insn (gen_call_internal_reg (operands[1]));
5718     }
5719
5720   if (flag_pic)
5721     {
5722       use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
5723       if (TARGET_64BIT)
5724         use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), arg_pointer_rtx);
5725
5726       /* After each call we must restore the PIC register, even if it
5727          doesn't appear to be used.  */
5728       emit_move_insn (pic_offset_table_rtx, PIC_OFFSET_TABLE_SAVE_RTX);
5729     }
5730   DONE;
5731 }")
5732
5733 (define_insn "call_internal_symref"
5734   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
5735          (match_operand 1 "" "i"))
5736    (clobber (reg:SI 2))
5737    (use (const_int 0))]
5738   "! TARGET_PORTABLE_RUNTIME"
5739   "*
5740 {
5741   output_arg_descriptor (insn);
5742   return output_call (insn, operands[0], 0);
5743 }"
5744   [(set_attr "type" "call")
5745    (set (attr "length")
5746 ;;       If we're sure that we can either reach the target or that the
5747 ;;       linker can use a long-branch stub, then the length is 4 bytes.
5748 ;;
5749 ;;       For long-calls the length will be either 52 bytes (non-pic)
5750 ;;       or 68 bytes (pic).  */
5751 ;;       Else we have to use a long-call;
5752       (if_then_else (lt (plus (symbol_ref "total_code_bytes") (pc))
5753                         (const_int 240000))
5754                     (const_int 4)
5755                     (if_then_else (eq (symbol_ref "flag_pic")
5756                                       (const_int 0))
5757                                   (const_int 52)
5758                                   (const_int 68))))])
5759
5760 (define_insn "call_internal_reg_64bit"
5761   [(call (mem:SI (match_operand:DI 0 "register_operand" "r"))
5762          (match_operand 1 "" "i"))
5763    (clobber (reg:SI 2))
5764    (use (const_int 1))]
5765   "TARGET_64BIT"
5766   "*
5767 {
5768   rtx xoperands[2];
5769
5770   /* ??? Needs more work.  Length computation, split into multiple insns,
5771      do not use %r22 directly, expose delay slot.  */
5772   return \"ldd 16(%0),%%r2\;ldd 24(%0),%%r27\;bve,l (%%r2),%%r2\;nop\";
5773 }"
5774   [(set_attr "type" "dyncall")
5775    (set (attr "length") (const_int 16))])
5776
5777 (define_insn "call_internal_reg"
5778   [(call (mem:SI (reg:SI 22))
5779          (match_operand 0 "" "i"))
5780    (clobber (reg:SI 2))
5781    (use (const_int 1))]
5782   ""
5783   "*
5784 {
5785   rtx xoperands[2];
5786
5787   /* First the special case for kernels, level 0 systems, etc.  */
5788   if (TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS)
5789     return \"ble 0(%%sr4,%%r22)\;copy %%r31,%%r2\";
5790
5791   /* Now the normal case -- we can reach $$dyncall directly or
5792      we're sure that we can get there via a long-branch stub. 
5793
5794      No need to check target flags as the length uniquely identifies
5795      the remaining cases.  */
5796   if (get_attr_length (insn) == 8)
5797     return \".CALL\\tARGW0=GR\;{bl|b,l} $$dyncall,%%r31\;copy %%r31,%%r2\";
5798
5799   /* Long millicode call, but we are not generating PIC or portable runtime
5800      code.  */
5801   if (get_attr_length (insn) == 12)
5802     return \".CALL\\tARGW0=GR\;ldil L%%$$dyncall,%%r2\;ble R%%$$dyncall(%%sr4,%%r2)\;copy %%r31,%%r2\";
5803
5804   /* Long millicode call for portable runtime.  */
5805   if (get_attr_length (insn) == 20)
5806     return \"ldil L%%$$dyncall,%%r31\;ldo R%%$$dyncall(%%r31),%%r31\;blr %%r0,%%r2\;bv,n %%r0(%%r31)\;nop\";
5807
5808   /* If we're generating PIC code.  */
5809   xoperands[0] = operands[0];
5810   xoperands[1] = gen_label_rtx ();
5811   output_asm_insn (\"{bl|b,l} .+8,%%r1\", xoperands);
5812   output_asm_insn (\"addil L%%$$dyncall-%1,%%r1\", xoperands);
5813   ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\",
5814                              CODE_LABEL_NUMBER (xoperands[1]));
5815   output_asm_insn (\"ldo R%%$$dyncall-%1(%%r1),%%r1\", xoperands);
5816   output_asm_insn (\"blr %%r0,%%r2\", xoperands);
5817   output_asm_insn (\"bv,n %%r0(%%r1)\\n\\tnop\", xoperands);
5818   return \"\";
5819 }"
5820   [(set_attr "type" "dyncall")
5821    (set (attr "length")
5822      (cond [
5823 ;; First NO_SPACE_REGS
5824             (ne (symbol_ref "TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS")
5825                 (const_int 0))
5826             (const_int 8)
5827
5828 ;; Target (or stub) within reach
5829             (and (lt (plus (symbol_ref "total_code_bytes") (pc))
5830                      (const_int 240000))
5831                  (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
5832                      (const_int 0)))
5833             (const_int 8)
5834
5835 ;; Out of reach, but not PIC or PORTABLE_RUNTIME
5836             (and (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
5837                      (const_int 0))
5838                  (eq (symbol_ref "flag_pic")
5839                      (const_int 0)))
5840             (const_int 12)
5841
5842             (ne (symbol_ref "TARGET_PORTABLE_RUNTIME")
5843                 (const_int 0))
5844             (const_int 20)]
5845
5846 ;; Out of range PIC case
5847           (const_int 24)))])
5848
5849 (define_expand "call_value"
5850   [(parallel [(set (match_operand 0 "" "")
5851                    (call (match_operand:SI 1 "" "")
5852                          (match_operand 2 "" "")))
5853               (clobber (reg:SI 2))])]
5854   ""
5855   "
5856 {
5857   rtx op;
5858   rtx call_insn;
5859
5860   if (TARGET_PORTABLE_RUNTIME)
5861     op = force_reg (word_mode, XEXP (operands[1], 0));
5862   else
5863     op = XEXP (operands[1], 0);
5864
5865   if (TARGET_64BIT)
5866     emit_move_insn (arg_pointer_rtx,
5867                     gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
5868                                   GEN_INT (64)));
5869
5870   if (flag_pic && PIC_OFFSET_TABLE_SAVE_RTX == NULL_RTX)
5871     hppa_init_pic_save ();
5872
5873   /* Use two different patterns for calls to explicitly named functions
5874      and calls through function pointers.  This is necessary as these two
5875      types of calls use different calling conventions, and CSE might try
5876      to change the named call into an indirect call in some cases (using
5877      two patterns keeps CSE from performing this optimization).  */
5878   if (GET_CODE (op) == SYMBOL_REF)
5879     call_insn = emit_call_insn (gen_call_value_internal_symref (operands[0],
5880                                                                 op,
5881                                                                 operands[2]));
5882   else if (TARGET_64BIT)
5883     {
5884       rtx tmpreg = force_reg (word_mode, op);
5885       call_insn
5886         = emit_call_insn (gen_call_value_internal_reg_64bit (operands[0],
5887                                                              tmpreg,
5888                                                              operands[2]));
5889     }
5890   else
5891     {
5892       rtx tmpreg = gen_rtx_REG (word_mode, 22);
5893       emit_move_insn (tmpreg, force_reg (word_mode, op));
5894       call_insn = emit_call_insn (gen_call_value_internal_reg (operands[0],
5895                                                                operands[2]));
5896     }
5897   if (flag_pic)
5898     {
5899       use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
5900       if (TARGET_64BIT)
5901         use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), arg_pointer_rtx);
5902
5903       /* After each call we must restore the PIC register, even if it
5904          doesn't appear to be used.  */
5905       emit_move_insn (pic_offset_table_rtx, PIC_OFFSET_TABLE_SAVE_RTX);
5906     }
5907   DONE;
5908 }")
5909
5910 (define_insn "call_value_internal_symref"
5911   [(set (match_operand 0 "" "=rf")
5912         (call (mem:SI (match_operand 1 "call_operand_address" ""))
5913               (match_operand 2 "" "i")))
5914    (clobber (reg:SI 2))
5915    (use (const_int 0))]
5916   ;;- Don't use operand 1 for most machines.
5917   "! TARGET_PORTABLE_RUNTIME"
5918   "*
5919 {
5920   output_arg_descriptor (insn);
5921   return output_call (insn, operands[1], 0);
5922 }"
5923   [(set_attr "type" "call")
5924    (set (attr "length")
5925 ;;       If we're sure that we can either reach the target or that the
5926 ;;       linker can use a long-branch stub, then the length is 4 bytes.
5927 ;;
5928 ;;       For long-calls the length will be either 52 bytes (non-pic)
5929 ;;       or 68 bytes (pic).  */
5930 ;;       Else we have to use a long-call;
5931       (if_then_else (lt (plus (symbol_ref "total_code_bytes") (pc))
5932                         (const_int 240000))
5933                     (const_int 4)
5934                     (if_then_else (eq (symbol_ref "flag_pic")
5935                                       (const_int 0))
5936                                   (const_int 52)
5937                                   (const_int 68))))])
5938
5939 (define_insn "call_value_internal_reg_64bit"
5940   [(set (match_operand 0 "" "=rf")
5941          (call (mem:SI (match_operand:DI 1 "register_operand" "r"))
5942                (match_operand 2 "" "i")))
5943    (clobber (reg:SI 2))
5944    (use (const_int 1))]
5945   "TARGET_64BIT"
5946   "*
5947 {
5948   /* ??? Needs more work.  Length computation, split into multiple insns,
5949      do not use %r22 directly, expose delay slot.  */
5950   return \"ldd 16(%1),%%r2\;ldd 24(%1),%%r27\;bve,l (%%r2),%%r2\;nop\";
5951 }"
5952   [(set_attr "type" "dyncall")
5953    (set (attr "length") (const_int 16))])
5954
5955 (define_insn "call_value_internal_reg"
5956   [(set (match_operand 0 "" "=rf")
5957         (call (mem:SI (reg:SI 22))
5958               (match_operand 1 "" "i")))
5959    (clobber (reg:SI 2))
5960    (use (const_int 1))]
5961   ""
5962   "*
5963 {
5964   rtx xoperands[2];
5965
5966   /* First the special case for kernels, level 0 systems, etc.  */
5967   if (TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS)
5968     return \"ble 0(%%sr4,%%r22)\;copy %%r31,%%r2\";
5969
5970   /* Now the normal case -- we can reach $$dyncall directly or
5971      we're sure that we can get there via a long-branch stub. 
5972
5973      No need to check target flags as the length uniquely identifies
5974      the remaining cases.  */
5975   if (get_attr_length (insn) == 8)
5976     return \".CALL\\tARGW0=GR\;{bl|b,l} $$dyncall,%%r31\;copy %%r31,%%r2\";
5977
5978   /* Long millicode call, but we are not generating PIC or portable runtime
5979      code.  */
5980   if (get_attr_length (insn) == 12)
5981     return \".CALL\\tARGW0=GR\;ldil L%%$$dyncall,%%r2\;ble R%%$$dyncall(%%sr4,%%r2)\;copy %%r31,%%r2\";
5982
5983   /* Long millicode call for portable runtime.  */
5984   if (get_attr_length (insn) == 20)
5985     return \"ldil L%%$$dyncall,%%r31\;ldo R%%$$dyncall(%%r31),%%r31\;blr %%r0,%%r2\;bv,n %%r0(%%r31)\;nop\";
5986
5987   /* If we're generating PIC code.  */
5988   xoperands[0] = operands[1];
5989   xoperands[1] = gen_label_rtx ();
5990   output_asm_insn (\"{bl|b,l} .+8,%%r1\", xoperands);
5991   output_asm_insn (\"addil L%%$$dyncall-%1,%%r1\", xoperands);
5992   ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\",
5993                              CODE_LABEL_NUMBER (xoperands[1]));
5994   output_asm_insn (\"ldo R%%$$dyncall-%1(%%r1),%%r1\", xoperands);
5995   output_asm_insn (\"blr %%r0,%%r2\", xoperands);
5996   output_asm_insn (\"bv,n %%r0(%%r1)\\n\\tnop\", xoperands);
5997   return \"\";
5998 }"
5999   [(set_attr "type" "dyncall")
6000    (set (attr "length")
6001      (cond [
6002 ;; First NO_SPACE_REGS
6003             (ne (symbol_ref "TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS")
6004                 (const_int 0))
6005             (const_int 8)
6006
6007 ;; Target (or stub) within reach
6008             (and (lt (plus (symbol_ref "total_code_bytes") (pc))
6009                      (const_int 240000))
6010                  (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
6011                      (const_int 0)))
6012             (const_int 8)
6013
6014 ;; Out of reach, but not PIC or PORTABLE_RUNTIME
6015             (and (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
6016                      (const_int 0))
6017                  (eq (symbol_ref "flag_pic")
6018                      (const_int 0)))
6019             (const_int 12)
6020
6021             (ne (symbol_ref "TARGET_PORTABLE_RUNTIME")
6022                 (const_int 0))
6023             (const_int 20)]
6024
6025 ;; Out of range PIC case
6026           (const_int 24)))])
6027
6028 ;; Call subroutine returning any type.
6029
6030 (define_expand "untyped_call"
6031   [(parallel [(call (match_operand 0 "" "")
6032                     (const_int 0))
6033               (match_operand 1 "" "")
6034               (match_operand 2 "" "")])]
6035   ""
6036   "
6037 {
6038   int i;
6039
6040   emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
6041
6042   for (i = 0; i < XVECLEN (operands[2], 0); i++)
6043     {
6044       rtx set = XVECEXP (operands[2], 0, i);
6045       emit_move_insn (SET_DEST (set), SET_SRC (set));
6046     }
6047
6048   /* The optimizer does not know that the call sets the function value
6049      registers we stored in the result block.  We avoid problems by
6050      claiming that all hard registers are used and clobbered at this
6051      point.  */
6052   emit_insn (gen_blockage ());
6053
6054   DONE;
6055 }")
6056
6057 (define_expand "sibcall"
6058   [(parallel [(call (match_operand:SI 0 "" "")
6059                     (match_operand 1 "" ""))
6060               (clobber (reg:SI 0))])]
6061   "! TARGET_PORTABLE_RUNTIME"
6062   "
6063 {
6064   rtx op;
6065   rtx call_insn;
6066
6067   op = XEXP (operands[0], 0);
6068
6069   if (flag_pic && PIC_OFFSET_TABLE_SAVE_RTX == NULL_RTX)
6070     hppa_init_pic_save ();
6071
6072   /* We do not allow indirect sibling calls.  */
6073   call_insn = emit_call_insn (gen_sibcall_internal_symref (op, operands[1]));
6074
6075   if (flag_pic)
6076     {
6077       use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
6078
6079       /* After each call we must restore the PIC register, even if it
6080          doesn't appear to be used.  */
6081       emit_move_insn (pic_offset_table_rtx, PIC_OFFSET_TABLE_SAVE_RTX);
6082     }
6083   DONE;
6084 }")
6085
6086 (define_insn "sibcall_internal_symref"
6087   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
6088          (match_operand 1 "" "i"))
6089    (clobber (reg:SI 0))
6090    (use (reg:SI 2))
6091    (use (const_int 0))]
6092   "! TARGET_PORTABLE_RUNTIME"
6093   "*
6094 {
6095   output_arg_descriptor (insn);
6096   return output_call (insn, operands[0], 1);
6097 }"
6098   [(set_attr "type" "call")
6099    (set (attr "length")
6100 ;;       If we're sure that we can either reach the target or that the
6101 ;;       linker can use a long-branch stub, then the length is 4 bytes.
6102 ;;
6103 ;;       For long-calls the length will be either 52 bytes (non-pic)
6104 ;;       or 68 bytes (pic).  */
6105 ;;       Else we have to use a long-call;
6106       (if_then_else (lt (plus (symbol_ref "total_code_bytes") (pc))
6107                         (const_int 240000))
6108                     (const_int 4)
6109                     (if_then_else (eq (symbol_ref "flag_pic")
6110                                       (const_int 0))
6111                                   (const_int 52)
6112                                   (const_int 68))))])
6113
6114 (define_expand "sibcall_value"
6115   [(parallel [(set (match_operand 0 "" "")
6116                    (call (match_operand:SI 1 "" "")
6117                          (match_operand 2 "" "")))
6118               (clobber (reg:SI 0))])]
6119   "! TARGET_PORTABLE_RUNTIME"
6120   "
6121 {
6122   rtx op;
6123   rtx call_insn;
6124
6125   op = XEXP (operands[1], 0);
6126
6127   if (flag_pic && PIC_OFFSET_TABLE_SAVE_RTX == NULL_RTX)
6128     hppa_init_pic_save ();
6129
6130   /* We do not allow indirect sibling calls.  */
6131   call_insn = emit_call_insn (gen_sibcall_value_internal_symref (operands[0],
6132                                                                  op,
6133                                                                  operands[2]));
6134   if (flag_pic)
6135     {
6136       use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
6137
6138       /* After each call we must restore the PIC register, even if it
6139          doesn't appear to be used.  */
6140       emit_move_insn (pic_offset_table_rtx, PIC_OFFSET_TABLE_SAVE_RTX);
6141     }
6142   DONE;
6143 }")
6144
6145 (define_insn "sibcall_value_internal_symref"
6146   [(set (match_operand 0 "" "=rf")
6147         (call (mem:SI (match_operand 1 "call_operand_address" ""))
6148               (match_operand 2 "" "i")))
6149    (clobber (reg:SI 0))
6150    (use (reg:SI 2))
6151    (use (const_int 0))]
6152   ;;- Don't use operand 1 for most machines.
6153   "! TARGET_PORTABLE_RUNTIME"
6154   "*
6155 {
6156   output_arg_descriptor (insn);
6157   return output_call (insn, operands[1], 1);
6158 }"
6159   [(set_attr "type" "call")
6160    (set (attr "length")
6161 ;;       If we're sure that we can either reach the target or that the
6162 ;;       linker can use a long-branch stub, then the length is 4 bytes.
6163 ;;
6164 ;;       For long-calls the length will be either 52 bytes (non-pic)
6165 ;;       or 68 bytes (pic).  */
6166 ;;       Else we have to use a long-call;
6167       (if_then_else (lt (plus (symbol_ref "total_code_bytes") (pc))
6168                         (const_int 240000))
6169                     (const_int 4)
6170                     (if_then_else (eq (symbol_ref "flag_pic")
6171                                       (const_int 0))
6172                                   (const_int 52)
6173                                   (const_int 68))))])
6174
6175 (define_insn "nop"
6176   [(const_int 0)]
6177   ""
6178   "nop"
6179   [(set_attr "type" "move")
6180    (set_attr "length" "4")])
6181
6182 ;; These are just placeholders so we know where branch tables
6183 ;; begin and end.
6184 (define_insn "begin_brtab"
6185   [(const_int 1)]
6186   ""
6187   "*
6188 {
6189   /* Only GAS actually supports this pseudo-op.  */
6190   if (TARGET_GAS)
6191     return \".begin_brtab\";
6192   else
6193     return \"\";
6194 }"
6195   [(set_attr "type" "move")
6196    (set_attr "length" "0")])
6197
6198 (define_insn "end_brtab"
6199   [(const_int 2)]
6200   ""
6201   "*
6202 {
6203   /* Only GAS actually supports this pseudo-op.  */
6204   if (TARGET_GAS)
6205     return \".end_brtab\";
6206   else
6207     return \"\";
6208 }"
6209   [(set_attr "type" "move")
6210    (set_attr "length" "0")])
6211
6212 ;;; EH does longjmp's from and within the data section.  Thus,
6213 ;;; an interspace branch is required for the longjmp implementation.
6214 ;;; Registers r1 and r2 are not saved in the jmpbuf environment.
6215 ;;; Thus, they can be used as scratch registers for the jump.
6216 (define_expand "interspace_jump"
6217   [(parallel
6218      [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
6219       (clobber (match_dup 1))])]
6220   ""
6221   "
6222 {
6223   operands[1] = gen_rtx_REG (word_mode, 2);
6224 }")
6225
6226 (define_insn ""
6227   [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
6228   (clobber (reg:SI 2))]
6229   "!TARGET_64BIT"
6230   "ldsid (%%sr0,%0),%%r2\; mtsp %%r2,%%sr0\; be%* 0(%%sr0,%0)"
6231    [(set_attr "type" "branch")
6232     (set_attr "length" "12")])
6233
6234 (define_insn ""
6235   [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
6236   (clobber (reg:DI 2))]
6237   "TARGET_64BIT"
6238   "ldsid (%%sr0,%0),%%r2\; mtsp %%r2,%%sr0\; be%* 0(%%sr0,%0)"
6239    [(set_attr "type" "branch")
6240     (set_attr "length" "12")])
6241
6242 (define_expand "builtin_longjmp"
6243   [(unspec_volatile [(match_operand 0 "register_operand" "r")] 3)]
6244   ""
6245   "
6246 {
6247   /* The elements of the buffer are, in order:  */
6248   rtx fp = gen_rtx_MEM (Pmode, operands[0]);
6249   rtx lab = gen_rtx_MEM (Pmode, plus_constant (operands[0], 4));
6250   rtx stack = gen_rtx_MEM (Pmode, plus_constant (operands[0], 8));
6251   rtx pv = gen_rtx_REG (Pmode, 1);
6252
6253   /* This bit is the same as expand_builtin_longjmp.  */
6254   emit_move_insn (hard_frame_pointer_rtx, fp);
6255   emit_stack_restore (SAVE_NONLOCAL, stack, NULL_RTX);
6256   emit_insn (gen_rtx_USE (VOIDmode, hard_frame_pointer_rtx));
6257   emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
6258
6259   /* Load the label we are jumping through into r1 so that we know
6260      where to look for it when we get back to setjmp's function for
6261      restoring the gp.  */
6262   emit_move_insn (pv, lab);
6263   emit_jump_insn (gen_interspace_jump (pv));
6264   emit_barrier ();
6265   DONE;
6266 }")
6267 ;;; Hope this is only within a function...
6268 (define_insn "indirect_jump"
6269   [(set (pc) (match_operand 0 "register_operand" "r"))]
6270   "GET_MODE (operands[0]) == word_mode"
6271   "bv%* %%r0(%0)"
6272   [(set_attr "type" "branch")
6273    (set_attr "length" "4")])
6274
6275 (define_expand "extzv"
6276   [(set (match_operand 0 "register_operand" "")
6277         (zero_extract (match_operand 1 "register_operand" "")
6278                       (match_operand 2 "uint32_operand" "")
6279                       (match_operand 3 "uint32_operand" "")))]
6280   ""
6281   "
6282 {
6283   if (TARGET_64BIT)
6284     emit_insn (gen_extzv_64 (operands[0], operands[1],
6285                              operands[2], operands[3]));
6286   else
6287     emit_insn (gen_extzv_32 (operands[0], operands[1],
6288                              operands[2], operands[3]));
6289   DONE;
6290 }")
6291
6292 (define_insn "extzv_32"
6293   [(set (match_operand:SI 0 "register_operand" "=r")
6294         (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
6295                          (match_operand:SI 2 "uint5_operand" "")
6296                          (match_operand:SI 3 "uint5_operand" "")))]
6297   ""
6298   "{extru|extrw,u} %1,%3+%2-1,%2,%0"
6299   [(set_attr "type" "shift")
6300    (set_attr "length" "4")])
6301
6302 (define_insn ""
6303   [(set (match_operand:SI 0 "register_operand" "=r")
6304         (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
6305                          (const_int 1)
6306                          (match_operand:SI 2 "register_operand" "q")))]
6307   ""
6308   "{vextru %1,1,%0|extrw,u %1,%%sar,1,%0}"
6309   [(set_attr "type" "shift")
6310    (set_attr "length" "4")])
6311
6312 (define_insn "extzv_64"
6313   [(set (match_operand:DI 0 "register_operand" "=r")
6314         (zero_extract:DI (match_operand:DI 1 "register_operand" "r")
6315                          (match_operand:DI 2 "uint32_operand" "")
6316                          (match_operand:DI 3 "uint32_operand" "")))]
6317   "TARGET_64BIT"
6318   "extrd,u %1,%3+%2-1,%2,%0"
6319   [(set_attr "type" "shift")
6320    (set_attr "length" "4")])
6321
6322 (define_insn ""
6323   [(set (match_operand:DI 0 "register_operand" "=r")
6324         (zero_extract:DI (match_operand:DI 1 "register_operand" "r")
6325                          (const_int 1)
6326                          (match_operand:DI 2 "register_operand" "q")))]
6327   "TARGET_64BIT"
6328   "extrd,u %1,%%sar,1,%0"
6329   [(set_attr "type" "shift")
6330    (set_attr "length" "4")])
6331
6332 (define_expand "extv"
6333   [(set (match_operand 0 "register_operand" "")
6334         (sign_extract (match_operand 1 "register_operand" "")
6335                       (match_operand 2 "uint32_operand" "")
6336                       (match_operand 3 "uint32_operand" "")))]
6337   ""
6338   "
6339 {
6340   if (TARGET_64BIT)
6341     emit_insn (gen_extv_64 (operands[0], operands[1],
6342                             operands[2], operands[3]));
6343   else
6344     emit_insn (gen_extv_32 (operands[0], operands[1],
6345                             operands[2], operands[3]));
6346   DONE;
6347 }")
6348
6349 (define_insn "extv_32"
6350   [(set (match_operand:SI 0 "register_operand" "=r")
6351         (sign_extract:SI (match_operand:SI 1 "register_operand" "r")
6352                          (match_operand:SI 2 "uint5_operand" "")
6353                          (match_operand:SI 3 "uint5_operand" "")))]
6354   ""
6355   "{extrs|extrw,s} %1,%3+%2-1,%2,%0"
6356   [(set_attr "type" "shift")
6357    (set_attr "length" "4")])
6358
6359 (define_insn ""
6360   [(set (match_operand:SI 0 "register_operand" "=r")
6361         (sign_extract:SI (match_operand:SI 1 "register_operand" "r")
6362                          (const_int 1)
6363                          (match_operand:SI 2 "register_operand" "q")))]
6364   "!TARGET_64BIT"
6365   "{vextrs %1,1,%0|extrw,s %1,%%sar,1,%0}"
6366   [(set_attr "type" "shift")
6367    (set_attr "length" "4")])
6368
6369 (define_insn "extv_64"
6370   [(set (match_operand:DI 0 "register_operand" "=r")
6371         (sign_extract:DI (match_operand:DI 1 "register_operand" "r")
6372                          (match_operand:DI 2 "uint32_operand" "")
6373                          (match_operand:DI 3 "uint32_operand" "")))]
6374   "TARGET_64BIT"
6375   "extrd,s %1,%3+%2-1,%2,%0"
6376   [(set_attr "type" "shift")
6377    (set_attr "length" "4")])
6378
6379 (define_insn ""
6380   [(set (match_operand:DI 0 "register_operand" "=r")
6381         (sign_extract:DI (match_operand:DI 1 "register_operand" "r")
6382                          (const_int 1)
6383                          (match_operand:DI 2 "register_operand" "q")))]
6384   "TARGET_64BIT"
6385   "extrd,s %1,%%sar,1,%0"
6386   [(set_attr "type" "shift")
6387    (set_attr "length" "4")])
6388
6389 ;; Only specify the mode operands 0, the rest are assumed to be word_mode.
6390 (define_expand "insv"
6391   [(set (zero_extract (match_operand 0 "register_operand" "")
6392                       (match_operand 1 "uint32_operand" "")
6393                       (match_operand 2 "uint32_operand" ""))
6394         (match_operand 3 "arith5_operand" ""))]
6395   ""
6396   "
6397 {
6398   if (TARGET_64BIT)
6399     emit_insn (gen_insv_64 (operands[0], operands[1],
6400                             operands[2], operands[3]));
6401   else
6402     emit_insn (gen_insv_32 (operands[0], operands[1],
6403                             operands[2], operands[3]));
6404   DONE;
6405 }")
6406
6407 (define_insn "insv_32"
6408   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r,r")
6409                          (match_operand:SI 1 "uint5_operand" "")
6410                          (match_operand:SI 2 "uint5_operand" ""))
6411         (match_operand:SI 3 "arith5_operand" "r,L"))]
6412   ""
6413   "@
6414    {dep|depw} %3,%2+%1-1,%1,%0
6415    {depi|depwi} %3,%2+%1-1,%1,%0"
6416   [(set_attr "type" "shift,shift")
6417    (set_attr "length" "4,4")])
6418
6419 ;; Optimize insertion of const_int values of type 1...1xxxx.
6420 (define_insn ""
6421   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
6422                          (match_operand:SI 1 "uint5_operand" "")
6423                          (match_operand:SI 2 "uint5_operand" ""))
6424         (match_operand:SI 3 "const_int_operand" ""))]
6425   "(INTVAL (operands[3]) & 0x10) != 0 &&
6426    (~INTVAL (operands[3]) & ((1L << INTVAL (operands[1])) - 1) & ~0xf) == 0"
6427   "*
6428 {
6429   operands[3] = GEN_INT ((INTVAL (operands[3]) & 0xf) - 0x10);
6430   return \"{depi|depwi} %3,%2+%1-1,%1,%0\";
6431 }"
6432   [(set_attr "type" "shift")
6433    (set_attr "length" "4")])
6434
6435 (define_insn "insv_64"
6436   [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+r,r")
6437                          (match_operand:DI 1 "uint32_operand" "")
6438                          (match_operand:DI 2 "uint32_operand" ""))
6439         (match_operand:DI 3 "arith32_operand" "r,L"))]
6440   "TARGET_64BIT"
6441   "@
6442    depd %3,%2+%1-1,%1,%0
6443    depdi %3,%2+%1-1,%1,%0"
6444   [(set_attr "type" "shift,shift")
6445    (set_attr "length" "4,4")])
6446
6447 ;; Optimize insertion of const_int values of type 1...1xxxx.
6448 (define_insn ""
6449   [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+r")
6450                          (match_operand:DI 1 "uint32_operand" "")
6451                          (match_operand:DI 2 "uint32_operand" ""))
6452         (match_operand:DI 3 "const_int_operand" ""))]
6453   "(INTVAL (operands[3]) & 0x10) != 0
6454    && TARGET_64BIT
6455    && (~INTVAL (operands[3]) & ((1L << INTVAL (operands[1])) - 1) & ~0xf) == 0"
6456   "*
6457 {
6458   operands[3] = GEN_INT ((INTVAL (operands[3]) & 0xf) - 0x10);
6459   return \"depdi %3,%2+%1-1,%1,%0\";
6460 }"
6461   [(set_attr "type" "shift")
6462    (set_attr "length" "4")])
6463
6464 (define_insn ""
6465   [(set (match_operand:DI 0 "register_operand" "=r")
6466         (ashift:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
6467                    (const_int 32)))]
6468   "TARGET_64BIT"
6469   "depd,z %1,31,32,%0"
6470   [(set_attr "type" "shift")
6471    (set_attr "length" "4")])
6472
6473 ;; This insn is used for some loop tests, typically loops reversed when
6474 ;; strength reduction is used.  It is actually created when the instruction
6475 ;; combination phase combines the special loop test.  Since this insn
6476 ;; is both a jump insn and has an output, it must deal with its own
6477 ;; reloads, hence the `m' constraints.  The `!' constraints direct reload
6478 ;; to not choose the register alternatives in the event a reload is needed.
6479 (define_insn "decrement_and_branch_until_zero"
6480   [(set (pc)
6481         (if_then_else
6482           (match_operator 2 "comparison_operator"
6483            [(plus:SI (match_operand:SI 0 "register_operand" "+!r,!*f,!*m")
6484                      (match_operand:SI 1 "int5_operand" "L,L,L"))
6485             (const_int 0)])
6486           (label_ref (match_operand 3 "" ""))
6487           (pc)))
6488    (set (match_dup 0)
6489         (plus:SI (match_dup 0) (match_dup 1)))
6490    (clobber (match_scratch:SI 4 "=X,r,r"))]
6491   ""
6492   "* return output_dbra (operands, insn, which_alternative); "
6493 ;; Do not expect to understand this the first time through.
6494 [(set_attr "type" "cbranch,multi,multi")
6495  (set (attr "length")
6496       (if_then_else (eq_attr "alternative" "0")
6497 ;; Loop counter in register case
6498 ;; Short branch has length of 4
6499 ;; Long branch has length of 8
6500         (if_then_else (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
6501                       (const_int 8184))
6502            (const_int 4)
6503            (const_int 8))
6504
6505 ;; Loop counter in FP reg case.
6506 ;; Extra goo to deal with additional reload insns.
6507         (if_then_else (eq_attr "alternative" "1")
6508           (if_then_else (lt (match_dup 3) (pc))
6509             (if_then_else
6510               (lt (abs (minus (match_dup 3) (plus (pc) (const_int 24))))
6511                   (const_int 8184))
6512               (const_int 24)
6513               (const_int 28))
6514             (if_then_else
6515               (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
6516                   (const_int 8184))
6517               (const_int 24)
6518               (const_int 28)))
6519 ;; Loop counter in memory case.
6520 ;; Extra goo to deal with additional reload insns.
6521         (if_then_else (lt (match_dup 3) (pc))
6522           (if_then_else
6523             (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
6524                 (const_int 8184))
6525             (const_int 12)
6526             (const_int 16))
6527           (if_then_else
6528             (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
6529                 (const_int 8184))
6530             (const_int 12)
6531             (const_int 16))))))])
6532
6533 (define_insn ""
6534   [(set (pc)
6535         (if_then_else
6536           (match_operator 2 "movb_comparison_operator"
6537            [(match_operand:SI 1 "register_operand" "r,r,r,r") (const_int 0)])
6538           (label_ref (match_operand 3 "" ""))
6539           (pc)))
6540    (set (match_operand:SI 0 "register_operand" "=!r,!*f,!*m,!*q")
6541         (match_dup 1))]
6542   ""
6543 "* return output_movb (operands, insn, which_alternative, 0); "
6544 ;; Do not expect to understand this the first time through.
6545 [(set_attr "type" "cbranch,multi,multi,multi")
6546  (set (attr "length")
6547       (if_then_else (eq_attr "alternative" "0")
6548 ;; Loop counter in register case
6549 ;; Short branch has length of 4
6550 ;; Long branch has length of 8
6551         (if_then_else (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
6552                       (const_int 8184))
6553            (const_int 4)
6554            (const_int 8))
6555
6556 ;; Loop counter in FP reg case.
6557 ;; Extra goo to deal with additional reload insns.
6558         (if_then_else (eq_attr "alternative" "1")
6559           (if_then_else (lt (match_dup 3) (pc))
6560             (if_then_else
6561               (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
6562                   (const_int 8184))
6563               (const_int 12)
6564               (const_int 16))
6565             (if_then_else
6566               (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
6567                   (const_int 8184))
6568               (const_int 12)
6569               (const_int 16)))
6570 ;; Loop counter in memory or sar case.
6571 ;; Extra goo to deal with additional reload insns.
6572         (if_then_else
6573           (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
6574               (const_int 8184))
6575           (const_int 8)
6576           (const_int 12)))))])
6577
6578 ;; Handle negated branch.
6579 (define_insn ""
6580   [(set (pc)
6581         (if_then_else
6582           (match_operator 2 "movb_comparison_operator"
6583            [(match_operand:SI 1 "register_operand" "r,r,r,r") (const_int 0)])
6584           (pc)
6585           (label_ref (match_operand 3 "" ""))))
6586    (set (match_operand:SI 0 "register_operand" "=!r,!*f,!*m,!*q")
6587         (match_dup 1))]
6588   ""
6589 "* return output_movb (operands, insn, which_alternative, 1); "
6590 ;; Do not expect to understand this the first time through.
6591 [(set_attr "type" "cbranch,multi,multi,multi")
6592  (set (attr "length")
6593       (if_then_else (eq_attr "alternative" "0")
6594 ;; Loop counter in register case
6595 ;; Short branch has length of 4
6596 ;; Long branch has length of 8
6597         (if_then_else (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
6598                       (const_int 8184))
6599            (const_int 4)
6600            (const_int 8))
6601
6602 ;; Loop counter in FP reg case.
6603 ;; Extra goo to deal with additional reload insns.
6604         (if_then_else (eq_attr "alternative" "1")
6605           (if_then_else (lt (match_dup 3) (pc))
6606             (if_then_else
6607               (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
6608                   (const_int 8184))
6609               (const_int 12)
6610               (const_int 16))
6611             (if_then_else
6612               (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
6613                   (const_int 8184))
6614               (const_int 12)
6615               (const_int 16)))
6616 ;; Loop counter in memory or SAR case.
6617 ;; Extra goo to deal with additional reload insns.
6618         (if_then_else
6619           (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
6620               (const_int 8184))
6621           (const_int 8)
6622           (const_int 12)))))])
6623
6624 (define_insn ""
6625   [(set (pc) (label_ref (match_operand 3 "" "" )))
6626    (set (match_operand:SI 0 "ireg_operand" "=r")
6627         (plus:SI (match_operand:SI 1 "ireg_operand" "r")
6628                  (match_operand:SI 2 "ireg_or_int5_operand" "rL")))]
6629   "(reload_completed && operands[0] == operands[1]) || operands[0] == operands[2]"
6630   "*
6631 {
6632   return output_parallel_addb (operands, get_attr_length (insn));
6633 }"
6634   [(set_attr "type" "parallel_branch")
6635    (set (attr "length")
6636     (if_then_else (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
6637                       (const_int 8184))
6638            (const_int 4)
6639            (const_int 8)))])
6640
6641 (define_insn ""
6642   [(set (pc) (label_ref (match_operand 2 "" "" )))
6643    (set (match_operand:SF 0 "ireg_operand" "=r")
6644         (match_operand:SF 1 "ireg_or_int5_operand" "rL"))]
6645   "reload_completed"
6646   "*
6647 {
6648   return output_parallel_movb (operands, get_attr_length (insn));
6649 }"
6650   [(set_attr "type" "parallel_branch")
6651    (set (attr "length")
6652     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
6653                       (const_int 8184))
6654            (const_int 4)
6655            (const_int 8)))])
6656
6657 (define_insn ""
6658   [(set (pc) (label_ref (match_operand 2 "" "" )))
6659    (set (match_operand:SI 0 "ireg_operand" "=r")
6660         (match_operand:SI 1 "ireg_or_int5_operand" "rL"))]
6661   "reload_completed"
6662   "*
6663 {
6664   return output_parallel_movb (operands, get_attr_length (insn));
6665 }"
6666   [(set_attr "type" "parallel_branch")
6667    (set (attr "length")
6668     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
6669                       (const_int 8184))
6670            (const_int 4)
6671            (const_int 8)))])
6672
6673 (define_insn ""
6674   [(set (pc) (label_ref (match_operand 2 "" "" )))
6675    (set (match_operand:HI 0 "ireg_operand" "=r")
6676         (match_operand:HI 1 "ireg_or_int5_operand" "rL"))]
6677   "reload_completed"
6678   "*
6679 {
6680   return output_parallel_movb (operands, get_attr_length (insn));
6681 }"
6682   [(set_attr "type" "parallel_branch")
6683    (set (attr "length")
6684     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
6685                       (const_int 8184))
6686            (const_int 4)
6687            (const_int 8)))])
6688
6689 (define_insn ""
6690   [(set (pc) (label_ref (match_operand 2 "" "" )))
6691    (set (match_operand:QI 0 "ireg_operand" "=r")
6692         (match_operand:QI 1 "ireg_or_int5_operand" "rL"))]
6693   "reload_completed"
6694   "*
6695 {
6696   return output_parallel_movb (operands, get_attr_length (insn));
6697 }"
6698   [(set_attr "type" "parallel_branch")
6699    (set (attr "length")
6700     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
6701                       (const_int 8184))
6702            (const_int 4)
6703            (const_int 8)))])
6704
6705 (define_insn ""
6706   [(set (match_operand 0 "register_operand" "=f")
6707         (mult (match_operand 1 "register_operand" "f")
6708               (match_operand 2 "register_operand" "f")))
6709    (set (match_operand 3 "register_operand" "+f")
6710         (plus (match_operand 4 "register_operand" "f")
6711               (match_operand 5 "register_operand" "f")))]
6712   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
6713    && reload_completed && fmpyaddoperands (operands)"
6714   "*
6715 {
6716   if (GET_MODE (operands[0]) == DFmode)
6717     {
6718       if (rtx_equal_p (operands[3], operands[5]))
6719         return \"fmpyadd,dbl %1,%2,%0,%4,%3\";
6720       else
6721         return \"fmpyadd,dbl %1,%2,%0,%5,%3\";
6722     }
6723   else
6724     {
6725       if (rtx_equal_p (operands[3], operands[5]))
6726         return \"fmpyadd,sgl %1,%2,%0,%4,%3\";
6727       else
6728         return \"fmpyadd,sgl %1,%2,%0,%5,%3\";
6729     }
6730 }"
6731   [(set_attr "type" "fpalu")
6732    (set_attr "length" "4")])
6733
6734 (define_insn ""
6735   [(set (match_operand 3 "register_operand" "+f")
6736         (plus (match_operand 4 "register_operand" "f")
6737               (match_operand 5 "register_operand" "f")))
6738    (set (match_operand 0 "register_operand" "=f")
6739         (mult (match_operand 1 "register_operand" "f")
6740               (match_operand 2 "register_operand" "f")))]
6741   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
6742    && reload_completed && fmpyaddoperands (operands)"
6743   "*
6744 {
6745   if (GET_MODE (operands[0]) == DFmode)
6746     {
6747       if (rtx_equal_p (operands[3], operands[5]))
6748         return \"fmpyadd,dbl %1,%2,%0,%4,%3\";
6749       else
6750         return \"fmpyadd,dbl %1,%2,%0,%5,%3\";
6751     }
6752   else
6753     {
6754       if (rtx_equal_p (operands[3], operands[5]))
6755         return \"fmpyadd,sgl %1,%2,%0,%4,%3\";
6756       else
6757         return \"fmpyadd,sgl %1,%2,%0,%5,%3\";
6758     }
6759 }"
6760   [(set_attr "type" "fpalu")
6761    (set_attr "length" "4")])
6762
6763 (define_insn ""
6764   [(set (match_operand 0 "register_operand" "=f")
6765         (mult (match_operand 1 "register_operand" "f")
6766               (match_operand 2 "register_operand" "f")))
6767    (set (match_operand 3 "register_operand" "+f")
6768         (minus (match_operand 4 "register_operand" "f")
6769                (match_operand 5 "register_operand" "f")))]
6770   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
6771    && reload_completed && fmpysuboperands (operands)"
6772   "*
6773 {
6774   if (GET_MODE (operands[0]) == DFmode)
6775     return \"fmpysub,dbl %1,%2,%0,%5,%3\";
6776   else
6777     return \"fmpysub,sgl %1,%2,%0,%5,%3\";
6778 }"
6779   [(set_attr "type" "fpalu")
6780    (set_attr "length" "4")])
6781
6782 (define_insn ""
6783   [(set (match_operand 3 "register_operand" "+f")
6784         (minus (match_operand 4 "register_operand" "f")
6785                (match_operand 5 "register_operand" "f")))
6786    (set (match_operand 0 "register_operand" "=f")
6787         (mult (match_operand 1 "register_operand" "f")
6788               (match_operand 2 "register_operand" "f")))]
6789   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
6790    && reload_completed && fmpysuboperands (operands)"
6791   "*
6792 {
6793   if (GET_MODE (operands[0]) == DFmode)
6794     return \"fmpysub,dbl %1,%2,%0,%5,%3\";
6795   else
6796     return \"fmpysub,sgl %1,%2,%0,%5,%3\";
6797 }"
6798   [(set_attr "type" "fpalu")
6799    (set_attr "length" "4")])
6800
6801 ;; Clean up turds left by reload.
6802 (define_peephole
6803   [(set (match_operand 0 "reg_or_nonsymb_mem_operand" "")
6804         (match_operand 1 "register_operand" "fr"))
6805    (set (match_operand 2 "register_operand" "fr")
6806         (match_dup 0))]
6807   "! TARGET_SOFT_FLOAT
6808    && GET_CODE (operands[0]) == MEM
6809    && ! MEM_VOLATILE_P (operands[0])
6810    && GET_MODE (operands[0]) == GET_MODE (operands[1])
6811    && GET_MODE (operands[0]) == GET_MODE (operands[2])
6812    && GET_MODE (operands[0]) == DFmode
6813    && GET_CODE (operands[1]) == REG
6814    && GET_CODE (operands[2]) == REG
6815    && ! side_effects_p (XEXP (operands[0], 0))
6816    && REGNO_REG_CLASS (REGNO (operands[1]))
6817       == REGNO_REG_CLASS (REGNO (operands[2]))"
6818   "*
6819 {
6820   rtx xoperands[2];
6821
6822   if (FP_REG_P (operands[1]))
6823     output_asm_insn (output_fp_move_double (operands), operands);
6824   else
6825     output_asm_insn (output_move_double (operands), operands);
6826
6827   if (rtx_equal_p (operands[1], operands[2]))
6828     return \"\";
6829
6830   xoperands[0] = operands[2];
6831   xoperands[1] = operands[1];
6832       
6833   if (FP_REG_P (xoperands[1]))
6834     output_asm_insn (output_fp_move_double (xoperands), xoperands);
6835   else
6836     output_asm_insn (output_move_double (xoperands), xoperands);
6837
6838   return \"\";
6839 }")
6840
6841 (define_peephole
6842   [(set (match_operand 0 "register_operand" "fr")
6843         (match_operand 1 "reg_or_nonsymb_mem_operand" ""))
6844    (set (match_operand 2 "register_operand" "fr")
6845         (match_dup 1))]
6846   "! TARGET_SOFT_FLOAT
6847    && GET_CODE (operands[1]) == MEM
6848    && ! MEM_VOLATILE_P (operands[1])
6849    && GET_MODE (operands[0]) == GET_MODE (operands[1])
6850    && GET_MODE (operands[0]) == GET_MODE (operands[2])
6851    && GET_MODE (operands[0]) == DFmode
6852    && GET_CODE (operands[0]) == REG
6853    && GET_CODE (operands[2]) == REG
6854    && ! side_effects_p (XEXP (operands[1], 0))
6855    && REGNO_REG_CLASS (REGNO (operands[0]))
6856       == REGNO_REG_CLASS (REGNO (operands[2]))"
6857   "*
6858 {
6859   rtx xoperands[2];
6860
6861   if (FP_REG_P (operands[0]))
6862     output_asm_insn (output_fp_move_double (operands), operands);
6863   else
6864     output_asm_insn (output_move_double (operands), operands);
6865
6866   xoperands[0] = operands[2];
6867   xoperands[1] = operands[0];
6868       
6869   if (FP_REG_P (xoperands[1]))
6870     output_asm_insn (output_fp_move_double (xoperands), xoperands);
6871   else
6872     output_asm_insn (output_move_double (xoperands), xoperands);
6873
6874   return \"\";
6875 }")
6876
6877 ;; Flush the I and D cache line found at the address in operand 0.
6878 ;; This is used by the trampoline code for nested functions.
6879 ;; So long as the trampoline itself is less than 32 bytes this
6880 ;; is sufficient.
6881
6882 (define_insn "dcacheflush"
6883   [(unspec_volatile [(const_int 1)] 0)
6884    (use (mem:SI (match_operand 0 "pmode_register_operand" "r")))
6885    (use (mem:SI (match_operand 1 "pmode_register_operand" "r")))]
6886   ""
6887   "fdc 0(%0)\;fdc 0(%1)\;sync"
6888   [(set_attr "type" "multi")
6889    (set_attr "length" "12")])
6890
6891 (define_insn "icacheflush"
6892   [(unspec_volatile [(const_int 2)] 0)
6893    (use (mem:SI (match_operand 0 "pmode_register_operand" "r")))
6894    (use (mem:SI (match_operand 1 "pmode_register_operand" "r")))
6895    (use (match_operand 2 "pmode_register_operand" "r"))
6896    (clobber (match_operand 3 "pmode_register_operand" "=&r"))
6897    (clobber (match_operand 4 "pmode_register_operand" "=&r"))]
6898   ""
6899   "mfsp %%sr0,%4\;ldsid (%2),%3\;mtsp %3,%%sr0\;fic 0(%%sr0,%0)\;fic 0(%%sr0,%1)\;sync\;mtsp %4,%%sr0\;nop\;nop\;nop\;nop\;nop\;nop"
6900   [(set_attr "type" "multi")
6901    (set_attr "length" "52")])
6902
6903 ;; An out-of-line prologue.
6904 (define_insn "outline_prologue_call"
6905   [(unspec_volatile [(const_int 0)] 0)
6906    (clobber (reg:SI 31))
6907    (clobber (reg:SI 22))
6908    (clobber (reg:SI 21))
6909    (clobber (reg:SI 20))
6910    (clobber (reg:SI 19))
6911    (clobber (reg:SI 1))]
6912   ""
6913   "*
6914 {
6915   extern int frame_pointer_needed;
6916
6917   /* We need two different versions depending on whether or not we
6918      need a frame pointer.   Also note that we return to the instruction
6919      immediately after the branch rather than two instructions after the
6920      break as normally is the case.  */
6921   if (frame_pointer_needed)
6922     {
6923       /* Must import the magic millicode routine(s).  */
6924       output_asm_insn (\".IMPORT __outline_prologue_fp,MILLICODE\", NULL);
6925
6926       if (TARGET_PORTABLE_RUNTIME)
6927         {
6928           output_asm_insn (\"ldil L'__outline_prologue_fp,%%r31\", NULL);
6929           output_asm_insn (\"ble,n R'__outline_prologue_fp(%%sr0,%%r31)\",
6930                            NULL);
6931         }
6932       else
6933         output_asm_insn (\"{bl|b,l},n __outline_prologue_fp,%%r31\", NULL);
6934     }
6935   else
6936     {
6937       /* Must import the magic millicode routine(s).  */
6938       output_asm_insn (\".IMPORT __outline_prologue,MILLICODE\", NULL);
6939
6940       if (TARGET_PORTABLE_RUNTIME)
6941         {
6942           output_asm_insn (\"ldil L'__outline_prologue,%%r31\", NULL);
6943           output_asm_insn (\"ble,n R'__outline_prologue(%%sr0,%%r31)\", NULL);
6944         }
6945       else
6946         output_asm_insn (\"{bl|b,l},n __outline_prologue,%%r31\", NULL);
6947     }
6948   return \"\";
6949 }"
6950   [(set_attr "type" "multi")
6951    (set_attr "length" "8")])
6952
6953 ;; An out-of-line epilogue.
6954 (define_insn "outline_epilogue_call"
6955   [(unspec_volatile [(const_int 1)] 0)
6956    (use (reg:SI 29))
6957    (use (reg:SI 28))
6958    (clobber (reg:SI 31))
6959    (clobber (reg:SI 22))
6960    (clobber (reg:SI 21))
6961    (clobber (reg:SI 20))
6962    (clobber (reg:SI 19))
6963    (clobber (reg:SI 2))
6964    (clobber (reg:SI 1))]
6965   ""
6966   "*
6967 {
6968   extern int frame_pointer_needed;
6969
6970   /* We need two different versions depending on whether or not we
6971      need a frame pointer.   Also note that we return to the instruction
6972      immediately after the branch rather than two instructions after the
6973      break as normally is the case.  */
6974   if (frame_pointer_needed)
6975     {
6976       /* Must import the magic millicode routine.  */
6977       output_asm_insn (\".IMPORT __outline_epilogue_fp,MILLICODE\", NULL);
6978
6979       /* The out-of-line prologue will make sure we return to the right
6980          instruction.  */
6981       if (TARGET_PORTABLE_RUNTIME)
6982         {
6983           output_asm_insn (\"ldil L'__outline_epilogue_fp,%%r31\", NULL);
6984           output_asm_insn (\"ble,n R'__outline_epilogue_fp(%%sr0,%%r31)\",
6985                            NULL);
6986         }
6987       else
6988         output_asm_insn (\"{bl|b,l},n __outline_epilogue_fp,%%r31\", NULL);
6989     }
6990   else
6991     {
6992       /* Must import the magic millicode routine.  */
6993       output_asm_insn (\".IMPORT __outline_epilogue,MILLICODE\", NULL);
6994
6995       /* The out-of-line prologue will make sure we return to the right
6996          instruction.  */
6997       if (TARGET_PORTABLE_RUNTIME)
6998         {
6999           output_asm_insn (\"ldil L'__outline_epilogue,%%r31\", NULL);
7000           output_asm_insn (\"ble,n R'__outline_epilogue(%%sr0,%%r31)\", NULL);
7001         }
7002       else
7003         output_asm_insn (\"{bl|b,l},n __outline_epilogue,%%r31\", NULL);
7004     }
7005   return \"\";
7006 }"
7007   [(set_attr "type" "multi")
7008    (set_attr "length" "8")])
7009
7010 ;; Given a function pointer, canonicalize it so it can be 
7011 ;; reliably compared to another function pointer.  */
7012 (define_expand "canonicalize_funcptr_for_compare"
7013   [(set (reg:SI 26) (match_operand:SI 1 "register_operand" ""))
7014    (parallel [(set (reg:SI 29) (unspec:SI [(reg:SI 26)] 0))
7015               (clobber (match_dup 2))
7016               (clobber (reg:SI 26))
7017               (clobber (reg:SI 22))
7018               (clobber (reg:SI 31))])
7019    (set (match_operand:SI 0 "register_operand" "")
7020         (reg:SI 29))]
7021   "! TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7022   "
7023 {
7024   operands[2] = gen_reg_rtx (SImode);
7025   if (GET_CODE (operands[1]) != REG)
7026     {
7027       rtx tmp = gen_reg_rtx (Pmode);
7028       emit_move_insn (tmp, operands[1]);
7029       operands[1] = tmp;
7030     }
7031 }")
7032
7033 (define_insn ""
7034   [(set (reg:SI 29) (unspec:SI [(reg:SI 26)] 0))
7035    (clobber (match_operand:SI 0 "register_operand" "=a"))
7036    (clobber (reg:SI 26))
7037    (clobber (reg:SI 22))
7038    (clobber (reg:SI 31))]
7039   "!TARGET_64BIT"
7040   "*
7041 {
7042   /* Must import the magic millicode routine.  */
7043   output_asm_insn (\".IMPORT $$sh_func_adrs,MILLICODE\", NULL);
7044
7045   /* This is absolutely amazing.
7046
7047      First, copy our input parameter into %r29 just in case we don't
7048      need to call $$sh_func_adrs.  */
7049   output_asm_insn (\"copy %%r26,%%r29\", NULL);
7050
7051   /* Next, examine the low two bits in %r26, if they aren't 0x2, then
7052      we use %r26 unchanged.  */
7053   if (get_attr_length (insn) == 32)
7054     output_asm_insn (\"{extru|extrw,u} %%r26,31,2,%%r31\;{comib|cmpib},<>,n 2,%%r31,.+24\", NULL);
7055   else if (get_attr_length (insn) == 40)
7056     output_asm_insn (\"{extru|extrw,u} %%r26,31,2,%%r31\;{comib|cmpib},<>,n 2,%%r31,.+32\", NULL);
7057   else if (get_attr_length (insn) == 44)
7058     output_asm_insn (\"{extru|extrw,u} %%r26,31,2,%%r31\;{comib|cmpib},<>,n 2,%%r31,.+36\", NULL);
7059   else
7060     output_asm_insn (\"{extru|extrw,u} %%r26,31,2,%%r31\;{comib|cmpib},<>,n 2,%%r31,.+20\", NULL);
7061
7062   /* Next, compare %r26 with 4096, if %r26 is less than or equal to
7063      4096, then we use %r26 unchanged.  */
7064   if (get_attr_length (insn) == 32)
7065     output_asm_insn (\"ldi 4096,%%r31\;{comb|cmpb},<<,n %%r26,%%r31,.+16\",
7066                      NULL);
7067   else if (get_attr_length (insn) == 40)
7068     output_asm_insn (\"ldi 4096,%%r31\;{comb|cmpb},<<,n %%r26,%%r31,.+24\",
7069                      NULL);
7070   else if (get_attr_length (insn) == 44)
7071     output_asm_insn (\"ldi 4096,%%r31\;{comb|cmpb},<<,n %%r26,%%r31,.+28\",
7072                      NULL);
7073   else
7074     output_asm_insn (\"ldi 4096,%%r31\;{comb|cmpb},<<,n %%r26,%%r31,.+12\",
7075                      NULL);
7076
7077   /* Else call $$sh_func_adrs to extract the function's real add24.  */
7078   return output_millicode_call (insn,
7079                                 gen_rtx_SYMBOL_REF (SImode,
7080                                          \"$$sh_func_adrs\"));
7081 }"
7082   [(set_attr "type" "multi")
7083    (set (attr "length")
7084      (cond [
7085 ;; Target (or stub) within reach
7086             (and (lt (plus (symbol_ref "total_code_bytes") (pc))
7087                      (const_int 240000))
7088                  (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
7089                      (const_int 0)))
7090             (const_int 28)
7091
7092 ;; NO_SPACE_REGS
7093             (ne (symbol_ref "TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS")
7094                 (const_int 0))
7095             (const_int 32)
7096
7097 ;; Out of reach, but not PIC or PORTABLE_RUNTIME
7098 ;; same as NO_SPACE_REGS code
7099             (and (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
7100                      (const_int 0))
7101                  (eq (symbol_ref "flag_pic")
7102                      (const_int 0)))
7103             (const_int 32)
7104
7105 ;; PORTABLE_RUNTIME
7106             (ne (symbol_ref "TARGET_PORTABLE_RUNTIME")
7107                 (const_int 0))
7108             (const_int 40)]
7109
7110 ;; Out of range and PIC 
7111           (const_int 44)))])
7112
7113 ;; On the PA, the PIC register is call clobbered, so it must
7114 ;; be saved & restored around calls by the caller.  If the call
7115 ;; doesn't return normally (nonlocal goto, or an exception is
7116 ;; thrown), then the code at the exception handler label must
7117 ;; restore the PIC register.
7118 (define_expand "exception_receiver"
7119   [(const_int 4)]
7120   "!TARGET_PORTABLE_RUNTIME && flag_pic"
7121   "
7122 {
7123   /* Load the PIC register from the stack slot (in our caller's
7124      frame).  */
7125   emit_move_insn (pic_offset_table_rtx,
7126                   gen_rtx_MEM (SImode,
7127                                plus_constant (stack_pointer_rtx, -32)));
7128   emit_insn (gen_rtx (USE, VOIDmode, pic_offset_table_rtx));
7129   emit_insn (gen_blockage ());
7130   DONE;
7131 }")