1;;- Machine description for HP PA-RISC architecture for GCC compiler
2;;   Copyright (C) 1992-2018 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 GCC.
7
8;; GCC is free software; you can redistribute it and/or modify
9;; it under the terms of the GNU General Public License as published by
10;; the Free Software Foundation; either version 3, or (at your option)
11;; any later version.
12
13;; GCC is distributed in the hope that it will be useful,
14;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16;; GNU General Public License for more details.
17
18;; You should have received a copy of the GNU General Public License
19;; along with GCC; see the file COPYING3.  If not see
20;; <http://www.gnu.org/licenses/>.
21
22;; This machine description is inspired by sparc.md and to a lesser
23;; extent mips.md.
24
25;; Possible improvements:
26;;
27;; * With PA1.1, most computational instructions can conditionally nullify
28;;   the execution of the following instruction.  A nullified instruction
29;;   does not cause the instruction pipeline to stall, making it a very
30;;   efficient alternative to e.g. branching or conditional moves.
31;;
32;;   Nullification is performed conditionally based on the outcome of a
33;;   test specified in the opcode.  The test result is stored in PSW[N]
34;;   and can only be used to nullify the instruction following immediately
35;;   after the test.  For example:
36;;
37;;	ldi 10,%r26
38;;	ldi 5,%r25
39;;	sub,< %r26,%r25,%r28
40;;	sub   %r28,%r25,%r28	; %r28 == 0
41;;	sub,> %r26,%r25,%r29
42;;	sub   %r29,%r25,%r29	; %r29 == 5
43;;
44;;   This could be tricky to implement because the result of the test has
45;;   to be propagated one instruction forward, which, in the worst case,
46;;   would involve (1) adding a fake register for PSW[N]; (2) adding the
47;;   variants of the computational instructions that set or consume this
48;;   fake register.  The cond_exec infrastructure is probably not helpful
49;;   for this.
50;;
51;; * PA-RISC includes a set of conventions for branch instruction usage
52;;   to indicate whether a particular branch is more likely to be taken
53;;   or not taken.  For example, the prediction for CMPB instructions
54;;   (CMPB,cond,n r1,r2,target) depends on the direction of the branch
55;;   (forward or backward) and on the order of the operands:
56;;
57;;     | branch    | operand  | branch     |
58;;     | direction | compare  | prediction |
59;;     +-----------+----------+------------+
60;;     | backward  | r1 < r2  | taken      |
61;;     | backward  | r1 >= r2 | not taken  |
62;;     | forward   | r1 < r2  | not taken  |
63;;     | forward   | r1 >= r2 | taken      |
64;;
65;;   By choosing instructions and operand order carefully, the compiler
66;;   could give the CPU branch predictor some help.
67;;
68
69;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
70
71;; Uses of UNSPEC in this file:
72
73(define_c_enum "unspec"
74  [UNSPEC_CFFC		; canonicalize_funcptr_for_compare
75   UNSPEC_GOTO		; indirect_goto
76   UNSPEC_DLTIND14R
77   UNSPEC_TP
78   UNSPEC_TLSGD
79   UNSPEC_TLSLDM
80   UNSPEC_TLSLDO
81   UNSPEC_TLSLDBASE
82   UNSPEC_TLSIE
83   UNSPEC_TLSLE
84   UNSPEC_TLSGD_PIC
85   UNSPEC_TLSLDM_PIC
86   UNSPEC_TLSIE_PIC
87   UNSPEC_MEMORY_BARRIER
88  ])
89
90;; UNSPEC_VOLATILE:
91
92(define_c_enum "unspecv"
93  [UNSPECV_BLOCKAGE	; blockage
94   UNSPECV_DCACHE	; dcacheflush
95   UNSPECV_ICACHE	; icacheflush
96   UNSPECV_OPC		; outline_prologue_call
97   UNSPECV_OEC		; outline_epilogue_call
98   UNSPECV_LONGJMP	; builtin_longjmp
99  ])
100
101;; Maximum pc-relative branch offsets.
102
103;; These numbers are a bit smaller than the maximum allowable offsets
104;; so that a few instructions may be inserted before the actual branch.
105
106(define_constants
107  [(MAX_12BIT_OFFSET     8184)	; 12-bit branch
108   (MAX_17BIT_OFFSET   262100)	; 17-bit branch
109  ])
110
111;; Mode and code iterators
112
113;; This mode iterator allows :P to be used for patterns that operate on
114;; pointer-sized quantities.  Exactly one of the two alternatives will match.
115(define_mode_iterator P [(SI "Pmode == SImode") (DI "Pmode == DImode")])
116
117;; This attribute defines the condition prefix for word and double word
118;; add, compare, subtract and logical instructions.
119(define_mode_attr dwc [(SI "") (DI "*")])
120
121;; Insn type.  Used to default other attribute values.
122
123;; type "unary" insns have one input operand (1) and one output operand (0)
124;; type "binary" insns have two input operands (1,2) and one output (0)
125
126(define_attr "type"
127  "move,unary,binary,shift,nullshift,compare,load,store,uncond_branch,branch,cbranch,fbranch,call,sibcall,dyncall,fpload,fpstore,fpalu,fpcc,fpmulsgl,fpmuldbl,fpdivsgl,fpdivdbl,fpsqrtsgl,fpsqrtdbl,multi,milli,sh_func_adrs,parallel_branch,fpstore_load,store_fpload,trap"
128  (const_string "binary"))
129
130(define_attr "pa_combine_type"
131  "fmpy,faddsub,uncond_branch,addmove,none"
132  (const_string "none"))
133
134;; Processor type (for scheduling, not code generation) -- this attribute
135;; must exactly match the processor_type enumeration in pa.h.
136;;
137;; FIXME: Add 800 scheduling for completeness?
138
139(define_attr "cpu" "700,7100,7100LC,7200,7300,8000" (const (symbol_ref "pa_cpu_attr")))
140
141;; Length (in # of bytes).
142(define_attr "length" ""
143  (cond [(eq_attr "type" "load,fpload")
144	 (if_then_else (match_operand 1 "symbolic_memory_operand" "")
145		       (const_int 8) (const_int 4))
146
147	 (eq_attr "type" "store,fpstore")
148	 (if_then_else (match_operand 0 "symbolic_memory_operand" "")
149		       (const_int 8) (const_int 4))
150
151	 (eq_attr "type" "binary,shift,nullshift")
152	 (if_then_else (match_operand 2 "arith14_operand" "")
153		       (const_int 4) (const_int 12))
154
155	 (eq_attr "type" "move,unary,shift,nullshift")
156	 (if_then_else (match_operand 1 "arith14_operand" "")
157		       (const_int 4) (const_int 8))]
158
159	(const_int 4)))
160
161(define_asm_attributes
162  [(set_attr "length" "4")
163   (set_attr "type" "multi")])
164
165;; Attributes for instruction and branch scheduling
166
167;; For conditional branches. Frame related instructions are not allowed
168;; because they confuse the unwind support.
169(define_attr "in_branch_delay" "false,true"
170  (if_then_else (and (eq_attr "type" "!uncond_branch,branch,cbranch,fbranch,call,sibcall,dyncall,multi,milli,sh_func_adrs,parallel_branch,trap")
171		     (eq_attr "length" "4")
172		     (not (match_test "RTX_FRAME_RELATED_P (insn)")))
173		(const_string "true")
174		(const_string "false")))
175
176;; Disallow instructions which use the FPU since they will tie up the FPU
177;; even if the instruction is nullified.
178(define_attr "in_nullified_branch_delay" "false,true"
179  (if_then_else (and (eq_attr "type" "!uncond_branch,branch,cbranch,fbranch,call,sibcall,dyncall,multi,milli,sh_func_adrs,fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpdivdbl,fpsqrtsgl,fpsqrtdbl,parallel_branch,trap")
180		     (eq_attr "length" "4")
181		     (not (match_test "RTX_FRAME_RELATED_P (insn)")))
182		(const_string "true")
183		(const_string "false")))
184
185;; For calls and millicode calls.
186(define_attr "in_call_delay" "false,true"
187  (if_then_else (and (eq_attr "type" "!uncond_branch,branch,cbranch,fbranch,call,sibcall,dyncall,multi,milli,sh_func_adrs,parallel_branch,trap")
188		     (eq_attr "length" "4")
189		     (not (match_test "RTX_FRAME_RELATED_P (insn)")))
190		(const_string "true")
191		(const_string "false")))
192
193;; Call delay slot description.
194(define_delay (eq_attr "type" "call")
195  [(eq_attr "in_call_delay" "true") (nil) (nil)])
196
197;; Sibcall delay slot description.
198(define_delay (eq_attr "type" "sibcall")
199  [(eq_attr "in_call_delay" "true") (nil) (nil)])
200
201;; Millicode call delay slot description.
202(define_delay (eq_attr "type" "milli")
203  [(eq_attr "in_call_delay" "true") (nil) (nil)])
204
205;; Return and other similar instructions.
206(define_delay (eq_attr "type" "branch,parallel_branch")
207  [(eq_attr "in_branch_delay" "true") (nil) (nil)])
208
209;; Floating point conditional branch delay slot description.
210(define_delay (eq_attr "type" "fbranch")
211  [(eq_attr "in_branch_delay" "true")
212   (eq_attr "in_nullified_branch_delay" "true")
213   (nil)])
214
215;; Integer conditional branch delay slot description.
216;; Nullification of conditional branches on the PA is dependent on the
217;; direction of the branch.  Forward branches nullify true and
218;; backward branches nullify false.  If the direction is unknown
219;; then nullification is not allowed.
220(define_delay (eq_attr "type" "cbranch")
221  [(eq_attr "in_branch_delay" "true")
222   (and (eq_attr "in_nullified_branch_delay" "true")
223	(attr_flag "forward"))
224   (and (eq_attr "in_nullified_branch_delay" "true")
225	(attr_flag "backward"))])
226
227(define_delay (eq_attr "type" "uncond_branch")
228  [(eq_attr "in_branch_delay" "true") (nil) (nil)])
229
230;; Memory. Disregarding Cache misses, the Mustang memory times are:
231;; load: 2, fpload: 3
232;; store, fpstore: 3, no D-cache operations should be scheduled.
233
234;; The Timex (aka 700) has two floating-point units: ALU, and MUL/DIV/SQRT.
235;; Timings:
236;; Instruction	Time	Unit	Minimum Distance (unit contention)
237;; fcpy		3	ALU	2
238;; fabs		3	ALU	2
239;; fadd		3	ALU	2
240;; fsub		3	ALU	2
241;; fcmp		3	ALU	2
242;; fcnv		3	ALU	2
243;; fmpyadd	3	ALU,MPY	2
244;; fmpysub	3	ALU,MPY 2
245;; fmpycfxt	3	ALU,MPY 2
246;; fmpy		3	MPY	2
247;; fmpyi	3	MPY	2
248;; fdiv,sgl	10	MPY	10
249;; fdiv,dbl	12	MPY	12
250;; fsqrt,sgl	14	MPY	14
251;; fsqrt,dbl	18	MPY	18
252;;
253;; We don't model fmpyadd/fmpysub properly as those instructions
254;; keep both the FP ALU and MPY units busy.  Given that these
255;; processors are obsolete, I'm not going to spend the time to
256;; model those instructions correctly.
257
258(define_automaton "pa700")
259(define_cpu_unit "dummy_700,mem_700,fpalu_700,fpmpy_700" "pa700")
260
261(define_insn_reservation "W0" 4
262  (and (eq_attr "type" "fpcc")
263       (eq_attr "cpu" "700"))
264  "fpalu_700*2")
265
266(define_insn_reservation "W1" 3
267  (and (eq_attr "type" "fpalu")
268       (eq_attr "cpu" "700"))
269  "fpalu_700*2")
270
271(define_insn_reservation "W2" 3
272  (and (eq_attr "type" "fpmulsgl,fpmuldbl")
273       (eq_attr "cpu" "700"))
274  "fpmpy_700*2")
275
276(define_insn_reservation "W3" 10
277  (and (eq_attr "type" "fpdivsgl")
278       (eq_attr "cpu" "700"))
279  "fpmpy_700*10")
280
281(define_insn_reservation "W4" 12
282  (and (eq_attr "type" "fpdivdbl")
283       (eq_attr "cpu" "700"))
284  "fpmpy_700*12")
285
286(define_insn_reservation "W5" 14
287  (and (eq_attr "type" "fpsqrtsgl")
288       (eq_attr "cpu" "700"))
289  "fpmpy_700*14")
290
291(define_insn_reservation "W6" 18
292  (and (eq_attr "type" "fpsqrtdbl")
293       (eq_attr "cpu" "700"))
294  "fpmpy_700*18")
295
296(define_insn_reservation "W7" 2
297  (and (eq_attr "type" "load")
298       (eq_attr "cpu" "700"))
299  "mem_700")
300
301(define_insn_reservation "W8" 2
302  (and (eq_attr "type" "fpload")
303       (eq_attr "cpu" "700"))
304  "mem_700")
305
306(define_insn_reservation "W9" 3
307  (and (eq_attr "type" "store")
308       (eq_attr "cpu" "700"))
309  "mem_700*3")
310
311(define_insn_reservation "W10" 3
312  (and (eq_attr "type" "fpstore")
313       (eq_attr "cpu" "700"))
314  "mem_700*3")
315
316(define_insn_reservation "W11" 5
317  (and (eq_attr "type" "fpstore_load")
318       (eq_attr "cpu" "700"))
319  "mem_700*5")
320
321(define_insn_reservation "W12" 6
322  (and (eq_attr "type" "store_fpload")
323       (eq_attr "cpu" "700"))
324  "mem_700*6")
325
326(define_insn_reservation "W13" 1
327  (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpdivdbl,fpsqrtsgl,fpsqrtdbl,load,fpload,store,fpstore,fpstore_load,store_fpload")
328       (eq_attr "cpu" "700"))
329  "dummy_700")
330
331;; We have a bypass for all computations in the FP unit which feed an
332;; FP store as long as the sizes are the same.
333(define_bypass 2 "W1,W2" "W10,W11" "pa_fpstore_bypass_p")
334(define_bypass 9 "W3" "W10,W11" "pa_fpstore_bypass_p")
335(define_bypass 11 "W4" "W10,W11" "pa_fpstore_bypass_p")
336(define_bypass 13 "W5" "W10,W11" "pa_fpstore_bypass_p")
337(define_bypass 17 "W6" "W10,W11" "pa_fpstore_bypass_p")
338
339;; We have an "anti-bypass" for FP loads which feed an FP store.
340(define_bypass 4 "W8,W12" "W10,W11" "pa_fpstore_bypass_p")
341
342;; Function units for the 7100 and 7150.  The 7100/7150 can dual-issue
343;; floating point computations with non-floating point computations (fp loads
344;; and stores are not fp computations).
345;;
346;; Memory. Disregarding Cache misses, memory loads take two cycles; stores also
347;; take two cycles, during which no Dcache operations should be scheduled.
348;; Any special cases are handled in pa_adjust_cost.  The 7100, 7150 and 7100LC
349;; all have the same memory characteristics if one disregards cache misses.
350;;
351;; The 7100/7150 has three floating-point units: ALU, MUL, and DIV.
352;; There's no value in modeling the ALU and MUL separately though
353;; since there can never be a functional unit conflict given the
354;; latency and issue rates for those units.
355;;
356;; Timings:
357;; Instruction	Time	Unit	Minimum Distance (unit contention)
358;; fcpy		2	ALU	1
359;; fabs		2	ALU	1
360;; fadd		2	ALU	1
361;; fsub		2	ALU	1
362;; fcmp		2	ALU	1
363;; fcnv		2	ALU	1
364;; fmpyadd	2	ALU,MPY	1
365;; fmpysub	2	ALU,MPY 1
366;; fmpycfxt	2	ALU,MPY 1
367;; fmpy		2	MPY	1
368;; fmpyi	2	MPY	1
369;; fdiv,sgl	8	DIV	8
370;; fdiv,dbl	15	DIV	15
371;; fsqrt,sgl	8	DIV	8
372;; fsqrt,dbl	15	DIV	15
373
374(define_automaton "pa7100")
375(define_cpu_unit "i_7100, f_7100,fpmac_7100,fpdivsqrt_7100,mem_7100" "pa7100")
376
377(define_insn_reservation "X0" 2
378  (and (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
379       (eq_attr "cpu" "7100"))
380  "f_7100,fpmac_7100")
381
382(define_insn_reservation "X1" 8
383  (and (eq_attr "type" "fpdivsgl,fpsqrtsgl")
384       (eq_attr "cpu" "7100"))
385  "f_7100+fpdivsqrt_7100,fpdivsqrt_7100*7")
386
387(define_insn_reservation "X2" 15
388  (and (eq_attr "type" "fpdivdbl,fpsqrtdbl")
389       (eq_attr "cpu" "7100"))
390  "f_7100+fpdivsqrt_7100,fpdivsqrt_7100*14")
391
392(define_insn_reservation "X3" 2
393  (and (eq_attr "type" "load")
394       (eq_attr "cpu" "7100"))
395  "i_7100+mem_7100")
396
397(define_insn_reservation "X4" 2
398  (and (eq_attr "type" "fpload")
399       (eq_attr "cpu" "7100"))
400  "i_7100+mem_7100")
401
402(define_insn_reservation "X5" 2
403  (and (eq_attr "type" "store")
404       (eq_attr "cpu" "7100"))
405  "i_7100+mem_7100,mem_7100")
406
407(define_insn_reservation "X6" 2
408  (and (eq_attr "type" "fpstore")
409       (eq_attr "cpu" "7100"))
410  "i_7100+mem_7100,mem_7100")
411
412(define_insn_reservation "X7" 4
413  (and (eq_attr "type" "fpstore_load")
414       (eq_attr "cpu" "7100"))
415  "i_7100+mem_7100,mem_7100*3")
416
417(define_insn_reservation "X8" 4
418  (and (eq_attr "type" "store_fpload")
419       (eq_attr "cpu" "7100"))
420  "i_7100+mem_7100,mem_7100*3")
421
422(define_insn_reservation "X9" 1
423  (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl,load,fpload,store,fpstore,fpstore_load,store_fpload")
424       (eq_attr "cpu" "7100"))
425  "i_7100")
426
427;; We have a bypass for all computations in the FP unit which feed an
428;; FP store as long as the sizes are the same.
429(define_bypass 1 "X0" "X6,X7" "pa_fpstore_bypass_p")
430(define_bypass 7 "X1" "X6,X7" "pa_fpstore_bypass_p")
431(define_bypass 14 "X2" "X6,X7" "pa_fpstore_bypass_p")
432
433;; We have an "anti-bypass" for FP loads which feed an FP store.
434(define_bypass 3 "X4,X8" "X6,X7" "pa_fpstore_bypass_p")
435
436;; The 7100LC has three floating-point units: ALU, MUL, and DIV.
437;; There's no value in modeling the ALU and MUL separately though
438;; since there can never be a functional unit conflict that
439;; can be avoided given the latency, issue rates and mandatory
440;; one cycle cpu-wide lock for a double precision fp multiply.
441;;
442;; Timings:
443;; Instruction	Time	Unit	Minimum Distance (unit contention)
444;; fcpy		2	ALU	1
445;; fabs		2	ALU	1
446;; fadd		2	ALU	1
447;; fsub		2	ALU	1
448;; fcmp		2	ALU	1
449;; fcnv		2	ALU	1
450;; fmpyadd,sgl	2	ALU,MPY	1
451;; fmpyadd,dbl	3	ALU,MPY	2
452;; fmpysub,sgl	2	ALU,MPY 1
453;; fmpysub,dbl	3	ALU,MPY 2
454;; fmpycfxt,sgl	2	ALU,MPY 1
455;; fmpycfxt,dbl	3	ALU,MPY 2
456;; fmpy,sgl	2	MPY	1
457;; fmpy,dbl	3	MPY	2
458;; fmpyi	3	MPY	2
459;; fdiv,sgl	8	DIV	8
460;; fdiv,dbl	15	DIV	15
461;; fsqrt,sgl	8	DIV	8
462;; fsqrt,dbl	15	DIV	15
463;;
464;; The PA7200 is just like the PA7100LC except that there is
465;; no store-store penalty.
466;;
467;; The PA7300 is just like the PA7200 except that there is
468;; no store-load penalty.
469;;
470;; Note there are some aspects of the 7100LC we are not modeling
471;; at the moment.  I'll be reviewing the 7100LC scheduling info
472;; shortly and updating this description.
473;;
474;;   load-load pairs
475;;   store-store pairs
476;;   other issue modeling
477
478(define_automaton "pa7100lc")
479(define_cpu_unit "i0_7100lc, i1_7100lc, f_7100lc" "pa7100lc")
480(define_cpu_unit "fpmac_7100lc" "pa7100lc")
481(define_cpu_unit "mem_7100lc" "pa7100lc")
482
483;; Double precision multiplies lock the entire CPU for one
484;; cycle.  There is no way to avoid this lock and trying to
485;; schedule around the lock is pointless and thus there is no
486;; value in trying to model this lock.
487;;
488;; Not modeling the lock allows us to treat fp multiplies just
489;; like any other FP alu instruction.  It allows for a smaller
490;; DFA and may reduce register pressure.
491(define_insn_reservation "Y0" 2
492  (and (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
493       (eq_attr "cpu" "7100LC,7200,7300"))
494  "f_7100lc,fpmac_7100lc")
495
496;; fp division and sqrt instructions lock the entire CPU for
497;; 7 cycles (single precision) or 14 cycles (double precision).
498;; There is no way to avoid this lock and trying to schedule
499;; around the lock is pointless and thus there is no value in
500;; trying to model this lock.  Not modeling the lock allows
501;; for a smaller DFA and may reduce register pressure.
502(define_insn_reservation "Y1" 1
503  (and (eq_attr "type" "fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl")
504       (eq_attr "cpu" "7100LC,7200,7300"))
505  "f_7100lc")
506
507(define_insn_reservation "Y2" 2
508  (and (eq_attr "type" "load")
509       (eq_attr "cpu" "7100LC,7200,7300"))
510  "i1_7100lc+mem_7100lc")
511
512(define_insn_reservation "Y3" 2
513  (and (eq_attr "type" "fpload")
514       (eq_attr "cpu" "7100LC,7200,7300"))
515  "i1_7100lc+mem_7100lc")
516
517(define_insn_reservation "Y4" 2
518  (and (eq_attr "type" "store")
519       (eq_attr "cpu" "7100LC"))
520  "i1_7100lc+mem_7100lc,mem_7100lc")
521
522(define_insn_reservation "Y5" 2
523  (and (eq_attr "type" "fpstore")
524       (eq_attr "cpu" "7100LC"))
525  "i1_7100lc+mem_7100lc,mem_7100lc")
526
527(define_insn_reservation "Y6" 4
528  (and (eq_attr "type" "fpstore_load")
529       (eq_attr "cpu" "7100LC"))
530  "i1_7100lc+mem_7100lc,mem_7100lc*3")
531
532(define_insn_reservation "Y7" 4
533  (and (eq_attr "type" "store_fpload")
534       (eq_attr "cpu" "7100LC"))
535  "i1_7100lc+mem_7100lc,mem_7100lc*3")
536
537(define_insn_reservation "Y8" 1
538  (and (eq_attr "type" "shift,nullshift")
539       (eq_attr "cpu" "7100LC,7200,7300"))
540  "i1_7100lc")
541
542(define_insn_reservation "Y9" 1
543  (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl,load,fpload,store,fpstore,shift,nullshift")
544       (eq_attr "cpu" "7100LC,7200,7300"))
545  "(i0_7100lc|i1_7100lc)")
546
547;; The 7200 has a store-load penalty
548(define_insn_reservation "Y10" 2
549  (and (eq_attr "type" "store")
550       (eq_attr "cpu" "7200"))
551  "i1_7100lc,mem_7100lc")
552
553(define_insn_reservation "Y11" 2
554  (and (eq_attr "type" "fpstore")
555       (eq_attr "cpu" "7200"))
556  "i1_7100lc,mem_7100lc")
557
558(define_insn_reservation "Y12" 4
559  (and (eq_attr "type" "fpstore_load")
560       (eq_attr "cpu" "7200"))
561  "i1_7100lc,mem_7100lc,i1_7100lc+mem_7100lc")
562
563(define_insn_reservation "Y13" 4
564  (and (eq_attr "type" "store_fpload")
565       (eq_attr "cpu" "7200"))
566  "i1_7100lc,mem_7100lc,i1_7100lc+mem_7100lc")
567
568;; The 7300 has no penalty for store-store or store-load
569(define_insn_reservation "Y14" 2
570  (and (eq_attr "type" "store")
571       (eq_attr "cpu" "7300"))
572  "i1_7100lc")
573
574(define_insn_reservation "Y15" 2
575  (and (eq_attr "type" "fpstore")
576       (eq_attr "cpu" "7300"))
577  "i1_7100lc")
578
579(define_insn_reservation "Y16" 4
580  (and (eq_attr "type" "fpstore_load")
581       (eq_attr "cpu" "7300"))
582  "i1_7100lc,i1_7100lc+mem_7100lc")
583
584(define_insn_reservation "Y17" 4
585  (and (eq_attr "type" "store_fpload")
586       (eq_attr "cpu" "7300"))
587  "i1_7100lc,i1_7100lc+mem_7100lc")
588
589;; We have an "anti-bypass" for FP loads which feed an FP store.
590(define_bypass 3 "Y3,Y7,Y13,Y17" "Y5,Y6,Y11,Y12,Y15,Y16" "pa_fpstore_bypass_p")
591
592;; Scheduling for the PA8000 is somewhat different than scheduling for a
593;; traditional architecture.
594;;
595;; The PA8000 has a large (56) entry reorder buffer that is split between
596;; memory and non-memory operations.
597;;
598;; The PA8000 can issue two memory and two non-memory operations per cycle to
599;; the function units, with the exception of branches and multi-output
600;; instructions.  The PA8000 can retire two non-memory operations per cycle
601;; and two memory operations per cycle, only one of which may be a store.
602;;
603;; Given the large reorder buffer, the processor can hide most latencies.
604;; According to HP, they've got the best results by scheduling for retirement
605;; bandwidth with limited latency scheduling for floating point operations.
606;; Latency for integer operations and memory references is ignored.
607;;
608;;
609;; We claim floating point operations have a 2 cycle latency and are
610;; fully pipelined, except for div and sqrt which are not pipelined and
611;; take from 17 to 31 cycles to complete.
612;;
613;; It's worth noting that there is no way to saturate all the functional
614;; units on the PA8000 as there is not enough issue bandwidth.
615
616(define_automaton "pa8000")
617(define_cpu_unit "inm0_8000, inm1_8000, im0_8000, im1_8000" "pa8000")
618(define_cpu_unit "rnm0_8000, rnm1_8000, rm0_8000, rm1_8000" "pa8000")
619(define_cpu_unit "store_8000" "pa8000")
620(define_cpu_unit "f0_8000, f1_8000" "pa8000")
621(define_cpu_unit "fdivsqrt0_8000, fdivsqrt1_8000" "pa8000")
622(define_reservation "inm_8000" "inm0_8000 | inm1_8000")
623(define_reservation "im_8000" "im0_8000 | im1_8000")
624(define_reservation "rnm_8000" "rnm0_8000 | rnm1_8000")
625(define_reservation "rm_8000" "rm0_8000 | rm1_8000")
626(define_reservation "f_8000" "f0_8000 | f1_8000")
627(define_reservation "fdivsqrt_8000" "fdivsqrt0_8000 | fdivsqrt1_8000")
628
629;; We can issue any two memops per cycle, but we can only retire
630;; one memory store per cycle.  We assume that the reorder buffer
631;; will hide any memory latencies per HP's recommendation.
632(define_insn_reservation "Z0" 0
633  (and
634    (eq_attr "type" "load,fpload")
635    (eq_attr "cpu" "8000"))
636  "im_8000,rm_8000")
637
638(define_insn_reservation "Z1" 0
639  (and
640    (eq_attr "type" "store,fpstore")
641    (eq_attr "cpu" "8000"))
642  "im_8000,rm_8000+store_8000")
643
644(define_insn_reservation "Z2" 0
645  (and (eq_attr "type" "fpstore_load,store_fpload")
646       (eq_attr "cpu" "8000"))
647  "im_8000,rm_8000+store_8000,im_8000,rm_8000")
648
649;; We can issue and retire two non-memory operations per cycle with
650;; a few exceptions (branches).  This group catches those we want
651;; to assume have zero latency.
652(define_insn_reservation "Z3" 0
653  (and
654    (eq_attr "type" "!load,fpload,store,fpstore,uncond_branch,branch,cbranch,fbranch,call,sibcall,dyncall,multi,milli,sh_func_adrs,parallel_branch,fpcc,fpalu,fpmulsgl,fpmuldbl,fpsqrtsgl,fpsqrtdbl,fpdivsgl,fpdivdbl,fpstore_load,store_fpload")
655    (eq_attr "cpu" "8000"))
656  "inm_8000,rnm_8000")
657
658;; Branches use both slots in the non-memory issue and
659;; retirement unit.
660(define_insn_reservation "Z4" 0
661  (and
662    (eq_attr "type" "uncond_branch,branch,cbranch,fbranch,call,sibcall,dyncall,multi,milli,sh_func_adrs,parallel_branch")
663    (eq_attr "cpu" "8000"))
664  "inm0_8000+inm1_8000,rnm0_8000+rnm1_8000")
665
666;; We partial latency schedule the floating point units.
667;; They can issue/retire two at a time in the non-memory
668;; units.  We fix their latency at 2 cycles and they
669;; are fully pipelined.
670(define_insn_reservation "Z5" 1
671 (and
672   (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
673   (eq_attr "cpu" "8000"))
674 "inm_8000,f_8000,rnm_8000")
675
676;; The fdivsqrt units are not pipelined and have a very long latency.
677;; To keep the DFA from exploding, we do not show all the
678;; reservations for the divsqrt unit.
679(define_insn_reservation "Z6" 17
680 (and
681   (eq_attr "type" "fpdivsgl,fpsqrtsgl")
682   (eq_attr "cpu" "8000"))
683 "inm_8000,fdivsqrt_8000*6,rnm_8000")
684
685(define_insn_reservation "Z7" 31
686 (and
687   (eq_attr "type" "fpdivdbl,fpsqrtdbl")
688   (eq_attr "cpu" "8000"))
689 "inm_8000,fdivsqrt_8000*6,rnm_8000")
690
691;; Operand and operator predicates and constraints
692
693(include "predicates.md")
694(include "constraints.md")
695
696;; Compare instructions.
697;; This controls RTL generation and register allocation.
698
699(define_insn ""
700  [(set (reg:CCFP 0)
701	(match_operator:CCFP 2 "comparison_operator"
702			     [(match_operand:SF 0 "reg_or_0_operand" "fG")
703			      (match_operand:SF 1 "reg_or_0_operand" "fG")]))]
704  "! TARGET_SOFT_FLOAT"
705  "fcmp,sgl,%Y2 %f0,%f1"
706  [(set_attr "length" "4")
707   (set_attr "type" "fpcc")])
708
709(define_insn ""
710  [(set (reg:CCFP 0)
711	(match_operator:CCFP 2 "comparison_operator"
712			     [(match_operand:DF 0 "reg_or_0_operand" "fG")
713			      (match_operand:DF 1 "reg_or_0_operand" "fG")]))]
714  "! TARGET_SOFT_FLOAT"
715  "fcmp,dbl,%Y2 %f0,%f1"
716  [(set_attr "length" "4")
717   (set_attr "type" "fpcc")])
718
719;; Provide a means to emit the movccfp0 and movccfp1 optimization
720;; placeholders.  This is necessary in rare situations when a
721;; placeholder is re-emitted (see PR 8705).
722
723(define_expand "movccfp"
724  [(set (reg:CCFP 0)
725	(match_operand 0 "const_int_operand" ""))]
726  "! TARGET_SOFT_FLOAT"
727  "
728{
729  if ((unsigned HOST_WIDE_INT) INTVAL (operands[0]) > 1)
730    FAIL;
731}")
732
733;; The following patterns are optimization placeholders.  In almost
734;; all cases, the user of the condition code will be simplified and the
735;; original condition code setting insn should be eliminated.
736
737(define_insn "*movccfp0"
738  [(set (reg:CCFP 0)
739	(const_int 0))]
740  "! TARGET_SOFT_FLOAT"
741  "fcmp,dbl,= %%fr0,%%fr0"
742  [(set_attr "length" "4")
743   (set_attr "type" "fpcc")])
744
745(define_insn "*movccfp1"
746  [(set (reg:CCFP 0)
747	(const_int 1))]
748  "! TARGET_SOFT_FLOAT"
749  "fcmp,dbl,!= %%fr0,%%fr0"
750  [(set_attr "length" "4")
751   (set_attr "type" "fpcc")])
752
753;; scc insns.
754
755(define_expand "cstoresi4"
756  [(set (match_operand:SI 0 "register_operand")
757	(match_operator:SI 1 "ordered_comparison_operator"
758	 [(match_operand:SI 2 "reg_or_0_operand" "")
759	  (match_operand:SI 3 "arith5_operand" "")]))]
760  "!TARGET_64BIT"
761  "")
762
763;; Instruction canonicalization puts immediate operands second, which
764;; is the reverse of what we want.
765
766(define_insn "scc"
767  [(set (match_operand:SI 0 "register_operand" "=r")
768	(match_operator:SI 3 "ordered_comparison_operator"
769			   [(match_operand:SI 1 "reg_or_0_operand" "rM")
770			    (match_operand:SI 2 "arith11_operand" "rI")]))]
771  ""
772  "{com%I2clr|cmp%I2clr},%B3 %2,%r1,%0\;ldi 1,%0"
773  [(set_attr "type" "binary")
774   (set_attr "length" "8")])
775
776(define_insn ""
777  [(set (match_operand:DI 0 "register_operand" "=r")
778	(match_operator:DI 3 "ordered_comparison_operator"
779			   [(match_operand:DI 1 "reg_or_0_operand" "rM")
780			    (match_operand:DI 2 "arith11_operand" "rI")]))]
781  "TARGET_64BIT"
782  "cmp%I2clr,*%B3 %2,%r1,%0\;ldi 1,%0"
783  [(set_attr "type" "binary")
784   (set_attr "length" "8")])
785
786(define_insn "iorscc"
787  [(set (match_operand:SI 0 "register_operand" "=r")
788	(ior:SI (match_operator:SI 3 "ordered_comparison_operator"
789				   [(match_operand:SI 1 "reg_or_0_operand" "rM")
790				    (match_operand:SI 2 "arith11_operand" "rI")])
791		(match_operator:SI 6 "ordered_comparison_operator"
792				   [(match_operand:SI 4 "reg_or_0_operand" "rM")
793				    (match_operand:SI 5 "arith11_operand" "rI")])))]
794  ""
795  "{com%I2clr|cmp%I2clr},%S3 %2,%r1,%%r0\;{com%I5clr|cmp%I5clr},%B6 %5,%r4,%0\;ldi 1,%0"
796  [(set_attr "type" "binary")
797   (set_attr "length" "12")])
798
799(define_insn ""
800  [(set (match_operand:DI 0 "register_operand" "=r")
801	(ior:DI (match_operator:DI 3 "ordered_comparison_operator"
802				   [(match_operand:DI 1 "reg_or_0_operand" "rM")
803				    (match_operand:DI 2 "arith11_operand" "rI")])
804		(match_operator:DI 6 "ordered_comparison_operator"
805				   [(match_operand:DI 4 "reg_or_0_operand" "rM")
806				    (match_operand:DI 5 "arith11_operand" "rI")])))]
807  "TARGET_64BIT"
808  "cmp%I2clr,*%S3 %2,%r1,%%r0\;cmp%I5clr,*%B6 %5,%r4,%0\;ldi 1,%0"
809  [(set_attr "type" "binary")
810   (set_attr "length" "12")])
811
812;; Combiner patterns for common operations performed with the output
813;; from an scc insn (negscc and incscc).
814(define_insn "negscc"
815  [(set (match_operand:SI 0 "register_operand" "=r")
816	(neg:SI (match_operator:SI 3 "ordered_comparison_operator"
817	       [(match_operand:SI 1 "reg_or_0_operand" "rM")
818		(match_operand:SI 2 "arith11_operand" "rI")])))]
819  ""
820  "{com%I2clr|cmp%I2clr},%B3 %2,%r1,%0\;ldi -1,%0"
821  [(set_attr "type" "binary")
822   (set_attr "length" "8")])
823
824(define_insn ""
825  [(set (match_operand:DI 0 "register_operand" "=r")
826	(neg:DI (match_operator:DI 3 "ordered_comparison_operator"
827	       [(match_operand:DI 1 "reg_or_0_operand" "rM")
828		(match_operand:DI 2 "arith11_operand" "rI")])))]
829  "TARGET_64BIT"
830  "cmp%I2clr,*%B3 %2,%r1,%0\;ldi -1,%0"
831  [(set_attr "type" "binary")
832   (set_attr "length" "8")])
833
834;; Patterns for adding/subtracting the result of a boolean expression from
835;; a register.  First we have special patterns that make use of the carry
836;; bit, and output only two instructions.  For the cases we can't in
837;; general do in two instructions, the incscc pattern at the end outputs
838;; two or three instructions.
839
840(define_insn ""
841  [(set (match_operand:SI 0 "register_operand" "=r")
842	(plus:SI (leu:SI (match_operand:SI 2 "register_operand" "r")
843			 (match_operand:SI 3 "arith11_operand" "rI"))
844		 (match_operand:SI 1 "register_operand" "r")))]
845  ""
846  "sub%I3 %3,%2,%%r0\;{addc|add,c} %%r0,%1,%0"
847  [(set_attr "type" "binary")
848   (set_attr "length" "8")])
849
850(define_insn ""
851  [(set (match_operand:DI 0 "register_operand" "=r")
852	(plus:DI (leu:DI (match_operand:DI 2 "register_operand" "r")
853			 (match_operand:DI 3 "arith11_operand" "rI"))
854		 (match_operand:DI 1 "register_operand" "r")))]
855  "TARGET_64BIT"
856  "sub%I3 %3,%2,%%r0\;add,dc %%r0,%1,%0"
857  [(set_attr "type" "binary")
858   (set_attr "length" "8")])
859
860; This need only accept registers for op3, since canonicalization
861; replaces geu with gtu when op3 is an integer.
862(define_insn ""
863  [(set (match_operand:SI 0 "register_operand" "=r")
864	(plus:SI (geu:SI (match_operand:SI 2 "register_operand" "r")
865			 (match_operand:SI 3 "register_operand" "r"))
866		 (match_operand:SI 1 "register_operand" "r")))]
867  ""
868  "sub %2,%3,%%r0\;{addc|add,c} %%r0,%1,%0"
869  [(set_attr "type" "binary")
870   (set_attr "length" "8")])
871
872(define_insn ""
873  [(set (match_operand:DI 0 "register_operand" "=r")
874	(plus:DI (geu:DI (match_operand:DI 2 "register_operand" "r")
875			 (match_operand:DI 3 "register_operand" "r"))
876		 (match_operand:DI 1 "register_operand" "r")))]
877  "TARGET_64BIT"
878  "sub %2,%3,%%r0\;add,dc %%r0,%1,%0"
879  [(set_attr "type" "binary")
880   (set_attr "length" "8")])
881
882; Match only integers for op3 here.  This is used as canonical form of the
883; geu pattern when op3 is an integer.  Don't match registers since we can't
884; make better code than the general incscc pattern.
885(define_insn ""
886  [(set (match_operand:SI 0 "register_operand" "=r")
887	(plus:SI (gtu:SI (match_operand:SI 2 "register_operand" "r")
888			 (match_operand:SI 3 "int11_operand" "I"))
889		 (match_operand:SI 1 "register_operand" "r")))]
890  ""
891  "addi %k3,%2,%%r0\;{addc|add,c} %%r0,%1,%0"
892  [(set_attr "type" "binary")
893   (set_attr "length" "8")])
894
895(define_insn ""
896  [(set (match_operand:DI 0 "register_operand" "=r")
897	(plus:DI (gtu:DI (match_operand:DI 2 "register_operand" "r")
898			 (match_operand:DI 3 "int11_operand" "I"))
899		 (match_operand:DI 1 "register_operand" "r")))]
900  "TARGET_64BIT"
901  "addi %k3,%2,%%r0\;add,dc %%r0,%1,%0"
902  [(set_attr "type" "binary")
903   (set_attr "length" "8")])
904
905(define_insn "incscc"
906  [(set (match_operand:SI 0 "register_operand" "=r,r")
907 	(plus:SI (match_operator:SI 4 "ordered_comparison_operator"
908		    [(match_operand:SI 2 "register_operand" "r,r")
909		     (match_operand:SI 3 "arith11_operand" "rI,rI")])
910		 (match_operand:SI 1 "register_operand" "0,?r")))]
911  ""
912  "@
913   {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi 1,%0,%0
914   {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi,tr 1,%1,%0\;copy %1,%0"
915  [(set_attr "type" "binary,binary")
916   (set_attr "length" "8,12")])
917
918(define_insn ""
919  [(set (match_operand:DI 0 "register_operand" "=r,r")
920 	(plus:DI (match_operator:DI 4 "ordered_comparison_operator"
921		    [(match_operand:DI 2 "register_operand" "r,r")
922		     (match_operand:DI 3 "arith11_operand" "rI,rI")])
923		 (match_operand:DI 1 "register_operand" "0,?r")))]
924  "TARGET_64BIT"
925  "@
926   cmp%I3clr,*%B4 %3,%2,%%r0\;addi 1,%0,%0
927   cmp%I3clr,*%B4 %3,%2,%%r0\;addi,tr 1,%1,%0\;copy %1,%0"
928  [(set_attr "type" "binary,binary")
929   (set_attr "length" "8,12")])
930
931(define_insn ""
932  [(set (match_operand:SI 0 "register_operand" "=r")
933	(minus:SI (match_operand:SI 1 "register_operand" "r")
934		  (gtu:SI (match_operand:SI 2 "register_operand" "r")
935			  (match_operand:SI 3 "arith11_operand" "rI"))))]
936  ""
937  "sub%I3 %3,%2,%%r0\;{subb|sub,b} %1,%%r0,%0"
938  [(set_attr "type" "binary")
939   (set_attr "length" "8")])
940
941(define_insn ""
942  [(set (match_operand:DI 0 "register_operand" "=r")
943	(minus:DI (match_operand:DI 1 "register_operand" "r")
944		  (gtu:DI (match_operand:DI 2 "register_operand" "r")
945			  (match_operand:DI 3 "arith11_operand" "rI"))))]
946  "TARGET_64BIT"
947  "sub%I3 %3,%2,%%r0\;sub,db %1,%%r0,%0"
948  [(set_attr "type" "binary")
949   (set_attr "length" "8")])
950
951(define_insn ""
952  [(set (match_operand:SI 0 "register_operand" "=r")
953	(minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
954			    (gtu:SI (match_operand:SI 2 "register_operand" "r")
955				    (match_operand:SI 3 "arith11_operand" "rI")))
956		  (match_operand:SI 4 "register_operand" "r")))]
957  ""
958  "sub%I3 %3,%2,%%r0\;{subb|sub,b} %1,%4,%0"
959  [(set_attr "type" "binary")
960   (set_attr "length" "8")])
961
962(define_insn ""
963  [(set (match_operand:DI 0 "register_operand" "=r")
964	(minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
965			    (gtu:DI (match_operand:DI 2 "register_operand" "r")
966				    (match_operand:DI 3 "arith11_operand" "rI")))
967		  (match_operand:DI 4 "register_operand" "r")))]
968  "TARGET_64BIT"
969  "sub%I3 %3,%2,%%r0\;sub,db %1,%4,%0"
970  [(set_attr "type" "binary")
971   (set_attr "length" "8")])
972
973; This need only accept registers for op3, since canonicalization
974; replaces ltu with leu when op3 is an integer.
975(define_insn ""
976  [(set (match_operand:SI 0 "register_operand" "=r")
977	(minus:SI (match_operand:SI 1 "register_operand" "r")
978		  (ltu:SI (match_operand:SI 2 "register_operand" "r")
979			  (match_operand:SI 3 "register_operand" "r"))))]
980  ""
981  "sub %2,%3,%%r0\;{subb|sub,b} %1,%%r0,%0"
982  [(set_attr "type" "binary")
983   (set_attr "length" "8")])
984
985(define_insn ""
986  [(set (match_operand:DI 0 "register_operand" "=r")
987	(minus:DI (match_operand:DI 1 "register_operand" "r")
988		  (ltu:DI (match_operand:DI 2 "register_operand" "r")
989			  (match_operand:DI 3 "register_operand" "r"))))]
990  "TARGET_64BIT"
991  "sub %2,%3,%%r0\;sub,db %1,%%r0,%0"
992  [(set_attr "type" "binary")
993   (set_attr "length" "8")])
994
995(define_insn ""
996  [(set (match_operand:SI 0 "register_operand" "=r")
997	(minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
998			    (ltu:SI (match_operand:SI 2 "register_operand" "r")
999				    (match_operand:SI 3 "register_operand" "r")))
1000		  (match_operand:SI 4 "register_operand" "r")))]
1001  ""
1002  "sub %2,%3,%%r0\;{subb|sub,b} %1,%4,%0"
1003  [(set_attr "type" "binary")
1004   (set_attr "length" "8")])
1005
1006(define_insn ""
1007  [(set (match_operand:DI 0 "register_operand" "=r")
1008	(minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
1009			    (ltu:DI (match_operand:DI 2 "register_operand" "r")
1010				    (match_operand:DI 3 "register_operand" "r")))
1011		  (match_operand:DI 4 "register_operand" "r")))]
1012  "TARGET_64BIT"
1013  "sub %2,%3,%%r0\;sub,db %1,%4,%0"
1014  [(set_attr "type" "binary")
1015   (set_attr "length" "8")])
1016
1017; Match only integers for op3 here.  This is used as canonical form of the
1018; ltu pattern when op3 is an integer.  Don't match registers since we can't
1019; make better code than the general incscc pattern.
1020(define_insn ""
1021  [(set (match_operand:SI 0 "register_operand" "=r")
1022	(minus:SI (match_operand:SI 1 "register_operand" "r")
1023		  (leu:SI (match_operand:SI 2 "register_operand" "r")
1024			  (match_operand:SI 3 "int11_operand" "I"))))]
1025  ""
1026  "addi %k3,%2,%%r0\;{subb|sub,b} %1,%%r0,%0"
1027  [(set_attr "type" "binary")
1028   (set_attr "length" "8")])
1029
1030(define_insn ""
1031  [(set (match_operand:DI 0 "register_operand" "=r")
1032	(minus:DI (match_operand:DI 1 "register_operand" "r")
1033		  (leu:DI (match_operand:DI 2 "register_operand" "r")
1034			  (match_operand:DI 3 "int11_operand" "I"))))]
1035  "TARGET_64BIT"
1036  "addi %k3,%2,%%r0\;sub,db %1,%%r0,%0"
1037  [(set_attr "type" "binary")
1038   (set_attr "length" "8")])
1039
1040(define_insn ""
1041  [(set (match_operand:SI 0 "register_operand" "=r")
1042	(minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
1043			    (leu:SI (match_operand:SI 2 "register_operand" "r")
1044				    (match_operand:SI 3 "int11_operand" "I")))
1045		  (match_operand:SI 4 "register_operand" "r")))]
1046  ""
1047  "addi %k3,%2,%%r0\;{subb|sub,b} %1,%4,%0"
1048  [(set_attr "type" "binary")
1049   (set_attr "length" "8")])
1050
1051(define_insn ""
1052  [(set (match_operand:DI 0 "register_operand" "=r")
1053	(minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
1054			    (leu:DI (match_operand:DI 2 "register_operand" "r")
1055				    (match_operand:DI 3 "int11_operand" "I")))
1056		  (match_operand:DI 4 "register_operand" "r")))]
1057  "TARGET_64BIT"
1058  "addi %k3,%2,%%r0\;sub,db %1,%4,%0"
1059  [(set_attr "type" "binary")
1060   (set_attr "length" "8")])
1061
1062(define_insn "decscc"
1063  [(set (match_operand:SI 0 "register_operand" "=r,r")
1064	(minus:SI (match_operand:SI 1 "register_operand" "0,?r")
1065		  (match_operator:SI 4 "ordered_comparison_operator"
1066		     [(match_operand:SI 2 "register_operand" "r,r")
1067		      (match_operand:SI 3 "arith11_operand" "rI,rI")])))]
1068  ""
1069  "@
1070   {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi -1,%0,%0
1071   {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi,tr -1,%1,%0\;copy %1,%0"
1072  [(set_attr "type" "binary,binary")
1073   (set_attr "length" "8,12")])
1074
1075(define_insn ""
1076  [(set (match_operand:DI 0 "register_operand" "=r,r")
1077	(minus:DI (match_operand:DI 1 "register_operand" "0,?r")
1078		  (match_operator:DI 4 "ordered_comparison_operator"
1079		     [(match_operand:DI 2 "register_operand" "r,r")
1080		      (match_operand:DI 3 "arith11_operand" "rI,rI")])))]
1081  "TARGET_64BIT"
1082  "@
1083   cmp%I3clr,*%B4 %3,%2,%%r0\;addi -1,%0,%0
1084   cmp%I3clr,*%B4 %3,%2,%%r0\;addi,tr -1,%1,%0\;copy %1,%0"
1085  [(set_attr "type" "binary,binary")
1086   (set_attr "length" "8,12")])
1087
1088; Patterns for max and min.  (There is no need for an earlyclobber in the
1089; last alternative since the middle alternative will match if op0 == op1.)
1090
1091(define_insn "sminsi3"
1092  [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1093	(smin:SI (match_operand:SI 1 "register_operand" "%0,0,r")
1094		 (match_operand:SI 2 "arith11_operand" "r,I,M")))]
1095  ""
1096  "@
1097  {comclr|cmpclr},> %2,%0,%%r0\;copy %2,%0
1098  {comiclr|cmpiclr},> %2,%0,%%r0\;ldi %2,%0
1099  {comclr|cmpclr},> %1,%r2,%0\;copy %1,%0"
1100[(set_attr "type" "multi,multi,multi")
1101 (set_attr "length" "8,8,8")])
1102
1103(define_insn "smindi3"
1104  [(set (match_operand:DI 0 "register_operand" "=r,r,r")
1105	(smin:DI (match_operand:DI 1 "register_operand" "%0,0,r")
1106		 (match_operand:DI 2 "arith11_operand" "r,I,M")))]
1107  "TARGET_64BIT"
1108  "@
1109  cmpclr,*> %2,%0,%%r0\;copy %2,%0
1110  cmpiclr,*> %2,%0,%%r0\;ldi %2,%0
1111  cmpclr,*> %1,%r2,%0\;copy %1,%0"
1112[(set_attr "type" "multi,multi,multi")
1113 (set_attr "length" "8,8,8")])
1114
1115(define_insn "uminsi3"
1116  [(set (match_operand:SI 0 "register_operand" "=r,r")
1117	(umin:SI (match_operand:SI 1 "register_operand" "%0,0")
1118		 (match_operand:SI 2 "arith11_operand" "r,I")))]
1119  ""
1120  "@
1121  {comclr|cmpclr},>> %2,%0,%%r0\;copy %2,%0
1122  {comiclr|cmpiclr},>> %2,%0,%%r0\;ldi %2,%0"
1123[(set_attr "type" "multi,multi")
1124 (set_attr "length" "8,8")])
1125
1126(define_insn "umindi3"
1127  [(set (match_operand:DI 0 "register_operand" "=r,r")
1128	(umin:DI (match_operand:DI 1 "register_operand" "%0,0")
1129		 (match_operand:DI 2 "arith11_operand" "r,I")))]
1130  "TARGET_64BIT"
1131  "@
1132  cmpclr,*>> %2,%0,%%r0\;copy %2,%0
1133  cmpiclr,*>> %2,%0,%%r0\;ldi %2,%0"
1134[(set_attr "type" "multi,multi")
1135 (set_attr "length" "8,8")])
1136
1137(define_insn "smaxsi3"
1138  [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1139	(smax:SI (match_operand:SI 1 "register_operand" "%0,0,r")
1140		 (match_operand:SI 2 "arith11_operand" "r,I,M")))]
1141  ""
1142  "@
1143  {comclr|cmpclr},< %2,%0,%%r0\;copy %2,%0
1144  {comiclr|cmpiclr},< %2,%0,%%r0\;ldi %2,%0
1145  {comclr|cmpclr},< %1,%r2,%0\;copy %1,%0"
1146[(set_attr "type" "multi,multi,multi")
1147 (set_attr "length" "8,8,8")])
1148
1149(define_insn "smaxdi3"
1150  [(set (match_operand:DI 0 "register_operand" "=r,r,r")
1151	(smax:DI (match_operand:DI 1 "register_operand" "%0,0,r")
1152		 (match_operand:DI 2 "arith11_operand" "r,I,M")))]
1153  "TARGET_64BIT"
1154  "@
1155  cmpclr,*< %2,%0,%%r0\;copy %2,%0
1156  cmpiclr,*< %2,%0,%%r0\;ldi %2,%0
1157  cmpclr,*< %1,%r2,%0\;copy %1,%0"
1158[(set_attr "type" "multi,multi,multi")
1159 (set_attr "length" "8,8,8")])
1160
1161(define_insn "umaxsi3"
1162  [(set (match_operand:SI 0 "register_operand" "=r,r")
1163	(umax:SI (match_operand:SI 1 "register_operand" "%0,0")
1164		 (match_operand:SI 2 "arith11_operand" "r,I")))]
1165  ""
1166  "@
1167  {comclr|cmpclr},<< %2,%0,%%r0\;copy %2,%0
1168  {comiclr|cmpiclr},<< %2,%0,%%r0\;ldi %2,%0"
1169[(set_attr "type" "multi,multi")
1170 (set_attr "length" "8,8")])
1171
1172(define_insn "umaxdi3"
1173  [(set (match_operand:DI 0 "register_operand" "=r,r")
1174	(umax:DI (match_operand:DI 1 "register_operand" "%0,0")
1175		 (match_operand:DI 2 "arith11_operand" "r,I")))]
1176  "TARGET_64BIT"
1177  "@
1178  cmpclr,*<< %2,%0,%%r0\;copy %2,%0
1179  cmpiclr,*<< %2,%0,%%r0\;ldi %2,%0"
1180[(set_attr "type" "multi,multi")
1181 (set_attr "length" "8,8")])
1182
1183(define_insn "absqi2"
1184  [(set (match_operand:QI 0 "register_operand" "=r")
1185	(abs:QI (match_operand:QI 1 "register_operand" "r")))]
1186  ""
1187  "{extrs|extrw,s},>= %1,31,8,%0\;subi 0,%0,%0"
1188  [(set_attr "type" "multi")
1189   (set_attr "length" "8")])
1190
1191(define_insn "abshi2"
1192  [(set (match_operand:HI 0 "register_operand" "=r")
1193	(abs:HI (match_operand:HI 1 "register_operand" "r")))]
1194  ""
1195  "{extrs|extrw,s},>= %1,31,16,%0\;subi 0,%0,%0"
1196  [(set_attr "type" "multi")
1197   (set_attr "length" "8")])
1198
1199(define_insn "abssi2"
1200  [(set (match_operand:SI 0 "register_operand" "=r")
1201	(abs:SI (match_operand:SI 1 "register_operand" "r")))]
1202  ""
1203  "or,>= %%r0,%1,%0\;subi 0,%0,%0"
1204  [(set_attr "type" "multi")
1205   (set_attr "length" "8")])
1206
1207(define_insn "absdi2"
1208  [(set (match_operand:DI 0 "register_operand" "=r")
1209	(abs:DI (match_operand:DI 1 "register_operand" "r")))]
1210  "TARGET_64BIT"
1211  "or,*>= %%r0,%1,%0\;subi 0,%0,%0"
1212  [(set_attr "type" "multi")
1213   (set_attr "length" "8")])
1214
1215(define_insn "bswaphi2"
1216  [(set (match_operand:HI 0 "register_operand" "=&r")
1217	(bswap:HI (match_operand:HI 1 "register_operand" "r")))]
1218  ""
1219  "{extru|extrw,u} %1,23,8,%0\;{dep|depw} %1,23,8,%0"
1220  [(set_attr "type" "multi")
1221   (set_attr "length" "8")])
1222
1223(define_insn "bswapsi2"
1224  [(set (match_operand:SI 0 "register_operand" "=&r")
1225	(bswap:SI (match_operand:SI 1 "register_operand" "r")))]
1226  ""
1227  "{shd|shrpw} %1,%1,16,%0\;{dep|depw} %0,15,8,%0\;{shd|shrpw} %1,%0,8,%0"
1228  [(set_attr "type" "multi")
1229   (set_attr "length" "12")])
1230
1231(define_insn "bswapdi2"
1232  [(set (match_operand:DI 0 "register_operand" "=&r")
1233	(bswap:DI (match_operand:DI 1 "register_operand" "r")))
1234   (clobber (match_scratch:DI 2 "=r"))]
1235  "TARGET_64BIT"
1236  "permh,3210 %1,%2\;hshl %2,8,%0\;hshr,u %2,8,%2\;or %0,%2,%0"
1237  [(set_attr "type" "multi")
1238   (set_attr "length" "16")])
1239
1240;;; Experimental conditional move patterns
1241
1242(define_expand "movsicc"
1243  [(set (match_operand:SI 0 "register_operand" "")
1244	(if_then_else:SI
1245	 (match_operand 1 "ordered_comparison_operator" "")
1246	 (match_operand:SI 2 "reg_or_cint_move_operand" "")
1247	 (match_operand:SI 3 "reg_or_cint_move_operand" "")))]
1248  ""
1249  "
1250{
1251  if (GET_MODE (XEXP (operands[1], 0)) != SImode
1252      || GET_MODE (XEXP (operands[1], 0)) != GET_MODE (XEXP (operands[1], 1)))
1253    FAIL;
1254}")
1255
1256;; We used to accept any register for op1.
1257;;
1258;; However, it loses sometimes because the compiler will end up using
1259;; different registers for op0 and op1 in some critical cases.  local-alloc
1260;; will  not tie op0 and op1 because op0 is used in multiple basic blocks.
1261;;
1262;; If/when global register allocation supports tying we should allow any
1263;; register for op1 again.
1264(define_insn ""
1265  [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
1266	(if_then_else:SI
1267	 (match_operator 2 "ordered_comparison_operator"
1268	    [(match_operand:SI 3 "register_operand" "r,r,r,r")
1269	     (match_operand:SI 4 "arith11_operand" "rI,rI,rI,rI")])
1270	 (match_operand:SI 1 "reg_or_cint_move_operand" "0,J,N,K")
1271	 (const_int 0)))]
1272  ""
1273  "@
1274   {com%I4clr|cmp%I4clr},%S2 %4,%3,%%r0\;ldi 0,%0
1275   {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;ldi %1,%0
1276   {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;ldil L'%1,%0
1277   {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;{zdepi|depwi,z} %Z1,%0"
1278  [(set_attr "type" "multi,multi,multi,nullshift")
1279   (set_attr "length" "8,8,8,8")])
1280
1281(define_insn ""
1282  [(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r,r,r")
1283	(if_then_else:SI
1284	 (match_operator 5 "ordered_comparison_operator"
1285	    [(match_operand:SI 3 "register_operand" "r,r,r,r,r,r,r,r")
1286	     (match_operand:SI 4 "arith11_operand" "rI,rI,rI,rI,rI,rI,rI,rI")])
1287	 (match_operand:SI 1 "reg_or_cint_move_operand" "0,0,0,0,r,J,N,K")
1288	 (match_operand:SI 2 "reg_or_cint_move_operand" "r,J,N,K,0,0,0,0")))]
1289  ""
1290  "@
1291   {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;copy %2,%0
1292   {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;ldi %2,%0
1293   {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;ldil L'%2,%0
1294   {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;{zdepi|depwi,z} %Z2,%0
1295   {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;copy %1,%0
1296   {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;ldi %1,%0
1297   {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;ldil L'%1,%0
1298   {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;{zdepi|depwi,z} %Z1,%0"
1299  [(set_attr "type" "multi,multi,multi,nullshift,multi,multi,multi,nullshift")
1300   (set_attr "length" "8,8,8,8,8,8,8,8")])
1301
1302(define_expand "movdicc"
1303  [(set (match_operand:DI 0 "register_operand" "")
1304	(if_then_else:DI
1305	 (match_operand 1 "ordered_comparison_operator" "")
1306	 (match_operand:DI 2 "reg_or_cint_move_operand" "")
1307	 (match_operand:DI 3 "reg_or_cint_move_operand" "")))]
1308  "TARGET_64BIT"
1309  "
1310{
1311  if (GET_MODE (XEXP (operands[1], 0)) != DImode
1312      || GET_MODE (XEXP (operands[1], 0)) != GET_MODE (XEXP (operands[1], 1)))
1313    FAIL;
1314}")
1315
1316; We need the first constraint alternative in order to avoid
1317; earlyclobbers on all other alternatives.
1318(define_insn ""
1319  [(set (match_operand:DI 0 "register_operand" "=r,r,r,r,r")
1320	(if_then_else:DI
1321	 (match_operator 2 "ordered_comparison_operator"
1322	    [(match_operand:DI 3 "register_operand" "r,r,r,r,r")
1323	     (match_operand:DI 4 "arith11_operand" "rI,rI,rI,rI,rI")])
1324	 (match_operand:DI 1 "reg_or_cint_move_operand" "0,r,J,N,K")
1325	 (const_int 0)))]
1326  "TARGET_64BIT"
1327  "@
1328   cmp%I4clr,*%S2 %4,%3,%%r0\;ldi 0,%0
1329   cmp%I4clr,*%B2 %4,%3,%0\;copy %1,%0
1330   cmp%I4clr,*%B2 %4,%3,%0\;ldi %1,%0
1331   cmp%I4clr,*%B2 %4,%3,%0\;ldil L'%1,%0
1332   cmp%I4clr,*%B2 %4,%3,%0\;depdi,z %z1,%0"
1333  [(set_attr "type" "multi,multi,multi,multi,nullshift")
1334   (set_attr "length" "8,8,8,8,8")])
1335
1336(define_insn ""
1337  [(set (match_operand:DI 0 "register_operand" "=r,r,r,r,r,r,r,r")
1338	(if_then_else:DI
1339	 (match_operator 5 "ordered_comparison_operator"
1340	    [(match_operand:DI 3 "register_operand" "r,r,r,r,r,r,r,r")
1341	     (match_operand:DI 4 "arith11_operand" "rI,rI,rI,rI,rI,rI,rI,rI")])
1342	 (match_operand:DI 1 "reg_or_cint_move_operand" "0,0,0,0,r,J,N,K")
1343	 (match_operand:DI 2 "reg_or_cint_move_operand" "r,J,N,K,0,0,0,0")))]
1344  "TARGET_64BIT"
1345  "@
1346   cmp%I4clr,*%S5 %4,%3,%%r0\;copy %2,%0
1347   cmp%I4clr,*%S5 %4,%3,%%r0\;ldi %2,%0
1348   cmp%I4clr,*%S5 %4,%3,%%r0\;ldil L'%2,%0
1349   cmp%I4clr,*%S5 %4,%3,%%r0\;depdi,z %z2,%0
1350   cmp%I4clr,*%B5 %4,%3,%%r0\;copy %1,%0
1351   cmp%I4clr,*%B5 %4,%3,%%r0\;ldi %1,%0
1352   cmp%I4clr,*%B5 %4,%3,%%r0\;ldil L'%1,%0
1353   cmp%I4clr,*%B5 %4,%3,%%r0\;depdi,z %z1,%0"
1354  [(set_attr "type" "multi,multi,multi,nullshift,multi,multi,multi,nullshift")
1355   (set_attr "length" "8,8,8,8,8,8,8,8")])
1356
1357;; Conditional Branches
1358
1359(define_expand "cbranchdi4"
1360  [(set (pc)
1361        (if_then_else (match_operator 0 "ordered_comparison_operator"
1362		       [(match_operand:DI 1 "reg_or_0_operand" "")
1363                        (match_operand:DI 2 "register_operand" "")])
1364		      (label_ref (match_operand 3 "" ""))
1365		      (pc)))]
1366  "TARGET_64BIT"
1367  "")
1368
1369(define_expand "cbranchsi4"
1370  [(set (pc)
1371        (if_then_else (match_operator 0 "ordered_comparison_operator"
1372		       [(match_operand:SI 1 "reg_or_0_operand" "")
1373                        (match_operand:SI 2 "arith5_operand" "")])
1374		      (label_ref (match_operand 3 "" ""))
1375		      (pc)))]
1376  ""
1377  "")
1378
1379(define_expand "cbranchsf4"
1380  [(set (pc)
1381        (if_then_else (match_operator 0 "comparison_operator"
1382		       [(match_operand:SF 1 "reg_or_0_operand" "")
1383                        (match_operand:SF 2 "reg_or_0_operand" "")])
1384		      (label_ref (match_operand 3 "" ""))
1385		      (pc)))]
1386  ""
1387  "
1388{
1389  pa_emit_bcond_fp (operands);
1390  DONE;
1391}")
1392
1393
1394(define_expand "cbranchdf4"
1395  [(set (pc)
1396        (if_then_else (match_operator 0 "comparison_operator"
1397		       [(match_operand:DF 1 "reg_or_0_operand" "")
1398                        (match_operand:DF 2 "reg_or_0_operand" "")])
1399		      (label_ref (match_operand 3 "" ""))
1400		      (pc)))]
1401  ""
1402  "
1403{
1404  pa_emit_bcond_fp (operands);
1405  DONE;
1406}")
1407
1408;; Match the branch patterns.
1409
1410
1411;; Note a long backward conditional branch with an annulled delay slot
1412;; has a length of 12.
1413(define_insn ""
1414  [(set (pc)
1415	(if_then_else
1416	 (match_operator 3 "ordered_comparison_operator"
1417			 [(match_operand:SI 1 "reg_or_0_operand" "rM")
1418			  (match_operand:SI 2 "arith5_operand" "rL")])
1419	 (label_ref (match_operand 0 "" ""))
1420	 (pc)))]
1421  ""
1422  "*
1423{
1424  return pa_output_cbranch (operands, 0, insn);
1425}"
1426[(set_attr "type" "cbranch")
1427 (set (attr "length")
1428    (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1429	       (const_int MAX_12BIT_OFFSET))
1430	   (const_int 4)
1431	   (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1432	       (const_int MAX_17BIT_OFFSET))
1433	   (const_int 8)
1434	   (match_test "TARGET_PORTABLE_RUNTIME")
1435	   (const_int 24)
1436	   (not (match_test "flag_pic"))
1437	   (const_int 20)]
1438	  (const_int 28)))])
1439
1440;; Match the negated branch.
1441
1442(define_insn ""
1443  [(set (pc)
1444	(if_then_else
1445	 (match_operator 3 "ordered_comparison_operator"
1446			 [(match_operand:SI 1 "reg_or_0_operand" "rM")
1447			  (match_operand:SI 2 "arith5_operand" "rL")])
1448	 (pc)
1449	 (label_ref (match_operand 0 "" ""))))]
1450  ""
1451  "*
1452{
1453  return pa_output_cbranch (operands, 1, insn);
1454}"
1455[(set_attr "type" "cbranch")
1456 (set (attr "length")
1457    (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1458	       (const_int MAX_12BIT_OFFSET))
1459	   (const_int 4)
1460	   (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1461	       (const_int MAX_17BIT_OFFSET))
1462	   (const_int 8)
1463	   (match_test "TARGET_PORTABLE_RUNTIME")
1464	   (const_int 24)
1465	   (not (match_test "flag_pic"))
1466	   (const_int 20)]
1467	  (const_int 28)))])
1468
1469(define_insn ""
1470  [(set (pc)
1471	(if_then_else
1472	 (match_operator 3 "ordered_comparison_operator"
1473			 [(match_operand:DI 1 "reg_or_0_operand" "rM")
1474			  (match_operand:DI 2 "reg_or_0_operand" "rM")])
1475	 (label_ref (match_operand 0 "" ""))
1476	 (pc)))]
1477  "TARGET_64BIT"
1478  "*
1479{
1480  return pa_output_cbranch (operands, 0, insn);
1481}"
1482[(set_attr "type" "cbranch")
1483 (set (attr "length")
1484    (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1485	       (const_int MAX_12BIT_OFFSET))
1486	   (const_int 4)
1487	   (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1488	       (const_int MAX_17BIT_OFFSET))
1489	   (const_int 8)
1490	   (match_test "TARGET_PORTABLE_RUNTIME")
1491	   (const_int 24)
1492	   (not (match_test "flag_pic"))
1493	   (const_int 20)]
1494	  (const_int 28)))])
1495
1496;; Match the negated branch.
1497
1498(define_insn ""
1499  [(set (pc)
1500	(if_then_else
1501	 (match_operator 3 "ordered_comparison_operator"
1502			 [(match_operand:DI 1 "reg_or_0_operand" "rM")
1503			  (match_operand:DI 2 "reg_or_0_operand" "rM")])
1504	 (pc)
1505	 (label_ref (match_operand 0 "" ""))))]
1506  "TARGET_64BIT"
1507  "*
1508{
1509  return pa_output_cbranch (operands, 1, insn);
1510}"
1511[(set_attr "type" "cbranch")
1512 (set (attr "length")
1513    (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1514	       (const_int MAX_12BIT_OFFSET))
1515	   (const_int 4)
1516	   (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1517	       (const_int MAX_17BIT_OFFSET))
1518	   (const_int 8)
1519	   (match_test "TARGET_PORTABLE_RUNTIME")
1520	   (const_int 24)
1521	   (not (match_test "flag_pic"))
1522	   (const_int 20)]
1523	  (const_int 28)))])
1524(define_insn ""
1525  [(set (pc)
1526	(if_then_else
1527	 (match_operator 3 "cmpib_comparison_operator"
1528			 [(match_operand:DI 1 "reg_or_0_operand" "rM")
1529			  (match_operand:DI 2 "arith5_operand" "rL")])
1530	 (label_ref (match_operand 0 "" ""))
1531	 (pc)))]
1532  "TARGET_64BIT"
1533  "*
1534{
1535  return pa_output_cbranch (operands, 0, insn);
1536}"
1537[(set_attr "type" "cbranch")
1538 (set (attr "length")
1539    (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1540	       (const_int MAX_12BIT_OFFSET))
1541	   (const_int 4)
1542	   (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1543	       (const_int MAX_17BIT_OFFSET))
1544	   (const_int 8)
1545	   (match_test "TARGET_PORTABLE_RUNTIME")
1546	   (const_int 24)
1547	   (not (match_test "flag_pic"))
1548	   (const_int 20)]
1549	  (const_int 28)))])
1550
1551;; Match the negated branch.
1552
1553(define_insn ""
1554  [(set (pc)
1555	(if_then_else
1556	 (match_operator 3 "cmpib_comparison_operator"
1557			 [(match_operand:DI 1 "reg_or_0_operand" "rM")
1558			  (match_operand:DI 2 "arith5_operand" "rL")])
1559	 (pc)
1560	 (label_ref (match_operand 0 "" ""))))]
1561  "TARGET_64BIT"
1562  "*
1563{
1564  return pa_output_cbranch (operands, 1, insn);
1565}"
1566[(set_attr "type" "cbranch")
1567 (set (attr "length")
1568    (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1569	       (const_int MAX_12BIT_OFFSET))
1570	   (const_int 4)
1571	   (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1572	       (const_int MAX_17BIT_OFFSET))
1573	   (const_int 8)
1574	   (match_test "TARGET_PORTABLE_RUNTIME")
1575	   (const_int 24)
1576	   (not (match_test "flag_pic"))
1577	   (const_int 20)]
1578	  (const_int 28)))])
1579
1580;; Branch on Bit patterns.
1581(define_insn ""
1582  [(set (pc)
1583	(if_then_else
1584	 (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1585			      (const_int 1)
1586			      (match_operand:SI 1 "uint5_operand" ""))
1587	     (const_int 0))
1588	 (label_ref (match_operand 2 "" ""))
1589	 (pc)))]
1590  ""
1591  "*
1592{
1593  return pa_output_bb (operands, 0, insn, 0);
1594}"
1595[(set_attr "type" "cbranch")
1596 (set (attr "length")
1597    (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1598	       (const_int MAX_12BIT_OFFSET))
1599	   (const_int 4)
1600	   (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1601	       (const_int MAX_17BIT_OFFSET))
1602	   (const_int 8)
1603	   (match_test "TARGET_PORTABLE_RUNTIME")
1604	   (const_int 24)
1605	   (not (match_test "flag_pic"))
1606	   (const_int 20)]
1607	  (const_int 28)))])
1608
1609(define_insn ""
1610  [(set (pc)
1611	(if_then_else
1612	 (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1613			      (const_int 1)
1614			      (match_operand:DI 1 "uint32_operand" ""))
1615	     (const_int 0))
1616	 (label_ref (match_operand 2 "" ""))
1617	 (pc)))]
1618  "TARGET_64BIT"
1619  "*
1620{
1621  return pa_output_bb (operands, 0, insn, 0);
1622}"
1623[(set_attr "type" "cbranch")
1624 (set (attr "length")
1625    (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1626	       (const_int MAX_12BIT_OFFSET))
1627	   (const_int 4)
1628	   (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1629	       (const_int MAX_17BIT_OFFSET))
1630	   (const_int 8)
1631	   (match_test "TARGET_PORTABLE_RUNTIME")
1632	   (const_int 24)
1633	   (not (match_test "flag_pic"))
1634	   (const_int 20)]
1635	  (const_int 28)))])
1636
1637(define_insn ""
1638  [(set (pc)
1639	(if_then_else
1640	 (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1641			      (const_int 1)
1642			      (match_operand:SI 1 "uint5_operand" ""))
1643	     (const_int 0))
1644	 (pc)
1645	 (label_ref (match_operand 2 "" ""))))]
1646  ""
1647  "*
1648{
1649  return pa_output_bb (operands, 1, insn, 0);
1650}"
1651[(set_attr "type" "cbranch")
1652 (set (attr "length")
1653    (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1654	       (const_int MAX_12BIT_OFFSET))
1655	   (const_int 4)
1656	   (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1657	       (const_int MAX_17BIT_OFFSET))
1658	   (const_int 8)
1659	   (match_test "TARGET_PORTABLE_RUNTIME")
1660	   (const_int 24)
1661	   (not (match_test "flag_pic"))
1662	   (const_int 20)]
1663	  (const_int 28)))])
1664
1665(define_insn ""
1666  [(set (pc)
1667	(if_then_else
1668	 (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1669			      (const_int 1)
1670			      (match_operand:DI 1 "uint32_operand" ""))
1671	     (const_int 0))
1672	 (pc)
1673	 (label_ref (match_operand 2 "" ""))))]
1674  "TARGET_64BIT"
1675  "*
1676{
1677  return pa_output_bb (operands, 1, insn, 0);
1678}"
1679[(set_attr "type" "cbranch")
1680 (set (attr "length")
1681    (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1682	       (const_int MAX_12BIT_OFFSET))
1683	   (const_int 4)
1684	   (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1685	       (const_int MAX_17BIT_OFFSET))
1686	   (const_int 8)
1687	   (match_test "TARGET_PORTABLE_RUNTIME")
1688	   (const_int 24)
1689	   (not (match_test "flag_pic"))
1690	   (const_int 20)]
1691	  (const_int 28)))])
1692
1693(define_insn ""
1694  [(set (pc)
1695	(if_then_else
1696	 (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1697			      (const_int 1)
1698			      (match_operand:SI 1 "uint5_operand" ""))
1699	     (const_int 0))
1700	 (label_ref (match_operand 2 "" ""))
1701	 (pc)))]
1702  ""
1703  "*
1704{
1705  return pa_output_bb (operands, 0, insn, 1);
1706}"
1707[(set_attr "type" "cbranch")
1708 (set (attr "length")
1709    (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1710	       (const_int MAX_12BIT_OFFSET))
1711	   (const_int 4)
1712	   (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1713	       (const_int MAX_17BIT_OFFSET))
1714	   (const_int 8)
1715	   (match_test "TARGET_PORTABLE_RUNTIME")
1716	   (const_int 24)
1717	   (not (match_test "flag_pic"))
1718	   (const_int 20)]
1719	  (const_int 28)))])
1720
1721(define_insn ""
1722  [(set (pc)
1723	(if_then_else
1724	 (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1725			      (const_int 1)
1726			      (match_operand:DI 1 "uint32_operand" ""))
1727	     (const_int 0))
1728	 (label_ref (match_operand 2 "" ""))
1729	 (pc)))]
1730  "TARGET_64BIT"
1731  "*
1732{
1733  return pa_output_bb (operands, 0, insn, 1);
1734}"
1735[(set_attr "type" "cbranch")
1736 (set (attr "length")
1737    (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1738	       (const_int MAX_12BIT_OFFSET))
1739	   (const_int 4)
1740	   (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1741	       (const_int MAX_17BIT_OFFSET))
1742	   (const_int 8)
1743	   (match_test "TARGET_PORTABLE_RUNTIME")
1744	   (const_int 24)
1745	   (not (match_test "flag_pic"))
1746	   (const_int 20)]
1747	  (const_int 28)))])
1748
1749(define_insn ""
1750  [(set (pc)
1751	(if_then_else
1752	 (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1753			      (const_int 1)
1754			      (match_operand:SI 1 "uint5_operand" ""))
1755	     (const_int 0))
1756	 (pc)
1757	 (label_ref (match_operand 2 "" ""))))]
1758  ""
1759  "*
1760{
1761  return pa_output_bb (operands, 1, insn, 1);
1762}"
1763[(set_attr "type" "cbranch")
1764 (set (attr "length")
1765    (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1766	       (const_int MAX_12BIT_OFFSET))
1767	   (const_int 4)
1768	   (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1769	       (const_int MAX_17BIT_OFFSET))
1770	   (const_int 8)
1771	   (match_test "TARGET_PORTABLE_RUNTIME")
1772	   (const_int 24)
1773	   (not (match_test "flag_pic"))
1774	   (const_int 20)]
1775	  (const_int 28)))])
1776
1777(define_insn ""
1778  [(set (pc)
1779	(if_then_else
1780	 (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1781			      (const_int 1)
1782			      (match_operand:DI 1 "uint32_operand" ""))
1783	     (const_int 0))
1784	 (pc)
1785	 (label_ref (match_operand 2 "" ""))))]
1786  "TARGET_64BIT"
1787  "*
1788{
1789  return pa_output_bb (operands, 1, insn, 1);
1790}"
1791[(set_attr "type" "cbranch")
1792 (set (attr "length")
1793    (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1794	       (const_int MAX_12BIT_OFFSET))
1795	   (const_int 4)
1796	   (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1797	       (const_int MAX_17BIT_OFFSET))
1798	   (const_int 8)
1799	   (match_test "TARGET_PORTABLE_RUNTIME")
1800	   (const_int 24)
1801	   (not (match_test "flag_pic"))
1802	   (const_int 20)]
1803	  (const_int 28)))])
1804
1805;; Branch on Variable Bit patterns.
1806(define_insn ""
1807  [(set (pc)
1808	(if_then_else
1809	 (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1810			      (const_int 1)
1811			      (match_operand:SI 1 "register_operand" "q"))
1812	     (const_int 0))
1813	 (label_ref (match_operand 2 "" ""))
1814	 (pc)))]
1815  ""
1816  "*
1817{
1818  return pa_output_bvb (operands, 0, insn, 0);
1819}"
1820[(set_attr "type" "cbranch")
1821 (set (attr "length")
1822    (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1823	       (const_int MAX_12BIT_OFFSET))
1824	   (const_int 4)
1825	   (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1826	       (const_int MAX_17BIT_OFFSET))
1827	   (const_int 8)
1828	   (match_test "TARGET_PORTABLE_RUNTIME")
1829	   (const_int 24)
1830	   (not (match_test "flag_pic"))
1831	   (const_int 20)]
1832	  (const_int 28)))])
1833
1834(define_insn ""
1835  [(set (pc)
1836	(if_then_else
1837	 (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1838			      (const_int 1)
1839			      (match_operand:DI 1 "register_operand" "q"))
1840	     (const_int 0))
1841	 (label_ref (match_operand 2 "" ""))
1842	 (pc)))]
1843  "TARGET_64BIT"
1844  "*
1845{
1846  return pa_output_bvb (operands, 0, insn, 0);
1847}"
1848[(set_attr "type" "cbranch")
1849 (set (attr "length")
1850    (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1851	       (const_int MAX_12BIT_OFFSET))
1852	   (const_int 4)
1853	   (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1854	       (const_int MAX_17BIT_OFFSET))
1855	   (const_int 8)
1856	   (match_test "TARGET_PORTABLE_RUNTIME")
1857	   (const_int 24)
1858	   (not (match_test "flag_pic"))
1859	   (const_int 20)]
1860	  (const_int 28)))])
1861
1862(define_insn ""
1863  [(set (pc)
1864	(if_then_else
1865	 (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1866			      (const_int 1)
1867			      (match_operand:SI 1 "register_operand" "q"))
1868	     (const_int 0))
1869	 (pc)
1870	 (label_ref (match_operand 2 "" ""))))]
1871  ""
1872  "*
1873{
1874  return pa_output_bvb (operands, 1, insn, 0);
1875}"
1876[(set_attr "type" "cbranch")
1877 (set (attr "length")
1878    (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1879	       (const_int MAX_12BIT_OFFSET))
1880	   (const_int 4)
1881	   (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1882	       (const_int MAX_17BIT_OFFSET))
1883	   (const_int 8)
1884	   (match_test "TARGET_PORTABLE_RUNTIME")
1885	   (const_int 24)
1886	   (not (match_test "flag_pic"))
1887	   (const_int 20)]
1888	  (const_int 28)))])
1889
1890(define_insn ""
1891  [(set (pc)
1892	(if_then_else
1893	 (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1894			      (const_int 1)
1895			      (match_operand:DI 1 "register_operand" "q"))
1896	     (const_int 0))
1897	 (pc)
1898	 (label_ref (match_operand 2 "" ""))))]
1899  "TARGET_64BIT"
1900  "*
1901{
1902  return pa_output_bvb (operands, 1, insn, 0);
1903}"
1904[(set_attr "type" "cbranch")
1905 (set (attr "length")
1906    (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1907	       (const_int MAX_12BIT_OFFSET))
1908	   (const_int 4)
1909	   (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1910	       (const_int MAX_17BIT_OFFSET))
1911	   (const_int 8)
1912	   (match_test "TARGET_PORTABLE_RUNTIME")
1913	   (const_int 24)
1914	   (not (match_test "flag_pic"))
1915	   (const_int 20)]
1916	  (const_int 28)))])
1917
1918(define_insn ""
1919  [(set (pc)
1920	(if_then_else
1921	 (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1922			      (const_int 1)
1923			      (match_operand:SI 1 "register_operand" "q"))
1924	     (const_int 0))
1925	 (label_ref (match_operand 2 "" ""))
1926	 (pc)))]
1927  ""
1928  "*
1929{
1930  return pa_output_bvb (operands, 0, insn, 1);
1931}"
1932[(set_attr "type" "cbranch")
1933 (set (attr "length")
1934    (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1935	       (const_int MAX_12BIT_OFFSET))
1936	   (const_int 4)
1937	   (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1938	       (const_int MAX_17BIT_OFFSET))
1939	   (const_int 8)
1940	   (match_test "TARGET_PORTABLE_RUNTIME")
1941	   (const_int 24)
1942	   (not (match_test "flag_pic"))
1943	   (const_int 20)]
1944	  (const_int 28)))])
1945
1946(define_insn ""
1947  [(set (pc)
1948	(if_then_else
1949	 (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1950			      (const_int 1)
1951			      (match_operand:DI 1 "register_operand" "q"))
1952	     (const_int 0))
1953	 (label_ref (match_operand 2 "" ""))
1954	 (pc)))]
1955  "TARGET_64BIT"
1956  "*
1957{
1958  return pa_output_bvb (operands, 0, insn, 1);
1959}"
1960[(set_attr "type" "cbranch")
1961 (set (attr "length")
1962    (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1963	       (const_int MAX_12BIT_OFFSET))
1964	   (const_int 4)
1965	   (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1966	       (const_int MAX_17BIT_OFFSET))
1967	   (const_int 8)
1968	   (match_test "TARGET_PORTABLE_RUNTIME")
1969	   (const_int 24)
1970	   (not (match_test "flag_pic"))
1971	   (const_int 20)]
1972	  (const_int 28)))])
1973
1974(define_insn ""
1975  [(set (pc)
1976	(if_then_else
1977	 (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1978			      (const_int 1)
1979			      (match_operand:SI 1 "register_operand" "q"))
1980	     (const_int 0))
1981	 (pc)
1982	 (label_ref (match_operand 2 "" ""))))]
1983  ""
1984  "*
1985{
1986  return pa_output_bvb (operands, 1, insn, 1);
1987}"
1988[(set_attr "type" "cbranch")
1989 (set (attr "length")
1990    (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1991	       (const_int MAX_12BIT_OFFSET))
1992	   (const_int 4)
1993	   (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1994	       (const_int MAX_17BIT_OFFSET))
1995	   (const_int 8)
1996	   (match_test "TARGET_PORTABLE_RUNTIME")
1997	   (const_int 24)
1998	   (not (match_test "flag_pic"))
1999	   (const_int 20)]
2000	  (const_int 28)))])
2001
2002(define_insn ""
2003  [(set (pc)
2004	(if_then_else
2005	 (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2006			      (const_int 1)
2007			      (match_operand:DI 1 "register_operand" "q"))
2008	     (const_int 0))
2009	 (pc)
2010	 (label_ref (match_operand 2 "" ""))))]
2011  "TARGET_64BIT"
2012  "*
2013{
2014  return pa_output_bvb (operands, 1, insn, 1);
2015}"
2016[(set_attr "type" "cbranch")
2017 (set (attr "length")
2018    (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2019	       (const_int MAX_12BIT_OFFSET))
2020	   (const_int 4)
2021	   (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2022	       (const_int MAX_17BIT_OFFSET))
2023	   (const_int 8)
2024	   (match_test "TARGET_PORTABLE_RUNTIME")
2025	   (const_int 24)
2026	   (not (match_test "flag_pic"))
2027	   (const_int 20)]
2028	  (const_int 28)))])
2029
2030;; Floating point branches
2031
2032;; ??? Nullification is handled differently from other branches.
2033;; If nullification is specified, the delay slot is nullified on any
2034;; taken branch regardless of branch direction.
2035(define_insn ""
2036  [(set (pc) (if_then_else (ne (reg:CCFP 0) (const_int 0))
2037			   (label_ref (match_operand 0 "" ""))
2038			   (pc)))]
2039  "!TARGET_SOFT_FLOAT"
2040  "*
2041{
2042  int length = get_attr_length (insn);
2043  rtx xoperands[1];
2044  int nullify, xdelay;
2045
2046  if (length < 16)
2047    return \"ftest\;b%* %l0\";
2048
2049  if (dbr_sequence_length () == 0 || INSN_ANNULLED_BRANCH_P (insn))
2050    {
2051      nullify = 1;
2052      xdelay = 0;
2053      xoperands[0] = GEN_INT (length - 8);
2054    }
2055  else
2056    {
2057      nullify = 0;
2058      xdelay = 1;
2059      xoperands[0] = GEN_INT (length - 4);
2060    }
2061
2062  if (nullify)
2063    output_asm_insn (\"ftest\;add,tr %%r0,%%r0,%%r0\;b,n .+%0\", xoperands);
2064  else
2065    output_asm_insn (\"ftest\;add,tr %%r0,%%r0,%%r0\;b .+%0\", xoperands);
2066  return pa_output_lbranch (operands[0], insn, xdelay);
2067}"
2068[(set_attr "type" "fbranch")
2069 (set (attr "length")
2070    (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
2071	       (const_int MAX_17BIT_OFFSET))
2072	   (const_int 8)
2073	   (match_test "TARGET_PORTABLE_RUNTIME")
2074	   (const_int 32)
2075	   (not (match_test "flag_pic"))
2076	   (const_int 28)]
2077	  (const_int 36)))])
2078
2079(define_insn ""
2080  [(set (pc) (if_then_else (ne (reg:CCFP 0) (const_int 0))
2081			   (pc)
2082			   (label_ref (match_operand 0 "" ""))))]
2083  "!TARGET_SOFT_FLOAT"
2084  "*
2085{
2086  int length = get_attr_length (insn);
2087  rtx xoperands[1];
2088  int nullify, xdelay;
2089
2090  if (length < 16)
2091    return \"ftest\;add,tr %%r0,%%r0,%%r0\;b%* %0\";
2092
2093  if (dbr_sequence_length () == 0 || INSN_ANNULLED_BRANCH_P (insn))
2094    {
2095      nullify = 1;
2096      xdelay = 0;
2097      xoperands[0] = GEN_INT (length - 4);
2098    }
2099  else
2100    {
2101      nullify = 0;
2102      xdelay = 1;
2103      xoperands[0] = GEN_INT (length);
2104    }
2105
2106  if (nullify)
2107    output_asm_insn (\"ftest\;b,n .+%0\", xoperands);
2108  else
2109    output_asm_insn (\"ftest\;b .+%0\", xoperands);
2110  return pa_output_lbranch (operands[0], insn, xdelay);
2111}"
2112[(set_attr "type" "fbranch")
2113 (set (attr "length")
2114    (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
2115	       (const_int MAX_17BIT_OFFSET))
2116	   (const_int 12)
2117	   (match_test "TARGET_PORTABLE_RUNTIME")
2118	   (const_int 28)
2119	   (not (match_test "flag_pic"))
2120	   (const_int 24)]
2121	  (const_int 32)))])
2122
2123;; Move instructions
2124
2125(define_expand "movsi"
2126  [(set (match_operand:SI 0 "general_operand" "")
2127	(match_operand:SI 1 "general_operand" ""))]
2128  ""
2129  "
2130{
2131  if (pa_emit_move_sequence (operands, SImode, 0))
2132    DONE;
2133}")
2134
2135;; Handle SImode input reloads requiring %r1 as a scratch register.
2136(define_expand "reload_insi_r1"
2137  [(set (match_operand:SI 0 "register_operand" "=Z")
2138	(match_operand:SI 1 "non_hard_reg_operand" ""))
2139   (clobber (match_operand:SI 2 "register_operand" "=&a"))]
2140  ""
2141  "
2142{
2143  if (pa_emit_move_sequence (operands, SImode, operands[2]))
2144    DONE;
2145
2146  /* We don't want the clobber emitted, so handle this ourselves.  */
2147  emit_insn (gen_rtx_SET (operands[0], operands[1]));
2148  DONE;
2149}")
2150
2151;; Handle SImode input reloads requiring a general register as a
2152;; scratch register.
2153(define_expand "reload_insi"
2154  [(set (match_operand:SI 0 "register_operand" "=Z")
2155	(match_operand:SI 1 "non_hard_reg_operand" ""))
2156   (clobber (match_operand:SI 2 "register_operand" "=&r"))]
2157  ""
2158  "
2159{
2160  if (pa_emit_move_sequence (operands, SImode, operands[2]))
2161    DONE;
2162
2163  /* We don't want the clobber emitted, so handle this ourselves.  */
2164  emit_insn (gen_rtx_SET (operands[0], operands[1]));
2165  DONE;
2166}")
2167
2168;; Handle SImode output reloads requiring a general register as a
2169;; scratch register.
2170(define_expand "reload_outsi"
2171  [(set (match_operand:SI 0 "non_hard_reg_operand" "")
2172	(match_operand:SI 1  "register_operand" "Z"))
2173   (clobber (match_operand:SI 2 "register_operand" "=&r"))]
2174  ""
2175  "
2176{
2177  if (pa_emit_move_sequence (operands, SImode, operands[2]))
2178    DONE;
2179
2180  /* We don't want the clobber emitted, so handle this ourselves.  */
2181  emit_insn (gen_rtx_SET (operands[0], operands[1]));
2182  DONE;
2183}")
2184
2185(define_insn ""
2186  [(set (match_operand:SI 0 "move_dest_operand"
2187			  "=r,r,r,r,r,r,Q,!*q,!r,!*f,*f,T,?r,?*f")
2188	(match_operand:SI 1 "move_src_operand"
2189			  "A,r,J,N,K,RQ,rM,!rM,!*q,!*fM,RT,*f,*f,r"))]
2190  "(register_operand (operands[0], SImode)
2191    || reg_or_0_operand (operands[1], SImode))
2192   && !TARGET_SOFT_FLOAT
2193   && !TARGET_64BIT"
2194  "@
2195   ldw RT'%A1,%0
2196   copy %1,%0
2197   ldi %1,%0
2198   ldil L'%1,%0
2199   {zdepi|depwi,z} %Z1,%0
2200   ldw%M1 %1,%0
2201   stw%M0 %r1,%0
2202   mtsar %r1
2203   {mfctl|mfctl,w} %%sar,%0
2204   fcpy,sgl %f1,%0
2205   fldw%F1 %1,%0
2206   fstw%F0 %1,%0
2207   {fstws|fstw} %1,-16(%%sp)\n\t{ldws|ldw} -16(%%sp),%0
2208   {stws|stw} %1,-16(%%sp)\n\t{fldws|fldw} -16(%%sp),%0"
2209  [(set_attr "type" "load,move,move,move,shift,load,store,move,move,fpalu,fpload,fpstore,fpstore_load,store_fpload")
2210   (set_attr "pa_combine_type" "addmove")
2211   (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4,8,8")])
2212
2213(define_insn ""
2214  [(set (match_operand:SI 0 "move_dest_operand"
2215			  "=r,r,r,r,r,r,Q,!*q,!r,!*f,*f,T")
2216	(match_operand:SI 1 "move_src_operand"
2217			  "A,r,J,N,K,RQ,rM,!rM,!*q,!*fM,RT,*f"))]
2218  "(register_operand (operands[0], SImode)
2219    || reg_or_0_operand (operands[1], SImode))
2220   && !TARGET_SOFT_FLOAT
2221   && TARGET_64BIT"
2222  "@
2223   ldw RT'%A1,%0
2224   copy %1,%0
2225   ldi %1,%0
2226   ldil L'%1,%0
2227   {zdepi|depwi,z} %Z1,%0
2228   ldw%M1 %1,%0
2229   stw%M0 %r1,%0
2230   mtsar %r1
2231   {mfctl|mfctl,w} %%sar,%0
2232   fcpy,sgl %f1,%0
2233   fldw%F1 %1,%0
2234   fstw%F0 %1,%0"
2235  [(set_attr "type" "load,move,move,move,shift,load,store,move,move,fpalu,fpload,fpstore")
2236   (set_attr "pa_combine_type" "addmove")
2237   (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4")])
2238
2239(define_insn ""
2240  [(set (match_operand:SI 0 "indexed_memory_operand" "=R")
2241	(match_operand:SI 1 "register_operand" "f"))]
2242  "!TARGET_SOFT_FLOAT
2243   && !TARGET_DISABLE_INDEXING
2244   && reload_completed"
2245  "fstw%F0 %1,%0"
2246  [(set_attr "type" "fpstore")
2247   (set_attr "pa_combine_type" "addmove")
2248   (set_attr "length" "4")])
2249
2250; Rewrite RTL using an indexed store.  This will allow the insn that
2251; computes the address to be deleted if the register it sets is dead.
2252(define_peephole2
2253  [(set (match_operand:SI 0 "register_operand" "")
2254	(plus:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
2255			    (const_int 2))
2256		 (match_operand:SI 2 "register_operand" "")))
2257   (set (mem:SI (match_dup 0))
2258        (match_operand:SI 3 "register_operand" ""))]
2259  "!TARGET_SOFT_FLOAT
2260   && !TARGET_DISABLE_INDEXING
2261   && REG_OK_FOR_BASE_P (operands[2])
2262   && FP_REGNO_P (REGNO (operands[3]))"
2263  [(set (mem:SI (plus:SI (mult:SI (match_dup 1) (const_int 4)) (match_dup 2)))
2264	(match_dup 3))
2265   (set (match_dup 0) (plus:SI (ashift:SI (match_dup 1) (const_int 2))
2266			       (match_dup 2)))]
2267  "")
2268
2269(define_peephole2
2270  [(set (match_operand:DI 0 "register_operand" "")
2271	(plus:DI (ashift:DI (match_operand:DI 1 "register_operand" "")
2272			    (const_int 2))
2273		 (match_operand:DI 2 "register_operand" "")))
2274   (set (mem:SI (match_dup 0))
2275        (match_operand:SI 3 "register_operand" ""))]
2276  "!TARGET_SOFT_FLOAT
2277   && !TARGET_DISABLE_INDEXING
2278   && TARGET_64BIT
2279   && REG_OK_FOR_BASE_P (operands[2])
2280   && FP_REGNO_P (REGNO (operands[3]))"
2281  [(set (mem:SI (plus:DI (mult:DI (match_dup 1) (const_int 4)) (match_dup 2)))
2282	(match_dup 3))
2283   (set (match_dup 0) (plus:DI (ashift:DI (match_dup 1) (const_int 2))
2284			       (match_dup 2)))]
2285  "")
2286
2287(define_peephole2
2288  [(set (match_operand:SI 0 "register_operand" "")
2289	(plus:SI (match_operand:SI 1 "register_operand" "")
2290		 (match_operand:SI 2 "register_operand" "")))
2291   (set (mem:SI (match_dup 0))
2292        (match_operand:SI 3 "register_operand" ""))]
2293  "!TARGET_SOFT_FLOAT
2294   && !TARGET_DISABLE_INDEXING
2295   && TARGET_NO_SPACE_REGS
2296   && REG_OK_FOR_INDEX_P (operands[1])
2297   && REG_OK_FOR_BASE_P (operands[2])
2298   && FP_REGNO_P (REGNO (operands[3]))"
2299  [(set (mem:SI (plus:SI (match_dup 1) (match_dup 2)))
2300	(match_dup 3))
2301   (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
2302  "")
2303
2304(define_peephole2
2305  [(set (match_operand:SI 0 "register_operand" "")
2306	(plus:SI (match_operand:SI 1 "register_operand" "")
2307		 (match_operand:SI 2 "register_operand" "")))
2308   (set (mem:SI (match_dup 0))
2309        (match_operand:SI 3 "register_operand" ""))]
2310  "!TARGET_SOFT_FLOAT
2311   && !TARGET_DISABLE_INDEXING
2312   && TARGET_NO_SPACE_REGS
2313   && REG_OK_FOR_BASE_P (operands[1])
2314   && REG_OK_FOR_INDEX_P (operands[2])
2315   && FP_REGNO_P (REGNO (operands[3]))"
2316  [(set (mem:SI (plus:SI (match_dup 2) (match_dup 1)))
2317	(match_dup 3))
2318   (set (match_dup 0) (plus:SI (match_dup 2) (match_dup 1)))]
2319  "")
2320
2321(define_peephole2
2322  [(set (match_operand:DI 0 "register_operand" "")
2323	(plus:DI (match_operand:DI 1 "register_operand" "")
2324		 (match_operand:DI 2 "register_operand" "")))
2325   (set (mem:SI (match_dup 0))
2326        (match_operand:SI 3 "register_operand" ""))]
2327  "!TARGET_SOFT_FLOAT
2328   && !TARGET_DISABLE_INDEXING
2329   && TARGET_64BIT
2330   && TARGET_NO_SPACE_REGS
2331   && REG_OK_FOR_INDEX_P (operands[1])
2332   && REG_OK_FOR_BASE_P (operands[2])
2333   && FP_REGNO_P (REGNO (operands[3]))"
2334  [(set (mem:SI (plus:DI (match_dup 1) (match_dup 2)))
2335	(match_dup 3))
2336   (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
2337  "")
2338
2339(define_peephole2
2340  [(set (match_operand:DI 0 "register_operand" "")
2341	(plus:DI (match_operand:DI 1 "register_operand" "")
2342		 (match_operand:DI 2 "register_operand" "")))
2343   (set (mem:SI (match_dup 0))
2344        (match_operand:SI 3 "register_operand" ""))]
2345  "!TARGET_SOFT_FLOAT
2346   && !TARGET_DISABLE_INDEXING
2347   && TARGET_64BIT
2348   && TARGET_NO_SPACE_REGS
2349   && REG_OK_FOR_BASE_P (operands[1])
2350   && REG_OK_FOR_INDEX_P (operands[2])
2351   && FP_REGNO_P (REGNO (operands[3]))"
2352  [(set (mem:SI (plus:DI (match_dup 2) (match_dup 1)))
2353	(match_dup 3))
2354   (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
2355  "")
2356
2357(define_insn ""
2358  [(set (match_operand:SI 0 "move_dest_operand"
2359			  "=r,r,r,r,r,r,Q,!*q,!r")
2360	(match_operand:SI 1 "move_src_operand"
2361			  "A,r,J,N,K,RQ,rM,!rM,!*q"))]
2362  "(register_operand (operands[0], SImode)
2363    || reg_or_0_operand (operands[1], SImode))
2364   && TARGET_SOFT_FLOAT"
2365  "@
2366   ldw RT'%A1,%0
2367   copy %1,%0
2368   ldi %1,%0
2369   ldil L'%1,%0
2370   {zdepi|depwi,z} %Z1,%0
2371   ldw%M1 %1,%0
2372   stw%M0 %r1,%0
2373   mtsar %r1
2374   {mfctl|mfctl,w} %%sar,%0"
2375  [(set_attr "type" "load,move,move,move,move,load,store,move,move")
2376   (set_attr "pa_combine_type" "addmove")
2377   (set_attr "length" "4,4,4,4,4,4,4,4,4")])
2378
2379;; Load or store with base-register modification.
2380(define_insn ""
2381  [(set (match_operand:SI 0 "register_operand" "=r")
2382	(mem:SI (plus:DI (match_operand:DI 1 "register_operand" "+r")
2383			 (match_operand:DI 2 "int5_operand" "L"))))
2384   (set (match_dup 1)
2385	(plus:DI (match_dup 1) (match_dup 2)))]
2386  "TARGET_64BIT"
2387  "ldw,mb %2(%1),%0"
2388  [(set_attr "type" "load")
2389   (set_attr "length" "4")])
2390
2391; And a zero extended variant.
2392(define_insn ""
2393  [(set (match_operand:DI 0 "register_operand" "=r")
2394	(zero_extend:DI (mem:SI
2395			  (plus:DI
2396			    (match_operand:DI 1 "register_operand" "+r")
2397			    (match_operand:DI 2 "int5_operand" "L")))))
2398   (set (match_dup 1)
2399	(plus:DI (match_dup 1) (match_dup 2)))]
2400  "TARGET_64BIT"
2401  "ldw,mb %2(%1),%0"
2402  [(set_attr "type" "load")
2403   (set_attr "length" "4")])
2404
2405(define_expand "pre_load"
2406  [(parallel [(set (match_operand:SI 0 "register_operand" "")
2407	      (mem (plus (match_operand 1 "register_operand" "")
2408			       (match_operand 2 "pre_cint_operand" ""))))
2409	      (set (match_dup 1)
2410		   (plus (match_dup 1) (match_dup 2)))])]
2411  ""
2412  "
2413{
2414  if (TARGET_64BIT)
2415    {
2416      emit_insn (gen_pre_ldd (operands[0], operands[1], operands[2]));
2417      DONE;
2418    }
2419  emit_insn (gen_pre_ldw (operands[0], operands[1], operands[2]));
2420  DONE;
2421}")
2422
2423(define_insn "pre_ldw"
2424  [(set (match_operand:SI 0 "register_operand" "=r")
2425	(mem:SI (plus:SI (match_operand:SI 1 "register_operand" "+r")
2426			 (match_operand:SI 2 "pre_cint_operand" ""))))
2427   (set (match_dup 1)
2428	(plus:SI (match_dup 1) (match_dup 2)))]
2429  ""
2430  "*
2431{
2432  if (INTVAL (operands[2]) < 0)
2433    return \"{ldwm|ldw,mb} %2(%1),%0\";
2434  return \"{ldws|ldw},mb %2(%1),%0\";
2435}"
2436  [(set_attr "type" "load")
2437   (set_attr "length" "4")])
2438
2439(define_insn "pre_ldd"
2440  [(set (match_operand:DI 0 "register_operand" "=r")
2441	(mem:DI (plus:DI (match_operand:DI 1 "register_operand" "+r")
2442			 (match_operand:DI 2 "pre_cint_operand" ""))))
2443   (set (match_dup 1)
2444	(plus:DI (match_dup 1) (match_dup 2)))]
2445  "TARGET_64BIT"
2446  "ldd,mb %2(%1),%0"
2447  [(set_attr "type" "load")
2448   (set_attr "length" "4")])
2449
2450(define_insn ""
2451  [(set (mem:SI (plus:SI (match_operand:SI 0 "register_operand" "+r")
2452			 (match_operand:SI 1 "pre_cint_operand" "")))
2453	(match_operand:SI 2 "reg_or_0_operand" "rM"))
2454   (set (match_dup 0)
2455	(plus:SI (match_dup 0) (match_dup 1)))]
2456  ""
2457  "*
2458{
2459  if (INTVAL (operands[1]) < 0)
2460    return \"{stwm|stw,mb} %r2,%1(%0)\";
2461  return \"{stws|stw},mb %r2,%1(%0)\";
2462}"
2463  [(set_attr "type" "store")
2464   (set_attr "length" "4")])
2465
2466(define_insn ""
2467  [(set (match_operand:SI 0 "register_operand" "=r")
2468	(mem:SI (match_operand:SI 1 "register_operand" "+r")))
2469   (set (match_dup 1)
2470	(plus:SI (match_dup 1)
2471		 (match_operand:SI 2 "post_cint_operand" "")))]
2472  ""
2473  "*
2474{
2475  if (INTVAL (operands[2]) > 0)
2476    return \"{ldwm|ldw,ma} %2(%1),%0\";
2477  return \"{ldws|ldw},ma %2(%1),%0\";
2478}"
2479  [(set_attr "type" "load")
2480   (set_attr "length" "4")])
2481
2482(define_expand "post_store"
2483  [(parallel [(set (mem (match_operand 0 "register_operand" ""))
2484		   (match_operand 1 "reg_or_0_operand" ""))
2485	      (set (match_dup 0)
2486		   (plus (match_dup 0)
2487			 (match_operand 2 "post_cint_operand" "")))])]
2488  ""
2489  "
2490{
2491  if (TARGET_64BIT)
2492    {
2493      emit_insn (gen_post_std (operands[0], operands[1], operands[2]));
2494      DONE;
2495    }
2496  emit_insn (gen_post_stw (operands[0], operands[1], operands[2]));
2497  DONE;
2498}")
2499
2500(define_insn "post_stw"
2501  [(set (mem:SI (match_operand:SI 0 "register_operand" "+r"))
2502	(match_operand:SI 1 "reg_or_0_operand" "rM"))
2503   (set (match_dup 0)
2504	(plus:SI (match_dup 0)
2505		 (match_operand:SI 2 "post_cint_operand" "")))]
2506  ""
2507  "*
2508{
2509  if (INTVAL (operands[2]) > 0)
2510    return \"{stwm|stw,ma} %r1,%2(%0)\";
2511  return \"{stws|stw},ma %r1,%2(%0)\";
2512}"
2513  [(set_attr "type" "store")
2514   (set_attr "length" "4")])
2515
2516(define_insn "post_std"
2517  [(set (mem:DI (match_operand:DI 0 "register_operand" "+r"))
2518	(match_operand:DI 1 "reg_or_0_operand" "rM"))
2519   (set (match_dup 0)
2520	(plus:DI (match_dup 0)
2521		 (match_operand:DI 2 "post_cint_operand" "")))]
2522  "TARGET_64BIT"
2523  "std,ma %r1,%2(%0)"
2524  [(set_attr "type" "store")
2525   (set_attr "length" "4")])
2526
2527;; For loading the address of a label while generating PIC code.
2528;; Note since this pattern can be created at reload time (via movsi), all
2529;; the same rules for movsi apply here.  (no new pseudos, no temporaries).
2530(define_insn ""
2531  [(set (match_operand 0 "pmode_register_operand" "=a")
2532	(match_operand 1 "pic_label_operand" ""))]
2533  "TARGET_PA_20"
2534  "*
2535{
2536  rtx xoperands[3];
2537
2538  xoperands[0] = operands[0];
2539  xoperands[1] = operands[1];
2540
2541  if (GET_CODE (operands[1]) == LABEL_REF
2542      && !LABEL_REF_NONLOCAL_P (operands[1]))
2543    {
2544      xoperands[2] = gen_label_rtx ();
2545      (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
2546					 CODE_LABEL_NUMBER (xoperands[2]));
2547      output_asm_insn (\"mfia %0\", xoperands);
2548
2549      /* If we're trying to load the address of a label that happens to be
2550	 close, then we can use a shorter sequence.  */
2551      if (INSN_ADDRESSES_SET_P ()
2552	  && abs (INSN_ADDRESSES (INSN_UID (XEXP (operands[1], 0)))
2553		  - INSN_ADDRESSES (INSN_UID (insn))) < 8100)
2554	output_asm_insn (\"ldo %1-%2(%0),%0\", xoperands);
2555      else
2556	{
2557	  output_asm_insn (\"addil L%%%1-%2,%0\", xoperands);
2558	  output_asm_insn (\"ldo R%%%1-%2(%0),%0\", xoperands);
2559	}
2560    }
2561  else
2562    {
2563      /* Load using linkage table.  */
2564      if (TARGET_64BIT)
2565	{
2566	  output_asm_insn (\"addil LT%%%1,%%r27\", xoperands);
2567	  output_asm_insn (\"ldd RT%%%1(%0),%0\", xoperands);
2568	}
2569      else
2570	{
2571	  output_asm_insn (\"addil LT%%%1,%%r19\", xoperands);
2572	  output_asm_insn (\"ldw RT%%%1(%0),%0\", xoperands);
2573	}
2574    }
2575  return \"\";
2576}"
2577  [(set_attr "type" "multi")
2578   (set_attr "length" "12")])		; 8 or 12
2579
2580(define_insn ""
2581  [(set (match_operand 0 "pmode_register_operand" "=a")
2582	(match_operand 1 "pic_label_operand" ""))]
2583  "!TARGET_PA_20"
2584  "*
2585{
2586  rtx xoperands[3];
2587
2588  xoperands[0] = operands[0];
2589  xoperands[1] = operands[1];
2590
2591  if (GET_CODE (operands[1]) == LABEL_REF
2592      && !LABEL_REF_NONLOCAL_P (operands[1]))
2593    {
2594      xoperands[2] = gen_label_rtx ();
2595      output_asm_insn (\"bl .+8,%0\", xoperands);
2596      output_asm_insn (\"depi 0,31,2,%0\", xoperands);
2597      (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
2598					 CODE_LABEL_NUMBER (xoperands[2]));
2599
2600      /* If we're trying to load the address of a label that happens to be
2601	 close, then we can use a shorter sequence.  */
2602      if (INSN_ADDRESSES_SET_P ()
2603	  && abs (INSN_ADDRESSES (INSN_UID (XEXP (operands[1], 0)))
2604		  - INSN_ADDRESSES (INSN_UID (insn))) < 8100)
2605	output_asm_insn (\"ldo %1-%2(%0),%0\", xoperands);
2606      else
2607	{
2608	  output_asm_insn (\"addil L%%%1-%2,%0\", xoperands);
2609	  output_asm_insn (\"ldo R%%%1-%2(%0),%0\", xoperands);
2610	}
2611    }
2612  else
2613    {
2614      /* Load using linkage table.  */
2615      output_asm_insn (\"addil LT%%%1,%%r19\", xoperands);
2616      output_asm_insn (\"ldw RT%%%1(%0),%0\", xoperands);
2617    }
2618  return \"\";
2619}"
2620  [(set_attr "type" "multi")
2621   (set_attr "length" "16")])		; 12 or 16
2622
2623(define_insn ""
2624  [(set (match_operand:SI 0 "register_operand" "=a")
2625	(plus:SI (match_operand:SI 1 "register_operand" "r")
2626		 (high:SI (match_operand 2 "" ""))))]
2627  "symbolic_operand (operands[2], Pmode)
2628   && ! function_label_operand (operands[2], Pmode)
2629   && flag_pic"
2630  "addil LT'%G2,%1"
2631  [(set_attr "type" "binary")
2632   (set_attr "length" "4")])
2633
2634(define_insn ""
2635  [(set (match_operand:DI 0 "register_operand" "=a")
2636	(plus:DI (match_operand:DI 1 "register_operand" "r")
2637	         (high:DI (match_operand 2 "" ""))))]
2638  "symbolic_operand (operands[2], Pmode)
2639   && ! function_label_operand (operands[2], Pmode)
2640   && TARGET_64BIT
2641   && flag_pic"
2642  "addil LT'%G2,%1"
2643  [(set_attr "type" "binary")
2644   (set_attr "length" "4")])
2645
2646(define_insn ""
2647 [(set (match_operand:SI 0 "register_operand" "=r")
2648       (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
2649		  (unspec:SI [(match_operand 2 "" "")] UNSPEC_DLTIND14R)))]
2650  "symbolic_operand (operands[2], Pmode)
2651   && ! function_label_operand (operands[2], Pmode)
2652   && flag_pic"
2653  "ldo RT'%G2(%1),%0"
2654  [(set_attr "type" "binary")
2655   (set_attr "length" "4")])
2656
2657(define_insn ""
2658 [(set (match_operand:DI 0 "register_operand" "=r")
2659       (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
2660		  (unspec:DI [(match_operand 2 "" "")] UNSPEC_DLTIND14R)))]
2661  "symbolic_operand (operands[2], Pmode)
2662   && ! function_label_operand (operands[2], Pmode)
2663   && TARGET_64BIT
2664   && flag_pic"
2665  "ldo RT'%G2(%1),%0"
2666  [(set_attr "type" "binary")
2667   (set_attr "length" "4")])
2668
2669;; Always use addil rather than ldil;add sequences.  This allows the
2670;; HP linker to eliminate the dp relocation if the symbolic operand
2671;; lives in the TEXT space.
2672(define_insn ""
2673  [(set (match_operand:SI 0 "register_operand" "=a")
2674	(high:SI (match_operand 1 "" "")))]
2675  "symbolic_operand (operands[1], Pmode)
2676   && ! function_label_operand (operands[1], Pmode)
2677   && ! read_only_operand (operands[1], Pmode)
2678   && ! flag_pic"
2679  "*
2680{
2681  if (TARGET_LONG_LOAD_STORE)
2682    return \"addil NLR'%H1,%%r27\;ldo N'%H1(%%r1),%%r1\";
2683  else
2684    return \"addil LR'%H1,%%r27\";
2685}"
2686  [(set_attr "type" "binary")
2687   (set (attr "length")
2688      (if_then_else (not (match_test "TARGET_LONG_LOAD_STORE"))
2689		    (const_int 4)
2690		    (const_int 8)))])
2691
2692
2693;; This is for use in the prologue/epilogue code.  We need it
2694;; to add large constants to a stack pointer or frame pointer.
2695;; Because of the additional %r1 pressure, we probably do not
2696;; want to use this in general code, so make it available
2697;; only after reload.
2698(define_insn ""
2699  [(set (match_operand:SI 0 "register_operand" "=!a,*r")
2700	(plus:SI (match_operand:SI 1 "register_operand" "r,r")
2701		 (high:SI (match_operand 2 "const_int_operand" ""))))]
2702  "reload_completed"
2703  "@
2704   addil L'%G2,%1
2705   ldil L'%G2,%0\;{addl|add,l} %0,%1,%0"
2706  [(set_attr "type" "binary,binary")
2707   (set_attr "length" "4,8")])
2708
2709(define_insn ""
2710  [(set (match_operand:DI 0 "register_operand" "=!a,*r")
2711	(plus:DI (match_operand:DI 1 "register_operand" "r,r")
2712		 (high:DI (match_operand 2 "const_int_operand" ""))))]
2713  "reload_completed && TARGET_64BIT"
2714  "@
2715   addil L'%G2,%1
2716   ldil L'%G2,%0\;{addl|add,l} %0,%1,%0"
2717  [(set_attr "type" "binary,binary")
2718   (set_attr "length" "4,8")])
2719
2720(define_insn ""
2721  [(set (match_operand:SI 0 "register_operand" "=r")
2722	(high:SI (match_operand 1 "" "")))]
2723  "(!flag_pic || !symbolic_operand (operands[1], Pmode))
2724    && !pa_is_function_label_plus_const (operands[1])"
2725  "*
2726{
2727  if (symbolic_operand (operands[1], Pmode))
2728    return \"ldil LR'%H1,%0\";
2729  else
2730    return \"ldil L'%G1,%0\";
2731}"
2732  [(set_attr "type" "move")
2733   (set_attr "length" "4")])
2734
2735(define_insn ""
2736  [(set (match_operand:DI 0 "register_operand" "=r")
2737	(high:DI (match_operand 1 "const_int_operand" "")))]
2738  "TARGET_64BIT"
2739  "ldil L'%G1,%0";
2740  [(set_attr "type" "move")
2741   (set_attr "length" "4")])
2742
2743(define_insn ""
2744  [(set (match_operand:DI 0 "register_operand" "=r")
2745	(lo_sum:DI (match_operand:DI 1 "register_operand" "r")
2746		   (match_operand:DI 2 "const_int_operand" "i")))]
2747  "TARGET_64BIT"
2748  "ldo R'%G2(%1),%0";
2749  [(set_attr "type" "move")
2750   (set_attr "length" "4")])
2751
2752(define_insn ""
2753  [(set (match_operand:SI 0 "register_operand" "=r")
2754	(lo_sum:SI (match_operand:SI 1 "register_operand" "r")
2755		   (match_operand:SI 2 "immediate_operand" "i")))]
2756  "!pa_is_function_label_plus_const (operands[2])"
2757  "*
2758{
2759  gcc_assert (!flag_pic || !symbolic_operand (operands[2], Pmode));
2760
2761  if (symbolic_operand (operands[2], Pmode))
2762    return \"ldo RR'%G2(%1),%0\";
2763  else
2764    return \"ldo R'%G2(%1),%0\";
2765}"
2766  [(set_attr "type" "move")
2767   (set_attr "length" "4")])
2768
2769;; Now that a symbolic_address plus a constant is broken up early
2770;; in the compilation phase (for better CSE) we need a special
2771;; combiner pattern to load the symbolic address plus the constant
2772;; in only 2 instructions. (For cases where the symbolic address
2773;; was not a common subexpression.)
2774(define_split
2775  [(set (match_operand:SI 0 "register_operand" "")
2776	(match_operand:SI 1 "symbolic_operand" ""))
2777   (clobber (match_operand:SI 2 "register_operand" ""))]
2778  "! (flag_pic && pic_label_operand (operands[1], SImode))"
2779  [(set (match_dup 2) (high:SI (match_dup 1)))
2780   (set (match_dup 0) (lo_sum:SI (match_dup 2) (match_dup 1)))]
2781  "")
2782
2783;; hppa_legitimize_address goes to a great deal of trouble to
2784;; create addresses which use indexing.  In some cases, this
2785;; is a lose because there isn't any store instructions which
2786;; allow indexed addresses (with integer register source).
2787;;
2788;; These define_splits try to turn a 3 insn store into
2789;; a 2 insn store with some creative RTL rewriting.
2790(define_split
2791  [(set (mem:SI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2792			       (match_operand:SI 1 "mem_shadd_operand" ""))
2793		   (plus:SI (match_operand:SI 2 "register_operand" "")
2794			    (match_operand:SI 3 "const_int_operand" ""))))
2795	(match_operand:SI 4 "register_operand" ""))
2796   (clobber (match_operand:SI 5 "register_operand" ""))]
2797  ""
2798  [(set (match_dup 5) (plus:SI (ashift:SI (match_dup 0) (match_dup 1))
2799			       (match_dup 2)))
2800   (set (mem:SI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2801  "
2802{
2803  operands[1] = GEN_INT (exact_log2 (INTVAL (operands[1])));
2804
2805}")
2806
2807(define_split
2808  [(set (mem:HI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2809			       (match_operand:SI 1 "mem_shadd_operand" ""))
2810		   (plus:SI (match_operand:SI 2 "register_operand" "")
2811			    (match_operand:SI 3 "const_int_operand" ""))))
2812	(match_operand:HI 4 "register_operand" ""))
2813   (clobber (match_operand:SI 5 "register_operand" ""))]
2814  ""
2815  [(set (match_dup 5) (plus:SI (ashift:SI (match_dup 0) (match_dup 1))
2816			       (match_dup 2)))
2817   (set (mem:HI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2818  "
2819{
2820  operands[1] = GEN_INT (exact_log2 (INTVAL (operands[1])));
2821
2822}")
2823
2824(define_split
2825  [(set (mem:QI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2826			       (match_operand:SI 1 "mem_shadd_operand" ""))
2827		   (plus:SI (match_operand:SI 2 "register_operand" "")
2828			    (match_operand:SI 3 "const_int_operand" ""))))
2829	(match_operand:QI 4 "register_operand" ""))
2830   (clobber (match_operand:SI 5 "register_operand" ""))]
2831  ""
2832  [(set (match_dup 5) (plus:SI (ashift:SI (match_dup 0) (match_dup 1))
2833			       (match_dup 2)))
2834   (set (mem:QI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2835  "
2836{
2837  operands[1] = GEN_INT (exact_log2 (INTVAL (operands[1])));
2838
2839}")
2840
2841(define_expand "movhi"
2842  [(set (match_operand:HI 0 "general_operand" "")
2843	(match_operand:HI 1 "general_operand" ""))]
2844  ""
2845  "
2846{
2847  if (pa_emit_move_sequence (operands, HImode, 0))
2848    DONE;
2849}")
2850
2851;; Handle HImode input reloads requiring a general register as a
2852;; scratch register.
2853(define_expand "reload_inhi"
2854  [(set (match_operand:HI 0 "register_operand" "=Z")
2855	(match_operand:HI 1 "non_hard_reg_operand" ""))
2856   (clobber (match_operand:HI 2 "register_operand" "=&r"))]
2857  ""
2858  "
2859{
2860  if (pa_emit_move_sequence (operands, HImode, operands[2]))
2861    DONE;
2862
2863  /* We don't want the clobber emitted, so handle this ourselves.  */
2864  emit_insn (gen_rtx_SET (operands[0], operands[1]));
2865  DONE;
2866}")
2867
2868;; Handle HImode output reloads requiring a general register as a
2869;; scratch register.
2870(define_expand "reload_outhi"
2871  [(set (match_operand:HI 0 "non_hard_reg_operand" "")
2872	(match_operand:HI 1  "register_operand" "Z"))
2873   (clobber (match_operand:HI 2 "register_operand" "=&r"))]
2874  ""
2875  "
2876{
2877  if (pa_emit_move_sequence (operands, HImode, operands[2]))
2878    DONE;
2879
2880  /* We don't want the clobber emitted, so handle this ourselves.  */
2881  emit_insn (gen_rtx_SET (operands[0], operands[1]));
2882  DONE;
2883}")
2884
2885(define_insn ""
2886  [(set (match_operand:HI 0 "move_dest_operand"
2887	 		  "=r,r,r,r,r,Q,!*q,!r")
2888	(match_operand:HI 1 "move_src_operand"
2889			  "r,J,N,K,RQ,rM,!rM,!*q"))]
2890  "(register_operand (operands[0], HImode)
2891    || reg_or_0_operand (operands[1], HImode))"
2892  "@
2893   copy %1,%0
2894   ldi %1,%0
2895   ldil L'%1,%0
2896   {zdepi|depwi,z} %Z1,%0
2897   ldh%M1 %1,%0
2898   sth%M0 %r1,%0
2899   mtsar %r1
2900   {mfctl|mfctl,w} %sar,%0"
2901  [(set_attr "type" "move,move,move,shift,load,store,move,move")
2902   (set_attr "pa_combine_type" "addmove")
2903   (set_attr "length" "4,4,4,4,4,4,4,4")])
2904
2905(define_insn ""
2906  [(set (match_operand:HI 0 "register_operand" "=r")
2907	(mem:HI (plus:SI (match_operand:SI 1 "register_operand" "+r")
2908			 (match_operand:SI 2 "int5_operand" "L"))))
2909   (set (match_dup 1)
2910	(plus:SI (match_dup 1) (match_dup 2)))]
2911  ""
2912  "{ldhs|ldh},mb %2(%1),%0"
2913  [(set_attr "type" "load")
2914   (set_attr "length" "4")])
2915
2916(define_insn ""
2917  [(set (match_operand:HI 0 "register_operand" "=r")
2918	(mem:HI (plus:DI (match_operand:DI 1 "register_operand" "+r")
2919			 (match_operand:DI 2 "int5_operand" "L"))))
2920   (set (match_dup 1)
2921	(plus:DI (match_dup 1) (match_dup 2)))]
2922  "TARGET_64BIT"
2923  "ldh,mb %2(%1),%0"
2924  [(set_attr "type" "load")
2925   (set_attr "length" "4")])
2926
2927; And a zero extended variant.
2928(define_insn ""
2929  [(set (match_operand:DI 0 "register_operand" "=r")
2930	(zero_extend:DI (mem:HI
2931			  (plus:DI
2932			    (match_operand:DI 1 "register_operand" "+r")
2933			    (match_operand:DI 2 "int5_operand" "L")))))
2934   (set (match_dup 1)
2935	(plus:DI (match_dup 1) (match_dup 2)))]
2936  "TARGET_64BIT"
2937  "ldh,mb %2(%1),%0"
2938  [(set_attr "type" "load")
2939   (set_attr "length" "4")])
2940
2941(define_insn ""
2942  [(set (match_operand:SI 0 "register_operand" "=r")
2943	(zero_extend:SI (mem:HI
2944			  (plus:SI
2945			    (match_operand:SI 1 "register_operand" "+r")
2946			    (match_operand:SI 2 "int5_operand" "L")))))
2947   (set (match_dup 1)
2948	(plus:SI (match_dup 1) (match_dup 2)))]
2949  ""
2950  "{ldhs|ldh},mb %2(%1),%0"
2951  [(set_attr "type" "load")
2952   (set_attr "length" "4")])
2953
2954(define_insn ""
2955  [(set (match_operand:SI 0 "register_operand" "=r")
2956	(zero_extend:SI (mem:HI
2957			  (plus:DI
2958			    (match_operand:DI 1 "register_operand" "+r")
2959			    (match_operand:DI 2 "int5_operand" "L")))))
2960   (set (match_dup 1)
2961	(plus:DI (match_dup 1) (match_dup 2)))]
2962  "TARGET_64BIT"
2963  "ldh,mb %2(%1),%0"
2964  [(set_attr "type" "load")
2965   (set_attr "length" "4")])
2966
2967(define_insn ""
2968  [(set (mem:HI (plus:SI (match_operand:SI 0 "register_operand" "+r")
2969			 (match_operand:SI 1 "int5_operand" "L")))
2970	(match_operand:HI 2 "reg_or_0_operand" "rM"))
2971   (set (match_dup 0)
2972	(plus:SI (match_dup 0) (match_dup 1)))]
2973  ""
2974  "{sths|sth},mb %r2,%1(%0)"
2975  [(set_attr "type" "store")
2976   (set_attr "length" "4")])
2977
2978(define_insn ""
2979  [(set (mem:HI (plus:DI (match_operand:DI 0 "register_operand" "+r")
2980			 (match_operand:DI 1 "int5_operand" "L")))
2981	(match_operand:HI 2 "reg_or_0_operand" "rM"))
2982   (set (match_dup 0)
2983	(plus:DI (match_dup 0) (match_dup 1)))]
2984  "TARGET_64BIT"
2985  "sth,mb %r2,%1(%0)"
2986  [(set_attr "type" "store")
2987   (set_attr "length" "4")])
2988
2989(define_insn "addhi3"
2990  [(set (match_operand:HI 0 "register_operand" "=r,r")
2991	(plus:HI (match_operand:HI 1 "register_operand" "%r,r")
2992		 (match_operand:HI 2 "arith14_operand" "r,J")))]
2993  ""
2994  "@
2995   {addl|add,l} %1,%2,%0
2996   ldo %2(%1),%0"
2997  [(set_attr "type" "binary,binary")
2998   (set_attr "pa_combine_type" "addmove")
2999   (set_attr "length" "4,4")])
3000
3001(define_expand "movqi"
3002  [(set (match_operand:QI 0 "general_operand" "")
3003	(match_operand:QI 1 "general_operand" ""))]
3004  ""
3005  "
3006{
3007  if (pa_emit_move_sequence (operands, QImode, 0))
3008    DONE;
3009}")
3010
3011;; Handle QImode input reloads requiring a general register as a
3012;; scratch register.
3013(define_expand "reload_inqi"
3014  [(set (match_operand:QI 0 "register_operand" "=Z")
3015	(match_operand:QI 1 "non_hard_reg_operand" ""))
3016   (clobber (match_operand:QI 2 "register_operand" "=&r"))]
3017  ""
3018  "
3019{
3020  if (pa_emit_move_sequence (operands, QImode, operands[2]))
3021    DONE;
3022
3023  /* We don't want the clobber emitted, so handle this ourselves.  */
3024  emit_insn (gen_rtx_SET (operands[0], operands[1]));
3025  DONE;
3026}")
3027
3028;; Handle QImode output reloads requiring a general register as a
3029;; scratch register.
3030(define_expand "reload_outqi"
3031  [(set (match_operand:QI 0 "non_hard_reg_operand" "")
3032	(match_operand:QI 1  "register_operand" "Z"))
3033   (clobber (match_operand:QI 2 "register_operand" "=&r"))]
3034  ""
3035  "
3036{
3037  if (pa_emit_move_sequence (operands, QImode, operands[2]))
3038    DONE;
3039
3040  /* We don't want the clobber emitted, so handle this ourselves.  */
3041  emit_insn (gen_rtx_SET (operands[0], operands[1]));
3042  DONE;
3043}")
3044
3045(define_insn ""
3046  [(set (match_operand:QI 0 "move_dest_operand"
3047			  "=r,r,r,r,r,Q,!*q,!r")
3048	(match_operand:QI 1 "move_src_operand"
3049			  "r,J,N,K,RQ,rM,!rM,!*q"))]
3050  "(register_operand (operands[0], QImode)
3051    || reg_or_0_operand (operands[1], QImode))"
3052  "@
3053   copy %1,%0
3054   ldi %1,%0
3055   ldil L'%1,%0
3056   {zdepi|depwi,z} %Z1,%0
3057   ldb%M1 %1,%0
3058   stb%M0 %r1,%0
3059   mtsar %r1
3060   {mfctl|mfctl,w} %%sar,%0"
3061  [(set_attr "type" "move,move,move,shift,load,store,move,move")
3062   (set_attr "pa_combine_type" "addmove")
3063   (set_attr "length" "4,4,4,4,4,4,4,4")])
3064
3065(define_insn ""
3066  [(set (match_operand:QI 0 "register_operand" "=r")
3067	(mem:QI (plus:SI (match_operand:SI 1 "register_operand" "+r")
3068			 (match_operand:SI 2 "int5_operand" "L"))))
3069   (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
3070  ""
3071  "{ldbs|ldb},mb %2(%1),%0"
3072  [(set_attr "type" "load")
3073   (set_attr "length" "4")])
3074
3075(define_insn ""
3076  [(set (match_operand:QI 0 "register_operand" "=r")
3077	(mem:QI (plus:DI (match_operand:DI 1 "register_operand" "+r")
3078			 (match_operand:DI 2 "int5_operand" "L"))))
3079   (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3080  "TARGET_64BIT"
3081  "ldb,mb %2(%1),%0"
3082  [(set_attr "type" "load")
3083   (set_attr "length" "4")])
3084
3085; Now the same thing with zero extensions.
3086(define_insn ""
3087  [(set (match_operand:DI 0 "register_operand" "=r")
3088	(zero_extend:DI (mem:QI (plus:DI
3089				  (match_operand:DI 1 "register_operand" "+r")
3090				  (match_operand:DI 2 "int5_operand" "L")))))
3091   (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3092  "TARGET_64BIT"
3093  "ldb,mb %2(%1),%0"
3094  [(set_attr "type" "load")
3095   (set_attr "length" "4")])
3096
3097(define_insn ""
3098  [(set (match_operand:SI 0 "register_operand" "=r")
3099	(zero_extend:SI (mem:QI (plus:SI
3100				  (match_operand:SI 1 "register_operand" "+r")
3101				  (match_operand:SI 2 "int5_operand" "L")))))
3102   (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
3103  ""
3104  "{ldbs|ldb},mb %2(%1),%0"
3105  [(set_attr "type" "load")
3106   (set_attr "length" "4")])
3107
3108(define_insn ""
3109  [(set (match_operand:SI 0 "register_operand" "=r")
3110	(zero_extend:SI (mem:QI (plus:DI
3111				  (match_operand:DI 1 "register_operand" "+r")
3112				  (match_operand:DI 2 "int5_operand" "L")))))
3113   (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3114  "TARGET_64BIT"
3115  "ldb,mb %2(%1),%0"
3116  [(set_attr "type" "load")
3117   (set_attr "length" "4")])
3118
3119(define_insn ""
3120  [(set (match_operand:HI 0 "register_operand" "=r")
3121	(zero_extend:HI (mem:QI (plus:SI
3122				  (match_operand:SI 1 "register_operand" "+r")
3123				  (match_operand:SI 2 "int5_operand" "L")))))
3124   (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
3125  ""
3126  "{ldbs|ldb},mb %2(%1),%0"
3127  [(set_attr "type" "load")
3128   (set_attr "length" "4")])
3129
3130(define_insn ""
3131  [(set (match_operand:HI 0 "register_operand" "=r")
3132	(zero_extend:HI (mem:QI (plus:DI
3133				  (match_operand:DI 1 "register_operand" "+r")
3134				  (match_operand:DI 2 "int5_operand" "L")))))
3135   (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3136  "TARGET_64BIT"
3137  "ldb,mb %2(%1),%0"
3138  [(set_attr "type" "load")
3139   (set_attr "length" "4")])
3140
3141(define_insn ""
3142  [(set (mem:QI (plus:SI (match_operand:SI 0 "register_operand" "+r")
3143			 (match_operand:SI 1 "int5_operand" "L")))
3144	(match_operand:QI 2 "reg_or_0_operand" "rM"))
3145   (set (match_dup 0)
3146	(plus:SI (match_dup 0) (match_dup 1)))]
3147  ""
3148  "{stbs|stb},mb %r2,%1(%0)"
3149  [(set_attr "type" "store")
3150   (set_attr "length" "4")])
3151
3152(define_insn ""
3153  [(set (mem:QI (plus:DI (match_operand:DI 0 "register_operand" "+r")
3154			 (match_operand:DI 1 "int5_operand" "L")))
3155	(match_operand:QI 2 "reg_or_0_operand" "rM"))
3156   (set (match_dup 0)
3157	(plus:DI (match_dup 0) (match_dup 1)))]
3158  "TARGET_64BIT"
3159  "stb,mb %r2,%1(%0)"
3160  [(set_attr "type" "store")
3161   (set_attr "length" "4")])
3162
3163;; The definition of this insn does not really explain what it does,
3164;; but it should suffice that anything generated as this insn will be
3165;; recognized as a movmemsi operation, and that it will not successfully
3166;; combine with anything.
3167(define_expand "movmemsi"
3168  [(parallel [(set (match_operand:BLK 0 "" "")
3169		   (match_operand:BLK 1 "" ""))
3170	      (clobber (match_dup 4))
3171	      (clobber (match_dup 5))
3172	      (clobber (match_dup 6))
3173	      (clobber (match_dup 7))
3174	      (clobber (match_dup 8))
3175	      (use (match_operand:SI 2 "arith14_operand" ""))
3176	      (use (match_operand:SI 3 "const_int_operand" ""))])]
3177  "!TARGET_64BIT && optimize > 0"
3178  "
3179{
3180  int size, align;
3181
3182  /* HP provides very fast block move library routine for the PA;
3183     this routine includes:
3184
3185	4x4 byte at a time block moves,
3186	1x4 byte at a time with alignment checked at runtime with
3187	    attempts to align the source and destination as needed
3188	1x1 byte loop
3189
3190     With that in mind, here's the heuristics to try and guess when
3191     the inlined block move will be better than the library block
3192     move:
3193
3194	If the size isn't constant, then always use the library routines.
3195
3196	If the size is large in respect to the known alignment, then use
3197	the library routines.
3198
3199	If the size is small in respect to the known alignment, then open
3200	code the copy (since that will lead to better scheduling).
3201
3202        Else use the block move pattern.   */
3203
3204  /* Undetermined size, use the library routine.  */
3205  if (GET_CODE (operands[2]) != CONST_INT)
3206    FAIL;
3207
3208  size = INTVAL (operands[2]);
3209  align = INTVAL (operands[3]);
3210  align = align > 4 ? 4 : (align ? align : 1);
3211
3212  /* If size/alignment is large, then use the library routines.  */
3213  if (size / align > 16)
3214    FAIL;
3215
3216  /* This does happen, but not often enough to worry much about.  */
3217  if (size / align < MOVE_RATIO (optimize_insn_for_speed_p ()))
3218    FAIL;
3219
3220  /* Fall through means we're going to use our block move pattern.  */
3221  operands[0]
3222    = replace_equiv_address (operands[0],
3223			     copy_to_mode_reg (SImode, XEXP (operands[0], 0)));
3224  operands[1]
3225    = replace_equiv_address (operands[1],
3226			     copy_to_mode_reg (SImode, XEXP (operands[1], 0)));
3227  operands[4] = gen_reg_rtx (SImode);
3228  operands[5] = gen_reg_rtx (SImode);
3229  operands[6] = gen_reg_rtx (SImode);
3230  operands[7] = gen_reg_rtx (SImode);
3231  operands[8] = gen_reg_rtx (SImode);
3232}")
3233
3234;; The operand constraints are written like this to support both compile-time
3235;; and run-time determined byte counts.  The expander and pa_output_block_move
3236;; only support compile-time determined counts at this time.
3237;;
3238;; If the count is run-time determined, the register with the byte count
3239;; is clobbered by the copying code, and therefore it is forced to operand 2.
3240;;
3241;; We used to clobber operands 0 and 1.  However, a change to regrename.c
3242;; broke this semantic for pseudo registers.  We can't use match_scratch
3243;; as this requires two registers in the class R1_REGS when the MEMs for
3244;; operands 0 and 1 are both equivalent to symbolic MEMs.  Thus, we are
3245;; forced to internally copy operands 0 and 1 to operands 7 and 8,
3246;; respectively.  We then split or peephole optimize after reload.
3247(define_insn "movmemsi_prereload"
3248  [(set (mem:BLK (match_operand:SI 0 "register_operand" "r,r"))
3249	(mem:BLK (match_operand:SI 1 "register_operand" "r,r")))
3250   (clobber (match_operand:SI 2 "register_operand" "=&r,&r"))	;loop cnt/tmp
3251   (clobber (match_operand:SI 3 "register_operand" "=&r,&r"))	;item tmp1
3252   (clobber (match_operand:SI 6 "register_operand" "=&r,&r"))	;item tmp2
3253   (clobber (match_operand:SI 7 "register_operand" "=&r,&r"))	;item tmp3
3254   (clobber (match_operand:SI 8 "register_operand" "=&r,&r"))	;item tmp4
3255   (use (match_operand:SI 4 "arith14_operand" "J,2"))	 ;byte count
3256   (use (match_operand:SI 5 "const_int_operand" "n,n"))] ;alignment
3257  "!TARGET_64BIT"
3258  "#"
3259  [(set_attr "type" "multi,multi")])
3260
3261(define_split
3262  [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3263		   (match_operand:BLK 1 "memory_operand" ""))
3264	      (clobber (match_operand:SI 2 "register_operand" ""))
3265	      (clobber (match_operand:SI 3 "register_operand" ""))
3266	      (clobber (match_operand:SI 6 "register_operand" ""))
3267	      (clobber (match_operand:SI 7 "register_operand" ""))
3268	      (clobber (match_operand:SI 8 "register_operand" ""))
3269	      (use (match_operand:SI 4 "arith14_operand" ""))
3270	      (use (match_operand:SI 5 "const_int_operand" ""))])]
3271  "!TARGET_64BIT && reload_completed && !flag_peephole2
3272   && GET_CODE (operands[0]) == MEM
3273   && register_operand (XEXP (operands[0], 0), SImode)
3274   && GET_CODE (operands[1]) == MEM
3275   && register_operand (XEXP (operands[1], 0), SImode)"
3276  [(set (match_dup 7) (match_dup 9))
3277   (set (match_dup 8) (match_dup 10))
3278   (parallel [(set (match_dup 0) (match_dup 1))
3279   	      (clobber (match_dup 2))
3280   	      (clobber (match_dup 3))
3281   	      (clobber (match_dup 6))
3282   	      (clobber (match_dup 7))
3283   	      (clobber (match_dup 8))
3284   	      (use (match_dup 4))
3285   	      (use (match_dup 5))
3286	      (const_int 0)])]
3287  "
3288{
3289  operands[9] = XEXP (operands[0], 0);
3290  operands[10] = XEXP (operands[1], 0);
3291  operands[0] = replace_equiv_address (operands[0], operands[7]);
3292  operands[1] = replace_equiv_address (operands[1], operands[8]);
3293}")
3294
3295(define_peephole2
3296  [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3297		   (match_operand:BLK 1 "memory_operand" ""))
3298	      (clobber (match_operand:SI 2 "register_operand" ""))
3299	      (clobber (match_operand:SI 3 "register_operand" ""))
3300	      (clobber (match_operand:SI 6 "register_operand" ""))
3301	      (clobber (match_operand:SI 7 "register_operand" ""))
3302	      (clobber (match_operand:SI 8 "register_operand" ""))
3303	      (use (match_operand:SI 4 "arith14_operand" ""))
3304	      (use (match_operand:SI 5 "const_int_operand" ""))])]
3305  "!TARGET_64BIT
3306   && GET_CODE (operands[0]) == MEM
3307   && register_operand (XEXP (operands[0], 0), SImode)
3308   && GET_CODE (operands[1]) == MEM
3309   && register_operand (XEXP (operands[1], 0), SImode)"
3310  [(parallel [(set (match_dup 0) (match_dup 1))
3311   	      (clobber (match_dup 2))
3312   	      (clobber (match_dup 3))
3313   	      (clobber (match_dup 6))
3314   	      (clobber (match_dup 7))
3315   	      (clobber (match_dup 8))
3316   	      (use (match_dup 4))
3317   	      (use (match_dup 5))
3318	      (const_int 0)])]
3319  "
3320{
3321  rtx addr = XEXP (operands[0], 0);
3322  if (dead_or_set_p (curr_insn, addr))
3323    operands[7] = addr;
3324  else
3325    {
3326      emit_insn (gen_rtx_SET (operands[7], addr));
3327      operands[0] = replace_equiv_address (operands[0], operands[7]);
3328    }
3329
3330  addr = XEXP (operands[1], 0);
3331  if (dead_or_set_p (curr_insn, addr))
3332    operands[8] = addr;
3333  else
3334    {
3335      emit_insn (gen_rtx_SET (operands[8], addr));
3336      operands[1] = replace_equiv_address (operands[1], operands[8]);
3337    }
3338}")
3339
3340(define_insn "movmemsi_postreload"
3341  [(set (mem:BLK (match_operand:SI 0 "register_operand" "+r,r"))
3342	(mem:BLK (match_operand:SI 1 "register_operand" "+r,r")))
3343   (clobber (match_operand:SI 2 "register_operand" "=&r,&r"))	;loop cnt/tmp
3344   (clobber (match_operand:SI 3 "register_operand" "=&r,&r"))	;item tmp1
3345   (clobber (match_operand:SI 6 "register_operand" "=&r,&r"))	;item tmp2
3346   (clobber (match_dup 0))
3347   (clobber (match_dup 1))
3348   (use (match_operand:SI 4 "arith14_operand" "J,2"))	 ;byte count
3349   (use (match_operand:SI 5 "const_int_operand" "n,n"))  ;alignment
3350   (const_int 0)]
3351  "!TARGET_64BIT && reload_completed"
3352  "* return pa_output_block_move (operands, !which_alternative);"
3353  [(set_attr "type" "multi,multi")])
3354
3355(define_expand "movmemdi"
3356  [(parallel [(set (match_operand:BLK 0 "" "")
3357		   (match_operand:BLK 1 "" ""))
3358	      (clobber (match_dup 4))
3359	      (clobber (match_dup 5))
3360	      (clobber (match_dup 6))
3361	      (clobber (match_dup 7))
3362	      (clobber (match_dup 8))
3363	      (use (match_operand:DI 2 "arith14_operand" ""))
3364	      (use (match_operand:DI 3 "const_int_operand" ""))])]
3365  "TARGET_64BIT && optimize > 0"
3366  "
3367{
3368  int size, align;
3369
3370  /* HP provides very fast block move library routine for the PA;
3371     this routine includes:
3372
3373	4x4 byte at a time block moves,
3374	1x4 byte at a time with alignment checked at runtime with
3375	    attempts to align the source and destination as needed
3376	1x1 byte loop
3377
3378     With that in mind, here's the heuristics to try and guess when
3379     the inlined block move will be better than the library block
3380     move:
3381
3382	If the size isn't constant, then always use the library routines.
3383
3384	If the size is large in respect to the known alignment, then use
3385	the library routines.
3386
3387	If the size is small in respect to the known alignment, then open
3388	code the copy (since that will lead to better scheduling).
3389
3390        Else use the block move pattern.   */
3391
3392  /* Undetermined size, use the library routine.  */
3393  if (GET_CODE (operands[2]) != CONST_INT)
3394    FAIL;
3395
3396  size = INTVAL (operands[2]);
3397  align = INTVAL (operands[3]);
3398  align = align > 8 ? 8 : (align ? align : 1);
3399
3400  /* If size/alignment is large, then use the library routines.  */
3401  if (size / align > 16)
3402    FAIL;
3403
3404  /* This does happen, but not often enough to worry much about.  */
3405  if (size / align < MOVE_RATIO (optimize_insn_for_speed_p ()))
3406    FAIL;
3407
3408  /* Fall through means we're going to use our block move pattern.  */
3409  operands[0]
3410    = replace_equiv_address (operands[0],
3411			     copy_to_mode_reg (DImode, XEXP (operands[0], 0)));
3412  operands[1]
3413    = replace_equiv_address (operands[1],
3414			     copy_to_mode_reg (DImode, XEXP (operands[1], 0)));
3415  operands[4] = gen_reg_rtx (DImode);
3416  operands[5] = gen_reg_rtx (DImode);
3417  operands[6] = gen_reg_rtx (DImode);
3418  operands[7] = gen_reg_rtx (DImode);
3419  operands[8] = gen_reg_rtx (DImode);
3420}")
3421
3422;; The operand constraints are written like this to support both compile-time
3423;; and run-time determined byte counts.  The expander and pa_output_block_move
3424;; only support compile-time determined counts at this time.
3425;;
3426;; If the count is run-time determined, the register with the byte count
3427;; is clobbered by the copying code, and therefore it is forced to operand 2.
3428;;
3429;; We used to clobber operands 0 and 1.  However, a change to regrename.c
3430;; broke this semantic for pseudo registers.  We can't use match_scratch
3431;; as this requires two registers in the class R1_REGS when the MEMs for
3432;; operands 0 and 1 are both equivalent to symbolic MEMs.  Thus, we are
3433;; forced to internally copy operands 0 and 1 to operands 7 and 8,
3434;; respectively.  We then split or peephole optimize after reload.
3435(define_insn "movmemdi_prereload"
3436  [(set (mem:BLK (match_operand:DI 0 "register_operand" "r,r"))
3437	(mem:BLK (match_operand:DI 1 "register_operand" "r,r")))
3438   (clobber (match_operand:DI 2 "register_operand" "=&r,&r"))	;loop cnt/tmp
3439   (clobber (match_operand:DI 3 "register_operand" "=&r,&r"))	;item tmp1
3440   (clobber (match_operand:DI 6 "register_operand" "=&r,&r"))	;item tmp2
3441   (clobber (match_operand:DI 7 "register_operand" "=&r,&r"))	;item tmp3
3442   (clobber (match_operand:DI 8 "register_operand" "=&r,&r"))	;item tmp4
3443   (use (match_operand:DI 4 "arith14_operand" "J,2"))	 ;byte count
3444   (use (match_operand:DI 5 "const_int_operand" "n,n"))] ;alignment
3445  "TARGET_64BIT"
3446  "#"
3447  [(set_attr "type" "multi,multi")])
3448
3449(define_split
3450  [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3451		   (match_operand:BLK 1 "memory_operand" ""))
3452	      (clobber (match_operand:DI 2 "register_operand" ""))
3453	      (clobber (match_operand:DI 3 "register_operand" ""))
3454	      (clobber (match_operand:DI 6 "register_operand" ""))
3455	      (clobber (match_operand:DI 7 "register_operand" ""))
3456	      (clobber (match_operand:DI 8 "register_operand" ""))
3457	      (use (match_operand:DI 4 "arith14_operand" ""))
3458	      (use (match_operand:DI 5 "const_int_operand" ""))])]
3459  "TARGET_64BIT && reload_completed && !flag_peephole2
3460   && GET_CODE (operands[0]) == MEM
3461   && register_operand (XEXP (operands[0], 0), DImode)
3462   && GET_CODE (operands[1]) == MEM
3463   && register_operand (XEXP (operands[1], 0), DImode)"
3464  [(set (match_dup 7) (match_dup 9))
3465   (set (match_dup 8) (match_dup 10))
3466   (parallel [(set (match_dup 0) (match_dup 1))
3467   	      (clobber (match_dup 2))
3468   	      (clobber (match_dup 3))
3469   	      (clobber (match_dup 6))
3470   	      (clobber (match_dup 7))
3471   	      (clobber (match_dup 8))
3472   	      (use (match_dup 4))
3473   	      (use (match_dup 5))
3474	      (const_int 0)])]
3475  "
3476{
3477  operands[9] = XEXP (operands[0], 0);
3478  operands[10] = XEXP (operands[1], 0);
3479  operands[0] = replace_equiv_address (operands[0], operands[7]);
3480  operands[1] = replace_equiv_address (operands[1], operands[8]);
3481}")
3482
3483(define_peephole2
3484  [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3485		   (match_operand:BLK 1 "memory_operand" ""))
3486	      (clobber (match_operand:DI 2 "register_operand" ""))
3487	      (clobber (match_operand:DI 3 "register_operand" ""))
3488	      (clobber (match_operand:DI 6 "register_operand" ""))
3489	      (clobber (match_operand:DI 7 "register_operand" ""))
3490	      (clobber (match_operand:DI 8 "register_operand" ""))
3491	      (use (match_operand:DI 4 "arith14_operand" ""))
3492	      (use (match_operand:DI 5 "const_int_operand" ""))])]
3493  "TARGET_64BIT
3494   && GET_CODE (operands[0]) == MEM
3495   && register_operand (XEXP (operands[0], 0), DImode)
3496   && GET_CODE (operands[1]) == MEM
3497   && register_operand (XEXP (operands[1], 0), DImode)"
3498  [(parallel [(set (match_dup 0) (match_dup 1))
3499   	      (clobber (match_dup 2))
3500   	      (clobber (match_dup 3))
3501   	      (clobber (match_dup 6))
3502   	      (clobber (match_dup 7))
3503   	      (clobber (match_dup 8))
3504   	      (use (match_dup 4))
3505   	      (use (match_dup 5))
3506	      (const_int 0)])]
3507  "
3508{
3509  rtx addr = XEXP (operands[0], 0);
3510  if (dead_or_set_p (curr_insn, addr))
3511    operands[7] = addr;
3512  else
3513    {
3514      emit_insn (gen_rtx_SET (operands[7], addr));
3515      operands[0] = replace_equiv_address (operands[0], operands[7]);
3516    }
3517
3518  addr = XEXP (operands[1], 0);
3519  if (dead_or_set_p (curr_insn, addr))
3520    operands[8] = addr;
3521  else
3522    {
3523      emit_insn (gen_rtx_SET (operands[8], addr));
3524      operands[1] = replace_equiv_address (operands[1], operands[8]);
3525    }
3526}")
3527
3528(define_insn "movmemdi_postreload"
3529  [(set (mem:BLK (match_operand:DI 0 "register_operand" "+r,r"))
3530	(mem:BLK (match_operand:DI 1 "register_operand" "+r,r")))
3531   (clobber (match_operand:DI 2 "register_operand" "=&r,&r"))	;loop cnt/tmp
3532   (clobber (match_operand:DI 3 "register_operand" "=&r,&r"))	;item tmp1
3533   (clobber (match_operand:DI 6 "register_operand" "=&r,&r"))	;item tmp2
3534   (clobber (match_dup 0))
3535   (clobber (match_dup 1))
3536   (use (match_operand:DI 4 "arith14_operand" "J,2"))	 ;byte count
3537   (use (match_operand:DI 5 "const_int_operand" "n,n"))  ;alignment
3538   (const_int 0)]
3539  "TARGET_64BIT && reload_completed"
3540  "* return pa_output_block_move (operands, !which_alternative);"
3541  [(set_attr "type" "multi,multi")])
3542
3543(define_expand "setmemsi"
3544  [(parallel [(set (match_operand:BLK 0 "" "")
3545		   (match_operand 2 "const_int_operand" ""))
3546	      (clobber (match_dup 4))
3547	      (clobber (match_dup 5))
3548	      (use (match_operand:SI 1 "arith14_operand" ""))
3549	      (use (match_operand:SI 3 "const_int_operand" ""))])]
3550  "!TARGET_64BIT && optimize > 0"
3551  "
3552{
3553  int size, align;
3554
3555  /* If value to set is not zero, use the library routine.  */
3556  if (operands[2] != const0_rtx)
3557    FAIL;
3558
3559  /* Undetermined size, use the library routine.  */
3560  if (GET_CODE (operands[1]) != CONST_INT)
3561    FAIL;
3562
3563  size = INTVAL (operands[1]);
3564  align = INTVAL (operands[3]);
3565  align = align > 4 ? 4 : align;
3566
3567  /* If size/alignment is large, then use the library routines.  */
3568  if (size / align > 16)
3569    FAIL;
3570
3571  /* This does happen, but not often enough to worry much about.  */
3572  if (size / align < MOVE_RATIO (optimize_insn_for_speed_p ()))
3573    FAIL;
3574
3575  /* Fall through means we're going to use our block clear pattern.  */
3576  operands[0]
3577    = replace_equiv_address (operands[0],
3578			     copy_to_mode_reg (SImode, XEXP (operands[0], 0)));
3579  operands[4] = gen_reg_rtx (SImode);
3580  operands[5] = gen_reg_rtx (SImode);
3581}")
3582
3583(define_insn "clrmemsi_prereload"
3584  [(set (mem:BLK (match_operand:SI 0 "register_operand" "r,r"))
3585	(const_int 0))
3586   (clobber (match_operand:SI 1 "register_operand" "=&r,&r"))	;loop cnt/tmp
3587   (clobber (match_operand:SI 4 "register_operand" "=&r,&r"))	;tmp1
3588   (use (match_operand:SI 2 "arith14_operand" "J,1"))	 ;byte count
3589   (use (match_operand:SI 3 "const_int_operand" "n,n"))] ;alignment
3590  "!TARGET_64BIT"
3591  "#"
3592  [(set_attr "type" "multi,multi")])
3593
3594(define_split
3595  [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3596		   (const_int 0))
3597	      (clobber (match_operand:SI 1 "register_operand" ""))
3598	      (clobber (match_operand:SI 4 "register_operand" ""))
3599	      (use (match_operand:SI 2 "arith14_operand" ""))
3600	      (use (match_operand:SI 3 "const_int_operand" ""))])]
3601  "!TARGET_64BIT && reload_completed && !flag_peephole2
3602   && GET_CODE (operands[0]) == MEM
3603   && register_operand (XEXP (operands[0], 0), SImode)"
3604  [(set (match_dup 4) (match_dup 5))
3605   (parallel [(set (match_dup 0) (const_int 0))
3606   	      (clobber (match_dup 1))
3607   	      (clobber (match_dup 4))
3608   	      (use (match_dup 2))
3609   	      (use (match_dup 3))
3610	      (const_int 0)])]
3611  "
3612{
3613  operands[5] = XEXP (operands[0], 0);
3614  operands[0] = replace_equiv_address (operands[0], operands[4]);
3615}")
3616
3617(define_peephole2
3618  [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3619		   (const_int 0))
3620	      (clobber (match_operand:SI 1 "register_operand" ""))
3621	      (clobber (match_operand:SI 4 "register_operand" ""))
3622	      (use (match_operand:SI 2 "arith14_operand" ""))
3623	      (use (match_operand:SI 3 "const_int_operand" ""))])]
3624  "!TARGET_64BIT
3625   && GET_CODE (operands[0]) == MEM
3626   && register_operand (XEXP (operands[0], 0), SImode)"
3627  [(parallel [(set (match_dup 0) (const_int 0))
3628   	      (clobber (match_dup 1))
3629   	      (clobber (match_dup 4))
3630   	      (use (match_dup 2))
3631   	      (use (match_dup 3))
3632	      (const_int 0)])]
3633  "
3634{
3635  rtx addr = XEXP (operands[0], 0);
3636  if (dead_or_set_p (curr_insn, addr))
3637    operands[4] = addr;
3638  else
3639    {
3640      emit_insn (gen_rtx_SET (operands[4], addr));
3641      operands[0] = replace_equiv_address (operands[0], operands[4]);
3642    }
3643}")
3644
3645(define_insn "clrmemsi_postreload"
3646  [(set (mem:BLK (match_operand:SI 0 "register_operand" "+r,r"))
3647	(const_int 0))
3648   (clobber (match_operand:SI 1 "register_operand" "=&r,&r"))	;loop cnt/tmp
3649   (clobber (match_dup 0))
3650   (use (match_operand:SI 2 "arith14_operand" "J,1"))	 ;byte count
3651   (use (match_operand:SI 3 "const_int_operand" "n,n"))  ;alignment
3652   (const_int 0)]
3653  "!TARGET_64BIT && reload_completed"
3654  "* return pa_output_block_clear (operands, !which_alternative);"
3655  [(set_attr "type" "multi,multi")])
3656
3657(define_expand "setmemdi"
3658  [(parallel [(set (match_operand:BLK 0 "" "")
3659		   (match_operand 2 "const_int_operand" ""))
3660	      (clobber (match_dup 4))
3661	      (clobber (match_dup 5))
3662	      (use (match_operand:DI 1 "arith14_operand" ""))
3663	      (use (match_operand:DI 3 "const_int_operand" ""))])]
3664  "TARGET_64BIT && optimize > 0"
3665  "
3666{
3667  int size, align;
3668
3669  /* If value to set is not zero, use the library routine.  */
3670  if (operands[2] != const0_rtx)
3671    FAIL;
3672
3673  /* Undetermined size, use the library routine.  */
3674  if (GET_CODE (operands[1]) != CONST_INT)
3675    FAIL;
3676
3677  size = INTVAL (operands[1]);
3678  align = INTVAL (operands[3]);
3679  align = align > 8 ? 8 : align;
3680
3681  /* If size/alignment is large, then use the library routines.  */
3682  if (size / align > 16)
3683    FAIL;
3684
3685  /* This does happen, but not often enough to worry much about.  */
3686  if (size / align < MOVE_RATIO (optimize_insn_for_speed_p ()))
3687    FAIL;
3688
3689  /* Fall through means we're going to use our block clear pattern.  */
3690  operands[0]
3691    = replace_equiv_address (operands[0],
3692			     copy_to_mode_reg (DImode, XEXP (operands[0], 0)));
3693  operands[4] = gen_reg_rtx (DImode);
3694  operands[5] = gen_reg_rtx (DImode);
3695}")
3696
3697(define_insn "clrmemdi_prereload"
3698  [(set (mem:BLK (match_operand:DI 0 "register_operand" "r,r"))
3699	(const_int 0))
3700   (clobber (match_operand:DI 1 "register_operand" "=&r,&r"))	;loop cnt/tmp
3701   (clobber (match_operand:DI 4 "register_operand" "=&r,&r"))	;item tmp1
3702   (use (match_operand:DI 2 "arith14_operand" "J,1"))	 ;byte count
3703   (use (match_operand:DI 3 "const_int_operand" "n,n"))] ;alignment
3704  "TARGET_64BIT"
3705  "#"
3706  [(set_attr "type" "multi,multi")])
3707
3708(define_split
3709  [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3710		   (const_int 0))
3711	      (clobber (match_operand:DI 1 "register_operand" ""))
3712	      (clobber (match_operand:DI 4 "register_operand" ""))
3713	      (use (match_operand:DI 2 "arith14_operand" ""))
3714	      (use (match_operand:DI 3 "const_int_operand" ""))])]
3715  "TARGET_64BIT && reload_completed && !flag_peephole2
3716   && GET_CODE (operands[0]) == MEM
3717   && register_operand (XEXP (operands[0], 0), DImode)"
3718  [(set (match_dup 4) (match_dup 5))
3719   (parallel [(set (match_dup 0) (const_int 0))
3720   	      (clobber (match_dup 1))
3721   	      (clobber (match_dup 4))
3722   	      (use (match_dup 2))
3723   	      (use (match_dup 3))
3724	      (const_int 0)])]
3725  "
3726{
3727  operands[5] = XEXP (operands[0], 0);
3728  operands[0] = replace_equiv_address (operands[0], operands[4]);
3729}")
3730
3731(define_peephole2
3732  [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3733		   (const_int 0))
3734	      (clobber (match_operand:DI 1 "register_operand" ""))
3735	      (clobber (match_operand:DI 4 "register_operand" ""))
3736	      (use (match_operand:DI 2 "arith14_operand" ""))
3737	      (use (match_operand:DI 3 "const_int_operand" ""))])]
3738  "TARGET_64BIT
3739   && GET_CODE (operands[0]) == MEM
3740   && register_operand (XEXP (operands[0], 0), DImode)"
3741  [(parallel [(set (match_dup 0) (const_int 0))
3742   	      (clobber (match_dup 1))
3743   	      (clobber (match_dup 4))
3744   	      (use (match_dup 2))
3745   	      (use (match_dup 3))
3746	      (const_int 0)])]
3747  "
3748{
3749  rtx addr = XEXP (operands[0], 0);
3750  if (dead_or_set_p (curr_insn, addr))
3751    operands[4] = addr;
3752  else
3753    {
3754      emit_insn (gen_rtx_SET (operands[4], addr));
3755      operands[0] = replace_equiv_address (operands[0], operands[4]);
3756    }
3757}")
3758
3759(define_insn "clrmemdi_postreload"
3760  [(set (mem:BLK (match_operand:DI 0 "register_operand" "+r,r"))
3761	(const_int 0))
3762   (clobber (match_operand:DI 1 "register_operand" "=&r,&r"))	;loop cnt/tmp
3763   (clobber (match_dup 0))
3764   (use (match_operand:DI 2 "arith14_operand" "J,1"))	 ;byte count
3765   (use (match_operand:DI 3 "const_int_operand" "n,n"))  ;alignment
3766   (const_int 0)]
3767  "TARGET_64BIT && reload_completed"
3768  "* return pa_output_block_clear (operands, !which_alternative);"
3769  [(set_attr "type" "multi,multi")])
3770
3771;; Floating point move insns
3772
3773(define_expand "movdf"
3774  [(set (match_operand:DF 0 "general_operand" "")
3775	(match_operand:DF 1 "general_operand" ""))]
3776  ""
3777  "
3778{
3779  if (pa_emit_move_sequence (operands, DFmode, 0))
3780    DONE;
3781}")
3782
3783;; Handle DFmode input reloads requiring %r1 as a scratch register.
3784(define_expand "reload_indf_r1"
3785  [(set (match_operand:DF 0 "register_operand" "=Z")
3786	(match_operand:DF 1 "non_hard_reg_operand" ""))
3787   (clobber (match_operand:SI 2 "register_operand" "=&a"))]
3788  ""
3789  "
3790{
3791  if (pa_emit_move_sequence (operands, DFmode, operands[2]))
3792    DONE;
3793
3794  /* We don't want the clobber emitted, so handle this ourselves.  */
3795  emit_insn (gen_rtx_SET (operands[0], operands[1]));
3796  DONE;
3797}")
3798
3799;; Handle DFmode input reloads requiring a general register as a
3800;; scratch register.
3801(define_expand "reload_indf"
3802  [(set (match_operand:DF 0 "register_operand" "=Z")
3803	(match_operand:DF 1 "non_hard_reg_operand" ""))
3804   (clobber (match_operand:DF 2 "register_operand" "=&r"))]
3805  ""
3806  "
3807{
3808  if (pa_emit_move_sequence (operands, DFmode, operands[2]))
3809    DONE;
3810
3811  /* We don't want the clobber emitted, so handle this ourselves.  */
3812  emit_insn (gen_rtx_SET (operands[0], operands[1]));
3813  DONE;
3814}")
3815
3816;; Handle DFmode output reloads requiring a general register as a
3817;; scratch register.
3818(define_expand "reload_outdf"
3819 [(set (match_operand:DF 0 "non_hard_reg_operand" "")
3820	(match_operand:DF 1  "register_operand" "Z"))
3821   (clobber (match_operand:DF 2 "register_operand" "=&r"))]
3822  ""
3823  "
3824{
3825  if (pa_emit_move_sequence (operands, DFmode, operands[2]))
3826    DONE;
3827
3828  /* We don't want the clobber emitted, so handle this ourselves.  */
3829  emit_insn (gen_rtx_SET (operands[0], operands[1]));
3830  DONE;
3831}")
3832
3833(define_insn ""
3834  [(set (match_operand:DF 0 "move_dest_operand"
3835			  "=f,*r,T,?o,?Q,f,*r,*r,?*r,?f")
3836	(match_operand:DF 1 "reg_or_0_or_nonsymb_mem_operand"
3837			  "fG,*rG,f,*r,*r,RT,o,RQ,f,*r"))]
3838  "(register_operand (operands[0], DFmode)
3839    || reg_or_0_operand (operands[1], DFmode))
3840   && !(GET_CODE (operands[1]) == CONST_DOUBLE
3841	&& GET_CODE (operands[0]) == MEM)
3842   && !TARGET_64BIT
3843   && !TARGET_SOFT_FLOAT"
3844  "*
3845{
3846  if ((FP_REG_P (operands[0]) || FP_REG_P (operands[1])
3847       || operands[1] == CONST0_RTX (DFmode))
3848      && !(REG_P (operands[0]) && REG_P (operands[1])
3849	   && FP_REG_P (operands[0]) ^ FP_REG_P (operands[1])))
3850    return pa_output_fp_move_double (operands);
3851  return pa_output_move_double (operands);
3852}"
3853  [(set_attr "type" "fpalu,move,fpstore,store,store,fpload,load,load,fpstore_load,store_fpload")
3854   (set_attr "length" "4,8,4,8,16,4,8,16,12,12")])
3855
3856(define_insn ""
3857  [(set (match_operand:DF 0 "indexed_memory_operand" "=R")
3858	(match_operand:DF 1 "reg_or_0_operand" "f"))]
3859  "!TARGET_SOFT_FLOAT
3860   && !TARGET_DISABLE_INDEXING
3861   && reload_completed"
3862  "fstd%F0 %1,%0"
3863  [(set_attr "type" "fpstore")
3864   (set_attr "pa_combine_type" "addmove")
3865   (set_attr "length" "4")])
3866
3867(define_peephole2
3868  [(set (match_operand:SI 0 "register_operand" "")
3869	(plus:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
3870			    (const_int 3))
3871		 (match_operand:SI 2 "register_operand" "")))
3872   (set (mem:DF (match_dup 0))
3873        (match_operand:DF 3 "register_operand" ""))]
3874  "!TARGET_SOFT_FLOAT
3875   && !TARGET_DISABLE_INDEXING
3876   && REG_OK_FOR_BASE_P (operands[2])
3877   && FP_REGNO_P (REGNO (operands[3]))"
3878  [(set (mem:DF (plus:SI (mult:SI (match_dup 1) (const_int 8)) (match_dup 2)))
3879	(match_dup 3))
3880   (set (match_dup 0) (plus:SI (ashift:SI (match_dup 1) (const_int 3))
3881			       (match_dup 2)))]
3882  "")
3883
3884(define_peephole2
3885  [(set (match_operand:SI 0 "register_operand" "")
3886	(plus:SI (match_operand:SI 2 "register_operand" "")
3887		 (ashift:SI (match_operand:SI 1 "register_operand" "")
3888			    (const_int 3))))
3889   (set (mem:DF (match_dup 0))
3890        (match_operand:DF 3 "register_operand" ""))]
3891  "!TARGET_SOFT_FLOAT
3892   && !TARGET_DISABLE_INDEXING
3893   && REG_OK_FOR_BASE_P (operands[2])
3894   && FP_REGNO_P (REGNO (operands[3]))"
3895  [(set (mem:DF (plus:SI (mult:SI (match_dup 1) (const_int 8)) (match_dup 2)))
3896	(match_dup 3))
3897   (set (match_dup 0) (plus:SI (ashift:SI (match_dup 1) (const_int 3))
3898			       (match_dup 2)))]
3899  "")
3900
3901(define_peephole2
3902  [(set (match_operand:DI 0 "register_operand" "")
3903	(plus:DI (ashift:DI (match_operand:DI 1 "register_operand" "")
3904			    (const_int 3))
3905		 (match_operand:DI 2 "register_operand" "")))
3906   (set (mem:DF (match_dup 0))
3907        (match_operand:DF 3 "register_operand" ""))]
3908  "!TARGET_SOFT_FLOAT
3909   && !TARGET_DISABLE_INDEXING
3910   && TARGET_64BIT
3911   && REG_OK_FOR_BASE_P (operands[2])
3912   && FP_REGNO_P (REGNO (operands[3]))"
3913  [(set (mem:DF (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
3914	(match_dup 3))
3915   (set (match_dup 0) (plus:DI (ashift:DI (match_dup 1) (const_int 3))
3916			       (match_dup 2)))]
3917  "")
3918
3919(define_peephole2
3920  [(set (match_operand:DI 0 "register_operand" "")
3921	(plus:DI (match_operand:DI 2 "register_operand" "")
3922		 (ashift:DI (match_operand:DI 1 "register_operand" "")
3923			    (const_int 3))))
3924   (set (mem:DF (match_dup 0))
3925        (match_operand:DF 3 "register_operand" ""))]
3926  "!TARGET_SOFT_FLOAT
3927   && !TARGET_DISABLE_INDEXING
3928   && TARGET_64BIT
3929   && REG_OK_FOR_BASE_P (operands[2])
3930   && FP_REGNO_P (REGNO (operands[3]))"
3931  [(set (mem:DF (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
3932	(match_dup 3))
3933   (set (match_dup 0) (plus:DI (ashift:DI (match_dup 1) (const_int 3))
3934			       (match_dup 2)))]
3935  "")
3936
3937(define_peephole2
3938  [(set (match_operand:SI 0 "register_operand" "")
3939	(plus:SI (match_operand:SI 1 "register_operand" "")
3940		 (match_operand:SI 2 "register_operand" "")))
3941   (set (mem:DF (match_dup 0))
3942        (match_operand:DF 3 "register_operand" ""))]
3943  "!TARGET_SOFT_FLOAT
3944   && !TARGET_DISABLE_INDEXING
3945   && TARGET_NO_SPACE_REGS
3946   && REG_OK_FOR_INDEX_P (operands[1])
3947   && REG_OK_FOR_BASE_P (operands[2])
3948   && FP_REGNO_P (REGNO (operands[3]))"
3949  [(set (mem:DF (plus:SI (match_dup 1) (match_dup 2)))
3950	(match_dup 3))
3951   (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
3952  "")
3953
3954(define_peephole2
3955  [(set (match_operand:SI 0 "register_operand" "")
3956	(plus:SI (match_operand:SI 1 "register_operand" "")
3957		 (match_operand:SI 2 "register_operand" "")))
3958   (set (mem:DF (match_dup 0))
3959        (match_operand:DF 3 "register_operand" ""))]
3960  "!TARGET_SOFT_FLOAT
3961   && !TARGET_DISABLE_INDEXING
3962   && TARGET_NO_SPACE_REGS
3963   && REG_OK_FOR_BASE_P (operands[1])
3964   && REG_OK_FOR_INDEX_P (operands[2])
3965   && FP_REGNO_P (REGNO (operands[3]))"
3966  [(set (mem:DF (plus:SI (match_dup 2) (match_dup 1)))
3967	(match_dup 3))
3968   (set (match_dup 0) (plus:SI (match_dup 2) (match_dup 1)))]
3969  "")
3970
3971(define_peephole2
3972  [(set (match_operand:DI 0 "register_operand" "")
3973	(plus:DI (match_operand:DI 1 "register_operand" "")
3974		 (match_operand:DI 2 "register_operand" "")))
3975   (set (mem:DF (match_dup 0))
3976        (match_operand:DF 3 "register_operand" ""))]
3977  "!TARGET_SOFT_FLOAT
3978   && !TARGET_DISABLE_INDEXING
3979   && TARGET_64BIT
3980   && TARGET_NO_SPACE_REGS
3981   && REG_OK_FOR_INDEX_P (operands[1])
3982   && REG_OK_FOR_BASE_P (operands[2])
3983   && FP_REGNO_P (REGNO (operands[3]))"
3984  [(set (mem:DF (plus:DI (match_dup 1) (match_dup 2)))
3985	(match_dup 3))
3986   (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
3987  "")
3988
3989(define_peephole2
3990  [(set (match_operand:DI 0 "register_operand" "")
3991	(plus:DI (match_operand:DI 1 "register_operand" "")
3992		 (match_operand:DI 2 "register_operand" "")))
3993   (set (mem:DF (match_dup 0))
3994        (match_operand:DF 3 "register_operand" ""))]
3995  "!TARGET_SOFT_FLOAT
3996   && !TARGET_DISABLE_INDEXING
3997   && TARGET_64BIT
3998   && TARGET_NO_SPACE_REGS
3999   && REG_OK_FOR_BASE_P (operands[1])
4000   && REG_OK_FOR_INDEX_P (operands[2])
4001   && FP_REGNO_P (REGNO (operands[3]))"
4002  [(set (mem:DF (plus:DI (match_dup 2) (match_dup 1)))
4003	(match_dup 3))
4004   (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
4005  "")
4006
4007(define_insn ""
4008  [(set (match_operand:DF 0 "move_dest_operand"
4009			  "=r,?o,?Q,r,r")
4010	(match_operand:DF 1 "reg_or_0_or_nonsymb_mem_operand"
4011			  "rG,r,r,o,RQ"))]
4012  "(register_operand (operands[0], DFmode)
4013    || reg_or_0_operand (operands[1], DFmode))
4014   && !TARGET_64BIT
4015   && TARGET_SOFT_FLOAT"
4016  "*
4017{
4018  return pa_output_move_double (operands);
4019}"
4020  [(set_attr "type" "move,store,store,load,load")
4021   (set_attr "length" "8,8,16,8,16")])
4022
4023(define_insn ""
4024  [(set (match_operand:DF 0 "move_dest_operand"
4025			  "=!*r,*r,*r,*r,*r,Q,f,f,T")
4026	(match_operand:DF 1 "move_src_operand"
4027			  "!*r,J,N,K,RQ,*rG,fG,RT,f"))]
4028  "(register_operand (operands[0], DFmode)
4029    || reg_or_0_operand (operands[1], DFmode))
4030   && !TARGET_SOFT_FLOAT && TARGET_64BIT"
4031  "@
4032   copy %1,%0
4033   ldi %1,%0
4034   ldil L'%1,%0
4035   depdi,z %z1,%0
4036   ldd%M1 %1,%0
4037   std%M0 %r1,%0
4038   fcpy,dbl %f1,%0
4039   fldd%F1 %1,%0
4040   fstd%F0 %1,%0"
4041  [(set_attr "type" "move,move,move,shift,load,store,fpalu,fpload,fpstore")
4042   (set_attr "pa_combine_type" "addmove")
4043   (set_attr "length" "4,4,4,4,4,4,4,4,4")])
4044
4045
4046(define_expand "movdi"
4047  [(set (match_operand:DI 0 "general_operand" "")
4048	(match_operand:DI 1 "general_operand" ""))]
4049  ""
4050  "
4051{
4052  if (pa_emit_move_sequence (operands, DImode, 0))
4053    DONE;
4054}")
4055
4056;; Handle DImode input reloads requiring %r1 as a scratch register.
4057(define_expand "reload_indi_r1"
4058  [(set (match_operand:DI 0 "register_operand" "=Z")
4059	(match_operand:DI 1 "non_hard_reg_operand" ""))
4060   (clobber (match_operand:SI 2 "register_operand" "=&a"))]
4061  ""
4062  "
4063{
4064  if (pa_emit_move_sequence (operands, DImode, operands[2]))
4065    DONE;
4066
4067  /* We don't want the clobber emitted, so handle this ourselves.  */
4068  emit_insn (gen_rtx_SET (operands[0], operands[1]));
4069  DONE;
4070}")
4071
4072;; Handle DImode input reloads requiring a general register as a
4073;; scratch register.
4074(define_expand "reload_indi"
4075  [(set (match_operand:DI 0 "register_operand" "=Z")
4076	(match_operand:DI 1 "non_hard_reg_operand" ""))
4077   (clobber (match_operand:SI 2 "register_operand" "=&r"))]
4078  ""
4079  "
4080{
4081  if (pa_emit_move_sequence (operands, DImode, operands[2]))
4082    DONE;
4083
4084  /* We don't want the clobber emitted, so handle this ourselves.  */
4085  emit_insn (gen_rtx_SET (operands[0], operands[1]));
4086  DONE;
4087}")
4088
4089;; Handle DImode output reloads requiring a general register as a
4090;; scratch register.
4091(define_expand "reload_outdi"
4092  [(set (match_operand:DI 0 "non_hard_reg_operand" "")
4093	(match_operand:DI 1 "register_operand" "Z"))
4094   (clobber (match_operand:SI 2 "register_operand" "=&r"))]
4095  ""
4096  "
4097{
4098  if (pa_emit_move_sequence (operands, DImode, operands[2]))
4099    DONE;
4100
4101  /* We don't want the clobber emitted, so handle this ourselves.  */
4102  emit_insn (gen_rtx_SET (operands[0], operands[1]));
4103  DONE;
4104}")
4105
4106(define_insn ""
4107  [(set (match_operand:DI 0 "register_operand" "=r")
4108	(high:DI (match_operand 1 "" "")))]
4109  "!TARGET_64BIT"
4110  "*
4111{
4112  rtx op0 = operands[0];
4113  rtx op1 = operands[1];
4114
4115  switch (GET_CODE (op1))
4116    {
4117    case CONST_INT:
4118#if HOST_BITS_PER_WIDE_INT <= 32
4119      operands[0] = operand_subword (op0, 1, 0, DImode);
4120      output_asm_insn (\"ldil L'%1,%0\", operands);
4121
4122      operands[0] = operand_subword (op0, 0, 0, DImode);
4123      if (INTVAL (op1) < 0)
4124	output_asm_insn (\"ldi -1,%0\", operands);
4125      else
4126	output_asm_insn (\"ldi 0,%0\", operands);
4127#else
4128      operands[0] = operand_subword (op0, 1, 0, DImode);
4129      operands[1] = GEN_INT (INTVAL (op1) & 0xffffffff);
4130      output_asm_insn (\"ldil L'%1,%0\", operands);
4131
4132      operands[0] = operand_subword (op0, 0, 0, DImode);
4133      operands[1] = GEN_INT (INTVAL (op1) >> 32);
4134      output_asm_insn (pa_singlemove_string (operands), operands);
4135#endif
4136      break;
4137
4138    case CONST_DOUBLE:
4139      operands[0] = operand_subword (op0, 1, 0, DImode);
4140      operands[1] = GEN_INT (CONST_DOUBLE_LOW (op1));
4141      output_asm_insn (\"ldil L'%1,%0\", operands);
4142
4143      operands[0] = operand_subword (op0, 0, 0, DImode);
4144      operands[1] = GEN_INT (CONST_DOUBLE_HIGH (op1));
4145      output_asm_insn (pa_singlemove_string (operands), operands);
4146      break;
4147
4148    default:
4149      gcc_unreachable ();
4150    }
4151  return \"\";
4152}"
4153  [(set_attr "type" "move")
4154   (set_attr "length" "12")])
4155
4156(define_insn ""
4157  [(set (match_operand:DI 0 "move_dest_operand"
4158			  "=r,o,Q,r,r,r,*f,*f,T,?r,?*f")
4159	(match_operand:DI 1 "move_src_operand"
4160			  "rM,r,r,o*R,Q,i,*fM,RT,*f,*f,r"))]
4161  "(register_operand (operands[0], DImode)
4162    || reg_or_0_operand (operands[1], DImode))
4163   && !TARGET_64BIT
4164   && !TARGET_SOFT_FLOAT"
4165  "*
4166{
4167  if ((FP_REG_P (operands[0]) || FP_REG_P (operands[1])
4168       || operands[1] == CONST0_RTX (DFmode))
4169      && !(REG_P (operands[0]) && REG_P (operands[1])
4170	   && FP_REG_P (operands[0]) ^ FP_REG_P (operands[1])))
4171    return pa_output_fp_move_double (operands);
4172  return pa_output_move_double (operands);
4173}"
4174  [(set_attr "type"
4175    "move,store,store,load,load,multi,fpalu,fpload,fpstore,fpstore_load,store_fpload")
4176   (set_attr "length" "8,8,16,8,16,16,4,4,4,12,12")])
4177
4178(define_insn ""
4179  [(set (match_operand:DI 0 "move_dest_operand"
4180			  "=r,r,r,r,r,r,Q,!*q,!r,!*f,*f,T")
4181	(match_operand:DI 1 "move_src_operand"
4182			  "A,r,J,N,K,RQ,rM,!rM,!*q,!*fM,RT,*f"))]
4183  "(register_operand (operands[0], DImode)
4184    || reg_or_0_operand (operands[1], DImode))
4185   && !TARGET_SOFT_FLOAT && TARGET_64BIT"
4186  "@
4187   ldd RT'%A1,%0
4188   copy %1,%0
4189   ldi %1,%0
4190   ldil L'%1,%0
4191   depdi,z %z1,%0
4192   ldd%M1 %1,%0
4193   std%M0 %r1,%0
4194   mtsar %r1
4195   {mfctl|mfctl,w} %%sar,%0
4196   fcpy,dbl %f1,%0
4197   fldd%F1 %1,%0
4198   fstd%F0 %1,%0"
4199  [(set_attr "type" "load,move,move,move,shift,load,store,move,move,fpalu,fpload,fpstore")
4200   (set_attr "pa_combine_type" "addmove")
4201   (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4")])
4202
4203(define_insn ""
4204  [(set (match_operand:DI 0 "indexed_memory_operand" "=R")
4205	(match_operand:DI 1 "register_operand" "f"))]
4206  "!TARGET_SOFT_FLOAT
4207   && TARGET_64BIT
4208   && !TARGET_DISABLE_INDEXING
4209   && reload_completed"
4210  "fstd%F0 %1,%0"
4211  [(set_attr "type" "fpstore")
4212   (set_attr "pa_combine_type" "addmove")
4213   (set_attr "length" "4")])
4214
4215(define_peephole2
4216  [(set (match_operand:DI 0 "register_operand" "")
4217	(plus:DI (ashift:DI (match_operand:DI 1 "register_operand" "")
4218			    (const_int 3))
4219		 (match_operand:DI 2 "register_operand" "")))
4220   (set (mem:DI (match_dup 0))
4221        (match_operand:DI 3 "register_operand" ""))]
4222  "!TARGET_SOFT_FLOAT
4223   && !TARGET_DISABLE_INDEXING
4224   && TARGET_64BIT
4225   && REG_OK_FOR_BASE_P (operands[2])
4226   && FP_REGNO_P (REGNO (operands[3]))"
4227  [(set (mem:DI (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
4228	(match_dup 3))
4229   (set (match_dup 0) (plus:DI (ashift:DI (match_dup 1) (const_int 3))
4230			       (match_dup 2)))]
4231  "")
4232
4233(define_peephole2
4234  [(set (match_operand:DI 0 "register_operand" "")
4235	(plus:DI (match_operand:DI 1 "register_operand" "")
4236		 (match_operand:DI 2 "register_operand" "")))
4237   (set (mem:DI (match_dup 0))
4238        (match_operand:DI 3 "register_operand" ""))]
4239  "!TARGET_SOFT_FLOAT
4240   && !TARGET_DISABLE_INDEXING
4241   && TARGET_64BIT
4242   && TARGET_NO_SPACE_REGS
4243   && REG_OK_FOR_INDEX_P (operands[1])
4244   && REG_OK_FOR_BASE_P (operands[2])
4245   && FP_REGNO_P (REGNO (operands[3]))"
4246  [(set (mem:DI (plus:DI (match_dup 1) (match_dup 2)))
4247	(match_dup 3))
4248   (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
4249  "")
4250
4251(define_peephole2
4252  [(set (match_operand:DI 0 "register_operand" "")
4253	(plus:DI (match_operand:DI 1 "register_operand" "")
4254		 (match_operand:DI 2 "register_operand" "")))
4255   (set (mem:DI (match_dup 0))
4256        (match_operand:DI 3 "register_operand" ""))]
4257  "!TARGET_SOFT_FLOAT
4258   && !TARGET_DISABLE_INDEXING
4259   && TARGET_64BIT
4260   && TARGET_NO_SPACE_REGS
4261   && REG_OK_FOR_BASE_P (operands[1])
4262   && REG_OK_FOR_INDEX_P (operands[2])
4263   && FP_REGNO_P (REGNO (operands[3]))"
4264  [(set (mem:DI (plus:DI (match_dup 2) (match_dup 1)))
4265	(match_dup 3))
4266   (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
4267  "")
4268
4269(define_insn ""
4270  [(set (match_operand:DI 0 "move_dest_operand"
4271			  "=r,o,Q,r,r,r")
4272	(match_operand:DI 1 "general_operand"
4273			  "rM,r,r,o,Q,i"))]
4274  "(register_operand (operands[0], DImode)
4275    || reg_or_0_operand (operands[1], DImode))
4276   && !TARGET_64BIT
4277   && TARGET_SOFT_FLOAT"
4278  "*
4279{
4280  return pa_output_move_double (operands);
4281}"
4282  [(set_attr "type" "move,store,store,load,load,multi")
4283   (set_attr "length" "8,8,16,8,16,16")])
4284
4285(define_insn ""
4286  [(set (match_operand:DI 0 "register_operand" "=r,&r")
4287	(lo_sum:DI (match_operand:DI 1 "register_operand" "0,r")
4288		   (match_operand:DI 2 "immediate_operand" "i,i")))]
4289  "!TARGET_64BIT"
4290  "*
4291{
4292  /* Don't output a 64-bit constant, since we can't trust the assembler to
4293     handle it correctly.  */
4294  if (GET_CODE (operands[2]) == CONST_DOUBLE)
4295    operands[2] = GEN_INT (CONST_DOUBLE_LOW (operands[2]));
4296  else if (HOST_BITS_PER_WIDE_INT > 32
4297	   && GET_CODE (operands[2]) == CONST_INT)
4298    operands[2] = GEN_INT (INTVAL (operands[2]) & 0xffffffff);
4299  if (which_alternative == 1)
4300    output_asm_insn (\"copy %1,%0\", operands);
4301  return \"ldo R'%G2(%R1),%R0\";
4302}"
4303  [(set_attr "type" "move,move")
4304   (set_attr "length" "4,8")])
4305
4306(define_expand "movsf"
4307  [(set (match_operand:SF 0 "general_operand" "")
4308	(match_operand:SF 1 "general_operand" ""))]
4309  ""
4310  "
4311{
4312  if (pa_emit_move_sequence (operands, SFmode, 0))
4313    DONE;
4314}")
4315
4316;; Handle SFmode input reloads requiring %r1 as a scratch register.
4317(define_expand "reload_insf_r1"
4318  [(set (match_operand:SF 0 "register_operand" "=Z")
4319	(match_operand:SF 1 "non_hard_reg_operand" ""))
4320   (clobber (match_operand:SI 2 "register_operand" "=&a"))]
4321  ""
4322  "
4323{
4324  if (pa_emit_move_sequence (operands, SFmode, operands[2]))
4325    DONE;
4326
4327  /* We don't want the clobber emitted, so handle this ourselves.  */
4328  emit_insn (gen_rtx_SET (operands[0], operands[1]));
4329  DONE;
4330}")
4331
4332;; Handle SFmode input reloads requiring a general register as a
4333;; scratch register.
4334(define_expand "reload_insf"
4335  [(set (match_operand:SF 0 "register_operand" "=Z")
4336	(match_operand:SF 1 "non_hard_reg_operand" ""))
4337   (clobber (match_operand:SF 2 "register_operand" "=&r"))]
4338  ""
4339  "
4340{
4341  if (pa_emit_move_sequence (operands, SFmode, operands[2]))
4342    DONE;
4343
4344  /* We don't want the clobber emitted, so handle this ourselves.  */
4345  emit_insn (gen_rtx_SET (operands[0], operands[1]));
4346  DONE;
4347}")
4348
4349;; Handle SFmode output reloads requiring a general register as a
4350;; scratch register.
4351(define_expand "reload_outsf"
4352  [(set (match_operand:SF 0 "non_hard_reg_operand" "")
4353	(match_operand:SF 1  "register_operand" "Z"))
4354   (clobber (match_operand:SF 2 "register_operand" "=&r"))]
4355  ""
4356  "
4357{
4358  if (pa_emit_move_sequence (operands, SFmode, operands[2]))
4359    DONE;
4360
4361  /* We don't want the clobber emitted, so handle this ourselves.  */
4362  emit_insn (gen_rtx_SET (operands[0], operands[1]));
4363  DONE;
4364}")
4365
4366(define_insn ""
4367  [(set (match_operand:SF 0 "move_dest_operand"
4368			  "=f,!*r,f,*r,T,Q,?*r,?f")
4369	(match_operand:SF 1 "reg_or_0_or_nonsymb_mem_operand"
4370			  "fG,!*rG,RT,RQ,f,*rG,f,*r"))]
4371  "(register_operand (operands[0], SFmode)
4372    || reg_or_0_operand (operands[1], SFmode))
4373   && !TARGET_SOFT_FLOAT
4374   && !TARGET_64BIT"
4375  "@
4376   fcpy,sgl %f1,%0
4377   copy %r1,%0
4378   fldw%F1 %1,%0
4379   ldw%M1 %1,%0
4380   fstw%F0 %1,%0
4381   stw%M0 %r1,%0
4382   {fstws|fstw} %1,-16(%%sp)\n\t{ldws|ldw} -16(%%sp),%0
4383   {stws|stw} %1,-16(%%sp)\n\t{fldws|fldw} -16(%%sp),%0"
4384  [(set_attr "type" "fpalu,move,fpload,load,fpstore,store,fpstore_load,store_fpload")
4385   (set_attr "pa_combine_type" "addmove")
4386   (set_attr "length" "4,4,4,4,4,4,8,8")])
4387
4388(define_insn ""
4389  [(set (match_operand:SF 0 "move_dest_operand"
4390			  "=f,!*r,f,*r,T,Q")
4391	(match_operand:SF 1 "reg_or_0_or_nonsymb_mem_operand"
4392			  "fG,!*rG,RT,RQ,f,*rG"))]
4393  "(register_operand (operands[0], SFmode)
4394    || reg_or_0_operand (operands[1], SFmode))
4395   && !TARGET_SOFT_FLOAT
4396   && TARGET_64BIT"
4397  "@
4398   fcpy,sgl %f1,%0
4399   copy %r1,%0
4400   fldw%F1 %1,%0
4401   ldw%M1 %1,%0
4402   fstw%F0 %1,%0
4403   stw%M0 %r1,%0"
4404  [(set_attr "type" "fpalu,move,fpload,load,fpstore,store")
4405   (set_attr "pa_combine_type" "addmove")
4406   (set_attr "length" "4,4,4,4,4,4")])
4407
4408(define_insn ""
4409  [(set (match_operand:SF 0 "indexed_memory_operand" "=R")
4410	(match_operand:SF 1 "register_operand" "f"))]
4411  "!TARGET_SOFT_FLOAT
4412   && !TARGET_DISABLE_INDEXING
4413   && reload_completed"
4414  "fstw%F0 %1,%0"
4415  [(set_attr "type" "fpstore")
4416   (set_attr "pa_combine_type" "addmove")
4417   (set_attr "length" "4")])
4418
4419(define_peephole2
4420  [(set (match_operand:SI 0 "register_operand" "")
4421	(plus:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
4422			    (const_int 2))
4423		 (match_operand:SI 2 "register_operand" "")))
4424   (set (mem:SF (match_dup 0))
4425        (match_operand:SF 3 "register_operand" ""))]
4426  "!TARGET_SOFT_FLOAT
4427   && !TARGET_DISABLE_INDEXING
4428   && REG_OK_FOR_BASE_P (operands[2])
4429   && FP_REGNO_P (REGNO (operands[3]))"
4430  [(set (mem:SF (plus:SI (mult:SI (match_dup 1) (const_int 4)) (match_dup 2)))
4431	(match_dup 3))
4432   (set (match_dup 0) (plus:SI (ashift:SI (match_dup 1) (const_int 2))
4433			       (match_dup 2)))]
4434  "")
4435
4436(define_peephole2
4437  [(set (match_operand:DI 0 "register_operand" "")
4438	(plus:DI (ashift:DI (match_operand:DI 1 "register_operand" "")
4439			    (const_int 2))
4440		 (match_operand:DI 2 "register_operand" "")))
4441   (set (mem:SF (match_dup 0))
4442        (match_operand:SF 3 "register_operand" ""))]
4443  "!TARGET_SOFT_FLOAT
4444   && !TARGET_DISABLE_INDEXING
4445   && TARGET_64BIT
4446   && REG_OK_FOR_BASE_P (operands[2])
4447   && FP_REGNO_P (REGNO (operands[3]))"
4448  [(set (mem:SF (plus:DI (mult:DI (match_dup 1) (const_int 4)) (match_dup 2)))
4449	(match_dup 3))
4450   (set (match_dup 0) (plus:DI (ashift:DI (match_dup 1) (const_int 2))
4451			       (match_dup 2)))]
4452  "")
4453
4454(define_peephole2
4455  [(set (match_operand:SI 0 "register_operand" "")
4456	(plus:SI (match_operand:SI 1 "register_operand" "")
4457		 (match_operand:SI 2 "register_operand" "")))
4458   (set (mem:SF (match_dup 0))
4459        (match_operand:SF 3 "register_operand" ""))]
4460  "!TARGET_SOFT_FLOAT
4461   && !TARGET_DISABLE_INDEXING
4462   && TARGET_NO_SPACE_REGS
4463   && REG_OK_FOR_INDEX_P (operands[1])
4464   && REG_OK_FOR_BASE_P (operands[2])
4465   && FP_REGNO_P (REGNO (operands[3]))"
4466  [(set (mem:SF (plus:SI (match_dup 1) (match_dup 2)))
4467	(match_dup 3))
4468   (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
4469  "")
4470
4471(define_peephole2
4472  [(set (match_operand:SI 0 "register_operand" "")
4473	(plus:SI (match_operand:SI 1 "register_operand" "")
4474		 (match_operand:SI 2 "register_operand" "")))
4475   (set (mem:SF (match_dup 0))
4476        (match_operand:SF 3 "register_operand" ""))]
4477  "!TARGET_SOFT_FLOAT
4478   && !TARGET_DISABLE_INDEXING
4479   && TARGET_NO_SPACE_REGS
4480   && REG_OK_FOR_BASE_P (operands[1])
4481   && REG_OK_FOR_INDEX_P (operands[2])
4482   && FP_REGNO_P (REGNO (operands[3]))"
4483  [(set (mem:SF (plus:SI (match_dup 2) (match_dup 1)))
4484	(match_dup 3))
4485   (set (match_dup 0) (plus:SI (match_dup 2) (match_dup 1)))]
4486  "")
4487
4488(define_peephole2
4489  [(set (match_operand:DI 0 "register_operand" "")
4490	(plus:DI (match_operand:DI 1 "register_operand" "")
4491		 (match_operand:DI 2 "register_operand" "")))
4492   (set (mem:SF (match_dup 0))
4493        (match_operand:SF 3 "register_operand" ""))]
4494  "!TARGET_SOFT_FLOAT
4495   && !TARGET_DISABLE_INDEXING
4496   && TARGET_64BIT
4497   && TARGET_NO_SPACE_REGS
4498   && REG_OK_FOR_INDEX_P (operands[1])
4499   && REG_OK_FOR_BASE_P (operands[2])
4500   && FP_REGNO_P (REGNO (operands[3]))"
4501  [(set (mem:SF (plus:DI (match_dup 1) (match_dup 2)))
4502	(match_dup 3))
4503   (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
4504  "")
4505
4506(define_peephole2
4507  [(set (match_operand:DI 0 "register_operand" "")
4508	(plus:DI (match_operand:DI 1 "register_operand" "")
4509		 (match_operand:DI 2 "register_operand" "")))
4510   (set (mem:SF (match_dup 0))
4511        (match_operand:SF 3 "register_operand" ""))]
4512  "!TARGET_SOFT_FLOAT
4513   && !TARGET_DISABLE_INDEXING
4514   && TARGET_64BIT
4515   && TARGET_NO_SPACE_REGS
4516   && REG_OK_FOR_BASE_P (operands[1])
4517   && REG_OK_FOR_INDEX_P (operands[2])
4518   && FP_REGNO_P (REGNO (operands[3]))"
4519  [(set (mem:SF (plus:DI (match_dup 2) (match_dup 1)))
4520	(match_dup 3))
4521   (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
4522  "")
4523
4524(define_insn ""
4525  [(set (match_operand:SF 0 "move_dest_operand"
4526			  "=r,r,Q")
4527	(match_operand:SF 1 "reg_or_0_or_nonsymb_mem_operand"
4528			  "rG,RQ,rG"))]
4529  "(register_operand (operands[0], SFmode)
4530    || reg_or_0_operand (operands[1], SFmode))
4531   && TARGET_SOFT_FLOAT"
4532  "@
4533   copy %r1,%0
4534   ldw%M1 %1,%0
4535   stw%M0 %r1,%0"
4536  [(set_attr "type" "move,load,store")
4537   (set_attr "pa_combine_type" "addmove")
4538   (set_attr "length" "4,4,4")])
4539
4540
4541
4542;;- zero extension instructions
4543;; We have define_expand for zero extension patterns to make sure the
4544;; operands get loaded into registers.  The define_insns accept
4545;; memory operands.  This gives us better overall code than just
4546;; having a pattern that does or does not accept memory operands.
4547
4548(define_expand "zero_extendqihi2"
4549  [(set (match_operand:HI 0 "register_operand" "")
4550	(zero_extend:HI
4551	 (match_operand:QI 1 "register_operand" "")))]
4552  ""
4553  "")
4554
4555(define_insn ""
4556  [(set (match_operand:HI 0 "register_operand" "=r,r")
4557	(zero_extend:HI
4558	 (match_operand:QI 1 "move_src_operand" "r,RQ")))]
4559  "GET_CODE (operands[1]) != CONST_INT"
4560  "@
4561   {extru|extrw,u} %1,31,8,%0
4562   ldb%M1 %1,%0"
4563  [(set_attr "type" "shift,load")
4564   (set_attr "length" "4,4")])
4565
4566(define_expand "zero_extendqisi2"
4567  [(set (match_operand:SI 0 "register_operand" "")
4568	(zero_extend:SI
4569	 (match_operand:QI 1 "register_operand" "")))]
4570  ""
4571  "")
4572
4573(define_insn ""
4574  [(set (match_operand:SI 0 "register_operand" "=r,r")
4575	(zero_extend:SI
4576	 (match_operand:QI 1 "move_src_operand" "r,RQ")))]
4577  "GET_CODE (operands[1]) != CONST_INT"
4578  "@
4579   {extru|extrw,u} %1,31,8,%0
4580   ldb%M1 %1,%0"
4581  [(set_attr "type" "shift,load")
4582   (set_attr "length" "4,4")])
4583
4584(define_expand "zero_extendhisi2"
4585  [(set (match_operand:SI 0 "register_operand" "")
4586	(zero_extend:SI
4587	 (match_operand:HI 1 "register_operand" "")))]
4588  ""
4589  "")
4590
4591(define_insn ""
4592  [(set (match_operand:SI 0 "register_operand" "=r,r")
4593	(zero_extend:SI
4594	 (match_operand:HI 1 "move_src_operand" "r,RQ")))]
4595  "GET_CODE (operands[1]) != CONST_INT"
4596  "@
4597   {extru|extrw,u} %1,31,16,%0
4598   ldh%M1 %1,%0"
4599  [(set_attr "type" "shift,load")
4600   (set_attr "length" "4,4")])
4601
4602(define_expand "zero_extendqidi2"
4603  [(set (match_operand:DI 0 "register_operand" "")
4604	(zero_extend:DI
4605	 (match_operand:QI 1 "register_operand" "")))]
4606  "TARGET_64BIT"
4607  "")
4608
4609(define_insn ""
4610  [(set (match_operand:DI 0 "register_operand" "=r,r")
4611	(zero_extend:DI
4612	 (match_operand:QI 1 "move_src_operand" "r,RQ")))]
4613  "TARGET_64BIT && GET_CODE (operands[1]) != CONST_INT"
4614  "@
4615   extrd,u %1,63,8,%0
4616   ldb%M1 %1,%0"
4617  [(set_attr "type" "shift,load")
4618   (set_attr "length" "4,4")])
4619
4620(define_expand "zero_extendhidi2"
4621  [(set (match_operand:DI 0 "register_operand" "")
4622	(zero_extend:DI
4623	 (match_operand:HI 1 "register_operand" "")))]
4624  "TARGET_64BIT"
4625  "")
4626
4627(define_insn ""
4628  [(set (match_operand:DI 0 "register_operand" "=r,r")
4629	(zero_extend:DI
4630	 (match_operand:HI 1 "move_src_operand" "r,RQ")))]
4631  "TARGET_64BIT && GET_CODE (operands[1]) != CONST_INT"
4632  "@
4633   extrd,u %1,63,16,%0
4634   ldh%M1 %1,%0"
4635  [(set_attr "type" "shift,load")
4636   (set_attr "length" "4,4")])
4637
4638(define_expand "zero_extendsidi2"
4639  [(set (match_operand:DI 0 "register_operand" "")
4640	(zero_extend:DI
4641	 (match_operand:SI 1 "register_operand" "")))]
4642  "TARGET_64BIT"
4643  "")
4644
4645(define_insn ""
4646  [(set (match_operand:DI 0 "register_operand" "=r,r")
4647	(zero_extend:DI
4648	 (match_operand:SI 1 "move_src_operand" "r,RQ")))]
4649  "TARGET_64BIT && GET_CODE (operands[1]) != CONST_INT"
4650  "@
4651   extrd,u %1,63,32,%0
4652   ldw%M1 %1,%0"
4653  [(set_attr "type" "shift,load")
4654   (set_attr "length" "4,4")])
4655
4656;;- sign extension instructions
4657
4658(define_insn "extendhisi2"
4659  [(set (match_operand:SI 0 "register_operand" "=r")
4660	(sign_extend:SI (match_operand:HI 1 "register_operand" "r")))]
4661  ""
4662  "{extrs|extrw,s} %1,31,16,%0"
4663  [(set_attr "type" "shift")
4664   (set_attr "length" "4")])
4665
4666(define_insn "extendqihi2"
4667  [(set (match_operand:HI 0 "register_operand" "=r")
4668	(sign_extend:HI (match_operand:QI 1 "register_operand" "r")))]
4669  ""
4670  "{extrs|extrw,s} %1,31,8,%0"
4671  [(set_attr "type" "shift")
4672  (set_attr "length" "4")])
4673
4674(define_insn "extendqisi2"
4675  [(set (match_operand:SI 0 "register_operand" "=r")
4676	(sign_extend:SI (match_operand:QI 1 "register_operand" "r")))]
4677  ""
4678  "{extrs|extrw,s} %1,31,8,%0"
4679  [(set_attr "type" "shift")
4680   (set_attr "length" "4")])
4681
4682(define_insn "extendqidi2"
4683  [(set (match_operand:DI 0 "register_operand" "=r")
4684	(sign_extend:DI (match_operand:QI 1 "register_operand" "r")))]
4685  "TARGET_64BIT"
4686  "extrd,s %1,63,8,%0"
4687  [(set_attr "type" "shift")
4688  (set_attr "length" "4")])
4689
4690(define_insn "extendhidi2"
4691  [(set (match_operand:DI 0 "register_operand" "=r")
4692	(sign_extend:DI (match_operand:HI 1 "register_operand" "r")))]
4693  "TARGET_64BIT"
4694  "extrd,s %1,63,16,%0"
4695  [(set_attr "type" "shift")
4696  (set_attr "length" "4")])
4697
4698(define_insn "extendsidi2"
4699  [(set (match_operand:DI 0 "register_operand" "=r")
4700	(sign_extend:DI (match_operand:SI 1 "register_operand" "r")))]
4701  "TARGET_64BIT"
4702  "extrd,s %1,63,32,%0"
4703  [(set_attr "type" "shift")
4704  (set_attr "length" "4")])
4705
4706
4707;; Conversions between float and double.
4708
4709(define_insn "extendsfdf2"
4710  [(set (match_operand:DF 0 "register_operand" "=f")
4711	(float_extend:DF
4712	 (match_operand:SF 1 "register_operand" "f")))]
4713  "! TARGET_SOFT_FLOAT"
4714  "{fcnvff|fcnv},sgl,dbl %1,%0"
4715  [(set_attr "type" "fpalu")
4716   (set_attr "length" "4")])
4717
4718(define_insn "truncdfsf2"
4719  [(set (match_operand:SF 0 "register_operand" "=f")
4720	(float_truncate:SF
4721	 (match_operand:DF 1 "register_operand" "f")))]
4722  "! TARGET_SOFT_FLOAT"
4723  "{fcnvff|fcnv},dbl,sgl %1,%0"
4724  [(set_attr "type" "fpalu")
4725   (set_attr "length" "4")])
4726
4727;; Conversion between fixed point and floating point.
4728;; Note that among the fix-to-float insns
4729;; the ones that start with SImode come first.
4730;; That is so that an operand that is a CONST_INT
4731;; (and therefore lacks a specific machine mode).
4732;; will be recognized as SImode (which is always valid)
4733;; rather than as QImode or HImode.
4734
4735;; This pattern forces (set (reg:SF ...) (float:SF (const_int ...)))
4736;; to be reloaded by putting the constant into memory.
4737;; It must come before the more general floatsisf2 pattern.
4738(define_insn ""
4739  [(set (match_operand:SF 0 "register_operand" "=f")
4740	(float:SF (match_operand:SI 1 "const_int_operand" "m")))]
4741  "! TARGET_SOFT_FLOAT"
4742  "fldw%F1 %1,%0\;{fcnvxf,sgl,sgl|fcnv,w,sgl} %0,%0"
4743  [(set_attr "type" "fpalu")
4744   (set_attr "length" "8")])
4745
4746(define_insn "floatsisf2"
4747  [(set (match_operand:SF 0 "register_operand" "=f")
4748	(float:SF (match_operand:SI 1 "register_operand" "f")))]
4749  "! TARGET_SOFT_FLOAT"
4750  "{fcnvxf,sgl,sgl|fcnv,w,sgl} %1,%0"
4751  [(set_attr "type" "fpalu")
4752   (set_attr "length" "4")])
4753
4754;; This pattern forces (set (reg:DF ...) (float:DF (const_int ...)))
4755;; to be reloaded by putting the constant into memory.
4756;; It must come before the more general floatsidf2 pattern.
4757(define_insn ""
4758  [(set (match_operand:DF 0 "register_operand" "=f")
4759	(float:DF (match_operand:SI 1 "const_int_operand" "m")))]
4760  "! TARGET_SOFT_FLOAT"
4761  "fldw%F1 %1,%0\;{fcnvxf,sgl,dbl|fcnv,w,dbl} %0,%0"
4762  [(set_attr "type" "fpalu")
4763   (set_attr "length" "8")])
4764
4765(define_insn "floatsidf2"
4766  [(set (match_operand:DF 0 "register_operand" "=f")
4767	(float:DF (match_operand:SI 1 "register_operand" "f")))]
4768  "! TARGET_SOFT_FLOAT"
4769  "{fcnvxf,sgl,dbl|fcnv,w,dbl} %1,%0"
4770  [(set_attr "type" "fpalu")
4771   (set_attr "length" "4")])
4772
4773(define_expand "floatunssisf2"
4774  [(set (subreg:SI (match_dup 2) 4)
4775	(match_operand:SI 1 "register_operand" ""))
4776   (set (subreg:SI (match_dup 2) 0)
4777	(const_int 0))
4778   (set (match_operand:SF 0 "register_operand" "")
4779	(float:SF (match_dup 2)))]
4780  "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4781  "
4782{
4783  if (TARGET_PA_20)
4784    {
4785      emit_insn (gen_floatunssisf2_pa20 (operands[0], operands[1]));
4786      DONE;
4787    }
4788  operands[2] = gen_reg_rtx (DImode);
4789}")
4790
4791(define_expand "floatunssidf2"
4792  [(set (subreg:SI (match_dup 2) 4)
4793	(match_operand:SI 1 "register_operand" ""))
4794   (set (subreg:SI (match_dup 2) 0)
4795	(const_int 0))
4796   (set (match_operand:DF 0 "register_operand" "")
4797	(float:DF (match_dup 2)))]
4798  "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4799  "
4800{
4801  if (TARGET_PA_20)
4802    {
4803      emit_insn (gen_floatunssidf2_pa20 (operands[0], operands[1]));
4804      DONE;
4805    }
4806  operands[2] = gen_reg_rtx (DImode);
4807}")
4808
4809(define_insn "floatdisf2"
4810  [(set (match_operand:SF 0 "register_operand" "=f")
4811	(float:SF (match_operand:DI 1 "register_operand" "f")))]
4812  "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4813  "{fcnvxf,dbl,sgl|fcnv,dw,sgl} %1,%0"
4814  [(set_attr "type" "fpalu")
4815   (set_attr "length" "4")])
4816
4817(define_insn "floatdidf2"
4818  [(set (match_operand:DF 0 "register_operand" "=f")
4819	(float:DF (match_operand:DI 1 "register_operand" "f")))]
4820  "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4821  "{fcnvxf,dbl,dbl|fcnv,dw,dbl} %1,%0"
4822  [(set_attr "type" "fpalu")
4823   (set_attr "length" "4")])
4824
4825;; Convert a float to an actual integer.
4826;; Truncation is performed as part of the conversion.
4827
4828(define_insn "fix_truncsfsi2"
4829  [(set (match_operand:SI 0 "register_operand" "=f")
4830	(fix:SI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
4831  "! TARGET_SOFT_FLOAT"
4832  "{fcnvfxt,sgl,sgl|fcnv,t,sgl,w} %1,%0"
4833  [(set_attr "type" "fpalu")
4834   (set_attr "length" "4")])
4835
4836(define_insn "fix_truncdfsi2"
4837  [(set (match_operand:SI 0 "register_operand" "=f")
4838	(fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
4839  "! TARGET_SOFT_FLOAT"
4840  "{fcnvfxt,dbl,sgl|fcnv,t,dbl,w} %1,%0"
4841  [(set_attr "type" "fpalu")
4842   (set_attr "length" "4")])
4843
4844(define_insn "fix_truncsfdi2"
4845  [(set (match_operand:DI 0 "register_operand" "=f")
4846	(fix:DI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
4847  "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4848  "{fcnvfxt,sgl,dbl|fcnv,t,sgl,dw} %1,%0"
4849  [(set_attr "type" "fpalu")
4850   (set_attr "length" "4")])
4851
4852(define_insn "fix_truncdfdi2"
4853  [(set (match_operand:DI 0 "register_operand" "=f")
4854	(fix:DI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
4855  "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4856  "{fcnvfxt,dbl,dbl|fcnv,t,dbl,dw} %1,%0"
4857  [(set_attr "type" "fpalu")
4858   (set_attr "length" "4")])
4859
4860(define_insn "floatunssidf2_pa20"
4861  [(set (match_operand:DF 0 "register_operand" "=f")
4862	(unsigned_float:DF (match_operand:SI 1 "register_operand" "f")))]
4863  "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4864  "fcnv,uw,dbl %1,%0"
4865  [(set_attr "type" "fpalu")
4866   (set_attr "length" "4")])
4867
4868(define_insn "floatunssisf2_pa20"
4869  [(set (match_operand:SF 0 "register_operand" "=f")
4870	(unsigned_float:SF (match_operand:SI 1 "register_operand" "f")))]
4871  "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4872  "fcnv,uw,sgl %1,%0"
4873  [(set_attr "type" "fpalu")
4874   (set_attr "length" "4")])
4875
4876(define_insn "floatunsdisf2"
4877  [(set (match_operand:SF 0 "register_operand" "=f")
4878	(unsigned_float:SF (match_operand:DI 1 "register_operand" "f")))]
4879  "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4880  "fcnv,udw,sgl %1,%0"
4881  [(set_attr "type" "fpalu")
4882   (set_attr "length" "4")])
4883
4884(define_insn "floatunsdidf2"
4885  [(set (match_operand:DF 0 "register_operand" "=f")
4886	(unsigned_float:DF (match_operand:DI 1 "register_operand" "f")))]
4887  "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4888  "fcnv,udw,dbl %1,%0"
4889  [(set_attr "type" "fpalu")
4890   (set_attr "length" "4")])
4891
4892(define_insn "fixuns_truncsfsi2"
4893  [(set (match_operand:SI 0 "register_operand" "=f")
4894	(unsigned_fix:SI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
4895  "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4896  "fcnv,t,sgl,uw %1,%0"
4897  [(set_attr "type" "fpalu")
4898   (set_attr "length" "4")])
4899
4900(define_insn "fixuns_truncdfsi2"
4901  [(set (match_operand:SI 0 "register_operand" "=f")
4902	(unsigned_fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
4903  "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4904  "fcnv,t,dbl,uw %1,%0"
4905  [(set_attr "type" "fpalu")
4906   (set_attr "length" "4")])
4907
4908(define_insn "fixuns_truncsfdi2"
4909  [(set (match_operand:DI 0 "register_operand" "=f")
4910	(unsigned_fix:DI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
4911  "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4912  "fcnv,t,sgl,udw %1,%0"
4913  [(set_attr "type" "fpalu")
4914   (set_attr "length" "4")])
4915
4916(define_insn "fixuns_truncdfdi2"
4917  [(set (match_operand:DI 0 "register_operand" "=f")
4918	(unsigned_fix:DI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
4919  "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4920  "fcnv,t,dbl,udw %1,%0"
4921  [(set_attr "type" "fpalu")
4922   (set_attr "length" "4")])
4923
4924;;- arithmetic instructions
4925
4926(define_expand "adddi3"
4927  [(set (match_operand:DI 0 "register_operand" "")
4928	(plus:DI (match_operand:DI 1 "register_operand" "")
4929		 (match_operand:DI 2 "adddi3_operand" "")))]
4930  ""
4931  "")
4932
4933(define_insn ""
4934  [(set (match_operand:DI 0 "register_operand" "=r")
4935	(plus:DI (match_operand:DI 1 "register_operand" "%r")
4936		 (match_operand:DI 2 "arith11_operand" "rI")))]
4937  "!TARGET_64BIT"
4938  "*
4939{
4940  if (GET_CODE (operands[2]) == CONST_INT)
4941    {
4942      if (INTVAL (operands[2]) >= 0)
4943	return \"addi %2,%R1,%R0\;{addc|add,c} %1,%%r0,%0\";
4944      else
4945	return \"addi %2,%R1,%R0\;{subb|sub,b} %1,%%r0,%0\";
4946    }
4947  else
4948    return \"add %R2,%R1,%R0\;{addc|add,c} %2,%1,%0\";
4949}"
4950  [(set_attr "type" "binary")
4951   (set_attr "length" "8")])
4952
4953(define_insn ""
4954  [(set (match_operand:DI 0 "register_operand" "=r,r")
4955	(plus:DI (match_operand:DI 1 "register_operand" "%r,r")
4956		 (match_operand:DI 2 "arith14_operand" "r,J")))]
4957  "TARGET_64BIT"
4958  "@
4959   add,l %1,%2,%0
4960   ldo %2(%1),%0"
4961  [(set_attr "type" "binary,binary")
4962   (set_attr "pa_combine_type" "addmove")
4963   (set_attr "length" "4,4")])
4964
4965(define_insn ""
4966  [(set (match_operand:DI 0 "register_operand" "=r")
4967	(plus:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
4968		 (match_operand:DI 2 "register_operand" "r")))]
4969  "TARGET_64BIT"
4970  "uaddcm %2,%1,%0"
4971  [(set_attr "type" "binary")
4972   (set_attr "length" "4")])
4973
4974(define_insn ""
4975  [(set (match_operand:SI 0 "register_operand" "=r")
4976	(plus:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
4977		 (match_operand:SI 2 "register_operand" "r")))]
4978  ""
4979  "uaddcm %2,%1,%0"
4980  [(set_attr "type" "binary")
4981   (set_attr "length" "4")])
4982
4983(define_expand "addvdi3"
4984  [(parallel [(set (match_operand:DI 0 "register_operand" "")
4985		   (plus:DI (match_operand:DI 1 "reg_or_0_operand" "")
4986			    (match_operand:DI 2 "arith11_operand" "")))
4987	      (trap_if (ne (plus:TI (sign_extend:TI (match_dup 1))
4988				    (sign_extend:TI (match_dup 2)))
4989			   (sign_extend:TI (plus:DI (match_dup 1)
4990						    (match_dup 2))))
4991		       (const_int 0))])]
4992  ""
4993  "")
4994
4995(define_insn ""
4996  [(set (match_operand:DI 0 "register_operand" "=r,r")
4997	(plus:DI (match_operand:DI 1 "reg_or_0_operand" "%rM,rM")
4998		 (match_operand:DI 2 "arith11_operand" "r,I")))
4999   (trap_if (ne (plus:TI (sign_extend:TI (match_dup 1))
5000			 (sign_extend:TI (match_dup 2)))
5001		(sign_extend:TI (plus:DI (match_dup 1)
5002					 (match_dup 2))))
5003	    (const_int 0))]
5004  "TARGET_64BIT"
5005  "@
5006  add,tsv,* %2,%1,%0
5007  addi,tsv,* %2,%1,%0"
5008  [(set_attr "type" "binary,binary")
5009   (set_attr "length" "4,4")])
5010
5011(define_insn ""
5012  [(set (match_operand:DI 0 "register_operand" "=r")
5013	(plus:DI (match_operand:DI 1 "reg_or_0_operand" "%rM")
5014		 (match_operand:DI 2 "arith11_operand" "rI")))
5015   (trap_if (ne (plus:TI (sign_extend:TI (match_dup 1))
5016			 (sign_extend:TI (match_dup 2)))
5017		(sign_extend:TI (plus:DI (match_dup 1)
5018					 (match_dup 2))))
5019	    (const_int 0))]
5020  "!TARGET_64BIT"
5021  "*
5022{
5023  if (GET_CODE (operands[2]) == CONST_INT)
5024    {
5025      if (INTVAL (operands[2]) >= 0)
5026	return \"addi %2,%R1,%R0\;{addco|add,c,tsv} %1,%%r0,%0\";
5027      else
5028	return \"addi %2,%R1,%R0\;{subbo|sub,b,tsv} %1,%%r0,%0\";
5029    }
5030  else
5031    return \"add %R2,%R1,%R0\;{addco|add,c,tsv} %2,%1,%0\";
5032}"
5033  [(set_attr "type" "binary")
5034   (set_attr "length" "8")])
5035
5036;; define_splits to optimize cases of adding a constant integer
5037;; to a register when the constant does not fit in 14 bits.  */
5038(define_split
5039  [(set (match_operand:SI 0 "register_operand" "")
5040	(plus:SI (match_operand:SI 1 "register_operand" "")
5041		 (match_operand:SI 2 "const_int_operand" "")))
5042   (clobber (match_operand:SI 4 "register_operand" ""))]
5043  "! pa_cint_ok_for_move (UINTVAL (operands[2]))
5044   && VAL_14_BITS_P (INTVAL (operands[2]) >> 1)"
5045  [(set (match_dup 4) (plus:SI (match_dup 1) (match_dup 2)))
5046   (set (match_dup 0) (plus:SI (match_dup 4) (match_dup 3)))]
5047  "
5048{
5049  int val = INTVAL (operands[2]);
5050  int low = (val < 0) ? -0x2000 : 0x1fff;
5051  int rest = val - low;
5052
5053  operands[2] = GEN_INT (rest);
5054  operands[3] = GEN_INT (low);
5055}")
5056
5057(define_split
5058  [(set (match_operand:SI 0 "register_operand" "")
5059	(plus:SI (match_operand:SI 1 "register_operand" "")
5060		 (match_operand:SI 2 "const_int_operand" "")))
5061   (clobber (match_operand:SI 4 "register_operand" ""))]
5062  "! pa_cint_ok_for_move (UINTVAL (operands[2]))"
5063  [(set (match_dup 4) (match_dup 2))
5064   (set (match_dup 0) (plus:SI (ashift:SI (match_dup 4) (match_dup 3))
5065			       (match_dup 1)))]
5066  "
5067{
5068  unsigned HOST_WIDE_INT intval = UINTVAL (operands[2]);
5069
5070  /* Try dividing the constant by 2, then 4, and finally 8 to see
5071     if we can get a constant which can be loaded into a register
5072     in a single instruction (pa_cint_ok_for_move).
5073
5074     If that fails, try to negate the constant and subtract it
5075     from our input operand.  */
5076  if (intval % 2 == 0 && pa_cint_ok_for_move (intval / 2))
5077    {
5078      operands[2] = GEN_INT (intval / 2);
5079      operands[3] = const1_rtx;
5080    }
5081  else if (intval % 4 == 0 && pa_cint_ok_for_move (intval / 4))
5082    {
5083      operands[2] = GEN_INT (intval / 4);
5084      operands[3] = const2_rtx;
5085    }
5086  else if (intval % 8 == 0 && pa_cint_ok_for_move (intval / 8))
5087    {
5088      operands[2] = GEN_INT (intval / 8);
5089      operands[3] = GEN_INT (3);
5090    }
5091  else if (pa_cint_ok_for_move (-intval))
5092    {
5093      emit_insn (gen_rtx_SET (operands[4], GEN_INT (-intval)));
5094      emit_insn (gen_subsi3 (operands[0], operands[1], operands[4]));
5095      DONE;
5096    }
5097  else
5098    FAIL;
5099}")
5100
5101(define_insn "addsi3"
5102  [(set (match_operand:SI 0 "register_operand" "=r,r")
5103	(plus:SI (match_operand:SI 1 "register_operand" "%r,r")
5104		 (match_operand:SI 2 "arith14_operand" "r,J")))]
5105  ""
5106  "@
5107   {addl|add,l} %1,%2,%0
5108   ldo %2(%1),%0"
5109  [(set_attr "type" "binary,binary")
5110   (set_attr "pa_combine_type" "addmove")
5111   (set_attr "length" "4,4")])
5112
5113(define_insn "addvsi3"
5114  [(set (match_operand:SI 0 "register_operand" "=r,r")
5115	(plus:SI (match_operand:SI 1 "reg_or_0_operand" "%rM,rM")
5116		 (match_operand:SI 2 "arith11_operand" "r,I")))
5117   (trap_if (ne (plus:DI (sign_extend:DI (match_dup 1))
5118			 (sign_extend:DI (match_dup 2)))
5119		(sign_extend:DI (plus:SI (match_dup 1)
5120					 (match_dup 2))))
5121	    (const_int 0))]
5122  ""
5123  "@
5124  {addo|add,tsv} %2,%1,%0
5125  {addio|addi,tsv} %2,%1,%0"
5126  [(set_attr "type" "binary,binary")
5127   (set_attr "length" "4,4")])
5128
5129(define_expand "subdi3"
5130  [(set (match_operand:DI 0 "register_operand" "")
5131	(minus:DI (match_operand:DI 1 "arith11_operand" "")
5132		  (match_operand:DI 2 "reg_or_0_operand" "")))]
5133  ""
5134  "")
5135
5136(define_insn ""
5137  [(set (match_operand:DI 0 "register_operand" "=r,r,!q")
5138	(minus:DI (match_operand:DI 1 "arith11_operand" "r,I,!U")
5139		  (match_operand:DI 2 "reg_or_0_operand" "rM,rM,!rM")))]
5140  "TARGET_64BIT"
5141  "@
5142   sub %1,%2,%0
5143   subi %1,%2,%0
5144   mtsarcm %2"
5145  [(set_attr "type" "binary,binary,move")
5146  (set_attr "length" "4,4,4")])
5147
5148(define_insn ""
5149  [(set (match_operand:DI 0 "register_operand" "=r,&r")
5150	(minus:DI (match_operand:DI 1 "arith11_operand" "r,I")
5151		  (match_operand:DI 2 "reg_or_0_operand" "rM,rM")))]
5152  "!TARGET_64BIT"
5153  "*
5154{
5155  if (GET_CODE (operands[1]) == CONST_INT)
5156    {
5157      if (INTVAL (operands[1]) >= 0)
5158	return \"subi %1,%R2,%R0\;{subb|sub,b} %%r0,%2,%0\";
5159      else
5160	return \"ldi -1,%0\;subi %1,%R2,%R0\;{subb|sub,b} %0,%2,%0\";
5161    }
5162  else
5163    return \"sub %R1,%R2,%R0\;{subb|sub,b} %1,%2,%0\";
5164}"
5165  [(set_attr "type" "binary")
5166   (set (attr "length")
5167	(if_then_else (eq_attr "alternative" "0")
5168	  (const_int 8)
5169	  (if_then_else (ge (symbol_ref "INTVAL (operands[1])")
5170			    (const_int 0))
5171	    (const_int 8)
5172	    (const_int 12))))])
5173
5174(define_expand "subvdi3"
5175  [(parallel [(set (match_operand:DI 0 "register_operand" "")
5176		   (minus:DI (match_operand:DI 1 "arith11_operand" "")
5177			     (match_operand:DI 2 "reg_or_0_operand" "")))
5178	      (trap_if (ne (minus:TI (sign_extend:TI (match_dup 1))
5179				     (sign_extend:TI (match_dup 2)))
5180			   (sign_extend:TI (minus:DI (match_dup 1)
5181						     (match_dup 2))))
5182		       (const_int 0))])]
5183  ""
5184  "")
5185
5186(define_insn ""
5187  [(set (match_operand:DI 0 "register_operand" "=r,r")
5188	(minus:DI (match_operand:DI 1 "arith11_operand" "r,I")
5189		  (match_operand:DI 2 "reg_or_0_operand" "rM,rM")))
5190   (trap_if (ne (minus:TI (sign_extend:TI (match_dup 1))
5191			  (sign_extend:TI (match_dup 2)))
5192		(sign_extend:TI (minus:DI (match_dup 1)
5193					  (match_dup 2))))
5194	    (const_int 0))]
5195  "TARGET_64BIT"
5196  "@
5197  {subo|sub,tsv} %1,%2,%0
5198  {subio|subi,tsv} %1,%2,%0"
5199  [(set_attr "type" "binary,binary")
5200   (set_attr "length" "4,4")])
5201
5202(define_insn ""
5203  [(set (match_operand:DI 0 "register_operand" "=r,&r")
5204	(minus:DI (match_operand:DI 1 "arith11_operand" "r,I")
5205		  (match_operand:DI 2 "reg_or_0_operand" "rM,rM")))
5206   (trap_if (ne (minus:TI (sign_extend:TI (match_dup 1))
5207			  (sign_extend:TI (match_dup 2)))
5208		(sign_extend:TI (minus:DI (match_dup 1)
5209					  (match_dup 2))))
5210	    (const_int 0))]
5211  "!TARGET_64BIT"
5212  "*
5213{
5214  if (GET_CODE (operands[1]) == CONST_INT)
5215    {
5216      if (INTVAL (operands[1]) >= 0)
5217	return \"subi %1,%R2,%R0\;{subbo|sub,b,tsv} %%r0,%2,%0\";
5218      else
5219	return \"ldi -1,%0\;subi %1,%R2,%R0\;{subbo|sub,b,tsv} %0,%2,%0\";
5220    }
5221  else
5222    return \"sub %R1,%R2,%R0\;{subbo|sub,b,tsv} %1,%2,%0\";
5223}"
5224  [(set_attr "type" "binary,binary")
5225   (set (attr "length")
5226	(if_then_else (eq_attr "alternative" "0")
5227	  (const_int 8)
5228	  (if_then_else (ge (symbol_ref "INTVAL (operands[1])")
5229			    (const_int 0))
5230	    (const_int 8)
5231	    (const_int 12))))])
5232
5233(define_expand "subsi3"
5234  [(set (match_operand:SI 0 "register_operand" "")
5235	(minus:SI (match_operand:SI 1 "arith11_operand" "")
5236		  (match_operand:SI 2 "register_operand" "")))]
5237  ""
5238  "")
5239
5240(define_insn ""
5241  [(set (match_operand:SI 0 "register_operand" "=r,r")
5242	(minus:SI (match_operand:SI 1 "arith11_operand" "r,I")
5243		  (match_operand:SI 2 "register_operand" "r,r")))]
5244  "!TARGET_PA_20"
5245  "@
5246   sub %1,%2,%0
5247   subi %1,%2,%0"
5248  [(set_attr "type" "binary,binary")
5249   (set_attr "length" "4,4")])
5250
5251(define_insn ""
5252  [(set (match_operand:SI 0 "register_operand" "=r,r,!q")
5253	(minus:SI (match_operand:SI 1 "arith11_operand" "r,I,!S")
5254		  (match_operand:SI 2 "register_operand" "r,r,!r")))]
5255  "TARGET_PA_20"
5256  "@
5257   sub %1,%2,%0
5258   subi %1,%2,%0
5259   mtsarcm %2"
5260  [(set_attr "type" "binary,binary,move")
5261   (set_attr "length" "4,4,4")])
5262
5263(define_insn "subvsi3"
5264  [(set (match_operand:SI 0 "register_operand" "=r,r")
5265	(minus:SI (match_operand:SI 1 "arith11_operand" "rM,I")
5266		  (match_operand:SI 2 "reg_or_0_operand" "rM,rM")))
5267   (trap_if (ne (minus:DI (sign_extend:DI (match_dup 1))
5268			  (sign_extend:DI (match_dup 2)))
5269		(sign_extend:DI (minus:SI (match_dup 1)
5270					  (match_dup 2))))
5271	    (const_int 0))]
5272  ""
5273  "@
5274  {subo|sub,tsv} %1,%2,%0
5275  {subio|subi,tsv} %1,%2,%0"
5276  [(set_attr "type" "binary,binary")
5277   (set_attr "length" "4,4")])
5278
5279;; Trap instructions.
5280
5281(define_insn "trap"
5282  [(trap_if (const_int 1) (const_int 0))]
5283  ""
5284  "{addit|addi,tc},<> 1,%%r0,%%r0"
5285  [(set_attr "type" "trap")
5286   (set_attr "length" "4")])
5287
5288;; Clobbering a "register_operand" instead of a match_scratch
5289;; in operand3 of millicode calls avoids spilling %r1 and
5290;; produces better code.
5291
5292;; The mulsi3 insns set up registers for the millicode call.
5293(define_expand "mulsi3"
5294  [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5295   (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5296   (parallel [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
5297	      (clobber (match_dup 3))
5298	      (clobber (reg:SI 26))
5299	      (clobber (reg:SI 25))
5300	      (clobber (match_dup 4))])
5301   (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5302  ""
5303  "
5304{
5305  operands[4] = gen_rtx_REG (SImode, TARGET_64BIT ? 2 : 31);
5306  if (TARGET_PA_11 && !TARGET_DISABLE_FPREGS && !TARGET_SOFT_FLOAT)
5307    {
5308      rtx scratch = gen_reg_rtx (DImode);
5309      operands[1] = force_reg (SImode, operands[1]);
5310      operands[2] = force_reg (SImode, operands[2]);
5311      emit_insn (gen_umulsidi3 (scratch, operands[1], operands[2]));
5312      emit_insn (gen_movsi (operands[0],
5313			    gen_rtx_SUBREG (SImode, scratch,
5314					    GET_MODE_SIZE (SImode))));
5315      DONE;
5316    }
5317  operands[3] = gen_reg_rtx (SImode);
5318}")
5319
5320(define_insn "umulsidi3"
5321  [(set (match_operand:DI 0 "register_operand" "=f")
5322	(mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "f"))
5323		 (zero_extend:DI (match_operand:SI 2 "register_operand" "f"))))]
5324  "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT"
5325  "xmpyu %1,%2,%0"
5326  [(set_attr "type" "fpmuldbl")
5327   (set_attr "length" "4")])
5328
5329(define_insn ""
5330  [(set (match_operand:DI 0 "register_operand" "=f")
5331	(mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "f"))
5332		 (match_operand:DI 2 "uint32_operand" "f")))]
5333  "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT && !TARGET_64BIT"
5334  "xmpyu %1,%R2,%0"
5335  [(set_attr "type" "fpmuldbl")
5336   (set_attr "length" "4")])
5337
5338(define_insn ""
5339  [(set (match_operand:DI 0 "register_operand" "=f")
5340	(mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "f"))
5341		 (match_operand:DI 2 "uint32_operand" "f")))]
5342  "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT && TARGET_64BIT"
5343  "xmpyu %1,%2R,%0"
5344  [(set_attr "type" "fpmuldbl")
5345   (set_attr "length" "4")])
5346
5347(define_insn ""
5348  [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
5349   (clobber (match_operand:SI 0 "register_operand" "=a"))
5350   (clobber (reg:SI 26))
5351   (clobber (reg:SI 25))
5352   (clobber (reg:SI 31))]
5353  "!TARGET_64BIT"
5354  "* return pa_output_mul_insn (0, insn);"
5355  [(set_attr "type" "milli")
5356   (set (attr "length")
5357	(cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5358	      (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5359
5360(define_insn ""
5361  [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
5362   (clobber (match_operand:SI 0 "register_operand" "=a"))
5363   (clobber (reg:SI 26))
5364   (clobber (reg:SI 25))
5365   (clobber (reg:SI 2))]
5366  "TARGET_64BIT"
5367  "* return pa_output_mul_insn (0, insn);"
5368  [(set_attr "type" "milli")
5369   (set (attr "length")
5370	(cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5371	      (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5372
5373(define_expand "muldi3"
5374  [(set (match_operand:DI 0 "register_operand" "")
5375        (mult:DI (match_operand:DI 1 "register_operand" "")
5376		 (match_operand:DI 2 "register_operand" "")))]
5377  "TARGET_64BIT && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT"
5378  "
5379{
5380  rtx low_product = gen_reg_rtx (DImode);
5381  rtx cross_product1 = gen_reg_rtx (DImode);
5382  rtx cross_product2 = gen_reg_rtx (DImode);
5383  rtx cross_scratch = gen_reg_rtx (DImode);
5384  rtx cross_product = gen_reg_rtx (DImode);
5385  rtx op1l, op1r, op2l, op2r;
5386  rtx op1shifted, op2shifted;
5387
5388  op1shifted = gen_reg_rtx (DImode);
5389  op2shifted = gen_reg_rtx (DImode);
5390  op1l = gen_reg_rtx (SImode);
5391  op1r = gen_reg_rtx (SImode);
5392  op2l = gen_reg_rtx (SImode);
5393  op2r = gen_reg_rtx (SImode);
5394
5395  emit_move_insn (op1shifted, gen_rtx_LSHIFTRT (DImode, operands[1],
5396						GEN_INT (32)));
5397  emit_move_insn (op2shifted, gen_rtx_LSHIFTRT (DImode, operands[2],
5398						GEN_INT (32)));
5399  op1r = force_reg (SImode, gen_rtx_SUBREG (SImode, operands[1], 4));
5400  op2r = force_reg (SImode, gen_rtx_SUBREG (SImode, operands[2], 4));
5401  op1l = force_reg (SImode, gen_rtx_SUBREG (SImode, op1shifted, 4));
5402  op2l = force_reg (SImode, gen_rtx_SUBREG (SImode, op2shifted, 4));
5403
5404  /* Emit multiplies for the cross products.  */
5405  emit_insn (gen_umulsidi3 (cross_product1, op2r, op1l));
5406  emit_insn (gen_umulsidi3 (cross_product2, op2l, op1r));
5407
5408  /* Emit a multiply for the low sub-word.  */
5409  emit_insn (gen_umulsidi3 (low_product, copy_rtx (op2r), copy_rtx (op1r)));
5410
5411  /* Sum the cross products and shift them into proper position.  */
5412  emit_insn (gen_adddi3 (cross_scratch, cross_product1, cross_product2));
5413  emit_insn (gen_ashldi3 (cross_product, cross_scratch, GEN_INT (32)));
5414
5415  /* Add the cross product to the low product and store the result
5416     into the output operand .  */
5417  emit_insn (gen_adddi3 (operands[0], cross_product, low_product));
5418  DONE;
5419}")
5420
5421;;; Division and mod.
5422(define_expand "divsi3"
5423  [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5424   (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5425   (parallel [(set (reg:SI 29) (div:SI (reg:SI 26) (reg:SI 25)))
5426	      (clobber (match_dup 3))
5427	      (clobber (match_dup 4))
5428	      (clobber (reg:SI 26))
5429	      (clobber (reg:SI 25))
5430	      (clobber (match_dup 5))])
5431   (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5432  ""
5433  "
5434{
5435  operands[3] = gen_reg_rtx (SImode);
5436  if (TARGET_64BIT)
5437    {
5438      operands[5] = gen_rtx_REG (SImode, 2);
5439      operands[4] = operands[5];
5440    }
5441  else
5442    {
5443      operands[5] = gen_rtx_REG (SImode, 31);
5444      operands[4] = gen_reg_rtx (SImode);
5445    }
5446  if (GET_CODE (operands[2]) == CONST_INT && pa_emit_hpdiv_const (operands, 0))
5447    DONE;
5448}")
5449
5450(define_insn ""
5451  [(set (reg:SI 29)
5452	(div:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5453   (clobber (match_operand:SI 1 "register_operand" "=a"))
5454   (clobber (match_operand:SI 2 "register_operand" "=&r"))
5455   (clobber (reg:SI 26))
5456   (clobber (reg:SI 25))
5457   (clobber (reg:SI 31))]
5458  "!TARGET_64BIT"
5459  "*
5460   return pa_output_div_insn (operands, 0, insn);"
5461  [(set_attr "type" "milli")
5462   (set (attr "length")
5463	(cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5464	      (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5465
5466(define_insn ""
5467  [(set (reg:SI 29)
5468	(div:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5469   (clobber (match_operand:SI 1 "register_operand" "=a"))
5470   (clobber (match_operand:SI 2 "register_operand" "=&r"))
5471   (clobber (reg:SI 26))
5472   (clobber (reg:SI 25))
5473   (clobber (reg:SI 2))]
5474  "TARGET_64BIT"
5475  "*
5476   return pa_output_div_insn (operands, 0, insn);"
5477  [(set_attr "type" "milli")
5478   (set (attr "length")
5479	(cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5480	      (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5481
5482(define_expand "udivsi3"
5483  [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5484   (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5485   (parallel [(set (reg:SI 29) (udiv:SI (reg:SI 26) (reg:SI 25)))
5486	      (clobber (match_dup 3))
5487	      (clobber (match_dup 4))
5488	      (clobber (reg:SI 26))
5489	      (clobber (reg:SI 25))
5490	      (clobber (match_dup 5))])
5491   (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5492  ""
5493  "
5494{
5495  operands[3] = gen_reg_rtx (SImode);
5496
5497  if (TARGET_64BIT)
5498    {
5499      operands[5] = gen_rtx_REG (SImode, 2);
5500      operands[4] = operands[5];
5501    }
5502  else
5503    {
5504      operands[5] = gen_rtx_REG (SImode, 31);
5505      operands[4] = gen_reg_rtx (SImode);
5506    }
5507  if (GET_CODE (operands[2]) == CONST_INT && pa_emit_hpdiv_const (operands, 1))
5508    DONE;
5509}")
5510
5511(define_insn ""
5512  [(set (reg:SI 29)
5513	(udiv:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5514   (clobber (match_operand:SI 1 "register_operand" "=a"))
5515   (clobber (match_operand:SI 2 "register_operand" "=&r"))
5516   (clobber (reg:SI 26))
5517   (clobber (reg:SI 25))
5518   (clobber (reg:SI 31))]
5519  "!TARGET_64BIT"
5520  "*
5521   return pa_output_div_insn (operands, 1, insn);"
5522  [(set_attr "type" "milli")
5523   (set (attr "length")
5524	(cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5525	      (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5526
5527(define_insn ""
5528  [(set (reg:SI 29)
5529	(udiv:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5530   (clobber (match_operand:SI 1 "register_operand" "=a"))
5531   (clobber (match_operand:SI 2 "register_operand" "=&r"))
5532   (clobber (reg:SI 26))
5533   (clobber (reg:SI 25))
5534   (clobber (reg:SI 2))]
5535  "TARGET_64BIT"
5536  "*
5537   return pa_output_div_insn (operands, 1, insn);"
5538  [(set_attr "type" "milli")
5539   (set (attr "length")
5540	(cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5541	      (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5542
5543(define_expand "modsi3"
5544  [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5545   (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5546   (parallel [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
5547	      (clobber (match_dup 3))
5548	      (clobber (match_dup 4))
5549	      (clobber (reg:SI 26))
5550	      (clobber (reg:SI 25))
5551	      (clobber (match_dup 5))])
5552   (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5553  ""
5554  "
5555{
5556  if (TARGET_64BIT)
5557    {
5558      operands[5] = gen_rtx_REG (SImode, 2);
5559      operands[4] = operands[5];
5560    }
5561  else
5562    {
5563      operands[5] = gen_rtx_REG (SImode, 31);
5564      operands[4] = gen_reg_rtx (SImode);
5565    }
5566  operands[3] = gen_reg_rtx (SImode);
5567}")
5568
5569(define_insn ""
5570  [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
5571   (clobber (match_operand:SI 0 "register_operand" "=a"))
5572   (clobber (match_operand:SI 1 "register_operand" "=&r"))
5573   (clobber (reg:SI 26))
5574   (clobber (reg:SI 25))
5575   (clobber (reg:SI 31))]
5576  "!TARGET_64BIT"
5577  "*
5578  return pa_output_mod_insn (0, insn);"
5579  [(set_attr "type" "milli")
5580   (set (attr "length")
5581	(cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5582	      (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5583
5584(define_insn ""
5585  [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
5586   (clobber (match_operand:SI 0 "register_operand" "=a"))
5587   (clobber (match_operand:SI 1 "register_operand" "=&r"))
5588   (clobber (reg:SI 26))
5589   (clobber (reg:SI 25))
5590   (clobber (reg:SI 2))]
5591  "TARGET_64BIT"
5592  "*
5593  return pa_output_mod_insn (0, insn);"
5594  [(set_attr "type" "milli")
5595   (set (attr "length")
5596	(cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5597	      (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5598
5599(define_expand "umodsi3"
5600  [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5601   (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5602   (parallel [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
5603	      (clobber (match_dup 3))
5604	      (clobber (match_dup 4))
5605	      (clobber (reg:SI 26))
5606	      (clobber (reg:SI 25))
5607	      (clobber (match_dup 5))])
5608   (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5609  ""
5610  "
5611{
5612  if (TARGET_64BIT)
5613    {
5614      operands[5] = gen_rtx_REG (SImode, 2);
5615      operands[4] = operands[5];
5616    }
5617  else
5618    {
5619      operands[5] = gen_rtx_REG (SImode, 31);
5620      operands[4] = gen_reg_rtx (SImode);
5621    }
5622  operands[3] = gen_reg_rtx (SImode);
5623}")
5624
5625(define_insn ""
5626  [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
5627   (clobber (match_operand:SI 0 "register_operand" "=a"))
5628   (clobber (match_operand:SI 1 "register_operand" "=&r"))
5629   (clobber (reg:SI 26))
5630   (clobber (reg:SI 25))
5631   (clobber (reg:SI 31))]
5632  "!TARGET_64BIT"
5633  "*
5634  return pa_output_mod_insn (1, insn);"
5635  [(set_attr "type" "milli")
5636   (set (attr "length")
5637	(cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5638	      (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5639
5640(define_insn ""
5641  [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
5642   (clobber (match_operand:SI 0 "register_operand" "=a"))
5643   (clobber (match_operand:SI 1 "register_operand" "=&r"))
5644   (clobber (reg:SI 26))
5645   (clobber (reg:SI 25))
5646   (clobber (reg:SI 2))]
5647  "TARGET_64BIT"
5648  "*
5649  return pa_output_mod_insn (1, insn);"
5650  [(set_attr "type" "milli")
5651   (set (attr "length")
5652	(cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5653	      (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5654
5655;;- and instructions
5656;; We define DImode `and` so with DImode `not` we can get
5657;; DImode `andn`.  Other combinations are possible.
5658
5659(define_expand "anddi3"
5660  [(set (match_operand:DI 0 "register_operand" "")
5661	(and:DI (match_operand:DI 1 "register_operand" "")
5662		(match_operand:DI 2 "and_operand" "")))]
5663  "TARGET_64BIT"
5664  "")
5665
5666(define_insn ""
5667  [(set (match_operand:DI 0 "register_operand" "=r,r")
5668	(and:DI (match_operand:DI 1 "register_operand" "%?r,0")
5669		(match_operand:DI 2 "and_operand" "rO,P")))]
5670  "TARGET_64BIT"
5671  "* return pa_output_64bit_and (operands); "
5672  [(set_attr "type" "binary")
5673   (set_attr "length" "4")])
5674
5675; The ? for op1 makes reload prefer zdepi instead of loading a huge
5676; constant with ldil;ldo.
5677(define_insn "andsi3"
5678  [(set (match_operand:SI 0 "register_operand" "=r,r")
5679	(and:SI (match_operand:SI 1 "register_operand" "%?r,0")
5680		(match_operand:SI 2 "and_operand" "rO,P")))]
5681  ""
5682  "* return pa_output_and (operands); "
5683  [(set_attr "type" "binary,shift")
5684   (set_attr "length" "4,4")])
5685
5686(define_insn ""
5687  [(set (match_operand:DI 0 "register_operand" "=r")
5688	(and:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
5689		(match_operand:DI 2 "register_operand" "r")))]
5690  "TARGET_64BIT"
5691  "andcm %2,%1,%0"
5692  [(set_attr "type" "binary")
5693   (set_attr "length" "4")])
5694
5695(define_insn ""
5696  [(set (match_operand:SI 0 "register_operand" "=r")
5697	(and:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
5698		(match_operand:SI 2 "register_operand" "r")))]
5699  ""
5700  "andcm %2,%1,%0"
5701  [(set_attr "type" "binary")
5702  (set_attr "length" "4")])
5703
5704(define_expand "iordi3"
5705  [(set (match_operand:DI 0 "register_operand" "")
5706	(ior:DI (match_operand:DI 1 "register_operand" "")
5707		(match_operand:DI 2 "reg_or_cint_ior_operand" "")))]
5708  "TARGET_64BIT"
5709  "")
5710
5711(define_insn ""
5712  [(set (match_operand:DI 0 "register_operand" "=r,r")
5713	(ior:DI (match_operand:DI 1 "register_operand" "0,0")
5714		(match_operand:DI 2 "cint_ior_operand" "M,i")))]
5715  "TARGET_64BIT"
5716  "* return pa_output_64bit_ior (operands); "
5717  [(set_attr "type" "binary,shift")
5718   (set_attr "length" "4,4")])
5719
5720(define_insn ""
5721  [(set (match_operand:DI 0 "register_operand" "=r")
5722	(ior:DI (match_operand:DI 1 "register_operand" "%r")
5723		(match_operand:DI 2 "register_operand" "r")))]
5724  "TARGET_64BIT"
5725  "or %1,%2,%0"
5726  [(set_attr "type" "binary")
5727   (set_attr "length" "4")])
5728
5729;; Need a define_expand because we've run out of CONST_OK... characters.
5730(define_expand "iorsi3"
5731  [(set (match_operand:SI 0 "register_operand" "")
5732	(ior:SI (match_operand:SI 1 "register_operand" "")
5733		(match_operand:SI 2 "reg_or_cint_ior_operand" "")))]
5734  ""
5735  "")
5736
5737(define_insn ""
5738  [(set (match_operand:SI 0 "register_operand" "=r,r")
5739	(ior:SI (match_operand:SI 1 "register_operand" "0,0")
5740		(match_operand:SI 2 "cint_ior_operand" "M,i")))]
5741  ""
5742  "* return pa_output_ior (operands); "
5743  [(set_attr "type" "binary,shift")
5744   (set_attr "length" "4,4")])
5745
5746(define_insn ""
5747  [(set (match_operand:SI 0 "register_operand" "=r")
5748	(ior:SI (match_operand:SI 1 "register_operand" "%r")
5749		(match_operand:SI 2 "register_operand" "r")))]
5750  ""
5751  "or %1,%2,%0"
5752  [(set_attr "type" "binary")
5753   (set_attr "length" "4")])
5754
5755(define_expand "xordi3"
5756  [(set (match_operand:DI 0 "register_operand" "")
5757	(xor:DI (match_operand:DI 1 "register_operand" "")
5758		(match_operand:DI 2 "register_operand" "")))]
5759  "TARGET_64BIT"
5760  "")
5761
5762(define_insn ""
5763  [(set (match_operand:DI 0 "register_operand" "=r")
5764	(xor:DI (match_operand:DI 1 "register_operand" "%r")
5765		(match_operand:DI 2 "register_operand" "r")))]
5766  "TARGET_64BIT"
5767  "xor %1,%2,%0"
5768  [(set_attr "type" "binary")
5769   (set_attr "length" "4")])
5770
5771(define_insn "xorsi3"
5772  [(set (match_operand:SI 0 "register_operand" "=r")
5773	(xor:SI (match_operand:SI 1 "register_operand" "%r")
5774		(match_operand:SI 2 "register_operand" "r")))]
5775  ""
5776  "xor %1,%2,%0"
5777  [(set_attr "type" "binary")
5778   (set_attr "length" "4")])
5779
5780(define_expand "negdi2"
5781  [(set (match_operand:DI 0 "register_operand" "")
5782	(neg:DI (match_operand:DI 1 "register_operand" "")))]
5783  ""
5784  "")
5785
5786(define_insn ""
5787  [(set (match_operand:DI 0 "register_operand" "=r")
5788	(neg:DI (match_operand:DI 1 "register_operand" "r")))]
5789  "!TARGET_64BIT"
5790  "sub %%r0,%R1,%R0\;{subb|sub,b} %%r0,%1,%0"
5791  [(set_attr "type" "unary")
5792   (set_attr "length" "8")])
5793
5794(define_insn ""
5795  [(set (match_operand:DI 0 "register_operand" "=r")
5796	(neg:DI (match_operand:DI 1 "register_operand" "r")))]
5797  "TARGET_64BIT"
5798  "sub %%r0,%1,%0"
5799  [(set_attr "type" "unary")
5800   (set_attr "length" "4")])
5801
5802(define_expand "negvdi2"
5803  [(parallel [(set (match_operand:DI 0 "register_operand" "")
5804		   (neg:DI (match_operand:DI 1 "register_operand" "")))
5805	      (trap_if (ne (neg:TI (sign_extend:TI (match_dup 1)))
5806				   (sign_extend:TI (neg:DI (match_dup 1))))
5807		       (const_int 0))])]
5808  ""
5809  "")
5810
5811(define_insn ""
5812  [(set (match_operand:DI 0 "register_operand" "=r")
5813	(neg:DI (match_operand:DI 1 "register_operand" "r")))
5814   (trap_if (ne (neg:TI (sign_extend:TI (match_dup 1)))
5815		(sign_extend:TI (neg:DI (match_dup 1))))
5816	    (const_int 0))]
5817  "!TARGET_64BIT"
5818  "sub %%r0,%R1,%R0\;{subbo|sub,b,tsv} %%r0,%1,%0"
5819  [(set_attr "type" "unary")
5820   (set_attr "length" "8")])
5821
5822(define_insn ""
5823  [(set (match_operand:DI 0 "register_operand" "=r")
5824	(neg:DI (match_operand:DI 1 "register_operand" "r")))
5825   (trap_if (ne (neg:TI (sign_extend:TI (match_dup 1)))
5826		(sign_extend:TI (neg:DI (match_dup 1))))
5827	    (const_int 0))]
5828  "TARGET_64BIT"
5829  "sub,tsv %%r0,%1,%0"
5830  [(set_attr "type" "unary")
5831   (set_attr "length" "4")])
5832
5833(define_insn "negsi2"
5834  [(set (match_operand:SI 0 "register_operand" "=r")
5835	(neg:SI (match_operand:SI 1 "register_operand" "r")))]
5836  ""
5837  "sub %%r0,%1,%0"
5838  [(set_attr "type" "unary")
5839   (set_attr "length" "4")])
5840
5841(define_insn "negvsi2"
5842  [(set (match_operand:SI 0 "register_operand" "=r")
5843        (neg:SI (match_operand:SI 1 "register_operand" "r")))
5844   (trap_if (ne (neg:DI (sign_extend:DI (match_dup 1)))
5845		(sign_extend:DI (neg:SI (match_dup 1))))
5846	    (const_int 0))]
5847   ""
5848   "{subo|sub,tsv} %%r0,%1,%0"
5849  [(set_attr "type" "unary")
5850   (set_attr "length" "4")])
5851
5852(define_expand "one_cmpldi2"
5853  [(set (match_operand:DI 0 "register_operand" "")
5854	(not:DI (match_operand:DI 1 "register_operand" "")))]
5855  ""
5856  "
5857{
5858}")
5859
5860(define_insn ""
5861  [(set (match_operand:DI 0 "register_operand" "=r")
5862	(not:DI (match_operand:DI 1 "register_operand" "r")))]
5863  "!TARGET_64BIT"
5864  "uaddcm %%r0,%1,%0\;uaddcm %%r0,%R1,%R0"
5865  [(set_attr "type" "unary")
5866   (set_attr "length" "8")])
5867
5868(define_insn ""
5869  [(set (match_operand:DI 0 "register_operand" "=r")
5870	(not:DI (match_operand:DI 1 "register_operand" "r")))]
5871  "TARGET_64BIT"
5872  "uaddcm %%r0,%1,%0"
5873  [(set_attr "type" "unary")
5874   (set_attr "length" "4")])
5875
5876(define_insn "one_cmplsi2"
5877  [(set (match_operand:SI 0 "register_operand" "=r")
5878	(not:SI (match_operand:SI 1 "register_operand" "r")))]
5879  ""
5880  "uaddcm %%r0,%1,%0"
5881  [(set_attr "type" "unary")
5882   (set_attr "length" "4")])
5883
5884;; Floating point arithmetic instructions.
5885
5886(define_insn "adddf3"
5887  [(set (match_operand:DF 0 "register_operand" "=f")
5888	(plus:DF (match_operand:DF 1 "register_operand" "f")
5889		 (match_operand:DF 2 "register_operand" "f")))]
5890  "! TARGET_SOFT_FLOAT"
5891  "fadd,dbl %1,%2,%0"
5892  [(set_attr "type" "fpalu")
5893   (set_attr "pa_combine_type" "faddsub")
5894   (set_attr "length" "4")])
5895
5896(define_insn "addsf3"
5897  [(set (match_operand:SF 0 "register_operand" "=f")
5898	(plus:SF (match_operand:SF 1 "register_operand" "f")
5899		 (match_operand:SF 2 "register_operand" "f")))]
5900  "! TARGET_SOFT_FLOAT"
5901  "fadd,sgl %1,%2,%0"
5902  [(set_attr "type" "fpalu")
5903   (set_attr "pa_combine_type" "faddsub")
5904   (set_attr "length" "4")])
5905
5906(define_insn "subdf3"
5907  [(set (match_operand:DF 0 "register_operand" "=f")
5908	(minus:DF (match_operand:DF 1 "register_operand" "f")
5909		  (match_operand:DF 2 "register_operand" "f")))]
5910  "! TARGET_SOFT_FLOAT"
5911  "fsub,dbl %1,%2,%0"
5912  [(set_attr "type" "fpalu")
5913   (set_attr "pa_combine_type" "faddsub")
5914   (set_attr "length" "4")])
5915
5916(define_insn "subsf3"
5917  [(set (match_operand:SF 0 "register_operand" "=f")
5918	(minus:SF (match_operand:SF 1 "register_operand" "f")
5919		  (match_operand:SF 2 "register_operand" "f")))]
5920  "! TARGET_SOFT_FLOAT"
5921  "fsub,sgl %1,%2,%0"
5922  [(set_attr "type" "fpalu")
5923   (set_attr "pa_combine_type" "faddsub")
5924   (set_attr "length" "4")])
5925
5926(define_insn "muldf3"
5927  [(set (match_operand:DF 0 "register_operand" "=f")
5928	(mult:DF (match_operand:DF 1 "register_operand" "f")
5929		 (match_operand:DF 2 "register_operand" "f")))]
5930  "! TARGET_SOFT_FLOAT"
5931  "fmpy,dbl %1,%2,%0"
5932  [(set_attr "type" "fpmuldbl")
5933   (set_attr "pa_combine_type" "fmpy")
5934   (set_attr "length" "4")])
5935
5936(define_insn "mulsf3"
5937  [(set (match_operand:SF 0 "register_operand" "=f")
5938	(mult:SF (match_operand:SF 1 "register_operand" "f")
5939		 (match_operand:SF 2 "register_operand" "f")))]
5940  "! TARGET_SOFT_FLOAT"
5941  "fmpy,sgl %1,%2,%0"
5942  [(set_attr "type" "fpmulsgl")
5943   (set_attr "pa_combine_type" "fmpy")
5944   (set_attr "length" "4")])
5945
5946(define_insn "divdf3"
5947  [(set (match_operand:DF 0 "register_operand" "=f")
5948	(div:DF (match_operand:DF 1 "register_operand" "f")
5949		(match_operand:DF 2 "register_operand" "f")))]
5950  "! TARGET_SOFT_FLOAT"
5951  "fdiv,dbl %1,%2,%0"
5952  [(set_attr "type" "fpdivdbl")
5953   (set_attr "length" "4")])
5954
5955(define_insn "divsf3"
5956  [(set (match_operand:SF 0 "register_operand" "=f")
5957	(div:SF (match_operand:SF 1 "register_operand" "f")
5958		(match_operand:SF 2 "register_operand" "f")))]
5959  "! TARGET_SOFT_FLOAT"
5960  "fdiv,sgl %1,%2,%0"
5961  [(set_attr "type" "fpdivsgl")
5962   (set_attr "length" "4")])
5963
5964;; Processors prior to PA 2.0 don't have a fneg instruction.  Fast
5965;; negation can be done by subtracting from plus zero.  However, this
5966;; violates the IEEE standard when negating plus and minus zero.
5967;; The slow path toggles the sign bit in the general registers.
5968(define_expand "negdf2"
5969  [(set (match_operand:DF 0 "register_operand" "")
5970	(neg:DF (match_operand:DF 1 "register_operand" "")))]
5971  "!TARGET_SOFT_FLOAT"
5972{
5973  if (TARGET_PA_20 || !flag_signed_zeros)
5974    emit_insn (gen_negdf2_fast (operands[0], operands[1]));
5975  else
5976    emit_insn (gen_negdf2_slow (operands[0], operands[1]));
5977  DONE;
5978})
5979
5980(define_insn "negdf2_slow"
5981  [(set (match_operand:DF 0 "register_operand" "=r")
5982	(neg:DF (match_operand:DF 1 "register_operand" "r")))]
5983  "!TARGET_SOFT_FLOAT && !TARGET_PA_20"
5984  "*
5985{
5986  if (rtx_equal_p (operands[0], operands[1]))
5987    return \"and,< %1,%1,%0\;depi,tr 1,0,1,%0\;depi 0,0,1,%0\";
5988  else
5989    return \"and,< %1,%1,%0\;depi,tr 1,0,1,%0\;depi 0,0,1,%0\;copy %R1,%R0\";
5990}"
5991  [(set_attr "type" "multi")
5992   (set (attr "length")
5993	(if_then_else (match_test "rtx_equal_p (operands[0], operands[1])")
5994	    (const_int 12)
5995	    (const_int 16)))])
5996
5997(define_insn "negdf2_fast"
5998  [(set (match_operand:DF 0 "register_operand" "=f")
5999	(neg:DF (match_operand:DF 1 "register_operand" "f")))]
6000  "!TARGET_SOFT_FLOAT"
6001  "*
6002{
6003  if (TARGET_PA_20)
6004    return \"fneg,dbl %1,%0\";
6005  else
6006    return \"fsub,dbl %%fr0,%1,%0\";
6007}"
6008  [(set_attr "type" "fpalu")
6009   (set_attr "length" "4")])
6010
6011(define_expand "negsf2"
6012  [(set (match_operand:SF 0 "register_operand" "")
6013	(neg:SF (match_operand:SF 1 "register_operand" "")))]
6014  "!TARGET_SOFT_FLOAT"
6015{
6016  if (TARGET_PA_20 || !flag_signed_zeros)
6017    emit_insn (gen_negsf2_fast (operands[0], operands[1]));
6018  else
6019    emit_insn (gen_negsf2_slow (operands[0], operands[1]));
6020  DONE;
6021})
6022
6023(define_insn "negsf2_slow"
6024  [(set (match_operand:SF 0 "register_operand" "=r")
6025	(neg:SF (match_operand:SF 1 "register_operand" "r")))]
6026  "!TARGET_SOFT_FLOAT && !TARGET_PA_20"
6027  "and,< %1,%1,%0\;depi,tr 1,0,1,%0\;depi 0,0,1,%0"
6028  [(set_attr "type" "multi")
6029   (set_attr "length" "12")])
6030
6031(define_insn "negsf2_fast"
6032  [(set (match_operand:SF 0 "register_operand" "=f")
6033	(neg:SF (match_operand:SF 1 "register_operand" "f")))]
6034  "!TARGET_SOFT_FLOAT"
6035  "*
6036{
6037  if (TARGET_PA_20)
6038    return \"fneg,sgl %1,%0\";
6039  else
6040    return \"fsub,sgl %%fr0,%1,%0\";
6041}"
6042  [(set_attr "type" "fpalu")
6043   (set_attr "length" "4")])
6044
6045(define_insn "absdf2"
6046  [(set (match_operand:DF 0 "register_operand" "=f")
6047	(abs:DF (match_operand:DF 1 "register_operand" "f")))]
6048  "! TARGET_SOFT_FLOAT"
6049  "fabs,dbl %1,%0"
6050  [(set_attr "type" "fpalu")
6051   (set_attr "length" "4")])
6052
6053(define_insn "abssf2"
6054  [(set (match_operand:SF 0 "register_operand" "=f")
6055	(abs:SF (match_operand:SF 1 "register_operand" "f")))]
6056  "! TARGET_SOFT_FLOAT"
6057  "fabs,sgl %1,%0"
6058  [(set_attr "type" "fpalu")
6059   (set_attr "length" "4")])
6060
6061(define_insn "sqrtdf2"
6062  [(set (match_operand:DF 0 "register_operand" "=f")
6063	(sqrt:DF (match_operand:DF 1 "register_operand" "f")))]
6064  "! TARGET_SOFT_FLOAT"
6065  "fsqrt,dbl %1,%0"
6066  [(set_attr "type" "fpsqrtdbl")
6067   (set_attr "length" "4")])
6068
6069(define_insn "sqrtsf2"
6070  [(set (match_operand:SF 0 "register_operand" "=f")
6071	(sqrt:SF (match_operand:SF 1 "register_operand" "f")))]
6072  "! TARGET_SOFT_FLOAT"
6073  "fsqrt,sgl %1,%0"
6074  [(set_attr "type" "fpsqrtsgl")
6075   (set_attr "length" "4")])
6076
6077;; PA 2.0 floating point instructions
6078
6079; fmpyfadd patterns
6080(define_insn "fmadf4"
6081  [(set (match_operand:DF 0 "register_operand" "=f")
6082	(fma:DF (match_operand:DF 1 "register_operand" "f")
6083		(match_operand:DF 2 "register_operand" "f")
6084		(match_operand:DF 3 "register_operand" "f")))]
6085  "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6086  "fmpyfadd,dbl %1,%2,%3,%0"
6087  [(set_attr "type" "fpmuldbl")
6088   (set_attr "length" "4")])
6089
6090(define_insn "fmasf4"
6091  [(set (match_operand:SF 0 "register_operand" "=f")
6092	(fma:SF (match_operand:SF 1 "register_operand" "f")
6093		(match_operand:SF 2 "register_operand" "f")
6094		(match_operand:SF 3 "register_operand" "f")))]
6095  "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6096  "fmpyfadd,sgl %1,%2,%3,%0"
6097  [(set_attr "type" "fpmulsgl")
6098   (set_attr "length" "4")])
6099
6100; fmpynfadd patterns
6101(define_insn "fnmadf4"
6102  [(set (match_operand:DF 0 "register_operand" "=f")
6103	(fma:DF (neg:DF (match_operand:DF 1 "register_operand" "f"))
6104		(match_operand:DF 2 "register_operand" "f")
6105		(match_operand:DF 3 "register_operand" "f")))]
6106  "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6107  "fmpynfadd,dbl %1,%2,%3,%0"
6108  [(set_attr "type" "fpmuldbl")
6109   (set_attr "length" "4")])
6110
6111(define_insn "fnmasf4"
6112  [(set (match_operand:SF 0 "register_operand" "=f")
6113	(fma:SF (neg:SF (match_operand:SF 1 "register_operand" "f"))
6114		(match_operand:SF 2 "register_operand" "f")
6115		(match_operand:SF 3 "register_operand" "f")))]
6116  "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6117  "fmpynfadd,sgl %1,%2,%3,%0"
6118  [(set_attr "type" "fpmulsgl")
6119   (set_attr "length" "4")])
6120
6121; fnegabs patterns
6122(define_insn ""
6123  [(set (match_operand:DF 0 "register_operand" "=f")
6124	(neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))]
6125  "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6126  "fnegabs,dbl %1,%0"
6127  [(set_attr "type" "fpalu")
6128   (set_attr "length" "4")])
6129
6130(define_insn ""
6131  [(set (match_operand:SF 0 "register_operand" "=f")
6132	(neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))]
6133  "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6134  "fnegabs,sgl %1,%0"
6135  [(set_attr "type" "fpalu")
6136   (set_attr "length" "4")])
6137
6138(define_insn ""
6139  [(set (match_operand:DF 0 "register_operand" "=f")
6140	(neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))
6141   (set (match_operand:DF 2 "register_operand" "=&f") (abs:DF (match_dup 1)))]
6142  "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6143    && ! reg_overlap_mentioned_p (operands[2], operands[1]))"
6144  "#"
6145  [(set_attr "type" "fpalu")
6146   (set_attr "length" "8")])
6147
6148(define_split
6149  [(set (match_operand:DF 0 "register_operand" "")
6150	(neg:DF (abs:DF (match_operand:DF 1 "register_operand" ""))))
6151   (set (match_operand:DF 2 "register_operand" "") (abs:DF (match_dup 1)))]
6152  "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6153  [(set (match_dup 2) (abs:DF (match_dup 1)))
6154   (set (match_dup 0) (neg:DF (abs:DF (match_dup 1))))]
6155  "")
6156
6157(define_insn ""
6158  [(set (match_operand:SF 0 "register_operand" "=f")
6159	(neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))
6160   (set (match_operand:SF 2 "register_operand" "=&f") (abs:SF (match_dup 1)))]
6161  "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6162    && ! reg_overlap_mentioned_p (operands[2], operands[1]))"
6163  "#"
6164  [(set_attr "type" "fpalu")
6165   (set_attr "length" "8")])
6166
6167(define_split
6168  [(set (match_operand:SF 0 "register_operand" "")
6169	(neg:SF (abs:SF (match_operand:SF 1 "register_operand" ""))))
6170   (set (match_operand:SF 2 "register_operand" "") (abs:SF (match_dup 1)))]
6171  "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6172  [(set (match_dup 2) (abs:SF (match_dup 1)))
6173   (set (match_dup 0) (neg:SF (abs:SF (match_dup 1))))]
6174  "")
6175
6176;; Negating a multiply can be faked by adding zero in a fused multiply-add
6177;; instruction if we can ignore the sign of zero.
6178(define_insn ""
6179  [(set (match_operand:DF 0 "register_operand" "=f")
6180	(neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
6181			 (match_operand:DF 2 "register_operand" "f"))))]
6182  "!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros"
6183  "fmpynfadd,dbl %1,%2,%%fr0,%0"
6184  [(set_attr "type" "fpmuldbl")
6185   (set_attr "length" "4")])
6186
6187(define_insn ""
6188  [(set (match_operand:SF 0 "register_operand" "=f")
6189	(neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
6190			 (match_operand:SF 2 "register_operand" "f"))))]
6191  "!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros"
6192  "fmpynfadd,sgl %1,%2,%%fr0,%0"
6193  [(set_attr "type" "fpmuldbl")
6194   (set_attr "length" "4")])
6195
6196(define_insn ""
6197  [(set (match_operand:DF 0 "register_operand" "=f")
6198	(neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
6199			 (match_operand:DF 2 "register_operand" "f"))))
6200   (set (match_operand:DF 3 "register_operand" "=&f")
6201	(mult:DF (match_dup 1) (match_dup 2)))]
6202  "(!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros
6203    && ! (reg_overlap_mentioned_p (operands[3], operands[1])
6204          || reg_overlap_mentioned_p (operands[3], operands[2])))"
6205  "#"
6206  [(set_attr "type" "fpmuldbl")
6207   (set_attr "length" "8")])
6208
6209(define_split
6210  [(set (match_operand:DF 0 "register_operand" "")
6211	(neg:DF (mult:DF (match_operand:DF 1 "register_operand" "")
6212			 (match_operand:DF 2 "register_operand" ""))))
6213   (set (match_operand:DF 3 "register_operand" "")
6214	(mult:DF (match_dup 1) (match_dup 2)))]
6215  "!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros"
6216  [(set (match_dup 3) (mult:DF (match_dup 1) (match_dup 2)))
6217   (set (match_dup 0) (neg:DF (mult:DF (match_dup 1) (match_dup 2))))]
6218  "")
6219
6220(define_insn ""
6221  [(set (match_operand:SF 0 "register_operand" "=f")
6222	(neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
6223			 (match_operand:SF 2 "register_operand" "f"))))
6224   (set (match_operand:SF 3 "register_operand" "=&f")
6225	(mult:SF (match_dup 1) (match_dup 2)))]
6226  "(!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros
6227    && ! (reg_overlap_mentioned_p (operands[3], operands[1])
6228          || reg_overlap_mentioned_p (operands[3], operands[2])))"
6229  "#"
6230  [(set_attr "type" "fpmuldbl")
6231   (set_attr "length" "8")])
6232
6233(define_split
6234  [(set (match_operand:SF 0 "register_operand" "")
6235	(neg:SF (mult:SF (match_operand:SF 1 "register_operand" "")
6236			 (match_operand:SF 2 "register_operand" ""))))
6237   (set (match_operand:SF 3 "register_operand" "")
6238	(mult:SF (match_dup 1) (match_dup 2)))]
6239  "!TARGET_SOFT_FLOAT && TARGET_PA_20&& !flag_signed_zeros"
6240  [(set (match_dup 3) (mult:SF (match_dup 1) (match_dup 2)))
6241   (set (match_dup 0) (neg:SF (mult:SF (match_dup 1) (match_dup 2))))]
6242  "")
6243
6244;;- Shift instructions
6245
6246;; Optimized special case of shifting.
6247
6248(define_insn ""
6249  [(set (match_operand:SI 0 "register_operand" "=r")
6250	(lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
6251		     (const_int 24)))]
6252  ""
6253  "ldb%M1 %1,%0"
6254  [(set_attr "type" "load")
6255   (set_attr "length" "4")])
6256
6257(define_insn ""
6258  [(set (match_operand:SI 0 "register_operand" "=r")
6259	(lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
6260		     (const_int 16)))]
6261  ""
6262  "ldh%M1 %1,%0"
6263  [(set_attr "type" "load")
6264   (set_attr "length" "4")])
6265
6266(define_insn ""
6267  [(set (match_operand:SI 0 "register_operand" "=r")
6268	(plus:SI (ashift:SI (match_operand:SI 2 "register_operand" "r")
6269			    (match_operand:SI 3 "shadd_operand" ""))
6270		 (match_operand:SI 1 "register_operand" "r")))]
6271  ""
6272  "{sh%o3addl %2,%1,%0|shladd,l %2,%o3,%1,%0} "
6273  [(set_attr "type" "binary")
6274   (set_attr "length" "4")])
6275
6276(define_insn ""
6277  [(set (match_operand:SI 0 "register_operand" "=r")
6278	(plus:SI (mult:SI (match_operand:SI 2 "register_operand" "r")
6279			  (match_operand:SI 3 "mem_shadd_operand" ""))
6280		 (match_operand:SI 1 "register_operand" "r")))]
6281  ""
6282  "*
6283{
6284  int shift_val = exact_log2 (INTVAL (operands[3]));
6285  operands[3] = GEN_INT (shift_val);
6286  return \"{sh%o3addl %2,%1,%0|shladd,l %2,%o3,%1,%0}\";
6287}"
6288  [(set_attr "type" "binary")
6289   (set_attr "length" "4")])
6290
6291(define_insn ""
6292  [(set (match_operand:DI 0 "register_operand" "=r")
6293	(plus:DI (ashift:DI (match_operand:DI 2 "register_operand" "r")
6294			    (match_operand:DI 3 "shadd_operand" ""))
6295		 (match_operand:DI 1 "register_operand" "r")))]
6296  "TARGET_64BIT"
6297  "shladd,l %2,%o3,%1,%0"
6298  [(set_attr "type" "binary")
6299   (set_attr "length" "4")])
6300
6301(define_insn ""
6302  [(set (match_operand:DI 0 "register_operand" "=r")
6303	(plus:DI (mult:DI (match_operand:DI 2 "register_operand" "r")
6304			  (match_operand:DI 3 "mem_shadd_operand" ""))
6305		 (match_operand:DI 1 "register_operand" "r")))]
6306  "TARGET_64BIT"
6307  "*
6308{
6309  int shift_val = exact_log2 (INTVAL (operands[3]));
6310  operands[3] = GEN_INT (shift_val);
6311  return \"shladd,l %2,%o3,%1,%0\";
6312}"
6313  [(set_attr "type" "binary")
6314   (set_attr "length" "4")])
6315
6316(define_expand "ashlsi3"
6317  [(set (match_operand:SI 0 "register_operand" "")
6318	(ashift:SI (match_operand:SI 1 "lhs_lshift_operand" "")
6319		   (match_operand:SI 2 "arith32_operand" "")))]
6320  ""
6321  "
6322{
6323  if (GET_CODE (operands[2]) != CONST_INT)
6324    {
6325      rtx temp = gen_reg_rtx (SImode);
6326      emit_insn (gen_subsi3 (temp, GEN_INT (31), operands[2]));
6327      if (GET_CODE (operands[1]) == CONST_INT)
6328	emit_insn (gen_zvdep_imm32 (operands[0], operands[1], temp));
6329      else
6330	emit_insn (gen_zvdep32 (operands[0], operands[1], temp));
6331      DONE;
6332    }
6333  /* Make sure both inputs are not constants,
6334     there are no patterns for that.  */
6335  operands[1] = force_reg (SImode, operands[1]);
6336}")
6337
6338(define_insn ""
6339  [(set (match_operand:SI 0 "register_operand" "=r")
6340	(ashift:SI (match_operand:SI 1 "register_operand" "r")
6341		   (match_operand:SI 2 "const_int_operand" "n")))]
6342  ""
6343  "{zdep|depw,z} %1,%P2,%L2,%0"
6344  [(set_attr "type" "shift")
6345   (set_attr "length" "4")])
6346
6347; Match cases of op1 a CONST_INT here that zvdep_imm32 doesn't handle.
6348; Doing it like this makes slightly better code since reload can
6349; replace a register with a known value in range -16..15 with a
6350; constant.  Ideally, we would like to merge zvdep32 and zvdep_imm32,
6351; but since we have no more CONST_OK... characters, that is not
6352; possible.
6353(define_insn "zvdep32"
6354  [(set (match_operand:SI 0 "register_operand" "=r,r")
6355	(ashift:SI (match_operand:SI 1 "arith5_operand" "r,L")
6356		   (minus:SI (const_int 31)
6357			     (match_operand:SI 2 "register_operand" "q,q"))))]
6358  ""
6359  "@
6360   {zvdep %1,32,%0|depw,z %1,%%sar,32,%0}
6361   {zvdepi %1,32,%0|depwi,z %1,%%sar,32,%0}"
6362  [(set_attr "type" "shift,shift")
6363   (set_attr "length" "4,4")])
6364
6365(define_insn "zvdep_imm32"
6366  [(set (match_operand:SI 0 "register_operand" "=r")
6367	(ashift:SI (match_operand:SI 1 "lhs_lshift_cint_operand" "")
6368		   (minus:SI (const_int 31)
6369			     (match_operand:SI 2 "register_operand" "q"))))]
6370  ""
6371  "*
6372{
6373  unsigned HOST_WIDE_INT x = UINTVAL (operands[1]);
6374  operands[2] = GEN_INT (4 + exact_log2 ((x >> 4) + 1));
6375  operands[1] = GEN_INT ((x & 0xf) - 0x10);
6376  return \"{zvdepi %1,%2,%0|depwi,z %1,%%sar,%2,%0}\";
6377}"
6378  [(set_attr "type" "shift")
6379   (set_attr "length" "4")])
6380
6381(define_insn "vdepi_ior"
6382  [(set (match_operand:SI 0 "register_operand" "=r")
6383	(ior:SI (ashift:SI (match_operand:SI 1 "const_int_operand" "")
6384			   (minus:SI (const_int 31)
6385				     (match_operand:SI 2 "register_operand" "q")))
6386		(match_operand:SI 3 "register_operand" "0")))]
6387  ; accept ...0001...1, can this be generalized?
6388  "exact_log2 (INTVAL (operands[1]) + 1) > 0"
6389  "*
6390{
6391  HOST_WIDE_INT x = INTVAL (operands[1]);
6392  operands[2] = GEN_INT (exact_log2 (x + 1));
6393  return \"{vdepi -1,%2,%0|depwi -1,%%sar,%2,%0}\";
6394}"
6395  [(set_attr "type" "shift")
6396   (set_attr "length" "4")])
6397
6398(define_insn "vdepi_and"
6399  [(set (match_operand:SI 0 "register_operand" "=r")
6400	(and:SI (rotate:SI (match_operand:SI 1 "const_int_operand" "")
6401			   (minus:SI (const_int 31)
6402				     (match_operand:SI 2 "register_operand" "q")))
6403		(match_operand:SI 3 "register_operand" "0")))]
6404  ; this can be generalized...!
6405  "INTVAL (operands[1]) == -2"
6406  "*
6407{
6408  HOST_WIDE_INT x = INTVAL (operands[1]);
6409  operands[2] = GEN_INT (exact_log2 ((~x) + 1));
6410  return \"{vdepi 0,%2,%0|depwi 0,%%sar,%2,%0}\";
6411}"
6412  [(set_attr "type" "shift")
6413   (set_attr "length" "4")])
6414
6415(define_expand "ashldi3"
6416  [(set (match_operand:DI 0 "register_operand" "")
6417	(ashift:DI (match_operand:DI 1 "lhs_lshift_operand" "")
6418		   (match_operand:DI 2 "arith32_operand" "")))]
6419  "TARGET_64BIT"
6420  "
6421{
6422  if (GET_CODE (operands[2]) != CONST_INT)
6423    {
6424      rtx temp = gen_reg_rtx (DImode);
6425      emit_insn (gen_subdi3 (temp, GEN_INT (63), operands[2]));
6426      if (GET_CODE (operands[1]) == CONST_INT)
6427	emit_insn (gen_zvdep_imm64 (operands[0], operands[1], temp));
6428      else
6429	emit_insn (gen_zvdep64 (operands[0], operands[1], temp));
6430      DONE;
6431    }
6432  /* Make sure both inputs are not constants,
6433     there are no patterns for that.  */
6434  operands[1] = force_reg (DImode, operands[1]);
6435}")
6436
6437(define_insn ""
6438  [(set (match_operand:DI 0 "register_operand" "=r")
6439	(ashift:DI (match_operand:DI 1 "register_operand" "r")
6440		   (match_operand:DI 2 "const_int_operand" "n")))]
6441  "TARGET_64BIT"
6442  "depd,z %1,%p2,%Q2,%0"
6443  [(set_attr "type" "shift")
6444   (set_attr "length" "4")])
6445
6446; Match cases of op1 a CONST_INT here that zvdep_imm64 doesn't handle.
6447; Doing it like this makes slightly better code since reload can
6448; replace a register with a known value in range -16..15 with a
6449; constant.  Ideally, we would like to merge zvdep64 and zvdep_imm64,
6450; but since we have no more CONST_OK... characters, that is not
6451; possible.
6452(define_insn "zvdep64"
6453  [(set (match_operand:DI 0 "register_operand" "=r,r")
6454	(ashift:DI (match_operand:DI 1 "arith5_operand" "r,L")
6455		   (minus:DI (const_int 63)
6456			     (match_operand:DI 2 "register_operand" "q,q"))))]
6457  "TARGET_64BIT"
6458  "@
6459   depd,z %1,%%sar,64,%0
6460   depdi,z %1,%%sar,64,%0"
6461  [(set_attr "type" "shift,shift")
6462   (set_attr "length" "4,4")])
6463
6464(define_insn "zvdep_imm64"
6465  [(set (match_operand:DI 0 "register_operand" "=r")
6466	(ashift:DI (match_operand:DI 1 "lhs_lshift_cint_operand" "")
6467		   (minus:DI (const_int 63)
6468			     (match_operand:DI 2 "register_operand" "q"))))]
6469  "TARGET_64BIT"
6470  "*
6471{
6472  unsigned HOST_WIDE_INT x = UINTVAL (operands[1]);
6473  operands[2] = GEN_INT (4 + exact_log2 ((x >> 4) + 1));
6474  operands[1] = GEN_INT ((x & 0x1f) - 0x20);
6475  return \"depdi,z %1,%%sar,%2,%0\";
6476}"
6477  [(set_attr "type" "shift")
6478   (set_attr "length" "4")])
6479
6480(define_insn ""
6481  [(set (match_operand:DI 0 "register_operand" "=r")
6482	(ior:DI (ashift:DI (match_operand:DI 1 "const_int_operand" "")
6483			   (minus:DI (const_int 63)
6484				     (match_operand:DI 2 "register_operand" "q")))
6485		(match_operand:DI 3 "register_operand" "0")))]
6486  ; accept ...0001...1, can this be generalized?
6487  "TARGET_64BIT && exact_log2 (INTVAL (operands[1]) + 1) > 0"
6488  "*
6489{
6490  HOST_WIDE_INT x = INTVAL (operands[1]);
6491  operands[2] = GEN_INT (exact_log2 (x + 1));
6492  return \"depdi -1,%%sar,%2,%0\";
6493}"
6494  [(set_attr "type" "shift")
6495   (set_attr "length" "4")])
6496
6497(define_insn ""
6498  [(set (match_operand:DI 0 "register_operand" "=r")
6499	(and:DI (rotate:DI (match_operand:DI 1 "const_int_operand" "")
6500			   (minus:DI (const_int 63)
6501				     (match_operand:DI 2 "register_operand" "q")))
6502		(match_operand:DI 3 "register_operand" "0")))]
6503  ; this can be generalized...!
6504  "TARGET_64BIT && INTVAL (operands[1]) == -2"
6505  "*
6506{
6507  HOST_WIDE_INT x = INTVAL (operands[1]);
6508  operands[2] = GEN_INT (exact_log2 ((~x) + 1));
6509  return \"depdi 0,%%sar,%2,%0\";
6510}"
6511  [(set_attr "type" "shift")
6512   (set_attr "length" "4")])
6513
6514(define_expand "ashrsi3"
6515  [(set (match_operand:SI 0 "register_operand" "")
6516	(ashiftrt:SI (match_operand:SI 1 "register_operand" "")
6517		     (match_operand:SI 2 "arith32_operand" "")))]
6518  ""
6519  "
6520{
6521  if (GET_CODE (operands[2]) != CONST_INT)
6522    {
6523      rtx temp = gen_reg_rtx (SImode);
6524      emit_insn (gen_subsi3 (temp, GEN_INT (31), operands[2]));
6525      emit_insn (gen_vextrs32 (operands[0], operands[1], temp));
6526      DONE;
6527    }
6528}")
6529
6530(define_insn ""
6531  [(set (match_operand:SI 0 "register_operand" "=r")
6532	(ashiftrt:SI (match_operand:SI 1 "register_operand" "r")
6533		     (match_operand:SI 2 "const_int_operand" "n")))]
6534  ""
6535  "{extrs|extrw,s} %1,%P2,%L2,%0"
6536  [(set_attr "type" "shift")
6537   (set_attr "length" "4")])
6538
6539(define_insn "vextrs32"
6540  [(set (match_operand:SI 0 "register_operand" "=r")
6541	(ashiftrt:SI (match_operand:SI 1 "register_operand" "r")
6542		     (minus:SI (const_int 31)
6543			       (match_operand:SI 2 "register_operand" "q"))))]
6544  ""
6545  "{vextrs %1,32,%0|extrw,s %1,%%sar,32,%0}"
6546  [(set_attr "type" "shift")
6547   (set_attr "length" "4")])
6548
6549(define_expand "ashrdi3"
6550  [(set (match_operand:DI 0 "register_operand" "")
6551	(ashiftrt:DI (match_operand:DI 1 "register_operand" "")
6552		     (match_operand:DI 2 "arith32_operand" "")))]
6553  "TARGET_64BIT"
6554  "
6555{
6556  if (GET_CODE (operands[2]) != CONST_INT)
6557    {
6558      rtx temp = gen_reg_rtx (DImode);
6559      emit_insn (gen_subdi3 (temp, GEN_INT (63), operands[2]));
6560      emit_insn (gen_vextrs64 (operands[0], operands[1], temp));
6561      DONE;
6562    }
6563}")
6564
6565(define_insn ""
6566  [(set (match_operand:DI 0 "register_operand" "=r")
6567	(ashiftrt:DI (match_operand:DI 1 "register_operand" "r")
6568		     (match_operand:DI 2 "const_int_operand" "n")))]
6569  "TARGET_64BIT"
6570  "extrd,s %1,%p2,%Q2,%0"
6571  [(set_attr "type" "shift")
6572   (set_attr "length" "4")])
6573
6574(define_insn "vextrs64"
6575  [(set (match_operand:DI 0 "register_operand" "=r")
6576	(ashiftrt:DI (match_operand:DI 1 "register_operand" "r")
6577		     (minus:DI (const_int 63)
6578			       (match_operand:DI 2 "register_operand" "q"))))]
6579  "TARGET_64BIT"
6580  "extrd,s %1,%%sar,64,%0"
6581  [(set_attr "type" "shift")
6582   (set_attr "length" "4")])
6583
6584(define_insn "lshrsi3"
6585  [(set (match_operand:SI 0 "register_operand" "=r,r")
6586	(lshiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
6587		     (match_operand:SI 2 "shift5_operand" "q,n")))]
6588  ""
6589  "@
6590   {vshd %%r0,%1,%0|shrpw %%r0,%1,%%sar,%0}
6591   {extru|extrw,u} %1,%P2,%L2,%0"
6592  [(set_attr "type" "shift")
6593   (set_attr "length" "4")])
6594
6595(define_insn "lshrdi3"
6596  [(set (match_operand:DI 0 "register_operand" "=r,r")
6597	(lshiftrt:DI (match_operand:DI 1 "register_operand" "r,r")
6598		     (match_operand:DI 2 "shift6_operand" "q,n")))]
6599  "TARGET_64BIT"
6600  "@
6601   shrpd %%r0,%1,%%sar,%0
6602   extrd,u %1,%p2,%Q2,%0"
6603  [(set_attr "type" "shift")
6604   (set_attr "length" "4")])
6605
6606; Shift right pair word 0 to 31 bits.
6607(define_insn "shrpsi4"
6608  [(set (match_operand:SI 0 "register_operand" "=r,r")
6609	(ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "r,r")
6610			   (minus:SI (const_int 32)
6611			     (match_operand:SI 3 "shift5_operand" "q,n")))
6612		(lshiftrt:SI (match_operand:SI 2 "register_operand" "r,r")
6613			     (match_dup 3))))]
6614  ""
6615  "@
6616   {vshd %1,%2,%0|shrpw %1,%2,%%sar,%0}
6617   {shd|shrpw} %1,%2,%3,%0"
6618  [(set_attr "type" "shift")
6619   (set_attr "length" "4")])
6620
6621; Shift right pair doubleword 0 to 63 bits.
6622(define_insn "shrpdi4"
6623  [(set (match_operand:DI 0 "register_operand" "=r,r")
6624	(ior:DI (ashift:DI (match_operand:SI 1 "register_operand" "r,r")
6625			   (minus:DI (const_int 64)
6626			     (match_operand:DI 3 "shift6_operand" "q,n")))
6627		(lshiftrt:DI (match_operand:DI 2 "register_operand" "r,r")
6628			     (match_dup 3))))]
6629  "TARGET_64BIT"
6630  "@
6631   shrpd %1,%2,%%sar,%0
6632   shrpd %1,%2,%3,%0"
6633  [(set_attr "type" "shift")
6634   (set_attr "length" "4")])
6635
6636(define_insn "rotrsi3"
6637  [(set (match_operand:SI 0 "register_operand" "=r,r")
6638	(rotatert:SI (match_operand:SI 1 "register_operand" "r,r")
6639		     (match_operand:SI 2 "shift5_operand" "q,n")))]
6640  ""
6641  "*
6642{
6643  if (GET_CODE (operands[2]) == CONST_INT)
6644    {
6645      operands[2] = GEN_INT (INTVAL (operands[2]) & 31);
6646      return \"{shd|shrpw} %1,%1,%2,%0\";
6647    }
6648  else
6649    return \"{vshd %1,%1,%0|shrpw %1,%1,%%sar,%0}\";
6650}"
6651  [(set_attr "type" "shift")
6652   (set_attr "length" "4")])
6653
6654(define_expand "rotlsi3"
6655  [(set (match_operand:SI 0 "register_operand" "")
6656        (rotate:SI (match_operand:SI 1 "register_operand" "")
6657                   (match_operand:SI 2 "arith32_operand" "")))]
6658  ""
6659  "
6660{
6661  if (GET_CODE (operands[2]) != CONST_INT)
6662    {
6663      rtx temp = gen_reg_rtx (SImode);
6664      emit_insn (gen_subsi3 (temp, GEN_INT (32), operands[2]));
6665      emit_insn (gen_rotrsi3 (operands[0], operands[1], temp));
6666      DONE;
6667    }
6668  /* Else expand normally.  */
6669}")
6670
6671(define_insn ""
6672  [(set (match_operand:SI 0 "register_operand" "=r")
6673        (rotate:SI (match_operand:SI 1 "register_operand" "r")
6674                   (match_operand:SI 2 "const_int_operand" "n")))]
6675  ""
6676  "*
6677{
6678  operands[2] = GEN_INT ((32 - INTVAL (operands[2])) & 31);
6679  return \"{shd|shrpw} %1,%1,%2,%0\";
6680}"
6681  [(set_attr "type" "shift")
6682   (set_attr "length" "4")])
6683
6684(define_insn ""
6685  [(set (match_operand:SI 0 "register_operand" "=r")
6686	(match_operator:SI 5 "plus_xor_ior_operator"
6687	  [(ashift:SI (match_operand:SI 1 "register_operand" "r")
6688		      (match_operand:SI 3 "const_int_operand" "n"))
6689	   (lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
6690			(match_operand:SI 4 "const_int_operand" "n"))]))]
6691  "INTVAL (operands[3]) + INTVAL (operands[4]) == 32"
6692  "{shd|shrpw} %1,%2,%4,%0"
6693  [(set_attr "type" "shift")
6694   (set_attr "length" "4")])
6695
6696(define_insn ""
6697  [(set (match_operand:SI 0 "register_operand" "=r")
6698	(match_operator:SI 5 "plus_xor_ior_operator"
6699	  [(lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
6700			(match_operand:SI 4 "const_int_operand" "n"))
6701	   (ashift:SI (match_operand:SI 1 "register_operand" "r")
6702		      (match_operand:SI 3 "const_int_operand" "n"))]))]
6703  "INTVAL (operands[3]) + INTVAL (operands[4]) == 32"
6704  "{shd|shrpw} %1,%2,%4,%0"
6705  [(set_attr "type" "shift")
6706   (set_attr "length" "4")])
6707
6708(define_insn ""
6709  [(set (match_operand:SI 0 "register_operand" "=r")
6710	(and:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
6711			   (match_operand:SI 2 "const_int_operand" ""))
6712		(match_operand:SI 3 "const_int_operand" "")))]
6713  "exact_log2 (1 + (INTVAL (operands[3]) >> (INTVAL (operands[2]) & 31))) > 0"
6714  "*
6715{
6716  int cnt = INTVAL (operands[2]) & 31;
6717  operands[3] = GEN_INT (exact_log2 (1 + (INTVAL (operands[3]) >> cnt)));
6718  operands[2] = GEN_INT (31 - cnt);
6719  return \"{zdep|depw,z} %1,%2,%3,%0\";
6720}"
6721  [(set_attr "type" "shift")
6722   (set_attr "length" "4")])
6723
6724;; Unconditional and other jump instructions.
6725
6726;; Trivial return used when no epilogue is needed.
6727(define_insn "return"
6728  [(return)
6729   (use (reg:SI 2))]
6730  "pa_can_use_return_insn ()"
6731  "*
6732{
6733  if (TARGET_PA_20)
6734    return \"bve%* (%%r2)\";
6735  return \"bv%* %%r0(%%r2)\";
6736}"
6737  [(set_attr "type" "branch")
6738   (set_attr "length" "4")])
6739
6740;; This is used for most returns.
6741(define_insn "return_internal"
6742  [(return)
6743   (use (reg:SI 2))]
6744  ""
6745  "*
6746{
6747  if (TARGET_PA_20)
6748    return \"bve%* (%%r2)\";
6749  return \"bv%* %%r0(%%r2)\";
6750}"
6751  [(set_attr "type" "branch")
6752   (set_attr "length" "4")])
6753
6754;; This is used for eh returns which bypass the return stub.
6755(define_insn "return_external_pic"
6756  [(return)
6757   (clobber (reg:SI 1))
6758   (use (reg:SI 2))]
6759  "!TARGET_NO_SPACE_REGS
6760   && !TARGET_PA_20
6761   && flag_pic && crtl->calls_eh_return"
6762  "ldsid (%%sr0,%%r2),%%r1\;mtsp %%r1,%%sr0\;be%* 0(%%sr0,%%r2)"
6763  [(set_attr "type" "branch")
6764   (set_attr "length" "12")])
6765
6766(define_expand "prologue"
6767  [(const_int 0)]
6768  ""
6769  "pa_expand_prologue ();DONE;")
6770
6771(define_expand "sibcall_epilogue"
6772  [(return)]
6773  ""
6774  "
6775{
6776  pa_expand_epilogue ();
6777  DONE;
6778}")
6779
6780(define_expand "epilogue"
6781  [(return)]
6782  ""
6783  "
6784{
6785  rtx x;
6786
6787  /* Try to use the trivial return first.  Else use the full epilogue.  */
6788  if (pa_can_use_return_insn ())
6789    x = gen_return ();
6790  else
6791    {
6792      pa_expand_epilogue ();
6793
6794      /* EH returns bypass the normal return stub.  Thus, we must do an
6795	 interspace branch to return from functions that call eh_return.
6796	 This is only a problem for returns from shared code on ports
6797	 using space registers.  */
6798      if (!TARGET_NO_SPACE_REGS
6799	  && !TARGET_PA_20
6800	  && flag_pic && crtl->calls_eh_return)
6801	x = gen_return_external_pic ();
6802      else
6803	x = gen_return_internal ();
6804    }
6805  emit_jump_insn (x);
6806  DONE;
6807}")
6808
6809; Used by hppa_profile_hook to load the starting address of the current
6810; function; operand 1 contains the address of the label in operand 3
6811(define_insn "load_offset_label_address"
6812  [(set (match_operand:SI 0 "register_operand" "=r")
6813        (plus:SI (match_operand:SI 1 "register_operand" "r")
6814		 (minus:SI (match_operand:SI 2 "" "")
6815			   (label_ref:SI (match_operand 3 "" "")))))]
6816  ""
6817  "ldo %2-%l3(%1),%0"
6818  [(set_attr "type" "multi")
6819   (set_attr "length" "4")])
6820
6821; Output a code label and load its address.
6822(define_insn "lcla1"
6823  [(set (match_operand:SI 0 "register_operand" "=r")
6824        (label_ref:SI (match_operand 1 "" "")))
6825   (const_int 0)]
6826  "!TARGET_PA_20"
6827  "*
6828{
6829  output_asm_insn (\"bl .+8,%0\;depi 0,31,2,%0\", operands);
6830  (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
6831                                     CODE_LABEL_NUMBER (operands[1]));
6832  return \"\";
6833}"
6834  [(set_attr "type" "multi")
6835   (set_attr "length" "8")])
6836
6837(define_insn "lcla2"
6838  [(set (match_operand:SI 0 "register_operand" "=r")
6839        (label_ref:SI (match_operand 1 "" "")))
6840   (const_int 0)]
6841  "TARGET_PA_20"
6842  "*
6843{
6844  (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
6845                                     CODE_LABEL_NUMBER (operands[1]));
6846  return \"mfia %0\";
6847}"
6848  [(set_attr "type" "move")
6849   (set_attr "length" "4")])
6850
6851(define_insn "blockage"
6852  [(unspec_volatile [(const_int 2)] UNSPECV_BLOCKAGE)]
6853  ""
6854  ""
6855  [(set_attr "length" "0")])
6856
6857(define_insn "jump"
6858  [(set (pc) (label_ref (match_operand 0 "" "")))]
6859  ""
6860  "*
6861{
6862  /* An unconditional branch which can reach its target.  */
6863  if (get_attr_length (insn) < 16)
6864    return \"b%* %l0\";
6865
6866  return pa_output_lbranch (operands[0], insn, 1);
6867}"
6868  [(set_attr "type" "uncond_branch")
6869   (set_attr "pa_combine_type" "uncond_branch")
6870   (set (attr "length")
6871    (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
6872	       (const_int MAX_17BIT_OFFSET))
6873	   (const_int 4)
6874	   (match_test "TARGET_PORTABLE_RUNTIME")
6875	   (const_int 20)
6876	   (not (match_test "flag_pic"))
6877	   (const_int 16)]
6878	  (const_int 24)))])
6879
6880;;; Hope this is only within a function...
6881(define_insn "indirect_jump"
6882  [(set (pc) (match_operand 0 "pmode_register_operand" "r"))]
6883  ""
6884  "bv%* %%r0(%0)"
6885  [(set_attr "type" "branch")
6886   (set_attr "length" "4")])
6887
6888;;; An indirect jump can be optimized to a direct jump.  GAS for the
6889;;; SOM target doesn't allow branching to a label inside a function.
6890;;; We also don't correctly compute branch distances for labels
6891;;; outside the current function.  Thus, we use an indirect jump can't
6892;;; be optimized to a direct jump for all targets.  We assume that
6893;;; the branch target is in the same space (i.e., nested function
6894;;; jumping to a label in an outer function in the same translation
6895;;; unit).
6896(define_expand "nonlocal_goto"
6897  [(use (match_operand 0 "general_operand" ""))
6898   (use (match_operand 1 "general_operand" ""))
6899   (use (match_operand 2 "general_operand" ""))
6900   (use (match_operand 3 "general_operand" ""))]
6901  ""
6902{
6903  rtx lab = operands[1];
6904  rtx stack = operands[2];
6905  rtx fp = operands[3];
6906
6907  emit_clobber (gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (VOIDmode)));
6908  emit_clobber (gen_rtx_MEM (BLKmode, hard_frame_pointer_rtx));
6909
6910  lab = copy_to_reg (lab);
6911
6912  /* Restore the stack and frame pointers.  The virtual_stack_vars_rtx
6913     is saved instead of the hard_frame_pointer_rtx in the save area.
6914     As a result, an extra instruction is needed to adjust for the offset
6915     of the virtual stack variables and the hard frame pointer.  */
6916  fp = copy_to_reg (fp);
6917  emit_stack_restore (SAVE_NONLOCAL, stack);
6918
6919  /* Ensure the frame pointer move is not optimized.  */
6920  emit_insn (gen_blockage ());
6921  emit_clobber (hard_frame_pointer_rtx);
6922  emit_clobber (frame_pointer_rtx);
6923  emit_move_insn (hard_frame_pointer_rtx, plus_constant (Pmode, fp, -8));
6924
6925  emit_use (hard_frame_pointer_rtx);
6926  emit_use (stack_pointer_rtx);
6927
6928  /* Nonlocal goto jumps are only used between functions in the same
6929     translation unit.  Thus, we can avoid the extra overhead of an
6930     interspace jump.  */
6931  emit_jump_insn (gen_indirect_goto (lab));
6932  emit_barrier ();
6933  DONE;
6934})
6935
6936(define_insn "indirect_goto"
6937  [(unspec [(match_operand 0 "register_operand" "=r")] UNSPEC_GOTO)]
6938  "GET_MODE (operands[0]) == word_mode"
6939  "bv%* %%r0(%0)"
6940  [(set_attr "type" "branch")
6941   (set_attr "length" "4")])
6942
6943;; Subroutines of "casesi".
6944;; operand 0 is index
6945;; operand 1 is the minimum bound
6946;; operand 2 is the maximum bound - minimum bound + 1
6947;; operand 3 is CODE_LABEL for the table;
6948;; operand 4 is the CODE_LABEL to go to if index out of range.
6949
6950(define_expand "casesi"
6951  [(match_operand:SI 0 "general_operand" "")
6952   (match_operand:SI 1 "const_int_operand" "")
6953   (match_operand:SI 2 "const_int_operand" "")
6954   (match_operand 3 "" "")
6955   (match_operand 4 "" "")]
6956  ""
6957  "
6958{
6959  if (GET_CODE (operands[0]) != REG)
6960    operands[0] = force_reg (SImode, operands[0]);
6961
6962  if (operands[1] != const0_rtx)
6963    {
6964      rtx index = gen_reg_rtx (SImode);
6965
6966      operands[1] = gen_int_mode (-INTVAL (operands[1]), SImode);
6967      if (!INT_14_BITS (operands[1]))
6968	operands[1] = force_reg (SImode, operands[1]);
6969      emit_insn (gen_addsi3 (index, operands[0], operands[1]));
6970      operands[0] = index;
6971    }
6972
6973  if (!INT_5_BITS (operands[2]))
6974    operands[2] = force_reg (SImode, operands[2]);
6975
6976  /* This branch prevents us finding an insn for the delay slot of the
6977     following vectored branch.  It might be possible to use the delay
6978     slot if an index value of -1 was used to transfer to the out-of-range
6979     label.  In order to do this, we would have to output the -1 vector
6980     element after the delay insn.  The casesi output code would have to
6981     check if the casesi insn is in a delay branch sequence and output
6982     the delay insn if one is found.  If this was done, then it might
6983     then be worthwhile to split the casesi patterns to improve scheduling.
6984     However, it's not clear that all this extra complexity is worth
6985     the effort.  */
6986  {
6987    rtx test = gen_rtx_GTU (VOIDmode, operands[0], operands[2]);
6988    emit_jump_insn (gen_cbranchsi4 (test, operands[0], operands[2], operands[4]));
6989  }
6990
6991  /* In 64bit mode we must make sure to wipe the upper bits of the register
6992     just in case the addition overflowed or we had random bits in the
6993     high part of the register.  */
6994  if (TARGET_64BIT)
6995    {
6996      rtx index = gen_reg_rtx (DImode);
6997
6998      emit_insn (gen_extendsidi2 (index, operands[0]));
6999      operands[0] = index;
7000    }
7001
7002  if (TARGET_64BIT)
7003    emit_jump_insn (gen_casesi64p (operands[0], operands[3]));
7004  else if (flag_pic)
7005    emit_jump_insn (gen_casesi32p (operands[0], operands[3]));
7006  else
7007    emit_jump_insn (gen_casesi32 (operands[0], operands[3]));
7008  DONE;
7009}")
7010
7011;;; 32-bit code, absolute branch table.
7012(define_insn "casesi32"
7013  [(set (pc) (mem:SI (plus:SI
7014		       (mult:SI (match_operand:SI 0 "register_operand" "r")
7015				(const_int 4))
7016		       (label_ref (match_operand 1 "" "")))))
7017   (clobber (match_scratch:SI 2 "=&r"))]
7018  "!flag_pic"
7019  "ldil L'%l1,%2\;ldo R'%l1(%2),%2\;{ldwx|ldw},s %0(%2),%2\;bv,n %%r0(%2)"
7020  [(set_attr "type" "multi")
7021   (set_attr "length" "16")])
7022
7023;;; 32-bit code, relative branch table.
7024(define_insn "casesi32p"
7025  [(set (pc) (mem:SI (plus:SI
7026		       (mult:SI (match_operand:SI 0 "register_operand" "r")
7027				(const_int 4))
7028		       (label_ref (match_operand 1 "" "")))))
7029   (clobber (match_scratch:SI 2 "=&r"))
7030   (clobber (match_scratch:SI 3 "=&r"))]
7031  "flag_pic"
7032  "{bl .+8,%2\;depi 0,31,2,%2|mfia %2}\;ldo {%l1-.|%l1+4-.}(%2),%2\;\
7033{ldwx|ldw},s %0(%2),%3\;{addl|add,l} %2,%3,%3\;bv,n %%r0(%3)"
7034  [(set_attr "type" "multi")
7035   (set (attr "length")
7036     (if_then_else (match_test "TARGET_PA_20")
7037	(const_int 20)
7038	(const_int 24)))])
7039
7040;;; 64-bit code, 32-bit relative branch table.
7041(define_insn "casesi64p"
7042  [(set (pc) (mem:DI (plus:DI
7043		       (mult:DI (match_operand:DI 0 "register_operand" "r")
7044				(const_int 8))
7045		       (label_ref (match_operand 1 "" "")))))
7046   (clobber (match_scratch:DI 2 "=&r"))
7047   (clobber (match_scratch:DI 3 "=&r"))]
7048  ""
7049  "mfia %2\;ldo %l1+4-.(%2),%2\;ldw,s %0(%2),%3\;extrd,s %3,63,32,%3\;\
7050add,l %2,%3,%3\;bv,n %%r0(%3)"
7051  [(set_attr "type" "multi")
7052   (set_attr "length" "24")])
7053
7054
7055;; Call patterns.
7056;;- jump to subroutine
7057
7058(define_expand "call"
7059  [(parallel [(call (match_operand:SI 0 "" "")
7060		    (match_operand 1 "" ""))
7061	      (clobber (reg:SI 2))])]
7062  ""
7063  "
7064{
7065  rtx op;
7066  rtx nb = operands[1];
7067
7068  if (TARGET_PORTABLE_RUNTIME)
7069    op = force_reg (SImode, XEXP (operands[0], 0));
7070  else
7071    {
7072      op = XEXP (operands[0], 0);
7073
7074      /* Generate indirect long calls to non-local functions. */
7075      if (TARGET_LONG_CALLS && GET_CODE (op) == SYMBOL_REF)
7076	{
7077	  tree call_decl = SYMBOL_REF_DECL (op);
7078	  if (!(call_decl && targetm.binds_local_p (call_decl)))
7079	    op = force_reg (word_mode, op);
7080	}
7081    }
7082
7083  if (TARGET_64BIT)
7084    {
7085      if (!virtuals_instantiated)
7086	emit_move_insn (arg_pointer_rtx,
7087			gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
7088				      GEN_INT (64)));
7089      else
7090	{
7091	  /* The loop pass can generate new libcalls after the virtual
7092	     registers are instantiated when fpregs are disabled because
7093	     the only method that we have for doing DImode multiplication
7094	     is with a libcall.  This could be trouble if we haven't
7095	     allocated enough space for the outgoing arguments.  */
7096	  gcc_assert (INTVAL (nb) <= crtl->outgoing_args_size);
7097
7098	  emit_move_insn (arg_pointer_rtx,
7099			  gen_rtx_PLUS (word_mode, stack_pointer_rtx,
7100					GEN_INT (STACK_POINTER_OFFSET + 64)));
7101	}
7102    }
7103
7104  /* Use two different patterns for calls to explicitly named functions
7105     and calls through function pointers.  This is necessary as these two
7106     types of calls use different calling conventions, and CSE might try
7107     to change the named call into an indirect call in some cases (using
7108     two patterns keeps CSE from performing this optimization).
7109
7110     We now use even more call patterns as there was a subtle bug in
7111     attempting to restore the pic register after a call using a simple
7112     move insn.  During reload, a instruction involving a pseudo register
7113     with no explicit dependence on the PIC register can be converted
7114     to an equivalent load from memory using the PIC register.  If we
7115     emit a simple move to restore the PIC register in the initial rtl
7116     generation, then it can potentially be repositioned during scheduling.
7117     and an instruction that eventually uses the PIC register may end up
7118     between the call and the PIC register restore.
7119
7120     This only worked because there is a post call group of instructions
7121     that are scheduled with the call.  These instructions are included
7122     in the same basic block as the call.  However, calls can throw in
7123     C++ code and a basic block has to terminate at the call if the call
7124     can throw.  This results in the PIC register restore being scheduled
7125     independently from the call.  So, we now hide the save and restore
7126     of the PIC register in the call pattern until after reload.  Then,
7127     we split the moves out.  A small side benefit is that we now don't
7128     need to have a use of the PIC register in the return pattern and
7129     the final save/restore operation is not needed.
7130
7131     I elected to just use register %r4 in the PIC patterns instead
7132     of trying to force hppa_pic_save_rtx () to a callee saved register.
7133     This might have required a new register class and constraint.  It
7134     was also simpler to just handle the restore from a register than a
7135     generic pseudo.  */
7136  if (TARGET_64BIT)
7137    {
7138      rtx r4 = gen_rtx_REG (word_mode, 4);
7139      if (GET_CODE (op) == SYMBOL_REF)
7140	emit_call_insn (gen_call_symref_64bit (op, nb, r4));
7141      else
7142	{
7143	  op = force_reg (word_mode, op);
7144	  emit_call_insn (gen_call_reg_64bit (op, nb, r4));
7145	}
7146    }
7147  else
7148    {
7149      if (GET_CODE (op) == SYMBOL_REF)
7150	{
7151	  if (flag_pic)
7152	    {
7153	      rtx r4 = gen_rtx_REG (word_mode, 4);
7154	      emit_call_insn (gen_call_symref_pic (op, nb, r4));
7155	    }
7156	  else
7157	    emit_call_insn (gen_call_symref (op, nb));
7158	}
7159      else
7160	{
7161	  rtx tmpreg = gen_rtx_REG (word_mode, 22);
7162	  emit_move_insn (tmpreg, force_reg (word_mode, op));
7163	  if (flag_pic)
7164	    {
7165	      rtx r4 = gen_rtx_REG (word_mode, 4);
7166	      emit_call_insn (gen_call_reg_pic (nb, r4));
7167	    }
7168	  else
7169	    emit_call_insn (gen_call_reg (nb));
7170	}
7171    }
7172
7173  DONE;
7174}")
7175
7176;; We use function calls to set the attribute length of calls and millicode
7177;; calls.  This is necessary because of the large variety of call sequences.
7178;; Implementing the calculation in rtl is difficult as well as ugly.  As
7179;; we need the same calculation in several places, maintenance becomes a
7180;; nightmare.
7181;;
7182;; However, this has a subtle impact on branch shortening.  When the
7183;; expression used to set the length attribute of an instruction depends
7184;; on a relative address (e.g., pc or a branch address), genattrtab
7185;; notes that the insn's length is variable, and attempts to determine a
7186;; worst-case default length and code to compute an insn's current length.
7187
7188;; The use of a function call hides the variable dependence of our calls
7189;; and millicode calls.  The result is genattrtab doesn't treat the operation
7190;; as variable and it only generates code for the default case using our
7191;; function call.  Because of this, calls and millicode calls have a fixed
7192;; length in the branch shortening pass, and some branches will use a longer
7193;; code sequence than necessary.  However, the length of any given call
7194;; will still reflect its final code location and it may be shorter than
7195;; the initial length estimate.
7196
7197;; It's possible to trick genattrtab by adding an expression involving `pc'
7198;; in the set.  However, when genattrtab hits a function call in its attempt
7199;; to compute the default length, it marks the result as unknown and sets
7200;; the default result to MAX_INT ;-(  One possible fix that would allow
7201;; calls to participate in branch shortening would be to make the call to
7202;; insn_default_length a target option.  Then, we could massage unknown
7203;; results.  Another fix might be to change genattrtab so that it just does
7204;; the call in the variable case as it already does for the fixed case.
7205
7206(define_insn "call_symref"
7207  [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7208	 (match_operand 1 "" "i"))
7209   (clobber (reg:SI 1))
7210   (clobber (reg:SI 2))
7211   (use (const_int 0))]
7212  "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7213  "*
7214{
7215  pa_output_arg_descriptor (insn);
7216  return pa_output_call (insn, operands[0], 0);
7217}"
7218  [(set_attr "type" "call")
7219   (set (attr "length")
7220	(cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7221	      (symbol_ref "pa_attr_length_call (insn, 0)")))])
7222
7223(define_insn "call_symref_pic"
7224  [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7225	 (match_operand 1 "" "i"))
7226   (clobber (reg:SI 1))
7227   (clobber (reg:SI 2))
7228   (clobber (match_operand 2))
7229   (use (reg:SI 19))
7230   (use (const_int 0))]
7231  "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7232  "#")
7233
7234;; Split out the PIC register save and restore after reload.  As the
7235;; split is done after reload, there are some situations in which we
7236;; unnecessarily save and restore %r4.  This happens when there is a
7237;; single call and the PIC register is not used after the call.
7238;;
7239;; The split has to be done since call_from_call_insn () can't handle
7240;; the pattern as is.  Noreturn calls are special because they have to
7241;; terminate the basic block.  The split has to contain more than one
7242;; insn.
7243(define_split
7244  [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7245		    (match_operand 1 "" ""))
7246	      (clobber (reg:SI 1))
7247	      (clobber (reg:SI 2))
7248	      (clobber (match_operand 2))
7249	      (use (reg:SI 19))
7250	      (use (const_int 0))])]
7251  "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed
7252   && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7253  [(set (match_dup 2) (reg:SI 19))
7254   (parallel [(call (mem:SI (match_dup 0))
7255		    (match_dup 1))
7256	      (clobber (reg:SI 1))
7257	      (clobber (reg:SI 2))
7258	      (use (reg:SI 19))
7259	      (use (const_int 0))])]
7260  "")
7261
7262(define_split
7263  [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7264		    (match_operand 1 "" ""))
7265	      (clobber (reg:SI 1))
7266	      (clobber (reg:SI 2))
7267	      (clobber (match_operand 2))
7268	      (use (reg:SI 19))
7269	      (use (const_int 0))])]
7270  "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
7271  [(set (match_dup 2) (reg:SI 19))
7272   (parallel [(call (mem:SI (match_dup 0))
7273		    (match_dup 1))
7274	      (clobber (reg:SI 1))
7275	      (clobber (reg:SI 2))
7276	      (use (reg:SI 19))
7277	      (use (const_int 0))])
7278   (set (reg:SI 19) (match_dup 2))]
7279  "")
7280
7281(define_insn "*call_symref_pic_post_reload"
7282  [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7283	 (match_operand 1 "" "i"))
7284   (clobber (reg:SI 1))
7285   (clobber (reg:SI 2))
7286   (use (reg:SI 19))
7287   (use (const_int 0))]
7288  "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7289  "*
7290{
7291  pa_output_arg_descriptor (insn);
7292  return pa_output_call (insn, operands[0], 0);
7293}"
7294  [(set_attr "type" "call")
7295   (set (attr "length")
7296	(cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7297	      (symbol_ref "pa_attr_length_call (insn, 0)")))])
7298
7299;; This pattern is split if it is necessary to save and restore the
7300;; PIC register.
7301(define_insn "call_symref_64bit"
7302  [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7303	 (match_operand 1 "" "i"))
7304   (clobber (reg:DI 1))
7305   (clobber (reg:DI 2))
7306   (clobber (match_operand 2))
7307   (use (reg:DI 27))
7308   (use (reg:DI 29))
7309   (use (const_int 0))]
7310  "TARGET_64BIT"
7311  "#")
7312
7313;; Split out the PIC register save and restore after reload.  As the
7314;; split is done after reload, there are some situations in which we
7315;; unnecessarily save and restore %r4.  This happens when there is a
7316;; single call and the PIC register is not used after the call.
7317;;
7318;; The split has to be done since call_from_call_insn () can't handle
7319;; the pattern as is.  Noreturn calls are special because they have to
7320;; terminate the basic block.  The split has to contain more than one
7321;; insn.
7322(define_split
7323  [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7324		    (match_operand 1 "" ""))
7325	      (clobber (reg:DI 1))
7326	      (clobber (reg:DI 2))
7327	      (clobber (match_operand 2))
7328	      (use (reg:DI 27))
7329	      (use (reg:DI 29))
7330	      (use (const_int 0))])]
7331  "TARGET_64BIT && reload_completed
7332   && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7333  [(set (match_dup 2) (reg:DI 27))
7334   (parallel [(call (mem:SI (match_dup 0))
7335		    (match_dup 1))
7336	      (clobber (reg:DI 1))
7337	      (clobber (reg:DI 2))
7338	      (use (reg:DI 27))
7339	      (use (reg:DI 29))
7340	      (use (const_int 0))])]
7341  "")
7342
7343(define_split
7344  [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7345		    (match_operand 1 "" ""))
7346	      (clobber (reg:DI 1))
7347	      (clobber (reg:DI 2))
7348	      (clobber (match_operand 2))
7349	      (use (reg:DI 27))
7350	      (use (reg:DI 29))
7351	      (use (const_int 0))])]
7352  "TARGET_64BIT && reload_completed"
7353  [(set (match_dup 2) (reg:DI 27))
7354   (parallel [(call (mem:SI (match_dup 0))
7355		    (match_dup 1))
7356	      (clobber (reg:DI 1))
7357	      (clobber (reg:DI 2))
7358	      (use (reg:DI 27))
7359	      (use (reg:DI 29))
7360	      (use (const_int 0))])
7361   (set (reg:DI 27) (match_dup 2))]
7362  "")
7363
7364(define_insn "*call_symref_64bit_post_reload"
7365  [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7366	 (match_operand 1 "" "i"))
7367   (clobber (reg:DI 1))
7368   (clobber (reg:DI 2))
7369   (use (reg:DI 27))
7370   (use (reg:DI 29))
7371   (use (const_int 0))]
7372  "TARGET_64BIT"
7373  "*
7374{
7375  return pa_output_call (insn, operands[0], 0);
7376}"
7377  [(set_attr "type" "call")
7378   (set (attr "length")
7379	(cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7380	      (symbol_ref "pa_attr_length_call (insn, 0)")))])
7381
7382(define_insn "call_reg"
7383  [(call (mem:SI (reg:SI 22))
7384	 (match_operand 0 "" "i"))
7385   (clobber (reg:SI 1))
7386   (clobber (reg:SI 2))
7387   (use (const_int 1))]
7388  "!TARGET_64BIT"
7389  "*
7390{
7391  return pa_output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
7392}"
7393  [(set_attr "type" "dyncall")
7394   (set (attr "length")
7395	(cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7396	      (symbol_ref "pa_attr_length_indirect_call (insn)")))])
7397
7398;; This pattern is split if it is necessary to save and restore the
7399;; PIC register.
7400(define_insn "call_reg_pic"
7401  [(call (mem:SI (reg:SI 22))
7402	 (match_operand 0 "" "i"))
7403   (clobber (reg:SI 1))
7404   (clobber (reg:SI 2))
7405   (clobber (match_operand 1))
7406   (use (reg:SI 19))
7407   (use (const_int 1))]
7408  "!TARGET_64BIT"
7409  "#")
7410
7411;; Split out the PIC register save and restore after reload.  As the
7412;; split is done after reload, there are some situations in which we
7413;; unnecessarily save and restore %r4.  This happens when there is a
7414;; single call and the PIC register is not used after the call.
7415;;
7416;; The split has to be done since call_from_call_insn () can't handle
7417;; the pattern as is.  Noreturn calls are special because they have to
7418;; terminate the basic block.  The split has to contain more than one
7419;; insn.
7420(define_split
7421  [(parallel [(call (mem:SI (reg:SI 22))
7422		    (match_operand 0 "" ""))
7423	      (clobber (reg:SI 1))
7424	      (clobber (reg:SI 2))
7425	      (clobber (match_operand 1))
7426	      (use (reg:SI 19))
7427	      (use (const_int 1))])]
7428  "!TARGET_64BIT && reload_completed
7429   && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7430  [(set (match_dup 1) (reg:SI 19))
7431   (parallel [(call (mem:SI (reg:SI 22))
7432		    (match_dup 0))
7433	      (clobber (reg:SI 1))
7434	      (clobber (reg:SI 2))
7435	      (use (reg:SI 19))
7436	      (use (const_int 1))])]
7437  "")
7438
7439(define_split
7440  [(parallel [(call (mem:SI (reg:SI 22))
7441		    (match_operand 0 "" ""))
7442	      (clobber (reg:SI 1))
7443	      (clobber (reg:SI 2))
7444	      (clobber (match_operand 1))
7445	      (use (reg:SI 19))
7446	      (use (const_int 1))])]
7447  "!TARGET_64BIT && reload_completed"
7448  [(set (match_dup 1) (reg:SI 19))
7449   (parallel [(call (mem:SI (reg:SI 22))
7450		    (match_dup 0))
7451	      (clobber (reg:SI 1))
7452	      (clobber (reg:SI 2))
7453	      (use (reg:SI 19))
7454	      (use (const_int 1))])
7455   (set (reg:SI 19) (match_dup 1))]
7456  "")
7457
7458(define_insn "*call_reg_pic_post_reload"
7459  [(call (mem:SI (reg:SI 22))
7460	 (match_operand 0 "" "i"))
7461   (clobber (reg:SI 1))
7462   (clobber (reg:SI 2))
7463   (use (reg:SI 19))
7464   (use (const_int 1))]
7465  "!TARGET_64BIT"
7466  "*
7467{
7468  return pa_output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
7469}"
7470  [(set_attr "type" "dyncall")
7471   (set (attr "length")
7472	(cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7473	      (symbol_ref "pa_attr_length_indirect_call (insn)")))])
7474
7475;; This pattern is split if it is necessary to save and restore the
7476;; PIC register.
7477(define_insn "call_reg_64bit"
7478  [(call (mem:SI (match_operand:DI 0 "register_operand" "r"))
7479	 (match_operand 1 "" "i"))
7480   (clobber (reg:DI 2))
7481   (clobber (match_operand 2))
7482   (use (reg:DI 27))
7483   (use (reg:DI 29))
7484   (use (const_int 1))]
7485  "TARGET_64BIT"
7486  "#")
7487
7488;; Split out the PIC register save and restore after reload.  As the
7489;; split is done after reload, there are some situations in which we
7490;; unnecessarily save and restore %r4.  This happens when there is a
7491;; single call and the PIC register is not used after the call.
7492;;
7493;; The split has to be done since call_from_call_insn () can't handle
7494;; the pattern as is.  Noreturn calls are special because they have to
7495;; terminate the basic block.  The split has to contain more than one
7496;; insn.
7497(define_split
7498  [(parallel [(call (mem:SI (match_operand 0 "register_operand" ""))
7499		    (match_operand 1 "" ""))
7500	      (clobber (reg:DI 2))
7501	      (clobber (match_operand 2))
7502	      (use (reg:DI 27))
7503	      (use (reg:DI 29))
7504	      (use (const_int 1))])]
7505  "TARGET_64BIT && reload_completed
7506   && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7507  [(set (match_dup 2) (reg:DI 27))
7508   (parallel [(call (mem:SI (match_dup 0))
7509		    (match_dup 1))
7510	      (clobber (reg:DI 2))
7511	      (use (reg:DI 27))
7512	      (use (reg:DI 29))
7513	      (use (const_int 1))])]
7514  "")
7515
7516(define_split
7517  [(parallel [(call (mem:SI (match_operand 0 "register_operand" ""))
7518		    (match_operand 1 "" ""))
7519	      (clobber (reg:DI 2))
7520	      (clobber (match_operand 2))
7521	      (use (reg:DI 27))
7522	      (use (reg:DI 29))
7523	      (use (const_int 1))])]
7524  "TARGET_64BIT && reload_completed"
7525  [(set (match_dup 2) (reg:DI 27))
7526   (parallel [(call (mem:SI (match_dup 0))
7527		    (match_dup 1))
7528	      (clobber (reg:DI 2))
7529	      (use (reg:DI 27))
7530	      (use (reg:DI 29))
7531	      (use (const_int 1))])
7532   (set (reg:DI 27) (match_dup 2))]
7533  "")
7534
7535(define_insn "*call_reg_64bit_post_reload"
7536  [(call (mem:SI (match_operand:DI 0 "register_operand" "r"))
7537	 (match_operand 1 "" "i"))
7538   (clobber (reg:DI 2))
7539   (use (reg:DI 27))
7540   (use (reg:DI 29))
7541   (use (const_int 1))]
7542  "TARGET_64BIT"
7543  "*
7544{
7545  return pa_output_indirect_call (insn, operands[0]);
7546}"
7547  [(set_attr "type" "dyncall")
7548   (set (attr "length")
7549	(cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 12)]
7550	      (symbol_ref "pa_attr_length_indirect_call (insn)")))])
7551
7552(define_expand "call_value"
7553  [(parallel [(set (match_operand 0 "" "")
7554		   (call (match_operand:SI 1 "" "")
7555			 (match_operand 2 "" "")))
7556	      (clobber (reg:SI 2))])]
7557  ""
7558{
7559  rtx op;
7560  rtx dst = operands[0];
7561  rtx nb = operands[2];
7562  bool call_powf = false;
7563
7564  if (TARGET_PORTABLE_RUNTIME)
7565    op = force_reg (SImode, XEXP (operands[1], 0));
7566  else
7567    {
7568      op = XEXP (operands[1], 0);
7569      if (GET_CODE (op) == SYMBOL_REF)
7570	{
7571	  /* Handle special call to buggy powf function.  */
7572	  if (TARGET_HPUX && !TARGET_DISABLE_FPREGS && !TARGET_SOFT_FLOAT
7573	      && !strcmp (targetm.strip_name_encoding (XSTR (op, 0)), "powf"))
7574	    call_powf = true;
7575
7576	  /* Generate indirect long calls to non-local functions. */
7577	  else if (TARGET_LONG_CALLS)
7578	    {
7579	      tree call_decl = SYMBOL_REF_DECL (op);
7580	      if (!(call_decl && targetm.binds_local_p (call_decl)))
7581		op = force_reg (word_mode, op);
7582	    }
7583	}
7584    }
7585
7586  if (TARGET_64BIT)
7587    {
7588      if (!virtuals_instantiated)
7589	emit_move_insn (arg_pointer_rtx,
7590			gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
7591				      GEN_INT (64)));
7592      else
7593	{
7594	  /* The loop pass can generate new libcalls after the virtual
7595	     registers are instantiated when fpregs are disabled because
7596	     the only method that we have for doing DImode multiplication
7597	     is with a libcall.  This could be trouble if we haven't
7598	     allocated enough space for the outgoing arguments.  */
7599	  gcc_assert (INTVAL (nb) <= crtl->outgoing_args_size);
7600
7601	  emit_move_insn (arg_pointer_rtx,
7602			  gen_rtx_PLUS (word_mode, stack_pointer_rtx,
7603					GEN_INT (STACK_POINTER_OFFSET + 64)));
7604	}
7605    }
7606
7607  /* Use two different patterns for calls to explicitly named functions
7608     and calls through function pointers.  This is necessary as these two
7609     types of calls use different calling conventions, and CSE might try
7610     to change the named call into an indirect call in some cases (using
7611     two patterns keeps CSE from performing this optimization).
7612
7613     We now use even more call patterns as there was a subtle bug in
7614     attempting to restore the pic register after a call using a simple
7615     move insn.  During reload, a instruction involving a pseudo register
7616     with no explicit dependence on the PIC register can be converted
7617     to an equivalent load from memory using the PIC register.  If we
7618     emit a simple move to restore the PIC register in the initial rtl
7619     generation, then it can potentially be repositioned during scheduling.
7620     and an instruction that eventually uses the PIC register may end up
7621     between the call and the PIC register restore.
7622
7623     This only worked because there is a post call group of instructions
7624     that are scheduled with the call.  These instructions are included
7625     in the same basic block as the call.  However, calls can throw in
7626     C++ code and a basic block has to terminate at the call if the call
7627     can throw.  This results in the PIC register restore being scheduled
7628     independently from the call.  So, we now hide the save and restore
7629     of the PIC register in the call pattern until after reload.  Then,
7630     we split the moves out.  A small side benefit is that we now don't
7631     need to have a use of the PIC register in the return pattern and
7632     the final save/restore operation is not needed.
7633
7634     I elected to just use register %r4 in the PIC patterns instead
7635     of trying to force hppa_pic_save_rtx () to a callee saved register.
7636     This might have required a new register class and constraint.  It
7637     was also simpler to just handle the restore from a register than a
7638     generic pseudo.  */
7639  if (TARGET_64BIT)
7640    {
7641      rtx r4 = gen_rtx_REG (word_mode, 4);
7642      if (GET_CODE (op) == SYMBOL_REF)
7643	{
7644	  if (call_powf)
7645	    emit_call_insn (gen_call_val_powf_64bit (dst, op, nb, r4));
7646	  else
7647	    emit_call_insn (gen_call_val_symref_64bit (dst, op, nb, r4));
7648	}
7649      else
7650	{
7651	  op = force_reg (word_mode, op);
7652	  emit_call_insn (gen_call_val_reg_64bit (dst, op, nb, r4));
7653	}
7654    }
7655  else
7656    {
7657      if (GET_CODE (op) == SYMBOL_REF)
7658	{
7659	  if (flag_pic)
7660	    {
7661	      rtx r4 = gen_rtx_REG (word_mode, 4);
7662
7663	      if (call_powf)
7664		emit_call_insn (gen_call_val_powf_pic (dst, op, nb, r4));
7665	      else
7666		emit_call_insn (gen_call_val_symref_pic (dst, op, nb, r4));
7667	    }
7668	  else
7669	    {
7670	      if (call_powf)
7671		emit_call_insn (gen_call_val_powf (dst, op, nb));
7672	      else
7673		emit_call_insn (gen_call_val_symref (dst, op, nb));
7674	    }
7675	}
7676      else
7677	{
7678	  rtx tmpreg = gen_rtx_REG (word_mode, 22);
7679	  emit_move_insn (tmpreg, force_reg (word_mode, op));
7680	  if (flag_pic)
7681	    {
7682	      rtx r4 = gen_rtx_REG (word_mode, 4);
7683	      emit_call_insn (gen_call_val_reg_pic (dst, nb, r4));
7684	    }
7685	  else
7686	    emit_call_insn (gen_call_val_reg (dst, nb));
7687	}
7688    }
7689
7690  DONE;
7691})
7692
7693(define_insn "call_val_symref"
7694  [(set (match_operand 0 "" "")
7695	(call (mem:SI (match_operand 1 "call_operand_address" ""))
7696	      (match_operand 2 "" "i")))
7697   (clobber (reg:SI 1))
7698   (clobber (reg:SI 2))
7699   (use (const_int 0))]
7700  "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7701  "*
7702{
7703  pa_output_arg_descriptor (insn);
7704  return pa_output_call (insn, operands[1], 0);
7705}"
7706  [(set_attr "type" "call")
7707   (set (attr "length")
7708	(cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7709	      (symbol_ref "pa_attr_length_call (insn, 0)")))])
7710
7711;; powf function clobbers %fr12
7712(define_insn "call_val_powf"
7713  [(set (match_operand 0 "" "")
7714	(call (mem:SI (match_operand 1 "call_operand_address" ""))
7715	      (match_operand 2 "" "i")))
7716   (clobber (reg:SI 1))
7717   (clobber (reg:SI 2))
7718   (clobber (reg:DF 48))
7719   (use (const_int 1))]
7720  "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7721  "*
7722{
7723  pa_output_arg_descriptor (insn);
7724  return pa_output_call (insn, operands[1], 0);
7725}"
7726  [(set_attr "type" "call")
7727   (set (attr "length")
7728	(cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7729	      (symbol_ref "pa_attr_length_call (insn, 0)")))])
7730
7731(define_insn "call_val_symref_pic"
7732  [(set (match_operand 0 "" "")
7733	(call (mem:SI (match_operand 1 "call_operand_address" ""))
7734	      (match_operand 2 "" "i")))
7735   (clobber (reg:SI 1))
7736   (clobber (reg:SI 2))
7737   (clobber (match_operand 3))
7738   (use (reg:SI 19))
7739   (use (const_int 0))]
7740  "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7741  "#")
7742
7743;; Split out the PIC register save and restore after reload.  As the
7744;; split is done after reload, there are some situations in which we
7745;; unnecessarily save and restore %r4.  This happens when there is a
7746;; single call and the PIC register is not used after the call.
7747;;
7748;; The split has to be done since call_from_call_insn () can't handle
7749;; the pattern as is.  Noreturn calls are special because they have to
7750;; terminate the basic block.  The split has to contain more than one
7751;; insn.
7752(define_split
7753  [(parallel [(set (match_operand 0 "" "")
7754	      (call (mem:SI (match_operand 1 "call_operand_address" ""))
7755		    (match_operand 2 "" "")))
7756	      (clobber (reg:SI 1))
7757	      (clobber (reg:SI 2))
7758	      (clobber (match_operand 3))
7759	      (use (reg:SI 19))
7760	      (use (const_int 0))])]
7761  "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed
7762   && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7763  [(set (match_dup 3) (reg:SI 19))
7764   (parallel [(set (match_dup 0)
7765	      (call (mem:SI (match_dup 1))
7766		    (match_dup 2)))
7767	      (clobber (reg:SI 1))
7768	      (clobber (reg:SI 2))
7769	      (use (reg:SI 19))
7770	      (use (const_int 0))])]
7771  "")
7772
7773(define_split
7774  [(parallel [(set (match_operand 0 "" "")
7775	      (call (mem:SI (match_operand 1 "call_operand_address" ""))
7776		    (match_operand 2 "" "")))
7777	      (clobber (reg:SI 1))
7778	      (clobber (reg:SI 2))
7779	      (clobber (match_operand 3))
7780	      (use (reg:SI 19))
7781	      (use (const_int 0))])]
7782  "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
7783  [(set (match_dup 3) (reg:SI 19))
7784   (parallel [(set (match_dup 0)
7785	      (call (mem:SI (match_dup 1))
7786		    (match_dup 2)))
7787	      (clobber (reg:SI 1))
7788	      (clobber (reg:SI 2))
7789	      (use (reg:SI 19))
7790	      (use (const_int 0))])
7791   (set (reg:SI 19) (match_dup 3))]
7792  "")
7793
7794(define_insn "*call_val_symref_pic_post_reload"
7795  [(set (match_operand 0 "" "")
7796	(call (mem:SI (match_operand 1 "call_operand_address" ""))
7797	      (match_operand 2 "" "i")))
7798   (clobber (reg:SI 1))
7799   (clobber (reg:SI 2))
7800   (use (reg:SI 19))
7801   (use (const_int 0))]
7802  "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7803  "*
7804{
7805  pa_output_arg_descriptor (insn);
7806  return pa_output_call (insn, operands[1], 0);
7807}"
7808  [(set_attr "type" "call")
7809   (set (attr "length")
7810	(cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7811	      (symbol_ref "pa_attr_length_call (insn, 0)")))])
7812
7813;; powf function clobbers %fr12
7814(define_insn "call_val_powf_pic"
7815  [(set (match_operand 0 "" "")
7816	(call (mem:SI (match_operand 1 "call_operand_address" ""))
7817	      (match_operand 2 "" "i")))
7818   (clobber (reg:SI 1))
7819   (clobber (reg:SI 2))
7820   (clobber (reg:DF 48))
7821   (clobber (match_operand 3))
7822   (use (reg:SI 19))
7823   (use (const_int 1))]
7824  "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7825  "#")
7826
7827;; Split out the PIC register save and restore after reload.  As the
7828;; split is done after reload, there are some situations in which we
7829;; unnecessarily save and restore %r4.  This happens when there is a
7830;; single call and the PIC register is not used after the call.
7831;;
7832;; The split has to be done since call_from_call_insn () can't handle
7833;; the pattern as is.  Noreturn calls are special because they have to
7834;; terminate the basic block.  The split has to contain more than one
7835;; insn.
7836(define_split
7837  [(parallel [(set (match_operand 0 "" "")
7838	      (call (mem:SI (match_operand 1 "call_operand_address" ""))
7839		    (match_operand 2 "" "")))
7840	      (clobber (reg:SI 1))
7841	      (clobber (reg:SI 2))
7842	      (clobber (reg:DF 48))
7843	      (clobber (match_operand 3))
7844	      (use (reg:SI 19))
7845	      (use (const_int 1))])]
7846  "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed
7847   && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7848  [(set (match_dup 3) (reg:SI 19))
7849   (parallel [(set (match_dup 0)
7850	      (call (mem:SI (match_dup 1))
7851		    (match_dup 2)))
7852	      (clobber (reg:SI 1))
7853	      (clobber (reg:SI 2))
7854	      (clobber (reg:DF 48))
7855	      (use (reg:SI 19))
7856	      (use (const_int 1))])]
7857  "")
7858
7859(define_split
7860  [(parallel [(set (match_operand 0 "" "")
7861	      (call (mem:SI (match_operand 1 "call_operand_address" ""))
7862		    (match_operand 2 "" "")))
7863	      (clobber (reg:SI 1))
7864	      (clobber (reg:SI 2))
7865	      (clobber (reg:DF 48))
7866	      (clobber (match_operand 3))
7867	      (use (reg:SI 19))
7868	      (use (const_int 1))])]
7869  "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
7870  [(set (match_dup 3) (reg:SI 19))
7871   (parallel [(set (match_dup 0)
7872	      (call (mem:SI (match_dup 1))
7873		    (match_dup 2)))
7874	      (clobber (reg:SI 1))
7875	      (clobber (reg:SI 2))
7876	      (clobber (reg:DF 48))
7877	      (use (reg:SI 19))
7878	      (use (const_int 1))])
7879   (set (reg:SI 19) (match_dup 3))]
7880  "")
7881
7882(define_insn "*call_val_powf_pic_post_reload"
7883  [(set (match_operand 0 "" "")
7884	(call (mem:SI (match_operand 1 "call_operand_address" ""))
7885	      (match_operand 2 "" "i")))
7886   (clobber (reg:SI 1))
7887   (clobber (reg:SI 2))
7888   (clobber (reg:DF 48))
7889   (use (reg:SI 19))
7890   (use (const_int 1))]
7891  "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7892  "*
7893{
7894  pa_output_arg_descriptor (insn);
7895  return pa_output_call (insn, operands[1], 0);
7896}"
7897  [(set_attr "type" "call")
7898   (set (attr "length")
7899	(cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7900	      (symbol_ref "pa_attr_length_call (insn, 0)")))])
7901
7902;; This pattern is split if it is necessary to save and restore the
7903;; PIC register.
7904(define_insn "call_val_symref_64bit"
7905  [(set (match_operand 0 "" "")
7906	(call (mem:SI (match_operand 1 "call_operand_address" ""))
7907	      (match_operand 2 "" "i")))
7908   (clobber (reg:DI 1))
7909   (clobber (reg:DI 2))
7910   (clobber (match_operand 3))
7911   (use (reg:DI 27))
7912   (use (reg:DI 29))
7913   (use (const_int 0))]
7914  "TARGET_64BIT"
7915  "#")
7916
7917;; Split out the PIC register save and restore after reload.  As the
7918;; split is done after reload, there are some situations in which we
7919;; unnecessarily save and restore %r4.  This happens when there is a
7920;; single call and the PIC register is not used after the call.
7921;;
7922;; The split has to be done since call_from_call_insn () can't handle
7923;; the pattern as is.  Noreturn calls are special because they have to
7924;; terminate the basic block.  The split has to contain more than one
7925;; insn.
7926(define_split
7927  [(parallel [(set (match_operand 0 "" "")
7928	      (call (mem:SI (match_operand 1 "call_operand_address" ""))
7929		    (match_operand 2 "" "")))
7930	      (clobber (reg:DI 1))
7931	      (clobber (reg:DI 2))
7932	      (clobber (match_operand 3))
7933	      (use (reg:DI 27))
7934	      (use (reg:DI 29))
7935	      (use (const_int 0))])]
7936  "TARGET_64BIT && reload_completed
7937   && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7938  [(set (match_dup 3) (reg:DI 27))
7939   (parallel [(set (match_dup 0)
7940	      (call (mem:SI (match_dup 1))
7941		    (match_dup 2)))
7942	      (clobber (reg:DI 1))
7943	      (clobber (reg:DI 2))
7944	      (use (reg:DI 27))
7945	      (use (reg:DI 29))
7946	      (use (const_int 0))])]
7947  "")
7948
7949(define_split
7950  [(parallel [(set (match_operand 0 "" "")
7951	      (call (mem:SI (match_operand 1 "call_operand_address" ""))
7952		    (match_operand 2 "" "")))
7953	      (clobber (reg:DI 1))
7954	      (clobber (reg:DI 2))
7955	      (clobber (match_operand 3))
7956	      (use (reg:DI 27))
7957	      (use (reg:DI 29))
7958	      (use (const_int 0))])]
7959  "TARGET_64BIT && reload_completed"
7960  [(set (match_dup 3) (reg:DI 27))
7961   (parallel [(set (match_dup 0)
7962	      (call (mem:SI (match_dup 1))
7963		    (match_dup 2)))
7964	      (clobber (reg:DI 1))
7965	      (clobber (reg:DI 2))
7966	      (use (reg:DI 27))
7967	      (use (reg:DI 29))
7968	      (use (const_int 0))])
7969   (set (reg:DI 27) (match_dup 3))]
7970  "")
7971
7972(define_insn "*call_val_symref_64bit_post_reload"
7973  [(set (match_operand 0 "" "")
7974	(call (mem:SI (match_operand 1 "call_operand_address" ""))
7975	      (match_operand 2 "" "i")))
7976   (clobber (reg:DI 1))
7977   (clobber (reg:DI 2))
7978   (use (reg:DI 27))
7979   (use (reg:DI 29))
7980   (use (const_int 0))]
7981  "TARGET_64BIT"
7982  "*
7983{
7984  return pa_output_call (insn, operands[1], 0);
7985}"
7986  [(set_attr "type" "call")
7987   (set (attr "length")
7988	(cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7989	      (symbol_ref "pa_attr_length_call (insn, 0)")))])
7990
7991;; powf function clobbers %fr12
7992(define_insn "call_val_powf_64bit"
7993  [(set (match_operand 0 "" "")
7994	(call (mem:SI (match_operand 1 "call_operand_address" ""))
7995	      (match_operand 2 "" "i")))
7996   (clobber (reg:DI 1))
7997   (clobber (reg:DI 2))
7998   (clobber (reg:DF 40))
7999   (clobber (match_operand 3))
8000   (use (reg:DI 27))
8001   (use (reg:DI 29))
8002   (use (const_int 1))]
8003  "TARGET_64BIT && TARGET_HPUX"
8004  "#")
8005
8006;; Split out the PIC register save and restore after reload.  As the
8007;; split is done after reload, there are some situations in which we
8008;; unnecessarily save and restore %r4.  This happens when there is a
8009;; single call and the PIC register is not used after the call.
8010;;
8011;; The split has to be done since call_from_call_insn () can't handle
8012;; the pattern as is.  Noreturn calls are special because they have to
8013;; terminate the basic block.  The split has to contain more than one
8014;; insn.
8015(define_split
8016  [(parallel [(set (match_operand 0 "" "")
8017	      (call (mem:SI (match_operand 1 "call_operand_address" ""))
8018		    (match_operand 2 "" "")))
8019	      (clobber (reg:DI 1))
8020	      (clobber (reg:DI 2))
8021	      (clobber (reg:DF 40))
8022	      (clobber (match_operand 3))
8023	      (use (reg:DI 27))
8024	      (use (reg:DI 29))
8025	      (use (const_int 1))])]
8026  "TARGET_64BIT && TARGET_HPUX && reload_completed
8027   && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8028  [(set (match_dup 3) (reg:DI 27))
8029   (parallel [(set (match_dup 0)
8030	      (call (mem:SI (match_dup 1))
8031		    (match_dup 2)))
8032	      (clobber (reg:DI 1))
8033	      (clobber (reg:DI 2))
8034	      (clobber (reg:DF 40))
8035	      (use (reg:DI 27))
8036	      (use (reg:DI 29))
8037	      (use (const_int 1))])]
8038  "")
8039
8040(define_split
8041  [(parallel [(set (match_operand 0 "" "")
8042	      (call (mem:SI (match_operand 1 "call_operand_address" ""))
8043		    (match_operand 2 "" "")))
8044	      (clobber (reg:DI 1))
8045	      (clobber (reg:DI 2))
8046	      (clobber (reg:DF 40))
8047	      (clobber (match_operand 3))
8048	      (use (reg:DI 27))
8049	      (use (reg:DI 29))
8050	      (use (const_int 1))])]
8051  "TARGET_64BIT && TARGET_HPUX && reload_completed"
8052  [(set (match_dup 3) (reg:DI 27))
8053   (parallel [(set (match_dup 0)
8054	      (call (mem:SI (match_dup 1))
8055		    (match_dup 2)))
8056	      (clobber (reg:DI 1))
8057	      (clobber (reg:DI 2))
8058	      (clobber (reg:DF 40))
8059	      (use (reg:DI 27))
8060	      (use (reg:DI 29))
8061	      (use (const_int 1))])
8062   (set (reg:DI 27) (match_dup 3))]
8063  "")
8064
8065(define_insn "*call_val_powf_64bit_post_reload"
8066  [(set (match_operand 0 "" "")
8067	(call (mem:SI (match_operand 1 "call_operand_address" ""))
8068	      (match_operand 2 "" "i")))
8069   (clobber (reg:DI 1))
8070   (clobber (reg:DI 2))
8071   (clobber (reg:DF 40))
8072   (use (reg:DI 27))
8073   (use (reg:DI 29))
8074   (use (const_int 1))]
8075  "TARGET_64BIT && TARGET_HPUX"
8076  "*
8077{
8078  return pa_output_call (insn, operands[1], 0);
8079}"
8080  [(set_attr "type" "call")
8081   (set (attr "length")
8082	(cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8083	      (symbol_ref "pa_attr_length_call (insn, 0)")))])
8084
8085(define_insn "call_val_reg"
8086  [(set (match_operand 0 "" "")
8087	(call (mem:SI (reg:SI 22))
8088	      (match_operand 1 "" "i")))
8089   (clobber (reg:SI 1))
8090   (clobber (reg:SI 2))
8091   (use (const_int 1))]
8092  "!TARGET_64BIT"
8093  "*
8094{
8095  return pa_output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
8096}"
8097  [(set_attr "type" "dyncall")
8098   (set (attr "length")
8099	(cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8100	      (symbol_ref "pa_attr_length_indirect_call (insn)")))])
8101
8102;; This pattern is split if it is necessary to save and restore the
8103;; PIC register.
8104(define_insn "call_val_reg_pic"
8105  [(set (match_operand 0 "" "")
8106	(call (mem:SI (reg:SI 22))
8107	      (match_operand 1 "" "i")))
8108   (clobber (reg:SI 1))
8109   (clobber (reg:SI 2))
8110   (clobber (match_operand 2))
8111   (use (reg:SI 19))
8112   (use (const_int 1))]
8113  "!TARGET_64BIT"
8114  "#")
8115
8116;; Split out the PIC register save and restore after reload.  As the
8117;; split is done after reload, there are some situations in which we
8118;; unnecessarily save and restore %r4.  This happens when there is a
8119;; single call and the PIC register is not used after the call.
8120;;
8121;; The split has to be done since call_from_call_insn () can't handle
8122;; the pattern as is.  Noreturn calls are special because they have to
8123;; terminate the basic block.  The split has to contain more than one
8124;; insn.
8125(define_split
8126  [(parallel [(set (match_operand 0 "" "")
8127		   (call (mem:SI (reg:SI 22))
8128			 (match_operand 1 "" "")))
8129	      (clobber (reg:SI 1))
8130	      (clobber (reg:SI 2))
8131	      (clobber (match_operand 2))
8132	      (use (reg:SI 19))
8133	      (use (const_int 1))])]
8134  "!TARGET_64BIT && reload_completed
8135   && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8136  [(set (match_dup 2) (reg:SI 19))
8137   (parallel [(set (match_dup 0)
8138		   (call (mem:SI (reg:SI 22))
8139			 (match_dup 1)))
8140	      (clobber (reg:SI 1))
8141	      (clobber (reg:SI 2))
8142	      (use (reg:SI 19))
8143	      (use (const_int 1))])]
8144  "")
8145
8146(define_split
8147  [(parallel [(set (match_operand 0 "" "")
8148		   (call (mem:SI (reg:SI 22))
8149			 (match_operand 1 "" "")))
8150	      (clobber (reg:SI 1))
8151	      (clobber (reg:SI 2))
8152	      (clobber (match_operand 2))
8153	      (use (reg:SI 19))
8154	      (use (const_int 1))])]
8155  "!TARGET_64BIT && reload_completed"
8156  [(set (match_dup 2) (reg:SI 19))
8157   (parallel [(set (match_dup 0)
8158		   (call (mem:SI (reg:SI 22))
8159			 (match_dup 1)))
8160	      (clobber (reg:SI 1))
8161	      (clobber (reg:SI 2))
8162	      (use (reg:SI 19))
8163	      (use (const_int 1))])
8164   (set (reg:SI 19) (match_dup 2))]
8165  "")
8166
8167(define_insn "*call_val_reg_pic_post_reload"
8168  [(set (match_operand 0 "" "")
8169	(call (mem:SI (reg:SI 22))
8170	      (match_operand 1 "" "i")))
8171   (clobber (reg:SI 1))
8172   (clobber (reg:SI 2))
8173   (use (reg:SI 19))
8174   (use (const_int 1))]
8175  "!TARGET_64BIT"
8176  "*
8177{
8178  return pa_output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
8179}"
8180  [(set_attr "type" "dyncall")
8181   (set (attr "length")
8182	(cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8183	      (symbol_ref "pa_attr_length_indirect_call (insn)")))])
8184
8185;; This pattern is split if it is necessary to save and restore the
8186;; PIC register.
8187(define_insn "call_val_reg_64bit"
8188  [(set (match_operand 0 "" "")
8189	(call (mem:SI (match_operand:DI 1 "register_operand" "r"))
8190	      (match_operand 2 "" "i")))
8191   (clobber (reg:DI 2))
8192   (clobber (match_operand 3))
8193   (use (reg:DI 27))
8194   (use (reg:DI 29))
8195   (use (const_int 1))]
8196  "TARGET_64BIT"
8197  "#")
8198
8199;; Split out the PIC register save and restore after reload.  As the
8200;; split is done after reload, there are some situations in which we
8201;; unnecessarily save and restore %r4.  This happens when there is a
8202;; single call and the PIC register is not used after the call.
8203;;
8204;; The split has to be done since call_from_call_insn () can't handle
8205;; the pattern as is.  Noreturn calls are special because they have to
8206;; terminate the basic block.  The split has to contain more than one
8207;; insn.
8208(define_split
8209  [(parallel [(set (match_operand 0 "" "")
8210		   (call (mem:SI (match_operand:DI 1 "register_operand" ""))
8211			 (match_operand 2 "" "")))
8212	      (clobber (reg:DI 2))
8213	      (clobber (match_operand 3))
8214	      (use (reg:DI 27))
8215	      (use (reg:DI 29))
8216	      (use (const_int 1))])]
8217  "TARGET_64BIT && reload_completed
8218   && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8219  [(set (match_dup 3) (reg:DI 27))
8220   (parallel [(set (match_dup 0)
8221		   (call (mem:SI (match_dup 1))
8222			 (match_dup 2)))
8223	      (clobber (reg:DI 2))
8224	      (use (reg:DI 27))
8225	      (use (reg:DI 29))
8226	      (use (const_int 1))])]
8227  "")
8228
8229(define_split
8230  [(parallel [(set (match_operand 0 "" "")
8231		   (call (mem:SI (match_operand:DI 1 "register_operand" ""))
8232			 (match_operand 2 "" "")))
8233	      (clobber (reg:DI 2))
8234	      (clobber (match_operand 3))
8235	      (use (reg:DI 27))
8236	      (use (reg:DI 29))
8237	      (use (const_int 1))])]
8238  "TARGET_64BIT && reload_completed"
8239  [(set (match_dup 3) (reg:DI 27))
8240   (parallel [(set (match_dup 0)
8241		   (call (mem:SI (match_dup 1))
8242			 (match_dup 2)))
8243	      (clobber (reg:DI 2))
8244	      (use (reg:DI 27))
8245	      (use (reg:DI 29))
8246	      (use (const_int 1))])
8247   (set (reg:DI 27) (match_dup 3))]
8248  "")
8249
8250(define_insn "*call_val_reg_64bit_post_reload"
8251  [(set (match_operand 0 "" "")
8252	(call (mem:SI (match_operand:DI 1 "register_operand" "r"))
8253	      (match_operand 2 "" "i")))
8254   (clobber (reg:DI 2))
8255   (use (reg:DI 27))
8256   (use (reg:DI 29))
8257   (use (const_int 1))]
8258  "TARGET_64BIT"
8259  "*
8260{
8261  return pa_output_indirect_call (insn, operands[1]);
8262}"
8263  [(set_attr "type" "dyncall")
8264   (set (attr "length")
8265	(cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 12)]
8266	      (symbol_ref "pa_attr_length_indirect_call (insn)")))])
8267
8268/* Expand special pc-relative call to _mcount.  */
8269
8270(define_expand "call_mcount"
8271  [(parallel [(call (match_operand:SI 0 "" "")
8272		    (match_operand 1 "" ""))
8273	      (set (reg:SI 25)
8274		   (plus:SI (reg:SI 2)
8275			    (minus:SI (match_operand 2 "" "")
8276				      (plus:SI (pc) (const_int 4)))))
8277	      (clobber (reg:SI 2))])]
8278  "!TARGET_PORTABLE_RUNTIME"
8279  "
8280{
8281  rtx op = XEXP (operands[0], 0);
8282  rtx nb = operands[1];
8283  rtx lab = operands[2];
8284
8285  if (TARGET_64BIT)
8286    {
8287      rtx r4 = gen_rtx_REG (word_mode, 4);
8288      emit_move_insn (arg_pointer_rtx,
8289		      gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
8290				    GEN_INT (64)));
8291      emit_call_insn (gen_call_mcount_64bit (op, nb, lab, r4));
8292    }
8293  else
8294    {
8295      if (flag_pic)
8296	{
8297	  rtx r4 = gen_rtx_REG (word_mode, 4);
8298	  emit_call_insn (gen_call_mcount_pic (op, nb, lab, r4));
8299	}
8300      else
8301	emit_call_insn (gen_call_mcount_nonpic (op, nb, lab));
8302    }
8303
8304  DONE;
8305}")
8306
8307(define_insn "call_mcount_nonpic"
8308  [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8309	 (match_operand 1 "" "i"))
8310   (set (reg:SI 25)
8311	(plus:SI (reg:SI 2)
8312		 (minus:SI (match_operand 2 "" "")
8313			   (plus:SI (pc) (const_int 4)))))
8314   (clobber (reg:SI 2))]
8315  "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8316  "*
8317{
8318  pa_output_arg_descriptor (insn);
8319  return \"{bl|b,l} %0,%%r2\;ldo %2-.-4(%%r2),%%r25\";
8320}"
8321  [(set_attr "type" "multi")
8322   (set_attr "length" "8")])
8323
8324(define_insn "call_mcount_pic"
8325  [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8326	 (match_operand 1 "" "i"))
8327   (set (reg:SI 25)
8328	(plus:SI (reg:SI 2)
8329		 (minus:SI (match_operand 2 "" "")
8330			   (plus:SI (pc) (const_int 4)))))
8331   (clobber (reg:SI 2))
8332   (clobber (match_operand 3))
8333   (use (reg:SI 19))]
8334  "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8335  "#")
8336
8337(define_split
8338  [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8339		    (match_operand 1 "" ""))
8340	      (set (reg:SI 25)
8341		   (plus:SI (reg:SI 2)
8342			    (minus:SI (match_operand 2 "" "")
8343				      (plus:SI (pc) (const_int 4)))))
8344	      (clobber (reg:SI 2))
8345	      (clobber (match_operand 3))
8346	      (use (reg:SI 19))])]
8347  "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
8348  [(set (match_dup 3) (reg:SI 19))
8349   (parallel [(call (mem:SI (match_dup 0))
8350		    (match_dup 1))
8351	      (set (reg:SI 25)
8352		   (plus:SI (reg:SI 2)
8353			    (minus:SI (match_dup 2)
8354				      (plus:SI (pc) (const_int 4)))))
8355	      (clobber (reg:SI 2))
8356	      (use (reg:SI 19))])
8357   (set (reg:SI 19) (match_dup 3))]
8358  "")
8359
8360(define_insn "*call_mcount_pic_post_reload"
8361  [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8362	 (match_operand 1 "" "i"))
8363   (set (reg:SI 25)
8364	(plus:SI (reg:SI 2)
8365		 (minus:SI (match_operand 2 "" "")
8366			   (plus:SI (pc) (const_int 4)))))
8367   (clobber (reg:SI 2))
8368   (use (reg:SI 19))]
8369  "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8370  "*
8371{
8372  pa_output_arg_descriptor (insn);
8373  return \"{bl|b,l} %0,%%r2\;ldo %2-.-4(%%r2),%%r25\";
8374}"
8375  [(set_attr "type" "multi")
8376   (set_attr "length" "8")])
8377
8378(define_insn "call_mcount_64bit"
8379  [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8380	 (match_operand 1 "" "i"))
8381   (set (reg:SI 25)
8382	(plus:SI (reg:SI 2)
8383		 (minus:SI (match_operand 2 "" "")
8384			   (plus:SI (pc) (const_int 4)))))
8385   (clobber (reg:DI 2))
8386   (clobber (match_operand 3))
8387   (use (reg:DI 27))
8388   (use (reg:DI 29))]
8389  "TARGET_64BIT"
8390  "#")
8391
8392(define_split
8393  [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8394		    (match_operand 1 "" ""))
8395	      (set (reg:SI 25)
8396		   (plus:SI (reg:SI 2)
8397			    (minus:SI (match_operand 2 "" "")
8398				      (plus:SI (pc) (const_int 4)))))
8399	      (clobber (reg:DI 2))
8400	      (clobber (match_operand 3))
8401	      (use (reg:DI 27))
8402	      (use (reg:DI 29))])]
8403  "TARGET_64BIT && reload_completed"
8404  [(set (match_dup 3) (reg:DI 27))
8405   (parallel [(call (mem:SI (match_dup 0))
8406		    (match_dup 1))
8407	      (set (reg:SI 25)
8408		   (plus:SI (reg:SI 2)
8409			    (minus:SI (match_dup 2)
8410				      (plus:SI (pc) (const_int 4)))))
8411	      (clobber (reg:DI 2))
8412	      (use (reg:DI 27))
8413	      (use (reg:DI 29))])
8414   (set (reg:DI 27) (match_dup 3))]
8415  "")
8416
8417(define_insn "*call_mcount_64bit_post_reload"
8418  [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8419	 (match_operand 1 "" "i"))
8420   (set (reg:SI 25)
8421	(plus:SI (reg:SI 2)
8422		 (minus:SI (match_operand 2 "" "")
8423			   (plus:SI (pc) (const_int 4)))))
8424   (clobber (reg:DI 2))
8425   (use (reg:DI 27))
8426   (use (reg:DI 29))]
8427  "TARGET_64BIT"
8428  "{bl|b,l} %0,%%r2\;ldo %2-.-4(%%r2),%%r25"
8429  [(set_attr "type" "multi")
8430   (set_attr "length" "8")])
8431
8432;; Call subroutine returning any type.
8433
8434(define_expand "untyped_call"
8435  [(parallel [(call (match_operand 0 "" "")
8436		    (const_int 0))
8437	      (match_operand 1 "" "")
8438	      (match_operand 2 "" "")])]
8439  ""
8440  "
8441{
8442  int i;
8443
8444  emit_call_insn (gen_call (operands[0], const0_rtx));
8445
8446  for (i = 0; i < XVECLEN (operands[2], 0); i++)
8447    {
8448      rtx set = XVECEXP (operands[2], 0, i);
8449      emit_move_insn (SET_DEST (set), SET_SRC (set));
8450    }
8451
8452  /* The optimizer does not know that the call sets the function value
8453     registers we stored in the result block.  We avoid problems by
8454     claiming that all hard registers are used and clobbered at this
8455     point.  */
8456  emit_insn (gen_blockage ());
8457
8458  DONE;
8459}")
8460
8461(define_expand "sibcall"
8462  [(call (match_operand:SI 0 "" "")
8463	 (match_operand 1 "" ""))]
8464  "!TARGET_PORTABLE_RUNTIME"
8465  "
8466{
8467  rtx op, call_insn;
8468  rtx nb = operands[1];
8469
8470  op = XEXP (operands[0], 0);
8471
8472  if (TARGET_64BIT)
8473    {
8474      if (!virtuals_instantiated)
8475	emit_move_insn (arg_pointer_rtx,
8476			gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
8477				      GEN_INT (64)));
8478      else
8479	{
8480	  /* The loop pass can generate new libcalls after the virtual
8481	     registers are instantiated when fpregs are disabled because
8482	     the only method that we have for doing DImode multiplication
8483	     is with a libcall.  This could be trouble if we haven't
8484	     allocated enough space for the outgoing arguments.  */
8485	  gcc_assert (INTVAL (nb) <= crtl->outgoing_args_size);
8486
8487	  emit_move_insn (arg_pointer_rtx,
8488			  gen_rtx_PLUS (word_mode, stack_pointer_rtx,
8489					GEN_INT (STACK_POINTER_OFFSET + 64)));
8490	}
8491    }
8492
8493  /* Indirect sibling calls are not allowed.  */
8494  if (TARGET_64BIT)
8495    call_insn = gen_sibcall_internal_symref_64bit (op, operands[1]);
8496  else
8497    call_insn = gen_sibcall_internal_symref (op, operands[1]);
8498
8499  call_insn = emit_call_insn (call_insn);
8500
8501  if (TARGET_64BIT)
8502    use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), arg_pointer_rtx);
8503
8504  /* We don't have to restore the PIC register.  */
8505  if (flag_pic)
8506    use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
8507
8508  DONE;
8509}")
8510
8511(define_insn "sibcall_internal_symref"
8512  [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8513	 (match_operand 1 "" "i"))
8514   (clobber (reg:SI 1))
8515   (use (reg:SI 2))
8516   (use (const_int 0))]
8517  "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8518  "*
8519{
8520  pa_output_arg_descriptor (insn);
8521  return pa_output_call (insn, operands[0], 1);
8522}"
8523  [(set_attr "type" "sibcall")
8524   (set (attr "length")
8525	(cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8526	      (symbol_ref "pa_attr_length_call (insn, 1)")))])
8527
8528(define_insn "sibcall_internal_symref_64bit"
8529  [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8530	 (match_operand 1 "" "i"))
8531   (clobber (reg:DI 1))
8532   (use (reg:DI 2))
8533   (use (const_int 0))]
8534  "TARGET_64BIT"
8535  "*
8536{
8537  return pa_output_call (insn, operands[0], 1);
8538}"
8539  [(set_attr "type" "sibcall")
8540   (set (attr "length")
8541	(cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8542	      (symbol_ref "pa_attr_length_call (insn, 1)")))])
8543
8544(define_expand "sibcall_value"
8545  [(set (match_operand 0 "" "")
8546		   (call (match_operand:SI 1 "" "")
8547			 (match_operand 2 "" "")))]
8548  "!TARGET_PORTABLE_RUNTIME"
8549  "
8550{
8551  rtx op, call_insn;
8552  rtx nb = operands[1];
8553
8554  op = XEXP (operands[1], 0);
8555
8556  if (TARGET_64BIT)
8557    {
8558      if (!virtuals_instantiated)
8559	emit_move_insn (arg_pointer_rtx,
8560			gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
8561				      GEN_INT (64)));
8562      else
8563	{
8564	  /* The loop pass can generate new libcalls after the virtual
8565	     registers are instantiated when fpregs are disabled because
8566	     the only method that we have for doing DImode multiplication
8567	     is with a libcall.  This could be trouble if we haven't
8568	     allocated enough space for the outgoing arguments.  */
8569	  gcc_assert (INTVAL (nb) <= crtl->outgoing_args_size);
8570
8571	  emit_move_insn (arg_pointer_rtx,
8572			  gen_rtx_PLUS (word_mode, stack_pointer_rtx,
8573					GEN_INT (STACK_POINTER_OFFSET + 64)));
8574	}
8575    }
8576
8577  /* Indirect sibling calls are not allowed.  */
8578  if (TARGET_64BIT)
8579    call_insn
8580      = gen_sibcall_value_internal_symref_64bit (operands[0], op, operands[2]);
8581  else
8582    call_insn
8583      = gen_sibcall_value_internal_symref (operands[0], op, operands[2]);
8584
8585  call_insn = emit_call_insn (call_insn);
8586
8587  if (TARGET_64BIT)
8588    use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), arg_pointer_rtx);
8589
8590  /* We don't have to restore the PIC register.  */
8591  if (flag_pic)
8592    use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
8593
8594  DONE;
8595}")
8596
8597(define_insn "sibcall_value_internal_symref"
8598  [(set (match_operand 0 "" "")
8599	(call (mem:SI (match_operand 1 "call_operand_address" ""))
8600	      (match_operand 2 "" "i")))
8601   (clobber (reg:SI 1))
8602   (use (reg:SI 2))
8603   (use (const_int 0))]
8604  "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8605  "*
8606{
8607  pa_output_arg_descriptor (insn);
8608  return pa_output_call (insn, operands[1], 1);
8609}"
8610  [(set_attr "type" "sibcall")
8611   (set (attr "length")
8612	(cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8613	      (symbol_ref "pa_attr_length_call (insn, 1)")))])
8614
8615(define_insn "sibcall_value_internal_symref_64bit"
8616  [(set (match_operand 0 "" "")
8617	(call (mem:SI (match_operand 1 "call_operand_address" ""))
8618	      (match_operand 2 "" "i")))
8619   (clobber (reg:DI 1))
8620   (use (reg:DI 2))
8621   (use (const_int 0))]
8622  "TARGET_64BIT"
8623  "*
8624{
8625  return pa_output_call (insn, operands[1], 1);
8626}"
8627  [(set_attr "type" "sibcall")
8628   (set (attr "length")
8629	(cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8630	      (symbol_ref "pa_attr_length_call (insn, 1)")))])
8631
8632(define_insn "nop"
8633  [(const_int 0)]
8634  ""
8635  "nop"
8636  [(set_attr "type" "move")
8637   (set_attr "length" "4")])
8638
8639;;; EH does longjmp's from and within the data section.  Thus,
8640;;; an interspace branch is required for the longjmp implementation.
8641;;; Registers r1 and r2 are used as scratch registers for the jump
8642;;; when necessary.
8643(define_expand "interspace_jump"
8644  [(parallel
8645     [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8646      (clobber (match_dup 1))])]
8647  ""
8648  "
8649{
8650  operands[1] = gen_rtx_REG (word_mode, 2);
8651}")
8652
8653(define_insn ""
8654  [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8655  (clobber (reg:SI 2))]
8656  "TARGET_PA_20 && !TARGET_64BIT"
8657  "bve%* (%0)"
8658   [(set_attr "type" "branch")
8659    (set_attr "length" "4")])
8660
8661(define_insn ""
8662  [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8663  (clobber (reg:SI 2))]
8664  "TARGET_NO_SPACE_REGS && !TARGET_64BIT"
8665  "be%* 0(%%sr4,%0)"
8666   [(set_attr "type" "branch")
8667    (set_attr "length" "4")])
8668
8669(define_insn ""
8670  [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8671  (clobber (reg:SI 2))]
8672  "!TARGET_64BIT"
8673  "ldsid (%%sr0,%0),%%r2\;mtsp %%r2,%%sr0\;be%* 0(%%sr0,%0)"
8674   [(set_attr "type" "branch")
8675    (set_attr "length" "12")])
8676
8677(define_insn ""
8678  [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8679  (clobber (reg:DI 2))]
8680  "TARGET_64BIT"
8681  "bve%* (%0)"
8682   [(set_attr "type" "branch")
8683    (set_attr "length" "4")])
8684
8685(define_expand "builtin_longjmp"
8686  [(unspec_volatile [(match_operand 0 "register_operand" "r")] UNSPECV_LONGJMP)]
8687  ""
8688  "
8689{
8690  /* The elements of the buffer are, in order:  */
8691  rtx fp = gen_rtx_MEM (Pmode, operands[0]);
8692  rtx lab = gen_rtx_MEM (Pmode, plus_constant (Pmode, operands[0],
8693			 POINTER_SIZE / BITS_PER_UNIT));
8694  rtx stack = gen_rtx_MEM (Pmode, plus_constant (Pmode, operands[0],
8695			   (POINTER_SIZE * 2) / BITS_PER_UNIT));
8696  rtx pv = gen_rtx_REG (Pmode, 1);
8697
8698  emit_clobber (gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (VOIDmode)));
8699  emit_clobber (gen_rtx_MEM (BLKmode, hard_frame_pointer_rtx));
8700
8701  /* Load the label we are jumping through into r1 so that we know
8702     where to look for it when we get back to setjmp's function for
8703     restoring the gp.  */
8704  emit_move_insn (pv, lab);
8705
8706  /* Restore the stack and frame pointers.  The virtual_stack_vars_rtx
8707     is saved instead of the hard_frame_pointer_rtx in the save area.
8708     We need to adjust for the offset between these two values.  */
8709  fp = copy_to_reg (fp);
8710  emit_stack_restore (SAVE_NONLOCAL, stack);
8711
8712  /* Ensure the frame pointer move is not optimized.  */
8713  emit_insn (gen_blockage ());
8714  emit_clobber (hard_frame_pointer_rtx);
8715  emit_clobber (frame_pointer_rtx);
8716  emit_move_insn (hard_frame_pointer_rtx, plus_constant (Pmode, fp, -8));
8717
8718  emit_use (hard_frame_pointer_rtx);
8719  emit_use (stack_pointer_rtx);
8720
8721  /* Prevent the insns above from being scheduled into the delay slot
8722     of the interspace jump because the space register could change.  */
8723  emit_insn (gen_blockage ());
8724
8725  emit_jump_insn (gen_interspace_jump (pv));
8726  emit_barrier ();
8727  DONE;
8728}")
8729
8730;;; Operands 2 and 3 are assumed to be CONST_INTs.
8731(define_expand "extzvsi"
8732  [(set (match_operand:SI 0 "register_operand" "")
8733	(zero_extract:SI (match_operand:SI 1 "register_operand" "")
8734			 (match_operand:SI 2 "uint5_operand" "")
8735			 (match_operand:SI 3 "uint5_operand" "")))]
8736  ""
8737  "
8738{
8739  unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
8740  unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
8741
8742  /* PA extraction insns don't support zero length bitfields or fields
8743     extending beyond the left or right-most bits.  Also, the predicate
8744     rejects lengths equal to a word as they are better handled by
8745     the move patterns.  */
8746  if (len == 0 || pos + len > 32)
8747    FAIL;
8748
8749  /* From mips.md: extract_bit_field doesn't verify that our source
8750     matches the predicate, so check it again here.  */
8751  if (!register_operand (operands[1], VOIDmode))
8752    FAIL;
8753
8754  emit_insn (gen_extzv_32 (operands[0], operands[1],
8755			   operands[2], operands[3]));
8756  DONE;
8757}")
8758
8759(define_insn "extzv_32"
8760  [(set (match_operand:SI 0 "register_operand" "=r")
8761	(zero_extract:SI (match_operand:SI 1 "register_operand" "r")
8762			 (match_operand:SI 2 "uint5_operand" "")
8763			 (match_operand:SI 3 "uint5_operand" "")))]
8764  "UINTVAL (operands[2]) > 0
8765   && UINTVAL (operands[2]) + UINTVAL (operands[3]) <= 32"
8766  "{extru|extrw,u} %1,%3+%2-1,%2,%0"
8767  [(set_attr "type" "shift")
8768   (set_attr "length" "4")])
8769
8770(define_insn ""
8771  [(set (match_operand:SI 0 "register_operand" "=r")
8772	(zero_extract:SI (match_operand:SI 1 "register_operand" "r")
8773			 (const_int 1)
8774			 (match_operand:SI 2 "register_operand" "q")))]
8775  ""
8776  "{vextru %1,1,%0|extrw,u %1,%%sar,1,%0}"
8777  [(set_attr "type" "shift")
8778   (set_attr "length" "4")])
8779
8780(define_expand "extzvdi"
8781  [(set (match_operand:DI 0 "register_operand" "")
8782	(zero_extract:DI (match_operand:DI 1 "register_operand" "")
8783			 (match_operand:DI 2 "uint6_operand" "")
8784			 (match_operand:DI 3 "uint6_operand" "")))]
8785  "TARGET_64BIT"
8786  "
8787{
8788  unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
8789  unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
8790
8791  /* PA extraction insns don't support zero length bitfields or fields
8792     extending beyond the left or right-most bits.  Also, the predicate
8793     rejects lengths equal to a doubleword as they are better handled by
8794     the move patterns.  */
8795  if (len == 0 || pos + len > 64)
8796    FAIL;
8797
8798  /* From mips.md: extract_bit_field doesn't verify that our source
8799     matches the predicate, so check it again here.  */
8800  if (!register_operand (operands[1], VOIDmode))
8801    FAIL;
8802
8803  emit_insn (gen_extzv_64 (operands[0], operands[1],
8804			   operands[2], operands[3]));
8805  DONE;
8806}")
8807
8808(define_insn "extzv_64"
8809  [(set (match_operand:DI 0 "register_operand" "=r")
8810	(zero_extract:DI (match_operand:DI 1 "register_operand" "r")
8811			 (match_operand:DI 2 "uint6_operand" "")
8812			 (match_operand:DI 3 "uint6_operand" "")))]
8813  "TARGET_64BIT
8814   && UINTVAL (operands[2]) > 0
8815   && UINTVAL (operands[2]) + UINTVAL (operands[3]) <= 64"
8816  "extrd,u %1,%3+%2-1,%2,%0"
8817  [(set_attr "type" "shift")
8818   (set_attr "length" "4")])
8819
8820(define_insn ""
8821  [(set (match_operand:DI 0 "register_operand" "=r")
8822	(zero_extract:DI (match_operand:DI 1 "register_operand" "r")
8823			 (const_int 1)
8824			 (match_operand:DI 2 "register_operand" "q")))]
8825  "TARGET_64BIT"
8826  "extrd,u %1,%%sar,1,%0"
8827  [(set_attr "type" "shift")
8828   (set_attr "length" "4")])
8829
8830;;; Operands 2 and 3 are assumed to be CONST_INTs.
8831(define_expand "extvsi"
8832  [(set (match_operand:SI 0 "register_operand" "")
8833	(sign_extract:SI (match_operand:SI 1 "register_operand" "")
8834			 (match_operand:SI 2 "uint5_operand" "")
8835			 (match_operand:SI 3 "uint5_operand" "")))]
8836  ""
8837  "
8838{
8839  unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
8840  unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
8841
8842  /* PA extraction insns don't support zero length bitfields or fields
8843     extending beyond the left or right-most bits.  Also, the predicate
8844     rejects lengths equal to a word as they are better handled by
8845     the move patterns.  */
8846  if (len == 0 || pos + len > 32)
8847    FAIL;
8848
8849  /* From mips.md: extract_bit_field doesn't verify that our source
8850     matches the predicate, so check it again here.  */
8851  if (!register_operand (operands[1], VOIDmode))
8852    FAIL;
8853
8854  emit_insn (gen_extv_32 (operands[0], operands[1],
8855			  operands[2], operands[3]));
8856  DONE;
8857}")
8858
8859(define_insn "extv_32"
8860  [(set (match_operand:SI 0 "register_operand" "=r")
8861	(sign_extract:SI (match_operand:SI 1 "register_operand" "r")
8862			 (match_operand:SI 2 "uint5_operand" "")
8863			 (match_operand:SI 3 "uint5_operand" "")))]
8864  "UINTVAL (operands[2]) > 0
8865   && UINTVAL (operands[2]) + UINTVAL (operands[3]) <= 32"
8866  "{extrs|extrw,s} %1,%3+%2-1,%2,%0"
8867  [(set_attr "type" "shift")
8868   (set_attr "length" "4")])
8869
8870(define_insn ""
8871  [(set (match_operand:SI 0 "register_operand" "=r")
8872	(sign_extract:SI (match_operand:SI 1 "register_operand" "r")
8873			 (const_int 1)
8874			 (match_operand:SI 2 "register_operand" "q")))]
8875  "!TARGET_64BIT"
8876  "{vextrs %1,1,%0|extrw,s %1,%%sar,1,%0}"
8877  [(set_attr "type" "shift")
8878   (set_attr "length" "4")])
8879
8880(define_expand "extvdi"
8881  [(set (match_operand:DI 0 "register_operand" "")
8882	(sign_extract:DI (match_operand:DI 1 "register_operand" "")
8883			 (match_operand:DI 2 "uint6_operand" "")
8884			 (match_operand:DI 3 "uint6_operand" "")))]
8885  "TARGET_64BIT"
8886  "
8887{
8888  unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
8889  unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
8890
8891  /* PA extraction insns don't support zero length bitfields or fields
8892     extending beyond the left or right-most bits.  Also, the predicate
8893     rejects lengths equal to a doubleword as they are better handled by
8894     the move patterns.  */
8895  if (len == 0 || pos + len > 64)
8896    FAIL;
8897
8898  /* From mips.md: extract_bit_field doesn't verify that our source
8899     matches the predicate, so check it again here.  */
8900  if (!register_operand (operands[1], VOIDmode))
8901    FAIL;
8902
8903  emit_insn (gen_extv_64 (operands[0], operands[1],
8904			  operands[2], operands[3]));
8905  DONE;
8906}")
8907
8908(define_insn "extv_64"
8909  [(set (match_operand:DI 0 "register_operand" "=r")
8910	(sign_extract:DI (match_operand:DI 1 "register_operand" "r")
8911			 (match_operand:DI 2 "uint6_operand" "")
8912			 (match_operand:DI 3 "uint6_operand" "")))]
8913  "TARGET_64BIT
8914   && UINTVAL (operands[2]) > 0
8915   && UINTVAL (operands[2]) + UINTVAL (operands[3]) <= 64"
8916  "extrd,s %1,%3+%2-1,%2,%0"
8917  [(set_attr "type" "shift")
8918   (set_attr "length" "4")])
8919
8920(define_insn ""
8921  [(set (match_operand:DI 0 "register_operand" "=r")
8922	(sign_extract:DI (match_operand:DI 1 "register_operand" "r")
8923			 (const_int 1)
8924			 (match_operand:DI 2 "register_operand" "q")))]
8925  "TARGET_64BIT"
8926  "extrd,s %1,%%sar,1,%0"
8927  [(set_attr "type" "shift")
8928   (set_attr "length" "4")])
8929
8930;;; Operands 1 and 2 are assumed to be CONST_INTs.
8931(define_expand "insvsi"
8932  [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "")
8933			 (match_operand:SI 1 "uint5_operand" "")
8934			 (match_operand:SI 2 "uint5_operand" ""))
8935	(match_operand:SI 3 "arith5_operand" ""))]
8936  ""
8937  "
8938{
8939  unsigned HOST_WIDE_INT len = UINTVAL (operands[1]);
8940  unsigned HOST_WIDE_INT pos = UINTVAL (operands[2]);
8941
8942  /* PA insertion insns don't support zero length bitfields or fields
8943     extending beyond the left or right-most bits.  Also, the predicate
8944     rejects lengths equal to a word as they are better handled by
8945     the move patterns.  */
8946  if (len <= 0 || pos + len > 32)
8947    FAIL;
8948
8949  /* From mips.md: insert_bit_field doesn't verify that our destination
8950     matches the predicate, so check it again here.  */
8951  if (!register_operand (operands[0], VOIDmode))
8952    FAIL;
8953
8954  emit_insn (gen_insv_32 (operands[0], operands[1],
8955			  operands[2], operands[3]));
8956  DONE;
8957}")
8958
8959(define_insn "insv_32"
8960  [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r,r")
8961			 (match_operand:SI 1 "uint5_operand" "")
8962			 (match_operand:SI 2 "uint5_operand" ""))
8963	(match_operand:SI 3 "arith5_operand" "r,L"))]
8964  "UINTVAL (operands[1]) > 0
8965   && UINTVAL (operands[1]) + UINTVAL (operands[2]) <= 32"
8966  "@
8967   {dep|depw} %3,%2+%1-1,%1,%0
8968   {depi|depwi} %3,%2+%1-1,%1,%0"
8969  [(set_attr "type" "shift,shift")
8970   (set_attr "length" "4,4")])
8971
8972;; Optimize insertion of const_int values of type 1...1xxxx.
8973(define_insn ""
8974  [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
8975			 (match_operand:SI 1 "uint5_operand" "")
8976			 (match_operand:SI 2 "uint5_operand" ""))
8977	(match_operand:SI 3 "const_int_operand" ""))]
8978  "(INTVAL (operands[3]) & 0x10) != 0 &&
8979   (~INTVAL (operands[3]) & ((1L << INTVAL (operands[1])) - 1) & ~0xf) == 0"
8980  "*
8981{
8982  operands[3] = GEN_INT ((INTVAL (operands[3]) & 0xf) - 0x10);
8983  return \"{depi|depwi} %3,%2+%1-1,%1,%0\";
8984}"
8985  [(set_attr "type" "shift")
8986   (set_attr "length" "4")])
8987
8988(define_expand "insvdi"
8989  [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "")
8990			 (match_operand:DI 1 "uint6_operand" "")
8991			 (match_operand:DI 2 "uint6_operand" ""))
8992	(match_operand:DI 3 "arith5_operand" ""))]
8993  "TARGET_64BIT"
8994  "
8995{
8996  unsigned HOST_WIDE_INT len = UINTVAL (operands[1]);
8997  unsigned HOST_WIDE_INT pos = UINTVAL (operands[2]);
8998
8999  /* PA insertion insns don't support zero length bitfields or fields
9000     extending beyond the left or right-most bits.  Also, the predicate
9001     rejects lengths equal to a doubleword as they are better handled by
9002     the move patterns.  */
9003  if (len <= 0 || pos + len > 64)
9004    FAIL;
9005
9006  /* From mips.md: insert_bit_field doesn't verify that our destination
9007     matches the predicate, so check it again here.  */
9008  if (!register_operand (operands[0], VOIDmode))
9009    FAIL;
9010
9011  emit_insn (gen_insv_64 (operands[0], operands[1],
9012			  operands[2], operands[3]));
9013  DONE;
9014}")
9015
9016(define_insn "insv_64"
9017  [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+r,r")
9018			 (match_operand:DI 1 "uint6_operand" "")
9019			 (match_operand:DI 2 "uint6_operand" ""))
9020	(match_operand:DI 3 "arith5_operand" "r,L"))]
9021  "TARGET_64BIT
9022   && UINTVAL (operands[1]) > 0
9023   && UINTVAL (operands[1]) + UINTVAL (operands[2]) <= 64"
9024  "@
9025   depd %3,%2+%1-1,%1,%0
9026   depdi %3,%2+%1-1,%1,%0"
9027  [(set_attr "type" "shift,shift")
9028   (set_attr "length" "4,4")])
9029
9030;; Optimize insertion of const_int values of type 1...1xxxx.
9031(define_insn ""
9032  [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+r")
9033			 (match_operand:DI 1 "uint6_operand" "")
9034			 (match_operand:DI 2 "uint6_operand" ""))
9035	(match_operand:DI 3 "const_int_operand" ""))]
9036  "(INTVAL (operands[3]) & 0x10) != 0
9037   && TARGET_64BIT
9038   && (~INTVAL (operands[3]) & ((1L << INTVAL (operands[1])) - 1) & ~0xf) == 0"
9039  "*
9040{
9041  operands[3] = GEN_INT ((INTVAL (operands[3]) & 0xf) - 0x10);
9042  return \"depdi %3,%2+%1-1,%1,%0\";
9043}"
9044  [(set_attr "type" "shift")
9045   (set_attr "length" "4")])
9046
9047(define_insn ""
9048  [(set (match_operand:DI 0 "register_operand" "=r")
9049	(ashift:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
9050		   (const_int 32)))]
9051  "TARGET_64BIT"
9052  "depd,z %1,31,32,%0"
9053  [(set_attr "type" "shift")
9054   (set_attr "length" "4")])
9055
9056;; This insn is used for some loop tests, typically loops reversed when
9057;; strength reduction is used.  It is actually created when the instruction
9058;; combination phase combines the special loop test.  Since this insn
9059;; is both a jump insn and has an output, it must deal with its own
9060;; reloads, hence the `Q' constraints.  The `!' constraints direct reload
9061;; to not choose the register alternatives in the event a reload is needed.
9062(define_insn "decrement_and_branch_until_zero"
9063  [(set (pc)
9064	(if_then_else
9065	  (match_operator 2 "ordered_comparison_operator"
9066	   [(plus:SI
9067	      (match_operand:SI 0 "reg_before_reload_operand" "+!r,!*f,*Q")
9068	      (match_operand:SI 1 "int5_operand" "L,L,L"))
9069	    (const_int 0)])
9070	  (label_ref (match_operand 3 "" ""))
9071	  (pc)))
9072   (set (match_dup 0)
9073	(plus:SI (match_dup 0) (match_dup 1)))
9074   (clobber (match_scratch:SI 4 "=X,r,r"))]
9075  ""
9076  "* return pa_output_dbra (operands, insn, which_alternative); "
9077;; Do not expect to understand this the first time through.
9078[(set_attr "type" "cbranch,multi,multi")
9079 (set (attr "length")
9080      (if_then_else (eq_attr "alternative" "0")
9081;; Loop counter in register case
9082;; Short branch has length of 4
9083;; Long branch has length of 8, 20, 24 or 28
9084	(cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9085	       (const_int MAX_12BIT_OFFSET))
9086	   (const_int 4)
9087	   (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9088	       (const_int MAX_17BIT_OFFSET))
9089	   (const_int 8)
9090	   (match_test "TARGET_PORTABLE_RUNTIME")
9091	   (const_int 24)
9092	   (not (match_test "flag_pic"))
9093	   (const_int 20)]
9094	  (const_int 28))
9095
9096;; Loop counter in FP reg case.
9097;; Extra goo to deal with additional reload insns.
9098	(if_then_else (eq_attr "alternative" "1")
9099	  (if_then_else (lt (match_dup 3) (pc))
9100	     (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 24))))
9101		      (const_int MAX_12BIT_OFFSET))
9102		    (const_int 24)
9103		    (lt (abs (minus (match_dup 3) (plus (pc) (const_int 24))))
9104		      (const_int MAX_17BIT_OFFSET))
9105		    (const_int 28)
9106		    (match_test "TARGET_PORTABLE_RUNTIME")
9107		    (const_int 44)
9108		    (not (match_test "flag_pic"))
9109		    (const_int 40)]
9110		  (const_int 48))
9111	     (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9112		      (const_int MAX_12BIT_OFFSET))
9113		    (const_int 24)
9114		    (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9115		      (const_int MAX_17BIT_OFFSET))
9116		    (const_int 28)
9117		    (match_test "TARGET_PORTABLE_RUNTIME")
9118		    (const_int 44)
9119		    (not (match_test "flag_pic"))
9120		    (const_int 40)]
9121		  (const_int 48)))
9122
9123;; Loop counter in memory case.
9124;; Extra goo to deal with additional reload insns.
9125	(if_then_else (lt (match_dup 3) (pc))
9126	     (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9127		      (const_int MAX_12BIT_OFFSET))
9128		    (const_int 12)
9129		    (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9130		      (const_int MAX_17BIT_OFFSET))
9131		    (const_int 16)
9132		    (match_test "TARGET_PORTABLE_RUNTIME")
9133		    (const_int 32)
9134		    (not (match_test "flag_pic"))
9135		    (const_int 28)]
9136		  (const_int 36))
9137	     (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9138		      (const_int MAX_12BIT_OFFSET))
9139		    (const_int 12)
9140		    (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9141		      (const_int MAX_17BIT_OFFSET))
9142		    (const_int 16)
9143		    (match_test "TARGET_PORTABLE_RUNTIME")
9144		    (const_int 32)
9145		    (not (match_test "flag_pic"))
9146		    (const_int 28)]
9147		  (const_int 36))))))])
9148
9149(define_insn ""
9150  [(set (pc)
9151	(if_then_else
9152	  (match_operator 2 "movb_comparison_operator"
9153	   [(match_operand:SI 1 "register_operand" "r,r,r,r") (const_int 0)])
9154	  (label_ref (match_operand 3 "" ""))
9155	  (pc)))
9156   (set (match_operand:SI 0 "reg_before_reload_operand" "=!r,!*f,*Q,!*q")
9157	(match_dup 1))]
9158  ""
9159"* return pa_output_movb (operands, insn, which_alternative, 0); "
9160;; Do not expect to understand this the first time through.
9161[(set_attr "type" "cbranch,multi,multi,multi")
9162 (set (attr "length")
9163      (if_then_else (eq_attr "alternative" "0")
9164;; Loop counter in register case
9165;; Short branch has length of 4
9166;; Long branch has length of 8, 20, 24 or 28
9167        (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9168	       (const_int MAX_12BIT_OFFSET))
9169	   (const_int 4)
9170	   (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9171	       (const_int MAX_17BIT_OFFSET))
9172	   (const_int 8)
9173	   (match_test "TARGET_PORTABLE_RUNTIME")
9174	   (const_int 24)
9175	   (not (match_test "flag_pic"))
9176	   (const_int 20)]
9177	  (const_int 28))
9178
9179;; Loop counter in FP reg case.
9180;; Extra goo to deal with additional reload insns.
9181	(if_then_else (eq_attr "alternative" "1")
9182	  (if_then_else (lt (match_dup 3) (pc))
9183	     (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9184		      (const_int MAX_12BIT_OFFSET))
9185		    (const_int 12)
9186		    (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9187		      (const_int MAX_17BIT_OFFSET))
9188		    (const_int 16)
9189		    (match_test "TARGET_PORTABLE_RUNTIME")
9190		    (const_int 32)
9191		    (not (match_test "flag_pic"))
9192		    (const_int 28)]
9193		  (const_int 36))
9194	     (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9195		      (const_int MAX_12BIT_OFFSET))
9196		    (const_int 12)
9197		    (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9198		      (const_int MAX_17BIT_OFFSET))
9199		    (const_int 16)
9200		    (match_test "TARGET_PORTABLE_RUNTIME")
9201		    (const_int 32)
9202		    (not (match_test "flag_pic"))
9203		    (const_int 28)]
9204		  (const_int 36)))
9205
9206;; Loop counter in memory or sar case.
9207;; Extra goo to deal with additional reload insns.
9208	(cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9209		   (const_int MAX_12BIT_OFFSET))
9210		(const_int 8)
9211		(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9212		  (const_int MAX_17BIT_OFFSET))
9213		(const_int 12)
9214		(match_test "TARGET_PORTABLE_RUNTIME")
9215		(const_int 28)
9216		(not (match_test "flag_pic"))
9217		(const_int 24)]
9218	      (const_int 32)))))])
9219
9220;; Handle negated branch.
9221(define_insn ""
9222  [(set (pc)
9223	(if_then_else
9224	  (match_operator 2 "movb_comparison_operator"
9225	   [(match_operand:SI 1 "register_operand" "r,r,r,r") (const_int 0)])
9226	  (pc)
9227	  (label_ref (match_operand 3 "" ""))))
9228   (set (match_operand:SI 0 "reg_before_reload_operand" "=!r,!*f,*Q,!*q")
9229	(match_dup 1))]
9230  ""
9231"* return pa_output_movb (operands, insn, which_alternative, 1); "
9232;; Do not expect to understand this the first time through.
9233[(set_attr "type" "cbranch,multi,multi,multi")
9234 (set (attr "length")
9235      (if_then_else (eq_attr "alternative" "0")
9236;; Loop counter in register case
9237;; Short branch has length of 4
9238;; Long branch has length of 8
9239        (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9240	       (const_int MAX_12BIT_OFFSET))
9241	   (const_int 4)
9242	   (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9243	       (const_int MAX_17BIT_OFFSET))
9244	   (const_int 8)
9245	   (match_test "TARGET_PORTABLE_RUNTIME")
9246	   (const_int 24)
9247	   (not (match_test "flag_pic"))
9248	   (const_int 20)]
9249	  (const_int 28))
9250
9251;; Loop counter in FP reg case.
9252;; Extra goo to deal with additional reload insns.
9253	(if_then_else (eq_attr "alternative" "1")
9254	  (if_then_else (lt (match_dup 3) (pc))
9255	     (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9256		      (const_int MAX_12BIT_OFFSET))
9257		    (const_int 12)
9258		    (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9259		      (const_int MAX_17BIT_OFFSET))
9260		    (const_int 16)
9261		    (match_test "TARGET_PORTABLE_RUNTIME")
9262		    (const_int 32)
9263		    (not (match_test "flag_pic"))
9264		    (const_int 28)]
9265		  (const_int 36))
9266	     (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9267		      (const_int MAX_12BIT_OFFSET))
9268		    (const_int 12)
9269		    (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9270		      (const_int MAX_17BIT_OFFSET))
9271		    (const_int 16)
9272		    (match_test "TARGET_PORTABLE_RUNTIME")
9273		    (const_int 32)
9274		    (not (match_test "flag_pic"))
9275		    (const_int 28)]
9276		  (const_int 36)))
9277
9278;; Loop counter in memory or SAR case.
9279;; Extra goo to deal with additional reload insns.
9280	(cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9281		   (const_int MAX_12BIT_OFFSET))
9282		(const_int 8)
9283		(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9284		  (const_int MAX_17BIT_OFFSET))
9285		(const_int 12)
9286		(match_test "TARGET_PORTABLE_RUNTIME")
9287		(const_int 28)
9288		(not (match_test "flag_pic"))
9289		(const_int 24)]
9290	      (const_int 32)))))])
9291
9292(define_insn ""
9293  [(set (pc) (label_ref (match_operand 3 "" "" )))
9294   (set (match_operand:SI 0 "ireg_operand" "=r")
9295	(plus:SI (match_operand:SI 1 "ireg_operand" "r")
9296		 (match_operand:SI 2 "ireg_or_int5_operand" "rL")))]
9297  "(reload_completed && operands[0] == operands[1]) || operands[0] == operands[2]"
9298  "*
9299{
9300  return pa_output_parallel_addb (operands, insn);
9301}"
9302[(set_attr "type" "parallel_branch")
9303 (set (attr "length")
9304    (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9305	       (const_int MAX_12BIT_OFFSET))
9306	   (const_int 4)
9307	   (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9308	       (const_int MAX_17BIT_OFFSET))
9309	   (const_int 8)
9310	   (match_test "TARGET_PORTABLE_RUNTIME")
9311	   (const_int 24)
9312	   (not (match_test "flag_pic"))
9313	   (const_int 20)]
9314	  (const_int 28)))])
9315
9316(define_insn ""
9317  [(set (pc) (label_ref (match_operand 2 "" "" )))
9318   (set (match_operand:SF 0 "ireg_operand" "=r")
9319	(match_operand:SF 1 "ireg_or_int5_operand" "rL"))]
9320  "reload_completed"
9321  "*
9322{
9323  return pa_output_parallel_movb (operands, insn);
9324}"
9325[(set_attr "type" "parallel_branch")
9326 (set (attr "length")
9327    (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9328	       (const_int MAX_12BIT_OFFSET))
9329	   (const_int 4)
9330	   (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9331	       (const_int MAX_17BIT_OFFSET))
9332	   (const_int 8)
9333	   (match_test "TARGET_PORTABLE_RUNTIME")
9334	   (const_int 24)
9335	   (not (match_test "flag_pic"))
9336	   (const_int 20)]
9337	  (const_int 28)))])
9338
9339(define_insn ""
9340  [(set (pc) (label_ref (match_operand 2 "" "" )))
9341   (set (match_operand:SI 0 "ireg_operand" "=r")
9342	(match_operand:SI 1 "ireg_or_int5_operand" "rL"))]
9343  "reload_completed"
9344  "*
9345{
9346  return pa_output_parallel_movb (operands, insn);
9347}"
9348[(set_attr "type" "parallel_branch")
9349 (set (attr "length")
9350    (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9351	       (const_int MAX_12BIT_OFFSET))
9352	   (const_int 4)
9353	   (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9354	       (const_int MAX_17BIT_OFFSET))
9355	   (const_int 8)
9356	   (match_test "TARGET_PORTABLE_RUNTIME")
9357	   (const_int 24)
9358	   (not (match_test "flag_pic"))
9359	   (const_int 20)]
9360	  (const_int 28)))])
9361
9362(define_insn ""
9363  [(set (pc) (label_ref (match_operand 2 "" "" )))
9364   (set (match_operand:HI 0 "ireg_operand" "=r")
9365	(match_operand:HI 1 "ireg_or_int5_operand" "rL"))]
9366  "reload_completed"
9367  "*
9368{
9369  return pa_output_parallel_movb (operands, insn);
9370}"
9371[(set_attr "type" "parallel_branch")
9372 (set (attr "length")
9373    (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9374	       (const_int MAX_12BIT_OFFSET))
9375	   (const_int 4)
9376	   (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9377	       (const_int MAX_17BIT_OFFSET))
9378	   (const_int 8)
9379	   (match_test "TARGET_PORTABLE_RUNTIME")
9380	   (const_int 24)
9381	   (not (match_test "flag_pic"))
9382	   (const_int 20)]
9383	  (const_int 28)))])
9384
9385(define_insn ""
9386  [(set (pc) (label_ref (match_operand 2 "" "" )))
9387   (set (match_operand:QI 0 "ireg_operand" "=r")
9388	(match_operand:QI 1 "ireg_or_int5_operand" "rL"))]
9389  "reload_completed"
9390  "*
9391{
9392  return pa_output_parallel_movb (operands, insn);
9393}"
9394[(set_attr "type" "parallel_branch")
9395 (set (attr "length")
9396    (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9397	       (const_int MAX_12BIT_OFFSET))
9398	   (const_int 4)
9399	   (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9400	       (const_int MAX_17BIT_OFFSET))
9401	   (const_int 8)
9402	   (match_test "TARGET_PORTABLE_RUNTIME")
9403	   (const_int 24)
9404	   (not (match_test "flag_pic"))
9405	   (const_int 20)]
9406	  (const_int 28)))])
9407
9408(define_insn ""
9409  [(set (match_operand 0 "register_operand" "=f")
9410	(mult (match_operand 1 "register_operand" "f")
9411	      (match_operand 2 "register_operand" "f")))
9412   (set (match_operand 3 "register_operand" "+f")
9413	(plus (match_operand 4 "register_operand" "f")
9414	      (match_operand 5 "register_operand" "f")))]
9415  "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9416   && reload_completed && pa_fmpyaddoperands (operands)"
9417  "*
9418{
9419  if (GET_MODE (operands[0]) == DFmode)
9420    {
9421      if (rtx_equal_p (operands[3], operands[5]))
9422	return \"fmpyadd,dbl %1,%2,%0,%4,%3\";
9423      else
9424	return \"fmpyadd,dbl %1,%2,%0,%5,%3\";
9425    }
9426  else
9427    {
9428      if (rtx_equal_p (operands[3], operands[5]))
9429	return \"fmpyadd,sgl %1,%2,%0,%4,%3\";
9430      else
9431	return \"fmpyadd,sgl %1,%2,%0,%5,%3\";
9432    }
9433}"
9434  [(set_attr "type" "fpalu")
9435   (set_attr "length" "4")])
9436
9437(define_insn ""
9438  [(set (match_operand 3 "register_operand" "+f")
9439	(plus (match_operand 4 "register_operand" "f")
9440	      (match_operand 5 "register_operand" "f")))
9441   (set (match_operand 0 "register_operand" "=f")
9442	(mult (match_operand 1 "register_operand" "f")
9443	      (match_operand 2 "register_operand" "f")))]
9444  "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9445   && reload_completed && pa_fmpyaddoperands (operands)"
9446  "*
9447{
9448  if (GET_MODE (operands[0]) == DFmode)
9449    {
9450      if (rtx_equal_p (operands[3], operands[5]))
9451	return \"fmpyadd,dbl %1,%2,%0,%4,%3\";
9452      else
9453	return \"fmpyadd,dbl %1,%2,%0,%5,%3\";
9454    }
9455  else
9456    {
9457      if (rtx_equal_p (operands[3], operands[5]))
9458	return \"fmpyadd,sgl %1,%2,%0,%4,%3\";
9459      else
9460	return \"fmpyadd,sgl %1,%2,%0,%5,%3\";
9461    }
9462}"
9463  [(set_attr "type" "fpalu")
9464   (set_attr "length" "4")])
9465
9466(define_insn ""
9467  [(set (match_operand 0 "register_operand" "=f")
9468	(mult (match_operand 1 "register_operand" "f")
9469	      (match_operand 2 "register_operand" "f")))
9470   (set (match_operand 3 "register_operand" "+f")
9471	(minus (match_operand 4 "register_operand" "f")
9472	       (match_operand 5 "register_operand" "f")))]
9473  "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9474   && reload_completed && pa_fmpysuboperands (operands)"
9475  "*
9476{
9477  if (GET_MODE (operands[0]) == DFmode)
9478    return \"fmpysub,dbl %1,%2,%0,%5,%3\";
9479  else
9480    return \"fmpysub,sgl %1,%2,%0,%5,%3\";
9481}"
9482  [(set_attr "type" "fpalu")
9483   (set_attr "length" "4")])
9484
9485(define_insn ""
9486  [(set (match_operand 3 "register_operand" "+f")
9487	(minus (match_operand 4 "register_operand" "f")
9488	       (match_operand 5 "register_operand" "f")))
9489   (set (match_operand 0 "register_operand" "=f")
9490	(mult (match_operand 1 "register_operand" "f")
9491	      (match_operand 2 "register_operand" "f")))]
9492  "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9493   && reload_completed && pa_fmpysuboperands (operands)"
9494  "*
9495{
9496  if (GET_MODE (operands[0]) == DFmode)
9497    return \"fmpysub,dbl %1,%2,%0,%5,%3\";
9498  else
9499    return \"fmpysub,sgl %1,%2,%0,%5,%3\";
9500}"
9501  [(set_attr "type" "fpalu")
9502   (set_attr "length" "4")])
9503
9504;; The following two patterns are used by the trampoline code for nested
9505;; functions.  They flush the I and D cache lines from the start address
9506;; (operand0) to the end address (operand1).  No lines are flushed if the
9507;; end address is less than the start address (unsigned).
9508;;
9509;; Because the range of memory flushed is variable and the size of a MEM
9510;; can only be a CONST_INT, the patterns specify that they perform an
9511;; unspecified volatile operation on all memory.
9512;;
9513;; The address range for an icache flush must lie within a single
9514;; space on targets with non-equivalent space registers.
9515;;
9516;; Operand 0 contains the start address.
9517;; Operand 1 contains the end address.
9518;; Operand 2 contains the line length to use.
9519(define_insn "dcacheflush<P:mode>"
9520  [(const_int 1)
9521   (unspec_volatile [(mem:BLK (scratch))] UNSPECV_DCACHE)
9522   (use (match_operand 0 "pmode_register_operand" "r"))
9523   (use (match_operand 1 "pmode_register_operand" "r"))
9524   (use (match_operand 2 "pmode_register_operand" "r"))
9525   (clobber (match_scratch:P 3 "=&0"))]
9526  ""
9527  "cmpb,<dwc><<=,n %3,%1,.\;fdc,m %2(%3)\;sync"
9528  [(set_attr "type" "multi")
9529   (set_attr "length" "12")])
9530
9531(define_insn "icacheflush<P:mode>"
9532  [(const_int 2)
9533   (unspec_volatile [(mem:BLK (scratch))] UNSPECV_ICACHE)
9534   (use (match_operand 0 "pmode_register_operand" "r"))
9535   (use (match_operand 1 "pmode_register_operand" "r"))
9536   (use (match_operand 2 "pmode_register_operand" "r"))
9537   (clobber (match_operand 3 "pmode_register_operand" "=&r"))
9538   (clobber (match_operand 4 "pmode_register_operand" "=&r"))
9539   (clobber (match_scratch:P 5 "=&0"))]
9540  ""
9541  "mfsp %%sr0,%4\;ldsid (%5),%3\;mtsp %3,%%sr0\;cmpb,<dwc><<=,n %5,%1,.\;fic,m %2(%%sr0,%5)\;sync\;mtsp %4,%%sr0\;nop\;nop\;nop\;nop\;nop\;nop"
9542  [(set_attr "type" "multi")
9543   (set_attr "length" "52")])
9544
9545;; An out-of-line prologue.
9546(define_insn "outline_prologue_call"
9547  [(unspec_volatile [(const_int 0)] UNSPECV_OPC)
9548   (clobber (reg:SI 31))
9549   (clobber (reg:SI 22))
9550   (clobber (reg:SI 21))
9551   (clobber (reg:SI 20))
9552   (clobber (reg:SI 19))
9553   (clobber (reg:SI 1))]
9554  ""
9555  "*
9556{
9557
9558  /* We need two different versions depending on whether or not we
9559     need a frame pointer.   Also note that we return to the instruction
9560     immediately after the branch rather than two instructions after the
9561     break as normally is the case.  */
9562  if (frame_pointer_needed)
9563    {
9564      /* Must import the magic millicode routine(s).  */
9565      output_asm_insn (\".IMPORT __outline_prologue_fp,MILLICODE\", NULL);
9566
9567      if (TARGET_PORTABLE_RUNTIME)
9568	{
9569	  output_asm_insn (\"ldil L'__outline_prologue_fp,%%r31\", NULL);
9570	  output_asm_insn (\"ble,n R'__outline_prologue_fp(%%sr0,%%r31)\",
9571			   NULL);
9572	}
9573      else
9574	output_asm_insn (\"{bl|b,l},n __outline_prologue_fp,%%r31\", NULL);
9575    }
9576  else
9577    {
9578      /* Must import the magic millicode routine(s).  */
9579      output_asm_insn (\".IMPORT __outline_prologue,MILLICODE\", NULL);
9580
9581      if (TARGET_PORTABLE_RUNTIME)
9582	{
9583	  output_asm_insn (\"ldil L'__outline_prologue,%%r31\", NULL);
9584	  output_asm_insn (\"ble,n R'__outline_prologue(%%sr0,%%r31)\", NULL);
9585	}
9586      else
9587	output_asm_insn (\"{bl|b,l},n __outline_prologue,%%r31\", NULL);
9588    }
9589  return \"\";
9590}"
9591  [(set_attr "type" "multi")
9592   (set_attr "length" "8")])
9593
9594;; An out-of-line epilogue.
9595(define_insn "outline_epilogue_call"
9596  [(unspec_volatile [(const_int 1)] UNSPECV_OEC)
9597   (use (reg:SI 29))
9598   (use (reg:SI 28))
9599   (clobber (reg:SI 31))
9600   (clobber (reg:SI 22))
9601   (clobber (reg:SI 21))
9602   (clobber (reg:SI 20))
9603   (clobber (reg:SI 19))
9604   (clobber (reg:SI 2))
9605   (clobber (reg:SI 1))]
9606  ""
9607  "*
9608{
9609
9610  /* We need two different versions depending on whether or not we
9611     need a frame pointer.   Also note that we return to the instruction
9612     immediately after the branch rather than two instructions after the
9613     break as normally is the case.  */
9614  if (frame_pointer_needed)
9615    {
9616      /* Must import the magic millicode routine.  */
9617      output_asm_insn (\".IMPORT __outline_epilogue_fp,MILLICODE\", NULL);
9618
9619      /* The out-of-line prologue will make sure we return to the right
9620	 instruction.  */
9621      if (TARGET_PORTABLE_RUNTIME)
9622	{
9623	  output_asm_insn (\"ldil L'__outline_epilogue_fp,%%r31\", NULL);
9624	  output_asm_insn (\"ble,n R'__outline_epilogue_fp(%%sr0,%%r31)\",
9625			   NULL);
9626	}
9627      else
9628	output_asm_insn (\"{bl|b,l},n __outline_epilogue_fp,%%r31\", NULL);
9629    }
9630  else
9631    {
9632      /* Must import the magic millicode routine.  */
9633      output_asm_insn (\".IMPORT __outline_epilogue,MILLICODE\", NULL);
9634
9635      /* The out-of-line prologue will make sure we return to the right
9636	 instruction.  */
9637      if (TARGET_PORTABLE_RUNTIME)
9638	{
9639	  output_asm_insn (\"ldil L'__outline_epilogue,%%r31\", NULL);
9640	  output_asm_insn (\"ble,n R'__outline_epilogue(%%sr0,%%r31)\", NULL);
9641	}
9642      else
9643	output_asm_insn (\"{bl|b,l},n __outline_epilogue,%%r31\", NULL);
9644    }
9645  return \"\";
9646}"
9647  [(set_attr "type" "multi")
9648   (set_attr "length" "8")])
9649
9650;; Given a function pointer, canonicalize it so it can be
9651;; reliably compared to another function pointer.  */
9652(define_expand "canonicalize_funcptr_for_compare"
9653  [(set (reg:SI 26) (match_operand:SI 1 "register_operand" ""))
9654   (parallel [(set (reg:SI 29) (unspec:SI [(reg:SI 26)] UNSPEC_CFFC))
9655	      (clobber (match_dup 2))
9656	      (clobber (reg:SI 26))
9657	      (clobber (reg:SI 22))
9658	      (clobber (reg:SI 31))])
9659   (set (match_operand:SI 0 "register_operand" "")
9660	(reg:SI 29))]
9661  "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
9662  "
9663{
9664  if (TARGET_ELF32)
9665    {
9666      rtx canonicalize_funcptr_for_compare_libfunc
9667        = init_one_libfunc (CANONICALIZE_FUNCPTR_FOR_COMPARE_LIBCALL);
9668
9669      emit_library_call_value (canonicalize_funcptr_for_compare_libfunc,
9670      			       operands[0], LCT_NORMAL, Pmode,
9671			       operands[1], Pmode);
9672      DONE;
9673    }
9674
9675  operands[2] = gen_reg_rtx (SImode);
9676  if (GET_CODE (operands[1]) != REG)
9677    {
9678      rtx tmp = gen_reg_rtx (Pmode);
9679      emit_move_insn (tmp, operands[1]);
9680      operands[1] = tmp;
9681    }
9682}")
9683
9684(define_insn "*$$sh_func_adrs"
9685  [(set (reg:SI 29) (unspec:SI [(reg:SI 26)] UNSPEC_CFFC))
9686   (clobber (match_operand:SI 0 "register_operand" "=a"))
9687   (clobber (reg:SI 26))
9688   (clobber (reg:SI 22))
9689   (clobber (reg:SI 31))]
9690  "!TARGET_64BIT"
9691  "*
9692{
9693  int length = get_attr_length (insn);
9694  rtx xoperands[2];
9695
9696  xoperands[0] = GEN_INT (length - 8);
9697  xoperands[1] = GEN_INT (length - 16);
9698
9699  /* Must import the magic millicode routine.  */
9700  output_asm_insn (\".IMPORT $$sh_func_adrs,MILLICODE\", NULL);
9701
9702  /* This is absolutely amazing.
9703
9704     First, copy our input parameter into %r29 just in case we don't
9705     need to call $$sh_func_adrs.  */
9706  output_asm_insn (\"copy %%r26,%%r29\", NULL);
9707  output_asm_insn (\"{extru|extrw,u} %%r26,31,2,%%r31\", NULL);
9708
9709  /* Next, examine the low two bits in %r26, if they aren't 0x2, then
9710     we use %r26 unchanged.  */
9711  output_asm_insn (\"{comib|cmpib},<>,n 2,%%r31,.+%0\", xoperands);
9712  output_asm_insn (\"ldi 4096,%%r31\", NULL);
9713
9714  /* Next, compare %r26 with 4096, if %r26 is less than or equal to
9715     4096, then again we use %r26 unchanged.  */
9716  output_asm_insn (\"{comb|cmpb},<<,n %%r26,%%r31,.+%1\", xoperands);
9717
9718  /* Finally, call $$sh_func_adrs to extract the function's real add24.  */
9719  return pa_output_millicode_call (insn,
9720				   gen_rtx_SYMBOL_REF (SImode,
9721						       \"$$sh_func_adrs\"));
9722}"
9723  [(set_attr "type" "sh_func_adrs")
9724   (set (attr "length")
9725	(cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 28)]
9726	      (plus (symbol_ref "pa_attr_length_millicode_call (insn)")
9727		    (const_int 20))))])
9728
9729;; On the PA, the PIC register is call clobbered, so it must
9730;; be saved & restored around calls by the caller.  If the call
9731;; doesn't return normally (nonlocal goto, or an exception is
9732;; thrown), then the code at the exception handler label must
9733;; restore the PIC register.
9734(define_expand "exception_receiver"
9735  [(const_int 4)]
9736  "flag_pic"
9737  "
9738{
9739  /* On the 64-bit port, we need a blockage because there is
9740     confusion regarding the dependence of the restore on the
9741     frame pointer.  As a result, the frame pointer and pic
9742     register restores sometimes are interchanged erroneously.  */
9743  if (TARGET_64BIT)
9744    emit_insn (gen_blockage ());
9745  /* Restore the PIC register using hppa_pic_save_rtx ().  The
9746     PIC register is not saved in the frame in 64-bit ABI.  */
9747  emit_move_insn (pic_offset_table_rtx, hppa_pic_save_rtx ());
9748  emit_insn (gen_blockage ());
9749  DONE;
9750}")
9751
9752(define_expand "builtin_setjmp_receiver"
9753  [(label_ref (match_operand 0 "" ""))]
9754  "flag_pic"
9755  "
9756{
9757  if (TARGET_64BIT)
9758    emit_insn (gen_blockage ());
9759  /* Restore the PIC register.  Hopefully, this will always be from
9760     a stack slot.  The only registers that are valid after a
9761     builtin_longjmp are the stack and frame pointers.  */
9762  emit_move_insn (pic_offset_table_rtx, hppa_pic_save_rtx ());
9763  emit_insn (gen_blockage ());
9764  DONE;
9765}")
9766
9767;; Allocate new stack space and update the saved stack pointer in the
9768;; frame marker.  The HP C compilers also copy additional words in the
9769;; frame marker.  The 64-bit compiler copies words at -48, -32 and -24.
9770;; The 32-bit compiler copies the word at -16 (Static Link).  We
9771;; currently don't copy these values.
9772;;
9773;; Since the copy of the frame marker can't be done atomically, I
9774;; suspect that using it for unwind purposes may be somewhat unreliable.
9775;; The HP compilers appear to raise the stack and copy the frame
9776;; marker in a strict instruction sequence.  This suggests that the
9777;; unwind library may check for an alloca sequence when ALLOCA_FRAME
9778;; is set in the callinfo data.  We currently don't set ALLOCA_FRAME
9779;; as GAS doesn't support it, or try to keep the instructions emitted
9780;; here in strict sequence.
9781(define_expand "allocate_stack"
9782  [(match_operand 0 "" "")
9783   (match_operand 1 "" "")]
9784  ""
9785  "
9786{
9787  rtx addr;
9788
9789  /* Since the stack grows upward, we need to store virtual_stack_dynamic_rtx
9790     in operand 0 before adjusting the stack.  */
9791  emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
9792  anti_adjust_stack (operands[1]);
9793  if (TARGET_HPUX_UNWIND_LIBRARY)
9794    {
9795      addr = gen_rtx_PLUS (word_mode, stack_pointer_rtx,
9796			   GEN_INT (TARGET_64BIT ? -8 : -4));
9797      emit_move_insn (gen_rtx_MEM (word_mode, addr), hard_frame_pointer_rtx);
9798    }
9799  if (!TARGET_64BIT && flag_pic)
9800    {
9801      rtx addr = gen_rtx_PLUS (word_mode, stack_pointer_rtx, GEN_INT (-32));
9802      emit_move_insn (gen_rtx_MEM (word_mode, addr), pic_offset_table_rtx);
9803    }
9804  DONE;
9805}")
9806
9807(define_expand "prefetch"
9808  [(match_operand 0 "address_operand" "")
9809   (match_operand 1 "const_int_operand" "")
9810   (match_operand 2 "const_int_operand" "")]
9811  "TARGET_PA_20"
9812{
9813  operands[0] = copy_addr_to_reg (operands[0]);
9814  emit_insn (gen_prefetch_20 (operands[0], operands[1], operands[2]));
9815  DONE;
9816})
9817
9818(define_insn "prefetch_20"
9819  [(prefetch (match_operand 0 "pmode_register_operand" "r")
9820	     (match_operand:SI 1 "const_int_operand" "n")
9821	     (match_operand:SI 2 "const_int_operand" "n"))]
9822  "TARGET_PA_20"
9823{
9824  /* The SL cache-control completer indicates good spatial locality but
9825     poor temporal locality.  The ldw instruction with a target of general
9826     register 0 prefetches a cache line for a read.  The ldd instruction
9827     prefetches a cache line for a write.  */
9828  static const char * const instr[2][2] = {
9829    {
9830      "ldw,sl 0(%0),%%r0",
9831      "ldd,sl 0(%0),%%r0"
9832    },
9833    {
9834      "ldw 0(%0),%%r0",
9835      "ldd 0(%0),%%r0"
9836    }
9837  };
9838  int read_or_write = INTVAL (operands[1]) == 0 ? 0 : 1;
9839  int locality = INTVAL (operands[2]) == 0 ? 0 : 1;
9840
9841  return instr [locality][read_or_write];
9842}
9843  [(set_attr "type" "load")
9844   (set_attr "length" "4")])
9845
9846;; TLS Support
9847(define_insn "tgd_load"
9848 [(set (match_operand:SI 0 "register_operand" "=r")
9849       (unspec:SI [(match_operand 1 "tgd_symbolic_operand" "")] UNSPEC_TLSGD))
9850  (clobber (reg:SI 1))
9851  (use (reg:SI 27))]
9852  ""
9853  "*
9854{
9855  return \"addil LR'%1-$tls_gdidx$,%%r27\;ldo RR'%1-$tls_gdidx$(%%r1),%0\";
9856}"
9857  [(set_attr "type" "multi")
9858   (set_attr "length" "8")])
9859
9860(define_insn "tgd_load_pic"
9861 [(set (match_operand:SI 0 "register_operand" "=r")
9862       (unspec:SI [(match_operand 1 "tgd_symbolic_operand" "")] UNSPEC_TLSGD_PIC))
9863  (clobber (reg:SI 1))
9864  (use (reg:SI 19))]
9865  ""
9866  "*
9867{
9868  return \"addil LT'%1-$tls_gdidx$,%%r19\;ldo RT'%1-$tls_gdidx$(%%r1),%0\";
9869}"
9870  [(set_attr "type" "multi")
9871   (set_attr "length" "8")])
9872
9873(define_insn "tld_load"
9874 [(set (match_operand:SI 0 "register_operand" "=r")
9875       (unspec:SI [(match_operand 1 "tld_symbolic_operand" "")] UNSPEC_TLSLDM))
9876  (clobber (reg:SI 1))
9877  (use (reg:SI 27))]
9878  ""
9879  "*
9880{
9881  return \"addil LR'%1-$tls_ldidx$,%%r27\;ldo RR'%1-$tls_ldidx$(%%r1),%0\";
9882}"
9883  [(set_attr "type" "multi")
9884   (set_attr "length" "8")])
9885
9886(define_insn "tld_load_pic"
9887 [(set (match_operand:SI 0 "register_operand" "=r")
9888       (unspec:SI [(match_operand 1 "tld_symbolic_operand" "")] UNSPEC_TLSLDM_PIC))
9889  (clobber (reg:SI 1))
9890  (use (reg:SI 19))]
9891  ""
9892  "*
9893{
9894  return \"addil LT'%1-$tls_ldidx$,%%r19\;ldo RT'%1-$tls_ldidx$(%%r1),%0\";
9895}"
9896  [(set_attr "type" "multi")
9897   (set_attr "length" "8")])
9898
9899(define_insn "tld_offset_load"
9900  [(set (match_operand:SI 0 "register_operand" "=r")
9901        (plus:SI (unspec:SI [(match_operand 1 "tld_symbolic_operand" "")]
9902		 	    UNSPEC_TLSLDO)
9903		 (match_operand:SI 2 "register_operand" "r")))
9904   (clobber (reg:SI 1))]
9905  ""
9906  "*
9907{
9908  return \"addil LR'%1-$tls_dtpoff$,%2\;ldo RR'%1-$tls_dtpoff$(%%r1),%0\";
9909}"
9910  [(set_attr "type" "multi")
9911   (set_attr "length" "8")])
9912
9913(define_insn "tp_load"
9914  [(set (match_operand:SI 0 "register_operand" "=r")
9915	(unspec:SI [(const_int 0)] UNSPEC_TP))]
9916  ""
9917  "mfctl %%cr27,%0"
9918  [(set_attr "type" "multi")
9919   (set_attr "length" "4")])
9920
9921(define_insn "tie_load"
9922  [(set (match_operand:SI 0 "register_operand" "=r")
9923        (unspec:SI [(match_operand 1 "tie_symbolic_operand" "")] UNSPEC_TLSIE))
9924   (clobber (reg:SI 1))
9925   (use (reg:SI 27))]
9926  ""
9927  "*
9928{
9929  return \"addil LR'%1-$tls_ieoff$,%%r27\;ldw RR'%1-$tls_ieoff$(%%r1),%0\";
9930}"
9931  [(set_attr "type" "multi")
9932   (set_attr "length" "8")])
9933
9934(define_insn "tie_load_pic"
9935  [(set (match_operand:SI 0 "register_operand" "=r")
9936        (unspec:SI [(match_operand 1 "tie_symbolic_operand" "")] UNSPEC_TLSIE_PIC))
9937   (clobber (reg:SI 1))
9938   (use (reg:SI 19))]
9939  ""
9940  "*
9941{
9942  return \"addil LT'%1-$tls_ieoff$,%%r19\;ldw RT'%1-$tls_ieoff$(%%r1),%0\";
9943}"
9944  [(set_attr "type" "multi")
9945   (set_attr "length" "8")])
9946
9947(define_insn "tle_load"
9948  [(set (match_operand:SI 0 "register_operand" "=r")
9949        (plus:SI (unspec:SI [(match_operand 1 "tle_symbolic_operand" "")]
9950		 	    UNSPEC_TLSLE)
9951		 (match_operand:SI 2 "register_operand" "r")))
9952   (clobber (reg:SI 1))]
9953  ""
9954  "addil LR'%1-$tls_leoff$,%2\;ldo RR'%1-$tls_leoff$(%%r1),%0"
9955  [(set_attr "type" "multi")
9956   (set_attr "length" "8")])
9957
9958;; Atomic instructions
9959
9960;; All memory loads and stores access storage atomically except
9961;; for one exception.  The STORE BYTES, STORE DOUBLE BYTES, and
9962;; doubleword loads and stores are not guaranteed to be atomic
9963;; when referencing the I/O address space.
9964
9965;; These patterns are at the bottom so the non atomic versions are preferred.
9966
9967(define_expand "atomic_storeqi"
9968  [(match_operand:QI 0 "memory_operand")                ;; memory
9969   (match_operand:QI 1 "register_operand")              ;; val out
9970   (match_operand:SI 2 "const_int_operand")]            ;; model
9971  ""
9972{
9973  if (TARGET_SYNC_LIBCALL)
9974    {
9975      rtx mem = operands[0];
9976      rtx val = operands[1];
9977      if (pa_maybe_emit_compare_and_swap_exchange_loop (NULL_RTX, mem, val))
9978	DONE;
9979    }
9980  FAIL;
9981})
9982
9983;; Implement atomic HImode stores using exchange.
9984
9985(define_expand "atomic_storehi"
9986  [(match_operand:HI 0 "memory_operand")                ;; memory
9987   (match_operand:HI 1 "register_operand")              ;; val out
9988   (match_operand:SI 2 "const_int_operand")]            ;; model
9989  ""
9990{
9991  if (TARGET_SYNC_LIBCALL)
9992    {
9993      rtx mem = operands[0];
9994      rtx val = operands[1];
9995      if (pa_maybe_emit_compare_and_swap_exchange_loop (NULL_RTX, mem, val))
9996	DONE;
9997    }
9998  FAIL;
9999})
10000
10001;; Implement atomic SImode store using exchange.
10002
10003(define_expand "atomic_storesi"
10004  [(match_operand:SI 0 "memory_operand")                ;; memory
10005   (match_operand:SI 1 "register_operand")              ;; val out
10006   (match_operand:SI 2 "const_int_operand")]            ;; model
10007  ""
10008{
10009  if (TARGET_SYNC_LIBCALL)
10010    {
10011      rtx mem = operands[0];
10012      rtx val = operands[1];
10013      if (pa_maybe_emit_compare_and_swap_exchange_loop (NULL_RTX, mem, val))
10014	DONE;
10015    }
10016  FAIL;
10017})
10018
10019;; Implement atomic DImode load.
10020
10021(define_expand "atomic_loaddi"
10022  [(match_operand:DI 0 "register_operand")              ;; val out
10023   (match_operand:DI 1 "memory_operand")                ;; memory
10024   (match_operand:SI 2 "const_int_operand")]            ;; model
10025  ""
10026{
10027  enum memmodel model;
10028
10029  if (TARGET_64BIT || TARGET_DISABLE_FPREGS || TARGET_SOFT_FLOAT)
10030    FAIL;
10031
10032  model = memmodel_from_int (INTVAL (operands[2]));
10033  operands[1] = force_reg (SImode, XEXP (operands[1], 0));
10034  if (is_mm_seq_cst (model))
10035    expand_mem_thread_fence (model);
10036  emit_insn (gen_atomic_loaddi_1 (operands[0], operands[1]));
10037  expand_mem_thread_fence (model);
10038  DONE;
10039})
10040
10041(define_insn "atomic_loaddi_1"
10042  [(set (match_operand:DI 0 "register_operand" "=r")
10043        (mem:DI (match_operand:SI 1 "register_operand" "r")))
10044   (clobber (match_scratch:DI 2 "=f"))]
10045  "!TARGET_64BIT && !TARGET_DISABLE_FPREGS && !TARGET_SOFT_FLOAT"
10046  "{fldds|fldd} 0(%1),%2\n\t{fstds|fstd} %2,-16(%%sp)\n\t{ldws|ldw} -16(%%sp),%0\n\t{ldws|ldw} -12(%%sp),%R0"
10047  [(set_attr "type" "move")
10048   (set_attr "length" "16")])
10049
10050;; Implement atomic DImode store.
10051
10052(define_expand "atomic_storedi"
10053  [(match_operand:DI 0 "memory_operand")                ;; memory
10054   (match_operand:DI 1 "reg_or_cint_move_operand")      ;; val out
10055   (match_operand:SI 2 "const_int_operand")]            ;; model
10056  ""
10057{
10058  enum memmodel model;
10059
10060  if (TARGET_SYNC_LIBCALL)
10061    {
10062      rtx mem = operands[0];
10063      rtx val = operands[1];
10064      if (pa_maybe_emit_compare_and_swap_exchange_loop (NULL_RTX, mem, val))
10065	DONE;
10066    }
10067
10068  if (TARGET_64BIT || TARGET_DISABLE_FPREGS || TARGET_SOFT_FLOAT)
10069    FAIL;
10070
10071  model = memmodel_from_int (INTVAL (operands[2]));
10072  operands[0] = force_reg (SImode, XEXP (operands[0], 0));
10073  if (operands[1] != CONST0_RTX (DImode))
10074    operands[1] = force_reg (DImode, operands[1]);
10075  expand_mem_thread_fence (model);
10076  emit_insn (gen_atomic_storedi_1 (operands[0], operands[1]));
10077  if (is_mm_seq_cst (model))
10078    expand_mem_thread_fence (model);
10079  DONE;
10080})
10081
10082(define_insn "atomic_storedi_1"
10083  [(set (mem:DI (match_operand:SI 0 "register_operand" "r,r"))
10084        (match_operand:DI 1 "reg_or_0_operand" "M,r"))
10085   (clobber (match_scratch:DI 2 "=X,f"))]
10086  "!TARGET_64BIT && !TARGET_DISABLE_FPREGS && !TARGET_SOFT_FLOAT"
10087  "@
10088   {fstds|fstd} %%fr0,0(%0)
10089   {stws|stw} %1,-16(%%sp)\n\t{stws|stw} %R1,-12(%%sp)\n\t{fldds|fldd} -16(%%sp),%2\n\t{fstds|fstd} %2,0(%0)"
10090  [(set_attr "type" "move,move")
10091   (set_attr "length" "4,16")])
10092
10093;; PA 2.0 hardware supports out-of-order execution of loads and stores, so
10094;; we need memory barriers to enforce program order for memory references
10095;; when the TLB and PSW O bits are not set.  We assume all PA 2.0 systems
10096;; are weakly ordered since neither HP-UX or Linux set the PSW O bit.  Since
10097;; we want PA 1.x code to be PA 2.0 compatible, we also need barriers when
10098;; generating PA 1.x code even though all PA 1.x systems are strongly ordered.
10099
10100;; When barriers are needed, we use a strongly ordered ldcw instruction as
10101;; the barrier.  Most PA 2.0 targets are cache coherent.  In that case, we
10102;; can use the coherent cache control hint and avoid aligning the ldcw
10103;; address.  In spite of its description, it is not clear that the sync
10104;; instruction works as a barrier.
10105
10106(define_expand "memory_barrier"
10107  [(parallel
10108     [(set (match_dup 0) (unspec:BLK [(match_dup 0)] UNSPEC_MEMORY_BARRIER))
10109      (clobber (match_dup 1))])]
10110  ""
10111{
10112  /* We don't need a barrier if the target uses ordered memory references.  */
10113  if (TARGET_ORDERED)
10114    FAIL;
10115  operands[1] = gen_reg_rtx (Pmode);
10116  operands[0] = gen_rtx_MEM (BLKmode, operands[1]);
10117  MEM_VOLATILE_P (operands[0]) = 1;
10118})
10119
10120(define_insn "*memory_barrier_coherent"
10121  [(set (match_operand:BLK 0 "" "")
10122        (unspec:BLK [(match_dup 0)] UNSPEC_MEMORY_BARRIER))
10123   (clobber (match_operand 1 "pmode_register_operand" "=r"))]
10124  "TARGET_PA_20 && TARGET_COHERENT_LDCW"
10125  "ldcw,co 0(%%sp),%1"
10126  [(set_attr "type" "binary")
10127   (set_attr "length" "4")])
10128
10129(define_insn "*memory_barrier_64"
10130  [(set (match_operand:BLK 0 "" "")
10131        (unspec:BLK [(match_dup 0)] UNSPEC_MEMORY_BARRIER))
10132    (clobber (match_operand 1 "pmode_register_operand" "=&r"))]
10133  "TARGET_64BIT"
10134  "ldo 15(%%sp),%1\n\tdepd %%r0,63,3,%1\n\tldcw 0(%1),%1"
10135  [(set_attr "type" "binary")
10136   (set_attr "length" "12")])
10137
10138(define_insn "*memory_barrier_32"
10139  [(set (match_operand:BLK 0 "" "")
10140        (unspec:BLK [(match_dup 0)] UNSPEC_MEMORY_BARRIER))
10141    (clobber (match_operand 1 "pmode_register_operand" "=&r"))]
10142  ""
10143  "ldo 15(%%sp),%1\n\t{dep|depw} %%r0,31,3,%1\n\tldcw 0(%1),%1"
10144  [(set_attr "type" "binary")
10145   (set_attr "length" "12")])
10146