annotate gcc/config/tilepro/predicates.md @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ;; Predicate definitions for Tilera TILEPro chip.
kono
parents:
diff changeset
2 ;; Copyright (C) 2011-2017 Free Software Foundation, Inc.
kono
parents:
diff changeset
3 ;; Contributed by Walter Lee (walt@tilera.com)
kono
parents:
diff changeset
4 ;;
kono
parents:
diff changeset
5 ;; This file is part of GCC.
kono
parents:
diff changeset
6 ;;
kono
parents:
diff changeset
7 ;; GCC is free software; you can redistribute it and/or modify it
kono
parents:
diff changeset
8 ;; under the terms of the GNU General Public License as published
kono
parents:
diff changeset
9 ;; by the Free Software Foundation; either version 3, or (at your
kono
parents:
diff changeset
10 ;; option) any later version.
kono
parents:
diff changeset
11 ;;
kono
parents:
diff changeset
12 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
kono
parents:
diff changeset
13 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
kono
parents:
diff changeset
14 ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
kono
parents:
diff changeset
15 ;; License for more details.
kono
parents:
diff changeset
16 ;;
kono
parents:
diff changeset
17 ;; You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
18 ;; along with GCC; see the file COPYING3. If not see
kono
parents:
diff changeset
19 ;; <http://www.gnu.org/licenses/>.
kono
parents:
diff changeset
20
kono
parents:
diff changeset
21 ;; Return true if OP is the zero constant for MODE.
kono
parents:
diff changeset
22 (define_predicate "const_zero_operand"
kono
parents:
diff changeset
23 (and (match_code "const_int,const_double,const_vector")
kono
parents:
diff changeset
24 (match_test "op == CONST0_RTX (mode)")))
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 ;; Returns true if OP is either the constant zero or a register.
kono
parents:
diff changeset
27 (define_predicate "reg_or_0_operand"
kono
parents:
diff changeset
28 (and (ior (match_operand 0 "register_operand")
kono
parents:
diff changeset
29 (match_operand 0 "const_zero_operand"))
kono
parents:
diff changeset
30 (match_test "GET_MODE_SIZE (mode) <= UNITS_PER_WORD")))
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 ; Return 1 if OP is a network register identifier.
kono
parents:
diff changeset
33 (define_predicate "netreg_operand"
kono
parents:
diff changeset
34 (and (match_code "const_int")
kono
parents:
diff changeset
35 (match_test "IN_RANGE (INTVAL (op), 0, 6)")))
kono
parents:
diff changeset
36
kono
parents:
diff changeset
37 ; Return 1 if OP is an unsigned 5-bit constant.
kono
parents:
diff changeset
38 (define_predicate "u5bit_cint_operand"
kono
parents:
diff changeset
39 (and (match_code "const_int")
kono
parents:
diff changeset
40 (match_test "INTVAL (op) == (INTVAL (op) & 0x1F)")))
kono
parents:
diff changeset
41
kono
parents:
diff changeset
42 ;; Return 1 if OP is an unsigned 16-bit constant.
kono
parents:
diff changeset
43 (define_predicate "u16bit_cint_operand"
kono
parents:
diff changeset
44 (and (match_code "const_int")
kono
parents:
diff changeset
45 (match_test "(unsigned HOST_WIDE_INT)INTVAL (op) < (1U << 16)")))
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 ;; Return 1 if OP is a signed 8-bit constant.
kono
parents:
diff changeset
48 (define_predicate "s8bit_cint_operand"
kono
parents:
diff changeset
49 (and (match_code "const_int")
kono
parents:
diff changeset
50 (match_test "satisfies_constraint_I (op)")))
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 ;; Return 1 if OP is a signed 16-bit constant.
kono
parents:
diff changeset
53 (define_predicate "s16bit_cint_operand"
kono
parents:
diff changeset
54 (and (match_code "const_int")
kono
parents:
diff changeset
55 (match_test "satisfies_constraint_J (op)")))
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 ;; Return 1 if OP is a nonzero integer constant whose low 16 bits are zero.
kono
parents:
diff changeset
58 (define_predicate "auli_cint_operand"
kono
parents:
diff changeset
59 (and (match_code "const_int")
kono
parents:
diff changeset
60 (match_test "satisfies_constraint_K (op)")))
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 ;; Return 1 if OP is an unsigned 15-bit constant.
kono
parents:
diff changeset
63 (define_predicate "u15bit_cint_operand"
kono
parents:
diff changeset
64 (and (match_code "const_int")
kono
parents:
diff changeset
65 (match_test "(unsigned HOST_WIDE_INT)INTVAL (op) < (1U << 15)")))
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 ;; Return 1 if OP is a constant or any register.
kono
parents:
diff changeset
68 (define_predicate "reg_or_cint_operand"
kono
parents:
diff changeset
69 (ior (match_operand 0 "register_operand")
kono
parents:
diff changeset
70 (match_operand 0 "const_int_operand")))
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 ;; Return 1 if OP is a 4-element vector constant with identical signed
kono
parents:
diff changeset
73 ;; 8-bit elements or any register.
kono
parents:
diff changeset
74 (define_predicate "reg_or_v4s8bit_operand"
kono
parents:
diff changeset
75 (ior (match_operand 0 "register_operand")
kono
parents:
diff changeset
76 (and (match_code "const_vector")
kono
parents:
diff changeset
77 (match_test "CONST_VECTOR_NUNITS (op) == 4
kono
parents:
diff changeset
78 && (satisfies_constraint_I
kono
parents:
diff changeset
79 (unwrap_const_vec_duplicate (op)))"))))
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 ;; Return 1 if OP is a 2-element vector constant with identical signed
kono
parents:
diff changeset
82 ;; 8-bit elements or any register.
kono
parents:
diff changeset
83 (define_predicate "reg_or_v2s8bit_operand"
kono
parents:
diff changeset
84 (ior (match_operand 0 "register_operand")
kono
parents:
diff changeset
85 (and (match_code "const_vector")
kono
parents:
diff changeset
86 (match_test "CONST_VECTOR_NUNITS (op) == 2
kono
parents:
diff changeset
87 && (satisfies_constraint_I
kono
parents:
diff changeset
88 (unwrap_const_vec_duplicate (op)))"))))
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 ;; Return 1 if the operand is a valid second operand to an add insn.
kono
parents:
diff changeset
91 (define_predicate "add_operand"
kono
parents:
diff changeset
92 (if_then_else (match_code "const_int")
kono
parents:
diff changeset
93 (match_test "satisfies_constraint_J (op) || satisfies_constraint_K (op)")
kono
parents:
diff changeset
94 (match_operand 0 "register_operand")))
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 ;; Return 1 if the operand is a register or signed 8-bit immediate operand.
kono
parents:
diff changeset
97 (define_predicate "reg_or_s8bit_operand"
kono
parents:
diff changeset
98 (if_then_else (match_code "const_int")
kono
parents:
diff changeset
99 (match_test "satisfies_constraint_I (op)")
kono
parents:
diff changeset
100 (match_operand 0 "register_operand")))
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 ;; Return 1 for an operand suitable for ANDing with a register.
kono
parents:
diff changeset
103 (define_predicate "and_operand"
kono
parents:
diff changeset
104 (if_then_else (match_code "const_int")
kono
parents:
diff changeset
105 (match_test "satisfies_constraint_I (op) || satisfies_constraint_M (op)")
kono
parents:
diff changeset
106 (match_operand 0 "register_operand")))
kono
parents:
diff changeset
107
kono
parents:
diff changeset
108 ;; Return 1 if the operand is a register or unsigned 5-bit immediate operand.
kono
parents:
diff changeset
109 (define_predicate "reg_or_u5bit_operand"
kono
parents:
diff changeset
110 (if_then_else (match_code "const_int")
kono
parents:
diff changeset
111 (match_test "INTVAL (op) == (INTVAL (op) & 0x1F)")
kono
parents:
diff changeset
112 (match_operand 0 "register_operand")))
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 ; Return 1 if the operand is 2, 4 or 8.
kono
parents:
diff changeset
115 (define_predicate "cint_248_operand"
kono
parents:
diff changeset
116 (and (match_code "const_int")
kono
parents:
diff changeset
117 (match_test
kono
parents:
diff changeset
118 "INTVAL (op) == 2 || INTVAL (op) == 4 || INTVAL (op) == 8")))
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120
kono
parents:
diff changeset
121 ;; Return true if OP is a TLS symbolic operand.
kono
parents:
diff changeset
122 (define_predicate "tls_symbolic_operand"
kono
parents:
diff changeset
123 (and (match_code "symbol_ref")
kono
parents:
diff changeset
124 (match_test "SYMBOL_REF_TLS_MODEL (op) != TLS_MODEL_NONE")))
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 ;; Return true if OP is a symbolic operand for the TLS Global Dynamic model.
kono
parents:
diff changeset
127 (define_predicate "tls_gd_symbolic_operand"
kono
parents:
diff changeset
128 (and (match_code "symbol_ref")
kono
parents:
diff changeset
129 (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_GLOBAL_DYNAMIC")))
kono
parents:
diff changeset
130
kono
parents:
diff changeset
131 ;; Return true if OP is a symbolic operand for the TLS Local Dynamic model.
kono
parents:
diff changeset
132 (define_predicate "tls_ld_symbolic_operand"
kono
parents:
diff changeset
133 (and (match_code "symbol_ref")
kono
parents:
diff changeset
134 (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_LOCAL_DYNAMIC")))
kono
parents:
diff changeset
135
kono
parents:
diff changeset
136 ;; Return true if OP is a symbolic operand that can be used for the
kono
parents:
diff changeset
137 ;; TLS Initial Exec model.
kono
parents:
diff changeset
138 (define_predicate "tls_ie_symbolic_operand"
kono
parents:
diff changeset
139 (and (match_code "symbol_ref")
kono
parents:
diff changeset
140 (ior (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_INITIAL_EXEC")
kono
parents:
diff changeset
141 (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_LOCAL_EXEC"))))
kono
parents:
diff changeset
142
kono
parents:
diff changeset
143 ;; Return true if OP is a symbolic operand for the TLS Local Exec model.
kono
parents:
diff changeset
144 (define_predicate "tls_le_symbolic_operand"
kono
parents:
diff changeset
145 (and (match_code "symbol_ref")
kono
parents:
diff changeset
146 (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_LOCAL_EXEC")))
kono
parents:
diff changeset
147
kono
parents:
diff changeset
148 ;; Returns true if OP is any general operand except for an
kono
parents:
diff changeset
149 ;; auto-incrementing address operand.
kono
parents:
diff changeset
150 (define_predicate "nonautoinc_operand"
kono
parents:
diff changeset
151 (and (match_operand 0 "general_operand")
kono
parents:
diff changeset
152 (not (ior (match_code "pre_dec") (match_code "pre_inc")
kono
parents:
diff changeset
153 (match_code "post_dec") (match_code "post_inc")
kono
parents:
diff changeset
154 (match_code "post_modify") (match_code "pre_modify")))))
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156 ;; Returns true if OP is a non-auto-incrementing memory operand.
kono
parents:
diff changeset
157 (define_predicate "nonautoincmem_operand"
kono
parents:
diff changeset
158 (match_operand 0 "memory_operand")
kono
parents:
diff changeset
159 {
kono
parents:
diff changeset
160 return nonautoinc_operand (XEXP (op, 0), GET_MODE (XEXP (op, 0)));
kono
parents:
diff changeset
161 })
kono
parents:
diff changeset
162
kono
parents:
diff changeset
163 ;; Returns true if OP is a non-auto-incrementing memory, general
kono
parents:
diff changeset
164 ;; operand.
kono
parents:
diff changeset
165 (define_predicate "nonautoincmem_general_operand"
kono
parents:
diff changeset
166 (match_operand 0 "general_operand")
kono
parents:
diff changeset
167 {
kono
parents:
diff changeset
168 if (memory_operand (op, mode))
kono
parents:
diff changeset
169 return nonautoinc_operand (XEXP (op, 0), GET_MODE (XEXP (op, 0)));
kono
parents:
diff changeset
170 else
kono
parents:
diff changeset
171 return true;
kono
parents:
diff changeset
172 })
kono
parents:
diff changeset
173
kono
parents:
diff changeset
174 ;; Returns true if OP is a non-auto-incrementing memory, non-immediate
kono
parents:
diff changeset
175 ;; operand.
kono
parents:
diff changeset
176 (define_predicate "nonautoincmem_nonimmediate_operand"
kono
parents:
diff changeset
177 (match_operand 0 "nonimmediate_operand")
kono
parents:
diff changeset
178 {
kono
parents:
diff changeset
179 if (memory_operand (op, mode))
kono
parents:
diff changeset
180 return nonautoinc_operand (XEXP (op, 0), GET_MODE (XEXP (op, 0)));
kono
parents:
diff changeset
181 else
kono
parents:
diff changeset
182 return true;
kono
parents:
diff changeset
183 })
kono
parents:
diff changeset
184
kono
parents:
diff changeset
185 ;; Return true if OP is a valid operand for the source of a move insn.
kono
parents:
diff changeset
186 (define_predicate "move_operand"
kono
parents:
diff changeset
187 (match_operand 0 "general_operand")
kono
parents:
diff changeset
188 {
kono
parents:
diff changeset
189 /* If both modes are non-void they must be the same. */
kono
parents:
diff changeset
190 if (mode != VOIDmode && GET_MODE (op) != VOIDmode && mode != GET_MODE (op))
kono
parents:
diff changeset
191 return false;
kono
parents:
diff changeset
192
kono
parents:
diff changeset
193 if (GET_MODE_SIZE (mode) > 4)
kono
parents:
diff changeset
194 return false;
kono
parents:
diff changeset
195
kono
parents:
diff changeset
196 switch (GET_CODE (op))
kono
parents:
diff changeset
197 {
kono
parents:
diff changeset
198 case CONST_INT:
kono
parents:
diff changeset
199 return (satisfies_constraint_J (op)
kono
parents:
diff changeset
200 || satisfies_constraint_K (op)
kono
parents:
diff changeset
201 || satisfies_constraint_N (op)
kono
parents:
diff changeset
202 || satisfies_constraint_P (op));
kono
parents:
diff changeset
203
kono
parents:
diff changeset
204 case HIGH:
kono
parents:
diff changeset
205 return true;
kono
parents:
diff changeset
206
kono
parents:
diff changeset
207 case MEM:
kono
parents:
diff changeset
208 return memory_address_p (mode, XEXP (op, 0));
kono
parents:
diff changeset
209
kono
parents:
diff changeset
210 default:
kono
parents:
diff changeset
211 return register_operand (op, mode);
kono
parents:
diff changeset
212 }
kono
parents:
diff changeset
213 })
kono
parents:
diff changeset
214
kono
parents:
diff changeset
215 ;; Returns 1 if OP is a symbolic operand, i.e. a symbol_ref or a label_ref,
kono
parents:
diff changeset
216 ;; possibly with an offset.
kono
parents:
diff changeset
217 (define_predicate "symbolic_operand"
kono
parents:
diff changeset
218 (ior (match_code "symbol_ref,label_ref")
kono
parents:
diff changeset
219 (and (match_code "const")
kono
parents:
diff changeset
220 (match_test "GET_CODE (XEXP (op,0)) == PLUS
kono
parents:
diff changeset
221 && (GET_CODE (XEXP (XEXP (op,0), 0)) == SYMBOL_REF
kono
parents:
diff changeset
222 || GET_CODE (XEXP (XEXP (op,0), 0)) == LABEL_REF)
kono
parents:
diff changeset
223 && CONST_INT_P (XEXP (XEXP (op,0), 1))"))))
kono
parents:
diff changeset
224
kono
parents:
diff changeset
225 ;; Returns 1 if OP is a symbolic operand, or a const unspec wrapper
kono
parents:
diff changeset
226 ;; representing a got reference, a tls reference, or pc-relative
kono
parents:
diff changeset
227 ;; reference.
kono
parents:
diff changeset
228 (define_predicate "const_symbolic_operand"
kono
parents:
diff changeset
229 (ior (match_operand 0 "symbolic_operand")
kono
parents:
diff changeset
230 (and (match_code "const")
kono
parents:
diff changeset
231 (match_test "GET_CODE (XEXP (op,0)) == UNSPEC")
kono
parents:
diff changeset
232 (ior (match_test "XINT (XEXP (op,0), 1) == UNSPEC_GOT16_SYM")
kono
parents:
diff changeset
233 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_GOT32_SYM")
kono
parents:
diff changeset
234 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_PCREL_SYM")
kono
parents:
diff changeset
235 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_TLS_GD")
kono
parents:
diff changeset
236 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_TLS_IE")
kono
parents:
diff changeset
237 (match_test "XINT (XEXP (op,0), 1) == UNSPEC_TLS_LE")))))
kono
parents:
diff changeset
238
kono
parents:
diff changeset
239 ;; Return true if OP is an address suitable for a call insn.
kono
parents:
diff changeset
240 ;; Call insn on TILE can take a PC-relative constant address
kono
parents:
diff changeset
241 ;; or any regular memory address.
kono
parents:
diff changeset
242 (define_predicate "call_address_operand"
kono
parents:
diff changeset
243 (ior (match_operand 0 "symbolic_operand")
kono
parents:
diff changeset
244 (match_test "memory_address_p (Pmode, op)")))
kono
parents:
diff changeset
245
kono
parents:
diff changeset
246 ;; Return true if OP is an operand suitable for a call insn.
kono
parents:
diff changeset
247 (define_predicate "call_operand"
kono
parents:
diff changeset
248 (and (match_code "mem")
kono
parents:
diff changeset
249 (match_test "call_address_operand (XEXP (op, 0), mode)")))
kono
parents:
diff changeset
250
kono
parents:
diff changeset
251 ;; Return 1 if OP is a signed comparison operation.
kono
parents:
diff changeset
252 ;; We can use these directly in compares against zero.
kono
parents:
diff changeset
253 (define_predicate "signed_comparison_operator"
kono
parents:
diff changeset
254 (match_code "eq,ne,le,lt,ge,gt"))
kono
parents:
diff changeset
255
kono
parents:
diff changeset
256 ;; Return 1 if OP is a equal or not-equal operation.
kono
parents:
diff changeset
257 (define_predicate "eqne_operator"
kono
parents:
diff changeset
258 (match_code "eq,ne"))