| 1 |
;; Operand and operator predicates for the GCC CRIS port. |
| 2 |
;; Copyright (C) 2005-2025 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 |
|
| 21 |
;; Operator predicates. |
| 22 |
|
| 23 |
(define_predicate "cris_orthogonal_operator" |
| 24 |
(match_code "plus, minus, ior, and, umin")) |
| 25 |
|
| 26 |
(define_predicate "cris_commutative_orth_op" |
| 27 |
(match_code "plus, ior, and, umin")) |
| 28 |
|
| 29 |
;; By the name, you might think we should include MULT. We don't because |
| 30 |
;; it doesn't accept the same addressing modes as the others (only |
| 31 |
;; registers) and there's also the problem of handling TARGET_MUL_BUG. |
| 32 |
|
| 33 |
(define_predicate "cris_operand_extend_operator" |
| 34 |
(match_code "plus, minus, umin")) |
| 35 |
|
| 36 |
(define_predicate "cris_additive_operand_extend_operator" |
| 37 |
(match_code "plus, minus")) |
| 38 |
|
| 39 |
(define_predicate "cris_extend_operator" |
| 40 |
(match_code "zero_extend, sign_extend")) |
| 41 |
|
| 42 |
(define_predicate "cris_plus_or_bound_operator" |
| 43 |
(match_code "plus, umin")) |
| 44 |
|
| 45 |
;; Used as an operator to get a handle on a already-known-valid MEM rtx:es |
| 46 |
;; (no need to validate the address), where some address expression parts |
| 47 |
;; have their own match_operand. |
| 48 |
|
| 49 |
(define_predicate "cris_mem_op" |
| 50 |
(match_code "mem")) |
| 51 |
|
| 52 |
(define_predicate "cris_load_multiple_op" |
| 53 |
(and (match_code "parallel") |
| 54 |
(match_test "cris_movem_load_rest_p (op)"))) |
| 55 |
|
| 56 |
(define_predicate "cris_store_multiple_op" |
| 57 |
(and (match_code "parallel") |
| 58 |
(match_test "cris_store_multiple_op_p (op)"))) |
| 59 |
|
| 60 |
|
| 61 |
;; Operand helper predicates. |
| 62 |
|
| 63 |
(define_predicate "cris_bdap_const_operand" |
| 64 |
(match_operand 0 "immediate_operand")) |
| 65 |
|
| 66 |
(define_predicate "cris_simple_address_operand" |
| 67 |
(ior (match_operand:SI 0 "register_operand") |
| 68 |
(and (match_code "post_inc") |
| 69 |
(match_test "register_operand (XEXP (op, 0), Pmode)")))) |
| 70 |
|
| 71 |
(define_predicate "cris_simple_operand" |
| 72 |
(ior (match_operand 0 "register_operand") |
| 73 |
(and (match_code "mem") |
| 74 |
(match_test "cris_simple_address_operand (XEXP (op, 0), |
| 75 |
Pmode)")))) |
| 76 |
|
| 77 |
(define_predicate "cris_nonsp_register_operand" |
| 78 |
(and (match_operand 0 "register_operand") |
| 79 |
(match_test "op != stack_pointer_rtx"))) |
| 80 |
|
| 81 |
;; The caller needs to use :SI. |
| 82 |
(define_predicate "cris_bdap_sign_extend_operand" |
| 83 |
; Disabled until <URL:http://gcc.gnu.org/ml/gcc-patches/2005-10/msg01376.html> |
| 84 |
; or <URL:http://gcc.gnu.org/ml/gcc-patches/2005-10/msg00940.html> is committed. |
| 85 |
(match_test "0")) |
| 86 |
; (and (match_code "sign_extend") |
| 87 |
; (and (match_test "MEM_P (XEXP (op, 0))") |
| 88 |
; (match_test "cris_simple_address_operand (XEXP (XEXP (op, 0), 0), |
| 89 |
; Pmode)")))) |
| 90 |
|
| 91 |
;; FIXME: Should not have to test for 1. |
| 92 |
(define_predicate "cris_scale_int_operand" |
| 93 |
(and (match_code "const_int") |
| 94 |
(ior (ior (match_test "op == GEN_INT (4)") |
| 95 |
(match_test "op == const2_rtx")) |
| 96 |
(match_test "op == const1_rtx")))) |
| 97 |
|
| 98 |
;; FIXME: Should be able to assume (reg int). |
| 99 |
(define_predicate "cris_biap_mult_operand" |
| 100 |
(and (match_code "mult") |
| 101 |
(ior (and (match_test "register_operand (XEXP (op, 0), Pmode)") |
| 102 |
(match_test "cris_scale_int_operand (XEXP (op, 1), Pmode)")) |
| 103 |
(and (match_test "cris_scale_int_operand (XEXP (op, 0), Pmode)") |
| 104 |
(match_test "register_operand (XEXP (op, 1), Pmode)"))))) |
| 105 |
|
| 106 |
|
| 107 |
;; Operand predicates. |
| 108 |
|
| 109 |
;; This checks a part of an address, the one that is not a plain register |
| 110 |
;; for an addressing mode using BDAP. |
| 111 |
;; Allowed operands are either: |
| 112 |
;; a) a register |
| 113 |
;; b) a CONST operand (but not a symbol when generating PIC) |
| 114 |
;; c) a [r] or [r+] in SImode, or sign-extend from HI or QI. |
| 115 |
|
| 116 |
(define_predicate "cris_bdap_operand" |
| 117 |
(ior (match_operand 0 "cris_bdap_const_operand") |
| 118 |
(ior (match_operand:SI 0 "cris_simple_operand") |
| 119 |
(match_operand:SI 0 "cris_bdap_sign_extend_operand")))) |
| 120 |
|
| 121 |
;; This is similar to cris_bdap_operand: |
| 122 |
;; It checks a part of an address, the one that is not a plain register |
| 123 |
;; for an addressing mode using BDAP or BIAP. |
| 124 |
;; Allowed operands are either: |
| 125 |
;; a) a register |
| 126 |
;; b) a CONST operand (but not a symbol when generating PIC) |
| 127 |
;; c) a mult of (1, 2 or 4) and a register |
| 128 |
;; d) a [r] or [r+] in SImode, or sign-extend from HI or QI. */ |
| 129 |
|
| 130 |
(define_predicate "cris_bdap_biap_operand" |
| 131 |
(ior (match_operand 0 "cris_bdap_operand") |
| 132 |
(match_operand 0 "cris_biap_mult_operand"))) |