OSDN Git Service

* Makefile.in (INSN_ATTR_H): New macro. Replace all dependencies
[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
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 5 "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},%S5 %4,%3,%%r0\;ldi 0,%0
1109    {com%I4clr|cmp%I4clr},%B5 %4,%3,%0\;ldi %1,%0
1110    {com%I4clr|cmp%I4clr},%B5 %4,%3,%0\;ldil L'%1,%0
1111    {com%I4clr|cmp%I4clr},%B5 %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 5 "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,*%S5 %4,%3,%%r0\;ldi 0,%0
1176    cmp%I4clr,*%B5 %4,%3,%0\;copy %1,%0
1177    cmp%I4clr,*%B5 %4,%3,%0\;ldi %1,%0
1178    cmp%I4clr,*%B5 %4,%3,%0\;ldil L'%1,%0
1179    cmp%I4clr,*%B5 %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 ;; Match the branch patterns.
1373
1374
1375 ;; Note a long backward conditional branch with an annulled delay slot
1376 ;; has a length of 12.
1377 (define_insn ""
1378   [(set (pc)
1379         (if_then_else
1380          (match_operator 3 "comparison_operator"
1381                          [(match_operand:SI 1 "reg_or_0_operand" "rM")
1382                           (match_operand:SI 2 "arith5_operand" "rL")])
1383          (label_ref (match_operand 0 "" ""))
1384          (pc)))]
1385   ""
1386   "*
1387 {
1388   return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1389                          get_attr_length (insn), 0, insn);
1390 }"
1391 [(set_attr "type" "cbranch")
1392  (set (attr "length")
1393     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1394                (const_int 8184))
1395            (const_int 4)
1396            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1397                (const_int 262100))
1398            (const_int 8)
1399            (eq (symbol_ref "flag_pic") (const_int 0))
1400            (const_int 20)]
1401           (const_int 28)))])
1402
1403 ;; Match the negated branch.
1404
1405 (define_insn ""
1406   [(set (pc)
1407         (if_then_else
1408          (match_operator 3 "comparison_operator"
1409                          [(match_operand:SI 1 "reg_or_0_operand" "rM")
1410                           (match_operand:SI 2 "arith5_operand" "rL")])
1411          (pc)
1412          (label_ref (match_operand 0 "" ""))))]
1413   ""
1414   "*
1415 {
1416   return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1417                          get_attr_length (insn), 1, insn);
1418 }"
1419 [(set_attr "type" "cbranch")
1420  (set (attr "length")
1421     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1422                (const_int 8184))
1423            (const_int 4)
1424            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1425                (const_int 262100))
1426            (const_int 8)
1427            (eq (symbol_ref "flag_pic") (const_int 0))
1428            (const_int 20)]
1429           (const_int 28)))])
1430
1431 (define_insn ""
1432   [(set (pc)
1433         (if_then_else
1434          (match_operator 3 "comparison_operator"
1435                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1436                           (match_operand:DI 2 "reg_or_0_operand" "rM")])
1437          (label_ref (match_operand 0 "" ""))
1438          (pc)))]
1439   "TARGET_64BIT"
1440   "*
1441 {
1442   return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1443                          get_attr_length (insn), 0, insn);
1444 }"
1445 [(set_attr "type" "cbranch")
1446  (set (attr "length")
1447     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1448                (const_int 8184))
1449            (const_int 4)
1450            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1451                (const_int 262100))
1452            (const_int 8)
1453            (eq (symbol_ref "flag_pic") (const_int 0))
1454            (const_int 20)]
1455           (const_int 28)))])
1456
1457 ;; Match the negated branch.
1458
1459 (define_insn ""
1460   [(set (pc)
1461         (if_then_else
1462          (match_operator 3 "comparison_operator"
1463                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1464                           (match_operand:DI 2 "reg_or_0_operand" "rM")])
1465          (pc)
1466          (label_ref (match_operand 0 "" ""))))]
1467   "TARGET_64BIT"
1468   "*
1469 {
1470   return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1471                          get_attr_length (insn), 1, insn);
1472 }"
1473 [(set_attr "type" "cbranch")
1474  (set (attr "length")
1475     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1476                (const_int 8184))
1477            (const_int 4)
1478            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1479                (const_int 262100))
1480            (const_int 8)
1481            (eq (symbol_ref "flag_pic") (const_int 0))
1482            (const_int 20)]
1483           (const_int 28)))])
1484 (define_insn ""
1485   [(set (pc)
1486         (if_then_else
1487          (match_operator 3 "cmpib_comparison_operator"
1488                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1489                           (match_operand:DI 2 "arith5_operand" "rL")])
1490          (label_ref (match_operand 0 "" ""))
1491          (pc)))]
1492   "TARGET_64BIT"
1493   "*
1494 {
1495   return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1496                          get_attr_length (insn), 0, insn);
1497 }"
1498 [(set_attr "type" "cbranch")
1499  (set (attr "length")
1500     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1501                (const_int 8184))
1502            (const_int 4)
1503            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1504                (const_int 262100))
1505            (const_int 8)
1506            (eq (symbol_ref "flag_pic") (const_int 0))
1507            (const_int 20)]
1508           (const_int 28)))])
1509
1510 ;; Match the negated branch.
1511
1512 (define_insn ""
1513   [(set (pc)
1514         (if_then_else
1515          (match_operator 3 "cmpib_comparison_operator"
1516                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1517                           (match_operand:DI 2 "arith5_operand" "rL")])
1518          (pc)
1519          (label_ref (match_operand 0 "" ""))))]
1520   "TARGET_64BIT"
1521   "*
1522 {
1523   return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1524                          get_attr_length (insn), 1, insn);
1525 }"
1526 [(set_attr "type" "cbranch")
1527  (set (attr "length")
1528     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1529                (const_int 8184))
1530            (const_int 4)
1531            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1532                (const_int 262100))
1533            (const_int 8)
1534            (eq (symbol_ref "flag_pic") (const_int 0))
1535            (const_int 20)]
1536           (const_int 28)))])
1537
1538 ;; Branch on Bit patterns.
1539 (define_insn ""
1540   [(set (pc)
1541         (if_then_else
1542          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1543                               (const_int 1)
1544                               (match_operand:SI 1 "uint5_operand" ""))
1545              (const_int 0))
1546          (label_ref (match_operand 2 "" ""))
1547          (pc)))]
1548   ""
1549   "*
1550 {
1551   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1552                          get_attr_length (insn), 0, insn, 0);
1553 }"
1554 [(set_attr "type" "cbranch")
1555  (set (attr "length")
1556     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1557                       (const_int 8184))
1558            (const_int 4)
1559            (const_int 8)))])
1560
1561 (define_insn ""
1562   [(set (pc)
1563         (if_then_else
1564          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1565                               (const_int 1)
1566                               (match_operand:DI 1 "uint32_operand" ""))
1567              (const_int 0))
1568          (label_ref (match_operand 2 "" ""))
1569          (pc)))]
1570   "TARGET_64BIT"
1571   "*
1572 {
1573   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1574                          get_attr_length (insn), 0, insn, 0);
1575 }"
1576 [(set_attr "type" "cbranch")
1577  (set (attr "length")
1578     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1579                       (const_int 8184))
1580            (const_int 4)
1581            (const_int 8)))])
1582
1583 (define_insn ""
1584   [(set (pc)
1585         (if_then_else
1586          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1587                               (const_int 1)
1588                               (match_operand:SI 1 "uint5_operand" ""))
1589              (const_int 0))
1590          (pc)
1591          (label_ref (match_operand 2 "" ""))))]
1592   ""
1593   "*
1594 {
1595   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1596                          get_attr_length (insn), 1, insn, 0);
1597 }"
1598 [(set_attr "type" "cbranch")
1599  (set (attr "length")
1600     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1601                       (const_int 8184))
1602            (const_int 4)
1603            (const_int 8)))])
1604
1605 (define_insn ""
1606   [(set (pc)
1607         (if_then_else
1608          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1609                               (const_int 1)
1610                               (match_operand:DI 1 "uint32_operand" ""))
1611              (const_int 0))
1612          (pc)
1613          (label_ref (match_operand 2 "" ""))))]
1614   "TARGET_64BIT"
1615   "*
1616 {
1617   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1618                          get_attr_length (insn), 1, insn, 0);
1619 }"
1620 [(set_attr "type" "cbranch")
1621  (set (attr "length")
1622     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1623                       (const_int 8184))
1624            (const_int 4)
1625            (const_int 8)))])
1626
1627 (define_insn ""
1628   [(set (pc)
1629         (if_then_else
1630          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1631                               (const_int 1)
1632                               (match_operand:SI 1 "uint5_operand" ""))
1633              (const_int 0))
1634          (label_ref (match_operand 2 "" ""))
1635          (pc)))]
1636   ""
1637   "*
1638 {
1639   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1640                          get_attr_length (insn), 0, insn, 1);
1641 }"
1642 [(set_attr "type" "cbranch")
1643  (set (attr "length")
1644     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1645                       (const_int 8184))
1646            (const_int 4)
1647            (const_int 8)))])
1648
1649 (define_insn ""
1650   [(set (pc)
1651         (if_then_else
1652          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1653                               (const_int 1)
1654                               (match_operand:DI 1 "uint32_operand" ""))
1655              (const_int 0))
1656          (label_ref (match_operand 2 "" ""))
1657          (pc)))]
1658   "TARGET_64BIT"
1659   "*
1660 {
1661   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1662                          get_attr_length (insn), 0, insn, 1);
1663 }"
1664 [(set_attr "type" "cbranch")
1665  (set (attr "length")
1666     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1667                       (const_int 8184))
1668            (const_int 4)
1669            (const_int 8)))])
1670
1671 (define_insn ""
1672   [(set (pc)
1673         (if_then_else
1674          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1675                               (const_int 1)
1676                               (match_operand:SI 1 "uint5_operand" ""))
1677              (const_int 0))
1678          (pc)
1679          (label_ref (match_operand 2 "" ""))))]
1680   ""
1681   "*
1682 {
1683   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1684                          get_attr_length (insn), 1, insn, 1);
1685 }"
1686 [(set_attr "type" "cbranch")
1687  (set (attr "length")
1688     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1689                       (const_int 8184))
1690            (const_int 4)
1691            (const_int 8)))])
1692
1693 (define_insn ""
1694   [(set (pc)
1695         (if_then_else
1696          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1697                               (const_int 1)
1698                               (match_operand:DI 1 "uint32_operand" ""))
1699              (const_int 0))
1700          (pc)
1701          (label_ref (match_operand 2 "" ""))))]
1702   "TARGET_64BIT"
1703   "*
1704 {
1705   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1706                          get_attr_length (insn), 1, insn, 1);
1707 }"
1708 [(set_attr "type" "cbranch")
1709  (set (attr "length")
1710     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1711                       (const_int 8184))
1712            (const_int 4)
1713            (const_int 8)))])
1714
1715 ;; Branch on Variable Bit patterns.
1716 (define_insn ""
1717   [(set (pc)
1718         (if_then_else
1719          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1720                               (const_int 1)
1721                               (match_operand:SI 1 "register_operand" "q"))
1722              (const_int 0))
1723          (label_ref (match_operand 2 "" ""))
1724          (pc)))]
1725   ""
1726   "*
1727 {
1728   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
1729                      get_attr_length (insn), 0, insn, 0);
1730 }"
1731 [(set_attr "type" "cbranch")
1732  (set (attr "length")
1733     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1734                       (const_int 8184))
1735            (const_int 4)
1736            (const_int 8)))])
1737
1738 (define_insn ""
1739   [(set (pc)
1740         (if_then_else
1741          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1742                               (const_int 1)
1743                               (match_operand:DI 1 "register_operand" "q"))
1744              (const_int 0))
1745          (label_ref (match_operand 2 "" ""))
1746          (pc)))]
1747   "TARGET_64BIT"
1748   "*
1749 {
1750   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
1751                      get_attr_length (insn), 0, insn, 0);
1752 }"
1753 [(set_attr "type" "cbranch")
1754  (set (attr "length")
1755     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1756                       (const_int 8184))
1757            (const_int 4)
1758            (const_int 8)))])
1759
1760 (define_insn ""
1761   [(set (pc)
1762         (if_then_else
1763          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1764                               (const_int 1)
1765                               (match_operand:SI 1 "register_operand" "q"))
1766              (const_int 0))
1767          (pc)
1768          (label_ref (match_operand 2 "" ""))))]
1769   ""
1770   "*
1771 {
1772   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
1773                      get_attr_length (insn), 1, insn, 0);
1774 }"
1775 [(set_attr "type" "cbranch")
1776  (set (attr "length")
1777     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1778                       (const_int 8184))
1779            (const_int 4)
1780            (const_int 8)))])
1781
1782 (define_insn ""
1783   [(set (pc)
1784         (if_then_else
1785          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1786                               (const_int 1)
1787                               (match_operand:DI 1 "register_operand" "q"))
1788              (const_int 0))
1789          (pc)
1790          (label_ref (match_operand 2 "" ""))))]
1791   "TARGET_64BIT"
1792   "*
1793 {
1794   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
1795                      get_attr_length (insn), 1, insn, 0);
1796 }"
1797 [(set_attr "type" "cbranch")
1798  (set (attr "length")
1799     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1800                       (const_int 8184))
1801            (const_int 4)
1802            (const_int 8)))])
1803
1804 (define_insn ""
1805   [(set (pc)
1806         (if_then_else
1807          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1808                               (const_int 1)
1809                               (match_operand:SI 1 "register_operand" "q"))
1810              (const_int 0))
1811          (label_ref (match_operand 2 "" ""))
1812          (pc)))]
1813   ""
1814   "*
1815 {
1816   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
1817                      get_attr_length (insn), 0, insn, 1);
1818 }"
1819 [(set_attr "type" "cbranch")
1820  (set (attr "length")
1821     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1822                       (const_int 8184))
1823            (const_int 4)
1824            (const_int 8)))])
1825
1826 (define_insn ""
1827   [(set (pc)
1828         (if_then_else
1829          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1830                               (const_int 1)
1831                               (match_operand:DI 1 "register_operand" "q"))
1832              (const_int 0))
1833          (label_ref (match_operand 2 "" ""))
1834          (pc)))]
1835   "TARGET_64BIT"
1836   "*
1837 {
1838   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
1839                      get_attr_length (insn), 0, insn, 1);
1840 }"
1841 [(set_attr "type" "cbranch")
1842  (set (attr "length")
1843     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1844                       (const_int 8184))
1845            (const_int 4)
1846            (const_int 8)))])
1847
1848 (define_insn ""
1849   [(set (pc)
1850         (if_then_else
1851          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1852                               (const_int 1)
1853                               (match_operand:SI 1 "register_operand" "q"))
1854              (const_int 0))
1855          (pc)
1856          (label_ref (match_operand 2 "" ""))))]
1857   ""
1858   "*
1859 {
1860   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
1861                      get_attr_length (insn), 1, insn, 1);
1862 }"
1863 [(set_attr "type" "cbranch")
1864  (set (attr "length")
1865     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1866                       (const_int 8184))
1867            (const_int 4)
1868            (const_int 8)))])
1869
1870 (define_insn ""
1871   [(set (pc)
1872         (if_then_else
1873          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1874                               (const_int 1)
1875                               (match_operand:DI 1 "register_operand" "q"))
1876              (const_int 0))
1877          (pc)
1878          (label_ref (match_operand 2 "" ""))))]
1879   "TARGET_64BIT"
1880   "*
1881 {
1882   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
1883                      get_attr_length (insn), 1, insn, 1);
1884 }"
1885 [(set_attr "type" "cbranch")
1886  (set (attr "length")
1887     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1888                       (const_int 8184))
1889            (const_int 4)
1890            (const_int 8)))])
1891
1892 ;; Floating point branches
1893 (define_insn ""
1894   [(set (pc) (if_then_else (ne (reg:CCFP 0) (const_int 0))
1895                            (label_ref (match_operand 0 "" ""))
1896                            (pc)))]
1897   "! TARGET_SOFT_FLOAT"
1898   "*
1899 {
1900   if (INSN_ANNULLED_BRANCH_P (insn))
1901     return \"ftest\;b,n %0\";
1902   else
1903     return \"ftest\;b%* %0\";
1904 }"
1905   [(set_attr "type" "fbranch")
1906    (set_attr "length" "8")])
1907
1908 (define_insn ""
1909   [(set (pc) (if_then_else (ne (reg:CCFP 0) (const_int 0))
1910                            (pc)
1911                            (label_ref (match_operand 0 "" ""))))]
1912   "! TARGET_SOFT_FLOAT"
1913   "*
1914 {
1915   if (INSN_ANNULLED_BRANCH_P (insn))
1916     return \"ftest\;add,tr %%r0,%%r0,%%r0\;b,n %0\";
1917   else
1918     return \"ftest\;add,tr %%r0,%%r0,%%r0\;b%* %0\";
1919 }"
1920   [(set_attr "type" "fbranch")
1921    (set_attr "length" "12")])
1922
1923 ;; Move instructions
1924
1925 (define_expand "movsi"
1926   [(set (match_operand:SI 0 "general_operand" "")
1927         (match_operand:SI 1 "general_operand" ""))]
1928   ""
1929   "
1930 {
1931   if (emit_move_sequence (operands, SImode, 0))
1932     DONE;
1933 }")
1934
1935 ;; Reloading an SImode or DImode value requires a scratch register if
1936 ;; going in to or out of float point registers.
1937
1938 (define_expand "reload_insi"
1939   [(set (match_operand:SI 0 "register_operand" "=Z")
1940         (match_operand:SI 1 "non_hard_reg_operand" ""))
1941    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
1942   ""
1943   "
1944 {
1945   if (emit_move_sequence (operands, SImode, operands[2]))
1946     DONE;
1947
1948   /* We don't want the clobber emitted, so handle this ourselves.  */
1949   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
1950   DONE;
1951 }")
1952
1953 (define_expand "reload_outsi"
1954   [(set (match_operand:SI 0 "non_hard_reg_operand" "")
1955         (match_operand:SI 1  "register_operand" "Z"))
1956    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
1957   ""
1958   "
1959 {
1960   if (emit_move_sequence (operands, SImode, operands[2]))
1961     DONE;
1962
1963   /* We don't want the clobber emitted, so handle this ourselves.  */
1964   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
1965   DONE;
1966 }")
1967
1968 ;;; pic symbol references
1969
1970 (define_insn ""
1971   [(set (match_operand:SI 0 "register_operand" "=r")
1972         (mem:SI (plus:SI (match_operand:SI 1 "register_operand" "r")
1973                          (match_operand:SI 2 "symbolic_operand" ""))))]
1974   "flag_pic && operands[1] == pic_offset_table_rtx"
1975   "ldw T'%2(%1),%0"
1976   [(set_attr "type" "load")
1977    (set_attr "length" "4")])
1978
1979 (define_insn ""
1980   [(set (match_operand:SI 0 "reg_or_nonsymb_mem_operand"
1981                                 "=r,r,r,r,r,Q,*q,!f,f,*TR")
1982         (match_operand:SI 1 "move_operand"
1983                                 "r,J,N,K,RQ,rM,rM,!fM,*RT,f"))]
1984   "(register_operand (operands[0], SImode)
1985     || reg_or_0_operand (operands[1], SImode))
1986    && ! TARGET_SOFT_FLOAT"
1987   "@
1988    copy %1,%0
1989    ldi %1,%0
1990    ldil L'%1,%0
1991    {zdepi|depwi,z} %Z1,%0
1992    ldw%M1 %1,%0
1993    stw%M0 %r1,%0
1994    mtsar %r1
1995    fcpy,sgl %f1,%0
1996    fldw%F1 %1,%0
1997    fstw%F0 %1,%0"
1998   [(set_attr "type" "move,move,move,shift,load,store,move,fpalu,fpload,fpstore")
1999    (set_attr "pa_combine_type" "addmove")
2000    (set_attr "length" "4,4,4,4,4,4,4,4,4,4")])
2001
2002 (define_insn ""
2003   [(set (match_operand:SI 0 "reg_or_nonsymb_mem_operand"
2004                                 "=r,r,r,r,r,Q,*q")
2005         (match_operand:SI 1 "move_operand"
2006                                 "r,J,N,K,RQ,rM,rM"))]
2007   "(register_operand (operands[0], SImode)
2008     || reg_or_0_operand (operands[1], SImode))
2009    && TARGET_SOFT_FLOAT"
2010   "@
2011    copy %1,%0
2012    ldi %1,%0
2013    ldil L'%1,%0
2014    {zdepi|depwi,z} %Z1,%0
2015    ldw%M1 %1,%0
2016    stw%M0 %r1,%0
2017    mtsar %r1"
2018   [(set_attr "type" "move,move,move,move,load,store,move")
2019    (set_attr "pa_combine_type" "addmove")
2020    (set_attr "length" "4,4,4,4,4,4,4")])
2021
2022 (define_insn ""
2023   [(set (match_operand:SI 0 "register_operand" "=r")
2024         (mem:SI (plus:SI (match_operand:SI 1 "basereg_operand" "r")
2025                          (match_operand:SI 2 "register_operand" "r"))))]
2026   "! TARGET_DISABLE_INDEXING"
2027   "*
2028 {
2029   /* Reload can create backwards (relative to cse) unscaled index
2030      address modes when eliminating registers and possibly for
2031      pseudos that don't get hard registers.  Deal with it.  */
2032   if (operands[2] == hard_frame_pointer_rtx
2033       || operands[2] == stack_pointer_rtx)
2034     return \"{ldwx|ldw} %1(%2),%0\";
2035   else
2036     return \"{ldwx|ldw} %2(%1),%0\";
2037 }"
2038   [(set_attr "type" "load")
2039    (set_attr "length" "4")])
2040
2041 (define_insn ""
2042   [(set (match_operand:SI 0 "register_operand" "=r")
2043         (mem:SI (plus:SI (match_operand:SI 1 "register_operand" "r")
2044                          (match_operand:SI 2 "basereg_operand" "r"))))]
2045   "! TARGET_DISABLE_INDEXING"
2046   "*
2047 {
2048   /* Reload can create backwards (relative to cse) unscaled index
2049      address modes when eliminating registers and possibly for
2050      pseudos that don't get hard registers.  Deal with it.  */
2051   if (operands[1] == hard_frame_pointer_rtx
2052       || operands[1] == stack_pointer_rtx)
2053     return \"{ldwx|ldw} %2(%1),%0\";
2054   else
2055     return \"{ldwx|ldw} %1(%2),%0\";
2056 }"
2057   [(set_attr "type" "load")
2058    (set_attr "length" "4")])
2059
2060 ;; Load or store with base-register modification.
2061
2062 (define_expand "pre_load"
2063   [(parallel [(set (match_operand:SI 0 "register_operand" "")
2064               (mem (plus (match_operand 1 "register_operand" "")
2065                                (match_operand 2 "pre_cint_operand" ""))))
2066               (set (match_dup 1)
2067                    (plus (match_dup 1) (match_dup 2)))])]
2068   ""
2069   "
2070 {
2071   if (TARGET_64BIT)
2072     {
2073       emit_insn (gen_pre_ldd (operands[0], operands[1], operands[2]));
2074       DONE;
2075     }
2076   emit_insn (gen_pre_ldw (operands[0], operands[1], operands[2]));
2077   DONE;
2078 }")
2079
2080 (define_insn "pre_ldw"
2081   [(set (match_operand:SI 0 "register_operand" "=r")
2082         (mem:SI (plus:SI (match_operand:SI 1 "register_operand" "+r")
2083                          (match_operand:SI 2 "pre_cint_operand" ""))))
2084    (set (match_dup 1)
2085         (plus:SI (match_dup 1) (match_dup 2)))]
2086   ""
2087   "*
2088 {
2089   if (INTVAL (operands[2]) < 0)
2090     return \"{ldwm|ldw,mb} %2(%1),%0\";
2091   return \"{ldws|ldw},mb %2(%1),%0\";
2092 }"
2093   [(set_attr "type" "load")
2094    (set_attr "length" "4")])
2095
2096 (define_insn "pre_ldd"
2097   [(set (match_operand:DI 0 "register_operand" "=r")
2098         (mem:DI (plus:DI (match_operand:DI 1 "register_operand" "+r")
2099                          (match_operand:DI 2 "pre_cint_operand" ""))))
2100    (set (match_dup 1)
2101         (plus:DI (match_dup 1) (match_dup 2)))]
2102   "TARGET_64BIT"
2103   "ldd,mb %2(%1),%0"
2104   [(set_attr "type" "load")
2105    (set_attr "length" "4")])
2106
2107 (define_insn ""
2108   [(set (mem:SI (plus:SI (match_operand:SI 0 "register_operand" "+r")
2109                          (match_operand:SI 1 "pre_cint_operand" "")))
2110         (match_operand:SI 2 "reg_or_0_operand" "rM"))
2111    (set (match_dup 0)
2112         (plus:SI (match_dup 0) (match_dup 1)))]
2113   ""
2114   "*
2115 {
2116   if (INTVAL (operands[1]) < 0)
2117     return \"{stwm|stw,mb} %r2,%1(%0)\";
2118   return \"{stws|stw},mb %r2,%1(%0)\";
2119 }"
2120   [(set_attr "type" "store")
2121    (set_attr "length" "4")])
2122
2123 (define_insn ""
2124   [(set (match_operand:SI 0 "register_operand" "=r")
2125         (mem:SI (match_operand:SI 1 "register_operand" "+r")))
2126    (set (match_dup 1)
2127         (plus:SI (match_dup 1)
2128                  (match_operand:SI 2 "post_cint_operand" "")))]
2129   ""
2130   "*
2131 {
2132   if (INTVAL (operands[2]) > 0)
2133     return \"{ldwm|ldw,ma} %2(%1),%0\";
2134   return \"{ldws|ldw},ma %2(%1),%0\";
2135 }"
2136   [(set_attr "type" "load")
2137    (set_attr "length" "4")])
2138
2139 (define_expand "post_store"
2140   [(parallel [(set (mem (match_operand 0 "register_operand" ""))
2141                    (match_operand 1 "reg_or_0_operand" ""))
2142               (set (match_dup 0)
2143                    (plus (match_dup 0)
2144                          (match_operand 2 "post_cint_operand" "")))])]
2145   ""
2146   "
2147 {
2148   if (TARGET_64BIT)
2149     {
2150       emit_insn (gen_post_std (operands[0], operands[1], operands[2]));
2151       DONE;
2152     }
2153   emit_insn (gen_post_stw (operands[0], operands[1], operands[2]));
2154   DONE;
2155 }")
2156
2157 (define_insn "post_stw"
2158   [(set (mem:SI (match_operand:SI 0 "register_operand" "+r"))
2159         (match_operand:SI 1 "reg_or_0_operand" "rM"))
2160    (set (match_dup 0)
2161         (plus:SI (match_dup 0)
2162                  (match_operand:SI 2 "post_cint_operand" "")))]
2163   ""
2164   "*
2165 {
2166   if (INTVAL (operands[2]) > 0)
2167     return \"{stwm|stw,ma} %r1,%2(%0)\";
2168   return \"{stws|stw},ma %r1,%2(%0)\";
2169 }"
2170   [(set_attr "type" "store")
2171    (set_attr "length" "4")])
2172
2173 (define_insn "post_std"
2174   [(set (mem:DI (match_operand:DI 0 "register_operand" "+r"))
2175         (match_operand:DI 1 "reg_or_0_operand" "rM"))
2176    (set (match_dup 0)
2177         (plus:DI (match_dup 0)
2178                  (match_operand:DI 2 "post_cint_operand" "")))]
2179   "TARGET_64BIT"
2180   "std,ma %r1,%2(%0)"
2181   [(set_attr "type" "store")
2182    (set_attr "length" "4")])
2183
2184 ;; For loading the address of a label while generating PIC code.
2185 ;; Note since this pattern can be created at reload time (via movsi), all
2186 ;; the same rules for movsi apply here.  (no new pseudos, no temporaries).
2187 (define_insn ""
2188   [(set (match_operand 0 "pmode_register_operand" "=a")
2189         (match_operand 1 "pic_label_operand" ""))]
2190   ""
2191   "*
2192 {
2193   rtx label_rtx = gen_label_rtx ();
2194   rtx xoperands[3];
2195   extern FILE *asm_out_file;
2196
2197   xoperands[0] = operands[0];
2198   xoperands[1] = operands[1];
2199   xoperands[2] = label_rtx;
2200   output_asm_insn (\"{bl|b,l} .+8,%0\", xoperands);
2201   output_asm_insn (\"{depi|depwi} 0,31,2,%0\", xoperands);
2202   ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\",
2203                              CODE_LABEL_NUMBER (label_rtx));
2204
2205   /* If we're trying to load the address of a label that happens to be
2206      close, then we can use a shorter sequence.  */
2207   if (GET_CODE (operands[1]) == LABEL_REF
2208       && INSN_ADDRESSES_SET_P ()
2209       && abs (INSN_ADDRESSES (INSN_UID (XEXP (operands[1], 0)))
2210                 - INSN_ADDRESSES (INSN_UID (insn))) < 8100)
2211     {
2212       /* Prefixing with R% here is wrong, it extracts just 11 bits and is
2213          always non-negative.  */
2214       output_asm_insn (\"ldo %1-%2(%0),%0\", xoperands);
2215     }
2216   else
2217     {
2218       output_asm_insn (\"addil L%%%1-%2,%0\", xoperands);
2219       output_asm_insn (\"ldo R%%%1-%2(%0),%0\", xoperands);
2220     }
2221   return \"\";
2222 }"
2223   [(set_attr "type" "multi")
2224    (set_attr "length" "16")])           ; 12 or 16
2225
2226 (define_insn ""
2227   [(set (match_operand:SI 0 "register_operand" "=a")
2228         (plus:SI (match_operand:SI 1 "register_operand" "r")
2229                  (high:SI (match_operand 2 "" ""))))]
2230   "symbolic_operand (operands[2], Pmode)
2231    && ! function_label_operand (operands[2], Pmode)
2232    && flag_pic == 2"
2233   "addil LT'%G2,%1"
2234   [(set_attr "type" "binary")
2235    (set_attr "length" "4")])
2236
2237 (define_insn ""
2238   [(set (match_operand:DI 0 "register_operand" "=a")
2239         (plus:DI (match_operand:DI 1 "register_operand" "r")
2240                  (high:DI (match_operand 2 "" ""))))]
2241   "symbolic_operand (operands[2], Pmode)
2242    && ! function_label_operand (operands[2], Pmode)
2243    && TARGET_64BIT
2244    && flag_pic == 2"
2245   "addil LT'%G2,%1"
2246   [(set_attr "type" "binary")
2247    (set_attr "length" "4")])
2248
2249 ; We need this to make sure CSE doesn't simplify a memory load with a
2250 ; symbolic address, whose content it think it knows.  For PIC, what CSE
2251 ; think is the real value will be the address of that value.
2252 (define_insn ""
2253   [(set (match_operand:SI 0 "register_operand" "=r")
2254         (mem:SI
2255           (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
2256                      (unspec:SI
2257                         [(match_operand:SI 2 "symbolic_operand" "")] 0))))]
2258   ""
2259   "*
2260 {
2261   if (flag_pic != 2)
2262     abort ();
2263   return \"ldw RT'%G2(%1),%0\";
2264 }"
2265   [(set_attr "type" "load")
2266    (set_attr "length" "4")])
2267
2268 (define_insn ""
2269   [(set (match_operand:DI 0 "register_operand" "=r")
2270         (mem:DI
2271           (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
2272                      (unspec:DI
2273                         [(match_operand:DI 2 "symbolic_operand" "")] 0))))]
2274   "TARGET_64BIT"
2275   "*
2276 {
2277   if (flag_pic != 2)
2278     abort ();
2279   return \"ldd RT'%G2(%1),%0\";
2280 }"
2281   [(set_attr "type" "load")
2282    (set_attr "length" "4")])
2283
2284 ;; Always use addil rather than ldil;add sequences.  This allows the
2285 ;; HP linker to eliminate the dp relocation if the symbolic operand
2286 ;; lives in the TEXT space.
2287 (define_insn ""
2288   [(set (match_operand:SI 0 "register_operand" "=a")
2289         (high:SI (match_operand 1 "" "")))]
2290   "symbolic_operand (operands[1], Pmode)
2291    && ! function_label_operand (operands[1], Pmode)
2292    && ! read_only_operand (operands[1], Pmode)
2293    && ! flag_pic"
2294   "*
2295 {
2296   if (TARGET_LONG_LOAD_STORE)
2297     return \"addil NLR'%H1,%%r27\;ldo N'%H1(%%r1),%%r1\";
2298   else
2299     return \"addil LR'%H1,%%r27\";
2300 }"
2301   [(set_attr "type" "binary")
2302    (set (attr "length")
2303       (if_then_else (eq (symbol_ref "TARGET_LONG_LOAD_STORE") (const_int 0))
2304                     (const_int 4)
2305                     (const_int 8)))])
2306
2307
2308 ;; This is for use in the prologue/epilogue code.  We need it
2309 ;; to add large constants to a stack pointer or frame pointer.
2310 ;; Because of the additional %r1 pressure, we probably do not
2311 ;; want to use this in general code, so make it available
2312 ;; only after reload.
2313 (define_insn ""
2314   [(set (match_operand:SI 0 "register_operand" "=!a,*r")
2315         (plus:SI (match_operand:SI 1 "register_operand" "r,r")
2316                  (high:SI (match_operand 2 "const_int_operand" ""))))]
2317   "reload_completed"
2318   "@
2319    addil L'%G2,%1
2320    ldil L'%G2,%0\;{addl|add,l} %0,%1,%0"
2321   [(set_attr "type" "binary,binary")
2322    (set_attr "length" "4,8")])
2323
2324 (define_insn ""
2325   [(set (match_operand:DI 0 "register_operand" "=!a,*r")
2326         (plus:DI (match_operand:DI 1 "register_operand" "r,r")
2327                  (high:DI (match_operand 2 "const_int_operand" ""))))]
2328   "reload_completed && TARGET_64BIT"
2329   "@
2330    addil L'%G2,%1
2331    ldil L'%G2,%0\;{addl|add,l} %0,%1,%0"
2332   [(set_attr "type" "binary,binary")
2333    (set_attr "length" "4,8")])
2334
2335 (define_insn ""
2336   [(set (match_operand:SI 0 "register_operand" "=r")
2337         (high:SI (match_operand 1 "" "")))]
2338   "(!flag_pic || !symbolic_operand (operands[1], Pmode))
2339     && !is_function_label_plus_const (operands[1])"
2340   "*
2341 {
2342   if (symbolic_operand (operands[1], Pmode))
2343     return \"ldil LR'%H1,%0\";
2344   else
2345     return \"ldil L'%G1,%0\";
2346 }"
2347   [(set_attr "type" "move")
2348    (set_attr "length" "4")])
2349
2350 (define_insn ""
2351   [(set (match_operand:DI 0 "register_operand" "=r")
2352         (high:DI (match_operand 1 "const_int_operand" "")))]
2353   "TARGET_64BIT"
2354   "ldil L'%G1,%0";
2355   [(set_attr "type" "move")
2356    (set_attr "length" "4")])
2357
2358 (define_insn ""
2359   [(set (match_operand:DI 0 "register_operand" "=r")
2360         (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
2361                    (match_operand:DI 2 "const_int_operand" "i")))]
2362   "TARGET_64BIT"
2363   "ldo R'%G2(%1),%0";
2364   [(set_attr "type" "move")
2365    (set_attr "length" "4")])
2366
2367 (define_insn ""
2368   [(set (match_operand:SI 0 "register_operand" "=r")
2369         (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
2370                    (match_operand:SI 2 "immediate_operand" "i")))]
2371   "!is_function_label_plus_const (operands[2])"
2372   "*
2373 {
2374   if (flag_pic && symbolic_operand (operands[2], Pmode))
2375     abort ();
2376   else if (symbolic_operand (operands[2], Pmode))
2377     return \"ldo RR'%G2(%1),%0\";
2378   else
2379     return \"ldo R'%G2(%1),%0\";
2380 }"
2381   [(set_attr "type" "move")
2382    (set_attr "length" "4")])
2383
2384 ;; Now that a symbolic_address plus a constant is broken up early
2385 ;; in the compilation phase (for better CSE) we need a special
2386 ;; combiner pattern to load the symbolic address plus the constant
2387 ;; in only 2 instructions. (For cases where the symbolic address
2388 ;; was not a common subexpression.)
2389 (define_split
2390   [(set (match_operand:SI 0 "register_operand" "")
2391         (match_operand:SI 1 "symbolic_operand" ""))
2392    (clobber (match_operand:SI 2 "register_operand" ""))]
2393   "! (flag_pic && pic_label_operand (operands[1], SImode))"
2394   [(set (match_dup 2) (high:SI (match_dup 1)))
2395    (set (match_dup 0) (lo_sum:SI (match_dup 2) (match_dup 1)))]
2396   "")
2397
2398 ;; hppa_legitimize_address goes to a great deal of trouble to
2399 ;; create addresses which use indexing.  In some cases, this
2400 ;; is a lose because there isn't any store instructions which
2401 ;; allow indexed addresses (with integer register source).
2402 ;;
2403 ;; These define_splits try to turn a 3 insn store into
2404 ;; a 2 insn store with some creative RTL rewriting.
2405 (define_split
2406   [(set (mem:SI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2407                                (match_operand:SI 1 "shadd_operand" ""))
2408                    (plus:SI (match_operand:SI 2 "register_operand" "")
2409                             (match_operand:SI 3 "const_int_operand" ""))))
2410         (match_operand:SI 4 "register_operand" ""))
2411    (clobber (match_operand:SI 5 "register_operand" ""))]
2412   ""
2413   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
2414                                (match_dup 2)))
2415    (set (mem:SI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2416   "")
2417
2418 (define_split
2419   [(set (mem:HI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2420                                (match_operand:SI 1 "shadd_operand" ""))
2421                    (plus:SI (match_operand:SI 2 "register_operand" "")
2422                             (match_operand:SI 3 "const_int_operand" ""))))
2423         (match_operand:HI 4 "register_operand" ""))
2424    (clobber (match_operand:SI 5 "register_operand" ""))]
2425   ""
2426   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
2427                                (match_dup 2)))
2428    (set (mem:HI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2429   "")
2430
2431 (define_split
2432   [(set (mem:QI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2433                                (match_operand:SI 1 "shadd_operand" ""))
2434                    (plus:SI (match_operand:SI 2 "register_operand" "")
2435                             (match_operand:SI 3 "const_int_operand" ""))))
2436         (match_operand:QI 4 "register_operand" ""))
2437    (clobber (match_operand:SI 5 "register_operand" ""))]
2438   ""
2439   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
2440                                (match_dup 2)))
2441    (set (mem:QI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2442   "")
2443
2444 (define_expand "movhi"
2445   [(set (match_operand:HI 0 "general_operand" "")
2446         (match_operand:HI 1 "general_operand" ""))]
2447   ""
2448   "
2449 {
2450   if (emit_move_sequence (operands, HImode, 0))
2451     DONE;
2452 }")
2453
2454 (define_insn ""
2455   [(set (match_operand:HI 0 "reg_or_nonsymb_mem_operand" "=r,r,r,r,r,Q,*q,!*f")
2456         (match_operand:HI 1 "move_operand" "r,J,N,K,RQ,rM,rM,!*fM"))]
2457   "register_operand (operands[0], HImode)
2458    || reg_or_0_operand (operands[1], HImode)"
2459   "@
2460    copy %1,%0
2461    ldi %1,%0
2462    ldil L'%1,%0
2463    {zdepi|depwi,z} %Z1,%0
2464    ldh%M1 %1,%0
2465    sth%M0 %r1,%0
2466    mtsar %r1
2467    fcpy,sgl %f1,%0"
2468   [(set_attr "type" "move,move,move,shift,load,store,move,fpalu")
2469    (set_attr "pa_combine_type" "addmove")
2470    (set_attr "length" "4,4,4,4,4,4,4,4")])
2471
2472 (define_insn ""
2473   [(set (match_operand:HI 0 "register_operand" "=r")
2474         (mem:HI (plus:SI (match_operand:SI 1 "basereg_operand" "r")
2475                          (match_operand:SI 2 "register_operand" "r"))))]
2476   "! TARGET_DISABLE_INDEXING"
2477   "*
2478 {
2479   /* Reload can create backwards (relative to cse) unscaled index
2480      address modes when eliminating registers and possibly for
2481      pseudos that don't get hard registers.  Deal with it.  */
2482   if (operands[2] == hard_frame_pointer_rtx
2483       || operands[2] == stack_pointer_rtx)
2484     return \"{ldhx|ldh} %1(%2),%0\";
2485   else
2486     return \"{ldhx|ldh} %2(%1),%0\";
2487 }"
2488   [(set_attr "type" "load")
2489    (set_attr "length" "4")])
2490
2491 (define_insn ""
2492   [(set (match_operand:HI 0 "register_operand" "=r")
2493         (mem:HI (plus:SI (match_operand:SI 1 "register_operand" "r")
2494                          (match_operand:SI 2 "basereg_operand" "r"))))]
2495   "! TARGET_DISABLE_INDEXING"
2496   "*
2497 {
2498   /* Reload can create backwards (relative to cse) unscaled index
2499      address modes when eliminating registers and possibly for
2500      pseudos that don't get hard registers.  Deal with it.  */
2501   if (operands[1] == hard_frame_pointer_rtx
2502       || operands[1] == stack_pointer_rtx)
2503     return \"{ldhx|ldh} %2(%1),%0\";
2504   else
2505     return \"{ldhx|ldh} %1(%2),%0\";
2506 }"
2507   [(set_attr "type" "load")
2508    (set_attr "length" "4")])
2509
2510 ; Now zero extended variants.
2511 (define_insn ""
2512   [(set (match_operand:SI 0 "register_operand" "=r")
2513         (zero_extend:SI (mem:HI
2514                           (plus:SI
2515                             (match_operand:SI 1 "basereg_operand" "r")
2516                             (match_operand:SI 2 "register_operand" "r")))))]
2517   "! TARGET_DISABLE_INDEXING"
2518   "*
2519 {
2520   /* Reload can create backwards (relative to cse) unscaled index
2521      address modes when eliminating registers and possibly for
2522      pseudos that don't get hard registers.  Deal with it.  */
2523   if (operands[2] == hard_frame_pointer_rtx
2524       || operands[2] == stack_pointer_rtx)
2525     return \"{ldhx|ldh} %1(%2),%0\";
2526   else
2527     return \"{ldhx|ldh} %2(%1),%0\";
2528 }"
2529   [(set_attr "type" "load")
2530    (set_attr "length" "4")])
2531
2532 (define_insn ""
2533   [(set (match_operand:SI 0 "register_operand" "=r")
2534         (zero_extend:SI (mem:HI
2535                           (plus:SI
2536                              (match_operand:SI 1 "register_operand" "r")
2537                              (match_operand:SI 2 "basereg_operand" "r")))))]
2538   "! TARGET_DISABLE_INDEXING"
2539   "*
2540 {
2541   /* Reload can create backwards (relative to cse) unscaled index
2542      address modes when eliminating registers and possibly for
2543      pseudos that don't get hard registers.  Deal with it.  */
2544   if (operands[1] == hard_frame_pointer_rtx
2545       || operands[1] == stack_pointer_rtx)
2546     return \"{ldhx|ldh} %2(%1),%0\";
2547   else
2548     return \"{ldhx|ldh} %1(%2),%0\";
2549 }"
2550   [(set_attr "type" "load")
2551    (set_attr "length" "4")])
2552
2553 (define_insn ""
2554   [(set (match_operand:HI 0 "register_operand" "=r")
2555         (mem:HI (plus:SI (match_operand:SI 1 "register_operand" "+r")
2556                          (match_operand:SI 2 "int5_operand" "L"))))
2557    (set (match_dup 1)
2558         (plus:SI (match_dup 1) (match_dup 2)))]
2559   ""
2560   "{ldhs|ldh},mb %2(%1),%0"
2561   [(set_attr "type" "load")
2562    (set_attr "length" "4")])
2563
2564 ; And a zero extended variant.
2565 (define_insn ""
2566   [(set (match_operand:SI 0 "register_operand" "=r")
2567         (zero_extend:SI (mem:HI
2568                           (plus:SI
2569                             (match_operand:SI 1 "register_operand" "+r")
2570                             (match_operand:SI 2 "int5_operand" "L")))))
2571    (set (match_dup 1)
2572         (plus:SI (match_dup 1) (match_dup 2)))]
2573   ""
2574   "{ldhs|ldh},mb %2(%1),%0"
2575   [(set_attr "type" "load")
2576    (set_attr "length" "4")])
2577
2578 (define_insn ""
2579   [(set (mem:HI (plus:SI (match_operand:SI 0 "register_operand" "+r")
2580                          (match_operand:SI 1 "int5_operand" "L")))
2581         (match_operand:HI 2 "reg_or_0_operand" "rM"))
2582    (set (match_dup 0)
2583         (plus:SI (match_dup 0) (match_dup 1)))]
2584   ""
2585   "{sths|sth},mb %r2,%1(%0)"
2586   [(set_attr "type" "store")
2587    (set_attr "length" "4")])
2588
2589 (define_insn ""
2590   [(set (match_operand:HI 0 "register_operand" "=r")
2591         (high:HI (match_operand 1 "const_int_operand" "")))]
2592   ""
2593   "ldil L'%G1,%0"
2594   [(set_attr "type" "move")
2595    (set_attr "length" "4")])
2596
2597 (define_insn ""
2598   [(set (match_operand:HI 0 "register_operand" "=r")
2599         (lo_sum:HI (match_operand:HI 1 "register_operand" "r")
2600                    (match_operand 2 "const_int_operand" "")))]
2601   ""
2602   "ldo R'%G2(%1),%0"
2603   [(set_attr "type" "move")
2604    (set_attr "length" "4")])
2605
2606 (define_expand "movqi"
2607   [(set (match_operand:QI 0 "general_operand" "")
2608         (match_operand:QI 1 "general_operand" ""))]
2609   ""
2610   "
2611 {
2612   if (emit_move_sequence (operands, QImode, 0))
2613     DONE;
2614 }")
2615
2616 (define_insn ""
2617   [(set (match_operand:QI 0 "reg_or_nonsymb_mem_operand" "=r,r,r,r,r,Q,*q,!*f")
2618         (match_operand:QI 1 "move_operand" "r,J,N,K,RQ,rM,rM,!*fM"))]
2619   "register_operand (operands[0], QImode)
2620    || reg_or_0_operand (operands[1], QImode)"
2621   "@
2622    copy %1,%0
2623    ldi %1,%0
2624    ldil L'%1,%0
2625    {zdepi|depwi,z} %Z1,%0
2626    ldb%M1 %1,%0
2627    stb%M0 %r1,%0
2628    mtsar %r1
2629    fcpy,sgl %f1,%0"
2630   [(set_attr "type" "move,move,move,shift,load,store,move,fpalu")
2631    (set_attr "pa_combine_type" "addmove")
2632    (set_attr "length" "4,4,4,4,4,4,4,4")])
2633
2634 (define_insn ""
2635   [(set (match_operand:QI 0 "register_operand" "=r")
2636         (mem:QI (plus:SI (match_operand:SI 1 "basereg_operand" "r")
2637                          (match_operand:SI 2 "register_operand" "r"))))]
2638   "! TARGET_DISABLE_INDEXING"
2639   "*
2640 {
2641   /* Reload can create backwards (relative to cse) unscaled index
2642      address modes when eliminating registers and possibly for
2643      pseudos that don't get hard registers.  Deal with it.  */
2644   if (operands[2] == hard_frame_pointer_rtx
2645       || operands[2] == stack_pointer_rtx)
2646     return \"{ldbx|ldb} %1(%2),%0\";
2647   else
2648     return \"{ldbx|ldb} %2(%1),%0\";
2649 }"
2650   [(set_attr "type" "load")
2651    (set_attr "length" "4")])
2652
2653 (define_insn ""
2654   [(set (match_operand:QI 0 "register_operand" "=r")
2655         (mem:QI (plus:SI (match_operand:SI 1 "register_operand" "r")
2656                          (match_operand:SI 2 "basereg_operand" "r"))))]
2657   "! TARGET_DISABLE_INDEXING"
2658   "*
2659 {
2660   /* Reload can create backwards (relative to cse) unscaled index
2661      address modes when eliminating registers and possibly for
2662      pseudos that don't get hard registers.  Deal with it.  */
2663   if (operands[1] == hard_frame_pointer_rtx
2664       || operands[1] == stack_pointer_rtx)
2665     return \"{ldbx|ldb} %2(%1),%0\";
2666   else
2667     return \"{ldbx|ldb} %1(%2),%0\";
2668 }"
2669   [(set_attr "type" "load")
2670    (set_attr "length" "4")])
2671
2672 ; Indexed byte load with zero extension to SImode or HImode.
2673 (define_insn ""
2674   [(set (match_operand:SI 0 "register_operand" "=r")
2675         (zero_extend:SI (mem:QI
2676                           (plus:SI
2677                             (match_operand:SI 1 "basereg_operand" "r")
2678                             (match_operand:SI 2 "register_operand" "r")))))]
2679   "! TARGET_DISABLE_INDEXING"
2680   "*
2681 {
2682   /* Reload can create backwards (relative to cse) unscaled index
2683      address modes when eliminating registers and possibly for
2684      pseudos that don't get hard registers.  Deal with it.  */
2685   if (operands[2] == hard_frame_pointer_rtx
2686       || operands[2] == stack_pointer_rtx)
2687     return \"{ldbx|ldb} %1(%2),%0\";
2688   else
2689     return \"{ldbx|ldb} %2(%1),%0\";
2690 }"
2691   [(set_attr "type" "load")
2692    (set_attr "length" "4")])
2693
2694 (define_insn ""
2695   [(set (match_operand:SI 0 "register_operand" "=r")
2696         (zero_extend:SI (mem:QI
2697                           (plus:SI
2698                             (match_operand:SI 1 "register_operand" "r")
2699                             (match_operand:SI 2 "basereg_operand" "r")))))]
2700   "! TARGET_DISABLE_INDEXING"
2701   "*
2702 {
2703   /* Reload can create backwards (relative to cse) unscaled index
2704      address modes when eliminating registers and possibly for
2705      pseudos that don't get hard registers.  Deal with it.  */
2706   if (operands[1] == hard_frame_pointer_rtx
2707       || operands[1] == stack_pointer_rtx)
2708     return \"{ldbx|ldb} %2(%1),%0\";
2709   else
2710     return \"{ldbx|ldb} %1(%2),%0\";
2711 }"
2712   [(set_attr "type" "load")
2713    (set_attr "length" "4")])
2714
2715 (define_insn ""
2716   [(set (match_operand:HI 0 "register_operand" "=r")
2717         (zero_extend:HI (mem:QI
2718                           (plus:SI
2719                             (match_operand:SI 1 "basereg_operand" "r")
2720                             (match_operand:SI 2 "register_operand" "r")))))]
2721   "! TARGET_DISABLE_INDEXING"
2722   "*
2723 {
2724   /* Reload can create backwards (relative to cse) unscaled index
2725      address modes when eliminating registers and possibly for
2726      pseudos that don't get hard registers.  Deal with it.  */
2727   if (operands[2] == hard_frame_pointer_rtx
2728       || operands[2] == stack_pointer_rtx)
2729     return \"{ldbx|ldb} %1(%2),%0\";
2730   else
2731     return \"{ldbx|ldb} %2(%1),%0\";
2732 }"
2733   [(set_attr "type" "load")
2734    (set_attr "length" "4")])
2735
2736 (define_insn ""
2737   [(set (match_operand:HI 0 "register_operand" "=r")
2738         (zero_extend:HI (mem:QI
2739                           (plus:SI
2740                             (match_operand:SI 1 "register_operand" "r")
2741                             (match_operand:SI 2 "basereg_operand" "r")))))]
2742   "! TARGET_DISABLE_INDEXING"
2743   "*
2744 {
2745   /* Reload can create backwards (relative to cse) unscaled index
2746      address modes when eliminating registers and possibly for
2747      pseudos that don't get hard registers.  Deal with it.  */
2748   if (operands[1] == hard_frame_pointer_rtx
2749       || operands[1] == stack_pointer_rtx)
2750     return \"{ldbx|ldb} %2(%1),%0\";
2751   else
2752     return \"{ldbx|ldb} %1(%2),%0\";
2753 }"
2754   [(set_attr "type" "load")
2755    (set_attr "length" "4")])
2756
2757 (define_insn ""
2758   [(set (match_operand:QI 0 "register_operand" "=r")
2759         (mem:QI (plus:SI (match_operand:SI 1 "register_operand" "+r")
2760                          (match_operand:SI 2 "int5_operand" "L"))))
2761    (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
2762   ""
2763   "{ldbs|ldb},mb %2(%1),%0"
2764   [(set_attr "type" "load")
2765    (set_attr "length" "4")])
2766
2767 ; Now the same thing with zero extensions.
2768 (define_insn ""
2769   [(set (match_operand:SI 0 "register_operand" "=r")
2770         (zero_extend:SI (mem:QI (plus:SI
2771                                   (match_operand:SI 1 "register_operand" "+r")
2772                                   (match_operand:SI 2 "int5_operand" "L")))))
2773    (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
2774   ""
2775   "{ldbs|ldb},mb %2(%1),%0"
2776   [(set_attr "type" "load")
2777    (set_attr "length" "4")])
2778
2779 (define_insn ""
2780   [(set (match_operand:HI 0 "register_operand" "=r")
2781         (zero_extend:HI (mem:QI (plus:SI
2782                                   (match_operand:SI 1 "register_operand" "+r")
2783                                   (match_operand:SI 2 "int5_operand" "L")))))
2784    (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
2785   ""
2786   "{ldbs|ldb},mb %2(%1),%0"
2787   [(set_attr "type" "load")
2788    (set_attr "length" "4")])
2789
2790 (define_insn ""
2791   [(set (mem:QI (plus:SI (match_operand:SI 0 "register_operand" "+r")
2792                          (match_operand:SI 1 "int5_operand" "L")))
2793         (match_operand:QI 2 "reg_or_0_operand" "rM"))
2794    (set (match_dup 0)
2795         (plus:SI (match_dup 0) (match_dup 1)))]
2796   ""
2797   "{stbs|stb},mb %r2,%1(%0)"
2798   [(set_attr "type" "store")
2799    (set_attr "length" "4")])
2800
2801 ;; The definition of this insn does not really explain what it does,
2802 ;; but it should suffice
2803 ;; that anything generated as this insn will be recognized as one
2804 ;; and that it will not successfully combine with anything.
2805 (define_expand "movstrsi"
2806   [(parallel [(set (match_operand:BLK 0 "" "")
2807                    (match_operand:BLK 1 "" ""))
2808               (clobber (match_dup 7))
2809               (clobber (match_dup 8))
2810               (clobber (match_dup 4))
2811               (clobber (match_dup 5))
2812               (clobber (match_dup 6))
2813               (use (match_operand:SI 2 "arith_operand" ""))
2814               (use (match_operand:SI 3 "const_int_operand" ""))])]
2815   "!TARGET_64BIT"
2816   "
2817 {
2818   int size, align;
2819
2820   /* HP provides very fast block move library routine for the PA;
2821      this routine includes:
2822
2823         4x4 byte at a time block moves,
2824         1x4 byte at a time with alignment checked at runtime with
2825             attempts to align the source and destination as needed
2826         1x1 byte loop
2827
2828      With that in mind, here's the heuristics to try and guess when
2829      the inlined block move will be better than the library block
2830      move:
2831
2832         If the size isn't constant, then always use the library routines.
2833
2834         If the size is large in respect to the known alignment, then use
2835         the library routines.
2836
2837         If the size is small in repsect to the known alignment, then open
2838         code the copy (since that will lead to better scheduling).
2839
2840         Else use the block move pattern.   */
2841
2842   /* Undetermined size, use the library routine.  */
2843   if (GET_CODE (operands[2]) != CONST_INT)
2844     FAIL;
2845
2846   size = INTVAL (operands[2]);
2847   align = INTVAL (operands[3]);
2848   align = align > 4 ? 4 : align;
2849
2850   /* If size/alignment > 8 (eg size is large in respect to alignment),
2851      then use the library routines.  */
2852   if (size / align > 16)
2853     FAIL;
2854
2855   /* This does happen, but not often enough to worry much about.  */
2856   if (size / align < MOVE_RATIO)
2857     FAIL;
2858   
2859   /* Fall through means we're going to use our block move pattern.  */
2860   operands[0]
2861     = change_address (operands[0], VOIDmode,
2862                       copy_to_mode_reg (SImode, XEXP (operands[0], 0)));
2863   operands[1]
2864     = change_address (operands[1], VOIDmode,
2865                       copy_to_mode_reg (SImode, XEXP (operands[1], 0)));
2866   operands[4] = gen_reg_rtx (SImode);
2867   operands[5] = gen_reg_rtx (SImode);
2868   operands[6] = gen_reg_rtx (SImode);
2869   operands[7] = XEXP (operands[0], 0);
2870   operands[8] = XEXP (operands[1], 0);
2871 }")
2872
2873 ;; The operand constraints are written like this to support both compile-time
2874 ;; and run-time determined byte count.  If the count is run-time determined,
2875 ;; the register with the byte count is clobbered by the copying code, and
2876 ;; therefore it is forced to operand 2.  If the count is compile-time
2877 ;; determined, we need two scratch registers for the unrolled code.
2878 (define_insn "movstrsi_internal"
2879   [(set (mem:BLK (match_operand:SI 0 "register_operand" "+r,r"))
2880         (mem:BLK (match_operand:SI 1 "register_operand" "+r,r")))
2881    (clobber (match_dup 0))
2882    (clobber (match_dup 1))
2883    (clobber (match_operand:SI 2 "register_operand" "=r,r"))     ;loop cnt/tmp
2884    (clobber (match_operand:SI 3 "register_operand" "=&r,&r"))   ;item tmp
2885    (clobber (match_operand:SI 6 "register_operand" "=&r,&r"))   ;item tmp2
2886    (use (match_operand:SI 4 "arith_operand" "J,2"))      ;byte count
2887    (use (match_operand:SI 5 "const_int_operand" "n,n"))] ;alignment
2888   "!TARGET_64BIT"
2889   "* return output_block_move (operands, !which_alternative);"
2890   [(set_attr "type" "multi,multi")])
2891 \f
2892 ;; Floating point move insns
2893
2894 ;; This pattern forces (set (reg:DF ...) (const_double ...))
2895 ;; to be reloaded by putting the constant into memory when
2896 ;; reg is a floating point register.
2897 ;;
2898 ;; For integer registers we use ldil;ldo to set the appropriate
2899 ;; value.
2900 ;;
2901 ;; This must come before the movdf pattern, and it must be present
2902 ;; to handle obscure reloading cases.
2903 (define_insn ""
2904   [(set (match_operand:DF 0 "register_operand" "=?r,f")
2905         (match_operand:DF 1 "" "?F,m"))]
2906   "GET_CODE (operands[1]) == CONST_DOUBLE
2907    && operands[1] != CONST0_RTX (DFmode)
2908    && !TARGET_64BIT
2909    && ! TARGET_SOFT_FLOAT"
2910   "* return (which_alternative == 0 ? output_move_double (operands)
2911                                     : \"fldd%F1 %1,%0\");"
2912   [(set_attr "type" "move,fpload")
2913    (set_attr "length" "16,4")])
2914
2915 (define_expand "movdf"
2916   [(set (match_operand:DF 0 "general_operand" "")
2917         (match_operand:DF 1 "general_operand" ""))]
2918   ""
2919   "
2920 {
2921   if (GET_CODE (operands[1]) == CONST_DOUBLE && TARGET_64BIT)
2922       operands[1] = force_const_mem (DFmode, operands[1]);
2923
2924   if (emit_move_sequence (operands, DFmode, 0))
2925     DONE;
2926 }")
2927
2928 ;; Reloading an SImode or DImode value requires a scratch register if
2929 ;; going in to or out of float point registers.
2930
2931 (define_expand "reload_indf"
2932   [(set (match_operand:DF 0 "register_operand" "=Z")
2933         (match_operand:DF 1 "non_hard_reg_operand" ""))
2934    (clobber (match_operand:DF 2 "register_operand" "=&r"))]
2935   ""
2936   "
2937 {
2938   if (emit_move_sequence (operands, DFmode, operands[2]))
2939     DONE;
2940
2941   /* We don't want the clobber emitted, so handle this ourselves.  */
2942   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
2943   DONE;
2944 }")
2945
2946 (define_expand "reload_outdf" 
2947  [(set (match_operand:DF 0 "non_hard_reg_operand" "")
2948         (match_operand:DF 1  "register_operand" "Z"))
2949    (clobber (match_operand:DF 2 "register_operand" "=&r"))]
2950   ""
2951   "
2952 {
2953   if (emit_move_sequence (operands, DFmode, operands[2]))
2954     DONE;
2955
2956   /* We don't want the clobber emitted, so handle this ourselves.  */
2957   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
2958   DONE;
2959 }")
2960
2961 (define_insn ""
2962   [(set (match_operand:DF 0 "reg_or_nonsymb_mem_operand"
2963                           "=f,*r,RQ,?o,?Q,f,*r,*r")
2964         (match_operand:DF 1 "reg_or_0_or_nonsymb_mem_operand"
2965                           "fG,*rG,f,*r,*r,RQ,o,RQ"))]
2966   "(register_operand (operands[0], DFmode)
2967     || reg_or_0_operand (operands[1], DFmode))
2968    && ! (GET_CODE (operands[1]) == CONST_DOUBLE
2969          && GET_CODE (operands[0]) == MEM)
2970    && ! TARGET_64BIT
2971    && ! TARGET_SOFT_FLOAT"
2972   "*
2973 {
2974   if (FP_REG_P (operands[0]) || FP_REG_P (operands[1])
2975       || operands[1] == CONST0_RTX (DFmode))
2976     return output_fp_move_double (operands);
2977   return output_move_double (operands);
2978 }"
2979   [(set_attr "type" "fpalu,move,fpstore,store,store,fpload,load,load")
2980    (set_attr "length" "4,8,4,8,16,4,8,16")])
2981
2982 (define_insn ""
2983   [(set (match_operand:DF 0 "reg_or_nonsymb_mem_operand"
2984                           "=r,?o,?Q,r,r")
2985         (match_operand:DF 1 "reg_or_0_or_nonsymb_mem_operand"
2986                           "rG,r,r,o,Q"))]
2987   "(register_operand (operands[0], DFmode)
2988     || reg_or_0_operand (operands[1], DFmode))
2989    && ! TARGET_64BIT
2990    && TARGET_SOFT_FLOAT"
2991   "*
2992 {
2993   return output_move_double (operands);
2994 }"
2995   [(set_attr "type" "move,store,store,load,load")
2996    (set_attr "length" "8,8,16,8,16")])
2997
2998 (define_insn ""
2999   [(set (match_operand:DF 0 "reg_or_nonsymb_mem_operand"
3000                                 "=r,r,r,r,r,Q,*q,!f,f,*TR")
3001         (match_operand:DF 1 "move_operand"
3002                                 "r,J,N,K,RQ,rM,rM,!fM,*RT,f"))]
3003   "(register_operand (operands[0], DFmode)
3004     || reg_or_0_operand (operands[1], DFmode))
3005    && ! TARGET_SOFT_FLOAT && TARGET_64BIT"
3006   "@
3007    copy %1,%0
3008    ldi %1,%0
3009    ldil L'%1,%0
3010    depdi,z %z1,%0
3011    ldd%M1 %1,%0
3012    std%M0 %r1,%0
3013    mtsar %r1
3014    fcpy,dbl %f1,%0
3015    fldd%F1 %1,%0
3016    fstd%F0 %1,%0"
3017   [(set_attr "type" "move,move,move,shift,load,store,move,fpalu,fpload,fpstore")
3018    (set_attr "pa_combine_type" "addmove")
3019    (set_attr "length" "4,4,4,4,4,4,4,4,4,4")])
3020
3021 (define_insn ""
3022   [(set (match_operand:DF 0 "register_operand" "=fx")
3023         (mem:DF (plus:SI (match_operand:SI 1 "basereg_operand" "r")
3024                          (match_operand:SI 2 "register_operand" "r"))))]
3025   "! TARGET_DISABLE_INDEXING && ! TARGET_SOFT_FLOAT"
3026   "*
3027 {
3028   /* Reload can create backwards (relative to cse) unscaled index
3029      address modes when eliminating registers and possibly for
3030      pseudos that don't get hard registers.  Deal with it.  */
3031   if (operands[2] == hard_frame_pointer_rtx
3032       || operands[2] == stack_pointer_rtx)
3033     return \"{flddx|fldd} %1(%2),%0\";
3034   else
3035     return \"{flddx|fldd} %2(%1),%0\";
3036 }"
3037   [(set_attr "type" "fpload")
3038    (set_attr "length" "4")])
3039
3040 (define_insn ""
3041   [(set (match_operand:DF 0 "register_operand" "=fx")
3042         (mem:DF (plus:SI (match_operand:SI 1 "register_operand" "r")
3043                          (match_operand:SI 2 "basereg_operand" "r"))))]
3044   "! TARGET_DISABLE_INDEXING && ! TARGET_SOFT_FLOAT"
3045   "*
3046 {
3047   /* Reload can create backwards (relative to cse) unscaled index
3048      address modes when eliminating registers and possibly for
3049      pseudos that don't get hard registers.  Deal with it.  */
3050   if (operands[1] == hard_frame_pointer_rtx
3051       || operands[1] == stack_pointer_rtx)
3052     return \"{flddx|fldd} %2(%1),%0\";
3053   else
3054     return \"{flddx|fldd} %1(%2),%0\";
3055 }"
3056   [(set_attr "type" "fpload")
3057    (set_attr "length" "4")])
3058
3059 (define_insn ""
3060   [(set (mem:DF (plus:SI (match_operand:SI 1 "basereg_operand" "r")
3061                          (match_operand:SI 2 "register_operand" "r")))
3062         (match_operand:DF 0 "register_operand" "fx"))]
3063   "! TARGET_DISABLE_INDEXING && ! TARGET_SOFT_FLOAT"
3064   "*
3065 {
3066   /* Reload can create backwards (relative to cse) unscaled index
3067      address modes when eliminating registers and possibly for
3068      pseudos that don't get hard registers.  Deal with it.  */
3069   if (operands[2] == hard_frame_pointer_rtx
3070       || operands[2] == stack_pointer_rtx)
3071     return \"{fstdx|fstd} %0,%1(%2)\";
3072   else
3073     return \"{fstdx|fstd} %0,%2(%1)\";
3074 }"
3075   [(set_attr "type" "fpstore")
3076    (set_attr "length" "4")])
3077
3078 (define_insn ""
3079   [(set (mem:DF (plus:SI (match_operand:SI 1 "register_operand" "r")
3080                          (match_operand:SI 2 "basereg_operand" "r")))
3081         (match_operand:DF 0 "register_operand" "fx"))]
3082   "! TARGET_DISABLE_INDEXING && ! TARGET_SOFT_FLOAT"
3083   "*
3084 {
3085   /* Reload can create backwards (relative to cse) unscaled index
3086      address modes when eliminating registers and possibly for
3087      pseudos that don't get hard registers.  Deal with it.  */
3088   if (operands[1] == hard_frame_pointer_rtx
3089       || operands[1] == stack_pointer_rtx)
3090     return \"{fstdx|fstd} %0,%2(%1)\";
3091   else
3092     return \"{fstdx|fstd} %0,%1(%2)\";
3093 }"
3094   [(set_attr "type" "fpstore")
3095    (set_attr "length" "4")])
3096
3097 (define_expand "movdi"
3098   [(set (match_operand:DI 0 "reg_or_nonsymb_mem_operand" "")
3099         (match_operand:DI 1 "general_operand" ""))]
3100   ""
3101   "
3102 {
3103   if (GET_CODE (operands[1]) == CONST_DOUBLE && TARGET_64BIT)
3104       operands[1] = force_const_mem (DImode, operands[1]);
3105
3106   if (emit_move_sequence (operands, DImode, 0))
3107     DONE;
3108 }")
3109
3110 (define_expand "reload_indi"
3111   [(set (match_operand:DI 0 "register_operand" "=Z")
3112         (match_operand:DI 1 "non_hard_reg_operand" ""))
3113    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
3114   ""
3115   "
3116 {
3117   if (emit_move_sequence (operands, DImode, operands[2]))
3118     DONE;
3119
3120   /* We don't want the clobber emitted, so handle this ourselves.  */
3121   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
3122   DONE;
3123 }")
3124
3125 (define_expand "reload_outdi"
3126   [(set (match_operand:DI 0 "general_operand" "")
3127         (match_operand:DI 1 "register_operand" "Z"))
3128    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
3129   ""
3130   "
3131 {
3132   if (emit_move_sequence (operands, DImode, operands[2]))
3133     DONE;
3134
3135   /* We don't want the clobber emitted, so handle this ourselves.  */
3136   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
3137   DONE;
3138 }")
3139
3140 (define_insn ""
3141   [(set (match_operand:DI 0 "register_operand" "=r")
3142         (high:DI (match_operand 1 "" "")))]
3143   "!TARGET_64BIT"
3144   "*
3145 {
3146   rtx op0 = operands[0];
3147   rtx op1 = operands[1];
3148
3149   if (GET_CODE (op1) == CONST_INT)
3150     {
3151       operands[0] = operand_subword (op0, 1, 0, DImode);
3152       output_asm_insn (\"ldil L'%1,%0\", operands);
3153
3154       operands[0] = operand_subword (op0, 0, 0, DImode);
3155       if (INTVAL (op1) < 0)
3156         output_asm_insn (\"ldi -1,%0\", operands);
3157       else
3158         output_asm_insn (\"ldi 0,%0\", operands);
3159       return \"\";
3160     }
3161   else if (GET_CODE (op1) == CONST_DOUBLE)
3162     {
3163       operands[0] = operand_subword (op0, 1, 0, DImode);
3164       operands[1] = GEN_INT (CONST_DOUBLE_LOW (op1));
3165       output_asm_insn (\"ldil L'%1,%0\", operands);
3166
3167       operands[0] = operand_subword (op0, 0, 0, DImode);
3168       operands[1] = GEN_INT (CONST_DOUBLE_HIGH (op1));
3169       output_asm_insn (singlemove_string (operands), operands);
3170       return \"\";
3171     }
3172   else
3173     abort ();
3174 }"
3175   [(set_attr "type" "move")
3176    (set_attr "length" "8")])
3177
3178 (define_insn ""
3179   [(set (match_operand:DI 0 "reg_or_nonsymb_mem_operand"
3180                           "=r,o,Q,r,r,r,f,f,*TR")
3181         (match_operand:DI 1 "general_operand"
3182                           "rM,r,r,o*R,Q,i,fM,*TR,f"))]
3183   "(register_operand (operands[0], DImode)
3184     || reg_or_0_operand (operands[1], DImode))
3185    && ! TARGET_64BIT
3186    && ! TARGET_SOFT_FLOAT"
3187   "*
3188 {
3189   if (FP_REG_P (operands[0]) || FP_REG_P (operands[1])
3190       || (operands[1] == CONST0_RTX (DImode)))
3191     return output_fp_move_double (operands);
3192   return output_move_double (operands);
3193 }"
3194   [(set_attr "type" "move,store,store,load,load,multi,fpalu,fpload,fpstore")
3195    (set_attr "length" "8,8,16,8,16,16,4,4,4")])
3196
3197 (define_insn ""
3198   [(set (match_operand:DI 0 "reg_or_nonsymb_mem_operand"
3199                                 "=r,r,r,r,r,Q,*q,!f,f,*TR")
3200         (match_operand:DI 1 "move_operand"
3201                                 "r,J,N,K,RQ,rM,rM,!fM,*RT,f"))]
3202   "(register_operand (operands[0], DImode)
3203     || reg_or_0_operand (operands[1], DImode))
3204    && ! TARGET_SOFT_FLOAT && TARGET_64BIT"
3205   "@
3206    copy %1,%0
3207    ldi %1,%0
3208    ldil L'%1,%0
3209    depdi,z %z1,%0
3210    ldd%M1 %1,%0
3211    std%M0 %r1,%0
3212    mtsar %r1
3213    fcpy,dbl %f1,%0
3214    fldd%F1 %1,%0
3215    fstd%F0 %1,%0"
3216   [(set_attr "type" "move,move,move,shift,load,store,move,fpalu,fpload,fpstore")
3217    (set_attr "pa_combine_type" "addmove")
3218    (set_attr "length" "4,4,4,4,4,4,4,4,4,4")])
3219
3220 (define_insn ""
3221   [(set (match_operand:DI 0 "reg_or_nonsymb_mem_operand"
3222                           "=r,o,Q,r,r,r")
3223         (match_operand:DI 1 "general_operand"
3224                           "rM,r,r,o,Q,i"))]
3225   "(register_operand (operands[0], DImode)
3226     || reg_or_0_operand (operands[1], DImode))
3227    && ! TARGET_64BIT
3228    && TARGET_SOFT_FLOAT"
3229   "*
3230 {
3231   return output_move_double (operands);
3232 }"
3233   [(set_attr "type" "move,store,store,load,load,multi")
3234    (set_attr "length" "8,8,16,8,16,16")])
3235
3236 (define_insn ""
3237   [(set (match_operand:DI 0 "register_operand" "=r,&r")
3238         (lo_sum:DI (match_operand:DI 1 "register_operand" "0,r")
3239                    (match_operand:DI 2 "immediate_operand" "i,i")))]
3240   "!TARGET_64BIT"
3241   "*
3242 {
3243   /* Don't output a 64 bit constant, since we can't trust the assembler to
3244      handle it correctly.  */
3245   if (GET_CODE (operands[2]) == CONST_DOUBLE)
3246     operands[2] = GEN_INT (CONST_DOUBLE_LOW (operands[2]));
3247   if (which_alternative == 1)
3248     output_asm_insn (\"copy %1,%0\", operands);
3249   return \"ldo R'%G2(%R1),%R0\";
3250 }"
3251   [(set_attr "type" "move,move")
3252    (set_attr "length" "4,8")])
3253
3254 ;; This pattern forces (set (reg:SF ...) (const_double ...))
3255 ;; to be reloaded by putting the constant into memory when
3256 ;; reg is a floating point register.
3257 ;;
3258 ;; For integer registers we use ldil;ldo to set the appropriate
3259 ;; value.
3260 ;;
3261 ;; This must come before the movsf pattern, and it must be present
3262 ;; to handle obscure reloading cases.
3263 (define_insn ""
3264   [(set (match_operand:SF 0 "register_operand" "=?r,f")
3265         (match_operand:SF 1 "" "?F,m"))]
3266   "GET_CODE (operands[1]) == CONST_DOUBLE
3267    && operands[1] != CONST0_RTX (SFmode)
3268    && ! TARGET_SOFT_FLOAT"
3269   "* return (which_alternative == 0 ? singlemove_string (operands)
3270                                     : \" fldw%F1 %1,%0\");"
3271   [(set_attr "type" "move,fpload")
3272    (set_attr "length" "8,4")])
3273
3274 (define_expand "movsf"
3275   [(set (match_operand:SF 0 "general_operand" "")
3276         (match_operand:SF 1 "general_operand" ""))]
3277   ""
3278   "
3279 {
3280   if (emit_move_sequence (operands, SFmode, 0))
3281     DONE;
3282 }")
3283
3284 ;; Reloading an SImode or DImode value requires a scratch register if
3285 ;; going in to or out of float point registers.
3286
3287 (define_expand "reload_insf"
3288   [(set (match_operand:SF 0 "register_operand" "=Z")
3289         (match_operand:SF 1 "non_hard_reg_operand" ""))
3290    (clobber (match_operand:SF 2 "register_operand" "=&r"))]
3291   ""
3292   "
3293 {
3294   if (emit_move_sequence (operands, SFmode, operands[2]))
3295     DONE;
3296
3297   /* We don't want the clobber emitted, so handle this ourselves.  */
3298   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
3299   DONE;
3300 }")
3301
3302 (define_expand "reload_outsf"
3303   [(set (match_operand:SF 0 "non_hard_reg_operand" "")
3304         (match_operand:SF 1  "register_operand" "Z"))
3305    (clobber (match_operand:SF 2 "register_operand" "=&r"))]
3306   ""
3307   "
3308 {
3309   if (emit_move_sequence (operands, SFmode, operands[2]))
3310     DONE;
3311
3312   /* We don't want the clobber emitted, so handle this ourselves.  */
3313   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
3314   DONE;
3315 }")
3316
3317 (define_insn ""
3318   [(set (match_operand:SF 0 "reg_or_nonsymb_mem_operand"
3319                           "=f,r,f,r,RQ,Q")
3320         (match_operand:SF 1 "reg_or_0_or_nonsymb_mem_operand"
3321                           "fG,rG,RQ,RQ,f,rG"))]
3322   "(register_operand (operands[0], SFmode)
3323     || reg_or_0_operand (operands[1], SFmode))
3324    && ! TARGET_SOFT_FLOAT"
3325   "@
3326    fcpy,sgl %f1,%0
3327    copy %r1,%0
3328    fldw%F1 %1,%0
3329    ldw%M1 %1,%0
3330    fstw%F0 %r1,%0
3331    stw%M0 %r1,%0"
3332   [(set_attr "type" "fpalu,move,fpload,load,fpstore,store")
3333    (set_attr "pa_combine_type" "addmove")
3334    (set_attr "length" "4,4,4,4,4,4")])
3335
3336 (define_insn ""
3337   [(set (match_operand:SF 0 "reg_or_nonsymb_mem_operand"
3338                           "=r,r,Q")
3339         (match_operand:SF 1 "reg_or_0_or_nonsymb_mem_operand"
3340                           "rG,RQ,rG"))]
3341   "(register_operand (operands[0], SFmode)
3342     || reg_or_0_operand (operands[1], SFmode))
3343    && TARGET_SOFT_FLOAT"
3344   "@
3345    copy %r1,%0
3346    ldw%M1 %1,%0
3347    stw%M0 %r1,%0"
3348   [(set_attr "type" "move,load,store")
3349    (set_attr "pa_combine_type" "addmove")
3350    (set_attr "length" "4,4,4")])
3351
3352 (define_insn ""
3353   [(set (match_operand:SF 0 "register_operand" "=fx")
3354         (mem:SF (plus:SI (match_operand:SI 1 "basereg_operand" "r")
3355                          (match_operand:SI 2 "register_operand" "r"))))]
3356   "! TARGET_DISABLE_INDEXING && ! TARGET_SOFT_FLOAT"
3357   "*
3358 {
3359   /* Reload can create backwards (relative to cse) unscaled index
3360      address modes when eliminating registers and possibly for
3361      pseudos that don't get hard registers.  Deal with it.  */
3362   if (operands[2] == hard_frame_pointer_rtx
3363       || operands[2] == stack_pointer_rtx)
3364     return \"{fldwx|fldw} %1(%2),%0\";
3365   else
3366     return \"{fldwx|fldw} %2(%1),%0\";
3367 }"
3368   [(set_attr "type" "fpload")
3369    (set_attr "length" "4")])
3370
3371 (define_insn ""
3372   [(set (match_operand:SF 0 "register_operand" "=fx")
3373         (mem:SF (plus:SI (match_operand:SI 1 "register_operand" "r")
3374                          (match_operand:SI 2 "basereg_operand" "r"))))]
3375   "! TARGET_DISABLE_INDEXING && ! TARGET_SOFT_FLOAT"
3376   "*
3377 {
3378   /* Reload can create backwards (relative to cse) unscaled index
3379      address modes when eliminating registers and possibly for
3380      pseudos that don't get hard registers.  Deal with it.  */
3381   if (operands[1] == hard_frame_pointer_rtx
3382       || operands[1] == stack_pointer_rtx)
3383     return \"{fldwx|fldw} %2(%1),%0\";
3384   else
3385     return \"{fldwx|fldw} %1(%2),%0\";
3386 }"
3387   [(set_attr "type" "fpload")
3388    (set_attr "length" "4")])
3389
3390 (define_insn ""
3391   [(set (mem:SF (plus:SI (match_operand:SI 1 "basereg_operand" "r")
3392                          (match_operand:SI 2 "register_operand" "r")))
3393       (match_operand:SF 0 "register_operand" "fx"))]
3394   "! TARGET_DISABLE_INDEXING && ! TARGET_SOFT_FLOAT"
3395   "*
3396 {
3397   /* Reload can create backwards (relative to cse) unscaled index
3398      address modes when eliminating registers and possibly for
3399      pseudos that don't get hard registers.  Deal with it.  */
3400   if (operands[2] == hard_frame_pointer_rtx
3401       || operands[2] == stack_pointer_rtx)
3402     return \"{fstwx|fstw} %0,%1(%2)\";
3403   else
3404     return \"{fstwx|fstw} %0,%2(%1)\";
3405 }"
3406   [(set_attr "type" "fpstore")
3407    (set_attr "length" "4")])
3408 \f
3409 (define_insn ""
3410   [(set (mem:SF (plus:SI (match_operand:SI 1 "register_operand" "r")
3411                          (match_operand:SI 2 "basereg_operand" "r")))
3412       (match_operand:SF 0 "register_operand" "fx"))]
3413   "! TARGET_DISABLE_INDEXING && ! TARGET_SOFT_FLOAT"
3414   "*
3415 {
3416   /* Reload can create backwards (relative to cse) unscaled index
3417      address modes when eliminating registers and possibly for
3418      pseudos that don't get hard registers.  Deal with it.  */
3419   if (operands[1] == hard_frame_pointer_rtx
3420       || operands[1] == stack_pointer_rtx)
3421     return \"{fstwx|fstw} %0,%2(%1)\";
3422   else
3423     return \"{fstwx|fstw} %0,%1(%2)\";
3424 }"
3425   [(set_attr "type" "fpstore")
3426    (set_attr "length" "4")])
3427 \f
3428
3429 ;;- zero extension instructions
3430 ;; We have define_expand for zero extension patterns to make sure the
3431 ;; operands get loaded into registers.  The define_insns accept
3432 ;; memory operands.  This gives us better overall code than just
3433 ;; having a pattern that does or does not accept memory operands.
3434
3435 (define_expand "zero_extendhisi2"
3436   [(set (match_operand:SI 0 "register_operand" "")
3437         (zero_extend:SI
3438          (match_operand:HI 1 "register_operand" "")))]
3439   ""
3440   "")
3441
3442 (define_insn ""
3443   [(set (match_operand:SI 0 "register_operand" "=r,r")
3444         (zero_extend:SI
3445          (match_operand:HI 1 "move_operand" "r,RQ")))]
3446   "GET_CODE (operands[1]) != CONST_INT"
3447   "@
3448    {extru|extrw,u} %1,31,16,%0
3449    ldh%M1 %1,%0"
3450   [(set_attr "type" "shift,load")
3451    (set_attr "length" "4,4")])
3452
3453 (define_expand "zero_extendqihi2"
3454   [(set (match_operand:HI 0 "register_operand" "")
3455         (zero_extend:HI
3456          (match_operand:QI 1 "register_operand" "")))]
3457   ""
3458   "")
3459
3460 (define_insn ""
3461   [(set (match_operand:HI 0 "register_operand" "=r,r")
3462         (zero_extend:HI
3463          (match_operand:QI 1 "move_operand" "r,RQ")))]
3464   "GET_CODE (operands[1]) != CONST_INT"
3465   "@
3466    {extru|extrw,u} %1,31,8,%0
3467    ldb%M1 %1,%0"
3468   [(set_attr "type" "shift,load")
3469    (set_attr "length" "4,4")])
3470
3471 (define_expand "zero_extendqisi2"
3472   [(set (match_operand:SI 0 "register_operand" "")
3473         (zero_extend:SI
3474          (match_operand:QI 1 "register_operand" "")))]
3475   ""
3476   "")
3477
3478 (define_insn ""
3479   [(set (match_operand:SI 0 "register_operand" "=r,r")
3480         (zero_extend:SI
3481          (match_operand:QI 1 "move_operand" "r,RQ")))]
3482   "GET_CODE (operands[1]) != CONST_INT"
3483   "@
3484    {extru|extrw,u} %1,31,8,%0
3485    ldb%M1 %1,%0"
3486   [(set_attr "type" "shift,load")
3487    (set_attr "length" "4,4")])
3488
3489 (define_insn "zero_extendqidi2"
3490   [(set (match_operand:DI 0 "register_operand" "=r")
3491         (zero_extend:DI (match_operand:QI 1 "register_operand" "r")))]
3492   "TARGET_64BIT"
3493   "extrd,u %1,63,8,%0"
3494   [(set_attr "type" "shift") 
3495   (set_attr "length" "4")])
3496
3497 (define_insn "zero_extendhidi2"
3498   [(set (match_operand:DI 0 "register_operand" "=r")
3499         (zero_extend:DI (match_operand:HI 1 "register_operand" "r")))]
3500   "TARGET_64BIT"
3501   "extrd,u %1,63,16,%0"
3502   [(set_attr "type" "shift") 
3503   (set_attr "length" "4")])
3504
3505 (define_insn "zero_extendsidi2"
3506   [(set (match_operand:DI 0 "register_operand" "=r")
3507         (zero_extend:DI (match_operand:SI 1 "register_operand" "r")))]
3508   "TARGET_64BIT"
3509   "extrd,u %1,63,32,%0"
3510   [(set_attr "type" "shift") 
3511   (set_attr "length" "4")])
3512
3513 ;;- sign extension instructions
3514
3515 (define_insn "extendhisi2"
3516   [(set (match_operand:SI 0 "register_operand" "=r")
3517         (sign_extend:SI (match_operand:HI 1 "register_operand" "r")))]
3518   ""
3519   "{extrs|extrw,s} %1,31,16,%0"
3520   [(set_attr "type" "shift")
3521    (set_attr "length" "4")])
3522
3523 (define_insn "extendqihi2"
3524   [(set (match_operand:HI 0 "register_operand" "=r")
3525         (sign_extend:HI (match_operand:QI 1 "register_operand" "r")))]
3526   ""
3527   "{extrs|extrw,s} %1,31,8,%0"
3528   [(set_attr "type" "shift") 
3529   (set_attr "length" "4")])
3530
3531 (define_insn "extendqisi2"
3532   [(set (match_operand:SI 0 "register_operand" "=r")
3533         (sign_extend:SI (match_operand:QI 1 "register_operand" "r")))]
3534   ""
3535   "{extrs|extrw,s} %1,31,8,%0"
3536   [(set_attr "type" "shift")
3537    (set_attr "length" "4")])
3538
3539 (define_insn "extendqidi2"
3540   [(set (match_operand:DI 0 "register_operand" "=r")
3541         (sign_extend:DI (match_operand:QI 1 "register_operand" "r")))]
3542   "TARGET_64BIT"
3543   "extrd,s %1,63,8,%0"
3544   [(set_attr "type" "shift") 
3545   (set_attr "length" "4")])
3546
3547 (define_insn "extendhidi2"
3548   [(set (match_operand:DI 0 "register_operand" "=r")
3549         (sign_extend:DI (match_operand:HI 1 "register_operand" "r")))]
3550   "TARGET_64BIT"
3551   "extrd,s %1,63,16,%0"
3552   [(set_attr "type" "shift") 
3553   (set_attr "length" "4")])
3554
3555 (define_insn "extendsidi2"
3556   [(set (match_operand:DI 0 "register_operand" "=r")
3557         (sign_extend:DI (match_operand:SI 1 "register_operand" "r")))]
3558   "TARGET_64BIT"
3559   "extrd,s %1,63,32,%0"
3560   [(set_attr "type" "shift") 
3561   (set_attr "length" "4")])
3562
3563 \f
3564 ;; Conversions between float and double.
3565
3566 (define_insn "extendsfdf2"
3567   [(set (match_operand:DF 0 "register_operand" "=f")
3568         (float_extend:DF
3569          (match_operand:SF 1 "register_operand" "f")))]
3570   "! TARGET_SOFT_FLOAT"
3571   "{fcnvff|fcnv},sgl,dbl %1,%0"
3572   [(set_attr "type" "fpalu")
3573    (set_attr "length" "4")])
3574
3575 (define_insn "truncdfsf2"
3576   [(set (match_operand:SF 0 "register_operand" "=f")
3577         (float_truncate:SF
3578          (match_operand:DF 1 "register_operand" "f")))]
3579   "! TARGET_SOFT_FLOAT"
3580   "{fcnvff|fcnv},dbl,sgl %1,%0"
3581   [(set_attr "type" "fpalu")
3582    (set_attr "length" "4")])
3583
3584 ;; Conversion between fixed point and floating point.
3585 ;; Note that among the fix-to-float insns
3586 ;; the ones that start with SImode come first.
3587 ;; That is so that an operand that is a CONST_INT
3588 ;; (and therefore lacks a specific machine mode).
3589 ;; will be recognized as SImode (which is always valid)
3590 ;; rather than as QImode or HImode.
3591
3592 ;; This pattern forces (set (reg:SF ...) (float:SF (const_int ...)))
3593 ;; to be reloaded by putting the constant into memory.
3594 ;; It must come before the more general floatsisf2 pattern.
3595 (define_insn ""
3596   [(set (match_operand:SF 0 "register_operand" "=f")
3597         (float:SF (match_operand:SI 1 "const_int_operand" "m")))]
3598   "! TARGET_SOFT_FLOAT"
3599   "fldw%F1 %1,%0\;{fcnvxf,sgl,sgl|fcnv,w,sgl} %0,%0"
3600   [(set_attr "type" "fpalu")
3601    (set_attr "length" "8")])
3602
3603 (define_insn "floatsisf2"
3604   [(set (match_operand:SF 0 "register_operand" "=f")
3605         (float:SF (match_operand:SI 1 "register_operand" "f")))]
3606   "! TARGET_SOFT_FLOAT"
3607   "{fcnvxf,sgl,sgl|fcnv,w,sgl} %1,%0"
3608   [(set_attr "type" "fpalu")
3609    (set_attr "length" "4")])
3610
3611 ;; This pattern forces (set (reg:DF ...) (float:DF (const_int ...)))
3612 ;; to be reloaded by putting the constant into memory.
3613 ;; It must come before the more general floatsidf2 pattern.
3614 (define_insn ""
3615   [(set (match_operand:DF 0 "register_operand" "=f")
3616         (float:DF (match_operand:SI 1 "const_int_operand" "m")))]
3617   "! TARGET_SOFT_FLOAT"
3618   "fldw%F1 %1,%0\;{fcnvxf,sgl,dbl|fcnv,w,dbl} %0,%0"
3619   [(set_attr "type" "fpalu")
3620    (set_attr "length" "8")])
3621
3622 (define_insn "floatsidf2"
3623   [(set (match_operand:DF 0 "register_operand" "=f")
3624         (float:DF (match_operand:SI 1 "register_operand" "f")))]
3625   "! TARGET_SOFT_FLOAT"
3626   "{fcnvxf,sgl,dbl|fcnv,w,dbl} %1,%0"
3627   [(set_attr "type" "fpalu")
3628    (set_attr "length" "4")])
3629
3630 (define_expand "floatunssisf2"
3631   [(set (subreg:SI (match_dup 2) 1)
3632         (match_operand:SI 1 "register_operand" ""))
3633    (set (subreg:SI (match_dup 2) 0)
3634         (const_int 0))
3635    (set (match_operand:SF 0 "register_operand" "")
3636         (float:SF (match_dup 2)))]
3637   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
3638   "
3639 {
3640   if (TARGET_PA_20)
3641     {
3642       emit_insn (gen_floatunssisf2_pa20 (operands[0], operands[1]));
3643       DONE;
3644     }
3645   operands[2] = gen_reg_rtx (DImode);
3646 }")
3647
3648 (define_expand "floatunssidf2"
3649   [(set (subreg:SI (match_dup 2) 1)
3650         (match_operand:SI 1 "register_operand" ""))
3651    (set (subreg:SI (match_dup 2) 0)
3652         (const_int 0))
3653    (set (match_operand:DF 0 "register_operand" "")
3654         (float:DF (match_dup 2)))]
3655   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
3656   "
3657 {
3658   if (TARGET_PA_20)
3659     {
3660       emit_insn (gen_floatunssidf2_pa20 (operands[0], operands[1]));
3661       DONE;
3662     }
3663   operands[2] = gen_reg_rtx (DImode);
3664 }")
3665
3666 (define_insn "floatdisf2"
3667   [(set (match_operand:SF 0 "register_operand" "=f")
3668         (float:SF (match_operand:DI 1 "register_operand" "f")))]
3669   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
3670   "{fcnvxf,dbl,sgl|fcnv,dw,sgl} %1,%0"
3671   [(set_attr "type" "fpalu")
3672    (set_attr "length" "4")])
3673
3674 (define_insn "floatdidf2"
3675   [(set (match_operand:DF 0 "register_operand" "=f")
3676         (float:DF (match_operand:DI 1 "register_operand" "f")))]
3677   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
3678   "{fcnvxf,dbl,dbl|fcnv,dw,dbl} %1,%0"
3679   [(set_attr "type" "fpalu")
3680    (set_attr "length" "4")])
3681
3682 ;; Convert a float to an actual integer.
3683 ;; Truncation is performed as part of the conversion.
3684
3685 (define_insn "fix_truncsfsi2"
3686   [(set (match_operand:SI 0 "register_operand" "=f")
3687         (fix:SI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
3688   "! TARGET_SOFT_FLOAT"
3689   "{fcnvfxt,sgl,sgl|fcnv,t,sgl,w} %1,%0"
3690   [(set_attr "type" "fpalu")
3691    (set_attr "length" "4")])
3692
3693 (define_insn "fix_truncdfsi2"
3694   [(set (match_operand:SI 0 "register_operand" "=f")
3695         (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
3696   "! TARGET_SOFT_FLOAT"
3697   "{fcnvfxt,dbl,sgl|fcnv,t,dbl,w} %1,%0"
3698   [(set_attr "type" "fpalu")
3699    (set_attr "length" "4")])
3700
3701 (define_insn "fix_truncsfdi2"
3702   [(set (match_operand:DI 0 "register_operand" "=f")
3703         (fix:DI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
3704   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
3705   "{fcnvfxt,sgl,dbl|fcnv,t,sgl,dw} %1,%0"
3706   [(set_attr "type" "fpalu")
3707    (set_attr "length" "4")])
3708
3709 (define_insn "fix_truncdfdi2"
3710   [(set (match_operand:DI 0 "register_operand" "=f")
3711         (fix:DI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
3712   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
3713   "{fcnvfxt,dbl,dbl|fcnv,t,dbl,dw} %1,%0"
3714   [(set_attr "type" "fpalu")
3715    (set_attr "length" "4")])
3716
3717 (define_insn "floatunssidf2_pa20"
3718   [(set (match_operand:DF 0 "register_operand" "=f")
3719         (unsigned_float:DF (match_operand:SI 1 "register_operand" "f")))]
3720   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
3721   "fcnv,uw,dbl %1,%0"
3722   [(set_attr "type" "fpalu")
3723    (set_attr "length" "4")])
3724
3725 (define_insn "floatunssisf2_pa20"
3726   [(set (match_operand:SF 0 "register_operand" "=f")
3727         (unsigned_float:SF (match_operand:SI 1 "register_operand" "f")))]
3728   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
3729   "fcnv,uw,sgl %1,%0"
3730   [(set_attr "type" "fpalu")
3731    (set_attr "length" "4")])
3732
3733 (define_insn "floatunsdisf2"
3734   [(set (match_operand:SF 0 "register_operand" "=f")
3735         (unsigned_float:SF (match_operand:DI 1 "register_operand" "f")))]
3736   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
3737   "fcnv,udw,sgl %1,%0"
3738   [(set_attr "type" "fpalu")
3739    (set_attr "length" "4")])
3740
3741 (define_insn "floatunsdidf2"
3742   [(set (match_operand:DF 0 "register_operand" "=f")
3743         (unsigned_float:DF (match_operand:DI 1 "register_operand" "f")))]
3744   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
3745   "fcnv,udw,dbl %1,%0"
3746   [(set_attr "type" "fpalu")
3747    (set_attr "length" "4")])
3748
3749 (define_insn "fixuns_truncsfsi2"
3750   [(set (match_operand:SI 0 "register_operand" "=f")
3751         (unsigned_fix:SI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
3752   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
3753   "fcnv,t,sgl,uw %1,%0"
3754   [(set_attr "type" "fpalu")
3755    (set_attr "length" "4")])
3756
3757 (define_insn "fixuns_truncdfsi2"
3758   [(set (match_operand:SI 0 "register_operand" "=f")
3759         (unsigned_fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
3760   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
3761   "fcnv,t,dbl,uw %1,%0"
3762   [(set_attr "type" "fpalu")
3763    (set_attr "length" "4")])
3764
3765 (define_insn "fixuns_truncsfdi2"
3766   [(set (match_operand:DI 0 "register_operand" "=f")
3767         (unsigned_fix:DI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
3768   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
3769   "fcnv,t,sgl,udw %1,%0"
3770   [(set_attr "type" "fpalu")
3771    (set_attr "length" "4")])
3772
3773 (define_insn "fixuns_truncdfdi2"
3774   [(set (match_operand:DI 0 "register_operand" "=f")
3775         (unsigned_fix:DI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
3776   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
3777   "fcnv,t,dbl,udw %1,%0"
3778   [(set_attr "type" "fpalu")
3779    (set_attr "length" "4")])
3780 \f
3781 ;;- arithmetic instructions
3782
3783 (define_expand "adddi3"
3784   [(set (match_operand:DI 0 "register_operand" "")
3785         (plus:DI (match_operand:DI 1 "register_operand" "")
3786                  (match_operand:DI 2 "arith_operand" "")))]
3787   ""
3788   "")
3789
3790 ;; We allow arith_operand for operands2, even though strictly speaking it
3791 ;; we would prefer to us arith11_operand since that's what the hardware
3792 ;; can actually support.
3793 ;;
3794 ;; But the price of the extra reload in that case is worth the simplicity
3795 ;; we get by allowing a trivial adddi3 expander to be used for both
3796 ;; PA64 and PA32.
3797
3798 (define_insn ""
3799   [(set (match_operand:DI 0 "register_operand" "=r")
3800         (plus:DI (match_operand:DI 1 "register_operand" "%r")
3801                  (match_operand:DI 2 "arith_operand" "rI")))]
3802   "!TARGET_64BIT"
3803   "*
3804 {
3805   if (GET_CODE (operands[2]) == CONST_INT)
3806     {
3807       if (INTVAL (operands[2]) >= 0)
3808         return \"addi %2,%R1,%R0\;{addc|add,c} %1,%%r0,%0\";
3809       else
3810         return \"addi %2,%R1,%R0\;{subb|sub,b} %1,%%r0,%0\";
3811     }
3812   else
3813     return \"add %R2,%R1,%R0\;{addc|add,c} %2,%1,%0\";
3814 }"
3815   [(set_attr "type" "binary")
3816    (set_attr "length" "8")])
3817
3818 (define_insn ""
3819   [(set (match_operand:DI 0 "register_operand" "=r,r")
3820         (plus:DI (match_operand:DI 1 "register_operand" "%r,r")
3821                  (match_operand:DI 2 "arith_operand" "r,J")))]
3822   "TARGET_64BIT"
3823   "@
3824    {addl|add,l} %1,%2,%0
3825    ldo %2(%1),%0"
3826   [(set_attr "type" "binary,binary")
3827    (set_attr "pa_combine_type" "addmove")
3828    (set_attr "length" "4,4")])
3829
3830 (define_insn ""
3831   [(set (match_operand:DI 0 "register_operand" "=r")
3832         (plus:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
3833                  (match_operand:DI 2 "register_operand" "r")))]
3834   "TARGET_64BIT"
3835   "uaddcm %2,%1,%0"
3836   [(set_attr "type" "binary")
3837    (set_attr "length" "4")])
3838
3839 (define_insn ""
3840   [(set (match_operand:SI 0 "register_operand" "=r")
3841         (plus:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
3842                  (match_operand:SI 2 "register_operand" "r")))]
3843   ""
3844   "uaddcm %2,%1,%0"
3845   [(set_attr "type" "binary")
3846    (set_attr "length" "4")])
3847
3848 ;; define_splits to optimize cases of adding a constant integer
3849 ;; to a register when the constant does not fit in 14 bits.  */
3850 (define_split
3851   [(set (match_operand:SI 0 "register_operand" "")
3852         (plus:SI (match_operand:SI 1 "register_operand" "")
3853                  (match_operand:SI 2 "const_int_operand" "")))
3854    (clobber (match_operand:SI 4 "register_operand" ""))]
3855   "! cint_ok_for_move (INTVAL (operands[2]))
3856    && VAL_14_BITS_P (INTVAL (operands[2]) >> 1)"
3857   [(set (match_dup 4) (plus:SI (match_dup 1) (match_dup 2)))
3858    (set (match_dup 0) (plus:SI (match_dup 4) (match_dup 3)))]
3859   "
3860 {
3861   int val = INTVAL (operands[2]);
3862   int low = (val < 0) ? -0x2000 : 0x1fff;
3863   int rest = val - low;
3864
3865   operands[2] = GEN_INT (rest);
3866   operands[3] = GEN_INT (low);
3867 }")
3868
3869 (define_split
3870   [(set (match_operand:SI 0 "register_operand" "")
3871         (plus:SI (match_operand:SI 1 "register_operand" "")
3872                  (match_operand:SI 2 "const_int_operand" "")))
3873    (clobber (match_operand:SI 4 "register_operand" ""))]
3874   "! cint_ok_for_move (INTVAL (operands[2]))"
3875   [(set (match_dup 4) (match_dup 2))
3876    (set (match_dup 0) (plus:SI (mult:SI (match_dup 4) (match_dup 3))
3877                                (match_dup 1)))]
3878   "
3879 {
3880   HOST_WIDE_INT intval = INTVAL (operands[2]);
3881
3882   /* Try dividing the constant by 2, then 4, and finally 8 to see
3883      if we can get a constant which can be loaded into a register
3884      in a single instruction (cint_ok_for_move). 
3885
3886      If that fails, try to negate the constant and subtract it
3887      from our input operand.  */
3888   if (intval % 2 == 0 && cint_ok_for_move (intval / 2))
3889     {
3890       operands[2] = GEN_INT (intval / 2);
3891       operands[3] = GEN_INT (2);
3892     }
3893   else if (intval % 4 == 0 && cint_ok_for_move (intval / 4))
3894     {
3895       operands[2] = GEN_INT (intval / 4);
3896       operands[3] = GEN_INT (4);
3897     }
3898   else if (intval % 8 == 0 && cint_ok_for_move (intval / 8))
3899     {
3900       operands[2] = GEN_INT (intval / 8);
3901       operands[3] = GEN_INT (8);
3902     }
3903   else if (cint_ok_for_move (-intval))
3904     {
3905       emit_insn (gen_rtx_SET (VOIDmode, operands[4], GEN_INT (-intval)));
3906       emit_insn (gen_subsi3 (operands[0], operands[1], operands[4]));
3907       DONE;
3908     }
3909   else
3910     FAIL;
3911 }")
3912
3913 (define_insn "addsi3"
3914   [(set (match_operand:SI 0 "register_operand" "=r,r")
3915         (plus:SI (match_operand:SI 1 "register_operand" "%r,r")
3916                  (match_operand:SI 2 "arith_operand" "r,J")))]
3917   ""
3918   "@
3919    {addl|add,l} %1,%2,%0
3920    ldo %2(%1),%0"
3921   [(set_attr "type" "binary,binary")
3922    (set_attr "pa_combine_type" "addmove")
3923    (set_attr "length" "4,4")])
3924
3925 (define_expand "subdi3"
3926   [(set (match_operand:DI 0 "register_operand" "")
3927         (minus:DI (match_operand:DI 1 "register_operand" "")
3928                   (match_operand:DI 2 "register_operand" "")))]
3929   ""
3930   "")
3931
3932 (define_insn ""
3933   [(set (match_operand:DI 0 "register_operand" "=r")
3934         (minus:DI (match_operand:DI 1 "register_operand" "r")
3935                   (match_operand:DI 2 "register_operand" "r")))]
3936   "!TARGET_64BIT"
3937   "sub %R1,%R2,%R0\;{subb|sub,b} %1,%2,%0"
3938   [(set_attr "type" "binary")
3939   (set_attr "length" "8")])
3940
3941 (define_insn ""
3942   [(set (match_operand:DI 0 "register_operand" "=r,r,q")
3943         (minus:DI (match_operand:DI 1 "arith11_operand" "r,I,U")
3944                   (match_operand:DI 2 "register_operand" "r,r,r")))]
3945   "TARGET_64BIT"
3946   "@
3947    sub %1,%2,%0
3948    subi %1,%2,%0
3949    mtsarcm %2"
3950   [(set_attr "type" "binary,binary,move")
3951   (set_attr "length" "4,4,4")])
3952
3953 (define_expand "subsi3"
3954   [(set (match_operand:SI 0 "register_operand" "")
3955         (minus:SI (match_operand:SI 1 "arith11_operand" "")
3956                   (match_operand:SI 2 "register_operand" "")))]
3957   ""
3958   "")
3959
3960 (define_insn ""
3961   [(set (match_operand:SI 0 "register_operand" "=r,r")
3962         (minus:SI (match_operand:SI 1 "arith11_operand" "r,I")
3963                   (match_operand:SI 2 "register_operand" "r,r")))]
3964   "!TARGET_PA_20"
3965   "@
3966    sub %1,%2,%0
3967    subi %1,%2,%0"
3968   [(set_attr "type" "binary,binary")
3969    (set_attr "length" "4,4")])
3970
3971 (define_insn ""
3972   [(set (match_operand:SI 0 "register_operand" "=r,r,q")
3973         (minus:SI (match_operand:SI 1 "arith11_operand" "r,I,S")
3974                   (match_operand:SI 2 "register_operand" "r,r,r")))]
3975   "TARGET_PA_20"
3976   "@
3977    sub %1,%2,%0
3978    subi %1,%2,%0
3979    mtsarcm %2"
3980   [(set_attr "type" "binary,binary,move")
3981    (set_attr "length" "4,4,4")])
3982
3983 ;; Clobbering a "register_operand" instead of a match_scratch
3984 ;; in operand3 of millicode calls avoids spilling %r1 and
3985 ;; produces better code.
3986
3987 ;; The mulsi3 insns set up registers for the millicode call.
3988 (define_expand "mulsi3"
3989   [(set (reg:SI 26) (match_operand:SI 1 "move_operand" ""))
3990    (set (reg:SI 25) (match_operand:SI 2 "move_operand" ""))
3991    (parallel [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
3992               (clobber (match_dup 3))
3993               (clobber (reg:SI 26))
3994               (clobber (reg:SI 25))
3995               (clobber (reg:SI 31))])
3996    (set (match_operand:SI 0 "general_operand" "") (reg:SI 29))]
3997   ""
3998   "
3999 {
4000   if (TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT)
4001     {
4002       rtx scratch = gen_reg_rtx (DImode);
4003       operands[1] = force_reg (SImode, operands[1]);
4004       operands[2] = force_reg (SImode, operands[2]);
4005       emit_insn (gen_umulsidi3 (scratch, operands[1], operands[2]));
4006       /* We do not want (subreg:SI (XX:DI) 1)) for TARGET_64BIT since
4007          that has no real meaning.  */
4008       if (TARGET_64BIT)
4009         {
4010           emit_insn (gen_rtx_SET (VOIDmode,
4011                                   operands[0],
4012                                   gen_rtx_SUBREG (SImode, scratch, 0)));
4013           DONE;
4014           
4015         }
4016       emit_insn (gen_rtx_SET (VOIDmode, operands[0],
4017                               gen_rtx_SUBREG (SImode, scratch, 1)));
4018       DONE;
4019     }
4020   operands[3] = gen_reg_rtx (SImode);
4021 }")
4022
4023 (define_insn "umulsidi3"
4024   [(set (match_operand:DI 0 "nonimmediate_operand" "=f")
4025         (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "f"))
4026                  (zero_extend:DI (match_operand:SI 2 "nonimmediate_operand" "f"))))]
4027   "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT"
4028   "xmpyu %1,%2,%0"
4029   [(set_attr "type" "fpmuldbl")
4030    (set_attr "length" "4")])
4031
4032 (define_insn ""
4033   [(set (match_operand:DI 0 "nonimmediate_operand" "=f")
4034         (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "f"))
4035                  (match_operand:DI 2 "uint32_operand" "f")))]
4036   "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT && !TARGET_64BIT"
4037   "xmpyu %1,%R2,%0"
4038   [(set_attr "type" "fpmuldbl")
4039    (set_attr "length" "4")])
4040
4041 (define_insn ""
4042   [(set (match_operand:DI 0 "nonimmediate_operand" "=f")
4043         (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "f"))
4044                  (match_operand:DI 2 "uint32_operand" "f")))]
4045   "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT && TARGET_64BIT"
4046   "xmpyu %1,%2R,%0"
4047   [(set_attr "type" "fpmuldbl")
4048    (set_attr "length" "4")])
4049
4050 (define_insn ""
4051   [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
4052    (clobber (match_operand:SI 0 "register_operand" "=a"))
4053    (clobber (reg:SI 26))
4054    (clobber (reg:SI 25))
4055    (clobber (reg:SI 31))]
4056   ""
4057   "* return output_mul_insn (0, insn);"
4058   [(set_attr "type" "milli")
4059    (set (attr "length")
4060      (cond [
4061 ;; Target (or stub) within reach
4062             (and (lt (plus (symbol_ref "total_code_bytes") (pc))
4063                      (const_int 240000))
4064                  (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
4065                      (const_int 0)))
4066             (const_int 4)
4067
4068 ;; NO_SPACE_REGS
4069             (ne (symbol_ref "TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS")
4070                 (const_int 0))
4071             (const_int 8)
4072
4073 ;; Out of reach, but not PIC or PORTABLE_RUNTIME
4074 ;; same as NO_SPACE_REGS code
4075             (and (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
4076                      (const_int 0))
4077                  (eq (symbol_ref "flag_pic")
4078                      (const_int 0)))
4079             (const_int 8)]
4080
4081 ;; Out of range and either PIC or PORTABLE_RUNTIME
4082           (const_int 24)))])
4083
4084 (define_expand "muldi3"
4085   [(set (match_operand:DI 0 "register_operand" "")
4086         (mult:DI (match_operand:DI 1 "register_operand" "")
4087                  (match_operand:DI 2 "register_operand" "")))]
4088   "TARGET_64BIT && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT"
4089   "
4090 {
4091   rtx low_product = gen_reg_rtx (DImode);
4092   rtx cross_product1 = gen_reg_rtx (DImode);
4093   rtx cross_product2 = gen_reg_rtx (DImode);
4094   rtx cross_scratch = gen_reg_rtx (DImode);
4095   rtx cross_product = gen_reg_rtx (DImode);
4096   rtx op1l, op1r, op2l, op2r;
4097   rtx op1shifted, op2shifted;
4098
4099   op1shifted = gen_reg_rtx (DImode);
4100   op2shifted = gen_reg_rtx (DImode);
4101   op1l = gen_reg_rtx (SImode);
4102   op1r = gen_reg_rtx (SImode);
4103   op2l = gen_reg_rtx (SImode);
4104   op2r = gen_reg_rtx (SImode);
4105
4106   emit_move_insn (op1shifted, gen_rtx_LSHIFTRT (DImode, operands[1],
4107                                                 GEN_INT (32)));
4108   emit_move_insn (op2shifted, gen_rtx_LSHIFTRT (DImode, operands[2],
4109                                                 GEN_INT (32)));
4110   op1r = gen_rtx_SUBREG (SImode, operands[1], 0);
4111   op2r = gen_rtx_SUBREG (SImode, operands[2], 0);
4112   op1l = gen_rtx_SUBREG (SImode, op1shifted, 0);
4113   op2l = gen_rtx_SUBREG (SImode, op2shifted, 0);
4114
4115   /* Emit multiplies for the cross products.  */
4116   emit_insn (gen_umulsidi3 (cross_product1, op2r, op1l));
4117   emit_insn (gen_umulsidi3 (cross_product2, op2l, op1r));
4118
4119   /* Emit a multiply for the low sub-word.  */
4120   emit_insn (gen_umulsidi3 (low_product, op2r, op1r));
4121
4122   /* Sum the cross products and shift them into proper position.  */
4123   emit_insn (gen_adddi3 (cross_scratch, cross_product1, cross_product2));
4124   emit_insn (gen_ashldi3 (cross_product, cross_scratch, GEN_INT (32)));
4125
4126   /* Add the cross product to the low product and store the result
4127      into the output operand .  */
4128   emit_insn (gen_adddi3 (operands[0], cross_product, low_product));
4129   DONE;
4130 }")
4131
4132 ;;; Division and mod.
4133 (define_expand "divsi3"
4134   [(set (reg:SI 26) (match_operand:SI 1 "move_operand" ""))
4135    (set (reg:SI 25) (match_operand:SI 2 "move_operand" ""))
4136    (parallel [(set (reg:SI 29) (div:SI (reg:SI 26) (reg:SI 25)))
4137               (clobber (match_dup 3))
4138               (clobber (match_dup 4))
4139               (clobber (reg:SI 26))
4140               (clobber (reg:SI 25))
4141               (clobber (reg:SI 31))])
4142    (set (match_operand:SI 0 "general_operand" "") (reg:SI 29))]
4143   ""
4144   "
4145 {
4146   operands[3] = gen_reg_rtx (SImode);
4147   operands[4] = gen_reg_rtx (SImode);
4148   if (TARGET_64BIT)
4149     operands[4] = gen_rtx_REG (SImode, 2);
4150   if (GET_CODE (operands[2]) == CONST_INT && emit_hpdiv_const (operands, 0))
4151     DONE;
4152 }")
4153
4154 (define_insn ""
4155   [(set (reg:SI 29)
4156         (div:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
4157    (clobber (match_operand:SI 1 "register_operand" "=a"))
4158    (clobber (match_operand:SI 2 "register_operand" "=&r"))
4159    (clobber (reg:SI 26))
4160    (clobber (reg:SI 25))
4161    (clobber (reg:SI 31))]
4162   ""
4163   "*
4164    return output_div_insn (operands, 0, insn);"
4165   [(set_attr "type" "milli")
4166    (set (attr "length")
4167      (cond [
4168 ;; Target (or stub) within reach
4169             (and (lt (plus (symbol_ref "total_code_bytes") (pc))
4170                      (const_int 240000))
4171                  (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
4172                      (const_int 0)))
4173             (const_int 4)
4174
4175 ;; NO_SPACE_REGS
4176             (ne (symbol_ref "TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS")
4177                 (const_int 0))
4178             (const_int 8)
4179
4180 ;; Out of reach, but not PIC or PORTABLE_RUNTIME
4181 ;; same as NO_SPACE_REGS code
4182             (and (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
4183                      (const_int 0))
4184                  (eq (symbol_ref "flag_pic")
4185                      (const_int 0)))
4186             (const_int 8)]
4187
4188 ;; Out of range and either PIC or PORTABLE_RUNTIME
4189           (const_int 24)))])
4190
4191 (define_expand "udivsi3"
4192   [(set (reg:SI 26) (match_operand:SI 1 "move_operand" ""))
4193    (set (reg:SI 25) (match_operand:SI 2 "move_operand" ""))
4194    (parallel [(set (reg:SI 29) (udiv:SI (reg:SI 26) (reg:SI 25)))
4195               (clobber (match_dup 3))
4196               (clobber (match_dup 4))
4197               (clobber (reg:SI 26))
4198               (clobber (reg:SI 25))
4199               (clobber (reg:SI 31))])
4200    (set (match_operand:SI 0 "general_operand" "") (reg:SI 29))]
4201   ""
4202   "
4203 {
4204   operands[3] = gen_reg_rtx (SImode);
4205   operands[4] = gen_reg_rtx (SImode);
4206   if (TARGET_64BIT)
4207     operands[4] = gen_rtx_REG (SImode, 2);
4208   if (GET_CODE (operands[2]) == CONST_INT && emit_hpdiv_const (operands, 1))
4209     DONE;
4210 }")
4211
4212 (define_insn ""
4213   [(set (reg:SI 29)
4214         (udiv:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
4215    (clobber (match_operand:SI 1 "register_operand" "=a"))
4216    (clobber (match_operand:SI 2 "register_operand" "=&r"))
4217    (clobber (reg:SI 26))
4218    (clobber (reg:SI 25))
4219    (clobber (reg:SI 31))]
4220   ""
4221   "*
4222    return output_div_insn (operands, 1, insn);"
4223   [(set_attr "type" "milli")
4224    (set (attr "length")
4225      (cond [
4226 ;; Target (or stub) within reach
4227             (and (lt (plus (symbol_ref "total_code_bytes") (pc))
4228                      (const_int 240000))
4229                  (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
4230                      (const_int 0)))
4231             (const_int 4)
4232
4233 ;; NO_SPACE_REGS
4234             (ne (symbol_ref "TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS")
4235                 (const_int 0))
4236             (const_int 8)
4237
4238 ;; Out of reach, but not PIC or PORTABLE_RUNTIME
4239 ;; same as NO_SPACE_REGS code
4240             (and (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
4241                      (const_int 0))
4242                  (eq (symbol_ref "flag_pic")
4243                      (const_int 0)))
4244             (const_int 8)]
4245
4246 ;; Out of range and either PIC or PORTABLE_RUNTIME
4247           (const_int 24)))])
4248
4249 (define_expand "modsi3"
4250   [(set (reg:SI 26) (match_operand:SI 1 "move_operand" ""))
4251    (set (reg:SI 25) (match_operand:SI 2 "move_operand" ""))
4252    (parallel [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
4253               (clobber (match_dup 3))
4254               (clobber (match_dup 4))
4255               (clobber (reg:SI 26))
4256               (clobber (reg:SI 25))
4257               (clobber (reg:SI 31))])
4258    (set (match_operand:SI 0 "general_operand" "") (reg:SI 29))]
4259   ""
4260   "
4261 {
4262   operands[4] = gen_reg_rtx (SImode);
4263   if (TARGET_64BIT)
4264     operands[4] = gen_rtx_REG (SImode, 2);
4265   operands[3] = gen_reg_rtx (SImode);
4266 }")
4267
4268 (define_insn ""
4269   [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
4270    (clobber (match_operand:SI 0 "register_operand" "=a"))
4271    (clobber (match_operand:SI 2 "register_operand" "=&r"))
4272    (clobber (reg:SI 26))
4273    (clobber (reg:SI 25))
4274    (clobber (reg:SI 31))]
4275   ""
4276   "*
4277   return output_mod_insn (0, insn);"
4278   [(set_attr "type" "milli")
4279    (set (attr "length")
4280      (cond [
4281 ;; Target (or stub) within reach
4282             (and (lt (plus (symbol_ref "total_code_bytes") (pc))
4283                      (const_int 240000))
4284                  (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
4285                      (const_int 0)))
4286             (const_int 4)
4287
4288 ;; NO_SPACE_REGS
4289             (ne (symbol_ref "TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS")
4290                 (const_int 0))
4291             (const_int 8)
4292
4293 ;; Out of reach, but not PIC or PORTABLE_RUNTIME
4294 ;; same as NO_SPACE_REGS code
4295             (and (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
4296                      (const_int 0))
4297                  (eq (symbol_ref "flag_pic")
4298                      (const_int 0)))
4299             (const_int 8)]
4300
4301 ;; Out of range and either PIC or PORTABLE_RUNTIME
4302           (const_int 24)))])
4303
4304 (define_expand "umodsi3"
4305   [(set (reg:SI 26) (match_operand:SI 1 "move_operand" ""))
4306    (set (reg:SI 25) (match_operand:SI 2 "move_operand" ""))
4307    (parallel [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
4308               (clobber (match_dup 3))
4309               (clobber (match_dup 4))
4310               (clobber (reg:SI 26))
4311               (clobber (reg:SI 25))
4312               (clobber (reg:SI 31))])
4313    (set (match_operand:SI 0 "general_operand" "") (reg:SI 29))]
4314   ""
4315   "
4316 {
4317   operands[4] = gen_reg_rtx (SImode);
4318   if (TARGET_64BIT)
4319     operands[4] = gen_rtx_REG (SImode, 2);
4320   operands[3] = gen_reg_rtx (SImode);
4321 }")
4322
4323 (define_insn ""
4324   [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
4325    (clobber (match_operand:SI 0 "register_operand" "=a"))
4326    (clobber (match_operand:SI 2 "register_operand" "=&r"))
4327    (clobber (reg:SI 26))
4328    (clobber (reg:SI 25))
4329    (clobber (reg:SI 31))]
4330   ""
4331   "*
4332   return output_mod_insn (1, insn);"
4333   [(set_attr "type" "milli")
4334    (set (attr "length")
4335      (cond [
4336 ;; Target (or stub) within reach
4337             (and (lt (plus (symbol_ref "total_code_bytes") (pc))
4338                      (const_int 240000))
4339                  (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
4340                      (const_int 0)))
4341             (const_int 4)
4342
4343 ;; NO_SPACE_REGS
4344             (ne (symbol_ref "TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS")
4345                 (const_int 0))
4346             (const_int 8)
4347
4348 ;; Out of reach, but not PIC or PORTABLE_RUNTIME
4349 ;; same as NO_SPACE_REGS code
4350             (and (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
4351                      (const_int 0))
4352                  (eq (symbol_ref "flag_pic")
4353                      (const_int 0)))
4354             (const_int 8)]
4355
4356 ;; Out of range and either PIC or PORTABLE_RUNTIME
4357           (const_int 24)))])
4358
4359 ;;- and instructions
4360 ;; We define DImode `and` so with DImode `not` we can get
4361 ;; DImode `andn`.  Other combinations are possible.
4362
4363 (define_expand "anddi3"
4364   [(set (match_operand:DI 0 "register_operand" "")
4365         (and:DI (match_operand:DI 1 "arith_double_operand" "")
4366                 (match_operand:DI 2 "arith_double_operand" "")))]
4367   ""
4368   "
4369 {
4370   if (! register_operand (operands[1], DImode)
4371       || ! register_operand (operands[2], DImode))
4372     /* Let GCC break this into word-at-a-time operations.  */
4373     FAIL;
4374 }")
4375
4376 (define_insn ""
4377   [(set (match_operand:DI 0 "register_operand" "=r")
4378         (and:DI (match_operand:DI 1 "register_operand" "%r")
4379                 (match_operand:DI 2 "register_operand" "r")))]
4380   "!TARGET_64BIT"
4381   "and %1,%2,%0\;and %R1,%R2,%R0"
4382   [(set_attr "type" "binary")
4383    (set_attr "length" "8")])
4384
4385 (define_insn ""
4386   [(set (match_operand:DI 0 "register_operand" "=r,r")
4387         (and:DI (match_operand:DI 1 "register_operand" "%?r,0")
4388                 (match_operand:DI 2 "and_operand" "rO,P")))]
4389   "TARGET_64BIT"
4390   "* return output_64bit_and (operands); "
4391   [(set_attr "type" "binary")
4392    (set_attr "length" "4")])
4393
4394 ; The ? for op1 makes reload prefer zdepi instead of loading a huge
4395 ; constant with ldil;ldo.
4396 (define_insn "andsi3"
4397   [(set (match_operand:SI 0 "register_operand" "=r,r")
4398         (and:SI (match_operand:SI 1 "register_operand" "%?r,0")
4399                 (match_operand:SI 2 "and_operand" "rO,P")))]
4400   ""
4401   "* return output_and (operands); "
4402   [(set_attr "type" "binary,shift")
4403    (set_attr "length" "4,4")])
4404
4405 (define_insn ""
4406   [(set (match_operand:DI 0 "register_operand" "=r")
4407         (and:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
4408                 (match_operand:DI 2 "register_operand" "r")))]
4409   "!TARGET_64BIT"
4410   "andcm %2,%1,%0\;andcm %R2,%R1,%R0"
4411   [(set_attr "type" "binary")
4412    (set_attr "length" "8")])
4413
4414 (define_insn ""
4415   [(set (match_operand:DI 0 "register_operand" "=r")
4416         (and:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
4417                 (match_operand:DI 2 "register_operand" "r")))]
4418   "TARGET_64BIT"
4419   "andcm %2,%1,%0"
4420   [(set_attr "type" "binary")
4421    (set_attr "length" "4")])
4422
4423 (define_insn ""
4424   [(set (match_operand:SI 0 "register_operand" "=r")
4425         (and:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
4426                 (match_operand:SI 2 "register_operand" "r")))]
4427   ""
4428   "andcm %2,%1,%0"
4429   [(set_attr "type" "binary")
4430   (set_attr "length" "4")])
4431
4432 (define_expand "iordi3"
4433   [(set (match_operand:DI 0 "register_operand" "")
4434         (ior:DI (match_operand:DI 1 "arith_double_operand" "")
4435                 (match_operand:DI 2 "arith_double_operand" "")))]
4436   ""
4437   "
4438 {
4439   if (! register_operand (operands[1], DImode)
4440       || ! register_operand (operands[2], DImode))
4441     /* Let GCC break this into word-at-a-time operations.  */
4442     FAIL;
4443 }")
4444
4445 (define_insn ""
4446   [(set (match_operand:DI 0 "register_operand" "=r")
4447         (ior:DI (match_operand:DI 1 "register_operand" "%r")
4448                 (match_operand:DI 2 "register_operand" "r")))]
4449   "!TARGET_64BIT"
4450   "or %1,%2,%0\;or %R1,%R2,%R0"
4451   [(set_attr "type" "binary")
4452    (set_attr "length" "8")])
4453
4454 (define_insn ""
4455   [(set (match_operand:DI 0 "register_operand" "=r,r")
4456         (ior:DI (match_operand:DI 1 "register_operand" "0,0")
4457                 (match_operand:DI 2 "ior_operand" "M,i")))]
4458   "TARGET_64BIT"
4459   "* return output_64bit_ior (operands); "
4460   [(set_attr "type" "binary,shift")
4461    (set_attr "length" "4,4")])
4462
4463 (define_insn ""
4464   [(set (match_operand:DI 0 "register_operand" "=r")
4465         (ior:DI (match_operand:DI 1 "register_operand" "%r")
4466                 (match_operand:DI 2 "register_operand" "r")))]
4467   "TARGET_64BIT"
4468   "or %1,%2,%0"
4469   [(set_attr "type" "binary")
4470    (set_attr "length" "4")])
4471
4472 ;; Need a define_expand because we've run out of CONST_OK... characters.
4473 (define_expand "iorsi3"
4474   [(set (match_operand:SI 0 "register_operand" "")
4475         (ior:SI (match_operand:SI 1 "register_operand" "")
4476                 (match_operand:SI 2 "arith32_operand" "")))]
4477   ""
4478   "
4479 {
4480   if (! (ior_operand (operands[2], SImode)
4481          || register_operand (operands[2], SImode)))
4482     operands[2] = force_reg (SImode, operands[2]);
4483 }")
4484
4485 (define_insn ""
4486   [(set (match_operand:SI 0 "register_operand" "=r,r")
4487         (ior:SI (match_operand:SI 1 "register_operand" "0,0")
4488                 (match_operand:SI 2 "ior_operand" "M,i")))]
4489   ""
4490   "* return output_ior (operands); "
4491   [(set_attr "type" "binary,shift")
4492    (set_attr "length" "4,4")])
4493
4494 (define_insn ""
4495   [(set (match_operand:SI 0 "register_operand" "=r")
4496         (ior:SI (match_operand:SI 1 "register_operand" "%r")
4497                 (match_operand:SI 2 "register_operand" "r")))]
4498   ""
4499   "or %1,%2,%0"
4500   [(set_attr "type" "binary")
4501    (set_attr "length" "4")])
4502
4503 (define_expand "xordi3"
4504   [(set (match_operand:DI 0 "register_operand" "")
4505         (xor:DI (match_operand:DI 1 "arith_double_operand" "")
4506                 (match_operand:DI 2 "arith_double_operand" "")))]
4507   ""
4508   "
4509 {
4510   if (! register_operand (operands[1], DImode)
4511       || ! register_operand (operands[2], DImode))
4512     /* Let GCC break this into word-at-a-time operations.  */
4513     FAIL;
4514 }")
4515
4516 (define_insn ""
4517   [(set (match_operand:DI 0 "register_operand" "=r")
4518         (xor:DI (match_operand:DI 1 "register_operand" "%r")
4519                 (match_operand:DI 2 "register_operand" "r")))]
4520   "!TARGET_64BIT"
4521   "xor %1,%2,%0\;xor %R1,%R2,%R0"
4522   [(set_attr "type" "binary")
4523    (set_attr "length" "8")])
4524
4525 (define_insn ""
4526   [(set (match_operand:DI 0 "register_operand" "=r")
4527         (xor:DI (match_operand:DI 1 "register_operand" "%r")
4528                 (match_operand:DI 2 "register_operand" "r")))]
4529   "TARGET_64BIT"
4530   "xor %1,%2,%0"
4531   [(set_attr "type" "binary")
4532    (set_attr "length" "4")])
4533
4534 (define_insn "xorsi3"
4535   [(set (match_operand:SI 0 "register_operand" "=r")
4536         (xor:SI (match_operand:SI 1 "register_operand" "%r")
4537                 (match_operand:SI 2 "register_operand" "r")))]
4538   ""
4539   "xor %1,%2,%0"
4540   [(set_attr "type" "binary")
4541    (set_attr "length" "4")])
4542
4543 (define_expand "negdi2"
4544   [(set (match_operand:DI 0 "register_operand" "")
4545         (neg:DI (match_operand:DI 1 "register_operand" "")))]
4546   ""
4547   "")
4548
4549 (define_insn ""
4550   [(set (match_operand:DI 0 "register_operand" "=r")
4551         (neg:DI (match_operand:DI 1 "register_operand" "r")))]
4552   "!TARGET_64BIT"
4553   "sub %%r0,%R1,%R0\;{subb|sub,b} %%r0,%1,%0"
4554   [(set_attr "type" "unary")
4555    (set_attr "length" "8")])
4556
4557 (define_insn ""
4558   [(set (match_operand:DI 0 "register_operand" "=r")
4559         (neg:DI (match_operand:DI 1 "register_operand" "r")))]
4560   "TARGET_64BIT"
4561   "sub %%r0,%1,%0"
4562   [(set_attr "type" "unary")
4563    (set_attr "length" "4")])
4564
4565 (define_insn "negsi2"
4566   [(set (match_operand:SI 0 "register_operand" "=r")
4567         (neg:SI (match_operand:SI 1 "register_operand" "r")))]
4568   ""
4569   "sub %%r0,%1,%0"
4570   [(set_attr "type" "unary")
4571    (set_attr "length" "4")])
4572
4573 (define_expand "one_cmpldi2"
4574   [(set (match_operand:DI 0 "register_operand" "")
4575         (not:DI (match_operand:DI 1 "arith_double_operand" "")))]
4576   ""
4577   "
4578 {
4579   if (! register_operand (operands[1], DImode))
4580     FAIL;
4581 }")
4582
4583 (define_insn ""
4584   [(set (match_operand:DI 0 "register_operand" "=r")
4585         (not:DI (match_operand:DI 1 "register_operand" "r")))]
4586   "!TARGET_64BIT"
4587   "uaddcm %%r0,%1,%0\;uaddcm %%r0,%R1,%R0"
4588   [(set_attr "type" "unary")
4589    (set_attr "length" "8")])
4590
4591 (define_insn ""
4592   [(set (match_operand:DI 0 "register_operand" "=r")
4593         (not:DI (match_operand:DI 1 "register_operand" "r")))]
4594   "TARGET_64BIT"
4595   "uaddcm %%r0,%1,%0"
4596   [(set_attr "type" "unary")
4597    (set_attr "length" "4")])
4598
4599 (define_insn "one_cmplsi2"
4600   [(set (match_operand:SI 0 "register_operand" "=r")
4601         (not:SI (match_operand:SI 1 "register_operand" "r")))]
4602   ""
4603   "uaddcm %%r0,%1,%0"
4604   [(set_attr "type" "unary")
4605    (set_attr "length" "4")])
4606 \f
4607 ;; Floating point arithmetic instructions.
4608
4609 (define_insn "adddf3"
4610   [(set (match_operand:DF 0 "register_operand" "=f")
4611         (plus:DF (match_operand:DF 1 "register_operand" "f")
4612                  (match_operand:DF 2 "register_operand" "f")))]
4613   "! TARGET_SOFT_FLOAT"
4614   "fadd,dbl %1,%2,%0"
4615   [(set_attr "type" "fpalu")
4616    (set_attr "pa_combine_type" "faddsub")
4617    (set_attr "length" "4")])
4618
4619 (define_insn "addsf3"
4620   [(set (match_operand:SF 0 "register_operand" "=f")
4621         (plus:SF (match_operand:SF 1 "register_operand" "f")
4622                  (match_operand:SF 2 "register_operand" "f")))]
4623   "! TARGET_SOFT_FLOAT"
4624   "fadd,sgl %1,%2,%0"
4625   [(set_attr "type" "fpalu")
4626    (set_attr "pa_combine_type" "faddsub")
4627    (set_attr "length" "4")])
4628
4629 (define_insn "subdf3"
4630   [(set (match_operand:DF 0 "register_operand" "=f")
4631         (minus:DF (match_operand:DF 1 "register_operand" "f")
4632                   (match_operand:DF 2 "register_operand" "f")))]
4633   "! TARGET_SOFT_FLOAT"
4634   "fsub,dbl %1,%2,%0"
4635   [(set_attr "type" "fpalu")
4636    (set_attr "pa_combine_type" "faddsub")
4637    (set_attr "length" "4")])
4638
4639 (define_insn "subsf3"
4640   [(set (match_operand:SF 0 "register_operand" "=f")
4641         (minus:SF (match_operand:SF 1 "register_operand" "f")
4642                   (match_operand:SF 2 "register_operand" "f")))]
4643   "! TARGET_SOFT_FLOAT"
4644   "fsub,sgl %1,%2,%0"
4645   [(set_attr "type" "fpalu")
4646    (set_attr "pa_combine_type" "faddsub")
4647    (set_attr "length" "4")])
4648
4649 (define_insn "muldf3"
4650   [(set (match_operand:DF 0 "register_operand" "=f")
4651         (mult:DF (match_operand:DF 1 "register_operand" "f")
4652                  (match_operand:DF 2 "register_operand" "f")))]
4653   "! TARGET_SOFT_FLOAT"
4654   "fmpy,dbl %1,%2,%0"
4655   [(set_attr "type" "fpmuldbl")
4656    (set_attr "pa_combine_type" "fmpy")
4657    (set_attr "length" "4")])
4658
4659 (define_insn "mulsf3"
4660   [(set (match_operand:SF 0 "register_operand" "=f")
4661         (mult:SF (match_operand:SF 1 "register_operand" "f")
4662                  (match_operand:SF 2 "register_operand" "f")))]
4663   "! TARGET_SOFT_FLOAT"
4664   "fmpy,sgl %1,%2,%0"
4665   [(set_attr "type" "fpmulsgl")
4666    (set_attr "pa_combine_type" "fmpy")
4667    (set_attr "length" "4")])
4668
4669 (define_insn "divdf3"
4670   [(set (match_operand:DF 0 "register_operand" "=f")
4671         (div:DF (match_operand:DF 1 "register_operand" "f")
4672                 (match_operand:DF 2 "register_operand" "f")))]
4673   "! TARGET_SOFT_FLOAT"
4674   "fdiv,dbl %1,%2,%0"
4675   [(set_attr "type" "fpdivdbl")
4676    (set_attr "length" "4")])
4677
4678 (define_insn "divsf3"
4679   [(set (match_operand:SF 0 "register_operand" "=f")
4680         (div:SF (match_operand:SF 1 "register_operand" "f")
4681                 (match_operand:SF 2 "register_operand" "f")))]
4682   "! TARGET_SOFT_FLOAT"
4683   "fdiv,sgl %1,%2,%0"
4684   [(set_attr "type" "fpdivsgl")
4685    (set_attr "length" "4")])
4686
4687 (define_insn "negdf2"
4688   [(set (match_operand:DF 0 "register_operand" "=f")
4689         (neg:DF (match_operand:DF 1 "register_operand" "f")))]
4690   "! TARGET_SOFT_FLOAT"
4691   "*
4692 {
4693   if (TARGET_PA_20)
4694     return \"fneg,dbl %1,%0\";
4695   else
4696     return \"fsub,dbl %%fr0,%1,%0\";
4697 }"
4698   [(set_attr "type" "fpalu")
4699    (set_attr "length" "4")])
4700
4701 (define_insn "negsf2"
4702   [(set (match_operand:SF 0 "register_operand" "=f")
4703         (neg:SF (match_operand:SF 1 "register_operand" "f")))]
4704   "! TARGET_SOFT_FLOAT"
4705   "*
4706 {
4707   if (TARGET_PA_20)
4708     return \"fneg,sgl %1,%0\";
4709   else
4710     return \"fsub,sgl %%fr0,%1,%0\";
4711 }"
4712   [(set_attr "type" "fpalu")
4713    (set_attr "length" "4")])
4714
4715 (define_insn "absdf2"
4716   [(set (match_operand:DF 0 "register_operand" "=f")
4717         (abs:DF (match_operand:DF 1 "register_operand" "f")))]
4718   "! TARGET_SOFT_FLOAT"
4719   "fabs,dbl %1,%0"
4720   [(set_attr "type" "fpalu")
4721    (set_attr "length" "4")])
4722
4723 (define_insn "abssf2"
4724   [(set (match_operand:SF 0 "register_operand" "=f")
4725         (abs:SF (match_operand:SF 1 "register_operand" "f")))]
4726   "! TARGET_SOFT_FLOAT"
4727   "fabs,sgl %1,%0"
4728   [(set_attr "type" "fpalu")
4729    (set_attr "length" "4")])
4730
4731 (define_insn "sqrtdf2"
4732   [(set (match_operand:DF 0 "register_operand" "=f")
4733         (sqrt:DF (match_operand:DF 1 "register_operand" "f")))]
4734   "! TARGET_SOFT_FLOAT"
4735   "fsqrt,dbl %1,%0"
4736   [(set_attr "type" "fpsqrtdbl")
4737    (set_attr "length" "4")])
4738
4739 (define_insn "sqrtsf2"
4740   [(set (match_operand:SF 0 "register_operand" "=f")
4741         (sqrt:SF (match_operand:SF 1 "register_operand" "f")))]
4742   "! TARGET_SOFT_FLOAT"
4743   "fsqrt,sgl %1,%0"
4744   [(set_attr "type" "fpsqrtsgl")
4745    (set_attr "length" "4")])
4746
4747 ;; PA 2.0 floating point instructions
4748
4749 ; fmpyfadd patterns
4750 (define_insn ""
4751   [(set (match_operand:DF 0 "register_operand" "=f")
4752         (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
4753                           (match_operand:DF 2 "register_operand" "f"))
4754                  (match_operand:DF 3 "register_operand" "f")))]
4755   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
4756   "fmpyfadd,dbl %1,%2,%3,%0"
4757   [(set_attr "type" "fpmuldbl")
4758    (set_attr "length" "4")])
4759
4760 (define_insn ""
4761   [(set (match_operand:DF 0 "register_operand" "=f")
4762         (plus:DF (match_operand:DF 1 "register_operand" "f")
4763                  (mult:DF (match_operand:DF 2 "register_operand" "f")
4764                           (match_operand:DF 3 "register_operand" "f"))))]
4765   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
4766   "fmpyfadd,dbl %2,%3,%1,%0"
4767   [(set_attr "type" "fpmuldbl")
4768    (set_attr "length" "4")])
4769
4770 (define_insn ""
4771   [(set (match_operand:SF 0 "register_operand" "=f")
4772         (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
4773                           (match_operand:SF 2 "register_operand" "f"))
4774                  (match_operand:SF 3 "register_operand" "f")))]
4775   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
4776   "fmpyfadd,sgl %1,%2,%3,%0"
4777   [(set_attr "type" "fpmulsgl")
4778    (set_attr "length" "4")])
4779
4780 (define_insn ""
4781   [(set (match_operand:SF 0 "register_operand" "=f")
4782         (plus:SF (match_operand:SF 1 "register_operand" "f")
4783                  (mult:SF (match_operand:SF 2 "register_operand" "f")
4784                           (match_operand:SF 3 "register_operand" "f"))))]
4785   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
4786   "fmpyfadd,sgl %2,%3,%1,%0"
4787   [(set_attr "type" "fpmulsgl")
4788    (set_attr "length" "4")])
4789
4790 ; fmpynfadd patterns
4791 (define_insn ""
4792   [(set (match_operand:DF 0 "register_operand" "=f")
4793         (minus:DF (match_operand:DF 1 "register_operand" "f")
4794                   (mult:DF (match_operand:DF 2 "register_operand" "f")
4795                            (match_operand:DF 3 "register_operand" "f"))))]
4796   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
4797   "fmpynfadd,dbl %2,%3,%1,%0"
4798   [(set_attr "type" "fpmuldbl")
4799    (set_attr "length" "4")])
4800
4801 (define_insn ""
4802   [(set (match_operand:SF 0 "register_operand" "=f")
4803         (minus:SF (match_operand:SF 1 "register_operand" "f")
4804                   (mult:SF (match_operand:SF 2 "register_operand" "f")
4805                            (match_operand:SF 3 "register_operand" "f"))))]
4806   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
4807   "fmpynfadd,sgl %2,%3,%1,%0"
4808   [(set_attr "type" "fpmulsgl")
4809    (set_attr "length" "4")])
4810
4811 ; fnegabs patterns
4812 (define_insn ""
4813   [(set (match_operand:DF 0 "register_operand" "=f")
4814         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))]
4815   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
4816   "fnegabs,dbl %1,%0"
4817   [(set_attr "type" "fpalu")
4818    (set_attr "length" "4")])
4819
4820 (define_insn ""
4821   [(set (match_operand:SF 0 "register_operand" "=f")
4822         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))]
4823   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
4824   "fnegabs,sgl %1,%0"
4825   [(set_attr "type" "fpalu")
4826    (set_attr "length" "4")])
4827
4828 ;; Generating a fused multiply sequence is a win for this case as it will
4829 ;; reduce the latency for the fused case without impacting the plain
4830 ;; multiply case.
4831 ;;
4832 ;; Similar possibilities exist for fnegabs, shadd and other insns which
4833 ;; perform two operations with the result of the first feeding the second.
4834 (define_insn ""
4835   [(set (match_operand:DF 0 "register_operand" "=f")
4836         (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
4837                           (match_operand:DF 2 "register_operand" "f"))
4838                  (match_operand:DF 3 "register_operand" "f")))
4839    (set (match_operand:DF 4 "register_operand" "=&f")
4840         (mult:DF (match_dup 1) (match_dup 2)))]
4841   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
4842     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
4843           || reg_overlap_mentioned_p (operands[4], operands[2])))"
4844   "#"
4845   [(set_attr "type" "fpmuldbl")
4846    (set_attr "length" "8")])
4847
4848 ;; We want to split this up during scheduling since we want both insns
4849 ;; to schedule independently.
4850 (define_split
4851   [(set (match_operand:DF 0 "register_operand" "=f")
4852         (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
4853                           (match_operand:DF 2 "register_operand" "f"))
4854                  (match_operand:DF 3 "register_operand" "f")))
4855    (set (match_operand:DF 4 "register_operand" "=&f")
4856         (mult:DF (match_dup 1) (match_dup 2)))]
4857   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4858   [(set (match_dup 4) (mult:DF (match_dup 1) (match_dup 2)))
4859    (set (match_dup 0) (plus:DF (mult:DF (match_dup 1) (match_dup 2))
4860                                (match_dup 3)))]
4861   "")
4862
4863 (define_insn ""
4864   [(set (match_operand:SF 0 "register_operand" "=f")
4865         (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
4866                           (match_operand:SF 2 "register_operand" "f"))
4867                  (match_operand:SF 3 "register_operand" "f")))
4868    (set (match_operand:SF 4 "register_operand" "=&f")
4869         (mult:SF (match_dup 1) (match_dup 2)))]
4870   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
4871     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
4872           || reg_overlap_mentioned_p (operands[4], operands[2])))"
4873   "#"
4874   [(set_attr "type" "fpmuldbl")
4875    (set_attr "length" "8")])
4876
4877 ;; We want to split this up during scheduling since we want both insns
4878 ;; to schedule independently.
4879 (define_split
4880   [(set (match_operand:SF 0 "register_operand" "=f")
4881         (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
4882                           (match_operand:SF 2 "register_operand" "f"))
4883                  (match_operand:SF 3 "register_operand" "f")))
4884    (set (match_operand:SF 4 "register_operand" "=&f")
4885         (mult:SF (match_dup 1) (match_dup 2)))]
4886   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4887   [(set (match_dup 4) (mult:SF (match_dup 1) (match_dup 2)))
4888    (set (match_dup 0) (plus:SF (mult:SF (match_dup 1) (match_dup 2))
4889                                (match_dup 3)))]
4890   "")
4891
4892 ;; Negating a multiply can be faked by adding zero in a fused multiply-add
4893 ;; instruction.
4894 (define_insn ""
4895   [(set (match_operand:DF 0 "register_operand" "=f")
4896         (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
4897                          (match_operand:DF 2 "register_operand" "f"))))]
4898   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4899   "fmpynfadd,dbl %1,%2,%%fr0,%0"
4900   [(set_attr "type" "fpmuldbl")
4901    (set_attr "length" "4")])
4902
4903 (define_insn ""
4904   [(set (match_operand:SF 0 "register_operand" "=f")
4905         (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
4906                          (match_operand:SF 2 "register_operand" "f"))))]
4907   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4908   "fmpynfadd,sgl %1,%2,%%fr0,%0"
4909   [(set_attr "type" "fpmuldbl")
4910    (set_attr "length" "4")])
4911
4912 (define_insn ""
4913   [(set (match_operand:DF 0 "register_operand" "=f")
4914         (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
4915                          (match_operand:DF 2 "register_operand" "f"))))
4916    (set (match_operand:DF 3 "register_operand" "=&f")
4917         (mult:DF (match_dup 1) (match_dup 2)))]
4918   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
4919     && ! (reg_overlap_mentioned_p (operands[3], operands[1])
4920           || reg_overlap_mentioned_p (operands[3], operands[2])))"
4921   "#"
4922   [(set_attr "type" "fpmuldbl")
4923    (set_attr "length" "8")])
4924
4925 (define_split
4926   [(set (match_operand:DF 0 "register_operand" "=f")
4927         (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
4928                          (match_operand:DF 2 "register_operand" "f"))))
4929    (set (match_operand:DF 3 "register_operand" "=&f")
4930         (mult:DF (match_dup 1) (match_dup 2)))]
4931   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4932   [(set (match_dup 3) (mult:DF (match_dup 1) (match_dup 2)))
4933    (set (match_dup 0) (neg:DF (mult:DF (match_dup 1) (match_dup 2))))]
4934   "")
4935
4936 (define_insn ""
4937   [(set (match_operand:SF 0 "register_operand" "=f")
4938         (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
4939                          (match_operand:SF 2 "register_operand" "f"))))
4940    (set (match_operand:SF 3 "register_operand" "=&f")
4941         (mult:SF (match_dup 1) (match_dup 2)))]
4942   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
4943     && ! (reg_overlap_mentioned_p (operands[3], operands[1])
4944           || reg_overlap_mentioned_p (operands[3], operands[2])))"
4945   "#"
4946   [(set_attr "type" "fpmuldbl")
4947    (set_attr "length" "8")])
4948
4949 (define_split
4950   [(set (match_operand:SF 0 "register_operand" "=f")
4951         (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
4952                          (match_operand:SF 2 "register_operand" "f"))))
4953    (set (match_operand:SF 3 "register_operand" "=&f")
4954         (mult:SF (match_dup 1) (match_dup 2)))]
4955   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4956   [(set (match_dup 3) (mult:SF (match_dup 1) (match_dup 2)))
4957    (set (match_dup 0) (neg:SF (mult:SF (match_dup 1) (match_dup 2))))]
4958   "")
4959
4960 ;; Now fused multiplies with the result of the multiply negated.
4961 (define_insn ""
4962   [(set (match_operand:DF 0 "register_operand" "=f")
4963         (plus:DF (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
4964                                   (match_operand:DF 2 "register_operand" "f")))
4965                  (match_operand:DF 3 "register_operand" "f")))]
4966   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4967   "fmpynfadd,dbl %1,%2,%3,%0"
4968   [(set_attr "type" "fpmuldbl")
4969    (set_attr "length" "4")])
4970
4971 (define_insn ""
4972   [(set (match_operand:SF 0 "register_operand" "=f")
4973         (plus:SF (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
4974                          (match_operand:SF 2 "register_operand" "f")))
4975                  (match_operand:SF 3 "register_operand" "f")))]
4976   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4977   "fmpynfadd,sgl %1,%2,%3,%0"
4978   [(set_attr "type" "fpmuldbl")
4979    (set_attr "length" "4")])
4980
4981 (define_insn ""
4982   [(set (match_operand:DF 0 "register_operand" "=f")
4983         (plus:DF (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
4984                                   (match_operand:DF 2 "register_operand" "f")))
4985                  (match_operand:DF 3 "register_operand" "f")))
4986    (set (match_operand:DF 4 "register_operand" "=&f")
4987         (mult:DF (match_dup 1) (match_dup 2)))]
4988   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
4989     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
4990           || reg_overlap_mentioned_p (operands[4], operands[2])))"
4991   "#"
4992   [(set_attr "type" "fpmuldbl")
4993    (set_attr "length" "8")])
4994
4995 (define_split
4996   [(set (match_operand:DF 0 "register_operand" "=f")
4997         (plus:DF (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
4998                                   (match_operand:DF 2 "register_operand" "f")))
4999                  (match_operand:DF 3 "register_operand" "f")))
5000    (set (match_operand:DF 4 "register_operand" "=&f")
5001         (mult:DF (match_dup 1) (match_dup 2)))]
5002   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5003   [(set (match_dup 4) (mult:DF (match_dup 1) (match_dup 2)))
5004    (set (match_dup 0) (plus:DF (neg:DF (mult:DF (match_dup 1) (match_dup 2)))
5005                                (match_dup 3)))]
5006   "")
5007
5008 (define_insn ""
5009   [(set (match_operand:SF 0 "register_operand" "=f")
5010         (plus:SF (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
5011                                   (match_operand:SF 2 "register_operand" "f")))
5012                  (match_operand:SF 3 "register_operand" "f")))
5013    (set (match_operand:SF 4 "register_operand" "=&f")
5014         (mult:SF (match_dup 1) (match_dup 2)))]
5015   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
5016     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
5017           || reg_overlap_mentioned_p (operands[4], operands[2])))"
5018   "#"
5019   [(set_attr "type" "fpmuldbl")
5020    (set_attr "length" "8")])
5021
5022 (define_split
5023   [(set (match_operand:SF 0 "register_operand" "=f")
5024         (plus:SF (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
5025                                   (match_operand:SF 2 "register_operand" "f")))
5026                  (match_operand:SF 3 "register_operand" "f")))
5027    (set (match_operand:SF 4 "register_operand" "=&f")
5028         (mult:SF (match_dup 1) (match_dup 2)))]
5029   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5030   [(set (match_dup 4) (mult:SF (match_dup 1) (match_dup 2)))
5031    (set (match_dup 0) (plus:SF (neg:SF (mult:SF (match_dup 1) (match_dup 2)))
5032                                (match_dup 3)))]
5033   "")
5034
5035 (define_insn ""
5036   [(set (match_operand:DF 0 "register_operand" "=f")
5037         (minus:DF (match_operand:DF 3 "register_operand" "f")
5038                   (mult:DF (match_operand:DF 1 "register_operand" "f")
5039                            (match_operand:DF 2 "register_operand" "f"))))
5040    (set (match_operand:DF 4 "register_operand" "=&f")
5041         (mult:DF (match_dup 1) (match_dup 2)))]
5042   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
5043     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
5044           || reg_overlap_mentioned_p (operands[4], operands[2])))"
5045   "#"
5046   [(set_attr "type" "fpmuldbl")
5047    (set_attr "length" "8")])
5048
5049 (define_split
5050   [(set (match_operand:DF 0 "register_operand" "=f")
5051         (minus:DF (match_operand:DF 3 "register_operand" "f")
5052                   (mult:DF (match_operand:DF 1 "register_operand" "f")
5053                            (match_operand:DF 2 "register_operand" "f"))))
5054    (set (match_operand:DF 4 "register_operand" "=&f")
5055         (mult:DF (match_dup 1) (match_dup 2)))]
5056   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5057   [(set (match_dup 4) (mult:DF (match_dup 1) (match_dup 2)))
5058    (set (match_dup 0) (minus:DF (match_dup 3)
5059                                 (mult:DF (match_dup 1) (match_dup 2))))]
5060   "")
5061
5062 (define_insn ""
5063   [(set (match_operand:SF 0 "register_operand" "=f")
5064         (minus:SF (match_operand:SF 3 "register_operand" "f")
5065                   (mult:SF (match_operand:SF 1 "register_operand" "f")
5066                            (match_operand:SF 2 "register_operand" "f"))))
5067    (set (match_operand:SF 4 "register_operand" "=&f")
5068         (mult:SF (match_dup 1) (match_dup 2)))]
5069   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
5070     && ! (reg_overlap_mentioned_p (operands[4], operands[1])
5071           || reg_overlap_mentioned_p (operands[4], operands[2])))"
5072   "#"
5073   [(set_attr "type" "fpmuldbl")
5074    (set_attr "length" "8")])
5075
5076 (define_split
5077   [(set (match_operand:SF 0 "register_operand" "=f")
5078         (minus:SF (match_operand:SF 3 "register_operand" "f")
5079                   (mult:SF (match_operand:SF 1 "register_operand" "f")
5080                            (match_operand:SF 2 "register_operand" "f"))))
5081    (set (match_operand:SF 4 "register_operand" "=&f")
5082         (mult:SF (match_dup 1) (match_dup 2)))]
5083   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5084   [(set (match_dup 4) (mult:SF (match_dup 1) (match_dup 2)))
5085    (set (match_dup 0) (minus:SF (match_dup 3)
5086                                 (mult:SF (match_dup 1) (match_dup 2))))]
5087   "")
5088
5089 (define_insn ""
5090   [(set (match_operand:DF 0 "register_operand" "=f")
5091         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))
5092    (set (match_operand:DF 2 "register_operand" "=&f") (abs:DF (match_dup 1)))]
5093   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
5094     && ! reg_overlap_mentioned_p (operands[2], operands[1]))"
5095   "#"
5096   [(set_attr "type" "fpalu")
5097    (set_attr "length" "8")])
5098
5099 (define_split
5100   [(set (match_operand:DF 0 "register_operand" "=f")
5101         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))
5102    (set (match_operand:DF 2 "register_operand" "=&f") (abs:DF (match_dup 1)))]
5103   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5104   [(set (match_dup 2) (abs:DF (match_dup 1)))
5105    (set (match_dup 0) (neg:DF (abs:DF (match_dup 1))))]
5106   "")
5107
5108 (define_insn ""
5109   [(set (match_operand:SF 0 "register_operand" "=f")
5110         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))
5111    (set (match_operand:SF 2 "register_operand" "=&f") (abs:SF (match_dup 1)))]
5112   "(! TARGET_SOFT_FLOAT && TARGET_PA_20
5113     && ! reg_overlap_mentioned_p (operands[2], operands[1]))"
5114   "#"
5115   [(set_attr "type" "fpalu")
5116    (set_attr "length" "8")])
5117
5118 (define_split
5119   [(set (match_operand:SF 0 "register_operand" "=f")
5120         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))
5121    (set (match_operand:SF 2 "register_operand" "=&f") (abs:SF (match_dup 1)))]
5122   "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5123   [(set (match_dup 2) (abs:SF (match_dup 1)))
5124    (set (match_dup 0) (neg:SF (abs:SF (match_dup 1))))]
5125   "")
5126 \f
5127 ;;- Shift instructions
5128
5129 ;; Optimized special case of shifting.
5130
5131 (define_insn ""
5132   [(set (match_operand:SI 0 "register_operand" "=r")
5133         (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
5134                      (const_int 24)))]
5135   ""
5136   "ldb%M1 %1,%0"
5137   [(set_attr "type" "load")
5138    (set_attr "length" "4")])
5139
5140 (define_insn ""
5141   [(set (match_operand:SI 0 "register_operand" "=r")
5142         (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
5143                      (const_int 16)))]
5144   ""
5145   "ldh%M1 %1,%0"
5146   [(set_attr "type" "load")
5147    (set_attr "length" "4")])
5148
5149 (define_insn ""
5150   [(set (match_operand:SI 0 "register_operand" "=r")
5151         (plus:SI (mult:SI (match_operand:SI 2 "register_operand" "r")
5152                           (match_operand:SI 3 "shadd_operand" ""))
5153                  (match_operand:SI 1 "register_operand" "r")))]
5154   ""
5155   "{sh%O3addl %2,%1,%0|shladd,l %2,%O3,%1,%0} "
5156   [(set_attr "type" "binary")
5157    (set_attr "length" "4")])
5158
5159 (define_insn ""
5160   [(set (match_operand:DI 0 "register_operand" "=r")
5161         (plus:DI (mult:DI (match_operand:DI 2 "register_operand" "r")
5162                           (match_operand:DI 3 "shadd_operand" ""))
5163                  (match_operand:DI 1 "register_operand" "r")))]
5164   "TARGET_64BIT"
5165   "shladd,l %2,%O3,%1,%0"
5166   [(set_attr "type" "binary")
5167    (set_attr "length" "4")])
5168
5169 ;; This anonymous pattern and splitter wins because it reduces the latency
5170 ;; of the shadd sequence without increasing the latency of the shift.
5171 ;;
5172 ;; We want to make sure and split up the operations for the scheduler since
5173 ;; these instructions can (and should) schedule independently.
5174 ;;
5175 ;; It would be clearer if combine used the same operator for both expressions,
5176 ;; it's somewhat confusing to have a mult in ine operation and an ashift
5177 ;; in the other.
5178 ;;
5179 ;; If this pattern is not split before register allocation, then we must expose
5180 ;; the fact that operand 4 is set before operands 1, 2 and 3 have been read.
5181 (define_insn ""
5182   [(set (match_operand:SI 0 "register_operand" "=r")
5183         (plus:SI (mult:SI (match_operand:SI 2 "register_operand" "r")
5184                           (match_operand:SI 3 "shadd_operand" ""))
5185                  (match_operand:SI 1 "register_operand" "r")))
5186    (set (match_operand:SI 4 "register_operand" "=&r")
5187         (ashift:SI (match_dup 2)
5188                    (match_operand:SI 5 "const_int_operand" "i")))]
5189   "(INTVAL (operands[5]) == exact_log2 (INTVAL (operands[3]))
5190     && ! (reg_overlap_mentioned_p (operands[4], operands[2])))"
5191   "#"
5192   [(set_attr "type" "binary")
5193    (set_attr "length" "8")])
5194
5195 (define_split
5196   [(set (match_operand:SI 0 "register_operand" "=r")
5197         (plus:SI (mult:SI (match_operand:SI 2 "register_operand" "r")
5198                           (match_operand:SI 3 "shadd_operand" ""))
5199                  (match_operand:SI 1 "register_operand" "r")))
5200    (set (match_operand:SI 4 "register_operand" "=&r")
5201         (ashift:SI (match_dup 2)
5202                    (match_operand:SI 5 "const_int_operand" "i")))]
5203   "INTVAL (operands[5]) == exact_log2 (INTVAL (operands[3]))"
5204   [(set (match_dup 4) (ashift:SI (match_dup 2) (match_dup 5)))
5205    (set (match_dup 0) (plus:SI (mult:SI (match_dup 2) (match_dup 3))
5206                                (match_dup 1)))]
5207   "")
5208
5209 (define_insn ""
5210   [(set (match_operand:DI 0 "register_operand" "=r")
5211         (plus:DI (mult:DI (match_operand:DI 2 "register_operand" "r")
5212                           (match_operand:DI 3 "shadd_operand" ""))
5213                  (match_operand:DI 1 "register_operand" "r")))
5214    (set (match_operand:DI 4 "register_operand" "=&r")
5215         (ashift:DI (match_dup 2)
5216                    (match_operand:DI 5 "const_int_operand" "i")))]
5217   "TARGET_64BIT && INTVAL (operands[5]) == exact_log2 (INTVAL (operands[3]))"
5218   "#"
5219   [(set_attr "type" "binary")
5220    (set_attr "length" "8")])
5221
5222 (define_split
5223   [(set (match_operand:DI 0 "register_operand" "=r")
5224         (plus:DI (mult:DI (match_operand:DI 2 "register_operand" "r")
5225                           (match_operand:DI 3 "shadd_operand" ""))
5226                  (match_operand:DI 1 "register_operand" "r")))
5227    (set (match_operand:DI 4 "register_operand" "=&r")
5228         (ashift:DI (match_dup 2)
5229                    (match_operand:DI 5 "const_int_operand" "i")))]
5230   "TARGET_64BIT && INTVAL (operands[5]) == exact_log2 (INTVAL (operands[3]))"
5231   [(set (match_dup 4) (ashift:DI (match_dup 2) (match_dup 5)))
5232    (set (match_dup 0) (plus:DI (mult:DI (match_dup 2) (match_dup 3))
5233                                (match_dup 1)))]
5234   "")
5235
5236 (define_expand "ashlsi3"
5237   [(set (match_operand:SI 0 "register_operand" "")
5238         (ashift:SI (match_operand:SI 1 "lhs_lshift_operand" "")
5239                    (match_operand:SI 2 "arith32_operand" "")))]
5240   ""
5241   "
5242 {
5243   if (GET_CODE (operands[2]) != CONST_INT)
5244     {
5245       rtx temp = gen_reg_rtx (SImode);
5246       emit_insn (gen_subsi3 (temp, GEN_INT (31), operands[2]));
5247       if (GET_CODE (operands[1]) == CONST_INT)
5248         emit_insn (gen_zvdep_imm32 (operands[0], operands[1], temp));
5249       else
5250         emit_insn (gen_zvdep32 (operands[0], operands[1], temp));
5251       DONE;
5252     }
5253   /* Make sure both inputs are not constants,
5254      there are no patterns for that.  */
5255   operands[1] = force_reg (SImode, operands[1]);
5256 }")
5257
5258 (define_insn ""
5259   [(set (match_operand:SI 0 "register_operand" "=r")
5260         (ashift:SI (match_operand:SI 1 "register_operand" "r")
5261                    (match_operand:SI 2 "const_int_operand" "n")))]
5262   ""
5263   "{zdep|depw,z} %1,%P2,%L2,%0"
5264   [(set_attr "type" "shift")
5265    (set_attr "length" "4")])
5266
5267 ; Match cases of op1 a CONST_INT here that zvdep_imm32 doesn't handle.
5268 ; Doing it like this makes slightly better code since reload can
5269 ; replace a register with a known value in range -16..15 with a
5270 ; constant.  Ideally, we would like to merge zvdep32 and zvdep_imm32,
5271 ; but since we have no more CONST_OK... characters, that is not
5272 ; possible.
5273 (define_insn "zvdep32"
5274   [(set (match_operand:SI 0 "register_operand" "=r,r")
5275         (ashift:SI (match_operand:SI 1 "arith5_operand" "r,L")
5276                    (minus:SI (const_int 31)
5277                              (match_operand:SI 2 "register_operand" "q,q"))))]
5278   ""
5279   "@
5280    {zvdep %1,32,%0|depw,z %1,%%sar,32,%0}
5281    {zvdepi %1,32,%0|depwi,z %1,%%sar,32,%0}"
5282   [(set_attr "type" "shift,shift")
5283    (set_attr "length" "4,4")])
5284
5285 (define_insn "zvdep_imm32"
5286   [(set (match_operand:SI 0 "register_operand" "=r")
5287         (ashift:SI (match_operand:SI 1 "lhs_lshift_cint_operand" "")
5288                    (minus:SI (const_int 31)
5289                              (match_operand:SI 2 "register_operand" "q"))))]
5290   ""
5291   "*
5292 {
5293   int x = INTVAL (operands[1]);
5294   operands[2] = GEN_INT (4 + exact_log2 ((x >> 4) + 1));
5295   operands[1] = GEN_INT ((x & 0xf) - 0x10);
5296   return \"{zvdepi %1,%2,%0|depwi,z %1,%%sar,%2,%0}\";
5297 }"
5298   [(set_attr "type" "shift")
5299    (set_attr "length" "4")])
5300
5301 (define_insn "vdepi_ior"
5302   [(set (match_operand:SI 0 "register_operand" "=r")
5303         (ior:SI (ashift:SI (match_operand:SI 1 "const_int_operand" "")
5304                            (minus:SI (const_int 31)
5305                                      (match_operand:SI 2 "register_operand" "q")))
5306                 (match_operand:SI 3 "register_operand" "0")))]
5307   ; accept ...0001...1, can this be generalized?
5308   "exact_log2 (INTVAL (operands[1]) + 1) >= 0"
5309   "*
5310 {
5311   int x = INTVAL (operands[1]);
5312   operands[2] = GEN_INT (exact_log2 (x + 1));
5313   return \"{vdepi -1,%2,%0|depwi -1,%%sar,%2,%0}\";
5314 }"
5315   [(set_attr "type" "shift")
5316    (set_attr "length" "4")])
5317
5318 (define_insn "vdepi_and"
5319   [(set (match_operand:SI 0 "register_operand" "=r")
5320         (and:SI (rotate:SI (match_operand:SI 1 "const_int_operand" "")
5321                            (minus:SI (const_int 31)
5322                                      (match_operand:SI 2 "register_operand" "q")))
5323                 (match_operand:SI 3 "register_operand" "0")))]
5324   ; this can be generalized...!
5325   "INTVAL (operands[1]) == -2"
5326   "*
5327 {
5328   int x = INTVAL (operands[1]);
5329   operands[2] = GEN_INT (exact_log2 ((~x) + 1));
5330   return \"{vdepi 0,%2,%0|depwi 0,%%sar,%2,%0}\";
5331 }"
5332   [(set_attr "type" "shift")
5333    (set_attr "length" "4")])
5334
5335 (define_expand "ashldi3"
5336   [(set (match_operand:DI 0 "register_operand" "")
5337         (ashift:DI (match_operand:DI 1 "lhs_lshift_operand" "")
5338                    (match_operand:DI 2 "arith32_operand" "")))]
5339   "TARGET_64BIT"
5340   "
5341 {
5342   if (GET_CODE (operands[2]) != CONST_INT)
5343     {
5344       rtx temp = gen_reg_rtx (DImode);
5345       emit_insn (gen_subdi3 (temp, GEN_INT (63), operands[2]));
5346       if (GET_CODE (operands[1]) == CONST_INT)
5347         emit_insn (gen_zvdep_imm64 (operands[0], operands[1], temp));
5348       else
5349         emit_insn (gen_zvdep64 (operands[0], operands[1], temp));
5350       DONE;
5351     }
5352   /* Make sure both inputs are not constants,
5353      there are no patterns for that.  */
5354   operands[1] = force_reg (DImode, operands[1]);
5355 }")
5356
5357 (define_insn ""
5358   [(set (match_operand:DI 0 "register_operand" "=r")
5359         (ashift:DI (match_operand:DI 1 "register_operand" "r")
5360                    (match_operand:DI 2 "const_int_operand" "n")))]
5361   "TARGET_64BIT"
5362   "depd,z %1,%p2,%Q2,%0"
5363   [(set_attr "type" "shift")
5364    (set_attr "length" "4")])
5365
5366 ; Match cases of op1 a CONST_INT here that zvdep_imm64 doesn't handle.
5367 ; Doing it like this makes slightly better code since reload can
5368 ; replace a register with a known value in range -16..15 with a
5369 ; constant.  Ideally, we would like to merge zvdep64 and zvdep_imm64,
5370 ; but since we have no more CONST_OK... characters, that is not
5371 ; possible.
5372 (define_insn "zvdep64"
5373   [(set (match_operand:DI 0 "register_operand" "=r,r")
5374         (ashift:DI (match_operand:DI 1 "arith5_operand" "r,L")
5375                    (minus:DI (const_int 63)
5376                              (match_operand:DI 2 "register_operand" "q,q"))))]
5377   "TARGET_64BIT"
5378   "@
5379    depd,z %1,%%sar,64,%0
5380    depdi,z %1,%%sar,64,%0"
5381   [(set_attr "type" "shift,shift")
5382    (set_attr "length" "4,4")])
5383
5384 (define_insn "zvdep_imm64"
5385   [(set (match_operand:DI 0 "register_operand" "=r")
5386         (ashift:DI (match_operand:DI 1 "lhs_lshift_cint_operand" "")
5387                    (minus:DI (const_int 63)
5388                              (match_operand:DI 2 "register_operand" "q"))))]
5389   "TARGET_64BIT"
5390   "*
5391 {
5392   int x = INTVAL (operands[1]);
5393   operands[2] = GEN_INT (4 + exact_log2 ((x >> 4) + 1));
5394   operands[1] = GEN_INT ((x & 0x1f) - 0x20);
5395   return \"depdi,z %1,%%sar,%2,%0\";
5396 }"
5397   [(set_attr "type" "shift")
5398    (set_attr "length" "4")])
5399
5400 (define_insn ""
5401   [(set (match_operand:DI 0 "register_operand" "=r")
5402         (ior:DI (ashift:DI (match_operand:DI 1 "const_int_operand" "")
5403                            (minus:DI (const_int 63)
5404                                      (match_operand:DI 2 "register_operand" "q")))
5405                 (match_operand:DI 3 "register_operand" "0")))]
5406   ; accept ...0001...1, can this be generalized?
5407   "TARGET_64BIT && exact_log2 (INTVAL (operands[1]) + 1) >= 0"
5408   "*
5409 {
5410   int x = INTVAL (operands[1]);
5411   operands[2] = GEN_INT (exact_log2 (x + 1));
5412   return \"depdi -1,%%sar,%2,%0\";
5413 }"
5414   [(set_attr "type" "shift")
5415    (set_attr "length" "4")])
5416
5417 (define_insn ""
5418   [(set (match_operand:DI 0 "register_operand" "=r")
5419         (and:DI (rotate:DI (match_operand:DI 1 "const_int_operand" "")
5420                            (minus:DI (const_int 63)
5421                                      (match_operand:DI 2 "register_operand" "q")))
5422                 (match_operand:DI 3 "register_operand" "0")))]
5423   ; this can be generalized...!
5424   "TARGET_64BIT && INTVAL (operands[1]) == -2"
5425   "*
5426 {
5427   int x = INTVAL (operands[1]);
5428   operands[2] = GEN_INT (exact_log2 ((~x) + 1));
5429   return \"depdi 0,%%sar,%2,%0\";
5430 }"
5431   [(set_attr "type" "shift")
5432    (set_attr "length" "4")])
5433
5434 (define_expand "ashrsi3"
5435   [(set (match_operand:SI 0 "register_operand" "")
5436         (ashiftrt:SI (match_operand:SI 1 "register_operand" "")
5437                      (match_operand:SI 2 "arith32_operand" "")))]
5438   ""
5439   "
5440 {
5441   if (GET_CODE (operands[2]) != CONST_INT)
5442     {
5443       rtx temp = gen_reg_rtx (SImode);
5444       emit_insn (gen_subsi3 (temp, GEN_INT (31), operands[2]));
5445       emit_insn (gen_vextrs32 (operands[0], operands[1], temp));
5446       DONE;
5447     }
5448 }")
5449
5450 (define_insn ""
5451   [(set (match_operand:SI 0 "register_operand" "=r")
5452         (ashiftrt:SI (match_operand:SI 1 "register_operand" "r")
5453                      (match_operand:SI 2 "const_int_operand" "n")))]
5454   ""
5455   "{extrs|extrw,s} %1,%P2,%L2,%0"
5456   [(set_attr "type" "shift")
5457    (set_attr "length" "4")])
5458
5459 (define_insn "vextrs32"
5460   [(set (match_operand:SI 0 "register_operand" "=r")
5461         (ashiftrt:SI (match_operand:SI 1 "register_operand" "r")
5462                      (minus:SI (const_int 31)
5463                                (match_operand:SI 2 "register_operand" "q"))))]
5464   ""
5465   "{vextrs %1,32,%0|extrw,s %1,%%sar,32,%0}"
5466   [(set_attr "type" "shift")
5467    (set_attr "length" "4")])
5468
5469 (define_expand "ashrdi3"
5470   [(set (match_operand:DI 0 "register_operand" "")
5471         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
5472                      (match_operand:DI 2 "arith32_operand" "")))]
5473   "TARGET_64BIT"
5474   "
5475 {
5476   if (GET_CODE (operands[2]) != CONST_INT)
5477     {
5478       rtx temp = gen_reg_rtx (DImode);
5479       emit_insn (gen_subdi3 (temp, GEN_INT (63), operands[2]));
5480       emit_insn (gen_vextrs64 (operands[0], operands[1], temp));
5481       DONE;
5482     }
5483 }")
5484
5485 (define_insn ""
5486   [(set (match_operand:DI 0 "register_operand" "=r")
5487         (ashiftrt:DI (match_operand:DI 1 "register_operand" "r")
5488                      (match_operand:DI 2 "const_int_operand" "n")))]
5489   "TARGET_64BIT"
5490   "extrd,s %1,%p2,%Q2,%0"
5491   [(set_attr "type" "shift")
5492    (set_attr "length" "4")])
5493
5494 (define_insn "vextrs64"
5495   [(set (match_operand:DI 0 "register_operand" "=r")
5496         (ashiftrt:DI (match_operand:DI 1 "register_operand" "r")
5497                      (minus:DI (const_int 63)
5498                                (match_operand:DI 2 "register_operand" "q"))))]
5499   "TARGET_64BIT"
5500   "extrd,s %1,%%sar,64,%0"
5501   [(set_attr "type" "shift")
5502    (set_attr "length" "4")])
5503
5504 (define_insn "lshrsi3"
5505   [(set (match_operand:SI 0 "register_operand" "=r,r")
5506         (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
5507                      (match_operand:SI 2 "arith32_operand" "q,n")))]
5508   ""
5509   "@
5510    {vshd %%r0,%1,%0|shrpw %%r0,%1,%%sar,%0}
5511    {extru|extrw,u} %1,%P2,%L2,%0"
5512   [(set_attr "type" "shift")
5513    (set_attr "length" "4")])
5514
5515 (define_insn "lshrdi3"
5516   [(set (match_operand:DI 0 "register_operand" "=r,r")
5517         (lshiftrt:DI (match_operand:DI 1 "register_operand" "r,r")
5518                      (match_operand:DI 2 "arith32_operand" "q,n")))]
5519   "TARGET_64BIT"
5520   "@
5521    shrpd %%r0,%1,%%sar,%0
5522    extrd,u %1,%p2,%Q2,%0"
5523   [(set_attr "type" "shift")
5524    (set_attr "length" "4")])
5525
5526 (define_insn "rotrsi3"
5527   [(set (match_operand:SI 0 "register_operand" "=r,r")
5528         (rotatert:SI (match_operand:SI 1 "register_operand" "r,r")
5529                      (match_operand:SI 2 "arith32_operand" "q,n")))]
5530   ""
5531   "*
5532 {
5533   if (GET_CODE (operands[2]) == CONST_INT)
5534     {
5535       operands[2] = GEN_INT (INTVAL (operands[2]) & 31);
5536       return \"{shd|shrpw} %1,%1,%2,%0\";
5537     }
5538   else
5539     return \"{vshd %1,%1,%0|shrpw %1,%1,%%sar,%0}\";
5540 }"
5541   [(set_attr "type" "shift")
5542    (set_attr "length" "4")])
5543
5544 (define_expand "rotlsi3"
5545   [(set (match_operand:SI 0 "register_operand" "")
5546         (rotate:SI (match_operand:SI 1 "register_operand" "")
5547                    (match_operand:SI 2 "arith32_operand" "")))]
5548   ""
5549   "
5550 {
5551   if (GET_CODE (operands[2]) != CONST_INT)
5552     {
5553       rtx temp = gen_reg_rtx (SImode);
5554       emit_insn (gen_subsi3 (temp, GEN_INT (32), operands[2]));
5555       emit_insn (gen_rotrsi3 (operands[0], operands[1], temp));
5556       DONE;
5557     }
5558   /* Else expand normally.  */
5559 }")
5560
5561 (define_insn ""
5562   [(set (match_operand:SI 0 "register_operand" "=r")
5563         (rotate:SI (match_operand:SI 1 "register_operand" "r")
5564                    (match_operand:SI 2 "const_int_operand" "n")))]
5565   ""
5566   "*
5567 {
5568   operands[2] = GEN_INT ((32 - INTVAL (operands[2])) & 31);
5569   return \"{shd|shrpw} %1,%1,%2,%0\";
5570 }"
5571   [(set_attr "type" "shift")
5572    (set_attr "length" "4")])
5573
5574 (define_insn ""
5575   [(set (match_operand:SI 0 "register_operand" "=r")
5576         (match_operator:SI 5 "plus_xor_ior_operator"
5577           [(ashift:SI (match_operand:SI 1 "register_operand" "r")
5578                       (match_operand:SI 3 "const_int_operand" "n"))
5579            (lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
5580                         (match_operand:SI 4 "const_int_operand" "n"))]))]
5581   "INTVAL (operands[3]) + INTVAL (operands[4]) == 32"
5582   "{shd|shrpw} %1,%2,%4,%0"
5583   [(set_attr "type" "shift")
5584    (set_attr "length" "4")])
5585
5586 (define_insn ""
5587   [(set (match_operand:SI 0 "register_operand" "=r")
5588         (match_operator:SI 5 "plus_xor_ior_operator"
5589           [(lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
5590                         (match_operand:SI 4 "const_int_operand" "n"))
5591            (ashift:SI (match_operand:SI 1 "register_operand" "r")
5592                       (match_operand:SI 3 "const_int_operand" "n"))]))]
5593   "INTVAL (operands[3]) + INTVAL (operands[4]) == 32"
5594   "{shd|shrpw} %1,%2,%4,%0"
5595   [(set_attr "type" "shift")
5596    (set_attr "length" "4")])
5597
5598 (define_insn ""
5599   [(set (match_operand:SI 0 "register_operand" "=r")
5600         (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
5601                            (match_operand:SI 2 "const_int_operand" ""))
5602                 (match_operand:SI 3 "const_int_operand" "")))]
5603   "exact_log2 (1 + (INTVAL (operands[3]) >> (INTVAL (operands[2]) & 31))) >= 0"
5604   "*
5605 {
5606   int cnt = INTVAL (operands[2]) & 31;
5607   operands[3] = GEN_INT (exact_log2 (1 + (INTVAL (operands[3]) >> cnt)));
5608   operands[2] = GEN_INT (31 - cnt);
5609   return \"{zdep|depw,z} %1,%2,%3,%0\";
5610 }"
5611   [(set_attr "type" "shift")
5612    (set_attr "length" "4")])
5613 \f
5614 ;; Unconditional and other jump instructions.
5615
5616 (define_insn "return"
5617   [(return)]
5618   "hppa_can_use_return_insn_p ()"
5619   "*
5620 {
5621   if (TARGET_PA_20)
5622     return \"bve%* (%%r2)\";
5623   return \"bv%* %%r0(%%r2)\";
5624 }"
5625   [(set_attr "type" "branch")
5626    (set_attr "length" "4")])
5627
5628 ;; Use a different pattern for functions which have non-trivial
5629 ;; epilogues so as not to confuse jump and reorg.
5630 (define_insn "return_internal"
5631   [(use (reg:SI 2))
5632    (return)]
5633   ""
5634   "*
5635 {
5636   if (TARGET_PA_20)
5637     return \"bve%* (%%r2)\";
5638   return \"bv%* %%r0(%%r2)\";
5639 }"
5640   [(set_attr "type" "branch")
5641    (set_attr "length" "4")])
5642
5643 (define_expand "prologue"
5644   [(const_int 0)]
5645   ""
5646   "hppa_expand_prologue ();DONE;")
5647
5648 (define_expand "sibcall_epilogue"
5649   [(return)]
5650   ""
5651   "
5652 {
5653   hppa_expand_epilogue ();
5654   DONE;
5655 }")
5656
5657 (define_expand "epilogue"
5658   [(return)]
5659   ""
5660   "
5661 {
5662   /* Try to use the trivial return first.  Else use the full
5663      epilogue.  */
5664   if (hppa_can_use_return_insn_p ())
5665    emit_jump_insn (gen_return ());
5666   else
5667     {
5668       hppa_expand_epilogue ();
5669       emit_jump_insn (gen_return_internal ());
5670     }
5671   DONE;
5672 }")
5673
5674 ;; Special because we use the value placed in %r2 by the bl instruction
5675 ;; from within its delay slot to set the value for the 2nd parameter to
5676 ;; the call.
5677 (define_insn "call_profiler"
5678   [(unspec_volatile [(const_int 0)] 0)
5679    (use (match_operand:SI 0 "const_int_operand" ""))]
5680   ""
5681   "{bl|b,l} _mcount,%%r2\;ldo %0(%%r2),%%r25"
5682   [(set_attr "type" "multi")
5683    (set_attr "length" "8")])
5684
5685 (define_insn "blockage"
5686   [(unspec_volatile [(const_int 2)] 0)]
5687   ""
5688   ""
5689   [(set_attr "length" "0")])
5690
5691 (define_insn "jump"
5692   [(set (pc) (label_ref (match_operand 0 "" "")))]
5693   ""
5694   "*
5695 {
5696   extern int optimize;
5697
5698   if (GET_MODE (insn) == SImode)
5699     return \"b %l0%#\";
5700
5701   /* An unconditional branch which can reach its target.  */
5702   if (get_attr_length (insn) != 24
5703       && get_attr_length (insn) != 16)
5704     return \"b%* %l0\";
5705
5706   /* An unconditional branch which can not reach its target.
5707
5708      We need to be able to use %r1 as a scratch register; however,
5709      we can never be sure whether or not it's got a live value in
5710      it.  Therefore, we must restore its original value after the
5711      jump.
5712
5713      To make matters worse, we don't have a stack slot which we
5714      can always clobber.  sp-12/sp-16 shouldn't ever have a live
5715      value during a non-optimizing compilation, so we use those
5716      slots for now.  We don't support very long branches when
5717      optimizing -- they should be quite rare when optimizing.
5718
5719      Really the way to go long term is a register scavenger; goto
5720      the target of the jump and find a register which we can use
5721      as a scratch to hold the value in %r1.  */
5722
5723   /* We don't know how to register scavenge yet.  */
5724   if (optimize)
5725     abort ();
5726
5727   /* First store %r1 into the stack.  */
5728   output_asm_insn (\"stw %%r1,-16(%%r30)\", operands);
5729
5730   /* Now load the target address into %r1 and do an indirect jump
5731      to the value specified in %r1.  Be careful to generate PIC
5732      code as needed.  */
5733   if (flag_pic)
5734     {
5735       rtx xoperands[2];
5736       xoperands[0] = operands[0];
5737       xoperands[1] = gen_label_rtx ();
5738
5739       output_asm_insn (\"{bl|b,l} .+8,%%r1\\n\\taddil L'%l0-%l1,%%r1\",
5740                        xoperands);
5741       ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\",
5742                                  CODE_LABEL_NUMBER (xoperands[1]));
5743       output_asm_insn (\"ldo R'%l0-%l1(%%r1),%%r1\\n\\tbv %%r0(%%r1)\",
5744                        xoperands);
5745     }
5746   else
5747     output_asm_insn (\"ldil L'%l0,%%r1\\n\\tbe R'%l0(%%sr4,%%r1)\", operands);;
5748
5749   /* And restore the value of %r1 in the delay slot.  We're not optimizing,
5750      so we know nothing else can be in the delay slot.  */
5751   return \"ldw -16(%%r30),%%r1\";
5752 }"
5753   [(set_attr "type" "uncond_branch")
5754    (set_attr "pa_combine_type" "uncond_branch")
5755    (set (attr "length")
5756     (cond [(eq (symbol_ref "jump_in_call_delay (insn)") (const_int 1))
5757            (if_then_else (lt (abs (minus (match_dup 0)
5758                                          (plus (pc) (const_int 8))))
5759                              (const_int 8184))
5760                          (const_int 4)
5761                          (const_int 8))
5762            (ge (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
5763                (const_int 262100))
5764            (if_then_else (eq (symbol_ref "flag_pic") (const_int 0))
5765                          (const_int 16)
5766                          (const_int 24))]
5767           (const_int 4)))])
5768
5769 ;; Subroutines of "casesi".
5770 ;; operand 0 is index
5771 ;; operand 1 is the minimum bound
5772 ;; operand 2 is the maximum bound - minimum bound + 1
5773 ;; operand 3 is CODE_LABEL for the table;
5774 ;; operand 4 is the CODE_LABEL to go to if index out of range.
5775
5776 (define_expand "casesi"
5777   [(match_operand:SI 0 "general_operand" "")
5778    (match_operand:SI 1 "const_int_operand" "")
5779    (match_operand:SI 2 "const_int_operand" "")
5780    (match_operand 3 "" "")
5781    (match_operand 4 "" "")]
5782   ""
5783   "
5784 {
5785   if (GET_CODE (operands[0]) != REG)
5786     operands[0] = force_reg (SImode, operands[0]);
5787
5788   if (operands[1] != const0_rtx)
5789     {
5790       rtx reg = gen_reg_rtx (SImode);
5791
5792       operands[1] = GEN_INT (-INTVAL (operands[1]));
5793       if (!INT_14_BITS (operands[1]))
5794         operands[1] = force_reg (SImode, operands[1]);
5795       emit_insn (gen_addsi3 (reg, operands[0], operands[1]));
5796
5797       operands[0] = reg;
5798     }
5799
5800   /* In 64bit mode we must make sure to wipe the upper bits of the register
5801      just in case the addition overflowed or we had random bits in the
5802      high part of the register.  */
5803   if (TARGET_64BIT)
5804     {
5805       rtx reg = gen_reg_rtx (DImode);
5806       emit_insn (gen_extendsidi2 (reg, operands[0]));
5807       operands[0] = gen_rtx_SUBREG (SImode, reg, 0);
5808     }
5809
5810   if (!INT_5_BITS (operands[2]))
5811     operands[2] = force_reg (SImode, operands[2]);
5812
5813   emit_insn (gen_cmpsi (operands[0], operands[2]));
5814   emit_jump_insn (gen_bgtu (operands[4]));
5815   if (TARGET_BIG_SWITCH)
5816     {
5817       rtx temp = gen_reg_rtx (SImode);
5818       emit_move_insn (temp, gen_rtx_PLUS (SImode, operands[0], operands[0]));
5819       operands[0] = temp;
5820     }
5821   emit_jump_insn (gen_casesi0 (operands[0], operands[3]));
5822   DONE;
5823 }")
5824
5825 (define_insn "casesi0"
5826   [(set (pc) (plus:SI
5827                (mem:SI (plus:SI (pc)
5828                                 (match_operand:SI 0 "register_operand" "r")))
5829                (label_ref (match_operand 1 "" ""))))]
5830   ""
5831   "blr %0,%%r0\;nop"
5832   [(set_attr "type" "multi")
5833    (set_attr "length" "8")])
5834
5835 ;; Need nops for the calls because execution is supposed to continue
5836 ;; past; we don't want to nullify an instruction that we need.
5837 ;;- jump to subroutine
5838
5839 (define_expand "call"
5840   [(parallel [(call (match_operand:SI 0 "" "")
5841                     (match_operand 1 "" ""))
5842               (clobber (reg:SI 2))])]
5843   ""
5844   "
5845 {
5846   rtx op;
5847   rtx call_insn;
5848
5849   if (TARGET_PORTABLE_RUNTIME)
5850     op = force_reg (SImode, XEXP (operands[0], 0));
5851   else
5852     op = XEXP (operands[0], 0);
5853
5854   if (TARGET_64BIT)
5855     emit_move_insn (arg_pointer_rtx,
5856                     gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
5857                                   GEN_INT (64)));
5858
5859   /* Use two different patterns for calls to explicitly named functions
5860      and calls through function pointers.  This is necessary as these two
5861      types of calls use different calling conventions, and CSE might try
5862      to change the named call into an indirect call in some cases (using
5863      two patterns keeps CSE from performing this optimization).  */
5864   if (GET_CODE (op) == SYMBOL_REF)
5865     call_insn = emit_call_insn (gen_call_internal_symref (op, operands[1]));
5866   else if (TARGET_64BIT)
5867     {
5868       rtx tmpreg = force_reg (word_mode, op);
5869       call_insn = emit_call_insn (gen_call_internal_reg_64bit (tmpreg,
5870                                                                operands[1]));
5871     }
5872   else
5873     {
5874       rtx tmpreg = gen_rtx_REG (word_mode, 22);
5875       emit_move_insn (tmpreg, force_reg (word_mode, op));
5876       call_insn = emit_call_insn (gen_call_internal_reg (operands[1]));
5877     }
5878
5879   if (flag_pic)
5880     {
5881       use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
5882       use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn),
5883                gen_rtx_REG (word_mode, PIC_OFFSET_TABLE_REGNUM_SAVED));
5884       if (TARGET_64BIT)
5885         use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), arg_pointer_rtx);
5886
5887       /* After each call we must restore the PIC register, even if it
5888          doesn't appear to be used.
5889
5890          This will set regs_ever_live for the callee saved register we
5891          stored the PIC register in.  */
5892       emit_move_insn (pic_offset_table_rtx,
5893                       gen_rtx_REG (word_mode, PIC_OFFSET_TABLE_REGNUM_SAVED));
5894     }
5895   DONE;
5896 }")
5897
5898 (define_insn "call_internal_symref"
5899   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
5900          (match_operand 1 "" "i"))
5901    (clobber (reg:SI 2))
5902    (use (const_int 0))]
5903   "! TARGET_PORTABLE_RUNTIME"
5904   "*
5905 {
5906   output_arg_descriptor (insn);
5907   return output_call (insn, operands[0], 0);
5908 }"
5909   [(set_attr "type" "call")
5910    (set (attr "length")
5911 ;;       If we're sure that we can either reach the target or that the
5912 ;;       linker can use a long-branch stub, then the length is 4 bytes.
5913 ;;
5914 ;;       For long-calls the length will be either 52 bytes (non-pic)
5915 ;;       or 68 bytes (pic).  */
5916 ;;       Else we have to use a long-call;
5917       (if_then_else (lt (plus (symbol_ref "total_code_bytes") (pc))
5918                         (const_int 240000))
5919                     (const_int 4)
5920                     (if_then_else (eq (symbol_ref "flag_pic")
5921                                       (const_int 0))
5922                                   (const_int 52)
5923                                   (const_int 68))))])
5924
5925 (define_insn "call_internal_reg_64bit"
5926   [(call (mem:SI (match_operand:DI 0 "register_operand" "r"))
5927          (match_operand 1 "" "i"))
5928    (clobber (reg:SI 2))
5929    (use (const_int 1))]
5930   "TARGET_64BIT"
5931   "*
5932 {
5933   rtx xoperands[2];
5934
5935   /* ??? Needs more work.  Length computation, split into multiple insns,
5936      do not use %r22 directly, expose delay slot.  */
5937   return \"ldd 16(%0),%%r2\;ldd 24(%0),%%r27\;bve,l (%%r2),%%r2\;nop\";
5938 }"
5939   [(set_attr "type" "dyncall")
5940    (set (attr "length") (const_int 16))])
5941
5942 (define_insn "call_internal_reg"
5943   [(call (mem:SI (reg:SI 22))
5944          (match_operand 0 "" "i"))
5945    (clobber (reg:SI 2))
5946    (use (const_int 1))]
5947   ""
5948   "*
5949 {
5950   rtx xoperands[2];
5951
5952   /* First the special case for kernels, level 0 systems, etc.  */
5953   if (TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS)
5954     return \"ble 0(%%sr4,%%r22)\;copy %%r31,%%r2\";
5955
5956   /* Now the normal case -- we can reach $$dyncall directly or
5957      we're sure that we can get there via a long-branch stub. 
5958
5959      No need to check target flags as the length uniquely identifies
5960      the remaining cases.  */
5961   if (get_attr_length (insn) == 8)
5962     return \".CALL\\tARGW0=GR\;{bl|b,l} $$dyncall,%%r31\;copy %%r31,%%r2\";
5963
5964   /* Long millicode call, but we are not generating PIC or portable runtime
5965      code.  */
5966   if (get_attr_length (insn) == 12)
5967     return \".CALL\\tARGW0=GR\;ldil L%%$$dyncall,%%r2\;ble R%%$$dyncall(%%sr4,%%r2)\;copy %%r31,%%r2\";
5968
5969   /* Long millicode call for portable runtime.  */
5970   if (get_attr_length (insn) == 20)
5971     return \"ldil L%%$$dyncall,%%r31\;ldo R%%$$dyncall(%%r31),%%r31\;blr %%r0,%%r2\;bv,n %%r0(%%r31)\;nop\";
5972
5973   /* If we're generating PIC code.  */
5974   xoperands[0] = operands[0];
5975   xoperands[1] = gen_label_rtx ();
5976   output_asm_insn (\"{bl|b,l} .+8,%%r1\", xoperands);
5977   output_asm_insn (\"addil L%%$$dyncall-%1,%%r1\", xoperands);
5978   ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\",
5979                              CODE_LABEL_NUMBER (xoperands[1]));
5980   output_asm_insn (\"ldo R%%$$dyncall-%1(%%r1),%%r1\", xoperands);
5981   output_asm_insn (\"blr %%r0,%%r2\", xoperands);
5982   output_asm_insn (\"bv,n %%r0(%%r1)\\n\\tnop\", xoperands);
5983   return \"\";
5984 }"
5985   [(set_attr "type" "dyncall")
5986    (set (attr "length")
5987      (cond [
5988 ;; First NO_SPACE_REGS
5989             (ne (symbol_ref "TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS")
5990                 (const_int 0))
5991             (const_int 8)
5992
5993 ;; Target (or stub) within reach
5994             (and (lt (plus (symbol_ref "total_code_bytes") (pc))
5995                      (const_int 240000))
5996                  (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
5997                      (const_int 0)))
5998             (const_int 8)
5999
6000 ;; Out of reach, but not PIC or PORTABLE_RUNTIME
6001             (and (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
6002                      (const_int 0))
6003                  (eq (symbol_ref "flag_pic")
6004                      (const_int 0)))
6005             (const_int 12)
6006
6007             (ne (symbol_ref "TARGET_PORTABLE_RUNTIME")
6008                 (const_int 0))
6009             (const_int 20)]
6010
6011 ;; Out of range PIC case
6012           (const_int 24)))])
6013
6014 (define_expand "call_value"
6015   [(parallel [(set (match_operand 0 "" "")
6016                    (call (match_operand:SI 1 "" "")
6017                          (match_operand 2 "" "")))
6018               (clobber (reg:SI 2))])]
6019   ""
6020   "
6021 {
6022   rtx op;
6023   rtx call_insn;
6024
6025   if (TARGET_PORTABLE_RUNTIME)
6026     op = force_reg (word_mode, XEXP (operands[1], 0));
6027   else
6028     op = XEXP (operands[1], 0);
6029
6030   if (TARGET_64BIT)
6031     emit_move_insn (arg_pointer_rtx,
6032                     gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
6033                                   GEN_INT (64)));
6034
6035   /* Use two different patterns for calls to explicitly named functions
6036      and calls through function pointers.  This is necessary as these two
6037      types of calls use different calling conventions, and CSE might try
6038      to change the named call into an indirect call in some cases (using
6039      two patterns keeps CSE from performing this optimization).  */
6040   if (GET_CODE (op) == SYMBOL_REF)
6041     call_insn = emit_call_insn (gen_call_value_internal_symref (operands[0],
6042                                                                 op,
6043                                                                 operands[2]));
6044   else if (TARGET_64BIT)
6045     {
6046       rtx tmpreg = force_reg (word_mode, op);
6047       call_insn
6048         = emit_call_insn (gen_call_value_internal_reg_64bit (operands[0],
6049                                                              tmpreg,
6050                                                              operands[2]));
6051     }
6052   else
6053     {
6054       rtx tmpreg = gen_rtx_REG (word_mode, 22);
6055       emit_move_insn (tmpreg, force_reg (word_mode, op));
6056       call_insn = emit_call_insn (gen_call_value_internal_reg (operands[0],
6057                                                                operands[2]));
6058     }
6059   if (flag_pic)
6060     {
6061       use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
6062       use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn),
6063                gen_rtx_REG (word_mode, PIC_OFFSET_TABLE_REGNUM_SAVED));
6064       if (TARGET_64BIT)
6065         use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), arg_pointer_rtx);
6066
6067       /* After each call we must restore the PIC register, even if it
6068          doesn't appear to be used.
6069
6070          This will set regs_ever_live for the callee saved register we
6071          stored the PIC register in.  */
6072       emit_move_insn (pic_offset_table_rtx,
6073                       gen_rtx_REG (word_mode, PIC_OFFSET_TABLE_REGNUM_SAVED));
6074     }
6075   DONE;
6076 }")
6077
6078 (define_insn "call_value_internal_symref"
6079   [(set (match_operand 0 "" "=rf")
6080         (call (mem:SI (match_operand 1 "call_operand_address" ""))
6081               (match_operand 2 "" "i")))
6082    (clobber (reg:SI 2))
6083    (use (const_int 0))]
6084   ;;- Don't use operand 1 for most machines.
6085   "! TARGET_PORTABLE_RUNTIME"
6086   "*
6087 {
6088   output_arg_descriptor (insn);
6089   return output_call (insn, operands[1], 0);
6090 }"
6091   [(set_attr "type" "call")
6092    (set (attr "length")
6093 ;;       If we're sure that we can either reach the target or that the
6094 ;;       linker can use a long-branch stub, then the length is 4 bytes.
6095 ;;
6096 ;;       For long-calls the length will be either 52 bytes (non-pic)
6097 ;;       or 68 bytes (pic).  */
6098 ;;       Else we have to use a long-call;
6099       (if_then_else (lt (plus (symbol_ref "total_code_bytes") (pc))
6100                         (const_int 240000))
6101                     (const_int 4)
6102                     (if_then_else (eq (symbol_ref "flag_pic")
6103                                       (const_int 0))
6104                                   (const_int 52)
6105                                   (const_int 68))))])
6106
6107 (define_insn "call_value_internal_reg_64bit"
6108   [(set (match_operand 0 "" "=rf")
6109          (call (mem:SI (match_operand:DI 1 "register_operand" "r"))
6110                (match_operand 2 "" "i")))
6111    (clobber (reg:SI 2))
6112    (use (const_int 1))]
6113   "TARGET_64BIT"
6114   "*
6115 {
6116   /* ??? Needs more work.  Length computation, split into multiple insns,
6117      do not use %r22 directly, expose delay slot.  */
6118   return \"ldd 16(%1),%%r2\;ldd 24(%1),%%r27\;bve,l (%%r2),%%r2\;nop\";
6119 }"
6120   [(set_attr "type" "dyncall")
6121    (set (attr "length") (const_int 16))])
6122
6123 (define_insn "call_value_internal_reg"
6124   [(set (match_operand 0 "" "=rf")
6125         (call (mem:SI (reg:SI 22))
6126               (match_operand 1 "" "i")))
6127    (clobber (reg:SI 2))
6128    (use (const_int 1))]
6129   ""
6130   "*
6131 {
6132   rtx xoperands[2];
6133
6134   /* First the special case for kernels, level 0 systems, etc.  */
6135   if (TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS)
6136     return \"ble 0(%%sr4,%%r22)\;copy %%r31,%%r2\";
6137
6138   /* Now the normal case -- we can reach $$dyncall directly or
6139      we're sure that we can get there via a long-branch stub. 
6140
6141      No need to check target flags as the length uniquely identifies
6142      the remaining cases.  */
6143   if (get_attr_length (insn) == 8)
6144     return \".CALL\\tARGW0=GR\;{bl|b,l} $$dyncall,%%r31\;copy %%r31,%%r2\";
6145
6146   /* Long millicode call, but we are not generating PIC or portable runtime
6147      code.  */
6148   if (get_attr_length (insn) == 12)
6149     return \".CALL\\tARGW0=GR\;ldil L%%$$dyncall,%%r2\;ble R%%$$dyncall(%%sr4,%%r2)\;copy %%r31,%%r2\";
6150
6151   /* Long millicode call for portable runtime.  */
6152   if (get_attr_length (insn) == 20)
6153     return \"ldil L%%$$dyncall,%%r31\;ldo R%%$$dyncall(%%r31),%%r31\;blr %%r0,%%r2\;bv,n %%r0(%%r31)\;nop\";
6154
6155   /* If we're generating PIC code.  */
6156   xoperands[0] = operands[1];
6157   xoperands[1] = gen_label_rtx ();
6158   output_asm_insn (\"{bl|b,l} .+8,%%r1\", xoperands);
6159   output_asm_insn (\"addil L%%$$dyncall-%1,%%r1\", xoperands);
6160   ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\",
6161                              CODE_LABEL_NUMBER (xoperands[1]));
6162   output_asm_insn (\"ldo R%%$$dyncall-%1(%%r1),%%r1\", xoperands);
6163   output_asm_insn (\"blr %%r0,%%r2\", xoperands);
6164   output_asm_insn (\"bv,n %%r0(%%r1)\\n\\tnop\", xoperands);
6165   return \"\";
6166 }"
6167   [(set_attr "type" "dyncall")
6168    (set (attr "length")
6169      (cond [
6170 ;; First NO_SPACE_REGS
6171             (ne (symbol_ref "TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS")
6172                 (const_int 0))
6173             (const_int 8)
6174
6175 ;; Target (or stub) within reach
6176             (and (lt (plus (symbol_ref "total_code_bytes") (pc))
6177                      (const_int 240000))
6178                  (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
6179                      (const_int 0)))
6180             (const_int 8)
6181
6182 ;; Out of reach, but not PIC or PORTABLE_RUNTIME
6183             (and (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
6184                      (const_int 0))
6185                  (eq (symbol_ref "flag_pic")
6186                      (const_int 0)))
6187             (const_int 12)
6188
6189             (ne (symbol_ref "TARGET_PORTABLE_RUNTIME")
6190                 (const_int 0))
6191             (const_int 20)]
6192
6193 ;; Out of range PIC case
6194           (const_int 24)))])
6195
6196 ;; Call subroutine returning any type.
6197
6198 (define_expand "untyped_call"
6199   [(parallel [(call (match_operand 0 "" "")
6200                     (const_int 0))
6201               (match_operand 1 "" "")
6202               (match_operand 2 "" "")])]
6203   ""
6204   "
6205 {
6206   int i;
6207
6208   emit_call_insn (gen_call (operands[0], const0_rtx));
6209
6210   for (i = 0; i < XVECLEN (operands[2], 0); i++)
6211     {
6212       rtx set = XVECEXP (operands[2], 0, i);
6213       emit_move_insn (SET_DEST (set), SET_SRC (set));
6214     }
6215
6216   /* The optimizer does not know that the call sets the function value
6217      registers we stored in the result block.  We avoid problems by
6218      claiming that all hard registers are used and clobbered at this
6219      point.  */
6220   emit_insn (gen_blockage ());
6221
6222   DONE;
6223 }")
6224
6225 (define_expand "sibcall"
6226   [(parallel [(call (match_operand:SI 0 "" "")
6227                     (match_operand 1 "" ""))
6228               (clobber (reg:SI 0))])]
6229   "! TARGET_PORTABLE_RUNTIME"
6230   "
6231 {
6232   rtx op;
6233   rtx call_insn;
6234
6235   op = XEXP (operands[0], 0);
6236
6237   /* We do not allow indirect sibling calls.  */
6238   call_insn = emit_call_insn (gen_sibcall_internal_symref (op, operands[1]));
6239
6240   if (flag_pic)
6241     {
6242       use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
6243       use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn),
6244                gen_rtx_REG (word_mode, PIC_OFFSET_TABLE_REGNUM_SAVED));
6245
6246       /* After each call we must restore the PIC register, even if it
6247          doesn't appear to be used.
6248
6249          This will set regs_ever_live for the callee saved register we
6250          stored the PIC register in.  */
6251       emit_move_insn (pic_offset_table_rtx,
6252                       gen_rtx_REG (word_mode, PIC_OFFSET_TABLE_REGNUM_SAVED));
6253     }
6254   DONE;
6255 }")
6256
6257 (define_insn "sibcall_internal_symref"
6258   [(call (mem:SI (match_operand 0 "call_operand_address" ""))
6259          (match_operand 1 "" "i"))
6260    (clobber (reg:SI 0))
6261    (use (reg:SI 2))
6262    (use (const_int 0))]
6263   "! TARGET_PORTABLE_RUNTIME"
6264   "*
6265 {
6266   output_arg_descriptor (insn);
6267   return output_call (insn, operands[0], 1);
6268 }"
6269   [(set_attr "type" "call")
6270    (set (attr "length")
6271 ;;       If we're sure that we can either reach the target or that the
6272 ;;       linker can use a long-branch stub, then the length is 4 bytes.
6273 ;;
6274 ;;       For long-calls the length will be either 52 bytes (non-pic)
6275 ;;       or 68 bytes (pic).  */
6276 ;;       Else we have to use a long-call;
6277       (if_then_else (lt (plus (symbol_ref "total_code_bytes") (pc))
6278                         (const_int 240000))
6279                     (const_int 4)
6280                     (if_then_else (eq (symbol_ref "flag_pic")
6281                                       (const_int 0))
6282                                   (const_int 52)
6283                                   (const_int 68))))])
6284
6285 (define_expand "sibcall_value"
6286   [(parallel [(set (match_operand 0 "" "")
6287                    (call (match_operand:SI 1 "" "")
6288                          (match_operand 2 "" "")))
6289               (clobber (reg:SI 0))])]
6290   "! TARGET_PORTABLE_RUNTIME"
6291   "
6292 {
6293   rtx op;
6294   rtx call_insn;
6295
6296   op = XEXP (operands[1], 0);
6297
6298   /* We do not allow indirect sibling calls.  */
6299   call_insn = emit_call_insn (gen_sibcall_value_internal_symref (operands[0],
6300                                                                  op,
6301                                                                  operands[2]));
6302   if (flag_pic)
6303     {
6304       use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
6305       use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn),
6306                gen_rtx_REG (word_mode, PIC_OFFSET_TABLE_REGNUM_SAVED));
6307
6308       /* After each call we must restore the PIC register, even if it
6309          doesn't appear to be used.
6310
6311          This will set regs_ever_live for the callee saved register we
6312          stored the PIC register in.  */
6313       emit_move_insn (pic_offset_table_rtx,
6314                       gen_rtx_REG (word_mode, PIC_OFFSET_TABLE_REGNUM_SAVED));
6315     }
6316   DONE;
6317 }")
6318
6319 (define_insn "sibcall_value_internal_symref"
6320   [(set (match_operand 0 "" "=rf")
6321         (call (mem:SI (match_operand 1 "call_operand_address" ""))
6322               (match_operand 2 "" "i")))
6323    (clobber (reg:SI 0))
6324    (use (reg:SI 2))
6325    (use (const_int 0))]
6326   ;;- Don't use operand 1 for most machines.
6327   "! TARGET_PORTABLE_RUNTIME"
6328   "*
6329 {
6330   output_arg_descriptor (insn);
6331   return output_call (insn, operands[1], 1);
6332 }"
6333   [(set_attr "type" "call")
6334    (set (attr "length")
6335 ;;       If we're sure that we can either reach the target or that the
6336 ;;       linker can use a long-branch stub, then the length is 4 bytes.
6337 ;;
6338 ;;       For long-calls the length will be either 52 bytes (non-pic)
6339 ;;       or 68 bytes (pic).  */
6340 ;;       Else we have to use a long-call;
6341       (if_then_else (lt (plus (symbol_ref "total_code_bytes") (pc))
6342                         (const_int 240000))
6343                     (const_int 4)
6344                     (if_then_else (eq (symbol_ref "flag_pic")
6345                                       (const_int 0))
6346                                   (const_int 52)
6347                                   (const_int 68))))])
6348
6349 (define_insn "nop"
6350   [(const_int 0)]
6351   ""
6352   "nop"
6353   [(set_attr "type" "move")
6354    (set_attr "length" "4")])
6355
6356 ;; These are just placeholders so we know where branch tables
6357 ;; begin and end.
6358 (define_insn "begin_brtab"
6359   [(const_int 1)]
6360   ""
6361   "*
6362 {
6363   /* Only GAS actually supports this pseudo-op.  */
6364   if (TARGET_GAS)
6365     return \".begin_brtab\";
6366   else
6367     return \"\";
6368 }"
6369   [(set_attr "type" "move")
6370    (set_attr "length" "0")])
6371
6372 (define_insn "end_brtab"
6373   [(const_int 2)]
6374   ""
6375   "*
6376 {
6377   /* Only GAS actually supports this pseudo-op.  */
6378   if (TARGET_GAS)
6379     return \".end_brtab\";
6380   else
6381     return \"\";
6382 }"
6383   [(set_attr "type" "move")
6384    (set_attr "length" "0")])
6385
6386 ;;; EH does longjmp's from and within the data section.  Thus,
6387 ;;; an interspace branch is required for the longjmp implementation.
6388 ;;; Registers r1 and r2 are not saved in the jmpbuf environment.
6389 ;;; Thus, they can be used as scratch registers for the jump.
6390 (define_expand "interspace_jump"
6391   [(parallel
6392      [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
6393       (clobber (match_dup 1))])]
6394   ""
6395   "
6396 {
6397   operands[1] = gen_rtx_REG (word_mode, 2);
6398 }")
6399
6400 (define_insn ""
6401   [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
6402   (clobber (reg:SI 2))]
6403   "!TARGET_64BIT"
6404   "ldsid (%%sr0,%0),%%r2\; mtsp %%r2,%%sr0\; be%* 0(%%sr0,%0)"
6405    [(set_attr "type" "branch")
6406     (set_attr "length" "12")])
6407
6408 (define_insn ""
6409   [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
6410   (clobber (reg:DI 2))]
6411   "TARGET_64BIT"
6412   "ldsid (%%sr0,%0),%%r2\; mtsp %%r2,%%sr0\; be%* 0(%%sr0,%0)"
6413    [(set_attr "type" "branch")
6414     (set_attr "length" "12")])
6415
6416 (define_expand "builtin_longjmp"
6417   [(unspec_volatile [(match_operand 0 "register_operand" "r")] 3)]
6418   ""
6419   "
6420 {
6421   /* The elements of the buffer are, in order:  */
6422   rtx fp = gen_rtx_MEM (Pmode, operands[0]);
6423   rtx lab = gen_rtx_MEM (Pmode, plus_constant (operands[0], 4));
6424   rtx stack = gen_rtx_MEM (Pmode, plus_constant (operands[0], 8));
6425   rtx pv = gen_rtx_REG (Pmode, 1);
6426
6427   /* This bit is the same as expand_builtin_longjmp.  */
6428   emit_move_insn (hard_frame_pointer_rtx, fp);
6429   emit_stack_restore (SAVE_NONLOCAL, stack, NULL_RTX);
6430   emit_insn (gen_rtx_USE (VOIDmode, hard_frame_pointer_rtx));
6431   emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
6432
6433   /* Load the label we are jumping through into r1 so that we know
6434      where to look for it when we get back to setjmp's function for
6435      restoring the gp.  */
6436   emit_move_insn (pv, lab);
6437   emit_jump_insn (gen_interspace_jump (pv));
6438   emit_barrier ();
6439   DONE;
6440 }")
6441 ;;; Hope this is only within a function...
6442 (define_insn "indirect_jump"
6443   [(set (pc) (match_operand 0 "register_operand" "r"))]
6444   "GET_MODE (operands[0]) == word_mode"
6445   "bv%* %%r0(%0)"
6446   [(set_attr "type" "branch")
6447    (set_attr "length" "4")])
6448
6449 (define_expand "extzv"
6450   [(set (match_operand 0 "register_operand" "")
6451         (zero_extract (match_operand 1 "register_operand" "")
6452                       (match_operand 2 "uint32_operand" "")
6453                       (match_operand 3 "uint32_operand" "")))]
6454   ""
6455   "
6456 {
6457   if (TARGET_64BIT)
6458     emit_insn (gen_extzv_64 (operands[0], operands[1],
6459                              operands[2], operands[3]));
6460   else
6461     emit_insn (gen_extzv_32 (operands[0], operands[1],
6462                              operands[2], operands[3]));
6463   DONE;
6464 }")
6465
6466 (define_insn "extzv_32"
6467   [(set (match_operand:SI 0 "register_operand" "=r")
6468         (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
6469                          (match_operand:SI 2 "uint5_operand" "")
6470                          (match_operand:SI 3 "uint5_operand" "")))]
6471   ""
6472   "{extru|extrw,u} %1,%3+%2-1,%2,%0"
6473   [(set_attr "type" "shift")
6474    (set_attr "length" "4")])
6475
6476 (define_insn ""
6477   [(set (match_operand:SI 0 "register_operand" "=r")
6478         (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
6479                          (const_int 1)
6480                          (match_operand:SI 3 "register_operand" "q")))]
6481   ""
6482   "{vextru %1,1,%0|extrw,u %1,%%sar,1,%0}"
6483   [(set_attr "type" "shift")
6484    (set_attr "length" "4")])
6485
6486 (define_insn "extzv_64"
6487   [(set (match_operand:DI 0 "register_operand" "=r")
6488         (zero_extract:DI (match_operand:DI 1 "register_operand" "r")
6489                          (match_operand:DI 2 "uint32_operand" "")
6490                          (match_operand:DI 3 "uint32_operand" "")))]
6491   "TARGET_64BIT"
6492   "extrd,u %1,%3+%2-1,%2,%0"
6493   [(set_attr "type" "shift")
6494    (set_attr "length" "4")])
6495
6496 (define_insn ""
6497   [(set (match_operand:DI 0 "register_operand" "=r")
6498         (zero_extract:DI (match_operand:DI 1 "register_operand" "r")
6499                          (const_int 1)
6500                          (match_operand:DI 3 "register_operand" "q")))]
6501   "TARGET_64BIT"
6502   "extrd,u %1,%%sar,1,%0"
6503   [(set_attr "type" "shift")
6504    (set_attr "length" "4")])
6505
6506 (define_expand "extv"
6507   [(set (match_operand 0 "register_operand" "")
6508         (sign_extract (match_operand 1 "register_operand" "")
6509                       (match_operand 2 "uint32_operand" "")
6510                       (match_operand 3 "uint32_operand" "")))]
6511   ""
6512   "
6513 {
6514   if (TARGET_64BIT)
6515     emit_insn (gen_extv_64 (operands[0], operands[1],
6516                             operands[2], operands[3]));
6517   else
6518     emit_insn (gen_extv_32 (operands[0], operands[1],
6519                             operands[2], operands[3]));
6520   DONE;
6521 }")
6522
6523 (define_insn "extv_32"
6524   [(set (match_operand:SI 0 "register_operand" "=r")
6525         (sign_extract:SI (match_operand:SI 1 "register_operand" "r")
6526                          (match_operand:SI 2 "uint5_operand" "")
6527                          (match_operand:SI 3 "uint5_operand" "")))]
6528   ""
6529   "{extrs|extrw,s} %1,%3+%2-1,%2,%0"
6530   [(set_attr "type" "shift")
6531    (set_attr "length" "4")])
6532
6533 (define_insn ""
6534   [(set (match_operand:SI 0 "register_operand" "=r")
6535         (sign_extract:SI (match_operand:SI 1 "register_operand" "r")
6536                          (const_int 1)
6537                          (match_operand:SI 3 "register_operand" "q")))]
6538   "!TARGET_64BIT"
6539   "{vextrs %1,1,%0|extrw,s %1,%%sar,1,%0}"
6540   [(set_attr "type" "shift")
6541    (set_attr "length" "4")])
6542
6543 (define_insn "extv_64"
6544   [(set (match_operand:DI 0 "register_operand" "=r")
6545         (sign_extract:DI (match_operand:DI 1 "register_operand" "r")
6546                          (match_operand:DI 2 "uint32_operand" "")
6547                          (match_operand:DI 3 "uint32_operand" "")))]
6548   "TARGET_64BIT"
6549   "extrd,s %1,%3+%2-1,%2,%0"
6550   [(set_attr "type" "shift")
6551    (set_attr "length" "4")])
6552
6553 (define_insn ""
6554   [(set (match_operand:DI 0 "register_operand" "=r")
6555         (sign_extract:DI (match_operand:DI 1 "register_operand" "r")
6556                          (const_int 1)
6557                          (match_operand:DI 3 "register_operand" "q")))]
6558   "TARGET_64BIT"
6559   "extrd,s %1,%%sar,1,%0"
6560   [(set_attr "type" "shift")
6561    (set_attr "length" "4")])
6562
6563 ;; Only specify the mode operands 0, the rest are assumed to be word_mode.
6564 (define_expand "insv"
6565   [(set (zero_extract (match_operand 0 "register_operand" "")
6566                       (match_operand 1 "uint32_operand" "")
6567                       (match_operand 2 "uint32_operand" ""))
6568         (match_operand 3 "arith5_operand" ""))]
6569   ""
6570   "
6571 {
6572   if (TARGET_64BIT)
6573     emit_insn (gen_insv_64 (operands[0], operands[1],
6574                             operands[2], operands[3]));
6575   else
6576     emit_insn (gen_insv_32 (operands[0], operands[1],
6577                             operands[2], operands[3]));
6578   DONE;
6579 }")
6580
6581 (define_insn "insv_32"
6582   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r,r")
6583                          (match_operand:SI 1 "uint5_operand" "")
6584                          (match_operand:SI 2 "uint5_operand" ""))
6585         (match_operand:SI 3 "arith5_operand" "r,L"))]
6586   ""
6587   "@
6588    {dep|depw} %3,%2+%1-1,%1,%0
6589    {depi|depwi} %3,%2+%1-1,%1,%0"
6590   [(set_attr "type" "shift,shift")
6591    (set_attr "length" "4,4")])
6592
6593 ;; Optimize insertion of const_int values of type 1...1xxxx.
6594 (define_insn ""
6595   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
6596                          (match_operand:SI 1 "uint5_operand" "")
6597                          (match_operand:SI 2 "uint5_operand" ""))
6598         (match_operand:SI 3 "const_int_operand" ""))]
6599   "(INTVAL (operands[3]) & 0x10) != 0 &&
6600    (~INTVAL (operands[3]) & ((1L << INTVAL (operands[1])) - 1) & ~0xf) == 0"
6601   "*
6602 {
6603   operands[3] = GEN_INT ((INTVAL (operands[3]) & 0xf) - 0x10);
6604   return \"{depi|depwi} %3,%2+%1-1,%1,%0\";
6605 }"
6606   [(set_attr "type" "shift")
6607    (set_attr "length" "4")])
6608
6609 (define_insn "insv_64"
6610   [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+r,r")
6611                          (match_operand:DI 1 "uint32_operand" "")
6612                          (match_operand:DI 2 "uint32_operand" ""))
6613         (match_operand:DI 3 "arith32_operand" "r,L"))]
6614   "TARGET_64BIT"
6615   "@
6616    depd %3,%2+%1-1,%1,%0
6617    depdi %3,%2+%1-1,%1,%0"
6618   [(set_attr "type" "shift,shift")
6619    (set_attr "length" "4,4")])
6620
6621 ;; Optimize insertion of const_int values of type 1...1xxxx.
6622 (define_insn ""
6623   [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+r")
6624                          (match_operand:DI 1 "uint32_operand" "")
6625                          (match_operand:DI 2 "uint32_operand" ""))
6626         (match_operand:DI 3 "const_int_operand" ""))]
6627   "(INTVAL (operands[3]) & 0x10) != 0
6628    && TARGET_64BIT
6629    && (~INTVAL (operands[3]) & ((1L << INTVAL (operands[1])) - 1) & ~0xf) == 0"
6630   "*
6631 {
6632   operands[3] = GEN_INT ((INTVAL (operands[3]) & 0xf) - 0x10);
6633   return \"depdi %3,%2+%1-1,%1,%0\";
6634 }"
6635   [(set_attr "type" "shift")
6636    (set_attr "length" "4")])
6637
6638 (define_insn ""
6639   [(set (match_operand:DI 0 "register_operand" "=r")
6640         (ashift:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
6641                    (const_int 32)))]
6642   "TARGET_64BIT"
6643   "depd,z %1,31,32,%0"
6644   [(set_attr "type" "shift")
6645    (set_attr "length" "4")])
6646
6647 ;; This insn is used for some loop tests, typically loops reversed when
6648 ;; strength reduction is used.  It is actually created when the instruction
6649 ;; combination phase combines the special loop test.  Since this insn
6650 ;; is both a jump insn and has an output, it must deal with its own
6651 ;; reloads, hence the `m' constraints.  The `!' constraints direct reload
6652 ;; to not choose the register alternatives in the event a reload is needed.
6653 (define_insn "decrement_and_branch_until_zero"
6654   [(set (pc)
6655         (if_then_else
6656           (match_operator 2 "comparison_operator"
6657            [(plus:SI (match_operand:SI 0 "register_operand" "+!r,!*f,!*m")
6658                      (match_operand:SI 1 "int5_operand" "L,L,L"))
6659             (const_int 0)])
6660           (label_ref (match_operand 3 "" ""))
6661           (pc)))
6662    (set (match_dup 0)
6663         (plus:SI (match_dup 0) (match_dup 1)))
6664    (clobber (match_scratch:SI 4 "=X,r,r"))]
6665   ""
6666   "* return output_dbra (operands, insn, which_alternative); "
6667 ;; Do not expect to understand this the first time through.
6668 [(set_attr "type" "cbranch,multi,multi")
6669  (set (attr "length")
6670       (if_then_else (eq_attr "alternative" "0")
6671 ;; Loop counter in register case
6672 ;; Short branch has length of 4
6673 ;; Long branch has length of 8
6674         (if_then_else (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
6675                       (const_int 8184))
6676            (const_int 4)
6677            (const_int 8))
6678
6679 ;; Loop counter in FP reg case.
6680 ;; Extra goo to deal with additional reload insns.
6681         (if_then_else (eq_attr "alternative" "1")
6682           (if_then_else (lt (match_dup 3) (pc))
6683             (if_then_else
6684               (lt (abs (minus (match_dup 3) (plus (pc) (const_int 24))))
6685                   (const_int 8184))
6686               (const_int 24)
6687               (const_int 28))
6688             (if_then_else
6689               (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
6690                   (const_int 8184))
6691               (const_int 24)
6692               (const_int 28)))
6693 ;; Loop counter in memory case.
6694 ;; Extra goo to deal with additional reload insns.
6695         (if_then_else (lt (match_dup 3) (pc))
6696           (if_then_else
6697             (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
6698                 (const_int 8184))
6699             (const_int 12)
6700             (const_int 16))
6701           (if_then_else
6702             (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
6703                 (const_int 8184))
6704             (const_int 12)
6705             (const_int 16))))))])
6706
6707 (define_insn ""
6708   [(set (pc)
6709         (if_then_else
6710           (match_operator 2 "movb_comparison_operator"
6711            [(match_operand:SI 1 "register_operand" "r,r,r,r") (const_int 0)])
6712           (label_ref (match_operand 3 "" ""))
6713           (pc)))
6714    (set (match_operand:SI 0 "register_operand" "=!r,!*f,!*m,!*q")
6715         (match_dup 1))]
6716   ""
6717 "* return output_movb (operands, insn, which_alternative, 0); "
6718 ;; Do not expect to understand this the first time through.
6719 [(set_attr "type" "cbranch,multi,multi,multi")
6720  (set (attr "length")
6721       (if_then_else (eq_attr "alternative" "0")
6722 ;; Loop counter in register case
6723 ;; Short branch has length of 4
6724 ;; Long branch has length of 8
6725         (if_then_else (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
6726                       (const_int 8184))
6727            (const_int 4)
6728            (const_int 8))
6729
6730 ;; Loop counter in FP reg case.
6731 ;; Extra goo to deal with additional reload insns.
6732         (if_then_else (eq_attr "alternative" "1")
6733           (if_then_else (lt (match_dup 3) (pc))
6734             (if_then_else
6735               (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
6736                   (const_int 8184))
6737               (const_int 12)
6738               (const_int 16))
6739             (if_then_else
6740               (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
6741                   (const_int 8184))
6742               (const_int 12)
6743               (const_int 16)))
6744 ;; Loop counter in memory or sar case.
6745 ;; Extra goo to deal with additional reload insns.
6746         (if_then_else
6747           (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
6748               (const_int 8184))
6749           (const_int 8)
6750           (const_int 12)))))])
6751
6752 ;; Handle negated branch.
6753 (define_insn ""
6754   [(set (pc)
6755         (if_then_else
6756           (match_operator 2 "movb_comparison_operator"
6757            [(match_operand:SI 1 "register_operand" "r,r,r,r") (const_int 0)])
6758           (pc)
6759           (label_ref (match_operand 3 "" ""))))
6760    (set (match_operand:SI 0 "register_operand" "=!r,!*f,!*m,!*q")
6761         (match_dup 1))]
6762   ""
6763 "* return output_movb (operands, insn, which_alternative, 1); "
6764 ;; Do not expect to understand this the first time through.
6765 [(set_attr "type" "cbranch,multi,multi,multi")
6766  (set (attr "length")
6767       (if_then_else (eq_attr "alternative" "0")
6768 ;; Loop counter in register case
6769 ;; Short branch has length of 4
6770 ;; Long branch has length of 8
6771         (if_then_else (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
6772                       (const_int 8184))
6773            (const_int 4)
6774            (const_int 8))
6775
6776 ;; Loop counter in FP reg case.
6777 ;; Extra goo to deal with additional reload insns.
6778         (if_then_else (eq_attr "alternative" "1")
6779           (if_then_else (lt (match_dup 3) (pc))
6780             (if_then_else
6781               (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
6782                   (const_int 8184))
6783               (const_int 12)
6784               (const_int 16))
6785             (if_then_else
6786               (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
6787                   (const_int 8184))
6788               (const_int 12)
6789               (const_int 16)))
6790 ;; Loop counter in memory or SAR case.
6791 ;; Extra goo to deal with additional reload insns.
6792         (if_then_else
6793           (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
6794               (const_int 8184))
6795           (const_int 8)
6796           (const_int 12)))))])
6797
6798 (define_insn ""
6799   [(set (pc) (label_ref (match_operand 3 "" "" )))
6800    (set (match_operand:SI 0 "ireg_operand" "=r")
6801         (plus:SI (match_operand:SI 1 "ireg_operand" "r")
6802                  (match_operand:SI 2 "ireg_or_int5_operand" "rL")))]
6803   "(reload_completed && operands[0] == operands[1]) || operands[0] == operands[2]"
6804   "*
6805 {
6806   return output_parallel_addb (operands, get_attr_length (insn));
6807 }"
6808   [(set_attr "type" "parallel_branch")
6809    (set (attr "length")
6810     (if_then_else (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
6811                       (const_int 8184))
6812            (const_int 4)
6813            (const_int 8)))])
6814
6815 (define_insn ""
6816   [(set (pc) (label_ref (match_operand 2 "" "" )))
6817    (set (match_operand:SF 0 "ireg_operand" "=r")
6818         (match_operand:SF 1 "ireg_or_int5_operand" "rL"))]
6819   "reload_completed"
6820   "*
6821 {
6822   return output_parallel_movb (operands, get_attr_length (insn));
6823 }"
6824   [(set_attr "type" "parallel_branch")
6825    (set (attr "length")
6826     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
6827                       (const_int 8184))
6828            (const_int 4)
6829            (const_int 8)))])
6830
6831 (define_insn ""
6832   [(set (pc) (label_ref (match_operand 2 "" "" )))
6833    (set (match_operand:SI 0 "ireg_operand" "=r")
6834         (match_operand:SI 1 "ireg_or_int5_operand" "rL"))]
6835   "reload_completed"
6836   "*
6837 {
6838   return output_parallel_movb (operands, get_attr_length (insn));
6839 }"
6840   [(set_attr "type" "parallel_branch")
6841    (set (attr "length")
6842     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
6843                       (const_int 8184))
6844            (const_int 4)
6845            (const_int 8)))])
6846
6847 (define_insn ""
6848   [(set (pc) (label_ref (match_operand 2 "" "" )))
6849    (set (match_operand:HI 0 "ireg_operand" "=r")
6850         (match_operand:HI 1 "ireg_or_int5_operand" "rL"))]
6851   "reload_completed"
6852   "*
6853 {
6854   return output_parallel_movb (operands, get_attr_length (insn));
6855 }"
6856   [(set_attr "type" "parallel_branch")
6857    (set (attr "length")
6858     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
6859                       (const_int 8184))
6860            (const_int 4)
6861            (const_int 8)))])
6862
6863 (define_insn ""
6864   [(set (pc) (label_ref (match_operand 2 "" "" )))
6865    (set (match_operand:QI 0 "ireg_operand" "=r")
6866         (match_operand:QI 1 "ireg_or_int5_operand" "rL"))]
6867   "reload_completed"
6868   "*
6869 {
6870   return output_parallel_movb (operands, get_attr_length (insn));
6871 }"
6872   [(set_attr "type" "parallel_branch")
6873    (set (attr "length")
6874     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
6875                       (const_int 8184))
6876            (const_int 4)
6877            (const_int 8)))])
6878
6879 (define_insn ""
6880   [(set (match_operand 0 "register_operand" "=f")
6881         (mult (match_operand 1 "register_operand" "f")
6882               (match_operand 2 "register_operand" "f")))
6883    (set (match_operand 3 "register_operand" "+f")
6884         (plus (match_operand 4 "register_operand" "f")
6885               (match_operand 5 "register_operand" "f")))]
6886   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
6887    && reload_completed && fmpyaddoperands (operands)"
6888   "*
6889 {
6890   if (GET_MODE (operands[0]) == DFmode)
6891     {
6892       if (rtx_equal_p (operands[3], operands[5]))
6893         return \"fmpyadd,dbl %1,%2,%0,%4,%3\";
6894       else
6895         return \"fmpyadd,dbl %1,%2,%0,%5,%3\";
6896     }
6897   else
6898     {
6899       if (rtx_equal_p (operands[3], operands[5]))
6900         return \"fmpyadd,sgl %1,%2,%0,%4,%3\";
6901       else
6902         return \"fmpyadd,sgl %1,%2,%0,%5,%3\";
6903     }
6904 }"
6905   [(set_attr "type" "fpalu")
6906    (set_attr "length" "4")])
6907
6908 (define_insn ""
6909   [(set (match_operand 3 "register_operand" "+f")
6910         (plus (match_operand 4 "register_operand" "f")
6911               (match_operand 5 "register_operand" "f")))
6912    (set (match_operand 0 "register_operand" "=f")
6913         (mult (match_operand 1 "register_operand" "f")
6914               (match_operand 2 "register_operand" "f")))]
6915   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
6916    && reload_completed && fmpyaddoperands (operands)"
6917   "*
6918 {
6919   if (GET_MODE (operands[0]) == DFmode)
6920     {
6921       if (rtx_equal_p (operands[3], operands[5]))
6922         return \"fmpyadd,dbl %1,%2,%0,%4,%3\";
6923       else
6924         return \"fmpyadd,dbl %1,%2,%0,%5,%3\";
6925     }
6926   else
6927     {
6928       if (rtx_equal_p (operands[3], operands[5]))
6929         return \"fmpyadd,sgl %1,%2,%0,%4,%3\";
6930       else
6931         return \"fmpyadd,sgl %1,%2,%0,%5,%3\";
6932     }
6933 }"
6934   [(set_attr "type" "fpalu")
6935    (set_attr "length" "4")])
6936
6937 (define_insn ""
6938   [(set (match_operand 0 "register_operand" "=f")
6939         (mult (match_operand 1 "register_operand" "f")
6940               (match_operand 2 "register_operand" "f")))
6941    (set (match_operand 3 "register_operand" "+f")
6942         (minus (match_operand 4 "register_operand" "f")
6943                (match_operand 5 "register_operand" "f")))]
6944   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
6945    && reload_completed && fmpysuboperands (operands)"
6946   "*
6947 {
6948   if (GET_MODE (operands[0]) == DFmode)
6949     return \"fmpysub,dbl %1,%2,%0,%5,%3\";
6950   else
6951     return \"fmpysub,sgl %1,%2,%0,%5,%3\";
6952 }"
6953   [(set_attr "type" "fpalu")
6954    (set_attr "length" "4")])
6955
6956 (define_insn ""
6957   [(set (match_operand 3 "register_operand" "+f")
6958         (minus (match_operand 4 "register_operand" "f")
6959                (match_operand 5 "register_operand" "f")))
6960    (set (match_operand 0 "register_operand" "=f")
6961         (mult (match_operand 1 "register_operand" "f")
6962               (match_operand 2 "register_operand" "f")))]
6963   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
6964    && reload_completed && fmpysuboperands (operands)"
6965   "*
6966 {
6967   if (GET_MODE (operands[0]) == DFmode)
6968     return \"fmpysub,dbl %1,%2,%0,%5,%3\";
6969   else
6970     return \"fmpysub,sgl %1,%2,%0,%5,%3\";
6971 }"
6972   [(set_attr "type" "fpalu")
6973    (set_attr "length" "4")])
6974
6975 ;; Clean up turds left by reload.
6976 (define_peephole
6977   [(set (match_operand 0 "reg_or_nonsymb_mem_operand" "")
6978         (match_operand 1 "register_operand" "fr"))
6979    (set (match_operand 2 "register_operand" "fr")
6980         (match_dup 0))]
6981   "! TARGET_SOFT_FLOAT
6982    && GET_CODE (operands[0]) == MEM
6983    && ! MEM_VOLATILE_P (operands[0])
6984    && GET_MODE (operands[0]) == GET_MODE (operands[1])
6985    && GET_MODE (operands[0]) == GET_MODE (operands[2])
6986    && GET_MODE (operands[0]) == DFmode
6987    && GET_CODE (operands[1]) == REG
6988    && GET_CODE (operands[2]) == REG
6989    && ! side_effects_p (XEXP (operands[0], 0))
6990    && REGNO_REG_CLASS (REGNO (operands[1]))
6991       == REGNO_REG_CLASS (REGNO (operands[2]))"
6992   "*
6993 {
6994   rtx xoperands[2];
6995
6996   if (FP_REG_P (operands[1]))
6997     output_asm_insn (output_fp_move_double (operands), operands);
6998   else
6999     output_asm_insn (output_move_double (operands), operands);
7000
7001   if (rtx_equal_p (operands[1], operands[2]))
7002     return \"\";
7003
7004   xoperands[0] = operands[2];
7005   xoperands[1] = operands[1];
7006       
7007   if (FP_REG_P (xoperands[1]))
7008     output_asm_insn (output_fp_move_double (xoperands), xoperands);
7009   else
7010     output_asm_insn (output_move_double (xoperands), xoperands);
7011
7012   return \"\";
7013 }")
7014
7015 (define_peephole
7016   [(set (match_operand 0 "register_operand" "fr")
7017         (match_operand 1 "reg_or_nonsymb_mem_operand" ""))
7018    (set (match_operand 2 "register_operand" "fr")
7019         (match_dup 1))]
7020   "! TARGET_SOFT_FLOAT
7021    && GET_CODE (operands[1]) == MEM
7022    && ! MEM_VOLATILE_P (operands[1])
7023    && GET_MODE (operands[0]) == GET_MODE (operands[1])
7024    && GET_MODE (operands[0]) == GET_MODE (operands[2])
7025    && GET_MODE (operands[0]) == DFmode
7026    && GET_CODE (operands[0]) == REG
7027    && GET_CODE (operands[2]) == REG
7028    && ! side_effects_p (XEXP (operands[1], 0))
7029    && REGNO_REG_CLASS (REGNO (operands[0]))
7030       == REGNO_REG_CLASS (REGNO (operands[2]))"
7031   "*
7032 {
7033   rtx xoperands[2];
7034
7035   if (FP_REG_P (operands[0]))
7036     output_asm_insn (output_fp_move_double (operands), operands);
7037   else
7038     output_asm_insn (output_move_double (operands), operands);
7039
7040   xoperands[0] = operands[2];
7041   xoperands[1] = operands[0];
7042       
7043   if (FP_REG_P (xoperands[1]))
7044     output_asm_insn (output_fp_move_double (xoperands), xoperands);
7045   else
7046     output_asm_insn (output_move_double (xoperands), xoperands);
7047
7048   return \"\";
7049 }")
7050
7051 ;; Flush the I and D cache line found at the address in operand 0.
7052 ;; This is used by the trampoline code for nested functions.
7053 ;; So long as the trampoline itself is less than 32 bytes this
7054 ;; is sufficient.
7055
7056 (define_insn "dcacheflush"
7057   [(unspec_volatile [(const_int 1)] 0)
7058    (use (mem:SI (match_operand 0 "pmode_register_operand" "r")))
7059    (use (mem:SI (match_operand 1 "pmode_register_operand" "r")))]
7060   ""
7061   "fdc 0(%0)\;fdc 0(%1)\;sync"
7062   [(set_attr "type" "multi")
7063    (set_attr "length" "12")])
7064
7065 (define_insn "icacheflush"
7066   [(unspec_volatile [(const_int 2)] 0)
7067    (use (mem:SI (match_operand 0 "pmode_register_operand" "r")))
7068    (use (mem:SI (match_operand 1 "pmode_register_operand" "r")))
7069    (use (match_operand 2 "pmode_register_operand" "r"))
7070    (clobber (match_operand 3 "pmode_register_operand" "=&r"))
7071    (clobber (match_operand 4 "pmode_register_operand" "=&r"))]
7072   ""
7073   "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"
7074   [(set_attr "type" "multi")
7075    (set_attr "length" "52")])
7076
7077 ;; An out-of-line prologue.
7078 (define_insn "outline_prologue_call"
7079   [(unspec_volatile [(const_int 0)] 0)
7080    (clobber (reg:SI 31))
7081    (clobber (reg:SI 22))
7082    (clobber (reg:SI 21))
7083    (clobber (reg:SI 20))
7084    (clobber (reg:SI 19))
7085    (clobber (reg:SI 1))]
7086   ""
7087   "*
7088 {
7089   extern int frame_pointer_needed;
7090
7091   /* We need two different versions depending on whether or not we
7092      need a frame pointer.   Also note that we return to the instruction
7093      immediately after the branch rather than two instructions after the
7094      break as normally is the case.  */
7095   if (frame_pointer_needed)
7096     {
7097       /* Must import the magic millicode routine(s).  */
7098       output_asm_insn (\".IMPORT __outline_prologue_fp,MILLICODE\", NULL);
7099
7100       if (TARGET_PORTABLE_RUNTIME)
7101         {
7102           output_asm_insn (\"ldil L'__outline_prologue_fp,%%r31\", NULL);
7103           output_asm_insn (\"ble,n R'__outline_prologue_fp(%%sr0,%%r31)\",
7104                            NULL);
7105         }
7106       else
7107         output_asm_insn (\"{bl|b,l},n __outline_prologue_fp,%%r31\", NULL);
7108     }
7109   else
7110     {
7111       /* Must import the magic millicode routine(s).  */
7112       output_asm_insn (\".IMPORT __outline_prologue,MILLICODE\", NULL);
7113
7114       if (TARGET_PORTABLE_RUNTIME)
7115         {
7116           output_asm_insn (\"ldil L'__outline_prologue,%%r31\", NULL);
7117           output_asm_insn (\"ble,n R'__outline_prologue(%%sr0,%%r31)\", NULL);
7118         }
7119       else
7120         output_asm_insn (\"{bl|b,l},n __outline_prologue,%%r31\", NULL);
7121     }
7122   return \"\";
7123 }"
7124   [(set_attr "type" "multi")
7125    (set_attr "length" "8")])
7126
7127 ;; An out-of-line epilogue.
7128 (define_insn "outline_epilogue_call"
7129   [(unspec_volatile [(const_int 1)] 0)
7130    (use (reg:SI 29))
7131    (use (reg:SI 28))
7132    (clobber (reg:SI 31))
7133    (clobber (reg:SI 22))
7134    (clobber (reg:SI 21))
7135    (clobber (reg:SI 20))
7136    (clobber (reg:SI 19))
7137    (clobber (reg:SI 2))
7138    (clobber (reg:SI 1))]
7139   ""
7140   "*
7141 {
7142   extern int frame_pointer_needed;
7143
7144   /* We need two different versions depending on whether or not we
7145      need a frame pointer.   Also note that we return to the instruction
7146      immediately after the branch rather than two instructions after the
7147      break as normally is the case.  */
7148   if (frame_pointer_needed)
7149     {
7150       /* Must import the magic millicode routine.  */
7151       output_asm_insn (\".IMPORT __outline_epilogue_fp,MILLICODE\", NULL);
7152
7153       /* The out-of-line prologue will make sure we return to the right
7154          instruction.  */
7155       if (TARGET_PORTABLE_RUNTIME)
7156         {
7157           output_asm_insn (\"ldil L'__outline_epilogue_fp,%%r31\", NULL);
7158           output_asm_insn (\"ble,n R'__outline_epilogue_fp(%%sr0,%%r31)\",
7159                            NULL);
7160         }
7161       else
7162         output_asm_insn (\"{bl|b,l},n __outline_epilogue_fp,%%r31\", NULL);
7163     }
7164   else
7165     {
7166       /* Must import the magic millicode routine.  */
7167       output_asm_insn (\".IMPORT __outline_epilogue,MILLICODE\", NULL);
7168
7169       /* The out-of-line prologue will make sure we return to the right
7170          instruction.  */
7171       if (TARGET_PORTABLE_RUNTIME)
7172         {
7173           output_asm_insn (\"ldil L'__outline_epilogue,%%r31\", NULL);
7174           output_asm_insn (\"ble,n R'__outline_epilogue(%%sr0,%%r31)\", NULL);
7175         }
7176       else
7177         output_asm_insn (\"{bl|b,l},n __outline_epilogue,%%r31\", NULL);
7178     }
7179   return \"\";
7180 }"
7181   [(set_attr "type" "multi")
7182    (set_attr "length" "8")])
7183
7184 ;; Given a function pointer, canonicalize it so it can be 
7185 ;; reliably compared to another function pointer.  */
7186 (define_expand "canonicalize_funcptr_for_compare"
7187   [(set (reg:SI 26) (match_operand:SI 1 "register_operand" ""))
7188    (parallel [(set (reg:SI 29) (unspec:SI [(reg:SI 26)] 0))
7189               (clobber (match_dup 2))
7190               (clobber (reg:SI 26))
7191               (clobber (reg:SI 22))
7192               (clobber (reg:SI 31))])
7193    (set (match_operand:SI 0 "register_operand" "")
7194         (reg:SI 29))]
7195   "! TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7196   "
7197 {
7198   operands[2] = gen_reg_rtx (SImode);
7199   if (GET_CODE (operands[1]) != REG)
7200     {
7201       rtx tmp = gen_reg_rtx (Pmode);
7202       emit_move_insn (tmp, operands[1]);
7203       operands[1] = tmp;
7204     }
7205 }")
7206
7207 (define_insn ""
7208   [(set (reg:SI 29) (unspec:SI [(reg:SI 26)] 0))
7209    (clobber (match_operand:SI 0 "register_operand" "=a"))
7210    (clobber (reg:SI 26))
7211    (clobber (reg:SI 22))
7212    (clobber (reg:SI 31))]
7213   "!TARGET_64BIT"
7214   "*
7215 {
7216   /* Must import the magic millicode routine.  */
7217   output_asm_insn (\".IMPORT $$sh_func_adrs,MILLICODE\", NULL);
7218
7219   /* This is absolutely amazing.
7220
7221      First, copy our input parameter into %r29 just in case we don't
7222      need to call $$sh_func_adrs.  */
7223   output_asm_insn (\"copy %%r26,%%r29\", NULL);
7224
7225   /* Next, examine the low two bits in %r26, if they aren't 0x2, then
7226      we use %r26 unchanged.  */
7227   if (get_attr_length (insn) == 32)
7228     output_asm_insn (\"{extru|extrw,u} %%r26,31,2,%%r31\;{comib|cmpib},<>,n 2,%%r31,.+24\", NULL);
7229   else if (get_attr_length (insn) == 40)
7230     output_asm_insn (\"{extru|extrw,u} %%r26,31,2,%%r31\;{comib|cmpib},<>,n 2,%%r31,.+32\", NULL);
7231   else if (get_attr_length (insn) == 44)
7232     output_asm_insn (\"{extru|extrw,u} %%r26,31,2,%%r31\;{comib|cmpib},<>,n 2,%%r31,.+36\", NULL);
7233   else
7234     output_asm_insn (\"{extru|extrw,u} %%r26,31,2,%%r31\;{comib|cmpib},<>,n 2,%%r31,.+20\", NULL);
7235
7236   /* Next, compare %r26 with 4096, if %r26 is less than or equal to
7237      4096, then we use %r26 unchanged.  */
7238   if (get_attr_length (insn) == 32)
7239     output_asm_insn (\"ldi 4096,%%r31\;{comb|cmpb},<<,n %%r26,%%r31,.+16\",
7240                      NULL);
7241   else if (get_attr_length (insn) == 40)
7242     output_asm_insn (\"ldi 4096,%%r31\;{comb|cmpb},<<,n %%r26,%%r31,.+24\",
7243                      NULL);
7244   else if (get_attr_length (insn) == 44)
7245     output_asm_insn (\"ldi 4096,%%r31\;{comb|cmpb},<<,n %%r26,%%r31,.+28\",
7246                      NULL);
7247   else
7248     output_asm_insn (\"ldi 4096,%%r31\;{comb|cmpb},<<,n %%r26,%%r31,.+12\",
7249                      NULL);
7250
7251   /* Else call $$sh_func_adrs to extract the function's real add24.  */
7252   return output_millicode_call (insn,
7253                                 gen_rtx_SYMBOL_REF (SImode,
7254                                          \"$$sh_func_adrs\"));
7255 }"
7256   [(set_attr "type" "multi")
7257    (set (attr "length")
7258      (cond [
7259 ;; Target (or stub) within reach
7260             (and (lt (plus (symbol_ref "total_code_bytes") (pc))
7261                      (const_int 240000))
7262                  (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
7263                      (const_int 0)))
7264             (const_int 28)
7265
7266 ;; NO_SPACE_REGS
7267             (ne (symbol_ref "TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS")
7268                 (const_int 0))
7269             (const_int 32)
7270
7271 ;; Out of reach, but not PIC or PORTABLE_RUNTIME
7272 ;; same as NO_SPACE_REGS code
7273             (and (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
7274                      (const_int 0))
7275                  (eq (symbol_ref "flag_pic")
7276                      (const_int 0)))
7277             (const_int 32)
7278
7279 ;; PORTABLE_RUNTIME
7280             (ne (symbol_ref "TARGET_PORTABLE_RUNTIME")
7281                 (const_int 0))
7282             (const_int 40)]
7283
7284 ;; Out of range and PIC 
7285           (const_int 44)))])
7286
7287 ;; On the PA, the PIC register is call clobbered, so it must
7288 ;; be saved & restored around calls by the caller.  If the call
7289 ;; doesn't return normally (nonlocal goto, or an exception is
7290 ;; thrown), then the code at the exception handler label must
7291 ;; restore the PIC register.
7292 (define_expand "exception_receiver"
7293   [(const_int 4)]
7294   "!TARGET_PORTABLE_RUNTIME && flag_pic"
7295   "
7296 {
7297   /* Load the PIC register from the stack slot (in our caller's
7298      frame).  */
7299   emit_move_insn (pic_offset_table_rtx,
7300                   gen_rtx_MEM (SImode,
7301                                plus_constant (stack_pointer_rtx, -32)));
7302   emit_insn (gen_rtx (USE, VOIDmode, pic_offset_table_rtx));
7303   emit_insn (gen_blockage ());
7304   DONE;
7305 }")