OSDN Git Service

* pa.md (reload_indi, reload_outdi): Allow any register for the
[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, 93-98, 1999 Free Software Foundation, Inc.
3 ;;   Contributed by the Center for Software Science at the University
4 ;;   of Utah.
5
6 ;; This file is part of GNU CC.
7
8 ;; GNU CC is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 2, or (at your option)
11 ;; any later version.
12
13 ;; GNU CC is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 ;; GNU General Public License for more details.
17
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GNU CC; see the file COPYING.  If not, write to
20 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
21 ;; Boston, MA 02111-1307, USA.
22
23 ;; This gcc Version 2 machine description is inspired by sparc.md and
24 ;; mips.md.
25
26 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
27
28 ;; Insn type.  Used to default other attribute values.
29
30 ;; type "unary" insns have one input operand (1) and one output operand (0)
31 ;; type "binary" insns have two input operands (1,2) and one output (0)
32
33 (define_attr "type"
34   "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"
35   (const_string "binary"))
36
37 (define_attr "pa_combine_type"
38   "fmpy,faddsub,uncond_branch,addmove,none"
39   (const_string "none"))
40
41 ;; Processor type (for scheduling, not code generation) -- this attribute
42 ;; must exactly match the processor_type enumeration in pa.h.
43 ;;
44 ;; FIXME: Add 800 scheduling for completeness?
45
46 (define_attr "cpu" "700,7100,7100LC,7200,8000" (const (symbol_ref "pa_cpu_attr")))
47
48 ;; Length (in # of bytes).
49 (define_attr "length" ""
50   (cond [(eq_attr "type" "load,fpload")
51          (if_then_else (match_operand 1 "symbolic_memory_operand" "")
52                        (const_int 8) (const_int 4))
53
54          (eq_attr "type" "store,fpstore")
55          (if_then_else (match_operand 0 "symbolic_memory_operand" "")
56                        (const_int 8) (const_int 4))
57
58          (eq_attr "type" "binary,shift,nullshift")
59          (if_then_else (match_operand 2 "arith_operand" "")
60                        (const_int 4) (const_int 12))
61
62          (eq_attr "type" "move,unary,shift,nullshift")
63          (if_then_else (match_operand 1 "arith_operand" "")
64                        (const_int 4) (const_int 8))]
65
66         (const_int 4)))
67
68 (define_asm_attributes
69   [(set_attr "length" "4")
70    (set_attr "type" "multi")])
71
72 ;; Attributes for instruction and branch scheduling
73
74 ;; For conditional branches.
75 (define_attr "in_branch_delay" "false,true"
76   (if_then_else (and (eq_attr "type" "!uncond_branch,branch,cbranch,fbranch,call,dyncall,multi,milli,parallel_branch")
77                      (eq_attr "length" "4"))
78                 (const_string "true")
79                 (const_string "false")))
80
81 ;; Disallow instructions which use the FPU since they will tie up the FPU
82 ;; even if the instruction is nullified.
83 (define_attr "in_nullified_branch_delay" "false,true"
84   (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")
85                      (eq_attr "length" "4"))
86                 (const_string "true")
87                 (const_string "false")))
88
89 ;; For calls and millicode calls.  Allow unconditional branches in the
90 ;; delay slot.
91 (define_attr "in_call_delay" "false,true"
92   (cond [(and (eq_attr "type" "!uncond_branch,branch,cbranch,fbranch,call,dyncall,multi,milli,parallel_branch")
93               (eq_attr "length" "4"))
94            (const_string "true")
95          (eq_attr "type" "uncond_branch")
96            (if_then_else (ne (symbol_ref "TARGET_JUMP_IN_DELAY")
97                              (const_int 0))
98                          (const_string "true")
99                          (const_string "false"))]
100         (const_string "false")))
101
102
103 ;; Call delay slot description.
104 (define_delay (eq_attr "type" "call")
105   [(eq_attr "in_call_delay" "true") (nil) (nil)])
106
107 ;; millicode call delay slot description.  Note it disallows delay slot
108 ;; when TARGET_PORTABLE_RUNTIME is true.
109 (define_delay (eq_attr "type" "milli")
110   [(and (eq_attr "in_call_delay" "true")
111         (eq (symbol_ref "TARGET_PORTABLE_RUNTIME") (const_int 0)))
112    (nil) (nil)])
113
114 ;; Return and other similar instructions.
115 (define_delay (eq_attr "type" "branch,parallel_branch")
116   [(eq_attr "in_branch_delay" "true") (nil) (nil)])
117
118 ;; Floating point conditional branch delay slot description and
119 (define_delay (eq_attr "type" "fbranch")
120   [(eq_attr "in_branch_delay" "true")
121    (eq_attr "in_nullified_branch_delay" "true")
122    (nil)])
123
124 ;; Integer conditional branch delay slot description.
125 ;; Nullification of conditional branches on the PA is dependent on the
126 ;; direction of the branch.  Forward branches nullify true and
127 ;; backward branches nullify false.  If the direction is unknown
128 ;; then nullification is not allowed.
129 (define_delay (eq_attr "type" "cbranch")
130   [(eq_attr "in_branch_delay" "true")
131    (and (eq_attr "in_nullified_branch_delay" "true")
132         (attr_flag "forward"))
133    (and (eq_attr "in_nullified_branch_delay" "true")
134         (attr_flag "backward"))])
135
136 (define_delay (and (eq_attr "type" "uncond_branch")
137                    (eq (symbol_ref "following_call (insn)")
138                        (const_int 0)))
139   [(eq_attr "in_branch_delay" "true") (nil) (nil)])
140
141 ;; Function units of the HPPA. The following data is for the 700 CPUs
142 ;; (Mustang CPU + Timex FPU aka PA-89) because that's what I have the docs for.
143 ;; Scheduling instructions for PA-83 machines according to the Snake
144 ;; constraints shouldn't hurt.
145
146 ;; (define_function_unit {name} {num-units} {n-users} {test}
147 ;;                       {ready-delay} {issue-delay} [{conflict-list}])
148
149 ;; The integer ALU.
150 ;; (Noted only for documentation; units that take one cycle do not need to
151 ;; be specified.)
152
153 ;; (define_function_unit "alu" 1 0
154 ;;  (and (eq_attr "type" "unary,shift,nullshift,binary,move,address")
155 ;;       (eq_attr "cpu" "700"))
156 ;;  1 0)
157
158
159 ;; Memory. Disregarding Cache misses, the Mustang memory times are:
160 ;; load: 2, fpload: 3
161 ;; store, fpstore: 3, no D-cache operations should be scheduled.
162
163 (define_function_unit "pa700memory" 1 0
164   (and (eq_attr "type" "load,fpload")
165        (eq_attr "cpu" "700")) 2 0)
166 (define_function_unit "pa700memory" 1 0 
167   (and (eq_attr "type" "store,fpstore")
168        (eq_attr "cpu" "700")) 3 3)
169
170 ;; The Timex (aka 700) has two floating-point units: ALU, and MUL/DIV/SQRT.
171 ;; Timings:
172 ;; Instruction  Time    Unit    Minimum Distance (unit contention)
173 ;; fcpy         3       ALU     2
174 ;; fabs         3       ALU     2
175 ;; fadd         3       ALU     2
176 ;; fsub         3       ALU     2
177 ;; fcmp         3       ALU     2
178 ;; fcnv         3       ALU     2
179 ;; fmpyadd      3       ALU,MPY 2
180 ;; fmpysub      3       ALU,MPY 2
181 ;; fmpycfxt     3       ALU,MPY 2
182 ;; fmpy         3       MPY     2
183 ;; fmpyi        3       MPY     2
184 ;; fdiv,sgl     10      MPY     10
185 ;; fdiv,dbl     12      MPY     12
186 ;; fsqrt,sgl    14      MPY     14
187 ;; fsqrt,dbl    18      MPY     18
188
189 (define_function_unit "pa700fp_alu" 1 0
190   (and (eq_attr "type" "fpcc")
191        (eq_attr "cpu" "700")) 4 2)
192 (define_function_unit "pa700fp_alu" 1 0
193   (and (eq_attr "type" "fpalu")
194        (eq_attr "cpu" "700")) 3 2)
195 (define_function_unit "pa700fp_mpy" 1 0
196   (and (eq_attr "type" "fpmulsgl,fpmuldbl")
197        (eq_attr "cpu" "700")) 3 2)
198 (define_function_unit "pa700fp_mpy" 1 0
199   (and (eq_attr "type" "fpdivsgl")
200        (eq_attr "cpu" "700")) 10 10)
201 (define_function_unit "pa700fp_mpy" 1 0
202   (and (eq_attr "type" "fpdivdbl")
203        (eq_attr "cpu" "700")) 12 12)
204 (define_function_unit "pa700fp_mpy" 1 0
205   (and (eq_attr "type" "fpsqrtsgl")
206        (eq_attr "cpu" "700")) 14 14)
207 (define_function_unit "pa700fp_mpy" 1 0
208   (and (eq_attr "type" "fpsqrtdbl")
209        (eq_attr "cpu" "700")) 18 18)
210
211 ;; Function units for the 7100 and 7150.  The 7100/7150 can dual-issue
212 ;; floating point computations with non-floating point computations (fp loads
213 ;; and stores are not fp computations).
214 ;;
215
216 ;; Memory. Disregarding Cache misses, memory loads take two cycles; stores also
217 ;; take two cycles, during which no Dcache operations should be scheduled.
218 ;; Any special cases are handled in pa_adjust_cost.  The 7100, 7150 and 7100LC
219 ;; all have the same memory characteristics if one disregards cache misses.
220 (define_function_unit "pa7100memory" 1 0
221   (and (eq_attr "type" "load,fpload")
222        (eq_attr "cpu" "7100,7100LC")) 2 0)
223 (define_function_unit "pa7100memory" 1 0 
224   (and (eq_attr "type" "store,fpstore")
225        (eq_attr "cpu" "7100,7100LC")) 2 2)
226
227 ;; The 7100/7150 has three floating-point units: ALU, MUL, and DIV.
228 ;; Timings:
229 ;; Instruction  Time    Unit    Minimum Distance (unit contention)
230 ;; fcpy         2       ALU     1
231 ;; fabs         2       ALU     1
232 ;; fadd         2       ALU     1
233 ;; fsub         2       ALU     1
234 ;; fcmp         2       ALU     1
235 ;; fcnv         2       ALU     1
236 ;; fmpyadd      2       ALU,MPY 1
237 ;; fmpysub      2       ALU,MPY 1
238 ;; fmpycfxt     2       ALU,MPY 1
239 ;; fmpy         2       MPY     1
240 ;; fmpyi        2       MPY     1
241 ;; fdiv,sgl     8       DIV     8
242 ;; fdiv,dbl     15      DIV     15
243 ;; fsqrt,sgl    8       DIV     8
244 ;; fsqrt,dbl    15      DIV     15
245
246 (define_function_unit "pa7100fp_alu" 1 0
247   (and (eq_attr "type" "fpcc,fpalu")
248        (eq_attr "cpu" "7100")) 2 1)
249 (define_function_unit "pa7100fp_mpy" 1 0
250   (and (eq_attr "type" "fpmulsgl,fpmuldbl")
251        (eq_attr "cpu" "7100")) 2 1)
252 (define_function_unit "pa7100fp_div" 1 0
253   (and (eq_attr "type" "fpdivsgl,fpsqrtsgl")
254        (eq_attr "cpu" "7100")) 8 8)
255 (define_function_unit "pa7100fp_div" 1 0
256   (and (eq_attr "type" "fpdivdbl,fpsqrtdbl")
257        (eq_attr "cpu" "7100")) 15 15)
258
259 ;; To encourage dual issue we define function units corresponding to
260 ;; the instructions which can be dual issued.    This is a rather crude
261 ;; approximation, the "pa7100nonflop" test in particular could be refined.
262 (define_function_unit "pa7100flop" 1 1
263   (and
264     (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl")
265     (eq_attr "cpu" "7100")) 1 1)
266
267 (define_function_unit "pa7100nonflop" 1 1
268   (and
269     (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl")
270     (eq_attr "cpu" "7100")) 1 1)
271
272
273 ;; Memory subsystem works just like 7100/7150 (except for cache miss times which
274 ;; we don't model here).  
275
276 ;; The 7100LC has three floating-point units: ALU, MUL, and DIV.
277 ;; Note divides and sqrt flops lock the cpu until the flop is
278 ;; finished.  fmpy and xmpyu (fmpyi) lock the cpu for one cycle.
279 ;; There's no way to avoid the penalty.
280 ;; Timings:
281 ;; Instruction  Time    Unit    Minimum Distance (unit contention)
282 ;; fcpy         2       ALU     1
283 ;; fabs         2       ALU     1
284 ;; fadd         2       ALU     1
285 ;; fsub         2       ALU     1
286 ;; fcmp         2       ALU     1
287 ;; fcnv         2       ALU     1
288 ;; fmpyadd,sgl  2       ALU,MPY 1
289 ;; fmpyadd,dbl  3       ALU,MPY 2
290 ;; fmpysub,sgl  2       ALU,MPY 1
291 ;; fmpysub,dbl  3       ALU,MPY 2
292 ;; fmpycfxt,sgl 2       ALU,MPY 1
293 ;; fmpycfxt,dbl 3       ALU,MPY 2
294 ;; fmpy,sgl     2       MPY     1
295 ;; fmpy,dbl     3       MPY     2
296 ;; fmpyi        3       MPY     2
297 ;; fdiv,sgl     8       DIV     8
298 ;; fdiv,dbl     15      DIV     15
299 ;; fsqrt,sgl    8       DIV     8
300 ;; fsqrt,dbl    15      DIV     15
301
302 (define_function_unit "pa7100LCfp_alu" 1 0
303   (and (eq_attr "type" "fpcc,fpalu")
304        (eq_attr "cpu" "7100LC,7200")) 2 1)
305 (define_function_unit "pa7100LCfp_mpy" 1 0
306   (and (eq_attr "type" "fpmulsgl")
307        (eq_attr "cpu" "7100LC,7200")) 2 1)
308 (define_function_unit "pa7100LCfp_mpy" 1 0
309   (and (eq_attr "type" "fpmuldbl")
310        (eq_attr "cpu" "7100LC,7200")) 3 2)
311 (define_function_unit "pa7100LCfp_div" 1 0
312   (and (eq_attr "type" "fpdivsgl,fpsqrtsgl")
313        (eq_attr "cpu" "7100LC,7200")) 8 8)
314 (define_function_unit "pa7100LCfp_div" 1 0
315   (and (eq_attr "type" "fpdivdbl,fpsqrtdbl")
316        (eq_attr "cpu" "7100LC,7200")) 15 15)
317
318 ;; Define the various functional units for dual-issue.
319
320 ;; There's only one floating point unit.
321 (define_function_unit "pa7100LCflop" 1 1
322   (and
323     (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl")
324     (eq_attr "cpu" "7100LC,7200")) 1 1)
325
326 ;; Shifts and memory ops execute in only one of the integer ALUs
327 (define_function_unit "pa7100LCshiftmem" 1 1
328   (and
329     (eq_attr "type" "shift,nullshift,load,fpload,store,fpstore")
330     (eq_attr "cpu" "7100LC,7200")) 1 1)
331
332 ;; We have two basic ALUs.
333 (define_function_unit "pa7100LCalu" 2 1
334   (and
335     (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl")
336    (eq_attr "cpu" "7100LC,7200")) 1 1)
337
338 ;; I don't have complete information on the PA7200; however, most of
339 ;; what I've heard makes it look like a 7100LC without the store-store
340 ;; penalty.  So that's how we'll model it.
341
342 ;; Memory. Disregarding Cache misses, memory loads and stores take
343 ;; two cycles.  Any special cases are handled in pa_adjust_cost.
344 (define_function_unit "pa7200memory" 1 0
345   (and (eq_attr "type" "load,fpload,store,fpstore")
346        (eq_attr "cpu" "7200")) 2 0)
347
348 ;; I don't have detailed information on the PA7200 FP pipeline, so I
349 ;; treat it just like the 7100LC pipeline.
350 ;; Similarly for the multi-issue fake units.
351
352 ;; 
353 ;; Scheduling for the PA8000 is somewhat different than scheduling for a
354 ;; traditional architecture.
355 ;;
356 ;; The PA8000 has a large (56) entry reorder buffer that is split between
357 ;; memory and non-memory operations.
358 ;;
359 ;; The PA800 can issue two memory and two non-memory operations per cycle to
360 ;; the function units.  Similarly, the PA8000 can retire two memory and two
361 ;; non-memory operations per cycle.
362 ;;
363 ;; Given the large reorder buffer, the processor can hide most latencies.
364 ;; According to HP, they've got the best results by scheduling for retirement
365 ;; bandwidth with limited latency scheduling for floating point operations.
366 ;; Latency for integer operations and memory references is ignored.
367 ;;
368 ;; We claim floating point operations have a 2 cycle latency and are
369 ;; fully pipelined, except for div and sqrt which are not pipelined.
370 ;;
371 ;; It is not necessary to define the shifter and integer alu units.
372 ;;
373 ;; These first two define_unit_unit descriptions model retirement from
374 ;; the reorder buffer.
375 (define_function_unit "pa8000lsu" 2 1
376   (and
377     (eq_attr "type" "load,fpload,store,fpstore")
378     (eq_attr "cpu" "8000")) 1 1)
379
380 (define_function_unit "pa8000alu" 2 1
381   (and
382     (eq_attr "type" "!load,fpload,store,fpstore")
383     (eq_attr "cpu" "8000")) 1 1)
384
385 ;; Claim floating point ops have a 2 cycle latency, excluding div and
386 ;; sqrt, which are not pipelined and issue to different units.
387 (define_function_unit "pa8000fmac" 2 0
388   (and
389     (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
390     (eq_attr "cpu" "8000")) 2 1)
391
392 (define_function_unit "pa8000fdiv" 2 1
393   (and
394     (eq_attr "type" "fpdivsgl,fpsqrtsgl")
395     (eq_attr "cpu" "8000")) 17 17)
396
397 (define_function_unit "pa8000fdiv" 2 1
398   (and
399     (eq_attr "type" "fpdivdbl,fpsqrtdbl")
400     (eq_attr "cpu" "8000")) 31 31)
401
402 \f
403 ;; Compare instructions.
404 ;; This controls RTL generation and register allocation.
405
406 ;; We generate RTL for comparisons and branches by having the cmpxx
407 ;; patterns store away the operands.  Then, the scc and bcc patterns
408 ;; emit RTL for both the compare and the branch.
409 ;;
410
411 (define_expand "cmpsi"
412   [(set (reg:CC 0)
413         (compare:CC (match_operand:SI 0 "reg_or_0_operand" "")
414                     (match_operand:SI 1 "arith5_operand" "")))]
415   ""
416   "
417 {
418  hppa_compare_op0 = operands[0];
419  hppa_compare_op1 = operands[1];
420  hppa_branch_type = CMP_SI;
421  DONE;
422 }")
423
424 (define_expand "cmpsf"
425   [(set (reg:CCFP 0)
426         (compare:CCFP (match_operand:SF 0 "reg_or_0_operand" "")
427                       (match_operand:SF 1 "reg_or_0_operand" "")))]
428   "! TARGET_SOFT_FLOAT"
429   "
430 {
431   hppa_compare_op0 = operands[0];
432   hppa_compare_op1 = operands[1];
433   hppa_branch_type = CMP_SF;
434   DONE;
435 }")
436
437 (define_expand "cmpdf"
438   [(set (reg:CCFP 0)
439       (compare:CCFP (match_operand:DF 0 "reg_or_0_operand" "")
440                     (match_operand:DF 1 "reg_or_0_operand" "")))]
441   "! TARGET_SOFT_FLOAT"
442   "
443 {
444   hppa_compare_op0 = operands[0];
445   hppa_compare_op1 = operands[1];
446   hppa_branch_type = CMP_DF;
447   DONE;
448 }")
449
450 (define_insn ""
451   [(set (reg:CCFP 0)
452         (match_operator:CCFP 2 "comparison_operator"
453                              [(match_operand:SF 0 "reg_or_0_operand" "fG")
454                               (match_operand:SF 1 "reg_or_0_operand" "fG")]))]
455   "! TARGET_SOFT_FLOAT"
456   "fcmp,sgl,%Y2 %f0,%f1"
457   [(set_attr "length" "4")
458    (set_attr "type" "fpcc")])
459
460 (define_insn ""
461   [(set (reg:CCFP 0)
462         (match_operator:CCFP 2 "comparison_operator"
463                              [(match_operand:DF 0 "reg_or_0_operand" "fG")
464                               (match_operand:DF 1 "reg_or_0_operand" "fG")]))]
465   "! TARGET_SOFT_FLOAT"
466   "fcmp,dbl,%Y2 %f0,%f1"
467   [(set_attr "length" "4")
468    (set_attr "type" "fpcc")])
469
470 ;; scc insns.
471
472 (define_expand "seq"
473   [(set (match_operand:SI 0 "register_operand" "")
474         (eq:SI (match_dup 1)
475                (match_dup 2)))]
476   ""
477   "
478 {
479   /* fp scc patterns rarely match, and are not a win on the PA.  */
480   if (hppa_branch_type != CMP_SI)
481     FAIL;
482   /* set up operands from compare.  */
483   operands[1] = hppa_compare_op0;
484   operands[2] = hppa_compare_op1;
485   /* fall through and generate default code */
486 }")
487
488 (define_expand "sne"
489   [(set (match_operand:SI 0 "register_operand" "")
490         (ne:SI (match_dup 1)
491                (match_dup 2)))]
492   ""
493   "
494 {
495   /* fp scc patterns rarely match, and are not a win on the PA.  */
496   if (hppa_branch_type != CMP_SI)
497     FAIL;
498   operands[1] = hppa_compare_op0;
499   operands[2] = hppa_compare_op1;
500 }")
501
502 (define_expand "slt"
503   [(set (match_operand:SI 0 "register_operand" "")
504         (lt:SI (match_dup 1)
505                (match_dup 2)))]
506   ""
507   "
508 {
509   /* fp scc patterns rarely match, and are not a win on the PA.  */
510   if (hppa_branch_type != CMP_SI)
511     FAIL;
512   operands[1] = hppa_compare_op0;
513   operands[2] = hppa_compare_op1;
514 }")
515
516 (define_expand "sgt"
517   [(set (match_operand:SI 0 "register_operand" "")
518         (gt:SI (match_dup 1)
519                (match_dup 2)))]
520   ""
521   "
522 {
523   /* fp scc patterns rarely match, and are not a win on the PA.  */
524   if (hppa_branch_type != CMP_SI)
525     FAIL;
526   operands[1] = hppa_compare_op0;
527   operands[2] = hppa_compare_op1;
528 }")
529
530 (define_expand "sle"
531   [(set (match_operand:SI 0 "register_operand" "")
532         (le:SI (match_dup 1)
533                (match_dup 2)))]
534   ""
535   "
536 {
537   /* fp scc patterns rarely match, and are not a win on the PA.  */
538   if (hppa_branch_type != CMP_SI)
539     FAIL;
540   operands[1] = hppa_compare_op0;
541   operands[2] = hppa_compare_op1;
542 }")
543
544 (define_expand "sge"
545   [(set (match_operand:SI 0 "register_operand" "")
546         (ge:SI (match_dup 1)
547                (match_dup 2)))]
548   ""
549   "
550 {
551   /* fp scc patterns rarely match, and are not a win on the PA.  */
552   if (hppa_branch_type != CMP_SI)
553     FAIL;
554   operands[1] = hppa_compare_op0;
555   operands[2] = hppa_compare_op1;
556 }")
557
558 (define_expand "sltu"
559   [(set (match_operand:SI 0 "register_operand" "")
560         (ltu:SI (match_dup 1)
561                 (match_dup 2)))]
562   ""
563   "
564 {
565   if (hppa_branch_type != CMP_SI)
566     FAIL;
567   operands[1] = hppa_compare_op0;
568   operands[2] = hppa_compare_op1;
569 }")
570
571 (define_expand "sgtu"
572   [(set (match_operand:SI 0 "register_operand" "")
573         (gtu:SI (match_dup 1)
574                 (match_dup 2)))]
575   ""
576   "
577 {
578   if (hppa_branch_type != CMP_SI)
579     FAIL;
580   operands[1] = hppa_compare_op0;
581   operands[2] = hppa_compare_op1;
582 }")
583
584 (define_expand "sleu"
585   [(set (match_operand:SI 0 "register_operand" "")
586         (leu:SI (match_dup 1)
587                 (match_dup 2)))]
588   ""
589   "
590 {
591   if (hppa_branch_type != CMP_SI)
592     FAIL;
593   operands[1] = hppa_compare_op0;
594   operands[2] = hppa_compare_op1;
595 }")
596
597 (define_expand "sgeu"
598   [(set (match_operand:SI 0 "register_operand" "")
599         (geu:SI (match_dup 1)
600                 (match_dup 2)))]
601   ""
602   "
603 {
604   if (hppa_branch_type != CMP_SI)
605     FAIL;
606   operands[1] = hppa_compare_op0;
607   operands[2] = hppa_compare_op1;
608 }")
609
610 ;; Instruction canonicalization puts immediate operands second, which
611 ;; is the reverse of what we want.
612
613 (define_insn "scc"
614   [(set (match_operand:SI 0 "register_operand" "=r")
615         (match_operator:SI 3 "comparison_operator"
616                            [(match_operand:SI 1 "register_operand" "r")
617                             (match_operand:SI 2 "arith11_operand" "rI")]))]
618   ""
619   "com%I2clr,%B3 %2,%1,%0\;ldi 1,%0"
620   [(set_attr "type" "binary")
621    (set_attr "length" "8")])
622
623 (define_insn "iorscc"
624   [(set (match_operand:SI 0 "register_operand" "=r")
625         (ior:SI (match_operator:SI 3 "comparison_operator"
626                                    [(match_operand:SI 1 "register_operand" "r")
627                                     (match_operand:SI 2 "arith11_operand" "rI")])
628                 (match_operator:SI 6 "comparison_operator"
629                                    [(match_operand:SI 4 "register_operand" "r")
630                                     (match_operand:SI 5 "arith11_operand" "rI")])))]
631   ""
632   "com%I2clr,%S3 %2,%1,%%r0\;com%I5clr,%B6 %5,%4,%0\;ldi 1,%0"
633   [(set_attr "type" "binary")
634    (set_attr "length" "12")])
635
636 ;; Combiner patterns for common operations performed with the output
637 ;; from an scc insn (negscc and incscc).
638 (define_insn "negscc"
639   [(set (match_operand:SI 0 "register_operand" "=r")
640         (neg:SI (match_operator:SI 3 "comparison_operator"
641                [(match_operand:SI 1 "register_operand" "r")
642                 (match_operand:SI 2 "arith11_operand" "rI")])))]
643   ""
644   "com%I2clr,%B3 %2,%1,%0\;ldi -1,%0"
645   [(set_attr "type" "binary")
646    (set_attr "length" "8")])
647
648 ;; Patterns for adding/subtracting the result of a boolean expression from
649 ;; a register.  First we have special patterns that make use of the carry
650 ;; bit, and output only two instructions.  For the cases we can't in
651 ;; general do in two instructions, the incscc pattern at the end outputs
652 ;; two or three instructions.
653
654 (define_insn ""
655   [(set (match_operand:SI 0 "register_operand" "=r")
656         (plus:SI (leu:SI (match_operand:SI 2 "register_operand" "r")
657                          (match_operand:SI 3 "arith11_operand" "rI"))
658                  (match_operand:SI 1 "register_operand" "r")))]
659   ""
660   "sub%I3 %3,%2,%%r0\;addc %%r0,%1,%0"
661   [(set_attr "type" "binary")
662    (set_attr "length" "8")])
663
664 ; This need only accept registers for op3, since canonicalization
665 ; replaces geu with gtu when op3 is an integer.
666 (define_insn ""
667   [(set (match_operand:SI 0 "register_operand" "=r")
668         (plus:SI (geu:SI (match_operand:SI 2 "register_operand" "r")
669                          (match_operand:SI 3 "register_operand" "r"))
670                  (match_operand:SI 1 "register_operand" "r")))]
671   ""
672   "sub %2,%3,%%r0\;addc %%r0,%1,%0"
673   [(set_attr "type" "binary")
674    (set_attr "length" "8")])
675
676 ; Match only integers for op3 here.  This is used as canonical form of the
677 ; geu pattern when op3 is an integer.  Don't match registers since we can't
678 ; make better code than the general incscc pattern.
679 (define_insn ""
680   [(set (match_operand:SI 0 "register_operand" "=r")
681         (plus:SI (gtu:SI (match_operand:SI 2 "register_operand" "r")
682                          (match_operand:SI 3 "int11_operand" "I"))
683                  (match_operand:SI 1 "register_operand" "r")))]
684   ""
685   "addi %k3,%2,%%r0\;addc %%r0,%1,%0"
686   [(set_attr "type" "binary")
687    (set_attr "length" "8")])
688
689 (define_insn "incscc"
690   [(set (match_operand:SI 0 "register_operand" "=r,r")
691         (plus:SI (match_operator:SI 4 "comparison_operator"
692                     [(match_operand:SI 2 "register_operand" "r,r")
693                      (match_operand:SI 3 "arith11_operand" "rI,rI")])
694                  (match_operand:SI 1 "register_operand" "0,?r")))]
695   ""
696   "@
697    com%I3clr,%B4 %3,%2,%%r0\;addi 1,%0,%0
698    com%I3clr,%B4 %3,%2,%%r0\;addi,tr 1,%1,%0\;copy %1,%0"
699   [(set_attr "type" "binary,binary")
700    (set_attr "length" "8,12")])
701
702 (define_insn ""
703   [(set (match_operand:SI 0 "register_operand" "=r")
704         (minus:SI (match_operand:SI 1 "register_operand" "r")
705                   (gtu:SI (match_operand:SI 2 "register_operand" "r")
706                           (match_operand:SI 3 "arith11_operand" "rI"))))]
707   ""
708   "sub%I3 %3,%2,%%r0\;subb %1,0,%0"
709   [(set_attr "type" "binary")
710    (set_attr "length" "8")])
711
712 (define_insn ""
713   [(set (match_operand:SI 0 "register_operand" "=r")
714         (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
715                             (gtu:SI (match_operand:SI 2 "register_operand" "r")
716                                     (match_operand:SI 3 "arith11_operand" "rI")))
717                   (match_operand:SI 4 "register_operand" "r")))]
718   ""
719   "sub%I3 %3,%2,%%r0\;subb %1,%4,%0"
720   [(set_attr "type" "binary")
721    (set_attr "length" "8")])
722
723 ; This need only accept registers for op3, since canonicalization
724 ; replaces ltu with leu when op3 is an integer.
725 (define_insn ""
726   [(set (match_operand:SI 0 "register_operand" "=r")
727         (minus:SI (match_operand:SI 1 "register_operand" "r")
728                   (ltu:SI (match_operand:SI 2 "register_operand" "r")
729                           (match_operand:SI 3 "register_operand" "r"))))]
730   ""
731   "sub %2,%3,%%r0\;subb %1,0,%0"
732   [(set_attr "type" "binary")
733    (set_attr "length" "8")])
734
735 (define_insn ""
736   [(set (match_operand:SI 0 "register_operand" "=r")
737         (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
738                             (ltu:SI (match_operand:SI 2 "register_operand" "r")
739                                     (match_operand:SI 3 "register_operand" "r")))
740                   (match_operand:SI 4 "register_operand" "r")))]
741   ""
742   "sub %2,%3,%%r0\;subb %1,%4,%0"
743   [(set_attr "type" "binary")
744    (set_attr "length" "8")])
745
746 ; Match only integers for op3 here.  This is used as canonical form of the
747 ; ltu pattern when op3 is an integer.  Don't match registers since we can't
748 ; make better code than the general incscc pattern.
749 (define_insn ""
750   [(set (match_operand:SI 0 "register_operand" "=r")
751         (minus:SI (match_operand:SI 1 "register_operand" "r")
752                   (leu:SI (match_operand:SI 2 "register_operand" "r")
753                           (match_operand:SI 3 "int11_operand" "I"))))]
754   ""
755   "addi %k3,%2,%%r0\;subb %1,0,%0"
756   [(set_attr "type" "binary")
757    (set_attr "length" "8")])
758
759 (define_insn ""
760   [(set (match_operand:SI 0 "register_operand" "=r")
761         (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
762                             (leu:SI (match_operand:SI 2 "register_operand" "r")
763                                     (match_operand:SI 3 "int11_operand" "I")))
764                   (match_operand:SI 4 "register_operand" "r")))]
765   ""
766   "addi %k3,%2,%%r0\;subb %1,%4,%0"
767   [(set_attr "type" "binary")
768    (set_attr "length" "8")])
769
770 (define_insn "decscc"
771   [(set (match_operand:SI 0 "register_operand" "=r,r")
772         (minus:SI (match_operand:SI 1 "register_operand" "0,?r")
773                   (match_operator:SI 4 "comparison_operator"
774                      [(match_operand:SI 2 "register_operand" "r,r")
775                       (match_operand:SI 3 "arith11_operand" "rI,rI")])))]
776   ""
777   "@
778    com%I3clr,%B4 %3,%2,%%r0\;addi -1,%0,%0
779    com%I3clr,%B4 %3,%2,%%r0\;addi,tr -1,%1,%0\;copy %1,%0"
780   [(set_attr "type" "binary,binary")
781    (set_attr "length" "8,12")])
782
783 ; Patterns for max and min.  (There is no need for an earlyclobber in the
784 ; last alternative since the middle alternative will match if op0 == op1.)
785
786 (define_insn "sminsi3"
787   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
788         (smin:SI (match_operand:SI 1 "register_operand" "%0,0,r")
789                  (match_operand:SI 2 "arith11_operand" "r,I,M")))]
790   ""
791   "@
792   comclr,> %2,%0,%%r0\;copy %2,%0
793   comiclr,> %2,%0,%%r0\;ldi %2,%0
794   comclr,> %1,%r2,%0\;copy %1,%0"
795 [(set_attr "type" "multi,multi,multi")
796  (set_attr "length" "8,8,8")])
797
798 (define_insn "uminsi3"
799   [(set (match_operand:SI 0 "register_operand" "=r,r")
800         (umin:SI (match_operand:SI 1 "register_operand" "%0,0")
801                  (match_operand:SI 2 "arith11_operand" "r,I")))]
802   ""
803   "@
804   comclr,>> %2,%0,%%r0\;copy %2,%0
805   comiclr,>> %2,%0,%%r0\;ldi %2,%0"
806 [(set_attr "type" "multi,multi")
807  (set_attr "length" "8,8")])
808
809 (define_insn "smaxsi3"
810   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
811         (smax:SI (match_operand:SI 1 "register_operand" "%0,0,r")
812                  (match_operand:SI 2 "arith11_operand" "r,I,M")))]
813   ""
814   "@
815   comclr,< %2,%0,%%r0\;copy %2,%0
816   comiclr,< %2,%0,%%r0\;ldi %2,%0
817   comclr,< %1,%r2,%0\;copy %1,%0"
818 [(set_attr "type" "multi,multi,multi")
819  (set_attr "length" "8,8,8")])
820
821 (define_insn "umaxsi3"
822   [(set (match_operand:SI 0 "register_operand" "=r,r")
823         (umax:SI (match_operand:SI 1 "register_operand" "%0,0")
824                  (match_operand:SI 2 "arith11_operand" "r,I")))]
825   ""
826   "@
827   comclr,<< %2,%0,%%r0\;copy %2,%0
828   comiclr,<< %2,%0,%%r0\;ldi %2,%0"
829 [(set_attr "type" "multi,multi")
830  (set_attr "length" "8,8")])
831
832 (define_insn "abssi2"
833   [(set (match_operand:SI 0 "register_operand" "=r")
834         (abs:SI (match_operand:SI 1 "register_operand" "r")))]
835   ""
836   "or,>= %%r0,%1,%0\;subi 0,%0,%0"
837   [(set_attr "type" "multi")
838    (set_attr "length" "8")])
839
840 ;;; Experimental conditional move patterns
841
842 (define_expand "movsicc"
843   [(set (match_operand:SI 0 "register_operand" "")
844         (if_then_else:SI
845          (match_operator 1 "comparison_operator"
846             [(match_dup 4)
847              (match_dup 5)])
848          (match_operand:SI 2 "reg_or_cint_move_operand" "")
849          (match_operand:SI 3 "reg_or_cint_move_operand" "")))]
850   ""
851   "
852 {
853   enum rtx_code code = GET_CODE (operands[1]);
854
855   if (hppa_branch_type != CMP_SI)
856     FAIL;
857
858   /* operands[1] is currently the result of compare_from_rtx.  We want to
859      emit a compare of the original operands.  */
860   operands[1] = gen_rtx_fmt_ee (code, SImode, hppa_compare_op0, hppa_compare_op1);
861   operands[4] = hppa_compare_op0;
862   operands[5] = hppa_compare_op1;
863 }")
864
865 ; We need the first constraint alternative in order to avoid
866 ; earlyclobbers on all other alternatives.
867 (define_insn ""
868   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r")
869         (if_then_else:SI
870          (match_operator 5 "comparison_operator"
871             [(match_operand:SI 3 "register_operand" "r,r,r,r,r")
872              (match_operand:SI 4 "arith11_operand" "rI,rI,rI,rI,rI")])
873          (match_operand:SI 1 "reg_or_cint_move_operand" "0,r,J,N,K")
874          (const_int 0)))]
875   ""
876   "@
877    com%I4clr,%S5 %4,%3,%%r0\;ldi 0,%0
878    com%I4clr,%B5 %4,%3,%0\;copy %1,%0
879    com%I4clr,%B5 %4,%3,%0\;ldi %1,%0
880    com%I4clr,%B5 %4,%3,%0\;ldil L'%1,%0
881    com%I4clr,%B5 %4,%3,%0\;zdepi %Z1,%0"
882   [(set_attr "type" "multi,multi,multi,multi,nullshift")
883    (set_attr "length" "8,8,8,8,8")])
884
885 (define_insn ""
886   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r,r,r")
887         (if_then_else:SI
888          (match_operator 5 "comparison_operator"
889             [(match_operand:SI 3 "register_operand" "r,r,r,r,r,r,r,r")
890              (match_operand:SI 4 "arith11_operand" "rI,rI,rI,rI,rI,rI,rI,rI")])
891          (match_operand:SI 1 "reg_or_cint_move_operand" "0,0,0,0,r,J,N,K")
892          (match_operand:SI 2 "reg_or_cint_move_operand" "r,J,N,K,0,0,0,0")))]
893   ""
894   "@
895    com%I4clr,%S5 %4,%3,%%r0\;copy %2,%0
896    com%I4clr,%S5 %4,%3,%%r0\;ldi %2,%0
897    com%I4clr,%S5 %4,%3,%%r0\;ldil L'%2,%0
898    com%I4clr,%S5 %4,%3,%%r0\;zdepi %Z2,%0
899    com%I4clr,%B5 %4,%3,%%r0\;copy %1,%0
900    com%I4clr,%B5 %4,%3,%%r0\;ldi %1,%0
901    com%I4clr,%B5 %4,%3,%%r0\;ldil L'%1,%0
902    com%I4clr,%B5 %4,%3,%%r0\;zdepi %Z1,%0"
903   [(set_attr "type" "multi,multi,multi,nullshift,multi,multi,multi,nullshift")
904    (set_attr "length" "8,8,8,8,8,8,8,8")])
905
906 ;; Conditional Branches
907
908 (define_expand "beq"
909   [(set (pc)
910         (if_then_else (eq (match_dup 1) (match_dup 2))
911                       (label_ref (match_operand 0 "" ""))
912                       (pc)))]
913   ""
914   "
915 {
916   if (hppa_branch_type != CMP_SI)
917     {
918       emit_insn (gen_cmp_fp (EQ, hppa_compare_op0, hppa_compare_op1));
919       emit_bcond_fp (NE, operands[0]);
920       DONE;
921     }
922   /* set up operands from compare.  */
923   operands[1] = hppa_compare_op0;
924   operands[2] = hppa_compare_op1;
925   /* fall through and generate default code */
926 }")
927
928 (define_expand "bne"
929   [(set (pc)
930         (if_then_else (ne (match_dup 1) (match_dup 2))
931                       (label_ref (match_operand 0 "" ""))
932                       (pc)))]
933   ""
934   "
935 {
936   if (hppa_branch_type != CMP_SI)
937     {
938       emit_insn (gen_cmp_fp (NE, hppa_compare_op0, hppa_compare_op1));
939       emit_bcond_fp (NE, operands[0]);
940       DONE;
941     }
942   operands[1] = hppa_compare_op0;
943   operands[2] = hppa_compare_op1;
944 }")
945
946 (define_expand "bgt"
947   [(set (pc)
948         (if_then_else (gt (match_dup 1) (match_dup 2))
949                       (label_ref (match_operand 0 "" ""))
950                       (pc)))]
951   ""
952   "
953 {
954   if (hppa_branch_type != CMP_SI)
955     {
956       emit_insn (gen_cmp_fp (GT, hppa_compare_op0, hppa_compare_op1));
957       emit_bcond_fp (NE, operands[0]);
958       DONE;
959     }
960   operands[1] = hppa_compare_op0;
961   operands[2] = hppa_compare_op1;
962 }")
963
964 (define_expand "blt"
965   [(set (pc)
966         (if_then_else (lt (match_dup 1) (match_dup 2))
967                       (label_ref (match_operand 0 "" ""))
968                       (pc)))]
969   ""
970   "
971 {
972   if (hppa_branch_type != CMP_SI)
973     {
974       emit_insn (gen_cmp_fp (LT, hppa_compare_op0, hppa_compare_op1));
975       emit_bcond_fp (NE, operands[0]);
976       DONE;
977     }
978   operands[1] = hppa_compare_op0;
979   operands[2] = hppa_compare_op1;
980 }")
981
982 (define_expand "bge"
983   [(set (pc)
984         (if_then_else (ge (match_dup 1) (match_dup 2))
985                       (label_ref (match_operand 0 "" ""))
986                       (pc)))]
987   ""
988   "
989 {
990   if (hppa_branch_type != CMP_SI)
991     {
992       emit_insn (gen_cmp_fp (GE, hppa_compare_op0, hppa_compare_op1));
993       emit_bcond_fp (NE, operands[0]);
994       DONE;
995     }
996   operands[1] = hppa_compare_op0;
997   operands[2] = hppa_compare_op1;
998 }")
999
1000 (define_expand "ble"
1001   [(set (pc)
1002         (if_then_else (le (match_dup 1) (match_dup 2))
1003                       (label_ref (match_operand 0 "" ""))
1004                       (pc)))]
1005   ""
1006   "
1007 {
1008   if (hppa_branch_type != CMP_SI)
1009     {
1010       emit_insn (gen_cmp_fp (LE, hppa_compare_op0, hppa_compare_op1));
1011       emit_bcond_fp (NE, operands[0]);
1012       DONE;
1013     }
1014   operands[1] = hppa_compare_op0;
1015   operands[2] = hppa_compare_op1;
1016 }")
1017
1018 (define_expand "bgtu"
1019   [(set (pc)
1020         (if_then_else (gtu (match_dup 1) (match_dup 2))
1021                       (label_ref (match_operand 0 "" ""))
1022                       (pc)))]
1023   ""
1024   "
1025 {
1026   if (hppa_branch_type != CMP_SI)
1027     FAIL;
1028   operands[1] = hppa_compare_op0;
1029   operands[2] = hppa_compare_op1;
1030 }")
1031
1032 (define_expand "bltu"
1033   [(set (pc)
1034         (if_then_else (ltu (match_dup 1) (match_dup 2))
1035                       (label_ref (match_operand 0 "" ""))
1036                       (pc)))]
1037   ""
1038   "
1039 {
1040   if (hppa_branch_type != CMP_SI)
1041     FAIL;
1042   operands[1] = hppa_compare_op0;
1043   operands[2] = hppa_compare_op1;
1044 }")
1045
1046 (define_expand "bgeu"
1047   [(set (pc)
1048         (if_then_else (geu (match_dup 1) (match_dup 2))
1049                       (label_ref (match_operand 0 "" ""))
1050                       (pc)))]
1051   ""
1052   "
1053 {
1054   if (hppa_branch_type != CMP_SI)
1055     FAIL;
1056   operands[1] = hppa_compare_op0;
1057   operands[2] = hppa_compare_op1;
1058 }")
1059
1060 (define_expand "bleu"
1061   [(set (pc)
1062         (if_then_else (leu (match_dup 1) (match_dup 2))
1063                       (label_ref (match_operand 0 "" ""))
1064                       (pc)))]
1065   ""
1066   "
1067 {
1068   if (hppa_branch_type != CMP_SI)
1069     FAIL;
1070   operands[1] = hppa_compare_op0;
1071   operands[2] = hppa_compare_op1;
1072 }")
1073
1074 ;; Match the branch patterns.
1075
1076
1077 ;; Note a long backward conditional branch with an annulled delay slot
1078 ;; has a length of 12.
1079 (define_insn ""
1080   [(set (pc)
1081         (if_then_else
1082          (match_operator 3 "comparison_operator"
1083                          [(match_operand:SI 1 "reg_or_0_operand" "rM")
1084                           (match_operand:SI 2 "arith5_operand" "rL")])
1085          (label_ref (match_operand 0 "" ""))
1086          (pc)))]
1087   ""
1088   "*
1089 {
1090   return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1091                          get_attr_length (insn), 0, insn);
1092 }"
1093 [(set_attr "type" "cbranch")
1094  (set (attr "length")
1095     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1096                (const_int 8184))
1097            (const_int 4)
1098            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1099                (const_int 262100))
1100            (const_int 8)
1101            (eq (symbol_ref "flag_pic") (const_int 0))
1102            (const_int 20)]
1103           (const_int 28)))])
1104
1105 ;; Match the negated branch.
1106
1107 (define_insn ""
1108   [(set (pc)
1109         (if_then_else
1110          (match_operator 3 "comparison_operator"
1111                          [(match_operand:SI 1 "reg_or_0_operand" "rM")
1112                           (match_operand:SI 2 "arith5_operand" "rL")])
1113          (pc)
1114          (label_ref (match_operand 0 "" ""))))]
1115   ""
1116   "*
1117 {
1118   return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1119                          get_attr_length (insn), 1, insn);
1120 }"
1121 [(set_attr "type" "cbranch")
1122  (set (attr "length")
1123     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1124                (const_int 8184))
1125            (const_int 4)
1126            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1127                (const_int 262100))
1128            (const_int 8)
1129            (eq (symbol_ref "flag_pic") (const_int 0))
1130            (const_int 20)]
1131           (const_int 28)))])
1132
1133 ;; Branch on Bit patterns.
1134 (define_insn ""
1135   [(set (pc)
1136         (if_then_else
1137          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1138                               (const_int 1)
1139                               (match_operand:SI 1 "uint5_operand" ""))
1140              (const_int 0))
1141          (label_ref (match_operand 2 "" ""))
1142          (pc)))]
1143   ""
1144   "*
1145 {
1146   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1147                          get_attr_length (insn), 0, insn, 0);
1148 }"
1149 [(set_attr "type" "cbranch")
1150  (set (attr "length")
1151     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1152                       (const_int 8184))
1153            (const_int 4)
1154            (const_int 8)))])
1155
1156 (define_insn ""
1157   [(set (pc)
1158         (if_then_else
1159          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1160                               (const_int 1)
1161                               (match_operand:SI 1 "uint5_operand" ""))
1162              (const_int 0))
1163          (pc)
1164          (label_ref (match_operand 2 "" ""))))]
1165   ""
1166   "*
1167 {
1168   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1169                          get_attr_length (insn), 1, insn, 0);
1170 }"
1171 [(set_attr "type" "cbranch")
1172  (set (attr "length")
1173     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1174                       (const_int 8184))
1175            (const_int 4)
1176            (const_int 8)))])
1177
1178 (define_insn ""
1179   [(set (pc)
1180         (if_then_else
1181          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1182                               (const_int 1)
1183                               (match_operand:SI 1 "uint5_operand" ""))
1184              (const_int 0))
1185          (label_ref (match_operand 2 "" ""))
1186          (pc)))]
1187   ""
1188   "*
1189 {
1190   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1191                          get_attr_length (insn), 0, insn, 1);
1192 }"
1193 [(set_attr "type" "cbranch")
1194  (set (attr "length")
1195     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1196                       (const_int 8184))
1197            (const_int 4)
1198            (const_int 8)))])
1199
1200 (define_insn ""
1201   [(set (pc)
1202         (if_then_else
1203          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1204                               (const_int 1)
1205                               (match_operand:SI 1 "uint5_operand" ""))
1206              (const_int 0))
1207          (pc)
1208          (label_ref (match_operand 2 "" ""))))]
1209   ""
1210   "*
1211 {
1212   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1213                          get_attr_length (insn), 1, insn, 1);
1214 }"
1215 [(set_attr "type" "cbranch")
1216  (set (attr "length")
1217     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1218                       (const_int 8184))
1219            (const_int 4)
1220            (const_int 8)))])
1221
1222 ;; Branch on Variable Bit patterns.
1223 (define_insn ""
1224   [(set (pc)
1225         (if_then_else
1226          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1227                               (const_int 1)
1228                               (match_operand:SI 1 "register_operand" "q"))
1229              (const_int 0))
1230          (label_ref (match_operand 2 "" ""))
1231          (pc)))]
1232   ""
1233   "*
1234 {
1235   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
1236                      get_attr_length (insn), 0, insn, 0);
1237 }"
1238 [(set_attr "type" "cbranch")
1239  (set (attr "length")
1240     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1241                       (const_int 8184))
1242            (const_int 4)
1243            (const_int 8)))])
1244
1245 (define_insn ""
1246   [(set (pc)
1247         (if_then_else
1248          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1249                               (const_int 1)
1250                               (match_operand:SI 1 "register_operand" "q"))
1251              (const_int 0))
1252          (pc)
1253          (label_ref (match_operand 2 "" ""))))]
1254   ""
1255   "*
1256 {
1257   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
1258                      get_attr_length (insn), 1, insn, 0);
1259 }"
1260 [(set_attr "type" "cbranch")
1261  (set (attr "length")
1262     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1263                       (const_int 8184))
1264            (const_int 4)
1265            (const_int 8)))])
1266
1267 (define_insn ""
1268   [(set (pc)
1269         (if_then_else
1270          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1271                               (const_int 1)
1272                               (match_operand:SI 1 "register_operand" "q"))
1273              (const_int 0))
1274          (label_ref (match_operand 2 "" ""))
1275          (pc)))]
1276   ""
1277   "*
1278 {
1279   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
1280                      get_attr_length (insn), 0, insn, 1);
1281 }"
1282 [(set_attr "type" "cbranch")
1283  (set (attr "length")
1284     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1285                       (const_int 8184))
1286            (const_int 4)
1287            (const_int 8)))])
1288
1289 (define_insn ""
1290   [(set (pc)
1291         (if_then_else
1292          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1293                               (const_int 1)
1294                               (match_operand:SI 1 "register_operand" "q"))
1295              (const_int 0))
1296          (pc)
1297          (label_ref (match_operand 2 "" ""))))]
1298   ""
1299   "*
1300 {
1301   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
1302                      get_attr_length (insn), 1, insn, 1);
1303 }"
1304 [(set_attr "type" "cbranch")
1305  (set (attr "length")
1306     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1307                       (const_int 8184))
1308            (const_int 4)
1309            (const_int 8)))])
1310
1311 ;; Floating point branches
1312 (define_insn ""
1313   [(set (pc) (if_then_else (ne (reg:CCFP 0) (const_int 0))
1314                            (label_ref (match_operand 0 "" ""))
1315                            (pc)))]
1316   "! TARGET_SOFT_FLOAT"
1317   "*
1318 {
1319   if (INSN_ANNULLED_BRANCH_P (insn))
1320     return \"ftest\;b,n %0\";
1321   else
1322     return \"ftest\;b%* %0\";
1323 }"
1324   [(set_attr "type" "fbranch")
1325    (set_attr "length" "8")])
1326
1327 (define_insn ""
1328   [(set (pc) (if_then_else (ne (reg:CCFP 0) (const_int 0))
1329                            (pc)
1330                            (label_ref (match_operand 0 "" ""))))]
1331   "! TARGET_SOFT_FLOAT"
1332   "*
1333 {
1334   if (INSN_ANNULLED_BRANCH_P (insn))
1335     return \"ftest\;add,tr %%r0,%%r0,%%r0\;b,n %0\";
1336   else
1337     return \"ftest\;add,tr %%r0,%%r0,%%r0\;b%* %0\";
1338 }"
1339   [(set_attr "type" "fbranch")
1340    (set_attr "length" "12")])
1341
1342 ;; Move instructions
1343
1344 (define_expand "movsi"
1345   [(set (match_operand:SI 0 "general_operand" "")
1346         (match_operand:SI 1 "general_operand" ""))]
1347   ""
1348   "
1349 {
1350   if (emit_move_sequence (operands, SImode, 0))
1351     DONE;
1352 }")
1353
1354 ;; Reloading an SImode or DImode value requires a scratch register if
1355 ;; going in to or out of float point registers.
1356
1357 (define_expand "reload_insi"
1358   [(set (match_operand:SI 0 "register_operand" "=Z")
1359         (match_operand:SI 1 "non_hard_reg_operand" ""))
1360    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
1361   ""
1362   "
1363 {
1364   if (emit_move_sequence (operands, SImode, operands[2]))
1365     DONE;
1366
1367   /* We don't want the clobber emitted, so handle this ourselves.  */
1368   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
1369   DONE;
1370 }")
1371
1372 (define_expand "reload_outsi"
1373   [(set (match_operand:SI 0 "non_hard_reg_operand" "")
1374         (match_operand:SI 1  "register_operand" "Z"))
1375    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
1376   ""
1377   "
1378 {
1379   if (emit_move_sequence (operands, SImode, operands[2]))
1380     DONE;
1381
1382   /* We don't want the clobber emitted, so handle this ourselves.  */
1383   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
1384   DONE;
1385 }")
1386
1387 ;;; pic symbol references
1388
1389 (define_insn ""
1390   [(set (match_operand:SI 0 "register_operand" "=r")
1391         (mem:SI (plus:SI (match_operand:SI 1 "register_operand" "r")
1392                          (match_operand:SI 2 "symbolic_operand" ""))))]
1393   "flag_pic && operands[1] == pic_offset_table_rtx"
1394   "ldw T'%2(%1),%0"
1395   [(set_attr "type" "load")
1396    (set_attr "length" "4")])
1397
1398 (define_insn ""
1399   [(set (match_operand:SI 0 "reg_or_nonsymb_mem_operand"
1400                                 "=r,r,r,r,r,Q,*q,!f,f,*TR")
1401         (match_operand:SI 1 "move_operand"
1402                                 "r,J,N,K,RQ,rM,rM,!fM,*RT,f"))]
1403   "(register_operand (operands[0], SImode)
1404     || reg_or_0_operand (operands[1], SImode))
1405    && ! TARGET_SOFT_FLOAT"
1406   "@
1407    copy %1,%0
1408    ldi %1,%0
1409    ldil L'%1,%0
1410    zdepi %Z1,%0
1411    ldw%M1 %1,%0
1412    stw%M0 %r1,%0
1413    mtsar %r1
1414    fcpy,sgl %f1,%0
1415    fldw%F1 %1,%0
1416    fstw%F0 %1,%0"
1417   [(set_attr "type" "move,move,move,shift,load,store,move,fpalu,fpload,fpstore")
1418    (set_attr "pa_combine_type" "addmove")
1419    (set_attr "length" "4,4,4,4,4,4,4,4,4,4")])
1420
1421 (define_insn ""
1422   [(set (match_operand:SI 0 "reg_or_nonsymb_mem_operand"
1423                                 "=r,r,r,r,r,Q,*q")
1424         (match_operand:SI 1 "move_operand"
1425                                 "r,J,N,K,RQ,rM,rM"))]
1426   "(register_operand (operands[0], SImode)
1427     || reg_or_0_operand (operands[1], SImode))
1428    && TARGET_SOFT_FLOAT"
1429   "@
1430    copy %1,%0
1431    ldi %1,%0
1432    ldil L'%1,%0
1433    zdepi %Z1,%0
1434    ldw%M1 %1,%0
1435    stw%M0 %r1,%0
1436    mtsar %r1"
1437   [(set_attr "type" "move,move,move,move,load,store,move")
1438    (set_attr "pa_combine_type" "addmove")
1439    (set_attr "length" "4,4,4,4,4,4,4")])
1440
1441 (define_insn ""
1442   [(set (match_operand:SI 0 "register_operand" "=r")
1443         (mem:SI (plus:SI (match_operand:SI 1 "basereg_operand" "r")
1444                          (match_operand:SI 2 "register_operand" "r"))))]
1445   "! TARGET_DISABLE_INDEXING"
1446   "*
1447 {
1448   /* Reload can create backwards (relative to cse) unscaled index
1449      address modes when eliminating registers and possibly for
1450      pseudos that don't get hard registers.  Deal with it.  */
1451   if (operands[2] == hard_frame_pointer_rtx
1452       || operands[2] == stack_pointer_rtx)
1453     return \"ldwx %1(%2),%0\";
1454   else
1455     return \"ldwx %2(%1),%0\";
1456 }"
1457   [(set_attr "type" "load")
1458    (set_attr "length" "4")])
1459
1460 (define_insn ""
1461   [(set (match_operand:SI 0 "register_operand" "=r")
1462         (mem:SI (plus:SI (match_operand:SI 1 "register_operand" "r")
1463                          (match_operand:SI 2 "basereg_operand" "r"))))]
1464   "! TARGET_DISABLE_INDEXING"
1465   "*
1466 {
1467   /* Reload can create backwards (relative to cse) unscaled index
1468      address modes when eliminating registers and possibly for
1469      pseudos that don't get hard registers.  Deal with it.  */
1470   if (operands[1] == hard_frame_pointer_rtx
1471       || operands[1] == stack_pointer_rtx)
1472     return \"ldwx %2(%1),%0\";
1473   else
1474     return \"ldwx %1(%2),%0\";
1475 }"
1476   [(set_attr "type" "load")
1477    (set_attr "length" "4")])
1478
1479 ;; Load or store with base-register modification.
1480
1481 (define_expand "pre_load"
1482   [(parallel [(set (match_operand:SI 0 "register_operand" "")
1483               (mem (plus (match_operand 1 "register_operand" "")
1484                                (match_operand 2 "pre_cint_operand" ""))))
1485               (set (match_dup 1)
1486                    (plus (match_dup 1) (match_dup 2)))])]
1487   ""
1488   "
1489 {
1490   emit_insn (gen_pre_ldw (operands[0], operands[1], operands[2]));
1491   DONE;
1492 }")
1493
1494 (define_insn "pre_ldw"
1495   [(set (match_operand:SI 0 "register_operand" "=r")
1496         (mem:SI (plus:SI (match_operand:SI 1 "register_operand" "+r")
1497                          (match_operand:SI 2 "pre_cint_operand" ""))))
1498    (set (match_dup 1)
1499         (plus:SI (match_dup 1) (match_dup 2)))]
1500   ""
1501   "*
1502 {
1503   if (INTVAL (operands[2]) < 0)
1504     return \"ldwm %2(%1),%0\";
1505   return \"ldws,mb %2(%1),%0\";
1506 }"
1507   [(set_attr "type" "load")
1508    (set_attr "length" "4")])
1509
1510 (define_insn ""
1511   [(set (mem:SI (plus:SI (match_operand:SI 0 "register_operand" "+r")
1512                          (match_operand:SI 1 "pre_cint_operand" "")))
1513         (match_operand:SI 2 "reg_or_0_operand" "rM"))
1514    (set (match_dup 0)
1515         (plus:SI (match_dup 0) (match_dup 1)))]
1516   ""
1517   "*
1518 {
1519   if (INTVAL (operands[1]) < 0)
1520     return \"stwm %r2,%1(%0)\";
1521   return \"stws,mb %r2,%1(%0)\";
1522 }"
1523   [(set_attr "type" "store")
1524    (set_attr "length" "4")])
1525
1526 (define_insn ""
1527   [(set (match_operand:SI 0 "register_operand" "=r")
1528         (mem:SI (match_operand:SI 1 "register_operand" "+r")))
1529    (set (match_dup 1)
1530         (plus:SI (match_dup 1)
1531                  (match_operand:SI 2 "post_cint_operand" "")))]
1532   ""
1533   "*
1534 {
1535   if (INTVAL (operands[2]) > 0)
1536     return \"ldwm %2(%1),%0\";
1537   return \"ldws,ma %2(%1),%0\";
1538 }"
1539   [(set_attr "type" "load")
1540    (set_attr "length" "4")])
1541
1542 (define_expand "post_store"
1543   [(parallel [(set (mem (match_operand 0 "register_operand" ""))
1544                    (match_operand 1 "reg_or_0_operand" ""))
1545               (set (match_dup 0)
1546                    (plus (match_dup 0)
1547                          (match_operand 2 "post_cint_operand" "")))])]
1548   ""
1549   "
1550 {
1551   emit_insn (gen_post_stw (operands[0], operands[1], operands[2]));
1552   DONE;
1553 }")
1554
1555 (define_insn "post_stw"
1556   [(set (mem:SI (match_operand:SI 0 "register_operand" "+r"))
1557         (match_operand:SI 1 "reg_or_0_operand" "rM"))
1558    (set (match_dup 0)
1559         (plus:SI (match_dup 0)
1560                  (match_operand:SI 2 "post_cint_operand" "")))]
1561   ""
1562   "*
1563 {
1564   if (INTVAL (operands[2]) > 0)
1565     return \"stwm %r1,%2(%0)\";
1566   return \"stws,ma %r1,%2(%0)\";
1567 }"
1568   [(set_attr "type" "store")
1569    (set_attr "length" "4")])
1570
1571 ;; For pic
1572 ;; Note since this pattern can be created at reload time (via movsi), all
1573 ;; the same rules for movsi apply here.  (no new pseudos, no temporaries).
1574 (define_insn "pic_load_label"
1575   [(set (match_operand:SI 0 "register_operand" "=a")
1576         (match_operand:SI 1 "pic_label_operand" ""))]
1577   ""
1578   "*
1579 {
1580   rtx label_rtx = gen_label_rtx ();
1581   rtx xoperands[3];
1582   extern FILE *asm_out_file;
1583
1584   xoperands[0] = operands[0];
1585   xoperands[1] = operands[1];
1586   xoperands[2] = label_rtx;
1587   output_asm_insn (\"bl .+8,%0\", xoperands);
1588   output_asm_insn (\"depi 0,31,2,%0\", xoperands);
1589   ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\",
1590                              CODE_LABEL_NUMBER (label_rtx));
1591
1592   /* If we're trying to load the address of a label that happens to be
1593      close, then we can use a shorter sequence.  */
1594   if (GET_CODE (operands[1]) == LABEL_REF
1595       && insn_addresses
1596       && abs (insn_addresses[INSN_UID (XEXP (operands[1], 0))]
1597                 - insn_addresses[INSN_UID (insn)]) < 8100)
1598     {
1599       /* Prefixing with R% here is wrong, it extracts just 11 bits and is
1600          always non-negative.  */
1601       output_asm_insn (\"ldo %1-%2(%0),%0\", xoperands);
1602     }
1603   else
1604     {
1605       output_asm_insn (\"addil L%%%1-%2,%0\", xoperands);
1606       output_asm_insn (\"ldo R%%%1-%2(%0),%0\", xoperands);
1607     }
1608   return \"\";
1609 }"
1610   [(set_attr "type" "multi")
1611    (set_attr "length" "16")])           ; 12 or 16
1612
1613 (define_insn ""
1614   [(set (match_operand:SI 0 "register_operand" "=a")
1615         (plus:SI (match_operand:SI 1 "register_operand" "r")
1616                  (high:SI (match_operand 2 "" ""))))]
1617   "symbolic_operand (operands[2], Pmode)
1618    && ! function_label_operand (operands[2])
1619    && flag_pic == 2"
1620   "addil LT'%G2,%1"
1621   [(set_attr "type" "binary")
1622    (set_attr "length" "4")])
1623
1624 ; We need this to make sure CSE doesn't simplify a memory load with a
1625 ; symbolic address, whose content it think it knows.  For PIC, what CSE
1626 ; think is the real value will be the address of that value.
1627 (define_insn ""
1628   [(set (match_operand:SI 0 "register_operand" "=r")
1629         (mem:SI
1630           (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
1631                      (unspec:SI
1632                         [(match_operand:SI 2 "symbolic_operand" "")] 0))))]
1633   "*
1634 {
1635   if (flag_pic != 2)
1636     abort ();
1637   return \"ldw RT'%G2(%1),%0\";
1638 }"
1639   [(set_attr "type" "load")
1640    (set_attr "length" "4")])
1641
1642 ;; Always use addil rather than ldil;add sequences.  This allows the
1643 ;; HP linker to eliminate the dp relocation if the symbolic operand
1644 ;; lives in the TEXT space.
1645 (define_insn ""
1646   [(set (match_operand:SI 0 "register_operand" "=a")
1647         (high:SI (match_operand 1 "" "")))]
1648   "symbolic_operand (operands[1], Pmode)
1649    && ! function_label_operand (operands[1])
1650    && ! read_only_operand (operands[1])
1651    && ! flag_pic"
1652   "*
1653 {
1654   if (TARGET_LONG_LOAD_STORE)
1655     return \"addil NLR'%H1,%%r27\;ldo N'%H1(%%r1),%%r1\";
1656   else
1657     return \"addil LR'%H1,%%r27\";
1658 }"
1659   [(set_attr "type" "binary")
1660    (set (attr "length")
1661       (if_then_else (eq (symbol_ref "TARGET_LONG_LOAD_STORE") (const_int 0))
1662                     (const_int 4)
1663                     (const_int 8)))])
1664
1665
1666 ;; This is for use in the prologue/epilogue code.  We need it
1667 ;; to add large constants to a stack pointer or frame pointer.
1668 ;; Because of the additional %r1 pressure, we probably do not
1669 ;; want to use this in general code, so make it available
1670 ;; only after reload.
1671 (define_insn ""
1672   [(set (match_operand:SI 0 "register_operand" "=!a,*r")
1673         (plus:SI (match_operand:SI 1 "register_operand" "r,r")
1674                  (high:SI (match_operand 2 "const_int_operand" ""))))]
1675   "reload_completed"
1676   "@
1677    addil L'%G2,%1
1678    ldil L'%G2,%0\;addl %0,%1,%0"
1679   [(set_attr "type" "binary,binary")
1680    (set_attr "length" "4,8")])
1681
1682 (define_insn ""
1683   [(set (match_operand:SI 0 "register_operand" "=r")
1684         (high:SI (match_operand 1 "" "")))]
1685   "(!flag_pic || !symbolic_operand (operands[1]), Pmode)
1686     && !is_function_label_plus_const (operands[1])"
1687   "*
1688 {
1689   if (symbolic_operand (operands[1], Pmode))
1690     return \"ldil LR'%H1,%0\";
1691   else
1692     return \"ldil L'%G1,%0\";
1693 }"
1694   [(set_attr "type" "move")
1695    (set_attr "length" "4")])
1696
1697 (define_insn ""
1698   [(set (match_operand:SI 0 "register_operand" "=r")
1699         (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
1700                    (match_operand:SI 2 "immediate_operand" "i")))]
1701   "!is_function_label_plus_const (operands[2])"
1702   "*
1703 {
1704   if (flag_pic && symbolic_operand (operands[2], Pmode))
1705     abort ();
1706   else if (symbolic_operand (operands[2], Pmode))
1707     return \"ldo RR'%G2(%1),%0\";
1708   else
1709     return \"ldo R'%G2(%1),%0\";
1710 }"
1711   [(set_attr "type" "move")
1712    (set_attr "length" "4")])
1713
1714 ;; Now that a symbolic_address plus a constant is broken up early
1715 ;; in the compilation phase (for better CSE) we need a special
1716 ;; combiner pattern to load the symbolic address plus the constant
1717 ;; in only 2 instructions. (For cases where the symbolic address
1718 ;; was not a common subexpression.)
1719 (define_split
1720   [(set (match_operand:SI 0 "register_operand" "")
1721         (match_operand:SI 1 "symbolic_operand" ""))
1722    (clobber (match_operand:SI 2 "register_operand" ""))]
1723   "! (flag_pic && pic_label_operand (operands[1], SImode))"
1724   [(set (match_dup 2) (high:SI (match_dup 1)))
1725    (set (match_dup 0) (lo_sum:SI (match_dup 2) (match_dup 1)))]
1726   "")
1727
1728 ;; hppa_legitimize_address goes to a great deal of trouble to
1729 ;; create addresses which use indexing.  In some cases, this
1730 ;; is a lose because there isn't any store instructions which
1731 ;; allow indexed addresses (with integer register source).
1732 ;;
1733 ;; These define_splits try to turn a 3 insn store into
1734 ;; a 2 insn store with some creative RTL rewriting.
1735 (define_split
1736   [(set (mem:SI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
1737                                (match_operand:SI 1 "shadd_operand" ""))
1738                    (plus:SI (match_operand:SI 2 "register_operand" "")
1739                             (match_operand:SI 3 "const_int_operand" ""))))
1740         (match_operand:SI 4 "register_operand" ""))
1741    (clobber (match_operand:SI 5 "register_operand" ""))]
1742   ""
1743   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
1744                                (match_dup 2)))
1745    (set (mem:SI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
1746   "")
1747
1748 (define_split
1749   [(set (mem:HI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
1750                                (match_operand:SI 1 "shadd_operand" ""))
1751                    (plus:SI (match_operand:SI 2 "register_operand" "")
1752                             (match_operand:SI 3 "const_int_operand" ""))))
1753         (match_operand:HI 4 "register_operand" ""))
1754    (clobber (match_operand:SI 5 "register_operand" ""))]
1755   ""
1756   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
1757                                (match_dup 2)))
1758    (set (mem:HI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
1759   "")
1760
1761 (define_split
1762   [(set (mem:QI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
1763                                (match_operand:SI 1 "shadd_operand" ""))
1764                    (plus:SI (match_operand:SI 2 "register_operand" "")
1765                             (match_operand:SI 3 "const_int_operand" ""))))
1766         (match_operand:QI 4 "register_operand" ""))
1767    (clobber (match_operand:SI 5 "register_operand" ""))]
1768   ""
1769   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
1770                                (match_dup 2)))
1771    (set (mem:QI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
1772   "")
1773
1774 (define_expand "movhi"
1775   [(set (match_operand:HI 0 "general_operand" "")
1776         (match_operand:HI 1 "general_operand" ""))]
1777   ""
1778   "
1779 {
1780   if (emit_move_sequence (operands, HImode, 0))
1781     DONE;
1782 }")
1783
1784 (define_insn ""
1785   [(set (match_operand:HI 0 "reg_or_nonsymb_mem_operand" "=r,r,r,r,r,Q,*q,!f")
1786         (match_operand:HI 1 "move_operand" "r,J,N,K,RQ,rM,rM,!fM"))]
1787   "register_operand (operands[0], HImode)
1788    || reg_or_0_operand (operands[1], HImode)"
1789   "@
1790    copy %1,%0
1791    ldi %1,%0
1792    ldil L'%1,%0
1793    zdepi %Z1,%0
1794    ldh%M1 %1,%0
1795    sth%M0 %r1,%0
1796    mtsar %r1
1797    fcpy,sgl %f1,%0"
1798   [(set_attr "type" "move,move,move,shift,load,store,move,fpalu")
1799    (set_attr "pa_combine_type" "addmove")
1800    (set_attr "length" "4,4,4,4,4,4,4,4")])
1801
1802 (define_insn ""
1803   [(set (match_operand:HI 0 "register_operand" "=r")
1804         (mem:HI (plus:SI (match_operand:SI 1 "basereg_operand" "r")
1805                          (match_operand:SI 2 "register_operand" "r"))))]
1806   "! TARGET_DISABLE_INDEXING"
1807   "*
1808 {
1809   /* Reload can create backwards (relative to cse) unscaled index
1810      address modes when eliminating registers and possibly for
1811      pseudos that don't get hard registers.  Deal with it.  */
1812   if (operands[2] == hard_frame_pointer_rtx
1813       || operands[2] == stack_pointer_rtx)
1814     return \"ldhx %1(%2),%0\";
1815   else
1816     return \"ldhx %2(%1),%0\";
1817 }"
1818   [(set_attr "type" "load")
1819    (set_attr "length" "4")])
1820
1821 (define_insn ""
1822   [(set (match_operand:HI 0 "register_operand" "=r")
1823         (mem:HI (plus:SI (match_operand:SI 1 "register_operand" "r")
1824                          (match_operand:SI 2 "basereg_operand" "r"))))]
1825   "! TARGET_DISABLE_INDEXING"
1826   "*
1827 {
1828   /* Reload can create backwards (relative to cse) unscaled index
1829      address modes when eliminating registers and possibly for
1830      pseudos that don't get hard registers.  Deal with it.  */
1831   if (operands[1] == hard_frame_pointer_rtx
1832       || operands[1] == stack_pointer_rtx)
1833     return \"ldhx %2(%1),%0\";
1834   else
1835     return \"ldhx %1(%2),%0\";
1836 }"
1837   [(set_attr "type" "load")
1838    (set_attr "length" "4")])
1839
1840 ; Now zero extended variants.
1841 (define_insn ""
1842   [(set (match_operand:SI 0 "register_operand" "=r")
1843         (zero_extend:SI (mem:HI
1844                           (plus:SI
1845                             (match_operand:SI 1 "basereg_operand" "r")
1846                             (match_operand:SI 2 "register_operand" "r")))))]
1847   "! TARGET_DISABLE_INDEXING"
1848   "*
1849 {
1850   /* Reload can create backwards (relative to cse) unscaled index
1851      address modes when eliminating registers and possibly for
1852      pseudos that don't get hard registers.  Deal with it.  */
1853   if (operands[2] == hard_frame_pointer_rtx
1854       || operands[2] == stack_pointer_rtx)
1855     return \"ldhx %1(%2),%0\";
1856   else
1857     return \"ldhx %2(%1),%0\";
1858 }"
1859   [(set_attr "type" "load")
1860    (set_attr "length" "4")])
1861
1862 (define_insn ""
1863   [(set (match_operand:SI 0 "register_operand" "=r")
1864         (zero_extend:SI (mem:HI
1865                           (plus:SI
1866                              (match_operand:SI 1 "register_operand" "r")
1867                              (match_operand:SI 2 "basereg_operand" "r")))))]
1868   "! TARGET_DISABLE_INDEXING"
1869   "*
1870 {
1871   /* Reload can create backwards (relative to cse) unscaled index
1872      address modes when eliminating registers and possibly for
1873      pseudos that don't get hard registers.  Deal with it.  */
1874   if (operands[1] == hard_frame_pointer_rtx
1875       || operands[1] == stack_pointer_rtx)
1876     return \"ldhx %2(%1),%0\";
1877   else
1878     return \"ldhx %1(%2),%0\";
1879 }"
1880   [(set_attr "type" "load")
1881    (set_attr "length" "4")])
1882
1883 (define_insn ""
1884   [(set (match_operand:HI 0 "register_operand" "=r")
1885         (mem:HI (plus:SI (match_operand:SI 1 "register_operand" "+r")
1886                          (match_operand:SI 2 "int5_operand" "L"))))
1887    (set (match_dup 1)
1888         (plus:SI (match_dup 1) (match_dup 2)))]
1889   ""
1890   "ldhs,mb %2(%1),%0"
1891   [(set_attr "type" "load")
1892    (set_attr "length" "4")])
1893
1894 ; And a zero extended variant.
1895 (define_insn ""
1896   [(set (match_operand:SI 0 "register_operand" "=r")
1897         (zero_extend:SI (mem:HI
1898                           (plus:SI
1899                             (match_operand:SI 1 "register_operand" "+r")
1900                             (match_operand:SI 2 "int5_operand" "L")))))
1901    (set (match_dup 1)
1902         (plus:SI (match_dup 1) (match_dup 2)))]
1903   ""
1904   "ldhs,mb %2(%1),%0"
1905   [(set_attr "type" "load")
1906    (set_attr "length" "4")])
1907
1908 (define_insn ""
1909   [(set (mem:HI (plus:SI (match_operand:SI 0 "register_operand" "+r")
1910                          (match_operand:SI 1 "int5_operand" "L")))
1911         (match_operand:HI 2 "reg_or_0_operand" "rM"))
1912    (set (match_dup 0)
1913         (plus:SI (match_dup 0) (match_dup 1)))]
1914   ""
1915   "sths,mb %r2,%1(%0)"
1916   [(set_attr "type" "store")
1917    (set_attr "length" "4")])
1918
1919 (define_insn ""
1920   [(set (match_operand:HI 0 "register_operand" "=r")
1921         (high:HI (match_operand 1 "const_int_operand" "")))]
1922   ""
1923   "ldil L'%G1,%0"
1924   [(set_attr "type" "move")
1925    (set_attr "length" "4")])
1926
1927 (define_insn ""
1928   [(set (match_operand:HI 0 "register_operand" "=r")
1929         (lo_sum:HI (match_operand:HI 1 "register_operand" "r")
1930                    (match_operand 2 "const_int_operand" "")))]
1931   ""
1932   "ldo R'%G2(%1),%0"
1933   [(set_attr "type" "move")
1934    (set_attr "length" "4")])
1935
1936 (define_expand "movqi"
1937   [(set (match_operand:QI 0 "general_operand" "")
1938         (match_operand:QI 1 "general_operand" ""))]
1939   ""
1940   "
1941 {
1942   if (emit_move_sequence (operands, QImode, 0))
1943     DONE;
1944 }")
1945
1946 (define_insn ""
1947   [(set (match_operand:QI 0 "reg_or_nonsymb_mem_operand" "=r,r,r,r,r,Q,*q,!f")
1948         (match_operand:QI 1 "move_operand" "r,J,N,K,RQ,rM,rM,!fM"))]
1949   "register_operand (operands[0], QImode)
1950    || reg_or_0_operand (operands[1], QImode)"
1951   "@
1952    copy %1,%0
1953    ldi %1,%0
1954    ldil L'%1,%0
1955    zdepi %Z1,%0
1956    ldb%M1 %1,%0
1957    stb%M0 %r1,%0
1958    mtsar %r1
1959    fcpy,sgl %f1,%0"
1960   [(set_attr "type" "move,move,move,shift,load,store,move,fpalu")
1961    (set_attr "pa_combine_type" "addmove")
1962    (set_attr "length" "4,4,4,4,4,4,4,4")])
1963
1964 (define_insn ""
1965   [(set (match_operand:QI 0 "register_operand" "=r")
1966         (mem:QI (plus:SI (match_operand:SI 1 "basereg_operand" "r")
1967                          (match_operand:SI 2 "register_operand" "r"))))]
1968   "! TARGET_DISABLE_INDEXING"
1969   "*
1970 {
1971   /* Reload can create backwards (relative to cse) unscaled index
1972      address modes when eliminating registers and possibly for
1973      pseudos that don't get hard registers.  Deal with it.  */
1974   if (operands[2] == hard_frame_pointer_rtx
1975       || operands[2] == stack_pointer_rtx)
1976     return \"ldbx %1(%2),%0\";
1977   else
1978     return \"ldbx %2(%1),%0\";
1979 }"
1980   [(set_attr "type" "load")
1981    (set_attr "length" "4")])
1982
1983 (define_insn ""
1984   [(set (match_operand:QI 0 "register_operand" "=r")
1985         (mem:QI (plus:SI (match_operand:SI 1 "register_operand" "r")
1986                          (match_operand:SI 2 "basereg_operand" "r"))))]
1987   "! TARGET_DISABLE_INDEXING"
1988   "*
1989 {
1990   /* Reload can create backwards (relative to cse) unscaled index
1991      address modes when eliminating registers and possibly for
1992      pseudos that don't get hard registers.  Deal with it.  */
1993   if (operands[1] == hard_frame_pointer_rtx
1994       || operands[1] == stack_pointer_rtx)
1995     return \"ldbx %2(%1),%0\";
1996   else
1997     return \"ldbx %1(%2),%0\";
1998 }"
1999   [(set_attr "type" "load")
2000    (set_attr "length" "4")])
2001
2002 ; Indexed byte load with zero extension to SImode or HImode.
2003 (define_insn ""
2004   [(set (match_operand:SI 0 "register_operand" "=r")
2005         (zero_extend:SI (mem:QI
2006                           (plus:SI
2007                             (match_operand:SI 1 "basereg_operand" "r")
2008                             (match_operand:SI 2 "register_operand" "r")))))]
2009   "! TARGET_DISABLE_INDEXING"
2010   "*
2011 {
2012   /* Reload can create backwards (relative to cse) unscaled index
2013      address modes when eliminating registers and possibly for
2014      pseudos that don't get hard registers.  Deal with it.  */
2015   if (operands[2] == hard_frame_pointer_rtx
2016       || operands[2] == stack_pointer_rtx)
2017     return \"ldbx %1(%2),%0\";
2018   else
2019     return \"ldbx %2(%1),%0\";
2020 }"
2021   [(set_attr "type" "load")
2022    (set_attr "length" "4")])
2023
2024 (define_insn ""
2025   [(set (match_operand:SI 0 "register_operand" "=r")
2026         (zero_extend:SI (mem:QI
2027                           (plus:SI
2028                             (match_operand:SI 1 "register_operand" "r")
2029                             (match_operand:SI 2 "basereg_operand" "r")))))]
2030   "! TARGET_DISABLE_INDEXING"
2031   "*
2032 {
2033   /* Reload can create backwards (relative to cse) unscaled index
2034      address modes when eliminating registers and possibly for
2035      pseudos that don't get hard registers.  Deal with it.  */
2036   if (operands[1] == hard_frame_pointer_rtx
2037       || operands[1] == stack_pointer_rtx)
2038     return \"ldbx %2(%1),%0\";
2039   else
2040     return \"ldbx %1(%2),%0\";
2041 }"
2042   [(set_attr "type" "load")
2043    (set_attr "length" "4")])
2044
2045 (define_insn ""
2046   [(set (match_operand:HI 0 "register_operand" "=r")
2047         (zero_extend:HI (mem:QI
2048                           (plus:SI
2049                             (match_operand:SI 1 "basereg_operand" "r")
2050                             (match_operand:SI 2 "register_operand" "r")))))]
2051   "! TARGET_DISABLE_INDEXING"
2052   "*
2053 {
2054   /* Reload can create backwards (relative to cse) unscaled index
2055      address modes when eliminating registers and possibly for
2056      pseudos that don't get hard registers.  Deal with it.  */
2057   if (operands[2] == hard_frame_pointer_rtx
2058       || operands[2] == stack_pointer_rtx)
2059     return \"ldbx %1(%2),%0\";
2060   else
2061     return \"ldbx %2(%1),%0\";
2062 }"
2063   [(set_attr "type" "load")
2064    (set_attr "length" "4")])
2065
2066 (define_insn ""
2067   [(set (match_operand:HI 0 "register_operand" "=r")
2068         (zero_extend:HI (mem:QI
2069                           (plus:SI
2070                             (match_operand:SI 1 "register_operand" "r")
2071                             (match_operand:SI 2 "basereg_operand" "r")))))]
2072   "! TARGET_DISABLE_INDEXING"
2073   "*
2074 {
2075   /* Reload can create backwards (relative to cse) unscaled index
2076      address modes when eliminating registers and possibly for
2077      pseudos that don't get hard registers.  Deal with it.  */
2078   if (operands[1] == hard_frame_pointer_rtx
2079       || operands[1] == stack_pointer_rtx)
2080     return \"ldbx %2(%1),%0\";
2081   else
2082     return \"ldbx %1(%2),%0\";
2083 }"
2084   [(set_attr "type" "load")
2085    (set_attr "length" "4")])
2086
2087 (define_insn ""
2088   [(set (match_operand:QI 0 "register_operand" "=r")
2089         (mem:QI (plus:SI (match_operand:SI 1 "register_operand" "+r")
2090                          (match_operand:SI 2 "int5_operand" "L"))))
2091    (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
2092   ""
2093   "ldbs,mb %2(%1),%0"
2094   [(set_attr "type" "load")
2095    (set_attr "length" "4")])
2096
2097 ; Now the same thing with zero extensions.
2098 (define_insn ""
2099   [(set (match_operand:SI 0 "register_operand" "=r")
2100         (zero_extend:SI (mem:QI (plus:SI
2101                                   (match_operand:SI 1 "register_operand" "+r")
2102                                   (match_operand:SI 2 "int5_operand" "L")))))
2103    (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
2104   ""
2105   "ldbs,mb %2(%1),%0"
2106   [(set_attr "type" "load")
2107    (set_attr "length" "4")])
2108
2109 (define_insn ""
2110   [(set (match_operand:HI 0 "register_operand" "=r")
2111         (zero_extend:HI (mem:QI (plus:SI
2112                                   (match_operand:SI 1 "register_operand" "+r")
2113                                   (match_operand:SI 2 "int5_operand" "L")))))
2114    (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
2115   ""
2116   "ldbs,mb %2(%1),%0"
2117   [(set_attr "type" "load")
2118    (set_attr "length" "4")])
2119
2120 (define_insn ""
2121   [(set (mem:QI (plus:SI (match_operand:SI 0 "register_operand" "+r")
2122                          (match_operand:SI 1 "int5_operand" "L")))
2123         (match_operand:QI 2 "reg_or_0_operand" "rM"))
2124    (set (match_dup 0)
2125         (plus:SI (match_dup 0) (match_dup 1)))]
2126   ""
2127   "stbs,mb %r2,%1(%0)"
2128   [(set_attr "type" "store")
2129    (set_attr "length" "4")])
2130
2131 ;; The definition of this insn does not really explain what it does,
2132 ;; but it should suffice
2133 ;; that anything generated as this insn will be recognized as one
2134 ;; and that it will not successfully combine with anything.
2135 (define_expand "movstrsi"
2136   [(parallel [(set (match_operand:BLK 0 "" "")
2137                    (match_operand:BLK 1 "" ""))
2138               (clobber (match_dup 7))
2139               (clobber (match_dup 8))
2140               (clobber (match_dup 4))
2141               (clobber (match_dup 5))
2142               (clobber (match_dup 6))
2143               (use (match_operand:SI 2 "arith_operand" ""))
2144               (use (match_operand:SI 3 "const_int_operand" ""))])]
2145   ""
2146   "
2147 {
2148   int size, align;
2149
2150   /* HP provides very fast block move library routine for the PA;
2151      this routine includes:
2152
2153         4x4 byte at a time block moves,
2154         1x4 byte at a time with alignment checked at runtime with
2155             attempts to align the source and destination as needed
2156         1x1 byte loop
2157
2158      With that in mind, here's the heuristics to try and guess when
2159      the inlined block move will be better than the library block
2160      move:
2161
2162         If the size isn't constant, then always use the library routines.
2163
2164         If the size is large in respect to the known alignment, then use
2165         the library routines.
2166
2167         If the size is small in repsect to the known alignment, then open
2168         code the copy (since that will lead to better scheduling).
2169
2170         Else use the block move pattern.   */
2171
2172   /* Undetermined size, use the library routine.  */
2173   if (GET_CODE (operands[2]) != CONST_INT)
2174     FAIL;
2175
2176   size = INTVAL (operands[2]);
2177   align = INTVAL (operands[3]);
2178   align = align > 4 ? 4 : align;
2179
2180   /* If size/alignment > 8 (eg size is large in respect to alignment),
2181      then use the library routines.  */
2182   if (size / align > 16)
2183     FAIL;
2184
2185   /* This does happen, but not often enough to worry much about.  */
2186   if (size / align < MOVE_RATIO)
2187     FAIL;
2188   
2189   /* Fall through means we're going to use our block move pattern.  */
2190   operands[0]
2191     = change_address (operands[0], VOIDmode,
2192                       copy_to_mode_reg (SImode, XEXP (operands[0], 0)));
2193   operands[1]
2194     = change_address (operands[1], VOIDmode,
2195                       copy_to_mode_reg (SImode, XEXP (operands[1], 0)));
2196   operands[4] = gen_reg_rtx (SImode);
2197   operands[5] = gen_reg_rtx (SImode);
2198   operands[6] = gen_reg_rtx (SImode);
2199   operands[7] = XEXP (operands[0], 0);
2200   operands[8] = XEXP (operands[1], 0);
2201 }")
2202
2203 ;; The operand constraints are written like this to support both compile-time
2204 ;; and run-time determined byte count.  If the count is run-time determined,
2205 ;; the register with the byte count is clobbered by the copying code, and
2206 ;; therefore it is forced to operand 2.  If the count is compile-time
2207 ;; determined, we need two scratch registers for the unrolled code.
2208 (define_insn "movstrsi_internal"
2209   [(set (mem:BLK (match_operand:SI 0 "register_operand" "+r,r"))
2210         (mem:BLK (match_operand:SI 1 "register_operand" "+r,r")))
2211    (clobber (match_dup 0))
2212    (clobber (match_dup 1))
2213    (clobber (match_operand:SI 2 "register_operand" "=r,r"))     ;loop cnt/tmp
2214    (clobber (match_operand:SI 3 "register_operand" "=&r,&r"))   ;item tmp
2215    (clobber (match_operand:SI 6 "register_operand" "=&r,&r"))   ;item tmp2
2216    (use (match_operand:SI 4 "arith_operand" "J,2"))      ;byte count
2217    (use (match_operand:SI 5 "const_int_operand" "n,n"))] ;alignment
2218   ""
2219   "* return output_block_move (operands, !which_alternative);"
2220   [(set_attr "type" "multi,multi")])
2221 \f
2222 ;; Floating point move insns
2223
2224 ;; This pattern forces (set (reg:DF ...) (const_double ...))
2225 ;; to be reloaded by putting the constant into memory when
2226 ;; reg is a floating point register.
2227 ;;
2228 ;; For integer registers we use ldil;ldo to set the appropriate
2229 ;; value.
2230 ;;
2231 ;; This must come before the movdf pattern, and it must be present
2232 ;; to handle obscure reloading cases.
2233 (define_insn ""
2234   [(set (match_operand:DF 0 "register_operand" "=?r,f")
2235         (match_operand:DF 1 "" "?F,m"))]
2236   "GET_CODE (operands[1]) == CONST_DOUBLE
2237    && operands[1] != CONST0_RTX (DFmode)
2238    && ! TARGET_SOFT_FLOAT"
2239   "* return (which_alternative == 0 ? output_move_double (operands)
2240                                     : \"fldd%F1 %1,%0\");"
2241   [(set_attr "type" "move,fpload")
2242    (set_attr "length" "16,4")])
2243
2244 (define_expand "movdf"
2245   [(set (match_operand:DF 0 "general_operand" "")
2246         (match_operand:DF 1 "general_operand" ""))]
2247   ""
2248   "
2249 {
2250   if (emit_move_sequence (operands, DFmode, 0))
2251     DONE;
2252 }")
2253
2254 ;; Reloading an SImode or DImode value requires a scratch register if
2255 ;; going in to or out of float point registers.
2256
2257 (define_expand "reload_indf"
2258   [(set (match_operand:DF 0 "register_operand" "=Z")
2259         (match_operand:DF 1 "non_hard_reg_operand" ""))
2260    (clobber (match_operand:DF 2 "register_operand" "=&r"))]
2261   ""
2262   "
2263 {
2264   if (emit_move_sequence (operands, DFmode, operands[2]))
2265     DONE;
2266
2267   /* We don't want the clobber emitted, so handle this ourselves.  */
2268   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
2269   DONE;
2270 }")
2271
2272 (define_expand "reload_outdf" 
2273  [(set (match_operand:DF 0 "non_hard_reg_operand" "")
2274         (match_operand:DF 1  "register_operand" "Z"))
2275    (clobber (match_operand:DF 2 "register_operand" "=&r"))]
2276   ""
2277   "
2278 {
2279   if (emit_move_sequence (operands, DFmode, operands[2]))
2280     DONE;
2281
2282   /* We don't want the clobber emitted, so handle this ourselves.  */
2283   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
2284   DONE;
2285 }")
2286
2287 (define_insn ""
2288   [(set (match_operand:DF 0 "reg_or_nonsymb_mem_operand"
2289                           "=f,*r,RQ,?o,?Q,f,*r,*r")
2290         (match_operand:DF 1 "reg_or_0_or_nonsymb_mem_operand"
2291                           "fG,*rG,f,*r,*r,RQ,o,RQ"))]
2292   "(register_operand (operands[0], DFmode)
2293     || reg_or_0_operand (operands[1], DFmode))
2294    && ! (GET_CODE (operands[1]) == CONST_DOUBLE
2295          && GET_CODE (operands[0]) == MEM)
2296    && ! TARGET_SOFT_FLOAT"
2297   "*
2298 {
2299   if (FP_REG_P (operands[0]) || FP_REG_P (operands[1])
2300       || operands[1] == CONST0_RTX (DFmode))
2301     return output_fp_move_double (operands);
2302   return output_move_double (operands);
2303 }"
2304   [(set_attr "type" "fpalu,move,fpstore,store,store,fpload,load,load")
2305    (set_attr "length" "4,8,4,8,16,4,8,16")])
2306
2307 (define_insn ""
2308   [(set (match_operand:DF 0 "reg_or_nonsymb_mem_operand"
2309                           "=r,?o,?Q,r,r")
2310         (match_operand:DF 1 "reg_or_0_or_nonsymb_mem_operand"
2311                           "rG,r,r,o,Q"))]
2312   "(register_operand (operands[0], DFmode)
2313     || reg_or_0_operand (operands[1], DFmode))
2314    && TARGET_SOFT_FLOAT"
2315   "*
2316 {
2317   return output_move_double (operands);
2318 }"
2319   [(set_attr "type" "move,store,store,load,load")
2320    (set_attr "length" "8,8,16,8,16")])
2321
2322 (define_insn ""
2323   [(set (match_operand:DF 0 "register_operand" "=fx")
2324         (mem:DF (plus:SI (match_operand:SI 1 "basereg_operand" "r")
2325                          (match_operand:SI 2 "register_operand" "r"))))]
2326   "! TARGET_DISABLE_INDEXING && ! TARGET_SOFT_FLOAT"
2327   "*
2328 {
2329   /* Reload can create backwards (relative to cse) unscaled index
2330      address modes when eliminating registers and possibly for
2331      pseudos that don't get hard registers.  Deal with it.  */
2332   if (operands[2] == hard_frame_pointer_rtx
2333       || operands[2] == stack_pointer_rtx)
2334     return \"flddx %1(%2),%0\";
2335   else
2336     return \"flddx %2(%1),%0\";
2337 }"
2338   [(set_attr "type" "fpload")
2339    (set_attr "length" "4")])
2340
2341 (define_insn ""
2342   [(set (match_operand:DF 0 "register_operand" "=fx")
2343         (mem:DF (plus:SI (match_operand:SI 1 "register_operand" "r")
2344                          (match_operand:SI 2 "basereg_operand" "r"))))]
2345   "! TARGET_DISABLE_INDEXING && ! TARGET_SOFT_FLOAT"
2346   "*
2347 {
2348   /* Reload can create backwards (relative to cse) unscaled index
2349      address modes when eliminating registers and possibly for
2350      pseudos that don't get hard registers.  Deal with it.  */
2351   if (operands[1] == hard_frame_pointer_rtx
2352       || operands[1] == stack_pointer_rtx)
2353     return \"flddx %2(%1),%0\";
2354   else
2355     return \"flddx %1(%2),%0\";
2356 }"
2357   [(set_attr "type" "fpload")
2358    (set_attr "length" "4")])
2359
2360 (define_insn ""
2361   [(set (mem:DF (plus:SI (match_operand:SI 1 "basereg_operand" "r")
2362                          (match_operand:SI 2 "register_operand" "r")))
2363         (match_operand:DF 0 "register_operand" "fx"))]
2364   "! TARGET_DISABLE_INDEXING && ! TARGET_SOFT_FLOAT"
2365   "*
2366 {
2367   /* Reload can create backwards (relative to cse) unscaled index
2368      address modes when eliminating registers and possibly for
2369      pseudos that don't get hard registers.  Deal with it.  */
2370   if (operands[2] == hard_frame_pointer_rtx
2371       || operands[2] == stack_pointer_rtx)
2372     return \"fstdx %0,%1(%2)\";
2373   else
2374     return \"fstdx %0,%2(%1)\";
2375 }"
2376   [(set_attr "type" "fpstore")
2377    (set_attr "length" "4")])
2378
2379 (define_insn ""
2380   [(set (mem:DF (plus:SI (match_operand:SI 1 "register_operand" "r")
2381                          (match_operand:SI 2 "basereg_operand" "r")))
2382         (match_operand:DF 0 "register_operand" "fx"))]
2383   "! TARGET_DISABLE_INDEXING && ! TARGET_SOFT_FLOAT"
2384   "*
2385 {
2386   /* Reload can create backwards (relative to cse) unscaled index
2387      address modes when eliminating registers and possibly for
2388      pseudos that don't get hard registers.  Deal with it.  */
2389   if (operands[1] == hard_frame_pointer_rtx
2390       || operands[1] == stack_pointer_rtx)
2391     return \"fstdx %0,%2(%1)\";
2392   else
2393     return \"fstdx %0,%1(%2)\";
2394 }"
2395   [(set_attr "type" "fpstore")
2396    (set_attr "length" "4")])
2397
2398 (define_expand "movdi"
2399   [(set (match_operand:DI 0 "reg_or_nonsymb_mem_operand" "")
2400         (match_operand:DI 1 "general_operand" ""))]
2401   ""
2402   "
2403 {
2404   if (emit_move_sequence (operands, DImode, 0))
2405     DONE;
2406 }")
2407
2408 (define_expand "reload_indi"
2409   [(set (match_operand:DI 0 "register_operand" "=Z")
2410         (match_operand:DI 1 "non_hard_reg_operand" ""))
2411    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
2412   ""
2413   "
2414 {
2415   if (emit_move_sequence (operands, DImode, operands[2]))
2416     DONE;
2417
2418   /* We don't want the clobber emitted, so handle this ourselves.  */
2419   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
2420   DONE;
2421 }")
2422
2423 (define_expand "reload_outdi"
2424   [(set (match_operand:DI 0 "general_operand" "")
2425         (match_operand:DI 1 "register_operand" "Z"))
2426    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
2427   ""
2428   "
2429 {
2430   if (emit_move_sequence (operands, DImode, operands[2]))
2431     DONE;
2432
2433   /* We don't want the clobber emitted, so handle this ourselves.  */
2434   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
2435   DONE;
2436 }")
2437
2438 (define_insn ""
2439   [(set (match_operand:DI 0 "register_operand" "=r")
2440         (high:DI (match_operand 1 "" "")))]
2441   ""
2442   "*
2443 {
2444   rtx op0 = operands[0];
2445   rtx op1 = operands[1];
2446
2447   if (GET_CODE (op1) == CONST_INT)
2448     {
2449       operands[0] = operand_subword (op0, 1, 0, DImode);
2450       output_asm_insn (\"ldil L'%1,%0\", operands);
2451
2452       operands[0] = operand_subword (op0, 0, 0, DImode);
2453       if (INTVAL (op1) < 0)
2454         output_asm_insn (\"ldi -1,%0\", operands);
2455       else
2456         output_asm_insn (\"ldi 0,%0\", operands);
2457       return \"\";
2458     }
2459   else if (GET_CODE (op1) == CONST_DOUBLE)
2460     {
2461       operands[0] = operand_subword (op0, 1, 0, DImode);
2462       operands[1] = GEN_INT (CONST_DOUBLE_LOW (op1));
2463       output_asm_insn (\"ldil L'%1,%0\", operands);
2464
2465       operands[0] = operand_subword (op0, 0, 0, DImode);
2466       operands[1] = GEN_INT (CONST_DOUBLE_HIGH (op1));
2467       output_asm_insn (singlemove_string (operands), operands);
2468       return \"\";
2469     }
2470   else
2471     abort ();
2472 }"
2473   [(set_attr "type" "move")
2474    (set_attr "length" "8")])
2475
2476 (define_insn ""
2477   [(set (match_operand:DI 0 "reg_or_nonsymb_mem_operand"
2478                           "=r,o,Q,r,r,r,f,f,*TR")
2479         (match_operand:DI 1 "general_operand"
2480                           "rM,r,r,o*R,Q,i,fM,*TR,f"))]
2481   "(register_operand (operands[0], DImode)
2482     || reg_or_0_operand (operands[1], DImode))
2483    && ! TARGET_SOFT_FLOAT"
2484   "*
2485 {
2486   if (FP_REG_P (operands[0]) || FP_REG_P (operands[1])
2487       || (operands[1] == CONST0_RTX (DImode)))
2488     return output_fp_move_double (operands);
2489   return output_move_double (operands);
2490 }"
2491   [(set_attr "type" "move,store,store,load,load,multi,fpalu,fpload,fpstore")
2492    (set_attr "length" "8,8,16,8,16,16,4,4,4")])
2493
2494 (define_insn ""
2495   [(set (match_operand:DI 0 "reg_or_nonsymb_mem_operand"
2496                           "=r,o,Q,r,r,r")
2497         (match_operand:DI 1 "general_operand"
2498                           "rM,r,r,o,Q,i"))]
2499   "(register_operand (operands[0], DImode)
2500     || reg_or_0_operand (operands[1], DImode))
2501    && TARGET_SOFT_FLOAT"
2502   "*
2503 {
2504   return output_move_double (operands);
2505 }"
2506   [(set_attr "type" "move,store,store,load,load,multi")
2507    (set_attr "length" "8,8,16,8,16,16")])
2508
2509 (define_insn ""
2510   [(set (match_operand:DI 0 "register_operand" "=r,&r")
2511         (lo_sum:DI (match_operand:DI 1 "register_operand" "0,r")
2512                    (match_operand:DI 2 "immediate_operand" "i,i")))]
2513   ""
2514   "*
2515 {
2516   /* Don't output a 64 bit constant, since we can't trust the assembler to
2517      handle it correctly.  */
2518   if (GET_CODE (operands[2]) == CONST_DOUBLE)
2519     operands[2] = GEN_INT (CONST_DOUBLE_LOW (operands[2]));
2520   if (which_alternative == 1)
2521     output_asm_insn (\"copy %1,%0\", operands);
2522   return \"ldo R'%G2(%R1),%R0\";
2523 }"
2524   [(set_attr "type" "move,move")
2525    (set_attr "length" "4,8")])
2526
2527 ;; This pattern forces (set (reg:SF ...) (const_double ...))
2528 ;; to be reloaded by putting the constant into memory when
2529 ;; reg is a floating point register.
2530 ;;
2531 ;; For integer registers we use ldil;ldo to set the appropriate
2532 ;; value.
2533 ;;
2534 ;; This must come before the movsf pattern, and it must be present
2535 ;; to handle obscure reloading cases.
2536 (define_insn ""
2537   [(set (match_operand:SF 0 "register_operand" "=?r,f")
2538         (match_operand:SF 1 "" "?F,m"))]
2539   "GET_CODE (operands[1]) == CONST_DOUBLE
2540    && operands[1] != CONST0_RTX (SFmode)
2541    && ! TARGET_SOFT_FLOAT"
2542   "* return (which_alternative == 0 ? singlemove_string (operands)
2543                                     : \" fldw%F1 %1,%0\");"
2544   [(set_attr "type" "move,fpload")
2545    (set_attr "length" "8,4")])
2546
2547 (define_expand "movsf"
2548   [(set (match_operand:SF 0 "general_operand" "")
2549         (match_operand:SF 1 "general_operand" ""))]
2550   ""
2551   "
2552 {
2553   if (emit_move_sequence (operands, SFmode, 0))
2554     DONE;
2555 }")
2556
2557 ;; Reloading an SImode or DImode value requires a scratch register if
2558 ;; going in to or out of float point registers.
2559
2560 (define_expand "reload_insf"
2561   [(set (match_operand:SF 0 "register_operand" "=Z")
2562         (match_operand:SF 1 "non_hard_reg_operand" ""))
2563    (clobber (match_operand:SF 2 "register_operand" "=&r"))]
2564   ""
2565   "
2566 {
2567   if (emit_move_sequence (operands, SFmode, operands[2]))
2568     DONE;
2569
2570   /* We don't want the clobber emitted, so handle this ourselves.  */
2571   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
2572   DONE;
2573 }")
2574
2575 (define_expand "reload_outsf"
2576   [(set (match_operand:SF 0 "non_hard_reg_operand" "")
2577         (match_operand:SF 1  "register_operand" "Z"))
2578    (clobber (match_operand:SF 2 "register_operand" "=&r"))]
2579   ""
2580   "
2581 {
2582   if (emit_move_sequence (operands, SFmode, operands[2]))
2583     DONE;
2584
2585   /* We don't want the clobber emitted, so handle this ourselves.  */
2586   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
2587   DONE;
2588 }")
2589
2590 (define_insn ""
2591   [(set (match_operand:SF 0 "reg_or_nonsymb_mem_operand"
2592                           "=f,r,f,r,RQ,Q")
2593         (match_operand:SF 1 "reg_or_0_or_nonsymb_mem_operand"
2594                           "fG,rG,RQ,RQ,f,rG"))]
2595   "(register_operand (operands[0], SFmode)
2596     || reg_or_0_operand (operands[1], SFmode))
2597    && ! TARGET_SOFT_FLOAT"
2598   "@
2599    fcpy,sgl %f1,%0
2600    copy %r1,%0
2601    fldw%F1 %1,%0
2602    ldw%M1 %1,%0
2603    fstw%F0 %r1,%0
2604    stw%M0 %r1,%0"
2605   [(set_attr "type" "fpalu,move,fpload,load,fpstore,store")
2606    (set_attr "pa_combine_type" "addmove")
2607    (set_attr "length" "4,4,4,4,4,4")])
2608
2609 (define_insn ""
2610   [(set (match_operand:SF 0 "reg_or_nonsymb_mem_operand"
2611                           "=r,r,Q")
2612         (match_operand:SF 1 "reg_or_0_or_nonsymb_mem_operand"
2613                           "rG,RQ,rG"))]
2614   "(register_operand (operands[0], SFmode)
2615     || reg_or_0_operand (operands[1], SFmode))
2616    && TARGET_SOFT_FLOAT"
2617   "@
2618    copy %r1,%0
2619    ldw%M1 %1,%0
2620    stw%M0 %r1,%0"
2621   [(set_attr "type" "move,load,store")
2622    (set_attr "pa_combine_type" "addmove")
2623    (set_attr "length" "4,4,4")])
2624
2625 (define_insn ""
2626   [(set (match_operand:SF 0 "register_operand" "=fx")
2627         (mem:SF (plus:SI (match_operand:SI 1 "basereg_operand" "r")
2628                          (match_operand:SI 2 "register_operand" "r"))))]
2629   "! TARGET_DISABLE_INDEXING && ! TARGET_SOFT_FLOAT"
2630   "*
2631 {
2632   /* Reload can create backwards (relative to cse) unscaled index
2633      address modes when eliminating registers and possibly for
2634      pseudos that don't get hard registers.  Deal with it.  */
2635   if (operands[2] == hard_frame_pointer_rtx
2636       || operands[2] == stack_pointer_rtx)
2637     return \"fldwx %1(%2),%0\";
2638   else
2639     return \"fldwx %2(%1),%0\";
2640 }"
2641   [(set_attr "type" "fpload")
2642    (set_attr "length" "4")])
2643
2644 (define_insn ""
2645   [(set (match_operand:SF 0 "register_operand" "=fx")
2646         (mem:SF (plus:SI (match_operand:SI 1 "register_operand" "r")
2647                          (match_operand:SI 2 "basereg_operand" "r"))))]
2648   "! TARGET_DISABLE_INDEXING && ! TARGET_SOFT_FLOAT"
2649   "*
2650 {
2651   /* Reload can create backwards (relative to cse) unscaled index
2652      address modes when eliminating registers and possibly for
2653      pseudos that don't get hard registers.  Deal with it.  */
2654   if (operands[1] == hard_frame_pointer_rtx
2655       || operands[1] == stack_pointer_rtx)
2656     return \"fldwx %2(%1),%0\";
2657   else
2658     return \"fldwx %1(%2),%0\";
2659 }"
2660   [(set_attr "type" "fpload")
2661    (set_attr "length" "4")])
2662
2663 (define_insn ""
2664   [(set (mem:SF (plus:SI (match_operand:SI 1 "basereg_operand" "r")
2665                          (match_operand:SI 2 "register_operand" "r")))
2666       (match_operand:SF 0 "register_operand" "fx"))]
2667   "! TARGET_DISABLE_INDEXING && ! TARGET_SOFT_FLOAT"
2668   "*
2669 {
2670   /* Reload can create backwards (relative to cse) unscaled index
2671      address modes when eliminating registers and possibly for
2672      pseudos that don't get hard registers.  Deal with it.  */
2673   if (operands[2] == hard_frame_pointer_rtx
2674       || operands[2] == stack_pointer_rtx)
2675     return \"fstwx %0,%1(%2)\";
2676   else
2677     return \"fstwx %0,%2(%1)\";
2678 }"
2679   [(set_attr "type" "fpstore")
2680    (set_attr "length" "4")])
2681 \f
2682 (define_insn ""
2683   [(set (mem:SF (plus:SI (match_operand:SI 1 "register_operand" "r")
2684                          (match_operand:SI 2 "basereg_operand" "r")))
2685       (match_operand:SF 0 "register_operand" "fx"))]
2686   "! TARGET_DISABLE_INDEXING && ! TARGET_SOFT_FLOAT"
2687   "*
2688 {
2689   /* Reload can create backwards (relative to cse) unscaled index
2690      address modes when eliminating registers and possibly for
2691      pseudos that don't get hard registers.  Deal with it.  */
2692   if (operands[1] == hard_frame_pointer_rtx
2693       || operands[1] == stack_pointer_rtx)
2694     return \"fstwx %0,%2(%1)\";
2695   else
2696     return \"fstwx %0,%1(%2)\";
2697 }"
2698   [(set_attr "type" "fpstore")
2699    (set_attr "length" "4")])
2700 \f
2701
2702 ;;- zero extension instructions
2703 ;; We have define_expand for zero extension patterns to make sure the
2704 ;; operands get loaded into registers.  The define_insns accept
2705 ;; memory operands.  This gives us better overall code than just
2706 ;; having a pattern that does or does not accept memory operands.
2707
2708 (define_expand "zero_extendhisi2"
2709   [(set (match_operand:SI 0 "register_operand" "")
2710         (zero_extend:SI
2711          (match_operand:HI 1 "register_operand" "")))]
2712   ""
2713   "")
2714
2715 (define_insn ""
2716   [(set (match_operand:SI 0 "register_operand" "=r,r")
2717         (zero_extend:SI
2718          (match_operand:HI 1 "move_operand" "r,RQ")))]
2719   "GET_CODE (operands[1]) != CONST_INT"
2720   "@
2721    extru %1,31,16,%0
2722    ldh%M1 %1,%0"
2723   [(set_attr "type" "shift,load")
2724    (set_attr "length" "4,4")])
2725
2726 (define_expand "zero_extendqihi2"
2727   [(set (match_operand:HI 0 "register_operand" "")
2728         (zero_extend:HI
2729          (match_operand:QI 1 "register_operand" "")))]
2730   ""
2731   "")
2732
2733 (define_insn ""
2734   [(set (match_operand:HI 0 "register_operand" "=r,r")
2735         (zero_extend:HI
2736          (match_operand:QI 1 "move_operand" "r,RQ")))]
2737   "GET_CODE (operands[1]) != CONST_INT"
2738   "@
2739    extru %1,31,8,%0
2740    ldb%M1 %1,%0"
2741   [(set_attr "type" "shift,load")
2742    (set_attr "length" "4,4")])
2743
2744 (define_expand "zero_extendqisi2"
2745   [(set (match_operand:SI 0 "register_operand" "")
2746         (zero_extend:SI
2747          (match_operand:QI 1 "register_operand" "")))]
2748   ""
2749   "")
2750
2751 (define_insn ""
2752   [(set (match_operand:SI 0 "register_operand" "=r,r")
2753         (zero_extend:SI
2754          (match_operand:QI 1 "move_operand" "r,RQ")))]
2755   "GET_CODE (operands[1]) != CONST_INT"
2756   "@
2757    extru %1,31,8,%0
2758    ldb%M1 %1,%0"
2759   [(set_attr "type" "shift,load")
2760    (set_attr "length" "4,4")])
2761
2762 ;;- sign extension instructions
2763
2764 (define_insn "extendhisi2"
2765   [(set (match_operand:SI 0 "register_operand" "=r")
2766         (sign_extend:SI (match_operand:HI 1 "register_operand" "r")))]
2767   ""
2768   "extrs %1,31,16,%0"
2769   [(set_attr "type" "shift")
2770    (set_attr "length" "4")])
2771
2772 (define_insn "extendqihi2"
2773   [(set (match_operand:HI 0 "register_operand" "=r")
2774         (sign_extend:HI (match_operand:QI 1 "register_operand" "r")))]
2775   ""
2776   "extrs %1,31,8,%0"
2777   [(set_attr "type" "shift") 
2778   (set_attr "length" "4")])
2779
2780 (define_insn "extendqisi2"
2781   [(set (match_operand:SI 0 "register_operand" "=r")
2782         (sign_extend:SI (match_operand:QI 1 "register_operand" "r")))]
2783   ""
2784   "extrs %1,31,8,%0"
2785   [(set_attr "type" "shift")
2786    (set_attr "length" "4")])
2787 \f
2788 ;; Conversions between float and double.
2789
2790 (define_insn "extendsfdf2"
2791   [(set (match_operand:DF 0 "register_operand" "=f")
2792         (float_extend:DF
2793          (match_operand:SF 1 "register_operand" "f")))]
2794   "! TARGET_SOFT_FLOAT"
2795   "fcnvff,sgl,dbl %1,%0"
2796   [(set_attr "type" "fpalu")
2797    (set_attr "length" "4")])
2798
2799 (define_insn "truncdfsf2"
2800   [(set (match_operand:SF 0 "register_operand" "=f")
2801         (float_truncate:SF
2802          (match_operand:DF 1 "register_operand" "f")))]
2803   "! TARGET_SOFT_FLOAT"
2804   "fcnvff,dbl,sgl %1,%0"
2805   [(set_attr "type" "fpalu")
2806    (set_attr "length" "4")])
2807
2808 ;; Conversion between fixed point and floating point.
2809 ;; Note that among the fix-to-float insns
2810 ;; the ones that start with SImode come first.
2811 ;; That is so that an operand that is a CONST_INT
2812 ;; (and therefore lacks a specific machine mode).
2813 ;; will be recognized as SImode (which is always valid)
2814 ;; rather than as QImode or HImode.
2815
2816 ;; This pattern forces (set (reg:SF ...) (float:SF (const_int ...)))
2817 ;; to be reloaded by putting the constant into memory.
2818 ;; It must come before the more general floatsisf2 pattern.
2819 (define_insn ""
2820   [(set (match_operand:SF 0 "register_operand" "=f")
2821         (float:SF (match_operand:SI 1 "const_int_operand" "m")))]
2822   "! TARGET_SOFT_FLOAT"
2823   "fldw%F1 %1,%0\;fcnvxf,sgl,sgl %0,%0"
2824   [(set_attr "type" "fpalu")
2825    (set_attr "length" "8")])
2826
2827 (define_insn "floatsisf2"
2828   [(set (match_operand:SF 0 "register_operand" "=f")
2829         (float:SF (match_operand:SI 1 "register_operand" "f")))]
2830   "! TARGET_SOFT_FLOAT"
2831   "fcnvxf,sgl,sgl %1,%0"
2832   [(set_attr "type" "fpalu")
2833    (set_attr "length" "4")])
2834
2835 ;; This pattern forces (set (reg:DF ...) (float:DF (const_int ...)))
2836 ;; to be reloaded by putting the constant into memory.
2837 ;; It must come before the more general floatsidf2 pattern.
2838 (define_insn ""
2839   [(set (match_operand:DF 0 "register_operand" "=f")
2840         (float:DF (match_operand:SI 1 "const_int_operand" "m")))]
2841   "! TARGET_SOFT_FLOAT"
2842   "fldw%F1 %1,%0\;fcnvxf,sgl,dbl %0,%0"
2843   [(set_attr "type" "fpalu")
2844    (set_attr "length" "8")])
2845
2846 (define_insn "floatsidf2"
2847   [(set (match_operand:DF 0 "register_operand" "=f")
2848         (float:DF (match_operand:SI 1 "register_operand" "f")))]
2849   "! TARGET_SOFT_FLOAT"
2850   "fcnvxf,sgl,dbl %1,%0"
2851   [(set_attr "type" "fpalu")
2852    (set_attr "length" "4")])
2853
2854 (define_expand "floatunssisf2"
2855   [(set (subreg:SI (match_dup 2) 1)
2856         (match_operand:SI 1 "register_operand" ""))
2857    (set (subreg:SI (match_dup 2) 0)
2858         (const_int 0))
2859    (set (match_operand:SF 0 "register_operand" "")
2860         (float:SF (match_dup 2)))]
2861   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
2862   "operands[2] = gen_reg_rtx (DImode);")
2863
2864 (define_expand "floatunssidf2"
2865   [(set (subreg:SI (match_dup 2) 1)
2866         (match_operand:SI 1 "register_operand" ""))
2867    (set (subreg:SI (match_dup 2) 0)
2868         (const_int 0))
2869    (set (match_operand:DF 0 "register_operand" "")
2870         (float:DF (match_dup 2)))]
2871   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
2872   "operands[2] = gen_reg_rtx (DImode);")
2873
2874 (define_insn "floatdisf2"
2875   [(set (match_operand:SF 0 "register_operand" "=f")
2876         (float:SF (match_operand:DI 1 "register_operand" "f")))]
2877   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
2878   "fcnvxf,dbl,sgl %1,%0"
2879   [(set_attr "type" "fpalu")
2880    (set_attr "length" "4")])
2881
2882 (define_insn "floatdidf2"
2883   [(set (match_operand:DF 0 "register_operand" "=f")
2884         (float:DF (match_operand:DI 1 "register_operand" "f")))]
2885   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
2886   "fcnvxf,dbl,dbl %1,%0"
2887   [(set_attr "type" "fpalu")
2888    (set_attr "length" "4")])
2889
2890 ;; Convert a float to an actual integer.
2891 ;; Truncation is performed as part of the conversion.
2892
2893 (define_insn "fix_truncsfsi2"
2894   [(set (match_operand:SI 0 "register_operand" "=f")
2895         (fix:SI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
2896   "! TARGET_SOFT_FLOAT"
2897   "fcnvfxt,sgl,sgl %1,%0"
2898   [(set_attr "type" "fpalu")
2899    (set_attr "length" "4")])
2900
2901 (define_insn "fix_truncdfsi2"
2902   [(set (match_operand:SI 0 "register_operand" "=f")
2903         (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
2904   "! TARGET_SOFT_FLOAT"
2905   "fcnvfxt,dbl,sgl %1,%0"
2906   [(set_attr "type" "fpalu")
2907    (set_attr "length" "4")])
2908
2909 (define_insn "fix_truncsfdi2"
2910   [(set (match_operand:DI 0 "register_operand" "=f")
2911         (fix:DI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
2912   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
2913   "fcnvfxt,sgl,dbl %1,%0"
2914   [(set_attr "type" "fpalu")
2915    (set_attr "length" "4")])
2916
2917 (define_insn "fix_truncdfdi2"
2918   [(set (match_operand:DI 0 "register_operand" "=f")
2919         (fix:DI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
2920   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
2921   "fcnvfxt,dbl,dbl %1,%0"
2922   [(set_attr "type" "fpalu")
2923    (set_attr "length" "4")])
2924 \f
2925 ;;- arithmetic instructions
2926
2927 (define_expand "adddi3"
2928   [(set (match_operand:DI 0 "register_operand" "")
2929         (plus:DI (match_operand:DI 1 "register_operand" "")
2930                  (match_operand:DI 2 "arith11_operand" "")))]
2931   ""
2932   "")
2933
2934 (define_insn ""
2935   [(set (match_operand:DI 0 "register_operand" "=r")
2936         (plus:DI (match_operand:DI 1 "register_operand" "%r")
2937                  (match_operand:DI 2 "arith11_operand" "rI")))]
2938   ""
2939   "*
2940 {
2941   if (GET_CODE (operands[2]) == CONST_INT)
2942     {
2943       if (INTVAL (operands[2]) >= 0)
2944         return \"addi %2,%R1,%R0\;addc %1,0,%0\";
2945       else
2946         return \"addi %2,%R1,%R0\;subb %1,0,%0\";
2947     }
2948   else
2949     return \"add %R2,%R1,%R0\;addc %2,%1,%0\";
2950 }"
2951   [(set_attr "type" "binary")
2952    (set_attr "length" "8")])
2953
2954 (define_insn ""
2955   [(set (match_operand:SI 0 "register_operand" "=r")
2956         (plus:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
2957                  (match_operand:SI 2 "register_operand" "r")))]
2958   ""
2959   "uaddcm %2,%1,%0"
2960   [(set_attr "type" "binary")
2961    (set_attr "length" "4")])
2962
2963 ;; define_splits to optimize cases of adding a constant integer
2964 ;; to a register when the constant does not fit in 14 bits.  */
2965 (define_split
2966   [(set (match_operand:SI 0 "register_operand" "")
2967         (plus:SI (match_operand:SI 1 "register_operand" "")
2968                  (match_operand:SI 2 "const_int_operand" "")))
2969    (clobber (match_operand:SI 4 "register_operand" ""))]
2970   "! cint_ok_for_move (INTVAL (operands[2]))
2971    && VAL_14_BITS_P (INTVAL (operands[2]) >> 1)"
2972   [(set (match_dup 4) (plus:SI (match_dup 1) (match_dup 2)))
2973    (set (match_dup 0) (plus:SI (match_dup 4) (match_dup 3)))]
2974   "
2975 {
2976   int val = INTVAL (operands[2]);
2977   int low = (val < 0) ? -0x2000 : 0x1fff;
2978   int rest = val - low;
2979
2980   operands[2] = GEN_INT (rest);
2981   operands[3] = GEN_INT (low);
2982 }")
2983
2984 (define_split
2985   [(set (match_operand:SI 0 "register_operand" "")
2986         (plus:SI (match_operand:SI 1 "register_operand" "")
2987                  (match_operand:SI 2 "const_int_operand" "")))
2988    (clobber (match_operand:SI 4 "register_operand" ""))]
2989   "! cint_ok_for_move (INTVAL (operands[2]))"
2990   [(set (match_dup 4) (match_dup 2))
2991    (set (match_dup 0) (plus:SI (mult:SI (match_dup 4) (match_dup 3))
2992                                (match_dup 1)))]
2993   "
2994 {
2995   HOST_WIDE_INT intval = INTVAL (operands[2]);
2996
2997   /* Try dividing the constant by 2, then 4, and finally 8 to see
2998      if we can get a constant which can be loaded into a register
2999      in a single instruction (cint_ok_for_move). 
3000
3001      If that fails, try to negate the constant and subtract it
3002      from our input operand.  */
3003   if (intval % 2 == 0 && cint_ok_for_move (intval / 2))
3004     {
3005       operands[2] = GEN_INT (intval / 2);
3006       operands[3] = GEN_INT (2);
3007     }
3008   else if (intval % 4 == 0 && cint_ok_for_move (intval / 4))
3009     {
3010       operands[2] = GEN_INT (intval / 4);
3011       operands[3] = GEN_INT (4);
3012     }
3013   else if (intval % 8 == 0 && cint_ok_for_move (intval / 8))
3014     {
3015       operands[2] = GEN_INT (intval / 8);
3016       operands[3] = GEN_INT (8);
3017     }
3018   else if (cint_ok_for_move (-intval))
3019     {
3020       emit_insn (gen_rtx_SET (VOIDmode, operands[4], GEN_INT (-intval)));
3021       emit_insn (gen_subsi3 (operands[0], operands[1], operands[4]));
3022       DONE;
3023     }
3024   else
3025     FAIL;
3026 }")
3027
3028 (define_insn "addsi3"
3029   [(set (match_operand:SI 0 "register_operand" "=r,r")
3030         (plus:SI (match_operand:SI 1 "register_operand" "%r,r")
3031                  (match_operand:SI 2 "arith_operand" "r,J")))]
3032   ""
3033   "@
3034    addl %1,%2,%0
3035    ldo %2(%1),%0"
3036   [(set_attr "type" "binary,binary")
3037    (set_attr "pa_combine_type" "addmove")
3038    (set_attr "length" "4,4")])
3039
3040 ;; Disgusting kludge to work around reload bugs with frame pointer
3041 ;; elimination.  Similar to other magic reload patterns in the
3042 ;; indexed memory operations.
3043 (define_insn ""
3044   [(set (match_operand:SI 0 "register_operand" "=&r")
3045         (plus:SI (plus:SI (match_operand:SI 1 "register_operand" "%r")
3046                           (match_operand:SI 2 "register_operand" "r"))
3047                  (match_operand:SI 3 "const_int_operand" "rL")))]
3048   "reload_in_progress"
3049   "*
3050 {
3051   if (GET_CODE (operands[3]) == CONST_INT)
3052     return \"ldo %3(%2),%0\;addl %1,%0,%0\";
3053   else
3054     return \"addl %3,%2,%0\;addl %1,%0,%0\";
3055 }"
3056   [(set_attr "type" "binary")
3057    (set_attr "length" "8")])
3058
3059 (define_expand "subdi3"
3060   [(set (match_operand:DI 0 "register_operand" "")
3061         (minus:DI (match_operand:DI 1 "register_operand" "")
3062                   (match_operand:DI 2 "register_operand" "")))]
3063   ""
3064   "")
3065
3066 (define_insn ""
3067   [(set (match_operand:DI 0 "register_operand" "=r")
3068         (minus:DI (match_operand:DI 1 "register_operand" "r")
3069                   (match_operand:DI 2 "register_operand" "r")))]
3070   ""
3071   "sub %R1,%R2,%R0\;subb %1,%2,%0"
3072   [(set_attr "type" "binary")
3073   (set_attr "length" "8")])
3074
3075 (define_insn "subsi3"
3076   [(set (match_operand:SI 0 "register_operand" "=r,r")
3077         (minus:SI (match_operand:SI 1 "arith11_operand" "r,I")
3078                   (match_operand:SI 2 "register_operand" "r,r")))]
3079   ""
3080   "@
3081    sub %1,%2,%0
3082    subi %1,%2,%0"
3083   [(set_attr "type" "binary,binary")
3084    (set_attr "length" "4,4")])
3085
3086 ;; Clobbering a "register_operand" instead of a match_scratch
3087 ;; in operand3 of millicode calls avoids spilling %r1 and
3088 ;; produces better code.
3089
3090 ;; The mulsi3 insns set up registers for the millicode call.
3091 (define_expand "mulsi3"
3092   [(set (reg:SI 26) (match_operand:SI 1 "move_operand" ""))
3093    (set (reg:SI 25) (match_operand:SI 2 "move_operand" ""))
3094    (parallel [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
3095               (clobber (match_dup 3))
3096               (clobber (reg:SI 26))
3097               (clobber (reg:SI 25))
3098               (clobber (reg:SI 31))])
3099    (set (match_operand:SI 0 "general_operand" "") (reg:SI 29))]
3100   ""
3101   "
3102 {
3103   if (TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT)
3104     {
3105       rtx scratch = gen_reg_rtx (DImode);
3106       operands[1] = force_reg (SImode, operands[1]);
3107       operands[2] = force_reg (SImode, operands[2]);
3108       emit_insn (gen_umulsidi3 (scratch, operands[1], operands[2]));
3109       emit_insn (gen_rtx_SET (VOIDmode,
3110                               operands[0],
3111                               gen_rtx_SUBREG (SImode, scratch, 1)));
3112       DONE;
3113     }
3114   operands[3] = gen_reg_rtx (SImode);
3115 }")
3116
3117 (define_insn "umulsidi3"
3118   [(set (match_operand:DI 0 "nonimmediate_operand" "=f")
3119         (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "f"))
3120                  (zero_extend:DI (match_operand:SI 2 "nonimmediate_operand" "f"))))]
3121   "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT"
3122   "xmpyu %1,%2,%0"
3123   [(set_attr "type" "fpmuldbl")
3124    (set_attr "length" "4")])
3125
3126 (define_insn ""
3127   [(set (match_operand:DI 0 "nonimmediate_operand" "=f")
3128         (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "f"))
3129                  (match_operand:DI 2 "uint32_operand" "f")))]
3130   "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT"
3131   "xmpyu %1,%R2,%0"
3132   [(set_attr "type" "fpmuldbl")
3133    (set_attr "length" "4")])
3134
3135 (define_insn ""
3136   [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
3137    (clobber (match_operand:SI 0 "register_operand" "=a"))
3138    (clobber (reg:SI 26))
3139    (clobber (reg:SI 25))
3140    (clobber (reg:SI 31))]
3141   ""
3142   "* return output_mul_insn (0, insn);"
3143   [(set_attr "type" "milli")
3144    (set (attr "length")
3145      (cond [
3146 ;; Target (or stub) within reach
3147             (and (lt (plus (symbol_ref "total_code_bytes") (pc))
3148                      (const_int 240000))
3149                  (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
3150                      (const_int 0)))
3151             (const_int 4)
3152
3153 ;; NO_SPACE_REGS
3154             (ne (symbol_ref "TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS")
3155                 (const_int 0))
3156             (const_int 8)
3157
3158 ;; Out of reach, but not PIC or PORTABLE_RUNTIME
3159 ;; same as NO_SPACE_REGS code
3160             (and (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
3161                      (const_int 0))
3162                  (eq (symbol_ref "flag_pic")
3163                      (const_int 0)))
3164             (const_int 8)]
3165
3166 ;; Out of range and either PIC or PORTABLE_RUNTIME
3167           (const_int 24)))])
3168
3169 ;;; Division and mod.
3170 (define_expand "divsi3"
3171   [(set (reg:SI 26) (match_operand:SI 1 "move_operand" ""))
3172    (set (reg:SI 25) (match_operand:SI 2 "move_operand" ""))
3173    (parallel [(set (reg:SI 29) (div:SI (reg:SI 26) (reg:SI 25)))
3174               (clobber (match_dup 3))
3175               (clobber (reg:SI 26))
3176               (clobber (reg:SI 25))
3177               (clobber (reg:SI 31))])
3178    (set (match_operand:SI 0 "general_operand" "") (reg:SI 29))]
3179   ""
3180   "
3181 {
3182   operands[3] = gen_reg_rtx (SImode);
3183   if (GET_CODE (operands[2]) == CONST_INT && emit_hpdiv_const (operands, 0))
3184     DONE;
3185 }")
3186
3187 (define_insn ""
3188   [(set (reg:SI 29)
3189         (div:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
3190    (clobber (match_operand:SI 1 "register_operand" "=a"))
3191    (clobber (reg:SI 26))
3192    (clobber (reg:SI 25))
3193    (clobber (reg:SI 31))]
3194   ""
3195   "*
3196    return output_div_insn (operands, 0, insn);"
3197   [(set_attr "type" "milli")
3198    (set (attr "length")
3199      (cond [
3200 ;; Target (or stub) within reach
3201             (and (lt (plus (symbol_ref "total_code_bytes") (pc))
3202                      (const_int 240000))
3203                  (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
3204                      (const_int 0)))
3205             (const_int 4)
3206
3207 ;; NO_SPACE_REGS
3208             (ne (symbol_ref "TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS")
3209                 (const_int 0))
3210             (const_int 8)
3211
3212 ;; Out of reach, but not PIC or PORTABLE_RUNTIME
3213 ;; same as NO_SPACE_REGS code
3214             (and (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
3215                      (const_int 0))
3216                  (eq (symbol_ref "flag_pic")
3217                      (const_int 0)))
3218             (const_int 8)]
3219
3220 ;; Out of range and either PIC or PORTABLE_RUNTIME
3221           (const_int 24)))])
3222
3223 (define_expand "udivsi3"
3224   [(set (reg:SI 26) (match_operand:SI 1 "move_operand" ""))
3225    (set (reg:SI 25) (match_operand:SI 2 "move_operand" ""))
3226    (parallel [(set (reg:SI 29) (udiv:SI (reg:SI 26) (reg:SI 25)))
3227               (clobber (match_dup 3))
3228               (clobber (reg:SI 26))
3229               (clobber (reg:SI 25))
3230               (clobber (reg:SI 31))])
3231    (set (match_operand:SI 0 "general_operand" "") (reg:SI 29))]
3232   ""
3233   "
3234 {
3235   operands[3] = gen_reg_rtx (SImode);
3236   if (GET_CODE (operands[2]) == CONST_INT && emit_hpdiv_const (operands, 1))
3237     DONE;
3238 }")
3239
3240 (define_insn ""
3241   [(set (reg:SI 29)
3242         (udiv:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
3243    (clobber (match_operand:SI 1 "register_operand" "=a"))
3244    (clobber (reg:SI 26))
3245    (clobber (reg:SI 25))
3246    (clobber (reg:SI 31))]
3247   ""
3248   "*
3249    return output_div_insn (operands, 1, insn);"
3250   [(set_attr "type" "milli")
3251    (set (attr "length")
3252      (cond [
3253 ;; Target (or stub) within reach
3254             (and (lt (plus (symbol_ref "total_code_bytes") (pc))
3255                      (const_int 240000))
3256                  (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
3257                      (const_int 0)))
3258             (const_int 4)
3259
3260 ;; NO_SPACE_REGS
3261             (ne (symbol_ref "TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS")
3262                 (const_int 0))
3263             (const_int 8)
3264
3265 ;; Out of reach, but not PIC or PORTABLE_RUNTIME
3266 ;; same as NO_SPACE_REGS code
3267             (and (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
3268                      (const_int 0))
3269                  (eq (symbol_ref "flag_pic")
3270                      (const_int 0)))
3271             (const_int 8)]
3272
3273 ;; Out of range and either PIC or PORTABLE_RUNTIME
3274           (const_int 24)))])
3275
3276 (define_expand "modsi3"
3277   [(set (reg:SI 26) (match_operand:SI 1 "move_operand" ""))
3278    (set (reg:SI 25) (match_operand:SI 2 "move_operand" ""))
3279    (parallel [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
3280               (clobber (match_dup 3))
3281               (clobber (reg:SI 26))
3282               (clobber (reg:SI 25))
3283               (clobber (reg:SI 31))])
3284    (set (match_operand:SI 0 "general_operand" "") (reg:SI 29))]
3285   ""
3286   "
3287 {
3288   operands[3] = gen_reg_rtx (SImode);
3289 }")
3290
3291 (define_insn ""
3292   [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
3293    (clobber (match_operand:SI 0 "register_operand" "=a"))
3294    (clobber (reg:SI 26))
3295    (clobber (reg:SI 25))
3296    (clobber (reg:SI 31))]
3297   ""
3298   "*
3299   return output_mod_insn (0, insn);"
3300   [(set_attr "type" "milli")
3301    (set (attr "length")
3302      (cond [
3303 ;; Target (or stub) within reach
3304             (and (lt (plus (symbol_ref "total_code_bytes") (pc))
3305                      (const_int 240000))
3306                  (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
3307                      (const_int 0)))
3308             (const_int 4)
3309
3310 ;; NO_SPACE_REGS
3311             (ne (symbol_ref "TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS")
3312                 (const_int 0))
3313             (const_int 8)
3314
3315 ;; Out of reach, but not PIC or PORTABLE_RUNTIME
3316 ;; same as NO_SPACE_REGS code
3317             (and (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
3318                      (const_int 0))
3319                  (eq (symbol_ref "flag_pic")
3320                      (const_int 0)))
3321             (const_int 8)]
3322
3323 ;; Out of range and either PIC or PORTABLE_RUNTIME
3324           (const_int 24)))])
3325
3326 (define_expand "umodsi3"
3327   [(set (reg:SI 26) (match_operand:SI 1 "move_operand" ""))
3328    (set (reg:SI 25) (match_operand:SI 2 "move_operand" ""))
3329    (parallel [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
3330               (clobber (match_dup 3))
3331               (clobber (reg:SI 26))
3332               (clobber (reg:SI 25))
3333               (clobber (reg:SI 31))])
3334    (set (match_operand:SI 0 "general_operand" "") (reg:SI 29))]
3335   ""
3336   "
3337 {
3338   operands[3] = gen_reg_rtx (SImode);
3339 }")
3340
3341 (define_insn ""
3342   [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
3343    (clobber (match_operand:SI 0 "register_operand" "=a"))
3344    (clobber (reg:SI 26))
3345    (clobber (reg:SI 25))
3346    (clobber (reg:SI 31))]
3347   ""
3348   "*
3349   return output_mod_insn (1, insn);"
3350   [(set_attr "type" "milli")
3351    (set (attr "length")
3352      (cond [
3353 ;; Target (or stub) within reach
3354             (and (lt (plus (symbol_ref "total_code_bytes") (pc))
3355                      (const_int 240000))
3356                  (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
3357                      (const_int 0)))
3358             (const_int 4)
3359
3360 ;; NO_SPACE_REGS
3361             (ne (symbol_ref "TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS")
3362                 (const_int 0))
3363             (const_int 8)
3364
3365 ;; Out of reach, but not PIC or PORTABLE_RUNTIME
3366 ;; same as NO_SPACE_REGS code
3367             (and (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
3368                      (const_int 0))
3369                  (eq (symbol_ref "flag_pic")
3370                      (const_int 0)))
3371             (const_int 8)]
3372
3373 ;; Out of range and either PIC or PORTABLE_RUNTIME
3374           (const_int 24)))])
3375
3376 ;;- and instructions
3377 ;; We define DImode `and` so with DImode `not` we can get
3378 ;; DImode `andn`.  Other combinations are possible.
3379
3380 (define_expand "anddi3"
3381   [(set (match_operand:DI 0 "register_operand" "")
3382         (and:DI (match_operand:DI 1 "arith_double_operand" "")
3383                 (match_operand:DI 2 "arith_double_operand" "")))]
3384   ""
3385   "
3386 {
3387   if (! register_operand (operands[1], DImode)
3388       || ! register_operand (operands[2], DImode))
3389     /* Let GCC break this into word-at-a-time operations.  */
3390     FAIL;
3391 }")
3392
3393 (define_insn ""
3394   [(set (match_operand:DI 0 "register_operand" "=r")
3395         (and:DI (match_operand:DI 1 "register_operand" "%r")
3396                 (match_operand:DI 2 "register_operand" "r")))]
3397   ""
3398   "and %1,%2,%0\;and %R1,%R2,%R0"
3399   [(set_attr "type" "binary")
3400    (set_attr "length" "8")])
3401
3402 ; The ? for op1 makes reload prefer zdepi instead of loading a huge
3403 ; constant with ldil;ldo.
3404 (define_insn "andsi3"
3405   [(set (match_operand:SI 0 "register_operand" "=r,r")
3406         (and:SI (match_operand:SI 1 "register_operand" "%?r,0")
3407                 (match_operand:SI 2 "and_operand" "rO,P")))]
3408   ""
3409   "* return output_and (operands); "
3410   [(set_attr "type" "binary,shift")
3411    (set_attr "length" "4,4")])
3412
3413 (define_insn ""
3414   [(set (match_operand:DI 0 "register_operand" "=r")
3415         (and:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
3416                 (match_operand:DI 2 "register_operand" "r")))]
3417   ""
3418   "andcm %2,%1,%0\;andcm %R2,%R1,%R0"
3419   [(set_attr "type" "binary")
3420    (set_attr "length" "8")])
3421
3422 (define_insn ""
3423   [(set (match_operand:SI 0 "register_operand" "=r")
3424         (and:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
3425                 (match_operand:SI 2 "register_operand" "r")))]
3426   ""
3427   "andcm %2,%1,%0"
3428   [(set_attr "type" "binary")
3429   (set_attr "length" "4")])
3430
3431 (define_expand "iordi3"
3432   [(set (match_operand:DI 0 "register_operand" "")
3433         (ior:DI (match_operand:DI 1 "arith_double_operand" "")
3434                 (match_operand:DI 2 "arith_double_operand" "")))]
3435   ""
3436   "
3437 {
3438   if (! register_operand (operands[1], DImode)
3439       || ! register_operand (operands[2], DImode))
3440     /* Let GCC break this into word-at-a-time operations.  */
3441     FAIL;
3442 }")
3443
3444 (define_insn ""
3445   [(set (match_operand:DI 0 "register_operand" "=r")
3446         (ior:DI (match_operand:DI 1 "register_operand" "%r")
3447                 (match_operand:DI 2 "register_operand" "r")))]
3448   ""
3449   "or %1,%2,%0\;or %R1,%R2,%R0"
3450   [(set_attr "type" "binary")
3451    (set_attr "length" "8")])
3452
3453 ;; Need a define_expand because we've run out of CONST_OK... characters.
3454 (define_expand "iorsi3"
3455   [(set (match_operand:SI 0 "register_operand" "")
3456         (ior:SI (match_operand:SI 1 "register_operand" "")
3457                 (match_operand:SI 2 "arith32_operand" "")))]
3458   ""
3459   "
3460 {
3461   if (! (ior_operand (operands[2], SImode)
3462          || register_operand (operands[2], SImode)))
3463     operands[2] = force_reg (SImode, operands[2]);
3464 }")
3465
3466 (define_insn ""
3467   [(set (match_operand:SI 0 "register_operand" "=r,r")
3468         (ior:SI (match_operand:SI 1 "register_operand" "0,0")
3469                 (match_operand:SI 2 "ior_operand" "M,i")))]
3470   ""
3471   "* return output_ior (operands); "
3472   [(set_attr "type" "binary,shift")
3473    (set_attr "length" "4,4")])
3474
3475 (define_insn ""
3476   [(set (match_operand:SI 0 "register_operand" "=r")
3477         (ior:SI (match_operand:SI 1 "register_operand" "%r")
3478                 (match_operand:SI 2 "register_operand" "r")))]
3479   ""
3480   "or %1,%2,%0"
3481   [(set_attr "type" "binary")
3482    (set_attr "length" "4")])
3483
3484 (define_expand "xordi3"
3485   [(set (match_operand:DI 0 "register_operand" "")
3486         (xor:DI (match_operand:DI 1 "arith_double_operand" "")
3487                 (match_operand:DI 2 "arith_double_operand" "")))]
3488   ""
3489   "
3490 {
3491   if (! register_operand (operands[1], DImode)
3492       || ! register_operand (operands[2], DImode))
3493     /* Let GCC break this into word-at-a-time operations.  */
3494     FAIL;
3495 }")
3496
3497 (define_insn ""
3498   [(set (match_operand:DI 0 "register_operand" "=r")
3499         (xor:DI (match_operand:DI 1 "register_operand" "%r")
3500                 (match_operand:DI 2 "register_operand" "r")))]
3501   ""
3502   "xor %1,%2,%0\;xor %R1,%R2,%R0"
3503   [(set_attr "type" "binary")
3504    (set_attr "length" "8")])
3505
3506 (define_insn "xorsi3"
3507   [(set (match_operand:SI 0 "register_operand" "=r")
3508         (xor:SI (match_operand:SI 1 "register_operand" "%r")
3509                 (match_operand:SI 2 "register_operand" "r")))]
3510   ""
3511   "xor %1,%2,%0"
3512   [(set_attr "type" "binary")
3513    (set_attr "length" "4")])
3514
3515 (define_insn "negdi2"
3516   [(set (match_operand:DI 0 "register_operand" "=r")
3517         (neg:DI (match_operand:DI 1 "register_operand" "r")))]
3518   ""
3519   "sub %%r0,%R1,%R0\;subb %%r0,%1,%0"
3520   [(set_attr "type" "unary")
3521    (set_attr "length" "8")])
3522
3523 (define_insn "negsi2"
3524   [(set (match_operand:SI 0 "register_operand" "=r")
3525         (neg:SI (match_operand:SI 1 "register_operand" "r")))]
3526   ""
3527   "sub %%r0,%1,%0"
3528   [(set_attr "type" "unary")
3529    (set_attr "length" "4")])
3530
3531 (define_expand "one_cmpldi2"
3532   [(set (match_operand:DI 0 "register_operand" "")
3533         (not:DI (match_operand:DI 1 "arith_double_operand" "")))]
3534   ""
3535   "
3536 {
3537   if (! register_operand (operands[1], DImode))
3538     FAIL;
3539 }")
3540
3541 (define_insn ""
3542   [(set (match_operand:DI 0 "register_operand" "=r")
3543         (not:DI (match_operand:DI 1 "register_operand" "r")))]
3544   ""
3545   "uaddcm %%r0,%1,%0\;uaddcm %%r0,%R1,%R0"
3546   [(set_attr "type" "unary")
3547    (set_attr "length" "8")])
3548
3549 (define_insn "one_cmplsi2"
3550   [(set (match_operand:SI 0 "register_operand" "=r")
3551         (not:SI (match_operand:SI 1 "register_operand" "r")))]
3552   ""
3553   "uaddcm %%r0,%1,%0"
3554   [(set_attr "type" "unary")
3555    (set_attr "length" "4")])
3556 \f
3557 ;; Floating point arithmetic instructions.
3558
3559 (define_insn "adddf3"
3560   [(set (match_operand:DF 0 "register_operand" "=f")
3561         (plus:DF (match_operand:DF 1 "register_operand" "f")
3562                  (match_operand:DF 2 "register_operand" "f")))]
3563   "! TARGET_SOFT_FLOAT"
3564   "fadd,dbl %1,%2,%0"
3565   [(set_attr "type" "fpalu")
3566    (set_attr "pa_combine_type" "faddsub")
3567    (set_attr "length" "4")])
3568
3569 (define_insn "addsf3"
3570   [(set (match_operand:SF 0 "register_operand" "=f")
3571         (plus:SF (match_operand:SF 1 "register_operand" "f")
3572                  (match_operand:SF 2 "register_operand" "f")))]
3573   "! TARGET_SOFT_FLOAT"
3574   "fadd,sgl %1,%2,%0"
3575   [(set_attr "type" "fpalu")
3576    (set_attr "pa_combine_type" "faddsub")
3577    (set_attr "length" "4")])
3578
3579 (define_insn "subdf3"
3580   [(set (match_operand:DF 0 "register_operand" "=f")
3581         (minus:DF (match_operand:DF 1 "register_operand" "f")
3582                   (match_operand:DF 2 "register_operand" "f")))]
3583   "! TARGET_SOFT_FLOAT"
3584   "fsub,dbl %1,%2,%0"
3585   [(set_attr "type" "fpalu")
3586    (set_attr "pa_combine_type" "faddsub")
3587    (set_attr "length" "4")])
3588
3589 (define_insn "subsf3"
3590   [(set (match_operand:SF 0 "register_operand" "=f")
3591         (minus:SF (match_operand:SF 1 "register_operand" "f")
3592                   (match_operand:SF 2 "register_operand" "f")))]
3593   "! TARGET_SOFT_FLOAT"
3594   "fsub,sgl %1,%2,%0"
3595   [(set_attr "type" "fpalu")
3596    (set_attr "pa_combine_type" "faddsub")
3597    (set_attr "length" "4")])
3598
3599 (define_insn "muldf3"
3600   [(set (match_operand:DF 0 "register_operand" "=f")
3601         (mult:DF (match_operand:DF 1 "register_operand" "f")
3602                  (match_operand:DF 2 "register_operand" "f")))]
3603   "! TARGET_SOFT_FLOAT"
3604   "fmpy,dbl %1,%2,%0"
3605   [(set_attr "type" "fpmuldbl")
3606    (set_attr "pa_combine_type" "fmpy")
3607    (set_attr "length" "4")])
3608
3609 (define_insn "mulsf3"
3610   [(set (match_operand:SF 0 "register_operand" "=f")
3611         (mult:SF (match_operand:SF 1 "register_operand" "f")
3612                  (match_operand:SF 2 "register_operand" "f")))]
3613   "! TARGET_SOFT_FLOAT"
3614   "fmpy,sgl %1,%2,%0"
3615   [(set_attr "type" "fpmulsgl")
3616    (set_attr "pa_combine_type" "fmpy")
3617    (set_attr "length" "4")])
3618
3619 (define_insn "divdf3"
3620   [(set (match_operand:DF 0 "register_operand" "=f")
3621         (div:DF (match_operand:DF 1 "register_operand" "f")
3622                 (match_operand:DF 2 "register_operand" "f")))]
3623   "! TARGET_SOFT_FLOAT"
3624   "fdiv,dbl %1,%2,%0"
3625   [(set_attr "type" "fpdivdbl")
3626    (set_attr "length" "4")])
3627
3628 (define_insn "divsf3"
3629   [(set (match_operand:SF 0 "register_operand" "=f")
3630         (div:SF (match_operand:SF 1 "register_operand" "f")
3631                 (match_operand:SF 2 "register_operand" "f")))]
3632   "! TARGET_SOFT_FLOAT"
3633   "fdiv,sgl %1,%2,%0"
3634   [(set_attr "type" "fpdivsgl")
3635    (set_attr "length" "4")])
3636
3637 (define_insn "negdf2"
3638   [(set (match_operand:DF 0 "register_operand" "=f")
3639         (neg:DF (match_operand:DF 1 "register_operand" "f")))]
3640   "! TARGET_SOFT_FLOAT"
3641   "*
3642 {
3643   if (TARGET_PA_20)
3644     return \"fneg,dbl %1,%0\";
3645   else
3646     return \"fsub,dbl %%fr0,%1,%0\";
3647 }"
3648   [(set_attr "type" "fpalu")
3649    (set_attr "length" "4")])
3650
3651 (define_insn "negsf2"
3652   [(set (match_operand:SF 0 "register_operand" "=f")
3653         (neg:SF (match_operand:SF 1 "register_operand" "f")))]
3654   "! TARGET_SOFT_FLOAT"
3655   "*
3656 {
3657   if (TARGET_PA_20)
3658     return \"fneg,sgl %1,%0\";
3659   else
3660     return \"fsub,sgl %%fr0,%1,%0\";
3661 }"
3662   [(set_attr "type" "fpalu")
3663    (set_attr "length" "4")])
3664
3665 (define_insn "absdf2"
3666   [(set (match_operand:DF 0 "register_operand" "=f")
3667         (abs:DF (match_operand:DF 1 "register_operand" "f")))]
3668   "! TARGET_SOFT_FLOAT"
3669   "fabs,dbl %1,%0"
3670   [(set_attr "type" "fpalu")
3671    (set_attr "length" "4")])
3672
3673 (define_insn "abssf2"
3674   [(set (match_operand:SF 0 "register_operand" "=f")
3675         (abs:SF (match_operand:SF 1 "register_operand" "f")))]
3676   "! TARGET_SOFT_FLOAT"
3677   "fabs,sgl %1,%0"
3678   [(set_attr "type" "fpalu")
3679    (set_attr "length" "4")])
3680
3681 (define_insn "sqrtdf2"
3682   [(set (match_operand:DF 0 "register_operand" "=f")
3683         (sqrt:DF (match_operand:DF 1 "register_operand" "f")))]
3684   "! TARGET_SOFT_FLOAT"
3685   "fsqrt,dbl %1,%0"
3686   [(set_attr "type" "fpsqrtdbl")
3687    (set_attr "length" "4")])
3688
3689 (define_insn "sqrtsf2"
3690   [(set (match_operand:SF 0 "register_operand" "=f")
3691         (sqrt:SF (match_operand:SF 1 "register_operand" "f")))]
3692   "! TARGET_SOFT_FLOAT"
3693   "fsqrt,sgl %1,%0"
3694   [(set_attr "type" "fpsqrtsgl")
3695    (set_attr "length" "4")])
3696
3697 ;; PA 2.0 floating point instructions
3698
3699 ; fmpyfadd patterns
3700 (define_insn ""
3701   [(set (match_operand:DF 0 "register_operand" "=f")
3702         (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
3703                           (match_operand:DF 2 "register_operand" "f"))
3704                  (match_operand:DF 3 "register_operand" "f")))]
3705   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
3706   "fmpyfadd,dbl %1,%2,%3,%0"
3707   [(set_attr "type" "fpmuldbl")
3708    (set_attr "length" "4")])
3709
3710 (define_insn ""
3711   [(set (match_operand:DF 0 "register_operand" "=f")
3712         (plus:DF (match_operand:DF 1 "register_operand" "f")
3713                  (mult:DF (match_operand:DF 2 "register_operand" "f")
3714                           (match_operand:DF 3 "register_operand" "f"))))]
3715   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
3716   "fmpyfadd,dbl %2,%3,%1,%0"
3717   [(set_attr "type" "fpmuldbl")
3718    (set_attr "length" "4")])
3719
3720 (define_insn ""
3721   [(set (match_operand:SF 0 "register_operand" "=f")
3722         (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
3723                           (match_operand:SF 2 "register_operand" "f"))
3724                  (match_operand:SF 3 "register_operand" "f")))]
3725   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
3726   "fmpyfadd,sgl %1,%2,%3,%0"
3727   [(set_attr "type" "fpmulsgl")
3728    (set_attr "length" "4")])
3729
3730 (define_insn ""
3731   [(set (match_operand:SF 0 "register_operand" "=f")
3732         (plus:SF (match_operand:SF 1 "register_operand" "f")
3733                  (mult:SF (match_operand:SF 2 "register_operand" "f")
3734                           (match_operand:SF 3 "register_operand" "f"))))]
3735   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
3736   "fmpyfadd,sgl %2,%3,%1,%0"
3737   [(set_attr "type" "fpmulsgl")
3738    (set_attr "length" "4")])
3739
3740 ; fmpynfadd patterns
3741 (define_insn ""
3742   [(set (match_operand:DF 0 "register_operand" "=f")
3743         (minus:DF (match_operand:DF 1 "register_operand" "f")
3744                   (mult:DF (match_operand:DF 2 "register_operand" "f")
3745                            (match_operand:DF 3 "register_operand" "f"))))]
3746   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
3747   "fmpynfadd,dbl %2,%3,%1,%0"
3748   [(set_attr "type" "fpmuldbl")
3749    (set_attr "length" "4")])
3750
3751 (define_insn ""
3752   [(set (match_operand:SF 0 "register_operand" "=f")
3753         (minus:SF (match_operand:SF 1 "register_operand" "f")
3754                   (mult:SF (match_operand:SF 2 "register_operand" "f")
3755                            (match_operand:SF 3 "register_operand" "f"))))]
3756   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
3757   "fmpynfadd,sgl %2,%3,%1,%0"
3758   [(set_attr "type" "fpmulsgl")
3759    (set_attr "length" "4")])
3760
3761 ; fnegabs patterns
3762 (define_insn ""
3763   [(set (match_operand:DF 0 "register_operand" "=f")
3764         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))]
3765   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
3766   "fnegabs,dbl %1,%0"
3767   [(set_attr "type" "fpalu")
3768    (set_attr "length" "4")])
3769
3770 (define_insn ""
3771   [(set (match_operand:SF 0 "register_operand" "=f")
3772         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))]
3773   "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
3774   "fnegabs,sgl %1,%0"
3775   [(set_attr "type" "fpalu")
3776    (set_attr "length" "4")])
3777
3778 \f
3779 ;;- Shift instructions
3780
3781 ;; Optimized special case of shifting.
3782
3783 (define_insn ""
3784   [(set (match_operand:SI 0 "register_operand" "=r")
3785         (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
3786                      (const_int 24)))]
3787   ""
3788   "ldb%M1 %1,%0"
3789   [(set_attr "type" "load")
3790    (set_attr "length" "4")])
3791
3792 (define_insn ""
3793   [(set (match_operand:SI 0 "register_operand" "=r")
3794         (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
3795                      (const_int 16)))]
3796   ""
3797   "ldh%M1 %1,%0"
3798   [(set_attr "type" "load")
3799    (set_attr "length" "4")])
3800
3801 (define_insn ""
3802   [(set (match_operand:SI 0 "register_operand" "=r")
3803         (plus:SI (mult:SI (match_operand:SI 2 "register_operand" "r")
3804                           (match_operand:SI 3 "shadd_operand" ""))
3805                  (match_operand:SI 1 "register_operand" "r")))]
3806   ""
3807   "sh%O3addl %2,%1,%0"
3808   [(set_attr "type" "binary")
3809    (set_attr "length" "4")])
3810
3811 ;; This variant of the above insn can occur if the first operand
3812 ;; is the frame pointer.  This is a kludge, but there doesn't
3813 ;; seem to be a way around it.  Only recognize it while reloading.
3814 ;; Note how operand 3 uses a predicate of "const_int_operand", but 
3815 ;; has constraints allowing a register.  I don't know how this works,
3816 ;; but it somehow makes sure that out-of-range constants are placed
3817 ;; in a register which somehow magically is a "const_int_operand".
3818 ;; (this was stolen from alpha.md, I'm not going to try and change it.
3819
3820 (define_insn ""
3821   [(set (match_operand:SI 0 "register_operand" "=&r,r")
3822         (plus:SI (plus:SI (mult:SI (match_operand:SI 2 "register_operand" "r,r")
3823                                    (match_operand:SI 4 "shadd_operand" ""))
3824                           (match_operand:SI 1 "register_operand" "r,r"))
3825                  (match_operand:SI 3 "const_int_operand" "r,J")))]
3826   "reload_in_progress"
3827   "@
3828    sh%O4addl %2,%1,%0\;addl %3,%0,%0
3829    sh%O4addl %2,%1,%0\;ldo %3(%0),%0"
3830   [(set_attr "type" "multi")
3831    (set_attr "length" "8")])
3832
3833 ;; This anonymous pattern and splitter wins because it reduces the latency
3834 ;; of the shadd sequence without increasing the latency of the shift.
3835 ;;
3836 ;; We want to make sure and split up the operations for the scheduler since
3837 ;; these instructions can (and should) schedule independently.
3838 ;;
3839 ;; It would be clearer if combine used the same operator for both expressions,
3840 ;; it's somewhat confusing to have a mult in ine operation and an ashift
3841 ;; in the other.
3842 ;;
3843 ;; If this pattern is not split before register allocation, then we must expose
3844 ;; the fact that operand 4 is set before operands 1, 2 and 3 have been read.
3845 (define_insn ""
3846   [(set (match_operand:SI 0 "register_operand" "=r")
3847         (plus:SI (mult:SI (match_operand:SI 2 "register_operand" "r")
3848                           (match_operand:SI 3 "shadd_operand" ""))
3849                  (match_operand:SI 1 "register_operand" "r")))
3850    (set (match_operand:SI 4 "register_operand" "=&r")
3851         (ashift:SI (match_dup 2)
3852                    (match_operand:SI 5 "const_int_operand" "i")))]
3853   "INTVAL (operands[5]) == exact_log2 (INTVAL (operands[3]))"
3854   "#"
3855   [(set_attr "type" "binary")
3856    (set_attr "length" "8")])
3857
3858 (define_split
3859   [(set (match_operand:SI 0 "register_operand" "=r")
3860         (plus:SI (mult:SI (match_operand:SI 2 "register_operand" "r")
3861                           (match_operand:SI 3 "shadd_operand" ""))
3862                  (match_operand:SI 1 "register_operand" "r")))
3863    (set (match_operand:SI 4 "register_operand" "=&r")
3864         (ashift:SI (match_dup 2)
3865                    (match_operand:SI 5 "const_int_operand" "i")))]
3866   "INTVAL (operands[5]) == exact_log2 (INTVAL (operands[3]))"
3867   [(set (match_dup 4) (ashift:SI (match_dup 2) (match_dup 5)))
3868    (set (match_dup 0) (plus:SI (mult:SI (match_dup 2) (match_dup 3))
3869                                (match_dup 1)))]
3870   "")
3871
3872 (define_expand "ashlsi3"
3873   [(set (match_operand:SI 0 "register_operand" "")
3874         (ashift:SI (match_operand:SI 1 "lhs_lshift_operand" "")
3875                    (match_operand:SI 2 "arith32_operand" "")))]
3876   ""
3877   "
3878 {
3879   if (GET_CODE (operands[2]) != CONST_INT)
3880     {
3881       rtx temp = gen_reg_rtx (SImode);
3882       emit_insn (gen_subsi3 (temp, GEN_INT (31), operands[2]));
3883       if (GET_CODE (operands[1]) == CONST_INT)
3884         emit_insn (gen_zvdep_imm32 (operands[0], operands[1], temp));
3885       else
3886         emit_insn (gen_zvdep32 (operands[0], operands[1], temp));
3887       DONE;
3888     }
3889   /* Make sure both inputs are not constants,
3890      there are no patterns for that.  */
3891   operands[1] = force_reg (SImode, operands[1]);
3892 }")
3893
3894 (define_insn ""
3895   [(set (match_operand:SI 0 "register_operand" "=r")
3896         (ashift:SI (match_operand:SI 1 "register_operand" "r")
3897                    (match_operand:SI 2 "const_int_operand" "n")))]
3898   ""
3899   "zdep %1,%P2,%L2,%0"
3900   [(set_attr "type" "shift")
3901    (set_attr "length" "4")])
3902
3903 ; Match cases of op1 a CONST_INT here that zvdep_imm32 doesn't handle.
3904 ; Doing it like this makes slightly better code since reload can
3905 ; replace a register with a known value in range -16..15 with a
3906 ; constant.  Ideally, we would like to merge zvdep32 and zvdep_imm32,
3907 ; but since we have no more CONST_OK... characters, that is not
3908 ; possible.
3909 (define_insn "zvdep32"
3910   [(set (match_operand:SI 0 "register_operand" "=r,r")
3911         (ashift:SI (match_operand:SI 1 "arith5_operand" "r,L")
3912                    (minus:SI (const_int 31)
3913                              (match_operand:SI 2 "register_operand" "q,q"))))]
3914   ""
3915   "@
3916    zvdep %1,32,%0
3917    zvdepi %1,32,%0"
3918   [(set_attr "type" "shift,shift")
3919    (set_attr "length" "4,4")])
3920
3921 (define_insn "zvdep_imm32"
3922   [(set (match_operand:SI 0 "register_operand" "=r")
3923         (ashift:SI (match_operand:SI 1 "lhs_lshift_cint_operand" "")
3924                    (minus:SI (const_int 31)
3925                              (match_operand:SI 2 "register_operand" "q"))))]
3926   ""
3927   "*
3928 {
3929   int x = INTVAL (operands[1]);
3930   operands[2] = GEN_INT (4 + exact_log2 ((x >> 4) + 1));
3931   operands[1] = GEN_INT ((x & 0xf) - 0x10);
3932   return \"zvdepi %1,%2,%0\";
3933 }"
3934   [(set_attr "type" "shift")
3935    (set_attr "length" "4")])
3936
3937 (define_insn "vdepi_ior"
3938   [(set (match_operand:SI 0 "register_operand" "=r")
3939         (ior:SI (ashift:SI (match_operand:SI 1 "const_int_operand" "")
3940                            (minus:SI (const_int 31)
3941                                      (match_operand:SI 2 "register_operand" "q")))
3942                 (match_operand:SI 3 "register_operand" "0")))]
3943   ; accept ...0001...1, can this be generalized?
3944   "exact_log2 (INTVAL (operands[1]) + 1) >= 0"
3945   "*
3946 {
3947   int x = INTVAL (operands[1]);
3948   operands[2] = GEN_INT (exact_log2 (x + 1));
3949   return \"vdepi -1,%2,%0\";
3950 }"
3951   [(set_attr "type" "shift")
3952    (set_attr "length" "4")])
3953
3954 (define_insn "vdepi_and"
3955   [(set (match_operand:SI 0 "register_operand" "=r")
3956         (and:SI (rotate:SI (match_operand:SI 1 "const_int_operand" "")
3957                            (minus:SI (const_int 31)
3958                                      (match_operand:SI 2 "register_operand" "q")))
3959                 (match_operand:SI 3 "register_operand" "0")))]
3960   ; this can be generalized...!
3961   "INTVAL (operands[1]) == -2"
3962   "*
3963 {
3964   int x = INTVAL (operands[1]);
3965   operands[2] = GEN_INT (exact_log2 ((~x) + 1));
3966   return \"vdepi 0,%2,%0\";
3967 }"
3968   [(set_attr "type" "shift")
3969    (set_attr "length" "4")])
3970
3971 (define_expand "ashrsi3"
3972   [(set (match_operand:SI 0 "register_operand" "")
3973         (ashiftrt:SI (match_operand:SI 1 "register_operand" "")
3974                      (match_operand:SI 2 "arith32_operand" "")))]
3975   ""
3976   "
3977 {
3978   if (GET_CODE (operands[2]) != CONST_INT)
3979     {
3980       rtx temp = gen_reg_rtx (SImode);
3981       emit_insn (gen_subsi3 (temp, GEN_INT (31), operands[2]));
3982       emit_insn (gen_vextrs32 (operands[0], operands[1], temp));
3983       DONE;
3984     }
3985 }")
3986
3987 (define_insn ""
3988   [(set (match_operand:SI 0 "register_operand" "=r")
3989         (ashiftrt:SI (match_operand:SI 1 "register_operand" "r")
3990                      (match_operand:SI 2 "const_int_operand" "n")))]
3991   ""
3992   "extrs %1,%P2,%L2,%0"
3993   [(set_attr "type" "shift")
3994    (set_attr "length" "4")])
3995
3996 (define_insn "vextrs32"
3997   [(set (match_operand:SI 0 "register_operand" "=r")
3998         (ashiftrt:SI (match_operand:SI 1 "register_operand" "r")
3999                      (minus:SI (const_int 31)
4000                                (match_operand:SI 2 "register_operand" "q"))))]
4001   ""
4002   "vextrs %1,32,%0"
4003   [(set_attr "type" "shift")
4004    (set_attr "length" "4")])
4005
4006 (define_insn "lshrsi3"
4007   [(set (match_operand:SI 0 "register_operand" "=r,r")
4008         (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
4009                      (match_operand:SI 2 "arith32_operand" "q,n")))]
4010   ""
4011   "@
4012    vshd %%r0,%1,%0
4013    extru %1,%P2,%L2,%0"
4014   [(set_attr "type" "shift")
4015    (set_attr "length" "4")])
4016
4017 (define_insn "rotrsi3"
4018   [(set (match_operand:SI 0 "register_operand" "=r,r")
4019         (rotatert:SI (match_operand:SI 1 "register_operand" "r,r")
4020                      (match_operand:SI 2 "arith32_operand" "q,n")))]
4021   ""
4022   "*
4023 {
4024   if (GET_CODE (operands[2]) == CONST_INT)
4025     {
4026       operands[2] = GEN_INT (INTVAL (operands[2]) & 31);
4027       return \"shd %1,%1,%2,%0\";
4028     }
4029   else
4030     return \"vshd %1,%1,%0\";
4031 }"
4032   [(set_attr "type" "shift")
4033    (set_attr "length" "4")])
4034
4035 (define_expand "rotlsi3"
4036   [(set (match_operand:SI 0 "register_operand" "")
4037         (rotate:SI (match_operand:SI 1 "register_operand" "")
4038                    (match_operand:SI 2 "arith32_operand" "")))]
4039   ""
4040   "
4041 {
4042   if (GET_CODE (operands[2]) != CONST_INT)
4043     {
4044       rtx temp = gen_reg_rtx (SImode);
4045       emit_insn (gen_subsi3 (temp, GEN_INT (32), operands[2]));
4046       emit_insn (gen_rotrsi3 (operands[0], operands[1], temp));
4047       DONE;
4048     }
4049   /* Else expand normally.  */
4050 }")
4051
4052 (define_insn ""
4053   [(set (match_operand:SI 0 "register_operand" "=r")
4054         (rotate:SI (match_operand:SI 1 "register_operand" "r")
4055                    (match_operand:SI 2 "const_int_operand" "n")))]
4056   ""
4057   "*
4058 {
4059   operands[2] = GEN_INT ((32 - INTVAL (operands[2])) & 31);
4060   return \"shd %1,%1,%2,%0\";
4061 }"
4062   [(set_attr "type" "shift")
4063    (set_attr "length" "4")])
4064
4065 (define_insn ""
4066   [(set (match_operand:SI 0 "register_operand" "=r")
4067         (match_operator:SI 5 "plus_xor_ior_operator"
4068           [(ashift:SI (match_operand:SI 1 "register_operand" "r")
4069                       (match_operand:SI 3 "const_int_operand" "n"))
4070            (lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
4071                         (match_operand:SI 4 "const_int_operand" "n"))]))]
4072   "INTVAL (operands[3]) + INTVAL (operands[4]) == 32"
4073   "shd %1,%2,%4,%0"
4074   [(set_attr "type" "shift")
4075    (set_attr "length" "4")])
4076
4077 (define_insn ""
4078   [(set (match_operand:SI 0 "register_operand" "=r")
4079         (match_operator:SI 5 "plus_xor_ior_operator"
4080           [(lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
4081                         (match_operand:SI 4 "const_int_operand" "n"))
4082            (ashift:SI (match_operand:SI 1 "register_operand" "r")
4083                       (match_operand:SI 3 "const_int_operand" "n"))]))]
4084   "INTVAL (operands[3]) + INTVAL (operands[4]) == 32"
4085   "shd %1,%2,%4,%0"
4086   [(set_attr "type" "shift")
4087    (set_attr "length" "4")])
4088
4089 (define_insn ""
4090   [(set (match_operand:SI 0 "register_operand" "=r")
4091         (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
4092                            (match_operand:SI 2 "const_int_operand" ""))
4093                 (match_operand:SI 3 "const_int_operand" "")))]
4094   "exact_log2 (1 + (INTVAL (operands[3]) >> (INTVAL (operands[2]) & 31))) >= 0"
4095   "*
4096 {
4097   int cnt = INTVAL (operands[2]) & 31;
4098   operands[3] = GEN_INT (exact_log2 (1 + (INTVAL (operands[3]) >> cnt)));
4099   operands[2] = GEN_INT (31 - cnt);
4100   return \"zdep %1,%2,%3,%0\";
4101 }"
4102   [(set_attr "type" "shift")
4103    (set_attr "length" "4")])
4104 \f
4105 ;; Unconditional and other jump instructions.
4106
4107 (define_insn "return"
4108   [(return)]
4109   "hppa_can_use_return_insn_p ()"
4110   "bv%* %%r0(%%r2)"
4111   [(set_attr "type" "branch")
4112    (set_attr "length" "4")])
4113
4114 ;; Use a different pattern for functions which have non-trivial
4115 ;; epilogues so as not to confuse jump and reorg.
4116 (define_insn "return_internal"
4117   [(use (reg:SI 2))
4118    (return)]
4119   ""
4120   "bv%* %%r0(%%r2)"
4121   [(set_attr "type" "branch")
4122    (set_attr "length" "4")])
4123
4124 (define_expand "prologue"
4125   [(const_int 0)]
4126   ""
4127   "hppa_expand_prologue ();DONE;")
4128
4129 (define_expand "epilogue"
4130   [(return)]
4131   ""
4132   "
4133 {
4134   /* Try to use the trivial return first.  Else use the full
4135      epilogue.  */
4136   if (hppa_can_use_return_insn_p ())
4137    emit_jump_insn (gen_return ());
4138   else
4139     {
4140       hppa_expand_epilogue ();
4141       emit_jump_insn (gen_return_internal ());
4142     }
4143   DONE;
4144 }")
4145
4146 ;; Special because we use the value placed in %r2 by the bl instruction
4147 ;; from within its delay slot to set the value for the 2nd parameter to
4148 ;; the call.
4149 (define_insn "call_profiler"
4150   [(unspec_volatile [(const_int 0)] 0)
4151    (use (match_operand:SI 0 "const_int_operand" ""))]
4152   ""
4153   "bl _mcount,%%r2\;ldo %0(%%r2),%%r25"
4154   [(set_attr "type" "multi")
4155    (set_attr "length" "8")])
4156
4157 (define_insn "blockage"
4158   [(unspec_volatile [(const_int 2)] 0)]
4159   ""
4160   ""
4161   [(set_attr "length" "0")])
4162
4163 (define_insn "jump"
4164   [(set (pc) (label_ref (match_operand 0 "" "")))]
4165   ""
4166   "*
4167 {
4168   extern int optimize;
4169
4170   if (GET_MODE (insn) == SImode)
4171     return \"b %l0%#\";
4172
4173   /* An unconditional branch which can reach its target.  */
4174   if (get_attr_length (insn) != 24
4175       && get_attr_length (insn) != 16)
4176     return \"b%* %l0\";
4177
4178   /* An unconditional branch which can not reach its target.
4179
4180      We need to be able to use %r1 as a scratch register; however,
4181      we can never be sure whether or not it's got a live value in
4182      it.  Therefore, we must restore its original value after the
4183      jump.
4184
4185      To make matters worse, we don't have a stack slot which we
4186      can always clobber.  sp-12/sp-16 shouldn't ever have a live
4187      value during a non-optimizing compilation, so we use those
4188      slots for now.  We don't support very long branches when
4189      optimizing -- they should be quite rare when optimizing.
4190
4191      Really the way to go long term is a register scavenger; goto
4192      the target of the jump and find a register which we can use
4193      as a scratch to hold the value in %r1.  */
4194
4195   /* We don't know how to register scavenge yet.  */
4196   if (optimize)
4197     abort ();
4198
4199   /* First store %r1 into the stack.  */
4200   output_asm_insn (\"stw %%r1,-16(%%r30)\", operands);
4201
4202   /* Now load the target address into %r1 and do an indirect jump
4203      to the value specified in %r1.  Be careful to generate PIC
4204      code as needed.  */
4205   if (flag_pic)
4206     {
4207       rtx xoperands[2];
4208       xoperands[0] = operands[0];
4209       xoperands[1] = gen_label_rtx ();
4210
4211       output_asm_insn (\"bl .+8,%%r1\\n\\taddil L'%l0-%l1,%%r1\", xoperands);
4212       ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\",
4213                                  CODE_LABEL_NUMBER (xoperands[1]));
4214       output_asm_insn (\"ldo R'%l0-%l1(%%r1),%%r1\\n\\tbv %%r0(%%r1)\",
4215                        xoperands);
4216     }
4217   else
4218     output_asm_insn (\"ldil L'%l0,%%r1\\n\\tbe R'%l0(%%sr4,%%r1)\", operands);;
4219
4220   /* And restore the value of %r1 in the delay slot.  We're not optimizing,
4221      so we know nothing else can be in the delay slot.  */
4222   return \"ldw -16(%%r30),%%r1\";
4223 }"
4224   [(set_attr "type" "uncond_branch")
4225    (set_attr "pa_combine_type" "uncond_branch")
4226    (set (attr "length")
4227     (cond [(eq (symbol_ref "jump_in_call_delay (insn)") (const_int 1))
4228            (if_then_else (lt (abs (minus (match_dup 0)
4229                                          (plus (pc) (const_int 8))))
4230                              (const_int 8184))
4231                          (const_int 4)
4232                          (const_int 8))
4233            (ge (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
4234                (const_int 262100))
4235            (if_then_else (eq (symbol_ref "flag_pic") (const_int 0))
4236                          (const_int 16)
4237                          (const_int 24))]
4238           (const_int 4)))])
4239
4240 ;; Subroutines of "casesi".
4241 ;; operand 0 is index
4242 ;; operand 1 is the minimum bound
4243 ;; operand 2 is the maximum bound - minimum bound + 1
4244 ;; operand 3 is CODE_LABEL for the table;
4245 ;; operand 4 is the CODE_LABEL to go to if index out of range.
4246
4247 (define_expand "casesi"
4248   [(match_operand:SI 0 "general_operand" "")
4249    (match_operand:SI 1 "const_int_operand" "")
4250    (match_operand:SI 2 "const_int_operand" "")
4251    (match_operand 3 "" "")
4252    (match_operand 4 "" "")]
4253   ""
4254   "
4255 {
4256   if (GET_CODE (operands[0]) != REG)
4257     operands[0] = force_reg (SImode, operands[0]);
4258
4259   if (operands[1] != const0_rtx)
4260     {
4261       rtx reg = gen_reg_rtx (SImode);
4262
4263       operands[1] = GEN_INT (-INTVAL (operands[1]));
4264       if (!INT_14_BITS (operands[1]))
4265         operands[1] = force_reg (SImode, operands[1]);
4266       emit_insn (gen_addsi3 (reg, operands[0], operands[1]));
4267
4268       operands[0] = reg;
4269     }
4270
4271   if (!INT_5_BITS (operands[2]))
4272     operands[2] = force_reg (SImode, operands[2]);
4273
4274   emit_insn (gen_cmpsi (operands[0], operands[2]));
4275   emit_jump_insn (gen_bgtu (operands[4]));
4276   if (TARGET_BIG_SWITCH)
4277     {
4278       rtx temp = gen_reg_rtx (SImode);
4279       emit_move_insn (temp, gen_rtx_PLUS (SImode, operands[0], operands[0]));
4280       operands[0] = temp;
4281     }
4282   emit_jump_insn (gen_casesi0 (operands[0], operands[3]));
4283   DONE;
4284 }")
4285
4286 (define_insn "casesi0"
4287   [(set (pc) (plus:SI
4288                (mem:SI (plus:SI (pc)
4289                                 (match_operand:SI 0 "register_operand" "r")))
4290                (label_ref (match_operand 1 "" ""))))]
4291   ""
4292   "blr %0,%%r0\;nop"
4293   [(set_attr "type" "multi")
4294    (set_attr "length" "8")])
4295
4296 ;; Need nops for the calls because execution is supposed to continue
4297 ;; past; we don't want to nullify an instruction that we need.
4298 ;;- jump to subroutine
4299
4300 (define_expand "call"
4301   [(parallel [(call (match_operand:SI 0 "" "")
4302                     (match_operand 1 "" ""))
4303               (clobber (reg:SI 2))])]
4304   ""
4305   "
4306 {
4307   rtx op;
4308   rtx call_insn;
4309
4310   if (TARGET_PORTABLE_RUNTIME)
4311     op = force_reg (SImode, XEXP (operands[0], 0));
4312   else
4313     op = XEXP (operands[0], 0);
4314
4315   /* Use two different patterns for calls to explicitly named functions
4316      and calls through function pointers.  This is necessary as these two
4317      types of calls use different calling conventions, and CSE might try
4318      to change the named call into an indirect call in some cases (using
4319      two patterns keeps CSE from performing this optimization).  */
4320   if (GET_CODE (op) == SYMBOL_REF)
4321     call_insn = emit_call_insn (gen_call_internal_symref (op, operands[1]));
4322   else
4323     {
4324       rtx tmpreg = gen_rtx_REG (word_mode, 22);
4325       emit_move_insn (tmpreg, force_reg (word_mode, op));
4326       call_insn = emit_call_insn (gen_call_internal_reg (operands[1]));
4327     }
4328
4329   if (flag_pic)
4330     {
4331       use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
4332
4333       /* After each call we must restore the PIC register, even if it
4334          doesn't appear to be used.
4335
4336          This will set regs_ever_live for the callee saved register we
4337          stored the PIC register in.  */
4338       emit_move_insn (pic_offset_table_rtx,
4339                       gen_rtx_REG (word_mode, PIC_OFFSET_TABLE_REGNUM_SAVED));
4340       emit_insn (gen_rtx_USE (VOIDmode, pic_offset_table_rtx));
4341
4342       /* Gross.  We have to keep the scheduler from moving the restore
4343          of the PIC register away from the call.  SCHED_GROUP_P is
4344          supposed to do this, but for some reason the compiler will
4345          go into an infinite loop when we use that.
4346
4347          This method (blockage insn) may make worse code (then again
4348          it may not since calls are nearly blockages anyway), but at
4349          least it should work.  */
4350       emit_insn (gen_blockage ());
4351     }
4352   DONE;
4353 }")
4354
4355 (define_insn "call_internal_symref"
4356   [(call (mem:SI (match_operand:SI 0 "call_operand_address" ""))
4357          (match_operand 1 "" "i"))
4358    (clobber (reg:SI 2))
4359    (use (const_int 0))]
4360   "! TARGET_PORTABLE_RUNTIME"
4361   "*
4362 {
4363   output_arg_descriptor (insn);
4364   return output_call (insn, operands[0]);
4365 }"
4366   [(set_attr "type" "call")
4367    (set (attr "length")
4368 ;;       If we're sure that we can either reach the target or that the
4369 ;;       linker can use a long-branch stub, then the length is 4 bytes.
4370 ;;
4371 ;;       For long-calls the length will be either 52 bytes (non-pic)
4372 ;;       or 68 bytes (pic).  */
4373 ;;       Else we have to use a long-call;
4374       (if_then_else (lt (plus (symbol_ref "total_code_bytes") (pc))
4375                         (const_int 240000))
4376                     (const_int 4)
4377                     (if_then_else (eq (symbol_ref "flag_pic")
4378                                       (const_int 0))
4379                                   (const_int 52)
4380                                   (const_int 68))))])
4381
4382 (define_insn "call_internal_reg"
4383   [(call (mem:SI (reg:SI 22))
4384          (match_operand 0 "" "i"))
4385    (clobber (reg:SI 2))
4386    (use (const_int 1))]
4387   ""
4388   "*
4389 {
4390   rtx xoperands[2];
4391
4392   /* First the special case for kernels, level 0 systems, etc.  */
4393   if (TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS)
4394     return \"ble 0(%%sr4,%%r22)\;copy %%r31,%%r2\";
4395
4396   /* Now the normal case -- we can reach $$dyncall directly or
4397      we're sure that we can get there via a long-branch stub. 
4398
4399      No need to check target flags as the length uniquely identifies
4400      the remaining cases.  */
4401   if (get_attr_length (insn) == 8)
4402     return \".CALL\\tARGW0=GR\;bl $$dyncall,%%r31\;copy %%r31,%%r2\";
4403
4404   /* Long millicode call, but we are not generating PIC or portable runtime
4405      code.  */
4406   if (get_attr_length (insn) == 12)
4407     return \".CALL\\tARGW0=GR\;ldil L%%$$dyncall,%%r2\;ble R%%$$dyncall(%%sr4,%%r2)\;copy %%r31,%%r2\";
4408
4409   /* Long millicode call for portable runtime.  */
4410   if (get_attr_length (insn) == 20)
4411     return \"ldil L%%$$dyncall,%%r31\;ldo R%%$$dyncall(%%r31),%%r31\;blr %%r0,%%r2\;bv,n %%r0(%%r31)\;nop\";
4412
4413   /* If we're generating PIC code.  */
4414   xoperands[0] = operands[0];
4415   xoperands[1] = gen_label_rtx ();
4416   output_asm_insn (\"bl .+8,%%r1\", xoperands);
4417   output_asm_insn (\"addil L%%$$dyncall-%1,%%r1\", xoperands);
4418   ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\",
4419                              CODE_LABEL_NUMBER (xoperands[1]));
4420   output_asm_insn (\"ldo R%%$$dyncall-%1(%%r1),%%r1\", xoperands);
4421   output_asm_insn (\"blr %%r0,%%r2\", xoperands);
4422   output_asm_insn (\"bv,n %%r0(%%r1)\\n\\tnop\", xoperands);
4423   return \"\";
4424 }"
4425   [(set_attr "type" "dyncall")
4426    (set (attr "length")
4427      (cond [
4428 ;; First NO_SPACE_REGS
4429             (ne (symbol_ref "TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS")
4430                 (const_int 0))
4431             (const_int 8)
4432
4433 ;; Target (or stub) within reach
4434             (and (lt (plus (symbol_ref "total_code_bytes") (pc))
4435                      (const_int 240000))
4436                  (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
4437                      (const_int 0)))
4438             (const_int 8)
4439
4440 ;; Out of reach, but not PIC or PORTABLE_RUNTIME
4441             (and (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
4442                      (const_int 0))
4443                  (eq (symbol_ref "flag_pic")
4444                      (const_int 0)))
4445             (const_int 12)
4446
4447             (ne (symbol_ref "TARGET_PORTABLE_RUNTIME")
4448                 (const_int 0))
4449             (const_int 20)]
4450
4451 ;; Out of range PIC case
4452           (const_int 24)))])
4453
4454 (define_expand "call_value"
4455   [(parallel [(set (match_operand 0 "" "")
4456                    (call (match_operand:SI 1 "" "")
4457                          (match_operand 2 "" "")))
4458               (clobber (reg:SI 2))])]
4459   ""
4460   "
4461 {
4462   rtx op;
4463   rtx call_insn;
4464
4465   if (TARGET_PORTABLE_RUNTIME)
4466     op = force_reg (word_mode, XEXP (operands[1], 0));
4467   else
4468     op = XEXP (operands[1], 0);
4469
4470   /* Use two different patterns for calls to explicitly named functions
4471      and calls through function pointers.  This is necessary as these two
4472      types of calls use different calling conventions, and CSE might try
4473      to change the named call into an indirect call in some cases (using
4474      two patterns keeps CSE from performing this optimization).  */
4475   if (GET_CODE (op) == SYMBOL_REF)
4476     call_insn = emit_call_insn (gen_call_value_internal_symref (operands[0],
4477                                                                 op,
4478                                                                 operands[2]));
4479   else
4480     {
4481       rtx tmpreg = gen_rtx_REG (word_mode, 22);
4482       emit_move_insn (tmpreg, force_reg (word_mode, op));
4483       call_insn = emit_call_insn (gen_call_value_internal_reg (operands[0],
4484                                                                operands[2]));
4485     }
4486   if (flag_pic)
4487     {
4488       use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
4489
4490       /* After each call we must restore the PIC register, even if it
4491          doesn't appear to be used.
4492
4493          This will set regs_ever_live for the callee saved register we
4494          stored the PIC register in.  */
4495       emit_move_insn (pic_offset_table_rtx,
4496                       gen_rtx_REG (word_mode, PIC_OFFSET_TABLE_REGNUM_SAVED));
4497       emit_insn (gen_rtx_USE (VOIDmode, pic_offset_table_rtx));
4498
4499       /* Gross.  We have to keep the scheduler from moving the restore
4500          of the PIC register away from the call.  SCHED_GROUP_P is
4501          supposed to do this, but for some reason the compiler will
4502          go into an infinite loop when we use that.
4503
4504          This method (blockage insn) may make worse code (then again
4505          it may not since calls are nearly blockages anyway), but at
4506          least it should work.  */
4507       emit_insn (gen_blockage ());
4508     }
4509   DONE;
4510 }")
4511
4512 (define_insn "call_value_internal_symref"
4513   [(set (match_operand 0 "" "=rf")
4514         (call (mem:SI (match_operand:SI 1 "call_operand_address" ""))
4515               (match_operand 2 "" "i")))
4516    (clobber (reg:SI 2))
4517    (use (const_int 0))]
4518   ;;- Don't use operand 1 for most machines.
4519   "! TARGET_PORTABLE_RUNTIME"
4520   "*
4521 {
4522   output_arg_descriptor (insn);
4523   return output_call (insn, operands[1]);
4524 }"
4525   [(set_attr "type" "call")
4526    (set (attr "length")
4527 ;;       If we're sure that we can either reach the target or that the
4528 ;;       linker can use a long-branch stub, then the length is 4 bytes.
4529 ;;
4530 ;;       For long-calls the length will be either 52 bytes (non-pic)
4531 ;;       or 68 bytes (pic).  */
4532 ;;       Else we have to use a long-call;
4533       (if_then_else (lt (plus (symbol_ref "total_code_bytes") (pc))
4534                         (const_int 240000))
4535                     (const_int 4)
4536                     (if_then_else (eq (symbol_ref "flag_pic")
4537                                       (const_int 0))
4538                                   (const_int 52)
4539                                   (const_int 68))))])
4540
4541 (define_insn "call_value_internal_reg"
4542   [(set (match_operand 0 "" "=rf")
4543         (call (mem:SI (reg:SI 22))
4544               (match_operand 1 "" "i")))
4545    (clobber (reg:SI 2))
4546    (use (const_int 1))]
4547   ""
4548   "*
4549 {
4550   rtx xoperands[2];
4551
4552   /* First the special case for kernels, level 0 systems, etc.  */
4553   if (TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS)
4554     return \"ble 0(%%sr4,%%r22)\;copy %%r31,%%r2\";
4555
4556   /* Now the normal case -- we can reach $$dyncall directly or
4557      we're sure that we can get there via a long-branch stub. 
4558
4559      No need to check target flags as the length uniquely identifies
4560      the remaining cases.  */
4561   if (get_attr_length (insn) == 8)
4562     return \".CALL\\tARGW0=GR\;bl $$dyncall,%%r31\;copy %%r31,%%r2\";
4563
4564   /* Long millicode call, but we are not generating PIC or portable runtime
4565      code.  */
4566   if (get_attr_length (insn) == 12)
4567     return \".CALL\\tARGW0=GR\;ldil L%%$$dyncall,%%r2\;ble R%%$$dyncall(%%sr4,%%r2)\;copy %%r31,%%r2\";
4568
4569   /* Long millicode call for portable runtime.  */
4570   if (get_attr_length (insn) == 20)
4571     return \"ldil L%%$$dyncall,%%r31\;ldo R%%$$dyncall(%%r31),%%r31\;blr %%r0,%%r2\;bv,n %%r0(%%r31)\;nop\";
4572
4573   /* If we're generating PIC code.  */
4574   xoperands[0] = operands[1];
4575   xoperands[1] = gen_label_rtx ();
4576   output_asm_insn (\"bl .+8,%%r1\", xoperands);
4577   output_asm_insn (\"addil L%%$$dyncall-%1,%%r1\", xoperands);
4578   ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"L\",
4579                              CODE_LABEL_NUMBER (xoperands[1]));
4580   output_asm_insn (\"ldo R%%$$dyncall-%1(%%r1),%%r1\", xoperands);
4581   output_asm_insn (\"blr %%r0,%%r2\", xoperands);
4582   output_asm_insn (\"bv,n %%r0(%%r1)\\n\\tnop\", xoperands);
4583   return \"\";
4584 }"
4585   [(set_attr "type" "dyncall")
4586    (set (attr "length")
4587      (cond [
4588 ;; First NO_SPACE_REGS
4589             (ne (symbol_ref "TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS")
4590                 (const_int 0))
4591             (const_int 8)
4592
4593 ;; Target (or stub) within reach
4594             (and (lt (plus (symbol_ref "total_code_bytes") (pc))
4595                      (const_int 240000))
4596                  (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
4597                      (const_int 0)))
4598             (const_int 8)
4599
4600 ;; Out of reach, but not PIC or PORTABLE_RUNTIME
4601             (and (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
4602                      (const_int 0))
4603                  (eq (symbol_ref "flag_pic")
4604                      (const_int 0)))
4605             (const_int 12)
4606
4607             (ne (symbol_ref "TARGET_PORTABLE_RUNTIME")
4608                 (const_int 0))
4609             (const_int 20)]
4610
4611 ;; Out of range PIC case
4612           (const_int 24)))])
4613
4614 ;; Call subroutine returning any type.
4615
4616 (define_expand "untyped_call"
4617   [(parallel [(call (match_operand 0 "" "")
4618                     (const_int 0))
4619               (match_operand 1 "" "")
4620               (match_operand 2 "" "")])]
4621   ""
4622   "
4623 {
4624   int i;
4625
4626   emit_call_insn (gen_call (operands[0], const0_rtx));
4627
4628   for (i = 0; i < XVECLEN (operands[2], 0); i++)
4629     {
4630       rtx set = XVECEXP (operands[2], 0, i);
4631       emit_move_insn (SET_DEST (set), SET_SRC (set));
4632     }
4633
4634   /* The optimizer does not know that the call sets the function value
4635      registers we stored in the result block.  We avoid problems by
4636      claiming that all hard registers are used and clobbered at this
4637      point.  */
4638   emit_insn (gen_blockage ());
4639
4640   DONE;
4641 }")
4642 (define_insn "nop"
4643   [(const_int 0)]
4644   ""
4645   "nop"
4646   [(set_attr "type" "move")
4647    (set_attr "length" "4")])
4648
4649 ;; These are just placeholders so we know where branch tables
4650 ;; begin and end.
4651 (define_insn "begin_brtab"
4652   [(const_int 1)]
4653   ""
4654   "*
4655 {
4656   /* Only GAS actually supports this pseudo-op.  */
4657   if (TARGET_GAS)
4658     return \".begin_brtab\";
4659   else
4660     return \"\";
4661 }"
4662   [(set_attr "type" "move")
4663    (set_attr "length" "0")])
4664
4665 (define_insn "end_brtab"
4666   [(const_int 2)]
4667   ""
4668   "*
4669 {
4670   /* Only GAS actually supports this pseudo-op.  */
4671   if (TARGET_GAS)
4672     return \".end_brtab\";
4673   else
4674     return \"\";
4675 }"
4676   [(set_attr "type" "move")
4677    (set_attr "length" "0")])
4678
4679 ;;; Hope this is only within a function...
4680 (define_insn "indirect_jump"
4681   [(set (pc) (match_operand 0 "register_operand" "r"))]
4682   "GET_MODE (operands[0]) == word_mode"
4683   "bv%* %%r0(%0)"
4684   [(set_attr "type" "branch")
4685    (set_attr "length" "4")])
4686
4687 (define_insn "extzv"
4688   [(set (match_operand:SI 0 "register_operand" "=r")
4689         (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
4690                          (match_operand:SI 2 "uint5_operand" "")
4691                          (match_operand:SI 3 "uint5_operand" "")))]
4692   ""
4693   "extru %1,%3+%2-1,%2,%0"
4694   [(set_attr "type" "shift")
4695    (set_attr "length" "4")])
4696
4697 (define_insn ""
4698   [(set (match_operand:SI 0 "register_operand" "=r")
4699         (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
4700                          (const_int 1)
4701                          (match_operand:SI 3 "register_operand" "q")))]
4702   ""
4703   "vextru %1,1,%0"
4704   [(set_attr "type" "shift")
4705    (set_attr "length" "4")])
4706
4707 (define_insn "extv"
4708   [(set (match_operand:SI 0 "register_operand" "=r")
4709         (sign_extract:SI (match_operand:SI 1 "register_operand" "r")
4710                          (match_operand:SI 2 "uint5_operand" "")
4711                          (match_operand:SI 3 "uint5_operand" "")))]
4712   ""
4713   "extrs %1,%3+%2-1,%2,%0"
4714   [(set_attr "type" "shift")
4715    (set_attr "length" "4")])
4716
4717 (define_insn ""
4718   [(set (match_operand:SI 0 "register_operand" "=r")
4719         (sign_extract:SI (match_operand:SI 1 "register_operand" "r")
4720                          (const_int 1)
4721                          (match_operand:SI 3 "register_operand" "q")))]
4722   ""
4723   "vextrs %1,1,%0"
4724   [(set_attr "type" "shift")
4725    (set_attr "length" "4")])
4726
4727 (define_insn "insv"
4728   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r,r")
4729                          (match_operand:SI 1 "uint5_operand" "")
4730                          (match_operand:SI 2 "uint5_operand" ""))
4731         (match_operand:SI 3 "arith5_operand" "r,L"))]
4732   ""
4733   "@
4734    dep %3,%2+%1-1,%1,%0
4735    depi %3,%2+%1-1,%1,%0"
4736   [(set_attr "type" "shift,shift")
4737    (set_attr "length" "4,4")])
4738
4739 ;; Optimize insertion of const_int values of type 1...1xxxx.
4740 (define_insn ""
4741   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
4742                          (match_operand:SI 1 "uint5_operand" "")
4743                          (match_operand:SI 2 "uint5_operand" ""))
4744         (match_operand:SI 3 "const_int_operand" ""))]
4745   "(INTVAL (operands[3]) & 0x10) != 0 &&
4746    (~INTVAL (operands[3]) & ((1L << INTVAL (operands[1])) - 1) & ~0xf) == 0"
4747   "*
4748 {
4749   operands[3] = GEN_INT ((INTVAL (operands[3]) & 0xf) - 0x10);
4750   return \"depi %3,%2+%1-1,%1,%0\";
4751 }"
4752   [(set_attr "type" "shift")
4753    (set_attr "length" "4")])
4754
4755 ;; This insn is used for some loop tests, typically loops reversed when
4756 ;; strength reduction is used.  It is actually created when the instruction
4757 ;; combination phase combines the special loop test.  Since this insn
4758 ;; is both a jump insn and has an output, it must deal with its own
4759 ;; reloads, hence the `m' constraints.  The `!' constraints direct reload
4760 ;; to not choose the register alternatives in the event a reload is needed.
4761 (define_insn "decrement_and_branch_until_zero"
4762   [(set (pc)
4763         (if_then_else
4764           (match_operator 2 "comparison_operator"
4765            [(plus:SI (match_operand:SI 0 "register_operand" "+!r,!*f,!*m")
4766                      (match_operand:SI 1 "int5_operand" "L,L,L"))
4767             (const_int 0)])
4768           (label_ref (match_operand 3 "" ""))
4769           (pc)))
4770    (set (match_dup 0)
4771         (plus:SI (match_dup 0) (match_dup 1)))
4772    (clobber (match_scratch:SI 4 "=X,r,r"))]
4773   ""
4774   "* return output_dbra (operands, insn, which_alternative); "
4775 ;; Do not expect to understand this the first time through.
4776 [(set_attr "type" "cbranch,multi,multi")
4777  (set (attr "length")
4778       (if_then_else (eq_attr "alternative" "0")
4779 ;; Loop counter in register case
4780 ;; Short branch has length of 4
4781 ;; Long branch has length of 8
4782         (if_then_else (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
4783                       (const_int 8184))
4784            (const_int 4)
4785            (const_int 8))
4786
4787 ;; Loop counter in FP reg case.
4788 ;; Extra goo to deal with additional reload insns.
4789         (if_then_else (eq_attr "alternative" "1")
4790           (if_then_else (lt (match_dup 3) (pc))
4791             (if_then_else
4792               (lt (abs (minus (match_dup 3) (plus (pc) (const_int 24))))
4793                   (const_int 8184))
4794               (const_int 24)
4795               (const_int 28))
4796             (if_then_else
4797               (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
4798                   (const_int 8184))
4799               (const_int 24)
4800               (const_int 28)))
4801 ;; Loop counter in memory case.
4802 ;; Extra goo to deal with additional reload insns.
4803         (if_then_else (lt (match_dup 3) (pc))
4804           (if_then_else
4805             (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
4806                 (const_int 8184))
4807             (const_int 12)
4808             (const_int 16))
4809           (if_then_else
4810             (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
4811                 (const_int 8184))
4812             (const_int 12)
4813             (const_int 16))))))])
4814
4815 (define_insn ""
4816   [(set (pc)
4817         (if_then_else
4818           (match_operator 2 "movb_comparison_operator"
4819            [(match_operand:SI 1 "register_operand" "r,r,r,r") (const_int 0)])
4820           (label_ref (match_operand 3 "" ""))
4821           (pc)))
4822    (set (match_operand:SI 0 "register_operand" "=!r,!*f,!*m,!*q")
4823         (match_dup 1))]
4824   ""
4825 "* return output_movb (operands, insn, which_alternative, 0); "
4826 ;; Do not expect to understand this the first time through.
4827 [(set_attr "type" "cbranch,multi,multi,multi")
4828  (set (attr "length")
4829       (if_then_else (eq_attr "alternative" "0")
4830 ;; Loop counter in register case
4831 ;; Short branch has length of 4
4832 ;; Long branch has length of 8
4833         (if_then_else (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
4834                       (const_int 8184))
4835            (const_int 4)
4836            (const_int 8))
4837
4838 ;; Loop counter in FP reg case.
4839 ;; Extra goo to deal with additional reload insns.
4840         (if_then_else (eq_attr "alternative" "1")
4841           (if_then_else (lt (match_dup 3) (pc))
4842             (if_then_else
4843               (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
4844                   (const_int 8184))
4845               (const_int 12)
4846               (const_int 16))
4847             (if_then_else
4848               (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
4849                   (const_int 8184))
4850               (const_int 12)
4851               (const_int 16)))
4852 ;; Loop counter in memory or sar case.
4853 ;; Extra goo to deal with additional reload insns.
4854         (if_then_else
4855           (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
4856               (const_int 8184))
4857           (const_int 8)
4858           (const_int 12)))))])
4859
4860 ;; Handle negated branch.
4861 (define_insn ""
4862   [(set (pc)
4863         (if_then_else
4864           (match_operator 2 "movb_comparison_operator"
4865            [(match_operand:SI 1 "register_operand" "r,r,r,r") (const_int 0)])
4866           (pc)
4867           (label_ref (match_operand 3 "" ""))))
4868    (set (match_operand:SI 0 "register_operand" "=!r,!*f,!*m,!*q")
4869         (match_dup 1))]
4870   ""
4871 "* return output_movb (operands, insn, which_alternative, 1); "
4872 ;; Do not expect to understand this the first time through.
4873 [(set_attr "type" "cbranch,multi,multi,multi")
4874  (set (attr "length")
4875       (if_then_else (eq_attr "alternative" "0")
4876 ;; Loop counter in register case
4877 ;; Short branch has length of 4
4878 ;; Long branch has length of 8
4879         (if_then_else (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
4880                       (const_int 8184))
4881            (const_int 4)
4882            (const_int 8))
4883
4884 ;; Loop counter in FP reg case.
4885 ;; Extra goo to deal with additional reload insns.
4886         (if_then_else (eq_attr "alternative" "1")
4887           (if_then_else (lt (match_dup 3) (pc))
4888             (if_then_else
4889               (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
4890                   (const_int 8184))
4891               (const_int 12)
4892               (const_int 16))
4893             (if_then_else
4894               (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
4895                   (const_int 8184))
4896               (const_int 12)
4897               (const_int 16)))
4898 ;; Loop counter in memory or SAR case.
4899 ;; Extra goo to deal with additional reload insns.
4900         (if_then_else
4901           (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
4902               (const_int 8184))
4903           (const_int 8)
4904           (const_int 12)))))])
4905
4906 ;; The next several patterns (parallel_addb, parallel_movb, fmpyadd and
4907 ;; fmpysub aren't currently used by the FSF sources, but will be soon.
4908 ;;
4909 ;; They're in the FSF tree for documentation and to make Cygnus<->FSF
4910 ;; merging easier.
4911 (define_insn ""
4912   [(set (pc) (label_ref (match_operand 3 "" "" )))
4913    (set (match_operand:SI 0 "register_operand" "=r")
4914         (plus:SI (match_operand:SI 1 "register_operand" "r")
4915                  (match_operand:SI 2 "ireg_or_int5_operand" "rL")))]
4916   "(reload_completed && operands[0] == operands[1]) || operands[0] == operands[2]"
4917   "*
4918 {
4919   return output_parallel_addb (operands, get_attr_length (insn));
4920 }"
4921   [(set_attr "type" "parallel_branch")
4922    (set (attr "length")
4923     (if_then_else (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
4924                       (const_int 8184))
4925            (const_int 4)
4926            (const_int 8)))])
4927
4928 (define_insn ""
4929   [(set (pc) (label_ref (match_operand 2 "" "" )))
4930    (set (match_operand:SF 0 "register_operand" "=r")
4931         (match_operand:SF 1 "ireg_or_int5_operand" "rL"))]
4932   "reload_completed"
4933   "*
4934 {
4935   return output_parallel_movb (operands, get_attr_length (insn));
4936 }"
4937   [(set_attr "type" "parallel_branch")
4938    (set (attr "length")
4939     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
4940                       (const_int 8184))
4941            (const_int 4)
4942            (const_int 8)))])
4943
4944 (define_insn ""
4945   [(set (pc) (label_ref (match_operand 2 "" "" )))
4946    (set (match_operand:SI 0 "register_operand" "=r")
4947         (match_operand:SI 1 "ireg_or_int5_operand" "rL"))]
4948   "reload_completed"
4949   "*
4950 {
4951   return output_parallel_movb (operands, get_attr_length (insn));
4952 }"
4953   [(set_attr "type" "parallel_branch")
4954    (set (attr "length")
4955     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
4956                       (const_int 8184))
4957            (const_int 4)
4958            (const_int 8)))])
4959
4960 (define_insn ""
4961   [(set (pc) (label_ref (match_operand 2 "" "" )))
4962    (set (match_operand:HI 0 "register_operand" "=r")
4963         (match_operand:HI 1 "ireg_or_int5_operand" "rL"))]
4964   "reload_completed"
4965   "*
4966 {
4967   return output_parallel_movb (operands, get_attr_length (insn));
4968 }"
4969   [(set_attr "type" "parallel_branch")
4970    (set (attr "length")
4971     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
4972                       (const_int 8184))
4973            (const_int 4)
4974            (const_int 8)))])
4975
4976 (define_insn ""
4977   [(set (pc) (label_ref (match_operand 2 "" "" )))
4978    (set (match_operand:QI 0 "register_operand" "=r")
4979         (match_operand:QI 1 "ireg_or_int5_operand" "rL"))]
4980   "reload_completed"
4981   "*
4982 {
4983   return output_parallel_movb (operands, get_attr_length (insn));
4984 }"
4985   [(set_attr "type" "parallel_branch")
4986    (set (attr "length")
4987     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
4988                       (const_int 8184))
4989            (const_int 4)
4990            (const_int 8)))])
4991
4992 (define_insn ""
4993   [(set (match_operand 0 "register_operand" "=f")
4994         (mult (match_operand 1 "register_operand" "f")
4995               (match_operand 2 "register_operand" "f")))
4996    (set (match_operand 3 "register_operand" "+f")
4997         (plus (match_operand 4 "register_operand" "f")
4998               (match_operand 5 "register_operand" "f")))]
4999   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
5000    && reload_completed && fmpyaddoperands (operands)"
5001   "*
5002 {
5003   if (GET_MODE (operands[0]) == DFmode)
5004     {
5005       if (rtx_equal_p (operands[3], operands[5]))
5006         return \"fmpyadd,dbl %1,%2,%0,%4,%3\";
5007       else
5008         return \"fmpyadd,dbl %1,%2,%0,%5,%3\";
5009     }
5010   else
5011     {
5012       if (rtx_equal_p (operands[3], operands[5]))
5013         return \"fmpyadd,sgl %1,%2,%0,%4,%3\";
5014       else
5015         return \"fmpyadd,sgl %1,%2,%0,%5,%3\";
5016     }
5017 }"
5018   [(set_attr "type" "fpalu")
5019    (set_attr "length" "4")])
5020
5021 (define_insn ""
5022   [(set (match_operand 3 "register_operand" "+f")
5023         (plus (match_operand 4 "register_operand" "f")
5024               (match_operand 5 "register_operand" "f")))
5025    (set (match_operand 0 "register_operand" "=f")
5026         (mult (match_operand 1 "register_operand" "f")
5027               (match_operand 2 "register_operand" "f")))]
5028   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
5029    && reload_completed && fmpyaddoperands (operands)"
5030   "*
5031 {
5032   if (GET_MODE (operands[0]) == DFmode)
5033     {
5034       if (rtx_equal_p (operands[3], operands[5]))
5035         return \"fmpyadd,dbl %1,%2,%0,%4,%3\";
5036       else
5037         return \"fmpyadd,dbl %1,%2,%0,%5,%3\";
5038     }
5039   else
5040     {
5041       if (rtx_equal_p (operands[3], operands[5]))
5042         return \"fmpyadd,sgl %1,%2,%0,%4,%3\";
5043       else
5044         return \"fmpyadd,sgl %1,%2,%0,%5,%3\";
5045     }
5046 }"
5047   [(set_attr "type" "fpalu")
5048    (set_attr "length" "4")])
5049
5050 (define_insn ""
5051   [(set (match_operand 0 "register_operand" "=f")
5052         (mult (match_operand 1 "register_operand" "f")
5053               (match_operand 2 "register_operand" "f")))
5054    (set (match_operand 3 "register_operand" "+f")
5055         (minus (match_operand 4 "register_operand" "f")
5056                (match_operand 5 "register_operand" "f")))]
5057   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
5058    && reload_completed && fmpysuboperands (operands)"
5059   "*
5060 {
5061   if (GET_MODE (operands[0]) == DFmode)
5062     return \"fmpysub,dbl %1,%2,%0,%5,%3\";
5063   else
5064     return \"fmpysub,sgl %1,%2,%0,%5,%3\";
5065 }"
5066   [(set_attr "type" "fpalu")
5067    (set_attr "length" "4")])
5068
5069 (define_insn ""
5070   [(set (match_operand 3 "register_operand" "+f")
5071         (minus (match_operand 4 "register_operand" "f")
5072                (match_operand 5 "register_operand" "f")))
5073    (set (match_operand 0 "register_operand" "=f")
5074         (mult (match_operand 1 "register_operand" "f")
5075               (match_operand 2 "register_operand" "f")))]
5076   "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
5077    && reload_completed && fmpysuboperands (operands)"
5078   "*
5079 {
5080   if (GET_MODE (operands[0]) == DFmode)
5081     return \"fmpysub,dbl %1,%2,%0,%5,%3\";
5082   else
5083     return \"fmpysub,sgl %1,%2,%0,%5,%3\";
5084 }"
5085   [(set_attr "type" "fpalu")
5086    (set_attr "length" "4")])
5087
5088 ;; Clean up turds left by reload.
5089 (define_peephole
5090   [(set (match_operand 0 "reg_or_nonsymb_mem_operand" "")
5091         (match_operand 1 "register_operand" "fr"))
5092    (set (match_operand 2 "register_operand" "fr")
5093         (match_dup 0))]
5094   "! TARGET_SOFT_FLOAT
5095    && GET_CODE (operands[0]) == MEM
5096    && ! MEM_VOLATILE_P (operands[0])
5097    && GET_MODE (operands[0]) == GET_MODE (operands[1])
5098    && GET_MODE (operands[0]) == GET_MODE (operands[2])
5099    && GET_MODE (operands[0]) == DFmode
5100    && GET_CODE (operands[1]) == REG
5101    && GET_CODE (operands[2]) == REG
5102    && ! side_effects_p (XEXP (operands[0], 0))
5103    && REGNO_REG_CLASS (REGNO (operands[1]))
5104       == REGNO_REG_CLASS (REGNO (operands[2]))"
5105   "*
5106 {
5107   rtx xoperands[2];
5108
5109   if (FP_REG_P (operands[1]))
5110     output_asm_insn (output_fp_move_double (operands), operands);
5111   else
5112     output_asm_insn (output_move_double (operands), operands);
5113
5114   if (rtx_equal_p (operands[1], operands[2]))
5115     return \"\";
5116
5117   xoperands[0] = operands[2];
5118   xoperands[1] = operands[1];
5119       
5120   if (FP_REG_P (xoperands[1]))
5121     output_asm_insn (output_fp_move_double (xoperands), xoperands);
5122   else
5123     output_asm_insn (output_move_double (xoperands), xoperands);
5124
5125   return \"\";
5126 }")
5127
5128 (define_peephole
5129   [(set (match_operand 0 "register_operand" "fr")
5130         (match_operand 1 "reg_or_nonsymb_mem_operand" ""))
5131    (set (match_operand 2 "register_operand" "fr")
5132         (match_dup 1))]
5133   "! TARGET_SOFT_FLOAT
5134    && GET_CODE (operands[1]) == MEM
5135    && ! MEM_VOLATILE_P (operands[1])
5136    && GET_MODE (operands[0]) == GET_MODE (operands[1])
5137    && GET_MODE (operands[0]) == GET_MODE (operands[2])
5138    && GET_MODE (operands[0]) == DFmode
5139    && GET_CODE (operands[0]) == REG
5140    && GET_CODE (operands[2]) == REG
5141    && ! side_effects_p (XEXP (operands[1], 0))
5142    && REGNO_REG_CLASS (REGNO (operands[0]))
5143       == REGNO_REG_CLASS (REGNO (operands[2]))"
5144   "*
5145 {
5146   rtx xoperands[2];
5147
5148   if (FP_REG_P (operands[0]))
5149     output_asm_insn (output_fp_move_double (operands), operands);
5150   else
5151     output_asm_insn (output_move_double (operands), operands);
5152
5153   xoperands[0] = operands[2];
5154   xoperands[1] = operands[0];
5155       
5156   if (FP_REG_P (xoperands[1]))
5157     output_asm_insn (output_fp_move_double (xoperands), xoperands);
5158   else
5159     output_asm_insn (output_move_double (xoperands), xoperands);
5160
5161   return \"\";
5162 }")
5163
5164 ;; Flush the I and D cache line found at the address in operand 0.
5165 ;; This is used by the trampoline code for nested functions.
5166 ;; So long as the trampoline itself is less than 32 bytes this
5167 ;; is sufficient.
5168
5169 (define_insn "dcacheflush"
5170   [(unspec_volatile [(const_int 1)] 0)
5171    (use (mem:SI (match_operand 0 "register_operand" "r")))
5172    (use (mem:SI (match_operand 1 "register_operand" "r")))]
5173   ""
5174   "fdc 0(%0)\;fdc 0(%1)\;sync"
5175   [(set_attr "type" "multi")
5176    (set_attr "length" "12")])
5177
5178 (define_insn "icacheflush"
5179   [(unspec_volatile [(const_int 2)] 0)
5180    (use (mem:SI (match_operand 0 "register_operand" "r")))
5181    (use (mem:SI (match_operand 1 "register_operand" "r")))
5182    (use (match_operand 2 "register_operand" "r"))
5183    (clobber (match_operand 3 "register_operand" "=&r"))
5184    (clobber (match_operand 4 "register_operand" "=&r"))]
5185   ""
5186   "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"
5187   [(set_attr "type" "multi")
5188    (set_attr "length" "52")])
5189
5190 ;; An out-of-line prologue.
5191 (define_insn "outline_prologue_call"
5192   [(unspec_volatile [(const_int 0)] 0)
5193    (clobber (reg:SI 31))
5194    (clobber (reg:SI 22))
5195    (clobber (reg:SI 21))
5196    (clobber (reg:SI 20))
5197    (clobber (reg:SI 19))
5198    (clobber (reg:SI 1))]
5199   ""
5200   "*
5201 {
5202   extern int frame_pointer_needed;
5203
5204   /* We need two different versions depending on whether or not we
5205      need a frame pointer.   Also note that we return to the instruction
5206      immediately after the branch rather than two instructions after the
5207      break as normally is the case.  */
5208   if (frame_pointer_needed)
5209     {
5210       /* Must import the magic millicode routine(s).  */
5211       output_asm_insn (\".IMPORT __outline_prologue_fp,MILLICODE\", NULL);
5212
5213       if (TARGET_PORTABLE_RUNTIME)
5214         {
5215           output_asm_insn (\"ldil L'__outline_prologue_fp,%%r31\", NULL);
5216           output_asm_insn (\"ble,n R'__outline_prologue_fp(%%sr0,%%r31)\",
5217                            NULL);
5218         }
5219       else
5220         output_asm_insn (\"bl,n __outline_prologue_fp,%%r31\", NULL);
5221     }
5222   else
5223     {
5224       /* Must import the magic millicode routine(s).  */
5225       output_asm_insn (\".IMPORT __outline_prologue,MILLICODE\", NULL);
5226
5227       if (TARGET_PORTABLE_RUNTIME)
5228         {
5229           output_asm_insn (\"ldil L'__outline_prologue,%%r31\", NULL);
5230           output_asm_insn (\"ble,n R'__outline_prologue(%%sr0,%%r31)\", NULL);
5231         }
5232       else
5233         output_asm_insn (\"bl,n __outline_prologue,%%r31\", NULL);
5234     }
5235   return \"\";
5236 }"
5237   [(set_attr "type" "multi")
5238    (set_attr "length" "8")])
5239
5240 ;; An out-of-line epilogue.
5241 (define_insn "outline_epilogue_call"
5242   [(unspec_volatile [(const_int 1)] 0)
5243    (use (reg:SI 29))
5244    (use (reg:SI 28))
5245    (clobber (reg:SI 31))
5246    (clobber (reg:SI 22))
5247    (clobber (reg:SI 21))
5248    (clobber (reg:SI 20))
5249    (clobber (reg:SI 19))
5250    (clobber (reg:SI 2))
5251    (clobber (reg:SI 1))]
5252   ""
5253   "*
5254 {
5255   extern int frame_pointer_needed;
5256
5257   /* We need two different versions depending on whether or not we
5258      need a frame pointer.   Also note that we return to the instruction
5259      immediately after the branch rather than two instructions after the
5260      break as normally is the case.  */
5261   if (frame_pointer_needed)
5262     {
5263       /* Must import the magic millicode routine.  */
5264       output_asm_insn (\".IMPORT __outline_epilogue_fp,MILLICODE\", NULL);
5265
5266       /* The out-of-line prologue will make sure we return to the right
5267          instruction.  */
5268       if (TARGET_PORTABLE_RUNTIME)
5269         {
5270           output_asm_insn (\"ldil L'__outline_epilogue_fp,%%r31\", NULL);
5271           output_asm_insn (\"ble,n R'__outline_epilogue_fp(%%sr0,%%r31)\",
5272                            NULL);
5273         }
5274       else
5275         output_asm_insn (\"bl,n __outline_epilogue_fp,%%r31\", NULL);
5276     }
5277   else
5278     {
5279       /* Must import the magic millicode routine.  */
5280       output_asm_insn (\".IMPORT __outline_epilogue,MILLICODE\", NULL);
5281
5282       /* The out-of-line prologue will make sure we return to the right
5283          instruction.  */
5284       if (TARGET_PORTABLE_RUNTIME)
5285         {
5286           output_asm_insn (\"ldil L'__outline_epilogue,%%r31\", NULL);
5287           output_asm_insn (\"ble,n R'__outline_epilogue(%%sr0,%%r31)\", NULL);
5288         }
5289       else
5290         output_asm_insn (\"bl,n __outline_epilogue,%%r31\", NULL);
5291     }
5292   return \"\";
5293 }"
5294   [(set_attr "type" "multi")
5295    (set_attr "length" "8")])
5296
5297 ;; Given a function pointer, canonicalize it so it can be 
5298 ;; reliably compared to another function pointer.  */
5299 (define_expand "canonicalize_funcptr_for_compare"
5300   [(set (reg:SI 26) (match_operand:SI 1 "register_operand" ""))
5301    (parallel [(set (reg:SI 29) (unspec:SI [(reg:SI 26)] 0))
5302               (clobber (match_dup 2))
5303               (clobber (reg:SI 26))
5304               (clobber (reg:SI 22))
5305               (clobber (reg:SI 31))])
5306    (set (match_operand:SI 0 "register_operand" "")
5307         (reg:SI 29))]
5308   "! TARGET_PORTABLE_RUNTIME"
5309   "
5310 {
5311   operands[2] = gen_reg_rtx (SImode);
5312   if (GET_CODE (operands[1]) != REG)
5313     {
5314       rtx tmp = gen_reg_rtx (Pmode);
5315       emit_move_insn (tmp, operands[1]);
5316       operands[1] = tmp;
5317     }
5318 }")
5319
5320 (define_insn ""
5321   [(set (reg:SI 29) (unspec:SI [(reg:SI 26)] 0))
5322    (clobber (match_operand:SI 0 "register_operand" "=a"))
5323    (clobber (reg:SI 26))
5324    (clobber (reg:SI 22))
5325    (clobber (reg:SI 31))]
5326   ""
5327   "*
5328 {
5329   /* Must import the magic millicode routine.  */
5330   output_asm_insn (\".IMPORT $$sh_func_adrs,MILLICODE\", NULL);
5331
5332   /* This is absolutely amazing.
5333
5334      First, copy our input parameter into %r29 just in case we don't
5335      need to call $$sh_func_adrs.  */
5336   output_asm_insn (\"copy %%r26,%%r29\", NULL);
5337
5338   /* Next, examine the low two bits in %r26, if they aren't 0x2, then
5339      we use %r26 unchanged.  */
5340   if (get_attr_length (insn) == 32)
5341     output_asm_insn (\"extru %%r26,31,2,%%r31\;comib,<>,n 2,%%r31,.+24\", NULL);
5342   else if (get_attr_length (insn) == 40)
5343     output_asm_insn (\"extru %%r26,31,2,%%r31\;comib,<>,n 2,%%r31,.+32\", NULL);
5344   else if (get_attr_length (insn) == 44)
5345     output_asm_insn (\"extru %%r26,31,2,%%r31\;comib,<>,n 2,%%r31,.+36\", NULL);
5346   else
5347     output_asm_insn (\"extru %%r26,31,2,%%r31\;comib,<>,n 2,%%r31,.+20\", NULL);
5348
5349   /* Next, compare %r26 with 4096, if %r26 is less than or equal to
5350      4096, then we use %r26 unchanged.  */
5351   if (get_attr_length (insn) == 32)
5352     output_asm_insn (\"ldi 4096,%%r31\;comb,<<,n %%r26,%%r31,.+16\", NULL);
5353   else if (get_attr_length (insn) == 40)
5354     output_asm_insn (\"ldi 4096,%%r31\;comb,<<,n %%r26,%%r31,.+24\", NULL);
5355   else if (get_attr_length (insn) == 44)
5356     output_asm_insn (\"ldi 4096,%%r31\;comb,<<,n %%r26,%%r31,.+28\", NULL);
5357   else
5358     output_asm_insn (\"ldi 4096,%%r31\;comb,<<,n %%r26,%%r31,.+12\", NULL);
5359
5360   /* Else call $$sh_func_adrs to extract the function's real add24.  */
5361   return output_millicode_call (insn,
5362                                 gen_rtx_SYMBOL_REF (SImode, \"$$sh_func_adrs\"));
5363 }"
5364   [(set_attr "type" "multi")
5365    (set (attr "length")
5366      (cond [
5367 ;; Target (or stub) within reach
5368             (and (lt (plus (symbol_ref "total_code_bytes") (pc))
5369                      (const_int 240000))
5370                  (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
5371                      (const_int 0)))
5372             (const_int 28)
5373
5374 ;; NO_SPACE_REGS
5375             (ne (symbol_ref "TARGET_NO_SPACE_REGS || TARGET_FAST_INDIRECT_CALLS")
5376                 (const_int 0))
5377             (const_int 32)
5378
5379 ;; Out of reach, but not PIC or PORTABLE_RUNTIME
5380 ;; same as NO_SPACE_REGS code
5381             (and (eq (symbol_ref "TARGET_PORTABLE_RUNTIME")
5382                      (const_int 0))
5383                  (eq (symbol_ref "flag_pic")
5384                      (const_int 0)))
5385             (const_int 32)
5386
5387 ;; PORTABLE_RUNTIME
5388             (ne (symbol_ref "TARGET_PORTABLE_RUNTIME")
5389                 (const_int 0))
5390             (const_int 40)]
5391
5392 ;; Out of range and PIC 
5393           (const_int 44)))])
5394
5395 ;; On the PA, the PIC register is call clobbered, so it must
5396 ;; be saved & restored around calls by the caller.  If the call
5397 ;; doesn't return normally (nonlocal goto, or an exception is
5398 ;; thrown), then the code at the exception handler label must
5399 ;; restore the PIC register.
5400 (define_expand "exception_receiver"
5401   [(const_int 4)]
5402   "!TARGET_PORTABLE_RUNTIME && flag_pic"
5403   "
5404 {
5405   /* Load the PIC register from the stack slot (in our caller's
5406      frame).  */
5407   emit_move_insn (pic_offset_table_rtx,
5408                   gen_rtx_MEM (SImode, plus_constant (stack_pointer_rtx, -32)));
5409   emit_insn (gen_rtx_USE (VOIDmode, pic_offset_table_rtx));
5410   emit_insn (gen_blockage ());
5411   DONE;
5412 }")
5413
5414