Debian Codegraph @

gcc/config/gcn/predicates.md

raw
1 ;; Predicate definitions for GCN.
2 ;; Copyright (C) 2016-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 ;; Return true if VALUE can be stored in a sign extended immediate field.
20
21 (define_predicate "gcn_conditional_register_operand"
22 (match_operand 0 "register_operand")
23 {
24 if (GET_CODE (op) == SUBREG)
25 op = SUBREG_REG (op);
26
27 if (!REG_P (op) || GET_MODE (op) != BImode)
28 return 0;
29
30 return REGNO (op) == VCCZ_REG
31 || REGNO (op) == VCC_REG /* Implied VCCZ. */
32 || REGNO (op) == SCC_REG
33 || REGNO (op) == EXECZ_REG
34 || REGNO (op) >= FIRST_PSEUDO_REGISTER;
35 })
36
37 (define_predicate "gcn_ssrc_register_operand"
38 (match_operand 0 "register_operand")
39 {
40 if (GET_CODE (op) == SUBREG)
41 op = SUBREG_REG (op);
42
43 if (!REG_P (op))
44 return false;
45
46 return SSRC_REGNO_P (REGNO (op)) || REGNO (op) >= FIRST_PSEUDO_REGISTER;
47 })
48
49 (define_predicate "gcn_sdst_register_operand"
50 (match_operand 0 "register_operand")
51 {
52 if (GET_CODE (op) == SUBREG)
53 op = SUBREG_REG (op);
54
55 if (!REG_P (op))
56 return false;
57
58 return SDST_REGNO_P (REGNO (op)) || REGNO (op) >= FIRST_PSEUDO_REGISTER;
59 })
60
61 (define_predicate "gcn_vgpr_register_operand"
62 (match_operand 0 "register_operand")
63 {
64 if (GET_CODE (op) == SUBREG)
65 op = SUBREG_REG (op);
66
67 if (!REG_P (op))
68 return false;
69
70 return VGPR_REGNO_P (REGNO (op)) || REGNO (op) >= FIRST_PSEUDO_REGISTER;
71 })
72
73 (define_predicate "gcn_avgpr_register_operand"
74 (match_operand 0 "register_operand")
75 {
76 if (GET_CODE (op) == SUBREG)
77 op = SUBREG_REG (op);
78
79 if (!REG_P (op))
80 return false;
81
82 return AVGPR_REGNO_P (REGNO (op)) || REGNO (op) >= FIRST_PSEUDO_REGISTER;
83 })
84
85 (define_predicate "gcn_avgpr_hard_register_operand"
86 (match_operand 0 "register_operand")
87 {
88 if (GET_CODE (op) == SUBREG)
89 op = SUBREG_REG (op);
90
91 if (!REG_P (op))
92 return false;
93
94 return AVGPR_REGNO_P (REGNO (op));
95 })
96
97 (define_predicate "gcn_inline_immediate_operand"
98 (match_code "const_int,const_double,const_vector")
99 {
100 return gcn_inline_constant_p (op);
101 })
102
103 (define_predicate "gcn_vop3_operand"
104 (ior (match_operand 0 "gcn_inline_immediate_operand")
105 (match_operand 0 "register_operand")))
106
107 (define_predicate "gcn_vec0_operand"
108 (match_code "const_vector")
109 {
110 return CONST_VECTOR_ELT (op, 0) == const0_rtx && gcn_inline_constant_p (op);
111 })
112
113 (define_predicate "gcn_vec1_operand"
114 (match_code "const_vector")
115 {
116 return CONST_VECTOR_ELT (op, 0) == const1_rtx && gcn_inline_constant_p (op);
117 })
118
119 (define_predicate "gcn_vec1d_operand"
120 (match_code "const_vector")
121 {
122 if (!gcn_inline_constant_p (op))
123 return false;
124
125 rtx elem = CONST_VECTOR_ELT (op, 0);
126 if (!CONST_DOUBLE_P (elem))
127 return false;
128 return real_identical (CONST_DOUBLE_REAL_VALUE (elem), &dconst1);
129 })
130
131 (define_predicate "gcn_const1d_operand"
132 (match_code "const_double")
133 {
134 return gcn_inline_constant_p (op)
135 && real_identical (CONST_DOUBLE_REAL_VALUE (op), &dconst1);
136 })
137
138 (define_predicate "gcn_32bit_immediate_operand"
139 (match_code "const_int,const_double,const_vector,symbol_ref,label_ref")
140 {
141 return gcn_constant_p (op);
142 })
143
144 ; LRA works smoother when exec values are immediate constants
145 ; prior register allocation.
146 (define_predicate "gcn_exec_operand"
147 (ior (match_operand 0 "register_operand")
148 (match_code "const_int")))
149
150 (define_predicate "gcn_exec_reg_operand"
151 (match_operand 0 "register_operand"))
152
153 (define_predicate "gcn_load_operand"
154 (ior (match_operand 0 "nonimmediate_operand")
155 (match_operand 0 "gcn_32bit_immediate_operand")))
156
157 (define_predicate "gcn_alu_operand"
158 (ior (match_operand 0 "register_operand")
159 (match_operand 0 "gcn_32bit_immediate_operand")))
160
161 (define_predicate "gcn_ds_memory_operand"
162 (and (match_code "mem")
163 (and (match_test "AS_ANY_DS_P (MEM_ADDR_SPACE (op))")
164 (match_operand 0 "memory_operand"))))
165
166 (define_predicate "gcn_valu_dst_operand"
167 (ior (match_operand 0 "register_operand")
168 (match_operand 0 "gcn_ds_memory_operand")))
169
170 (define_predicate "gcn_valu_src0_operand"
171 (ior (match_operand 0 "register_operand")
172 (ior (match_operand 0 "gcn_32bit_immediate_operand")
173 (match_operand 0 "gcn_ds_memory_operand"))))
174
175 (define_predicate "gcn_valu_src1_operand"
176 (match_operand 0 "register_operand"))
177
178 (define_predicate "gcn_valu_src1com_operand"
179 (ior (match_operand 0 "register_operand")
180 (match_operand 0 "gcn_32bit_immediate_operand")))
181
182 (define_predicate "gcn_conditional_operator"
183 (match_code "eq,ne"))
184
185 (define_predicate "gcn_compare_64bit_operator"
186 (match_code "eq,ne"))
187
188 (define_predicate "gcn_compare_operator"
189 (match_code "eq,ne,gt,ge,lt,le,gtu,geu,ltu,leu"))
190
191 (define_predicate "gcn_fp_compare_operator"
192 (match_code "eq,ne,gt,ge,lt,le,gtu,geu,ltu,leu,ordered,unordered,uneq,unge,ungt,unle,unlt,ltgt"))
193
194 (define_predicate "unary_operator"
195 (match_code "not,popcount"))
196
197 (define_predicate "binary_operator"
198 (match_code "and,ior,xor,ashift,lshiftrt,ashiftrt,smin,smax,umin,umax"))
199
200 (define_predicate "gcn_unspec_operand"
201 (and (match_code "unspec")
202 (match_test "XINT (op, 1) == UNSPEC_VECTOR")))
203
204 (define_predicate "general_or_unspec_operand"
205 (ior (match_operand 0 "general_operand")
206 (and (match_code "unspec")
207 (match_test "XINT (op, 1) == UNSPEC_VECTOR"))))
208
209 (define_predicate "gcn_register_or_unspec_operand"
210 (ior (match_operand 0 "register_operand")
211 (and (match_code "unspec")
212 (match_test "XINT (op, 1) == UNSPEC_VECTOR"))))
213
214 (define_predicate "gcn_alu_or_unspec_operand"
215 (ior (match_operand 0 "gcn_alu_operand")
216 (and (match_code "unspec")
217 (match_test "XINT (op, 1) == UNSPEC_VECTOR"))))
218
219 (define_predicate "gcn_register_ds_or_unspec_operand"
220 (ior (match_operand 0 "register_operand")
221 (ior (match_operand 0 "gcn_ds_memory_operand")
222 (and (match_code "unspec")
223 (match_test "XINT (op, 1) == UNSPEC_VECTOR")))))
224
225 (define_predicate "ascending_zero_int_parallel"
226 (match_code "parallel")
227 {
228 return gcn_stepped_zero_int_parallel_p (op, 1);
229 })
230
231 (define_predicate "maskload_else_operand"
232 (match_operand 0 "scratch_operand"))