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