]> gcc.gnu.org Git - gcc.git/blob - gcc/config/rs6000/predicates.md
rs6000.opt (-mpower9-dform-scalar): Delete undocumented switches.
[gcc.git] / gcc / config / rs6000 / predicates.md
1 ;; Predicate definitions for POWER and PowerPC.
2 ;; Copyright (C) 2005-2017 Free Software Foundation, Inc.
3 ;;
4 ;; This file is part of GCC.
5 ;;
6 ;; GCC is free software; you can redistribute it and/or modify
7 ;; it under the terms of the GNU General Public License as published by
8 ;; the Free Software Foundation; either version 3, or (at your option)
9 ;; any later version.
10 ;;
11 ;; GCC is distributed in the hope that it will be useful,
12 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;; GNU General Public License for more details.
15 ;;
16 ;; You should have received a copy of the GNU General Public License
17 ;; along with GCC; see the file COPYING3. If not see
18 ;; <http://www.gnu.org/licenses/>.
19
20 ;; Return 1 for anything except PARALLEL.
21 (define_predicate "any_operand"
22 (match_code "const_int,const_double,const_wide_int,const,symbol_ref,label_ref,subreg,reg,mem"))
23
24 ;; Return 1 for any PARALLEL.
25 (define_predicate "any_parallel_operand"
26 (match_code "parallel"))
27
28 ;; Return 1 if op is COUNT register.
29 (define_predicate "count_register_operand"
30 (and (match_code "reg")
31 (match_test "REGNO (op) == CTR_REGNO
32 || REGNO (op) > LAST_VIRTUAL_REGISTER")))
33
34 ;; Return 1 if op is a SUBREG that is used to look at a SFmode value as
35 ;; and integer or vice versa.
36 ;;
37 ;; In the normal case where SFmode is in a floating point/vector register, it
38 ;; is stored as a DFmode and has a different format. If we don't transform the
39 ;; value, things that use logical operations on the values will get the wrong
40 ;; value.
41 ;;
42 ;; If we don't have 64-bit and direct move, this conversion will be done by
43 ;; store and load, instead of by fiddling with the bits within the register.
44 (define_predicate "sf_subreg_operand"
45 (match_code "subreg")
46 {
47 rtx inner_reg = SUBREG_REG (op);
48 machine_mode inner_mode = GET_MODE (inner_reg);
49
50 if (TARGET_ALLOW_SF_SUBREG || !REG_P (inner_reg))
51 return 0;
52
53 if ((mode == SFmode && GET_MODE_CLASS (inner_mode) == MODE_INT)
54 || (GET_MODE_CLASS (mode) == MODE_INT && inner_mode == SFmode))
55 {
56 if (INT_REGNO_P (REGNO (inner_reg)))
57 return 0;
58
59 return 1;
60 }
61 return 0;
62 })
63
64 ;; Return 1 if op is an Altivec register.
65 (define_predicate "altivec_register_operand"
66 (match_operand 0 "register_operand")
67 {
68 if (GET_CODE (op) == SUBREG)
69 {
70 if (TARGET_NO_SF_SUBREG && sf_subreg_operand (op, mode))
71 return 0;
72
73 op = SUBREG_REG (op);
74 }
75
76 if (!REG_P (op))
77 return 0;
78
79 if (REGNO (op) >= FIRST_PSEUDO_REGISTER)
80 return 1;
81
82 return ALTIVEC_REGNO_P (REGNO (op));
83 })
84
85 ;; Return 1 if op is a VSX register.
86 (define_predicate "vsx_register_operand"
87 (match_operand 0 "register_operand")
88 {
89 if (GET_CODE (op) == SUBREG)
90 {
91 if (TARGET_NO_SF_SUBREG && sf_subreg_operand (op, mode))
92 return 0;
93
94 op = SUBREG_REG (op);
95 }
96
97 if (!REG_P (op))
98 return 0;
99
100 if (REGNO (op) >= FIRST_PSEUDO_REGISTER)
101 return 1;
102
103 return VSX_REGNO_P (REGNO (op));
104 })
105
106 ;; Like vsx_register_operand, but allow SF SUBREGS
107 (define_predicate "vsx_reg_sfsubreg_ok"
108 (match_operand 0 "register_operand")
109 {
110 if (GET_CODE (op) == SUBREG)
111 op = SUBREG_REG (op);
112
113 if (!REG_P (op))
114 return 0;
115
116 if (REGNO (op) >= FIRST_PSEUDO_REGISTER)
117 return 1;
118
119 return VSX_REGNO_P (REGNO (op));
120 })
121
122 ;; Return 1 if op is a vector register that operates on floating point vectors
123 ;; (either altivec or VSX).
124 (define_predicate "vfloat_operand"
125 (match_operand 0 "register_operand")
126 {
127 if (GET_CODE (op) == SUBREG)
128 {
129 if (TARGET_NO_SF_SUBREG && sf_subreg_operand (op, mode))
130 return 0;
131
132 op = SUBREG_REG (op);
133 }
134
135 if (!REG_P (op))
136 return 0;
137
138 if (REGNO (op) >= FIRST_PSEUDO_REGISTER)
139 return 1;
140
141 return VFLOAT_REGNO_P (REGNO (op));
142 })
143
144 ;; Return 1 if op is a vector register that operates on integer vectors
145 ;; (only altivec, VSX doesn't support integer vectors)
146 (define_predicate "vint_operand"
147 (match_operand 0 "register_operand")
148 {
149 if (GET_CODE (op) == SUBREG)
150 {
151 if (TARGET_NO_SF_SUBREG && sf_subreg_operand (op, mode))
152 return 0;
153
154 op = SUBREG_REG (op);
155 }
156
157 if (!REG_P (op))
158 return 0;
159
160 if (REGNO (op) >= FIRST_PSEUDO_REGISTER)
161 return 1;
162
163 return VINT_REGNO_P (REGNO (op));
164 })
165
166 ;; Return 1 if op is a vector register to do logical operations on (and, or,
167 ;; xor, etc.)
168 (define_predicate "vlogical_operand"
169 (match_operand 0 "register_operand")
170 {
171 if (GET_CODE (op) == SUBREG)
172 {
173 if (TARGET_NO_SF_SUBREG && sf_subreg_operand (op, mode))
174 return 0;
175
176 op = SUBREG_REG (op);
177 }
178
179
180 if (!REG_P (op))
181 return 0;
182
183 if (REGNO (op) >= FIRST_PSEUDO_REGISTER)
184 return 1;
185
186 return VLOGICAL_REGNO_P (REGNO (op));
187 })
188
189 ;; Return 1 if op is the carry register.
190 (define_predicate "ca_operand"
191 (match_operand 0 "register_operand")
192 {
193 if (GET_CODE (op) == SUBREG)
194 op = SUBREG_REG (op);
195
196 if (!REG_P (op))
197 return 0;
198
199 return CA_REGNO_P (REGNO (op));
200 })
201
202 ;; Return 1 if op is a signed 5-bit constant integer.
203 (define_predicate "s5bit_cint_operand"
204 (and (match_code "const_int")
205 (match_test "INTVAL (op) >= -16 && INTVAL (op) <= 15")))
206
207 ;; Return 1 if op is a unsigned 3-bit constant integer.
208 (define_predicate "u3bit_cint_operand"
209 (and (match_code "const_int")
210 (match_test "INTVAL (op) >= 0 && INTVAL (op) <= 7")))
211
212 ;; Return 1 if op is a unsigned 5-bit constant integer.
213 (define_predicate "u5bit_cint_operand"
214 (and (match_code "const_int")
215 (match_test "INTVAL (op) >= 0 && INTVAL (op) <= 31")))
216
217 ;; Return 1 if op is a unsigned 6-bit constant integer.
218 (define_predicate "u6bit_cint_operand"
219 (and (match_code "const_int")
220 (match_test "INTVAL (op) >= 0 && INTVAL (op) <= 63")))
221
222 ;; Return 1 if op is an unsigned 7-bit constant integer.
223 (define_predicate "u7bit_cint_operand"
224 (and (match_code "const_int")
225 (match_test "IN_RANGE (INTVAL (op), 0, 127)")))
226
227 ;; Return 1 if op is a signed 8-bit constant integer.
228 ;; Integer multiplication complete more quickly
229 (define_predicate "s8bit_cint_operand"
230 (and (match_code "const_int")
231 (match_test "INTVAL (op) >= -128 && INTVAL (op) <= 127")))
232
233 ;; Return 1 if op is a unsigned 10-bit constant integer.
234 (define_predicate "u10bit_cint_operand"
235 (and (match_code "const_int")
236 (match_test "INTVAL (op) >= 0 && INTVAL (op) <= 1023")))
237
238 ;; Return 1 if op is a constant integer that can fit in a D field.
239 (define_predicate "short_cint_operand"
240 (and (match_code "const_int")
241 (match_test "satisfies_constraint_I (op)")))
242
243 ;; Return 1 if op is a constant integer that can fit in an unsigned D field.
244 (define_predicate "u_short_cint_operand"
245 (and (match_code "const_int")
246 (match_test "satisfies_constraint_K (op)")))
247
248 ;; Return 1 if op is a constant integer that is a signed 16-bit constant
249 ;; shifted left 16 bits
250 (define_predicate "upper16_cint_operand"
251 (and (match_code "const_int")
252 (match_test "satisfies_constraint_L (op)")))
253
254 ;; Return 1 if op is a constant integer that cannot fit in a signed D field.
255 (define_predicate "non_short_cint_operand"
256 (and (match_code "const_int")
257 (match_test "(unsigned HOST_WIDE_INT)
258 (INTVAL (op) + 0x8000) >= 0x10000")))
259
260 ;; Return 1 if op is a positive constant integer that is an exact power of 2.
261 (define_predicate "exact_log2_cint_operand"
262 (and (match_code "const_int")
263 (match_test "INTVAL (op) > 0 && exact_log2 (INTVAL (op)) >= 0")))
264
265 ;; Match op = 0 or op = 1.
266 (define_predicate "const_0_to_1_operand"
267 (and (match_code "const_int")
268 (match_test "IN_RANGE (INTVAL (op), 0, 1)")))
269
270 ;; Match op = 0..3.
271 (define_predicate "const_0_to_3_operand"
272 (and (match_code "const_int")
273 (match_test "IN_RANGE (INTVAL (op), 0, 3)")))
274
275 ;; Match op = 2 or op = 3.
276 (define_predicate "const_2_to_3_operand"
277 (and (match_code "const_int")
278 (match_test "IN_RANGE (INTVAL (op), 2, 3)")))
279
280 ;; Match op = 0..7.
281 (define_predicate "const_0_to_7_operand"
282 (and (match_code "const_int")
283 (match_test "IN_RANGE (INTVAL (op), 0, 7)")))
284
285 ;; Match op = 0..11
286 (define_predicate "const_0_to_12_operand"
287 (and (match_code "const_int")
288 (match_test "IN_RANGE (INTVAL (op), 0, 12)")))
289
290 ;; Match op = 0..15
291 (define_predicate "const_0_to_15_operand"
292 (and (match_code "const_int")
293 (match_test "IN_RANGE (INTVAL (op), 0, 15)")))
294
295 ;; Return 1 if op is a register that is not special.
296 ;; Disallow (SUBREG:SF (REG:SI)) and (SUBREG:SI (REG:SF)) on VSX systems where
297 ;; you need to be careful in moving a SFmode to SImode and vice versa due to
298 ;; the fact that SFmode is represented as DFmode in the VSX registers.
299 (define_predicate "gpc_reg_operand"
300 (match_operand 0 "register_operand")
301 {
302 if (GET_CODE (op) == SUBREG)
303 {
304 if (TARGET_NO_SF_SUBREG && sf_subreg_operand (op, mode))
305 return 0;
306
307 op = SUBREG_REG (op);
308 }
309
310 if (!REG_P (op))
311 return 0;
312
313 if (REGNO (op) >= FIRST_PSEUDO_REGISTER)
314 return 1;
315
316 if (TARGET_ALTIVEC && ALTIVEC_REGNO_P (REGNO (op)))
317 return 1;
318
319 if (TARGET_VSX && VSX_REGNO_P (REGNO (op)))
320 return 1;
321
322 return INT_REGNO_P (REGNO (op)) || FP_REGNO_P (REGNO (op));
323 })
324
325 ;; Return 1 if op is a general purpose register. Unlike gpc_reg_operand, don't
326 ;; allow floating point or vector registers. Since vector registers are not
327 ;; allowed, we don't have to reject SFmode/SImode subregs.
328 (define_predicate "int_reg_operand"
329 (match_operand 0 "register_operand")
330 {
331 if (GET_CODE (op) == SUBREG)
332 {
333 if (TARGET_NO_SF_SUBREG && sf_subreg_operand (op, mode))
334 return 0;
335
336 op = SUBREG_REG (op);
337 }
338
339 if (!REG_P (op))
340 return 0;
341
342 if (REGNO (op) >= FIRST_PSEUDO_REGISTER)
343 return 1;
344
345 return INT_REGNO_P (REGNO (op));
346 })
347
348 ;; Like int_reg_operand, but don't return true for pseudo registers
349 ;; We don't have to check for SF SUBREGS because pseudo registers
350 ;; are not allowed, and SF SUBREGs are ok within GPR registers.
351 (define_predicate "int_reg_operand_not_pseudo"
352 (match_operand 0 "register_operand")
353 {
354 if (GET_CODE (op) == SUBREG)
355 op = SUBREG_REG (op);
356
357 if (!REG_P (op))
358 return 0;
359
360 if (REGNO (op) >= FIRST_PSEUDO_REGISTER)
361 return 0;
362
363 return INT_REGNO_P (REGNO (op));
364 })
365
366 ;; Like int_reg_operand, but only return true for base registers
367 (define_predicate "base_reg_operand"
368 (match_operand 0 "int_reg_operand")
369 {
370 if (GET_CODE (op) == SUBREG)
371 op = SUBREG_REG (op);
372
373 if (!REG_P (op))
374 return 0;
375
376 return (REGNO (op) != FIRST_GPR_REGNO);
377 })
378
379
380 ;; Return true if this is a traditional floating point register
381 (define_predicate "fpr_reg_operand"
382 (match_code "reg,subreg")
383 {
384 HOST_WIDE_INT r;
385
386 if (GET_CODE (op) == SUBREG)
387 op = SUBREG_REG (op);
388
389 if (!REG_P (op))
390 return 0;
391
392 r = REGNO (op);
393 if (r >= FIRST_PSEUDO_REGISTER)
394 return 1;
395
396 return FP_REGNO_P (r);
397 })
398
399 ;; Return true if this is a register that can has D-form addressing (GPR and
400 ;; traditional FPR registers for scalars). ISA 3.0 (power9) adds D-form
401 ;; addressing for scalars in Altivec registers.
402 ;;
403 ;; If this is a pseudo only allow for GPR fusion in power8. If we have the
404 ;; power9 fusion allow the floating point types.
405 (define_predicate "toc_fusion_or_p9_reg_operand"
406 (match_code "reg,subreg")
407 {
408 HOST_WIDE_INT r;
409 bool gpr_p = (mode == QImode || mode == HImode || mode == SImode
410 || mode == SFmode
411 || (TARGET_POWERPC64 && (mode == DImode || mode == DFmode)));
412 bool fpr_p = (TARGET_P9_FUSION
413 && (mode == DFmode || mode == SFmode
414 || (TARGET_POWERPC64 && mode == DImode)));
415 bool vmx_p = (TARGET_P9_FUSION && TARGET_P9_VECTOR
416 && (mode == DFmode || mode == SFmode));
417
418 if (!TARGET_P8_FUSION)
419 return 0;
420
421 if (GET_CODE (op) == SUBREG)
422 op = SUBREG_REG (op);
423
424 if (!REG_P (op))
425 return 0;
426
427 r = REGNO (op);
428 if (r >= FIRST_PSEUDO_REGISTER)
429 return (gpr_p || fpr_p || vmx_p);
430
431 if (INT_REGNO_P (r))
432 return gpr_p;
433
434 if (FP_REGNO_P (r))
435 return fpr_p;
436
437 if (ALTIVEC_REGNO_P (r))
438 return vmx_p;
439
440 return 0;
441 })
442
443 ;; Return 1 if op is a HTM specific SPR register.
444 (define_predicate "htm_spr_reg_operand"
445 (match_operand 0 "register_operand")
446 {
447 if (!TARGET_HTM)
448 return 0;
449
450 if (GET_CODE (op) == SUBREG)
451 op = SUBREG_REG (op);
452
453 if (!REG_P (op))
454 return 0;
455
456 switch (REGNO (op))
457 {
458 case TFHAR_REGNO:
459 case TFIAR_REGNO:
460 case TEXASR_REGNO:
461 return 1;
462 default:
463 break;
464 }
465
466 /* Unknown SPR. */
467 return 0;
468 })
469
470 ;; Return 1 if op is a general purpose register that is an even register
471 ;; which suitable for a load/store quad operation
472 ;; Subregs are not allowed here because when they are combine can
473 ;; create (subreg:PTI (reg:TI pseudo)) which will cause reload to
474 ;; think the innermost reg needs reloading, in TImode instead of
475 ;; PTImode. So reload will choose a reg in TImode which has no
476 ;; requirement that the reg be even.
477 (define_predicate "quad_int_reg_operand"
478 (match_code "reg")
479 {
480 HOST_WIDE_INT r;
481
482 if (!TARGET_QUAD_MEMORY && !TARGET_QUAD_MEMORY_ATOMIC)
483 return 0;
484
485 r = REGNO (op);
486 if (r >= FIRST_PSEUDO_REGISTER)
487 return 1;
488
489 return (INT_REGNO_P (r) && ((r & 1) == 0));
490 })
491
492 ;; Return 1 if op is a register that is a condition register field.
493 (define_predicate "cc_reg_operand"
494 (match_operand 0 "register_operand")
495 {
496 if (GET_CODE (op) == SUBREG)
497 op = SUBREG_REG (op);
498
499 if (!REG_P (op))
500 return 0;
501
502 if (REGNO (op) > LAST_VIRTUAL_REGISTER)
503 return 1;
504
505 return CR_REGNO_P (REGNO (op));
506 })
507
508 ;; Return 1 if op is a register that is a condition register field not cr0.
509 (define_predicate "cc_reg_not_cr0_operand"
510 (match_operand 0 "register_operand")
511 {
512 if (GET_CODE (op) == SUBREG)
513 op = SUBREG_REG (op);
514
515 if (!REG_P (op))
516 return 0;
517
518 if (REGNO (op) > LAST_VIRTUAL_REGISTER)
519 return 1;
520
521 return CR_REGNO_NOT_CR0_P (REGNO (op));
522 })
523
524 ;; Return 1 if op is a constant integer valid for D field
525 ;; or non-special register register.
526 (define_predicate "reg_or_short_operand"
527 (if_then_else (match_code "const_int")
528 (match_operand 0 "short_cint_operand")
529 (match_operand 0 "gpc_reg_operand")))
530
531 ;; Return 1 if op is a constant integer valid for DS field
532 ;; or non-special register.
533 (define_predicate "reg_or_aligned_short_operand"
534 (if_then_else (match_code "const_int")
535 (and (match_operand 0 "short_cint_operand")
536 (match_test "!(INTVAL (op) & 3)"))
537 (match_operand 0 "gpc_reg_operand")))
538
539 ;; Return 1 if op is a constant integer whose high-order 16 bits are zero
540 ;; or non-special register.
541 (define_predicate "reg_or_u_short_operand"
542 (if_then_else (match_code "const_int")
543 (match_operand 0 "u_short_cint_operand")
544 (match_operand 0 "gpc_reg_operand")))
545
546 ;; Return 1 if op is any constant integer
547 ;; or non-special register.
548 (define_predicate "reg_or_cint_operand"
549 (ior (match_code "const_int")
550 (match_operand 0 "gpc_reg_operand")))
551
552 ;; Return 1 if op is a constant integer valid for addition with addis, addi.
553 (define_predicate "add_cint_operand"
554 (and (match_code "const_int")
555 (match_test "((unsigned HOST_WIDE_INT) INTVAL (op)
556 + (mode == SImode ? 0x80000000 : 0x80008000))
557 < (unsigned HOST_WIDE_INT) 0x100000000ll")))
558
559 ;; Return 1 if op is a constant integer valid for addition
560 ;; or non-special register.
561 (define_predicate "reg_or_add_cint_operand"
562 (if_then_else (match_code "const_int")
563 (match_operand 0 "add_cint_operand")
564 (match_operand 0 "gpc_reg_operand")))
565
566 ;; Return 1 if op is a constant integer valid for subtraction
567 ;; or non-special register.
568 (define_predicate "reg_or_sub_cint_operand"
569 (if_then_else (match_code "const_int")
570 (match_test "(unsigned HOST_WIDE_INT)
571 (- UINTVAL (op) + (mode == SImode ? 0x80000000 : 0x80008000))
572 < (unsigned HOST_WIDE_INT) 0x100000000ll")
573 (match_operand 0 "gpc_reg_operand")))
574
575 ;; Return 1 if op is any 32-bit unsigned constant integer
576 ;; or non-special register.
577 (define_predicate "reg_or_logical_cint_operand"
578 (if_then_else (match_code "const_int")
579 (match_test "(GET_MODE_BITSIZE (mode) > HOST_BITS_PER_WIDE_INT
580 && INTVAL (op) >= 0)
581 || ((INTVAL (op) & GET_MODE_MASK (mode)
582 & (~ (unsigned HOST_WIDE_INT) 0xffffffff)) == 0)")
583 (match_operand 0 "gpc_reg_operand")))
584
585 ;; Like reg_or_logical_cint_operand, but allow vsx registers
586 (define_predicate "vsx_reg_or_cint_operand"
587 (ior (match_operand 0 "vsx_register_operand")
588 (match_operand 0 "reg_or_logical_cint_operand")))
589
590 ;; Return 1 if operand is a CONST_DOUBLE that can be set in a register
591 ;; with no more than one instruction per word.
592 (define_predicate "easy_fp_constant"
593 (match_code "const_double")
594 {
595 if (GET_MODE (op) != mode
596 || (!SCALAR_FLOAT_MODE_P (mode) && mode != DImode))
597 return 0;
598
599 /* Consider all constants with -msoft-float to be easy. */
600 if ((TARGET_SOFT_FLOAT
601 || (TARGET_HARD_FLOAT && (TARGET_SINGLE_FLOAT && ! TARGET_DOUBLE_FLOAT)))
602 && mode != DImode)
603 return 1;
604
605 /* 0.0D is not all zero bits. */
606 if (DECIMAL_FLOAT_MODE_P (mode))
607 return 0;
608
609 /* The constant 0.0 is easy under VSX. */
610 if (TARGET_VSX && SCALAR_FLOAT_MODE_P (mode) && op == CONST0_RTX (mode))
611 return 1;
612
613 /* If we are using V.4 style PIC, consider all constants to be hard. */
614 if (flag_pic && DEFAULT_ABI == ABI_V4)
615 return 0;
616
617 /* If we have real FPRs, consider floating point constants hard (other than
618 0.0 under VSX), so that the constant gets pushed to memory during the
619 early RTL phases. This has the advantage that double precision constants
620 that can be represented in single precision without a loss of precision
621 will use single precision loads. */
622
623 switch (mode)
624 {
625 case KFmode:
626 case IFmode:
627 case TFmode:
628 case DFmode:
629 case SFmode:
630 return 0;
631
632 case DImode:
633 return (num_insns_constant (op, DImode) <= 2);
634
635 case SImode:
636 return 1;
637
638 default:
639 gcc_unreachable ();
640 }
641 })
642
643 ;; Return 1 if the operand is a constant that can loaded with a XXSPLTIB
644 ;; instruction and then a VUPKHSB, VECSB2W or VECSB2D instruction.
645
646 (define_predicate "xxspltib_constant_split"
647 (match_code "const_vector,vec_duplicate,const_int")
648 {
649 int value = 256;
650 int num_insns = -1;
651
652 if (!xxspltib_constant_p (op, mode, &num_insns, &value))
653 return false;
654
655 return num_insns > 1;
656 })
657
658
659 ;; Return 1 if the operand is constant that can loaded directly with a XXSPLTIB
660 ;; instruction.
661
662 (define_predicate "xxspltib_constant_nosplit"
663 (match_code "const_vector,vec_duplicate,const_int")
664 {
665 int value = 256;
666 int num_insns = -1;
667
668 if (!xxspltib_constant_p (op, mode, &num_insns, &value))
669 return false;
670
671 return num_insns == 1;
672 })
673
674 ;; Return 1 if the operand is a CONST_VECTOR and can be loaded into a
675 ;; vector register without using memory.
676 (define_predicate "easy_vector_constant"
677 (match_code "const_vector")
678 {
679 /* As the paired vectors are actually FPRs it seems that there is
680 no easy way to load a CONST_VECTOR without using memory. */
681 if (TARGET_PAIRED_FLOAT)
682 return false;
683
684 /* Because IEEE 128-bit floating point is considered a vector type
685 in order to pass it in VSX registers, it might use this function
686 instead of easy_fp_constant. */
687 if (FLOAT128_VECTOR_P (mode))
688 return easy_fp_constant (op, mode);
689
690 if (VECTOR_MEM_ALTIVEC_OR_VSX_P (mode))
691 {
692 int value = 256;
693 int num_insns = -1;
694
695 if (zero_constant (op, mode) || all_ones_constant (op, mode))
696 return true;
697
698 if (TARGET_P9_VECTOR
699 && xxspltib_constant_p (op, mode, &num_insns, &value))
700 return true;
701
702 return easy_altivec_constant (op, mode);
703 }
704
705 return false;
706 })
707
708 ;; Same as easy_vector_constant but only for EASY_VECTOR_15_ADD_SELF.
709 (define_predicate "easy_vector_constant_add_self"
710 (and (match_code "const_vector")
711 (and (match_test "TARGET_ALTIVEC")
712 (match_test "easy_altivec_constant (op, mode)")))
713 {
714 HOST_WIDE_INT val;
715 int elt;
716 if (mode == V2DImode || mode == V2DFmode)
717 return 0;
718 elt = BYTES_BIG_ENDIAN ? GET_MODE_NUNITS (mode) - 1 : 0;
719 val = const_vector_elt_as_int (op, elt);
720 val = ((val & 0xff) ^ 0x80) - 0x80;
721 return EASY_VECTOR_15_ADD_SELF (val);
722 })
723
724 ;; Same as easy_vector_constant but only for EASY_VECTOR_MSB.
725 (define_predicate "easy_vector_constant_msb"
726 (and (match_code "const_vector")
727 (and (match_test "TARGET_ALTIVEC")
728 (match_test "easy_altivec_constant (op, mode)")))
729 {
730 HOST_WIDE_INT val;
731 int elt;
732 if (mode == V2DImode || mode == V2DFmode)
733 return 0;
734 elt = BYTES_BIG_ENDIAN ? GET_MODE_NUNITS (mode) - 1 : 0;
735 val = const_vector_elt_as_int (op, elt);
736 return EASY_VECTOR_MSB (val, GET_MODE_INNER (mode));
737 })
738
739 ;; Return true if this is an easy altivec constant that we form
740 ;; by using VSLDOI.
741 (define_predicate "easy_vector_constant_vsldoi"
742 (and (match_code "const_vector")
743 (and (match_test "TARGET_ALTIVEC")
744 (and (match_test "easy_altivec_constant (op, mode)")
745 (match_test "vspltis_shifted (op) != 0")))))
746
747 ;; Return 1 if operand is constant zero (scalars and vectors).
748 (define_predicate "zero_constant"
749 (and (match_code "const_int,const_double,const_wide_int,const_vector")
750 (match_test "op == CONST0_RTX (mode)")))
751
752 ;; Return 1 if operand is constant -1 (scalars and vectors).
753 (define_predicate "all_ones_constant"
754 (and (match_code "const_int,const_double,const_wide_int,const_vector")
755 (match_test "op == CONSTM1_RTX (mode) && !FLOAT_MODE_P (mode)")))
756
757 ;; Return 1 if operand is a vector int register or is either a vector constant
758 ;; of all 0 bits of a vector constant of all 1 bits.
759 (define_predicate "vector_int_reg_or_same_bit"
760 (match_code "reg,subreg,const_vector")
761 {
762 if (GET_MODE_CLASS (mode) != MODE_VECTOR_INT)
763 return 0;
764
765 else if (REG_P (op) || SUBREG_P (op))
766 return vint_operand (op, mode);
767
768 else
769 return op == CONST0_RTX (mode) || op == CONSTM1_RTX (mode);
770 })
771
772 ;; Return 1 if operand is 0.0.
773 (define_predicate "zero_fp_constant"
774 (and (match_code "const_double")
775 (match_test "SCALAR_FLOAT_MODE_P (mode)
776 && op == CONST0_RTX (mode)")))
777
778 ;; Return 1 if the operand is in volatile memory. Note that during the
779 ;; RTL generation phase, memory_operand does not return TRUE for volatile
780 ;; memory references. So this function allows us to recognize volatile
781 ;; references where it's safe.
782 (define_predicate "volatile_mem_operand"
783 (and (and (match_code "mem")
784 (match_test "MEM_VOLATILE_P (op)"))
785 (if_then_else (match_test "reload_completed")
786 (match_operand 0 "memory_operand")
787 (match_test "memory_address_p (mode, XEXP (op, 0))"))))
788
789 ;; Return 1 if the operand is an offsettable memory operand.
790 (define_predicate "offsettable_mem_operand"
791 (and (match_operand 0 "memory_operand")
792 (match_test "offsettable_nonstrict_memref_p (op)")))
793
794 ;; Return 1 if the operand is a simple offsettable memory operand
795 ;; that does not include pre-increment, post-increment, etc.
796 (define_predicate "simple_offsettable_mem_operand"
797 (match_operand 0 "offsettable_mem_operand")
798 {
799 rtx addr = XEXP (op, 0);
800
801 if (GET_CODE (addr) != PLUS && GET_CODE (addr) != LO_SUM)
802 return 0;
803
804 if (!CONSTANT_P (XEXP (addr, 1)))
805 return 0;
806
807 return base_reg_operand (XEXP (addr, 0), Pmode);
808 })
809
810 ;; Return 1 if the operand is suitable for load/store quad memory.
811 ;; This predicate only checks for non-atomic loads/stores (not lqarx/stqcx).
812 (define_predicate "quad_memory_operand"
813 (match_code "mem")
814 {
815 if (!TARGET_QUAD_MEMORY && !TARGET_SYNC_TI)
816 return false;
817
818 if (GET_MODE_SIZE (mode) != 16 || !MEM_P (op) || MEM_ALIGN (op) < 128)
819 return false;
820
821 return quad_address_p (XEXP (op, 0), mode, false);
822 })
823
824 ;; Return 1 if the operand is suitable for load/store to vector registers with
825 ;; d-form addressing (register+offset), which was added in ISA 3.0.
826 ;; Unlike quad_memory_operand, we do not have to check for alignment.
827 (define_predicate "vsx_quad_dform_memory_operand"
828 (match_code "mem")
829 {
830 if (!TARGET_P9_VECTOR || !MEM_P (op) || GET_MODE_SIZE (mode) != 16)
831 return false;
832
833 return quad_address_p (XEXP (op, 0), mode, false);
834 })
835
836 ;; Return 1 if the operand is an indexed or indirect memory operand.
837 (define_predicate "indexed_or_indirect_operand"
838 (match_code "mem")
839 {
840 op = XEXP (op, 0);
841 if (VECTOR_MEM_ALTIVEC_P (mode)
842 && GET_CODE (op) == AND
843 && GET_CODE (XEXP (op, 1)) == CONST_INT
844 && INTVAL (XEXP (op, 1)) == -16)
845 op = XEXP (op, 0);
846
847 return indexed_or_indirect_address (op, mode);
848 })
849
850 ;; Like indexed_or_indirect_operand, but also allow a GPR register if direct
851 ;; moves are supported.
852 (define_predicate "reg_or_indexed_operand"
853 (match_code "mem,reg,subreg")
854 {
855 if (MEM_P (op))
856 return indexed_or_indirect_operand (op, mode);
857 else if (TARGET_DIRECT_MOVE)
858 return register_operand (op, mode);
859 return
860 0;
861 })
862
863 ;; Return 1 if the operand is an indexed or indirect memory operand with an
864 ;; AND -16 in it, used to recognize when we need to switch to Altivec loads
865 ;; to realign loops instead of VSX (altivec silently ignores the bottom bits,
866 ;; while VSX uses the full address and traps)
867 (define_predicate "altivec_indexed_or_indirect_operand"
868 (match_code "mem")
869 {
870 op = XEXP (op, 0);
871 if (VECTOR_MEM_ALTIVEC_OR_VSX_P (mode)
872 && GET_CODE (op) == AND
873 && GET_CODE (XEXP (op, 1)) == CONST_INT
874 && INTVAL (XEXP (op, 1)) == -16)
875 return indexed_or_indirect_address (XEXP (op, 0), mode);
876
877 return 0;
878 })
879
880 ;; Return 1 if the operand is an indexed or indirect address.
881 (define_special_predicate "indexed_or_indirect_address"
882 (and (match_test "REG_P (op)
883 || (GET_CODE (op) == PLUS
884 /* Omit testing REG_P (XEXP (op, 0)). */
885 && REG_P (XEXP (op, 1)))")
886 (match_operand 0 "address_operand")))
887
888 ;; Return 1 if the operand is an index-form address.
889 (define_special_predicate "indexed_address"
890 (match_test "(GET_CODE (op) == PLUS
891 && REG_P (XEXP (op, 0))
892 && REG_P (XEXP (op, 1)))"))
893
894 ;; Return 1 if the operand is a MEM with an update-form address. This may
895 ;; also include update-indexed form.
896 (define_special_predicate "update_address_mem"
897 (match_test "(MEM_P (op)
898 && (GET_CODE (XEXP (op, 0)) == PRE_INC
899 || GET_CODE (XEXP (op, 0)) == PRE_DEC
900 || GET_CODE (XEXP (op, 0)) == PRE_MODIFY))"))
901
902 ;; Return 1 if the operand is a MEM with an indexed-form address.
903 (define_special_predicate "indexed_address_mem"
904 (match_test "(MEM_P (op)
905 && (indexed_address (XEXP (op, 0), mode)
906 || (GET_CODE (XEXP (op, 0)) == PRE_MODIFY
907 && indexed_address (XEXP (XEXP (op, 0), 1), mode))))"))
908
909 ;; Return 1 if the operand is either a non-special register or can be used
910 ;; as the operand of a `mode' add insn.
911 (define_predicate "add_operand"
912 (if_then_else (match_code "const_int")
913 (match_test "satisfies_constraint_I (op)
914 || satisfies_constraint_L (op)")
915 (match_operand 0 "gpc_reg_operand")))
916
917 ;; Return 1 if the operand is either a non-special register, or 0, or -1.
918 (define_predicate "adde_operand"
919 (if_then_else (match_code "const_int")
920 (match_test "INTVAL (op) == 0 || INTVAL (op) == -1")
921 (match_operand 0 "gpc_reg_operand")))
922
923 ;; Return 1 if OP is a constant but not a valid add_operand.
924 (define_predicate "non_add_cint_operand"
925 (and (match_code "const_int")
926 (match_test "!satisfies_constraint_I (op)
927 && !satisfies_constraint_L (op)")))
928
929 ;; Return 1 if the operand is a constant that can be used as the operand
930 ;; of an OR or XOR.
931 (define_predicate "logical_const_operand"
932 (match_code "const_int")
933 {
934 HOST_WIDE_INT opl;
935
936 opl = INTVAL (op) & GET_MODE_MASK (mode);
937
938 return ((opl & ~ (unsigned HOST_WIDE_INT) 0xffff) == 0
939 || (opl & ~ (unsigned HOST_WIDE_INT) 0xffff0000) == 0);
940 })
941
942 ;; Return 1 if the operand is a non-special register or a constant that
943 ;; can be used as the operand of an OR or XOR.
944 (define_predicate "logical_operand"
945 (ior (match_operand 0 "gpc_reg_operand")
946 (match_operand 0 "logical_const_operand")))
947
948 ;; Return 1 if op is a constant that is not a logical operand, but could
949 ;; be split into one.
950 (define_predicate "non_logical_cint_operand"
951 (and (match_code "const_int,const_wide_int")
952 (and (not (match_operand 0 "logical_operand"))
953 (match_operand 0 "reg_or_logical_cint_operand"))))
954
955 ;; Return 1 if the operand is either a non-special register or a
956 ;; constant that can be used as the operand of a logical AND.
957 (define_predicate "and_operand"
958 (ior (and (match_code "const_int")
959 (match_test "rs6000_is_valid_and_mask (op, mode)"))
960 (if_then_else (match_test "fixed_regs[CR0_REGNO]")
961 (match_operand 0 "gpc_reg_operand")
962 (match_operand 0 "logical_operand"))))
963
964 ;; Return 1 if the operand is either a logical operand or a short cint operand.
965 (define_predicate "scc_eq_operand"
966 (ior (match_operand 0 "logical_operand")
967 (match_operand 0 "short_cint_operand")))
968
969 ;; Return 1 if the operand is a general non-special register or memory operand.
970 (define_predicate "reg_or_mem_operand"
971 (ior (match_operand 0 "memory_operand")
972 (and (match_code "mem")
973 (match_test "macho_lo_sum_memory_operand (op, mode)"))
974 (match_operand 0 "volatile_mem_operand")
975 (match_operand 0 "gpc_reg_operand")))
976
977 ;; Return 1 if the operand is CONST_DOUBLE 0, register or memory operand.
978 (define_predicate "zero_reg_mem_operand"
979 (ior (and (match_test "TARGET_VSX")
980 (match_operand 0 "zero_fp_constant"))
981 (match_operand 0 "reg_or_mem_operand")))
982
983 ;; Return 1 if the operand is a CONST_INT and it is the element for 64-bit
984 ;; data types inside of a vector that scalar instructions operate on
985 (define_predicate "vsx_scalar_64bit"
986 (match_code "const_int")
987 {
988 return (INTVAL (op) == VECTOR_ELEMENT_SCALAR_64BIT);
989 })
990
991 ;; Return 1 if the operand is a general register or memory operand without
992 ;; pre_inc or pre_dec or pre_modify, which produces invalid form of PowerPC
993 ;; lwa instruction.
994 (define_predicate "lwa_operand"
995 (match_code "reg,subreg,mem")
996 {
997 rtx inner, addr, offset;
998
999 inner = op;
1000 if (reload_completed && GET_CODE (inner) == SUBREG)
1001 inner = SUBREG_REG (inner);
1002
1003 if (gpc_reg_operand (inner, mode))
1004 return true;
1005 if (!memory_operand (inner, mode))
1006 return false;
1007
1008 addr = XEXP (inner, 0);
1009 if (GET_CODE (addr) == PRE_INC
1010 || GET_CODE (addr) == PRE_DEC
1011 || (GET_CODE (addr) == PRE_MODIFY
1012 && !legitimate_indexed_address_p (XEXP (addr, 1), 0)))
1013 return false;
1014 if (GET_CODE (addr) == LO_SUM
1015 && GET_CODE (XEXP (addr, 0)) == REG
1016 && GET_CODE (XEXP (addr, 1)) == CONST)
1017 addr = XEXP (XEXP (addr, 1), 0);
1018 if (GET_CODE (addr) != PLUS)
1019 return true;
1020 offset = XEXP (addr, 1);
1021 if (GET_CODE (offset) != CONST_INT)
1022 return true;
1023 return INTVAL (offset) % 4 == 0;
1024 })
1025
1026 ;; Return 1 if the operand, used inside a MEM, is a SYMBOL_REF.
1027 (define_predicate "symbol_ref_operand"
1028 (and (match_code "symbol_ref")
1029 (match_test "(mode == VOIDmode || GET_MODE (op) == mode)
1030 && (DEFAULT_ABI != ABI_AIX || SYMBOL_REF_FUNCTION_P (op))")))
1031
1032 ;; Return 1 if op is an operand that can be loaded via the GOT.
1033 ;; or non-special register register field no cr0
1034 (define_predicate "got_operand"
1035 (match_code "symbol_ref,const,label_ref"))
1036
1037 ;; Return 1 if op is a simple reference that can be loaded via the GOT,
1038 ;; excluding labels involving addition.
1039 (define_predicate "got_no_const_operand"
1040 (match_code "symbol_ref,label_ref"))
1041
1042 ;; Return 1 if op is a SYMBOL_REF for a TLS symbol.
1043 (define_predicate "rs6000_tls_symbol_ref"
1044 (and (match_code "symbol_ref")
1045 (match_test "RS6000_SYMBOL_REF_TLS_P (op)")))
1046
1047 ;; Return 1 if the operand, used inside a MEM, is a valid first argument
1048 ;; to CALL. This is a SYMBOL_REF, a pseudo-register, LR or CTR.
1049 (define_predicate "call_operand"
1050 (if_then_else (match_code "reg")
1051 (match_test "REGNO (op) == LR_REGNO
1052 || REGNO (op) == CTR_REGNO
1053 || REGNO (op) >= FIRST_PSEUDO_REGISTER")
1054 (match_code "symbol_ref")))
1055
1056 ;; Return 1 if the operand is a SYMBOL_REF for a function known to be in
1057 ;; this file.
1058 (define_predicate "current_file_function_operand"
1059 (and (match_code "symbol_ref")
1060 (match_test "(DEFAULT_ABI != ABI_AIX || SYMBOL_REF_FUNCTION_P (op))
1061 && (SYMBOL_REF_LOCAL_P (op)
1062 || (op == XEXP (DECL_RTL (current_function_decl), 0)
1063 && !decl_replaceable_p (current_function_decl)))
1064 && !((DEFAULT_ABI == ABI_AIX
1065 || DEFAULT_ABI == ABI_ELFv2)
1066 && (SYMBOL_REF_EXTERNAL_P (op)
1067 || SYMBOL_REF_WEAK (op)))")))
1068
1069 ;; Return 1 if this operand is a valid input for a move insn.
1070 (define_predicate "input_operand"
1071 (match_code "symbol_ref,const,reg,subreg,mem,
1072 const_double,const_wide_int,const_vector,const_int")
1073 {
1074 /* Memory is always valid. */
1075 if (memory_operand (op, mode))
1076 return 1;
1077
1078 /* For floating-point, easy constants are valid. */
1079 if (SCALAR_FLOAT_MODE_P (mode)
1080 && easy_fp_constant (op, mode))
1081 return 1;
1082
1083 /* Allow any integer constant. */
1084 if (GET_MODE_CLASS (mode) == MODE_INT
1085 && CONST_SCALAR_INT_P (op))
1086 return 1;
1087
1088 /* Allow easy vector constants. */
1089 if (GET_CODE (op) == CONST_VECTOR
1090 && easy_vector_constant (op, mode))
1091 return 1;
1092
1093 /* For floating-point or multi-word mode, the only remaining valid type
1094 is a register. */
1095 if (SCALAR_FLOAT_MODE_P (mode)
1096 || GET_MODE_SIZE (mode) > UNITS_PER_WORD)
1097 return register_operand (op, mode);
1098
1099 /* We don't allow moving the carry bit around. */
1100 if (ca_operand (op, mode))
1101 return 0;
1102
1103 /* The only cases left are integral modes one word or smaller (we
1104 do not get called for MODE_CC values). These can be in any
1105 register. */
1106 if (register_operand (op, mode))
1107 return 1;
1108
1109 /* V.4 allows SYMBOL_REFs and CONSTs that are in the small data region
1110 to be valid. */
1111 if (DEFAULT_ABI == ABI_V4
1112 && (GET_CODE (op) == SYMBOL_REF || GET_CODE (op) == CONST)
1113 && small_data_operand (op, Pmode))
1114 return 1;
1115
1116 return 0;
1117 })
1118
1119 ;; Return 1 if this operand is a valid input for a vsx_splat insn.
1120 (define_predicate "splat_input_operand"
1121 (match_code "reg,subreg,mem")
1122 {
1123 machine_mode vmode;
1124
1125 if (mode == DFmode)
1126 vmode = V2DFmode;
1127 else if (mode == DImode)
1128 vmode = V2DImode;
1129 else if (mode == SImode && TARGET_P9_VECTOR)
1130 vmode = V4SImode;
1131 else if (mode == SFmode && TARGET_P9_VECTOR)
1132 vmode = V4SFmode;
1133 else
1134 return false;
1135
1136 if (MEM_P (op))
1137 {
1138 rtx addr = XEXP (op, 0);
1139
1140 if (! volatile_ok && MEM_VOLATILE_P (op))
1141 return 0;
1142
1143 if (lra_in_progress || reload_completed)
1144 return indexed_or_indirect_address (addr, vmode);
1145 else
1146 return memory_address_addr_space_p (vmode, addr, MEM_ADDR_SPACE (op));
1147 }
1148 return gpc_reg_operand (op, mode);
1149 })
1150
1151 ;; Return true if operand is an operator used in rotate-and-mask instructions.
1152 (define_predicate "rotate_mask_operator"
1153 (match_code "rotate,ashift,lshiftrt"))
1154
1155 ;; Return true if operand is boolean operator.
1156 (define_predicate "boolean_operator"
1157 (match_code "and,ior,xor"))
1158
1159 ;; Return true if operand is OR-form of boolean operator.
1160 (define_predicate "boolean_or_operator"
1161 (match_code "ior,xor"))
1162
1163 ;; Return true if operand is an equality operator.
1164 (define_special_predicate "equality_operator"
1165 (match_code "eq,ne"))
1166
1167 ;; Return 1 if OP is a comparison operation that is valid for a branch
1168 ;; instruction. We check the opcode against the mode of the CC value.
1169 ;; validate_condition_mode is an assertion.
1170 (define_predicate "branch_comparison_operator"
1171 (and (match_operand 0 "comparison_operator")
1172 (and (match_test "GET_MODE_CLASS (GET_MODE (XEXP (op, 0))) == MODE_CC")
1173 (match_test "validate_condition_mode (GET_CODE (op),
1174 GET_MODE (XEXP (op, 0))),
1175 1"))))
1176
1177 ;; Return 1 if OP is an unsigned comparison operator.
1178 (define_predicate "unsigned_comparison_operator"
1179 (match_code "ltu,gtu,leu,geu"))
1180
1181 ;; Return 1 if OP is a signed comparison operator.
1182 (define_predicate "signed_comparison_operator"
1183 (match_code "lt,gt,le,ge"))
1184
1185 ;; Return 1 if OP is a comparison operation that is valid for an SCC insn --
1186 ;; it must be a positive comparison.
1187 (define_predicate "scc_comparison_operator"
1188 (and (match_operand 0 "branch_comparison_operator")
1189 (match_code "eq,lt,gt,ltu,gtu,unordered")))
1190
1191 ;; Return 1 if OP is a comparison operation whose inverse would be valid for
1192 ;; an SCC insn.
1193 (define_predicate "scc_rev_comparison_operator"
1194 (and (match_operand 0 "branch_comparison_operator")
1195 (match_code "ne,le,ge,leu,geu,ordered")))
1196
1197 ;; Return 1 if OP is a comparison operator suitable for floating point
1198 ;; vector/scalar comparisons that generate a -1/0 mask.
1199 (define_predicate "fpmask_comparison_operator"
1200 (match_code "eq,gt,ge"))
1201
1202 ;; Return 1 if OP is a comparison operator suitable for vector/scalar
1203 ;; comparisons that generate a 0/-1 mask (i.e. the inverse of
1204 ;; fpmask_comparison_operator).
1205 (define_predicate "invert_fpmask_comparison_operator"
1206 (match_code "ne,unlt,unle"))
1207
1208 ;; Return 1 if OP is a comparison operation suitable for integer vector/scalar
1209 ;; comparisons that generate a -1/0 mask.
1210 (define_predicate "vecint_comparison_operator"
1211 (match_code "eq,gt,gtu"))
1212
1213 ;; Return 1 if OP is a comparison operation that is valid for a branch
1214 ;; insn, which is true if the corresponding bit in the CC register is set.
1215 (define_predicate "branch_positive_comparison_operator"
1216 (and (match_operand 0 "branch_comparison_operator")
1217 (match_code "eq,lt,gt,ltu,gtu,unordered")))
1218
1219 ;; Return 1 if OP is a load multiple operation, known to be a PARALLEL.
1220 (define_predicate "load_multiple_operation"
1221 (match_code "parallel")
1222 {
1223 int count = XVECLEN (op, 0);
1224 unsigned int dest_regno;
1225 rtx src_addr;
1226 int i;
1227
1228 /* Perform a quick check so we don't blow up below. */
1229 if (count <= 1
1230 || GET_CODE (XVECEXP (op, 0, 0)) != SET
1231 || GET_CODE (SET_DEST (XVECEXP (op, 0, 0))) != REG
1232 || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != MEM)
1233 return 0;
1234
1235 dest_regno = REGNO (SET_DEST (XVECEXP (op, 0, 0)));
1236 src_addr = XEXP (SET_SRC (XVECEXP (op, 0, 0)), 0);
1237
1238 for (i = 1; i < count; i++)
1239 {
1240 rtx elt = XVECEXP (op, 0, i);
1241
1242 if (GET_CODE (elt) != SET
1243 || GET_CODE (SET_DEST (elt)) != REG
1244 || GET_MODE (SET_DEST (elt)) != SImode
1245 || REGNO (SET_DEST (elt)) != dest_regno + i
1246 || GET_CODE (SET_SRC (elt)) != MEM
1247 || GET_MODE (SET_SRC (elt)) != SImode
1248 || GET_CODE (XEXP (SET_SRC (elt), 0)) != PLUS
1249 || ! rtx_equal_p (XEXP (XEXP (SET_SRC (elt), 0), 0), src_addr)
1250 || GET_CODE (XEXP (XEXP (SET_SRC (elt), 0), 1)) != CONST_INT
1251 || INTVAL (XEXP (XEXP (SET_SRC (elt), 0), 1)) != i * 4)
1252 return 0;
1253 }
1254
1255 return 1;
1256 })
1257
1258 ;; Return 1 if OP is a store multiple operation, known to be a PARALLEL.
1259 ;; The second vector element is a CLOBBER.
1260 (define_predicate "store_multiple_operation"
1261 (match_code "parallel")
1262 {
1263 int count = XVECLEN (op, 0) - 1;
1264 unsigned int src_regno;
1265 rtx dest_addr;
1266 int i;
1267
1268 /* Perform a quick check so we don't blow up below. */
1269 if (count <= 1
1270 || GET_CODE (XVECEXP (op, 0, 0)) != SET
1271 || GET_CODE (SET_DEST (XVECEXP (op, 0, 0))) != MEM
1272 || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != REG)
1273 return 0;
1274
1275 src_regno = REGNO (SET_SRC (XVECEXP (op, 0, 0)));
1276 dest_addr = XEXP (SET_DEST (XVECEXP (op, 0, 0)), 0);
1277
1278 for (i = 1; i < count; i++)
1279 {
1280 rtx elt = XVECEXP (op, 0, i + 1);
1281
1282 if (GET_CODE (elt) != SET
1283 || GET_CODE (SET_SRC (elt)) != REG
1284 || GET_MODE (SET_SRC (elt)) != SImode
1285 || REGNO (SET_SRC (elt)) != src_regno + i
1286 || GET_CODE (SET_DEST (elt)) != MEM
1287 || GET_MODE (SET_DEST (elt)) != SImode
1288 || GET_CODE (XEXP (SET_DEST (elt), 0)) != PLUS
1289 || ! rtx_equal_p (XEXP (XEXP (SET_DEST (elt), 0), 0), dest_addr)
1290 || GET_CODE (XEXP (XEXP (SET_DEST (elt), 0), 1)) != CONST_INT
1291 || INTVAL (XEXP (XEXP (SET_DEST (elt), 0), 1)) != i * 4)
1292 return 0;
1293 }
1294
1295 return 1;
1296 })
1297
1298 ;; Return 1 if OP is valid for a save_world call in prologue, known to be
1299 ;; a PARLLEL.
1300 (define_predicate "save_world_operation"
1301 (match_code "parallel")
1302 {
1303 int index;
1304 int i;
1305 rtx elt;
1306 int count = XVECLEN (op, 0);
1307
1308 if (count != 54)
1309 return 0;
1310
1311 index = 0;
1312 if (GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER
1313 || GET_CODE (XVECEXP (op, 0, index++)) != USE)
1314 return 0;
1315
1316 for (i=1; i <= 18; i++)
1317 {
1318 elt = XVECEXP (op, 0, index++);
1319 if (GET_CODE (elt) != SET
1320 || GET_CODE (SET_DEST (elt)) != MEM
1321 || ! memory_operand (SET_DEST (elt), DFmode)
1322 || GET_CODE (SET_SRC (elt)) != REG
1323 || GET_MODE (SET_SRC (elt)) != DFmode)
1324 return 0;
1325 }
1326
1327 for (i=1; i <= 12; i++)
1328 {
1329 elt = XVECEXP (op, 0, index++);
1330 if (GET_CODE (elt) != SET
1331 || GET_CODE (SET_DEST (elt)) != MEM
1332 || GET_CODE (SET_SRC (elt)) != REG
1333 || GET_MODE (SET_SRC (elt)) != V4SImode)
1334 return 0;
1335 }
1336
1337 for (i=1; i <= 19; i++)
1338 {
1339 elt = XVECEXP (op, 0, index++);
1340 if (GET_CODE (elt) != SET
1341 || GET_CODE (SET_DEST (elt)) != MEM
1342 || ! memory_operand (SET_DEST (elt), Pmode)
1343 || GET_CODE (SET_SRC (elt)) != REG
1344 || GET_MODE (SET_SRC (elt)) != Pmode)
1345 return 0;
1346 }
1347
1348 elt = XVECEXP (op, 0, index++);
1349 if (GET_CODE (elt) != SET
1350 || GET_CODE (SET_DEST (elt)) != MEM
1351 || ! memory_operand (SET_DEST (elt), Pmode)
1352 || GET_CODE (SET_SRC (elt)) != REG
1353 || REGNO (SET_SRC (elt)) != CR2_REGNO
1354 || GET_MODE (SET_SRC (elt)) != Pmode)
1355 return 0;
1356
1357 if (GET_CODE (XVECEXP (op, 0, index++)) != SET
1358 || GET_CODE (XVECEXP (op, 0, index++)) != SET)
1359 return 0;
1360 return 1;
1361 })
1362
1363 ;; Return 1 if OP is valid for a restore_world call in epilogue, known to be
1364 ;; a PARLLEL.
1365 (define_predicate "restore_world_operation"
1366 (match_code "parallel")
1367 {
1368 int index;
1369 int i;
1370 rtx elt;
1371 int count = XVECLEN (op, 0);
1372
1373 if (count != 59)
1374 return 0;
1375
1376 index = 0;
1377 if (GET_CODE (XVECEXP (op, 0, index++)) != RETURN
1378 || GET_CODE (XVECEXP (op, 0, index++)) != USE
1379 || GET_CODE (XVECEXP (op, 0, index++)) != USE
1380 || GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER)
1381 return 0;
1382
1383 elt = XVECEXP (op, 0, index++);
1384 if (GET_CODE (elt) != SET
1385 || GET_CODE (SET_SRC (elt)) != MEM
1386 || ! memory_operand (SET_SRC (elt), Pmode)
1387 || GET_CODE (SET_DEST (elt)) != REG
1388 || REGNO (SET_DEST (elt)) != CR2_REGNO
1389 || GET_MODE (SET_DEST (elt)) != Pmode)
1390 return 0;
1391
1392 for (i=1; i <= 19; i++)
1393 {
1394 elt = XVECEXP (op, 0, index++);
1395 if (GET_CODE (elt) != SET
1396 || GET_CODE (SET_SRC (elt)) != MEM
1397 || ! memory_operand (SET_SRC (elt), Pmode)
1398 || GET_CODE (SET_DEST (elt)) != REG
1399 || GET_MODE (SET_DEST (elt)) != Pmode)
1400 return 0;
1401 }
1402
1403 for (i=1; i <= 12; i++)
1404 {
1405 elt = XVECEXP (op, 0, index++);
1406 if (GET_CODE (elt) != SET
1407 || GET_CODE (SET_SRC (elt)) != MEM
1408 || GET_CODE (SET_DEST (elt)) != REG
1409 || GET_MODE (SET_DEST (elt)) != V4SImode)
1410 return 0;
1411 }
1412
1413 for (i=1; i <= 18; i++)
1414 {
1415 elt = XVECEXP (op, 0, index++);
1416 if (GET_CODE (elt) != SET
1417 || GET_CODE (SET_SRC (elt)) != MEM
1418 || ! memory_operand (SET_SRC (elt), DFmode)
1419 || GET_CODE (SET_DEST (elt)) != REG
1420 || GET_MODE (SET_DEST (elt)) != DFmode)
1421 return 0;
1422 }
1423
1424 if (GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER
1425 || GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER
1426 || GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER
1427 || GET_CODE (XVECEXP (op, 0, index++)) != CLOBBER
1428 || GET_CODE (XVECEXP (op, 0, index++)) != USE)
1429 return 0;
1430 return 1;
1431 })
1432
1433 ;; Return 1 if OP is valid for a vrsave call, known to be a PARALLEL.
1434 (define_predicate "vrsave_operation"
1435 (match_code "parallel")
1436 {
1437 int count = XVECLEN (op, 0);
1438 unsigned int dest_regno, src_regno;
1439 int i;
1440
1441 if (count <= 1
1442 || GET_CODE (XVECEXP (op, 0, 0)) != SET
1443 || GET_CODE (SET_DEST (XVECEXP (op, 0, 0))) != REG
1444 || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != UNSPEC_VOLATILE
1445 || XINT (SET_SRC (XVECEXP (op, 0, 0)), 1) != UNSPECV_SET_VRSAVE)
1446 return 0;
1447
1448 dest_regno = REGNO (SET_DEST (XVECEXP (op, 0, 0)));
1449 src_regno = REGNO (XVECEXP (SET_SRC (XVECEXP (op, 0, 0)), 0, 1));
1450
1451 if (dest_regno != VRSAVE_REGNO || src_regno != VRSAVE_REGNO)
1452 return 0;
1453
1454 for (i = 1; i < count; i++)
1455 {
1456 rtx elt = XVECEXP (op, 0, i);
1457
1458 if (GET_CODE (elt) != CLOBBER
1459 && GET_CODE (elt) != SET)
1460 return 0;
1461 }
1462
1463 return 1;
1464 })
1465
1466 ;; Return 1 if OP is valid for mfcr insn, known to be a PARALLEL.
1467 (define_predicate "mfcr_operation"
1468 (match_code "parallel")
1469 {
1470 int count = XVECLEN (op, 0);
1471 int i;
1472
1473 /* Perform a quick check so we don't blow up below. */
1474 if (count < 1
1475 || GET_CODE (XVECEXP (op, 0, 0)) != SET
1476 || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != UNSPEC
1477 || XVECLEN (SET_SRC (XVECEXP (op, 0, 0)), 0) != 2)
1478 return 0;
1479
1480 for (i = 0; i < count; i++)
1481 {
1482 rtx exp = XVECEXP (op, 0, i);
1483 rtx unspec;
1484 int maskval;
1485 rtx src_reg;
1486
1487 src_reg = XVECEXP (SET_SRC (exp), 0, 0);
1488
1489 if (GET_CODE (src_reg) != REG
1490 || GET_MODE (src_reg) != CCmode
1491 || ! CR_REGNO_P (REGNO (src_reg)))
1492 return 0;
1493
1494 if (GET_CODE (exp) != SET
1495 || GET_CODE (SET_DEST (exp)) != REG
1496 || GET_MODE (SET_DEST (exp)) != SImode
1497 || ! INT_REGNO_P (REGNO (SET_DEST (exp))))
1498 return 0;
1499 unspec = SET_SRC (exp);
1500 maskval = 1 << (MAX_CR_REGNO - REGNO (src_reg));
1501
1502 if (GET_CODE (unspec) != UNSPEC
1503 || XINT (unspec, 1) != UNSPEC_MOVESI_FROM_CR
1504 || XVECLEN (unspec, 0) != 2
1505 || XVECEXP (unspec, 0, 0) != src_reg
1506 || GET_CODE (XVECEXP (unspec, 0, 1)) != CONST_INT
1507 || INTVAL (XVECEXP (unspec, 0, 1)) != maskval)
1508 return 0;
1509 }
1510 return 1;
1511 })
1512
1513 ;; Return 1 if OP is valid for mtcrf insn, known to be a PARALLEL.
1514 (define_predicate "mtcrf_operation"
1515 (match_code "parallel")
1516 {
1517 int count = XVECLEN (op, 0);
1518 int i;
1519 rtx src_reg;
1520
1521 /* Perform a quick check so we don't blow up below. */
1522 if (count < 1
1523 || GET_CODE (XVECEXP (op, 0, 0)) != SET
1524 || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != UNSPEC
1525 || XVECLEN (SET_SRC (XVECEXP (op, 0, 0)), 0) != 2)
1526 return 0;
1527 src_reg = XVECEXP (SET_SRC (XVECEXP (op, 0, 0)), 0, 0);
1528
1529 if (GET_CODE (src_reg) != REG
1530 || GET_MODE (src_reg) != SImode
1531 || ! INT_REGNO_P (REGNO (src_reg)))
1532 return 0;
1533
1534 for (i = 0; i < count; i++)
1535 {
1536 rtx exp = XVECEXP (op, 0, i);
1537 rtx unspec;
1538 int maskval;
1539
1540 if (GET_CODE (exp) != SET
1541 || GET_CODE (SET_DEST (exp)) != REG
1542 || GET_MODE (SET_DEST (exp)) != CCmode
1543 || ! CR_REGNO_P (REGNO (SET_DEST (exp))))
1544 return 0;
1545 unspec = SET_SRC (exp);
1546 maskval = 1 << (MAX_CR_REGNO - REGNO (SET_DEST (exp)));
1547
1548 if (GET_CODE (unspec) != UNSPEC
1549 || XINT (unspec, 1) != UNSPEC_MOVESI_TO_CR
1550 || XVECLEN (unspec, 0) != 2
1551 || XVECEXP (unspec, 0, 0) != src_reg
1552 || GET_CODE (XVECEXP (unspec, 0, 1)) != CONST_INT
1553 || INTVAL (XVECEXP (unspec, 0, 1)) != maskval)
1554 return 0;
1555 }
1556 return 1;
1557 })
1558
1559 ;; Return 1 if OP is valid for crsave insn, known to be a PARALLEL.
1560 (define_predicate "crsave_operation"
1561 (match_code "parallel")
1562 {
1563 int count = XVECLEN (op, 0);
1564 int i;
1565
1566 for (i = 1; i < count; i++)
1567 {
1568 rtx exp = XVECEXP (op, 0, i);
1569
1570 if (GET_CODE (exp) != USE
1571 || GET_CODE (XEXP (exp, 0)) != REG
1572 || GET_MODE (XEXP (exp, 0)) != CCmode
1573 || ! CR_REGNO_P (REGNO (XEXP (exp, 0))))
1574 return 0;
1575 }
1576 return 1;
1577 })
1578
1579 ;; Return 1 if OP is valid for lmw insn, known to be a PARALLEL.
1580 (define_predicate "lmw_operation"
1581 (match_code "parallel")
1582 {
1583 int count = XVECLEN (op, 0);
1584 unsigned int dest_regno;
1585 rtx src_addr;
1586 unsigned int base_regno;
1587 HOST_WIDE_INT offset;
1588 int i;
1589
1590 /* Perform a quick check so we don't blow up below. */
1591 if (count <= 1
1592 || GET_CODE (XVECEXP (op, 0, 0)) != SET
1593 || GET_CODE (SET_DEST (XVECEXP (op, 0, 0))) != REG
1594 || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != MEM)
1595 return 0;
1596
1597 dest_regno = REGNO (SET_DEST (XVECEXP (op, 0, 0)));
1598 src_addr = XEXP (SET_SRC (XVECEXP (op, 0, 0)), 0);
1599
1600 if (dest_regno > 31
1601 || count != 32 - (int) dest_regno)
1602 return 0;
1603
1604 if (legitimate_indirect_address_p (src_addr, 0))
1605 {
1606 offset = 0;
1607 base_regno = REGNO (src_addr);
1608 if (base_regno == 0)
1609 return 0;
1610 }
1611 else if (rs6000_legitimate_offset_address_p (SImode, src_addr, false, false))
1612 {
1613 offset = INTVAL (XEXP (src_addr, 1));
1614 base_regno = REGNO (XEXP (src_addr, 0));
1615 }
1616 else
1617 return 0;
1618
1619 for (i = 0; i < count; i++)
1620 {
1621 rtx elt = XVECEXP (op, 0, i);
1622 rtx newaddr;
1623 rtx addr_reg;
1624 HOST_WIDE_INT newoffset;
1625
1626 if (GET_CODE (elt) != SET
1627 || GET_CODE (SET_DEST (elt)) != REG
1628 || GET_MODE (SET_DEST (elt)) != SImode
1629 || REGNO (SET_DEST (elt)) != dest_regno + i
1630 || GET_CODE (SET_SRC (elt)) != MEM
1631 || GET_MODE (SET_SRC (elt)) != SImode)
1632 return 0;
1633 newaddr = XEXP (SET_SRC (elt), 0);
1634 if (legitimate_indirect_address_p (newaddr, 0))
1635 {
1636 newoffset = 0;
1637 addr_reg = newaddr;
1638 }
1639 else if (rs6000_legitimate_offset_address_p (SImode, newaddr, false, false))
1640 {
1641 addr_reg = XEXP (newaddr, 0);
1642 newoffset = INTVAL (XEXP (newaddr, 1));
1643 }
1644 else
1645 return 0;
1646 if (REGNO (addr_reg) != base_regno
1647 || newoffset != offset + 4 * i)
1648 return 0;
1649 }
1650
1651 return 1;
1652 })
1653
1654 ;; Return 1 if OP is valid for stmw insn, known to be a PARALLEL.
1655 (define_predicate "stmw_operation"
1656 (match_code "parallel")
1657 {
1658 int count = XVECLEN (op, 0);
1659 unsigned int src_regno;
1660 rtx dest_addr;
1661 unsigned int base_regno;
1662 HOST_WIDE_INT offset;
1663 int i;
1664
1665 /* Perform a quick check so we don't blow up below. */
1666 if (count <= 1
1667 || GET_CODE (XVECEXP (op, 0, 0)) != SET
1668 || GET_CODE (SET_DEST (XVECEXP (op, 0, 0))) != MEM
1669 || GET_CODE (SET_SRC (XVECEXP (op, 0, 0))) != REG)
1670 return 0;
1671
1672 src_regno = REGNO (SET_SRC (XVECEXP (op, 0, 0)));
1673 dest_addr = XEXP (SET_DEST (XVECEXP (op, 0, 0)), 0);
1674
1675 if (src_regno > 31
1676 || count != 32 - (int) src_regno)
1677 return 0;
1678
1679 if (legitimate_indirect_address_p (dest_addr, 0))
1680 {
1681 offset = 0;
1682 base_regno = REGNO (dest_addr);
1683 if (base_regno == 0)
1684 return 0;
1685 }
1686 else if (rs6000_legitimate_offset_address_p (SImode, dest_addr, false, false))
1687 {
1688 offset = INTVAL (XEXP (dest_addr, 1));
1689 base_regno = REGNO (XEXP (dest_addr, 0));
1690 }
1691 else
1692 return 0;
1693
1694 for (i = 0; i < count; i++)
1695 {
1696 rtx elt = XVECEXP (op, 0, i);
1697 rtx newaddr;
1698 rtx addr_reg;
1699 HOST_WIDE_INT newoffset;
1700
1701 if (GET_CODE (elt) != SET
1702 || GET_CODE (SET_SRC (elt)) != REG
1703 || GET_MODE (SET_SRC (elt)) != SImode
1704 || REGNO (SET_SRC (elt)) != src_regno + i
1705 || GET_CODE (SET_DEST (elt)) != MEM
1706 || GET_MODE (SET_DEST (elt)) != SImode)
1707 return 0;
1708 newaddr = XEXP (SET_DEST (elt), 0);
1709 if (legitimate_indirect_address_p (newaddr, 0))
1710 {
1711 newoffset = 0;
1712 addr_reg = newaddr;
1713 }
1714 else if (rs6000_legitimate_offset_address_p (SImode, newaddr, false, false))
1715 {
1716 addr_reg = XEXP (newaddr, 0);
1717 newoffset = INTVAL (XEXP (newaddr, 1));
1718 }
1719 else
1720 return 0;
1721 if (REGNO (addr_reg) != base_regno
1722 || newoffset != offset + 4 * i)
1723 return 0;
1724 }
1725
1726 return 1;
1727 })
1728
1729 ;; Return 1 if OP is a stack tie operand.
1730 (define_predicate "tie_operand"
1731 (match_code "parallel")
1732 {
1733 return (GET_CODE (XVECEXP (op, 0, 0)) == SET
1734 && GET_CODE (XEXP (XVECEXP (op, 0, 0), 0)) == MEM
1735 && GET_MODE (XEXP (XVECEXP (op, 0, 0), 0)) == BLKmode
1736 && XEXP (XVECEXP (op, 0, 0), 1) == const0_rtx);
1737 })
1738
1739 ;; Match a small code model toc reference (or medium and large
1740 ;; model toc references before reload).
1741 (define_predicate "small_toc_ref"
1742 (match_code "unspec,plus")
1743 {
1744 if (GET_CODE (op) == PLUS && add_cint_operand (XEXP (op, 1), mode))
1745 op = XEXP (op, 0);
1746
1747 return GET_CODE (op) == UNSPEC && XINT (op, 1) == UNSPEC_TOCREL;
1748 })
1749
1750 ;; Match the TOC memory operand that can be fused with an addis instruction.
1751 ;; This is used in matching a potential fused address before register
1752 ;; allocation.
1753 (define_predicate "toc_fusion_mem_raw"
1754 (match_code "mem")
1755 {
1756 if (!TARGET_TOC_FUSION_INT || !can_create_pseudo_p ())
1757 return false;
1758
1759 return small_toc_ref (XEXP (op, 0), Pmode);
1760 })
1761
1762 ;; Match the memory operand that has been fused with an addis instruction and
1763 ;; wrapped inside of an (unspec [...] UNSPEC_FUSION_ADDIS) wrapper.
1764 (define_predicate "toc_fusion_mem_wrapped"
1765 (match_code "mem")
1766 {
1767 rtx addr;
1768
1769 if (!TARGET_TOC_FUSION_INT)
1770 return false;
1771
1772 if (!MEM_P (op))
1773 return false;
1774
1775 addr = XEXP (op, 0);
1776 return (GET_CODE (addr) == UNSPEC && XINT (addr, 1) == UNSPEC_FUSION_ADDIS);
1777 })
1778
1779 ;; Match the first insn (addis) in fusing the combination of addis and loads to
1780 ;; GPR registers on power8.
1781 (define_predicate "fusion_gpr_addis"
1782 (match_code "const_int,high,plus")
1783 {
1784 HOST_WIDE_INT value;
1785 rtx int_const;
1786
1787 if (GET_CODE (op) == HIGH)
1788 return 1;
1789
1790 if (CONST_INT_P (op))
1791 int_const = op;
1792
1793 else if (GET_CODE (op) == PLUS
1794 && base_reg_operand (XEXP (op, 0), Pmode)
1795 && CONST_INT_P (XEXP (op, 1)))
1796 int_const = XEXP (op, 1);
1797
1798 else
1799 return 0;
1800
1801 value = INTVAL (int_const);
1802 if ((value & (HOST_WIDE_INT)0xffff) != 0)
1803 return 0;
1804
1805 if ((value & (HOST_WIDE_INT)0xffff0000) == 0)
1806 return 0;
1807
1808 /* Power8 currently will only do the fusion if the top 11 bits of the addis
1809 value are all 1's or 0's. Ignore this restriction if we are testing
1810 advanced fusion. */
1811 if (TARGET_P9_FUSION)
1812 return 1;
1813
1814 return (IN_RANGE (value >> 16, -32, 31));
1815 })
1816
1817 ;; Match the second insn (lbz, lhz, lwz, ld) in fusing the combination of addis
1818 ;; and loads to GPR registers on power8.
1819 (define_predicate "fusion_gpr_mem_load"
1820 (match_code "mem,sign_extend,zero_extend")
1821 {
1822 rtx addr, base, offset;
1823
1824 /* Handle sign/zero extend. */
1825 if (GET_CODE (op) == ZERO_EXTEND
1826 || (TARGET_P8_FUSION_SIGN && GET_CODE (op) == SIGN_EXTEND))
1827 {
1828 op = XEXP (op, 0);
1829 mode = GET_MODE (op);
1830 }
1831
1832 if (!MEM_P (op))
1833 return 0;
1834
1835 switch (mode)
1836 {
1837 case QImode:
1838 case HImode:
1839 case SImode:
1840 break;
1841
1842 case DImode:
1843 if (!TARGET_POWERPC64)
1844 return 0;
1845 break;
1846
1847 default:
1848 return 0;
1849 }
1850
1851 addr = XEXP (op, 0);
1852 if (GET_CODE (addr) != PLUS && GET_CODE (addr) != LO_SUM)
1853 return 0;
1854
1855 base = XEXP (addr, 0);
1856 if (!base_reg_operand (base, GET_MODE (base)))
1857 return 0;
1858
1859 offset = XEXP (addr, 1);
1860
1861 if (GET_CODE (addr) == PLUS)
1862 return satisfies_constraint_I (offset);
1863
1864 else if (GET_CODE (addr) == LO_SUM)
1865 {
1866 if (TARGET_XCOFF || (TARGET_ELF && TARGET_POWERPC64))
1867 return small_toc_ref (offset, GET_MODE (offset));
1868
1869 else if (TARGET_ELF && !TARGET_POWERPC64)
1870 return CONSTANT_P (offset);
1871 }
1872
1873 return 0;
1874 })
1875
1876 ;; Match a GPR load (lbz, lhz, lwz, ld) that uses a combined address in the
1877 ;; memory field with both the addis and the memory offset. Sign extension
1878 ;; is not handled here, since lha and lwa are not fused.
1879 ;; With P9 fusion, also match a fpr/vector load and float_extend
1880 (define_predicate "fusion_addis_mem_combo_load"
1881 (match_code "mem,zero_extend,float_extend")
1882 {
1883 rtx addr, base, offset;
1884
1885 /* Handle zero/float extend. */
1886 if (GET_CODE (op) == ZERO_EXTEND || GET_CODE (op) == FLOAT_EXTEND)
1887 {
1888 op = XEXP (op, 0);
1889 mode = GET_MODE (op);
1890 }
1891
1892 if (!MEM_P (op))
1893 return 0;
1894
1895 switch (mode)
1896 {
1897 case QImode:
1898 case HImode:
1899 case SImode:
1900 break;
1901
1902 /* Do not fuse 64-bit DImode in 32-bit since it splits into two
1903 separate instructions. */
1904 case DImode:
1905 if (!TARGET_POWERPC64)
1906 return 0;
1907 break;
1908
1909 /* ISA 2.08/power8 only had fusion of GPR loads. */
1910 case SFmode:
1911 if (!TARGET_P9_FUSION)
1912 return 0;
1913 break;
1914
1915 /* ISA 2.08/power8 only had fusion of GPR loads. Do not allow 64-bit
1916 DFmode in 32-bit if -msoft-float since it splits into two separate
1917 instructions. */
1918 case DFmode:
1919 if ((!TARGET_POWERPC64 && !TARGET_DF_FPR) || !TARGET_P9_FUSION)
1920 return 0;
1921 break;
1922
1923 default:
1924 return 0;
1925 }
1926
1927 addr = XEXP (op, 0);
1928 if (GET_CODE (addr) != PLUS && GET_CODE (addr) != LO_SUM)
1929 return 0;
1930
1931 base = XEXP (addr, 0);
1932 if (!fusion_gpr_addis (base, GET_MODE (base)))
1933 return 0;
1934
1935 offset = XEXP (addr, 1);
1936 if (GET_CODE (addr) == PLUS)
1937 return satisfies_constraint_I (offset);
1938
1939 else if (GET_CODE (addr) == LO_SUM)
1940 {
1941 if (TARGET_XCOFF || (TARGET_ELF && TARGET_POWERPC64))
1942 return small_toc_ref (offset, GET_MODE (offset));
1943
1944 else if (TARGET_ELF && !TARGET_POWERPC64)
1945 return CONSTANT_P (offset);
1946 }
1947
1948 return 0;
1949 })
1950
1951 ;; Like fusion_addis_mem_combo_load, but for stores
1952 (define_predicate "fusion_addis_mem_combo_store"
1953 (match_code "mem")
1954 {
1955 rtx addr, base, offset;
1956
1957 if (!MEM_P (op) || !TARGET_P9_FUSION)
1958 return 0;
1959
1960 switch (mode)
1961 {
1962 case QImode:
1963 case HImode:
1964 case SImode:
1965 case SFmode:
1966 break;
1967
1968 /* Do not fuse 64-bit DImode in 32-bit since it splits into two
1969 separate instructions. */
1970 case DImode:
1971 if (!TARGET_POWERPC64)
1972 return 0;
1973 break;
1974
1975 /* Do not allow 64-bit DFmode in 32-bit if -msoft-float since it splits
1976 into two separate instructions. Do allow fusion if we have hardware
1977 floating point. */
1978 case DFmode:
1979 if (!TARGET_POWERPC64 && !TARGET_DF_FPR)
1980 return 0;
1981 break;
1982
1983 default:
1984 return 0;
1985 }
1986
1987 addr = XEXP (op, 0);
1988 if (GET_CODE (addr) != PLUS && GET_CODE (addr) != LO_SUM)
1989 return 0;
1990
1991 base = XEXP (addr, 0);
1992 if (!fusion_gpr_addis (base, GET_MODE (base)))
1993 return 0;
1994
1995 offset = XEXP (addr, 1);
1996 if (GET_CODE (addr) == PLUS)
1997 return satisfies_constraint_I (offset);
1998
1999 else if (GET_CODE (addr) == LO_SUM)
2000 {
2001 if (TARGET_XCOFF || (TARGET_ELF && TARGET_POWERPC64))
2002 return small_toc_ref (offset, GET_MODE (offset));
2003
2004 else if (TARGET_ELF && !TARGET_POWERPC64)
2005 return CONSTANT_P (offset);
2006 }
2007
2008 return 0;
2009 })
2010
2011 ;; Return true if the operand is a float_extend or zero extend of an
2012 ;; offsettable memory operand suitable for use in fusion
2013 (define_predicate "fusion_offsettable_mem_operand"
2014 (match_code "mem,zero_extend,float_extend")
2015 {
2016 if (GET_CODE (op) == ZERO_EXTEND || GET_CODE (op) == FLOAT_EXTEND)
2017 {
2018 op = XEXP (op, 0);
2019 mode = GET_MODE (op);
2020 }
2021
2022 if (!memory_operand (op, mode))
2023 return 0;
2024
2025 return offsettable_nonstrict_memref_p (op);
2026 })
This page took 0.132481 seconds and 6 git commands to generate.