1 ;; Predicate definitions for GCN.
2 ;; Copyright (C) 2016-2024 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/>.
19 ;; Return true if VALUE can be stored in a sign extended immediate field.
21 (define_predicate "gcn_conditional_register_operand"
22 (match_operand 0 "register_operand")
24 if (GET_CODE (op) == SUBREG)
27 if (!REG_P (op) || GET_MODE (op) != BImode)
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;
37 (define_predicate "gcn_ssrc_register_operand"
38 (match_operand 0 "register_operand")
40 if (GET_CODE (op) == SUBREG)
46 return SSRC_REGNO_P (REGNO (op)) || REGNO (op) >= FIRST_PSEUDO_REGISTER;
49 (define_predicate "gcn_sdst_register_operand"
50 (match_operand 0 "register_operand")
52 if (GET_CODE (op) == SUBREG)
58 return SDST_REGNO_P (REGNO (op)) || REGNO (op) >= FIRST_PSEUDO_REGISTER;
61 (define_predicate "gcn_vgpr_register_operand"
62 (match_operand 0 "register_operand")
64 if (GET_CODE (op) == SUBREG)
70 return VGPR_REGNO_P (REGNO (op)) || REGNO (op) >= FIRST_PSEUDO_REGISTER;
73 (define_predicate "gcn_avgpr_register_operand"
74 (match_operand 0 "register_operand")
76 if (GET_CODE (op) == SUBREG)
82 return AVGPR_REGNO_P (REGNO (op)) || REGNO (op) >= FIRST_PSEUDO_REGISTER;
85 (define_predicate "gcn_avgpr_hard_register_operand"
86 (match_operand 0 "register_operand")
88 if (GET_CODE (op) == SUBREG)
94 return AVGPR_REGNO_P (REGNO (op));
97 (define_predicate "gcn_inline_immediate_operand"
98 (match_code "const_int,const_double,const_vector")
100 return gcn_inline_constant_p (op);
103 (define_predicate "gcn_vop3_operand"
104 (ior (match_operand 0 "gcn_inline_immediate_operand")
105 (match_operand 0 "register_operand")))
107 (define_predicate "gcn_vec0_operand"
108 (match_code "const_vector")
110 return CONST_VECTOR_ELT (op, 0) == const0_rtx && gcn_inline_constant_p (op);
113 (define_predicate "gcn_vec1_operand"
114 (match_code "const_vector")
116 return CONST_VECTOR_ELT (op, 0) == const1_rtx && gcn_inline_constant_p (op);
119 (define_predicate "gcn_vec1d_operand"
120 (match_code "const_vector")
122 if (!gcn_inline_constant_p (op))
125 rtx elem = CONST_VECTOR_ELT (op, 0);
126 if (!CONST_DOUBLE_P (elem))
128 return real_identical (CONST_DOUBLE_REAL_VALUE (elem), &dconst1);
131 (define_predicate "gcn_const1d_operand"
132 (match_code "const_double")
134 return gcn_inline_constant_p (op)
135 && real_identical (CONST_DOUBLE_REAL_VALUE (op), &dconst1);
138 (define_predicate "gcn_32bit_immediate_operand"
139 (match_code "const_int,const_double,const_vector,symbol_ref,label_ref")
141 return gcn_constant_p (op);
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")))
150 (define_predicate "gcn_exec_reg_operand"
151 (match_operand 0 "register_operand"))
153 (define_predicate "gcn_load_operand"
154 (ior (match_operand 0 "nonimmediate_operand")
155 (match_operand 0 "gcn_32bit_immediate_operand")))
157 (define_predicate "gcn_alu_operand"
158 (ior (match_operand 0 "register_operand")
159 (match_operand 0 "gcn_32bit_immediate_operand")))
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"))))
166 (define_predicate "gcn_valu_dst_operand"
167 (ior (match_operand 0 "register_operand")
168 (match_operand 0 "gcn_ds_memory_operand")))
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"))))
175 (define_predicate "gcn_valu_src1_operand"
176 (match_operand 0 "register_operand"))
178 (define_predicate "gcn_valu_src1com_operand"
179 (ior (match_operand 0 "register_operand")
180 (match_operand 0 "gcn_32bit_immediate_operand")))
182 (define_predicate "gcn_conditional_operator"
183 (match_code "eq,ne"))
185 (define_predicate "gcn_compare_64bit_operator"
186 (match_code "eq,ne"))
188 (define_predicate "gcn_compare_operator"
189 (match_code "eq,ne,gt,ge,lt,le,gtu,geu,ltu,leu"))
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"))
194 (define_predicate "unary_operator"
195 (match_code "not,popcount"))
197 (define_predicate "binary_operator"
198 (match_code "and,ior,xor,ashift,lshiftrt,ashiftrt,smin,smax,umin,umax"))
200 (define_predicate "gcn_unspec_operand"
201 (and (match_code "unspec")
202 (match_test "XINT (op, 1) == UNSPEC_VECTOR")))
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"))))
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"))))
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"))))
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")))))
225 (define_predicate "ascending_zero_int_parallel"
226 (match_code "parallel")
228 return gcn_stepped_zero_int_parallel_p (op, 1);