Debian Codegraph @

gcc/config/pa/pa.md

raw
1 ;;- Machine description for HP PA-RISC architecture for GCC compiler
2 ;; Copyright (C) 1992-2025 Free Software Foundation, Inc.
3 ;; Contributed by the Center for Software Science at the University
4 ;; of Utah.
5
6 ;; This file is part of GCC.
7
8 ;; GCC is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 3, or (at your option)
11 ;; any later version.
12
13 ;; GCC is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
17
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GCC; see the file COPYING3. If not see
20 ;; <http://www.gnu.org/licenses/>.
21
22 ;; This machine description is inspired by sparc.md and to a lesser
23 ;; extent mips.md.
24
25 ;; Possible improvements:
26 ;;
27 ;; * With PA1.1, most computational instructions can conditionally nullify
28 ;; the execution of the following instruction. A nullified instruction
29 ;; does not cause the instruction pipeline to stall, making it a very
30 ;; efficient alternative to e.g. branching or conditional moves.
31 ;;
32 ;; Nullification is performed conditionally based on the outcome of a
33 ;; test specified in the opcode. The test result is stored in PSW[N]
34 ;; and can only be used to nullify the instruction following immediately
35 ;; after the test. For example:
36 ;;
37 ;; ldi 10,%r26
38 ;; ldi 5,%r25
39 ;; sub,< %r26,%r25,%r28
40 ;; sub %r28,%r25,%r28 ; %r28 == 0
41 ;; sub,> %r26,%r25,%r29
42 ;; sub %r29,%r25,%r29 ; %r29 == 5
43 ;;
44 ;; This could be tricky to implement because the result of the test has
45 ;; to be propagated one instruction forward, which, in the worst case,
46 ;; would involve (1) adding a fake register for PSW[N]; (2) adding the
47 ;; variants of the computational instructions that set or consume this
48 ;; fake register. The cond_exec infrastructure is probably not helpful
49 ;; for this.
50 ;;
51 ;; * PA-RISC includes a set of conventions for branch instruction usage
52 ;; to indicate whether a particular branch is more likely to be taken
53 ;; or not taken. For example, the prediction for CMPB instructions
54 ;; (CMPB,cond,n r1,r2,target) depends on the direction of the branch
55 ;; (forward or backward) and on the order of the operands:
56 ;;
57 ;; | branch | operand | branch |
58 ;; | direction | compare | prediction |
59 ;; +-----------+----------+------------+
60 ;; | backward | r1 < r2 | taken |
61 ;; | backward | r1 >= r2 | not taken |
62 ;; | forward | r1 < r2 | not taken |
63 ;; | forward | r1 >= r2 | taken |
64 ;;
65 ;; By choosing instructions and operand order carefully, the compiler
66 ;; could give the CPU branch predictor some help.
67 ;;
68
69 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
70
71 ;; Uses of UNSPEC in this file:
72
73 (define_c_enum "unspec"
74 [UNSPEC_CFFC ; canonicalize_funcptr_for_compare
75 UNSPEC_GOTO ; indirect_goto
76 UNSPEC_DLTIND14R
77 UNSPEC_TP
78 UNSPEC_TLSGD
79 UNSPEC_TLSLDM
80 UNSPEC_TLSLDO
81 UNSPEC_TLSLDBASE
82 UNSPEC_TLSIE
83 UNSPEC_TLSLE
84 UNSPEC_TLSGD_PIC
85 UNSPEC_TLSLDM_PIC
86 UNSPEC_TLSIE_PIC
87 UNSPEC_MEMORY_BARRIER
88 ])
89
90 ;; UNSPEC_VOLATILE:
91
92 (define_c_enum "unspecv"
93 [UNSPECV_BLOCKAGE ; blockage
94 UNSPECV_DCACHE ; dcacheflush
95 UNSPECV_ICACHE ; icacheflush
96 UNSPECV_OPC ; outline_prologue_call
97 UNSPECV_OEC ; outline_epilogue_call
98 UNSPECV_LONGJMP ; builtin_longjmp
99 UNSPECV_GET_FPSR ; get floating-point status register
100 UNSPECV_SET_FPSR ; set floating-point status register
101 ])
102
103 ;; Maximum pc-relative branch offsets.
104
105 ;; These numbers are a bit smaller than the maximum allowable offsets
106 ;; so that a few instructions may be inserted before the actual branch.
107
108 (define_constants
109 [(MAX_12BIT_OFFSET 8184) ; 12-bit branch
110 (MAX_17BIT_OFFSET 262100) ; 17-bit branch
111 ])
112
113 ;; Register numbers
114
115 (define_constants
116 [(R1_REGNUM 1)
117 (R19_REGNUM 19)
118 (R27_REGNUM 27)
119 ])
120
121 ;; Mode and code iterators
122
123 ;; This mode iterator allows :P to be used for patterns that operate on
124 ;; pointer-sized quantities. Exactly one of the two alternatives will match.
125 (define_mode_iterator P [(SI "Pmode == SImode") (DI "Pmode == DImode")])
126
127 ;; This attribute defines the condition prefix for word and double word
128 ;; add, compare, subtract and logical instructions.
129 (define_mode_attr dwc [(SI "") (DI "*")])
130
131 ;; Insn type. Used to default other attribute values.
132
133 ;; type "unary" insns have one input operand (1) and one output operand (0)
134 ;; type "binary" insns have two input operands (1,2) and one output (0)
135
136 (define_attr "type"
137 "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"
138 (const_string "binary"))
139
140 (define_attr "pa_combine_type"
141 "fmpy,faddsub,uncond_branch,addmove,none"
142 (const_string "none"))
143
144 ;; Processor type (for scheduling, not code generation) -- this attribute
145 ;; must exactly match the processor_type enumeration in pa.h.
146 ;;
147 ;; FIXME: Add 800 scheduling for completeness?
148
149 (define_attr "cpu" "700,7100,7100LC,7200,7300,8000" (const (symbol_ref "pa_cpu_attr")))
150
151 ;; Length (in # of bytes).
152 (define_attr "length" ""
153 (cond [(eq_attr "type" "load,fpload")
154 (if_then_else (match_operand 1 "symbolic_memory_operand" "")
155 (const_int 8) (const_int 4))
156
157 (eq_attr "type" "store,fpstore")
158 (if_then_else (match_operand 0 "symbolic_memory_operand" "")
159 (const_int 8) (const_int 4))
160
161 (eq_attr "type" "binary,shift,nullshift")
162 (if_then_else (match_operand 2 "arith14_operand" "")
163 (const_int 4) (const_int 12))
164
165 (eq_attr "type" "move,unary,shift,nullshift")
166 (if_then_else (match_operand 1 "arith14_operand" "")
167 (const_int 4) (const_int 8))]
168
169 (const_int 4)))
170
171 (define_asm_attributes
172 [(set_attr "length" "4")
173 (set_attr "type" "multi")])
174
175 ;; Attributes for instruction and branch scheduling
176
177 ;; For conditional branches. Frame related instructions are not allowed
178 ;; because they confuse the unwind support.
179 (define_attr "in_branch_delay" "false,true"
180 (if_then_else (and (eq_attr "type" "!uncond_branch,branch,cbranch,fbranch,call,sibcall,dyncall,multi,milli,sh_func_adrs,parallel_branch,trap")
181 (eq_attr "length" "4")
182 (not (match_test "RTX_FRAME_RELATED_P (insn)")))
183 (const_string "true")
184 (const_string "false")))
185
186 ;; Disallow instructions which use the FPU since they will tie up the FPU
187 ;; even if the instruction is nullified.
188 (define_attr "in_nullified_branch_delay" "false,true"
189 (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")
190 (eq_attr "length" "4")
191 (not (match_test "RTX_FRAME_RELATED_P (insn)")))
192 (const_string "true")
193 (const_string "false")))
194
195 ;; For calls and millicode calls.
196 (define_attr "in_call_delay" "false,true"
197 (if_then_else (and (eq_attr "type" "!uncond_branch,branch,cbranch,fbranch,call,sibcall,dyncall,multi,milli,sh_func_adrs,parallel_branch,trap")
198 (eq_attr "length" "4")
199 (not (match_test "RTX_FRAME_RELATED_P (insn)")))
200 (const_string "true")
201 (const_string "false")))
202
203 ;; Call delay slot description.
204 (define_delay (eq_attr "type" "call")
205 [(eq_attr "in_call_delay" "true") (nil) (nil)])
206
207 ;; Sibcall delay slot description.
208 (define_delay (eq_attr "type" "sibcall")
209 [(eq_attr "in_call_delay" "true") (nil) (nil)])
210
211 ;; Millicode call delay slot description.
212 (define_delay (eq_attr "type" "milli")
213 [(eq_attr "in_call_delay" "true") (nil) (nil)])
214
215 ;; Return and other similar instructions.
216 (define_delay (eq_attr "type" "branch,parallel_branch")
217 [(eq_attr "in_branch_delay" "true") (nil) (nil)])
218
219 ;; Floating point conditional branch delay slot description.
220 (define_delay (eq_attr "type" "fbranch")
221 [(eq_attr "in_branch_delay" "true")
222 (eq_attr "in_nullified_branch_delay" "true")
223 (nil)])
224
225 ;; Integer conditional branch delay slot description.
226 ;; Nullification of conditional branches on the PA is dependent on the
227 ;; direction of the branch. Forward branches nullify true and
228 ;; backward branches nullify false. If the direction is unknown
229 ;; then nullification is not allowed.
230 (define_delay (eq_attr "type" "cbranch")
231 [(eq_attr "in_branch_delay" "true")
232 (and (eq_attr "in_nullified_branch_delay" "true")
233 (attr_flag "forward"))
234 (and (eq_attr "in_nullified_branch_delay" "true")
235 (attr_flag "backward"))])
236
237 (define_delay (eq_attr "type" "uncond_branch")
238 [(eq_attr "in_branch_delay" "true") (nil) (nil)])
239
240 ;; Memory. Disregarding Cache misses, the Mustang memory times are:
241 ;; load: 2, fpload: 3
242 ;; store, fpstore: 3, no D-cache operations should be scheduled.
243
244 ;; The Timex (aka 700) has two floating-point units: ALU, and MUL/DIV/SQRT.
245 ;; Timings:
246 ;; Instruction Time Unit Minimum Distance (unit contention)
247 ;; fcpy 3 ALU 2
248 ;; fabs 3 ALU 2
249 ;; fadd 3 ALU 2
250 ;; fsub 3 ALU 2
251 ;; fcmp 3 ALU 2
252 ;; fcnv 3 ALU 2
253 ;; fmpyadd 3 ALU,MPY 2
254 ;; fmpysub 3 ALU,MPY 2
255 ;; fmpycfxt 3 ALU,MPY 2
256 ;; fmpy 3 MPY 2
257 ;; fmpyi 3 MPY 2
258 ;; fdiv,sgl 10 MPY 10
259 ;; fdiv,dbl 12 MPY 12
260 ;; fsqrt,sgl 14 MPY 14
261 ;; fsqrt,dbl 18 MPY 18
262 ;;
263 ;; We don't model fmpyadd/fmpysub properly as those instructions
264 ;; keep both the FP ALU and MPY units busy. Given that these
265 ;; processors are obsolete, I'm not going to spend the time to
266 ;; model those instructions correctly.
267
268 (define_automaton "pa700")
269 (define_cpu_unit "dummy_700,mem_700,fpalu_700,fpmpy_700" "pa700")
270
271 (define_insn_reservation "W0" 4
272 (and (eq_attr "type" "fpcc")
273 (eq_attr "cpu" "700"))
274 "fpalu_700*2")
275
276 (define_insn_reservation "W1" 3
277 (and (eq_attr "type" "fpalu")
278 (eq_attr "cpu" "700"))
279 "fpalu_700*2")
280
281 (define_insn_reservation "W2" 3
282 (and (eq_attr "type" "fpmulsgl,fpmuldbl")
283 (eq_attr "cpu" "700"))
284 "fpmpy_700*2")
285
286 (define_insn_reservation "W3" 10
287 (and (eq_attr "type" "fpdivsgl")
288 (eq_attr "cpu" "700"))
289 "fpmpy_700*10")
290
291 (define_insn_reservation "W4" 12
292 (and (eq_attr "type" "fpdivdbl")
293 (eq_attr "cpu" "700"))
294 "fpmpy_700*12")
295
296 (define_insn_reservation "W5" 14
297 (and (eq_attr "type" "fpsqrtsgl")
298 (eq_attr "cpu" "700"))
299 "fpmpy_700*14")
300
301 (define_insn_reservation "W6" 18
302 (and (eq_attr "type" "fpsqrtdbl")
303 (eq_attr "cpu" "700"))
304 "fpmpy_700*18")
305
306 (define_insn_reservation "W7" 2
307 (and (eq_attr "type" "load")
308 (eq_attr "cpu" "700"))
309 "mem_700")
310
311 (define_insn_reservation "W8" 2
312 (and (eq_attr "type" "fpload")
313 (eq_attr "cpu" "700"))
314 "mem_700")
315
316 (define_insn_reservation "W9" 3
317 (and (eq_attr "type" "store")
318 (eq_attr "cpu" "700"))
319 "mem_700*3")
320
321 (define_insn_reservation "W10" 3
322 (and (eq_attr "type" "fpstore")
323 (eq_attr "cpu" "700"))
324 "mem_700*3")
325
326 (define_insn_reservation "W11" 5
327 (and (eq_attr "type" "fpstore_load")
328 (eq_attr "cpu" "700"))
329 "mem_700*5")
330
331 (define_insn_reservation "W12" 6
332 (and (eq_attr "type" "store_fpload")
333 (eq_attr "cpu" "700"))
334 "mem_700*6")
335
336 (define_insn_reservation "W13" 1
337 (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpdivdbl,fpsqrtsgl,fpsqrtdbl,load,fpload,store,fpstore,fpstore_load,store_fpload")
338 (eq_attr "cpu" "700"))
339 "dummy_700")
340
341 ;; We have a bypass for all computations in the FP unit which feed an
342 ;; FP store as long as the sizes are the same.
343 (define_bypass 2 "W1,W2" "W10,W11" "pa_fpstore_bypass_p")
344 (define_bypass 9 "W3" "W10,W11" "pa_fpstore_bypass_p")
345 (define_bypass 11 "W4" "W10,W11" "pa_fpstore_bypass_p")
346 (define_bypass 13 "W5" "W10,W11" "pa_fpstore_bypass_p")
347 (define_bypass 17 "W6" "W10,W11" "pa_fpstore_bypass_p")
348
349 ;; We have an "anti-bypass" for FP loads which feed an FP store.
350 (define_bypass 4 "W8,W12" "W10,W11" "pa_fpstore_bypass_p")
351
352 ;; Function units for the 7100 and 7150. The 7100/7150 can dual-issue
353 ;; floating point computations with non-floating point computations (fp loads
354 ;; and stores are not fp computations).
355 ;;
356 ;; Memory. Disregarding Cache misses, memory loads take two cycles; stores also
357 ;; take two cycles, during which no Dcache operations should be scheduled.
358 ;; Any special cases are handled in pa_adjust_cost. The 7100, 7150 and 7100LC
359 ;; all have the same memory characteristics if one disregards cache misses.
360 ;;
361 ;; The 7100/7150 has three floating-point units: ALU, MUL, and DIV.
362 ;; There's no value in modeling the ALU and MUL separately though
363 ;; since there can never be a functional unit conflict given the
364 ;; latency and issue rates for those units.
365 ;;
366 ;; Timings:
367 ;; Instruction Time Unit Minimum Distance (unit contention)
368 ;; fcpy 2 ALU 1
369 ;; fabs 2 ALU 1
370 ;; fadd 2 ALU 1
371 ;; fsub 2 ALU 1
372 ;; fcmp 2 ALU 1
373 ;; fcnv 2 ALU 1
374 ;; fmpyadd 2 ALU,MPY 1
375 ;; fmpysub 2 ALU,MPY 1
376 ;; fmpycfxt 2 ALU,MPY 1
377 ;; fmpy 2 MPY 1
378 ;; fmpyi 2 MPY 1
379 ;; fdiv,sgl 8 DIV 8
380 ;; fdiv,dbl 15 DIV 15
381 ;; fsqrt,sgl 8 DIV 8
382 ;; fsqrt,dbl 15 DIV 15
383
384 (define_automaton "pa7100")
385 (define_cpu_unit "i_7100, f_7100,fpmac_7100,fpdivsqrt_7100,mem_7100" "pa7100")
386
387 (define_insn_reservation "X0" 2
388 (and (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
389 (eq_attr "cpu" "7100"))
390 "f_7100,fpmac_7100")
391
392 (define_insn_reservation "X1" 8
393 (and (eq_attr "type" "fpdivsgl,fpsqrtsgl")
394 (eq_attr "cpu" "7100"))
395 "f_7100+fpdivsqrt_7100,fpdivsqrt_7100*7")
396
397 (define_insn_reservation "X2" 15
398 (and (eq_attr "type" "fpdivdbl,fpsqrtdbl")
399 (eq_attr "cpu" "7100"))
400 "f_7100+fpdivsqrt_7100,fpdivsqrt_7100*14")
401
402 (define_insn_reservation "X3" 2
403 (and (eq_attr "type" "load")
404 (eq_attr "cpu" "7100"))
405 "i_7100+mem_7100")
406
407 (define_insn_reservation "X4" 2
408 (and (eq_attr "type" "fpload")
409 (eq_attr "cpu" "7100"))
410 "i_7100+mem_7100")
411
412 (define_insn_reservation "X5" 2
413 (and (eq_attr "type" "store")
414 (eq_attr "cpu" "7100"))
415 "i_7100+mem_7100,mem_7100")
416
417 (define_insn_reservation "X6" 2
418 (and (eq_attr "type" "fpstore")
419 (eq_attr "cpu" "7100"))
420 "i_7100+mem_7100,mem_7100")
421
422 (define_insn_reservation "X7" 4
423 (and (eq_attr "type" "fpstore_load")
424 (eq_attr "cpu" "7100"))
425 "i_7100+mem_7100,mem_7100*3")
426
427 (define_insn_reservation "X8" 4
428 (and (eq_attr "type" "store_fpload")
429 (eq_attr "cpu" "7100"))
430 "i_7100+mem_7100,mem_7100*3")
431
432 (define_insn_reservation "X9" 1
433 (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl,load,fpload,store,fpstore,fpstore_load,store_fpload")
434 (eq_attr "cpu" "7100"))
435 "i_7100")
436
437 ;; We have a bypass for all computations in the FP unit which feed an
438 ;; FP store as long as the sizes are the same.
439 (define_bypass 1 "X0" "X6,X7" "pa_fpstore_bypass_p")
440 (define_bypass 7 "X1" "X6,X7" "pa_fpstore_bypass_p")
441 (define_bypass 14 "X2" "X6,X7" "pa_fpstore_bypass_p")
442
443 ;; We have an "anti-bypass" for FP loads which feed an FP store.
444 (define_bypass 3 "X4,X8" "X6,X7" "pa_fpstore_bypass_p")
445
446 ;; The 7100LC has three floating-point units: ALU, MUL, and DIV.
447 ;; There's no value in modeling the ALU and MUL separately though
448 ;; since there can never be a functional unit conflict that
449 ;; can be avoided given the latency, issue rates and mandatory
450 ;; one cycle cpu-wide lock for a double precision fp multiply.
451 ;;
452 ;; Timings:
453 ;; Instruction Time Unit Minimum Distance (unit contention)
454 ;; fcpy 2 ALU 1
455 ;; fabs 2 ALU 1
456 ;; fadd 2 ALU 1
457 ;; fsub 2 ALU 1
458 ;; fcmp 2 ALU 1
459 ;; fcnv 2 ALU 1
460 ;; fmpyadd,sgl 2 ALU,MPY 1
461 ;; fmpyadd,dbl 3 ALU,MPY 2
462 ;; fmpysub,sgl 2 ALU,MPY 1
463 ;; fmpysub,dbl 3 ALU,MPY 2
464 ;; fmpycfxt,sgl 2 ALU,MPY 1
465 ;; fmpycfxt,dbl 3 ALU,MPY 2
466 ;; fmpy,sgl 2 MPY 1
467 ;; fmpy,dbl 3 MPY 2
468 ;; fmpyi 3 MPY 2
469 ;; fdiv,sgl 8 DIV 8
470 ;; fdiv,dbl 15 DIV 15
471 ;; fsqrt,sgl 8 DIV 8
472 ;; fsqrt,dbl 15 DIV 15
473 ;;
474 ;; The PA7200 is just like the PA7100LC except that there is
475 ;; no store-store penalty.
476 ;;
477 ;; The PA7300 is just like the PA7200 except that there is
478 ;; no store-load penalty.
479 ;;
480 ;; Note there are some aspects of the 7100LC we are not modeling
481 ;; at the moment. I'll be reviewing the 7100LC scheduling info
482 ;; shortly and updating this description.
483 ;;
484 ;; load-load pairs
485 ;; store-store pairs
486 ;; other issue modeling
487
488 (define_automaton "pa7100lc")
489 (define_cpu_unit "i0_7100lc, i1_7100lc, f_7100lc" "pa7100lc")
490 (define_cpu_unit "fpmac_7100lc" "pa7100lc")
491 (define_cpu_unit "mem_7100lc" "pa7100lc")
492
493 ;; Double precision multiplies lock the entire CPU for one
494 ;; cycle. There is no way to avoid this lock and trying to
495 ;; schedule around the lock is pointless and thus there is no
496 ;; value in trying to model this lock.
497 ;;
498 ;; Not modeling the lock allows us to treat fp multiplies just
499 ;; like any other FP alu instruction. It allows for a smaller
500 ;; DFA and may reduce register pressure.
501 (define_insn_reservation "Y0" 2
502 (and (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
503 (eq_attr "cpu" "7100LC,7200,7300"))
504 "f_7100lc,fpmac_7100lc")
505
506 ;; fp division and sqrt instructions lock the entire CPU for
507 ;; 7 cycles (single precision) or 14 cycles (double precision).
508 ;; There is no way to avoid this lock and trying to schedule
509 ;; around the lock is pointless and thus there is no value in
510 ;; trying to model this lock. Not modeling the lock allows
511 ;; for a smaller DFA and may reduce register pressure.
512 (define_insn_reservation "Y1" 1
513 (and (eq_attr "type" "fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl")
514 (eq_attr "cpu" "7100LC,7200,7300"))
515 "f_7100lc")
516
517 (define_insn_reservation "Y2" 2
518 (and (eq_attr "type" "load")
519 (eq_attr "cpu" "7100LC,7200,7300"))
520 "i1_7100lc+mem_7100lc")
521
522 (define_insn_reservation "Y3" 2
523 (and (eq_attr "type" "fpload")
524 (eq_attr "cpu" "7100LC,7200,7300"))
525 "i1_7100lc+mem_7100lc")
526
527 (define_insn_reservation "Y4" 2
528 (and (eq_attr "type" "store")
529 (eq_attr "cpu" "7100LC"))
530 "i1_7100lc+mem_7100lc,mem_7100lc")
531
532 (define_insn_reservation "Y5" 2
533 (and (eq_attr "type" "fpstore")
534 (eq_attr "cpu" "7100LC"))
535 "i1_7100lc+mem_7100lc,mem_7100lc")
536
537 (define_insn_reservation "Y6" 4
538 (and (eq_attr "type" "fpstore_load")
539 (eq_attr "cpu" "7100LC"))
540 "i1_7100lc+mem_7100lc,mem_7100lc*3")
541
542 (define_insn_reservation "Y7" 4
543 (and (eq_attr "type" "store_fpload")
544 (eq_attr "cpu" "7100LC"))
545 "i1_7100lc+mem_7100lc,mem_7100lc*3")
546
547 (define_insn_reservation "Y8" 1
548 (and (eq_attr "type" "shift,nullshift")
549 (eq_attr "cpu" "7100LC,7200,7300"))
550 "i1_7100lc")
551
552 (define_insn_reservation "Y9" 1
553 (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl,load,fpload,store,fpstore,shift,nullshift")
554 (eq_attr "cpu" "7100LC,7200,7300"))
555 "(i0_7100lc|i1_7100lc)")
556
557 ;; The 7200 has a store-load penalty
558 (define_insn_reservation "Y10" 2
559 (and (eq_attr "type" "store")
560 (eq_attr "cpu" "7200"))
561 "i1_7100lc,mem_7100lc")
562
563 (define_insn_reservation "Y11" 2
564 (and (eq_attr "type" "fpstore")
565 (eq_attr "cpu" "7200"))
566 "i1_7100lc,mem_7100lc")
567
568 (define_insn_reservation "Y12" 4
569 (and (eq_attr "type" "fpstore_load")
570 (eq_attr "cpu" "7200"))
571 "i1_7100lc,mem_7100lc,i1_7100lc+mem_7100lc")
572
573 (define_insn_reservation "Y13" 4
574 (and (eq_attr "type" "store_fpload")
575 (eq_attr "cpu" "7200"))
576 "i1_7100lc,mem_7100lc,i1_7100lc+mem_7100lc")
577
578 ;; The 7300 has no penalty for store-store or store-load
579 (define_insn_reservation "Y14" 2
580 (and (eq_attr "type" "store")
581 (eq_attr "cpu" "7300"))
582 "i1_7100lc")
583
584 (define_insn_reservation "Y15" 2
585 (and (eq_attr "type" "fpstore")
586 (eq_attr "cpu" "7300"))
587 "i1_7100lc")
588
589 (define_insn_reservation "Y16" 4
590 (and (eq_attr "type" "fpstore_load")
591 (eq_attr "cpu" "7300"))
592 "i1_7100lc,i1_7100lc+mem_7100lc")
593
594 (define_insn_reservation "Y17" 4
595 (and (eq_attr "type" "store_fpload")
596 (eq_attr "cpu" "7300"))
597 "i1_7100lc,i1_7100lc+mem_7100lc")
598
599 ;; We have an "anti-bypass" for FP loads which feed an FP store.
600 (define_bypass 3 "Y3,Y7,Y13,Y17" "Y5,Y6,Y11,Y12,Y15,Y16" "pa_fpstore_bypass_p")
601
602 ;; Scheduling for the PA8000 is somewhat different than scheduling for a
603 ;; traditional architecture.
604 ;;
605 ;; The PA8000 has a large (56) entry reorder buffer that is split between
606 ;; memory and non-memory operations.
607 ;;
608 ;; The PA8000 can issue two memory and two non-memory operations per cycle to
609 ;; the function units, with the exception of branches and multi-output
610 ;; instructions. The PA8000 can retire two non-memory operations per cycle
611 ;; and two memory operations per cycle, only one of which may be a store.
612 ;;
613 ;; Given the large reorder buffer, the processor can hide most latencies.
614 ;; According to HP, they've got the best results by scheduling for retirement
615 ;; bandwidth with limited latency scheduling for floating point operations.
616 ;; Latency for integer operations and memory references is ignored.
617 ;;
618 ;;
619 ;; We claim floating point operations have a 2 cycle latency and are
620 ;; fully pipelined, except for div and sqrt which are not pipelined and
621 ;; take from 17 to 31 cycles to complete.
622 ;;
623 ;; It's worth noting that there is no way to saturate all the functional
624 ;; units on the PA8000 as there is not enough issue bandwidth.
625
626 (define_automaton "pa8000")
627 (define_cpu_unit "inm0_8000, inm1_8000, im0_8000, im1_8000" "pa8000")
628 (define_cpu_unit "rnm0_8000, rnm1_8000, rm0_8000, rm1_8000" "pa8000")
629 (define_cpu_unit "store_8000" "pa8000")
630 (define_cpu_unit "f0_8000, f1_8000" "pa8000")
631 (define_cpu_unit "fdivsqrt0_8000, fdivsqrt1_8000" "pa8000")
632 (define_reservation "inm_8000" "inm0_8000 | inm1_8000")
633 (define_reservation "im_8000" "im0_8000 | im1_8000")
634 (define_reservation "rnm_8000" "rnm0_8000 | rnm1_8000")
635 (define_reservation "rm_8000" "rm0_8000 | rm1_8000")
636 (define_reservation "f_8000" "f0_8000 | f1_8000")
637 (define_reservation "fdivsqrt_8000" "fdivsqrt0_8000 | fdivsqrt1_8000")
638
639 ;; We can issue any two memops per cycle, but we can only retire
640 ;; one memory store per cycle. We assume that the reorder buffer
641 ;; will hide any memory latencies per HP's recommendation.
642 (define_insn_reservation "Z0" 0
643 (and
644 (eq_attr "type" "load,fpload")
645 (eq_attr "cpu" "8000"))
646 "im_8000,rm_8000")
647
648 (define_insn_reservation "Z1" 0
649 (and
650 (eq_attr "type" "store,fpstore")
651 (eq_attr "cpu" "8000"))
652 "im_8000,rm_8000+store_8000")
653
654 (define_insn_reservation "Z2" 0
655 (and (eq_attr "type" "fpstore_load,store_fpload")
656 (eq_attr "cpu" "8000"))
657 "im_8000,rm_8000+store_8000,im_8000,rm_8000")
658
659 ;; We can issue and retire two non-memory operations per cycle with
660 ;; a few exceptions (branches). This group catches those we want
661 ;; to assume have zero latency.
662 (define_insn_reservation "Z3" 0
663 (and
664 (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")
665 (eq_attr "cpu" "8000"))
666 "inm_8000,rnm_8000")
667
668 ;; Branches use both slots in the non-memory issue and
669 ;; retirement unit.
670 (define_insn_reservation "Z4" 0
671 (and
672 (eq_attr "type" "uncond_branch,branch,cbranch,fbranch,call,sibcall,dyncall,multi,milli,sh_func_adrs,parallel_branch")
673 (eq_attr "cpu" "8000"))
674 "inm0_8000+inm1_8000,rnm0_8000+rnm1_8000")
675
676 ;; We partial latency schedule the floating point units.
677 ;; They can issue/retire two at a time in the non-memory
678 ;; units. We fix their latency at 2 cycles and they
679 ;; are fully pipelined.
680 (define_insn_reservation "Z5" 1
681 (and
682 (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
683 (eq_attr "cpu" "8000"))
684 "inm_8000,f_8000,rnm_8000")
685
686 ;; The fdivsqrt units are not pipelined and have a very long latency.
687 ;; To keep the DFA from exploding, we do not show all the
688 ;; reservations for the divsqrt unit.
689 (define_insn_reservation "Z6" 17
690 (and
691 (eq_attr "type" "fpdivsgl,fpsqrtsgl")
692 (eq_attr "cpu" "8000"))
693 "inm_8000,fdivsqrt_8000*6,rnm_8000")
694
695 (define_insn_reservation "Z7" 31
696 (and
697 (eq_attr "type" "fpdivdbl,fpsqrtdbl")
698 (eq_attr "cpu" "8000"))
699 "inm_8000,fdivsqrt_8000*6,rnm_8000")
700
701 ;; Operand and operator predicates and constraints
702
703 (include "predicates.md")
704 (include "constraints.md")
705
706 ;; Compare instructions.
707 ;; This controls RTL generation and register allocation.
708
709 (define_insn ""
710 [(set (reg:CCFP 0)
711 (match_operator:CCFP 2 "comparison_operator"
712 [(match_operand:SF 0 "reg_or_0_operand" "fG")
713 (match_operand:SF 1 "reg_or_0_operand" "fG")]))]
714 "! TARGET_SOFT_FLOAT"
715 "fcmp,sgl,%Y2 %f0,%f1"
716 [(set_attr "length" "4")
717 (set_attr "type" "fpcc")])
718
719 (define_insn ""
720 [(set (reg:CCFP 0)
721 (match_operator:CCFP 2 "comparison_operator"
722 [(match_operand:DF 0 "reg_or_0_operand" "fG")
723 (match_operand:DF 1 "reg_or_0_operand" "fG")]))]
724 "! TARGET_SOFT_FLOAT"
725 "fcmp,dbl,%Y2 %f0,%f1"
726 [(set_attr "length" "4")
727 (set_attr "type" "fpcc")])
728
729 ;; Provide a means to emit the movccfp0 and movccfp1 optimization
730 ;; placeholders. This is necessary in rare situations when a
731 ;; placeholder is re-emitted (see PR 8705).
732
733 (define_expand "movccfp"
734 [(set (reg:CCFP 0)
735 (match_operand 0 "const_int_operand" ""))]
736 "! TARGET_SOFT_FLOAT"
737 "
738 {
739 if ((unsigned HOST_WIDE_INT) INTVAL (operands[0]) > 1)
740 FAIL;
741 }")
742
743 ;; The following patterns are optimization placeholders. In almost
744 ;; all cases, the user of the condition code will be simplified and the
745 ;; original condition code setting insn should be eliminated.
746
747 (define_insn "*movccfp0"
748 [(set (reg:CCFP 0)
749 (const_int 0))]
750 "! TARGET_SOFT_FLOAT"
751 "fcmp,dbl,= %%fr0,%%fr0"
752 [(set_attr "length" "4")
753 (set_attr "type" "fpcc")])
754
755 (define_insn "*movccfp1"
756 [(set (reg:CCFP 0)
757 (const_int 1))]
758 "! TARGET_SOFT_FLOAT"
759 "fcmp,dbl,!= %%fr0,%%fr0"
760 [(set_attr "length" "4")
761 (set_attr "type" "fpcc")])
762
763 ;; scc insns.
764
765 (define_expand "cstoresi4"
766 [(set (match_operand:SI 0 "register_operand")
767 (match_operator:SI 1 "ordered_comparison_operator"
768 [(match_operand:SI 2 "reg_or_0_operand" "")
769 (match_operand:SI 3 "arith5_operand" "")]))]
770 "!TARGET_64BIT"
771 "")
772
773 ;; Instruction canonicalization puts immediate operands second, which
774 ;; is the reverse of what we want.
775
776 (define_insn "scc"
777 [(set (match_operand:SI 0 "register_operand" "=r")
778 (match_operator:SI 3 "ordered_comparison_operator"
779 [(match_operand:SI 1 "reg_or_0_operand" "rM")
780 (match_operand:SI 2 "arith11_operand" "rI")]))]
781 ""
782 "{com%I2clr|cmp%I2clr},%B3 %2,%r1,%0\;ldi 1,%0"
783 [(set_attr "type" "binary")
784 (set_attr "length" "8")])
785
786 (define_insn ""
787 [(set (match_operand:DI 0 "register_operand" "=r")
788 (match_operator:DI 3 "ordered_comparison_operator"
789 [(match_operand:DI 1 "reg_or_0_operand" "rM")
790 (match_operand:DI 2 "arith11_operand" "rI")]))]
791 "TARGET_64BIT"
792 "cmp%I2clr,*%B3 %2,%r1,%0\;ldi 1,%0"
793 [(set_attr "type" "binary")
794 (set_attr "length" "8")])
795
796 (define_insn "iorscc"
797 [(set (match_operand:SI 0 "register_operand" "=r")
798 (ior:SI (match_operator:SI 3 "ordered_comparison_operator"
799 [(match_operand:SI 1 "reg_or_0_operand" "rM")
800 (match_operand:SI 2 "arith11_operand" "rI")])
801 (match_operator:SI 6 "ordered_comparison_operator"
802 [(match_operand:SI 4 "reg_or_0_operand" "rM")
803 (match_operand:SI 5 "arith11_operand" "rI")])))]
804 ""
805 "{com%I2clr|cmp%I2clr},%S3 %2,%r1,%%r0\;{com%I5clr|cmp%I5clr},%B6 %5,%r4,%0\;ldi 1,%0"
806 [(set_attr "type" "binary")
807 (set_attr "length" "12")])
808
809 (define_insn ""
810 [(set (match_operand:DI 0 "register_operand" "=r")
811 (ior:DI (match_operator:DI 3 "ordered_comparison_operator"
812 [(match_operand:DI 1 "reg_or_0_operand" "rM")
813 (match_operand:DI 2 "arith11_operand" "rI")])
814 (match_operator:DI 6 "ordered_comparison_operator"
815 [(match_operand:DI 4 "reg_or_0_operand" "rM")
816 (match_operand:DI 5 "arith11_operand" "rI")])))]
817 "TARGET_64BIT"
818 "cmp%I2clr,*%S3 %2,%r1,%%r0\;cmp%I5clr,*%B6 %5,%r4,%0\;ldi 1,%0"
819 [(set_attr "type" "binary")
820 (set_attr "length" "12")])
821
822 ;; Combiner patterns for common operations performed with the output
823 ;; from an scc insn (negscc and incscc).
824 (define_insn "negscc"
825 [(set (match_operand:SI 0 "register_operand" "=r")
826 (neg:SI (match_operator:SI 3 "ordered_comparison_operator"
827 [(match_operand:SI 1 "reg_or_0_operand" "rM")
828 (match_operand:SI 2 "arith11_operand" "rI")])))]
829 ""
830 "{com%I2clr|cmp%I2clr},%B3 %2,%r1,%0\;ldi -1,%0"
831 [(set_attr "type" "binary")
832 (set_attr "length" "8")])
833
834 (define_insn ""
835 [(set (match_operand:DI 0 "register_operand" "=r")
836 (neg:DI (match_operator:DI 3 "ordered_comparison_operator"
837 [(match_operand:DI 1 "reg_or_0_operand" "rM")
838 (match_operand:DI 2 "arith11_operand" "rI")])))]
839 "TARGET_64BIT"
840 "cmp%I2clr,*%B3 %2,%r1,%0\;ldi -1,%0"
841 [(set_attr "type" "binary")
842 (set_attr "length" "8")])
843
844 ;; Patterns for adding/subtracting the result of a boolean expression from
845 ;; a register. First we have special patterns that make use of the carry
846 ;; bit, and output only two instructions. For the cases we can't in
847 ;; general do in two instructions, the incscc pattern at the end outputs
848 ;; two or three instructions.
849
850 (define_insn ""
851 [(set (match_operand:SI 0 "register_operand" "=r")
852 (plus:SI (leu:SI (match_operand:SI 2 "register_operand" "r")
853 (match_operand:SI 3 "arith11_operand" "rI"))
854 (match_operand:SI 1 "register_operand" "r")))]
855 ""
856 "sub%I3 %3,%2,%%r0\;{addc|add,c} %%r0,%1,%0"
857 [(set_attr "type" "binary")
858 (set_attr "length" "8")])
859
860 (define_insn ""
861 [(set (match_operand:DI 0 "register_operand" "=r")
862 (plus:DI (leu:DI (match_operand:DI 2 "register_operand" "r")
863 (match_operand:DI 3 "arith11_operand" "rI"))
864 (match_operand:DI 1 "register_operand" "r")))]
865 "TARGET_64BIT"
866 "sub%I3 %3,%2,%%r0\;add,dc %%r0,%1,%0"
867 [(set_attr "type" "binary")
868 (set_attr "length" "8")])
869
870 ; This need only accept registers for op3, since canonicalization
871 ; replaces geu with gtu when op3 is an integer.
872 (define_insn ""
873 [(set (match_operand:SI 0 "register_operand" "=r")
874 (plus:SI (geu:SI (match_operand:SI 2 "register_operand" "r")
875 (match_operand:SI 3 "register_operand" "r"))
876 (match_operand:SI 1 "register_operand" "r")))]
877 ""
878 "sub %2,%3,%%r0\;{addc|add,c} %%r0,%1,%0"
879 [(set_attr "type" "binary")
880 (set_attr "length" "8")])
881
882 (define_insn ""
883 [(set (match_operand:DI 0 "register_operand" "=r")
884 (plus:DI (geu:DI (match_operand:DI 2 "register_operand" "r")
885 (match_operand:DI 3 "register_operand" "r"))
886 (match_operand:DI 1 "register_operand" "r")))]
887 "TARGET_64BIT"
888 "sub %2,%3,%%r0\;add,dc %%r0,%1,%0"
889 [(set_attr "type" "binary")
890 (set_attr "length" "8")])
891
892 ; Match only integers for op3 here. This is used as canonical form of the
893 ; geu pattern when op3 is an integer. Don't match registers since we can't
894 ; make better code than the general incscc pattern.
895 (define_insn ""
896 [(set (match_operand:SI 0 "register_operand" "=r")
897 (plus:SI (gtu:SI (match_operand:SI 2 "register_operand" "r")
898 (match_operand:SI 3 "int11_operand" "I"))
899 (match_operand:SI 1 "register_operand" "r")))]
900 ""
901 "addi %k3,%2,%%r0\;{addc|add,c} %%r0,%1,%0"
902 [(set_attr "type" "binary")
903 (set_attr "length" "8")])
904
905 (define_insn ""
906 [(set (match_operand:DI 0 "register_operand" "=r")
907 (plus:DI (gtu:DI (match_operand:DI 2 "register_operand" "r")
908 (match_operand:DI 3 "int11_operand" "I"))
909 (match_operand:DI 1 "register_operand" "r")))]
910 "TARGET_64BIT"
911 "addi %k3,%2,%%r0\;add,dc %%r0,%1,%0"
912 [(set_attr "type" "binary")
913 (set_attr "length" "8")])
914
915 (define_insn "incscc"
916 [(set (match_operand:SI 0 "register_operand" "=r,r")
917 (plus:SI (match_operator:SI 4 "ordered_comparison_operator"
918 [(match_operand:SI 2 "register_operand" "r,r")
919 (match_operand:SI 3 "arith11_operand" "rI,rI")])
920 (match_operand:SI 1 "register_operand" "0,?r")))]
921 ""
922 "@
923 {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi 1,%0,%0
924 {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi,tr 1,%1,%0\;copy %1,%0"
925 [(set_attr "type" "binary,binary")
926 (set_attr "length" "8,12")])
927
928 (define_insn ""
929 [(set (match_operand:DI 0 "register_operand" "=r,r")
930 (plus:DI (match_operator:DI 4 "ordered_comparison_operator"
931 [(match_operand:DI 2 "register_operand" "r,r")
932 (match_operand:DI 3 "arith11_operand" "rI,rI")])
933 (match_operand:DI 1 "register_operand" "0,?r")))]
934 "TARGET_64BIT"
935 "@
936 cmp%I3clr,*%B4 %3,%2,%%r0\;addi 1,%0,%0
937 cmp%I3clr,*%B4 %3,%2,%%r0\;addi,tr 1,%1,%0\;copy %1,%0"
938 [(set_attr "type" "binary,binary")
939 (set_attr "length" "8,12")])
940
941 (define_insn ""
942 [(set (match_operand:SI 0 "register_operand" "=r")
943 (minus:SI (match_operand:SI 1 "register_operand" "r")
944 (gtu:SI (match_operand:SI 2 "register_operand" "r")
945 (match_operand:SI 3 "arith11_operand" "rI"))))]
946 ""
947 "sub%I3 %3,%2,%%r0\;{subb|sub,b} %1,%%r0,%0"
948 [(set_attr "type" "binary")
949 (set_attr "length" "8")])
950
951 (define_insn ""
952 [(set (match_operand:DI 0 "register_operand" "=r")
953 (minus:DI (match_operand:DI 1 "register_operand" "r")
954 (gtu:DI (match_operand:DI 2 "register_operand" "r")
955 (match_operand:DI 3 "arith11_operand" "rI"))))]
956 "TARGET_64BIT"
957 "sub%I3 %3,%2,%%r0\;sub,db %1,%%r0,%0"
958 [(set_attr "type" "binary")
959 (set_attr "length" "8")])
960
961 (define_insn ""
962 [(set (match_operand:SI 0 "register_operand" "=r")
963 (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
964 (gtu:SI (match_operand:SI 2 "register_operand" "r")
965 (match_operand:SI 3 "arith11_operand" "rI")))
966 (match_operand:SI 4 "register_operand" "r")))]
967 ""
968 "sub%I3 %3,%2,%%r0\;{subb|sub,b} %1,%4,%0"
969 [(set_attr "type" "binary")
970 (set_attr "length" "8")])
971
972 (define_insn ""
973 [(set (match_operand:DI 0 "register_operand" "=r")
974 (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
975 (gtu:DI (match_operand:DI 2 "register_operand" "r")
976 (match_operand:DI 3 "arith11_operand" "rI")))
977 (match_operand:DI 4 "register_operand" "r")))]
978 "TARGET_64BIT"
979 "sub%I3 %3,%2,%%r0\;sub,db %1,%4,%0"
980 [(set_attr "type" "binary")
981 (set_attr "length" "8")])
982
983 ; This need only accept registers for op3, since canonicalization
984 ; replaces ltu with leu when op3 is an integer.
985 (define_insn ""
986 [(set (match_operand:SI 0 "register_operand" "=r")
987 (minus:SI (match_operand:SI 1 "register_operand" "r")
988 (ltu:SI (match_operand:SI 2 "register_operand" "r")
989 (match_operand:SI 3 "register_operand" "r"))))]
990 ""
991 "sub %2,%3,%%r0\;{subb|sub,b} %1,%%r0,%0"
992 [(set_attr "type" "binary")
993 (set_attr "length" "8")])
994
995 (define_insn ""
996 [(set (match_operand:DI 0 "register_operand" "=r")
997 (minus:DI (match_operand:DI 1 "register_operand" "r")
998 (ltu:DI (match_operand:DI 2 "register_operand" "r")
999 (match_operand:DI 3 "register_operand" "r"))))]
1000 "TARGET_64BIT"
1001 "sub %2,%3,%%r0\;sub,db %1,%%r0,%0"
1002 [(set_attr "type" "binary")
1003 (set_attr "length" "8")])
1004
1005 (define_insn ""
1006 [(set (match_operand:SI 0 "register_operand" "=r")
1007 (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
1008 (ltu:SI (match_operand:SI 2 "register_operand" "r")
1009 (match_operand:SI 3 "register_operand" "r")))
1010 (match_operand:SI 4 "register_operand" "r")))]
1011 ""
1012 "sub %2,%3,%%r0\;{subb|sub,b} %1,%4,%0"
1013 [(set_attr "type" "binary")
1014 (set_attr "length" "8")])
1015
1016 (define_insn ""
1017 [(set (match_operand:DI 0 "register_operand" "=r")
1018 (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
1019 (ltu:DI (match_operand:DI 2 "register_operand" "r")
1020 (match_operand:DI 3 "register_operand" "r")))
1021 (match_operand:DI 4 "register_operand" "r")))]
1022 "TARGET_64BIT"
1023 "sub %2,%3,%%r0\;sub,db %1,%4,%0"
1024 [(set_attr "type" "binary")
1025 (set_attr "length" "8")])
1026
1027 ; Match only integers for op3 here. This is used as canonical form of the
1028 ; ltu pattern when op3 is an integer. Don't match registers since we can't
1029 ; make better code than the general incscc pattern.
1030 (define_insn ""
1031 [(set (match_operand:SI 0 "register_operand" "=r")
1032 (minus:SI (match_operand:SI 1 "register_operand" "r")
1033 (leu:SI (match_operand:SI 2 "register_operand" "r")
1034 (match_operand:SI 3 "int11_operand" "I"))))]
1035 ""
1036 "addi %k3,%2,%%r0\;{subb|sub,b} %1,%%r0,%0"
1037 [(set_attr "type" "binary")
1038 (set_attr "length" "8")])
1039
1040 (define_insn ""
1041 [(set (match_operand:DI 0 "register_operand" "=r")
1042 (minus:DI (match_operand:DI 1 "register_operand" "r")
1043 (leu:DI (match_operand:DI 2 "register_operand" "r")
1044 (match_operand:DI 3 "int11_operand" "I"))))]
1045 "TARGET_64BIT"
1046 "addi %k3,%2,%%r0\;sub,db %1,%%r0,%0"
1047 [(set_attr "type" "binary")
1048 (set_attr "length" "8")])
1049
1050 (define_insn ""
1051 [(set (match_operand:SI 0 "register_operand" "=r")
1052 (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
1053 (leu:SI (match_operand:SI 2 "register_operand" "r")
1054 (match_operand:SI 3 "int11_operand" "I")))
1055 (match_operand:SI 4 "register_operand" "r")))]
1056 ""
1057 "addi %k3,%2,%%r0\;{subb|sub,b} %1,%4,%0"
1058 [(set_attr "type" "binary")
1059 (set_attr "length" "8")])
1060
1061 (define_insn ""
1062 [(set (match_operand:DI 0 "register_operand" "=r")
1063 (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
1064 (leu:DI (match_operand:DI 2 "register_operand" "r")
1065 (match_operand:DI 3 "int11_operand" "I")))
1066 (match_operand:DI 4 "register_operand" "r")))]
1067 "TARGET_64BIT"
1068 "addi %k3,%2,%%r0\;sub,db %1,%4,%0"
1069 [(set_attr "type" "binary")
1070 (set_attr "length" "8")])
1071
1072 (define_insn "decscc"
1073 [(set (match_operand:SI 0 "register_operand" "=r,r")
1074 (minus:SI (match_operand:SI 1 "register_operand" "0,?r")
1075 (match_operator:SI 4 "ordered_comparison_operator"
1076 [(match_operand:SI 2 "register_operand" "r,r")
1077 (match_operand:SI 3 "arith11_operand" "rI,rI")])))]
1078 ""
1079 "@
1080 {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi -1,%0,%0
1081 {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi,tr -1,%1,%0\;copy %1,%0"
1082 [(set_attr "type" "binary,binary")
1083 (set_attr "length" "8,12")])
1084
1085 (define_insn ""
1086 [(set (match_operand:DI 0 "register_operand" "=r,r")
1087 (minus:DI (match_operand:DI 1 "register_operand" "0,?r")
1088 (match_operator:DI 4 "ordered_comparison_operator"
1089 [(match_operand:DI 2 "register_operand" "r,r")
1090 (match_operand:DI 3 "arith11_operand" "rI,rI")])))]
1091 "TARGET_64BIT"
1092 "@
1093 cmp%I3clr,*%B4 %3,%2,%%r0\;addi -1,%0,%0
1094 cmp%I3clr,*%B4 %3,%2,%%r0\;addi,tr -1,%1,%0\;copy %1,%0"
1095 [(set_attr "type" "binary,binary")
1096 (set_attr "length" "8,12")])
1097
1098 ; Patterns for max and min. (There is no need for an earlyclobber in the
1099 ; last alternative since the middle alternative will match if op0 == op1.)
1100
1101 (define_insn "sminsi3"
1102 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1103 (smin:SI (match_operand:SI 1 "register_operand" "%0,0,r")
1104 (match_operand:SI 2 "arith11_operand" "r,I,M")))]
1105 ""
1106 "@
1107 {comclr|cmpclr},> %2,%0,%%r0\;copy %2,%0
1108 {comiclr|cmpiclr},> %2,%0,%%r0\;ldi %2,%0
1109 {comclr|cmpclr},> %1,%r2,%0\;copy %1,%0"
1110 [(set_attr "type" "multi,multi,multi")
1111 (set_attr "length" "8,8,8")])
1112
1113 (define_insn "smindi3"
1114 [(set (match_operand:DI 0 "register_operand" "=r,r,r")
1115 (smin:DI (match_operand:DI 1 "register_operand" "%0,0,r")
1116 (match_operand:DI 2 "arith11_operand" "r,I,M")))]
1117 "TARGET_64BIT"
1118 "@
1119 cmpclr,*> %2,%0,%%r0\;copy %2,%0
1120 cmpiclr,*> %2,%0,%%r0\;ldi %2,%0
1121 cmpclr,*> %1,%r2,%0\;copy %1,%0"
1122 [(set_attr "type" "multi,multi,multi")
1123 (set_attr "length" "8,8,8")])
1124
1125 (define_insn "uminsi3"
1126 [(set (match_operand:SI 0 "register_operand" "=r,r")
1127 (umin:SI (match_operand:SI 1 "register_operand" "%0,0")
1128 (match_operand:SI 2 "arith11_operand" "r,I")))]
1129 ""
1130 "@
1131 {comclr|cmpclr},>> %2,%0,%%r0\;copy %2,%0
1132 {comiclr|cmpiclr},>> %2,%0,%%r0\;ldi %2,%0"
1133 [(set_attr "type" "multi,multi")
1134 (set_attr "length" "8,8")])
1135
1136 (define_insn "umindi3"
1137 [(set (match_operand:DI 0 "register_operand" "=r,r")
1138 (umin:DI (match_operand:DI 1 "register_operand" "%0,0")
1139 (match_operand:DI 2 "arith11_operand" "r,I")))]
1140 "TARGET_64BIT"
1141 "@
1142 cmpclr,*>> %2,%0,%%r0\;copy %2,%0
1143 cmpiclr,*>> %2,%0,%%r0\;ldi %2,%0"
1144 [(set_attr "type" "multi,multi")
1145 (set_attr "length" "8,8")])
1146
1147 (define_insn "smaxsi3"
1148 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1149 (smax:SI (match_operand:SI 1 "register_operand" "%0,0,r")
1150 (match_operand:SI 2 "arith11_operand" "r,I,M")))]
1151 ""
1152 "@
1153 {comclr|cmpclr},< %2,%0,%%r0\;copy %2,%0
1154 {comiclr|cmpiclr},< %2,%0,%%r0\;ldi %2,%0
1155 {comclr|cmpclr},< %1,%r2,%0\;copy %1,%0"
1156 [(set_attr "type" "multi,multi,multi")
1157 (set_attr "length" "8,8,8")])
1158
1159 (define_insn "smaxdi3"
1160 [(set (match_operand:DI 0 "register_operand" "=r,r,r")
1161 (smax:DI (match_operand:DI 1 "register_operand" "%0,0,r")
1162 (match_operand:DI 2 "arith11_operand" "r,I,M")))]
1163 "TARGET_64BIT"
1164 "@
1165 cmpclr,*< %2,%0,%%r0\;copy %2,%0
1166 cmpiclr,*< %2,%0,%%r0\;ldi %2,%0
1167 cmpclr,*< %1,%r2,%0\;copy %1,%0"
1168 [(set_attr "type" "multi,multi,multi")
1169 (set_attr "length" "8,8,8")])
1170
1171 (define_insn "umaxsi3"
1172 [(set (match_operand:SI 0 "register_operand" "=r,r")
1173 (umax:SI (match_operand:SI 1 "register_operand" "%0,0")
1174 (match_operand:SI 2 "arith11_operand" "r,I")))]
1175 ""
1176 "@
1177 {comclr|cmpclr},<< %2,%0,%%r0\;copy %2,%0
1178 {comiclr|cmpiclr},<< %2,%0,%%r0\;ldi %2,%0"
1179 [(set_attr "type" "multi,multi")
1180 (set_attr "length" "8,8")])
1181
1182 (define_insn "umaxdi3"
1183 [(set (match_operand:DI 0 "register_operand" "=r,r")
1184 (umax:DI (match_operand:DI 1 "register_operand" "%0,0")
1185 (match_operand:DI 2 "arith11_operand" "r,I")))]
1186 "TARGET_64BIT"
1187 "@
1188 cmpclr,*<< %2,%0,%%r0\;copy %2,%0
1189 cmpiclr,*<< %2,%0,%%r0\;ldi %2,%0"
1190 [(set_attr "type" "multi,multi")
1191 (set_attr "length" "8,8")])
1192
1193 (define_insn "absqi2"
1194 [(set (match_operand:QI 0 "register_operand" "=r")
1195 (abs:QI (match_operand:QI 1 "register_operand" "r")))]
1196 ""
1197 "{extrs|extrw,s},>= %1,31,8,%0\;subi 0,%0,%0"
1198 [(set_attr "type" "multi")
1199 (set_attr "length" "8")])
1200
1201 (define_insn "abshi2"
1202 [(set (match_operand:HI 0 "register_operand" "=r")
1203 (abs:HI (match_operand:HI 1 "register_operand" "r")))]
1204 ""
1205 "{extrs|extrw,s},>= %1,31,16,%0\;subi 0,%0,%0"
1206 [(set_attr "type" "multi")
1207 (set_attr "length" "8")])
1208
1209 (define_insn "abssi2"
1210 [(set (match_operand:SI 0 "register_operand" "=r")
1211 (abs:SI (match_operand:SI 1 "register_operand" "r")))]
1212 ""
1213 "or,>= %%r0,%1,%0\;subi 0,%0,%0"
1214 [(set_attr "type" "multi")
1215 (set_attr "length" "8")])
1216
1217 (define_insn "absdi2"
1218 [(set (match_operand:DI 0 "register_operand" "=r")
1219 (abs:DI (match_operand:DI 1 "register_operand" "r")))]
1220 "TARGET_64BIT"
1221 "or,*>= %%r0,%1,%0\;subi 0,%0,%0"
1222 [(set_attr "type" "multi")
1223 (set_attr "length" "8")])
1224
1225 (define_insn "bswaphi2"
1226 [(set (match_operand:HI 0 "register_operand" "=&r")
1227 (bswap:HI (match_operand:HI 1 "register_operand" "r")))]
1228 ""
1229 "{extru|extrw,u} %1,23,8,%0\;{dep|depw} %1,23,8,%0"
1230 [(set_attr "type" "multi")
1231 (set_attr "length" "8")])
1232
1233 (define_insn "bswapsi2"
1234 [(set (match_operand:SI 0 "register_operand" "=&r")
1235 (bswap:SI (match_operand:SI 1 "register_operand" "r")))]
1236 ""
1237 "{shd|shrpw} %1,%1,16,%0\;{dep|depw} %0,15,8,%0\;{shd|shrpw} %1,%0,8,%0"
1238 [(set_attr "type" "multi")
1239 (set_attr "length" "12")])
1240
1241 (define_insn "bswapdi2"
1242 [(set (match_operand:DI 0 "register_operand" "=&r")
1243 (bswap:DI (match_operand:DI 1 "register_operand" "r")))
1244 (clobber (match_scratch:DI 2 "=r"))]
1245 "TARGET_64BIT"
1246 "permh,3210 %1,%2\;hshl %2,8,%0\;hshr,u %2,8,%2\;or %0,%2,%0"
1247 [(set_attr "type" "multi")
1248 (set_attr "length" "16")])
1249
1250 ;;; Experimental conditional move patterns
1251
1252 (define_expand "movsicc"
1253 [(set (match_operand:SI 0 "register_operand" "")
1254 (if_then_else:SI
1255 (match_operand 1 "ordered_comparison_operator" "")
1256 (match_operand:SI 2 "reg_or_cint_move_operand" "")
1257 (match_operand:SI 3 "reg_or_cint_move_operand" "")))]
1258 ""
1259 "
1260 {
1261 if (GET_MODE (XEXP (operands[1], 0)) != SImode
1262 || GET_MODE (XEXP (operands[1], 0)) != GET_MODE (XEXP (operands[1], 1)))
1263 FAIL;
1264 }")
1265
1266 ;; We used to accept any register for op1.
1267 ;;
1268 ;; However, it loses sometimes because the compiler will end up using
1269 ;; different registers for op0 and op1 in some critical cases. local-alloc
1270 ;; will not tie op0 and op1 because op0 is used in multiple basic blocks.
1271 ;;
1272 ;; If/when global register allocation supports tying we should allow any
1273 ;; register for op1 again.
1274 (define_insn ""
1275 [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
1276 (if_then_else:SI
1277 (match_operator 2 "ordered_comparison_operator"
1278 [(match_operand:SI 3 "register_operand" "r,r,r,r")
1279 (match_operand:SI 4 "arith11_operand" "rI,rI,rI,rI")])
1280 (match_operand:SI 1 "reg_or_cint_move_operand" "0,J,N,K")
1281 (const_int 0)))]
1282 ""
1283 "@
1284 {com%I4clr|cmp%I4clr},%S2 %4,%3,%%r0\;ldi 0,%0
1285 {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;ldi %1,%0
1286 {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;ldil L'%1,%0
1287 {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;{zdepi|depwi,z} %Z1,%0"
1288 [(set_attr "type" "multi,multi,multi,nullshift")
1289 (set_attr "length" "8,8,8,8")])
1290
1291 (define_insn ""
1292 [(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r,r,r")
1293 (if_then_else:SI
1294 (match_operator 5 "ordered_comparison_operator"
1295 [(match_operand:SI 3 "register_operand" "r,r,r,r,r,r,r,r")
1296 (match_operand:SI 4 "arith11_operand" "rI,rI,rI,rI,rI,rI,rI,rI")])
1297 (match_operand:SI 1 "reg_or_cint_move_operand" "0,0,0,0,r,J,N,K")
1298 (match_operand:SI 2 "reg_or_cint_move_operand" "r,J,N,K,0,0,0,0")))]
1299 ""
1300 "@
1301 {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;copy %2,%0
1302 {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;ldi %2,%0
1303 {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;ldil L'%2,%0
1304 {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;{zdepi|depwi,z} %Z2,%0
1305 {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;copy %1,%0
1306 {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;ldi %1,%0
1307 {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;ldil L'%1,%0
1308 {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;{zdepi|depwi,z} %Z1,%0"
1309 [(set_attr "type" "multi,multi,multi,nullshift,multi,multi,multi,nullshift")
1310 (set_attr "length" "8,8,8,8,8,8,8,8")])
1311
1312 (define_expand "movdicc"
1313 [(set (match_operand:DI 0 "register_operand" "")
1314 (if_then_else:DI
1315 (match_operand 1 "ordered_comparison_operator" "")
1316 (match_operand:DI 2 "reg_or_cint_move_operand" "")
1317 (match_operand:DI 3 "reg_or_cint_move_operand" "")))]
1318 "TARGET_64BIT"
1319 "
1320 {
1321 if (GET_MODE (XEXP (operands[1], 0)) != DImode
1322 || GET_MODE (XEXP (operands[1], 0)) != GET_MODE (XEXP (operands[1], 1)))
1323 FAIL;
1324 }")
1325
1326 ; We need the first constraint alternative in order to avoid
1327 ; earlyclobbers on all other alternatives.
1328 (define_insn ""
1329 [(set (match_operand:DI 0 "register_operand" "=r,r,r,r,r")
1330 (if_then_else:DI
1331 (match_operator 2 "ordered_comparison_operator"
1332 [(match_operand:DI 3 "register_operand" "r,r,r,r,r")
1333 (match_operand:DI 4 "arith11_operand" "rI,rI,rI,rI,rI")])
1334 (match_operand:DI 1 "reg_or_cint_move_operand" "0,r,J,N,K")
1335 (const_int 0)))]
1336 "TARGET_64BIT"
1337 "@
1338 cmp%I4clr,*%S2 %4,%3,%%r0\;ldi 0,%0
1339 cmp%I4clr,*%B2 %4,%3,%0\;copy %1,%0
1340 cmp%I4clr,*%B2 %4,%3,%0\;ldi %1,%0
1341 cmp%I4clr,*%B2 %4,%3,%0\;ldil L'%1,%0
1342 cmp%I4clr,*%B2 %4,%3,%0\;depdi,z %z1,%0"
1343 [(set_attr "type" "multi,multi,multi,multi,nullshift")
1344 (set_attr "length" "8,8,8,8,8")])
1345
1346 (define_insn ""
1347 [(set (match_operand:DI 0 "register_operand" "=r,r,r,r,r,r,r,r")
1348 (if_then_else:DI
1349 (match_operator 5 "ordered_comparison_operator"
1350 [(match_operand:DI 3 "register_operand" "r,r,r,r,r,r,r,r")
1351 (match_operand:DI 4 "arith11_operand" "rI,rI,rI,rI,rI,rI,rI,rI")])
1352 (match_operand:DI 1 "reg_or_cint_move_operand" "0,0,0,0,r,J,N,K")
1353 (match_operand:DI 2 "reg_or_cint_move_operand" "r,J,N,K,0,0,0,0")))]
1354 "TARGET_64BIT"
1355 "@
1356 cmp%I4clr,*%S5 %4,%3,%%r0\;copy %2,%0
1357 cmp%I4clr,*%S5 %4,%3,%%r0\;ldi %2,%0
1358 cmp%I4clr,*%S5 %4,%3,%%r0\;ldil L'%2,%0
1359 cmp%I4clr,*%S5 %4,%3,%%r0\;depdi,z %z2,%0
1360 cmp%I4clr,*%B5 %4,%3,%%r0\;copy %1,%0
1361 cmp%I4clr,*%B5 %4,%3,%%r0\;ldi %1,%0
1362 cmp%I4clr,*%B5 %4,%3,%%r0\;ldil L'%1,%0
1363 cmp%I4clr,*%B5 %4,%3,%%r0\;depdi,z %z1,%0"
1364 [(set_attr "type" "multi,multi,multi,nullshift,multi,multi,multi,nullshift")
1365 (set_attr "length" "8,8,8,8,8,8,8,8")])
1366
1367 ;; Conditional Branches
1368
1369 (define_expand "cbranchdi4"
1370 [(set (pc)
1371 (if_then_else (match_operator 0 "ordered_comparison_operator"
1372 [(match_operand:DI 1 "reg_or_0_operand" "")
1373 (match_operand:DI 2 "register_operand" "")])
1374 (label_ref (match_operand 3 "" ""))
1375 (pc)))]
1376 "TARGET_64BIT"
1377 "")
1378
1379 (define_expand "cbranchsi4"
1380 [(set (pc)
1381 (if_then_else (match_operator 0 "ordered_comparison_operator"
1382 [(match_operand:SI 1 "reg_or_0_operand" "")
1383 (match_operand:SI 2 "arith5_operand" "")])
1384 (label_ref (match_operand 3 "" ""))
1385 (pc)))]
1386 ""
1387 "")
1388
1389 (define_expand "cbranchsf4"
1390 [(set (pc)
1391 (if_then_else (match_operator 0 "comparison_operator"
1392 [(match_operand:SF 1 "reg_or_0_operand" "")
1393 (match_operand:SF 2 "reg_or_0_operand" "")])
1394 (label_ref (match_operand 3 "" ""))
1395 (pc)))]
1396 "! TARGET_SOFT_FLOAT"
1397 "
1398 {
1399 pa_emit_bcond_fp (operands);
1400 DONE;
1401 }")
1402
1403
1404 (define_expand "cbranchdf4"
1405 [(set (pc)
1406 (if_then_else (match_operator 0 "comparison_operator"
1407 [(match_operand:DF 1 "reg_or_0_operand" "")
1408 (match_operand:DF 2 "reg_or_0_operand" "")])
1409 (label_ref (match_operand 3 "" ""))
1410 (pc)))]
1411 "! TARGET_SOFT_FLOAT"
1412 "
1413 {
1414 pa_emit_bcond_fp (operands);
1415 DONE;
1416 }")
1417
1418 ;; Match the branch patterns.
1419
1420
1421 ;; Note a long backward conditional branch with an annulled delay slot
1422 ;; has a length of 12.
1423 (define_insn ""
1424 [(set (pc)
1425 (if_then_else
1426 (match_operator 3 "ordered_comparison_operator"
1427 [(match_operand:SI 1 "reg_or_0_operand" "rM")
1428 (match_operand:SI 2 "arith5_operand" "rL")])
1429 (label_ref (match_operand 0 "" ""))
1430 (pc)))]
1431 ""
1432 "*
1433 {
1434 return pa_output_cbranch (operands, 0, insn);
1435 }"
1436 [(set_attr "type" "cbranch")
1437 (set (attr "length")
1438 (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1439 (const_int MAX_12BIT_OFFSET))
1440 (const_int 4)
1441 (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1442 (const_int MAX_17BIT_OFFSET))
1443 (const_int 8)
1444 (match_test "TARGET_PORTABLE_RUNTIME")
1445 (const_int 24)
1446 (not (match_test "flag_pic"))
1447 (const_int 20)]
1448 (const_int 28)))])
1449
1450 ;; Match the negated branch.
1451
1452 (define_insn ""
1453 [(set (pc)
1454 (if_then_else
1455 (match_operator 3 "ordered_comparison_operator"
1456 [(match_operand:SI 1 "reg_or_0_operand" "rM")
1457 (match_operand:SI 2 "arith5_operand" "rL")])
1458 (pc)
1459 (label_ref (match_operand 0 "" ""))))]
1460 ""
1461 "*
1462 {
1463 return pa_output_cbranch (operands, 1, insn);
1464 }"
1465 [(set_attr "type" "cbranch")
1466 (set (attr "length")
1467 (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1468 (const_int MAX_12BIT_OFFSET))
1469 (const_int 4)
1470 (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1471 (const_int MAX_17BIT_OFFSET))
1472 (const_int 8)
1473 (match_test "TARGET_PORTABLE_RUNTIME")
1474 (const_int 24)
1475 (not (match_test "flag_pic"))
1476 (const_int 20)]
1477 (const_int 28)))])
1478
1479 (define_insn ""
1480 [(set (pc)
1481 (if_then_else
1482 (match_operator 3 "ordered_comparison_operator"
1483 [(match_operand:DI 1 "reg_or_0_operand" "rM")
1484 (match_operand:DI 2 "reg_or_0_operand" "rM")])
1485 (label_ref (match_operand 0 "" ""))
1486 (pc)))]
1487 "TARGET_64BIT"
1488 "*
1489 {
1490 return pa_output_cbranch (operands, 0, insn);
1491 }"
1492 [(set_attr "type" "cbranch")
1493 (set (attr "length")
1494 (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1495 (const_int MAX_12BIT_OFFSET))
1496 (const_int 4)
1497 (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1498 (const_int MAX_17BIT_OFFSET))
1499 (const_int 8)
1500 (match_test "TARGET_PORTABLE_RUNTIME")
1501 (const_int 24)
1502 (not (match_test "flag_pic"))
1503 (const_int 20)]
1504 (const_int 28)))])
1505
1506 ;; Match the negated branch.
1507
1508 (define_insn ""
1509 [(set (pc)
1510 (if_then_else
1511 (match_operator 3 "ordered_comparison_operator"
1512 [(match_operand:DI 1 "reg_or_0_operand" "rM")
1513 (match_operand:DI 2 "reg_or_0_operand" "rM")])
1514 (pc)
1515 (label_ref (match_operand 0 "" ""))))]
1516 "TARGET_64BIT"
1517 "*
1518 {
1519 return pa_output_cbranch (operands, 1, insn);
1520 }"
1521 [(set_attr "type" "cbranch")
1522 (set (attr "length")
1523 (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1524 (const_int MAX_12BIT_OFFSET))
1525 (const_int 4)
1526 (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1527 (const_int MAX_17BIT_OFFSET))
1528 (const_int 8)
1529 (match_test "TARGET_PORTABLE_RUNTIME")
1530 (const_int 24)
1531 (not (match_test "flag_pic"))
1532 (const_int 20)]
1533 (const_int 28)))])
1534 (define_insn ""
1535 [(set (pc)
1536 (if_then_else
1537 (match_operator 3 "cmpib_comparison_operator"
1538 [(match_operand:DI 1 "reg_or_0_operand" "rM")
1539 (match_operand:DI 2 "arith5_operand" "rL")])
1540 (label_ref (match_operand 0 "" ""))
1541 (pc)))]
1542 "TARGET_64BIT"
1543 "*
1544 {
1545 return pa_output_cbranch (operands, 0, insn);
1546 }"
1547 [(set_attr "type" "cbranch")
1548 (set (attr "length")
1549 (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1550 (const_int MAX_12BIT_OFFSET))
1551 (const_int 4)
1552 (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1553 (const_int MAX_17BIT_OFFSET))
1554 (const_int 8)
1555 (match_test "TARGET_PORTABLE_RUNTIME")
1556 (const_int 24)
1557 (not (match_test "flag_pic"))
1558 (const_int 20)]
1559 (const_int 28)))])
1560
1561 ;; Match the negated branch.
1562
1563 (define_insn ""
1564 [(set (pc)
1565 (if_then_else
1566 (match_operator 3 "cmpib_comparison_operator"
1567 [(match_operand:DI 1 "reg_or_0_operand" "rM")
1568 (match_operand:DI 2 "arith5_operand" "rL")])
1569 (pc)
1570 (label_ref (match_operand 0 "" ""))))]
1571 "TARGET_64BIT"
1572 "*
1573 {
1574 return pa_output_cbranch (operands, 1, insn);
1575 }"
1576 [(set_attr "type" "cbranch")
1577 (set (attr "length")
1578 (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1579 (const_int MAX_12BIT_OFFSET))
1580 (const_int 4)
1581 (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1582 (const_int MAX_17BIT_OFFSET))
1583 (const_int 8)
1584 (match_test "TARGET_PORTABLE_RUNTIME")
1585 (const_int 24)
1586 (not (match_test "flag_pic"))
1587 (const_int 20)]
1588 (const_int 28)))])
1589
1590 ;; Branch on Bit patterns.
1591 (define_insn ""
1592 [(set (pc)
1593 (if_then_else
1594 (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1595 (const_int 1)
1596 (match_operand:SI 1 "uint5_operand" ""))
1597 (const_int 0))
1598 (label_ref (match_operand 2 "" ""))
1599 (pc)))]
1600 ""
1601 "*
1602 {
1603 return pa_output_bb (operands, 0, insn, 0);
1604 }"
1605 [(set_attr "type" "cbranch")
1606 (set (attr "length")
1607 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1608 (const_int MAX_12BIT_OFFSET))
1609 (const_int 4)
1610 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1611 (const_int MAX_17BIT_OFFSET))
1612 (const_int 8)
1613 (match_test "TARGET_PORTABLE_RUNTIME")
1614 (const_int 24)
1615 (not (match_test "flag_pic"))
1616 (const_int 20)]
1617 (const_int 28)))])
1618
1619 (define_insn ""
1620 [(set (pc)
1621 (if_then_else
1622 (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1623 (const_int 1)
1624 (match_operand:DI 1 "uint32_operand" ""))
1625 (const_int 0))
1626 (label_ref (match_operand 2 "" ""))
1627 (pc)))]
1628 "TARGET_64BIT"
1629 "*
1630 {
1631 return pa_output_bb (operands, 0, insn, 0);
1632 }"
1633 [(set_attr "type" "cbranch")
1634 (set (attr "length")
1635 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1636 (const_int MAX_12BIT_OFFSET))
1637 (const_int 4)
1638 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1639 (const_int MAX_17BIT_OFFSET))
1640 (const_int 8)
1641 (match_test "TARGET_PORTABLE_RUNTIME")
1642 (const_int 24)
1643 (not (match_test "flag_pic"))
1644 (const_int 20)]
1645 (const_int 28)))])
1646
1647 (define_insn ""
1648 [(set (pc)
1649 (if_then_else
1650 (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1651 (const_int 1)
1652 (match_operand:SI 1 "uint5_operand" ""))
1653 (const_int 0))
1654 (pc)
1655 (label_ref (match_operand 2 "" ""))))]
1656 ""
1657 "*
1658 {
1659 return pa_output_bb (operands, 1, insn, 0);
1660 }"
1661 [(set_attr "type" "cbranch")
1662 (set (attr "length")
1663 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1664 (const_int MAX_12BIT_OFFSET))
1665 (const_int 4)
1666 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1667 (const_int MAX_17BIT_OFFSET))
1668 (const_int 8)
1669 (match_test "TARGET_PORTABLE_RUNTIME")
1670 (const_int 24)
1671 (not (match_test "flag_pic"))
1672 (const_int 20)]
1673 (const_int 28)))])
1674
1675 (define_insn ""
1676 [(set (pc)
1677 (if_then_else
1678 (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1679 (const_int 1)
1680 (match_operand:DI 1 "uint32_operand" ""))
1681 (const_int 0))
1682 (pc)
1683 (label_ref (match_operand 2 "" ""))))]
1684 "TARGET_64BIT"
1685 "*
1686 {
1687 return pa_output_bb (operands, 1, insn, 0);
1688 }"
1689 [(set_attr "type" "cbranch")
1690 (set (attr "length")
1691 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1692 (const_int MAX_12BIT_OFFSET))
1693 (const_int 4)
1694 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1695 (const_int MAX_17BIT_OFFSET))
1696 (const_int 8)
1697 (match_test "TARGET_PORTABLE_RUNTIME")
1698 (const_int 24)
1699 (not (match_test "flag_pic"))
1700 (const_int 20)]
1701 (const_int 28)))])
1702
1703 (define_insn ""
1704 [(set (pc)
1705 (if_then_else
1706 (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1707 (const_int 1)
1708 (match_operand:SI 1 "uint5_operand" ""))
1709 (const_int 0))
1710 (label_ref (match_operand 2 "" ""))
1711 (pc)))]
1712 ""
1713 "*
1714 {
1715 return pa_output_bb (operands, 0, insn, 1);
1716 }"
1717 [(set_attr "type" "cbranch")
1718 (set (attr "length")
1719 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1720 (const_int MAX_12BIT_OFFSET))
1721 (const_int 4)
1722 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1723 (const_int MAX_17BIT_OFFSET))
1724 (const_int 8)
1725 (match_test "TARGET_PORTABLE_RUNTIME")
1726 (const_int 24)
1727 (not (match_test "flag_pic"))
1728 (const_int 20)]
1729 (const_int 28)))])
1730
1731 (define_insn ""
1732 [(set (pc)
1733 (if_then_else
1734 (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1735 (const_int 1)
1736 (match_operand:DI 1 "uint32_operand" ""))
1737 (const_int 0))
1738 (label_ref (match_operand 2 "" ""))
1739 (pc)))]
1740 "TARGET_64BIT"
1741 "*
1742 {
1743 return pa_output_bb (operands, 0, insn, 1);
1744 }"
1745 [(set_attr "type" "cbranch")
1746 (set (attr "length")
1747 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1748 (const_int MAX_12BIT_OFFSET))
1749 (const_int 4)
1750 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1751 (const_int MAX_17BIT_OFFSET))
1752 (const_int 8)
1753 (match_test "TARGET_PORTABLE_RUNTIME")
1754 (const_int 24)
1755 (not (match_test "flag_pic"))
1756 (const_int 20)]
1757 (const_int 28)))])
1758
1759 (define_insn ""
1760 [(set (pc)
1761 (if_then_else
1762 (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1763 (const_int 1)
1764 (match_operand:SI 1 "uint5_operand" ""))
1765 (const_int 0))
1766 (pc)
1767 (label_ref (match_operand 2 "" ""))))]
1768 ""
1769 "*
1770 {
1771 return pa_output_bb (operands, 1, insn, 1);
1772 }"
1773 [(set_attr "type" "cbranch")
1774 (set (attr "length")
1775 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1776 (const_int MAX_12BIT_OFFSET))
1777 (const_int 4)
1778 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1779 (const_int MAX_17BIT_OFFSET))
1780 (const_int 8)
1781 (match_test "TARGET_PORTABLE_RUNTIME")
1782 (const_int 24)
1783 (not (match_test "flag_pic"))
1784 (const_int 20)]
1785 (const_int 28)))])
1786
1787 (define_insn ""
1788 [(set (pc)
1789 (if_then_else
1790 (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1791 (const_int 1)
1792 (match_operand:DI 1 "uint32_operand" ""))
1793 (const_int 0))
1794 (pc)
1795 (label_ref (match_operand 2 "" ""))))]
1796 "TARGET_64BIT"
1797 "*
1798 {
1799 return pa_output_bb (operands, 1, insn, 1);
1800 }"
1801 [(set_attr "type" "cbranch")
1802 (set (attr "length")
1803 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1804 (const_int MAX_12BIT_OFFSET))
1805 (const_int 4)
1806 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1807 (const_int MAX_17BIT_OFFSET))
1808 (const_int 8)
1809 (match_test "TARGET_PORTABLE_RUNTIME")
1810 (const_int 24)
1811 (not (match_test "flag_pic"))
1812 (const_int 20)]
1813 (const_int 28)))])
1814
1815 ;; Branch on Variable Bit patterns.
1816 (define_insn ""
1817 [(set (pc)
1818 (if_then_else
1819 (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1820 (const_int 1)
1821 (match_operand:SI 1 "register_operand" "q"))
1822 (const_int 0))
1823 (label_ref (match_operand 2 "" ""))
1824 (pc)))]
1825 ""
1826 "*
1827 {
1828 return pa_output_bvb (operands, 0, insn, 0);
1829 }"
1830 [(set_attr "type" "cbranch")
1831 (set (attr "length")
1832 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1833 (const_int MAX_12BIT_OFFSET))
1834 (const_int 4)
1835 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1836 (const_int MAX_17BIT_OFFSET))
1837 (const_int 8)
1838 (match_test "TARGET_PORTABLE_RUNTIME")
1839 (const_int 24)
1840 (not (match_test "flag_pic"))
1841 (const_int 20)]
1842 (const_int 28)))])
1843
1844 (define_insn ""
1845 [(set (pc)
1846 (if_then_else
1847 (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1848 (const_int 1)
1849 (match_operand:DI 1 "register_operand" "q"))
1850 (const_int 0))
1851 (label_ref (match_operand 2 "" ""))
1852 (pc)))]
1853 "TARGET_64BIT"
1854 "*
1855 {
1856 return pa_output_bvb (operands, 0, insn, 0);
1857 }"
1858 [(set_attr "type" "cbranch")
1859 (set (attr "length")
1860 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1861 (const_int MAX_12BIT_OFFSET))
1862 (const_int 4)
1863 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1864 (const_int MAX_17BIT_OFFSET))
1865 (const_int 8)
1866 (match_test "TARGET_PORTABLE_RUNTIME")
1867 (const_int 24)
1868 (not (match_test "flag_pic"))
1869 (const_int 20)]
1870 (const_int 28)))])
1871
1872 (define_insn ""
1873 [(set (pc)
1874 (if_then_else
1875 (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1876 (const_int 1)
1877 (match_operand:SI 1 "register_operand" "q"))
1878 (const_int 0))
1879 (pc)
1880 (label_ref (match_operand 2 "" ""))))]
1881 ""
1882 "*
1883 {
1884 return pa_output_bvb (operands, 1, insn, 0);
1885 }"
1886 [(set_attr "type" "cbranch")
1887 (set (attr "length")
1888 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1889 (const_int MAX_12BIT_OFFSET))
1890 (const_int 4)
1891 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1892 (const_int MAX_17BIT_OFFSET))
1893 (const_int 8)
1894 (match_test "TARGET_PORTABLE_RUNTIME")
1895 (const_int 24)
1896 (not (match_test "flag_pic"))
1897 (const_int 20)]
1898 (const_int 28)))])
1899
1900 (define_insn ""
1901 [(set (pc)
1902 (if_then_else
1903 (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1904 (const_int 1)
1905 (match_operand:DI 1 "register_operand" "q"))
1906 (const_int 0))
1907 (pc)
1908 (label_ref (match_operand 2 "" ""))))]
1909 "TARGET_64BIT"
1910 "*
1911 {
1912 return pa_output_bvb (operands, 1, insn, 0);
1913 }"
1914 [(set_attr "type" "cbranch")
1915 (set (attr "length")
1916 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1917 (const_int MAX_12BIT_OFFSET))
1918 (const_int 4)
1919 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1920 (const_int MAX_17BIT_OFFSET))
1921 (const_int 8)
1922 (match_test "TARGET_PORTABLE_RUNTIME")
1923 (const_int 24)
1924 (not (match_test "flag_pic"))
1925 (const_int 20)]
1926 (const_int 28)))])
1927
1928 (define_insn ""
1929 [(set (pc)
1930 (if_then_else
1931 (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1932 (const_int 1)
1933 (match_operand:SI 1 "register_operand" "q"))
1934 (const_int 0))
1935 (label_ref (match_operand 2 "" ""))
1936 (pc)))]
1937 ""
1938 "*
1939 {
1940 return pa_output_bvb (operands, 0, insn, 1);
1941 }"
1942 [(set_attr "type" "cbranch")
1943 (set (attr "length")
1944 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1945 (const_int MAX_12BIT_OFFSET))
1946 (const_int 4)
1947 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1948 (const_int MAX_17BIT_OFFSET))
1949 (const_int 8)
1950 (match_test "TARGET_PORTABLE_RUNTIME")
1951 (const_int 24)
1952 (not (match_test "flag_pic"))
1953 (const_int 20)]
1954 (const_int 28)))])
1955
1956 (define_insn ""
1957 [(set (pc)
1958 (if_then_else
1959 (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1960 (const_int 1)
1961 (match_operand:DI 1 "register_operand" "q"))
1962 (const_int 0))
1963 (label_ref (match_operand 2 "" ""))
1964 (pc)))]
1965 "TARGET_64BIT"
1966 "*
1967 {
1968 return pa_output_bvb (operands, 0, insn, 1);
1969 }"
1970 [(set_attr "type" "cbranch")
1971 (set (attr "length")
1972 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1973 (const_int MAX_12BIT_OFFSET))
1974 (const_int 4)
1975 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1976 (const_int MAX_17BIT_OFFSET))
1977 (const_int 8)
1978 (match_test "TARGET_PORTABLE_RUNTIME")
1979 (const_int 24)
1980 (not (match_test "flag_pic"))
1981 (const_int 20)]
1982 (const_int 28)))])
1983
1984 (define_insn ""
1985 [(set (pc)
1986 (if_then_else
1987 (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1988 (const_int 1)
1989 (match_operand:SI 1 "register_operand" "q"))
1990 (const_int 0))
1991 (pc)
1992 (label_ref (match_operand 2 "" ""))))]
1993 ""
1994 "*
1995 {
1996 return pa_output_bvb (operands, 1, insn, 1);
1997 }"
1998 [(set_attr "type" "cbranch")
1999 (set (attr "length")
2000 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2001 (const_int MAX_12BIT_OFFSET))
2002 (const_int 4)
2003 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2004 (const_int MAX_17BIT_OFFSET))
2005 (const_int 8)
2006 (match_test "TARGET_PORTABLE_RUNTIME")
2007 (const_int 24)
2008 (not (match_test "flag_pic"))
2009 (const_int 20)]
2010 (const_int 28)))])
2011
2012 (define_insn ""
2013 [(set (pc)
2014 (if_then_else
2015 (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2016 (const_int 1)
2017 (match_operand:DI 1 "register_operand" "q"))
2018 (const_int 0))
2019 (pc)
2020 (label_ref (match_operand 2 "" ""))))]
2021 "TARGET_64BIT"
2022 "*
2023 {
2024 return pa_output_bvb (operands, 1, insn, 1);
2025 }"
2026 [(set_attr "type" "cbranch")
2027 (set (attr "length")
2028 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2029 (const_int MAX_12BIT_OFFSET))
2030 (const_int 4)
2031 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2032 (const_int MAX_17BIT_OFFSET))
2033 (const_int 8)
2034 (match_test "TARGET_PORTABLE_RUNTIME")
2035 (const_int 24)
2036 (not (match_test "flag_pic"))
2037 (const_int 20)]
2038 (const_int 28)))])
2039
2040 ;; Floating point branches
2041
2042 ;; ??? Nullification is handled differently from other branches.
2043 ;; If nullification is specified, the delay slot is nullified on any
2044 ;; taken branch regardless of branch direction.
2045 (define_insn ""
2046 [(set (pc) (if_then_else (ne (reg:CCFP 0) (const_int 0))
2047 (label_ref (match_operand 0 "" ""))
2048 (pc)))]
2049 "!TARGET_SOFT_FLOAT"
2050 "*
2051 {
2052 int length = get_attr_length (insn);
2053 rtx xoperands[1];
2054 int nullify, xdelay;
2055
2056 if (length < 16)
2057 return \"ftest\;b%* %l0\";
2058
2059 if (dbr_sequence_length () == 0 || INSN_ANNULLED_BRANCH_P (insn))
2060 {
2061 nullify = 1;
2062 xdelay = 0;
2063 xoperands[0] = GEN_INT (length - 8);
2064 }
2065 else
2066 {
2067 nullify = 0;
2068 xdelay = 1;
2069 xoperands[0] = GEN_INT (length - 4);
2070 }
2071
2072 if (nullify)
2073 output_asm_insn (\"ftest\;add,tr %%r0,%%r0,%%r0\;b,n .+%0\", xoperands);
2074 else
2075 output_asm_insn (\"ftest\;add,tr %%r0,%%r0,%%r0\;b .+%0\", xoperands);
2076 return pa_output_lbranch (operands[0], insn, xdelay);
2077 }"
2078 [(set_attr "type" "fbranch")
2079 (set (attr "length")
2080 (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
2081 (const_int MAX_17BIT_OFFSET))
2082 (const_int 8)
2083 (match_test "TARGET_PORTABLE_RUNTIME")
2084 (const_int 32)
2085 (not (match_test "flag_pic"))
2086 (const_int 28)]
2087 (const_int 36)))])
2088
2089 (define_insn ""
2090 [(set (pc) (if_then_else (ne (reg:CCFP 0) (const_int 0))
2091 (pc)
2092 (label_ref (match_operand 0 "" ""))))]
2093 "!TARGET_SOFT_FLOAT"
2094 "*
2095 {
2096 int length = get_attr_length (insn);
2097 rtx xoperands[1];
2098 int nullify, xdelay;
2099
2100 if (length < 16)
2101 return \"ftest\;add,tr %%r0,%%r0,%%r0\;b%* %0\";
2102
2103 if (dbr_sequence_length () == 0 || INSN_ANNULLED_BRANCH_P (insn))
2104 {
2105 nullify = 1;
2106 xdelay = 0;
2107 xoperands[0] = GEN_INT (length - 4);
2108 }
2109 else
2110 {
2111 nullify = 0;
2112 xdelay = 1;
2113 xoperands[0] = GEN_INT (length);
2114 }
2115
2116 if (nullify)
2117 output_asm_insn (\"ftest\;b,n .+%0\", xoperands);
2118 else
2119 output_asm_insn (\"ftest\;b .+%0\", xoperands);
2120 return pa_output_lbranch (operands[0], insn, xdelay);
2121 }"
2122 [(set_attr "type" "fbranch")
2123 (set (attr "length")
2124 (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
2125 (const_int MAX_17BIT_OFFSET))
2126 (const_int 12)
2127 (match_test "TARGET_PORTABLE_RUNTIME")
2128 (const_int 28)
2129 (not (match_test "flag_pic"))
2130 (const_int 24)]
2131 (const_int 32)))])
2132
2133 ;; Move instructions
2134
2135 (define_expand "movsi"
2136 [(set (match_operand:SI 0 "general_operand" "")
2137 (match_operand:SI 1 "general_operand" ""))]
2138 ""
2139 "
2140 {
2141 if (pa_emit_move_sequence (operands, SImode, 0))
2142 DONE;
2143 }")
2144
2145 ;; Handle SImode input reloads requiring %r1 as a scratch register.
2146 (define_expand "reload_insi_r1"
2147 [(set (match_operand:SI 0 "register_operand" "=Z")
2148 (match_operand:SI 1 "non_hard_reg_operand" ""))
2149 (clobber (match_operand:SI 2 "register_operand" "=&a"))]
2150 ""
2151 "
2152 {
2153 if (pa_emit_move_sequence (operands, SImode, operands[2]))
2154 DONE;
2155
2156 /* We don't want the clobber emitted, so handle this ourselves. */
2157 emit_insn (gen_rtx_SET (operands[0], operands[1]));
2158 DONE;
2159 }")
2160
2161 ;; Handle SImode input reloads requiring a general register as a
2162 ;; scratch register.
2163 (define_expand "reload_insi"
2164 [(set (match_operand:SI 0 "register_operand" "=Z")
2165 (match_operand:SI 1 "non_hard_reg_operand" ""))
2166 (clobber (match_operand:SI 2 "register_operand" "=&r"))]
2167 ""
2168 "
2169 {
2170 if (pa_emit_move_sequence (operands, SImode, operands[2]))
2171 DONE;
2172
2173 /* We don't want the clobber emitted, so handle this ourselves. */
2174 emit_insn (gen_rtx_SET (operands[0], operands[1]));
2175 DONE;
2176 }")
2177
2178 ;; Handle SImode output reloads requiring a general register as a
2179 ;; scratch register.
2180 (define_expand "reload_outsi"
2181 [(set (match_operand:SI 0 "non_hard_reg_operand" "")
2182 (match_operand:SI 1 "register_operand" "Z"))
2183 (clobber (match_operand:SI 2 "register_operand" "=&r"))]
2184 ""
2185 "
2186 {
2187 if (pa_emit_move_sequence (operands, SImode, operands[2]))
2188 DONE;
2189
2190 /* We don't want the clobber emitted, so handle this ourselves. */
2191 emit_insn (gen_rtx_SET (operands[0], operands[1]));
2192 DONE;
2193 }")
2194
2195 (define_insn ""
2196 [(set (match_operand:SI 0 "move_dest_operand"
2197 "=r,r,r,r,r,r,Q,!*q,!r,!*f,*f,T,?r,?*f")
2198 (match_operand:SI 1 "move_src_operand"
2199 "A,r,J,N,K,RQ,rM,!rM,!*q,!*fM,RT,*f,*f,r"))]
2200 "(register_operand (operands[0], SImode)
2201 || reg_or_0_operand (operands[1], SImode))
2202 && !TARGET_SOFT_FLOAT
2203 && !TARGET_64BIT"
2204 "@
2205 ldw RT'%A1,%0
2206 copy %1,%0
2207 ldi %1,%0
2208 ldil L'%1,%0
2209 {zdepi|depwi,z} %Z1,%0
2210 ldw%M1 %1,%0
2211 stw%M0 %r1,%0
2212 mtsar %r1
2213 {mfctl|mfctl,w} %%sar,%0
2214 fcpy,sgl %f1,%0
2215 fldw%F1 %1,%0
2216 fstw%F0 %1,%0
2217 {fstws|fstw} %1,-16(%%sp)\n\t{ldws|ldw} -16(%%sp),%0
2218 {stws|stw} %1,-16(%%sp)\n\t{fldws|fldw} -16(%%sp),%0"
2219 [(set_attr "type" "load,move,move,move,shift,load,store,move,move,fpalu,fpload,fpstore,fpstore_load,store_fpload")
2220 (set_attr "pa_combine_type" "addmove")
2221 (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4,8,8")])
2222
2223 (define_insn ""
2224 [(set (match_operand:SI 0 "move_dest_operand"
2225 "=r,r,r,r,r,r,Q,!*q,!r,!*f,*f,T,?r,?*f")
2226 (match_operand:SI 1 "move_src_operand"
2227 "A,r,J,N,K,RQ,rM,!rM,!*q,!*fM,RT,*f,*f,r"))]
2228 "(register_operand (operands[0], SImode)
2229 || reg_or_0_operand (operands[1], SImode))
2230 && !TARGET_SOFT_FLOAT
2231 && TARGET_64BIT"
2232 "@
2233 ldw RT'%A1,%0
2234 copy %1,%0
2235 ldi %1,%0
2236 ldil L'%1,%0
2237 {zdepi|depwi,z} %Z1,%0
2238 ldw%M1 %1,%0
2239 stw%M0 %r1,%0
2240 mtsar %r1
2241 {mfctl|mfctl,w} %%sar,%0
2242 fcpy,sgl %f1,%0
2243 fldw%F1 %1,%0
2244 fstw%F0 %1,%0
2245 fstw %1,-40(%%sp)\n\tldw -40(%%sp),%0
2246 stw %1,-40(%%sp)\n\tfldw -40(%%sp),%0"
2247 [(set_attr "type" "load,move,move,move,shift,load,store,move,move,fpalu,fpload,fpstore,fpstore_load,store_fpload")
2248 (set_attr "pa_combine_type" "addmove")
2249 (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4,8,8")])
2250
2251 (define_insn ""
2252 [(set (match_operand:SI 0 "move_dest_operand"
2253 "=r,r,r,r,r,r,Q,!*q,!r")
2254 (match_operand:SI 1 "move_src_operand"
2255 "A,r,J,N,K,RQ,rM,!rM,!*q"))]
2256 "(register_operand (operands[0], SImode)
2257 || reg_or_0_operand (operands[1], SImode))
2258 && TARGET_SOFT_FLOAT
2259 && TARGET_64BIT"
2260 "@
2261 ldw RT'%A1,%0
2262 copy %1,%0
2263 ldi %1,%0
2264 ldil L'%1,%0
2265 {zdepi|depwi,z} %Z1,%0
2266 ldw%M1 %1,%0
2267 stw%M0 %r1,%0
2268 mtsar %r1
2269 {mfctl|mfctl,w} %%sar,%0"
2270 [(set_attr "type" "load,move,move,move,shift,load,store,move,move")
2271 (set_attr "pa_combine_type" "addmove")
2272 (set_attr "length" "4,4,4,4,4,4,4,4,4")])
2273
2274 (define_insn ""
2275 [(set (match_operand:SI 0 "indexed_memory_operand" "=R")
2276 (match_operand:SI 1 "register_operand" "f"))]
2277 "!TARGET_SOFT_FLOAT
2278 && !TARGET_DISABLE_INDEXING
2279 && reload_completed"
2280 "fstw%F0 %1,%0"
2281 [(set_attr "type" "fpstore")
2282 (set_attr "pa_combine_type" "addmove")
2283 (set_attr "length" "4")])
2284
2285 ; Rewrite RTL using a REG+D store. This will allow the insn that
2286 ; computes the address to be deleted if the register it sets is dead.
2287 (define_peephole2
2288 [(set (match_operand:SI 0 "register_operand" "")
2289 (plus:SI (match_operand:SI 1 "register_operand" "")
2290 (match_operand:SI 2 "const_int_operand" "")))
2291 (set (mem:SI (match_dup 0))
2292 (match_operand:SI 3 "register_operand" ""))]
2293 "!TARGET_64BIT
2294 && !INT14_OK_STRICT
2295 && GENERAL_REGNO_P (REGNO (operands[0]))
2296 && GENERAL_REGNO_P (REGNO (operands[3]))
2297 && REGNO (operands[0]) != REGNO (operands[3])
2298 && base14_operand (operands[2], E_SImode)"
2299 [(set (mem:SI (plus:SI (match_dup 1) (match_dup 2))) (match_dup 3))
2300 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
2301 "")
2302
2303 ; Rewrite RTL using a REG+D load. This will allow the insn that
2304 ; computes the address to be deleted if the register it sets is dead.
2305 (define_peephole2
2306 [(set (match_operand:SI 0 "register_operand" "")
2307 (plus:SI (match_operand:SI 1 "register_operand" "")
2308 (match_operand:SI 2 "const_int_operand" "")))
2309 (set (match_operand:SI 3 "register_operand" "")
2310 (mem:SI (match_dup 0)))]
2311 "!TARGET_64BIT
2312 && !INT14_OK_STRICT
2313 && GENERAL_REGNO_P (REGNO (operands[0]))
2314 && GENERAL_REGNO_P (REGNO (operands[3]))
2315 && REGNO (operands[0]) != REGNO (operands[3])
2316 && REGNO (operands[1]) != REGNO (operands[3])
2317 && base14_operand (operands[2], E_SImode)"
2318 [(set (match_dup 3) (mem:SI (plus:SI (match_dup 1) (match_dup 2))))
2319 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
2320 "")
2321
2322 (define_peephole2
2323 [(set (match_operand:SI 0 "register_operand" "")
2324 (plus:SI (match_operand:SI 1 "register_operand" "")
2325 (match_operand:SI 2 "const_int_operand" "")))
2326 (set (match_operand:SI 3 "register_operand" "")
2327 (mem:SI (match_dup 0)))]
2328 "!TARGET_64BIT
2329 && !INT14_OK_STRICT
2330 && GENERAL_REGNO_P (REGNO (operands[0]))
2331 && GENERAL_REGNO_P (REGNO (operands[3]))
2332 && REGNO (operands[0]) == REGNO (operands[3])
2333 && base14_operand (operands[2], E_SImode)"
2334 [(set (match_dup 3) (mem:SI (plus:SI (match_dup 1) (match_dup 2))))]
2335 "")
2336
2337 ; Rewrite RTL using an indexed store. This will allow the insn that
2338 ; computes the address to be deleted if the register it sets is dead.
2339 (define_peephole2
2340 [(set (match_operand:SI 0 "register_operand" "")
2341 (plus:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
2342 (const_int 2))
2343 (match_operand:SI 2 "register_operand" "")))
2344 (set (mem:SI (match_dup 0))
2345 (match_operand:SI 3 "register_operand" ""))]
2346 "!TARGET_SOFT_FLOAT
2347 && !TARGET_DISABLE_INDEXING
2348 && REG_OK_FOR_BASE_P (operands[2])
2349 && FP_REGNO_P (REGNO (operands[3]))"
2350 [(set (mem:SI (plus:SI (mult:SI (match_dup 1) (const_int 4)) (match_dup 2)))
2351 (match_dup 3))
2352 (set (match_dup 0) (plus:SI (ashift:SI (match_dup 1) (const_int 2))
2353 (match_dup 2)))]
2354 "")
2355
2356 (define_peephole2
2357 [(set (match_operand:DI 0 "register_operand" "")
2358 (plus:DI (ashift:DI (match_operand:DI 1 "register_operand" "")
2359 (const_int 2))
2360 (match_operand:DI 2 "register_operand" "")))
2361 (set (mem:SI (match_dup 0))
2362 (match_operand:SI 3 "register_operand" ""))]
2363 "!TARGET_SOFT_FLOAT
2364 && !TARGET_DISABLE_INDEXING
2365 && TARGET_64BIT
2366 && REG_OK_FOR_BASE_P (operands[2])
2367 && FP_REGNO_P (REGNO (operands[3]))"
2368 [(set (mem:SI (plus:DI (mult:DI (match_dup 1) (const_int 4)) (match_dup 2)))
2369 (match_dup 3))
2370 (set (match_dup 0) (plus:DI (ashift:DI (match_dup 1) (const_int 2))
2371 (match_dup 2)))]
2372 "")
2373
2374 (define_peephole2
2375 [(set (match_operand:SI 0 "register_operand" "")
2376 (plus:SI (match_operand:SI 1 "register_operand" "")
2377 (match_operand:SI 2 "register_operand" "")))
2378 (set (mem:SI (match_dup 0))
2379 (match_operand:SI 3 "register_operand" ""))]
2380 "!TARGET_SOFT_FLOAT
2381 && !TARGET_DISABLE_INDEXING
2382 && TARGET_NO_SPACE_REGS
2383 && REG_OK_FOR_INDEX_P (operands[1])
2384 && REG_OK_FOR_BASE_P (operands[2])
2385 && FP_REGNO_P (REGNO (operands[3]))"
2386 [(set (mem:SI (plus:SI (match_dup 1) (match_dup 2)))
2387 (match_dup 3))
2388 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
2389 "")
2390
2391 (define_peephole2
2392 [(set (match_operand:SI 0 "register_operand" "")
2393 (plus:SI (match_operand:SI 1 "register_operand" "")
2394 (match_operand:SI 2 "register_operand" "")))
2395 (set (mem:SI (match_dup 0))
2396 (match_operand:SI 3 "register_operand" ""))]
2397 "!TARGET_SOFT_FLOAT
2398 && !TARGET_DISABLE_INDEXING
2399 && TARGET_NO_SPACE_REGS
2400 && REG_OK_FOR_BASE_P (operands[1])
2401 && REG_OK_FOR_INDEX_P (operands[2])
2402 && FP_REGNO_P (REGNO (operands[3]))"
2403 [(set (mem:SI (plus:SI (match_dup 2) (match_dup 1)))
2404 (match_dup 3))
2405 (set (match_dup 0) (plus:SI (match_dup 2) (match_dup 1)))]
2406 "")
2407
2408 (define_peephole2
2409 [(set (match_operand:DI 0 "register_operand" "")
2410 (plus:DI (match_operand:DI 1 "register_operand" "")
2411 (match_operand:DI 2 "register_operand" "")))
2412 (set (mem:SI (match_dup 0))
2413 (match_operand:SI 3 "register_operand" ""))]
2414 "!TARGET_SOFT_FLOAT
2415 && !TARGET_DISABLE_INDEXING
2416 && TARGET_64BIT
2417 && TARGET_NO_SPACE_REGS
2418 && REG_OK_FOR_INDEX_P (operands[1])
2419 && REG_OK_FOR_BASE_P (operands[2])
2420 && FP_REGNO_P (REGNO (operands[3]))"
2421 [(set (mem:SI (plus:DI (match_dup 1) (match_dup 2)))
2422 (match_dup 3))
2423 (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
2424 "")
2425
2426 (define_peephole2
2427 [(set (match_operand:DI 0 "register_operand" "")
2428 (plus:DI (match_operand:DI 1 "register_operand" "")
2429 (match_operand:DI 2 "register_operand" "")))
2430 (set (mem:SI (match_dup 0))
2431 (match_operand:SI 3 "register_operand" ""))]
2432 "!TARGET_SOFT_FLOAT
2433 && !TARGET_DISABLE_INDEXING
2434 && TARGET_64BIT
2435 && TARGET_NO_SPACE_REGS
2436 && REG_OK_FOR_BASE_P (operands[1])
2437 && REG_OK_FOR_INDEX_P (operands[2])
2438 && FP_REGNO_P (REGNO (operands[3]))"
2439 [(set (mem:SI (plus:DI (match_dup 2) (match_dup 1)))
2440 (match_dup 3))
2441 (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
2442 "")
2443
2444 (define_insn ""
2445 [(set (match_operand:SI 0 "move_dest_operand"
2446 "=r,r,r,r,r,r,Q,!*q,!r")
2447 (match_operand:SI 1 "move_src_operand"
2448 "A,r,J,N,K,RQ,rM,!rM,!*q"))]
2449 "(register_operand (operands[0], SImode)
2450 || reg_or_0_operand (operands[1], SImode))
2451 && TARGET_SOFT_FLOAT"
2452 "@
2453 ldw RT'%A1,%0
2454 copy %1,%0
2455 ldi %1,%0
2456 ldil L'%1,%0
2457 {zdepi|depwi,z} %Z1,%0
2458 ldw%M1 %1,%0
2459 stw%M0 %r1,%0
2460 mtsar %r1
2461 {mfctl|mfctl,w} %%sar,%0"
2462 [(set_attr "type" "load,move,move,move,move,load,store,move,move")
2463 (set_attr "pa_combine_type" "addmove")
2464 (set_attr "length" "4,4,4,4,4,4,4,4,4")])
2465
2466 ;; Load or store with base-register modification.
2467 (define_insn ""
2468 [(set (match_operand:SI 0 "register_operand" "=r")
2469 (mem:SI (plus:DI (match_operand:DI 1 "register_operand" "+r")
2470 (match_operand:DI 2 "int5_operand" "L"))))
2471 (set (match_dup 1)
2472 (plus:DI (match_dup 1) (match_dup 2)))]
2473 "TARGET_64BIT"
2474 "ldw,mb %2(%1),%0"
2475 [(set_attr "type" "load")
2476 (set_attr "length" "4")])
2477
2478 ; And a zero extended variant.
2479 (define_insn ""
2480 [(set (match_operand:DI 0 "register_operand" "=r")
2481 (zero_extend:DI (mem:SI
2482 (plus:DI
2483 (match_operand:DI 1 "register_operand" "+r")
2484 (match_operand:DI 2 "int5_operand" "L")))))
2485 (set (match_dup 1)
2486 (plus:DI (match_dup 1) (match_dup 2)))]
2487 "TARGET_64BIT"
2488 "ldw,mb %2(%1),%0"
2489 [(set_attr "type" "load")
2490 (set_attr "length" "4")])
2491
2492 (define_expand "pre_load"
2493 [(parallel [(set (match_operand:SI 0 "register_operand" "")
2494 (mem (plus (match_operand 1 "register_operand" "")
2495 (match_operand 2 "pre_cint_operand" ""))))
2496 (set (match_dup 1)
2497 (plus (match_dup 1) (match_dup 2)))])]
2498 ""
2499 "
2500 {
2501 if (TARGET_64BIT)
2502 {
2503 emit_insn (gen_pre_ldd (operands[0], operands[1], operands[2]));
2504 DONE;
2505 }
2506 emit_insn (gen_pre_ldw (operands[0], operands[1], operands[2]));
2507 DONE;
2508 }")
2509
2510 (define_insn "pre_ldw"
2511 [(set (match_operand:SI 0 "register_operand" "=r")
2512 (mem:SI (plus:SI (match_operand:SI 1 "register_operand" "+r")
2513 (match_operand:SI 2 "pre_cint_operand" ""))))
2514 (set (match_dup 1)
2515 (plus:SI (match_dup 1) (match_dup 2)))]
2516 ""
2517 "*
2518 {
2519 if (INTVAL (operands[2]) < 0)
2520 return \"{ldwm|ldw,mb} %2(%1),%0\";
2521 return \"{ldws|ldw},mb %2(%1),%0\";
2522 }"
2523 [(set_attr "type" "load")
2524 (set_attr "length" "4")])
2525
2526 (define_insn "pre_ldd"
2527 [(set (match_operand:DI 0 "register_operand" "=r")
2528 (mem:DI (plus:DI (match_operand:DI 1 "register_operand" "+r")
2529 (match_operand:DI 2 "pre_cint_operand" ""))))
2530 (set (match_dup 1)
2531 (plus:DI (match_dup 1) (match_dup 2)))]
2532 "TARGET_64BIT"
2533 "ldd,mb %2(%1),%0"
2534 [(set_attr "type" "load")
2535 (set_attr "length" "4")])
2536
2537 (define_insn ""
2538 [(set (mem:SI (plus:SI (match_operand:SI 0 "register_operand" "+r")
2539 (match_operand:SI 1 "pre_cint_operand" "")))
2540 (match_operand:SI 2 "reg_or_0_operand" "rM"))
2541 (set (match_dup 0)
2542 (plus:SI (match_dup 0) (match_dup 1)))]
2543 ""
2544 "*
2545 {
2546 if (INTVAL (operands[1]) < 0)
2547 return \"{stwm|stw,mb} %r2,%1(%0)\";
2548 return \"{stws|stw},mb %r2,%1(%0)\";
2549 }"
2550 [(set_attr "type" "store")
2551 (set_attr "length" "4")])
2552
2553 (define_insn ""
2554 [(set (match_operand:SI 0 "register_operand" "=r")
2555 (mem:SI (match_operand:SI 1 "register_operand" "+r")))
2556 (set (match_dup 1)
2557 (plus:SI (match_dup 1)
2558 (match_operand:SI 2 "post_cint_operand" "")))]
2559 ""
2560 "*
2561 {
2562 if (INTVAL (operands[2]) > 0)
2563 return \"{ldwm|ldw,ma} %2(%1),%0\";
2564 return \"{ldws|ldw},ma %2(%1),%0\";
2565 }"
2566 [(set_attr "type" "load")
2567 (set_attr "length" "4")])
2568
2569 (define_expand "post_store"
2570 [(parallel [(set (mem (match_operand 0 "register_operand" ""))
2571 (match_operand 1 "reg_or_0_operand" ""))
2572 (set (match_dup 0)
2573 (plus (match_dup 0)
2574 (match_operand 2 "post_cint_operand" "")))])]
2575 ""
2576 "
2577 {
2578 if (TARGET_64BIT)
2579 {
2580 emit_insn (gen_post_std (operands[0], operands[1], operands[2]));
2581 DONE;
2582 }
2583 emit_insn (gen_post_stw (operands[0], operands[1], operands[2]));
2584 DONE;
2585 }")
2586
2587 (define_insn "post_stw"
2588 [(set (mem:SI (match_operand:SI 0 "register_operand" "+r"))
2589 (match_operand:SI 1 "reg_or_0_operand" "rM"))
2590 (set (match_dup 0)
2591 (plus:SI (match_dup 0)
2592 (match_operand:SI 2 "post_cint_operand" "")))]
2593 ""
2594 "*
2595 {
2596 if (INTVAL (operands[2]) > 0)
2597 return \"{stwm|stw,ma} %r1,%2(%0)\";
2598 return \"{stws|stw},ma %r1,%2(%0)\";
2599 }"
2600 [(set_attr "type" "store")
2601 (set_attr "length" "4")])
2602
2603 (define_insn "post_std"
2604 [(set (mem:DI (match_operand:DI 0 "register_operand" "+r"))
2605 (match_operand:DI 1 "reg_or_0_operand" "rM"))
2606 (set (match_dup 0)
2607 (plus:DI (match_dup 0)
2608 (match_operand:DI 2 "post_cint_operand" "")))]
2609 "TARGET_64BIT"
2610 "std,ma %r1,%2(%0)"
2611 [(set_attr "type" "store")
2612 (set_attr "length" "4")])
2613
2614 ;; For loading the address of a label while generating PIC code.
2615 ;; Note since this pattern can be created at reload time (via movsi), all
2616 ;; the same rules for movsi apply here. (no new pseudos, no temporaries).
2617 (define_insn ""
2618 [(set (match_operand 0 "pmode_register_operand" "=a")
2619 (match_operand 1 "pic_label_operand" ""))]
2620 "TARGET_PA_20"
2621 "*
2622 {
2623 rtx xoperands[3];
2624
2625 xoperands[0] = operands[0];
2626 xoperands[1] = operands[1];
2627
2628 if (GET_CODE (operands[1]) == LABEL_REF
2629 && !LABEL_REF_NONLOCAL_P (operands[1]))
2630 {
2631 xoperands[2] = gen_label_rtx ();
2632 (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
2633 CODE_LABEL_NUMBER (xoperands[2]));
2634 output_asm_insn (\"mfia %0\", xoperands);
2635
2636 /* If we're trying to load the address of a label that happens to be
2637 close, then we can use a shorter sequence. */
2638 if (INSN_ADDRESSES_SET_P ()
2639 && abs (INSN_ADDRESSES (INSN_UID (XEXP (operands[1], 0)))
2640 - INSN_ADDRESSES (INSN_UID (insn))) < 8100)
2641 output_asm_insn (\"ldo %1-%2(%0),%0\", xoperands);
2642 else
2643 {
2644 output_asm_insn (\"addil L%%%1-%2,%0\", xoperands);
2645 output_asm_insn (\"ldo R%%%1-%2(%0),%0\", xoperands);
2646 }
2647 }
2648 else
2649 {
2650 /* Load using linkage table. */
2651 if (TARGET_64BIT)
2652 {
2653 output_asm_insn (\"addil LT%%%1,%%r27\", xoperands);
2654 output_asm_insn (\"ldd RT%%%1(%0),%0\", xoperands);
2655 }
2656 else
2657 {
2658 output_asm_insn (\"addil LT%%%1,%%r19\", xoperands);
2659 output_asm_insn (\"ldw RT%%%1(%0),%0\", xoperands);
2660 }
2661 }
2662 return \"\";
2663 }"
2664 [(set_attr "type" "multi")
2665 (set_attr "length" "12")]) ; 8 or 12
2666
2667 (define_insn ""
2668 [(set (match_operand 0 "pmode_register_operand" "=a")
2669 (match_operand 1 "pic_label_operand" ""))]
2670 "!TARGET_PA_20"
2671 "*
2672 {
2673 rtx xoperands[3];
2674
2675 xoperands[0] = operands[0];
2676 xoperands[1] = operands[1];
2677
2678 if (GET_CODE (operands[1]) == LABEL_REF
2679 && !LABEL_REF_NONLOCAL_P (operands[1]))
2680 {
2681 xoperands[2] = gen_label_rtx ();
2682 output_asm_insn (\"bl .+8,%0\", xoperands);
2683 output_asm_insn (\"depi 0,31,2,%0\", xoperands);
2684 (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
2685 CODE_LABEL_NUMBER (xoperands[2]));
2686
2687 /* If we're trying to load the address of a label that happens to be
2688 close, then we can use a shorter sequence. */
2689 if (INSN_ADDRESSES_SET_P ()
2690 && abs (INSN_ADDRESSES (INSN_UID (XEXP (operands[1], 0)))
2691 - INSN_ADDRESSES (INSN_UID (insn))) < 8100)
2692 output_asm_insn (\"ldo %1-%2(%0),%0\", xoperands);
2693 else
2694 {
2695 output_asm_insn (\"addil L%%%1-%2,%0\", xoperands);
2696 output_asm_insn (\"ldo R%%%1-%2(%0),%0\", xoperands);
2697 }
2698 }
2699 else
2700 {
2701 /* Load using linkage table. */
2702 output_asm_insn (\"addil LT%%%1,%%r19\", xoperands);
2703 output_asm_insn (\"ldw RT%%%1(%0),%0\", xoperands);
2704 }
2705 return \"\";
2706 }"
2707 [(set_attr "type" "multi")
2708 (set_attr "length" "16")]) ; 12 or 16
2709
2710 (define_insn ""
2711 [(set (match_operand:SI 0 "register_operand" "=a")
2712 (plus:SI (match_operand:SI 1 "register_operand" "r")
2713 (high:SI (match_operand 2 "" ""))))]
2714 "symbolic_operand (operands[2], Pmode)
2715 && ! function_label_operand (operands[2], Pmode)
2716 && flag_pic"
2717 "addil LT'%G2,%1"
2718 [(set_attr "type" "binary")
2719 (set_attr "length" "4")])
2720
2721 (define_insn ""
2722 [(set (match_operand:DI 0 "register_operand" "=a")
2723 (plus:DI (match_operand:DI 1 "register_operand" "r")
2724 (high:DI (match_operand 2 "" ""))))]
2725 "symbolic_operand (operands[2], Pmode)
2726 && ! function_label_operand (operands[2], Pmode)
2727 && TARGET_64BIT
2728 && flag_pic"
2729 "addil LT'%G2,%1"
2730 [(set_attr "type" "binary")
2731 (set_attr "length" "4")])
2732
2733 (define_insn ""
2734 [(set (match_operand:SI 0 "register_operand" "=r")
2735 (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
2736 (unspec:SI [(match_operand 2 "" "")] UNSPEC_DLTIND14R)))]
2737 "symbolic_operand (operands[2], Pmode)
2738 && ! function_label_operand (operands[2], Pmode)
2739 && flag_pic"
2740 "ldo RT'%G2(%1),%0"
2741 [(set_attr "type" "binary")
2742 (set_attr "length" "4")])
2743
2744 (define_insn ""
2745 [(set (match_operand:DI 0 "register_operand" "=r")
2746 (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
2747 (unspec:DI [(match_operand 2 "" "")] UNSPEC_DLTIND14R)))]
2748 "symbolic_operand (operands[2], Pmode)
2749 && ! function_label_operand (operands[2], Pmode)
2750 && TARGET_64BIT
2751 && flag_pic"
2752 "ldo RT'%G2(%1),%0"
2753 [(set_attr "type" "binary")
2754 (set_attr "length" "4")])
2755
2756 ;; Always use addil rather than ldil;add sequences. This allows the
2757 ;; HP linker to eliminate the dp relocation if the symbolic operand
2758 ;; lives in the TEXT space.
2759 (define_insn ""
2760 [(set (match_operand:SI 0 "register_operand" "=a")
2761 (high:SI (match_operand 1 "" "")))]
2762 "symbolic_operand (operands[1], Pmode)
2763 && ! function_label_operand (operands[1], Pmode)
2764 && ! read_only_operand (operands[1], Pmode)
2765 && ! flag_pic"
2766 "*
2767 {
2768 if (TARGET_LONG_LOAD_STORE)
2769 return \"addil NLR'%H1,%%r27\;ldo N'%H1(%%r1),%%r1\";
2770 else
2771 return \"addil LR'%H1,%%r27\";
2772 }"
2773 [(set_attr "type" "binary")
2774 (set (attr "length")
2775 (if_then_else (not (match_test "TARGET_LONG_LOAD_STORE"))
2776 (const_int 4)
2777 (const_int 8)))])
2778
2779
2780 ;; This is for use in the prologue/epilogue code. We need it
2781 ;; to add large constants to a stack pointer or frame pointer.
2782 ;; Because of the additional %r1 pressure, we probably do not
2783 ;; want to use this in general code, so make it available
2784 ;; only after reload.
2785 (define_insn ""
2786 [(set (match_operand:SI 0 "register_operand" "=!a,*r")
2787 (plus:SI (match_operand:SI 1 "register_operand" "r,r")
2788 (high:SI (match_operand 2 "const_int_operand" ""))))]
2789 "reload_completed"
2790 "@
2791 addil L'%G2,%1
2792 ldil L'%G2,%0\;{addl|add,l} %0,%1,%0"
2793 [(set_attr "type" "binary,binary")
2794 (set_attr "length" "4,8")])
2795
2796 (define_insn ""
2797 [(set (match_operand:DI 0 "register_operand" "=!a,*r")
2798 (plus:DI (match_operand:DI 1 "register_operand" "r,r")
2799 (high:DI (match_operand 2 "const_int_operand" ""))))]
2800 "reload_completed && TARGET_64BIT"
2801 "@
2802 addil L'%G2,%1
2803 ldil L'%G2,%0\;{addl|add,l} %0,%1,%0"
2804 [(set_attr "type" "binary,binary")
2805 (set_attr "length" "4,8")])
2806
2807 (define_insn ""
2808 [(set (match_operand:SI 0 "register_operand" "=r")
2809 (high:SI (match_operand 1 "" "")))]
2810 "(!flag_pic || !symbolic_operand (operands[1], Pmode))
2811 && !pa_is_function_label_plus_const (operands[1])"
2812 "*
2813 {
2814 if (symbolic_operand (operands[1], Pmode))
2815 return \"ldil LR'%H1,%0\";
2816 else
2817 return \"ldil L'%G1,%0\";
2818 }"
2819 [(set_attr "type" "move")
2820 (set_attr "length" "4")])
2821
2822 (define_insn ""
2823 [(set (match_operand:DI 0 "register_operand" "=r")
2824 (high:DI (match_operand 1 "const_int_operand" "")))]
2825 "TARGET_64BIT"
2826 "ldil L'%G1,%0";
2827 [(set_attr "type" "move")
2828 (set_attr "length" "4")])
2829
2830 (define_insn ""
2831 [(set (match_operand:DI 0 "register_operand" "=r")
2832 (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
2833 (match_operand:DI 2 "const_int_operand" "i")))]
2834 "TARGET_64BIT"
2835 "ldo R'%G2(%1),%0";
2836 [(set_attr "type" "move")
2837 (set_attr "length" "4")])
2838
2839 (define_insn ""
2840 [(set (match_operand:SI 0 "register_operand" "=r")
2841 (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
2842 (match_operand:SI 2 "immediate_operand" "i")))]
2843 "!pa_is_function_label_plus_const (operands[2])"
2844 "*
2845 {
2846 gcc_assert (!flag_pic || !symbolic_operand (operands[2], Pmode));
2847
2848 if (symbolic_operand (operands[2], Pmode))
2849 return \"ldo RR'%G2(%1),%0\";
2850 else
2851 return \"ldo R'%G2(%1),%0\";
2852 }"
2853 [(set_attr "type" "move")
2854 (set_attr "length" "4")])
2855
2856 ;; Now that a symbolic_address plus a constant is broken up early
2857 ;; in the compilation phase (for better CSE) we need a special
2858 ;; combiner pattern to load the symbolic address plus the constant
2859 ;; in only 2 instructions. (For cases where the symbolic address
2860 ;; was not a common subexpression.)
2861 (define_split
2862 [(set (match_operand:SI 0 "register_operand" "")
2863 (match_operand:SI 1 "symbolic_operand" ""))
2864 (clobber (match_operand:SI 2 "register_operand" ""))]
2865 "! (flag_pic && pic_label_operand (operands[1], SImode))"
2866 [(set (match_dup 2) (high:SI (match_dup 1)))
2867 (set (match_dup 0) (lo_sum:SI (match_dup 2) (match_dup 1)))]
2868 "")
2869
2870 ;; hppa_legitimize_address goes to a great deal of trouble to
2871 ;; create addresses which use indexing. In some cases, this
2872 ;; is a lose because there isn't any store instructions which
2873 ;; allow indexed addresses (with integer register source).
2874 ;;
2875 ;; These define_splits try to turn a 3 insn store into
2876 ;; a 2 insn store with some creative RTL rewriting.
2877 (define_split
2878 [(set (mem:SI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2879 (match_operand:SI 1 "mem_shadd_operand" ""))
2880 (plus:SI (match_operand:SI 2 "register_operand" "")
2881 (match_operand:SI 3 "const_int_operand" ""))))
2882 (match_operand:SI 4 "register_operand" ""))
2883 (clobber (match_operand:SI 5 "register_operand" ""))]
2884 ""
2885 [(set (match_dup 5) (plus:SI (ashift:SI (match_dup 0) (match_dup 1))
2886 (match_dup 2)))
2887 (set (mem:SI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2888 "
2889 {
2890 operands[1] = GEN_INT (exact_log2 (INTVAL (operands[1])));
2891
2892 }")
2893
2894 (define_split
2895 [(set (mem:HI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2896 (match_operand:SI 1 "mem_shadd_operand" ""))
2897 (plus:SI (match_operand:SI 2 "register_operand" "")
2898 (match_operand:SI 3 "const_int_operand" ""))))
2899 (match_operand:HI 4 "register_operand" ""))
2900 (clobber (match_operand:SI 5 "register_operand" ""))]
2901 ""
2902 [(set (match_dup 5) (plus:SI (ashift:SI (match_dup 0) (match_dup 1))
2903 (match_dup 2)))
2904 (set (mem:HI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2905 "
2906 {
2907 operands[1] = GEN_INT (exact_log2 (INTVAL (operands[1])));
2908
2909 }")
2910
2911 (define_split
2912 [(set (mem:QI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2913 (match_operand:SI 1 "mem_shadd_operand" ""))
2914 (plus:SI (match_operand:SI 2 "register_operand" "")
2915 (match_operand:SI 3 "const_int_operand" ""))))
2916 (match_operand:QI 4 "register_operand" ""))
2917 (clobber (match_operand:SI 5 "register_operand" ""))]
2918 ""
2919 [(set (match_dup 5) (plus:SI (ashift:SI (match_dup 0) (match_dup 1))
2920 (match_dup 2)))
2921 (set (mem:QI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2922 "
2923 {
2924 operands[1] = GEN_INT (exact_log2 (INTVAL (operands[1])));
2925
2926 }")
2927
2928 (define_expand "movhi"
2929 [(set (match_operand:HI 0 "general_operand" "")
2930 (match_operand:HI 1 "general_operand" ""))]
2931 ""
2932 "
2933 {
2934 if (pa_emit_move_sequence (operands, HImode, 0))
2935 DONE;
2936 }")
2937
2938 ;; Handle HImode input reloads requiring a general register as a
2939 ;; scratch register.
2940 (define_expand "reload_inhi"
2941 [(set (match_operand:HI 0 "register_operand" "=Z")
2942 (match_operand:HI 1 "non_hard_reg_operand" ""))
2943 (clobber (match_operand:HI 2 "register_operand" "=&r"))]
2944 ""
2945 "
2946 {
2947 if (pa_emit_move_sequence (operands, HImode, operands[2]))
2948 DONE;
2949
2950 /* We don't want the clobber emitted, so handle this ourselves. */
2951 emit_insn (gen_rtx_SET (operands[0], operands[1]));
2952 DONE;
2953 }")
2954
2955 ;; Handle HImode output reloads requiring a general register as a
2956 ;; scratch register.
2957 (define_expand "reload_outhi"
2958 [(set (match_operand:HI 0 "non_hard_reg_operand" "")
2959 (match_operand:HI 1 "register_operand" "Z"))
2960 (clobber (match_operand:HI 2 "register_operand" "=&r"))]
2961 ""
2962 "
2963 {
2964 if (pa_emit_move_sequence (operands, HImode, operands[2]))
2965 DONE;
2966
2967 /* We don't want the clobber emitted, so handle this ourselves. */
2968 emit_insn (gen_rtx_SET (operands[0], operands[1]));
2969 DONE;
2970 }")
2971
2972 (define_insn ""
2973 [(set (match_operand:HI 0 "move_dest_operand"
2974 "=r,r,r,r,r,Q,!*q,!r")
2975 (match_operand:HI 1 "move_src_operand"
2976 "r,J,N,K,RQ,rM,!rM,!*q"))]
2977 "(register_operand (operands[0], HImode)
2978 || reg_or_0_operand (operands[1], HImode))"
2979 "@
2980 copy %1,%0
2981 ldi %1,%0
2982 ldil L'%1,%0
2983 {zdepi|depwi,z} %Z1,%0
2984 ldh%M1 %1,%0
2985 sth%M0 %r1,%0
2986 mtsar %r1
2987 {mfctl|mfctl,w} %sar,%0"
2988 [(set_attr "type" "move,move,move,shift,load,store,move,move")
2989 (set_attr "pa_combine_type" "addmove")
2990 (set_attr "length" "4,4,4,4,4,4,4,4")])
2991
2992 (define_insn ""
2993 [(set (match_operand:HI 0 "register_operand" "=r")
2994 (mem:HI (plus:SI (match_operand:SI 1 "register_operand" "+r")
2995 (match_operand:SI 2 "int5_operand" "L"))))
2996 (set (match_dup 1)
2997 (plus:SI (match_dup 1) (match_dup 2)))]
2998 ""
2999 "{ldhs|ldh},mb %2(%1),%0"
3000 [(set_attr "type" "load")
3001 (set_attr "length" "4")])
3002
3003 (define_insn ""
3004 [(set (match_operand:HI 0 "register_operand" "=r")
3005 (mem:HI (plus:DI (match_operand:DI 1 "register_operand" "+r")
3006 (match_operand:DI 2 "int5_operand" "L"))))
3007 (set (match_dup 1)
3008 (plus:DI (match_dup 1) (match_dup 2)))]
3009 "TARGET_64BIT"
3010 "ldh,mb %2(%1),%0"
3011 [(set_attr "type" "load")
3012 (set_attr "length" "4")])
3013
3014 ; And a zero extended variant.
3015 (define_insn ""
3016 [(set (match_operand:DI 0 "register_operand" "=r")
3017 (zero_extend:DI (mem:HI
3018 (plus:DI
3019 (match_operand:DI 1 "register_operand" "+r")
3020 (match_operand:DI 2 "int5_operand" "L")))))
3021 (set (match_dup 1)
3022 (plus:DI (match_dup 1) (match_dup 2)))]
3023 "TARGET_64BIT"
3024 "ldh,mb %2(%1),%0"
3025 [(set_attr "type" "load")
3026 (set_attr "length" "4")])
3027
3028 (define_insn ""
3029 [(set (match_operand:SI 0 "register_operand" "=r")
3030 (zero_extend:SI (mem:HI
3031 (plus:SI
3032 (match_operand:SI 1 "register_operand" "+r")
3033 (match_operand:SI 2 "int5_operand" "L")))))
3034 (set (match_dup 1)
3035 (plus:SI (match_dup 1) (match_dup 2)))]
3036 ""
3037 "{ldhs|ldh},mb %2(%1),%0"
3038 [(set_attr "type" "load")
3039 (set_attr "length" "4")])
3040
3041 (define_insn ""
3042 [(set (match_operand:SI 0 "register_operand" "=r")
3043 (zero_extend:SI (mem:HI
3044 (plus:DI
3045 (match_operand:DI 1 "register_operand" "+r")
3046 (match_operand:DI 2 "int5_operand" "L")))))
3047 (set (match_dup 1)
3048 (plus:DI (match_dup 1) (match_dup 2)))]
3049 "TARGET_64BIT"
3050 "ldh,mb %2(%1),%0"
3051 [(set_attr "type" "load")
3052 (set_attr "length" "4")])
3053
3054 (define_insn ""
3055 [(set (mem:HI (plus:SI (match_operand:SI 0 "register_operand" "+r")
3056 (match_operand:SI 1 "int5_operand" "L")))
3057 (match_operand:HI 2 "reg_or_0_operand" "rM"))
3058 (set (match_dup 0)
3059 (plus:SI (match_dup 0) (match_dup 1)))]
3060 ""
3061 "{sths|sth},mb %r2,%1(%0)"
3062 [(set_attr "type" "store")
3063 (set_attr "length" "4")])
3064
3065 (define_insn ""
3066 [(set (mem:HI (plus:DI (match_operand:DI 0 "register_operand" "+r")
3067 (match_operand:DI 1 "int5_operand" "L")))
3068 (match_operand:HI 2 "reg_or_0_operand" "rM"))
3069 (set (match_dup 0)
3070 (plus:DI (match_dup 0) (match_dup 1)))]
3071 "TARGET_64BIT"
3072 "sth,mb %r2,%1(%0)"
3073 [(set_attr "type" "store")
3074 (set_attr "length" "4")])
3075
3076 (define_insn "addhi3"
3077 [(set (match_operand:HI 0 "register_operand" "=r,r")
3078 (plus:HI (match_operand:HI 1 "register_operand" "%r,r")
3079 (match_operand:HI 2 "arith14_operand" "r,J")))]
3080 ""
3081 "@
3082 {addl|add,l} %1,%2,%0
3083 ldo %2(%1),%0"
3084 [(set_attr "type" "binary,binary")
3085 (set_attr "pa_combine_type" "addmove")
3086 (set_attr "length" "4,4")])
3087
3088 (define_expand "movqi"
3089 [(set (match_operand:QI 0 "general_operand" "")
3090 (match_operand:QI 1 "general_operand" ""))]
3091 ""
3092 "
3093 {
3094 if (pa_emit_move_sequence (operands, QImode, 0))
3095 DONE;
3096 }")
3097
3098 ;; Handle QImode input reloads requiring a general register as a
3099 ;; scratch register.
3100 (define_expand "reload_inqi"
3101 [(set (match_operand:QI 0 "register_operand" "=Z")
3102 (match_operand:QI 1 "non_hard_reg_operand" ""))
3103 (clobber (match_operand:QI 2 "register_operand" "=&r"))]
3104 ""
3105 "
3106 {
3107 if (pa_emit_move_sequence (operands, QImode, operands[2]))
3108 DONE;
3109
3110 /* We don't want the clobber emitted, so handle this ourselves. */
3111 emit_insn (gen_rtx_SET (operands[0], operands[1]));
3112 DONE;
3113 }")
3114
3115 ;; Handle QImode output reloads requiring a general register as a
3116 ;; scratch register.
3117 (define_expand "reload_outqi"
3118 [(set (match_operand:QI 0 "non_hard_reg_operand" "")
3119 (match_operand:QI 1 "register_operand" "Z"))
3120 (clobber (match_operand:QI 2 "register_operand" "=&r"))]
3121 ""
3122 "
3123 {
3124 if (pa_emit_move_sequence (operands, QImode, operands[2]))
3125 DONE;
3126
3127 /* We don't want the clobber emitted, so handle this ourselves. */
3128 emit_insn (gen_rtx_SET (operands[0], operands[1]));
3129 DONE;
3130 }")
3131
3132 (define_insn ""
3133 [(set (match_operand:QI 0 "move_dest_operand"
3134 "=r,r,r,r,r,Q,!*q,!r")
3135 (match_operand:QI 1 "move_src_operand"
3136 "r,J,N,K,RQ,rM,!rM,!*q"))]
3137 "(register_operand (operands[0], QImode)
3138 || reg_or_0_operand (operands[1], QImode))"
3139 "@
3140 copy %1,%0
3141 ldi %1,%0
3142 ldil L'%1,%0
3143 {zdepi|depwi,z} %Z1,%0
3144 ldb%M1 %1,%0
3145 stb%M0 %r1,%0
3146 mtsar %r1
3147 {mfctl|mfctl,w} %%sar,%0"
3148 [(set_attr "type" "move,move,move,shift,load,store,move,move")
3149 (set_attr "pa_combine_type" "addmove")
3150 (set_attr "length" "4,4,4,4,4,4,4,4")])
3151
3152 (define_insn ""
3153 [(set (match_operand:QI 0 "register_operand" "=r")
3154 (mem:QI (plus:SI (match_operand:SI 1 "register_operand" "+r")
3155 (match_operand:SI 2 "int5_operand" "L"))))
3156 (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
3157 ""
3158 "{ldbs|ldb},mb %2(%1),%0"
3159 [(set_attr "type" "load")
3160 (set_attr "length" "4")])
3161
3162 (define_insn ""
3163 [(set (match_operand:QI 0 "register_operand" "=r")
3164 (mem:QI (plus:DI (match_operand:DI 1 "register_operand" "+r")
3165 (match_operand:DI 2 "int5_operand" "L"))))
3166 (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3167 "TARGET_64BIT"
3168 "ldb,mb %2(%1),%0"
3169 [(set_attr "type" "load")
3170 (set_attr "length" "4")])
3171
3172 ; Now the same thing with zero extensions.
3173 (define_insn ""
3174 [(set (match_operand:DI 0 "register_operand" "=r")
3175 (zero_extend:DI (mem:QI (plus:DI
3176 (match_operand:DI 1 "register_operand" "+r")
3177 (match_operand:DI 2 "int5_operand" "L")))))
3178 (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3179 "TARGET_64BIT"
3180 "ldb,mb %2(%1),%0"
3181 [(set_attr "type" "load")
3182 (set_attr "length" "4")])
3183
3184 (define_insn ""
3185 [(set (match_operand:SI 0 "register_operand" "=r")
3186 (zero_extend:SI (mem:QI (plus:SI
3187 (match_operand:SI 1 "register_operand" "+r")
3188 (match_operand:SI 2 "int5_operand" "L")))))
3189 (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
3190 ""
3191 "{ldbs|ldb},mb %2(%1),%0"
3192 [(set_attr "type" "load")
3193 (set_attr "length" "4")])
3194
3195 (define_insn ""
3196 [(set (match_operand:SI 0 "register_operand" "=r")
3197 (zero_extend:SI (mem:QI (plus:DI
3198 (match_operand:DI 1 "register_operand" "+r")
3199 (match_operand:DI 2 "int5_operand" "L")))))
3200 (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3201 "TARGET_64BIT"
3202 "ldb,mb %2(%1),%0"
3203 [(set_attr "type" "load")
3204 (set_attr "length" "4")])
3205
3206 (define_insn ""
3207 [(set (match_operand:HI 0 "register_operand" "=r")
3208 (zero_extend:HI (mem:QI (plus:SI
3209 (match_operand:SI 1 "register_operand" "+r")
3210 (match_operand:SI 2 "int5_operand" "L")))))
3211 (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
3212 ""
3213 "{ldbs|ldb},mb %2(%1),%0"
3214 [(set_attr "type" "load")
3215 (set_attr "length" "4")])
3216
3217 (define_insn ""
3218 [(set (match_operand:HI 0 "register_operand" "=r")
3219 (zero_extend:HI (mem:QI (plus:DI
3220 (match_operand:DI 1 "register_operand" "+r")
3221 (match_operand:DI 2 "int5_operand" "L")))))
3222 (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3223 "TARGET_64BIT"
3224 "ldb,mb %2(%1),%0"
3225 [(set_attr "type" "load")
3226 (set_attr "length" "4")])
3227
3228 (define_insn ""
3229 [(set (mem:QI (plus:SI (match_operand:SI 0 "register_operand" "+r")
3230 (match_operand:SI 1 "int5_operand" "L")))
3231 (match_operand:QI 2 "reg_or_0_operand" "rM"))
3232 (set (match_dup 0)
3233 (plus:SI (match_dup 0) (match_dup 1)))]
3234 ""
3235 "{stbs|stb},mb %r2,%1(%0)"
3236 [(set_attr "type" "store")
3237 (set_attr "length" "4")])
3238
3239 (define_insn ""
3240 [(set (mem:QI (plus:DI (match_operand:DI 0 "register_operand" "+r")
3241 (match_operand:DI 1 "int5_operand" "L")))
3242 (match_operand:QI 2 "reg_or_0_operand" "rM"))
3243 (set (match_dup 0)
3244 (plus:DI (match_dup 0) (match_dup 1)))]
3245 "TARGET_64BIT"
3246 "stb,mb %r2,%1(%0)"
3247 [(set_attr "type" "store")
3248 (set_attr "length" "4")])
3249
3250 ;; The definition of this insn does not really explain what it does,
3251 ;; but it should suffice that anything generated as this insn will be
3252 ;; recognized as a cpymemsi operation, and that it will not successfully
3253 ;; combine with anything.
3254 (define_expand "cpymemsi"
3255 [(parallel [(set (match_operand:BLK 0 "" "")
3256 (match_operand:BLK 1 "" ""))
3257 (clobber (match_dup 4))
3258 (clobber (match_dup 5))
3259 (clobber (match_dup 6))
3260 (clobber (match_dup 7))
3261 (clobber (match_dup 8))
3262 (use (match_operand:SI 2 "arith14_operand" ""))
3263 (use (match_operand:SI 3 "const_int_operand" ""))])]
3264 "!TARGET_64BIT && optimize > 0"
3265 "
3266 {
3267 int size, align;
3268
3269 /* HP provides very fast block move library routine for the PA;
3270 this routine includes:
3271
3272 4x4 byte at a time block moves,
3273 1x4 byte at a time with alignment checked at runtime with
3274 attempts to align the source and destination as needed
3275 1x1 byte loop
3276
3277 With that in mind, here's the heuristics to try and guess when
3278 the inlined block move will be better than the library block
3279 move:
3280
3281 If the size isn't constant, then always use the library routines.
3282
3283 If the size is large in respect to the known alignment, then use
3284 the library routines.
3285
3286 If the size is small in respect to the known alignment, then open
3287 code the copy (since that will lead to better scheduling).
3288
3289 Else use the block move pattern. */
3290
3291 /* Undetermined size, use the library routine. */
3292 if (GET_CODE (operands[2]) != CONST_INT)
3293 FAIL;
3294
3295 size = INTVAL (operands[2]);
3296 align = INTVAL (operands[3]);
3297 align = align > 4 ? 4 : (align ? align : 1);
3298
3299 /* If size/alignment is large, then use the library routines. */
3300 if (size / align > 16)
3301 FAIL;
3302
3303 /* This does happen, but not often enough to worry much about. */
3304 if (size / align < MOVE_RATIO (optimize_insn_for_speed_p ()))
3305 FAIL;
3306
3307 /* Fall through means we're going to use our block move pattern. */
3308 operands[0]
3309 = replace_equiv_address (operands[0],
3310 copy_to_mode_reg (SImode, XEXP (operands[0], 0)));
3311 operands[1]
3312 = replace_equiv_address (operands[1],
3313 copy_to_mode_reg (SImode, XEXP (operands[1], 0)));
3314 operands[4] = gen_reg_rtx (SImode);
3315 operands[5] = gen_reg_rtx (SImode);
3316 operands[6] = gen_reg_rtx (SImode);
3317 operands[7] = gen_reg_rtx (SImode);
3318 operands[8] = gen_reg_rtx (SImode);
3319 }")
3320
3321 ;; The operand constraints are written like this to support both compile-time
3322 ;; and run-time determined byte counts. The expander and pa_output_block_move
3323 ;; only support compile-time determined counts at this time.
3324 ;;
3325 ;; If the count is run-time determined, the register with the byte count
3326 ;; is clobbered by the copying code, and therefore it is forced to operand 2.
3327 ;;
3328 ;; We used to clobber operands 0 and 1. However, a change to regrename.cc
3329 ;; broke this semantic for pseudo registers. We can't use match_scratch
3330 ;; as this requires two registers in the class R1_REGS when the MEMs for
3331 ;; operands 0 and 1 are both equivalent to symbolic MEMs. Thus, we are
3332 ;; forced to internally copy operands 0 and 1 to operands 7 and 8,
3333 ;; respectively. We then split or peephole optimize after reload.
3334 (define_insn "cpymemsi_prereload"
3335 [(set (mem:BLK (match_operand:SI 0 "register_operand" "r,r"))
3336 (mem:BLK (match_operand:SI 1 "register_operand" "r,r")))
3337 (clobber (match_operand:SI 2 "register_operand" "=&r,&r")) ;loop cnt/tmp
3338 (clobber (match_operand:SI 3 "register_operand" "=&r,&r")) ;item tmp1
3339 (clobber (match_operand:SI 6 "register_operand" "=&r,&r")) ;item tmp2
3340 (clobber (match_operand:SI 7 "register_operand" "=&r,&r")) ;item tmp3
3341 (clobber (match_operand:SI 8 "register_operand" "=&r,&r")) ;item tmp4
3342 (use (match_operand:SI 4 "arith14_operand" "J,2")) ;byte count
3343 (use (match_operand:SI 5 "const_int_operand" "n,n"))] ;alignment
3344 "!TARGET_64BIT"
3345 "#"
3346 [(set_attr "type" "multi,multi")])
3347
3348 (define_split
3349 [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3350 (match_operand:BLK 1 "memory_operand" ""))
3351 (clobber (match_operand:SI 2 "register_operand" ""))
3352 (clobber (match_operand:SI 3 "register_operand" ""))
3353 (clobber (match_operand:SI 6 "register_operand" ""))
3354 (clobber (match_operand:SI 7 "register_operand" ""))
3355 (clobber (match_operand:SI 8 "register_operand" ""))
3356 (use (match_operand:SI 4 "arith14_operand" ""))
3357 (use (match_operand:SI 5 "const_int_operand" ""))])]
3358 "!TARGET_64BIT && reload_completed && !flag_peephole2
3359 && GET_CODE (operands[0]) == MEM
3360 && register_operand (XEXP (operands[0], 0), SImode)
3361 && GET_CODE (operands[1]) == MEM
3362 && register_operand (XEXP (operands[1], 0), SImode)"
3363 [(set (match_dup 7) (match_dup 9))
3364 (set (match_dup 8) (match_dup 10))
3365 (parallel [(set (match_dup 0) (match_dup 1))
3366 (clobber (match_dup 2))
3367 (clobber (match_dup 3))
3368 (clobber (match_dup 6))
3369 (clobber (match_dup 7))
3370 (clobber (match_dup 8))
3371 (use (match_dup 4))
3372 (use (match_dup 5))
3373 (const_int 0)])]
3374 "
3375 {
3376 operands[9] = XEXP (operands[0], 0);
3377 operands[10] = XEXP (operands[1], 0);
3378 operands[0] = replace_equiv_address (operands[0], operands[7]);
3379 operands[1] = replace_equiv_address (operands[1], operands[8]);
3380 }")
3381
3382 (define_peephole2
3383 [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3384 (match_operand:BLK 1 "memory_operand" ""))
3385 (clobber (match_operand:SI 2 "register_operand" ""))
3386 (clobber (match_operand:SI 3 "register_operand" ""))
3387 (clobber (match_operand:SI 6 "register_operand" ""))
3388 (clobber (match_operand:SI 7 "register_operand" ""))
3389 (clobber (match_operand:SI 8 "register_operand" ""))
3390 (use (match_operand:SI 4 "arith14_operand" ""))
3391 (use (match_operand:SI 5 "const_int_operand" ""))])]
3392 "!TARGET_64BIT
3393 && GET_CODE (operands[0]) == MEM
3394 && register_operand (XEXP (operands[0], 0), SImode)
3395 && GET_CODE (operands[1]) == MEM
3396 && register_operand (XEXP (operands[1], 0), SImode)"
3397 [(parallel [(set (match_dup 0) (match_dup 1))
3398 (clobber (match_dup 2))
3399 (clobber (match_dup 3))
3400 (clobber (match_dup 6))
3401 (clobber (match_dup 7))
3402 (clobber (match_dup 8))
3403 (use (match_dup 4))
3404 (use (match_dup 5))
3405 (const_int 0)])]
3406 "
3407 {
3408 rtx addr = XEXP (operands[0], 0);
3409 if (dead_or_set_p (curr_insn, addr))
3410 operands[7] = addr;
3411 else
3412 {
3413 emit_insn (gen_rtx_SET (operands[7], addr));
3414 operands[0] = replace_equiv_address (operands[0], operands[7]);
3415 }
3416
3417 addr = XEXP (operands[1], 0);
3418 if (dead_or_set_p (curr_insn, addr))
3419 operands[8] = addr;
3420 else
3421 {
3422 emit_insn (gen_rtx_SET (operands[8], addr));
3423 operands[1] = replace_equiv_address (operands[1], operands[8]);
3424 }
3425 }")
3426
3427 (define_insn "cpymemsi_postreload"
3428 [(set (mem:BLK (match_operand:SI 0 "register_operand" "+r,r"))
3429 (mem:BLK (match_operand:SI 1 "register_operand" "+r,r")))
3430 (clobber (match_operand:SI 2 "register_operand" "=&r,&r")) ;loop cnt/tmp
3431 (clobber (match_operand:SI 3 "register_operand" "=&r,&r")) ;item tmp1
3432 (clobber (match_operand:SI 6 "register_operand" "=&r,&r")) ;item tmp2
3433 (clobber (match_dup 0))
3434 (clobber (match_dup 1))
3435 (use (match_operand:SI 4 "arith14_operand" "J,2")) ;byte count
3436 (use (match_operand:SI 5 "const_int_operand" "n,n")) ;alignment
3437 (const_int 0)]
3438 "!TARGET_64BIT && reload_completed"
3439 "* return pa_output_block_move (operands, !which_alternative);"
3440 [(set_attr "type" "multi,multi")])
3441
3442 (define_expand "cpymemdi"
3443 [(parallel [(set (match_operand:BLK 0 "" "")
3444 (match_operand:BLK 1 "" ""))
3445 (clobber (match_dup 4))
3446 (clobber (match_dup 5))
3447 (clobber (match_dup 6))
3448 (clobber (match_dup 7))
3449 (clobber (match_dup 8))
3450 (use (match_operand:DI 2 "arith14_operand" ""))
3451 (use (match_operand:DI 3 "const_int_operand" ""))])]
3452 "TARGET_64BIT && optimize > 0"
3453 "
3454 {
3455 int size, align;
3456
3457 /* HP provides very fast block move library routine for the PA;
3458 this routine includes:
3459
3460 4x4 byte at a time block moves,
3461 1x4 byte at a time with alignment checked at runtime with
3462 attempts to align the source and destination as needed
3463 1x1 byte loop
3464
3465 With that in mind, here's the heuristics to try and guess when
3466 the inlined block move will be better than the library block
3467 move:
3468
3469 If the size isn't constant, then always use the library routines.
3470
3471 If the size is large in respect to the known alignment, then use
3472 the library routines.
3473
3474 If the size is small in respect to the known alignment, then open
3475 code the copy (since that will lead to better scheduling).
3476
3477 Else use the block move pattern. */
3478
3479 /* Undetermined size, use the library routine. */
3480 if (GET_CODE (operands[2]) != CONST_INT)
3481 FAIL;
3482
3483 size = INTVAL (operands[2]);
3484 align = INTVAL (operands[3]);
3485 align = align > 8 ? 8 : (align ? align : 1);
3486
3487 /* If size/alignment is large, then use the library routines. */
3488 if (size / align > 16)
3489 FAIL;
3490
3491 /* This does happen, but not often enough to worry much about. */
3492 if (size / align < MOVE_RATIO (optimize_insn_for_speed_p ()))
3493 FAIL;
3494
3495 /* Fall through means we're going to use our block move pattern. */
3496 operands[0]
3497 = replace_equiv_address (operands[0],
3498 copy_to_mode_reg (DImode, XEXP (operands[0], 0)));
3499 operands[1]
3500 = replace_equiv_address (operands[1],
3501 copy_to_mode_reg (DImode, XEXP (operands[1], 0)));
3502 operands[4] = gen_reg_rtx (DImode);
3503 operands[5] = gen_reg_rtx (DImode);
3504 operands[6] = gen_reg_rtx (DImode);
3505 operands[7] = gen_reg_rtx (DImode);
3506 operands[8] = gen_reg_rtx (DImode);
3507 }")
3508
3509 ;; The operand constraints are written like this to support both compile-time
3510 ;; and run-time determined byte counts. The expander and pa_output_block_move
3511 ;; only support compile-time determined counts at this time.
3512 ;;
3513 ;; If the count is run-time determined, the register with the byte count
3514 ;; is clobbered by the copying code, and therefore it is forced to operand 2.
3515 ;;
3516 ;; We used to clobber operands 0 and 1. However, a change to regrename.cc
3517 ;; broke this semantic for pseudo registers. We can't use match_scratch
3518 ;; as this requires two registers in the class R1_REGS when the MEMs for
3519 ;; operands 0 and 1 are both equivalent to symbolic MEMs. Thus, we are
3520 ;; forced to internally copy operands 0 and 1 to operands 7 and 8,
3521 ;; respectively. We then split or peephole optimize after reload.
3522 (define_insn "cpymemdi_prereload"
3523 [(set (mem:BLK (match_operand:DI 0 "register_operand" "r,r"))
3524 (mem:BLK (match_operand:DI 1 "register_operand" "r,r")))
3525 (clobber (match_operand:DI 2 "register_operand" "=&r,&r")) ;loop cnt/tmp
3526 (clobber (match_operand:DI 3 "register_operand" "=&r,&r")) ;item tmp1
3527 (clobber (match_operand:DI 6 "register_operand" "=&r,&r")) ;item tmp2
3528 (clobber (match_operand:DI 7 "register_operand" "=&r,&r")) ;item tmp3
3529 (clobber (match_operand:DI 8 "register_operand" "=&r,&r")) ;item tmp4
3530 (use (match_operand:DI 4 "arith14_operand" "J,2")) ;byte count
3531 (use (match_operand:DI 5 "const_int_operand" "n,n"))] ;alignment
3532 "TARGET_64BIT"
3533 "#"
3534 [(set_attr "type" "multi,multi")])
3535
3536 (define_split
3537 [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3538 (match_operand:BLK 1 "memory_operand" ""))
3539 (clobber (match_operand:DI 2 "register_operand" ""))
3540 (clobber (match_operand:DI 3 "register_operand" ""))
3541 (clobber (match_operand:DI 6 "register_operand" ""))
3542 (clobber (match_operand:DI 7 "register_operand" ""))
3543 (clobber (match_operand:DI 8 "register_operand" ""))
3544 (use (match_operand:DI 4 "arith14_operand" ""))
3545 (use (match_operand:DI 5 "const_int_operand" ""))])]
3546 "TARGET_64BIT && reload_completed && !flag_peephole2
3547 && GET_CODE (operands[0]) == MEM
3548 && register_operand (XEXP (operands[0], 0), DImode)
3549 && GET_CODE (operands[1]) == MEM
3550 && register_operand (XEXP (operands[1], 0), DImode)"
3551 [(set (match_dup 7) (match_dup 9))
3552 (set (match_dup 8) (match_dup 10))
3553 (parallel [(set (match_dup 0) (match_dup 1))
3554 (clobber (match_dup 2))
3555 (clobber (match_dup 3))
3556 (clobber (match_dup 6))
3557 (clobber (match_dup 7))
3558 (clobber (match_dup 8))
3559 (use (match_dup 4))
3560 (use (match_dup 5))
3561 (const_int 0)])]
3562 "
3563 {
3564 operands[9] = XEXP (operands[0], 0);
3565 operands[10] = XEXP (operands[1], 0);
3566 operands[0] = replace_equiv_address (operands[0], operands[7]);
3567 operands[1] = replace_equiv_address (operands[1], operands[8]);
3568 }")
3569
3570 (define_peephole2
3571 [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3572 (match_operand:BLK 1 "memory_operand" ""))
3573 (clobber (match_operand:DI 2 "register_operand" ""))
3574 (clobber (match_operand:DI 3 "register_operand" ""))
3575 (clobber (match_operand:DI 6 "register_operand" ""))
3576 (clobber (match_operand:DI 7 "register_operand" ""))
3577 (clobber (match_operand:DI 8 "register_operand" ""))
3578 (use (match_operand:DI 4 "arith14_operand" ""))
3579 (use (match_operand:DI 5 "const_int_operand" ""))])]
3580 "TARGET_64BIT
3581 && GET_CODE (operands[0]) == MEM
3582 && register_operand (XEXP (operands[0], 0), DImode)
3583 && GET_CODE (operands[1]) == MEM
3584 && register_operand (XEXP (operands[1], 0), DImode)"
3585 [(parallel [(set (match_dup 0) (match_dup 1))
3586 (clobber (match_dup 2))
3587 (clobber (match_dup 3))
3588 (clobber (match_dup 6))
3589 (clobber (match_dup 7))
3590 (clobber (match_dup 8))
3591 (use (match_dup 4))
3592 (use (match_dup 5))
3593 (const_int 0)])]
3594 "
3595 {
3596 rtx addr = XEXP (operands[0], 0);
3597 if (dead_or_set_p (curr_insn, addr))
3598 operands[7] = addr;
3599 else
3600 {
3601 emit_insn (gen_rtx_SET (operands[7], addr));
3602 operands[0] = replace_equiv_address (operands[0], operands[7]);
3603 }
3604
3605 addr = XEXP (operands[1], 0);
3606 if (dead_or_set_p (curr_insn, addr))
3607 operands[8] = addr;
3608 else
3609 {
3610 emit_insn (gen_rtx_SET (operands[8], addr));
3611 operands[1] = replace_equiv_address (operands[1], operands[8]);
3612 }
3613 }")
3614
3615 (define_insn "cpymemdi_postreload"
3616 [(set (mem:BLK (match_operand:DI 0 "register_operand" "+r,r"))
3617 (mem:BLK (match_operand:DI 1 "register_operand" "+r,r")))
3618 (clobber (match_operand:DI 2 "register_operand" "=&r,&r")) ;loop cnt/tmp
3619 (clobber (match_operand:DI 3 "register_operand" "=&r,&r")) ;item tmp1
3620 (clobber (match_operand:DI 6 "register_operand" "=&r,&r")) ;item tmp2
3621 (clobber (match_dup 0))
3622 (clobber (match_dup 1))
3623 (use (match_operand:DI 4 "arith14_operand" "J,2")) ;byte count
3624 (use (match_operand:DI 5 "const_int_operand" "n,n")) ;alignment
3625 (const_int 0)]
3626 "TARGET_64BIT && reload_completed"
3627 "* return pa_output_block_move (operands, !which_alternative);"
3628 [(set_attr "type" "multi,multi")])
3629
3630 (define_expand "setmemsi"
3631 [(parallel [(set (match_operand:BLK 0 "" "")
3632 (match_operand 2 "const_int_operand" ""))
3633 (clobber (match_dup 4))
3634 (clobber (match_dup 5))
3635 (use (match_operand:SI 1 "arith14_operand" ""))
3636 (use (match_operand:SI 3 "const_int_operand" ""))])]
3637 "!TARGET_64BIT && optimize > 0"
3638 "
3639 {
3640 int size, align;
3641
3642 /* If value to set is not zero, use the library routine. */
3643 if (operands[2] != const0_rtx)
3644 FAIL;
3645
3646 /* Undetermined size, use the library routine. */
3647 if (GET_CODE (operands[1]) != CONST_INT)
3648 FAIL;
3649
3650 size = INTVAL (operands[1]);
3651 align = INTVAL (operands[3]);
3652 align = align > 4 ? 4 : align;
3653
3654 /* If size/alignment is large, then use the library routines. */
3655 if (size / align > 16)
3656 FAIL;
3657
3658 /* This does happen, but not often enough to worry much about. */
3659 if (size / align < MOVE_RATIO (optimize_insn_for_speed_p ()))
3660 FAIL;
3661
3662 /* Fall through means we're going to use our block clear pattern. */
3663 operands[0]
3664 = replace_equiv_address (operands[0],
3665 copy_to_mode_reg (SImode, XEXP (operands[0], 0)));
3666 operands[4] = gen_reg_rtx (SImode);
3667 operands[5] = gen_reg_rtx (SImode);
3668 }")
3669
3670 (define_insn "clrmemsi_prereload"
3671 [(set (mem:BLK (match_operand:SI 0 "register_operand" "r,r"))
3672 (const_int 0))
3673 (clobber (match_operand:SI 1 "register_operand" "=&r,&r")) ;loop cnt/tmp
3674 (clobber (match_operand:SI 4 "register_operand" "=&r,&r")) ;tmp1
3675 (use (match_operand:SI 2 "arith14_operand" "J,1")) ;byte count
3676 (use (match_operand:SI 3 "const_int_operand" "n,n"))] ;alignment
3677 "!TARGET_64BIT"
3678 "#"
3679 [(set_attr "type" "multi,multi")])
3680
3681 (define_split
3682 [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3683 (const_int 0))
3684 (clobber (match_operand:SI 1 "register_operand" ""))
3685 (clobber (match_operand:SI 4 "register_operand" ""))
3686 (use (match_operand:SI 2 "arith14_operand" ""))
3687 (use (match_operand:SI 3 "const_int_operand" ""))])]
3688 "!TARGET_64BIT && reload_completed && !flag_peephole2
3689 && GET_CODE (operands[0]) == MEM
3690 && register_operand (XEXP (operands[0], 0), SImode)"
3691 [(set (match_dup 4) (match_dup 5))
3692 (parallel [(set (match_dup 0) (const_int 0))
3693 (clobber (match_dup 1))
3694 (clobber (match_dup 4))
3695 (use (match_dup 2))
3696 (use (match_dup 3))
3697 (const_int 0)])]
3698 "
3699 {
3700 operands[5] = XEXP (operands[0], 0);
3701 operands[0] = replace_equiv_address (operands[0], operands[4]);
3702 }")
3703
3704 (define_peephole2
3705 [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3706 (const_int 0))
3707 (clobber (match_operand:SI 1 "register_operand" ""))
3708 (clobber (match_operand:SI 4 "register_operand" ""))
3709 (use (match_operand:SI 2 "arith14_operand" ""))
3710 (use (match_operand:SI 3 "const_int_operand" ""))])]
3711 "!TARGET_64BIT
3712 && GET_CODE (operands[0]) == MEM
3713 && register_operand (XEXP (operands[0], 0), SImode)"
3714 [(parallel [(set (match_dup 0) (const_int 0))
3715 (clobber (match_dup 1))
3716 (clobber (match_dup 4))
3717 (use (match_dup 2))
3718 (use (match_dup 3))
3719 (const_int 0)])]
3720 "
3721 {
3722 rtx addr = XEXP (operands[0], 0);
3723 if (dead_or_set_p (curr_insn, addr))
3724 operands[4] = addr;
3725 else
3726 {
3727 emit_insn (gen_rtx_SET (operands[4], addr));
3728 operands[0] = replace_equiv_address (operands[0], operands[4]);
3729 }
3730 }")
3731
3732 (define_insn "clrmemsi_postreload"
3733 [(set (mem:BLK (match_operand:SI 0 "register_operand" "+r,r"))
3734 (const_int 0))
3735 (clobber (match_operand:SI 1 "register_operand" "=&r,&r")) ;loop cnt/tmp
3736 (clobber (match_dup 0))
3737 (use (match_operand:SI 2 "arith14_operand" "J,1")) ;byte count
3738 (use (match_operand:SI 3 "const_int_operand" "n,n")) ;alignment
3739 (const_int 0)]
3740 "!TARGET_64BIT && reload_completed"
3741 "* return pa_output_block_clear (operands, !which_alternative);"
3742 [(set_attr "type" "multi,multi")])
3743
3744 (define_expand "setmemdi"
3745 [(parallel [(set (match_operand:BLK 0 "" "")
3746 (match_operand 2 "const_int_operand" ""))
3747 (clobber (match_dup 4))
3748 (clobber (match_dup 5))
3749 (use (match_operand:DI 1 "arith14_operand" ""))
3750 (use (match_operand:DI 3 "const_int_operand" ""))])]
3751 "TARGET_64BIT && optimize > 0"
3752 "
3753 {
3754 int size, align;
3755
3756 /* If value to set is not zero, use the library routine. */
3757 if (operands[2] != const0_rtx)
3758 FAIL;
3759
3760 /* Undetermined size, use the library routine. */
3761 if (GET_CODE (operands[1]) != CONST_INT)
3762 FAIL;
3763
3764 size = INTVAL (operands[1]);
3765 align = INTVAL (operands[3]);
3766 align = align > 8 ? 8 : align;
3767
3768 /* If size/alignment is large, then use the library routines. */
3769 if (size / align > 16)
3770 FAIL;
3771
3772 /* This does happen, but not often enough to worry much about. */
3773 if (size / align < MOVE_RATIO (optimize_insn_for_speed_p ()))
3774 FAIL;
3775
3776 /* Fall through means we're going to use our block clear pattern. */
3777 operands[0]
3778 = replace_equiv_address (operands[0],
3779 copy_to_mode_reg (DImode, XEXP (operands[0], 0)));
3780 operands[4] = gen_reg_rtx (DImode);
3781 operands[5] = gen_reg_rtx (DImode);
3782 }")
3783
3784 (define_insn "clrmemdi_prereload"
3785 [(set (mem:BLK (match_operand:DI 0 "register_operand" "r,r"))
3786 (const_int 0))
3787 (clobber (match_operand:DI 1 "register_operand" "=&r,&r")) ;loop cnt/tmp
3788 (clobber (match_operand:DI 4 "register_operand" "=&r,&r")) ;item tmp1
3789 (use (match_operand:DI 2 "arith14_operand" "J,1")) ;byte count
3790 (use (match_operand:DI 3 "const_int_operand" "n,n"))] ;alignment
3791 "TARGET_64BIT"
3792 "#"
3793 [(set_attr "type" "multi,multi")])
3794
3795 (define_split
3796 [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3797 (const_int 0))
3798 (clobber (match_operand:DI 1 "register_operand" ""))
3799 (clobber (match_operand:DI 4 "register_operand" ""))
3800 (use (match_operand:DI 2 "arith14_operand" ""))
3801 (use (match_operand:DI 3 "const_int_operand" ""))])]
3802 "TARGET_64BIT && reload_completed && !flag_peephole2
3803 && GET_CODE (operands[0]) == MEM
3804 && register_operand (XEXP (operands[0], 0), DImode)"
3805 [(set (match_dup 4) (match_dup 5))
3806 (parallel [(set (match_dup 0) (const_int 0))
3807 (clobber (match_dup 1))
3808 (clobber (match_dup 4))
3809 (use (match_dup 2))
3810 (use (match_dup 3))
3811 (const_int 0)])]
3812 "
3813 {
3814 operands[5] = XEXP (operands[0], 0);
3815 operands[0] = replace_equiv_address (operands[0], operands[4]);
3816 }")
3817
3818 (define_peephole2
3819 [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3820 (const_int 0))
3821 (clobber (match_operand:DI 1 "register_operand" ""))
3822 (clobber (match_operand:DI 4 "register_operand" ""))
3823 (use (match_operand:DI 2 "arith14_operand" ""))
3824 (use (match_operand:DI 3 "const_int_operand" ""))])]
3825 "TARGET_64BIT
3826 && GET_CODE (operands[0]) == MEM
3827 && register_operand (XEXP (operands[0], 0), DImode)"
3828 [(parallel [(set (match_dup 0) (const_int 0))
3829 (clobber (match_dup 1))
3830 (clobber (match_dup 4))
3831 (use (match_dup 2))
3832 (use (match_dup 3))
3833 (const_int 0)])]
3834 "
3835 {
3836 rtx addr = XEXP (operands[0], 0);
3837 if (dead_or_set_p (curr_insn, addr))
3838 operands[4] = addr;
3839 else
3840 {
3841 emit_insn (gen_rtx_SET (operands[4], addr));
3842 operands[0] = replace_equiv_address (operands[0], operands[4]);
3843 }
3844 }")
3845
3846 (define_insn "clrmemdi_postreload"
3847 [(set (mem:BLK (match_operand:DI 0 "register_operand" "+r,r"))
3848 (const_int 0))
3849 (clobber (match_operand:DI 1 "register_operand" "=&r,&r")) ;loop cnt/tmp
3850 (clobber (match_dup 0))
3851 (use (match_operand:DI 2 "arith14_operand" "J,1")) ;byte count
3852 (use (match_operand:DI 3 "const_int_operand" "n,n")) ;alignment
3853 (const_int 0)]
3854 "TARGET_64BIT && reload_completed"
3855 "* return pa_output_block_clear (operands, !which_alternative);"
3856 [(set_attr "type" "multi,multi")])
3857
3858 ;; Floating point move insns
3859
3860 (define_expand "movdf"
3861 [(set (match_operand:DF 0 "general_operand" "")
3862 (match_operand:DF 1 "general_operand" ""))]
3863 ""
3864 "
3865 {
3866 if (pa_emit_move_sequence (operands, DFmode, 0))
3867 DONE;
3868 }")
3869
3870 ;; Handle DFmode input reloads requiring %r1 as a scratch register.
3871 (define_expand "reload_indf_r1"
3872 [(set (match_operand:DF 0 "register_operand" "=Z")
3873 (match_operand:DF 1 "non_hard_reg_operand" ""))
3874 (clobber (match_operand:SI 2 "register_operand" "=&a"))]
3875 ""
3876 "
3877 {
3878 if (pa_emit_move_sequence (operands, DFmode, operands[2]))
3879 DONE;
3880
3881 /* We don't want the clobber emitted, so handle this ourselves. */
3882 emit_insn (gen_rtx_SET (operands[0], operands[1]));
3883 DONE;
3884 }")
3885
3886 ;; Handle DFmode input reloads requiring a general register as a
3887 ;; scratch register.
3888 (define_expand "reload_indf"
3889 [(set (match_operand:DF 0 "register_operand" "=Z")
3890 (match_operand:DF 1 "non_hard_reg_operand" ""))
3891 (clobber (match_operand:DF 2 "register_operand" "=&r"))]
3892 ""
3893 "
3894 {
3895 if (pa_emit_move_sequence (operands, DFmode, operands[2]))
3896 DONE;
3897
3898 /* We don't want the clobber emitted, so handle this ourselves. */
3899 emit_insn (gen_rtx_SET (operands[0], operands[1]));
3900 DONE;
3901 }")
3902
3903 ;; Handle DFmode output reloads requiring a general register as a
3904 ;; scratch register.
3905 (define_expand "reload_outdf"
3906 [(set (match_operand:DF 0 "non_hard_reg_operand" "")
3907 (match_operand:DF 1 "register_operand" "Z"))
3908 (clobber (match_operand:DF 2 "register_operand" "=&r"))]
3909 ""
3910 "
3911 {
3912 if (pa_emit_move_sequence (operands, DFmode, operands[2]))
3913 DONE;
3914
3915 /* We don't want the clobber emitted, so handle this ourselves. */
3916 emit_insn (gen_rtx_SET (operands[0], operands[1]));
3917 DONE;
3918 }")
3919
3920 (define_insn ""
3921 [(set (match_operand:DF 0 "move_dest_operand"
3922 "=f,*r,T,?o,?Q,f,*r,*r,?*r,?f")
3923 (match_operand:DF 1 "reg_or_0_or_mem_operand"
3924 "fG,*rG,f,*r,*r,RT,o,RQ,f,*r"))]
3925 "(register_operand (operands[0], DFmode)
3926 || reg_or_0_operand (operands[1], DFmode))
3927 && !(GET_CODE (operands[1]) == CONST_DOUBLE
3928 && GET_CODE (operands[0]) == MEM)
3929 && !TARGET_64BIT
3930 && !TARGET_SOFT_FLOAT"
3931 "*
3932 {
3933 if ((FP_REG_P (operands[0]) || FP_REG_P (operands[1])
3934 || operands[1] == CONST0_RTX (DFmode))
3935 && !(REG_P (operands[0]) && REG_P (operands[1])
3936 && FP_REG_P (operands[0]) ^ FP_REG_P (operands[1])))
3937 return pa_output_fp_move_double (operands);
3938 return pa_output_move_double (operands);
3939 }"
3940 [(set_attr "type" "fpalu,move,fpstore,store,store,fpload,load,load,fpstore_load,store_fpload")
3941 (set_attr "length" "4,8,4,8,16,4,8,16,12,12")])
3942
3943 (define_insn ""
3944 [(set (match_operand:DF 0 "indexed_memory_operand" "=R")
3945 (match_operand:DF 1 "reg_or_0_operand" "f"))]
3946 "!TARGET_SOFT_FLOAT
3947 && !TARGET_DISABLE_INDEXING
3948 && reload_completed"
3949 "fstd%F0 %1,%0"
3950 [(set_attr "type" "fpstore")
3951 (set_attr "pa_combine_type" "addmove")
3952 (set_attr "length" "4")])
3953
3954 (define_peephole2
3955 [(set (match_operand:SI 0 "register_operand" "")
3956 (plus:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
3957 (const_int 3))
3958 (match_operand:SI 2 "register_operand" "")))
3959 (set (mem:DF (match_dup 0))
3960 (match_operand:DF 3 "register_operand" ""))]
3961 "!TARGET_SOFT_FLOAT
3962 && !TARGET_DISABLE_INDEXING
3963 && REG_OK_FOR_BASE_P (operands[2])
3964 && FP_REGNO_P (REGNO (operands[3]))"
3965 [(set (mem:DF (plus:SI (mult:SI (match_dup 1) (const_int 8)) (match_dup 2)))
3966 (match_dup 3))
3967 (set (match_dup 0) (plus:SI (ashift:SI (match_dup 1) (const_int 3))
3968 (match_dup 2)))]
3969 "")
3970
3971 (define_peephole2
3972 [(set (match_operand:SI 0 "register_operand" "")
3973 (plus:SI (match_operand:SI 2 "register_operand" "")
3974 (ashift:SI (match_operand:SI 1 "register_operand" "")
3975 (const_int 3))))
3976 (set (mem:DF (match_dup 0))
3977 (match_operand:DF 3 "register_operand" ""))]
3978 "!TARGET_SOFT_FLOAT
3979 && !TARGET_DISABLE_INDEXING
3980 && REG_OK_FOR_BASE_P (operands[2])
3981 && FP_REGNO_P (REGNO (operands[3]))"
3982 [(set (mem:DF (plus:SI (mult:SI (match_dup 1) (const_int 8)) (match_dup 2)))
3983 (match_dup 3))
3984 (set (match_dup 0) (plus:SI (ashift:SI (match_dup 1) (const_int 3))
3985 (match_dup 2)))]
3986 "")
3987
3988 (define_peephole2
3989 [(set (match_operand:DI 0 "register_operand" "")
3990 (plus:DI (ashift:DI (match_operand:DI 1 "register_operand" "")
3991 (const_int 3))
3992 (match_operand:DI 2 "register_operand" "")))
3993 (set (mem:DF (match_dup 0))
3994 (match_operand:DF 3 "register_operand" ""))]
3995 "!TARGET_SOFT_FLOAT
3996 && !TARGET_DISABLE_INDEXING
3997 && TARGET_64BIT
3998 && REG_OK_FOR_BASE_P (operands[2])
3999 && FP_REGNO_P (REGNO (operands[3]))"
4000 [(set (mem:DF (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
4001 (match_dup 3))
4002 (set (match_dup 0) (plus:DI (ashift:DI (match_dup 1) (const_int 3))
4003 (match_dup 2)))]
4004 "")
4005
4006 (define_peephole2
4007 [(set (match_operand:DI 0 "register_operand" "")
4008 (plus:DI (match_operand:DI 2 "register_operand" "")
4009 (ashift:DI (match_operand:DI 1 "register_operand" "")
4010 (const_int 3))))
4011 (set (mem:DF (match_dup 0))
4012 (match_operand:DF 3 "register_operand" ""))]
4013 "!TARGET_SOFT_FLOAT
4014 && !TARGET_DISABLE_INDEXING
4015 && TARGET_64BIT
4016 && REG_OK_FOR_BASE_P (operands[2])
4017 && FP_REGNO_P (REGNO (operands[3]))"
4018 [(set (mem:DF (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
4019 (match_dup 3))
4020 (set (match_dup 0) (plus:DI (ashift:DI (match_dup 1) (const_int 3))
4021 (match_dup 2)))]
4022 "")
4023
4024 (define_peephole2
4025 [(set (match_operand:SI 0 "register_operand" "")
4026 (plus:SI (match_operand:SI 1 "register_operand" "")
4027 (match_operand:SI 2 "register_operand" "")))
4028 (set (mem:DF (match_dup 0))
4029 (match_operand:DF 3 "register_operand" ""))]
4030 "!TARGET_SOFT_FLOAT
4031 && !TARGET_DISABLE_INDEXING
4032 && TARGET_NO_SPACE_REGS
4033 && REG_OK_FOR_INDEX_P (operands[1])
4034 && REG_OK_FOR_BASE_P (operands[2])
4035 && FP_REGNO_P (REGNO (operands[3]))"
4036 [(set (mem:DF (plus:SI (match_dup 1) (match_dup 2)))
4037 (match_dup 3))
4038 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
4039 "")
4040
4041 (define_peephole2
4042 [(set (match_operand:SI 0 "register_operand" "")
4043 (plus:SI (match_operand:SI 1 "register_operand" "")
4044 (match_operand:SI 2 "register_operand" "")))
4045 (set (mem:DF (match_dup 0))
4046 (match_operand:DF 3 "register_operand" ""))]
4047 "!TARGET_SOFT_FLOAT
4048 && !TARGET_DISABLE_INDEXING
4049 && TARGET_NO_SPACE_REGS
4050 && REG_OK_FOR_BASE_P (operands[1])
4051 && REG_OK_FOR_INDEX_P (operands[2])
4052 && FP_REGNO_P (REGNO (operands[3]))"
4053 [(set (mem:DF (plus:SI (match_dup 2) (match_dup 1)))
4054 (match_dup 3))
4055 (set (match_dup 0) (plus:SI (match_dup 2) (match_dup 1)))]
4056 "")
4057
4058 (define_peephole2
4059 [(set (match_operand:DI 0 "register_operand" "")
4060 (plus:DI (match_operand:DI 1 "register_operand" "")
4061 (match_operand:DI 2 "register_operand" "")))
4062 (set (mem:DF (match_dup 0))
4063 (match_operand:DF 3 "register_operand" ""))]
4064 "!TARGET_SOFT_FLOAT
4065 && !TARGET_DISABLE_INDEXING
4066 && TARGET_64BIT
4067 && TARGET_NO_SPACE_REGS
4068 && REG_OK_FOR_INDEX_P (operands[1])
4069 && REG_OK_FOR_BASE_P (operands[2])
4070 && FP_REGNO_P (REGNO (operands[3]))"
4071 [(set (mem:DF (plus:DI (match_dup 1) (match_dup 2)))
4072 (match_dup 3))
4073 (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
4074 "")
4075
4076 (define_peephole2
4077 [(set (match_operand:DI 0 "register_operand" "")
4078 (plus:DI (match_operand:DI 1 "register_operand" "")
4079 (match_operand:DI 2 "register_operand" "")))
4080 (set (mem:DF (match_dup 0))
4081 (match_operand:DF 3 "register_operand" ""))]
4082 "!TARGET_SOFT_FLOAT
4083 && !TARGET_DISABLE_INDEXING
4084 && TARGET_64BIT
4085 && TARGET_NO_SPACE_REGS
4086 && REG_OK_FOR_BASE_P (operands[1])
4087 && REG_OK_FOR_INDEX_P (operands[2])
4088 && FP_REGNO_P (REGNO (operands[3]))"
4089 [(set (mem:DF (plus:DI (match_dup 2) (match_dup 1)))
4090 (match_dup 3))
4091 (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
4092 "")
4093
4094 (define_insn ""
4095 [(set (match_operand:DF 0 "move_dest_operand"
4096 "=r,?o,?Q,r,r")
4097 (match_operand:DF 1 "reg_or_0_or_mem_operand"
4098 "rG,r,r,o,RQ"))]
4099 "(register_operand (operands[0], DFmode)
4100 || reg_or_0_operand (operands[1], DFmode))
4101 && !TARGET_64BIT
4102 && TARGET_SOFT_FLOAT"
4103 "*
4104 {
4105 return pa_output_move_double (operands);
4106 }"
4107 [(set_attr "type" "move,store,store,load,load")
4108 (set_attr "length" "8,8,16,8,16")])
4109
4110 (define_insn ""
4111 [(set (match_operand:DF 0 "move_dest_operand"
4112 "=!*r,*r,*r,*r,*r,Q,f,f,T,?*r,?f")
4113 (match_operand:DF 1 "move_src_operand"
4114 "!*rG,J,N,K,RQ,*rG,fG,RT,f,f,*r"))]
4115 "(register_operand (operands[0], DFmode)
4116 || reg_or_0_operand (operands[1], DFmode))
4117 && !TARGET_SOFT_FLOAT && TARGET_64BIT"
4118 "@
4119 copy %r1,%0
4120 ldi %1,%0
4121 ldil L'%1,%0
4122 depdi,z %z1,%0
4123 ldd%M1 %1,%0
4124 std%M0 %r1,%0
4125 fcpy,dbl %f1,%0
4126 fldd%F1 %1,%0
4127 fstd%F0 %1,%0
4128 fstd %1,-40(%%sp)\n\tldd -40(%%sp),%0
4129 std %1,-40(%%sp)\n\tfldd -40(%%sp),%0"
4130 [(set_attr "type" "move,move,move,shift,load,store,fpalu,fpload,fpstore,fpstore_load,store_fpload")
4131 (set_attr "pa_combine_type" "addmove")
4132 (set_attr "length" "4,4,4,4,4,4,4,4,4,8,8")])
4133
4134 (define_insn ""
4135 [(set (match_operand:DF 0 "move_dest_operand"
4136 "=!*r,*r,*r,*r,*r,Q")
4137 (match_operand:DF 1 "move_src_operand"
4138 "!*rG,J,N,K,RQ,*rG"))]
4139 "(register_operand (operands[0], DFmode)
4140 || reg_or_0_operand (operands[1], DFmode))
4141 && TARGET_SOFT_FLOAT && TARGET_64BIT"
4142 "@
4143 copy %r1,%0
4144 ldi %1,%0
4145 ldil L'%1,%0
4146 depdi,z %z1,%0
4147 ldd%M1 %1,%0
4148 std%M0 %r1,%0"
4149 [(set_attr "type" "move,move,move,shift,load,store")
4150 (set_attr "pa_combine_type" "addmove")
4151 (set_attr "length" "4,4,4,4,4,4")])
4152
4153
4154 (define_expand "movdi"
4155 [(set (match_operand:DI 0 "general_operand" "")
4156 (match_operand:DI 1 "general_operand" ""))]
4157 ""
4158 "
4159 {
4160 if (pa_emit_move_sequence (operands, DImode, 0))
4161 DONE;
4162 }")
4163
4164 ;; Handle DImode input reloads requiring %r1 as a scratch register.
4165 (define_expand "reload_indi_r1"
4166 [(set (match_operand:DI 0 "register_operand" "=Z")
4167 (match_operand:DI 1 "non_hard_reg_operand" ""))
4168 (clobber (match_operand:SI 2 "register_operand" "=&a"))]
4169 ""
4170 "
4171 {
4172 if (pa_emit_move_sequence (operands, DImode, operands[2]))
4173 DONE;
4174
4175 /* We don't want the clobber emitted, so handle this ourselves. */
4176 emit_insn (gen_rtx_SET (operands[0], operands[1]));
4177 DONE;
4178 }")
4179
4180 ;; Handle DImode input reloads requiring a general register as a
4181 ;; scratch register.
4182 (define_expand "reload_indi"
4183 [(set (match_operand:DI 0 "register_operand" "=Z")
4184 (match_operand:DI 1 "non_hard_reg_operand" ""))
4185 (clobber (match_operand:SI 2 "register_operand" "=&r"))]
4186 ""
4187 "
4188 {
4189 if (pa_emit_move_sequence (operands, DImode, operands[2]))
4190 DONE;
4191
4192 /* We don't want the clobber emitted, so handle this ourselves. */
4193 emit_insn (gen_rtx_SET (operands[0], operands[1]));
4194 DONE;
4195 }")
4196
4197 ;; Handle DImode output reloads requiring a general register as a
4198 ;; scratch register.
4199 (define_expand "reload_outdi"
4200 [(set (match_operand:DI 0 "non_hard_reg_operand" "")
4201 (match_operand:DI 1 "register_operand" "Z"))
4202 (clobber (match_operand:SI 2 "register_operand" "=&r"))]
4203 ""
4204 "
4205 {
4206 if (pa_emit_move_sequence (operands, DImode, operands[2]))
4207 DONE;
4208
4209 /* We don't want the clobber emitted, so handle this ourselves. */
4210 emit_insn (gen_rtx_SET (operands[0], operands[1]));
4211 DONE;
4212 }")
4213
4214 (define_insn ""
4215 [(set (match_operand:DI 0 "register_operand" "=r")
4216 (high:DI (match_operand 1 "" "")))]
4217 "!TARGET_64BIT"
4218 "*
4219 {
4220 rtx op0 = operands[0];
4221 rtx op1 = operands[1];
4222
4223 switch (GET_CODE (op1))
4224 {
4225 case CONST_INT:
4226 #if HOST_BITS_PER_WIDE_INT <= 32
4227 operands[0] = operand_subword (op0, 1, 0, DImode);
4228 output_asm_insn (\"ldil L'%1,%0\", operands);
4229
4230 operands[0] = operand_subword (op0, 0, 0, DImode);
4231 if (INTVAL (op1) < 0)
4232 output_asm_insn (\"ldi -1,%0\", operands);
4233 else
4234 output_asm_insn (\"ldi 0,%0\", operands);
4235 #else
4236 operands[0] = operand_subword (op0, 1, 0, DImode);
4237 operands[1] = GEN_INT (INTVAL (op1) & 0xffffffff);
4238 output_asm_insn (\"ldil L'%1,%0\", operands);
4239
4240 operands[0] = operand_subword (op0, 0, 0, DImode);
4241 operands[1] = GEN_INT (INTVAL (op1) >> 32);
4242 output_asm_insn (pa_singlemove_string (operands), operands);
4243 #endif
4244 break;
4245
4246 case CONST_DOUBLE:
4247 operands[0] = operand_subword (op0, 1, 0, DImode);
4248 operands[1] = GEN_INT (CONST_DOUBLE_LOW (op1));
4249 output_asm_insn (\"ldil L'%1,%0\", operands);
4250
4251 operands[0] = operand_subword (op0, 0, 0, DImode);
4252 operands[1] = GEN_INT (CONST_DOUBLE_HIGH (op1));
4253 output_asm_insn (pa_singlemove_string (operands), operands);
4254 break;
4255
4256 default:
4257 gcc_unreachable ();
4258 }
4259 return \"\";
4260 }"
4261 [(set_attr "type" "move")
4262 (set_attr "length" "12")])
4263
4264 (define_insn ""
4265 [(set (match_operand:DI 0 "move_dest_operand"
4266 "=r,o,Q,r,r,r,*f,*f,T,?r,?*f")
4267 (match_operand:DI 1 "move_src_operand"
4268 "rM,r,r,o*R,Q,i,*fM,RT,*f,*f,r"))]
4269 "(register_operand (operands[0], DImode)
4270 || reg_or_0_operand (operands[1], DImode))
4271 && !TARGET_64BIT
4272 && !TARGET_SOFT_FLOAT"
4273 "*
4274 {
4275 if ((FP_REG_P (operands[0]) || FP_REG_P (operands[1])
4276 || operands[1] == CONST0_RTX (DFmode))
4277 && !(REG_P (operands[0]) && REG_P (operands[1])
4278 && FP_REG_P (operands[0]) ^ FP_REG_P (operands[1])))
4279 return pa_output_fp_move_double (operands);
4280 return pa_output_move_double (operands);
4281 }"
4282 [(set_attr "type"
4283 "move,store,store,load,load,multi,fpalu,fpload,fpstore,fpstore_load,store_fpload")
4284 (set_attr "length" "8,8,16,8,16,16,4,4,4,12,12")])
4285
4286 (define_insn ""
4287 [(set (match_operand:DI 0 "move_dest_operand"
4288 "=r,r,r,r,r,r,Q,!*q,!r,!*f,*f,T,?r,?*f")
4289 (match_operand:DI 1 "move_src_operand"
4290 "A,r,J,N,K,RQ,rM,!rM,!*q,!*fM,RT,*f,*f,r"))]
4291 "(register_operand (operands[0], DImode)
4292 || reg_or_0_operand (operands[1], DImode))
4293 && !TARGET_SOFT_FLOAT && TARGET_64BIT"
4294 "@
4295 ldd RT'%A1,%0
4296 copy %1,%0
4297 ldi %1,%0
4298 ldil L'%1,%0
4299 depdi,z %z1,%0
4300 ldd%M1 %1,%0
4301 std%M0 %r1,%0
4302 mtsar %r1
4303 {mfctl|mfctl,w} %%sar,%0
4304 fcpy,dbl %f1,%0
4305 fldd%F1 %1,%0
4306 fstd%F0 %1,%0
4307 fstd %1,-40(%%sp)\n\tldd -40(%%sp),%0
4308 std %1,-40(%%sp)\n\tfldd -40(%%sp),%0"
4309 [(set_attr "type" "load,move,move,move,shift,load,store,move,move,fpalu,fpload,fpstore,fpstore_load,store_fpload")
4310 (set_attr "pa_combine_type" "addmove")
4311 (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4,8,8")])
4312
4313 (define_insn ""
4314 [(set (match_operand:DI 0 "move_dest_operand"
4315 "=r,r,r,r,r,r,Q,!*q,!r")
4316 (match_operand:DI 1 "move_src_operand"
4317 "A,r,J,N,K,RQ,rM,!rM,!*q"))]
4318 "(register_operand (operands[0], DImode)
4319 || reg_or_0_operand (operands[1], DImode))
4320 && TARGET_SOFT_FLOAT && TARGET_64BIT"
4321 "@
4322 ldd RT'%A1,%0
4323 copy %1,%0
4324 ldi %1,%0
4325 ldil L'%1,%0
4326 depdi,z %z1,%0
4327 ldd%M1 %1,%0
4328 std%M0 %r1,%0
4329 mtsar %r1
4330 {mfctl|mfctl,w} %%sar,%0"
4331 [(set_attr "type" "load,move,move,move,shift,load,store,move,move")
4332 (set_attr "pa_combine_type" "addmove")
4333 (set_attr "length" "4,4,4,4,4,4,4,4,4")])
4334
4335 (define_insn ""
4336 [(set (match_operand:DI 0 "indexed_memory_operand" "=R")
4337 (match_operand:DI 1 "register_operand" "f"))]
4338 "!TARGET_SOFT_FLOAT
4339 && TARGET_64BIT
4340 && !TARGET_DISABLE_INDEXING
4341 && reload_completed"
4342 "fstd%F0 %1,%0"
4343 [(set_attr "type" "fpstore")
4344 (set_attr "pa_combine_type" "addmove")
4345 (set_attr "length" "4")])
4346
4347 (define_peephole2
4348 [(set (match_operand:DI 0 "register_operand" "")
4349 (plus:DI (ashift:DI (match_operand:DI 1 "register_operand" "")
4350 (const_int 3))
4351 (match_operand:DI 2 "register_operand" "")))
4352 (set (mem:DI (match_dup 0))
4353 (match_operand:DI 3 "register_operand" ""))]
4354 "!TARGET_SOFT_FLOAT
4355 && !TARGET_DISABLE_INDEXING
4356 && TARGET_64BIT
4357 && REG_OK_FOR_BASE_P (operands[2])
4358 && FP_REGNO_P (REGNO (operands[3]))"
4359 [(set (mem:DI (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
4360 (match_dup 3))
4361 (set (match_dup 0) (plus:DI (ashift:DI (match_dup 1) (const_int 3))
4362 (match_dup 2)))]
4363 "")
4364
4365 (define_peephole2
4366 [(set (match_operand:DI 0 "register_operand" "")
4367 (plus:DI (match_operand:DI 1 "register_operand" "")
4368 (match_operand:DI 2 "register_operand" "")))
4369 (set (mem:DI (match_dup 0))
4370 (match_operand:DI 3 "register_operand" ""))]
4371 "!TARGET_SOFT_FLOAT
4372 && !TARGET_DISABLE_INDEXING
4373 && TARGET_64BIT
4374 && TARGET_NO_SPACE_REGS
4375 && REG_OK_FOR_INDEX_P (operands[1])
4376 && REG_OK_FOR_BASE_P (operands[2])
4377 && FP_REGNO_P (REGNO (operands[3]))"
4378 [(set (mem:DI (plus:DI (match_dup 1) (match_dup 2)))
4379 (match_dup 3))
4380 (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
4381 "")
4382
4383 (define_peephole2
4384 [(set (match_operand:DI 0 "register_operand" "")
4385 (plus:DI (match_operand:DI 1 "register_operand" "")
4386 (match_operand:DI 2 "register_operand" "")))
4387 (set (mem:DI (match_dup 0))
4388 (match_operand:DI 3 "register_operand" ""))]
4389 "!TARGET_SOFT_FLOAT
4390 && !TARGET_DISABLE_INDEXING
4391 && TARGET_64BIT
4392 && TARGET_NO_SPACE_REGS
4393 && REG_OK_FOR_BASE_P (operands[1])
4394 && REG_OK_FOR_INDEX_P (operands[2])
4395 && FP_REGNO_P (REGNO (operands[3]))"
4396 [(set (mem:DI (plus:DI (match_dup 2) (match_dup 1)))
4397 (match_dup 3))
4398 (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
4399 "")
4400
4401 (define_insn ""
4402 [(set (match_operand:DI 0 "move_dest_operand"
4403 "=r,o,Q,r,r,r")
4404 (match_operand:DI 1 "general_operand"
4405 "rM,r,r,o,Q,i"))]
4406 "(register_operand (operands[0], DImode)
4407 || reg_or_0_operand (operands[1], DImode))
4408 && !TARGET_64BIT
4409 && TARGET_SOFT_FLOAT"
4410 "*
4411 {
4412 return pa_output_move_double (operands);
4413 }"
4414 [(set_attr "type" "move,store,store,load,load,multi")
4415 (set_attr "length" "8,8,16,8,16,16")])
4416
4417 (define_insn ""
4418 [(set (match_operand:DI 0 "register_operand" "=r,&r")
4419 (lo_sum:DI (match_operand:DI 1 "register_operand" "0,r")
4420 (match_operand:DI 2 "immediate_operand" "i,i")))]
4421 "!TARGET_64BIT"
4422 "*
4423 {
4424 /* Don't output a 64-bit constant, since we can't trust the assembler to
4425 handle it correctly. */
4426 if (GET_CODE (operands[2]) == CONST_DOUBLE)
4427 operands[2] = GEN_INT (CONST_DOUBLE_LOW (operands[2]));
4428 else if (HOST_BITS_PER_WIDE_INT > 32
4429 && GET_CODE (operands[2]) == CONST_INT)
4430 operands[2] = GEN_INT (INTVAL (operands[2]) & 0xffffffff);
4431 if (which_alternative == 1)
4432 output_asm_insn (\"copy %1,%0\", operands);
4433 return \"ldo R'%G2(%R1),%R0\";
4434 }"
4435 [(set_attr "type" "move,move")
4436 (set_attr "length" "4,8")])
4437
4438 (define_expand "movsf"
4439 [(set (match_operand:SF 0 "general_operand" "")
4440 (match_operand:SF 1 "general_operand" ""))]
4441 ""
4442 "
4443 {
4444 if (pa_emit_move_sequence (operands, SFmode, 0))
4445 DONE;
4446 }")
4447
4448 ;; Handle SFmode input reloads requiring %r1 as a scratch register.
4449 (define_expand "reload_insf_r1"
4450 [(set (match_operand:SF 0 "register_operand" "=Z")
4451 (match_operand:SF 1 "non_hard_reg_operand" ""))
4452 (clobber (match_operand:SI 2 "register_operand" "=&a"))]
4453 ""
4454 "
4455 {
4456 if (pa_emit_move_sequence (operands, SFmode, operands[2]))
4457 DONE;
4458
4459 /* We don't want the clobber emitted, so handle this ourselves. */
4460 emit_insn (gen_rtx_SET (operands[0], operands[1]));
4461 DONE;
4462 }")
4463
4464 ;; Handle SFmode input reloads requiring a general register as a
4465 ;; scratch register.
4466 (define_expand "reload_insf"
4467 [(set (match_operand:SF 0 "register_operand" "=Z")
4468 (match_operand:SF 1 "non_hard_reg_operand" ""))
4469 (clobber (match_operand:SF 2 "register_operand" "=&r"))]
4470 ""
4471 "
4472 {
4473 if (pa_emit_move_sequence (operands, SFmode, operands[2]))
4474 DONE;
4475
4476 /* We don't want the clobber emitted, so handle this ourselves. */
4477 emit_insn (gen_rtx_SET (operands[0], operands[1]));
4478 DONE;
4479 }")
4480
4481 ;; Handle SFmode output reloads requiring a general register as a
4482 ;; scratch register.
4483 (define_expand "reload_outsf"
4484 [(set (match_operand:SF 0 "non_hard_reg_operand" "")
4485 (match_operand:SF 1 "register_operand" "Z"))
4486 (clobber (match_operand:SF 2 "register_operand" "=&r"))]
4487 ""
4488 "
4489 {
4490 if (pa_emit_move_sequence (operands, SFmode, operands[2]))
4491 DONE;
4492
4493 /* We don't want the clobber emitted, so handle this ourselves. */
4494 emit_insn (gen_rtx_SET (operands[0], operands[1]));
4495 DONE;
4496 }")
4497
4498 (define_insn ""
4499 [(set (match_operand:SF 0 "move_dest_operand"
4500 "=f,!*r,f,*r,T,Q,?*r,?f")
4501 (match_operand:SF 1 "reg_or_0_or_mem_operand"
4502 "fG,!*rG,RT,RQ,f,*rG,f,*r"))]
4503 "(register_operand (operands[0], SFmode)
4504 || reg_or_0_operand (operands[1], SFmode))
4505 && !TARGET_SOFT_FLOAT
4506 && !TARGET_64BIT"
4507 "@
4508 fcpy,sgl %f1,%0
4509 copy %r1,%0
4510 fldw%F1 %1,%0
4511 ldw%M1 %1,%0
4512 fstw%F0 %1,%0
4513 stw%M0 %r1,%0
4514 {fstws|fstw} %1,-16(%%sp)\n\t{ldws|ldw} -16(%%sp),%0
4515 {stws|stw} %1,-16(%%sp)\n\t{fldws|fldw} -16(%%sp),%0"
4516 [(set_attr "type" "fpalu,move,fpload,load,fpstore,store,fpstore_load,store_fpload")
4517 (set_attr "pa_combine_type" "addmove")
4518 (set_attr "length" "4,4,4,4,4,4,8,8")])
4519
4520 (define_insn ""
4521 [(set (match_operand:SF 0 "move_dest_operand"
4522 "=f,!*r,f,*r,T,Q,?*r,?f")
4523 (match_operand:SF 1 "reg_or_0_or_mem_operand"
4524 "fG,!*rG,RT,RQ,f,*rG,f,*r"))]
4525 "(register_operand (operands[0], SFmode)
4526 || reg_or_0_operand (operands[1], SFmode))
4527 && !TARGET_SOFT_FLOAT
4528 && TARGET_64BIT"
4529 "@
4530 fcpy,sgl %f1,%0
4531 copy %r1,%0
4532 fldw%F1 %1,%0
4533 ldw%M1 %1,%0
4534 fstw%F0 %1,%0
4535 stw%M0 %r1,%0
4536 fstw %1,-40(%%sp)\n\tldw -40(%%sp),%0
4537 stw %1,-40(%%sp)\n\tfldw -40(%%sp),%0"
4538 [(set_attr "type" "fpalu,move,fpload,load,fpstore,store,fpstore_load,store_fpload")
4539 (set_attr "pa_combine_type" "addmove")
4540 (set_attr "length" "4,4,4,4,4,4,8,8")])
4541
4542 (define_insn ""
4543 [(set (match_operand:SF 0 "move_dest_operand"
4544 "=!*r,*r,Q")
4545 (match_operand:SF 1 "reg_or_0_or_mem_operand"
4546 "!*rG,RQ,*rG"))]
4547 "(register_operand (operands[0], SFmode)
4548 || reg_or_0_operand (operands[1], SFmode))
4549 && TARGET_SOFT_FLOAT
4550 && TARGET_64BIT"
4551 "@
4552 copy %r1,%0
4553 ldw%M1 %1,%0
4554 stw%M0 %r1,%0"
4555 [(set_attr "type" "move,load,store")
4556 (set_attr "pa_combine_type" "addmove")
4557 (set_attr "length" "4,4,4")])
4558
4559 (define_insn ""
4560 [(set (match_operand:SF 0 "indexed_memory_operand" "=R")
4561 (match_operand:SF 1 "register_operand" "f"))]
4562 "!TARGET_SOFT_FLOAT
4563 && !TARGET_DISABLE_INDEXING
4564 && reload_completed"
4565 "fstw%F0 %1,%0"
4566 [(set_attr "type" "fpstore")
4567 (set_attr "pa_combine_type" "addmove")
4568 (set_attr "length" "4")])
4569
4570 (define_peephole2
4571 [(set (match_operand:SI 0 "register_operand" "")
4572 (plus:SI (match_operand:SI 1 "register_operand" "")
4573 (match_operand:SI 2 "const_int_operand" "")))
4574 (set (mem:SF (match_dup 0))
4575 (match_operand:SF 3 "register_operand" ""))]
4576 "!TARGET_64BIT
4577 && !INT14_OK_STRICT
4578 && GENERAL_REGNO_P (REGNO (operands[0]))
4579 && GENERAL_REGNO_P (REGNO (operands[3]))
4580 && REGNO (operands[0]) != REGNO (operands[3])
4581 && base14_operand (operands[2], E_SImode)"
4582 [(set (mem:SF (plus:SI (match_dup 1) (match_dup 2))) (match_dup 3))
4583 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
4584 "")
4585
4586 (define_peephole2
4587 [(set (match_operand:SI 0 "register_operand" "")
4588 (plus:SI (match_operand:SI 1 "register_operand" "")
4589 (match_operand:SI 2 "const_int_operand" "")))
4590 (set (match_operand:SF 3 "register_operand" "")
4591 (mem:SF (match_dup 0)))]
4592 "!TARGET_64BIT
4593 && !INT14_OK_STRICT
4594 && GENERAL_REGNO_P (REGNO (operands[0]))
4595 && GENERAL_REGNO_P (REGNO (operands[3]))
4596 && REGNO (operands[0]) != REGNO (operands[3])
4597 && REGNO (operands[1]) != REGNO (operands[3])
4598 && base14_operand (operands[2], E_SImode)"
4599 [(set (match_dup 3) (mem:SF (plus:SI (match_dup 1) (match_dup 2))))
4600 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
4601 "")
4602
4603 (define_peephole2
4604 [(set (match_operand:SI 0 "register_operand" "")
4605 (plus:SI (match_operand:SI 1 "register_operand" "")
4606 (match_operand:SI 2 "const_int_operand" "")))
4607 (set (match_operand:SF 3 "register_operand" "")
4608 (mem:SF (match_dup 0)))]
4609 "!TARGET_64BIT
4610 && !INT14_OK_STRICT
4611 && GENERAL_REGNO_P (REGNO (operands[0]))
4612 && GENERAL_REGNO_P (REGNO (operands[3]))
4613 && REGNO (operands[0]) == REGNO (operands[3])
4614 && base14_operand (operands[2], E_SImode)"
4615 [(set (match_dup 3) (mem:SF (plus:SI (match_dup 1) (match_dup 2))))]
4616 "")
4617
4618 (define_peephole2
4619 [(set (match_operand:SI 0 "register_operand" "")
4620 (plus:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
4621 (const_int 2))
4622 (match_operand:SI 2 "register_operand" "")))
4623 (set (mem:SF (match_dup 0))
4624 (match_operand:SF 3 "register_operand" ""))]
4625 "!TARGET_SOFT_FLOAT
4626 && !TARGET_DISABLE_INDEXING
4627 && REG_OK_FOR_BASE_P (operands[2])
4628 && FP_REGNO_P (REGNO (operands[3]))"
4629 [(set (mem:SF (plus:SI (mult:SI (match_dup 1) (const_int 4)) (match_dup 2)))
4630 (match_dup 3))
4631 (set (match_dup 0) (plus:SI (ashift:SI (match_dup 1) (const_int 2))
4632 (match_dup 2)))]
4633 "")
4634
4635 (define_peephole2
4636 [(set (match_operand:DI 0 "register_operand" "")
4637 (plus:DI (ashift:DI (match_operand:DI 1 "register_operand" "")
4638 (const_int 2))
4639 (match_operand:DI 2 "register_operand" "")))
4640 (set (mem:SF (match_dup 0))
4641 (match_operand:SF 3 "register_operand" ""))]
4642 "!TARGET_SOFT_FLOAT
4643 && !TARGET_DISABLE_INDEXING
4644 && TARGET_64BIT
4645 && REG_OK_FOR_BASE_P (operands[2])
4646 && FP_REGNO_P (REGNO (operands[3]))"
4647 [(set (mem:SF (plus:DI (mult:DI (match_dup 1) (const_int 4)) (match_dup 2)))
4648 (match_dup 3))
4649 (set (match_dup 0) (plus:DI (ashift:DI (match_dup 1) (const_int 2))
4650 (match_dup 2)))]
4651 "")
4652
4653 (define_peephole2
4654 [(set (match_operand:SI 0 "register_operand" "")
4655 (plus:SI (match_operand:SI 1 "register_operand" "")
4656 (match_operand:SI 2 "register_operand" "")))
4657 (set (mem:SF (match_dup 0))
4658 (match_operand:SF 3 "register_operand" ""))]
4659 "!TARGET_SOFT_FLOAT
4660 && !TARGET_DISABLE_INDEXING
4661 && TARGET_NO_SPACE_REGS
4662 && REG_OK_FOR_INDEX_P (operands[1])
4663 && REG_OK_FOR_BASE_P (operands[2])
4664 && FP_REGNO_P (REGNO (operands[3]))"
4665 [(set (mem:SF (plus:SI (match_dup 1) (match_dup 2)))
4666 (match_dup 3))
4667 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
4668 "")
4669
4670 (define_peephole2
4671 [(set (match_operand:SI 0 "register_operand" "")
4672 (plus:SI (match_operand:SI 1 "register_operand" "")
4673 (match_operand:SI 2 "register_operand" "")))
4674 (set (mem:SF (match_dup 0))
4675 (match_operand:SF 3 "register_operand" ""))]
4676 "!TARGET_SOFT_FLOAT
4677 && !TARGET_DISABLE_INDEXING
4678 && TARGET_NO_SPACE_REGS
4679 && REG_OK_FOR_BASE_P (operands[1])
4680 && REG_OK_FOR_INDEX_P (operands[2])
4681 && FP_REGNO_P (REGNO (operands[3]))"
4682 [(set (mem:SF (plus:SI (match_dup 2) (match_dup 1)))
4683 (match_dup 3))
4684 (set (match_dup 0) (plus:SI (match_dup 2) (match_dup 1)))]
4685 "")
4686
4687 (define_peephole2
4688 [(set (match_operand:DI 0 "register_operand" "")
4689 (plus:DI (match_operand:DI 1 "register_operand" "")
4690 (match_operand:DI 2 "register_operand" "")))
4691 (set (mem:SF (match_dup 0))
4692 (match_operand:SF 3 "register_operand" ""))]
4693 "!TARGET_SOFT_FLOAT
4694 && !TARGET_DISABLE_INDEXING
4695 && TARGET_64BIT
4696 && TARGET_NO_SPACE_REGS
4697 && REG_OK_FOR_INDEX_P (operands[1])
4698 && REG_OK_FOR_BASE_P (operands[2])
4699 && FP_REGNO_P (REGNO (operands[3]))"
4700 [(set (mem:SF (plus:DI (match_dup 1) (match_dup 2)))
4701 (match_dup 3))
4702 (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
4703 "")
4704
4705 (define_peephole2
4706 [(set (match_operand:DI 0 "register_operand" "")
4707 (plus:DI (match_operand:DI 1 "register_operand" "")
4708 (match_operand:DI 2 "register_operand" "")))
4709 (set (mem:SF (match_dup 0))
4710 (match_operand:SF 3 "register_operand" ""))]
4711 "!TARGET_SOFT_FLOAT
4712 && !TARGET_DISABLE_INDEXING
4713 && TARGET_64BIT
4714 && TARGET_NO_SPACE_REGS
4715 && REG_OK_FOR_BASE_P (operands[1])
4716 && REG_OK_FOR_INDEX_P (operands[2])
4717 && FP_REGNO_P (REGNO (operands[3]))"
4718 [(set (mem:SF (plus:DI (match_dup 2) (match_dup 1)))
4719 (match_dup 3))
4720 (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
4721 "")
4722
4723 (define_insn ""
4724 [(set (match_operand:SF 0 "move_dest_operand"
4725 "=r,r,Q")
4726 (match_operand:SF 1 "reg_or_0_or_mem_operand"
4727 "rG,RQ,rG"))]
4728 "(register_operand (operands[0], SFmode)
4729 || reg_or_0_operand (operands[1], SFmode))
4730 && TARGET_SOFT_FLOAT"
4731 "@
4732 copy %r1,%0
4733 ldw%M1 %1,%0
4734 stw%M0 %r1,%0"
4735 [(set_attr "type" "move,load,store")
4736 (set_attr "pa_combine_type" "addmove")
4737 (set_attr "length" "4,4,4")])
4738
4739
4740
4741 ;;- zero extension instructions
4742 ;; We have define_expand for zero extension patterns to make sure the
4743 ;; operands get loaded into registers. The define_insns accept
4744 ;; memory operands. This gives us better overall code than just
4745 ;; having a pattern that does or does not accept memory operands.
4746
4747 (define_expand "zero_extendqihi2"
4748 [(set (match_operand:HI 0 "register_operand" "")
4749 (zero_extend:HI
4750 (match_operand:QI 1 "register_operand" "")))]
4751 ""
4752 "")
4753
4754 (define_insn ""
4755 [(set (match_operand:HI 0 "register_operand" "=r,r")
4756 (zero_extend:HI
4757 (match_operand:QI 1 "move_src_operand" "r,RQ")))]
4758 "GET_CODE (operands[1]) != CONST_INT"
4759 "@
4760 {extru|extrw,u} %1,31,8,%0
4761 ldb%M1 %1,%0"
4762 [(set_attr "type" "shift,load")
4763 (set_attr "length" "4,4")])
4764
4765 (define_expand "zero_extendqisi2"
4766 [(set (match_operand:SI 0 "register_operand" "")
4767 (zero_extend:SI
4768 (match_operand:QI 1 "register_operand" "")))]
4769 ""
4770 "")
4771
4772 (define_insn ""
4773 [(set (match_operand:SI 0 "register_operand" "=r,r")
4774 (zero_extend:SI
4775 (match_operand:QI 1 "move_src_operand" "r,RQ")))]
4776 "GET_CODE (operands[1]) != CONST_INT"
4777 "@
4778 {extru|extrw,u} %1,31,8,%0
4779 ldb%M1 %1,%0"
4780 [(set_attr "type" "shift,load")
4781 (set_attr "length" "4,4")])
4782
4783 (define_expand "zero_extendhisi2"
4784 [(set (match_operand:SI 0 "register_operand" "")
4785 (zero_extend:SI
4786 (match_operand:HI 1 "register_operand" "")))]
4787 ""
4788 "")
4789
4790 (define_insn ""
4791 [(set (match_operand:SI 0 "register_operand" "=r,r")
4792 (zero_extend:SI
4793 (match_operand:HI 1 "move_src_operand" "r,RQ")))]
4794 "GET_CODE (operands[1]) != CONST_INT"
4795 "@
4796 {extru|extrw,u} %1,31,16,%0
4797 ldh%M1 %1,%0"
4798 [(set_attr "type" "shift,load")
4799 (set_attr "length" "4,4")])
4800
4801 (define_expand "zero_extendqidi2"
4802 [(set (match_operand:DI 0 "register_operand" "")
4803 (zero_extend:DI
4804 (match_operand:QI 1 "register_operand" "")))]
4805 "TARGET_64BIT"
4806 "")
4807
4808 (define_insn ""
4809 [(set (match_operand:DI 0 "register_operand" "=r,r")
4810 (zero_extend:DI
4811 (match_operand:QI 1 "move_src_operand" "r,RQ")))]
4812 "TARGET_64BIT && GET_CODE (operands[1]) != CONST_INT"
4813 "@
4814 extrd,u %1,63,8,%0
4815 ldb%M1 %1,%0"
4816 [(set_attr "type" "shift,load")
4817 (set_attr "length" "4,4")])
4818
4819 (define_expand "zero_extendhidi2"
4820 [(set (match_operand:DI 0 "register_operand" "")
4821 (zero_extend:DI
4822 (match_operand:HI 1 "register_operand" "")))]
4823 "TARGET_64BIT"
4824 "")
4825
4826 (define_insn ""
4827 [(set (match_operand:DI 0 "register_operand" "=r,r")
4828 (zero_extend:DI
4829 (match_operand:HI 1 "move_src_operand" "r,RQ")))]
4830 "TARGET_64BIT && GET_CODE (operands[1]) != CONST_INT"
4831 "@
4832 extrd,u %1,63,16,%0
4833 ldh%M1 %1,%0"
4834 [(set_attr "type" "shift,load")
4835 (set_attr "length" "4,4")])
4836
4837 (define_expand "zero_extendsidi2"
4838 [(set (match_operand:DI 0 "register_operand" "")
4839 (zero_extend:DI
4840 (match_operand:SI 1 "register_operand" "")))]
4841 "TARGET_64BIT"
4842 "")
4843
4844 (define_insn ""
4845 [(set (match_operand:DI 0 "register_operand" "=r,r")
4846 (zero_extend:DI
4847 (match_operand:SI 1 "move_src_operand" "r,RQ")))]
4848 "TARGET_64BIT && GET_CODE (operands[1]) != CONST_INT"
4849 "@
4850 extrd,u %1,63,32,%0
4851 ldw%M1 %1,%0"
4852 [(set_attr "type" "shift,load")
4853 (set_attr "length" "4,4")])
4854
4855 ;;- sign extension instructions
4856
4857 (define_insn "extendhisi2"
4858 [(set (match_operand:SI 0 "register_operand" "=r")
4859 (sign_extend:SI (match_operand:HI 1 "register_operand" "r")))]
4860 ""
4861 "{extrs|extrw,s} %1,31,16,%0"
4862 [(set_attr "type" "shift")
4863 (set_attr "length" "4")])
4864
4865 (define_insn "extendqihi2"
4866 [(set (match_operand:HI 0 "register_operand" "=r")
4867 (sign_extend:HI (match_operand:QI 1 "register_operand" "r")))]
4868 ""
4869 "{extrs|extrw,s} %1,31,8,%0"
4870 [(set_attr "type" "shift")
4871 (set_attr "length" "4")])
4872
4873 (define_insn "extendqisi2"
4874 [(set (match_operand:SI 0 "register_operand" "=r")
4875 (sign_extend:SI (match_operand:QI 1 "register_operand" "r")))]
4876 ""
4877 "{extrs|extrw,s} %1,31,8,%0"
4878 [(set_attr "type" "shift")
4879 (set_attr "length" "4")])
4880
4881 (define_insn "extendqidi2"
4882 [(set (match_operand:DI 0 "register_operand" "=r")
4883 (sign_extend:DI (match_operand:QI 1 "register_operand" "r")))]
4884 "TARGET_64BIT"
4885 "extrd,s %1,63,8,%0"
4886 [(set_attr "type" "shift")
4887 (set_attr "length" "4")])
4888
4889 (define_insn "extendhidi2"
4890 [(set (match_operand:DI 0 "register_operand" "=r")
4891 (sign_extend:DI (match_operand:HI 1 "register_operand" "r")))]
4892 "TARGET_64BIT"
4893 "extrd,s %1,63,16,%0"
4894 [(set_attr "type" "shift")
4895 (set_attr "length" "4")])
4896
4897 (define_insn "extendsidi2"
4898 [(set (match_operand:DI 0 "register_operand" "=r")
4899 (sign_extend:DI (match_operand:SI 1 "register_operand" "r")))]
4900 "TARGET_64BIT"
4901 "extrd,s %1,63,32,%0"
4902 [(set_attr "type" "shift")
4903 (set_attr "length" "4")])
4904
4905
4906 ;; Conversions between float and double.
4907
4908 (define_insn "extendsfdf2"
4909 [(set (match_operand:DF 0 "register_operand" "=f")
4910 (float_extend:DF
4911 (match_operand:SF 1 "register_operand" "f")))]
4912 "! TARGET_SOFT_FLOAT"
4913 "{fcnvff|fcnv},sgl,dbl %1,%0"
4914 [(set_attr "type" "fpalu")
4915 (set_attr "length" "4")])
4916
4917 (define_insn "truncdfsf2"
4918 [(set (match_operand:SF 0 "register_operand" "=f")
4919 (float_truncate:SF
4920 (match_operand:DF 1 "register_operand" "f")))]
4921 "! TARGET_SOFT_FLOAT"
4922 "{fcnvff|fcnv},dbl,sgl %1,%0"
4923 [(set_attr "type" "fpalu")
4924 (set_attr "length" "4")])
4925
4926 ;; Conversion between fixed point and floating point.
4927 ;; Note that among the fix-to-float insns
4928 ;; the ones that start with SImode come first.
4929 ;; That is so that an operand that is a CONST_INT
4930 ;; (and therefore lacks a specific machine mode).
4931 ;; will be recognized as SImode (which is always valid)
4932 ;; rather than as QImode or HImode.
4933
4934 ;; This pattern forces (set (reg:SF ...) (float:SF (const_int ...)))
4935 ;; to be reloaded by putting the constant into memory.
4936 ;; It must come before the more general floatsisf2 pattern.
4937 (define_insn ""
4938 [(set (match_operand:SF 0 "register_operand" "=f")
4939 (float:SF (match_operand:SI 1 "const_int_operand" "m")))]
4940 "! TARGET_SOFT_FLOAT"
4941 "fldw%F1 %1,%0\;{fcnvxf,sgl,sgl|fcnv,w,sgl} %0,%0"
4942 [(set_attr "type" "fpalu")
4943 (set_attr "length" "8")])
4944
4945 (define_insn "floatsisf2"
4946 [(set (match_operand:SF 0 "register_operand" "=f")
4947 (float:SF (match_operand:SI 1 "register_operand" "f")))]
4948 "! TARGET_SOFT_FLOAT"
4949 "{fcnvxf,sgl,sgl|fcnv,w,sgl} %1,%0"
4950 [(set_attr "type" "fpalu")
4951 (set_attr "length" "4")])
4952
4953 ;; This pattern forces (set (reg:DF ...) (float:DF (const_int ...)))
4954 ;; to be reloaded by putting the constant into memory.
4955 ;; It must come before the more general floatsidf2 pattern.
4956 (define_insn ""
4957 [(set (match_operand:DF 0 "register_operand" "=f")
4958 (float:DF (match_operand:SI 1 "const_int_operand" "m")))]
4959 "! TARGET_SOFT_FLOAT"
4960 "fldw%F1 %1,%0\;{fcnvxf,sgl,dbl|fcnv,w,dbl} %0,%0"
4961 [(set_attr "type" "fpalu")
4962 (set_attr "length" "8")])
4963
4964 (define_insn "floatsidf2"
4965 [(set (match_operand:DF 0 "register_operand" "=f")
4966 (float:DF (match_operand:SI 1 "register_operand" "f")))]
4967 "! TARGET_SOFT_FLOAT"
4968 "{fcnvxf,sgl,dbl|fcnv,w,dbl} %1,%0"
4969 [(set_attr "type" "fpalu")
4970 (set_attr "length" "4")])
4971
4972 (define_expand "floatunssisf2"
4973 [(set (subreg:SI (match_dup 2) 4)
4974 (match_operand:SI 1 "register_operand" ""))
4975 (set (subreg:SI (match_dup 2) 0)
4976 (const_int 0))
4977 (set (match_operand:SF 0 "register_operand" "")
4978 (float:SF (match_dup 2)))]
4979 "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4980 "
4981 {
4982 if (TARGET_PA_20)
4983 {
4984 emit_insn (gen_floatunssisf2_pa20 (operands[0], operands[1]));
4985 DONE;
4986 }
4987 operands[2] = gen_reg_rtx (DImode);
4988 }")
4989
4990 (define_expand "floatunssidf2"
4991 [(set (subreg:SI (match_dup 2) 4)
4992 (match_operand:SI 1 "register_operand" ""))
4993 (set (subreg:SI (match_dup 2) 0)
4994 (const_int 0))
4995 (set (match_operand:DF 0 "register_operand" "")
4996 (float:DF (match_dup 2)))]
4997 "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4998 "
4999 {
5000 if (TARGET_PA_20)
5001 {
5002 emit_insn (gen_floatunssidf2_pa20 (operands[0], operands[1]));
5003 DONE;
5004 }
5005 operands[2] = gen_reg_rtx (DImode);
5006 }")
5007
5008 (define_insn "floatdisf2"
5009 [(set (match_operand:SF 0 "register_operand" "=f")
5010 (float:SF (match_operand:DI 1 "register_operand" "f")))]
5011 "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
5012 "{fcnvxf,dbl,sgl|fcnv,dw,sgl} %1,%0"
5013 [(set_attr "type" "fpalu")
5014 (set_attr "length" "4")])
5015
5016 (define_insn "floatdidf2"
5017 [(set (match_operand:DF 0 "register_operand" "=f")
5018 (float:DF (match_operand:DI 1 "register_operand" "f")))]
5019 "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
5020 "{fcnvxf,dbl,dbl|fcnv,dw,dbl} %1,%0"
5021 [(set_attr "type" "fpalu")
5022 (set_attr "length" "4")])
5023
5024 ;; Convert a float to an actual integer.
5025 ;; Truncation is performed as part of the conversion.
5026
5027 (define_insn "fix_truncsfsi2"
5028 [(set (match_operand:SI 0 "register_operand" "=f")
5029 (fix:SI (match_operand:SF 1 "register_operand" "f")))]
5030 "! TARGET_SOFT_FLOAT"
5031 "{fcnvfxt,sgl,sgl|fcnv,t,sgl,w} %1,%0"
5032 [(set_attr "type" "fpalu")
5033 (set_attr "length" "4")])
5034
5035 (define_insn "fix_truncdfsi2"
5036 [(set (match_operand:SI 0 "register_operand" "=f")
5037 (fix:SI (match_operand:DF 1 "register_operand" "f")))]
5038 "! TARGET_SOFT_FLOAT"
5039 "{fcnvfxt,dbl,sgl|fcnv,t,dbl,w} %1,%0"
5040 [(set_attr "type" "fpalu")
5041 (set_attr "length" "4")])
5042
5043 (define_insn "fix_truncsfdi2"
5044 [(set (match_operand:DI 0 "register_operand" "=f")
5045 (fix:DI (match_operand:SF 1 "register_operand" "f")))]
5046 "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
5047 "{fcnvfxt,sgl,dbl|fcnv,t,sgl,dw} %1,%0"
5048 [(set_attr "type" "fpalu")
5049 (set_attr "length" "4")])
5050
5051 (define_insn "fix_truncdfdi2"
5052 [(set (match_operand:DI 0 "register_operand" "=f")
5053 (fix:DI (match_operand:DF 1 "register_operand" "f")))]
5054 "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
5055 "{fcnvfxt,dbl,dbl|fcnv,t,dbl,dw} %1,%0"
5056 [(set_attr "type" "fpalu")
5057 (set_attr "length" "4")])
5058
5059 (define_insn "floatunssidf2_pa20"
5060 [(set (match_operand:DF 0 "register_operand" "=f")
5061 (unsigned_float:DF (match_operand:SI 1 "register_operand" "f")))]
5062 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5063 "fcnv,uw,dbl %1,%0"
5064 [(set_attr "type" "fpalu")
5065 (set_attr "length" "4")])
5066
5067 (define_insn "floatunssisf2_pa20"
5068 [(set (match_operand:SF 0 "register_operand" "=f")
5069 (unsigned_float:SF (match_operand:SI 1 "register_operand" "f")))]
5070 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5071 "fcnv,uw,sgl %1,%0"
5072 [(set_attr "type" "fpalu")
5073 (set_attr "length" "4")])
5074
5075 (define_insn "floatunsdisf2"
5076 [(set (match_operand:SF 0 "register_operand" "=f")
5077 (unsigned_float:SF (match_operand:DI 1 "register_operand" "f")))]
5078 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5079 "fcnv,udw,sgl %1,%0"
5080 [(set_attr "type" "fpalu")
5081 (set_attr "length" "4")])
5082
5083 (define_insn "floatunsdidf2"
5084 [(set (match_operand:DF 0 "register_operand" "=f")
5085 (unsigned_float:DF (match_operand:DI 1 "register_operand" "f")))]
5086 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5087 "fcnv,udw,dbl %1,%0"
5088 [(set_attr "type" "fpalu")
5089 (set_attr "length" "4")])
5090
5091 (define_insn "fixuns_truncsfsi2"
5092 [(set (match_operand:SI 0 "register_operand" "=f")
5093 (unsigned_fix:SI (match_operand:SF 1 "register_operand" "f")))]
5094 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5095 "fcnv,t,sgl,uw %1,%0"
5096 [(set_attr "type" "fpalu")
5097 (set_attr "length" "4")])
5098
5099 (define_insn "fixuns_truncdfsi2"
5100 [(set (match_operand:SI 0 "register_operand" "=f")
5101 (unsigned_fix:SI (match_operand:DF 1 "register_operand" "f")))]
5102 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5103 "fcnv,t,dbl,uw %1,%0"
5104 [(set_attr "type" "fpalu")
5105 (set_attr "length" "4")])
5106
5107 (define_insn "fixuns_truncsfdi2"
5108 [(set (match_operand:DI 0 "register_operand" "=f")
5109 (unsigned_fix:DI (match_operand:SF 1 "register_operand" "f")))]
5110 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5111 "fcnv,t,sgl,udw %1,%0"
5112 [(set_attr "type" "fpalu")
5113 (set_attr "length" "4")])
5114
5115 (define_insn "fixuns_truncdfdi2"
5116 [(set (match_operand:DI 0 "register_operand" "=f")
5117 (unsigned_fix:DI (match_operand:DF 1 "register_operand" "f")))]
5118 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5119 "fcnv,t,dbl,udw %1,%0"
5120 [(set_attr "type" "fpalu")
5121 (set_attr "length" "4")])
5122
5123 ;;- arithmetic instructions
5124
5125 (define_expand "adddi3"
5126 [(set (match_operand:DI 0 "register_operand" "")
5127 (plus:DI (match_operand:DI 1 "register_operand" "")
5128 (match_operand:DI 2 "adddi3_operand" "")))]
5129 ""
5130 "")
5131
5132 (define_insn ""
5133 [(set (match_operand:DI 0 "register_operand" "=r")
5134 (plus:DI (match_operand:DI 1 "register_operand" "%r")
5135 (match_operand:DI 2 "arith11_operand" "rI")))]
5136 "!TARGET_64BIT"
5137 "*
5138 {
5139 if (GET_CODE (operands[2]) == CONST_INT)
5140 {
5141 if (INTVAL (operands[2]) >= 0)
5142 return \"addi %2,%R1,%R0\;{addc|add,c} %1,%%r0,%0\";
5143 else
5144 return \"addi %2,%R1,%R0\;{subb|sub,b} %1,%%r0,%0\";
5145 }
5146 else
5147 return \"add %R2,%R1,%R0\;{addc|add,c} %2,%1,%0\";
5148 }"
5149 [(set_attr "type" "binary")
5150 (set_attr "length" "8")])
5151
5152 (define_insn ""
5153 [(set (match_operand:DI 0 "register_operand" "=r,r")
5154 (plus:DI (match_operand:DI 1 "register_operand" "%r,r")
5155 (match_operand:DI 2 "arith14_operand" "r,J")))]
5156 "TARGET_64BIT"
5157 "@
5158 add,l %1,%2,%0
5159 ldo %2(%1),%0"
5160 [(set_attr "type" "binary,binary")
5161 (set_attr "pa_combine_type" "addmove")
5162 (set_attr "length" "4,4")])
5163
5164 (define_insn ""
5165 [(set (match_operand:DI 0 "register_operand" "=r")
5166 (plus:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
5167 (match_operand:DI 2 "register_operand" "r")))]
5168 "TARGET_64BIT"
5169 "uaddcm %2,%1,%0"
5170 [(set_attr "type" "binary")
5171 (set_attr "length" "4")])
5172
5173 (define_insn ""
5174 [(set (match_operand:SI 0 "register_operand" "=r")
5175 (plus:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
5176 (match_operand:SI 2 "register_operand" "r")))]
5177 ""
5178 "uaddcm %2,%1,%0"
5179 [(set_attr "type" "binary")
5180 (set_attr "length" "4")])
5181
5182 (define_expand "addvdi3"
5183 [(parallel [(set (match_operand:DI 0 "register_operand" "")
5184 (plus:DI (match_operand:DI 1 "reg_or_0_operand" "")
5185 (match_operand:DI 2 "arith11_operand" "")))
5186 (trap_if (ne (plus:TI (sign_extend:TI (match_dup 1))
5187 (sign_extend:TI (match_dup 2)))
5188 (sign_extend:TI (plus:DI (match_dup 1)
5189 (match_dup 2))))
5190 (const_int 0))])]
5191 ""
5192 "
5193 {
5194 if (TARGET_64BIT)
5195 operands[2] = force_reg (DImode, operands[2]);
5196 }")
5197
5198 (define_insn ""
5199 [(set (match_operand:DI 0 "register_operand" "=r")
5200 (plus:DI (match_operand:DI 1 "reg_or_0_operand" "%rM")
5201 (match_operand:DI 2 "register_operand" "r")))
5202 (trap_if (ne (plus:TI (sign_extend:TI (match_dup 1))
5203 (sign_extend:TI (match_dup 2)))
5204 (sign_extend:TI (plus:DI (match_dup 1)
5205 (match_dup 2))))
5206 (const_int 0))]
5207 "TARGET_64BIT"
5208 "add,tsv,* %2,%1,%0"
5209 [(set_attr "type" "binary")
5210 (set_attr "length" "4")])
5211
5212 (define_insn ""
5213 [(set (match_operand:DI 0 "register_operand" "=r")
5214 (plus:DI (match_operand:DI 1 "reg_or_0_operand" "%rM")
5215 (match_operand:DI 2 "arith11_operand" "rI")))
5216 (trap_if (ne (plus:TI (sign_extend:TI (match_dup 1))
5217 (sign_extend:TI (match_dup 2)))
5218 (sign_extend:TI (plus:DI (match_dup 1)
5219 (match_dup 2))))
5220 (const_int 0))]
5221 "!TARGET_64BIT"
5222 "*
5223 {
5224 if (GET_CODE (operands[2]) == CONST_INT)
5225 {
5226 if (INTVAL (operands[2]) >= 0)
5227 return \"addi %2,%R1,%R0\;{addco|add,c,tsv} %1,%%r0,%0\";
5228 else
5229 return \"addi %2,%R1,%R0\;{subbo|sub,b,tsv} %1,%%r0,%0\";
5230 }
5231 else
5232 return \"add %R2,%R1,%R0\;{addco|add,c,tsv} %2,%1,%0\";
5233 }"
5234 [(set_attr "type" "binary")
5235 (set_attr "length" "8")])
5236
5237 ;; define_splits to optimize cases of adding a constant integer
5238 ;; to a register when the constant does not fit in 14 bits. */
5239 (define_split
5240 [(set (match_operand:SI 0 "register_operand" "")
5241 (plus:SI (match_operand:SI 1 "register_operand" "")
5242 (match_operand:SI 2 "const_int_operand" "")))
5243 (clobber (match_operand:SI 4 "register_operand" ""))]
5244 "! pa_cint_ok_for_move (UINTVAL (operands[2]))
5245 && VAL_14_BITS_P (INTVAL (operands[2]) >> 1)"
5246 [(set (match_dup 4) (plus:SI (match_dup 1) (match_dup 2)))
5247 (set (match_dup 0) (plus:SI (match_dup 4) (match_dup 3)))]
5248 "
5249 {
5250 int val = INTVAL (operands[2]);
5251 int low = (val < 0) ? -0x2000 : 0x1fff;
5252 int rest = val - low;
5253
5254 operands[2] = GEN_INT (rest);
5255 operands[3] = GEN_INT (low);
5256 }")
5257
5258 (define_split
5259 [(set (match_operand:SI 0 "register_operand" "")
5260 (plus:SI (match_operand:SI 1 "register_operand" "")
5261 (match_operand:SI 2 "const_int_operand" "")))
5262 (clobber (match_operand:SI 4 "register_operand" ""))]
5263 "! pa_cint_ok_for_move (UINTVAL (operands[2]))"
5264 [(set (match_dup 4) (match_dup 2))
5265 (set (match_dup 0) (plus:SI (ashift:SI (match_dup 4) (match_dup 3))
5266 (match_dup 1)))]
5267 "
5268 {
5269 unsigned HOST_WIDE_INT intval = UINTVAL (operands[2]);
5270
5271 /* Try dividing the constant by 2, then 4, and finally 8 to see
5272 if we can get a constant which can be loaded into a register
5273 in a single instruction (pa_cint_ok_for_move).
5274
5275 If that fails, try to negate the constant and subtract it
5276 from our input operand. */
5277 if (intval % 2 == 0 && pa_cint_ok_for_move (intval / 2))
5278 {
5279 operands[2] = GEN_INT (intval / 2);
5280 operands[3] = const1_rtx;
5281 }
5282 else if (intval % 4 == 0 && pa_cint_ok_for_move (intval / 4))
5283 {
5284 operands[2] = GEN_INT (intval / 4);
5285 operands[3] = const2_rtx;
5286 }
5287 else if (intval % 8 == 0 && pa_cint_ok_for_move (intval / 8))
5288 {
5289 operands[2] = GEN_INT (intval / 8);
5290 operands[3] = GEN_INT (3);
5291 }
5292 else if (pa_cint_ok_for_move (-intval))
5293 {
5294 emit_insn (gen_rtx_SET (operands[4], GEN_INT (-intval)));
5295 emit_insn (gen_subsi3 (operands[0], operands[1], operands[4]));
5296 DONE;
5297 }
5298 else
5299 FAIL;
5300 }")
5301
5302 (define_insn "addsi3"
5303 [(set (match_operand:SI 0 "register_operand" "=r,r")
5304 (plus:SI (match_operand:SI 1 "register_operand" "%r,r")
5305 (match_operand:SI 2 "arith14_operand" "r,J")))]
5306 ""
5307 "@
5308 {addl|add,l} %1,%2,%0
5309 ldo %2(%1),%0"
5310 [(set_attr "type" "binary,binary")
5311 (set_attr "pa_combine_type" "addmove")
5312 (set_attr "length" "4,4")])
5313
5314 (define_insn "addvsi3"
5315 [(set (match_operand:SI 0 "register_operand" "=r,r")
5316 (plus:SI (match_operand:SI 1 "reg_or_0_operand" "%rM,rM")
5317 (match_operand:SI 2 "arith11_operand" "r,I")))
5318 (trap_if (ne (plus:DI (sign_extend:DI (match_dup 1))
5319 (sign_extend:DI (match_dup 2)))
5320 (sign_extend:DI (plus:SI (match_dup 1)
5321 (match_dup 2))))
5322 (const_int 0))]
5323 ""
5324 "@
5325 {addo|add,tsv} %2,%1,%0
5326 {addio|addi,tsv} %2,%1,%0"
5327 [(set_attr "type" "binary,binary")
5328 (set_attr "length" "4,4")])
5329
5330 (define_expand "subdi3"
5331 [(set (match_operand:DI 0 "register_operand" "")
5332 (minus:DI (match_operand:DI 1 "arith11_operand" "")
5333 (match_operand:DI 2 "reg_or_0_operand" "")))]
5334 ""
5335 "")
5336
5337 (define_insn ""
5338 [(set (match_operand:DI 0 "register_operand" "=r,r,!q")
5339 (minus:DI (match_operand:DI 1 "arith11_operand" "r,I,!U")
5340 (match_operand:DI 2 "reg_or_0_operand" "rM,rM,!rM")))]
5341 "TARGET_64BIT"
5342 "@
5343 sub %1,%2,%0
5344 subi %1,%2,%0
5345 mtsarcm %2"
5346 [(set_attr "type" "binary,binary,move")
5347 (set_attr "length" "4,4,4")])
5348
5349 (define_insn ""
5350 [(set (match_operand:DI 0 "register_operand" "=r,&r")
5351 (minus:DI (match_operand:DI 1 "arith11_operand" "r,I")
5352 (match_operand:DI 2 "reg_or_0_operand" "rM,rM")))]
5353 "!TARGET_64BIT"
5354 "*
5355 {
5356 if (GET_CODE (operands[1]) == CONST_INT)
5357 {
5358 if (INTVAL (operands[1]) >= 0)
5359 return \"subi %1,%R2,%R0\;{subb|sub,b} %%r0,%2,%0\";
5360 else
5361 return \"ldi -1,%0\;subi %1,%R2,%R0\;{subb|sub,b} %0,%2,%0\";
5362 }
5363 else
5364 return \"sub %R1,%R2,%R0\;{subb|sub,b} %1,%2,%0\";
5365 }"
5366 [(set_attr "type" "binary")
5367 (set (attr "length")
5368 (if_then_else (eq_attr "alternative" "0")
5369 (const_int 8)
5370 (if_then_else (ge (symbol_ref "INTVAL (operands[1])")
5371 (const_int 0))
5372 (const_int 8)
5373 (const_int 12))))])
5374
5375 (define_expand "subvdi3"
5376 [(parallel [(set (match_operand:DI 0 "register_operand" "")
5377 (minus:DI (match_operand:DI 1 "arith11_operand" "")
5378 (match_operand:DI 2 "reg_or_0_operand" "")))
5379 (trap_if (ne (minus:TI (sign_extend:TI (match_dup 1))
5380 (sign_extend:TI (match_dup 2)))
5381 (sign_extend:TI (minus:DI (match_dup 1)
5382 (match_dup 2))))
5383 (const_int 0))])]
5384 ""
5385 "
5386 {
5387 if (TARGET_64BIT)
5388 operands[1] = force_reg (DImode, operands[1]);
5389 }")
5390
5391 (define_insn ""
5392 [(set (match_operand:DI 0 "register_operand" "=r")
5393 (minus:DI (match_operand:DI 1 "register_operand" "r")
5394 (match_operand:DI 2 "reg_or_0_operand" "rM")))
5395 (trap_if (ne (minus:TI (sign_extend:TI (match_dup 1))
5396 (sign_extend:TI (match_dup 2)))
5397 (sign_extend:TI (minus:DI (match_dup 1)
5398 (match_dup 2))))
5399 (const_int 0))]
5400 "TARGET_64BIT"
5401 "sub,tsv,* %1,%2,%0"
5402 [(set_attr "type" "binary")
5403 (set_attr "length" "4")])
5404
5405 (define_insn ""
5406 [(set (match_operand:DI 0 "register_operand" "=r,&r")
5407 (minus:DI (match_operand:DI 1 "arith11_operand" "r,I")
5408 (match_operand:DI 2 "reg_or_0_operand" "rM,rM")))
5409 (trap_if (ne (minus:TI (sign_extend:TI (match_dup 1))
5410 (sign_extend:TI (match_dup 2)))
5411 (sign_extend:TI (minus:DI (match_dup 1)
5412 (match_dup 2))))
5413 (const_int 0))]
5414 "!TARGET_64BIT"
5415 "*
5416 {
5417 if (GET_CODE (operands[1]) == CONST_INT)
5418 {
5419 if (INTVAL (operands[1]) >= 0)
5420 return \"subi %1,%R2,%R0\;{subbo|sub,b,tsv} %%r0,%2,%0\";
5421 else
5422 return \"ldi -1,%0\;subi %1,%R2,%R0\;{subbo|sub,b,tsv} %0,%2,%0\";
5423 }
5424 else
5425 return \"sub %R1,%R2,%R0\;{subbo|sub,b,tsv} %1,%2,%0\";
5426 }"
5427 [(set_attr "type" "binary,binary")
5428 (set (attr "length")
5429 (if_then_else (eq_attr "alternative" "0")
5430 (const_int 8)
5431 (if_then_else (ge (symbol_ref "INTVAL (operands[1])")
5432 (const_int 0))
5433 (const_int 8)
5434 (const_int 12))))])
5435
5436 (define_expand "subsi3"
5437 [(set (match_operand:SI 0 "register_operand" "")
5438 (minus:SI (match_operand:SI 1 "arith11_operand" "")
5439 (match_operand:SI 2 "register_operand" "")))]
5440 ""
5441 "")
5442
5443 (define_insn ""
5444 [(set (match_operand:SI 0 "register_operand" "=r,r")
5445 (minus:SI (match_operand:SI 1 "arith11_operand" "r,I")
5446 (match_operand:SI 2 "register_operand" "r,r")))]
5447 "!TARGET_PA_20"
5448 "@
5449 sub %1,%2,%0
5450 subi %1,%2,%0"
5451 [(set_attr "type" "binary,binary")
5452 (set_attr "length" "4,4")])
5453
5454 (define_insn ""
5455 [(set (match_operand:SI 0 "register_operand" "=r,r,!q")
5456 (minus:SI (match_operand:SI 1 "arith11_operand" "r,I,!S")
5457 (match_operand:SI 2 "register_operand" "r,r,!r")))]
5458 "TARGET_PA_20"
5459 "@
5460 sub %1,%2,%0
5461 subi %1,%2,%0
5462 mtsarcm %2"
5463 [(set_attr "type" "binary,binary,move")
5464 (set_attr "length" "4,4,4")])
5465
5466 (define_insn "subvsi3"
5467 [(set (match_operand:SI 0 "register_operand" "=r,r")
5468 (minus:SI (match_operand:SI 1 "arith11_operand" "rM,I")
5469 (match_operand:SI 2 "reg_or_0_operand" "rM,rM")))
5470 (trap_if (ne (minus:DI (sign_extend:DI (match_dup 1))
5471 (sign_extend:DI (match_dup 2)))
5472 (sign_extend:DI (minus:SI (match_dup 1)
5473 (match_dup 2))))
5474 (const_int 0))]
5475 ""
5476 "@
5477 {subo|sub,tsv} %1,%2,%0
5478 {subio|subi,tsv} %1,%2,%0"
5479 [(set_attr "type" "binary,binary")
5480 (set_attr "length" "4,4")])
5481
5482 (define_insn "addti3"
5483 [(set (match_operand:TI 0 "register_operand" "=r")
5484 (plus:TI (match_operand:TI 1 "register_operand" "%r")
5485 (match_operand:TI 2 "arith11_operand" "rI")))]
5486 "TARGET_64BIT"
5487 "*
5488 {
5489 if (GET_CODE (operands[2]) == CONST_INT)
5490 {
5491 if (INTVAL (operands[2]) >= 0)
5492 return \"addi %2,%R1,%R0\;add,dc %1,%%r0,%0\";
5493 else
5494 return \"addi %2,%R1,%R0\;sub,db %1,%%r0,%0\";
5495 }
5496 else
5497 return \"add %R2,%R1,%R0\;add,dc %2,%1,%0\";
5498 }"
5499 [(set_attr "type" "multi")
5500 (set_attr "length" "8")])
5501
5502 (define_insn "addvti3"
5503 [(set (match_operand:TI 0 "register_operand" "=r")
5504 (plus:TI (match_operand:TI 1 "register_operand" "r")
5505 (match_operand:TI 2 "arith11_operand" "rI")))
5506 (trap_if (ne (plus:OI (sign_extend:OI (match_dup 1))
5507 (sign_extend:OI (match_dup 2)))
5508 (sign_extend:OI (plus:TI (match_dup 1)
5509 (match_dup 2))))
5510 (const_int 0))]
5511 "TARGET_64BIT"
5512 "*
5513 {
5514 if (GET_CODE (operands[2]) == CONST_INT)
5515 {
5516 if (INTVAL (operands[2]) >= 0)
5517 return \"addi %2,%R1,%R0\;add,dc,tsv %1,%%r0,%0\";
5518 else
5519 return \"addi %2,%R1,%R0\;sub,db,tsv %1,%%r0,%0\";
5520 }
5521 else
5522 return \"add %R2,%R1,%R0\;add,dc,tsv %2,%1,%0\";
5523 }"
5524 [(set_attr "type" "multi")
5525 (set_attr "length" "8")])
5526
5527 (define_insn "subti3"
5528 [(set (match_operand:TI 0 "register_operand" "=r,&r")
5529 (minus:TI (match_operand:TI 1 "arith11_operand" "r,I")
5530 (match_operand:TI 2 "reg_or_0_operand" "rM,rM")))]
5531 "TARGET_64BIT"
5532 "*
5533 {
5534 if (GET_CODE (operands[1]) == CONST_INT)
5535 {
5536 if (INTVAL (operands[1]) >= 0)
5537 return \"subi %1,%R2,%R0\;sub,db %%r0,%2,%0\";
5538 else
5539 return \"ldi -1,%0\;subi %1,%R2,%R0\;sub,db %0,%2,%0\";
5540 }
5541 else
5542 return \"sub %R1,%R2,%R0\;sub,db %1,%2,%0\";
5543 }"
5544 [(set_attr "type" "multi")
5545 (set (attr "length")
5546 (if_then_else (eq_attr "alternative" "0")
5547 (const_int 8)
5548 (if_then_else (ge (symbol_ref "INTVAL (operands[1])")
5549 (const_int 0))
5550 (const_int 8)
5551 (const_int 12))))])
5552
5553 (define_insn "subvti3"
5554 [(set (match_operand:TI 0 "register_operand" "=r,&r")
5555 (minus:TI (match_operand:TI 1 "arith11_operand" "r,I")
5556 (match_operand:TI 2 "reg_or_0_operand" "rM,rM")))
5557 (trap_if (ne (minus:OI (sign_extend:OI (match_dup 1))
5558 (sign_extend:OI (match_dup 2)))
5559 (sign_extend:OI (minus:TI (match_dup 1)
5560 (match_dup 2))))
5561 (const_int 0))]
5562 "TARGET_64BIT"
5563 "*
5564 {
5565 if (GET_CODE (operands[1]) == CONST_INT)
5566 {
5567 if (INTVAL (operands[1]) >= 0)
5568 return \"subi %1,%R2,%R0\;sub,db,tsv %%r0,%2,%0\";
5569 else
5570 return \"ldi -1,%0\;subi %1,%R2,%R0\;sub,db,tsv %0,%2,%0\";
5571 }
5572 else
5573 return \"sub %R1,%R2,%R0\;sub,db,tsv %1,%2,%0\";
5574 }"
5575 [(set_attr "type" "multi,multi")
5576 (set (attr "length")
5577 (if_then_else (eq_attr "alternative" "0")
5578 (const_int 8)
5579 (if_then_else (ge (symbol_ref "INTVAL (operands[1])")
5580 (const_int 0))
5581 (const_int 8)
5582 (const_int 12))))])
5583
5584 ;; Trap instructions.
5585
5586 (define_insn "trap"
5587 [(trap_if (const_int 1) (const_int 0))]
5588 ""
5589 "{addit|addi,tc},<> 1,%%r0,%%r0"
5590 [(set_attr "type" "trap")
5591 (set_attr "length" "4")])
5592
5593 ;; Clobbering a "register_operand" instead of a match_scratch
5594 ;; in operand3 of millicode calls avoids spilling %r1 and
5595 ;; produces better code.
5596
5597 ;; The mulsi3 insns set up registers for the millicode call.
5598 (define_expand "mulsi3"
5599 [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5600 (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5601 (parallel [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
5602 (clobber (match_dup 3))
5603 (clobber (reg:SI 26))
5604 (clobber (reg:SI 25))
5605 (clobber (match_dup 4))])
5606 (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5607 ""
5608 "
5609 {
5610 operands[4] = gen_rtx_REG (SImode, TARGET_64BIT ? 2 : 31);
5611 if (TARGET_PA_11 && !TARGET_SOFT_FLOAT && !TARGET_SOFT_MULT)
5612 {
5613 rtx scratch = gen_reg_rtx (DImode);
5614 operands[1] = force_reg (SImode, operands[1]);
5615 operands[2] = force_reg (SImode, operands[2]);
5616 emit_insn (gen_umulsidi3 (scratch, operands[1], operands[2]));
5617 emit_insn (gen_movsi (operands[0],
5618 gen_rtx_SUBREG (SImode, scratch,
5619 GET_MODE_SIZE (SImode))));
5620 DONE;
5621 }
5622 operands[3] = gen_reg_rtx (SImode);
5623 }")
5624
5625 (define_insn "umulsidi3"
5626 [(set (match_operand:DI 0 "register_operand" "=f")
5627 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "f"))
5628 (zero_extend:DI (match_operand:SI 2 "register_operand" "f"))))]
5629 "TARGET_PA_11 && ! TARGET_SOFT_FLOAT && ! TARGET_SOFT_MULT"
5630 "xmpyu %1,%2,%0"
5631 [(set_attr "type" "fpmuldbl")
5632 (set_attr "length" "4")])
5633
5634 (define_insn ""
5635 [(set (reg:SI 29)
5636 (mult:SI (match_operand:SI 1 "r26_operand" "")
5637 (match_operand:SI 0 "r25_operand" "")))
5638 (clobber (match_operand:SI 2 "register_operand" "=a"))
5639 (clobber (reg:SI 26))
5640 (clobber (reg:SI 25))
5641 (clobber (reg:SI 31))]
5642 "!TARGET_64BIT"
5643 "* return pa_output_mul_insn (0, insn);"
5644 [(set_attr "type" "milli")
5645 (set (attr "length")
5646 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5647 (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5648
5649 (define_insn ""
5650 [(set (reg:SI 29)
5651 (mult:SI (match_operand:SI 1 "r26_operand" "")
5652 (match_operand:SI 0 "r25_operand" "")))
5653 (clobber (match_operand:SI 2 "register_operand" "=a"))
5654 (clobber (reg:SI 26))
5655 (clobber (reg:SI 25))
5656 (clobber (reg:SI 2))]
5657 "TARGET_64BIT"
5658 "* return pa_output_mul_insn (0, insn);"
5659 [(set_attr "type" "milli")
5660 (set (attr "length")
5661 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5662 (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5663
5664 (define_expand "muldi3"
5665 [(set (match_operand:DI 0 "register_operand" "")
5666 (mult:DI (match_operand:DI 1 "register_operand" "")
5667 (match_operand:DI 2 "register_operand" "")))]
5668 "! optimize_size
5669 && TARGET_PA_11
5670 && ! TARGET_SOFT_FLOAT
5671 && ! TARGET_SOFT_MULT"
5672 "
5673 {
5674 rtx low_product = gen_reg_rtx (DImode);
5675 rtx cross_product1 = gen_reg_rtx (DImode);
5676 rtx cross_product2 = gen_reg_rtx (DImode);
5677 rtx op1l, op1r, op2l, op2r;
5678
5679 if (TARGET_64BIT)
5680 {
5681 rtx op1shifted = gen_reg_rtx (DImode);
5682 rtx op2shifted = gen_reg_rtx (DImode);
5683
5684 emit_move_insn (op1shifted, gen_rtx_LSHIFTRT (DImode, operands[1],
5685 GEN_INT (32)));
5686 emit_move_insn (op2shifted, gen_rtx_LSHIFTRT (DImode, operands[2],
5687 GEN_INT (32)));
5688 op1r = force_reg (SImode, gen_rtx_SUBREG (SImode, operands[1], 4));
5689 op2r = force_reg (SImode, gen_rtx_SUBREG (SImode, operands[2], 4));
5690 op1l = force_reg (SImode, gen_rtx_SUBREG (SImode, op1shifted, 4));
5691 op2l = force_reg (SImode, gen_rtx_SUBREG (SImode, op2shifted, 4));
5692 }
5693 else
5694 {
5695 op1r = force_reg (SImode, gen_lowpart (SImode, operands[1]));
5696 op2r = force_reg (SImode, gen_lowpart (SImode, operands[2]));
5697 op1l = force_reg (SImode, gen_highpart (SImode, operands[1]));
5698 op2l = force_reg (SImode, gen_highpart (SImode, operands[2]));
5699 }
5700
5701 /* Emit multiplies for the cross products. */
5702 emit_insn (gen_umulsidi3 (cross_product1, op2r, op1l));
5703 emit_insn (gen_umulsidi3 (cross_product2, op2l, op1r));
5704
5705 /* Emit a multiply for the low sub-word. */
5706 emit_insn (gen_umulsidi3 (low_product, copy_rtx (op2r), copy_rtx (op1r)));
5707
5708 if (TARGET_64BIT)
5709 {
5710 rtx cross_scratch = gen_reg_rtx (DImode);
5711 rtx cross_product = gen_reg_rtx (DImode);
5712
5713 /* Sum the cross products and shift them into proper position. */
5714 emit_insn (gen_adddi3 (cross_scratch, cross_product1, cross_product2));
5715 emit_insn (gen_ashldi3 (cross_product, cross_scratch, GEN_INT (32)));
5716
5717 /* Add the cross product to the low product and store the result
5718 into the output operand . */
5719 emit_insn (gen_adddi3 (operands[0], cross_product, low_product));
5720 }
5721 else
5722 {
5723 rtx cross_scratch = gen_reg_rtx (SImode);
5724
5725 /* Sum cross products. */
5726 emit_move_insn (cross_scratch,
5727 gen_rtx_PLUS (SImode,
5728 gen_lowpart (SImode, cross_product1),
5729 gen_lowpart (SImode, cross_product2)));
5730 emit_move_insn (gen_lowpart (SImode, operands[0]),
5731 gen_lowpart (SImode, low_product));
5732 emit_move_insn (gen_highpart (SImode, operands[0]),
5733 gen_rtx_PLUS (SImode,
5734 gen_highpart (SImode, low_product),
5735 cross_scratch));
5736 }
5737 DONE;
5738 }")
5739
5740 ;;; Division and mod.
5741 (define_expand "divsi3"
5742 [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5743 (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5744 (parallel [(set (reg:SI 29) (div:SI (reg:SI 26) (reg:SI 25)))
5745 (clobber (reg:SI 1))
5746 (clobber (reg:SI 26))
5747 (clobber (reg:SI 25))
5748 (clobber (match_dup 3))])
5749 (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5750 ""
5751 "
5752 {
5753 operands[3] = gen_rtx_REG (SImode, TARGET_64BIT ? 2 : 31);
5754 if (pa_emit_hpdiv_const (operands, 0))
5755 DONE;
5756 }")
5757
5758 (define_insn ""
5759 [(set (reg:SI 29)
5760 (div:SI (match_operand:SI 1 "r26_operand" "")
5761 (match_operand:SI 0 "div_operand" "")))
5762 (clobber (match_operand:SI 2 "register_operand" "=a"))
5763 (clobber (reg:SI 26))
5764 (clobber (reg:SI 25))
5765 (clobber (reg:SI 31))]
5766 "!TARGET_64BIT"
5767 "*
5768 return pa_output_div_insn (operands, 0, insn);"
5769 [(set_attr "type" "milli")
5770 (set (attr "length")
5771 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5772 (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5773
5774 (define_insn ""
5775 [(set (reg:SI 29)
5776 (div:SI (match_operand:SI 1 "r26_operand" "")
5777 (match_operand:SI 0 "div_operand" "")))
5778 (clobber (match_operand:SI 2 "register_operand" "=a"))
5779 (clobber (reg:SI 26))
5780 (clobber (reg:SI 25))
5781 (clobber (reg:SI 2))]
5782 "TARGET_64BIT"
5783 "*
5784 return pa_output_div_insn (operands, 0, insn);"
5785 [(set_attr "type" "milli")
5786 (set (attr "length")
5787 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5788 (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5789
5790 (define_expand "udivsi3"
5791 [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5792 (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5793 (parallel [(set (reg:SI 29) (udiv:SI (reg:SI 26) (reg:SI 25)))
5794 (clobber (reg:SI 1))
5795 (clobber (reg:SI 26))
5796 (clobber (reg:SI 25))
5797 (clobber (match_dup 3))])
5798 (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5799 ""
5800 "
5801 {
5802 operands[3] = gen_rtx_REG (SImode, TARGET_64BIT ? 2 : 31);
5803 if (pa_emit_hpdiv_const (operands, 1))
5804 DONE;
5805 }")
5806
5807 (define_insn ""
5808 [(set (reg:SI 29)
5809 (udiv:SI (match_operand:SI 1 "r26_operand" "")
5810 (match_operand:SI 0 "div_operand" "")))
5811 (clobber (match_operand:SI 2 "register_operand" "=a"))
5812 (clobber (reg:SI 26))
5813 (clobber (reg:SI 25))
5814 (clobber (reg:SI 31))]
5815 "!TARGET_64BIT"
5816 "*
5817 return pa_output_div_insn (operands, 1, insn);"
5818 [(set_attr "type" "milli")
5819 (set (attr "length")
5820 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5821 (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5822
5823 (define_insn ""
5824 [(set (reg:SI 29)
5825 (udiv:SI (match_operand:SI 1 "r26_operand" "")
5826 (match_operand:SI 0 "div_operand" "")))
5827 (clobber (match_operand:SI 2 "register_operand" "=a"))
5828 (clobber (reg:SI 26))
5829 (clobber (reg:SI 25))
5830 (clobber (reg:SI 2))]
5831 "TARGET_64BIT"
5832 "*
5833 return pa_output_div_insn (operands, 1, insn);"
5834 [(set_attr "type" "milli")
5835 (set (attr "length")
5836 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5837 (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5838
5839 (define_expand "modsi3"
5840 [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5841 (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5842 (parallel [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
5843 (clobber (reg:SI 1))
5844 (clobber (reg:SI 26))
5845 (clobber (reg:SI 25))
5846 (clobber (match_dup 3))])
5847 (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5848 ""
5849 "
5850 {
5851 operands[3] = gen_rtx_REG (SImode, TARGET_64BIT ? 2 : 31);
5852 }")
5853
5854 (define_insn ""
5855 [(set (reg:SI 29)
5856 (mod:SI (match_operand:SI 1 "r26_operand" "")
5857 (match_operand:SI 0 "r25_operand" "")))
5858 (clobber (match_operand:SI 2 "register_operand" "=a"))
5859 (clobber (reg:SI 26))
5860 (clobber (reg:SI 25))
5861 (clobber (reg:SI 31))]
5862 "!TARGET_64BIT"
5863 "*
5864 return pa_output_mod_insn (0, insn);"
5865 [(set_attr "type" "milli")
5866 (set (attr "length")
5867 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5868 (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5869
5870 (define_insn ""
5871 [(set (reg:SI 29)
5872 (mod:SI (match_operand:SI 1 "r26_operand" "")
5873 (match_operand:SI 0 "r25_operand" "")))
5874 (clobber (match_operand:SI 2 "register_operand" "=a"))
5875 (clobber (reg:SI 26))
5876 (clobber (reg:SI 25))
5877 (clobber (reg:SI 2))]
5878 "TARGET_64BIT"
5879 "*
5880 return pa_output_mod_insn (0, insn);"
5881 [(set_attr "type" "milli")
5882 (set (attr "length")
5883 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5884 (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5885
5886 (define_expand "umodsi3"
5887 [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5888 (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5889 (parallel [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
5890 (clobber (reg:SI 1))
5891 (clobber (reg:SI 26))
5892 (clobber (reg:SI 25))
5893 (clobber (match_dup 3))])
5894 (set (match_operand:SI 0 "move_dest_operand" "") (reg:SI 29))]
5895 ""
5896 "
5897 {
5898 operands[3] = gen_rtx_REG (SImode, TARGET_64BIT ? 2 : 31);
5899 }")
5900
5901 (define_insn ""
5902 [(set (reg:SI 29)
5903 (umod:SI (match_operand:SI 1 "r26_operand" "")
5904 (match_operand:SI 0 "r25_operand" "")))
5905 (clobber (match_operand:SI 2 "register_operand" "=a"))
5906 (clobber (reg:SI 26))
5907 (clobber (reg:SI 25))
5908 (clobber (reg:SI 31))]
5909 "!TARGET_64BIT"
5910 "*
5911 return pa_output_mod_insn (1, insn);"
5912 [(set_attr "type" "milli")
5913 (set (attr "length")
5914 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5915 (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5916
5917 (define_insn ""
5918 [(set (reg:SI 29)
5919 (umod:SI (match_operand:SI 1 "r26_operand" "")
5920 (match_operand:SI 0 "r25_operand" "")))
5921 (clobber (match_operand:SI 2 "register_operand" "=a"))
5922 (clobber (reg:SI 26))
5923 (clobber (reg:SI 25))
5924 (clobber (reg:SI 2))]
5925 "TARGET_64BIT"
5926 "*
5927 return pa_output_mod_insn (1, insn);"
5928 [(set_attr "type" "milli")
5929 (set (attr "length")
5930 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
5931 (symbol_ref "pa_attr_length_millicode_call (insn)")))])
5932
5933 ;;- and instructions
5934 ;; We define DImode `and` so with DImode `not` we can get
5935 ;; DImode `andn`. Other combinations are possible.
5936
5937 (define_expand "anddi3"
5938 [(set (match_operand:DI 0 "register_operand" "")
5939 (and:DI (match_operand:DI 1 "register_operand" "")
5940 (match_operand:DI 2 "and_operand" "")))]
5941 "TARGET_64BIT"
5942 "")
5943
5944 (define_insn ""
5945 [(set (match_operand:DI 0 "register_operand" "=r,r")
5946 (and:DI (match_operand:DI 1 "register_operand" "%?r,0")
5947 (match_operand:DI 2 "and_operand" "rO,P")))]
5948 "TARGET_64BIT"
5949 "* return pa_output_64bit_and (operands); "
5950 [(set_attr "type" "binary")
5951 (set_attr "length" "4")])
5952
5953 ; The ? for op1 makes reload prefer zdepi instead of loading a huge
5954 ; constant with ldil;ldo.
5955 (define_insn "andsi3"
5956 [(set (match_operand:SI 0 "register_operand" "=r,r")
5957 (and:SI (match_operand:SI 1 "register_operand" "%?r,0")
5958 (match_operand:SI 2 "and_operand" "rO,P")))]
5959 ""
5960 "* return pa_output_and (operands); "
5961 [(set_attr "type" "binary,shift")
5962 (set_attr "length" "4,4")])
5963
5964 (define_insn ""
5965 [(set (match_operand:DI 0 "register_operand" "=r")
5966 (and:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
5967 (match_operand:DI 2 "register_operand" "r")))]
5968 "TARGET_64BIT"
5969 "andcm %2,%1,%0"
5970 [(set_attr "type" "binary")
5971 (set_attr "length" "4")])
5972
5973 (define_insn ""
5974 [(set (match_operand:SI 0 "register_operand" "=r")
5975 (and:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
5976 (match_operand:SI 2 "register_operand" "r")))]
5977 ""
5978 "andcm %2,%1,%0"
5979 [(set_attr "type" "binary")
5980 (set_attr "length" "4")])
5981
5982 (define_expand "iordi3"
5983 [(set (match_operand:DI 0 "register_operand" "")
5984 (ior:DI (match_operand:DI 1 "register_operand" "")
5985 (match_operand:DI 2 "reg_or_cint_ior_operand" "")))]
5986 "TARGET_64BIT"
5987 "")
5988
5989 (define_insn ""
5990 [(set (match_operand:DI 0 "register_operand" "=r,r")
5991 (ior:DI (match_operand:DI 1 "register_operand" "0,0")
5992 (match_operand:DI 2 "cint_ior_operand" "M,i")))]
5993 "TARGET_64BIT"
5994 "* return pa_output_64bit_ior (operands); "
5995 [(set_attr "type" "binary,shift")
5996 (set_attr "length" "4,4")])
5997
5998 (define_insn ""
5999 [(set (match_operand:DI 0 "register_operand" "=r")
6000 (ior:DI (match_operand:DI 1 "register_operand" "%r")
6001 (match_operand:DI 2 "register_operand" "r")))]
6002 "TARGET_64BIT"
6003 "or %1,%2,%0"
6004 [(set_attr "type" "binary")
6005 (set_attr "length" "4")])
6006
6007 ;; Need a define_expand because we've run out of CONST_OK... characters.
6008 (define_expand "iorsi3"
6009 [(set (match_operand:SI 0 "register_operand" "")
6010 (ior:SI (match_operand:SI 1 "register_operand" "")
6011 (match_operand:SI 2 "reg_or_cint_ior_operand" "")))]
6012 ""
6013 "")
6014
6015 (define_insn ""
6016 [(set (match_operand:SI 0 "register_operand" "=r,r")
6017 (ior:SI (match_operand:SI 1 "register_operand" "0,0")
6018 (match_operand:SI 2 "cint_ior_operand" "M,i")))]
6019 ""
6020 "* return pa_output_ior (operands); "
6021 [(set_attr "type" "binary,shift")
6022 (set_attr "length" "4,4")])
6023
6024 (define_insn ""
6025 [(set (match_operand:SI 0 "register_operand" "=r")
6026 (ior:SI (match_operand:SI 1 "register_operand" "%r")
6027 (match_operand:SI 2 "register_operand" "r")))]
6028 ""
6029 "or %1,%2,%0"
6030 [(set_attr "type" "binary")
6031 (set_attr "length" "4")])
6032
6033 (define_expand "xordi3"
6034 [(set (match_operand:DI 0 "register_operand" "")
6035 (xor:DI (match_operand:DI 1 "register_operand" "")
6036 (match_operand:DI 2 "register_operand" "")))]
6037 "TARGET_64BIT"
6038 "")
6039
6040 (define_insn ""
6041 [(set (match_operand:DI 0 "register_operand" "=r")
6042 (xor:DI (match_operand:DI 1 "register_operand" "%r")
6043 (match_operand:DI 2 "register_operand" "r")))]
6044 "TARGET_64BIT"
6045 "xor %1,%2,%0"
6046 [(set_attr "type" "binary")
6047 (set_attr "length" "4")])
6048
6049 (define_insn "xorsi3"
6050 [(set (match_operand:SI 0 "register_operand" "=r")
6051 (xor:SI (match_operand:SI 1 "register_operand" "%r")
6052 (match_operand:SI 2 "register_operand" "r")))]
6053 ""
6054 "xor %1,%2,%0"
6055 [(set_attr "type" "binary")
6056 (set_attr "length" "4")])
6057
6058 (define_expand "negdi2"
6059 [(set (match_operand:DI 0 "register_operand" "")
6060 (neg:DI (match_operand:DI 1 "register_operand" "")))]
6061 ""
6062 "")
6063
6064 (define_insn ""
6065 [(set (match_operand:DI 0 "register_operand" "=r")
6066 (neg:DI (match_operand:DI 1 "register_operand" "r")))]
6067 "!TARGET_64BIT"
6068 "sub %%r0,%R1,%R0\;{subb|sub,b} %%r0,%1,%0"
6069 [(set_attr "type" "multi")
6070 (set_attr "length" "8")])
6071
6072 (define_insn ""
6073 [(set (match_operand:DI 0 "register_operand" "=r")
6074 (neg:DI (match_operand:DI 1 "register_operand" "r")))]
6075 "TARGET_64BIT"
6076 "sub %%r0,%1,%0"
6077 [(set_attr "type" "unary")
6078 (set_attr "length" "4")])
6079
6080 (define_insn "negti2"
6081 [(set (match_operand:TI 0 "register_operand" "=r")
6082 (neg:TI (match_operand:TI 1 "register_operand" "r")))]
6083 "TARGET_64BIT"
6084 "sub %%r0,%R1,%R0\;sub,db %%r0,%1,%0"
6085 [(set_attr "type" "multi")
6086 (set_attr "length" "8")])
6087
6088 (define_expand "negvdi2"
6089 [(parallel [(set (match_operand:DI 0 "register_operand" "")
6090 (neg:DI (match_operand:DI 1 "register_operand" "")))
6091 (trap_if (ne (neg:TI (sign_extend:TI (match_dup 1)))
6092 (sign_extend:TI (neg:DI (match_dup 1))))
6093 (const_int 0))])]
6094 ""
6095 "")
6096
6097 (define_insn ""
6098 [(set (match_operand:DI 0 "register_operand" "=r")
6099 (neg:DI (match_operand:DI 1 "register_operand" "r")))
6100 (trap_if (ne (neg:TI (sign_extend:TI (match_dup 1)))
6101 (sign_extend:TI (neg:DI (match_dup 1))))
6102 (const_int 0))]
6103 "!TARGET_64BIT"
6104 "sub %%r0,%R1,%R0\;{subbo|sub,b,tsv} %%r0,%1,%0"
6105 [(set_attr "type" "multi")
6106 (set_attr "length" "8")])
6107
6108 (define_insn ""
6109 [(set (match_operand:DI 0 "register_operand" "=r")
6110 (neg:DI (match_operand:DI 1 "register_operand" "r")))
6111 (trap_if (ne (neg:TI (sign_extend:TI (match_dup 1)))
6112 (sign_extend:TI (neg:DI (match_dup 1))))
6113 (const_int 0))]
6114 "TARGET_64BIT"
6115 "sub,tsv %%r0,%1,%0"
6116 [(set_attr "type" "unary")
6117 (set_attr "length" "4")])
6118
6119 (define_insn "negvti2"
6120 [(set (match_operand:TI 0 "register_operand" "=r")
6121 (neg:TI (match_operand:TI 1 "register_operand" "r")))
6122 (trap_if (ne (neg:OI (sign_extend:OI (match_dup 1)))
6123 (sign_extend:OI (neg:TI (match_dup 1))))
6124 (const_int 0))]
6125 "TARGET_64BIT"
6126 "sub %%r0,%R1,%R0\;sub,db,tsv %%r0,%1,%0"
6127 [(set_attr "type" "multi")
6128 (set_attr "length" "8")])
6129
6130 (define_insn "negsi2"
6131 [(set (match_operand:SI 0 "register_operand" "=r")
6132 (neg:SI (match_operand:SI 1 "register_operand" "r")))]
6133 ""
6134 "sub %%r0,%1,%0"
6135 [(set_attr "type" "unary")
6136 (set_attr "length" "4")])
6137
6138 (define_insn "negvsi2"
6139 [(set (match_operand:SI 0 "register_operand" "=r")
6140 (neg:SI (match_operand:SI 1 "register_operand" "r")))
6141 (trap_if (ne (neg:DI (sign_extend:DI (match_dup 1)))
6142 (sign_extend:DI (neg:SI (match_dup 1))))
6143 (const_int 0))]
6144 ""
6145 "{subo|sub,tsv} %%r0,%1,%0"
6146 [(set_attr "type" "unary")
6147 (set_attr "length" "4")])
6148
6149 (define_expand "one_cmpldi2"
6150 [(set (match_operand:DI 0 "register_operand" "")
6151 (not:DI (match_operand:DI 1 "register_operand" "")))]
6152 ""
6153 "
6154 {
6155 }")
6156
6157 (define_insn ""
6158 [(set (match_operand:DI 0 "register_operand" "=r")
6159 (not:DI (match_operand:DI 1 "register_operand" "r")))]
6160 "!TARGET_64BIT"
6161 "uaddcm %%r0,%1,%0\;uaddcm %%r0,%R1,%R0"
6162 [(set_attr "type" "unary")
6163 (set_attr "length" "8")])
6164
6165 (define_insn ""
6166 [(set (match_operand:DI 0 "register_operand" "=r")
6167 (not:DI (match_operand:DI 1 "register_operand" "r")))]
6168 "TARGET_64BIT"
6169 "uaddcm %%r0,%1,%0"
6170 [(set_attr "type" "unary")
6171 (set_attr "length" "4")])
6172
6173 (define_insn "one_cmplsi2"
6174 [(set (match_operand:SI 0 "register_operand" "=r")
6175 (not:SI (match_operand:SI 1 "register_operand" "r")))]
6176 ""
6177 "uaddcm %%r0,%1,%0"
6178 [(set_attr "type" "unary")
6179 (set_attr "length" "4")])
6180
6181 ;; Floating point arithmetic instructions.
6182
6183 (define_insn "adddf3"
6184 [(set (match_operand:DF 0 "register_operand" "=f")
6185 (plus:DF (match_operand:DF 1 "register_operand" "f")
6186 (match_operand:DF 2 "register_operand" "f")))]
6187 "! TARGET_SOFT_FLOAT"
6188 "fadd,dbl %1,%2,%0"
6189 [(set_attr "type" "fpalu")
6190 (set_attr "pa_combine_type" "faddsub")
6191 (set_attr "length" "4")])
6192
6193 (define_insn "addsf3"
6194 [(set (match_operand:SF 0 "register_operand" "=f")
6195 (plus:SF (match_operand:SF 1 "register_operand" "f")
6196 (match_operand:SF 2 "register_operand" "f")))]
6197 "! TARGET_SOFT_FLOAT"
6198 "fadd,sgl %1,%2,%0"
6199 [(set_attr "type" "fpalu")
6200 (set_attr "pa_combine_type" "faddsub")
6201 (set_attr "length" "4")])
6202
6203 (define_insn "subdf3"
6204 [(set (match_operand:DF 0 "register_operand" "=f")
6205 (minus:DF (match_operand:DF 1 "register_operand" "f")
6206 (match_operand:DF 2 "register_operand" "f")))]
6207 "! TARGET_SOFT_FLOAT"
6208 "fsub,dbl %1,%2,%0"
6209 [(set_attr "type" "fpalu")
6210 (set_attr "pa_combine_type" "faddsub")
6211 (set_attr "length" "4")])
6212
6213 (define_insn "subsf3"
6214 [(set (match_operand:SF 0 "register_operand" "=f")
6215 (minus:SF (match_operand:SF 1 "register_operand" "f")
6216 (match_operand:SF 2 "register_operand" "f")))]
6217 "! TARGET_SOFT_FLOAT"
6218 "fsub,sgl %1,%2,%0"
6219 [(set_attr "type" "fpalu")
6220 (set_attr "pa_combine_type" "faddsub")
6221 (set_attr "length" "4")])
6222
6223 (define_insn "muldf3"
6224 [(set (match_operand:DF 0 "register_operand" "=f")
6225 (mult:DF (match_operand:DF 1 "register_operand" "f")
6226 (match_operand:DF 2 "register_operand" "f")))]
6227 "! TARGET_SOFT_FLOAT"
6228 "fmpy,dbl %1,%2,%0"
6229 [(set_attr "type" "fpmuldbl")
6230 (set_attr "pa_combine_type" "fmpy")
6231 (set_attr "length" "4")])
6232
6233 (define_insn "mulsf3"
6234 [(set (match_operand:SF 0 "register_operand" "=f")
6235 (mult:SF (match_operand:SF 1 "register_operand" "f")
6236 (match_operand:SF 2 "register_operand" "f")))]
6237 "! TARGET_SOFT_FLOAT"
6238 "fmpy,sgl %1,%2,%0"
6239 [(set_attr "type" "fpmulsgl")
6240 (set_attr "pa_combine_type" "fmpy")
6241 (set_attr "length" "4")])
6242
6243 (define_insn "divdf3"
6244 [(set (match_operand:DF 0 "register_operand" "=f")
6245 (div:DF (match_operand:DF 1 "register_operand" "f")
6246 (match_operand:DF 2 "register_operand" "f")))]
6247 "! TARGET_SOFT_FLOAT"
6248 "fdiv,dbl %1,%2,%0"
6249 [(set_attr "type" "fpdivdbl")
6250 (set_attr "length" "4")])
6251
6252 (define_insn "divsf3"
6253 [(set (match_operand:SF 0 "register_operand" "=f")
6254 (div:SF (match_operand:SF 1 "register_operand" "f")
6255 (match_operand:SF 2 "register_operand" "f")))]
6256 "! TARGET_SOFT_FLOAT"
6257 "fdiv,sgl %1,%2,%0"
6258 [(set_attr "type" "fpdivsgl")
6259 (set_attr "length" "4")])
6260
6261 ;; Processors prior to PA 2.0 don't have a fneg instruction. Fast
6262 ;; negation can be done by subtracting from plus zero. However, this
6263 ;; violates the IEEE standard when negating plus and minus zero.
6264 ;; The slow path toggles the sign bit in the general registers.
6265 (define_expand "negdf2"
6266 [(set (match_operand:DF 0 "register_operand" "")
6267 (neg:DF (match_operand:DF 1 "register_operand" "")))]
6268 "!TARGET_SOFT_FLOAT"
6269 {
6270 if (TARGET_PA_20 || !flag_signed_zeros)
6271 emit_insn (gen_negdf2_fast (operands[0], operands[1]));
6272 else
6273 emit_insn (gen_negdf2_slow (operands[0], operands[1]));
6274 DONE;
6275 })
6276
6277 (define_insn "negdf2_slow"
6278 [(set (match_operand:DF 0 "register_operand" "=r")
6279 (neg:DF (match_operand:DF 1 "register_operand" "r")))]
6280 "!TARGET_SOFT_FLOAT && !TARGET_PA_20"
6281 "*
6282 {
6283 if (rtx_equal_p (operands[0], operands[1]))
6284 return \"and,< %1,%1,%0\;depi,tr 1,0,1,%0\;depi 0,0,1,%0\";
6285 else
6286 return \"and,< %1,%1,%0\;depi,tr 1,0,1,%0\;depi 0,0,1,%0\;copy %R1,%R0\";
6287 }"
6288 [(set_attr "type" "multi")
6289 (set (attr "length")
6290 (if_then_else (match_test "rtx_equal_p (operands[0], operands[1])")
6291 (const_int 12)
6292 (const_int 16)))])
6293
6294 (define_insn "negdf2_fast"
6295 [(set (match_operand:DF 0 "register_operand" "=f")
6296 (neg:DF (match_operand:DF 1 "register_operand" "f")))]
6297 "!TARGET_SOFT_FLOAT"
6298 "*
6299 {
6300 if (TARGET_PA_20)
6301 return \"fneg,dbl %1,%0\";
6302 else
6303 return \"fsub,dbl %%fr0,%1,%0\";
6304 }"
6305 [(set_attr "type" "fpalu")
6306 (set_attr "length" "4")])
6307
6308 (define_expand "negsf2"
6309 [(set (match_operand:SF 0 "register_operand" "")
6310 (neg:SF (match_operand:SF 1 "register_operand" "")))]
6311 "!TARGET_SOFT_FLOAT"
6312 {
6313 if (TARGET_PA_20 || !flag_signed_zeros)
6314 emit_insn (gen_negsf2_fast (operands[0], operands[1]));
6315 else
6316 emit_insn (gen_negsf2_slow (operands[0], operands[1]));
6317 DONE;
6318 })
6319
6320 (define_insn "negsf2_slow"
6321 [(set (match_operand:SF 0 "register_operand" "=r")
6322 (neg:SF (match_operand:SF 1 "register_operand" "r")))]
6323 "!TARGET_SOFT_FLOAT && !TARGET_PA_20"
6324 "and,< %1,%1,%0\;depi,tr 1,0,1,%0\;depi 0,0,1,%0"
6325 [(set_attr "type" "multi")
6326 (set_attr "length" "12")])
6327
6328 (define_insn "negsf2_fast"
6329 [(set (match_operand:SF 0 "register_operand" "=f")
6330 (neg:SF (match_operand:SF 1 "register_operand" "f")))]
6331 "!TARGET_SOFT_FLOAT"
6332 "*
6333 {
6334 if (TARGET_PA_20)
6335 return \"fneg,sgl %1,%0\";
6336 else
6337 return \"fsub,sgl %%fr0,%1,%0\";
6338 }"
6339 [(set_attr "type" "fpalu")
6340 (set_attr "length" "4")])
6341
6342 (define_insn "absdf2"
6343 [(set (match_operand:DF 0 "register_operand" "=f")
6344 (abs:DF (match_operand:DF 1 "register_operand" "f")))]
6345 "! TARGET_SOFT_FLOAT"
6346 "fabs,dbl %1,%0"
6347 [(set_attr "type" "fpalu")
6348 (set_attr "length" "4")])
6349
6350 (define_insn "abssf2"
6351 [(set (match_operand:SF 0 "register_operand" "=f")
6352 (abs:SF (match_operand:SF 1 "register_operand" "f")))]
6353 "! TARGET_SOFT_FLOAT"
6354 "fabs,sgl %1,%0"
6355 [(set_attr "type" "fpalu")
6356 (set_attr "length" "4")])
6357
6358 (define_insn "sqrtdf2"
6359 [(set (match_operand:DF 0 "register_operand" "=f")
6360 (sqrt:DF (match_operand:DF 1 "register_operand" "f")))]
6361 "! TARGET_SOFT_FLOAT"
6362 "fsqrt,dbl %1,%0"
6363 [(set_attr "type" "fpsqrtdbl")
6364 (set_attr "length" "4")])
6365
6366 (define_insn "sqrtsf2"
6367 [(set (match_operand:SF 0 "register_operand" "=f")
6368 (sqrt:SF (match_operand:SF 1 "register_operand" "f")))]
6369 "! TARGET_SOFT_FLOAT"
6370 "fsqrt,sgl %1,%0"
6371 [(set_attr "type" "fpsqrtsgl")
6372 (set_attr "length" "4")])
6373
6374 ;; PA 2.0 floating point instructions
6375
6376 ; fmpyfadd patterns
6377 (define_insn "fmadf4"
6378 [(set (match_operand:DF 0 "register_operand" "=f")
6379 (fma:DF (match_operand:DF 1 "register_operand" "f")
6380 (match_operand:DF 2 "register_operand" "f")
6381 (match_operand:DF 3 "register_operand" "f")))]
6382 "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6383 "fmpyfadd,dbl %1,%2,%3,%0"
6384 [(set_attr "type" "fpmuldbl")
6385 (set_attr "length" "4")])
6386
6387 (define_insn "fmasf4"
6388 [(set (match_operand:SF 0 "register_operand" "=f")
6389 (fma:SF (match_operand:SF 1 "register_operand" "f")
6390 (match_operand:SF 2 "register_operand" "f")
6391 (match_operand:SF 3 "register_operand" "f")))]
6392 "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6393 "fmpyfadd,sgl %1,%2,%3,%0"
6394 [(set_attr "type" "fpmulsgl")
6395 (set_attr "length" "4")])
6396
6397 ; fmpynfadd patterns
6398 (define_insn "fnmadf4"
6399 [(set (match_operand:DF 0 "register_operand" "=f")
6400 (fma:DF (neg:DF (match_operand:DF 1 "register_operand" "f"))
6401 (match_operand:DF 2 "register_operand" "f")
6402 (match_operand:DF 3 "register_operand" "f")))]
6403 "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6404 "fmpynfadd,dbl %1,%2,%3,%0"
6405 [(set_attr "type" "fpmuldbl")
6406 (set_attr "length" "4")])
6407
6408 (define_insn "fnmasf4"
6409 [(set (match_operand:SF 0 "register_operand" "=f")
6410 (fma:SF (neg:SF (match_operand:SF 1 "register_operand" "f"))
6411 (match_operand:SF 2 "register_operand" "f")
6412 (match_operand:SF 3 "register_operand" "f")))]
6413 "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6414 "fmpynfadd,sgl %1,%2,%3,%0"
6415 [(set_attr "type" "fpmulsgl")
6416 (set_attr "length" "4")])
6417
6418 ; fnegabs patterns
6419 (define_insn ""
6420 [(set (match_operand:DF 0 "register_operand" "=f")
6421 (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))]
6422 "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6423 "fnegabs,dbl %1,%0"
6424 [(set_attr "type" "fpalu")
6425 (set_attr "length" "4")])
6426
6427 (define_insn ""
6428 [(set (match_operand:SF 0 "register_operand" "=f")
6429 (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))]
6430 "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
6431 "fnegabs,sgl %1,%0"
6432 [(set_attr "type" "fpalu")
6433 (set_attr "length" "4")])
6434
6435 (define_insn ""
6436 [(set (match_operand:DF 0 "register_operand" "=f")
6437 (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))
6438 (set (match_operand:DF 2 "register_operand" "=&f") (abs:DF (match_dup 1)))]
6439 "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6440 && ! reg_overlap_mentioned_p (operands[2], operands[1]))"
6441 "#"
6442 [(set_attr "type" "fpalu")
6443 (set_attr "length" "8")])
6444
6445 (define_split
6446 [(set (match_operand:DF 0 "register_operand" "")
6447 (neg:DF (abs:DF (match_operand:DF 1 "register_operand" ""))))
6448 (set (match_operand:DF 2 "register_operand" "") (abs:DF (match_dup 1)))]
6449 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6450 [(set (match_dup 2) (abs:DF (match_dup 1)))
6451 (set (match_dup 0) (neg:DF (abs:DF (match_dup 1))))]
6452 "")
6453
6454 (define_insn ""
6455 [(set (match_operand:SF 0 "register_operand" "=f")
6456 (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))
6457 (set (match_operand:SF 2 "register_operand" "=&f") (abs:SF (match_dup 1)))]
6458 "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6459 && ! reg_overlap_mentioned_p (operands[2], operands[1]))"
6460 "#"
6461 [(set_attr "type" "fpalu")
6462 (set_attr "length" "8")])
6463
6464 (define_split
6465 [(set (match_operand:SF 0 "register_operand" "")
6466 (neg:SF (abs:SF (match_operand:SF 1 "register_operand" ""))))
6467 (set (match_operand:SF 2 "register_operand" "") (abs:SF (match_dup 1)))]
6468 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6469 [(set (match_dup 2) (abs:SF (match_dup 1)))
6470 (set (match_dup 0) (neg:SF (abs:SF (match_dup 1))))]
6471 "")
6472
6473 ;; Negating a multiply can be faked by adding zero in a fused multiply-add
6474 ;; instruction if we can ignore the sign of zero.
6475 (define_insn ""
6476 [(set (match_operand:DF 0 "register_operand" "=f")
6477 (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
6478 (match_operand:DF 2 "register_operand" "f"))))]
6479 "!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros"
6480 "fmpynfadd,dbl %1,%2,%%fr0,%0"
6481 [(set_attr "type" "fpmuldbl")
6482 (set_attr "length" "4")])
6483
6484 (define_insn ""
6485 [(set (match_operand:SF 0 "register_operand" "=f")
6486 (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
6487 (match_operand:SF 2 "register_operand" "f"))))]
6488 "!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros"
6489 "fmpynfadd,sgl %1,%2,%%fr0,%0"
6490 [(set_attr "type" "fpmuldbl")
6491 (set_attr "length" "4")])
6492
6493 (define_insn ""
6494 [(set (match_operand:DF 0 "register_operand" "=f")
6495 (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
6496 (match_operand:DF 2 "register_operand" "f"))))
6497 (set (match_operand:DF 3 "register_operand" "=&f")
6498 (mult:DF (match_dup 1) (match_dup 2)))]
6499 "(!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros
6500 && ! (reg_overlap_mentioned_p (operands[3], operands[1])
6501 || reg_overlap_mentioned_p (operands[3], operands[2])))"
6502 "#"
6503 [(set_attr "type" "fpmuldbl")
6504 (set_attr "length" "8")])
6505
6506 (define_split
6507 [(set (match_operand:DF 0 "register_operand" "")
6508 (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "")
6509 (match_operand:DF 2 "register_operand" ""))))
6510 (set (match_operand:DF 3 "register_operand" "")
6511 (mult:DF (match_dup 1) (match_dup 2)))]
6512 "!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros"
6513 [(set (match_dup 3) (mult:DF (match_dup 1) (match_dup 2)))
6514 (set (match_dup 0) (neg:DF (mult:DF (match_dup 1) (match_dup 2))))]
6515 "")
6516
6517 (define_insn ""
6518 [(set (match_operand:SF 0 "register_operand" "=f")
6519 (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
6520 (match_operand:SF 2 "register_operand" "f"))))
6521 (set (match_operand:SF 3 "register_operand" "=&f")
6522 (mult:SF (match_dup 1) (match_dup 2)))]
6523 "(!TARGET_SOFT_FLOAT && TARGET_PA_20 && !flag_signed_zeros
6524 && ! (reg_overlap_mentioned_p (operands[3], operands[1])
6525 || reg_overlap_mentioned_p (operands[3], operands[2])))"
6526 "#"
6527 [(set_attr "type" "fpmuldbl")
6528 (set_attr "length" "8")])
6529
6530 (define_split
6531 [(set (match_operand:SF 0 "register_operand" "")
6532 (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "")
6533 (match_operand:SF 2 "register_operand" ""))))
6534 (set (match_operand:SF 3 "register_operand" "")
6535 (mult:SF (match_dup 1) (match_dup 2)))]
6536 "!TARGET_SOFT_FLOAT && TARGET_PA_20&& !flag_signed_zeros"
6537 [(set (match_dup 3) (mult:SF (match_dup 1) (match_dup 2)))
6538 (set (match_dup 0) (neg:SF (mult:SF (match_dup 1) (match_dup 2))))]
6539 "")
6540
6541 ;;- Shift instructions
6542
6543 ;; Optimized special case of shifting.
6544
6545 (define_insn ""
6546 [(set (match_operand:SI 0 "register_operand" "=r")
6547 (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
6548 (const_int 24)))]
6549 ""
6550 "ldb%M1 %1,%0"
6551 [(set_attr "type" "load")
6552 (set_attr "length" "4")])
6553
6554 (define_insn ""
6555 [(set (match_operand:SI 0 "register_operand" "=r")
6556 (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
6557 (const_int 16)))]
6558 ""
6559 "ldh%M1 %1,%0"
6560 [(set_attr "type" "load")
6561 (set_attr "length" "4")])
6562
6563 (define_insn ""
6564 [(set (match_operand:SI 0 "register_operand" "=r")
6565 (plus:SI (ashift:SI (match_operand:SI 2 "register_operand" "r")
6566 (match_operand:SI 3 "shadd_operand" ""))
6567 (match_operand:SI 1 "register_operand" "r")))]
6568 ""
6569 "{sh%o3addl %2,%1,%0|shladd,l %2,%o3,%1,%0} "
6570 [(set_attr "type" "binary")
6571 (set_attr "length" "4")])
6572
6573 (define_insn ""
6574 [(set (match_operand:SI 0 "register_operand" "=r")
6575 (plus:SI (mult:SI (match_operand:SI 2 "register_operand" "r")
6576 (match_operand:SI 3 "mem_shadd_operand" ""))
6577 (match_operand:SI 1 "register_operand" "r")))]
6578 ""
6579 "*
6580 {
6581 int shift_val = exact_log2 (INTVAL (operands[3]));
6582 operands[3] = GEN_INT (shift_val);
6583 return \"{sh%o3addl %2,%1,%0|shladd,l %2,%o3,%1,%0}\";
6584 }"
6585 [(set_attr "type" "binary")
6586 (set_attr "length" "4")])
6587
6588 (define_insn ""
6589 [(set (match_operand:DI 0 "register_operand" "=r")
6590 (plus:DI (ashift:DI (match_operand:DI 2 "register_operand" "r")
6591 (match_operand:DI 3 "shadd_operand" ""))
6592 (match_operand:DI 1 "register_operand" "r")))]
6593 "TARGET_64BIT"
6594 "shladd,l %2,%o3,%1,%0"
6595 [(set_attr "type" "binary")
6596 (set_attr "length" "4")])
6597
6598 (define_insn ""
6599 [(set (match_operand:DI 0 "register_operand" "=r")
6600 (plus:DI (mult:DI (match_operand:DI 2 "register_operand" "r")
6601 (match_operand:DI 3 "mem_shadd_operand" ""))
6602 (match_operand:DI 1 "register_operand" "r")))]
6603 "TARGET_64BIT"
6604 "*
6605 {
6606 int shift_val = exact_log2 (INTVAL (operands[3]));
6607 operands[3] = GEN_INT (shift_val);
6608 return \"shladd,l %2,%o3,%1,%0\";
6609 }"
6610 [(set_attr "type" "binary")
6611 (set_attr "length" "4")])
6612
6613 (define_expand "ashlsi3"
6614 [(set (match_operand:SI 0 "register_operand" "")
6615 (ashift:SI (match_operand:SI 1 "lhs_lshift_operand" "")
6616 (match_operand:SI 2 "arith32_operand" "")))]
6617 ""
6618 "
6619 {
6620 if (GET_CODE (operands[2]) != CONST_INT)
6621 {
6622 rtx temp = gen_reg_rtx (SImode);
6623 emit_insn (gen_subsi3 (temp, GEN_INT (31), operands[2]));
6624 if (GET_CODE (operands[1]) == CONST_INT)
6625 emit_insn (gen_zvdep_imm32 (operands[0], operands[1], temp));
6626 else
6627 emit_insn (gen_zvdep32 (operands[0], operands[1], temp));
6628 DONE;
6629 }
6630 /* Make sure both inputs are not constants,
6631 there are no patterns for that. */
6632 operands[1] = force_reg (SImode, operands[1]);
6633 }")
6634
6635 (define_insn ""
6636 [(set (match_operand:SI 0 "register_operand" "=r")
6637 (ashift:SI (match_operand:SI 1 "register_operand" "r")
6638 (match_operand:SI 2 "const_int_operand" "n")))]
6639 ""
6640 "{zdep|depw,z} %1,%P2,%L2,%0"
6641 [(set_attr "type" "shift")
6642 (set_attr "length" "4")])
6643
6644 ; Match cases of op1 a CONST_INT here that zvdep_imm32 doesn't handle.
6645 ; Doing it like this makes slightly better code since reload can
6646 ; replace a register with a known value in range -16..15 with a
6647 ; constant. Ideally, we would like to merge zvdep32 and zvdep_imm32,
6648 ; but since we have no more CONST_OK... characters, that is not
6649 ; possible.
6650 (define_insn "zvdep32"
6651 [(set (match_operand:SI 0 "register_operand" "=r,r")
6652 (ashift:SI (match_operand:SI 1 "arith5_operand" "r,L")
6653 (minus:SI (const_int 31)
6654 (match_operand:SI 2 "register_operand" "q,q"))))]
6655 ""
6656 "@
6657 {zvdep %1,32,%0|depw,z %1,%%sar,32,%0}
6658 {zvdepi %1,32,%0|depwi,z %1,%%sar,32,%0}"
6659 [(set_attr "type" "shift,shift")
6660 (set_attr "length" "4,4")])
6661
6662 (define_insn "zvdep_imm32"
6663 [(set (match_operand:SI 0 "register_operand" "=r")
6664 (ashift:SI (match_operand:SI 1 "lhs_lshift_cint_operand" "")
6665 (minus:SI (const_int 31)
6666 (match_operand:SI 2 "register_operand" "q"))))]
6667 ""
6668 "*
6669 {
6670 unsigned HOST_WIDE_INT x = UINTVAL (operands[1]);
6671 operands[2] = GEN_INT (4 + exact_log2 ((x >> 4) + 1));
6672 operands[1] = GEN_INT ((x & 0xf) - 0x10);
6673 return \"{zvdepi %1,%2,%0|depwi,z %1,%%sar,%2,%0}\";
6674 }"
6675 [(set_attr "type" "shift")
6676 (set_attr "length" "4")])
6677
6678 (define_insn "vdepi_ior"
6679 [(set (match_operand:SI 0 "register_operand" "=r")
6680 (ior:SI (ashift:SI (match_operand:SI 1 "const_int_operand" "")
6681 (minus:SI (const_int 31)
6682 (match_operand:SI 2 "register_operand" "q")))
6683 (match_operand:SI 3 "register_operand" "0")))]
6684 ; accept ...0001...1, can this be generalized?
6685 "exact_log2 (INTVAL (operands[1]) + 1) > 0"
6686 "*
6687 {
6688 HOST_WIDE_INT x = INTVAL (operands[1]);
6689 operands[2] = GEN_INT (exact_log2 (x + 1));
6690 return \"{vdepi -1,%2,%0|depwi -1,%%sar,%2,%0}\";
6691 }"
6692 [(set_attr "type" "shift")
6693 (set_attr "length" "4")])
6694
6695 (define_insn "vdepi_and"
6696 [(set (match_operand:SI 0 "register_operand" "=r")
6697 (and:SI (rotate:SI (match_operand:SI 1 "const_int_operand" "")
6698 (minus:SI (const_int 31)
6699 (match_operand:SI 2 "register_operand" "q")))
6700 (match_operand:SI 3 "register_operand" "0")))]
6701 ; this can be generalized...!
6702 "INTVAL (operands[1]) == -2"
6703 "*
6704 {
6705 HOST_WIDE_INT x = INTVAL (operands[1]);
6706 operands[2] = GEN_INT (exact_log2 ((~x) + 1));
6707 return \"{vdepi 0,%2,%0|depwi 0,%%sar,%2,%0}\";
6708 }"
6709 [(set_attr "type" "shift")
6710 (set_attr "length" "4")])
6711
6712 (define_expand "ashldi3"
6713 [(set (match_operand:DI 0 "register_operand" "")
6714 (ashift:DI (match_operand:DI 1 "lhs_lshift_operand" "")
6715 (match_operand:DI 2 "arith32_operand" "")))]
6716 ""
6717 "
6718 {
6719 if (!TARGET_64BIT)
6720 {
6721 if (REG_P (operands[0]) && GET_CODE (operands[2]) == CONST_INT)
6722 {
6723 unsigned HOST_WIDE_INT shift = UINTVAL (operands[2]);
6724 if (shift >= 1 && shift <= 31)
6725 {
6726 rtx dst = operands[0];
6727 rtx src = force_reg (DImode, operands[1]);
6728 emit_insn (gen_shd_internal (gen_highpart (SImode, dst),
6729 gen_lowpart (SImode, src),
6730 GEN_INT (32-shift),
6731 gen_highpart (SImode, src),
6732 GEN_INT (shift)));
6733 emit_insn (gen_ashlsi3 (gen_lowpart (SImode, dst),
6734 gen_lowpart (SImode, src),
6735 GEN_INT (shift)));
6736 DONE;
6737 }
6738 }
6739 /* Fallback to using optabs.cc's expand_doubleword_shift. */
6740 FAIL;
6741 }
6742 if (GET_CODE (operands[2]) != CONST_INT)
6743 {
6744 rtx temp = gen_reg_rtx (DImode);
6745 emit_insn (gen_subdi3 (temp, GEN_INT (63), operands[2]));
6746 if (GET_CODE (operands[1]) == CONST_INT)
6747 emit_insn (gen_zvdep_imm64 (operands[0], operands[1], temp));
6748 else
6749 emit_insn (gen_zvdep64 (operands[0], operands[1], temp));
6750 DONE;
6751 }
6752 /* Make sure both inputs are not constants,
6753 there are no patterns for that. */
6754 operands[1] = force_reg (DImode, operands[1]);
6755 }")
6756
6757 (define_expand "ashlti3"
6758 [(set (match_operand:TI 0 "register_operand" "")
6759 (ashift:TI (match_operand:TI 1 "lhs_lshift_operand" "")
6760 (match_operand:TI 2 "arith32_operand" "")))]
6761 "TARGET_64BIT"
6762 {
6763 if (REG_P (operands[0]) && GET_CODE (operands[2]) == CONST_INT)
6764 {
6765 unsigned HOST_WIDE_INT shift = UINTVAL (operands[2]);
6766 rtx dst = operands[0];
6767 rtx src = force_reg (TImode, operands[1]);
6768 if (shift >= 1 && shift <= 63)
6769 {
6770 emit_insn (gen_shrpd_internal (gen_highpart (DImode, dst),
6771 gen_lowpart (DImode, src),
6772 GEN_INT (64-shift),
6773 gen_highpart (DImode, src),
6774 GEN_INT (shift)));
6775 emit_insn (gen_ashldi3 (gen_lowpart (DImode, dst),
6776 gen_lowpart (DImode, src),
6777 GEN_INT (shift)));
6778 DONE;
6779 }
6780 else if (shift >= 64 && shift <= 127)
6781 {
6782 emit_insn (gen_ashldi3 (gen_highpart (DImode, dst),
6783 gen_lowpart (DImode, src),
6784 GEN_INT (shift - 64)));
6785 emit_move_insn (gen_lowpart (DImode, dst), GEN_INT (0));
6786 DONE;
6787 }
6788 }
6789 /* Fallback to using optabs.cc's expand_doubleword_shift. */
6790 FAIL;
6791 })
6792
6793 (define_insn ""
6794 [(set (match_operand:DI 0 "register_operand" "=r")
6795 (ashift:DI (match_operand:DI 1 "register_operand" "r")
6796 (match_operand:DI 2 "const_int_operand" "n")))]
6797 "TARGET_64BIT"
6798 "depd,z %1,%p2,%Q2,%0"
6799 [(set_attr "type" "shift")
6800 (set_attr "length" "4")])
6801
6802 ; Match cases of op1 a CONST_INT here that zvdep_imm64 doesn't handle.
6803 ; Doing it like this makes slightly better code since reload can
6804 ; replace a register with a known value in range -16..15 with a
6805 ; constant. Ideally, we would like to merge zvdep64 and zvdep_imm64,
6806 ; but since we have no more CONST_OK... characters, that is not
6807 ; possible.
6808 (define_insn "zvdep64"
6809 [(set (match_operand:DI 0 "register_operand" "=r,r")
6810 (ashift:DI (match_operand:DI 1 "arith5_operand" "r,L")
6811 (minus:DI (const_int 63)
6812 (match_operand:DI 2 "register_operand" "q,q"))))]
6813 "TARGET_64BIT"
6814 "@
6815 depd,z %1,%%sar,64,%0
6816 depdi,z %1,%%sar,64,%0"
6817 [(set_attr "type" "shift,shift")
6818 (set_attr "length" "4,4")])
6819
6820 (define_insn "zvdep_imm64"
6821 [(set (match_operand:DI 0 "register_operand" "=r")
6822 (ashift:DI (match_operand:DI 1 "lhs_lshift_cint_operand" "")
6823 (minus:DI (const_int 63)
6824 (match_operand:DI 2 "register_operand" "q"))))]
6825 "TARGET_64BIT"
6826 "*
6827 {
6828 unsigned HOST_WIDE_INT x = UINTVAL (operands[1]);
6829 operands[2] = GEN_INT (4 + exact_log2 ((x >> 4) + 1));
6830 operands[1] = GEN_INT ((x & 0x1f) - 0x20);
6831 return \"depdi,z %1,%%sar,%2,%0\";
6832 }"
6833 [(set_attr "type" "shift")
6834 (set_attr "length" "4")])
6835
6836 (define_insn ""
6837 [(set (match_operand:DI 0 "register_operand" "=r")
6838 (ior:DI (ashift:DI (match_operand:DI 1 "const_int_operand" "")
6839 (minus:DI (const_int 63)
6840 (match_operand:DI 2 "register_operand" "q")))
6841 (match_operand:DI 3 "register_operand" "0")))]
6842 ; accept ...0001...1, can this be generalized?
6843 "TARGET_64BIT && exact_log2 (INTVAL (operands[1]) + 1) > 0"
6844 "*
6845 {
6846 HOST_WIDE_INT x = INTVAL (operands[1]);
6847 operands[2] = GEN_INT (exact_log2 (x + 1));
6848 return \"depdi -1,%%sar,%2,%0\";
6849 }"
6850 [(set_attr "type" "shift")
6851 (set_attr "length" "4")])
6852
6853 (define_insn ""
6854 [(set (match_operand:DI 0 "register_operand" "=r")
6855 (and:DI (rotate:DI (match_operand:DI 1 "const_int_operand" "")
6856 (minus:DI (const_int 63)
6857 (match_operand:DI 2 "register_operand" "q")))
6858 (match_operand:DI 3 "register_operand" "0")))]
6859 ; this can be generalized...!
6860 "TARGET_64BIT && INTVAL (operands[1]) == -2"
6861 "*
6862 {
6863 HOST_WIDE_INT x = INTVAL (operands[1]);
6864 operands[2] = GEN_INT (exact_log2 ((~x) + 1));
6865 return \"depdi 0,%%sar,%2,%0\";
6866 }"
6867 [(set_attr "type" "shift")
6868 (set_attr "length" "4")])
6869
6870 (define_expand "ashrsi3"
6871 [(set (match_operand:SI 0 "register_operand" "")
6872 (ashiftrt:SI (match_operand:SI 1 "register_operand" "")
6873 (match_operand:SI 2 "arith32_operand" "")))]
6874 ""
6875 "
6876 {
6877 if (GET_CODE (operands[2]) != CONST_INT)
6878 {
6879 rtx temp = gen_reg_rtx (SImode);
6880 emit_insn (gen_subsi3 (temp, GEN_INT (31), operands[2]));
6881 emit_insn (gen_vextrs32 (operands[0], operands[1], temp));
6882 DONE;
6883 }
6884 }")
6885
6886 (define_insn ""
6887 [(set (match_operand:SI 0 "register_operand" "=r")
6888 (ashiftrt:SI (match_operand:SI 1 "register_operand" "r")
6889 (match_operand:SI 2 "const_int_operand" "n")))]
6890 ""
6891 "{extrs|extrw,s} %1,%P2,%L2,%0"
6892 [(set_attr "type" "shift")
6893 (set_attr "length" "4")])
6894
6895 (define_insn "vextrs32"
6896 [(set (match_operand:SI 0 "register_operand" "=r")
6897 (ashiftrt:SI (match_operand:SI 1 "register_operand" "r")
6898 (minus:SI (const_int 31)
6899 (match_operand:SI 2 "register_operand" "q"))))]
6900 ""
6901 "{vextrs %1,32,%0|extrw,s %1,%%sar,32,%0}"
6902 [(set_attr "type" "shift")
6903 (set_attr "length" "4")])
6904
6905 (define_expand "ashrdi3"
6906 [(set (match_operand:DI 0 "register_operand" "")
6907 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
6908 (match_operand:DI 2 "arith32_operand" "")))]
6909 "TARGET_64BIT"
6910 "
6911 {
6912 if (GET_CODE (operands[2]) != CONST_INT)
6913 {
6914 rtx temp = gen_reg_rtx (DImode);
6915 emit_insn (gen_subdi3 (temp, GEN_INT (63), operands[2]));
6916 emit_insn (gen_vextrs64 (operands[0], operands[1], temp));
6917 DONE;
6918 }
6919 }")
6920
6921 (define_insn ""
6922 [(set (match_operand:DI 0 "register_operand" "=r")
6923 (ashiftrt:DI (match_operand:DI 1 "register_operand" "r")
6924 (match_operand:DI 2 "const_int_operand" "n")))]
6925 "TARGET_64BIT"
6926 "extrd,s %1,%p2,%Q2,%0"
6927 [(set_attr "type" "shift")
6928 (set_attr "length" "4")])
6929
6930 (define_insn "vextrs64"
6931 [(set (match_operand:DI 0 "register_operand" "=r")
6932 (ashiftrt:DI (match_operand:DI 1 "register_operand" "r")
6933 (minus:DI (const_int 63)
6934 (match_operand:DI 2 "register_operand" "q"))))]
6935 "TARGET_64BIT"
6936 "extrd,s %1,%%sar,64,%0"
6937 [(set_attr "type" "shift")
6938 (set_attr "length" "4")])
6939
6940 (define_insn "lshrsi3"
6941 [(set (match_operand:SI 0 "register_operand" "=r,r")
6942 (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
6943 (match_operand:SI 2 "shift5_operand" "q,n")))]
6944 ""
6945 "@
6946 {vshd %%r0,%1,%0|shrpw %%r0,%1,%%sar,%0}
6947 {extru|extrw,u} %1,%P2,%L2,%0"
6948 [(set_attr "type" "shift")
6949 (set_attr "length" "4")])
6950
6951 (define_insn "lshrdi3"
6952 [(set (match_operand:DI 0 "register_operand" "=r,r")
6953 (lshiftrt:DI (match_operand:DI 1 "register_operand" "r,r")
6954 (match_operand:DI 2 "shift6_operand" "q,n")))]
6955 "TARGET_64BIT"
6956 "@
6957 shrpd %%r0,%1,%%sar,%0
6958 extrd,u %1,%p2,%Q2,%0"
6959 [(set_attr "type" "shift")
6960 (set_attr "length" "4")])
6961
6962 ; Shift right pair word 0 to 31 bits.
6963 (define_insn "*shrpsi4_1"
6964 [(set (match_operand:SI 0 "register_operand" "=r")
6965 (match_operator:SI 4 "plus_xor_ior_operator"
6966 [(ashift:SI (match_operand:SI 1 "register_operand" "r")
6967 (minus:SI (const_int 32)
6968 (match_operand:SI 3 "register_operand" "q")))
6969 (lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
6970 (match_dup 3))]))]
6971 ""
6972 "{vshd %1,%2,%0|shrpw %1,%2,%%sar,%0}"
6973 [(set_attr "type" "shift")
6974 (set_attr "length" "4")])
6975
6976 (define_insn "*shrpsi4_2"
6977 [(set (match_operand:SI 0 "register_operand" "=r")
6978 (match_operator:SI 4 "plus_xor_ior_operator"
6979 [(lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
6980 (match_operand:SI 3 "register_operand" "q"))
6981 (ashift:SI (match_operand:SI 1 "register_operand" "r")
6982 (minus:SI (const_int 32)
6983 (match_dup 3)))]))]
6984 ""
6985 "{vshd %1,%2,%0|shrpw %1,%2,%%sar,%0}"
6986 [(set_attr "type" "shift")
6987 (set_attr "length" "4")])
6988
6989 ; Shift right pair doubleword 0 to 63 bits.
6990 (define_insn "*shrpdi4_1"
6991 [(set (match_operand:DI 0 "register_operand" "=r")
6992 (match_operator:DI 4 "plus_xor_ior_operator"
6993 [(ashift:DI (match_operand:DI 1 "register_operand" "r")
6994 (minus:DI (const_int 64)
6995 (match_operand:DI 3 "register_operand" "q")))
6996 (lshiftrt:DI (match_operand:DI 2 "register_operand" "r")
6997 (match_dup 3))]))]
6998 "TARGET_64BIT"
6999 "shrpd %1,%2,%%sar,%0"
7000 [(set_attr "type" "shift")
7001 (set_attr "length" "4")])
7002
7003 (define_insn "*shrpdi4_2"
7004 [(set (match_operand:DI 0 "register_operand" "=r")
7005 (match_operator:DI 4 "plus_xor_ior_operator"
7006 [(lshiftrt:DI (match_operand:DI 2 "register_operand" "r")
7007 (match_operand:DI 3 "shift6_operand" "q"))
7008 (ashift:DI (match_operand:SI 1 "register_operand" "r")
7009 (minus:DI (const_int 64)
7010 (match_dup 3)))]))]
7011 "TARGET_64BIT"
7012 "shrpd %1,%2,%%sar,%0"
7013 [(set_attr "type" "shift")
7014 (set_attr "length" "4")])
7015
7016 (define_insn "*shrpdi4_3"
7017 [(set (match_operand:DI 0 "register_operand" "=r")
7018 (match_operator:DI 5 "plus_xor_ior_operator"
7019 [(ashift:DI (match_operand:DI 1 "register_operand" "r")
7020 (match_operand:DI 3 "const_int_operand" "n"))
7021 (lshiftrt:DI (match_operand:DI 2 "register_operand" "r")
7022 (match_operand:DI 4 "const_int_operand" "n"))]))]
7023 "TARGET_64BIT
7024 && INTVAL (operands[3]) + INTVAL (operands[4]) == 64"
7025 "shrpd %1,%2,%4,%0"
7026 [(set_attr "type" "shift")
7027 (set_attr "length" "4")])
7028
7029 (define_insn "*shrpdi4_4"
7030 [(set (match_operand:DI 0 "register_operand" "=r")
7031 (match_operator:DI 5 "plus_xor_ior_operator"
7032 [(lshiftrt:DI (match_operand:DI 2 "register_operand" "r")
7033 (match_operand:DI 4 "const_int_operand" "n"))
7034 (ashift:DI (match_operand:DI 1 "register_operand" "r")
7035 (match_operand:DI 3 "const_int_operand" "n"))]))]
7036 "TARGET_64BIT
7037 && INTVAL (operands[3]) + INTVAL (operands[4]) == 64"
7038 "shrpd %1,%2,%4,%0"
7039 [(set_attr "type" "shift")
7040 (set_attr "length" "4")])
7041
7042 (define_insn "rotrsi3"
7043 [(set (match_operand:SI 0 "register_operand" "=r,r")
7044 (rotatert:SI (match_operand:SI 1 "register_operand" "r,r")
7045 (match_operand:SI 2 "shift5_operand" "q,n")))]
7046 ""
7047 "*
7048 {
7049 if (GET_CODE (operands[2]) == CONST_INT)
7050 {
7051 operands[2] = GEN_INT (INTVAL (operands[2]) & 31);
7052 return \"{shd|shrpw} %1,%1,%2,%0\";
7053 }
7054 else
7055 return \"{vshd %1,%1,%0|shrpw %1,%1,%%sar,%0}\";
7056 }"
7057 [(set_attr "type" "shift")
7058 (set_attr "length" "4")])
7059
7060 (define_expand "rotlsi3"
7061 [(set (match_operand:SI 0 "register_operand" "")
7062 (rotate:SI (match_operand:SI 1 "register_operand" "")
7063 (match_operand:SI 2 "arith32_operand" "")))]
7064 ""
7065 "
7066 {
7067 if (GET_CODE (operands[2]) != CONST_INT)
7068 {
7069 rtx temp = gen_reg_rtx (SImode);
7070 emit_insn (gen_subsi3 (temp, GEN_INT (32), operands[2]));
7071 emit_insn (gen_rotrsi3 (operands[0], operands[1], temp));
7072 DONE;
7073 }
7074 /* Else expand normally. */
7075 }")
7076
7077 (define_insn "*rotlsi3_internal"
7078 [(set (match_operand:SI 0 "register_operand" "=r")
7079 (rotate:SI (match_operand:SI 1 "register_operand" "r")
7080 (match_operand:SI 2 "const_int_operand" "n")))]
7081 ""
7082 "*
7083 {
7084 operands[2] = GEN_INT ((32 - INTVAL (operands[2])) & 31);
7085 return \"{shd|shrpw} %1,%1,%2,%0\";
7086 }"
7087 [(set_attr "type" "shift")
7088 (set_attr "length" "4")])
7089
7090 (define_insn "rotrdi3"
7091 [(set (match_operand:DI 0 "register_operand" "=r,r")
7092 (rotatert:DI (match_operand:DI 1 "register_operand" "r,r")
7093 (match_operand:DI 2 "shift6_operand" "q,n")))]
7094 "TARGET_64BIT"
7095 "*
7096 {
7097 if (GET_CODE (operands[2]) == CONST_INT)
7098 {
7099 operands[2] = GEN_INT (INTVAL (operands[2]) & 63);
7100 return \"shrpd %1,%1,%2,%0\";
7101 }
7102 else
7103 return \"shrpd %1,%1,%%sar,%0\";
7104 }"
7105 [(set_attr "type" "shift")
7106 (set_attr "length" "4")])
7107
7108 (define_expand "rotldi3"
7109 [(set (match_operand:DI 0 "register_operand" "")
7110 (rotate:DI (match_operand:DI 1 "register_operand" "")
7111 (match_operand:DI 2 "arith32_operand" "")))]
7112 "TARGET_64BIT"
7113 "
7114 {
7115 if (GET_CODE (operands[2]) != CONST_INT)
7116 {
7117 rtx temp = gen_reg_rtx (DImode);
7118 emit_insn (gen_subdi3 (temp, GEN_INT (64), operands[2]));
7119 emit_insn (gen_rotrdi3 (operands[0], operands[1], temp));
7120 DONE;
7121 }
7122 /* Else expand normally. */
7123 }")
7124
7125 (define_insn "*rotldi3_internal"
7126 [(set (match_operand:DI 0 "register_operand" "=r")
7127 (rotate:DI (match_operand:DI 1 "register_operand" "r")
7128 (match_operand:DI 2 "const_int_operand" "n")))]
7129 "TARGET_64BIT"
7130 "*
7131 {
7132 operands[2] = GEN_INT ((64 - INTVAL (operands[2])) & 63);
7133 return \"shrpd %1,%1,%2,%0\";
7134 }"
7135 [(set_attr "type" "shift")
7136 (set_attr "length" "4")])
7137
7138 (define_insn ""
7139 [(set (match_operand:SI 0 "register_operand" "=r")
7140 (match_operator:SI 5 "plus_xor_ior_operator"
7141 [(ashift:SI (match_operand:SI 1 "register_operand" "r")
7142 (match_operand:SI 3 "const_int_operand" "n"))
7143 (lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
7144 (match_operand:SI 4 "const_int_operand" "n"))]))]
7145 "INTVAL (operands[3]) + INTVAL (operands[4]) == 32"
7146 "{shd|shrpw} %1,%2,%4,%0"
7147 [(set_attr "type" "shift")
7148 (set_attr "length" "4")])
7149
7150 (define_insn ""
7151 [(set (match_operand:SI 0 "register_operand" "=r")
7152 (match_operator:SI 5 "plus_xor_ior_operator"
7153 [(lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
7154 (match_operand:SI 4 "const_int_operand" "n"))
7155 (ashift:SI (match_operand:SI 1 "register_operand" "r")
7156 (match_operand:SI 3 "const_int_operand" "n"))]))]
7157 "INTVAL (operands[3]) + INTVAL (operands[4]) == 32"
7158 "{shd|shrpw} %1,%2,%4,%0"
7159 [(set_attr "type" "shift")
7160 (set_attr "length" "4")])
7161
7162 (define_expand "shd_internal"
7163 [(set (match_operand:SI 0 "register_operand")
7164 (ior:SI
7165 (lshiftrt:SI (match_operand:SI 1 "register_operand")
7166 (match_operand:SI 2 "const_int_operand"))
7167 (ashift:SI (match_operand:SI 3 "register_operand")
7168 (match_operand:SI 4 "const_int_operand"))))]
7169 "")
7170
7171 (define_expand "shrpd_internal"
7172 [(set (match_operand:DI 0 "register_operand")
7173 (ior:DI
7174 (lshiftrt:DI (match_operand:DI 1 "register_operand")
7175 (match_operand:DI 2 "const_int_operand"))
7176 (ashift:DI (match_operand:DI 3 "register_operand")
7177 (match_operand:DI 4 "const_int_operand"))))]
7178 "TARGET_64BIT")
7179
7180 (define_insn ""
7181 [(set (match_operand:SI 0 "register_operand" "=r")
7182 (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
7183 (match_operand:SI 2 "const_int_operand" ""))
7184 (match_operand:SI 3 "const_int_operand" "")))]
7185 "exact_log2 (1 + (INTVAL (operands[3]) >> (INTVAL (operands[2]) & 31))) > 0"
7186 "*
7187 {
7188 int cnt = INTVAL (operands[2]) & 31;
7189 operands[3] = GEN_INT (exact_log2 (1 + (INTVAL (operands[3]) >> cnt)));
7190 operands[2] = GEN_INT (31 - cnt);
7191 return \"{zdep|depw,z} %1,%2,%3,%0\";
7192 }"
7193 [(set_attr "type" "shift")
7194 (set_attr "length" "4")])
7195
7196 ;; Unconditional and other jump instructions.
7197
7198 ;; Trivial return used when no epilogue is needed.
7199 (define_insn "return"
7200 [(return)
7201 (use (reg:SI 2))]
7202 "pa_can_use_return_insn ()"
7203 "*
7204 {
7205 if (TARGET_PA_20)
7206 return \"bve%* (%%r2)\";
7207 return \"bv%* %%r0(%%r2)\";
7208 }"
7209 [(set_attr "type" "branch")
7210 (set_attr "length" "4")])
7211
7212 ;; This is used for most returns.
7213 (define_insn "return_internal"
7214 [(return)
7215 (use (reg:SI 2))]
7216 ""
7217 "*
7218 {
7219 if (TARGET_PA_20)
7220 return \"bve%* (%%r2)\";
7221 return \"bv%* %%r0(%%r2)\";
7222 }"
7223 [(set_attr "type" "branch")
7224 (set_attr "length" "4")])
7225
7226 ;; This is used for eh returns which bypass the return stub.
7227 (define_insn "return_external_pic"
7228 [(return)
7229 (clobber (reg:SI 1))
7230 (use (reg:SI 2))]
7231 "!TARGET_NO_SPACE_REGS
7232 && !TARGET_PA_20
7233 && flag_pic && crtl->calls_eh_return"
7234 "ldsid (%%sr0,%%r2),%%r1\;mtsp %%r1,%%sr0\;be%* 0(%%sr0,%%r2)"
7235 [(set_attr "type" "branch")
7236 (set_attr "length" "12")])
7237
7238 (define_expand "prologue"
7239 [(const_int 0)]
7240 ""
7241 "pa_expand_prologue ();DONE;")
7242
7243 (define_expand "sibcall_epilogue"
7244 [(return)]
7245 ""
7246 "
7247 {
7248 pa_expand_epilogue ();
7249 DONE;
7250 }")
7251
7252 (define_expand "epilogue"
7253 [(return)]
7254 ""
7255 "
7256 {
7257 rtx x;
7258
7259 /* Try to use the trivial return first. Else use the full epilogue. */
7260 if (pa_can_use_return_insn ())
7261 x = gen_return ();
7262 else
7263 {
7264 pa_expand_epilogue ();
7265
7266 /* EH returns bypass the normal return stub. Thus, we must do an
7267 interspace branch to return from functions that call eh_return.
7268 This is only a problem for returns from shared code on ports
7269 using space registers. */
7270 if (!TARGET_NO_SPACE_REGS
7271 && !TARGET_PA_20
7272 && flag_pic && crtl->calls_eh_return)
7273 x = gen_return_external_pic ();
7274 else
7275 x = gen_return_internal ();
7276 }
7277 emit_jump_insn (x);
7278 DONE;
7279 }")
7280
7281 ; Used by hppa_profile_hook to load the starting address of the current
7282 ; function; operand 1 contains the address of the label in operand 3
7283 (define_insn "load_offset_label_address"
7284 [(set (match_operand:SI 0 "register_operand" "=r")
7285 (plus:SI (match_operand:SI 1 "register_operand" "r")
7286 (minus:SI (match_operand:SI 2 "" "")
7287 (label_ref:SI (match_operand 3 "" "")))))]
7288 ""
7289 "ldo %2-%l3(%1),%0"
7290 [(set_attr "type" "multi")
7291 (set_attr "length" "4")])
7292
7293 ; Output a code label and load its address.
7294 (define_insn "lcla1"
7295 [(set (match_operand:SI 0 "register_operand" "=r")
7296 (label_ref:SI (match_operand 1 "" "")))
7297 (const_int 0)]
7298 "!TARGET_PA_20"
7299 "*
7300 {
7301 output_asm_insn (\"bl .+8,%0\;depi 0,31,2,%0\", operands);
7302 (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
7303 CODE_LABEL_NUMBER (operands[1]));
7304 return \"\";
7305 }"
7306 [(set_attr "type" "multi")
7307 (set_attr "length" "8")])
7308
7309 (define_insn "lcla2"
7310 [(set (match_operand:SI 0 "register_operand" "=r")
7311 (label_ref:SI (match_operand 1 "" "")))
7312 (const_int 0)]
7313 "TARGET_PA_20"
7314 "*
7315 {
7316 (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
7317 CODE_LABEL_NUMBER (operands[1]));
7318 return \"mfia %0\";
7319 }"
7320 [(set_attr "type" "move")
7321 (set_attr "length" "4")])
7322
7323 (define_insn "blockage"
7324 [(unspec_volatile [(const_int 2)] UNSPECV_BLOCKAGE)]
7325 ""
7326 ""
7327 [(set_attr "length" "0")])
7328
7329 (define_insn "jump"
7330 [(set (pc) (label_ref (match_operand 0 "" "")))]
7331 ""
7332 "*
7333 {
7334 /* An unconditional branch which can reach its target. */
7335 if (get_attr_length (insn) < 16)
7336 return \"b%* %l0\";
7337
7338 return pa_output_lbranch (operands[0], insn, 1);
7339 }"
7340 [(set_attr "type" "uncond_branch")
7341 (set_attr "pa_combine_type" "uncond_branch")
7342 (set (attr "length")
7343 (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
7344 (const_int MAX_17BIT_OFFSET))
7345 (const_int 4)
7346 (match_test "TARGET_PORTABLE_RUNTIME")
7347 (const_int 20)
7348 (not (match_test "flag_pic"))
7349 (const_int 16)]
7350 (const_int 24)))])
7351
7352 ;;; Hope this is only within a function...
7353 (define_insn "indirect_jump"
7354 [(set (pc) (match_operand 0 "pmode_register_operand" "r"))]
7355 ""
7356 "bv%* %%r0(%0)"
7357 [(set_attr "type" "branch")
7358 (set_attr "length" "4")])
7359
7360 ;;; An indirect jump can be optimized to a direct jump. GAS for the
7361 ;;; SOM target doesn't allow branching to a label inside a function.
7362 ;;; We also don't correctly compute branch distances for labels
7363 ;;; outside the current function. Thus, we use an indirect jump can't
7364 ;;; be optimized to a direct jump for all targets. We assume that
7365 ;;; the branch target is in the same space (i.e., nested function
7366 ;;; jumping to a label in an outer function in the same translation
7367 ;;; unit).
7368 (define_expand "nonlocal_goto"
7369 [(use (match_operand 0 "general_operand" ""))
7370 (use (match_operand 1 "general_operand" ""))
7371 (use (match_operand 2 "general_operand" ""))
7372 (use (match_operand 3 "general_operand" ""))]
7373 ""
7374 {
7375 rtx lab = operands[1];
7376 rtx stack = operands[2];
7377 rtx fp = operands[3];
7378
7379 emit_clobber (gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (VOIDmode)));
7380 emit_clobber (gen_rtx_MEM (BLKmode, hard_frame_pointer_rtx));
7381
7382 lab = copy_to_reg (lab);
7383
7384 /* Restore the stack and frame pointers. */
7385 fp = copy_to_reg (fp);
7386 emit_stack_restore (SAVE_NONLOCAL, stack);
7387
7388 /* Ensure the frame pointer move is not optimized. */
7389 emit_insn (gen_blockage ());
7390 emit_clobber (hard_frame_pointer_rtx);
7391 emit_move_insn (hard_frame_pointer_rtx, fp);
7392
7393 emit_use (hard_frame_pointer_rtx);
7394 emit_use (stack_pointer_rtx);
7395
7396 /* Nonlocal goto jumps are only used between functions in the same
7397 translation unit. Thus, we can avoid the extra overhead of an
7398 interspace jump. */
7399 emit_jump_insn (gen_indirect_goto (lab));
7400 emit_barrier ();
7401 DONE;
7402 })
7403
7404 (define_insn "indirect_goto"
7405 [(unspec [(match_operand 0 "register_operand" "r")] UNSPEC_GOTO)]
7406 "GET_MODE (operands[0]) == word_mode"
7407 "bv%* %%r0(%0)"
7408 [(set_attr "type" "branch")
7409 (set_attr "length" "4")])
7410
7411 ;; Subroutines of "casesi".
7412 ;; operand 0 is index
7413 ;; operand 1 is the minimum bound
7414 ;; operand 2 is the maximum bound - minimum bound + 1
7415 ;; operand 3 is CODE_LABEL for the table;
7416 ;; operand 4 is the CODE_LABEL to go to if index out of range.
7417
7418 (define_expand "casesi"
7419 [(match_operand:SI 0 "general_operand" "")
7420 (match_operand:SI 1 "const_int_operand" "")
7421 (match_operand:SI 2 "const_int_operand" "")
7422 (match_operand 3 "" "")
7423 (match_operand 4 "" "")]
7424 ""
7425 "
7426 {
7427 if (GET_CODE (operands[0]) != REG)
7428 operands[0] = force_reg (SImode, operands[0]);
7429
7430 if (operands[1] != const0_rtx)
7431 {
7432 rtx index = gen_reg_rtx (SImode);
7433
7434 operands[1] = gen_int_mode (-INTVAL (operands[1]), SImode);
7435 if (!INT_14_BITS (operands[1]))
7436 operands[1] = force_reg (SImode, operands[1]);
7437 emit_insn (gen_addsi3 (index, operands[0], operands[1]));
7438 operands[0] = index;
7439 }
7440
7441 if (!INT_5_BITS (operands[2]))
7442 operands[2] = force_reg (SImode, operands[2]);
7443
7444 /* This branch prevents us finding an insn for the delay slot of the
7445 following vectored branch. It might be possible to use the delay
7446 slot if an index value of -1 was used to transfer to the out-of-range
7447 label. In order to do this, we would have to output the -1 vector
7448 element after the delay insn. The casesi output code would have to
7449 check if the casesi insn is in a delay branch sequence and output
7450 the delay insn if one is found. If this was done, then it might
7451 then be worthwhile to split the casesi patterns to improve scheduling.
7452 However, it's not clear that all this extra complexity is worth
7453 the effort. */
7454 {
7455 rtx test = gen_rtx_GTU (VOIDmode, operands[0], operands[2]);
7456 emit_jump_insn (gen_cbranchsi4 (test, operands[0], operands[2], operands[4]));
7457 }
7458
7459 /* In 64bit mode we must make sure to wipe the upper bits of the register
7460 just in case the addition overflowed or we had random bits in the
7461 high part of the register. */
7462 if (TARGET_64BIT)
7463 {
7464 rtx index = gen_reg_rtx (DImode);
7465
7466 emit_insn (gen_extendsidi2 (index, operands[0]));
7467 operands[0] = index;
7468 }
7469
7470 if (TARGET_64BIT)
7471 emit_jump_insn (gen_casesi64p (operands[0], operands[3]));
7472 else if (flag_pic)
7473 emit_jump_insn (gen_casesi32p (operands[0], operands[3]));
7474 else
7475 emit_jump_insn (gen_casesi32 (operands[0], operands[3]));
7476 DONE;
7477 }")
7478
7479 ;;; 32-bit code, absolute branch table.
7480 (define_insn "casesi32"
7481 [(set (pc) (mem:SI (plus:SI
7482 (mult:SI (match_operand:SI 0 "register_operand" "r")
7483 (const_int 4))
7484 (label_ref (match_operand 1 "" "")))))
7485 (clobber (match_scratch:SI 2 "=&r"))]
7486 "!flag_pic"
7487 "ldil L'%l1,%2\;ldo R'%l1(%2),%2\;{ldwx|ldw},s %0(%2),%2\;bv,n %%r0(%2)"
7488 [(set_attr "type" "multi")
7489 (set_attr "length" "16")])
7490
7491 ;;; 32-bit code, relative branch table.
7492 (define_insn "casesi32p"
7493 [(set (pc) (mem:SI (plus:SI
7494 (mult:SI (match_operand:SI 0 "register_operand" "r")
7495 (const_int 4))
7496 (label_ref (match_operand 1 "" "")))))
7497 (clobber (match_scratch:SI 2 "=&r"))
7498 (clobber (match_scratch:SI 3 "=&r"))]
7499 "flag_pic"
7500 "{bl .+8,%2\;depi 0,31,2,%2|mfia %2}\;ldo {%l1-.|%l1+4-.}(%2),%2\;\
7501 {ldwx|ldw},s %0(%2),%3\;{addl|add,l} %2,%3,%3\;bv,n %%r0(%3)"
7502 [(set_attr "type" "multi")
7503 (set (attr "length")
7504 (if_then_else (match_test "TARGET_PA_20")
7505 (const_int 20)
7506 (const_int 24)))])
7507
7508 ;;; 64-bit code, 32-bit relative branch table.
7509 (define_insn "casesi64p"
7510 [(set (pc) (mem:DI (plus:DI
7511 (mult:DI (match_operand:DI 0 "register_operand" "r")
7512 (const_int 8))
7513 (label_ref (match_operand 1 "" "")))))
7514 (clobber (match_scratch:DI 2 "=&r"))
7515 (clobber (match_scratch:DI 3 "=&r"))]
7516 ""
7517 "mfia %2\;ldo %l1+4-.(%2),%2\;ldw,s %0(%2),%3\;extrd,s %3,63,32,%3\;\
7518 add,l %2,%3,%3\;bv,n %%r0(%3)"
7519 [(set_attr "type" "multi")
7520 (set_attr "length" "24")])
7521
7522
7523 ;; Call patterns.
7524 ;;- jump to subroutine
7525
7526 (define_expand "call"
7527 [(parallel [(call (match_operand:SI 0 "" "")
7528 (match_operand 1 "" ""))
7529 (clobber (reg:SI 2))])]
7530 ""
7531 "
7532 {
7533 rtx op;
7534 rtx nb = operands[1];
7535
7536 if (TARGET_PORTABLE_RUNTIME)
7537 op = force_reg (SImode, XEXP (operands[0], 0));
7538 else
7539 {
7540 op = XEXP (operands[0], 0);
7541
7542 /* Generate indirect long calls to non-local functions. */
7543 if (TARGET_LONG_CALLS && GET_CODE (op) == SYMBOL_REF)
7544 {
7545 tree call_decl = SYMBOL_REF_DECL (op);
7546 if (!(call_decl && targetm.binds_local_p (call_decl)))
7547 op = force_reg (word_mode, op);
7548 }
7549 }
7550
7551 if (TARGET_64BIT)
7552 {
7553 if (!virtuals_instantiated)
7554 emit_move_insn (arg_pointer_rtx,
7555 gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
7556 GEN_INT (64)));
7557 else
7558 {
7559 /* The loop pass can generate new libcalls after the virtual
7560 registers are instantiated when fpregs are disabled because
7561 the only method that we have for doing DImode multiplication
7562 is with a libcall. This could be trouble if we haven't
7563 allocated enough space for the outgoing arguments. */
7564 gcc_assert (INTVAL (nb) <= crtl->outgoing_args_size);
7565
7566 emit_move_insn (arg_pointer_rtx,
7567 gen_rtx_PLUS (word_mode, stack_pointer_rtx,
7568 GEN_INT (STACK_POINTER_OFFSET + 64)));
7569 }
7570 }
7571
7572 /* Use two different patterns for calls to explicitly named functions
7573 and calls through function pointers. This is necessary as these two
7574 types of calls use different calling conventions, and CSE might try
7575 to change the named call into an indirect call in some cases (using
7576 two patterns keeps CSE from performing this optimization).
7577
7578 We now use even more call patterns as there was a subtle bug in
7579 attempting to restore the pic register after a call using a simple
7580 move insn. During reload, a instruction involving a pseudo register
7581 with no explicit dependence on the PIC register can be converted
7582 to an equivalent load from memory using the PIC register. If we
7583 emit a simple move to restore the PIC register in the initial rtl
7584 generation, then it can potentially be repositioned during scheduling.
7585 and an instruction that eventually uses the PIC register may end up
7586 between the call and the PIC register restore.
7587
7588 This only worked because there is a post call group of instructions
7589 that are scheduled with the call. These instructions are included
7590 in the same basic block as the call. However, calls can throw in
7591 C++ code and a basic block has to terminate at the call if the call
7592 can throw. This results in the PIC register restore being scheduled
7593 independently from the call. So, we now hide the save and restore
7594 of the PIC register in the call pattern until after reload. Then,
7595 we split the moves out. A small side benefit is that we now don't
7596 need to have a use of the PIC register in the return pattern and
7597 the final save/restore operation is not needed.
7598
7599 I elected to just use register %r4 in the PIC patterns instead
7600 of trying to force hppa_pic_save_rtx () to a callee saved register.
7601 This might have required a new register class and constraint. It
7602 was also simpler to just handle the restore from a register than a
7603 generic pseudo. */
7604 if (TARGET_64BIT)
7605 {
7606 rtx r4 = gen_rtx_REG (word_mode, 4);
7607 if (GET_CODE (op) == SYMBOL_REF)
7608 emit_call_insn (gen_call_symref_64bit (op, nb, r4));
7609 else
7610 {
7611 op = force_reg (word_mode, op);
7612 emit_call_insn (gen_call_reg_64bit (op, nb, r4));
7613 }
7614 }
7615 else
7616 {
7617 if (GET_CODE (op) == SYMBOL_REF)
7618 {
7619 if (flag_pic)
7620 {
7621 rtx r4 = gen_rtx_REG (word_mode, 4);
7622 emit_call_insn (gen_call_symref_pic (op, nb, r4));
7623 }
7624 else
7625 emit_call_insn (gen_call_symref (op, nb));
7626 }
7627 else
7628 {
7629 rtx tmpreg = gen_rtx_REG (word_mode, 22);
7630 emit_move_insn (tmpreg, force_reg (word_mode, op));
7631 if (flag_pic)
7632 {
7633 rtx r4 = gen_rtx_REG (word_mode, 4);
7634 emit_call_insn (gen_call_reg_pic (nb, r4));
7635 }
7636 else
7637 emit_call_insn (gen_call_reg (nb));
7638 }
7639 }
7640
7641 DONE;
7642 }")
7643
7644 ;; We use function calls to set the attribute length of calls and millicode
7645 ;; calls. This is necessary because of the large variety of call sequences.
7646 ;; Implementing the calculation in rtl is difficult as well as ugly. As
7647 ;; we need the same calculation in several places, maintenance becomes a
7648 ;; nightmare.
7649 ;;
7650 ;; However, this has a subtle impact on branch shortening. When the
7651 ;; expression used to set the length attribute of an instruction depends
7652 ;; on a relative address (e.g., pc or a branch address), genattrtab
7653 ;; notes that the insn's length is variable, and attempts to determine a
7654 ;; worst-case default length and code to compute an insn's current length.
7655
7656 ;; The use of a function call hides the variable dependence of our calls
7657 ;; and millicode calls. The result is genattrtab doesn't treat the operation
7658 ;; as variable and it only generates code for the default case using our
7659 ;; function call. Because of this, calls and millicode calls have a fixed
7660 ;; length in the branch shortening pass, and some branches will use a longer
7661 ;; code sequence than necessary. However, the length of any given call
7662 ;; will still reflect its final code location and it may be shorter than
7663 ;; the initial length estimate.
7664
7665 ;; It's possible to trick genattrtab by adding an expression involving `pc'
7666 ;; in the set. However, when genattrtab hits a function call in its attempt
7667 ;; to compute the default length, it marks the result as unknown and sets
7668 ;; the default result to MAX_INT ;-( One possible fix that would allow
7669 ;; calls to participate in branch shortening would be to make the call to
7670 ;; insn_default_length a target option. Then, we could massage unknown
7671 ;; results. Another fix might be to change genattrtab so that it just does
7672 ;; the call in the variable case as it already does for the fixed case.
7673
7674 (define_insn "call_symref"
7675 [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7676 (match_operand 1 "" "i"))
7677 (clobber (reg:SI 1))
7678 (clobber (reg:SI 2))
7679 (use (const_int 0))]
7680 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7681 "*
7682 {
7683 pa_output_arg_descriptor (insn);
7684 return pa_output_call (insn, operands[0], 0);
7685 }"
7686 [(set_attr "type" "call")
7687 (set (attr "length")
7688 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7689 (symbol_ref "pa_attr_length_call (insn, 0)")))])
7690
7691 (define_insn "call_symref_pic"
7692 [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7693 (match_operand 1 "" "i"))
7694 (clobber (reg:SI 1))
7695 (clobber (reg:SI 2))
7696 (clobber (match_operand 2))
7697 (use (reg:SI 19))
7698 (use (const_int 0))]
7699 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7700 "#")
7701
7702 ;; Split out the PIC register save and restore after reload. As the
7703 ;; split is done after reload, there are some situations in which we
7704 ;; unnecessarily save and restore %r4. This happens when there is a
7705 ;; single call and the PIC register is not used after the call.
7706 ;;
7707 ;; The split has to be done since call_from_call_insn () can't handle
7708 ;; the pattern as is. Noreturn calls are special because they have to
7709 ;; terminate the basic block. The split has to contain more than one
7710 ;; insn.
7711 (define_split
7712 [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7713 (match_operand 1 "" ""))
7714 (clobber (reg:SI 1))
7715 (clobber (reg:SI 2))
7716 (clobber (match_operand 2))
7717 (use (reg:SI 19))
7718 (use (const_int 0))])]
7719 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed
7720 && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7721 [(set (match_dup 2) (reg:SI 19))
7722 (parallel [(call (mem:SI (match_dup 0))
7723 (match_dup 1))
7724 (clobber (reg:SI 1))
7725 (clobber (reg:SI 2))
7726 (use (reg:SI 19))
7727 (use (const_int 0))])]
7728 "")
7729
7730 (define_split
7731 [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7732 (match_operand 1 "" ""))
7733 (clobber (reg:SI 1))
7734 (clobber (reg:SI 2))
7735 (clobber (match_operand 2))
7736 (use (reg:SI 19))
7737 (use (const_int 0))])]
7738 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
7739 [(set (match_dup 2) (reg:SI 19))
7740 (parallel [(call (mem:SI (match_dup 0))
7741 (match_dup 1))
7742 (clobber (reg:SI 1))
7743 (clobber (reg:SI 2))
7744 (use (reg:SI 19))
7745 (use (const_int 0))])
7746 (set (reg:SI 19) (match_dup 2))]
7747 "")
7748
7749 (define_insn "*call_symref_pic_post_reload"
7750 [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7751 (match_operand 1 "" "i"))
7752 (clobber (reg:SI 1))
7753 (clobber (reg:SI 2))
7754 (use (reg:SI 19))
7755 (use (const_int 0))]
7756 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7757 "*
7758 {
7759 pa_output_arg_descriptor (insn);
7760 return pa_output_call (insn, operands[0], 0);
7761 }"
7762 [(set_attr "type" "call")
7763 (set (attr "length")
7764 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7765 (symbol_ref "pa_attr_length_call (insn, 0)")))])
7766
7767 ;; This pattern is split if it is necessary to save and restore the
7768 ;; PIC register.
7769 (define_insn "call_symref_64bit"
7770 [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7771 (match_operand 1 "" "i"))
7772 (clobber (reg:DI 1))
7773 (clobber (reg:DI 2))
7774 (clobber (match_operand 2))
7775 (use (reg:DI 27))
7776 (use (reg:DI 29))
7777 (use (const_int 0))]
7778 "TARGET_64BIT"
7779 "#")
7780
7781 ;; Split out the PIC register save and restore after reload. As the
7782 ;; split is done after reload, there are some situations in which we
7783 ;; unnecessarily save and restore %r4. This happens when there is a
7784 ;; single call and the PIC register is not used after the call.
7785 ;;
7786 ;; The split has to be done since call_from_call_insn () can't handle
7787 ;; the pattern as is. Noreturn calls are special because they have to
7788 ;; terminate the basic block. The split has to contain more than one
7789 ;; insn.
7790 (define_split
7791 [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7792 (match_operand 1 "" ""))
7793 (clobber (reg:DI 1))
7794 (clobber (reg:DI 2))
7795 (clobber (match_operand 2))
7796 (use (reg:DI 27))
7797 (use (reg:DI 29))
7798 (use (const_int 0))])]
7799 "TARGET_64BIT && reload_completed
7800 && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7801 [(set (match_dup 2) (reg:DI 27))
7802 (parallel [(call (mem:SI (match_dup 0))
7803 (match_dup 1))
7804 (clobber (reg:DI 1))
7805 (clobber (reg:DI 2))
7806 (use (reg:DI 27))
7807 (use (reg:DI 29))
7808 (use (const_int 0))])]
7809 "")
7810
7811 (define_split
7812 [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7813 (match_operand 1 "" ""))
7814 (clobber (reg:DI 1))
7815 (clobber (reg:DI 2))
7816 (clobber (match_operand 2))
7817 (use (reg:DI 27))
7818 (use (reg:DI 29))
7819 (use (const_int 0))])]
7820 "TARGET_64BIT && reload_completed"
7821 [(set (match_dup 2) (reg:DI 27))
7822 (parallel [(call (mem:SI (match_dup 0))
7823 (match_dup 1))
7824 (clobber (reg:DI 1))
7825 (clobber (reg:DI 2))
7826 (use (reg:DI 27))
7827 (use (reg:DI 29))
7828 (use (const_int 0))])
7829 (set (reg:DI 27) (match_dup 2))]
7830 "")
7831
7832 (define_insn "*call_symref_64bit_post_reload"
7833 [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7834 (match_operand 1 "" "i"))
7835 (clobber (reg:DI 1))
7836 (clobber (reg:DI 2))
7837 (use (reg:DI 27))
7838 (use (reg:DI 29))
7839 (use (const_int 0))]
7840 "TARGET_64BIT"
7841 "*
7842 {
7843 return pa_output_call (insn, operands[0], 0);
7844 }"
7845 [(set_attr "type" "call")
7846 (set (attr "length")
7847 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7848 (symbol_ref "pa_attr_length_call (insn, 0)")))])
7849
7850 (define_insn "call_reg"
7851 [(call (mem:SI (reg:SI 22))
7852 (match_operand 0 "" "i"))
7853 (clobber (reg:SI 1))
7854 (clobber (reg:SI 2))
7855 (use (const_int 1))]
7856 "!TARGET_64BIT"
7857 "*
7858 {
7859 return pa_output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
7860 }"
7861 [(set_attr "type" "dyncall")
7862 (set (attr "length")
7863 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7864 (symbol_ref "pa_attr_length_indirect_call (insn)")))])
7865
7866 ;; This pattern is split if it is necessary to save and restore the
7867 ;; PIC register.
7868 (define_insn "call_reg_pic"
7869 [(call (mem:SI (reg:SI 22))
7870 (match_operand 0 "" "i"))
7871 (clobber (reg:SI 1))
7872 (clobber (reg:SI 2))
7873 (clobber (match_operand 1))
7874 (use (reg:SI 19))
7875 (use (const_int 1))]
7876 "!TARGET_64BIT"
7877 "#")
7878
7879 ;; Split out the PIC register save and restore after reload. As the
7880 ;; split is done after reload, there are some situations in which we
7881 ;; unnecessarily save and restore %r4. This happens when there is a
7882 ;; single call and the PIC register is not used after the call.
7883 ;;
7884 ;; The split has to be done since call_from_call_insn () can't handle
7885 ;; the pattern as is. Noreturn calls are special because they have to
7886 ;; terminate the basic block. The split has to contain more than one
7887 ;; insn.
7888 (define_split
7889 [(parallel [(call (mem:SI (reg:SI 22))
7890 (match_operand 0 "" ""))
7891 (clobber (reg:SI 1))
7892 (clobber (reg:SI 2))
7893 (clobber (match_operand 1))
7894 (use (reg:SI 19))
7895 (use (const_int 1))])]
7896 "!TARGET_64BIT && reload_completed
7897 && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7898 [(set (match_dup 1) (reg:SI 19))
7899 (parallel [(call (mem:SI (reg:SI 22))
7900 (match_dup 0))
7901 (clobber (reg:SI 1))
7902 (clobber (reg:SI 2))
7903 (use (reg:SI 19))
7904 (use (const_int 1))])]
7905 "")
7906
7907 (define_split
7908 [(parallel [(call (mem:SI (reg:SI 22))
7909 (match_operand 0 "" ""))
7910 (clobber (reg:SI 1))
7911 (clobber (reg:SI 2))
7912 (clobber (match_operand 1))
7913 (use (reg:SI 19))
7914 (use (const_int 1))])]
7915 "!TARGET_64BIT && reload_completed"
7916 [(set (match_dup 1) (reg:SI 19))
7917 (parallel [(call (mem:SI (reg:SI 22))
7918 (match_dup 0))
7919 (clobber (reg:SI 1))
7920 (clobber (reg:SI 2))
7921 (use (reg:SI 19))
7922 (use (const_int 1))])
7923 (set (reg:SI 19) (match_dup 1))]
7924 "")
7925
7926 (define_insn "*call_reg_pic_post_reload"
7927 [(call (mem:SI (reg:SI 22))
7928 (match_operand 0 "" "i"))
7929 (clobber (reg:SI 1))
7930 (clobber (reg:SI 2))
7931 (use (reg:SI 19))
7932 (use (const_int 1))]
7933 "!TARGET_64BIT"
7934 "*
7935 {
7936 return pa_output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
7937 }"
7938 [(set_attr "type" "dyncall")
7939 (set (attr "length")
7940 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
7941 (symbol_ref "pa_attr_length_indirect_call (insn)")))])
7942
7943 ;; This pattern is split if it is necessary to save and restore the
7944 ;; PIC register.
7945 (define_insn "call_reg_64bit"
7946 [(call (mem:SI (match_operand:DI 0 "register_operand" "r"))
7947 (match_operand 1 "" "i"))
7948 (clobber (reg:DI 2))
7949 (clobber (match_operand 2))
7950 (use (reg:DI 27))
7951 (use (reg:DI 29))
7952 (use (const_int 1))]
7953 "TARGET_64BIT"
7954 "#")
7955
7956 ;; Split out the PIC register save and restore after reload. As the
7957 ;; split is done after reload, there are some situations in which we
7958 ;; unnecessarily save and restore %r4. This happens when there is a
7959 ;; single call and the PIC register is not used after the call.
7960 ;;
7961 ;; The split has to be done since call_from_call_insn () can't handle
7962 ;; the pattern as is. Noreturn calls are special because they have to
7963 ;; terminate the basic block. The split has to contain more than one
7964 ;; insn.
7965 (define_split
7966 [(parallel [(call (mem:SI (match_operand 0 "register_operand" ""))
7967 (match_operand 1 "" ""))
7968 (clobber (reg:DI 2))
7969 (clobber (match_operand 2))
7970 (use (reg:DI 27))
7971 (use (reg:DI 29))
7972 (use (const_int 1))])]
7973 "TARGET_64BIT && reload_completed
7974 && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7975 [(set (match_dup 2) (reg:DI 27))
7976 (parallel [(call (mem:SI (match_dup 0))
7977 (match_dup 1))
7978 (clobber (reg:DI 2))
7979 (use (reg:DI 27))
7980 (use (reg:DI 29))
7981 (use (const_int 1))])]
7982 "")
7983
7984 (define_split
7985 [(parallel [(call (mem:SI (match_operand 0 "register_operand" ""))
7986 (match_operand 1 "" ""))
7987 (clobber (reg:DI 2))
7988 (clobber (match_operand 2))
7989 (use (reg:DI 27))
7990 (use (reg:DI 29))
7991 (use (const_int 1))])]
7992 "TARGET_64BIT && reload_completed"
7993 [(set (match_dup 2) (reg:DI 27))
7994 (parallel [(call (mem:SI (match_dup 0))
7995 (match_dup 1))
7996 (clobber (reg:DI 2))
7997 (use (reg:DI 27))
7998 (use (reg:DI 29))
7999 (use (const_int 1))])
8000 (set (reg:DI 27) (match_dup 2))]
8001 "")
8002
8003 (define_insn "*call_reg_64bit_post_reload"
8004 [(call (mem:SI (match_operand:DI 0 "register_operand" "r"))
8005 (match_operand 1 "" "i"))
8006 (clobber (reg:DI 2))
8007 (use (reg:DI 27))
8008 (use (reg:DI 29))
8009 (use (const_int 1))]
8010 "TARGET_64BIT"
8011 "*
8012 {
8013 return pa_output_indirect_call (insn, operands[0]);
8014 }"
8015 [(set_attr "type" "dyncall")
8016 (set (attr "length")
8017 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 12)]
8018 (symbol_ref "pa_attr_length_indirect_call (insn)")))])
8019
8020 (define_expand "call_value"
8021 [(parallel [(set (match_operand 0 "" "")
8022 (call (match_operand:SI 1 "" "")
8023 (match_operand 2 "" "")))
8024 (clobber (reg:SI 2))])]
8025 ""
8026 {
8027 rtx op;
8028 rtx dst = operands[0];
8029 rtx nb = operands[2];
8030 bool call_powf = false;
8031
8032 if (TARGET_PORTABLE_RUNTIME)
8033 op = force_reg (SImode, XEXP (operands[1], 0));
8034 else
8035 {
8036 op = XEXP (operands[1], 0);
8037 if (GET_CODE (op) == SYMBOL_REF)
8038 {
8039 /* Handle special call to buggy powf function. */
8040 if (TARGET_HPUX && !TARGET_SOFT_FLOAT
8041 && !strcmp (targetm.strip_name_encoding (XSTR (op, 0)), "powf"))
8042 call_powf = true;
8043
8044 /* Generate indirect long calls to non-local functions. */
8045 else if (TARGET_LONG_CALLS)
8046 {
8047 tree call_decl = SYMBOL_REF_DECL (op);
8048 if (!(call_decl && targetm.binds_local_p (call_decl)))
8049 op = force_reg (word_mode, op);
8050 }
8051 }
8052 }
8053
8054 if (TARGET_64BIT)
8055 {
8056 if (!virtuals_instantiated)
8057 emit_move_insn (arg_pointer_rtx,
8058 gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
8059 GEN_INT (64)));
8060 else
8061 {
8062 /* The loop pass can generate new libcalls after the virtual
8063 registers are instantiated when fpregs are disabled because
8064 the only method that we have for doing DImode multiplication
8065 is with a libcall. This could be trouble if we haven't
8066 allocated enough space for the outgoing arguments. */
8067 gcc_assert (INTVAL (nb) <= crtl->outgoing_args_size);
8068
8069 emit_move_insn (arg_pointer_rtx,
8070 gen_rtx_PLUS (word_mode, stack_pointer_rtx,
8071 GEN_INT (STACK_POINTER_OFFSET + 64)));
8072 }
8073 }
8074
8075 /* Use two different patterns for calls to explicitly named functions
8076 and calls through function pointers. This is necessary as these two
8077 types of calls use different calling conventions, and CSE might try
8078 to change the named call into an indirect call in some cases (using
8079 two patterns keeps CSE from performing this optimization).
8080
8081 We now use even more call patterns as there was a subtle bug in
8082 attempting to restore the pic register after a call using a simple
8083 move insn. During reload, a instruction involving a pseudo register
8084 with no explicit dependence on the PIC register can be converted
8085 to an equivalent load from memory using the PIC register. If we
8086 emit a simple move to restore the PIC register in the initial rtl
8087 generation, then it can potentially be repositioned during scheduling.
8088 and an instruction that eventually uses the PIC register may end up
8089 between the call and the PIC register restore.
8090
8091 This only worked because there is a post call group of instructions
8092 that are scheduled with the call. These instructions are included
8093 in the same basic block as the call. However, calls can throw in
8094 C++ code and a basic block has to terminate at the call if the call
8095 can throw. This results in the PIC register restore being scheduled
8096 independently from the call. So, we now hide the save and restore
8097 of the PIC register in the call pattern until after reload. Then,
8098 we split the moves out. A small side benefit is that we now don't
8099 need to have a use of the PIC register in the return pattern and
8100 the final save/restore operation is not needed.
8101
8102 I elected to just use register %r4 in the PIC patterns instead
8103 of trying to force hppa_pic_save_rtx () to a callee saved register.
8104 This might have required a new register class and constraint. It
8105 was also simpler to just handle the restore from a register than a
8106 generic pseudo. */
8107 if (TARGET_64BIT)
8108 {
8109 rtx r4 = gen_rtx_REG (word_mode, 4);
8110 if (GET_CODE (op) == SYMBOL_REF)
8111 {
8112 if (call_powf)
8113 emit_call_insn (gen_call_val_powf_64bit (dst, op, nb, r4));
8114 else
8115 emit_call_insn (gen_call_val_symref_64bit (dst, op, nb, r4));
8116 }
8117 else
8118 {
8119 op = force_reg (word_mode, op);
8120 emit_call_insn (gen_call_val_reg_64bit (dst, op, nb, r4));
8121 }
8122 }
8123 else
8124 {
8125 if (GET_CODE (op) == SYMBOL_REF)
8126 {
8127 if (flag_pic)
8128 {
8129 rtx r4 = gen_rtx_REG (word_mode, 4);
8130
8131 if (call_powf)
8132 emit_call_insn (gen_call_val_powf_pic (dst, op, nb, r4));
8133 else
8134 emit_call_insn (gen_call_val_symref_pic (dst, op, nb, r4));
8135 }
8136 else
8137 {
8138 if (call_powf)
8139 emit_call_insn (gen_call_val_powf (dst, op, nb));
8140 else
8141 emit_call_insn (gen_call_val_symref (dst, op, nb));
8142 }
8143 }
8144 else
8145 {
8146 rtx tmpreg = gen_rtx_REG (word_mode, 22);
8147 emit_move_insn (tmpreg, force_reg (word_mode, op));
8148 if (flag_pic)
8149 {
8150 rtx r4 = gen_rtx_REG (word_mode, 4);
8151 emit_call_insn (gen_call_val_reg_pic (dst, nb, r4));
8152 }
8153 else
8154 emit_call_insn (gen_call_val_reg (dst, nb));
8155 }
8156 }
8157
8158 DONE;
8159 })
8160
8161 (define_insn "call_val_symref"
8162 [(set (match_operand 0 "" "")
8163 (call (mem:SI (match_operand 1 "call_operand_address" ""))
8164 (match_operand 2 "" "i")))
8165 (clobber (reg:SI 1))
8166 (clobber (reg:SI 2))
8167 (use (const_int 0))]
8168 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8169 "*
8170 {
8171 pa_output_arg_descriptor (insn);
8172 return pa_output_call (insn, operands[1], 0);
8173 }"
8174 [(set_attr "type" "call")
8175 (set (attr "length")
8176 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8177 (symbol_ref "pa_attr_length_call (insn, 0)")))])
8178
8179 ;; powf function clobbers %fr12
8180 (define_insn "call_val_powf"
8181 [(set (match_operand 0 "" "")
8182 (call (mem:SI (match_operand 1 "call_operand_address" ""))
8183 (match_operand 2 "" "i")))
8184 (clobber (reg:SI 1))
8185 (clobber (reg:SI 2))
8186 (clobber (reg:DF 48))
8187 (use (const_int 1))]
8188 "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8189 "*
8190 {
8191 pa_output_arg_descriptor (insn);
8192 return pa_output_call (insn, operands[1], 0);
8193 }"
8194 [(set_attr "type" "call")
8195 (set (attr "length")
8196 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8197 (symbol_ref "pa_attr_length_call (insn, 0)")))])
8198
8199 (define_insn "call_val_symref_pic"
8200 [(set (match_operand 0 "" "")
8201 (call (mem:SI (match_operand 1 "call_operand_address" ""))
8202 (match_operand 2 "" "i")))
8203 (clobber (reg:SI 1))
8204 (clobber (reg:SI 2))
8205 (clobber (match_operand 3))
8206 (use (reg:SI 19))
8207 (use (const_int 0))]
8208 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8209 "#")
8210
8211 ;; Split out the PIC register save and restore after reload. As the
8212 ;; split is done after reload, there are some situations in which we
8213 ;; unnecessarily save and restore %r4. This happens when there is a
8214 ;; single call and the PIC register is not used after the call.
8215 ;;
8216 ;; The split has to be done since call_from_call_insn () can't handle
8217 ;; the pattern as is. Noreturn calls are special because they have to
8218 ;; terminate the basic block. The split has to contain more than one
8219 ;; insn.
8220 (define_split
8221 [(parallel [(set (match_operand 0 "" "")
8222 (call (mem:SI (match_operand 1 "call_operand_address" ""))
8223 (match_operand 2 "" "")))
8224 (clobber (reg:SI 1))
8225 (clobber (reg:SI 2))
8226 (clobber (match_operand 3))
8227 (use (reg:SI 19))
8228 (use (const_int 0))])]
8229 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed
8230 && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8231 [(set (match_dup 3) (reg:SI 19))
8232 (parallel [(set (match_dup 0)
8233 (call (mem:SI (match_dup 1))
8234 (match_dup 2)))
8235 (clobber (reg:SI 1))
8236 (clobber (reg:SI 2))
8237 (use (reg:SI 19))
8238 (use (const_int 0))])]
8239 "")
8240
8241 (define_split
8242 [(parallel [(set (match_operand 0 "" "")
8243 (call (mem:SI (match_operand 1 "call_operand_address" ""))
8244 (match_operand 2 "" "")))
8245 (clobber (reg:SI 1))
8246 (clobber (reg:SI 2))
8247 (clobber (match_operand 3))
8248 (use (reg:SI 19))
8249 (use (const_int 0))])]
8250 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
8251 [(set (match_dup 3) (reg:SI 19))
8252 (parallel [(set (match_dup 0)
8253 (call (mem:SI (match_dup 1))
8254 (match_dup 2)))
8255 (clobber (reg:SI 1))
8256 (clobber (reg:SI 2))
8257 (use (reg:SI 19))
8258 (use (const_int 0))])
8259 (set (reg:SI 19) (match_dup 3))]
8260 "")
8261
8262 (define_insn "*call_val_symref_pic_post_reload"
8263 [(set (match_operand 0 "" "")
8264 (call (mem:SI (match_operand 1 "call_operand_address" ""))
8265 (match_operand 2 "" "i")))
8266 (clobber (reg:SI 1))
8267 (clobber (reg:SI 2))
8268 (use (reg:SI 19))
8269 (use (const_int 0))]
8270 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8271 "*
8272 {
8273 pa_output_arg_descriptor (insn);
8274 return pa_output_call (insn, operands[1], 0);
8275 }"
8276 [(set_attr "type" "call")
8277 (set (attr "length")
8278 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8279 (symbol_ref "pa_attr_length_call (insn, 0)")))])
8280
8281 ;; powf function clobbers %fr12
8282 (define_insn "call_val_powf_pic"
8283 [(set (match_operand 0 "" "")
8284 (call (mem:SI (match_operand 1 "call_operand_address" ""))
8285 (match_operand 2 "" "i")))
8286 (clobber (reg:SI 1))
8287 (clobber (reg:SI 2))
8288 (clobber (reg:DF 48))
8289 (clobber (match_operand 3))
8290 (use (reg:SI 19))
8291 (use (const_int 1))]
8292 "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8293 "#")
8294
8295 ;; Split out the PIC register save and restore after reload. As the
8296 ;; split is done after reload, there are some situations in which we
8297 ;; unnecessarily save and restore %r4. This happens when there is a
8298 ;; single call and the PIC register is not used after the call.
8299 ;;
8300 ;; The split has to be done since call_from_call_insn () can't handle
8301 ;; the pattern as is. Noreturn calls are special because they have to
8302 ;; terminate the basic block. The split has to contain more than one
8303 ;; insn.
8304 (define_split
8305 [(parallel [(set (match_operand 0 "" "")
8306 (call (mem:SI (match_operand 1 "call_operand_address" ""))
8307 (match_operand 2 "" "")))
8308 (clobber (reg:SI 1))
8309 (clobber (reg:SI 2))
8310 (clobber (reg:DF 48))
8311 (clobber (match_operand 3))
8312 (use (reg:SI 19))
8313 (use (const_int 1))])]
8314 "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed
8315 && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8316 [(set (match_dup 3) (reg:SI 19))
8317 (parallel [(set (match_dup 0)
8318 (call (mem:SI (match_dup 1))
8319 (match_dup 2)))
8320 (clobber (reg:SI 1))
8321 (clobber (reg:SI 2))
8322 (clobber (reg:DF 48))
8323 (use (reg:SI 19))
8324 (use (const_int 1))])]
8325 "")
8326
8327 (define_split
8328 [(parallel [(set (match_operand 0 "" "")
8329 (call (mem:SI (match_operand 1 "call_operand_address" ""))
8330 (match_operand 2 "" "")))
8331 (clobber (reg:SI 1))
8332 (clobber (reg:SI 2))
8333 (clobber (reg:DF 48))
8334 (clobber (match_operand 3))
8335 (use (reg:SI 19))
8336 (use (const_int 1))])]
8337 "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
8338 [(set (match_dup 3) (reg:SI 19))
8339 (parallel [(set (match_dup 0)
8340 (call (mem:SI (match_dup 1))
8341 (match_dup 2)))
8342 (clobber (reg:SI 1))
8343 (clobber (reg:SI 2))
8344 (clobber (reg:DF 48))
8345 (use (reg:SI 19))
8346 (use (const_int 1))])
8347 (set (reg:SI 19) (match_dup 3))]
8348 "")
8349
8350 (define_insn "*call_val_powf_pic_post_reload"
8351 [(set (match_operand 0 "" "")
8352 (call (mem:SI (match_operand 1 "call_operand_address" ""))
8353 (match_operand 2 "" "i")))
8354 (clobber (reg:SI 1))
8355 (clobber (reg:SI 2))
8356 (clobber (reg:DF 48))
8357 (use (reg:SI 19))
8358 (use (const_int 1))]
8359 "TARGET_HPUX && !TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8360 "*
8361 {
8362 pa_output_arg_descriptor (insn);
8363 return pa_output_call (insn, operands[1], 0);
8364 }"
8365 [(set_attr "type" "call")
8366 (set (attr "length")
8367 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8368 (symbol_ref "pa_attr_length_call (insn, 0)")))])
8369
8370 ;; This pattern is split if it is necessary to save and restore the
8371 ;; PIC register.
8372 (define_insn "call_val_symref_64bit"
8373 [(set (match_operand 0 "" "")
8374 (call (mem:SI (match_operand 1 "call_operand_address" ""))
8375 (match_operand 2 "" "i")))
8376 (clobber (reg:DI 1))
8377 (clobber (reg:DI 2))
8378 (clobber (match_operand 3))
8379 (use (reg:DI 27))
8380 (use (reg:DI 29))
8381 (use (const_int 0))]
8382 "TARGET_64BIT"
8383 "#")
8384
8385 ;; Split out the PIC register save and restore after reload. As the
8386 ;; split is done after reload, there are some situations in which we
8387 ;; unnecessarily save and restore %r4. This happens when there is a
8388 ;; single call and the PIC register is not used after the call.
8389 ;;
8390 ;; The split has to be done since call_from_call_insn () can't handle
8391 ;; the pattern as is. Noreturn calls are special because they have to
8392 ;; terminate the basic block. The split has to contain more than one
8393 ;; insn.
8394 (define_split
8395 [(parallel [(set (match_operand 0 "" "")
8396 (call (mem:SI (match_operand 1 "call_operand_address" ""))
8397 (match_operand 2 "" "")))
8398 (clobber (reg:DI 1))
8399 (clobber (reg:DI 2))
8400 (clobber (match_operand 3))
8401 (use (reg:DI 27))
8402 (use (reg:DI 29))
8403 (use (const_int 0))])]
8404 "TARGET_64BIT && reload_completed
8405 && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8406 [(set (match_dup 3) (reg:DI 27))
8407 (parallel [(set (match_dup 0)
8408 (call (mem:SI (match_dup 1))
8409 (match_dup 2)))
8410 (clobber (reg:DI 1))
8411 (clobber (reg:DI 2))
8412 (use (reg:DI 27))
8413 (use (reg:DI 29))
8414 (use (const_int 0))])]
8415 "")
8416
8417 (define_split
8418 [(parallel [(set (match_operand 0 "" "")
8419 (call (mem:SI (match_operand 1 "call_operand_address" ""))
8420 (match_operand 2 "" "")))
8421 (clobber (reg:DI 1))
8422 (clobber (reg:DI 2))
8423 (clobber (match_operand 3))
8424 (use (reg:DI 27))
8425 (use (reg:DI 29))
8426 (use (const_int 0))])]
8427 "TARGET_64BIT && reload_completed"
8428 [(set (match_dup 3) (reg:DI 27))
8429 (parallel [(set (match_dup 0)
8430 (call (mem:SI (match_dup 1))
8431 (match_dup 2)))
8432 (clobber (reg:DI 1))
8433 (clobber (reg:DI 2))
8434 (use (reg:DI 27))
8435 (use (reg:DI 29))
8436 (use (const_int 0))])
8437 (set (reg:DI 27) (match_dup 3))]
8438 "")
8439
8440 (define_insn "*call_val_symref_64bit_post_reload"
8441 [(set (match_operand 0 "" "")
8442 (call (mem:SI (match_operand 1 "call_operand_address" ""))
8443 (match_operand 2 "" "i")))
8444 (clobber (reg:DI 1))
8445 (clobber (reg:DI 2))
8446 (use (reg:DI 27))
8447 (use (reg:DI 29))
8448 (use (const_int 0))]
8449 "TARGET_64BIT"
8450 "*
8451 {
8452 return pa_output_call (insn, operands[1], 0);
8453 }"
8454 [(set_attr "type" "call")
8455 (set (attr "length")
8456 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8457 (symbol_ref "pa_attr_length_call (insn, 0)")))])
8458
8459 ;; powf function clobbers %fr12
8460 (define_insn "call_val_powf_64bit"
8461 [(set (match_operand 0 "" "")
8462 (call (mem:SI (match_operand 1 "call_operand_address" ""))
8463 (match_operand 2 "" "i")))
8464 (clobber (reg:DI 1))
8465 (clobber (reg:DI 2))
8466 (clobber (reg:DF 40))
8467 (clobber (match_operand 3))
8468 (use (reg:DI 27))
8469 (use (reg:DI 29))
8470 (use (const_int 1))]
8471 "TARGET_64BIT && TARGET_HPUX"
8472 "#")
8473
8474 ;; Split out the PIC register save and restore after reload. As the
8475 ;; split is done after reload, there are some situations in which we
8476 ;; unnecessarily save and restore %r4. This happens when there is a
8477 ;; single call and the PIC register is not used after the call.
8478 ;;
8479 ;; The split has to be done since call_from_call_insn () can't handle
8480 ;; the pattern as is. Noreturn calls are special because they have to
8481 ;; terminate the basic block. The split has to contain more than one
8482 ;; insn.
8483 (define_split
8484 [(parallel [(set (match_operand 0 "" "")
8485 (call (mem:SI (match_operand 1 "call_operand_address" ""))
8486 (match_operand 2 "" "")))
8487 (clobber (reg:DI 1))
8488 (clobber (reg:DI 2))
8489 (clobber (reg:DF 40))
8490 (clobber (match_operand 3))
8491 (use (reg:DI 27))
8492 (use (reg:DI 29))
8493 (use (const_int 1))])]
8494 "TARGET_64BIT && TARGET_HPUX && reload_completed
8495 && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8496 [(set (match_dup 3) (reg:DI 27))
8497 (parallel [(set (match_dup 0)
8498 (call (mem:SI (match_dup 1))
8499 (match_dup 2)))
8500 (clobber (reg:DI 1))
8501 (clobber (reg:DI 2))
8502 (clobber (reg:DF 40))
8503 (use (reg:DI 27))
8504 (use (reg:DI 29))
8505 (use (const_int 1))])]
8506 "")
8507
8508 (define_split
8509 [(parallel [(set (match_operand 0 "" "")
8510 (call (mem:SI (match_operand 1 "call_operand_address" ""))
8511 (match_operand 2 "" "")))
8512 (clobber (reg:DI 1))
8513 (clobber (reg:DI 2))
8514 (clobber (reg:DF 40))
8515 (clobber (match_operand 3))
8516 (use (reg:DI 27))
8517 (use (reg:DI 29))
8518 (use (const_int 1))])]
8519 "TARGET_64BIT && TARGET_HPUX && reload_completed"
8520 [(set (match_dup 3) (reg:DI 27))
8521 (parallel [(set (match_dup 0)
8522 (call (mem:SI (match_dup 1))
8523 (match_dup 2)))
8524 (clobber (reg:DI 1))
8525 (clobber (reg:DI 2))
8526 (clobber (reg:DF 40))
8527 (use (reg:DI 27))
8528 (use (reg:DI 29))
8529 (use (const_int 1))])
8530 (set (reg:DI 27) (match_dup 3))]
8531 "")
8532
8533 (define_insn "*call_val_powf_64bit_post_reload"
8534 [(set (match_operand 0 "" "")
8535 (call (mem:SI (match_operand 1 "call_operand_address" ""))
8536 (match_operand 2 "" "i")))
8537 (clobber (reg:DI 1))
8538 (clobber (reg:DI 2))
8539 (clobber (reg:DF 40))
8540 (use (reg:DI 27))
8541 (use (reg:DI 29))
8542 (use (const_int 1))]
8543 "TARGET_64BIT && TARGET_HPUX"
8544 "*
8545 {
8546 return pa_output_call (insn, operands[1], 0);
8547 }"
8548 [(set_attr "type" "call")
8549 (set (attr "length")
8550 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8551 (symbol_ref "pa_attr_length_call (insn, 0)")))])
8552
8553 (define_insn "call_val_reg"
8554 [(set (match_operand 0 "" "")
8555 (call (mem:SI (reg:SI 22))
8556 (match_operand 1 "" "i")))
8557 (clobber (reg:SI 1))
8558 (clobber (reg:SI 2))
8559 (use (const_int 1))]
8560 "!TARGET_64BIT"
8561 "*
8562 {
8563 return pa_output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
8564 }"
8565 [(set_attr "type" "dyncall")
8566 (set (attr "length")
8567 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8568 (symbol_ref "pa_attr_length_indirect_call (insn)")))])
8569
8570 ;; This pattern is split if it is necessary to save and restore the
8571 ;; PIC register.
8572 (define_insn "call_val_reg_pic"
8573 [(set (match_operand 0 "" "")
8574 (call (mem:SI (reg:SI 22))
8575 (match_operand 1 "" "i")))
8576 (clobber (reg:SI 1))
8577 (clobber (reg:SI 2))
8578 (clobber (match_operand 2))
8579 (use (reg:SI 19))
8580 (use (const_int 1))]
8581 "!TARGET_64BIT"
8582 "#")
8583
8584 ;; Split out the PIC register save and restore after reload. As the
8585 ;; split is done after reload, there are some situations in which we
8586 ;; unnecessarily save and restore %r4. This happens when there is a
8587 ;; single call and the PIC register is not used after the call.
8588 ;;
8589 ;; The split has to be done since call_from_call_insn () can't handle
8590 ;; the pattern as is. Noreturn calls are special because they have to
8591 ;; terminate the basic block. The split has to contain more than one
8592 ;; insn.
8593 (define_split
8594 [(parallel [(set (match_operand 0 "" "")
8595 (call (mem:SI (reg:SI 22))
8596 (match_operand 1 "" "")))
8597 (clobber (reg:SI 1))
8598 (clobber (reg:SI 2))
8599 (clobber (match_operand 2))
8600 (use (reg:SI 19))
8601 (use (const_int 1))])]
8602 "!TARGET_64BIT && reload_completed
8603 && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8604 [(set (match_dup 2) (reg:SI 19))
8605 (parallel [(set (match_dup 0)
8606 (call (mem:SI (reg:SI 22))
8607 (match_dup 1)))
8608 (clobber (reg:SI 1))
8609 (clobber (reg:SI 2))
8610 (use (reg:SI 19))
8611 (use (const_int 1))])]
8612 "")
8613
8614 (define_split
8615 [(parallel [(set (match_operand 0 "" "")
8616 (call (mem:SI (reg:SI 22))
8617 (match_operand 1 "" "")))
8618 (clobber (reg:SI 1))
8619 (clobber (reg:SI 2))
8620 (clobber (match_operand 2))
8621 (use (reg:SI 19))
8622 (use (const_int 1))])]
8623 "!TARGET_64BIT && reload_completed"
8624 [(set (match_dup 2) (reg:SI 19))
8625 (parallel [(set (match_dup 0)
8626 (call (mem:SI (reg:SI 22))
8627 (match_dup 1)))
8628 (clobber (reg:SI 1))
8629 (clobber (reg:SI 2))
8630 (use (reg:SI 19))
8631 (use (const_int 1))])
8632 (set (reg:SI 19) (match_dup 2))]
8633 "")
8634
8635 (define_insn "*call_val_reg_pic_post_reload"
8636 [(set (match_operand 0 "" "")
8637 (call (mem:SI (reg:SI 22))
8638 (match_operand 1 "" "i")))
8639 (clobber (reg:SI 1))
8640 (clobber (reg:SI 2))
8641 (use (reg:SI 19))
8642 (use (const_int 1))]
8643 "!TARGET_64BIT"
8644 "*
8645 {
8646 return pa_output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
8647 }"
8648 [(set_attr "type" "dyncall")
8649 (set (attr "length")
8650 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8651 (symbol_ref "pa_attr_length_indirect_call (insn)")))])
8652
8653 ;; This pattern is split if it is necessary to save and restore the
8654 ;; PIC register.
8655 (define_insn "call_val_reg_64bit"
8656 [(set (match_operand 0 "" "")
8657 (call (mem:SI (match_operand:DI 1 "register_operand" "r"))
8658 (match_operand 2 "" "i")))
8659 (clobber (reg:DI 2))
8660 (clobber (match_operand 3))
8661 (use (reg:DI 27))
8662 (use (reg:DI 29))
8663 (use (const_int 1))]
8664 "TARGET_64BIT"
8665 "#")
8666
8667 ;; Split out the PIC register save and restore after reload. As the
8668 ;; split is done after reload, there are some situations in which we
8669 ;; unnecessarily save and restore %r4. This happens when there is a
8670 ;; single call and the PIC register is not used after the call.
8671 ;;
8672 ;; The split has to be done since call_from_call_insn () can't handle
8673 ;; the pattern as is. Noreturn calls are special because they have to
8674 ;; terminate the basic block. The split has to contain more than one
8675 ;; insn.
8676 (define_split
8677 [(parallel [(set (match_operand 0 "" "")
8678 (call (mem:SI (match_operand:DI 1 "register_operand" ""))
8679 (match_operand 2 "" "")))
8680 (clobber (reg:DI 2))
8681 (clobber (match_operand 3))
8682 (use (reg:DI 27))
8683 (use (reg:DI 29))
8684 (use (const_int 1))])]
8685 "TARGET_64BIT && reload_completed
8686 && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8687 [(set (match_dup 3) (reg:DI 27))
8688 (parallel [(set (match_dup 0)
8689 (call (mem:SI (match_dup 1))
8690 (match_dup 2)))
8691 (clobber (reg:DI 2))
8692 (use (reg:DI 27))
8693 (use (reg:DI 29))
8694 (use (const_int 1))])]
8695 "")
8696
8697 (define_split
8698 [(parallel [(set (match_operand 0 "" "")
8699 (call (mem:SI (match_operand:DI 1 "register_operand" ""))
8700 (match_operand 2 "" "")))
8701 (clobber (reg:DI 2))
8702 (clobber (match_operand 3))
8703 (use (reg:DI 27))
8704 (use (reg:DI 29))
8705 (use (const_int 1))])]
8706 "TARGET_64BIT && reload_completed"
8707 [(set (match_dup 3) (reg:DI 27))
8708 (parallel [(set (match_dup 0)
8709 (call (mem:SI (match_dup 1))
8710 (match_dup 2)))
8711 (clobber (reg:DI 2))
8712 (use (reg:DI 27))
8713 (use (reg:DI 29))
8714 (use (const_int 1))])
8715 (set (reg:DI 27) (match_dup 3))]
8716 "")
8717
8718 (define_insn "*call_val_reg_64bit_post_reload"
8719 [(set (match_operand 0 "" "")
8720 (call (mem:SI (match_operand:DI 1 "register_operand" "r"))
8721 (match_operand 2 "" "i")))
8722 (clobber (reg:DI 2))
8723 (use (reg:DI 27))
8724 (use (reg:DI 29))
8725 (use (const_int 1))]
8726 "TARGET_64BIT"
8727 "*
8728 {
8729 return pa_output_indirect_call (insn, operands[1]);
8730 }"
8731 [(set_attr "type" "dyncall")
8732 (set (attr "length")
8733 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 12)]
8734 (symbol_ref "pa_attr_length_indirect_call (insn)")))])
8735
8736 /* Expand special pc-relative call to _mcount. */
8737
8738 (define_expand "call_mcount"
8739 [(parallel [(call (match_operand:SI 0 "" "")
8740 (match_operand 1 "" ""))
8741 (set (reg:SI 25)
8742 (plus:SI (reg:SI 2)
8743 (minus:SI (match_operand 2 "" "")
8744 (plus:SI (pc) (const_int 4)))))
8745 (clobber (reg:SI 2))])]
8746 "!TARGET_PORTABLE_RUNTIME"
8747 "
8748 {
8749 rtx op = XEXP (operands[0], 0);
8750 rtx nb = operands[1];
8751 rtx lab = operands[2];
8752
8753 if (TARGET_64BIT)
8754 {
8755 rtx r4 = gen_rtx_REG (word_mode, 4);
8756 emit_move_insn (arg_pointer_rtx,
8757 gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
8758 GEN_INT (64)));
8759 emit_call_insn (gen_call_mcount_64bit (op, nb, lab, r4));
8760 }
8761 else
8762 {
8763 if (flag_pic)
8764 {
8765 rtx r4 = gen_rtx_REG (word_mode, 4);
8766 emit_call_insn (gen_call_mcount_pic (op, nb, lab, r4));
8767 }
8768 else
8769 emit_call_insn (gen_call_mcount_nonpic (op, nb, lab));
8770 }
8771
8772 DONE;
8773 }")
8774
8775 (define_insn "call_mcount_nonpic"
8776 [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8777 (match_operand 1 "" "i"))
8778 (set (reg:SI 25)
8779 (plus:SI (reg:SI 2)
8780 (minus:SI (match_operand 2 "" "")
8781 (plus:SI (pc) (const_int 4)))))
8782 (clobber (reg:SI 2))]
8783 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8784 "*
8785 {
8786 pa_output_arg_descriptor (insn);
8787 return \"{bl|b,l} %0,%%r2\;ldo %2-.-4(%%r2),%%r25\";
8788 }"
8789 [(set_attr "type" "multi")
8790 (set_attr "length" "8")])
8791
8792 (define_insn "call_mcount_pic"
8793 [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8794 (match_operand 1 "" "i"))
8795 (set (reg:SI 25)
8796 (plus:SI (reg:SI 2)
8797 (minus:SI (match_operand 2 "" "")
8798 (plus:SI (pc) (const_int 4)))))
8799 (clobber (reg:SI 2))
8800 (clobber (match_operand 3))
8801 (use (reg:SI 19))]
8802 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8803 "#")
8804
8805 (define_split
8806 [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8807 (match_operand 1 "" ""))
8808 (set (reg:SI 25)
8809 (plus:SI (reg:SI 2)
8810 (minus:SI (match_operand 2 "" "")
8811 (plus:SI (pc) (const_int 4)))))
8812 (clobber (reg:SI 2))
8813 (clobber (match_operand 3))
8814 (use (reg:SI 19))])]
8815 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
8816 [(set (match_dup 3) (reg:SI 19))
8817 (parallel [(call (mem:SI (match_dup 0))
8818 (match_dup 1))
8819 (set (reg:SI 25)
8820 (plus:SI (reg:SI 2)
8821 (minus:SI (match_dup 2)
8822 (plus:SI (pc) (const_int 4)))))
8823 (clobber (reg:SI 2))
8824 (use (reg:SI 19))])
8825 (set (reg:SI 19) (match_dup 3))]
8826 "")
8827
8828 (define_insn "*call_mcount_pic_post_reload"
8829 [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8830 (match_operand 1 "" "i"))
8831 (set (reg:SI 25)
8832 (plus:SI (reg:SI 2)
8833 (minus:SI (match_operand 2 "" "")
8834 (plus:SI (pc) (const_int 4)))))
8835 (clobber (reg:SI 2))
8836 (use (reg:SI 19))]
8837 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8838 "*
8839 {
8840 pa_output_arg_descriptor (insn);
8841 return \"{bl|b,l} %0,%%r2\;ldo %2-.-4(%%r2),%%r25\";
8842 }"
8843 [(set_attr "type" "multi")
8844 (set_attr "length" "8")])
8845
8846 (define_insn "call_mcount_64bit"
8847 [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8848 (match_operand 1 "" "i"))
8849 (set (reg:SI 25)
8850 (plus:SI (reg:SI 2)
8851 (minus:SI (match_operand 2 "" "")
8852 (plus:SI (pc) (const_int 4)))))
8853 (clobber (reg:DI 2))
8854 (clobber (match_operand 3))
8855 (use (reg:DI 27))
8856 (use (reg:DI 29))]
8857 "TARGET_64BIT"
8858 "#")
8859
8860 (define_split
8861 [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8862 (match_operand 1 "" ""))
8863 (set (reg:SI 25)
8864 (plus:SI (reg:SI 2)
8865 (minus:SI (match_operand 2 "" "")
8866 (plus:SI (pc) (const_int 4)))))
8867 (clobber (reg:DI 2))
8868 (clobber (match_operand 3))
8869 (use (reg:DI 27))
8870 (use (reg:DI 29))])]
8871 "TARGET_64BIT && reload_completed"
8872 [(set (match_dup 3) (reg:DI 27))
8873 (parallel [(call (mem:SI (match_dup 0))
8874 (match_dup 1))
8875 (set (reg:SI 25)
8876 (plus:SI (reg:SI 2)
8877 (minus:SI (match_dup 2)
8878 (plus:SI (pc) (const_int 4)))))
8879 (clobber (reg:DI 2))
8880 (use (reg:DI 27))
8881 (use (reg:DI 29))])
8882 (set (reg:DI 27) (match_dup 3))]
8883 "")
8884
8885 (define_insn "*call_mcount_64bit_post_reload"
8886 [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8887 (match_operand 1 "" "i"))
8888 (set (reg:SI 25)
8889 (plus:SI (reg:SI 2)
8890 (minus:SI (match_operand 2 "" "")
8891 (plus:SI (pc) (const_int 4)))))
8892 (clobber (reg:DI 2))
8893 (use (reg:DI 27))
8894 (use (reg:DI 29))]
8895 "TARGET_64BIT"
8896 "{bl|b,l} %0,%%r2\;ldo %2-.-4(%%r2),%%r25"
8897 [(set_attr "type" "multi")
8898 (set_attr "length" "8")])
8899
8900 ;; Call subroutine returning any type.
8901
8902 (define_expand "untyped_call"
8903 [(parallel [(call (match_operand 0 "" "")
8904 (const_int 0))
8905 (match_operand 1 "" "")
8906 (match_operand 2 "" "")])]
8907 ""
8908 "
8909 {
8910 int i;
8911
8912 emit_call_insn (gen_call (operands[0], const0_rtx));
8913
8914 for (i = 0; i < XVECLEN (operands[2], 0); i++)
8915 {
8916 rtx set = XVECEXP (operands[2], 0, i);
8917 emit_move_insn (SET_DEST (set), SET_SRC (set));
8918 }
8919
8920 /* The optimizer does not know that the call sets the function value
8921 registers we stored in the result block. We avoid problems by
8922 claiming that all hard registers are used and clobbered at this
8923 point. */
8924 emit_insn (gen_blockage ());
8925
8926 DONE;
8927 }")
8928
8929 (define_expand "sibcall"
8930 [(call (match_operand:SI 0 "" "")
8931 (match_operand 1 "" ""))]
8932 "!TARGET_PORTABLE_RUNTIME"
8933 "
8934 {
8935 rtx op, call_insn;
8936 rtx nb = operands[1];
8937
8938 op = XEXP (operands[0], 0);
8939
8940 if (TARGET_64BIT)
8941 {
8942 if (!virtuals_instantiated)
8943 emit_move_insn (arg_pointer_rtx,
8944 gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
8945 GEN_INT (64)));
8946 else
8947 {
8948 /* The loop pass can generate new libcalls after the virtual
8949 registers are instantiated when fpregs are disabled because
8950 the only method that we have for doing DImode multiplication
8951 is with a libcall. This could be trouble if we haven't
8952 allocated enough space for the outgoing arguments. */
8953 gcc_assert (INTVAL (nb) <= crtl->outgoing_args_size);
8954
8955 emit_move_insn (arg_pointer_rtx,
8956 gen_rtx_PLUS (word_mode, stack_pointer_rtx,
8957 GEN_INT (STACK_POINTER_OFFSET + 64)));
8958 }
8959 }
8960
8961 /* Indirect sibling calls are not allowed. */
8962 if (TARGET_64BIT)
8963 call_insn = gen_sibcall_internal_symref_64bit (op, operands[1]);
8964 else
8965 call_insn = gen_sibcall_internal_symref (op, operands[1]);
8966
8967 call_insn = emit_call_insn (call_insn);
8968
8969 if (TARGET_64BIT)
8970 use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), arg_pointer_rtx);
8971
8972 /* We don't have to restore the PIC register. */
8973 if (flag_pic)
8974 use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
8975
8976 DONE;
8977 }")
8978
8979 (define_insn "sibcall_internal_symref"
8980 [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8981 (match_operand 1 "" "i"))
8982 (clobber (reg:SI 1))
8983 (use (reg:SI 2))
8984 (use (const_int 0))]
8985 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8986 "*
8987 {
8988 pa_output_arg_descriptor (insn);
8989 return pa_output_call (insn, operands[0], 1);
8990 }"
8991 [(set_attr "type" "sibcall")
8992 (set (attr "length")
8993 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
8994 (symbol_ref "pa_attr_length_call (insn, 1)")))])
8995
8996 (define_insn "sibcall_internal_symref_64bit"
8997 [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8998 (match_operand 1 "" "i"))
8999 (clobber (reg:DI 1))
9000 (use (reg:DI 2))
9001 (use (const_int 0))]
9002 "TARGET_64BIT"
9003 "*
9004 {
9005 return pa_output_call (insn, operands[0], 1);
9006 }"
9007 [(set_attr "type" "sibcall")
9008 (set (attr "length")
9009 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
9010 (symbol_ref "pa_attr_length_call (insn, 1)")))])
9011
9012 (define_expand "sibcall_value"
9013 [(set (match_operand 0 "" "")
9014 (call (match_operand:SI 1 "" "")
9015 (match_operand 2 "" "")))]
9016 "!TARGET_PORTABLE_RUNTIME"
9017 "
9018 {
9019 rtx op, call_insn;
9020 rtx nb = operands[1];
9021
9022 op = XEXP (operands[1], 0);
9023
9024 if (TARGET_64BIT)
9025 {
9026 if (!virtuals_instantiated)
9027 emit_move_insn (arg_pointer_rtx,
9028 gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
9029 GEN_INT (64)));
9030 else
9031 {
9032 /* The loop pass can generate new libcalls after the virtual
9033 registers are instantiated when fpregs are disabled because
9034 the only method that we have for doing DImode multiplication
9035 is with a libcall. This could be trouble if we haven't
9036 allocated enough space for the outgoing arguments. */
9037 gcc_assert (INTVAL (nb) <= crtl->outgoing_args_size);
9038
9039 emit_move_insn (arg_pointer_rtx,
9040 gen_rtx_PLUS (word_mode, stack_pointer_rtx,
9041 GEN_INT (STACK_POINTER_OFFSET + 64)));
9042 }
9043 }
9044
9045 /* Indirect sibling calls are not allowed. */
9046 if (TARGET_64BIT)
9047 call_insn
9048 = gen_sibcall_value_internal_symref_64bit (operands[0], op, operands[2]);
9049 else
9050 call_insn
9051 = gen_sibcall_value_internal_symref (operands[0], op, operands[2]);
9052
9053 call_insn = emit_call_insn (call_insn);
9054
9055 if (TARGET_64BIT)
9056 use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), arg_pointer_rtx);
9057
9058 /* We don't have to restore the PIC register. */
9059 if (flag_pic)
9060 use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
9061
9062 DONE;
9063 }")
9064
9065 (define_insn "sibcall_value_internal_symref"
9066 [(set (match_operand 0 "" "")
9067 (call (mem:SI (match_operand 1 "call_operand_address" ""))
9068 (match_operand 2 "" "i")))
9069 (clobber (reg:SI 1))
9070 (use (reg:SI 2))
9071 (use (const_int 0))]
9072 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
9073 "*
9074 {
9075 pa_output_arg_descriptor (insn);
9076 return pa_output_call (insn, operands[1], 1);
9077 }"
9078 [(set_attr "type" "sibcall")
9079 (set (attr "length")
9080 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
9081 (symbol_ref "pa_attr_length_call (insn, 1)")))])
9082
9083 (define_insn "sibcall_value_internal_symref_64bit"
9084 [(set (match_operand 0 "" "")
9085 (call (mem:SI (match_operand 1 "call_operand_address" ""))
9086 (match_operand 2 "" "i")))
9087 (clobber (reg:DI 1))
9088 (use (reg:DI 2))
9089 (use (const_int 0))]
9090 "TARGET_64BIT"
9091 "*
9092 {
9093 return pa_output_call (insn, operands[1], 1);
9094 }"
9095 [(set_attr "type" "sibcall")
9096 (set (attr "length")
9097 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 8)]
9098 (symbol_ref "pa_attr_length_call (insn, 1)")))])
9099
9100 (define_insn "nop"
9101 [(const_int 0)]
9102 ""
9103 "nop"
9104 [(set_attr "type" "move")
9105 (set_attr "length" "4")])
9106
9107 ;;; EH does longjmp's from and within the data section. Thus,
9108 ;;; an interspace branch is required for the longjmp implementation.
9109 ;;; Registers r1 and r2 are used as scratch registers for the jump
9110 ;;; when necessary.
9111 (define_expand "interspace_jump"
9112 [(parallel
9113 [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
9114 (clobber (match_dup 1))])]
9115 ""
9116 "
9117 {
9118 operands[1] = gen_rtx_REG (word_mode, 2);
9119 }")
9120
9121 (define_insn ""
9122 [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
9123 (clobber (reg:SI 2))]
9124 "TARGET_PA_20 && !TARGET_64BIT"
9125 "bve%* (%0)"
9126 [(set_attr "type" "branch")
9127 (set_attr "length" "4")])
9128
9129 (define_insn ""
9130 [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
9131 (clobber (reg:SI 2))]
9132 "TARGET_NO_SPACE_REGS && !TARGET_64BIT"
9133 "be%* 0(%%sr4,%0)"
9134 [(set_attr "type" "branch")
9135 (set_attr "length" "4")])
9136
9137 (define_insn ""
9138 [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
9139 (clobber (reg:SI 2))]
9140 "!TARGET_64BIT"
9141 "ldsid (%%sr0,%0),%%r2\;mtsp %%r2,%%sr0\;be%* 0(%%sr0,%0)"
9142 [(set_attr "type" "branch")
9143 (set_attr "length" "12")])
9144
9145 (define_insn ""
9146 [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
9147 (clobber (reg:DI 2))]
9148 "TARGET_64BIT"
9149 "bve%* (%0)"
9150 [(set_attr "type" "branch")
9151 (set_attr "length" "4")])
9152
9153 (define_expand "builtin_longjmp"
9154 [(unspec_volatile [(match_operand 0 "register_operand" "r")] UNSPECV_LONGJMP)]
9155 ""
9156 "
9157 {
9158 /* The elements of the buffer are, in order: */
9159 rtx fp = gen_rtx_MEM (Pmode, operands[0]);
9160 rtx lab = gen_rtx_MEM (Pmode, plus_constant (Pmode, operands[0],
9161 POINTER_SIZE / BITS_PER_UNIT));
9162 rtx stack = gen_rtx_MEM (Pmode, plus_constant (Pmode, operands[0],
9163 (POINTER_SIZE * 2) / BITS_PER_UNIT));
9164 rtx pv = gen_rtx_REG (Pmode, 1);
9165
9166 emit_clobber (gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (VOIDmode)));
9167 emit_clobber (gen_rtx_MEM (BLKmode, hard_frame_pointer_rtx));
9168
9169 /* Load the label we are jumping through into r1 so that we know
9170 where to look for it when we get back to setjmp's function for
9171 restoring the gp. */
9172 emit_move_insn (pv, lab);
9173
9174 /* Restore the stack and frame pointers. */
9175 fp = copy_to_reg (fp);
9176 emit_stack_restore (SAVE_NONLOCAL, stack);
9177
9178 /* Ensure the frame pointer move is not optimized. */
9179 emit_insn (gen_blockage ());
9180 emit_clobber (hard_frame_pointer_rtx);
9181 emit_move_insn (hard_frame_pointer_rtx, fp);
9182
9183 emit_use (hard_frame_pointer_rtx);
9184 emit_use (stack_pointer_rtx);
9185
9186 /* Prevent the insns above from being scheduled into the delay slot
9187 of the interspace jump because the space register could change. */
9188 emit_insn (gen_blockage ());
9189
9190 emit_jump_insn (gen_interspace_jump (pv));
9191 emit_barrier ();
9192 DONE;
9193 }")
9194
9195 ;;; Operands 2 and 3 are assumed to be CONST_INTs.
9196 (define_expand "extzvsi"
9197 [(set (match_operand:SI 0 "register_operand" "")
9198 (zero_extract:SI (match_operand:SI 1 "register_operand" "")
9199 (match_operand:SI 2 "uint5_operand" "")
9200 (match_operand:SI 3 "uint5_operand" "")))]
9201 ""
9202 "
9203 {
9204 unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
9205 unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
9206
9207 /* PA extraction insns don't support zero length bitfields or fields
9208 extending beyond the left or right-most bits. Also, the predicate
9209 rejects lengths equal to a word as they are better handled by
9210 the move patterns. */
9211 if (len == 0 || pos + len > 32)
9212 FAIL;
9213
9214 /* From mips.md: extract_bit_field doesn't verify that our source
9215 matches the predicate, so check it again here. */
9216 if (!register_operand (operands[1], VOIDmode))
9217 FAIL;
9218
9219 emit_insn (gen_extzv_32 (operands[0], operands[1],
9220 operands[2], operands[3]));
9221 DONE;
9222 }")
9223
9224 (define_insn "extzv_32"
9225 [(set (match_operand:SI 0 "register_operand" "=r")
9226 (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
9227 (match_operand:SI 2 "uint5_operand" "")
9228 (match_operand:SI 3 "uint5_operand" "")))]
9229 "UINTVAL (operands[2]) > 0
9230 && UINTVAL (operands[2]) + UINTVAL (operands[3]) <= 32"
9231 "{extru|extrw,u} %1,%3+%2-1,%2,%0"
9232 [(set_attr "type" "shift")
9233 (set_attr "length" "4")])
9234
9235 (define_insn ""
9236 [(set (match_operand:SI 0 "register_operand" "=r")
9237 (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
9238 (const_int 1)
9239 (match_operand:SI 2 "register_operand" "q")))]
9240 ""
9241 "{vextru %1,1,%0|extrw,u %1,%%sar,1,%0}"
9242 [(set_attr "type" "shift")
9243 (set_attr "length" "4")])
9244
9245 (define_expand "extzvdi"
9246 [(set (match_operand:DI 0 "register_operand" "")
9247 (zero_extract:DI (match_operand:DI 1 "register_operand" "")
9248 (match_operand:DI 2 "uint6_operand" "")
9249 (match_operand:DI 3 "uint6_operand" "")))]
9250 "TARGET_64BIT"
9251 "
9252 {
9253 unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
9254 unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
9255
9256 /* PA extraction insns don't support zero length bitfields or fields
9257 extending beyond the left or right-most bits. Also, the predicate
9258 rejects lengths equal to a doubleword as they are better handled by
9259 the move patterns. */
9260 if (len == 0 || pos + len > 64)
9261 FAIL;
9262
9263 /* From mips.md: extract_bit_field doesn't verify that our source
9264 matches the predicate, so check it again here. */
9265 if (!register_operand (operands[1], VOIDmode))
9266 FAIL;
9267
9268 emit_insn (gen_extzv_64 (operands[0], operands[1],
9269 operands[2], operands[3]));
9270 DONE;
9271 }")
9272
9273 (define_insn "extzv_64"
9274 [(set (match_operand:DI 0 "register_operand" "=r")
9275 (zero_extract:DI (match_operand:DI 1 "register_operand" "r")
9276 (match_operand:DI 2 "uint6_operand" "")
9277 (match_operand:DI 3 "uint6_operand" "")))]
9278 "TARGET_64BIT
9279 && UINTVAL (operands[2]) > 0
9280 && UINTVAL (operands[2]) + UINTVAL (operands[3]) <= 64"
9281 "extrd,u %1,%3+%2-1,%2,%0"
9282 [(set_attr "type" "shift")
9283 (set_attr "length" "4")])
9284
9285 (define_insn ""
9286 [(set (match_operand:DI 0 "register_operand" "=r")
9287 (zero_extract:DI (match_operand:DI 1 "register_operand" "r")
9288 (const_int 1)
9289 (match_operand:DI 2 "register_operand" "q")))]
9290 "TARGET_64BIT"
9291 "extrd,u %1,%%sar,1,%0"
9292 [(set_attr "type" "shift")
9293 (set_attr "length" "4")])
9294
9295 ;;; Operands 2 and 3 are assumed to be CONST_INTs.
9296 (define_expand "extvsi"
9297 [(set (match_operand:SI 0 "register_operand" "")
9298 (sign_extract:SI (match_operand:SI 1 "register_operand" "")
9299 (match_operand:SI 2 "uint5_operand" "")
9300 (match_operand:SI 3 "uint5_operand" "")))]
9301 ""
9302 "
9303 {
9304 unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
9305 unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
9306
9307 /* PA extraction insns don't support zero length bitfields or fields
9308 extending beyond the left or right-most bits. Also, the predicate
9309 rejects lengths equal to a word as they are better handled by
9310 the move patterns. */
9311 if (len == 0 || pos + len > 32)
9312 FAIL;
9313
9314 /* From mips.md: extract_bit_field doesn't verify that our source
9315 matches the predicate, so check it again here. */
9316 if (!register_operand (operands[1], VOIDmode))
9317 FAIL;
9318
9319 emit_insn (gen_extv_32 (operands[0], operands[1],
9320 operands[2], operands[3]));
9321 DONE;
9322 }")
9323
9324 (define_insn "extv_32"
9325 [(set (match_operand:SI 0 "register_operand" "=r")
9326 (sign_extract:SI (match_operand:SI 1 "register_operand" "r")
9327 (match_operand:SI 2 "uint5_operand" "")
9328 (match_operand:SI 3 "uint5_operand" "")))]
9329 "UINTVAL (operands[2]) > 0
9330 && UINTVAL (operands[2]) + UINTVAL (operands[3]) <= 32"
9331 "{extrs|extrw,s} %1,%3+%2-1,%2,%0"
9332 [(set_attr "type" "shift")
9333 (set_attr "length" "4")])
9334
9335 (define_insn ""
9336 [(set (match_operand:SI 0 "register_operand" "=r")
9337 (sign_extract:SI (match_operand:SI 1 "register_operand" "r")
9338 (const_int 1)
9339 (match_operand:SI 2 "register_operand" "q")))]
9340 "!TARGET_64BIT"
9341 "{vextrs %1,1,%0|extrw,s %1,%%sar,1,%0}"
9342 [(set_attr "type" "shift")
9343 (set_attr "length" "4")])
9344
9345 (define_expand "extvdi"
9346 [(set (match_operand:DI 0 "register_operand" "")
9347 (sign_extract:DI (match_operand:DI 1 "register_operand" "")
9348 (match_operand:DI 2 "uint6_operand" "")
9349 (match_operand:DI 3 "uint6_operand" "")))]
9350 "TARGET_64BIT"
9351 "
9352 {
9353 unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
9354 unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
9355
9356 /* PA extraction insns don't support zero length bitfields or fields
9357 extending beyond the left or right-most bits. Also, the predicate
9358 rejects lengths equal to a doubleword as they are better handled by
9359 the move patterns. */
9360 if (len == 0 || pos + len > 64)
9361 FAIL;
9362
9363 /* From mips.md: extract_bit_field doesn't verify that our source
9364 matches the predicate, so check it again here. */
9365 if (!register_operand (operands[1], VOIDmode))
9366 FAIL;
9367
9368 emit_insn (gen_extv_64 (operands[0], operands[1],
9369 operands[2], operands[3]));
9370 DONE;
9371 }")
9372
9373 (define_insn "extv_64"
9374 [(set (match_operand:DI 0 "register_operand" "=r")
9375 (sign_extract:DI (match_operand:DI 1 "register_operand" "r")
9376 (match_operand:DI 2 "uint6_operand" "")
9377 (match_operand:DI 3 "uint6_operand" "")))]
9378 "TARGET_64BIT
9379 && UINTVAL (operands[2]) > 0
9380 && UINTVAL (operands[2]) + UINTVAL (operands[3]) <= 64"
9381 "extrd,s %1,%3+%2-1,%2,%0"
9382 [(set_attr "type" "shift")
9383 (set_attr "length" "4")])
9384
9385 (define_insn ""
9386 [(set (match_operand:DI 0 "register_operand" "=r")
9387 (sign_extract:DI (match_operand:DI 1 "register_operand" "r")
9388 (const_int 1)
9389 (match_operand:DI 2 "register_operand" "q")))]
9390 "TARGET_64BIT"
9391 "extrd,s %1,%%sar,1,%0"
9392 [(set_attr "type" "shift")
9393 (set_attr "length" "4")])
9394
9395 ;;; Operands 1 and 2 are assumed to be CONST_INTs.
9396 (define_expand "insvsi"
9397 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "")
9398 (match_operand:SI 1 "uint5_operand" "")
9399 (match_operand:SI 2 "uint5_operand" ""))
9400 (match_operand:SI 3 "arith5_operand" ""))]
9401 ""
9402 "
9403 {
9404 unsigned HOST_WIDE_INT len = UINTVAL (operands[1]);
9405 unsigned HOST_WIDE_INT pos = UINTVAL (operands[2]);
9406
9407 /* PA insertion insns don't support zero length bitfields or fields
9408 extending beyond the left or right-most bits. Also, the predicate
9409 rejects lengths equal to a word as they are better handled by
9410 the move patterns. */
9411 if (len <= 0 || pos + len > 32)
9412 FAIL;
9413
9414 /* From mips.md: insert_bit_field doesn't verify that our destination
9415 matches the predicate, so check it again here. */
9416 if (!register_operand (operands[0], VOIDmode))
9417 FAIL;
9418
9419 emit_insn (gen_insv_32 (operands[0], operands[1],
9420 operands[2], operands[3]));
9421 DONE;
9422 }")
9423
9424 (define_insn "insv_32"
9425 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r,r")
9426 (match_operand:SI 1 "uint5_operand" "")
9427 (match_operand:SI 2 "uint5_operand" ""))
9428 (match_operand:SI 3 "arith5_operand" "r,L"))]
9429 "UINTVAL (operands[1]) > 0
9430 && UINTVAL (operands[1]) + UINTVAL (operands[2]) <= 32"
9431 "@
9432 {dep|depw} %3,%2+%1-1,%1,%0
9433 {depi|depwi} %3,%2+%1-1,%1,%0"
9434 [(set_attr "type" "shift,shift")
9435 (set_attr "length" "4,4")])
9436
9437 ;; Optimize insertion of const_int values of type 1...1xxxx.
9438 (define_insn ""
9439 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
9440 (match_operand:SI 1 "uint5_operand" "")
9441 (match_operand:SI 2 "uint5_operand" ""))
9442 (match_operand:SI 3 "const_int_operand" ""))]
9443 "(INTVAL (operands[3]) & 0x10) != 0 &&
9444 (~INTVAL (operands[3]) & ((1L << INTVAL (operands[1])) - 1) & ~0xf) == 0"
9445 "*
9446 {
9447 operands[3] = GEN_INT ((INTVAL (operands[3]) & 0xf) - 0x10);
9448 return \"{depi|depwi} %3,%2+%1-1,%1,%0\";
9449 }"
9450 [(set_attr "type" "shift")
9451 (set_attr "length" "4")])
9452
9453 (define_expand "insvdi"
9454 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "")
9455 (match_operand:DI 1 "uint6_operand" "")
9456 (match_operand:DI 2 "uint6_operand" ""))
9457 (match_operand:DI 3 "arith5_operand" ""))]
9458 "TARGET_64BIT"
9459 "
9460 {
9461 unsigned HOST_WIDE_INT len = UINTVAL (operands[1]);
9462 unsigned HOST_WIDE_INT pos = UINTVAL (operands[2]);
9463
9464 /* PA insertion insns don't support zero length bitfields or fields
9465 extending beyond the left or right-most bits. Also, the predicate
9466 rejects lengths equal to a doubleword as they are better handled by
9467 the move patterns. */
9468 if (len <= 0 || pos + len > 64)
9469 FAIL;
9470
9471 /* From mips.md: insert_bit_field doesn't verify that our destination
9472 matches the predicate, so check it again here. */
9473 if (!register_operand (operands[0], VOIDmode))
9474 FAIL;
9475
9476 emit_insn (gen_insv_64 (operands[0], operands[1],
9477 operands[2], operands[3]));
9478 DONE;
9479 }")
9480
9481 (define_insn "insv_64"
9482 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+r,r")
9483 (match_operand:DI 1 "uint6_operand" "")
9484 (match_operand:DI 2 "uint6_operand" ""))
9485 (match_operand:DI 3 "arith5_operand" "r,L"))]
9486 "TARGET_64BIT
9487 && UINTVAL (operands[1]) > 0
9488 && UINTVAL (operands[1]) + UINTVAL (operands[2]) <= 64"
9489 "@
9490 depd %3,%2+%1-1,%1,%0
9491 depdi %3,%2+%1-1,%1,%0"
9492 [(set_attr "type" "shift,shift")
9493 (set_attr "length" "4,4")])
9494
9495 ;; Optimize insertion of const_int values of type 1...1xxxx.
9496 (define_insn ""
9497 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+r")
9498 (match_operand:DI 1 "uint6_operand" "")
9499 (match_operand:DI 2 "uint6_operand" ""))
9500 (match_operand:DI 3 "const_int_operand" ""))]
9501 "(INTVAL (operands[3]) & 0x10) != 0
9502 && TARGET_64BIT
9503 && (~INTVAL (operands[3]) & ((1L << INTVAL (operands[1])) - 1) & ~0xf) == 0"
9504 "*
9505 {
9506 operands[3] = GEN_INT ((INTVAL (operands[3]) & 0xf) - 0x10);
9507 return \"depdi %3,%2+%1-1,%1,%0\";
9508 }"
9509 [(set_attr "type" "shift")
9510 (set_attr "length" "4")])
9511
9512 (define_insn ""
9513 [(set (match_operand:DI 0 "register_operand" "=r")
9514 (ashift:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
9515 (const_int 32)))]
9516 "TARGET_64BIT"
9517 "depd,z %1,31,32,%0"
9518 [(set_attr "type" "shift")
9519 (set_attr "length" "4")])
9520
9521 ;; This insn is used for some loop tests, typically loops reversed when
9522 ;; strength reduction is used. It is actually created when the instruction
9523 ;; combination phase combines the special loop test. Since this insn
9524 ;; is both a jump insn and has an output, it must deal with its own
9525 ;; reloads, hence the `Q' constraints. The `!' constraints direct reload
9526 ;; to not choose the register alternatives in the event a reload is needed.
9527 (define_insn "decrement_and_branch_until_zero"
9528 [(set (pc)
9529 (if_then_else
9530 (match_operator 2 "ordered_comparison_operator"
9531 [(plus:SI
9532 (match_operand:SI 0 "reg_before_reload_operand" "+!r,!*f,*Q")
9533 (match_operand:SI 1 "int5_operand" "L,L,L"))
9534 (const_int 0)])
9535 (label_ref (match_operand 3 "" ""))
9536 (pc)))
9537 (set (match_dup 0)
9538 (plus:SI (match_dup 0) (match_dup 1)))
9539 (clobber (match_scratch:SI 4 "=X,r,&r"))]
9540 ""
9541 "* return pa_output_dbra (operands, insn, which_alternative); "
9542 ;; Do not expect to understand this the first time through.
9543 [(set_attr "type" "cbranch,multi,multi")
9544 (set (attr "length")
9545 (if_then_else (eq_attr "alternative" "0")
9546 ;; Loop counter in register case
9547 ;; Short branch has length of 4
9548 ;; Long branch has length of 8, 20, 24 or 28
9549 (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9550 (const_int MAX_12BIT_OFFSET))
9551 (const_int 4)
9552 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9553 (const_int MAX_17BIT_OFFSET))
9554 (const_int 8)
9555 (match_test "TARGET_PORTABLE_RUNTIME")
9556 (const_int 24)
9557 (not (match_test "flag_pic"))
9558 (const_int 20)]
9559 (const_int 28))
9560
9561 ;; Loop counter in FP reg case.
9562 ;; Extra goo to deal with additional reload insns.
9563 (if_then_else (eq_attr "alternative" "1")
9564 (if_then_else (lt (match_dup 3) (pc))
9565 (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 24))))
9566 (const_int MAX_12BIT_OFFSET))
9567 (const_int 24)
9568 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 24))))
9569 (const_int MAX_17BIT_OFFSET))
9570 (const_int 28)
9571 (match_test "TARGET_PORTABLE_RUNTIME")
9572 (const_int 44)
9573 (not (match_test "flag_pic"))
9574 (const_int 40)]
9575 (const_int 48))
9576 (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9577 (const_int MAX_12BIT_OFFSET))
9578 (const_int 24)
9579 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9580 (const_int MAX_17BIT_OFFSET))
9581 (const_int 28)
9582 (match_test "TARGET_PORTABLE_RUNTIME")
9583 (const_int 44)
9584 (not (match_test "flag_pic"))
9585 (const_int 40)]
9586 (const_int 48)))
9587
9588 ;; Loop counter in memory case.
9589 ;; Extra goo to deal with additional reload insns.
9590 (if_then_else (lt (match_dup 3) (pc))
9591 (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9592 (const_int MAX_12BIT_OFFSET))
9593 (const_int 12)
9594 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9595 (const_int MAX_17BIT_OFFSET))
9596 (const_int 16)
9597 (match_test "TARGET_PORTABLE_RUNTIME")
9598 (const_int 32)
9599 (not (match_test "flag_pic"))
9600 (const_int 28)]
9601 (const_int 36))
9602 (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9603 (const_int MAX_12BIT_OFFSET))
9604 (const_int 12)
9605 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9606 (const_int MAX_17BIT_OFFSET))
9607 (const_int 16)
9608 (match_test "TARGET_PORTABLE_RUNTIME")
9609 (const_int 32)
9610 (not (match_test "flag_pic"))
9611 (const_int 28)]
9612 (const_int 36))))))])
9613
9614 (define_insn ""
9615 [(set (pc)
9616 (if_then_else
9617 (match_operator 2 "movb_comparison_operator"
9618 [(match_operand:SI 1 "register_operand" "r,r,r,r") (const_int 0)])
9619 (label_ref (match_operand 3 "" ""))
9620 (pc)))
9621 (set (match_operand:SI 0 "reg_before_reload_operand" "=!r,!*f,*Q,!*q")
9622 (match_dup 1))]
9623 ""
9624 "* return pa_output_movb (operands, insn, which_alternative, 0); "
9625 ;; Do not expect to understand this the first time through.
9626 [(set_attr "type" "cbranch,multi,multi,multi")
9627 (set (attr "length")
9628 (if_then_else (eq_attr "alternative" "0")
9629 ;; Loop counter in register case
9630 ;; Short branch has length of 4
9631 ;; Long branch has length of 8, 20, 24 or 28
9632 (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9633 (const_int MAX_12BIT_OFFSET))
9634 (const_int 4)
9635 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9636 (const_int MAX_17BIT_OFFSET))
9637 (const_int 8)
9638 (match_test "TARGET_PORTABLE_RUNTIME")
9639 (const_int 24)
9640 (not (match_test "flag_pic"))
9641 (const_int 20)]
9642 (const_int 28))
9643
9644 ;; Loop counter in FP reg case.
9645 ;; Extra goo to deal with additional reload insns.
9646 (if_then_else (eq_attr "alternative" "1")
9647 (if_then_else (lt (match_dup 3) (pc))
9648 (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9649 (const_int MAX_12BIT_OFFSET))
9650 (const_int 12)
9651 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9652 (const_int MAX_17BIT_OFFSET))
9653 (const_int 16)
9654 (match_test "TARGET_PORTABLE_RUNTIME")
9655 (const_int 32)
9656 (not (match_test "flag_pic"))
9657 (const_int 28)]
9658 (const_int 36))
9659 (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9660 (const_int MAX_12BIT_OFFSET))
9661 (const_int 12)
9662 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9663 (const_int MAX_17BIT_OFFSET))
9664 (const_int 16)
9665 (match_test "TARGET_PORTABLE_RUNTIME")
9666 (const_int 32)
9667 (not (match_test "flag_pic"))
9668 (const_int 28)]
9669 (const_int 36)))
9670
9671 ;; Loop counter in memory or sar case.
9672 ;; Extra goo to deal with additional reload insns.
9673 (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9674 (const_int MAX_12BIT_OFFSET))
9675 (const_int 8)
9676 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9677 (const_int MAX_17BIT_OFFSET))
9678 (const_int 12)
9679 (match_test "TARGET_PORTABLE_RUNTIME")
9680 (const_int 28)
9681 (not (match_test "flag_pic"))
9682 (const_int 24)]
9683 (const_int 32)))))])
9684
9685 ;; Handle negated branch.
9686 (define_insn ""
9687 [(set (pc)
9688 (if_then_else
9689 (match_operator 2 "movb_comparison_operator"
9690 [(match_operand:SI 1 "register_operand" "r,r,r,r") (const_int 0)])
9691 (pc)
9692 (label_ref (match_operand 3 "" ""))))
9693 (set (match_operand:SI 0 "reg_before_reload_operand" "=!r,!*f,*Q,!*q")
9694 (match_dup 1))]
9695 ""
9696 "* return pa_output_movb (operands, insn, which_alternative, 1); "
9697 ;; Do not expect to understand this the first time through.
9698 [(set_attr "type" "cbranch,multi,multi,multi")
9699 (set (attr "length")
9700 (if_then_else (eq_attr "alternative" "0")
9701 ;; Loop counter in register case
9702 ;; Short branch has length of 4
9703 ;; Long branch has length of 8
9704 (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9705 (const_int MAX_12BIT_OFFSET))
9706 (const_int 4)
9707 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9708 (const_int MAX_17BIT_OFFSET))
9709 (const_int 8)
9710 (match_test "TARGET_PORTABLE_RUNTIME")
9711 (const_int 24)
9712 (not (match_test "flag_pic"))
9713 (const_int 20)]
9714 (const_int 28))
9715
9716 ;; Loop counter in FP reg case.
9717 ;; Extra goo to deal with additional reload insns.
9718 (if_then_else (eq_attr "alternative" "1")
9719 (if_then_else (lt (match_dup 3) (pc))
9720 (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9721 (const_int MAX_12BIT_OFFSET))
9722 (const_int 12)
9723 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
9724 (const_int MAX_17BIT_OFFSET))
9725 (const_int 16)
9726 (match_test "TARGET_PORTABLE_RUNTIME")
9727 (const_int 32)
9728 (not (match_test "flag_pic"))
9729 (const_int 28)]
9730 (const_int 36))
9731 (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9732 (const_int MAX_12BIT_OFFSET))
9733 (const_int 12)
9734 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9735 (const_int MAX_17BIT_OFFSET))
9736 (const_int 16)
9737 (match_test "TARGET_PORTABLE_RUNTIME")
9738 (const_int 32)
9739 (not (match_test "flag_pic"))
9740 (const_int 28)]
9741 (const_int 36)))
9742
9743 ;; Loop counter in memory or SAR case.
9744 ;; Extra goo to deal with additional reload insns.
9745 (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9746 (const_int MAX_12BIT_OFFSET))
9747 (const_int 8)
9748 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9749 (const_int MAX_17BIT_OFFSET))
9750 (const_int 12)
9751 (match_test "TARGET_PORTABLE_RUNTIME")
9752 (const_int 28)
9753 (not (match_test "flag_pic"))
9754 (const_int 24)]
9755 (const_int 32)))))])
9756
9757 (define_insn ""
9758 [(set (pc) (label_ref (match_operand 3 "" "" )))
9759 (set (match_operand:SI 0 "ireg_operand" "=r")
9760 (plus:SI (match_operand:SI 1 "ireg_operand" "r")
9761 (match_operand:SI 2 "ireg_or_int5_operand" "rL")))]
9762 "(reload_completed && operands[0] == operands[1]) || operands[0] == operands[2]"
9763 "*
9764 {
9765 return pa_output_parallel_addb (operands, insn);
9766 }"
9767 [(set_attr "type" "parallel_branch")
9768 (set (attr "length")
9769 (cond [(lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9770 (const_int MAX_12BIT_OFFSET))
9771 (const_int 4)
9772 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
9773 (const_int MAX_17BIT_OFFSET))
9774 (const_int 8)
9775 (match_test "TARGET_PORTABLE_RUNTIME")
9776 (const_int 24)
9777 (not (match_test "flag_pic"))
9778 (const_int 20)]
9779 (const_int 28)))])
9780
9781 (define_insn ""
9782 [(set (pc) (label_ref (match_operand 2 "" "" )))
9783 (set (match_operand:SF 0 "ireg_operand" "=r")
9784 (match_operand:SF 1 "ireg_or_int5_operand" "rL"))]
9785 "reload_completed"
9786 "*
9787 {
9788 return pa_output_parallel_movb (operands, insn);
9789 }"
9790 [(set_attr "type" "parallel_branch")
9791 (set (attr "length")
9792 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9793 (const_int MAX_12BIT_OFFSET))
9794 (const_int 4)
9795 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9796 (const_int MAX_17BIT_OFFSET))
9797 (const_int 8)
9798 (match_test "TARGET_PORTABLE_RUNTIME")
9799 (const_int 24)
9800 (not (match_test "flag_pic"))
9801 (const_int 20)]
9802 (const_int 28)))])
9803
9804 (define_insn ""
9805 [(set (pc) (label_ref (match_operand 2 "" "" )))
9806 (set (match_operand:SI 0 "ireg_operand" "=r")
9807 (match_operand:SI 1 "ireg_or_int5_operand" "rL"))]
9808 "reload_completed"
9809 "*
9810 {
9811 return pa_output_parallel_movb (operands, insn);
9812 }"
9813 [(set_attr "type" "parallel_branch")
9814 (set (attr "length")
9815 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9816 (const_int MAX_12BIT_OFFSET))
9817 (const_int 4)
9818 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9819 (const_int MAX_17BIT_OFFSET))
9820 (const_int 8)
9821 (match_test "TARGET_PORTABLE_RUNTIME")
9822 (const_int 24)
9823 (not (match_test "flag_pic"))
9824 (const_int 20)]
9825 (const_int 28)))])
9826
9827 (define_insn ""
9828 [(set (pc) (label_ref (match_operand 2 "" "" )))
9829 (set (match_operand:HI 0 "ireg_operand" "=r")
9830 (match_operand:HI 1 "ireg_or_int5_operand" "rL"))]
9831 "reload_completed"
9832 "*
9833 {
9834 return pa_output_parallel_movb (operands, insn);
9835 }"
9836 [(set_attr "type" "parallel_branch")
9837 (set (attr "length")
9838 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9839 (const_int MAX_12BIT_OFFSET))
9840 (const_int 4)
9841 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9842 (const_int MAX_17BIT_OFFSET))
9843 (const_int 8)
9844 (match_test "TARGET_PORTABLE_RUNTIME")
9845 (const_int 24)
9846 (not (match_test "flag_pic"))
9847 (const_int 20)]
9848 (const_int 28)))])
9849
9850 (define_insn ""
9851 [(set (pc) (label_ref (match_operand 2 "" "" )))
9852 (set (match_operand:QI 0 "ireg_operand" "=r")
9853 (match_operand:QI 1 "ireg_or_int5_operand" "rL"))]
9854 "reload_completed"
9855 "*
9856 {
9857 return pa_output_parallel_movb (operands, insn);
9858 }"
9859 [(set_attr "type" "parallel_branch")
9860 (set (attr "length")
9861 (cond [(lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9862 (const_int MAX_12BIT_OFFSET))
9863 (const_int 4)
9864 (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
9865 (const_int MAX_17BIT_OFFSET))
9866 (const_int 8)
9867 (match_test "TARGET_PORTABLE_RUNTIME")
9868 (const_int 24)
9869 (not (match_test "flag_pic"))
9870 (const_int 20)]
9871 (const_int 28)))])
9872
9873 (define_insn ""
9874 [(set (match_operand 0 "register_operand" "=f")
9875 (mult (match_operand 1 "register_operand" "f")
9876 (match_operand 2 "register_operand" "f")))
9877 (set (match_operand 3 "register_operand" "+f")
9878 (plus (match_operand 4 "register_operand" "f")
9879 (match_operand 5 "register_operand" "f")))]
9880 "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9881 && reload_completed && pa_fmpyaddoperands (operands)"
9882 "*
9883 {
9884 if (GET_MODE (operands[0]) == DFmode)
9885 {
9886 if (rtx_equal_p (operands[3], operands[5]))
9887 return \"fmpyadd,dbl %1,%2,%0,%4,%3\";
9888 else
9889 return \"fmpyadd,dbl %1,%2,%0,%5,%3\";
9890 }
9891 else
9892 {
9893 if (rtx_equal_p (operands[3], operands[5]))
9894 return \"fmpyadd,sgl %1,%2,%0,%4,%3\";
9895 else
9896 return \"fmpyadd,sgl %1,%2,%0,%5,%3\";
9897 }
9898 }"
9899 [(set_attr "type" "fpalu")
9900 (set_attr "length" "4")])
9901
9902 (define_insn ""
9903 [(set (match_operand 3 "register_operand" "+f")
9904 (plus (match_operand 4 "register_operand" "f")
9905 (match_operand 5 "register_operand" "f")))
9906 (set (match_operand 0 "register_operand" "=f")
9907 (mult (match_operand 1 "register_operand" "f")
9908 (match_operand 2 "register_operand" "f")))]
9909 "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9910 && reload_completed && pa_fmpyaddoperands (operands)"
9911 "*
9912 {
9913 if (GET_MODE (operands[0]) == DFmode)
9914 {
9915 if (rtx_equal_p (operands[3], operands[5]))
9916 return \"fmpyadd,dbl %1,%2,%0,%4,%3\";
9917 else
9918 return \"fmpyadd,dbl %1,%2,%0,%5,%3\";
9919 }
9920 else
9921 {
9922 if (rtx_equal_p (operands[3], operands[5]))
9923 return \"fmpyadd,sgl %1,%2,%0,%4,%3\";
9924 else
9925 return \"fmpyadd,sgl %1,%2,%0,%5,%3\";
9926 }
9927 }"
9928 [(set_attr "type" "fpalu")
9929 (set_attr "length" "4")])
9930
9931 (define_insn ""
9932 [(set (match_operand 0 "register_operand" "=f")
9933 (mult (match_operand 1 "register_operand" "f")
9934 (match_operand 2 "register_operand" "f")))
9935 (set (match_operand 3 "register_operand" "+f")
9936 (minus (match_operand 4 "register_operand" "f")
9937 (match_operand 5 "register_operand" "f")))]
9938 "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9939 && reload_completed && pa_fmpysuboperands (operands)"
9940 "*
9941 {
9942 if (GET_MODE (operands[0]) == DFmode)
9943 return \"fmpysub,dbl %1,%2,%0,%5,%3\";
9944 else
9945 return \"fmpysub,sgl %1,%2,%0,%5,%3\";
9946 }"
9947 [(set_attr "type" "fpalu")
9948 (set_attr "length" "4")])
9949
9950 (define_insn ""
9951 [(set (match_operand 3 "register_operand" "+f")
9952 (minus (match_operand 4 "register_operand" "f")
9953 (match_operand 5 "register_operand" "f")))
9954 (set (match_operand 0 "register_operand" "=f")
9955 (mult (match_operand 1 "register_operand" "f")
9956 (match_operand 2 "register_operand" "f")))]
9957 "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
9958 && reload_completed && pa_fmpysuboperands (operands)"
9959 "*
9960 {
9961 if (GET_MODE (operands[0]) == DFmode)
9962 return \"fmpysub,dbl %1,%2,%0,%5,%3\";
9963 else
9964 return \"fmpysub,sgl %1,%2,%0,%5,%3\";
9965 }"
9966 [(set_attr "type" "fpalu")
9967 (set_attr "length" "4")])
9968
9969 ;; The following four patterns are used by the trampoline code for nested
9970 ;; functions. They flush the I and D cache lines from the start address
9971 ;; (operand0) to the end address (operand1).
9972 ;;
9973 ;; Because the range of memory flushed is variable and the size of a MEM
9974 ;; can only be a CONST_INT, the patterns specify that they perform an
9975 ;; unspecified volatile operation on all memory.
9976 ;;
9977 ;; The address range for an icache flush must lie within a single
9978 ;; space on targets with non-equivalent space registers.
9979 ;;
9980 ;; Operand 0 contains the line aligned start address.
9981 ;; Operand 1 contains the end address.
9982 ;; Operand 2 contains the line size to use.
9983 (define_insn "dcacheflush<P:mode>"
9984 [(const_int 1)
9985 (unspec_volatile [(mem:BLK (scratch))] UNSPECV_DCACHE)
9986 (use (match_operand 0 "pmode_register_operand" "r"))
9987 (use (match_operand 1 "pmode_register_operand" "r"))
9988 (use (match_operand 2 "pmode_register_operand" "r"))
9989 (clobber (match_scratch:P 3 "=&0"))]
9990 ""
9991 "{comb|cmpb},<dwc><<,n %3,%1,.\;fdc,m %2(%3)\;sync"
9992 [(set_attr "type" "multi")
9993 (set_attr "length" "12")])
9994
9995 (define_insn "icacheflush1<P:mode>"
9996 [(const_int 2)
9997 (unspec_volatile [(mem:BLK (scratch))] UNSPECV_ICACHE)
9998 (use (match_operand 0 "pmode_register_operand" "r"))
9999 (use (match_operand 1 "pmode_register_operand" "r"))
10000 (use (match_operand 2 "pmode_register_operand" "r"))
10001 (clobber (match_operand 3 "pmode_register_operand" "=&r"))
10002 (clobber (match_operand 4 "pmode_register_operand" "=&r"))
10003 (clobber (match_scratch:P 5 "=&0"))]
10004 ""
10005 "mfsp %%sr1,%4\;ldsid (%5),%3\;mtsp %3,%%sr1\;{comb|cmpb},<dwc><<,n %5,%1,.\;fic,m %2(%%sr1,%5)\;sync\;mtsp %4,%%sr1\;nop\;nop\;nop\;nop\;nop\;nop"
10006 [(set_attr "type" "multi")
10007 (set_attr "length" "52")])
10008
10009 (define_insn "icacheflush2<P:mode>"
10010 [(const_int 2)
10011 (unspec_volatile [(mem:BLK (scratch))] UNSPECV_ICACHE)
10012 (use (match_operand 0 "pmode_register_operand" "r"))
10013 (use (match_operand 1 "pmode_register_operand" "r"))
10014 (use (match_operand 2 "pmode_register_operand" "r"))
10015 (clobber (match_scratch:P 3 "=&0"))]
10016 "TARGET_PA_20"
10017 "cmpb,<dwc><<,n %3,%1,.\;fic,m %2(%3)\;sync\;nop\;nop\;nop\;nop\;nop\;nop\;nop"
10018 [(set_attr "type" "multi")
10019 (set_attr "length" "40")])
10020
10021 (define_insn "icacheflush3<P:mode>"
10022 [(const_int 3)
10023 (unspec_volatile [(mem:BLK (scratch))] UNSPECV_ICACHE)
10024 (use (match_operand 0 "pmode_register_operand" "r"))
10025 (use (match_operand 1 "pmode_register_operand" "r"))
10026 (use (match_operand 2 "pmode_register_operand" "r"))
10027 (clobber (match_scratch:P 3 "=&0"))]
10028 "!TARGET_PA_20 && TARGET_NO_SPACE_REGS"
10029 "comb,<dwc><<,n %3,%1,.\;fic,m %2(%%sr4,%3)\;sync\;nop\;nop\;nop\;nop\;nop\;nop\;nop"
10030 [(set_attr "type" "multi")
10031 (set_attr "length" "40")])
10032
10033 ;; clear_cache
10034 ;;
10035 ;; Note the data and instruction cache flushes need to be separated
10036 ;; by a sync instruction (see page 7-151 in PA 2.0 architecture manual).
10037 ;; Thus, we can't combine the flush operations in a single loop.
10038
10039 ;; Operand 0 contains the start address (inclusive).
10040 ;; Operand 1 contains the end address (exclusive).
10041 (define_expand "clear_cache"
10042 [(match_operand 0 "pmode_register_operand")
10043 (match_operand 1 "pmode_register_operand")]
10044 ""
10045 {
10046 rtx start = gen_reg_rtx (Pmode);
10047 rtx line_size = gen_reg_rtx (Pmode);
10048 rtx lab = gen_label_rtx ();
10049 rtx op0 = operands[0];
10050 rtx op1 = operands[1];
10051
10052 /* Skip flush if op0 is greater than or equal to op1. */
10053 emit_cmp_and_jump_insns (op0, op1, GEU, NULL_RTX, Pmode, 0, lab);
10054
10055 /* Load cache line size. */
10056 emit_move_insn (line_size, GEN_INT (MIN_CACHELINE_SIZE));
10057
10058 if (TARGET_64BIT)
10059 {
10060 /* Align the start address. */
10061 emit_insn (gen_anddi3 (start, op0, GEN_INT (-MIN_CACHELINE_SIZE)));
10062
10063 /* Flush the cache. */
10064 emit_insn (gen_dcacheflushdi (start, op1, line_size));
10065 emit_insn (gen_icacheflush2di (start, op1, line_size));
10066 }
10067 else
10068 {
10069 /* Align the start address. */
10070 emit_insn (gen_andsi3 (start, op0, GEN_INT (-MIN_CACHELINE_SIZE)));
10071
10072 /* Flush the cache. */
10073 emit_insn (gen_dcacheflushsi (start, op1, line_size));
10074 if (TARGET_PA_20)
10075 emit_insn (gen_icacheflush2si (start, op1, line_size));
10076 else if (TARGET_NO_SPACE_REGS)
10077 emit_insn (gen_icacheflush3si (start, op1, line_size));
10078 else
10079 emit_insn (gen_icacheflush1si (start, op1, line_size,
10080 gen_reg_rtx (Pmode),
10081 gen_reg_rtx (Pmode)));
10082 }
10083
10084 emit_label (lab);
10085 DONE;
10086 })
10087
10088 ;; An out-of-line prologue.
10089 (define_insn "outline_prologue_call"
10090 [(unspec_volatile [(const_int 0)] UNSPECV_OPC)
10091 (clobber (reg:SI 31))
10092 (clobber (reg:SI 22))
10093 (clobber (reg:SI 21))
10094 (clobber (reg:SI 20))
10095 (clobber (reg:SI 19))
10096 (clobber (reg:SI 1))]
10097 ""
10098 "*
10099 {
10100
10101 /* We need two different versions depending on whether or not we
10102 need a frame pointer. Also note that we return to the instruction
10103 immediately after the branch rather than two instructions after the
10104 break as normally is the case. */
10105 if (frame_pointer_needed)
10106 {
10107 /* Must import the magic millicode routine(s). */
10108 output_asm_insn (\".IMPORT __outline_prologue_fp,MILLICODE\", NULL);
10109
10110 if (TARGET_PORTABLE_RUNTIME)
10111 {
10112 output_asm_insn (\"ldil L'__outline_prologue_fp,%%r31\", NULL);
10113 output_asm_insn (\"ble,n R'__outline_prologue_fp(%%sr0,%%r31)\",
10114 NULL);
10115 }
10116 else
10117 output_asm_insn (\"{bl|b,l},n __outline_prologue_fp,%%r31\", NULL);
10118 }
10119 else
10120 {
10121 /* Must import the magic millicode routine(s). */
10122 output_asm_insn (\".IMPORT __outline_prologue,MILLICODE\", NULL);
10123
10124 if (TARGET_PORTABLE_RUNTIME)
10125 {
10126 output_asm_insn (\"ldil L'__outline_prologue,%%r31\", NULL);
10127 output_asm_insn (\"ble,n R'__outline_prologue(%%sr0,%%r31)\", NULL);
10128 }
10129 else
10130 output_asm_insn (\"{bl|b,l},n __outline_prologue,%%r31\", NULL);
10131 }
10132 return \"\";
10133 }"
10134 [(set_attr "type" "multi")
10135 (set_attr "length" "8")])
10136
10137 ;; An out-of-line epilogue.
10138 (define_insn "outline_epilogue_call"
10139 [(unspec_volatile [(const_int 1)] UNSPECV_OEC)
10140 (use (reg:SI 29))
10141 (use (reg:SI 28))
10142 (clobber (reg:SI 31))
10143 (clobber (reg:SI 22))
10144 (clobber (reg:SI 21))
10145 (clobber (reg:SI 20))
10146 (clobber (reg:SI 19))
10147 (clobber (reg:SI 2))
10148 (clobber (reg:SI 1))]
10149 ""
10150 "*
10151 {
10152
10153 /* We need two different versions depending on whether or not we
10154 need a frame pointer. Also note that we return to the instruction
10155 immediately after the branch rather than two instructions after the
10156 break as normally is the case. */
10157 if (frame_pointer_needed)
10158 {
10159 /* Must import the magic millicode routine. */
10160 output_asm_insn (\".IMPORT __outline_epilogue_fp,MILLICODE\", NULL);
10161
10162 /* The out-of-line prologue will make sure we return to the right
10163 instruction. */
10164 if (TARGET_PORTABLE_RUNTIME)
10165 {
10166 output_asm_insn (\"ldil L'__outline_epilogue_fp,%%r31\", NULL);
10167 output_asm_insn (\"ble,n R'__outline_epilogue_fp(%%sr0,%%r31)\",
10168 NULL);
10169 }
10170 else
10171 output_asm_insn (\"{bl|b,l},n __outline_epilogue_fp,%%r31\", NULL);
10172 }
10173 else
10174 {
10175 /* Must import the magic millicode routine. */
10176 output_asm_insn (\".IMPORT __outline_epilogue,MILLICODE\", NULL);
10177
10178 /* The out-of-line prologue will make sure we return to the right
10179 instruction. */
10180 if (TARGET_PORTABLE_RUNTIME)
10181 {
10182 output_asm_insn (\"ldil L'__outline_epilogue,%%r31\", NULL);
10183 output_asm_insn (\"ble,n R'__outline_epilogue(%%sr0,%%r31)\", NULL);
10184 }
10185 else
10186 output_asm_insn (\"{bl|b,l},n __outline_epilogue,%%r31\", NULL);
10187 }
10188 return \"\";
10189 }"
10190 [(set_attr "type" "multi")
10191 (set_attr "length" "8")])
10192
10193 ;; Given a function pointer, canonicalize it so it can be
10194 ;; reliably compared to another function pointer. */
10195 (define_expand "canonicalize_funcptr_for_compare"
10196 [(set (reg:SI 26) (match_operand:SI 1 "register_operand" ""))
10197 (parallel [(set (reg:SI 29) (unspec:SI [(reg:SI 26)] UNSPEC_CFFC))
10198 (clobber (match_dup 2))
10199 (clobber (reg:SI 26))
10200 (clobber (reg:SI 22))
10201 (clobber (reg:SI 31))])
10202 (set (match_operand:SI 0 "register_operand" "")
10203 (reg:SI 29))]
10204 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
10205 "
10206 {
10207 if (TARGET_ELF32)
10208 {
10209 rtx canonicalize_funcptr_for_compare_libfunc
10210 = init_one_libfunc (CANONICALIZE_FUNCPTR_FOR_COMPARE_LIBCALL);
10211
10212 emit_library_call_value (canonicalize_funcptr_for_compare_libfunc,
10213 operands[0], LCT_NORMAL, Pmode,
10214 operands[1], Pmode);
10215 DONE;
10216 }
10217
10218 operands[2] = gen_reg_rtx (SImode);
10219 if (GET_CODE (operands[1]) != REG)
10220 {
10221 rtx tmp = gen_reg_rtx (Pmode);
10222 emit_move_insn (tmp, operands[1]);
10223 operands[1] = tmp;
10224 }
10225 }")
10226
10227 (define_insn "*$$sh_func_adrs"
10228 [(set (reg:SI 29) (unspec:SI [(reg:SI 26)] UNSPEC_CFFC))
10229 (clobber (match_operand:SI 0 "register_operand" "=a"))
10230 (clobber (reg:SI 26))
10231 (clobber (reg:SI 22))
10232 (clobber (reg:SI 31))]
10233 "!TARGET_64BIT"
10234 "*
10235 {
10236 int length = get_attr_length (insn);
10237 rtx xoperands[2];
10238
10239 xoperands[0] = GEN_INT (length - 8);
10240 xoperands[1] = GEN_INT (length - 16);
10241
10242 /* Must import the magic millicode routine. */
10243 output_asm_insn (\".IMPORT $$sh_func_adrs,MILLICODE\", NULL);
10244
10245 /* This is absolutely amazing.
10246
10247 First, copy our input parameter into %r29 just in case we don't
10248 need to call $$sh_func_adrs. */
10249 output_asm_insn (\"copy %%r26,%%r29\", NULL);
10250 output_asm_insn (\"{extru|extrw,u} %%r26,31,2,%%r31\", NULL);
10251
10252 /* Next, examine the low two bits in %r26, if they aren't 0x2, then
10253 we use %r26 unchanged. */
10254 output_asm_insn (\"{comib|cmpib},<>,n 2,%%r31,.+%0\", xoperands);
10255 output_asm_insn (\"ldi 4096,%%r31\", NULL);
10256
10257 /* Next, compare %r26 with 4096, if %r26 is less than or equal to
10258 4096, then again we use %r26 unchanged. */
10259 output_asm_insn (\"{comb|cmpb},<<,n %%r26,%%r31,.+%1\", xoperands);
10260
10261 /* Finally, call $$sh_func_adrs to extract the function's real add24. */
10262 return pa_output_millicode_call (insn,
10263 gen_rtx_SYMBOL_REF (SImode,
10264 \"$$sh_func_adrs\"));
10265 }"
10266 [(set_attr "type" "sh_func_adrs")
10267 (set (attr "length")
10268 (cond [(and (const_int 0) (eq (const_int 0) (pc))) (const_int 28)]
10269 (plus (symbol_ref "pa_attr_length_millicode_call (insn)")
10270 (const_int 20))))])
10271
10272 ;; On the PA, the PIC register is call clobbered, so it must
10273 ;; be saved & restored around calls by the caller. If the call
10274 ;; doesn't return normally (nonlocal goto, or an exception is
10275 ;; thrown), then the code at the exception handler label must
10276 ;; restore the PIC register.
10277 (define_expand "exception_receiver"
10278 [(const_int 4)]
10279 "flag_pic"
10280 "
10281 {
10282 /* On the 64-bit port, we need a blockage because there is
10283 confusion regarding the dependence of the restore on the
10284 frame pointer. As a result, the frame pointer and pic
10285 register restores sometimes are interchanged erroneously. */
10286 if (TARGET_64BIT)
10287 emit_insn (gen_blockage ());
10288 /* Restore the PIC register using hppa_pic_save_rtx (). The
10289 PIC register is not saved in the frame in 64-bit ABI. */
10290 emit_move_insn (pic_offset_table_rtx, hppa_pic_save_rtx ());
10291 emit_insn (gen_blockage ());
10292 DONE;
10293 }")
10294
10295 (define_expand "builtin_setjmp_receiver"
10296 [(label_ref (match_operand 0 "" ""))]
10297 "flag_pic"
10298 "
10299 {
10300 if (TARGET_64BIT)
10301 emit_insn (gen_blockage ());
10302 /* Restore the PIC register. Hopefully, this will always be from
10303 a stack slot. The only registers that are valid after a
10304 builtin_longjmp are the stack and frame pointers. */
10305 emit_move_insn (pic_offset_table_rtx, hppa_pic_save_rtx ());
10306 emit_insn (gen_blockage ());
10307 DONE;
10308 }")
10309
10310 ;; Allocate new stack space and update the saved stack pointer in the
10311 ;; frame marker. The HP C compilers also copy additional words in the
10312 ;; frame marker. The 64-bit compiler copies words at -48, -32 and -24.
10313 ;; The 32-bit compiler copies the word at -16 (Static Link). We
10314 ;; currently don't copy these values.
10315 ;;
10316 ;; Since the copy of the frame marker can't be done atomically, I
10317 ;; suspect that using it for unwind purposes may be somewhat unreliable.
10318 ;; The HP compilers appear to raise the stack and copy the frame
10319 ;; marker in a strict instruction sequence. This suggests that the
10320 ;; unwind library may check for an alloca sequence when ALLOCA_FRAME
10321 ;; is set in the callinfo data. We currently don't set ALLOCA_FRAME
10322 ;; as GAS doesn't support it, or try to keep the instructions emitted
10323 ;; here in strict sequence.
10324 (define_expand "allocate_stack"
10325 [(match_operand 0 "" "")
10326 (match_operand 1 "" "")]
10327 ""
10328 "
10329 {
10330 rtx addr;
10331
10332 /* Since the stack grows upward, we need to store virtual_stack_dynamic_rtx
10333 in operand 0 before adjusting the stack. */
10334 emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
10335 anti_adjust_stack (operands[1]);
10336 if (TARGET_HPUX_UNWIND_LIBRARY)
10337 {
10338 addr = gen_rtx_PLUS (word_mode, stack_pointer_rtx,
10339 GEN_INT (TARGET_64BIT ? -8 : -4));
10340 emit_move_insn (gen_rtx_MEM (word_mode, addr), hard_frame_pointer_rtx);
10341 }
10342 if (!TARGET_64BIT && flag_pic)
10343 {
10344 rtx addr = gen_rtx_PLUS (word_mode, stack_pointer_rtx, GEN_INT (-32));
10345 emit_move_insn (gen_rtx_MEM (word_mode, addr), pic_offset_table_rtx);
10346 }
10347 DONE;
10348 }")
10349
10350 (define_expand "prefetch"
10351 [(match_operand 0 "address_operand" "")
10352 (match_operand 1 "const_int_operand" "")
10353 (match_operand 2 "const_int_operand" "")]
10354 "TARGET_PA_20"
10355 {
10356 operands[0] = copy_addr_to_reg (operands[0]);
10357 emit_insn (gen_prefetch_20 (operands[0], operands[1], operands[2]));
10358 DONE;
10359 })
10360
10361 (define_insn "prefetch_20"
10362 [(prefetch (match_operand 0 "pmode_register_operand" "r")
10363 (match_operand:SI 1 "const_int_operand" "n")
10364 (match_operand:SI 2 "const_int_operand" "n"))]
10365 "TARGET_PA_20"
10366 {
10367 /* The SL cache-control completer indicates good spatial locality but
10368 poor temporal locality. The ldw instruction with a target of general
10369 register 0 prefetches a cache line for a read. The ldd instruction
10370 prefetches a cache line for a write. */
10371 static const char * const instr[2][2] = {
10372 {
10373 "ldw,sl 0(%0),%%r0",
10374 "ldd,sl 0(%0),%%r0"
10375 },
10376 {
10377 "ldw 0(%0),%%r0",
10378 "ldd 0(%0),%%r0"
10379 }
10380 };
10381 int read_or_write = INTVAL (operands[1]) & 1;
10382 int locality = INTVAL (operands[2]) == 0 ? 0 : 1;
10383
10384 return instr [locality][read_or_write];
10385 }
10386 [(set_attr "type" "load")
10387 (set_attr "length" "4")])
10388
10389 ;; TLS Support
10390 (define_insn "tgd_load"
10391 [(set (match_operand:SI 0 "register_operand" "=r")
10392 (unspec:SI [(match_operand 1 "tgd_symbolic_operand" "")] UNSPEC_TLSGD))
10393 (clobber (reg:SI R1_REGNUM))
10394 (use (reg:SI R27_REGNUM))]
10395 "!TARGET_64BIT"
10396 "*
10397 {
10398 return \"addil LR'%1-$tls_gdidx$,%%r27\;ldo RR'%1-$tls_gdidx$(%%r1),%0\";
10399 }"
10400 [(set_attr "type" "multi")
10401 (set_attr "length" "8")])
10402
10403 (define_expand "tgd_load_pic"
10404 [(set (match_operand 0 "register_operand")
10405 (unspec [(match_operand 1 "tgd_symbolic_operand")] UNSPEC_TLSGD_PIC))
10406 (clobber (reg R1_REGNUM))]
10407 ""
10408 {
10409 if (TARGET_64BIT)
10410 emit_insn (gen_tgd_load_picdi (operands[0], operands[1]));
10411 else
10412 emit_insn (gen_tgd_load_picsi (operands[0], operands[1]));
10413 DONE;
10414 })
10415
10416 (define_insn "tgd_load_picsi"
10417 [(set (match_operand:SI 0 "register_operand" "=r")
10418 (unspec:SI [(match_operand 1 "tgd_symbolic_operand" "")] UNSPEC_TLSGD_PIC))
10419 (clobber (reg:SI R1_REGNUM))
10420 (use (reg:SI R19_REGNUM))]
10421 "!TARGET_64BIT"
10422 "*
10423 {
10424 return \"addil LT'%1-$tls_gdidx$,%%r19\;ldo RT'%1-$tls_gdidx$(%%r1),%0\";
10425 }"
10426 [(set_attr "type" "multi")
10427 (set_attr "length" "8")])
10428
10429 (define_insn "tgd_load_picdi"
10430 [(set (match_operand:DI 0 "register_operand" "=r")
10431 (unspec:DI [(match_operand 1 "tgd_symbolic_operand" "")] UNSPEC_TLSGD_PIC))
10432 (clobber (reg:DI R1_REGNUM))
10433 (use (reg:DI R27_REGNUM))]
10434 "TARGET_64BIT"
10435 "*
10436 {
10437 return \"addil LT'%1-$tls_gdidx$,%%r27\;ldo RT'%1-$tls_gdidx$(%%r1),%0\";
10438 }"
10439 [(set_attr "type" "multi")
10440 (set_attr "length" "8")])
10441
10442 (define_insn "tld_load"
10443 [(set (match_operand:SI 0 "register_operand" "=r")
10444 (unspec:SI [(match_operand 1 "tld_symbolic_operand" "")] UNSPEC_TLSLDM))
10445 (clobber (reg:SI R1_REGNUM))
10446 (use (reg:SI R27_REGNUM))]
10447 "!TARGET_64BIT"
10448 "*
10449 {
10450 return \"addil LR'%1-$tls_ldidx$,%%r27\;ldo RR'%1-$tls_ldidx$(%%r1),%0\";
10451 }"
10452 [(set_attr "type" "multi")
10453 (set_attr "length" "8")])
10454
10455 (define_expand "tld_load_pic"
10456 [(set (match_operand 0 "register_operand")
10457 (unspec [(match_operand 1 "tld_symbolic_operand")] UNSPEC_TLSLDM_PIC))
10458 (clobber (reg R1_REGNUM))]
10459 ""
10460 {
10461 if (TARGET_64BIT)
10462 emit_insn (gen_tld_load_picdi (operands[0], operands[1]));
10463 else
10464 emit_insn (gen_tld_load_picsi (operands[0], operands[1]));
10465 DONE;
10466 })
10467
10468 (define_insn "tld_load_picsi"
10469 [(set (match_operand:SI 0 "register_operand" "=r")
10470 (unspec:SI [(match_operand 1 "tld_symbolic_operand" "")] UNSPEC_TLSLDM_PIC))
10471 (clobber (reg:SI R1_REGNUM))
10472 (use (reg:SI R19_REGNUM))]
10473 "!TARGET_64BIT"
10474 "*
10475 {
10476 return \"addil LT'%1-$tls_ldidx$,%%r19\;ldo RT'%1-$tls_ldidx$(%%r1),%0\";
10477 }"
10478 [(set_attr "type" "multi")
10479 (set_attr "length" "8")])
10480
10481 (define_insn "tld_load_picdi"
10482 [(set (match_operand:DI 0 "register_operand" "=r")
10483 (unspec:DI [(match_operand 1 "tld_symbolic_operand" "")] UNSPEC_TLSLDM_PIC))
10484 (clobber (reg:DI R1_REGNUM))
10485 (use (reg:DI R27_REGNUM))]
10486 "TARGET_64BIT"
10487 "*
10488 {
10489 return \"addil LT'%1-$tls_ldidx$,%%r27\;ldo RT'%1-$tls_ldidx$(%%r1),%0\";
10490 }"
10491 [(set_attr "type" "multi")
10492 (set_attr "length" "8")])
10493
10494 (define_expand "tld_offset_load"
10495 [(set (match_operand 0 "register_operand")
10496 (plus (unspec [(match_operand 1 "tld_symbolic_operand")]
10497 UNSPEC_TLSLDO)
10498 (match_operand 2 "register_operand")))
10499 (clobber (reg R1_REGNUM))]
10500 ""
10501 {
10502 if (TARGET_64BIT)
10503 emit_insn (gen_tld_offset_loaddi (operands[0], operands[1], operands[2]));
10504 else
10505 emit_insn (gen_tld_offset_loadsi (operands[0], operands[1], operands[2]));
10506 DONE;
10507 })
10508
10509 (define_insn "tld_offset_load<P:mode>"
10510 [(set (match_operand:P 0 "register_operand" "=r")
10511 (plus:P (unspec:P [(match_operand 1 "tld_symbolic_operand" "")]
10512 UNSPEC_TLSLDO)
10513 (match_operand:P 2 "register_operand" "r")))
10514 (clobber (reg:P R1_REGNUM))]
10515 ""
10516 "*
10517 {
10518 return \"addil LR'%1-$tls_dtpoff$,%2\;ldo RR'%1-$tls_dtpoff$(%%r1),%0\";
10519 }"
10520 [(set_attr "type" "multi")
10521 (set_attr "length" "8")])
10522
10523 (define_expand "tp_load"
10524 [(set (match_operand 0 "register_operand")
10525 (unspec [(const_int 0)] UNSPEC_TP))]
10526 ""
10527 {
10528 if (TARGET_64BIT)
10529 emit_insn (gen_tp_loaddi (operands[0]));
10530 else
10531 emit_insn (gen_tp_loadsi (operands[0]));
10532 DONE;
10533 })
10534
10535 (define_insn "tp_load<P:mode>"
10536 [(set (match_operand:P 0 "register_operand" "=r")
10537 (unspec:P [(const_int 0)] UNSPEC_TP))]
10538 ""
10539 "mfctl %%cr27,%0"
10540 [(set_attr "type" "multi")
10541 (set_attr "length" "4")])
10542
10543 (define_insn "tie_load"
10544 [(set (match_operand:SI 0 "register_operand" "=r")
10545 (unspec:SI [(match_operand 1 "tie_symbolic_operand" "")] UNSPEC_TLSIE))
10546 (clobber (reg:SI R1_REGNUM))
10547 (use (reg:SI R27_REGNUM))]
10548 "!TARGET_64BIT"
10549 "*
10550 {
10551 return \"addil LR'%1-$tls_ieoff$,%%r27\;ldw RR'%1-$tls_ieoff$(%%r1),%0\";
10552 }"
10553 [(set_attr "type" "multi")
10554 (set_attr "length" "8")])
10555
10556 (define_expand "tie_load_pic"
10557 [(set (match_operand 0 "register_operand")
10558 (unspec [(match_operand 1 "tie_symbolic_operand")] UNSPEC_TLSIE_PIC))
10559 (clobber (reg R1_REGNUM))]
10560 ""
10561 {
10562 if (TARGET_64BIT)
10563 emit_insn (gen_tie_load_picdi (operands[0], operands[1]));
10564 else
10565 emit_insn (gen_tie_load_picsi (operands[0], operands[1]));
10566 DONE;
10567 })
10568
10569 (define_insn "tie_load_picsi"
10570 [(set (match_operand:SI 0 "register_operand" "=r")
10571 (unspec:SI [(match_operand 1 "tie_symbolic_operand" "")] UNSPEC_TLSIE_PIC))
10572 (clobber (reg:SI R1_REGNUM))
10573 (use (reg:SI R19_REGNUM))]
10574 "!TARGET_64BIT"
10575 "*
10576 {
10577 return \"addil LT'%1-$tls_ieoff$,%%r19\;ldw RT'%1-$tls_ieoff$(%%r1),%0\";
10578 }"
10579 [(set_attr "type" "multi")
10580 (set_attr "length" "8")])
10581
10582 (define_insn "tie_load_picdi"
10583 [(set (match_operand:DI 0 "register_operand" "=r")
10584 (unspec:DI [(match_operand 1 "tie_symbolic_operand" "")] UNSPEC_TLSIE_PIC))
10585 (clobber (reg:DI R1_REGNUM))
10586 (use (reg:DI R27_REGNUM))]
10587 "!TARGET_64BIT"
10588 "*
10589 {
10590 return \"addil LT'%1-$tls_ieoff$,%%r27\;ldd RT'%1-$tls_ieoff$(%%r1),%0\";
10591 }"
10592 [(set_attr "type" "multi")
10593 (set_attr "length" "8")])
10594
10595 (define_expand "tle_load"
10596 [(set (match_operand 0 "register_operand")
10597 (plus (unspec [(match_operand 1 "tle_symbolic_operand")]
10598 UNSPEC_TLSLE)
10599 (match_operand 2 "register_operand")))
10600 (clobber (reg R1_REGNUM))]
10601 ""
10602 {
10603 if (TARGET_64BIT)
10604 emit_insn (gen_tle_loaddi (operands[0], operands[1], operands[2]));
10605 else
10606 emit_insn (gen_tle_loadsi (operands[0], operands[1], operands[2]));
10607 DONE;
10608 })
10609
10610 (define_insn "tle_load<P:mode>"
10611 [(set (match_operand:P 0 "register_operand" "=r")
10612 (plus:P (unspec:P [(match_operand 1 "tle_symbolic_operand" "")]
10613 UNSPEC_TLSLE)
10614 (match_operand:P 2 "register_operand" "r")))
10615 (clobber (reg:P R1_REGNUM))]
10616 ""
10617 "addil LR'%1-$tls_leoff$,%2\;ldo RR'%1-$tls_leoff$(%%r1),%0"
10618 [(set_attr "type" "multi")
10619 (set_attr "length" "8")])
10620
10621 ;; Atomic instructions
10622
10623 ;; All memory loads and stores access storage atomically except
10624 ;; for one exception. The STORE BYTES, STORE DOUBLE BYTES, and
10625 ;; doubleword loads and stores are not guaranteed to be atomic
10626 ;; when referencing the I/O address space.
10627
10628 ;; Atomic and sync libcalls use different lock sets. Great care is
10629 ;; needed if both are used in a single application.
10630
10631 ;; Atomic load and store libcalls are enabled by the -matomic-libcalls
10632 ;; option. This option is not enabled by default as the generated
10633 ;; libcalls depend on libatomic which is not built until the end of
10634 ;; the gcc build. For loads, we only need an atomic libcall for DImode.
10635 ;; Sync libcalls are not generated when atomic libcalls are enabled.
10636
10637 ;; Sync libcalls are enabled by default when supported. They can be
10638 ;; disabled by the -fno-sync-libcalls option. Sync libcalls always
10639 ;; use a single memory store in their implementation, even for DImode.
10640 ;; DImode stores are done using either std or fstd. Thus, we only
10641 ;; need a sync load libcall for DImode when we don't have an atomic
10642 ;; processor load available for the mode (TARGET_SOFT_FLOAT).
10643
10644 ;; Implement atomic QImode store using exchange.
10645
10646 (define_expand "atomic_storeqi"
10647 [(match_operand:QI 0 "memory_operand") ;; memory
10648 (match_operand:QI 1 "register_operand") ;; val out
10649 (match_operand:SI 2 "const_int_operand")] ;; model
10650 ""
10651 {
10652 rtx addr, libfunc;
10653
10654 if (TARGET_SYNC_LIBCALLS)
10655 {
10656 addr = convert_memory_address (Pmode, XEXP (operands[0], 0));
10657 libfunc = optab_libfunc (sync_lock_test_and_set_optab, QImode);
10658 emit_library_call (libfunc, LCT_NORMAL, VOIDmode, addr, Pmode,
10659 operands[1], QImode);
10660 DONE;
10661 }
10662
10663 if (TARGET_ATOMIC_LIBCALLS)
10664 {
10665 addr = convert_memory_address (Pmode, XEXP (operands[0], 0));
10666 libfunc = init_one_libfunc ("__atomic_exchange_1");
10667 emit_library_call (libfunc, LCT_NORMAL, VOIDmode, addr, Pmode,
10668 operands[1], QImode);
10669 DONE;
10670 }
10671
10672 FAIL;
10673 })
10674
10675 ;; Implement atomic HImode store using exchange.
10676
10677 (define_expand "atomic_storehi"
10678 [(match_operand:HI 0 "memory_operand") ;; memory
10679 (match_operand:HI 1 "register_operand") ;; val out
10680 (match_operand:SI 2 "const_int_operand")] ;; model
10681 ""
10682 {
10683 rtx addr, libfunc;
10684
10685 if (TARGET_SYNC_LIBCALLS)
10686 {
10687 addr = convert_memory_address (Pmode, XEXP (operands[0], 0));
10688 libfunc = optab_libfunc (sync_lock_test_and_set_optab, HImode);
10689 emit_library_call (libfunc, LCT_NORMAL, VOIDmode, addr, Pmode,
10690 operands[1], HImode);
10691 DONE;
10692 }
10693
10694 if (TARGET_ATOMIC_LIBCALLS)
10695 {
10696 addr = convert_memory_address (Pmode, XEXP (operands[0], 0));
10697 libfunc = init_one_libfunc ("__atomic_exchange_2");
10698 emit_library_call (libfunc, LCT_NORMAL, VOIDmode, addr, Pmode,
10699 operands[1], HImode);
10700 DONE;
10701 }
10702
10703 FAIL;
10704 })
10705
10706 ;; Implement atomic SImode store using exchange.
10707
10708 (define_expand "atomic_storesi"
10709 [(match_operand:SI 0 "memory_operand") ;; memory
10710 (match_operand:SI 1 "register_operand") ;; val out
10711 (match_operand:SI 2 "const_int_operand")] ;; model
10712 ""
10713 {
10714 rtx addr, libfunc;
10715
10716 if (TARGET_SYNC_LIBCALLS)
10717 {
10718 addr = convert_memory_address (Pmode, XEXP (operands[0], 0));
10719 libfunc = optab_libfunc (sync_lock_test_and_set_optab, SImode);
10720 emit_library_call (libfunc, LCT_NORMAL, VOIDmode, addr, Pmode,
10721 operands[1], SImode);
10722 DONE;
10723 }
10724
10725 if (TARGET_ATOMIC_LIBCALLS)
10726 {
10727 addr = convert_memory_address (Pmode, XEXP (operands[0], 0));
10728 libfunc = init_one_libfunc ("__atomic_exchange_4");
10729 emit_library_call (libfunc, LCT_NORMAL, VOIDmode, addr, Pmode,
10730 operands[1], SImode);
10731 DONE;
10732 }
10733
10734 FAIL;
10735 })
10736
10737 ;; Implement atomic DImode load.
10738
10739 ;; We need an atomic or sync libcall whenever the processor load or
10740 ;; store used for DImode is not atomic. The 32-bit libatomic
10741 ;; implementation uses a pair of stw instructions. They are not
10742 ;; atomic, so we need to call __atomic_load_8. The linux libgcc
10743 ;; sync implementation uses a std or fstd instruction. They are
10744 ;; atomic, so we only need to call __sync_load_8 when the load
10745 ;; operation would not be atomic (e.g., 32-bit TARGET_SOFT_FLOAT).
10746
10747 (define_expand "atomic_loaddi"
10748 [(match_operand:DI 0 "register_operand") ;; val out
10749 (match_operand:DI 1 "memory_operand") ;; memory
10750 (match_operand:SI 2 "const_int_operand")] ;; model
10751 ""
10752 {
10753 enum memmodel model;
10754 rtx addr, libfunc;
10755
10756 if (TARGET_64BIT)
10757 FAIL;
10758
10759 if (TARGET_SYNC_LIBCALLS && MAX_SYNC_LIBFUNC_SIZE >= 8 && TARGET_SOFT_FLOAT)
10760 {
10761 addr = convert_memory_address (Pmode, XEXP (operands[1], 0));
10762 libfunc = init_one_libfunc ("__sync_load_8");
10763 emit_library_call_value (libfunc, operands[0], LCT_NORMAL, DImode,
10764 addr, Pmode);
10765 DONE;
10766 }
10767
10768 if (TARGET_ATOMIC_LIBCALLS && TARGET_SOFT_FLOAT)
10769 {
10770 addr = convert_memory_address (Pmode, XEXP (operands[1], 0));
10771 libfunc = init_one_libfunc ("__atomic_load_8");
10772 emit_library_call_value (libfunc, operands[0], LCT_NORMAL, DImode,
10773 addr, Pmode);
10774 DONE;
10775 }
10776
10777 if (TARGET_SOFT_FLOAT)
10778 FAIL;
10779
10780 /* Fallback to processor load with barriers. */
10781 model = memmodel_from_int (INTVAL (operands[2]));
10782 operands[1] = force_reg (Pmode, XEXP (operands[1], 0));
10783 if (is_mm_seq_cst (model))
10784 expand_mem_thread_fence (model);
10785 emit_insn (gen_atomic_loaddi_1 (operands[0], operands[1]));
10786 expand_mem_thread_fence (model);
10787 DONE;
10788 })
10789
10790 (define_insn "atomic_loaddi_1"
10791 [(set (match_operand:DI 0 "register_operand" "=r")
10792 (mem:DI (match_operand:SI 1 "register_operand" "r")))
10793 (clobber (match_scratch:DI 2 "=f"))]
10794 "!TARGET_64BIT && !TARGET_SOFT_FLOAT"
10795 "{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"
10796 [(set_attr "type" "move")
10797 (set_attr "length" "16")])
10798
10799 ;; Implement atomic DImode store.
10800
10801 (define_expand "atomic_storedi"
10802 [(match_operand:DI 0 "memory_operand") ;; memory
10803 (match_operand:DI 1 "reg_or_cint_move_operand") ;; val out
10804 (match_operand:SI 2 "const_int_operand")] ;; model
10805 ""
10806 {
10807 enum memmodel model;
10808 rtx addr, libfunc;
10809
10810 if (TARGET_SYNC_LIBCALLS && MAX_SYNC_LIBFUNC_SIZE >= 8)
10811 {
10812 addr = convert_memory_address (Pmode, XEXP (operands[0], 0));
10813 libfunc = optab_libfunc (sync_lock_test_and_set_optab, DImode);
10814 emit_library_call (libfunc, LCT_NORMAL, VOIDmode, addr, Pmode,
10815 operands[1], DImode);
10816 DONE;
10817 }
10818
10819 if (TARGET_ATOMIC_LIBCALLS)
10820 {
10821 addr = convert_memory_address (Pmode, XEXP (operands[0], 0));
10822 libfunc = init_one_libfunc ("__atomic_exchange_8");
10823 emit_library_call (libfunc, LCT_NORMAL, VOIDmode, addr, Pmode,
10824 operands[1], DImode);
10825 DONE;
10826 }
10827
10828 if (TARGET_64BIT || TARGET_SOFT_FLOAT)
10829 FAIL;
10830
10831 /* Fallback to processor store with barriers. */
10832 model = memmodel_from_int (INTVAL (operands[2]));
10833 operands[0] = force_reg (Pmode, XEXP (operands[0], 0));
10834 if (operands[1] != CONST0_RTX (DImode))
10835 operands[1] = force_reg (DImode, operands[1]);
10836 expand_mem_thread_fence (model);
10837 emit_insn (gen_atomic_storedi_1 (operands[0], operands[1]));
10838 if (is_mm_seq_cst (model))
10839 expand_mem_thread_fence (model);
10840 DONE;
10841 })
10842
10843 (define_insn "atomic_storedi_1"
10844 [(set (mem:DI (match_operand:SI 0 "register_operand" "r,r"))
10845 (match_operand:DI 1 "reg_or_0_operand" "M,r"))
10846 (clobber (match_scratch:DI 2 "=f,f"))]
10847 "!TARGET_64BIT && !TARGET_SOFT_FLOAT"
10848 "@
10849 fcpy,dbl %%fr0,%2\n\t{fstds|fstd} %2,0(%0)
10850 {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)"
10851 [(set_attr "type" "move,move")
10852 (set_attr "length" "8,16")])
10853
10854 ;; PA 2.0 hardware supports out-of-order execution of loads and stores, so
10855 ;; we need memory barriers to enforce program order for memory references
10856 ;; when the TLB and PSW O bits are not set. We assume all PA 2.0 systems
10857 ;; are weakly ordered since neither HP-UX or Linux set the PSW O bit. Since
10858 ;; we want PA 1.x code to be PA 2.0 compatible, we also need barriers when
10859 ;; generating PA 1.x code even though all PA 1.x systems are strongly ordered.
10860
10861 ;; When barriers are needed, we use a strongly ordered ldcw instruction as
10862 ;; the barrier. All PA 2.0 targets accept the "co" cache control hint but
10863 ;; only PA8800 and PA8900 processors implement the cacheable hint. In
10864 ;; that case, we can avoid aligning the ldcw address. In spite of its
10865 ;; description, it is not clear that the sync instruction works as a barrier.
10866
10867 (define_expand "memory_barrier"
10868 [(parallel
10869 [(set (match_dup 0) (unspec:BLK [(match_dup 0)] UNSPEC_MEMORY_BARRIER))
10870 (clobber (match_dup 1))])]
10871 ""
10872 {
10873 /* We don't need a barrier if the target uses ordered memory references. */
10874 if (TARGET_ORDERED)
10875 FAIL;
10876 operands[1] = gen_reg_rtx (Pmode);
10877 operands[0] = gen_rtx_MEM (BLKmode, operands[1]);
10878 MEM_VOLATILE_P (operands[0]) = 1;
10879 })
10880
10881 (define_insn "*memory_barrier_coherent"
10882 [(set (match_operand:BLK 0 "" "")
10883 (unspec:BLK [(match_dup 0)] UNSPEC_MEMORY_BARRIER))
10884 (clobber (match_operand 1 "pmode_register_operand" "=r"))]
10885 "TARGET_PA_20 && TARGET_COHERENT_LDCW"
10886 "ldcw,co 0(%%sp),%1"
10887 [(set_attr "type" "binary")
10888 (set_attr "length" "4")])
10889
10890 (define_insn "*memory_barrier_64"
10891 [(set (match_operand:BLK 0 "" "")
10892 (unspec:BLK [(match_dup 0)] UNSPEC_MEMORY_BARRIER))
10893 (clobber (match_operand 1 "pmode_register_operand" "=&r"))]
10894 "TARGET_64BIT"
10895 "ldo 15(%%sp),%1\n\tdepd %%r0,63,3,%1\n\tldcw,co 0(%1),%1"
10896 [(set_attr "type" "binary")
10897 (set_attr "length" "12")])
10898
10899 (define_insn "*memory_barrier_32"
10900 [(set (match_operand:BLK 0 "" "")
10901 (unspec:BLK [(match_dup 0)] UNSPEC_MEMORY_BARRIER))
10902 (clobber (match_operand 1 "pmode_register_operand" "=&r"))]
10903 ""
10904 "ldo 15(%%sp),%1\n\t{dep|depw} %%r0,31,3,%1\n\t{ldcw|ldcw,co} 0(%1),%1"
10905 [(set_attr "type" "binary")
10906 (set_attr "length" "12")])
10907
10908 ;; Get floating-point status register.
10909
10910 (define_expand "get_fpsr"
10911 [(set (match_operand:SI 0 "register_operand" "=r")
10912 (unspec_volatile:SI [(const_int 0)] UNSPECV_GET_FPSR))]
10913 ""
10914 {
10915 if (TARGET_SOFT_FLOAT)
10916 FAIL;
10917
10918 if (TARGET_64BIT)
10919 emit_insn (gen_get_fpsr_64 (operands[0]));
10920 else
10921 emit_insn (gen_get_fpsr_32 (operands[0]));
10922 DONE;
10923 })
10924
10925 ;; The floating-point status register is stored to an unused slot in
10926 ;; the frame marker and then loaded to register operand 0. The final
10927 ;; floating-point load restores the T bit in the status register.
10928
10929 ;; The final load might be avoided if a word mode store was used to
10930 ;; store the status register. It is unclear why we need a double-word
10931 ;; store. I suspect PA 1.0 didn't support single-word stores of the
10932 ;; status register.
10933
10934 (define_insn "get_fpsr_32"
10935 [(set (match_operand:SI 0 "register_operand" "=r")
10936 (unspec_volatile:SI [(const_int 0)] UNSPECV_GET_FPSR))]
10937 "!TARGET_SOFT_FLOAT && !TARGET_64BIT"
10938 "{fstds|fstd} %%fr0,-16(%%sp)\n\tldw -16(%%sp),%0\n\t{fldds|fldd} -16(%%sp),%%fr0"
10939 [(set_attr "type" "fpstore_load")
10940 (set_attr "length" "12")])
10941
10942 ;; The 64-bit pattern is similar to the 32-bit pattern except we need
10943 ;; compute the address of the frame location as long displacements aren't
10944 ;; supported on Linux targets.
10945
10946 (define_insn "get_fpsr_64"
10947 [(set (match_operand:SI 0 "register_operand" "=r")
10948 (unspec_volatile:SI [(const_int 0)] UNSPECV_GET_FPSR))
10949 (clobber (match_scratch:DI 1 "=&r"))]
10950 "!TARGET_SOFT_FLOAT && TARGET_64BIT"
10951 "ldo -40(%%sp),%1\n\tfstd %%fr0,0(%1)\n\tldw 0(%1),%0\n\tfldd 0(%1),%%fr0"
10952 [(set_attr "type" "fpstore_load")
10953 (set_attr "length" "16")])
10954
10955 ;; Set floating-point status register.
10956
10957 (define_expand "set_fpsr"
10958 [(unspec_volatile [(match_operand:SI 0 "register_operand" "r")] UNSPECV_SET_FPSR)]
10959 ""
10960 {
10961 if (TARGET_SOFT_FLOAT)
10962 FAIL;
10963
10964 if (TARGET_64BIT)
10965 emit_insn (gen_set_fpsr_64 (operands[0]));
10966 else
10967 emit_insn (gen_set_fpsr_32 (operands[0]));
10968 DONE;
10969 })
10970
10971 ;; The old T bit is extracted and stored in the new status register.
10972
10973 (define_insn "set_fpsr_32"
10974 [(unspec_volatile [(match_operand:SI 0 "register_operand" "r")] UNSPECV_SET_FPSR)
10975 (clobber (match_scratch:SI 1 "=&r"))]
10976 "!TARGET_SOFT_FLOAT && !TARGET_64BIT"
10977 "{fstds|fstd} %%fr0,-16(%%sp)\n\tldw -16(%%sp),%1\n\t{extru|extrw,u} %1,25,1,%1\n\t{dep|depw} %1,25,1,%0\n\tstw %0,-16(%%sp)\n\t{fldds|fldd} -16(%%sp),%%fr0"
10978 [(set_attr "type" "store_fpload")
10979 (set_attr "length" "24")])
10980
10981 (define_insn "set_fpsr_64"
10982 [(unspec_volatile [(match_operand:SI 0 "register_operand" "r")] UNSPECV_SET_FPSR)
10983 (clobber (match_scratch:DI 1 "=&r"))
10984 (clobber (match_scratch:SI 2 "=&r"))]
10985 "!TARGET_SOFT_FLOAT && TARGET_64BIT"
10986 "ldo -40(%%sp),%1\n\tfstd %%fr0,0(%1)\n\tldw 0(%1),%2\n\textrw,u %2,25,1,%2\n\tdepw %2,25,1,%0\n\tstw %0,0(%1)\n\tfldd 0(%1),%%fr0"
10987 [(set_attr "type" "store_fpload")
10988 (set_attr "length" "28")])