annotate gcc/config/c6x/predicates.md @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Predicates for TI C6X
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2 Copyright (C) 2010-2018 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
3 Contributed by Andrew Jenner <andrew@codesourcery.com>
kono
parents:
diff changeset
4 Contributed by Bernd Schmidt <bernds@codesourcery.com>
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 This file is part of GCC.
kono
parents:
diff changeset
7
kono
parents:
diff changeset
8 GCC is free software; you can redistribute it and/or modify it
kono
parents:
diff changeset
9 under the terms of the GNU General Public License as published
kono
parents:
diff changeset
10 by the Free Software Foundation; either version 3, or (at your
kono
parents:
diff changeset
11 option) any later version.
kono
parents:
diff changeset
12
kono
parents:
diff changeset
13 GCC is distributed in the hope that it will be useful, but WITHOUT
kono
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
kono
parents:
diff changeset
15 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
kono
parents:
diff changeset
16 License for more details.
kono
parents:
diff changeset
17
kono
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
19 along with GCC; see the file COPYING3. If not see
kono
parents:
diff changeset
20 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
21
kono
parents:
diff changeset
22 (define_predicate "reg_or_const_int_operand"
kono
parents:
diff changeset
23 (ior (match_operand 0 "register_operand")
kono
parents:
diff changeset
24 (match_operand 0 "const_int_operand")))
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 (define_predicate "const_vector_operand"
kono
parents:
diff changeset
27 (match_code "const_vector"))
kono
parents:
diff changeset
28
kono
parents:
diff changeset
29 (define_predicate "scst5_operand"
kono
parents:
diff changeset
30 (and (match_operand 0 "const_int_operand")
kono
parents:
diff changeset
31 (match_test "satisfies_constraint_Is5 (op)")))
kono
parents:
diff changeset
32
kono
parents:
diff changeset
33 (define_predicate "reg_or_ucst4_operand"
kono
parents:
diff changeset
34 (ior (match_operand 0 "register_operand")
kono
parents:
diff changeset
35 (and (match_operand 0 "const_int_operand")
kono
parents:
diff changeset
36 (match_test "satisfies_constraint_Iu4 (op)"))))
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 (define_predicate "reg_or_scst5_operand"
kono
parents:
diff changeset
39 (ior (match_operand 0 "register_operand")
kono
parents:
diff changeset
40 (match_operand 0 "scst5_operand")))
kono
parents:
diff changeset
41
kono
parents:
diff changeset
42 (define_predicate "reg_or_ucst5_operand"
kono
parents:
diff changeset
43 (ior (match_operand 0 "register_operand")
kono
parents:
diff changeset
44 (and (match_operand 0 "const_int_operand")
kono
parents:
diff changeset
45 (match_test "satisfies_constraint_Iu5 (op)"))))
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 (define_predicate "addsi_operand"
kono
parents:
diff changeset
48 (ior (match_operand 0 "register_operand")
kono
parents:
diff changeset
49 (and (match_operand 0 "const_int_operand")
kono
parents:
diff changeset
50 (match_test "satisfies_constraint_IsB (op)"))))
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 (define_predicate "andsi_operand"
kono
parents:
diff changeset
53 (ior (match_operand 0 "reg_or_scst5_operand")
kono
parents:
diff changeset
54 (and (match_operand 0 "const_int_operand")
kono
parents:
diff changeset
55 (match_test "satisfies_constraint_Jc (op)"))))
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 (define_predicate "iorsi_operand"
kono
parents:
diff changeset
58 (ior (match_operand 0 "reg_or_scst5_operand")
kono
parents:
diff changeset
59 (and (match_operand 0 "const_int_operand")
kono
parents:
diff changeset
60 (match_test "satisfies_constraint_Js (op)"))))
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 (define_predicate "insv_operand"
kono
parents:
diff changeset
63 (and (match_operand 0 "const_int_operand")
kono
parents:
diff changeset
64 (match_test "INTVAL (op) == 0 || INTVAL (op) == -1")))
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 (define_predicate "c6x_jump_operand"
kono
parents:
diff changeset
67 (match_code "label_ref,symbol_ref,reg"))
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 (define_predicate "c6x_call_operand"
kono
parents:
diff changeset
70 (ior (match_code "symbol_ref,reg")
kono
parents:
diff changeset
71 (and (match_code "subreg")
kono
parents:
diff changeset
72 (match_test "GET_CODE (XEXP (op, 0)) == REG")))
kono
parents:
diff changeset
73 {
kono
parents:
diff changeset
74 /* The linker transforms jumps to undefined weak symbols in a way that
kono
parents:
diff changeset
75 is incompatible with our code generation. */
kono
parents:
diff changeset
76 return (GET_CODE (op) != SYMBOL_REF
kono
parents:
diff changeset
77 || (!SYMBOL_REF_WEAK (op)
kono
parents:
diff changeset
78 && !c6x_long_call_p (op)));
kono
parents:
diff changeset
79 })
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 ;; Returns 1 if OP is a symbolic operand, i.e. a symbol_ref or a label_ref,
kono
parents:
diff changeset
82 ;; possibly with an offset.
kono
parents:
diff changeset
83 (define_predicate "symbolic_operand"
kono
parents:
diff changeset
84 (ior (match_code "symbol_ref,label_ref")
kono
parents:
diff changeset
85 (and (match_code "const")
kono
parents:
diff changeset
86 (match_test "GET_CODE (XEXP (op,0)) == PLUS
kono
parents:
diff changeset
87 && (GET_CODE (XEXP (XEXP (op, 0), 0)) == SYMBOL_REF
kono
parents:
diff changeset
88 || GET_CODE (XEXP (XEXP (op, 0), 0)) == LABEL_REF)
kono
parents:
diff changeset
89 && GET_CODE (XEXP (XEXP (op, 0), 1)) == CONST_INT"))))
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 (define_predicate "const_int_or_symbolic_operand"
kono
parents:
diff changeset
92 (ior (match_operand 0 "symbolic_operand")
kono
parents:
diff changeset
93 (match_operand 0 "const_int_operand")))
kono
parents:
diff changeset
94
kono
parents:
diff changeset
95 ;; Return nonzero iff OP is one of the integer constants 2, 4 or 8.
kono
parents:
diff changeset
96 (define_predicate "adda_scale_operand"
kono
parents:
diff changeset
97 (and (match_code "const_int")
kono
parents:
diff changeset
98 (match_test "INTVAL (op) == 2 || INTVAL (op) == 4
kono
parents:
diff changeset
99 || ((TARGET_INSNS_64 || TARGET_INSNS_67)
kono
parents:
diff changeset
100 && INTVAL (op) == 8)")))
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 ;; Return nonzero iff OP is one of the integer constants 2 or 4.
kono
parents:
diff changeset
103 (define_predicate "suba_scale_operand"
kono
parents:
diff changeset
104 (and (match_code "const_int")
kono
parents:
diff changeset
105 (match_test "INTVAL (op) == 2 || INTVAL (op) == 4")))
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 ;; True if this operator is valid for predication.
kono
parents:
diff changeset
108 (define_predicate "predicate_operator"
kono
parents:
diff changeset
109 (match_code "eq,ne"))
kono
parents:
diff changeset
110
kono
parents:
diff changeset
111 (define_predicate "c6x_comparison_operator"
kono
parents:
diff changeset
112 (match_code "eq,ltu,gtu,lt,gt"))
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 (define_predicate "non_c6x_comparison_operator"
kono
parents:
diff changeset
115 (match_code "ne,leu,geu,le,ge"))
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117 ;; FP Comparisons handled by c6x_expand_compare.
kono
parents:
diff changeset
118 (define_predicate "c6x_fp_comparison_operator"
kono
parents:
diff changeset
119 (ior (match_code "eq,lt,gt,le,ge")
kono
parents:
diff changeset
120 (and (match_test "TARGET_FP")
kono
parents:
diff changeset
121 (match_code "ltgt,uneq,unlt,ungt,unle,unge,ordered,unordered"))))
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 (define_predicate "c6x_any_comparison_operand"
kono
parents:
diff changeset
124 (match_code "eq,lt,gt,le,ge,ltu,gtu")
kono
parents:
diff changeset
125 {
kono
parents:
diff changeset
126 rtx op0 = XEXP (op, 0);
kono
parents:
diff changeset
127 rtx op1 = XEXP (op, 1);
kono
parents:
diff changeset
128 if (ltugtu_operator (op, SImode)
kono
parents:
diff changeset
129 && register_operand (op0, SImode)
kono
parents:
diff changeset
130 && ((TARGET_INSNS_64 && reg_or_ucst5_operand (op1, SImode))
kono
parents:
diff changeset
131 || (!TARGET_INSNS_64 && reg_or_ucst4_operand (op1, SImode))))
kono
parents:
diff changeset
132 return true;
kono
parents:
diff changeset
133 if (eqltgt_operator (op, SImode)
kono
parents:
diff changeset
134 && register_operand (op0, SImode)
kono
parents:
diff changeset
135 && reg_or_scst5_operand (op1, SImode))
kono
parents:
diff changeset
136 return true;
kono
parents:
diff changeset
137 if (!TARGET_FP)
kono
parents:
diff changeset
138 return false;
kono
parents:
diff changeset
139 if (!eqltgt_operator (op, SFmode) && !eqltgt_operator (op, DFmode))
kono
parents:
diff changeset
140 return false;
kono
parents:
diff changeset
141 if (register_operand (op0, GET_MODE (op))
kono
parents:
diff changeset
142 && register_operand (op1, GET_MODE (op)))
kono
parents:
diff changeset
143 return true;
kono
parents:
diff changeset
144 return false;
kono
parents:
diff changeset
145 })
kono
parents:
diff changeset
146
kono
parents:
diff changeset
147 (define_predicate "ltugtu_operator"
kono
parents:
diff changeset
148 (match_code "ltu,gtu"))
kono
parents:
diff changeset
149
kono
parents:
diff changeset
150 (define_predicate "eqltgt_operator"
kono
parents:
diff changeset
151 (match_code "eq,lt,gt"))
kono
parents:
diff changeset
152
kono
parents:
diff changeset
153 (define_predicate "eqne_operator"
kono
parents:
diff changeset
154 (match_code "eq,ne"))
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156 (define_predicate "predicate_register"
kono
parents:
diff changeset
157 (and (match_code "reg")
kono
parents:
diff changeset
158 (ior (match_test "REGNO_REG_CLASS (REGNO (op)) == PREDICATE_A_REGS")
kono
parents:
diff changeset
159 (match_test "REGNO_REG_CLASS (REGNO (op)) == PREDICATE_B_REGS"))))
kono
parents:
diff changeset
160
kono
parents:
diff changeset
161 ;; Allow const_ints for things like the real_mult patterns.
kono
parents:
diff changeset
162 (define_predicate "a_register"
kono
parents:
diff changeset
163 (ior (and (match_code "reg")
kono
parents:
diff changeset
164 (match_test "A_REGNO_P (REGNO (op))"))
kono
parents:
diff changeset
165 (and (match_code "const_int")
kono
parents:
diff changeset
166 (match_test "A_REGNO_P (INTVAL (op))"))))
kono
parents:
diff changeset
167
kono
parents:
diff changeset
168 (define_predicate "b_register"
kono
parents:
diff changeset
169 (ior (and (match_code "reg")
kono
parents:
diff changeset
170 (match_test "B_REGNO_P (REGNO (op))"))
kono
parents:
diff changeset
171 (and (match_code "const_int")
kono
parents:
diff changeset
172 (match_test "B_REGNO_P (INTVAL (op))"))))
kono
parents:
diff changeset
173
kono
parents:
diff changeset
174 (define_predicate "pic_register_operand"
kono
parents:
diff changeset
175 (and (match_code "reg")
kono
parents:
diff changeset
176 (match_test "op == pic_offset_table_rtx")))
kono
parents:
diff changeset
177
kono
parents:
diff changeset
178 ;; True if OP refers to a symbol in the sdata section.
kono
parents:
diff changeset
179 (define_predicate "sdata_symbolic_operand"
kono
parents:
diff changeset
180 (match_code "symbol_ref,const")
kono
parents:
diff changeset
181 {
kono
parents:
diff changeset
182 HOST_WIDE_INT offset = 0, size = 0;
kono
parents:
diff changeset
183 tree t;
kono
parents:
diff changeset
184
kono
parents:
diff changeset
185 switch (GET_CODE (op))
kono
parents:
diff changeset
186 {
kono
parents:
diff changeset
187 case CONST:
kono
parents:
diff changeset
188 op = XEXP (op, 0);
kono
parents:
diff changeset
189 if (GET_CODE (op) != PLUS
kono
parents:
diff changeset
190 || GET_CODE (XEXP (op, 0)) != SYMBOL_REF
kono
parents:
diff changeset
191 || GET_CODE (XEXP (op, 1)) != CONST_INT)
kono
parents:
diff changeset
192 return false;
kono
parents:
diff changeset
193 offset = INTVAL (XEXP (op, 1));
kono
parents:
diff changeset
194 op = XEXP (op, 0);
kono
parents:
diff changeset
195 /* FALLTHRU */
kono
parents:
diff changeset
196
kono
parents:
diff changeset
197 case SYMBOL_REF:
kono
parents:
diff changeset
198 /* For shared libraries, only allow symbols we know are local.
kono
parents:
diff changeset
199 For executables, the linker knows to create copy relocs if
kono
parents:
diff changeset
200 necessary so we can use DP-relative addressing for all small
kono
parents:
diff changeset
201 objects. */
kono
parents:
diff changeset
202 if ((c6x_initial_flag_pic && !SYMBOL_REF_LOCAL_P (op))
kono
parents:
diff changeset
203 || !SYMBOL_REF_SMALL_P (op))
kono
parents:
diff changeset
204 return false;
kono
parents:
diff changeset
205
kono
parents:
diff changeset
206 /* Note that in addition to DECLs, we can get various forms
kono
parents:
diff changeset
207 of constants here. */
kono
parents:
diff changeset
208 t = SYMBOL_REF_DECL (op);
kono
parents:
diff changeset
209 if (DECL_P (t))
kono
parents:
diff changeset
210 t = DECL_SIZE_UNIT (t);
kono
parents:
diff changeset
211 else
kono
parents:
diff changeset
212 t = TYPE_SIZE_UNIT (TREE_TYPE (t));
kono
parents:
diff changeset
213 if (t && tree_fits_shwi_p (t))
kono
parents:
diff changeset
214 {
kono
parents:
diff changeset
215 size = tree_to_shwi (t);
kono
parents:
diff changeset
216 if (size < 0)
kono
parents:
diff changeset
217 size = 0;
kono
parents:
diff changeset
218 }
kono
parents:
diff changeset
219
kono
parents:
diff changeset
220 /* Don't allow addressing outside the object. */
kono
parents:
diff changeset
221 return (offset >= 0 && offset <= size);
kono
parents:
diff changeset
222
kono
parents:
diff changeset
223 default:
kono
parents:
diff changeset
224 gcc_unreachable ();
kono
parents:
diff changeset
225 }
kono
parents:
diff changeset
226 })