pa.md: (prefetch_64, prefetch_32): Fix typo.
[gcc.git] / gcc / config / pa / pa.md
1 ;;- Machine description for HP PA-RISC architecture for GCC compiler
2 ;; Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
3 ;; 2002, 2003, 2004 Free Software Foundation, Inc.
4 ;; Contributed by the Center for Software Science at the University
5 ;; of Utah.
6
7 ;; This file is part of GCC.
8
9 ;; GCC is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; any later version.
13
14 ;; GCC is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GCC; see the file COPYING. If not, write to
21 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
23
24 ;; This gcc Version 2 machine description is inspired by sparc.md and
25 ;; mips.md.
26
27 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
28
29 ;; Uses of UNSPEC in this file:
30
31 (define_constants
32 [(UNSPEC_CFFC 0) ; canonicalize_funcptr_for_compare
33 (UNSPEC_GOTO 1) ; indirect_goto
34 (UNSPEC_DLTIND14R 2) ;
35 ])
36
37 ;; UNSPEC_VOLATILE:
38
39 (define_constants
40 [(UNSPECV_BLOCKAGE 0) ; blockage
41 (UNSPECV_DCACHE 1) ; dcacheflush
42 (UNSPECV_ICACHE 2) ; icacheflush
43 (UNSPECV_OPC 3) ; outline_prologue_call
44 (UNSPECV_OEC 4) ; outline_epilogue_call
45 (UNSPECV_LONGJMP 5) ; builtin_longjmp
46 ])
47
48 ;; Insn type. Used to default other attribute values.
49
50 ;; type "unary" insns have one input operand (1) and one output operand (0)
51 ;; type "binary" insns have two input operands (1,2) and one output (0)
52
53 (define_attr "type"
54 "move,unary,binary,shift,nullshift,compare,load,store,uncond_branch,btable_branch,branch,cbranch,fbranch,call,dyncall,fpload,fpstore,fpalu,fpcc,fpmulsgl,fpmuldbl,fpdivsgl,fpdivdbl,fpsqrtsgl,fpsqrtdbl,multi,milli,parallel_branch"
55 (const_string "binary"))
56
57 (define_attr "pa_combine_type"
58 "fmpy,faddsub,uncond_branch,addmove,none"
59 (const_string "none"))
60
61 ;; Processor type (for scheduling, not code generation) -- this attribute
62 ;; must exactly match the processor_type enumeration in pa.h.
63 ;;
64 ;; FIXME: Add 800 scheduling for completeness?
65
66 (define_attr "cpu" "700,7100,7100LC,7200,7300,8000" (const (symbol_ref "pa_cpu_attr")))
67
68 ;; Length (in # of bytes).
69 (define_attr "length" ""
70 (cond [(eq_attr "type" "load,fpload")
71 (if_then_else (match_operand 1 "symbolic_memory_operand" "")
72 (const_int 8) (const_int 4))
73
74 (eq_attr "type" "store,fpstore")
75 (if_then_else (match_operand 0 "symbolic_memory_operand" "")
76 (const_int 8) (const_int 4))
77
78 (eq_attr "type" "binary,shift,nullshift")
79 (if_then_else (match_operand 2 "arith_operand" "")
80 (const_int 4) (const_int 12))
81
82 (eq_attr "type" "move,unary,shift,nullshift")
83 (if_then_else (match_operand 1 "arith_operand" "")
84 (const_int 4) (const_int 8))]
85
86 (const_int 4)))
87
88 (define_asm_attributes
89 [(set_attr "length" "4")
90 (set_attr "type" "multi")])
91
92 ;; Attributes for instruction and branch scheduling
93
94 ;; For conditional branches.
95 (define_attr "in_branch_delay" "false,true"
96 (if_then_else (and (eq_attr "type" "!uncond_branch,btable_branch,branch,cbranch,fbranch,call,dyncall,multi,milli,parallel_branch")
97 (eq_attr "length" "4"))
98 (const_string "true")
99 (const_string "false")))
100
101 ;; Disallow instructions which use the FPU since they will tie up the FPU
102 ;; even if the instruction is nullified.
103 (define_attr "in_nullified_branch_delay" "false,true"
104 (if_then_else (and (eq_attr "type" "!uncond_branch,btable_branch,branch,cbranch,fbranch,call,dyncall,multi,milli,fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpdivdbl,fpsqrtsgl,fpsqrtdbl,parallel_branch")
105 (eq_attr "length" "4"))
106 (const_string "true")
107 (const_string "false")))
108
109 ;; For calls and millicode calls. Allow unconditional branches in the
110 ;; delay slot.
111 (define_attr "in_call_delay" "false,true"
112 (cond [(and (eq_attr "type" "!uncond_branch,btable_branch,branch,cbranch,fbranch,call,dyncall,multi,milli,parallel_branch")
113 (eq_attr "length" "4"))
114 (const_string "true")
115 (eq_attr "type" "uncond_branch")
116 (if_then_else (ne (symbol_ref "TARGET_JUMP_IN_DELAY")
117 (const_int 0))
118 (const_string "true")
119 (const_string "false"))]
120 (const_string "false")))
121
122
123 ;; Call delay slot description.
124 (define_delay (eq_attr "type" "call")
125 [(eq_attr "in_call_delay" "true") (nil) (nil)])
126
127 ;; Millicode call delay slot description.
128 (define_delay (eq_attr "type" "milli")
129 [(eq_attr "in_call_delay" "true") (nil) (nil)])
130
131 ;; Return and other similar instructions.
132 (define_delay (eq_attr "type" "btable_branch,branch,parallel_branch")
133 [(eq_attr "in_branch_delay" "true") (nil) (nil)])
134
135 ;; Floating point conditional branch delay slot description and
136 (define_delay (eq_attr "type" "fbranch")
137 [(eq_attr "in_branch_delay" "true")
138 (eq_attr "in_nullified_branch_delay" "true")
139 (nil)])
140
141 ;; Integer conditional branch delay slot description.
142 ;; Nullification of conditional branches on the PA is dependent on the
143 ;; direction of the branch. Forward branches nullify true and
144 ;; backward branches nullify false. If the direction is unknown
145 ;; then nullification is not allowed.
146 (define_delay (eq_attr "type" "cbranch")
147 [(eq_attr "in_branch_delay" "true")
148 (and (eq_attr "in_nullified_branch_delay" "true")
149 (attr_flag "forward"))
150 (and (eq_attr "in_nullified_branch_delay" "true")
151 (attr_flag "backward"))])
152
153 (define_delay (and (eq_attr "type" "uncond_branch")
154 (eq (symbol_ref "following_call (insn)")
155 (const_int 0)))
156 [(eq_attr "in_branch_delay" "true") (nil) (nil)])
157
158 ;; Memory. Disregarding Cache misses, the Mustang memory times are:
159 ;; load: 2, fpload: 3
160 ;; store, fpstore: 3, no D-cache operations should be scheduled.
161
162 ;; The Timex (aka 700) has two floating-point units: ALU, and MUL/DIV/SQRT.
163 ;; Timings:
164 ;; Instruction Time Unit Minimum Distance (unit contention)
165 ;; fcpy 3 ALU 2
166 ;; fabs 3 ALU 2
167 ;; fadd 3 ALU 2
168 ;; fsub 3 ALU 2
169 ;; fcmp 3 ALU 2
170 ;; fcnv 3 ALU 2
171 ;; fmpyadd 3 ALU,MPY 2
172 ;; fmpysub 3 ALU,MPY 2
173 ;; fmpycfxt 3 ALU,MPY 2
174 ;; fmpy 3 MPY 2
175 ;; fmpyi 3 MPY 2
176 ;; fdiv,sgl 10 MPY 10
177 ;; fdiv,dbl 12 MPY 12
178 ;; fsqrt,sgl 14 MPY 14
179 ;; fsqrt,dbl 18 MPY 18
180 ;;
181 ;; We don't model fmpyadd/fmpysub properly as those instructions
182 ;; keep both the FP ALU and MPY units busy. Given that these
183 ;; processors are obsolete, I'm not going to spend the time to
184 ;; model those instructions correctly.
185
186 (define_automaton "pa700")
187 (define_cpu_unit "dummy_700,mem_700,fpalu_700,fpmpy_700" "pa700")
188
189 (define_insn_reservation "W0" 4
190 (and (eq_attr "type" "fpcc")
191 (eq_attr "cpu" "700"))
192 "fpalu_700*2")
193
194 (define_insn_reservation "W1" 3
195 (and (eq_attr "type" "fpalu")
196 (eq_attr "cpu" "700"))
197 "fpalu_700*2")
198
199 (define_insn_reservation "W2" 3
200 (and (eq_attr "type" "fpmulsgl,fpmuldbl")
201 (eq_attr "cpu" "700"))
202 "fpmpy_700*2")
203
204 (define_insn_reservation "W3" 10
205 (and (eq_attr "type" "fpdivsgl")
206 (eq_attr "cpu" "700"))
207 "fpmpy_700*10")
208
209 (define_insn_reservation "W4" 12
210 (and (eq_attr "type" "fpdivdbl")
211 (eq_attr "cpu" "700"))
212 "fpmpy_700*12")
213
214 (define_insn_reservation "W5" 14
215 (and (eq_attr "type" "fpsqrtsgl")
216 (eq_attr "cpu" "700"))
217 "fpmpy_700*14")
218
219 (define_insn_reservation "W6" 18
220 (and (eq_attr "type" "fpsqrtdbl")
221 (eq_attr "cpu" "700"))
222 "fpmpy_700*18")
223
224 (define_insn_reservation "W7" 2
225 (and (eq_attr "type" "load")
226 (eq_attr "cpu" "700"))
227 "mem_700")
228
229 (define_insn_reservation "W8" 2
230 (and (eq_attr "type" "fpload")
231 (eq_attr "cpu" "700"))
232 "mem_700")
233
234 (define_insn_reservation "W9" 3
235 (and (eq_attr "type" "store")
236 (eq_attr "cpu" "700"))
237 "mem_700*3")
238
239 (define_insn_reservation "W10" 3
240 (and (eq_attr "type" "fpstore")
241 (eq_attr "cpu" "700"))
242 "mem_700*3")
243
244 (define_insn_reservation "W11" 1
245 (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpdivdbl,fpsqrtsgl,fpsqrtdbl,load,fpload,store,fpstore")
246 (eq_attr "cpu" "700"))
247 "dummy_700")
248
249 ;; We have a bypass for all computations in the FP unit which feed an
250 ;; FP store as long as the sizes are the same.
251 (define_bypass 2 "W1,W2" "W10" "hppa_fpstore_bypass_p")
252 (define_bypass 9 "W3" "W10" "hppa_fpstore_bypass_p")
253 (define_bypass 11 "W4" "W10" "hppa_fpstore_bypass_p")
254 (define_bypass 13 "W5" "W10" "hppa_fpstore_bypass_p")
255 (define_bypass 17 "W6" "W10" "hppa_fpstore_bypass_p")
256
257 ;; We have an "anti-bypass" for FP loads which feed an FP store.
258 (define_bypass 4 "W8" "W10" "hppa_fpstore_bypass_p")
259
260 ;; Function units for the 7100 and 7150. The 7100/7150 can dual-issue
261 ;; floating point computations with non-floating point computations (fp loads
262 ;; and stores are not fp computations).
263 ;;
264 ;; Memory. Disregarding Cache misses, memory loads take two cycles; stores also
265 ;; take two cycles, during which no Dcache operations should be scheduled.
266 ;; Any special cases are handled in pa_adjust_cost. The 7100, 7150 and 7100LC
267 ;; all have the same memory characteristics if one disregards cache misses.
268 ;;
269 ;; The 7100/7150 has three floating-point units: ALU, MUL, and DIV.
270 ;; There's no value in modeling the ALU and MUL separately though
271 ;; since there can never be a functional unit conflict given the
272 ;; latency and issue rates for those units.
273 ;;
274 ;; Timings:
275 ;; Instruction Time Unit Minimum Distance (unit contention)
276 ;; fcpy 2 ALU 1
277 ;; fabs 2 ALU 1
278 ;; fadd 2 ALU 1
279 ;; fsub 2 ALU 1
280 ;; fcmp 2 ALU 1
281 ;; fcnv 2 ALU 1
282 ;; fmpyadd 2 ALU,MPY 1
283 ;; fmpysub 2 ALU,MPY 1
284 ;; fmpycfxt 2 ALU,MPY 1
285 ;; fmpy 2 MPY 1
286 ;; fmpyi 2 MPY 1
287 ;; fdiv,sgl 8 DIV 8
288 ;; fdiv,dbl 15 DIV 15
289 ;; fsqrt,sgl 8 DIV 8
290 ;; fsqrt,dbl 15 DIV 15
291
292 (define_automaton "pa7100")
293 (define_cpu_unit "i_7100, f_7100,fpmac_7100,fpdivsqrt_7100,mem_7100" "pa7100")
294
295 (define_insn_reservation "X0" 2
296 (and (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
297 (eq_attr "cpu" "7100"))
298 "f_7100,fpmac_7100")
299
300 (define_insn_reservation "X1" 8
301 (and (eq_attr "type" "fpdivsgl,fpsqrtsgl")
302 (eq_attr "cpu" "7100"))
303 "f_7100+fpdivsqrt_7100,fpdivsqrt_7100*7")
304
305 (define_insn_reservation "X2" 15
306 (and (eq_attr "type" "fpdivdbl,fpsqrtdbl")
307 (eq_attr "cpu" "7100"))
308 "f_7100+fpdivsqrt_7100,fpdivsqrt_7100*14")
309
310 (define_insn_reservation "X3" 2
311 (and (eq_attr "type" "load")
312 (eq_attr "cpu" "7100"))
313 "i_7100+mem_7100")
314
315 (define_insn_reservation "X4" 2
316 (and (eq_attr "type" "fpload")
317 (eq_attr "cpu" "7100"))
318 "i_7100+mem_7100")
319
320 (define_insn_reservation "X5" 2
321 (and (eq_attr "type" "store")
322 (eq_attr "cpu" "7100"))
323 "i_7100+mem_7100,mem_7100")
324
325 (define_insn_reservation "X6" 2
326 (and (eq_attr "type" "fpstore")
327 (eq_attr "cpu" "7100"))
328 "i_7100+mem_7100,mem_7100")
329
330 (define_insn_reservation "X7" 1
331 (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl,load,fpload,store,fpstore")
332 (eq_attr "cpu" "7100"))
333 "i_7100")
334
335 ;; We have a bypass for all computations in the FP unit which feed an
336 ;; FP store as long as the sizes are the same.
337 (define_bypass 1 "X0" "X6" "hppa_fpstore_bypass_p")
338 (define_bypass 7 "X1" "X6" "hppa_fpstore_bypass_p")
339 (define_bypass 14 "X2" "X6" "hppa_fpstore_bypass_p")
340
341 ;; We have an "anti-bypass" for FP loads which feed an FP store.
342 (define_bypass 3 "X4" "X6" "hppa_fpstore_bypass_p")
343
344 ;; The 7100LC has three floating-point units: ALU, MUL, and DIV.
345 ;; There's no value in modeling the ALU and MUL separately though
346 ;; since there can never be a functional unit conflict that
347 ;; can be avoided given the latency, issue rates and mandatory
348 ;; one cycle cpu-wide lock for a double precision fp multiply.
349 ;;
350 ;; Timings:
351 ;; Instruction Time Unit Minimum Distance (unit contention)
352 ;; fcpy 2 ALU 1
353 ;; fabs 2 ALU 1
354 ;; fadd 2 ALU 1
355 ;; fsub 2 ALU 1
356 ;; fcmp 2 ALU 1
357 ;; fcnv 2 ALU 1
358 ;; fmpyadd,sgl 2 ALU,MPY 1
359 ;; fmpyadd,dbl 3 ALU,MPY 2
360 ;; fmpysub,sgl 2 ALU,MPY 1
361 ;; fmpysub,dbl 3 ALU,MPY 2
362 ;; fmpycfxt,sgl 2 ALU,MPY 1
363 ;; fmpycfxt,dbl 3 ALU,MPY 2
364 ;; fmpy,sgl 2 MPY 1
365 ;; fmpy,dbl 3 MPY 2
366 ;; fmpyi 3 MPY 2
367 ;; fdiv,sgl 8 DIV 8
368 ;; fdiv,dbl 15 DIV 15
369 ;; fsqrt,sgl 8 DIV 8
370 ;; fsqrt,dbl 15 DIV 15
371 ;;
372 ;; The PA7200 is just like the PA7100LC except that there is
373 ;; no store-store penalty.
374 ;;
375 ;; The PA7300 is just like the PA7200 except that there is
376 ;; no store-load penalty.
377 ;;
378 ;; Note there are some aspects of the 7100LC we are not modeling
379 ;; at the moment. I'll be reviewing the 7100LC scheduling info
380 ;; shortly and updating this description.
381 ;;
382 ;; load-load pairs
383 ;; store-store pairs
384 ;; other issue modeling
385
386 (define_automaton "pa7100lc")
387 (define_cpu_unit "i0_7100lc, i1_7100lc, f_7100lc" "pa7100lc")
388 (define_cpu_unit "fpmac_7100lc" "pa7100lc")
389 (define_cpu_unit "mem_7100lc" "pa7100lc")
390
391 ;; Double precision multiplies lock the entire CPU for one
392 ;; cycle. There is no way to avoid this lock and trying to
393 ;; schedule around the lock is pointless and thus there is no
394 ;; value in trying to model this lock.
395 ;;
396 ;; Not modeling the lock allows us to treat fp multiplies just
397 ;; like any other FP alu instruction. It allows for a smaller
398 ;; DFA and may reduce register pressure.
399 (define_insn_reservation "Y0" 2
400 (and (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
401 (eq_attr "cpu" "7100LC,7200,7300"))
402 "f_7100lc,fpmac_7100lc")
403
404 ;; fp division and sqrt instructions lock the entire CPU for
405 ;; 7 cycles (single precision) or 14 cycles (double precision).
406 ;; There is no way to avoid this lock and trying to schedule
407 ;; around the lock is pointless and thus there is no value in
408 ;; trying to model this lock. Not modeling the lock allows
409 ;; for a smaller DFA and may reduce register pressure.
410 (define_insn_reservation "Y1" 1
411 (and (eq_attr "type" "fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl")
412 (eq_attr "cpu" "7100LC,7200,7300"))
413 "f_7100lc")
414
415 (define_insn_reservation "Y2" 2
416 (and (eq_attr "type" "load")
417 (eq_attr "cpu" "7100LC,7200,7300"))
418 "i1_7100lc+mem_7100lc")
419
420 (define_insn_reservation "Y3" 2
421 (and (eq_attr "type" "fpload")
422 (eq_attr "cpu" "7100LC,7200,7300"))
423 "i1_7100lc+mem_7100lc")
424
425 (define_insn_reservation "Y4" 2
426 (and (eq_attr "type" "store")
427 (eq_attr "cpu" "7100LC"))
428 "i1_7100lc+mem_7100lc,mem_7100lc")
429
430 (define_insn_reservation "Y5" 2
431 (and (eq_attr "type" "fpstore")
432 (eq_attr "cpu" "7100LC"))
433 "i1_7100lc+mem_7100lc,mem_7100lc")
434
435 (define_insn_reservation "Y6" 1
436 (and (eq_attr "type" "shift,nullshift")
437 (eq_attr "cpu" "7100LC,7200,7300"))
438 "i1_7100lc")
439
440 (define_insn_reservation "Y7" 1
441 (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl,load,fpload,store,fpstore,shift,nullshift")
442 (eq_attr "cpu" "7100LC,7200,7300"))
443 "(i0_7100lc|i1_7100lc)")
444
445 ;; The 7200 has a store-load penalty
446 (define_insn_reservation "Y8" 2
447 (and (eq_attr "type" "store")
448 (eq_attr "cpu" "7200"))
449 "i1_7100lc,mem_7100lc")
450
451 (define_insn_reservation "Y9" 2
452 (and (eq_attr "type" "fpstore")
453 (eq_attr "cpu" "7200"))
454 "i1_7100lc,mem_7100lc")
455
456 ;; The 7300 has no penalty for store-store or store-load
457 (define_insn_reservation "Y10" 2
458 (and (eq_attr "type" "store")
459 (eq_attr "cpu" "7300"))
460 "i1_7100lc")
461
462 (define_insn_reservation "Y11" 2
463 (and (eq_attr "type" "fpstore")
464 (eq_attr "cpu" "7300"))
465 "i1_7100lc")
466
467 ;; We have an "anti-bypass" for FP loads which feed an FP store.
468 (define_bypass 3 "Y3" "Y5,Y9,Y11" "hppa_fpstore_bypass_p")
469
470 ;; Scheduling for the PA8000 is somewhat different than scheduling for a
471 ;; traditional architecture.
472 ;;
473 ;; The PA8000 has a large (56) entry reorder buffer that is split between
474 ;; memory and non-memory operations.
475 ;;
476 ;; The PA8000 can issue two memory and two non-memory operations per cycle to
477 ;; the function units, with the exception of branches and multi-output
478 ;; instructions. The PA8000 can retire two non-memory operations per cycle
479 ;; and two memory operations per cycle, only one of which may be a store.
480 ;;
481 ;; Given the large reorder buffer, the processor can hide most latencies.
482 ;; According to HP, they've got the best results by scheduling for retirement
483 ;; bandwidth with limited latency scheduling for floating point operations.
484 ;; Latency for integer operations and memory references is ignored.
485 ;;
486 ;;
487 ;; We claim floating point operations have a 2 cycle latency and are
488 ;; fully pipelined, except for div and sqrt which are not pipelined and
489 ;; take from 17 to 31 cycles to complete.
490 ;;
491 ;; It's worth noting that there is no way to saturate all the functional
492 ;; units on the PA8000 as there is not enough issue bandwidth.
493
494 (define_automaton "pa8000")
495 (define_cpu_unit "inm0_8000, inm1_8000, im0_8000, im1_8000" "pa8000")
496 (define_cpu_unit "rnm0_8000, rnm1_8000, rm0_8000, rm1_8000" "pa8000")
497 (define_cpu_unit "store_8000" "pa8000")
498 (define_cpu_unit "f0_8000, f1_8000" "pa8000")
499 (define_cpu_unit "fdivsqrt0_8000, fdivsqrt1_8000" "pa8000")
500 (define_reservation "inm_8000" "inm0_8000 | inm1_8000")
501 (define_reservation "im_8000" "im0_8000 | im1_8000")
502 (define_reservation "rnm_8000" "rnm0_8000 | rnm1_8000")
503 (define_reservation "rm_8000" "rm0_8000 | rm1_8000")
504 (define_reservation "f_8000" "f0_8000 | f1_8000")
505 (define_reservation "fdivsqrt_8000" "fdivsqrt0_8000 | fdivsqrt1_8000")
506
507 ;; We can issue any two memops per cycle, but we can only retire
508 ;; one memory store per cycle. We assume that the reorder buffer
509 ;; will hide any memory latencies per HP's recommendation.
510 (define_insn_reservation "Z0" 0
511 (and
512 (eq_attr "type" "load,fpload")
513 (eq_attr "cpu" "8000"))
514 "im_8000,rm_8000")
515
516 (define_insn_reservation "Z1" 0
517 (and
518 (eq_attr "type" "store,fpstore")
519 (eq_attr "cpu" "8000"))
520 "im_8000,rm_8000+store_8000")
521
522 ;; We can issue and retire two non-memory operations per cycle with
523 ;; a few exceptions (branches). This group catches those we want
524 ;; to assume have zero latency.
525 (define_insn_reservation "Z2" 0
526 (and
527 (eq_attr "type" "!load,fpload,store,fpstore,uncond_branch,btable_branch,branch,cbranch,fbranch,call,dyncall,multi,milli,parallel_branch,fpcc,fpalu,fpmulsgl,fpmuldbl,fpsqrtsgl,fpsqrtdbl,fpdivsgl,fpdivdbl")
528 (eq_attr "cpu" "8000"))
529 "inm_8000,rnm_8000")
530
531 ;; Branches use both slots in the non-memory issue and
532 ;; retirement unit.
533 (define_insn_reservation "Z3" 0
534 (and
535 (eq_attr "type" "uncond_branch,btable_branch,branch,cbranch,fbranch,call,dyncall,multi,milli,parallel_branch")
536 (eq_attr "cpu" "8000"))
537 "inm0_8000+inm1_8000,rnm0_8000+rnm1_8000")
538
539 ;; We partial latency schedule the floating point units.
540 ;; They can issue/retire two at a time in the non-memory
541 ;; units. We fix their latency at 2 cycles and they
542 ;; are fully pipelined.
543 (define_insn_reservation "Z4" 1
544 (and
545 (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
546 (eq_attr "cpu" "8000"))
547 "inm_8000,f_8000,rnm_8000")
548
549 ;; The fdivsqrt units are not pipelined and have a very long latency.
550 ;; To keep the DFA from exploding, we do not show all the
551 ;; reservations for the divsqrt unit.
552 (define_insn_reservation "Z5" 17
553 (and
554 (eq_attr "type" "fpdivsgl,fpsqrtsgl")
555 (eq_attr "cpu" "8000"))
556 "inm_8000,fdivsqrt_8000*6,rnm_8000")
557
558 (define_insn_reservation "Z6" 31
559 (and
560 (eq_attr "type" "fpdivdbl,fpsqrtdbl")
561 (eq_attr "cpu" "8000"))
562 "inm_8000,fdivsqrt_8000*6,rnm_8000")
563
564
565 \f
566 ;; Compare instructions.
567 ;; This controls RTL generation and register allocation.
568
569 ;; We generate RTL for comparisons and branches by having the cmpxx
570 ;; patterns store away the operands. Then, the scc and bcc patterns
571 ;; emit RTL for both the compare and the branch.
572 ;;
573
574 (define_expand "cmpdi"
575 [(set (reg:CC 0)
576 (compare:CC (match_operand:DI 0 "reg_or_0_operand" "")
577 (match_operand:DI 1 "register_operand" "")))]
578 "TARGET_64BIT"
579
580 "
581 {
582 hppa_compare_op0 = operands[0];
583 hppa_compare_op1 = operands[1];
584 hppa_branch_type = CMP_SI;
585 DONE;
586 }")
587
588 (define_expand "cmpsi"
589 [(set (reg:CC 0)
590 (compare:CC (match_operand:SI 0 "reg_or_0_operand" "")
591 (match_operand:SI 1 "arith5_operand" "")))]
592 ""
593 "
594 {
595 hppa_compare_op0 = operands[0];
596 hppa_compare_op1 = operands[1];
597 hppa_branch_type = CMP_SI;
598 DONE;
599 }")
600
601 (define_expand "cmpsf"
602 [(set (reg:CCFP 0)
603 (compare:CCFP (match_operand:SF 0 "reg_or_0_operand" "")
604 (match_operand:SF 1 "reg_or_0_operand" "")))]
605 "! TARGET_SOFT_FLOAT"
606 "
607 {
608 hppa_compare_op0 = operands[0];
609 hppa_compare_op1 = operands[1];
610 hppa_branch_type = CMP_SF;
611 DONE;
612 }")
613
614 (define_expand "cmpdf"
615 [(set (reg:CCFP 0)
616 (compare:CCFP (match_operand:DF 0 "reg_or_0_operand" "")
617 (match_operand:DF 1 "reg_or_0_operand" "")))]
618 "! TARGET_SOFT_FLOAT"
619 "
620 {
621 hppa_compare_op0 = operands[0];
622 hppa_compare_op1 = operands[1];
623 hppa_branch_type = CMP_DF;
624 DONE;
625 }")
626
627 (define_insn ""
628 [(set (reg:CCFP 0)
629 (match_operator:CCFP 2 "comparison_operator"
630 [(match_operand:SF 0 "reg_or_0_operand" "fG")
631 (match_operand:SF 1 "reg_or_0_operand" "fG")]))]
632 "! TARGET_SOFT_FLOAT"
633 "fcmp,sgl,%Y2 %f0,%f1"
634 [(set_attr "length" "4")
635 (set_attr "type" "fpcc")])
636
637 (define_insn ""
638 [(set (reg:CCFP 0)
639 (match_operator:CCFP 2 "comparison_operator"
640 [(match_operand:DF 0 "reg_or_0_operand" "fG")
641 (match_operand:DF 1 "reg_or_0_operand" "fG")]))]
642 "! TARGET_SOFT_FLOAT"
643 "fcmp,dbl,%Y2 %f0,%f1"
644 [(set_attr "length" "4")
645 (set_attr "type" "fpcc")])
646
647 ;; Provide a means to emit the movccfp0 and movccfp1 optimization
648 ;; placeholders. This is necessary in rare situations when a
649 ;; placeholder is re-emitted (see PR 8705).
650
651 (define_expand "movccfp"
652 [(set (reg:CCFP 0)
653 (match_operand 0 "const_int_operand" ""))]
654 "! TARGET_SOFT_FLOAT"
655 "
656 {
657 if ((unsigned HOST_WIDE_INT) INTVAL (operands[0]) > 1)
658 FAIL;
659 }")
660
661 ;; The following patterns are optimization placeholders. In almost
662 ;; all cases, the user of the condition code will be simplified and the
663 ;; original condition code setting insn should be eliminated.
664
665 (define_insn "*movccfp0"
666 [(set (reg:CCFP 0)
667 (const_int 0))]
668 "! TARGET_SOFT_FLOAT"
669 "fcmp,dbl,= %%fr0,%%fr0"
670 [(set_attr "length" "4")
671 (set_attr "type" "fpcc")])
672
673 (define_insn "*movccfp1"
674 [(set (reg:CCFP 0)
675 (const_int 1))]
676 "! TARGET_SOFT_FLOAT"
677 "fcmp,dbl,!= %%fr0,%%fr0"
678 [(set_attr "length" "4")
679 (set_attr "type" "fpcc")])
680
681 ;; scc insns.
682
683 (define_expand "seq"
684 [(set (match_operand:SI 0 "register_operand" "")
685 (eq:SI (match_dup 1)
686 (match_dup 2)))]
687 "!TARGET_64BIT"
688 "
689 {
690 /* fp scc patterns rarely match, and are not a win on the PA. */
691 if (hppa_branch_type != CMP_SI)
692 FAIL;
693 /* set up operands from compare. */
694 operands[1] = hppa_compare_op0;
695 operands[2] = hppa_compare_op1;
696 /* fall through and generate default code */
697 }")
698
699 (define_expand "sne"
700 [(set (match_operand:SI 0 "register_operand" "")
701 (ne:SI (match_dup 1)
702 (match_dup 2)))]
703 "!TARGET_64BIT"
704 "
705 {
706 /* fp scc patterns rarely match, and are not a win on the PA. */
707 if (hppa_branch_type != CMP_SI)
708 FAIL;
709 operands[1] = hppa_compare_op0;
710 operands[2] = hppa_compare_op1;
711 }")
712
713 (define_expand "slt"
714 [(set (match_operand:SI 0 "register_operand" "")
715 (lt:SI (match_dup 1)
716 (match_dup 2)))]
717 "!TARGET_64BIT"
718 "
719 {
720 /* fp scc patterns rarely match, and are not a win on the PA. */
721 if (hppa_branch_type != CMP_SI)
722 FAIL;
723 operands[1] = hppa_compare_op0;
724 operands[2] = hppa_compare_op1;
725 }")
726
727 (define_expand "sgt"
728 [(set (match_operand:SI 0 "register_operand" "")
729 (gt:SI (match_dup 1)
730 (match_dup 2)))]
731 "!TARGET_64BIT"
732 "
733 {
734 /* fp scc patterns rarely match, and are not a win on the PA. */
735 if (hppa_branch_type != CMP_SI)
736 FAIL;
737 operands[1] = hppa_compare_op0;
738 operands[2] = hppa_compare_op1;
739 }")
740
741 (define_expand "sle"
742 [(set (match_operand:SI 0 "register_operand" "")
743 (le:SI (match_dup 1)
744 (match_dup 2)))]
745 "!TARGET_64BIT"
746 "
747 {
748 /* fp scc patterns rarely match, and are not a win on the PA. */
749 if (hppa_branch_type != CMP_SI)
750 FAIL;
751 operands[1] = hppa_compare_op0;
752 operands[2] = hppa_compare_op1;
753 }")
754
755 (define_expand "sge"
756 [(set (match_operand:SI 0 "register_operand" "")
757 (ge:SI (match_dup 1)
758 (match_dup 2)))]
759 "!TARGET_64BIT"
760 "
761 {
762 /* fp scc patterns rarely match, and are not a win on the PA. */
763 if (hppa_branch_type != CMP_SI)
764 FAIL;
765 operands[1] = hppa_compare_op0;
766 operands[2] = hppa_compare_op1;
767 }")
768
769 (define_expand "sltu"
770 [(set (match_operand:SI 0 "register_operand" "")
771 (ltu:SI (match_dup 1)
772 (match_dup 2)))]
773 "!TARGET_64BIT"
774 "
775 {
776 if (hppa_branch_type != CMP_SI)
777 FAIL;
778 operands[1] = hppa_compare_op0;
779 operands[2] = hppa_compare_op1;
780 }")
781
782 (define_expand "sgtu"
783 [(set (match_operand:SI 0 "register_operand" "")
784 (gtu:SI (match_dup 1)
785 (match_dup 2)))]
786 "!TARGET_64BIT"
787 "
788 {
789 if (hppa_branch_type != CMP_SI)
790 FAIL;
791 operands[1] = hppa_compare_op0;
792 operands[2] = hppa_compare_op1;
793 }")
794
795 (define_expand "sleu"
796 [(set (match_operand:SI 0 "register_operand" "")
797 (leu:SI (match_dup 1)
798 (match_dup 2)))]
799 "!TARGET_64BIT"
800 "
801 {
802 if (hppa_branch_type != CMP_SI)
803 FAIL;
804 operands[1] = hppa_compare_op0;
805 operands[2] = hppa_compare_op1;
806 }")
807
808 (define_expand "sgeu"
809 [(set (match_operand:SI 0 "register_operand" "")
810 (geu:SI (match_dup 1)
811 (match_dup 2)))]
812 "!TARGET_64BIT"
813 "
814 {
815 if (hppa_branch_type != CMP_SI)
816 FAIL;
817 operands[1] = hppa_compare_op0;
818 operands[2] = hppa_compare_op1;
819 }")
820
821 ;; Instruction canonicalization puts immediate operands second, which
822 ;; is the reverse of what we want.
823
824 (define_insn "scc"
825 [(set (match_operand:SI 0 "register_operand" "=r")
826 (match_operator:SI 3 "comparison_operator"
827 [(match_operand:SI 1 "register_operand" "r")
828 (match_operand:SI 2 "arith11_operand" "rI")]))]
829 ""
830 "{com%I2clr|cmp%I2clr},%B3 %2,%1,%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 (match_operator:DI 3 "comparison_operator"
837 [(match_operand:DI 1 "register_operand" "r")
838 (match_operand:DI 2 "arith11_operand" "rI")]))]
839 "TARGET_64BIT"
840 "cmp%I2clr,*%B3 %2,%1,%0\;ldi 1,%0"
841 [(set_attr "type" "binary")
842 (set_attr "length" "8")])
843
844 (define_insn "iorscc"
845 [(set (match_operand:SI 0 "register_operand" "=r")
846 (ior:SI (match_operator:SI 3 "comparison_operator"
847 [(match_operand:SI 1 "register_operand" "r")
848 (match_operand:SI 2 "arith11_operand" "rI")])
849 (match_operator:SI 6 "comparison_operator"
850 [(match_operand:SI 4 "register_operand" "r")
851 (match_operand:SI 5 "arith11_operand" "rI")])))]
852 ""
853 "{com%I2clr|cmp%I2clr},%S3 %2,%1,%%r0\;{com%I5clr|cmp%I5clr},%B6 %5,%4,%0\;ldi 1,%0"
854 [(set_attr "type" "binary")
855 (set_attr "length" "12")])
856
857 (define_insn ""
858 [(set (match_operand:DI 0 "register_operand" "=r")
859 (ior:DI (match_operator:DI 3 "comparison_operator"
860 [(match_operand:DI 1 "register_operand" "r")
861 (match_operand:DI 2 "arith11_operand" "rI")])
862 (match_operator:DI 6 "comparison_operator"
863 [(match_operand:DI 4 "register_operand" "r")
864 (match_operand:DI 5 "arith11_operand" "rI")])))]
865 "TARGET_64BIT"
866 "cmp%I2clr,*%S3 %2,%1,%%r0\;cmp%I5clr,*%B6 %5,%4,%0\;ldi 1,%0"
867 [(set_attr "type" "binary")
868 (set_attr "length" "12")])
869
870 ;; Combiner patterns for common operations performed with the output
871 ;; from an scc insn (negscc and incscc).
872 (define_insn "negscc"
873 [(set (match_operand:SI 0 "register_operand" "=r")
874 (neg:SI (match_operator:SI 3 "comparison_operator"
875 [(match_operand:SI 1 "register_operand" "r")
876 (match_operand:SI 2 "arith11_operand" "rI")])))]
877 ""
878 "{com%I2clr|cmp%I2clr},%B3 %2,%1,%0\;ldi -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 (neg:DI (match_operator:DI 3 "comparison_operator"
885 [(match_operand:DI 1 "register_operand" "r")
886 (match_operand:DI 2 "arith11_operand" "rI")])))]
887 "TARGET_64BIT"
888 "cmp%I2clr,*%B3 %2,%1,%0\;ldi -1,%0"
889 [(set_attr "type" "binary")
890 (set_attr "length" "8")])
891
892 ;; Patterns for adding/subtracting the result of a boolean expression from
893 ;; a register. First we have special patterns that make use of the carry
894 ;; bit, and output only two instructions. For the cases we can't in
895 ;; general do in two instructions, the incscc pattern at the end outputs
896 ;; two or three instructions.
897
898 (define_insn ""
899 [(set (match_operand:SI 0 "register_operand" "=r")
900 (plus:SI (leu:SI (match_operand:SI 2 "register_operand" "r")
901 (match_operand:SI 3 "arith11_operand" "rI"))
902 (match_operand:SI 1 "register_operand" "r")))]
903 ""
904 "sub%I3 %3,%2,%%r0\;{addc|add,c} %%r0,%1,%0"
905 [(set_attr "type" "binary")
906 (set_attr "length" "8")])
907
908 (define_insn ""
909 [(set (match_operand:DI 0 "register_operand" "=r")
910 (plus:DI (leu:DI (match_operand:DI 2 "register_operand" "r")
911 (match_operand:DI 3 "arith11_operand" "rI"))
912 (match_operand:DI 1 "register_operand" "r")))]
913 "TARGET_64BIT"
914 "sub%I3 %3,%2,%%r0\;add,dc %%r0,%1,%0"
915 [(set_attr "type" "binary")
916 (set_attr "length" "8")])
917
918 ; This need only accept registers for op3, since canonicalization
919 ; replaces geu with gtu when op3 is an integer.
920 (define_insn ""
921 [(set (match_operand:SI 0 "register_operand" "=r")
922 (plus:SI (geu:SI (match_operand:SI 2 "register_operand" "r")
923 (match_operand:SI 3 "register_operand" "r"))
924 (match_operand:SI 1 "register_operand" "r")))]
925 ""
926 "sub %2,%3,%%r0\;{addc|add,c} %%r0,%1,%0"
927 [(set_attr "type" "binary")
928 (set_attr "length" "8")])
929
930 (define_insn ""
931 [(set (match_operand:DI 0 "register_operand" "=r")
932 (plus:DI (geu:DI (match_operand:DI 2 "register_operand" "r")
933 (match_operand:DI 3 "register_operand" "r"))
934 (match_operand:DI 1 "register_operand" "r")))]
935 "TARGET_64BIT"
936 "sub %2,%3,%%r0\;add,dc %%r0,%1,%0"
937 [(set_attr "type" "binary")
938 (set_attr "length" "8")])
939
940 ; Match only integers for op3 here. This is used as canonical form of the
941 ; geu pattern when op3 is an integer. Don't match registers since we can't
942 ; make better code than the general incscc pattern.
943 (define_insn ""
944 [(set (match_operand:SI 0 "register_operand" "=r")
945 (plus:SI (gtu:SI (match_operand:SI 2 "register_operand" "r")
946 (match_operand:SI 3 "int11_operand" "I"))
947 (match_operand:SI 1 "register_operand" "r")))]
948 ""
949 "addi %k3,%2,%%r0\;{addc|add,c} %%r0,%1,%0"
950 [(set_attr "type" "binary")
951 (set_attr "length" "8")])
952
953 (define_insn ""
954 [(set (match_operand:DI 0 "register_operand" "=r")
955 (plus:DI (gtu:DI (match_operand:DI 2 "register_operand" "r")
956 (match_operand:DI 3 "int11_operand" "I"))
957 (match_operand:DI 1 "register_operand" "r")))]
958 "TARGET_64BIT"
959 "addi %k3,%2,%%r0\;add,dc %%r0,%1,%0"
960 [(set_attr "type" "binary")
961 (set_attr "length" "8")])
962
963 (define_insn "incscc"
964 [(set (match_operand:SI 0 "register_operand" "=r,r")
965 (plus:SI (match_operator:SI 4 "comparison_operator"
966 [(match_operand:SI 2 "register_operand" "r,r")
967 (match_operand:SI 3 "arith11_operand" "rI,rI")])
968 (match_operand:SI 1 "register_operand" "0,?r")))]
969 ""
970 "@
971 {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi 1,%0,%0
972 {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi,tr 1,%1,%0\;copy %1,%0"
973 [(set_attr "type" "binary,binary")
974 (set_attr "length" "8,12")])
975
976 (define_insn ""
977 [(set (match_operand:DI 0 "register_operand" "=r,r")
978 (plus:DI (match_operator:DI 4 "comparison_operator"
979 [(match_operand:DI 2 "register_operand" "r,r")
980 (match_operand:DI 3 "arith11_operand" "rI,rI")])
981 (match_operand:DI 1 "register_operand" "0,?r")))]
982 "TARGET_64BIT"
983 "@
984 cmp%I3clr,*%B4 %3,%2,%%r0\;addi 1,%0,%0
985 cmp%I3clr,*%B4 %3,%2,%%r0\;addi,tr 1,%1,%0\;copy %1,%0"
986 [(set_attr "type" "binary,binary")
987 (set_attr "length" "8,12")])
988
989 (define_insn ""
990 [(set (match_operand:SI 0 "register_operand" "=r")
991 (minus:SI (match_operand:SI 1 "register_operand" "r")
992 (gtu:SI (match_operand:SI 2 "register_operand" "r")
993 (match_operand:SI 3 "arith11_operand" "rI"))))]
994 ""
995 "sub%I3 %3,%2,%%r0\;{subb|sub,b} %1,%%r0,%0"
996 [(set_attr "type" "binary")
997 (set_attr "length" "8")])
998
999 (define_insn ""
1000 [(set (match_operand:DI 0 "register_operand" "=r")
1001 (minus:DI (match_operand:DI 1 "register_operand" "r")
1002 (gtu:DI (match_operand:DI 2 "register_operand" "r")
1003 (match_operand:DI 3 "arith11_operand" "rI"))))]
1004 "TARGET_64BIT"
1005 "sub%I3 %3,%2,%%r0\;sub,db %1,%%r0,%0"
1006 [(set_attr "type" "binary")
1007 (set_attr "length" "8")])
1008
1009 (define_insn ""
1010 [(set (match_operand:SI 0 "register_operand" "=r")
1011 (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
1012 (gtu:SI (match_operand:SI 2 "register_operand" "r")
1013 (match_operand:SI 3 "arith11_operand" "rI")))
1014 (match_operand:SI 4 "register_operand" "r")))]
1015 ""
1016 "sub%I3 %3,%2,%%r0\;{subb|sub,b} %1,%4,%0"
1017 [(set_attr "type" "binary")
1018 (set_attr "length" "8")])
1019
1020 (define_insn ""
1021 [(set (match_operand:DI 0 "register_operand" "=r")
1022 (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
1023 (gtu:DI (match_operand:DI 2 "register_operand" "r")
1024 (match_operand:DI 3 "arith11_operand" "rI")))
1025 (match_operand:DI 4 "register_operand" "r")))]
1026 "TARGET_64BIT"
1027 "sub%I3 %3,%2,%%r0\;sub,db %1,%4,%0"
1028 [(set_attr "type" "binary")
1029 (set_attr "length" "8")])
1030
1031 ; This need only accept registers for op3, since canonicalization
1032 ; replaces ltu with leu when op3 is an integer.
1033 (define_insn ""
1034 [(set (match_operand:SI 0 "register_operand" "=r")
1035 (minus:SI (match_operand:SI 1 "register_operand" "r")
1036 (ltu:SI (match_operand:SI 2 "register_operand" "r")
1037 (match_operand:SI 3 "register_operand" "r"))))]
1038 ""
1039 "sub %2,%3,%%r0\;{subb|sub,b} %1,%%r0,%0"
1040 [(set_attr "type" "binary")
1041 (set_attr "length" "8")])
1042
1043 (define_insn ""
1044 [(set (match_operand:DI 0 "register_operand" "=r")
1045 (minus:DI (match_operand:DI 1 "register_operand" "r")
1046 (ltu:DI (match_operand:DI 2 "register_operand" "r")
1047 (match_operand:DI 3 "register_operand" "r"))))]
1048 "TARGET_64BIT"
1049 "sub %2,%3,%%r0\;sub,db %1,%%r0,%0"
1050 [(set_attr "type" "binary")
1051 (set_attr "length" "8")])
1052
1053 (define_insn ""
1054 [(set (match_operand:SI 0 "register_operand" "=r")
1055 (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
1056 (ltu:SI (match_operand:SI 2 "register_operand" "r")
1057 (match_operand:SI 3 "register_operand" "r")))
1058 (match_operand:SI 4 "register_operand" "r")))]
1059 ""
1060 "sub %2,%3,%%r0\;{subb|sub,b} %1,%4,%0"
1061 [(set_attr "type" "binary")
1062 (set_attr "length" "8")])
1063
1064 (define_insn ""
1065 [(set (match_operand:DI 0 "register_operand" "=r")
1066 (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
1067 (ltu:DI (match_operand:DI 2 "register_operand" "r")
1068 (match_operand:DI 3 "register_operand" "r")))
1069 (match_operand:DI 4 "register_operand" "r")))]
1070 "TARGET_64BIT"
1071 "sub %2,%3,%%r0\;sub,db %1,%4,%0"
1072 [(set_attr "type" "binary")
1073 (set_attr "length" "8")])
1074
1075 ; Match only integers for op3 here. This is used as canonical form of the
1076 ; ltu pattern when op3 is an integer. Don't match registers since we can't
1077 ; make better code than the general incscc pattern.
1078 (define_insn ""
1079 [(set (match_operand:SI 0 "register_operand" "=r")
1080 (minus:SI (match_operand:SI 1 "register_operand" "r")
1081 (leu:SI (match_operand:SI 2 "register_operand" "r")
1082 (match_operand:SI 3 "int11_operand" "I"))))]
1083 ""
1084 "addi %k3,%2,%%r0\;{subb|sub,b} %1,%%r0,%0"
1085 [(set_attr "type" "binary")
1086 (set_attr "length" "8")])
1087
1088 (define_insn ""
1089 [(set (match_operand:DI 0 "register_operand" "=r")
1090 (minus:DI (match_operand:DI 1 "register_operand" "r")
1091 (leu:DI (match_operand:DI 2 "register_operand" "r")
1092 (match_operand:DI 3 "int11_operand" "I"))))]
1093 "TARGET_64BIT"
1094 "addi %k3,%2,%%r0\;sub,db %1,%%r0,%0"
1095 [(set_attr "type" "binary")
1096 (set_attr "length" "8")])
1097
1098 (define_insn ""
1099 [(set (match_operand:SI 0 "register_operand" "=r")
1100 (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
1101 (leu:SI (match_operand:SI 2 "register_operand" "r")
1102 (match_operand:SI 3 "int11_operand" "I")))
1103 (match_operand:SI 4 "register_operand" "r")))]
1104 ""
1105 "addi %k3,%2,%%r0\;{subb|sub,b} %1,%4,%0"
1106 [(set_attr "type" "binary")
1107 (set_attr "length" "8")])
1108
1109 (define_insn ""
1110 [(set (match_operand:DI 0 "register_operand" "=r")
1111 (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
1112 (leu:DI (match_operand:DI 2 "register_operand" "r")
1113 (match_operand:DI 3 "int11_operand" "I")))
1114 (match_operand:DI 4 "register_operand" "r")))]
1115 "TARGET_64BIT"
1116 "addi %k3,%2,%%r0\;sub,db %1,%4,%0"
1117 [(set_attr "type" "binary")
1118 (set_attr "length" "8")])
1119
1120 (define_insn "decscc"
1121 [(set (match_operand:SI 0 "register_operand" "=r,r")
1122 (minus:SI (match_operand:SI 1 "register_operand" "0,?r")
1123 (match_operator:SI 4 "comparison_operator"
1124 [(match_operand:SI 2 "register_operand" "r,r")
1125 (match_operand:SI 3 "arith11_operand" "rI,rI")])))]
1126 ""
1127 "@
1128 {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi -1,%0,%0
1129 {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi,tr -1,%1,%0\;copy %1,%0"
1130 [(set_attr "type" "binary,binary")
1131 (set_attr "length" "8,12")])
1132
1133 (define_insn ""
1134 [(set (match_operand:DI 0 "register_operand" "=r,r")
1135 (minus:DI (match_operand:DI 1 "register_operand" "0,?r")
1136 (match_operator:DI 4 "comparison_operator"
1137 [(match_operand:DI 2 "register_operand" "r,r")
1138 (match_operand:DI 3 "arith11_operand" "rI,rI")])))]
1139 "TARGET_64BIT"
1140 "@
1141 cmp%I3clr,*%B4 %3,%2,%%r0\;addi -1,%0,%0
1142 cmp%I3clr,*%B4 %3,%2,%%r0\;addi,tr -1,%1,%0\;copy %1,%0"
1143 [(set_attr "type" "binary,binary")
1144 (set_attr "length" "8,12")])
1145
1146 ; Patterns for max and min. (There is no need for an earlyclobber in the
1147 ; last alternative since the middle alternative will match if op0 == op1.)
1148
1149 (define_insn "sminsi3"
1150 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1151 (smin:SI (match_operand:SI 1 "register_operand" "%0,0,r")
1152 (match_operand:SI 2 "arith11_operand" "r,I,M")))]
1153 ""
1154 "@
1155 {comclr|cmpclr},> %2,%0,%%r0\;copy %2,%0
1156 {comiclr|cmpiclr},> %2,%0,%%r0\;ldi %2,%0
1157 {comclr|cmpclr},> %1,%r2,%0\;copy %1,%0"
1158 [(set_attr "type" "multi,multi,multi")
1159 (set_attr "length" "8,8,8")])
1160
1161 (define_insn "smindi3"
1162 [(set (match_operand:DI 0 "register_operand" "=r,r,r")
1163 (smin:DI (match_operand:DI 1 "register_operand" "%0,0,r")
1164 (match_operand:DI 2 "arith11_operand" "r,I,M")))]
1165 "TARGET_64BIT"
1166 "@
1167 cmpclr,*> %2,%0,%%r0\;copy %2,%0
1168 cmpiclr,*> %2,%0,%%r0\;ldi %2,%0
1169 cmpclr,*> %1,%r2,%0\;copy %1,%0"
1170 [(set_attr "type" "multi,multi,multi")
1171 (set_attr "length" "8,8,8")])
1172
1173 (define_insn "uminsi3"
1174 [(set (match_operand:SI 0 "register_operand" "=r,r")
1175 (umin:SI (match_operand:SI 1 "register_operand" "%0,0")
1176 (match_operand:SI 2 "arith11_operand" "r,I")))]
1177 ""
1178 "@
1179 {comclr|cmpclr},>> %2,%0,%%r0\;copy %2,%0
1180 {comiclr|cmpiclr},>> %2,%0,%%r0\;ldi %2,%0"
1181 [(set_attr "type" "multi,multi")
1182 (set_attr "length" "8,8")])
1183
1184 (define_insn "umindi3"
1185 [(set (match_operand:DI 0 "register_operand" "=r,r")
1186 (umin:DI (match_operand:DI 1 "register_operand" "%0,0")
1187 (match_operand:DI 2 "arith11_operand" "r,I")))]
1188 "TARGET_64BIT"
1189 "@
1190 cmpclr,*>> %2,%0,%%r0\;copy %2,%0
1191 cmpiclr,*>> %2,%0,%%r0\;ldi %2,%0"
1192 [(set_attr "type" "multi,multi")
1193 (set_attr "length" "8,8")])
1194
1195 (define_insn "smaxsi3"
1196 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1197 (smax:SI (match_operand:SI 1 "register_operand" "%0,0,r")
1198 (match_operand:SI 2 "arith11_operand" "r,I,M")))]
1199 ""
1200 "@
1201 {comclr|cmpclr},< %2,%0,%%r0\;copy %2,%0
1202 {comiclr|cmpiclr},< %2,%0,%%r0\;ldi %2,%0
1203 {comclr|cmpclr},< %1,%r2,%0\;copy %1,%0"
1204 [(set_attr "type" "multi,multi,multi")
1205 (set_attr "length" "8,8,8")])
1206
1207 (define_insn "smaxdi3"
1208 [(set (match_operand:DI 0 "register_operand" "=r,r,r")
1209 (smax:DI (match_operand:DI 1 "register_operand" "%0,0,r")
1210 (match_operand:DI 2 "arith11_operand" "r,I,M")))]
1211 "TARGET_64BIT"
1212 "@
1213 cmpclr,*< %2,%0,%%r0\;copy %2,%0
1214 cmpiclr,*< %2,%0,%%r0\;ldi %2,%0
1215 cmpclr,*< %1,%r2,%0\;copy %1,%0"
1216 [(set_attr "type" "multi,multi,multi")
1217 (set_attr "length" "8,8,8")])
1218
1219 (define_insn "umaxsi3"
1220 [(set (match_operand:SI 0 "register_operand" "=r,r")
1221 (umax:SI (match_operand:SI 1 "register_operand" "%0,0")
1222 (match_operand:SI 2 "arith11_operand" "r,I")))]
1223 ""
1224 "@
1225 {comclr|cmpclr},<< %2,%0,%%r0\;copy %2,%0
1226 {comiclr|cmpiclr},<< %2,%0,%%r0\;ldi %2,%0"
1227 [(set_attr "type" "multi,multi")
1228 (set_attr "length" "8,8")])
1229
1230 (define_insn "umaxdi3"
1231 [(set (match_operand:DI 0 "register_operand" "=r,r")
1232 (umax:DI (match_operand:DI 1 "register_operand" "%0,0")
1233 (match_operand:DI 2 "arith11_operand" "r,I")))]
1234 "TARGET_64BIT"
1235 "@
1236 cmpclr,*<< %2,%0,%%r0\;copy %2,%0
1237 cmpiclr,*<< %2,%0,%%r0\;ldi %2,%0"
1238 [(set_attr "type" "multi,multi")
1239 (set_attr "length" "8,8")])
1240
1241 (define_insn "abssi2"
1242 [(set (match_operand:SI 0 "register_operand" "=r")
1243 (abs:SI (match_operand:SI 1 "register_operand" "r")))]
1244 ""
1245 "or,>= %%r0,%1,%0\;subi 0,%0,%0"
1246 [(set_attr "type" "multi")
1247 (set_attr "length" "8")])
1248
1249 (define_insn "absdi2"
1250 [(set (match_operand:DI 0 "register_operand" "=r")
1251 (abs:DI (match_operand:DI 1 "register_operand" "r")))]
1252 "TARGET_64BIT"
1253 "or,*>= %%r0,%1,%0\;subi 0,%0,%0"
1254 [(set_attr "type" "multi")
1255 (set_attr "length" "8")])
1256
1257 ;;; Experimental conditional move patterns
1258
1259 (define_expand "movsicc"
1260 [(set (match_operand:SI 0 "register_operand" "")
1261 (if_then_else:SI
1262 (match_operator 1 "comparison_operator"
1263 [(match_dup 4)
1264 (match_dup 5)])
1265 (match_operand:SI 2 "reg_or_cint_move_operand" "")
1266 (match_operand:SI 3 "reg_or_cint_move_operand" "")))]
1267 ""
1268 "
1269 {
1270 enum rtx_code code = GET_CODE (operands[1]);
1271
1272 if (hppa_branch_type != CMP_SI)
1273 FAIL;
1274
1275 if (GET_MODE (hppa_compare_op0) != GET_MODE (hppa_compare_op1)
1276 || GET_MODE (hppa_compare_op0) != GET_MODE (operands[0]))
1277 FAIL;
1278
1279 /* operands[1] is currently the result of compare_from_rtx. We want to
1280 emit a compare of the original operands. */
1281 operands[1] = gen_rtx_fmt_ee (code, SImode, hppa_compare_op0, hppa_compare_op1);
1282 operands[4] = hppa_compare_op0;
1283 operands[5] = hppa_compare_op1;
1284 }")
1285
1286 ;; We used to accept any register for op1.
1287 ;;
1288 ;; However, it loses sometimes because the compiler will end up using
1289 ;; different registers for op0 and op1 in some critical cases. local-alloc
1290 ;; will not tie op0 and op1 because op0 is used in multiple basic blocks.
1291 ;;
1292 ;; If/when global register allocation supports tying we should allow any
1293 ;; register for op1 again.
1294 (define_insn ""
1295 [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
1296 (if_then_else:SI
1297 (match_operator 2 "comparison_operator"
1298 [(match_operand:SI 3 "register_operand" "r,r,r,r")
1299 (match_operand:SI 4 "arith11_operand" "rI,rI,rI,rI")])
1300 (match_operand:SI 1 "reg_or_cint_move_operand" "0,J,N,K")
1301 (const_int 0)))]
1302 ""
1303 "@
1304 {com%I4clr|cmp%I4clr},%S2 %4,%3,%%r0\;ldi 0,%0
1305 {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;ldi %1,%0
1306 {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;ldil L'%1,%0
1307 {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;{zdepi|depwi,z} %Z1,%0"
1308 [(set_attr "type" "multi,multi,multi,nullshift")
1309 (set_attr "length" "8,8,8,8")])
1310
1311 (define_insn ""
1312 [(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r,r,r")
1313 (if_then_else:SI
1314 (match_operator 5 "comparison_operator"
1315 [(match_operand:SI 3 "register_operand" "r,r,r,r,r,r,r,r")
1316 (match_operand:SI 4 "arith11_operand" "rI,rI,rI,rI,rI,rI,rI,rI")])
1317 (match_operand:SI 1 "reg_or_cint_move_operand" "0,0,0,0,r,J,N,K")
1318 (match_operand:SI 2 "reg_or_cint_move_operand" "r,J,N,K,0,0,0,0")))]
1319 ""
1320 "@
1321 {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;copy %2,%0
1322 {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;ldi %2,%0
1323 {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;ldil L'%2,%0
1324 {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;{zdepi|depwi,z} %Z2,%0
1325 {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;copy %1,%0
1326 {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;ldi %1,%0
1327 {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;ldil L'%1,%0
1328 {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;{zdepi|depwi,z} %Z1,%0"
1329 [(set_attr "type" "multi,multi,multi,nullshift,multi,multi,multi,nullshift")
1330 (set_attr "length" "8,8,8,8,8,8,8,8")])
1331
1332 (define_expand "movdicc"
1333 [(set (match_operand:DI 0 "register_operand" "")
1334 (if_then_else:DI
1335 (match_operator 1 "comparison_operator"
1336 [(match_dup 4)
1337 (match_dup 5)])
1338 (match_operand:DI 2 "reg_or_cint_move_operand" "")
1339 (match_operand:DI 3 "reg_or_cint_move_operand" "")))]
1340 "TARGET_64BIT"
1341 "
1342 {
1343 enum rtx_code code = GET_CODE (operands[1]);
1344
1345 if (hppa_branch_type != CMP_SI)
1346 FAIL;
1347
1348 if (GET_MODE (hppa_compare_op0) != GET_MODE (hppa_compare_op1)
1349 || GET_MODE (hppa_compare_op0) != GET_MODE (operands[0]))
1350 FAIL;
1351
1352 /* operands[1] is currently the result of compare_from_rtx. We want to
1353 emit a compare of the original operands. */
1354 operands[1] = gen_rtx_fmt_ee (code, DImode, hppa_compare_op0, hppa_compare_op1);
1355 operands[4] = hppa_compare_op0;
1356 operands[5] = hppa_compare_op1;
1357 }")
1358
1359 ; We need the first constraint alternative in order to avoid
1360 ; earlyclobbers on all other alternatives.
1361 (define_insn ""
1362 [(set (match_operand:DI 0 "register_operand" "=r,r,r,r,r")
1363 (if_then_else:DI
1364 (match_operator 2 "comparison_operator"
1365 [(match_operand:DI 3 "register_operand" "r,r,r,r,r")
1366 (match_operand:DI 4 "arith11_operand" "rI,rI,rI,rI,rI")])
1367 (match_operand:DI 1 "reg_or_cint_move_operand" "0,r,J,N,K")
1368 (const_int 0)))]
1369 "TARGET_64BIT"
1370 "@
1371 cmp%I4clr,*%S2 %4,%3,%%r0\;ldi 0,%0
1372 cmp%I4clr,*%B2 %4,%3,%0\;copy %1,%0
1373 cmp%I4clr,*%B2 %4,%3,%0\;ldi %1,%0
1374 cmp%I4clr,*%B2 %4,%3,%0\;ldil L'%1,%0
1375 cmp%I4clr,*%B2 %4,%3,%0\;depdi,z %z1,%0"
1376 [(set_attr "type" "multi,multi,multi,multi,nullshift")
1377 (set_attr "length" "8,8,8,8,8")])
1378
1379 (define_insn ""
1380 [(set (match_operand:DI 0 "register_operand" "=r,r,r,r,r,r,r,r")
1381 (if_then_else:DI
1382 (match_operator 5 "comparison_operator"
1383 [(match_operand:DI 3 "register_operand" "r,r,r,r,r,r,r,r")
1384 (match_operand:DI 4 "arith11_operand" "rI,rI,rI,rI,rI,rI,rI,rI")])
1385 (match_operand:DI 1 "reg_or_cint_move_operand" "0,0,0,0,r,J,N,K")
1386 (match_operand:DI 2 "reg_or_cint_move_operand" "r,J,N,K,0,0,0,0")))]
1387 "TARGET_64BIT"
1388 "@
1389 cmp%I4clr,*%S5 %4,%3,%%r0\;copy %2,%0
1390 cmp%I4clr,*%S5 %4,%3,%%r0\;ldi %2,%0
1391 cmp%I4clr,*%S5 %4,%3,%%r0\;ldil L'%2,%0
1392 cmp%I4clr,*%S5 %4,%3,%%r0\;depdi,z %z2,%0
1393 cmp%I4clr,*%B5 %4,%3,%%r0\;copy %1,%0
1394 cmp%I4clr,*%B5 %4,%3,%%r0\;ldi %1,%0
1395 cmp%I4clr,*%B5 %4,%3,%%r0\;ldil L'%1,%0
1396 cmp%I4clr,*%B5 %4,%3,%%r0\;depdi,z %z1,%0"
1397 [(set_attr "type" "multi,multi,multi,nullshift,multi,multi,multi,nullshift")
1398 (set_attr "length" "8,8,8,8,8,8,8,8")])
1399
1400 ;; Conditional Branches
1401
1402 (define_expand "beq"
1403 [(set (pc)
1404 (if_then_else (eq (match_dup 1) (match_dup 2))
1405 (label_ref (match_operand 0 "" ""))
1406 (pc)))]
1407 ""
1408 "
1409 {
1410 if (hppa_branch_type != CMP_SI)
1411 {
1412 emit_insn (gen_cmp_fp (EQ, hppa_compare_op0, hppa_compare_op1));
1413 emit_bcond_fp (NE, operands[0]);
1414 DONE;
1415 }
1416 /* set up operands from compare. */
1417 operands[1] = hppa_compare_op0;
1418 operands[2] = hppa_compare_op1;
1419 /* fall through and generate default code */
1420 }")
1421
1422 (define_expand "bne"
1423 [(set (pc)
1424 (if_then_else (ne (match_dup 1) (match_dup 2))
1425 (label_ref (match_operand 0 "" ""))
1426 (pc)))]
1427 ""
1428 "
1429 {
1430 if (hppa_branch_type != CMP_SI)
1431 {
1432 emit_insn (gen_cmp_fp (NE, hppa_compare_op0, hppa_compare_op1));
1433 emit_bcond_fp (NE, operands[0]);
1434 DONE;
1435 }
1436 operands[1] = hppa_compare_op0;
1437 operands[2] = hppa_compare_op1;
1438 }")
1439
1440 (define_expand "bgt"
1441 [(set (pc)
1442 (if_then_else (gt (match_dup 1) (match_dup 2))
1443 (label_ref (match_operand 0 "" ""))
1444 (pc)))]
1445 ""
1446 "
1447 {
1448 if (hppa_branch_type != CMP_SI)
1449 {
1450 emit_insn (gen_cmp_fp (GT, hppa_compare_op0, hppa_compare_op1));
1451 emit_bcond_fp (NE, operands[0]);
1452 DONE;
1453 }
1454 operands[1] = hppa_compare_op0;
1455 operands[2] = hppa_compare_op1;
1456 }")
1457
1458 (define_expand "blt"
1459 [(set (pc)
1460 (if_then_else (lt (match_dup 1) (match_dup 2))
1461 (label_ref (match_operand 0 "" ""))
1462 (pc)))]
1463 ""
1464 "
1465 {
1466 if (hppa_branch_type != CMP_SI)
1467 {
1468 emit_insn (gen_cmp_fp (LT, hppa_compare_op0, hppa_compare_op1));
1469 emit_bcond_fp (NE, operands[0]);
1470 DONE;
1471 }
1472 operands[1] = hppa_compare_op0;
1473 operands[2] = hppa_compare_op1;
1474 }")
1475
1476 (define_expand "bge"
1477 [(set (pc)
1478 (if_then_else (ge (match_dup 1) (match_dup 2))
1479 (label_ref (match_operand 0 "" ""))
1480 (pc)))]
1481 ""
1482 "
1483 {
1484 if (hppa_branch_type != CMP_SI)
1485 {
1486 emit_insn (gen_cmp_fp (GE, hppa_compare_op0, hppa_compare_op1));
1487 emit_bcond_fp (NE, operands[0]);
1488 DONE;
1489 }
1490 operands[1] = hppa_compare_op0;
1491 operands[2] = hppa_compare_op1;
1492 }")
1493
1494 (define_expand "ble"
1495 [(set (pc)
1496 (if_then_else (le (match_dup 1) (match_dup 2))
1497 (label_ref (match_operand 0 "" ""))
1498 (pc)))]
1499 ""
1500 "
1501 {
1502 if (hppa_branch_type != CMP_SI)
1503 {
1504 emit_insn (gen_cmp_fp (LE, hppa_compare_op0, hppa_compare_op1));
1505 emit_bcond_fp (NE, operands[0]);
1506 DONE;
1507 }
1508 operands[1] = hppa_compare_op0;
1509 operands[2] = hppa_compare_op1;
1510 }")
1511
1512 (define_expand "bgtu"
1513 [(set (pc)
1514 (if_then_else (gtu (match_dup 1) (match_dup 2))
1515 (label_ref (match_operand 0 "" ""))
1516 (pc)))]
1517 ""
1518 "
1519 {
1520 if (hppa_branch_type != CMP_SI)
1521 FAIL;
1522 operands[1] = hppa_compare_op0;
1523 operands[2] = hppa_compare_op1;
1524 }")
1525
1526 (define_expand "bltu"
1527 [(set (pc)
1528 (if_then_else (ltu (match_dup 1) (match_dup 2))
1529 (label_ref (match_operand 0 "" ""))
1530 (pc)))]
1531 ""
1532 "
1533 {
1534 if (hppa_branch_type != CMP_SI)
1535 FAIL;
1536 operands[1] = hppa_compare_op0;
1537 operands[2] = hppa_compare_op1;
1538 }")
1539
1540 (define_expand "bgeu"
1541 [(set (pc)
1542 (if_then_else (geu (match_dup 1) (match_dup 2))
1543 (label_ref (match_operand 0 "" ""))
1544 (pc)))]
1545 ""
1546 "
1547 {
1548 if (hppa_branch_type != CMP_SI)
1549 FAIL;
1550 operands[1] = hppa_compare_op0;
1551 operands[2] = hppa_compare_op1;
1552 }")
1553
1554 (define_expand "bleu"
1555 [(set (pc)
1556 (if_then_else (leu (match_dup 1) (match_dup 2))
1557 (label_ref (match_operand 0 "" ""))
1558 (pc)))]
1559 ""
1560 "
1561 {
1562 if (hppa_branch_type != CMP_SI)
1563 FAIL;
1564 operands[1] = hppa_compare_op0;
1565 operands[2] = hppa_compare_op1;
1566 }")
1567
1568 (define_expand "bltgt"
1569 [(set (pc)
1570 (if_then_else (ltgt (match_dup 1) (match_dup 2))
1571 (label_ref (match_operand 0 "" ""))
1572 (pc)))]
1573 ""
1574 "
1575 {
1576 if (hppa_branch_type == CMP_SI)
1577 FAIL;
1578 emit_insn (gen_cmp_fp (LTGT, hppa_compare_op0, hppa_compare_op1));
1579 emit_bcond_fp (NE, operands[0]);
1580 DONE;
1581 }")
1582
1583 (define_expand "bunle"
1584 [(set (pc)
1585 (if_then_else (unle (match_dup 1) (match_dup 2))
1586 (label_ref (match_operand 0 "" ""))
1587 (pc)))]
1588 ""
1589 "
1590 {
1591 if (hppa_branch_type == CMP_SI)
1592 FAIL;
1593 emit_insn (gen_cmp_fp (UNLE, hppa_compare_op0, hppa_compare_op1));
1594 emit_bcond_fp (NE, operands[0]);
1595 DONE;
1596 }")
1597
1598 (define_expand "bunlt"
1599 [(set (pc)
1600 (if_then_else (unlt (match_dup 1) (match_dup 2))
1601 (label_ref (match_operand 0 "" ""))
1602 (pc)))]
1603 ""
1604 "
1605 {
1606 if (hppa_branch_type == CMP_SI)
1607 FAIL;
1608 emit_insn (gen_cmp_fp (UNLT, hppa_compare_op0, hppa_compare_op1));
1609 emit_bcond_fp (NE, operands[0]);
1610 DONE;
1611 }")
1612
1613 (define_expand "bunge"
1614 [(set (pc)
1615 (if_then_else (unge (match_dup 1) (match_dup 2))
1616 (label_ref (match_operand 0 "" ""))
1617 (pc)))]
1618 ""
1619 "
1620 {
1621 if (hppa_branch_type == CMP_SI)
1622 FAIL;
1623 emit_insn (gen_cmp_fp (UNGE, hppa_compare_op0, hppa_compare_op1));
1624 emit_bcond_fp (NE, operands[0]);
1625 DONE;
1626 }")
1627
1628 (define_expand "bungt"
1629 [(set (pc)
1630 (if_then_else (ungt (match_dup 1) (match_dup 2))
1631 (label_ref (match_operand 0 "" ""))
1632 (pc)))]
1633 ""
1634 "
1635 {
1636 if (hppa_branch_type == CMP_SI)
1637 FAIL;
1638 emit_insn (gen_cmp_fp (UNGT, hppa_compare_op0, hppa_compare_op1));
1639 emit_bcond_fp (NE, operands[0]);
1640 DONE;
1641 }")
1642
1643 (define_expand "buneq"
1644 [(set (pc)
1645 (if_then_else (uneq (match_dup 1) (match_dup 2))
1646 (label_ref (match_operand 0 "" ""))
1647 (pc)))]
1648 ""
1649 "
1650 {
1651 if (hppa_branch_type == CMP_SI)
1652 FAIL;
1653 emit_insn (gen_cmp_fp (UNEQ, hppa_compare_op0, hppa_compare_op1));
1654 emit_bcond_fp (NE, operands[0]);
1655 DONE;
1656 }")
1657
1658 (define_expand "bunordered"
1659 [(set (pc)
1660 (if_then_else (unordered (match_dup 1) (match_dup 2))
1661 (label_ref (match_operand 0 "" ""))
1662 (pc)))]
1663 ""
1664 "
1665 {
1666 if (hppa_branch_type == CMP_SI)
1667 FAIL;
1668 emit_insn (gen_cmp_fp (UNORDERED, hppa_compare_op0, hppa_compare_op1));
1669 emit_bcond_fp (NE, operands[0]);
1670 DONE;
1671 }")
1672
1673 (define_expand "bordered"
1674 [(set (pc)
1675 (if_then_else (ordered (match_dup 1) (match_dup 2))
1676 (label_ref (match_operand 0 "" ""))
1677 (pc)))]
1678 ""
1679 "
1680 {
1681 if (hppa_branch_type == CMP_SI)
1682 FAIL;
1683 emit_insn (gen_cmp_fp (ORDERED, hppa_compare_op0, hppa_compare_op1));
1684 emit_bcond_fp (NE, operands[0]);
1685 DONE;
1686 }")
1687
1688 ;; Match the branch patterns.
1689
1690
1691 ;; Note a long backward conditional branch with an annulled delay slot
1692 ;; has a length of 12.
1693 (define_insn ""
1694 [(set (pc)
1695 (if_then_else
1696 (match_operator 3 "comparison_operator"
1697 [(match_operand:SI 1 "reg_or_0_operand" "rM")
1698 (match_operand:SI 2 "arith5_operand" "rL")])
1699 (label_ref (match_operand 0 "" ""))
1700 (pc)))]
1701 ""
1702 "*
1703 {
1704 return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1705 get_attr_length (insn), 0, insn);
1706 }"
1707 [(set_attr "type" "cbranch")
1708 (set (attr "length")
1709 (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1710 (const_int 8184))
1711 (const_int 4)
1712 (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1713 (const_int 262100))
1714 (const_int 8)
1715 (eq (symbol_ref "flag_pic") (const_int 0))
1716 (const_int 20)]
1717 (const_int 28)))])
1718
1719 ;; Match the negated branch.
1720
1721 (define_insn ""
1722 [(set (pc)
1723 (if_then_else
1724 (match_operator 3 "comparison_operator"
1725 [(match_operand:SI 1 "reg_or_0_operand" "rM")
1726 (match_operand:SI 2 "arith5_operand" "rL")])
1727 (pc)
1728 (label_ref (match_operand 0 "" ""))))]
1729 ""
1730 "*
1731 {
1732 return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1733 get_attr_length (insn), 1, insn);
1734 }"
1735 [(set_attr "type" "cbranch")
1736 (set (attr "length")
1737 (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1738 (const_int 8184))
1739 (const_int 4)
1740 (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1741 (const_int 262100))
1742 (const_int 8)
1743 (eq (symbol_ref "flag_pic") (const_int 0))
1744 (const_int 20)]
1745 (const_int 28)))])
1746
1747 (define_insn ""
1748 [(set (pc)
1749 (if_then_else
1750 (match_operator 3 "comparison_operator"
1751 [(match_operand:DI 1 "reg_or_0_operand" "rM")
1752 (match_operand:DI 2 "reg_or_0_operand" "rM")])
1753 (label_ref (match_operand 0 "" ""))
1754 (pc)))]
1755 "TARGET_64BIT"
1756 "*
1757 {
1758 return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1759 get_attr_length (insn), 0, insn);
1760 }"
1761 [(set_attr "type" "cbranch")
1762 (set (attr "length")
1763 (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1764 (const_int 8184))
1765 (const_int 4)
1766 (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1767 (const_int 262100))
1768 (const_int 8)
1769 (eq (symbol_ref "flag_pic") (const_int 0))
1770 (const_int 20)]
1771 (const_int 28)))])
1772
1773 ;; Match the negated branch.
1774
1775 (define_insn ""
1776 [(set (pc)
1777 (if_then_else
1778 (match_operator 3 "comparison_operator"
1779 [(match_operand:DI 1 "reg_or_0_operand" "rM")
1780 (match_operand:DI 2 "reg_or_0_operand" "rM")])
1781 (pc)
1782 (label_ref (match_operand 0 "" ""))))]
1783 "TARGET_64BIT"
1784 "*
1785 {
1786 return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1787 get_attr_length (insn), 1, insn);
1788 }"
1789 [(set_attr "type" "cbranch")
1790 (set (attr "length")
1791 (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1792 (const_int 8184))
1793 (const_int 4)
1794 (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1795 (const_int 262100))
1796 (const_int 8)
1797 (eq (symbol_ref "flag_pic") (const_int 0))
1798 (const_int 20)]
1799 (const_int 28)))])
1800 (define_insn ""
1801 [(set (pc)
1802 (if_then_else
1803 (match_operator 3 "cmpib_comparison_operator"
1804 [(match_operand:DI 1 "reg_or_0_operand" "rM")
1805 (match_operand:DI 2 "arith5_operand" "rL")])
1806 (label_ref (match_operand 0 "" ""))
1807 (pc)))]
1808 "TARGET_64BIT"
1809 "*
1810 {
1811 return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1812 get_attr_length (insn), 0, insn);
1813 }"
1814 [(set_attr "type" "cbranch")
1815 (set (attr "length")
1816 (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1817 (const_int 8184))
1818 (const_int 4)
1819 (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1820 (const_int 262100))
1821 (const_int 8)
1822 (eq (symbol_ref "flag_pic") (const_int 0))
1823 (const_int 20)]
1824 (const_int 28)))])
1825
1826 ;; Match the negated branch.
1827
1828 (define_insn ""
1829 [(set (pc)
1830 (if_then_else
1831 (match_operator 3 "cmpib_comparison_operator"
1832 [(match_operand:DI 1 "reg_or_0_operand" "rM")
1833 (match_operand:DI 2 "arith5_operand" "rL")])
1834 (pc)
1835 (label_ref (match_operand 0 "" ""))))]
1836 "TARGET_64BIT"
1837 "*
1838 {
1839 return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1840 get_attr_length (insn), 1, insn);
1841 }"
1842 [(set_attr "type" "cbranch")
1843 (set (attr "length")
1844 (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1845 (const_int 8184))
1846 (const_int 4)
1847 (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1848 (const_int 262100))
1849 (const_int 8)
1850 (eq (symbol_ref "flag_pic") (const_int 0))
1851 (const_int 20)]
1852 (const_int 28)))])
1853
1854 ;; Branch on Bit patterns.
1855 (define_insn ""
1856 [(set (pc)
1857 (if_then_else
1858 (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1859 (const_int 1)
1860 (match_operand:SI 1 "uint5_operand" ""))
1861 (const_int 0))
1862 (label_ref (match_operand 2 "" ""))
1863 (pc)))]
1864 ""
1865 "*
1866 {
1867 return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1868 get_attr_length (insn), 0, insn, 0);
1869 }"
1870 [(set_attr "type" "cbranch")
1871 (set (attr "length")
1872 (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1873 (const_int 8184))
1874 (const_int 4)
1875 (const_int 8)))])
1876
1877 (define_insn ""
1878 [(set (pc)
1879 (if_then_else
1880 (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1881 (const_int 1)
1882 (match_operand:DI 1 "uint32_operand" ""))
1883 (const_int 0))
1884 (label_ref (match_operand 2 "" ""))
1885 (pc)))]
1886 "TARGET_64BIT"
1887 "*
1888 {
1889 return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1890 get_attr_length (insn), 0, insn, 0);
1891 }"
1892 [(set_attr "type" "cbranch")
1893 (set (attr "length")
1894 (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1895 (const_int 8184))
1896 (const_int 4)
1897 (const_int 8)))])
1898
1899 (define_insn ""
1900 [(set (pc)
1901 (if_then_else
1902 (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1903 (const_int 1)
1904 (match_operand:SI 1 "uint5_operand" ""))
1905 (const_int 0))
1906 (pc)
1907 (label_ref (match_operand 2 "" ""))))]
1908 ""
1909 "*
1910 {
1911 return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1912 get_attr_length (insn), 1, insn, 0);
1913 }"
1914 [(set_attr "type" "cbranch")
1915 (set (attr "length")
1916 (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1917 (const_int 8184))
1918 (const_int 4)
1919 (const_int 8)))])
1920
1921 (define_insn ""
1922 [(set (pc)
1923 (if_then_else
1924 (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1925 (const_int 1)
1926 (match_operand:DI 1 "uint32_operand" ""))
1927 (const_int 0))
1928 (pc)
1929 (label_ref (match_operand 2 "" ""))))]
1930 "TARGET_64BIT"
1931 "*
1932 {
1933 return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1934 get_attr_length (insn), 1, insn, 0);
1935 }"
1936 [(set_attr "type" "cbranch")
1937 (set (attr "length")
1938 (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1939 (const_int 8184))
1940 (const_int 4)
1941 (const_int 8)))])
1942
1943 (define_insn ""
1944 [(set (pc)
1945 (if_then_else
1946 (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1947 (const_int 1)
1948 (match_operand:SI 1 "uint5_operand" ""))
1949 (const_int 0))
1950 (label_ref (match_operand 2 "" ""))
1951 (pc)))]
1952 ""
1953 "*
1954 {
1955 return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1956 get_attr_length (insn), 0, insn, 1);
1957 }"
1958 [(set_attr "type" "cbranch")
1959 (set (attr "length")
1960 (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1961 (const_int 8184))
1962 (const_int 4)
1963 (const_int 8)))])
1964
1965 (define_insn ""
1966 [(set (pc)
1967 (if_then_else
1968 (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1969 (const_int 1)
1970 (match_operand:DI 1 "uint32_operand" ""))
1971 (const_int 0))
1972 (label_ref (match_operand 2 "" ""))
1973 (pc)))]
1974 "TARGET_64BIT"
1975 "*
1976 {
1977 return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1978 get_attr_length (insn), 0, insn, 1);
1979 }"
1980 [(set_attr "type" "cbranch")
1981 (set (attr "length")
1982 (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1983 (const_int 8184))
1984 (const_int 4)
1985 (const_int 8)))])
1986
1987 (define_insn ""
1988 [(set (pc)
1989 (if_then_else
1990 (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1991 (const_int 1)
1992 (match_operand:SI 1 "uint5_operand" ""))
1993 (const_int 0))
1994 (pc)
1995 (label_ref (match_operand 2 "" ""))))]
1996 ""
1997 "*
1998 {
1999 return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
2000 get_attr_length (insn), 1, insn, 1);
2001 }"
2002 [(set_attr "type" "cbranch")
2003 (set (attr "length")
2004 (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2005 (const_int 8184))
2006 (const_int 4)
2007 (const_int 8)))])
2008
2009 (define_insn ""
2010 [(set (pc)
2011 (if_then_else
2012 (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2013 (const_int 1)
2014 (match_operand:DI 1 "uint32_operand" ""))
2015 (const_int 0))
2016 (pc)
2017 (label_ref (match_operand 2 "" ""))))]
2018 "TARGET_64BIT"
2019 "*
2020 {
2021 return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
2022 get_attr_length (insn), 1, insn, 1);
2023 }"
2024 [(set_attr "type" "cbranch")
2025 (set (attr "length")
2026 (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2027 (const_int 8184))
2028 (const_int 4)
2029 (const_int 8)))])
2030
2031 ;; Branch on Variable Bit patterns.
2032 (define_insn ""
2033 [(set (pc)
2034 (if_then_else
2035 (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
2036 (const_int 1)
2037 (match_operand:SI 1 "register_operand" "q"))
2038 (const_int 0))
2039 (label_ref (match_operand 2 "" ""))
2040 (pc)))]
2041 ""
2042 "*
2043 {
2044 return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
2045 get_attr_length (insn), 0, insn, 0);
2046 }"
2047 [(set_attr "type" "cbranch")
2048 (set (attr "length")
2049 (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2050 (const_int 8184))
2051 (const_int 4)
2052 (const_int 8)))])
2053
2054 (define_insn ""
2055 [(set (pc)
2056 (if_then_else
2057 (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2058 (const_int 1)
2059 (match_operand:DI 1 "register_operand" "q"))
2060 (const_int 0))
2061 (label_ref (match_operand 2 "" ""))
2062 (pc)))]
2063 "TARGET_64BIT"
2064 "*
2065 {
2066 return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
2067 get_attr_length (insn), 0, insn, 0);
2068 }"
2069 [(set_attr "type" "cbranch")
2070 (set (attr "length")
2071 (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2072 (const_int 8184))
2073 (const_int 4)
2074 (const_int 8)))])
2075
2076 (define_insn ""
2077 [(set (pc)
2078 (if_then_else
2079 (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
2080 (const_int 1)
2081 (match_operand:SI 1 "register_operand" "q"))
2082 (const_int 0))
2083 (pc)
2084 (label_ref (match_operand 2 "" ""))))]
2085 ""
2086 "*
2087 {
2088 return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
2089 get_attr_length (insn), 1, insn, 0);
2090 }"
2091 [(set_attr "type" "cbranch")
2092 (set (attr "length")
2093 (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2094 (const_int 8184))
2095 (const_int 4)
2096 (const_int 8)))])
2097
2098 (define_insn ""
2099 [(set (pc)
2100 (if_then_else
2101 (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2102 (const_int 1)
2103 (match_operand:DI 1 "register_operand" "q"))
2104 (const_int 0))
2105 (pc)
2106 (label_ref (match_operand 2 "" ""))))]
2107 "TARGET_64BIT"
2108 "*
2109 {
2110 return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
2111 get_attr_length (insn), 1, insn, 0);
2112 }"
2113 [(set_attr "type" "cbranch")
2114 (set (attr "length")
2115 (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2116 (const_int 8184))
2117 (const_int 4)
2118 (const_int 8)))])
2119
2120 (define_insn ""
2121 [(set (pc)
2122 (if_then_else
2123 (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
2124 (const_int 1)
2125 (match_operand:SI 1 "register_operand" "q"))
2126 (const_int 0))
2127 (label_ref (match_operand 2 "" ""))
2128 (pc)))]
2129 ""
2130 "*
2131 {
2132 return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
2133 get_attr_length (insn), 0, insn, 1);
2134 }"
2135 [(set_attr "type" "cbranch")
2136 (set (attr "length")
2137 (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2138 (const_int 8184))
2139 (const_int 4)
2140 (const_int 8)))])
2141
2142 (define_insn ""
2143 [(set (pc)
2144 (if_then_else
2145 (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2146 (const_int 1)
2147 (match_operand:DI 1 "register_operand" "q"))
2148 (const_int 0))
2149 (label_ref (match_operand 2 "" ""))
2150 (pc)))]
2151 "TARGET_64BIT"
2152 "*
2153 {
2154 return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
2155 get_attr_length (insn), 0, insn, 1);
2156 }"
2157 [(set_attr "type" "cbranch")
2158 (set (attr "length")
2159 (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2160 (const_int 8184))
2161 (const_int 4)
2162 (const_int 8)))])
2163
2164 (define_insn ""
2165 [(set (pc)
2166 (if_then_else
2167 (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
2168 (const_int 1)
2169 (match_operand:SI 1 "register_operand" "q"))
2170 (const_int 0))
2171 (pc)
2172 (label_ref (match_operand 2 "" ""))))]
2173 ""
2174 "*
2175 {
2176 return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
2177 get_attr_length (insn), 1, insn, 1);
2178 }"
2179 [(set_attr "type" "cbranch")
2180 (set (attr "length")
2181 (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2182 (const_int 8184))
2183 (const_int 4)
2184 (const_int 8)))])
2185
2186 (define_insn ""
2187 [(set (pc)
2188 (if_then_else
2189 (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2190 (const_int 1)
2191 (match_operand:DI 1 "register_operand" "q"))
2192 (const_int 0))
2193 (pc)
2194 (label_ref (match_operand 2 "" ""))))]
2195 "TARGET_64BIT"
2196 "*
2197 {
2198 return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
2199 get_attr_length (insn), 1, insn, 1);
2200 }"
2201 [(set_attr "type" "cbranch")
2202 (set (attr "length")
2203 (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2204 (const_int 8184))
2205 (const_int 4)
2206 (const_int 8)))])
2207
2208 ;; Floating point branches
2209 (define_insn ""
2210 [(set (pc) (if_then_else (ne (reg:CCFP 0) (const_int 0))
2211 (label_ref (match_operand 0 "" ""))
2212 (pc)))]
2213 "! TARGET_SOFT_FLOAT"
2214 "*
2215 {
2216 if (INSN_ANNULLED_BRANCH_P (insn))
2217 return \"ftest\;b,n %0\";
2218 else
2219 return \"ftest\;b%* %0\";
2220 }"
2221 [(set_attr "type" "fbranch")
2222 (set_attr "length" "8")])
2223
2224 (define_insn ""
2225 [(set (pc) (if_then_else (ne (reg:CCFP 0) (const_int 0))
2226 (pc)
2227 (label_ref (match_operand 0 "" ""))))]
2228 "! TARGET_SOFT_FLOAT"
2229 "*
2230 {
2231 if (INSN_ANNULLED_BRANCH_P (insn))
2232 return \"ftest\;add,tr %%r0,%%r0,%%r0\;b,n %0\";
2233 else
2234 return \"ftest\;add,tr %%r0,%%r0,%%r0\;b%* %0\";
2235 }"
2236 [(set_attr "type" "fbranch")
2237 (set_attr "length" "12")])
2238
2239 ;; Move instructions
2240
2241 (define_expand "movsi"
2242 [(set (match_operand:SI 0 "general_operand" "")
2243 (match_operand:SI 1 "general_operand" ""))]
2244 ""
2245 "
2246 {
2247 if (emit_move_sequence (operands, SImode, 0))
2248 DONE;
2249 }")
2250
2251 ;; Reloading an SImode or DImode value requires a scratch register if
2252 ;; going in to or out of float point registers.
2253
2254 (define_expand "reload_insi"
2255 [(set (match_operand:SI 0 "register_operand" "=Z")
2256 (match_operand:SI 1 "non_hard_reg_operand" ""))
2257 (clobber (match_operand:SI 2 "register_operand" "=&r"))]
2258 ""
2259 "
2260 {
2261 if (emit_move_sequence (operands, SImode, operands[2]))
2262 DONE;
2263
2264 /* We don't want the clobber emitted, so handle this ourselves. */
2265 emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
2266 DONE;
2267 }")
2268
2269 (define_expand "reload_outsi"
2270 [(set (match_operand:SI 0 "non_hard_reg_operand" "")
2271 (match_operand:SI 1 "register_operand" "Z"))
2272 (clobber (match_operand:SI 2 "register_operand" "=&r"))]
2273 ""
2274 "
2275 {
2276 if (emit_move_sequence (operands, SImode, operands[2]))
2277 DONE;
2278
2279 /* We don't want the clobber emitted, so handle this ourselves. */
2280 emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
2281 DONE;
2282 }")
2283
2284 (define_insn ""
2285 [(set (match_operand:SI 0 "move_dest_operand"
2286 "=r,r,r,r,r,r,Q,!*q,!r,!*f,*f,T")
2287 (match_operand:SI 1 "move_src_operand"
2288 "A,r,J,N,K,RQ,rM,!rM,!*q,!*fM,RT,*f"))]
2289 "(register_operand (operands[0], SImode)
2290 || reg_or_0_operand (operands[1], SImode))
2291 && !TARGET_SOFT_FLOAT"
2292 "@
2293 ldw RT'%A1,%0
2294 copy %1,%0
2295 ldi %1,%0
2296 ldil L'%1,%0
2297 {zdepi|depwi,z} %Z1,%0
2298 ldw%M1 %1,%0
2299 stw%M0 %r1,%0
2300 mtsar %r1
2301 {mfctl|mfctl,w} %%sar,%0
2302 fcpy,sgl %f1,%0
2303 fldw%F1 %1,%0
2304 fstw%F0 %1,%0"
2305 [(set_attr "type" "load,move,move,move,shift,load,store,move,move,fpalu,fpload,fpstore")
2306 (set_attr "pa_combine_type" "addmove")
2307 (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4")])
2308
2309 (define_insn ""
2310 [(set (match_operand:SI 0 "indexed_memory_operand" "=R")
2311 (match_operand:SI 1 "register_operand" "f"))]
2312 "!TARGET_SOFT_FLOAT
2313 && !TARGET_DISABLE_INDEXING
2314 && reload_completed"
2315 "fstw%F0 %1,%0"
2316 [(set_attr "type" "fpstore")
2317 (set_attr "pa_combine_type" "addmove")
2318 (set_attr "length" "4")])
2319
2320 ; Rewrite RTL using an indexed store. This will allow the insn that
2321 ; computes the address to be deleted if the register it sets is dead.
2322 (define_peephole2
2323 [(set (match_operand:SI 0 "register_operand" "")
2324 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "")
2325 (const_int 4))
2326 (match_operand:SI 2 "register_operand" "")))
2327 (set (mem:SI (match_dup 0))
2328 (match_operand:SI 3 "register_operand" ""))]
2329 "!TARGET_SOFT_FLOAT
2330 && !TARGET_DISABLE_INDEXING
2331 && REG_OK_FOR_BASE_P (operands[2])
2332 && FP_REGNO_P (REGNO (operands[3]))"
2333 [(set (mem:SI (plus:SI (mult:SI (match_dup 1) (const_int 4)) (match_dup 2)))
2334 (match_dup 3))
2335 (set (match_dup 0) (plus:SI (mult:SI (match_dup 1) (const_int 4))
2336 (match_dup 2)))]
2337 "")
2338
2339 (define_peephole2
2340 [(set (match_operand:SI 0 "register_operand" "")
2341 (plus:SI (match_operand:SI 2 "register_operand" "")
2342 (mult:SI (match_operand:SI 1 "register_operand" "")
2343 (const_int 4))))
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 (mult:SI (match_dup 1) (const_int 4))
2353 (match_dup 2)))]
2354 "")
2355
2356 (define_peephole2
2357 [(set (match_operand:DI 0 "register_operand" "")
2358 (plus:DI (mult:DI (match_operand:DI 1 "register_operand" "")
2359 (const_int 4))
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 (mult:DI (match_dup 1) (const_int 4))
2371 (match_dup 2)))]
2372 "")
2373
2374 (define_peephole2
2375 [(set (match_operand:DI 0 "register_operand" "")
2376 (plus:DI (match_operand:DI 2 "register_operand" "")
2377 (mult:DI (match_operand:DI 1 "register_operand" "")
2378 (const_int 4))))
2379 (set (mem:SI (match_dup 0))
2380 (match_operand:SI 3 "register_operand" ""))]
2381 "!TARGET_SOFT_FLOAT
2382 && !TARGET_DISABLE_INDEXING
2383 && TARGET_64BIT
2384 && REG_OK_FOR_BASE_P (operands[2])
2385 && FP_REGNO_P (REGNO (operands[3]))"
2386 [(set (mem:SI (plus:DI (mult:DI (match_dup 1) (const_int 4)) (match_dup 2)))
2387 (match_dup 3))
2388 (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 4))
2389 (match_dup 2)))]
2390 "")
2391
2392 (define_peephole2
2393 [(set (match_operand:SI 0 "register_operand" "")
2394 (plus:SI (match_operand:SI 1 "register_operand" "")
2395 (match_operand:SI 2 "register_operand" "")))
2396 (set (mem:SI (match_dup 0))
2397 (match_operand:SI 3 "register_operand" ""))]
2398 "!TARGET_SOFT_FLOAT
2399 && !TARGET_DISABLE_INDEXING
2400 && REG_OK_FOR_BASE_P (operands[1])
2401 && (TARGET_NO_SPACE_REGS
2402 || (!REG_POINTER (operands[1]) && REG_POINTER (operands[2])))
2403 && FP_REGNO_P (REGNO (operands[3]))"
2404 [(set (mem:SI (plus:SI (match_dup 1) (match_dup 2)))
2405 (match_dup 3))
2406 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
2407 "")
2408
2409 (define_peephole2
2410 [(set (match_operand:SI 0 "register_operand" "")
2411 (plus:SI (match_operand:SI 1 "register_operand" "")
2412 (match_operand:SI 2 "register_operand" "")))
2413 (set (mem:SI (match_dup 0))
2414 (match_operand:SI 3 "register_operand" ""))]
2415 "!TARGET_SOFT_FLOAT
2416 && !TARGET_DISABLE_INDEXING
2417 && REG_OK_FOR_BASE_P (operands[2])
2418 && (TARGET_NO_SPACE_REGS
2419 || (REG_POINTER (operands[1]) && !REG_POINTER (operands[2])))
2420 && FP_REGNO_P (REGNO (operands[3]))"
2421 [(set (mem:SI (plus:SI (match_dup 2) (match_dup 1)))
2422 (match_dup 3))
2423 (set (match_dup 0) (plus:SI (match_dup 2) (match_dup 1)))]
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 && REG_OK_FOR_BASE_P (operands[1])
2436 && (TARGET_NO_SPACE_REGS
2437 || (!REG_POINTER (operands[1]) && REG_POINTER (operands[2])))
2438 && FP_REGNO_P (REGNO (operands[3]))"
2439 [(set (mem:SI (plus:DI (match_dup 1) (match_dup 2)))
2440 (match_dup 3))
2441 (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
2442 "")
2443
2444 (define_peephole2
2445 [(set (match_operand:DI 0 "register_operand" "")
2446 (plus:DI (match_operand:DI 1 "register_operand" "")
2447 (match_operand:DI 2 "register_operand" "")))
2448 (set (mem:SI (match_dup 0))
2449 (match_operand:SI 3 "register_operand" ""))]
2450 "!TARGET_SOFT_FLOAT
2451 && !TARGET_DISABLE_INDEXING
2452 && TARGET_64BIT
2453 && REG_OK_FOR_BASE_P (operands[2])
2454 && (TARGET_NO_SPACE_REGS
2455 || (REG_POINTER (operands[1]) && !REG_POINTER (operands[2])))
2456 && FP_REGNO_P (REGNO (operands[3]))"
2457 [(set (mem:SI (plus:DI (match_dup 2) (match_dup 1)))
2458 (match_dup 3))
2459 (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
2460 "")
2461
2462 (define_insn ""
2463 [(set (match_operand:SI 0 "move_dest_operand"
2464 "=r,r,r,r,r,r,Q,!*q,!r")
2465 (match_operand:SI 1 "move_src_operand"
2466 "A,r,J,N,K,RQ,rM,!rM,!*q"))]
2467 "(register_operand (operands[0], SImode)
2468 || reg_or_0_operand (operands[1], SImode))
2469 && TARGET_SOFT_FLOAT"
2470 "@
2471 ldw RT'%A1,%0
2472 copy %1,%0
2473 ldi %1,%0
2474 ldil L'%1,%0
2475 {zdepi|depwi,z} %Z1,%0
2476 ldw%M1 %1,%0
2477 stw%M0 %r1,%0
2478 mtsar %r1
2479 {mfctl|mfctl,w} %%sar,%0"
2480 [(set_attr "type" "load,move,move,move,move,load,store,move,move")
2481 (set_attr "pa_combine_type" "addmove")
2482 (set_attr "length" "4,4,4,4,4,4,4,4,4")])
2483
2484 ;; Load or store with base-register modification.
2485 (define_insn ""
2486 [(set (match_operand:SI 0 "register_operand" "=r")
2487 (mem:SI (plus:DI (match_operand:DI 1 "register_operand" "+r")
2488 (match_operand:DI 2 "int5_operand" "L"))))
2489 (set (match_dup 1)
2490 (plus:DI (match_dup 1) (match_dup 2)))]
2491 "TARGET_64BIT"
2492 "ldw,mb %2(%1),%0"
2493 [(set_attr "type" "load")
2494 (set_attr "length" "4")])
2495
2496 ; And a zero extended variant.
2497 (define_insn ""
2498 [(set (match_operand:DI 0 "register_operand" "=r")
2499 (zero_extend:DI (mem:SI
2500 (plus:DI
2501 (match_operand:DI 1 "register_operand" "+r")
2502 (match_operand:DI 2 "int5_operand" "L")))))
2503 (set (match_dup 1)
2504 (plus:DI (match_dup 1) (match_dup 2)))]
2505 "TARGET_64BIT"
2506 "ldw,mb %2(%1),%0"
2507 [(set_attr "type" "load")
2508 (set_attr "length" "4")])
2509
2510 (define_expand "pre_load"
2511 [(parallel [(set (match_operand:SI 0 "register_operand" "")
2512 (mem (plus (match_operand 1 "register_operand" "")
2513 (match_operand 2 "pre_cint_operand" ""))))
2514 (set (match_dup 1)
2515 (plus (match_dup 1) (match_dup 2)))])]
2516 ""
2517 "
2518 {
2519 if (TARGET_64BIT)
2520 {
2521 emit_insn (gen_pre_ldd (operands[0], operands[1], operands[2]));
2522 DONE;
2523 }
2524 emit_insn (gen_pre_ldw (operands[0], operands[1], operands[2]));
2525 DONE;
2526 }")
2527
2528 (define_insn "pre_ldw"
2529 [(set (match_operand:SI 0 "register_operand" "=r")
2530 (mem:SI (plus:SI (match_operand:SI 1 "register_operand" "+r")
2531 (match_operand:SI 2 "pre_cint_operand" ""))))
2532 (set (match_dup 1)
2533 (plus:SI (match_dup 1) (match_dup 2)))]
2534 ""
2535 "*
2536 {
2537 if (INTVAL (operands[2]) < 0)
2538 return \"{ldwm|ldw,mb} %2(%1),%0\";
2539 return \"{ldws|ldw},mb %2(%1),%0\";
2540 }"
2541 [(set_attr "type" "load")
2542 (set_attr "length" "4")])
2543
2544 (define_insn "pre_ldd"
2545 [(set (match_operand:DI 0 "register_operand" "=r")
2546 (mem:DI (plus:DI (match_operand:DI 1 "register_operand" "+r")
2547 (match_operand:DI 2 "pre_cint_operand" ""))))
2548 (set (match_dup 1)
2549 (plus:DI (match_dup 1) (match_dup 2)))]
2550 "TARGET_64BIT"
2551 "ldd,mb %2(%1),%0"
2552 [(set_attr "type" "load")
2553 (set_attr "length" "4")])
2554
2555 (define_insn ""
2556 [(set (mem:SI (plus:SI (match_operand:SI 0 "register_operand" "+r")
2557 (match_operand:SI 1 "pre_cint_operand" "")))
2558 (match_operand:SI 2 "reg_or_0_operand" "rM"))
2559 (set (match_dup 0)
2560 (plus:SI (match_dup 0) (match_dup 1)))]
2561 ""
2562 "*
2563 {
2564 if (INTVAL (operands[1]) < 0)
2565 return \"{stwm|stw,mb} %r2,%1(%0)\";
2566 return \"{stws|stw},mb %r2,%1(%0)\";
2567 }"
2568 [(set_attr "type" "store")
2569 (set_attr "length" "4")])
2570
2571 (define_insn ""
2572 [(set (match_operand:SI 0 "register_operand" "=r")
2573 (mem:SI (match_operand:SI 1 "register_operand" "+r")))
2574 (set (match_dup 1)
2575 (plus:SI (match_dup 1)
2576 (match_operand:SI 2 "post_cint_operand" "")))]
2577 ""
2578 "*
2579 {
2580 if (INTVAL (operands[2]) > 0)
2581 return \"{ldwm|ldw,ma} %2(%1),%0\";
2582 return \"{ldws|ldw},ma %2(%1),%0\";
2583 }"
2584 [(set_attr "type" "load")
2585 (set_attr "length" "4")])
2586
2587 (define_expand "post_store"
2588 [(parallel [(set (mem (match_operand 0 "register_operand" ""))
2589 (match_operand 1 "reg_or_0_operand" ""))
2590 (set (match_dup 0)
2591 (plus (match_dup 0)
2592 (match_operand 2 "post_cint_operand" "")))])]
2593 ""
2594 "
2595 {
2596 if (TARGET_64BIT)
2597 {
2598 emit_insn (gen_post_std (operands[0], operands[1], operands[2]));
2599 DONE;
2600 }
2601 emit_insn (gen_post_stw (operands[0], operands[1], operands[2]));
2602 DONE;
2603 }")
2604
2605 (define_insn "post_stw"
2606 [(set (mem:SI (match_operand:SI 0 "register_operand" "+r"))
2607 (match_operand:SI 1 "reg_or_0_operand" "rM"))
2608 (set (match_dup 0)
2609 (plus:SI (match_dup 0)
2610 (match_operand:SI 2 "post_cint_operand" "")))]
2611 ""
2612 "*
2613 {
2614 if (INTVAL (operands[2]) > 0)
2615 return \"{stwm|stw,ma} %r1,%2(%0)\";
2616 return \"{stws|stw},ma %r1,%2(%0)\";
2617 }"
2618 [(set_attr "type" "store")
2619 (set_attr "length" "4")])
2620
2621 (define_insn "post_std"
2622 [(set (mem:DI (match_operand:DI 0 "register_operand" "+r"))
2623 (match_operand:DI 1 "reg_or_0_operand" "rM"))
2624 (set (match_dup 0)
2625 (plus:DI (match_dup 0)
2626 (match_operand:DI 2 "post_cint_operand" "")))]
2627 "TARGET_64BIT"
2628 "std,ma %r1,%2(%0)"
2629 [(set_attr "type" "store")
2630 (set_attr "length" "4")])
2631
2632 ;; For loading the address of a label while generating PIC code.
2633 ;; Note since this pattern can be created at reload time (via movsi), all
2634 ;; the same rules for movsi apply here. (no new pseudos, no temporaries).
2635 (define_insn ""
2636 [(set (match_operand 0 "pmode_register_operand" "=a")
2637 (match_operand 1 "pic_label_operand" ""))]
2638 "TARGET_PA_20"
2639 "*
2640 {
2641 rtx xoperands[3];
2642
2643 xoperands[0] = operands[0];
2644 xoperands[1] = operands[1];
2645 xoperands[2] = gen_label_rtx ();
2646
2647 (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
2648 CODE_LABEL_NUMBER (xoperands[2]));
2649 output_asm_insn (\"mfia %0\", xoperands);
2650
2651 /* If we're trying to load the address of a label that happens to be
2652 close, then we can use a shorter sequence. */
2653 if (GET_CODE (operands[1]) == LABEL_REF
2654 && !LABEL_REF_NONLOCAL_P (operands[1])
2655 && INSN_ADDRESSES_SET_P ()
2656 && abs (INSN_ADDRESSES (INSN_UID (XEXP (operands[1], 0)))
2657 - INSN_ADDRESSES (INSN_UID (insn))) < 8100)
2658 output_asm_insn (\"ldo %1-%2(%0),%0\", xoperands);
2659 else
2660 {
2661 output_asm_insn (\"addil L%%%1-%2,%0\", xoperands);
2662 output_asm_insn (\"ldo R%%%1-%2(%0),%0\", xoperands);
2663 }
2664 return \"\";
2665 }"
2666 [(set_attr "type" "multi")
2667 (set_attr "length" "12")]) ; 8 or 12
2668
2669 (define_insn ""
2670 [(set (match_operand 0 "pmode_register_operand" "=a")
2671 (match_operand 1 "pic_label_operand" ""))]
2672 "!TARGET_PA_20"
2673 "*
2674 {
2675 rtx xoperands[3];
2676
2677 xoperands[0] = operands[0];
2678 xoperands[1] = operands[1];
2679 xoperands[2] = gen_label_rtx ();
2680
2681 output_asm_insn (\"bl .+8,%0\", xoperands);
2682 output_asm_insn (\"depi 0,31,2,%0\", xoperands);
2683 (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
2684 CODE_LABEL_NUMBER (xoperands[2]));
2685
2686 /* If we're trying to load the address of a label that happens to be
2687 close, then we can use a shorter sequence. */
2688 if (GET_CODE (operands[1]) == LABEL_REF
2689 && !LABEL_REF_NONLOCAL_P (operands[1])
2690 && INSN_ADDRESSES_SET_P ()
2691 && abs (INSN_ADDRESSES (INSN_UID (XEXP (operands[1], 0)))
2692 - INSN_ADDRESSES (INSN_UID (insn))) < 8100)
2693 output_asm_insn (\"ldo %1-%2(%0),%0\", xoperands);
2694 else
2695 {
2696 output_asm_insn (\"addil L%%%1-%2,%0\", xoperands);
2697 output_asm_insn (\"ldo R%%%1-%2(%0),%0\", xoperands);
2698 }
2699 return \"\";
2700 }"
2701 [(set_attr "type" "multi")
2702 (set_attr "length" "16")]) ; 12 or 16
2703
2704 (define_insn ""
2705 [(set (match_operand:SI 0 "register_operand" "=a")
2706 (plus:SI (match_operand:SI 1 "register_operand" "r")
2707 (high:SI (match_operand 2 "" ""))))]
2708 "symbolic_operand (operands[2], Pmode)
2709 && ! function_label_operand (operands[2], Pmode)
2710 && flag_pic"
2711 "addil LT'%G2,%1"
2712 [(set_attr "type" "binary")
2713 (set_attr "length" "4")])
2714
2715 (define_insn ""
2716 [(set (match_operand:DI 0 "register_operand" "=a")
2717 (plus:DI (match_operand:DI 1 "register_operand" "r")
2718 (high:DI (match_operand 2 "" ""))))]
2719 "symbolic_operand (operands[2], Pmode)
2720 && ! function_label_operand (operands[2], Pmode)
2721 && TARGET_64BIT
2722 && flag_pic"
2723 "addil LT'%G2,%1"
2724 [(set_attr "type" "binary")
2725 (set_attr "length" "4")])
2726
2727 ;; Always use addil rather than ldil;add sequences. This allows the
2728 ;; HP linker to eliminate the dp relocation if the symbolic operand
2729 ;; lives in the TEXT space.
2730 (define_insn ""
2731 [(set (match_operand:SI 0 "register_operand" "=a")
2732 (high:SI (match_operand 1 "" "")))]
2733 "symbolic_operand (operands[1], Pmode)
2734 && ! function_label_operand (operands[1], Pmode)
2735 && ! read_only_operand (operands[1], Pmode)
2736 && ! flag_pic"
2737 "*
2738 {
2739 if (TARGET_LONG_LOAD_STORE)
2740 return \"addil NLR'%H1,%%r27\;ldo N'%H1(%%r1),%%r1\";
2741 else
2742 return \"addil LR'%H1,%%r27\";
2743 }"
2744 [(set_attr "type" "binary")
2745 (set (attr "length")
2746 (if_then_else (eq (symbol_ref "TARGET_LONG_LOAD_STORE") (const_int 0))
2747 (const_int 4)
2748 (const_int 8)))])
2749
2750
2751 ;; This is for use in the prologue/epilogue code. We need it
2752 ;; to add large constants to a stack pointer or frame pointer.
2753 ;; Because of the additional %r1 pressure, we probably do not
2754 ;; want to use this in general code, so make it available
2755 ;; only after reload.
2756 (define_insn ""
2757 [(set (match_operand:SI 0 "register_operand" "=!a,*r")
2758 (plus:SI (match_operand:SI 1 "register_operand" "r,r")
2759 (high:SI (match_operand 2 "const_int_operand" ""))))]
2760 "reload_completed"
2761 "@
2762 addil L'%G2,%1
2763 ldil L'%G2,%0\;{addl|add,l} %0,%1,%0"
2764 [(set_attr "type" "binary,binary")
2765 (set_attr "length" "4,8")])
2766
2767 (define_insn ""
2768 [(set (match_operand:DI 0 "register_operand" "=!a,*r")
2769 (plus:DI (match_operand:DI 1 "register_operand" "r,r")
2770 (high:DI (match_operand 2 "const_int_operand" ""))))]
2771 "reload_completed && TARGET_64BIT"
2772 "@
2773 addil L'%G2,%1
2774 ldil L'%G2,%0\;{addl|add,l} %0,%1,%0"
2775 [(set_attr "type" "binary,binary")
2776 (set_attr "length" "4,8")])
2777
2778 (define_insn ""
2779 [(set (match_operand:SI 0 "register_operand" "=r")
2780 (high:SI (match_operand 1 "" "")))]
2781 "(!flag_pic || !symbolic_operand (operands[1], Pmode))
2782 && !is_function_label_plus_const (operands[1])"
2783 "*
2784 {
2785 if (symbolic_operand (operands[1], Pmode))
2786 return \"ldil LR'%H1,%0\";
2787 else
2788 return \"ldil L'%G1,%0\";
2789 }"
2790 [(set_attr "type" "move")
2791 (set_attr "length" "4")])
2792
2793 (define_insn ""
2794 [(set (match_operand:DI 0 "register_operand" "=r")
2795 (high:DI (match_operand 1 "const_int_operand" "")))]
2796 "TARGET_64BIT"
2797 "ldil L'%G1,%0";
2798 [(set_attr "type" "move")
2799 (set_attr "length" "4")])
2800
2801 (define_insn ""
2802 [(set (match_operand:DI 0 "register_operand" "=r")
2803 (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
2804 (match_operand:DI 2 "const_int_operand" "i")))]
2805 "TARGET_64BIT"
2806 "ldo R'%G2(%1),%0";
2807 [(set_attr "type" "move")
2808 (set_attr "length" "4")])
2809
2810 (define_insn ""
2811 [(set (match_operand:SI 0 "register_operand" "=r")
2812 (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
2813 (match_operand:SI 2 "immediate_operand" "i")))]
2814 "!is_function_label_plus_const (operands[2])"
2815 "*
2816 {
2817 if (flag_pic && symbolic_operand (operands[2], Pmode))
2818 abort ();
2819 else if (symbolic_operand (operands[2], Pmode))
2820 return \"ldo RR'%G2(%1),%0\";
2821 else
2822 return \"ldo R'%G2(%1),%0\";
2823 }"
2824 [(set_attr "type" "move")
2825 (set_attr "length" "4")])
2826
2827 ;; Now that a symbolic_address plus a constant is broken up early
2828 ;; in the compilation phase (for better CSE) we need a special
2829 ;; combiner pattern to load the symbolic address plus the constant
2830 ;; in only 2 instructions. (For cases where the symbolic address
2831 ;; was not a common subexpression.)
2832 (define_split
2833 [(set (match_operand:SI 0 "register_operand" "")
2834 (match_operand:SI 1 "symbolic_operand" ""))
2835 (clobber (match_operand:SI 2 "register_operand" ""))]
2836 "! (flag_pic && pic_label_operand (operands[1], SImode))"
2837 [(set (match_dup 2) (high:SI (match_dup 1)))
2838 (set (match_dup 0) (lo_sum:SI (match_dup 2) (match_dup 1)))]
2839 "")
2840
2841 ;; hppa_legitimize_address goes to a great deal of trouble to
2842 ;; create addresses which use indexing. In some cases, this
2843 ;; is a lose because there isn't any store instructions which
2844 ;; allow indexed addresses (with integer register source).
2845 ;;
2846 ;; These define_splits try to turn a 3 insn store into
2847 ;; a 2 insn store with some creative RTL rewriting.
2848 (define_split
2849 [(set (mem:SI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2850 (match_operand:SI 1 "shadd_operand" ""))
2851 (plus:SI (match_operand:SI 2 "register_operand" "")
2852 (match_operand:SI 3 "const_int_operand" ""))))
2853 (match_operand:SI 4 "register_operand" ""))
2854 (clobber (match_operand:SI 5 "register_operand" ""))]
2855 ""
2856 [(set (match_dup 5) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
2857 (match_dup 2)))
2858 (set (mem:SI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2859 "")
2860
2861 (define_split
2862 [(set (mem:HI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2863 (match_operand:SI 1 "shadd_operand" ""))
2864 (plus:SI (match_operand:SI 2 "register_operand" "")
2865 (match_operand:SI 3 "const_int_operand" ""))))
2866 (match_operand:HI 4 "register_operand" ""))
2867 (clobber (match_operand:SI 5 "register_operand" ""))]
2868 ""
2869 [(set (match_dup 5) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
2870 (match_dup 2)))
2871 (set (mem:HI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2872 "")
2873
2874 (define_split
2875 [(set (mem:QI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2876 (match_operand:SI 1 "shadd_operand" ""))
2877 (plus:SI (match_operand:SI 2 "register_operand" "")
2878 (match_operand:SI 3 "const_int_operand" ""))))
2879 (match_operand:QI 4 "register_operand" ""))
2880 (clobber (match_operand:SI 5 "register_operand" ""))]
2881 ""
2882 [(set (match_dup 5) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
2883 (match_dup 2)))
2884 (set (mem:QI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2885 "")
2886
2887 (define_expand "movhi"
2888 [(set (match_operand:HI 0 "general_operand" "")
2889 (match_operand:HI 1 "general_operand" ""))]
2890 ""
2891 "
2892 {
2893 if (emit_move_sequence (operands, HImode, 0))
2894 DONE;
2895 }")
2896
2897 (define_insn ""
2898 [(set (match_operand:HI 0 "move_dest_operand"
2899 "=r,r,r,r,r,Q,!*q,!r,!*f")
2900 (match_operand:HI 1 "move_src_operand"
2901 "r,J,N,K,RQ,rM,!rM,!*q,!*fM"))]
2902 "register_operand (operands[0], HImode)
2903 || reg_or_0_operand (operands[1], HImode)"
2904 "@
2905 copy %1,%0
2906 ldi %1,%0
2907 ldil L'%1,%0
2908 {zdepi|depwi,z} %Z1,%0
2909 ldh%M1 %1,%0
2910 sth%M0 %r1,%0
2911 mtsar %r1
2912 {mfctl|mfctl,w} %sar,%0
2913 fcpy,sgl %f1,%0"
2914 [(set_attr "type" "move,move,move,shift,load,store,move,move,fpalu")
2915 (set_attr "pa_combine_type" "addmove")
2916 (set_attr "length" "4,4,4,4,4,4,4,4,4")])
2917
2918 (define_insn ""
2919 [(set (match_operand:HI 0 "register_operand" "=r")
2920 (mem:HI (plus:SI (match_operand:SI 1 "register_operand" "+r")
2921 (match_operand:SI 2 "int5_operand" "L"))))
2922 (set (match_dup 1)
2923 (plus:SI (match_dup 1) (match_dup 2)))]
2924 ""
2925 "{ldhs|ldh},mb %2(%1),%0"
2926 [(set_attr "type" "load")
2927 (set_attr "length" "4")])
2928
2929 (define_insn ""
2930 [(set (match_operand:HI 0 "register_operand" "=r")
2931 (mem:HI (plus:DI (match_operand:DI 1 "register_operand" "+r")
2932 (match_operand:DI 2 "int5_operand" "L"))))
2933 (set (match_dup 1)
2934 (plus:DI (match_dup 1) (match_dup 2)))]
2935 "TARGET_64BIT"
2936 "ldh,mb %2(%1),%0"
2937 [(set_attr "type" "load")
2938 (set_attr "length" "4")])
2939
2940 ; And a zero extended variant.
2941 (define_insn ""
2942 [(set (match_operand:DI 0 "register_operand" "=r")
2943 (zero_extend:DI (mem:HI
2944 (plus:DI
2945 (match_operand:DI 1 "register_operand" "+r")
2946 (match_operand:DI 2 "int5_operand" "L")))))
2947 (set (match_dup 1)
2948 (plus:DI (match_dup 1) (match_dup 2)))]
2949 "TARGET_64BIT"
2950 "ldh,mb %2(%1),%0"
2951 [(set_attr "type" "load")
2952 (set_attr "length" "4")])
2953
2954 (define_insn ""
2955 [(set (match_operand:SI 0 "register_operand" "=r")
2956 (zero_extend:SI (mem:HI
2957 (plus:SI
2958 (match_operand:SI 1 "register_operand" "+r")
2959 (match_operand:SI 2 "int5_operand" "L")))))
2960 (set (match_dup 1)
2961 (plus:SI (match_dup 1) (match_dup 2)))]
2962 ""
2963 "{ldhs|ldh},mb %2(%1),%0"
2964 [(set_attr "type" "load")
2965 (set_attr "length" "4")])
2966
2967 (define_insn ""
2968 [(set (match_operand:SI 0 "register_operand" "=r")
2969 (zero_extend:SI (mem:HI
2970 (plus:DI
2971 (match_operand:DI 1 "register_operand" "+r")
2972 (match_operand:DI 2 "int5_operand" "L")))))
2973 (set (match_dup 1)
2974 (plus:DI (match_dup 1) (match_dup 2)))]
2975 "TARGET_64BIT"
2976 "ldh,mb %2(%1),%0"
2977 [(set_attr "type" "load")
2978 (set_attr "length" "4")])
2979
2980 (define_insn ""
2981 [(set (mem:HI (plus:SI (match_operand:SI 0 "register_operand" "+r")
2982 (match_operand:SI 1 "int5_operand" "L")))
2983 (match_operand:HI 2 "reg_or_0_operand" "rM"))
2984 (set (match_dup 0)
2985 (plus:SI (match_dup 0) (match_dup 1)))]
2986 ""
2987 "{sths|sth},mb %r2,%1(%0)"
2988 [(set_attr "type" "store")
2989 (set_attr "length" "4")])
2990
2991 (define_insn ""
2992 [(set (mem:HI (plus:DI (match_operand:DI 0 "register_operand" "+r")
2993 (match_operand:DI 1 "int5_operand" "L")))
2994 (match_operand:HI 2 "reg_or_0_operand" "rM"))
2995 (set (match_dup 0)
2996 (plus:DI (match_dup 0) (match_dup 1)))]
2997 "TARGET_64BIT"
2998 "sth,mb %r2,%1(%0)"
2999 [(set_attr "type" "store")
3000 (set_attr "length" "4")])
3001
3002 (define_insn ""
3003 [(set (match_operand:HI 0 "register_operand" "=r")
3004 (plus:HI (match_operand:HI 1 "register_operand" "r")
3005 (match_operand 2 "const_int_operand" "J")))]
3006 ""
3007 "ldo %2(%1),%0"
3008 [(set_attr "type" "binary")
3009 (set_attr "pa_combine_type" "addmove")
3010 (set_attr "length" "4")])
3011
3012 (define_expand "movqi"
3013 [(set (match_operand:QI 0 "general_operand" "")
3014 (match_operand:QI 1 "general_operand" ""))]
3015 ""
3016 "
3017 {
3018 if (emit_move_sequence (operands, QImode, 0))
3019 DONE;
3020 }")
3021
3022 (define_insn ""
3023 [(set (match_operand:QI 0 "move_dest_operand"
3024 "=r,r,r,r,r,Q,!*q,!r,!*f")
3025 (match_operand:QI 1 "move_src_operand"
3026 "r,J,N,K,RQ,rM,!rM,!*q,!*fM"))]
3027 "register_operand (operands[0], QImode)
3028 || reg_or_0_operand (operands[1], QImode)"
3029 "@
3030 copy %1,%0
3031 ldi %1,%0
3032 ldil L'%1,%0
3033 {zdepi|depwi,z} %Z1,%0
3034 ldb%M1 %1,%0
3035 stb%M0 %r1,%0
3036 mtsar %r1
3037 {mfctl|mfctl,w} %%sar,%0
3038 fcpy,sgl %f1,%0"
3039 [(set_attr "type" "move,move,move,shift,load,store,move,move,fpalu")
3040 (set_attr "pa_combine_type" "addmove")
3041 (set_attr "length" "4,4,4,4,4,4,4,4,4")])
3042
3043 (define_insn ""
3044 [(set (match_operand:QI 0 "register_operand" "=r")
3045 (mem:QI (plus:SI (match_operand:SI 1 "register_operand" "+r")
3046 (match_operand:SI 2 "int5_operand" "L"))))
3047 (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
3048 ""
3049 "{ldbs|ldb},mb %2(%1),%0"
3050 [(set_attr "type" "load")
3051 (set_attr "length" "4")])
3052
3053 (define_insn ""
3054 [(set (match_operand:QI 0 "register_operand" "=r")
3055 (mem:QI (plus:DI (match_operand:DI 1 "register_operand" "+r")
3056 (match_operand:DI 2 "int5_operand" "L"))))
3057 (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3058 "TARGET_64BIT"
3059 "ldb,mb %2(%1),%0"
3060 [(set_attr "type" "load")
3061 (set_attr "length" "4")])
3062
3063 ; Now the same thing with zero extensions.
3064 (define_insn ""
3065 [(set (match_operand:DI 0 "register_operand" "=r")
3066 (zero_extend:DI (mem:QI (plus:DI
3067 (match_operand:DI 1 "register_operand" "+r")
3068 (match_operand:DI 2 "int5_operand" "L")))))
3069 (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3070 "TARGET_64BIT"
3071 "ldb,mb %2(%1),%0"
3072 [(set_attr "type" "load")
3073 (set_attr "length" "4")])
3074
3075 (define_insn ""
3076 [(set (match_operand:SI 0 "register_operand" "=r")
3077 (zero_extend:SI (mem:QI (plus:SI
3078 (match_operand:SI 1 "register_operand" "+r")
3079 (match_operand:SI 2 "int5_operand" "L")))))
3080 (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
3081 ""
3082 "{ldbs|ldb},mb %2(%1),%0"
3083 [(set_attr "type" "load")
3084 (set_attr "length" "4")])
3085
3086 (define_insn ""
3087 [(set (match_operand:SI 0 "register_operand" "=r")
3088 (zero_extend:SI (mem:QI (plus:DI
3089 (match_operand:DI 1 "register_operand" "+r")
3090 (match_operand:DI 2 "int5_operand" "L")))))
3091 (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3092 "TARGET_64BIT"
3093 "ldb,mb %2(%1),%0"
3094 [(set_attr "type" "load")
3095 (set_attr "length" "4")])
3096
3097 (define_insn ""
3098 [(set (match_operand:HI 0 "register_operand" "=r")
3099 (zero_extend:HI (mem:QI (plus:SI
3100 (match_operand:SI 1 "register_operand" "+r")
3101 (match_operand:SI 2 "int5_operand" "L")))))
3102 (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
3103 ""
3104 "{ldbs|ldb},mb %2(%1),%0"
3105 [(set_attr "type" "load")
3106 (set_attr "length" "4")])
3107
3108 (define_insn ""
3109 [(set (match_operand:HI 0 "register_operand" "=r")
3110 (zero_extend:HI (mem:QI (plus:DI
3111 (match_operand:DI 1 "register_operand" "+r")
3112 (match_operand:DI 2 "int5_operand" "L")))))
3113 (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3114 "TARGET_64BIT"
3115 "ldb,mb %2(%1),%0"
3116 [(set_attr "type" "load")
3117 (set_attr "length" "4")])
3118
3119 (define_insn ""
3120 [(set (mem:QI (plus:SI (match_operand:SI 0 "register_operand" "+r")
3121 (match_operand:SI 1 "int5_operand" "L")))
3122 (match_operand:QI 2 "reg_or_0_operand" "rM"))
3123 (set (match_dup 0)
3124 (plus:SI (match_dup 0) (match_dup 1)))]
3125 ""
3126 "{stbs|stb},mb %r2,%1(%0)"
3127 [(set_attr "type" "store")
3128 (set_attr "length" "4")])
3129
3130 (define_insn ""
3131 [(set (mem:QI (plus:DI (match_operand:DI 0 "register_operand" "+r")
3132 (match_operand:DI 1 "int5_operand" "L")))
3133 (match_operand:QI 2 "reg_or_0_operand" "rM"))
3134 (set (match_dup 0)
3135 (plus:DI (match_dup 0) (match_dup 1)))]
3136 "TARGET_64BIT"
3137 "stb,mb %r2,%1(%0)"
3138 [(set_attr "type" "store")
3139 (set_attr "length" "4")])
3140
3141 ;; The definition of this insn does not really explain what it does,
3142 ;; but it should suffice that anything generated as this insn will be
3143 ;; recognized as a movmemsi operation, and that it will not successfully
3144 ;; combine with anything.
3145 (define_expand "movmemsi"
3146 [(parallel [(set (match_operand:BLK 0 "" "")
3147 (match_operand:BLK 1 "" ""))
3148 (clobber (match_dup 4))
3149 (clobber (match_dup 5))
3150 (clobber (match_dup 6))
3151 (clobber (match_dup 7))
3152 (clobber (match_dup 8))
3153 (use (match_operand:SI 2 "arith_operand" ""))
3154 (use (match_operand:SI 3 "const_int_operand" ""))])]
3155 "!TARGET_64BIT && optimize > 0"
3156 "
3157 {
3158 int size, align;
3159
3160 /* HP provides very fast block move library routine for the PA;
3161 this routine includes:
3162
3163 4x4 byte at a time block moves,
3164 1x4 byte at a time with alignment checked at runtime with
3165 attempts to align the source and destination as needed
3166 1x1 byte loop
3167
3168 With that in mind, here's the heuristics to try and guess when
3169 the inlined block move will be better than the library block
3170 move:
3171
3172 If the size isn't constant, then always use the library routines.
3173
3174 If the size is large in respect to the known alignment, then use
3175 the library routines.
3176
3177 If the size is small in respect to the known alignment, then open
3178 code the copy (since that will lead to better scheduling).
3179
3180 Else use the block move pattern. */
3181
3182 /* Undetermined size, use the library routine. */
3183 if (GET_CODE (operands[2]) != CONST_INT)
3184 FAIL;
3185
3186 size = INTVAL (operands[2]);
3187 align = INTVAL (operands[3]);
3188 align = align > 4 ? 4 : align;
3189
3190 /* If size/alignment is large, then use the library routines. */
3191 if (size / align > 16)
3192 FAIL;
3193
3194 /* This does happen, but not often enough to worry much about. */
3195 if (size / align < MOVE_RATIO)
3196 FAIL;
3197
3198 /* Fall through means we're going to use our block move pattern. */
3199 operands[0]
3200 = replace_equiv_address (operands[0],
3201 copy_to_mode_reg (SImode, XEXP (operands[0], 0)));
3202 operands[1]
3203 = replace_equiv_address (operands[1],
3204 copy_to_mode_reg (SImode, XEXP (operands[1], 0)));
3205 operands[4] = gen_reg_rtx (SImode);
3206 operands[5] = gen_reg_rtx (SImode);
3207 operands[6] = gen_reg_rtx (SImode);
3208 operands[7] = gen_reg_rtx (SImode);
3209 operands[8] = gen_reg_rtx (SImode);
3210 }")
3211
3212 ;; The operand constraints are written like this to support both compile-time
3213 ;; and run-time determined byte counts. The expander and output_block_move
3214 ;; only support compile-time determined counts at this time.
3215 ;;
3216 ;; If the count is run-time determined, the register with the byte count
3217 ;; is clobbered by the copying code, and therefore it is forced to operand 2.
3218 ;;
3219 ;; We used to clobber operands 0 and 1. However, a change to regrename.c
3220 ;; broke this semantic for pseudo registers. We can't use match_scratch
3221 ;; as this requires two registers in the class R1_REGS when the MEMs for
3222 ;; operands 0 and 1 are both equivalent to symbolic MEMs. Thus, we are
3223 ;; forced to internally copy operands 0 and 1 to operands 7 and 8,
3224 ;; respectively. We then split or peephole optimize after reload.
3225 (define_insn "movmemsi_prereload"
3226 [(set (mem:BLK (match_operand:SI 0 "register_operand" "r,r"))
3227 (mem:BLK (match_operand:SI 1 "register_operand" "r,r")))
3228 (clobber (match_operand:SI 2 "register_operand" "=&r,&r")) ;loop cnt/tmp
3229 (clobber (match_operand:SI 3 "register_operand" "=&r,&r")) ;item tmp1
3230 (clobber (match_operand:SI 6 "register_operand" "=&r,&r")) ;item tmp2
3231 (clobber (match_operand:SI 7 "register_operand" "=&r,&r")) ;item tmp3
3232 (clobber (match_operand:SI 8 "register_operand" "=&r,&r")) ;item tmp4
3233 (use (match_operand:SI 4 "arith_operand" "J,2")) ;byte count
3234 (use (match_operand:SI 5 "const_int_operand" "n,n"))] ;alignment
3235 "!TARGET_64BIT"
3236 "#"
3237 [(set_attr "type" "multi,multi")])
3238
3239 (define_split
3240 [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3241 (match_operand:BLK 1 "memory_operand" ""))
3242 (clobber (match_operand:SI 2 "register_operand" ""))
3243 (clobber (match_operand:SI 3 "register_operand" ""))
3244 (clobber (match_operand:SI 6 "register_operand" ""))
3245 (clobber (match_operand:SI 7 "register_operand" ""))
3246 (clobber (match_operand:SI 8 "register_operand" ""))
3247 (use (match_operand:SI 4 "arith_operand" ""))
3248 (use (match_operand:SI 5 "const_int_operand" ""))])]
3249 "!TARGET_64BIT && reload_completed && !flag_peephole2
3250 && GET_CODE (operands[0]) == MEM
3251 && register_operand (XEXP (operands[0], 0), SImode)
3252 && GET_CODE (operands[1]) == MEM
3253 && register_operand (XEXP (operands[1], 0), SImode)"
3254 [(set (match_dup 7) (match_dup 9))
3255 (set (match_dup 8) (match_dup 10))
3256 (parallel [(set (match_dup 0) (match_dup 1))
3257 (clobber (match_dup 2))
3258 (clobber (match_dup 3))
3259 (clobber (match_dup 6))
3260 (clobber (match_dup 7))
3261 (clobber (match_dup 8))
3262 (use (match_dup 4))
3263 (use (match_dup 5))
3264 (const_int 0)])]
3265 "
3266 {
3267 operands[9] = XEXP (operands[0], 0);
3268 operands[10] = XEXP (operands[1], 0);
3269 operands[0] = replace_equiv_address (operands[0], operands[7]);
3270 operands[1] = replace_equiv_address (operands[1], operands[8]);
3271 }")
3272
3273 (define_peephole2
3274 [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3275 (match_operand:BLK 1 "memory_operand" ""))
3276 (clobber (match_operand:SI 2 "register_operand" ""))
3277 (clobber (match_operand:SI 3 "register_operand" ""))
3278 (clobber (match_operand:SI 6 "register_operand" ""))
3279 (clobber (match_operand:SI 7 "register_operand" ""))
3280 (clobber (match_operand:SI 8 "register_operand" ""))
3281 (use (match_operand:SI 4 "arith_operand" ""))
3282 (use (match_operand:SI 5 "const_int_operand" ""))])]
3283 "!TARGET_64BIT
3284 && GET_CODE (operands[0]) == MEM
3285 && register_operand (XEXP (operands[0], 0), SImode)
3286 && GET_CODE (operands[1]) == MEM
3287 && register_operand (XEXP (operands[1], 0), SImode)"
3288 [(parallel [(set (match_dup 0) (match_dup 1))
3289 (clobber (match_dup 2))
3290 (clobber (match_dup 3))
3291 (clobber (match_dup 6))
3292 (clobber (match_dup 7))
3293 (clobber (match_dup 8))
3294 (use (match_dup 4))
3295 (use (match_dup 5))
3296 (const_int 0)])]
3297 "
3298 {
3299 rtx addr = XEXP (operands[0], 0);
3300 if (dead_or_set_p (curr_insn, addr))
3301 operands[7] = addr;
3302 else
3303 {
3304 emit_insn (gen_rtx_SET (VOIDmode, operands[7], addr));
3305 operands[0] = replace_equiv_address (operands[0], operands[7]);
3306 }
3307
3308 addr = XEXP (operands[1], 0);
3309 if (dead_or_set_p (curr_insn, addr))
3310 operands[8] = addr;
3311 else
3312 {
3313 emit_insn (gen_rtx_SET (VOIDmode, operands[8], addr));
3314 operands[1] = replace_equiv_address (operands[1], operands[8]);
3315 }
3316 }")
3317
3318 (define_insn "movmemsi_postreload"
3319 [(set (mem:BLK (match_operand:SI 0 "register_operand" "+r,r"))
3320 (mem:BLK (match_operand:SI 1 "register_operand" "+r,r")))
3321 (clobber (match_operand:SI 2 "register_operand" "=&r,&r")) ;loop cnt/tmp
3322 (clobber (match_operand:SI 3 "register_operand" "=&r,&r")) ;item tmp1
3323 (clobber (match_operand:SI 6 "register_operand" "=&r,&r")) ;item tmp2
3324 (clobber (match_dup 0))
3325 (clobber (match_dup 1))
3326 (use (match_operand:SI 4 "arith_operand" "J,2")) ;byte count
3327 (use (match_operand:SI 5 "const_int_operand" "n,n")) ;alignment
3328 (const_int 0)]
3329 "!TARGET_64BIT && reload_completed"
3330 "* return output_block_move (operands, !which_alternative);"
3331 [(set_attr "type" "multi,multi")])
3332
3333 (define_expand "movmemdi"
3334 [(parallel [(set (match_operand:BLK 0 "" "")
3335 (match_operand:BLK 1 "" ""))
3336 (clobber (match_dup 4))
3337 (clobber (match_dup 5))
3338 (clobber (match_dup 6))
3339 (clobber (match_dup 7))
3340 (clobber (match_dup 8))
3341 (use (match_operand:DI 2 "arith_operand" ""))
3342 (use (match_operand:DI 3 "const_int_operand" ""))])]
3343 "TARGET_64BIT && optimize > 0"
3344 "
3345 {
3346 int size, align;
3347
3348 /* HP provides very fast block move library routine for the PA;
3349 this routine includes:
3350
3351 4x4 byte at a time block moves,
3352 1x4 byte at a time with alignment checked at runtime with
3353 attempts to align the source and destination as needed
3354 1x1 byte loop
3355
3356 With that in mind, here's the heuristics to try and guess when
3357 the inlined block move will be better than the library block
3358 move:
3359
3360 If the size isn't constant, then always use the library routines.
3361
3362 If the size is large in respect to the known alignment, then use
3363 the library routines.
3364
3365 If the size is small in respect to the known alignment, then open
3366 code the copy (since that will lead to better scheduling).
3367
3368 Else use the block move pattern. */
3369
3370 /* Undetermined size, use the library routine. */
3371 if (GET_CODE (operands[2]) != CONST_INT)
3372 FAIL;
3373
3374 size = INTVAL (operands[2]);
3375 align = INTVAL (operands[3]);
3376 align = align > 8 ? 8 : align;
3377
3378 /* If size/alignment is large, then use the library routines. */
3379 if (size / align > 16)
3380 FAIL;
3381
3382 /* This does happen, but not often enough to worry much about. */
3383 if (size / align < MOVE_RATIO)
3384 FAIL;
3385
3386 /* Fall through means we're going to use our block move pattern. */
3387 operands[0]
3388 = replace_equiv_address (operands[0],
3389 copy_to_mode_reg (DImode, XEXP (operands[0], 0)));
3390 operands[1]
3391 = replace_equiv_address (operands[1],
3392 copy_to_mode_reg (DImode, XEXP (operands[1], 0)));
3393 operands[4] = gen_reg_rtx (DImode);
3394 operands[5] = gen_reg_rtx (DImode);
3395 operands[6] = gen_reg_rtx (DImode);
3396 operands[7] = gen_reg_rtx (DImode);
3397 operands[8] = gen_reg_rtx (DImode);
3398 }")
3399
3400 ;; The operand constraints are written like this to support both compile-time
3401 ;; and run-time determined byte counts. The expander and output_block_move
3402 ;; only support compile-time determined counts at this time.
3403 ;;
3404 ;; If the count is run-time determined, the register with the byte count
3405 ;; is clobbered by the copying code, and therefore it is forced to operand 2.
3406 ;;
3407 ;; We used to clobber operands 0 and 1. However, a change to regrename.c
3408 ;; broke this semantic for pseudo registers. We can't use match_scratch
3409 ;; as this requires two registers in the class R1_REGS when the MEMs for
3410 ;; operands 0 and 1 are both equivalent to symbolic MEMs. Thus, we are
3411 ;; forced to internally copy operands 0 and 1 to operands 7 and 8,
3412 ;; respectively. We then split or peephole optimize after reload.
3413 (define_insn "movmemdi_prereload"
3414 [(set (mem:BLK (match_operand:DI 0 "register_operand" "r,r"))
3415 (mem:BLK (match_operand:DI 1 "register_operand" "r,r")))
3416 (clobber (match_operand:DI 2 "register_operand" "=&r,&r")) ;loop cnt/tmp
3417 (clobber (match_operand:DI 3 "register_operand" "=&r,&r")) ;item tmp1
3418 (clobber (match_operand:DI 6 "register_operand" "=&r,&r")) ;item tmp2
3419 (clobber (match_operand:DI 7 "register_operand" "=&r,&r")) ;item tmp3
3420 (clobber (match_operand:DI 8 "register_operand" "=&r,&r")) ;item tmp4
3421 (use (match_operand:DI 4 "arith_operand" "J,2")) ;byte count
3422 (use (match_operand:DI 5 "const_int_operand" "n,n"))] ;alignment
3423 "TARGET_64BIT"
3424 "#"
3425 [(set_attr "type" "multi,multi")])
3426
3427 (define_split
3428 [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3429 (match_operand:BLK 1 "memory_operand" ""))
3430 (clobber (match_operand:DI 2 "register_operand" ""))
3431 (clobber (match_operand:DI 3 "register_operand" ""))
3432 (clobber (match_operand:DI 6 "register_operand" ""))
3433 (clobber (match_operand:DI 7 "register_operand" ""))
3434 (clobber (match_operand:DI 8 "register_operand" ""))
3435 (use (match_operand:DI 4 "arith_operand" ""))
3436 (use (match_operand:DI 5 "const_int_operand" ""))])]
3437 "TARGET_64BIT && reload_completed && !flag_peephole2
3438 && GET_CODE (operands[0]) == MEM
3439 && register_operand (XEXP (operands[0], 0), DImode)
3440 && GET_CODE (operands[1]) == MEM
3441 && register_operand (XEXP (operands[1], 0), DImode)"
3442 [(set (match_dup 7) (match_dup 9))
3443 (set (match_dup 8) (match_dup 10))
3444 (parallel [(set (match_dup 0) (match_dup 1))
3445 (clobber (match_dup 2))
3446 (clobber (match_dup 3))
3447 (clobber (match_dup 6))
3448 (clobber (match_dup 7))
3449 (clobber (match_dup 8))
3450 (use (match_dup 4))
3451 (use (match_dup 5))
3452 (const_int 0)])]
3453 "
3454 {
3455 operands[9] = XEXP (operands[0], 0);
3456 operands[10] = XEXP (operands[1], 0);
3457 operands[0] = replace_equiv_address (operands[0], operands[7]);
3458 operands[1] = replace_equiv_address (operands[1], operands[8]);
3459 }")
3460
3461 (define_peephole2
3462 [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3463 (match_operand:BLK 1 "memory_operand" ""))
3464 (clobber (match_operand:DI 2 "register_operand" ""))
3465 (clobber (match_operand:DI 3 "register_operand" ""))
3466 (clobber (match_operand:DI 6 "register_operand" ""))
3467 (clobber (match_operand:DI 7 "register_operand" ""))
3468 (clobber (match_operand:DI 8 "register_operand" ""))
3469 (use (match_operand:DI 4 "arith_operand" ""))
3470 (use (match_operand:DI 5 "const_int_operand" ""))])]
3471 "TARGET_64BIT
3472 && GET_CODE (operands[0]) == MEM
3473 && register_operand (XEXP (operands[0], 0), DImode)
3474 && GET_CODE (operands[1]) == MEM
3475 && register_operand (XEXP (operands[1], 0), DImode)"
3476 [(parallel [(set (match_dup 0) (match_dup 1))
3477 (clobber (match_dup 2))
3478 (clobber (match_dup 3))
3479 (clobber (match_dup 6))
3480 (clobber (match_dup 7))
3481 (clobber (match_dup 8))
3482 (use (match_dup 4))
3483 (use (match_dup 5))
3484 (const_int 0)])]
3485 "
3486 {
3487 rtx addr = XEXP (operands[0], 0);
3488 if (dead_or_set_p (curr_insn, addr))
3489 operands[7] = addr;
3490 else
3491 {
3492 emit_insn (gen_rtx_SET (VOIDmode, operands[7], addr));
3493 operands[0] = replace_equiv_address (operands[0], operands[7]);
3494 }
3495
3496 addr = XEXP (operands[1], 0);
3497 if (dead_or_set_p (curr_insn, addr))
3498 operands[8] = addr;
3499 else
3500 {
3501 emit_insn (gen_rtx_SET (VOIDmode, operands[8], addr));
3502 operands[1] = replace_equiv_address (operands[1], operands[8]);
3503 }
3504 }")
3505
3506 (define_insn "movmemdi_postreload"
3507 [(set (mem:BLK (match_operand:DI 0 "register_operand" "+r,r"))
3508 (mem:BLK (match_operand:DI 1 "register_operand" "+r,r")))
3509 (clobber (match_operand:DI 2 "register_operand" "=&r,&r")) ;loop cnt/tmp
3510 (clobber (match_operand:DI 3 "register_operand" "=&r,&r")) ;item tmp1
3511 (clobber (match_operand:DI 6 "register_operand" "=&r,&r")) ;item tmp2
3512 (clobber (match_dup 0))
3513 (clobber (match_dup 1))
3514 (use (match_operand:DI 4 "arith_operand" "J,2")) ;byte count
3515 (use (match_operand:DI 5 "const_int_operand" "n,n")) ;alignment
3516 (const_int 0)]
3517 "TARGET_64BIT && reload_completed"
3518 "* return output_block_move (operands, !which_alternative);"
3519 [(set_attr "type" "multi,multi")])
3520
3521 (define_expand "clrmemsi"
3522 [(parallel [(set (match_operand:BLK 0 "" "")
3523 (const_int 0))
3524 (clobber (match_dup 3))
3525 (clobber (match_dup 4))
3526 (use (match_operand:SI 1 "arith_operand" ""))
3527 (use (match_operand:SI 2 "const_int_operand" ""))])]
3528 "!TARGET_64BIT && optimize > 0"
3529 "
3530 {
3531 int size, align;
3532
3533 /* Undetermined size, use the library routine. */
3534 if (GET_CODE (operands[1]) != CONST_INT)
3535 FAIL;
3536
3537 size = INTVAL (operands[1]);
3538 align = INTVAL (operands[2]);
3539 align = align > 4 ? 4 : align;
3540
3541 /* If size/alignment is large, then use the library routines. */
3542 if (size / align > 16)
3543 FAIL;
3544
3545 /* This does happen, but not often enough to worry much about. */
3546 if (size / align < MOVE_RATIO)
3547 FAIL;
3548
3549 /* Fall through means we're going to use our block clear pattern. */
3550 operands[0]
3551 = replace_equiv_address (operands[0],
3552 copy_to_mode_reg (SImode, XEXP (operands[0], 0)));
3553 operands[3] = gen_reg_rtx (SImode);
3554 operands[4] = gen_reg_rtx (SImode);
3555 }")
3556
3557 (define_insn "clrmemsi_prereload"
3558 [(set (mem:BLK (match_operand:SI 0 "register_operand" "r,r"))
3559 (const_int 0))
3560 (clobber (match_operand:SI 1 "register_operand" "=&r,&r")) ;loop cnt/tmp
3561 (clobber (match_operand:SI 4 "register_operand" "=&r,&r")) ;tmp1
3562 (use (match_operand:SI 2 "arith_operand" "J,1")) ;byte count
3563 (use (match_operand:SI 3 "const_int_operand" "n,n"))] ;alignment
3564 "!TARGET_64BIT"
3565 "#"
3566 [(set_attr "type" "multi,multi")])
3567
3568 (define_split
3569 [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3570 (const_int 0))
3571 (clobber (match_operand:SI 1 "register_operand" ""))
3572 (clobber (match_operand:SI 4 "register_operand" ""))
3573 (use (match_operand:SI 2 "arith_operand" ""))
3574 (use (match_operand:SI 3 "const_int_operand" ""))])]
3575 "!TARGET_64BIT && reload_completed && !flag_peephole2
3576 && GET_CODE (operands[0]) == MEM
3577 && register_operand (XEXP (operands[0], 0), SImode)"
3578 [(set (match_dup 4) (match_dup 5))
3579 (parallel [(set (match_dup 0) (const_int 0))
3580 (clobber (match_dup 1))
3581 (clobber (match_dup 4))
3582 (use (match_dup 2))
3583 (use (match_dup 3))
3584 (const_int 0)])]
3585 "
3586 {
3587 operands[5] = XEXP (operands[0], 0);
3588 operands[0] = replace_equiv_address (operands[0], operands[4]);
3589 }")
3590
3591 (define_peephole2
3592 [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3593 (const_int 0))
3594 (clobber (match_operand:SI 1 "register_operand" ""))
3595 (clobber (match_operand:SI 4 "register_operand" ""))
3596 (use (match_operand:SI 2 "arith_operand" ""))
3597 (use (match_operand:SI 3 "const_int_operand" ""))])]
3598 "!TARGET_64BIT
3599 && GET_CODE (operands[0]) == MEM
3600 && register_operand (XEXP (operands[0], 0), SImode)"
3601 [(parallel [(set (match_dup 0) (const_int 0))
3602 (clobber (match_dup 1))
3603 (clobber (match_dup 4))
3604 (use (match_dup 2))
3605 (use (match_dup 3))
3606 (const_int 0)])]
3607 "
3608 {
3609 rtx addr = XEXP (operands[0], 0);
3610 if (dead_or_set_p (curr_insn, addr))
3611 operands[4] = addr;
3612 else
3613 {
3614 emit_insn (gen_rtx_SET (VOIDmode, operands[4], addr));
3615 operands[0] = replace_equiv_address (operands[0], operands[4]);
3616 }
3617 }")
3618
3619 (define_insn "clrmemsi_postreload"
3620 [(set (mem:BLK (match_operand:SI 0 "register_operand" "+r,r"))
3621 (const_int 0))
3622 (clobber (match_operand:SI 1 "register_operand" "=&r,&r")) ;loop cnt/tmp
3623 (clobber (match_dup 0))
3624 (use (match_operand:SI 2 "arith_operand" "J,1")) ;byte count
3625 (use (match_operand:SI 3 "const_int_operand" "n,n")) ;alignment
3626 (const_int 0)]
3627 "!TARGET_64BIT && reload_completed"
3628 "* return output_block_clear (operands, !which_alternative);"
3629 [(set_attr "type" "multi,multi")])
3630
3631 (define_expand "clrmemdi"
3632 [(parallel [(set (match_operand:BLK 0 "" "")
3633 (const_int 0))
3634 (clobber (match_dup 3))
3635 (clobber (match_dup 4))
3636 (use (match_operand:DI 1 "arith_operand" ""))
3637 (use (match_operand:DI 2 "const_int_operand" ""))])]
3638 "TARGET_64BIT && optimize > 0"
3639 "
3640 {
3641 int size, align;
3642
3643 /* Undetermined size, use the library routine. */
3644 if (GET_CODE (operands[1]) != CONST_INT)
3645 FAIL;
3646
3647 size = INTVAL (operands[1]);
3648 align = INTVAL (operands[2]);
3649 align = align > 8 ? 8 : align;
3650
3651 /* If size/alignment is large, then use the library routines. */
3652 if (size / align > 16)
3653 FAIL;
3654
3655 /* This does happen, but not often enough to worry much about. */
3656 if (size / align < MOVE_RATIO)
3657 FAIL;
3658
3659 /* Fall through means we're going to use our block clear pattern. */
3660 operands[0]
3661 = replace_equiv_address (operands[0],
3662 copy_to_mode_reg (DImode, XEXP (operands[0], 0)));
3663 operands[3] = gen_reg_rtx (DImode);
3664 operands[4] = gen_reg_rtx (DImode);
3665 }")
3666
3667 (define_insn "clrmemdi_prereload"
3668 [(set (mem:BLK (match_operand:DI 0 "register_operand" "r,r"))
3669 (const_int 0))
3670 (clobber (match_operand:DI 1 "register_operand" "=&r,&r")) ;loop cnt/tmp
3671 (clobber (match_operand:DI 4 "register_operand" "=&r,&r")) ;item tmp1
3672 (use (match_operand:DI 2 "arith_operand" "J,1")) ;byte count
3673 (use (match_operand:DI 3 "const_int_operand" "n,n"))] ;alignment
3674 "TARGET_64BIT"
3675 "#"
3676 [(set_attr "type" "multi,multi")])
3677
3678 (define_split
3679 [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3680 (const_int 0))
3681 (clobber (match_operand:DI 1 "register_operand" ""))
3682 (clobber (match_operand:DI 4 "register_operand" ""))
3683 (use (match_operand:DI 2 "arith_operand" ""))
3684 (use (match_operand:DI 3 "const_int_operand" ""))])]
3685 "TARGET_64BIT && reload_completed && !flag_peephole2
3686 && GET_CODE (operands[0]) == MEM
3687 && register_operand (XEXP (operands[0], 0), DImode)"
3688 [(set (match_dup 4) (match_dup 5))
3689 (parallel [(set (match_dup 0) (const_int 0))
3690 (clobber (match_dup 1))
3691 (clobber (match_dup 4))
3692 (use (match_dup 2))
3693 (use (match_dup 3))
3694 (const_int 0)])]
3695 "
3696 {
3697 operands[5] = XEXP (operands[0], 0);
3698 operands[0] = replace_equiv_address (operands[0], operands[4]);
3699 }")
3700
3701 (define_peephole2
3702 [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3703 (const_int 0))
3704 (clobber (match_operand:DI 1 "register_operand" ""))
3705 (clobber (match_operand:DI 4 "register_operand" ""))
3706 (use (match_operand:DI 2 "arith_operand" ""))
3707 (use (match_operand:DI 3 "const_int_operand" ""))])]
3708 "TARGET_64BIT
3709 && GET_CODE (operands[0]) == MEM
3710 && register_operand (XEXP (operands[0], 0), DImode)"
3711 [(parallel [(set (match_dup 0) (const_int 0))
3712 (clobber (match_dup 1))
3713 (clobber (match_dup 4))
3714 (use (match_dup 2))
3715 (use (match_dup 3))
3716 (const_int 0)])]
3717 "
3718 {
3719 rtx addr = XEXP (operands[0], 0);
3720 if (dead_or_set_p (curr_insn, addr))
3721 operands[4] = addr;
3722 else
3723 {
3724 emit_insn (gen_rtx_SET (VOIDmode, operands[4], addr));
3725 operands[0] = replace_equiv_address (operands[0], operands[4]);
3726 }
3727 }")
3728
3729 (define_insn "clrmemdi_postreload"
3730 [(set (mem:BLK (match_operand:DI 0 "register_operand" "+r,r"))
3731 (const_int 0))
3732 (clobber (match_operand:DI 1 "register_operand" "=&r,&r")) ;loop cnt/tmp
3733 (clobber (match_dup 0))
3734 (use (match_operand:DI 2 "arith_operand" "J,1")) ;byte count
3735 (use (match_operand:DI 3 "const_int_operand" "n,n")) ;alignment
3736 (const_int 0)]
3737 "TARGET_64BIT && reload_completed"
3738 "* return output_block_clear (operands, !which_alternative);"
3739 [(set_attr "type" "multi,multi")])
3740 \f
3741 ;; Floating point move insns
3742
3743 ;; This pattern forces (set (reg:DF ...) (const_double ...))
3744 ;; to be reloaded by putting the constant into memory when
3745 ;; reg is a floating point register.
3746 ;;
3747 ;; For integer registers we use ldil;ldo to set the appropriate
3748 ;; value.
3749 ;;
3750 ;; This must come before the movdf pattern, and it must be present
3751 ;; to handle obscure reloading cases.
3752 (define_insn ""
3753 [(set (match_operand:DF 0 "register_operand" "=?r,f")
3754 (match_operand:DF 1 "" "?F,m"))]
3755 "GET_CODE (operands[1]) == CONST_DOUBLE
3756 && operands[1] != CONST0_RTX (DFmode)
3757 && !TARGET_64BIT
3758 && !TARGET_SOFT_FLOAT"
3759 "* return (which_alternative == 0 ? output_move_double (operands)
3760 : \"fldd%F1 %1,%0\");"
3761 [(set_attr "type" "move,fpload")
3762 (set_attr "length" "16,4")])
3763
3764 (define_expand "movdf"
3765 [(set (match_operand:DF 0 "general_operand" "")
3766 (match_operand:DF 1 "general_operand" ""))]
3767 ""
3768 "
3769 {
3770 if (GET_CODE (operands[1]) == CONST_DOUBLE && TARGET_64BIT)
3771 operands[1] = force_const_mem (DFmode, operands[1]);
3772
3773 if (emit_move_sequence (operands, DFmode, 0))
3774 DONE;
3775 }")
3776
3777 ;; Reloading an SImode or DImode value requires a scratch register if
3778 ;; going in to or out of float point registers.
3779
3780 (define_expand "reload_indf"
3781 [(set (match_operand:DF 0 "register_operand" "=Z")
3782 (match_operand:DF 1 "non_hard_reg_operand" ""))
3783 (clobber (match_operand:DF 2 "register_operand" "=&r"))]
3784 ""
3785 "
3786 {
3787 if (emit_move_sequence (operands, DFmode, operands[2]))
3788 DONE;
3789
3790 /* We don't want the clobber emitted, so handle this ourselves. */
3791 emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
3792 DONE;
3793 }")
3794
3795 (define_expand "reload_outdf"
3796 [(set (match_operand:DF 0 "non_hard_reg_operand" "")
3797 (match_operand:DF 1 "register_operand" "Z"))
3798 (clobber (match_operand:DF 2 "register_operand" "=&r"))]
3799 ""
3800 "
3801 {
3802 if (emit_move_sequence (operands, DFmode, operands[2]))
3803 DONE;
3804
3805 /* We don't want the clobber emitted, so handle this ourselves. */
3806 emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
3807 DONE;
3808 }")
3809
3810 (define_insn ""
3811 [(set (match_operand:DF 0 "move_dest_operand"
3812 "=f,*r,Q,?o,?Q,f,*r,*r")
3813 (match_operand:DF 1 "reg_or_0_or_nonsymb_mem_operand"
3814 "fG,*rG,f,*r,*r,RQ,o,RQ"))]
3815 "(register_operand (operands[0], DFmode)
3816 || reg_or_0_operand (operands[1], DFmode))
3817 && !(GET_CODE (operands[1]) == CONST_DOUBLE
3818 && GET_CODE (operands[0]) == MEM)
3819 && !TARGET_64BIT
3820 && !TARGET_SOFT_FLOAT"
3821 "*
3822 {
3823 if (FP_REG_P (operands[0]) || FP_REG_P (operands[1])
3824 || operands[1] == CONST0_RTX (DFmode))
3825 return output_fp_move_double (operands);
3826 return output_move_double (operands);
3827 }"
3828 [(set_attr "type" "fpalu,move,fpstore,store,store,fpload,load,load")
3829 (set_attr "length" "4,8,4,8,16,4,8,16")])
3830
3831 (define_insn ""
3832 [(set (match_operand:DF 0 "indexed_memory_operand" "=R")
3833 (match_operand:DF 1 "reg_or_0_operand" "f"))]
3834 "!TARGET_SOFT_FLOAT
3835 && !TARGET_DISABLE_INDEXING
3836 && reload_completed"
3837 "fstd%F0 %1,%0"
3838 [(set_attr "type" "fpstore")
3839 (set_attr "pa_combine_type" "addmove")
3840 (set_attr "length" "4")])
3841
3842 (define_peephole2
3843 [(set (match_operand:SI 0 "register_operand" "")
3844 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "")
3845 (const_int 8))
3846 (match_operand:SI 2 "register_operand" "")))
3847 (set (mem:DF (match_dup 0))
3848 (match_operand:DF 3 "register_operand" ""))]
3849 "!TARGET_SOFT_FLOAT
3850 && !TARGET_DISABLE_INDEXING
3851 && REG_OK_FOR_BASE_P (operands[2])
3852 && FP_REGNO_P (REGNO (operands[3]))"
3853 [(set (mem:DF (plus:SI (mult:SI (match_dup 1) (const_int 8)) (match_dup 2)))
3854 (match_dup 3))
3855 (set (match_dup 0) (plus:SI (mult:SI (match_dup 1) (const_int 8))
3856 (match_dup 2)))]
3857 "")
3858
3859 (define_peephole2
3860 [(set (match_operand:SI 0 "register_operand" "")
3861 (plus:SI (match_operand:SI 2 "register_operand" "")
3862 (mult:SI (match_operand:SI 1 "register_operand" "")
3863 (const_int 8))))
3864 (set (mem:DF (match_dup 0))
3865 (match_operand:DF 3 "register_operand" ""))]
3866 "!TARGET_SOFT_FLOAT
3867 && !TARGET_DISABLE_INDEXING
3868 && REG_OK_FOR_BASE_P (operands[2])
3869 && FP_REGNO_P (REGNO (operands[3]))"
3870 [(set (mem:DF (plus:SI (mult:SI (match_dup 1) (const_int 8)) (match_dup 2)))
3871 (match_dup 3))
3872 (set (match_dup 0) (plus:SI (mult:SI (match_dup 1) (const_int 8))
3873 (match_dup 2)))]
3874 "")
3875
3876 (define_peephole2
3877 [(set (match_operand:DI 0 "register_operand" "")
3878 (plus:DI (mult:DI (match_operand:DI 1 "register_operand" "")
3879 (const_int 8))
3880 (match_operand:DI 2 "register_operand" "")))
3881 (set (mem:DF (match_dup 0))
3882 (match_operand:DF 3 "register_operand" ""))]
3883 "!TARGET_SOFT_FLOAT
3884 && !TARGET_DISABLE_INDEXING
3885 && TARGET_64BIT
3886 && REG_OK_FOR_BASE_P (operands[2])
3887 && FP_REGNO_P (REGNO (operands[3]))"
3888 [(set (mem:DF (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
3889 (match_dup 3))
3890 (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 8))
3891 (match_dup 2)))]
3892 "")
3893
3894 (define_peephole2
3895 [(set (match_operand:DI 0 "register_operand" "")
3896 (plus:DI (match_operand:DI 2 "register_operand" "")
3897 (mult:DI (match_operand:DI 1 "register_operand" "")
3898 (const_int 8))))
3899 (set (mem:DF (match_dup 0))
3900 (match_operand:DF 3 "register_operand" ""))]
3901 "!TARGET_SOFT_FLOAT
3902 && !TARGET_DISABLE_INDEXING
3903 && TARGET_64BIT
3904 && REG_OK_FOR_BASE_P (operands[2])
3905 && FP_REGNO_P (REGNO (operands[3]))"
3906 [(set (mem:DF (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
3907 (match_dup 3))
3908 (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 8))
3909 (match_dup 2)))]
3910 "")
3911
3912 (define_peephole2
3913 [(set (match_operand:SI 0 "register_operand" "")
3914 (plus:SI (match_operand:SI 1 "register_operand" "")
3915 (match_operand:SI 2 "register_operand" "")))
3916 (set (mem:DF (match_dup 0))
3917 (match_operand:DF 3 "register_operand" ""))]
3918 "!TARGET_SOFT_FLOAT
3919 && !TARGET_DISABLE_INDEXING
3920 && REG_OK_FOR_BASE_P (operands[1])
3921 && (TARGET_NO_SPACE_REGS
3922 || (!REG_POINTER (operands[1]) && REG_POINTER (operands[2])))
3923 && FP_REGNO_P (REGNO (operands[3]))"
3924 [(set (mem:DF (plus:SI (match_dup 1) (match_dup 2)))
3925 (match_dup 3))
3926 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
3927 "")
3928
3929 (define_peephole2
3930 [(set (match_operand:SI 0 "register_operand" "")
3931 (plus:SI (match_operand:SI 1 "register_operand" "")
3932 (match_operand:SI 2 "register_operand" "")))
3933 (set (mem:DF (match_dup 0))
3934 (match_operand:DF 3 "register_operand" ""))]
3935 "!TARGET_SOFT_FLOAT
3936 && !TARGET_DISABLE_INDEXING
3937 && REG_OK_FOR_BASE_P (operands[2])
3938 && (TARGET_NO_SPACE_REGS
3939 || (REG_POINTER (operands[1]) && !REG_POINTER (operands[2])))
3940 && FP_REGNO_P (REGNO (operands[3]))"
3941 [(set (mem:DF (plus:SI (match_dup 2) (match_dup 1)))
3942 (match_dup 3))
3943 (set (match_dup 0) (plus:SI (match_dup 2) (match_dup 1)))]
3944 "")
3945
3946 (define_peephole2
3947 [(set (match_operand:DI 0 "register_operand" "")
3948 (plus:DI (match_operand:DI 1 "register_operand" "")
3949 (match_operand:DI 2 "register_operand" "")))
3950 (set (mem:DF (match_dup 0))
3951 (match_operand:DF 3 "register_operand" ""))]
3952 "!TARGET_SOFT_FLOAT
3953 && !TARGET_DISABLE_INDEXING
3954 && TARGET_64BIT
3955 && REG_OK_FOR_BASE_P (operands[1])
3956 && (TARGET_NO_SPACE_REGS
3957 || (!REG_POINTER (operands[1]) && REG_POINTER (operands[2])))
3958 && FP_REGNO_P (REGNO (operands[3]))"
3959 [(set (mem:DF (plus:DI (match_dup 1) (match_dup 2)))
3960 (match_dup 3))
3961 (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
3962 "")
3963
3964 (define_peephole2
3965 [(set (match_operand:DI 0 "register_operand" "")
3966 (plus:DI (match_operand:DI 1 "register_operand" "")
3967 (match_operand:DI 2 "register_operand" "")))
3968 (set (mem:DF (match_dup 0))
3969 (match_operand:DF 3 "register_operand" ""))]
3970 "!TARGET_SOFT_FLOAT
3971 && !TARGET_DISABLE_INDEXING
3972 && TARGET_64BIT
3973 && REG_OK_FOR_BASE_P (operands[2])
3974 && (TARGET_NO_SPACE_REGS
3975 || (REG_POINTER (operands[1]) && !REG_POINTER (operands[2])))
3976 && FP_REGNO_P (REGNO (operands[3]))"
3977 [(set (mem:DF (plus:DI (match_dup 2) (match_dup 1)))
3978 (match_dup 3))
3979 (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
3980 "")
3981
3982 (define_insn ""
3983 [(set (match_operand:DF 0 "move_dest_operand"
3984 "=r,?o,?Q,r,r")
3985 (match_operand:DF 1 "reg_or_0_or_nonsymb_mem_operand"
3986 "rG,r,r,o,RQ"))]
3987 "(register_operand (operands[0], DFmode)
3988 || reg_or_0_operand (operands[1], DFmode))
3989 && !TARGET_64BIT
3990 && TARGET_SOFT_FLOAT"
3991 "*
3992 {
3993 return output_move_double (operands);
3994 }"
3995 [(set_attr "type" "move,store,store,load,load")
3996 (set_attr "length" "8,8,16,8,16")])
3997
3998 (define_insn ""
3999 [(set (match_operand:DF 0 "move_dest_operand"
4000 "=!*r,*r,*r,*r,*r,Q,f,f,T")
4001 (match_operand:DF 1 "move_src_operand"
4002 "!*r,J,N,K,RQ,*rM,fM,RT,f"))]
4003 "(register_operand (operands[0], DFmode)
4004 || reg_or_0_operand (operands[1], DFmode))
4005 && !TARGET_SOFT_FLOAT && TARGET_64BIT"
4006 "@
4007 copy %1,%0
4008 ldi %1,%0
4009 ldil L'%1,%0
4010 depdi,z %z1,%0
4011 ldd%M1 %1,%0
4012 std%M0 %r1,%0
4013 fcpy,dbl %f1,%0
4014 fldd%F1 %1,%0
4015 fstd%F0 %1,%0"
4016 [(set_attr "type" "move,move,move,shift,load,store,fpalu,fpload,fpstore")
4017 (set_attr "pa_combine_type" "addmove")
4018 (set_attr "length" "4,4,4,4,4,4,4,4,4")])
4019
4020 \f
4021 (define_expand "movdi"
4022 [(set (match_operand:DI 0 "general_operand" "")
4023 (match_operand:DI 1 "general_operand" ""))]
4024 ""
4025 "
4026 {
4027 if (GET_CODE (operands[1]) == CONST_DOUBLE && TARGET_64BIT)
4028 operands[1] = force_const_mem (DImode, operands[1]);
4029
4030 if (emit_move_sequence (operands, DImode, 0))
4031 DONE;
4032 }")
4033
4034 (define_expand "reload_indi"
4035 [(set (match_operand:DI 0 "register_operand" "=Z")
4036 (match_operand:DI 1 "non_hard_reg_operand" ""))
4037 (clobber (match_operand:SI 2 "register_operand" "=&r"))]
4038 ""
4039 "
4040 {
4041 if (emit_move_sequence (operands, DImode, operands[2]))
4042 DONE;
4043
4044 /* We don't want the clobber emitted, so handle this ourselves. */
4045 emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
4046 DONE;
4047 }")
4048
4049 (define_expand "reload_outdi"
4050 [(set (match_operand:DI 0 "non_hard_reg_operand" "")
4051 (match_operand:DI 1 "register_operand" "Z"))
4052 (clobber (match_operand:SI 2 "register_operand" "=&r"))]
4053 ""
4054 "
4055 {
4056 if (emit_move_sequence (operands, DImode, operands[2]))
4057 DONE;
4058
4059 /* We don't want the clobber emitted, so handle this ourselves. */
4060 emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
4061 DONE;
4062 }")
4063
4064 (define_insn ""
4065 [(set (match_operand:DI 0 "register_operand" "=r")
4066 (high:DI (match_operand 1 "" "")))]
4067 "!TARGET_64BIT"
4068 "*
4069 {
4070 rtx op0 = operands[0];
4071 rtx op1 = operands[1];
4072
4073 if (GET_CODE (op1) == CONST_INT)
4074 {
4075 operands[0] = operand_subword (op0, 1, 0, DImode);
4076 output_asm_insn (\"ldil L'%1,%0\", operands);
4077
4078 operands[0] = operand_subword (op0, 0, 0, DImode);
4079 if (INTVAL (op1) < 0)
4080 output_asm_insn (\"ldi -1,%0\", operands);
4081 else
4082 output_asm_insn (\"ldi 0,%0\", operands);
4083 return \"\";
4084 }
4085 else if (GET_CODE (op1) == CONST_DOUBLE)
4086 {
4087 operands[0] = operand_subword (op0, 1, 0, DImode);
4088 operands[1] = GEN_INT (CONST_DOUBLE_LOW (op1));
4089 output_asm_insn (\"ldil L'%1,%0\", operands);
4090
4091 operands[0] = operand_subword (op0, 0, 0, DImode);
4092 operands[1] = GEN_INT (CONST_DOUBLE_HIGH (op1));
4093 output_asm_insn (singlemove_string (operands), operands);
4094 return \"\";
4095 }
4096 else
4097 abort ();
4098 }"
4099 [(set_attr "type" "move")
4100 (set_attr "length" "8")])
4101
4102 (define_insn ""
4103 [(set (match_operand:DI 0 "move_dest_operand"
4104 "=r,o,Q,r,r,r,*f,*f,T")
4105 (match_operand:DI 1 "general_operand"
4106 "rM,r,r,o*R,Q,i,*fM,RT,*f"))]
4107 "(register_operand (operands[0], DImode)
4108 || reg_or_0_operand (operands[1], DImode))
4109 && !TARGET_64BIT
4110 && !TARGET_SOFT_FLOAT"
4111 "*
4112 {
4113 if (FP_REG_P (operands[0]) || FP_REG_P (operands[1])
4114 || (operands[1] == CONST0_RTX (DImode)))
4115 return output_fp_move_double (operands);
4116 return output_move_double (operands);
4117 }"
4118 [(set_attr "type" "move,store,store,load,load,multi,fpalu,fpload,fpstore")
4119 (set_attr "length" "8,8,16,8,16,16,4,4,4")])
4120
4121 (define_insn ""
4122 [(set (match_operand:DI 0 "move_dest_operand"
4123 "=r,r,r,r,r,r,Q,!*q,!r,!*f,*f,T")
4124 (match_operand:DI 1 "move_src_operand"
4125 "A,r,J,N,K,RQ,rM,!rM,!*q,!*fM,RT,*f"))]
4126 "(register_operand (operands[0], DImode)
4127 || reg_or_0_operand (operands[1], DImode))
4128 && !TARGET_SOFT_FLOAT && TARGET_64BIT"
4129 "@
4130 ldd RT'%A1,%0
4131 copy %1,%0
4132 ldi %1,%0
4133 ldil L'%1,%0
4134 depdi,z %z1,%0
4135 ldd%M1 %1,%0
4136 std%M0 %r1,%0
4137 mtsar %r1
4138 {mfctl|mfctl,w} %%sar,%0
4139 fcpy,dbl %f1,%0
4140 fldd%F1 %1,%0
4141 fstd%F0 %1,%0"
4142 [(set_attr "type" "load,move,move,move,shift,load,store,move,move,fpalu,fpload,fpstore")
4143 (set_attr "pa_combine_type" "addmove")
4144 (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4")])
4145
4146 (define_insn ""
4147 [(set (match_operand:DI 0 "indexed_memory_operand" "=R")
4148 (match_operand:DI 1 "register_operand" "f"))]
4149 "!TARGET_SOFT_FLOAT
4150 && TARGET_64BIT
4151 && !TARGET_DISABLE_INDEXING
4152 && reload_completed"
4153 "fstd%F0 %1,%0"
4154 [(set_attr "type" "fpstore")
4155 (set_attr "pa_combine_type" "addmove")
4156 (set_attr "length" "4")])
4157
4158 (define_peephole2
4159 [(set (match_operand:DI 0 "register_operand" "")
4160 (plus:DI (mult:DI (match_operand:DI 1 "register_operand" "")
4161 (const_int 8))
4162 (match_operand:DI 2 "register_operand" "")))
4163 (set (mem:DI (match_dup 0))
4164 (match_operand:DI 3 "register_operand" ""))]
4165 "!TARGET_SOFT_FLOAT
4166 && !TARGET_DISABLE_INDEXING
4167 && TARGET_64BIT
4168 && REG_OK_FOR_BASE_P (operands[2])
4169 && FP_REGNO_P (REGNO (operands[3]))"
4170 [(set (mem:DI (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
4171 (match_dup 3))
4172 (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 8))
4173 (match_dup 2)))]
4174 "")
4175
4176 (define_peephole2
4177 [(set (match_operand:DI 0 "register_operand" "")
4178 (plus:DI (match_operand:DI 2 "register_operand" "")
4179 (mult:DI (match_operand:DI 1 "register_operand" "")
4180 (const_int 8))))
4181 (set (mem:DI (match_dup 0))
4182 (match_operand:DI 3 "register_operand" ""))]
4183 "!TARGET_SOFT_FLOAT
4184 && !TARGET_DISABLE_INDEXING
4185 && TARGET_64BIT
4186 && REG_OK_FOR_BASE_P (operands[2])
4187 && FP_REGNO_P (REGNO (operands[3]))"
4188 [(set (mem:DI (plus:DI (mult:DI (match_dup 1) (const_int 8)) (match_dup 2)))
4189 (match_dup 3))
4190 (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 8))
4191 (match_dup 2)))]
4192 "")
4193
4194 (define_peephole2
4195 [(set (match_operand:DI 0 "register_operand" "")
4196 (plus:DI (match_operand:DI 1 "register_operand" "")
4197 (match_operand:DI 2 "register_operand" "")))
4198 (set (mem:DI (match_dup 0))
4199 (match_operand:DI 3 "register_operand" ""))]
4200 "!TARGET_SOFT_FLOAT
4201 && !TARGET_DISABLE_INDEXING
4202 && TARGET_64BIT
4203 && REG_OK_FOR_BASE_P (operands[1])
4204 && (TARGET_NO_SPACE_REGS
4205 || (!REG_POINTER (operands[1]) && REG_POINTER (operands[2])))
4206 && FP_REGNO_P (REGNO (operands[3]))"
4207 [(set (mem:DI (plus:DI (match_dup 1) (match_dup 2)))
4208 (match_dup 3))
4209 (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
4210 "")
4211
4212 (define_peephole2
4213 [(set (match_operand:DI 0 "register_operand" "")
4214 (plus:DI (match_operand:DI 1 "register_operand" "")
4215 (match_operand:DI 2 "register_operand" "")))
4216 (set (mem:DI (match_dup 0))
4217 (match_operand:DI 3 "register_operand" ""))]
4218 "!TARGET_SOFT_FLOAT
4219 && !TARGET_DISABLE_INDEXING
4220 && TARGET_64BIT
4221 && REG_OK_FOR_BASE_P (operands[2])
4222 && (TARGET_NO_SPACE_REGS
4223 || (REG_POINTER (operands[1]) && !REG_POINTER (operands[2])))
4224 && FP_REGNO_P (REGNO (operands[3]))"
4225 [(set (mem:DI (plus:DI (match_dup 2) (match_dup 1)))
4226 (match_dup 3))
4227 (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
4228 "")
4229
4230 (define_insn ""
4231 [(set (match_operand:DI 0 "move_dest_operand"
4232 "=r,o,Q,r,r,r")
4233 (match_operand:DI 1 "general_operand"
4234 "rM,r,r,o,Q,i"))]
4235 "(register_operand (operands[0], DImode)
4236 || reg_or_0_operand (operands[1], DImode))
4237 && !TARGET_64BIT
4238 && TARGET_SOFT_FLOAT"
4239 "*
4240 {
4241 return output_move_double (operands);
4242 }"
4243 [(set_attr "type" "move,store,store,load,load,multi")
4244 (set_attr "length" "8,8,16,8,16,16")])
4245
4246 (define_insn ""
4247 [(set (match_operand:DI 0 "register_operand" "=r,&r")
4248 (lo_sum:DI (match_operand:DI 1 "register_operand" "0,r")
4249 (match_operand:DI 2 "immediate_operand" "i,i")))]
4250 "!TARGET_64BIT"
4251 "*
4252 {
4253 /* Don't output a 64 bit constant, since we can't trust the assembler to
4254 handle it correctly. */
4255 if (GET_CODE (operands[2]) == CONST_DOUBLE)
4256 operands[2] = GEN_INT (CONST_DOUBLE_LOW (operands[2]));
4257 if (which_alternative == 1)
4258 output_asm_insn (\"copy %1,%0\", operands);
4259 return \"ldo R'%G2(%R1),%R0\";
4260 }"
4261 [(set_attr "type" "move,move")
4262 (set_attr "length" "4,8")])
4263
4264 ;; This pattern forces (set (reg:SF ...) (const_double ...))
4265 ;; to be reloaded by putting the constant into memory when
4266 ;; reg is a floating point register.
4267 ;;
4268 ;; For integer registers we use ldil;ldo to set the appropriate
4269 ;; value.
4270 ;;
4271 ;; This must come before the movsf pattern, and it must be present
4272 ;; to handle obscure reloading cases.
4273 (define_insn ""
4274 [(set (match_operand:SF 0 "register_operand" "=?r,f")
4275 (match_operand:SF 1 "" "?F,m"))]
4276 "GET_CODE (operands[1]) == CONST_DOUBLE
4277 && operands[1] != CONST0_RTX (SFmode)
4278 && ! TARGET_SOFT_FLOAT"
4279 "* return (which_alternative == 0 ? singlemove_string (operands)
4280 : \" fldw%F1 %1,%0\");"
4281 [(set_attr "type" "move,fpload")
4282 (set_attr "length" "8,4")])
4283
4284 (define_expand "movsf"
4285 [(set (match_operand:SF 0 "general_operand" "")
4286 (match_operand:SF 1 "general_operand" ""))]
4287 ""
4288 "
4289 {
4290 if (emit_move_sequence (operands, SFmode, 0))
4291 DONE;
4292 }")
4293
4294 ;; Reloading an SImode or DImode value requires a scratch register if
4295 ;; going in to or out of float point registers.
4296
4297 (define_expand "reload_insf"
4298 [(set (match_operand:SF 0 "register_operand" "=Z")
4299 (match_operand:SF 1 "non_hard_reg_operand" ""))
4300 (clobber (match_operand:SF 2 "register_operand" "=&r"))]
4301 ""
4302 "
4303 {
4304 if (emit_move_sequence (operands, SFmode, operands[2]))
4305 DONE;
4306
4307 /* We don't want the clobber emitted, so handle this ourselves. */
4308 emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
4309 DONE;
4310 }")
4311
4312 (define_expand "reload_outsf"
4313 [(set (match_operand:SF 0 "non_hard_reg_operand" "")
4314 (match_operand:SF 1 "register_operand" "Z"))
4315 (clobber (match_operand:SF 2 "register_operand" "=&r"))]
4316 ""
4317 "
4318 {
4319 if (emit_move_sequence (operands, SFmode, operands[2]))
4320 DONE;
4321
4322 /* We don't want the clobber emitted, so handle this ourselves. */
4323 emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
4324 DONE;
4325 }")
4326
4327 (define_insn ""
4328 [(set (match_operand:SF 0 "move_dest_operand"
4329 "=f,!*r,f,*r,Q,Q")
4330 (match_operand:SF 1 "reg_or_0_or_nonsymb_mem_operand"
4331 "fG,!*rG,RQ,RQ,f,*rG"))]
4332 "(register_operand (operands[0], SFmode)
4333 || reg_or_0_operand (operands[1], SFmode))
4334 && !TARGET_SOFT_FLOAT"
4335 "@
4336 fcpy,sgl %f1,%0
4337 copy %r1,%0
4338 fldw%F1 %1,%0
4339 ldw%M1 %1,%0
4340 fstw%F0 %1,%0
4341 stw%M0 %r1,%0"
4342 [(set_attr "type" "fpalu,move,fpload,load,fpstore,store")
4343 (set_attr "pa_combine_type" "addmove")
4344 (set_attr "length" "4,4,4,4,4,4")])
4345
4346 (define_insn ""
4347 [(set (match_operand:SF 0 "indexed_memory_operand" "=R")
4348 (match_operand:SF 1 "register_operand" "f"))]
4349 "!TARGET_SOFT_FLOAT
4350 && !TARGET_DISABLE_INDEXING
4351 && reload_completed"
4352 "fstw%F0 %1,%0"
4353 [(set_attr "type" "fpstore")
4354 (set_attr "pa_combine_type" "addmove")
4355 (set_attr "length" "4")])
4356
4357 (define_peephole2
4358 [(set (match_operand:SI 0 "register_operand" "")
4359 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "")
4360 (const_int 4))
4361 (match_operand:SI 2 "register_operand" "")))
4362 (set (mem:SF (match_dup 0))
4363 (match_operand:SF 3 "register_operand" ""))]
4364 "!TARGET_SOFT_FLOAT
4365 && !TARGET_DISABLE_INDEXING
4366 && REG_OK_FOR_BASE_P (operands[2])
4367 && FP_REGNO_P (REGNO (operands[3]))"
4368 [(set (mem:SF (plus:SI (mult:SI (match_dup 1) (const_int 4)) (match_dup 2)))
4369 (match_dup 3))
4370 (set (match_dup 0) (plus:SI (mult:SI (match_dup 1) (const_int 4))
4371 (match_dup 2)))]
4372 "")
4373
4374 (define_peephole2
4375 [(set (match_operand:SI 0 "register_operand" "")
4376 (plus:SI (match_operand:SI 2 "register_operand" "")
4377 (mult:SI (match_operand:SI 1 "register_operand" "")
4378 (const_int 4))))
4379 (set (mem:SF (match_dup 0))
4380 (match_operand:SF 3 "register_operand" ""))]
4381 "!TARGET_SOFT_FLOAT
4382 && !TARGET_DISABLE_INDEXING
4383 && REG_OK_FOR_BASE_P (operands[2])
4384 && FP_REGNO_P (REGNO (operands[3]))"
4385 [(set (mem:SF (plus:SI (mult:SI (match_dup 1) (const_int 4)) (match_dup 2)))
4386 (match_dup 3))
4387 (set (match_dup 0) (plus:SI (mult:SI (match_dup 1) (const_int 4))
4388 (match_dup 2)))]
4389 "")
4390
4391 (define_peephole2
4392 [(set (match_operand:DI 0 "register_operand" "")
4393 (plus:DI (mult:DI (match_operand:DI 1 "register_operand" "")
4394 (const_int 4))
4395 (match_operand:DI 2 "register_operand" "")))
4396 (set (mem:SF (match_dup 0))
4397 (match_operand:SF 3 "register_operand" ""))]
4398 "!TARGET_SOFT_FLOAT
4399 && !TARGET_DISABLE_INDEXING
4400 && TARGET_64BIT
4401 && REG_OK_FOR_BASE_P (operands[2])
4402 && FP_REGNO_P (REGNO (operands[3]))"
4403 [(set (mem:SF (plus:DI (mult:DI (match_dup 1) (const_int 4)) (match_dup 2)))
4404 (match_dup 3))
4405 (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 4))
4406 (match_dup 2)))]
4407 "")
4408
4409 (define_peephole2
4410 [(set (match_operand:DI 0 "register_operand" "")
4411 (plus:DI (match_operand:DI 2 "register_operand" "")
4412 (mult:DI (match_operand:DI 1 "register_operand" "")
4413 (const_int 4))))
4414 (set (mem:SF (match_dup 0))
4415 (match_operand:SF 3 "register_operand" ""))]
4416 "!TARGET_SOFT_FLOAT
4417 && !TARGET_DISABLE_INDEXING
4418 && TARGET_64BIT
4419 && REG_OK_FOR_BASE_P (operands[2])
4420 && FP_REGNO_P (REGNO (operands[3]))"
4421 [(set (mem:SF (plus:DI (mult:DI (match_dup 1) (const_int 4)) (match_dup 2)))
4422 (match_dup 3))
4423 (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 4))
4424 (match_dup 2)))]
4425 "")
4426
4427 (define_peephole2
4428 [(set (match_operand:SI 0 "register_operand" "")
4429 (plus:SI (match_operand:SI 1 "register_operand" "")
4430 (match_operand:SI 2 "register_operand" "")))
4431 (set (mem:SF (match_dup 0))
4432 (match_operand:SF 3 "register_operand" ""))]
4433 "!TARGET_SOFT_FLOAT
4434 && !TARGET_DISABLE_INDEXING
4435 && REG_OK_FOR_BASE_P (operands[1])
4436 && (TARGET_NO_SPACE_REGS
4437 || (!REG_POINTER (operands[1]) && REG_POINTER (operands[2])))
4438 && FP_REGNO_P (REGNO (operands[3]))"
4439 [(set (mem:SF (plus:SI (match_dup 1) (match_dup 2)))
4440 (match_dup 3))
4441 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
4442 "")
4443
4444 (define_peephole2
4445 [(set (match_operand:SI 0 "register_operand" "")
4446 (plus:SI (match_operand:SI 1 "register_operand" "")
4447 (match_operand:SI 2 "register_operand" "")))
4448 (set (mem:SF (match_dup 0))
4449 (match_operand:SF 3 "register_operand" ""))]
4450 "!TARGET_SOFT_FLOAT
4451 && !TARGET_DISABLE_INDEXING
4452 && REG_OK_FOR_BASE_P (operands[2])
4453 && (TARGET_NO_SPACE_REGS
4454 || (REG_POINTER (operands[1]) && !REG_POINTER (operands[2])))
4455 && FP_REGNO_P (REGNO (operands[3]))"
4456 [(set (mem:SF (plus:SI (match_dup 2) (match_dup 1)))
4457 (match_dup 3))
4458 (set (match_dup 0) (plus:SI (match_dup 2) (match_dup 1)))]
4459 "")
4460
4461 (define_peephole2
4462 [(set (match_operand:DI 0 "register_operand" "")
4463 (plus:DI (match_operand:DI 1 "register_operand" "")
4464 (match_operand:DI 2 "register_operand" "")))
4465 (set (mem:SF (match_dup 0))
4466 (match_operand:SF 3 "register_operand" ""))]
4467 "!TARGET_SOFT_FLOAT
4468 && !TARGET_DISABLE_INDEXING
4469 && TARGET_64BIT
4470 && REG_OK_FOR_BASE_P (operands[1])
4471 && (TARGET_NO_SPACE_REGS
4472 || (!REG_POINTER (operands[1]) && REG_POINTER (operands[2])))
4473 && FP_REGNO_P (REGNO (operands[3]))"
4474 [(set (mem:SF (plus:DI (match_dup 1) (match_dup 2)))
4475 (match_dup 3))
4476 (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
4477 "")
4478
4479 (define_peephole2
4480 [(set (match_operand:DI 0 "register_operand" "")
4481 (plus:DI (match_operand:DI 1 "register_operand" "")
4482 (match_operand:DI 2 "register_operand" "")))
4483 (set (mem:SF (match_dup 0))
4484 (match_operand:SF 3 "register_operand" ""))]
4485 "!TARGET_SOFT_FLOAT
4486 && !TARGET_DISABLE_INDEXING
4487 && TARGET_64BIT
4488 && REG_OK_FOR_BASE_P (operands[2])
4489 && (TARGET_NO_SPACE_REGS
4490 || (REG_POINTER (operands[1]) && !REG_POINTER (operands[2])))
4491 && FP_REGNO_P (REGNO (operands[3]))"
4492 [(set (mem:SF (plus:DI (match_dup 2) (match_dup 1)))
4493 (match_dup 3))
4494 (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
4495 "")
4496
4497 (define_insn ""
4498 [(set (match_operand:SF 0 "move_dest_operand"
4499 "=r,r,Q")
4500 (match_operand:SF 1 "reg_or_0_or_nonsymb_mem_operand"
4501 "rG,RQ,rG"))]
4502 "(register_operand (operands[0], SFmode)
4503 || reg_or_0_operand (operands[1], SFmode))
4504 && TARGET_SOFT_FLOAT"
4505 "@
4506 copy %r1,%0
4507 ldw%M1 %1,%0
4508 stw%M0 %r1,%0"
4509 [(set_attr "type" "move,load,store")
4510 (set_attr "pa_combine_type" "addmove")
4511 (set_attr "length" "4,4,4")])
4512
4513 \f
4514
4515 ;;- zero extension instructions
4516 ;; We have define_expand for zero extension patterns to make sure the
4517 ;; operands get loaded into registers. The define_insns accept
4518 ;; memory operands. This gives us better overall code than just
4519 ;; having a pattern that does or does not accept memory operands.
4520
4521 (define_expand "zero_extendqihi2"
4522 [(set (match_operand:HI 0 "register_operand" "")
4523 (zero_extend:HI
4524 (match_operand:QI 1 "register_operand" "")))]
4525 ""
4526 "")
4527
4528 (define_insn ""
4529 [(set (match_operand:HI 0 "register_operand" "=r,r")
4530 (zero_extend:HI
4531 (match_operand:QI 1 "move_src_operand" "r,RQ")))]
4532 "GET_CODE (operands[1]) != CONST_INT"
4533 "@
4534 {extru|extrw,u} %1,31,8,%0
4535 ldb%M1 %1,%0"
4536 [(set_attr "type" "shift,load")
4537 (set_attr "length" "4,4")])
4538
4539 (define_expand "zero_extendqisi2"
4540 [(set (match_operand:SI 0 "register_operand" "")
4541 (zero_extend:SI
4542 (match_operand:QI 1 "register_operand" "")))]
4543 ""
4544 "")
4545
4546 (define_insn ""
4547 [(set (match_operand:SI 0 "register_operand" "=r,r")
4548 (zero_extend:SI
4549 (match_operand:QI 1 "move_src_operand" "r,RQ")))]
4550 "GET_CODE (operands[1]) != CONST_INT"
4551 "@
4552 {extru|extrw,u} %1,31,8,%0
4553 ldb%M1 %1,%0"
4554 [(set_attr "type" "shift,load")
4555 (set_attr "length" "4,4")])
4556
4557 (define_expand "zero_extendhisi2"
4558 [(set (match_operand:SI 0 "register_operand" "")
4559 (zero_extend:SI
4560 (match_operand:HI 1 "register_operand" "")))]
4561 ""
4562 "")
4563
4564 (define_insn ""
4565 [(set (match_operand:SI 0 "register_operand" "=r,r")
4566 (zero_extend:SI
4567 (match_operand:HI 1 "move_src_operand" "r,RQ")))]
4568 "GET_CODE (operands[1]) != CONST_INT"
4569 "@
4570 {extru|extrw,u} %1,31,16,%0
4571 ldh%M1 %1,%0"
4572 [(set_attr "type" "shift,load")
4573 (set_attr "length" "4,4")])
4574
4575 (define_expand "zero_extendqidi2"
4576 [(set (match_operand:DI 0 "register_operand" "")
4577 (zero_extend:DI
4578 (match_operand:QI 1 "register_operand" "")))]
4579 "TARGET_64BIT"
4580 "")
4581
4582 (define_insn ""
4583 [(set (match_operand:DI 0 "register_operand" "=r,r")
4584 (zero_extend:DI
4585 (match_operand:QI 1 "move_src_operand" "r,RQ")))]
4586 "TARGET_64BIT && GET_CODE (operands[1]) != CONST_INT"
4587 "@
4588 extrd,u %1,63,8,%0
4589 ldb%M1 %1,%0"
4590 [(set_attr "type" "shift,load")
4591 (set_attr "length" "4,4")])
4592
4593 (define_expand "zero_extendhidi2"
4594 [(set (match_operand:DI 0 "register_operand" "")
4595 (zero_extend:DI
4596 (match_operand:HI 1 "register_operand" "")))]
4597 "TARGET_64BIT"
4598 "")
4599
4600 (define_insn ""
4601 [(set (match_operand:DI 0 "register_operand" "=r,r")
4602 (zero_extend:DI
4603 (match_operand:HI 1 "move_src_operand" "r,RQ")))]
4604 "TARGET_64BIT && GET_CODE (operands[1]) != CONST_INT"
4605 "@
4606 extrd,u %1,63,16,%0
4607 ldh%M1 %1,%0"
4608 [(set_attr "type" "shift,load")
4609 (set_attr "length" "4,4")])
4610
4611 (define_expand "zero_extendsidi2"
4612 [(set (match_operand:DI 0 "register_operand" "")
4613 (zero_extend:DI
4614 (match_operand:SI 1 "register_operand" "")))]
4615 "TARGET_64BIT"
4616 "")
4617
4618 (define_insn ""
4619 [(set (match_operand:DI 0 "register_operand" "=r,r")
4620 (zero_extend:DI
4621 (match_operand:SI 1 "move_src_operand" "r,RQ")))]
4622 "TARGET_64BIT && GET_CODE (operands[1]) != CONST_INT"
4623 "@
4624 extrd,u %1,63,32,%0
4625 ldw%M1 %1,%0"
4626 [(set_attr "type" "shift,load")
4627 (set_attr "length" "4,4")])
4628
4629 ;;- sign extension instructions
4630
4631 (define_insn "extendhisi2"
4632 [(set (match_operand:SI 0 "register_operand" "=r")
4633 (sign_extend:SI (match_operand:HI 1 "register_operand" "r")))]
4634 ""
4635 "{extrs|extrw,s} %1,31,16,%0"
4636 [(set_attr "type" "shift")
4637 (set_attr "length" "4")])
4638
4639 (define_insn "extendqihi2"
4640 [(set (match_operand:HI 0 "register_operand" "=r")
4641 (sign_extend:HI (match_operand:QI 1 "register_operand" "r")))]
4642 ""
4643 "{extrs|extrw,s} %1,31,8,%0"
4644 [(set_attr "type" "shift")
4645 (set_attr "length" "4")])
4646
4647 (define_insn "extendqisi2"
4648 [(set (match_operand:SI 0 "register_operand" "=r")
4649 (sign_extend:SI (match_operand:QI 1 "register_operand" "r")))]
4650 ""
4651 "{extrs|extrw,s} %1,31,8,%0"
4652 [(set_attr "type" "shift")
4653 (set_attr "length" "4")])
4654
4655 (define_insn "extendqidi2"
4656 [(set (match_operand:DI 0 "register_operand" "=r")
4657 (sign_extend:DI (match_operand:QI 1 "register_operand" "r")))]
4658 "TARGET_64BIT"
4659 "extrd,s %1,63,8,%0"
4660 [(set_attr "type" "shift")
4661 (set_attr "length" "4")])
4662
4663 (define_insn "extendhidi2"
4664 [(set (match_operand:DI 0 "register_operand" "=r")
4665 (sign_extend:DI (match_operand:HI 1 "register_operand" "r")))]
4666 "TARGET_64BIT"
4667 "extrd,s %1,63,16,%0"
4668 [(set_attr "type" "shift")
4669 (set_attr "length" "4")])
4670
4671 (define_insn "extendsidi2"
4672 [(set (match_operand:DI 0 "register_operand" "=r")
4673 (sign_extend:DI (match_operand:SI 1 "register_operand" "r")))]
4674 "TARGET_64BIT"
4675 "extrd,s %1,63,32,%0"
4676 [(set_attr "type" "shift")
4677 (set_attr "length" "4")])
4678
4679 \f
4680 ;; Conversions between float and double.
4681
4682 (define_insn "extendsfdf2"
4683 [(set (match_operand:DF 0 "register_operand" "=f")
4684 (float_extend:DF
4685 (match_operand:SF 1 "register_operand" "f")))]
4686 "! TARGET_SOFT_FLOAT"
4687 "{fcnvff|fcnv},sgl,dbl %1,%0"
4688 [(set_attr "type" "fpalu")
4689 (set_attr "length" "4")])
4690
4691 (define_insn "truncdfsf2"
4692 [(set (match_operand:SF 0 "register_operand" "=f")
4693 (float_truncate:SF
4694 (match_operand:DF 1 "register_operand" "f")))]
4695 "! TARGET_SOFT_FLOAT"
4696 "{fcnvff|fcnv},dbl,sgl %1,%0"
4697 [(set_attr "type" "fpalu")
4698 (set_attr "length" "4")])
4699
4700 ;; Conversion between fixed point and floating point.
4701 ;; Note that among the fix-to-float insns
4702 ;; the ones that start with SImode come first.
4703 ;; That is so that an operand that is a CONST_INT
4704 ;; (and therefore lacks a specific machine mode).
4705 ;; will be recognized as SImode (which is always valid)
4706 ;; rather than as QImode or HImode.
4707
4708 ;; This pattern forces (set (reg:SF ...) (float:SF (const_int ...)))
4709 ;; to be reloaded by putting the constant into memory.
4710 ;; It must come before the more general floatsisf2 pattern.
4711 (define_insn ""
4712 [(set (match_operand:SF 0 "register_operand" "=f")
4713 (float:SF (match_operand:SI 1 "const_int_operand" "m")))]
4714 "! TARGET_SOFT_FLOAT"
4715 "fldw%F1 %1,%0\;{fcnvxf,sgl,sgl|fcnv,w,sgl} %0,%0"
4716 [(set_attr "type" "fpalu")
4717 (set_attr "length" "8")])
4718
4719 (define_insn "floatsisf2"
4720 [(set (match_operand:SF 0 "register_operand" "=f")
4721 (float:SF (match_operand:SI 1 "register_operand" "f")))]
4722 "! TARGET_SOFT_FLOAT"
4723 "{fcnvxf,sgl,sgl|fcnv,w,sgl} %1,%0"
4724 [(set_attr "type" "fpalu")
4725 (set_attr "length" "4")])
4726
4727 ;; This pattern forces (set (reg:DF ...) (float:DF (const_int ...)))
4728 ;; to be reloaded by putting the constant into memory.
4729 ;; It must come before the more general floatsidf2 pattern.
4730 (define_insn ""
4731 [(set (match_operand:DF 0 "register_operand" "=f")
4732 (float:DF (match_operand:SI 1 "const_int_operand" "m")))]
4733 "! TARGET_SOFT_FLOAT"
4734 "fldw%F1 %1,%0\;{fcnvxf,sgl,dbl|fcnv,w,dbl} %0,%0"
4735 [(set_attr "type" "fpalu")
4736 (set_attr "length" "8")])
4737
4738 (define_insn "floatsidf2"
4739 [(set (match_operand:DF 0 "register_operand" "=f")
4740 (float:DF (match_operand:SI 1 "register_operand" "f")))]
4741 "! TARGET_SOFT_FLOAT"
4742 "{fcnvxf,sgl,dbl|fcnv,w,dbl} %1,%0"
4743 [(set_attr "type" "fpalu")
4744 (set_attr "length" "4")])
4745
4746 (define_expand "floatunssisf2"
4747 [(set (subreg:SI (match_dup 2) 4)
4748 (match_operand:SI 1 "register_operand" ""))
4749 (set (subreg:SI (match_dup 2) 0)
4750 (const_int 0))
4751 (set (match_operand:SF 0 "register_operand" "")
4752 (float:SF (match_dup 2)))]
4753 "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4754 "
4755 {
4756 if (TARGET_PA_20)
4757 {
4758 emit_insn (gen_floatunssisf2_pa20 (operands[0], operands[1]));
4759 DONE;
4760 }
4761 operands[2] = gen_reg_rtx (DImode);
4762 }")
4763
4764 (define_expand "floatunssidf2"
4765 [(set (subreg:SI (match_dup 2) 4)
4766 (match_operand:SI 1 "register_operand" ""))
4767 (set (subreg:SI (match_dup 2) 0)
4768 (const_int 0))
4769 (set (match_operand:DF 0 "register_operand" "")
4770 (float:DF (match_dup 2)))]
4771 "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4772 "
4773 {
4774 if (TARGET_PA_20)
4775 {
4776 emit_insn (gen_floatunssidf2_pa20 (operands[0], operands[1]));
4777 DONE;
4778 }
4779 operands[2] = gen_reg_rtx (DImode);
4780 }")
4781
4782 (define_insn "floatdisf2"
4783 [(set (match_operand:SF 0 "register_operand" "=f")
4784 (float:SF (match_operand:DI 1 "register_operand" "f")))]
4785 "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4786 "{fcnvxf,dbl,sgl|fcnv,dw,sgl} %1,%0"
4787 [(set_attr "type" "fpalu")
4788 (set_attr "length" "4")])
4789
4790 (define_insn "floatdidf2"
4791 [(set (match_operand:DF 0 "register_operand" "=f")
4792 (float:DF (match_operand:DI 1 "register_operand" "f")))]
4793 "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4794 "{fcnvxf,dbl,dbl|fcnv,dw,dbl} %1,%0"
4795 [(set_attr "type" "fpalu")
4796 (set_attr "length" "4")])
4797
4798 ;; Convert a float to an actual integer.
4799 ;; Truncation is performed as part of the conversion.
4800
4801 (define_insn "fix_truncsfsi2"
4802 [(set (match_operand:SI 0 "register_operand" "=f")
4803 (fix:SI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
4804 "! TARGET_SOFT_FLOAT"
4805 "{fcnvfxt,sgl,sgl|fcnv,t,sgl,w} %1,%0"
4806 [(set_attr "type" "fpalu")
4807 (set_attr "length" "4")])
4808
4809 (define_insn "fix_truncdfsi2"
4810 [(set (match_operand:SI 0 "register_operand" "=f")
4811 (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
4812 "! TARGET_SOFT_FLOAT"
4813 "{fcnvfxt,dbl,sgl|fcnv,t,dbl,w} %1,%0"
4814 [(set_attr "type" "fpalu")
4815 (set_attr "length" "4")])
4816
4817 (define_insn "fix_truncsfdi2"
4818 [(set (match_operand:DI 0 "register_operand" "=f")
4819 (fix:DI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
4820 "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4821 "{fcnvfxt,sgl,dbl|fcnv,t,sgl,dw} %1,%0"
4822 [(set_attr "type" "fpalu")
4823 (set_attr "length" "4")])
4824
4825 (define_insn "fix_truncdfdi2"
4826 [(set (match_operand:DI 0 "register_operand" "=f")
4827 (fix:DI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
4828 "TARGET_PA_11 && ! TARGET_SOFT_FLOAT"
4829 "{fcnvfxt,dbl,dbl|fcnv,t,dbl,dw} %1,%0"
4830 [(set_attr "type" "fpalu")
4831 (set_attr "length" "4")])
4832
4833 (define_insn "floatunssidf2_pa20"
4834 [(set (match_operand:DF 0 "register_operand" "=f")
4835 (unsigned_float:DF (match_operand:SI 1 "register_operand" "f")))]
4836 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4837 "fcnv,uw,dbl %1,%0"
4838 [(set_attr "type" "fpalu")
4839 (set_attr "length" "4")])
4840
4841 (define_insn "floatunssisf2_pa20"
4842 [(set (match_operand:SF 0 "register_operand" "=f")
4843 (unsigned_float:SF (match_operand:SI 1 "register_operand" "f")))]
4844 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4845 "fcnv,uw,sgl %1,%0"
4846 [(set_attr "type" "fpalu")
4847 (set_attr "length" "4")])
4848
4849 (define_insn "floatunsdisf2"
4850 [(set (match_operand:SF 0 "register_operand" "=f")
4851 (unsigned_float:SF (match_operand:DI 1 "register_operand" "f")))]
4852 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4853 "fcnv,udw,sgl %1,%0"
4854 [(set_attr "type" "fpalu")
4855 (set_attr "length" "4")])
4856
4857 (define_insn "floatunsdidf2"
4858 [(set (match_operand:DF 0 "register_operand" "=f")
4859 (unsigned_float:DF (match_operand:DI 1 "register_operand" "f")))]
4860 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4861 "fcnv,udw,dbl %1,%0"
4862 [(set_attr "type" "fpalu")
4863 (set_attr "length" "4")])
4864
4865 (define_insn "fixuns_truncsfsi2"
4866 [(set (match_operand:SI 0 "register_operand" "=f")
4867 (unsigned_fix:SI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
4868 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4869 "fcnv,t,sgl,uw %1,%0"
4870 [(set_attr "type" "fpalu")
4871 (set_attr "length" "4")])
4872
4873 (define_insn "fixuns_truncdfsi2"
4874 [(set (match_operand:SI 0 "register_operand" "=f")
4875 (unsigned_fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
4876 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4877 "fcnv,t,dbl,uw %1,%0"
4878 [(set_attr "type" "fpalu")
4879 (set_attr "length" "4")])
4880
4881 (define_insn "fixuns_truncsfdi2"
4882 [(set (match_operand:DI 0 "register_operand" "=f")
4883 (unsigned_fix:DI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
4884 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4885 "fcnv,t,sgl,udw %1,%0"
4886 [(set_attr "type" "fpalu")
4887 (set_attr "length" "4")])
4888
4889 (define_insn "fixuns_truncdfdi2"
4890 [(set (match_operand:DI 0 "register_operand" "=f")
4891 (unsigned_fix:DI (fix:DF (match_operand:DF 1 "register_operand" "f"))))]
4892 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
4893 "fcnv,t,dbl,udw %1,%0"
4894 [(set_attr "type" "fpalu")
4895 (set_attr "length" "4")])
4896 \f
4897 ;;- arithmetic instructions
4898
4899 (define_expand "adddi3"
4900 [(set (match_operand:DI 0 "register_operand" "")
4901 (plus:DI (match_operand:DI 1 "register_operand" "")
4902 (match_operand:DI 2 "adddi3_operand" "")))]
4903 ""
4904 "")
4905
4906 (define_insn ""
4907 [(set (match_operand:DI 0 "register_operand" "=r")
4908 (plus:DI (match_operand:DI 1 "register_operand" "%r")
4909 (match_operand:DI 2 "arith11_operand" "rI")))]
4910 "!TARGET_64BIT"
4911 "*
4912 {
4913 if (GET_CODE (operands[2]) == CONST_INT)
4914 {
4915 if (INTVAL (operands[2]) >= 0)
4916 return \"addi %2,%R1,%R0\;{addc|add,c} %1,%%r0,%0\";
4917 else
4918 return \"addi %2,%R1,%R0\;{subb|sub,b} %1,%%r0,%0\";
4919 }
4920 else
4921 return \"add %R2,%R1,%R0\;{addc|add,c} %2,%1,%0\";
4922 }"
4923 [(set_attr "type" "binary")
4924 (set_attr "length" "8")])
4925
4926 (define_insn ""
4927 [(set (match_operand:DI 0 "register_operand" "=r,r")
4928 (plus:DI (match_operand:DI 1 "register_operand" "%r,r")
4929 (match_operand:DI 2 "arith_operand" "r,J")))]
4930 "TARGET_64BIT"
4931 "@
4932 add,l %1,%2,%0
4933 ldo %2(%1),%0"
4934 [(set_attr "type" "binary,binary")
4935 (set_attr "pa_combine_type" "addmove")
4936 (set_attr "length" "4,4")])
4937
4938 (define_insn ""
4939 [(set (match_operand:DI 0 "register_operand" "=r")
4940 (plus:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
4941 (match_operand:DI 2 "register_operand" "r")))]
4942 "TARGET_64BIT"
4943 "uaddcm %2,%1,%0"
4944 [(set_attr "type" "binary")
4945 (set_attr "length" "4")])
4946
4947 (define_insn ""
4948 [(set (match_operand:SI 0 "register_operand" "=r")
4949 (plus:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
4950 (match_operand:SI 2 "register_operand" "r")))]
4951 ""
4952 "uaddcm %2,%1,%0"
4953 [(set_attr "type" "binary")
4954 (set_attr "length" "4")])
4955
4956 ;; define_splits to optimize cases of adding a constant integer
4957 ;; to a register when the constant does not fit in 14 bits. */
4958 (define_split
4959 [(set (match_operand:SI 0 "register_operand" "")
4960 (plus:SI (match_operand:SI 1 "register_operand" "")
4961 (match_operand:SI 2 "const_int_operand" "")))
4962 (clobber (match_operand:SI 4 "register_operand" ""))]
4963 "! cint_ok_for_move (INTVAL (operands[2]))
4964 && VAL_14_BITS_P (INTVAL (operands[2]) >> 1)"
4965 [(set (match_dup 4) (plus:SI (match_dup 1) (match_dup 2)))
4966 (set (match_dup 0) (plus:SI (match_dup 4) (match_dup 3)))]
4967 "
4968 {
4969 int val = INTVAL (operands[2]);
4970 int low = (val < 0) ? -0x2000 : 0x1fff;
4971 int rest = val - low;
4972
4973 operands[2] = GEN_INT (rest);
4974 operands[3] = GEN_INT (low);
4975 }")
4976
4977 (define_split
4978 [(set (match_operand:SI 0 "register_operand" "")
4979 (plus:SI (match_operand:SI 1 "register_operand" "")
4980 (match_operand:SI 2 "const_int_operand" "")))
4981 (clobber (match_operand:SI 4 "register_operand" ""))]
4982 "! cint_ok_for_move (INTVAL (operands[2]))"
4983 [(set (match_dup 4) (match_dup 2))
4984 (set (match_dup 0) (plus:SI (mult:SI (match_dup 4) (match_dup 3))
4985 (match_dup 1)))]
4986 "
4987 {
4988 HOST_WIDE_INT intval = INTVAL (operands[2]);
4989
4990 /* Try dividing the constant by 2, then 4, and finally 8 to see
4991 if we can get a constant which can be loaded into a register
4992 in a single instruction (cint_ok_for_move).
4993
4994 If that fails, try to negate the constant and subtract it
4995 from our input operand. */
4996 if (intval % 2 == 0 && cint_ok_for_move (intval / 2))
4997 {
4998 operands[2] = GEN_INT (intval / 2);
4999 operands[3] = const2_rtx;
5000 }
5001 else if (intval % 4 == 0 && cint_ok_for_move (intval / 4))
5002 {
5003 operands[2] = GEN_INT (intval / 4);
5004 operands[3] = GEN_INT (4);
5005 }
5006 else if (intval % 8 == 0 && cint_ok_for_move (intval / 8))
5007 {
5008 operands[2] = GEN_INT (intval / 8);
5009 operands[3] = GEN_INT (8);
5010 }
5011 else if (cint_ok_for_move (-intval))
5012 {
5013 emit_insn (gen_rtx_SET (VOIDmode, operands[4], GEN_INT (-intval)));
5014 emit_insn (gen_subsi3 (operands[0], operands[1], operands[4]));
5015 DONE;
5016 }
5017 else
5018 FAIL;
5019 }")
5020
5021 (define_insn "addsi3"
5022 [(set (match_operand:SI 0 "register_operand" "=r,r")
5023 (plus:SI (match_operand:SI 1 "register_operand" "%r,r")
5024 (match_operand:SI 2 "arith_operand" "r,J")))]
5025 ""
5026 "@
5027 {addl|add,l} %1,%2,%0
5028 ldo %2(%1),%0"
5029 [(set_attr "type" "binary,binary")
5030 (set_attr "pa_combine_type" "addmove")
5031 (set_attr "length" "4,4")])
5032
5033 (define_expand "subdi3"
5034 [(set (match_operand:DI 0 "register_operand" "")
5035 (minus:DI (match_operand:DI 1 "register_operand" "")
5036 (match_operand:DI 2 "register_operand" "")))]
5037 ""
5038 "")
5039
5040 (define_insn ""
5041 [(set (match_operand:DI 0 "register_operand" "=r")
5042 (minus:DI (match_operand:DI 1 "register_operand" "r")
5043 (match_operand:DI 2 "register_operand" "r")))]
5044 "!TARGET_64BIT"
5045 "sub %R1,%R2,%R0\;{subb|sub,b} %1,%2,%0"
5046 [(set_attr "type" "binary")
5047 (set_attr "length" "8")])
5048
5049 (define_insn ""
5050 [(set (match_operand:DI 0 "register_operand" "=r,r,!q")
5051 (minus:DI (match_operand:DI 1 "arith11_operand" "r,I,!U")
5052 (match_operand:DI 2 "register_operand" "r,r,!r")))]
5053 "TARGET_64BIT"
5054 "@
5055 sub %1,%2,%0
5056 subi %1,%2,%0
5057 mtsarcm %2"
5058 [(set_attr "type" "binary,binary,move")
5059 (set_attr "length" "4,4,4")])
5060
5061 (define_expand "subsi3"
5062 [(set (match_operand:SI 0 "register_operand" "")
5063 (minus:SI (match_operand:SI 1 "arith11_operand" "")
5064 (match_operand:SI 2 "register_operand" "")))]
5065 ""
5066 "")
5067
5068 (define_insn ""
5069 [(set (match_operand:SI 0 "register_operand" "=r,r")
5070 (minus:SI (match_operand:SI 1 "arith11_operand" "r,I")
5071 (match_operand:SI 2 "register_operand" "r,r")))]
5072 "!TARGET_PA_20"
5073 "@
5074 sub %1,%2,%0
5075 subi %1,%2,%0"
5076 [(set_attr "type" "binary,binary")
5077 (set_attr "length" "4,4")])
5078
5079 (define_insn ""
5080 [(set (match_operand:SI 0 "register_operand" "=r,r,!q")
5081 (minus:SI (match_operand:SI 1 "arith11_operand" "r,I,!S")
5082 (match_operand:SI 2 "register_operand" "r,r,!r")))]
5083 "TARGET_PA_20"
5084 "@
5085 sub %1,%2,%0
5086 subi %1,%2,%0
5087 mtsarcm %2"
5088 [(set_attr "type" "binary,binary,move")
5089 (set_attr "length" "4,4,4")])
5090
5091 ;; Clobbering a "register_operand" instead of a match_scratch
5092 ;; in operand3 of millicode calls avoids spilling %r1 and
5093 ;; produces better code.
5094
5095 ;; The mulsi3 insns set up registers for the millicode call.
5096 (define_expand "mulsi3"
5097 [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5098 (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5099 (parallel [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
5100 (clobber (match_dup 3))
5101 (clobber (reg:SI 26))
5102 (clobber (reg:SI 25))
5103 (clobber (match_dup 4))])
5104 (set (match_operand:SI 0 "general_operand" "") (reg:SI 29))]
5105 ""
5106 "
5107 {
5108 operands[4] = gen_rtx_REG (SImode, TARGET_64BIT ? 2 : 31);
5109 if (TARGET_PA_11 && !TARGET_DISABLE_FPREGS && !TARGET_SOFT_FLOAT)
5110 {
5111 rtx scratch = gen_reg_rtx (DImode);
5112 operands[1] = force_reg (SImode, operands[1]);
5113 operands[2] = force_reg (SImode, operands[2]);
5114 emit_insn (gen_umulsidi3 (scratch, operands[1], operands[2]));
5115 emit_insn (gen_movsi (operands[0],
5116 gen_rtx_SUBREG (SImode, scratch,
5117 GET_MODE_SIZE (SImode))));
5118 DONE;
5119 }
5120 operands[3] = gen_reg_rtx (SImode);
5121 }")
5122
5123 (define_insn "umulsidi3"
5124 [(set (match_operand:DI 0 "nonimmediate_operand" "=f")
5125 (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "f"))
5126 (zero_extend:DI (match_operand:SI 2 "nonimmediate_operand" "f"))))]
5127 "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT"
5128 "xmpyu %1,%2,%0"
5129 [(set_attr "type" "fpmuldbl")
5130 (set_attr "length" "4")])
5131
5132 (define_insn ""
5133 [(set (match_operand:DI 0 "nonimmediate_operand" "=f")
5134 (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "f"))
5135 (match_operand:DI 2 "uint32_operand" "f")))]
5136 "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT && !TARGET_64BIT"
5137 "xmpyu %1,%R2,%0"
5138 [(set_attr "type" "fpmuldbl")
5139 (set_attr "length" "4")])
5140
5141 (define_insn ""
5142 [(set (match_operand:DI 0 "nonimmediate_operand" "=f")
5143 (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "f"))
5144 (match_operand:DI 2 "uint32_operand" "f")))]
5145 "TARGET_PA_11 && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT && TARGET_64BIT"
5146 "xmpyu %1,%2R,%0"
5147 [(set_attr "type" "fpmuldbl")
5148 (set_attr "length" "4")])
5149
5150 (define_insn ""
5151 [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
5152 (clobber (match_operand:SI 0 "register_operand" "=a"))
5153 (clobber (reg:SI 26))
5154 (clobber (reg:SI 25))
5155 (clobber (reg:SI 31))]
5156 "!TARGET_64BIT"
5157 "* return output_mul_insn (0, insn);"
5158 [(set_attr "type" "milli")
5159 (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5160
5161 (define_insn ""
5162 [(set (reg:SI 29) (mult:SI (reg:SI 26) (reg:SI 25)))
5163 (clobber (match_operand:SI 0 "register_operand" "=a"))
5164 (clobber (reg:SI 26))
5165 (clobber (reg:SI 25))
5166 (clobber (reg:SI 2))]
5167 "TARGET_64BIT"
5168 "* return output_mul_insn (0, insn);"
5169 [(set_attr "type" "milli")
5170 (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5171
5172 (define_expand "muldi3"
5173 [(set (match_operand:DI 0 "register_operand" "")
5174 (mult:DI (match_operand:DI 1 "register_operand" "")
5175 (match_operand:DI 2 "register_operand" "")))]
5176 "TARGET_64BIT && ! TARGET_DISABLE_FPREGS && ! TARGET_SOFT_FLOAT"
5177 "
5178 {
5179 rtx low_product = gen_reg_rtx (DImode);
5180 rtx cross_product1 = gen_reg_rtx (DImode);
5181 rtx cross_product2 = gen_reg_rtx (DImode);
5182 rtx cross_scratch = gen_reg_rtx (DImode);
5183 rtx cross_product = gen_reg_rtx (DImode);
5184 rtx op1l, op1r, op2l, op2r;
5185 rtx op1shifted, op2shifted;
5186
5187 op1shifted = gen_reg_rtx (DImode);
5188 op2shifted = gen_reg_rtx (DImode);
5189 op1l = gen_reg_rtx (SImode);
5190 op1r = gen_reg_rtx (SImode);
5191 op2l = gen_reg_rtx (SImode);
5192 op2r = gen_reg_rtx (SImode);
5193
5194 emit_move_insn (op1shifted, gen_rtx_LSHIFTRT (DImode, operands[1],
5195 GEN_INT (32)));
5196 emit_move_insn (op2shifted, gen_rtx_LSHIFTRT (DImode, operands[2],
5197 GEN_INT (32)));
5198 op1r = gen_rtx_SUBREG (SImode, operands[1], 4);
5199 op2r = gen_rtx_SUBREG (SImode, operands[2], 4);
5200 op1l = gen_rtx_SUBREG (SImode, op1shifted, 4);
5201 op2l = gen_rtx_SUBREG (SImode, op2shifted, 4);
5202
5203 /* Emit multiplies for the cross products. */
5204 emit_insn (gen_umulsidi3 (cross_product1, op2r, op1l));
5205 emit_insn (gen_umulsidi3 (cross_product2, op2l, op1r));
5206
5207 /* Emit a multiply for the low sub-word. */
5208 emit_insn (gen_umulsidi3 (low_product, copy_rtx (op2r), copy_rtx (op1r)));
5209
5210 /* Sum the cross products and shift them into proper position. */
5211 emit_insn (gen_adddi3 (cross_scratch, cross_product1, cross_product2));
5212 emit_insn (gen_ashldi3 (cross_product, cross_scratch, GEN_INT (32)));
5213
5214 /* Add the cross product to the low product and store the result
5215 into the output operand . */
5216 emit_insn (gen_adddi3 (operands[0], cross_product, low_product));
5217 DONE;
5218 }")
5219
5220 ;;; Division and mod.
5221 (define_expand "divsi3"
5222 [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5223 (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5224 (parallel [(set (reg:SI 29) (div:SI (reg:SI 26) (reg:SI 25)))
5225 (clobber (match_dup 3))
5226 (clobber (match_dup 4))
5227 (clobber (reg:SI 26))
5228 (clobber (reg:SI 25))
5229 (clobber (match_dup 5))])
5230 (set (match_operand:SI 0 "general_operand" "") (reg:SI 29))]
5231 ""
5232 "
5233 {
5234 operands[3] = gen_reg_rtx (SImode);
5235 if (TARGET_64BIT)
5236 {
5237 operands[5] = gen_rtx_REG (SImode, 2);
5238 operands[4] = operands[5];
5239 }
5240 else
5241 {
5242 operands[5] = gen_rtx_REG (SImode, 31);
5243 operands[4] = gen_reg_rtx (SImode);
5244 }
5245 if (GET_CODE (operands[2]) == CONST_INT && emit_hpdiv_const (operands, 0))
5246 DONE;
5247 }")
5248
5249 (define_insn ""
5250 [(set (reg:SI 29)
5251 (div:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5252 (clobber (match_operand:SI 1 "register_operand" "=a"))
5253 (clobber (match_operand:SI 2 "register_operand" "=&r"))
5254 (clobber (reg:SI 26))
5255 (clobber (reg:SI 25))
5256 (clobber (reg:SI 31))]
5257 "!TARGET_64BIT"
5258 "*
5259 return output_div_insn (operands, 0, insn);"
5260 [(set_attr "type" "milli")
5261 (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5262
5263 (define_insn ""
5264 [(set (reg:SI 29)
5265 (div:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5266 (clobber (match_operand:SI 1 "register_operand" "=a"))
5267 (clobber (match_operand:SI 2 "register_operand" "=&r"))
5268 (clobber (reg:SI 26))
5269 (clobber (reg:SI 25))
5270 (clobber (reg:SI 2))]
5271 "TARGET_64BIT"
5272 "*
5273 return output_div_insn (operands, 0, insn);"
5274 [(set_attr "type" "milli")
5275 (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5276
5277 (define_expand "udivsi3"
5278 [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5279 (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5280 (parallel [(set (reg:SI 29) (udiv:SI (reg:SI 26) (reg:SI 25)))
5281 (clobber (match_dup 3))
5282 (clobber (match_dup 4))
5283 (clobber (reg:SI 26))
5284 (clobber (reg:SI 25))
5285 (clobber (match_dup 5))])
5286 (set (match_operand:SI 0 "general_operand" "") (reg:SI 29))]
5287 ""
5288 "
5289 {
5290 operands[3] = gen_reg_rtx (SImode);
5291
5292 if (TARGET_64BIT)
5293 {
5294 operands[5] = gen_rtx_REG (SImode, 2);
5295 operands[4] = operands[5];
5296 }
5297 else
5298 {
5299 operands[5] = gen_rtx_REG (SImode, 31);
5300 operands[4] = gen_reg_rtx (SImode);
5301 }
5302 if (GET_CODE (operands[2]) == CONST_INT && emit_hpdiv_const (operands, 1))
5303 DONE;
5304 }")
5305
5306 (define_insn ""
5307 [(set (reg:SI 29)
5308 (udiv:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5309 (clobber (match_operand:SI 1 "register_operand" "=a"))
5310 (clobber (match_operand:SI 2 "register_operand" "=&r"))
5311 (clobber (reg:SI 26))
5312 (clobber (reg:SI 25))
5313 (clobber (reg:SI 31))]
5314 "!TARGET_64BIT"
5315 "*
5316 return output_div_insn (operands, 1, insn);"
5317 [(set_attr "type" "milli")
5318 (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5319
5320 (define_insn ""
5321 [(set (reg:SI 29)
5322 (udiv:SI (reg:SI 26) (match_operand:SI 0 "div_operand" "")))
5323 (clobber (match_operand:SI 1 "register_operand" "=a"))
5324 (clobber (match_operand:SI 2 "register_operand" "=&r"))
5325 (clobber (reg:SI 26))
5326 (clobber (reg:SI 25))
5327 (clobber (reg:SI 2))]
5328 "TARGET_64BIT"
5329 "*
5330 return output_div_insn (operands, 1, insn);"
5331 [(set_attr "type" "milli")
5332 (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5333
5334 (define_expand "modsi3"
5335 [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5336 (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5337 (parallel [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
5338 (clobber (match_dup 3))
5339 (clobber (match_dup 4))
5340 (clobber (reg:SI 26))
5341 (clobber (reg:SI 25))
5342 (clobber (match_dup 5))])
5343 (set (match_operand:SI 0 "general_operand" "") (reg:SI 29))]
5344 ""
5345 "
5346 {
5347 if (TARGET_64BIT)
5348 {
5349 operands[5] = gen_rtx_REG (SImode, 2);
5350 operands[4] = operands[5];
5351 }
5352 else
5353 {
5354 operands[5] = gen_rtx_REG (SImode, 31);
5355 operands[4] = gen_reg_rtx (SImode);
5356 }
5357 operands[3] = gen_reg_rtx (SImode);
5358 }")
5359
5360 (define_insn ""
5361 [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
5362 (clobber (match_operand:SI 0 "register_operand" "=a"))
5363 (clobber (match_operand:SI 1 "register_operand" "=&r"))
5364 (clobber (reg:SI 26))
5365 (clobber (reg:SI 25))
5366 (clobber (reg:SI 31))]
5367 "!TARGET_64BIT"
5368 "*
5369 return output_mod_insn (0, insn);"
5370 [(set_attr "type" "milli")
5371 (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5372
5373 (define_insn ""
5374 [(set (reg:SI 29) (mod:SI (reg:SI 26) (reg:SI 25)))
5375 (clobber (match_operand:SI 0 "register_operand" "=a"))
5376 (clobber (match_operand:SI 1 "register_operand" "=&r"))
5377 (clobber (reg:SI 26))
5378 (clobber (reg:SI 25))
5379 (clobber (reg:SI 2))]
5380 "TARGET_64BIT"
5381 "*
5382 return output_mod_insn (0, insn);"
5383 [(set_attr "type" "milli")
5384 (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5385
5386 (define_expand "umodsi3"
5387 [(set (reg:SI 26) (match_operand:SI 1 "move_src_operand" ""))
5388 (set (reg:SI 25) (match_operand:SI 2 "move_src_operand" ""))
5389 (parallel [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
5390 (clobber (match_dup 3))
5391 (clobber (match_dup 4))
5392 (clobber (reg:SI 26))
5393 (clobber (reg:SI 25))
5394 (clobber (match_dup 5))])
5395 (set (match_operand:SI 0 "general_operand" "") (reg:SI 29))]
5396 ""
5397 "
5398 {
5399 if (TARGET_64BIT)
5400 {
5401 operands[5] = gen_rtx_REG (SImode, 2);
5402 operands[4] = operands[5];
5403 }
5404 else
5405 {
5406 operands[5] = gen_rtx_REG (SImode, 31);
5407 operands[4] = gen_reg_rtx (SImode);
5408 }
5409 operands[3] = gen_reg_rtx (SImode);
5410 }")
5411
5412 (define_insn ""
5413 [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
5414 (clobber (match_operand:SI 0 "register_operand" "=a"))
5415 (clobber (match_operand:SI 1 "register_operand" "=&r"))
5416 (clobber (reg:SI 26))
5417 (clobber (reg:SI 25))
5418 (clobber (reg:SI 31))]
5419 "!TARGET_64BIT"
5420 "*
5421 return output_mod_insn (1, insn);"
5422 [(set_attr "type" "milli")
5423 (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5424
5425 (define_insn ""
5426 [(set (reg:SI 29) (umod:SI (reg:SI 26) (reg:SI 25)))
5427 (clobber (match_operand:SI 0 "register_operand" "=a"))
5428 (clobber (match_operand:SI 1 "register_operand" "=&r"))
5429 (clobber (reg:SI 26))
5430 (clobber (reg:SI 25))
5431 (clobber (reg:SI 2))]
5432 "TARGET_64BIT"
5433 "*
5434 return output_mod_insn (1, insn);"
5435 [(set_attr "type" "milli")
5436 (set (attr "length") (symbol_ref "attr_length_millicode_call (insn)"))])
5437
5438 ;;- and instructions
5439 ;; We define DImode `and` so with DImode `not` we can get
5440 ;; DImode `andn`. Other combinations are possible.
5441
5442 (define_expand "anddi3"
5443 [(set (match_operand:DI 0 "register_operand" "")
5444 (and:DI (match_operand:DI 1 "and_operand" "")
5445 (match_operand:DI 2 "and_operand" "")))]
5446 ""
5447 "
5448 {
5449 if (TARGET_64BIT)
5450 {
5451 /* One operand must be a register operand. */
5452 if (!register_operand (operands[1], DImode)
5453 && !register_operand (operands[2], DImode))
5454 FAIL;
5455 }
5456 else
5457 {
5458 /* Both operands must be register operands. */
5459 if (!register_operand (operands[1], DImode)
5460 || !register_operand (operands[2], DImode))
5461 FAIL;
5462 }
5463 }")
5464
5465 (define_insn ""
5466 [(set (match_operand:DI 0 "register_operand" "=r")
5467 (and:DI (match_operand:DI 1 "register_operand" "%r")
5468 (match_operand:DI 2 "register_operand" "r")))]
5469 "!TARGET_64BIT"
5470 "and %1,%2,%0\;and %R1,%R2,%R0"
5471 [(set_attr "type" "binary")
5472 (set_attr "length" "8")])
5473
5474 (define_insn ""
5475 [(set (match_operand:DI 0 "register_operand" "=r,r")
5476 (and:DI (match_operand:DI 1 "register_operand" "%?r,0")
5477 (match_operand:DI 2 "and_operand" "rO,P")))]
5478 "TARGET_64BIT"
5479 "* return output_64bit_and (operands); "
5480 [(set_attr "type" "binary")
5481 (set_attr "length" "4")])
5482
5483 ; The ? for op1 makes reload prefer zdepi instead of loading a huge
5484 ; constant with ldil;ldo.
5485 (define_insn "andsi3"
5486 [(set (match_operand:SI 0 "register_operand" "=r,r")
5487 (and:SI (match_operand:SI 1 "register_operand" "%?r,0")
5488 (match_operand:SI 2 "and_operand" "rO,P")))]
5489 ""
5490 "* return output_and (operands); "
5491 [(set_attr "type" "binary,shift")
5492 (set_attr "length" "4,4")])
5493
5494 (define_insn ""
5495 [(set (match_operand:DI 0 "register_operand" "=r")
5496 (and:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
5497 (match_operand:DI 2 "register_operand" "r")))]
5498 "!TARGET_64BIT"
5499 "andcm %2,%1,%0\;andcm %R2,%R1,%R0"
5500 [(set_attr "type" "binary")
5501 (set_attr "length" "8")])
5502
5503 (define_insn ""
5504 [(set (match_operand:DI 0 "register_operand" "=r")
5505 (and:DI (not:DI (match_operand:DI 1 "register_operand" "r"))
5506 (match_operand:DI 2 "register_operand" "r")))]
5507 "TARGET_64BIT"
5508 "andcm %2,%1,%0"
5509 [(set_attr "type" "binary")
5510 (set_attr "length" "4")])
5511
5512 (define_insn ""
5513 [(set (match_operand:SI 0 "register_operand" "=r")
5514 (and:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
5515 (match_operand:SI 2 "register_operand" "r")))]
5516 ""
5517 "andcm %2,%1,%0"
5518 [(set_attr "type" "binary")
5519 (set_attr "length" "4")])
5520
5521 (define_expand "iordi3"
5522 [(set (match_operand:DI 0 "register_operand" "")
5523 (ior:DI (match_operand:DI 1 "ior_operand" "")
5524 (match_operand:DI 2 "ior_operand" "")))]
5525 ""
5526 "
5527 {
5528 if (TARGET_64BIT)
5529 {
5530 /* One operand must be a register operand. */
5531 if (!register_operand (operands[1], DImode)
5532 && !register_operand (operands[2], DImode))
5533 FAIL;
5534 }
5535 else
5536 {
5537 /* Both operands must be register operands. */
5538 if (!register_operand (operands[1], DImode)
5539 || !register_operand (operands[2], DImode))
5540 FAIL;
5541 }
5542 }")
5543
5544 (define_insn ""
5545 [(set (match_operand:DI 0 "register_operand" "=r")
5546 (ior:DI (match_operand:DI 1 "register_operand" "%r")
5547 (match_operand:DI 2 "register_operand" "r")))]
5548 "!TARGET_64BIT"
5549 "or %1,%2,%0\;or %R1,%R2,%R0"
5550 [(set_attr "type" "binary")
5551 (set_attr "length" "8")])
5552
5553 (define_insn ""
5554 [(set (match_operand:DI 0 "register_operand" "=r,r")
5555 (ior:DI (match_operand:DI 1 "register_operand" "0,0")
5556 (match_operand:DI 2 "ior_operand" "M,i")))]
5557 "TARGET_64BIT"
5558 "* return output_64bit_ior (operands); "
5559 [(set_attr "type" "binary,shift")
5560 (set_attr "length" "4,4")])
5561
5562 (define_insn ""
5563 [(set (match_operand:DI 0 "register_operand" "=r")
5564 (ior:DI (match_operand:DI 1 "register_operand" "%r")
5565 (match_operand:DI 2 "register_operand" "r")))]
5566 "TARGET_64BIT"
5567 "or %1,%2,%0"
5568 [(set_attr "type" "binary")
5569 (set_attr "length" "4")])
5570
5571 ;; Need a define_expand because we've run out of CONST_OK... characters.
5572 (define_expand "iorsi3"
5573 [(set (match_operand:SI 0 "register_operand" "")
5574 (ior:SI (match_operand:SI 1 "register_operand" "")
5575 (match_operand:SI 2 "arith32_operand" "")))]
5576 ""
5577 "
5578 {
5579 if (! (ior_operand (operands[2], SImode)
5580 || register_operand (operands[2], SImode)))
5581 operands[2] = force_reg (SImode, operands[2]);
5582 }")
5583
5584 (define_insn ""
5585 [(set (match_operand:SI 0 "register_operand" "=r,r")
5586 (ior:SI (match_operand:SI 1 "register_operand" "0,0")
5587 (match_operand:SI 2 "ior_operand" "M,i")))]
5588 ""
5589 "* return output_ior (operands); "
5590 [(set_attr "type" "binary,shift")
5591 (set_attr "length" "4,4")])
5592
5593 (define_insn ""
5594 [(set (match_operand:SI 0 "register_operand" "=r")
5595 (ior:SI (match_operand:SI 1 "register_operand" "%r")
5596 (match_operand:SI 2 "register_operand" "r")))]
5597 ""
5598 "or %1,%2,%0"
5599 [(set_attr "type" "binary")
5600 (set_attr "length" "4")])
5601
5602 (define_expand "xordi3"
5603 [(set (match_operand:DI 0 "register_operand" "")
5604 (xor:DI (match_operand:DI 1 "register_operand" "")
5605 (match_operand:DI 2 "register_operand" "")))]
5606 ""
5607 "
5608 {
5609 }")
5610
5611 (define_insn ""
5612 [(set (match_operand:DI 0 "register_operand" "=r")
5613 (xor:DI (match_operand:DI 1 "register_operand" "%r")
5614 (match_operand:DI 2 "register_operand" "r")))]
5615 "!TARGET_64BIT"
5616 "xor %1,%2,%0\;xor %R1,%R2,%R0"
5617 [(set_attr "type" "binary")
5618 (set_attr "length" "8")])
5619
5620 (define_insn ""
5621 [(set (match_operand:DI 0 "register_operand" "=r")
5622 (xor:DI (match_operand:DI 1 "register_operand" "%r")
5623 (match_operand:DI 2 "register_operand" "r")))]
5624 "TARGET_64BIT"
5625 "xor %1,%2,%0"
5626 [(set_attr "type" "binary")
5627 (set_attr "length" "4")])
5628
5629 (define_insn "xorsi3"
5630 [(set (match_operand:SI 0 "register_operand" "=r")
5631 (xor:SI (match_operand:SI 1 "register_operand" "%r")
5632 (match_operand:SI 2 "register_operand" "r")))]
5633 ""
5634 "xor %1,%2,%0"
5635 [(set_attr "type" "binary")
5636 (set_attr "length" "4")])
5637
5638 (define_expand "negdi2"
5639 [(set (match_operand:DI 0 "register_operand" "")
5640 (neg:DI (match_operand:DI 1 "register_operand" "")))]
5641 ""
5642 "")
5643
5644 (define_insn ""
5645 [(set (match_operand:DI 0 "register_operand" "=r")
5646 (neg:DI (match_operand:DI 1 "register_operand" "r")))]
5647 "!TARGET_64BIT"
5648 "sub %%r0,%R1,%R0\;{subb|sub,b} %%r0,%1,%0"
5649 [(set_attr "type" "unary")
5650 (set_attr "length" "8")])
5651
5652 (define_insn ""
5653 [(set (match_operand:DI 0 "register_operand" "=r")
5654 (neg:DI (match_operand:DI 1 "register_operand" "r")))]
5655 "TARGET_64BIT"
5656 "sub %%r0,%1,%0"
5657 [(set_attr "type" "unary")
5658 (set_attr "length" "4")])
5659
5660 (define_insn "negsi2"
5661 [(set (match_operand:SI 0 "register_operand" "=r")
5662 (neg:SI (match_operand:SI 1 "register_operand" "r")))]
5663 ""
5664 "sub %%r0,%1,%0"
5665 [(set_attr "type" "unary")
5666 (set_attr "length" "4")])
5667
5668 (define_expand "one_cmpldi2"
5669 [(set (match_operand:DI 0 "register_operand" "")
5670 (not:DI (match_operand:DI 1 "register_operand" "")))]
5671 ""
5672 "
5673 {
5674 }")
5675
5676 (define_insn ""
5677 [(set (match_operand:DI 0 "register_operand" "=r")
5678 (not:DI (match_operand:DI 1 "register_operand" "r")))]
5679 "!TARGET_64BIT"
5680 "uaddcm %%r0,%1,%0\;uaddcm %%r0,%R1,%R0"
5681 [(set_attr "type" "unary")
5682 (set_attr "length" "8")])
5683
5684 (define_insn ""
5685 [(set (match_operand:DI 0 "register_operand" "=r")
5686 (not:DI (match_operand:DI 1 "register_operand" "r")))]
5687 "TARGET_64BIT"
5688 "uaddcm %%r0,%1,%0"
5689 [(set_attr "type" "unary")
5690 (set_attr "length" "4")])
5691
5692 (define_insn "one_cmplsi2"
5693 [(set (match_operand:SI 0 "register_operand" "=r")
5694 (not:SI (match_operand:SI 1 "register_operand" "r")))]
5695 ""
5696 "uaddcm %%r0,%1,%0"
5697 [(set_attr "type" "unary")
5698 (set_attr "length" "4")])
5699 \f
5700 ;; Floating point arithmetic instructions.
5701
5702 (define_insn "adddf3"
5703 [(set (match_operand:DF 0 "register_operand" "=f")
5704 (plus:DF (match_operand:DF 1 "register_operand" "f")
5705 (match_operand:DF 2 "register_operand" "f")))]
5706 "! TARGET_SOFT_FLOAT"
5707 "fadd,dbl %1,%2,%0"
5708 [(set_attr "type" "fpalu")
5709 (set_attr "pa_combine_type" "faddsub")
5710 (set_attr "length" "4")])
5711
5712 (define_insn "addsf3"
5713 [(set (match_operand:SF 0 "register_operand" "=f")
5714 (plus:SF (match_operand:SF 1 "register_operand" "f")
5715 (match_operand:SF 2 "register_operand" "f")))]
5716 "! TARGET_SOFT_FLOAT"
5717 "fadd,sgl %1,%2,%0"
5718 [(set_attr "type" "fpalu")
5719 (set_attr "pa_combine_type" "faddsub")
5720 (set_attr "length" "4")])
5721
5722 (define_insn "subdf3"
5723 [(set (match_operand:DF 0 "register_operand" "=f")
5724 (minus:DF (match_operand:DF 1 "register_operand" "f")
5725 (match_operand:DF 2 "register_operand" "f")))]
5726 "! TARGET_SOFT_FLOAT"
5727 "fsub,dbl %1,%2,%0"
5728 [(set_attr "type" "fpalu")
5729 (set_attr "pa_combine_type" "faddsub")
5730 (set_attr "length" "4")])
5731
5732 (define_insn "subsf3"
5733 [(set (match_operand:SF 0 "register_operand" "=f")
5734 (minus:SF (match_operand:SF 1 "register_operand" "f")
5735 (match_operand:SF 2 "register_operand" "f")))]
5736 "! TARGET_SOFT_FLOAT"
5737 "fsub,sgl %1,%2,%0"
5738 [(set_attr "type" "fpalu")
5739 (set_attr "pa_combine_type" "faddsub")
5740 (set_attr "length" "4")])
5741
5742 (define_insn "muldf3"
5743 [(set (match_operand:DF 0 "register_operand" "=f")
5744 (mult:DF (match_operand:DF 1 "register_operand" "f")
5745 (match_operand:DF 2 "register_operand" "f")))]
5746 "! TARGET_SOFT_FLOAT"
5747 "fmpy,dbl %1,%2,%0"
5748 [(set_attr "type" "fpmuldbl")
5749 (set_attr "pa_combine_type" "fmpy")
5750 (set_attr "length" "4")])
5751
5752 (define_insn "mulsf3"
5753 [(set (match_operand:SF 0 "register_operand" "=f")
5754 (mult:SF (match_operand:SF 1 "register_operand" "f")
5755 (match_operand:SF 2 "register_operand" "f")))]
5756 "! TARGET_SOFT_FLOAT"
5757 "fmpy,sgl %1,%2,%0"
5758 [(set_attr "type" "fpmulsgl")
5759 (set_attr "pa_combine_type" "fmpy")
5760 (set_attr "length" "4")])
5761
5762 (define_insn "divdf3"
5763 [(set (match_operand:DF 0 "register_operand" "=f")
5764 (div:DF (match_operand:DF 1 "register_operand" "f")
5765 (match_operand:DF 2 "register_operand" "f")))]
5766 "! TARGET_SOFT_FLOAT"
5767 "fdiv,dbl %1,%2,%0"
5768 [(set_attr "type" "fpdivdbl")
5769 (set_attr "length" "4")])
5770
5771 (define_insn "divsf3"
5772 [(set (match_operand:SF 0 "register_operand" "=f")
5773 (div:SF (match_operand:SF 1 "register_operand" "f")
5774 (match_operand:SF 2 "register_operand" "f")))]
5775 "! TARGET_SOFT_FLOAT"
5776 "fdiv,sgl %1,%2,%0"
5777 [(set_attr "type" "fpdivsgl")
5778 (set_attr "length" "4")])
5779
5780 ;; Processors prior to PA 2.0 don't have a fneg instruction. Fast
5781 ;; negation can be done by subtracting from plus zero. However, this
5782 ;; violates the IEEE standard when negating plus and minus zero.
5783 (define_expand "negdf2"
5784 [(parallel [(set (match_operand:DF 0 "register_operand" "")
5785 (neg:DF (match_operand:DF 1 "register_operand" "")))
5786 (use (match_dup 2))])]
5787 "! TARGET_SOFT_FLOAT"
5788 {
5789 if (TARGET_PA_20 || flag_unsafe_math_optimizations)
5790 emit_insn (gen_negdf2_fast (operands[0], operands[1]));
5791 else
5792 {
5793 operands[2] = force_reg (DFmode,
5794 CONST_DOUBLE_FROM_REAL_VALUE (dconstm1, DFmode));
5795 emit_insn (gen_muldf3 (operands[0], operands[1], operands[2]));
5796 }
5797 DONE;
5798 })
5799
5800 (define_insn "negdf2_fast"
5801 [(set (match_operand:DF 0 "register_operand" "=f")
5802 (neg:DF (match_operand:DF 1 "register_operand" "f")))]
5803 "! TARGET_SOFT_FLOAT && (TARGET_PA_20 || flag_unsafe_math_optimizations)"
5804 "*
5805 {
5806 if (TARGET_PA_20)
5807 return \"fneg,dbl %1,%0\";
5808 else
5809 return \"fsub,dbl %%fr0,%1,%0\";
5810 }"
5811 [(set_attr "type" "fpalu")
5812 (set_attr "length" "4")])
5813
5814 (define_expand "negsf2"
5815 [(parallel [(set (match_operand:SF 0 "register_operand" "")
5816 (neg:SF (match_operand:SF 1 "register_operand" "")))
5817 (use (match_dup 2))])]
5818 "! TARGET_SOFT_FLOAT"
5819 {
5820 if (TARGET_PA_20 || flag_unsafe_math_optimizations)
5821 emit_insn (gen_negsf2_fast (operands[0], operands[1]));
5822 else
5823 {
5824 operands[2] = force_reg (SFmode,
5825 CONST_DOUBLE_FROM_REAL_VALUE (dconstm1, SFmode));
5826 emit_insn (gen_mulsf3 (operands[0], operands[1], operands[2]));
5827 }
5828 DONE;
5829 })
5830
5831 (define_insn "negsf2_fast"
5832 [(set (match_operand:SF 0 "register_operand" "=f")
5833 (neg:SF (match_operand:SF 1 "register_operand" "f")))]
5834 "! TARGET_SOFT_FLOAT && (TARGET_PA_20 || flag_unsafe_math_optimizations)"
5835 "*
5836 {
5837 if (TARGET_PA_20)
5838 return \"fneg,sgl %1,%0\";
5839 else
5840 return \"fsub,sgl %%fr0,%1,%0\";
5841 }"
5842 [(set_attr "type" "fpalu")
5843 (set_attr "length" "4")])
5844
5845 (define_insn "absdf2"
5846 [(set (match_operand:DF 0 "register_operand" "=f")
5847 (abs:DF (match_operand:DF 1 "register_operand" "f")))]
5848 "! TARGET_SOFT_FLOAT"
5849 "fabs,dbl %1,%0"
5850 [(set_attr "type" "fpalu")
5851 (set_attr "length" "4")])
5852
5853 (define_insn "abssf2"
5854 [(set (match_operand:SF 0 "register_operand" "=f")
5855 (abs:SF (match_operand:SF 1 "register_operand" "f")))]
5856 "! TARGET_SOFT_FLOAT"
5857 "fabs,sgl %1,%0"
5858 [(set_attr "type" "fpalu")
5859 (set_attr "length" "4")])
5860
5861 (define_insn "sqrtdf2"
5862 [(set (match_operand:DF 0 "register_operand" "=f")
5863 (sqrt:DF (match_operand:DF 1 "register_operand" "f")))]
5864 "! TARGET_SOFT_FLOAT"
5865 "fsqrt,dbl %1,%0"
5866 [(set_attr "type" "fpsqrtdbl")
5867 (set_attr "length" "4")])
5868
5869 (define_insn "sqrtsf2"
5870 [(set (match_operand:SF 0 "register_operand" "=f")
5871 (sqrt:SF (match_operand:SF 1 "register_operand" "f")))]
5872 "! TARGET_SOFT_FLOAT"
5873 "fsqrt,sgl %1,%0"
5874 [(set_attr "type" "fpsqrtsgl")
5875 (set_attr "length" "4")])
5876
5877 ;; PA 2.0 floating point instructions
5878
5879 ; fmpyfadd patterns
5880 (define_insn ""
5881 [(set (match_operand:DF 0 "register_operand" "=f")
5882 (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
5883 (match_operand:DF 2 "register_operand" "f"))
5884 (match_operand:DF 3 "register_operand" "f")))]
5885 "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
5886 "fmpyfadd,dbl %1,%2,%3,%0"
5887 [(set_attr "type" "fpmuldbl")
5888 (set_attr "length" "4")])
5889
5890 (define_insn ""
5891 [(set (match_operand:DF 0 "register_operand" "=f")
5892 (plus:DF (match_operand:DF 1 "register_operand" "f")
5893 (mult:DF (match_operand:DF 2 "register_operand" "f")
5894 (match_operand:DF 3 "register_operand" "f"))))]
5895 "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
5896 "fmpyfadd,dbl %2,%3,%1,%0"
5897 [(set_attr "type" "fpmuldbl")
5898 (set_attr "length" "4")])
5899
5900 (define_insn ""
5901 [(set (match_operand:SF 0 "register_operand" "=f")
5902 (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
5903 (match_operand:SF 2 "register_operand" "f"))
5904 (match_operand:SF 3 "register_operand" "f")))]
5905 "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
5906 "fmpyfadd,sgl %1,%2,%3,%0"
5907 [(set_attr "type" "fpmulsgl")
5908 (set_attr "length" "4")])
5909
5910 (define_insn ""
5911 [(set (match_operand:SF 0 "register_operand" "=f")
5912 (plus:SF (match_operand:SF 1 "register_operand" "f")
5913 (mult:SF (match_operand:SF 2 "register_operand" "f")
5914 (match_operand:SF 3 "register_operand" "f"))))]
5915 "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
5916 "fmpyfadd,sgl %2,%3,%1,%0"
5917 [(set_attr "type" "fpmulsgl")
5918 (set_attr "length" "4")])
5919
5920 ; fmpynfadd patterns
5921 (define_insn ""
5922 [(set (match_operand:DF 0 "register_operand" "=f")
5923 (minus:DF (match_operand:DF 1 "register_operand" "f")
5924 (mult:DF (match_operand:DF 2 "register_operand" "f")
5925 (match_operand:DF 3 "register_operand" "f"))))]
5926 "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
5927 "fmpynfadd,dbl %2,%3,%1,%0"
5928 [(set_attr "type" "fpmuldbl")
5929 (set_attr "length" "4")])
5930
5931 (define_insn ""
5932 [(set (match_operand:SF 0 "register_operand" "=f")
5933 (minus:SF (match_operand:SF 1 "register_operand" "f")
5934 (mult:SF (match_operand:SF 2 "register_operand" "f")
5935 (match_operand:SF 3 "register_operand" "f"))))]
5936 "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
5937 "fmpynfadd,sgl %2,%3,%1,%0"
5938 [(set_attr "type" "fpmulsgl")
5939 (set_attr "length" "4")])
5940
5941 ; fnegabs patterns
5942 (define_insn ""
5943 [(set (match_operand:DF 0 "register_operand" "=f")
5944 (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))]
5945 "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
5946 "fnegabs,dbl %1,%0"
5947 [(set_attr "type" "fpalu")
5948 (set_attr "length" "4")])
5949
5950 (define_insn ""
5951 [(set (match_operand:SF 0 "register_operand" "=f")
5952 (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))]
5953 "TARGET_PA_20 && ! TARGET_SOFT_FLOAT"
5954 "fnegabs,sgl %1,%0"
5955 [(set_attr "type" "fpalu")
5956 (set_attr "length" "4")])
5957
5958 ;; Generating a fused multiply sequence is a win for this case as it will
5959 ;; reduce the latency for the fused case without impacting the plain
5960 ;; multiply case.
5961 ;;
5962 ;; Similar possibilities exist for fnegabs, shadd and other insns which
5963 ;; perform two operations with the result of the first feeding the second.
5964 (define_insn ""
5965 [(set (match_operand:DF 0 "register_operand" "=f")
5966 (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
5967 (match_operand:DF 2 "register_operand" "f"))
5968 (match_operand:DF 3 "register_operand" "f")))
5969 (set (match_operand:DF 4 "register_operand" "=&f")
5970 (mult:DF (match_dup 1) (match_dup 2)))]
5971 "(! TARGET_SOFT_FLOAT && TARGET_PA_20
5972 && ! (reg_overlap_mentioned_p (operands[4], operands[1])
5973 || reg_overlap_mentioned_p (operands[4], operands[2])))"
5974 "#"
5975 [(set_attr "type" "fpmuldbl")
5976 (set_attr "length" "8")])
5977
5978 ;; We want to split this up during scheduling since we want both insns
5979 ;; to schedule independently.
5980 (define_split
5981 [(set (match_operand:DF 0 "register_operand" "")
5982 (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "")
5983 (match_operand:DF 2 "register_operand" ""))
5984 (match_operand:DF 3 "register_operand" "")))
5985 (set (match_operand:DF 4 "register_operand" "")
5986 (mult:DF (match_dup 1) (match_dup 2)))]
5987 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
5988 [(set (match_dup 4) (mult:DF (match_dup 1) (match_dup 2)))
5989 (set (match_dup 0) (plus:DF (mult:DF (match_dup 1) (match_dup 2))
5990 (match_dup 3)))]
5991 "")
5992
5993 (define_insn ""
5994 [(set (match_operand:SF 0 "register_operand" "=f")
5995 (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
5996 (match_operand:SF 2 "register_operand" "f"))
5997 (match_operand:SF 3 "register_operand" "f")))
5998 (set (match_operand:SF 4 "register_operand" "=&f")
5999 (mult:SF (match_dup 1) (match_dup 2)))]
6000 "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6001 && ! (reg_overlap_mentioned_p (operands[4], operands[1])
6002 || reg_overlap_mentioned_p (operands[4], operands[2])))"
6003 "#"
6004 [(set_attr "type" "fpmuldbl")
6005 (set_attr "length" "8")])
6006
6007 ;; We want to split this up during scheduling since we want both insns
6008 ;; to schedule independently.
6009 (define_split
6010 [(set (match_operand:SF 0 "register_operand" "")
6011 (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "")
6012 (match_operand:SF 2 "register_operand" ""))
6013 (match_operand:SF 3 "register_operand" "")))
6014 (set (match_operand:SF 4 "register_operand" "")
6015 (mult:SF (match_dup 1) (match_dup 2)))]
6016 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6017 [(set (match_dup 4) (mult:SF (match_dup 1) (match_dup 2)))
6018 (set (match_dup 0) (plus:SF (mult:SF (match_dup 1) (match_dup 2))
6019 (match_dup 3)))]
6020 "")
6021
6022 ;; Negating a multiply can be faked by adding zero in a fused multiply-add
6023 ;; instruction.
6024 (define_insn ""
6025 [(set (match_operand:DF 0 "register_operand" "=f")
6026 (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
6027 (match_operand:DF 2 "register_operand" "f"))))]
6028 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6029 "fmpynfadd,dbl %1,%2,%%fr0,%0"
6030 [(set_attr "type" "fpmuldbl")
6031 (set_attr "length" "4")])
6032
6033 (define_insn ""
6034 [(set (match_operand:SF 0 "register_operand" "=f")
6035 (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
6036 (match_operand:SF 2 "register_operand" "f"))))]
6037 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6038 "fmpynfadd,sgl %1,%2,%%fr0,%0"
6039 [(set_attr "type" "fpmuldbl")
6040 (set_attr "length" "4")])
6041
6042 (define_insn ""
6043 [(set (match_operand:DF 0 "register_operand" "=f")
6044 (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
6045 (match_operand:DF 2 "register_operand" "f"))))
6046 (set (match_operand:DF 3 "register_operand" "=&f")
6047 (mult:DF (match_dup 1) (match_dup 2)))]
6048 "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6049 && ! (reg_overlap_mentioned_p (operands[3], operands[1])
6050 || reg_overlap_mentioned_p (operands[3], operands[2])))"
6051 "#"
6052 [(set_attr "type" "fpmuldbl")
6053 (set_attr "length" "8")])
6054
6055 (define_split
6056 [(set (match_operand:DF 0 "register_operand" "")
6057 (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "")
6058 (match_operand:DF 2 "register_operand" ""))))
6059 (set (match_operand:DF 3 "register_operand" "")
6060 (mult:DF (match_dup 1) (match_dup 2)))]
6061 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6062 [(set (match_dup 3) (mult:DF (match_dup 1) (match_dup 2)))
6063 (set (match_dup 0) (neg:DF (mult:DF (match_dup 1) (match_dup 2))))]
6064 "")
6065
6066 (define_insn ""
6067 [(set (match_operand:SF 0 "register_operand" "=f")
6068 (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
6069 (match_operand:SF 2 "register_operand" "f"))))
6070 (set (match_operand:SF 3 "register_operand" "=&f")
6071 (mult:SF (match_dup 1) (match_dup 2)))]
6072 "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6073 && ! (reg_overlap_mentioned_p (operands[3], operands[1])
6074 || reg_overlap_mentioned_p (operands[3], operands[2])))"
6075 "#"
6076 [(set_attr "type" "fpmuldbl")
6077 (set_attr "length" "8")])
6078
6079 (define_split
6080 [(set (match_operand:SF 0 "register_operand" "")
6081 (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "")
6082 (match_operand:SF 2 "register_operand" ""))))
6083 (set (match_operand:SF 3 "register_operand" "")
6084 (mult:SF (match_dup 1) (match_dup 2)))]
6085 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6086 [(set (match_dup 3) (mult:SF (match_dup 1) (match_dup 2)))
6087 (set (match_dup 0) (neg:SF (mult:SF (match_dup 1) (match_dup 2))))]
6088 "")
6089
6090 ;; Now fused multiplies with the result of the multiply negated.
6091 (define_insn ""
6092 [(set (match_operand:DF 0 "register_operand" "=f")
6093 (plus:DF (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
6094 (match_operand:DF 2 "register_operand" "f")))
6095 (match_operand:DF 3 "register_operand" "f")))]
6096 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6097 "fmpynfadd,dbl %1,%2,%3,%0"
6098 [(set_attr "type" "fpmuldbl")
6099 (set_attr "length" "4")])
6100
6101 (define_insn ""
6102 [(set (match_operand:SF 0 "register_operand" "=f")
6103 (plus:SF (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
6104 (match_operand:SF 2 "register_operand" "f")))
6105 (match_operand:SF 3 "register_operand" "f")))]
6106 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6107 "fmpynfadd,sgl %1,%2,%3,%0"
6108 [(set_attr "type" "fpmuldbl")
6109 (set_attr "length" "4")])
6110
6111 (define_insn ""
6112 [(set (match_operand:DF 0 "register_operand" "=f")
6113 (plus:DF (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "f")
6114 (match_operand:DF 2 "register_operand" "f")))
6115 (match_operand:DF 3 "register_operand" "f")))
6116 (set (match_operand:DF 4 "register_operand" "=&f")
6117 (mult:DF (match_dup 1) (match_dup 2)))]
6118 "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6119 && ! (reg_overlap_mentioned_p (operands[4], operands[1])
6120 || reg_overlap_mentioned_p (operands[4], operands[2])))"
6121 "#"
6122 [(set_attr "type" "fpmuldbl")
6123 (set_attr "length" "8")])
6124
6125 (define_split
6126 [(set (match_operand:DF 0 "register_operand" "")
6127 (plus:DF (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "")
6128 (match_operand:DF 2 "register_operand" "")))
6129 (match_operand:DF 3 "register_operand" "")))
6130 (set (match_operand:DF 4 "register_operand" "")
6131 (mult:DF (match_dup 1) (match_dup 2)))]
6132 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6133 [(set (match_dup 4) (mult:DF (match_dup 1) (match_dup 2)))
6134 (set (match_dup 0) (plus:DF (neg:DF (mult:DF (match_dup 1) (match_dup 2)))
6135 (match_dup 3)))]
6136 "")
6137
6138 (define_insn ""
6139 [(set (match_operand:SF 0 "register_operand" "=f")
6140 (plus:SF (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "f")
6141 (match_operand:SF 2 "register_operand" "f")))
6142 (match_operand:SF 3 "register_operand" "f")))
6143 (set (match_operand:SF 4 "register_operand" "=&f")
6144 (mult:SF (match_dup 1) (match_dup 2)))]
6145 "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6146 && ! (reg_overlap_mentioned_p (operands[4], operands[1])
6147 || reg_overlap_mentioned_p (operands[4], operands[2])))"
6148 "#"
6149 [(set_attr "type" "fpmuldbl")
6150 (set_attr "length" "8")])
6151
6152 (define_split
6153 [(set (match_operand:SF 0 "register_operand" "")
6154 (plus:SF (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "")
6155 (match_operand:SF 2 "register_operand" "")))
6156 (match_operand:SF 3 "register_operand" "")))
6157 (set (match_operand:SF 4 "register_operand" "")
6158 (mult:SF (match_dup 1) (match_dup 2)))]
6159 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6160 [(set (match_dup 4) (mult:SF (match_dup 1) (match_dup 2)))
6161 (set (match_dup 0) (plus:SF (neg:SF (mult:SF (match_dup 1) (match_dup 2)))
6162 (match_dup 3)))]
6163 "")
6164
6165 (define_insn ""
6166 [(set (match_operand:DF 0 "register_operand" "=f")
6167 (minus:DF (match_operand:DF 3 "register_operand" "f")
6168 (mult:DF (match_operand:DF 1 "register_operand" "f")
6169 (match_operand:DF 2 "register_operand" "f"))))
6170 (set (match_operand:DF 4 "register_operand" "=&f")
6171 (mult:DF (match_dup 1) (match_dup 2)))]
6172 "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6173 && ! (reg_overlap_mentioned_p (operands[4], operands[1])
6174 || reg_overlap_mentioned_p (operands[4], operands[2])))"
6175 "#"
6176 [(set_attr "type" "fpmuldbl")
6177 (set_attr "length" "8")])
6178
6179 (define_split
6180 [(set (match_operand:DF 0 "register_operand" "")
6181 (minus:DF (match_operand:DF 3 "register_operand" "")
6182 (mult:DF (match_operand:DF 1 "register_operand" "")
6183 (match_operand:DF 2 "register_operand" ""))))
6184 (set (match_operand:DF 4 "register_operand" "")
6185 (mult:DF (match_dup 1) (match_dup 2)))]
6186 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6187 [(set (match_dup 4) (mult:DF (match_dup 1) (match_dup 2)))
6188 (set (match_dup 0) (minus:DF (match_dup 3)
6189 (mult:DF (match_dup 1) (match_dup 2))))]
6190 "")
6191
6192 (define_insn ""
6193 [(set (match_operand:SF 0 "register_operand" "=f")
6194 (minus:SF (match_operand:SF 3 "register_operand" "f")
6195 (mult:SF (match_operand:SF 1 "register_operand" "f")
6196 (match_operand:SF 2 "register_operand" "f"))))
6197 (set (match_operand:SF 4 "register_operand" "=&f")
6198 (mult:SF (match_dup 1) (match_dup 2)))]
6199 "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6200 && ! (reg_overlap_mentioned_p (operands[4], operands[1])
6201 || reg_overlap_mentioned_p (operands[4], operands[2])))"
6202 "#"
6203 [(set_attr "type" "fpmuldbl")
6204 (set_attr "length" "8")])
6205
6206 (define_split
6207 [(set (match_operand:SF 0 "register_operand" "")
6208 (minus:SF (match_operand:SF 3 "register_operand" "")
6209 (mult:SF (match_operand:SF 1 "register_operand" "")
6210 (match_operand:SF 2 "register_operand" ""))))
6211 (set (match_operand:SF 4 "register_operand" "")
6212 (mult:SF (match_dup 1) (match_dup 2)))]
6213 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6214 [(set (match_dup 4) (mult:SF (match_dup 1) (match_dup 2)))
6215 (set (match_dup 0) (minus:SF (match_dup 3)
6216 (mult:SF (match_dup 1) (match_dup 2))))]
6217 "")
6218
6219 (define_insn ""
6220 [(set (match_operand:DF 0 "register_operand" "=f")
6221 (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))
6222 (set (match_operand:DF 2 "register_operand" "=&f") (abs:DF (match_dup 1)))]
6223 "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6224 && ! reg_overlap_mentioned_p (operands[2], operands[1]))"
6225 "#"
6226 [(set_attr "type" "fpalu")
6227 (set_attr "length" "8")])
6228
6229 (define_split
6230 [(set (match_operand:DF 0 "register_operand" "")
6231 (neg:DF (abs:DF (match_operand:DF 1 "register_operand" ""))))
6232 (set (match_operand:DF 2 "register_operand" "") (abs:DF (match_dup 1)))]
6233 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6234 [(set (match_dup 2) (abs:DF (match_dup 1)))
6235 (set (match_dup 0) (neg:DF (abs:DF (match_dup 1))))]
6236 "")
6237
6238 (define_insn ""
6239 [(set (match_operand:SF 0 "register_operand" "=f")
6240 (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))
6241 (set (match_operand:SF 2 "register_operand" "=&f") (abs:SF (match_dup 1)))]
6242 "(! TARGET_SOFT_FLOAT && TARGET_PA_20
6243 && ! reg_overlap_mentioned_p (operands[2], operands[1]))"
6244 "#"
6245 [(set_attr "type" "fpalu")
6246 (set_attr "length" "8")])
6247
6248 (define_split
6249 [(set (match_operand:SF 0 "register_operand" "")
6250 (neg:SF (abs:SF (match_operand:SF 1 "register_operand" ""))))
6251 (set (match_operand:SF 2 "register_operand" "") (abs:SF (match_dup 1)))]
6252 "! TARGET_SOFT_FLOAT && TARGET_PA_20"
6253 [(set (match_dup 2) (abs:SF (match_dup 1)))
6254 (set (match_dup 0) (neg:SF (abs:SF (match_dup 1))))]
6255 "")
6256 \f
6257 ;;- Shift instructions
6258
6259 ;; Optimized special case of shifting.
6260
6261 (define_insn ""
6262 [(set (match_operand:SI 0 "register_operand" "=r")
6263 (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
6264 (const_int 24)))]
6265 ""
6266 "ldb%M1 %1,%0"
6267 [(set_attr "type" "load")
6268 (set_attr "length" "4")])
6269
6270 (define_insn ""
6271 [(set (match_operand:SI 0 "register_operand" "=r")
6272 (lshiftrt:SI (match_operand:SI 1 "memory_operand" "m")
6273 (const_int 16)))]
6274 ""
6275 "ldh%M1 %1,%0"
6276 [(set_attr "type" "load")
6277 (set_attr "length" "4")])
6278
6279 (define_insn ""
6280 [(set (match_operand:SI 0 "register_operand" "=r")
6281 (plus:SI (mult:SI (match_operand:SI 2 "register_operand" "r")
6282 (match_operand:SI 3 "shadd_operand" ""))
6283 (match_operand:SI 1 "register_operand" "r")))]
6284 ""
6285 "{sh%O3addl %2,%1,%0|shladd,l %2,%O3,%1,%0} "
6286 [(set_attr "type" "binary")
6287 (set_attr "length" "4")])
6288
6289 (define_insn ""
6290 [(set (match_operand:DI 0 "register_operand" "=r")
6291 (plus:DI (mult:DI (match_operand:DI 2 "register_operand" "r")
6292 (match_operand:DI 3 "shadd_operand" ""))
6293 (match_operand:DI 1 "register_operand" "r")))]
6294 "TARGET_64BIT"
6295 "shladd,l %2,%O3,%1,%0"
6296 [(set_attr "type" "binary")
6297 (set_attr "length" "4")])
6298
6299 (define_expand "ashlsi3"
6300 [(set (match_operand:SI 0 "register_operand" "")
6301 (ashift:SI (match_operand:SI 1 "lhs_lshift_operand" "")
6302 (match_operand:SI 2 "arith32_operand" "")))]
6303 ""
6304 "
6305 {
6306 if (GET_CODE (operands[2]) != CONST_INT)
6307 {
6308 rtx temp = gen_reg_rtx (SImode);
6309 emit_insn (gen_subsi3 (temp, GEN_INT (31), operands[2]));
6310 if (GET_CODE (operands[1]) == CONST_INT)
6311 emit_insn (gen_zvdep_imm32 (operands[0], operands[1], temp));
6312 else
6313 emit_insn (gen_zvdep32 (operands[0], operands[1], temp));
6314 DONE;
6315 }
6316 /* Make sure both inputs are not constants,
6317 there are no patterns for that. */
6318 operands[1] = force_reg (SImode, operands[1]);
6319 }")
6320
6321 (define_insn ""
6322 [(set (match_operand:SI 0 "register_operand" "=r")
6323 (ashift:SI (match_operand:SI 1 "register_operand" "r")
6324 (match_operand:SI 2 "const_int_operand" "n")))]
6325 ""
6326 "{zdep|depw,z} %1,%P2,%L2,%0"
6327 [(set_attr "type" "shift")
6328 (set_attr "length" "4")])
6329
6330 ; Match cases of op1 a CONST_INT here that zvdep_imm32 doesn't handle.
6331 ; Doing it like this makes slightly better code since reload can
6332 ; replace a register with a known value in range -16..15 with a
6333 ; constant. Ideally, we would like to merge zvdep32 and zvdep_imm32,
6334 ; but since we have no more CONST_OK... characters, that is not
6335 ; possible.
6336 (define_insn "zvdep32"
6337 [(set (match_operand:SI 0 "register_operand" "=r,r")
6338 (ashift:SI (match_operand:SI 1 "arith5_operand" "r,L")
6339 (minus:SI (const_int 31)
6340 (match_operand:SI 2 "register_operand" "q,q"))))]
6341 ""
6342 "@
6343 {zvdep %1,32,%0|depw,z %1,%%sar,32,%0}
6344 {zvdepi %1,32,%0|depwi,z %1,%%sar,32,%0}"
6345 [(set_attr "type" "shift,shift")
6346 (set_attr "length" "4,4")])
6347
6348 (define_insn "zvdep_imm32"
6349 [(set (match_operand:SI 0 "register_operand" "=r")
6350 (ashift:SI (match_operand:SI 1 "lhs_lshift_cint_operand" "")
6351 (minus:SI (const_int 31)
6352 (match_operand:SI 2 "register_operand" "q"))))]
6353 ""
6354 "*
6355 {
6356 int x = INTVAL (operands[1]);
6357 operands[2] = GEN_INT (4 + exact_log2 ((x >> 4) + 1));
6358 operands[1] = GEN_INT ((x & 0xf) - 0x10);
6359 return \"{zvdepi %1,%2,%0|depwi,z %1,%%sar,%2,%0}\";
6360 }"
6361 [(set_attr "type" "shift")
6362 (set_attr "length" "4")])
6363
6364 (define_insn "vdepi_ior"
6365 [(set (match_operand:SI 0 "register_operand" "=r")
6366 (ior:SI (ashift:SI (match_operand:SI 1 "const_int_operand" "")
6367 (minus:SI (const_int 31)
6368 (match_operand:SI 2 "register_operand" "q")))
6369 (match_operand:SI 3 "register_operand" "0")))]
6370 ; accept ...0001...1, can this be generalized?
6371 "exact_log2 (INTVAL (operands[1]) + 1) >= 0"
6372 "*
6373 {
6374 int x = INTVAL (operands[1]);
6375 operands[2] = GEN_INT (exact_log2 (x + 1));
6376 return \"{vdepi -1,%2,%0|depwi -1,%%sar,%2,%0}\";
6377 }"
6378 [(set_attr "type" "shift")
6379 (set_attr "length" "4")])
6380
6381 (define_insn "vdepi_and"
6382 [(set (match_operand:SI 0 "register_operand" "=r")
6383 (and:SI (rotate:SI (match_operand:SI 1 "const_int_operand" "")
6384 (minus:SI (const_int 31)
6385 (match_operand:SI 2 "register_operand" "q")))
6386 (match_operand:SI 3 "register_operand" "0")))]
6387 ; this can be generalized...!
6388 "INTVAL (operands[1]) == -2"
6389 "*
6390 {
6391 int x = INTVAL (operands[1]);
6392 operands[2] = GEN_INT (exact_log2 ((~x) + 1));
6393 return \"{vdepi 0,%2,%0|depwi 0,%%sar,%2,%0}\";
6394 }"
6395 [(set_attr "type" "shift")
6396 (set_attr "length" "4")])
6397
6398 (define_expand "ashldi3"
6399 [(set (match_operand:DI 0 "register_operand" "")
6400 (ashift:DI (match_operand:DI 1 "lhs_lshift_operand" "")
6401 (match_operand:DI 2 "arith32_operand" "")))]
6402 "TARGET_64BIT"
6403 "
6404 {
6405 if (GET_CODE (operands[2]) != CONST_INT)
6406 {
6407 rtx temp = gen_reg_rtx (DImode);
6408 emit_insn (gen_subdi3 (temp, GEN_INT (63), operands[2]));
6409 if (GET_CODE (operands[1]) == CONST_INT)
6410 emit_insn (gen_zvdep_imm64 (operands[0], operands[1], temp));
6411 else
6412 emit_insn (gen_zvdep64 (operands[0], operands[1], temp));
6413 DONE;
6414 }
6415 /* Make sure both inputs are not constants,
6416 there are no patterns for that. */
6417 operands[1] = force_reg (DImode, operands[1]);
6418 }")
6419
6420 (define_insn ""
6421 [(set (match_operand:DI 0 "register_operand" "=r")
6422 (ashift:DI (match_operand:DI 1 "register_operand" "r")
6423 (match_operand:DI 2 "const_int_operand" "n")))]
6424 "TARGET_64BIT"
6425 "depd,z %1,%p2,%Q2,%0"
6426 [(set_attr "type" "shift")
6427 (set_attr "length" "4")])
6428
6429 ; Match cases of op1 a CONST_INT here that zvdep_imm64 doesn't handle.
6430 ; Doing it like this makes slightly better code since reload can
6431 ; replace a register with a known value in range -16..15 with a
6432 ; constant. Ideally, we would like to merge zvdep64 and zvdep_imm64,
6433 ; but since we have no more CONST_OK... characters, that is not
6434 ; possible.
6435 (define_insn "zvdep64"
6436 [(set (match_operand:DI 0 "register_operand" "=r,r")
6437 (ashift:DI (match_operand:DI 1 "arith5_operand" "r,L")
6438 (minus:DI (const_int 63)
6439 (match_operand:DI 2 "register_operand" "q,q"))))]
6440 "TARGET_64BIT"
6441 "@
6442 depd,z %1,%%sar,64,%0
6443 depdi,z %1,%%sar,64,%0"
6444 [(set_attr "type" "shift,shift")
6445 (set_attr "length" "4,4")])
6446
6447 (define_insn "zvdep_imm64"
6448 [(set (match_operand:DI 0 "register_operand" "=r")
6449 (ashift:DI (match_operand:DI 1 "lhs_lshift_cint_operand" "")
6450 (minus:DI (const_int 63)
6451 (match_operand:DI 2 "register_operand" "q"))))]
6452 "TARGET_64BIT"
6453 "*
6454 {
6455 int x = INTVAL (operands[1]);
6456 operands[2] = GEN_INT (4 + exact_log2 ((x >> 4) + 1));
6457 operands[1] = GEN_INT ((x & 0x1f) - 0x20);
6458 return \"depdi,z %1,%%sar,%2,%0\";
6459 }"
6460 [(set_attr "type" "shift")
6461 (set_attr "length" "4")])
6462
6463 (define_insn ""
6464 [(set (match_operand:DI 0 "register_operand" "=r")
6465 (ior:DI (ashift:DI (match_operand:DI 1 "const_int_operand" "")
6466 (minus:DI (const_int 63)
6467 (match_operand:DI 2 "register_operand" "q")))
6468 (match_operand:DI 3 "register_operand" "0")))]
6469 ; accept ...0001...1, can this be generalized?
6470 "TARGET_64BIT && exact_log2 (INTVAL (operands[1]) + 1) >= 0"
6471 "*
6472 {
6473 int x = INTVAL (operands[1]);
6474 operands[2] = GEN_INT (exact_log2 (x + 1));
6475 return \"depdi -1,%%sar,%2,%0\";
6476 }"
6477 [(set_attr "type" "shift")
6478 (set_attr "length" "4")])
6479
6480 (define_insn ""
6481 [(set (match_operand:DI 0 "register_operand" "=r")
6482 (and:DI (rotate:DI (match_operand:DI 1 "const_int_operand" "")
6483 (minus:DI (const_int 63)
6484 (match_operand:DI 2 "register_operand" "q")))
6485 (match_operand:DI 3 "register_operand" "0")))]
6486 ; this can be generalized...!
6487 "TARGET_64BIT && INTVAL (operands[1]) == -2"
6488 "*
6489 {
6490 int x = INTVAL (operands[1]);
6491 operands[2] = GEN_INT (exact_log2 ((~x) + 1));
6492 return \"depdi 0,%%sar,%2,%0\";
6493 }"
6494 [(set_attr "type" "shift")
6495 (set_attr "length" "4")])
6496
6497 (define_expand "ashrsi3"
6498 [(set (match_operand:SI 0 "register_operand" "")
6499 (ashiftrt:SI (match_operand:SI 1 "register_operand" "")
6500 (match_operand:SI 2 "arith32_operand" "")))]
6501 ""
6502 "
6503 {
6504 if (GET_CODE (operands[2]) != CONST_INT)
6505 {
6506 rtx temp = gen_reg_rtx (SImode);
6507 emit_insn (gen_subsi3 (temp, GEN_INT (31), operands[2]));
6508 emit_insn (gen_vextrs32 (operands[0], operands[1], temp));
6509 DONE;
6510 }
6511 }")
6512
6513 (define_insn ""
6514 [(set (match_operand:SI 0 "register_operand" "=r")
6515 (ashiftrt:SI (match_operand:SI 1 "register_operand" "r")
6516 (match_operand:SI 2 "const_int_operand" "n")))]
6517 ""
6518 "{extrs|extrw,s} %1,%P2,%L2,%0"
6519 [(set_attr "type" "shift")
6520 (set_attr "length" "4")])
6521
6522 (define_insn "vextrs32"
6523 [(set (match_operand:SI 0 "register_operand" "=r")
6524 (ashiftrt:SI (match_operand:SI 1 "register_operand" "r")
6525 (minus:SI (const_int 31)
6526 (match_operand:SI 2 "register_operand" "q"))))]
6527 ""
6528 "{vextrs %1,32,%0|extrw,s %1,%%sar,32,%0}"
6529 [(set_attr "type" "shift")
6530 (set_attr "length" "4")])
6531
6532 (define_expand "ashrdi3"
6533 [(set (match_operand:DI 0 "register_operand" "")
6534 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
6535 (match_operand:DI 2 "arith32_operand" "")))]
6536 "TARGET_64BIT"
6537 "
6538 {
6539 if (GET_CODE (operands[2]) != CONST_INT)
6540 {
6541 rtx temp = gen_reg_rtx (DImode);
6542 emit_insn (gen_subdi3 (temp, GEN_INT (63), operands[2]));
6543 emit_insn (gen_vextrs64 (operands[0], operands[1], temp));
6544 DONE;
6545 }
6546 }")
6547
6548 (define_insn ""
6549 [(set (match_operand:DI 0 "register_operand" "=r")
6550 (ashiftrt:DI (match_operand:DI 1 "register_operand" "r")
6551 (match_operand:DI 2 "const_int_operand" "n")))]
6552 "TARGET_64BIT"
6553 "extrd,s %1,%p2,%Q2,%0"
6554 [(set_attr "type" "shift")
6555 (set_attr "length" "4")])
6556
6557 (define_insn "vextrs64"
6558 [(set (match_operand:DI 0 "register_operand" "=r")
6559 (ashiftrt:DI (match_operand:DI 1 "register_operand" "r")
6560 (minus:DI (const_int 63)
6561 (match_operand:DI 2 "register_operand" "q"))))]
6562 "TARGET_64BIT"
6563 "extrd,s %1,%%sar,64,%0"
6564 [(set_attr "type" "shift")
6565 (set_attr "length" "4")])
6566
6567 (define_insn "lshrsi3"
6568 [(set (match_operand:SI 0 "register_operand" "=r,r")
6569 (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
6570 (match_operand:SI 2 "arith32_operand" "q,n")))]
6571 ""
6572 "@
6573 {vshd %%r0,%1,%0|shrpw %%r0,%1,%%sar,%0}
6574 {extru|extrw,u} %1,%P2,%L2,%0"
6575 [(set_attr "type" "shift")
6576 (set_attr "length" "4")])
6577
6578 (define_insn "lshrdi3"
6579 [(set (match_operand:DI 0 "register_operand" "=r,r")
6580 (lshiftrt:DI (match_operand:DI 1 "register_operand" "r,r")
6581 (match_operand:DI 2 "arith32_operand" "q,n")))]
6582 "TARGET_64BIT"
6583 "@
6584 shrpd %%r0,%1,%%sar,%0
6585 extrd,u %1,%p2,%Q2,%0"
6586 [(set_attr "type" "shift")
6587 (set_attr "length" "4")])
6588
6589 (define_insn "rotrsi3"
6590 [(set (match_operand:SI 0 "register_operand" "=r,r")
6591 (rotatert:SI (match_operand:SI 1 "register_operand" "r,r")
6592 (match_operand:SI 2 "arith32_operand" "q,n")))]
6593 ""
6594 "*
6595 {
6596 if (GET_CODE (operands[2]) == CONST_INT)
6597 {
6598 operands[2] = GEN_INT (INTVAL (operands[2]) & 31);
6599 return \"{shd|shrpw} %1,%1,%2,%0\";
6600 }
6601 else
6602 return \"{vshd %1,%1,%0|shrpw %1,%1,%%sar,%0}\";
6603 }"
6604 [(set_attr "type" "shift")
6605 (set_attr "length" "4")])
6606
6607 (define_expand "rotlsi3"
6608 [(set (match_operand:SI 0 "register_operand" "")
6609 (rotate:SI (match_operand:SI 1 "register_operand" "")
6610 (match_operand:SI 2 "arith32_operand" "")))]
6611 ""
6612 "
6613 {
6614 if (GET_CODE (operands[2]) != CONST_INT)
6615 {
6616 rtx temp = gen_reg_rtx (SImode);
6617 emit_insn (gen_subsi3 (temp, GEN_INT (32), operands[2]));
6618 emit_insn (gen_rotrsi3 (operands[0], operands[1], temp));
6619 DONE;
6620 }
6621 /* Else expand normally. */
6622 }")
6623
6624 (define_insn ""
6625 [(set (match_operand:SI 0 "register_operand" "=r")
6626 (rotate:SI (match_operand:SI 1 "register_operand" "r")
6627 (match_operand:SI 2 "const_int_operand" "n")))]
6628 ""
6629 "*
6630 {
6631 operands[2] = GEN_INT ((32 - INTVAL (operands[2])) & 31);
6632 return \"{shd|shrpw} %1,%1,%2,%0\";
6633 }"
6634 [(set_attr "type" "shift")
6635 (set_attr "length" "4")])
6636
6637 (define_insn ""
6638 [(set (match_operand:SI 0 "register_operand" "=r")
6639 (match_operator:SI 5 "plus_xor_ior_operator"
6640 [(ashift:SI (match_operand:SI 1 "register_operand" "r")
6641 (match_operand:SI 3 "const_int_operand" "n"))
6642 (lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
6643 (match_operand:SI 4 "const_int_operand" "n"))]))]
6644 "INTVAL (operands[3]) + INTVAL (operands[4]) == 32"
6645 "{shd|shrpw} %1,%2,%4,%0"
6646 [(set_attr "type" "shift")
6647 (set_attr "length" "4")])
6648
6649 (define_insn ""
6650 [(set (match_operand:SI 0 "register_operand" "=r")
6651 (match_operator:SI 5 "plus_xor_ior_operator"
6652 [(lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
6653 (match_operand:SI 4 "const_int_operand" "n"))
6654 (ashift:SI (match_operand:SI 1 "register_operand" "r")
6655 (match_operand:SI 3 "const_int_operand" "n"))]))]
6656 "INTVAL (operands[3]) + INTVAL (operands[4]) == 32"
6657 "{shd|shrpw} %1,%2,%4,%0"
6658 [(set_attr "type" "shift")
6659 (set_attr "length" "4")])
6660
6661 (define_insn ""
6662 [(set (match_operand:SI 0 "register_operand" "=r")
6663 (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
6664 (match_operand:SI 2 "const_int_operand" ""))
6665 (match_operand:SI 3 "const_int_operand" "")))]
6666 "exact_log2 (1 + (INTVAL (operands[3]) >> (INTVAL (operands[2]) & 31))) >= 0"
6667 "*
6668 {
6669 int cnt = INTVAL (operands[2]) & 31;
6670 operands[3] = GEN_INT (exact_log2 (1 + (INTVAL (operands[3]) >> cnt)));
6671 operands[2] = GEN_INT (31 - cnt);
6672 return \"{zdep|depw,z} %1,%2,%3,%0\";
6673 }"
6674 [(set_attr "type" "shift")
6675 (set_attr "length" "4")])
6676 \f
6677 ;; Unconditional and other jump instructions.
6678
6679 ;; This can only be used in a leaf function, so we do
6680 ;; not need to use the PIC register when generating PIC code.
6681 (define_insn "return"
6682 [(return)
6683 (use (reg:SI 2))
6684 (const_int 0)]
6685 "hppa_can_use_return_insn_p ()"
6686 "*
6687 {
6688 if (TARGET_PA_20)
6689 return \"bve%* (%%r2)\";
6690 return \"bv%* %%r0(%%r2)\";
6691 }"
6692 [(set_attr "type" "branch")
6693 (set_attr "length" "4")])
6694
6695 ;; Emit a different pattern for functions which have non-trivial
6696 ;; epilogues so as not to confuse jump and reorg.
6697 (define_insn "return_internal"
6698 [(return)
6699 (use (reg:SI 2))
6700 (const_int 1)]
6701 ""
6702 "*
6703 {
6704 if (TARGET_PA_20)
6705 return \"bve%* (%%r2)\";
6706 return \"bv%* %%r0(%%r2)\";
6707 }"
6708 [(set_attr "type" "branch")
6709 (set_attr "length" "4")])
6710
6711 ;; This is used for eh returns which bypass the return stub.
6712 (define_insn "return_external_pic"
6713 [(return)
6714 (clobber (reg:SI 1))
6715 (use (reg:SI 2))]
6716 "!TARGET_NO_SPACE_REGS
6717 && !TARGET_PA_20
6718 && flag_pic && current_function_calls_eh_return"
6719 "ldsid (%%sr0,%%r2),%%r1\;mtsp %%r1,%%sr0\;be%* 0(%%sr0,%%r2)"
6720 [(set_attr "type" "branch")
6721 (set_attr "length" "12")])
6722
6723 (define_expand "prologue"
6724 [(const_int 0)]
6725 ""
6726 "hppa_expand_prologue ();DONE;")
6727
6728 (define_expand "sibcall_epilogue"
6729 [(return)]
6730 ""
6731 "
6732 {
6733 hppa_expand_epilogue ();
6734 DONE;
6735 }")
6736
6737 (define_expand "epilogue"
6738 [(return)]
6739 ""
6740 "
6741 {
6742 /* Try to use the trivial return first. Else use the full
6743 epilogue. */
6744 if (hppa_can_use_return_insn_p ())
6745 emit_jump_insn (gen_return ());
6746 else
6747 {
6748 rtx x;
6749
6750 hppa_expand_epilogue ();
6751
6752 /* EH returns bypass the normal return stub. Thus, we must do an
6753 interspace branch to return from functions that call eh_return.
6754 This is only a problem for returns from shared code on ports
6755 using space registers. */
6756 if (!TARGET_NO_SPACE_REGS
6757 && !TARGET_PA_20
6758 && flag_pic && current_function_calls_eh_return)
6759 x = gen_return_external_pic ();
6760 else
6761 x = gen_return_internal ();
6762
6763 emit_jump_insn (x);
6764 }
6765 DONE;
6766 }")
6767
6768 ; Used by hppa_profile_hook to load the starting address of the current
6769 ; function; operand 1 contains the address of the label in operand 3
6770 (define_insn "load_offset_label_address"
6771 [(set (match_operand:SI 0 "register_operand" "=r")
6772 (plus:SI (match_operand:SI 1 "register_operand" "r")
6773 (minus:SI (match_operand:SI 2 "" "")
6774 (label_ref:SI (match_operand 3 "" "")))))]
6775 ""
6776 "ldo %2-%l3(%1),%0"
6777 [(set_attr "type" "multi")
6778 (set_attr "length" "4")])
6779
6780 ; Output a code label and load its address.
6781 (define_insn "lcla1"
6782 [(set (match_operand:SI 0 "register_operand" "=r")
6783 (label_ref:SI (match_operand 1 "" "")))
6784 (const_int 0)]
6785 "!TARGET_PA_20"
6786 "*
6787 {
6788 output_asm_insn (\"bl .+8,%0\;depi 0,31,2,%0\", operands);
6789 (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
6790 CODE_LABEL_NUMBER (operands[1]));
6791 return \"\";
6792 }"
6793 [(set_attr "type" "multi")
6794 (set_attr "length" "8")])
6795
6796 (define_insn "lcla2"
6797 [(set (match_operand:SI 0 "register_operand" "=r")
6798 (label_ref:SI (match_operand 1 "" "")))
6799 (const_int 0)]
6800 "TARGET_PA_20"
6801 "*
6802 {
6803 (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
6804 CODE_LABEL_NUMBER (operands[1]));
6805 return \"mfia %0\";
6806 }"
6807 [(set_attr "type" "move")
6808 (set_attr "length" "4")])
6809
6810 (define_insn "blockage"
6811 [(unspec_volatile [(const_int 2)] UNSPECV_BLOCKAGE)]
6812 ""
6813 ""
6814 [(set_attr "length" "0")])
6815
6816 (define_insn "jump"
6817 [(set (pc) (label_ref (match_operand 0 "" "")))]
6818 ""
6819 "*
6820 {
6821 /* An unconditional branch which can reach its target. */
6822 if (get_attr_length (insn) != 24
6823 && get_attr_length (insn) != 16)
6824 return \"b%* %l0\";
6825
6826 return output_lbranch (operands[0], insn);
6827 }"
6828 [(set_attr "type" "uncond_branch")
6829 (set_attr "pa_combine_type" "uncond_branch")
6830 (set (attr "length")
6831 (cond [(eq (symbol_ref "jump_in_call_delay (insn)") (const_int 1))
6832 (if_then_else (lt (abs (minus (match_dup 0)
6833 (plus (pc) (const_int 8))))
6834 (const_int 8184))
6835 (const_int 4)
6836 (const_int 8))
6837 (ge (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
6838 (const_int 262100))
6839 (if_then_else (eq (symbol_ref "flag_pic") (const_int 0))
6840 (const_int 16)
6841 (const_int 24))]
6842 (const_int 4)))])
6843
6844 ;;; Hope this is only within a function...
6845 (define_insn "indirect_jump"
6846 [(set (pc) (match_operand 0 "register_operand" "r"))]
6847 "GET_MODE (operands[0]) == word_mode"
6848 "bv%* %%r0(%0)"
6849 [(set_attr "type" "branch")
6850 (set_attr "length" "4")])
6851
6852 ;;; An indirect jump can be optimized to a direct jump. GAS for the
6853 ;;; SOM target doesn't allow branching to a label inside a function.
6854 ;;; We also don't correctly compute branch distances for labels
6855 ;;; outside the current function. Thus, we use an indirect jump can't
6856 ;;; be optimized to a direct jump for all targets. We assume that
6857 ;;; the branch target is in the same space (i.e., nested function
6858 ;;; jumping to a label in an outer function in the same translation
6859 ;;; unit).
6860 (define_expand "nonlocal_goto"
6861 [(use (match_operand 0 "general_operand" ""))
6862 (use (match_operand 1 "general_operand" ""))
6863 (use (match_operand 2 "general_operand" ""))
6864 (use (match_operand 3 "general_operand" ""))]
6865 ""
6866 {
6867 rtx lab = operands[1];
6868 rtx stack = operands[2];
6869 rtx fp = operands[3];
6870
6871 lab = copy_to_reg (lab);
6872
6873 emit_insn (gen_rtx_CLOBBER (VOIDmode,
6874 gen_rtx_MEM (BLKmode,
6875 gen_rtx_SCRATCH (VOIDmode))));
6876 emit_insn (gen_rtx_CLOBBER (VOIDmode,
6877 gen_rtx_MEM (BLKmode,
6878 hard_frame_pointer_rtx)));
6879
6880 /* Restore the frame pointer. The virtual_stack_vars_rtx is saved
6881 instead of the hard_frame_pointer_rtx in the save area. As a
6882 result, an extra instruction is needed to adjust for the offset
6883 of the virtual stack variables and the frame pointer. */
6884 if (GET_CODE (fp) != REG)
6885 fp = force_reg (Pmode, fp);
6886 emit_move_insn (virtual_stack_vars_rtx, fp);
6887
6888 emit_stack_restore (SAVE_NONLOCAL, stack, NULL_RTX);
6889
6890 emit_insn (gen_rtx_USE (VOIDmode, hard_frame_pointer_rtx));
6891 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
6892
6893 /* Nonlocal goto jumps are only used between functions in the same
6894 translation unit. Thus, we can avoid the extra overhead of an
6895 interspace jump. */
6896 emit_jump_insn (gen_indirect_goto (lab));
6897 emit_barrier ();
6898 DONE;
6899 })
6900
6901 (define_insn "indirect_goto"
6902 [(unspec [(match_operand 0 "register_operand" "=r")] UNSPEC_GOTO)]
6903 "GET_MODE (operands[0]) == word_mode"
6904 "bv%* %%r0(%0)"
6905 [(set_attr "type" "branch")
6906 (set_attr "length" "4")])
6907
6908 ;;; This jump is used in branch tables where the insn length is fixed.
6909 ;;; The length of this insn is adjusted if the delay slot is not filled.
6910 (define_insn "short_jump"
6911 [(set (pc) (label_ref (match_operand 0 "" "")))
6912 (const_int 0)]
6913 ""
6914 "b%* %l0%#"
6915 [(set_attr "type" "btable_branch")
6916 (set_attr "length" "4")])
6917
6918 ;; Subroutines of "casesi".
6919 ;; operand 0 is index
6920 ;; operand 1 is the minimum bound
6921 ;; operand 2 is the maximum bound - minimum bound + 1
6922 ;; operand 3 is CODE_LABEL for the table;
6923 ;; operand 4 is the CODE_LABEL to go to if index out of range.
6924
6925 (define_expand "casesi"
6926 [(match_operand:SI 0 "general_operand" "")
6927 (match_operand:SI 1 "const_int_operand" "")
6928 (match_operand:SI 2 "const_int_operand" "")
6929 (match_operand 3 "" "")
6930 (match_operand 4 "" "")]
6931 ""
6932 "
6933 {
6934 if (GET_CODE (operands[0]) != REG)
6935 operands[0] = force_reg (SImode, operands[0]);
6936
6937 if (operands[1] != const0_rtx)
6938 {
6939 rtx index = gen_reg_rtx (SImode);
6940
6941 operands[1] = GEN_INT (-INTVAL (operands[1]));
6942 if (!INT_14_BITS (operands[1]))
6943 operands[1] = force_reg (SImode, operands[1]);
6944 emit_insn (gen_addsi3 (index, operands[0], operands[1]));
6945 operands[0] = index;
6946 }
6947
6948 /* In 64bit mode we must make sure to wipe the upper bits of the register
6949 just in case the addition overflowed or we had random bits in the
6950 high part of the register. */
6951 if (TARGET_64BIT)
6952 {
6953 rtx index = gen_reg_rtx (DImode);
6954
6955 emit_insn (gen_extendsidi2 (index, operands[0]));
6956 operands[0] = gen_rtx_SUBREG (SImode, index, 4);
6957 }
6958
6959 if (!INT_5_BITS (operands[2]))
6960 operands[2] = force_reg (SImode, operands[2]);
6961
6962 /* This branch prevents us finding an insn for the delay slot of the
6963 following vectored branch. It might be possible to use the delay
6964 slot if an index value of -1 was used to transfer to the out-of-range
6965 label. In order to do this, we would have to output the -1 vector
6966 element after the delay insn. The casesi output code would have to
6967 check if the casesi insn is in a delay branch sequence and output
6968 the delay insn if one is found. If this was done, then it might
6969 then be worthwhile to split the casesi patterns to improve scheduling.
6970 However, it's not clear that all this extra complexity is worth
6971 the effort. */
6972 emit_insn (gen_cmpsi (operands[0], operands[2]));
6973 emit_jump_insn (gen_bgtu (operands[4]));
6974
6975 if (TARGET_BIG_SWITCH)
6976 {
6977 if (TARGET_64BIT)
6978 {
6979 rtx tmp1 = gen_reg_rtx (DImode);
6980 rtx tmp2 = gen_reg_rtx (DImode);
6981
6982 emit_jump_insn (gen_casesi64p (operands[0], operands[3],
6983 tmp1, tmp2));
6984 }
6985 else
6986 {
6987 rtx tmp1 = gen_reg_rtx (SImode);
6988
6989 if (flag_pic)
6990 {
6991 rtx tmp2 = gen_reg_rtx (SImode);
6992
6993 emit_jump_insn (gen_casesi32p (operands[0], operands[3],
6994 tmp1, tmp2));
6995 }
6996 else
6997 emit_jump_insn (gen_casesi32 (operands[0], operands[3], tmp1));
6998 }
6999 }
7000 else
7001 emit_jump_insn (gen_casesi0 (operands[0], operands[3]));
7002 DONE;
7003 }")
7004
7005 ;;; The rtl for this pattern doesn't accurately describe what the insn
7006 ;;; actually does, particularly when case-vector elements are exploded
7007 ;;; in pa_reorg. However, the initial SET in these patterns must show
7008 ;;; the connection of the insn to the following jump table.
7009 (define_insn "casesi0"
7010 [(set (pc) (mem:SI (plus:SI
7011 (mult:SI (match_operand:SI 0 "register_operand" "r")
7012 (const_int 4))
7013 (label_ref (match_operand 1 "" "")))))]
7014 ""
7015 "blr,n %0,%%r0\;nop"
7016 [(set_attr "type" "multi")
7017 (set_attr "length" "8")])
7018
7019 ;;; 32-bit code, absolute branch table.
7020 (define_insn "casesi32"
7021 [(set (pc) (mem:SI (plus:SI
7022 (mult:SI (match_operand:SI 0 "register_operand" "r")
7023 (const_int 4))
7024 (label_ref (match_operand 1 "" "")))))
7025 (clobber (match_operand:SI 2 "register_operand" "=&r"))]
7026 "!TARGET_64BIT && TARGET_BIG_SWITCH"
7027 "ldil L'%l1,%2\;ldo R'%l1(%2),%2\;{ldwx|ldw},s %0(%2),%2\;bv,n %%r0(%2)"
7028 [(set_attr "type" "multi")
7029 (set_attr "length" "16")])
7030
7031 ;;; 32-bit code, relative branch table.
7032 (define_insn "casesi32p"
7033 [(set (pc) (mem:SI (plus:SI
7034 (mult:SI (match_operand:SI 0 "register_operand" "r")
7035 (const_int 4))
7036 (label_ref (match_operand 1 "" "")))))
7037 (clobber (match_operand:SI 2 "register_operand" "=&a"))
7038 (clobber (match_operand:SI 3 "register_operand" "=&r"))]
7039 "!TARGET_64BIT && TARGET_BIG_SWITCH"
7040 "{bl .+8,%2\;depi 0,31,2,%2|mfia %2}\;ldo {16|20}(%2),%2\;\
7041 {ldwx|ldw},s %0(%2),%3\;{addl|add,l} %2,%3,%3\;bv,n %%r0(%3)"
7042 [(set_attr "type" "multi")
7043 (set (attr "length")
7044 (if_then_else (ne (symbol_ref "TARGET_PA_20") (const_int 0))
7045 (const_int 20)
7046 (const_int 24)))])
7047
7048 ;;; 64-bit code, 32-bit relative branch table.
7049 (define_insn "casesi64p"
7050 [(set (pc) (mem:DI (plus:DI
7051 (mult:DI (sign_extend:DI
7052 (match_operand:SI 0 "register_operand" "r"))
7053 (const_int 8))
7054 (label_ref (match_operand 1 "" "")))))
7055 (clobber (match_operand:DI 2 "register_operand" "=&r"))
7056 (clobber (match_operand:DI 3 "register_operand" "=&r"))]
7057 "TARGET_64BIT && TARGET_BIG_SWITCH"
7058 "mfia %2\;ldo 24(%2),%2\;ldw,s %0(%2),%3\;extrd,s %3,63,32,%3\;\
7059 add,l %2,%3,%3\;bv,n %%r0(%3)"
7060 [(set_attr "type" "multi")
7061 (set_attr "length" "24")])
7062
7063
7064 ;; Call patterns.
7065 ;;- jump to subroutine
7066
7067 (define_expand "call"
7068 [(parallel [(call (match_operand:SI 0 "" "")
7069 (match_operand 1 "" ""))
7070 (clobber (reg:SI 2))])]
7071 ""
7072 "
7073 {
7074 rtx op, call_insn;
7075 rtx nb = operands[1];
7076
7077 if (TARGET_PORTABLE_RUNTIME)
7078 op = force_reg (SImode, XEXP (operands[0], 0));
7079 else
7080 op = XEXP (operands[0], 0);
7081
7082 if (TARGET_64BIT)
7083 {
7084 if (!virtuals_instantiated)
7085 emit_move_insn (arg_pointer_rtx,
7086 gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
7087 GEN_INT (64)));
7088 else
7089 {
7090 /* The loop pass can generate new libcalls after the virtual
7091 registers are instantiated when fpregs are disabled because
7092 the only method that we have for doing DImode multiplication
7093 is with a libcall. This could be trouble if we haven't
7094 allocated enough space for the outgoing arguments. */
7095 if (INTVAL (nb) > current_function_outgoing_args_size)
7096 abort ();
7097
7098 emit_move_insn (arg_pointer_rtx,
7099 gen_rtx_PLUS (word_mode, stack_pointer_rtx,
7100 GEN_INT (STACK_POINTER_OFFSET + 64)));
7101 }
7102 }
7103
7104 /* Use two different patterns for calls to explicitly named functions
7105 and calls through function pointers. This is necessary as these two
7106 types of calls use different calling conventions, and CSE might try
7107 to change the named call into an indirect call in some cases (using
7108 two patterns keeps CSE from performing this optimization).
7109
7110 We now use even more call patterns as there was a subtle bug in
7111 attempting to restore the pic register after a call using a simple
7112 move insn. During reload, a instruction involving a pseudo register
7113 with no explicit dependence on the PIC register can be converted
7114 to an equivalent load from memory using the PIC register. If we
7115 emit a simple move to restore the PIC register in the initial rtl
7116 generation, then it can potentially be repositioned during scheduling.
7117 and an instruction that eventually uses the PIC register may end up
7118 between the call and the PIC register restore.
7119
7120 This only worked because there is a post call group of instructions
7121 that are scheduled with the call. These instructions are included
7122 in the same basic block as the call. However, calls can throw in
7123 C++ code and a basic block has to terminate at the call if the call
7124 can throw. This results in the PIC register restore being scheduled
7125 independently from the call. So, we now hide the save and restore
7126 of the PIC register in the call pattern until after reload. Then,
7127 we split the moves out. A small side benefit is that we now don't
7128 need to have a use of the PIC register in the return pattern and
7129 the final save/restore operation is not needed.
7130
7131 I elected to just clobber %r4 in the PIC patterns and use it instead
7132 of trying to force hppa_pic_save_rtx () to a callee saved register.
7133 This might have required a new register class and constraint. It
7134 was also simpler to just handle the restore from a register than a
7135 generic pseudo. */
7136 if (TARGET_64BIT)
7137 {
7138 if (GET_CODE (op) == SYMBOL_REF)
7139 call_insn = emit_call_insn (gen_call_symref_64bit (op, nb));
7140 else
7141 {
7142 op = force_reg (word_mode, op);
7143 call_insn = emit_call_insn (gen_call_reg_64bit (op, nb));
7144 }
7145 }
7146 else
7147 {
7148 if (GET_CODE (op) == SYMBOL_REF)
7149 {
7150 if (flag_pic)
7151 call_insn = emit_call_insn (gen_call_symref_pic (op, nb));
7152 else
7153 call_insn = emit_call_insn (gen_call_symref (op, nb));
7154 }
7155 else
7156 {
7157 rtx tmpreg = gen_rtx_REG (word_mode, 22);
7158
7159 emit_move_insn (tmpreg, force_reg (word_mode, op));
7160 if (flag_pic)
7161 call_insn = emit_call_insn (gen_call_reg_pic (nb));
7162 else
7163 call_insn = emit_call_insn (gen_call_reg (nb));
7164 }
7165 }
7166
7167 DONE;
7168 }")
7169
7170 ;; We use function calls to set the attribute length of calls and millicode
7171 ;; calls. This is necessary because of the large variety of call sequences.
7172 ;; Implementing the calculation in rtl is difficult as well as ugly. As
7173 ;; we need the same calculation in several places, maintenance becomes a
7174 ;; nightmare.
7175 ;;
7176 ;; However, this has a subtle impact on branch shortening. When the
7177 ;; expression used to set the length attribute of an instruction depends
7178 ;; on a relative address (e.g., pc or a branch address), genattrtab
7179 ;; notes that the insn's length is variable, and attempts to determine a
7180 ;; worst-case default length and code to compute an insn's current length.
7181
7182 ;; The use of a function call hides the variable dependence of our calls
7183 ;; and millicode calls. The result is genattrtab doesn't treat the operation
7184 ;; as variable and it only generates code for the default case using our
7185 ;; function call. Because of this, calls and millicode calls have a fixed
7186 ;; length in the branch shortening pass, and some branches will use a longer
7187 ;; code sequence than necessary. However, the length of any given call
7188 ;; will still reflect its final code location and it may be shorter than
7189 ;; the initial length estimate.
7190
7191 ;; It's possible to trick genattrtab by adding an expression involving `pc'
7192 ;; in the set. However, when genattrtab hits a function call in its attempt
7193 ;; to compute the default length, it marks the result as unknown and sets
7194 ;; the default result to MAX_INT ;-( One possible fix that would allow
7195 ;; calls to participate in branch shortening would be to make the call to
7196 ;; insn_default_length a target option. Then, we could massage unknown
7197 ;; results. Another fix might be to change genattrtab so that it just does
7198 ;; the call in the variable case as it already does for the fixed case.
7199
7200 (define_insn "call_symref"
7201 [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7202 (match_operand 1 "" "i"))
7203 (clobber (reg:SI 1))
7204 (clobber (reg:SI 2))
7205 (use (const_int 0))]
7206 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7207 "*
7208 {
7209 output_arg_descriptor (insn);
7210 return output_call (insn, operands[0], 0);
7211 }"
7212 [(set_attr "type" "call")
7213 (set (attr "length") (symbol_ref "attr_length_call (insn, 0)"))])
7214
7215 (define_insn "call_symref_pic"
7216 [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7217 (match_operand 1 "" "i"))
7218 (clobber (reg:SI 1))
7219 (clobber (reg:SI 2))
7220 (clobber (reg:SI 4))
7221 (use (reg:SI 19))
7222 (use (const_int 0))]
7223 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7224 "*
7225 {
7226 output_arg_descriptor (insn);
7227 return output_call (insn, operands[0], 0);
7228 }"
7229 [(set_attr "type" "call")
7230 (set (attr "length")
7231 (plus (symbol_ref "attr_length_call (insn, 0)")
7232 (symbol_ref "attr_length_save_restore_dltp (insn)")))])
7233
7234 ;; Split out the PIC register save and restore after reload. This is
7235 ;; done only if the function returns. As the split is done after reload,
7236 ;; there are some situations in which we unnecessarily save and restore
7237 ;; %r4. This happens when there is a single call and the PIC register
7238 ;; is "dead" after the call. This isn't easy to fix as the usage of
7239 ;; the PIC register isn't completely determined until the reload pass.
7240 (define_split
7241 [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7242 (match_operand 1 "" ""))
7243 (clobber (reg:SI 1))
7244 (clobber (reg:SI 2))
7245 (clobber (reg:SI 4))
7246 (use (reg:SI 19))
7247 (use (const_int 0))])]
7248 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT
7249 && reload_completed
7250 && !find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7251 [(set (reg:SI 4) (reg:SI 19))
7252 (parallel [(call (mem:SI (match_dup 0))
7253 (match_dup 1))
7254 (clobber (reg:SI 1))
7255 (clobber (reg:SI 2))
7256 (use (reg:SI 19))
7257 (use (const_int 0))])
7258 (set (reg:SI 19) (reg:SI 4))]
7259 "")
7260
7261 ;; Remove the clobber of register 4 when optimizing. This has to be
7262 ;; done with a peephole optimization rather than a split because the
7263 ;; split sequence for a call must be longer than one instruction.
7264 (define_peephole2
7265 [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7266 (match_operand 1 "" ""))
7267 (clobber (reg:SI 1))
7268 (clobber (reg:SI 2))
7269 (clobber (reg:SI 4))
7270 (use (reg:SI 19))
7271 (use (const_int 0))])]
7272 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
7273 [(parallel [(call (mem:SI (match_dup 0))
7274 (match_dup 1))
7275 (clobber (reg:SI 1))
7276 (clobber (reg:SI 2))
7277 (use (reg:SI 19))
7278 (use (const_int 0))])]
7279 "")
7280
7281 (define_insn "*call_symref_pic_post_reload"
7282 [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7283 (match_operand 1 "" "i"))
7284 (clobber (reg:SI 1))
7285 (clobber (reg:SI 2))
7286 (use (reg:SI 19))
7287 (use (const_int 0))]
7288 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7289 "*
7290 {
7291 output_arg_descriptor (insn);
7292 return output_call (insn, operands[0], 0);
7293 }"
7294 [(set_attr "type" "call")
7295 (set (attr "length") (symbol_ref "attr_length_call (insn, 0)"))])
7296
7297 ;; This pattern is split if it is necessary to save and restore the
7298 ;; PIC register.
7299 (define_insn "call_symref_64bit"
7300 [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7301 (match_operand 1 "" "i"))
7302 (clobber (reg:DI 1))
7303 (clobber (reg:DI 2))
7304 (clobber (reg:DI 4))
7305 (use (reg:DI 27))
7306 (use (reg:DI 29))
7307 (use (const_int 0))]
7308 "TARGET_64BIT"
7309 "*
7310 {
7311 output_arg_descriptor (insn);
7312 return output_call (insn, operands[0], 0);
7313 }"
7314 [(set_attr "type" "call")
7315 (set (attr "length")
7316 (plus (symbol_ref "attr_length_call (insn, 0)")
7317 (symbol_ref "attr_length_save_restore_dltp (insn)")))])
7318
7319 ;; Split out the PIC register save and restore after reload. This is
7320 ;; done only if the function returns. As the split is done after reload,
7321 ;; there are some situations in which we unnecessarily save and restore
7322 ;; %r4. This happens when there is a single call and the PIC register
7323 ;; is "dead" after the call. This isn't easy to fix as the usage of
7324 ;; the PIC register isn't completely determined until the reload pass.
7325 (define_split
7326 [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7327 (match_operand 1 "" ""))
7328 (clobber (reg:DI 1))
7329 (clobber (reg:DI 2))
7330 (clobber (reg:DI 4))
7331 (use (reg:DI 27))
7332 (use (reg:DI 29))
7333 (use (const_int 0))])]
7334 "TARGET_64BIT
7335 && reload_completed
7336 && !find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7337 [(set (reg:DI 4) (reg:DI 27))
7338 (parallel [(call (mem:SI (match_dup 0))
7339 (match_dup 1))
7340 (clobber (reg:DI 1))
7341 (clobber (reg:DI 2))
7342 (use (reg:DI 27))
7343 (use (reg:DI 29))
7344 (use (const_int 0))])
7345 (set (reg:DI 27) (reg:DI 4))]
7346 "")
7347
7348 ;; Remove the clobber of register 4 when optimizing. This has to be
7349 ;; done with a peephole optimization rather than a split because the
7350 ;; split sequence for a call must be longer than one instruction.
7351 (define_peephole2
7352 [(parallel [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7353 (match_operand 1 "" ""))
7354 (clobber (reg:DI 1))
7355 (clobber (reg:DI 2))
7356 (clobber (reg:DI 4))
7357 (use (reg:DI 27))
7358 (use (reg:DI 29))
7359 (use (const_int 0))])]
7360 "TARGET_64BIT && reload_completed"
7361 [(parallel [(call (mem:SI (match_dup 0))
7362 (match_dup 1))
7363 (clobber (reg:DI 1))
7364 (clobber (reg:DI 2))
7365 (use (reg:DI 27))
7366 (use (reg:DI 29))
7367 (use (const_int 0))])]
7368 "")
7369
7370 (define_insn "*call_symref_64bit_post_reload"
7371 [(call (mem:SI (match_operand 0 "call_operand_address" ""))
7372 (match_operand 1 "" "i"))
7373 (clobber (reg:DI 1))
7374 (clobber (reg:DI 2))
7375 (use (reg:DI 27))
7376 (use (reg:DI 29))
7377 (use (const_int 0))]
7378 "TARGET_64BIT"
7379 "*
7380 {
7381 output_arg_descriptor (insn);
7382 return output_call (insn, operands[0], 0);
7383 }"
7384 [(set_attr "type" "call")
7385 (set (attr "length") (symbol_ref "attr_length_call (insn, 0)"))])
7386
7387 (define_insn "call_reg"
7388 [(call (mem:SI (reg:SI 22))
7389 (match_operand 0 "" "i"))
7390 (clobber (reg:SI 1))
7391 (clobber (reg:SI 2))
7392 (use (const_int 1))]
7393 "!TARGET_64BIT"
7394 "*
7395 {
7396 return output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
7397 }"
7398 [(set_attr "type" "dyncall")
7399 (set (attr "length") (symbol_ref "attr_length_indirect_call (insn)"))])
7400
7401 ;; This pattern is split if it is necessary to save and restore the
7402 ;; PIC register.
7403 (define_insn "call_reg_pic"
7404 [(call (mem:SI (reg:SI 22))
7405 (match_operand 0 "" "i"))
7406 (clobber (reg:SI 1))
7407 (clobber (reg:SI 2))
7408 (clobber (reg:SI 4))
7409 (use (reg:SI 19))
7410 (use (const_int 1))]
7411 "!TARGET_64BIT"
7412 "*
7413 {
7414 return output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
7415 }"
7416 [(set_attr "type" "dyncall")
7417 (set (attr "length")
7418 (plus (symbol_ref "attr_length_indirect_call (insn)")
7419 (symbol_ref "attr_length_save_restore_dltp (insn)")))])
7420
7421 ;; Split out the PIC register save and restore after reload. This is
7422 ;; done only if the function returns. As the split is done after reload,
7423 ;; there are some situations in which we unnecessarily save and restore
7424 ;; %r4. This happens when there is a single call and the PIC register
7425 ;; is "dead" after the call. This isn't easy to fix as the usage of
7426 ;; the PIC register isn't completely determined until the reload pass.
7427 (define_split
7428 [(parallel [(call (mem:SI (reg:SI 22))
7429 (match_operand 0 "" ""))
7430 (clobber (reg:SI 1))
7431 (clobber (reg:SI 2))
7432 (clobber (reg:SI 4))
7433 (use (reg:SI 19))
7434 (use (const_int 1))])]
7435 "!TARGET_64BIT
7436 && reload_completed
7437 && !find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7438 [(set (reg:SI 4) (reg:SI 19))
7439 (parallel [(call (mem:SI (reg:SI 22))
7440 (match_dup 0))
7441 (clobber (reg:SI 1))
7442 (clobber (reg:SI 2))
7443 (use (reg:SI 19))
7444 (use (const_int 1))])
7445 (set (reg:SI 19) (reg:SI 4))]
7446 "")
7447
7448 ;; Remove the clobber of register 4 when optimizing. This has to be
7449 ;; done with a peephole optimization rather than a split because the
7450 ;; split sequence for a call must be longer than one instruction.
7451 (define_peephole2
7452 [(parallel [(call (mem:SI (reg:SI 22))
7453 (match_operand 0 "" ""))
7454 (clobber (reg:SI 1))
7455 (clobber (reg:SI 2))
7456 (clobber (reg:SI 4))
7457 (use (reg:SI 19))
7458 (use (const_int 1))])]
7459 "!TARGET_64BIT && reload_completed"
7460 [(parallel [(call (mem:SI (reg:SI 22))
7461 (match_dup 0))
7462 (clobber (reg:SI 1))
7463 (clobber (reg:SI 2))
7464 (use (reg:SI 19))
7465 (use (const_int 1))])]
7466 "")
7467
7468 (define_insn "*call_reg_pic_post_reload"
7469 [(call (mem:SI (reg:SI 22))
7470 (match_operand 0 "" "i"))
7471 (clobber (reg:SI 1))
7472 (clobber (reg:SI 2))
7473 (use (reg:SI 19))
7474 (use (const_int 1))]
7475 "!TARGET_64BIT"
7476 "*
7477 {
7478 return output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
7479 }"
7480 [(set_attr "type" "dyncall")
7481 (set (attr "length") (symbol_ref "attr_length_indirect_call (insn)"))])
7482
7483 ;; This pattern is split if it is necessary to save and restore the
7484 ;; PIC register.
7485 (define_insn "call_reg_64bit"
7486 [(call (mem:SI (match_operand:DI 0 "register_operand" "r"))
7487 (match_operand 1 "" "i"))
7488 (clobber (reg:DI 2))
7489 (clobber (reg:DI 4))
7490 (use (reg:DI 27))
7491 (use (reg:DI 29))
7492 (use (const_int 1))]
7493 "TARGET_64BIT"
7494 "*
7495 {
7496 return output_indirect_call (insn, operands[0]);
7497 }"
7498 [(set_attr "type" "dyncall")
7499 (set (attr "length")
7500 (plus (symbol_ref "attr_length_indirect_call (insn)")
7501 (symbol_ref "attr_length_save_restore_dltp (insn)")))])
7502
7503 ;; Split out the PIC register save and restore after reload. This is
7504 ;; done only if the function returns. As the split is done after reload,
7505 ;; there are some situations in which we unnecessarily save and restore
7506 ;; %r4. This happens when there is a single call and the PIC register
7507 ;; is "dead" after the call. This isn't easy to fix as the usage of
7508 ;; the PIC register isn't completely determined until the reload pass.
7509 (define_split
7510 [(parallel [(call (mem:SI (match_operand 0 "register_operand" ""))
7511 (match_operand 1 "" ""))
7512 (clobber (reg:DI 2))
7513 (clobber (reg:DI 4))
7514 (use (reg:DI 27))
7515 (use (reg:DI 29))
7516 (use (const_int 1))])]
7517 "TARGET_64BIT
7518 && reload_completed
7519 && !find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7520 [(set (reg:DI 4) (reg:DI 27))
7521 (parallel [(call (mem:SI (match_dup 0))
7522 (match_dup 1))
7523 (clobber (reg:DI 2))
7524 (use (reg:DI 27))
7525 (use (reg:DI 29))
7526 (use (const_int 1))])
7527 (set (reg:DI 27) (reg:DI 4))]
7528 "")
7529
7530 ;; Remove the clobber of register 4 when optimizing. This has to be
7531 ;; done with a peephole optimization rather than a split because the
7532 ;; split sequence for a call must be longer than one instruction.
7533 (define_peephole2
7534 [(parallel [(call (mem:SI (match_operand 0 "register_operand" ""))
7535 (match_operand 1 "" ""))
7536 (clobber (reg:DI 2))
7537 (clobber (reg:DI 4))
7538 (use (reg:DI 27))
7539 (use (reg:DI 29))
7540 (use (const_int 1))])]
7541 "TARGET_64BIT && reload_completed"
7542 [(parallel [(call (mem:SI (match_dup 0))
7543 (match_dup 1))
7544 (clobber (reg:DI 2))
7545 (use (reg:DI 27))
7546 (use (reg:DI 29))
7547 (use (const_int 1))])]
7548 "")
7549
7550 (define_insn "*call_reg_64bit_post_reload"
7551 [(call (mem:SI (match_operand:DI 0 "register_operand" "r"))
7552 (match_operand 1 "" "i"))
7553 (clobber (reg:DI 2))
7554 (use (reg:DI 27))
7555 (use (reg:DI 29))
7556 (use (const_int 1))]
7557 "TARGET_64BIT"
7558 "*
7559 {
7560 return output_indirect_call (insn, operands[0]);
7561 }"
7562 [(set_attr "type" "dyncall")
7563 (set (attr "length") (symbol_ref "attr_length_indirect_call (insn)"))])
7564
7565 (define_expand "call_value"
7566 [(parallel [(set (match_operand 0 "" "")
7567 (call (match_operand:SI 1 "" "")
7568 (match_operand 2 "" "")))
7569 (clobber (reg:SI 2))])]
7570 ""
7571 "
7572 {
7573 rtx op, call_insn;
7574 rtx dst = operands[0];
7575 rtx nb = operands[2];
7576
7577 if (TARGET_PORTABLE_RUNTIME)
7578 op = force_reg (SImode, XEXP (operands[1], 0));
7579 else
7580 op = XEXP (operands[1], 0);
7581
7582 if (TARGET_64BIT)
7583 {
7584 if (!virtuals_instantiated)
7585 emit_move_insn (arg_pointer_rtx,
7586 gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
7587 GEN_INT (64)));
7588 else
7589 {
7590 /* The loop pass can generate new libcalls after the virtual
7591 registers are instantiated when fpregs are disabled because
7592 the only method that we have for doing DImode multiplication
7593 is with a libcall. This could be trouble if we haven't
7594 allocated enough space for the outgoing arguments. */
7595 if (INTVAL (nb) > current_function_outgoing_args_size)
7596 abort ();
7597
7598 emit_move_insn (arg_pointer_rtx,
7599 gen_rtx_PLUS (word_mode, stack_pointer_rtx,
7600 GEN_INT (STACK_POINTER_OFFSET + 64)));
7601 }
7602 }
7603
7604 /* Use two different patterns for calls to explicitly named functions
7605 and calls through function pointers. This is necessary as these two
7606 types of calls use different calling conventions, and CSE might try
7607 to change the named call into an indirect call in some cases (using
7608 two patterns keeps CSE from performing this optimization).
7609
7610 We now use even more call patterns as there was a subtle bug in
7611 attempting to restore the pic register after a call using a simple
7612 move insn. During reload, a instruction involving a pseudo register
7613 with no explicit dependence on the PIC register can be converted
7614 to an equivalent load from memory using the PIC register. If we
7615 emit a simple move to restore the PIC register in the initial rtl
7616 generation, then it can potentially be repositioned during scheduling.
7617 and an instruction that eventually uses the PIC register may end up
7618 between the call and the PIC register restore.
7619
7620 This only worked because there is a post call group of instructions
7621 that are scheduled with the call. These instructions are included
7622 in the same basic block as the call. However, calls can throw in
7623 C++ code and a basic block has to terminate at the call if the call
7624 can throw. This results in the PIC register restore being scheduled
7625 independently from the call. So, we now hide the save and restore
7626 of the PIC register in the call pattern until after reload. Then,
7627 we split the moves out. A small side benefit is that we now don't
7628 need to have a use of the PIC register in the return pattern and
7629 the final save/restore operation is not needed.
7630
7631 I elected to just clobber %r4 in the PIC patterns and use it instead
7632 of trying to force hppa_pic_save_rtx () to a callee saved register.
7633 This might have required a new register class and constraint. It
7634 was also simpler to just handle the restore from a register than a
7635 generic pseudo. */
7636 if (TARGET_64BIT)
7637 {
7638 if (GET_CODE (op) == SYMBOL_REF)
7639 call_insn = emit_call_insn (gen_call_val_symref_64bit (dst, op, nb));
7640 else
7641 {
7642 op = force_reg (word_mode, op);
7643 call_insn = emit_call_insn (gen_call_val_reg_64bit (dst, op, nb));
7644 }
7645 }
7646 else
7647 {
7648 if (GET_CODE (op) == SYMBOL_REF)
7649 {
7650 if (flag_pic)
7651 call_insn = emit_call_insn (gen_call_val_symref_pic (dst, op, nb));
7652 else
7653 call_insn = emit_call_insn (gen_call_val_symref (dst, op, nb));
7654 }
7655 else
7656 {
7657 rtx tmpreg = gen_rtx_REG (word_mode, 22);
7658
7659 emit_move_insn (tmpreg, force_reg (word_mode, op));
7660 if (flag_pic)
7661 call_insn = emit_call_insn (gen_call_val_reg_pic (dst, nb));
7662 else
7663 call_insn = emit_call_insn (gen_call_val_reg (dst, nb));
7664 }
7665 }
7666
7667 DONE;
7668 }")
7669
7670 (define_insn "call_val_symref"
7671 [(set (match_operand 0 "" "")
7672 (call (mem:SI (match_operand 1 "call_operand_address" ""))
7673 (match_operand 2 "" "i")))
7674 (clobber (reg:SI 1))
7675 (clobber (reg:SI 2))
7676 (use (const_int 0))]
7677 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7678 "*
7679 {
7680 output_arg_descriptor (insn);
7681 return output_call (insn, operands[1], 0);
7682 }"
7683 [(set_attr "type" "call")
7684 (set (attr "length") (symbol_ref "attr_length_call (insn, 0)"))])
7685
7686 (define_insn "call_val_symref_pic"
7687 [(set (match_operand 0 "" "")
7688 (call (mem:SI (match_operand 1 "call_operand_address" ""))
7689 (match_operand 2 "" "i")))
7690 (clobber (reg:SI 1))
7691 (clobber (reg:SI 2))
7692 (clobber (reg:SI 4))
7693 (use (reg:SI 19))
7694 (use (const_int 0))]
7695 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7696 "*
7697 {
7698 output_arg_descriptor (insn);
7699 return output_call (insn, operands[1], 0);
7700 }"
7701 [(set_attr "type" "call")
7702 (set (attr "length")
7703 (plus (symbol_ref "attr_length_call (insn, 0)")
7704 (symbol_ref "attr_length_save_restore_dltp (insn)")))])
7705
7706 ;; Split out the PIC register save and restore after reload. This is
7707 ;; done only if the function returns. As the split is done after reload,
7708 ;; there are some situations in which we unnecessarily save and restore
7709 ;; %r4. This happens when there is a single call and the PIC register
7710 ;; is "dead" after the call. This isn't easy to fix as the usage of
7711 ;; the PIC register isn't completely determined until the reload pass.
7712 (define_split
7713 [(parallel [(set (match_operand 0 "" "")
7714 (call (mem:SI (match_operand 1 "call_operand_address" ""))
7715 (match_operand 2 "" "")))
7716 (clobber (reg:SI 1))
7717 (clobber (reg:SI 2))
7718 (clobber (reg:SI 4))
7719 (use (reg:SI 19))
7720 (use (const_int 0))])]
7721 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT
7722 && reload_completed
7723 && !find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7724 [(set (reg:SI 4) (reg:SI 19))
7725 (parallel [(set (match_dup 0)
7726 (call (mem:SI (match_dup 1))
7727 (match_dup 2)))
7728 (clobber (reg:SI 1))
7729 (clobber (reg:SI 2))
7730 (use (reg:SI 19))
7731 (use (const_int 0))])
7732 (set (reg:SI 19) (reg:SI 4))]
7733 "")
7734
7735 ;; Remove the clobber of register 4 when optimizing. This has to be
7736 ;; done with a peephole optimization rather than a split because the
7737 ;; split sequence for a call must be longer than one instruction.
7738 (define_peephole2
7739 [(parallel [(set (match_operand 0 "" "")
7740 (call (mem:SI (match_operand 1 "call_operand_address" ""))
7741 (match_operand 2 "" "")))
7742 (clobber (reg:SI 1))
7743 (clobber (reg:SI 2))
7744 (clobber (reg:SI 4))
7745 (use (reg:SI 19))
7746 (use (const_int 0))])]
7747 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT && reload_completed"
7748 [(parallel [(set (match_dup 0)
7749 (call (mem:SI (match_dup 1))
7750 (match_dup 2)))
7751 (clobber (reg:SI 1))
7752 (clobber (reg:SI 2))
7753 (use (reg:SI 19))
7754 (use (const_int 0))])]
7755 "")
7756
7757 (define_insn "*call_val_symref_pic_post_reload"
7758 [(set (match_operand 0 "" "")
7759 (call (mem:SI (match_operand 1 "call_operand_address" ""))
7760 (match_operand 2 "" "i")))
7761 (clobber (reg:SI 1))
7762 (clobber (reg:SI 2))
7763 (use (reg:SI 19))
7764 (use (const_int 0))]
7765 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
7766 "*
7767 {
7768 output_arg_descriptor (insn);
7769 return output_call (insn, operands[1], 0);
7770 }"
7771 [(set_attr "type" "call")
7772 (set (attr "length") (symbol_ref "attr_length_call (insn, 0)"))])
7773
7774 ;; This pattern is split if it is necessary to save and restore the
7775 ;; PIC register.
7776 (define_insn "call_val_symref_64bit"
7777 [(set (match_operand 0 "" "")
7778 (call (mem:SI (match_operand 1 "call_operand_address" ""))
7779 (match_operand 2 "" "i")))
7780 (clobber (reg:DI 1))
7781 (clobber (reg:DI 2))
7782 (clobber (reg:DI 4))
7783 (use (reg:DI 27))
7784 (use (reg:DI 29))
7785 (use (const_int 0))]
7786 "TARGET_64BIT"
7787 "*
7788 {
7789 output_arg_descriptor (insn);
7790 return output_call (insn, operands[1], 0);
7791 }"
7792 [(set_attr "type" "call")
7793 (set (attr "length")
7794 (plus (symbol_ref "attr_length_call (insn, 0)")
7795 (symbol_ref "attr_length_save_restore_dltp (insn)")))])
7796
7797 ;; Split out the PIC register save and restore after reload. This is
7798 ;; done only if the function returns. As the split is done after reload,
7799 ;; there are some situations in which we unnecessarily save and restore
7800 ;; %r4. This happens when there is a single call and the PIC register
7801 ;; is "dead" after the call. This isn't easy to fix as the usage of
7802 ;; the PIC register isn't completely determined until the reload pass.
7803 (define_split
7804 [(parallel [(set (match_operand 0 "" "")
7805 (call (mem:SI (match_operand 1 "call_operand_address" ""))
7806 (match_operand 2 "" "")))
7807 (clobber (reg:DI 1))
7808 (clobber (reg:DI 2))
7809 (clobber (reg:DI 4))
7810 (use (reg:DI 27))
7811 (use (reg:DI 29))
7812 (use (const_int 0))])]
7813 "TARGET_64BIT
7814 && reload_completed
7815 && !find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7816 [(set (reg:DI 4) (reg:DI 27))
7817 (parallel [(set (match_dup 0)
7818 (call (mem:SI (match_dup 1))
7819 (match_dup 2)))
7820 (clobber (reg:DI 1))
7821 (clobber (reg:DI 2))
7822 (use (reg:DI 27))
7823 (use (reg:DI 29))
7824 (use (const_int 0))])
7825 (set (reg:DI 27) (reg:DI 4))]
7826 "")
7827
7828 ;; Remove the clobber of register 4 when optimizing. This has to be
7829 ;; done with a peephole optimization rather than a split because the
7830 ;; split sequence for a call must be longer than one instruction.
7831 (define_peephole2
7832 [(parallel [(set (match_operand 0 "" "")
7833 (call (mem:SI (match_operand 1 "call_operand_address" ""))
7834 (match_operand 2 "" "")))
7835 (clobber (reg:DI 1))
7836 (clobber (reg:DI 2))
7837 (clobber (reg:DI 4))
7838 (use (reg:DI 27))
7839 (use (reg:DI 29))
7840 (use (const_int 0))])]
7841 "TARGET_64BIT && reload_completed"
7842 [(parallel [(set (match_dup 0)
7843 (call (mem:SI (match_dup 1))
7844 (match_dup 2)))
7845 (clobber (reg:DI 1))
7846 (clobber (reg:DI 2))
7847 (use (reg:DI 27))
7848 (use (reg:DI 29))
7849 (use (const_int 0))])]
7850 "")
7851
7852 (define_insn "*call_val_symref_64bit_post_reload"
7853 [(set (match_operand 0 "" "")
7854 (call (mem:SI (match_operand 1 "call_operand_address" ""))
7855 (match_operand 2 "" "i")))
7856 (clobber (reg:DI 1))
7857 (clobber (reg:DI 2))
7858 (use (reg:DI 27))
7859 (use (reg:DI 29))
7860 (use (const_int 0))]
7861 "TARGET_64BIT"
7862 "*
7863 {
7864 output_arg_descriptor (insn);
7865 return output_call (insn, operands[1], 0);
7866 }"
7867 [(set_attr "type" "call")
7868 (set (attr "length") (symbol_ref "attr_length_call (insn, 0)"))])
7869
7870 (define_insn "call_val_reg"
7871 [(set (match_operand 0 "" "")
7872 (call (mem:SI (reg:SI 22))
7873 (match_operand 1 "" "i")))
7874 (clobber (reg:SI 1))
7875 (clobber (reg:SI 2))
7876 (use (const_int 1))]
7877 "!TARGET_64BIT"
7878 "*
7879 {
7880 return output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
7881 }"
7882 [(set_attr "type" "dyncall")
7883 (set (attr "length") (symbol_ref "attr_length_indirect_call (insn)"))])
7884
7885 ;; This pattern is split if it is necessary to save and restore the
7886 ;; PIC register.
7887 (define_insn "call_val_reg_pic"
7888 [(set (match_operand 0 "" "")
7889 (call (mem:SI (reg:SI 22))
7890 (match_operand 1 "" "i")))
7891 (clobber (reg:SI 1))
7892 (clobber (reg:SI 2))
7893 (clobber (reg:SI 4))
7894 (use (reg:SI 19))
7895 (use (const_int 1))]
7896 "!TARGET_64BIT"
7897 "*
7898 {
7899 return output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
7900 }"
7901 [(set_attr "type" "dyncall")
7902 (set (attr "length")
7903 (plus (symbol_ref "attr_length_indirect_call (insn)")
7904 (symbol_ref "attr_length_save_restore_dltp (insn)")))])
7905
7906 ;; Split out the PIC register save and restore after reload. This is
7907 ;; done only if the function returns. As the split is done after reload,
7908 ;; there are some situations in which we unnecessarily save and restore
7909 ;; %r4. This happens when there is a single call and the PIC register
7910 ;; is "dead" after the call. This isn't easy to fix as the usage of
7911 ;; the PIC register isn't completely determined until the reload pass.
7912 (define_split
7913 [(parallel [(set (match_operand 0 "" "")
7914 (call (mem:SI (reg:SI 22))
7915 (match_operand 1 "" "")))
7916 (clobber (reg:SI 1))
7917 (clobber (reg:SI 2))
7918 (clobber (reg:SI 4))
7919 (use (reg:SI 19))
7920 (use (const_int 1))])]
7921 "!TARGET_64BIT
7922 && reload_completed
7923 && !find_reg_note (insn, REG_NORETURN, NULL_RTX)"
7924 [(set (reg:SI 4) (reg:SI 19))
7925 (parallel [(set (match_dup 0)
7926 (call (mem:SI (reg:SI 22))
7927 (match_dup 1)))
7928 (clobber (reg:SI 1))
7929 (clobber (reg:SI 2))
7930 (use (reg:SI 19))
7931 (use (const_int 1))])
7932 (set (reg:SI 19) (reg:SI 4))]
7933 "")
7934
7935 ;; Remove the clobber of register 4 when optimizing. This has to be
7936 ;; done with a peephole optimization rather than a split because the
7937 ;; split sequence for a call must be longer than one instruction.
7938 (define_peephole2
7939 [(parallel [(set (match_operand 0 "" "")
7940 (call (mem:SI (reg:SI 22))
7941 (match_operand 1 "" "")))
7942 (clobber (reg:SI 1))
7943 (clobber (reg:SI 2))
7944 (clobber (reg:SI 4))
7945 (use (reg:SI 19))
7946 (use (const_int 1))])]
7947 "!TARGET_64BIT && reload_completed"
7948 [(parallel [(set (match_dup 0)
7949 (call (mem:SI (reg:SI 22))
7950 (match_dup 1)))
7951 (clobber (reg:SI 1))
7952 (clobber (reg:SI 2))
7953 (use (reg:SI 19))
7954 (use (const_int 1))])]
7955 "")
7956
7957 (define_insn "*call_val_reg_pic_post_reload"
7958 [(set (match_operand 0 "" "")
7959 (call (mem:SI (reg:SI 22))
7960 (match_operand 1 "" "i")))
7961 (clobber (reg:SI 1))
7962 (clobber (reg:SI 2))
7963 (use (reg:SI 19))
7964 (use (const_int 1))]
7965 "!TARGET_64BIT"
7966 "*
7967 {
7968 return output_indirect_call (insn, gen_rtx_REG (word_mode, 22));
7969 }"
7970 [(set_attr "type" "dyncall")
7971 (set (attr "length") (symbol_ref "attr_length_indirect_call (insn)"))])
7972
7973 ;; This pattern is split if it is necessary to save and restore the
7974 ;; PIC register.
7975 (define_insn "call_val_reg_64bit"
7976 [(set (match_operand 0 "" "")
7977 (call (mem:SI (match_operand:DI 1 "register_operand" "r"))
7978 (match_operand 2 "" "i")))
7979 (clobber (reg:DI 2))
7980 (clobber (reg:DI 4))
7981 (use (reg:DI 27))
7982 (use (reg:DI 29))
7983 (use (const_int 1))]
7984 "TARGET_64BIT"
7985 "*
7986 {
7987 return output_indirect_call (insn, operands[1]);
7988 }"
7989 [(set_attr "type" "dyncall")
7990 (set (attr "length")
7991 (plus (symbol_ref "attr_length_indirect_call (insn)")
7992 (symbol_ref "attr_length_save_restore_dltp (insn)")))])
7993
7994 ;; Split out the PIC register save and restore after reload. This is
7995 ;; done only if the function returns. As the split is done after reload,
7996 ;; there are some situations in which we unnecessarily save and restore
7997 ;; %r4. This happens when there is a single call and the PIC register
7998 ;; is "dead" after the call. This isn't easy to fix as the usage of
7999 ;; the PIC register isn't completely determined until the reload pass.
8000 (define_split
8001 [(parallel [(set (match_operand 0 "" "")
8002 (call (mem:SI (match_operand:DI 1 "register_operand" ""))
8003 (match_operand 2 "" "")))
8004 (clobber (reg:DI 2))
8005 (clobber (reg:DI 4))
8006 (use (reg:DI 27))
8007 (use (reg:DI 29))
8008 (use (const_int 1))])]
8009 "TARGET_64BIT
8010 && reload_completed
8011 && !find_reg_note (insn, REG_NORETURN, NULL_RTX)"
8012 [(set (reg:DI 4) (reg:DI 27))
8013 (parallel [(set (match_dup 0)
8014 (call (mem:SI (match_dup 1))
8015 (match_dup 2)))
8016 (clobber (reg:DI 2))
8017 (use (reg:DI 27))
8018 (use (reg:DI 29))
8019 (use (const_int 1))])
8020 (set (reg:DI 27) (reg:DI 4))]
8021 "")
8022
8023 ;; Remove the clobber of register 4 when optimizing. This has to be
8024 ;; done with a peephole optimization rather than a split because the
8025 ;; split sequence for a call must be longer than one instruction.
8026 (define_peephole2
8027 [(parallel [(set (match_operand 0 "" "")
8028 (call (mem:SI (match_operand:DI 1 "register_operand" ""))
8029 (match_operand 2 "" "")))
8030 (clobber (reg:DI 2))
8031 (clobber (reg:DI 4))
8032 (use (reg:DI 27))
8033 (use (reg:DI 29))
8034 (use (const_int 1))])]
8035 "TARGET_64BIT && reload_completed"
8036 [(parallel [(set (match_dup 0)
8037 (call (mem:SI (match_dup 1))
8038 (match_dup 2)))
8039 (clobber (reg:DI 2))
8040 (use (reg:DI 27))
8041 (use (reg:DI 29))
8042 (use (const_int 1))])]
8043 "")
8044
8045 (define_insn "*call_val_reg_64bit_post_reload"
8046 [(set (match_operand 0 "" "")
8047 (call (mem:SI (match_operand:DI 1 "register_operand" "r"))
8048 (match_operand 2 "" "i")))
8049 (clobber (reg:DI 2))
8050 (use (reg:DI 27))
8051 (use (reg:DI 29))
8052 (use (const_int 1))]
8053 "TARGET_64BIT"
8054 "*
8055 {
8056 return output_indirect_call (insn, operands[1]);
8057 }"
8058 [(set_attr "type" "dyncall")
8059 (set (attr "length") (symbol_ref "attr_length_indirect_call (insn)"))])
8060
8061 ;; Call subroutine returning any type.
8062
8063 (define_expand "untyped_call"
8064 [(parallel [(call (match_operand 0 "" "")
8065 (const_int 0))
8066 (match_operand 1 "" "")
8067 (match_operand 2 "" "")])]
8068 ""
8069 "
8070 {
8071 int i;
8072
8073 emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
8074
8075 for (i = 0; i < XVECLEN (operands[2], 0); i++)
8076 {
8077 rtx set = XVECEXP (operands[2], 0, i);
8078 emit_move_insn (SET_DEST (set), SET_SRC (set));
8079 }
8080
8081 /* The optimizer does not know that the call sets the function value
8082 registers we stored in the result block. We avoid problems by
8083 claiming that all hard registers are used and clobbered at this
8084 point. */
8085 emit_insn (gen_blockage ());
8086
8087 DONE;
8088 }")
8089
8090 (define_expand "sibcall"
8091 [(call (match_operand:SI 0 "" "")
8092 (match_operand 1 "" ""))]
8093 "!TARGET_PORTABLE_RUNTIME"
8094 "
8095 {
8096 rtx op, call_insn;
8097 rtx nb = operands[1];
8098
8099 op = XEXP (operands[0], 0);
8100
8101 if (TARGET_64BIT)
8102 {
8103 if (!virtuals_instantiated)
8104 emit_move_insn (arg_pointer_rtx,
8105 gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
8106 GEN_INT (64)));
8107 else
8108 {
8109 /* The loop pass can generate new libcalls after the virtual
8110 registers are instantiated when fpregs are disabled because
8111 the only method that we have for doing DImode multiplication
8112 is with a libcall. This could be trouble if we haven't
8113 allocated enough space for the outgoing arguments. */
8114 if (INTVAL (nb) > current_function_outgoing_args_size)
8115 abort ();
8116
8117 emit_move_insn (arg_pointer_rtx,
8118 gen_rtx_PLUS (word_mode, stack_pointer_rtx,
8119 GEN_INT (STACK_POINTER_OFFSET + 64)));
8120 }
8121 }
8122
8123 /* Indirect sibling calls are not allowed. */
8124 if (TARGET_64BIT)
8125 call_insn = gen_sibcall_internal_symref_64bit (op, operands[1]);
8126 else
8127 call_insn = gen_sibcall_internal_symref (op, operands[1]);
8128
8129 call_insn = emit_call_insn (call_insn);
8130
8131 if (TARGET_64BIT)
8132 use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), arg_pointer_rtx);
8133
8134 /* We don't have to restore the PIC register. */
8135 if (flag_pic)
8136 use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
8137
8138 DONE;
8139 }")
8140
8141 (define_insn "sibcall_internal_symref"
8142 [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8143 (match_operand 1 "" "i"))
8144 (clobber (reg:SI 1))
8145 (use (reg:SI 2))
8146 (use (const_int 0))]
8147 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8148 "*
8149 {
8150 output_arg_descriptor (insn);
8151 return output_call (insn, operands[0], 1);
8152 }"
8153 [(set_attr "type" "call")
8154 (set (attr "length") (symbol_ref "attr_length_call (insn, 1)"))])
8155
8156 (define_insn "sibcall_internal_symref_64bit"
8157 [(call (mem:SI (match_operand 0 "call_operand_address" ""))
8158 (match_operand 1 "" "i"))
8159 (clobber (reg:DI 1))
8160 (use (reg:DI 2))
8161 (use (const_int 0))]
8162 "TARGET_64BIT"
8163 "*
8164 {
8165 output_arg_descriptor (insn);
8166 return output_call (insn, operands[0], 1);
8167 }"
8168 [(set_attr "type" "call")
8169 (set (attr "length") (symbol_ref "attr_length_call (insn, 1)"))])
8170
8171 (define_expand "sibcall_value"
8172 [(set (match_operand 0 "" "")
8173 (call (match_operand:SI 1 "" "")
8174 (match_operand 2 "" "")))]
8175 "!TARGET_PORTABLE_RUNTIME"
8176 "
8177 {
8178 rtx op, call_insn;
8179 rtx nb = operands[1];
8180
8181 op = XEXP (operands[1], 0);
8182
8183 if (TARGET_64BIT)
8184 {
8185 if (!virtuals_instantiated)
8186 emit_move_insn (arg_pointer_rtx,
8187 gen_rtx_PLUS (word_mode, virtual_outgoing_args_rtx,
8188 GEN_INT (64)));
8189 else
8190 {
8191 /* The loop pass can generate new libcalls after the virtual
8192 registers are instantiated when fpregs are disabled because
8193 the only method that we have for doing DImode multiplication
8194 is with a libcall. This could be trouble if we haven't
8195 allocated enough space for the outgoing arguments. */
8196 if (INTVAL (nb) > current_function_outgoing_args_size)
8197 abort ();
8198
8199 emit_move_insn (arg_pointer_rtx,
8200 gen_rtx_PLUS (word_mode, stack_pointer_rtx,
8201 GEN_INT (STACK_POINTER_OFFSET + 64)));
8202 }
8203 }
8204
8205 /* Indirect sibling calls are not allowed. */
8206 if (TARGET_64BIT)
8207 call_insn
8208 = gen_sibcall_value_internal_symref_64bit (operands[0], op, operands[2]);
8209 else
8210 call_insn
8211 = gen_sibcall_value_internal_symref (operands[0], op, operands[2]);
8212
8213 call_insn = emit_call_insn (call_insn);
8214
8215 if (TARGET_64BIT)
8216 use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), arg_pointer_rtx);
8217
8218 /* We don't have to restore the PIC register. */
8219 if (flag_pic)
8220 use_reg (&CALL_INSN_FUNCTION_USAGE (call_insn), pic_offset_table_rtx);
8221
8222 DONE;
8223 }")
8224
8225 (define_insn "sibcall_value_internal_symref"
8226 [(set (match_operand 0 "" "")
8227 (call (mem:SI (match_operand 1 "call_operand_address" ""))
8228 (match_operand 2 "" "i")))
8229 (clobber (reg:SI 1))
8230 (use (reg:SI 2))
8231 (use (const_int 0))]
8232 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
8233 "*
8234 {
8235 output_arg_descriptor (insn);
8236 return output_call (insn, operands[1], 1);
8237 }"
8238 [(set_attr "type" "call")
8239 (set (attr "length") (symbol_ref "attr_length_call (insn, 1)"))])
8240
8241 (define_insn "sibcall_value_internal_symref_64bit"
8242 [(set (match_operand 0 "" "")
8243 (call (mem:SI (match_operand 1 "call_operand_address" ""))
8244 (match_operand 2 "" "i")))
8245 (clobber (reg:DI 1))
8246 (use (reg:DI 2))
8247 (use (const_int 0))]
8248 "TARGET_64BIT"
8249 "*
8250 {
8251 output_arg_descriptor (insn);
8252 return output_call (insn, operands[1], 1);
8253 }"
8254 [(set_attr "type" "call")
8255 (set (attr "length") (symbol_ref "attr_length_call (insn, 1)"))])
8256
8257 (define_insn "nop"
8258 [(const_int 0)]
8259 ""
8260 "nop"
8261 [(set_attr "type" "move")
8262 (set_attr "length" "4")])
8263
8264 ;; These are just placeholders so we know where branch tables
8265 ;; begin and end.
8266 (define_insn "begin_brtab"
8267 [(const_int 1)]
8268 ""
8269 "*
8270 {
8271 /* Only GAS actually supports this pseudo-op. */
8272 if (TARGET_GAS)
8273 return \".begin_brtab\";
8274 else
8275 return \"\";
8276 }"
8277 [(set_attr "type" "move")
8278 (set_attr "length" "0")])
8279
8280 (define_insn "end_brtab"
8281 [(const_int 2)]
8282 ""
8283 "*
8284 {
8285 /* Only GAS actually supports this pseudo-op. */
8286 if (TARGET_GAS)
8287 return \".end_brtab\";
8288 else
8289 return \"\";
8290 }"
8291 [(set_attr "type" "move")
8292 (set_attr "length" "0")])
8293
8294 ;;; EH does longjmp's from and within the data section. Thus,
8295 ;;; an interspace branch is required for the longjmp implementation.
8296 ;;; Registers r1 and r2 are used as scratch registers for the jump
8297 ;;; when necessary.
8298 (define_expand "interspace_jump"
8299 [(parallel
8300 [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8301 (clobber (match_dup 1))])]
8302 ""
8303 "
8304 {
8305 operands[1] = gen_rtx_REG (word_mode, 2);
8306 }")
8307
8308 (define_insn ""
8309 [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8310 (clobber (reg:SI 2))]
8311 "TARGET_PA_20 && !TARGET_64BIT"
8312 "bve%* (%0)"
8313 [(set_attr "type" "branch")
8314 (set_attr "length" "4")])
8315
8316 (define_insn ""
8317 [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8318 (clobber (reg:SI 2))]
8319 "TARGET_NO_SPACE_REGS && !TARGET_64BIT"
8320 "be%* 0(%%sr4,%0)"
8321 [(set_attr "type" "branch")
8322 (set_attr "length" "4")])
8323
8324 (define_insn ""
8325 [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8326 (clobber (reg:SI 2))]
8327 "!TARGET_64BIT"
8328 "ldsid (%%sr0,%0),%%r2\;mtsp %%r2,%%sr0\;be%* 0(%%sr0,%0)"
8329 [(set_attr "type" "branch")
8330 (set_attr "length" "12")])
8331
8332 (define_insn ""
8333 [(set (pc) (match_operand 0 "pmode_register_operand" "a"))
8334 (clobber (reg:DI 2))]
8335 "TARGET_64BIT"
8336 "bve%* (%0)"
8337 [(set_attr "type" "branch")
8338 (set_attr "length" "4")])
8339
8340 (define_expand "builtin_longjmp"
8341 [(unspec_volatile [(match_operand 0 "register_operand" "r")] UNSPECV_LONGJMP)]
8342 ""
8343 "
8344 {
8345 /* The elements of the buffer are, in order: */
8346 rtx fp = gen_rtx_MEM (Pmode, operands[0]);
8347 rtx lab = gen_rtx_MEM (Pmode, plus_constant (operands[0],
8348 POINTER_SIZE / BITS_PER_UNIT));
8349 rtx stack = gen_rtx_MEM (Pmode, plus_constant (operands[0],
8350 (POINTER_SIZE * 2) / BITS_PER_UNIT));
8351 rtx pv = gen_rtx_REG (Pmode, 1);
8352
8353 emit_insn (gen_rtx_CLOBBER (VOIDmode,
8354 gen_rtx_MEM (BLKmode,
8355 gen_rtx_SCRATCH (VOIDmode))));
8356 emit_insn (gen_rtx_CLOBBER (VOIDmode,
8357 gen_rtx_MEM (BLKmode,
8358 hard_frame_pointer_rtx)));
8359
8360 /* Restore the frame pointer. The virtual_stack_vars_rtx is saved
8361 instead of the hard_frame_pointer_rtx in the save area. We need
8362 to adjust for the offset between these two values when we have
8363 a nonlocal_goto pattern. When we don't have a nonlocal_goto
8364 pattern, the receiver performs the adjustment. */
8365 #ifdef HAVE_nonlocal_goto
8366 if (HAVE_nonlocal_goto)
8367 emit_move_insn (virtual_stack_vars_rtx, force_reg (Pmode, fp));
8368 else
8369 #endif
8370 emit_move_insn (hard_frame_pointer_rtx, fp);
8371
8372 /* This bit is the same as expand_builtin_longjmp. */
8373 emit_stack_restore (SAVE_NONLOCAL, stack, NULL_RTX);
8374 emit_insn (gen_rtx_USE (VOIDmode, hard_frame_pointer_rtx));
8375 emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
8376
8377 /* Load the label we are jumping through into r1 so that we know
8378 where to look for it when we get back to setjmp's function for
8379 restoring the gp. */
8380 emit_move_insn (pv, lab);
8381
8382 /* Prevent the insns above from being scheduled into the delay slot
8383 of the interspace jump because the space register could change. */
8384 emit_insn (gen_blockage ());
8385
8386 emit_jump_insn (gen_interspace_jump (pv));
8387 emit_barrier ();
8388 DONE;
8389 }")
8390
8391 ;;; Operands 2 and 3 are assumed to be CONST_INTs.
8392 (define_expand "extzv"
8393 [(set (match_operand 0 "register_operand" "")
8394 (zero_extract (match_operand 1 "register_operand" "")
8395 (match_operand 2 "uint32_operand" "")
8396 (match_operand 3 "uint32_operand" "")))]
8397 ""
8398 "
8399 {
8400 HOST_WIDE_INT len = INTVAL (operands[2]);
8401 HOST_WIDE_INT pos = INTVAL (operands[3]);
8402
8403 /* PA extraction insns don't support zero length bitfields or fields
8404 extending beyond the left or right-most bits. Also, we reject lengths
8405 equal to a word as they are better handled by the move patterns. */
8406 if (len <= 0 || len >= BITS_PER_WORD || pos < 0 || pos + len > BITS_PER_WORD)
8407 FAIL;
8408
8409 /* From mips.md: extract_bit_field doesn't verify that our source
8410 matches the predicate, so check it again here. */
8411 if (!register_operand (operands[1], VOIDmode))
8412 FAIL;
8413
8414 if (TARGET_64BIT)
8415 emit_insn (gen_extzv_64 (operands[0], operands[1],
8416 operands[2], operands[3]));
8417 else
8418 emit_insn (gen_extzv_32 (operands[0], operands[1],
8419 operands[2], operands[3]));
8420 DONE;
8421 }")
8422
8423 (define_insn "extzv_32"
8424 [(set (match_operand:SI 0 "register_operand" "=r")
8425 (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
8426 (match_operand:SI 2 "uint5_operand" "")
8427 (match_operand:SI 3 "uint5_operand" "")))]
8428 ""
8429 "{extru|extrw,u} %1,%3+%2-1,%2,%0"
8430 [(set_attr "type" "shift")
8431 (set_attr "length" "4")])
8432
8433 (define_insn ""
8434 [(set (match_operand:SI 0 "register_operand" "=r")
8435 (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
8436 (const_int 1)
8437 (match_operand:SI 2 "register_operand" "q")))]
8438 ""
8439 "{vextru %1,1,%0|extrw,u %1,%%sar,1,%0}"
8440 [(set_attr "type" "shift")
8441 (set_attr "length" "4")])
8442
8443 (define_insn "extzv_64"
8444 [(set (match_operand:DI 0 "register_operand" "=r")
8445 (zero_extract:DI (match_operand:DI 1 "register_operand" "r")
8446 (match_operand:DI 2 "uint32_operand" "")
8447 (match_operand:DI 3 "uint32_operand" "")))]
8448 "TARGET_64BIT"
8449 "extrd,u %1,%3+%2-1,%2,%0"
8450 [(set_attr "type" "shift")
8451 (set_attr "length" "4")])
8452
8453 (define_insn ""
8454 [(set (match_operand:DI 0 "register_operand" "=r")
8455 (zero_extract:DI (match_operand:DI 1 "register_operand" "r")
8456 (const_int 1)
8457 (match_operand:DI 2 "register_operand" "q")))]
8458 "TARGET_64BIT"
8459 "extrd,u %1,%%sar,1,%0"
8460 [(set_attr "type" "shift")
8461 (set_attr "length" "4")])
8462
8463 ;;; Operands 2 and 3 are assumed to be CONST_INTs.
8464 (define_expand "extv"
8465 [(set (match_operand 0 "register_operand" "")
8466 (sign_extract (match_operand 1 "register_operand" "")
8467 (match_operand 2 "uint32_operand" "")
8468 (match_operand 3 "uint32_operand" "")))]
8469 ""
8470 "
8471 {
8472 HOST_WIDE_INT len = INTVAL (operands[2]);
8473 HOST_WIDE_INT pos = INTVAL (operands[3]);
8474
8475 /* PA extraction insns don't support zero length bitfields or fields
8476 extending beyond the left or right-most bits. Also, we reject lengths
8477 equal to a word as they are better handled by the move patterns. */
8478 if (len <= 0 || len >= BITS_PER_WORD || pos < 0 || pos + len > BITS_PER_WORD)
8479 FAIL;
8480
8481 /* From mips.md: extract_bit_field doesn't verify that our source
8482 matches the predicate, so check it again here. */
8483 if (!register_operand (operands[1], VOIDmode))
8484 FAIL;
8485
8486 if (TARGET_64BIT)
8487 emit_insn (gen_extv_64 (operands[0], operands[1],
8488 operands[2], operands[3]));
8489 else
8490 emit_insn (gen_extv_32 (operands[0], operands[1],
8491 operands[2], operands[3]));
8492 DONE;
8493 }")
8494
8495 (define_insn "extv_32"
8496 [(set (match_operand:SI 0 "register_operand" "=r")
8497 (sign_extract:SI (match_operand:SI 1 "register_operand" "r")
8498 (match_operand:SI 2 "uint5_operand" "")
8499 (match_operand:SI 3 "uint5_operand" "")))]
8500 ""
8501 "{extrs|extrw,s} %1,%3+%2-1,%2,%0"
8502 [(set_attr "type" "shift")
8503 (set_attr "length" "4")])
8504
8505 (define_insn ""
8506 [(set (match_operand:SI 0 "register_operand" "=r")
8507 (sign_extract:SI (match_operand:SI 1 "register_operand" "r")
8508 (const_int 1)
8509 (match_operand:SI 2 "register_operand" "q")))]
8510 "!TARGET_64BIT"
8511 "{vextrs %1,1,%0|extrw,s %1,%%sar,1,%0}"
8512 [(set_attr "type" "shift")
8513 (set_attr "length" "4")])
8514
8515 (define_insn "extv_64"
8516 [(set (match_operand:DI 0 "register_operand" "=r")
8517 (sign_extract:DI (match_operand:DI 1 "register_operand" "r")
8518 (match_operand:DI 2 "uint32_operand" "")
8519 (match_operand:DI 3 "uint32_operand" "")))]
8520 "TARGET_64BIT"
8521 "extrd,s %1,%3+%2-1,%2,%0"
8522 [(set_attr "type" "shift")
8523 (set_attr "length" "4")])
8524
8525 (define_insn ""
8526 [(set (match_operand:DI 0 "register_operand" "=r")
8527 (sign_extract:DI (match_operand:DI 1 "register_operand" "r")
8528 (const_int 1)
8529 (match_operand:DI 2 "register_operand" "q")))]
8530 "TARGET_64BIT"
8531 "extrd,s %1,%%sar,1,%0"
8532 [(set_attr "type" "shift")
8533 (set_attr "length" "4")])
8534
8535 ;;; Operands 1 and 2 are assumed to be CONST_INTs.
8536 (define_expand "insv"
8537 [(set (zero_extract (match_operand 0 "register_operand" "")
8538 (match_operand 1 "uint32_operand" "")
8539 (match_operand 2 "uint32_operand" ""))
8540 (match_operand 3 "arith5_operand" ""))]
8541 ""
8542 "
8543 {
8544 HOST_WIDE_INT len = INTVAL (operands[1]);
8545 HOST_WIDE_INT pos = INTVAL (operands[2]);
8546
8547 /* PA insertion insns don't support zero length bitfields or fields
8548 extending beyond the left or right-most bits. Also, we reject lengths
8549 equal to a word as they are better handled by the move patterns. */
8550 if (len <= 0 || len >= BITS_PER_WORD || pos < 0 || pos + len > BITS_PER_WORD)
8551 FAIL;
8552
8553 /* From mips.md: insert_bit_field doesn't verify that our destination
8554 matches the predicate, so check it again here. */
8555 if (!register_operand (operands[0], VOIDmode))
8556 FAIL;
8557
8558 if (TARGET_64BIT)
8559 emit_insn (gen_insv_64 (operands[0], operands[1],
8560 operands[2], operands[3]));
8561 else
8562 emit_insn (gen_insv_32 (operands[0], operands[1],
8563 operands[2], operands[3]));
8564 DONE;
8565 }")
8566
8567 (define_insn "insv_32"
8568 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r,r")
8569 (match_operand:SI 1 "uint5_operand" "")
8570 (match_operand:SI 2 "uint5_operand" ""))
8571 (match_operand:SI 3 "arith5_operand" "r,L"))]
8572 ""
8573 "@
8574 {dep|depw} %3,%2+%1-1,%1,%0
8575 {depi|depwi} %3,%2+%1-1,%1,%0"
8576 [(set_attr "type" "shift,shift")
8577 (set_attr "length" "4,4")])
8578
8579 ;; Optimize insertion of const_int values of type 1...1xxxx.
8580 (define_insn ""
8581 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
8582 (match_operand:SI 1 "uint5_operand" "")
8583 (match_operand:SI 2 "uint5_operand" ""))
8584 (match_operand:SI 3 "const_int_operand" ""))]
8585 "(INTVAL (operands[3]) & 0x10) != 0 &&
8586 (~INTVAL (operands[3]) & ((1L << INTVAL (operands[1])) - 1) & ~0xf) == 0"
8587 "*
8588 {
8589 operands[3] = GEN_INT ((INTVAL (operands[3]) & 0xf) - 0x10);
8590 return \"{depi|depwi} %3,%2+%1-1,%1,%0\";
8591 }"
8592 [(set_attr "type" "shift")
8593 (set_attr "length" "4")])
8594
8595 (define_insn "insv_64"
8596 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+r,r")
8597 (match_operand:DI 1 "uint32_operand" "")
8598 (match_operand:DI 2 "uint32_operand" ""))
8599 (match_operand:DI 3 "arith32_operand" "r,L"))]
8600 "TARGET_64BIT"
8601 "@
8602 depd %3,%2+%1-1,%1,%0
8603 depdi %3,%2+%1-1,%1,%0"
8604 [(set_attr "type" "shift,shift")
8605 (set_attr "length" "4,4")])
8606
8607 ;; Optimize insertion of const_int values of type 1...1xxxx.
8608 (define_insn ""
8609 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+r")
8610 (match_operand:DI 1 "uint32_operand" "")
8611 (match_operand:DI 2 "uint32_operand" ""))
8612 (match_operand:DI 3 "const_int_operand" ""))]
8613 "(INTVAL (operands[3]) & 0x10) != 0
8614 && TARGET_64BIT
8615 && (~INTVAL (operands[3]) & ((1L << INTVAL (operands[1])) - 1) & ~0xf) == 0"
8616 "*
8617 {
8618 operands[3] = GEN_INT ((INTVAL (operands[3]) & 0xf) - 0x10);
8619 return \"depdi %3,%2+%1-1,%1,%0\";
8620 }"
8621 [(set_attr "type" "shift")
8622 (set_attr "length" "4")])
8623
8624 (define_insn ""
8625 [(set (match_operand:DI 0 "register_operand" "=r")
8626 (ashift:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
8627 (const_int 32)))]
8628 "TARGET_64BIT"
8629 "depd,z %1,31,32,%0"
8630 [(set_attr "type" "shift")
8631 (set_attr "length" "4")])
8632
8633 ;; This insn is used for some loop tests, typically loops reversed when
8634 ;; strength reduction is used. It is actually created when the instruction
8635 ;; combination phase combines the special loop test. Since this insn
8636 ;; is both a jump insn and has an output, it must deal with its own
8637 ;; reloads, hence the `m' constraints. The `!' constraints direct reload
8638 ;; to not choose the register alternatives in the event a reload is needed.
8639 (define_insn "decrement_and_branch_until_zero"
8640 [(set (pc)
8641 (if_then_else
8642 (match_operator 2 "comparison_operator"
8643 [(plus:SI
8644 (match_operand:SI 0 "reg_before_reload_operand" "+!r,!*f,*m")
8645 (match_operand:SI 1 "int5_operand" "L,L,L"))
8646 (const_int 0)])
8647 (label_ref (match_operand 3 "" ""))
8648 (pc)))
8649 (set (match_dup 0)
8650 (plus:SI (match_dup 0) (match_dup 1)))
8651 (clobber (match_scratch:SI 4 "=X,r,r"))]
8652 ""
8653 "* return output_dbra (operands, insn, which_alternative); "
8654 ;; Do not expect to understand this the first time through.
8655 [(set_attr "type" "cbranch,multi,multi")
8656 (set (attr "length")
8657 (if_then_else (eq_attr "alternative" "0")
8658 ;; Loop counter in register case
8659 ;; Short branch has length of 4
8660 ;; Long branch has length of 8
8661 (if_then_else (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
8662 (const_int 8184))
8663 (const_int 4)
8664 (const_int 8))
8665
8666 ;; Loop counter in FP reg case.
8667 ;; Extra goo to deal with additional reload insns.
8668 (if_then_else (eq_attr "alternative" "1")
8669 (if_then_else (lt (match_dup 3) (pc))
8670 (if_then_else
8671 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 24))))
8672 (const_int 8184))
8673 (const_int 24)
8674 (const_int 28))
8675 (if_then_else
8676 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
8677 (const_int 8184))
8678 (const_int 24)
8679 (const_int 28)))
8680 ;; Loop counter in memory case.
8681 ;; Extra goo to deal with additional reload insns.
8682 (if_then_else (lt (match_dup 3) (pc))
8683 (if_then_else
8684 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
8685 (const_int 8184))
8686 (const_int 12)
8687 (const_int 16))
8688 (if_then_else
8689 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
8690 (const_int 8184))
8691 (const_int 12)
8692 (const_int 16))))))])
8693
8694 (define_insn ""
8695 [(set (pc)
8696 (if_then_else
8697 (match_operator 2 "movb_comparison_operator"
8698 [(match_operand:SI 1 "register_operand" "r,r,r,r") (const_int 0)])
8699 (label_ref (match_operand 3 "" ""))
8700 (pc)))
8701 (set (match_operand:SI 0 "reg_before_reload_operand" "=!r,!*f,*m,!*q")
8702 (match_dup 1))]
8703 ""
8704 "* return output_movb (operands, insn, which_alternative, 0); "
8705 ;; Do not expect to understand this the first time through.
8706 [(set_attr "type" "cbranch,multi,multi,multi")
8707 (set (attr "length")
8708 (if_then_else (eq_attr "alternative" "0")
8709 ;; Loop counter in register case
8710 ;; Short branch has length of 4
8711 ;; Long branch has length of 8
8712 (if_then_else (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
8713 (const_int 8184))
8714 (const_int 4)
8715 (const_int 8))
8716
8717 ;; Loop counter in FP reg case.
8718 ;; Extra goo to deal with additional reload insns.
8719 (if_then_else (eq_attr "alternative" "1")
8720 (if_then_else (lt (match_dup 3) (pc))
8721 (if_then_else
8722 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
8723 (const_int 8184))
8724 (const_int 12)
8725 (const_int 16))
8726 (if_then_else
8727 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
8728 (const_int 8184))
8729 (const_int 12)
8730 (const_int 16)))
8731 ;; Loop counter in memory or sar case.
8732 ;; Extra goo to deal with additional reload insns.
8733 (if_then_else
8734 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
8735 (const_int 8184))
8736 (const_int 8)
8737 (const_int 12)))))])
8738
8739 ;; Handle negated branch.
8740 (define_insn ""
8741 [(set (pc)
8742 (if_then_else
8743 (match_operator 2 "movb_comparison_operator"
8744 [(match_operand:SI 1 "register_operand" "r,r,r,r") (const_int 0)])
8745 (pc)
8746 (label_ref (match_operand 3 "" ""))))
8747 (set (match_operand:SI 0 "reg_before_reload_operand" "=!r,!*f,*m,!*q")
8748 (match_dup 1))]
8749 ""
8750 "* return output_movb (operands, insn, which_alternative, 1); "
8751 ;; Do not expect to understand this the first time through.
8752 [(set_attr "type" "cbranch,multi,multi,multi")
8753 (set (attr "length")
8754 (if_then_else (eq_attr "alternative" "0")
8755 ;; Loop counter in register case
8756 ;; Short branch has length of 4
8757 ;; Long branch has length of 8
8758 (if_then_else (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
8759 (const_int 8184))
8760 (const_int 4)
8761 (const_int 8))
8762
8763 ;; Loop counter in FP reg case.
8764 ;; Extra goo to deal with additional reload insns.
8765 (if_then_else (eq_attr "alternative" "1")
8766 (if_then_else (lt (match_dup 3) (pc))
8767 (if_then_else
8768 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 12))))
8769 (const_int 8184))
8770 (const_int 12)
8771 (const_int 16))
8772 (if_then_else
8773 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
8774 (const_int 8184))
8775 (const_int 12)
8776 (const_int 16)))
8777 ;; Loop counter in memory or SAR case.
8778 ;; Extra goo to deal with additional reload insns.
8779 (if_then_else
8780 (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
8781 (const_int 8184))
8782 (const_int 8)
8783 (const_int 12)))))])
8784
8785 (define_insn ""
8786 [(set (pc) (label_ref (match_operand 3 "" "" )))
8787 (set (match_operand:SI 0 "ireg_operand" "=r")
8788 (plus:SI (match_operand:SI 1 "ireg_operand" "r")
8789 (match_operand:SI 2 "ireg_or_int5_operand" "rL")))]
8790 "(reload_completed && operands[0] == operands[1]) || operands[0] == operands[2]"
8791 "*
8792 {
8793 return output_parallel_addb (operands, get_attr_length (insn));
8794 }"
8795 [(set_attr "type" "parallel_branch")
8796 (set (attr "length")
8797 (if_then_else (lt (abs (minus (match_dup 3) (plus (pc) (const_int 8))))
8798 (const_int 8184))
8799 (const_int 4)
8800 (const_int 8)))])
8801
8802 (define_insn ""
8803 [(set (pc) (label_ref (match_operand 2 "" "" )))
8804 (set (match_operand:SF 0 "ireg_operand" "=r")
8805 (match_operand:SF 1 "ireg_or_int5_operand" "rL"))]
8806 "reload_completed"
8807 "*
8808 {
8809 return output_parallel_movb (operands, get_attr_length (insn));
8810 }"
8811 [(set_attr "type" "parallel_branch")
8812 (set (attr "length")
8813 (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
8814 (const_int 8184))
8815 (const_int 4)
8816 (const_int 8)))])
8817
8818 (define_insn ""
8819 [(set (pc) (label_ref (match_operand 2 "" "" )))
8820 (set (match_operand:SI 0 "ireg_operand" "=r")
8821 (match_operand:SI 1 "ireg_or_int5_operand" "rL"))]
8822 "reload_completed"
8823 "*
8824 {
8825 return output_parallel_movb (operands, get_attr_length (insn));
8826 }"
8827 [(set_attr "type" "parallel_branch")
8828 (set (attr "length")
8829 (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
8830 (const_int 8184))
8831 (const_int 4)
8832 (const_int 8)))])
8833
8834 (define_insn ""
8835 [(set (pc) (label_ref (match_operand 2 "" "" )))
8836 (set (match_operand:HI 0 "ireg_operand" "=r")
8837 (match_operand:HI 1 "ireg_or_int5_operand" "rL"))]
8838 "reload_completed"
8839 "*
8840 {
8841 return output_parallel_movb (operands, get_attr_length (insn));
8842 }"
8843 [(set_attr "type" "parallel_branch")
8844 (set (attr "length")
8845 (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
8846 (const_int 8184))
8847 (const_int 4)
8848 (const_int 8)))])
8849
8850 (define_insn ""
8851 [(set (pc) (label_ref (match_operand 2 "" "" )))
8852 (set (match_operand:QI 0 "ireg_operand" "=r")
8853 (match_operand:QI 1 "ireg_or_int5_operand" "rL"))]
8854 "reload_completed"
8855 "*
8856 {
8857 return output_parallel_movb (operands, get_attr_length (insn));
8858 }"
8859 [(set_attr "type" "parallel_branch")
8860 (set (attr "length")
8861 (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
8862 (const_int 8184))
8863 (const_int 4)
8864 (const_int 8)))])
8865
8866 (define_insn ""
8867 [(set (match_operand 0 "register_operand" "=f")
8868 (mult (match_operand 1 "register_operand" "f")
8869 (match_operand 2 "register_operand" "f")))
8870 (set (match_operand 3 "register_operand" "+f")
8871 (plus (match_operand 4 "register_operand" "f")
8872 (match_operand 5 "register_operand" "f")))]
8873 "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
8874 && reload_completed && fmpyaddoperands (operands)"
8875 "*
8876 {
8877 if (GET_MODE (operands[0]) == DFmode)
8878 {
8879 if (rtx_equal_p (operands[3], operands[5]))
8880 return \"fmpyadd,dbl %1,%2,%0,%4,%3\";
8881 else
8882 return \"fmpyadd,dbl %1,%2,%0,%5,%3\";
8883 }
8884 else
8885 {
8886 if (rtx_equal_p (operands[3], operands[5]))
8887 return \"fmpyadd,sgl %1,%2,%0,%4,%3\";
8888 else
8889 return \"fmpyadd,sgl %1,%2,%0,%5,%3\";
8890 }
8891 }"
8892 [(set_attr "type" "fpalu")
8893 (set_attr "length" "4")])
8894
8895 (define_insn ""
8896 [(set (match_operand 3 "register_operand" "+f")
8897 (plus (match_operand 4 "register_operand" "f")
8898 (match_operand 5 "register_operand" "f")))
8899 (set (match_operand 0 "register_operand" "=f")
8900 (mult (match_operand 1 "register_operand" "f")
8901 (match_operand 2 "register_operand" "f")))]
8902 "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
8903 && reload_completed && fmpyaddoperands (operands)"
8904 "*
8905 {
8906 if (GET_MODE (operands[0]) == DFmode)
8907 {
8908 if (rtx_equal_p (operands[3], operands[5]))
8909 return \"fmpyadd,dbl %1,%2,%0,%4,%3\";
8910 else
8911 return \"fmpyadd,dbl %1,%2,%0,%5,%3\";
8912 }
8913 else
8914 {
8915 if (rtx_equal_p (operands[3], operands[5]))
8916 return \"fmpyadd,sgl %1,%2,%0,%4,%3\";
8917 else
8918 return \"fmpyadd,sgl %1,%2,%0,%5,%3\";
8919 }
8920 }"
8921 [(set_attr "type" "fpalu")
8922 (set_attr "length" "4")])
8923
8924 (define_insn ""
8925 [(set (match_operand 0 "register_operand" "=f")
8926 (mult (match_operand 1 "register_operand" "f")
8927 (match_operand 2 "register_operand" "f")))
8928 (set (match_operand 3 "register_operand" "+f")
8929 (minus (match_operand 4 "register_operand" "f")
8930 (match_operand 5 "register_operand" "f")))]
8931 "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
8932 && reload_completed && fmpysuboperands (operands)"
8933 "*
8934 {
8935 if (GET_MODE (operands[0]) == DFmode)
8936 return \"fmpysub,dbl %1,%2,%0,%5,%3\";
8937 else
8938 return \"fmpysub,sgl %1,%2,%0,%5,%3\";
8939 }"
8940 [(set_attr "type" "fpalu")
8941 (set_attr "length" "4")])
8942
8943 (define_insn ""
8944 [(set (match_operand 3 "register_operand" "+f")
8945 (minus (match_operand 4 "register_operand" "f")
8946 (match_operand 5 "register_operand" "f")))
8947 (set (match_operand 0 "register_operand" "=f")
8948 (mult (match_operand 1 "register_operand" "f")
8949 (match_operand 2 "register_operand" "f")))]
8950 "TARGET_PA_11 && ! TARGET_SOFT_FLOAT
8951 && reload_completed && fmpysuboperands (operands)"
8952 "*
8953 {
8954 if (GET_MODE (operands[0]) == DFmode)
8955 return \"fmpysub,dbl %1,%2,%0,%5,%3\";
8956 else
8957 return \"fmpysub,sgl %1,%2,%0,%5,%3\";
8958 }"
8959 [(set_attr "type" "fpalu")
8960 (set_attr "length" "4")])
8961
8962 ;; Flush the I and D cache lines from the start address (operand0)
8963 ;; to the end address (operand1). No lines are flushed if the end
8964 ;; address is less than the start address (unsigned).
8965 ;;
8966 ;; Because the range of memory flushed is variable and the size of
8967 ;; a MEM can only be a CONST_INT, the patterns specify that they
8968 ;; perform an unspecified volatile operation on all memory.
8969 ;;
8970 ;; The address range for an icache flush must lie within a single
8971 ;; space on targets with non-equivalent space registers.
8972 ;;
8973 ;; This is used by the trampoline code for nested functions.
8974 ;;
8975 ;; Operand 0 contains the start address.
8976 ;; Operand 1 contains the end address.
8977 ;; Operand 2 contains the line length to use.
8978 ;; Operands 3 and 4 (icacheflush) are clobbered scratch registers.
8979 (define_insn "dcacheflush"
8980 [(const_int 1)
8981 (unspec_volatile [(mem:BLK (scratch))] UNSPECV_DCACHE)
8982 (use (match_operand 0 "pmode_register_operand" "r"))
8983 (use (match_operand 1 "pmode_register_operand" "r"))
8984 (use (match_operand 2 "pmode_register_operand" "r"))
8985 (clobber (match_scratch 3 "=&0"))]
8986 ""
8987 "*
8988 {
8989 if (TARGET_64BIT)
8990 return \"cmpb,*<<=,n %3,%1,.\;fdc,m %2(%3)\;sync\";
8991 else
8992 return \"cmpb,<<=,n %3,%1,.\;fdc,m %2(%3)\;sync\";
8993 }"
8994 [(set_attr "type" "multi")
8995 (set_attr "length" "12")])
8996
8997 (define_insn "icacheflush"
8998 [(const_int 2)
8999 (unspec_volatile [(mem:BLK (scratch))] UNSPECV_ICACHE)
9000 (use (match_operand 0 "pmode_register_operand" "r"))
9001 (use (match_operand 1 "pmode_register_operand" "r"))
9002 (use (match_operand 2 "pmode_register_operand" "r"))
9003 (clobber (match_operand 3 "pmode_register_operand" "=&r"))
9004 (clobber (match_operand 4 "pmode_register_operand" "=&r"))
9005 (clobber (match_scratch 5 "=&0"))]
9006 ""
9007 "*
9008 {
9009 if (TARGET_64BIT)
9010 return \"mfsp %%sr0,%4\;ldsid (%5),%3\;mtsp %3,%%sr0\;cmpb,*<<=,n %5,%1,.\;fic,m %2(%%sr0,%5)\;sync\;mtsp %4,%%sr0\;nop\;nop\;nop\;nop\;nop\;nop\";
9011 else
9012 return \"mfsp %%sr0,%4\;ldsid (%5),%3\;mtsp %3,%%sr0\;cmpb,<<=,n %5,%1,.\;fic,m %2(%%sr0,%5)\;sync\;mtsp %4,%%sr0\;nop\;nop\;nop\;nop\;nop\;nop\";
9013 }"
9014 [(set_attr "type" "multi")
9015 (set_attr "length" "52")])
9016
9017 ;; An out-of-line prologue.
9018 (define_insn "outline_prologue_call"
9019 [(unspec_volatile [(const_int 0)] UNSPECV_OPC)
9020 (clobber (reg:SI 31))
9021 (clobber (reg:SI 22))
9022 (clobber (reg:SI 21))
9023 (clobber (reg:SI 20))
9024 (clobber (reg:SI 19))
9025 (clobber (reg:SI 1))]
9026 ""
9027 "*
9028 {
9029 extern int frame_pointer_needed;
9030
9031 /* We need two different versions depending on whether or not we
9032 need a frame pointer. Also note that we return to the instruction
9033 immediately after the branch rather than two instructions after the
9034 break as normally is the case. */
9035 if (frame_pointer_needed)
9036 {
9037 /* Must import the magic millicode routine(s). */
9038 output_asm_insn (\".IMPORT __outline_prologue_fp,MILLICODE\", NULL);
9039
9040 if (TARGET_PORTABLE_RUNTIME)
9041 {
9042 output_asm_insn (\"ldil L'__outline_prologue_fp,%%r31\", NULL);
9043 output_asm_insn (\"ble,n R'__outline_prologue_fp(%%sr0,%%r31)\",
9044 NULL);
9045 }
9046 else
9047 output_asm_insn (\"{bl|b,l},n __outline_prologue_fp,%%r31\", NULL);
9048 }
9049 else
9050 {
9051 /* Must import the magic millicode routine(s). */
9052 output_asm_insn (\".IMPORT __outline_prologue,MILLICODE\", NULL);
9053
9054 if (TARGET_PORTABLE_RUNTIME)
9055 {
9056 output_asm_insn (\"ldil L'__outline_prologue,%%r31\", NULL);
9057 output_asm_insn (\"ble,n R'__outline_prologue(%%sr0,%%r31)\", NULL);
9058 }
9059 else
9060 output_asm_insn (\"{bl|b,l},n __outline_prologue,%%r31\", NULL);
9061 }
9062 return \"\";
9063 }"
9064 [(set_attr "type" "multi")
9065 (set_attr "length" "8")])
9066
9067 ;; An out-of-line epilogue.
9068 (define_insn "outline_epilogue_call"
9069 [(unspec_volatile [(const_int 1)] UNSPECV_OEC)
9070 (use (reg:SI 29))
9071 (use (reg:SI 28))
9072 (clobber (reg:SI 31))
9073 (clobber (reg:SI 22))
9074 (clobber (reg:SI 21))
9075 (clobber (reg:SI 20))
9076 (clobber (reg:SI 19))
9077 (clobber (reg:SI 2))
9078 (clobber (reg:SI 1))]
9079 ""
9080 "*
9081 {
9082 extern int frame_pointer_needed;
9083
9084 /* We need two different versions depending on whether or not we
9085 need a frame pointer. Also note that we return to the instruction
9086 immediately after the branch rather than two instructions after the
9087 break as normally is the case. */
9088 if (frame_pointer_needed)
9089 {
9090 /* Must import the magic millicode routine. */
9091 output_asm_insn (\".IMPORT __outline_epilogue_fp,MILLICODE\", NULL);
9092
9093 /* The out-of-line prologue will make sure we return to the right
9094 instruction. */
9095 if (TARGET_PORTABLE_RUNTIME)
9096 {
9097 output_asm_insn (\"ldil L'__outline_epilogue_fp,%%r31\", NULL);
9098 output_asm_insn (\"ble,n R'__outline_epilogue_fp(%%sr0,%%r31)\",
9099 NULL);
9100 }
9101 else
9102 output_asm_insn (\"{bl|b,l},n __outline_epilogue_fp,%%r31\", NULL);
9103 }
9104 else
9105 {
9106 /* Must import the magic millicode routine. */
9107 output_asm_insn (\".IMPORT __outline_epilogue,MILLICODE\", NULL);
9108
9109 /* The out-of-line prologue will make sure we return to the right
9110 instruction. */
9111 if (TARGET_PORTABLE_RUNTIME)
9112 {
9113 output_asm_insn (\"ldil L'__outline_epilogue,%%r31\", NULL);
9114 output_asm_insn (\"ble,n R'__outline_epilogue(%%sr0,%%r31)\", NULL);
9115 }
9116 else
9117 output_asm_insn (\"{bl|b,l},n __outline_epilogue,%%r31\", NULL);
9118 }
9119 return \"\";
9120 }"
9121 [(set_attr "type" "multi")
9122 (set_attr "length" "8")])
9123
9124 ;; Given a function pointer, canonicalize it so it can be
9125 ;; reliably compared to another function pointer. */
9126 (define_expand "canonicalize_funcptr_for_compare"
9127 [(set (reg:SI 26) (match_operand:SI 1 "register_operand" ""))
9128 (parallel [(set (reg:SI 29) (unspec:SI [(reg:SI 26)] UNSPEC_CFFC))
9129 (clobber (match_dup 2))
9130 (clobber (reg:SI 26))
9131 (clobber (reg:SI 22))
9132 (clobber (reg:SI 31))])
9133 (set (match_operand:SI 0 "register_operand" "")
9134 (reg:SI 29))]
9135 "!TARGET_PORTABLE_RUNTIME && !TARGET_64BIT"
9136 "
9137 {
9138 if (TARGET_ELF32)
9139 {
9140 rtx canonicalize_funcptr_for_compare_libfunc
9141 = init_one_libfunc (CANONICALIZE_FUNCPTR_FOR_COMPARE_LIBCALL);
9142
9143 emit_library_call_value (canonicalize_funcptr_for_compare_libfunc,
9144 operands[0], LCT_NORMAL, Pmode,
9145 1, operands[1], Pmode);
9146 DONE;
9147 }
9148
9149 operands[2] = gen_reg_rtx (SImode);
9150 if (GET_CODE (operands[1]) != REG)
9151 {
9152 rtx tmp = gen_reg_rtx (Pmode);
9153 emit_move_insn (tmp, operands[1]);
9154 operands[1] = tmp;
9155 }
9156 }")
9157
9158 (define_insn "*$$sh_func_adrs"
9159 [(set (reg:SI 29) (unspec:SI [(reg:SI 26)] UNSPEC_CFFC))
9160 (clobber (match_operand:SI 0 "register_operand" "=a"))
9161 (clobber (reg:SI 26))
9162 (clobber (reg:SI 22))
9163 (clobber (reg:SI 31))]
9164 "!TARGET_64BIT"
9165 "*
9166 {
9167 int length = get_attr_length (insn);
9168 rtx xoperands[2];
9169
9170 xoperands[0] = GEN_INT (length - 8);
9171 xoperands[1] = GEN_INT (length - 16);
9172
9173 /* Must import the magic millicode routine. */
9174 output_asm_insn (\".IMPORT $$sh_func_adrs,MILLICODE\", NULL);
9175
9176 /* This is absolutely amazing.
9177
9178 First, copy our input parameter into %r29 just in case we don't
9179 need to call $$sh_func_adrs. */
9180 output_asm_insn (\"copy %%r26,%%r29\", NULL);
9181 output_asm_insn (\"{extru|extrw,u} %%r26,31,2,%%r31\", NULL);
9182
9183 /* Next, examine the low two bits in %r26, if they aren't 0x2, then
9184 we use %r26 unchanged. */
9185 output_asm_insn (\"{comib|cmpib},<>,n 2,%%r31,.+%0\", xoperands);
9186 output_asm_insn (\"ldi 4096,%%r31\", NULL);
9187
9188 /* Next, compare %r26 with 4096, if %r26 is less than or equal to
9189 4096, then again we use %r26 unchanged. */
9190 output_asm_insn (\"{comb|cmpb},<<,n %%r26,%%r31,.+%1\", xoperands);
9191
9192 /* Finally, call $$sh_func_adrs to extract the function's real add24. */
9193 return output_millicode_call (insn,
9194 gen_rtx_SYMBOL_REF (SImode,
9195 \"$$sh_func_adrs\"));
9196 }"
9197 [(set_attr "type" "multi")
9198 (set (attr "length")
9199 (plus (symbol_ref "attr_length_millicode_call (insn)")
9200 (const_int 20)))])
9201
9202 ;; On the PA, the PIC register is call clobbered, so it must
9203 ;; be saved & restored around calls by the caller. If the call
9204 ;; doesn't return normally (nonlocal goto, or an exception is
9205 ;; thrown), then the code at the exception handler label must
9206 ;; restore the PIC register.
9207 (define_expand "exception_receiver"
9208 [(const_int 4)]
9209 "flag_pic"
9210 "
9211 {
9212 /* On the 64-bit port, we need a blockage because there is
9213 confusion regarding the dependence of the restore on the
9214 frame pointer. As a result, the frame pointer and pic
9215 register restores sometimes are interchanged erroneously. */
9216 if (TARGET_64BIT)
9217 emit_insn (gen_blockage ());
9218 /* Restore the PIC register using hppa_pic_save_rtx (). The
9219 PIC register is not saved in the frame in 64-bit ABI. */
9220 emit_move_insn (pic_offset_table_rtx, hppa_pic_save_rtx ());
9221 emit_insn (gen_blockage ());
9222 DONE;
9223 }")
9224
9225 (define_expand "builtin_setjmp_receiver"
9226 [(label_ref (match_operand 0 "" ""))]
9227 "flag_pic"
9228 "
9229 {
9230 if (TARGET_64BIT)
9231 emit_insn (gen_blockage ());
9232 /* Restore the PIC register. Hopefully, this will always be from
9233 a stack slot. The only registers that are valid after a
9234 builtin_longjmp are the stack and frame pointers. */
9235 emit_move_insn (pic_offset_table_rtx, hppa_pic_save_rtx ());
9236 emit_insn (gen_blockage ());
9237 DONE;
9238 }")
9239
9240 ;; Allocate new stack space and update the saved stack pointer in the
9241 ;; frame marker. The HP C compilers also copy additional words in the
9242 ;; frame marker. The 64-bit compiler copies words at -48, -32 and -24.
9243 ;; The 32-bit compiler copies the word at -16 (Static Link). We
9244 ;; currently don't copy these values.
9245 ;;
9246 ;; Since the copy of the frame marker can't be done atomically, I
9247 ;; suspect that using it for unwind purposes may be somewhat unreliable.
9248 ;; The HP compilers appear to raise the stack and copy the frame
9249 ;; marker in a strict instruction sequence. This suggests that the
9250 ;; unwind library may check for an alloca sequence when ALLOCA_FRAME
9251 ;; is set in the callinfo data. We currently don't set ALLOCA_FRAME
9252 ;; as GAS doesn't support it, or try to keep the instructions emitted
9253 ;; here in strict sequence.
9254 (define_expand "allocate_stack"
9255 [(match_operand 0 "" "")
9256 (match_operand 1 "" "")]
9257 ""
9258 "
9259 {
9260 rtx addr;
9261
9262 /* Since the stack grows upward, we need to store virtual_stack_dynamic_rtx
9263 in operand 0 before adjusting the stack. */
9264 emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
9265 anti_adjust_stack (operands[1]);
9266 if (TARGET_HPUX_UNWIND_LIBRARY)
9267 {
9268 addr = gen_rtx_PLUS (word_mode, stack_pointer_rtx,
9269 GEN_INT (TARGET_64BIT ? -8 : -4));
9270 emit_move_insn (gen_rtx_MEM (word_mode, addr), frame_pointer_rtx);
9271 }
9272 if (!TARGET_64BIT && flag_pic)
9273 {
9274 rtx addr = gen_rtx_PLUS (word_mode, stack_pointer_rtx, GEN_INT (-32));
9275 emit_move_insn (gen_rtx_MEM (word_mode, addr), pic_offset_table_rtx);
9276 }
9277 DONE;
9278 }")
9279
9280 (define_expand "prefetch"
9281 [(match_operand 0 "address_operand" "")
9282 (match_operand 1 "const_int_operand" "")
9283 (match_operand 2 "const_int_operand" "")]
9284 "TARGET_PA_20"
9285 {
9286 /* The PA 2.0 prefetch instructions only support short displacements
9287 when a cache control completer needs to be supplied. Thus, we
9288 can't use LO_SUM DLT addresses with the spatial locality completer. */
9289 if (operands[2] == const0_rtx && IS_LO_SUM_DLT_ADDR_P (operands[0]))
9290 FAIL;
9291
9292 /* We change operand0 to a MEM as we don't have the infrastructure to
9293 output all the supported address modes for ldw/ldd but we do have
9294 it for MEMs. */
9295 operands[0] = gen_rtx_MEM (Pmode, operands[0]);
9296
9297 if (!TARGET_NO_SPACE_REGS
9298 && !cse_not_expected
9299 && GET_CODE (XEXP (operands[0], 0)) == PLUS
9300 && REG_P (XEXP (XEXP (operands[0], 0), 0))
9301 && REG_P (XEXP (XEXP (operands[0], 0), 1)))
9302 operands[0]
9303 = replace_equiv_address (operands[0],
9304 copy_to_mode_reg (Pmode,
9305 XEXP (operands[0], 0)));
9306
9307 if (TARGET_64BIT)
9308 emit_insn (gen_prefetch_64 (operands[0], operands[1], operands[2]));
9309 else
9310 emit_insn (gen_prefetch_32 (operands[0], operands[1], operands[2]));
9311 DONE;
9312 })
9313
9314 (define_insn "prefetch_64"
9315 [(prefetch (match_operand:DI 0 "prefetch_operand" "A,RQ")
9316 (match_operand:DI 1 "const_int_operand" "n,n")
9317 (match_operand:DI 2 "const_int_operand" "n,n"))]
9318 "TARGET_64BIT
9319 && (operands[2] != const0_rtx
9320 || GET_CODE (XEXP (operands[0], 0)) != PLUS
9321 || GET_CODE (XEXP (XEXP (operands[0], 0), 1)) != CONST_INT
9322 || INT_5_BITS (XEXP (XEXP (operands[0], 0), 1)))"
9323 {
9324 /* The SL completor indicates good spatial locality but poor temporal
9325 locality. The ldw instruction with a target of general register 0
9326 prefetches a cache line for a read. The ldd instruction prefetches
9327 a cache line for a write. */
9328 static const char * const instr[2][2][2] = {
9329 {
9330 {
9331 "",
9332 "ldw RT'%A0,%%r0",
9333 },
9334 {
9335 "",
9336 "ldd RT'%A0,%%r0",
9337 },
9338 },
9339 {
9340 {
9341 "ldw%M0,sl %0,%%r0",
9342 "ldw%M0 %0,%%r0",
9343 },
9344 {
9345 "ldd%M0,sl %0,%%r0",
9346 "ldd%M0 %0,%%r0",
9347 }
9348 }
9349 };
9350 int read_or_write = INTVAL (operands[1]);
9351 int locality = INTVAL (operands[2]);
9352
9353 if ((which_alternative != 0 && which_alternative != 1)
9354 || (read_or_write != 0 && read_or_write != 1)
9355 || (locality < 0 || locality > 3))
9356 abort ();
9357
9358 if (which_alternative == 0 && locality == 0)
9359 abort ();
9360
9361 return instr [which_alternative][read_or_write][locality == 0 ? 0 : 1];
9362 }
9363 [(set_attr "type" "load")
9364 (set_attr "length" "4")])
9365
9366 (define_insn "prefetch_32"
9367 [(prefetch (match_operand:SI 0 "prefetch_operand" "A,RQ")
9368 (match_operand:SI 1 "const_int_operand" "n,n")
9369 (match_operand:SI 2 "const_int_operand" "n,n"))]
9370 "TARGET_PA_20
9371 && (operands[2] != const0_rtx
9372 || GET_CODE (XEXP (operands[0], 0)) != PLUS
9373 || GET_CODE (XEXP (XEXP (operands[0], 0), 1)) != CONST_INT
9374 || INT_5_BITS (XEXP (XEXP (operands[0], 0), 1)))"
9375 {
9376 /* The SL completor indicates good spatial locality but poor temporal
9377 locality. The ldw instruction with a target of general register 0
9378 prefetches a cache line for a read. The ldd instruction prefetches
9379 a cache line for a write. */
9380 static const char * const instr[2][2][2] = {
9381 {
9382 {
9383 "",
9384 "ldw RT'%A0,%%r0",
9385 },
9386 {
9387 "",
9388 "ldd RT'%A0,%%r0",
9389 },
9390 },
9391 {
9392 {
9393 "ldw%M0,sl %0,%%r0",
9394 "ldw%M0 %0,%%r0",
9395 },
9396 {
9397 "ldd%M0,sl %0,%%r0",
9398 "ldd%M0 %0,%%r0",
9399 }
9400 }
9401 };
9402 int read_or_write = INTVAL (operands[1]);
9403 int locality = INTVAL (operands[2]);
9404
9405 if ((which_alternative != 0 && which_alternative != 1)
9406 || (read_or_write != 0 && read_or_write != 1)
9407 || (locality < 0 || locality > 3))
9408 abort ();
9409
9410 if (which_alternative == 0 && locality == 0)
9411 abort ();
9412
9413 return instr [which_alternative][read_or_write][locality == 0 ? 0 : 1];
9414 }
9415 [(set_attr "type" "load")
9416 (set_attr "length" "4")])