Line data Source code
1 : /* Defining test functions for value conversion via dyn_cast.
2 : Copyright (C) 2022-2026 Free Software Foundation, Inc.
3 : Contributed by Matevos Mehrabyan <matevosmehrabyan@gmail.com>
4 :
5 : This file is part of GCC.
6 :
7 : GCC is free software; you can redistribute it and/or modify it under
8 : the terms of the GNU General Public License as published by the Free
9 : Software Foundation; either version 3, or (at your option) any later
10 : version.
11 :
12 : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 : WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 : FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 : for more details.
16 :
17 : You should have received a copy of the GNU General Public License
18 : along with GCC; see the file COPYING3. If not see
19 : <http://www.gnu.org/licenses/>. */
20 :
21 :
22 : #ifndef SYM_EXEC_EXPRESSION_IS_A_HELPER_H
23 : #define SYM_EXEC_EXPRESSION_IS_A_HELPER_H
24 :
25 : #include "sym-exec-condition.h"
26 :
27 : /* Test function used by dyn_cast checks if the value_bit is of
28 : the value_type::SYMBOLIC_BIT type. */
29 :
30 : template<>
31 : template<>
32 : inline bool
33 949801 : is_a_helper<symbolic_bit *>::test (value_bit *ptr)
34 : {
35 949801 : return ptr->get_type () == value_type::SYMBOLIC_BIT;
36 : }
37 :
38 :
39 : /* Test function used by dyn_cast checks if the value_bit is of
40 : the value_type::BIT type. */
41 :
42 : template<>
43 : template<>
44 : inline bool
45 19591589 : is_a_helper<bit *>::test (value_bit *ptr)
46 : {
47 19591589 : return ptr->get_type () == value_type::BIT;
48 : }
49 :
50 :
51 : /* Test function used by dyn_cast checks if the value_bit
52 : is a bit_expression. */
53 :
54 : template<>
55 : template<>
56 : inline bool
57 134357 : is_a_helper<bit_expression *>::test (value_bit *ptr)
58 : {
59 134357 : value_type type = ptr->get_type ();
60 134357 : return type == value_type::BIT_AND_EXPRESSION
61 : || type == value_type::BIT_OR_EXPRESSION
62 : || type == value_type::BIT_XOR_EXPRESSION
63 : || type == value_type::BIT_COMPLEMENT_EXPRESSION
64 : || type == value_type::SHIFT_RIGHT_EXPRESSION
65 : || type == value_type::SHIFT_LEFT_EXPRESSION
66 : || type == value_type::ADD_EXPRESSION
67 : || type == value_type::SUB_EXPRESSION
68 134357 : || type == value_type::BIT_CONDITION;
69 : }
70 :
71 :
72 : /* Test function used by dyn_cast checks if the value_bit
73 : is a bit_and_expression. */
74 :
75 : template<>
76 : template<>
77 : inline bool
78 : is_a_helper<bit_and_expression *>::test (value_bit *ptr)
79 : {
80 : return ptr->get_type () == value_type::BIT_AND_EXPRESSION;
81 : }
82 :
83 :
84 : /* Test function used by dyn_cast checks if the value_bit
85 : is a bit_or_expression. */
86 :
87 : template<>
88 : template<>
89 : inline bool
90 : is_a_helper<bit_or_expression *>::test (value_bit *ptr)
91 : {
92 : return ptr->get_type () == value_type::BIT_OR_EXPRESSION;
93 : }
94 :
95 :
96 : /* Test function used by dyn_cast checks if the value_bit
97 : is a bit_xor_expression. */
98 :
99 : template<>
100 : template<>
101 : inline bool
102 361280 : is_a_helper<bit_xor_expression *>::test (value_bit *ptr)
103 : {
104 361280 : return ptr->get_type () == value_type::BIT_XOR_EXPRESSION;
105 : }
106 :
107 :
108 : /* Test function used by dyn_cast checks if the value_bit
109 : is a bit_complement_expression. */
110 :
111 : template<>
112 : template<>
113 : inline bool
114 : is_a_helper<bit_complement_expression *>::test (value_bit *ptr)
115 : {
116 : return ptr->get_type () == value_type::BIT_COMPLEMENT_EXPRESSION;
117 : }
118 :
119 :
120 : /* Test function used by dyn_cast checks if the value_bit
121 : is a shift_left_expression. */
122 :
123 : template<>
124 : template<>
125 : inline bool
126 : is_a_helper<shift_left_expression *>::test (value_bit *ptr)
127 : {
128 : return ptr->get_type () == value_type::SHIFT_LEFT_EXPRESSION;
129 : }
130 :
131 :
132 : /* Test function used by dyn_cast checks if the value_bit
133 : is a shift_right_expression. */
134 :
135 : template<>
136 : template<>
137 : inline bool
138 : is_a_helper<shift_right_expression *>::test (value_bit *ptr)
139 : {
140 : return ptr->get_type () == value_type::SHIFT_RIGHT_EXPRESSION;
141 : }
142 :
143 :
144 : /* Test function used by dyn_cast checks if the value_bit
145 : is an add_expression. */
146 :
147 : template<>
148 : template<>
149 : inline bool
150 : is_a_helper<add_expression *>::test (value_bit *ptr)
151 : {
152 : return ptr->get_type () == value_type::ADD_EXPRESSION;
153 : }
154 :
155 :
156 : /* Test function used by dyn_cast checks if the value_bit
157 : is a sub_expression. */
158 :
159 : template<>
160 : template<>
161 : inline bool
162 : is_a_helper<sub_expression *>::test (value_bit *ptr)
163 : {
164 : return ptr->get_type () == value_type::SUB_EXPRESSION;
165 : }
166 :
167 :
168 : /* Test function used by dyn_cast checks if the value_bit
169 : is a bit_condition. */
170 :
171 : template<>
172 : template<>
173 : inline bool
174 : is_a_helper<bit_condition *>::test (value_bit *ptr)
175 : {
176 : return ptr->get_type () == value_type::BIT_CONDITION;
177 : }
178 :
179 :
180 : /* Test function used by dyn_cast checks if the bit_expression
181 : is a bit_and_expression. */
182 :
183 : template<>
184 : template<>
185 : inline bool
186 : is_a_helper<bit_and_expression *>::test (bit_expression *ptr)
187 : {
188 : return ptr->get_type () == value_type::BIT_AND_EXPRESSION;
189 : }
190 :
191 :
192 : /* Test function used by dyn_cast checks if the bit_expression
193 : is a bit_or_expression. */
194 :
195 : template<>
196 : template<>
197 : inline bool
198 : is_a_helper<bit_or_expression *>::test (bit_expression *ptr)
199 : {
200 : return ptr->get_type () == value_type::BIT_OR_EXPRESSION;
201 : }
202 :
203 :
204 : /* Test function used by dyn_cast checks if the bit_expression
205 : is a bit_xor_expression. */
206 :
207 : template<>
208 : template<>
209 : inline bool
210 : is_a_helper<bit_xor_expression *>::test (bit_expression *ptr)
211 : {
212 : return ptr->get_type () == value_type::BIT_XOR_EXPRESSION;
213 : }
214 :
215 :
216 : /* Test function used by dyn_cast checks if the bit_expression
217 : is a bit_complement_expression. */
218 :
219 : template<>
220 : template<>
221 : inline bool
222 0 : is_a_helper<bit_complement_expression *>::test (bit_expression *ptr)
223 : {
224 0 : return ptr->get_type () == value_type::BIT_COMPLEMENT_EXPRESSION;
225 : }
226 :
227 :
228 : /* Test function used by dyn_cast checks if the bit_expression
229 : is a shift_left_expression. */
230 :
231 : template<>
232 : template<>
233 : inline bool
234 : is_a_helper<shift_left_expression *>::test (bit_expression *ptr)
235 : {
236 : return ptr->get_type () == value_type::SHIFT_LEFT_EXPRESSION;
237 : }
238 :
239 :
240 : /* Test function used by dyn_cast checks if the bit_expression
241 : is a shift_right_expression. */
242 :
243 : template<>
244 : template<>
245 : inline bool
246 : is_a_helper<shift_right_expression *>::test (bit_expression *ptr)
247 : {
248 : return ptr->get_type () == value_type::SHIFT_RIGHT_EXPRESSION;
249 : }
250 :
251 :
252 : /* Test function used by dyn_cast checks if the bit_expression
253 : is a add_expression. */
254 :
255 : template<>
256 : template<>
257 : inline bool
258 : is_a_helper<add_expression *>::test (bit_expression *ptr)
259 : {
260 : return ptr->get_type () == value_type::ADD_EXPRESSION;
261 : }
262 :
263 :
264 : /* Test function used by dyn_cast checks if the bit_expression
265 : is a sub_expression. */
266 :
267 : template<>
268 : template<>
269 : inline bool
270 : is_a_helper<sub_expression *>::test (bit_expression *ptr)
271 : {
272 : return ptr->get_type () == value_type::SUB_EXPRESSION;
273 : }
274 :
275 :
276 : /* Test function used by dyn_cast checks if the bit_expression
277 : is a bit_condition_expression. */
278 :
279 : template<>
280 : template<>
281 : inline bool
282 12614 : is_a_helper<bit_condition *>::test (bit_expression *ptr)
283 : {
284 12614 : return ptr->get_type () == value_type::BIT_CONDITION;
285 : }
286 :
287 : #endif /* SYM_EXEC_EXPRESSION_IS_A_HELPER_H. */
|