annotate gcc/config/s390/s390-c.c @ 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 /* Language specific subroutines used for code generation on IBM S/390
kono
parents:
diff changeset
2 and zSeries
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3 Copyright (C) 2015-2018 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 Contributed by Andreas Krebbel (Andreas.Krebbel@de.ibm.com).
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 This file is part of GCC.
kono
parents:
diff changeset
8
kono
parents:
diff changeset
9 GCC is free software; you can redistribute it and/or modify it
kono
parents:
diff changeset
10 under the terms of the GNU General Public License as published by
kono
parents:
diff changeset
11 the Free Software Foundation; either version 3, or (at your option)
kono
parents:
diff changeset
12 any later version.
kono
parents:
diff changeset
13
kono
parents:
diff changeset
14 GCC is distributed in the hope that it will be useful, but WITHOUT
kono
parents:
diff changeset
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
kono
parents:
diff changeset
16 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
kono
parents:
diff changeset
17 License for more details.
kono
parents:
diff changeset
18
kono
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
20 along with GCC; see the file COPYING3. If not see
kono
parents:
diff changeset
21 <http://www.gnu.org/licenses/>.
kono
parents:
diff changeset
22
kono
parents:
diff changeset
23 Based on gcc/config/rs6000/rs6000-c.c.
kono
parents:
diff changeset
24
kono
parents:
diff changeset
25 In GCC terms this file belongs to the frontend. It will be
kono
parents:
diff changeset
26 compiled with -DIN_GCC_FRONTEND. With that rtl.h cannot be
kono
parents:
diff changeset
27 included anymore - a mechanism supposed to avoid adding frontend -
kono
parents:
diff changeset
28 backend dependencies. */
kono
parents:
diff changeset
29
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
30 #define IN_TARGET_CODE 1
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
31
111
kono
parents:
diff changeset
32 #include "config.h"
kono
parents:
diff changeset
33 #include "system.h"
kono
parents:
diff changeset
34 #include "coretypes.h"
kono
parents:
diff changeset
35 #include "target.h"
kono
parents:
diff changeset
36 #include "tree.h"
kono
parents:
diff changeset
37 #include "c-family/c-common.h"
kono
parents:
diff changeset
38 #include "c/c-tree.h"
kono
parents:
diff changeset
39 #include "memmodel.h"
kono
parents:
diff changeset
40 #include "tm_p.h"
kono
parents:
diff changeset
41 #include "stringpool.h"
kono
parents:
diff changeset
42 #include "c-family/c-pragma.h"
kono
parents:
diff changeset
43 #include "langhooks.h"
kono
parents:
diff changeset
44 #include "tree-pretty-print.h"
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 #include "s390-builtins.h"
kono
parents:
diff changeset
47
kono
parents:
diff changeset
48 static GTY(()) tree __vector_keyword;
kono
parents:
diff changeset
49 static GTY(()) tree vector_keyword;
kono
parents:
diff changeset
50 static GTY(()) tree __bool_keyword;
kono
parents:
diff changeset
51 static GTY(()) tree bool_keyword;
kono
parents:
diff changeset
52 static GTY(()) tree _Bool_keyword;
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 /* Generate an array holding all the descriptions of variants of
kono
parents:
diff changeset
56 overloaded builtins defined with OB_DEF_VAR in
kono
parents:
diff changeset
57 s390-builtins.def. */
kono
parents:
diff changeset
58 static enum s390_builtin_ov_type_index
kono
parents:
diff changeset
59 type_for_overloaded_builtin_var[S390_OVERLOADED_BUILTIN_VAR_MAX + 1] =
kono
parents:
diff changeset
60 {
kono
parents:
diff changeset
61 #undef B_DEF
kono
parents:
diff changeset
62 #undef OB_DEF
kono
parents:
diff changeset
63 #undef OB_DEF_VAR
kono
parents:
diff changeset
64 #define B_DEF(...)
kono
parents:
diff changeset
65 #define OB_DEF(...)
kono
parents:
diff changeset
66 #define OB_DEF_VAR(NAME, PATTERN, FLAGS, OPFLAGS, FNTYPE) FNTYPE,
kono
parents:
diff changeset
67 #include "s390-builtins.def"
kono
parents:
diff changeset
68 BT_OV_MAX
kono
parents:
diff changeset
69 };
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 /* Generate an array indexed by an overloaded builtin index returning
kono
parents:
diff changeset
73 the first index in desc_for_overloaded_builtin_var where the
kono
parents:
diff changeset
74 variants for the builtin can be found. */
kono
parents:
diff changeset
75 static enum s390_overloaded_builtin_vars
kono
parents:
diff changeset
76 desc_start_for_overloaded_builtin[S390_OVERLOADED_BUILTIN_MAX + 1] =
kono
parents:
diff changeset
77 {
kono
parents:
diff changeset
78 #undef B_DEF
kono
parents:
diff changeset
79 #undef OB_DEF
kono
parents:
diff changeset
80 #undef OB_DEF_VAR
kono
parents:
diff changeset
81 #define B_DEF(...)
kono
parents:
diff changeset
82 #define OB_DEF(NAME, FIRST_VAR_NAME,...) \
kono
parents:
diff changeset
83 S390_OVERLOADED_BUILTIN_VAR_##FIRST_VAR_NAME,
kono
parents:
diff changeset
84 #define OB_DEF_VAR(...)
kono
parents:
diff changeset
85 #include "s390-builtins.def"
kono
parents:
diff changeset
86 S390_OVERLOADED_BUILTIN_VAR_MAX
kono
parents:
diff changeset
87 };
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89 /* Generate an array indexed by an overloaded builtin index returning
kono
parents:
diff changeset
90 the last index in desc_for_overloaded_builtin_var where the
kono
parents:
diff changeset
91 variants for the builtin can be found. */
kono
parents:
diff changeset
92 static enum s390_overloaded_builtin_vars
kono
parents:
diff changeset
93 desc_end_for_overloaded_builtin[S390_OVERLOADED_BUILTIN_MAX + 1] =
kono
parents:
diff changeset
94 {
kono
parents:
diff changeset
95 #undef B_DEF
kono
parents:
diff changeset
96 #undef OB_DEF
kono
parents:
diff changeset
97 #undef OB_DEF_VAR
kono
parents:
diff changeset
98 #define B_DEF(...)
kono
parents:
diff changeset
99 #define OB_DEF(NAME, FIRST_VAR_NAME, LAST_VAR_NAME,...) \
kono
parents:
diff changeset
100 S390_OVERLOADED_BUILTIN_VAR_##LAST_VAR_NAME,
kono
parents:
diff changeset
101 #define OB_DEF_VAR(...)
kono
parents:
diff changeset
102 #include "s390-builtins.def"
kono
parents:
diff changeset
103 S390_OVERLOADED_BUILTIN_VAR_MAX
kono
parents:
diff changeset
104 };
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 static enum s390_builtin_type_index
kono
parents:
diff changeset
107 s390_builtin_ov_types[BT_OV_MAX][MAX_OV_OPERANDS] =
kono
parents:
diff changeset
108 {
kono
parents:
diff changeset
109 #undef DEF_TYPE
kono
parents:
diff changeset
110 #undef DEF_POINTER_TYPE
kono
parents:
diff changeset
111 #undef DEF_DISTINCT_TYPE
kono
parents:
diff changeset
112 #undef DEF_VECTOR_TYPE
kono
parents:
diff changeset
113 #undef DEF_OPAQUE_VECTOR_TYPE
kono
parents:
diff changeset
114 #undef DEF_FN_TYPE
kono
parents:
diff changeset
115 #undef DEF_OV_TYPE
kono
parents:
diff changeset
116 #define DEF_TYPE(...)
kono
parents:
diff changeset
117 #define DEF_POINTER_TYPE(...)
kono
parents:
diff changeset
118 #define DEF_DISTINCT_TYPE(...)
kono
parents:
diff changeset
119 #define DEF_VECTOR_TYPE(...)
kono
parents:
diff changeset
120 #define DEF_OPAQUE_VECTOR_TYPE(...)
kono
parents:
diff changeset
121 #define DEF_FN_TYPE(...)
kono
parents:
diff changeset
122 #define DEF_OV_TYPE(INDEX, args...) { args },
kono
parents:
diff changeset
123 #include "s390-builtin-types.def"
kono
parents:
diff changeset
124 };
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 static const enum s390_builtins
kono
parents:
diff changeset
127 bt_for_overloaded_builtin_var[S390_OVERLOADED_BUILTIN_VAR_MAX] = {
kono
parents:
diff changeset
128 #undef B_DEF
kono
parents:
diff changeset
129 #undef OB_DEF
kono
parents:
diff changeset
130 #undef OB_DEF_VAR
kono
parents:
diff changeset
131 #define B_DEF(...)
kono
parents:
diff changeset
132 #define OB_DEF(...)
kono
parents:
diff changeset
133 #define OB_DEF_VAR(NAME, BT, ...) S390_BUILTIN_##BT,
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 #include "s390-builtins.def"
kono
parents:
diff changeset
136 };
kono
parents:
diff changeset
137
kono
parents:
diff changeset
138 /* In addition to calling fold_convert for EXPR of type TYPE, also
kono
parents:
diff changeset
139 call c_fully_fold to remove any C_MAYBE_CONST_EXPRs that could be
kono
parents:
diff changeset
140 hiding there (PR47197). */
kono
parents:
diff changeset
141 tree
kono
parents:
diff changeset
142 fully_fold_convert (tree type, tree expr)
kono
parents:
diff changeset
143 {
kono
parents:
diff changeset
144 tree result = fold_convert (type, expr);
kono
parents:
diff changeset
145 bool maybe_const = true;
kono
parents:
diff changeset
146
kono
parents:
diff changeset
147 if (!c_dialect_cxx ())
kono
parents:
diff changeset
148 result = c_fully_fold (result, false, &maybe_const);
kono
parents:
diff changeset
149
kono
parents:
diff changeset
150 return result;
kono
parents:
diff changeset
151 }
kono
parents:
diff changeset
152
kono
parents:
diff changeset
153 /* Unify the different variants to the same nodes in order to keep the
kono
parents:
diff changeset
154 code working with it simple. */
kono
parents:
diff changeset
155 static cpp_hashnode *
kono
parents:
diff changeset
156 s390_categorize_keyword (const cpp_token *tok)
kono
parents:
diff changeset
157 {
kono
parents:
diff changeset
158 if (tok->type == CPP_NAME)
kono
parents:
diff changeset
159 {
kono
parents:
diff changeset
160 cpp_hashnode *ident = tok->val.node.node;
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 if (ident == C_CPP_HASHNODE (vector_keyword))
kono
parents:
diff changeset
163 return C_CPP_HASHNODE (__vector_keyword);
kono
parents:
diff changeset
164
kono
parents:
diff changeset
165 if (ident == C_CPP_HASHNODE (bool_keyword))
kono
parents:
diff changeset
166 return C_CPP_HASHNODE (__bool_keyword);
kono
parents:
diff changeset
167
kono
parents:
diff changeset
168 if (ident == C_CPP_HASHNODE (_Bool_keyword))
kono
parents:
diff changeset
169 return C_CPP_HASHNODE (__bool_keyword);
kono
parents:
diff changeset
170 return ident;
kono
parents:
diff changeset
171 }
kono
parents:
diff changeset
172
kono
parents:
diff changeset
173 return 0;
kono
parents:
diff changeset
174 }
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176
kono
parents:
diff changeset
177 /* Called to decide whether a conditional macro should be expanded.
kono
parents:
diff changeset
178 Since we have exactly one such macro (i.e, 'vector'), we do not
kono
parents:
diff changeset
179 need to examine the 'tok' parameter. */
kono
parents:
diff changeset
180
kono
parents:
diff changeset
181 static cpp_hashnode *
kono
parents:
diff changeset
182 s390_macro_to_expand (cpp_reader *pfile, const cpp_token *tok)
kono
parents:
diff changeset
183 {
kono
parents:
diff changeset
184 cpp_hashnode *expand_this = tok->val.node.node;
kono
parents:
diff changeset
185 cpp_hashnode *ident;
kono
parents:
diff changeset
186 static bool expand_bool_p = false;
kono
parents:
diff changeset
187 int idx = 0;
kono
parents:
diff changeset
188 enum rid rid_code;
kono
parents:
diff changeset
189
kono
parents:
diff changeset
190 /* The vector keyword is only expanded if the machine actually
kono
parents:
diff changeset
191 provides hardware support. */
kono
parents:
diff changeset
192 if (!TARGET_ZVECTOR)
kono
parents:
diff changeset
193 return NULL;
kono
parents:
diff changeset
194
kono
parents:
diff changeset
195 ident = s390_categorize_keyword (tok);
kono
parents:
diff changeset
196
kono
parents:
diff changeset
197 /* Triggered when we picked a different variant in
kono
parents:
diff changeset
198 s390_categorize_keyword. */
kono
parents:
diff changeset
199 if (ident != expand_this)
kono
parents:
diff changeset
200 expand_this = NULL;
kono
parents:
diff changeset
201
kono
parents:
diff changeset
202 /* The vector keyword has been found already and we remembered to
kono
parents:
diff changeset
203 expand the next bool. */
kono
parents:
diff changeset
204 if (expand_bool_p && ident == C_CPP_HASHNODE (__bool_keyword))
kono
parents:
diff changeset
205 {
kono
parents:
diff changeset
206 expand_bool_p = false;
kono
parents:
diff changeset
207 return ident;
kono
parents:
diff changeset
208 }
kono
parents:
diff changeset
209
kono
parents:
diff changeset
210 if (ident != C_CPP_HASHNODE (__vector_keyword))
kono
parents:
diff changeset
211 return expand_this;
kono
parents:
diff changeset
212
kono
parents:
diff changeset
213 do
kono
parents:
diff changeset
214 tok = cpp_peek_token (pfile, idx++);
kono
parents:
diff changeset
215 while (tok->type == CPP_PADDING);
kono
parents:
diff changeset
216 ident = s390_categorize_keyword (tok);
kono
parents:
diff changeset
217
kono
parents:
diff changeset
218 if (!ident)
kono
parents:
diff changeset
219 return expand_this;
kono
parents:
diff changeset
220
kono
parents:
diff changeset
221 /* vector bool - remember to expand the next bool. */
kono
parents:
diff changeset
222 if (ident == C_CPP_HASHNODE (__bool_keyword))
kono
parents:
diff changeset
223 {
kono
parents:
diff changeset
224 expand_bool_p = true;
kono
parents:
diff changeset
225 return C_CPP_HASHNODE (__vector_keyword);
kono
parents:
diff changeset
226 }
kono
parents:
diff changeset
227
kono
parents:
diff changeset
228 /* The boost libraries have code with Iterator::vector vector in it.
kono
parents:
diff changeset
229 If we allow the normal handling, this module will be called
kono
parents:
diff changeset
230 recursively, and the vector will be skipped.; */
kono
parents:
diff changeset
231 if (ident == C_CPP_HASHNODE (__vector_keyword))
kono
parents:
diff changeset
232 return expand_this;
kono
parents:
diff changeset
233
kono
parents:
diff changeset
234 rid_code = (enum rid)(ident->rid_code);
kono
parents:
diff changeset
235
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
236 if (cpp_macro_p (ident))
111
kono
parents:
diff changeset
237 {
kono
parents:
diff changeset
238 /* Now actually fetch the tokens we "peeked" before and do a
kono
parents:
diff changeset
239 lookahead for the next. */
kono
parents:
diff changeset
240 do
kono
parents:
diff changeset
241 (void) cpp_get_token (pfile);
kono
parents:
diff changeset
242 while (--idx > 0);
kono
parents:
diff changeset
243 do
kono
parents:
diff changeset
244 tok = cpp_peek_token (pfile, idx++);
kono
parents:
diff changeset
245 while (tok->type == CPP_PADDING);
kono
parents:
diff changeset
246 ident = s390_categorize_keyword (tok);
kono
parents:
diff changeset
247
kono
parents:
diff changeset
248 if (ident == C_CPP_HASHNODE (__bool_keyword))
kono
parents:
diff changeset
249 {
kono
parents:
diff changeset
250 expand_bool_p = true;
kono
parents:
diff changeset
251 return C_CPP_HASHNODE (__vector_keyword);
kono
parents:
diff changeset
252 }
kono
parents:
diff changeset
253 else if (ident)
kono
parents:
diff changeset
254 rid_code = (enum rid)(ident->rid_code);
kono
parents:
diff changeset
255 }
kono
parents:
diff changeset
256
kono
parents:
diff changeset
257 /* vector keyword followed by type identifier: vector unsigned,
kono
parents:
diff changeset
258 vector long, ...
kono
parents:
diff changeset
259 Types consisting of more than one identifier are not supported by
kono
parents:
diff changeset
260 zvector e.g. long long, long double, unsigned long int. */
kono
parents:
diff changeset
261 if (rid_code == RID_UNSIGNED || rid_code == RID_LONG
kono
parents:
diff changeset
262 || rid_code == RID_SHORT || rid_code == RID_SIGNED
kono
parents:
diff changeset
263 || rid_code == RID_INT || rid_code == RID_CHAR
kono
parents:
diff changeset
264 || (rid_code == RID_FLOAT && TARGET_VXE)
kono
parents:
diff changeset
265 || rid_code == RID_DOUBLE)
kono
parents:
diff changeset
266 {
kono
parents:
diff changeset
267 expand_this = C_CPP_HASHNODE (__vector_keyword);
kono
parents:
diff changeset
268 /* If the next keyword is bool, it will need to be expanded as
kono
parents:
diff changeset
269 well. */
kono
parents:
diff changeset
270 do
kono
parents:
diff changeset
271 tok = cpp_peek_token (pfile, idx++);
kono
parents:
diff changeset
272 while (tok->type == CPP_PADDING);
kono
parents:
diff changeset
273 ident = s390_categorize_keyword (tok);
kono
parents:
diff changeset
274
kono
parents:
diff changeset
275 /* __vector long __bool a; */
kono
parents:
diff changeset
276 if (ident == C_CPP_HASHNODE (__bool_keyword))
kono
parents:
diff changeset
277 expand_bool_p = true;
kono
parents:
diff changeset
278 else
kono
parents:
diff changeset
279 {
kono
parents:
diff changeset
280 /* Triggered with: __vector long long __bool a; */
kono
parents:
diff changeset
281 do
kono
parents:
diff changeset
282 tok = cpp_peek_token (pfile, idx++);
kono
parents:
diff changeset
283 while (tok->type == CPP_PADDING);
kono
parents:
diff changeset
284 ident = s390_categorize_keyword (tok);
kono
parents:
diff changeset
285
kono
parents:
diff changeset
286 if (ident == C_CPP_HASHNODE (__bool_keyword))
kono
parents:
diff changeset
287 expand_bool_p = true;
kono
parents:
diff changeset
288 }
kono
parents:
diff changeset
289 }
kono
parents:
diff changeset
290
kono
parents:
diff changeset
291 return expand_this;
kono
parents:
diff changeset
292 }
kono
parents:
diff changeset
293
kono
parents:
diff changeset
294 /* Helper function that defines or undefines macros. If SET is true, the macro
kono
parents:
diff changeset
295 MACRO_DEF is defined. If SET is false, the macro MACRO_UNDEF is undefined.
kono
parents:
diff changeset
296 Nothing is done if SET and WAS_SET have the same value. */
kono
parents:
diff changeset
297 static void
kono
parents:
diff changeset
298 s390_def_or_undef_macro (cpp_reader *pfile,
kono
parents:
diff changeset
299 unsigned int mask,
kono
parents:
diff changeset
300 const struct cl_target_option *old_opts,
kono
parents:
diff changeset
301 const struct cl_target_option *new_opts,
kono
parents:
diff changeset
302 const char *macro_def, const char *macro_undef)
kono
parents:
diff changeset
303 {
kono
parents:
diff changeset
304 bool was_set;
kono
parents:
diff changeset
305 bool set;
kono
parents:
diff changeset
306
kono
parents:
diff changeset
307 was_set = (!old_opts) ? false : old_opts->x_target_flags & mask;
kono
parents:
diff changeset
308 set = new_opts->x_target_flags & mask;
kono
parents:
diff changeset
309 if (was_set == set)
kono
parents:
diff changeset
310 return;
kono
parents:
diff changeset
311 if (set)
kono
parents:
diff changeset
312 cpp_define (pfile, macro_def);
kono
parents:
diff changeset
313 else
kono
parents:
diff changeset
314 cpp_undef (pfile, macro_undef);
kono
parents:
diff changeset
315 }
kono
parents:
diff changeset
316
kono
parents:
diff changeset
317 /* Internal function to either define or undef the appropriate system
kono
parents:
diff changeset
318 macros. */
kono
parents:
diff changeset
319 static void
kono
parents:
diff changeset
320 s390_cpu_cpp_builtins_internal (cpp_reader *pfile,
kono
parents:
diff changeset
321 struct cl_target_option *opts,
kono
parents:
diff changeset
322 const struct cl_target_option *old_opts)
kono
parents:
diff changeset
323 {
kono
parents:
diff changeset
324 s390_def_or_undef_macro (pfile, MASK_OPT_HTM, old_opts, opts,
kono
parents:
diff changeset
325 "__HTM__", "__HTM__");
kono
parents:
diff changeset
326 s390_def_or_undef_macro (pfile, MASK_OPT_VX, old_opts, opts,
kono
parents:
diff changeset
327 "__VX__", "__VX__");
kono
parents:
diff changeset
328 s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts,
kono
parents:
diff changeset
329 "__VEC__=10302", "__VEC__");
kono
parents:
diff changeset
330 s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts,
kono
parents:
diff changeset
331 "__vector=__attribute__((vector_size(16)))",
kono
parents:
diff changeset
332 "__vector__");
kono
parents:
diff changeset
333 s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts,
kono
parents:
diff changeset
334 "__bool=__attribute__((s390_vector_bool)) unsigned",
kono
parents:
diff changeset
335 "__bool");
kono
parents:
diff changeset
336 {
kono
parents:
diff changeset
337 char macro_def[64];
kono
parents:
diff changeset
338 gcc_assert (s390_arch != PROCESSOR_NATIVE);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
339 sprintf (macro_def, "__ARCH__=%d", processor_table[s390_arch].arch_level);
111
kono
parents:
diff changeset
340 cpp_undef (pfile, "__ARCH__");
kono
parents:
diff changeset
341 cpp_define (pfile, macro_def);
kono
parents:
diff changeset
342 }
kono
parents:
diff changeset
343
kono
parents:
diff changeset
344 if (!flag_iso)
kono
parents:
diff changeset
345 {
kono
parents:
diff changeset
346 s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts,
kono
parents:
diff changeset
347 "__VECTOR_KEYWORD_SUPPORTED__",
kono
parents:
diff changeset
348 "__VECTOR_KEYWORD_SUPPORTED__");
kono
parents:
diff changeset
349 s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts,
kono
parents:
diff changeset
350 "vector=vector", "vector");
kono
parents:
diff changeset
351 s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts,
kono
parents:
diff changeset
352 "bool=bool", "bool");
kono
parents:
diff changeset
353 if (TARGET_ZVECTOR_P (opts->x_target_flags) && __vector_keyword == NULL)
kono
parents:
diff changeset
354 {
kono
parents:
diff changeset
355 __vector_keyword = get_identifier ("__vector");
kono
parents:
diff changeset
356 C_CPP_HASHNODE (__vector_keyword)->flags |= NODE_CONDITIONAL;
kono
parents:
diff changeset
357
kono
parents:
diff changeset
358 vector_keyword = get_identifier ("vector");
kono
parents:
diff changeset
359 C_CPP_HASHNODE (vector_keyword)->flags |= NODE_CONDITIONAL;
kono
parents:
diff changeset
360
kono
parents:
diff changeset
361 __bool_keyword = get_identifier ("__bool");
kono
parents:
diff changeset
362 C_CPP_HASHNODE (__bool_keyword)->flags |= NODE_CONDITIONAL;
kono
parents:
diff changeset
363
kono
parents:
diff changeset
364 bool_keyword = get_identifier ("bool");
kono
parents:
diff changeset
365 C_CPP_HASHNODE (bool_keyword)->flags |= NODE_CONDITIONAL;
kono
parents:
diff changeset
366
kono
parents:
diff changeset
367 _Bool_keyword = get_identifier ("_Bool");
kono
parents:
diff changeset
368 C_CPP_HASHNODE (_Bool_keyword)->flags |= NODE_CONDITIONAL;
kono
parents:
diff changeset
369
kono
parents:
diff changeset
370 /* Enable context-sensitive macros. */
kono
parents:
diff changeset
371 cpp_get_callbacks (pfile)->macro_to_expand = s390_macro_to_expand;
kono
parents:
diff changeset
372 }
kono
parents:
diff changeset
373 }
kono
parents:
diff changeset
374 }
kono
parents:
diff changeset
375
kono
parents:
diff changeset
376 /* Define platform dependent macros. */
kono
parents:
diff changeset
377 void
kono
parents:
diff changeset
378 s390_cpu_cpp_builtins (cpp_reader *pfile)
kono
parents:
diff changeset
379 {
kono
parents:
diff changeset
380 struct cl_target_option opts;
kono
parents:
diff changeset
381
kono
parents:
diff changeset
382 cpp_assert (pfile, "cpu=s390");
kono
parents:
diff changeset
383 cpp_assert (pfile, "machine=s390");
kono
parents:
diff changeset
384 cpp_define (pfile, "__s390__");
kono
parents:
diff changeset
385 if (TARGET_ZARCH)
kono
parents:
diff changeset
386 cpp_define (pfile, "__zarch__");
kono
parents:
diff changeset
387 if (TARGET_64BIT)
kono
parents:
diff changeset
388 cpp_define (pfile, "__s390x__");
kono
parents:
diff changeset
389 if (TARGET_LONG_DOUBLE_128)
kono
parents:
diff changeset
390 cpp_define (pfile, "__LONG_DOUBLE_128__");
kono
parents:
diff changeset
391 cl_target_option_save (&opts, &global_options);
kono
parents:
diff changeset
392 s390_cpu_cpp_builtins_internal (pfile, &opts, NULL);
kono
parents:
diff changeset
393 }
kono
parents:
diff changeset
394
kono
parents:
diff changeset
395 #if S390_USE_TARGET_ATTRIBUTE
kono
parents:
diff changeset
396 /* Hook to validate the current #pragma GCC target and set the state, and
kono
parents:
diff changeset
397 update the macros based on what was changed. If ARGS is NULL, then
kono
parents:
diff changeset
398 POP_TARGET is used to reset the options. */
kono
parents:
diff changeset
399
kono
parents:
diff changeset
400 static bool
kono
parents:
diff changeset
401 s390_pragma_target_parse (tree args, tree pop_target)
kono
parents:
diff changeset
402 {
kono
parents:
diff changeset
403 tree prev_tree = build_target_option_node (&global_options);
kono
parents:
diff changeset
404 tree cur_tree;
kono
parents:
diff changeset
405
kono
parents:
diff changeset
406 if (! args)
kono
parents:
diff changeset
407 cur_tree = pop_target;
kono
parents:
diff changeset
408 else
kono
parents:
diff changeset
409 {
kono
parents:
diff changeset
410 cur_tree = s390_valid_target_attribute_tree (args, &global_options,
kono
parents:
diff changeset
411 &global_options_set, true);
kono
parents:
diff changeset
412 if (!cur_tree || cur_tree == error_mark_node)
kono
parents:
diff changeset
413 {
kono
parents:
diff changeset
414 cl_target_option_restore (&global_options,
kono
parents:
diff changeset
415 TREE_TARGET_OPTION (prev_tree));
kono
parents:
diff changeset
416 return false;
kono
parents:
diff changeset
417 }
kono
parents:
diff changeset
418 }
kono
parents:
diff changeset
419
kono
parents:
diff changeset
420 target_option_current_node = cur_tree;
kono
parents:
diff changeset
421 s390_activate_target_options (target_option_current_node);
kono
parents:
diff changeset
422
kono
parents:
diff changeset
423 {
kono
parents:
diff changeset
424 struct cl_target_option *prev_opt;
kono
parents:
diff changeset
425 struct cl_target_option *cur_opt;
kono
parents:
diff changeset
426
kono
parents:
diff changeset
427 /* Figure out the previous/current differences. */
kono
parents:
diff changeset
428 prev_opt = TREE_TARGET_OPTION (prev_tree);
kono
parents:
diff changeset
429 cur_opt = TREE_TARGET_OPTION (cur_tree);
kono
parents:
diff changeset
430
kono
parents:
diff changeset
431 /* For the definitions, ensure all newly defined macros are considered
kono
parents:
diff changeset
432 as used for -Wunused-macros. There is no point warning about the
kono
parents:
diff changeset
433 compiler predefined macros. */
kono
parents:
diff changeset
434 cpp_options *cpp_opts = cpp_get_options (parse_in);
kono
parents:
diff changeset
435 unsigned char saved_warn_unused_macros = cpp_opts->warn_unused_macros;
kono
parents:
diff changeset
436
kono
parents:
diff changeset
437 cpp_opts->warn_unused_macros = 0;
kono
parents:
diff changeset
438
kono
parents:
diff changeset
439 /* Define all of the macros for new options that were just turned on. */
kono
parents:
diff changeset
440 s390_cpu_cpp_builtins_internal (parse_in, cur_opt, prev_opt);
kono
parents:
diff changeset
441
kono
parents:
diff changeset
442 cpp_opts->warn_unused_macros = saved_warn_unused_macros;
kono
parents:
diff changeset
443 }
kono
parents:
diff changeset
444
kono
parents:
diff changeset
445 return true;
kono
parents:
diff changeset
446 }
kono
parents:
diff changeset
447 #endif
kono
parents:
diff changeset
448
kono
parents:
diff changeset
449 /* Expand builtins which can directly be mapped to tree expressions.
kono
parents:
diff changeset
450 LOC - location information
kono
parents:
diff changeset
451 FCODE - function code of the builtin
kono
parents:
diff changeset
452 ARGLIST - value supposed to be passed as arguments
kono
parents:
diff changeset
453 RETURN-TYPE - expected return type of the builtin */
kono
parents:
diff changeset
454 static tree
kono
parents:
diff changeset
455 s390_expand_overloaded_builtin (location_t loc,
kono
parents:
diff changeset
456 unsigned fcode,
kono
parents:
diff changeset
457 vec<tree, va_gc> *arglist,
kono
parents:
diff changeset
458 tree return_type)
kono
parents:
diff changeset
459 {
kono
parents:
diff changeset
460 switch (fcode)
kono
parents:
diff changeset
461 {
kono
parents:
diff changeset
462 case S390_OVERLOADED_BUILTIN_s390_vec_step:
kono
parents:
diff changeset
463 if (TREE_CODE (TREE_TYPE ((*arglist)[0])) != VECTOR_TYPE)
kono
parents:
diff changeset
464 {
kono
parents:
diff changeset
465 error_at (loc, "builtin vec_step can only be used on vector types.");
kono
parents:
diff changeset
466 return error_mark_node;
kono
parents:
diff changeset
467 }
kono
parents:
diff changeset
468 return build_int_cst (NULL_TREE,
kono
parents:
diff changeset
469 TYPE_VECTOR_SUBPARTS (TREE_TYPE ((*arglist)[0])));
kono
parents:
diff changeset
470 case S390_OVERLOADED_BUILTIN_s390_vec_xl:
kono
parents:
diff changeset
471 case S390_OVERLOADED_BUILTIN_s390_vec_xld2:
kono
parents:
diff changeset
472 case S390_OVERLOADED_BUILTIN_s390_vec_xlw4:
kono
parents:
diff changeset
473 return build2 (MEM_REF, return_type,
kono
parents:
diff changeset
474 fold_build_pointer_plus ((*arglist)[1], (*arglist)[0]),
kono
parents:
diff changeset
475 build_int_cst (TREE_TYPE ((*arglist)[1]), 0));
kono
parents:
diff changeset
476 case S390_OVERLOADED_BUILTIN_s390_vec_xst:
kono
parents:
diff changeset
477 case S390_OVERLOADED_BUILTIN_s390_vec_xstd2:
kono
parents:
diff changeset
478 case S390_OVERLOADED_BUILTIN_s390_vec_xstw4:
kono
parents:
diff changeset
479 return build2 (MODIFY_EXPR, TREE_TYPE((*arglist)[0]),
kono
parents:
diff changeset
480 build1 (INDIRECT_REF, TREE_TYPE((*arglist)[0]),
kono
parents:
diff changeset
481 fold_build_pointer_plus ((*arglist)[2], (*arglist)[1])),
kono
parents:
diff changeset
482 (*arglist)[0]);
kono
parents:
diff changeset
483 case S390_OVERLOADED_BUILTIN_s390_vec_load_pair:
kono
parents:
diff changeset
484 return build_constructor_va (return_type, 2,
kono
parents:
diff changeset
485 NULL_TREE, (*arglist)[0],
kono
parents:
diff changeset
486 NULL_TREE, (*arglist)[1]);
kono
parents:
diff changeset
487 default:
kono
parents:
diff changeset
488 gcc_unreachable ();
kono
parents:
diff changeset
489 }
kono
parents:
diff changeset
490 }
kono
parents:
diff changeset
491
kono
parents:
diff changeset
492 /* invert result */
kono
parents:
diff changeset
493 #define __VSTRING_FLAG_IN 8
kono
parents:
diff changeset
494 /* result type */
kono
parents:
diff changeset
495 #define __VSTRING_FLAG_RT 4
kono
parents:
diff changeset
496 /* zero search */
kono
parents:
diff changeset
497 #define __VSTRING_FLAG_ZS 2
kono
parents:
diff changeset
498 /* set condition code */
kono
parents:
diff changeset
499 #define __VSTRING_FLAG_CS 1
kono
parents:
diff changeset
500
kono
parents:
diff changeset
501 /* Return the flags value to be used for string low-level builtins
kono
parents:
diff changeset
502 when expanded from overloaded builtin OB_FCODE. */
kono
parents:
diff changeset
503 static unsigned int
kono
parents:
diff changeset
504 s390_get_vstring_flags (int ob_fcode)
kono
parents:
diff changeset
505 {
kono
parents:
diff changeset
506 unsigned int flags = 0;
kono
parents:
diff changeset
507
kono
parents:
diff changeset
508 switch (ob_fcode)
kono
parents:
diff changeset
509 {
kono
parents:
diff changeset
510 case S390_OVERLOADED_BUILTIN_s390_vec_find_any_ne_idx:
kono
parents:
diff changeset
511 case S390_OVERLOADED_BUILTIN_s390_vec_find_any_ne_or_0_idx:
kono
parents:
diff changeset
512 case S390_OVERLOADED_BUILTIN_s390_vec_find_any_ne:
kono
parents:
diff changeset
513 case S390_OVERLOADED_BUILTIN_s390_vec_find_any_ne_idx_cc:
kono
parents:
diff changeset
514 case S390_OVERLOADED_BUILTIN_s390_vec_find_any_ne_or_0_idx_cc:
kono
parents:
diff changeset
515 case S390_OVERLOADED_BUILTIN_s390_vec_find_any_ne_cc:
kono
parents:
diff changeset
516 case S390_OVERLOADED_BUILTIN_s390_vec_cmpnrg_idx:
kono
parents:
diff changeset
517 case S390_OVERLOADED_BUILTIN_s390_vec_cmpnrg_or_0_idx:
kono
parents:
diff changeset
518 case S390_OVERLOADED_BUILTIN_s390_vec_cmpnrg:
kono
parents:
diff changeset
519 case S390_OVERLOADED_BUILTIN_s390_vec_cmpnrg_idx_cc:
kono
parents:
diff changeset
520 case S390_OVERLOADED_BUILTIN_s390_vec_cmpnrg_or_0_idx_cc:
kono
parents:
diff changeset
521 case S390_OVERLOADED_BUILTIN_s390_vec_cmpnrg_cc:
kono
parents:
diff changeset
522 flags |= __VSTRING_FLAG_IN;
kono
parents:
diff changeset
523 break;
kono
parents:
diff changeset
524 default:
kono
parents:
diff changeset
525 break;
kono
parents:
diff changeset
526 }
kono
parents:
diff changeset
527 switch (ob_fcode)
kono
parents:
diff changeset
528 {
kono
parents:
diff changeset
529
kono
parents:
diff changeset
530 case S390_OVERLOADED_BUILTIN_s390_vec_find_any_eq:
kono
parents:
diff changeset
531 case S390_OVERLOADED_BUILTIN_s390_vec_find_any_ne:
kono
parents:
diff changeset
532 case S390_OVERLOADED_BUILTIN_s390_vec_find_any_eq_cc:
kono
parents:
diff changeset
533 case S390_OVERLOADED_BUILTIN_s390_vec_find_any_ne_cc:
kono
parents:
diff changeset
534 case S390_OVERLOADED_BUILTIN_s390_vec_cmprg:
kono
parents:
diff changeset
535 case S390_OVERLOADED_BUILTIN_s390_vec_cmpnrg:
kono
parents:
diff changeset
536 case S390_OVERLOADED_BUILTIN_s390_vec_cmprg_cc:
kono
parents:
diff changeset
537 case S390_OVERLOADED_BUILTIN_s390_vec_cmpnrg_cc:
kono
parents:
diff changeset
538 flags |= __VSTRING_FLAG_RT;
kono
parents:
diff changeset
539 break;
kono
parents:
diff changeset
540 default:
kono
parents:
diff changeset
541 break;
kono
parents:
diff changeset
542 }
kono
parents:
diff changeset
543 switch (ob_fcode)
kono
parents:
diff changeset
544 {
kono
parents:
diff changeset
545
kono
parents:
diff changeset
546 case S390_OVERLOADED_BUILTIN_s390_vec_find_any_eq_or_0_idx:
kono
parents:
diff changeset
547 case S390_OVERLOADED_BUILTIN_s390_vec_find_any_ne_or_0_idx:
kono
parents:
diff changeset
548 case S390_OVERLOADED_BUILTIN_s390_vec_find_any_eq_or_0_idx_cc:
kono
parents:
diff changeset
549 case S390_OVERLOADED_BUILTIN_s390_vec_find_any_ne_or_0_idx_cc:
kono
parents:
diff changeset
550 case S390_OVERLOADED_BUILTIN_s390_vec_cmprg_or_0_idx:
kono
parents:
diff changeset
551 case S390_OVERLOADED_BUILTIN_s390_vec_cmpnrg_or_0_idx:
kono
parents:
diff changeset
552 case S390_OVERLOADED_BUILTIN_s390_vec_cmprg_or_0_idx_cc:
kono
parents:
diff changeset
553 case S390_OVERLOADED_BUILTIN_s390_vec_cmpnrg_or_0_idx_cc:
kono
parents:
diff changeset
554 flags |= __VSTRING_FLAG_ZS;
kono
parents:
diff changeset
555 break;
kono
parents:
diff changeset
556 default:
kono
parents:
diff changeset
557 break;
kono
parents:
diff changeset
558 }
kono
parents:
diff changeset
559 switch (ob_fcode)
kono
parents:
diff changeset
560 {
kono
parents:
diff changeset
561 case S390_OVERLOADED_BUILTIN_s390_vec_find_any_eq_idx_cc:
kono
parents:
diff changeset
562 case S390_OVERLOADED_BUILTIN_s390_vec_find_any_ne_idx_cc:
kono
parents:
diff changeset
563 case S390_OVERLOADED_BUILTIN_s390_vec_find_any_eq_or_0_idx_cc:
kono
parents:
diff changeset
564 case S390_OVERLOADED_BUILTIN_s390_vec_find_any_ne_or_0_idx_cc:
kono
parents:
diff changeset
565 case S390_OVERLOADED_BUILTIN_s390_vec_find_any_eq_cc:
kono
parents:
diff changeset
566 case S390_OVERLOADED_BUILTIN_s390_vec_find_any_ne_cc:
kono
parents:
diff changeset
567 case S390_OVERLOADED_BUILTIN_s390_vec_cmprg_idx_cc:
kono
parents:
diff changeset
568 case S390_OVERLOADED_BUILTIN_s390_vec_cmpnrg_idx_cc:
kono
parents:
diff changeset
569 case S390_OVERLOADED_BUILTIN_s390_vec_cmprg_or_0_idx_cc:
kono
parents:
diff changeset
570 case S390_OVERLOADED_BUILTIN_s390_vec_cmpnrg_or_0_idx_cc:
kono
parents:
diff changeset
571 case S390_OVERLOADED_BUILTIN_s390_vec_cmprg_cc:
kono
parents:
diff changeset
572 case S390_OVERLOADED_BUILTIN_s390_vec_cmpnrg_cc:
kono
parents:
diff changeset
573 flags |= __VSTRING_FLAG_CS;
kono
parents:
diff changeset
574 break;
kono
parents:
diff changeset
575 default:
kono
parents:
diff changeset
576 break;
kono
parents:
diff changeset
577 }
kono
parents:
diff changeset
578 return flags;
kono
parents:
diff changeset
579 }
kono
parents:
diff changeset
580 #undef __VSTRING_FLAG_IN
kono
parents:
diff changeset
581 #undef __VSTRING_FLAG_RT
kono
parents:
diff changeset
582 #undef __VSTRING_FLAG_ZS
kono
parents:
diff changeset
583 #undef __VSTRING_FLAG_CS
kono
parents:
diff changeset
584
kono
parents:
diff changeset
585 /* For several overloaded builtins the argument lists do not match
kono
parents:
diff changeset
586 exactly the signature of a low-level builtin. This function
kono
parents:
diff changeset
587 adjusts the argument list ARGLIST for the overloaded builtin
kono
parents:
diff changeset
588 OB_FCODE to the signature of the low-level builtin given by
kono
parents:
diff changeset
589 DECL. */
kono
parents:
diff changeset
590 static void
kono
parents:
diff changeset
591 s390_adjust_builtin_arglist (unsigned int ob_fcode, tree decl,
kono
parents:
diff changeset
592 vec<tree, va_gc> **arglist)
kono
parents:
diff changeset
593 {
kono
parents:
diff changeset
594 tree arg_chain;
kono
parents:
diff changeset
595 int src_arg_index, dest_arg_index;
kono
parents:
diff changeset
596 vec<tree, va_gc> *folded_args = NULL;
kono
parents:
diff changeset
597
kono
parents:
diff changeset
598 /* We at most add one more operand to the list. */
kono
parents:
diff changeset
599 vec_alloc (folded_args, (*arglist)->allocated () + 1);
kono
parents:
diff changeset
600 for (arg_chain = TYPE_ARG_TYPES (TREE_TYPE (decl)),
kono
parents:
diff changeset
601 src_arg_index = 0, dest_arg_index = 0;
kono
parents:
diff changeset
602 !VOID_TYPE_P (TREE_VALUE (arg_chain));
kono
parents:
diff changeset
603 arg_chain = TREE_CHAIN (arg_chain), dest_arg_index++)
kono
parents:
diff changeset
604 {
kono
parents:
diff changeset
605 bool arg_assigned_p = false;
kono
parents:
diff changeset
606 switch (ob_fcode)
kono
parents:
diff changeset
607 {
kono
parents:
diff changeset
608 /* For all these the low level builtin needs an additional flags parameter. */
kono
parents:
diff changeset
609 case S390_OVERLOADED_BUILTIN_s390_vec_find_any_eq_idx:
kono
parents:
diff changeset
610 case S390_OVERLOADED_BUILTIN_s390_vec_find_any_ne_idx:
kono
parents:
diff changeset
611 case S390_OVERLOADED_BUILTIN_s390_vec_find_any_eq_or_0_idx:
kono
parents:
diff changeset
612 case S390_OVERLOADED_BUILTIN_s390_vec_find_any_ne_or_0_idx:
kono
parents:
diff changeset
613 case S390_OVERLOADED_BUILTIN_s390_vec_find_any_eq:
kono
parents:
diff changeset
614 case S390_OVERLOADED_BUILTIN_s390_vec_find_any_ne:
kono
parents:
diff changeset
615 case S390_OVERLOADED_BUILTIN_s390_vec_find_any_eq_idx_cc:
kono
parents:
diff changeset
616 case S390_OVERLOADED_BUILTIN_s390_vec_find_any_ne_idx_cc:
kono
parents:
diff changeset
617 case S390_OVERLOADED_BUILTIN_s390_vec_find_any_eq_or_0_idx_cc:
kono
parents:
diff changeset
618 case S390_OVERLOADED_BUILTIN_s390_vec_find_any_ne_or_0_idx_cc:
kono
parents:
diff changeset
619 case S390_OVERLOADED_BUILTIN_s390_vec_find_any_eq_cc:
kono
parents:
diff changeset
620 case S390_OVERLOADED_BUILTIN_s390_vec_find_any_ne_cc:
kono
parents:
diff changeset
621 if (dest_arg_index == 2)
kono
parents:
diff changeset
622 {
kono
parents:
diff changeset
623 folded_args->quick_push (build_int_cst (integer_type_node,
kono
parents:
diff changeset
624 s390_get_vstring_flags (ob_fcode)));
kono
parents:
diff changeset
625 arg_assigned_p = true;
kono
parents:
diff changeset
626 }
kono
parents:
diff changeset
627 break;
kono
parents:
diff changeset
628 case S390_OVERLOADED_BUILTIN_s390_vec_cmprg_idx:
kono
parents:
diff changeset
629 case S390_OVERLOADED_BUILTIN_s390_vec_cmpnrg_idx:
kono
parents:
diff changeset
630 case S390_OVERLOADED_BUILTIN_s390_vec_cmprg_or_0_idx:
kono
parents:
diff changeset
631 case S390_OVERLOADED_BUILTIN_s390_vec_cmpnrg_or_0_idx:
kono
parents:
diff changeset
632 case S390_OVERLOADED_BUILTIN_s390_vec_cmprg:
kono
parents:
diff changeset
633 case S390_OVERLOADED_BUILTIN_s390_vec_cmpnrg:
kono
parents:
diff changeset
634 case S390_OVERLOADED_BUILTIN_s390_vec_cmprg_idx_cc:
kono
parents:
diff changeset
635 case S390_OVERLOADED_BUILTIN_s390_vec_cmpnrg_idx_cc:
kono
parents:
diff changeset
636 case S390_OVERLOADED_BUILTIN_s390_vec_cmprg_or_0_idx_cc:
kono
parents:
diff changeset
637 case S390_OVERLOADED_BUILTIN_s390_vec_cmpnrg_or_0_idx_cc:
kono
parents:
diff changeset
638 case S390_OVERLOADED_BUILTIN_s390_vec_cmprg_cc:
kono
parents:
diff changeset
639 case S390_OVERLOADED_BUILTIN_s390_vec_cmpnrg_cc:
kono
parents:
diff changeset
640 if (dest_arg_index == 3)
kono
parents:
diff changeset
641 {
kono
parents:
diff changeset
642 folded_args->quick_push (build_int_cst (integer_type_node,
kono
parents:
diff changeset
643 s390_get_vstring_flags (ob_fcode)));
kono
parents:
diff changeset
644 arg_assigned_p = true;
kono
parents:
diff changeset
645 }
kono
parents:
diff changeset
646 break;
kono
parents:
diff changeset
647 case S390_OVERLOADED_BUILTIN_s390_vec_sel:
kono
parents:
diff changeset
648 case S390_OVERLOADED_BUILTIN_s390_vec_insert:
kono
parents:
diff changeset
649 case S390_OVERLOADED_BUILTIN_s390_vec_load_len:
kono
parents:
diff changeset
650 /* Swap the first to arguments. It is better to do it here
kono
parents:
diff changeset
651 instead of the header file to avoid operand checking
kono
parents:
diff changeset
652 throwing error messages for a weird operand index. */
kono
parents:
diff changeset
653 if (dest_arg_index < 2)
kono
parents:
diff changeset
654 {
kono
parents:
diff changeset
655 folded_args->quick_push (fully_fold_convert (TREE_VALUE (arg_chain),
kono
parents:
diff changeset
656 (**arglist)[1 - dest_arg_index]));
kono
parents:
diff changeset
657 src_arg_index++;
kono
parents:
diff changeset
658 arg_assigned_p = true;
kono
parents:
diff changeset
659 }
kono
parents:
diff changeset
660 break;
kono
parents:
diff changeset
661 case S390_OVERLOADED_BUILTIN_s390_vec_store_len:
kono
parents:
diff changeset
662 if (dest_arg_index == 1 || dest_arg_index == 2)
kono
parents:
diff changeset
663 {
kono
parents:
diff changeset
664 folded_args->quick_push (fully_fold_convert (TREE_VALUE (arg_chain),
kono
parents:
diff changeset
665 (**arglist)[3 - dest_arg_index]));
kono
parents:
diff changeset
666 src_arg_index++;
kono
parents:
diff changeset
667 arg_assigned_p = true;
kono
parents:
diff changeset
668 }
kono
parents:
diff changeset
669 break;
kono
parents:
diff changeset
670
kono
parents:
diff changeset
671 case S390_OVERLOADED_BUILTIN_s390_vec_load_bndry:
kono
parents:
diff changeset
672 {
kono
parents:
diff changeset
673 int code;
kono
parents:
diff changeset
674 if (dest_arg_index == 1)
kono
parents:
diff changeset
675 {
kono
parents:
diff changeset
676 tree arg = (**arglist)[src_arg_index];
kono
parents:
diff changeset
677
kono
parents:
diff changeset
678 if (TREE_CODE (arg) != INTEGER_CST)
kono
parents:
diff changeset
679 {
kono
parents:
diff changeset
680 error ("constant value required for builtin %qF argument %d",
kono
parents:
diff changeset
681 decl, src_arg_index + 1);
kono
parents:
diff changeset
682 return;
kono
parents:
diff changeset
683 }
kono
parents:
diff changeset
684
kono
parents:
diff changeset
685 switch (tree_to_uhwi (arg))
kono
parents:
diff changeset
686 {
kono
parents:
diff changeset
687 case 64: code = 0; break;
kono
parents:
diff changeset
688 case 128: code = 1; break;
kono
parents:
diff changeset
689 case 256: code = 2; break;
kono
parents:
diff changeset
690 case 512: code = 3; break;
kono
parents:
diff changeset
691 case 1024: code = 4; break;
kono
parents:
diff changeset
692 case 2048: code = 5; break;
kono
parents:
diff changeset
693 case 4096: code = 6; break;
kono
parents:
diff changeset
694 default:
kono
parents:
diff changeset
695 error ("valid values for builtin %qF argument %d are 64, "
kono
parents:
diff changeset
696 "128, 256, 512, 1024, 2048, and 4096", decl,
kono
parents:
diff changeset
697 src_arg_index + 1);
kono
parents:
diff changeset
698 return;
kono
parents:
diff changeset
699 }
kono
parents:
diff changeset
700 folded_args->quick_push (build_int_cst (integer_type_node,
kono
parents:
diff changeset
701 code));
kono
parents:
diff changeset
702 src_arg_index++;
kono
parents:
diff changeset
703 arg_assigned_p = true;
kono
parents:
diff changeset
704 }
kono
parents:
diff changeset
705 }
kono
parents:
diff changeset
706 break;
kono
parents:
diff changeset
707 case S390_OVERLOADED_BUILTIN_s390_vec_rl_mask:
kono
parents:
diff changeset
708 /* Duplicate the first src arg. */
kono
parents:
diff changeset
709 if (dest_arg_index == 0)
kono
parents:
diff changeset
710 {
kono
parents:
diff changeset
711 folded_args->quick_push (fully_fold_convert (TREE_VALUE (arg_chain),
kono
parents:
diff changeset
712 (**arglist)[src_arg_index]));
kono
parents:
diff changeset
713 arg_assigned_p = true;
kono
parents:
diff changeset
714 }
kono
parents:
diff changeset
715 break;
kono
parents:
diff changeset
716 default:
kono
parents:
diff changeset
717 break;
kono
parents:
diff changeset
718 }
kono
parents:
diff changeset
719 if (!arg_assigned_p)
kono
parents:
diff changeset
720 {
kono
parents:
diff changeset
721 folded_args->quick_push (fully_fold_convert (TREE_VALUE (arg_chain),
kono
parents:
diff changeset
722 (**arglist)[src_arg_index]));
kono
parents:
diff changeset
723 src_arg_index++;
kono
parents:
diff changeset
724 }
kono
parents:
diff changeset
725 }
kono
parents:
diff changeset
726 *arglist = folded_args;
kono
parents:
diff changeset
727 }
kono
parents:
diff changeset
728
kono
parents:
diff changeset
729 /* Check whether the arguments in ARGLIST match the function type
kono
parents:
diff changeset
730 DEF_TYPE. Return the number of argument types which required
kono
parents:
diff changeset
731 conversion/promotion in order to make it match.
kono
parents:
diff changeset
732 0 stands for a perfect match - all operand types match without changes
kono
parents:
diff changeset
733 INT_MAX stands for a mismatch. */
kono
parents:
diff changeset
734 static int
kono
parents:
diff changeset
735 s390_fn_types_compatible (enum s390_builtin_ov_type_index typeindex,
kono
parents:
diff changeset
736 vec<tree, va_gc> *arglist)
kono
parents:
diff changeset
737 {
kono
parents:
diff changeset
738 unsigned int i;
kono
parents:
diff changeset
739 int match_type = 0;
kono
parents:
diff changeset
740
kono
parents:
diff changeset
741 for (i = 0; i < vec_safe_length (arglist); i++)
kono
parents:
diff changeset
742 {
kono
parents:
diff changeset
743 tree b_arg_type = s390_builtin_types[s390_builtin_ov_types[typeindex][i + 1]];
kono
parents:
diff changeset
744 tree in_arg = (*arglist)[i];
kono
parents:
diff changeset
745 tree in_type = TREE_TYPE (in_arg);
kono
parents:
diff changeset
746
kono
parents:
diff changeset
747 if (TREE_CODE (b_arg_type) == VECTOR_TYPE)
kono
parents:
diff changeset
748 {
kono
parents:
diff changeset
749 /* Vector types have to match precisely. */
kono
parents:
diff changeset
750 if (b_arg_type != in_type
kono
parents:
diff changeset
751 && TYPE_MAIN_VARIANT (b_arg_type) != TYPE_MAIN_VARIANT (in_type))
kono
parents:
diff changeset
752 goto mismatch;
kono
parents:
diff changeset
753 }
kono
parents:
diff changeset
754
kono
parents:
diff changeset
755 if (lang_hooks.types_compatible_p (in_type, b_arg_type))
kono
parents:
diff changeset
756 continue;
kono
parents:
diff changeset
757
kono
parents:
diff changeset
758 if (lang_hooks.types_compatible_p (
kono
parents:
diff changeset
759 lang_hooks.types.type_promotes_to (in_type),
kono
parents:
diff changeset
760 lang_hooks.types.type_promotes_to (b_arg_type)))
kono
parents:
diff changeset
761 {
kono
parents:
diff changeset
762 match_type++;
kono
parents:
diff changeset
763 continue;
kono
parents:
diff changeset
764 }
kono
parents:
diff changeset
765
kono
parents:
diff changeset
766 /* In this stage the C++ frontend would go ahead trying to find
kono
parents:
diff changeset
767 implicit conversion chains for the argument to match the
kono
parents:
diff changeset
768 target type. We will mimic this here only for our limited
kono
parents:
diff changeset
769 subset of argument types. */
kono
parents:
diff changeset
770 if (TREE_CODE (b_arg_type) == INTEGER_TYPE
kono
parents:
diff changeset
771 && TREE_CODE (in_type) == INTEGER_TYPE)
kono
parents:
diff changeset
772 {
kono
parents:
diff changeset
773 match_type++;
kono
parents:
diff changeset
774 continue;
kono
parents:
diff changeset
775 }
kono
parents:
diff changeset
776
kono
parents:
diff changeset
777 /* If the incoming pointer argument has more qualifiers than the
kono
parents:
diff changeset
778 argument type it can still be an imperfect match. */
kono
parents:
diff changeset
779 if (POINTER_TYPE_P (b_arg_type) && POINTER_TYPE_P (in_type)
kono
parents:
diff changeset
780 && !(TYPE_QUALS (TREE_TYPE (in_type))
kono
parents:
diff changeset
781 & ~TYPE_QUALS (TREE_TYPE (b_arg_type)))
kono
parents:
diff changeset
782 && (TYPE_QUALS (TREE_TYPE (b_arg_type))
kono
parents:
diff changeset
783 & ~TYPE_QUALS (TREE_TYPE (in_type))))
kono
parents:
diff changeset
784 {
kono
parents:
diff changeset
785 tree qual_in_type =
kono
parents:
diff changeset
786 build_qualified_type (TREE_TYPE (in_type),
kono
parents:
diff changeset
787 TYPE_QUALS (TREE_TYPE (b_arg_type)));
kono
parents:
diff changeset
788
kono
parents:
diff changeset
789 if (lang_hooks.types_compatible_p (qual_in_type,
kono
parents:
diff changeset
790 TREE_TYPE (b_arg_type)))
kono
parents:
diff changeset
791 {
kono
parents:
diff changeset
792 match_type++;
kono
parents:
diff changeset
793 continue;
kono
parents:
diff changeset
794 }
kono
parents:
diff changeset
795 }
kono
parents:
diff changeset
796
kono
parents:
diff changeset
797 mismatch:
kono
parents:
diff changeset
798 if (TARGET_DEBUG_ARG)
kono
parents:
diff changeset
799 fprintf (stderr, " mismatch in operand: %d\n", i + 1);
kono
parents:
diff changeset
800 return INT_MAX;
kono
parents:
diff changeset
801 }
kono
parents:
diff changeset
802
kono
parents:
diff changeset
803 return match_type;
kono
parents:
diff changeset
804 }
kono
parents:
diff changeset
805
kono
parents:
diff changeset
806 /* Return the number of elements in the vector arguments of FNDECL in
kono
parents:
diff changeset
807 case all it matches for all vector arguments, -1 otherwise. */
kono
parents:
diff changeset
808 static int
kono
parents:
diff changeset
809 s390_vec_n_elem (tree fndecl)
kono
parents:
diff changeset
810 {
kono
parents:
diff changeset
811 tree b_arg_chain;
kono
parents:
diff changeset
812 int n_elem = -1;
kono
parents:
diff changeset
813
kono
parents:
diff changeset
814 if (TREE_CODE (TREE_TYPE (TREE_TYPE (fndecl))) == VECTOR_TYPE)
kono
parents:
diff changeset
815 n_elem = TYPE_VECTOR_SUBPARTS (TREE_TYPE (TREE_TYPE ((fndecl))));
kono
parents:
diff changeset
816
kono
parents:
diff changeset
817 for (b_arg_chain = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
kono
parents:
diff changeset
818 !VOID_TYPE_P (TREE_VALUE (b_arg_chain));
kono
parents:
diff changeset
819 b_arg_chain = TREE_CHAIN (b_arg_chain))
kono
parents:
diff changeset
820 {
kono
parents:
diff changeset
821 int tmp_n_elem;
kono
parents:
diff changeset
822 if (TREE_CODE (TREE_VALUE (b_arg_chain)) != VECTOR_TYPE)
kono
parents:
diff changeset
823 continue;
kono
parents:
diff changeset
824 tmp_n_elem = TYPE_VECTOR_SUBPARTS (TREE_VALUE (b_arg_chain));
kono
parents:
diff changeset
825 if (n_elem != -1 && n_elem != tmp_n_elem)
kono
parents:
diff changeset
826 return -1;
kono
parents:
diff changeset
827 n_elem = tmp_n_elem;
kono
parents:
diff changeset
828 }
kono
parents:
diff changeset
829 return n_elem;
kono
parents:
diff changeset
830 }
kono
parents:
diff changeset
831
kono
parents:
diff changeset
832
kono
parents:
diff changeset
833 /* Return a tree expression for a call to the overloaded builtin
kono
parents:
diff changeset
834 function OB_FNDECL at LOC with arguments PASSED_ARGLIST. */
kono
parents:
diff changeset
835 tree
kono
parents:
diff changeset
836 s390_resolve_overloaded_builtin (location_t loc,
kono
parents:
diff changeset
837 tree ob_fndecl,
kono
parents:
diff changeset
838 void *passed_arglist)
kono
parents:
diff changeset
839 {
kono
parents:
diff changeset
840 vec<tree, va_gc> *arglist = static_cast<vec<tree, va_gc> *> (passed_arglist);
kono
parents:
diff changeset
841 unsigned int in_args_num = vec_safe_length (arglist);
kono
parents:
diff changeset
842 unsigned int ob_args_num = 0;
kono
parents:
diff changeset
843 unsigned int ob_fcode = DECL_FUNCTION_CODE (ob_fndecl);
kono
parents:
diff changeset
844 enum s390_overloaded_builtin_vars bindex;
kono
parents:
diff changeset
845 unsigned int i;
kono
parents:
diff changeset
846 int last_match_type = INT_MAX;
kono
parents:
diff changeset
847 int last_match_index = -1;
kono
parents:
diff changeset
848 unsigned int all_op_flags;
kono
parents:
diff changeset
849 const unsigned int ob_flags = bflags_for_builtin(ob_fcode);
kono
parents:
diff changeset
850 int num_matches = 0;
kono
parents:
diff changeset
851 tree target_builtin_decl, b_arg_chain, return_type;
kono
parents:
diff changeset
852 enum s390_builtin_ov_type_index last_match_fntype_index = BT_OV_MAX;
kono
parents:
diff changeset
853
kono
parents:
diff changeset
854 if (TARGET_DEBUG_ARG)
kono
parents:
diff changeset
855 fprintf (stderr,
kono
parents:
diff changeset
856 "s390_resolve_overloaded_builtin, code = %4d, %s - %s overloaded\n",
kono
parents:
diff changeset
857 (int)ob_fcode, IDENTIFIER_POINTER (DECL_NAME (ob_fndecl)),
kono
parents:
diff changeset
858 ob_fcode < S390_BUILTIN_MAX ? "not" : "");
kono
parents:
diff changeset
859
kono
parents:
diff changeset
860 /* 0...S390_BUILTIN_MAX-1 is for non-overloaded builtins. */
kono
parents:
diff changeset
861 if (ob_fcode < S390_BUILTIN_MAX)
kono
parents:
diff changeset
862 {
kono
parents:
diff changeset
863 if (ob_flags & B_INT)
kono
parents:
diff changeset
864 {
kono
parents:
diff changeset
865 error_at (loc,
kono
parents:
diff changeset
866 "builtin %qF is for GCC internal use only.",
kono
parents:
diff changeset
867 ob_fndecl);
kono
parents:
diff changeset
868 return error_mark_node;
kono
parents:
diff changeset
869 }
kono
parents:
diff changeset
870 return NULL_TREE;
kono
parents:
diff changeset
871 }
kono
parents:
diff changeset
872
kono
parents:
diff changeset
873 if (ob_flags & B_DEP)
kono
parents:
diff changeset
874 warning_at (loc, 0, "builtin %qF is deprecated.", ob_fndecl);
kono
parents:
diff changeset
875
kono
parents:
diff changeset
876 if (!TARGET_VX && (ob_flags & B_VX))
kono
parents:
diff changeset
877 {
kono
parents:
diff changeset
878 error_at (loc, "%qF requires -mvx", ob_fndecl);
kono
parents:
diff changeset
879 return error_mark_node;
kono
parents:
diff changeset
880 }
kono
parents:
diff changeset
881
kono
parents:
diff changeset
882 if (!TARGET_VXE && (ob_flags & B_VXE))
kono
parents:
diff changeset
883 {
kono
parents:
diff changeset
884 error_at (loc, "%qF requires z14 or higher", ob_fndecl);
kono
parents:
diff changeset
885 return error_mark_node;
kono
parents:
diff changeset
886 }
kono
parents:
diff changeset
887
kono
parents:
diff changeset
888 ob_fcode -= S390_BUILTIN_MAX;
kono
parents:
diff changeset
889
kono
parents:
diff changeset
890 for (b_arg_chain = TYPE_ARG_TYPES (TREE_TYPE (ob_fndecl));
kono
parents:
diff changeset
891 !VOID_TYPE_P (TREE_VALUE (b_arg_chain));
kono
parents:
diff changeset
892 b_arg_chain = TREE_CHAIN (b_arg_chain))
kono
parents:
diff changeset
893 ob_args_num++;
kono
parents:
diff changeset
894
kono
parents:
diff changeset
895 if (ob_args_num != in_args_num)
kono
parents:
diff changeset
896 {
kono
parents:
diff changeset
897 error_at (loc,
kono
parents:
diff changeset
898 "mismatch in number of arguments for builtin %qF. "
kono
parents:
diff changeset
899 "Expected: %d got %d", ob_fndecl,
kono
parents:
diff changeset
900 ob_args_num, in_args_num);
kono
parents:
diff changeset
901 return error_mark_node;
kono
parents:
diff changeset
902 }
kono
parents:
diff changeset
903
kono
parents:
diff changeset
904 for (i = 0; i < in_args_num; i++)
kono
parents:
diff changeset
905 if ((*arglist)[i] == error_mark_node)
kono
parents:
diff changeset
906 return error_mark_node;
kono
parents:
diff changeset
907
kono
parents:
diff changeset
908 /* Overloaded builtins without any variants are directly expanded here. */
kono
parents:
diff changeset
909 if (desc_start_for_overloaded_builtin[ob_fcode] ==
kono
parents:
diff changeset
910 S390_OVERLOADED_BUILTIN_VAR_MAX)
kono
parents:
diff changeset
911 return s390_expand_overloaded_builtin (loc, ob_fcode, arglist, NULL_TREE);
kono
parents:
diff changeset
912
kono
parents:
diff changeset
913 for (bindex = desc_start_for_overloaded_builtin[ob_fcode];
kono
parents:
diff changeset
914 bindex <= desc_end_for_overloaded_builtin[ob_fcode];
kono
parents:
diff changeset
915 bindex = (enum s390_overloaded_builtin_vars)((int)bindex + 1))
kono
parents:
diff changeset
916 {
kono
parents:
diff changeset
917 int match_type;
kono
parents:
diff changeset
918 enum s390_builtin_ov_type_index type_index =
kono
parents:
diff changeset
919 type_for_overloaded_builtin_var[bindex];
kono
parents:
diff changeset
920
kono
parents:
diff changeset
921 if (TARGET_DEBUG_ARG)
kono
parents:
diff changeset
922 fprintf (stderr, "checking variant number: %d", (int)bindex);
kono
parents:
diff changeset
923
kono
parents:
diff changeset
924 match_type = s390_fn_types_compatible (type_index, arglist);
kono
parents:
diff changeset
925
kono
parents:
diff changeset
926 if (match_type == INT_MAX)
kono
parents:
diff changeset
927 continue;
kono
parents:
diff changeset
928
kono
parents:
diff changeset
929 if (TARGET_DEBUG_ARG)
kono
parents:
diff changeset
930 fprintf (stderr,
kono
parents:
diff changeset
931 " %s match score: %d\n", match_type == 0 ? "perfect" : "imperfect",
kono
parents:
diff changeset
932 match_type);
kono
parents:
diff changeset
933
kono
parents:
diff changeset
934 if (match_type < last_match_type)
kono
parents:
diff changeset
935 {
kono
parents:
diff changeset
936 num_matches = 1;
kono
parents:
diff changeset
937 last_match_type = match_type;
kono
parents:
diff changeset
938 last_match_fntype_index = type_index;
kono
parents:
diff changeset
939 last_match_index = bindex;
kono
parents:
diff changeset
940 }
kono
parents:
diff changeset
941 else if (match_type == last_match_type)
kono
parents:
diff changeset
942 num_matches++;
kono
parents:
diff changeset
943 }
kono
parents:
diff changeset
944
kono
parents:
diff changeset
945 if (last_match_type == INT_MAX)
kono
parents:
diff changeset
946 {
kono
parents:
diff changeset
947 error_at (loc, "invalid parameter combination for intrinsic %qs",
kono
parents:
diff changeset
948 IDENTIFIER_POINTER (DECL_NAME (ob_fndecl)));
kono
parents:
diff changeset
949 return error_mark_node;
kono
parents:
diff changeset
950 }
kono
parents:
diff changeset
951 else if (num_matches > 1)
kono
parents:
diff changeset
952 {
kono
parents:
diff changeset
953 error_at (loc, "ambiguous overload for intrinsic %qs",
kono
parents:
diff changeset
954 IDENTIFIER_POINTER (DECL_NAME (ob_fndecl)));
kono
parents:
diff changeset
955 return error_mark_node;
kono
parents:
diff changeset
956 }
kono
parents:
diff changeset
957
kono
parents:
diff changeset
958 if (!TARGET_VXE
kono
parents:
diff changeset
959 && bflags_overloaded_builtin_var[last_match_index] & B_VXE)
kono
parents:
diff changeset
960 {
kono
parents:
diff changeset
961 error_at (loc, "%qs matching variant requires z14 or higher",
kono
parents:
diff changeset
962 IDENTIFIER_POINTER (DECL_NAME (ob_fndecl)));
kono
parents:
diff changeset
963 return error_mark_node;
kono
parents:
diff changeset
964 }
kono
parents:
diff changeset
965
kono
parents:
diff changeset
966 if (bflags_overloaded_builtin_var[last_match_index] & B_DEP)
kono
parents:
diff changeset
967 warning_at (loc, 0, "%qs matching variant is deprecated.",
kono
parents:
diff changeset
968 IDENTIFIER_POINTER (DECL_NAME (ob_fndecl)));
kono
parents:
diff changeset
969
kono
parents:
diff changeset
970 /* Overloaded variants which have MAX set as low level builtin are
kono
parents:
diff changeset
971 supposed to be replaced during expansion with something else. */
kono
parents:
diff changeset
972 if (bt_for_overloaded_builtin_var[last_match_index] == S390_BUILTIN_MAX)
kono
parents:
diff changeset
973 target_builtin_decl = ob_fndecl;
kono
parents:
diff changeset
974 else
kono
parents:
diff changeset
975 target_builtin_decl = s390_builtin_decls[bt_for_overloaded_builtin_var[last_match_index]];
kono
parents:
diff changeset
976
kono
parents:
diff changeset
977 all_op_flags = opflags_overloaded_builtin_var[last_match_index];
kono
parents:
diff changeset
978 return_type = s390_builtin_types[s390_builtin_ov_types[last_match_fntype_index][0]];
kono
parents:
diff changeset
979
kono
parents:
diff changeset
980 /* Check for the operand flags in the overloaded builtin variant. */
kono
parents:
diff changeset
981 for (i = 0; i < ob_args_num; i++)
kono
parents:
diff changeset
982 {
kono
parents:
diff changeset
983 unsigned int op_flags = all_op_flags & ((1 << O_SHIFT) - 1);
kono
parents:
diff changeset
984 tree arg = (*arglist)[i];
kono
parents:
diff changeset
985 tree type = s390_builtin_types[s390_builtin_ov_types[last_match_fntype_index][i + 1]];
kono
parents:
diff changeset
986
kono
parents:
diff changeset
987 all_op_flags = all_op_flags >> O_SHIFT;
kono
parents:
diff changeset
988
kono
parents:
diff changeset
989 if (op_flags == O_ELEM)
kono
parents:
diff changeset
990 {
kono
parents:
diff changeset
991 int n_elem = s390_vec_n_elem (target_builtin_decl);
kono
parents:
diff changeset
992 gcc_assert (n_elem > 0);
kono
parents:
diff changeset
993 gcc_assert (type == integer_type_node);
kono
parents:
diff changeset
994 (*arglist)[i] = build2 (BIT_AND_EXPR, integer_type_node,
kono
parents:
diff changeset
995 fold_convert (integer_type_node, arg),
kono
parents:
diff changeset
996 build_int_cst (NULL_TREE, n_elem - 1));
kono
parents:
diff changeset
997 }
kono
parents:
diff changeset
998
kono
parents:
diff changeset
999 if (TREE_CODE (arg) != INTEGER_CST || !O_IMM_P (op_flags))
kono
parents:
diff changeset
1000 continue;
kono
parents:
diff changeset
1001
kono
parents:
diff changeset
1002 if ((TYPE_UNSIGNED (type)
kono
parents:
diff changeset
1003 && !int_fits_type_p (arg, c_common_unsigned_type (type)))
kono
parents:
diff changeset
1004 || (!TYPE_UNSIGNED (type)
kono
parents:
diff changeset
1005 && !int_fits_type_p (arg, c_common_signed_type (type))))
kono
parents:
diff changeset
1006 {
kono
parents:
diff changeset
1007 error("constant argument %d for builtin %qF is out "
kono
parents:
diff changeset
1008 "of range for target type",
kono
parents:
diff changeset
1009 i + 1, target_builtin_decl);
kono
parents:
diff changeset
1010 return error_mark_node;
kono
parents:
diff changeset
1011 }
kono
parents:
diff changeset
1012
kono
parents:
diff changeset
1013 if (TREE_CODE (arg) == INTEGER_CST
kono
parents:
diff changeset
1014 && !s390_const_operand_ok (arg, i + 1, op_flags, target_builtin_decl))
kono
parents:
diff changeset
1015 return error_mark_node;
kono
parents:
diff changeset
1016 }
kono
parents:
diff changeset
1017
kono
parents:
diff changeset
1018 /* Handle builtins we expand directly - without mapping it to a low
kono
parents:
diff changeset
1019 level builtin. */
kono
parents:
diff changeset
1020 if (bt_for_overloaded_builtin_var[last_match_index] == S390_BUILTIN_MAX)
kono
parents:
diff changeset
1021 return s390_expand_overloaded_builtin (loc, ob_fcode, arglist, return_type);
kono
parents:
diff changeset
1022
kono
parents:
diff changeset
1023 s390_adjust_builtin_arglist (ob_fcode, target_builtin_decl, &arglist);
kono
parents:
diff changeset
1024
kono
parents:
diff changeset
1025 if (VOID_TYPE_P (return_type))
kono
parents:
diff changeset
1026 return build_function_call_vec (loc, vNULL, target_builtin_decl,
kono
parents:
diff changeset
1027 arglist, NULL);
kono
parents:
diff changeset
1028 else
kono
parents:
diff changeset
1029 return fully_fold_convert (return_type,
kono
parents:
diff changeset
1030 build_function_call_vec (loc, vNULL, target_builtin_decl,
kono
parents:
diff changeset
1031 arglist, NULL));
kono
parents:
diff changeset
1032 }
kono
parents:
diff changeset
1033
kono
parents:
diff changeset
1034 /* This is used to define the REGISTER_TARGET_PRAGMAS macro in s390.h. */
kono
parents:
diff changeset
1035 void
kono
parents:
diff changeset
1036 s390_register_target_pragmas (void)
kono
parents:
diff changeset
1037 {
kono
parents:
diff changeset
1038 targetm.resolve_overloaded_builtin = s390_resolve_overloaded_builtin;
kono
parents:
diff changeset
1039 #if S390_USE_TARGET_ATTRIBUTE
kono
parents:
diff changeset
1040 /* Update pragma hook to allow parsing #pragma GCC target. */
kono
parents:
diff changeset
1041 targetm.target_option.pragma_parse = s390_pragma_target_parse;
kono
parents:
diff changeset
1042 #endif
kono
parents:
diff changeset
1043 }