]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/pa/pa.md
* config/pa/pa.c (hppa_profile_hook): Allocate stack space for
[thirdparty/gcc.git] / gcc / config / pa / pa.md
1 ;;- Machine description for HP PA-RISC architecture for GCC compiler
2 ;; Copyright (C) 1992-2016 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 ])
88
89 ;; UNSPEC_VOLATILE:
90
91 (define_c_enum "unspecv"
92 [UNSPECV_BLOCKAGE ; blockage
93 UNSPECV_DCACHE ; dcacheflush
94 UNSPECV_ICACHE ; icacheflush
95 UNSPECV_OPC ; outline_prologue_call
96 UNSPECV_OEC ; outline_epilogue_call
97 UNSPECV_LONGJMP ; builtin_longjmp
98 ])
99
100 ;; Maximum pc-relative branch offsets.
101
102 ;; These numbers are a bit smaller than the maximum allowable offsets
103 ;; so that a few instructions may be inserted before the actual branch.
104
105 (define_constants
106 [(MAX_12BIT_OFFSET 8184) ; 12-bit branch
107 (MAX_17BIT_OFFSET 262100) ; 17-bit branch
108 ])
109
110 ;; Mode and code iterators
111
112 ;; This mode iterator allows :P to be used for patterns that operate on
113 ;; pointer-sized quantities. Exactly one of the two alternatives will match.
114 (define_mode_iterator P [(SI "Pmode == SImode") (DI "Pmode == DImode")])
115
116 ;; This attribute defines the condition prefix for word and double word
117 ;; add, compare, subtract and logical instructions.
118 (define_mode_attr dwc [(SI "") (DI "*")])
119
120 ;; Insn type. Used to default other attribute values.
121
122 ;; type "unary" insns have one input operand (1) and one output operand (0)
123 ;; type "binary" insns have two input operands (1,2) and one output (0)
124
125 (define_attr "type"
126 "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"
127 (const_string "binary"))
128
129 (define_attr "pa_combine_type"
130 "fmpy,faddsub,uncond_branch,addmove,none"
131 (const_string "none"))
132
133 ;; Processor type (for scheduling, not code generation) -- this attribute
134 ;; must exactly match the processor_type enumeration in pa.h.
135 ;;
136 ;; FIXME: Add 800 scheduling for completeness?
137
138 (define_attr "cpu" "700,7100,7100LC,7200,7300,8000" (const (symbol_ref "pa_cpu_attr")))
139
140 ;; Length (in # of bytes).
141 (define_attr "length" ""
142 (cond [(eq_attr "type" "load,fpload")
143 (if_then_else (match_operand 1 "symbolic_memory_operand" "")
144 (const_int 8) (const_int 4))
145
146 (eq_attr "type" "store,fpstore")
147 (if_then_else (match_operand 0 "symbolic_memory_operand" "")
148 (const_int 8) (const_int 4))
149
150 (eq_attr "type" "binary,shift,nullshift")
151 (if_then_else (match_operand 2 "arith14_operand" "")
152 (const_int 4) (const_int 12))
153
154 (eq_attr "type" "move,unary,shift,nullshift")
155 (if_then_else (match_operand 1 "arith14_operand" "")
156 (const_int 4) (const_int 8))]
157
158 (const_int 4)))
159
160 (define_asm_attributes
161 [(set_attr "length" "4")
162 (set_attr "type" "multi")])
163
164 ;; Attributes for instruction and branch scheduling
165
166 ;; For conditional branches. Frame related instructions are not allowed
167 ;; because they confuse the unwind support.
168 (define_attr "in_branch_delay" "false,true"
169 (if_then_else (and (eq_attr "type" "!uncond_branch,branch,cbranch,fbranch,call,sibcall,dyncall,multi,milli,sh_func_adrs,parallel_branch,trap")
170 (eq_attr "length" "4")
171 (not (match_test "RTX_FRAME_RELATED_P (insn)")))
172 (const_string "true")
173 (const_string "false")))
174
175 ;; Disallow instructions which use the FPU since they will tie up the FPU
176 ;; even if the instruction is nullified.
177 (define_attr "in_nullified_branch_delay" "false,true"
178 (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")
179 (eq_attr "length" "4")
180 (not (match_test "RTX_FRAME_RELATED_P (insn)")))
181 (const_string "true")
182 (const_string "false")))
183
184 ;; For calls and millicode calls.
185 (define_attr "in_call_delay" "false,true"
186 (if_then_else (and (eq_attr "type" "!uncond_branch,branch,cbranch,fbranch,call,sibcall,dyncall,multi,milli,sh_func_adrs,parallel_branch,trap")
187 (eq_attr "length" "4")
188 (not (match_test "RTX_FRAME_RELATED_P (insn)")))
189 (const_string "true")
190 (const_string "false")))
191
192 ;; Call delay slot description.
193 (define_delay (eq_attr "type" "call")
194 [(eq_attr "in_call_delay" "true") (nil) (nil)])
195
196 ;; Sibcall delay slot description.
197 (define_delay (eq_attr "type" "sibcall")
198 [(eq_attr "in_call_delay" "true") (nil) (nil)])
199
200 ;; Millicode call delay slot description.
201 (define_delay (eq_attr "type" "milli")
202 [(eq_attr "in_call_delay" "true") (nil) (nil)])
203
204 ;; Return and other similar instructions.
205 (define_delay (eq_attr "type" "branch,parallel_branch")
206 [(eq_attr "in_branch_delay" "true") (nil) (nil)])
207
208 ;; Floating point conditional branch delay slot description.
209 (define_delay (eq_attr "type" "fbranch")
210 [(eq_attr "in_branch_delay" "true")
211 (eq_attr "in_nullified_branch_delay" "true")
212 (nil)])
213
214 ;; Integer conditional branch delay slot description.
215 ;; Nullification of conditional branches on the PA is dependent on the
216 ;; direction of the branch. Forward branches nullify true and
217 ;; backward branches nullify false. If the direction is unknown
218 ;; then nullification is not allowed.
219 (define_delay (eq_attr "type" "cbranch")
220 [(eq_attr "in_branch_delay" "true")
221 (and (eq_attr "in_nullified_branch_delay" "true")
222 (attr_flag "forward"))
223 (and (eq_attr "in_nullified_branch_delay" "true")
224 (attr_flag "backward"))])
225
226 (define_delay (eq_attr "type" "uncond_branch")
227 [(eq_attr "in_branch_delay" "true") (nil) (nil)])
228
229 ;; Memory. Disregarding Cache misses, the Mustang memory times are:
230 ;; load: 2, fpload: 3
231 ;; store, fpstore: 3, no D-cache operations should be scheduled.
232
233 ;; The Timex (aka 700) has two floating-point units: ALU, and MUL/DIV/SQRT.
234 ;; Timings:
235 ;; Instruction Time Unit Minimum Distance (unit contention)
236 ;; fcpy 3 ALU 2
237 ;; fabs 3 ALU 2
238 ;; fadd 3 ALU 2
239 ;; fsub 3 ALU 2
240 ;; fcmp 3 ALU 2
241 ;; fcnv 3 ALU 2
242 ;; fmpyadd 3 ALU,MPY 2
243 ;; fmpysub 3 ALU,MPY 2
244 ;; fmpycfxt 3 ALU,MPY 2
245 ;; fmpy 3 MPY 2
246 ;; fmpyi 3 MPY 2
247 ;; fdiv,sgl 10 MPY 10
248 ;; fdiv,dbl 12 MPY 12
249 ;; fsqrt,sgl 14 MPY 14
250 ;; fsqrt,dbl 18 MPY 18
251 ;;
252 ;; We don't model fmpyadd/fmpysub properly as those instructions
253 ;; keep both the FP ALU and MPY units busy. Given that these
254 ;; processors are obsolete, I'm not going to spend the time to
255 ;; model those instructions correctly.
256
257 (define_automaton "pa700")
258 (define_cpu_unit "dummy_700,mem_700,fpalu_700,fpmpy_700" "pa700")
259
260 (define_insn_reservation "W0" 4
261 (and (eq_attr "type" "fpcc")
262 (eq_attr "cpu" "700"))
263 "fpalu_700*2")
264
265 (define_insn_reservation "W1" 3
266 (and (eq_attr "type" "fpalu")
267 (eq_attr "cpu" "700"))
268 "fpalu_700*2")
269
270 (define_insn_reservation "W2" 3
271 (and (eq_attr "type" "fpmulsgl,fpmuldbl")
272 (eq_attr "cpu" "700"))
273 "fpmpy_700*2")
274
275 (define_insn_reservation "W3" 10
276 (and (eq_attr "type" "fpdivsgl")
277 (eq_attr "cpu" "700"))
278 "fpmpy_700*10")
279
280 (define_insn_reservation "W4" 12
281 (and (eq_attr "type" "fpdivdbl")
282 (eq_attr "cpu" "700"))
283 "fpmpy_700*12")
284
285 (define_insn_reservation "W5" 14
286 (and (eq_attr "type" "fpsqrtsgl")
287 (eq_attr "cpu" "700"))
288 "fpmpy_700*14")
289
290 (define_insn_reservation "W6" 18
291 (and (eq_attr "type" "fpsqrtdbl")
292 (eq_attr "cpu" "700"))
293 "fpmpy_700*18")
294
295 (define_insn_reservation "W7" 2
296 (and (eq_attr "type" "load")
297 (eq_attr "cpu" "700"))
298 "mem_700")
299
300 (define_insn_reservation "W8" 2
301 (and (eq_attr "type" "fpload")
302 (eq_attr "cpu" "700"))
303 "mem_700")
304
305 (define_insn_reservation "W9" 3
306 (and (eq_attr "type" "store")
307 (eq_attr "cpu" "700"))
308 "mem_700*3")
309
310 (define_insn_reservation "W10" 3
311 (and (eq_attr "type" "fpstore")
312 (eq_attr "cpu" "700"))
313 "mem_700*3")
314
315 (define_insn_reservation "W11" 5
316 (and (eq_attr "type" "fpstore_load")
317 (eq_attr "cpu" "700"))
318 "mem_700*5")
319
320 (define_insn_reservation "W12" 6
321 (and (eq_attr "type" "store_fpload")
322 (eq_attr "cpu" "700"))
323 "mem_700*6")
324
325 (define_insn_reservation "W13" 1
326 (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpdivdbl,fpsqrtsgl,fpsqrtdbl,load,fpload,store,fpstore,fpstore_load,store_fpload")
327 (eq_attr "cpu" "700"))
328 "dummy_700")
329
330 ;; We have a bypass for all computations in the FP unit which feed an
331 ;; FP store as long as the sizes are the same.
332 (define_bypass 2 "W1,W2" "W10,W11" "pa_fpstore_bypass_p")
333 (define_bypass 9 "W3" "W10,W11" "pa_fpstore_bypass_p")
334 (define_bypass 11 "W4" "W10,W11" "pa_fpstore_bypass_p")
335 (define_bypass 13 "W5" "W10,W11" "pa_fpstore_bypass_p")
336 (define_bypass 17 "W6" "W10,W11" "pa_fpstore_bypass_p")
337
338 ;; We have an "anti-bypass" for FP loads which feed an FP store.
339 (define_bypass 4 "W8,W12" "W10,W11" "pa_fpstore_bypass_p")
340
341 ;; Function units for the 7100 and 7150. The 7100/7150 can dual-issue
342 ;; floating point computations with non-floating point computations (fp loads
343 ;; and stores are not fp computations).
344 ;;
345 ;; Memory. Disregarding Cache misses, memory loads take two cycles; stores also
346 ;; take two cycles, during which no Dcache operations should be scheduled.
347 ;; Any special cases are handled in pa_adjust_cost. The 7100, 7150 and 7100LC
348 ;; all have the same memory characteristics if one disregards cache misses.
349 ;;
350 ;; The 7100/7150 has three floating-point units: ALU, MUL, and DIV.
351 ;; There's no value in modeling the ALU and MUL separately though
352 ;; since there can never be a functional unit conflict given the
353 ;; latency and issue rates for those units.
354 ;;
355 ;; Timings:
356 ;; Instruction Time Unit Minimum Distance (unit contention)
357 ;; fcpy 2 ALU 1
358 ;; fabs 2 ALU 1
359 ;; fadd 2 ALU 1
360 ;; fsub 2 ALU 1
361 ;; fcmp 2 ALU 1
362 ;; fcnv 2 ALU 1
363 ;; fmpyadd 2 ALU,MPY 1
364 ;; fmpysub 2 ALU,MPY 1
365 ;; fmpycfxt 2 ALU,MPY 1
366 ;; fmpy 2 MPY 1
367 ;; fmpyi 2 MPY 1
368 ;; fdiv,sgl 8 DIV 8
369 ;; fdiv,dbl 15 DIV 15
370 ;; fsqrt,sgl 8 DIV 8
371 ;; fsqrt,dbl 15 DIV 15
372
373 (define_automaton "pa7100")
374 (define_cpu_unit "i_7100, f_7100,fpmac_7100,fpdivsqrt_7100,mem_7100" "pa7100")
375
376 (define_insn_reservation "X0" 2
377 (and (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
378 (eq_attr "cpu" "7100"))
379 "f_7100,fpmac_7100")
380
381 (define_insn_reservation "X1" 8
382 (and (eq_attr "type" "fpdivsgl,fpsqrtsgl")
383 (eq_attr "cpu" "7100"))
384 "f_7100+fpdivsqrt_7100,fpdivsqrt_7100*7")
385
386 (define_insn_reservation "X2" 15
387 (and (eq_attr "type" "fpdivdbl,fpsqrtdbl")
388 (eq_attr "cpu" "7100"))
389 "f_7100+fpdivsqrt_7100,fpdivsqrt_7100*14")
390
391 (define_insn_reservation "X3" 2
392 (and (eq_attr "type" "load")
393 (eq_attr "cpu" "7100"))
394 "i_7100+mem_7100")
395
396 (define_insn_reservation "X4" 2
397 (and (eq_attr "type" "fpload")
398 (eq_attr "cpu" "7100"))
399 "i_7100+mem_7100")
400
401 (define_insn_reservation "X5" 2
402 (and (eq_attr "type" "store")
403 (eq_attr "cpu" "7100"))
404 "i_7100+mem_7100,mem_7100")
405
406 (define_insn_reservation "X6" 2
407 (and (eq_attr "type" "fpstore")
408 (eq_attr "cpu" "7100"))
409 "i_7100+mem_7100,mem_7100")
410
411 (define_insn_reservation "X7" 4
412 (and (eq_attr "type" "fpstore_load")
413 (eq_attr "cpu" "7100"))
414 "i_7100+mem_7100,mem_7100*3")
415
416 (define_insn_reservation "X8" 4
417 (and (eq_attr "type" "store_fpload")
418 (eq_attr "cpu" "7100"))
419 "i_7100+mem_7100,mem_7100*3")
420
421 (define_insn_reservation "X9" 1
422 (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl,load,fpload,store,fpstore,fpstore_load,store_fpload")
423 (eq_attr "cpu" "7100"))
424 "i_7100")
425
426 ;; We have a bypass for all computations in the FP unit which feed an
427 ;; FP store as long as the sizes are the same.
428 (define_bypass 1 "X0" "X6,X7" "pa_fpstore_bypass_p")
429 (define_bypass 7 "X1" "X6,X7" "pa_fpstore_bypass_p")
430 (define_bypass 14 "X2" "X6,X7" "pa_fpstore_bypass_p")
431
432 ;; We have an "anti-bypass" for FP loads which feed an FP store.
433 (define_bypass 3 "X4,X8" "X6,X7" "pa_fpstore_bypass_p")
434
435 ;; The 7100LC has three floating-point units: ALU, MUL, and DIV.
436 ;; There's no value in modeling the ALU and MUL separately though
437 ;; since there can never be a functional unit conflict that
438 ;; can be avoided given the latency, issue rates and mandatory
439 ;; one cycle cpu-wide lock for a double precision fp multiply.
440 ;;
441 ;; Timings:
442 ;; Instruction Time Unit Minimum Distance (unit contention)
443 ;; fcpy 2 ALU 1
444 ;; fabs 2 ALU 1
445 ;; fadd 2 ALU 1
446 ;; fsub 2 ALU 1
447 ;; fcmp 2 ALU 1
448 ;; fcnv 2 ALU 1
449 ;; fmpyadd,sgl 2 ALU,MPY 1
450 ;; fmpyadd,dbl 3 ALU,MPY 2
451 ;; fmpysub,sgl 2 ALU,MPY 1
452 ;; fmpysub,dbl 3 ALU,MPY 2
453 ;; fmpycfxt,sgl 2 ALU,MPY 1
454 ;; fmpycfxt,dbl 3 ALU,MPY 2
455 ;; fmpy,sgl 2 MPY 1
456 ;; fmpy,dbl 3 MPY 2
457 ;; fmpyi 3 MPY 2
458 ;; fdiv,sgl 8 DIV 8
459 ;; fdiv,dbl 15 DIV 15
460 ;; fsqrt,sgl 8 DIV 8
461 ;; fsqrt,dbl 15 DIV 15
462 ;;
463 ;; The PA7200 is just like the PA7100LC except that there is
464 ;; no store-store penalty.
465 ;;
466 ;; The PA7300 is just like the PA7200 except that there is
467 ;; no store-load penalty.
468 ;;
469 ;; Note there are some aspects of the 7100LC we are not modeling
470 ;; at the moment. I'll be reviewing the 7100LC scheduling info
471 ;; shortly and updating this description.
472 ;;
473 ;; load-load pairs
474 ;; store-store pairs
475 ;; other issue modeling
476
477 (define_automaton "pa7100lc")
478 (define_cpu_unit "i0_7100lc, i1_7100lc, f_7100lc" "pa7100lc")
479 (define_cpu_unit "fpmac_7100lc" "pa7100lc")
480 (define_cpu_unit "mem_7100lc" "pa7100lc")
481
482 ;; Double precision multiplies lock the entire CPU for one
483 ;; cycle. There is no way to avoid this lock and trying to
484 ;; schedule around the lock is pointless and thus there is no
485 ;; value in trying to model this lock.
486 ;;
487 ;; Not modeling the lock allows us to treat fp multiplies just
488 ;; like any other FP alu instruction. It allows for a smaller
489 ;; DFA and may reduce register pressure.
490 (define_insn_reservation "Y0" 2
491 (and (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
492 (eq_attr "cpu" "7100LC,7200,7300"))
493 "f_7100lc,fpmac_7100lc")
494
495 ;; fp division and sqrt instructions lock the entire CPU for
496 ;; 7 cycles (single precision) or 14 cycles (double precision).
497 ;; There is no way to avoid this lock and trying to schedule
498 ;; around the lock is pointless and thus there is no value in
499 ;; trying to model this lock. Not modeling the lock allows
500 ;; for a smaller DFA and may reduce register pressure.
501 (define_insn_reservation "Y1" 1
502 (and (eq_attr "type" "fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl")
503 (eq_attr "cpu" "7100LC,7200,7300"))
504 "f_7100lc")
505
506 (define_insn_reservation "Y2" 2
507 (and (eq_attr "type" "load")
508 (eq_attr "cpu" "7100LC,7200,7300"))
509 "i1_7100lc+mem_7100lc")
510
511 (define_insn_reservation "Y3" 2
512 (and (eq_attr "type" "fpload")
513 (eq_attr "cpu" "7100LC,7200,7300"))
514 "i1_7100lc+mem_7100lc")
515
516 (define_insn_reservation "Y4" 2
517 (and (eq_attr "type" "store")
518 (eq_attr "cpu" "7100LC"))
519 "i1_7100lc+mem_7100lc,mem_7100lc")
520
521 (define_insn_reservation "Y5" 2
522 (and (eq_attr "type" "fpstore")
523 (eq_attr "cpu" "7100LC"))
524 "i1_7100lc+mem_7100lc,mem_7100lc")
525
526 (define_insn_reservation "Y6" 4
527 (and (eq_attr "type" "fpstore_load")
528 (eq_attr "cpu" "7100LC"))
529 "i1_7100lc+mem_7100lc,mem_7100lc*3")
530
531 (define_insn_reservation "Y7" 4
532 (and (eq_attr "type" "store_fpload")
533 (eq_attr "cpu" "7100LC"))
534 "i1_7100lc+mem_7100lc,mem_7100lc*3")
535
536 (define_insn_reservation "Y8" 1
537 (and (eq_attr "type" "shift,nullshift")
538 (eq_attr "cpu" "7100LC,7200,7300"))
539 "i1_7100lc")
540
541 (define_insn_reservation "Y9" 1
542 (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl,load,fpload,store,fpstore,shift,nullshift")
543 (eq_attr "cpu" "7100LC,7200,7300"))
544 "(i0_7100lc|i1_7100lc)")
545
546 ;; The 7200 has a store-load penalty
547 (define_insn_reservation "Y10" 2
548 (and (eq_attr "type" "store")
549 (eq_attr "cpu" "7200"))
550 "i1_7100lc,mem_7100lc")
551
552 (define_insn_reservation "Y11" 2
553 (and (eq_attr "type" "fpstore")
554 (eq_attr "cpu" "7200"))
555 "i1_7100lc,mem_7100lc")
556
557 (define_insn_reservation "Y12" 4
558 (and (eq_attr "type" "fpstore_load")
559 (eq_attr "cpu" "7200"))
560 "i1_7100lc,mem_7100lc,i1_7100lc+mem_7100lc")
561
562 (define_insn_reservation "Y13" 4
563 (and (eq_attr "type" "store_fpload")
564 (eq_attr "cpu" "7200"))
565 "i1_7100lc,mem_7100lc,i1_7100lc+mem_7100lc")
566
567 ;; The 7300 has no penalty for store-store or store-load
568 (define_insn_reservation "Y14" 2
569 (and (eq_attr "type" "store")
570 (eq_attr "cpu" "7300"))
571 "i1_7100lc")
572
573 (define_insn_reservation "Y15" 2
574 (and (eq_attr "type" "fpstore")
575 (eq_attr "cpu" "7300"))
576 "i1_7100lc")
577
578 (define_insn_reservation "Y16" 4
579 (and (eq_attr "type" "fpstore_load")
580 (eq_attr "cpu" "7300"))
581 "i1_7100lc,i1_7100lc+mem_7100lc")
582
583 (define_insn_reservation "Y17" 4
584 (and (eq_attr "type" "store_fpload")
585 (eq_attr "cpu" "7300"))
586 "i1_7100lc,i1_7100lc+mem_7100lc")
587
588 ;; We have an "anti-bypass" for FP loads which feed an FP store.
589 (define_bypass 3 "Y3,Y7,Y13,Y17" "Y5,Y6,Y11,Y12,Y15,Y16" "pa_fpstore_bypass_p")
590
591 ;; Scheduling for the PA8000 is somewhat different than scheduling for a
592 ;; traditional architecture.
593 ;;
594 ;; The PA8000 has a large (56) entry reorder buffer that is split between
595 ;; memory and non-memory operations.
596 ;;
597 ;; The PA8000 can issue two memory and two non-memory operations per cycle to
598 ;; the function units, with the exception of branches and multi-output
599 ;; instructions. The PA8000 can retire two non-memory operations per cycle
600 ;; and two memory operations per cycle, only one of which may be a store.
601 ;;
602 ;; Given the large reorder buffer, the processor can hide most latencies.
603 ;; According to HP, they've got the best results by scheduling for retirement
604 ;; bandwidth with limited latency scheduling for floating point operations.
605 ;; Latency for integer operations and memory references is ignored.
606 ;;
607 ;;
608 ;; We claim floating point operations have a 2 cycle latency and are
609 ;; fully pipelined, except for div and sqrt which are not pipelined and
610 ;; take from 17 to 31 cycles to complete.
611 ;;
612 ;; It's worth noting that there is no way to saturate all the functional
613 ;; units on the PA8000 as there is not enough issue bandwidth.
614
615 (define_automaton "pa8000")
616 (define_cpu_unit "inm0_8000, inm1_8000, im0_8000, im1_8000" "pa8000")
617 (define_cpu_unit "rnm0_8000, rnm1_8000, rm0_8000, rm1_8000" "pa8000")
618 (define_cpu_unit "store_8000" "pa8000")
619 (define_cpu_unit "f0_8000, f1_8000" "pa8000")
620 (define_cpu_unit "fdivsqrt0_8000, fdivsqrt1_8000" "pa8000")
621 (define_reservation "inm_8000" "inm0_8000 | inm1_8000")
622 (define_reservation "im_8000" "im0_8000 | im1_8000")
623 (define_reservation "rnm_8000" "rnm0_8000 | rnm1_8000")
624 (define_reservation "rm_8000" "rm0_8000 | rm1_8000")
625 (define_reservation "f_8000" "f0_8000 | f1_8000")
626 (define_reservation "fdivsqrt_8000" "fdivsqrt0_8000 | fdivsqrt1_8000")
627
628 ;; We can issue any two memops per cycle, but we can only retire
629 ;; one memory store per cycle. We assume that the reorder buffer
630 ;; will hide any memory latencies per HP's recommendation.
631 (define_insn_reservation "Z0" 0
632 (and
633 (eq_attr "type" "load,fpload")
634 (eq_attr "cpu" "8000"))
635 "im_8000,rm_8000")
636
637 (define_insn_reservation "Z1" 0
638 (and
639 (eq_attr "type" "store,fpstore")
640 (eq_attr "cpu" "8000"))
641 "im_8000,rm_8000+store_8000")
642
643 (define_insn_reservation "Z2" 0
644 (and (eq_attr "type" "fpstore_load,store_fpload")
645 (eq_attr "cpu" "8000"))
646 "im_8000,rm_8000+store_8000,im_8000,rm_8000")
647
648 ;; We can issue and retire two non-memory operations per cycle with
649 ;; a few exceptions (branches). This group catches those we want
650 ;; to assume have zero latency.
651 (define_insn_reservation "Z3" 0
652 (and
653 (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")
654 (eq_attr "cpu" "8000"))
655 "inm_8000,rnm_8000")
656
657 ;; Branches use both slots in the non-memory issue and
658 ;; retirement unit.
659 (define_insn_reservation "Z4" 0
660 (and
661 (eq_attr "type" "uncond_branch,branch,cbranch,fbranch,call,sibcall,dyncall,multi,milli,sh_func_adrs,parallel_branch")
662 (eq_attr "cpu" "8000"))
663 "inm0_8000+inm1_8000,rnm0_8000+rnm1_8000")
664
665 ;; We partial latency schedule the floating point units.
666 ;; They can issue/retire two at a time in the non-memory
667 ;; units. We fix their latency at 2 cycles and they
668 ;; are fully pipelined.
669 (define_insn_reservation "Z5" 1
670 (and
671 (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
672 (eq_attr "cpu" "8000"))
673 "inm_8000,f_8000,rnm_8000")
674
675 ;; The fdivsqrt units are not pipelined and have a very long latency.
676 ;; To keep the DFA from exploding, we do not show all the
677 ;; reservations for the divsqrt unit.
678 (define_insn_reservation "Z6" 17
679 (and
680 (eq_attr "type" "fpdivsgl,fpsqrtsgl")
681 (eq_attr "cpu" "8000"))
682 "inm_8000,fdivsqrt_8000*6,rnm_8000")
683
684 (define_insn_reservation "Z7" 31
685 (and
686 (eq_attr "type" "fpdivdbl,fpsqrtdbl")
687 (eq_attr "cpu" "8000"))
688 "inm_8000,fdivsqrt_8000*6,rnm_8000")
689
690 ;; Operand and operator predicates and constraints
691
692 (include "predicates.md")
693 (include "constraints.md")
694 \f
695 ;; Compare instructions.
696 ;; This controls RTL generation and register allocation.
697
698 (define_insn ""
699 [(set (reg:CCFP 0)
700 (match_operator:CCFP 2 "comparison_operator"
701 [(match_operand:SF 0 "reg_or_0_operand" "fG")
702 (match_operand:SF 1 "reg_or_0_operand" "fG")]))]
703 "! TARGET_SOFT_FLOAT"
704 "fcmp,sgl,%Y2 %f0,%f1"
705 [(set_attr "length" "4")
706 (set_attr "type" "fpcc")])
707
708 (define_insn ""
709 [(set (reg:CCFP 0)
710 (match_operator:CCFP 2 "comparison_operator"
711 [(match_operand:DF 0 "reg_or_0_operand" "fG")
712 (match_operand:DF 1 "reg_or_0_operand" "fG")]))]
713 "! TARGET_SOFT_FLOAT"
714 "fcmp,dbl,%Y2 %f0,%f1"
715 [(set_attr "length" "4")
716 (set_attr "type" "fpcc")])
717
718 ;; Provide a means to emit the movccfp0 and movccfp1 optimization
719 ;; placeholders. This is necessary in rare situations when a
720 ;; placeholder is re-emitted (see PR 8705).
721
722 (define_expand "movccfp"
723 [(set (reg:CCFP 0)
724 (match_operand 0 "const_int_operand" ""))]
725 "! TARGET_SOFT_FLOAT"
726 "
727 {
728 if ((unsigned HOST_WIDE_INT) INTVAL (operands[0]) > 1)
729 FAIL;
730 }")
731
732 ;; The following patterns are optimization placeholders. In almost
733 ;; all cases, the user of the condition code will be simplified and the
734 ;; original condition code setting insn should be eliminated.
735
736 (define_insn "*movccfp0"
737 [(set (reg:CCFP 0)
738 (const_int 0))]
739 "! TARGET_SOFT_FLOAT"
740 "fcmp,dbl,= %%fr0,%%fr0"
741 [(set_attr "length" "4")
742 (set_attr "type" "fpcc")])
743
744 (define_insn "*movccfp1"
745 [(set (reg:CCFP 0)
746 (const_int 1))]
747 "! TARGET_SOFT_FLOAT"
748 "fcmp,dbl,!= %%fr0,%%fr0"
749 [(set_attr "length" "4")
750 (set_attr "type" "fpcc")])
751
752 ;; scc insns.
753
754 (define_expand "cstoresi4"
755 [(set (match_operand:SI 0 "register_operand")
756 (match_operator:SI 1 "ordered_comparison_operator"
757 [(match_operand:SI 2 "reg_or_0_operand" "")
758 (match_operand:SI 3 "arith5_operand" "")]))]
759 "!TARGET_64BIT"
760 "")
761
762 ;; Instruction canonicalization puts immediate operands second, which
763 ;; is the reverse of what we want.
764
765 (define_insn "scc"
766 [(set (match_operand:SI 0 "register_operand" "=r")
767 (match_operator:SI 3 "comparison_operator"
768 [(match_operand:SI 1 "reg_or_0_operand" "rM")
769 (match_operand:SI 2 "arith11_operand" "rI")]))]
770 ""
771 "{com%I2clr|cmp%I2clr},%B3 %2,%r1,%0\;ldi 1,%0"
772 [(set_attr "type" "binary")
773 (set_attr "length" "8")])
774
775 (define_insn ""
776 [(set (match_operand:DI 0 "register_operand" "=r")
777 (match_operator:DI 3 "comparison_operator"
778 [(match_operand:DI 1 "reg_or_0_operand" "rM")
779 (match_operand:DI 2 "arith11_operand" "rI")]))]
780 "TARGET_64BIT"
781 "cmp%I2clr,*%B3 %2,%r1,%0\;ldi 1,%0"
782 [(set_attr "type" "binary")
783 (set_attr "length" "8")])
784
785 (define_insn "iorscc"
786 [(set (match_operand:SI 0 "register_operand" "=r")
787 (ior:SI (match_operator:SI 3 "comparison_operator"
788 [(match_operand:SI 1 "reg_or_0_operand" "rM")
789 (match_operand:SI 2 "arith11_operand" "rI")])
790 (match_operator:SI 6 "comparison_operator"
791 [(match_operand:SI 4 "reg_or_0_operand" "rM")
792 (match_operand:SI 5 "arith11_operand" "rI")])))]
793 ""
794 "{com%I2clr|cmp%I2clr},%S3 %2,%r1,%%r0\;{com%I5clr|cmp%I5clr},%B6 %5,%r4,%0\;ldi 1,%0"
795 [(set_attr "type" "binary")
796 (set_attr "length" "12")])
797
798 (define_insn ""
799 [(set (match_operand:DI 0 "register_operand" "=r")
800 (ior:DI (match_operator:DI 3 "comparison_operator"
801 [(match_operand:DI 1 "reg_or_0_operand" "rM")
802 (match_operand:DI 2 "arith11_operand" "rI")])
803 (match_operator:DI 6 "comparison_operator"
804 [(match_operand:DI 4 "reg_or_0_operand" "rM")
805 (match_operand:DI 5 "arith11_operand" "rI")])))]
806 "TARGET_64BIT"
807 "cmp%I2clr,*%S3 %2,%r1,%%r0\;cmp%I5clr,*%B6 %5,%r4,%0\;ldi 1,%0"
808 [(set_attr "type" "binary")
809 (set_attr "length" "12")])
810
811 ;; Combiner patterns for common operations performed with the output
812 ;; from an scc insn (negscc and incscc).
813 (define_insn "negscc"
814 [(set (match_operand:SI 0 "register_operand" "=r")
815 (neg:SI (match_operator:SI 3 "comparison_operator"
816 [(match_operand:SI 1 "reg_or_0_operand" "rM")
817 (match_operand:SI 2 "arith11_operand" "rI")])))]
818 ""
819 "{com%I2clr|cmp%I2clr},%B3 %2,%r1,%0\;ldi -1,%0"
820 [(set_attr "type" "binary")
821 (set_attr "length" "8")])
822
823 (define_insn ""
824 [(set (match_operand:DI 0 "register_operand" "=r")
825 (neg:DI (match_operator:DI 3 "comparison_operator"
826 [(match_operand:DI 1 "reg_or_0_operand" "rM")
827 (match_operand:DI 2 "arith11_operand" "rI")])))]
828 "TARGET_64BIT"
829 "cmp%I2clr,*%B3 %2,%r1,%0\;ldi -1,%0"
830 [(set_attr "type" "binary")
831 (set_attr "length" "8")])
832
833 ;; Patterns for adding/subtracting the result of a boolean expression from
834 ;; a register. First we have special patterns that make use of the carry
835 ;; bit, and output only two instructions. For the cases we can't in
836 ;; general do in two instructions, the incscc pattern at the end outputs
837 ;; two or three instructions.
838
839 (define_insn ""
840 [(set (match_operand:SI 0 "register_operand" "=r")
841 (plus:SI (leu:SI (match_operand:SI 2 "register_operand" "r")
842 (match_operand:SI 3 "arith11_operand" "rI"))
843 (match_operand:SI 1 "register_operand" "r")))]
844 ""
845 "sub%I3 %3,%2,%%r0\;{addc|add,c} %%r0,%1,%0"
846 [(set_attr "type" "binary")
847 (set_attr "length" "8")])
848
849 (define_insn ""
850 [(set (match_operand:DI 0 "register_operand" "=r")
851 (plus:DI (leu:DI (match_operand:DI 2 "register_operand" "r")
852 (match_operand:DI 3 "arith11_operand" "rI"))
853 (match_operand:DI 1 "register_operand" "r")))]
854 "TARGET_64BIT"
855 "sub%I3 %3,%2,%%r0\;add,dc %%r0,%1,%0"
856 [(set_attr "type" "binary")
857 (set_attr "length" "8")])
858
859 ; This need only accept registers for op3, since canonicalization
860 ; replaces geu with gtu when op3 is an integer.
861 (define_insn ""
862 [(set (match_operand:SI 0 "register_operand" "=r")
863 (plus:SI (geu:SI (match_operand:SI 2 "register_operand" "r")
864 (match_operand:SI 3 "register_operand" "r"))
865 (match_operand:SI 1 "register_operand" "r")))]
866 ""
867 "sub %2,%3,%%r0\;{addc|add,c} %%r0,%1,%0"
868 [(set_attr "type" "binary")
869 (set_attr "length" "8")])
870
871 (define_insn ""
872 [(set (match_operand:DI 0 "register_operand" "=r")
873 (plus:DI (geu:DI (match_operand:DI 2 "register_operand" "r")
874 (match_operand:DI 3 "register_operand" "r"))
875 (match_operand:DI 1 "register_operand" "r")))]
876 "TARGET_64BIT"
877 "sub %2,%3,%%r0\;add,dc %%r0,%1,%0"
878 [(set_attr "type" "binary")
879 (set_attr "length" "8")])
880
881 ; Match only integers for op3 here. This is used as canonical form of the
882 ; geu pattern when op3 is an integer. Don't match registers since we can't
883 ; make better code than the general incscc pattern.
884 (define_insn ""
885 [(set (match_operand:SI 0 "register_operand" "=r")
886 (plus:SI (gtu:SI (match_operand:SI 2 "register_operand" "r")
887 (match_operand:SI 3 "int11_operand" "I"))
888 (match_operand:SI 1 "register_operand" "r")))]
889 ""
890 "addi %k3,%2,%%r0\;{addc|add,c} %%r0,%1,%0"
891 [(set_attr "type" "binary")
892 (set_attr "length" "8")])
893
894 (define_insn ""
895 [(set (match_operand:DI 0 "register_operand" "=r")
896 (plus:DI (gtu:DI (match_operand:DI 2 "register_operand" "r")
897 (match_operand:DI 3 "int11_operand" "I"))
898 (match_operand:DI 1 "register_operand" "r")))]
899 "TARGET_64BIT"
900 "addi %k3,%2,%%r0\;add,dc %%r0,%1,%0"
901 [(set_attr "type" "binary")
902 (set_attr "length" "8")])
903
904 (define_insn "incscc"
905 [(set (match_operand:SI 0 "register_operand" "=r,r")
906 (plus:SI (match_operator:SI 4 "comparison_operator"
907 [(match_operand:SI 2 "register_operand" "r,r")
908 (match_operand:SI 3 "arith11_operand" "rI,rI")])
909 (match_operand:SI 1 "register_operand" "0,?r")))]
910 ""
911 "@
912 {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi 1,%0,%0
913 {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi,tr 1,%1,%0\;copy %1,%0"
914 [(set_attr "type" "binary,binary")
915 (set_attr "length" "8,12")])
916
917 (define_insn ""
918 [(set (match_operand:DI 0 "register_operand" "=r,r")
919 (plus:DI (match_operator:DI 4 "comparison_operator"
920 [(match_operand:DI 2 "register_operand" "r,r")
921 (match_operand:DI 3 "arith11_operand" "rI,rI")])
922 (match_operand:DI 1 "register_operand" "0,?r")))]
923 "TARGET_64BIT"
924 "@
925 cmp%I3clr,*%B4 %3,%2,%%r0\;addi 1,%0,%0
926 cmp%I3clr,*%B4 %3,%2,%%r0\;addi,tr 1,%1,%0\;copy %1,%0"
927 [(set_attr "type" "binary,binary")
928 (set_attr "length" "8,12")])
929
930 (define_insn ""
931 [(set (match_operand:SI 0 "register_operand" "=r")
932 (minus:SI (match_operand:SI 1 "register_operand" "r")
933 (gtu:SI (match_operand:SI 2 "register_operand" "r")
934 (match_operand:SI 3 "arith11_operand" "rI"))))]
935 ""
936 "sub%I3 %3,%2,%%r0\;{subb|sub,b} %1,%%r0,%0"
937 [(set_attr "type" "binary")
938 (set_attr "length" "8")])
939
940 (define_insn ""
941 [(set (match_operand:DI 0 "register_operand" "=r")
942 (minus:DI (match_operand:DI 1 "register_operand" "r")
943 (gtu:DI (match_operand:DI 2 "register_operand" "r")
944 (match_operand:DI 3 "arith11_operand" "rI"))))]
945 "TARGET_64BIT"
946 "sub%I3 %3,%2,%%r0\;sub,db %1,%%r0,%0"
947 [(set_attr "type" "binary")
948 (set_attr "length" "8")])
949
950 (define_insn ""
951 [(set (match_operand:SI 0 "register_operand" "=r")
952 (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
953 (gtu:SI (match_operand:SI 2 "register_operand" "r")
954 (match_operand:SI 3 "arith11_operand" "rI")))
955 (match_operand:SI 4 "register_operand" "r")))]
956 ""
957 "sub%I3 %3,%2,%%r0\;{subb|sub,b} %1,%4,%0"
958 [(set_attr "type" "binary")
959 (set_attr "length" "8")])
960
961 (define_insn ""
962 [(set (match_operand:DI 0 "register_operand" "=r")
963 (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
964 (gtu:DI (match_operand:DI 2 "register_operand" "r")
965 (match_operand:DI 3 "arith11_operand" "rI")))
966 (match_operand:DI 4 "register_operand" "r")))]
967 "TARGET_64BIT"
968 "sub%I3 %3,%2,%%r0\;sub,db %1,%4,%0"
969 [(set_attr "type" "binary")
970 (set_attr "length" "8")])
971
972 ; This need only accept registers for op3, since canonicalization
973 ; replaces ltu with leu when op3 is an integer.
974 (define_insn ""
975 [(set (match_operand:SI 0 "register_operand" "=r")
976 (minus:SI (match_operand:SI 1 "register_operand" "r")
977 (ltu:SI (match_operand:SI 2 "register_operand" "r")
978 (match_operand:SI 3 "register_operand" "r"))))]
979 ""
980 "sub %2,%3,%%r0\;{subb|sub,b} %1,%%r0,%0"
981 [(set_attr "type" "binary")
982 (set_attr "length" "8")])
983
984 (define_insn ""
985 [(set (match_operand:DI 0 "register_operand" "=r")
986 (minus:DI (match_operand:DI 1 "register_operand" "r")
987 (ltu:DI (match_operand:DI 2 "register_operand" "r")
988 (match_operand:DI 3 "register_operand" "r"))))]
989 "TARGET_64BIT"
990 "sub %2,%3,%%r0\;sub,db %1,%%r0,%0"
991 [(set_attr "type" "binary")
992 (set_attr "length" "8")])
993
994 (define_insn ""
995 [(set (match_operand:SI 0 "register_operand" "=r")
996 (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
997 (ltu:SI (match_operand:SI 2 "register_operand" "r")
998 (match_operand:SI 3 "register_operand" "r")))
999 (match_operand:SI 4 "register_operand" "r")))]
1000 ""
1001 "sub %2,%3,%%r0\;{subb|sub,b} %1,%4,%0"
1002 [(set_attr "type" "binary")
1003 (set_attr "length" "8")])
1004
1005 (define_insn ""
1006 [(set (match_operand:DI 0 "register_operand" "=r")
1007 (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
1008 (ltu:DI (match_operand:DI 2 "register_operand" "r")
1009 (match_operand:DI 3 "register_operand" "r")))
1010 (match_operand:DI 4 "register_operand" "r")))]
1011 "TARGET_64BIT"
1012 "sub %2,%3,%%r0\;sub,db %1,%4,%0"
1013 [(set_attr "type" "binary")
1014 (set_attr "length" "8")])
1015
1016 ; Match only integers for op3 here. This is used as canonical form of the
1017 ; ltu pattern when op3 is an integer. Don't match registers since we can't
1018 ; make better code than the general incscc pattern.
1019 (define_insn ""
1020 [(set (match_operand:SI 0 "register_operand" "=r")
1021 (minus:SI (match_operand:SI 1 "register_operand" "r")
1022 (leu:SI (match_operand:SI 2 "register_operand" "r")
1023 (match_operand:SI 3 "int11_operand" "I"))))]
1024 ""
1025 "addi %k3,%2,%%r0\;{subb|sub,b} %1,%%r0,%0"
1026 [(set_attr "type" "binary")
1027 (set_attr "length" "8")])
1028
1029 (define_insn ""
1030 [(set (match_operand:DI 0 "register_operand" "=r")
1031 (minus:DI (match_operand:DI 1 "register_operand" "r")
1032 (leu:DI (match_operand:DI 2 "register_operand" "r")
1033 (match_operand:DI 3 "int11_operand" "I"))))]
1034 "TARGET_64BIT"
1035 "addi %k3,%2,%%r0\;sub,db %1,%%r0,%0"
1036 [(set_attr "type" "binary")
1037 (set_attr "length" "8")])
1038
1039 (define_insn ""
1040 [(set (match_operand:SI 0 "register_operand" "=r")
1041 (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
1042 (leu:SI (match_operand:SI 2 "register_operand" "r")
1043 (match_operand:SI 3 "int11_operand" "I")))
1044 (match_operand:SI 4 "register_operand" "r")))]
1045 ""
1046 "addi %k3,%2,%%r0\;{subb|sub,b} %1,%4,%0"
1047 [(set_attr "type" "binary")
1048 (set_attr "length" "8")])
1049
1050 (define_insn ""
1051 [(set (match_operand:DI 0 "register_operand" "=r")
1052 (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
1053 (leu:DI (match_operand:DI 2 "register_operand" "r")
1054 (match_operand:DI 3 "int11_operand" "I")))
1055 (match_operand:DI 4 "register_operand" "r")))]
1056 "TARGET_64BIT"
1057 "addi %k3,%2,%%r0\;sub,db %1,%4,%0"
1058 [(set_attr "type" "binary")
1059 (set_attr "length" "8")])
1060
1061 (define_insn "decscc"
1062 [(set (match_operand:SI 0 "register_operand" "=r,r")
1063 (minus:SI (match_operand:SI 1 "register_operand" "0,?r")
1064 (match_operator:SI 4 "comparison_operator"
1065 [(match_operand:SI 2 "register_operand" "r,r")
1066 (match_operand:SI 3 "arith11_operand" "rI,rI")])))]
1067 ""
1068 "@
1069 {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi -1,%0,%0
1070 {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi,tr -1,%1,%0\;copy %1,%0"
1071 [(set_attr "type" "binary,binary")
1072 (set_attr "length" "8,12")])
1073
1074 (define_insn ""
1075 [(set (match_operand:DI 0 "register_operand" "=r,r")
1076 (minus:DI (match_operand:DI 1 "register_operand" "0,?r")
1077 (match_operator:DI 4 "comparison_operator"
1078 [(match_operand:DI 2 "register_operand" "r,r")
1079 (match_operand:DI 3 "arith11_operand" "rI,rI")])))]
1080 "TARGET_64BIT"
1081 "@
1082 cmp%I3clr,*%B4 %3,%2,%%r0\;addi -1,%0,%0
1083 cmp%I3clr,*%B4 %3,%2,%%r0\;addi,tr -1,%1,%0\;copy %1,%0"
1084 [(set_attr "type" "binary,binary")
1085 (set_attr "length" "8,12")])
1086
1087 ; Patterns for max and min. (There is no need for an earlyclobber in the
1088 ; last alternative since the middle alternative will match if op0 == op1.)
1089
1090 (define_insn "sminsi3"
1091 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1092 (smin:SI (match_operand:SI 1 "register_operand" "%0,0,r")
1093 (match_operand:SI 2 "arith11_operand" "r,I,M")))]
1094 ""
1095 "@
1096 {comclr|cmpclr},> %2,%0,%%r0\;copy %2,%0
1097 {comiclr|cmpiclr},> %2,%0,%%r0\;ldi %2,%0
1098 {comclr|cmpclr},> %1,%r2,%0\;copy %1,%0"
1099 [(set_attr "type" "multi,multi,multi")
1100 (set_attr "length" "8,8,8")])
1101
1102 (define_insn "smindi3"
1103 [(set (match_operand:DI 0 "register_operand" "=r,r,r")
1104 (smin:DI (match_operand:DI 1 "register_operand" "%0,0,r")
1105 (match_operand:DI 2 "arith11_operand" "r,I,M")))]
1106 "TARGET_64BIT"
1107 "@
1108 cmpclr,*> %2,%0,%%r0\;copy %2,%0
1109 cmpiclr,*> %2,%0,%%r0\;ldi %2,%0
1110 cmpclr,*> %1,%r2,%0\;copy %1,%0"
1111 [(set_attr "type" "multi,multi,multi")
1112 (set_attr "length" "8,8,8")])
1113
1114 (define_insn "uminsi3"
1115 [(set (match_operand:SI 0 "register_operand" "=r,r")
1116 (umin:SI (match_operand:SI 1 "register_operand" "%0,0")
1117 (match_operand:SI 2 "arith11_operand" "r,I")))]
1118 ""
1119 "@
1120 {comclr|cmpclr},>> %2,%0,%%r0\;copy %2,%0
1121 {comiclr|cmpiclr},>> %2,%0,%%r0\;ldi %2,%0"
1122 [(set_attr "type" "multi,multi")
1123 (set_attr "length" "8,8")])
1124
1125 (define_insn "umindi3"
1126 [(set (match_operand:DI 0 "register_operand" "=r,r")
1127 (umin:DI (match_operand:DI 1 "register_operand" "%0,0")
1128 (match_operand:DI 2 "arith11_operand" "r,I")))]
1129 "TARGET_64BIT"
1130 "@
1131 cmpclr,*>> %2,%0,%%r0\;copy %2,%0
1132 cmpiclr,*>> %2,%0,%%r0\;ldi %2,%0"
1133 [(set_attr "type" "multi,multi")
1134 (set_attr "length" "8,8")])
1135
1136 (define_insn "smaxsi3"
1137 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1138 (smax:SI (match_operand:SI 1 "register_operand" "%0,0,r")
1139 (match_operand:SI 2 "arith11_operand" "r,I,M")))]
1140 ""
1141 "@
1142 {comclr|cmpclr},< %2,%0,%%r0\;copy %2,%0
1143 {comiclr|cmpiclr},< %2,%0,%%r0\;ldi %2,%0
1144 {comclr|cmpclr},< %1,%r2,%0\;copy %1,%0"
1145 [(set_attr "type" "multi,multi,multi")
1146 (set_attr "length" "8,8,8")])
1147
1148 (define_insn "smaxdi3"
1149 [(set (match_operand:DI 0 "register_operand" "=r,r,r")
1150 (smax:DI (match_operand:DI 1 "register_operand" "%0,0,r")
1151 (match_operand:DI 2 "arith11_operand" "r,I,M")))]
1152 "TARGET_64BIT"
1153 "@
1154 cmpclr,*< %2,%0,%%r0\;copy %2,%0
1155 cmpiclr,*< %2,%0,%%r0\;ldi %2,%0
1156 cmpclr,*< %1,%r2,%0\;copy %1,%0"
1157 [(set_attr "type" "multi,multi,multi")
1158 (set_attr "length" "8,8,8")])
1159
1160 (define_insn "umaxsi3"
1161 [(set (match_operand:SI 0 "register_operand" "=r,r")
1162 (umax:SI (match_operand:SI 1 "register_operand" "%0,0")
1163 (match_operand:SI 2 "arith11_operand" "r,I")))]
1164 ""
1165 "@
1166 {comclr|cmpclr},<< %2,%0,%%r0\;copy %2,%0
1167 {comiclr|cmpiclr},<< %2,%0,%%r0\;ldi %2,%0"
1168 [(set_attr "type" "multi,multi")
1169 (set_attr "length" "8,8")])
1170
1171 (define_insn "umaxdi3"
1172 [(set (match_operand:DI 0 "register_operand" "=r,r")
1173 (umax:DI (match_operand:DI 1 "register_operand" "%0,0")
1174 (match_operand:DI 2 "arith11_operand" "r,I")))]
1175 "TARGET_64BIT"
1176 "@
1177 cmpclr,*<< %2,%0,%%r0\;copy %2,%0
1178 cmpiclr,*<< %2,%0,%%r0\;ldi %2,%0"
1179 [(set_attr "type" "multi,multi")
1180 (set_attr "length" "8,8")])
1181
1182 (define_insn "absqi2"
1183 [(set (match_operand:QI 0 "register_operand" "=r")
1184 (abs:QI (match_operand:QI 1 "register_operand" "r")))]
1185 ""
1186 "{extrs|extrw,s},>= %1,31,8,%0\;subi 0,%0,%0"
1187 [(set_attr "type" "multi")
1188 (set_attr "length" "8")])
1189
1190 (define_insn "abshi2"
1191 [(set (match_operand:HI 0 "register_operand" "=r")
1192 (abs:HI (match_operand:HI 1 "register_operand" "r")))]
1193 ""
1194 "{extrs|extrw,s},>= %1,31,16,%0\;subi 0,%0,%0"
1195 [(set_attr "type" "multi")
1196 (set_attr "length" "8")])
1197
1198 (define_insn "abssi2"
1199 [(set (match_operand:SI 0 "register_operand" "=r")
1200 (abs:SI (match_operand:SI 1 "register_operand" "r")))]
1201 ""
1202 "or,>= %%r0,%1,%0\;subi 0,%0,%0"
1203 [(set_attr "type" "multi")
1204 (set_attr "length" "8")])
1205
1206 (define_insn "absdi2"
1207 [(set (match_operand:DI 0 "register_operand" "=r")
1208 (abs:DI (match_operand:DI 1 "register_operand" "r")))]
1209 "TARGET_64BIT"
1210 "or,*>= %%r0,%1,%0\;subi 0,%0,%0"
1211 [(set_attr "type" "multi")
1212 (set_attr "length" "8")])
1213
1214 (define_insn "bswaphi2"
1215 [(set (match_operand:HI 0 "register_operand" "=&r")
1216 (bswap:HI (match_operand:HI 1 "register_operand" "r")))]
1217 ""
1218 "{extru|extrw,u} %1,23,8,%0\;{dep|depw} %1,23,8,%0"
1219 [(set_attr "type" "multi")
1220 (set_attr "length" "8")])
1221
1222 (define_insn "bswapsi2"
1223 [(set (match_operand:SI 0 "register_operand" "=&r")
1224 (bswap:SI (match_operand:SI 1 "register_operand" "r")))]
1225 ""
1226 "{shd|shrpw} %1,%1,16,%0\;{dep|depw} %0,15,8,%0\;{shd|shrpw} %1,%0,8,%0"
1227 [(set_attr "type" "multi")
1228 (set_attr "length" "12")])
1229
1230 (define_insn "bswapdi2"
1231 [(set (match_operand:DI 0 "register_operand" "=&r")
1232 (bswap:DI (match_operand:DI 1 "register_operand" "r")))
1233 (clobber (match_scratch:DI 2 "=r"))]
1234 "TARGET_64BIT"
1235 "permh,3210 %1,%2\;hshl %2,8,%0\;hshr,u %2,8,%2\;or %0,%2,%0"
1236 [(set_attr "type" "multi")
1237 (set_attr "length" "16")])
1238
1239 ;;; Experimental conditional move patterns
1240
1241 (define_expand "movsicc"
1242 [(set (match_operand:SI 0 "register_operand" "")
1243 (if_then_else:SI
1244 (match_operand 1 "comparison_operator" "")
1245 (match_operand:SI 2 "reg_or_cint_move_operand" "")
1246 (match_operand:SI 3 "reg_or_cint_move_operand" "")))]
1247 ""
1248 "
1249 {
1250 if (GET_MODE (XEXP (operands[1], 0)) != SImode
1251 || GET_MODE (XEXP (operands[1], 0)) != GET_MODE (XEXP (operands[1], 1)))
1252 FAIL;
1253 }")
1254
1255 ;; We used to accept any register for op1.
1256 ;;
1257 ;; However, it loses sometimes because the compiler will end up using
1258 ;; different registers for op0 and op1 in some critical cases. local-alloc
1259 ;; will not tie op0 and op1 because op0 is used in multiple basic blocks.
1260 ;;
1261 ;; If/when global register allocation supports tying we should allow any
1262 ;; register for op1 again.
1263 (define_insn ""
1264 [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
1265 (if_then_else:SI
1266 (match_operator 2 "comparison_operator"
1267 [(match_operand:SI 3 "register_operand" "r,r,r,r")
1268 (match_operand:SI 4 "arith11_operand" "rI,rI,rI,rI")])
1269 (match_operand:SI 1 "reg_or_cint_move_operand" "0,J,N,K")
1270 (const_int 0)))]
1271 ""
1272 "@
1273 {com%I4clr|cmp%I4clr},%S2 %4,%3,%%r0\;ldi 0,%0
1274 {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;ldi %1,%0
1275 {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;ldil L'%1,%0
1276 {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;{zdepi|depwi,z} %Z1,%0"
1277 [(set_attr "type" "multi,multi,multi,nullshift")
1278 (set_attr "length" "8,8,8,8")])
1279
1280 (define_insn ""
1281 [(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r,r,r")
1282 (if_then_else:SI
1283 (match_operator 5 "comparison_operator"
1284 [(match_operand:SI 3 "register_operand" "r,r,r,r,r,r,r,r")
1285 (match_operand:SI 4 "arith11_operand" "rI,rI,rI,rI,rI,rI,rI,rI")])
1286 (match_operand:SI 1 "reg_or_cint_move_operand" "0,0,0,0,r,J,N,K")
1287 (match_operand:SI 2 "reg_or_cint_move_operand" "r,J,N,K,0,0,0,0")))]
1288 ""
1289 "@
1290 {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;copy %2,%0
1291 {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;ldi %2,%0
1292 {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;ldil L'%2,%0
1293 {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;{zdepi|depwi,z} %Z2,%0
1294 {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;copy %1,%0
1295 {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;ldi %1,%0
1296 {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;ldil L'%1,%0
1297 {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;{zdepi|depwi,z} %Z1,%0"
1298 [(set_attr "type" "multi,multi,multi,nullshift,multi,multi,multi,nullshift")
1299 (set_attr "length" "8,8,8,8,8,8,8,8")])
1300
1301 (define_expand "movdicc"
1302 [(set (match_operand:DI 0 "register_operand" "")
1303 (if_then_else:DI
1304 (match_operand 1 "comparison_operator" "")
1305 (match_operand:DI 2 "reg_or_cint_move_operand" "")
1306 (match_operand:DI 3 "reg_or_cint_move_operand" "")))]
1307 "TARGET_64BIT"
1308 "
1309 {
1310 if (GET_MODE (XEXP (operands[1], 0)) != DImode
1311 || GET_MODE (XEXP (operands[1], 0)) != GET_MODE (XEXP (operands[1], 1)))
1312 FAIL;
1313 }")
1314
1315 ; We need the first constraint alternative in order to avoid
1316 ; earlyclobbers on all other alternatives.
1317 (define_insn ""
1318 [(set (match_operand:DI 0 "register_operand" "=r,r,r,r,r")
1319 (if_then_else:DI
1320 (match_operator 2 "comparison_operator"
1321 [(match_operand:DI 3 "register_operand" "r,r,r,r,r")
1322 (match_operand:DI 4 "arith11_operand" "rI,rI,rI,rI,rI")])
1323 (match_operand:DI 1 "reg_or_cint_move_operand" "0,r,J,N,K")
1324 (const_int 0)))]
1325 "TARGET_64BIT"
1326 "@
1327 cmp%I4clr,*%S2 %4,%3,%%r0\;ldi 0,%0
1328 cmp%I4clr,*%B2 %4,%3,%0\;copy %1,%0
1329 cmp%I4clr,*%B2 %4,%3,%0\;ldi %1,%0
1330 cmp%I4clr,*%B2 %4,%3,%0\;ldil L'%1,%0
1331 cmp%I4clr,*%B2 %4,%3,%0\;depdi,z %z1,%0"
1332 [(set_attr "type" "multi,multi,multi,multi,nullshift")
1333 (set_attr "length" "8,8,8,8,8")])
1334
1335 (define_insn ""
1336 [(set (match_operand:DI 0 "register_operand" "=r,r,r,r,r,r,r,r")
1337 (if_then_else:DI
1338 (match_operator 5 "comparison_operator"
1339 [(match_operand:DI 3 "register_operand" "r,r,r,r,r,r,r,r")
1340 (match_operand:DI 4 "arith11_operand" "rI,rI,rI,rI,rI,rI,rI,rI")])
1341 (match_operand:DI 1 "reg_or_cint_move_operand" "0,0,0,0,r,J,N,K")
1342 (match_operand:DI 2 "reg_or_cint_move_operand" "r,J,N,K,0,0,0,0")))]
1343 "TARGET_64BIT"
1344 "@
1345 cmp%I4clr,*%S5 %4,%3,%%r0\;copy %2,%0
1346 cmp%I4clr,*%S5 %4,%3,%%r0\;ldi %2,%0
1347 cmp%I4clr,*%S5 %4,%3,%%r0\;ldil L'%2,%0
1348 cmp%I4clr,*%S5 %4,%3,%%r0\;depdi,z %z2,%0
1349 cmp%I4clr,*%B5 %4,%3,%%r0\;copy %1,%0
1350 cmp%I4clr,*%B5 %4,%3,%%r0\;ldi %1,%0
1351 cmp%I4clr,*%B5 %4,%3,%%r0\;ldil L'%1,%0
1352 cmp%I4clr,*%B5 %4,%3,%%r0\;depdi,z %z1,%0"
1353 [(set_attr "type" "multi,multi,multi,nullshift,multi,multi,multi,nullshift")
1354 (set_attr "length" "8,8,8,8,8,8,8,8")])
1355
1356 ;; Conditional Branches
1357
1358 (define_expand "cbranchdi4"
1359 [(set (pc)
1360 (if_then_else (match_operator 0 "ordered_comparison_operator"
1361 [(match_operand:DI 1 "reg_or_0_operand" "")
1362 (match_operand:DI 2 "register_operand" "")])
1363 (label_ref (match_operand 3 "" ""))
1364 (pc)))]
1365 "TARGET_64BIT"
1366 "")
1367
1368 (define_expand "cbranchsi4"
1369 [(set (pc)
1370 (if_then_else (match_operator 0 "ordered_comparison_operator"
1371 [(match_operand:SI 1 "reg_or_0_operand" "")
1372 (match_operand:SI 2 "arith5_operand" "")])
1373 (label_ref (match_operand 3 "" ""))
1374 (pc)))]
1375 ""
1376 "")
1377
1378 (define_expand "cbranchsf4"
1379 [(set (pc)
1380 (if_then_else (match_operator 0 "comparison_operator"
1381 [(match_operand:SF 1 "reg_or_0_operand" "")
1382 (match_operand:SF 2 "reg_or_0_operand" "")])
1383 (label_ref (match_operand 3 "" ""))
1384 (pc)))]
1385 ""
1386 "
1387 {
1388 pa_emit_bcond_fp (operands);
1389 DONE;
1390 }")
1391
1392
1393 (define_expand "cbranchdf4"
1394 [(set (pc)
1395 (if_then_else (match_operator 0 "comparison_operator"
1396 [(match_operand:DF 1 "reg_or_0_operand" "")
1397 (match_operand:DF 2 "reg_or_0_operand" "")])
1398 (label_ref (match_operand 3 "" ""))
1399 (pc)))]
1400 ""
1401 "
1402 {
1403 pa_emit_bcond_fp (operands);
1404 DONE;
1405 }")
1406
1407 ;; Match the branch patterns.
1408
1409
1410 ;; Note a long backward conditional branch with an annulled delay slot
1411 ;; has a length of 12.
1412 (define_insn ""
1413 [(set (pc)
1414 (if_then_else
1415 (match_operator 3 "comparison_operator"
1416 [(match_operand:SI 1 "reg_or_0_operand" "rM")
1417 (match_operand:SI 2 "arith5_operand" "rL")])
1418 (label_ref (match_operand 0 "" ""))
1419 (pc)))]
1420 ""
1421 "*
1422 {
1423 return pa_output_cbranch (operands, 0, insn);
1424 }"
1425 [(set_attr "type" "cbranch")
1426 (set (attr "length")
1427 (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1428 (const_int MAX_12BIT_OFFSET))
1429 (const_int 4)
1430 (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1431 (const_int MAX_17BIT_OFFSET))
1432 (const_int 8)
1433 (match_test "TARGET_PORTABLE_RUNTIME")
1434 (const_int 24)
1435 (not (match_test "flag_pic"))
1436 (const_int 20)]
1437 (const_int 28)))])
1438
1439 ;; Match the negated branch.
1440
1441 (define_insn ""
1442 [(set (pc)
1443 (if_then_else
1444 (match_operator 3 "comparison_operator"
1445 [(match_operand:SI 1 "reg_or_0_operand" "rM")
1446 (match_operand:SI 2 "arith5_operand" "rL")])
1447 (pc)
1448 (label_ref (match_operand 0 "" ""))))]
1449 ""
1450 "*
1451 {
1452 return pa_output_cbranch (operands, 1, insn);
1453 }"
1454 [(set_attr "type" "cbranch")
1455 (set (attr "length")
1456 (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1457 (const_int MAX_12BIT_OFFSET))
1458 (const_int 4)
1459 (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1460 (const_int MAX_17BIT_OFFSET))
1461 (const_int 8)
1462 (match_test "TARGET_PORTABLE_RUNTIME")
1463 (const_int 24)
1464 (not (match_test "flag_pic"))
1465 (const_int 20)]
1466 (const_int 28)))])
1467
1468 (define_insn ""
1469 [(set (pc)
1470 (if_then_else
1471 (match_operator 3 "comparison_operator"
1472 [(match_operand:DI 1 "reg_or_0_operand" "rM")
1473 (match_operand:DI 2 "reg_or_0_operand" "rM")])
1474 (label_ref (match_operand 0 "" ""))
1475 (pc)))]
1476 "TARGET_64BIT"
1477 "*
1478 {
1479 return pa_output_cbranch (operands, 0, insn);
1480 }"
1481 [(set_attr "type" "cbranch")
1482 (set (attr "length")
1483 (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1484 (const_int MAX_12BIT_OFFSET))
1485 (const_int 4)
1486 (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1487 (const_int MAX_17BIT_OFFSET))
1488 (const_int 8)
1489 (match_test "TARGET_PORTABLE_RUNTIME")
1490 (const_int 24)
1491 (not (match_test "flag_pic"))
1492 (const_int 20)]
1493 (const_int 28)))])
1494
1495 ;; Match the negated branch.
1496
1497 (define_insn ""
1498 [(set (pc)
1499 (if_then_else
1500 (match_operator 3 "comparison_operator"
1501 [(match_operand:DI 1 "reg_or_0_operand" "rM")
1502 (match_operand:DI 2 "reg_or_0_operand" "rM")])
1503 (pc)
1504 (label_ref (match_operand 0 "" ""))))]
1505 "TARGET_64BIT"
1506 "*
1507 {
1508 return pa_output_cbranch (operands, 1, insn);
1509 }"
1510 [(set_attr "type" "cbranch")
1511 (set (attr "length")
1512 (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1513 (const_int MAX_12BIT_OFFSET))
1514 (const_int 4)
1515 (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1516 (const_int MAX_17BIT_OFFSET))
1517 (const_int 8)
1518 (match_test "TARGET_PORTABLE_RUNTIME")
1519 (const_int 24)
1520 (not (match_test "flag_pic"))
1521 (const_int 20)]
1522 (const_int 28)))])
1523 (define_insn ""
1524 [(set (pc)
1525 (if_then_else
1526 (match_operator 3 "cmpib_comparison_operator"
1527 [(match_operand:DI 1 "reg_or_0_operand" "rM")
1528 (match_operand:DI 2 "arith5_operand" "rL")])
1529 (label_ref (match_operand 0 "" ""))
1530 (pc)))]
1531 "TARGET_64BIT"
1532 "*
1533 {
1534 return pa_output_cbranch (operands, 0, insn);
1535 }"
1536 [(set_attr "type" "cbranch")
1537 (set (attr "length")
1538 (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1539 (const_int MAX_12BIT_OFFSET))
1540 (const_int 4)
1541 (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1542 (const_int MAX_17BIT_OFFSET))
1543 (const_int 8)
1544 (match_test "TARGET_PORTABLE_RUNTIME")
1545 (const_int 24)
1546 (not (match_test "flag_pic"))
1547 (const_int 20)]
1548 (const_int 28)))])
1549
1550 ;; Match the negated branch.
1551
1552 (define_insn ""
1553 [(set (pc)
1554 (if_then_else
1555 (match_operator 3 "cmpib_comparison_operator"
1556 [(match_operand:DI 1 "reg_or_0_operand" "rM")
1557 (match_operand:DI 2 "arith5_operand" "rL")])
1558 (pc)
1559 (label_ref (match_operand 0 "" ""))))]
1560 "TARGET_64BIT"
1561 "*
1562 {
1563 return pa_output_cbranch (operands, 1, insn);
1564 }"
1565 [(set_attr "type" "cbranch")
1566 (set (attr "length")
1567 (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1568 (const_int MAX_12BIT_OFFSET))
1569 (const_int 4)
1570 (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1571 (const_int MAX_17BIT_OFFSET))
1572 (const_int 8)
1573 (match_test "TARGET_PORTABLE_RUNTIME")
1574 (const_int 24)
1575 (not (match_test "flag_pic"))
1576 (const_int 20)]
1577 (const_int 28)))])
1578
1579 ;; Branch on Bit patterns.
1580 (define_insn ""
1581 [(set (pc)
1582 (if_then_else
1583 (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1584 (const_int 1)
1585 (match_operand:SI 1 "uint5_operand" ""))
1586 (const_int 0))
1587 (label_ref (match_operand 2 "" ""))
1588 (pc)))]
1589 ""
1590 "*
1591 {
1592 return pa_output_bb (operands, 0, insn, 0);
1593 }"
1594 [(set_attr "type" "cbranch")
1595 (set (attr "length")
1596 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1597 (const_int MAX_12BIT_OFFSET))
1598 (const_int 4)
1599 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1600 (const_int MAX_17BIT_OFFSET))
1601 (const_int 8)
1602 (match_test "TARGET_PORTABLE_RUNTIME")
1603 (const_int 24)
1604 (not (match_test "flag_pic"))
1605 (const_int 20)]
1606 (const_int 28)))])
1607
1608 (define_insn ""
1609 [(set (pc)
1610 (if_then_else
1611 (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1612 (const_int 1)
1613 (match_operand:DI 1 "uint32_operand" ""))
1614 (const_int 0))
1615 (label_ref (match_operand 2 "" ""))
1616 (pc)))]
1617 "TARGET_64BIT"
1618 "*
1619 {
1620 return pa_output_bb (operands, 0, insn, 0);
1621 }"
1622 [(set_attr "type" "cbranch")
1623 (set (attr "length")
1624 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1625 (const_int MAX_12BIT_OFFSET))
1626 (const_int 4)
1627 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1628 (const_int MAX_17BIT_OFFSET))
1629 (const_int 8)
1630 (match_test "TARGET_PORTABLE_RUNTIME")
1631 (const_int 24)
1632 (not (match_test "flag_pic"))
1633 (const_int 20)]
1634 (const_int 28)))])
1635
1636 (define_insn ""
1637 [(set (pc)
1638 (if_then_else
1639 (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1640 (const_int 1)
1641 (match_operand:SI 1 "uint5_operand" ""))
1642 (const_int 0))
1643 (pc)
1644 (label_ref (match_operand 2 "" ""))))]
1645 ""
1646 "*
1647 {
1648 return pa_output_bb (operands, 1, insn, 0);
1649 }"
1650 [(set_attr "type" "cbranch")
1651 (set (attr "length")
1652 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1653 (const_int MAX_12BIT_OFFSET))
1654 (const_int 4)
1655 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1656 (const_int MAX_17BIT_OFFSET))
1657 (const_int 8)
1658 (match_test "TARGET_PORTABLE_RUNTIME")
1659 (const_int 24)
1660 (not (match_test "flag_pic"))
1661 (const_int 20)]
1662 (const_int 28)))])
1663
1664 (define_insn ""
1665 [(set (pc)
1666 (if_then_else
1667 (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1668 (const_int 1)
1669 (match_operand:DI 1 "uint32_operand" ""))
1670 (const_int 0))
1671 (pc)
1672 (label_ref (match_operand 2 "" ""))))]
1673 "TARGET_64BIT"
1674 "*
1675 {
1676 return pa_output_bb (operands, 1, insn, 0);
1677 }"
1678 [(set_attr "type" "cbranch")
1679 (set (attr "length")
1680 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1681 (const_int MAX_12BIT_OFFSET))
1682 (const_int 4)
1683 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1684 (const_int MAX_17BIT_OFFSET))
1685 (const_int 8)
1686 (match_test "TARGET_PORTABLE_RUNTIME")
1687 (const_int 24)
1688 (not (match_test "flag_pic"))
1689 (const_int 20)]
1690 (const_int 28)))])
1691
1692 (define_insn ""
1693 [(set (pc)
1694 (if_then_else
1695 (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1696 (const_int 1)
1697 (match_operand:SI 1 "uint5_operand" ""))
1698 (const_int 0))
1699 (label_ref (match_operand 2 "" ""))
1700 (pc)))]
1701 ""
1702 "*
1703 {
1704 return pa_output_bb (operands, 0, insn, 1);
1705 }"
1706 [(set_attr "type" "cbranch")
1707 (set (attr "length")
1708 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1709 (const_int MAX_12BIT_OFFSET))
1710 (const_int 4)
1711 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1712 (const_int MAX_17BIT_OFFSET))
1713 (const_int 8)
1714 (match_test "TARGET_PORTABLE_RUNTIME")
1715 (const_int 24)
1716 (not (match_test "flag_pic"))
1717 (const_int 20)]
1718 (const_int 28)))])
1719
1720 (define_insn ""
1721 [(set (pc)
1722 (if_then_else
1723 (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1724 (const_int 1)
1725 (match_operand:DI 1 "uint32_operand" ""))
1726 (const_int 0))
1727 (label_ref (match_operand 2 "" ""))
1728 (pc)))]
1729 "TARGET_64BIT"
1730 "*
1731 {
1732 return pa_output_bb (operands, 0, insn, 1);
1733 }"
1734 [(set_attr "type" "cbranch")
1735 (set (attr "length")
1736 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1737 (const_int MAX_12BIT_OFFSET))
1738 (const_int 4)
1739 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1740 (const_int MAX_17BIT_OFFSET))
1741 (const_int 8)
1742 (match_test "TARGET_PORTABLE_RUNTIME")
1743 (const_int 24)
1744 (not (match_test "flag_pic"))
1745 (const_int 20)]
1746 (const_int 28)))])
1747
1748 (define_insn ""
1749 [(set (pc)
1750 (if_then_else
1751 (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1752 (const_int 1)
1753 (match_operand:SI 1 "uint5_operand" ""))
1754 (const_int 0))
1755 (pc)
1756 (label_ref (match_operand 2 "" ""))))]
1757 ""
1758 "*
1759 {
1760 return pa_output_bb (operands, 1, insn, 1);
1761 }"
1762 [(set_attr "type" "cbranch")
1763 (set (attr "length")
1764 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1765 (const_int MAX_12BIT_OFFSET))
1766 (const_int 4)
1767 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1768 (const_int MAX_17BIT_OFFSET))
1769 (const_int 8)
1770 (match_test "TARGET_PORTABLE_RUNTIME")
1771 (const_int 24)
1772 (not (match_test "flag_pic"))
1773 (const_int 20)]
1774 (const_int 28)))])
1775
1776 (define_insn ""
1777 [(set (pc)
1778 (if_then_else
1779 (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1780 (const_int 1)
1781 (match_operand:DI 1 "uint32_operand" ""))
1782 (const_int 0))
1783 (pc)
1784 (label_ref (match_operand 2 "" ""))))]
1785 "TARGET_64BIT"
1786 "*
1787 {
1788 return pa_output_bb (operands, 1, insn, 1);
1789 }"
1790 [(set_attr "type" "cbranch")
1791 (set (attr "length")
1792 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1793 (const_int MAX_12BIT_OFFSET))
1794 (const_int 4)
1795 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1796 (const_int MAX_17BIT_OFFSET))
1797 (const_int 8)
1798 (match_test "TARGET_PORTABLE_RUNTIME")
1799 (const_int 24)
1800 (not (match_test "flag_pic"))
1801 (const_int 20)]
1802 (const_int 28)))])
1803
1804 ;; Branch on Variable Bit patterns.
1805 (define_insn ""
1806 [(set (pc)
1807 (if_then_else
1808 (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1809 (const_int 1)
1810 (match_operand:SI 1 "register_operand" "q"))
1811 (const_int 0))
1812 (label_ref (match_operand 2 "" ""))
1813 (pc)))]
1814 ""
1815 "*
1816 {
1817 return pa_output_bvb (operands, 0, insn, 0);
1818 }"
1819 [(set_attr "type" "cbranch")
1820 (set (attr "length")
1821 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1822 (const_int MAX_12BIT_OFFSET))
1823 (const_int 4)
1824 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1825 (const_int MAX_17BIT_OFFSET))
1826 (const_int 8)
1827 (match_test "TARGET_PORTABLE_RUNTIME")
1828 (const_int 24)
1829 (not (match_test "flag_pic"))
1830 (const_int 20)]
1831 (const_int 28)))])
1832
1833 (define_insn ""
1834 [(set (pc)
1835 (if_then_else
1836 (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1837 (const_int 1)
1838 (match_operand:DI 1 "register_operand" "q"))
1839 (const_int 0))
1840 (label_ref (match_operand 2 "" ""))
1841 (pc)))]
1842 "TARGET_64BIT"
1843 "*
1844 {
1845 return pa_output_bvb (operands, 0, insn, 0);
1846 }"
1847 [(set_attr "type" "cbranch")
1848 (set (attr "length")
1849 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1850 (const_int MAX_12BIT_OFFSET))
1851 (const_int 4)
1852 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1853 (const_int MAX_17BIT_OFFSET))
1854 (const_int 8)
1855 (match_test "TARGET_PORTABLE_RUNTIME")
1856 (const_int 24)
1857 (not (match_test "flag_pic"))
1858 (const_int 20)]
1859 (const_int 28)))])
1860
1861 (define_insn ""
1862 [(set (pc)
1863 (if_then_else
1864 (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1865 (const_int 1)
1866 (match_operand:SI 1 "register_operand" "q"))
1867 (const_int 0))
1868 (pc)
1869 (label_ref (match_operand 2 "" ""))))]
1870 ""
1871 "*
1872 {
1873 return pa_output_bvb (operands, 1, insn, 0);
1874 }"
1875 [(set_attr "type" "cbranch")
1876 (set (attr "length")
1877 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1878 (const_int MAX_12BIT_OFFSET))
1879 (const_int 4)
1880 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1881 (const_int MAX_17BIT_OFFSET))
1882 (const_int 8)
1883 (match_test "TARGET_PORTABLE_RUNTIME")
1884 (const_int 24)
1885 (not (match_test "flag_pic"))
1886 (const_int 20)]
1887 (const_int 28)))])
1888
1889 (define_insn ""
1890 [(set (pc)
1891 (if_then_else
1892 (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1893 (const_int 1)
1894 (match_operand:DI 1 "register_operand" "q"))
1895 (const_int 0))
1896 (pc)
1897 (label_ref (match_operand 2 "" ""))))]
1898 "TARGET_64BIT"
1899 "*
1900 {
1901 return pa_output_bvb (operands, 1, insn, 0);
1902 }"
1903 [(set_attr "type" "cbranch")
1904 (set (attr "length")
1905 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1906 (const_int MAX_12BIT_OFFSET))
1907 (const_int 4)
1908 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1909 (const_int MAX_17BIT_OFFSET))
1910 (const_int 8)
1911 (match_test "TARGET_PORTABLE_RUNTIME")
1912 (const_int 24)
1913 (not (match_test "flag_pic"))
1914 (const_int 20)]
1915 (const_int 28)))])
1916
1917 (define_insn ""
1918 [(set (pc)
1919 (if_then_else
1920 (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1921 (const_int 1)
1922 (match_operand:SI 1 "register_operand" "q"))
1923 (const_int 0))
1924 (label_ref (match_operand 2 "" ""))
1925 (pc)))]
1926 ""
1927 "*
1928 {
1929 return pa_output_bvb (operands, 0, insn, 1);
1930 }"
1931 [(set_attr "type" "cbranch")
1932 (set (attr "length")
1933 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1934 (const_int MAX_12BIT_OFFSET))
1935 (const_int 4)
1936 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1937 (const_int MAX_17BIT_OFFSET))
1938 (const_int 8)
1939 (match_test "TARGET_PORTABLE_RUNTIME")
1940 (const_int 24)
1941 (not (match_test "flag_pic"))
1942 (const_int 20)]
1943 (const_int 28)))])
1944
1945 (define_insn ""
1946 [(set (pc)
1947 (if_then_else
1948 (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1949 (const_int 1)
1950 (match_operand:DI 1 "register_operand" "q"))
1951 (const_int 0))
1952 (label_ref (match_operand 2 "" ""))
1953 (pc)))]
1954 "TARGET_64BIT"
1955 "*
1956 {
1957 return pa_output_bvb (operands, 0, insn, 1);
1958 }"
1959 [(set_attr "type" "cbranch")
1960 (set (attr "length")
1961 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1962 (const_int MAX_12BIT_OFFSET))
1963 (const_int 4)
1964 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1965 (const_int MAX_17BIT_OFFSET))
1966 (const_int 8)
1967 (match_test "TARGET_PORTABLE_RUNTIME")
1968 (const_int 24)
1969 (not (match_test "flag_pic"))
1970 (const_int 20)]
1971 (const_int 28)))])
1972
1973 (define_insn ""
1974 [(set (pc)
1975 (if_then_else
1976 (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1977 (const_int 1)
1978 (match_operand:SI 1 "register_operand" "q"))
1979 (const_int 0))
1980 (pc)
1981 (label_ref (match_operand 2 "" ""))))]
1982 ""
1983 "*
1984 {
1985 return pa_output_bvb (operands, 1, insn, 1);
1986 }"
1987 [(set_attr "type" "cbranch")
1988 (set (attr "length")
1989 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1990 (const_int MAX_12BIT_OFFSET))
1991 (const_int 4)
1992 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1993 (const_int MAX_17BIT_OFFSET))
1994 (const_int 8)
1995 (match_test "TARGET_PORTABLE_RUNTIME")
1996 (const_int 24)
1997 (not (match_test "flag_pic"))
1998 (const_int 20)]
1999 (const_int 28)))])
2000
2001 (define_insn ""
2002 [(set (pc)
2003 (if_then_else
2004 (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2005 (const_int 1)
2006 (match_operand:DI 1 "register_operand" "q"))
2007 (const_int 0))
2008 (pc)
2009 (label_ref (match_operand 2 "" ""))))]
2010 "TARGET_64BIT"
2011 "*
2012 {
2013 return pa_output_bvb (operands, 1, insn, 1);
2014 }"
2015 [(set_attr "type" "cbranch")
2016 (set (attr "length")
2017 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2018 (const_int MAX_12BIT_OFFSET))
2019 (const_int 4)
2020 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2021 (const_int MAX_17BIT_OFFSET))
2022 (const_int 8)
2023 (match_test "TARGET_PORTABLE_RUNTIME")
2024 (const_int 24)
2025 (not (match_test "flag_pic"))
2026 (const_int 20)]
2027 (const_int 28)))])
2028
2029 ;; Floating point branches
2030
2031 ;; ??? Nullification is handled differently from other branches.
2032 ;; If nullification is specified, the delay slot is nullified on any
2033 ;; taken branch regardless of branch direction.
2034 (define_insn ""
2035 [(set (pc) (if_then_else (ne (reg:CCFP 0) (const_int 0))
2036 (label_ref (match_operand 0 "" ""))
2037 (pc)))]
2038 "!TARGET_SOFT_FLOAT"
2039 "*
2040 {
2041 int length = get_attr_length (insn);
2042 rtx xoperands[1];
2043 int nullify, xdelay;
2044
2045 if (length < 16)
2046 return \"ftest\;b%* %l0\";
2047
2048 if (dbr_sequence_length () == 0 || INSN_ANNULLED_BRANCH_P (insn))
2049 {
2050 nullify = 1;
2051 xdelay = 0;
2052 xoperands[0] = GEN_INT (length - 8);
2053 }
2054 else
2055 {
2056 nullify = 0;
2057 xdelay = 1;
2058 xoperands[0] = GEN_INT (length - 4);
2059 }
2060
2061 if (nullify)
2062 output_asm_insn (\"ftest\;add,tr %%r0,%%r0,%%r0\;b,n .+%0\", xoperands);
2063 else
2064 output_asm_insn (\"ftest\;add,tr %%r0,%%r0,%%r0\;b .+%0\", xoperands);
2065 return pa_output_lbranch (operands[0], insn, xdelay);
2066 }"
2067 [(set_attr "type" "fbranch")
2068 (set (attr "length")
2069 (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
2070 (const_int MAX_17BIT_OFFSET))
2071 (const_int 8)
2072 (match_test "TARGET_PORTABLE_RUNTIME")
2073 (const_int 32)
2074 (not (match_test "flag_pic"))
2075 (const_int 28)]
2076 (const_int 36)))])
2077
2078 (define_insn ""
2079 [(set (pc) (if_then_else (ne (reg:CCFP 0) (const_int 0))
2080 (pc)
2081 (label_ref (match_operand 0 "" ""))))]
2082 "!TARGET_SOFT_FLOAT"
2083 "*
2084 {
2085 int length = get_attr_length (insn);
2086 rtx xoperands[1];
2087 int nullify, xdelay;
2088
2089 if (length < 16)
2090 return \"ftest\;add,tr %%r0,%%r0,%%r0\;b%* %0\";
2091
2092 if (dbr_sequence_length () == 0 || INSN_ANNULLED_BRANCH_P (insn))
2093 {
2094 nullify = 1;
2095 xdelay = 0;
2096 xoperands[0] = GEN_INT (length - 4);
2097 }
2098 else
2099 {
2100 nullify = 0;
2101 xdelay = 1;
2102 xoperands[0] = GEN_INT (length);
2103 }
2104
2105 if (nullify)
2106 output_asm_insn (\"ftest\;b,n .+%0\", xoperands);
2107 else
2108 output_asm_insn (\"ftest\;b .+%0\", xoperands);
2109 return pa_output_lbranch (operands[0], insn, xdelay);
2110 }"
2111 [(set_attr "type" "fbranch")
2112 (set (attr "length")
2113 (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
2114 (const_int MAX_17BIT_OFFSET))
2115 (const_int 12)
2116 (match_test "TARGET_PORTABLE_RUNTIME")
2117 (const_int 28)
2118 (not (match_test "flag_pic"))
2119 (const_int 24)]
2120 (const_int 32)))])
2121
2122 ;; Move instructions
2123
2124 (define_expand "movsi"
2125 [(set (match_operand:SI 0 "general_operand" "")
2126 (match_operand:SI 1 "general_operand" ""))]
2127 ""
2128 "
2129 {
2130 if (pa_emit_move_sequence (operands, SImode, 0))
2131 DONE;
2132 }")
2133
2134 ;; Handle SImode input reloads requiring %r1 as a scratch register.
2135 (define_expand "reload_insi_r1"
2136 [(set (match_operand:SI 0 "register_operand" "=Z")
2137 (match_operand:SI 1 "non_hard_reg_operand" ""))
2138 (clobber (match_operand:SI 2 "register_operand" "=&a"))]
2139 ""
2140 "
2141 {
2142 if (pa_emit_move_sequence (operands, SImode, operands[2]))
2143 DONE;
2144
2145 /* We don't want the clobber emitted, so handle this ourselves. */
2146 emit_insn (gen_rtx_SET (operands[0], operands[1]));
2147 DONE;
2148 }")
2149
2150 ;; Handle SImode input reloads requiring a general register as a
2151 ;; scratch register.
2152 (define_expand "reload_insi"
2153 [(set (match_operand:SI 0 "register_operand" "=Z")
2154 (match_operand:SI 1 "non_hard_reg_operand" ""))
2155 (clobber (match_operand:SI 2 "register_operand" "=&r"))]
2156 ""
2157 "
2158 {
2159 if (pa_emit_move_sequence (operands, SImode, operands[2]))
2160 DONE;
2161
2162 /* We don't want the clobber emitted, so handle this ourselves. */
2163 emit_insn (gen_rtx_SET (operands[0], operands[1]));
2164 DONE;
2165 }")
2166
2167 ;; Handle SImode output reloads requiring a general register as a
2168 ;; scratch register.
2169 (define_expand "reload_outsi"
2170 [(set (match_operand:SI 0 "non_hard_reg_operand" "")
2171 (match_operand:SI 1 "register_operand" "Z"))
2172 (clobber (match_operand:SI 2 "register_operand" "=&r"))]
2173 ""
2174 "
2175 {
2176 if (pa_emit_move_sequence (operands, SImode, operands[2]))
2177 DONE;
2178
2179 /* We don't want the clobber emitted, so handle this ourselves. */
2180 emit_insn (gen_rtx_SET (operands[0], operands[1]));
2181 DONE;
2182 }")
2183
2184 (define_insn ""
2185 [(set (match_operand:SI 0 "move_dest_operand"
2186 "=r,r,r,r,r,r,Q,!*q,!r,!*f,*f,T,?r,?*f")
2187 (match_operand:SI 1 "move_src_operand"
2188 "A,r,J,N,K,RQ,rM,!rM,!*q,!*fM,RT,*f,*f,r"))]
2189 "(register_operand (operands[0], SImode)
2190 || reg_or_0_operand (operands[1], SImode))
2191 && !TARGET_SOFT_FLOAT
2192 && !TARGET_64BIT"
2193 "@
2194 ldw RT'%A1,%0
2195 copy %1,%0
2196 ldi %1,%0
2197 ldil L'%1,%0
2198 {zdepi|depwi,z} %Z1,%0
2199 ldw%M1 %1,%0
2200 stw%M0 %r1,%0
2201 mtsar %r1
2202 {mfctl|mfctl,w} %%sar,%0
2203 fcpy,sgl %f1,%0
2204 fldw%F1 %1,%0
2205 fstw%F0 %1,%0
2206 {fstws|fstw} %1,-16(%%sp)\n\t{ldws|ldw} -16(%%sp),%0
2207 {stws|stw} %1,-16(%%sp)\n\t{fldws|fldw} -16(%%sp),%0"
2208 [(set_attr "type" "load,move,move,move,shift,load,store,move,move,fpalu,fpload,fpstore,fpstore_load,store_fpload")
2209 (set_attr "pa_combine_type" "addmove")
2210 (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4,8,8")])
2211
2212 (define_insn ""
2213 [(set (match_operand:SI 0 "move_dest_operand"
2214 "=r,r,r,r,r,r,Q,!*q,!r,!*f,*f,T")
2215 (match_operand:SI 1 "move_src_operand"
2216 "A,r,J,N,K,RQ,rM,!rM,!*q,!*fM,RT,*f"))]
2217 "(register_operand (operands[0], SImode)
2218 || reg_or_0_operand (operands[1], SImode))
2219 && !TARGET_SOFT_FLOAT
2220 && TARGET_64BIT"
2221 "@
2222 ldw RT'%A1,%0
2223 copy %1,%0
2224 ldi %1,%0
2225 ldil L'%1,%0
2226 {zdepi|depwi,z} %Z1,%0
2227 ldw%M1 %1,%0
2228 stw%M0 %r1,%0
2229 mtsar %r1
2230 {mfctl|mfctl,w} %%sar,%0
2231 fcpy,sgl %f1,%0
2232 fldw%F1 %1,%0
2233 fstw%F0 %1,%0"
2234 [(set_attr "type" "load,move,move,move,shift,load,store,move,move,fpalu,fpload,fpstore")
2235 (set_attr "pa_combine_type" "addmove")
2236 (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4")])
2237
2238 (define_insn ""
2239 [(set (match_operand:SI 0 "indexed_memory_operand" "=R")
2240 (match_operand:SI 1 "register_operand" "f"))]
2241 "!TARGET_SOFT_FLOAT
2242 && !TARGET_DISABLE_INDEXING
2243 && reload_completed"
2244 "fstw%F0 %1,%0"
2245 [(set_attr "type" "fpstore")
2246 (set_attr "pa_combine_type" "addmove")
2247 (set_attr "length" "4")])
2248
2249 ; Rewrite RTL using an indexed store. This will allow the insn that
2250 ; computes the address to be deleted if the register it sets is dead.
2251 (define_peephole2
2252 [(set (match_operand:SI 0 "register_operand" "")
2253 (plus:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
2254 (const_int 2))
2255 (match_operand:SI 2 "register_operand" "")))
2256 (set (mem:SI (match_dup 0))
2257 (match_operand:SI 3 "register_operand" ""))]
2258 "!TARGET_SOFT_FLOAT
2259 && !TARGET_DISABLE_INDEXING
2260 && REG_OK_FOR_BASE_P (operands[2])
2261 && FP_REGNO_P (REGNO (operands[3]))"
2262 [(set (mem:SI (plus:SI (mult:SI (match_dup 1) (const_int 4)) (match_dup 2)))
2263 (match_dup 3))
2264 (set (match_dup 0) (plus:SI (ashift:SI (match_dup 1) (const_int 2))
2265 (match_dup 2)))]
2266 "")
2267
2268 (define_peephole2
2269 [(set (match_operand:DI 0 "register_operand" "")
2270 (plus:DI (ashift:DI (match_operand:DI 1 "register_operand" "")
2271 (const_int 2))
2272 (match_operand:DI 2 "register_operand" "")))
2273 (set (mem:SI (match_dup 0))
2274 (match_operand:SI 3 "register_operand" ""))]
2275 "!TARGET_SOFT_FLOAT
2276 && !TARGET_DISABLE_INDEXING
2277 && TARGET_64BIT
2278 && REG_OK_FOR_BASE_P (operands[2])
2279 && FP_REGNO_P (REGNO (operands[3]))"
2280 [(set (mem:SI (plus:DI (mult:DI (match_dup 1) (const_int 4)) (match_dup 2)))
2281 (match_dup 3))
2282 (set (match_dup 0) (plus:DI (ashift:DI (match_dup 1) (const_int 2))
2283 (match_dup 2)))]
2284 "")
2285
2286 (define_peephole2
2287 [(set (match_operand:SI 0 "register_operand" "")
2288 (plus:SI (match_operand:SI 1 "register_operand" "")
2289 (match_operand:SI 2 "register_operand" "")))
2290 (set (mem:SI (match_dup 0))
2291 (match_operand:SI 3 "register_operand" ""))]
2292 "!TARGET_SOFT_FLOAT
2293 && !TARGET_DISABLE_INDEXING
2294 && TARGET_NO_SPACE_REGS
2295 && REG_OK_FOR_INDEX_P (operands[1])
2296 && REG_OK_FOR_BASE_P (operands[2])
2297 && FP_REGNO_P (REGNO (operands[3]))"
2298 [(set (mem:SI (plus:SI (match_dup 1) (match_dup 2)))
2299 (match_dup 3))
2300 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
2301 "")
2302
2303 (define_peephole2
2304 [(set (match_operand:SI 0 "register_operand" "")
2305 (plus:SI (match_operand:SI 1 "register_operand" "")
2306 (match_operand:SI 2 "register_operand" "")))
2307 (set (mem:SI (match_dup 0))
2308 (match_operand:SI 3 "register_operand" ""))]
2309 "!TARGET_SOFT_FLOAT
2310 && !TARGET_DISABLE_INDEXING
2311 && TARGET_NO_SPACE_REGS
2312 && REG_OK_FOR_BASE_P (operands[1])
2313 && REG_OK_FOR_INDEX_P (operands[2])
2314 && FP_REGNO_P (REGNO (operands[3]))"
2315 [(set (mem:SI (plus:SI (match_dup 2) (match_dup 1)))
2316 (match_dup 3))
2317 (set (match_dup 0) (plus:SI (match_dup 2) (match_dup 1)))]
2318 "")
2319
2320 (define_peephole2
2321 [(set (match_operand:DI 0 "register_operand" "")
2322 (plus:DI (match_operand:DI 1 "register_operand" "")
2323 (match_operand:DI 2 "register_operand" "")))
2324 (set (mem:SI (match_dup 0))
2325 (match_operand:SI 3 "register_operand" ""))]
2326 "!TARGET_SOFT_FLOAT
2327 && !TARGET_DISABLE_INDEXING
2328 && TARGET_64BIT
2329 && TARGET_NO_SPACE_REGS
2330 && REG_OK_FOR_INDEX_P (operands[1])
2331 && REG_OK_FOR_BASE_P (operands[2])
2332 && FP_REGNO_P (REGNO (operands[3]))"
2333 [(set (mem:SI (plus:DI (match_dup 1) (match_dup 2)))
2334 (match_dup 3))
2335 (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
2336 "")
2337
2338 (define_peephole2
2339 [(set (match_operand:DI 0 "register_operand" "")
2340 (plus:DI (match_operand:DI 1 "register_operand" "")
2341 (match_operand:DI 2 "register_operand" "")))
2342 (set (mem:SI (match_dup 0))
2343 (match_operand:SI 3 "register_operand" ""))]
2344 "!TARGET_SOFT_FLOAT
2345 && !TARGET_DISABLE_INDEXING
2346 && TARGET_64BIT
2347 && TARGET_NO_SPACE_REGS
2348 && REG_OK_FOR_BASE_P (operands[1])
2349 && REG_OK_FOR_INDEX_P (operands[2])
2350 && FP_REGNO_P (REGNO (operands[3]))"
2351 [(set (mem:SI (plus:DI (match_dup 2) (match_dup 1)))
2352 (match_dup 3))
2353 (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
2354 "")
2355
2356 (define_insn ""
2357 [(set (match_operand:SI 0 "move_dest_operand"
2358 "=r,r,r,r,r,r,Q,!*q,!r")
2359 (match_operand:SI 1 "move_src_operand"
2360 "A,r,J,N,K,RQ,rM,!rM,!*q"))]
2361 "(register_operand (operands[0], SImode)
2362 || reg_or_0_operand (operands[1], SImode))
2363 && TARGET_SOFT_FLOAT"
2364 "@
2365 ldw RT'%A1,%0
2366 copy %1,%0
2367 ldi %1,%0
2368 ldil L'%1,%0
2369 {zdepi|depwi,z} %Z1,%0
2370 ldw%M1 %1,%0
2371 stw%M0 %r1,%0
2372 mtsar %r1
2373 {mfctl|mfctl,w} %%sar,%0"
2374 [(set_attr "type" "load,move,move,move,move,load,store,move,move")
2375 (set_attr "pa_combine_type" "addmove")
2376 (set_attr "length" "4,4,4,4,4,4,4,4,4")])
2377
2378 ;; Load or store with base-register modification.
2379 (define_insn ""
2380 [(set (match_operand:SI 0 "register_operand" "=r")
2381 (mem:SI (plus:DI (match_operand:DI 1 "register_operand" "+r")
2382 (match_operand:DI 2 "int5_operand" "L"))))
2383 (set (match_dup 1)
2384 (plus:DI (match_dup 1) (match_dup 2)))]
2385 "TARGET_64BIT"
2386 "ldw,mb %2(%1),%0"
2387 [(set_attr "type" "load")
2388 (set_attr "length" "4")])
2389
2390 ; And a zero extended variant.
2391 (define_insn ""
2392 [(set (match_operand:DI 0 "register_operand" "=r")
2393 (zero_extend:DI (mem:SI
2394 (plus:DI
2395 (match_operand:DI 1 "register_operand" "+r")
2396 (match_operand:DI 2 "int5_operand" "L")))))
2397 (set (match_dup 1)
2398 (plus:DI (match_dup 1) (match_dup 2)))]
2399 "TARGET_64BIT"
2400 "ldw,mb %2(%1),%0"
2401 [(set_attr "type" "load")
2402 (set_attr "length" "4")])
2403
2404 (define_expand "pre_load"
2405 [(parallel [(set (match_operand:SI 0 "register_operand" "")
2406 (mem (plus (match_operand 1 "register_operand" "")
2407 (match_operand 2 "pre_cint_operand" ""))))
2408 (set (match_dup 1)
2409 (plus (match_dup 1) (match_dup 2)))])]
2410 ""
2411 "
2412 {
2413 if (TARGET_64BIT)
2414 {
2415 emit_insn (gen_pre_ldd (operands[0], operands[1], operands[2]));
2416 DONE;
2417 }
2418 emit_insn (gen_pre_ldw (operands[0], operands[1], operands[2]));
2419 DONE;
2420 }")
2421
2422 (define_insn "pre_ldw"
2423 [(set (match_operand:SI 0 "register_operand" "=r")
2424 (mem:SI (plus:SI (match_operand:SI 1 "register_operand" "+r")
2425 (match_operand:SI 2 "pre_cint_operand" ""))))
2426 (set (match_dup 1)
2427 (plus:SI (match_dup 1) (match_dup 2)))]
2428 ""
2429 "*
2430 {
2431 if (INTVAL (operands[2]) < 0)
2432 return \"{ldwm|ldw,mb} %2(%1),%0\";
2433 return \"{ldws|ldw},mb %2(%1),%0\";
2434 }"
2435 [(set_attr "type" "load")
2436 (set_attr "length" "4")])
2437
2438 (define_insn "pre_ldd"
2439 [(set (match_operand:DI 0 "register_operand" "=r")
2440 (mem:DI (plus:DI (match_operand:DI 1 "register_operand" "+r")
2441 (match_operand:DI 2 "pre_cint_operand" ""))))
2442 (set (match_dup 1)
2443 (plus:DI (match_dup 1) (match_dup 2)))]
2444 "TARGET_64BIT"
2445 "ldd,mb %2(%1),%0"
2446 [(set_attr "type" "load")
2447 (set_attr "length" "4")])
2448
2449 (define_insn ""
2450 [(set (mem:SI (plus:SI (match_operand:SI 0 "register_operand" "+r")
2451 (match_operand:SI 1 "pre_cint_operand" "")))
2452 (match_operand:SI 2 "reg_or_0_operand" "rM"))
2453 (set (match_dup 0)
2454 (plus:SI (match_dup 0) (match_dup 1)))]
2455 ""
2456 "*
2457 {
2458 if (INTVAL (operands[1]) < 0)
2459 return \"{stwm|stw,mb} %r2,%1(%0)\";
2460 return \"{stws|stw},mb %r2,%1(%0)\";
2461 }"
2462 [(set_attr "type" "store")
2463 (set_attr "length" "4")])
2464
2465 (define_insn ""
2466 [(set (match_operand:SI 0 "register_operand" "=r")
2467 (mem:SI (match_operand:SI 1 "register_operand" "+r")))
2468 (set (match_dup 1)
2469 (plus:SI (match_dup 1)
2470 (match_operand:SI 2 "post_cint_operand" "")))]
2471 ""
2472 "*
2473 {
2474 if (INTVAL (operands[2]) > 0)
2475 return \"{ldwm|ldw,ma} %2(%1),%0\";
2476 return \"{ldws|ldw},ma %2(%1),%0\";
2477 }"
2478 [(set_attr "type" "load")
2479 (set_attr "length" "4")])
2480
2481 (define_expand "post_store"
2482 [(parallel [(set (mem (match_operand 0 "register_operand" ""))
2483 (match_operand 1 "reg_or_0_operand" ""))
2484 (set (match_dup 0)
2485 (plus (match_dup 0)
2486 (match_operand 2 "post_cint_operand" "")))])]
2487 ""
2488 "
2489 {
2490 if (TARGET_64BIT)
2491 {
2492 emit_insn (gen_post_std (operands[0], operands[1], operands[2]));
2493 DONE;
2494 }
2495 emit_insn (gen_post_stw (operands[0], operands[1], operands[2]));
2496 DONE;
2497 }")
2498
2499 (define_insn "post_stw"
2500 [(set (mem:SI (match_operand:SI 0 "register_operand" "+r"))
2501 (match_operand:SI 1 "reg_or_0_operand" "rM"))
2502 (set (match_dup 0)
2503 (plus:SI (match_dup 0)
2504 (match_operand:SI 2 "post_cint_operand" "")))]
2505 ""
2506 "*
2507 {
2508 if (INTVAL (operands[2]) > 0)
2509 return \"{stwm|stw,ma} %r1,%2(%0)\";
2510 return \"{stws|stw},ma %r1,%2(%0)\";
2511 }"
2512 [(set_attr "type" "store")
2513 (set_attr "length" "4")])
2514
2515 (define_insn "post_std"
2516 [(set (mem:DI (match_operand:DI 0 "register_operand" "+r"))
2517 (match_operand:DI 1 "reg_or_0_operand" "rM"))
2518 (set (match_dup 0)
2519 (plus:DI (match_dup 0)
2520 (match_operand:DI 2 "post_cint_operand" "")))]
2521 "TARGET_64BIT"
2522 "std,ma %r1,%2(%0)"
2523 [(set_attr "type" "store")
2524 (set_attr "length" "4")])
2525
2526 ;; For loading the address of a label while generating PIC code.
2527 ;; Note since this pattern can be created at reload time (via movsi), all
2528 ;; the same rules for movsi apply here. (no new pseudos, no temporaries).
2529 (define_insn ""
2530 [(set (match_operand 0 "pmode_register_operand" "=a")
2531 (match_operand 1 "pic_label_operand" ""))]
2532 "TARGET_PA_20"
2533 "*
2534 {
2535 rtx xoperands[3];
2536
2537 xoperands[0] = operands[0];
2538 xoperands[1] = operands[1];
2539 xoperands[2] = gen_label_rtx ();
2540
2541 (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
2542 CODE_LABEL_NUMBER (xoperands[2]));
2543 output_asm_insn (\"mfia %0\", xoperands);
2544
2545 /* If we're trying to load the address of a label that happens to be
2546 close, then we can use a shorter sequence. */
2547 if (GET_CODE (operands[1]) == LABEL_REF
2548 && !LABEL_REF_NONLOCAL_P (operands[1])
2549 && INSN_ADDRESSES_SET_P ()
2550 && abs (INSN_ADDRESSES (INSN_UID (XEXP (operands[1], 0)))
2551 - INSN_ADDRESSES (INSN_UID (insn))) < 8100)
2552 output_asm_insn (\"ldo %1-%2(%0),%0\", xoperands);
2553 else
2554 {
2555 output_asm_insn (\"addil L%%%1-%2,%0\", xoperands);
2556 output_asm_insn (\"ldo R%%%1-%2(%0),%0\", xoperands);
2557 }
2558 return \"\";
2559 }"
2560 [(set_attr "type" "multi")
2561 (set_attr "length" "12")]) ; 8 or 12
2562
2563 (define_insn ""
2564 [(set (match_operand 0 "pmode_register_operand" "=a")
2565 (match_operand 1 "pic_label_operand" ""))]
2566 "!TARGET_PA_20"
2567 "*
2568 {
2569 rtx xoperands[3];
2570
2571 xoperands[0] = operands[0];
2572 xoperands[1] = operands[1];
2573 xoperands[2] = gen_label_rtx ();
2574
2575 output_asm_insn (\"bl .+8,%0\", xoperands);
2576 output_asm_insn (\"depi 0,31,2,%0\", xoperands);
2577 (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
2578 CODE_LABEL_NUMBER (xoperands[2]));
2579
2580 /* If we're trying to load the address of a label that happens to be
2581 close, then we can use a shorter sequence. */
2582 if (GET_CODE (operands[1]) == LABEL_REF
2583 && !LABEL_REF_NONLOCAL_P (operands[1])
2584 && INSN_ADDRESSES_SET_P ()
2585 && abs (INSN_ADDRESSES (INSN_UID (XEXP (operands[1], 0)))
2586 - INSN_ADDRESSES (INSN_UID (insn))) < 8100)
2587 output_asm_insn (\"ldo %1-%2(%0),%0\", xoperands);
2588 else
2589 {
2590 output_asm_insn (\"addil L%%%1-%2,%0\", xoperands);
2591 output_asm_insn (\"ldo R%%%1-%2(%0),%0\", xoperands);
2592 }
2593 return \"\";
2594 }"
2595 [(set_attr "type" "multi")
2596 (set_attr "length" "16")]) ; 12 or 16
2597
2598 (define_insn ""
2599 [(set (match_operand:SI 0 "register_operand" "=a")
2600 (plus:SI (match_operand:SI 1 "register_operand" "r")
2601 (high:SI (match_operand 2 "" ""))))]
2602 "symbolic_operand (operands[2], Pmode)
2603 && ! function_label_operand (operands[2], Pmode)
2604 && flag_pic"
2605 "addil LT'%G2,%1"
2606 [(set_attr "type" "binary")
2607 (set_attr "length" "4")])
2608
2609 (define_insn ""
2610 [(set (match_operand:DI 0 "register_operand" "=a")
2611 (plus:DI (match_operand:DI 1 "register_operand" "r")
2612 (high:DI (match_operand 2 "" ""))))]
2613 "symbolic_operand (operands[2], Pmode)
2614 && ! function_label_operand (operands[2], Pmode)
2615 && TARGET_64BIT
2616 && flag_pic"
2617 "addil LT'%G2,%1"
2618 [(set_attr "type" "binary")
2619 (set_attr "length" "4")])
2620
2621 (define_insn ""
2622 [(set (match_operand:SI 0 "register_operand" "=r")
2623 (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
2624 (unspec:SI [(match_operand 2 "" "")] UNSPEC_DLTIND14R)))]
2625 "symbolic_operand (operands[2], Pmode)
2626 && ! function_label_operand (operands[2], Pmode)
2627 && flag_pic"
2628 "ldo RT'%G2(%1),%0"
2629 [(set_attr "type" "binary")
2630 (set_attr "length" "4")])
2631
2632 (define_insn ""
2633 [(set (match_operand:DI 0 "register_operand" "=r")
2634 (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
2635 (unspec:DI [(match_operand 2 "" "")] UNSPEC_DLTIND14R)))]
2636 "symbolic_operand (operands[2], Pmode)
2637 && ! function_label_operand (operands[2], Pmode)
2638 && TARGET_64BIT
2639 && flag_pic"
2640 "ldo RT'%G2(%1),%0"
2641 [(set_attr "type" "binary")
2642 (set_attr "length" "4")])
2643
2644 ;; Always use addil rather than ldil;add sequences. This allows the
2645 ;; HP linker to eliminate the dp relocation if the symbolic operand
2646 ;; lives in the TEXT space.
2647 (define_insn ""
2648 [(set (match_operand:SI 0 "register_operand" "=a")
2649 (high:SI (match_operand 1 "" "")))]
2650 "symbolic_operand (operands[1], Pmode)
2651 && ! function_label_operand (operands[1], Pmode)
2652 && ! read_only_operand (operands[1], Pmode)
2653 && ! flag_pic"
2654 "*
2655 {
2656 if (TARGET_LONG_LOAD_STORE)
2657 return \"addil NLR'%H1,%%r27\;ldo N'%H1(%%r1),%%r1\";
2658 else
2659 return \"addil LR'%H1,%%r27\";
2660 }"
2661 [(set_attr "type" "binary")
2662 (set (attr "length")
2663 (if_then_else (not (match_test "TARGET_LONG_LOAD_STORE"))
2664 (const_int 4)
2665 (const_int 8)))])
2666
2667
2668 ;; This is for use in the prologue/epilogue code. We need it
2669 ;; to add large constants to a stack pointer or frame pointer.
2670 ;; Because of the additional %r1 pressure, we probably do not
2671 ;; want to use this in general code, so make it available
2672 ;; only after reload.
2673 (define_insn ""
2674 [(set (match_operand:SI 0 "register_operand" "=!a,*r")
2675 (plus:SI (match_operand:SI 1 "register_operand" "r,r")
2676 (high:SI (match_operand 2 "const_int_operand" ""))))]
2677 "reload_completed"
2678 "@
2679 addil L'%G2,%1
2680 ldil L'%G2,%0\;{addl|add,l} %0,%1,%0"
2681 [(set_attr "type" "binary,binary")
2682 (set_attr "length" "4,8")])
2683
2684 (define_insn ""
2685 [(set (match_operand:DI 0 "register_operand" "=!a,*r")
2686 (plus:DI (match_operand:DI 1 "register_operand" "r,r")
2687 (high:DI (match_operand 2 "const_int_operand" ""))))]
2688 "reload_completed && TARGET_64BIT"
2689 "@
2690 addil L'%G2,%1
2691 ldil L'%G2,%0\;{addl|add,l} %0,%1,%0"
2692 [(set_attr "type" "binary,binary")
2693 (set_attr "length" "4,8")])
2694
2695 (define_insn ""
2696 [(set (match_operand:SI 0 "register_operand" "=r")
2697 (high:SI (match_operand 1 "" "")))]
2698 "(!flag_pic || !symbolic_operand (operands[1], Pmode))
2699 && !pa_is_function_label_plus_const (operands[1])"
2700 "*
2701 {
2702 if (symbolic_operand (operands[1], Pmode))
2703 return \"ldil LR'%H1,%0\";
2704 else
2705 return \"ldil L'%G1,%0\";
2706 }"
2707 [(set_attr "type" "move")
2708 (set_attr "length" "4")])
2709
2710 (define_insn ""
2711 [(set (match_operand:DI 0 "register_operand" "=r")
2712 (high:DI (match_operand 1 "const_int_operand" "")))]
2713 "TARGET_64BIT"
2714 "ldil L'%G1,%0";
2715 [(set_attr "type" "move")
2716 (set_attr "length" "4")])
2717
2718 (define_insn ""
2719 [(set (match_operand:DI 0 "register_operand" "=r")
2720 (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
2721 (match_operand:DI 2 "const_int_operand" "i")))]
2722 "TARGET_64BIT"
2723 "ldo R'%G2(%1),%0";
2724 [(set_attr "type" "move")
2725 (set_attr "length" "4")])
2726
2727 (define_insn ""
2728 [(set (match_operand:SI 0 "register_operand" "=r")
2729 (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
2730 (match_operand:SI 2 "immediate_operand" "i")))]
2731 "!pa_is_function_label_plus_const (operands[2])"
2732 "*
2733 {
2734 gcc_assert (!flag_pic || !symbolic_operand (operands[2], Pmode));
2735
2736 if (symbolic_operand (operands[2], Pmode))
2737 return \"ldo RR'%G2(%1),%0\";
2738 else
2739 return \"ldo R'%G2(%1),%0\";
2740 }"
2741 [(set_attr "type" "move")
2742 (set_attr "length" "4")])
2743
2744 ;; Now that a symbolic_address plus a constant is broken up early
2745 ;; in the compilation phase (for better CSE) we need a special
2746 ;; combiner pattern to load the symbolic address plus the constant
2747 ;; in only 2 instructions. (For cases where the symbolic address
2748 ;; was not a common subexpression.)
2749 (define_split
2750 [(set (match_operand:SI 0 "register_operand" "")
2751 (match_operand:SI 1 "symbolic_operand" ""))
2752 (clobber (match_operand:SI 2 "register_operand" ""))]
2753 "! (flag_pic && pic_label_operand (operands[1], SImode))"
2754 [(set (match_dup 2) (high:SI (match_dup 1)))
2755 (set (match_dup 0) (lo_sum:SI (match_dup 2) (match_dup 1)))]
2756 "")
2757
2758 ;; hppa_legitimize_address goes to a great deal of trouble to
2759 ;; create addresses which use indexing. In some cases, this
2760 ;; is a lose because there isn't any store instructions which
2761 ;; allow indexed addresses (with integer register source).
2762 ;;
2763 ;; These define_splits try to turn a 3 insn store into
2764 ;; a 2 insn store with some creative RTL rewriting.
2765 (define_split
2766 [(set (mem:SI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2767 (match_operand:SI 1 "mem_shadd_operand" ""))
2768 (plus:SI (match_operand:SI 2 "register_operand" "")
2769 (match_operand:SI 3 "const_int_operand" ""))))
2770 (match_operand:SI 4 "register_operand" ""))
2771 (clobber (match_operand:SI 5 "register_operand" ""))]
2772 ""
2773 [(set (match_dup 5) (plus:SI (ashift:SI (match_dup 0) (match_dup 1))
2774 (match_dup 2)))
2775 (set (mem:SI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2776 "
2777 {
2778 operands[1] = GEN_INT (exact_log2 (INTVAL (operands[1])));
2779
2780 }")
2781
2782 (define_split
2783 [(set (mem:HI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2784 (match_operand:SI 1 "mem_shadd_operand" ""))
2785 (plus:SI (match_operand:SI 2 "register_operand" "")
2786 (match_operand:SI 3 "const_int_operand" ""))))
2787 (match_operand:HI 4 "register_operand" ""))
2788 (clobber (match_operand:SI 5 "register_operand" ""))]
2789 ""
2790 [(set (match_dup 5) (plus:SI (ashift:SI (match_dup 0) (match_dup 1))
2791 (match_dup 2)))
2792 (set (mem:HI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2793 "
2794 {
2795 operands[1] = GEN_INT (exact_log2 (INTVAL (operands[1])));
2796
2797 }")
2798
2799 (define_split
2800 [(set (mem:QI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2801 (match_operand:SI 1 "mem_shadd_operand" ""))
2802 (plus:SI (match_operand:SI 2 "register_operand" "")
2803 (match_operand:SI 3 "const_int_operand" ""))))
2804 (match_operand:QI 4 "register_operand" ""))
2805 (clobber (match_operand:SI 5 "register_operand" ""))]
2806 ""
2807 [(set (match_dup 5) (plus:SI (ashift:SI (match_dup 0) (match_dup 1))
2808 (match_dup 2)))
2809 (set (mem:QI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2810 "
2811 {
2812 operands[1] = GEN_INT (exact_log2 (INTVAL (operands[1])));
2813
2814 }")
2815
2816 (define_expand "movhi"
2817 [(set (match_operand:HI 0 "general_operand" "")
2818 (match_operand:HI 1 "general_operand" ""))]
2819 ""
2820 "
2821 {
2822 if (pa_emit_move_sequence (operands, HImode, 0))
2823 DONE;
2824 }")
2825
2826 ;; Handle HImode input reloads requiring a general register as a
2827 ;; scratch register.
2828 (define_expand "reload_inhi"
2829 [(set (match_operand:HI 0 "register_operand" "=Z")
2830 (match_operand:HI 1 "non_hard_reg_operand" ""))
2831 (clobber (match_operand:HI 2 "register_operand" "=&r"))]
2832 ""
2833 "
2834 {
2835 if (pa_emit_move_sequence (operands, HImode, operands[2]))
2836 DONE;
2837
2838 /* We don't want the clobber emitted, so handle this ourselves. */
2839 emit_insn (gen_rtx_SET (operands[0], operands[1]));
2840 DONE;
2841 }")
2842
2843 ;; Handle HImode output reloads requiring a general register as a
2844 ;; scratch register.
2845 (define_expand "reload_outhi"
2846 [(set (match_operand:HI 0 "non_hard_reg_operand" "")
2847 (match_operand:HI 1 "register_operand" "Z"))
2848 (clobber (match_operand:HI 2 "register_operand" "=&r"))]
2849 ""
2850 "
2851 {
2852 if (pa_emit_move_sequence (operands, HImode, operands[2]))
2853 DONE;
2854
2855 /* We don't want the clobber emitted, so handle this ourselves. */
2856 emit_insn (gen_rtx_SET (operands[0], operands[1]));
2857 DONE;
2858 }")
2859
2860 (define_insn ""
2861 [(set (match_operand:HI 0 "move_dest_operand"
2862 "=r,r,r,r,r,Q,!*q,!r")
2863 (match_operand:HI 1 "move_src_operand"
2864 "r,J,N,K,RQ,rM,!rM,!*q"))]
2865 "(register_operand (operands[0], HImode)
2866 || reg_or_0_operand (operands[1], HImode))"
2867 "@
2868 copy %1,%0
2869 ldi %1,%0
2870 ldil L'%1,%0
2871 {zdepi|depwi,z} %Z1,%0
2872 ldh%M1 %1,%0
2873 sth%M0 %r1,%0
2874 mtsar %r1
2875 {mfctl|mfctl,w} %sar,%0"
2876 [(set_attr "type" "move,move,move,shift,load,store,move,move")
2877 (set_attr "pa_combine_type" "addmove")
2878 (set_attr "length" "4,4,4,4,4,4,4,4")])
2879
2880 (define_insn ""
2881 [(set (match_operand:HI 0 "register_operand" "=r")
2882 (mem:HI (plus:SI (match_operand:SI 1 "register_operand" "+r")
2883 (match_operand:SI 2 "int5_operand" "L"))))
2884 (set (match_dup 1)
2885 (plus:SI (match_dup 1) (match_dup 2)))]
2886 ""
2887 "{ldhs|ldh},mb %2(%1),%0"
2888 [(set_attr "type" "load")
2889 (set_attr "length" "4")])
2890
2891 (define_insn ""
2892 [(set (match_operand:HI 0 "register_operand" "=r")
2893 (mem:HI (plus:DI (match_operand:DI 1 "register_operand" "+r")
2894 (match_operand:DI 2 "int5_operand" "L"))))
2895 (set (match_dup 1)
2896 (plus:DI (match_dup 1) (match_dup 2)))]
2897 "TARGET_64BIT"
2898 "ldh,mb %2(%1),%0"
2899 [(set_attr "type" "load")
2900 (set_attr "length" "4")])
2901
2902 ; And a zero extended variant.
2903 (define_insn ""
2904 [(set (match_operand:DI 0 "register_operand" "=r")
2905 (zero_extend:DI (mem:HI
2906 (plus:DI
2907 (match_operand:DI 1 "register_operand" "+r")
2908 (match_operand:DI 2 "int5_operand" "L")))))
2909 (set (match_dup 1)
2910 (plus:DI (match_dup 1) (match_dup 2)))]
2911 "TARGET_64BIT"
2912 "ldh,mb %2(%1),%0"
2913 [(set_attr "type" "load")
2914 (set_attr "length" "4")])
2915
2916 (define_insn ""
2917 [(set (match_operand:SI 0 "register_operand" "=r")
2918 (zero_extend:SI (mem:HI
2919 (plus:SI
2920 (match_operand:SI 1 "register_operand" "+r")
2921 (match_operand:SI 2 "int5_operand" "L")))))
2922 (set (match_dup 1)
2923 (plus:SI (match_dup 1) (match_dup 2)))]
2924 ""
2925 "{ldhs|ldh},mb %2(%1),%0"
2926 [(set_attr "type" "load")
2927 (set_attr "length" "4")])
2928
2929 (define_insn ""
2930 [(set (match_operand:SI 0 "register_operand" "=r")
2931 (zero_extend:SI (mem:HI
2932 (plus:DI
2933 (match_operand:DI 1 "register_operand" "+r")
2934 (match_operand:DI 2 "int5_operand" "L")))))
2935 (set (match_dup 1)
2936 (plus:DI (match_dup 1) (match_dup 2)))]
2937 "TARGET_64BIT"
2938 "ldh,mb %2(%1),%0"
2939 [(set_attr "type" "load")
2940 (set_attr "length" "4")])
2941
2942 (define_insn ""
2943 [(set (mem:HI (plus:SI (match_operand:SI 0 "register_operand" "+r")
2944 (match_operand:SI 1 "int5_operand" "L")))
2945 (match_operand:HI 2 "reg_or_0_operand" "rM"))
2946 (set (match_dup 0)
2947 (plus:SI (match_dup 0) (match_dup 1)))]
2948 ""
2949 "{sths|sth},mb %r2,%1(%0)"
2950 [(set_attr "type" "store")
2951 (set_attr "length" "4")])
2952
2953 (define_insn ""
2954 [(set (mem:HI (plus:DI (match_operand:DI 0 "register_operand" "+r")
2955 (match_operand:DI 1 "int5_operand" "L")))
2956 (match_operand:HI 2 "reg_or_0_operand" "rM"))
2957 (set (match_dup 0)
2958 (plus:DI (match_dup 0) (match_dup 1)))]
2959 "TARGET_64BIT"
2960 "sth,mb %r2,%1(%0)"
2961 [(set_attr "type" "store")
2962 (set_attr "length" "4")])
2963
2964 (define_insn "addhi3"
2965 [(set (match_operand:HI 0 "register_operand" "=r,r")
2966 (plus:HI (match_operand:HI 1 "register_operand" "%r,r")
2967 (match_operand:HI 2 "arith14_operand" "r,J")))]
2968 ""
2969 "@
2970 {addl|add,l} %1,%2,%0
2971 ldo %2(%1),%0"
2972 [(set_attr "type" "binary,binary")
2973 (set_attr "pa_combine_type" "addmove")
2974 (set_attr "length" "4,4")])
2975
2976 (define_expand "movqi"
2977 [(set (match_operand:QI 0 "general_operand" "")
2978 (match_operand:QI 1 "general_operand" ""))]
2979 ""
2980 "
2981 {
2982 if (pa_emit_move_sequence (operands, QImode, 0))
2983 DONE;
2984 }")
2985
2986 ;; Handle QImode input reloads requiring a general register as a
2987 ;; scratch register.
2988 (define_expand "reload_inqi"
2989 [(set (match_operand:QI 0 "register_operand" "=Z")
2990 (match_operand:QI 1 "non_hard_reg_operand" ""))
2991 (clobber (match_operand:QI 2 "register_operand" "=&r"))]
2992 ""
2993 "
2994 {
2995 if (pa_emit_move_sequence (operands, QImode, operands[2]))
2996 DONE;
2997
2998 /* We don't want the clobber emitted, so handle this ourselves. */
2999 emit_insn (gen_rtx_SET (operands[0], operands[1]));
3000 DONE;
3001 }")
3002
3003 ;; Handle QImode output reloads requiring a general register as a
3004 ;; scratch register.
3005 (define_expand "reload_outqi"
3006 [(set (match_operand:QI 0 "non_hard_reg_operand" "")
3007 (match_operand:QI 1 "register_operand" "Z"))
3008 (clobber (match_operand:QI 2 "register_operand" "=&r"))]
3009 ""
3010 "
3011 {
3012 if (pa_emit_move_sequence (operands, QImode, operands[2]))
3013 DONE;
3014
3015 /* We don't want the clobber emitted, so handle this ourselves. */
3016 emit_insn (gen_rtx_SET (operands[0], operands[1]));
3017 DONE;
3018 }")
3019
3020 (define_insn ""
3021 [(set (match_operand:QI 0 "move_dest_operand"
3022 "=r,r,r,r,r,Q,!*q,!r")
3023 (match_operand:QI 1 "move_src_operand"
3024 "r,J,N,K,RQ,rM,!rM,!*q"))]
3025 "(register_operand (operands[0], QImode)
3026 || reg_or_0_operand (operands[1], QImode))"
3027 "@
3028 copy %1,%0
3029 ldi %1,%0
3030 ldil L'%1,%0
3031 {zdepi|depwi,z} %Z1,%0
3032 ldb%M1 %1,%0
3033 stb%M0 %r1,%0
3034 mtsar %r1
3035 {mfctl|mfctl,w} %%sar,%0"
3036 [(set_attr "type" "move,move,move,shift,load,store,move,move")
3037 (set_attr "pa_combine_type" "addmove")
3038 (set_attr "length" "4,4,4,4,4,4,4,4")])
3039
3040 (define_insn ""
3041 [(set (match_operand:QI 0 "register_operand" "=r")
3042 (mem:QI (plus:SI (match_operand:SI 1 "register_operand" "+r")
3043 (match_operand:SI 2 "int5_operand" "L"))))
3044 (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
3045 ""
3046 "{ldbs|ldb},mb %2(%1),%0"
3047 [(set_attr "type" "load")
3048 (set_attr "length" "4")])
3049
3050 (define_insn ""
3051 [(set (match_operand:QI 0 "register_operand" "=r")
3052 (mem:QI (plus:DI (match_operand:DI 1 "register_operand" "+r")
3053 (match_operand:DI 2 "int5_operand" "L"))))
3054 (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3055 "TARGET_64BIT"
3056 "ldb,mb %2(%1),%0"
3057 [(set_attr "type" "load")
3058 (set_attr "length" "4")])
3059
3060 ; Now the same thing with zero extensions.
3061 (define_insn ""
3062 [(set (match_operand:DI 0 "register_operand" "=r")
3063 (zero_extend:DI (mem:QI (plus:DI
3064 (match_operand:DI 1 "register_operand" "+r")
3065 (match_operand:DI 2 "int5_operand" "L")))))
3066 (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3067 "TARGET_64BIT"
3068 "ldb,mb %2(%1),%0"
3069 [(set_attr "type" "load")
3070 (set_attr "length" "4")])
3071
3072 (define_insn ""
3073 [(set (match_operand:SI 0 "register_operand" "=r")
3074 (zero_extend:SI (mem:QI (plus:SI
3075 (match_operand:SI 1 "register_operand" "+r")
3076 (match_operand:SI 2 "int5_operand" "L")))))
3077 (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
3078 ""
3079 "{ldbs|ldb},mb %2(%1),%0"
3080 [(set_attr "type" "load")
3081 (set_attr "length" "4")])
3082
3083 (define_insn ""
3084 [(set (match_operand:SI 0 "register_operand" "=r")
3085 (zero_extend:SI (mem:QI (plus:DI
3086 (match_operand:DI 1 "register_operand" "+r")
3087 (match_operand:DI 2 "int5_operand" "L")))))
3088 (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3089 "TARGET_64BIT"
3090 "ldb,mb %2(%1),%0"
3091 [(set_attr "type" "load")
3092 (set_attr "length" "4")])
3093
3094 (define_insn ""
3095 [(set (match_operand:HI 0 "register_operand" "=r")
3096 (zero_extend:HI (mem:QI (plus:SI
3097 (match_operand:SI 1 "register_operand" "+r")
3098 (match_operand:SI 2 "int5_operand" "L")))))
3099 (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
3100 ""
3101 "{ldbs|ldb},mb %2(%1),%0"
3102 [(set_attr "type" "load")
3103 (set_attr "length" "4")])
3104
3105 (define_insn ""
3106 [(set (match_operand:HI 0 "register_operand" "=r")
3107 (zero_extend:HI (mem:QI (plus:DI
3108 (match_operand:DI 1 "register_operand" "+r")
3109 (match_operand:DI 2 "int5_operand" "L")))))
3110 (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3111 "TARGET_64BIT"
3112 "ldb,mb %2(%1),%0"
3113 [(set_attr "type" "load")
3114 (set_attr "length" "4")])
3115
3116 (define_insn ""
3117 [(set (mem:QI (plus:SI (match_operand:SI 0 "register_operand" "+r")
3118 (match_operand:SI 1 "int5_operand" "L")))
3119 (match_operand:QI 2 "reg_or_0_operand" "rM"))
3120 (set (match_dup 0)
3121 (plus:SI (match_dup 0) (match_dup 1)))]
3122 ""
3123 "{stbs|stb},mb %r2,%1(%0)"
3124 [(set_attr "type" "store")
3125 (set_attr "length" "4")])
3126
3127 (define_insn ""
3128 [(set (mem:QI (plus:DI (match_operand:DI 0 "register_operand" "+r")
3129 (match_operand:DI 1 "int5_operand" "L")))
3130 (match_operand:QI 2 "reg_or_0_operand" "rM"))
3131 (set (match_dup 0)
3132 (plus:DI (match_dup 0) (match_dup 1)))]
3133 "TARGET_64BIT"
3134 "stb,mb %r2,%1(%0)"
3135 [(set_attr "type" "store")
3136 (set_attr "length" "4")])
3137
3138 ;; The definition of this insn does not really explain what it does,
3139 ;; but it should suffice that anything generated as this insn will be
3140 ;; recognized as a movmemsi operation, and that it will not successfully
3141 ;; combine with anything.
3142 (define_expand "movmemsi"
3143 [(parallel [(set (match_operand:BLK 0 "" "")
3144 (match_operand:BLK 1 "" ""))
3145 (clobber (match_dup 4))
3146 (clobber (match_dup 5))
3147 (clobber (match_dup 6))
3148 (clobber (match_dup 7))
3149 (clobber (match_dup 8))
3150 (use (match_operand:SI 2 "arith14_operand" ""))
3151 (use (match_operand:SI 3 "const_int_operand" ""))])]
3152 "!TARGET_64BIT && optimize > 0"
3153 "
3154 {
3155 int size, align;
3156
3157 /* HP provides very fast block move library routine for the PA;
3158 this routine includes:
3159
3160 4x4 byte at a time block moves,
3161 1x4 byte at a time with alignment checked at runtime with
3162 attempts to align the source and destination as needed
3163 1x1 byte loop
3164
3165 With that in mind, here's the heuristics to try and guess when
3166 the inlined block move will be better than the library block
3167 move:
3168
3169 If the size isn't constant, then always use the library routines.
3170
3171 If the size is large in respect to the known alignment, then use
3172 the library routines.
3173
3174 If the size is small in respect to the known alignment, then open
3175 code the copy (since that will lead to better scheduling).
3176
3177 Else use the block move pattern. */
3178
3179 /* Undetermined size, use the library routine. */
3180 if (GET_CODE (operands[2]) != CONST_INT)
3181 FAIL;
3182
3183 size = INTVAL (operands[2]);
3184 align = INTVAL (operands[3]);
3185 align = align > 4 ? 4 : (align ? align : 1);
3186
3187 /* If size/alignment is large, then use the library routines. */
3188 if (size / align > 16)
3189 FAIL;
3190
3191 /* This does happen, but not often enough to worry much about. */
3192 if (size / align < MOVE_RATIO (optimize_insn_for_speed_p ()))
3193 FAIL;
3194
3195 /* Fall through means we're going to use our block move pattern. */
3196 operands[0]
3197 = replace_equiv_address (operands[0],
3198 copy_to_mode_reg (SImode, XEXP (operands[0], 0)));
3199 operands[1]
3200 = replace_equiv_address (operands[1],
3201 copy_to_mode_reg (SImode, XEXP (operands[1], 0)));
3202 operands[4] = gen_reg_rtx (SImode);
3203 operands[5] = gen_reg_rtx (SImode);
3204 operands[6] = gen_reg_rtx (SImode);
3205 operands[7] = gen_reg_rtx (SImode);
3206 operands[8] = gen_reg_rtx (SImode);
3207 }")
3208
3209 ;; The operand constraints are written like this to support both compile-time
3210 ;; and run-time determined byte counts. The expander and pa_output_block_move
3211 ;; only support compile-time determined counts at this time.
3212 ;;
3213 ;; If the count is run-time determined, the register with the byte count
3214 ;; is clobbered by the copying code, and therefore it is forced to operand 2.
3215 ;;
3216 ;; We used to clobber operands 0 and 1. However, a change to regrename.c
3217 ;; broke this semantic for pseudo registers. We can't use match_scratch
3218 ;; as this requires two registers in the class R1_REGS when the MEMs for
3219 ;; operands 0 and 1 are both equivalent to symbolic MEMs. Thus, we are
3220 ;; forced to internally copy operands 0 and 1 to operands 7 and 8,
3221 ;; respectively. We then split or peephole optimize after reload.
3222 (define_insn "movmemsi_prereload"
3223 [(set (mem:BLK (match_operand:SI 0 "register_operand" "r,r"))
3224 (mem:BLK (match_operand:SI 1 "register_operand" "r,r")))
3225 (clobber (match_operand:SI 2 "register_operand" "=&r,&r")) ;loop cnt/tmp
3226 (clobber (match_operand:SI 3 "register_operand" "=&r,&r")) ;item tmp1
3227 (clobber (match_operand:SI 6 "register_operand" "=&r,&r")) ;item tmp2
3228 (clobber (match_operand:SI 7 "register_operand" "=&r,&r")) ;item tmp3
3229 (clobber (match_operand:SI 8 "register_operand" "=&r,&r")) ;item tmp4
3230 (use (match_operand:SI 4 "arith14_operand" "J,2")) ;byte count
3231 (use (match_operand:SI 5 "const_int_operand" "n,n"))] ;alignment
3232 "!TARGET_64BIT"
3233 "#"
3234 [(set_attr "type" "multi,multi")])
3235
3236 (define_split
3237 [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3238 (match_operand:BLK 1 "memory_operand" ""))
3239 (clobber (match_operand:SI 2 "register_operand" ""))
3240 (clobber (match_operand:SI 3 "register_operand" ""))
3241 (clobber (match_operand:SI 6 "register_operand" ""))
3242 (clobber (match_operand:SI 7 "register_operand" ""))
3243 (clobber (match_operand:SI 8 "register_operand" ""))
3244 (use (match_operand:SI 4 "arith14_operand" ""))
3245 (use (match_operand:SI 5 "const_int_operand" ""))])]
3246 "!TARGET_64BIT && reload_completed && !flag_peephole2
3247 && GET_CODE (operands[0]) == MEM
3248 && register_operand (XEXP (operands[0], 0), SImode)
3249 && GET_CODE (operands[1]) == MEM
3250 && register_operand (XEXP (operands[1], 0), SImode)"
3251 [(set (match_dup 7) (match_dup 9))
3252 (set (match_dup 8) (match_dup 10))
3253 (parallel [(set (match_dup 0) (match_dup 1))
3254 (clobber (match_dup 2))
3255 (clobber (match_dup 3))
3256 (clobber (match_dup 6))
3257 (clobber (match_dup 7))
3258 (clobber (match_dup 8))
3259 (use (match_dup 4))
3260 (use (match_dup 5))
3261 (const_int 0)])]
3262 "
3263 {
3264 operands[9] = XEXP (operands[0], 0);
3265 operands[10] = XEXP (operands[1], 0);
3266 operands[0] = replace_equiv_address (operands[0], operands[7]);
3267 operands[1] = replace_equiv_address (operands[1], operands[8]);
3268 }")
3269
3270 (define_peephole2
3271 [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3272 (match_operand:BLK 1 "memory_operand" ""))
3273 (clobber (match_operand:SI 2 "register_operand" ""))
3274 (clobber (match_operand:SI 3 "register_operand" ""))
3275 (clobber (match_operand:SI 6 "register_operand" ""))
3276 (clobber (match_operand:SI 7 "register_operand" ""))
3277 (clobber (match_operand:SI 8 "register_operand" ""))
3278 (use (match_operand:SI 4 "arith14_operand" ""))
3279 (use (match_operand:SI 5 "const_int_operand" ""))])]
3280 "!TARGET_64BIT
3281 && GET_CODE (operands[0]) == MEM
3282 && register_operand (XEXP (operands[0], 0), SImode)
3283 && GET_CODE (operands[1]) == MEM
3284 && register_operand (XEXP (operands[1], 0), SImode)"
3285 [(parallel [(set (match_dup 0) (match_dup 1))
3286 (clobber (match_dup 2))
3287 (clobber (match_dup 3))
3288 (clobber (match_dup 6))
3289 (clobber (match_dup 7))
3290 (clobber (match_dup 8))
3291 (use (match_dup 4))
3292 (use (match_dup 5))
3293 (const_int 0)])]
3294 "
3295 {
3296 rtx addr = XEXP (operands[0], 0);
3297 if (dead_or_set_p (curr_insn, addr))
3298 operands[7] = addr;
3299 else
3300 {
3301 emit_insn (gen_rtx_SET (operands[7], addr));
3302 operands[0] = replace_equiv_address (operands[0], operands[7]);
3303 }
3304
3305 addr = XEXP (operands[1], 0);
3306 if (dead_or_set_p (curr_insn, addr))
3307 operands[8] = addr;
3308 else
3309 {
3310 emit_insn (gen_rtx_SET (operands[8], addr));
3311 operands[1] = replace_equiv_address (operands[1], operands[8]);
3312 }
3313 }")
3314
3315 (define_insn "movmemsi_postreload"
3316 [(set (mem:BLK (match_operand:SI 0 "register_operand" "+r,r"))
3317 (mem:BLK (match_operand:SI 1 "register_operand" "+r,r")))
3318 (clobber (match_operand:SI 2 "register_operand" "=&r,&r")) ;loop cnt/tmp
3319 (clobber (match_operand:SI 3 "register_operand" "=&r,&r")) ;item tmp1
3320 (clobber (match_operand:SI 6 "register_operand" "=&r,&r")) ;item tmp2
3321 (clobber (match_dup 0))
3322 (clobber (match_dup 1))
3323 (use (match_operand:SI 4 "arith14_operand" "J,2")) ;byte count
3324 (use (match_operand:SI 5 "const_int_operand" "n,n")) ;alignment
3325 (const_int 0)]
3326 "!TARGET_64BIT && reload_completed"
3327 "* return pa_output_block_move (operands, !which_alternative);"
3328 [(set_attr "type" "multi,multi")])
3329
3330 (define_expand "movmemdi"
3331 [(parallel [(set (match_operand:BLK 0 "" "")
3332 (match_operand:BLK 1 "" ""))
3333 (clobber (match_dup 4))
3334 (clobber (match_dup 5))
3335 (clobber (match_dup 6))
3336 (clobber (match_dup 7))
3337 (clobber (match_dup 8))
3338 (use (match_operand:DI 2 "arith14_operand" ""))
3339 (use (match_operand:DI 3 "const_int_operand" ""))])]
3340 "TARGET_64BIT && optimize > 0"
3341 "
3342 {
3343 int size, align;
3344
3345 /* HP provides very fast block move library routine for the PA;
3346 this routine includes:
3347
3348 4x4 byte at a time block moves,
3349 1x4 byte at a time with alignment checked at runtime with
3350 attempts to align the source and destination as needed
3351 1x1 byte loop
3352
3353 With that in mind, here's the heuristics to try and guess when
3354 the inlined block move will be better than the library block
3355 move:
3356
3357 If the size isn't constant, then always use the library routines.
3358
3359 If the size is large in respect to the known alignment, then use
3360 the library routines.
3361
3362 If the size is small in respect to the known alignment, then open
3363 code the copy (since that will lead to better scheduling).
3364
3365 Else use the block move pattern. */
3366
3367 /* Undetermined size, use the library routine. */
3368 if (GET_CODE (operands[2]) != CONST_INT)
3369 FAIL;
3370
3371 size = INTVAL (operands[2]);
3372 align = INTVAL (operands[3]);
3373 align = align > 8 ? 8 : (align ? align : 1);
3374
3375 /* If size/alignment is large, then use the library routines. */
3376 if (size / align > 16)
3377 FAIL;
3378
3379 /* This does happen, but not often enough to worry much about. */
3380 if (size / align < MOVE_RATIO (optimize_insn_for_speed_p ()))
3381 FAIL;
3382
3383 /* Fall through means we're going to use our block move pattern. */
3384 operands[0]
3385 = replace_equiv_address (operands[0],
3386 copy_to_mode_reg (DImode, XEXP (operands[0], 0)));
3387 operands[1]
3388 = replace_equiv_address (operands[1],
3389 copy_to_mode_reg (DImode, XEXP (operands[1], 0)));
3390 operands[4] = gen_reg_rtx (DImode);
3391 operands[5] = gen_reg_rtx (DImode);
3392 operands[6] = gen_reg_rtx (DImode);
3393 operands[7] = gen_reg_rtx (DImode);
3394 operands[8] = gen_reg_rtx (DImode);
3395 }")
3396
3397 ;; The operand constraints are written like this to support both compile-time
3398 ;; and run-time determined byte counts. The expander and pa_output_block_move
3399 ;; only support compile-time determined counts at this time.
3400 ;;
3401 ;; If the count is run-time determined, the register with the byte count
3402 ;; is clobbered by the copying code, and therefore it is forced to operand 2.
3403 ;;
3404 ;; We used to clobber operands 0 and 1. However, a change to regrename.c
3405 ;; broke this semantic for pseudo registers. We can't use match_scratch
3406 ;; as this requires two registers in the class R1_REGS when the MEMs for
3407 ;; operands 0 and 1 are both equivalent to symbolic MEMs. Thus, we are
3408 ;; forced to internally copy operands 0 and 1 to operands 7 and 8,
3409 ;; respectively. We then split or peephole optimize after reload.
3410 (define_insn "movmemdi_prereload"
3411 [(set (mem:BLK (match_operand:DI 0 "register_operand" "r,r"))
3412 (mem:BLK (match_operand:DI 1 "register_operand" "r,r")))
3413 (clobber (match_operand:DI 2 "register_operand" "=&r,&r")) ;loop cnt/tmp
3414 (clobber (match_operand:DI 3 "register_operand" "=&r,&r")) ;item tmp1
3415 (clobber (match_operand:DI 6 "register_operand" "=&r,&r")) ;item tmp2
3416 (clobber (match_operand:DI 7 "register_operand" "=&r,&r")) ;item tmp3
3417 (clobber (match_operand:DI 8 "register_operand" "=&r,&r")) ;item tmp4
3418 (use (match_operand:DI 4 "arith14_operand" "J,2")) ;byte count
3419 (use (match_operand:DI 5 "const_int_operand" "n,n"))] ;alignment
3420 "TARGET_64BIT"
3421 "#"
3422 [(set_attr "type" "multi,multi")])
3423
3424 (define_split
3425 [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3426 (match_operand:BLK 1 "memory_operand" ""))
3427 (clobber (match_operand:DI 2 "register_operand" ""))
3428 (clobber (match_operand:DI 3 "register_operand" ""))
3429 (clobber (match_operand:DI 6 "register_operand" ""))
3430 (clobber (match_operand:DI 7 "register_operand" ""))
3431 (clobber (match_operand:DI 8 "register_operand" ""))
3432 (use (match_operand:DI 4 "arith14_operand" ""))
3433 (use (match_operand:DI 5 "const_int_operand" ""))])]
3434 "TARGET_64BIT && reload_completed && !flag_peephole2
3435 && GET_CODE (operands[0]) == MEM
3436 && register_operand (XEXP (operands[0], 0), DImode)
3437 && GET_CODE (operands[1]) == MEM
3438 && register_operand (XEXP (operands[1], 0), DImode)"
3439 [(set (match_dup 7) (match_dup 9))
3440 (set (match_dup 8) (match_dup 10))
3441 (parallel [(set (match_dup 0) (match_dup 1))
3442 (clobber (match_dup 2))
3443 (clobber (match_dup 3))
3444 (clobber (match_dup 6))
3445 (clobber (match_dup 7))
3446 (clobber (match_dup 8))
3447 (use (match_dup 4))
3448 (use (match_dup 5))
3449 (const_int 0)])]
3450 "
3451 {
3452 operands[9] = XEXP (operands[0], 0);
3453 operands[10] = XEXP (operands[1], 0);
3454 operands[0] = replace_equiv_address (operands[0], operands[7]);
3455 operands[1] = replace_equiv_address (operands[1], operands[8]);
3456 }")
3457
3458 (define_peephole2
3459 [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3460 (match_operand:BLK 1 "memory_operand" ""))
3461 (clobber (match_operand:DI 2 "register_operand" ""))
3462 (clobber (match_operand:DI 3 "register_operand" ""))
3463 (clobber (match_operand:DI 6 "register_operand" ""))
3464 (clobber (match_operand:DI 7 "register_operand" ""))
3465 (clobber (match_operand:DI 8 "register_operand" ""))
3466 (use (match_operand:DI 4 "arith14_operand" ""))
3467 (use (match_operand:DI 5 "const_int_operand" ""))])]
3468 "TARGET_64BIT
3469 && GET_CODE (operands[0]) == MEM
3470 && register_operand (XEXP (operands[0], 0), DImode)
3471 && GET_CODE (operands[1]) == MEM
3472 && register_operand (XEXP (operands[1], 0), DImode)"
3473 [(parallel [(set (match_dup 0) (match_dup 1))
3474 (clobber (match_dup 2))
3475 (clobber (match_dup 3))
3476 (clobber (match_dup 6))
3477 (clobber (match_dup 7))
3478 (clobber (match_dup 8))
3479 (use (match_dup 4))
3480 (use (match_dup 5))
3481 (const_int 0)])]
3482 "
3483 {
3484 rtx addr = XEXP (operands[0], 0);
3485 if (dead_or_set_p (curr_insn, addr))
3486 operands[7] = addr;
3487 else
3488 {
3489 emit_insn (gen_rtx_SET (operands[7], addr));
3490 operands[0] = replace_equiv_address (operands[0], operands[7]);
3491 }
3492
3493 addr = XEXP (operands[1], 0);
3494 if (dead_or_set_p (curr_insn, addr))
3495 operands[8] = addr;
3496 else
3497 {
3498 emit_insn (gen_rtx_SET (operands[8], addr));
3499 operands[1] = replace_equiv_address (operands[1], operands[8]);
3500 }
3501 }")
3502
3503 (define_insn "movmemdi_postreload"
3504 [(set (mem:BLK (match_operand:DI 0 "register_operand" "+r,r"))
3505 (mem:BLK (match_operand:DI 1 "register_operand" "+r,r")))
3506 (clobber (match_operand:DI 2 "register_operand" "=&r,&r")) ;loop cnt/tmp
3507 (clobber (match_operand:DI 3 "register_operand" "=&r,&r")) ;item tmp1
3508 (clobber (match_operand:DI 6 "register_operand" "=&r,&r")) ;item tmp2
3509 (clobber (match_dup 0))
3510 (clobber (match_dup 1))
3511 (use (match_operand:DI 4 "arith14_operand" "J,2")) ;byte count
3512 (use (match_operand:DI 5 "const_int_operand" "n,n")) ;alignment
3513 (const_int 0)]
3514 "TARGET_64BIT && reload_completed"
3515 "* return pa_output_block_move (operands, !which_alternative);"
3516 [(set_attr "type" "multi,multi")])
3517
3518 (define_expand "setmemsi"
3519 [(parallel [(set (match_operand:BLK 0 "" "")
3520 (match_operand 2 "const_int_operand" ""))
3521 (clobber (match_dup 4))
3522 (clobber (match_dup 5))
3523 (use (match_operand:SI 1 "arith14_operand" ""))
3524 (use (match_operand:SI 3 "const_int_operand" ""))])]
3525 "!TARGET_64BIT && optimize > 0"
3526 "
3527 {
3528 int size, align;
3529
3530 /* If value to set is not zero, use the library routine. */
3531 if (operands[2] != const0_rtx)
3532 FAIL;
3533
3534 /* Undetermined size, use the library routine. */
3535 if (GET_CODE (operands[1]) != CONST_INT)
3536 FAIL;
3537
3538 size = INTVAL (operands[1]);
3539 align = INTVAL (operands[3]);
3540 align = align > 4 ? 4 : align;
3541
3542 /* If size/alignment is large, then use the library routines. */
3543 if (size / align > 16)
3544 FAIL;
3545
3546 /* This does happen, but not often enough to worry much about. */
3547 if (size / align < MOVE_RATIO (optimize_insn_for_speed_p ()))
3548 FAIL;
3549
3550 /* Fall through means we're going to use our block clear pattern. */
3551 operands[0]
3552 = replace_equiv_address (operands[0],
3553 copy_to_mode_reg (SImode, XEXP (operands[0], 0)));
3554 operands[4] = gen_reg_rtx (SImode);
3555 operands[5] = gen_reg_rtx (SImode);
3556 }")
3557
3558 (define_insn "clrmemsi_prereload"
3559 [(set (mem:BLK (match_operand:SI 0 "register_operand" "r,r"))
3560 (const_int 0))
3561 (clobber (match_operand:SI 1 "register_operand" "=&r,&r")) ;loop cnt/tmp
3562 (clobber (match_operand:SI 4 "register_operand" "=&r,&r")) ;tmp1
3563 (use (match_operand:SI 2 "arith14_operand" "J,1")) ;byte count
3564 (use (match_operand:SI 3 "const_int_operand" "n,n"))] ;alignment
3565 "!TARGET_64BIT"
3566 "#"
3567 [(set_attr "type" "multi,multi")])
3568
3569 (define_split
3570 [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3571 (const_int 0))
3572 (clobber (match_operand:SI 1 "register_operand" ""))
3573 (clobber (match_operand:SI 4 "register_operand" ""))
3574 (use (match_operand:SI 2 "arith14_operand" ""))
3575 (use (match_operand:SI 3 "const_int_operand" ""))])]
3576 "!TARGET_64BIT && reload_completed && !flag_peephole2
3577 && GET_CODE (operands[0]) == MEM
3578 && register_operand (XEXP (operands[0], 0), SImode)"
3579 [(set (match_dup 4) (match_dup 5))
3580 (parallel [(set (match_dup 0) (const_int 0))
3581 (clobber (match_dup 1))
3582 (clobber (match_dup 4))
3583 (use (match_dup 2))
3584 (use (match_dup 3))
3585 (const_int 0)])]
3586 "
3587 {
3588 operands[5] = XEXP (operands[0], 0);
3589 operands[0] = replace_equiv_address (operands[0], operands[4]);
3590 }")
3591
3592 (define_peephole2
3593 [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3594 (const_int 0))
3595 (clobber (match_operand:SI 1 "register_operand" ""))
3596 (clobber (match_operand:SI 4 "register_operand" ""))
3597 (use (match_operand:SI 2 "arith14_operand" ""))
3598 (use (match_operand:SI 3 "const_int_operand" ""))])]
3599 "!TARGET_64BIT
3600 && GET_CODE (operands[0]) == MEM
3601 && register_operand (XEXP (operands[0], 0), SImode)"
3602 [(parallel [(set (match_dup 0) (const_int 0))
3603 (clobber (match_dup 1))
3604 (clobber (match_dup 4))
3605 (use (match_dup 2))
3606 (use (match_dup 3))
3607 (const_int 0)])]
3608 "
3609 {
3610 rtx addr = XEXP (operands[0], 0);
3611 if (dead_or_set_p (curr_insn, addr))
3612 operands[4] = addr;
3613 else
3614 {
3615 emit_insn (gen_rtx_SET (operands[4], addr));
3616 operands[0] = replace_equiv_address (operands[0], operands[4]);
3617 }
3618 }")
3619
3620 (define_insn "clrmemsi_postreload"
3621 [(set (mem:BLK (match_operand:SI 0 "register_operand" "+r,r"))
3622 (const_int 0))
3623 (clobber (match_operand:SI 1 "register_operand" "=&r,&r")) ;loop cnt/tmp
3624 (clobber (match_dup 0))
3625 (use (match_operand:SI 2 "arith14_operand" "J,1")) ;byte count
3626 (use (match_operand:SI 3 "const_int_operand" "n,n")) ;alignment
3627 (const_int 0)]
3628 "!TARGET_64BIT && reload_completed"
3629 "* return pa_output_block_clear (operands, !which_alternative);"
3630 [(set_attr "type" "multi,multi")])
3631
3632 (define_expand "setmemdi"
3633 [(parallel [(set (match_operand:BLK 0 "" "")
3634 (match_operand 2 "const_int_operand" ""))
3635 (clobber (match_dup 4))
3636 (clobber (match_dup 5))
3637 (use (match_operand:DI 1 "arith14_operand" ""))
3638 (use (match_operand:DI 3 "const_int_operand" ""))])]
3639 "TARGET_64BIT && optimize > 0"
3640 "
3641 {
3642 int size, align;
3643
3644 /* If value to set is not zero, use the library routine. */
3645 if (operands[2] != const0_rtx)
3646 FAIL;
3647
3648 /* Undetermined size, use the library routine. */
3649 if (GET_CODE (operands[1]) != CONST_INT)
3650 FAIL;
3651
3652 size = INTVAL (operands[1]);
3653 align = INTVAL (operands[3]);
3654 align = align > 8 ? 8 : align;
3655
3656 /* If size/alignment is large, then use the library routines. */
3657 if (size / align > 16)
3658 FAIL;
3659
3660 /* This does happen, but not often enough to worry much about. */
3661 if (size / align < MOVE_RATIO (optimize_insn_for_speed_p ()))
3662 FAIL;
3663
3664 /* Fall through means we're going to use our block clear pattern. */
3665 operands[0]
3666 = replace_equiv_address (operands[0],
3667 copy_to_mode_reg (DImode, XEXP (operands[0], 0)));
3668 operands[4] = gen_reg_rtx (DImode);
3669 operands[5] = gen_reg_rtx (DImode);
3670 }")
3671
3672 (define_insn "clrmemdi_prereload"
3673 [(set (mem:BLK (match_operand:DI 0 "register_operand" "r,r"))
3674 (const_int 0))
3675 (clobber (match_operand:DI 1 "register_operand" "=&r,&r")) ;loop cnt/tmp
3676 (clobber (match_operand:DI 4 "register_operand" "=&r,&r")) ;item tmp1
3677 (use (match_operand:DI 2 "arith14_operand" "J,1")) ;byte count
3678 (use (match_operand:DI 3 "const_int_operand" "n,n"))] ;alignment
3679 "TARGET_64BIT"
3680 "#"
3681 [(set_attr "type" "multi,multi")])
3682
3683 (define_split
3684 [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3685 (const_int 0))
3686 (clobber (match_operand:DI 1 "register_operand" ""))
3687 (clobber (match_operand:DI 4 "register_operand" ""))
3688 (use (match_operand:DI 2 "arith14_operand" ""))
3689 (use (match_operand:DI 3 "const_int_operand" ""))])]
3690 "TARGET_64BIT && reload_completed && !flag_peephole2
3691 && GET_CODE (operands[0]) == MEM
3692 && register_operand (XEXP (operands[0], 0), DImode)"
3693 [(set (match_dup 4) (match_dup 5))
3694 (parallel [(set (match_dup 0) (const_int 0))
3695 (clobber (match_dup 1))
3696 (clobber (match_dup 4))
3697 (use (match_dup 2))
3698 (use (match_dup 3))
3699 (const_int 0)])]
3700 "
3701 {
3702 operands[5] = XEXP (operands[0], 0);
3703 operands[0] = replace_equiv_address (operands[0], operands[4]);
3704 }")
3705
3706 (define_peephole2
3707 [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3708 (const_int 0))
3709 (clobber (match_operand:DI 1 "register_operand" ""))
3710 (clobber (match_operand:DI 4 "register_operand" ""))
3711 (use (match_operand:DI 2 "arith14_operand" ""))
3712 (use (match_operand:DI 3 "const_int_operand" ""))])]
3713 "TARGET_64BIT
3714 && GET_CODE (operands[0]) == MEM
3715 && register_operand (XEXP (operands[0], 0), DImode)"
3716 [(parallel [(set (match_dup 0) (const_int 0))
3717 (clobber (match_dup 1))
3718 (clobber (match_dup 4))
3719 (use (match_dup 2))
3720 (use (match_dup 3))
3721 (const_int 0)])]
3722 "
3723 {
3724 rtx addr = XEXP (operands[0], 0);
3725 if (dead_or_set_p (curr_insn, addr))
3726 operands[4] = addr;
3727 else
3728 {
3729 emit_insn (gen_rtx_SET (operands[4], addr));
3730 operands[0] = replace_equiv_address (operands[0], operands[4]);
3731 }
3732 }")
3733
3734 (define_insn "clrmemdi_postreload"
3735 [(set (mem:BLK (match_operand:DI 0 "register_operand" "+r,r"))
3736 (const_int 0))
3737 (clobber (match_operand:DI 1 "register_operand" "=&r,&r")) ;loop cnt/tmp
3738 (clobber (match_dup 0))
3739 (use (match_operand:DI 2 "arith14_operand" "J,1")) ;byte count
3740 (use (match_operand:DI 3 "const_int_operand" "n,n")) ;alignment
3741 (const_int 0)]
3742 "TARGET_64BIT && reload_completed"
3743 "* return pa_output_block_clear (operands, !which_alternative);"
3744 [(set_attr "type" "multi,multi")])
3745 \f
3746 ;; Floating point move insns
3747
3748 (define_expand "movdf"
3749 [(set (match_operand:DF 0 "general_operand" "")
3750 (match_operand:DF 1 "general_operand" ""))]
3751 ""
3752 "
3753 {
3754 if (pa_emit_move_sequence (operands, DFmode, 0))
3755 DONE;
3756 }")
3757
3758 ;; Handle DFmode input reloads requiring %r1 as a scratch register.
3759 (define_expand "reload_indf_r1"
3760 [(set (match_operand:DF 0 "register_operand" "=Z")
3761 (match_operand:DF 1 "non_hard_reg_operand" ""))
3762 (clobber (match_operand:SI 2 "register_operand" "=&a"))]
3763 ""
3764 "
3765 {
3766 if (pa_emit_move_sequence (operands, DFmode, operands[2]))
3767 DONE;
3768
3769 /* We don't want the clobber emitted, so handle this ourselves. */
3770 emit_insn (gen_rtx_SET (operands[0], operands[1]));
3771 DONE;
3772 }")
3773
3774 ;; Handle DFmode input reloads requiring a general register as a
3775 ;; scratch register.
3776 (define_expand "reload_indf"
3777 [(set (match_operand:DF 0 "register_operand" "=Z")
3778 (match_operand:DF 1 "non_hard_reg_operand" ""))
3779 (clobber (match_operand:DF 2 "register_operand" "=&r"))]
3780 ""
3781 "
3782 {
3783 if (pa_emit_move_sequence (operands, DFmode, operands[2]))
3784 DONE;
3785
3786 /* We don't want the clobber emitted, so handle this ourselves. */
3787 emit_insn (gen_rtx_SET (operands[0], operands[1]));
3788 DONE;
3789 }")
3790
3791 ;; Handle DFmode output reloads requiring a general register as a
3792 ;; scratch register.
3793 (define_expand "reload_outdf"
3794 [(set (match_operand:DF 0 "non_hard_reg_operand" "")
3795 (match_operand:DF 1 "register_operand" "Z"))
3796 (clobber (match_operand:DF 2 "register_operand" "=&r"))]
3797 ""
3798 "
3799 {
3800 if (pa_emit_move_sequence (operands, DFmode, operands[2]))
3801 DONE;
3802
3803 /* We don't want the clobber emitted, so handle this ourselves. */
3804 emit_insn (gen_rtx_SET (operands[0], operands[1]));
3805 DONE;
3806 }")
3807
3808 (define_insn ""
3809 [(set (match_operand:DF 0 "move_dest_operand"
3810 "=f,*r,T,?o,?Q,f,*r,*r,?*r,?f")
3811 (match_operand:DF 1 "reg_or_0_or_nonsymb_mem_operand"
3812 "fG,*rG,f,*r,*r,RT,o,RQ,f,*r"))]
3813 "(register_operand (operands[0], DFmode)
3814 || reg_or_0_operand (operands[1], DFmode))
3815 && !(GET_CODE (operands[1]) == CONST_DOUBLE
3816 && GET_CODE (operands[0]) == MEM)
3817 && !TARGET_64BIT
3818 && !TARGET_SOFT_FLOAT"
3819 "*
3820 {
3821 if ((FP_REG_P (operands[0]) || FP_REG_P (operands[1])
3822 || operands[1] == CONST0_RTX (DFmode))
3823 && !(REG_P (operands[0]) && REG_P (operands[1])
3824 && FP_REG_P (operands[0]) ^ FP_REG_P (operands[1])))
3825 return pa_output_fp_move_double (operands);
3826 return pa_output_move_double (operands);
3827 }"
3828 [(set_attr "type" "fpalu,move,fpstore,store,store,fpload,load,load,fpstore_load,store_fpload")
3829 (set_attr "length" "4,8,4,8,16,4,8,16,12,12")])
3830
3831 (define_insn ""
3832 [(set (match_operand:DF 0 "indexed_memory_operand" "=R")
3833 (match_operand:DF 1 "reg_or_0_operand" "f"))]
3834 "!TARGET_SOFT_FLOAT
3835 && !TARGET_DISABLE_INDEXING
3836 && reload_completed"
3837 "fstd%F0 %1,%0"
3838 [(set_attr "type" "fpstore")
3839 (set_attr "pa_combine_type" "addmove")
3840 (set_attr "length" "4")])
3841
3842 (define_peephole2
3843 [(set (match_operand:SI 0 "register_operand" "")
3844 (plus:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
3845 (const_int 3))
3846 (match_operand:SI 2 "register_operand" "")))
3847 (set (mem:DF (match_dup 0))
3848 (match_operand:DF 3 "register_operand" ""))]
3849 "!TARGET_SOFT_FLOAT
3850 && !TARGET_DISABLE_INDEXING
3851 && REG_OK_FOR_BASE_P (operands[2])
3852 && FP_REGNO_P (REGNO (operands[3]))"
3853 [(set (mem:DF (plus:SI (mult:SI (match_dup 1) (const_int 8)) (match_dup 2)))
3854 (match_dup 3))
3855 (set (match_dup 0) (plus:SI (ashift:SI (match_dup 1) (const_int 3))
3856 (match_dup 2)))]
3857 "")
3858
3859 (define_peephole2
3860 [(set (match_operand:SI 0 "register_operand" "")
3861 (plus:SI (match_operand:SI 2 "register_operand" "")
3862 (ashift:SI (match_operand:SI 1 "register_operand" "")
3863 (const_int 3))))
3864 (set (mem:DF (match_dup 0))
3865 (match_operand:DF 3 "register_operand" ""))]
3866 "!TARGET_SOFT_FLOAT
3867 && !TARGET_DISABLE_INDEXING
3868 && REG_OK_FOR_BASE_P (operands[2])
3869 && FP_REGNO_P (REGNO (operands[3]))"
3870 [(set (mem:DF (plus:SI (mult:SI (match_dup 1) (const_int 8)) (match_dup 2)))
3871 (match_dup 3))
3872 (set (match_dup 0) (plus:SI (ashift:SI (match_dup 1) (const_int 3))
3873 (match_dup 2)))]
3874 "")
3875
3876 (define_peephole2
3877 [(set (match_operand:DI 0 "register_operand" "")
3878 (plus:DI (ashift:DI (match_operand:DI 1 "register_operand" "")
3879 (const_int 3))
3880 (match_operand:DI 2 "register_operand" "")))
3881 (set (mem:DF (match_dup 0))
3882 (match_operand:DF 3 "register_operand" ""))]
3883 "!TARGET_SOFT_FLOAT
3884 && !TARGET_DISABLE_INDEXING
3885 && TARGET_64BIT
3886 && REG_OK_FOR_BASE_P (operands[2])
3887 && FP_REGNO_P (REGNO (operands[3]))"
3888 [(set (mem:DF (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
3889 (match_dup 3))
3890 (set (match_dup 0) (plus:DI (ashift:DI (match_dup 1) (const_int 3))
3891 (match_dup 2)))]
3892 "")
3893
3894 (define_peephole2
3895 [(set (match_operand:DI 0 "register_operand" "")
3896 (plus:DI (match_operand:DI 2 "register_operand" "")
3897 (ashift:DI (match_operand:DI 1 "register_operand" "")
3898 (const_int 3))))
3899 (set (mem:DF (match_dup 0))
3900 (match_operand:DF 3 "register_operand" ""))]
3901 "!TARGET_SOFT_FLOAT
3902 && !TARGET_DISABLE_INDEXING
3903 && TARGET_64BIT
3904 && REG_OK_FOR_BASE_P (operands[2])
3905 && FP_REGNO_P (REGNO (operands[3]))"
3906 [(set (mem:DF (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
3907 (match_dup 3))
3908 (set (match_dup 0) (plus:DI (ashift:DI (match_dup 1) (const_int 3))
3909 (match_dup 2)))]
3910 "")
3911
3912 (define_peephole2
3913 [(set (match_operand:SI 0 "register_operand" "")
3914 (plus:SI (match_operand:SI 1 "register_operand" "")
3915 (match_operand:SI 2 "register_operand" "")))
3916 (set (mem:DF (match_dup 0))
3917 (match_operand:DF 3 "register_operand" ""))]
3918 "!TARGET_SOFT_FLOAT
3919 && !TARGET_DISABLE_INDEXING
3920 && TARGET_NO_SPACE_REGS
3921 && REG_OK_FOR_INDEX_P (operands[1])
3922 && REG_OK_FOR_BASE_P (operands[2])
3923 && FP_REGNO_P (REGNO (operands[3]))"
3924 [(set (mem:DF (plus:SI (match_dup 1) (match_dup 2)))
3925 (match_dup 3))
3926 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
3927 "")
3928
3929 (define_peephole2
3930 [(set (match_operand:SI 0 "register_operand" "")
3931 (plus:SI (match_operand:SI 1 "register_operand" "")
3932 (match_operand:SI 2 "register_operand" "")))
3933 (set (mem:DF (match_dup 0))
3934 (match_operand:DF 3 "register_operand" ""))]
3935 "!TARGET_SOFT_FLOAT
3936 && !TARGET_DISABLE_INDEXING
3937 && TARGET_NO_SPACE_REGS
3938 && REG_OK_FOR_BASE_P (operands[1])
3939 && REG_OK_FOR_INDEX_P (operands[2])
3940 && FP_REGNO_P (REGNO (operands[3]))"
3941 [(set (mem:DF (plus:SI (match_dup 2) (match_dup 1)))
3942 (match_dup 3))
3943 (set (match_dup 0) (plus:SI (match_dup 2) (match_dup 1)))]
3944 "")
3945
3946 (define_peephole2
3947 [(set (match_operand:DI 0 "register_operand" "")
3948 (plus:DI (match_operand:DI 1 "register_operand" "")
3949 (match_operand:DI 2 "register_operand" "")))
3950 (set (mem:DF (match_dup 0))
3951 (match_operand:DF 3 "register_operand" ""))]
3952 "!TARGET_SOFT_FLOAT
3953 && !TARGET_DISABLE_INDEXING
3954 && TARGET_64BIT
3955 && TARGET_NO_SPACE_REGS
3956 && REG_OK_FOR_INDEX_P (operands[1])
3957 && REG_OK_FOR_BASE_P (operands[2])
3958 && FP_REGNO_P (REGNO (operands[3]))"
3959 [(set (mem:DF (plus:DI (match_dup 1) (match_dup 2)))
3960 (match_dup 3))
3961 (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
3962 "")
3963
3964 (define_peephole2
3965 [(set (match_operand:DI 0 "register_operand" "")
3966 (plus:DI (match_operand:DI 1 "register_operand" "")
3967 (match_operand:DI 2 "register_operand" "")))
3968 (set (mem:DF (match_dup 0))
3969 (match_operand:DF 3 "register_operand" ""))]
3970 "!TARGET_SOFT_FLOAT
3971 && !TARGET_DISABLE_INDEXING
3972 && TARGET_64BIT
3973 && TARGET_NO_SPACE_REGS
3974 && REG_OK_FOR_BASE_P (operands[1])
3975 && REG_OK_FOR_INDEX_P (operands[2])
3976 && FP_REGNO_P (REGNO (operands[3]))"
3977 [(set (mem:DF (plus:DI (match_dup 2) (match_dup 1)))
3978 (match_dup 3))
3979 (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
3980 "")
3981
3982 (define_insn ""
3983 [(set (match_operand:DF 0 "move_dest_operand"
3984 "=r,?o,?Q,r,r")
3985 (match_operand:DF 1 "reg_or_0_or_nonsymb_mem_operand"
3986 "rG,r,r,o,RQ"))]
3987 "(register_operand (operands[0], DFmode)
3988 || reg_or_0_operand (operands[1], DFmode))
3989 && !TARGET_64BIT
3990 && TARGET_SOFT_FLOAT"
3991 "*
3992 {
3993 return pa_output_move_double (operands);
3994 }"
3995 [(set_attr "type" "move,store,store,load,load")
3996 (set_attr "length" "8,8,16,8,16")])
3997
3998 (define_insn ""
3999 [(set (match_operand:DF 0 "move_dest_operand"
4000 "=!*r,*r,*r,*r,*r,Q,f,f,T")
4001 (match_operand:DF 1 "move_src_operand"
4002 "!*r,J,N,K,RQ,*rG,fG,RT,f"))]
4003 "(register_operand (operands[0], DFmode)
4004 || reg_or_0_operand (operands[1], DFmode))
4005 && !TARGET_SOFT_FLOAT && TARGET_64BIT"
4006 "@
4007 copy %1,%0
4008 ldi %1,%0
4009 ldil L'%1,%0
4010 depdi,z %z1,%0
4011 ldd%M1 %1,%0
4012 std%M0 %r1,%0
4013 fcpy,dbl %f1,%0
4014 fldd%F1 %1,%0
4015 fstd%F0 %1,%0"
4016 [(set_attr "type" "move,move,move,shift,load,store,fpalu,fpload,fpstore")
4017 (set_attr "pa_combine_type" "addmove")
4018 (set_attr "length" "4,4,4,4,4,4,4,4,4")])
4019
4020 \f
4021 (define_expand "movdi"
4022 [(set (match_operand:DI 0 "general_operand" "")
4023 (match_operand:DI 1 "general_operand" ""))]
4024 ""
4025 "
4026 {
4027 if (pa_emit_move_sequence (operands, DImode, 0))
4028 DONE;
4029 }")
4030
4031 ;; Handle DImode input reloads requiring %r1 as a scratch register.
4032 (define_expand "reload_indi_r1"
4033 [(set (match_operand:DI 0 "register_operand" "=Z")
4034 (match_operand:DI 1 "non_hard_reg_operand" ""))
4035 (clobber (match_operand:SI 2 "register_operand" "=&a"))]
4036 ""
4037 "
4038 {
4039 if (pa_emit_move_sequence (operands, DImode, operands[2]))
4040 DONE;
4041
4042 /* We don't want the clobber emitted, so handle this ourselves. */
4043 emit_insn (gen_rtx_SET (operands[0], operands[1]));
4044 DONE;
4045 }")
4046
4047 ;; Handle DImode input reloads requiring a general register as a
4048 ;; scratch register.
4049 (define_expand "reload_indi"
4050 [(set (match_operand:DI 0 "register_operand" "=Z")
4051 (match_operand:DI 1 "non_hard_reg_operand" ""))
4052 (clobber (match_operand:SI 2 "register_operand" "=&r"))]
4053 ""
4054 "
4055 {
4056 if (pa_emit_move_sequence (operands, DImode, operands[2]))
4057 DONE;
4058
4059 /* We don't want the clobber emitted, so handle this ourselves. */
4060 emit_insn (gen_rtx_SET (operands[0], operands[1]));
4061 DONE;
4062 }")
4063
4064 ;; Handle DImode output reloads requiring a general register as a
4065 ;; scratch register.
4066 (define_expand "reload_outdi"
4067 [(set (match_operand:DI 0 "non_hard_reg_operand" "")
4068 (match_operand:DI 1 "register_operand" "Z"))
4069 (clobber (match_operand:SI 2 "register_operand" "=&r"))]
4070 ""
4071 "
4072 {
4073 if (pa_emit_move_sequence (operands, DImode, operands[2]))
4074 DONE;
4075
4076 /* We don't want the clobber emitted, so handle this ourselves. */
4077 emit_insn (gen_rtx_SET (operands[0], operands[1]));
4078 DONE;
4079 }")
4080
4081 (define_insn ""
4082 [(set (match_operand:DI 0 "register_operand" "=r")
4083 (high:DI (match_operand 1 "" "")))]
4084 "!TARGET_64BIT"
4085 "*
4086 {
4087 rtx op0 = operands[0];
4088 rtx op1 = operands[1];
4089
4090 switch (GET_CODE (op1))
4091 {
4092 case CONST_INT:
4093 #if HOST_BITS_PER_WIDE_INT <= 32
4094 operands[0] = operand_subword (op0, 1, 0, DImode);
4095 output_asm_insn (\"ldil L'%1,%0\", operands);
4096
4097 operands[0] = operand_subword (op0, 0, 0, DImode);
4098 if (INTVAL (op1) < 0)
4099 output_asm_insn (\"ldi -1,%0\", operands);
4100 else
4101 output_asm_insn (\"ldi 0,%0\", operands);
4102 #else
4103 operands[0] = operand_subword (op0, 1, 0, DImode);
4104 operands[1] = GEN_INT (INTVAL (op1) & 0xffffffff);
4105 output_asm_insn (\"ldil L'%1,%0\", operands);
4106
4107 operands[0] = operand_subword (op0, 0, 0, DImode);
4108 operands[1] = GEN_INT (INTVAL (op1) >> 32);
4109 output_asm_insn (pa_singlemove_string (operands), operands);
4110 #endif
4111 break;
4112
4113 case CONST_DOUBLE:
4114 operands[0] = operand_subword (op0, 1, 0, DImode);
4115 operands[1] = GEN_INT (CONST_DOUBLE_LOW (op1));
4116 output_asm_insn (\"ldil L'%1,%0\", operands);
4117
4118 operands[0] = operand_subword (op0, 0, 0, DImode);
4119 operands[1] = GEN_INT (CONST_DOUBLE_HIGH (op1));
4120 output_asm_insn (pa_singlemove_string (operands), operands);
4121 break;
4122
4123 default:
4124 gcc_unreachable ();
4125 }
4126 return \"\";
4127 }"
4128 [(set_attr "type" "move")
4129 (set_attr "length" "12")])
4130
4131 (define_insn ""
4132 [(set (match_operand:DI 0 "move_dest_operand"
4133 "=r,o,Q,r,r,r,*f,*f,T,?r,?*f")
4134 (match_operand:DI 1 "move_src_operand"
4135 "rM,r,r,o*R,Q,i,*fM,RT,*f,*f,r"))]
4136 "(register_operand (operands[0], DImode)
4137 || reg_or_0_operand (operands[1], DImode))
4138 && !TARGET_64BIT
4139 && !TARGET_SOFT_FLOAT"
4140 "*
4141 {
4142 if ((FP_REG_P (operands[0]) || FP_REG_P (operands[1])
4143 || operands[1] == CONST0_RTX (DFmode))
4144 && !(REG_P (operands[0]) && REG_P (operands[1])
4145 && FP_REG_P (operands[0]) ^ FP_REG_P (operands[1])))
4146 return pa_output_fp_move_double (operands);
4147 return pa_output_move_double (operands);
4148 }"
4149 [(set_attr "type"
4150 "move,store,store,load,load,multi,fpalu,fpload,fpstore,fpstore_load,store_fpload")
4151 (set_attr "length" "8,8,16,8,16,16,4,4,4,12,12")])
4152
4153 (define_insn ""
4154 [(set (match_operand:DI 0 "move_dest_operand"
4155 "=r,r,r,r,r,r,Q,!*q,!r,!*f,*f,T")
4156 (match_operand:DI 1 "move_src_operand"
4157 "A,r,J,N,K,RQ,rM,!rM,!*q,!*fM,RT,*f"))]
4158 "(register_operand (operands[0], DImode)
4159 || reg_or_0_operand (operands[1], DImode))
4160 && !TARGET_SOFT_FLOAT && TARGET_64BIT"
4161 "@
4162 ldd RT'%A1,%0
4163 copy %1,%0
4164 ldi %1,%0
4165 ldil L'%1,%0
4166 depdi,z %z1,%0
4167 ldd%M1 %1,%0
4168 std%M0 %r1,%0
4169 mtsar %r1
4170 {mfctl|mfctl,w} %%sar,%0
4171 fcpy,dbl %f1,%0
4172 fldd%F1 %1,%0
4173 fstd%F0 %1,%0"
4174 [(set_attr "type" "load,move,move,move,shift,load,store,move,move,fpalu,fpload,fpstore")
4175 (set_attr "pa_combine_type" "addmove")
4176 (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4")])
4177
4178 (define_insn ""
4179 [(set (match_operand:DI 0 "indexed_memory_operand" "=R")
4180 (match_operand:DI 1 "register_operand" "f"))]
4181 "!TARGET_SOFT_FLOAT
4182 && TARGET_64BIT
4183 && !TARGET_DISABLE_INDEXING
4184 && reload_completed"
4185 "fstd%F0 %1,%0"
4186 [(set_attr "type" "fpstore")
4187 (set_attr "pa_combine_type" "addmove")
4188 (set_attr "length" "4")])
4189
4190 (define_peephole2
4191 [(set (match_operand:DI 0 "register_operand" "")
4192 (plus:DI (ashift:DI (match_operand:DI 1 "register_operand" "")
4193 (const_int 3))
4194 (match_operand:DI 2 "register_operand" "")))
4195 (set (mem:DI (match_dup 0))
4196 (match_operand:DI 3 "register_operand" ""))]
4197 "!TARGET_SOFT_FLOAT
4198 && !TARGET_DISABLE_INDEXING
4199 && TARGET_64BIT
4200 && REG_OK_FOR_BASE_P (operands[2])
4201 && FP_REGNO_P (REGNO (operands[3]))"
4202 [(set (mem:DI (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
4203 (match_dup 3))
4204 (set (match_dup 0) (plus:DI (ashift:DI (match_dup 1) (const_int 3))
4205 (match_dup 2)))]
4206 "")
4207
4208 (define_peephole2
4209 [(set (match_operand:DI 0 "register_operand" "")
4210 (plus:DI (match_operand:DI 1 "register_operand" "")
4211 (match_operand:DI 2 "register_operand" "")))
4212 (set (mem:DI (match_dup 0))
4213 (match_operand:DI 3 "register_operand" ""))]
4214 "!TARGET_SOFT_FLOAT
4215 && !TARGET_DISABLE_INDEXING
4216 && TARGET_64BIT
4217 && TARGET_NO_SPACE_REGS
4218 && REG_OK_FOR_INDEX_P (operands[1])
4219 && REG_OK_FOR_BASE_P (operands[2])
4220 && FP_REGNO_P (REGNO (operands[3]))"
4221 [(set (mem:DI (plus:DI (match_dup 1) (match_dup 2)))
4222 (match_dup 3))
4223 (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
4224 "")
4225
4226 (define_peephole2
4227 [(set (match_operand:DI 0 "register_operand" "")
4228 (plus:DI (match_operand:DI 1 "register_operand" "")
4229 (match_operand:DI 2 "register_operand" "")))
4230 (set (mem:DI (match_dup 0))
4231 (match_operand:DI 3 "register_operand" ""))]
4232 "!TARGET_SOFT_FLOAT
4233 && !TARGET_DISABLE_INDEXING
4234 && TARGET_64BIT
4235 && TARGET_NO_SPACE_REGS
4236 && REG_OK_FOR_BASE_P (operands[1])
4237 && REG_OK_FOR_INDEX_P (operands[2])
4238 && FP_REGNO_P (REGNO (operands[3]))"
4239 [(set (mem:DI (plus:DI (match_dup 2) (match_dup 1)))
4240 (match_dup 3))
4241 (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
4242 "")
4243
4244 (define_insn ""
4245 [(set (match_operand:DI 0 "move_dest_operand"
4246 "=r,o,Q,r,r,r")
4247 (match_operand:DI 1 "general_operand"
4248 "rM,r,r,o,Q,i"))]
4249 "(register_operand (operands[0], DImode)
4250 || reg_or_0_operand (operands[1], DImode))
4251 && !TARGET_64BIT
4252 && TARGET_SOFT_FLOAT"
4253 "*
4254 {
4255 return pa_output_move_double (operands);
4256 }"
4257 [(set_attr "type" "move,store,store,load,load,multi")
4258 (set_attr "length" "8,8,16,8,16,16")])
4259
4260 (define_insn ""
4261 [(set (match_operand:DI 0 "register_operand" "=r,&r")
4262 (lo_sum:DI (match_operand:DI 1 "register_operand" "0,r")
4263 (match_operand:DI 2 "immediate_operand" "i,i")))]
4264 "!TARGET_64BIT"
4265 "*
4266 {
4267 /* Don't output a 64-bit constant, since we can't trust the assembler to
4268 handle it correctly. */
4269 if (GET_CODE (operands[2]) == CONST_DOUBLE)
4270 operands[2] = GEN_INT (CONST_DOUBLE_LOW (operands[2]));
4271 else if (HOST_BITS_PER_WIDE_INT > 32
4272 && GET_CODE (operands[2]) == CONST_INT)
4273 operands[2] = GEN_INT (INTVAL (operands[2]) & 0xffffffff);
4274 if (which_alternative == 1)
4275 output_asm_insn (\"copy %1,%0\", operands);
4276 return \"ldo R'%G2(%R1),%R0\";
4277 }"
4278 [(set_attr "type" "move,move")
4279 (set_attr "length" "4,8")])
4280
4281 (define_expand "movsf"
4282 [(set (match_operand:SF 0 "general_operand" "")
4283 (match_operand:SF 1 "general_operand" ""))]
4284 ""
4285 "
4286 {
4287 if (pa_emit_move_sequence (operands, SFmode, 0))
4288 DONE;
4289 }")
4290
4291 ;; Handle SFmode input reloads requiring %r1 as a scratch register.
4292 (define_expand "reload_insf_r1"
4293 [(set (match_operand:SF 0 "register_operand" "=Z")
4294 (match_operand:SF 1 "non_hard_reg_operand" ""))
4295 (clobber (match_operand:SI 2 "register_operand" "=&a"))]
4296 ""
4297 "
4298 {
4299 if (pa_emit_move_sequence (operands, SFmode, operands[2]))
4300 DONE;
4301
4302 /* We don't want the clobber emitted, so handle this ourselves. */
4303 emit_insn (gen_rtx_SET (operands[0], operands[1]));
4304 DONE;
4305 }")
4306
4307 ;; Handle SFmode input reloads requiring a general register as a
4308 ;; scratch register.
4309 (define_expand "reload_insf"
4310 [(set (match_operand:SF 0 "register_operand" "=Z")
4311 (match_operand:SF 1 "non_hard_reg_operand" ""))
4312 (clobber (match_operand:SF 2 "register_operand" "=&r"))]
4313 ""
4314 "
4315 {
4316 if (pa_emit_move_sequence (operands, SFmode, operands[2]))
4317 DONE;
4318
4319 /* We don't want the clobber emitted, so handle this ourselves. */
4320 emit_insn (gen_rtx_SET (operands[0], operands[1]));
4321 DONE;
4322 }")
4323
4324 ;; Handle SFmode output reloads requiring a general register as a
4325 ;; scratch register.
4326 (define_expand "reload_outsf"
4327 [(set (match_operand:SF 0 "non_hard_reg_operand" "")
4328 (match_operand:SF 1 "register_operand" "Z"))
4329 (clobber (match_operand:SF 2 "register_operand" "=&r"))]
4330 ""
4331 "
4332 {
4333 if (pa_emit_move_sequence (operands, SFmode, operands[2]))
4334 DONE;
4335
4336 /* We don't want the clobber emitted, so handle this ourselves. */
4337 emit_insn (gen_rtx_SET (operands[0], operands[1]));
4338 DONE;
4339 }")
4340
4341 (define_insn ""
4342 [(set (match_operand:SF 0 "move_dest_operand"
4343 "=f,!*r,f,*r,T,Q,?*r,?f")
4344 (match_operand:SF 1 "reg_or_0_or_nonsymb_mem_operand"
4345 "fG,!*rG,RT,RQ,f,*rG,f,*r"))]
4346 "(register_operand (operands[0], SFmode)
4347 || reg_or_0_operand (operands[1], SFmode))
4348 && !TARGET_SOFT_FLOAT
4349 && !TARGET_64BIT"
4350 "@
4351 fcpy,sgl %f1,%0
4352 copy %r1,%0
4353 fldw%F1 %1,%0
4354 ldw%M1 %1,%0
4355 fstw%F0 %1,%0
4356 stw%M0 %r1,%0
4357 {fstws|fstw} %1,-16(%%sp)\n\t{ldws|ldw} -16(%%sp),%0
4358 {stws|stw} %1,-16(%%sp)\n\t{fldws|fldw} -16(%%sp),%0"
4359 [(set_attr "type" "fpalu,move,fpload,load,fpstore,store,fpstore_load,store_fpload")
4360 (set_attr "pa_combine_type" "addmove")
4361 (set_attr "length" "4,4,4,4,4,4,8,8")])
4362
4363 (define_insn ""
4364 [(set (match_operand:SF 0 "move_dest_operand"
4365 "=f,!*r,f,*r,T,Q")
4366 (match_operand:SF 1 "reg_or_0_or_nonsymb_mem_operand"
4367 "fG,!*rG,RT,RQ,f,*rG"))]
4368 "(register_operand (operands[0], SFmode)
4369 || reg_or_0_operand (operands[1], SFmode))
4370 && !TARGET_SOFT_FLOAT
4371 && TARGET_64BIT"
4372 "@
4373 fcpy,sgl %f1,%0
4374 copy %r1,%0
4375 fldw%F1 %1,%0
4376 ldw%M1 %1,%0
4377 fstw%F0 %1,%0
4378 stw%M0 %r1,%0"
4379 [(set_attr "type" "fpalu,move,fpload,load,fpstore,store")
4380 (set_attr "pa_combine_type" "addmove")
4381 (set_attr "length" "4,4,4,4,4,4")])
4382
4383 (define_insn ""
4384 [(set (match_operand:SF 0 "indexed_memory_operand" "=R")
4385 (match_operand:SF 1 "register_operand" "f"))]
4386 "!TARGET_SOFT_FLOAT
4387 && !TARGET_DISABLE_INDEXING
4388 && reload_completed"
4389 "fstw%F0 %1,%0"
4390 [(set_attr "type" "fpstore")
4391 (set_attr "pa_combine_type" "addmove")
4392 (set_attr "length" "4")])
4393
4394 (define_peephole2
4395 [(set (match_operand:SI 0 "register_operand" "")
4396 (plus:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
4397 (const_int 2))
4398 (match_operand:SI 2 "register_operand" "")))
4399 (set (mem:SF (match_dup 0))
4400 (match_operand:SF 3 "register_operand" ""))]
4401 "!TARGET_SOFT_FLOAT
4402 && !TARGET_DISABLE_INDEXING
4403 && REG_OK_FOR_BASE_P (operands[2])
4404 && FP_REGNO_P (REGNO (operands[3]))"
4405 [(set (mem:SF (plus:SI (mult:SI (match_dup 1) (const_int 4)) (match_dup 2)))
4406 (match_dup 3))
4407 (set (match_dup 0) (plus:SI (ashift:SI (match_dup 1) (const_int 2))
4408 (match_dup 2)))]
4409 "")
4410
4411 (define_peephole2
4412 [(set (match_operand:DI 0 "register_operand" "")
4413 (plus:DI (ashift:DI (match_operand:DI 1 "register_operand" "")
4414 (const_int 2))
4415 (match_operand:DI 2 "register_operand" "")))
4416 (set (mem:SF (match_dup 0))
4417 (match_operand:SF 3 "register_operand" ""))]
4418 "!TARGET_SOFT_FLOAT
4419 && !TARGET_DISABLE_INDEXING
4420 && TARGET_64BIT
4421 && REG_OK_FOR_BASE_P (operands[2])
4422 && FP_REGNO_P (REGNO (operands[3]))"
4423 [(set (mem:SF (plus:DI (mult:DI (match_dup 1) (const_int 4)) (match_dup 2)))
4424 (match_dup 3))
4425 (set (match_dup 0) (plus:DI (ashift:DI (match_dup 1) (const_int 2))
4426 (match_dup 2)))]
4427 "")
4428
4429 (define_peephole2
4430 [(set (match_operand:SI 0 "register_operand" "")
4431 (plus:SI (match_operand:SI 1 "register_operand" "")
4432 (match_operand:SI 2 "register_operand" "")))
4433 (set (mem:SF (match_dup 0))
4434 (match_operand:SF 3 "register_operand" ""))]
4435 "!TARGET_SOFT_FLOAT
4436 && !TARGET_DISABLE_INDEXING
4437 && TARGET_NO_SPACE_REGS
4438 && REG_OK_FOR_INDEX_P (operands[1])
4439 && REG_OK_FOR_BASE_P (operands[2])
4440 && FP_REGNO_P (REGNO (operands[3]))"
4441 [(set (mem:SF (plus:SI (match_dup 1) (match_dup 2)))
4442 (match_dup 3))
4443 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
4444 "")
4445
4446 (define_peephole2
4447 [(set (match_operand:SI 0 "register_operand" "")
4448 (plus:SI (match_operand:SI 1 "register_operand" "")
4449 (match_operand:SI 2 "register_operand" "")))
4450 (set (mem:SF (match_dup 0))
4451 (match_operand:SF 3 "register_operand" ""))]
4452 "!TARGET_SOFT_FLOAT
4453 && !TARGET_DISABLE_INDEXING
4454 && TARGET_NO_SPACE_REGS
4455 && REG_OK_FOR_BASE_P (operands[1])
4456 && REG_OK_FOR_INDEX_P (operands[2])
4457 && FP_REGNO_P (REGNO (operands[3]))"
4458 [(set (mem:SF (plus:SI (match_dup 2) (match_dup 1)))
4459 (match_dup 3))
4460 (set (match_dup 0) (plus:SI (match_dup 2) (match_dup 1)))]
4461 "")
4462
4463 (define_peephole2
4464 [(set (match_operand:DI 0 "register_operand" "")
4465 (plus:DI (match_operand:DI 1 "register_operand" "")
4466 (match_operand:DI 2 "register_operand" "")))
4467 (set (mem:SF (match_dup 0))
4468 (match_operand:SF 3 "register_operand" ""))]
4469 "!TARGET_SOFT_FLOAT
4470 && !TARGET_DISABLE_INDEXING
4471 && TARGET_64BIT
4472 && TARGET_NO_SPACE_REGS
4473 && REG_OK_FOR_INDEX_P (operands[1])
4474 && REG_OK_FOR_BASE_P (operands[2])
4475 && FP_REGNO_P (REGNO (operands[3]))"
4476 [(set (mem:SF (plus:DI (match_dup 1) (match_dup 2)))
4477 (match_dup 3))
4478 (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
4479 "")
4480
4481 (define_peephole2
4482 [(set (match_operand:DI 0 "register_operand" "")
4483 (plus:DI (match_operand:DI 1 "register_operand" "")
4484 (match_operand:DI 2 "register_operand" "")))
4485 (set (mem:SF (match_dup 0))
4486 (match_operand:SF 3 "register_operand" ""))]
4487 "!TARGET_SOFT_FLOAT
4488 && !TARGET_DISABLE_INDEXING
4489 && TARGET_64BIT
4490 && TARGET_NO_SPACE_REGS
4491 && REG_OK_FOR_BASE_P (operands[1])
4492 && REG_OK_FOR_INDEX_P (operands[2])
4493 && FP_REGNO_P (REGNO (operands[3]))"
4494 [(set (mem:SF (plus:DI (match_dup 2) (match_dup 1)))
4495 (match_dup 3))
4496 (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
4497 "")
4498
4499 (define_insn ""
4500 [(set (match_operand:SF 0 "move_dest_operand"
4501 "=r,r,Q")
4502 (match_operand:SF 1 "reg_or_0_or_nonsymb_mem_operand"
4503 "rG,RQ,rG"))]
4504 "(register_operand (operands[0], SFmode)
4505 || reg_or_0_operand (operands[1], SFmode))
4506 && TARGET_SOFT_FLOAT"
4507 "@
4508 copy %r1,%0
4509 ldw%M1 %1,%0
4510 stw%M0 %r1,%0"
4511 [(set_attr "type" "move,load,store")
4512 (set_attr "pa_combine_type" "addmove")
4513 (set_attr "length" "4,4,4")])
4514
4515 \f
4516
4517 ;;- zero extension instructions
4518 ;; We have define_expand for zero extension patterns to make sure the
4519 ;; operands get loaded into registers. The define_insns accept
4520 ;; memory operands. This gives us better overall code than just
4521 ;; having a pattern that does or does not accept memory operands.
4522
4523 (define_expand "zero_extendqihi2"
4524 [(set (match_operand:HI 0 "register_operand" "")
4525 (zero_extend:HI
4526 (match_operand:QI 1 "register_operand" "")))]
4527 ""
4528 "")
4529
4530 (define_insn ""
4531 [(set (match_operand:HI 0 "register_operand" "=r,r")
4532 (zero_extend:HI
4533 (match_operand:QI 1 "move_src_operand" "r,RQ")))]
4534 "GET_CODE (operands[1]) != CONST_INT"
4535 "@
4536 {extru|extrw,u} %1,31,8,%0
4537 ldb%M1 %1,%0"
4538 [(set_attr "type" "shift,load")
4539 (set_attr "length" "4,4")])
4540
4541 (define_expand "zero_extendqisi2"
4542 [(set (match_operand:SI 0 "register_operand" "")
4543 (zero_extend:SI
4544 (match_operand:QI 1 "register_operand" "")))]
4545 ""
4546 "")
4547
4548 (define_insn ""
4549 [(set (match_operand:SI 0 "register_operand" "=r,r")
4550 (zero_extend:SI
4551 (match_operand:QI 1 "move_src_operand" "r,RQ")))]
4552 "GET_CODE (operands[1]) != CONST_INT"
4553 "@
4554 {extru|extrw,u} %1,31,8,%0
4555 ldb%M1 %1,%0"
4556 [(set_attr "type" "shift,load")
4557 (set_attr "length" "4,4")])
4558
4559 (define_expand "zero_extendhisi2"
4560 [(set (match_operand:SI 0 "register_operand" "")
4561 (zero_extend:SI
4562 (match_operand:HI 1 "register_operand" "")))]
4563 ""
4564 "")
4565
4566 (define_insn ""
4567 [(set (match_operand:SI 0 "register_operand" "=r,r")
4568 (zero_extend:SI
4569 (match_operand:HI 1 "move_src_operand" "r,RQ")))]
4570 "GET_CODE (operands[1]) != CONST_INT"
4571 "@
4572 {extru|extrw,u} %1,31,16,%0
4573 ldh%M1 %1,%0"
4574 [(set_attr "type" "shift,load")
4575 (set_attr "length" "4,4")])
4576
4577 (define_expand "zero_extendqidi2"
4578 [(set (match_operand:DI 0 "register_operand" "")
4579 (zero_extend:DI
4580 (match_operand:QI 1 "register_operand" "")))]
4581 "TARGET_64BIT"
4582 "")
4583
4584 (define_insn ""
4585 [(set (match_operand:DI 0 "register_operand" "=r,r")
4586 (zero_extend:DI
4587 (match_operand:QI 1 "move_src_operand" "r,RQ")))]
4588 "TARGET_64BIT && GET_CODE (operands[1]) != CONST_INT"
4589 "@
4590 extrd,u %1,63,8,%0
4591 ldb%M1 %1,%0"
4592 [(set_attr "type" "shift,load")
4593 (set_attr "length" "4,4")])
4594
4595 (define_expand "zero_extendhidi2"
4596 [(set (match_operand:DI 0 "register_operand" "")
4597 (zero_extend:DI
4598 (match_operand:HI 1 "register_operand" "")))]
4599 "TARGET_64BIT"
4600 "")
4601
4602 (define_insn ""
4603 [(set (match_operand:DI 0 "register_operand" "=r,r")
4604 (zero_extend:DI
4605 (match_operand:HI 1 "move_src_operand" "r,RQ")))]
4606 "TARGET_64BIT && GET_CODE (operands[1]) != CONST_INT"
4607 "@
4608 extrd,u %1,63,16,%0
4609 ldh%M1 %1,%0"
4610 [(set_attr "type" "shift,load")
4611 (set_attr "length" "4,4")])
4612
4613 (define_expand "zero_extendsidi2"
4614 [(set (match_operand:DI 0 "register_operand" "")
4615 (zero_extend:DI
4616 (match_operand:SI 1 "register_operand" "")))]
4617 "TARGET_64BIT"
4618 "")
4619
4620 (define_insn ""
4621 [(set (match_operand:DI 0 "register_operand" "=r,r")
4622 (zero_extend:DI
4623 (match_operand:SI 1 "move_src_operand" "r,RQ")))]
4624 "TARGET_64BIT && GET_CODE (operands[1]) != CONST_INT"
4625 "@
4626 extrd,u %1,63,32,%0
4627 ldw%M1 %1,%0"
4628 [(set_attr "type" "shift,load")
4629 (set_attr "length" "4,4")])
4630
4631 ;;- sign extension instructions
4632
4633 (define_insn "extendhisi2"
4634 [(set (match_operand:SI 0 "register_operand" "=r")
4635 (sign_extend:SI (match_operand:HI 1 "register_operand" "r")))]
4636 ""
4637 "{extrs|extrw,s} %1,31,16,%0"
4638 [(set_attr "type" "shift")
4639 (set_attr "length" "4")])
4640
4641 (define_insn "extendqihi2"
4642 [(set (match_operand:HI 0 "register_operand" "=r")
4643 (sign_extend:HI (match_operand:QI 1 "register_operand" "r")))]
4644 ""
4645 "{extrs|extrw,s} %1,31,8,%0"
4646 [(set_attr "type" "shift")
4647 (set_attr "length" "4")])
4648
4649 (define_insn "extendqisi2"
4650 [(set (match_operand:SI 0 "register_operand" "=r")
4651 (sign_extend:SI (match_operand:QI 1 "register_operand" "r")))]
4652 ""
4653 "{extrs|extrw,s} %1,31,8,%0"
4654 [(set_attr "type" "shift")
4655 (set_attr "length" "4")])
4656
4657 (define_insn "extendqidi2"
4658 [(set (match_operand:DI 0 "register_operand" "=r")
4659 (sign_extend:DI (match_operand:QI 1 "register_operand" "r")))]
4660 "TARGET_64BIT"
4661 "extrd,s %1,63,8,%0"
4662 [(set_attr "type" "shift")
4663 (set_attr "length" "4")])
4664
4665 (define_insn "extendhidi2"
4666 [(set (match_operand:DI 0 "register_operand" "=r")
4667 (sign_extend:DI (match_operand:HI 1 "register_operand" "r")))]
4668 "TARGET_64BIT"
4669 "extrd,s %1,63,16,%0"
4670 [(set_attr "type" "shift")
4671 (set_attr "length" "4")])
4672
4673 (define_insn "extendsidi2"
4674 [(set (match_operand:DI 0 "register_operand" "=r")
4675 (sign_extend:DI (match_operand:SI 1 "register_operand" "r")))]
4676 "TARGET_64BIT"
4677 "extrd,s %1,63,32,%0"
4678 [(set_attr "type" "shift")
4679 (set_attr "length" "4")])
4680
4681 \f
4682 ;; Conversions between float and double.
4683
4684 (define_insn "extendsfdf2"
4685 [(set (match_operand:DF 0 "register_operand" "=f")
4686 (float_extend:DF
4687 (match_operand:SF 1 "register_operand" "f")))]
4688 "! TARGET_SOFT_FLOAT"
4689 "{fcnvff|fcnv},sgl,dbl %1,%0"
4690 [(set_attr "type" "fpalu")
4691 (set_attr "length" "4")])
4692
4693 (define_insn "truncdfsf2"
4694 [(set (match_operand:SF 0 "register_operand" "=f")
4695 (float_truncate:SF
4696 (match_operand:DF 1 "register_operand" "f")))]
4697 "! TARGET_SOFT_FLOAT"
4698 "{fcnvff|fcnv},dbl,sgl %1,%0"
4699 [(set_attr "type" "fpalu")
4700 (set_attr "length" "4")])
4701
4702 ;; Conversion between fixed point and floating point.
4703 ;; Note that among the fix-to-float insns
4704 ;; the ones that start with SImode come first.
4705 ;; That is so that an operand that is a CONST_INT
4706 ;; (and therefore lacks a specific machine mode).
4707 ;; will be recognized as SImode (which is always valid)
4708 ;; rather than as QImode or HImode.
4709
4710 ;; This pattern forces (set (reg:SF ...) (float:SF (const_int ...)))
4711 ;; to be reloaded by putting the constant into memory.
4712 ;; It must come before the more general floatsisf2 pattern.
4713 (define_insn ""
4714 [(set (match_operand:SF 0 "register_operand" "=f")
4715 (float:SF (match_operand:SI 1 "const_int_operand" "m")))]
4716 "! TARGET_SOFT_FLOAT"
4717 "fldw%F1 %1,%0\;{fcnvxf,sgl,sgl|fcnv,w,sgl} %0,%0"
4718 [(set_attr "type" "fpalu")
4719 (set_attr "length" "8")])
4720
4721 (define_insn "floatsisf2"
4722 [(set (match_operand:SF 0 "register_operand" "=f")
4723 (float:SF (match_operand:SI 1 "register_operand" "f")))]
4724 "! TARGET_SOFT_FLOAT"
4725 "{fcnvxf,sgl,sgl|fcnv,w,sgl} %1,%0"
4726 [(set_attr "type" "fpalu")
4727 (set_attr "length" "4")])
4728
4729 ;; This pattern forces (set (reg:DF ...) (float:DF (const_int ...)))
4730 ;; to be reloaded by putting the constant into memory.
4731 ;; It must come before the more general floatsidf2 pattern.
4732 (define_insn ""
4733 [(set (match_operand:DF 0 "register_operand" "=f")
4734 (float:DF (match_operand:SI 1 "const_int_operand" "m")))]
4735 "! TARGET_SOFT_FLOAT"
4736 "fldw%F1 %1,%0\;{fcnvxf,sgl,dbl|fcnv,w,dbl} %0,%0"
4737 [(set_attr "type" "fpalu")
4738 (set_attr "length" "8")])
4739
4740 (define_insn "floatsidf2"
4741 [(set (match_operand:DF 0 "register_operand" "=f")
4742 (float:DF (match_operand:SI 1 "register_operand" "f")))]
4743 "! TARGET_SOFT_FLOAT"
4744 "{fcnvxf,sgl,dbl|fcnv,w,dbl} %1,%0"
4745 [(set_attr "type" "fpalu")
4746 (set_attr "length" "4")])
4747
4748 (define_expand "floatunssisf2"
4749 [(set (subreg:SI (match_dup 2) 4)
4750 (match_operand:SI 1 "register_operand" ""))
4751 (set (subreg:SI (match_dup 2) 0)
4752 (const_int 0))
4753 (set (match_operand:SF 0 "register_operand" "")
4754 (float:SF (match_dup 2)))]
4755 "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4756 "
4757 {
4758 if (TARGET_PA_20)
4759 {
4760 emit_insn (gen_floatunssisf2_pa20 (operands[0], operands[1]));
4761 DONE;
4762 }
4763 operands[2] = gen_reg_rtx (DImode);
4764 }")
4765
4766 (define_expand "floatunssidf2"
4767 [(set (subreg:SI (match_dup 2) 4)
4768 (match_operand:SI 1 "register_operand" ""))
4769 (set (subreg:SI (match_dup 2) 0)
4770 (const_int 0))
4771 (set (match_operand:DF 0 "register_operand" "")
4772 (float:DF (match_dup 2)))]
4773 "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4774 "
4775 {
4776 if (TARGET_PA_20)
4777 {
4778 emit_insn (gen_floatunssidf2_pa20 (operands[0], operands[1]));
4779 DONE;
4780 }
4781 operands[2] = gen_reg_rtx (DImode);
4782 }")
4783
4784 (define_insn "floatdisf2"
4785 [(set (match_operand:SF 0 "register_operand" "=f")
4786 (float:SF (match_operand:DI 1 "register_operand" "f")))]
4787 "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4788 "{fcnvxf,dbl,sgl|fcnv,dw,sgl} %1,%0"
4789 [(set_attr "type" "fpalu")
4790 (set_attr "length" "4")])
4791
4792 (define_insn "floatdidf2"
4793 [(set (match_operand:DF 0 "register_operand" "=f")
4794 (float:DF (match_operand:DI 1 "register_operand" "f")))]
4795 "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4796 "{fcnvxf,dbl,dbl|fcnv,dw,dbl} %1,%0"
4797 [(set_attr "type" "fpalu")
4798 (set_attr "length" "4")])
4799
4800 ;; Convert a float to an actual integer.
4801 ;; Truncation is performed as part of the conversion.
4802
4803 (define_insn "fix_truncsfsi2"
4804 [(set (match_operand:SI 0 "register_operand" "=f")
4805 (fix:SI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
4806 "! TARGET_SOFT_FLOAT"
4807 "{fcnvfxt,sgl,sgl|fcnv,t,sgl,w} %1,%0"
4808 [(set_attr "type" "fpalu")
4809 (set_attr "length" "4")])
4810
4811 (define_insn "fix_truncdfsi2"
4812 [(set (match_operand:SI 0 "register_operand" "=f")
4813 (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
4814 "! TARGET_SOFT_FLOAT"
4815 "{fcnvfxt,dbl,sgl|fcnv,t,dbl,w} %1,%0"
4816 [(set_attr "type" "fpalu")
4817 (set_attr "length" "4")])
4818
4819 (define_insn "fix_truncsfdi2"
4820 [(set (match_operand:DI 0 "register_operand" "=f")
4821 (fix:DI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
4822 "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4823 "{fcnvfxt,sgl,dbl|fcnv,t,sgl,dw} %1,%0"
4824 [(set_attr "type" "fpalu")
4825 (set_attr "length" "4")])
4826
4827 (define_insn "fix_truncdfdi2"
4828 [(set (match_operand:DI 0 "register_operand" "=f")
4829 (fix:DI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
4830 "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4831 "{fcnvfxt,dbl,dbl|fcnv,t,dbl,dw} %1,%0"
4832 [(set_attr "type" "fpalu")
4833 (set_attr "length" "4")])
4834
4835 (define_insn "floatunssidf2_pa20"
4836 [(set (match_operand:DF 0 "register_operand" "=f")
4837 (unsigned_float:DF (match_operand:SI 1 "register_operand" "f")))]
4838 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4839 "fcnv,uw,dbl %1,%0"
4840 [(set_attr "type" "fpalu")
4841 (set_attr "length" "4")])
4842
4843 (define_insn "floatunssisf2_pa20"
4844 [(set (match_operand:SF 0 "register_operand" "=f")
4845 (unsigned_float:SF (match_operand:SI 1 "register_operand" "f")))]
4846 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4847 "fcnv,uw,sgl %1,%0"
4848 [(set_attr "type" "fpalu")
4849 (set_attr "length" "4")])
4850
4851 (define_insn "floatunsdisf2"
4852 [(set (match_operand:SF 0 "register_operand" "=f")
4853 (unsigned_float:SF (match_operand:DI 1 "register_operand" "f")))]
4854 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4855 "fcnv,udw,sgl %1,%0"
4856 [(set_attr "type" "fpalu")
4857 (set_attr "length" "4")])
4858
4859 (define_insn "floatunsdidf2"
4860 [(set (match_operand:DF 0 "register_operand" "=f")
4861 (unsigned_float:DF (match_operand:DI 1 "register_operand" "f")))]
4862 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4863 "fcnv,udw,dbl %1,%0"
4864 [(set_attr "type" "fpalu")
4865 (set_attr "length" "4")])
4866
4867 (define_insn "fixuns_truncsfsi2"
4868 [(set (match_operand:SI 0 "register_operand" "=f")
4869 (unsigned_fix:SI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
4870 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4871 "fcnv,t,sgl,uw %1,%0"
4872 [(set_attr "type" "fpalu")
4873 (set_attr "length" "4")])
4874
4875 (define_insn "fixuns_truncdfsi2"
4876 [(set (match_operand:SI 0 "register_operand" "=f")
4877 (unsigned_fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
4878 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4879 "fcnv,t,dbl,uw %1,%0"
4880 [(set_attr "type" "fpalu")
4881 (set_attr "length" "4")])
4882
4883 (define_insn "fixuns_truncsfdi2"
4884 [(set (match_operand:DI 0 "register_operand" "=f")
4885 (unsigned_fix:DI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
4886 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4887 "fcnv,t,sgl,udw %1,%0"
4888 [(set_attr "type" "fpalu")
4889 (set_attr "length" "4")])
4890
4891 (define_insn "fixuns_truncdfdi2"
4892 [(set (match_operand:DI 0 "register_operand" "=f")
4893 (unsigned_fix:DI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
4894 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4895 "fcnv,t,dbl,udw %1,%0"
4896 [(set_attr "type" "fpalu")
4897 (set_attr "length" "4")])
4898 \f
4899 ;;- arithmetic instructions
4900
4901 (define_expand "adddi3"
4902 [(set (match_operand:DI 0 "register_operand" "")
4903 (plus:DI (match_operand:DI 1 "register_operand" "")
4904 (match_operand:DI 2 "adddi3_operand" "")))]
4905 ""
4906 "")
4907
4908 (define_insn ""
4909 [(set (match_operand:DI 0 "register_operand" "=r")
4910 (plus:DI (match_operand:DI 1 "register_operand" "%r")
4911 (match_operand:DI 2 "arith11_operand" "rI")))]
4912 "!TARGET_64BIT"
4913 "*
4914 {
4915 if (GET_CODE (operands[2]) == CONST_INT)
4916 {
4917 if (INTVAL (operands[2]) >= 0)
4918 return \"addi %2,%R1,%R0\;{addc|add,c} %1,%%r0,%0\";
4919 else
4920 return \"addi %2,%R1,%R0\;{subb|sub,b} %1,%%r0,%0\";
4921 }
4922 else
4923 return \"add %R2,%R1,%R0\;{addc|add,c} %2,%1,%0\";
4924 }"
4925 [(set_attr "type" "binary")
4926 (set_attr "length" "8")])
4927
4928 (define_insn ""
4929 [(set (match_operand:DI 0 "register_operand" "=r,r")
4930 (plus:DI (match_operand:DI 1 "register_operand" "%r,r")
4931 (match_operand:DI 2 "arith14_operand" "r,J")))]
4932 "TARGET_64BIT"
4933 "@
4934 add,l %1,%2,%0
4935 ldo %2(%1),%0"
4936 [(set_attr "type" "binary,binary")
4937 (set_attr "pa_combine_type" "addmove")
4938 (set_attr "length" "4,4")])
4939
4940 (define_insn ""
4941 [(set (match_operand:DI 0 "register_operand" "=r")
4942 (plus:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
4943 (match_operand:DI 2 "register_operand" "r")))]
4944 "TARGET_64BIT"
4945 "uaddcm %2,%1,%0"
4946 [(set_attr "type" "binary")
4947 (set_attr "length" "4")])
4948
4949 (define_insn ""
4950 [(set (match_operand:SI 0 "register_operand" "=r")
4951 (plus:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
4952 (match_operand:SI 2 "register_operand" "r")))]
4953 ""
4954 "uaddcm %2,%1,%0"
4955 [(set_attr "type" "binary")
4956 (set_attr "length" "4")])
4957
4958 (define_expand "addvdi3"
4959 [(parallel [(set (match_operand:DI 0 "register_operand" "")
4960 (plus:DI (match_operand:DI 1 "reg_or_0_operand" "")
4961 (match_operand:DI 2 "arith11_operand" "")))
4962 (trap_if (ne (plus:TI (sign_extend:TI (match_dup 1))
4963 (sign_extend:TI (match_dup 2)))
4964 (sign_extend:TI (plus:DI (match_dup 1)
4965 (match_dup 2))))
4966 (const_int 0))])]
4967 ""
4968 "")
4969
4970 (define_insn ""
4971 [(set (match_operand:DI 0 "register_operand" "=r,r")
4972 (plus:DI (match_operand:DI 1 "reg_or_0_operand" "%rM,rM")
4973 (match_operand:DI 2 "arith11_operand" "r,I")))
4974 (trap_if (ne (plus:TI (sign_extend:TI (match_dup 1))
4975 (sign_extend:TI (match_dup 2)))
4976 (sign_extend:TI (plus:DI (match_dup 1)
4977 (match_dup 2))))
4978 (const_int 0))]
4979 "TARGET_64BIT"
4980 "@
4981 add,tsv,* %2,%1,%0
4982 addi,tsv,* %2,%1,%0"
4983 [(set_attr "type" "binary,binary")
4984 (set_attr "length" "4,4")])
4985
4986 (define_insn ""
4987 [(set (match_operand:DI 0 "register_operand" "=r")
4988 (plus:DI (match_operand:DI 1 "reg_or_0_operand" "%rM")
4989 (match_operand:DI 2 "arith11_operand" "rI")))
4990 (trap_if (ne (plus:TI (sign_extend:TI (match_dup 1))
4991 (sign_extend:TI (match_dup 2)))
4992 (sign_extend:TI (plus:DI (match_dup 1)
4993 (match_dup 2))))
4994 (const_int 0))]
4995 "!TARGET_64BIT"
4996 "*
4997 {
4998 if (GET_CODE (operands[2]) == CONST_INT)
4999 {
5000 if (INTVAL (operands[2]) >= 0)
5001 return \"addi %2,%R1,%R0\;{addco|add,c,tsv} %1,%%r0,%0\";
5002 else
5003 return \"addi %2,%R1,%R0\;{subbo|sub,b,tsv} %1,%%r0,%0\";
5004 }
5005 else
5006 return \"add %R2,%R1,%R0\;{addco|add,c,tsv} %2,%1,%0\";
5007 }"
5008 [(set_attr "type" "binary")
5009 (set_attr "length" "8")])
5010
5011 ;; define_splits to optimize cases of adding a constant integer
5012 ;; to a register when the constant does not fit in 14 bits. */
5013 (define_split
5014 [(set (match_operand:SI 0 "register_operand" "")
5015 (plus:SI (match_operand:SI 1 "register_operand" "")
5016 (match_operand:SI 2 "const_int_operand" "")))
5017 (clobber (match_operand:SI 4 "register_operand" ""))]
5018 "! pa_cint_ok_for_move (UINTVAL (operands[2]))
5019 && VAL_14_BITS_P (INTVAL (operands[2]) >> 1)"
5020 [(set (match_dup 4) (plus:SI (match_dup 1) (match_dup 2)))
5021 (set (match_dup 0) (plus:SI (match_dup 4) (match_dup 3)))]
5022 "
5023 {
5024 int val = INTVAL (operands[2]);
5025 int low = (val < 0) ? -0x2000 : 0x1fff;
5026 int rest = val - low;
5027
5028 operands[2] = GEN_INT (rest);
5029 operands[3] = GEN_INT (low);
5030 }")
5031
5032 (define_split
5033 [(set (match_operand:SI 0 "register_operand" "")
5034 (plus:SI (match_operand:SI 1 "register_operand" "")
5035 (match_operand:SI 2 "const_int_operand" "")))
5036 (clobber (match_operand:SI 4 "register_operand" ""))]
5037 "! pa_cint_ok_for_move (UINTVAL (operands[2]))"
5038 [(set (match_dup 4) (match_dup 2))
5039 (set (match_dup 0) (plus:SI (ashift:SI (match_dup 4) (match_dup 3))
5040 (match_dup 1)))]
5041 "
5042 {
5043 unsigned HOST_WIDE_INT intval = UINTVAL (operands[2]);
5044
5045 /* Try dividing the constant by 2, then 4, and finally 8 to see
5046 if we can get a constant which can be loaded into a register
5047 in a single instruction (pa_cint_ok_for_move).
5048
5049 If that fails, try to negate the constant and subtract it
5050 from our input operand. */
5051 if (intval % 2 == 0 && pa_cint_ok_for_move (intval / 2))
5052 {
5053 operands[2] = GEN_INT (intval / 2);
5054 operands[3] = const1_rtx;
5055 }
5056 else if (intval % 4 == 0 && pa_cint_ok_for_move (intval / 4))
5057 {
5058 operands[2] = GEN_INT (intval / 4);
5059 operands[3] = const2_rtx;
5060 }
5061 else if (intval % 8 == 0 && pa_cint_ok_for_move (intval / 8))
5062 {
5063 operands[2] = GEN_INT (intval / 8);
5064 operands[3] = GEN_INT (3);
5065 }
5066 else if (pa_cint_ok_for_move (-intval))
5067 {
5068 emit_insn (gen_rtx_SET (operands[4], GEN_INT (-intval)));
5069 emit_insn (gen_subsi3 (operands[0], operands[1], operands[4]));
5070 DONE;
5071 }
5072 else
5073 FAIL;
5074 }")
5075
5076 (define_insn "addsi3"
5077 [(set (match_operand:SI 0 "register_operand" "=r,r")
5078 (plus:SI (match_operand:SI 1 "register_operand" "%r,r")
5079 (match_operand:SI 2 "arith14_operand" "r,J")))]
5080 ""
5081 "@
5082 {addl|add,l} %1,%2,%0
5083 ldo %2(%1),%0"
5084 [(set_attr "type" "binary,binary")
5085 (set_attr "pa_combine_type" "addmove")
5086 (set_attr "length" "4,4")])
5087
5088 (define_insn "addvsi3"
5089 [(set (match_operand:SI 0 "register_operand" "=r,r")
5090 (plus:SI (match_operand:SI 1 "reg_or_0_operand" "%rM,rM")
5091 (match_operand:SI 2 "arith11_operand" "r,I")))
5092 (trap_if (ne (plus:DI (sign_extend:DI (match_dup 1))
5093 (sign_extend:DI (match_dup 2)))
5094 (sign_extend:DI (plus:SI (match_dup 1)
5095 (match_dup 2))))
5096 (const_int 0))]
5097 ""
5098 "@
5099 {addo|add,tsv} %2,%1,%0
5100 {addio|addi,tsv} %2,%1,%0"
5101 [(set_attr "type" "binary,binary")
5102 (set_attr "length" "4,4")])
5103
5104 (define_expand "subdi3"
5105 [(set (match_operand:DI 0 "register_operand" "")
5106 (minus:DI (match_operand:DI 1 "arith11_operand" "")
5107 (match_operand:DI 2 "reg_or_0_operand" "")))]
5108 ""
5109 "")
5110
5111 (define_insn ""
5112 [(set (match_operand:DI 0 "register_operand" "=r,r,!q")
5113 (minus:DI (match_operand:DI 1 "arith11_operand" "r,I,!U")
5114 (match_operand:DI 2 "reg_or_0_operand" "rM,rM,!rM")))]
5115 "TARGET_64BIT"
5116 "@
5117 sub %1,%2,%0
5118 subi %1,%2,%0
5119 mtsarcm %2"
5120 [(set_attr "type" "binary,binary,move")
5121 (set_attr "length" "4,4,4")])
5122
5123 (define_insn ""
5124 [(set (match_operand:DI 0 "register_operand" "=r,&r")
5125 (minus:DI (match_operand:DI 1 "arith11_operand" "r,I")
5126 (match_operand:DI 2 "reg_or_0_operand" "rM,rM")))]
5127 "!TARGET_64BIT"
5128 "*
5129 {
5130 if (GET_CODE (operands[1]) == CONST_INT)
5131 {
5132 if (INTVAL (operands[1]) >= 0)
5133 return \"subi %1,%R2,%R0\;{subb|sub,b} %%r0,%2,%0\";
5134 else
5135 return \"ldi -1,%0\;subi %1,%R2,%R0\;{subb|sub,b} %0,%2,%0\";
5136 }
5137 else
5138 return \"sub %R1,%R2,%R0\;{subb|sub,b} %1,%2,%0\";
5139 }"
5140 [(set_attr "type" "binary")
5141 (set (attr "length")
5142 (if_then_else (eq_attr "alternative" "0")
5143 (const_int 8)
5144 (if_then_else (ge (symbol_ref "INTVAL (operands[1])")
5145 (const_int 0))
5146 (const_int 8)
5147 (const_int 12))))])
5148
5149 (define_expand "subvdi3"
5150 [(parallel [(set (match_operand:DI 0 "register_operand" "")
5151 (minus:DI (match_operand:DI 1 "arith11_operand" "")
5152 (match_operand:DI 2 "reg_or_0_operand" "")))
5153 (trap_if (ne (minus:TI (sign_extend:TI (match_dup 1))
5154 (sign_extend:TI (match_dup 2)))
5155 (sign_extend:TI (minus:DI (match_dup 1)
5156 (match_dup 2))))
5157 (const_int 0))])]
5158 ""
5159 "")
5160
5161 (define_insn ""
5162 [(set (match_operand:DI 0 "register_operand" "=r,r")
5163 (minus:DI (match_operand:DI 1 "arith11_operand" "r,I")
5164 (match_operand:DI 2 "reg_or_0_operand" "rM,rM")))
5165 (trap_if (ne (minus:TI (sign_extend:TI (match_dup 1))
5166 (sign_extend:TI (match_dup 2)))
5167 (sign_extend:TI (minus:DI (match_dup 1)
5168 (match_dup 2))))
5169 (const_int 0))]
5170 "TARGET_64BIT"
5171 "@
5172 {subo|sub,tsv} %1,%2,%0
5173 {subio|subi,tsv} %1,%2,%0"
5174 [(set_attr "type" "binary,binary")
5175 (set_attr "length" "4,4")])
5176
5177 (define_insn ""
5178 [(set (match_operand:DI 0 "register_operand" "=r,&r")
5179 (minus:DI (match_operand:DI 1 "arith11_operand" "r,I")
5180 (match_operand:DI 2 "reg_or_0_operand" "rM,rM")))
5181 (trap_if (ne (minus:TI (sign_extend:TI (match_dup 1))
5182 (sign_extend:TI (match_dup 2)))
5183 (sign_extend:TI (minus:DI (match_dup 1)
5184 (match_dup 2))))
5185 (const_int 0))]
5186 "!TARGET_64BIT"
5187 "*
5188 {
5189 if (GET_CODE (operands[1]) == CONST_INT)
5190 {
5191 if (INTVAL (operands[1]) >= 0)
5192 return \"subi %1,%R2,%R0\;{subbo|sub,b,tsv} %%r0,%2,%0\";
5193 else
5194 return \"ldi -1,%0\;subi %1,%R2,%R0\;{subbo|sub,b,tsv} %0,%2,%0\";
5195 }
5196 else
5197 return \"sub %R1,%R2,%R0\;{subbo|sub,b,tsv} %1,%2,%0\";
5198 }"
5199 [(set_attr "type" "binary,binary")
5200 (set (attr "length")
5201 (if_then_else (eq_attr "alternative" "0")
5202 (const_int 8)
5203 (if_then_else (ge (symbol_ref "INTVAL (operands[1])")
5204 (const_int 0))
5205 (const_int 8)
5206 (const_int 12))))])
5207
5208 (define_expand "subsi3"
5209 [(set (match_operand:SI 0 "register_operand" "")
5210 (minus:SI (match_operand:SI 1 "arith11_operand" "")
5211 (match_operand:SI 2 "register_operand" "")))]
5212 ""
5213 "")
5214
5215 (define_insn ""
5216 [(set (match_operand:SI 0 "register_operand" "=r,r")
5217 (minus:SI (match_operand:SI 1 "arith11_operand" "r,I")
5218 (match_operand:SI 2 "register_operand" "r,r")))]
5219 "!TARGET_PA_20"
5220 "@
5221 sub %1,%2,%0
5222 subi %1,%2,%0"
5223 [(set_attr "type" "binary,binary")
5224 (set_attr "length" "4,4")])
5225
5226 (define_insn ""
5227 [(set (match_operand:SI 0 "register_operand" "=r,r,!q")
5228 (minus:SI (match_operand:SI 1 "arith11_operand" "r,I,!S")
5229 (match_operand:SI 2 "register_operand" "r,r,!r")))]
5230 "TARGET_PA_20"
5231 "@
5232 sub %1,%2,%0
5233 subi %1,%2,%0
5234 mtsarcm %2"
5235 [(set_attr "type" "binary,binary,move")
5236 (set_attr "length" "4,4,4")])
5237
5238 (define_insn "subvsi3"
5239 [(set (match_operand:SI 0 "register_operand" "=r,r")
5240 (minus:SI (match_operand:SI 1 "arith11_operand" "rM,I")
5241 (match_operand:SI 2 "reg_or_0_operand" "rM,rM")))
5242 (trap_if (ne (minus:DI (sign_extend:DI (match_dup 1))
5243 (sign_extend:DI (match_dup 2)))
5244 (sign_extend:DI (minus:SI (match_dup 1)
5245 (match_dup 2))))
5246 (const_int 0))]
5247 ""
5248 "@
5249 {subo|sub,tsv} %1,%2,%0
5250 {subio|subi,tsv} %1,%2,%0"
5251 [(set_attr "type" "binary,binary")
5252 (set_attr "length" "4,4")])
5253
5254 ;; Trap instructions.
5255
5256 (define_insn "trap"
5257 [(trap_if (const_int 1) (const_int 0))]
5258 ""
5259 "{addit|addi,tc},<> 1,%%r0,%%r0"
5260 [(set_attr "type" "trap")
5261 (set_attr "length" "4")])
5262
5263 ;; Clobbering a "register_operand" instead of a match_scratch
5264 ;; in operand3 of millicode calls avoids spilling %r1 and
5265 ;; produces better code.
5266
5267 ;; The mulsi3 insns set up registers for the millicode call.
5268 (define_expand "mulsi3"
5269 [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5270 (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5271 (parallel [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
5272 (clobber (match_dup 3))
5273 (clobber (reg:SI 26))
5274 (clobber (reg:SI 25))
5275 (clobber (match_dup 4))])
5276 (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5277 ""
5278 "
5279 {
5280 operands[4] = gen_rtx_REG (SImode, TARGET_64BIT ? 2 : 31);
5281 if (TARGET_PA_11 && !TARGET_DISABLE_FPREGS && !TARGET_SOFT_FLOAT)
5282 {
5283 rtx scratch = gen_reg_rtx (DImode);
5284 operands[1] = force_reg (SImode, operands[1]);
5285 operands[2] = force_reg (SImode, operands[2]);
5286 emit_insn (gen_umulsidi3 (scratch, operands[1], operands[2]));
5287 emit_insn (gen_movsi (operands[0],
5288 gen_rtx_SUBREG (SImode, scratch,
5289 GET_MODE_SIZE (SImode))));
5290 DONE;
5291 }
5292 operands[3] = gen_reg_rtx (SImode);
5293 }")
5294
5295 (define_insn "umulsidi3"
5296 [(set (match_operand:DI 0 "register_operand" "=f")
5297 (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "f"))
5298 (zero_extend:DI (match_operand:SI 2 "nonimmediate_operand" "f"))))]
5299 "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT"
5300 "xmpyu %1,%2,%0"
5301 [(set_attr "type" "fpmuldbl")
5302 (set_attr "length" "4")])
5303
5304 (define_insn ""
5305 [(set (match_operand:DI 0 "register_operand" "=f")
5306 (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "f"))
5307 (match_operand:DI 2 "uint32_operand" "f")))]
5308 "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT && !TARGET_64BIT"
5309 "xmpyu %1,%R2,%0"
5310 [(set_attr "type" "fpmuldbl")
5311 (set_attr "length" "4")])
5312
5313 (define_insn ""
5314 [(set (match_operand:DI 0 "register_operand" "=f")
5315 (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "f"))
5316 (match_operand:DI 2 "uint32_operand" "f")))]
5317 "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT && TARGET_64BIT"
5318 "xmpyu %1,%2R,%0"
5319 [(set_attr "type" "fpmuldbl")
5320 (set_attr "length" "4")])
5321
5322 (define_insn ""
5323 [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
5324 (clobber (match_operand:SI 0 "register_operand" "=a"))
5325 (clobber (reg:SI 26))
5326 (clobber (reg:SI 25))
5327 (clobber (reg:SI 31))]
5328 "!TARGET_64BIT"
5329 "* return pa_output_mul_insn (0, insn);"
5330 [(set_attr "type" "milli")
5331 (set (attr "length")
5332 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5333 (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5334
5335 (define_insn ""
5336 [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
5337 (clobber (match_operand:SI 0 "register_operand" "=a"))
5338 (clobber (reg:SI 26))
5339 (clobber (reg:SI 25))
5340 (clobber (reg:SI 2))]
5341 "TARGET_64BIT"
5342 "* return pa_output_mul_insn (0, insn);"
5343 [(set_attr "type" "milli")
5344 (set (attr "length")
5345 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5346 (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5347
5348 (define_expand "muldi3"
5349 [(set (match_operand:DI 0 "register_operand" "")
5350 (mult:DI (match_operand:DI 1 "register_operand" "")
5351 (match_operand:DI 2 "register_operand" "")))]
5352 "TARGET_64BIT && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT"
5353 "
5354 {
5355 rtx low_product = gen_reg_rtx (DImode);
5356 rtx cross_product1 = gen_reg_rtx (DImode);
5357 rtx cross_product2 = gen_reg_rtx (DImode);
5358 rtx cross_scratch = gen_reg_rtx (DImode);
5359 rtx cross_product = gen_reg_rtx (DImode);
5360 rtx op1l, op1r, op2l, op2r;
5361 rtx op1shifted, op2shifted;
5362
5363 op1shifted = gen_reg_rtx (DImode);
5364 op2shifted = gen_reg_rtx (DImode);
5365 op1l = gen_reg_rtx (SImode);
5366 op1r = gen_reg_rtx (SImode);
5367 op2l = gen_reg_rtx (SImode);
5368 op2r = gen_reg_rtx (SImode);
5369
5370 emit_move_insn (op1shifted, gen_rtx_LSHIFTRT (DImode, operands[1],
5371 GEN_INT (32)));
5372 emit_move_insn (op2shifted, gen_rtx_LSHIFTRT (DImode, operands[2],
5373 GEN_INT (32)));
5374 op1r = force_reg (SImode, gen_rtx_SUBREG (SImode, operands[1], 4));
5375 op2r = force_reg (SImode, gen_rtx_SUBREG (SImode, operands[2], 4));
5376 op1l = force_reg (SImode, gen_rtx_SUBREG (SImode, op1shifted, 4));
5377 op2l = force_reg (SImode, gen_rtx_SUBREG (SImode, op2shifted, 4));
5378
5379 /* Emit multiplies for the cross products. */
5380 emit_insn (gen_umulsidi3 (cross_product1, op2r, op1l));
5381 emit_insn (gen_umulsidi3 (cross_product2, op2l, op1r));
5382
5383 /* Emit a multiply for the low sub-word. */
5384 emit_insn (gen_umulsidi3 (low_product, copy_rtx (op2r), copy_rtx (op1r)));
5385
5386 /* Sum the cross products and shift them into proper position. */
5387 emit_insn (gen_adddi3 (cross_scratch, cross_product1, cross_product2));
5388 emit_insn (gen_ashldi3 (cross_product, cross_scratch, GEN_INT (32)));
5389
5390 /* Add the cross product to the low product and store the result
5391 into the output operand . */
5392 emit_insn (gen_adddi3 (operands[0], cross_product, low_product));
5393 DONE;
5394 }")
5395
5396 ;;; Division and mod.
5397 (define_expand "divsi3"
5398 [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5399 (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5400 (parallel [(set (reg:SI 29) (div:SI (reg:SI 26) (reg:SI 25)))
5401 (clobber (match_dup 3))
5402 (clobber (match_dup 4))
5403 (clobber (reg:SI 26))
5404 (clobber (reg:SI 25))
5405 (clobber (match_dup 5))])
5406 (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5407 ""
5408 "
5409 {
5410 operands[3] = gen_reg_rtx (SImode);
5411 if (TARGET_64BIT)
5412 {
5413 operands[5] = gen_rtx_REG (SImode, 2);
5414 operands[4] = operands[5];
5415 }
5416 else
5417 {
5418 operands[5] = gen_rtx_REG (SImode, 31);
5419 operands[4] = gen_reg_rtx (SImode);
5420 }
5421 if (GET_CODE (operands[2]) == CONST_INT && pa_emit_hpdiv_const (operands, 0))
5422 DONE;
5423 }")
5424
5425 (define_insn ""
5426 [(set (reg:SI 29)
5427 (div:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5428 (clobber (match_operand:SI 1 "register_operand" "=a"))
5429 (clobber (match_operand:SI 2 "register_operand" "=&r"))
5430 (clobber (reg:SI 26))
5431 (clobber (reg:SI 25))
5432 (clobber (reg:SI 31))]
5433 "!TARGET_64BIT"
5434 "*
5435 return pa_output_div_insn (operands, 0, insn);"
5436 [(set_attr "type" "milli")
5437 (set (attr "length")
5438 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5439 (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5440
5441 (define_insn ""
5442 [(set (reg:SI 29)
5443 (div:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5444 (clobber (match_operand:SI 1 "register_operand" "=a"))
5445 (clobber (match_operand:SI 2 "register_operand" "=&r"))
5446 (clobber (reg:SI 26))
5447 (clobber (reg:SI 25))
5448 (clobber (reg:SI 2))]
5449 "TARGET_64BIT"
5450 "*
5451 return pa_output_div_insn (operands, 0, insn);"
5452 [(set_attr "type" "milli")
5453 (set (attr "length")
5454 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5455 (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5456
5457 (define_expand "udivsi3"
5458 [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5459 (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5460 (parallel [(set (reg:SI 29) (udiv:SI (reg:SI 26) (reg:SI 25)))
5461 (clobber (match_dup 3))
5462 (clobber (match_dup 4))
5463 (clobber (reg:SI 26))
5464 (clobber (reg:SI 25))
5465 (clobber (match_dup 5))])
5466 (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5467 ""
5468 "
5469 {
5470 operands[3] = gen_reg_rtx (SImode);
5471
5472 if (TARGET_64BIT)
5473 {
5474 operands[5] = gen_rtx_REG (SImode, 2);
5475 operands[4] = operands[5];
5476 }
5477 else
5478 {
5479 operands[5] = gen_rtx_REG (SImode, 31);
5480 operands[4] = gen_reg_rtx (SImode);
5481 }
5482 if (GET_CODE (operands[2]) == CONST_INT && pa_emit_hpdiv_const (operands, 1))
5483 DONE;
5484 }")
5485
5486 (define_insn ""
5487 [(set (reg:SI 29)
5488 (udiv:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5489 (clobber (match_operand:SI 1 "register_operand" "=a"))
5490 (clobber (match_operand:SI 2 "register_operand" "=&r"))
5491 (clobber (reg:SI 26))
5492 (clobber (reg:SI 25))
5493 (clobber (reg:SI 31))]
5494 "!TARGET_64BIT"
5495 "*
5496 return pa_output_div_insn (operands, 1, insn);"
5497 [(set_attr "type" "milli")
5498 (set (attr "length")
5499 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5500 (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5501
5502 (define_insn ""
5503 [(set (reg:SI 29)
5504 (udiv:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5505 (clobber (match_operand:SI 1 "register_operand" "=a"))
5506 (clobber (match_operand:SI 2 "register_operand" "=&r"))
5507 (clobber (reg:SI 26))
5508 (clobber (reg:SI 25))
5509 (clobber (reg:SI 2))]
5510 "TARGET_64BIT"
5511 "*
5512 return pa_output_div_insn (operands, 1, insn);"
5513 [(set_attr "type" "milli")
5514 (set (attr "length")
5515 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5516 (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5517
5518 (define_expand "modsi3"
5519 [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5520 (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5521 (parallel [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
5522 (clobber (match_dup 3))
5523 (clobber (match_dup 4))
5524 (clobber (reg:SI 26))
5525 (clobber (reg:SI 25))
5526 (clobber (match_dup 5))])
5527 (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5528 ""
5529 "
5530 {
5531 if (TARGET_64BIT)
5532 {
5533 operands[5] = gen_rtx_REG (SImode, 2);
5534 operands[4] = operands[5];
5535 }
5536 else
5537 {
5538 operands[5] = gen_rtx_REG (SImode, 31);
5539 operands[4] = gen_reg_rtx (SImode);
5540 }
5541 operands[3] = gen_reg_rtx (SImode);
5542 }")
5543
5544 (define_insn ""
5545 [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
5546 (clobber (match_operand:SI 0 "register_operand" "=a"))
5547 (clobber (match_operand:SI 1 "register_operand" "=&r"))
5548 (clobber (reg:SI 26))
5549 (clobber (reg:SI 25))
5550 (clobber (reg:SI 31))]
5551 "!TARGET_64BIT"
5552 "*
5553 return pa_output_mod_insn (0, insn);"
5554 [(set_attr "type" "milli")
5555 (set (attr "length")
5556 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5557 (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5558
5559 (define_insn ""
5560 [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
5561 (clobber (match_operand:SI 0 "register_operand" "=a"))
5562 (clobber (match_operand:SI 1 "register_operand" "=&r"))
5563 (clobber (reg:SI 26))
5564 (clobber (reg:SI 25))
5565 (clobber (reg:SI 2))]
5566 "TARGET_64BIT"
5567 "*
5568 return pa_output_mod_insn (0, insn);"
5569 [(set_attr "type" "milli")
5570 (set (attr "length")
5571 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5572 (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5573
5574 (define_expand "umodsi3"
5575 [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5576 (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5577 (parallel [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
5578 (clobber (match_dup 3))
5579 (clobber (match_dup 4))
5580 (clobber (reg:SI 26))
5581 (clobber (reg:SI 25))
5582 (clobber (match_dup 5))])
5583 (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5584 ""
5585 "
5586 {
5587 if (TARGET_64BIT)
5588 {
5589 operands[5] = gen_rtx_REG (SImode, 2);
5590 operands[4] = operands[5];
5591 }
5592 else
5593 {
5594 operands[5] = gen_rtx_REG (SImode, 31);
5595 operands[4] = gen_reg_rtx (SImode);
5596 }
5597 operands[3] = gen_reg_rtx (SImode);
5598 }")
5599
5600 (define_insn ""
5601 [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
5602 (clobber (match_operand:SI 0 "register_operand" "=a"))
5603 (clobber (match_operand:SI 1 "register_operand" "=&r"))
5604 (clobber (reg:SI 26))
5605 (clobber (reg:SI 25))
5606 (clobber (reg:SI 31))]
5607 "!TARGET_64BIT"
5608 "*
5609 return pa_output_mod_insn (1, insn);"
5610 [(set_attr "type" "milli")
5611 (set (attr "length")
5612 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5613 (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5614
5615 (define_insn ""
5616 [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
5617 (clobber (match_operand:SI 0 "register_operand" "=a"))
5618 (clobber (match_operand:SI 1 "register_operand" "=&r"))
5619 (clobber (reg:SI 26))
5620 (clobber (reg:SI 25))
5621 (clobber (reg:SI 2))]
5622 "TARGET_64BIT"
5623 "*
5624 return pa_output_mod_insn (1, insn);"
5625 [(set_attr "type" "milli")
5626 (set (attr "length")
5627 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5628 (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5629
5630 ;;- and instructions
5631 ;; We define DImode `and` so with DImode `not` we can get
5632 ;; DImode `andn`. Other combinations are possible.
5633
5634 (define_expand "anddi3"
5635 [(set (match_operand:DI 0 "register_operand" "")
5636 (and:DI (match_operand:DI 1 "register_operand" "")
5637 (match_operand:DI 2 "and_operand" "")))]
5638 "TARGET_64BIT"
5639 "")
5640
5641 (define_insn ""
5642 [(set (match_operand:DI 0 "register_operand" "=r,r")
5643 (and:DI (match_operand:DI 1 "register_operand" "%?r,0")
5644 (match_operand:DI 2 "and_operand" "rO,P")))]
5645 "TARGET_64BIT"
5646 "* return pa_output_64bit_and (operands); "
5647 [(set_attr "type" "binary")
5648 (set_attr "length" "4")])
5649
5650 ; The ? for op1 makes reload prefer zdepi instead of loading a huge
5651 ; constant with ldil;ldo.
5652 (define_insn "andsi3"
5653 [(set (match_operand:SI 0 "register_operand" "=r,r")
5654 (and:SI (match_operand:SI 1 "register_operand" "%?r,0")
5655 (match_operand:SI 2 "and_operand" "rO,P")))]
5656 ""
5657 "* return pa_output_and (operands); "
5658 [(set_attr "type" "binary,shift")
5659 (set_attr "length" "4,4")])
5660
5661 (define_insn ""
5662 [(set (match_operand:DI 0 "register_operand" "=r")
5663 (and:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
5664 (match_operand:DI 2 "register_operand" "r")))]
5665 "TARGET_64BIT"
5666 "andcm %2,%1,%0"
5667 [(set_attr "type" "binary")
5668 (set_attr "length" "4")])
5669
5670 (define_insn ""
5671 [(set (match_operand:SI 0 "register_operand" "=r")
5672 (and:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
5673 (match_operand:SI 2 "register_operand" "r")))]
5674 ""
5675 "andcm %2,%1,%0"
5676 [(set_attr "type" "binary")
5677 (set_attr "length" "4")])
5678
5679 (define_expand "iordi3"
5680 [(set (match_operand:DI 0 "register_operand" "")
5681 (ior:DI (match_operand:DI 1 "register_operand" "")
5682 (match_operand:DI 2 "reg_or_cint_ior_operand" "")))]
5683 "TARGET_64BIT"
5684 "")
5685
5686 (define_insn ""
5687 [(set (match_operand:DI 0 "register_operand" "=r,r")
5688 (ior:DI (match_operand:DI 1 "register_operand" "0,0")
5689 (match_operand:DI 2 "cint_ior_operand" "M,i")))]
5690 "TARGET_64BIT"
5691 "* return pa_output_64bit_ior (operands); "
5692 [(set_attr "type" "binary,shift")
5693 (set_attr "length" "4,4")])
5694
5695 (define_insn ""
5696 [(set (match_operand:DI 0 "register_operand" "=r")
5697 (ior:DI (match_operand:DI 1 "register_operand" "%r")
5698 (match_operand:DI 2 "register_operand" "r")))]
5699 "TARGET_64BIT"
5700 "or %1,%2,%0"
5701 [(set_attr "type" "binary")
5702 (set_attr "length" "4")])
5703
5704 ;; Need a define_expand because we've run out of CONST_OK... characters.
5705 (define_expand "iorsi3"
5706 [(set (match_operand:SI 0 "register_operand" "")
5707 (ior:SI (match_operand:SI 1 "register_operand" "")
5708 (match_operand:SI 2 "reg_or_cint_ior_operand" "")))]
5709 ""
5710 "")
5711
5712 (define_insn ""
5713 [(set (match_operand:SI 0 "register_operand" "=r,r")
5714 (ior:SI (match_operand:SI 1 "register_operand" "0,0")
5715 (match_operand:SI 2 "cint_ior_operand" "M,i")))]
5716 ""
5717 "* return pa_output_ior (operands); "
5718 [(set_attr "type" "binary,shift")
5719 (set_attr "length" "4,4")])
5720
5721 (define_insn ""
5722 [(set (match_operand:SI 0 "register_operand" "=r")
5723 (ior:SI (match_operand:SI 1 "register_operand" "%r")
5724 (match_operand:SI 2 "register_operand" "r")))]
5725 ""
5726 "or %1,%2,%0"
5727 [(set_attr "type" "binary")
5728 (set_attr "length" "4")])
5729
5730 (define_expand "xordi3"
5731 [(set (match_operand:DI 0 "register_operand" "")
5732 (xor:DI (match_operand:DI 1 "register_operand" "")
5733 (match_operand:DI 2 "register_operand" "")))]
5734 "TARGET_64BIT"
5735 "")
5736
5737 (define_insn ""
5738 [(set (match_operand:DI 0 "register_operand" "=r")
5739 (xor:DI (match_operand:DI 1 "register_operand" "%r")
5740 (match_operand:DI 2 "register_operand" "r")))]
5741 "TARGET_64BIT"
5742 "xor %1,%2,%0"
5743 [(set_attr "type" "binary")
5744 (set_attr "length" "4")])
5745
5746 (define_insn "xorsi3"
5747 [(set (match_operand:SI 0 "register_operand" "=r")
5748 (xor:SI (match_operand:SI 1 "register_operand" "%r")
5749 (match_operand:SI 2 "register_operand" "r")))]
5750 ""
5751 "xor %1,%2,%0"
5752 [(set_attr "type" "binary")
5753 (set_attr "length" "4")])
5754
5755 (define_expand "negdi2"
5756 [(set (match_operand:DI 0 "register_operand" "")
5757 (neg:DI (match_operand:DI 1 "register_operand" "")))]
5758 ""
5759 "")
5760
5761 (define_insn ""
5762 [(set (match_operand:DI 0 "register_operand" "=r")
5763 (neg:DI (match_operand:DI 1 "register_operand" "r")))]
5764 "!TARGET_64BIT"
5765 "sub %%r0,%R1,%R0\;{subb|sub,b} %%r0,%1,%0"
5766 [(set_attr "type" "unary")
5767 (set_attr "length" "8")])
5768
5769 (define_insn ""
5770 [(set (match_operand:DI 0 "register_operand" "=r")
5771 (neg:DI (match_operand:DI 1 "register_operand" "r")))]
5772 "TARGET_64BIT"
5773 "sub %%r0,%1,%0"
5774 [(set_attr "type" "unary")
5775 (set_attr "length" "4")])
5776
5777 (define_expand "negvdi2"
5778 [(parallel [(set (match_operand:DI 0 "register_operand" "")
5779 (neg:DI (match_operand:DI 1 "register_operand" "")))
5780 (trap_if (ne (neg:TI (sign_extend:TI (match_dup 1)))
5781 (sign_extend:TI (neg:DI (match_dup 1))))
5782 (const_int 0))])]
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 (trap_if (ne (neg:TI (sign_extend:TI (match_dup 1)))
5790 (sign_extend:TI (neg:DI (match_dup 1))))
5791 (const_int 0))]
5792 "!TARGET_64BIT"
5793 "sub %%r0,%R1,%R0\;{subbo|sub,b,tsv} %%r0,%1,%0"
5794 [(set_attr "type" "unary")
5795 (set_attr "length" "8")])
5796
5797 (define_insn ""
5798 [(set (match_operand:DI 0 "register_operand" "=r")
5799 (neg:DI (match_operand:DI 1 "register_operand" "r")))
5800 (trap_if (ne (neg:TI (sign_extend:TI (match_dup 1)))
5801 (sign_extend:TI (neg:DI (match_dup 1))))
5802 (const_int 0))]
5803 "TARGET_64BIT"
5804 "sub,tsv %%r0,%1,%0"
5805 [(set_attr "type" "unary")
5806 (set_attr "length" "4")])
5807
5808 (define_insn "negsi2"
5809 [(set (match_operand:SI 0 "register_operand" "=r")
5810 (neg:SI (match_operand:SI 1 "register_operand" "r")))]
5811 ""
5812 "sub %%r0,%1,%0"
5813 [(set_attr "type" "unary")
5814 (set_attr "length" "4")])
5815
5816 (define_insn "negvsi2"
5817 [(set (match_operand:SI 0 "register_operand" "=r")
5818 (neg:SI (match_operand:SI 1 "register_operand" "r")))
5819 (trap_if (ne (neg:DI (sign_extend:DI (match_dup 1)))
5820 (sign_extend:DI (neg:SI (match_dup 1))))
5821 (const_int 0))]
5822 ""
5823 "{subo|sub,tsv} %%r0,%1,%0"
5824 [(set_attr "type" "unary")
5825 (set_attr "length" "4")])
5826
5827 (define_expand "one_cmpldi2"
5828 [(set (match_operand:DI 0 "register_operand" "")
5829 (not:DI (match_operand:DI 1 "register_operand" "")))]
5830 ""
5831 "
5832 {
5833 }")
5834
5835 (define_insn ""
5836 [(set (match_operand:DI 0 "register_operand" "=r")
5837 (not:DI (match_operand:DI 1 "register_operand" "r")))]
5838 "!TARGET_64BIT"
5839 "uaddcm %%r0,%1,%0\;uaddcm %%r0,%R1,%R0"
5840 [(set_attr "type" "unary")
5841 (set_attr "length" "8")])
5842
5843 (define_insn ""
5844 [(set (match_operand:DI 0 "register_operand" "=r")
5845 (not:DI (match_operand:DI 1 "register_operand" "r")))]
5846 "TARGET_64BIT"
5847 "uaddcm %%r0,%1,%0"
5848 [(set_attr "type" "unary")
5849 (set_attr "length" "4")])
5850
5851 (define_insn "one_cmplsi2"
5852 [(set (match_operand:SI 0 "register_operand" "=r")
5853 (not:SI (match_operand:SI 1 "register_operand" "r")))]
5854 ""
5855 "uaddcm %%r0,%1,%0"
5856 [(set_attr "type" "unary")
5857 (set_attr "length" "4")])
5858 \f
5859 ;; Floating point arithmetic instructions.
5860
5861 (define_insn "adddf3"
5862 [(set (match_operand:DF 0 "register_operand" "=f")
5863 (plus:DF (match_operand:DF 1 "register_operand" "f")
5864 (match_operand:DF 2 "register_operand" "f")))]
5865 "! TARGET_SOFT_FLOAT"
5866 "fadd,dbl %1,%2,%0"
5867 [(set_attr "type" "fpalu")
5868 (set_attr "pa_combine_type" "faddsub")
5869 (set_attr "length" "4")])
5870
5871 (define_insn "addsf3"
5872 [(set (match_operand:SF 0 "register_operand" "=f")
5873 (plus:SF (match_operand:SF 1 "register_operand" "f")
5874 (match_operand:SF 2 "register_operand" "f")))]
5875 "! TARGET_SOFT_FLOAT"
5876 "fadd,sgl %1,%2,%0"
5877 [(set_attr "type" "fpalu")
5878 (set_attr "pa_combine_type" "faddsub")
5879 (set_attr "length" "4")])
5880
5881 (define_insn "subdf3"
5882 [(set (match_operand:DF 0 "register_operand" "=f")
5883 (minus:DF (match_operand:DF 1 "register_operand" "f")
5884 (match_operand:DF 2 "register_operand" "f")))]
5885 "! TARGET_SOFT_FLOAT"
5886 "fsub,dbl %1,%2,%0"
5887 [(set_attr "type" "fpalu")
5888 (set_attr "pa_combine_type" "faddsub")
5889 (set_attr "length" "4")])
5890
5891 (define_insn "subsf3"
5892 [(set (match_operand:SF 0 "register_operand" "=f")
5893 (minus:SF (match_operand:SF 1 "register_operand" "f")
5894 (match_operand:SF 2 "register_operand" "f")))]
5895 "! TARGET_SOFT_FLOAT"
5896 "fsub,sgl %1,%2,%0"
5897 [(set_attr "type" "fpalu")
5898 (set_attr "pa_combine_type" "faddsub")
5899 (set_attr "length" "4")])
5900
5901 (define_insn "muldf3"
5902 [(set (match_operand:DF 0 "register_operand" "=f")
5903 (mult:DF (match_operand:DF 1 "register_operand" "f")
5904 (match_operand:DF 2 "register_operand" "f")))]
5905 "! TARGET_SOFT_FLOAT"
5906 "fmpy,dbl %1,%2,%0"
5907 [(set_attr "type" "fpmuldbl")
5908 (set_attr "pa_combine_type" "fmpy")
5909 (set_attr "length" "4")])
5910
5911 (define_insn "mulsf3"
5912 [(set (match_operand:SF 0 "register_operand" "=f")
5913 (mult:SF (match_operand:SF 1 "register_operand" "f")
5914 (match_operand:SF 2 "register_operand" "f")))]
5915 "! TARGET_SOFT_FLOAT"
5916 "fmpy,sgl %1,%2,%0"
5917 [(set_attr "type" "fpmulsgl")
5918 (set_attr "pa_combine_type" "fmpy")
5919 (set_attr "length" "4")])
5920
5921 (define_insn "divdf3"
5922 [(set (match_operand:DF 0 "register_operand" "=f")
5923 (div:DF (match_operand:DF 1 "register_operand" "f")
5924 (match_operand:DF 2 "register_operand" "f")))]
5925 "! TARGET_SOFT_FLOAT"
5926 "fdiv,dbl %1,%2,%0"
5927 [(set_attr "type" "fpdivdbl")
5928 (set_attr "length" "4")])
5929
5930 (define_insn "divsf3"
5931 [(set (match_operand:SF 0 "register_operand" "=f")
5932 (div:SF (match_operand:SF 1 "register_operand" "f")
5933 (match_operand:SF 2 "register_operand" "f")))]
5934 "! TARGET_SOFT_FLOAT"
5935 "fdiv,sgl %1,%2,%0"
5936 [(set_attr "type" "fpdivsgl")
5937 (set_attr "length" "4")])
5938
5939 ;; Processors prior to PA 2.0 don't have a fneg instruction. Fast
5940 ;; negation can be done by subtracting from plus zero. However, this
5941 ;; violates the IEEE standard when negating plus and minus zero.
5942 ;; The slow path toggles the sign bit in the general registers.
5943 (define_expand "negdf2"
5944 [(set (match_operand:DF 0 "register_operand" "")
5945 (neg:DF (match_operand:DF 1 "register_operand" "")))]
5946 "!TARGET_SOFT_FLOAT"
5947 {
5948 if (TARGET_PA_20 || !flag_signed_zeros)
5949 emit_insn (gen_negdf2_fast (operands[0], operands[1]));
5950 else
5951 emit_insn (gen_negdf2_slow (operands[0], operands[1]));
5952 DONE;
5953 })
5954
5955 (define_insn "negdf2_slow"
5956 [(set (match_operand:DF 0 "register_operand" "=r")
5957 (neg:DF (match_operand:DF 1 "register_operand" "r")))]
5958 "!TARGET_SOFT_FLOAT && !TARGET_PA_20"
5959 "*
5960 {
5961 if (rtx_equal_p (operands[0], operands[1]))
5962 return \"and,< %1,%1,%0\;depi,tr 1,0,1,%0\;depi 0,0,1,%0\";
5963 else
5964 return \"and,< %1,%1,%0\;depi,tr 1,0,1,%0\;depi 0,0,1,%0\;copy %R1,%R0\";
5965 }"
5966 [(set_attr "type" "multi")
5967 (set (attr "length")
5968 (if_then_else (match_test "rtx_equal_p (operands[0], operands[1])")
5969 (const_int 12)
5970 (const_int 16)))])
5971
5972 (define_insn "negdf2_fast"
5973 [(set (match_operand:DF 0 "register_operand" "=f")
5974 (neg:DF (match_operand:DF 1 "register_operand" "f")))]
5975 "!TARGET_SOFT_FLOAT"
5976 "*
5977 {
5978 if (TARGET_PA_20)
5979 return \"fneg,dbl %1,%0\";
5980 else
5981 return \"fsub,dbl %%fr0,%1,%0\";
5982 }"
5983 [(set_attr "type" "fpalu")
5984 (set_attr "length" "4")])
5985
5986 (define_expand "negsf2"
5987 [(set (match_operand:SF 0 "register_operand" "")
5988 (neg:SF (match_operand:SF 1 "register_operand" "")))]
5989 "!TARGET_SOFT_FLOAT"
5990 {
5991 if (TARGET_PA_20 || !flag_signed_zeros)
5992 emit_insn (gen_negsf2_fast (operands[0], operands[1]));
5993 else
5994 emit_insn (gen_negsf2_slow (operands[0], operands[1]));
5995 DONE;
5996 })
5997
5998 (define_insn "negsf2_slow"
5999 [(set (match_operand:SF 0 "register_operand" "=r")
6000 (neg:SF (match_operand:SF 1 "register_operand" "r")))]
6001 "!TARGET_SOFT_FLOAT && !TARGET_PA_20"
6002 "and,< %1,%1,%0\;depi,tr 1,0,1,%0\;depi 0,0,1,%0"
6003 [(set_attr "type" "multi")
6004 (set_attr "length" "12")])
6005
6006 (define_insn "negsf2_fast"
6007 [(set (match_operand:SF 0 "register_operand" "=f")
6008 (neg:SF (match_operand:SF 1 "register_operand" "f")))]
6009 "!TARGET_SOFT_FLOAT"
6010 "*
6011 {
6012 if (TARGET_PA_20)
6013 return \"fneg,sgl %1,%0\";
6014 else
6015 return \"fsub,sgl %%fr0,%1,%0\";
6016 }"
6017 [(set_attr "type" "fpalu")
6018 (set_attr "length" "4")])
6019
6020 (define_insn "absdf2"
6021 [(set (match_operand:DF 0 "register_operand" "=f")
6022 (abs:DF (match_operand:DF 1 "register_operand" "f")))]
6023 "! TARGET_SOFT_FLOAT"
6024 "fabs,dbl %1,%0"
6025 [(set_attr "type" "fpalu")
6026 (set_attr "length" "4")])
6027
6028 (define_insn "abssf2"
6029 [(set (match_operand:SF 0 "register_operand" "=f")
6030 (abs:SF (match_operand:SF 1 "register_operand" "f")))]
6031 "! TARGET_SOFT_FLOAT"
6032 "fabs,sgl %1,%0"
6033 [(set_attr "type" "fpalu")
6034 (set_attr "length" "4")])
6035
6036 (define_insn "sqrtdf2"
6037 [(set (match_operand:DF 0 "register_operand" "=f")
6038 (sqrt:DF (match_operand:DF 1 "register_operand" "f")))]
6039 "! TARGET_SOFT_FLOAT"
6040 "fsqrt,dbl %1,%0"
6041 [(set_attr "type" "fpsqrtdbl")
6042 (set_attr "length" "4")])
6043
6044 (define_insn "sqrtsf2"
6045 [(set (match_operand:SF 0 "register_operand" "=f")
6046 (sqrt:SF (match_operand:SF 1 "register_operand" "f")))]
6047 "! TARGET_SOFT_FLOAT"
6048 "fsqrt,sgl %1,%0"
6049 [(set_attr "type" "fpsqrtsgl")
6050 (set_attr "length" "4")])
6051
6052 ;; PA 2.0 floating point instructions
6053
6054 ; fmpyfadd patterns
6055 (define_insn "fmadf4"
6056 [(set (match_operand:DF 0 "register_operand" "=f")
6057 (fma:DF (match_operand:DF 1 "register_operand" "f")
6058 (match_operand:DF 2 "register_operand" "f")
6059 (match_operand:DF 3 "register_operand" "f")))]
6060 "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6061 "fmpyfadd,dbl %1,%2,%3,%0"
6062 [(set_attr "type" "fpmuldbl")
6063 (set_attr "length" "4")])
6064
6065 (define_insn "fmasf4"
6066 [(set (match_operand:SF 0 "register_operand" "=f")
6067 (fma:SF (match_operand:SF 1 "register_operand" "f")
6068 (match_operand:SF 2 "register_operand" "f")
6069 (match_operand:SF 3 "register_operand" "f")))]
6070 "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6071 "fmpyfadd,sgl %1,%2,%3,%0"
6072 [(set_attr "type" "fpmulsgl")
6073 (set_attr "length" "4")])
6074
6075 ; fmpynfadd patterns
6076 (define_insn "fnmadf4"
6077 [(set (match_operand:DF 0 "register_operand" "=f")
6078 (fma:DF (neg:DF (match_operand:DF 1 "register_operand" "f"))
6079 (match_operand:DF 2 "register_operand" "f")
6080 (match_operand:DF 3 "register_operand" "f")))]
6081 "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6082 "fmpynfadd,dbl %1,%2,%3,%0"
6083 [(set_attr "type" "fpmuldbl")
6084 (set_attr "length" "4")])
6085
6086 (define_insn "fnmasf4"
6087 [(set (match_operand:SF 0 "register_operand" "=f")
6088 (fma:SF (neg:SF (match_operand:SF 1 "register_operand" "f"))
6089 (match_operand:SF 2 "register_operand" "f")
6090 (match_operand:SF 3 "register_operand" "f")))]
6091 "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6092 "fmpynfadd,sgl %1,%2,%3,%0"
6093 [(set_attr "type" "fpmulsgl")
6094 (set_attr "length" "4")])
6095
6096 ; fnegabs patterns
6097 (define_insn ""
6098 [(set (match_operand:DF 0 "register_operand" "=f")
6099 (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))]
6100 "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6101 "fnegabs,dbl %1,%0"
6102 [(set_attr "type" "fpalu")
6103 (set_attr "length" "4")])
6104
6105 (define_insn ""
6106 [(set (match_operand:SF 0 "register_operand" "=f")
6107 (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))]
6108 "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6109 "fnegabs,sgl %1,%0"
6110 [(set_attr "type" "fpalu")
6111 (set_attr "length" "4")])
6112
6113 (define_insn ""
6114 [(set (match_operand:DF 0 "register_operand" "=f")
6115 (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))
6116 (set (match_operand:DF 2 "register_operand" "=&f") (abs:DF (match_dup 1)))]
6117 "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6118 && ! reg_overlap_mentioned_p (operands[2], operands[1]))"
6119 "#"
6120 [(set_attr "type" "fpalu")
6121 (set_attr "length" "8")])
6122
6123 (define_split
6124 [(set (match_operand:DF 0 "register_operand" "")
6125 (neg:DF (abs:DF (match_operand:DF 1 "register_operand" ""))))
6126 (set (match_operand:DF 2 "register_operand" "") (abs:DF (match_dup 1)))]
6127 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6128 [(set (match_dup 2) (abs:DF (match_dup 1)))
6129 (set (match_dup 0) (neg:DF (abs:DF (match_dup 1))))]
6130 "")
6131
6132 (define_insn ""
6133 [(set (match_operand:SF 0 "register_operand" "=f")
6134 (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))
6135 (set (match_operand:SF 2 "register_operand" "=&f") (abs:SF (match_dup 1)))]
6136 "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6137 && ! reg_overlap_mentioned_p (operands[2], operands[1]))"
6138 "#"
6139 [(set_attr "type" "fpalu")
6140 (set_attr "length" "8")])
6141
6142 (define_split
6143 [(set (match_operand:SF 0 "register_operand" "")
6144 (neg:SF (abs:SF (match_operand:SF 1 "register_operand" ""))))
6145 (set (match_operand:SF 2 "register_operand" "") (abs:SF (match_dup 1)))]
6146 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6147 [(set (match_dup 2) (abs:SF (match_dup 1)))
6148 (set (match_dup 0) (neg:SF (abs:SF (match_dup 1))))]
6149 "")
6150
6151 ;; Negating a multiply can be faked by adding zero in a fused multiply-add
6152 ;; instruction if we can ignore the sign of zero.
6153 (define_insn ""
6154 [(set (match_operand:DF 0 "register_operand" "=f")
6155 (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
6156 (match_operand:DF 2 "register_operand" "f"))))]
6157 "!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros"
6158 "fmpynfadd,dbl %1,%2,%%fr0,%0"
6159 [(set_attr "type" "fpmuldbl")
6160 (set_attr "length" "4")])
6161
6162 (define_insn ""
6163 [(set (match_operand:SF 0 "register_operand" "=f")
6164 (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
6165 (match_operand:SF 2 "register_operand" "f"))))]
6166 "!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros"
6167 "fmpynfadd,sgl %1,%2,%%fr0,%0"
6168 [(set_attr "type" "fpmuldbl")
6169 (set_attr "length" "4")])
6170
6171 (define_insn ""
6172 [(set (match_operand:DF 0 "register_operand" "=f")
6173 (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
6174 (match_operand:DF 2 "register_operand" "f"))))
6175 (set (match_operand:DF 3 "register_operand" "=&f")
6176 (mult:DF (match_dup 1) (match_dup 2)))]
6177 "(!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros
6178 && ! (reg_overlap_mentioned_p (operands[3], operands[1])
6179 || reg_overlap_mentioned_p (operands[3], operands[2])))"
6180 "#"
6181 [(set_attr "type" "fpmuldbl")
6182 (set_attr "length" "8")])
6183
6184 (define_split
6185 [(set (match_operand:DF 0 "register_operand" "")
6186 (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "")
6187 (match_operand:DF 2 "register_operand" ""))))
6188 (set (match_operand:DF 3 "register_operand" "")
6189 (mult:DF (match_dup 1) (match_dup 2)))]
6190 "!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros"
6191 [(set (match_dup 3) (mult:DF (match_dup 1) (match_dup 2)))
6192 (set (match_dup 0) (neg:DF (mult:DF (match_dup 1) (match_dup 2))))]
6193 "")
6194
6195 (define_insn ""
6196 [(set (match_operand:SF 0 "register_operand" "=f")
6197 (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
6198 (match_operand:SF 2 "register_operand" "f"))))
6199 (set (match_operand:SF 3 "register_operand" "=&f")
6200 (mult:SF (match_dup 1) (match_dup 2)))]
6201 "(!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros
6202 && ! (reg_overlap_mentioned_p (operands[3], operands[1])
6203 || reg_overlap_mentioned_p (operands[3], operands[2])))"
6204 "#"
6205 [(set_attr "type" "fpmuldbl")
6206 (set_attr "length" "8")])
6207
6208 (define_split
6209 [(set (match_operand:SF 0 "register_operand" "")
6210 (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "")
6211 (match_operand:SF 2 "register_operand" ""))))
6212 (set (match_operand:SF 3 "register_operand" "")
6213 (mult:SF (match_dup 1) (match_dup 2)))]
6214 "!TARGET_SOFT_FLOAT && TARGET_PA_20&& !flag_signed_zeros"
6215 [(set (match_dup 3) (mult:SF (match_dup 1) (match_dup 2)))
6216 (set (match_dup 0) (neg:SF (mult:SF (match_dup 1) (match_dup 2))))]
6217 "")
6218 \f
6219 ;;- Shift instructions
6220
6221 ;; Optimized special case of shifting.
6222
6223 (define_insn ""
6224 [(set (match_operand:SI 0 "register_operand" "=r")
6225 (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
6226 (const_int 24)))]
6227 ""
6228 "ldb%M1 %1,%0"
6229 [(set_attr "type" "load")
6230 (set_attr "length" "4")])
6231
6232 (define_insn ""
6233 [(set (match_operand:SI 0 "register_operand" "=r")
6234 (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
6235 (const_int 16)))]
6236 ""
6237 "ldh%M1 %1,%0"
6238 [(set_attr "type" "load")
6239 (set_attr "length" "4")])
6240
6241 (define_insn ""
6242 [(set (match_operand:SI 0 "register_operand" "=r")
6243 (plus:SI (ashift:SI (match_operand:SI 2 "register_operand" "r")
6244 (match_operand:SI 3 "shadd_operand" ""))
6245 (match_operand:SI 1 "register_operand" "r")))]
6246 ""
6247 "{sh%o3addl %2,%1,%0|shladd,l %2,%o3,%1,%0} "
6248 [(set_attr "type" "binary")
6249 (set_attr "length" "4")])
6250
6251 (define_insn ""
6252 [(set (match_operand:DI 0 "register_operand" "=r")
6253 (plus:DI (ashift:DI (match_operand:DI 2 "register_operand" "r")
6254 (match_operand:DI 3 "shadd_operand" ""))
6255 (match_operand:DI 1 "register_operand" "r")))]
6256 "TARGET_64BIT"
6257 "shladd,l %2,%o3,%1,%0"
6258 [(set_attr "type" "binary")
6259 (set_attr "length" "4")])
6260
6261 (define_expand "ashlsi3"
6262 [(set (match_operand:SI 0 "register_operand" "")
6263 (ashift:SI (match_operand:SI 1 "lhs_lshift_operand" "")
6264 (match_operand:SI 2 "arith32_operand" "")))]
6265 ""
6266 "
6267 {
6268 if (GET_CODE (operands[2]) != CONST_INT)
6269 {
6270 rtx temp = gen_reg_rtx (SImode);
6271 emit_insn (gen_subsi3 (temp, GEN_INT (31), operands[2]));
6272 if (GET_CODE (operands[1]) == CONST_INT)
6273 emit_insn (gen_zvdep_imm32 (operands[0], operands[1], temp));
6274 else
6275 emit_insn (gen_zvdep32 (operands[0], operands[1], temp));
6276 DONE;
6277 }
6278 /* Make sure both inputs are not constants,
6279 there are no patterns for that. */
6280 operands[1] = force_reg (SImode, operands[1]);
6281 }")
6282
6283 (define_insn ""
6284 [(set (match_operand:SI 0 "register_operand" "=r")
6285 (ashift:SI (match_operand:SI 1 "register_operand" "r")
6286 (match_operand:SI 2 "const_int_operand" "n")))]
6287 ""
6288 "{zdep|depw,z} %1,%P2,%L2,%0"
6289 [(set_attr "type" "shift")
6290 (set_attr "length" "4")])
6291
6292 ; Match cases of op1 a CONST_INT here that zvdep_imm32 doesn't handle.
6293 ; Doing it like this makes slightly better code since reload can
6294 ; replace a register with a known value in range -16..15 with a
6295 ; constant. Ideally, we would like to merge zvdep32 and zvdep_imm32,
6296 ; but since we have no more CONST_OK... characters, that is not
6297 ; possible.
6298 (define_insn "zvdep32"
6299 [(set (match_operand:SI 0 "register_operand" "=r,r")
6300 (ashift:SI (match_operand:SI 1 "arith5_operand" "r,L")
6301 (minus:SI (const_int 31)
6302 (match_operand:SI 2 "register_operand" "q,q"))))]
6303 ""
6304 "@
6305 {zvdep %1,32,%0|depw,z %1,%%sar,32,%0}
6306 {zvdepi %1,32,%0|depwi,z %1,%%sar,32,%0}"
6307 [(set_attr "type" "shift,shift")
6308 (set_attr "length" "4,4")])
6309
6310 (define_insn "zvdep_imm32"
6311 [(set (match_operand:SI 0 "register_operand" "=r")
6312 (ashift:SI (match_operand:SI 1 "lhs_lshift_cint_operand" "")
6313 (minus:SI (const_int 31)
6314 (match_operand:SI 2 "register_operand" "q"))))]
6315 ""
6316 "*
6317 {
6318 unsigned HOST_WIDE_INT x = UINTVAL (operands[1]);
6319 operands[2] = GEN_INT (4 + exact_log2 ((x >> 4) + 1));
6320 operands[1] = GEN_INT ((x & 0xf) - 0x10);
6321 return \"{zvdepi %1,%2,%0|depwi,z %1,%%sar,%2,%0}\";
6322 }"
6323 [(set_attr "type" "shift")
6324 (set_attr "length" "4")])
6325
6326 (define_insn "vdepi_ior"
6327 [(set (match_operand:SI 0 "register_operand" "=r")
6328 (ior:SI (ashift:SI (match_operand:SI 1 "const_int_operand" "")
6329 (minus:SI (const_int 31)
6330 (match_operand:SI 2 "register_operand" "q")))
6331 (match_operand:SI 3 "register_operand" "0")))]
6332 ; accept ...0001...1, can this be generalized?
6333 "exact_log2 (INTVAL (operands[1]) + 1) > 0"
6334 "*
6335 {
6336 HOST_WIDE_INT x = INTVAL (operands[1]);
6337 operands[2] = GEN_INT (exact_log2 (x + 1));
6338 return \"{vdepi -1,%2,%0|depwi -1,%%sar,%2,%0}\";
6339 }"
6340 [(set_attr "type" "shift")
6341 (set_attr "length" "4")])
6342
6343 (define_insn "vdepi_and"
6344 [(set (match_operand:SI 0 "register_operand" "=r")
6345 (and:SI (rotate:SI (match_operand:SI 1 "const_int_operand" "")
6346 (minus:SI (const_int 31)
6347 (match_operand:SI 2 "register_operand" "q")))
6348 (match_operand:SI 3 "register_operand" "0")))]
6349 ; this can be generalized...!
6350 "INTVAL (operands[1]) == -2"
6351 "*
6352 {
6353 HOST_WIDE_INT x = INTVAL (operands[1]);
6354 operands[2] = GEN_INT (exact_log2 ((~x) + 1));
6355 return \"{vdepi 0,%2,%0|depwi 0,%%sar,%2,%0}\";
6356 }"
6357 [(set_attr "type" "shift")
6358 (set_attr "length" "4")])
6359
6360 (define_expand "ashldi3"
6361 [(set (match_operand:DI 0 "register_operand" "")
6362 (ashift:DI (match_operand:DI 1 "lhs_lshift_operand" "")
6363 (match_operand:DI 2 "arith32_operand" "")))]
6364 "TARGET_64BIT"
6365 "
6366 {
6367 if (GET_CODE (operands[2]) != CONST_INT)
6368 {
6369 rtx temp = gen_reg_rtx (DImode);
6370 emit_insn (gen_subdi3 (temp, GEN_INT (63), operands[2]));
6371 if (GET_CODE (operands[1]) == CONST_INT)
6372 emit_insn (gen_zvdep_imm64 (operands[0], operands[1], temp));
6373 else
6374 emit_insn (gen_zvdep64 (operands[0], operands[1], temp));
6375 DONE;
6376 }
6377 /* Make sure both inputs are not constants,
6378 there are no patterns for that. */
6379 operands[1] = force_reg (DImode, operands[1]);
6380 }")
6381
6382 (define_insn ""
6383 [(set (match_operand:DI 0 "register_operand" "=r")
6384 (ashift:DI (match_operand:DI 1 "register_operand" "r")
6385 (match_operand:DI 2 "const_int_operand" "n")))]
6386 "TARGET_64BIT"
6387 "depd,z %1,%p2,%Q2,%0"
6388 [(set_attr "type" "shift")
6389 (set_attr "length" "4")])
6390
6391 ; Match cases of op1 a CONST_INT here that zvdep_imm64 doesn't handle.
6392 ; Doing it like this makes slightly better code since reload can
6393 ; replace a register with a known value in range -16..15 with a
6394 ; constant. Ideally, we would like to merge zvdep64 and zvdep_imm64,
6395 ; but since we have no more CONST_OK... characters, that is not
6396 ; possible.
6397 (define_insn "zvdep64"
6398 [(set (match_operand:DI 0 "register_operand" "=r,r")
6399 (ashift:DI (match_operand:DI 1 "arith5_operand" "r,L")
6400 (minus:DI (const_int 63)
6401 (match_operand:DI 2 "register_operand" "q,q"))))]
6402 "TARGET_64BIT"
6403 "@
6404 depd,z %1,%%sar,64,%0
6405 depdi,z %1,%%sar,64,%0"
6406 [(set_attr "type" "shift,shift")
6407 (set_attr "length" "4,4")])
6408
6409 (define_insn "zvdep_imm64"
6410 [(set (match_operand:DI 0 "register_operand" "=r")
6411 (ashift:DI (match_operand:DI 1 "lhs_lshift_cint_operand" "")
6412 (minus:DI (const_int 63)
6413 (match_operand:DI 2 "register_operand" "q"))))]
6414 "TARGET_64BIT"
6415 "*
6416 {
6417 unsigned HOST_WIDE_INT x = UINTVAL (operands[1]);
6418 operands[2] = GEN_INT (4 + exact_log2 ((x >> 4) + 1));
6419 operands[1] = GEN_INT ((x & 0x1f) - 0x20);
6420 return \"depdi,z %1,%%sar,%2,%0\";
6421 }"
6422 [(set_attr "type" "shift")
6423 (set_attr "length" "4")])
6424
6425 (define_insn ""
6426 [(set (match_operand:DI 0 "register_operand" "=r")
6427 (ior:DI (ashift:DI (match_operand:DI 1 "const_int_operand" "")
6428 (minus:DI (const_int 63)
6429 (match_operand:DI 2 "register_operand" "q")))
6430 (match_operand:DI 3 "register_operand" "0")))]
6431 ; accept ...0001...1, can this be generalized?
6432 "TARGET_64BIT && exact_log2 (INTVAL (operands[1]) + 1) > 0"
6433 "*
6434 {
6435 HOST_WIDE_INT x = INTVAL (operands[1]);
6436 operands[2] = GEN_INT (exact_log2 (x + 1));
6437 return \"depdi -1,%%sar,%2,%0\";
6438 }"
6439 [(set_attr "type" "shift")
6440 (set_attr "length" "4")])
6441
6442 (define_insn ""
6443 [(set (match_operand:DI 0 "register_operand" "=r")
6444 (and:DI (rotate:DI (match_operand:DI 1 "const_int_operand" "")
6445 (minus:DI (const_int 63)
6446 (match_operand:DI 2 "register_operand" "q")))
6447 (match_operand:DI 3 "register_operand" "0")))]
6448 ; this can be generalized...!
6449 "TARGET_64BIT && INTVAL (operands[1]) == -2"
6450 "*
6451 {
6452 HOST_WIDE_INT x = INTVAL (operands[1]);
6453 operands[2] = GEN_INT (exact_log2 ((~x) + 1));
6454 return \"depdi 0,%%sar,%2,%0\";
6455 }"
6456 [(set_attr "type" "shift")
6457 (set_attr "length" "4")])
6458
6459 (define_expand "ashrsi3"
6460 [(set (match_operand:SI 0 "register_operand" "")
6461 (ashiftrt:SI (match_operand:SI 1 "register_operand" "")
6462 (match_operand:SI 2 "arith32_operand" "")))]
6463 ""
6464 "
6465 {
6466 if (GET_CODE (operands[2]) != CONST_INT)
6467 {
6468 rtx temp = gen_reg_rtx (SImode);
6469 emit_insn (gen_subsi3 (temp, GEN_INT (31), operands[2]));
6470 emit_insn (gen_vextrs32 (operands[0], operands[1], temp));
6471 DONE;
6472 }
6473 }")
6474
6475 (define_insn ""
6476 [(set (match_operand:SI 0 "register_operand" "=r")
6477 (ashiftrt:SI (match_operand:SI 1 "register_operand" "r")
6478 (match_operand:SI 2 "const_int_operand" "n")))]
6479 ""
6480 "{extrs|extrw,s} %1,%P2,%L2,%0"
6481 [(set_attr "type" "shift")
6482 (set_attr "length" "4")])
6483
6484 (define_insn "vextrs32"
6485 [(set (match_operand:SI 0 "register_operand" "=r")
6486 (ashiftrt:SI (match_operand:SI 1 "register_operand" "r")
6487 (minus:SI (const_int 31)
6488 (match_operand:SI 2 "register_operand" "q"))))]
6489 ""
6490 "{vextrs %1,32,%0|extrw,s %1,%%sar,32,%0}"
6491 [(set_attr "type" "shift")
6492 (set_attr "length" "4")])
6493
6494 (define_expand "ashrdi3"
6495 [(set (match_operand:DI 0 "register_operand" "")
6496 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
6497 (match_operand:DI 2 "arith32_operand" "")))]
6498 "TARGET_64BIT"
6499 "
6500 {
6501 if (GET_CODE (operands[2]) != CONST_INT)
6502 {
6503 rtx temp = gen_reg_rtx (DImode);
6504 emit_insn (gen_subdi3 (temp, GEN_INT (63), operands[2]));
6505 emit_insn (gen_vextrs64 (operands[0], operands[1], temp));
6506 DONE;
6507 }
6508 }")
6509
6510 (define_insn ""
6511 [(set (match_operand:DI 0 "register_operand" "=r")
6512 (ashiftrt:DI (match_operand:DI 1 "register_operand" "r")
6513 (match_operand:DI 2 "const_int_operand" "n")))]
6514 "TARGET_64BIT"
6515 "extrd,s %1,%p2,%Q2,%0"
6516 [(set_attr "type" "shift")
6517 (set_attr "length" "4")])
6518
6519 (define_insn "vextrs64"
6520 [(set (match_operand:DI 0 "register_operand" "=r")
6521 (ashiftrt:DI (match_operand:DI 1 "register_operand" "r")
6522 (minus:DI (const_int 63)
6523 (match_operand:DI 2 "register_operand" "q"))))]
6524 "TARGET_64BIT"
6525 "extrd,s %1,%%sar,64,%0"
6526 [(set_attr "type" "shift")
6527 (set_attr "length" "4")])
6528
6529 (define_insn "lshrsi3"
6530 [(set (match_operand:SI 0 "register_operand" "=r,r")
6531 (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
6532 (match_operand:SI 2 "shift5_operand" "q,n")))]
6533 ""
6534 "@
6535 {vshd %%r0,%1,%0|shrpw %%r0,%1,%%sar,%0}
6536 {extru|extrw,u} %1,%P2,%L2,%0"
6537 [(set_attr "type" "shift")
6538 (set_attr "length" "4")])
6539
6540 (define_insn "lshrdi3"
6541 [(set (match_operand:DI 0 "register_operand" "=r,r")
6542 (lshiftrt:DI (match_operand:DI 1 "register_operand" "r,r")
6543 (match_operand:DI 2 "shift6_operand" "q,n")))]
6544 "TARGET_64BIT"
6545 "@
6546 shrpd %%r0,%1,%%sar,%0
6547 extrd,u %1,%p2,%Q2,%0"
6548 [(set_attr "type" "shift")
6549 (set_attr "length" "4")])
6550
6551 ; Shift right pair word 0 to 31 bits.
6552 (define_insn "shrpsi4"
6553 [(set (match_operand:SI 0 "register_operand" "=r,r")
6554 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "r,r")
6555 (minus:SI (const_int 32)
6556 (match_operand:SI 3 "shift5_operand" "q,n")))
6557 (lshiftrt:SI (match_operand:SI 2 "register_operand" "r,r")
6558 (match_dup 3))))]
6559 ""
6560 "@
6561 {vshd %1,%2,%0|shrpw %1,%2,%%sar,%0}
6562 {shd|shrpw} %1,%2,%3,%0"
6563 [(set_attr "type" "shift")
6564 (set_attr "length" "4")])
6565
6566 ; Shift right pair doubleword 0 to 63 bits.
6567 (define_insn "shrpdi4"
6568 [(set (match_operand:DI 0 "register_operand" "=r,r")
6569 (ior:DI (ashift:DI (match_operand:SI 1 "register_operand" "r,r")
6570 (minus:DI (const_int 64)
6571 (match_operand:DI 3 "shift6_operand" "q,n")))
6572 (lshiftrt:DI (match_operand:DI 2 "register_operand" "r,r")
6573 (match_dup 3))))]
6574 "TARGET_64BIT"
6575 "@
6576 shrpd %1,%2,%%sar,%0
6577 shrpd %1,%2,%3,%0"
6578 [(set_attr "type" "shift")
6579 (set_attr "length" "4")])
6580
6581 (define_insn "rotrsi3"
6582 [(set (match_operand:SI 0 "register_operand" "=r,r")
6583 (rotatert:SI (match_operand:SI 1 "register_operand" "r,r")
6584 (match_operand:SI 2 "shift5_operand" "q,n")))]
6585 ""
6586 "*
6587 {
6588 if (GET_CODE (operands[2]) == CONST_INT)
6589 {
6590 operands[2] = GEN_INT (INTVAL (operands[2]) & 31);
6591 return \"{shd|shrpw} %1,%1,%2,%0\";
6592 }
6593 else
6594 return \"{vshd %1,%1,%0|shrpw %1,%1,%%sar,%0}\";
6595 }"
6596 [(set_attr "type" "shift")
6597 (set_attr "length" "4")])
6598
6599 (define_expand "rotlsi3"
6600 [(set (match_operand:SI 0 "register_operand" "")
6601 (rotate:SI (match_operand:SI 1 "register_operand" "")
6602 (match_operand:SI 2 "arith32_operand" "")))]
6603 ""
6604 "
6605 {
6606 if (GET_CODE (operands[2]) != CONST_INT)
6607 {
6608 rtx temp = gen_reg_rtx (SImode);
6609 emit_insn (gen_subsi3 (temp, GEN_INT (32), operands[2]));
6610 emit_insn (gen_rotrsi3 (operands[0], operands[1], temp));
6611 DONE;
6612 }
6613 /* Else expand normally. */
6614 }")
6615
6616 (define_insn ""
6617 [(set (match_operand:SI 0 "register_operand" "=r")
6618 (rotate:SI (match_operand:SI 1 "register_operand" "r")
6619 (match_operand:SI 2 "const_int_operand" "n")))]
6620 ""
6621 "*
6622 {
6623 operands[2] = GEN_INT ((32 - INTVAL (operands[2])) & 31);
6624 return \"{shd|shrpw} %1,%1,%2,%0\";
6625 }"
6626 [(set_attr "type" "shift")
6627 (set_attr "length" "4")])
6628
6629 (define_insn ""
6630 [(set (match_operand:SI 0 "register_operand" "=r")
6631 (match_operator:SI 5 "plus_xor_ior_operator"
6632 [(ashift:SI (match_operand:SI 1 "register_operand" "r")
6633 (match_operand:SI 3 "const_int_operand" "n"))
6634 (lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
6635 (match_operand:SI 4 "const_int_operand" "n"))]))]
6636 "INTVAL (operands[3]) + INTVAL (operands[4]) == 32"
6637 "{shd|shrpw} %1,%2,%4,%0"
6638 [(set_attr "type" "shift")
6639 (set_attr "length" "4")])
6640
6641 (define_insn ""
6642 [(set (match_operand:SI 0 "register_operand" "=r")
6643 (match_operator:SI 5 "plus_xor_ior_operator"
6644 [(lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
6645 (match_operand:SI 4 "const_int_operand" "n"))
6646 (ashift:SI (match_operand:SI 1 "register_operand" "r")
6647 (match_operand:SI 3 "const_int_operand" "n"))]))]
6648 "INTVAL (operands[3]) + INTVAL (operands[4]) == 32"
6649 "{shd|shrpw} %1,%2,%4,%0"
6650 [(set_attr "type" "shift")
6651 (set_attr "length" "4")])
6652
6653 (define_insn ""
6654 [(set (match_operand:SI 0 "register_operand" "=r")
6655 (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
6656 (match_operand:SI 2 "const_int_operand" ""))
6657 (match_operand:SI 3 "const_int_operand" "")))]
6658 "exact_log2 (1 + (INTVAL (operands[3]) >> (INTVAL (operands[2]) & 31))) > 0"
6659 "*
6660 {
6661 int cnt = INTVAL (operands[2]) & 31;
6662 operands[3] = GEN_INT (exact_log2 (1 + (INTVAL (operands[3]) >> cnt)));
6663 operands[2] = GEN_INT (31 - cnt);
6664 return \"{zdep|depw,z} %1,%2,%3,%0\";
6665 }"
6666 [(set_attr "type" "shift")
6667 (set_attr "length" "4")])
6668 \f
6669 ;; Unconditional and other jump instructions.
6670
6671 ;; Trivial return used when no epilogue is needed.
6672 (define_insn "return"
6673 [(return)
6674 (use (reg:SI 2))]
6675 "pa_can_use_return_insn ()"
6676 "*
6677 {
6678 if (TARGET_PA_20)
6679 return \"bve%* (%%r2)\";
6680 return \"bv%* %%r0(%%r2)\";
6681 }"
6682 [(set_attr "type" "branch")
6683 (set_attr "length" "4")])
6684
6685 ;; This is used for most returns.
6686 (define_insn "return_internal"
6687 [(return)
6688 (use (reg:SI 2))]
6689 ""
6690 "*
6691 {
6692 if (TARGET_PA_20)
6693 return \"bve%* (%%r2)\";
6694 return \"bv%* %%r0(%%r2)\";
6695 }"
6696 [(set_attr "type" "branch")
6697 (set_attr "length" "4")])
6698
6699 ;; This is used for eh returns which bypass the return stub.
6700 (define_insn "return_external_pic"
6701 [(return)
6702 (clobber (reg:SI 1))
6703 (use (reg:SI 2))]
6704 "!TARGET_NO_SPACE_REGS
6705 && !TARGET_PA_20
6706 && flag_pic && crtl->calls_eh_return"
6707 "ldsid (%%sr0,%%r2),%%r1\;mtsp %%r1,%%sr0\;be%* 0(%%sr0,%%r2)"
6708 [(set_attr "type" "branch")
6709 (set_attr "length" "12")])
6710
6711 (define_expand "prologue"
6712 [(const_int 0)]
6713 ""
6714 "pa_expand_prologue ();DONE;")
6715
6716 (define_expand "sibcall_epilogue"
6717 [(return)]
6718 ""
6719 "
6720 {
6721 pa_expand_epilogue ();
6722 DONE;
6723 }")
6724
6725 (define_expand "epilogue"
6726 [(return)]
6727 ""
6728 "
6729 {
6730 rtx x;
6731
6732 /* Try to use the trivial return first. Else use the full epilogue. */
6733 if (pa_can_use_return_insn ())
6734 x = gen_return ();
6735 else
6736 {
6737 pa_expand_epilogue ();
6738
6739 /* EH returns bypass the normal return stub. Thus, we must do an
6740 interspace branch to return from functions that call eh_return.
6741 This is only a problem for returns from shared code on ports
6742 using space registers. */
6743 if (!TARGET_NO_SPACE_REGS
6744 && !TARGET_PA_20
6745 && flag_pic && crtl->calls_eh_return)
6746 x = gen_return_external_pic ();
6747 else
6748 x = gen_return_internal ();
6749 }
6750 emit_jump_insn (x);
6751 DONE;
6752 }")
6753
6754 ; Used by hppa_profile_hook to load the starting address of the current
6755 ; function; operand 1 contains the address of the label in operand 3
6756 (define_insn "load_offset_label_address"
6757 [(set (match_operand:SI 0 "register_operand" "=r")
6758 (plus:SI (match_operand:SI 1 "register_operand" "r")
6759 (minus:SI (match_operand:SI 2 "" "")
6760 (label_ref:SI (match_operand 3 "" "")))))]
6761 ""
6762 "ldo %2-%l3(%1),%0"
6763 [(set_attr "type" "multi")
6764 (set_attr "length" "4")])
6765
6766 ; Output a code label and load its address.
6767 (define_insn "lcla1"
6768 [(set (match_operand:SI 0 "register_operand" "=r")
6769 (label_ref:SI (match_operand 1 "" "")))
6770 (const_int 0)]
6771 "!TARGET_PA_20"
6772 "*
6773 {
6774 output_asm_insn (\"bl .+8,%0\;depi 0,31,2,%0\", operands);
6775 (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
6776 CODE_LABEL_NUMBER (operands[1]));
6777 return \"\";
6778 }"
6779 [(set_attr "type" "multi")
6780 (set_attr "length" "8")])
6781
6782 (define_insn "lcla2"
6783 [(set (match_operand:SI 0 "register_operand" "=r")
6784 (label_ref:SI (match_operand 1 "" "")))
6785 (const_int 0)]
6786 "TARGET_PA_20"
6787 "*
6788 {
6789 (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
6790 CODE_LABEL_NUMBER (operands[1]));
6791 return \"mfia %0\";
6792 }"
6793 [(set_attr "type" "move")
6794 (set_attr "length" "4")])
6795
6796 (define_insn "blockage"
6797 [(unspec_volatile [(const_int 2)] UNSPECV_BLOCKAGE)]
6798 ""
6799 ""
6800 [(set_attr "length" "0")])
6801
6802 (define_insn "jump"
6803 [(set (pc) (label_ref (match_operand 0 "" "")))]
6804 ""
6805 "*
6806 {
6807 /* An unconditional branch which can reach its target. */
6808 if (get_attr_length (insn) < 16)
6809 return \"b%* %l0\";
6810
6811 return pa_output_lbranch (operands[0], insn, 1);
6812 }"
6813 [(set_attr "type" "uncond_branch")
6814 (set_attr "pa_combine_type" "uncond_branch")
6815 (set (attr "length")
6816 (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
6817 (const_int MAX_17BIT_OFFSET))
6818 (const_int 4)
6819 (match_test "TARGET_PORTABLE_RUNTIME")
6820 (const_int 20)
6821 (not (match_test "flag_pic"))
6822 (const_int 16)]
6823 (const_int 24)))])
6824
6825 ;;; Hope this is only within a function...
6826 (define_insn "indirect_jump"
6827 [(set (pc) (match_operand 0 "pmode_register_operand" "r"))]
6828 ""
6829 "bv%* %%r0(%0)"
6830 [(set_attr "type" "branch")
6831 (set_attr "length" "4")])
6832
6833 ;;; An indirect jump can be optimized to a direct jump. GAS for the
6834 ;;; SOM target doesn't allow branching to a label inside a function.
6835 ;;; We also don't correctly compute branch distances for labels
6836 ;;; outside the current function. Thus, we use an indirect jump can't
6837 ;;; be optimized to a direct jump for all targets. We assume that
6838 ;;; the branch target is in the same space (i.e., nested function
6839 ;;; jumping to a label in an outer function in the same translation
6840 ;;; unit).
6841 (define_expand "nonlocal_goto"
6842 [(use (match_operand 0 "general_operand" ""))
6843 (use (match_operand 1 "general_operand" ""))
6844 (use (match_operand 2 "general_operand" ""))
6845 (use (match_operand 3 "general_operand" ""))]
6846 ""
6847 {
6848 rtx lab = operands[1];
6849 rtx stack = operands[2];
6850 rtx fp = operands[3];
6851
6852 lab = copy_to_reg (lab);
6853
6854 emit_clobber (gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (VOIDmode)));
6855 emit_clobber (gen_rtx_MEM (BLKmode, hard_frame_pointer_rtx));
6856
6857 /* Restore the frame pointer. The virtual_stack_vars_rtx is saved
6858 instead of the hard_frame_pointer_rtx in the save area. As a
6859 result, an extra instruction is needed to adjust for the offset
6860 of the virtual stack variables and the hard frame pointer. */
6861 if (GET_CODE (fp) != REG)
6862 fp = force_reg (Pmode, fp);
6863 emit_move_insn (hard_frame_pointer_rtx, plus_constant (Pmode, fp, -8));
6864
6865 emit_stack_restore (SAVE_NONLOCAL, stack);
6866
6867 emit_use (hard_frame_pointer_rtx);
6868 emit_use (stack_pointer_rtx);
6869
6870 /* Nonlocal goto jumps are only used between functions in the same
6871 translation unit. Thus, we can avoid the extra overhead of an
6872 interspace jump. */
6873 emit_jump_insn (gen_indirect_goto (lab));
6874 emit_barrier ();
6875 DONE;
6876 })
6877
6878 (define_insn "indirect_goto"
6879 [(unspec [(match_operand 0 "register_operand" "=r")] UNSPEC_GOTO)]
6880 "GET_MODE (operands[0]) == word_mode"
6881 "bv%* %%r0(%0)"
6882 [(set_attr "type" "branch")
6883 (set_attr "length" "4")])
6884
6885 ;; Subroutines of "casesi".
6886 ;; operand 0 is index
6887 ;; operand 1 is the minimum bound
6888 ;; operand 2 is the maximum bound - minimum bound + 1
6889 ;; operand 3 is CODE_LABEL for the table;
6890 ;; operand 4 is the CODE_LABEL to go to if index out of range.
6891
6892 (define_expand "casesi"
6893 [(match_operand:SI 0 "general_operand" "")
6894 (match_operand:SI 1 "const_int_operand" "")
6895 (match_operand:SI 2 "const_int_operand" "")
6896 (match_operand 3 "" "")
6897 (match_operand 4 "" "")]
6898 ""
6899 "
6900 {
6901 if (GET_CODE (operands[0]) != REG)
6902 operands[0] = force_reg (SImode, operands[0]);
6903
6904 if (operands[1] != const0_rtx)
6905 {
6906 rtx index = gen_reg_rtx (SImode);
6907
6908 operands[1] = gen_int_mode (-INTVAL (operands[1]), SImode);
6909 if (!INT_14_BITS (operands[1]))
6910 operands[1] = force_reg (SImode, operands[1]);
6911 emit_insn (gen_addsi3 (index, operands[0], operands[1]));
6912 operands[0] = index;
6913 }
6914
6915 if (!INT_5_BITS (operands[2]))
6916 operands[2] = force_reg (SImode, operands[2]);
6917
6918 /* This branch prevents us finding an insn for the delay slot of the
6919 following vectored branch. It might be possible to use the delay
6920 slot if an index value of -1 was used to transfer to the out-of-range
6921 label. In order to do this, we would have to output the -1 vector
6922 element after the delay insn. The casesi output code would have to
6923 check if the casesi insn is in a delay branch sequence and output
6924 the delay insn if one is found. If this was done, then it might
6925 then be worthwhile to split the casesi patterns to improve scheduling.
6926 However, it's not clear that all this extra complexity is worth
6927 the effort. */
6928 {
6929 rtx test = gen_rtx_GTU (VOIDmode, operands[0], operands[2]);
6930 emit_jump_insn (gen_cbranchsi4 (test, operands[0], operands[2], operands[4]));
6931 }
6932
6933 /* In 64bit mode we must make sure to wipe the upper bits of the register
6934 just in case the addition overflowed or we had random bits in the
6935 high part of the register. */
6936 if (TARGET_64BIT)
6937 {
6938 rtx index = gen_reg_rtx (DImode);
6939
6940 emit_insn (gen_extendsidi2 (index, operands[0]));
6941 operands[0] = index;
6942 }
6943
6944 if (TARGET_64BIT)
6945 emit_jump_insn (gen_casesi64p (operands[0], operands[3]));
6946 else if (flag_pic)
6947 emit_jump_insn (gen_casesi32p (operands[0], operands[3]));
6948 else
6949 emit_jump_insn (gen_casesi32 (operands[0], operands[3]));
6950 DONE;
6951 }")
6952
6953 ;;; 32-bit code, absolute branch table.
6954 (define_insn "casesi32"
6955 [(set (pc) (mem:SI (plus:SI
6956 (mult:SI (match_operand:SI 0 "register_operand" "r")
6957 (const_int 4))
6958 (label_ref (match_operand 1 "" "")))))
6959 (clobber (match_scratch:SI 2 "=&r"))]
6960 "!flag_pic"
6961 "ldil L'%l1,%2\;ldo R'%l1(%2),%2\;{ldwx|ldw},s %0(%2),%2\;bv,n %%r0(%2)"
6962 [(set_attr "type" "multi")
6963 (set_attr "length" "16")])
6964
6965 ;;; 32-bit code, relative branch table.
6966 (define_insn "casesi32p"
6967 [(set (pc) (mem:SI (plus:SI
6968 (mult:SI (match_operand:SI 0 "register_operand" "r")
6969 (const_int 4))
6970 (label_ref (match_operand 1 "" "")))))
6971 (clobber (match_scratch:SI 2 "=&r"))
6972 (clobber (match_scratch:SI 3 "=&r"))]
6973 "flag_pic"
6974 "{bl .+8,%2\;depi 0,31,2,%2|mfia %2}\;ldo {%l1-.|%l1+4-.}(%2),%2\;\
6975 {ldwx|ldw},s %0(%2),%3\;{addl|add,l} %2,%3,%3\;bv,n %%r0(%3)"
6976 [(set_attr "type" "multi")
6977 (set (attr "length")
6978 (if_then_else (match_test "TARGET_PA_20")
6979 (const_int 20)
6980 (const_int 24)))])
6981
6982 ;;; 64-bit code, 32-bit relative branch table.
6983 (define_insn "casesi64p"
6984 [(set (pc) (mem:DI (plus:DI
6985 (mult:DI (match_operand:DI 0 "register_operand" "r")
6986 (const_int 8))
6987 (label_ref (match_operand 1 "" "")))))
6988 (clobber (match_scratch:DI 2 "=&r"))
6989 (clobber (match_scratch:DI 3 "=&r"))]
6990 ""
6991 "mfia %2\;ldo %l1+4-.(%2),%2\;ldw,s %0(%2),%3\;extrd,s %3,63,32,%3\;\
6992 add,l %2,%3,%3\;bv,n %%r0(%3)"
6993 [(set_attr "type" "multi")
6994 (set_attr "length" "24")])
6995
6996
6997 ;; Call patterns.
6998 ;;- jump to subroutine
6999
7000 (define_expand "call"
7001 [(parallel [(call (match_operand:SI 0 "" "")
7002 (match_operand 1 "" ""))
7003 (clobber (reg:SI 2))])]
7004 ""
7005 "
7006 {
7007 rtx op;
7008 rtx nb = operands[1];
7009
7010 if (TARGET_PORTABLE_RUNTIME)
7011 op = force_reg (SImode, XEXP (operands[0], 0));
7012 else
7013 {
7014 op = XEXP (operands[0], 0);
7015
7016 /* Generate indirect long calls to non-local functions. */
7017 if (TARGET_LONG_CALLS && GET_CODE (op) == SYMBOL_REF)
7018 {
7019 tree call_decl = SYMBOL_REF_DECL (op);
7020 if (!(call_decl && targetm.binds_local_p (call_decl)))
7021 op = force_reg (word_mode, op);
7022 }
7023 }
7024
7025 if (TARGET_64BIT)
7026 {
7027 if (!virtuals_instantiated)
7028 emit_move_insn (arg_pointer_rtx,
7029 gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
7030 GEN_INT (64)));
7031 else
7032 {
7033 /* The loop pass can generate new libcalls after the virtual
7034 registers are instantiated when fpregs are disabled because
7035 the only method that we have for doing DImode multiplication
7036 is with a libcall. This could be trouble if we haven't
7037 allocated enough space for the outgoing arguments. */
7038 gcc_assert (INTVAL (nb) <= crtl->outgoing_args_size);
7039
7040 emit_move_insn (arg_pointer_rtx,
7041 gen_rtx_PLUS (word_mode, stack_pointer_rtx,
7042 GEN_INT (STACK_POINTER_OFFSET + 64)));
7043 }
7044 }
7045
7046 /* Use two different patterns for calls to explicitly named functions
7047 and calls through function pointers. This is necessary as these two
7048 types of calls use different calling conventions, and CSE might try
7049 to change the named call into an indirect call in some cases (using
7050 two patterns keeps CSE from performing this optimization).
7051
7052 We now use even more call patterns as there was a subtle bug in
7053 attempting to restore the pic register after a call using a simple
7054 move insn. During reload, a instruction involving a pseudo register
7055 with no explicit dependence on the PIC register can be converted
7056 to an equivalent load from memory using the PIC register. If we
7057 emit a simple move to restore the PIC register in the initial rtl
7058 generation, then it can potentially be repositioned during scheduling.
7059 and an instruction that eventually uses the PIC register may end up
7060 between the call and the PIC register restore.
7061
7062 This only worked because there is a post call group of instructions
7063 that are scheduled with the call. These instructions are included
7064 in the same basic block as the call. However, calls can throw in
7065 C++ code and a basic block has to terminate at the call if the call
7066 can throw. This results in the PIC register restore being scheduled
7067 independently from the call. So, we now hide the save and restore
7068 of the PIC register in the call pattern until after reload. Then,
7069 we split the moves out. A small side benefit is that we now don't
7070 need to have a use of the PIC register in the return pattern and
7071 the final save/restore operation is not needed.
7072
7073 I elected to just use register %r4 in the PIC patterns instead
7074 of trying to force hppa_pic_save_rtx () to a callee saved register.
7075 This might have required a new register class and constraint. It
7076 was also simpler to just handle the restore from a register than a
7077 generic pseudo. */
7078 if (TARGET_64BIT)
7079 {
7080 rtx r4 = gen_rtx_REG (word_mode, 4);
7081 if (GET_CODE (op) == SYMBOL_REF)
7082 emit_call_insn (gen_call_symref_64bit (op, nb, r4));
7083 else
7084 {
7085 op = force_reg (word_mode, op);
7086 emit_call_insn (gen_call_reg_64bit (op, nb, r4));
7087 }
7088 }
7089 else
7090 {
7091 if (GET_CODE (op) == SYMBOL_REF)
7092 {
7093 if (flag_pic)
7094 {
7095 rtx r4 = gen_rtx_REG (word_mode, 4);
7096 emit_call_insn (gen_call_symref_pic (op, nb, r4));
7097 }
7098 else
7099 emit_call_insn (gen_call_symref (op, nb));
7100 }
7101 else
7102 {
7103 rtx tmpreg = gen_rtx_REG (word_mode, 22);
7104 emit_move_insn (tmpreg, force_reg (word_mode, op));
7105 if (flag_pic)
7106 {
7107 rtx r4 = gen_rtx_REG (word_mode, 4);
7108 emit_call_insn (gen_call_reg_pic (nb, r4));
7109 }
7110 else
7111 emit_call_insn (gen_call_reg (nb));
7112 }
7113 }
7114
7115 DONE;
7116 }")
7117
7118 ;; We use function calls to set the attribute length of calls and millicode
7119 ;; calls. This is necessary because of the large variety of call sequences.
7120 ;; Implementing the calculation in rtl is difficult as well as ugly. As
7121 ;; we need the same calculation in several places, maintenance becomes a
7122 ;; nightmare.
7123 ;;
7124 ;; However, this has a subtle impact on branch shortening. When the
7125 ;; expression used to set the length attribute of an instruction depends
7126 ;; on a relative address (e.g., pc or a branch address), genattrtab
7127 ;; notes that the insn's length is variable, and attempts to determine a
7128 ;; worst-case default length and code to compute an insn's current length.
7129
7130 ;; The use of a function call hides the variable dependence of our calls
7131 ;; and millicode calls. The result is genattrtab doesn't treat the operation
7132 ;; as variable and it only generates code for the default case using our
7133 ;; function call. Because of this, calls and millicode calls have a fixed
7134 ;; length in the branch shortening pass, and some branches will use a longer
7135 ;; code sequence than necessary. However, the length of any given call
7136 ;; will still reflect its final code location and it may be shorter than
7137 ;; the initial length estimate.
7138
7139 ;; It's possible to trick genattrtab by adding an expression involving `pc'
7140 ;; in the set. However, when genattrtab hits a function call in its attempt
7141 ;; to compute the default length, it marks the result as unknown and sets
7142 ;; the default result to MAX_INT ;-( One possible fix that would allow
7143 ;; calls to participate in branch shortening would be to make the call to
7144 ;; insn_default_length a target option. Then, we could massage unknown
7145 ;; results. Another fix might be to change genattrtab so that it just does
7146 ;; the call in the variable case as it already does for the fixed case.
7147
7148 (define_insn "call_symref"
7149 [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7150 (match_operand 1 "" "i"))
7151 (clobber (reg:SI 1))
7152 (clobber (reg:SI 2))
7153 (use (const_int 0))]
7154 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7155 "*
7156 {
7157 pa_output_arg_descriptor (insn);
7158 return pa_output_call (insn, operands[0], 0);
7159 }"
7160 [(set_attr "type" "call")
7161 (set (attr "length")
7162 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7163 (symbol_ref "pa_attr_length_call (insn, 0)")))])
7164
7165 (define_insn "call_symref_pic"
7166 [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7167 (match_operand 1 "" "i"))
7168 (clobber (reg:SI 1))
7169 (clobber (reg:SI 2))
7170 (clobber (match_operand 2))
7171 (use (reg:SI 19))
7172 (use (const_int 0))]
7173 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7174 "#")
7175
7176 ;; Split out the PIC register save and restore after reload. As the
7177 ;; split is done after reload, there are some situations in which we
7178 ;; unnecessarily save and restore %r4. This happens when there is a
7179 ;; single call and the PIC register is not used after the call.
7180 ;;
7181 ;; The split has to be done since call_from_call_insn () can't handle
7182 ;; the pattern as is. Noreturn calls are special because they have to
7183 ;; terminate the basic block. The split has to contain more than one
7184 ;; insn.
7185 (define_split
7186 [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7187 (match_operand 1 "" ""))
7188 (clobber (reg:SI 1))
7189 (clobber (reg:SI 2))
7190 (clobber (match_operand 2))
7191 (use (reg:SI 19))
7192 (use (const_int 0))])]
7193 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed
7194 && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7195 [(set (match_dup 2) (reg:SI 19))
7196 (parallel [(call (mem:SI (match_dup 0))
7197 (match_dup 1))
7198 (clobber (reg:SI 1))
7199 (clobber (reg:SI 2))
7200 (use (reg:SI 19))
7201 (use (const_int 0))])]
7202 "")
7203
7204 (define_split
7205 [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7206 (match_operand 1 "" ""))
7207 (clobber (reg:SI 1))
7208 (clobber (reg:SI 2))
7209 (clobber (match_operand 2))
7210 (use (reg:SI 19))
7211 (use (const_int 0))])]
7212 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
7213 [(set (match_dup 2) (reg:SI 19))
7214 (parallel [(call (mem:SI (match_dup 0))
7215 (match_dup 1))
7216 (clobber (reg:SI 1))
7217 (clobber (reg:SI 2))
7218 (use (reg:SI 19))
7219 (use (const_int 0))])
7220 (set (reg:SI 19) (match_dup 2))]
7221 "")
7222
7223 (define_insn "*call_symref_pic_post_reload"
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 (use (reg:SI 19))
7229 (use (const_int 0))]
7230 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7231 "*
7232 {
7233 pa_output_arg_descriptor (insn);
7234 return pa_output_call (insn, operands[0], 0);
7235 }"
7236 [(set_attr "type" "call")
7237 (set (attr "length")
7238 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7239 (symbol_ref "pa_attr_length_call (insn, 0)")))])
7240
7241 ;; This pattern is split if it is necessary to save and restore the
7242 ;; PIC register.
7243 (define_insn "call_symref_64bit"
7244 [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7245 (match_operand 1 "" "i"))
7246 (clobber (reg:DI 1))
7247 (clobber (reg:DI 2))
7248 (clobber (match_operand 2))
7249 (use (reg:DI 27))
7250 (use (reg:DI 29))
7251 (use (const_int 0))]
7252 "TARGET_64BIT"
7253 "#")
7254
7255 ;; Split out the PIC register save and restore after reload. As the
7256 ;; split is done after reload, there are some situations in which we
7257 ;; unnecessarily save and restore %r4. This happens when there is a
7258 ;; single call and the PIC register is not used after the call.
7259 ;;
7260 ;; The split has to be done since call_from_call_insn () can't handle
7261 ;; the pattern as is. Noreturn calls are special because they have to
7262 ;; terminate the basic block. The split has to contain more than one
7263 ;; insn.
7264 (define_split
7265 [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7266 (match_operand 1 "" ""))
7267 (clobber (reg:DI 1))
7268 (clobber (reg:DI 2))
7269 (clobber (match_operand 2))
7270 (use (reg:DI 27))
7271 (use (reg:DI 29))
7272 (use (const_int 0))])]
7273 "TARGET_64BIT && reload_completed
7274 && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7275 [(set (match_dup 2) (reg:DI 27))
7276 (parallel [(call (mem:SI (match_dup 0))
7277 (match_dup 1))
7278 (clobber (reg:DI 1))
7279 (clobber (reg:DI 2))
7280 (use (reg:DI 27))
7281 (use (reg:DI 29))
7282 (use (const_int 0))])]
7283 "")
7284
7285 (define_split
7286 [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7287 (match_operand 1 "" ""))
7288 (clobber (reg:DI 1))
7289 (clobber (reg:DI 2))
7290 (clobber (match_operand 2))
7291 (use (reg:DI 27))
7292 (use (reg:DI 29))
7293 (use (const_int 0))])]
7294 "TARGET_64BIT && reload_completed"
7295 [(set (match_dup 2) (reg:DI 27))
7296 (parallel [(call (mem:SI (match_dup 0))
7297 (match_dup 1))
7298 (clobber (reg:DI 1))
7299 (clobber (reg:DI 2))
7300 (use (reg:DI 27))
7301 (use (reg:DI 29))
7302 (use (const_int 0))])
7303 (set (reg:DI 27) (match_dup 2))]
7304 "")
7305
7306 (define_insn "*call_symref_64bit_post_reload"
7307 [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7308 (match_operand 1 "" "i"))
7309 (clobber (reg:DI 1))
7310 (clobber (reg:DI 2))
7311 (use (reg:DI 27))
7312 (use (reg:DI 29))
7313 (use (const_int 0))]
7314 "TARGET_64BIT"
7315 "*
7316 {
7317 return pa_output_call (insn, operands[0], 0);
7318 }"
7319 [(set_attr "type" "call")
7320 (set (attr "length")
7321 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7322 (symbol_ref "pa_attr_length_call (insn, 0)")))])
7323
7324 (define_insn "call_reg"
7325 [(call (mem:SI (reg:SI 22))
7326 (match_operand 0 "" "i"))
7327 (clobber (reg:SI 1))
7328 (clobber (reg:SI 2))
7329 (use (const_int 1))]
7330 "!TARGET_64BIT"
7331 "*
7332 {
7333 return pa_output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
7334 }"
7335 [(set_attr "type" "dyncall")
7336 (set (attr "length")
7337 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7338 (symbol_ref "pa_attr_length_indirect_call (insn)")))])
7339
7340 ;; This pattern is split if it is necessary to save and restore the
7341 ;; PIC register.
7342 (define_insn "call_reg_pic"
7343 [(call (mem:SI (reg:SI 22))
7344 (match_operand 0 "" "i"))
7345 (clobber (reg:SI 1))
7346 (clobber (reg:SI 2))
7347 (clobber (match_operand 1))
7348 (use (reg:SI 19))
7349 (use (const_int 1))]
7350 "!TARGET_64BIT"
7351 "#")
7352
7353 ;; Split out the PIC register save and restore after reload. As the
7354 ;; split is done after reload, there are some situations in which we
7355 ;; unnecessarily save and restore %r4. This happens when there is a
7356 ;; single call and the PIC register is not used after the call.
7357 ;;
7358 ;; The split has to be done since call_from_call_insn () can't handle
7359 ;; the pattern as is. Noreturn calls are special because they have to
7360 ;; terminate the basic block. The split has to contain more than one
7361 ;; insn.
7362 (define_split
7363 [(parallel [(call (mem:SI (reg:SI 22))
7364 (match_operand 0 "" ""))
7365 (clobber (reg:SI 1))
7366 (clobber (reg:SI 2))
7367 (clobber (match_operand 1))
7368 (use (reg:SI 19))
7369 (use (const_int 1))])]
7370 "!TARGET_64BIT && reload_completed
7371 && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7372 [(set (match_dup 1) (reg:SI 19))
7373 (parallel [(call (mem:SI (reg:SI 22))
7374 (match_dup 0))
7375 (clobber (reg:SI 1))
7376 (clobber (reg:SI 2))
7377 (use (reg:SI 19))
7378 (use (const_int 1))])]
7379 "")
7380
7381 (define_split
7382 [(parallel [(call (mem:SI (reg:SI 22))
7383 (match_operand 0 "" ""))
7384 (clobber (reg:SI 1))
7385 (clobber (reg:SI 2))
7386 (clobber (match_operand 1))
7387 (use (reg:SI 19))
7388 (use (const_int 1))])]
7389 "!TARGET_64BIT && reload_completed"
7390 [(set (match_dup 1) (reg:SI 19))
7391 (parallel [(call (mem:SI (reg:SI 22))
7392 (match_dup 0))
7393 (clobber (reg:SI 1))
7394 (clobber (reg:SI 2))
7395 (use (reg:SI 19))
7396 (use (const_int 1))])
7397 (set (reg:SI 19) (match_dup 1))]
7398 "")
7399
7400 (define_insn "*call_reg_pic_post_reload"
7401 [(call (mem:SI (reg:SI 22))
7402 (match_operand 0 "" "i"))
7403 (clobber (reg:SI 1))
7404 (clobber (reg:SI 2))
7405 (use (reg:SI 19))
7406 (use (const_int 1))]
7407 "!TARGET_64BIT"
7408 "*
7409 {
7410 return pa_output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
7411 }"
7412 [(set_attr "type" "dyncall")
7413 (set (attr "length")
7414 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7415 (symbol_ref "pa_attr_length_indirect_call (insn)")))])
7416
7417 ;; This pattern is split if it is necessary to save and restore the
7418 ;; PIC register.
7419 (define_insn "call_reg_64bit"
7420 [(call (mem:SI (match_operand:DI 0 "register_operand" "r"))
7421 (match_operand 1 "" "i"))
7422 (clobber (reg:DI 2))
7423 (clobber (match_operand 2))
7424 (use (reg:DI 27))
7425 (use (reg:DI 29))
7426 (use (const_int 1))]
7427 "TARGET_64BIT"
7428 "#")
7429
7430 ;; Split out the PIC register save and restore after reload. As the
7431 ;; split is done after reload, there are some situations in which we
7432 ;; unnecessarily save and restore %r4. This happens when there is a
7433 ;; single call and the PIC register is not used after the call.
7434 ;;
7435 ;; The split has to be done since call_from_call_insn () can't handle
7436 ;; the pattern as is. Noreturn calls are special because they have to
7437 ;; terminate the basic block. The split has to contain more than one
7438 ;; insn.
7439 (define_split
7440 [(parallel [(call (mem:SI (match_operand 0 "register_operand" ""))
7441 (match_operand 1 "" ""))
7442 (clobber (reg:DI 2))
7443 (clobber (match_operand 2))
7444 (use (reg:DI 27))
7445 (use (reg:DI 29))
7446 (use (const_int 1))])]
7447 "TARGET_64BIT && reload_completed
7448 && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7449 [(set (match_dup 2) (reg:DI 27))
7450 (parallel [(call (mem:SI (match_dup 0))
7451 (match_dup 1))
7452 (clobber (reg:DI 2))
7453 (use (reg:DI 27))
7454 (use (reg:DI 29))
7455 (use (const_int 1))])]
7456 "")
7457
7458 (define_split
7459 [(parallel [(call (mem:SI (match_operand 0 "register_operand" ""))
7460 (match_operand 1 "" ""))
7461 (clobber (reg:DI 2))
7462 (clobber (match_operand 2))
7463 (use (reg:DI 27))
7464 (use (reg:DI 29))
7465 (use (const_int 1))])]
7466 "TARGET_64BIT && reload_completed"
7467 [(set (match_dup 2) (reg:DI 27))
7468 (parallel [(call (mem:SI (match_dup 0))
7469 (match_dup 1))
7470 (clobber (reg:DI 2))
7471 (use (reg:DI 27))
7472 (use (reg:DI 29))
7473 (use (const_int 1))])
7474 (set (reg:DI 27) (match_dup 2))]
7475 "")
7476
7477 (define_insn "*call_reg_64bit_post_reload"
7478 [(call (mem:SI (match_operand:DI 0 "register_operand" "r"))
7479 (match_operand 1 "" "i"))
7480 (clobber (reg:DI 2))
7481 (use (reg:DI 27))
7482 (use (reg:DI 29))
7483 (use (const_int 1))]
7484 "TARGET_64BIT"
7485 "*
7486 {
7487 return pa_output_indirect_call (insn, operands[0]);
7488 }"
7489 [(set_attr "type" "dyncall")
7490 (set (attr "length")
7491 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 12)]
7492 (symbol_ref "pa_attr_length_indirect_call (insn)")))])
7493
7494 (define_expand "call_value"
7495 [(parallel [(set (match_operand 0 "" "")
7496 (call (match_operand:SI 1 "" "")
7497 (match_operand 2 "" "")))
7498 (clobber (reg:SI 2))])]
7499 ""
7500 {
7501 rtx op;
7502 rtx dst = operands[0];
7503 rtx nb = operands[2];
7504 bool call_powf = false;
7505
7506 if (TARGET_PORTABLE_RUNTIME)
7507 op = force_reg (SImode, XEXP (operands[1], 0));
7508 else
7509 {
7510 op = XEXP (operands[1], 0);
7511 if (GET_CODE (op) == SYMBOL_REF)
7512 {
7513 /* Handle special call to buggy powf function. */
7514 if (TARGET_HPUX && !TARGET_DISABLE_FPREGS && !TARGET_SOFT_FLOAT
7515 && !strcmp (targetm.strip_name_encoding (XSTR (op, 0)), "powf"))
7516 call_powf = true;
7517
7518 /* Generate indirect long calls to non-local functions. */
7519 else if (TARGET_LONG_CALLS)
7520 {
7521 tree call_decl = SYMBOL_REF_DECL (op);
7522 if (!(call_decl && targetm.binds_local_p (call_decl)))
7523 op = force_reg (word_mode, op);
7524 }
7525 }
7526 }
7527
7528 if (TARGET_64BIT)
7529 {
7530 if (!virtuals_instantiated)
7531 emit_move_insn (arg_pointer_rtx,
7532 gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
7533 GEN_INT (64)));
7534 else
7535 {
7536 /* The loop pass can generate new libcalls after the virtual
7537 registers are instantiated when fpregs are disabled because
7538 the only method that we have for doing DImode multiplication
7539 is with a libcall. This could be trouble if we haven't
7540 allocated enough space for the outgoing arguments. */
7541 gcc_assert (INTVAL (nb) <= crtl->outgoing_args_size);
7542
7543 emit_move_insn (arg_pointer_rtx,
7544 gen_rtx_PLUS (word_mode, stack_pointer_rtx,
7545 GEN_INT (STACK_POINTER_OFFSET + 64)));
7546 }
7547 }
7548
7549 /* Use two different patterns for calls to explicitly named functions
7550 and calls through function pointers. This is necessary as these two
7551 types of calls use different calling conventions, and CSE might try
7552 to change the named call into an indirect call in some cases (using
7553 two patterns keeps CSE from performing this optimization).
7554
7555 We now use even more call patterns as there was a subtle bug in
7556 attempting to restore the pic register after a call using a simple
7557 move insn. During reload, a instruction involving a pseudo register
7558 with no explicit dependence on the PIC register can be converted
7559 to an equivalent load from memory using the PIC register. If we
7560 emit a simple move to restore the PIC register in the initial rtl
7561 generation, then it can potentially be repositioned during scheduling.
7562 and an instruction that eventually uses the PIC register may end up
7563 between the call and the PIC register restore.
7564
7565 This only worked because there is a post call group of instructions
7566 that are scheduled with the call. These instructions are included
7567 in the same basic block as the call. However, calls can throw in
7568 C++ code and a basic block has to terminate at the call if the call
7569 can throw. This results in the PIC register restore being scheduled
7570 independently from the call. So, we now hide the save and restore
7571 of the PIC register in the call pattern until after reload. Then,
7572 we split the moves out. A small side benefit is that we now don't
7573 need to have a use of the PIC register in the return pattern and
7574 the final save/restore operation is not needed.
7575
7576 I elected to just use register %r4 in the PIC patterns instead
7577 of trying to force hppa_pic_save_rtx () to a callee saved register.
7578 This might have required a new register class and constraint. It
7579 was also simpler to just handle the restore from a register than a
7580 generic pseudo. */
7581 if (TARGET_64BIT)
7582 {
7583 rtx r4 = gen_rtx_REG (word_mode, 4);
7584 if (GET_CODE (op) == SYMBOL_REF)
7585 {
7586 if (call_powf)
7587 emit_call_insn (gen_call_val_powf_64bit (dst, op, nb, r4));
7588 else
7589 emit_call_insn (gen_call_val_symref_64bit (dst, op, nb, r4));
7590 }
7591 else
7592 {
7593 op = force_reg (word_mode, op);
7594 emit_call_insn (gen_call_val_reg_64bit (dst, op, nb, r4));
7595 }
7596 }
7597 else
7598 {
7599 if (GET_CODE (op) == SYMBOL_REF)
7600 {
7601 if (flag_pic)
7602 {
7603 rtx r4 = gen_rtx_REG (word_mode, 4);
7604
7605 if (call_powf)
7606 emit_call_insn (gen_call_val_powf_pic (dst, op, nb, r4));
7607 else
7608 emit_call_insn (gen_call_val_symref_pic (dst, op, nb, r4));
7609 }
7610 else
7611 {
7612 if (call_powf)
7613 emit_call_insn (gen_call_val_powf (dst, op, nb));
7614 else
7615 emit_call_insn (gen_call_val_symref (dst, op, nb));
7616 }
7617 }
7618 else
7619 {
7620 rtx tmpreg = gen_rtx_REG (word_mode, 22);
7621 emit_move_insn (tmpreg, force_reg (word_mode, op));
7622 if (flag_pic)
7623 {
7624 rtx r4 = gen_rtx_REG (word_mode, 4);
7625 emit_call_insn (gen_call_val_reg_pic (dst, nb, r4));
7626 }
7627 else
7628 emit_call_insn (gen_call_val_reg (dst, nb));
7629 }
7630 }
7631
7632 DONE;
7633 })
7634
7635 (define_insn "call_val_symref"
7636 [(set (match_operand 0 "" "")
7637 (call (mem:SI (match_operand 1 "call_operand_address" ""))
7638 (match_operand 2 "" "i")))
7639 (clobber (reg:SI 1))
7640 (clobber (reg:SI 2))
7641 (use (const_int 0))]
7642 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7643 "*
7644 {
7645 pa_output_arg_descriptor (insn);
7646 return pa_output_call (insn, operands[1], 0);
7647 }"
7648 [(set_attr "type" "call")
7649 (set (attr "length")
7650 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7651 (symbol_ref "pa_attr_length_call (insn, 0)")))])
7652
7653 ;; powf function clobbers %fr12
7654 (define_insn "call_val_powf"
7655 [(set (match_operand 0 "" "")
7656 (call (mem:SI (match_operand 1 "call_operand_address" ""))
7657 (match_operand 2 "" "i")))
7658 (clobber (reg:SI 1))
7659 (clobber (reg:SI 2))
7660 (clobber (reg:DF 48))
7661 (use (const_int 1))]
7662 "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7663 "*
7664 {
7665 pa_output_arg_descriptor (insn);
7666 return pa_output_call (insn, operands[1], 0);
7667 }"
7668 [(set_attr "type" "call")
7669 (set (attr "length")
7670 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7671 (symbol_ref "pa_attr_length_call (insn, 0)")))])
7672
7673 (define_insn "call_val_symref_pic"
7674 [(set (match_operand 0 "" "")
7675 (call (mem:SI (match_operand 1 "call_operand_address" ""))
7676 (match_operand 2 "" "i")))
7677 (clobber (reg:SI 1))
7678 (clobber (reg:SI 2))
7679 (clobber (match_operand 3))
7680 (use (reg:SI 19))
7681 (use (const_int 0))]
7682 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7683 "#")
7684
7685 ;; Split out the PIC register save and restore after reload. As the
7686 ;; split is done after reload, there are some situations in which we
7687 ;; unnecessarily save and restore %r4. This happens when there is a
7688 ;; single call and the PIC register is not used after the call.
7689 ;;
7690 ;; The split has to be done since call_from_call_insn () can't handle
7691 ;; the pattern as is. Noreturn calls are special because they have to
7692 ;; terminate the basic block. The split has to contain more than one
7693 ;; insn.
7694 (define_split
7695 [(parallel [(set (match_operand 0 "" "")
7696 (call (mem:SI (match_operand 1 "call_operand_address" ""))
7697 (match_operand 2 "" "")))
7698 (clobber (reg:SI 1))
7699 (clobber (reg:SI 2))
7700 (clobber (match_operand 3))
7701 (use (reg:SI 19))
7702 (use (const_int 0))])]
7703 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed
7704 && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7705 [(set (match_dup 3) (reg:SI 19))
7706 (parallel [(set (match_dup 0)
7707 (call (mem:SI (match_dup 1))
7708 (match_dup 2)))
7709 (clobber (reg:SI 1))
7710 (clobber (reg:SI 2))
7711 (use (reg:SI 19))
7712 (use (const_int 0))])]
7713 "")
7714
7715 (define_split
7716 [(parallel [(set (match_operand 0 "" "")
7717 (call (mem:SI (match_operand 1 "call_operand_address" ""))
7718 (match_operand 2 "" "")))
7719 (clobber (reg:SI 1))
7720 (clobber (reg:SI 2))
7721 (clobber (match_operand 3))
7722 (use (reg:SI 19))
7723 (use (const_int 0))])]
7724 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
7725 [(set (match_dup 3) (reg:SI 19))
7726 (parallel [(set (match_dup 0)
7727 (call (mem:SI (match_dup 1))
7728 (match_dup 2)))
7729 (clobber (reg:SI 1))
7730 (clobber (reg:SI 2))
7731 (use (reg:SI 19))
7732 (use (const_int 0))])
7733 (set (reg:SI 19) (match_dup 3))]
7734 "")
7735
7736 (define_insn "*call_val_symref_pic_post_reload"
7737 [(set (match_operand 0 "" "")
7738 (call (mem:SI (match_operand 1 "call_operand_address" ""))
7739 (match_operand 2 "" "i")))
7740 (clobber (reg:SI 1))
7741 (clobber (reg:SI 2))
7742 (use (reg:SI 19))
7743 (use (const_int 0))]
7744 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7745 "*
7746 {
7747 pa_output_arg_descriptor (insn);
7748 return pa_output_call (insn, operands[1], 0);
7749 }"
7750 [(set_attr "type" "call")
7751 (set (attr "length")
7752 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7753 (symbol_ref "pa_attr_length_call (insn, 0)")))])
7754
7755 ;; powf function clobbers %fr12
7756 (define_insn "call_val_powf_pic"
7757 [(set (match_operand 0 "" "")
7758 (call (mem:SI (match_operand 1 "call_operand_address" ""))
7759 (match_operand 2 "" "i")))
7760 (clobber (reg:SI 1))
7761 (clobber (reg:SI 2))
7762 (clobber (reg:DF 48))
7763 (clobber (match_operand 3))
7764 (use (reg:SI 19))
7765 (use (const_int 1))]
7766 "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7767 "#")
7768
7769 ;; Split out the PIC register save and restore after reload. As the
7770 ;; split is done after reload, there are some situations in which we
7771 ;; unnecessarily save and restore %r4. This happens when there is a
7772 ;; single call and the PIC register is not used after the call.
7773 ;;
7774 ;; The split has to be done since call_from_call_insn () can't handle
7775 ;; the pattern as is. Noreturn calls are special because they have to
7776 ;; terminate the basic block. The split has to contain more than one
7777 ;; insn.
7778 (define_split
7779 [(parallel [(set (match_operand 0 "" "")
7780 (call (mem:SI (match_operand 1 "call_operand_address" ""))
7781 (match_operand 2 "" "")))
7782 (clobber (reg:SI 1))
7783 (clobber (reg:SI 2))
7784 (clobber (reg:DF 48))
7785 (clobber (match_operand 3))
7786 (use (reg:SI 19))
7787 (use (const_int 1))])]
7788 "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed
7789 && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7790 [(set (match_dup 3) (reg:SI 19))
7791 (parallel [(set (match_dup 0)
7792 (call (mem:SI (match_dup 1))
7793 (match_dup 2)))
7794 (clobber (reg:SI 1))
7795 (clobber (reg:SI 2))
7796 (clobber (reg:DF 48))
7797 (use (reg:SI 19))
7798 (use (const_int 1))])]
7799 "")
7800
7801 (define_split
7802 [(parallel [(set (match_operand 0 "" "")
7803 (call (mem:SI (match_operand 1 "call_operand_address" ""))
7804 (match_operand 2 "" "")))
7805 (clobber (reg:SI 1))
7806 (clobber (reg:SI 2))
7807 (clobber (reg:DF 48))
7808 (clobber (match_operand 3))
7809 (use (reg:SI 19))
7810 (use (const_int 1))])]
7811 "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
7812 [(set (match_dup 3) (reg:SI 19))
7813 (parallel [(set (match_dup 0)
7814 (call (mem:SI (match_dup 1))
7815 (match_dup 2)))
7816 (clobber (reg:SI 1))
7817 (clobber (reg:SI 2))
7818 (clobber (reg:DF 48))
7819 (use (reg:SI 19))
7820 (use (const_int 1))])
7821 (set (reg:SI 19) (match_dup 3))]
7822 "")
7823
7824 (define_insn "*call_val_powf_pic_post_reload"
7825 [(set (match_operand 0 "" "")
7826 (call (mem:SI (match_operand 1 "call_operand_address" ""))
7827 (match_operand 2 "" "i")))
7828 (clobber (reg:SI 1))
7829 (clobber (reg:SI 2))
7830 (clobber (reg:DF 48))
7831 (use (reg:SI 19))
7832 (use (const_int 1))]
7833 "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7834 "*
7835 {
7836 pa_output_arg_descriptor (insn);
7837 return pa_output_call (insn, operands[1], 0);
7838 }"
7839 [(set_attr "type" "call")
7840 (set (attr "length")
7841 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7842 (symbol_ref "pa_attr_length_call (insn, 0)")))])
7843
7844 ;; This pattern is split if it is necessary to save and restore the
7845 ;; PIC register.
7846 (define_insn "call_val_symref_64bit"
7847 [(set (match_operand 0 "" "")
7848 (call (mem:SI (match_operand 1 "call_operand_address" ""))
7849 (match_operand 2 "" "i")))
7850 (clobber (reg:DI 1))
7851 (clobber (reg:DI 2))
7852 (clobber (match_operand 3))
7853 (use (reg:DI 27))
7854 (use (reg:DI 29))
7855 (use (const_int 0))]
7856 "TARGET_64BIT"
7857 "#")
7858
7859 ;; Split out the PIC register save and restore after reload. As the
7860 ;; split is done after reload, there are some situations in which we
7861 ;; unnecessarily save and restore %r4. This happens when there is a
7862 ;; single call and the PIC register is not used after the call.
7863 ;;
7864 ;; The split has to be done since call_from_call_insn () can't handle
7865 ;; the pattern as is. Noreturn calls are special because they have to
7866 ;; terminate the basic block. The split has to contain more than one
7867 ;; insn.
7868 (define_split
7869 [(parallel [(set (match_operand 0 "" "")
7870 (call (mem:SI (match_operand 1 "call_operand_address" ""))
7871 (match_operand 2 "" "")))
7872 (clobber (reg:DI 1))
7873 (clobber (reg:DI 2))
7874 (clobber (match_operand 3))
7875 (use (reg:DI 27))
7876 (use (reg:DI 29))
7877 (use (const_int 0))])]
7878 "TARGET_64BIT && reload_completed
7879 && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7880 [(set (match_dup 3) (reg:DI 27))
7881 (parallel [(set (match_dup 0)
7882 (call (mem:SI (match_dup 1))
7883 (match_dup 2)))
7884 (clobber (reg:DI 1))
7885 (clobber (reg:DI 2))
7886 (use (reg:DI 27))
7887 (use (reg:DI 29))
7888 (use (const_int 0))])]
7889 "")
7890
7891 (define_split
7892 [(parallel [(set (match_operand 0 "" "")
7893 (call (mem:SI (match_operand 1 "call_operand_address" ""))
7894 (match_operand 2 "" "")))
7895 (clobber (reg:DI 1))
7896 (clobber (reg:DI 2))
7897 (clobber (match_operand 3))
7898 (use (reg:DI 27))
7899 (use (reg:DI 29))
7900 (use (const_int 0))])]
7901 "TARGET_64BIT && reload_completed"
7902 [(set (match_dup 3) (reg:DI 27))
7903 (parallel [(set (match_dup 0)
7904 (call (mem:SI (match_dup 1))
7905 (match_dup 2)))
7906 (clobber (reg:DI 1))
7907 (clobber (reg:DI 2))
7908 (use (reg:DI 27))
7909 (use (reg:DI 29))
7910 (use (const_int 0))])
7911 (set (reg:DI 27) (match_dup 3))]
7912 "")
7913
7914 (define_insn "*call_val_symref_64bit_post_reload"
7915 [(set (match_operand 0 "" "")
7916 (call (mem:SI (match_operand 1 "call_operand_address" ""))
7917 (match_operand 2 "" "i")))
7918 (clobber (reg:DI 1))
7919 (clobber (reg:DI 2))
7920 (use (reg:DI 27))
7921 (use (reg:DI 29))
7922 (use (const_int 0))]
7923 "TARGET_64BIT"
7924 "*
7925 {
7926 return pa_output_call (insn, operands[1], 0);
7927 }"
7928 [(set_attr "type" "call")
7929 (set (attr "length")
7930 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7931 (symbol_ref "pa_attr_length_call (insn, 0)")))])
7932
7933 ;; powf function clobbers %fr12
7934 (define_insn "call_val_powf_64bit"
7935 [(set (match_operand 0 "" "")
7936 (call (mem:SI (match_operand 1 "call_operand_address" ""))
7937 (match_operand 2 "" "i")))
7938 (clobber (reg:DI 1))
7939 (clobber (reg:DI 2))
7940 (clobber (reg:DF 40))
7941 (clobber (match_operand 3))
7942 (use (reg:DI 27))
7943 (use (reg:DI 29))
7944 (use (const_int 1))]
7945 "TARGET_64BIT && TARGET_HPUX"
7946 "#")
7947
7948 ;; Split out the PIC register save and restore after reload. As the
7949 ;; split is done after reload, there are some situations in which we
7950 ;; unnecessarily save and restore %r4. This happens when there is a
7951 ;; single call and the PIC register is not used after the call.
7952 ;;
7953 ;; The split has to be done since call_from_call_insn () can't handle
7954 ;; the pattern as is. Noreturn calls are special because they have to
7955 ;; terminate the basic block. The split has to contain more than one
7956 ;; insn.
7957 (define_split
7958 [(parallel [(set (match_operand 0 "" "")
7959 (call (mem:SI (match_operand 1 "call_operand_address" ""))
7960 (match_operand 2 "" "")))
7961 (clobber (reg:DI 1))
7962 (clobber (reg:DI 2))
7963 (clobber (reg:DF 40))
7964 (clobber (match_operand 3))
7965 (use (reg:DI 27))
7966 (use (reg:DI 29))
7967 (use (const_int 1))])]
7968 "TARGET_64BIT && TARGET_HPUX && reload_completed
7969 && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7970 [(set (match_dup 3) (reg:DI 27))
7971 (parallel [(set (match_dup 0)
7972 (call (mem:SI (match_dup 1))
7973 (match_dup 2)))
7974 (clobber (reg:DI 1))
7975 (clobber (reg:DI 2))
7976 (clobber (reg:DF 40))
7977 (use (reg:DI 27))
7978 (use (reg:DI 29))
7979 (use (const_int 1))])]
7980 "")
7981
7982 (define_split
7983 [(parallel [(set (match_operand 0 "" "")
7984 (call (mem:SI (match_operand 1 "call_operand_address" ""))
7985 (match_operand 2 "" "")))
7986 (clobber (reg:DI 1))
7987 (clobber (reg:DI 2))
7988 (clobber (reg:DF 40))
7989 (clobber (match_operand 3))
7990 (use (reg:DI 27))
7991 (use (reg:DI 29))
7992 (use (const_int 1))])]
7993 "TARGET_64BIT && TARGET_HPUX && reload_completed"
7994 [(set (match_dup 3) (reg:DI 27))
7995 (parallel [(set (match_dup 0)
7996 (call (mem:SI (match_dup 1))
7997 (match_dup 2)))
7998 (clobber (reg:DI 1))
7999 (clobber (reg:DI 2))
8000 (clobber (reg:DF 40))
8001 (use (reg:DI 27))
8002 (use (reg:DI 29))
8003 (use (const_int 1))])
8004 (set (reg:DI 27) (match_dup 3))]
8005 "")
8006
8007 (define_insn "*call_val_powf_64bit_post_reload"
8008 [(set (match_operand 0 "" "")
8009 (call (mem:SI (match_operand 1 "call_operand_address" ""))
8010 (match_operand 2 "" "i")))
8011 (clobber (reg:DI 1))
8012 (clobber (reg:DI 2))
8013 (clobber (reg:DF 40))
8014 (use (reg:DI 27))
8015 (use (reg:DI 29))
8016 (use (const_int 1))]
8017 "TARGET_64BIT && TARGET_HPUX"
8018 "*
8019 {
8020 return pa_output_call (insn, operands[1], 0);
8021 }"
8022 [(set_attr "type" "call")
8023 (set (attr "length")
8024 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8025 (symbol_ref "pa_attr_length_call (insn, 0)")))])
8026
8027 (define_insn "call_val_reg"
8028 [(set (match_operand 0 "" "")
8029 (call (mem:SI (reg:SI 22))
8030 (match_operand 1 "" "i")))
8031 (clobber (reg:SI 1))
8032 (clobber (reg:SI 2))
8033 (use (const_int 1))]
8034 "!TARGET_64BIT"
8035 "*
8036 {
8037 return pa_output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
8038 }"
8039 [(set_attr "type" "dyncall")
8040 (set (attr "length")
8041 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8042 (symbol_ref "pa_attr_length_indirect_call (insn)")))])
8043
8044 ;; This pattern is split if it is necessary to save and restore the
8045 ;; PIC register.
8046 (define_insn "call_val_reg_pic"
8047 [(set (match_operand 0 "" "")
8048 (call (mem:SI (reg:SI 22))
8049 (match_operand 1 "" "i")))
8050 (clobber (reg:SI 1))
8051 (clobber (reg:SI 2))
8052 (clobber (match_operand 2))
8053 (use (reg:SI 19))
8054 (use (const_int 1))]
8055 "!TARGET_64BIT"
8056 "#")
8057
8058 ;; Split out the PIC register save and restore after reload. As the
8059 ;; split is done after reload, there are some situations in which we
8060 ;; unnecessarily save and restore %r4. This happens when there is a
8061 ;; single call and the PIC register is not used after the call.
8062 ;;
8063 ;; The split has to be done since call_from_call_insn () can't handle
8064 ;; the pattern as is. Noreturn calls are special because they have to
8065 ;; terminate the basic block. The split has to contain more than one
8066 ;; insn.
8067 (define_split
8068 [(parallel [(set (match_operand 0 "" "")
8069 (call (mem:SI (reg:SI 22))
8070 (match_operand 1 "" "")))
8071 (clobber (reg:SI 1))
8072 (clobber (reg:SI 2))
8073 (clobber (match_operand 2))
8074 (use (reg:SI 19))
8075 (use (const_int 1))])]
8076 "!TARGET_64BIT && reload_completed
8077 && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8078 [(set (match_dup 2) (reg:SI 19))
8079 (parallel [(set (match_dup 0)
8080 (call (mem:SI (reg:SI 22))
8081 (match_dup 1)))
8082 (clobber (reg:SI 1))
8083 (clobber (reg:SI 2))
8084 (use (reg:SI 19))
8085 (use (const_int 1))])]
8086 "")
8087
8088 (define_split
8089 [(parallel [(set (match_operand 0 "" "")
8090 (call (mem:SI (reg:SI 22))
8091 (match_operand 1 "" "")))
8092 (clobber (reg:SI 1))
8093 (clobber (reg:SI 2))
8094 (clobber (match_operand 2))
8095 (use (reg:SI 19))
8096 (use (const_int 1))])]
8097 "!TARGET_64BIT && reload_completed"
8098 [(set (match_dup 2) (reg:SI 19))
8099 (parallel [(set (match_dup 0)
8100 (call (mem:SI (reg:SI 22))
8101 (match_dup 1)))
8102 (clobber (reg:SI 1))
8103 (clobber (reg:SI 2))
8104 (use (reg:SI 19))
8105 (use (const_int 1))])
8106 (set (reg:SI 19) (match_dup 2))]
8107 "")
8108
8109 (define_insn "*call_val_reg_pic_post_reload"
8110 [(set (match_operand 0 "" "")
8111 (call (mem:SI (reg:SI 22))
8112 (match_operand 1 "" "i")))
8113 (clobber (reg:SI 1))
8114 (clobber (reg:SI 2))
8115 (use (reg:SI 19))
8116 (use (const_int 1))]
8117 "!TARGET_64BIT"
8118 "*
8119 {
8120 return pa_output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
8121 }"
8122 [(set_attr "type" "dyncall")
8123 (set (attr "length")
8124 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8125 (symbol_ref "pa_attr_length_indirect_call (insn)")))])
8126
8127 ;; This pattern is split if it is necessary to save and restore the
8128 ;; PIC register.
8129 (define_insn "call_val_reg_64bit"
8130 [(set (match_operand 0 "" "")
8131 (call (mem:SI (match_operand:DI 1 "register_operand" "r"))
8132 (match_operand 2 "" "i")))
8133 (clobber (reg:DI 2))
8134 (clobber (match_operand 3))
8135 (use (reg:DI 27))
8136 (use (reg:DI 29))
8137 (use (const_int 1))]
8138 "TARGET_64BIT"
8139 "#")
8140
8141 ;; Split out the PIC register save and restore after reload. As the
8142 ;; split is done after reload, there are some situations in which we
8143 ;; unnecessarily save and restore %r4. This happens when there is a
8144 ;; single call and the PIC register is not used after the call.
8145 ;;
8146 ;; The split has to be done since call_from_call_insn () can't handle
8147 ;; the pattern as is. Noreturn calls are special because they have to
8148 ;; terminate the basic block. The split has to contain more than one
8149 ;; insn.
8150 (define_split
8151 [(parallel [(set (match_operand 0 "" "")
8152 (call (mem:SI (match_operand:DI 1 "register_operand" ""))
8153 (match_operand 2 "" "")))
8154 (clobber (reg:DI 2))
8155 (clobber (match_operand 3))
8156 (use (reg:DI 27))
8157 (use (reg:DI 29))
8158 (use (const_int 1))])]
8159 "TARGET_64BIT && reload_completed
8160 && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8161 [(set (match_dup 3) (reg:DI 27))
8162 (parallel [(set (match_dup 0)
8163 (call (mem:SI (match_dup 1))
8164 (match_dup 2)))
8165 (clobber (reg:DI 2))
8166 (use (reg:DI 27))
8167 (use (reg:DI 29))
8168 (use (const_int 1))])]
8169 "")
8170
8171 (define_split
8172 [(parallel [(set (match_operand 0 "" "")
8173 (call (mem:SI (match_operand:DI 1 "register_operand" ""))
8174 (match_operand 2 "" "")))
8175 (clobber (reg:DI 2))
8176 (clobber (match_operand 3))
8177 (use (reg:DI 27))
8178 (use (reg:DI 29))
8179 (use (const_int 1))])]
8180 "TARGET_64BIT && reload_completed"
8181 [(set (match_dup 3) (reg:DI 27))
8182 (parallel [(set (match_dup 0)
8183 (call (mem:SI (match_dup 1))
8184 (match_dup 2)))
8185 (clobber (reg:DI 2))
8186 (use (reg:DI 27))
8187 (use (reg:DI 29))
8188 (use (const_int 1))])
8189 (set (reg:DI 27) (match_dup 3))]
8190 "")
8191
8192 (define_insn "*call_val_reg_64bit_post_reload"
8193 [(set (match_operand 0 "" "")
8194 (call (mem:SI (match_operand:DI 1 "register_operand" "r"))
8195 (match_operand 2 "" "i")))
8196 (clobber (reg:DI 2))
8197 (use (reg:DI 27))
8198 (use (reg:DI 29))
8199 (use (const_int 1))]
8200 "TARGET_64BIT"
8201 "*
8202 {
8203 return pa_output_indirect_call (insn, operands[1]);
8204 }"
8205 [(set_attr "type" "dyncall")
8206 (set (attr "length")
8207 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 12)]
8208 (symbol_ref "pa_attr_length_indirect_call (insn)")))])
8209
8210 /* Expand special pc-relative call to _mcount. */
8211
8212 (define_expand "call_mcount"
8213 [(parallel [(call (match_operand:SI 0 "" "")
8214 (match_operand 1 "" ""))
8215 (set (reg:SI 25)
8216 (plus:SI (reg:SI 2)
8217 (minus:SI (match_operand 2 "" "")
8218 (plus:SI (pc) (const_int 4)))))
8219 (clobber (reg:SI 2))])]
8220 "!TARGET_PORTABLE_RUNTIME"
8221 "
8222 {
8223 rtx op = XEXP (operands[0], 0);
8224 rtx nb = operands[1];
8225 rtx lab = operands[2];
8226
8227 if (TARGET_64BIT)
8228 {
8229 rtx r4 = gen_rtx_REG (word_mode, 4);
8230 emit_move_insn (arg_pointer_rtx,
8231 gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
8232 GEN_INT (64)));
8233 emit_call_insn (gen_call_mcount_64bit (op, nb, lab, r4));
8234 }
8235 else
8236 {
8237 if (flag_pic)
8238 {
8239 rtx r4 = gen_rtx_REG (word_mode, 4);
8240 emit_call_insn (gen_call_mcount_pic (op, nb, lab, r4));
8241 }
8242 else
8243 emit_call_insn (gen_call_mcount_nonpic (op, nb, lab));
8244 }
8245
8246 DONE;
8247 }")
8248
8249 (define_insn "call_mcount_nonpic"
8250 [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8251 (match_operand 1 "" "i"))
8252 (set (reg:SI 25)
8253 (plus:SI (reg:SI 2)
8254 (minus:SI (match_operand 2 "" "")
8255 (plus:SI (pc) (const_int 4)))))
8256 (clobber (reg:SI 2))]
8257 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8258 "*
8259 {
8260 pa_output_arg_descriptor (insn);
8261 return \"{bl|b,l} %0,%%r2\;ldo %2-.-4(%%r2),%%r25\";
8262 }"
8263 [(set_attr "type" "multi")
8264 (set_attr "length" "8")])
8265
8266 (define_insn "call_mcount_pic"
8267 [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8268 (match_operand 1 "" "i"))
8269 (set (reg:SI 25)
8270 (plus:SI (reg:SI 2)
8271 (minus:SI (match_operand 2 "" "")
8272 (plus:SI (pc) (const_int 4)))))
8273 (clobber (reg:SI 2))
8274 (clobber (match_operand 3))
8275 (use (reg:SI 19))]
8276 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8277 "#")
8278
8279 (define_split
8280 [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8281 (match_operand 1 "" ""))
8282 (set (reg:SI 25)
8283 (plus:SI (reg:SI 2)
8284 (minus:SI (match_operand 2 "" "")
8285 (plus:SI (pc) (const_int 4)))))
8286 (clobber (reg:SI 2))
8287 (clobber (match_operand 3))
8288 (use (reg:SI 19))])]
8289 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
8290 [(set (match_dup 3) (reg:SI 19))
8291 (parallel [(call (mem:SI (match_dup 0))
8292 (match_dup 1))
8293 (set (reg:SI 25)
8294 (plus:SI (reg:SI 2)
8295 (minus:SI (match_dup 2)
8296 (plus:SI (pc) (const_int 4)))))
8297 (clobber (reg:SI 2))
8298 (use (reg:SI 19))])
8299 (set (reg:SI 19) (match_dup 3))]
8300 "")
8301
8302 (define_insn "*call_mcount_pic_post_reload"
8303 [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8304 (match_operand 1 "" "i"))
8305 (set (reg:SI 25)
8306 (plus:SI (reg:SI 2)
8307 (minus:SI (match_operand 2 "" "")
8308 (plus:SI (pc) (const_int 4)))))
8309 (clobber (reg:SI 2))
8310 (use (reg:SI 19))]
8311 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8312 "*
8313 {
8314 pa_output_arg_descriptor (insn);
8315 return \"{bl|b,l} %0,%%r2\;ldo %2-.-4(%%r2),%%r25\";
8316 }"
8317 [(set_attr "type" "multi")
8318 (set_attr "length" "8")])
8319
8320 (define_insn "call_mcount_64bit"
8321 [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8322 (match_operand 1 "" "i"))
8323 (set (reg:SI 25)
8324 (plus:SI (reg:SI 2)
8325 (minus:SI (match_operand 2 "" "")
8326 (plus:SI (pc) (const_int 4)))))
8327 (clobber (reg:DI 2))
8328 (clobber (match_operand 3))
8329 (use (reg:DI 27))
8330 (use (reg:DI 29))]
8331 "TARGET_64BIT"
8332 "#")
8333
8334 (define_split
8335 [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8336 (match_operand 1 "" ""))
8337 (set (reg:SI 25)
8338 (plus:SI (reg:SI 2)
8339 (minus:SI (match_operand 2 "" "")
8340 (plus:SI (pc) (const_int 4)))))
8341 (clobber (reg:DI 2))
8342 (clobber (match_operand 3))
8343 (use (reg:DI 27))
8344 (use (reg:DI 29))])]
8345 "TARGET_64BIT && reload_completed"
8346 [(set (match_dup 3) (reg:DI 27))
8347 (parallel [(call (mem:SI (match_dup 0))
8348 (match_dup 1))
8349 (set (reg:SI 25)
8350 (plus:SI (reg:SI 2)
8351 (minus:SI (match_dup 2)
8352 (plus:SI (pc) (const_int 4)))))
8353 (clobber (reg:DI 2))
8354 (use (reg:DI 27))
8355 (use (reg:DI 29))])
8356 (set (reg:DI 27) (match_dup 3))]
8357 "")
8358
8359 (define_insn "*call_mcount_64bit_post_reload"
8360 [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8361 (match_operand 1 "" "i"))
8362 (set (reg:SI 25)
8363 (plus:SI (reg:SI 2)
8364 (minus:SI (match_operand 2 "" "")
8365 (plus:SI (pc) (const_int 4)))))
8366 (clobber (reg:DI 2))
8367 (use (reg:DI 27))
8368 (use (reg:DI 29))]
8369 "TARGET_64BIT"
8370 "{bl|b,l} %0,%%r2\;ldo %2-.-4(%%r2),%%r25"
8371 [(set_attr "type" "multi")
8372 (set_attr "length" "8")])
8373
8374 ;; Call subroutine returning any type.
8375
8376 (define_expand "untyped_call"
8377 [(parallel [(call (match_operand 0 "" "")
8378 (const_int 0))
8379 (match_operand 1 "" "")
8380 (match_operand 2 "" "")])]
8381 ""
8382 "
8383 {
8384 int i;
8385
8386 emit_call_insn (gen_call (operands[0], const0_rtx));
8387
8388 for (i = 0; i < XVECLEN (operands[2], 0); i++)
8389 {
8390 rtx set = XVECEXP (operands[2], 0, i);
8391 emit_move_insn (SET_DEST (set), SET_SRC (set));
8392 }
8393
8394 /* The optimizer does not know that the call sets the function value
8395 registers we stored in the result block. We avoid problems by
8396 claiming that all hard registers are used and clobbered at this
8397 point. */
8398 emit_insn (gen_blockage ());
8399
8400 DONE;
8401 }")
8402
8403 (define_expand "sibcall"
8404 [(call (match_operand:SI 0 "" "")
8405 (match_operand 1 "" ""))]
8406 "!TARGET_PORTABLE_RUNTIME"
8407 "
8408 {
8409 rtx op, call_insn;
8410 rtx nb = operands[1];
8411
8412 op = XEXP (operands[0], 0);
8413
8414 if (TARGET_64BIT)
8415 {
8416 if (!virtuals_instantiated)
8417 emit_move_insn (arg_pointer_rtx,
8418 gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
8419 GEN_INT (64)));
8420 else
8421 {
8422 /* The loop pass can generate new libcalls after the virtual
8423 registers are instantiated when fpregs are disabled because
8424 the only method that we have for doing DImode multiplication
8425 is with a libcall. This could be trouble if we haven't
8426 allocated enough space for the outgoing arguments. */
8427 gcc_assert (INTVAL (nb) <= crtl->outgoing_args_size);
8428
8429 emit_move_insn (arg_pointer_rtx,
8430 gen_rtx_PLUS (word_mode, stack_pointer_rtx,
8431 GEN_INT (STACK_POINTER_OFFSET + 64)));
8432 }
8433 }
8434
8435 /* Indirect sibling calls are not allowed. */
8436 if (TARGET_64BIT)
8437 call_insn = gen_sibcall_internal_symref_64bit (op, operands[1]);
8438 else
8439 call_insn = gen_sibcall_internal_symref (op, operands[1]);
8440
8441 call_insn = emit_call_insn (call_insn);
8442
8443 if (TARGET_64BIT)
8444 use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), arg_pointer_rtx);
8445
8446 /* We don't have to restore the PIC register. */
8447 if (flag_pic)
8448 use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
8449
8450 DONE;
8451 }")
8452
8453 (define_insn "sibcall_internal_symref"
8454 [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8455 (match_operand 1 "" "i"))
8456 (clobber (reg:SI 1))
8457 (use (reg:SI 2))
8458 (use (const_int 0))]
8459 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8460 "*
8461 {
8462 pa_output_arg_descriptor (insn);
8463 return pa_output_call (insn, operands[0], 1);
8464 }"
8465 [(set_attr "type" "sibcall")
8466 (set (attr "length")
8467 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8468 (symbol_ref "pa_attr_length_call (insn, 1)")))])
8469
8470 (define_insn "sibcall_internal_symref_64bit"
8471 [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8472 (match_operand 1 "" "i"))
8473 (clobber (reg:DI 1))
8474 (use (reg:DI 2))
8475 (use (const_int 0))]
8476 "TARGET_64BIT"
8477 "*
8478 {
8479 return pa_output_call (insn, operands[0], 1);
8480 }"
8481 [(set_attr "type" "sibcall")
8482 (set (attr "length")
8483 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8484 (symbol_ref "pa_attr_length_call (insn, 1)")))])
8485
8486 (define_expand "sibcall_value"
8487 [(set (match_operand 0 "" "")
8488 (call (match_operand:SI 1 "" "")
8489 (match_operand 2 "" "")))]
8490 "!TARGET_PORTABLE_RUNTIME"
8491 "
8492 {
8493 rtx op, call_insn;
8494 rtx nb = operands[1];
8495
8496 op = XEXP (operands[1], 0);
8497
8498 if (TARGET_64BIT)
8499 {
8500 if (!virtuals_instantiated)
8501 emit_move_insn (arg_pointer_rtx,
8502 gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
8503 GEN_INT (64)));
8504 else
8505 {
8506 /* The loop pass can generate new libcalls after the virtual
8507 registers are instantiated when fpregs are disabled because
8508 the only method that we have for doing DImode multiplication
8509 is with a libcall. This could be trouble if we haven't
8510 allocated enough space for the outgoing arguments. */
8511 gcc_assert (INTVAL (nb) <= crtl->outgoing_args_size);
8512
8513 emit_move_insn (arg_pointer_rtx,
8514 gen_rtx_PLUS (word_mode, stack_pointer_rtx,
8515 GEN_INT (STACK_POINTER_OFFSET + 64)));
8516 }
8517 }
8518
8519 /* Indirect sibling calls are not allowed. */
8520 if (TARGET_64BIT)
8521 call_insn
8522 = gen_sibcall_value_internal_symref_64bit (operands[0], op, operands[2]);
8523 else
8524 call_insn
8525 = gen_sibcall_value_internal_symref (operands[0], op, operands[2]);
8526
8527 call_insn = emit_call_insn (call_insn);
8528
8529 if (TARGET_64BIT)
8530 use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), arg_pointer_rtx);
8531
8532 /* We don't have to restore the PIC register. */
8533 if (flag_pic)
8534 use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
8535
8536 DONE;
8537 }")
8538
8539 (define_insn "sibcall_value_internal_symref"
8540 [(set (match_operand 0 "" "")
8541 (call (mem:SI (match_operand 1 "call_operand_address" ""))
8542 (match_operand 2 "" "i")))
8543 (clobber (reg:SI 1))
8544 (use (reg:SI 2))
8545 (use (const_int 0))]
8546 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8547 "*
8548 {
8549 pa_output_arg_descriptor (insn);
8550 return pa_output_call (insn, operands[1], 1);
8551 }"
8552 [(set_attr "type" "sibcall")
8553 (set (attr "length")
8554 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8555 (symbol_ref "pa_attr_length_call (insn, 1)")))])
8556
8557 (define_insn "sibcall_value_internal_symref_64bit"
8558 [(set (match_operand 0 "" "")
8559 (call (mem:SI (match_operand 1 "call_operand_address" ""))
8560 (match_operand 2 "" "i")))
8561 (clobber (reg:DI 1))
8562 (use (reg:DI 2))
8563 (use (const_int 0))]
8564 "TARGET_64BIT"
8565 "*
8566 {
8567 return pa_output_call (insn, operands[1], 1);
8568 }"
8569 [(set_attr "type" "sibcall")
8570 (set (attr "length")
8571 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8572 (symbol_ref "pa_attr_length_call (insn, 1)")))])
8573
8574 (define_insn "nop"
8575 [(const_int 0)]
8576 ""
8577 "nop"
8578 [(set_attr "type" "move")
8579 (set_attr "length" "4")])
8580
8581 ;;; EH does longjmp's from and within the data section. Thus,
8582 ;;; an interspace branch is required for the longjmp implementation.
8583 ;;; Registers r1 and r2 are used as scratch registers for the jump
8584 ;;; when necessary.
8585 (define_expand "interspace_jump"
8586 [(parallel
8587 [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8588 (clobber (match_dup 1))])]
8589 ""
8590 "
8591 {
8592 operands[1] = gen_rtx_REG (word_mode, 2);
8593 }")
8594
8595 (define_insn ""
8596 [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8597 (clobber (reg:SI 2))]
8598 "TARGET_PA_20 && !TARGET_64BIT"
8599 "bve%* (%0)"
8600 [(set_attr "type" "branch")
8601 (set_attr "length" "4")])
8602
8603 (define_insn ""
8604 [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8605 (clobber (reg:SI 2))]
8606 "TARGET_NO_SPACE_REGS && !TARGET_64BIT"
8607 "be%* 0(%%sr4,%0)"
8608 [(set_attr "type" "branch")
8609 (set_attr "length" "4")])
8610
8611 (define_insn ""
8612 [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8613 (clobber (reg:SI 2))]
8614 "!TARGET_64BIT"
8615 "ldsid (%%sr0,%0),%%r2\;mtsp %%r2,%%sr0\;be%* 0(%%sr0,%0)"
8616 [(set_attr "type" "branch")
8617 (set_attr "length" "12")])
8618
8619 (define_insn ""
8620 [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8621 (clobber (reg:DI 2))]
8622 "TARGET_64BIT"
8623 "bve%* (%0)"
8624 [(set_attr "type" "branch")
8625 (set_attr "length" "4")])
8626
8627 (define_expand "builtin_longjmp"
8628 [(unspec_volatile [(match_operand 0 "register_operand" "r")] UNSPECV_LONGJMP)]
8629 ""
8630 "
8631 {
8632 /* The elements of the buffer are, in order: */
8633 rtx fp = gen_rtx_MEM (Pmode, operands[0]);
8634 rtx lab = gen_rtx_MEM (Pmode, plus_constant (Pmode, operands[0],
8635 POINTER_SIZE / BITS_PER_UNIT));
8636 rtx stack = gen_rtx_MEM (Pmode, plus_constant (Pmode, operands[0],
8637 (POINTER_SIZE * 2) / BITS_PER_UNIT));
8638 rtx pv = gen_rtx_REG (Pmode, 1);
8639
8640 emit_clobber (gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (VOIDmode)));
8641 emit_clobber (gen_rtx_MEM (BLKmode, hard_frame_pointer_rtx));
8642
8643 /* Restore the frame pointer. The virtual_stack_vars_rtx is saved
8644 instead of the hard_frame_pointer_rtx in the save area. We need
8645 to adjust for the offset between these two values. */
8646 if (GET_CODE (fp) != REG)
8647 fp = force_reg (Pmode, fp);
8648 emit_move_insn (hard_frame_pointer_rtx, plus_constant (Pmode, fp, -8));
8649
8650 /* This bit is the same as expand_builtin_longjmp. */
8651 emit_stack_restore (SAVE_NONLOCAL, stack);
8652 emit_use (hard_frame_pointer_rtx);
8653 emit_use (stack_pointer_rtx);
8654
8655 /* Load the label we are jumping through into r1 so that we know
8656 where to look for it when we get back to setjmp's function for
8657 restoring the gp. */
8658 emit_move_insn (pv, lab);
8659
8660 /* Prevent the insns above from being scheduled into the delay slot
8661 of the interspace jump because the space register could change. */
8662 emit_insn (gen_blockage ());
8663
8664 emit_jump_insn (gen_interspace_jump (pv));
8665 emit_barrier ();
8666 DONE;
8667 }")
8668
8669 ;;; Operands 2 and 3 are assumed to be CONST_INTs.
8670 (define_expand "extzvsi"
8671 [(set (match_operand:SI 0 "register_operand" "")
8672 (zero_extract:SI (match_operand:SI 1 "register_operand" "")
8673 (match_operand:SI 2 "uint5_operand" "")
8674 (match_operand:SI 3 "uint5_operand" "")))]
8675 ""
8676 "
8677 {
8678 unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
8679 unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
8680
8681 /* PA extraction insns don't support zero length bitfields or fields
8682 extending beyond the left or right-most bits. Also, the predicate
8683 rejects lengths equal to a word as they are better handled by
8684 the move patterns. */
8685 if (len == 0 || pos + len > 32)
8686 FAIL;
8687
8688 /* From mips.md: extract_bit_field doesn't verify that our source
8689 matches the predicate, so check it again here. */
8690 if (!register_operand (operands[1], VOIDmode))
8691 FAIL;
8692
8693 emit_insn (gen_extzv_32 (operands[0], operands[1],
8694 operands[2], operands[3]));
8695 DONE;
8696 }")
8697
8698 (define_insn "extzv_32"
8699 [(set (match_operand:SI 0 "register_operand" "=r")
8700 (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
8701 (match_operand:SI 2 "uint5_operand" "")
8702 (match_operand:SI 3 "uint5_operand" "")))]
8703 "UINTVAL (operands[2]) > 0
8704 && UINTVAL (operands[2]) + UINTVAL (operands[3]) <= 32"
8705 "{extru|extrw,u} %1,%3+%2-1,%2,%0"
8706 [(set_attr "type" "shift")
8707 (set_attr "length" "4")])
8708
8709 (define_insn ""
8710 [(set (match_operand:SI 0 "register_operand" "=r")
8711 (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
8712 (const_int 1)
8713 (match_operand:SI 2 "register_operand" "q")))]
8714 ""
8715 "{vextru %1,1,%0|extrw,u %1,%%sar,1,%0}"
8716 [(set_attr "type" "shift")
8717 (set_attr "length" "4")])
8718
8719 (define_expand "extzvdi"
8720 [(set (match_operand:DI 0 "register_operand" "")
8721 (zero_extract:DI (match_operand:DI 1 "register_operand" "")
8722 (match_operand:DI 2 "uint6_operand" "")
8723 (match_operand:DI 3 "uint6_operand" "")))]
8724 "TARGET_64BIT"
8725 "
8726 {
8727 unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
8728 unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
8729
8730 /* PA extraction insns don't support zero length bitfields or fields
8731 extending beyond the left or right-most bits. Also, the predicate
8732 rejects lengths equal to a doubleword as they are better handled by
8733 the move patterns. */
8734 if (len == 0 || pos + len > 64)
8735 FAIL;
8736
8737 /* From mips.md: extract_bit_field doesn't verify that our source
8738 matches the predicate, so check it again here. */
8739 if (!register_operand (operands[1], VOIDmode))
8740 FAIL;
8741
8742 emit_insn (gen_extzv_64 (operands[0], operands[1],
8743 operands[2], operands[3]));
8744 DONE;
8745 }")
8746
8747 (define_insn "extzv_64"
8748 [(set (match_operand:DI 0 "register_operand" "=r")
8749 (zero_extract:DI (match_operand:DI 1 "register_operand" "r")
8750 (match_operand:DI 2 "uint6_operand" "")
8751 (match_operand:DI 3 "uint6_operand" "")))]
8752 "TARGET_64BIT
8753 && UINTVAL (operands[2]) > 0
8754 && UINTVAL (operands[2]) + UINTVAL (operands[3]) <= 64"
8755 "extrd,u %1,%3+%2-1,%2,%0"
8756 [(set_attr "type" "shift")
8757 (set_attr "length" "4")])
8758
8759 (define_insn ""
8760 [(set (match_operand:DI 0 "register_operand" "=r")
8761 (zero_extract:DI (match_operand:DI 1 "register_operand" "r")
8762 (const_int 1)
8763 (match_operand:DI 2 "register_operand" "q")))]
8764 "TARGET_64BIT"
8765 "extrd,u %1,%%sar,1,%0"
8766 [(set_attr "type" "shift")
8767 (set_attr "length" "4")])
8768
8769 ;;; Operands 2 and 3 are assumed to be CONST_INTs.
8770 (define_expand "extvsi"
8771 [(set (match_operand:SI 0 "register_operand" "")
8772 (sign_extract:SI (match_operand:SI 1 "register_operand" "")
8773 (match_operand:SI 2 "uint5_operand" "")
8774 (match_operand:SI 3 "uint5_operand" "")))]
8775 ""
8776 "
8777 {
8778 unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
8779 unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
8780
8781 /* PA extraction insns don't support zero length bitfields or fields
8782 extending beyond the left or right-most bits. Also, the predicate
8783 rejects lengths equal to a word as they are better handled by
8784 the move patterns. */
8785 if (len == 0 || pos + len > 32)
8786 FAIL;
8787
8788 /* From mips.md: extract_bit_field doesn't verify that our source
8789 matches the predicate, so check it again here. */
8790 if (!register_operand (operands[1], VOIDmode))
8791 FAIL;
8792
8793 emit_insn (gen_extv_32 (operands[0], operands[1],
8794 operands[2], operands[3]));
8795 DONE;
8796 }")
8797
8798 (define_insn "extv_32"
8799 [(set (match_operand:SI 0 "register_operand" "=r")
8800 (sign_extract:SI (match_operand:SI 1 "register_operand" "r")
8801 (match_operand:SI 2 "uint5_operand" "")
8802 (match_operand:SI 3 "uint5_operand" "")))]
8803 "UINTVAL (operands[2]) > 0
8804 && UINTVAL (operands[2]) + UINTVAL (operands[3]) <= 32"
8805 "{extrs|extrw,s} %1,%3+%2-1,%2,%0"
8806 [(set_attr "type" "shift")
8807 (set_attr "length" "4")])
8808
8809 (define_insn ""
8810 [(set (match_operand:SI 0 "register_operand" "=r")
8811 (sign_extract:SI (match_operand:SI 1 "register_operand" "r")
8812 (const_int 1)
8813 (match_operand:SI 2 "register_operand" "q")))]
8814 "!TARGET_64BIT"
8815 "{vextrs %1,1,%0|extrw,s %1,%%sar,1,%0}"
8816 [(set_attr "type" "shift")
8817 (set_attr "length" "4")])
8818
8819 (define_expand "extvdi"
8820 [(set (match_operand:DI 0 "register_operand" "")
8821 (sign_extract:DI (match_operand:DI 1 "register_operand" "")
8822 (match_operand:DI 2 "uint6_operand" "")
8823 (match_operand:DI 3 "uint6_operand" "")))]
8824 "TARGET_64BIT"
8825 "
8826 {
8827 unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
8828 unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
8829
8830 /* PA extraction insns don't support zero length bitfields or fields
8831 extending beyond the left or right-most bits. Also, the predicate
8832 rejects lengths equal to a doubleword as they are better handled by
8833 the move patterns. */
8834 if (len == 0 || pos + len > 64)
8835 FAIL;
8836
8837 /* From mips.md: extract_bit_field doesn't verify that our source
8838 matches the predicate, so check it again here. */
8839 if (!register_operand (operands[1], VOIDmode))
8840 FAIL;
8841
8842 emit_insn (gen_extv_64 (operands[0], operands[1],
8843 operands[2], operands[3]));
8844 DONE;
8845 }")
8846
8847 (define_insn "extv_64"
8848 [(set (match_operand:DI 0 "register_operand" "=r")
8849 (sign_extract:DI (match_operand:DI 1 "register_operand" "r")
8850 (match_operand:DI 2 "uint6_operand" "")
8851 (match_operand:DI 3 "uint6_operand" "")))]
8852 "TARGET_64BIT
8853 && UINTVAL (operands[2]) > 0
8854 && UINTVAL (operands[2]) + UINTVAL (operands[3]) <= 64"
8855 "extrd,s %1,%3+%2-1,%2,%0"
8856 [(set_attr "type" "shift")
8857 (set_attr "length" "4")])
8858
8859 (define_insn ""
8860 [(set (match_operand:DI 0 "register_operand" "=r")
8861 (sign_extract:DI (match_operand:DI 1 "register_operand" "r")
8862 (const_int 1)
8863 (match_operand:DI 2 "register_operand" "q")))]
8864 "TARGET_64BIT"
8865 "extrd,s %1,%%sar,1,%0"
8866 [(set_attr "type" "shift")
8867 (set_attr "length" "4")])
8868
8869 ;;; Operands 1 and 2 are assumed to be CONST_INTs.
8870 (define_expand "insvsi"
8871 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "")
8872 (match_operand:SI 1 "uint5_operand" "")
8873 (match_operand:SI 2 "uint5_operand" ""))
8874 (match_operand:SI 3 "arith5_operand" ""))]
8875 ""
8876 "
8877 {
8878 unsigned HOST_WIDE_INT len = UINTVAL (operands[1]);
8879 unsigned HOST_WIDE_INT pos = UINTVAL (operands[2]);
8880
8881 /* PA insertion insns don't support zero length bitfields or fields
8882 extending beyond the left or right-most bits. Also, the predicate
8883 rejects lengths equal to a word as they are better handled by
8884 the move patterns. */
8885 if (len <= 0 || pos + len > 32)
8886 FAIL;
8887
8888 /* From mips.md: insert_bit_field doesn't verify that our destination
8889 matches the predicate, so check it again here. */
8890 if (!register_operand (operands[0], VOIDmode))
8891 FAIL;
8892
8893 emit_insn (gen_insv_32 (operands[0], operands[1],
8894 operands[2], operands[3]));
8895 DONE;
8896 }")
8897
8898 (define_insn "insv_32"
8899 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r,r")
8900 (match_operand:SI 1 "uint5_operand" "")
8901 (match_operand:SI 2 "uint5_operand" ""))
8902 (match_operand:SI 3 "arith5_operand" "r,L"))]
8903 "UINTVAL (operands[1]) > 0
8904 && UINTVAL (operands[1]) + UINTVAL (operands[2]) <= 32"
8905 "@
8906 {dep|depw} %3,%2+%1-1,%1,%0
8907 {depi|depwi} %3,%2+%1-1,%1,%0"
8908 [(set_attr "type" "shift,shift")
8909 (set_attr "length" "4,4")])
8910
8911 ;; Optimize insertion of const_int values of type 1...1xxxx.
8912 (define_insn ""
8913 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
8914 (match_operand:SI 1 "uint5_operand" "")
8915 (match_operand:SI 2 "uint5_operand" ""))
8916 (match_operand:SI 3 "const_int_operand" ""))]
8917 "(INTVAL (operands[3]) & 0x10) != 0 &&
8918 (~INTVAL (operands[3]) & ((1L << INTVAL (operands[1])) - 1) & ~0xf) == 0"
8919 "*
8920 {
8921 operands[3] = GEN_INT ((INTVAL (operands[3]) & 0xf) - 0x10);
8922 return \"{depi|depwi} %3,%2+%1-1,%1,%0\";
8923 }"
8924 [(set_attr "type" "shift")
8925 (set_attr "length" "4")])
8926
8927 (define_expand "insvdi"
8928 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "")
8929 (match_operand:DI 1 "uint6_operand" "")
8930 (match_operand:DI 2 "uint6_operand" ""))
8931 (match_operand:DI 3 "arith5_operand" ""))]
8932 "TARGET_64BIT"
8933 "
8934 {
8935 unsigned HOST_WIDE_INT len = UINTVAL (operands[1]);
8936 unsigned HOST_WIDE_INT pos = UINTVAL (operands[2]);
8937
8938 /* PA insertion insns don't support zero length bitfields or fields
8939 extending beyond the left or right-most bits. Also, the predicate
8940 rejects lengths equal to a doubleword as they are better handled by
8941 the move patterns. */
8942 if (len <= 0 || pos + len > 64)
8943 FAIL;
8944
8945 /* From mips.md: insert_bit_field doesn't verify that our destination
8946 matches the predicate, so check it again here. */
8947 if (!register_operand (operands[0], VOIDmode))
8948 FAIL;
8949
8950 emit_insn (gen_insv_64 (operands[0], operands[1],
8951 operands[2], operands[3]));
8952 DONE;
8953 }")
8954
8955 (define_insn "insv_64"
8956 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+r,r")
8957 (match_operand:DI 1 "uint6_operand" "")
8958 (match_operand:DI 2 "uint6_operand" ""))
8959 (match_operand:DI 3 "arith5_operand" "r,L"))]
8960 "TARGET_64BIT
8961 && UINTVAL (operands[1]) > 0
8962 && UINTVAL (operands[1]) + UINTVAL (operands[2]) <= 64"
8963 "@
8964 depd %3,%2+%1-1,%1,%0
8965 depdi %3,%2+%1-1,%1,%0"
8966 [(set_attr "type" "shift,shift")
8967 (set_attr "length" "4,4")])
8968
8969 ;; Optimize insertion of const_int values of type 1...1xxxx.
8970 (define_insn ""
8971 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+r")
8972 (match_operand:DI 1 "uint6_operand" "")
8973 (match_operand:DI 2 "uint6_operand" ""))
8974 (match_operand:DI 3 "const_int_operand" ""))]
8975 "(INTVAL (operands[3]) & 0x10) != 0
8976 && TARGET_64BIT
8977 && (~INTVAL (operands[3]) & ((1L << INTVAL (operands[1])) - 1) & ~0xf) == 0"
8978 "*
8979 {
8980 operands[3] = GEN_INT ((INTVAL (operands[3]) & 0xf) - 0x10);
8981 return \"depdi %3,%2+%1-1,%1,%0\";
8982 }"
8983 [(set_attr "type" "shift")
8984 (set_attr "length" "4")])
8985
8986 (define_insn ""
8987 [(set (match_operand:DI 0 "register_operand" "=r")
8988 (ashift:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
8989 (const_int 32)))]
8990 "TARGET_64BIT"
8991 "depd,z %1,31,32,%0"
8992 [(set_attr "type" "shift")
8993 (set_attr "length" "4")])
8994
8995 ;; This insn is used for some loop tests, typically loops reversed when
8996 ;; strength reduction is used. It is actually created when the instruction
8997 ;; combination phase combines the special loop test. Since this insn
8998 ;; is both a jump insn and has an output, it must deal with its own
8999 ;; reloads, hence the `Q' constraints. The `!' constraints direct reload
9000 ;; to not choose the register alternatives in the event a reload is needed.
9001 (define_insn "decrement_and_branch_until_zero"
9002 [(set (pc)
9003 (if_then_else
9004 (match_operator 2 "comparison_operator"
9005 [(plus:SI
9006 (match_operand:SI 0 "reg_before_reload_operand" "+!r,!*f,*Q")
9007 (match_operand:SI 1 "int5_operand" "L,L,L"))
9008 (const_int 0)])
9009 (label_ref (match_operand 3 "" ""))
9010 (pc)))
9011 (set (match_dup 0)
9012 (plus:SI (match_dup 0) (match_dup 1)))
9013 (clobber (match_scratch:SI 4 "=X,r,r"))]
9014 ""
9015 "* return pa_output_dbra (operands, insn, which_alternative); "
9016 ;; Do not expect to understand this the first time through.
9017 [(set_attr "type" "cbranch,multi,multi")
9018 (set (attr "length")
9019 (if_then_else (eq_attr "alternative" "0")
9020 ;; Loop counter in register case
9021 ;; Short branch has length of 4
9022 ;; Long branch has length of 8, 20, 24 or 28
9023 (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9024 (const_int MAX_12BIT_OFFSET))
9025 (const_int 4)
9026 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9027 (const_int MAX_17BIT_OFFSET))
9028 (const_int 8)
9029 (match_test "TARGET_PORTABLE_RUNTIME")
9030 (const_int 24)
9031 (not (match_test "flag_pic"))
9032 (const_int 20)]
9033 (const_int 28))
9034
9035 ;; Loop counter in FP reg case.
9036 ;; Extra goo to deal with additional reload insns.
9037 (if_then_else (eq_attr "alternative" "1")
9038 (if_then_else (lt (match_dup 3) (pc))
9039 (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 24))))
9040 (const_int MAX_12BIT_OFFSET))
9041 (const_int 24)
9042 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 24))))
9043 (const_int MAX_17BIT_OFFSET))
9044 (const_int 28)
9045 (match_test "TARGET_PORTABLE_RUNTIME")
9046 (const_int 44)
9047 (not (match_test "flag_pic"))
9048 (const_int 40)]
9049 (const_int 48))
9050 (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9051 (const_int MAX_12BIT_OFFSET))
9052 (const_int 24)
9053 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9054 (const_int MAX_17BIT_OFFSET))
9055 (const_int 28)
9056 (match_test "TARGET_PORTABLE_RUNTIME")
9057 (const_int 44)
9058 (not (match_test "flag_pic"))
9059 (const_int 40)]
9060 (const_int 48)))
9061
9062 ;; Loop counter in memory case.
9063 ;; Extra goo to deal with additional reload insns.
9064 (if_then_else (lt (match_dup 3) (pc))
9065 (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9066 (const_int MAX_12BIT_OFFSET))
9067 (const_int 12)
9068 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9069 (const_int MAX_17BIT_OFFSET))
9070 (const_int 16)
9071 (match_test "TARGET_PORTABLE_RUNTIME")
9072 (const_int 32)
9073 (not (match_test "flag_pic"))
9074 (const_int 28)]
9075 (const_int 36))
9076 (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9077 (const_int MAX_12BIT_OFFSET))
9078 (const_int 12)
9079 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9080 (const_int MAX_17BIT_OFFSET))
9081 (const_int 16)
9082 (match_test "TARGET_PORTABLE_RUNTIME")
9083 (const_int 32)
9084 (not (match_test "flag_pic"))
9085 (const_int 28)]
9086 (const_int 36))))))])
9087
9088 (define_insn ""
9089 [(set (pc)
9090 (if_then_else
9091 (match_operator 2 "movb_comparison_operator"
9092 [(match_operand:SI 1 "register_operand" "r,r,r,r") (const_int 0)])
9093 (label_ref (match_operand 3 "" ""))
9094 (pc)))
9095 (set (match_operand:SI 0 "reg_before_reload_operand" "=!r,!*f,*Q,!*q")
9096 (match_dup 1))]
9097 ""
9098 "* return pa_output_movb (operands, insn, which_alternative, 0); "
9099 ;; Do not expect to understand this the first time through.
9100 [(set_attr "type" "cbranch,multi,multi,multi")
9101 (set (attr "length")
9102 (if_then_else (eq_attr "alternative" "0")
9103 ;; Loop counter in register case
9104 ;; Short branch has length of 4
9105 ;; Long branch has length of 8, 20, 24 or 28
9106 (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9107 (const_int MAX_12BIT_OFFSET))
9108 (const_int 4)
9109 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9110 (const_int MAX_17BIT_OFFSET))
9111 (const_int 8)
9112 (match_test "TARGET_PORTABLE_RUNTIME")
9113 (const_int 24)
9114 (not (match_test "flag_pic"))
9115 (const_int 20)]
9116 (const_int 28))
9117
9118 ;; Loop counter in FP reg case.
9119 ;; Extra goo to deal with additional reload insns.
9120 (if_then_else (eq_attr "alternative" "1")
9121 (if_then_else (lt (match_dup 3) (pc))
9122 (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9123 (const_int MAX_12BIT_OFFSET))
9124 (const_int 12)
9125 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9126 (const_int MAX_17BIT_OFFSET))
9127 (const_int 16)
9128 (match_test "TARGET_PORTABLE_RUNTIME")
9129 (const_int 32)
9130 (not (match_test "flag_pic"))
9131 (const_int 28)]
9132 (const_int 36))
9133 (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9134 (const_int MAX_12BIT_OFFSET))
9135 (const_int 12)
9136 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9137 (const_int MAX_17BIT_OFFSET))
9138 (const_int 16)
9139 (match_test "TARGET_PORTABLE_RUNTIME")
9140 (const_int 32)
9141 (not (match_test "flag_pic"))
9142 (const_int 28)]
9143 (const_int 36)))
9144
9145 ;; Loop counter in memory or sar case.
9146 ;; Extra goo to deal with additional reload insns.
9147 (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9148 (const_int MAX_12BIT_OFFSET))
9149 (const_int 8)
9150 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9151 (const_int MAX_17BIT_OFFSET))
9152 (const_int 12)
9153 (match_test "TARGET_PORTABLE_RUNTIME")
9154 (const_int 28)
9155 (not (match_test "flag_pic"))
9156 (const_int 24)]
9157 (const_int 32)))))])
9158
9159 ;; Handle negated branch.
9160 (define_insn ""
9161 [(set (pc)
9162 (if_then_else
9163 (match_operator 2 "movb_comparison_operator"
9164 [(match_operand:SI 1 "register_operand" "r,r,r,r") (const_int 0)])
9165 (pc)
9166 (label_ref (match_operand 3 "" ""))))
9167 (set (match_operand:SI 0 "reg_before_reload_operand" "=!r,!*f,*Q,!*q")
9168 (match_dup 1))]
9169 ""
9170 "* return pa_output_movb (operands, insn, which_alternative, 1); "
9171 ;; Do not expect to understand this the first time through.
9172 [(set_attr "type" "cbranch,multi,multi,multi")
9173 (set (attr "length")
9174 (if_then_else (eq_attr "alternative" "0")
9175 ;; Loop counter in register case
9176 ;; Short branch has length of 4
9177 ;; Long branch has length of 8
9178 (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9179 (const_int MAX_12BIT_OFFSET))
9180 (const_int 4)
9181 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9182 (const_int MAX_17BIT_OFFSET))
9183 (const_int 8)
9184 (match_test "TARGET_PORTABLE_RUNTIME")
9185 (const_int 24)
9186 (not (match_test "flag_pic"))
9187 (const_int 20)]
9188 (const_int 28))
9189
9190 ;; Loop counter in FP reg case.
9191 ;; Extra goo to deal with additional reload insns.
9192 (if_then_else (eq_attr "alternative" "1")
9193 (if_then_else (lt (match_dup 3) (pc))
9194 (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9195 (const_int MAX_12BIT_OFFSET))
9196 (const_int 12)
9197 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
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 (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9206 (const_int MAX_12BIT_OFFSET))
9207 (const_int 12)
9208 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9209 (const_int MAX_17BIT_OFFSET))
9210 (const_int 16)
9211 (match_test "TARGET_PORTABLE_RUNTIME")
9212 (const_int 32)
9213 (not (match_test "flag_pic"))
9214 (const_int 28)]
9215 (const_int 36)))
9216
9217 ;; Loop counter in memory or SAR case.
9218 ;; Extra goo to deal with additional reload insns.
9219 (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9220 (const_int MAX_12BIT_OFFSET))
9221 (const_int 8)
9222 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9223 (const_int MAX_17BIT_OFFSET))
9224 (const_int 12)
9225 (match_test "TARGET_PORTABLE_RUNTIME")
9226 (const_int 28)
9227 (not (match_test "flag_pic"))
9228 (const_int 24)]
9229 (const_int 32)))))])
9230
9231 (define_insn ""
9232 [(set (pc) (label_ref (match_operand 3 "" "" )))
9233 (set (match_operand:SI 0 "ireg_operand" "=r")
9234 (plus:SI (match_operand:SI 1 "ireg_operand" "r")
9235 (match_operand:SI 2 "ireg_or_int5_operand" "rL")))]
9236 "(reload_completed && operands[0] == operands[1]) || operands[0] == operands[2]"
9237 "*
9238 {
9239 return pa_output_parallel_addb (operands, insn);
9240 }"
9241 [(set_attr "type" "parallel_branch")
9242 (set (attr "length")
9243 (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9244 (const_int MAX_12BIT_OFFSET))
9245 (const_int 4)
9246 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9247 (const_int MAX_17BIT_OFFSET))
9248 (const_int 8)
9249 (match_test "TARGET_PORTABLE_RUNTIME")
9250 (const_int 24)
9251 (not (match_test "flag_pic"))
9252 (const_int 20)]
9253 (const_int 28)))])
9254
9255 (define_insn ""
9256 [(set (pc) (label_ref (match_operand 2 "" "" )))
9257 (set (match_operand:SF 0 "ireg_operand" "=r")
9258 (match_operand:SF 1 "ireg_or_int5_operand" "rL"))]
9259 "reload_completed"
9260 "*
9261 {
9262 return pa_output_parallel_movb (operands, insn);
9263 }"
9264 [(set_attr "type" "parallel_branch")
9265 (set (attr "length")
9266 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9267 (const_int MAX_12BIT_OFFSET))
9268 (const_int 4)
9269 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9270 (const_int MAX_17BIT_OFFSET))
9271 (const_int 8)
9272 (match_test "TARGET_PORTABLE_RUNTIME")
9273 (const_int 24)
9274 (not (match_test "flag_pic"))
9275 (const_int 20)]
9276 (const_int 28)))])
9277
9278 (define_insn ""
9279 [(set (pc) (label_ref (match_operand 2 "" "" )))
9280 (set (match_operand:SI 0 "ireg_operand" "=r")
9281 (match_operand:SI 1 "ireg_or_int5_operand" "rL"))]
9282 "reload_completed"
9283 "*
9284 {
9285 return pa_output_parallel_movb (operands, insn);
9286 }"
9287 [(set_attr "type" "parallel_branch")
9288 (set (attr "length")
9289 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9290 (const_int MAX_12BIT_OFFSET))
9291 (const_int 4)
9292 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9293 (const_int MAX_17BIT_OFFSET))
9294 (const_int 8)
9295 (match_test "TARGET_PORTABLE_RUNTIME")
9296 (const_int 24)
9297 (not (match_test "flag_pic"))
9298 (const_int 20)]
9299 (const_int 28)))])
9300
9301 (define_insn ""
9302 [(set (pc) (label_ref (match_operand 2 "" "" )))
9303 (set (match_operand:HI 0 "ireg_operand" "=r")
9304 (match_operand:HI 1 "ireg_or_int5_operand" "rL"))]
9305 "reload_completed"
9306 "*
9307 {
9308 return pa_output_parallel_movb (operands, insn);
9309 }"
9310 [(set_attr "type" "parallel_branch")
9311 (set (attr "length")
9312 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9313 (const_int MAX_12BIT_OFFSET))
9314 (const_int 4)
9315 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9316 (const_int MAX_17BIT_OFFSET))
9317 (const_int 8)
9318 (match_test "TARGET_PORTABLE_RUNTIME")
9319 (const_int 24)
9320 (not (match_test "flag_pic"))
9321 (const_int 20)]
9322 (const_int 28)))])
9323
9324 (define_insn ""
9325 [(set (pc) (label_ref (match_operand 2 "" "" )))
9326 (set (match_operand:QI 0 "ireg_operand" "=r")
9327 (match_operand:QI 1 "ireg_or_int5_operand" "rL"))]
9328 "reload_completed"
9329 "*
9330 {
9331 return pa_output_parallel_movb (operands, insn);
9332 }"
9333 [(set_attr "type" "parallel_branch")
9334 (set (attr "length")
9335 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9336 (const_int MAX_12BIT_OFFSET))
9337 (const_int 4)
9338 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9339 (const_int MAX_17BIT_OFFSET))
9340 (const_int 8)
9341 (match_test "TARGET_PORTABLE_RUNTIME")
9342 (const_int 24)
9343 (not (match_test "flag_pic"))
9344 (const_int 20)]
9345 (const_int 28)))])
9346
9347 (define_insn ""
9348 [(set (match_operand 0 "register_operand" "=f")
9349 (mult (match_operand 1 "register_operand" "f")
9350 (match_operand 2 "register_operand" "f")))
9351 (set (match_operand 3 "register_operand" "+f")
9352 (plus (match_operand 4 "register_operand" "f")
9353 (match_operand 5 "register_operand" "f")))]
9354 "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9355 && reload_completed && pa_fmpyaddoperands (operands)"
9356 "*
9357 {
9358 if (GET_MODE (operands[0]) == DFmode)
9359 {
9360 if (rtx_equal_p (operands[3], operands[5]))
9361 return \"fmpyadd,dbl %1,%2,%0,%4,%3\";
9362 else
9363 return \"fmpyadd,dbl %1,%2,%0,%5,%3\";
9364 }
9365 else
9366 {
9367 if (rtx_equal_p (operands[3], operands[5]))
9368 return \"fmpyadd,sgl %1,%2,%0,%4,%3\";
9369 else
9370 return \"fmpyadd,sgl %1,%2,%0,%5,%3\";
9371 }
9372 }"
9373 [(set_attr "type" "fpalu")
9374 (set_attr "length" "4")])
9375
9376 (define_insn ""
9377 [(set (match_operand 3 "register_operand" "+f")
9378 (plus (match_operand 4 "register_operand" "f")
9379 (match_operand 5 "register_operand" "f")))
9380 (set (match_operand 0 "register_operand" "=f")
9381 (mult (match_operand 1 "register_operand" "f")
9382 (match_operand 2 "register_operand" "f")))]
9383 "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9384 && reload_completed && pa_fmpyaddoperands (operands)"
9385 "*
9386 {
9387 if (GET_MODE (operands[0]) == DFmode)
9388 {
9389 if (rtx_equal_p (operands[3], operands[5]))
9390 return \"fmpyadd,dbl %1,%2,%0,%4,%3\";
9391 else
9392 return \"fmpyadd,dbl %1,%2,%0,%5,%3\";
9393 }
9394 else
9395 {
9396 if (rtx_equal_p (operands[3], operands[5]))
9397 return \"fmpyadd,sgl %1,%2,%0,%4,%3\";
9398 else
9399 return \"fmpyadd,sgl %1,%2,%0,%5,%3\";
9400 }
9401 }"
9402 [(set_attr "type" "fpalu")
9403 (set_attr "length" "4")])
9404
9405 (define_insn ""
9406 [(set (match_operand 0 "register_operand" "=f")
9407 (mult (match_operand 1 "register_operand" "f")
9408 (match_operand 2 "register_operand" "f")))
9409 (set (match_operand 3 "register_operand" "+f")
9410 (minus (match_operand 4 "register_operand" "f")
9411 (match_operand 5 "register_operand" "f")))]
9412 "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9413 && reload_completed && pa_fmpysuboperands (operands)"
9414 "*
9415 {
9416 if (GET_MODE (operands[0]) == DFmode)
9417 return \"fmpysub,dbl %1,%2,%0,%5,%3\";
9418 else
9419 return \"fmpysub,sgl %1,%2,%0,%5,%3\";
9420 }"
9421 [(set_attr "type" "fpalu")
9422 (set_attr "length" "4")])
9423
9424 (define_insn ""
9425 [(set (match_operand 3 "register_operand" "+f")
9426 (minus (match_operand 4 "register_operand" "f")
9427 (match_operand 5 "register_operand" "f")))
9428 (set (match_operand 0 "register_operand" "=f")
9429 (mult (match_operand 1 "register_operand" "f")
9430 (match_operand 2 "register_operand" "f")))]
9431 "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9432 && reload_completed && pa_fmpysuboperands (operands)"
9433 "*
9434 {
9435 if (GET_MODE (operands[0]) == DFmode)
9436 return \"fmpysub,dbl %1,%2,%0,%5,%3\";
9437 else
9438 return \"fmpysub,sgl %1,%2,%0,%5,%3\";
9439 }"
9440 [(set_attr "type" "fpalu")
9441 (set_attr "length" "4")])
9442
9443 ;; The following two patterns are used by the trampoline code for nested
9444 ;; functions. They flush the I and D cache lines from the start address
9445 ;; (operand0) to the end address (operand1). No lines are flushed if the
9446 ;; end address is less than the start address (unsigned).
9447 ;;
9448 ;; Because the range of memory flushed is variable and the size of a MEM
9449 ;; can only be a CONST_INT, the patterns specify that they perform an
9450 ;; unspecified volatile operation on all memory.
9451 ;;
9452 ;; The address range for an icache flush must lie within a single
9453 ;; space on targets with non-equivalent space registers.
9454 ;;
9455 ;; Operand 0 contains the start address.
9456 ;; Operand 1 contains the end address.
9457 ;; Operand 2 contains the line length to use.
9458 (define_insn "dcacheflush<P:mode>"
9459 [(const_int 1)
9460 (unspec_volatile [(mem:BLK (scratch))] UNSPECV_DCACHE)
9461 (use (match_operand 0 "pmode_register_operand" "r"))
9462 (use (match_operand 1 "pmode_register_operand" "r"))
9463 (use (match_operand 2 "pmode_register_operand" "r"))
9464 (clobber (match_scratch:P 3 "=&0"))]
9465 ""
9466 "cmpb,<dwc><<=,n %3,%1,.\;fdc,m %2(%3)\;sync"
9467 [(set_attr "type" "multi")
9468 (set_attr "length" "12")])
9469
9470 (define_insn "icacheflush<P:mode>"
9471 [(const_int 2)
9472 (unspec_volatile [(mem:BLK (scratch))] UNSPECV_ICACHE)
9473 (use (match_operand 0 "pmode_register_operand" "r"))
9474 (use (match_operand 1 "pmode_register_operand" "r"))
9475 (use (match_operand 2 "pmode_register_operand" "r"))
9476 (clobber (match_operand 3 "pmode_register_operand" "=&r"))
9477 (clobber (match_operand 4 "pmode_register_operand" "=&r"))
9478 (clobber (match_scratch:P 5 "=&0"))]
9479 ""
9480 "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"
9481 [(set_attr "type" "multi")
9482 (set_attr "length" "52")])
9483
9484 ;; An out-of-line prologue.
9485 (define_insn "outline_prologue_call"
9486 [(unspec_volatile [(const_int 0)] UNSPECV_OPC)
9487 (clobber (reg:SI 31))
9488 (clobber (reg:SI 22))
9489 (clobber (reg:SI 21))
9490 (clobber (reg:SI 20))
9491 (clobber (reg:SI 19))
9492 (clobber (reg:SI 1))]
9493 ""
9494 "*
9495 {
9496
9497 /* We need two different versions depending on whether or not we
9498 need a frame pointer. Also note that we return to the instruction
9499 immediately after the branch rather than two instructions after the
9500 break as normally is the case. */
9501 if (frame_pointer_needed)
9502 {
9503 /* Must import the magic millicode routine(s). */
9504 output_asm_insn (\".IMPORT __outline_prologue_fp,MILLICODE\", NULL);
9505
9506 if (TARGET_PORTABLE_RUNTIME)
9507 {
9508 output_asm_insn (\"ldil L'__outline_prologue_fp,%%r31\", NULL);
9509 output_asm_insn (\"ble,n R'__outline_prologue_fp(%%sr0,%%r31)\",
9510 NULL);
9511 }
9512 else
9513 output_asm_insn (\"{bl|b,l},n __outline_prologue_fp,%%r31\", NULL);
9514 }
9515 else
9516 {
9517 /* Must import the magic millicode routine(s). */
9518 output_asm_insn (\".IMPORT __outline_prologue,MILLICODE\", NULL);
9519
9520 if (TARGET_PORTABLE_RUNTIME)
9521 {
9522 output_asm_insn (\"ldil L'__outline_prologue,%%r31\", NULL);
9523 output_asm_insn (\"ble,n R'__outline_prologue(%%sr0,%%r31)\", NULL);
9524 }
9525 else
9526 output_asm_insn (\"{bl|b,l},n __outline_prologue,%%r31\", NULL);
9527 }
9528 return \"\";
9529 }"
9530 [(set_attr "type" "multi")
9531 (set_attr "length" "8")])
9532
9533 ;; An out-of-line epilogue.
9534 (define_insn "outline_epilogue_call"
9535 [(unspec_volatile [(const_int 1)] UNSPECV_OEC)
9536 (use (reg:SI 29))
9537 (use (reg:SI 28))
9538 (clobber (reg:SI 31))
9539 (clobber (reg:SI 22))
9540 (clobber (reg:SI 21))
9541 (clobber (reg:SI 20))
9542 (clobber (reg:SI 19))
9543 (clobber (reg:SI 2))
9544 (clobber (reg:SI 1))]
9545 ""
9546 "*
9547 {
9548
9549 /* We need two different versions depending on whether or not we
9550 need a frame pointer. Also note that we return to the instruction
9551 immediately after the branch rather than two instructions after the
9552 break as normally is the case. */
9553 if (frame_pointer_needed)
9554 {
9555 /* Must import the magic millicode routine. */
9556 output_asm_insn (\".IMPORT __outline_epilogue_fp,MILLICODE\", NULL);
9557
9558 /* The out-of-line prologue will make sure we return to the right
9559 instruction. */
9560 if (TARGET_PORTABLE_RUNTIME)
9561 {
9562 output_asm_insn (\"ldil L'__outline_epilogue_fp,%%r31\", NULL);
9563 output_asm_insn (\"ble,n R'__outline_epilogue_fp(%%sr0,%%r31)\",
9564 NULL);
9565 }
9566 else
9567 output_asm_insn (\"{bl|b,l},n __outline_epilogue_fp,%%r31\", NULL);
9568 }
9569 else
9570 {
9571 /* Must import the magic millicode routine. */
9572 output_asm_insn (\".IMPORT __outline_epilogue,MILLICODE\", NULL);
9573
9574 /* The out-of-line prologue will make sure we return to the right
9575 instruction. */
9576 if (TARGET_PORTABLE_RUNTIME)
9577 {
9578 output_asm_insn (\"ldil L'__outline_epilogue,%%r31\", NULL);
9579 output_asm_insn (\"ble,n R'__outline_epilogue(%%sr0,%%r31)\", NULL);
9580 }
9581 else
9582 output_asm_insn (\"{bl|b,l},n __outline_epilogue,%%r31\", NULL);
9583 }
9584 return \"\";
9585 }"
9586 [(set_attr "type" "multi")
9587 (set_attr "length" "8")])
9588
9589 ;; Given a function pointer, canonicalize it so it can be
9590 ;; reliably compared to another function pointer. */
9591 (define_expand "canonicalize_funcptr_for_compare"
9592 [(set (reg:SI 26) (match_operand:SI 1 "register_operand" ""))
9593 (parallel [(set (reg:SI 29) (unspec:SI [(reg:SI 26)] UNSPEC_CFFC))
9594 (clobber (match_dup 2))
9595 (clobber (reg:SI 26))
9596 (clobber (reg:SI 22))
9597 (clobber (reg:SI 31))])
9598 (set (match_operand:SI 0 "register_operand" "")
9599 (reg:SI 29))]
9600 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
9601 "
9602 {
9603 if (TARGET_ELF32)
9604 {
9605 rtx canonicalize_funcptr_for_compare_libfunc
9606 = init_one_libfunc (CANONICALIZE_FUNCPTR_FOR_COMPARE_LIBCALL);
9607
9608 emit_library_call_value (canonicalize_funcptr_for_compare_libfunc,
9609 operands[0], LCT_NORMAL, Pmode,
9610 1, operands[1], Pmode);
9611 DONE;
9612 }
9613
9614 operands[2] = gen_reg_rtx (SImode);
9615 if (GET_CODE (operands[1]) != REG)
9616 {
9617 rtx tmp = gen_reg_rtx (Pmode);
9618 emit_move_insn (tmp, operands[1]);
9619 operands[1] = tmp;
9620 }
9621 }")
9622
9623 (define_insn "*$$sh_func_adrs"
9624 [(set (reg:SI 29) (unspec:SI [(reg:SI 26)] UNSPEC_CFFC))
9625 (clobber (match_operand:SI 0 "register_operand" "=a"))
9626 (clobber (reg:SI 26))
9627 (clobber (reg:SI 22))
9628 (clobber (reg:SI 31))]
9629 "!TARGET_64BIT"
9630 "*
9631 {
9632 int length = get_attr_length (insn);
9633 rtx xoperands[2];
9634
9635 xoperands[0] = GEN_INT (length - 8);
9636 xoperands[1] = GEN_INT (length - 16);
9637
9638 /* Must import the magic millicode routine. */
9639 output_asm_insn (\".IMPORT $$sh_func_adrs,MILLICODE\", NULL);
9640
9641 /* This is absolutely amazing.
9642
9643 First, copy our input parameter into %r29 just in case we don't
9644 need to call $$sh_func_adrs. */
9645 output_asm_insn (\"copy %%r26,%%r29\", NULL);
9646 output_asm_insn (\"{extru|extrw,u} %%r26,31,2,%%r31\", NULL);
9647
9648 /* Next, examine the low two bits in %r26, if they aren't 0x2, then
9649 we use %r26 unchanged. */
9650 output_asm_insn (\"{comib|cmpib},<>,n 2,%%r31,.+%0\", xoperands);
9651 output_asm_insn (\"ldi 4096,%%r31\", NULL);
9652
9653 /* Next, compare %r26 with 4096, if %r26 is less than or equal to
9654 4096, then again we use %r26 unchanged. */
9655 output_asm_insn (\"{comb|cmpb},<<,n %%r26,%%r31,.+%1\", xoperands);
9656
9657 /* Finally, call $$sh_func_adrs to extract the function's real add24. */
9658 return pa_output_millicode_call (insn,
9659 gen_rtx_SYMBOL_REF (SImode,
9660 \"$$sh_func_adrs\"));
9661 }"
9662 [(set_attr "type" "sh_func_adrs")
9663 (set (attr "length")
9664 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 28)]
9665 (plus (symbol_ref "pa_attr_length_millicode_call (insn)")
9666 (const_int 20))))])
9667
9668 ;; On the PA, the PIC register is call clobbered, so it must
9669 ;; be saved & restored around calls by the caller. If the call
9670 ;; doesn't return normally (nonlocal goto, or an exception is
9671 ;; thrown), then the code at the exception handler label must
9672 ;; restore the PIC register.
9673 (define_expand "exception_receiver"
9674 [(const_int 4)]
9675 "flag_pic"
9676 "
9677 {
9678 /* On the 64-bit port, we need a blockage because there is
9679 confusion regarding the dependence of the restore on the
9680 frame pointer. As a result, the frame pointer and pic
9681 register restores sometimes are interchanged erroneously. */
9682 if (TARGET_64BIT)
9683 emit_insn (gen_blockage ());
9684 /* Restore the PIC register using hppa_pic_save_rtx (). The
9685 PIC register is not saved in the frame in 64-bit ABI. */
9686 emit_move_insn (pic_offset_table_rtx, hppa_pic_save_rtx ());
9687 emit_insn (gen_blockage ());
9688 DONE;
9689 }")
9690
9691 (define_expand "builtin_setjmp_receiver"
9692 [(label_ref (match_operand 0 "" ""))]
9693 "flag_pic"
9694 "
9695 {
9696 if (TARGET_64BIT)
9697 emit_insn (gen_blockage ());
9698 /* Restore the PIC register. Hopefully, this will always be from
9699 a stack slot. The only registers that are valid after a
9700 builtin_longjmp are the stack and frame pointers. */
9701 emit_move_insn (pic_offset_table_rtx, hppa_pic_save_rtx ());
9702 emit_insn (gen_blockage ());
9703 DONE;
9704 }")
9705
9706 ;; Allocate new stack space and update the saved stack pointer in the
9707 ;; frame marker. The HP C compilers also copy additional words in the
9708 ;; frame marker. The 64-bit compiler copies words at -48, -32 and -24.
9709 ;; The 32-bit compiler copies the word at -16 (Static Link). We
9710 ;; currently don't copy these values.
9711 ;;
9712 ;; Since the copy of the frame marker can't be done atomically, I
9713 ;; suspect that using it for unwind purposes may be somewhat unreliable.
9714 ;; The HP compilers appear to raise the stack and copy the frame
9715 ;; marker in a strict instruction sequence. This suggests that the
9716 ;; unwind library may check for an alloca sequence when ALLOCA_FRAME
9717 ;; is set in the callinfo data. We currently don't set ALLOCA_FRAME
9718 ;; as GAS doesn't support it, or try to keep the instructions emitted
9719 ;; here in strict sequence.
9720 (define_expand "allocate_stack"
9721 [(match_operand 0 "" "")
9722 (match_operand 1 "" "")]
9723 ""
9724 "
9725 {
9726 rtx addr;
9727
9728 /* Since the stack grows upward, we need to store virtual_stack_dynamic_rtx
9729 in operand 0 before adjusting the stack. */
9730 emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
9731 anti_adjust_stack (operands[1]);
9732 if (TARGET_HPUX_UNWIND_LIBRARY)
9733 {
9734 addr = gen_rtx_PLUS (word_mode, stack_pointer_rtx,
9735 GEN_INT (TARGET_64BIT ? -8 : -4));
9736 emit_move_insn (gen_rtx_MEM (word_mode, addr), hard_frame_pointer_rtx);
9737 }
9738 if (!TARGET_64BIT && flag_pic)
9739 {
9740 rtx addr = gen_rtx_PLUS (word_mode, stack_pointer_rtx, GEN_INT (-32));
9741 emit_move_insn (gen_rtx_MEM (word_mode, addr), pic_offset_table_rtx);
9742 }
9743 DONE;
9744 }")
9745
9746 (define_expand "prefetch"
9747 [(match_operand 0 "address_operand" "")
9748 (match_operand 1 "const_int_operand" "")
9749 (match_operand 2 "const_int_operand" "")]
9750 "TARGET_PA_20"
9751 {
9752 operands[0] = copy_addr_to_reg (operands[0]);
9753 emit_insn (gen_prefetch_20 (operands[0], operands[1], operands[2]));
9754 DONE;
9755 })
9756
9757 (define_insn "prefetch_20"
9758 [(prefetch (match_operand 0 "pmode_register_operand" "r")
9759 (match_operand:SI 1 "const_int_operand" "n")
9760 (match_operand:SI 2 "const_int_operand" "n"))]
9761 "TARGET_PA_20"
9762 {
9763 /* The SL cache-control completer indicates good spatial locality but
9764 poor temporal locality. The ldw instruction with a target of general
9765 register 0 prefetches a cache line for a read. The ldd instruction
9766 prefetches a cache line for a write. */
9767 static const char * const instr[2][2] = {
9768 {
9769 "ldw,sl 0(%0),%%r0",
9770 "ldd,sl 0(%0),%%r0"
9771 },
9772 {
9773 "ldw 0(%0),%%r0",
9774 "ldd 0(%0),%%r0"
9775 }
9776 };
9777 int read_or_write = INTVAL (operands[1]) == 0 ? 0 : 1;
9778 int locality = INTVAL (operands[2]) == 0 ? 0 : 1;
9779
9780 return instr [locality][read_or_write];
9781 }
9782 [(set_attr "type" "load")
9783 (set_attr "length" "4")])
9784
9785 ;; TLS Support
9786 (define_insn "tgd_load"
9787 [(set (match_operand:SI 0 "register_operand" "=r")
9788 (unspec:SI [(match_operand 1 "tgd_symbolic_operand" "")] UNSPEC_TLSGD))
9789 (clobber (reg:SI 1))
9790 (use (reg:SI 27))]
9791 ""
9792 "*
9793 {
9794 return \"addil LR'%1-$tls_gdidx$,%%r27\;ldo RR'%1-$tls_gdidx$(%%r1),%0\";
9795 }"
9796 [(set_attr "type" "multi")
9797 (set_attr "length" "8")])
9798
9799 (define_insn "tgd_load_pic"
9800 [(set (match_operand:SI 0 "register_operand" "=r")
9801 (unspec:SI [(match_operand 1 "tgd_symbolic_operand" "")] UNSPEC_TLSGD_PIC))
9802 (clobber (reg:SI 1))
9803 (use (reg:SI 19))]
9804 ""
9805 "*
9806 {
9807 return \"addil LT'%1-$tls_gdidx$,%%r19\;ldo RT'%1-$tls_gdidx$(%%r1),%0\";
9808 }"
9809 [(set_attr "type" "multi")
9810 (set_attr "length" "8")])
9811
9812 (define_insn "tld_load"
9813 [(set (match_operand:SI 0 "register_operand" "=r")
9814 (unspec:SI [(match_operand 1 "tld_symbolic_operand" "")] UNSPEC_TLSLDM))
9815 (clobber (reg:SI 1))
9816 (use (reg:SI 27))]
9817 ""
9818 "*
9819 {
9820 return \"addil LR'%1-$tls_ldidx$,%%r27\;ldo RR'%1-$tls_ldidx$(%%r1),%0\";
9821 }"
9822 [(set_attr "type" "multi")
9823 (set_attr "length" "8")])
9824
9825 (define_insn "tld_load_pic"
9826 [(set (match_operand:SI 0 "register_operand" "=r")
9827 (unspec:SI [(match_operand 1 "tld_symbolic_operand" "")] UNSPEC_TLSLDM_PIC))
9828 (clobber (reg:SI 1))
9829 (use (reg:SI 19))]
9830 ""
9831 "*
9832 {
9833 return \"addil LT'%1-$tls_ldidx$,%%r19\;ldo RT'%1-$tls_ldidx$(%%r1),%0\";
9834 }"
9835 [(set_attr "type" "multi")
9836 (set_attr "length" "8")])
9837
9838 (define_insn "tld_offset_load"
9839 [(set (match_operand:SI 0 "register_operand" "=r")
9840 (plus:SI (unspec:SI [(match_operand 1 "tld_symbolic_operand" "")]
9841 UNSPEC_TLSLDO)
9842 (match_operand:SI 2 "register_operand" "r")))
9843 (clobber (reg:SI 1))]
9844 ""
9845 "*
9846 {
9847 return \"addil LR'%1-$tls_dtpoff$,%2\;ldo RR'%1-$tls_dtpoff$(%%r1),%0\";
9848 }"
9849 [(set_attr "type" "multi")
9850 (set_attr "length" "8")])
9851
9852 (define_insn "tp_load"
9853 [(set (match_operand:SI 0 "register_operand" "=r")
9854 (unspec:SI [(const_int 0)] UNSPEC_TP))]
9855 ""
9856 "mfctl %%cr27,%0"
9857 [(set_attr "type" "multi")
9858 (set_attr "length" "4")])
9859
9860 (define_insn "tie_load"
9861 [(set (match_operand:SI 0 "register_operand" "=r")
9862 (unspec:SI [(match_operand 1 "tie_symbolic_operand" "")] UNSPEC_TLSIE))
9863 (clobber (reg:SI 1))
9864 (use (reg:SI 27))]
9865 ""
9866 "*
9867 {
9868 return \"addil LR'%1-$tls_ieoff$,%%r27\;ldw RR'%1-$tls_ieoff$(%%r1),%0\";
9869 }"
9870 [(set_attr "type" "multi")
9871 (set_attr "length" "8")])
9872
9873 (define_insn "tie_load_pic"
9874 [(set (match_operand:SI 0 "register_operand" "=r")
9875 (unspec:SI [(match_operand 1 "tie_symbolic_operand" "")] UNSPEC_TLSIE_PIC))
9876 (clobber (reg:SI 1))
9877 (use (reg:SI 19))]
9878 ""
9879 "*
9880 {
9881 return \"addil LT'%1-$tls_ieoff$,%%r19\;ldw RT'%1-$tls_ieoff$(%%r1),%0\";
9882 }"
9883 [(set_attr "type" "multi")
9884 (set_attr "length" "8")])
9885
9886 (define_insn "tle_load"
9887 [(set (match_operand:SI 0 "register_operand" "=r")
9888 (plus:SI (unspec:SI [(match_operand 1 "tle_symbolic_operand" "")]
9889 UNSPEC_TLSLE)
9890 (match_operand:SI 2 "register_operand" "r")))
9891 (clobber (reg:SI 1))]
9892 ""
9893 "addil LR'%1-$tls_leoff$,%2\;ldo RR'%1-$tls_leoff$(%%r1),%0"
9894 [(set_attr "type" "multi")
9895 (set_attr "length" "8")])
9896
9897 ;; Atomic instructions
9898
9899 ;; All memory loads and stores access storage atomically except
9900 ;; for one exception. The STORE BYTES, STORE DOUBLE BYTES, and
9901 ;; doubleword loads and stores are not guaranteed to be atomic
9902 ;; when referencing the I/O address space.
9903
9904 ;; The kernel cmpxchg operation on linux is not atomic with respect to
9905 ;; memory stores on SMP machines, so we must do stores using a cmpxchg
9906 ;; operation.
9907
9908 ;; These patterns are at the bottom so the non atomic versions are preferred.
9909
9910 ;; Implement atomic QImode store using exchange.
9911
9912 (define_expand "atomic_storeqi"
9913 [(match_operand:QI 0 "memory_operand") ;; memory
9914 (match_operand:QI 1 "register_operand") ;; val out
9915 (match_operand:SI 2 "const_int_operand")] ;; model
9916 ""
9917 {
9918 if (TARGET_SYNC_LIBCALL)
9919 {
9920 rtx mem = operands[0];
9921 rtx val = operands[1];
9922 if (pa_maybe_emit_compare_and_swap_exchange_loop (NULL_RTX, mem, val))
9923 DONE;
9924 }
9925 FAIL;
9926 })
9927
9928 ;; Implement atomic HImode stores using exchange.
9929
9930 (define_expand "atomic_storehi"
9931 [(match_operand:HI 0 "memory_operand") ;; memory
9932 (match_operand:HI 1 "register_operand") ;; val out
9933 (match_operand:SI 2 "const_int_operand")] ;; model
9934 ""
9935 {
9936 if (TARGET_SYNC_LIBCALL)
9937 {
9938 rtx mem = operands[0];
9939 rtx val = operands[1];
9940 if (pa_maybe_emit_compare_and_swap_exchange_loop (NULL_RTX, mem, val))
9941 DONE;
9942 }
9943 FAIL;
9944 })
9945
9946 ;; Implement atomic SImode store using exchange.
9947
9948 (define_expand "atomic_storesi"
9949 [(match_operand:SI 0 "memory_operand") ;; memory
9950 (match_operand:SI 1 "register_operand") ;; val out
9951 (match_operand:SI 2 "const_int_operand")] ;; model
9952 ""
9953 {
9954 if (TARGET_SYNC_LIBCALL)
9955 {
9956 rtx mem = operands[0];
9957 rtx val = operands[1];
9958 if (pa_maybe_emit_compare_and_swap_exchange_loop (NULL_RTX, mem, val))
9959 DONE;
9960 }
9961 FAIL;
9962 })
9963
9964 ;; Implement atomic SFmode store using exchange.
9965
9966 (define_expand "atomic_storesf"
9967 [(match_operand:SF 0 "memory_operand") ;; memory
9968 (match_operand:SF 1 "register_operand") ;; val out
9969 (match_operand:SI 2 "const_int_operand")] ;; model
9970 ""
9971 {
9972 if (TARGET_SYNC_LIBCALL)
9973 {
9974 rtx mem = operands[0];
9975 rtx val = operands[1];
9976 if (pa_maybe_emit_compare_and_swap_exchange_loop (NULL_RTX, mem, val))
9977 DONE;
9978 }
9979 FAIL;
9980 })
9981
9982 ;; Implement atomic DImode load using 64-bit floating point load.
9983
9984 (define_expand "atomic_loaddi"
9985 [(match_operand:DI 0 "register_operand") ;; val out
9986 (match_operand:DI 1 "memory_operand") ;; memory
9987 (match_operand:SI 2 "const_int_operand")] ;; model
9988 ""
9989 {
9990 enum memmodel model;
9991
9992 if (TARGET_64BIT || TARGET_DISABLE_FPREGS || TARGET_SOFT_FLOAT)
9993 FAIL;
9994
9995 model = memmodel_from_int (INTVAL (operands[2]));
9996 operands[1] = force_reg (SImode, XEXP (operands[1], 0));
9997 expand_mem_thread_fence (model);
9998 emit_insn (gen_atomic_loaddi_1 (operands[0], operands[1]));
9999 if (is_mm_seq_cst (model))
10000 expand_mem_thread_fence (model);
10001 DONE;
10002 })
10003
10004 (define_insn "atomic_loaddi_1"
10005 [(set (match_operand:DI 0 "register_operand" "=f,r")
10006 (mem:DI (match_operand:SI 1 "register_operand" "r,r")))
10007 (clobber (match_scratch:DI 2 "=X,f"))]
10008 "!TARGET_64BIT && !TARGET_DISABLE_FPREGS && !TARGET_SOFT_FLOAT"
10009 "@
10010 {fldds|fldd} 0(%1),%0
10011 {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"
10012 [(set_attr "type" "move,move")
10013 (set_attr "length" "4,16")])
10014
10015 ;; Implement atomic DImode store.
10016
10017 (define_expand "atomic_storedi"
10018 [(match_operand:DI 0 "memory_operand") ;; memory
10019 (match_operand:DI 1 "register_operand") ;; val out
10020 (match_operand:SI 2 "const_int_operand")] ;; model
10021 ""
10022 {
10023 enum memmodel model;
10024
10025 if (TARGET_SYNC_LIBCALL)
10026 {
10027 rtx mem = operands[0];
10028 rtx val = operands[1];
10029 if (pa_maybe_emit_compare_and_swap_exchange_loop (NULL_RTX, mem, val))
10030 DONE;
10031 }
10032
10033 if (TARGET_64BIT || TARGET_DISABLE_FPREGS || TARGET_SOFT_FLOAT)
10034 FAIL;
10035
10036 model = memmodel_from_int (INTVAL (operands[2]));
10037 operands[0] = force_reg (SImode, XEXP (operands[0], 0));
10038 expand_mem_thread_fence (model);
10039 emit_insn (gen_atomic_storedi_1 (operands[0], operands[1]));
10040 if (is_mm_seq_cst (model))
10041 expand_mem_thread_fence (model);
10042 DONE;
10043 })
10044
10045 (define_insn "atomic_storedi_1"
10046 [(set (mem:DI (match_operand:SI 0 "register_operand" "r,r"))
10047 (match_operand:DI 1 "register_operand" "f,r"))
10048 (clobber (match_scratch:DI 2 "=X,f"))]
10049 "!TARGET_64BIT && !TARGET_DISABLE_FPREGS
10050 && !TARGET_SOFT_FLOAT && !TARGET_SYNC_LIBCALL"
10051 "@
10052 {fstds|fstd} %1,0(%0)
10053 {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)"
10054 [(set_attr "type" "move,move")
10055 (set_attr "length" "4,16")])
10056
10057 ;; Implement atomic DFmode load using 64-bit floating point load.
10058
10059 (define_expand "atomic_loaddf"
10060 [(match_operand:DF 0 "register_operand") ;; val out
10061 (match_operand:DF 1 "memory_operand") ;; memory
10062 (match_operand:SI 2 "const_int_operand")] ;; model
10063 ""
10064 {
10065 enum memmodel model;
10066
10067 if (TARGET_64BIT || TARGET_DISABLE_FPREGS || TARGET_SOFT_FLOAT)
10068 FAIL;
10069
10070 model = memmodel_from_int (INTVAL (operands[2]));
10071 operands[1] = force_reg (SImode, XEXP (operands[1], 0));
10072 expand_mem_thread_fence (model);
10073 emit_insn (gen_atomic_loaddf_1 (operands[0], operands[1]));
10074 if (is_mm_seq_cst (model))
10075 expand_mem_thread_fence (model);
10076 DONE;
10077 })
10078
10079 (define_insn "atomic_loaddf_1"
10080 [(set (match_operand:DF 0 "register_operand" "=f,r")
10081 (mem:DF (match_operand:SI 1 "register_operand" "r,r")))
10082 (clobber (match_scratch:DF 2 "=X,f"))]
10083 "!TARGET_64BIT && !TARGET_DISABLE_FPREGS && !TARGET_SOFT_FLOAT"
10084 "@
10085 {fldds|fldd} 0(%1),%0
10086 {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"
10087 [(set_attr "type" "move,move")
10088 (set_attr "length" "4,16")])
10089
10090 ;; Implement atomic DFmode store using 64-bit floating point store.
10091
10092 (define_expand "atomic_storedf"
10093 [(match_operand:DF 0 "memory_operand") ;; memory
10094 (match_operand:DF 1 "register_operand") ;; val out
10095 (match_operand:SI 2 "const_int_operand")] ;; model
10096 ""
10097 {
10098 enum memmodel model;
10099
10100 if (TARGET_SYNC_LIBCALL)
10101 {
10102 rtx mem = operands[0];
10103 rtx val = operands[1];
10104 if (pa_maybe_emit_compare_and_swap_exchange_loop (NULL_RTX, mem, val))
10105 DONE;
10106 }
10107
10108 if (TARGET_64BIT || TARGET_DISABLE_FPREGS || TARGET_SOFT_FLOAT)
10109 FAIL;
10110
10111 model = memmodel_from_int (INTVAL (operands[2]));
10112 operands[0] = force_reg (SImode, XEXP (operands[0], 0));
10113 expand_mem_thread_fence (model);
10114 emit_insn (gen_atomic_storedf_1 (operands[0], operands[1]));
10115 if (is_mm_seq_cst (model))
10116 expand_mem_thread_fence (model);
10117 DONE;
10118 })
10119
10120 (define_insn "atomic_storedf_1"
10121 [(set (mem:DF (match_operand:SI 0 "register_operand" "r,r"))
10122 (match_operand:DF 1 "register_operand" "f,r"))
10123 (clobber (match_scratch:DF 2 "=X,f"))]
10124 "!TARGET_64BIT && !TARGET_DISABLE_FPREGS
10125 && !TARGET_SOFT_FLOAT && !TARGET_SYNC_LIBCALL"
10126 "@
10127 {fstds|fstd} %1,0(%0)
10128 {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)"
10129 [(set_attr "type" "move,move")
10130 (set_attr "length" "4,16")])