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