]> gcc.gnu.org Git - gcc.git/blob - gcc/config/rs6000/rs6000.md
V.4 PIC changes
[gcc.git] / gcc / config / rs6000 / rs6000.md
1 ;; Machine description for IBM RISC System 6000 (POWER) for GNU C compiler
2 ;; Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
3 ;; Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
4
5 ;; This file is part of GNU CC.
6
7 ;; GNU CC is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 2, or (at your option)
10 ;; any later version.
11
12 ;; GNU CC is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
16
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU CC; see the file COPYING. If not, write to
19 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
20 ;; Boston, MA 02111-1307, USA.
21
22 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
23 \f
24 ;; Define an insn type attribute. This is used in function unit delay
25 ;; computations.
26 (define_attr "type" "integer,load,store,fpload,fpstore,imul,idiv,branch,compare,delayed_compare,fpcompare,mtjmpr,fp,dmul,sdiv,ddiv,ssqrt,dsqrt,jmpreg"
27 (const_string "integer"))
28
29 ;; Length (in bytes).
30 (define_attr "length" ""
31 (if_then_else (eq_attr "type" "branch")
32 (if_then_else (and (ge (minus (pc) (match_dup 0))
33 (const_int -32768))
34 (lt (minus (pc) (match_dup 0))
35 (const_int 32767)))
36 (const_int 8)
37 (const_int 12))
38 (const_int 4)))
39
40 ;; Processor type -- this attribute must exactly match the processor_type
41 ;; enumeration in rs6000.h.
42
43 (define_attr "cpu" "rios1,rios2,mpccore,ppc403,ppc601,ppc603,ppc604,ppc620"
44 (const (symbol_ref "rs6000_cpu_attr")))
45
46 ; (define_function_unit NAME MULTIPLICITY SIMULTANEITY
47 ; TEST READY-DELAY ISSUE-DELAY [CONFLICT-LIST])
48
49 ; Load/Store Unit -- pure PowerPC only
50 ; (POWER and 601 use Integer Unit)
51 (define_function_unit "lsu" 1 0
52 (and (eq_attr "type" "load")
53 (eq_attr "cpu" "mpccore,ppc603,ppc604,ppc620"))
54 2 1)
55
56 (define_function_unit "lsu" 1 0
57 (and (eq_attr "type" "store,fpstore")
58 (eq_attr "cpu" "mpccore,ppc603,ppc604,ppc620"))
59 1 1)
60
61 (define_function_unit "lsu" 1 0
62 (and (eq_attr "type" "fpload")
63 (eq_attr "cpu" "mpccore,ppc603"))
64 2 1)
65
66 (define_function_unit "lsu" 1 0
67 (and (eq_attr "type" "fpload")
68 (eq_attr "cpu" "ppc604,ppc620"))
69 3 1)
70
71 (define_function_unit "iu" 1 0
72 (and (eq_attr "type" "load")
73 (eq_attr "cpu" "rios1,ppc403,ppc601"))
74 2 1)
75
76 (define_function_unit "iu" 1 0
77 (and (eq_attr "type" "store,fpstore")
78 (eq_attr "cpu" "rios1,ppc403,ppc601"))
79 1 1)
80
81 (define_function_unit "fpu" 1 0
82 (and (eq_attr "type" "fpstore")
83 (eq_attr "cpu" "rios1,ppc601"))
84 0 1)
85
86 (define_function_unit "iu" 1 0
87 (and (eq_attr "type" "fpload")
88 (eq_attr "cpu" "rios1"))
89 2 1)
90
91 (define_function_unit "iu" 1 0
92 (and (eq_attr "type" "fpload")
93 (eq_attr "cpu" "ppc601"))
94 3 1)
95
96 (define_function_unit "iu2" 2 0
97 (and (eq_attr "type" "load,fpload")
98 (eq_attr "cpu" "rios2"))
99 2 1)
100
101 (define_function_unit "iu2" 2 0
102 (and (eq_attr "type" "store,fpstore")
103 (eq_attr "cpu" "rios2"))
104 1 1)
105
106 ; Integer Unit (RIOS1, PPC601, PPC603)
107 (define_function_unit "iu" 1 0
108 (and (eq_attr "type" "integer")
109 (eq_attr "cpu" "rios1,mpccore,ppc403,ppc601,ppc603"))
110 1 1)
111
112 (define_function_unit "iu" 1 0
113 (and (eq_attr "type" "imul")
114 (eq_attr "cpu" "ppc403"))
115 4 4)
116
117 (define_function_unit "iu" 1 0
118 (and (eq_attr "type" "imul")
119 (eq_attr "cpu" "rios1,ppc601,ppc603"))
120 5 5)
121
122 (define_function_unit "iu" 1 0
123 (and (eq_attr "type" "idiv")
124 (eq_attr "cpu" "rios1"))
125 19 19)
126
127 (define_function_unit "iu" 1 0
128 (and (eq_attr "type" "idiv")
129 (eq_attr "cpu" "ppc403"))
130 33 33)
131
132 (define_function_unit "iu" 1 0
133 (and (eq_attr "type" "idiv")
134 (eq_attr "cpu" "ppc601"))
135 36 36)
136
137 (define_function_unit "iu" 1 0
138 (and (eq_attr "type" "idiv")
139 (eq_attr "cpu" "ppc603"))
140 37 36)
141
142 ; RIOS2 has two integer units: a primary one which can perform all
143 ; operations and a secondary one which is fed in lock step with the first
144 ; and can perform "simple" integer operations.
145 ; To catch this we define a 'dummy' imuldiv-unit that is also needed
146 ; for the complex insns.
147 (define_function_unit "iu2" 2 0
148 (and (eq_attr "type" "integer")
149 (eq_attr "cpu" "rios2"))
150 1 1)
151
152 (define_function_unit "iu2" 2 0
153 (and (eq_attr "type" "imul")
154 (eq_attr "cpu" "rios2"))
155 2 2)
156
157 (define_function_unit "iu2" 2 0
158 (and (eq_attr "type" "idiv")
159 (eq_attr "cpu" "rios2"))
160 13 13)
161
162 (define_function_unit "imuldiv" 1 0
163 (and (eq_attr "type" "imul")
164 (eq_attr "cpu" "rios2"))
165 2 2)
166
167 (define_function_unit "imuldiv" 1 0
168 (and (eq_attr "type" "idiv")
169 (eq_attr "cpu" "rios2"))
170 13 13)
171
172 ; MPCCORE has separate IMUL/IDIV unit for multicycle instructions
173 ; Divide latency varies greatly from 2-11, use 6 as average
174 (define_function_unit "imuldiv" 1 0
175 (and (eq_attr "type" "imul")
176 (eq_attr "cpu" "mpccore"))
177 2 1)
178
179 (define_function_unit "imuldiv" 1 0
180 (and (eq_attr "type" "idiv")
181 (eq_attr "cpu" "mpccore"))
182 6 6)
183
184 ; PPC604 has two units that perform integer operations
185 ; and one unit for divide/multiply operations (and move
186 ; from/to spr).
187 (define_function_unit "iu2" 2 0
188 (and (eq_attr "type" "integer")
189 (eq_attr "cpu" "ppc604,ppc620"))
190 1 1)
191
192 (define_function_unit "imuldiv" 1 0
193 (and (eq_attr "type" "imul")
194 (eq_attr "cpu" "ppc604,ppc620"))
195 4 2)
196
197 (define_function_unit "imuldiv" 1 0
198 (and (eq_attr "type" "idiv")
199 (eq_attr "cpu" "ppc604,ppc620"))
200 20 19)
201
202 ; compare is done on integer unit, but feeds insns which
203 ; execute on the branch unit.
204 (define_function_unit "iu" 1 0
205 (and (eq_attr "type" "compare")
206 (eq_attr "cpu" "rios1"))
207 4 1)
208
209 (define_function_unit "iu" 1 0
210 (and (eq_attr "type" "delayed_compare")
211 (eq_attr "cpu" "rios1"))
212 5 1)
213
214 (define_function_unit "iu" 1 0
215 (and (eq_attr "type" "compare,delayed_compare")
216 (eq_attr "cpu" "mpccore,ppc403,ppc601,ppc603,ppc604,ppc620"))
217 3 1)
218
219 (define_function_unit "iu2" 2 0
220 (and (eq_attr "type" "compare,delayed_compare")
221 (eq_attr "cpu" "rios2"))
222 3 1)
223
224 (define_function_unit "iu2" 2 0
225 (and (eq_attr "type" "compare,delayed_compare")
226 (eq_attr "cpu" "ppc604,ppc620"))
227 1 1)
228
229 ; fp compare uses fp unit
230 (define_function_unit "fpu" 1 0
231 (and (eq_attr "type" "fpcompare")
232 (eq_attr "cpu" "rios1"))
233 9 1)
234
235 ; rios1 and rios2 have different fpcompare delays
236 (define_function_unit "fpu2" 2 0
237 (and (eq_attr "type" "fpcompare")
238 (eq_attr "cpu" "rios2"))
239 5 1)
240
241 ; on ppc601 and ppc603, fpcompare takes also 2 cycles from
242 ; the integer unit
243 ; here we do not define delays, just occupy the unit. The dependencies
244 ; will be assigned by the fpcompare definition in the fpu.
245 (define_function_unit "iu" 1 0
246 (and (eq_attr "type" "fpcompare")
247 (eq_attr "cpu" "ppc601,ppc603"))
248 0 2)
249
250 ; fp compare uses fp unit
251 (define_function_unit "fpu" 1 0
252 (and (eq_attr "type" "fpcompare")
253 (eq_attr "cpu" "ppc601,ppc603,ppc604,ppc620"))
254 5 1)
255
256 (define_function_unit "fpu" 1 0
257 (and (eq_attr "type" "fpcompare")
258 (eq_attr "cpu" "mpccore"))
259 1 1)
260
261 (define_function_unit "bpu" 1 0
262 (and (eq_attr "type" "mtjmpr")
263 (eq_attr "cpu" "rios1,rios2"))
264 5 1)
265
266 (define_function_unit "bpu" 1 0
267 (and (eq_attr "type" "mtjmpr")
268 (eq_attr "cpu" "mpccore,ppc403,ppc601,ppc603,ppc604,ppc620"))
269 4 1)
270
271 ; all jumps/branches are executing on the bpu, in 1 cycle, for all machines.
272 (define_function_unit "bpu" 1 0
273 (eq_attr "type" "jmpreg")
274 1 1)
275
276 (define_function_unit "bpu" 1 0
277 (eq_attr "type" "branch")
278 1 1)
279
280 ; Floating Point Unit
281 (define_function_unit "fpu" 1 0
282 (and (eq_attr "type" "fp,dmul")
283 (eq_attr "cpu" "rios1"))
284 2 1)
285
286 (define_function_unit "fpu" 1 0
287 (and (eq_attr "type" "fp")
288 (eq_attr "cpu" "mpccore"))
289 4 4)
290
291 (define_function_unit "fpu" 1 0
292 (and (eq_attr "type" "fp")
293 (eq_attr "cpu" "ppc601"))
294 4 1)
295
296 (define_function_unit "fpu" 1 0
297 (and (eq_attr "type" "fp")
298 (eq_attr "cpu" "ppc603,ppc604,ppc620"))
299 3 1)
300
301 (define_function_unit "fpu" 1 0
302 (and (eq_attr "type" "dmul")
303 (eq_attr "cpu" "mpccore"))
304 5 5)
305
306 (define_function_unit "fpu" 1 0
307 (and (eq_attr "type" "dmul")
308 (eq_attr "cpu" "ppc601"))
309 5 2)
310
311 ; is this true?
312 (define_function_unit "fpu" 1 0
313 (and (eq_attr "type" "dmul")
314 (eq_attr "cpu" "ppc603"))
315 4 2)
316
317 (define_function_unit "fpu" 1 0
318 (and (eq_attr "type" "dmul")
319 (eq_attr "cpu" "ppc604,ppc620"))
320 3 1)
321
322 (define_function_unit "fpu" 1 0
323 (and (eq_attr "type" "sdiv,ddiv")
324 (eq_attr "cpu" "rios1"))
325 19 19)
326
327 (define_function_unit "fpu" 1 0
328 (and (eq_attr "type" "sdiv")
329 (eq_attr "cpu" "ppc601"))
330 17 17)
331
332 (define_function_unit "fpu" 1 0
333 (and (eq_attr "type" "sdiv")
334 (eq_attr "cpu" "mpccore"))
335 10 10)
336
337 (define_function_unit "fpu" 1 0
338 (and (eq_attr "type" "sdiv")
339 (eq_attr "cpu" "ppc603,ppc604,ppc620"))
340 18 18)
341
342 (define_function_unit "fpu" 1 0
343 (and (eq_attr "type" "ddiv")
344 (eq_attr "cpu" "mpccore"))
345 17 17)
346
347 (define_function_unit "fpu" 1 0
348 (and (eq_attr "type" "ddiv")
349 (eq_attr "cpu" "ppc601,ppc604,ppc620"))
350 31 31)
351
352 (define_function_unit "fpu" 1 0
353 (and (eq_attr "type" "ddiv")
354 (eq_attr "cpu" "ppc603"))
355 33 33)
356
357 (define_function_unit "fpu" 1 0
358 (and (eq_attr "type" "ssqrt")
359 (eq_attr "cpu" "ppc620"))
360 31 31)
361
362 (define_function_unit "fpu" 1 0
363 (and (eq_attr "type" "dsqrt")
364 (eq_attr "cpu" "ppc620"))
365 31 31)
366
367 ; RIOS2 has two symmetric FPUs.
368 (define_function_unit "fpu2" 2 0
369 (and (eq_attr "type" "fp")
370 (eq_attr "cpu" "rios2"))
371 2 1)
372
373 (define_function_unit "fpu2" 2 0
374 (and (eq_attr "type" "dmul")
375 (eq_attr "cpu" "rios2"))
376 2 1)
377
378 (define_function_unit "fpu2" 2 0
379 (and (eq_attr "type" "sdiv,ddiv")
380 (eq_attr "cpu" "rios2"))
381 17 17)
382
383 (define_function_unit "fpu2" 2 0
384 (and (eq_attr "type" "ssqrt,dsqrt")
385 (eq_attr "cpu" "rios2"))
386 26 26)
387
388 \f
389 ;; Start with fixed-point load and store insns. Here we put only the more
390 ;; complex forms. Basic data transfer is done later.
391
392 (define_expand "zero_extendqidi2"
393 [(set (match_operand:DI 0 "gpc_reg_operand" "")
394 (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" "")))]
395 "TARGET_POWERPC64"
396 "")
397
398 (define_insn ""
399 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
400 (zero_extend:DI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
401 "TARGET_POWERPC64"
402 "@
403 lbz%U1%X1 %0,%1
404 rldicl %0,%1,0,56"
405 [(set_attr "type" "load,*")])
406
407 (define_insn ""
408 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
409 (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r"))
410 (const_int 0)))
411 (clobber (match_scratch:DI 2 "=r"))]
412 "TARGET_POWERPC64"
413 "rldicl. %2,%1,0,56"
414 [(set_attr "type" "compare")])
415
416 (define_insn ""
417 [(set (match_operand:CC 2 "cc_reg_operand" "=x")
418 (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r"))
419 (const_int 0)))
420 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
421 (zero_extend:DI (match_dup 1)))]
422 "TARGET_POWERPC64"
423 "rldicl. %0,%1,0,56"
424 [(set_attr "type" "compare")])
425
426 (define_insn "extendqidi2"
427 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
428 (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r")))]
429 "TARGET_POWERPC64"
430 "extsb %0,%1")
431
432 (define_insn ""
433 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
434 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r"))
435 (const_int 0)))
436 (clobber (match_scratch:DI 2 "=r"))]
437 "TARGET_POWERPC64"
438 "extsb. %2,%1"
439 [(set_attr "type" "compare")])
440
441 (define_insn ""
442 [(set (match_operand:CC 2 "cc_reg_operand" "=x")
443 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r"))
444 (const_int 0)))
445 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
446 (sign_extend:DI (match_dup 1)))]
447 "TARGET_POWERPC64"
448 "extsb. %0,%1"
449 [(set_attr "type" "compare")])
450
451 (define_expand "zero_extendhidi2"
452 [(set (match_operand:DI 0 "gpc_reg_operand" "")
453 (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" "")))]
454 "TARGET_POWERPC64"
455 "")
456
457 (define_insn ""
458 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
459 (zero_extend:DI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
460 "TARGET_POWERPC64"
461 "@
462 lhz%U1%X1 %0,%1
463 rldicl %0,%1,0,48"
464 [(set_attr "type" "load,*")])
465
466 (define_insn ""
467 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
468 (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r"))
469 (const_int 0)))
470 (clobber (match_scratch:DI 2 "=r"))]
471 "TARGET_POWERPC64"
472 "rldicl. %2,%1,0,48"
473 [(set_attr "type" "compare")])
474
475 (define_insn ""
476 [(set (match_operand:CC 2 "cc_reg_operand" "=x")
477 (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r"))
478 (const_int 0)))
479 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
480 (zero_extend:DI (match_dup 1)))]
481 "TARGET_POWERPC64"
482 "rldicl. %0,%1,0,48"
483 [(set_attr "type" "compare")])
484
485 (define_expand "extendhidi2"
486 [(set (match_operand:DI 0 "gpc_reg_operand" "")
487 (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "")))]
488 "TARGET_POWERPC64"
489 "")
490
491 (define_insn ""
492 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
493 (sign_extend:DI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
494 "TARGET_POWERPC64"
495 "@
496 lha%U1%X1 %0,%1
497 extsh %0,%1"
498 [(set_attr "type" "load,*")])
499
500 (define_insn ""
501 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
502 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r"))
503 (const_int 0)))
504 (clobber (match_scratch:DI 2 "=r"))]
505 "TARGET_POWERPC64"
506 "extsh. %2,%1"
507 [(set_attr "type" "compare")])
508
509 (define_insn ""
510 [(set (match_operand:CC 2 "cc_reg_operand" "=x")
511 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r"))
512 (const_int 0)))
513 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
514 (sign_extend:DI (match_dup 1)))]
515 "TARGET_POWERPC64"
516 "extsh. %0,%1"
517 [(set_attr "type" "compare")])
518
519 (define_expand "zero_extendsidi2"
520 [(set (match_operand:DI 0 "gpc_reg_operand" "")
521 (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "")))]
522 "TARGET_POWERPC64"
523 "")
524
525 (define_insn ""
526 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
527 (zero_extend:DI (match_operand:SI 1 "reg_or_mem_operand" "m,r")))]
528 "TARGET_POWERPC64"
529 "@
530 lwz%U1%X1 %0,%1
531 rldicl %0,%1,0,32"
532 [(set_attr "type" "load,*")])
533
534 (define_insn ""
535 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
536 (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
537 (const_int 0)))
538 (clobber (match_scratch:DI 2 "=r"))]
539 "TARGET_POWERPC64"
540 "rldicl. %2,%1,0,32"
541 [(set_attr "type" "compare")])
542
543 (define_insn ""
544 [(set (match_operand:CC 2 "cc_reg_operand" "=x")
545 (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
546 (const_int 0)))
547 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
548 (zero_extend:DI (match_dup 1)))]
549 "TARGET_POWERPC64"
550 "rldicl. %0,%1,0,32"
551 [(set_attr "type" "compare")])
552
553 (define_expand "extendsidi2"
554 [(set (match_operand:DI 0 "gpc_reg_operand" "")
555 (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "")))]
556 "TARGET_POWERPC64"
557 "")
558
559 (define_insn ""
560 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
561 (sign_extend:DI (match_operand:SI 1 "lwa_operand" "m,r")))]
562 "TARGET_POWERPC64"
563 "@
564 lwa%U1%X1 %0,%1
565 extsw %0,%1"
566 [(set_attr "type" "load,*")])
567
568 (define_insn ""
569 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
570 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
571 (const_int 0)))
572 (clobber (match_scratch:DI 2 "=r"))]
573 "TARGET_POWERPC64"
574 "extsw. %2,%1"
575 [(set_attr "type" "compare")])
576
577 (define_insn ""
578 [(set (match_operand:CC 2 "cc_reg_operand" "=x")
579 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
580 (const_int 0)))
581 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
582 (sign_extend:DI (match_dup 1)))]
583 "TARGET_POWERPC64"
584 "extsw. %0,%1"
585 [(set_attr "type" "compare")])
586
587 (define_expand "zero_extendqisi2"
588 [(set (match_operand:SI 0 "gpc_reg_operand" "")
589 (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "")))]
590 ""
591 "")
592
593 (define_insn ""
594 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
595 (zero_extend:SI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
596 ""
597 "@
598 lbz%U1%X1 %0,%1
599 {rlinm|rlwinm} %0,%1,0,0xff"
600 [(set_attr "type" "load,*")])
601
602 (define_insn ""
603 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
604 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r"))
605 (const_int 0)))
606 (clobber (match_scratch:SI 2 "=r"))]
607 ""
608 "{andil.|andi.} %2,%1,0xff"
609 [(set_attr "type" "compare")])
610
611 (define_insn ""
612 [(set (match_operand:CC 2 "cc_reg_operand" "=x")
613 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r"))
614 (const_int 0)))
615 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
616 (zero_extend:SI (match_dup 1)))]
617 ""
618 "{andil.|andi.} %0,%1,0xff"
619 [(set_attr "type" "compare")])
620
621 (define_expand "extendqisi2"
622 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
623 (use (match_operand:QI 1 "gpc_reg_operand" ""))]
624 ""
625 "
626 {
627 if (TARGET_POWERPC)
628 emit_insn (gen_extendqisi2_ppc (operands[0], operands[1]));
629 else if (TARGET_POWER)
630 emit_insn (gen_extendqisi2_power (operands[0], operands[1]));
631 else
632 emit_insn (gen_extendqisi2_no_power (operands[0], operands[1]));
633 DONE;
634 }")
635
636 (define_insn "extendqisi2_ppc"
637 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
638 (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r")))]
639 "TARGET_POWERPC"
640 "extsb %0,%1")
641
642 (define_insn ""
643 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
644 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r"))
645 (const_int 0)))
646 (clobber (match_scratch:SI 2 "=r"))]
647 "TARGET_POWERPC"
648 "extsb. %2,%1"
649 [(set_attr "type" "compare")])
650
651 (define_insn ""
652 [(set (match_operand:CC 2 "cc_reg_operand" "=x")
653 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r"))
654 (const_int 0)))
655 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
656 (sign_extend:SI (match_dup 1)))]
657 "TARGET_POWERPC"
658 "extsb. %0,%1"
659 [(set_attr "type" "compare")])
660
661 (define_expand "extendqisi2_power"
662 [(parallel [(set (match_dup 2)
663 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
664 (const_int 24)))
665 (clobber (scratch:SI))])
666 (parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
667 (ashiftrt:SI (match_dup 2)
668 (const_int 24)))
669 (clobber (scratch:SI))])]
670 "TARGET_POWER"
671 "
672 { operands[1] = gen_lowpart (SImode, operands[1]);
673 operands[2] = gen_reg_rtx (SImode); }")
674
675 (define_expand "extendqisi2_no_power"
676 [(set (match_dup 2)
677 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
678 (const_int 24)))
679 (set (match_operand:SI 0 "gpc_reg_operand" "")
680 (ashiftrt:SI (match_dup 2)
681 (const_int 24)))]
682 "! TARGET_POWER && ! TARGET_POWERPC"
683 "
684 { operands[1] = gen_lowpart (SImode, operands[1]);
685 operands[2] = gen_reg_rtx (SImode); }")
686
687 (define_expand "zero_extendqihi2"
688 [(set (match_operand:HI 0 "gpc_reg_operand" "")
689 (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "")))]
690 ""
691 "")
692
693 (define_insn ""
694 [(set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
695 (zero_extend:HI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
696 ""
697 "@
698 lbz%U1%X1 %0,%1
699 {rlinm|rlwinm} %0,%1,0,0xff"
700 [(set_attr "type" "load,*")])
701
702 (define_insn ""
703 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
704 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r"))
705 (const_int 0)))
706 (clobber (match_scratch:HI 2 "=r"))]
707 ""
708 "{andil.|andi.} %2,%1,0xff"
709 [(set_attr "type" "compare")])
710
711 (define_insn ""
712 [(set (match_operand:CC 2 "cc_reg_operand" "=x")
713 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r"))
714 (const_int 0)))
715 (set (match_operand:HI 0 "gpc_reg_operand" "=r")
716 (zero_extend:HI (match_dup 1)))]
717 ""
718 "{andil.|andi.} %0,%1,0xff"
719 [(set_attr "type" "compare")])
720
721 (define_expand "extendqihi2"
722 [(use (match_operand:HI 0 "gpc_reg_operand" ""))
723 (use (match_operand:QI 1 "gpc_reg_operand" ""))]
724 ""
725 "
726 {
727 if (TARGET_POWERPC)
728 emit_insn (gen_extendqihi2_ppc (operands[0], operands[1]));
729 else if (TARGET_POWER)
730 emit_insn (gen_extendqihi2_power (operands[0], operands[1]));
731 else
732 emit_insn (gen_extendqihi2_no_power (operands[0], operands[1]));
733 DONE;
734 }")
735
736 (define_insn "extendqihi2_ppc"
737 [(set (match_operand:HI 0 "gpc_reg_operand" "=r")
738 (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r")))]
739 "TARGET_POWERPC"
740 "extsb %0,%1")
741
742 (define_insn ""
743 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
744 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r"))
745 (const_int 0)))
746 (clobber (match_scratch:HI 2 "=r"))]
747 "TARGET_POWERPC"
748 "extsb. %2,%1"
749 [(set_attr "type" "compare")])
750
751 (define_insn ""
752 [(set (match_operand:CC 2 "cc_reg_operand" "=x")
753 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r"))
754 (const_int 0)))
755 (set (match_operand:HI 0 "gpc_reg_operand" "=r")
756 (sign_extend:HI (match_dup 1)))]
757 "TARGET_POWERPC"
758 "extsb. %0,%1"
759 [(set_attr "type" "compare")])
760
761 (define_expand "extendqihi2_power"
762 [(parallel [(set (match_dup 2)
763 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
764 (const_int 24)))
765 (clobber (scratch:SI))])
766 (parallel [(set (match_operand:HI 0 "gpc_reg_operand" "")
767 (ashiftrt:SI (match_dup 2)
768 (const_int 24)))
769 (clobber (scratch:SI))])]
770 "TARGET_POWER"
771 "
772 { operands[0] = gen_lowpart (SImode, operands[0]);
773 operands[1] = gen_lowpart (SImode, operands[1]);
774 operands[2] = gen_reg_rtx (SImode); }")
775
776 (define_expand "extendqihi2_no_power"
777 [(set (match_dup 2)
778 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
779 (const_int 24)))
780 (set (match_operand:HI 0 "gpc_reg_operand" "")
781 (ashiftrt:SI (match_dup 2)
782 (const_int 24)))]
783 "! TARGET_POWER && ! TARGET_POWERPC"
784 "
785 { operands[0] = gen_lowpart (SImode, operands[0]);
786 operands[1] = gen_lowpart (SImode, operands[1]);
787 operands[2] = gen_reg_rtx (SImode); }")
788
789 (define_expand "zero_extendhisi2"
790 [(set (match_operand:SI 0 "gpc_reg_operand" "")
791 (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
792 ""
793 "")
794
795 (define_insn ""
796 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
797 (zero_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
798 ""
799 "@
800 lhz%U1%X1 %0,%1
801 {rlinm|rlwinm} %0,%1,0,0xffff"
802 [(set_attr "type" "load,*")])
803
804 (define_insn ""
805 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
806 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r"))
807 (const_int 0)))
808 (clobber (match_scratch:SI 2 "=r"))]
809 ""
810 "{andil.|andi.} %2,%1,0xffff"
811 [(set_attr "type" "compare")])
812
813 (define_insn ""
814 [(set (match_operand:CC 2 "cc_reg_operand" "=x")
815 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r"))
816 (const_int 0)))
817 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
818 (zero_extend:SI (match_dup 1)))]
819 ""
820 "{andil.|andi.} %0,%1,0xffff"
821 [(set_attr "type" "compare")])
822
823 (define_expand "extendhisi2"
824 [(set (match_operand:SI 0 "gpc_reg_operand" "")
825 (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
826 ""
827 "")
828
829 (define_insn ""
830 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
831 (sign_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
832 ""
833 "@
834 lha%U1%X1 %0,%1
835 {exts|extsh} %0,%1"
836 [(set_attr "type" "load,*")])
837
838 (define_insn ""
839 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
840 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r"))
841 (const_int 0)))
842 (clobber (match_scratch:SI 2 "=r"))]
843 ""
844 "{exts.|extsh.} %2,%1"
845 [(set_attr "type" "compare")])
846
847 (define_insn ""
848 [(set (match_operand:CC 2 "cc_reg_operand" "=x")
849 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r"))
850 (const_int 0)))
851 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
852 (sign_extend:SI (match_dup 1)))]
853 ""
854 "{exts.|extsh.} %0,%1"
855 [(set_attr "type" "compare")])
856 \f
857 ;; Fixed-point arithmetic insns.
858
859 ;; Discourage ai/addic because of carry but provide it in an alternative
860 ;; allowing register zero as source.
861 (define_insn "addsi3"
862 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,?r,r")
863 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "%r,b,r,b")
864 (match_operand:SI 2 "add_operand" "r,I,I,J")))]
865 ""
866 "@
867 {cax|add} %0,%1,%2
868 {cal %0,%2(%1)|addi %0,%1,%2}
869 {ai|addic} %0,%1,%2
870 {cau|addis} %0,%1,%v2")
871
872 (define_insn ""
873 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
874 (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
875 (match_operand:SI 2 "reg_or_short_operand" "r,I"))
876 (const_int 0)))
877 (clobber (match_scratch:SI 3 "=r,r"))]
878 ""
879 "@
880 {cax.|add.} %3,%1,%2
881 {ai.|addic.} %3,%1,%2"
882 [(set_attr "type" "compare")])
883
884 (define_insn ""
885 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x")
886 (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
887 (match_operand:SI 2 "reg_or_short_operand" "r,I"))
888 (const_int 0)))
889 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
890 (plus:SI (match_dup 1) (match_dup 2)))]
891 ""
892 "@
893 {cax.|add.} %0,%1,%2
894 {ai.|addic.} %0,%1,%2"
895 [(set_attr "type" "compare")])
896
897 ;; Split an add that we can't do in one insn into two insns, each of which
898 ;; does one 16-bit part. This is used by combine. Note that the low-order
899 ;; add should be last in case the result gets used in an address.
900
901 (define_split
902 [(set (match_operand:SI 0 "gpc_reg_operand" "")
903 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "")
904 (match_operand:SI 2 "non_add_cint_operand" "")))]
905 ""
906 [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 3)))
907 (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 4)))]
908 "
909 {
910 HOST_WIDE_INT low = INTVAL (operands[2]) & 0xffff;
911 HOST_WIDE_INT high = INTVAL (operands[2]) & (~ (HOST_WIDE_INT) 0xffff);
912
913 if (low & 0x8000)
914 high += 0x10000, low |= ((HOST_WIDE_INT) -1) << 16;
915
916 operands[3] = GEN_INT (high);
917 operands[4] = GEN_INT (low);
918 }")
919
920 (define_insn "one_cmplsi2"
921 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
922 (not:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
923 ""
924 "nor %0,%1,%1")
925
926 (define_insn ""
927 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
928 (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
929 (const_int 0)))
930 (clobber (match_scratch:SI 2 "=r"))]
931 ""
932 "nor. %2,%1,%1"
933 [(set_attr "type" "compare")])
934
935 (define_insn ""
936 [(set (match_operand:CC 2 "cc_reg_operand" "=x")
937 (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
938 (const_int 0)))
939 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
940 (not:SI (match_dup 1)))]
941 ""
942 "nor. %0,%1,%1"
943 [(set_attr "type" "compare")])
944
945 (define_insn ""
946 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
947 (minus:SI (match_operand:SI 1 "reg_or_short_operand" "rI")
948 (match_operand:SI 2 "gpc_reg_operand" "r")))]
949 "! TARGET_POWERPC"
950 "{sf%I1|subf%I1c} %0,%2,%1")
951
952 (define_insn ""
953 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
954 (minus:SI (match_operand:SI 1 "reg_or_short_operand" "r,I")
955 (match_operand:SI 2 "gpc_reg_operand" "r,r")))]
956 "TARGET_POWERPC"
957 "@
958 subf %0,%2,%1
959 subfic %0,%2,%1")
960
961 (define_insn ""
962 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
963 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r")
964 (match_operand:SI 2 "gpc_reg_operand" "r"))
965 (const_int 0)))
966 (clobber (match_scratch:SI 3 "=r"))]
967 "! TARGET_POWERPC"
968 "{sf.|subfc.} %3,%2,%1"
969 [(set_attr "type" "compare")])
970
971 (define_insn ""
972 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
973 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r")
974 (match_operand:SI 2 "gpc_reg_operand" "r"))
975 (const_int 0)))
976 (clobber (match_scratch:SI 3 "=r"))]
977 "TARGET_POWERPC"
978 "subf. %3,%2,%1"
979 [(set_attr "type" "compare")])
980
981 (define_insn ""
982 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
983 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r")
984 (match_operand:SI 2 "gpc_reg_operand" "r"))
985 (const_int 0)))
986 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
987 (minus:SI (match_dup 1) (match_dup 2)))]
988 "! TARGET_POWERPC"
989 "{sf.|subfc.} %0,%2,%1"
990 [(set_attr "type" "compare")])
991
992 (define_insn ""
993 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
994 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r")
995 (match_operand:SI 2 "gpc_reg_operand" "r"))
996 (const_int 0)))
997 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
998 (minus:SI (match_dup 1) (match_dup 2)))]
999 "TARGET_POWERPC"
1000 "subf. %0,%2,%1"
1001 [(set_attr "type" "compare")])
1002
1003 (define_expand "subsi3"
1004 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1005 (minus:SI (match_operand:SI 1 "reg_or_short_operand" "")
1006 (match_operand:SI 2 "reg_or_cint_operand" "")))]
1007 ""
1008 "
1009 {
1010 if (GET_CODE (operands[2]) == CONST_INT)
1011 {
1012 emit_insn (gen_addsi3 (operands[0], operands[1],
1013 negate_rtx (SImode, operands[2])));
1014 DONE;
1015 }
1016 }")
1017
1018 ;; For SMIN, SMAX, UMIN, and UMAX, we use DEFINE_EXPAND's that involve a doz[i]
1019 ;; instruction and some auxiliary computations. Then we just have a single
1020 ;; DEFINE_INSN for doz[i] and the define_splits to make them if made by
1021 ;; combine.
1022
1023 (define_expand "sminsi3"
1024 [(set (match_dup 3)
1025 (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1026 (match_operand:SI 2 "reg_or_short_operand" ""))
1027 (const_int 0)
1028 (minus:SI (match_dup 2) (match_dup 1))))
1029 (set (match_operand:SI 0 "gpc_reg_operand" "")
1030 (minus:SI (match_dup 2) (match_dup 3)))]
1031 "TARGET_POWER"
1032 "
1033 { operands[3] = gen_reg_rtx (SImode); }")
1034
1035 (define_split
1036 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1037 (smin:SI (match_operand:SI 1 "gpc_reg_operand" "")
1038 (match_operand:SI 2 "reg_or_short_operand" "")))
1039 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
1040 "TARGET_POWER"
1041 [(set (match_dup 3)
1042 (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1043 (const_int 0)
1044 (minus:SI (match_dup 2) (match_dup 1))))
1045 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 3)))]
1046 "")
1047
1048 (define_expand "smaxsi3"
1049 [(set (match_dup 3)
1050 (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1051 (match_operand:SI 2 "reg_or_short_operand" ""))
1052 (const_int 0)
1053 (minus:SI (match_dup 2) (match_dup 1))))
1054 (set (match_operand:SI 0 "gpc_reg_operand" "")
1055 (plus:SI (match_dup 3) (match_dup 1)))]
1056 "TARGET_POWER"
1057 "
1058 { operands[3] = gen_reg_rtx (SImode); }")
1059
1060 (define_split
1061 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1062 (smax:SI (match_operand:SI 1 "gpc_reg_operand" "")
1063 (match_operand:SI 2 "reg_or_short_operand" "")))
1064 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
1065 "TARGET_POWER"
1066 [(set (match_dup 3)
1067 (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1068 (const_int 0)
1069 (minus:SI (match_dup 2) (match_dup 1))))
1070 (set (match_dup 0) (plus:SI (match_dup 3) (match_dup 1)))]
1071 "")
1072
1073 (define_expand "uminsi3"
1074 [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1075 (match_dup 5)))
1076 (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1077 (match_dup 5)))
1078 (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1079 (const_int 0)
1080 (minus:SI (match_dup 4) (match_dup 3))))
1081 (set (match_operand:SI 0 "gpc_reg_operand" "")
1082 (minus:SI (match_dup 2) (match_dup 3)))]
1083 "TARGET_POWER"
1084 "
1085 {
1086 operands[3] = gen_reg_rtx (SImode);
1087 operands[4] = gen_reg_rtx (SImode);
1088 operands[5] = GEN_INT (-2147483647 - 1);
1089 }")
1090
1091 (define_expand "umaxsi3"
1092 [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1093 (match_dup 5)))
1094 (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1095 (match_dup 5)))
1096 (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1097 (const_int 0)
1098 (minus:SI (match_dup 4) (match_dup 3))))
1099 (set (match_operand:SI 0 "gpc_reg_operand" "")
1100 (plus:SI (match_dup 3) (match_dup 1)))]
1101 "TARGET_POWER"
1102 "
1103 {
1104 operands[3] = gen_reg_rtx (SImode);
1105 operands[4] = gen_reg_rtx (SImode);
1106 operands[5] = GEN_INT (-2147483647 - 1);
1107 }")
1108
1109 (define_insn ""
1110 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1111 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r")
1112 (match_operand:SI 2 "reg_or_short_operand" "rI"))
1113 (const_int 0)
1114 (minus:SI (match_dup 2) (match_dup 1))))]
1115 "TARGET_POWER"
1116 "doz%I2 %0,%1,%2")
1117
1118 (define_insn ""
1119 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1120 (compare:CC
1121 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r")
1122 (match_operand:SI 2 "reg_or_short_operand" "rI"))
1123 (const_int 0)
1124 (minus:SI (match_dup 2) (match_dup 1)))
1125 (const_int 0)))
1126 (clobber (match_scratch:SI 3 "=r"))]
1127 "TARGET_POWER"
1128 "doz%I2. %3,%1,%2"
1129 [(set_attr "type" "delayed_compare")])
1130
1131 (define_insn ""
1132 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1133 (compare:CC
1134 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r")
1135 (match_operand:SI 2 "reg_or_short_operand" "rI"))
1136 (const_int 0)
1137 (minus:SI (match_dup 2) (match_dup 1)))
1138 (const_int 0)))
1139 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1140 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1141 (const_int 0)
1142 (minus:SI (match_dup 2) (match_dup 1))))]
1143 "TARGET_POWER"
1144 "doz%I2. %0,%1,%2"
1145 [(set_attr "type" "delayed_compare")])
1146
1147 ;; We don't need abs with condition code because such comparisons should
1148 ;; never be done.
1149 (define_expand "abssi2"
1150 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1151 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))]
1152 ""
1153 "
1154 {
1155 if (!TARGET_POWER)
1156 {
1157 emit_insn (gen_abssi2_nopower (operands[0], operands[1]));
1158 DONE;
1159 }
1160 }")
1161
1162 (define_insn "abssi2_power"
1163 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1164 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
1165 "TARGET_POWER"
1166 "abs %0,%1")
1167
1168 (define_insn "abssi2_nopower"
1169 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
1170 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0")))
1171 (clobber (match_scratch:SI 2 "=&r,&r"))]
1172 "!TARGET_POWER"
1173 "*
1174 {
1175 return (TARGET_POWERPC)
1176 ? \"{srai|srawi} %2,%1,31\;xor %0,%2,%1\;subf %0,%2,%0\"
1177 : \"{srai|srawi} %2,%1,31\;xor %0,%2,%1\;{sf|subfc} %0,%2,%0\";
1178 }"
1179 [(set_attr "length" "12")])
1180
1181 (define_split
1182 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
1183 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0")))
1184 (clobber (match_scratch:SI 2 "=&r,&r"))]
1185 "!TARGET_POWER && reload_completed"
1186 [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
1187 (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
1188 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 0)))]
1189 "")
1190
1191 (define_insn ""
1192 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1193 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r"))))]
1194 "TARGET_POWER"
1195 "nabs %0,%1")
1196
1197 (define_insn ""
1198 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
1199 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0"))))
1200 (clobber (match_scratch:SI 2 "=&r,&r"))]
1201 "!TARGET_POWER"
1202 "*
1203 {
1204 return (TARGET_POWERPC)
1205 ? \"{srai|srawi} %2,%1,31\;xor %0,%2,%1\;subf %0,%0,%2\"
1206 : \"{srai|srawi} %2,%1,31\;xor %0,%2,%1\;{sf|subfc} %0,%0,%2\";
1207 }"
1208 [(set_attr "length" "12")])
1209
1210 (define_split
1211 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
1212 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0"))))
1213 (clobber (match_scratch:SI 2 "=&r,&r"))]
1214 "!TARGET_POWER && reload_completed"
1215 [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
1216 (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
1217 (set (match_dup 0) (minus:SI (match_dup 0) (match_dup 2)))]
1218 "")
1219
1220 (define_insn "negsi2"
1221 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1222 (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
1223 ""
1224 "neg %0,%1")
1225
1226 (define_insn ""
1227 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1228 (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
1229 (const_int 0)))
1230 (clobber (match_scratch:SI 2 "=r"))]
1231 ""
1232 "neg. %2,%1"
1233 [(set_attr "type" "compare")])
1234
1235 (define_insn ""
1236 [(set (match_operand:CC 2 "cc_reg_operand" "=x")
1237 (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
1238 (const_int 0)))
1239 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1240 (neg:SI (match_dup 1)))]
1241 ""
1242 "neg. %0,%1"
1243 [(set_attr "type" "compare")])
1244
1245 (define_insn "ffssi2"
1246 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
1247 (ffs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
1248 ""
1249 "neg %0,%1\;and %0,%0,%1\;{cntlz|cntlzw} %0,%0\;{sfi|subfic} %0,%0,32"
1250 [(set_attr "length" "16")])
1251
1252 (define_expand "mulsi3"
1253 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
1254 (use (match_operand:SI 1 "gpc_reg_operand" ""))
1255 (use (match_operand:SI 2 "reg_or_short_operand" ""))]
1256 ""
1257 "
1258 {
1259 if (TARGET_POWER)
1260 emit_insn (gen_mulsi3_mq (operands[0], operands[1], operands[2]));
1261 else
1262 emit_insn (gen_mulsi3_no_mq (operands[0], operands[1], operands[2]));
1263 DONE;
1264 }")
1265
1266 (define_insn "mulsi3_mq"
1267 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1268 (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1269 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
1270 (clobber (match_scratch:SI 3 "=q,q"))]
1271 "TARGET_POWER"
1272 "@
1273 {muls|mullw} %0,%1,%2
1274 {muli|mulli} %0,%1,%2"
1275 [(set_attr "type" "imul")])
1276
1277 (define_insn "mulsi3_no_mq"
1278 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1279 (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1280 (match_operand:SI 2 "reg_or_short_operand" "r,I")))]
1281 "! TARGET_POWER"
1282 "@
1283 {muls|mullw} %0,%1,%2
1284 {muli|mulli} %0,%1,%2"
1285 [(set_attr "type" "imul")])
1286
1287 (define_insn ""
1288 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1289 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
1290 (match_operand:SI 2 "gpc_reg_operand" "r"))
1291 (const_int 0)))
1292 (clobber (match_scratch:SI 3 "=r"))
1293 (clobber (match_scratch:SI 4 "=q"))]
1294 "TARGET_POWER"
1295 "{muls.|mullw.} %3,%1,%2"
1296 [(set_attr "type" "delayed_compare")])
1297
1298 (define_insn ""
1299 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1300 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
1301 (match_operand:SI 2 "gpc_reg_operand" "r"))
1302 (const_int 0)))
1303 (clobber (match_scratch:SI 3 "=r"))]
1304 "! TARGET_POWER"
1305 "{muls.|mullw.} %3,%1,%2"
1306 [(set_attr "type" "delayed_compare")])
1307
1308 (define_insn ""
1309 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1310 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
1311 (match_operand:SI 2 "gpc_reg_operand" "r"))
1312 (const_int 0)))
1313 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1314 (mult:SI (match_dup 1) (match_dup 2)))
1315 (clobber (match_scratch:SI 4 "=q"))]
1316 "TARGET_POWER"
1317 "{muls.|mullw.} %0,%1,%2"
1318 [(set_attr "type" "delayed_compare")])
1319
1320 (define_insn ""
1321 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1322 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
1323 (match_operand:SI 2 "gpc_reg_operand" "r"))
1324 (const_int 0)))
1325 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1326 (mult:SI (match_dup 1) (match_dup 2)))]
1327 "! TARGET_POWER"
1328 "{muls.|mullw.} %0,%1,%2"
1329 [(set_attr "type" "delayed_compare")])
1330
1331 ;; Operand 1 is divided by operand 2; quotient goes to operand
1332 ;; 0 and remainder to operand 3.
1333 ;; ??? At some point, see what, if anything, we can do about if (x % y == 0).
1334
1335 (define_expand "divmodsi4"
1336 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
1337 (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
1338 (match_operand:SI 2 "gpc_reg_operand" "")))
1339 (set (match_operand:SI 3 "gpc_reg_operand" "")
1340 (mod:SI (match_dup 1) (match_dup 2)))])]
1341 "TARGET_POWER || (! TARGET_POWER && ! TARGET_POWERPC)"
1342 "
1343 {
1344 if (! TARGET_POWER && ! TARGET_POWERPC)
1345 {
1346 emit_move_insn (gen_rtx (REG, SImode, 3), operands[1]);
1347 emit_move_insn (gen_rtx (REG, SImode, 4), operands[2]);
1348 emit_insn (gen_divss_call ());
1349 emit_move_insn (operands[0], gen_rtx (REG, SImode, 3));
1350 emit_move_insn (operands[3], gen_rtx (REG, SImode, 4));
1351 DONE;
1352 }
1353 }")
1354
1355 (define_insn ""
1356 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1357 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1358 (match_operand:SI 2 "gpc_reg_operand" "r")))
1359 (set (match_operand:SI 3 "gpc_reg_operand" "=q")
1360 (mod:SI (match_dup 1) (match_dup 2)))]
1361 "TARGET_POWER"
1362 "divs %0,%1,%2"
1363 [(set_attr "type" "idiv")])
1364
1365 (define_insn ""
1366 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1367 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1368 (match_operand:SI 2 "gpc_reg_operand" "r")))]
1369 "TARGET_POWERPC"
1370 "divw %0,%1,%2"
1371 [(set_attr "type" "idiv")])
1372
1373 (define_expand "udivsi3"
1374 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1375 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
1376 (match_operand:SI 2 "gpc_reg_operand" "")))]
1377 "TARGET_POWERPC || (! TARGET_POWER && ! TARGET_POWERPC)"
1378 "
1379 {
1380 if (! TARGET_POWER && ! TARGET_POWERPC)
1381 {
1382 emit_move_insn (gen_rtx (REG, SImode, 3), operands[1]);
1383 emit_move_insn (gen_rtx (REG, SImode, 4), operands[2]);
1384 emit_insn (gen_quous_call ());
1385 emit_move_insn (operands[0], gen_rtx (REG, SImode, 3));
1386 DONE;
1387 }
1388 }")
1389
1390 (define_insn ""
1391 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1392 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1393 (match_operand:SI 2 "gpc_reg_operand" "r")))]
1394 "TARGET_POWERPC"
1395 "divwu %0,%1,%2"
1396 [(set_attr "type" "idiv")])
1397
1398 ;; For powers of two we can do srai/aze for divide and then adjust for
1399 ;; modulus. If it isn't a power of two, FAIL on POWER so divmodsi4 will be
1400 ;; used; for PowerPC, force operands into register and do a normal divide;
1401 ;; for AIX common-mode, use quoss call on register operands.
1402 (define_expand "divsi3"
1403 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1404 (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
1405 (match_operand:SI 2 "reg_or_cint_operand" "")))]
1406 ""
1407 "
1408 {
1409 if (GET_CODE (operands[2]) == CONST_INT
1410 && exact_log2 (INTVAL (operands[2])) >= 0)
1411 ;
1412 else if (TARGET_POWERPC)
1413 operands[2] = force_reg (SImode, operands[2]);
1414 else if (TARGET_POWER)
1415 FAIL;
1416 else
1417 {
1418 emit_move_insn (gen_rtx (REG, SImode, 3), operands[1]);
1419 emit_move_insn (gen_rtx (REG, SImode, 4), operands[2]);
1420 emit_insn (gen_quoss_call ());
1421 emit_move_insn (operands[0], gen_rtx (REG, SImode, 3));
1422 DONE;
1423 }
1424 }")
1425
1426 (define_expand "modsi3"
1427 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
1428 (use (match_operand:SI 1 "gpc_reg_operand" ""))
1429 (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
1430 ""
1431 "
1432 {
1433 int i = exact_log2 (INTVAL (operands[2]));
1434 rtx temp1;
1435 rtx temp2;
1436
1437 if (GET_CODE (operands[2]) != CONST_INT || i < 0)
1438 FAIL;
1439
1440 temp1 = gen_reg_rtx (SImode);
1441 temp2 = gen_reg_rtx (SImode);
1442
1443 emit_insn (gen_divsi3 (temp1, operands[1], operands[2]));
1444 emit_insn (gen_ashlsi3 (temp2, temp1, GEN_INT (i)));
1445 emit_insn (gen_subsi3 (operands[0], operands[1], temp2));
1446 DONE;
1447 }")
1448
1449 (define_insn ""
1450 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1451 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1452 (match_operand:SI 2 "const_int_operand" "N")))]
1453 "exact_log2 (INTVAL (operands[2])) >= 0"
1454 "{srai|srawi} %0,%1,%p2\;{aze|addze} %0,%0"
1455 [(set_attr "length" "8")])
1456
1457 (define_insn ""
1458 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1459 (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1460 (match_operand:SI 2 "const_int_operand" "N"))
1461 (const_int 0)))
1462 (clobber (match_scratch:SI 3 "=r"))]
1463 "exact_log2 (INTVAL (operands[2])) >= 0"
1464 "{srai|srawi} %3,%1,%p2\;{aze.|addze.} %3,%3"
1465 [(set_attr "type" "compare")
1466 (set_attr "length" "8")])
1467
1468 (define_insn ""
1469 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1470 (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1471 (match_operand:SI 2 "const_int_operand" "N"))
1472 (const_int 0)))
1473 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1474 (div:SI (match_dup 1) (match_dup 2)))]
1475 "exact_log2 (INTVAL (operands[2])) >= 0"
1476 "{srai|srawi} %0,%1,%p2\;{aze.|addze.} %0,%0"
1477 [(set_attr "type" "compare")
1478 (set_attr "length" "8")])
1479
1480 (define_insn ""
1481 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1482 (udiv:SI
1483 (plus:DI (ashift:DI
1484 (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
1485 (const_int 32))
1486 (zero_extend:DI (match_operand:SI 4 "register_operand" "2")))
1487 (match_operand:SI 3 "gpc_reg_operand" "r")))
1488 (set (match_operand:SI 2 "register_operand" "=*q")
1489 (umod:SI
1490 (plus:DI (ashift:DI
1491 (zero_extend:DI (match_dup 1)) (const_int 32))
1492 (zero_extend:DI (match_dup 4)))
1493 (match_dup 3)))]
1494 "TARGET_POWER"
1495 "div %0,%1,%3"
1496 [(set_attr "type" "idiv")])
1497
1498 ;; To do unsigned divide we handle the cases of the divisor looking like a
1499 ;; negative number. If it is a constant that is less than 2**31, we don't
1500 ;; have to worry about the branches. So make a few subroutines here.
1501 ;;
1502 ;; First comes the normal case.
1503 (define_expand "udivmodsi4_normal"
1504 [(set (match_dup 4) (const_int 0))
1505 (parallel [(set (match_operand:SI 0 "" "")
1506 (udiv:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
1507 (const_int 32))
1508 (zero_extend:DI (match_operand:SI 1 "" "")))
1509 (match_operand:SI 2 "" "")))
1510 (set (match_operand:SI 3 "" "")
1511 (umod:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
1512 (const_int 32))
1513 (zero_extend:DI (match_dup 1)))
1514 (match_dup 2)))])]
1515 "TARGET_POWER"
1516 "
1517 { operands[4] = gen_reg_rtx (SImode); }")
1518
1519 ;; This handles the branches.
1520 (define_expand "udivmodsi4_tests"
1521 [(set (match_operand:SI 0 "" "") (const_int 0))
1522 (set (match_operand:SI 3 "" "") (match_operand:SI 1 "" ""))
1523 (set (match_dup 5) (compare:CCUNS (match_dup 1) (match_operand:SI 2 "" "")))
1524 (set (pc) (if_then_else (ltu (match_dup 5) (const_int 0))
1525 (label_ref (match_operand:SI 4 "" "")) (pc)))
1526 (set (match_dup 0) (const_int 1))
1527 (set (match_dup 3) (minus:SI (match_dup 1) (match_dup 2)))
1528 (set (match_dup 6) (compare:CC (match_dup 2) (const_int 0)))
1529 (set (pc) (if_then_else (lt (match_dup 6) (const_int 0))
1530 (label_ref (match_dup 4)) (pc)))]
1531 "TARGET_POWER"
1532 "
1533 { operands[5] = gen_reg_rtx (CCUNSmode);
1534 operands[6] = gen_reg_rtx (CCmode);
1535 }")
1536
1537 (define_expand "udivmodsi4"
1538 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
1539 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
1540 (match_operand:SI 2 "reg_or_cint_operand" "")))
1541 (set (match_operand:SI 3 "gpc_reg_operand" "")
1542 (umod:SI (match_dup 1) (match_dup 2)))])]
1543 ""
1544 "
1545 {
1546 rtx label = 0;
1547
1548 if (! TARGET_POWER)
1549 if (! TARGET_POWERPC)
1550 {
1551 emit_move_insn (gen_rtx (REG, SImode, 3), operands[1]);
1552 emit_move_insn (gen_rtx (REG, SImode, 4), operands[2]);
1553 emit_insn (gen_divus_call ());
1554 emit_move_insn (operands[0], gen_rtx (REG, SImode, 3));
1555 emit_move_insn (operands[3], gen_rtx (REG, SImode, 4));
1556 DONE;
1557 }
1558 else
1559 FAIL;
1560
1561 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) < 0)
1562 {
1563 operands[2] = force_reg (SImode, operands[2]);
1564 label = gen_label_rtx ();
1565 emit (gen_udivmodsi4_tests (operands[0], operands[1], operands[2],
1566 operands[3], label));
1567 }
1568 else
1569 operands[2] = force_reg (SImode, operands[2]);
1570
1571 emit (gen_udivmodsi4_normal (operands[0], operands[1], operands[2],
1572 operands[3]));
1573 if (label)
1574 emit_label (label);
1575
1576 DONE;
1577 }")
1578
1579 ;; AIX architecture-independent common-mode multiply (DImode),
1580 ;; divide/modulus, and quotient subroutine calls. Input operands in R3 and
1581 ;; R4; results in R3 and sometimes R4; link register always clobbered by bla
1582 ;; instruction; R0 sometimes clobbered; also, MQ sometimes clobbered but
1583 ;; assumed unused if generating common-mode, so ignore.
1584 (define_insn "mulh_call"
1585 [(set (reg:SI 3)
1586 (truncate:SI
1587 (lshiftrt:DI (mult:DI (sign_extend:DI (reg:SI 3))
1588 (sign_extend:DI (reg:SI 4)))
1589 (const_int 32))))
1590 (clobber (match_scratch:SI 0 "=l"))]
1591 "! TARGET_POWER && ! TARGET_POWERPC"
1592 "bla __mulh"
1593 [(set_attr "type" "imul")])
1594
1595 (define_insn "mull_call"
1596 [(set (reg:DI 3)
1597 (mult:DI (sign_extend:DI (reg:SI 3))
1598 (sign_extend:DI (reg:SI 4))))
1599 (clobber (match_scratch:SI 0 "=l"))
1600 (clobber (reg:SI 0))]
1601 "! TARGET_POWER && ! TARGET_POWERPC"
1602 "bla __mull"
1603 [(set_attr "type" "imul")])
1604
1605 (define_insn "divss_call"
1606 [(set (reg:SI 3)
1607 (div:SI (reg:SI 3) (reg:SI 4)))
1608 (set (reg:SI 4)
1609 (mod:SI (reg:SI 3) (reg:SI 4)))
1610 (clobber (match_scratch:SI 0 "=l"))
1611 (clobber (reg:SI 0))]
1612 "! TARGET_POWER && ! TARGET_POWERPC"
1613 "bla __divss"
1614 [(set_attr "type" "idiv")])
1615
1616 (define_insn "divus_call"
1617 [(set (reg:SI 3)
1618 (udiv:SI (reg:SI 3) (reg:SI 4)))
1619 (set (reg:SI 4)
1620 (umod:SI (reg:SI 3) (reg:SI 4)))
1621 (clobber (match_scratch:SI 0 "=l"))
1622 (clobber (reg:SI 0))
1623 (clobber (match_scratch:CC 1 "=x"))
1624 (clobber (reg:CC 69))]
1625 "! TARGET_POWER && ! TARGET_POWERPC"
1626 "bla __divus"
1627 [(set_attr "type" "idiv")])
1628
1629 (define_insn "quoss_call"
1630 [(set (reg:SI 3)
1631 (div:SI (reg:SI 3) (reg:SI 4)))
1632 (clobber (match_scratch:SI 0 "=l"))]
1633 "! TARGET_POWER && ! TARGET_POWERPC"
1634 "bla __quoss"
1635 [(set_attr "type" "idiv")])
1636
1637 (define_insn "quous_call"
1638 [(set (reg:SI 3)
1639 (udiv:SI (reg:SI 3) (reg:SI 4)))
1640 (clobber (match_scratch:SI 0 "=l"))
1641 (clobber (reg:SI 0))
1642 (clobber (match_scratch:CC 1 "=x"))
1643 (clobber (reg:CC 69))]
1644 "! TARGET_POWER && ! TARGET_POWERPC"
1645 "bla __quous"
1646 [(set_attr "type" "idiv")])
1647 \f
1648 (define_insn "andsi3"
1649 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
1650 (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
1651 (match_operand:SI 2 "and_operand" "?r,L,K,J")))
1652 (clobber (match_scratch:CC 3 "=X,X,x,x"))]
1653 ""
1654 "@
1655 and %0,%1,%2
1656 {rlinm|rlwinm} %0,%1,0,%m2,%M2
1657 {andil.|andi.} %0,%1,%b2
1658 {andiu.|andis.} %0,%1,%u2")
1659
1660 (define_insn ""
1661 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x")
1662 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
1663 (match_operand:SI 2 "and_operand" "r,K,J,L"))
1664 (const_int 0)))
1665 (clobber (match_scratch:SI 3 "=r,r,r,r"))]
1666 ""
1667 "@
1668 and. %3,%1,%2
1669 {andil.|andi.} %3,%1,%b2
1670 {andiu.|andis.} %3,%1,%u2
1671 {rlinm.|rlwinm.} %3,%1,0,%m2,%M2"
1672 [(set_attr "type" "compare,compare,compare,delayed_compare")])
1673
1674 (define_insn ""
1675 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x")
1676 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
1677 (match_operand:SI 2 "and_operand" "r,K,J,L"))
1678 (const_int 0)))
1679 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
1680 (and:SI (match_dup 1) (match_dup 2)))]
1681 ""
1682 "@
1683 and. %0,%1,%2
1684 {andil.|andi.} %0,%1,%b2
1685 {andiu.|andis.} %0,%1,%u2
1686 {rlinm.|rlwinm.} %0,%1,0,%m2,%M2"
1687 [(set_attr "type" "compare,compare,compare,delayed_compare")])
1688
1689 ;; Take a AND with a constant that cannot be done in a single insn and try to
1690 ;; split it into two insns. This does not verify that the insns are valid
1691 ;; since this need not be done as combine will do it.
1692
1693 (define_split
1694 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1695 (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
1696 (match_operand:SI 2 "non_and_cint_operand" "")))]
1697 ""
1698 [(set (match_dup 0) (and:SI (match_dup 1) (match_dup 3)))
1699 (set (match_dup 0) (and:SI (match_dup 0) (match_dup 4)))]
1700 "
1701 {
1702 int maskval = INTVAL (operands[2]);
1703 int i, transitions, last_bit_value;
1704 int orig = maskval, first_c = maskval, second_c;
1705
1706 /* We know that MASKVAL must have more than 2 bit-transitions. Start at
1707 the low-order bit and count for the third transition. When we get there,
1708 make a first mask that has everything to the left of that position
1709 a one. Then make the second mask to turn off whatever else is needed. */
1710
1711 for (i = 1, transitions = 0, last_bit_value = maskval & 1; i < 32; i++)
1712 {
1713 if (((maskval >>= 1) & 1) != last_bit_value)
1714 last_bit_value ^= 1, transitions++;
1715
1716 if (transitions > 2)
1717 {
1718 first_c |= (~0) << i;
1719 break;
1720 }
1721 }
1722
1723 second_c = orig | ~ first_c;
1724
1725 operands[3] = gen_rtx (CONST_INT, VOIDmode, first_c);
1726 operands[4] = gen_rtx (CONST_INT, VOIDmode, second_c);
1727 }")
1728
1729 (define_insn "iorsi3"
1730 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
1731 (ior:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r")
1732 (match_operand:SI 2 "logical_operand" "r,K,J")))]
1733 ""
1734 "@
1735 or %0,%1,%2
1736 {oril|ori} %0,%1,%b2
1737 {oriu|oris} %0,%1,%u2")
1738
1739 (define_insn ""
1740 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1741 (compare:CC (ior:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
1742 (match_operand:SI 2 "gpc_reg_operand" "r"))
1743 (const_int 0)))
1744 (clobber (match_scratch:SI 3 "=r"))]
1745 ""
1746 "or. %3,%1,%2"
1747 [(set_attr "type" "compare")])
1748
1749 (define_insn ""
1750 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1751 (compare:CC (ior:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
1752 (match_operand:SI 2 "gpc_reg_operand" "r"))
1753 (const_int 0)))
1754 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1755 (ior:SI (match_dup 1) (match_dup 2)))]
1756 ""
1757 "or. %0,%1,%2"
1758 [(set_attr "type" "compare")])
1759
1760 ;; Split an IOR that we can't do in one insn into two insns, each of which
1761 ;; does one 16-bit part. This is used by combine.
1762
1763 (define_split
1764 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1765 (ior:SI (match_operand:SI 1 "gpc_reg_operand" "")
1766 (match_operand:SI 2 "non_logical_cint_operand" "")))]
1767 ""
1768 [(set (match_dup 0) (ior:SI (match_dup 1) (match_dup 3)))
1769 (set (match_dup 0) (ior:SI (match_dup 0) (match_dup 4)))]
1770 "
1771 {
1772 operands[3] = gen_rtx (CONST_INT, VOIDmode,
1773 INTVAL (operands[2]) & 0xffff0000);
1774 operands[4] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) & 0xffff);
1775 }")
1776
1777 (define_insn "xorsi3"
1778 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
1779 (xor:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r")
1780 (match_operand:SI 2 "logical_operand" "r,K,J")))]
1781 ""
1782 "@
1783 xor %0,%1,%2
1784 {xoril|xori} %0,%1,%b2
1785 {xoriu|xoris} %0,%1,%u2")
1786
1787 (define_insn ""
1788 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1789 (compare:CC (xor:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
1790 (match_operand:SI 2 "gpc_reg_operand" "r"))
1791 (const_int 0)))
1792 (clobber (match_scratch:SI 3 "=r"))]
1793 ""
1794 "xor. %3,%1,%2"
1795 [(set_attr "type" "compare")])
1796
1797 (define_insn ""
1798 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1799 (compare:CC (xor:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
1800 (match_operand:SI 2 "gpc_reg_operand" "r"))
1801 (const_int 0)))
1802 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1803 (xor:SI (match_dup 1) (match_dup 2)))]
1804 ""
1805 "xor. %0,%1,%2"
1806 [(set_attr "type" "compare")])
1807
1808 ;; Split an XOR that we can't do in one insn into two insns, each of which
1809 ;; does one 16-bit part. This is used by combine.
1810
1811 (define_split
1812 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1813 (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1814 (match_operand:SI 2 "non_logical_cint_operand" "")))]
1815 ""
1816 [(set (match_dup 0) (xor:SI (match_dup 1) (match_dup 3)))
1817 (set (match_dup 0) (xor:SI (match_dup 0) (match_dup 4)))]
1818 "
1819 {
1820 operands[3] = gen_rtx (CONST_INT, VOIDmode,
1821 INTVAL (operands[2]) & 0xffff0000);
1822 operands[4] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) & 0xffff);
1823 }")
1824
1825 (define_insn ""
1826 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1827 (not:SI (xor:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
1828 (match_operand:SI 2 "gpc_reg_operand" "r"))))]
1829 ""
1830 "eqv %0,%1,%2")
1831
1832 (define_insn ""
1833 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1834 (compare:CC (not:SI (xor:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
1835 (match_operand:SI 2 "gpc_reg_operand" "r")))
1836 (const_int 0)))
1837 (clobber (match_scratch:SI 3 "=r"))]
1838 ""
1839 "eqv. %3,%1,%2"
1840 [(set_attr "type" "compare")])
1841
1842 (define_insn ""
1843 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1844 (compare:CC (not:SI (xor:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
1845 (match_operand:SI 2 "gpc_reg_operand" "r")))
1846 (const_int 0)))
1847 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1848 (not:SI (xor:SI (match_dup 1) (match_dup 2))))]
1849 ""
1850 "eqv. %0,%1,%2"
1851 [(set_attr "type" "compare")])
1852
1853 (define_insn ""
1854 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1855 (and:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
1856 (match_operand:SI 2 "gpc_reg_operand" "r")))]
1857 ""
1858 "andc %0,%2,%1")
1859
1860 (define_insn ""
1861 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1862 (compare:CC (and:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
1863 (match_operand:SI 2 "gpc_reg_operand" "r"))
1864 (const_int 0)))
1865 (clobber (match_scratch:SI 3 "=r"))]
1866 ""
1867 "andc. %3,%2,%1"
1868 [(set_attr "type" "compare")])
1869
1870 (define_insn ""
1871 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1872 (compare:CC (and:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
1873 (match_operand:SI 2 "gpc_reg_operand" "r"))
1874 (const_int 0)))
1875 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1876 (and:SI (not:SI (match_dup 1)) (match_dup 2)))]
1877 ""
1878 "andc. %0,%2,%1"
1879 [(set_attr "type" "compare")])
1880
1881 (define_insn ""
1882 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1883 (ior:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
1884 (match_operand:SI 2 "gpc_reg_operand" "r")))]
1885 ""
1886 "orc %0,%2,%1")
1887
1888 (define_insn ""
1889 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1890 (compare:CC (ior:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
1891 (match_operand:SI 2 "gpc_reg_operand" "r"))
1892 (const_int 0)))
1893 (clobber (match_scratch:SI 3 "=r"))]
1894 ""
1895 "orc. %3,%2,%1"
1896 [(set_attr "type" "compare")])
1897
1898 (define_insn ""
1899 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1900 (compare:CC (ior:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
1901 (match_operand:SI 2 "gpc_reg_operand" "r"))
1902 (const_int 0)))
1903 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1904 (ior:SI (not:SI (match_dup 1)) (match_dup 2)))]
1905 ""
1906 "orc. %0,%2,%1"
1907 [(set_attr "type" "compare")])
1908
1909 (define_insn ""
1910 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1911 (ior:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "%r"))
1912 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
1913 ""
1914 "nand %0,%1,%2")
1915
1916 (define_insn ""
1917 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1918 (compare:CC (ior:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "%r"))
1919 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r")))
1920 (const_int 0)))
1921 (clobber (match_scratch:SI 3 "=r"))]
1922 ""
1923 "nand. %3,%1,%2"
1924 [(set_attr "type" "compare")])
1925
1926 (define_insn ""
1927 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1928 (compare:CC (ior:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "%r"))
1929 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r")))
1930 (const_int 0)))
1931 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1932 (ior:SI (not:SI (match_dup 1)) (not:SI (match_dup 2))))]
1933 ""
1934 "nand. %0,%1,%2"
1935 [(set_attr "type" "compare")])
1936
1937 (define_insn ""
1938 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1939 (and:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "%r"))
1940 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
1941 ""
1942 "nor %0,%1,%2")
1943
1944 (define_insn ""
1945 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1946 (compare:CC (and:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "%r"))
1947 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r")))
1948 (const_int 0)))
1949 (clobber (match_scratch:SI 3 "=r"))]
1950 ""
1951 "nor. %3,%1,%2"
1952 [(set_attr "type" "compare")])
1953
1954 (define_insn ""
1955 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1956 (compare:CC (and:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "%r"))
1957 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r")))
1958 (const_int 0)))
1959 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1960 (and:SI (not:SI (match_dup 1)) (not:SI (match_dup 2))))]
1961 ""
1962 "nor. %0,%1,%2"
1963 [(set_attr "type" "compare")])
1964
1965 ;; maskir insn. We need four forms because things might be in arbitrary
1966 ;; orders. Don't define forms that only set CR fields because these
1967 ;; would modify an input register.
1968
1969 (define_insn ""
1970 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1971 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
1972 (match_operand:SI 1 "gpc_reg_operand" "0"))
1973 (and:SI (match_dup 2)
1974 (match_operand:SI 3 "gpc_reg_operand" "r"))))]
1975 "TARGET_POWER"
1976 "maskir %0,%3,%2")
1977
1978 (define_insn ""
1979 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1980 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
1981 (match_operand:SI 1 "gpc_reg_operand" "0"))
1982 (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
1983 (match_dup 2))))]
1984 "TARGET_POWER"
1985 "maskir %0,%3,%2")
1986
1987 (define_insn ""
1988 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1989 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r")
1990 (match_operand:SI 3 "gpc_reg_operand" "r"))
1991 (and:SI (not:SI (match_dup 2))
1992 (match_operand:SI 1 "gpc_reg_operand" "0"))))]
1993 "TARGET_POWER"
1994 "maskir %0,%3,%2")
1995
1996 (define_insn ""
1997 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1998 (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
1999 (match_operand:SI 2 "gpc_reg_operand" "r"))
2000 (and:SI (not:SI (match_dup 2))
2001 (match_operand:SI 1 "gpc_reg_operand" "0"))))]
2002 "TARGET_POWER"
2003 "maskir %0,%3,%2")
2004
2005 (define_insn ""
2006 [(set (match_operand:CC 4 "cc_reg_operand" "=x")
2007 (compare:CC
2008 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
2009 (match_operand:SI 1 "gpc_reg_operand" "0"))
2010 (and:SI (match_dup 2)
2011 (match_operand:SI 3 "gpc_reg_operand" "r")))
2012 (const_int 0)))
2013 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2014 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2015 (and:SI (match_dup 2) (match_dup 3))))]
2016 "TARGET_POWER"
2017 "maskir. %0,%3,%2"
2018 [(set_attr "type" "compare")])
2019
2020 (define_insn ""
2021 [(set (match_operand:CC 4 "cc_reg_operand" "=x")
2022 (compare:CC
2023 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
2024 (match_operand:SI 1 "gpc_reg_operand" "0"))
2025 (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2026 (match_dup 2)))
2027 (const_int 0)))
2028 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2029 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2030 (and:SI (match_dup 3) (match_dup 2))))]
2031 "TARGET_POWER"
2032 "maskir. %0,%3,%2"
2033 [(set_attr "type" "compare")])
2034
2035 (define_insn ""
2036 [(set (match_operand:CC 4 "cc_reg_operand" "=x")
2037 (compare:CC
2038 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r")
2039 (match_operand:SI 3 "gpc_reg_operand" "r"))
2040 (and:SI (not:SI (match_dup 2))
2041 (match_operand:SI 1 "gpc_reg_operand" "0")))
2042 (const_int 0)))
2043 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2044 (ior:SI (and:SI (match_dup 2) (match_dup 3))
2045 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
2046 "TARGET_POWER"
2047 "maskir. %0,%3,%2"
2048 [(set_attr "type" "compare")])
2049
2050 (define_insn ""
2051 [(set (match_operand:CC 4 "cc_reg_operand" "=x")
2052 (compare:CC
2053 (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2054 (match_operand:SI 2 "gpc_reg_operand" "r"))
2055 (and:SI (not:SI (match_dup 2))
2056 (match_operand:SI 1 "gpc_reg_operand" "0")))
2057 (const_int 0)))
2058 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2059 (ior:SI (and:SI (match_dup 3) (match_dup 2))
2060 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
2061 "TARGET_POWER"
2062 "maskir. %0,%3,%2"
2063 [(set_attr "type" "compare")])
2064 \f
2065 ;; Rotate and shift insns, in all their variants. These support shifts,
2066 ;; field inserts and extracts, and various combinations thereof.
2067 (define_expand "insv"
2068 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2069 (match_operand:SI 1 "const_int_operand" "i")
2070 (match_operand:SI 2 "const_int_operand" "i"))
2071 (match_operand:SI 3 "gpc_reg_operand" "r"))]
2072 ""
2073 "
2074 {
2075 /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
2076 the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
2077 compiler if the address of the structure is taken later. */
2078 if (GET_CODE (operands[0]) == SUBREG
2079 && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD))
2080 FAIL;
2081 }")
2082
2083 (define_insn ""
2084 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2085 (match_operand:SI 1 "const_int_operand" "i")
2086 (match_operand:SI 2 "const_int_operand" "i"))
2087 (match_operand:SI 3 "gpc_reg_operand" "r"))]
2088 ""
2089 "*
2090 {
2091 int start = INTVAL (operands[2]) & 31;
2092 int size = INTVAL (operands[1]) & 31;
2093
2094 operands[4] = gen_rtx (CONST_INT, VOIDmode, 32 - start - size);
2095 operands[1] = gen_rtx (CONST_INT, VOIDmode, start + size - 1);
2096 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
2097 }")
2098
2099 (define_insn ""
2100 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2101 (match_operand:SI 1 "const_int_operand" "i")
2102 (match_operand:SI 2 "const_int_operand" "i"))
2103 (ashift:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2104 (match_operand:SI 4 "const_int_operand" "i")))]
2105 ""
2106 "*
2107 {
2108 int shift = INTVAL (operands[4]) & 31;
2109 int start = INTVAL (operands[2]) & 31;
2110 int size = INTVAL (operands[1]) & 31;
2111
2112 operands[4] = gen_rtx (CONST_INT, VOIDmode, shift - start - size);
2113 operands[1] = gen_rtx (CONST_INT, VOIDmode, start + size - 1);
2114 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
2115 }")
2116
2117 (define_insn ""
2118 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2119 (match_operand:SI 1 "const_int_operand" "i")
2120 (match_operand:SI 2 "const_int_operand" "i"))
2121 (ashiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2122 (match_operand:SI 4 "const_int_operand" "i")))]
2123 ""
2124 "*
2125 {
2126 int shift = INTVAL (operands[4]) & 31;
2127 int start = INTVAL (operands[2]) & 31;
2128 int size = INTVAL (operands[1]) & 31;
2129
2130 operands[4] = gen_rtx (CONST_INT, VOIDmode, 32 - shift - start - size);
2131 operands[1] = gen_rtx (CONST_INT, VOIDmode, start + size - 1);
2132 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
2133 }")
2134
2135 (define_insn ""
2136 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2137 (match_operand:SI 1 "const_int_operand" "i")
2138 (match_operand:SI 2 "const_int_operand" "i"))
2139 (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2140 (match_operand:SI 4 "const_int_operand" "i")))]
2141 ""
2142 "*
2143 {
2144 int shift = INTVAL (operands[4]) & 31;
2145 int start = INTVAL (operands[2]) & 31;
2146 int size = INTVAL (operands[1]) & 31;
2147
2148 operands[4] = gen_rtx (CONST_INT, VOIDmode, 32 - shift - start - size);
2149 operands[1] = gen_rtx (CONST_INT, VOIDmode, start + size - 1);
2150 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
2151 }")
2152
2153 (define_insn ""
2154 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2155 (match_operand:SI 1 "const_int_operand" "i")
2156 (match_operand:SI 2 "const_int_operand" "i"))
2157 (zero_extract:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2158 (match_operand:SI 4 "const_int_operand" "i")
2159 (match_operand:SI 5 "const_int_operand" "i")))]
2160 "INTVAL (operands[4]) >= INTVAL (operands[1])"
2161 "*
2162 {
2163 int extract_start = INTVAL (operands[5]) & 31;
2164 int extract_size = INTVAL (operands[4]) & 31;
2165 int insert_start = INTVAL (operands[2]) & 31;
2166 int insert_size = INTVAL (operands[1]) & 31;
2167
2168 /* Align extract field with insert field */
2169 operands[5] = gen_rtx (CONST_INT, VOIDmode,
2170 extract_start + extract_size - insert_start - insert_size);
2171 operands[1] = gen_rtx (CONST_INT, VOIDmode, insert_start + insert_size - 1);
2172 return \"{rlimi|rlwimi} %0,%3,%h5,%h2,%h1\";
2173 }")
2174
2175 (define_insn ""
2176 [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
2177 (match_operand:DI 1 "const_int_operand" "i")
2178 (match_operand:DI 2 "const_int_operand" "i"))
2179 (match_operand:DI 3 "gpc_reg_operand" "r"))]
2180 "TARGET_POWERPC64"
2181 "*
2182 {
2183 int start = INTVAL (operands[2]) & 63;
2184 int size = INTVAL (operands[1]) & 63;
2185
2186 operands[2] = gen_rtx (CONST_INT, VOIDmode, 64 - start - size);
2187 return \"rldimi %0,%3,%H2,%H1\";
2188 }")
2189
2190 (define_expand "extzv"
2191 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2192 (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2193 (match_operand:SI 2 "const_int_operand" "i")
2194 (match_operand:SI 3 "const_int_operand" "i")))]
2195 ""
2196 "
2197 {
2198 /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
2199 the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
2200 compiler if the address of the structure is taken later. */
2201 if (GET_CODE (operands[0]) == SUBREG
2202 && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD))
2203 FAIL;
2204 }")
2205
2206 (define_insn ""
2207 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2208 (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2209 (match_operand:SI 2 "const_int_operand" "i")
2210 (match_operand:SI 3 "const_int_operand" "i")))]
2211 ""
2212 "*
2213 {
2214 int start = INTVAL (operands[3]) & 31;
2215 int size = INTVAL (operands[2]) & 31;
2216
2217 if (start + size >= 32)
2218 operands[3] = const0_rtx;
2219 else
2220 operands[3] = gen_rtx (CONST_INT, VOIDmode, start + size);
2221 return \"{rlinm|rlwinm} %0,%1,%3,%s2,31\";
2222 }")
2223
2224 (define_insn ""
2225 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
2226 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2227 (match_operand:SI 2 "const_int_operand" "i")
2228 (match_operand:SI 3 "const_int_operand" "i"))
2229 (const_int 0)))
2230 (clobber (match_scratch:SI 4 "=r"))]
2231 ""
2232 "*
2233 {
2234 int start = INTVAL (operands[3]) & 31;
2235 int size = INTVAL (operands[2]) & 31;
2236
2237 /* If the bitfield being tested fits in the upper or lower half of a
2238 word, it is possible to use andiu. or andil. to test it. This is
2239 useful because the condition register set-use delay is smaller for
2240 andi[ul]. than for rlinm. This doesn't work when the starting bit
2241 position is 0 because the LT and GT bits may be set wrong. */
2242
2243 if ((start > 0 && start + size <= 16) || start >= 16)
2244 {
2245 operands[3] = gen_rtx (CONST_INT, VOIDmode,
2246 ((1 << (16 - (start & 15)))
2247 - (1 << (16 - (start & 15) - size))));
2248 if (start < 16)
2249 return \"{andiu.|andis.} %4,%1,%3\";
2250 else
2251 return \"{andil.|andi.} %4,%1,%3\";
2252 }
2253
2254 if (start + size >= 32)
2255 operands[3] = const0_rtx;
2256 else
2257 operands[3] = gen_rtx (CONST_INT, VOIDmode, start + size);
2258 return \"{rlinm.|rlwinm.} %4,%1,%3,%s2,31\";
2259 }"
2260 [(set_attr "type" "compare")])
2261
2262 (define_insn ""
2263 [(set (match_operand:CC 4 "cc_reg_operand" "=x")
2264 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2265 (match_operand:SI 2 "const_int_operand" "i")
2266 (match_operand:SI 3 "const_int_operand" "i"))
2267 (const_int 0)))
2268 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2269 (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
2270 ""
2271 "*
2272 {
2273 int start = INTVAL (operands[3]) & 31;
2274 int size = INTVAL (operands[2]) & 31;
2275
2276 if (start >= 16 && start + size == 32)
2277 {
2278 operands[3] = gen_rtx (CONST_INT, VOIDmode, (1 << (32 - start)) - 1);
2279 return \"{andil.|andi.} %0,%1,%3\";
2280 }
2281
2282 if (start + size >= 32)
2283 operands[3] = const0_rtx;
2284 else
2285 operands[3] = gen_rtx (CONST_INT, VOIDmode, start + size);
2286 return \"{rlinm.|rlwinm.} %0,%1,%3,%s2,31\";
2287 }"
2288 [(set_attr "type" "delayed_compare")])
2289
2290 (define_insn ""
2291 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
2292 (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
2293 (match_operand:DI 2 "const_int_operand" "i")
2294 (match_operand:DI 3 "const_int_operand" "i")))]
2295 "TARGET_POWERPC64"
2296 "*
2297 {
2298 int start = INTVAL (operands[3]) & 63;
2299 int size = INTVAL (operands[2]) & 63;
2300
2301 if (start + size >= 64)
2302 operands[3] = const0_rtx;
2303 else
2304 operands[3] = gen_rtx (CONST_INT, VOIDmode, start + size);
2305 operands[2] = gen_rtx (CONST_INT, VOIDmode, 64 - size);
2306 return \"rldicl %0,%1,%3,%2\";
2307 }")
2308
2309 (define_insn ""
2310 [(set (match_operand:CC 0 "gpc_reg_operand" "=x")
2311 (compare:CC (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
2312 (match_operand:DI 2 "const_int_operand" "i")
2313 (match_operand:DI 3 "const_int_operand" "i"))
2314 (const_int 0)))
2315 (clobber (match_scratch:DI 4 "=r"))]
2316 "TARGET_POWERPC64"
2317 "*
2318 {
2319 int start = INTVAL (operands[3]) & 63;
2320 int size = INTVAL (operands[2]) & 63;
2321
2322 if (start + size >= 64)
2323 operands[3] = const0_rtx;
2324 else
2325 operands[3] = gen_rtx (CONST_INT, VOIDmode, start + size);
2326 operands[2] = gen_rtx (CONST_INT, VOIDmode, 64 - size);
2327 return \"rldicl. %4,%1,%3,%2\";
2328 }")
2329
2330 (define_insn ""
2331 [(set (match_operand:CC 4 "gpc_reg_operand" "=x")
2332 (compare:CC (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
2333 (match_operand:DI 2 "const_int_operand" "i")
2334 (match_operand:DI 3 "const_int_operand" "i"))
2335 (const_int 0)))
2336 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
2337 (zero_extract:DI (match_dup 1) (match_dup 2) (match_dup 3)))]
2338 "TARGET_POWERPC64"
2339 "*
2340 {
2341 int start = INTVAL (operands[3]) & 63;
2342 int size = INTVAL (operands[2]) & 63;
2343
2344 if (start + size >= 64)
2345 operands[3] = const0_rtx;
2346 else
2347 operands[3] = gen_rtx (CONST_INT, VOIDmode, start + size);
2348 operands[2] = gen_rtx (CONST_INT, VOIDmode, 64 - size);
2349 return \"rldicl. %0,%1,%3,%2\";
2350 }")
2351
2352 (define_insn "rotlsi3"
2353 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2354 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2355 (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
2356 ""
2357 "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xffffffff")
2358
2359 (define_insn ""
2360 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
2361 (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2362 (match_operand:SI 2 "reg_or_cint_operand" "ri"))
2363 (const_int 0)))
2364 (clobber (match_scratch:SI 3 "=r"))]
2365 ""
2366 "{rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xffffffff"
2367 [(set_attr "type" "delayed_compare")])
2368
2369 (define_insn ""
2370 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
2371 (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2372 (match_operand:SI 2 "reg_or_cint_operand" "ri"))
2373 (const_int 0)))
2374 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2375 (rotate:SI (match_dup 1) (match_dup 2)))]
2376 ""
2377 "{rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xffffffff"
2378 [(set_attr "type" "delayed_compare")])
2379
2380 (define_insn ""
2381 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2382 (and:SI (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2383 (match_operand:SI 2 "reg_or_cint_operand" "ri"))
2384 (match_operand:SI 3 "mask_operand" "L")))]
2385 ""
2386 "{rl%I2nm|rlw%I2nm} %0,%1,%h2,%m3,%M3")
2387
2388 (define_insn ""
2389 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
2390 (compare:CC (and:SI
2391 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2392 (match_operand:SI 2 "reg_or_cint_operand" "ri"))
2393 (match_operand:SI 3 "mask_operand" "L"))
2394 (const_int 0)))
2395 (clobber (match_scratch:SI 4 "=r"))]
2396 ""
2397 "{rl%I2nm.|rlw%I2nm.} %4,%1,%h2,%m3,%M3"
2398 [(set_attr "type" "delayed_compare")])
2399
2400 (define_insn ""
2401 [(set (match_operand:CC 4 "cc_reg_operand" "=x")
2402 (compare:CC (and:SI
2403 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2404 (match_operand:SI 2 "reg_or_cint_operand" "ri"))
2405 (match_operand:SI 3 "mask_operand" "L"))
2406 (const_int 0)))
2407 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2408 (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
2409 ""
2410 "{rl%I2nm.|rlw%I2nm.} %0,%1,%h2,%m3,%M3"
2411 [(set_attr "type" "delayed_compare")])
2412
2413 (define_insn ""
2414 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2415 (zero_extend:SI
2416 (subreg:QI
2417 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2418 (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0)))]
2419 ""
2420 "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xff")
2421
2422 (define_insn ""
2423 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
2424 (compare:CC (zero_extend:SI
2425 (subreg:QI
2426 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2427 (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0))
2428 (const_int 0)))
2429 (clobber (match_scratch:SI 3 "=r"))]
2430 ""
2431 "{rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xff"
2432 [(set_attr "type" "delayed_compare")])
2433
2434 (define_insn ""
2435 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
2436 (compare:CC (zero_extend:SI
2437 (subreg:QI
2438 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2439 (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0))
2440 (const_int 0)))
2441 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2442 (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
2443 ""
2444 "{rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xff"
2445 [(set_attr "type" "delayed_compare")])
2446
2447 (define_insn ""
2448 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2449 (zero_extend:SI
2450 (subreg:HI
2451 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2452 (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0)))]
2453 ""
2454 "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xffff")
2455
2456 (define_insn ""
2457 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
2458 (compare:CC (zero_extend:SI
2459 (subreg:HI
2460 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2461 (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0))
2462 (const_int 0)))
2463 (clobber (match_scratch:SI 3 "=r"))]
2464 ""
2465 "{rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xffff"
2466 [(set_attr "type" "delayed_compare")])
2467
2468 (define_insn ""
2469 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
2470 (compare:CC (zero_extend:SI
2471 (subreg:HI
2472 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2473 (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0))
2474 (const_int 0)))
2475 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2476 (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
2477 ""
2478 "{rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xffff"
2479 [(set_attr "type" "delayed_compare")])
2480
2481 ;; Note that we use "sle." instead of "sl." so that we can set
2482 ;; SHIFT_COUNT_TRUNCATED.
2483
2484 (define_expand "ashlsi3"
2485 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
2486 (use (match_operand:SI 1 "gpc_reg_operand" ""))
2487 (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
2488 ""
2489 "
2490 {
2491 if (TARGET_POWER)
2492 emit_insn (gen_ashlsi3_power (operands[0], operands[1], operands[2]));
2493 else
2494 emit_insn (gen_ashlsi3_no_power (operands[0], operands[1], operands[2]));
2495 DONE;
2496 }")
2497
2498 (define_insn "ashlsi3_power"
2499 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2500 (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2501 (match_operand:SI 2 "reg_or_cint_operand" "r,i")))
2502 (clobber (match_scratch:SI 3 "=q,X"))]
2503 "TARGET_POWER"
2504 "@
2505 sle %0,%1,%2
2506 {sli|slwi} %0,%1,%h2"
2507 [(set_attr "length" "8")])
2508
2509 (define_insn "ashlsi3_no_power"
2510 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2511 (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2512 (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
2513 "! TARGET_POWER"
2514 "{sl|slw}%I2 %0,%1,%h2"
2515 [(set_attr "length" "8")])
2516
2517 (define_insn ""
2518 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
2519 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2520 (match_operand:SI 2 "reg_or_cint_operand" "r,i"))
2521 (const_int 0)))
2522 (clobber (match_scratch:SI 3 "=r,r"))
2523 (clobber (match_scratch:SI 4 "=q,X"))]
2524 "TARGET_POWER"
2525 "@
2526 sle. %3,%1,%2
2527 {sli.|slwi.} %3,%1,%h2"
2528 [(set_attr "type" "delayed_compare")])
2529
2530 (define_insn ""
2531 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
2532 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2533 (match_operand:SI 2 "reg_or_cint_operand" "ri"))
2534 (const_int 0)))
2535 (clobber (match_scratch:SI 3 "=r"))]
2536 "! TARGET_POWER"
2537 "{sl|slw}%I2. %3,%1,%h2"
2538 [(set_attr "type" "delayed_compare")])
2539
2540 (define_insn ""
2541 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x")
2542 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2543 (match_operand:SI 2 "reg_or_cint_operand" "r,i"))
2544 (const_int 0)))
2545 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2546 (ashift:SI (match_dup 1) (match_dup 2)))
2547 (clobber (match_scratch:SI 4 "=q,X"))]
2548 "TARGET_POWER"
2549 "@
2550 sle. %0,%1,%2
2551 {sli.|slwi.} %0,%1,%h2"
2552 [(set_attr "type" "delayed_compare")])
2553
2554 (define_insn ""
2555 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
2556 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2557 (match_operand:SI 2 "reg_or_cint_operand" "ri"))
2558 (const_int 0)))
2559 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2560 (ashift:SI (match_dup 1) (match_dup 2)))]
2561 "! TARGET_POWER"
2562 "{sl|slw}%I2. %0,%1,%h2"
2563 [(set_attr "type" "delayed_compare")])
2564
2565 (define_insn ""
2566 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2567 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2568 (match_operand:SI 2 "const_int_operand" "i"))
2569 (match_operand:SI 3 "mask_operand" "L")))]
2570 "includes_lshift_p (operands[2], operands[3])"
2571 "{rlinm|rlwinm} %0,%1,%h2,%m3,%M3")
2572
2573 (define_insn ""
2574 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
2575 (compare:CC
2576 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2577 (match_operand:SI 2 "const_int_operand" "i"))
2578 (match_operand:SI 3 "mask_operand" "L"))
2579 (const_int 0)))
2580 (clobber (match_scratch:SI 4 "=r"))]
2581 "includes_lshift_p (operands[2], operands[3])"
2582 "{rlinm.|rlwinm.} %4,%1,%h2,%m3,%M3"
2583 [(set_attr "type" "delayed_compare")])
2584
2585 (define_insn ""
2586 [(set (match_operand:CC 4 "cc_reg_operand" "=x")
2587 (compare:CC
2588 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2589 (match_operand:SI 2 "const_int_operand" "i"))
2590 (match_operand:SI 3 "mask_operand" "L"))
2591 (const_int 0)))
2592 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2593 (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
2594 "includes_lshift_p (operands[2], operands[3])"
2595 "{rlinm.|rlwinm.} %0,%1,%h2,%m3,%M3"
2596 [(set_attr "type" "delayed_compare")])
2597
2598 ;; The AIX assembler mis-handles "sri x,x,0", so write that case as
2599 ;; "sli x,x,0".
2600 (define_expand "lshrsi3"
2601 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
2602 (use (match_operand:SI 1 "gpc_reg_operand" ""))
2603 (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
2604 ""
2605 "
2606 {
2607 if (TARGET_POWER)
2608 emit_insn (gen_lshrsi3_power (operands[0], operands[1], operands[2]));
2609 else
2610 emit_insn (gen_lshrsi3_no_power (operands[0], operands[1], operands[2]));
2611 DONE;
2612 }")
2613
2614 (define_insn "lshrsi3_power"
2615 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
2616 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r")
2617 (match_operand:SI 2 "reg_or_cint_operand" "r,O,i")))
2618 (clobber (match_scratch:SI 3 "=q,X,X"))]
2619 "TARGET_POWER"
2620 "@
2621 sre %0,%1,%2
2622 mr %0,%1
2623 {s%A2i|s%A2wi} %0,%1,%h2")
2624
2625 (define_insn "lshrsi3_no_power"
2626 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2627 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2628 (match_operand:SI 2 "reg_or_cint_operand" "O,ri")))]
2629 "! TARGET_POWER"
2630 "@
2631 mr %0,%1
2632 {sr|srw}%I2 %0,%1,%h2")
2633
2634 (define_insn ""
2635 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x")
2636 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r")
2637 (match_operand:SI 2 "reg_or_cint_operand" "r,O,i"))
2638 (const_int 0)))
2639 (clobber (match_scratch:SI 3 "=r,X,r"))
2640 (clobber (match_scratch:SI 4 "=q,X,X"))]
2641 "TARGET_POWER"
2642 "@
2643 sre. %3,%1,%2
2644 mr. %1,%1
2645 {s%A2i.|s%A2wi.} %3,%1,%h2"
2646 [(set_attr "type" "delayed_compare")])
2647
2648 (define_insn ""
2649 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
2650 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2651 (match_operand:SI 2 "reg_or_cint_operand" "O,ri"))
2652 (const_int 0)))
2653 (clobber (match_scratch:SI 3 "=X,r"))]
2654 "! TARGET_POWER"
2655 "@
2656 mr. %1,%1
2657 {sr|srw}%I2. %3,%1,%h2"
2658 [(set_attr "type" "delayed_compare")])
2659
2660 (define_insn ""
2661 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x")
2662 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r")
2663 (match_operand:SI 2 "reg_or_cint_operand" "r,O,i"))
2664 (const_int 0)))
2665 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
2666 (lshiftrt:SI (match_dup 1) (match_dup 2)))
2667 (clobber (match_scratch:SI 4 "=q,X,X"))]
2668 "TARGET_POWER"
2669 "@
2670 sre. %0,%1,%2
2671 mr. %0,%1
2672 {s%A2i.|s%A2wi.} %0,%1,%h2"
2673 [(set_attr "type" "delayed_compare")])
2674
2675 (define_insn ""
2676 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x")
2677 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2678 (match_operand:SI 2 "reg_or_cint_operand" "O,ri"))
2679 (const_int 0)))
2680 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2681 (lshiftrt:SI (match_dup 1) (match_dup 2)))]
2682 "! TARGET_POWER"
2683 "@
2684 mr. %0,%1
2685 {sr|srw}%I2. %0,%1,%h2"
2686 [(set_attr "type" "delayed_compare")])
2687
2688 (define_insn ""
2689 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2690 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2691 (match_operand:SI 2 "const_int_operand" "i"))
2692 (match_operand:SI 3 "mask_operand" "L")))]
2693 "includes_rshift_p (operands[2], operands[3])"
2694 "{rlinm|rlwinm} %0,%1,%s2,%m3,%M3")
2695
2696 (define_insn ""
2697 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
2698 (compare:CC
2699 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2700 (match_operand:SI 2 "const_int_operand" "i"))
2701 (match_operand:SI 3 "mask_operand" "L"))
2702 (const_int 0)))
2703 (clobber (match_scratch:SI 4 "=r"))]
2704 "includes_rshift_p (operands[2], operands[3])"
2705 "{rlinm.|rlwinm.} %4,%1,%s2,%m3,%M3"
2706 [(set_attr "type" "delayed_compare")])
2707
2708 (define_insn ""
2709 [(set (match_operand:CC 4 "cc_reg_operand" "=x")
2710 (compare:CC
2711 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2712 (match_operand:SI 2 "const_int_operand" "i"))
2713 (match_operand:SI 3 "mask_operand" "L"))
2714 (const_int 0)))
2715 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2716 (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
2717 "includes_rshift_p (operands[2], operands[3])"
2718 "{rlinm.|rlwinm.} %0,%1,%s2,%m3,%M3"
2719 [(set_attr "type" "delayed_compare")])
2720
2721 (define_insn ""
2722 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2723 (zero_extend:SI
2724 (subreg:QI
2725 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2726 (match_operand:SI 2 "const_int_operand" "i")) 0)))]
2727 "includes_rshift_p (operands[2], gen_rtx (CONST_INT, VOIDmode, 255))"
2728 "{rlinm|rlwinm} %0,%1,%s2,0xff")
2729
2730 (define_insn ""
2731 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
2732 (compare:CC
2733 (zero_extend:SI
2734 (subreg:QI
2735 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2736 (match_operand:SI 2 "const_int_operand" "i")) 0))
2737 (const_int 0)))
2738 (clobber (match_scratch:SI 3 "=r"))]
2739 "includes_rshift_p (operands[2], gen_rtx (CONST_INT, VOIDmode, 255))"
2740 "{rlinm.|rlwinm.} %3,%1,%s2,0xff"
2741 [(set_attr "type" "delayed_compare")])
2742
2743 (define_insn ""
2744 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
2745 (compare:CC
2746 (zero_extend:SI
2747 (subreg:QI
2748 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2749 (match_operand:SI 2 "const_int_operand" "i")) 0))
2750 (const_int 0)))
2751 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2752 (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
2753 "includes_rshift_p (operands[2], gen_rtx (CONST_INT, VOIDmode, 255))"
2754 "{rlinm.|rlwinm.} %0,%1,%s2,0xff"
2755 [(set_attr "type" "delayed_compare")])
2756
2757 (define_insn ""
2758 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2759 (zero_extend:SI
2760 (subreg:HI
2761 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2762 (match_operand:SI 2 "const_int_operand" "i")) 0)))]
2763 "includes_rshift_p (operands[2], gen_rtx (CONST_INT, VOIDmode, 65535))"
2764 "{rlinm|rlwinm} %0,%1,%s2,0xffff")
2765
2766 (define_insn ""
2767 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
2768 (compare:CC
2769 (zero_extend:SI
2770 (subreg:HI
2771 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2772 (match_operand:SI 2 "const_int_operand" "i")) 0))
2773 (const_int 0)))
2774 (clobber (match_scratch:SI 3 "=r"))]
2775 "includes_rshift_p (operands[2], gen_rtx (CONST_INT, VOIDmode, 65535))"
2776 "{rlinm.|rlwinm.} %3,%1,%s2,0xffff"
2777 [(set_attr "type" "delayed_compare")])
2778
2779 (define_insn ""
2780 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
2781 (compare:CC
2782 (zero_extend:SI
2783 (subreg:HI
2784 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2785 (match_operand:SI 2 "const_int_operand" "i")) 0))
2786 (const_int 0)))
2787 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2788 (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
2789 "includes_rshift_p (operands[2], gen_rtx (CONST_INT, VOIDmode, 65535))"
2790 "{rlinm.|rlwinm.} %0,%1,%s2,0xffff"
2791 [(set_attr "type" "delayed_compare")])
2792
2793 (define_insn ""
2794 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2795 (const_int 1)
2796 (match_operand:SI 1 "gpc_reg_operand" "r"))
2797 (ashiftrt:SI (match_operand:SI 2 "gpc_reg_operand" "r")
2798 (const_int 31)))]
2799 "TARGET_POWER"
2800 "rrib %0,%1,%2")
2801
2802 (define_insn ""
2803 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2804 (const_int 1)
2805 (match_operand:SI 1 "gpc_reg_operand" "r"))
2806 (lshiftrt:SI (match_operand:SI 2 "gpc_reg_operand" "r")
2807 (const_int 31)))]
2808 "TARGET_POWER"
2809 "rrib %0,%1,%2")
2810
2811 (define_insn ""
2812 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2813 (const_int 1)
2814 (match_operand:SI 1 "gpc_reg_operand" "r"))
2815 (zero_extract:SI (match_operand:SI 2 "gpc_reg_operand" "r")
2816 (const_int 1)
2817 (const_int 0)))]
2818 "TARGET_POWER"
2819 "rrib %0,%1,%2")
2820
2821 (define_expand "ashrsi3"
2822 [(set (match_operand:SI 0 "gpc_reg_operand" "")
2823 (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
2824 (match_operand:SI 2 "reg_or_cint_operand" "")))]
2825 ""
2826 "
2827 {
2828 if (TARGET_POWER)
2829 emit_insn (gen_ashrsi3_power (operands[0], operands[1], operands[2]));
2830 else
2831 emit_insn (gen_ashrsi3_no_power (operands[0], operands[1], operands[2]));
2832 DONE;
2833 }")
2834
2835 (define_insn "ashrsi3_power"
2836 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2837 (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2838 (match_operand:SI 2 "reg_or_cint_operand" "r,i")))
2839 (clobber (match_scratch:SI 3 "=q,X"))]
2840 "TARGET_POWER"
2841 "@
2842 srea %0,%1,%2
2843 {srai|srawi} %0,%1,%h2")
2844
2845 (define_insn "ashrsi3_no_power"
2846 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2847 (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2848 (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
2849 "! TARGET_POWER"
2850 "{sra|sraw}%I2 %0,%1,%h2")
2851
2852 (define_insn ""
2853 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
2854 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2855 (match_operand:SI 2 "reg_or_cint_operand" "r,i"))
2856 (const_int 0)))
2857 (clobber (match_scratch:SI 3 "=r,r"))
2858 (clobber (match_scratch:SI 4 "=q,X"))]
2859 "TARGET_POWER"
2860 "@
2861 srea. %3,%1,%2
2862 {srai.|srawi.} %3,%1,%h2"
2863 [(set_attr "type" "delayed_compare")])
2864
2865 (define_insn ""
2866 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
2867 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2868 (match_operand:SI 2 "reg_or_cint_operand" "ri"))
2869 (const_int 0)))
2870 (clobber (match_scratch:SI 3 "=r"))]
2871 "! TARGET_POWER"
2872 "{sra|sraw}%I2. %3,%1,%h2"
2873 [(set_attr "type" "delayed_compare")])
2874
2875 (define_insn ""
2876 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x")
2877 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2878 (match_operand:SI 2 "reg_or_cint_operand" "r,i"))
2879 (const_int 0)))
2880 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2881 (ashiftrt:SI (match_dup 1) (match_dup 2)))
2882 (clobber (match_scratch:SI 4 "=q,X"))]
2883 "TARGET_POWER"
2884 "@
2885 srea. %0,%1,%2
2886 {srai.|srawi.} %0,%1,%h2"
2887 [(set_attr "type" "delayed_compare")])
2888
2889 (define_insn ""
2890 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
2891 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2892 (match_operand:SI 2 "reg_or_cint_operand" "ri"))
2893 (const_int 0)))
2894 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2895 (ashiftrt:SI (match_dup 1) (match_dup 2)))]
2896 "! TARGET_POWER"
2897 "{sra|sraw}%I2. %0,%1,%h2"
2898 [(set_attr "type" "delayed_compare")])
2899 \f
2900 ;; Floating-point insns, excluding normal data motion.
2901 ;;
2902 ;; PowerPC has a full set of single-precision floating point instructions.
2903 ;;
2904 ;; For the POWER architecture, we pretend that we have both SFmode and
2905 ;; DFmode insns, while, in fact, all fp insns are actually done in double.
2906 ;; The only conversions we will do will be when storing to memory. In that
2907 ;; case, we will use the "frsp" instruction before storing.
2908 ;;
2909 ;; Note that when we store into a single-precision memory location, we need to
2910 ;; use the frsp insn first. If the register being stored isn't dead, we
2911 ;; need a scratch register for the frsp. But this is difficult when the store
2912 ;; is done by reload. It is not incorrect to do the frsp on the register in
2913 ;; this case, we just lose precision that we would have otherwise gotten but
2914 ;; is not guaranteed. Perhaps this should be tightened up at some point.
2915
2916 (define_insn "extendsfdf2"
2917 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
2918 (float_extend:DF (match_operand:SF 1 "gpc_reg_operand" "f")))]
2919 "TARGET_HARD_FLOAT"
2920 "*
2921 {
2922 if (REGNO (operands[0]) == REGNO (operands[1]))
2923 return \"\";
2924 else
2925 return \"fmr %0,%1\";
2926 }"
2927 [(set_attr "type" "fp")])
2928
2929 (define_insn "truncdfsf2"
2930 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2931 (float_truncate:SF (match_operand:DF 1 "gpc_reg_operand" "f")))]
2932 "TARGET_HARD_FLOAT"
2933 "frsp %0,%1"
2934 [(set_attr "type" "fp")])
2935
2936 (define_insn "aux_truncdfsf2"
2937 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2938 (unspec:SF [(match_operand:SF 1 "gpc_reg_operand" "f")] 0))]
2939 "! TARGET_POWERPC && TARGET_HARD_FLOAT"
2940 "frsp %0,%1"
2941 [(set_attr "type" "fp")])
2942
2943 (define_insn "negsf2"
2944 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2945 (neg:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
2946 "TARGET_HARD_FLOAT"
2947 "fneg %0,%1"
2948 [(set_attr "type" "fp")])
2949
2950 (define_insn "abssf2"
2951 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2952 (abs:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
2953 "TARGET_HARD_FLOAT"
2954 "fabs %0,%1"
2955 [(set_attr "type" "fp")])
2956
2957 (define_insn ""
2958 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2959 (neg:SF (abs:SF (match_operand:SF 1 "gpc_reg_operand" "f"))))]
2960 "TARGET_HARD_FLOAT"
2961 "fnabs %0,%1"
2962 [(set_attr "type" "fp")])
2963
2964 (define_expand "addsf3"
2965 [(set (match_operand:SF 0 "gpc_reg_operand" "")
2966 (plus:SF (match_operand:SF 1 "gpc_reg_operand" "")
2967 (match_operand:SF 2 "gpc_reg_operand" "")))]
2968 "TARGET_HARD_FLOAT"
2969 "")
2970
2971 (define_insn ""
2972 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2973 (plus:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
2974 (match_operand:SF 2 "gpc_reg_operand" "f")))]
2975 "TARGET_POWERPC && TARGET_HARD_FLOAT"
2976 "fadds %0,%1,%2"
2977 [(set_attr "type" "fp")])
2978
2979 (define_insn ""
2980 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2981 (plus:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
2982 (match_operand:SF 2 "gpc_reg_operand" "f")))]
2983 "! TARGET_POWERPC && TARGET_HARD_FLOAT"
2984 "{fa|fadd} %0,%1,%2"
2985 [(set_attr "type" "fp")])
2986
2987 (define_expand "subsf3"
2988 [(set (match_operand:SF 0 "gpc_reg_operand" "")
2989 (minus:SF (match_operand:SF 1 "gpc_reg_operand" "")
2990 (match_operand:SF 2 "gpc_reg_operand" "")))]
2991 "TARGET_HARD_FLOAT"
2992 "")
2993
2994 (define_insn ""
2995 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2996 (minus:SF (match_operand:SF 1 "gpc_reg_operand" "f")
2997 (match_operand:SF 2 "gpc_reg_operand" "f")))]
2998 "TARGET_POWERPC && TARGET_HARD_FLOAT"
2999 "fsubs %0,%1,%2"
3000 [(set_attr "type" "fp")])
3001
3002 (define_insn ""
3003 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3004 (minus:SF (match_operand:SF 1 "gpc_reg_operand" "f")
3005 (match_operand:SF 2 "gpc_reg_operand" "f")))]
3006 "! TARGET_POWERPC && TARGET_HARD_FLOAT"
3007 "{fs|fsub} %0,%1,%2"
3008 [(set_attr "type" "fp")])
3009
3010 (define_expand "mulsf3"
3011 [(set (match_operand:SF 0 "gpc_reg_operand" "")
3012 (mult:SF (match_operand:SF 1 "gpc_reg_operand" "")
3013 (match_operand:SF 2 "gpc_reg_operand" "")))]
3014 "TARGET_HARD_FLOAT"
3015 "")
3016
3017 (define_insn ""
3018 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3019 (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
3020 (match_operand:SF 2 "gpc_reg_operand" "f")))]
3021 "TARGET_POWERPC && TARGET_HARD_FLOAT"
3022 "fmuls %0,%1,%2"
3023 [(set_attr "type" "fp")])
3024
3025 (define_insn ""
3026 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3027 (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
3028 (match_operand:SF 2 "gpc_reg_operand" "f")))]
3029 "! TARGET_POWERPC && TARGET_HARD_FLOAT"
3030 "{fm|fmul} %0,%1,%2"
3031 [(set_attr "type" "dmul")])
3032
3033 (define_expand "divsf3"
3034 [(set (match_operand:SF 0 "gpc_reg_operand" "")
3035 (div:SF (match_operand:SF 1 "gpc_reg_operand" "")
3036 (match_operand:SF 2 "gpc_reg_operand" "")))]
3037 "TARGET_HARD_FLOAT"
3038 "")
3039
3040 (define_insn ""
3041 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3042 (div:SF (match_operand:SF 1 "gpc_reg_operand" "f")
3043 (match_operand:SF 2 "gpc_reg_operand" "f")))]
3044 "TARGET_POWERPC && TARGET_HARD_FLOAT"
3045 "fdivs %0,%1,%2"
3046 [(set_attr "type" "sdiv")])
3047
3048 (define_insn ""
3049 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3050 (div:SF (match_operand:SF 1 "gpc_reg_operand" "f")
3051 (match_operand:SF 2 "gpc_reg_operand" "f")))]
3052 "! TARGET_POWERPC && TARGET_HARD_FLOAT"
3053 "{fd|fdiv} %0,%1,%2"
3054 [(set_attr "type" "ddiv")])
3055
3056 (define_insn ""
3057 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3058 (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
3059 (match_operand:SF 2 "gpc_reg_operand" "f"))
3060 (match_operand:SF 3 "gpc_reg_operand" "f")))]
3061 "TARGET_POWERPC && TARGET_HARD_FLOAT"
3062 "fmadds %0,%1,%2,%3"
3063 [(set_attr "type" "fp")])
3064
3065 (define_insn ""
3066 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3067 (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
3068 (match_operand:SF 2 "gpc_reg_operand" "f"))
3069 (match_operand:SF 3 "gpc_reg_operand" "f")))]
3070 "! TARGET_POWERPC && TARGET_HARD_FLOAT"
3071 "{fma|fmadd} %0,%1,%2,%3"
3072 [(set_attr "type" "dmul")])
3073
3074 (define_insn ""
3075 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3076 (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
3077 (match_operand:SF 2 "gpc_reg_operand" "f"))
3078 (match_operand:SF 3 "gpc_reg_operand" "f")))]
3079 "TARGET_POWERPC && TARGET_HARD_FLOAT"
3080 "fmsubs %0,%1,%2,%3"
3081 [(set_attr "type" "fp")])
3082
3083 (define_insn ""
3084 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3085 (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
3086 (match_operand:SF 2 "gpc_reg_operand" "f"))
3087 (match_operand:SF 3 "gpc_reg_operand" "f")))]
3088 "! TARGET_POWERPC && TARGET_HARD_FLOAT"
3089 "{fms|fmsub} %0,%1,%2,%3"
3090 [(set_attr "type" "dmul")])
3091
3092 (define_insn ""
3093 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3094 (neg:SF (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
3095 (match_operand:SF 2 "gpc_reg_operand" "f"))
3096 (match_operand:SF 3 "gpc_reg_operand" "f"))))]
3097 "TARGET_POWERPC && TARGET_HARD_FLOAT"
3098 "fnmadds %0,%1,%2,%3"
3099 [(set_attr "type" "fp")])
3100
3101 (define_insn ""
3102 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3103 (neg:SF (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
3104 (match_operand:SF 2 "gpc_reg_operand" "f"))
3105 (match_operand:SF 3 "gpc_reg_operand" "f"))))]
3106 "! TARGET_POWERPC && TARGET_HARD_FLOAT"
3107 "{fnma|fnmadd} %0,%1,%2,%3"
3108 [(set_attr "type" "dmul")])
3109
3110 (define_insn ""
3111 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3112 (neg:SF (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
3113 (match_operand:SF 2 "gpc_reg_operand" "f"))
3114 (match_operand:SF 3 "gpc_reg_operand" "f"))))]
3115 "TARGET_POWERPC && TARGET_HARD_FLOAT"
3116 "fnmsubs %0,%1,%2,%3"
3117 [(set_attr "type" "fp")])
3118
3119 (define_insn ""
3120 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3121 (neg:SF (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
3122 (match_operand:SF 2 "gpc_reg_operand" "f"))
3123 (match_operand:SF 3 "gpc_reg_operand" "f"))))]
3124 "! TARGET_POWERPC && TARGET_HARD_FLOAT"
3125 "{fnms|fnmsub} %0,%1,%2,%3"
3126 [(set_attr "type" "dmul")])
3127
3128 (define_expand "sqrtsf2"
3129 [(set (match_operand:SF 0 "gpc_reg_operand" "")
3130 (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "")))]
3131 "(TARGET_PPC_GPOPT || TARGET_POWER2) && TARGET_HARD_FLOAT"
3132 "")
3133
3134 (define_insn ""
3135 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3136 (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
3137 "TARGET_PPC_GPOPT && TARGET_HARD_FLOAT"
3138 "fsqrts %0,%1"
3139 [(set_attr "type" "ssqrt")])
3140
3141 (define_insn ""
3142 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3143 (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
3144 "TARGET_POWER2 && TARGET_HARD_FLOAT"
3145 "fsqrt %0,%1"
3146 [(set_attr "type" "dsqrt")])
3147
3148 ;; For MIN, MAX, and conditional move, we use DEFINE_EXPAND's that involve a
3149 ;; fsel instruction and some auxiliary computations. Then we just have a
3150 ;; single DEFINE_INSN for fsel and the define_splits to make them if made by
3151 ;; combine.
3152 (define_expand "maxsf3"
3153 [(set (match_dup 3)
3154 (minus:SF (match_operand:SF 1 "gpc_reg_operand" "")
3155 (match_operand:SF 2 "gpc_reg_operand" "")))
3156 (set (match_operand:SF 0 "gpc_reg_operand" "")
3157 (if_then_else:SF (ge (match_dup 3)
3158 (const_int 0))
3159 (match_dup 1)
3160 (match_dup 2)))]
3161 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3162 "
3163 { operands[3] = gen_reg_rtx (SFmode); }")
3164
3165 (define_split
3166 [(set (match_operand:SF 0 "gpc_reg_operand" "")
3167 (smax:SF (match_operand:SF 1 "gpc_reg_operand" "")
3168 (match_operand:SF 2 "gpc_reg_operand" "")))
3169 (clobber (match_operand:SF 3 "gpc_reg_operand" ""))]
3170 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3171 [(set (match_dup 3)
3172 (minus:SF (match_dup 1) (match_dup 2)))
3173 (set (match_dup 0)
3174 (if_then_else:SF (ge (match_dup 3)
3175 (const_int 0))
3176 (match_dup 1)
3177 (match_dup 2)))]
3178 "")
3179
3180 (define_expand "minsf3"
3181 [(set (match_dup 3)
3182 (minus:SF (match_operand:SF 2 "gpc_reg_operand" "")
3183 (match_operand:SF 1 "gpc_reg_operand" "")))
3184 (set (match_operand:SF 0 "gpc_reg_operand" "")
3185 (if_then_else:SF (ge (match_dup 3)
3186 (const_int 0))
3187 (match_dup 1)
3188 (match_dup 2)))]
3189 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3190 "
3191 { operands[3] = gen_reg_rtx (SFmode); }")
3192
3193 (define_split
3194 [(set (match_operand:SF 0 "gpc_reg_operand" "")
3195 (smin:SF (match_operand:SF 1 "gpc_reg_operand" "")
3196 (match_operand:SF 2 "gpc_reg_operand" "")))
3197 (clobber (match_operand:SF 3 "gpc_reg_operand" ""))]
3198 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3199 [(set (match_dup 3)
3200 (minus:SF (match_dup 2) (match_dup 1)))
3201 (set (match_dup 0)
3202 (if_then_else:SF (ge (match_dup 3)
3203 (const_int 0))
3204 (match_dup 1)
3205 (match_dup 2)))]
3206 "")
3207
3208 (define_expand "movsfcc"
3209 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3210 (if_then_else:SF (match_operand 1 "comparison_operator" "")
3211 (match_operand:SF 2 "gpc_reg_operand" "f")
3212 (match_operand:SF 3 "gpc_reg_operand" "f")))]
3213 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3214 "
3215 {
3216 rtx temp, op0, op1;
3217 enum rtx_code code = GET_CODE (operands[1]);
3218 if (! rs6000_compare_fp_p)
3219 FAIL;
3220 switch (code)
3221 {
3222 case GE: case EQ: case NE:
3223 op0 = rs6000_compare_op0;
3224 op1 = rs6000_compare_op1;
3225 break;
3226 case GT:
3227 op0 = rs6000_compare_op1;
3228 op1 = rs6000_compare_op0;
3229 temp = operands[2]; operands[2] = operands[3]; operands[3] = temp;
3230 break;
3231 case LE:
3232 op0 = rs6000_compare_op1;
3233 op1 = rs6000_compare_op0;
3234 break;
3235 case LT:
3236 op0 = rs6000_compare_op0;
3237 op1 = rs6000_compare_op1;
3238 temp = operands[2]; operands[2] = operands[3]; operands[3] = temp;
3239 break;
3240 default:
3241 FAIL;
3242 }
3243 if (GET_MODE (rs6000_compare_op0) == DFmode)
3244 {
3245 temp = gen_reg_rtx (DFmode);
3246 emit_insn (gen_subdf3 (temp, op0, op1));
3247 emit_insn (gen_fseldfsf4 (operands[0], temp, operands[2], operands[3]));
3248 if (code == EQ)
3249 {
3250 emit_insn (gen_negdf2 (temp, temp));
3251 emit_insn (gen_fseldfsf4 (operands[0], temp, operands[0], operands[3]));
3252 }
3253 if (code == NE)
3254 {
3255 emit_insn (gen_negdf2 (temp, temp));
3256 emit_insn (gen_fseldfsf4 (operands[0], temp, operands[3], operands[0]));
3257 }
3258 }
3259 else
3260 {
3261 temp = gen_reg_rtx (SFmode);
3262 emit_insn (gen_subsf3 (temp, op0, op1));
3263 emit_insn (gen_fselsfsf4 (operands[0], temp, operands[2], operands[3]));
3264 if (code == EQ)
3265 {
3266 emit_insn (gen_negsf2 (temp, temp));
3267 emit_insn (gen_fselsfsf4 (operands[0], temp, operands[0], operands[3]));
3268 }
3269 if (code == NE)
3270 {
3271 emit_insn (gen_negsf2 (temp, temp));
3272 emit_insn (gen_fselsfsf4 (operands[0], temp, operands[3], operands[0]));
3273 }
3274 }
3275 DONE;
3276 }")
3277
3278 (define_insn "fselsfsf4"
3279 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3280 (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "f")
3281 (const_int 0))
3282 (match_operand:SF 2 "gpc_reg_operand" "f")
3283 (match_operand:SF 3 "gpc_reg_operand" "f")))]
3284 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3285 "fsel %0,%1,%2,%3"
3286 [(set_attr "type" "fp")])
3287
3288 (define_insn "fseldfsf4"
3289 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3290 (if_then_else:SF (ge (match_operand:DF 1 "gpc_reg_operand" "f")
3291 (const_int 0))
3292 (match_operand:SF 2 "gpc_reg_operand" "f")
3293 (match_operand:SF 3 "gpc_reg_operand" "f")))]
3294 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3295 "fsel %0,%1,%2,%3"
3296 [(set_attr "type" "fp")])
3297
3298 (define_insn "negdf2"
3299 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3300 (neg:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
3301 "TARGET_HARD_FLOAT"
3302 "fneg %0,%1"
3303 [(set_attr "type" "fp")])
3304
3305 (define_insn "absdf2"
3306 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3307 (abs:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
3308 "TARGET_HARD_FLOAT"
3309 "fabs %0,%1"
3310 [(set_attr "type" "fp")])
3311
3312 (define_insn ""
3313 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3314 (neg:DF (abs:DF (match_operand:DF 1 "gpc_reg_operand" "f"))))]
3315 "TARGET_HARD_FLOAT"
3316 "fnabs %0,%1"
3317 [(set_attr "type" "fp")])
3318
3319 (define_insn "adddf3"
3320 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3321 (plus:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
3322 (match_operand:DF 2 "gpc_reg_operand" "f")))]
3323 "TARGET_HARD_FLOAT"
3324 "{fa|fadd} %0,%1,%2"
3325 [(set_attr "type" "fp")])
3326
3327 (define_insn "subdf3"
3328 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3329 (minus:DF (match_operand:DF 1 "gpc_reg_operand" "f")
3330 (match_operand:DF 2 "gpc_reg_operand" "f")))]
3331 "TARGET_HARD_FLOAT"
3332 "{fs|fsub} %0,%1,%2"
3333 [(set_attr "type" "fp")])
3334
3335 (define_insn "muldf3"
3336 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3337 (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
3338 (match_operand:DF 2 "gpc_reg_operand" "f")))]
3339 "TARGET_HARD_FLOAT"
3340 "{fm|fmul} %0,%1,%2"
3341 [(set_attr "type" "dmul")])
3342
3343 (define_insn "divdf3"
3344 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3345 (div:DF (match_operand:DF 1 "gpc_reg_operand" "f")
3346 (match_operand:DF 2 "gpc_reg_operand" "f")))]
3347 "TARGET_HARD_FLOAT"
3348 "{fd|fdiv} %0,%1,%2"
3349 [(set_attr "type" "ddiv")])
3350
3351 (define_insn ""
3352 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3353 (plus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
3354 (match_operand:DF 2 "gpc_reg_operand" "f"))
3355 (match_operand:DF 3 "gpc_reg_operand" "f")))]
3356 "TARGET_HARD_FLOAT"
3357 "{fma|fmadd} %0,%1,%2,%3"
3358 [(set_attr "type" "dmul")])
3359
3360 (define_insn ""
3361 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3362 (minus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
3363 (match_operand:DF 2 "gpc_reg_operand" "f"))
3364 (match_operand:DF 3 "gpc_reg_operand" "f")))]
3365 "TARGET_HARD_FLOAT"
3366 "{fms|fmsub} %0,%1,%2,%3"
3367 [(set_attr "type" "dmul")])
3368
3369 (define_insn ""
3370 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3371 (neg:DF (plus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
3372 (match_operand:DF 2 "gpc_reg_operand" "f"))
3373 (match_operand:DF 3 "gpc_reg_operand" "f"))))]
3374 "TARGET_HARD_FLOAT"
3375 "{fnma|fnmadd} %0,%1,%2,%3"
3376 [(set_attr "type" "dmul")])
3377
3378 (define_insn ""
3379 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3380 (neg:DF (minus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
3381 (match_operand:DF 2 "gpc_reg_operand" "f"))
3382 (match_operand:DF 3 "gpc_reg_operand" "f"))))]
3383 "TARGET_HARD_FLOAT"
3384 "{fnms|fnmsub} %0,%1,%2,%3"
3385 [(set_attr "type" "dmul")])
3386
3387 (define_insn "sqrtdf2"
3388 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3389 (sqrt:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
3390 "(TARGET_PPC_GPOPT || TARGET_POWER2) && TARGET_HARD_FLOAT"
3391 "fsqrt %0,%1"
3392 [(set_attr "type" "dsqrt")])
3393
3394 ;; For MIN, MAX, and conditional move, we use DEFINE_EXPAND's that involve a
3395 ;; fsel instruction and some auxiliary computations. Then we just have a
3396 ;; single DEFINE_INSN for fsel and the define_splits to make them if made by
3397 ;; combine.
3398
3399 (define_expand "maxdf3"
3400 [(set (match_dup 3)
3401 (minus:DF (match_operand:DF 1 "gpc_reg_operand" "")
3402 (match_operand:DF 2 "gpc_reg_operand" "")))
3403 (set (match_operand:DF 0 "gpc_reg_operand" "")
3404 (if_then_else:DF (ge (match_dup 3)
3405 (const_int 0))
3406 (match_dup 1)
3407 (match_dup 2)))]
3408 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3409 "
3410 { operands[3] = gen_reg_rtx (DFmode); }")
3411
3412 (define_split
3413 [(set (match_operand:DF 0 "gpc_reg_operand" "")
3414 (smax:DF (match_operand:DF 1 "gpc_reg_operand" "")
3415 (match_operand:DF 2 "gpc_reg_operand" "")))
3416 (clobber (match_operand:DF 3 "gpc_reg_operand" ""))]
3417 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3418 [(set (match_dup 3)
3419 (minus:DF (match_dup 1) (match_dup 2)))
3420 (set (match_dup 0)
3421 (if_then_else:DF (ge (match_dup 3)
3422 (const_int 0))
3423 (match_dup 1)
3424 (match_dup 2)))]
3425 "")
3426
3427 (define_expand "mindf3"
3428 [(set (match_dup 3)
3429 (minus:DF (match_operand:DF 2 "gpc_reg_operand" "")
3430 (match_operand:DF 1 "gpc_reg_operand" "")))
3431 (set (match_operand:DF 0 "gpc_reg_operand" "")
3432 (if_then_else:DF (ge (match_dup 3)
3433 (const_int 0))
3434 (match_dup 1)
3435 (match_dup 2)))]
3436 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3437 "
3438 { operands[3] = gen_reg_rtx (DFmode); }")
3439
3440 (define_split
3441 [(set (match_operand:DF 0 "gpc_reg_operand" "")
3442 (smin:DF (match_operand:DF 1 "gpc_reg_operand" "")
3443 (match_operand:DF 2 "gpc_reg_operand" "")))
3444 (clobber (match_operand:DF 3 "gpc_reg_operand" ""))]
3445 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3446 [(set (match_dup 3)
3447 (minus:DF (match_dup 2) (match_dup 1)))
3448 (set (match_dup 0)
3449 (if_then_else:DF (ge (match_dup 3)
3450 (const_int 0))
3451 (match_dup 1)
3452 (match_dup 2)))]
3453 "")
3454
3455 (define_expand "movdfcc"
3456 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3457 (if_then_else:DF (match_operand 1 "comparison_operator" "")
3458 (match_operand:DF 2 "gpc_reg_operand" "f")
3459 (match_operand:DF 3 "gpc_reg_operand" "f")))]
3460 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3461 "
3462 {
3463 rtx temp, op0, op1;
3464 enum rtx_code code = GET_CODE (operands[1]);
3465 if (! rs6000_compare_fp_p)
3466 FAIL;
3467 switch (code)
3468 {
3469 case GE: case EQ: case NE:
3470 op0 = rs6000_compare_op0;
3471 op1 = rs6000_compare_op1;
3472 break;
3473 case GT:
3474 op0 = rs6000_compare_op1;
3475 op1 = rs6000_compare_op0;
3476 temp = operands[2]; operands[2] = operands[3]; operands[3] = temp;
3477 break;
3478 case LE:
3479 op0 = rs6000_compare_op1;
3480 op1 = rs6000_compare_op0;
3481 break;
3482 case LT:
3483 op0 = rs6000_compare_op0;
3484 op1 = rs6000_compare_op1;
3485 temp = operands[2]; operands[2] = operands[3]; operands[3] = temp;
3486 break;
3487 default:
3488 FAIL;
3489 }
3490 if (GET_MODE (rs6000_compare_op0) == DFmode)
3491 {
3492 temp = gen_reg_rtx (DFmode);
3493 emit_insn (gen_subdf3 (temp, op0, op1));
3494 emit_insn (gen_fseldfdf4 (operands[0], temp, operands[2], operands[3]));
3495 if (code == EQ)
3496 {
3497 emit_insn (gen_negdf2 (temp, temp));
3498 emit_insn (gen_fseldfdf4 (operands[0], temp, operands[0], operands[3]));
3499 }
3500 if (code == NE)
3501 {
3502 emit_insn (gen_negdf2 (temp, temp));
3503 emit_insn (gen_fseldfdf4 (operands[0], temp, operands[3], operands[0]));
3504 }
3505 }
3506 else
3507 {
3508 temp = gen_reg_rtx (SFmode);
3509 emit_insn (gen_subsf3 (temp, op0, op1));
3510 emit_insn (gen_fselsfdf4 (operands[0], temp, operands[2], operands[3]));
3511 if (code == EQ)
3512 {
3513 emit_insn (gen_negsf2 (temp, temp));
3514 emit_insn (gen_fselsfdf4 (operands[0], temp, operands[0], operands[3]));
3515 }
3516 if (code == NE)
3517 {
3518 emit_insn (gen_negsf2 (temp, temp));
3519 emit_insn (gen_fselsfdf4 (operands[0], temp, operands[3], operands[0]));
3520 }
3521 }
3522 DONE;
3523 }")
3524
3525 (define_insn "fseldfdf4"
3526 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3527 (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "f")
3528 (const_int 0))
3529 (match_operand:DF 2 "gpc_reg_operand" "f")
3530 (match_operand:DF 3 "gpc_reg_operand" "f")))]
3531 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3532 "fsel %0,%1,%2,%3"
3533 [(set_attr "type" "fp")])
3534
3535 (define_insn "fselsfdf4"
3536 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3537 (if_then_else:DF (ge (match_operand:SF 1 "gpc_reg_operand" "f")
3538 (const_int 0))
3539 (match_operand:DF 2 "gpc_reg_operand" "f")
3540 (match_operand:DF 3 "gpc_reg_operand" "f")))]
3541 "TARGET_PPC_GFXOPT"
3542 "fsel %0,%1,%2,%3"
3543 [(set_attr "type" "fp")])
3544 \f
3545 ;; Conversions to and from floating-point.
3546
3547 (define_expand "floatsidf2"
3548 [(parallel [(set (match_operand:DF 0 "gpc_reg_operand" "")
3549 (float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
3550 (use (match_dup 2))
3551 (use (match_dup 3))
3552 (clobber (match_dup 4))
3553 (clobber (reg:DF 76))])]
3554 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT"
3555 "
3556 {
3557 operands[2] = force_reg (SImode, GEN_INT (0x43300000));
3558 operands[3] = force_reg (DFmode, rs6000_float_const (\"4503601774854144\", DFmode));
3559 operands[4] = gen_reg_rtx (SImode);
3560 }")
3561
3562 (define_insn "*floatsidf2_internal"
3563 [(set (match_operand:DF 0 "gpc_reg_operand" "=&f")
3564 (float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
3565 (use (match_operand:SI 2 "gpc_reg_operand" "r"))
3566 (use (match_operand:DF 3 "gpc_reg_operand" "f"))
3567 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
3568 (clobber (reg:DF 76))]
3569 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT"
3570 "#"
3571 [(set_attr "length" "20")])
3572
3573 (define_split
3574 [(set (match_operand:DF 0 "gpc_reg_operand" "")
3575 (float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
3576 (use (match_operand:SI 2 "gpc_reg_operand" ""))
3577 (use (match_operand:DF 3 "gpc_reg_operand" ""))
3578 (clobber (match_operand:SI 4 "gpc_reg_operand" ""))
3579 (clobber (reg:DF 76))]
3580 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT"
3581 [(set (match_dup 4)
3582 (xor:SI (match_dup 1)
3583 (match_dup 5)))
3584 (set (match_dup 6)
3585 (unspec [(match_dup 4) ;; low word
3586 (reg:SI 1)] 11))
3587 (set (match_dup 6)
3588 (unspec [(match_dup 2) ;; high word
3589 (reg:SI 1)
3590 (match_dup 6)] 12))
3591 (set (match_dup 0)
3592 (unspec [(match_dup 6)
3593 (reg:SI 1)] 13))
3594 (set (match_dup 0)
3595 (minus:DF (match_dup 0)
3596 (match_dup 3)))]
3597 "
3598 {
3599 operands[5] = GEN_INT (0x80000000);
3600 operands[6] = gen_rtx (REG, DFmode, FPMEM_REGNUM);
3601 }")
3602
3603 (define_expand "floatunssidf2"
3604 [(parallel [(set (match_operand:DF 0 "gpc_reg_operand" "")
3605 (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
3606 (use (match_dup 2))
3607 (use (match_dup 3))
3608 (clobber (reg:DF 76))])]
3609 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT"
3610 "
3611 {
3612 operands[2] = force_reg (SImode, GEN_INT (0x43300000));
3613 operands[3] = force_reg (DFmode, rs6000_float_const (\"4503599627370496\", DFmode));
3614 }")
3615
3616 (define_insn "*floatunssidf2_internal"
3617 [(set (match_operand:DF 0 "gpc_reg_operand" "=&f")
3618 (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
3619 (use (match_operand:SI 2 "gpc_reg_operand" "r"))
3620 (use (match_operand:DF 3 "gpc_reg_operand" "f"))
3621 (clobber (reg:DF 76))]
3622 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT"
3623 "#"
3624 [(set_attr "length" "16")])
3625
3626 (define_split
3627 [(set (match_operand:DF 0 "gpc_reg_operand" "")
3628 (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
3629 (use (match_operand:SI 2 "gpc_reg_operand" ""))
3630 (use (match_operand:DF 3 "gpc_reg_operand" ""))
3631 (clobber (reg:DF 76))]
3632 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT"
3633 [(set (match_dup 4)
3634 (unspec [(match_dup 1) ;; low word
3635 (reg:SI 1)] 11))
3636 (set (match_dup 4)
3637 (unspec [(match_dup 2) ;; high word
3638 (reg:SI 1)
3639 (reg:DF 76)] 12))
3640 (set (match_dup 0)
3641 (unspec [(match_dup 4)
3642 (reg:SI 1)] 13))
3643 (set (match_dup 0)
3644 (minus:DF (match_dup 0)
3645 (match_dup 3)))]
3646 "operands[4] = gen_rtx (REG, DFmode, FPMEM_REGNUM);")
3647
3648 ;; Note, we list r1 in the unspec, so that the optimizer is not tempted to optimize
3649 ;; around an alloca call (the memory address is constructed directly from r1).
3650
3651 (define_insn "*floatsidf2_store1"
3652 [(set (reg:DF 76)
3653 (unspec [(match_operand:SI 0 "gpc_reg_operand" "r")
3654 (reg:SI 1)] 11))]
3655 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT"
3656 "*
3657 {
3658 operands[1] = gen_rtx (MEM, SImode,
3659 gen_rtx (PLUS, Pmode,
3660 stack_pointer_rtx,
3661 GEN_INT (rs6000_fpmem_offset
3662 + ((WORDS_BIG_ENDIAN != 0) * 4))));
3663
3664 return \"{st|stw} %0,%1\";
3665 }"
3666 [(set_attr "type" "store")])
3667
3668 (define_insn "*floatsidf2_store2"
3669 [(set (reg:DF 76)
3670 (unspec [(match_operand:SI 0 "gpc_reg_operand" "r")
3671 (reg:SI 1)
3672 (reg:DF 76)] 12))]
3673 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT"
3674 "*
3675 {
3676 operands[1] = gen_rtx (MEM, SImode,
3677 gen_rtx (PLUS, Pmode,
3678 stack_pointer_rtx,
3679 GEN_INT (rs6000_fpmem_offset
3680 + ((WORDS_BIG_ENDIAN == 0) * 4))));
3681
3682 return \"{st|stw} %0,%1\";
3683 }"
3684 [(set_attr "type" "store")])
3685
3686 (define_insn "*floatsidf2_load"
3687 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3688 (unspec [(reg:DF 76)
3689 (reg:SI 1)] 13))]
3690 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT"
3691 "*
3692 {
3693 operands[1] = gen_rtx (MEM, SImode,
3694 gen_rtx (PLUS, Pmode,
3695 stack_pointer_rtx,
3696 GEN_INT (rs6000_fpmem_offset)));
3697
3698 return \"lfd %0,%1\";
3699 }"
3700 [(set_attr "type" "fpload")])
3701
3702 (define_expand "fix_truncdfsi2"
3703 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
3704 (fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))
3705 (clobber (match_dup 2))
3706 (clobber (match_dup 3))])]
3707 "TARGET_HARD_FLOAT"
3708 "
3709 {
3710 if (!TARGET_POWER2 && !TARGET_POWERPC)
3711 {
3712 emit_insn (gen_trunc_call (operands[0], operands[1],
3713 gen_rtx (SYMBOL_REF, Pmode, RS6000_ITRUNC)));
3714 DONE;
3715 }
3716
3717 operands[2] = gen_reg_rtx (DImode);
3718 operands[3] = gen_rtx (REG, DImode, FPMEM_REGNUM);
3719 }")
3720
3721 (define_insn "*fix_truncdfsi2_internal"
3722 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3723 (fix:SI (match_operand:DF 1 "gpc_reg_operand" "f")))
3724 (clobber (match_operand:DI 2 "gpc_reg_operand" "=f"))
3725 (clobber (reg:DI 76))]
3726 "TARGET_HARD_FLOAT"
3727 "#"
3728 [(set_attr "length" "12")])
3729
3730 (define_split
3731 [(set (match_operand:SI 0 "gpc_reg_operand" "")
3732 (fix:SI (match_operand:DF 1 "gpc_reg_operand" "f")))
3733 (clobber (match_operand:DI 2 "gpc_reg_operand" ""))
3734 (clobber (reg:DI 76))]
3735 "TARGET_HARD_FLOAT"
3736 [(set (match_dup 2)
3737 (sign_extend:DI (fix:SI (match_operand:DF 1 "gpc_reg_operand" ""))))
3738 (set (match_dup 3)
3739 (unspec [(match_dup 2)
3740 (reg:SI 1)] 14))
3741 (set (match_operand:SI 0 "gpc_reg_operand" "")
3742 (unspec [(match_dup 3)
3743 (reg:SI 1)] 15))]
3744 "operands[3] = gen_rtx (REG, DImode, FPMEM_REGNUM);")
3745
3746 (define_insn "*fctiwz"
3747 [(set (match_operand:DI 0 "gpc_reg_operand" "=f")
3748 (sign_extend:DI (fix:SI (match_operand:DF 1 "gpc_reg_operand" "f"))))]
3749 "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT"
3750 "{fcirz|fctiwz} %0,%1"
3751 [(set_attr "type" "fp")])
3752
3753 (define_insn "*fix_truncdfsi2_store"
3754 [(set (reg:DI 76)
3755 (unspec [(match_operand:DI 0 "gpc_reg_operand" "f")
3756 (reg:SI 1)] 14))]
3757 "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT"
3758 "*
3759 {
3760 operands[1] = gen_rtx (MEM, DFmode,
3761 gen_rtx (PLUS, Pmode,
3762 stack_pointer_rtx,
3763 GEN_INT (rs6000_fpmem_offset)));
3764
3765 return \"stfd %0,%1\";
3766 }"
3767 [(set_attr "type" "fpstore")])
3768
3769 (define_insn "*fix_truncdfsi2_load"
3770 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3771 (unspec [(reg:DI 76)
3772 (reg:SI 1)] 15))]
3773 "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT"
3774 "*
3775 {
3776 operands[1] = gen_rtx (MEM, DFmode,
3777 gen_rtx (PLUS, Pmode,
3778 stack_pointer_rtx,
3779 GEN_INT (rs6000_fpmem_offset + ((WORDS_BIG_ENDIAN) ? 4 : 0))));
3780
3781 return \"{l|lwz} %0,%1\";
3782 }"
3783 [(set_attr "type" "load")])
3784
3785 (define_expand "fixuns_truncdfsi2"
3786 [(set (match_operand:SI 0 "gpc_reg_operand" "")
3787 (unsigned_fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))]
3788 "! TARGET_POWER2 && ! TARGET_POWERPC && TARGET_HARD_FLOAT"
3789 "
3790 {
3791 emit_insn (gen_trunc_call (operands[0], operands[1],
3792 gen_rtx (SYMBOL_REF, Pmode, RS6000_UITRUNC)));
3793 DONE;
3794 }")
3795
3796 (define_expand "trunc_call"
3797 [(parallel [(set (match_operand:SI 0 "" "")
3798 (fix:SI (match_operand:DF 1 "" "")))
3799 (use (match_operand:SI 2 "" ""))])]
3800 "TARGET_HARD_FLOAT"
3801 "
3802 {
3803 rtx insns = gen_trunc_call_rtl (operands[0], operands[1], operands[2]);
3804 rtx first = XVECEXP (insns, 0, 0);
3805 rtx last = XVECEXP (insns, 0, XVECLEN (insns, 0) - 1);
3806
3807 REG_NOTES (first) = gen_rtx (INSN_LIST, REG_LIBCALL, last,
3808 REG_NOTES (first));
3809 REG_NOTES (last) = gen_rtx (INSN_LIST, REG_RETVAL, first, REG_NOTES (last));
3810
3811 emit_insn (insns);
3812 DONE;
3813 }")
3814
3815 (define_expand "trunc_call_rtl"
3816 [(set (reg:DF 33) (match_operand:DF 1 "gpc_reg_operand" ""))
3817 (use (reg:DF 33))
3818 (parallel [(set (reg:SI 3)
3819 (call (mem:SI (match_operand 2 "" "")) (const_int 0)))
3820 (use (const_int 0))
3821 (clobber (scratch:SI))])
3822 (set (match_operand:SI 0 "gpc_reg_operand" "")
3823 (reg:SI 3))]
3824 "TARGET_HARD_FLOAT"
3825 "
3826 {
3827 rs6000_trunc_used = 1;
3828 }")
3829
3830 (define_insn "floatdidf2"
3831 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3832 (float:DF (match_operand:DI 1 "gpc_reg_operand" "f")))]
3833 "TARGET_POWERPC64 && TARGET_HARD_FLOAT"
3834 "fcfid %0,%1"
3835 [(set_attr "type" "fp")])
3836
3837 (define_insn "fix_truncdfdi2"
3838 [(set (match_operand:DI 0 "gpc_reg_operand" "=f")
3839 (fix:DI (match_operand:DF 1 "gpc_reg_operand" "f")))]
3840 "TARGET_POWERPC64 && TARGET_HARD_FLOAT"
3841 "fctidz %0,%1"
3842 [(set_attr "type" "fp")])
3843 \f
3844 ;; Define the DImode operations that can be done in a small number
3845 ;; of instructions. The & constraints are to prevent the register
3846 ;; allocator from allocating registers that overlap with the inputs
3847 ;; (for example, having an input in 7,8 and an output in 6,7). We
3848 ;; also allow for the the output being the same as one of the inputs.
3849
3850 (define_insn "*adddi3_noppc64"
3851 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,r,r")
3852 (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,0,0")
3853 (match_operand:DI 2 "reg_or_short_operand" "r,I,r,I")))]
3854 "! TARGET_POWERPC64"
3855 "*
3856 {
3857 if (WORDS_BIG_ENDIAN)
3858 return (GET_CODE (operands[2])) != CONST_INT
3859 ? \"{a|addc} %L0,%L1,%L2\;{ae|adde} %0,%1,%2\"
3860 : \"{ai|addic} %L0,%L1,%2\;{a%G2e|add%G2e} %0,%1\";
3861 else
3862 return (GET_CODE (operands[2])) != CONST_INT
3863 ? \"{a|addc} %0,%1,%2\;{ae|adde} %L0,%L1,%L2\"
3864 : \"{ai|addic} %0,%1,%2\;{a%G2e|add%G2e} %L0,%L1\";
3865 }"
3866 [(set_attr "length" "8")])
3867
3868 (define_insn "*subdi3_noppc64"
3869 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,r,r,r")
3870 (minus:DI (match_operand:DI 1 "reg_or_short_operand" "r,I,0,r,I")
3871 (match_operand:DI 2 "gpc_reg_operand" "r,r,r,0,0")))]
3872 "! TARGET_POWERPC64"
3873 "*
3874 {
3875 if (WORDS_BIG_ENDIAN)
3876 return (GET_CODE (operands[1]) != CONST_INT)
3877 ? \"{sf|subfc} %L0,%L2,%L1\;{sfe|subfe} %0,%2,%1\"
3878 : \"{sfi|subfic} %L0,%L2,%1\;{sf%G1e|subf%G1e} %0,%2\";
3879 else
3880 return (GET_CODE (operands[1]) != CONST_INT)
3881 ? \"{sf|subfc} %0,%2,%1\;{sfe|subfe} %L0,%L2,%L1\"
3882 : \"{sfi|subfic} %0,%2,%1\;{sf%G1e|subf%G1e} %L0,%L2\";
3883 }"
3884 [(set_attr "length" "8")])
3885
3886 (define_insn "*negdi2_noppc64"
3887 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
3888 (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r,0")))]
3889 "! TARGET_POWERPC64"
3890 "*
3891 {
3892 return (WORDS_BIG_ENDIAN)
3893 ? \"{sfi|subfic} %L0,%L1,0\;{sfze|subfze} %0,%1\"
3894 : \"{sfi|subfic} %0,%1,0\;{sfze|subfze} %L0,%L1\";
3895 }"
3896 [(set_attr "length" "8")])
3897
3898 (define_expand "mulsidi3"
3899 [(set (match_operand:DI 0 "gpc_reg_operand" "")
3900 (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
3901 (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
3902 ""
3903 "
3904 {
3905 if (! TARGET_POWER && ! TARGET_POWERPC)
3906 {
3907 emit_move_insn (gen_rtx (REG, SImode, 3), operands[1]);
3908 emit_move_insn (gen_rtx (REG, SImode, 4), operands[2]);
3909 emit_insn (gen_mull_call ());
3910 if (WORDS_BIG_ENDIAN)
3911 emit_move_insn (operands[0], gen_rtx (REG, DImode, 3));
3912 else
3913 {
3914 emit_move_insn (operand_subword (operands[0], 0, 0, DImode),
3915 gen_rtx (REG, SImode, 3));
3916 emit_move_insn (operand_subword (operands[0], 1, 0, DImode),
3917 gen_rtx (REG, SImode, 4));
3918 }
3919 DONE;
3920 }
3921 else if (TARGET_POWER)
3922 {
3923 emit_insn (gen_mulsidi3_mq (operands[0], operands[1], operands[2]));
3924 DONE;
3925 }
3926 }")
3927
3928 (define_insn "mulsidi3_mq"
3929 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
3930 (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
3931 (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))
3932 (clobber (match_scratch:SI 3 "=q"))]
3933 "TARGET_POWER"
3934 "mul %0,%1,%2\;mfmq %L0"
3935 [(set_attr "type" "imul")
3936 (set_attr "length" "8")])
3937
3938 (define_insn "*mulsidi3_powerpc"
3939 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
3940 (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
3941 (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
3942 "TARGET_POWERPC && ! TARGET_POWERPC64"
3943 "*
3944 {
3945 return (WORDS_BIG_ENDIAN)
3946 ? \"mulhw %0,%1,%2\;mullw %L0,%1,%2\"
3947 : \"mulhw %L0,%1,%2\;mullw %0,%1,%2\";
3948 }"
3949 [(set_attr "type" "imul")
3950 (set_attr "length" "8")])
3951
3952 (define_split
3953 [(set (match_operand:DI 0 "gpc_reg_operand" "")
3954 (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
3955 (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
3956 "TARGET_POWERPC && ! TARGET_POWERPC64 && reload_completed"
3957 [(set (match_dup 3)
3958 (truncate:SI
3959 (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
3960 (sign_extend:DI (match_dup 2)))
3961 (const_int 32))))
3962 (set (match_dup 4)
3963 (mult:SI (match_dup 1)
3964 (match_dup 2)))]
3965 "
3966 {
3967 int endian = (WORDS_BIG_ENDIAN == 0);
3968 operands[3] = operand_subword (operands[0], endian, 0, DImode);
3969 operands[4] = operand_subword (operands[0], 1 - endian, 0, DImode);
3970 }")
3971
3972 (define_insn "umulsidi3"
3973 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
3974 (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
3975 (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
3976 "TARGET_POWERPC && ! TARGET_POWERPC64"
3977 "*
3978 {
3979 return (WORDS_BIG_ENDIAN)
3980 ? \"mulhwu %0,%1,%2\;mullw %L0,%1,%2\"
3981 : \"mulhwu %L0,%1,%2\;mullw %0,%1,%2\";
3982 }"
3983 [(set_attr "type" "imul")
3984 (set_attr "length" "8")])
3985
3986 (define_split
3987 [(set (match_operand:DI 0 "gpc_reg_operand" "")
3988 (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
3989 (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
3990 "TARGET_POWERPC && ! TARGET_POWERPC64 && reload_completed"
3991 [(set (match_dup 3)
3992 (truncate:SI
3993 (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
3994 (zero_extend:DI (match_dup 2)))
3995 (const_int 32))))
3996 (set (match_dup 4)
3997 (mult:SI (match_dup 1)
3998 (match_dup 2)))]
3999 "
4000 {
4001 int endian = (WORDS_BIG_ENDIAN == 0);
4002 operands[3] = operand_subword (operands[0], endian, 0, DImode);
4003 operands[4] = operand_subword (operands[0], 1 - endian, 0, DImode);
4004 }")
4005
4006 (define_expand "smulsi3_highpart"
4007 [(set (match_operand:SI 0 "gpc_reg_operand" "")
4008 (truncate:SI
4009 (lshiftrt:DI (mult:DI (sign_extend:DI
4010 (match_operand:SI 1 "gpc_reg_operand" "%r"))
4011 (sign_extend:DI
4012 (match_operand:SI 2 "gpc_reg_operand" "r")))
4013 (const_int 32))))]
4014 ""
4015 "
4016 {
4017 if (! TARGET_POWER && ! TARGET_POWERPC)
4018 {
4019 emit_move_insn (gen_rtx (REG, SImode, 3), operands[1]);
4020 emit_move_insn (gen_rtx (REG, SImode, 4), operands[2]);
4021 emit_insn (gen_mulh_call ());
4022 emit_move_insn (operands[0], gen_rtx (REG, SImode, 3));
4023 DONE;
4024 }
4025 else if (TARGET_POWER)
4026 {
4027 emit_insn (gen_smulsi3_highpart_mq (operands[0], operands[1], operands[2]));
4028 DONE;
4029 }
4030 }")
4031
4032 (define_insn "smulsi3_highpart_mq"
4033 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4034 (truncate:SI
4035 (lshiftrt:DI (mult:DI (sign_extend:DI
4036 (match_operand:SI 1 "gpc_reg_operand" "%r"))
4037 (sign_extend:DI
4038 (match_operand:SI 2 "gpc_reg_operand" "r")))
4039 (const_int 32))))
4040 (clobber (match_scratch:SI 3 "=q"))]
4041 "TARGET_POWER"
4042 "mul %0,%1,%2"
4043 [(set_attr "type" "imul")])
4044
4045 (define_insn ""
4046 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4047 (truncate:SI
4048 (lshiftrt:DI (mult:DI (sign_extend:DI
4049 (match_operand:SI 1 "gpc_reg_operand" "%r"))
4050 (sign_extend:DI
4051 (match_operand:SI 2 "gpc_reg_operand" "r")))
4052 (const_int 32))))]
4053 "TARGET_POWERPC"
4054 "mulhw %0,%1,%2"
4055 [(set_attr "type" "imul")])
4056
4057 (define_insn "umulsi3_highpart"
4058 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4059 (truncate:SI
4060 (lshiftrt:DI (mult:DI (zero_extend:DI
4061 (match_operand:SI 1 "gpc_reg_operand" "%r"))
4062 (zero_extend:DI
4063 (match_operand:SI 2 "gpc_reg_operand" "r")))
4064 (const_int 32))))]
4065 "TARGET_POWERPC"
4066 "mulhwu %0,%1,%2"
4067 [(set_attr "type" "imul")])
4068
4069 ;; If operands 0 and 2 are in the same register, we have a problem. But
4070 ;; operands 0 and 1 (the usual case) can be in the same register. That's
4071 ;; why we have the strange constraints below.
4072 (define_insn "ashldi3_power"
4073 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,&r")
4074 (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,0,r")
4075 (match_operand:SI 2 "reg_or_cint_operand" "M,i,r,r")))
4076 (clobber (match_scratch:SI 3 "=X,q,q,q"))]
4077 "TARGET_POWER"
4078 "@
4079 {sli|slwi} %0,%L1,%h2\;{cal %L0,0(0)|li %L0,0}
4080 sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2
4081 sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2
4082 sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2"
4083 [(set_attr "length" "8")])
4084
4085 (define_insn "lshrdi3_power"
4086 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r,r,&r")
4087 (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,0,r")
4088 (match_operand:SI 2 "reg_or_cint_operand" "M,i,r,r")))
4089 (clobber (match_scratch:SI 3 "=X,q,q,q"))]
4090 "TARGET_POWER"
4091 "@
4092 {cal %0,0(0)|li %0,0}\;{s%A2i|s%A2wi} %L0,%1,%h2
4093 sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2
4094 sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2
4095 sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2"
4096 [(set_attr "length" "8")])
4097
4098 ;; Shift by a variable amount is too complex to be worth open-coding. We
4099 ;; just handle shifts by constants.
4100 (define_insn "ashrdi3_power"
4101 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
4102 (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
4103 (match_operand:SI 2 "const_int_operand" "M,i")))
4104 (clobber (match_scratch:SI 3 "=X,q"))]
4105 "TARGET_POWER"
4106 "@
4107 {srai|srawi} %0,%1,31\;{srai|srawi} %L0,%1,%h2
4108 sraiq %0,%1,%h2\;srliq %L0,%L1,%h2"
4109 [(set_attr "length" "8")])
4110 \f
4111 ;; PowerPC64 DImode operations.
4112
4113 (define_expand "adddi3"
4114 [(set (match_operand:DI 0 "gpc_reg_operand" "")
4115 (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
4116 (match_operand:DI 2 "add_operand" "")))]
4117 ""
4118 "
4119 {
4120 if (! TARGET_POWERPC64 && non_add_cint_operand (operands[2], DImode))
4121 FAIL;
4122 }")
4123
4124 ;; Discourage ai/addic because of carry but provide it in an alternative
4125 ;; allowing register zero as source.
4126
4127 (define_insn ""
4128 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,?r,r")
4129 (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,b,r,b")
4130 (match_operand:DI 2 "add_operand" "r,I,I,J")))]
4131 "TARGET_POWERPC64"
4132 "@
4133 add %0,%1,%2
4134 addi %0,%1,%2
4135 addic %0,%1,%2
4136 addis %0,%1,%v2")
4137
4138 (define_insn ""
4139 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
4140 (compare:CC (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r")
4141 (match_operand:DI 2 "reg_or_short_operand" "r,I"))
4142 (const_int 0)))
4143 (clobber (match_scratch:DI 3 "=r,r"))]
4144 "TARGET_POWERPC64"
4145 "@
4146 add. %3,%1,%2
4147 addic. %3,%1,%2"
4148 [(set_attr "type" "compare")])
4149
4150 (define_insn ""
4151 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x")
4152 (compare:CC (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r")
4153 (match_operand:DI 2 "reg_or_short_operand" "r,I"))
4154 (const_int 0)))
4155 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
4156 (plus:DI (match_dup 1) (match_dup 2)))]
4157 "TARGET_POWERPC64"
4158 "@
4159 add. %0,%1,%2
4160 addic. %0,%1,%2"
4161 [(set_attr "type" "compare")])
4162
4163 ;; Split an add that we can't do in one insn into two insns, each of which
4164 ;; does one 16-bit part. This is used by combine. Note that the low-order
4165 ;; add should be last in case the result gets used in an address.
4166
4167 (define_split
4168 [(set (match_operand:DI 0 "gpc_reg_operand" "")
4169 (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
4170 (match_operand:DI 2 "non_add_cint_operand" "")))]
4171 "TARGET_POWERPC64"
4172 [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 3)))
4173 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 4)))]
4174 "
4175 {
4176 HOST_WIDE_INT low = INTVAL (operands[2]) & 0xffff;
4177 HOST_WIDE_INT high = INTVAL (operands[2]) & (~ (HOST_WIDE_INT) 0xffff);
4178
4179 if (low & 0x8000)
4180 high+=0x10000, low |= ((HOST_WIDE_INT) -1) << 16;
4181
4182 operands[3] = GEN_INT (high);
4183 operands[4] = GEN_INT (low);
4184 }")
4185
4186 (define_insn "one_cmpldi2"
4187 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4188 (not:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
4189 "TARGET_POWERPC64"
4190 "nor %0,%1,%1")
4191
4192 (define_insn ""
4193 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4194 (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
4195 (const_int 0)))
4196 (clobber (match_scratch:DI 2 "=r"))]
4197 "TARGET_POWERPC64"
4198 "nor. %2,%1,%1"
4199 [(set_attr "type" "compare")])
4200
4201 (define_insn ""
4202 [(set (match_operand:CC 2 "cc_reg_operand" "=x")
4203 (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
4204 (const_int 0)))
4205 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4206 (not:DI (match_dup 1)))]
4207 "TARGET_POWERPC64"
4208 "nor. %0,%1,%1"
4209 [(set_attr "type" "compare")])
4210
4211 (define_insn ""
4212 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
4213 (minus:DI (match_operand:DI 1 "reg_or_short_operand" "r,I")
4214 (match_operand:DI 2 "gpc_reg_operand" "r,r")))]
4215 "TARGET_POWERPC64"
4216 "@
4217 subf %0,%2,%1
4218 subfic %0,%2,%1")
4219
4220 (define_insn ""
4221 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4222 (compare:CC (minus:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4223 (match_operand:DI 2 "gpc_reg_operand" "r"))
4224 (const_int 0)))
4225 (clobber (match_scratch:DI 3 "=r"))]
4226 "TARGET_POWERPC64"
4227 "subf. %3,%2,%1"
4228 [(set_attr "type" "compare")])
4229
4230 (define_insn ""
4231 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4232 (compare:CC (minus:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4233 (match_operand:DI 2 "gpc_reg_operand" "r"))
4234 (const_int 0)))
4235 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4236 (minus:DI (match_dup 1) (match_dup 2)))]
4237 "TARGET_POWERPC64"
4238 "subf. %0,%2,%1"
4239 [(set_attr "type" "compare")])
4240
4241 (define_expand "subdi3"
4242 [(set (match_operand:DI 0 "gpc_reg_operand" "")
4243 (minus:DI (match_operand:DI 1 "reg_or_short_operand" "")
4244 (match_operand:DI 2 "reg_or_cint_operand" "")))]
4245 ""
4246 "
4247 {
4248 if (GET_CODE (operands[2]) == CONST_INT)
4249 {
4250 emit_insn (gen_adddi3 (operands[0], operands[1],
4251 negate_rtx (DImode, operands[2])));
4252 DONE;
4253 }
4254 }")
4255
4256 (define_insn "absdi2"
4257 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
4258 (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,0")))
4259 (clobber (match_scratch:DI 2 "=&r,&r"))]
4260 "TARGET_POWERPC64"
4261 "sradi %2,%1,31\;xor %0,%2,%1\;subf %0,%2,%0"
4262 [(set_attr "length" "12")])
4263
4264 (define_split
4265 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
4266 (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,0")))
4267 (clobber (match_scratch:DI 2 "=&r,&r"))]
4268 "TARGET_POWERPC64 && reload_completed"
4269 [(set (match_dup 2) (ashiftrt:DI (match_dup 1) (const_int 31)))
4270 (set (match_dup 0) (xor:DI (match_dup 2) (match_dup 1)))
4271 (set (match_dup 0) (minus:DI (match_dup 2) (match_dup 0)))]
4272 "")
4273
4274 (define_insn ""
4275 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
4276 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,0"))))
4277 (clobber (match_scratch:DI 2 "=&r,&r"))]
4278 "TARGET_POWERPC64"
4279 "sradi %2,%1,31\;xor %0,%2,%1\;subf %0,%0,%2"
4280 [(set_attr "length" "12")])
4281
4282 (define_split
4283 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
4284 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,0"))))
4285 (clobber (match_scratch:DI 2 "=&r,&r"))]
4286 "TARGET_POWERPC64 && reload_completed"
4287 [(set (match_dup 2) (ashiftrt:DI (match_dup 1) (const_int 31)))
4288 (set (match_dup 0) (xor:DI (match_dup 2) (match_dup 1)))
4289 (set (match_dup 0) (minus:DI (match_dup 0) (match_dup 2)))]
4290 "")
4291
4292 (define_expand "negdi2"
4293 [(set (match_operand:DI 0 "gpc_reg_operand" "")
4294 (neg:DI (match_operand:DI 1 "gpc_reg_operand" "")))]
4295 ""
4296 "")
4297
4298 (define_insn ""
4299 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4300 (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
4301 "TARGET_POWERPC64"
4302 "neg %0,%1")
4303
4304 (define_insn ""
4305 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4306 (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
4307 (const_int 0)))
4308 (clobber (match_scratch:DI 2 "=r"))]
4309 "TARGET_POWERPC64"
4310 "neg. %2,%1"
4311 [(set_attr "type" "compare")])
4312
4313 (define_insn ""
4314 [(set (match_operand:CC 2 "cc_reg_operand" "=x")
4315 (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
4316 (const_int 0)))
4317 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4318 (neg:DI (match_dup 1)))]
4319 "TARGET_POWERPC64"
4320 "neg. %0,%1"
4321 [(set_attr "type" "compare")])
4322
4323 (define_insn "ffsdi2"
4324 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
4325 (ffs:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
4326 "TARGET_POWERPC64"
4327 "neg %0,%1\;and %0,%0,%1\;cntlzd %0,%0\;subfic %0,%0,64"
4328 [(set_attr "length" "16")])
4329
4330 (define_insn "muldi3"
4331 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4332 (mult:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
4333 (match_operand:DI 2 "gpc_reg_operand" "r")))]
4334 "TARGET_POWERPC64"
4335 "mulld %0,%1,%2"
4336 [(set_attr "type" "imul")])
4337
4338 (define_insn "smuldi3_highpart"
4339 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4340 (truncate:DI
4341 (lshiftrt:TI (mult:TI (sign_extend:TI
4342 (match_operand:DI 1 "gpc_reg_operand" "%r"))
4343 (sign_extend:TI
4344 (match_operand:DI 2 "gpc_reg_operand" "r")))
4345 (const_int 64))))]
4346 "TARGET_POWERPC64"
4347 "mulhd %0,%1,%2"
4348 [(set_attr "type" "imul")])
4349
4350 (define_insn "umuldi3_highpart"
4351 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4352 (truncate:DI
4353 (lshiftrt:TI (mult:TI (zero_extend:TI
4354 (match_operand:DI 1 "gpc_reg_operand" "%r"))
4355 (zero_extend:TI
4356 (match_operand:DI 2 "gpc_reg_operand" "r")))
4357 (const_int 64))))]
4358 "TARGET_POWERPC64"
4359 "mulhdu %0,%1,%2"
4360 [(set_attr "type" "imul")])
4361
4362 (define_expand "divdi3"
4363 [(set (match_operand:DI 0 "gpc_reg_operand" "")
4364 (div:DI (match_operand:DI 1 "gpc_reg_operand" "")
4365 (match_operand:DI 2 "reg_or_cint_operand" "")))]
4366 "TARGET_POWERPC64"
4367 "
4368 {
4369 if (GET_CODE (operands[2]) == CONST_INT
4370 && exact_log2 (INTVAL (operands[2])) >= 0)
4371 ;
4372 else
4373 operands[2] = force_reg (DImode, operands[2]);
4374 }")
4375
4376 (define_expand "moddi3"
4377 [(use (match_operand:DI 0 "gpc_reg_operand" ""))
4378 (use (match_operand:DI 1 "gpc_reg_operand" ""))
4379 (use (match_operand:DI 2 "reg_or_cint_operand" ""))]
4380 "TARGET_POWERPC64"
4381 "
4382 {
4383 int i = exact_log2 (INTVAL (operands[2]));
4384 rtx temp1;
4385 rtx temp2;
4386
4387 if (GET_CODE (operands[2]) != CONST_INT || i < 0)
4388 FAIL;
4389
4390 temp1 = gen_reg_rtx (DImode);
4391 temp2 = gen_reg_rtx (DImode);
4392
4393 emit_insn (gen_divdi3 (temp1, operands[1], operands[2]));
4394 emit_insn (gen_ashldi3 (temp2, temp1, GEN_INT (i)));
4395 emit_insn (gen_subdi3 (operands[0], operands[1], temp2));
4396 DONE;
4397 }")
4398
4399 (define_insn ""
4400 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4401 (div:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4402 (match_operand:DI 2 "const_int_operand" "N")))]
4403 "TARGET_POWERPC64 && exact_log2 (INTVAL (operands[2])) >= 0"
4404 "sradi %0,%1,%p2\;addze %0,%0"
4405 [(set_attr "length" "8")])
4406
4407 (define_insn ""
4408 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4409 (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4410 (match_operand:DI 2 "const_int_operand" "N"))
4411 (const_int 0)))
4412 (clobber (match_scratch:DI 3 "=r"))]
4413 "TARGET_POWERPC64 && exact_log2 (INTVAL (operands[2])) >= 0"
4414 "sradi %3,%1,%p2\;addze. %3,%3"
4415 [(set_attr "type" "compare")
4416 (set_attr "length" "8")])
4417
4418 (define_insn ""
4419 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4420 (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4421 (match_operand:DI 2 "const_int_operand" "N"))
4422 (const_int 0)))
4423 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4424 (div:DI (match_dup 1) (match_dup 2)))]
4425 "TARGET_POWERPC64 && exact_log2 (INTVAL (operands[2])) >= 0"
4426 "sradi %0,%1,%p2\;addze. %0,%0"
4427 [(set_attr "type" "compare")
4428 (set_attr "length" "8")])
4429
4430 (define_insn ""
4431 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4432 (div:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4433 (match_operand:DI 2 "gpc_reg_operand" "r")))]
4434 "TARGET_POWERPC64"
4435 "divd %0,%1,%2"
4436 [(set_attr "type" "idiv")])
4437
4438 (define_insn "udivdi3"
4439 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4440 (udiv:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4441 (match_operand:DI 2 "gpc_reg_operand" "r")))]
4442 "TARGET_POWERPC64"
4443 "divdu %0,%1,%2"
4444 [(set_attr "type" "idiv")])
4445
4446 (define_insn "rotldi3"
4447 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4448 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4449 (match_operand:DI 2 "reg_or_cint_operand" "ri")))]
4450 "TARGET_POWERPC64"
4451 "rld%I2cl %0,%1,%H2,0")
4452
4453 (define_insn ""
4454 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4455 (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4456 (match_operand:DI 2 "reg_or_cint_operand" "ri"))
4457 (const_int 0)))
4458 (clobber (match_scratch:DI 3 "=r"))]
4459 "TARGET_POWERPC64"
4460 "rld%I2cl. %3,%1,%H2,0"
4461 [(set_attr "type" "delayed_compare")])
4462
4463 (define_insn ""
4464 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4465 (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4466 (match_operand:DI 2 "reg_or_cint_operand" "ri"))
4467 (const_int 0)))
4468 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4469 (rotate:DI (match_dup 1) (match_dup 2)))]
4470 "TARGET_POWERPC64"
4471 "rld%I2cl. %0,%1,%H2,0"
4472 [(set_attr "type" "delayed_compare")])
4473
4474 (define_expand "ashldi3"
4475 [(set (match_operand:DI 0 "gpc_reg_operand" "")
4476 (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
4477 (match_operand:SI 2 "reg_or_cint_operand" "")))]
4478 "TARGET_POWERPC64 || TARGET_POWER"
4479 "
4480 {
4481 if (TARGET_POWERPC64)
4482 ;
4483 else if (TARGET_POWER)
4484 {
4485 emit_insn (gen_ashldi3_power (operands[0], operands[1], operands[2]));
4486 DONE;
4487 }
4488 else
4489 FAIL;
4490 }")
4491
4492 (define_insn ""
4493 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4494 (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4495 (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
4496 "TARGET_POWERPC64"
4497 "sld%I2 %0,%1,%H2"
4498 [(set_attr "length" "8")])
4499
4500 (define_insn ""
4501 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4502 (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4503 (match_operand:SI 2 "reg_or_cint_operand" "ri"))
4504 (const_int 0)))
4505 (clobber (match_scratch:DI 3 "=r"))]
4506 "TARGET_POWERPC64"
4507 "sld%I2. %3,%1,%H2"
4508 [(set_attr "type" "delayed_compare")])
4509
4510 (define_insn ""
4511 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4512 (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4513 (match_operand:SI 2 "reg_or_cint_operand" "ri"))
4514 (const_int 0)))
4515 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4516 (ashift:DI (match_dup 1) (match_dup 2)))]
4517 "TARGET_POWERPC64"
4518 "sld%I2. %0,%1,%H2"
4519 [(set_attr "type" "delayed_compare")])
4520
4521 (define_expand "lshrdi3"
4522 [(set (match_operand:DI 0 "gpc_reg_operand" "")
4523 (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
4524 (match_operand:SI 2 "reg_or_cint_operand" "")))]
4525 "TARGET_POWERPC64 || TARGET_POWER"
4526 "
4527 {
4528 if (TARGET_POWERPC64)
4529 ;
4530 else if (TARGET_POWER)
4531 {
4532 emit_insn (gen_lshrdi3_power (operands[0], operands[1], operands[2]));
4533 DONE;
4534 }
4535 else
4536 FAIL;
4537 }")
4538
4539 (define_insn ""
4540 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4541 (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4542 (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
4543 "TARGET_POWERPC64"
4544 "srd%I2 %0,%1,%H2")
4545
4546 (define_insn ""
4547 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4548 (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4549 (match_operand:SI 2 "reg_or_cint_operand" "ri"))
4550 (const_int 0)))
4551 (clobber (match_scratch:DI 3 "=r"))]
4552 "TARGET_POWERPC64"
4553 "srd%I2. %3,%1,%H2"
4554 [(set_attr "type" "delayed_compare")])
4555
4556 (define_insn ""
4557 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4558 (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4559 (match_operand:SI 2 "reg_or_cint_operand" "ri"))
4560 (const_int 0)))
4561 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4562 (lshiftrt:DI (match_dup 1) (match_dup 2)))]
4563 "TARGET_POWERPC64"
4564 "srd%I2. %0,%1,%H2"
4565 [(set_attr "type" "delayed_compare")])
4566
4567 (define_expand "ashrdi3"
4568 [(set (match_operand:DI 0 "gpc_reg_operand" "")
4569 (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
4570 (match_operand:SI 2 "reg_or_cint_operand" "")))]
4571 "TARGET_POWERPC64 || TARGET_POWER"
4572 "
4573 {
4574 if (TARGET_POWERPC64)
4575 ;
4576 else if (TARGET_POWER && GET_CODE (operands[2]) == CONST_INT)
4577 {
4578 emit_insn (gen_ashrdi3_power (operands[0], operands[1], operands[2]));
4579 DONE;
4580 }
4581 else
4582 FAIL;
4583 }")
4584
4585 (define_insn ""
4586 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4587 (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4588 (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
4589 "TARGET_POWERPC64"
4590 "srad%I2 %0,%1,%H2")
4591
4592 (define_insn ""
4593 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4594 (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4595 (match_operand:SI 2 "reg_or_cint_operand" "ri"))
4596 (const_int 0)))
4597 (clobber (match_scratch:DI 3 "=r"))]
4598 "TARGET_POWERPC64"
4599 "srad%I2. %3,%1,%H2"
4600 [(set_attr "type" "delayed_compare")])
4601
4602 (define_insn ""
4603 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4604 (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4605 (match_operand:SI 2 "reg_or_cint_operand" "ri"))
4606 (const_int 0)))
4607 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4608 (ashiftrt:DI (match_dup 1) (match_dup 2)))]
4609 "TARGET_POWERPC64"
4610 "srad%I2. %0,%1,%H2"
4611 [(set_attr "type" "delayed_compare")])
4612
4613 (define_insn "anddi3"
4614 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r")
4615 (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r")
4616 (match_operand:DI 2 "and_operand" "?r,K,J")))
4617 (clobber (match_scratch:CC 3 "=X,x,x"))]
4618 "TARGET_POWERPC64"
4619 "@
4620 and %0,%1,%2
4621 andi. %0,%1,%b2
4622 andis. %0,%1,%u2")
4623
4624 (define_insn ""
4625 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x")
4626 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r")
4627 (match_operand:DI 2 "and_operand" "r,K,J"))
4628 (const_int 0)))
4629 (clobber (match_scratch:DI 3 "=r,r,r"))]
4630 "TARGET_POWERPC64"
4631 "@
4632 and. %3,%1,%2
4633 andi. %3,%1,%b2
4634 andis. %3,%1,%u2"
4635 [(set_attr "type" "compare,compare,compare")])
4636
4637 (define_insn ""
4638 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x")
4639 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r")
4640 (match_operand:DI 2 "and_operand" "r,K,J"))
4641 (const_int 0)))
4642 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r")
4643 (and:DI (match_dup 1) (match_dup 2)))]
4644 "TARGET_POWERPC64"
4645 "@
4646 and. %0,%1,%2
4647 andi. %0,%1,%b2
4648 andis. %0,%1,%u2"
4649 [(set_attr "type" "compare,compare,compare")])
4650
4651 ;; Take a AND with a constant that cannot be done in a single insn and try to
4652 ;; split it into two insns. This does not verify that the insns are valid
4653 ;; since this need not be done as combine will do it.
4654
4655 (define_split
4656 [(set (match_operand:DI 0 "gpc_reg_operand" "")
4657 (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
4658 (match_operand:DI 2 "non_and_cint_operand" "")))]
4659 "TARGET_POWERPC64"
4660 [(set (match_dup 0) (and:DI (match_dup 1) (match_dup 3)))
4661 (set (match_dup 0) (and:DI (match_dup 0) (match_dup 4)))]
4662 "
4663 {
4664 int maskval = INTVAL (operands[2]);
4665 int i, transitions, last_bit_value;
4666 int orig = maskval, first_c = maskval, second_c;
4667
4668 /* We know that MASKVAL must have more than 2 bit-transitions. Start at
4669 the low-order bit and count for the third transition. When we get there,
4670 make a first mask that has everything to the left of that position
4671 a one. Then make the second mask to turn off whatever else is needed. */
4672
4673 for (i = 1, transitions = 0, last_bit_value = maskval & 1; i < 32; i++)
4674 {
4675 if (((maskval >>= 1) & 1) != last_bit_value)
4676 last_bit_value ^= 1, transitions++;
4677
4678 if (transitions > 2)
4679 {
4680 first_c |= (~0) << i;
4681 break;
4682 }
4683 }
4684
4685 second_c = orig | ~ first_c;
4686
4687 operands[3] = gen_rtx (CONST_INT, VOIDmode, first_c);
4688 operands[4] = gen_rtx (CONST_INT, VOIDmode, second_c);
4689 }")
4690
4691 (define_insn "iordi3"
4692 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r")
4693 (ior:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r")
4694 (match_operand:DI 2 "logical_operand" "r,K,J")))]
4695 "TARGET_POWERPC64"
4696 "@
4697 or %0,%1,%2
4698 ori %0,%1,%b2
4699 oris %0,%1,%u2")
4700
4701 (define_insn ""
4702 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4703 (compare:CC (ior:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
4704 (match_operand:DI 2 "gpc_reg_operand" "r"))
4705 (const_int 0)))
4706 (clobber (match_scratch:DI 3 "=r"))]
4707 "TARGET_POWERPC64"
4708 "or. %3,%1,%2"
4709 [(set_attr "type" "compare")])
4710
4711 (define_insn ""
4712 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4713 (compare:CC (ior:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
4714 (match_operand:DI 2 "gpc_reg_operand" "r"))
4715 (const_int 0)))
4716 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4717 (ior:DI (match_dup 1) (match_dup 2)))]
4718 "TARGET_POWERPC64"
4719 "or. %0,%1,%2"
4720 [(set_attr "type" "compare")])
4721
4722 ;; Split an IOR that we can't do in one insn into two insns, each of which
4723 ;; does one 16-bit part. This is used by combine.
4724
4725 (define_split
4726 [(set (match_operand:DI 0 "gpc_reg_operand" "")
4727 (ior:DI (match_operand:DI 1 "gpc_reg_operand" "")
4728 (match_operand:DI 2 "non_logical_cint_operand" "")))]
4729 "TARGET_POWERPC64"
4730 [(set (match_dup 0) (ior:DI (match_dup 1) (match_dup 3)))
4731 (set (match_dup 0) (ior:DI (match_dup 0) (match_dup 4)))]
4732 "
4733 {
4734 operands[3] = gen_rtx (CONST_INT, VOIDmode,
4735 INTVAL (operands[2]) & (~ (HOST_WIDE_INT) 0xffff));
4736 operands[4] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) & 0xffff);
4737 }")
4738
4739 (define_insn "xordi3"
4740 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r")
4741 (xor:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r")
4742 (match_operand:DI 2 "logical_operand" "r,K,J")))]
4743 "TARGET_POWERPC64"
4744 "@
4745 xor %0,%1,%2
4746 xori %0,%1,%b2
4747 xoris %0,%1,%u2")
4748
4749 (define_insn ""
4750 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4751 (compare:CC (xor:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
4752 (match_operand:DI 2 "gpc_reg_operand" "r"))
4753 (const_int 0)))
4754 (clobber (match_scratch:DI 3 "=r"))]
4755 "TARGET_POWERPC64"
4756 "xor. %3,%1,%2"
4757 [(set_attr "type" "compare")])
4758
4759 (define_insn ""
4760 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4761 (compare:CC (xor:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
4762 (match_operand:DI 2 "gpc_reg_operand" "r"))
4763 (const_int 0)))
4764 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4765 (xor:DI (match_dup 1) (match_dup 2)))]
4766 "TARGET_POWERPC64"
4767 "xor. %0,%1,%2"
4768 [(set_attr "type" "compare")])
4769
4770 ;; Split an XOR that we can't do in one insn into two insns, each of which
4771 ;; does one 16-bit part. This is used by combine.
4772
4773 (define_split
4774 [(set (match_operand:DI 0 "gpc_reg_operand" "")
4775 (xor:DI (match_operand:DI 1 "gpc_reg_operand" "")
4776 (match_operand:DI 2 "non_logical_cint_operand" "")))]
4777 "TARGET_POWERPC64"
4778 [(set (match_dup 0) (xor:DI (match_dup 1) (match_dup 3)))
4779 (set (match_dup 0) (xor:DI (match_dup 0) (match_dup 4)))]
4780 "
4781 {
4782 operands[3] = gen_rtx (CONST_INT, VOIDmode,
4783 INTVAL (operands[2]) & 0xffff0000);
4784 operands[4] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) & 0xffff);
4785 }")
4786
4787 (define_insn ""
4788 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4789 (not:DI (xor:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
4790 (match_operand:DI 2 "gpc_reg_operand" "r"))))]
4791 "TARGET_POWERPC64"
4792 "eqv %0,%1,%2")
4793
4794 (define_insn ""
4795 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4796 (compare:CC (not:DI (xor:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
4797 (match_operand:DI 2 "gpc_reg_operand" "r")))
4798 (const_int 0)))
4799 (clobber (match_scratch:DI 3 "=r"))]
4800 "TARGET_POWERPC64"
4801 "eqv. %3,%1,%2"
4802 [(set_attr "type" "compare")])
4803
4804 (define_insn ""
4805 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4806 (compare:CC (not:DI (xor:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
4807 (match_operand:DI 2 "gpc_reg_operand" "r")))
4808 (const_int 0)))
4809 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4810 (not:DI (xor:DI (match_dup 1) (match_dup 2))))]
4811 "TARGET_POWERPC64"
4812 "eqv. %0,%1,%2"
4813 [(set_attr "type" "compare")])
4814
4815 (define_insn ""
4816 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4817 (and:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
4818 (match_operand:DI 2 "gpc_reg_operand" "r")))]
4819 "TARGET_POWERPC64"
4820 "andc %0,%2,%1")
4821
4822 (define_insn ""
4823 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4824 (compare:CC (and:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
4825 (match_operand:DI 2 "gpc_reg_operand" "r"))
4826 (const_int 0)))
4827 (clobber (match_scratch:DI 3 "=r"))]
4828 "TARGET_POWERPC64"
4829 "andc. %3,%2,%1"
4830 [(set_attr "type" "compare")])
4831
4832 (define_insn ""
4833 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4834 (compare:CC (and:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
4835 (match_operand:DI 2 "gpc_reg_operand" "r"))
4836 (const_int 0)))
4837 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4838 (and:DI (not:DI (match_dup 1)) (match_dup 2)))]
4839 "TARGET_POWERPC64"
4840 "andc. %0,%2,%1"
4841 [(set_attr "type" "compare")])
4842
4843 (define_insn ""
4844 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4845 (ior:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
4846 (match_operand:DI 2 "gpc_reg_operand" "r")))]
4847 "TARGET_POWERPC64"
4848 "orc %0,%2,%1")
4849
4850 (define_insn ""
4851 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4852 (compare:CC (ior:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
4853 (match_operand:DI 2 "gpc_reg_operand" "r"))
4854 (const_int 0)))
4855 (clobber (match_scratch:DI 3 "=r"))]
4856 "TARGET_POWERPC64"
4857 "orc. %3,%2,%1"
4858 [(set_attr "type" "compare")])
4859
4860 (define_insn ""
4861 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4862 (compare:CC (ior:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
4863 (match_operand:DI 2 "gpc_reg_operand" "r"))
4864 (const_int 0)))
4865 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4866 (ior:DI (not:DI (match_dup 1)) (match_dup 2)))]
4867 "TARGET_POWERPC64"
4868 "orc. %0,%2,%1"
4869 [(set_attr "type" "compare")])
4870
4871 (define_insn ""
4872 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4873 (ior:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "%r"))
4874 (not:DI (match_operand:DI 2 "gpc_reg_operand" "r"))))]
4875 "TARGET_POWERPC64"
4876 "nand %0,%1,%2")
4877
4878 (define_insn ""
4879 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4880 (compare:CC (ior:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "%r"))
4881 (not:DI (match_operand:DI 2 "gpc_reg_operand" "r")))
4882 (const_int 0)))
4883 (clobber (match_scratch:DI 3 "=r"))]
4884 "TARGET_POWERPC64"
4885 "nand. %3,%1,%2"
4886 [(set_attr "type" "compare")])
4887
4888 (define_insn ""
4889 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4890 (compare:CC (ior:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "%r"))
4891 (not:DI (match_operand:DI 2 "gpc_reg_operand" "r")))
4892 (const_int 0)))
4893 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4894 (ior:DI (not:DI (match_dup 1)) (not:DI (match_dup 2))))]
4895 "TARGET_POWERPC64"
4896 "nand. %0,%1,%2"
4897 [(set_attr "type" "compare")])
4898
4899 (define_insn ""
4900 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4901 (and:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "%r"))
4902 (not:DI (match_operand:DI 2 "gpc_reg_operand" "r"))))]
4903 "TARGET_POWERPC64"
4904 "nor %0,%1,%2")
4905
4906 (define_insn ""
4907 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4908 (compare:CC (and:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "%r"))
4909 (not:DI (match_operand:DI 2 "gpc_reg_operand" "r")))
4910 (const_int 0)))
4911 (clobber (match_scratch:DI 3 "=r"))]
4912 "TARGET_POWERPC64"
4913 "nor. %3,%1,%2"
4914 [(set_attr "type" "compare")])
4915
4916 (define_insn ""
4917 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4918 (compare:CC (and:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "%r"))
4919 (not:DI (match_operand:DI 2 "gpc_reg_operand" "r")))
4920 (const_int 0)))
4921 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4922 (and:DI (not:DI (match_dup 1)) (not:DI (match_dup 2))))]
4923 "TARGET_POWERPC64"
4924 "nor. %0,%1,%2"
4925 [(set_attr "type" "compare")])
4926 \f
4927 ;; Now define ways of moving data around.
4928
4929 ;; Elf specific ways of loading addresses for non-PIC code.
4930 ;; The output of this could be r0, but we limit it to base
4931 ;; registers, since almost all uses of this will need it
4932 ;; in a base register shortly.
4933 (define_insn "elf_high"
4934 [(set (match_operand:SI 0 "register_operand" "=b")
4935 (high:SI (match_operand 1 "" "")))]
4936 "TARGET_ELF && !TARGET_64BIT"
4937 "{cau|addis} %0,0,%1@ha")
4938
4939 (define_insn "elf_low"
4940 [(set (match_operand:SI 0 "register_operand" "=r")
4941 (lo_sum:SI (match_operand:SI 1 "register_operand" "b")
4942 (match_operand 2 "" "")))]
4943 "TARGET_ELF && !TARGET_64BIT"
4944 "{cal %0,%a2@l(%1)|addi %0,%1,%2@l}")
4945
4946 ;; Set up a register with a value from the GOT table
4947
4948 (define_expand "movsi_got"
4949 [(set (match_operand:SI 0 "register_operand" "")
4950 (unspec [(match_operand:SI 1 "got_operand" "")
4951 (match_dup 2)] 8))]
4952 "(DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_SOLARIS) && flag_pic"
4953 "
4954 {
4955 if (!pic_offset_table_rtx)
4956 pic_offset_table_rtx = gen_reg_rtx (SImode);
4957
4958 operands[2] = pic_offset_table_rtx;
4959 if (flag_pic > 1)
4960 {
4961 emit_insn (gen_movsi_got_large (operands[0], operands[1], operands[2]));
4962 DONE;
4963 }
4964 }")
4965
4966 (define_insn "*movsi_got_internal1"
4967 [(set (match_operand:SI 0 "register_operand" "=r")
4968 (unspec [(match_operand:SI 1 "got_operand" "")
4969 (match_operand:SI 2 "register_operand" "b")] 8))]
4970 "(DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_SOLARIS) && flag_pic == 1"
4971 "{l|lwz} %0,%a1@got(%2)"
4972 [(set_attr "type" "load")])
4973
4974 (define_expand "movsi_got_large"
4975 [(set (match_dup 3)
4976 (unspec [(match_operand:SI 1 "got_operand" "")] 9))
4977 (set (match_dup 3)
4978 (unspec [(match_dup 1)
4979 (match_dup 3)] 10))
4980 (set (match_operand:SI 0 "register_operand" "")
4981 (mem:SI (plus:SI (match_dup 3)
4982 (match_operand:SI 2 "register_operand" ""))))]
4983 "(DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_SOLARIS) && flag_pic > 1"
4984 "
4985 {
4986 if (reload_completed || reload_in_progress)
4987 abort ();
4988
4989 operands[3] = gen_reg_rtx (SImode);
4990 }")
4991
4992 (define_insn "*movsi_got_internal2_high"
4993 [(set (match_operand:SI 0 "register_operand" "=b")
4994 (unspec [(match_operand:SI 1 "got_operand" "")] 9))]
4995 "(DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_SOLARIS) && flag_pic > 1"
4996 "{cau|addis} %0,0,%1@got@ha")
4997
4998 (define_insn "*movsi_got_internal2_losum"
4999 [(set (match_operand:SI 0 "register_operand" "=r")
5000 (unspec [(match_operand:SI 1 "got_operand" "")
5001 (match_operand:SI 2 "register_operand" "b")] 10))]
5002 "(DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_SOLARIS) && flag_pic > 1"
5003 "{cal %0,%a1@got@l(%2)|addi %0,%2,%a1@got@l}")
5004
5005 ;; For SI, we special-case integers that can't be loaded in one insn. We
5006 ;; do the load 16-bits at a time. We could do this by loading from memory,
5007 ;; and this is even supposed to be faster, but it is simpler not to get
5008 ;; integers in the TOC.
5009 (define_expand "movsi"
5010 [(set (match_operand:SI 0 "general_operand" "")
5011 (match_operand:SI 1 "any_operand" ""))]
5012 ""
5013 "
5014 {
5015 if (GET_CODE (operands[0]) != REG)
5016 operands[1] = force_reg (SImode, operands[1]);
5017
5018 /* Convert a move of a CONST_DOUBLE into a CONST_INT */
5019 if (GET_CODE (operands[1]) == CONST_DOUBLE)
5020 operands[1] = GEN_INT (CONST_DOUBLE_LOW (operands[1]));
5021
5022 /* Use default pattern for address of ELF small data */
5023 if (TARGET_ELF
5024 && (DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_SOLARIS)
5025 && (GET_CODE (operands[1]) == SYMBOL_REF || GET_CODE (operands[1]) == CONST)
5026 && small_data_operand (operands[1], SImode))
5027 {
5028 emit_insn (gen_rtx (SET, VOIDmode, operands[0], operands[1]));
5029 DONE;
5030 }
5031
5032 if ((DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_SOLARIS)
5033 && flag_pic && got_operand (operands[1], SImode))
5034 {
5035 emit_insn (gen_movsi_got (operands[0], operands[1]));
5036 DONE;
5037 }
5038
5039 if (TARGET_ELF && TARGET_NO_TOC && !TARGET_64BIT
5040 && CONSTANT_P (operands[1])
5041 && GET_CODE (operands[1]) != HIGH
5042 && GET_CODE (operands[1]) != CONST_INT)
5043 {
5044 rtx target = (reload_completed || reload_in_progress)
5045 ? operands[0] : gen_reg_rtx (SImode);
5046
5047 /* If this is a function address on -mcall-aixdesc or -mcall-nt,
5048 convert it to the address of the descriptor. */
5049 if ((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_NT)
5050 && GET_CODE (operands[1]) == SYMBOL_REF
5051 && XSTR (operands[1], 0)[0] == '.')
5052 {
5053 char *name = XSTR (operands[1], 0);
5054 rtx new_ref;
5055 while (*name == '.')
5056 name++;
5057 new_ref = gen_rtx (SYMBOL_REF, Pmode, name);
5058 CONSTANT_POOL_ADDRESS_P (new_ref) = CONSTANT_POOL_ADDRESS_P (operands[1]);
5059 SYMBOL_REF_FLAG (new_ref) = SYMBOL_REF_FLAG (operands[1]);
5060 SYMBOL_REF_USED (new_ref) = SYMBOL_REF_USED (operands[1]);
5061 operands[1] = new_ref;
5062 }
5063
5064 emit_insn (gen_elf_high (target, operands[1]));
5065 emit_insn (gen_elf_low (operands[0], target, operands[1]));
5066 DONE;
5067 }
5068
5069 if (GET_CODE (operands[1]) == CONST
5070 && DEFAULT_ABI == ABI_NT
5071 && !side_effects_p (operands[0]))
5072 {
5073 rtx const_term = const0_rtx;
5074 rtx sym = eliminate_constant_term (XEXP (operands[1], 0), &const_term);
5075 if (sym && GET_CODE (const_term) == CONST_INT
5076 && (GET_CODE (sym) == SYMBOL_REF || GET_CODE (sym) == LABEL_REF))
5077 {
5078 unsigned HOST_WIDE_INT value = INTVAL (const_term);
5079 int new_reg_p = (flag_expensive_optimizations
5080 && !reload_completed
5081 && !reload_in_progress);
5082 rtx tmp1 = (new_reg_p && value != 0) ? gen_reg_rtx (SImode) : operands[0];
5083
5084 emit_insn (gen_movsi (tmp1, sym));
5085 if (INTVAL (const_term) != 0)
5086 {
5087 if (value + 0x8000 < 0x10000)
5088 emit_insn (gen_addsi3 (operands[0], tmp1, GEN_INT (value)));
5089
5090 else
5091 {
5092 HOST_WIDE_INT high_int = value & (~ (HOST_WIDE_INT) 0xffff);
5093 HOST_WIDE_INT low_int = value & 0xffff;
5094 rtx tmp2 = (!new_reg_p || !low_int) ? operands[0] : gen_reg_rtx (Pmode);
5095
5096 if (low_int & 0x8000)
5097 high_int += 0x10000, low_int |= ((HOST_WIDE_INT) -1) << 16;
5098
5099 emit_insn (gen_addsi3 (tmp2, tmp1, GEN_INT (high_int)));
5100 if (low_int)
5101 emit_insn (gen_addsi3 (operands[0], tmp2, GEN_INT (low_int)));
5102 }
5103 }
5104 DONE;
5105 }
5106 else
5107 fatal_insn (\"bad address\", operands[1]);
5108 }
5109
5110 if ((!TARGET_WINDOWS_NT || DEFAULT_ABI != ABI_NT)
5111 && CONSTANT_P (operands[1])
5112 && GET_CODE (operands[1]) != CONST_INT
5113 && GET_CODE (operands[1]) != HIGH
5114 && ! LEGITIMATE_CONSTANT_POOL_ADDRESS_P (operands[1]))
5115 {
5116 /* If we are to limit the number of things we put in the TOC and
5117 this is a symbol plus a constant we can add in one insn,
5118 just put the symbol in the TOC and add the constant. Don't do
5119 this if reload is in progress. */
5120 if (GET_CODE (operands[1]) == CONST
5121 && TARGET_NO_SUM_IN_TOC && ! reload_in_progress
5122 && GET_CODE (XEXP (operands[1], 0)) == PLUS
5123 && add_operand (XEXP (XEXP (operands[1], 0), 1), SImode)
5124 && (GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == LABEL_REF
5125 || GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == SYMBOL_REF)
5126 && ! side_effects_p (operands[0]))
5127 {
5128 rtx sym = force_const_mem (SImode, XEXP (XEXP (operands[1], 0), 0));
5129 rtx other = XEXP (XEXP (operands[1], 0), 1);
5130
5131 emit_insn (gen_addsi3 (operands[0], force_reg (SImode, sym), other));
5132 DONE;
5133 }
5134
5135 operands[1] = force_const_mem (SImode, operands[1]);
5136 if (! memory_address_p (SImode, XEXP (operands[1], 0))
5137 && ! reload_in_progress)
5138 operands[1] = change_address (operands[1], SImode,
5139 XEXP (operands[1], 0));
5140 }
5141 }")
5142
5143 (define_insn ""
5144 [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,r,r,r,m,r,r,r,r,r,*q,*c*l,*h")
5145 (match_operand:SI 1 "input_operand" "r,S,T,U,m,r,I,J,n,R,*h,r,r,0"))]
5146 "gpc_reg_operand (operands[0], SImode)
5147 || gpc_reg_operand (operands[1], SImode)"
5148 "@
5149 mr %0,%1
5150 {l|lwz} %0,[toc]%1(2)
5151 {l|lwz} %0,[toc]%l1(2)
5152 {cal|la} %0,%a1
5153 {l%U1%X1|lwz%U1%X1} %0,%1
5154 {st%U0%X0|stw%U0%X0} %1,%0
5155 {lil|li} %0,%1
5156 {liu|lis} %0,%v1
5157 #
5158 {cal|la} %0,%1(%*)
5159 mf%1 %0
5160 mt%0 %1
5161 mt%0 %1
5162 cror 0,0,0"
5163 [(set_attr "type" "*,load,load,*,load,store,*,*,*,*,*,*,mtjmpr,*")
5164 (set_attr "length" "4,4,4,4,4,4,4,4,8,4,4,4,4,4")])
5165
5166 ;; Split a load of a large constant into the appropriate two-insn
5167 ;; sequence.
5168
5169 (define_split
5170 [(set (match_operand:SI 0 "gpc_reg_operand" "")
5171 (match_operand:SI 1 "const_int_operand" ""))]
5172 "(unsigned) (INTVAL (operands[1]) + 0x8000) >= 0x10000
5173 && (INTVAL (operands[1]) & 0xffff) != 0"
5174 [(set (match_dup 0)
5175 (match_dup 2))
5176 (set (match_dup 0)
5177 (ior:SI (match_dup 0)
5178 (match_dup 3)))]
5179 "
5180 {
5181 operands[2] = gen_rtx (CONST_INT, VOIDmode,
5182 INTVAL (operands[1]) & 0xffff0000);
5183 operands[3] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) & 0xffff);
5184 }")
5185
5186 (define_insn ""
5187 [(set (match_operand:CC 2 "cc_reg_operand" "=x")
5188 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
5189 (const_int 0)))
5190 (set (match_operand:SI 0 "gpc_reg_operand" "=r") (match_dup 1))]
5191 ""
5192 "mr. %0,%1"
5193 [(set_attr "type" "compare")])
5194 \f
5195 (define_expand "movhi"
5196 [(set (match_operand:HI 0 "general_operand" "")
5197 (match_operand:HI 1 "any_operand" ""))]
5198 ""
5199 "
5200 {
5201 if (GET_CODE (operands[0]) != REG)
5202 operands[1] = force_reg (HImode, operands[1]);
5203
5204 if (CONSTANT_P (operands[1]) && GET_CODE (operands[1]) != CONST_INT)
5205 {
5206 operands[1] = force_const_mem (HImode, operands[1]);
5207 if (! memory_address_p (HImode, XEXP (operands[1], 0))
5208 && ! reload_in_progress)
5209 operands[1] = change_address (operands[1], HImode,
5210 XEXP (operands[1], 0));
5211 }
5212 }")
5213
5214 (define_insn ""
5215 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,m,r,r,*q,*c*l,*h")
5216 (match_operand:HI 1 "input_operand" "r,m,r,i,*h,r,r,0"))]
5217 "gpc_reg_operand (operands[0], HImode)
5218 || gpc_reg_operand (operands[1], HImode)"
5219 "@
5220 mr %0,%1
5221 lhz%U1%X1 %0,%1
5222 sth%U0%X0 %1,%0
5223 {lil|li} %0,%w1
5224 mf%1 %0
5225 mt%0 %1
5226 mt%0 %1
5227 cror 0,0,0"
5228 [(set_attr "type" "*,load,store,*,*,*,mtjmpr,*")])
5229
5230 (define_expand "movqi"
5231 [(set (match_operand:QI 0 "general_operand" "")
5232 (match_operand:QI 1 "any_operand" ""))]
5233 ""
5234 "
5235 {
5236 if (GET_CODE (operands[0]) != REG)
5237 operands[1] = force_reg (QImode, operands[1]);
5238
5239 if (CONSTANT_P (operands[1]) && GET_CODE (operands[1]) != CONST_INT)
5240 {
5241 operands[1] = force_const_mem (QImode, operands[1]);
5242 if (! memory_address_p (QImode, XEXP (operands[1], 0))
5243 && ! reload_in_progress)
5244 operands[1] = change_address (operands[1], QImode,
5245 XEXP (operands[1], 0));
5246 }
5247 }")
5248
5249 (define_insn ""
5250 [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,m,r,r,*q,*c*l,*h")
5251 (match_operand:QI 1 "input_operand" "r,m,r,i,*h,r,r,0"))]
5252 "gpc_reg_operand (operands[0], QImode)
5253 || gpc_reg_operand (operands[1], QImode)"
5254 "@
5255 mr %0,%1
5256 lbz%U1%X1 %0,%1
5257 stb%U0%X0 %1,%0
5258 {lil|li} %0,%1
5259 mf%1 %0
5260 mt%0 %1
5261 mt%0 %1
5262 cror 0,0,0"
5263 [(set_attr "type" "*,load,store,*,*,*,mtjmpr,*")])
5264 \f
5265 ;; Here is how to move condition codes around. When we store CC data in
5266 ;; an integer register or memory, we store just the high-order 4 bits.
5267 ;; This lets us not shift in the most common case of CR0.
5268 (define_expand "movcc"
5269 [(set (match_operand:CC 0 "nonimmediate_operand" "")
5270 (match_operand:CC 1 "nonimmediate_operand" ""))]
5271 ""
5272 "")
5273
5274 (define_insn ""
5275 [(set (match_operand:CC 0 "nonimmediate_operand" "=y,x,y,r,r,r,r,m")
5276 (match_operand:CC 1 "nonimmediate_operand" "y,r,r,x,y,r,m,r"))]
5277 "register_operand (operands[0], CCmode)
5278 || register_operand (operands[1], CCmode)"
5279 "@
5280 mcrf %0,%1
5281 mtcrf 128,%1
5282 {rlinm|rlwinm} %1,%1,%F0,0xffffffff\;mtcrf %R0,%1\;{rlinm|rlwinm} %1,%1,%f0,0xffffffff
5283 mfcr %0
5284 mfcr %0\;{rlinm|rlwinm} %0,%0,%f1,0xf0000000
5285 mr %0,%1
5286 {l%U1%X1|lwz%U1%X1} %0,%1
5287 {st%U0%U1|stw%U0%U1} %1,%0"
5288 [(set_attr "type" "*,*,*,compare,*,*,load,store")
5289 (set_attr "length" "*,*,12,*,8,*,*,*")])
5290 \f
5291 ;; For floating-point, we normally deal with the floating-point registers
5292 ;; unless -msoft-float is used. The sole exception is that parameter passing
5293 ;; can produce floating-point values in fixed-point registers. Unless the
5294 ;; value is a simple constant or already in memory, we deal with this by
5295 ;; allocating memory and copying the value explicitly via that memory location.
5296 (define_expand "movsf"
5297 [(set (match_operand:SF 0 "nonimmediate_operand" "")
5298 (match_operand:SF 1 "any_operand" ""))]
5299 ""
5300 "
5301 {
5302 /* If we are called from reload, we might be getting a SUBREG of a hard
5303 reg. So expand it. */
5304 if (GET_CODE (operands[0]) == SUBREG
5305 && GET_CODE (SUBREG_REG (operands[0])) == REG
5306 && REGNO (SUBREG_REG (operands[0])) < FIRST_PSEUDO_REGISTER)
5307 operands[0] = alter_subreg (operands[0]);
5308 if (GET_CODE (operands[1]) == SUBREG
5309 && GET_CODE (SUBREG_REG (operands[1])) == REG
5310 && REGNO (SUBREG_REG (operands[1])) < FIRST_PSEUDO_REGISTER)
5311 operands[1] = alter_subreg (operands[1]);
5312
5313 if (TARGET_SOFT_FLOAT && GET_CODE (operands[0]) == MEM)
5314 operands[1] = force_reg (SFmode, operands[1]);
5315
5316 else if (TARGET_HARD_FLOAT)
5317 {
5318 if (GET_CODE (operands[1]) == REG && REGNO (operands[1]) < 32)
5319 {
5320 /* If this is a store to memory or another integer register do the
5321 move directly. Otherwise store to a temporary stack slot and
5322 load from there into a floating point register. */
5323
5324 if (GET_CODE (operands[0]) == MEM
5325 || (GET_CODE (operands[0]) == REG
5326 && (REGNO (operands[0]) < 32
5327 || (reload_in_progress
5328 && REGNO (operands[0]) >= FIRST_PSEUDO_REGISTER))))
5329 {
5330 emit_move_insn (operand_subword (operands[0], 0, 0, SFmode),
5331 operand_subword (operands[1], 0, 0, SFmode));
5332 DONE;
5333 }
5334 else
5335 {
5336 rtx stack_slot = assign_stack_temp (SFmode, 4, 0);
5337
5338 emit_move_insn (stack_slot, operands[1]);
5339 emit_move_insn (operands[0], stack_slot);
5340 DONE;
5341 }
5342 }
5343
5344 if (GET_CODE (operands[0]) == MEM)
5345 {
5346 /* If operands[1] is a register, it may have double-precision data
5347 in it, so truncate it to single precision. We need not do
5348 this for POWERPC. */
5349 if (! TARGET_POWERPC && TARGET_HARD_FLOAT
5350 && GET_CODE (operands[1]) == REG)
5351 {
5352 rtx newreg
5353 = reload_in_progress ? operands[1] : gen_reg_rtx (SFmode);
5354 emit_insn (gen_aux_truncdfsf2 (newreg, operands[1]));
5355 operands[1] = newreg;
5356 }
5357
5358 operands[1] = force_reg (SFmode, operands[1]);
5359 }
5360
5361 if (GET_CODE (operands[0]) == REG && REGNO (operands[0]) < 32)
5362 {
5363 if (GET_CODE (operands[1]) == MEM
5364 #if HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT && ! defined(REAL_IS_NOT_DOUBLE)
5365 || GET_CODE (operands[1]) == CONST_DOUBLE
5366 #endif
5367 || (GET_CODE (operands[1]) == REG
5368 && (REGNO (operands[1]) < 32
5369 || (reload_in_progress
5370 && REGNO (operands[1]) >= FIRST_PSEUDO_REGISTER))))
5371 {
5372 emit_move_insn (operand_subword (operands[0], 0, 0, SFmode),
5373 operand_subword (operands[1], 0, 0, SFmode));
5374 DONE;
5375 }
5376 else
5377 {
5378 rtx stack_slot = assign_stack_temp (SFmode, 4, 0);
5379
5380 emit_move_insn (stack_slot, operands[1]);
5381 emit_move_insn (operands[0], stack_slot);
5382 DONE;
5383 }
5384 }
5385 }
5386
5387 if (CONSTANT_P (operands[1]))
5388 {
5389 operands[1] = force_const_mem (SFmode, operands[1]);
5390 if (! memory_address_p (SFmode, XEXP (operands[1], 0))
5391 && ! reload_in_progress)
5392 operands[1] = change_address (operands[1], SFmode,
5393 XEXP (operands[1], 0));
5394 }
5395 }")
5396
5397 (define_split
5398 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5399 (match_operand:SF 1 "easy_fp_constant" ""))]
5400 "reload_completed && REGNO (operands[0]) <= 31"
5401 [(set (subreg:SI (match_dup 0) 0) (match_dup 2))]
5402 "
5403 {
5404 long l;
5405 REAL_VALUE_TYPE rv;
5406
5407 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
5408 REAL_VALUE_TO_TARGET_SINGLE (rv, l);
5409 operands[2] = GEN_INT(l);
5410 }")
5411
5412 (define_insn ""
5413 [(set (match_operand:SF 0 "fp_reg_or_mem_operand" "=f,f,m")
5414 (match_operand:SF 1 "input_operand" "f,m,f"))]
5415 "(gpc_reg_operand (operands[0], SFmode)
5416 || gpc_reg_operand (operands[1], SFmode)) && TARGET_HARD_FLOAT"
5417 "@
5418 fmr %0,%1
5419 lfs%U1%X1 %0,%1
5420 stfs%U0%X0 %1,%0"
5421 [(set_attr "type" "fp,fpload,fpstore")])
5422
5423 (define_insn ""
5424 [(set (match_operand:SF 0 "nonimmediate_operand" "=r,r,m,r,r,r")
5425 (match_operand:SF 1 "input_operand" "r,m,r,I,J,R"))]
5426 "(gpc_reg_operand (operands[0], SFmode)
5427 || gpc_reg_operand (operands[1], SFmode)) && TARGET_SOFT_FLOAT"
5428 "@
5429 mr %0,%1
5430 {l%U1%X1|lwz%U1%X1} %0,%1
5431 {st%U0%X0|stw%U0%X0} %1,%0
5432 {lil|li} %0,%1
5433 {liu|lis} %0,%v1
5434 {cal|la} %0,%1(%*)"
5435 [(set_attr "type" "*,load,store,*,*,*")])
5436
5437 \f
5438 (define_expand "movdf"
5439 [(set (match_operand:DF 0 "nonimmediate_operand" "")
5440 (match_operand:DF 1 "any_operand" ""))]
5441 ""
5442 "
5443 {
5444 if (GET_CODE (operands[0]) != REG)
5445 operands[1] = force_reg (DFmode, operands[1]);
5446
5447 /* Stores between FPR and any non-FPR registers must go through a
5448 temporary stack slot. */
5449
5450 if (TARGET_POWERPC64
5451 && GET_CODE (operands[0]) == REG && GET_CODE (operands[1]) == REG
5452 && ((FP_REGNO_P (REGNO (operands[0]))
5453 && ! FP_REGNO_P (REGNO (operands[1])))
5454 || (FP_REGNO_P (REGNO (operands[1]))
5455 && ! FP_REGNO_P (REGNO (operands[0])))))
5456 {
5457 rtx stack_slot = assign_stack_temp (DFmode, 8, 0);
5458
5459 emit_move_insn (stack_slot, operands[1]);
5460 emit_move_insn (operands[0], stack_slot);
5461 DONE;
5462 }
5463
5464 if (CONSTANT_P (operands[1]) && ! easy_fp_constant (operands[1], DFmode))
5465 {
5466 operands[1] = force_const_mem (DFmode, operands[1]);
5467 if (! memory_address_p (DFmode, XEXP (operands[1], 0))
5468 && ! reload_in_progress)
5469 operands[1] = change_address (operands[1], DFmode,
5470 XEXP (operands[1], 0));
5471 }
5472 }")
5473
5474 (define_split
5475 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5476 (match_operand:DF 1 "easy_fp_constant" ""))]
5477 "TARGET_32BIT && reload_completed && REGNO (operands[0]) <= 31"
5478 [(set (match_dup 2) (match_dup 3))
5479 (set (match_dup 4) (match_dup 5))]
5480 "
5481 { operands[2] = operand_subword (operands[0], 0, 0, DFmode);
5482 operands[3] = operand_subword (operands[1], 0, 0, DFmode);
5483 operands[4] = operand_subword (operands[0], 1, 0, DFmode);
5484 operands[5] = operand_subword (operands[1], 1, 0, DFmode); }")
5485
5486 (define_split
5487 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5488 (match_operand:DF 1 "easy_fp_constant" ""))]
5489 "TARGET_64BIT && reload_completed && REGNO (operands[0]) <= 31"
5490 [(set (subreg:DI (match_dup 0) 0) (subreg:DI (match_dup 1) 0))]
5491 "")
5492
5493 ;; Don't have reload use general registers to load a constant. First,
5494 ;; it might not work if the output operand has is the equivalent of
5495 ;; a non-offsettable memref, but also it is less efficient than loading
5496 ;; the constant into an FP register, since it will probably be used there.
5497 ;; The "??" is a kludge until we can figure out a more reasonable way
5498 ;; of handling these non-offsettable values.
5499 (define_insn ""
5500 [(set (match_operand:DF 0 "nonimmediate_operand" "=!r,??r,o,!r,f,f,m")
5501 (match_operand:DF 1 "input_operand" "r,o,r,G,f,m,f"))]
5502 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT
5503 && (register_operand (operands[0], DFmode)
5504 || register_operand (operands[1], DFmode))"
5505 "*
5506 {
5507 switch (which_alternative)
5508 {
5509 case 0:
5510 /* We normally copy the low-numbered register first. However, if
5511 the first register operand 0 is the same as the second register of
5512 operand 1, we must copy in the opposite order. */
5513 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
5514 return \"mr %L0,%L1\;mr %0,%1\";
5515 else
5516 return \"mr %0,%1\;mr %L0,%L1\";
5517 case 1:
5518 /* If the low-address word is used in the address, we must load it
5519 last. Otherwise, load it first. Note that we cannot have
5520 auto-increment in that case since the address register is known to be
5521 dead. */
5522 if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
5523 operands [1], 0))
5524 return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
5525 else
5526 return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
5527 case 2:
5528 return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
5529 case 3:
5530 return \"#\";
5531 case 4:
5532 return \"fmr %0,%1\";
5533 case 5:
5534 return \"lfd%U1%X1 %0,%1\";
5535 case 6:
5536 return \"stfd%U0%X0 %1,%0\";
5537 }
5538 }"
5539 [(set_attr "type" "*,load,store,*,fp,fpload,fpstore")
5540 (set_attr "length" "8,8,8,8,*,*,*")])
5541
5542 (define_insn ""
5543 [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,o,r")
5544 (match_operand:DF 1 "input_operand" "r,o,r,G"))]
5545 "! TARGET_POWERPC64 && TARGET_SOFT_FLOAT
5546 && (register_operand (operands[0], DFmode)
5547 || register_operand (operands[1], DFmode))"
5548 "*
5549 {
5550 switch (which_alternative)
5551 {
5552 case 0:
5553 /* We normally copy the low-numbered register first. However, if
5554 the first register operand 0 is the same as the second register of
5555 operand 1, we must copy in the opposite order. */
5556 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
5557 return \"mr %L0,%L1\;mr %0,%1\";
5558 else
5559 return \"mr %0,%1\;mr %L0,%L1\";
5560 case 1:
5561 /* If the low-address word is used in the address, we must load it
5562 last. Otherwise, load it first. Note that we cannot have
5563 auto-increment in that case since the address register is known to be
5564 dead. */
5565 if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
5566 operands [1], 0))
5567 return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
5568 else
5569 return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
5570 case 2:
5571 return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
5572 case 3:
5573 return \"#\";
5574 }
5575 }"
5576 [(set_attr "type" "*,load,store,*")
5577 (set_attr "length" "8,8,8,8")])
5578
5579 (define_insn ""
5580 [(set (match_operand:DF 0 "nonimmediate_operand" "=!r,??r,o,!r,f,f,m")
5581 (match_operand:DF 1 "input_operand" "r,o,r,G,f,m,f"))]
5582 "TARGET_POWERPC64 && TARGET_HARD_FLOAT
5583 && (register_operand (operands[0], DFmode)
5584 || register_operand (operands[1], DFmode))"
5585 "@
5586 mr %0,%1
5587 ld%U1%X1 %0,%1
5588 std%U0%X0 %1,%0
5589 #
5590 fmr %0,%1
5591 lfd%U1%X1 %0,%1
5592 stfd%U0%X0 %1,%0"
5593 [(set_attr "type" "*,load,store,*,fp,fpload,fpstore")])
5594
5595 (define_insn ""
5596 [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,o,r")
5597 (match_operand:DF 1 "input_operand" "r,o,r,G"))]
5598 "TARGET_POWERPC64 && TARGET_SOFT_FLOAT
5599 && (register_operand (operands[0], DFmode)
5600 || register_operand (operands[1], DFmode))"
5601 "@
5602 mr %0,%1
5603 ld%U1%X1 %0,%1
5604 std%U0%X0 %1,%0
5605 #"
5606 [(set_attr "type" "*,load,store,*")])
5607 \f
5608 ;; Next come the multi-word integer load and store and the load and store
5609 ;; multiple insns.
5610 (define_expand "movdi"
5611 [(set (match_operand:DI 0 "general_operand" "")
5612 (match_operand:DI 1 "any_operand" ""))]
5613 ""
5614 "
5615 {
5616 if (GET_CODE (operands[0]) != REG)
5617 operands[1] = force_reg (DImode, operands[1]);
5618
5619 if (TARGET_64BIT
5620 && (GET_CODE (operands[1]) == CONST_DOUBLE
5621 || GET_CODE (operands[1]) == CONST_INT))
5622 {
5623 HOST_WIDE_INT low;
5624 HOST_WIDE_INT high;
5625
5626 if (GET_CODE (operands[1]) == CONST_DOUBLE)
5627 {
5628 low = CONST_DOUBLE_LOW (operands[1]);
5629 high = CONST_DOUBLE_HIGH (operands[1]);
5630 }
5631 else
5632 #if HOST_BITS_PER_WIDE_INT == 32
5633 {
5634 low = INTVAL (operands[1]);
5635 high = (low < 0) ? ~0 : 0;
5636 }
5637 #else
5638 {
5639 low = INTVAL (operands[1]) & 0xffffffff;
5640 high = (HOST_WIDE_INT) INTVAL (operands[1]) >> 32;
5641 }
5642 #endif
5643
5644 if (high)
5645 {
5646 emit_move_insn (operands[0], GEN_INT (high));
5647 emit_insn (gen_ashldi3 (operands[0], operands[0], GEN_INT(32)));
5648 if (low)
5649 {
5650 HOST_WIDE_INT low_low = low & 0xffff;
5651 HOST_WIDE_INT low_high = low & (~ (HOST_WIDE_INT) 0xffff);
5652 if (low_high)
5653 emit_insn (gen_iordi3 (operands[0], operands[0],
5654 GEN_INT (low_high)));
5655 if (low_low)
5656 emit_insn (gen_iordi3 (operands[0], operands[0],
5657 GEN_INT (low_low)));
5658 }
5659 DONE;
5660 }
5661 }
5662
5663 /* Stores between FPR and any non-FPR registers must go through a
5664 temporary stack slot. */
5665
5666 if (GET_CODE (operands[0]) == REG && GET_CODE (operands[1]) == REG
5667 && ((FP_REGNO_P (REGNO (operands[0]))
5668 && ! FP_REGNO_P (REGNO (operands[1])))
5669 || (FP_REGNO_P (REGNO (operands[1]))
5670 && ! FP_REGNO_P (REGNO (operands[0])))))
5671 {
5672 rtx stack_slot = assign_stack_temp (DImode, 8, 0);
5673
5674 emit_move_insn (stack_slot, operands[1]);
5675 emit_move_insn (operands[0], stack_slot);
5676 DONE;
5677 }
5678 }")
5679
5680 (define_insn ""
5681 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m,f,f,m,r,r,r,r,r")
5682 (match_operand:DI 1 "input_operand" "r,m,r,f,m,f,IJK,n,G,H,F"))]
5683 "TARGET_32BIT
5684 && (gpc_reg_operand (operands[0], DImode)
5685 || gpc_reg_operand (operands[1], DImode))"
5686 "*
5687 {
5688 switch (which_alternative)
5689 {
5690 case 0:
5691 /* We normally copy the low-numbered register first. However, if
5692 the first register operand 0 is the same as the second register of
5693 operand 1, we must copy in the opposite order. */
5694 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
5695 return \"mr %L0,%L1\;mr %0,%1\";
5696 else
5697 return \"mr %0,%1\;mr %L0,%L1\";
5698 case 1:
5699 /* If the low-address word is used in the address, we must load it
5700 last. Otherwise, load it first. Note that we cannot have
5701 auto-increment in that case since the address register is known to be
5702 dead. */
5703 if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
5704 operands [1], 0))
5705 return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
5706 else
5707 return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
5708 case 2:
5709 return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
5710 case 3:
5711 return \"fmr %0,%1\";
5712 case 4:
5713 return \"lfd%U1%X1 %0,%1\";
5714 case 5:
5715 return \"stfd%U0%X0 %1,%0\";
5716 case 6:
5717 case 7:
5718 case 8:
5719 case 9:
5720 case 10:
5721 return \"#\";
5722 }
5723 }"
5724 [(set_attr "type" "*,load,store,fp,fpload,fpstore,*,*,*,*,*")
5725 (set_attr "length" "8,8,8,*,*,*,8,12,8,12,16")])
5726
5727 (define_split
5728 [(set (match_operand:DI 0 "gpc_reg_operand" "")
5729 (match_operand:DI 1 "const_int_operand" ""))]
5730 "TARGET_32BIT && reload_completed && num_insns_constant (operands[1], DImode) <= 1"
5731 [(set (match_dup 2) (match_dup 4))
5732 (set (match_dup 3) (match_dup 1))]
5733 "
5734 {
5735 operands[2] = gen_rtx (SUBREG, SImode, operands[0], WORDS_BIG_ENDIAN == 0);
5736 operands[3] = gen_rtx (SUBREG, SImode, operands[0], WORDS_BIG_ENDIAN != 0);
5737 operands[4] = (INTVAL (operands[1]) & 0x80000000) ? constm1_rtx : const0_rtx;
5738 }")
5739
5740 (define_split
5741 [(set (match_operand:DI 0 "gpc_reg_operand" "")
5742 (match_operand:DI 1 "const_int_operand" ""))]
5743 "TARGET_32BIT && reload_completed && num_insns_constant (operands[1], DImode) >= 2"
5744 [(set (match_dup 3) (match_dup 5))
5745 (set (match_dup 2) (match_dup 4))
5746 (set (match_dup 3) (ior:SI (match_dup 3) (match_dup 6)))]
5747 "
5748 {
5749 HOST_WIDE_INT value = INTVAL (operands[1]);
5750 operands[2] = gen_rtx (SUBREG, SImode, operands[0], WORDS_BIG_ENDIAN == 0);
5751 operands[3] = gen_rtx (SUBREG, SImode, operands[0], WORDS_BIG_ENDIAN != 0);
5752 operands[4] = (value & 0x80000000) ? constm1_rtx : const0_rtx;
5753 operands[5] = GEN_INT (value & 0xffff0000);
5754 operands[6] = GEN_INT (value & 0x0000ffff);
5755 }")
5756
5757 (define_split
5758 [(set (match_operand:DI 0 "gpc_reg_operand" "")
5759 (match_operand:DI 1 "const_double_operand" ""))]
5760 "TARGET_32BIT && reload_completed && num_insns_constant (operands[1], DImode) <= 2"
5761 [(set (match_dup 2) (match_dup 4))
5762 (set (match_dup 3) (match_dup 5))]
5763 "
5764 {
5765 operands[2] = gen_rtx (SUBREG, SImode, operands[0], WORDS_BIG_ENDIAN == 0);
5766 operands[3] = gen_rtx (SUBREG, SImode, operands[0], WORDS_BIG_ENDIAN != 0);
5767 operands[4] = GEN_INT (CONST_DOUBLE_HIGH (operands[1]));
5768 operands[5] = GEN_INT (CONST_DOUBLE_LOW (operands[1]));
5769 }")
5770
5771 (define_split
5772 [(set (match_operand:DI 0 "gpc_reg_operand" "")
5773 (match_operand:DI 1 "const_double_operand" ""))]
5774 "TARGET_32BIT && reload_completed && num_insns_constant (operands[1], DImode) == 3"
5775 [(set (match_dup 2) (match_dup 4))
5776 (set (match_dup 3) (match_dup 5))
5777 (set (match_dup 2) (ior:SI (match_dup 2) (match_dup 6)))]
5778 "
5779 {
5780 HOST_WIDE_INT high = CONST_DOUBLE_HIGH (operands[1]);
5781 HOST_WIDE_INT low = CONST_DOUBLE_LOW (operands[1]);
5782 rtx high_reg = gen_rtx (SUBREG, SImode, operands[0], WORDS_BIG_ENDIAN == 0);
5783 rtx low_reg = gen_rtx (SUBREG, SImode, operands[0], WORDS_BIG_ENDIAN != 0);
5784
5785 if (((unsigned HOST_WIDE_INT) (low + 0x8000) < 0x10000)
5786 || (low & 0xffff) == 0)
5787 {
5788 operands[2] = high_reg;
5789 operands[3] = low_reg;
5790 operands[4] = GEN_INT (high & 0xffff0000);
5791 operands[5] = GEN_INT (low);
5792 operands[6] = GEN_INT (high & 0x0000ffff);
5793 }
5794 else
5795 {
5796 operands[2] = low_reg;
5797 operands[3] = high_reg;
5798 operands[4] = GEN_INT (low & 0xffff0000);
5799 operands[5] = GEN_INT (high);
5800 operands[6] = GEN_INT (low & 0x0000ffff);
5801 }
5802 }")
5803
5804 (define_split
5805 [(set (match_operand:DI 0 "gpc_reg_operand" "")
5806 (match_operand:DI 1 "const_double_operand" ""))]
5807 "TARGET_32BIT && reload_completed && num_insns_constant (operands[1], DImode) >= 4"
5808 [(set (match_dup 2) (match_dup 4))
5809 (set (match_dup 3) (match_dup 5))
5810 (set (match_dup 2) (ior:SI (match_dup 2) (match_dup 6)))
5811 (set (match_dup 3) (ior:SI (match_dup 3) (match_dup 7)))]
5812 "
5813 {
5814 HOST_WIDE_INT high = CONST_DOUBLE_HIGH (operands[1]);
5815 HOST_WIDE_INT low = CONST_DOUBLE_LOW (operands[1]);
5816
5817 operands[2] = gen_rtx (SUBREG, SImode, operands[0], WORDS_BIG_ENDIAN == 0);
5818 operands[3] = gen_rtx (SUBREG, SImode, operands[0], WORDS_BIG_ENDIAN != 0);
5819 operands[4] = GEN_INT (high & 0xffff0000);
5820 operands[5] = GEN_INT (low & 0xffff0000);
5821 operands[6] = GEN_INT (high & 0x0000ffff);
5822 operands[7] = GEN_INT (low & 0x0000ffff);
5823 }")
5824
5825 (define_insn ""
5826 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m,r,r,r,r,f,f,m,r,*h,*h")
5827 (match_operand:DI 1 "input_operand" "r,m,r,I,J,nF,R,f,m,f,*h,r,0"))]
5828 "TARGET_64BIT
5829 && (gpc_reg_operand (operands[0], DImode)
5830 || gpc_reg_operand (operands[1], DImode))"
5831 "@
5832 mr %0,%1
5833 ld%U1%X1 %0,%1
5834 std%U0%X0 %1,%0
5835 li %0,%1
5836 lis %0,%v1
5837 #
5838 {cal|la} %0,%1(%*)
5839 fmr %0,%1
5840 lfd%U1%X1 %0,%1
5841 stfd%U0%X0 %1,%0
5842 mf%1 %0
5843 mt%0 %1
5844 cror 0,0,0"
5845 [(set_attr "type" "*,load,store,*,*,*,*,fp,fpload,fpstore,*,mtjmpr,*")
5846 (set_attr "length" "4,4,4,4,4,20,4,4,4,4,4,4,4")])
5847
5848 ;; Split a load of a large constant into the appropriate five-instruction
5849 ;; sequence. The expansion in movdi tries to perform the minimum number of
5850 ;; steps, but here we have to handle anything in a constant number of insns.
5851
5852 (define_split
5853 [(set (match_operand:DI 0 "gpc_reg_operand" "")
5854 (match_operand:DI 1 "const_double_operand" ""))]
5855 "TARGET_64BIT && num_insns_constant (operands[1], DImode) > 1"
5856 [(set (match_dup 0)
5857 (match_dup 2))
5858 (set (match_dup 0)
5859 (ior:DI (match_dup 0)
5860 (match_dup 3)))
5861 (set (match_dup 0)
5862 (ashift:DI (match_dup 0)
5863 (const_int 32)))
5864 (set (match_dup 0)
5865 (ior:DI (match_dup 0)
5866 (match_dup 4)))
5867 (set (match_dup 0)
5868 (ior:DI (match_dup 0)
5869 (match_dup 5)))]
5870 "
5871 {
5872 HOST_WIDE_INT low;
5873 HOST_WIDE_INT high;
5874
5875 if (GET_CODE (operands[1]) == CONST_DOUBLE)
5876 {
5877 low = CONST_DOUBLE_LOW (operands[1]);
5878 high = CONST_DOUBLE_HIGH (operands[1]);
5879 }
5880 else
5881 #if HOST_BITS_PER_WIDE_INT == 32
5882 {
5883 low = INTVAL (operands[1]);
5884 high = (low < 0) ? ~0 : 0;
5885 }
5886 #else
5887 {
5888 low = INTVAL (operands[1]) & 0xffffffff;
5889 high = (HOST_WIDE_INT) INTVAL (operands[1]) >> 32;
5890 }
5891 #endif
5892
5893 if ((high + 0x8000) < 0x10000
5894 && ((low & 0xffff) == 0 || (low & (~ (HOST_WIDE_INT) 0xffff)) == 0))
5895 FAIL;
5896
5897 operands[2] = GEN_INT (high & (~ (HOST_WIDE_INT) 0xffff));
5898 operands[3] = GEN_INT (high & 0xffff);
5899 operands[4] = GEN_INT (low & (~ (HOST_WIDE_INT) 0xffff));
5900 operands[5] = GEN_INT (low & 0xffff);
5901 }")
5902
5903 (define_insn ""
5904 [(set (match_operand:CC 2 "cc_reg_operand" "=x")
5905 (compare:CC (match_operand:DI 1 "gpc_reg_operand" "r")
5906 (const_int 0)))
5907 (set (match_operand:DI 0 "gpc_reg_operand" "=r") (match_dup 1))]
5908 "TARGET_POWERPC64"
5909 "mr. %0,%1"
5910 [(set_attr "type" "compare")])
5911 \f
5912 ;; TImode is similar, except that we usually want to compute the address into
5913 ;; a register and use lsi/stsi (the exception is during reload). MQ is also
5914 ;; clobbered in stsi for POWER, so we need a SCRATCH for it.
5915 (define_expand "movti"
5916 [(parallel [(set (match_operand:TI 0 "general_operand" "")
5917 (match_operand:TI 1 "general_operand" ""))
5918 (clobber (scratch:SI))])]
5919 "TARGET_STRING || TARGET_POWERPC64"
5920 "
5921 {
5922 if (GET_CODE (operands[0]) == MEM)
5923 operands[1] = force_reg (TImode, operands[1]);
5924
5925 if (GET_CODE (operands[0]) == MEM
5926 && GET_CODE (XEXP (operands[0], 0)) != REG
5927 && ! reload_in_progress)
5928 operands[0] = change_address (operands[0], TImode,
5929 copy_addr_to_reg (XEXP (operands[0], 0)));
5930
5931 if (GET_CODE (operands[1]) == MEM
5932 && GET_CODE (XEXP (operands[1], 0)) != REG
5933 && ! reload_in_progress)
5934 operands[1] = change_address (operands[1], TImode,
5935 copy_addr_to_reg (XEXP (operands[1], 0)));
5936 }")
5937
5938 ;; We say that MQ is clobbered in the last alternative because the first
5939 ;; alternative would never get used otherwise since it would need a reload
5940 ;; while the 2nd alternative would not. We put memory cases first so they
5941 ;; are preferred. Otherwise, we'd try to reload the output instead of
5942 ;; giving the SCRATCH mq.
5943 (define_insn ""
5944 [(set (match_operand:TI 0 "reg_or_mem_operand" "=Q,m,????r,????r,????r")
5945 (match_operand:TI 1 "reg_or_mem_operand" "r,r,r,Q,m"))
5946 (clobber (match_scratch:SI 2 "=q,q#X,X,X,X"))]
5947 "TARGET_STRING && TARGET_POWER && ! TARGET_POWERPC64
5948 && (gpc_reg_operand (operands[0], TImode) || gpc_reg_operand (operands[1], TImode))"
5949 "*
5950 {
5951 switch (which_alternative)
5952 {
5953 default:
5954 abort ();
5955
5956 case 0:
5957 return \"{stsi|stswi} %1,%P0,16\";
5958
5959 case 1:
5960 return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\;{st|stw} %Y1,%Y0\;{st|stw} %Z1,%Z0\";
5961
5962 case 2:
5963 /* Normally copy registers with lowest numbered register copied first.
5964 But copy in the other order if the first register of the output
5965 is the second, third, or fourth register in the input. */
5966 if (REGNO (operands[0]) >= REGNO (operands[1]) + 1
5967 && REGNO (operands[0]) <= REGNO (operands[1]) + 3)
5968 return \"mr %Z0,%Z1\;mr %Y0,%Y1\;mr %L0,%L1\;mr %0,%1\";
5969 else
5970 return \"mr %0,%1\;mr %L0,%L1\;mr %Y0,%Y1\;mr %Z0,%Z1\";
5971 case 3:
5972 /* If the address is not used in the output, we can use lsi. Otherwise,
5973 fall through to generating four loads. */
5974 if (! reg_overlap_mentioned_p (operands[0], operands[1]))
5975 return \"{lsi|lswi} %0,%P1,16\";
5976 /* ... fall through ... */
5977 case 4:
5978 /* If the address register is the same as the register for the lowest-
5979 addressed word, load it last. Similarly for the next two words.
5980 Otherwise load lowest address to highest. */
5981 if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
5982 operands[1], 0))
5983 return \"{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %0,%1\";
5984 else if (refers_to_regno_p (REGNO (operands[0]) + 1,
5985 REGNO (operands[0]) + 2, operands[1], 0))
5986 return \"{l|lwz} %0,%1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %L0,%L1\";
5987 else if (refers_to_regno_p (REGNO (operands[0]) + 2,
5988 REGNO (operands[0]) + 3, operands[1], 0))
5989 return \"{l|lwz} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Z0,%Z1\;{l|lwz} %Y0,%Y1\";
5990 else
5991 return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\";
5992 }
5993 }"
5994 [(set_attr "type" "store,store,*,load,load")
5995 (set_attr "length" "*,16,16,*,16")])
5996
5997 (define_insn ""
5998 [(set (match_operand:TI 0 "reg_or_mem_operand" "=m,????r,????r")
5999 (match_operand:TI 1 "reg_or_mem_operand" "r,r,m"))
6000 (clobber (match_scratch:SI 2 "=X,X,X"))]
6001 "TARGET_STRING && !TARGET_POWER && ! TARGET_POWERPC64
6002 && (gpc_reg_operand (operands[0], TImode) || gpc_reg_operand (operands[1], TImode))"
6003 "*
6004 {
6005 switch (which_alternative)
6006 {
6007 default:
6008 abort ();
6009
6010 case 0:
6011 return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\;{st|stw} %Y1,%Y0\;{st|stw} %Z1,%Z0\";
6012
6013 case 1:
6014 /* Normally copy registers with lowest numbered register copied first.
6015 But copy in the other order if the first register of the output
6016 is the second, third, or fourth register in the input. */
6017 if (REGNO (operands[0]) >= REGNO (operands[1]) + 1
6018 && REGNO (operands[0]) <= REGNO (operands[1]) + 3)
6019 return \"mr %Z0,%Z1\;mr %Y0,%Y1\;mr %L0,%L1\;mr %0,%1\";
6020 else
6021 return \"mr %0,%1\;mr %L0,%L1\;mr %Y0,%Y1\;mr %Z0,%Z1\";
6022 case 2:
6023 /* If the address register is the same as the register for the lowest-
6024 addressed word, load it last. Similarly for the next two words.
6025 Otherwise load lowest address to highest. */
6026 if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
6027 operands[1], 0))
6028 return \"{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %0,%1\";
6029 else if (refers_to_regno_p (REGNO (operands[0]) + 1,
6030 REGNO (operands[0]) + 2, operands[1], 0))
6031 return \"{l|lwz} %0,%1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %L0,%L1\";
6032 else if (refers_to_regno_p (REGNO (operands[0]) + 2,
6033 REGNO (operands[0]) + 3, operands[1], 0))
6034 return \"{l|lwz} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Z0,%Z1\;{l|lwz} %Y0,%Y1\";
6035 else
6036 return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\";
6037 }
6038 }"
6039 [(set_attr "type" "store,*,load")
6040 (set_attr "length" "16,16,16")])
6041
6042 (define_insn ""
6043 [(set (match_operand:TI 0 "nonimmediate_operand" "=r,r,m")
6044 (match_operand:TI 1 "input_operand" "r,m,r"))]
6045 "TARGET_POWERPC64 && (gpc_reg_operand (operands[0], TImode)
6046 || gpc_reg_operand (operands[1], TImode))"
6047 "*
6048 {
6049 switch (which_alternative)
6050 {
6051 case 0:
6052 /* We normally copy the low-numbered register first. However, if
6053 the first register operand 0 is the same as the second register of
6054 operand 1, we must copy in the opposite order. */
6055 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
6056 return \"mr %L0,%L1\;mr %0,%1\";
6057 else
6058 return \"mr %0,%1\;mr %L0,%L1\";
6059 case 1:
6060 /* If the low-address word is used in the address, we must load it
6061 last. Otherwise, load it first. Note that we cannot have
6062 auto-increment in that case since the address register is known to be
6063 dead. */
6064 if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
6065 operands [1], 0))
6066 return \"ld %L0,%L1\;ld %0,%1\";
6067 else
6068 return \"ld%U1 %0,%1\;ld %L0,%L1\";
6069 case 2:
6070 return \"std%U0 %1,%0\;std %L1,%L0\";
6071 }
6072 }"
6073 [(set_attr "type" "*,load,store")
6074 (set_attr "length" "8,8,8")])
6075 \f
6076 (define_expand "load_multiple"
6077 [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
6078 (match_operand:SI 1 "" ""))
6079 (use (match_operand:SI 2 "" ""))])]
6080 "TARGET_STRING"
6081 "
6082 {
6083 int regno;
6084 int count;
6085 rtx from;
6086 int i;
6087
6088 /* Support only loading a constant number of fixed-point registers from
6089 memory and only bother with this if more than two; the machine
6090 doesn't support more than eight. */
6091 if (GET_CODE (operands[2]) != CONST_INT
6092 || INTVAL (operands[2]) <= 2
6093 || INTVAL (operands[2]) > 8
6094 || GET_CODE (operands[1]) != MEM
6095 || GET_CODE (operands[0]) != REG
6096 || REGNO (operands[0]) >= 32)
6097 FAIL;
6098
6099 count = INTVAL (operands[2]);
6100 regno = REGNO (operands[0]);
6101
6102 operands[3] = gen_rtx (PARALLEL, VOIDmode, rtvec_alloc (count));
6103 from = force_reg (SImode, XEXP (operands[1], 0));
6104
6105 for (i = 0; i < count; i++)
6106 XVECEXP (operands[3], 0, i)
6107 = gen_rtx (SET, VOIDmode, gen_rtx (REG, SImode, regno + i),
6108 gen_rtx (MEM, SImode, plus_constant (from, i * 4)));
6109 }")
6110
6111 (define_insn ""
6112 [(match_parallel 0 "load_multiple_operation"
6113 [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
6114 (mem:SI (match_operand:SI 2 "register_operand" "b")))])]
6115 "TARGET_STRING"
6116 "*
6117 {
6118 /* We have to handle the case where the pseudo used to contain the address
6119 is assigned to one of the output registers. */
6120 int i, j;
6121 int words = XVECLEN (operands[0], 0);
6122 rtx xop[10];
6123
6124 if (XVECLEN (operands[0], 0) == 1)
6125 return \"{l|lwz} %1,0(%2)\";
6126
6127 for (i = 0; i < words; i++)
6128 if (refers_to_regno_p (REGNO (operands[1]) + i,
6129 REGNO (operands[1]) + i + 1, operands[2], 0))
6130 {
6131 if (i == words-1)
6132 {
6133 xop[0] = operands[1];
6134 xop[1] = operands[2];
6135 xop[2] = GEN_INT (4 * (words-1));
6136 output_asm_insn (\"{lsi|lswi} %0,%1,%2\;{l|lwz} %1,%2(%1)\", xop);
6137 return \"\";
6138 }
6139 else if (i == 0)
6140 {
6141 xop[0] = operands[1];
6142 xop[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1);
6143 xop[2] = GEN_INT (4 * (words-1));
6144 output_asm_insn (\"{cal %0,4(%0)|addi %0,%0,4}\;{lsi|lswi} %1,%0,%2\;{l|lwz} %0,-4(%0)\", xop);
6145 return \"\";
6146 }
6147 else
6148 {
6149 for (j = 0; j < words; j++)
6150 if (j != i)
6151 {
6152 xop[0] = gen_rtx (REG, SImode, REGNO (operands[1]) + j);
6153 xop[1] = operands[2];
6154 xop[2] = GEN_INT (j * 4);
6155 output_asm_insn (\"{l|lwz} %0,%2(%1)\", xop);
6156 }
6157 xop[0] = operands[2];
6158 xop[1] = GEN_INT (i * 4);
6159 output_asm_insn (\"{l|lwz} %0,%1(%0)\", xop);
6160 return \"\";
6161 }
6162 }
6163
6164 return \"{lsi|lswi} %1,%2,%N0\";
6165 }"
6166 [(set_attr "type" "load")
6167 (set_attr "length" "32")])
6168
6169 \f
6170 (define_expand "store_multiple"
6171 [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
6172 (match_operand:SI 1 "" ""))
6173 (clobber (scratch:SI))
6174 (use (match_operand:SI 2 "" ""))])]
6175 "TARGET_STRING"
6176 "
6177 {
6178 int regno;
6179 int count;
6180 rtx to;
6181 int i;
6182
6183 /* Support only storing a constant number of fixed-point registers to
6184 memory and only bother with this if more than two; the machine
6185 doesn't support more than eight. */
6186 if (GET_CODE (operands[2]) != CONST_INT
6187 || INTVAL (operands[2]) <= 2
6188 || INTVAL (operands[2]) > 8
6189 || GET_CODE (operands[0]) != MEM
6190 || GET_CODE (operands[1]) != REG
6191 || REGNO (operands[1]) >= 32)
6192 FAIL;
6193
6194 count = INTVAL (operands[2]);
6195 regno = REGNO (operands[1]);
6196
6197 operands[3] = gen_rtx (PARALLEL, VOIDmode, rtvec_alloc (count + 1));
6198 to = force_reg (SImode, XEXP (operands[0], 0));
6199
6200 XVECEXP (operands[3], 0, 0)
6201 = gen_rtx (SET, VOIDmode, gen_rtx (MEM, SImode, to), operands[1]);
6202 XVECEXP (operands[3], 0, 1) = gen_rtx (CLOBBER, VOIDmode,
6203 gen_rtx (SCRATCH, SImode));
6204
6205 for (i = 1; i < count; i++)
6206 XVECEXP (operands[3], 0, i + 1)
6207 = gen_rtx (SET, VOIDmode,
6208 gen_rtx (MEM, SImode, plus_constant (to, i * 4)),
6209 gen_rtx (REG, SImode, regno + i));
6210 }")
6211
6212 (define_insn ""
6213 [(match_parallel 0 "store_multiple_operation"
6214 [(set (match_operand:SI 1 "indirect_operand" "=Q")
6215 (match_operand:SI 2 "gpc_reg_operand" "r"))
6216 (clobber (match_scratch:SI 3 "=q"))])]
6217 "TARGET_STRING && TARGET_POWER"
6218 "{stsi|stswi} %2,%P1,%O0"
6219 [(set_attr "type" "store")])
6220
6221 (define_insn ""
6222 [(match_parallel 0 "store_multiple_operation"
6223 [(set (mem:SI (match_operand:SI 1 "register_operand" "b"))
6224 (match_operand:SI 2 "gpc_reg_operand" "r"))
6225 (clobber (match_scratch:SI 3 "X"))])]
6226 "TARGET_STRING && !TARGET_POWER"
6227 "{stsi|stswi} %2,%1,%O0"
6228 [(set_attr "type" "store")])
6229
6230 \f
6231 ;; String/block move insn.
6232 ;; Argument 0 is the destination
6233 ;; Argument 1 is the source
6234 ;; Argument 2 is the length
6235 ;; Argument 3 is the alignment
6236
6237 (define_expand "movstrsi"
6238 [(parallel [(set (match_operand:BLK 0 "" "")
6239 (match_operand:BLK 1 "" ""))
6240 (use (match_operand:SI 2 "" ""))
6241 (use (match_operand:SI 3 "" ""))])]
6242 ""
6243 "
6244 {
6245 if (expand_block_move (operands))
6246 DONE;
6247 else
6248 FAIL;
6249 }")
6250
6251 ;; Move up to 32 bytes at a time. The fixed registers are needed because the
6252 ;; register allocator doesn't have a clue about allocating 8 word registers
6253 (define_expand "movstrsi_8reg"
6254 [(parallel [(set (match_operand 0 "" "")
6255 (match_operand 1 "" ""))
6256 (use (match_operand 2 "" ""))
6257 (use (match_operand 3 "" ""))
6258 (clobber (reg:SI 5))
6259 (clobber (reg:SI 6))
6260 (clobber (reg:SI 7))
6261 (clobber (reg:SI 8))
6262 (clobber (reg:SI 9))
6263 (clobber (reg:SI 10))
6264 (clobber (reg:SI 11))
6265 (clobber (reg:SI 12))
6266 (clobber (match_scratch:SI 4 ""))])]
6267 "TARGET_STRING"
6268 "")
6269
6270 (define_insn ""
6271 [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
6272 (mem:BLK (match_operand:SI 1 "register_operand" "b")))
6273 (use (match_operand:SI 2 "immediate_operand" "i"))
6274 (use (match_operand:SI 3 "immediate_operand" "i"))
6275 (clobber (match_operand:SI 4 "register_operand" "=r"))
6276 (clobber (reg:SI 6))
6277 (clobber (reg:SI 7))
6278 (clobber (reg:SI 8))
6279 (clobber (reg:SI 9))
6280 (clobber (reg:SI 10))
6281 (clobber (reg:SI 11))
6282 (clobber (reg:SI 12))
6283 (clobber (match_scratch:SI 5 "=q"))]
6284 "TARGET_STRING && TARGET_POWER
6285 && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32) || INTVAL (operands[2]) == 0)
6286 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
6287 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
6288 && REGNO (operands[4]) == 5"
6289 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
6290 [(set_attr "type" "load")
6291 (set_attr "length" "8")])
6292
6293 (define_insn ""
6294 [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
6295 (mem:BLK (match_operand:SI 1 "register_operand" "b")))
6296 (use (match_operand:SI 2 "immediate_operand" "i"))
6297 (use (match_operand:SI 3 "immediate_operand" "i"))
6298 (clobber (match_operand:SI 4 "register_operand" "=r"))
6299 (clobber (reg:SI 6))
6300 (clobber (reg:SI 7))
6301 (clobber (reg:SI 8))
6302 (clobber (reg:SI 9))
6303 (clobber (reg:SI 10))
6304 (clobber (reg:SI 11))
6305 (clobber (reg:SI 12))
6306 (clobber (match_scratch:SI 5 "X"))]
6307 "TARGET_STRING && !TARGET_POWER
6308 && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32) || INTVAL (operands[2]) == 0)
6309 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
6310 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
6311 && REGNO (operands[4]) == 5"
6312 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
6313 [(set_attr "type" "load")
6314 (set_attr "length" "8")])
6315
6316 ;; Move up to 24 bytes at a time. The fixed registers are needed because the
6317 ;; register allocator doesn't have a clue about allocating 6 word registers
6318 (define_expand "movstrsi_6reg"
6319 [(parallel [(set (match_operand 0 "" "")
6320 (match_operand 1 "" ""))
6321 (use (match_operand 2 "" ""))
6322 (use (match_operand 3 "" ""))
6323 (clobber (reg:SI 7))
6324 (clobber (reg:SI 8))
6325 (clobber (reg:SI 9))
6326 (clobber (reg:SI 10))
6327 (clobber (reg:SI 11))
6328 (clobber (reg:SI 12))
6329 (clobber (match_scratch:SI 4 ""))])]
6330 "TARGET_STRING"
6331 "")
6332
6333 (define_insn ""
6334 [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
6335 (mem:BLK (match_operand:SI 1 "register_operand" "b")))
6336 (use (match_operand:SI 2 "immediate_operand" "i"))
6337 (use (match_operand:SI 3 "immediate_operand" "i"))
6338 (clobber (match_operand:SI 4 "register_operand" "=r"))
6339 (clobber (reg:SI 8))
6340 (clobber (reg:SI 9))
6341 (clobber (reg:SI 10))
6342 (clobber (reg:SI 11))
6343 (clobber (reg:SI 12))
6344 (clobber (match_scratch:SI 5 "=q"))]
6345 "TARGET_STRING && TARGET_POWER
6346 && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24
6347 && (REGNO (operands[0]) < 7 || REGNO (operands[0]) > 12)
6348 && (REGNO (operands[1]) < 7 || REGNO (operands[1]) > 12)
6349 && REGNO (operands[4]) == 7"
6350 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
6351 [(set_attr "type" "load")
6352 (set_attr "length" "8")])
6353
6354 (define_insn ""
6355 [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
6356 (mem:BLK (match_operand:SI 1 "register_operand" "b")))
6357 (use (match_operand:SI 2 "immediate_operand" "i"))
6358 (use (match_operand:SI 3 "immediate_operand" "i"))
6359 (clobber (match_operand:SI 4 "register_operand" "=r"))
6360 (clobber (reg:SI 8))
6361 (clobber (reg:SI 9))
6362 (clobber (reg:SI 10))
6363 (clobber (reg:SI 11))
6364 (clobber (reg:SI 12))
6365 (clobber (match_scratch:SI 5 "X"))]
6366 "TARGET_STRING && !TARGET_POWER
6367 && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 32
6368 && (REGNO (operands[0]) < 7 || REGNO (operands[0]) > 12)
6369 && (REGNO (operands[1]) < 7 || REGNO (operands[1]) > 12)
6370 && REGNO (operands[4]) == 7"
6371 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
6372 [(set_attr "type" "load")
6373 (set_attr "length" "8")])
6374
6375 ;; Move up to 16 bytes at a time, using 4 fixed registers to avoid spill problems
6376 ;; with TImode
6377 (define_expand "movstrsi_4reg"
6378 [(parallel [(set (match_operand 0 "" "")
6379 (match_operand 1 "" ""))
6380 (use (match_operand 2 "" ""))
6381 (use (match_operand 3 "" ""))
6382 (clobber (reg:SI 9))
6383 (clobber (reg:SI 10))
6384 (clobber (reg:SI 11))
6385 (clobber (reg:SI 12))
6386 (clobber (match_scratch:SI 4 ""))])]
6387 "TARGET_STRING"
6388 "")
6389
6390 (define_insn ""
6391 [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
6392 (mem:BLK (match_operand:SI 1 "register_operand" "b")))
6393 (use (match_operand:SI 2 "immediate_operand" "i"))
6394 (use (match_operand:SI 3 "immediate_operand" "i"))
6395 (clobber (match_operand:SI 4 "register_operand" "=r"))
6396 (clobber (reg:SI 10))
6397 (clobber (reg:SI 11))
6398 (clobber (reg:SI 12))
6399 (clobber (match_scratch:SI 5 "=q"))]
6400 "TARGET_STRING && TARGET_POWER
6401 && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
6402 && (REGNO (operands[0]) < 9 || REGNO (operands[0]) > 12)
6403 && (REGNO (operands[1]) < 9 || REGNO (operands[1]) > 12)
6404 && REGNO (operands[4]) == 9"
6405 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
6406 [(set_attr "type" "load")
6407 (set_attr "length" "8")])
6408
6409 (define_insn ""
6410 [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
6411 (mem:BLK (match_operand:SI 1 "register_operand" "b")))
6412 (use (match_operand:SI 2 "immediate_operand" "i"))
6413 (use (match_operand:SI 3 "immediate_operand" "i"))
6414 (clobber (match_operand:SI 4 "register_operand" "=r"))
6415 (clobber (reg:SI 10))
6416 (clobber (reg:SI 11))
6417 (clobber (reg:SI 12))
6418 (clobber (match_scratch:SI 5 "X"))]
6419 "TARGET_STRING && !TARGET_POWER
6420 && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
6421 && (REGNO (operands[0]) < 9 || REGNO (operands[0]) > 12)
6422 && (REGNO (operands[1]) < 9 || REGNO (operands[1]) > 12)
6423 && REGNO (operands[4]) == 9"
6424 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
6425 [(set_attr "type" "load")
6426 (set_attr "length" "8")])
6427
6428 ;; Move up to 8 bytes at a time.
6429 (define_expand "movstrsi_2reg"
6430 [(parallel [(set (match_operand 0 "" "")
6431 (match_operand 1 "" ""))
6432 (use (match_operand 2 "" ""))
6433 (use (match_operand 3 "" ""))
6434 (clobber (match_scratch:DI 4 ""))
6435 (clobber (match_scratch:SI 5 ""))])]
6436 "TARGET_STRING && !TARGET_64BIT"
6437 "")
6438
6439 (define_insn ""
6440 [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
6441 (mem:BLK (match_operand:SI 1 "register_operand" "b")))
6442 (use (match_operand:SI 2 "immediate_operand" "i"))
6443 (use (match_operand:SI 3 "immediate_operand" "i"))
6444 (clobber (match_scratch:DI 4 "=&r"))
6445 (clobber (match_scratch:SI 5 "=q"))]
6446 "TARGET_STRING && TARGET_POWER && !TARGET_64BIT
6447 && INTVAL (operands[2]) > 4 && INTVAL (operands[2]) <= 8"
6448 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
6449 [(set_attr "type" "load")
6450 (set_attr "length" "8")])
6451
6452 (define_insn ""
6453 [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
6454 (mem:BLK (match_operand:SI 1 "register_operand" "b")))
6455 (use (match_operand:SI 2 "immediate_operand" "i"))
6456 (use (match_operand:SI 3 "immediate_operand" "i"))
6457 (clobber (match_scratch:DI 4 "=&r"))
6458 (clobber (match_scratch:SI 5 "X"))]
6459 "TARGET_STRING && !TARGET_POWER && !TARGET_64BIT
6460 && INTVAL (operands[2]) > 4 && INTVAL (operands[2]) <= 8"
6461 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
6462 [(set_attr "type" "load")
6463 (set_attr "length" "8")])
6464
6465 ;; Move up to 4 bytes at a time.
6466 (define_expand "movstrsi_1reg"
6467 [(parallel [(set (match_operand 0 "" "")
6468 (match_operand 1 "" ""))
6469 (use (match_operand 2 "" ""))
6470 (use (match_operand 3 "" ""))
6471 (clobber (match_scratch:SI 4 ""))
6472 (clobber (match_scratch:SI 5 ""))])]
6473 "TARGET_STRING"
6474 "")
6475
6476 (define_insn ""
6477 [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
6478 (mem:BLK (match_operand:SI 1 "register_operand" "b")))
6479 (use (match_operand:SI 2 "immediate_operand" "i"))
6480 (use (match_operand:SI 3 "immediate_operand" "i"))
6481 (clobber (match_scratch:SI 4 "=&r"))
6482 (clobber (match_scratch:SI 5 "=q"))]
6483 "TARGET_STRING && TARGET_POWER
6484 && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
6485 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
6486 [(set_attr "type" "load")
6487 (set_attr "length" "8")])
6488
6489 (define_insn ""
6490 [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
6491 (mem:BLK (match_operand:SI 1 "register_operand" "b")))
6492 (use (match_operand:SI 2 "immediate_operand" "i"))
6493 (use (match_operand:SI 3 "immediate_operand" "i"))
6494 (clobber (match_scratch:SI 4 "=&r"))
6495 (clobber (match_scratch:SI 5 "X"))]
6496 "TARGET_STRING && !TARGET_POWER
6497 && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
6498 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
6499 [(set_attr "type" "load")
6500 (set_attr "length" "8")])
6501
6502 \f
6503 ;; Define insns that do load or store with update. Some of these we can
6504 ;; get by using pre-decrement or pre-increment, but the hardware can also
6505 ;; do cases where the increment is not the size of the object.
6506 ;;
6507 ;; In all these cases, we use operands 0 and 1 for the register being
6508 ;; incremented because those are the operands that local-alloc will
6509 ;; tie and these are the pair most likely to be tieable (and the ones
6510 ;; that will benefit the most).
6511
6512 (define_insn ""
6513 [(set (match_operand:DI 3 "gpc_reg_operand" "=r,r")
6514 (mem:DI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0,0")
6515 (match_operand:DI 2 "reg_or_short_operand" "r,I"))))
6516 (set (match_operand:DI 0 "gpc_reg_operand" "=b,b")
6517 (plus:DI (match_dup 1) (match_dup 2)))]
6518 "TARGET_POWERPC64"
6519 "@
6520 ldux %3,%0,%2
6521 ldu %3,%2(%0)"
6522 [(set_attr "type" "load")])
6523
6524 (define_insn ""
6525 [(set (match_operand:DI 3 "gpc_reg_operand" "=r")
6526 (sign_extend:DI
6527 (mem:SI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0")
6528 (match_operand:DI 2 "gpc_reg_operand" "r")))))
6529 (set (match_operand:DI 0 "gpc_reg_operand" "=b")
6530 (plus:DI (match_dup 1) (match_dup 2)))]
6531 "TARGET_POWERPC64"
6532 "lwaux %3,%0,%2"
6533 [(set_attr "type" "load")])
6534
6535 (define_insn "movdi_update"
6536 [(set (mem:DI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0,0")
6537 (match_operand:DI 2 "reg_or_short_operand" "r,I")))
6538 (match_operand:DI 3 "gpc_reg_operand" "r,r"))
6539 (set (match_operand:DI 0 "gpc_reg_operand" "=b,b")
6540 (plus:DI (match_dup 1) (match_dup 2)))]
6541 "TARGET_POWERPC64"
6542 "@
6543 stdux %3,%0,%2
6544 stdu %3,%2(%0)"
6545 [(set_attr "type" "store")])
6546
6547 (define_insn ""
6548 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
6549 (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6550 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
6551 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6552 (plus:SI (match_dup 1) (match_dup 2)))]
6553 ""
6554 "@
6555 {lux|lwzux} %3,%0,%2
6556 {lu|lwzu} %3,%2(%0)"
6557 [(set_attr "type" "load")])
6558
6559 (define_insn "movsi_update"
6560 [(set (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6561 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
6562 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
6563 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6564 (plus:SI (match_dup 1) (match_dup 2)))]
6565 ""
6566 "@
6567 {stux|stwux} %3,%0,%2
6568 {stu|stwu} %3,%2(%0)"
6569 [(set_attr "type" "store")])
6570
6571 (define_insn ""
6572 [(set (match_operand:HI 3 "gpc_reg_operand" "=r,r")
6573 (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6574 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
6575 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6576 (plus:SI (match_dup 1) (match_dup 2)))]
6577 ""
6578 "@
6579 lhzux %3,%0,%2
6580 lhzu %3,%2(%0)"
6581 [(set_attr "type" "load")])
6582
6583 (define_insn ""
6584 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
6585 (zero_extend:SI
6586 (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6587 (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
6588 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6589 (plus:SI (match_dup 1) (match_dup 2)))]
6590 ""
6591 "@
6592 lhzux %3,%0,%2
6593 lhzu %3,%2(%0)"
6594 [(set_attr "type" "load")])
6595
6596 (define_insn ""
6597 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
6598 (sign_extend:SI
6599 (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6600 (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
6601 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6602 (plus:SI (match_dup 1) (match_dup 2)))]
6603 ""
6604 "@
6605 lhaux %3,%0,%2
6606 lhau %3,%2(%0)"
6607 [(set_attr "type" "load")])
6608
6609 (define_insn ""
6610 [(set (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6611 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
6612 (match_operand:HI 3 "gpc_reg_operand" "r,r"))
6613 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6614 (plus:SI (match_dup 1) (match_dup 2)))]
6615 ""
6616 "@
6617 sthux %3,%0,%2
6618 sthu %3,%2(%0)"
6619 [(set_attr "type" "store")])
6620
6621 (define_insn ""
6622 [(set (match_operand:QI 3 "gpc_reg_operand" "=r,r")
6623 (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6624 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
6625 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6626 (plus:SI (match_dup 1) (match_dup 2)))]
6627 ""
6628 "@
6629 lbzux %3,%0,%2
6630 lbzu %3,%2(%0)"
6631 [(set_attr "type" "load")])
6632
6633 (define_insn ""
6634 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
6635 (zero_extend:SI
6636 (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6637 (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
6638 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6639 (plus:SI (match_dup 1) (match_dup 2)))]
6640 ""
6641 "@
6642 lbzux %3,%0,%2
6643 lbzu %3,%2(%0)"
6644 [(set_attr "type" "load")])
6645
6646 (define_insn ""
6647 [(set (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6648 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
6649 (match_operand:QI 3 "gpc_reg_operand" "r,r"))
6650 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6651 (plus:SI (match_dup 1) (match_dup 2)))]
6652 ""
6653 "@
6654 stbux %3,%0,%2
6655 stbu %3,%2(%0)"
6656 [(set_attr "type" "store")])
6657
6658 (define_insn ""
6659 [(set (match_operand:SF 3 "gpc_reg_operand" "=f,f")
6660 (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6661 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
6662 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6663 (plus:SI (match_dup 1) (match_dup 2)))]
6664 "TARGET_HARD_FLOAT"
6665 "@
6666 lfsux %3,%0,%2
6667 lfsu %3,%2(%0)"
6668 [(set_attr "type" "fpload")])
6669
6670 (define_insn ""
6671 [(set (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6672 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
6673 (match_operand:SF 3 "gpc_reg_operand" "f,f"))
6674 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6675 (plus:SI (match_dup 1) (match_dup 2)))]
6676 "TARGET_HARD_FLOAT"
6677 "@
6678 stfsux %3,%0,%2
6679 stfsu %3,%2(%0)"
6680 [(set_attr "type" "fpstore")])
6681
6682 (define_insn ""
6683 [(set (match_operand:DF 3 "gpc_reg_operand" "=f,f")
6684 (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6685 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
6686 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6687 (plus:SI (match_dup 1) (match_dup 2)))]
6688 "TARGET_HARD_FLOAT"
6689 "@
6690 lfdux %3,%0,%2
6691 lfdu %3,%2(%0)"
6692 [(set_attr "type" "fpload")])
6693
6694 (define_insn ""
6695 [(set (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6696 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
6697 (match_operand:DF 3 "gpc_reg_operand" "f,f"))
6698 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6699 (plus:SI (match_dup 1) (match_dup 2)))]
6700 "TARGET_HARD_FLOAT"
6701 "@
6702 stfdux %3,%0,%2
6703 stfdu %3,%2(%0)"
6704 [(set_attr "type" "fpstore")])
6705
6706 ;; Peephole to convert two consecutive FP loads or stores into lfq/stfq.
6707
6708 (define_peephole
6709 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
6710 (match_operand:DF 1 "memory_operand" ""))
6711 (set (match_operand:DF 2 "gpc_reg_operand" "=f")
6712 (match_operand:DF 3 "memory_operand" ""))]
6713 "TARGET_POWER2
6714 && TARGET_HARD_FLOAT
6715 && registers_ok_for_quad_peep (operands[0], operands[2])
6716 && ! MEM_VOLATILE_P (operands[1]) && ! MEM_VOLATILE_P (operands[3])
6717 && addrs_ok_for_quad_peep (XEXP (operands[1], 0), XEXP (operands[3], 0))"
6718 "lfq%U1%X1 %0,%1")
6719
6720 (define_peephole
6721 [(set (match_operand:DF 0 "memory_operand" "")
6722 (match_operand:DF 1 "gpc_reg_operand" "f"))
6723 (set (match_operand:DF 2 "memory_operand" "")
6724 (match_operand:DF 3 "gpc_reg_operand" "f"))]
6725 "TARGET_POWER2
6726 && TARGET_HARD_FLOAT
6727 && registers_ok_for_quad_peep (operands[1], operands[3])
6728 && ! MEM_VOLATILE_P (operands[0]) && ! MEM_VOLATILE_P (operands[2])
6729 && addrs_ok_for_quad_peep (XEXP (operands[0], 0), XEXP (operands[2], 0))"
6730 "stfq%U0%X0 %1,%0")
6731 \f
6732 ;; Next come insns related to the calling sequence.
6733 ;;
6734 ;; First, an insn to allocate new stack space for dynamic use (e.g., alloca).
6735 ;; We move the back-chain and decrement the stack pointer.
6736
6737 (define_expand "allocate_stack"
6738 [(set (reg:SI 1)
6739 (minus:SI (reg:SI 1) (match_operand:SI 0 "reg_or_short_operand" "")))]
6740 ""
6741 "
6742 { rtx chain = gen_reg_rtx (Pmode);
6743 rtx stack_bot = gen_rtx (MEM, Pmode, stack_pointer_rtx);
6744 rtx neg_op0;
6745
6746 emit_move_insn (chain, stack_bot);
6747
6748 /* Under Windows NT, we need to add stack probes for large/variable allocations,
6749 so do it via a call to the external function alloca, instead of doing it
6750 inline. */
6751 if (DEFAULT_ABI == ABI_NT
6752 && (GET_CODE (operands[0]) != CONST_INT || INTVAL (operands[0]) > 4096))
6753 {
6754 rtx tmp = gen_reg_rtx (SImode);
6755 emit_library_call_value (gen_rtx (SYMBOL_REF, Pmode, \"__allocate_stack\"),
6756 tmp, 0, SImode, 1, operands[0], Pmode);
6757 emit_insn (gen_set_sp (tmp));
6758 DONE;
6759 }
6760
6761 if (GET_CODE (operands[0]) != CONST_INT
6762 || INTVAL (operands[0]) < -32767
6763 || INTVAL (operands[0]) > 32768)
6764 {
6765 neg_op0 = gen_reg_rtx (Pmode);
6766 if (TARGET_32BIT)
6767 emit_insn (gen_negsi2 (neg_op0, operands[0]));
6768 else
6769 emit_insn (gen_negdi2 (neg_op0, operands[0]));
6770 }
6771 else
6772 neg_op0 = GEN_INT (- INTVAL (operands[0]));
6773
6774 if (TARGET_32BIT)
6775 emit_insn (gen_movsi_update (stack_pointer_rtx, stack_pointer_rtx, neg_op0, chain));
6776 else
6777 emit_insn (gen_movdi_update (stack_pointer_rtx, stack_pointer_rtx, neg_op0, chain));
6778
6779 DONE;
6780 }")
6781
6782 ;; Marker to indicate that the stack pointer was changed under NT in
6783 ;; ways not known to the compiler
6784
6785 (define_insn "set_sp"
6786 [(set (reg:SI 1)
6787 (unspec [(match_operand:SI 0 "register_operand" "r")] 7))]
6788 ""
6789 ""
6790 [(set_attr "length" "0")])
6791
6792 ;; These patterns say how to save and restore the stack pointer. We need not
6793 ;; save the stack pointer at function level since we are careful to
6794 ;; preserve the backchain. At block level, we have to restore the backchain
6795 ;; when we restore the stack pointer.
6796 ;;
6797 ;; For nonlocal gotos, we must save both the stack pointer and its
6798 ;; backchain and restore both. Note that in the nonlocal case, the
6799 ;; save area is a memory location.
6800
6801 (define_expand "save_stack_function"
6802 [(use (const_int 0))]
6803 ""
6804 "")
6805
6806 (define_expand "restore_stack_function"
6807 [(use (const_int 0))]
6808 ""
6809 "")
6810
6811 (define_expand "restore_stack_block"
6812 [(set (match_dup 2) (mem:SI (match_operand:SI 0 "register_operand" "")))
6813 (set (match_dup 0) (match_operand:SI 1 "register_operand" ""))
6814 (set (mem:SI (match_dup 0)) (match_dup 2))]
6815 ""
6816 "
6817 { operands[2] = gen_reg_rtx (SImode); }")
6818
6819 (define_expand "save_stack_nonlocal"
6820 [(match_operand:DI 0 "memory_operand" "")
6821 (match_operand:SI 1 "register_operand" "")]
6822 ""
6823 "
6824 {
6825 rtx temp = gen_reg_rtx (SImode);
6826
6827 /* Copy the backchain to the first word, sp to the second. */
6828 emit_move_insn (temp, gen_rtx (MEM, SImode, operands[1]));
6829 emit_move_insn (operand_subword (operands[0], 0, 0, DImode), temp);
6830 emit_move_insn (operand_subword (operands[0], 1, 0, DImode), operands[1]);
6831 DONE;
6832 }")
6833
6834 (define_expand "restore_stack_nonlocal"
6835 [(match_operand:SI 0 "register_operand" "")
6836 (match_operand:DI 1 "memory_operand" "")]
6837 ""
6838 "
6839 {
6840 rtx temp = gen_reg_rtx (SImode);
6841
6842 /* Restore the backchain from the first word, sp from the second. */
6843 emit_move_insn (temp, operand_subword (operands[1], 0, 0, DImode));
6844 emit_move_insn (operands[0], operand_subword (operands[1], 1, 0, DImode));
6845 emit_move_insn (gen_rtx (MEM, SImode, operands[0]), temp);
6846 DONE;
6847 }")
6848
6849 \f
6850 ;; A function pointer under AIX is a pointer to a data area whose first word
6851 ;; contains the actual address of the function, whose second word contains a
6852 ;; pointer to its TOC, and whose third word contains a value to place in the
6853 ;; static chain register (r11). Note that if we load the static chain, our
6854 ;; "trampoline" need not have any executable code.
6855 ;;
6856 ;; operands[0] is a register pointing to the 3 word descriptor (aka, the function address)
6857 ;; operands[1] is the stack size to clean up
6858 ;; operands[2] is the value FUNCTION_ARG returns for the VOID argument (must be 0 for AIX)
6859 ;; operands[3] is location to store the TOC
6860 ;; operands[4] is the TOC register
6861 ;; operands[5] is the static chain register
6862 ;;
6863 ;; We do not break this into separate insns, so that the scheduler will not try
6864 ;; to move the load of the new TOC before any loads from the TOC.
6865
6866 (define_insn "call_indirect_aix"
6867 [(call (mem:SI (match_operand:SI 0 "register_operand" "b"))
6868 (match_operand 1 "const_int_operand" "n"))
6869 (use (match_operand 2 "const_int_operand" "n"))
6870 (use (match_operand 3 "offsettable_addr_operand" "p"))
6871 (use (match_operand 4 "register_operand" "r"))
6872 (clobber (match_operand 5 "register_operand" "=r"))
6873 (clobber (match_scratch:SI 6 "=&r"))
6874 (clobber (match_scratch:SI 7 "=l"))]
6875 "DEFAULT_ABI == ABI_AIX
6876 && (INTVAL (operands[2]) == CALL_NORMAL || (INTVAL (operands[2]) & CALL_LONG) != 0)"
6877 "{st|stw} %4,%a3\;{l|lwz} %6,0(%0)\;{l|lwz} %4,4(%0)\;mt%7 %6\;{l|lwz} %5,8(%0)\;{brl|blrl}\;{l|lwz} %4,%a3"
6878 [(set_attr "type" "load")
6879 (set_attr "length" "28")])
6880
6881 (define_insn "call_value_indirect_aix"
6882 [(set (match_operand 0 "register_operand" "fg")
6883 (call (mem:SI (match_operand:SI 1 "register_operand" "b"))
6884 (match_operand 2 "const_int_operand" "n")))
6885 (use (match_operand 3 "const_int_operand" "n"))
6886 (use (match_operand 4 "offsettable_addr_operand" "p"))
6887 (use (match_operand 5 "register_operand" "r"))
6888 (clobber (match_operand 6 "register_operand" "=r"))
6889 (clobber (match_scratch:SI 7 "=&r"))
6890 (clobber (match_scratch:SI 8 "=l"))]
6891 "DEFAULT_ABI == ABI_AIX
6892 && (INTVAL (operands[3]) == CALL_NORMAL || (INTVAL (operands[3]) & CALL_LONG) != 0)"
6893 "{st|stw} %5,%a4\;{l|lwz} %7,0(%1)\;{l|lwz} %5,4(%1);\;mt%8 %7\;{l|lwz} %6,8(%1)\;{brl|blrl}\;{l|lwz} %5,%a4"
6894 [(set_attr "type" "load")
6895 (set_attr "length" "28")])
6896
6897 ;; A function pointer undef NT is a pointer to a data area whose first word
6898 ;; contains the actual address of the function, whose second word contains a
6899 ;; pointer to its TOC. The static chain is not stored under NT, which means
6900 ;; that we need a trampoline.
6901 ;;
6902 ;; operands[0] is an SImode pseudo in which we place the address of the function.
6903 ;; operands[1] is the stack size to clean up
6904 ;; operands[2] is the value FUNCTION_ARG returns for the VOID argument (must be 0 for NT)
6905 ;; operands[3] is location to store the TOC
6906 ;; operands[4] is the TOC register
6907 ;;
6908 ;; We do not break this into separate insns, so that the scheduler will not try
6909 ;; to move the load of the new TOC before any loads from the TOC.
6910
6911 (define_insn "call_indirect_nt"
6912 [(call (mem:SI (match_operand:SI 0 "register_operand" "b"))
6913 (match_operand 1 "const_int_operand" "n"))
6914 (use (match_operand 2 "const_int_operand" "n"))
6915 (use (match_operand 3 "offsettable_addr_operand" "p"))
6916 (use (match_operand 4 "register_operand" "r"))
6917 (clobber (match_scratch:SI 5 "=&r"))
6918 (clobber (match_scratch:SI 6 "=l"))]
6919 "DEFAULT_ABI == ABI_NT
6920 && (INTVAL (operands[2]) == CALL_NORMAL || (INTVAL (operands[2]) & CALL_LONG) != 0)"
6921 "{st|stw} %4,%a3\;{l|lwz} %5,0(%0)\;{l|lwz} %4,4(%0)\;mt%6 %5\;{brl|blrl}\;{l|lwz} %4,%a3"
6922 [(set_attr "type" "load")
6923 (set_attr "length" "24")])
6924
6925 (define_insn "call_value_indirect_nt"
6926 [(set (match_operand 0 "register_operand" "fg")
6927 (call (mem:SI (match_operand:SI 1 "register_operand" "b"))
6928 (match_operand 2 "const_int_operand" "n")))
6929 (use (match_operand 3 "const_int_operand" "n"))
6930 (use (match_operand 4 "offsettable_addr_operand" "p"))
6931 (use (match_operand 5 "register_operand" "r"))
6932 (clobber (match_scratch:SI 6 "=&r"))
6933 (clobber (match_scratch:SI 7 "=l"))]
6934 "DEFAULT_ABI == ABI_NT
6935 && (INTVAL (operands[3]) == CALL_NORMAL || (INTVAL (operands[3]) & CALL_LONG) != 0)"
6936 "{st|stw} %5,%a4\;{l|lwz} %6,0(%1)\;{l|lwz} %5,4(%1)\;mt%7 %6\;{brl|blrl}\;{l|lwz} %5,%a4"
6937 [(set_attr "type" "load")
6938 (set_attr "length" "24")])
6939
6940 ;; A function pointer under System V is just a normal pointer
6941 ;; operands[0] is the function pointer
6942 ;; operands[1] is the stack size to clean up
6943 ;; operands[2] is the value FUNCTION_ARG returns for the VOID argument which indicates how to set cr1
6944
6945 (define_insn "call_indirect_sysv"
6946 [(call (mem:SI (match_operand:SI 0 "register_operand" "l,l"))
6947 (match_operand 1 "const_int_operand" "n,n"))
6948 (use (match_operand 2 "const_int_operand" "O,n"))
6949 (clobber (match_scratch:SI 3 "=l,l"))]
6950 "DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_SOLARIS || DEFAULT_ABI == ABI_AIX_NODESC"
6951 "*
6952 {
6953 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
6954 output_asm_insn (\"crxor 6,6,6\", operands);
6955
6956 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
6957 output_asm_insn (\"creqv 6,6,6\", operands);
6958
6959 return \"{brl|blrl}\";
6960 }"
6961 [(set_attr "type" "jmpreg")
6962 (set_attr "length" "4,8")])
6963
6964 (define_insn "call_value_indirect_sysv"
6965 [(set (match_operand 0 "register_operand" "=fg,fg")
6966 (call (mem:SI (match_operand:SI 1 "register_operand" "l,l"))
6967 (match_operand 2 "const_int_operand" "n,n")))
6968 (use (match_operand 3 "const_int_operand" "O,n"))
6969 (clobber (match_scratch:SI 4 "=l,l"))]
6970 "DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_SOLARIS || DEFAULT_ABI == ABI_AIX_NODESC"
6971 "*
6972 {
6973 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
6974 output_asm_insn (\"crxor 6,6,6\", operands);
6975
6976 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
6977 output_asm_insn (\"creqv 6,6,6\", operands);
6978
6979 return \"{brl|blrl}\";
6980 }"
6981 [(set_attr "type" "jmpreg")
6982 (set_attr "length" "4,8")])
6983
6984 ;; Now the definitions for the call and call_value insns
6985 (define_expand "call"
6986 [(parallel [(call (mem:SI (match_operand:SI 0 "address_operand" ""))
6987 (match_operand 1 "" ""))
6988 (use (match_operand 2 "" ""))
6989 (clobber (scratch:SI))])]
6990 ""
6991 "
6992 {
6993 if (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != CONST_INT)
6994 abort ();
6995
6996 operands[0] = XEXP (operands[0], 0);
6997
6998 /* Convert NT DLL imports into an indirect call. */
6999 if (GET_CODE (operands[0]) == SYMBOL_REF
7000 && (INTVAL (operands[2]) & CALL_NT_DLLIMPORT) != 0)
7001 {
7002 operands[0] = rs6000_dll_import_ref (operands[0]);
7003 operands[2] = GEN_INT ((int)CALL_NORMAL);
7004 }
7005
7006 if (GET_CODE (operands[0]) != SYMBOL_REF
7007 || (INTVAL (operands[2]) & CALL_LONG) != 0)
7008 {
7009 if (INTVAL (operands[2]) & CALL_LONG)
7010 operands[0] = rs6000_longcall_ref (operands[0]);
7011
7012 if (DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_AIX_NODESC || DEFAULT_ABI == ABI_SOLARIS)
7013 emit_call_insn (gen_call_indirect_sysv (force_reg (Pmode, operands[0]),
7014 operands[1], operands[2]));
7015 else
7016 {
7017 rtx toc_reg = gen_rtx (REG, Pmode, 2);
7018 rtx toc_addr = RS6000_SAVE_TOC;
7019
7020 if (DEFAULT_ABI == ABI_AIX)
7021 {
7022 /* AIX function pointers are really pointers to a three word area */
7023 rtx static_chain = gen_rtx (REG, Pmode, STATIC_CHAIN_REGNUM);
7024 emit_call_insn (gen_call_indirect_aix (force_reg (Pmode, operands[0]),
7025 operands[1], operands[2],
7026 toc_addr, toc_reg, static_chain));
7027 }
7028 else if (DEFAULT_ABI == ABI_NT)
7029 {
7030 /* NT function pointers are really pointers to a two word area */
7031 rs6000_save_toc_p = 1;
7032 emit_call_insn (gen_call_indirect_nt (force_reg (Pmode, operands[0]),
7033 operands[1], operands[2],
7034 toc_addr, toc_reg));
7035 }
7036 else
7037 abort ();
7038 }
7039 DONE;
7040 }
7041 }")
7042
7043 (define_expand "call_value"
7044 [(parallel [(set (match_operand 0 "" "")
7045 (call (mem:SI (match_operand:SI 1 "address_operand" ""))
7046 (match_operand 2 "" "")))
7047 (use (match_operand 3 "" ""))
7048 (clobber (scratch:SI))])]
7049 ""
7050 "
7051 {
7052 if (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != CONST_INT)
7053 abort ();
7054
7055 operands[1] = XEXP (operands[1], 0);
7056
7057 /* Convert NT DLL imports into an indirect call. */
7058 if (GET_CODE (operands[1]) == SYMBOL_REF
7059 && (INTVAL (operands[3]) & CALL_NT_DLLIMPORT) != 0)
7060 {
7061 operands[1] = rs6000_dll_import_ref (operands[1]);
7062 operands[3] = GEN_INT ((int)CALL_NORMAL);
7063 }
7064
7065 if (GET_CODE (operands[1]) != SYMBOL_REF
7066 || (INTVAL (operands[3]) & CALL_LONG) != 0)
7067 {
7068 if (INTVAL (operands[2]) & CALL_LONG)
7069 operands[1] = rs6000_longcall_ref (operands[1]);
7070
7071 if (DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_AIX_NODESC || DEFAULT_ABI == ABI_SOLARIS)
7072 emit_call_insn (gen_call_value_indirect_sysv (operands[0], operands[1],
7073 operands[2], operands[3]));
7074 else
7075 {
7076 rtx toc_reg = gen_rtx (REG, Pmode, 2);
7077 rtx toc_addr = RS6000_SAVE_TOC;
7078
7079 if (DEFAULT_ABI == ABI_AIX)
7080 {
7081 /* AIX function pointers are really pointers to a three word area */
7082 rtx static_chain = gen_rtx (REG, Pmode, STATIC_CHAIN_REGNUM);
7083 emit_call_insn (gen_call_value_indirect_aix (operands[0],
7084 force_reg (Pmode, operands[1]),
7085 operands[2], operands[3],
7086 toc_addr, toc_reg, static_chain));
7087 }
7088 else if (DEFAULT_ABI == ABI_NT)
7089 {
7090 /* NT function pointers are really pointers to a two word area */
7091 rs6000_save_toc_p = 1;
7092 emit_call_insn (gen_call_value_indirect_nt (operands[0],
7093 force_reg (Pmode, operands[1]),
7094 operands[2], operands[3],
7095 toc_addr, toc_reg));
7096 }
7097 else
7098 abort ();
7099 }
7100 DONE;
7101 }
7102 }")
7103
7104 ;; Call to function in current module. No TOC pointer reload needed.
7105 ;; Operand2 is non-zero if we are using the V.4 calling sequence and
7106 ;; either the function was not prototyped, or it was prototyped as a
7107 ;; variable argument function. It is > 0 if FP registers were passed
7108 ;; and < 0 if they were not.
7109
7110 (define_insn ""
7111 [(call (mem:SI (match_operand:SI 0 "current_file_function_operand" "s,s"))
7112 (match_operand 1 "" "g,g"))
7113 (use (match_operand:SI 2 "immediate_operand" "O,n"))
7114 (clobber (match_scratch:SI 3 "=l,l"))]
7115 "(INTVAL (operands[2]) & CALL_LONG) == 0"
7116 "*
7117 {
7118 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
7119 output_asm_insn (\"crxor 6,6,6\", operands);
7120
7121 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
7122 output_asm_insn (\"creqv 6,6,6\", operands);
7123
7124 return \"bl %z0\";
7125 }"
7126 [(set_attr "type" "branch")
7127 (set_attr "length" "4,8")])
7128
7129 ;; Call to function which may be in another module. Restore the TOC
7130 ;; pointer (r2) after the call unless this is System V.
7131 ;; Operand2 is non-zero if we are using the V.4 calling sequence and
7132 ;; either the function was not prototyped, or it was prototyped as a
7133 ;; variable argument function. It is > 0 if FP registers were passed
7134 ;; and < 0 if they were not.
7135
7136 (define_insn ""
7137 [(call (mem:SI (match_operand:SI 0 "call_operand" "s,s"))
7138 (match_operand 1 "" "fg,fg"))
7139 (use (match_operand:SI 2 "immediate_operand" "O,n"))
7140 (clobber (match_scratch:SI 3 "=l,l"))]
7141 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_NT)
7142 && (INTVAL (operands[2]) & CALL_LONG) == 0"
7143 "*
7144 {
7145 /* Indirect calls should go through call_indirect */
7146 if (GET_CODE (operands[0]) == REG)
7147 abort ();
7148
7149 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
7150 output_asm_insn (\"crxor 6,6,6\", operands);
7151
7152 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
7153 output_asm_insn (\"creqv 6,6,6\", operands);
7154
7155 return (TARGET_WINDOWS_NT) ? \"bl %z0\;.znop %z0\" : \"bl %z0\;%.\";
7156 }"
7157 [(set_attr "type" "branch")
7158 (set_attr "length" "8,12")])
7159
7160 (define_insn ""
7161 [(call (mem:SI (match_operand:SI 0 "call_operand" "s,s"))
7162 (match_operand 1 "" "fg,fg"))
7163 (use (match_operand:SI 2 "immediate_operand" "O,n"))
7164 (clobber (match_scratch:SI 3 "=l,l"))]
7165 "(DEFAULT_ABI == ABI_AIX_NODESC || DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_SOLARIS)
7166 && (INTVAL (operands[2]) & CALL_LONG) == 0"
7167 "*
7168 {
7169 /* Indirect calls should go through call_indirect */
7170 if (GET_CODE (operands[0]) == REG)
7171 abort ();
7172
7173 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
7174 output_asm_insn (\"crxor 6,6,6\", operands);
7175
7176 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
7177 output_asm_insn (\"creqv 6,6,6\", operands);
7178
7179 return \"bl %z0\";
7180 }"
7181 [(set_attr "type" "branch")
7182 (set_attr "length" "4,8")])
7183
7184 (define_insn ""
7185 [(set (match_operand 0 "" "=fg,fg")
7186 (call (mem:SI (match_operand:SI 1 "current_file_function_operand" "s,s"))
7187 (match_operand 2 "" "g,g")))
7188 (use (match_operand:SI 3 "immediate_operand" "O,n"))
7189 (clobber (match_scratch:SI 4 "=l,l"))]
7190 "(INTVAL (operands[3]) & CALL_LONG) == 0"
7191 "*
7192 {
7193 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
7194 output_asm_insn (\"crxor 6,6,6\", operands);
7195
7196 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
7197 output_asm_insn (\"creqv 6,6,6\", operands);
7198
7199 return \"bl %z1\";
7200 }"
7201 [(set_attr "type" "branch")
7202 (set_attr "length" "4,8")])
7203
7204 (define_insn ""
7205 [(set (match_operand 0 "" "=fg,fg")
7206 (call (mem:SI (match_operand:SI 1 "call_operand" "s,s"))
7207 (match_operand 2 "" "fg,fg")))
7208 (use (match_operand:SI 3 "immediate_operand" "O,n"))
7209 (clobber (match_scratch:SI 4 "=l,l"))]
7210 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_NT)
7211 && (INTVAL (operands[3]) & CALL_LONG) == 0"
7212 "*
7213 {
7214 /* This should be handled by call_value_indirect */
7215 if (GET_CODE (operands[1]) == REG)
7216 abort ();
7217
7218 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
7219 output_asm_insn (\"crxor 6,6,6\", operands);
7220
7221 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
7222 output_asm_insn (\"creqv 6,6,6\", operands);
7223
7224 return (TARGET_WINDOWS_NT) ? \"bl %z1\;.znop %z1\" : \"bl %z1\;%.\";
7225 }"
7226 [(set_attr "type" "branch")
7227 (set_attr "length" "8,12")])
7228
7229 (define_insn ""
7230 [(set (match_operand 0 "" "=fg,fg")
7231 (call (mem:SI (match_operand:SI 1 "call_operand" "s,s"))
7232 (match_operand 2 "" "fg,fg")))
7233 (use (match_operand:SI 3 "immediate_operand" "O,n"))
7234 (clobber (match_scratch:SI 4 "=l,l"))]
7235 "(DEFAULT_ABI == ABI_AIX_NODESC || DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_SOLARIS)
7236 && (INTVAL (operands[3]) & CALL_LONG) == 0"
7237 "*
7238 {
7239 /* This should be handled by call_value_indirect */
7240 if (GET_CODE (operands[1]) == REG)
7241 abort ();
7242
7243 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
7244 output_asm_insn (\"crxor 6,6,6\", operands);
7245
7246 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
7247 output_asm_insn (\"creqv 6,6,6\", operands);
7248
7249 return \"bl %z1\";
7250 }"
7251 [(set_attr "type" "branch")
7252 (set_attr "length" "4,8")])
7253
7254 ;; Call subroutine returning any type.
7255 (define_expand "untyped_call"
7256 [(parallel [(call (match_operand 0 "" "")
7257 (const_int 0))
7258 (match_operand 1 "" "")
7259 (match_operand 2 "" "")])]
7260 ""
7261 "
7262 {
7263 int i;
7264
7265 emit_call_insn (gen_call (operands[0], const0_rtx, const0_rtx, const0_rtx));
7266
7267 for (i = 0; i < XVECLEN (operands[2], 0); i++)
7268 {
7269 rtx set = XVECEXP (operands[2], 0, i);
7270 emit_move_insn (SET_DEST (set), SET_SRC (set));
7271 }
7272
7273 /* The optimizer does not know that the call sets the function value
7274 registers we stored in the result block. We avoid problems by
7275 claiming that all hard registers are used and clobbered at this
7276 point. */
7277 emit_insn (gen_blockage ());
7278
7279 DONE;
7280 }")
7281
7282 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
7283 ;; all of memory. This blocks insns from being moved across this point.
7284
7285 (define_insn "blockage"
7286 [(unspec_volatile [(const_int 0)] 0)]
7287 ""
7288 "")
7289
7290 ;; Synchronize instructions/data caches for V.4 trampolines
7291 ;; The extra memory_operand is to prevent the optimizer from
7292 ;; deleting insns with "no" effect.
7293 (define_insn "icbi"
7294 [(unspec [(match_operand 0 "memory_operand" "=m")
7295 (match_operand 1 "register_operand" "b")
7296 (match_operand 2 "register_operand" "r")] 3)]
7297 "TARGET_POWERPC"
7298 "icbi %1,%2")
7299
7300 (define_insn "dcbst"
7301 [(unspec [(match_operand 0 "memory_operand" "=m")
7302 (match_operand 1 "register_operand" "b")
7303 (match_operand 2 "register_operand" "r")] 4)]
7304 "TARGET_POWERPC"
7305 "dcbst %1,%2")
7306
7307 (define_insn "sync"
7308 [(unspec [(match_operand 0 "memory_operand" "=m")] 5)]
7309 ""
7310 "{dcs|sync}")
7311
7312 (define_insn "isync"
7313 [(unspec [(match_operand 0 "memory_operand" "=m")] 6)]
7314 ""
7315 "{ics|isync}")
7316
7317
7318 ;; V.4 specific code to initialize the PIC register
7319
7320 (define_insn "init_v4_pic"
7321 [(set (match_operand:SI 0 "register_operand" "=l")
7322 (unspec [(const_int 0)] 7))]
7323 "DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_SOLARIS"
7324 "bl _GLOBAL_OFFSET_TABLE_-4"
7325 [(set_attr "type" "branch")])
7326
7327 \f
7328 ;; Compare insns are next. Note that the RS/6000 has two types of compares,
7329 ;; signed & unsigned, and one type of branch.
7330 ;;
7331 ;; Start with the DEFINE_EXPANDs to generate the rtl for compares, scc
7332 ;; insns, and branches. We store the operands of compares until we see
7333 ;; how it is used.
7334 (define_expand "cmpsi"
7335 [(set (cc0)
7336 (compare (match_operand:SI 0 "gpc_reg_operand" "")
7337 (match_operand:SI 1 "reg_or_short_operand" "")))]
7338 ""
7339 "
7340 {
7341 /* Take care of the possibility that operands[1] might be negative but
7342 this might be a logical operation. That insn doesn't exist. */
7343 if (GET_CODE (operands[1]) == CONST_INT
7344 && INTVAL (operands[1]) < 0)
7345 operands[1] = force_reg (SImode, operands[1]);
7346
7347 rs6000_compare_op0 = operands[0];
7348 rs6000_compare_op1 = operands[1];
7349 rs6000_compare_fp_p = 0;
7350 DONE;
7351 }")
7352
7353 (define_expand "cmpdi"
7354 [(set (cc0)
7355 (compare (match_operand:DI 0 "gpc_reg_operand" "")
7356 (match_operand:DI 1 "reg_or_short_operand" "")))]
7357 "TARGET_POWERPC64"
7358 "
7359 {
7360 /* Take care of the possibility that operands[1] might be negative but
7361 this might be a logical operation. That insn doesn't exist. */
7362 if (GET_CODE (operands[1]) == CONST_INT
7363 && INTVAL (operands[1]) < 0)
7364 operands[1] = force_reg (DImode, operands[1]);
7365
7366 rs6000_compare_op0 = operands[0];
7367 rs6000_compare_op1 = operands[1];
7368 rs6000_compare_fp_p = 0;
7369 DONE;
7370 }")
7371
7372 (define_expand "cmpsf"
7373 [(set (cc0) (compare (match_operand:SF 0 "gpc_reg_operand" "")
7374 (match_operand:SF 1 "gpc_reg_operand" "")))]
7375 "TARGET_HARD_FLOAT"
7376 "
7377 {
7378 rs6000_compare_op0 = operands[0];
7379 rs6000_compare_op1 = operands[1];
7380 rs6000_compare_fp_p = 1;
7381 DONE;
7382 }")
7383
7384 (define_expand "cmpdf"
7385 [(set (cc0) (compare (match_operand:DF 0 "gpc_reg_operand" "")
7386 (match_operand:DF 1 "gpc_reg_operand" "")))]
7387 "TARGET_HARD_FLOAT"
7388 "
7389 {
7390 rs6000_compare_op0 = operands[0];
7391 rs6000_compare_op1 = operands[1];
7392 rs6000_compare_fp_p = 1;
7393 DONE;
7394 }")
7395
7396 (define_expand "beq"
7397 [(set (match_dup 2) (match_dup 1))
7398 (set (pc)
7399 (if_then_else (eq (match_dup 2)
7400 (const_int 0))
7401 (label_ref (match_operand 0 "" ""))
7402 (pc)))]
7403 ""
7404 "
7405 { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
7406 operands[1] = gen_rtx (COMPARE, mode,
7407 rs6000_compare_op0, rs6000_compare_op1);
7408 operands[2] = gen_reg_rtx (mode);
7409 }")
7410
7411 (define_expand "bne"
7412 [(set (match_dup 2) (match_dup 1))
7413 (set (pc)
7414 (if_then_else (ne (match_dup 2)
7415 (const_int 0))
7416 (label_ref (match_operand 0 "" ""))
7417 (pc)))]
7418 ""
7419 "
7420 { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
7421 operands[1] = gen_rtx (COMPARE, mode,
7422 rs6000_compare_op0, rs6000_compare_op1);
7423 operands[2] = gen_reg_rtx (mode);
7424 }")
7425
7426 (define_expand "blt"
7427 [(set (match_dup 2) (match_dup 1))
7428 (set (pc)
7429 (if_then_else (lt (match_dup 2)
7430 (const_int 0))
7431 (label_ref (match_operand 0 "" ""))
7432 (pc)))]
7433 ""
7434 "
7435 { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
7436 operands[1] = gen_rtx (COMPARE, mode,
7437 rs6000_compare_op0, rs6000_compare_op1);
7438 operands[2] = gen_reg_rtx (mode);
7439 }")
7440
7441 (define_expand "bgt"
7442 [(set (match_dup 2) (match_dup 1))
7443 (set (pc)
7444 (if_then_else (gt (match_dup 2)
7445 (const_int 0))
7446 (label_ref (match_operand 0 "" ""))
7447 (pc)))]
7448 ""
7449 "
7450 { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
7451 operands[1] = gen_rtx (COMPARE, mode,
7452 rs6000_compare_op0, rs6000_compare_op1);
7453 operands[2] = gen_reg_rtx (mode);
7454 }")
7455
7456 (define_expand "ble"
7457 [(set (match_dup 2) (match_dup 1))
7458 (set (pc)
7459 (if_then_else (le (match_dup 2)
7460 (const_int 0))
7461 (label_ref (match_operand 0 "" ""))
7462 (pc)))]
7463 ""
7464 "
7465 { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
7466 operands[1] = gen_rtx (COMPARE, mode,
7467 rs6000_compare_op0, rs6000_compare_op1);
7468 operands[2] = gen_reg_rtx (mode);
7469 }")
7470
7471 (define_expand "bge"
7472 [(set (match_dup 2) (match_dup 1))
7473 (set (pc)
7474 (if_then_else (ge (match_dup 2)
7475 (const_int 0))
7476 (label_ref (match_operand 0 "" ""))
7477 (pc)))]
7478 ""
7479 "
7480 { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
7481 operands[1] = gen_rtx (COMPARE, mode,
7482 rs6000_compare_op0, rs6000_compare_op1);
7483 operands[2] = gen_reg_rtx (mode);
7484 }")
7485
7486 (define_expand "bgtu"
7487 [(set (match_dup 2) (match_dup 1))
7488 (set (pc)
7489 (if_then_else (gtu (match_dup 2)
7490 (const_int 0))
7491 (label_ref (match_operand 0 "" ""))
7492 (pc)))]
7493 ""
7494 "
7495 { operands[1] = gen_rtx (COMPARE, CCUNSmode,
7496 rs6000_compare_op0, rs6000_compare_op1);
7497 operands[2] = gen_reg_rtx (CCUNSmode);
7498 }")
7499
7500 (define_expand "bltu"
7501 [(set (match_dup 2) (match_dup 1))
7502 (set (pc)
7503 (if_then_else (ltu (match_dup 2)
7504 (const_int 0))
7505 (label_ref (match_operand 0 "" ""))
7506 (pc)))]
7507 ""
7508 "
7509 { operands[1] = gen_rtx (COMPARE, CCUNSmode,
7510 rs6000_compare_op0, rs6000_compare_op1);
7511 operands[2] = gen_reg_rtx (CCUNSmode);
7512 }")
7513
7514 (define_expand "bgeu"
7515 [(set (match_dup 2) (match_dup 1))
7516 (set (pc)
7517 (if_then_else (geu (match_dup 2)
7518 (const_int 0))
7519 (label_ref (match_operand 0 "" ""))
7520 (pc)))]
7521 ""
7522 "
7523 { operands[1] = gen_rtx (COMPARE, CCUNSmode,
7524 rs6000_compare_op0, rs6000_compare_op1);
7525 operands[2] = gen_reg_rtx (CCUNSmode);
7526 }")
7527
7528 (define_expand "bleu"
7529 [(set (match_dup 2) (match_dup 1))
7530 (set (pc)
7531 (if_then_else (leu (match_dup 2)
7532 (const_int 0))
7533 (label_ref (match_operand 0 "" ""))
7534 (pc)))]
7535 ""
7536 "
7537 { operands[1] = gen_rtx (COMPARE, CCUNSmode,
7538 rs6000_compare_op0, rs6000_compare_op1);
7539 operands[2] = gen_reg_rtx (CCUNSmode);
7540 }")
7541
7542 ;; For SNE, we would prefer that the xor/abs sequence be used for integers.
7543 ;; For SEQ, likewise, except that comparisons with zero should be done
7544 ;; with an scc insns. However, due to the order that combine see the
7545 ;; resulting insns, we must, in fact, allow SEQ for integers. Fail in
7546 ;; the cases we don't want to handle.
7547 (define_expand "seq"
7548 [(set (match_dup 2) (match_dup 1))
7549 (set (match_operand:SI 0 "gpc_reg_operand" "")
7550 (eq:SI (match_dup 2) (const_int 0)))]
7551 ""
7552 "
7553 { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
7554 operands[1] = gen_rtx (COMPARE, mode,
7555 rs6000_compare_op0, rs6000_compare_op1);
7556 operands[2] = gen_reg_rtx (mode);
7557 }")
7558
7559 (define_expand "sne"
7560 [(set (match_dup 2) (match_dup 1))
7561 (set (match_operand:SI 0 "gpc_reg_operand" "")
7562 (ne:SI (match_dup 2) (const_int 0)))]
7563 ""
7564 "
7565 { if (! rs6000_compare_fp_p)
7566 FAIL;
7567
7568 operands[1] = gen_rtx (COMPARE, CCFPmode,
7569 rs6000_compare_op0, rs6000_compare_op1);
7570 operands[2] = gen_reg_rtx (CCFPmode);
7571 }")
7572
7573 ;; A > 0 is best done using the portable sequence, so fail in that case.
7574 (define_expand "sgt"
7575 [(set (match_dup 2) (match_dup 1))
7576 (set (match_operand:SI 0 "gpc_reg_operand" "")
7577 (gt:SI (match_dup 2) (const_int 0)))]
7578 ""
7579 "
7580 { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
7581
7582 if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
7583 FAIL;
7584
7585 operands[1] = gen_rtx (COMPARE, mode,
7586 rs6000_compare_op0, rs6000_compare_op1);
7587 operands[2] = gen_reg_rtx (mode);
7588 }")
7589
7590 ;; A < 0 is best done in the portable way for A an integer.
7591 (define_expand "slt"
7592 [(set (match_dup 2) (match_dup 1))
7593 (set (match_operand:SI 0 "gpc_reg_operand" "")
7594 (lt:SI (match_dup 2) (const_int 0)))]
7595 ""
7596 "
7597 { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
7598
7599 if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
7600 FAIL;
7601
7602 operands[1] = gen_rtx (COMPARE, mode,
7603 rs6000_compare_op0, rs6000_compare_op1);
7604 operands[2] = gen_reg_rtx (mode);
7605 }")
7606
7607 (define_expand "sge"
7608 [(set (match_dup 2) (match_dup 1))
7609 (set (match_operand:SI 0 "gpc_reg_operand" "")
7610 (ge:SI (match_dup 2) (const_int 0)))]
7611 ""
7612 "
7613 { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
7614 operands[1] = gen_rtx (COMPARE, mode,
7615 rs6000_compare_op0, rs6000_compare_op1);
7616 operands[2] = gen_reg_rtx (mode);
7617 }")
7618
7619 ;; A <= 0 is best done the portable way for A an integer.
7620 (define_expand "sle"
7621 [(set (match_dup 2) (match_dup 1))
7622 (set (match_operand:SI 0 "gpc_reg_operand" "")
7623 (le:SI (match_dup 2) (const_int 0)))]
7624 ""
7625 "
7626 { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
7627
7628 if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
7629 FAIL;
7630
7631 operands[1] = gen_rtx (COMPARE, mode,
7632 rs6000_compare_op0, rs6000_compare_op1);
7633 operands[2] = gen_reg_rtx (mode);
7634 }")
7635
7636 (define_expand "sgtu"
7637 [(set (match_dup 2) (match_dup 1))
7638 (set (match_operand:SI 0 "gpc_reg_operand" "")
7639 (gtu:SI (match_dup 2) (const_int 0)))]
7640 ""
7641 "
7642 { operands[1] = gen_rtx (COMPARE, CCUNSmode,
7643 rs6000_compare_op0, rs6000_compare_op1);
7644 operands[2] = gen_reg_rtx (CCUNSmode);
7645 }")
7646
7647 (define_expand "sltu"
7648 [(set (match_dup 2) (match_dup 1))
7649 (set (match_operand:SI 0 "gpc_reg_operand" "")
7650 (ltu:SI (match_dup 2) (const_int 0)))]
7651 ""
7652 "
7653 { operands[1] = gen_rtx (COMPARE, CCUNSmode,
7654 rs6000_compare_op0, rs6000_compare_op1);
7655 operands[2] = gen_reg_rtx (CCUNSmode);
7656 }")
7657
7658 (define_expand "sgeu"
7659 [(set (match_dup 2) (match_dup 1))
7660 (set (match_operand:SI 0 "gpc_reg_operand" "")
7661 (geu:SI (match_dup 2) (const_int 0)))]
7662 ""
7663 "
7664 { operands[1] = gen_rtx (COMPARE, CCUNSmode,
7665 rs6000_compare_op0, rs6000_compare_op1);
7666 operands[2] = gen_reg_rtx (CCUNSmode);
7667 }")
7668
7669 (define_expand "sleu"
7670 [(set (match_dup 2) (match_dup 1))
7671 (set (match_operand:SI 0 "gpc_reg_operand" "")
7672 (leu:SI (match_dup 2) (const_int 0)))]
7673 ""
7674 "
7675 { operands[1] = gen_rtx (COMPARE, CCUNSmode,
7676 rs6000_compare_op0, rs6000_compare_op1);
7677 operands[2] = gen_reg_rtx (CCUNSmode);
7678 }")
7679 \f
7680 ;; Here are the actual compare insns.
7681 (define_insn ""
7682 [(set (match_operand:CC 0 "cc_reg_operand" "=y")
7683 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
7684 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
7685 ""
7686 "{cmp%I2|cmpw%I2} %0,%1,%2"
7687 [(set_attr "type" "compare")])
7688
7689 (define_insn ""
7690 [(set (match_operand:CC 0 "cc_reg_operand" "=y")
7691 (compare:CC (match_operand:DI 1 "gpc_reg_operand" "r")
7692 (match_operand:DI 2 "reg_or_short_operand" "rI")))]
7693 "TARGET_POWERPC64"
7694 "cmpd%I2 %0,%1,%2"
7695 [(set_attr "type" "compare")])
7696
7697 ;; If we are comparing a register for equality with a large constant,
7698 ;; we can do this with an XOR followed by a compare. But we need a scratch
7699 ;; register for the result of the XOR.
7700
7701 (define_split
7702 [(set (match_operand:CC 0 "cc_reg_operand" "")
7703 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
7704 (match_operand:SI 2 "non_short_cint_operand" "")))
7705 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
7706 "find_single_use (operands[0], insn, 0)
7707 && (GET_CODE (*find_single_use (operands[0], insn, 0)) == EQ
7708 || GET_CODE (*find_single_use (operands[0], insn, 0)) == NE)"
7709 [(set (match_dup 3) (xor:SI (match_dup 1) (match_dup 4)))
7710 (set (match_dup 0) (compare:CC (match_dup 3) (match_dup 5)))]
7711 "
7712 {
7713 /* Get the constant we are comparing against, C, and see what it looks like
7714 sign-extended to 16 bits. Then see what constant could be XOR'ed
7715 with C to get the sign-extended value. */
7716
7717 int c = INTVAL (operands[2]);
7718 int sextc = (c << 16) >> 16;
7719 int xorv = c ^ sextc;
7720
7721 operands[4] = gen_rtx (CONST_INT, VOIDmode, xorv);
7722 operands[5] = gen_rtx (CONST_INT, VOIDmode, sextc);
7723 }")
7724
7725 (define_insn ""
7726 [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
7727 (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
7728 (match_operand:SI 2 "reg_or_u_short_operand" "rI")))]
7729 ""
7730 "{cmpl%I2|cmplw%I2} %0,%1,%W2"
7731 [(set_attr "type" "compare")])
7732
7733 (define_insn ""
7734 [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
7735 (compare:CCUNS (match_operand:DI 1 "gpc_reg_operand" "r")
7736 (match_operand:DI 2 "reg_or_u_short_operand" "rI")))]
7737 ""
7738 "cmpld%I2 %0,%1,%W2"
7739 [(set_attr "type" "compare")])
7740
7741 ;; The following two insns don't exist as single insns, but if we provide
7742 ;; them, we can swap an add and compare, which will enable us to overlap more
7743 ;; of the required delay between a compare and branch. We generate code for
7744 ;; them by splitting.
7745
7746 (define_insn ""
7747 [(set (match_operand:CC 3 "cc_reg_operand" "=y")
7748 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
7749 (match_operand:SI 2 "short_cint_operand" "i")))
7750 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
7751 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
7752 ""
7753 "#"
7754 [(set_attr "length" "8")])
7755
7756 (define_insn ""
7757 [(set (match_operand:CCUNS 3 "cc_reg_operand" "=y")
7758 (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
7759 (match_operand:SI 2 "u_short_cint_operand" "i")))
7760 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
7761 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
7762 ""
7763 "#"
7764 [(set_attr "length" "8")])
7765
7766 (define_split
7767 [(set (match_operand:CC 3 "cc_reg_operand" "")
7768 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
7769 (match_operand:SI 2 "short_cint_operand" "")))
7770 (set (match_operand:SI 0 "gpc_reg_operand" "")
7771 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
7772 ""
7773 [(set (match_dup 3) (compare:CC (match_dup 1) (match_dup 2)))
7774 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
7775
7776 (define_split
7777 [(set (match_operand:CCUNS 3 "cc_reg_operand" "")
7778 (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "")
7779 (match_operand:SI 2 "u_short_cint_operand" "")))
7780 (set (match_operand:SI 0 "gpc_reg_operand" "")
7781 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
7782 ""
7783 [(set (match_dup 3) (compare:CCUNS (match_dup 1) (match_dup 2)))
7784 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
7785
7786 (define_insn ""
7787 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
7788 (compare:CCFP (match_operand:SF 1 "gpc_reg_operand" "f")
7789 (match_operand:SF 2 "gpc_reg_operand" "f")))]
7790 "TARGET_HARD_FLOAT"
7791 "fcmpu %0,%1,%2"
7792 [(set_attr "type" "fpcompare")])
7793
7794 (define_insn ""
7795 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
7796 (compare:CCFP (match_operand:DF 1 "gpc_reg_operand" "f")
7797 (match_operand:DF 2 "gpc_reg_operand" "f")))]
7798 "TARGET_HARD_FLOAT"
7799 "fcmpu %0,%1,%2"
7800 [(set_attr "type" "fpcompare")])
7801 \f
7802 ;; Now we have the scc insns. We can do some combinations because of the
7803 ;; way the machine works.
7804 ;;
7805 ;; Note that this is probably faster if we can put an insn between the
7806 ;; mfcr and rlinm, but this is tricky. Let's leave it for now. In most
7807 ;; cases the insns below which don't use an intermediate CR field will
7808 ;; be used instead.
7809 (define_insn ""
7810 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7811 (match_operator:SI 1 "scc_comparison_operator"
7812 [(match_operand 2 "cc_reg_operand" "y")
7813 (const_int 0)]))]
7814 ""
7815 "%D1mfcr %0\;{rlinm|rlwinm} %0,%0,%J1,1"
7816 [(set_attr "length" "12")])
7817
7818 (define_insn ""
7819 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
7820 (compare:CC (match_operator:SI 1 "scc_comparison_operator"
7821 [(match_operand 2 "cc_reg_operand" "y")
7822 (const_int 0)])
7823 (const_int 0)))
7824 (set (match_operand:SI 3 "gpc_reg_operand" "=r")
7825 (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
7826 ""
7827 "%D1mfcr %3\;{rlinm.|rlwinm.} %3,%3,%J1,1"
7828 [(set_attr "type" "delayed_compare")
7829 (set_attr "length" "12")])
7830
7831 (define_insn ""
7832 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7833 (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
7834 [(match_operand 2 "cc_reg_operand" "y")
7835 (const_int 0)])
7836 (match_operand:SI 3 "const_int_operand" "n")))]
7837 ""
7838 "*
7839 {
7840 int is_bit = ccr_bit (operands[1], 1);
7841 int put_bit = 31 - (INTVAL (operands[3]) & 31);
7842 int count;
7843
7844 if (is_bit >= put_bit)
7845 count = is_bit - put_bit;
7846 else
7847 count = 32 - (put_bit - is_bit);
7848
7849 operands[4] = gen_rtx (CONST_INT, VOIDmode, count);
7850 operands[5] = gen_rtx (CONST_INT, VOIDmode, put_bit);
7851
7852 return \"%D1mfcr %0\;{rlinm|rlwinm} %0,%0,%4,%5,%5\";
7853 }"
7854 [(set_attr "length" "12")])
7855
7856 (define_insn ""
7857 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
7858 (compare:CC
7859 (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
7860 [(match_operand 2 "cc_reg_operand" "y")
7861 (const_int 0)])
7862 (match_operand:SI 3 "const_int_operand" "n"))
7863 (const_int 0)))
7864 (set (match_operand:SI 4 "gpc_reg_operand" "=r")
7865 (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
7866 (match_dup 3)))]
7867 ""
7868 "*
7869 {
7870 int is_bit = ccr_bit (operands[1], 1);
7871 int put_bit = 31 - (INTVAL (operands[3]) & 31);
7872 int count;
7873
7874 if (is_bit >= put_bit)
7875 count = is_bit - put_bit;
7876 else
7877 count = 32 - (put_bit - is_bit);
7878
7879 operands[5] = gen_rtx (CONST_INT, VOIDmode, count);
7880 operands[6] = gen_rtx (CONST_INT, VOIDmode, put_bit);
7881
7882 return \"%D1mfcr %4\;{rlinm.|rlwinm.} %4,%4,%5,%6,%6\";
7883 }"
7884 [(set_attr "type" "delayed_compare")
7885 (set_attr "length" "12")])
7886
7887 ;; If we are comparing the result of two comparisons, this can be done
7888 ;; using creqv or crxor.
7889
7890 (define_insn ""
7891 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y")
7892 (compare:CCEQ (match_operator 1 "scc_comparison_operator"
7893 [(match_operand 2 "cc_reg_operand" "y")
7894 (const_int 0)])
7895 (match_operator 3 "scc_comparison_operator"
7896 [(match_operand 4 "cc_reg_operand" "y")
7897 (const_int 0)])))]
7898 "REGNO (operands[2]) != REGNO (operands[4])"
7899 "*
7900 {
7901 enum rtx_code code1, code2;
7902
7903 code1 = GET_CODE (operands[1]);
7904 code2 = GET_CODE (operands[3]);
7905
7906 if ((code1 == EQ || code1 == LT || code1 == GT
7907 || code1 == LTU || code1 == GTU
7908 || (code1 != NE && GET_MODE (operands[2]) == CCFPmode))
7909 !=
7910 (code2 == EQ || code2 == LT || code2 == GT
7911 || code2 == LTU || code2 == GTU
7912 || (code2 != NE && GET_MODE (operands[4]) == CCFPmode)))
7913 return \"%C1%C3crxor %E0,%j1,%j3\";
7914 else
7915 return \"%C1%C3creqv %E0,%j1,%j3\";
7916 }"
7917 [(set_attr "length" "12")])
7918
7919 ;; There is a 3 cycle delay between consecutive mfcr instructions
7920 ;; so it is useful to combine 2 scc instructions to use only one mfcr.
7921
7922 (define_peephole
7923 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7924 (match_operator:SI 1 "scc_comparison_operator"
7925 [(match_operand 2 "cc_reg_operand" "y")
7926 (const_int 0)]))
7927 (set (match_operand:SI 3 "gpc_reg_operand" "=r")
7928 (match_operator:SI 4 "scc_comparison_operator"
7929 [(match_operand 5 "cc_reg_operand" "y")
7930 (const_int 0)]))]
7931 "REGNO (operands[2]) != REGNO (operands[5])"
7932 "%D1%D4mfcr %3\;{rlinm|rlwinm} %0,%3,%J1,1\;{rlinm|rlwinm} %3,%3,%J4,1"
7933 [(set_attr "length" "20")])
7934
7935 ;; There are some scc insns that can be done directly, without a compare.
7936 ;; These are faster because they don't involve the communications between
7937 ;; the FXU and branch units. In fact, we will be replacing all of the
7938 ;; integer scc insns here or in the portable methods in emit_store_flag.
7939 ;;
7940 ;; Also support (neg (scc ..)) since that construct is used to replace
7941 ;; branches, (plus (scc ..) ..) since that construct is common and
7942 ;; takes no more insns than scc, and (and (neg (scc ..)) ..) in the
7943 ;; cases where it is no more expensive than (neg (scc ..)).
7944
7945 ;; Have reload force a constant into a register for the simple insns that
7946 ;; otherwise won't accept constants. We do this because it is faster than
7947 ;; the cmp/mfcr sequence we would otherwise generate.
7948
7949 (define_insn ""
7950 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
7951 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
7952 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,J,I")))
7953 (clobber (match_scratch:SI 3 "=r,&r,r,r,r"))]
7954 ""
7955 "@
7956 xor %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
7957 {sfi|subfic} %3,%1,0\;{ae|adde} %0,%3,%1
7958 {xoril|xori} %0,%1,%b2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
7959 {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
7960 {sfi|subfic} %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0"
7961 [(set_attr "length" "12,8,12,12,12")])
7962
7963 (define_insn ""
7964 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,x,x,x")
7965 (compare:CC
7966 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
7967 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,J,I"))
7968 (const_int 0)))
7969 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
7970 (eq:SI (match_dup 1) (match_dup 2)))
7971 (clobber (match_scratch:SI 3 "=r,&r,r,r,r"))]
7972 ""
7973 "@
7974 xor %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
7975 {sfi|subfic} %3,%1,0\;{ae.|adde.} %0,%3,%1
7976 {xoril|xori} %0,%1,%b2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
7977 {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
7978 {sfi|subfic} %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0"
7979 [(set_attr "type" "compare")
7980 (set_attr "length" "12,8,12,12,12")])
7981
7982 ;; We have insns of the form shown by the first define_insn below. If
7983 ;; there is something inside the comparison operation, we must split it.
7984 (define_split
7985 [(set (match_operand:SI 0 "gpc_reg_operand" "")
7986 (plus:SI (match_operator 1 "comparison_operator"
7987 [(match_operand:SI 2 "" "")
7988 (match_operand:SI 3
7989 "reg_or_cint_operand" "")])
7990 (match_operand:SI 4 "gpc_reg_operand" "")))
7991 (clobber (match_operand:SI 5 "register_operand" ""))]
7992 "! gpc_reg_operand (operands[2], SImode)"
7993 [(set (match_dup 5) (match_dup 2))
7994 (set (match_dup 2) (plus:SI (match_op_dup 1 [(match_dup 2) (match_dup 3)])
7995 (match_dup 4)))])
7996
7997 (define_insn ""
7998 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
7999 (plus:SI (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
8000 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,J,I"))
8001 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r")))
8002 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r,&r"))]
8003 ""
8004 "@
8005 xor %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze|addze} %0,%3
8006 {sfi|subfic} %4,%1,0\;{aze|addze} %0,%3
8007 {xoril|xori} %4,%1,%b2\;{sfi|subfic} %4,%4,0\;{aze|addze} %0,%3
8008 {xoriu|xoris} %4,%1,%u2\;{sfi|subfic} %4,%4,0\;{aze|addze} %0,%3
8009 {sfi|subfic} %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze|addze} %0,%3"
8010 [(set_attr "length" "12,8,12,12,12")])
8011
8012 (define_insn ""
8013 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,x")
8014 (compare:CC
8015 (plus:SI
8016 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
8017 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,J,I"))
8018 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r"))
8019 (const_int 0)))
8020 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r,&r"))]
8021 ""
8022 "@
8023 xor %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
8024 {sfi|subfic} %4,%1,0\;{aze.|addze.} %0,%3
8025 {xoril|xori} %4,%1,%b2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
8026 {xoriu|xoris} %4,%1,%u2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
8027 {sfi|subfic} %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3"
8028 [(set_attr "type" "compare")
8029 (set_attr "length" "12,8,12,12,12")])
8030
8031 (define_insn ""
8032 [(set (match_operand:CC 5 "cc_reg_operand" "=x,x,x,x,x")
8033 (compare:CC
8034 (plus:SI
8035 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
8036 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,J,I"))
8037 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r"))
8038 (const_int 0)))
8039 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
8040 (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
8041 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r,&r"))]
8042 ""
8043 "@
8044 xor %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %0,%3
8045 {sfi|subfic} %4,%1,0\;{aze.|addze.} %4,%3
8046 {xoril|xori} %4,%1,%b2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %0,%3
8047 {xoriu|xoris} %4,%1,%u2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %0,%3
8048 {sfi|subfic} %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %0,%3"
8049 [(set_attr "type" "compare")
8050 (set_attr "length" "12,8,12,12,12")])
8051
8052 (define_insn ""
8053 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
8054 (neg:SI (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
8055 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,J,I"))))]
8056 ""
8057 "@
8058 xor %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
8059 {ai|addic} %0,%1,-1\;{sfe|subfe} %0,%0,%0
8060 {xoril|xori} %0,%1,%b2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
8061 {xoriu|xoris} %0,%1,%u2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
8062 {sfi|subfic} %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0"
8063 [(set_attr "length" "12,8,12,12,12")])
8064
8065 ;; Simplify (ne X (const_int 0)) on the PowerPC. No need to on the Power,
8066 ;; since it nabs/sr is just as fast.
8067 (define_insn ""
8068 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8069 (lshiftrt:SI (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
8070 (const_int 31)))
8071 (clobber (match_scratch:SI 2 "=&r"))]
8072 "!TARGET_POWER"
8073 "{ai|addic} %2,%1,-1\;{sfe|subfe} %0,%2,%1"
8074 [(set_attr "length" "8")])
8075
8076 ;; This is what (plus (ne X (const_int 0)) Y) looks like.
8077 (define_insn ""
8078 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8079 (plus:SI (lshiftrt:SI
8080 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
8081 (const_int 31))
8082 (match_operand:SI 2 "gpc_reg_operand" "r")))
8083 (clobber (match_scratch:SI 3 "=&r"))]
8084 ""
8085 "{ai|addic} %3,%1,-1\;{aze|addze} %0,%2"
8086 [(set_attr "length" "8")])
8087
8088 (define_insn ""
8089 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
8090 (compare:CC
8091 (plus:SI (lshiftrt:SI
8092 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
8093 (const_int 31))
8094 (match_operand:SI 2 "gpc_reg_operand" "r"))
8095 (const_int 0)))
8096 (clobber (match_scratch:SI 3 "=&r"))]
8097 ""
8098 "{ai|addic} %3,%1,-1\;{aze.|addze.} %3,%2"
8099 [(set_attr "type" "compare")
8100 (set_attr "length" "8")])
8101
8102 (define_insn ""
8103 [(set (match_operand:CC 4 "cc_reg_operand" "=x")
8104 (compare:CC
8105 (plus:SI (lshiftrt:SI
8106 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
8107 (const_int 31))
8108 (match_operand:SI 2 "gpc_reg_operand" "r"))
8109 (const_int 0)))
8110 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
8111 (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
8112 (match_dup 2)))
8113 (clobber (match_scratch:SI 3 "=&r"))]
8114 ""
8115 "{ai|addic} %3,%1,-1\;{aze.|addze.} %0,%2"
8116 [(set_attr "type" "compare")
8117 (set_attr "length" "8")])
8118
8119 (define_insn ""
8120 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8121 (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8122 (match_operand:SI 2 "reg_or_short_operand" "r,O")))
8123 (clobber (match_scratch:SI 3 "=r,X"))]
8124 "TARGET_POWER"
8125 "@
8126 doz %3,%2,%1\;{sfi|subfic} %0,%3,0\;{ae|adde} %0,%0,%3
8127 {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{sri|srwi} %0,%0,31"
8128 [(set_attr "length" "12")])
8129
8130 (define_insn ""
8131 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x")
8132 (compare:CC
8133 (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8134 (match_operand:SI 2 "reg_or_short_operand" "r,O"))
8135 (const_int 0)))
8136 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8137 (le:SI (match_dup 1) (match_dup 2)))
8138 (clobber (match_scratch:SI 3 "=r,X"))]
8139 "TARGET_POWER"
8140 "@
8141 doz %3,%2,%1\;{sfi|subfic} %0,%3,0\;{ae.|adde.} %0,%0,%3
8142 {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{sri.|srwi.} %0,%0,31"
8143 [(set_attr "type" "compare,delayed_compare")
8144 (set_attr "length" "12")])
8145
8146 (define_insn ""
8147 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8148 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8149 (match_operand:SI 2 "reg_or_short_operand" "r,O"))
8150 (match_operand:SI 3 "gpc_reg_operand" "r,r")))
8151 (clobber (match_scratch:SI 4 "=&r,&r"))]
8152 "TARGET_POWER"
8153 "@
8154 doz %4,%2,%1\;{sfi|subfic} %4,%4,0\;{aze|addze} %0,%3
8155 {srai|srawi} %4,%1,31\;{sf|subfc} %4,%1,%4\;{aze|addze} %0,%3"
8156 [(set_attr "length" "12")])
8157
8158 (define_insn ""
8159 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
8160 (compare:CC
8161 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8162 (match_operand:SI 2 "reg_or_short_operand" "r,O"))
8163 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
8164 (const_int 0)))
8165 (clobber (match_scratch:SI 4 "=&r,&r"))]
8166 "TARGET_POWER"
8167 "@
8168 doz %4,%2,%1\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
8169 {srai|srawi} %4,%1,31\;{sf|subfc} %4,%1,%4\;{aze.|addze.} %4,%3"
8170 [(set_attr "type" "compare")
8171 (set_attr "length" "12")])
8172
8173 (define_insn ""
8174 [(set (match_operand:CC 5 "cc_reg_operand" "=x,x")
8175 (compare:CC
8176 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8177 (match_operand:SI 2 "reg_or_short_operand" "r,O"))
8178 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
8179 (const_int 0)))
8180 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8181 (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
8182 (clobber (match_scratch:SI 4 "=&r,&r"))]
8183 "TARGET_POWER"
8184 "@
8185 doz %4,%2,%1\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %0,%3
8186 {srai|srawi} %4,%1,31\;{sf|subfc} %4,%1,%4\;{aze.|addze.} %0,%3"
8187 [(set_attr "type" "compare")
8188 (set_attr "length" "12")])
8189
8190 (define_insn ""
8191 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8192 (neg:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8193 (match_operand:SI 2 "reg_or_short_operand" "r,O"))))]
8194 "TARGET_POWER"
8195 "@
8196 doz %0,%2,%1\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
8197 {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{srai|srawi} %0,%0,31"
8198 [(set_attr "length" "12")])
8199
8200 (define_insn ""
8201 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8202 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8203 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
8204 ""
8205 "{sf%I2|subf%I2c} %0,%1,%2\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0"
8206 [(set_attr "length" "12")])
8207
8208 (define_insn ""
8209 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
8210 (compare:CC
8211 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8212 (match_operand:SI 2 "reg_or_short_operand" "rI"))
8213 (const_int 0)))
8214 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
8215 (leu:SI (match_dup 1) (match_dup 2)))]
8216 ""
8217 "{sf%I2|subf%I2c} %0,%1,%2\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0"
8218 [(set_attr "type" "compare")
8219 (set_attr "length" "12")])
8220
8221 (define_insn ""
8222 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8223 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8224 (match_operand:SI 2 "reg_or_short_operand" "rI"))
8225 (match_operand:SI 3 "gpc_reg_operand" "r")))
8226 (clobber (match_scratch:SI 4 "=&r"))]
8227 ""
8228 "{sf%I2|subf%I2c} %4,%1,%2\;{aze|addze} %0,%3"
8229 [(set_attr "length" "8")])
8230
8231 (define_insn ""
8232 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
8233 (compare:CC
8234 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8235 (match_operand:SI 2 "reg_or_short_operand" "rI"))
8236 (match_operand:SI 3 "gpc_reg_operand" "r"))
8237 (const_int 0)))
8238 (clobber (match_scratch:SI 4 "=&r"))]
8239 ""
8240 "{sf%I2|subf%I2c} %4,%1,%2\;{aze.|addze.} %4,%3"
8241 [(set_attr "type" "compare")
8242 (set_attr "length" "8")])
8243
8244 (define_insn ""
8245 [(set (match_operand:CC 5 "cc_reg_operand" "=x")
8246 (compare:CC
8247 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8248 (match_operand:SI 2 "reg_or_short_operand" "rI"))
8249 (match_operand:SI 3 "gpc_reg_operand" "r"))
8250 (const_int 0)))
8251 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
8252 (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
8253 (clobber (match_scratch:SI 4 "=&r"))]
8254 ""
8255 "{sf%I2|subf%I2c} %4,%1,%2\;{aze.|addze.} %0,%3"
8256 [(set_attr "type" "compare")
8257 (set_attr "length" "8")])
8258
8259 (define_insn ""
8260 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8261 (neg:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8262 (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
8263 ""
8264 "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;nand %0,%0,%0"
8265 [(set_attr "length" "12")])
8266
8267 (define_insn ""
8268 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8269 (and:SI (neg:SI
8270 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8271 (match_operand:SI 2 "reg_or_short_operand" "rI")))
8272 (match_operand:SI 3 "gpc_reg_operand" "r")))
8273 (clobber (match_scratch:SI 4 "=&r"))]
8274 ""
8275 "{sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;andc %0,%3,%4"
8276 [(set_attr "length" "12")])
8277
8278 (define_insn ""
8279 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
8280 (compare:CC
8281 (and:SI (neg:SI
8282 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8283 (match_operand:SI 2 "reg_or_short_operand" "rI")))
8284 (match_operand:SI 3 "gpc_reg_operand" "r"))
8285 (const_int 0)))
8286 (clobber (match_scratch:SI 4 "=&r"))]
8287 ""
8288 "{sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4"
8289 [(set_attr "type" "compare")
8290 (set_attr "length" "12")])
8291
8292 (define_insn ""
8293 [(set (match_operand:CC 5 "cc_reg_operand" "=x")
8294 (compare:CC
8295 (and:SI (neg:SI
8296 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8297 (match_operand:SI 2 "reg_or_short_operand" "rI")))
8298 (match_operand:SI 3 "gpc_reg_operand" "r"))
8299 (const_int 0)))
8300 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
8301 (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))
8302 (clobber (match_scratch:SI 4 "=&r"))]
8303 ""
8304 "{sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;andc. %0,%3,%4"
8305 [(set_attr "type" "compare")
8306 (set_attr "length" "12")])
8307
8308 (define_insn ""
8309 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8310 (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8311 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
8312 "TARGET_POWER"
8313 "doz%I2 %0,%1,%2\;nabs %0,%0\;{sri|srwi} %0,%0,31"
8314 [(set_attr "length" "12")])
8315
8316 (define_insn ""
8317 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
8318 (compare:CC
8319 (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8320 (match_operand:SI 2 "reg_or_short_operand" "rI"))
8321 (const_int 0)))
8322 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
8323 (lt:SI (match_dup 1) (match_dup 2)))]
8324 "TARGET_POWER"
8325 "doz%I2 %0,%1,%2\;nabs %0,%0\;{sri.|srwi.} %0,%0,31"
8326 [(set_attr "type" "delayed_compare")
8327 (set_attr "length" "12")])
8328
8329 (define_insn ""
8330 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8331 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8332 (match_operand:SI 2 "reg_or_short_operand" "rI"))
8333 (match_operand:SI 3 "gpc_reg_operand" "r")))
8334 (clobber (match_scratch:SI 4 "=&r"))]
8335 "TARGET_POWER"
8336 "doz%I2 %4,%1,%2\;{ai|addic} %4,%4,-1\;{aze|addze} %0,%3"
8337 [(set_attr "length" "12")])
8338
8339 (define_insn ""
8340 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
8341 (compare:CC
8342 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8343 (match_operand:SI 2 "reg_or_short_operand" "rI"))
8344 (match_operand:SI 3 "gpc_reg_operand" "r"))
8345 (const_int 0)))
8346 (clobber (match_scratch:SI 4 "=&r"))]
8347 "TARGET_POWER"
8348 "doz%I2 %4,%1,%2\;{ai|addic} %4,%4,-1\;{aze.|addze.} %4,%3"
8349 [(set_attr "type" "compare")
8350 (set_attr "length" "12")])
8351
8352 (define_insn ""
8353 [(set (match_operand:CC 5 "cc_reg_operand" "=x")
8354 (compare:CC
8355 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8356 (match_operand:SI 2 "reg_or_short_operand" "rI"))
8357 (match_operand:SI 3 "gpc_reg_operand" "r"))
8358 (const_int 0)))
8359 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
8360 (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
8361 (clobber (match_scratch:SI 4 "=&r"))]
8362 "TARGET_POWER"
8363 "doz%I2 %4,%1,%2\;{ai|addic} %4,%4,-1\;{aze.|addze.} %0,%3"
8364 [(set_attr "type" "compare")
8365 (set_attr "length" "12")])
8366
8367 (define_insn ""
8368 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8369 (neg:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8370 (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
8371 "TARGET_POWER"
8372 "doz%I2 %0,%1,%2\;nabs %0,%0\;{srai|srawi} %0,%0,31"
8373 [(set_attr "length" "12")])
8374
8375 (define_insn ""
8376 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8377 (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8378 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))]
8379 ""
8380 "@
8381 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;neg %0,%0
8382 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;neg %0,%0"
8383 [(set_attr "length" "12")])
8384
8385 (define_insn ""
8386 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x")
8387 (compare:CC
8388 (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8389 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
8390 (const_int 0)))
8391 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8392 (ltu:SI (match_dup 1) (match_dup 2)))]
8393 ""
8394 "@
8395 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;neg. %0,%0
8396 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;neg. %0,%0"
8397 [(set_attr "type" "compare")
8398 (set_attr "length" "12")])
8399
8400 (define_insn ""
8401 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
8402 (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
8403 (match_operand:SI 2 "reg_or_neg_short_operand" "r,r,P,P"))
8404 (match_operand:SI 3 "reg_or_short_operand" "r,I,r,I")))
8405 (clobber (match_scratch:SI 4 "=&r,r,&r,r"))]
8406 ""
8407 "@
8408 {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;{sf%I3|subf%I3c} %0,%4,%3
8409 {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;{sf%I3|subf%I3c} %0,%4,%3
8410 {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;{sf%I3|subf%I3c} %0,%4,%3
8411 {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;{sf%I3|subf%I3c} %0,%4,%3"
8412 [(set_attr "length" "12")])
8413
8414 (define_insn ""
8415 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
8416 (compare:CC
8417 (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8418 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
8419 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
8420 (const_int 0)))
8421 (clobber (match_scratch:SI 4 "=&r,&r"))]
8422 ""
8423 "@
8424 {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %4,%4,%3
8425 {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %4,%4,%3"
8426 [(set_attr "type" "compare")
8427 (set_attr "length" "12")])
8428
8429 (define_insn ""
8430 [(set (match_operand:CC 5 "cc_reg_operand" "=x,x")
8431 (compare:CC
8432 (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8433 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
8434 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
8435 (const_int 0)))
8436 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8437 (plus:SI (ltu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
8438 (clobber (match_scratch:SI 4 "=&r,&r"))]
8439 ""
8440 "@
8441 {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %0,%4,%3
8442 {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %0,%4,%3"
8443 [(set_attr "type" "compare")
8444 (set_attr "length" "12")])
8445
8446 (define_insn ""
8447 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8448 (neg:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8449 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))))]
8450 ""
8451 "@
8452 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0
8453 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0"
8454 [(set_attr "length" "8")])
8455
8456 (define_insn ""
8457 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8458 (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8459 (match_operand:SI 2 "reg_or_short_operand" "rI")))
8460 (clobber (match_scratch:SI 3 "=r"))]
8461 "TARGET_POWER"
8462 "doz%I2 %3,%1,%2\;{sfi|subfic} %0,%3,0\;{ae|adde} %0,%0,%3"
8463 [(set_attr "length" "12")])
8464
8465 (define_insn ""
8466 [(set (match_operand:CC 4 "cc_reg_operand" "=x")
8467 (compare:CC
8468 (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8469 (match_operand:SI 2 "reg_or_short_operand" "rI"))
8470 (const_int 0)))
8471 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
8472 (ge:SI (match_dup 1) (match_dup 2)))
8473 (clobber (match_scratch:SI 3 "=r"))]
8474 "TARGET_POWER"
8475 "doz%I2 %3,%1,%2\;{sfi|subfic} %0,%3,0\;{ae.|adde.} %0,%0,%3"
8476 [(set_attr "type" "compare")
8477 (set_attr "length" "12")])
8478
8479 (define_insn ""
8480 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8481 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8482 (match_operand:SI 2 "reg_or_short_operand" "rI"))
8483 (match_operand:SI 3 "gpc_reg_operand" "r")))
8484 (clobber (match_scratch:SI 4 "=&r"))]
8485 "TARGET_POWER"
8486 "doz%I2 %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze|addze} %0,%3"
8487 [(set_attr "length" "12")])
8488
8489 (define_insn ""
8490 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
8491 (compare:CC
8492 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8493 (match_operand:SI 2 "reg_or_short_operand" "rI"))
8494 (match_operand:SI 3 "gpc_reg_operand" "r"))
8495 (const_int 0)))
8496 (clobber (match_scratch:SI 4 "=&r"))]
8497 "TARGET_POWER"
8498 "doz%I2 %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3"
8499 [(set_attr "type" "compare")
8500 (set_attr "length" "12")])
8501
8502 (define_insn ""
8503 [(set (match_operand:CC 5 "cc_reg_operand" "=x")
8504 (compare:CC
8505 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8506 (match_operand:SI 2 "reg_or_short_operand" "rI"))
8507 (match_operand:SI 3 "gpc_reg_operand" "r"))
8508 (const_int 0)))
8509 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
8510 (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
8511 (clobber (match_scratch:SI 4 "=&r"))]
8512 "TARGET_POWER"
8513 "doz%I2 %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %0,%3"
8514 [(set_attr "type" "compare")
8515 (set_attr "length" "12")])
8516
8517 (define_insn ""
8518 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8519 (neg:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8520 (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
8521 "TARGET_POWER"
8522 "doz%I2 %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0"
8523 [(set_attr "length" "12")])
8524
8525 ;; This is (and (neg (ge X (const_int 0))) Y).
8526 (define_insn ""
8527 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8528 (and:SI (neg:SI
8529 (lshiftrt:SI
8530 (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
8531 (const_int 31)))
8532 (match_operand:SI 2 "gpc_reg_operand" "r")))
8533 (clobber (match_scratch:SI 3 "=&r"))]
8534 ""
8535 "{srai|srawi} %3,%1,31\;andc %0,%2,%3"
8536 [(set_attr "length" "8")])
8537
8538 (define_insn ""
8539 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
8540 (compare:CC
8541 (and:SI (neg:SI
8542 (lshiftrt:SI
8543 (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
8544 (const_int 31)))
8545 (match_operand:SI 2 "gpc_reg_operand" "r"))
8546 (const_int 0)))
8547 (clobber (match_scratch:SI 3 "=&r"))]
8548 ""
8549 "{srai|srawi} %3,%1,31\;andc. %3,%2,%3"
8550 [(set_attr "type" "compare")
8551 (set_attr "length" "8")])
8552
8553 (define_insn ""
8554 [(set (match_operand:CC 4 "cc_reg_operand" "=x")
8555 (compare:CC
8556 (and:SI (neg:SI
8557 (lshiftrt:SI
8558 (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
8559 (const_int 31)))
8560 (match_operand:SI 2 "gpc_reg_operand" "r"))
8561 (const_int 0)))
8562 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
8563 (and:SI (neg:SI (lshiftrt:SI (not:SI (match_dup 1))
8564 (const_int 31)))
8565 (match_dup 2)))
8566 (clobber (match_scratch:SI 3 "=&r"))]
8567 ""
8568 "{srai|srawi} %3,%1,31\;andc. %0,%2,%3"
8569 [(set_attr "type" "compare")
8570 (set_attr "length" "8")])
8571
8572 (define_insn ""
8573 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8574 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8575 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))]
8576 ""
8577 "@
8578 {sf|subfc} %0,%2,%1\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0
8579 {ai|addic} %0,%1,%n2\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0"
8580 [(set_attr "length" "12")])
8581
8582 (define_insn ""
8583 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x")
8584 (compare:CC
8585 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8586 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
8587 (const_int 0)))
8588 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8589 (geu:SI (match_dup 1) (match_dup 2)))]
8590 ""
8591 "@
8592 {sf|subfc} %0,%2,%1\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
8593 {ai|addic} %0,%1,%n2\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0"
8594 [(set_attr "type" "compare")
8595 (set_attr "length" "12")])
8596
8597 (define_insn ""
8598 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8599 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8600 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
8601 (match_operand:SI 3 "gpc_reg_operand" "r,r")))
8602 (clobber (match_scratch:SI 4 "=&r,&r"))]
8603 ""
8604 "@
8605 {sf|subfc} %4,%2,%1\;{aze|addze} %0,%3
8606 {ai|addic} %4,%1,%n2\;{aze|addze} %0,%3"
8607 [(set_attr "length" "8")])
8608
8609 (define_insn ""
8610 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
8611 (compare:CC
8612 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8613 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
8614 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
8615 (const_int 0)))
8616 (clobber (match_scratch:SI 4 "=&r,&r"))]
8617 ""
8618 "@
8619 {sf|subfc} %4,%2,%1\;{aze.|addze.} %4,%3
8620 {ai|addic} %4,%1,%n2\;{aze.|addze.} %4,%3"
8621 [(set_attr "type" "compare")
8622 (set_attr "length" "8")])
8623
8624 (define_insn ""
8625 [(set (match_operand:CC 5 "cc_reg_operand" "=x,x")
8626 (compare:CC
8627 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8628 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
8629 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
8630 (const_int 0)))
8631 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8632 (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
8633 (clobber (match_scratch:SI 4 "=&r,&r"))]
8634 ""
8635 "@
8636 {sf|subfc} %4,%2,%1\;{aze.|addze.} %0,%3
8637 {ai|addic} %4,%1,%n2\;{aze.|addze.} %4,%3"
8638 [(set_attr "type" "compare")
8639 (set_attr "length" "8")])
8640
8641 (define_insn ""
8642 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8643 (neg:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8644 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))]
8645 ""
8646 "@
8647 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;nand %0,%0,%0
8648 {sfi|subfic} %0,%1,-1\;{a%I2|add%I2c} %0,%0,%2\;{sfe|subfe} %0,%0,%0"
8649 [(set_attr "length" "12")])
8650
8651 (define_insn ""
8652 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8653 (and:SI (neg:SI
8654 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8655 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))
8656 (match_operand:SI 3 "gpc_reg_operand" "r,r")))
8657 (clobber (match_scratch:SI 4 "=&r,&r"))]
8658 ""
8659 "@
8660 {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;andc %0,%3,%4
8661 {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;andc %0,%3,%4"
8662 [(set_attr "length" "12")])
8663
8664 (define_insn ""
8665 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
8666 (compare:CC
8667 (and:SI (neg:SI
8668 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8669 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))
8670 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
8671 (const_int 0)))
8672 (clobber (match_scratch:SI 4 "=&r,&r"))]
8673 ""
8674 "@
8675 {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
8676 {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4"
8677 [(set_attr "type" "compare")
8678 (set_attr "length" "12")])
8679
8680 (define_insn ""
8681 [(set (match_operand:CC 5 "cc_reg_operand" "=x,x")
8682 (compare:CC
8683 (and:SI (neg:SI
8684 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8685 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))
8686 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
8687 (const_int 0)))
8688 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8689 (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))
8690 (clobber (match_scratch:SI 4 "=&r,&r"))]
8691 ""
8692 "@
8693 {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;andc. %0,%3,%4
8694 {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;andc. %0,%3,%4"
8695 [(set_attr "type" "compare")
8696 (set_attr "length" "12")])
8697
8698 (define_insn ""
8699 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8700 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8701 (const_int 0)))]
8702 ""
8703 "{sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{sri|srwi} %0,%0,31"
8704 [(set_attr "length" "12")])
8705
8706 (define_insn ""
8707 [(set (match_operand:CC 2 "cc_reg_operand" "=x")
8708 (compare:CC
8709 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8710 (const_int 0))
8711 (const_int 0)))
8712 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
8713 (gt:SI (match_dup 1) (const_int 0)))]
8714 ""
8715 "{sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{sri.|srwi.} %0,%0,31"
8716 [(set_attr "type" "delayed_compare")
8717 (set_attr "length" "12")])
8718
8719 (define_insn ""
8720 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8721 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8722 (match_operand:SI 2 "reg_or_short_operand" "r")))]
8723 "TARGET_POWER"
8724 "doz %0,%2,%1\;nabs %0,%0\;{sri|srwi} %0,%0,31"
8725 [(set_attr "length" "12")])
8726
8727 (define_insn ""
8728 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
8729 (compare:CC
8730 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8731 (match_operand:SI 2 "reg_or_short_operand" "r"))
8732 (const_int 0)))
8733 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
8734 (gt:SI (match_dup 1) (match_dup 2)))]
8735 "TARGET_POWER"
8736 "doz %0,%2,%1\;nabs %0,%0\;{sri.|srwi.} %0,%0,31"
8737 [(set_attr "type" "delayed_compare")
8738 (set_attr "length" "12")])
8739
8740 (define_insn ""
8741 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8742 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8743 (const_int 0))
8744 (match_operand:SI 2 "gpc_reg_operand" "r")))
8745 (clobber (match_scratch:SI 3 "=&r"))]
8746 ""
8747 "{a|addc} %3,%1,%1\;{sfe|subfe} %3,%1,%3\;{aze|addze} %0,%2"
8748 [(set_attr "length" "12")])
8749
8750 (define_insn ""
8751 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
8752 (compare:CC
8753 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8754 (const_int 0))
8755 (match_operand:SI 2 "gpc_reg_operand" "r"))
8756 (const_int 0)))
8757 (clobber (match_scratch:SI 3 "=&r"))]
8758 ""
8759 "{a|addc} %3,%1,%1\;{sfe|subfe} %3,%1,%3\;{aze.|addze.} %0,%2"
8760 [(set_attr "type" "compare")
8761 (set_attr "length" "12")])
8762
8763 (define_insn ""
8764 [(set (match_operand:CC 4 "cc_reg_operand" "=x")
8765 (compare:CC
8766 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8767 (const_int 0))
8768 (match_operand:SI 2 "gpc_reg_operand" "r"))
8769 (const_int 0)))
8770 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
8771 (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))
8772 (clobber (match_scratch:SI 3 "=&r"))]
8773 ""
8774 "{a|addc} %3,%1,%1\;{sfe|subfe} %3,%1,%3\;{aze.|addze.} %3,%2"
8775 [(set_attr "type" "compare")
8776 (set_attr "length" "12")])
8777
8778 (define_insn ""
8779 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8780 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8781 (match_operand:SI 2 "reg_or_short_operand" "r"))
8782 (match_operand:SI 3 "gpc_reg_operand" "r")))
8783 (clobber (match_scratch:SI 4 "=&r"))]
8784 "TARGET_POWER"
8785 "doz %4,%2,%1\;{ai|addic} %4,%4,-1\;{aze|addze} %0,%3"
8786 [(set_attr "length" "12")])
8787
8788 (define_insn ""
8789 [(set (match_operand:CC 0 "cc_reg_operand" "=x")
8790 (compare:CC
8791 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8792 (match_operand:SI 2 "reg_or_short_operand" "r"))
8793 (match_operand:SI 3 "gpc_reg_operand" "r"))
8794 (const_int 0)))
8795 (clobber (match_scratch:SI 4 "=&r"))]
8796 "TARGET_POWER"
8797 "doz %4,%2,%1\;{ai|addic} %4,%4,-1\;{aze.|addze.} %4,%3"
8798 [(set_attr "type" "compare")
8799 (set_attr "length" "12")])
8800
8801 (define_insn ""
8802 [(set (match_operand:CC 5 "cc_reg_operand" "=x")
8803 (compare:CC
8804 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8805 (match_operand:SI 2 "reg_or_short_operand" "r"))
8806 (match_operand:SI 3 "gpc_reg_operand" "r"))
8807 (const_int 0)))
8808 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
8809 (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
8810 (clobber (match_scratch:SI 4 "=&r"))]
8811 "TARGET_POWER"
8812 "doz %4,%2,%1\;{ai|addic} %4,%4,-1\;{aze.|addze.} %0,%3"
8813 [(set_attr "type" "compare")
8814 (set_attr "length" "12")])
8815
8816 (define_insn ""
8817 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8818 (neg:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8819 (const_int 0))))]
8820 ""
8821 "{sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{srai|srawi} %0,%0,31"
8822 [(set_attr "length" "12")])
8823
8824 (define_insn ""
8825 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8826 (neg:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8827 (match_operand:SI 2 "reg_or_short_operand" "r"))))]
8828 "TARGET_POWER"
8829 "doz %0,%2,%1\;nabs %0,%0\;{srai|srawi} %0,%0,31"
8830 [(set_attr "length" "12")])
8831
8832 (define_insn ""
8833 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8834 (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8835 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
8836 ""
8837 "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;neg %0,%0"
8838 [(set_attr "length" "12")])
8839
8840 (define_insn ""
8841 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
8842 (compare:CC
8843 (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8844 (match_operand:SI 2 "reg_or_short_operand" "rI"))
8845 (const_int 0)))
8846 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
8847 (gtu:SI (match_dup 1) (match_dup 2)))]
8848 ""
8849 "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;neg. %0,%0"
8850 [(set_attr "type" "compare")
8851 (set_attr "length" "12")])
8852
8853 (define_insn ""
8854 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
8855 (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r")
8856 (match_operand:SI 2 "reg_or_short_operand" "I,r,rI"))
8857 (match_operand:SI 3 "reg_or_short_operand" "r,r,I")))
8858 (clobber (match_scratch:SI 4 "=&r,&r,&r"))]
8859 ""
8860 "@
8861 {ai|addic} %4,%1,%k2\;{aze|addze} %0,%3
8862 {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;{sf%I3|subf%I3c} %0,%4,%3
8863 {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;{sf%I3|subf%I3c} %0,%4,%3"
8864 [(set_attr "length" "8,12,12")])
8865
8866 (define_insn ""
8867 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
8868 (compare:CC
8869 (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8870 (match_operand:SI 2 "reg_or_short_operand" "I,r"))
8871 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
8872 (const_int 0)))
8873 (clobber (match_scratch:SI 4 "=&r,&r"))]
8874 ""
8875 "@
8876 {ai|addic} %4,%1,%k2\;{aze.|addze.} %0,%3
8877 {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %0,%4,%3"
8878 [(set_attr "type" "compare")
8879 (set_attr "length" "8,12")])
8880
8881 (define_insn ""
8882 [(set (match_operand:CC 5 "cc_reg_operand" "=x,x")
8883 (compare:CC
8884 (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8885 (match_operand:SI 2 "reg_or_short_operand" "I,r"))
8886 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
8887 (const_int 0)))
8888 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8889 (plus:SI (gtu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
8890 (clobber (match_scratch:SI 4 "=&r,&r"))]
8891 ""
8892 "@
8893 {ai|addic} %4,%1,%k2\;{aze.|addze.} %0,%3
8894 {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %0,%4,%3"
8895 [(set_attr "type" "compare")
8896 (set_attr "length" "8,12")])
8897
8898 (define_insn ""
8899 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8900 (neg:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8901 (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
8902 ""
8903 "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0"
8904 [(set_attr "length" "8")])
8905 \f
8906 ;; Define both directions of branch and return. If we need a reload
8907 ;; register, we'd rather use CR0 since it is much easier to copy a
8908 ;; register CC value to there.
8909
8910 (define_insn ""
8911 [(set (pc)
8912 (if_then_else (match_operator 1 "branch_comparison_operator"
8913 [(match_operand 2
8914 "cc_reg_operand" "x,?y")
8915 (const_int 0)])
8916 (label_ref (match_operand 0 "" ""))
8917 (pc)))]
8918 ""
8919 "*
8920 {
8921 if (get_attr_length (insn) == 8)
8922 return \"%C1bc %t1,%j1,%l0\";
8923 else
8924 return \"%C1bc %T1,%j1,%$+8\;b %l0\";
8925
8926 }"
8927 [(set_attr "type" "branch")])
8928
8929 (define_insn ""
8930 [(set (pc)
8931 (if_then_else (match_operator 0 "branch_comparison_operator"
8932 [(match_operand 1
8933 "cc_reg_operand" "x,?y")
8934 (const_int 0)])
8935 (return)
8936 (pc)))]
8937 "direct_return ()"
8938 "{%C0bcr|%C0bclr} %t0,%j0"
8939 [(set_attr "type" "branch")
8940 (set_attr "length" "8")])
8941
8942 (define_insn ""
8943 [(set (pc)
8944 (if_then_else (match_operator 1 "branch_comparison_operator"
8945 [(match_operand 2
8946 "cc_reg_operand" "x,?y")
8947 (const_int 0)])
8948 (pc)
8949 (label_ref (match_operand 0 "" ""))))]
8950 ""
8951 "*
8952 {
8953 if (get_attr_length (insn) == 8)
8954 return \"%C1bc %T1,%j1,%l0\";
8955 else
8956 return \"%C1bc %t1,%j1,%$+8\;b %l0\";
8957 }"
8958 [(set_attr "type" "branch")])
8959
8960 (define_insn ""
8961 [(set (pc)
8962 (if_then_else (match_operator 0 "branch_comparison_operator"
8963 [(match_operand 1
8964 "cc_reg_operand" "x,?y")
8965 (const_int 0)])
8966 (pc)
8967 (return)))]
8968 "direct_return ()"
8969 "{%C0bcr|%C0bclr} %T0,%j0"
8970 [(set_attr "type" "branch")
8971 (set_attr "length" "8")])
8972
8973 ;; Unconditional branch and return.
8974
8975 (define_insn "jump"
8976 [(set (pc)
8977 (label_ref (match_operand 0 "" "")))]
8978 ""
8979 "b %l0"
8980 [(set_attr "type" "branch")])
8981
8982 (define_insn "return"
8983 [(return)]
8984 "direct_return ()"
8985 "{br|blr}"
8986 [(set_attr "type" "jmpreg")])
8987
8988 (define_insn "indirect_jump"
8989 [(set (pc) (match_operand:SI 0 "register_operand" "c,l"))]
8990 ""
8991 "@
8992 bctr
8993 {br|blr}"
8994 [(set_attr "type" "jmpreg")])
8995
8996 (define_insn ""
8997 [(set (pc) (match_operand:DI 0 "register_operand" "c,l"))]
8998 "TARGET_POWERPC64"
8999 "@
9000 bctr
9001 {br|blr}"
9002 [(set_attr "type" "jmpreg")])
9003
9004 ;; Table jump for switch statements:
9005 (define_expand "tablejump"
9006 [(use (match_operand 0 "" ""))
9007 (use (label_ref (match_operand 1 "" "")))]
9008 ""
9009 "
9010 {
9011 if (TARGET_32BIT)
9012 emit_jump_insn (gen_tablejumpsi (operands[0], operands[1]));
9013 else
9014 emit_jump_insn (gen_tablejumpdi (operands[0], operands[1]));
9015 DONE;
9016 }")
9017
9018 (define_expand "tablejumpsi"
9019 [(set (match_dup 3)
9020 (plus:SI (match_operand:SI 0 "" "")
9021 (match_dup 2)))
9022 (parallel [(set (pc) (match_dup 3))
9023 (use (label_ref (match_operand 1 "" "")))])]
9024 ""
9025 "
9026 { operands[0] = force_reg (SImode, operands[0]);
9027 operands[2] = force_reg (SImode, gen_rtx (LABEL_REF, VOIDmode, operands[1]));
9028 operands[3] = gen_reg_rtx (SImode);
9029 }")
9030
9031 (define_expand "tablejumpdi"
9032 [(set (match_dup 3)
9033 (plus:DI (match_operand:DI 0 "" "")
9034 (match_dup 2)))
9035 (parallel [(set (pc) (match_dup 3))
9036 (use (label_ref (match_operand 1 "" "")))])]
9037 ""
9038 "
9039 { operands[0] = force_reg (DImode, operands[0]);
9040 operands[2] = force_reg (DImode, gen_rtx (LABEL_REF, VOIDmode, operands[1]));
9041 operands[3] = gen_reg_rtx (DImode);
9042 }")
9043
9044 (define_insn ""
9045 [(set (pc)
9046 (match_operand:SI 0 "register_operand" "c,l"))
9047 (use (label_ref (match_operand 1 "" "")))]
9048 ""
9049 "@
9050 bctr
9051 {br|blr}"
9052 [(set_attr "type" "jmpreg")])
9053
9054 (define_insn ""
9055 [(set (pc)
9056 (match_operand:DI 0 "register_operand" "c,l"))
9057 (use (label_ref (match_operand 1 "" "")))]
9058 "TARGET_POWERPC64"
9059 "@
9060 bctr
9061 {br|blr}"
9062 [(set_attr "type" "jmpreg")])
9063
9064 (define_insn "nop"
9065 [(const_int 0)]
9066 ""
9067 "{cror 0,0,0|nop}")
9068 \f
9069 ;; Define the subtract-one-and-jump insns, starting with the template
9070 ;; so loop.c knows what to generate.
9071
9072 (define_expand "decrement_and_branch_on_count"
9073 [(parallel [(set (pc) (if_then_else (ne (match_operand:SI 0 "register_operand" "")
9074 (const_int 1))
9075 (label_ref (match_operand 1 "" ""))
9076 (pc)))
9077 (set (match_dup 0)
9078 (plus:SI (match_dup 0)
9079 (const_int -1)))
9080 (clobber (match_scratch:CC 2 ""))
9081 (clobber (match_scratch:SI 3 ""))])]
9082 ""
9083 "")
9084
9085 ;; We need to be able to do this for any operand, including MEM, or we
9086 ;; will cause reload to blow up since we don't allow output reloads on
9087 ;; JUMP_INSNs.
9088 ;; In order that the length attribute is calculated correctly, the
9089 ;; label MUST be operand 0.
9090
9091 (define_insn ""
9092 [(set (pc)
9093 (if_then_else (ne (match_operand:SI 1 "register_operand" "c,*r,*r")
9094 (const_int 1))
9095 (label_ref (match_operand 0 "" ""))
9096 (pc)))
9097 (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
9098 (plus:SI (match_dup 1)
9099 (const_int -1)))
9100 (clobber (match_scratch:CC 3 "=X,&x,&x"))
9101 (clobber (match_scratch:SI 4 "=X,X,r"))]
9102 ""
9103 "*
9104 {
9105 if (which_alternative != 0)
9106 return \"#\";
9107 else if (get_attr_length (insn) == 8)
9108 return \"{bdn|bdnz} %l0\";
9109 else
9110 return \"bdz %$+8\;b %l0\";
9111 }"
9112 [(set_attr "type" "branch")
9113 (set_attr "length" "*,12,16")])
9114
9115 (define_insn ""
9116 [(set (pc)
9117 (if_then_else (ne (match_operand:SI 1 "register_operand" "c,*r,*r")
9118 (const_int 1))
9119 (pc)
9120 (label_ref (match_operand 0 "" ""))))
9121 (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
9122 (plus:SI (match_dup 1)
9123 (const_int -1)))
9124 (clobber (match_scratch:CC 3 "=X,&x,&x"))
9125 (clobber (match_scratch:SI 4 "=X,X,r"))]
9126 ""
9127 "*
9128 {
9129 if (which_alternative != 0)
9130 return \"#\";
9131 else if (get_attr_length (insn) == 8)
9132 return \"bdz %l0\";
9133 else
9134 return \"{bdn|bdnz} %$+8\;b %l0\";
9135 }"
9136 [(set_attr "type" "branch")
9137 (set_attr "length" "*,12,16")])
9138
9139 ;; Similar, but we can use GE since we have a REG_NONNEG.
9140 (define_insn ""
9141 [(set (pc)
9142 (if_then_else (ge (match_operand:SI 1 "register_operand" "c,*r,*r")
9143 (const_int 0))
9144 (label_ref (match_operand 0 "" ""))
9145 (pc)))
9146 (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
9147 (plus:SI (match_dup 1)
9148 (const_int -1)))
9149 (clobber (match_scratch:CC 3 "=X,&x,&X"))
9150 (clobber (match_scratch:SI 4 "=X,X,r"))]
9151 "find_reg_note (insn, REG_NONNEG, 0)"
9152 "*
9153 {
9154 if (which_alternative != 0)
9155 return \"#\";
9156 else if (get_attr_length (insn) == 8)
9157 return \"{bdn|bdnz} %l0\";
9158 else
9159 return \"bdz %$+8\;b %l0\";
9160 }"
9161 [(set_attr "type" "branch")
9162 (set_attr "length" "*,12,16")])
9163
9164 (define_insn ""
9165 [(set (pc)
9166 (if_then_else (ge (match_operand:SI 1 "register_operand" "c,*r,*r")
9167 (const_int 0))
9168 (pc)
9169 (label_ref (match_operand 0 "" ""))))
9170 (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
9171 (plus:SI (match_dup 1)
9172 (const_int -1)))
9173 (clobber (match_scratch:CC 3 "=X,&x,&X"))
9174 (clobber (match_scratch:SI 4 "=X,X,r"))]
9175 "find_reg_note (insn, REG_NONNEG, 0)"
9176 "*
9177 {
9178 if (which_alternative != 0)
9179 return \"#\";
9180 else if (get_attr_length (insn) == 8)
9181 return \"bdz %l0\";
9182 else
9183 return \"{bdn|bdnz} %$+8\;b %l0\";
9184 }"
9185 [(set_attr "type" "branch")
9186 (set_attr "length" "*,12,16")])
9187
9188 (define_insn ""
9189 [(set (pc)
9190 (if_then_else (eq (match_operand:SI 1 "register_operand" "c,*r,*r")
9191 (const_int 1))
9192 (label_ref (match_operand 0 "" ""))
9193 (pc)))
9194 (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
9195 (plus:SI (match_dup 1)
9196 (const_int -1)))
9197 (clobber (match_scratch:CC 3 "=X,&x,&x"))
9198 (clobber (match_scratch:SI 4 "=X,X,r"))]
9199 ""
9200 "*
9201 {
9202 if (which_alternative != 0)
9203 return \"#\";
9204 else if (get_attr_length (insn) == 8)
9205 return \"bdz %l0\";
9206 else
9207 return \"{bdn|bdnz} %$+8\;b %l0\";
9208 }"
9209 [(set_attr "type" "branch")
9210 (set_attr "length" "*,12,16")])
9211
9212 (define_insn ""
9213 [(set (pc)
9214 (if_then_else (eq (match_operand:SI 1 "register_operand" "c,*r,*r")
9215 (const_int 1))
9216 (pc)
9217 (label_ref (match_operand 0 "" ""))))
9218 (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
9219 (plus:SI (match_dup 1)
9220 (const_int -1)))
9221 (clobber (match_scratch:CC 3 "=X,&x,&x"))
9222 (clobber (match_scratch:SI 4 "=X,X,r"))]
9223 ""
9224 "*
9225 {
9226 if (which_alternative != 0)
9227 return \"#\";
9228 else if (get_attr_length (insn) == 8)
9229 return \"{bdn|bdnz} %l0\";
9230 else
9231 return \"bdz %$+8\;b %l0\";
9232 }"
9233 [(set_attr "type" "branch")
9234 (set_attr "length" "*,12,16")])
9235
9236 (define_split
9237 [(set (pc)
9238 (if_then_else (match_operator 2 "comparison_operator"
9239 [(match_operand:SI 1 "gpc_reg_operand" "")
9240 (const_int 1)])
9241 (match_operand 5 "" "")
9242 (match_operand 6 "" "")))
9243 (set (match_operand:SI 0 "gpc_reg_operand" "")
9244 (plus:SI (match_dup 1)
9245 (const_int -1)))
9246 (clobber (match_scratch:CC 3 ""))
9247 (clobber (match_scratch:SI 4 ""))]
9248 "reload_completed"
9249 [(parallel [(set (match_dup 3)
9250 (compare:CC (plus:SI (match_dup 1)
9251 (const_int -1))
9252 (const_int 0)))
9253 (set (match_dup 0)
9254 (plus:SI (match_dup 1)
9255 (const_int -1)))])
9256 (set (pc) (if_then_else (match_dup 7)
9257 (match_dup 5)
9258 (match_dup 6)))]
9259 "
9260 { operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
9261 const0_rtx); }")
9262
9263 (define_split
9264 [(set (pc)
9265 (if_then_else (match_operator 2 "comparison_operator"
9266 [(match_operand:SI 1 "gpc_reg_operand" "")
9267 (const_int 1)])
9268 (match_operand 5 "" "")
9269 (match_operand 6 "" "")))
9270 (set (match_operand:SI 0 "general_operand" "")
9271 (plus:SI (match_dup 1) (const_int -1)))
9272 (clobber (match_scratch:CC 3 ""))
9273 (clobber (match_scratch:SI 4 ""))]
9274 "reload_completed && ! gpc_reg_operand (operands[0], SImode)"
9275 [(parallel [(set (match_dup 3)
9276 (compare:CC (plus:SI (match_dup 1)
9277 (const_int -1))
9278 (const_int 0)))
9279 (set (match_dup 4)
9280 (plus:SI (match_dup 1)
9281 (const_int -1)))])
9282 (set (match_dup 0)
9283 (match_dup 4))
9284 (set (pc) (if_then_else (match_dup 7)
9285 (match_dup 5)
9286 (match_dup 6)))]
9287 "
9288 { operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
9289 const0_rtx); }")
This page took 0.427739 seconds and 6 git commands to generate.