1 ;; Operand and operator predicates for the GCC CRIS port.
2 ;; Copyright (C) 2005-2014 Free Software Foundation, Inc.
4 ;; This file is part of GCC.
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)
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.
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/>.
21 ;; Operator predicates.
23 (define_predicate "cris_orthogonal_operator"
24 (match_code "plus, minus, ior, and, umin"))
26 (define_predicate "cris_commutative_orth_op"
27 (match_code "plus, ior, and, umin"))
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.
33 (define_predicate "cris_operand_extend_operator"
34 (match_code "plus, minus, umin"))
36 (define_predicate "cris_additive_operand_extend_operator"
37 (match_code "plus, minus"))
39 (define_predicate "cris_extend_operator"
40 (match_code "zero_extend, sign_extend"))
42 (define_predicate "cris_plus_or_bound_operator"
43 (match_code "plus, umin"))
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.
49 (define_predicate "cris_mem_op"
52 (define_predicate "cris_load_multiple_op"
53 (and (match_code "parallel")
54 (match_test "cris_movem_load_rest_p (op, 0)")))
56 (define_predicate "cris_store_multiple_op"
57 (and (match_code "parallel")
58 (match_test "cris_store_multiple_op_p (op)")))
61 ;; Operand helper predicates.
63 (define_predicate "cris_bdap_const_operand"
64 (and (match_code "label_ref, symbol_ref, const_int, const_double, const")
65 (ior (not (match_test "flag_pic"))
66 (match_test "cris_valid_pic_const (op, true)"))))
68 (define_predicate "cris_simple_address_operand"
69 (ior (match_operand:SI 0 "register_operand")
70 (and (match_code "post_inc")
71 (match_test "register_operand (XEXP (op, 0), Pmode)"))))
73 (define_predicate "cris_simple_operand"
74 (ior (match_operand 0 "register_operand")
75 (and (match_code "mem")
76 (match_test "cris_simple_address_operand (XEXP (op, 0),
79 (define_predicate "cris_nonsp_register_operand"
80 (and (match_operand 0 "register_operand")
81 (match_test "op != stack_pointer_rtx")))
83 ;; The caller needs to use :SI.
84 (define_predicate "cris_bdap_sign_extend_operand"
85 ; Disabled until <URL:http://gcc.gnu.org/ml/gcc-patches/2005-10/msg01376.html>
86 ; or <URL:http://gcc.gnu.org/ml/gcc-patches/2005-10/msg00940.html> is committed.
88 ; (and (match_code "sign_extend")
89 ; (and (match_test "MEM_P (XEXP (op, 0))")
90 ; (match_test "cris_simple_address_operand (XEXP (XEXP (op, 0), 0),
93 ;; FIXME: Should not have to test for 1.
94 (define_predicate "cris_scale_int_operand"
95 (and (match_code "const_int")
96 (ior (ior (match_test "op == GEN_INT (4)")
97 (match_test "op == const2_rtx"))
98 (match_test "op == const1_rtx"))))
100 ;; FIXME: Should be able to assume (reg int).
101 (define_predicate "cris_biap_mult_operand"
102 (and (match_code "mult")
103 (ior (and (match_test "register_operand (XEXP (op, 0), Pmode)")
104 (match_test "cris_scale_int_operand (XEXP (op, 1), Pmode)"))
105 (and (match_test "cris_scale_int_operand (XEXP (op, 0), Pmode)")
106 (match_test "register_operand (XEXP (op, 1), Pmode)")))))
109 ;; Operand predicates.
111 ;; This checks a part of an address, the one that is not a plain register
112 ;; for an addressing mode using BDAP.
113 ;; Allowed operands are either:
115 ;; b) a CONST operand (but not a symbol when generating PIC)
116 ;; c) a [r] or [r+] in SImode, or sign-extend from HI or QI.
118 (define_predicate "cris_bdap_operand"
119 (ior (match_operand 0 "cris_bdap_const_operand")
120 (ior (match_operand:SI 0 "cris_simple_operand")
121 (match_operand:SI 0 "cris_bdap_sign_extend_operand"))))
123 ;; This is similar to cris_bdap_operand:
124 ;; It checks a part of an address, the one that is not a plain register
125 ;; for an addressing mode using BDAP or BIAP.
126 ;; Allowed operands are either:
128 ;; b) a CONST operand (but not a symbol when generating PIC)
129 ;; c) a mult of (1, 2 or 4) and a register
130 ;; d) a [r] or [r+] in SImode, or sign-extend from HI or QI. */
132 (define_predicate "cris_bdap_biap_operand"
133 (ior (match_operand 0 "cris_bdap_operand")
134 (match_operand 0 "cris_biap_mult_operand")))
136 ;; Since with -fPIC, not all symbols are valid PIC symbols or indeed
137 ;; general_operands, we have to have a predicate that matches it for the
139 ;; FIXME: Can s/special_// when PR 20413 is fixed.
141 (define_special_predicate "cris_general_operand_or_symbol"
142 (ior (match_operand 0 "general_operand")
143 (and (match_code "const, symbol_ref, label_ref")
144 ; The following test is actually just an assertion.
145 (match_test "cris_pic_symbol_type_of (op) != cris_no_symbol"))))
147 ;; A predicate for the anon movsi expansion, one that fits a PCREL
148 ;; operand as well as general_operand.
150 (define_special_predicate "cris_general_operand_or_pic_source"
151 (ior (match_operand 0 "general_operand")
152 (and (match_test "flag_pic")
153 (match_test "cris_valid_pic_const (op, false)"))))
155 ;; Since a PLT symbol is not a general_operand, we have to have a
156 ;; predicate that matches it when we need it. We use this in the expanded
157 ;; "call" and "call_value" anonymous patterns.
159 (define_predicate "cris_nonmemory_operand_or_callable_symbol"
160 (ior (match_operand 0 "nonmemory_operand")
161 (and (match_code "const")
163 (match_test "GET_CODE (XEXP (op, 0)) == UNSPEC")
165 (match_test "XINT (XEXP (op, 0), 1) == CRIS_UNSPEC_PLT_PCREL")
166 (match_test "XINT (XEXP (op, 0), 1) == CRIS_UNSPEC_PCREL"))))))
168 ;; This matches a (MEM (general_operand)) or
169 ;; (MEM (cris_general_operand_or_symbol)). The second one isn't a valid
170 ;; memory_operand, so we need this predicate to recognize call
171 ;; destinations before we change them to a PLT operand (by wrapping in
172 ;; UNSPEC CRIS_UNSPEC_PLT).
174 (define_predicate "cris_mem_call_operand"
175 (and (match_code "mem")
176 (ior (match_operand 0 "memory_operand")
177 (match_test "cris_general_operand_or_symbol (XEXP (op, 0),